MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run

Method run

atomic-cli/src/commands/agent/enable.rs:165–404  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

163
164impl Command for Enable {
165 fn run(&self) -> CliResult<()> {
166 // Data-driven install — definitions come from the integration's manifest.
167 if let Some(ref manifest) = self.hooks {
168 return self.run_manifest(manifest);
169 }
170
171 // Global install — writes to ~/.claude/settings.json
172 if self.global {
173 return self.run_global();
174 }
175
176 // Find the repository root
177 let repo_root = find_repository_root()?;
178
179 // Ensure .atomic/sessions directory exists
180 let sessions_dir = repo_root.join(".atomic").join("sessions");
181 if !sessions_dir.exists() {
182 std::fs::create_dir_all(&sessions_dir).map_err(|e| {
183 crate::error::CliError::Io(std::io::Error::new(
184 e.kind(),
185 format!("Failed to create sessions directory: {}", e),
186 ))
187 })?;
188 }
189
190 let registry = AgentRegistry::with_defaults();
191
192 // Determine which agents to install for
193 let agents_to_install: Vec<&str> = if self.all {
194 // Install for all detected agents
195 let detected = registry.detect(&repo_root);
196 if detected.is_empty() {
197 // Do not install hooks when no agent is detected.
198 print_error(
199 "No agents detected in this repository — nothing to enable with --all.",
200 );
201 print_warning(
202 "Create a .claude/, .gemini/, or .agents/ directory first, or use --agent <name>.",
203 );
204 return Err(crate::error::CliError::InvalidArgument {
205 message: "no agents detected for --all".to_string(),
206 });
207 }
208 detected
209 } else if let Some(ref name) = self.agent {
210 // Specific agent requested — validate it exists
211 registry
212 .require(name)
213 .map_err(|e| crate::error::CliError::InvalidArgument {
214 message: format!("Unknown agent '{}': {}", name, e),
215 })?;
216 vec![name.as_str()]
217 } else {
218 // Auto-detect
219 let detected = registry.detect(&repo_root);
220 if detected.is_empty() {
221 // No agent detected — try to install for all, with a hint
222 let available = registry.list();

Callers 2

sync_skills_cacheFunction · 0.45
sync_integration_packageFunction · 0.45

Calls 15

find_repository_rootFunction · 0.85
print_errorFunction · 0.85
print_warningFunction · 0.85
resolveFunction · 0.85
print_successFunction · 0.85
install_integrationMethod · 0.80
getMethod · 0.65
run_manifestMethod · 0.45
run_globalMethod · 0.45
existsMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected