(&self)
| 97 | |
| 98 | impl Command for Enable { |
| 99 | fn run(&self) -> CliResult<()> { |
| 100 | // Data-driven install — definitions come from the integration's manifest. |
| 101 | if let Some(ref manifest) = self.hooks { |
| 102 | return self.run_manifest(manifest); |
| 103 | } |
| 104 | |
| 105 | // Global install — writes to ~/.claude/settings.json |
| 106 | if self.global { |
| 107 | return self.run_global(); |
| 108 | } |
| 109 | |
| 110 | // Find the repository root |
| 111 | let repo_root = find_repository_root()?; |
| 112 | |
| 113 | // Ensure .atomic/sessions directory exists |
| 114 | let sessions_dir = repo_root.join(".atomic").join("sessions"); |
| 115 | if !sessions_dir.exists() { |
| 116 | std::fs::create_dir_all(&sessions_dir).map_err(|e| { |
| 117 | crate::error::CliError::Io(std::io::Error::new( |
| 118 | e.kind(), |
| 119 | format!("Failed to create sessions directory: {}", e), |
| 120 | )) |
| 121 | })?; |
| 122 | } |
| 123 | |
| 124 | let registry = AgentRegistry::with_defaults(); |
| 125 | |
| 126 | // Determine which agents to install for |
| 127 | let agents_to_install: Vec<&str> = if self.all { |
| 128 | // Install for all detected agents |
| 129 | let detected = registry.detect(&repo_root); |
| 130 | if detected.is_empty() { |
| 131 | // If none detected, try all registered agents |
| 132 | print_warning("No agents detected — installing hooks for all registered agents."); |
| 133 | registry.list() |
| 134 | } else { |
| 135 | detected |
| 136 | } |
| 137 | } else if let Some(ref name) = self.agent { |
| 138 | // Specific agent requested — validate it exists |
| 139 | registry |
| 140 | .require(name) |
| 141 | .map_err(|e| crate::error::CliError::InvalidArgument { |
| 142 | message: format!("Unknown agent '{}': {}", name, e), |
| 143 | })?; |
| 144 | vec![name.as_str()] |
| 145 | } else { |
| 146 | // Auto-detect |
| 147 | let detected = registry.detect(&repo_root); |
| 148 | if detected.is_empty() { |
| 149 | // No agent detected — try to install for all, with a hint |
| 150 | let available = registry.list(); |
| 151 | if available.is_empty() { |
| 152 | print_error("No agents available. This is a bug — the registry should have built-in agents."); |
| 153 | return Ok(()); |
| 154 | } |
| 155 | |
| 156 | // Default to the first available agent (claude-code) |
nothing calls this directly
no test coverage detected