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

Function cbm_upsert_claude_hooks

src/cli/cli.c:4552–4591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4550}
4551
4552int cbm_upsert_claude_hooks(const char *settings_path) {
4553 char command[CLI_BUF_8K];
4554 char previous_command[CLI_BUF_8K];
4555 char released_command[CLI_BUF_8K];
4556 char previous_legacy_command[CLI_BUF_8K];
4557 char released_legacy_command[CLI_BUF_8K];
4558 if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK ||
4559 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command,
4560 sizeof(previous_command)) != CLI_OK ||
4561 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command,
4562 sizeof(released_command)) != CLI_OK ||
4563 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command,
4564 sizeof(previous_legacy_command)) != CLI_OK ||
4565 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command,
4566 sizeof(released_legacy_command)) != CLI_OK) {
4567 return CLI_ERR;
4568 }
4569 const char *const old_commands[] = {released_command, previous_command, released_legacy_command,
4570 previous_legacy_command, NULL};
4571 int search_result = upsert_hooks_json((hooks_upsert_args_t){
4572 .settings_path = settings_path,
4573 .hook_event = "PreToolUse",
4574 .matcher_str = CMM_HOOK_SEARCH_MATCHER,
4575 .command_str = command,
4576 .old_matchers = cmm_claude_old_matchers,
4577 .old_commands = old_commands,
4578 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4579 .match_command_exact = command,
4580 });
4581 int read_result = upsert_hooks_json((hooks_upsert_args_t){
4582 .settings_path = settings_path,
4583 .hook_event = "PostToolUse",
4584 .matcher_str = CMM_HOOK_READ_MATCHER,
4585 .command_str = command,
4586 .old_commands = old_commands,
4587 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4588 .match_command_exact = command,
4589 });
4590 return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR;
4591}
4592
4593int cbm_remove_claude_hooks(const char *settings_path) {
4594 char command[CLI_BUF_8K];

Callers 3

test_cli.cFile · 0.85
repro_issue409.cFile · 0.85

Tested by

no test coverage detected