Uninstall hooks from a settings file.
(settings_path: &Path)
| 446 | |
| 447 | /// Uninstall hooks from a settings file. |
| 448 | fn uninstall_from(settings_path: &Path) -> AgentResult<()> { |
| 449 | if !settings_path.exists() { |
| 450 | return Ok(()); |
| 451 | } |
| 452 | |
| 453 | let (mut raw, mut hooks) = Self::read_settings(settings_path)?; |
| 454 | |
| 455 | remove_atomic_hooks(&mut hooks.session_start); |
| 456 | remove_atomic_hooks(&mut hooks.session_end); |
| 457 | remove_atomic_hooks(&mut hooks.before_agent); |
| 458 | remove_atomic_hooks(&mut hooks.after_agent); |
| 459 | remove_atomic_hooks(&mut hooks.before_tool); |
| 460 | remove_atomic_hooks(&mut hooks.after_tool); |
| 461 | |
| 462 | let hooks_val = serde_json::to_value(&hooks).map_err(|e| AgentError::ConfigError { |
| 463 | operation: "serialize hooks".to_string(), |
| 464 | path: settings_path.to_path_buf(), |
| 465 | reason: e.to_string(), |
| 466 | })?; |
| 467 | raw.insert("hooks".to_string(), hooks_val); |
| 468 | |
| 469 | Self::write_settings(settings_path, &raw)?; |
| 470 | |
| 471 | Ok(()) |
| 472 | } |
| 473 | |
| 474 | /// Check if Atomic hooks are installed in a settings file. |
| 475 | fn is_installed_in(settings_path: &Path) -> bool { |
nothing calls this directly
no test coverage detected