Remove hooks from the global `~/.claude/settings.json`.
(&self)
| 129 | |
| 130 | /// Remove hooks from the global `~/.claude/settings.json`. |
| 131 | pub fn uninstall_global(&self) -> AgentResult<()> { |
| 132 | let settings_path = match Self::global_settings_path() { |
| 133 | Some(p) => p, |
| 134 | None => return Ok(()), |
| 135 | }; |
| 136 | |
| 137 | if !settings_path.exists() { |
| 138 | return Ok(()); |
| 139 | } |
| 140 | |
| 141 | let (mut raw, mut hooks) = settings::read_settings(&settings_path)?; |
| 142 | |
| 143 | settings::remove_atomic_hooks(&mut hooks.session_start); |
| 144 | settings::remove_atomic_hooks(&mut hooks.session_end); |
| 145 | settings::remove_atomic_hooks(&mut hooks.stop); |
| 146 | settings::remove_atomic_hooks(&mut hooks.user_prompt_submit); |
| 147 | settings::remove_atomic_hooks(&mut hooks.pre_tool_use); |
| 148 | settings::remove_atomic_hooks(&mut hooks.post_tool_use); |
| 149 | |
| 150 | let hooks_val = serde_json::to_value(&hooks).map_err(|e| AgentError::ConfigError { |
| 151 | operation: "serialize hooks".to_string(), |
| 152 | path: settings_path.clone(), |
| 153 | reason: e.to_string(), |
| 154 | })?; |
| 155 | raw.insert("hooks".to_string(), hooks_val); |
| 156 | settings::write_settings(&settings_path, &raw)?; |
| 157 | |
| 158 | Ok(()) |
| 159 | } |
| 160 | |
| 161 | /// Check if hooks are installed globally in `~/.claude/settings.json`. |
| 162 | pub fn is_installed_global(&self) -> bool { |
nothing calls this directly
no test coverage detected