| 5568 | } |
| 5569 | |
| 5570 | int cbm_upsert_claude_subagent_hooks(const char *settings_path) { |
| 5571 | char command[CLI_BUF_8K]; |
| 5572 | char previous_command[CLI_BUF_8K]; |
| 5573 | char released_command[CLI_BUF_8K]; |
| 5574 | char previous_legacy_command[CLI_BUF_8K]; |
| 5575 | char released_legacy_command[CLI_BUF_8K]; |
| 5576 | if (cbm_resolve_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, command, sizeof(command)) != |
| 5577 | CLI_OK || |
| 5578 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, previous_command, |
| 5579 | sizeof(previous_command)) != CLI_OK || |
| 5580 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, released_command, |
| 5581 | sizeof(released_command)) != CLI_OK || |
| 5582 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5583 | previous_legacy_command, |
| 5584 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5585 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5586 | released_legacy_command, |
| 5587 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5588 | return CLI_ERR; |
| 5589 | } |
| 5590 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5591 | previous_legacy_command, NULL}; |
| 5592 | /* matcher "*" is the natural choice a user would also pick for their own |
| 5593 | * catch-all SubagentStart hook, so claim ownership by command too — never |
| 5594 | * clobber or remove a foreign "*" entry. */ |
| 5595 | return upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5596 | .hook_event = "SubagentStart", |
| 5597 | .matcher_str = "*", |
| 5598 | .command_str = command, |
| 5599 | .old_commands = old_commands, |
| 5600 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5601 | .match_command_exact = command}); |
| 5602 | } |
| 5603 | |
| 5604 | int cbm_remove_claude_subagent_hooks(const char *settings_path) { |
| 5605 | char command[CLI_BUF_8K]; |
no test coverage detected