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

Source from the content-addressed store, hash-verified

4041}
4042
4043static char *cbm_build_copilot_hook_manifest(const char *binary_path) {
4044 char session_bash[CLI_BUF_8K];
4045 char session_powershell[CLI_BUF_8K];
4046 char subagent_bash[CLI_BUF_8K];
4047 char subagent_powershell[CLI_BUF_8K];
4048 if (cbm_build_copilot_hook_command(binary_path, "SessionStart", false, session_bash,
4049 sizeof(session_bash)) != CLI_OK ||
4050 cbm_build_copilot_hook_command(binary_path, "SessionStart", true, session_powershell,
4051 sizeof(session_powershell)) != CLI_OK ||
4052 cbm_build_copilot_hook_command(binary_path, "SubagentStart", false, subagent_bash,
4053 sizeof(subagent_bash)) != CLI_OK ||
4054 cbm_build_copilot_hook_command(binary_path, "SubagentStart", true, subagent_powershell,
4055 sizeof(subagent_powershell)) != CLI_OK) {
4056 return NULL;
4057 }
4058
4059 yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
4060 yyjson_mut_val *root = doc ? yyjson_mut_obj(doc) : NULL;
4061 yyjson_mut_val *hooks = doc ? yyjson_mut_obj(doc) : NULL;
4062 if (!doc || !root || !hooks) {
4063 if (doc) {
4064 yyjson_mut_doc_free(doc);
4065 }
4066 return NULL;
4067 }
4068 yyjson_mut_doc_set_root(doc, root);
4069 bool ok =
4070 yyjson_mut_obj_add_int(doc, root, "version", 1) &&
4071 cbm_copilot_add_hook_event(doc, hooks, "sessionStart", session_bash, session_powershell) &&
4072 cbm_copilot_add_hook_event(doc, hooks, "subagentStart", subagent_bash,
4073 subagent_powershell) &&
4074 yyjson_mut_obj_add_val(doc, root, "hooks", hooks);
4075 char *manifest = ok ? yyjson_mut_write(doc, YYJSON_WRITE_PRETTY, NULL) : NULL;
4076 yyjson_mut_doc_free(doc);
4077 return manifest;
4078}
4079
4080/* Copilot loads every manifest in $COPILOT_HOME/hooks. Treat our dedicated
4081 * 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