@@ -10046,7 +10046,7 @@ TEST(cli_claude_hook_commands_use_exec_form_with_custom_config_dir) {
1004610046 yyjson_doc *document = settings ? yyjson_read(settings, strlen(settings), 0) : NULL;
1004710047 yyjson_val *root = document ? yyjson_doc_get_root(document) : NULL;
1004810048 static const char *const matchers[] = {"startup", "resume", "clear", "compact"};
10049- size_t owned = test_count_exec_hook(root, "PreToolUse", "Grep|Glob", binary, "hook-augment") +
10049+ size_t owned = test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash ", binary, "hook-augment") +
1005010050 test_count_exec_hook(root, "PostToolUse", "Read", binary, "hook-augment") +
1005110051 test_count_exec_hook(root, "SubagentStart", "*", binary, "hook-augment");
1005210052 for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {
@@ -10914,7 +10914,7 @@ TEST(cli_upgrade_migrates_released_claude_hook_scripts) {
1091410914 yyjson_val *settings_root = settings_doc ? yyjson_doc_get_root(settings_doc) : NULL;
1091510915 static const char *const matchers[] = {"startup", "resume", "clear", "compact"};
1091610916 size_t registered =
10917- test_count_exec_hook(settings_root, "PreToolUse", "Grep|Glob", binary, "hook-augment") +
10917+ test_count_exec_hook(settings_root, "PreToolUse", "Grep|Glob|Bash ", binary, "hook-augment") +
1091810918 test_count_exec_hook(settings_root, "PostToolUse", "Read", binary, "hook-augment") +
1091910919 test_count_exec_hook(settings_root, "SubagentStart", "*", binary, "hook-augment");
1092010920 for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {
@@ -12124,8 +12124,13 @@ TEST(cli_windows_claude_lifecycle_migrates_only_exact_owned_legacy_state) {
1212412124 snprintf(settings_path, sizeof(settings_path), "%s/settings.json", config_dir);
1212512125 snprintf(appdata, sizeof(appdata), "%s/AppData/Roaming", tmpdir);
1212612126 snprintf(binary_path, sizeof(binary_path), "%s/.local/bin/codebase-memory-mcp.exe", tmpdir);
12127+ /* cbm_mkdtemp hands back a native '\\' temp root; the product normalizes
12128+ * the install directory before any registration (cbm_cmd_install), so the
12129+ * exact-owned exec command is the '/'-spelled path uninstall derives. */
12130+ cbm_normalize_path_sep(binary_path);
1212712131 test_mkdirp(hooks_dir);
1212812132
12133+ static const char *const matchers[] = {"startup", "resume", "clear", "compact"};
1212912134 const char *const script_names[] = {
1213012135 "cbm-code-discovery-gate",
1213112136 "cbm-session-reminder",
@@ -12199,13 +12204,21 @@ TEST(cli_windows_claude_lifecycle_migrates_only_exact_owned_legacy_state) {
1219912204 yyjson_doc *installed_doc =
1220012205 installed_settings ? yyjson_read(installed_settings, strlen(installed_settings), 0) : NULL;
1220112206 yyjson_val *installed_root = installed_doc ? yyjson_doc_get_root(installed_doc) : NULL;
12207+ /* Every owned shell spelling (current .cmd, previous, released) converges
12208+ * on one exec-form registration per matcher; foreign hooks are untouched. */
12209+ size_t installed_exec =
12210+ test_count_exec_hook(installed_root, "SubagentStart", "*", binary_path, "hook-augment");
12211+ for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {
12212+ installed_exec += test_count_exec_hook(installed_root, "SessionStart", matchers[i],
12213+ binary_path, "hook-augment");
12214+ }
1220212215 bool commands_migrated =
12203- install_rc == 0 &&
12204- test_count_hook_command(installed_root, "SessionStart", session_current) == 4U &&
12216+ install_rc == 0 && installed_exec == 5U &&
12217+ test_count_hook_command(installed_root, "SessionStart", session_current) == 0U &&
1220512218 test_count_hook_command(installed_root, "SessionStart", session_previous) == 0U &&
1220612219 test_count_hook_command(installed_root, "SessionStart", session_released) == 0U &&
1220712220 test_count_hook_command(installed_root, "SessionStart", foreign_command) == 1U &&
12208- test_count_hook_command(installed_root, "SubagentStart", subagent_current) == 1U &&
12221+ test_count_hook_command(installed_root, "SubagentStart", subagent_current) == 0U &&
1220912222 test_count_hook_command(installed_root, "SubagentStart", subagent_previous) == 0U &&
1221012223 test_count_hook_command(installed_root, "SubagentStart", subagent_released) == 0U &&
1221112224 test_count_hook_command(installed_root, "SubagentStart", foreign_command) == 1U;
@@ -12229,8 +12242,14 @@ TEST(cli_windows_claude_lifecycle_migrates_only_exact_owned_legacy_state) {
1222912242 uninstalled_settings ? yyjson_read(uninstalled_settings, strlen(uninstalled_settings), 0)
1223012243 : NULL;
1223112244 yyjson_val *uninstalled_root = uninstalled_doc ? yyjson_doc_get_root(uninstalled_doc) : NULL;
12245+ size_t uninstalled_exec =
12246+ test_count_exec_hook(uninstalled_root, "SubagentStart", "*", binary_path, "hook-augment");
12247+ for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {
12248+ uninstalled_exec += test_count_exec_hook(uninstalled_root, "SessionStart", matchers[i],
12249+ binary_path, "hook-augment");
12250+ }
1223212251 bool commands_clean =
12233- uninstall_rc == 0 &&
12252+ uninstall_rc == 0 && uninstalled_exec == 0U &&
1223412253 test_count_hook_command(uninstalled_root, "SessionStart", session_current) == 0U &&
1223512254 test_count_hook_command(uninstalled_root, "SessionStart", session_previous) == 0U &&
1223612255 test_count_hook_command(uninstalled_root, "SessionStart", session_released) == 0U &&
@@ -12453,7 +12472,7 @@ TEST(cli_claude_hooks_use_exec_form_across_shells_issue1733) {
1245312472 yyjson_doc *doc = settings ? yyjson_read(settings, strlen(settings), 0) : NULL;
1245412473 yyjson_val *root = doc ? yyjson_doc_get_root(doc) : NULL;
1245512474 size_t owned =
12456- test_count_exec_hook(root, "PreToolUse", "Grep|Glob", binary_path, "hook-augment") +
12475+ test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash ", binary_path, "hook-augment") +
1245712476 test_count_exec_hook(root, "PostToolUse", "Read", binary_path, "hook-augment") +
1245812477 test_count_exec_hook(root, "SubagentStart", "*", binary_path, "hook-augment");
1245912478 for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {
@@ -12516,7 +12535,7 @@ TEST(cli_claude_exec_hooks_custom_dir_uninstall_issue1733) {
1251612535 yyjson_val *installed_root = installed_doc ? yyjson_doc_get_root(installed_doc) : NULL;
1251712536 const char *const matchers[] = {"startup", "resume", "clear", "compact"};
1251812537 size_t before_owned =
12519- test_count_exec_hook(installed_root, "PreToolUse", "Grep|Glob", binary_path,
12538+ test_count_exec_hook(installed_root, "PreToolUse", "Grep|Glob|Bash ", binary_path,
1252012539 "hook-augment") +
1252112540 test_count_exec_hook(installed_root, "PostToolUse", "Read", binary_path,
1252212541 "hook-augment") +
0 commit comments