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:4554–4575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4552#define KIMI_HOOK_END "# <<< codebase-memory-mcp Kimi UserPromptSubmit <<<"
4553
4554static int cbm_upsert_kimi_context_hook(const char *config_path, const char *binary_path) {
4555 char command[CLI_BUF_8K];
4556 char escaped[CLI_BUF_8K];
4557 char block[CLI_BUF_8K];
4558 if (cbm_build_augment_dialect_command(binary_path, "kimi", command, sizeof(command)) !=
4559 CLI_OK ||
4560 cbm_toml_escape_basic_string(command, escaped, sizeof(escaped)) != 0) {
4561 return CLI_ERR;
4562 }
4563 int written = snprintf(block, sizeof(block),
4564 "[[hooks]]\n"
4565 "event = \"UserPromptSubmit\"\n"
4566 "command = \"%s\"\n"
4567 "timeout = 5\n",
4568 escaped);
4569 if (written < 0 || (size_t)written >= sizeof(block)) {
4570 return CLI_ERR;
4571 }
4572 return cbm_toml_upsert_managed_block(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END, block) == 0
4573 ? CLI_OK
4574 : CLI_ERR;
4575}
4576
4577static int cbm_remove_kimi_context_hook(const char *config_path) {
4578 return cbm_toml_remove_managed_block(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END) == 0

Callers 1

Tested by

no test coverage detected