| 4627 | } |
| 4628 | |
| 4629 | int cbm_upsert_claude_hooks(const char *settings_path) { |
| 4630 | char command[CLI_BUF_8K]; |
| 4631 | char previous_command[CLI_BUF_8K]; |
| 4632 | char released_command[CLI_BUF_8K]; |
| 4633 | char previous_legacy_command[CLI_BUF_8K]; |
| 4634 | char released_legacy_command[CLI_BUF_8K]; |
| 4635 | if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 4636 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command, |
| 4637 | sizeof(previous_command)) != CLI_OK || |
| 4638 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command, |
| 4639 | sizeof(released_command)) != CLI_OK || |
| 4640 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command, |
| 4641 | sizeof(previous_legacy_command)) != CLI_OK || |
| 4642 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command, |
| 4643 | sizeof(released_legacy_command)) != CLI_OK) { |
| 4644 | return CLI_ERR; |
| 4645 | } |
| 4646 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 4647 | previous_legacy_command, NULL}; |
| 4648 | int search_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4649 | .settings_path = settings_path, |
| 4650 | .hook_event = "PreToolUse", |
| 4651 | .matcher_str = CMM_HOOK_SEARCH_MATCHER, |
| 4652 | .command_str = command, |
| 4653 | .old_matchers = cmm_claude_old_matchers, |
| 4654 | .old_commands = old_commands, |
| 4655 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4656 | .match_command_exact = command, |
| 4657 | }); |
| 4658 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4659 | .settings_path = settings_path, |
| 4660 | .hook_event = "PostToolUse", |
| 4661 | .matcher_str = CMM_HOOK_READ_MATCHER, |
| 4662 | .command_str = command, |
| 4663 | .old_commands = old_commands, |
| 4664 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4665 | .match_command_exact = command, |
| 4666 | }); |
| 4667 | return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR; |
| 4668 | } |
| 4669 | |
| 4670 | int cbm_remove_claude_hooks(const char *settings_path) { |
| 4671 | char command[CLI_BUF_8K]; |
no test coverage detected