MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_upsert_claude_hooks

Function cbm_upsert_claude_hooks

src/cli/cli.c:4772–4811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4770}
4771
4772int cbm_upsert_claude_hooks(const char *settings_path) {
4773 char command[CLI_BUF_8K];
4774 char previous_command[CLI_BUF_8K];
4775 char released_command[CLI_BUF_8K];
4776 char previous_legacy_command[CLI_BUF_8K];
4777 char released_legacy_command[CLI_BUF_8K];
4778 if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK ||
4779 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command,
4780 sizeof(previous_command)) != CLI_OK ||
4781 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command,
4782 sizeof(released_command)) != CLI_OK ||
4783 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command,
4784 sizeof(previous_legacy_command)) != CLI_OK ||
4785 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command,
4786 sizeof(released_legacy_command)) != CLI_OK) {
4787 return CLI_ERR;
4788 }
4789 const char *const old_commands[] = {released_command, previous_command, released_legacy_command,
4790 previous_legacy_command, NULL};
4791 int search_result = upsert_hooks_json((hooks_upsert_args_t){
4792 .settings_path = settings_path,
4793 .hook_event = "PreToolUse",
4794 .matcher_str = CMM_HOOK_SEARCH_MATCHER,
4795 .command_str = command,
4796 .old_matchers = cmm_claude_old_matchers,
4797 .old_commands = old_commands,
4798 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4799 .match_command_exact = command,
4800 });
4801 int read_result = upsert_hooks_json((hooks_upsert_args_t){
4802 .settings_path = settings_path,
4803 .hook_event = "PostToolUse",
4804 .matcher_str = CMM_HOOK_READ_MATCHER,
4805 .command_str = command,
4806 .old_commands = old_commands,
4807 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4808 .match_command_exact = command,
4809 });
4810 return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR;
4811}
4812
4813int cbm_remove_claude_hooks(const char *settings_path) {
4814 char command[CLI_BUF_8K];

Callers 3

test_cli.cFile · 0.85
repro_issue409.cFile · 0.85

Tested by

no test coverage detected