Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agent_starter_pack/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def create(
from ..utils.remote_template import check_and_execute_with_version_lock

if check_and_execute_with_version_lock(
template_source_path, agent, locked
template_source_path, agent, locked, project_name
):
# If we executed with locked version, cleanup and exit
shutil.rmtree(temp_dir, ignore_errors=True)
Expand All @@ -495,7 +495,7 @@ def create(
else:
console.print(f"Fetching remote template: {agent}")
template_source_path, temp_dir_path = fetch_remote_template(
remote_spec, agent, locked
remote_spec, agent, locked, project_name
)
temp_dir_to_clean = str(temp_dir_path)
selected_agent = f"remote_{hash(agent)}" # Generate unique name for remote template
Expand Down Expand Up @@ -566,7 +566,7 @@ def create(
else:
console.print(f"Fetching remote template: {agent}")
template_source_path, temp_dir_path = fetch_remote_template(
remote_spec, agent, locked
remote_spec, agent, locked, project_name
)
temp_dir_to_clean = str(temp_dir_path)
final_agent = f"remote_{hash(agent)}" # Generate unique name for remote template
Expand Down
21 changes: 20 additions & 1 deletion agent_starter_pack/cli/utils/remote_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ def check_and_execute_with_version_lock(
template_dir: pathlib.Path,
original_agent_spec: str | None = None,
locked: bool = False,
project_name: str | None = None,
) -> bool:
"""Check if remote template has agent-starter-pack version lock and execute if found.

Args:
template_dir: Path to the fetched template directory
original_agent_spec: The original agent spec (remote URL) to replace with local path
locked: Whether this is already a locked execution (prevents recursion)
project_name: Project name (may have been entered interactively)

Returns:
True if version lock was found and executed, False otherwise
Expand Down Expand Up @@ -181,6 +183,21 @@ def check_and_execute_with_version_lock(
# Agent was selected interactively, add --agent flag
original_args.extend(["--agent", f"local@{template_dir}"])

# Add project_name if provided interactively (not in original args)
if project_name:
# Check if project_name is already in the args (as positional argument)
# The create command signature is: create [PROJECT_NAME] [OPTIONS]
# If project_name was provided via CLI, it would be in sys.argv
# We check by looking for it in the original sys.argv
if project_name not in sys.argv:
# Insert project_name as first positional argument after 'create'
if "create" in original_args:
create_idx = original_args.index("create")
original_args.insert(create_idx + 1, project_name)
else:
# 'create' might not be in args if invoked directly
original_args.insert(0, project_name)

# Add version lock flags only for ASP versions 0.14.1 and above
if pkg_version.parse(version) > pkg_version.parse("0.14.1"):
original_args.extend(["--skip-welcome", "--locked"])
Expand Down Expand Up @@ -228,6 +245,7 @@ def fetch_remote_template(
spec: RemoteTemplateSpec,
original_agent_spec: str | None = None,
locked: bool = False,
project_name: str | None = None,
) -> tuple[pathlib.Path, pathlib.Path]:
"""Fetch remote template and return path to template directory.

Expand All @@ -238,6 +256,7 @@ def fetch_remote_template(
spec: Remote template specification
original_agent_spec: Original agent spec string (used to prevent recursion)
locked: Whether this is already a locked execution (prevents recursion)
project_name: Project name (may have been entered interactively)

Returns:
A tuple containing:
Expand Down Expand Up @@ -328,7 +347,7 @@ def fetch_remote_template(

# Check for version lock and execute nested command if found
if check_and_execute_with_version_lock(
template_dir, original_agent_spec, locked
template_dir, original_agent_spec, locked, project_name
):
# If we executed with locked version, the nested process will handle everything
# Clean up and exit successfully
Expand Down