| 5883 | #define CMM_SESSION_REMINDER_SCRIPT_LEGACY "cbm-session-reminder" |
| 5884 | |
| 5885 | static bool cbm_install_session_reminder_script(const char *home, const char *binary_path) { |
| 5886 | if (!home || !binary_path) { |
| 5887 | return false; |
| 5888 | } |
| 5889 | char config_dir[CLI_BUF_1K]; |
| 5890 | cbm_claude_config_dir(home, config_dir, sizeof(config_dir)); |
| 5891 | if (!config_dir[0]) { |
| 5892 | return false; |
| 5893 | } |
| 5894 | char hooks_dir[CLI_BUF_1K]; |
| 5895 | int hooks_written = snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", config_dir); |
| 5896 | if (hooks_written <= 0 || (size_t)hooks_written >= sizeof(hooks_dir)) { |
| 5897 | return false; |
| 5898 | } |
| 5899 | if (!cbm_mkdir_p_ex(hooks_dir, CLI_OCTAL_PERM, CBM_MKDIR_FOLLOW_OWNED)) { |
| 5900 | return false; |
| 5901 | } |
| 5902 | |
| 5903 | char script_path[CLI_BUF_1K]; |
| 5904 | int script_written = |
| 5905 | snprintf(script_path, sizeof(script_path), "%s/" CMM_SESSION_REMINDER_SCRIPT, hooks_dir); |
| 5906 | if (script_written <= 0 || (size_t)script_written >= sizeof(script_path)) { |
| 5907 | return false; |
| 5908 | } |
| 5909 | |
| 5910 | char script[CLI_BUF_8K]; |
| 5911 | if (cbm_build_current_hook_script(cmm_session_script_prefix, binary_path, script, |
| 5912 | sizeof(script)) != CLI_OK) { |
| 5913 | return false; |
| 5914 | } |
| 5915 | const char *const legacy[] = {cmm_released_session_script}; |
| 5916 | #ifdef _WIN32 |
| 5917 | if (cbm_remove_owned_legacy_hook_script(hooks_dir, CMM_SESSION_REMINDER_SCRIPT_LEGACY, script, |
| 5918 | legacy, 1U) != CLI_OK) { |
| 5919 | return false; |
| 5920 | } |
| 5921 | #endif |
| 5922 | return cbm_write_owned_hook_script_with_legacy(script_path, script, legacy, 1U); |
| 5923 | } |
| 5924 | |
| 5925 | static int cbm_upsert_session_hooks(const char *settings_path, const char *binary_path) { |
| 5926 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected