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

Function cbm_install_subagent_reminder_script

src/cli/cli.c:5263–5301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5261#define CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY "cbm-subagent-reminder"
5262
5263static bool cbm_install_subagent_reminder_script(const char *home, const char *binary_path) {
5264 if (!home || !binary_path) {
5265 return false;
5266 }
5267 char config_dir[CLI_BUF_1K];
5268 cbm_claude_config_dir(home, config_dir, sizeof(config_dir));
5269 if (!config_dir[0]) {
5270 return false;
5271 }
5272 char hooks_dir[CLI_BUF_1K];
5273 int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir);
5274 if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) {
5275 return false;
5276 }
5277 if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) {
5278 return false;
5279 }
5280
5281 char script_path[CLI_BUF_1K];
5282 int script_written =
5283 snprintf(script_path, sizeof(script_path), "%s/" CMM_SUBAGENT_REMINDER_SCRIPT, hooks_dir);
5284 if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) {
5285 return false;
5286 }
5287
5288 char script[CLI_BUF_8K];
5289 if (cbm_build_current_hook_script(cmm_subagent_script_prefix, binary_path, script,
5290 sizeof(script)) != CLI_OK) {
5291 return false;
5292 }
5293 const char *const legacy[] = {cmm_released_subagent_script};
5294#ifdef _WIN32
5295 if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, script,
5296 legacy, 1U) != CLI_OK) {
5297 return false;
5298 }
5299#endif
5300 return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U);
5301}
5302
5303/* #1387 dry-run predicate: would writing this hook script succeed, or would
5304 * the owned-document migration refuse it because the file on disk is not ours?

Callers 1

Tested by

no test coverage detected