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

Function cbm_upsert_kimi_context_hook

src/cli/cli.c:5094–5115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5092#define KIMI_HOOK_END "# <<< codebase-memory-mcp Kimi UserPromptSubmit <<<"
5093
5094static int cbm_upsert_kimi_context_hook(const char *config_path, const char *binary_path) {
5095 char command[CLI_BUF_8K];
5096 char escaped[CLI_BUF_8K];
5097 char block[CLI_BUF_8K];
5098 if (cbm_build_augment_dialect_command(binary_path, "kimi", command, sizeof(command)) !=
5099 CLI_OK ||
5100 cbm_toml_escape_basic_string(command, escaped, sizeof(escaped)) != 0) {
5101 return CLI_ERR;
5102 }
5103 int written = snprintf(block, sizeof(block),
5104 "[[hooks]]\n"
5105 "event = \"UserPromptSubmit\"\n"
5106 "command = \"%s\"\n"
5107 "timeout = 5\n",
5108 escaped);
5109 if (written < 0 || (size_t)written >= sizeof(block)) {
5110 return CLI_ERR;
5111 }
5112 return cbm_toml_upsert_managed_block(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END, block) == 0
5113 ? CLI_OK
5114 : CLI_ERR;
5115}
5116
5117static int cbm_remove_kimi_context_hook(const char *config_path) {
5118 return cbm_toml_remove_managed_block_owned(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END,

Callers 1

Tested by

no test coverage detected