| 5425 | } |
| 5426 | |
| 5427 | int cbm_upsert_claude_subagent_hooks(const char *settings_path) { |
| 5428 | char command[CLI_BUF_8K]; |
| 5429 | char previous_command[CLI_BUF_8K]; |
| 5430 | char released_command[CLI_BUF_8K]; |
| 5431 | char previous_legacy_command[CLI_BUF_8K]; |
| 5432 | char released_legacy_command[CLI_BUF_8K]; |
| 5433 | if (cbm_resolve_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, command, sizeof(command)) != |
| 5434 | CLI_OK || |
| 5435 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, previous_command, |
| 5436 | sizeof(previous_command)) != CLI_OK || |
| 5437 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, released_command, |
| 5438 | sizeof(released_command)) != CLI_OK || |
| 5439 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5440 | previous_legacy_command, |
| 5441 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5442 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5443 | released_legacy_command, |
| 5444 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5445 | return CLI_ERR; |
| 5446 | } |
| 5447 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5448 | previous_legacy_command, NULL}; |
| 5449 | /* matcher "*" is the natural choice a user would also pick for their own |
| 5450 | * catch-all SubagentStart hook, so claim ownership by command too — never |
| 5451 | * clobber or remove a foreign "*" entry. */ |
| 5452 | return upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5453 | .hook_event = "SubagentStart", |
| 5454 | .matcher_str = "*", |
| 5455 | .command_str = command, |
| 5456 | .old_commands = old_commands, |
| 5457 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5458 | .match_command_exact = command}); |
| 5459 | } |
| 5460 | |
| 5461 | int cbm_remove_claude_subagent_hooks(const char *settings_path) { |
| 5462 | char command[CLI_BUF_8K]; |
no test coverage detected