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

Function cbm_build_copilot_hook_manifest

src/cli/cli.c:3519–3554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3517}
3518
3519static char *cbm_build_copilot_hook_manifest(const char *binary_path) {
3520 char session_bash[CLI_BUF_8K];
3521 char session_powershell[CLI_BUF_8K];
3522 char subagent_bash[CLI_BUF_8K];
3523 char subagent_powershell[CLI_BUF_8K];
3524 if (cbm_build_copilot_hook_command(binary_path, "SessionStart", false, session_bash,
3525 sizeof(session_bash)) != CLI_OK ||
3526 cbm_build_copilot_hook_command(binary_path, "SessionStart", true, session_powershell,
3527 sizeof(session_powershell)) != CLI_OK ||
3528 cbm_build_copilot_hook_command(binary_path, "SubagentStart", false, subagent_bash,
3529 sizeof(subagent_bash)) != CLI_OK ||
3530 cbm_build_copilot_hook_command(binary_path, "SubagentStart", true, subagent_powershell,
3531 sizeof(subagent_powershell)) != CLI_OK) {
3532 return NULL;
3533 }
3534
3535 yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
3536 yyjson_mut_val *root = doc ? yyjson_mut_obj(doc) : NULL;
3537 yyjson_mut_val *hooks = doc ? yyjson_mut_obj(doc) : NULL;
3538 if (!doc || !root || !hooks) {
3539 if (doc) {
3540 yyjson_mut_doc_free(doc);
3541 }
3542 return NULL;
3543 }
3544 yyjson_mut_doc_set_root(doc, root);
3545 bool ok =
3546 yyjson_mut_obj_add_int(doc, root, "version", 1) &&
3547 cbm_copilot_add_hook_event(doc, hooks, "sessionStart", session_bash, session_powershell) &&
3548 cbm_copilot_add_hook_event(doc, hooks, "subagentStart", subagent_bash,
3549 subagent_powershell) &&
3550 yyjson_mut_obj_add_val(doc, root, "hooks", hooks);
3551 char *manifest = ok ? yyjson_mut_write(doc, YYJSON_WRITE_PRETTY, NULL) : NULL;
3552 yyjson_mut_doc_free(doc);
3553 return manifest;
3554}
3555
3556/* Copilot loads every manifest in $COPILOT_HOME/hooks. Treat our dedicated
3557 * filename as an exact-owned document: a foreign collision fails closed, and

Callers 2

cbm_upsert_copilot_hooksFunction · 0.85
cbm_remove_copilot_hooksFunction · 0.85

Calls 2

Tested by

no test coverage detected