Skip to content

Commit 12a447f

Browse files
authored
feat: add adk-py@ shortcut for google/adk-python contributing samples (#918)
Add a new shortcut pattern `adk-py@<sample-name>` that maps to `https://github.com/google/adk-python/tree/main/contributing/samples/<sample-name>`. This allows users to create projects from ADK Python contributing samples using a concise syntax, e.g.: uvx agent-starter-pack create -a adk-py@code-execution instead of the full URL: uvx agent-starter-pack create -a https://github.com/google/adk-python/tree/main/contributing/samples/code-execution
1 parent 07ab369 commit 12a447f

5 files changed

Lines changed: 43 additions & 3 deletions

File tree

agent_starter_pack/cli/commands/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def normalize_project_name(project_name: str) -> str:
265265
@click.option(
266266
"--agent",
267267
"-a",
268-
help="Template identifier to use. Can be a local agent name (e.g., `chat_agent`), a local path (`local@/path/to/template`), an `adk-samples` shortcut (e.g., `adk@data-science`), or a remote Git URL. Both shorthand (e.g., `github.com/org/repo/path@main`) and full URLs from your browser (e.g., `https://github.com/org/repo/tree/main/path`) are supported. Lists available local templates if omitted.",
268+
help="Template identifier to use. Can be a local agent name (e.g., `chat_agent`), a local path (`local@/path/to/template`), an `adk-samples` shortcut (e.g., `adk@data-science`), an `adk-python` shortcut (e.g., `adk-py@code-execution`), or a remote Git URL. Both shorthand (e.g., `github.com/org/repo/path@main`) and full URLs from your browser (e.g., `https://github.com/org/repo/tree/main/path`) are supported. Lists available local templates if omitted.",
269269
)
270270
@click.option(
271271
"--output-dir",

agent_starter_pack/cli/commands/enhance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ def enhance(
10441044
TEMPLATE_PATH can be:
10451045
- A local directory path (e.g., . for current directory)
10461046
- An agent name (e.g., adk)
1047-
- A remote template (e.g., adk@data-science)
1047+
- A remote template (e.g., adk@data-science, adk-py@code-execution)
10481048
10491049
The command will validate your project structure and provide guidance if needed.
10501050
"""

agent_starter_pack/cli/utils/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def display_welcome_banner(
128128
version=version,
129129
motto=motto,
130130
)
131-
elif agent and agent.startswith("adk@"):
131+
elif agent and (agent.startswith("adk@") or agent.startswith("adk-py@")):
132132
panel = _build_banner(
133133
line1=(
134134
"Powered by [link=https://goo.gle/agent-starter-pack]"

agent_starter_pack/cli/utils/remote_template.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ def parse_agent_spec(agent_spec: str) -> RemoteTemplateSpec | None:
6565
is_adk_samples=True,
6666
)
6767

68+
# Check for adk-py@ shortcut (maps to google/adk-python contributing samples)
69+
if agent_spec.startswith("adk-py@"):
70+
sample_name = agent_spec[7:] # Remove "adk-py@" prefix
71+
return RemoteTemplateSpec(
72+
repo_url="https://github.com/google/adk-python",
73+
template_path=f"contributing/samples/{sample_name}",
74+
git_ref="main",
75+
is_adk_samples=True,
76+
)
77+
6878
# GitHub /tree/ URL pattern
6979
tree_pattern = r"^(https?://[^/]+/[^/]+/[^/]+)/tree/([^/]+)/(.*)$"
7080
match = re.match(tree_pattern, agent_spec)

tests/cli/utils/test_remote_template.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ def test_parse_adk_shortcut(self) -> None:
6969
assert spec.git_ref == "main"
7070
assert spec.is_adk_samples is True
7171

72+
def test_parse_adk_py_shortcut(self) -> None:
73+
"""Test parsing ADK Python shortcut format"""
74+
spec = parse_agent_spec("adk-py@code-execution")
75+
assert spec is not None
76+
assert spec.repo_url == "https://github.com/google/adk-python"
77+
assert spec.template_path == "contributing/samples/code-execution"
78+
assert spec.git_ref == "main"
79+
assert spec.is_adk_samples is True
80+
81+
def test_parse_adk_py_shortcut_underscore_name(self) -> None:
82+
"""Test parsing ADK Python shortcut with underscore name"""
83+
spec = parse_agent_spec("adk-py@agent_engine_code_execution")
84+
assert spec is not None
85+
assert spec.repo_url == "https://github.com/google/adk-python"
86+
assert spec.template_path == "contributing/samples/agent_engine_code_execution"
87+
assert spec.git_ref == "main"
88+
assert spec.is_adk_samples is True
89+
7290
def test_parse_full_url_with_path_and_ref(self) -> None:
7391
"""Test parsing full URL with path and ref"""
7492
spec = parse_agent_spec("https://github.com/org/repo/path/to/template@develop")
@@ -504,6 +522,9 @@ def test_template_validation_scenarios(self) -> None:
504522
# ADK samples
505523
("adk@academic-research", True),
506524
("adk@custom-agent", True),
525+
# ADK Python samples
526+
("adk-py@code-execution", True),
527+
("adk-py@agent_engine_code_execution", True),
507528
# GitHub URLs
508529
("https://github.com/org/repo", True),
509530
("https://github.com/org/repo/path@branch", True),
@@ -585,6 +606,15 @@ def test_parse_adk_shortcut_not_affected(self) -> None:
585606
assert spec.git_ref == "main"
586607
assert spec.is_adk_samples is True
587608

609+
def test_parse_adk_py_shortcut_not_affected(self) -> None:
610+
"""Ensure the adk-py@ shortcut remains unaffected."""
611+
spec = parse_agent_spec("adk-py@code-execution")
612+
assert spec is not None
613+
assert spec.repo_url == "https://github.com/google/adk-python"
614+
assert spec.template_path == "contributing/samples/code-execution"
615+
assert spec.git_ref == "main"
616+
assert spec.is_adk_samples is True
617+
588618
def test_parse_github_shorthand_not_affected(self) -> None:
589619
"""Ensure GitHub shorthand parsing remains unaffected."""
590620
spec = parse_agent_spec("org/repo")

0 commit comments

Comments
 (0)