| 207 | } |
| 208 | |
| 209 | fn install(&self, repo_root: &Path) -> AgentResult<usize> { |
| 210 | let settings_path = Self::settings_path(repo_root); |
| 211 | let (mut raw, mut hooks) = settings::read_settings(&settings_path)?; |
| 212 | |
| 213 | let count = install_hooks_into(&mut hooks, &settings_path)?; |
| 214 | |
| 215 | // Add permissions.deny rule to prevent Claude from reading metadata |
| 216 | let permissions_changed = settings::ensure_deny_rule(&mut raw); |
| 217 | |
| 218 | if count == 0 && !permissions_changed { |
| 219 | return Ok(0); |
| 220 | } |
| 221 | |
| 222 | // Serialize hooks back into raw settings |
| 223 | let hooks_val = serde_json::to_value(&hooks).map_err(|e| AgentError::ConfigError { |
| 224 | operation: "serialize hooks".to_string(), |
| 225 | path: settings_path.clone(), |
| 226 | reason: e.to_string(), |
| 227 | })?; |
| 228 | raw.insert("hooks".to_string(), hooks_val); |
| 229 | settings::write_settings(&settings_path, &raw)?; |
| 230 | |
| 231 | Ok(count) |
| 232 | } |
| 233 | |
| 234 | fn uninstall(&self, repo_root: &Path) -> AgentResult<()> { |
| 235 | let settings_path = Self::settings_path(repo_root); |