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