| 88 | } |
| 89 | |
| 90 | fn install(&self, repo_root: &Path) -> AgentResult<usize> { |
| 91 | let settings_path = Self::settings_path(repo_root); |
| 92 | let (mut raw, mut hooks) = settings::read_settings(&settings_path)?; |
| 93 | |
| 94 | let count = install_hooks_into(&mut hooks, &settings_path)?; |
| 95 | |
| 96 | // Add permissions.deny rule to prevent Claude from reading metadata |
| 97 | let permissions_changed = settings::ensure_deny_rule(&mut raw); |
| 98 | |
| 99 | if count == 0 && !permissions_changed { |
| 100 | return Ok(0); |
| 101 | } |
| 102 | |
| 103 | // Serialize hooks back into raw settings |
| 104 | let hooks_val = serde_json::to_value(&hooks).map_err(|e| AgentError::ConfigError { |
| 105 | operation: "serialize hooks".to_string(), |
| 106 | path: settings_path.clone(), |
| 107 | reason: e.to_string(), |
| 108 | })?; |
| 109 | raw.insert("hooks".to_string(), hooks_val); |
| 110 | settings::write_settings(&settings_path, &raw)?; |
| 111 | |
| 112 | Ok(count) |
| 113 | } |
| 114 | |
| 115 | fn uninstall(&self, repo_root: &Path) -> AgentResult<()> { |
| 116 | let settings_path = Self::settings_path(repo_root); |