| 5287 | #define CMM_SESSION_REMINDER_SCRIPT_LEGACY "cbm-session-reminder" |
| 5288 | |
| 5289 | static bool cbm_install_session_reminder_script(const char *home, const char *binary_path) { |
| 5290 | if (!home || !binary_path) { |
| 5291 | return false; |
| 5292 | } |
| 5293 | char config_dir[CLI_BUF_1K]; |
| 5294 | cbm_claude_config_dir(home, config_dir, sizeof(config_dir)); |
| 5295 | if (!config_dir[0]) { |
| 5296 | return false; |
| 5297 | } |
| 5298 | char hooks_dir[CLI_BUF_1K]; |
| 5299 | int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir); |
| 5300 | if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) { |
| 5301 | return false; |
| 5302 | } |
| 5303 | if (!cbm_mkdir_p(hooks_dir, CLI_OCTAL_PERM)) { |
| 5304 | return false; |
| 5305 | } |
| 5306 | |
| 5307 | char script_path[CLI_BUF_1K]; |
| 5308 | int script_written = |
| 5309 | snprintf(script_path, sizeof(script_path), "%s/" CMM_SESSION_REMINDER_SCRIPT, hooks_dir); |
| 5310 | if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) { |
| 5311 | return false; |
| 5312 | } |
| 5313 | |
| 5314 | char script[CLI_BUF_8K]; |
| 5315 | if (cbm_build_current_hook_script(cmm_session_script_prefix, binary_path, script, |
| 5316 | sizeof(script)) != CLI_OK) { |
| 5317 | return false; |
| 5318 | } |
| 5319 | const char *const legacy[] = {cmm_released_session_script}; |
| 5320 | #ifdef _WIN32 |
| 5321 | if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SESSION_REMINDER_SCRIPT_LEGACY, script, |
| 5322 | legacy, 1U) != CLI_OK) { |
| 5323 | return false; |
| 5324 | } |
| 5325 | #endif |
| 5326 | return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U); |
| 5327 | } |
| 5328 | |
| 5329 | static int cbm_upsert_session_hooks(const char *settings_path) { |
| 5330 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected