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

Source from the content-addressed store, hash-verified

3579}
3580
3581static char *cbm_build_copilot_hook_manifest(const char *binary_path) {
3582 char session_bash[CLI_BUF_8K];
3583 char session_powershell[CLI_BUF_8K];
3584 char subagent_bash[CLI_BUF_8K];
3585 char subagent_powershell[CLI_BUF_8K];
3586 if (cbm_build_copilot_hook_command(binary_path, "SessionStart", false, session_bash,
3587 sizeof(session_bash)) != CLI_OK ||
3588 cbm_build_copilot_hook_command(binary_path, "SessionStart", true, session_powershell,
3589 sizeof(session_powershell)) != CLI_OK ||
3590 cbm_build_copilot_hook_command(binary_path, "SubagentStart", false, subagent_bash,
3591 sizeof(subagent_bash)) != CLI_OK ||
3592 cbm_build_copilot_hook_command(binary_path, "SubagentStart", true, subagent_powershell,
3593 sizeof(subagent_powershell)) != CLI_OK) {
3594 return NULL;
3595 }
3596
3597 yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
3598 yyjson_mut_val *root = doc ? yyjson_mut_obj(doc) : NULL;
3599 yyjson_mut_val *hooks = doc ? yyjson_mut_obj(doc) : NULL;
3600 if (!doc || !root || !hooks) {
3601 if (doc) {
3602 yyjson_mut_doc_free(doc);
3603 }
3604 return NULL;
3605 }
3606 yyjson_mut_doc_set_root(doc, root);
3607 bool ok =
3608 yyjson_mut_obj_add_int(doc, root, "version", 1) &&
3609 cbm_copilot_add_hook_event(doc, hooks, "sessionStart", session_bash, session_powershell) &&
3610 cbm_copilot_add_hook_event(doc, hooks, "subagentStart", subagent_bash,
3611 subagent_powershell) &&
3612 yyjson_mut_obj_add_val(doc, root, "hooks", hooks);
3613 char *manifest = ok ? yyjson_mut_write(doc, YYJSON_WRITE_PRETTY, NULL) : NULL;
3614 yyjson_mut_doc_free(doc);
3615 return manifest;
3616}
3617
3618/* Copilot loads every manifest in $COPILOT_HOME/hooks. Treat our dedicated
3619 * 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