Преглед на файлове

test: add Codex native hook drill coverage

Drew Ritter преди 4 месеца
родител
ревизия
f5c43d6055
променени са 3 файла, в които са добавени 23 реда и са изтрити 3 реда
  1. 6 0
      docs/windows/polyglot-hooks.md
  2. 4 3
      hooks/session-start
  3. 13 0
      tests/hooks/test-session-start.sh

+ 6 - 0
docs/windows/polyglot-hooks.md

@@ -134,6 +134,12 @@ verified `${PLUGIN_ROOT}` placeholder and the `startup|resume|clear` matcher:
 }
 ```
 
+The matcher differs from Claude Code intentionally: the Codex spike verified
+`startup`, `resume`, and `clear` as Codex `SessionStart` sources. Keep
+Claude Code on `startup|clear|compact` until `resume` is explicitly verified
+there, and keep Codex off `compact` until Codex support for that source is
+verified.
+
 Note: The path must be quoted because plugin roots may contain spaces on
 Windows, for example `C:\Program Files\...`.
 

+ 4 - 3
hooks/session-start

@@ -7,10 +7,11 @@ set -euo pipefail
 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
 PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
 
-# Codex plugin hooks set Claude-compatible root env vars, so detect Codex
-# through its plugin data env before building platform-specific context.
+# Codex plugin hooks set both unprefixed PLUGIN_* vars and Claude-compatible
+# CLAUDE_* vars. Only the unprefixed data var is Codex-specific enough to
+# distinguish Codex from Claude Code.
 is_codex_hook=0
-if [ -n "${PLUGIN_DATA:-}" ] || [ -n "${CLAUDE_PLUGIN_DATA:-}" ]; then
+if [ -n "${PLUGIN_DATA:-}" ]; then
     is_codex_hook=1
 fi
 

+ 13 - 0
tests/hooks/test-session-start.sh

@@ -216,6 +216,19 @@ assert_command_output \
     CLAUDE_PLUGIN_ROOT="$REPO_ROOT" \
     bash "$HOOK_UNDER_TEST"
 
+claude_data_home="$(make_home claude-data-warning)"
+claude_data="$TEST_ROOT/claude-data-warning/data"
+mkdir -p "$claude_data_home/.config/superpowers/skills" "$claude_data"
+assert_command_output \
+    "Claude with CLAUDE_PLUGIN_DATA still uses Claude legacy warning" \
+    "nested" \
+    "Superpowers now uses Claude Code's skills system. Custom skills in ~/.config/superpowers/skills will not be read. Move custom skills to ~/.claude/skills instead." \
+    "" \
+    "$claude_data_home" \
+    CLAUDE_PLUGIN_DATA="$claude_data" \
+    CLAUDE_PLUGIN_ROOT="$REPO_ROOT" \
+    bash "$HOOK_UNDER_TEST"
+
 codex_legacy_home="$(make_home codex-legacy-warning)"
 codex_legacy_data="$TEST_ROOT/codex-legacy-warning/data"
 mkdir -p "$codex_legacy_home/.config/superpowers/skills" "$codex_legacy_data"