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

Function cbm_install_session_reminder_script

src/cli/cli.c:5125–5163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5123#define CMM_SESSION_REMINDER_SCRIPT_LEGACY "cbm-session-reminder"
5124
5125static bool cbm_install_session_reminder_script(const char *home, const char *binary_path) {
5126 if (!home || !binary_path) {
5127 return false;
5128 }
5129 char config_dir[CLI_BUF_1K];
5130 cbm_claude_config_dir(home, config_dir, sizeof(config_dir));
5131 if (!config_dir[0]) {
5132 return false;
5133 }
5134 char hooks_dir[CLI_BUF_1K];
5135 int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir);
5136 if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) {
5137 return false;
5138 }
5139 if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) {
5140 return false;
5141 }
5142
5143 char script_path[CLI_BUF_1K];
5144 int script_written =
5145 snprintf(script_path, sizeof(script_path), "%s/" CMM_SESSION_REMINDER_SCRIPT, hooks_dir);
5146 if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) {
5147 return false;
5148 }
5149
5150 char script[CLI_BUF_8K];
5151 if (cbm_build_current_hook_script(cmm_session_script_prefix, binary_path, script,
5152 sizeof(script)) != CLI_OK) {
5153 return false;
5154 }
5155 const char *const legacy[] = {cmm_released_session_script};
5156#ifdef _WIN32
5157 if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SESSION_REMINDER_SCRIPT_LEGACY, script,
5158 legacy, 1U) != CLI_OK) {
5159 return false;
5160 }
5161#endif
5162 return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U);
5163}
5164
5165static int cbm_upsert_session_hooks(const char *settings_path) {
5166 static const char *matchers[] = {"startup", "resume", "clear", "compact"};

Callers 1

Tested by

no test coverage detected