| 5842 | } |
| 5843 | |
| 5844 | static int cbm_remove_session_hooks(const char *settings_path, const char *binary_path) { |
| 5845 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
| 5846 | char shell_command[CLI_BUF_8K]; |
| 5847 | char previous_command[CLI_BUF_8K]; |
| 5848 | char released_command[CLI_BUF_8K]; |
| 5849 | char previous_legacy_command[CLI_BUF_8K]; |
| 5850 | char released_legacy_command[CLI_BUF_8K]; |
| 5851 | if (cbm_resolve_hook_command(CMM_SESSION_REMINDER_SCRIPT, shell_command, |
| 5852 | sizeof(shell_command)) != CLI_OK || |
| 5853 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT, previous_command, |
| 5854 | sizeof(previous_command)) != CLI_OK || |
| 5855 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT, released_command, |
| 5856 | sizeof(released_command)) != CLI_OK || |
| 5857 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5858 | previous_legacy_command, |
| 5859 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5860 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5861 | released_legacy_command, |
| 5862 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5863 | return CLI_ERR; |
| 5864 | } |
| 5865 | const char *command = binary_path && binary_path[0] ? binary_path : shell_command; |
| 5866 | const char *const *command_args = binary_path && binary_path[0] ? cmm_claude_exec_args : NULL; |
| 5867 | size_t command_arg_count = binary_path && binary_path[0] |
| 5868 | ? sizeof(cmm_claude_exec_args) / sizeof(cmm_claude_exec_args[0]) |
| 5869 | : 0U; |
| 5870 | const char *const old_commands[] = {shell_command, released_command, |
| 5871 | previous_command, released_legacy_command, |
| 5872 | previous_legacy_command, NULL}; |
| 5873 | int rc = 0; |
| 5874 | for (int i = 0; i < NUM_DIRS; i++) { |
| 5875 | if (remove_hooks_json((hooks_remove_args_t){.settings_path = settings_path, |
| 5876 | .hook_event = "SessionStart", |
| 5877 | .matcher_str = matchers[i], |
| 5878 | .old_commands = old_commands, |
| 5879 | .match_command_exact = command, |
| 5880 | .match_args = command_args, |
| 5881 | .match_arg_count = command_arg_count}) != 0) { |
| 5882 | rc = CLI_ERR; |
| 5883 | } |
| 5884 | } |
| 5885 | return rc; |
| 5886 | } |
| 5887 | |
| 5888 | static bool cbm_has_complete_claude_session_hooks(const char *home, const char *binary_path) { |
| 5889 | static const char *const matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected