Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
50 changes: 37 additions & 13 deletions parallel_web_tools/cli/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,29 @@ def skills() -> None:
"""Install and manage Parallel agent skills.

Downloads come from skills.parallel.ai. Set PARALLEL_SKILLS_INDEX_URL to use a custom index.

Skills install to .agents/skills, and also to .claude/skills when a Claude Code
configuration directory is present, since Claude Code reads only its own directory.
"""
pass

def print_locations(result: dict) -> None:
locations = result["install_dirs"]
label = "Locations" if len(locations) > 1 else "Location"
console.print(f"{label}: [cyan]{', '.join(locations)}[/cyan]")

def print_skipped(result: dict) -> None:
skipped = result.get("skipped_skills") or []
if not skipped:
return

console.print(f"[yellow]Skipped ({len(skipped)}):[/yellow]")
for entry in skipped:
console.print(
f"[yellow] {entry['skill']} — {entry['install_dir']}/{entry['skill']} already exists "
f"and was not installed by parallel-cli, so it was left untouched[/yellow]"
)

@skills.command(name="list")
@click.option("--json", "output_json", is_flag=True, help="Output as JSON")
def skills_list(output_json: bool) -> None:
Expand Down Expand Up @@ -86,13 +106,13 @@ def skills_install(project: bool, skill_names: tuple[str, ...], output_json: boo
SkillsInputError,
SkillsInstallLocationError,
install_skills,
resolve_install_dir,
resolve_install_dirs,
)

try:
install_dir = resolve_install_dir(project=project)
install_dirs = resolve_install_dirs(project=project)
result = install_skills(
install_dir=install_dir,
install_dirs=install_dirs,
selected_skills=list(skill_names) or None,
)
except SkillsInstallLocationError as e:
Expand All @@ -109,9 +129,11 @@ def skills_install(project: bool, skill_names: tuple[str, ...], output_json: boo
return

console.print("[bold green]Skills installed[/bold green]")
console.print(f"Location: [cyan]{result['install_dir']}[/cyan]")
print_locations(result)
console.print(f"Ref: [cyan]{result['ref']}[/cyan]")
console.print(f"Installed ({result['count']}): [cyan]{', '.join(result['installed_skills'])}[/cyan]")
console.print(f"Files written: [cyan]{result['file_count']}[/cyan]")
print_skipped(result)

@skills.command(name="uninstall")
@click.option(
Expand All @@ -122,11 +144,11 @@ def skills_install(project: bool, skill_names: tuple[str, ...], output_json: boo
@click.option("--json", "output_json", is_flag=True, help="Output as JSON")
def skills_uninstall(project: bool, output_json: bool) -> None:
"""Uninstall skills previously installed by parallel-cli."""
from parallel_web_tools.core.skills import SkillsInstallLocationError, resolve_install_dir, uninstall_skills
from parallel_web_tools.core.skills import SkillsInstallLocationError, resolve_install_dirs, uninstall_skills

try:
install_dir = resolve_install_dir(project=project)
result = uninstall_skills(install_dir=install_dir)
install_dirs = resolve_install_dirs(project=project)
result = uninstall_skills(install_dirs=install_dirs)
except SkillsInstallLocationError as e:
handle_error(e, output_json=output_json, exit_code=exit_bad_input, prefix="Skills uninstall failed")
except Exception as e:
Expand All @@ -138,11 +160,11 @@ def skills_uninstall(project: bool, output_json: bool) -> None:

if result["count"] == 0:
console.print("[yellow]No managed skills found to uninstall[/yellow]")
console.print(f"Location: [cyan]{result['install_dir']}[/cyan]")
print_locations(result)
return

console.print("[bold green]Skills uninstalled[/bold green]")
console.print(f"Location: [cyan]{result['install_dir']}[/cyan]")
print_locations(result)
console.print(f"Removed ({result['count']}): [cyan]{', '.join(result['removed_skills'])}[/cyan]")

@skills.command(name="reinstall")
Expand All @@ -169,13 +191,13 @@ def skills_reinstall(project: bool, skill_names: tuple[str, ...], output_json: b
SkillsInputError,
SkillsInstallLocationError,
reinstall_skills,
resolve_install_dir,
resolve_install_dirs,
)

try:
install_dir = resolve_install_dir(project=project)
install_dirs = resolve_install_dirs(project=project)
result = reinstall_skills(
install_dir=install_dir,
install_dirs=install_dirs,
selected_skills=list(skill_names) or None,
)
except SkillsInstallLocationError as e:
Expand All @@ -192,9 +214,11 @@ def skills_reinstall(project: bool, skill_names: tuple[str, ...], output_json: b
return

console.print("[bold green]Skills reinstalled[/bold green]")
console.print(f"Location: [cyan]{result['install_dir']}[/cyan]")
print_locations(result)
console.print(f"Ref: [cyan]{result['ref']}[/cyan]")
console.print(f"Removed ({result['removed_count']}): [cyan]{', '.join(result['removed_skills'])}[/cyan]")
console.print(f"Installed ({result['installed_count']}): [cyan]{', '.join(result['installed_skills'])}[/cyan]")
console.print(f"Files written: [cyan]{result['file_count']}[/cyan]")
print_skipped(result)

return skills
Loading
Loading