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

Source from the content-addressed store, hash-verified

5061#define CMM_SESSION_REMINDER_SCRIPT_LEGACY "cbm-session-reminder"
5062
5063static bool cbm_install_session_reminder_script(const char *home, const char *binary_path) {
5064 if (!home || !binary_path) {
5065 return false;
5066 }
5067 char config_dir[CLI_BUF_1K];
5068 cbm_claude_config_dir(home, config_dir, sizeof(config_dir));
5069 if (!config_dir[0]) {
5070 return false;
5071 }
5072 char hooks_dir[CLI_BUF_1K];
5073 int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir);
5074 if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) {
5075 return false;
5076 }
5077 if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) {
5078 return false;
5079 }
5080
5081 char script_path[CLI_BUF_1K];
5082 int script_written =
5083 snprintf(script_path, sizeof(script_path), "%s/" CMM_SESSION_REMINDER_SCRIPT, hooks_dir);
5084 if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) {
5085 return false;
5086 }
5087
5088 char script[CLI_BUF_8K];
5089 if (cbm_build_current_hook_script(cmm_session_script_prefix, binary_path, script,
5090 sizeof(script)) != CLI_OK) {
5091 return false;
5092 }
5093 const char *const legacy[] = {cmm_released_session_script};
5094#ifdef _WIN32
5095 if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SESSION_REMINDER_SCRIPT_LEGACY, script,
5096 legacy, 1U) != CLI_OK) {
5097 return false;
5098 }
5099#endif
5100 return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U);
5101}
5102
5103static int cbm_upsert_session_hooks(const char *settings_path) {
5104 static const char *matchers[] = {"startup", "resume", "clear", "compact"};

Callers 1

Tested by

no test coverage detected