diff options
Diffstat (limited to 'tests/codex')
| -rwxr-xr-x | tests/codex/test-marketplace-manifest.sh | 36 | ||||
| -rwxr-xr-x | tests/codex/test-package-codex-plugin.sh | 7 |
2 files changed, 29 insertions, 14 deletions
diff --git a/tests/codex/test-marketplace-manifest.sh b/tests/codex/test-marketplace-manifest.sh index 4301a06..3bdde0b 100755 --- a/tests/codex/test-marketplace-manifest.sh +++ b/tests/codex/test-marketplace-manifest.sh @@ -52,25 +52,37 @@ if not plugin_manifest.exists(): manifest = json.loads(plugin_manifest.read_text(encoding="utf-8")) assert_equal(manifest.get("name"), plugin.get("name"), "plugin manifest name") -# Codex auto-discovers a plugin's hooks/hooks.json whenever the Codex manifest -# has no `hooks` field: load_plugin_hooks falls back to a hardcoded -# DEFAULT_HOOKS_CONFIG_FILE = "hooks/hooks.json" and registers it. That file is -# the Claude Code SessionStart hook, it is tracked in this repo, and this -# marketplace installs the whole repo root (source url "./"), so on Codex the -# fallback re-registers the SessionStart hook and its install-time trust prompt. -# Declaring an empty inline hooks object ({}) parses as an empty inline hook set -# and suppresses the auto-discovery. An absent field, an empty array ([]), and -# an empty inline list all collapse back to the fallback, so the value must be -# exactly an empty object. +# The Codex manifest must declare its hooks explicitly. An absent field makes +# load_plugin_hooks fall back to a hardcoded DEFAULT_HOOKS_CONFIG_FILE = +# "hooks/hooks.json" — the Claude Code SessionStart hook, which injects the +# bootstrap at startup and must not run on Codex. The explicit pointer both +# registers the Codex compaction re-injection hook and overrides that fallback. hooks_config = repo_root / "hooks" / "hooks.json" if not hooks_config.exists(): raise AssertionError("hooks/hooks.json must exist (Claude Code SessionStart hook)") assert_equal( manifest.get("hooks"), - {}, - "Codex manifest must declare empty hooks {} to suppress hooks/hooks.json auto-discovery", + "./hooks/hooks-codex.json", + "Codex manifest must point hooks at the Codex hook config (an absent field " + "falls back to auto-discovering the Claude Code hooks/hooks.json)", ) +codex_hooks_path = repo_root / "hooks" / "hooks-codex.json" +if not codex_hooks_path.exists(): + raise AssertionError("hooks/hooks-codex.json must exist (Codex manifest points at it)") + +codex_hooks = json.loads(codex_hooks_path.read_text(encoding="utf-8")) +session_start = codex_hooks["hooks"]["SessionStart"] +assert_equal(len(session_start), 1, "Codex SessionStart hook group count") +assert_equal(session_start[0].get("matcher"), "compact", "Codex hook matcher") +entry = session_start[0]["hooks"][0] +assert_equal(entry.get("type"), "command", "Codex hook type") +command = entry.get("command", "") +if "${PLUGIN_ROOT}" not in command or not command.endswith("session-start-codex"): + raise AssertionError( + f"Codex hook command must run session-start-codex via ${{PLUGIN_ROOT}}: {command!r}" + ) + print("Codex marketplace manifest looks good") PY diff --git a/tests/codex/test-package-codex-plugin.sh b/tests/codex/test-package-codex-plugin.sh index 947cb6d..b782bf4 100755 --- a/tests/codex/test-package-codex-plugin.sh +++ b/tests/codex/test-package-codex-plugin.sh @@ -141,7 +141,7 @@ tar_extracted="$TEST_ROOT/tar-extracted" write_metadata_fixture "$metadata_source" source_hooks="$(python3 -c 'import json; print(json.load(open("'"$REPO_ROOT"'/.codex-plugin/plugin.json")).get("hooks"))')" -assert_equals "$source_hooks" "{}" "source Codex manifest suppresses local hook auto-discovery" +assert_equals "$source_hooks" "./hooks/hooks-codex.json" "source Codex manifest declares the Codex hook config" if output="$("$SCRIPT_UNDER_TEST" --allow-dirty --metadata-source "$metadata_source" --output "$archive" 2>&1)"; then pass "package script exits successfully" @@ -163,10 +163,13 @@ assert_contains "$output" "SHA-256:" "reports archive checksum" extract_archive "$archive" "$extracted" archive_paths="$(list_archive "$archive" | normalize_archive_paths)" -unexpected_pattern='(^superpowers/|^\.agents/|^hooks/|package\.json$|^\.git|^\.pytest_cache|^\.ruff_cache|^scripts/|^tests/|^docs/|^evals/|^lib/|^\.claude|^\.cursor|^\.kimi|^\.opencode|^\.pi|^AGENTS\.md$|^CLAUDE\.md$|^GEMINI\.md$|^RELEASE-NOTES\.md$|^CHANGELOG\.md$)' +unexpected_pattern='(^superpowers/|^\.agents/|^hooks/hooks\.json$|^hooks/hooks-cursor\.json$|^hooks/session-start$|package\.json$|^\.git|^\.pytest_cache|^\.ruff_cache|^scripts/|^tests/|^docs/|^evals/|^lib/|^\.claude|^\.cursor|^\.kimi|^\.opencode|^\.pi|^AGENTS\.md$|^CLAUDE\.md$|^GEMINI\.md$|^RELEASE-NOTES\.md$|^CHANGELOG\.md$)' assert_not_matches "$archive_paths" "$unexpected_pattern" "archive excludes source-only paths" assert_contains "$archive_paths" ".codex-plugin/plugin.json" "archive includes Codex manifest" assert_contains "$archive_paths" "skills/brainstorming/SKILL.md" "archive includes skills" +assert_contains "$archive_paths" "hooks/hooks-codex.json" "archive includes Codex hook config" +assert_contains "$archive_paths" "hooks/session-start-codex" "archive includes Codex hook script" +assert_contains "$archive_paths" "hooks/run-hook.cmd" "archive includes hook runner" assert_contains "$archive_paths" "skills/brainstorming/agents/openai.yaml" "archive includes OpenAI skill metadata" assert_contains "$archive_paths" "assets/app-icon.png" "archive includes app icon" assert_contains "$archive_paths" "assets/superpowers-small.svg" "archive includes composer icon" |
