| 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 | if add_hook( |
| 348 | &mut config.hooks, |
| 349 | spec.event, |
| 350 | spec.command, |
| 351 | spec.status_message, |
| 352 | ) { |
| 353 | installed += 1; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | write_hooks_file(path, &config)?; |
| 358 | Ok(installed) |
| 359 | } |
| 360 | |
| 361 | fn uninstall_hooks_at(path: &Path) -> AgentResult<()> { |
| 362 | if !path.exists() { |