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

Source from the content-addressed store, hash-verified

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

Callers 1

Tested by

no test coverage detected