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

Function cbm_upsert_claude_hooks

src/cli/cli.c:4546–4585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

test_cli.cFile · 0.85
repro_issue409.cFile · 0.85

Tested by

no test coverage detected