| 113 | } |
| 114 | |
| 115 | fn uninstall(&self, repo_root: &Path) -> AgentResult<()> { |
| 116 | let settings_path = Self::settings_path(repo_root); |
| 117 | |
| 118 | if !settings_path.exists() { |
| 119 | return Ok(()); // Nothing to uninstall |
| 120 | } |
| 121 | |
| 122 | let (mut raw, mut hooks) = settings::read_settings(&settings_path)?; |
| 123 | |
| 124 | // Remove all Atomic hooks from every hook list |
| 125 | settings::remove_atomic_hooks(&mut hooks.session_start); |
| 126 | settings::remove_atomic_hooks(&mut hooks.session_end); |
| 127 | settings::remove_atomic_hooks(&mut hooks.stop); |
| 128 | settings::remove_atomic_hooks(&mut hooks.user_prompt_submit); |
| 129 | settings::remove_atomic_hooks(&mut hooks.pre_tool_use); |
| 130 | settings::remove_atomic_hooks(&mut hooks.post_tool_use); |
| 131 | |
| 132 | // Remove the metadata deny rule from permissions |
| 133 | settings::remove_deny_rule(&mut raw); |
| 134 | |
| 135 | // Serialize hooks back |
| 136 | let hooks_val = serde_json::to_value(&hooks).map_err(|e| AgentError::ConfigError { |
| 137 | operation: "serialize hooks".to_string(), |
| 138 | path: settings_path.clone(), |
| 139 | reason: e.to_string(), |
| 140 | })?; |
| 141 | raw.insert("hooks".to_string(), hooks_val); |
| 142 | settings::write_settings(&settings_path, &raw)?; |
| 143 | |
| 144 | Ok(()) |
| 145 | } |
| 146 | |
| 147 | fn is_installed(&self, repo_root: &Path) -> bool { |
| 148 | let settings_path = Self::settings_path(repo_root); |