agr 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
agr/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """agr: Agent Resources - Install and create Claude Code skills, commands, and agents."""
2
+
3
+ __version__ = "0.2.0"
agr/cli/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """CLI module for agr."""
2
+
3
+ from agr.cli.main import app
4
+
5
+ __all__ = ["app"]
agr/cli/add.py ADDED
@@ -0,0 +1,132 @@
1
+ """Add subcommand for agr - install resources from GitHub."""
2
+
3
+ from typing import Annotated, List, Optional
4
+
5
+ import typer
6
+ from rich.console import Console
7
+
8
+ from agr.cli.common import handle_add_bundle, handle_add_resource, handle_add_unified
9
+ from agr.fetcher import ResourceType
10
+
11
+ console = Console()
12
+
13
+ # Deprecated subcommand names
14
+ DEPRECATED_SUBCOMMANDS = {"skill", "command", "agent", "bundle"}
15
+
16
+
17
+ def extract_type_from_args(
18
+ args: list[str] | None, explicit_type: str | None
19
+ ) -> tuple[list[str], str | None]:
20
+ """
21
+ Extract --type/-t option from args list if present.
22
+
23
+ When --type or -t appears after the resource reference, Typer captures it
24
+ as part of the variadic args list. This function extracts it.
25
+
26
+ Args:
27
+ args: The argument list (may contain --type/-t)
28
+ explicit_type: The resource_type value from Typer (may be None if type was in args)
29
+
30
+ Returns:
31
+ Tuple of (cleaned_args, resource_type)
32
+ """
33
+ if not args or explicit_type is not None:
34
+ return args or [], explicit_type
35
+
36
+ cleaned_args = []
37
+ resource_type = None
38
+ i = 0
39
+ while i < len(args):
40
+ if args[i] in ("--type", "-t") and i + 1 < len(args):
41
+ resource_type = args[i + 1]
42
+ i += 2 # Skip both --type and its value
43
+ else:
44
+ cleaned_args.append(args[i])
45
+ i += 1
46
+
47
+ return cleaned_args, resource_type
48
+
49
+ app = typer.Typer(
50
+ help="Add skills, commands, or agents from GitHub.",
51
+ )
52
+
53
+
54
+ @app.callback(invoke_without_command=True)
55
+ def add_unified(
56
+ ctx: typer.Context,
57
+ args: Annotated[
58
+ Optional[List[str]],
59
+ typer.Argument(help="Resource reference and optional arguments"),
60
+ ] = None,
61
+ resource_type: Annotated[
62
+ Optional[str],
63
+ typer.Option(
64
+ "--type",
65
+ "-t",
66
+ help="Explicit resource type: skill, command, agent, or bundle",
67
+ ),
68
+ ] = None,
69
+ overwrite: Annotated[
70
+ bool,
71
+ typer.Option(
72
+ "--overwrite",
73
+ help="Overwrite existing resource if it exists.",
74
+ ),
75
+ ] = False,
76
+ global_install: Annotated[
77
+ bool,
78
+ typer.Option(
79
+ "--global",
80
+ "-g",
81
+ help="Install to ~/.claude/ instead of ./.claude/",
82
+ ),
83
+ ] = False,
84
+ ) -> None:
85
+ """Add a resource from a GitHub repository with auto-detection.
86
+
87
+ REFERENCE format:
88
+ - username/name: installs from github.com/username/agent-resources
89
+ - username/repo/name: installs from github.com/username/repo
90
+
91
+ Auto-detects the resource type (skill, command, agent, or bundle).
92
+ Use --type to explicitly specify when a name exists in multiple types.
93
+
94
+ Examples:
95
+ agr add kasperjunge/hello-world
96
+ agr add kasperjunge/my-repo/hello-world --type skill
97
+ agr add kasperjunge/productivity --global
98
+ """
99
+ # Extract --type/-t from args if it was captured there (happens when type comes after ref)
100
+ cleaned_args, resource_type = extract_type_from_args(args, resource_type)
101
+
102
+ if not cleaned_args:
103
+ console.print(ctx.get_help())
104
+ raise typer.Exit(0)
105
+
106
+ first_arg = cleaned_args[0]
107
+
108
+ # Handle deprecated subcommand syntax: agr add skill <ref>
109
+ if first_arg in DEPRECATED_SUBCOMMANDS:
110
+ if len(cleaned_args) < 2:
111
+ console.print(f"[red]Error: Missing resource reference after '{first_arg}'.[/red]")
112
+ raise typer.Exit(1)
113
+
114
+ resource_ref = cleaned_args[1]
115
+ console.print(
116
+ f"[yellow]Warning: 'agr add {first_arg}' is deprecated. "
117
+ f"Use 'agr add {resource_ref}' instead.[/yellow]"
118
+ )
119
+
120
+ if first_arg == "skill":
121
+ handle_add_resource(resource_ref, ResourceType.SKILL, "skills", overwrite, global_install)
122
+ elif first_arg == "command":
123
+ handle_add_resource(resource_ref, ResourceType.COMMAND, "commands", overwrite, global_install)
124
+ elif first_arg == "agent":
125
+ handle_add_resource(resource_ref, ResourceType.AGENT, "agents", overwrite, global_install)
126
+ elif first_arg == "bundle":
127
+ handle_add_bundle(resource_ref, overwrite, global_install)
128
+ return
129
+
130
+ # Normal unified add: agr add <ref>
131
+ resource_ref = first_arg
132
+ handle_add_unified(resource_ref, resource_type, overwrite, global_install)