Skip to content

Commit e043a58

Browse files
zhujian0805claude
andcommitted
feat: enhance plugin/skill/agent CLI commands
- Make URL optional in fetch commands (agent, skill, plugin) - Without URL: fetches from all configured repos - With URL: fetches and optionally saves specific repo - Add add-repo/remove-repo commands for plugin, skill, agent - Consistent naming: add/remove for CAM config management - install/uninstall for APP (Claude) installation - Enhance plugin info command to show: - Configured marketplaces/plugins (CAM) - Installed marketplaces/plugins (Claude) with enabled status - Restructure plugin marketplace subcommand - Keep only 'update' command for Claude CLI marketplace updates - Remove redundant list command (shown in plugin info) - Fix tests for Typer optional arguments 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a5f5db6 commit e043a58

5 files changed

Lines changed: 460 additions & 233 deletions

File tree

code_assistant_manager/cli/agents_commands.py

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
AgentRepo,
1414
)
1515
from code_assistant_manager.menu.base import Colors
16+
from code_assistant_manager.plugins.fetch import parse_github_url
1617

1718
logger = logging.getLogger(__name__)
1819

@@ -64,10 +65,98 @@ def list_agents():
6465

6566

6667
@agent_app.command("fetch")
67-
def fetch_agents():
68-
"""Fetch agents from configured repositories."""
68+
def fetch_agents(
69+
url: Optional[str] = typer.Argument(
70+
None,
71+
help="GitHub URL or owner/repo to fetch and save (e.g., https://github.com/owner/repo or owner/repo)",
72+
),
73+
save: bool = typer.Option(
74+
False,
75+
"--save",
76+
"-s",
77+
help="Save the fetched repo to config (only used with URL argument)",
78+
),
79+
agents_path: Optional[str] = typer.Option(
80+
None,
81+
"--agents-path",
82+
help="Agents subdirectory path in the repo (only used with URL argument)",
83+
),
84+
):
85+
"""Fetch agents from configured repositories or a specific GitHub URL.
86+
87+
Without URL: Fetches agents from all configured repositories.
88+
With URL: Fetches info from a specific GitHub repo and optionally saves it.
89+
90+
Examples:
91+
cam agent fetch # Fetch from all configured repos
92+
cam agent fetch owner/repo --save # Fetch and save a new repo
93+
cam agent fetch https://github.com/owner/repo --save --agents-path agents
94+
"""
6995
manager = _get_agent_manager()
7096

97+
# If URL provided, fetch from that specific repo
98+
if url:
99+
typer.echo(f"{Colors.CYAN}Fetching repository info...{Colors.RESET}")
100+
101+
# Parse and validate URL
102+
parsed = parse_github_url(url)
103+
if not parsed:
104+
typer.echo(f"{Colors.RED}✗ Invalid GitHub URL: {url}{Colors.RESET}")
105+
raise typer.Exit(1)
106+
107+
owner, repo, branch = parsed
108+
typer.echo(f" Repository: {Colors.BOLD}{owner}/{repo}{Colors.RESET}")
109+
110+
# Display results
111+
typer.echo(f"\n{Colors.BOLD}Repository Information:{Colors.RESET}\n")
112+
typer.echo(f" {Colors.CYAN}Owner:{Colors.RESET} {owner}")
113+
typer.echo(f" {Colors.CYAN}Repo:{Colors.RESET} {repo}")
114+
typer.echo(f" {Colors.CYAN}Branch:{Colors.RESET} {branch}")
115+
if agents_path:
116+
typer.echo(f" {Colors.CYAN}Agents Path:{Colors.RESET} {agents_path}")
117+
118+
# Save if requested
119+
if save:
120+
# Check if already exists
121+
existing_repos = manager.get_repos()
122+
repo_id = f"{owner}/{repo}"
123+
existing = next(
124+
(r for r in existing_repos if f"{r.owner}/{r.name}" == repo_id), None
125+
)
126+
if existing:
127+
typer.echo(
128+
f"\n{Colors.YELLOW}Repository '{repo_id}' already exists in config.{Colors.RESET}"
129+
)
130+
if not typer.confirm("Overwrite?"):
131+
raise typer.Exit(0)
132+
133+
# Create AgentRepo and save
134+
agent_repo = AgentRepo(
135+
owner=owner,
136+
name=repo,
137+
branch=branch,
138+
enabled=True,
139+
agents_path=agents_path,
140+
)
141+
manager.add_repo(agent_repo)
142+
typer.echo(
143+
f"\n{Colors.GREEN}✓ Saved '{repo_id}' to user config{Colors.RESET}"
144+
)
145+
typer.echo(f" Config file: {manager.repos_file}")
146+
147+
# Show next steps
148+
typer.echo(
149+
f"\n{Colors.CYAN}Next:{Colors.RESET} cam agent fetch # to fetch agents from all repos"
150+
)
151+
else:
152+
typer.echo(
153+
f"\n{Colors.CYAN}To save:{Colors.RESET} cam agent fetch '{url}' --save"
154+
)
155+
156+
typer.echo()
157+
return
158+
159+
# No URL provided - fetch from all configured repos
71160
typer.echo(f"{Colors.CYAN}Fetching agents from repositories...{Colors.RESET}")
72161

73162
try:

0 commit comments

Comments
 (0)