| 337 | } |
| 338 | |
| 339 | fn install_hooks_at(path: &Path, force: bool) -> AgentResult<usize> { |
| 340 | let mut config = read_hooks_file(path)?; |
| 341 | if force { |
| 342 | remove_atomic_hooks(&mut config.hooks); |
| 343 | } |
| 344 | |
| 345 | let mut installed = 0; |
| 346 | for spec in CODEX_HOOK_DEFS { |
| 347 | let command = crate::hooks::guarded_hook_command(spec.command); |
| 348 | if add_hook(&mut config.hooks, spec.event, &command, spec.status_message) { |
| 349 | installed += 1; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | write_hooks_file(path, &config)?; |
| 354 | Ok(installed) |
| 355 | } |
| 356 | |
| 357 | fn uninstall_hooks_at(path: &Path) -> AgentResult<()> { |
| 358 | if !path.exists() { |