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

Source from the content-addressed store, hash-verified

5144#define CMM_SESSION_REMINDER_SCRIPT_LEGACY "cbm-session-reminder"
5145
5146static bool cbm_install_session_reminder_script(const char *home, const char *binary_path) {
5147 if (!home || !binary_path) {
5148 return false;
5149 }
5150 char config_dir[CLI_BUF_1K];
5151 cbm_claude_config_dir(home, config_dir, sizeof(config_dir));
5152 if (!config_dir[0]) {
5153 return false;
5154 }
5155 char hooks_dir[CLI_BUF_1K];
5156 int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir);
5157 if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) {
5158 return false;
5159 }
5160 if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) {
5161 return false;
5162 }
5163
5164 char script_path[CLI_BUF_1K];
5165 int script_written =
5166 snprintf(script_path, sizeof(script_path), "%s/" CMM_SESSION_REMINDER_SCRIPT, hooks_dir);
5167 if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) {
5168 return false;
5169 }
5170
5171 char script[CLI_BUF_8K];
5172 if (cbm_build_current_hook_script(cmm_session_script_prefix, binary_path, script,
5173 sizeof(script)) != CLI_OK) {
5174 return false;
5175 }
5176 const char *const legacy[] = {cmm_released_session_script};
5177#ifdef _WIN32
5178 if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SESSION_REMINDER_SCRIPT_LEGACY, script,
5179 legacy, 1U) != CLI_OK) {
5180 return false;
5181 }
5182#endif
5183 return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U);
5184}
5185
5186static int cbm_upsert_session_hooks(const char *settings_path) {
5187 static const char *matchers[] = {"startup", "resume", "clear", "compact"};

Callers 1

Tested by

no test coverage detected