| 5404 | } |
| 5405 | |
| 5406 | int cbm_upsert_claude_subagent_hooks(const char *settings_path) { |
| 5407 | char command[CLI_BUF_8K]; |
| 5408 | char previous_command[CLI_BUF_8K]; |
| 5409 | char released_command[CLI_BUF_8K]; |
| 5410 | char previous_legacy_command[CLI_BUF_8K]; |
| 5411 | char released_legacy_command[CLI_BUF_8K]; |
| 5412 | if (cbm_resolve_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, command, sizeof(command)) != |
| 5413 | CLI_OK || |
| 5414 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, previous_command, |
| 5415 | sizeof(previous_command)) != CLI_OK || |
| 5416 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT, released_command, |
| 5417 | sizeof(released_command)) != CLI_OK || |
| 5418 | cbm_resolve_previous_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5419 | previous_legacy_command, |
| 5420 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5421 | cbm_resolve_released_hook_command(CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, |
| 5422 | released_legacy_command, |
| 5423 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5424 | return CLI_ERR; |
| 5425 | } |
| 5426 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5427 | previous_legacy_command, NULL}; |
| 5428 | /* matcher "*" is the natural choice a user would also pick for their own |
| 5429 | * catch-all SubagentStart hook, so claim ownership by command too — never |
| 5430 | * clobber or remove a foreign "*" entry. */ |
| 5431 | return upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5432 | .hook_event = "SubagentStart", |
| 5433 | .matcher_str = "*", |
| 5434 | .command_str = command, |
| 5435 | .old_commands = old_commands, |
| 5436 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5437 | .match_command_exact = command}); |
| 5438 | } |
| 5439 | |
| 5440 | int cbm_remove_claude_subagent_hooks(const char *settings_path) { |
| 5441 | char command[CLI_BUF_8K]; |
no test coverage detected