diff --git a/lib/code-notify/core/config.sh b/lib/code-notify/core/config.sh index 7b1cf1e..b1b06a5 100755 --- a/lib/code-notify/core/config.sh +++ b/lib/code-notify/core/config.sh @@ -448,7 +448,7 @@ has_legacy_global_claude_hooks() { grep -q 'claude-notify' "$file" || grep -qE 'notifier\.sh (notification|stop)"' "$file" || - grep -q 'notifier.sh PreToolUse' "$file" || + grep -qE 'notifier\.sh PreToolUse"' "$file" || grep -qE 'notify\.ps1.* (notification|stop)"' "$file" || grep -qE 'notify\.ps1.* PreToolUse' "$file" } diff --git a/tests/test-ask-user-alert.sh b/tests/test-ask-user-alert.sh index 57433d3..e0e5e83 100644 --- a/tests/test-ask-user-alert.sh +++ b/tests/test-ask-user-alert.sh @@ -13,7 +13,7 @@ mkdir -p "$CLAUDE_HOME/notifications" source "$ROOT_DIR/lib/code-notify/core/config.sh" -notify_script="$test_dir/notify.sh" +notify_script="$test_dir/notifier.sh" get_notify_script() { printf '%s\n' "$notify_script" } @@ -54,6 +54,10 @@ set_notify_types "idle_prompt|ask_user" enable_hooks_in_settings enable_hooks_in_settings +if claude_global_hooks_need_repair; then + fail "current ask_user hook was incorrectly flagged as legacy" +fi + python3 - "$GLOBAL_SETTINGS_FILE" "$notify_script" <<'PYTHON' import json import sys @@ -91,6 +95,29 @@ if not any( raise SystemExit("custom non-AskUserQuestion PreToolUse hook was not preserved") PYTHON +legacy_settings_file="$test_dir/legacy-settings.json" +cat > "$legacy_settings_file" <