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

Function cbm_cmd_hook_augment

src/cli/hook_augment.c:1787–1825  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785}
1786
1787int cbm_cmd_hook_augment(int argc, char **argv) {
1788 cbm_hook_augment_arm_deadline();
1789
1790 const char *forced_event = NULL;
1791 ha_lifecycle_dialect_t dialect = HA_DIALECT_EVENT;
1792 for (int i = 0; i < argc; i++) {
1793 if (strcmp(argv[i], "--event") == 0 && i + 1 < argc) {
1794 forced_event = argv[++i];
1795 } else if (strcmp(argv[i], "--dialect") == 0 && i + 1 < argc &&
1796 ha_dialect_from_name(argv[i + 1], &dialect)) {
1797 i++;
1798 } else {
1799 return 0;
1800 }
1801 }
1802 /* Copilot omits the event in stdin and therefore requires --event. Other
1803 * forced events must be documented lifecycle events for their dialect. */
1804 if (!ha_invocation_supported(dialect, forced_event)) {
1805 return 0;
1806 }
1807
1808 char *input = cbm_hook_augment_read_stdin();
1809 if (!input) {
1810 return 0;
1811 }
1812 if (!forced_event && cbm_hook_augment_input_is_noop_bash(input)) {
1813 free(input);
1814 return 0;
1815 }
1816 cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);
1817 char *output = srv ? ha_process(srv, input, forced_event, dialect) : NULL;
1818 if (output) {
1819 fputs(output, stdout);
1820 }
1821 free(output);
1822 cbm_mcp_server_free(srv);
1823 free(input);
1824 return 0;
1825}
1826
1827const char *cbm_hook_admission_notice(cbm_hook_admission_t reason, const char *hook_dialect) {
1828 /* Only Claude Code (the NULL dialect) consumes a bare stdout JSON object;

Callers 3

handle_subcommandFunction · 0.85
test_cli.cFile · 0.85
hl_run_hookFunction · 0.85

Calls 8

ha_dialect_from_nameFunction · 0.85
ha_invocation_supportedFunction · 0.85
cbm_mcp_server_newFunction · 0.85
ha_processFunction · 0.85
cbm_mcp_server_freeFunction · 0.85

Tested by 1

hl_run_hookFunction · 0.68