1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//! AGPM - Claude Code Package Manager
//!
//! A Git-based package manager for Claude Code resources (agents, snippets, commands,
//! scripts, hooks, and MCP servers) that enables reproducible installations using
//! lockfile-based dependency management, similar to Cargo.
//!
//! # Architecture Overview
//!
//! AGPM follows a manifest/lockfile model where:
//! - `agpm.toml` defines desired dependencies and their version constraints
//! - `agpm.lock` records exact resolved versions for reproducible builds
//! - Resources are fetched directly from Git repositories (no central registry)
//! - Pattern-based dependencies enable bulk installation of related resources
//!
//! ## Key Features
//!
//! - **Decentralized**: No central registry - resources come from Git repositories
//! - **Reproducible**: Lockfile ensures identical installations across environments
//! - **Cross-platform**: Works on Windows, macOS, and Linux with proper path handling
//! - **Pattern Matching**: Install multiple resources using glob patterns (e.g., `agents/*.md`)
//! - **MCP Integration**: Native support for Model Context Protocol servers
//! - **Hook System**: Automated Claude Code event handlers
//! - **Security**: Input validation, path traversal prevention, credential isolation
//!
//! # Core Modules
//!
//! ## Core Functionality
//! - [`cache`] - Git repository caching and management for performance
//! - [`cli`] - Command-line interface with comprehensive subcommands
//! - [`config`] - Global (~/.agpm/config.toml) and project configuration
//! - [`core`] - Core types, error handling, and resource abstractions
//! - [`resolver`] - Dependency resolution, conflict detection, and version matching
//!
//! ## Git Integration
//! - [`git`] - Git operations wrapper using system git command (like Cargo)
//! - [`source`] - Source repository operations and management
//!
//! ## Resource Management
//! - [`lockfile`] - Lockfile generation, parsing, and validation (agpm.lock)
//! - [`manifest`] - Manifest parsing and validation (agpm.toml)
//! - [`markdown`] - Markdown file operations and frontmatter extraction
//! - [`metadata`] - Extraction of transitive dependencies from resource files
//! - [`pattern`] - Pattern-based dependency resolution using glob patterns
//!
//! ## Resource Types
//! - [`hooks`] - Claude Code hook configuration and settings.local.json management
//! - [`mcp`] - Model Context Protocol server configuration and .mcp.json management
//!
//! ## Supporting Modules
//! - [`models`] - Shared data models for dependency specifications
//! - [`utils`] - Cross-platform utilities, file operations, and path validation
//! - [`version`] - Version constraint parsing, comparison, and resolution
//!
//! # Manifest Format (agpm.toml)
//!
//! ## Basic Example
//! ```toml
//! # Define source repositories
//! [sources]
//! community = "https://github.com/aig787/agpm-community.git"
//! official = "https://github.com/example-org/agpm-official.git"
//!
//! # Install individual resources
//! [agents]
//! code-reviewer = { source = "official", path = "agents/reviewer.md", version = "v1.0.0" }
//! local-helper = "../local-agents/helper.md" # Local file
//!
//! # Pattern-based dependencies (new feature)
//! ai-agents = { source = "community", path = "agents/ai/*.md", version = "v1.0.0" }
//! all-tools = { source = "community", path = "**/tools/*.md", version = "latest" }
//!
//! [snippets]
//! utils = { source = "community", path = "snippets/utils.md", version = "v2.1.0" }
//!
//! [commands]
//! deploy = { source = "official", path = "commands/deploy.md", version = "v1.0.0" }
//!
//! # MCP servers and hooks
//! [mcp-servers]
//! filesystem = { source = "official", path = "mcp-servers/filesystem.json", version = "v1.0.0" }
//!
//! [hooks]
//! pre-commit = { source = "community", path = "hooks/pre-commit.json", version = "v1.0.0" }
//! ```
//!
//! # Command-Line Usage
//!
//! ## Installation and Management
//! ```bash
//! # Initialize new AGPM project
//! agpm init
//!
//! # Install all dependencies from agpm.toml
//! agpm install
//!
//! # Install with frozen lockfile (CI/production)
//! agpm install --frozen
//!
//! # Update dependencies within version constraints
//! agpm update
//!
//! # Update specific dependencies only
//! agpm update code-reviewer utils
//! ```
//!
//! ## Resource Discovery
//! ```bash
//! # List installed resources
//! agpm list
//!
//! # List with details and source information
//! agpm list --details
//!
//! # List specific resource types
//! agpm list --agents --format json
//! ```
//!
//! ## Project Management
//! ```bash
//! # Validate project configuration
//! agpm validate --resolve --sources
//!
//! # Add new dependencies
//! agpm add dep agent official:agents/helper.md@v1.0.0
//!
//! # Manage cache
//! agpm cache clean
//! ```
// Core functionality modules
// Git integration
// Resource management
// Resource types
// Supporting modules
// test_utils module is available for both unit tests and integration tests