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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! `agent-config` installs hooks, prompt rules, MCP servers, and skills into AI coding harnesses.
//!
//! The library knows where each harness keeps its configuration and what shape
//! that configuration takes. Callers supply a [`HookSpec`], [`McpSpec`], or
//! [`SkillSpec`]. The library handles atomic writes, backups, ownership ledgers,
//! and idempotent edits.
//!
//! # Production usage
//!
//! In production code, prefer [`try_build()`](HookSpecBuilder::try_build) over
//! the panicking [`build()`](HookSpecBuilder::build) so that invalid specs
//! propagate as [`Result`] errors instead of panics:
//!
//! ```no_run
//! use agent_config::{by_id, HookSpec, Matcher, Event, Scope};
//!
//! fn install_my_hook() -> agent_config::Result<()> {
//! let spec = HookSpec::builder("myapp")
//! .command_program("myapp", ["hook", "claude"])
//! .matcher(Matcher::Bash)
//! .event(Event::PreToolUse)
//! .try_build()?;
//!
//! let claude = by_id("claude").expect("claude integration registered");
//! claude.install(&Scope::Global, &spec)?;
//! Ok(())
//! }
//! ```
//!
//! [`build()`](HookSpecBuilder::build) is also available as a convenience for
//! tests and examples where a panic on misconfiguration is acceptable.
//!
//! # Quick start
//!
//! ```no_run
//! use agent_config::{by_id, HookSpec, Matcher, Event, Scope};
//!
//! let spec = HookSpec::builder("myapp")
//! .command_program("myapp", ["hook", "claude"])
//! .matcher(Matcher::Bash)
//! .event(Event::PreToolUse)
//! .build();
//!
//! let claude = by_id("claude").expect("claude integration registered");
//! claude.install(&Scope::Global, &spec).unwrap();
//! ```
//!
//! # MCP servers
//!
//! ```no_run
//! use agent_config::{mcp_by_id, McpSpec, Scope};
//!
//! let spec = McpSpec::builder("github")
//! .owner("myapp")
//! .stdio("npx", ["-y", "@modelcontextprotocol/server-github"])
//! .build();
//!
//! let codex = mcp_by_id("codex").expect("codex MCP support registered");
//! codex.install_mcp(&Scope::Global, &spec).unwrap();
//! ```
//!
//! # Skills
//!
//! ```no_run
//! use agent_config::{skill_by_id, Scope, SkillSpec};
//!
//! let spec = SkillSpec::builder("my-skill")
//! .owner("myapp")
//! .description("Use when my app needs custom repository context.")
//! .body("# My Skill\n\nFollow the local project conventions.")
//! .build();
//!
//! let claude = skill_by_id("claude").expect("claude skill support registered");
//! claude.install_skill(&Scope::Global, &spec).unwrap();
//! ```
//!
//! # Discovery and uninstall
//!
//! ```no_run
//! use agent_config::{all, by_id, Scope};
//!
//! for integration in all() {
//! if integration.supported_scopes().contains(&Scope::Global.kind())
//! && integration.is_installed(&Scope::Global, "myapp").unwrap_or(false)
//! {
//! println!("{} has myapp installed", integration.display_name());
//! }
//! }
//!
//! let claude = by_id("claude").expect("claude integration registered");
//! claude.uninstall(&Scope::Global, "myapp").unwrap();
//! ```
//!
//! # Safety guarantees
//!
//! - Atomic writes (write-to-temp + rename).
//! - First-touch `.bak` backups of any pre-existing file we modify.
//! - Idempotent installs: repeating `install` with the same `tag` yields the same state.
//! - Reversible: `uninstall` removes only the tagged content.
//!
//! # Concrete agent types
//!
//! When the target harness is known at compile time, construct the agent
//! directly for type-safe, discoverable usage:
//!
//! ```no_run
//! use agent_config::{ClaudeAgent, Integration, HookSpec, Matcher, Event, Scope};
//!
//! fn main() -> agent_config::Result<()> {
//! let claude = ClaudeAgent::new();
//! let spec = HookSpec::builder("myapp")
//! .command_program("myapp", ["hook", "claude"])
//! .matcher(Matcher::Bash)
//! .event(Event::PreToolUse)
//! .try_build()?;
//!
//! claude.install(&Scope::Global, &spec)?;
//! Ok(())
//! }
//! ```
//!
//! The registry API (`by_id`, `mcp_by_id`, `skill_by_id`) remains the
//! recommended path for CLIs and tools that accept integration IDs from user
//! input at runtime. Concrete types are stable convenience handles for
//! compile-time usage.
pub use AgentConfigError;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Result alias used throughout the crate's public API.
pub type Result<T> = Result;