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