|
6 | 6 |
|
7 | 7 | from pathlib import Path |
8 | 8 | from importlib import resources |
9 | | -from importlib.resources import files as _pkg_files |
10 | 9 |
|
11 | 10 | import typer |
12 | 11 | from rich.console import Console |
@@ -84,8 +83,7 @@ def _copy_pkg_tree(pkg_rel: str, dst: Path, force: bool) -> int: |
84 | 83 | """ |
85 | 84 | try: |
86 | 85 | root = ( |
87 | | - _pkg_files("mcp_agent") |
88 | | - .joinpath("data") |
| 86 | + resources.files("mcp_agent.data") |
89 | 87 | .joinpath("examples") |
90 | 88 | .joinpath(pkg_rel) |
91 | 89 | ) |
@@ -164,24 +162,24 @@ def init( |
164 | 162 | templates = {**scaffolding_templates, **example_templates} |
165 | 163 |
|
166 | 164 | # Map template names to their source paths (shared by quickstart and template modes) |
167 | | - # Format: "name": (None, dest_name, pkg_rel) for packaged examples |
| 165 | + # Format: "name": (dest_name, pkg_rel) - all examples are packaged in mcp_agent.data/examples |
168 | 166 | example_map = { |
169 | | - "workflow": (None, "workflow", "workflows"), |
170 | | - "researcher": (None, "researcher", "usecases/mcp_researcher"), |
171 | | - "data-analysis": (None, "data-analysis", "usecases/mcp_financial_analyzer"), |
172 | | - "state-transfer": (None, "state-transfer", "workflows/workflow_router"), |
173 | | - "basic-agent-server": (None, "basic_agent_server", "mcp_agent_server/asyncio"), |
174 | | - "mcp-basic-agent": (None, "mcp_basic_agent", "basic/mcp_basic_agent"), |
175 | | - "token-counter": (None, "token_counter", "basic/token_counter"), |
176 | | - "agent-factory": (None, "agent_factory", "basic/agent_factory"), |
177 | | - "reference-agent-server": (None, "reference_agent_server", "mcp_agent_server/reference"), |
178 | | - "elicitation": (None, "elicitation", "mcp_agent_server/elicitation"), |
179 | | - "sampling": (None, "sampling", "mcp_agent_server/sampling"), |
180 | | - "notifications": (None, "notifications", "mcp_agent_server/notifications"), |
181 | | - "hello-world": (None, "hello_world", "cloud/hello_world"), |
182 | | - "mcp": (None, "mcp", "cloud/mcp"), |
183 | | - "temporal": (None, "temporal", "cloud/temporal"), |
184 | | - "chatgpt-app": (None, "chatgpt_app", "cloud/chatgpt_app"), |
| 167 | + "workflow": ("workflow", "workflows"), |
| 168 | + "researcher": ("researcher", "usecases/mcp_researcher"), |
| 169 | + "data-analysis": ("data-analysis", "usecases/mcp_financial_analyzer"), |
| 170 | + "state-transfer": ("state-transfer", "workflows/workflow_router"), |
| 171 | + "basic-agent-server": ("basic_agent_server", "mcp_agent_server/asyncio"), |
| 172 | + "mcp-basic-agent": ("mcp_basic_agent", "basic/mcp_basic_agent"), |
| 173 | + "token-counter": ("token_counter", "basic/token_counter"), |
| 174 | + "agent-factory": ("agent_factory", "basic/agent_factory"), |
| 175 | + "reference-agent-server": ("reference_agent_server", "mcp_agent_server/reference"), |
| 176 | + "elicitation": ("elicitation", "mcp_agent_server/elicitation"), |
| 177 | + "sampling": ("sampling", "mcp_agent_server/sampling"), |
| 178 | + "notifications": ("notifications", "mcp_agent_server/notifications"), |
| 179 | + "hello-world": ("hello_world", "cloud/hello_world"), |
| 180 | + "mcp": ("mcp", "cloud/mcp"), |
| 181 | + "temporal": ("temporal", "cloud/temporal"), |
| 182 | + "chatgpt-app": ("chatgpt_app", "cloud/chatgpt_app"), |
185 | 183 | } |
186 | 184 |
|
187 | 185 | if list_templates: |
@@ -228,7 +226,7 @@ def init( |
228 | 226 | base_dir = dir.resolve() |
229 | 227 | base_dir.mkdir(parents=True, exist_ok=True) |
230 | 228 |
|
231 | | - _, dst_name, pkg_rel = mapping |
| 229 | + dst_name, pkg_rel = mapping |
232 | 230 | dst = base_dir / dst_name |
233 | 231 | copied = _copy_pkg_tree(pkg_rel, dst, force) |
234 | 232 |
|
@@ -282,7 +280,7 @@ def init( |
282 | 280 | console.print(f"[red]Example template '{template}' not found[/red]") |
283 | 281 | raise typer.Exit(1) |
284 | 282 |
|
285 | | - _, dst_name, pkg_rel = mapping |
| 283 | + dst_name, pkg_rel = mapping |
286 | 284 | dst = dir / dst_name |
287 | 285 | copied = _copy_pkg_tree(pkg_rel, dst, force) |
288 | 286 |
|
|
0 commit comments