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

Source from the content-addressed store, hash-verified

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

Callers 1

Tested by

no test coverage detected