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

Source from the content-addressed store, hash-verified

5317#define CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY "cbm-subagent-reminder"
5318
5319static bool cbm_install_subagent_reminder_script(const char *home, const char *binary_path) {
5320 if (!home || !binary_path) {
5321 return false;
5322 }
5323 char config_dir[CLI_BUF_1K];
5324 cbm_claude_config_dir(home, config_dir, sizeof(config_dir));
5325 if (!config_dir[0]) {
5326 return false;
5327 }
5328 char hooks_dir[CLI_BUF_1K];
5329 int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir);
5330 if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) {
5331 return false;
5332 }
5333 if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) {
5334 return false;
5335 }
5336
5337 char script_path[CLI_BUF_1K];
5338 int script_written =
5339 snprintf(script_path, sizeof(script_path), "%s/" CMM_SUBAGENT_REMINDER_SCRIPT, hooks_dir);
5340 if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) {
5341 return false;
5342 }
5343
5344 char script[CLI_BUF_8K];
5345 if (cbm_build_current_hook_script(cmm_subagent_script_prefix, binary_path, script,
5346 sizeof(script)) != CLI_OK) {
5347 return false;
5348 }
5349 const char *const legacy[] = {cmm_released_subagent_script};
5350#ifdef _WIN32
5351 if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY, script,
5352 legacy, 1U) != CLI_OK) {
5353 return false;
5354 }
5355#endif
5356 return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U);
5357}
5358
5359/* #1387 dry-run predicate: would writing this hook script succeed, or would
5360 * the owned-document migration refuse it because the file on disk is not ours?

Callers 1

Tested by

no test coverage detected