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

Function cbm_upsert_claude_hooks

src/cli/cli.c:4608–4647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4606}
4607
4608int cbm_upsert_claude_hooks(const char *settings_path) {
4609 char command[CLI_BUF_8K];
4610 char previous_command[CLI_BUF_8K];
4611 char released_command[CLI_BUF_8K];
4612 char previous_legacy_command[CLI_BUF_8K];
4613 char released_legacy_command[CLI_BUF_8K];
4614 if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK ||
4615 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command,
4616 sizeof(previous_command)) != CLI_OK ||
4617 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command,
4618 sizeof(released_command)) != CLI_OK ||
4619 cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command,
4620 sizeof(previous_legacy_command)) != CLI_OK ||
4621 cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command,
4622 sizeof(released_legacy_command)) != CLI_OK) {
4623 return CLI_ERR;
4624 }
4625 const char *const old_commands[] = {released_command, previous_command, released_legacy_command,
4626 previous_legacy_command, NULL};
4627 int search_result = upsert_hooks_json((hooks_upsert_args_t){
4628 .settings_path = settings_path,
4629 .hook_event = "PreToolUse",
4630 .matcher_str = CMM_HOOK_SEARCH_MATCHER,
4631 .command_str = command,
4632 .old_matchers = cmm_claude_old_matchers,
4633 .old_commands = old_commands,
4634 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4635 .match_command_exact = command,
4636 });
4637 int read_result = upsert_hooks_json((hooks_upsert_args_t){
4638 .settings_path = settings_path,
4639 .hook_event = "PostToolUse",
4640 .matcher_str = CMM_HOOK_READ_MATCHER,
4641 .command_str = command,
4642 .old_commands = old_commands,
4643 .timeout_value = CMM_HOOK_TIMEOUT_SEC,
4644 .match_command_exact = command,
4645 });
4646 return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR;
4647}
4648
4649int cbm_remove_claude_hooks(const char *settings_path) {
4650 char command[CLI_BUF_8K];

Callers 3

test_cli.cFile · 0.85
repro_issue409.cFile · 0.85

Tested by

no test coverage detected