From 7ff0f84b1e37a792ef6127a91f8ba3f83e1e3913 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 22 Mar 2026 11:28:16 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20test=20coverage=20catalog=20=E2=80=94?= =?UTF-8?q?=20shared=20audit=20across=20plan/ship/review=20(v0.10.1.0)=20(?= =?UTF-8?q?#259)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: extract {{TEST_COVERAGE_AUDIT}} shared resolver DRY extraction of the test coverage audit methodology into a shared generator function with three explicit placeholders: - TEST_COVERAGE_AUDIT_PLAN (plan-eng-review) - TEST_COVERAGE_AUDIT_SHIP (ship) - TEST_COVERAGE_AUDIT_REVIEW (review) Shared across all modes: codepath tracing, ASCII diagram format, quality scoring rubric, E2E test decision matrix, regression rule, and test framework detection via CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) * refactor: plan-eng-review uses shared test coverage audit Replace the thin 6-line Section 3 test review with the full shared methodology via {{TEST_COVERAGE_AUDIT_PLAN}}. Plan mode now: - Traces every codepath with full ASCII diagrams - Adds missing tests to the plan (not just "check for tests") - Writes test plan artifact for /qa consumption - Includes E2E/eval recommendations and regression detection Co-Authored-By: Claude Opus 4.6 (1M context) * refactor: ship uses shared test coverage audit Replace 135 lines of inline Step 3.4 methodology with {{TEST_COVERAGE_AUDIT_SHIP}}. Functionally identical output plus: - E2E test decision matrix (marks paths needing E2E vs unit) - Eval recommendations for LLM prompt changes - Regression detection iron rule - Test framework detection via CLAUDE.md first - Test plan artifact for /qa consumption Co-Authored-By: Claude Opus 4.6 (1M context) * feat: /review Step 4.75 test coverage diagram Add codepath tracing to the pre-landing review via {{TEST_COVERAGE_AUDIT_REVIEW}}. Review mode: - Produces ASCII coverage diagram (same methodology as plan/ship) - Generates tests for gaps via Fix-First (ASK user) - Subsumes Pass 2 "Test Gaps" checklist category - Gaps are INFORMATIONAL findings Co-Authored-By: Claude Opus 4.6 (1M context) * test: mode differentiation + regression guard for coverage audit 10 new tests verifying the three TEST_COVERAGE_AUDIT placeholders: - All modes share: codepath tracing, E2E matrix, regression rule - Plan mode: adds to plan + artifact, no ship-specific content - Ship mode: auto-generates + before/after count + coverage summary - Review mode: Fix-First ASK + INFORMATIONAL, no artifact - Regression guard: ship SKILL.md preserves all key phrases Co-Authored-By: Claude Opus 4.6 (1M context) * test: extract shared coverage audit fixture + review E2E - Extract billing.ts fixture into coverage-audit-fixture.ts (DRY) - Refactor ship-coverage-audit E2E to use shared fixture - Add review-coverage-audit E2E for Step 4.75 - Update touchfiles: both E2Es depend on shared fixture Co-Authored-By: Claude Opus 4.6 (1M context) * fix: strengthen E2E assertions for coverage audit tests The coverage audit E2E tests (ship + review) were only asserting exitReason === 'success' and readCalls > 0 — they passed even if the agent produced no coverage diagram. Add assertion that the output contains either GAP or TESTED markers. Found during /review. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: plan mode traces the plan, not the git diff Codex adversarial review caught that plan-eng-review was inheriting "git diff origin/...HEAD" from the shared resolver, but plan mode reviews a plan document, not a code diff. Plan mode now says: "Trace every codepath in the plan" and "Read the plan document." Ship and review modes keep the git diff instruction. Co-Authored-By: Claude Opus 4.6 (1M context) * chore: bump version and changelog (v0.9.5.0) Co-Authored-By: Claude Opus 4.6 * feat: test coverage catalog + failure triage (merged branches) (#285) * feat: add bin/gstack-repo-mode — solo vs collaborative detection with caching Detects whether a repo is solo-dev (one person does 80%+ of recent commits) or collaborative. Uses 90-day git shortlog window with 7-day cache in ~/.gstack/projects/{SLUG}/repo-mode.json. Config override via `gstack-config set repo_mode solo|collaborative` takes precedence over the heuristic. Minimum 5 commits required to classify (otherwise unknown). Co-Authored-By: Claude Opus 4.6 (1M context) * feat: test failure ownership triage — see something say something Adds two new preamble sections to all gstack skills: - Repo Ownership Mode: explains solo vs collaborative behavior - See Something, Say Something: proactive issue flagging principle Adds {{TEST_FAILURE_TRIAGE}} template variable (opt-in, used by /ship): - Classifies test failures as in-branch vs pre-existing - Solo mode defaults to "investigate and fix now" - Collaborative mode offers "blame + assign GitHub issue" option - Also offers P0 TODO and skip options /ship Step 3 now triages test failures instead of hard-stopping on all failures. In-branch failures still block shipping. Pre-existing failures get user-directed triage based on repo mode. Adds P2 TODO for gstack notes system (deferred lightweight reminder). Co-Authored-By: Claude Opus 4.6 (1M context) * chore: regenerate SKILL.md files for Claude and Codex hosts All 22 Claude skills and 21 Codex skills regenerated with new preamble sections (Repo Ownership Mode, See Something Say Something) and {{TEST_FAILURE_TRIAGE}} resolved in ship/SKILL.md. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: validate repo mode values to prevent shell injection Codex adversarial review found that unvalidated config/cache values could be injected into shell via source <(gstack-repo-mode). Added validate_mode() that only allows solo|collaborative|unknown — anything else becomes "unknown". Prevents persistent code execution through malicious config.yaml or tampered cache JSON. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: shell injection via branch names + feature-branch sampling bias Codex code review found two issues: P1: eval $(gstack-slug) in gstack-repo-mode executes branch names as shell. Branch names like foo$(touch${IFS}pwned) are valid git refs and would execute arbitrary commands. Fix: compute SLUG directly with sed instead of eval'ing gstack-slug output. P2: git shortlog HEAD only sees current branch history. On feature branches that haven't merged main recently, other contributors disappear from the sample. Fix: use git shortlog on the default branch (origin/main) instead of HEAD. Also improved blame lookup in collaborative triage to check both the test file and the production code it covers. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: broaden codex-host stripping test to accommodate triage section "Investigate and fix" now appears in TEST_FAILURE_TRIAGE (not just the Codex review step). Use CODEX_REVIEWS config string as a more specific marker for detecting the Codex review step in Codex-hosted skills. * fix: replace template placeholder in TODOS.md with readable text {{TEST_FAILURE_TRIAGE}} is template syntax but TODOS.md is not processed by gen-skill-docs — replaced with human-readable reference. * chore: bump version and changelog (v0.9.5.0) Co-Authored-By: Claude Opus 4.6 * docs: add bin/ directory to project structure in CLAUDE.md * test: add triage resolver unit tests, plan-eng coverage audit E2E, and triage E2E - TEST_FAILURE_TRIAGE resolver: 6 unit tests verifying all triage steps (T1-T4), REPO_MODE branching, and safety default for ambiguous failures - plan-eng-coverage-audit E2E: tests /plan-eng-review coverage audit codepath (gap identified during eng review — existed on neither branch) - ship-triage E2E: planted-bug fixture with in-branch (truncate null) and pre-existing (divide-by-zero) failures; verifies correct classification - Touchfile entries for diff-based test selection Co-Authored-By: Claude Opus 4.6 (1M context) * chore: regenerate stale Codex SKILL.md for retro Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) * fix: gstack-repo-mode handles repos without origin remote Split `git remote get-url origin` into a separate variable with `|| true` so the script doesn't crash under `set -euo pipefail` in local-only repos. Falls back to REPO_MODE=unknown gracefully. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: REPO_MODE defaults to unknown when helper emits nothing Changed preamble from `source <(...) || REPO_MODE=unknown` (which doesn't catch empty output) to `source <(...) || true` followed by `REPO_MODE=${REPO_MODE:-unknown}`. Regenerated all SKILL.md files. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: triage E2E runs both test files in subprocesses math.test.js called process.exit(1) which killed the runner before string.test.js could execute. Changed test runner to use child_process so each test runs independently and both failure classes are exercised. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: gstack-repo-mode handles repos without origin remote Fall back through origin/main → origin/master → HEAD when git symbolic-ref refs/remotes/origin/HEAD is not set. Prevents shortlog crash in repos where origin/HEAD isn't configured. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: triage E2E runs both test files in subprocesses Add assertions verifying both math.test.js (pre-existing failure) and string.test.js (in-branch failure) actually executed during triage. Prevents false passes where only one failure class is exercised. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: REPO_MODE defaults to unknown when helper emits nothing - Remove head -20 truncation that biased solo classification by dropping low-volume contributors from the denominator - Use atomic write (mktemp + mv) for cache to prevent concurrent preamble reads from seeing partial JSON Co-Authored-By: Claude Opus 4.6 (1M context) * docs: add test coverage catalog to CHANGELOG + update project structure - CHANGELOG: add 6 entries for coverage audit, review Step 4.75, E2E recommendations, regression iron rule, failure triage, repo-mode fix - CLAUDE.md: add missing skill directories (autoplan, benchmark, canary, codex, land-and-deploy, setup-deploy) to project structure Co-Authored-By: Claude Opus 4.6 (1M context) * chore: bump version and changelog (v0.10.1.0) Co-Authored-By: Claude Opus 4.6 (1M context) * docs: CHANGELOG rules — branch-scoped versions, never fold into old entries Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- .agents/skills/gstack-benchmark/SKILL.md | 15 + .agents/skills/gstack-browse/SKILL.md | 15 + .agents/skills/gstack-canary/SKILL.md | 15 + .../gstack-design-consultation/SKILL.md | 15 + .agents/skills/gstack-design-review/SKILL.md | 15 + .../skills/gstack-document-release/SKILL.md | 15 + .agents/skills/gstack-investigate/SKILL.md | 15 + .../skills/gstack-land-and-deploy/SKILL.md | 15 + .agents/skills/gstack-office-hours/SKILL.md | 15 + .../skills/gstack-plan-ceo-review/SKILL.md | 15 + .../skills/gstack-plan-design-review/SKILL.md | 15 + .../skills/gstack-plan-eng-review/SKILL.md | 188 +- .agents/skills/gstack-qa-only/SKILL.md | 15 + .agents/skills/gstack-qa/SKILL.md | 15 + .agents/skills/gstack-retro/SKILL.md | 15 + .agents/skills/gstack-review/SKILL.md | 192 + .../gstack-setup-browser-cookies/SKILL.md | 15 + .agents/skills/gstack-setup-deploy/SKILL.md | 15 + .agents/skills/gstack-ship/SKILL.md | 221 +- .agents/skills/gstack/SKILL.md | 15 + CHANGELOG.md | 16 + CLAUDE.md | 26 +- SKILL.md | 15 + VERSION | 2 +- benchmark/SKILL.md | 15 + bin/gstack-repo-mode | 93 + browse/SKILL.md | 15 + canary/SKILL.md | 15 + codex/SKILL.md | 15 + design-consultation/SKILL.md | 15 + design-review/SKILL.md | 15 + document-release/SKILL.md | 15 + investigate/SKILL.md | 15 + land-and-deploy/SKILL.md | 15 + office-hours/SKILL.md | 15 + plan-ceo-review/SKILL.md | 15 + plan-design-review/SKILL.md | 15 + plan-eng-review/SKILL.md | 188 +- plan-eng-review/SKILL.md.tmpl | 36 +- qa-only/SKILL.md | 15 + qa/SKILL.md | 15 + retro/SKILL.md | 15 + review/SKILL.md | 192 + review/SKILL.md.tmpl | 8 + scripts/gen-skill-docs.ts | 487 +++ setup-browser-cookies/SKILL.md | 15 + setup-deploy/SKILL.md | 15 + ship/SKILL.md | 221 +- ship/SKILL.md.tmpl | 142 +- test/fixtures/coverage-audit-fixture.ts | 76 + test/gen-skill-docs.test.ts | 148 +- test/helpers/touchfiles.ts | 9 +- test/skill-e2e.test.ts | 3325 +++++++++++++++++ test/skill-validation.test.ts | 59 +- 54 files changed, 5949 insertions(+), 205 deletions(-) create mode 100755 bin/gstack-repo-mode create mode 100644 test/fixtures/coverage-audit-fixture.ts create mode 100644 test/skill-e2e.test.ts diff --git a/.agents/skills/gstack-benchmark/SKILL.md b/.agents/skills/gstack-benchmark/SKILL.md index 08367649f546f1a4f701cd3afac550c3307431c6..4557cfda0a4dcabfed5e05f91e28e062fdbde945 100644 --- a/.agents/skills/gstack-benchmark/SKILL.md +++ b/.agents/skills/gstack-benchmark/SKILL.md @@ -24,6 +24,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -124,6 +127,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-browse/SKILL.md b/.agents/skills/gstack-browse/SKILL.md index 45a59485867ee188de581a4e528ac93e5c8386d8..f04d81b015c5bc9ba6947742fd45b3791d12339f 100644 --- a/.agents/skills/gstack-browse/SKILL.md +++ b/.agents/skills/gstack-browse/SKILL.md @@ -25,6 +25,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -125,6 +128,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-canary/SKILL.md b/.agents/skills/gstack-canary/SKILL.md index bdce7913c52d4069875c2dad76f17893b679756a..416f8e5d11645e2a222bb633429962aaaf5f8801 100644 --- a/.agents/skills/gstack-canary/SKILL.md +++ b/.agents/skills/gstack-canary/SKILL.md @@ -24,6 +24,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -124,6 +127,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-design-consultation/SKILL.md b/.agents/skills/gstack-design-consultation/SKILL.md index 29e1a222b47d2ace4a6e51b34368ed8c781c7724..905855c4ee082e58d1345db39878f8466b5d7100 100644 --- a/.agents/skills/gstack-design-consultation/SKILL.md +++ b/.agents/skills/gstack-design-consultation/SKILL.md @@ -26,6 +26,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -126,6 +129,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-design-review/SKILL.md b/.agents/skills/gstack-design-review/SKILL.md index 700bd33e5367f81459f207fc47d8c3c771fba39d..d80335dff80bd0bfbc9fce9ad28039ce81af7c84 100644 --- a/.agents/skills/gstack-design-review/SKILL.md +++ b/.agents/skills/gstack-design-review/SKILL.md @@ -26,6 +26,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -126,6 +129,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-document-release/SKILL.md b/.agents/skills/gstack-document-release/SKILL.md index ccf34824626de06ee9b735be886c03e1f1aab99f..7ca050ea4e2db9b856168d24443c64dd9eeff040 100644 --- a/.agents/skills/gstack-document-release/SKILL.md +++ b/.agents/skills/gstack-document-release/SKILL.md @@ -24,6 +24,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -124,6 +127,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-investigate/SKILL.md b/.agents/skills/gstack-investigate/SKILL.md index 0f53afef8ff63a8449a61cf2d38c91da80e1c27b..13ba2a114fc94e1b69e23658f4c2d6b27da725aa 100644 --- a/.agents/skills/gstack-investigate/SKILL.md +++ b/.agents/skills/gstack-investigate/SKILL.md @@ -27,6 +27,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -127,6 +130,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-land-and-deploy/SKILL.md b/.agents/skills/gstack-land-and-deploy/SKILL.md index 3f98480a45d09cb28bb8cb55a49ec2b78ba822f6..d24d11914510597b4159445280c181c006567cd8 100644 --- a/.agents/skills/gstack-land-and-deploy/SKILL.md +++ b/.agents/skills/gstack-land-and-deploy/SKILL.md @@ -23,6 +23,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -123,6 +126,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-office-hours/SKILL.md b/.agents/skills/gstack-office-hours/SKILL.md index 955f4400b75ff905facf46d14c714be7806c3700..5057847547d82b4f672b7204df449440c96e9a4f 100644 --- a/.agents/skills/gstack-office-hours/SKILL.md +++ b/.agents/skills/gstack-office-hours/SKILL.md @@ -28,6 +28,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -128,6 +131,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-plan-ceo-review/SKILL.md b/.agents/skills/gstack-plan-ceo-review/SKILL.md index f253d18d72e6cc5ca84b11537b2eef52d6c50359..8f9ac8a475eae9526441eeaa2f190a1c90d4403e 100644 --- a/.agents/skills/gstack-plan-ceo-review/SKILL.md +++ b/.agents/skills/gstack-plan-ceo-review/SKILL.md @@ -27,6 +27,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -127,6 +130,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-plan-design-review/SKILL.md b/.agents/skills/gstack-plan-design-review/SKILL.md index af092247823078d3eea65be916649819ed47b736..697362ff0576053939e4bd29dfdacc12cbf9854b 100644 --- a/.agents/skills/gstack-plan-design-review/SKILL.md +++ b/.agents/skills/gstack-plan-design-review/SKILL.md @@ -26,6 +26,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -126,6 +129,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-plan-eng-review/SKILL.md b/.agents/skills/gstack-plan-eng-review/SKILL.md index f2be53a3c4aaa8dfe3c943ad0e905b645f74925c..ae8440988de423fc0d6bdbb1d10c71508aa8e651 100644 --- a/.agents/skills/gstack-plan-eng-review/SKILL.md +++ b/.agents/skills/gstack-plan-eng-review/SKILL.md @@ -25,6 +25,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -125,6 +128,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. @@ -380,15 +395,174 @@ Evaluate: **STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. ### 3. Test review -Make a diagram of all new UX, new data flow, new codepaths, and new branching if statements or outcomes. For each, note what is new about the features discussed in this branch and plan. Then, for each new item in the diagram, make sure there is a corresponding test. -For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user. +100% coverage is the goal. Evaluate every codepath in the plan and ensure the plan includes tests for each one. If the plan is missing tests, add them — the plan should be complete enough that implementation includes full test coverage from the start. -**STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** still produce the coverage diagram, but skip test generation. + +**Step 1. Trace every codepath in the plan:** + +Read the plan document. For each new feature, service, endpoint, or component described, trace how data will flow through the code — don't just list planned functions, actually follow the planned execution: + +1. **Read the plan.** For each planned component, understand what it does and how it connects to existing code. +2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: + - Where does input come from? (request params, props, database, API call) + - What transforms it? (validation, mapping, computation) + - Where does it go? (database write, API response, rendered output, side effect) + - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) +3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: + - Every function/method that was added or modified + - Every conditional branch (if/else, switch, ternary, guard clause, early return) + - Every error path (try/catch, rescue, error boundary, fallback) + - Every call to another function (trace into it — does IT have untested branches?) + - Every edge: what happens with null input? Empty array? Invalid type? + +This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test. + +**Step 2. Map user flows, interactions, and error states:** + +Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: + +- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. +- **Interaction edge cases:** What happens when the user does something unexpected? + - Double-click/rapid resubmit + - Navigate away mid-operation (back button, close tab, click another link) + - Submit with stale data (page sat open for 30 minutes, session expired) + - Slow connection (API takes 10 seconds — what does the user see?) + - Concurrent actions (two tabs, same form) +- **Error states the user can see:** For every error the code handles, what does the user actually experience? + - Is there a clear error message or a silent failure? + - Can the user recover (retry, go back, fix input) or are they stuck? + - What happens with no network? With a 500 from the API? With invalid data from the server? +- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? + +Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else. + +**Step 3. Check each branch against existing tests:** + +Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: +- Function `processPayment()` → look for `billing.test.ts`, `billing.spec.ts`, `test/billing_test.rb` +- An if/else → look for tests covering BOTH the true AND false path +- An error handler → look for a test that triggers that specific error condition +- A call to `helperFn()` that has its own branches → those branches need tests too +- A user flow → look for an integration or E2E test that walks through the journey +- An interaction edge case → look for a test that simulates the unexpected action + +Quality scoring rubric: +- ★★★ Tests behavior with edge cases AND error paths +- ★★ Tests correct behavior, happy path only +- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") + +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is added to the plan as a critical requirement. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +**Step 4. Output ASCII coverage diagram:** + +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: + +``` +CODE PATH COVERAGE +=========================== +[+] src/services/billing.ts + │ + ├── processPayment() + │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 + │ ├── [GAP] Network timeout — NO TEST + │ └── [GAP] Invalid currency — NO TEST + │ + └── refundPayment() + ├── [★★ TESTED] Full refund — billing.test.ts:89 + └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 + +USER FLOW COVERAGE +=========================== +[+] Payment checkout flow + │ + ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + +[+] Error states + │ + ├── [★★ TESTED] Card declined message — billing.test.ts:58 + ├── [GAP] Network timeout UX (what does user see?) — NO TEST + └── [GAP] Empty cart submission — NO TEST + +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + +───────────────────────────────── +COVERAGE: 5/13 paths tested (38%) + Code paths: 3/5 (60%) + User flows: 2/8 (25%) +QUALITY: ★★★: 2 ★★: 2 ★: 1 +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) +───────────────────────────────── +``` + +**Fast path:** All paths covered → "Test review: All new code paths have test coverage ✓" Continue. + +**Step 5. Add missing tests to the plan:** + +For each GAP identified in the diagram, add a test requirement to the plan. Be specific: +- What test file to create (match existing naming conventions) +- What the test should assert (specific inputs → expected outputs/behavior) +- Whether it's a unit test, E2E test, or eval (use the decision matrix) +- For regressions: flag as **CRITICAL** and explain what broke + +The plan should be complete enough that when implementation begins, every test is written alongside the feature code — not deferred to a follow-up. ### Test Plan Artifact -After producing the test diagram, write a test plan artifact to the project directory so `/qa` and `/qa-only` can consume it as primary test input (replacing the lossy git-diff heuristic): +After producing the coverage diagram, write a test plan artifact to the project directory so `/qa` and `/qa-only` can consume it as primary test input: ```bash source <(~/.codex/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG @@ -396,7 +570,7 @@ USER=$(whoami) DATETIME=$(date +%Y%m%d-%H%M%S) ``` -Write to `~/.gstack/projects/{slug}/{user}-{branch}-test-plan-{datetime}.md`: +Write to `~/.gstack/projects/{slug}/{user}-{branch}-eng-review-test-plan-{datetime}.md`: ```markdown # Test Plan @@ -419,6 +593,10 @@ Repo: {owner/repo} This file is consumed by `/qa` and `/qa-only` as primary test input. Include only the information that helps a QA tester know **what to test and where** — not implementation details. +For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user. + +**STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. + ### 4. Performance review Evaluate: * N+1 queries and database access patterns. diff --git a/.agents/skills/gstack-qa-only/SKILL.md b/.agents/skills/gstack-qa-only/SKILL.md index f310fb25a42bbf6ed26e9d359485cf51599b9170..ef030993a3437b649df8cf18d7fbf880bd2a2b4c 100644 --- a/.agents/skills/gstack-qa-only/SKILL.md +++ b/.agents/skills/gstack-qa-only/SKILL.md @@ -24,6 +24,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -124,6 +127,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-qa/SKILL.md b/.agents/skills/gstack-qa/SKILL.md index 92e61a9ac3f1f014a105997963d72562b14a436a..191e6472a5cc1bb6b89ee1ef3b3a3d7f3320b714 100644 --- a/.agents/skills/gstack-qa/SKILL.md +++ b/.agents/skills/gstack-qa/SKILL.md @@ -27,6 +27,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -127,6 +130,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-retro/SKILL.md b/.agents/skills/gstack-retro/SKILL.md index a0b796bad5debb6600b038c60a9ffd9a926f436a..126bc9115da0f061f071aae56e1faef2cd61a2dd 100644 --- a/.agents/skills/gstack-retro/SKILL.md +++ b/.agents/skills/gstack-retro/SKILL.md @@ -24,6 +24,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -124,6 +127,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-review/SKILL.md b/.agents/skills/gstack-review/SKILL.md index 8d37d6ddbe257826ea07b9c204e177ab477a22ac..03c1bdba81cb7c955e33c99034c360c29a81464a 100644 --- a/.agents/skills/gstack-review/SKILL.md +++ b/.agents/skills/gstack-review/SKILL.md @@ -23,6 +23,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -123,6 +126,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. @@ -389,6 +404,183 @@ Include any design findings alongside the findings from Step 4. They follow the --- +## Step 4.75: Test Coverage Diagram + +100% coverage is the goal. Evaluate every codepath changed in the diff and identify test gaps. Gaps become INFORMATIONAL findings that follow the Fix-First flow. + +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** still produce the coverage diagram, but skip test generation. + +**Step 1. Trace every codepath changed** using `git diff origin/...HEAD`: + +Read every changed file. For each one, trace how data flows through the code — don't just list functions, actually follow the execution: + +1. **Read the diff.** For each changed file, read the full file (not just the diff hunk) to understand context. +2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: + - Where does input come from? (request params, props, database, API call) + - What transforms it? (validation, mapping, computation) + - Where does it go? (database write, API response, rendered output, side effect) + - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) +3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: + - Every function/method that was added or modified + - Every conditional branch (if/else, switch, ternary, guard clause, early return) + - Every error path (try/catch, rescue, error boundary, fallback) + - Every call to another function (trace into it — does IT have untested branches?) + - Every edge: what happens with null input? Empty array? Invalid type? + +This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test. + +**Step 2. Map user flows, interactions, and error states:** + +Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: + +- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. +- **Interaction edge cases:** What happens when the user does something unexpected? + - Double-click/rapid resubmit + - Navigate away mid-operation (back button, close tab, click another link) + - Submit with stale data (page sat open for 30 minutes, session expired) + - Slow connection (API takes 10 seconds — what does the user see?) + - Concurrent actions (two tabs, same form) +- **Error states the user can see:** For every error the code handles, what does the user actually experience? + - Is there a clear error message or a silent failure? + - Can the user recover (retry, go back, fix input) or are they stuck? + - What happens with no network? With a 500 from the API? With invalid data from the server? +- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? + +Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else. + +**Step 3. Check each branch against existing tests:** + +Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: +- Function `processPayment()` → look for `billing.test.ts`, `billing.spec.ts`, `test/billing_test.rb` +- An if/else → look for tests covering BOTH the true AND false path +- An error handler → look for a test that triggers that specific error condition +- A call to `helperFn()` that has its own branches → those branches need tests too +- A user flow → look for an integration or E2E test that walks through the journey +- An interaction edge case → look for a test that simulates the unexpected action + +Quality scoring rubric: +- ★★★ Tests behavior with edge cases AND error paths +- ★★ Tests correct behavior, happy path only +- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") + +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is written immediately. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +Format: commit as `test: regression test for {what broke}` + +**Step 4. Output ASCII coverage diagram:** + +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: + +``` +CODE PATH COVERAGE +=========================== +[+] src/services/billing.ts + │ + ├── processPayment() + │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 + │ ├── [GAP] Network timeout — NO TEST + │ └── [GAP] Invalid currency — NO TEST + │ + └── refundPayment() + ├── [★★ TESTED] Full refund — billing.test.ts:89 + └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 + +USER FLOW COVERAGE +=========================== +[+] Payment checkout flow + │ + ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + +[+] Error states + │ + ├── [★★ TESTED] Card declined message — billing.test.ts:58 + ├── [GAP] Network timeout UX (what does user see?) — NO TEST + └── [GAP] Empty cart submission — NO TEST + +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + +───────────────────────────────── +COVERAGE: 5/13 paths tested (38%) + Code paths: 3/5 (60%) + User flows: 2/8 (25%) +QUALITY: ★★★: 2 ★★: 2 ★: 1 +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) +───────────────────────────────── +``` + +**Fast path:** All paths covered → "Step 4.75: All new code paths have test coverage ✓" Continue. + +**Step 5. Generate tests for gaps (Fix-First):** + +If test framework is detected and gaps were identified: +- Classify each gap as AUTO-FIX or ASK per the Fix-First Heuristic: + - **AUTO-FIX:** Simple unit tests for pure functions, edge cases of existing tested functions + - **ASK:** E2E tests, tests requiring new test infrastructure, tests for ambiguous behavior +- For AUTO-FIX gaps: generate the test, run it, commit as `test: coverage for {feature}` +- For ASK gaps: include in the Fix-First batch question with the other review findings +- For paths marked [→E2E]: always ASK (E2E tests are higher-effort and need user confirmation) +- For paths marked [→EVAL]: always ASK (eval tests need user confirmation on quality criteria) + +If no test framework detected → include gaps as INFORMATIONAL findings only, no generation. + +**Diff is test-only changes:** Skip Step 4.75 entirely: "No new application code paths to audit." + +This step subsumes the "Test Gaps" category from Pass 2 — do not duplicate findings between the checklist Test Gaps item and this coverage diagram. Include any coverage gaps alongside the findings from Step 4 and Step 4.5. They follow the same Fix-First flow — gaps are INFORMATIONAL findings. + +--- + ## Step 5: Fix-First Review **Every finding gets action — not just critical ones.** diff --git a/.agents/skills/gstack-setup-browser-cookies/SKILL.md b/.agents/skills/gstack-setup-browser-cookies/SKILL.md index 49e2e900baba6acbadccc6bc9cb0a7b8de2c7141..f52a7511ad9cebd4158dedac00505600a0adf7e8 100644 --- a/.agents/skills/gstack-setup-browser-cookies/SKILL.md +++ b/.agents/skills/gstack-setup-browser-cookies/SKILL.md @@ -23,6 +23,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -123,6 +126,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-setup-deploy/SKILL.md b/.agents/skills/gstack-setup-deploy/SKILL.md index 33ce5d713bea03da954b292a925105add77cb724..355de0865e446bd0b089432b3c93603222f22622 100644 --- a/.agents/skills/gstack-setup-deploy/SKILL.md +++ b/.agents/skills/gstack-setup-deploy/SKILL.md @@ -25,6 +25,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -125,6 +128,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/.agents/skills/gstack-ship/SKILL.md b/.agents/skills/gstack-ship/SKILL.md index 442c4a7297b73da474f5ea13a7a8dfbe44da6401..e53d02d8c195e8683907b27a426f1ab48ab6c423 100644 --- a/.agents/skills/gstack-ship/SKILL.md +++ b/.agents/skills/gstack-ship/SKILL.md @@ -21,6 +21,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -121,6 +124,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. @@ -257,7 +272,7 @@ You are running the `/ship` workflow. This is a **non-interactive, fully automat **Only stop for:** - On the base branch (abort) - Merge conflicts that can't be auto-resolved (stop, show conflicts) -- Test failures (stop, show failures) +- In-branch test failures (pre-existing failures are triaged, not auto-blocking) - Pre-landing review finds ASK items that need user judgment - MINOR or MAJOR version bump needed (ask — see Step 4) - Greptile review comments that need user decision (complex fixes, false positives) @@ -541,7 +556,105 @@ wait After both complete, read the output files and check pass/fail. -**If any test fails:** Show the failures and **STOP**. Do not proceed. +**If any test fails:** Do NOT immediately stop. Apply the Test Failure Ownership Triage: + +## Test Failure Ownership Triage + +When tests fail, do NOT immediately stop. First, determine ownership: + +### Step T1: Classify each failure + +For each failing test: + +1. **Get the files changed on this branch:** + ```bash + git diff origin/...HEAD --name-only + ``` + +2. **Classify the failure:** + - **In-branch** if: the failing test file itself was modified on this branch, OR the test output references code that was changed on this branch, OR you can trace the failure to a change in the branch diff. + - **Likely pre-existing** if: neither the test file nor the code it tests was modified on this branch, AND the failure is unrelated to any branch change you can identify. + - **When ambiguous, default to in-branch.** It is safer to stop the developer than to let a broken test ship. Only classify as pre-existing when you are confident. + + This classification is heuristic — use your judgment reading the diff and the test output. You do not have a programmatic dependency graph. + +### Step T2: Handle in-branch failures + +**STOP.** These are your failures. Show them and do not proceed. The developer must fix their own broken tests before shipping. + +### Step T3: Handle pre-existing failures + +Check `REPO_MODE` from the preamble output. + +**If REPO_MODE is `solo`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> Since this is a solo repo, you're the only one who will fix these. +> +> RECOMMENDATION: Choose A — fix now while the context is fresh. Completeness: 9/10. +> A) Investigate and fix now (human: ~2-4h / CC: ~15min) — Completeness: 10/10 +> B) Add as P0 TODO — fix after this branch lands — Completeness: 7/10 +> C) Skip — I know about this, ship anyway — Completeness: 3/10 + +**If REPO_MODE is `collaborative` or `unknown`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> This is a collaborative repo — these may be someone else's responsibility. +> +> RECOMMENDATION: Choose B — assign it to whoever broke it so the right person fixes it. Completeness: 9/10. +> A) Investigate and fix now anyway — Completeness: 10/10 +> B) Blame + assign GitHub issue to the author — Completeness: 9/10 +> C) Add as P0 TODO — Completeness: 7/10 +> D) Skip — ship anyway — Completeness: 3/10 + +### Step T4: Execute the chosen action + +**If "Investigate and fix now":** +- Switch to /investigate mindset: root cause first, then minimal fix. +- Fix the pre-existing failure. +- Commit the fix separately from the branch's changes: `git commit -m "fix: pre-existing test failure in "` +- Continue with the workflow. + +**If "Add as P0 TODO":** +- If `TODOS.md` exists, add the entry following the format in `review/TODOS-format.md` (or `.agents/skills/gstack/review/TODOS-format.md`). +- If `TODOS.md` does not exist, create it with the standard header and add the entry. +- Entry should include: title, the error output, which branch it was noticed on, and priority P0. +- Continue with the workflow — treat the pre-existing failure as non-blocking. + +**If "Blame + assign GitHub issue" (collaborative only):** +- Find who likely broke it. Check BOTH the test file AND the production code it tests: + ```bash + # Who last touched the failing test? + git log --format="%an (%ae)" -1 -- + # Who last touched the production code the test covers? (often the actual breaker) + git log --format="%an (%ae)" -1 -- + ``` + If these are different people, prefer the production code author — they likely introduced the regression. +- Create a GitHub issue assigned to that person: + ```bash + gh issue create \ + --title "Pre-existing test failure: " \ + --body "Found failing on branch . Failure is pre-existing.\n\n**Error:**\n```\n\n```\n\n**Last modified by:** \n**Noticed by:** gstack /ship on " \ + --assignee "" + ``` +- If `gh` is not available or `--assignee` fails (user not in org, etc.), create the issue without assignee and note who should look at it in the body. +- Continue with the workflow. + +**If "Skip":** +- Continue with the workflow. +- Note in output: "Pre-existing test failure skipped: " + +**After triage:** If any in-branch failures remain unfixed, **STOP**. Do not proceed. If all failures were pre-existing and handled (fixed, TODOed, assigned, or skipped), continue to Step 3.25. **If all pass:** Continue silently — just note the counts briefly. @@ -613,6 +726,27 @@ If multiple suites need to run, run them sequentially (each needs a test lane). 100% coverage is the goal — every untested path is a path where bugs hide and vibe coding becomes yolo coding. Evaluate what was ACTUALLY coded (from the diff), not what was planned. +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** falls through to the Test Framework Bootstrap step (Step 2.5) which handles full setup. + **0. Before/after test count:** ```bash @@ -675,9 +809,41 @@ Quality scoring rubric: - ★★ Tests correct behavior, happy path only - ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is written immediately. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +Format: commit as `test: regression test for {what broke}` + **4. Output ASCII coverage diagram:** -Include BOTH code paths and user flows in the same diagram: +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: ``` CODE PATH COVERAGE @@ -698,9 +864,9 @@ USER FLOW COVERAGE [+] Payment checkout flow │ ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 - ├── [GAP] Double-click submit — NO TEST - ├── [GAP] Navigate away during payment — NO TEST - └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 [+] Error states │ @@ -708,12 +874,16 @@ USER FLOW COVERAGE ├── [GAP] Network timeout UX (what does user see?) — NO TEST └── [GAP] Empty cart submission — NO TEST +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + ───────────────────────────────── -COVERAGE: 5/12 paths tested (42%) +COVERAGE: 5/13 paths tested (38%) Code paths: 3/5 (60%) - User flows: 2/7 (29%) + User flows: 2/8 (25%) QUALITY: ★★★: 2 ★★: 2 ★: 1 -GAPS: 7 paths need tests +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) ───────────────────────────────── ``` @@ -725,6 +895,8 @@ If test framework detected (or bootstrapped in Step 2.5): - Prioritize error handlers and edge cases first (happy paths are more likely already tested) - Read 2-3 existing test files to match conventions exactly - Generate unit tests. Mock all external dependencies (DB, API, Redis). +- For paths marked [→E2E]: generate integration/E2E tests using the project's E2E framework (Playwright, Cypress, Capybara, etc.) +- For paths marked [→EVAL]: generate eval tests using the project's eval framework, or flag for manual eval if none exists - Write tests that exercise the specific uncovered path with real assertions - Run each test. Passes → commit as `test: coverage for {feature}` - Fails → fix once. Still fails → revert, note gap in diagram. @@ -745,6 +917,37 @@ find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec For PR body: `Tests: {before} → {after} (+{delta} new)` Coverage line: `Test Coverage Audit: N new code paths. M covered (X%). K tests generated, J committed.` +### Test Plan Artifact + +After producing the coverage diagram, write a test plan artifact so `/qa` and `/qa-only` can consume it: + +```bash +source <(~/.codex/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG +USER=$(whoami) +DATETIME=$(date +%Y%m%d-%H%M%S) +``` + +Write to `~/.gstack/projects/{slug}/{user}-{branch}-ship-test-plan-{datetime}.md`: + +```markdown +# Test Plan +Generated by /ship on {date} +Branch: {branch} +Repo: {owner/repo} + +## Affected Pages/Routes +- {URL path} — {what to test and why} + +## Key Interactions to Verify +- {interaction description} on {page} + +## Edge Cases +- {edge case} on {page} + +## Critical Paths +- {end-to-end flow that must work} +``` + --- ## Step 3.5: Pre-Landing Review diff --git a/.agents/skills/gstack/SKILL.md b/.agents/skills/gstack/SKILL.md index e7c19582c0778f6b994668b2e9f712b14072422a..fa89afd5a6a70a5c3bcf6d8c21c8bd8c4d0932f2 100644 --- a/.agents/skills/gstack/SKILL.md +++ b/.agents/skills/gstack/SKILL.md @@ -57,6 +57,9 @@ _PROACTIVE=$(~/.codex/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.codex/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.codex/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -157,6 +160,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.codex/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eea57d6e5afdc12d278e786d777e2b3138ba92d..d9a4bf614e681e9de829f889dbaaf0c8cb5e14db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## [0.10.1.0] - 2026-03-22 — Test Coverage Catalog + +### Added + +- **Test coverage audit now works everywhere — plan, ship, and review.** The codepath tracing methodology (ASCII diagrams, quality scoring, gap detection) is shared across `/plan-eng-review`, `/ship`, and `/review` via a single `{{TEST_COVERAGE_AUDIT}}` resolver. Plan mode adds missing tests to your plan before you write code. Ship mode auto-generates tests for gaps. Review mode finds untested paths during pre-landing review. One methodology, three contexts, zero copy-paste. +- **`/review` Step 4.75 — test coverage diagram.** Before landing code, `/review` now traces every changed codepath and produces an ASCII coverage map showing what's tested (★★★/★★/★) and what's not (GAP). Gaps become INFORMATIONAL findings that follow the Fix-First flow — you can generate the missing tests right there. +- **E2E test recommendations built in.** The coverage audit knows when to recommend E2E tests (common user flows, tricky integrations where unit tests can't cover it) vs unit tests, and flags LLM prompt changes that need eval coverage. No more guessing whether something needs an integration test. +- **Regression detection iron rule.** When a code change modifies existing behavior, gstack always writes a regression test — no asking, no skipping. If you changed it, you test it. +- **`/ship` failure triage.** When tests fail during ship, the coverage audit classifies each failure and recommends next steps instead of just dumping the error output. +- **Test framework auto-detection.** Reads your CLAUDE.md for test commands first, then auto-detects from project files (package.json, Gemfile, pyproject.toml, etc.). Works with any framework. + +### Fixed + +- **gstack no longer crashes in repos without an `origin` remote.** The `gstack-repo-mode` helper now gracefully handles missing remotes, bare repos, and empty git output — defaulting to `unknown` mode instead of crashing the preamble. +- **`REPO_MODE` defaults correctly when the helper emits nothing.** Previously an empty response from `gstack-repo-mode` left `REPO_MODE` unset, causing downstream template errors. + ## [0.10.0.0] - 2026-03-22 — Autoplan ### Added diff --git a/CLAUDE.md b/CLAUDE.md index 6adb48b987a793cbd0a5be7929ea11b2732c019e..e18070e9b60d1766c267fc886a06ac055f18944c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -71,10 +71,17 @@ gstack/ ├── review/ # PR review skill ├── plan-ceo-review/ # /plan-ceo-review skill ├── plan-eng-review/ # /plan-eng-review skill +├── autoplan/ # /autoplan skill (auto-review pipeline: CEO → design → eng) +├── benchmark/ # /benchmark skill (performance regression detection) +├── canary/ # /canary skill (post-deploy monitoring loop) +├── codex/ # /codex skill (multi-AI second opinion via OpenAI Codex CLI) +├── land-and-deploy/ # /land-and-deploy skill (merge → deploy → canary verify) ├── office-hours/ # /office-hours skill (YC Office Hours — startup diagnostic + builder brainstorm) ├── investigate/ # /investigate skill (systematic root-cause debugging) ├── retro/ # Retrospective skill ├── document-release/ # /document-release skill (post-ship doc updates) +├── setup-deploy/ # /setup-deploy skill (one-time deploy config) +├── bin/ # CLI utilities (gstack-repo-mode, gstack-slug, gstack-config, etc.) ├── setup # One-time setup: build binary + symlink skills ├── SKILL.md # Generated from SKILL.md.tmpl (don't edit directly) ├── SKILL.md.tmpl # Template: edit this, run gen:skill-docs @@ -169,7 +176,24 @@ Examples of good bisection: When the user says "bisect commit" or "bisect and push," split staged/unstaged changes into logical commits and push. -## CHANGELOG style +## CHANGELOG + VERSION style + +**VERSION and CHANGELOG are branch-scoped.** Every feature branch that ships gets its +own version bump and CHANGELOG entry. The entry describes what THIS branch adds — +not what was already on main. + +**When to write the CHANGELOG entry:** +- At `/ship` time (Step 5), not during development or mid-branch. +- The entry covers ALL commits on this branch vs the base branch. +- Never fold new work into an existing CHANGELOG entry from a prior version that + already landed on main. If main has v0.10.0.0 and your branch adds features, + bump to v0.10.1.0 with a new entry — don't edit the v0.10.0.0 entry. + +**Key questions before writing:** +1. What branch am I on? What did THIS branch change? +2. Is the base branch version already released? (If yes, bump and create new entry.) +3. Does an existing entry on this branch already cover earlier work? (If yes, replace + it with one unified entry for the final version.) CHANGELOG.md is **for users**, not contributors. Write it like product release notes: diff --git a/SKILL.md b/SKILL.md index ee84d7368452d347ec18e4bca2aaee723065a827..f3cf04c06d009a82fd780b3ac70667d21facbbc5 100644 --- a/SKILL.md +++ b/SKILL.md @@ -63,6 +63,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -163,6 +166,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/VERSION b/VERSION index b8d6a6d72fc2449ebf51b05330fa176cc23e41ed..b6bee8bf41afe922a382ce5dbc5b2646382bcac5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.0.0 +0.10.1.0 diff --git a/benchmark/SKILL.md b/benchmark/SKILL.md index e52ecb3ac42916d9a0cc6c5073067dea98e86ade..c6845b2c4085320900be8c43a406a40229ae555e 100644 --- a/benchmark/SKILL.md +++ b/benchmark/SKILL.md @@ -31,6 +31,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -131,6 +134,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/bin/gstack-repo-mode b/bin/gstack-repo-mode new file mode 100755 index 0000000000000000000000000000000000000000..0b4d6da64fb86aa3458d3111de5c7b5bce8f6e7f --- /dev/null +++ b/bin/gstack-repo-mode @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# gstack-repo-mode — detect solo vs collaborative repo mode +# Usage: source <(gstack-repo-mode) → sets REPO_MODE variable +# Or: gstack-repo-mode → prints REPO_MODE=... line +# +# Detection heuristic (90-day window): +# Solo: top author >= 80% of commits +# Collaborative: top author < 80% +# +# Override: gstack-config set repo_mode solo|collaborative +# Cache: ~/.gstack/projects/$SLUG/repo-mode.json (7-day TTL) +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# Compute SLUG directly (avoid eval of gstack-slug — branch names can contain shell metacharacters) +REMOTE_URL=$(git remote get-url origin 2>/dev/null || true) +if [ -z "$REMOTE_URL" ]; then + echo "REPO_MODE=unknown" + exit 0 +fi +SLUG=$(echo "$REMOTE_URL" | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-') +[ -z "${SLUG:-}" ] && { echo "REPO_MODE=unknown"; exit 0; } + +# Validate: only allow known values (prevent shell injection via source <(...)) +validate_mode() { + case "$1" in solo|collaborative|unknown) echo "$1" ;; *) echo "unknown" ;; esac +} + +# Config override takes precedence +OVERRIDE=$("$SCRIPT_DIR/gstack-config" get repo_mode 2>/dev/null || true) +if [ -n "$OVERRIDE" ] && [ "$OVERRIDE" != "null" ]; then + echo "REPO_MODE=$(validate_mode "$OVERRIDE")" + exit 0 +fi + +# Check cache (7-day TTL) +CACHE_DIR="$HOME/.gstack/projects/$SLUG" +CACHE_FILE="$CACHE_DIR/repo-mode.json" +if [ -f "$CACHE_FILE" ]; then + CACHE_AGE=$(( $(date +%s) - $(stat -f %m "$CACHE_FILE" 2>/dev/null || stat -c %Y "$CACHE_FILE" 2>/dev/null || echo 0) )) + if [ "$CACHE_AGE" -lt 604800 ]; then # 7 days in seconds + MODE=$(grep -o '"mode":"[^"]*"' "$CACHE_FILE" | head -1 | cut -d'"' -f4) + [ -n "$MODE" ] && echo "REPO_MODE=$(validate_mode "$MODE")" && exit 0 + fi +fi + +# Compute from git history (90-day window) +# Use default branch (not HEAD) to avoid feature-branch sampling bias +DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/||' || true) +# Fallback: try origin/main, then origin/master, then HEAD +if [ -z "$DEFAULT_BRANCH" ]; then + if git rev-parse --verify origin/main &>/dev/null; then + DEFAULT_BRANCH="origin/main" + elif git rev-parse --verify origin/master &>/dev/null; then + DEFAULT_BRANCH="origin/master" + else + DEFAULT_BRANCH="HEAD" + fi +fi +SHORTLOG=$(git shortlog -sn --since="90 days ago" --no-merges "$DEFAULT_BRANCH" 2>/dev/null) +if [ -z "$SHORTLOG" ]; then + echo "REPO_MODE=unknown" + exit 0 +fi + +# Compute TOTAL from ALL authors (not truncated) to avoid solo bias +TOTAL=$(echo "$SHORTLOG" | awk '{s+=$1} END {print s}') +TOP=$(echo "$SHORTLOG" | head -1 | awk '{print $1}') +AUTHORS=$(echo "$SHORTLOG" | wc -l | tr -d ' ') + +# Minimum sample: need at least 5 commits to classify +if [ "$TOTAL" -lt 5 ]; then + echo "REPO_MODE=unknown" + exit 0 +fi + +TOP_PCT=$(( TOP * 100 / TOTAL )) + +# Solo: top author >= 80% of commits (occasional outside PRs don't change mode) +if [ "$TOP_PCT" -ge 80 ]; then + MODE=solo +else + MODE=collaborative +fi + +# Cache result atomically (fail silently if ~/.gstack is unwritable) +mkdir -p "$CACHE_DIR" 2>/dev/null || true +CACHE_TMP=$(mktemp "$CACHE_DIR/.repo-mode-XXXXXX" 2>/dev/null || true) +if [ -n "$CACHE_TMP" ]; then + echo "{\"mode\":\"$MODE\",\"top_pct\":$TOP_PCT,\"authors\":$AUTHORS,\"total\":$TOTAL,\"computed\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > "$CACHE_TMP" 2>/dev/null && mv "$CACHE_TMP" "$CACHE_FILE" 2>/dev/null || rm -f "$CACHE_TMP" 2>/dev/null +fi + +echo "REPO_MODE=$MODE" diff --git a/browse/SKILL.md b/browse/SKILL.md index e7ab62056d7db809a6d1dfc58dfad070fb6778f0..6e0f07314fa8daa0ac81f38f533552349b7a9f03 100644 --- a/browse/SKILL.md +++ b/browse/SKILL.md @@ -31,6 +31,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -131,6 +134,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/canary/SKILL.md b/canary/SKILL.md index 047415c69a63148ad105ab75cc7195e7da2d7bc3..f3f1c1ae40c9e7aa9bb0708b18a129cbb7cbbe8e 100644 --- a/canary/SKILL.md +++ b/canary/SKILL.md @@ -31,6 +31,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -131,6 +134,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/codex/SKILL.md b/codex/SKILL.md index 86715597ca4499b8ef5c8f1772f197f5e270981e..bb7d397d0ffa4b8b6b9dad1aeb41b4c3a19d6a53 100644 --- a/codex/SKILL.md +++ b/codex/SKILL.md @@ -32,6 +32,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -132,6 +135,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.md index f707f5b34db73810b1c6936b059c30150ef6438c..bf63f4a6704f6a33cbca08d0f6ea7e7cce84fb96 100644 --- a/design-consultation/SKILL.md +++ b/design-consultation/SKILL.md @@ -36,6 +36,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -136,6 +139,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/design-review/SKILL.md b/design-review/SKILL.md index 606ed2cd18f5ab0010f7bae967d79c559c0f27c4..2e1b30d7ddcfd5c13020329417bf0b90dcd8abd8 100644 --- a/design-review/SKILL.md +++ b/design-review/SKILL.md @@ -36,6 +36,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -136,6 +139,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/document-release/SKILL.md b/document-release/SKILL.md index 7beb7a9e94a189519d669e60face0f5536fe5906..0fb5422269bfffba25d7fff370273f1eefe12a10 100644 --- a/document-release/SKILL.md +++ b/document-release/SKILL.md @@ -33,6 +33,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -133,6 +136,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/investigate/SKILL.md b/investigate/SKILL.md index 9a61f5401c018181b74c1360cbe31ca85439675e..de20ab6d050814a00699436a85d3443c761820cf 100644 --- a/investigate/SKILL.md +++ b/investigate/SKILL.md @@ -47,6 +47,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -147,6 +150,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/land-and-deploy/SKILL.md b/land-and-deploy/SKILL.md index d37798bff2d1153cb10ccfcf4225f8b78c97baae..497fbc98554c2d5f5394dbf4ed7f83c29d64fc02 100644 --- a/land-and-deploy/SKILL.md +++ b/land-and-deploy/SKILL.md @@ -30,6 +30,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -130,6 +133,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/office-hours/SKILL.md b/office-hours/SKILL.md index 37c772c1137c1bddbb3683a164b506b08c1ca687..2a98fab3b88bea6c79684dcdd7a8e5fbf88aba88 100644 --- a/office-hours/SKILL.md +++ b/office-hours/SKILL.md @@ -38,6 +38,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -138,6 +141,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index 28ba5910aa5fb6ca7459cde5eba920570fde4793..b28966aa81a9a64b197be01c12e2ba208d3cd82a 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -36,6 +36,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -136,6 +139,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index d7aaa3e8ec1eef256a2734b6cb7935f0b2368e6a..3b9be845223c5deb4c7187c0aba9915f41093d93 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -34,6 +34,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -134,6 +137,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.md index b3f099a01167927c55231dab84a927a13fff91e0..9950f52b225aa27d8261d6d2519a92cd0673b46a 100644 --- a/plan-eng-review/SKILL.md +++ b/plan-eng-review/SKILL.md @@ -35,6 +35,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -135,6 +138,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. @@ -390,15 +405,174 @@ Evaluate: **STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. ### 3. Test review -Make a diagram of all new UX, new data flow, new codepaths, and new branching if statements or outcomes. For each, note what is new about the features discussed in this branch and plan. Then, for each new item in the diagram, make sure there is a corresponding test. -For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user. +100% coverage is the goal. Evaluate every codepath in the plan and ensure the plan includes tests for each one. If the plan is missing tests, add them — the plan should be complete enough that implementation includes full test coverage from the start. -**STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** still produce the coverage diagram, but skip test generation. + +**Step 1. Trace every codepath in the plan:** + +Read the plan document. For each new feature, service, endpoint, or component described, trace how data will flow through the code — don't just list planned functions, actually follow the planned execution: + +1. **Read the plan.** For each planned component, understand what it does and how it connects to existing code. +2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: + - Where does input come from? (request params, props, database, API call) + - What transforms it? (validation, mapping, computation) + - Where does it go? (database write, API response, rendered output, side effect) + - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) +3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: + - Every function/method that was added or modified + - Every conditional branch (if/else, switch, ternary, guard clause, early return) + - Every error path (try/catch, rescue, error boundary, fallback) + - Every call to another function (trace into it — does IT have untested branches?) + - Every edge: what happens with null input? Empty array? Invalid type? + +This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test. + +**Step 2. Map user flows, interactions, and error states:** + +Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: + +- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. +- **Interaction edge cases:** What happens when the user does something unexpected? + - Double-click/rapid resubmit + - Navigate away mid-operation (back button, close tab, click another link) + - Submit with stale data (page sat open for 30 minutes, session expired) + - Slow connection (API takes 10 seconds — what does the user see?) + - Concurrent actions (two tabs, same form) +- **Error states the user can see:** For every error the code handles, what does the user actually experience? + - Is there a clear error message or a silent failure? + - Can the user recover (retry, go back, fix input) or are they stuck? + - What happens with no network? With a 500 from the API? With invalid data from the server? +- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? + +Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else. + +**Step 3. Check each branch against existing tests:** + +Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: +- Function `processPayment()` → look for `billing.test.ts`, `billing.spec.ts`, `test/billing_test.rb` +- An if/else → look for tests covering BOTH the true AND false path +- An error handler → look for a test that triggers that specific error condition +- A call to `helperFn()` that has its own branches → those branches need tests too +- A user flow → look for an integration or E2E test that walks through the journey +- An interaction edge case → look for a test that simulates the unexpected action + +Quality scoring rubric: +- ★★★ Tests behavior with edge cases AND error paths +- ★★ Tests correct behavior, happy path only +- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") + +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is added to the plan as a critical requirement. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +**Step 4. Output ASCII coverage diagram:** + +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: + +``` +CODE PATH COVERAGE +=========================== +[+] src/services/billing.ts + │ + ├── processPayment() + │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 + │ ├── [GAP] Network timeout — NO TEST + │ └── [GAP] Invalid currency — NO TEST + │ + └── refundPayment() + ├── [★★ TESTED] Full refund — billing.test.ts:89 + └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 + +USER FLOW COVERAGE +=========================== +[+] Payment checkout flow + │ + ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + +[+] Error states + │ + ├── [★★ TESTED] Card declined message — billing.test.ts:58 + ├── [GAP] Network timeout UX (what does user see?) — NO TEST + └── [GAP] Empty cart submission — NO TEST + +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + +───────────────────────────────── +COVERAGE: 5/13 paths tested (38%) + Code paths: 3/5 (60%) + User flows: 2/8 (25%) +QUALITY: ★★★: 2 ★★: 2 ★: 1 +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) +───────────────────────────────── +``` + +**Fast path:** All paths covered → "Test review: All new code paths have test coverage ✓" Continue. + +**Step 5. Add missing tests to the plan:** + +For each GAP identified in the diagram, add a test requirement to the plan. Be specific: +- What test file to create (match existing naming conventions) +- What the test should assert (specific inputs → expected outputs/behavior) +- Whether it's a unit test, E2E test, or eval (use the decision matrix) +- For regressions: flag as **CRITICAL** and explain what broke + +The plan should be complete enough that when implementation begins, every test is written alongside the feature code — not deferred to a follow-up. ### Test Plan Artifact -After producing the test diagram, write a test plan artifact to the project directory so `/qa` and `/qa-only` can consume it as primary test input (replacing the lossy git-diff heuristic): +After producing the coverage diagram, write a test plan artifact to the project directory so `/qa` and `/qa-only` can consume it as primary test input: ```bash source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG @@ -406,7 +580,7 @@ USER=$(whoami) DATETIME=$(date +%Y%m%d-%H%M%S) ``` -Write to `~/.gstack/projects/{slug}/{user}-{branch}-test-plan-{datetime}.md`: +Write to `~/.gstack/projects/{slug}/{user}-{branch}-eng-review-test-plan-{datetime}.md`: ```markdown # Test Plan @@ -429,6 +603,10 @@ Repo: {owner/repo} This file is consumed by `/qa` and `/qa-only` as primary test input. Include only the information that helps a QA tester know **what to test and where** — not implementation details. +For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user. + +**STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. + ### 4. Performance review Evaluate: * N+1 queries and database access patterns. diff --git a/plan-eng-review/SKILL.md.tmpl b/plan-eng-review/SKILL.md.tmpl index f48bdd497c8b98fcc7f06621f146a3dc7d7f2b1a..c9ebde44d57522107736a3715dbdd97a8a00f651 100644 --- a/plan-eng-review/SKILL.md.tmpl +++ b/plan-eng-review/SKILL.md.tmpl @@ -149,45 +149,13 @@ Evaluate: **STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. ### 3. Test review -Make a diagram of all new UX, new data flow, new codepaths, and new branching if statements or outcomes. For each, note what is new about the features discussed in this branch and plan. Then, for each new item in the diagram, make sure there is a corresponding test. + +{{TEST_COVERAGE_AUDIT_PLAN}} For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user. **STOP.** For each issue found in this section, call AskUserQuestion individually. One issue per call. Present options, state your recommendation, explain WHY. Do NOT batch multiple issues into one AskUserQuestion. Only proceed to the next section after ALL issues in this section are resolved. -### Test Plan Artifact - -After producing the test diagram, write a test plan artifact to the project directory so `/qa` and `/qa-only` can consume it as primary test input (replacing the lossy git-diff heuristic): - -```bash -source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG -USER=$(whoami) -DATETIME=$(date +%Y%m%d-%H%M%S) -``` - -Write to `~/.gstack/projects/{slug}/{user}-{branch}-test-plan-{datetime}.md`: - -```markdown -# Test Plan -Generated by /plan-eng-review on {date} -Branch: {branch} -Repo: {owner/repo} - -## Affected Pages/Routes -- {URL path} — {what to test and why} - -## Key Interactions to Verify -- {interaction description} on {page} - -## Edge Cases -- {edge case} on {page} - -## Critical Paths -- {end-to-end flow that must work} -``` - -This file is consumed by `/qa` and `/qa-only` as primary test input. Include only the information that helps a QA tester know **what to test and where** — not implementation details. - ### 4. Performance review Evaluate: * N+1 queries and database access patterns. diff --git a/qa-only/SKILL.md b/qa-only/SKILL.md index a46233a3bd942d406dbc25ce55a670570c576c10..d71f8fafad3bd2e2e0efdeb14b77bcb89bdcfbff 100644 --- a/qa-only/SKILL.md +++ b/qa-only/SKILL.md @@ -31,6 +31,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -131,6 +134,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/qa/SKILL.md b/qa/SKILL.md index 6e7d49a003397d9faf7b82fee6a7fb9b278bf0b6..03edad8c761b0d434b545a71b51788596a8eebf6 100644 --- a/qa/SKILL.md +++ b/qa/SKILL.md @@ -37,6 +37,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -137,6 +140,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/retro/SKILL.md b/retro/SKILL.md index 635b5747cd647ed128625c1c3098b4e40927650d..cfbd258b5b5f6d9ee0d847df93f2f4a895a3864a 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -31,6 +31,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -131,6 +134,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/review/SKILL.md b/review/SKILL.md index abf517a48441b4848641bea20714bc44339796b2..5bbf79c3ab196ad4f9a9321ad97a4bcb35ca00d9 100644 --- a/review/SKILL.md +++ b/review/SKILL.md @@ -34,6 +34,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -134,6 +137,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. @@ -400,6 +415,183 @@ Include any design findings alongside the findings from Step 4. They follow the --- +## Step 4.75: Test Coverage Diagram + +100% coverage is the goal. Evaluate every codepath changed in the diff and identify test gaps. Gaps become INFORMATIONAL findings that follow the Fix-First flow. + +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** still produce the coverage diagram, but skip test generation. + +**Step 1. Trace every codepath changed** using `git diff origin/...HEAD`: + +Read every changed file. For each one, trace how data flows through the code — don't just list functions, actually follow the execution: + +1. **Read the diff.** For each changed file, read the full file (not just the diff hunk) to understand context. +2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: + - Where does input come from? (request params, props, database, API call) + - What transforms it? (validation, mapping, computation) + - Where does it go? (database write, API response, rendered output, side effect) + - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) +3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: + - Every function/method that was added or modified + - Every conditional branch (if/else, switch, ternary, guard clause, early return) + - Every error path (try/catch, rescue, error boundary, fallback) + - Every call to another function (trace into it — does IT have untested branches?) + - Every edge: what happens with null input? Empty array? Invalid type? + +This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test. + +**Step 2. Map user flows, interactions, and error states:** + +Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: + +- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. +- **Interaction edge cases:** What happens when the user does something unexpected? + - Double-click/rapid resubmit + - Navigate away mid-operation (back button, close tab, click another link) + - Submit with stale data (page sat open for 30 minutes, session expired) + - Slow connection (API takes 10 seconds — what does the user see?) + - Concurrent actions (two tabs, same form) +- **Error states the user can see:** For every error the code handles, what does the user actually experience? + - Is there a clear error message or a silent failure? + - Can the user recover (retry, go back, fix input) or are they stuck? + - What happens with no network? With a 500 from the API? With invalid data from the server? +- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? + +Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else. + +**Step 3. Check each branch against existing tests:** + +Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: +- Function `processPayment()` → look for `billing.test.ts`, `billing.spec.ts`, `test/billing_test.rb` +- An if/else → look for tests covering BOTH the true AND false path +- An error handler → look for a test that triggers that specific error condition +- A call to `helperFn()` that has its own branches → those branches need tests too +- A user flow → look for an integration or E2E test that walks through the journey +- An interaction edge case → look for a test that simulates the unexpected action + +Quality scoring rubric: +- ★★★ Tests behavior with edge cases AND error paths +- ★★ Tests correct behavior, happy path only +- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") + +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is written immediately. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +Format: commit as `test: regression test for {what broke}` + +**Step 4. Output ASCII coverage diagram:** + +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: + +``` +CODE PATH COVERAGE +=========================== +[+] src/services/billing.ts + │ + ├── processPayment() + │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 + │ ├── [GAP] Network timeout — NO TEST + │ └── [GAP] Invalid currency — NO TEST + │ + └── refundPayment() + ├── [★★ TESTED] Full refund — billing.test.ts:89 + └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 + +USER FLOW COVERAGE +=========================== +[+] Payment checkout flow + │ + ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + +[+] Error states + │ + ├── [★★ TESTED] Card declined message — billing.test.ts:58 + ├── [GAP] Network timeout UX (what does user see?) — NO TEST + └── [GAP] Empty cart submission — NO TEST + +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + +───────────────────────────────── +COVERAGE: 5/13 paths tested (38%) + Code paths: 3/5 (60%) + User flows: 2/8 (25%) +QUALITY: ★★★: 2 ★★: 2 ★: 1 +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) +───────────────────────────────── +``` + +**Fast path:** All paths covered → "Step 4.75: All new code paths have test coverage ✓" Continue. + +**Step 5. Generate tests for gaps (Fix-First):** + +If test framework is detected and gaps were identified: +- Classify each gap as AUTO-FIX or ASK per the Fix-First Heuristic: + - **AUTO-FIX:** Simple unit tests for pure functions, edge cases of existing tested functions + - **ASK:** E2E tests, tests requiring new test infrastructure, tests for ambiguous behavior +- For AUTO-FIX gaps: generate the test, run it, commit as `test: coverage for {feature}` +- For ASK gaps: include in the Fix-First batch question with the other review findings +- For paths marked [→E2E]: always ASK (E2E tests are higher-effort and need user confirmation) +- For paths marked [→EVAL]: always ASK (eval tests need user confirmation on quality criteria) + +If no test framework detected → include gaps as INFORMATIONAL findings only, no generation. + +**Diff is test-only changes:** Skip Step 4.75 entirely: "No new application code paths to audit." + +This step subsumes the "Test Gaps" category from Pass 2 — do not duplicate findings between the checklist Test Gaps item and this coverage diagram. Include any coverage gaps alongside the findings from Step 4 and Step 4.5. They follow the same Fix-First flow — gaps are INFORMATIONAL findings. + +--- + ## Step 5: Fix-First Review **Every finding gets action — not just critical ones.** diff --git a/review/SKILL.md.tmpl b/review/SKILL.md.tmpl index 0ecb07f5bf3a0946e737358fd02b5e11f43039e4..a33b0fa8edc1e73b1c8ce7b443ad73c2bad61d56 100644 --- a/review/SKILL.md.tmpl +++ b/review/SKILL.md.tmpl @@ -128,6 +128,14 @@ Include any design findings alongside the findings from Step 4. They follow the --- +## Step 4.75: Test Coverage Diagram + +{{TEST_COVERAGE_AUDIT_REVIEW}} + +This step subsumes the "Test Gaps" category from Pass 2 — do not duplicate findings between the checklist Test Gaps item and this coverage diagram. Include any coverage gaps alongside the findings from Step 4 and Step 4.5. They follow the same Fix-First flow — gaps are INFORMATIONAL findings. + +--- + ## Step 5: Fix-First Review **Every finding gets action — not just critical ones.** diff --git a/scripts/gen-skill-docs.ts b/scripts/gen-skill-docs.ts index 27718933acc653bdf17f516fca448e4d34fb840b..08c388f69cce94ddb306ffe579703db284dcec69 100644 --- a/scripts/gen-skill-docs.ts +++ b/scripts/gen-skill-docs.ts @@ -152,6 +152,9 @@ _PROACTIVE=$(${ctx.paths.binDir}/gstack-config get proactive 2>/dev/null || echo _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(${ctx.paths.binDir}/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=\${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -263,6 +266,118 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.")`; } +function generateRepoModeSection(): string { + return `## Repo Ownership Mode — See Something, Say Something + +\`REPO_MODE\` from the preamble tells you who owns issues in this repo: + +- **\`solo\`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **\`collaborative\`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **\`unknown\`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication.`; +} + +function generateTestFailureTriage(): string { + return `## Test Failure Ownership Triage + +When tests fail, do NOT immediately stop. First, determine ownership: + +### Step T1: Classify each failure + +For each failing test: + +1. **Get the files changed on this branch:** + \`\`\`bash + git diff origin/...HEAD --name-only + \`\`\` + +2. **Classify the failure:** + - **In-branch** if: the failing test file itself was modified on this branch, OR the test output references code that was changed on this branch, OR you can trace the failure to a change in the branch diff. + - **Likely pre-existing** if: neither the test file nor the code it tests was modified on this branch, AND the failure is unrelated to any branch change you can identify. + - **When ambiguous, default to in-branch.** It is safer to stop the developer than to let a broken test ship. Only classify as pre-existing when you are confident. + + This classification is heuristic — use your judgment reading the diff and the test output. You do not have a programmatic dependency graph. + +### Step T2: Handle in-branch failures + +**STOP.** These are your failures. Show them and do not proceed. The developer must fix their own broken tests before shipping. + +### Step T3: Handle pre-existing failures + +Check \`REPO_MODE\` from the preamble output. + +**If REPO_MODE is \`solo\`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> Since this is a solo repo, you're the only one who will fix these. +> +> RECOMMENDATION: Choose A — fix now while the context is fresh. Completeness: 9/10. +> A) Investigate and fix now (human: ~2-4h / CC: ~15min) — Completeness: 10/10 +> B) Add as P0 TODO — fix after this branch lands — Completeness: 7/10 +> C) Skip — I know about this, ship anyway — Completeness: 3/10 + +**If REPO_MODE is \`collaborative\` or \`unknown\`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> This is a collaborative repo — these may be someone else's responsibility. +> +> RECOMMENDATION: Choose B — assign it to whoever broke it so the right person fixes it. Completeness: 9/10. +> A) Investigate and fix now anyway — Completeness: 10/10 +> B) Blame + assign GitHub issue to the author — Completeness: 9/10 +> C) Add as P0 TODO — Completeness: 7/10 +> D) Skip — ship anyway — Completeness: 3/10 + +### Step T4: Execute the chosen action + +**If "Investigate and fix now":** +- Switch to /investigate mindset: root cause first, then minimal fix. +- Fix the pre-existing failure. +- Commit the fix separately from the branch's changes: \`git commit -m "fix: pre-existing test failure in "\` +- Continue with the workflow. + +**If "Add as P0 TODO":** +- If \`TODOS.md\` exists, add the entry following the format in \`review/TODOS-format.md\` (or \`.claude/skills/review/TODOS-format.md\`). +- If \`TODOS.md\` does not exist, create it with the standard header and add the entry. +- Entry should include: title, the error output, which branch it was noticed on, and priority P0. +- Continue with the workflow — treat the pre-existing failure as non-blocking. + +**If "Blame + assign GitHub issue" (collaborative only):** +- Find who likely broke it. Check BOTH the test file AND the production code it tests: + \`\`\`bash + # Who last touched the failing test? + git log --format="%an (%ae)" -1 -- + # Who last touched the production code the test covers? (often the actual breaker) + git log --format="%an (%ae)" -1 -- + \`\`\` + If these are different people, prefer the production code author — they likely introduced the regression. +- Create a GitHub issue assigned to that person: + \`\`\`bash + gh issue create \\ + --title "Pre-existing test failure: " \\ + --body "Found failing on branch . Failure is pre-existing.\\n\\n**Error:**\\n\`\`\`\\n\\n\`\`\`\\n\\n**Last modified by:** \\n**Noticed by:** gstack /ship on " \\ + --assignee "" + \`\`\` +- If \`gh\` is not available or \`--assignee\` fails (user not in org, etc.), create the issue without assignee and note who should look at it in the body. +- Continue with the workflow. + +**If "Skip":** +- Continue with the workflow. +- Note in output: "Pre-existing test failure skipped: "`; +} + function generateSearchBeforeBuildingSection(ctx: TemplateContext): string { return `## Search Before Building @@ -387,6 +502,7 @@ function generatePreamble(ctx: TemplateContext): string { generateTelemetryPrompt(ctx), generateAskUserFormat(ctx), generateCompletenessSection(), + generateRepoModeSection(), generateSearchBeforeBuildingSection(ctx), generateContributorMode(), generateCompletionStatus(), @@ -1354,6 +1470,373 @@ Only commit if there are changes. Stage all bootstrap files (config, test direct ---`; } +// ─── Test Coverage Audit ──────────────────────────────────── +// +// Shared methodology for codepath tracing, ASCII diagrams, and test gap analysis. +// Three modes, three placeholders, one inner function: +// +// {{TEST_COVERAGE_AUDIT_PLAN}} → plan-eng-review: adds missing tests to the plan +// {{TEST_COVERAGE_AUDIT_SHIP}} → ship: auto-generates tests, coverage summary +// {{TEST_COVERAGE_AUDIT_REVIEW}} → review: generates tests via Fix-First (ASK) +// +// ┌────────────────────────────────────────────────┐ +// │ generateTestCoverageAuditInner(mode) │ +// │ │ +// │ SHARED: framework detect, codepath trace, │ +// │ ASCII diagram, quality rubric, E2E matrix, │ +// │ regression rule │ +// │ │ +// │ plan: edit plan file, write artifact │ +// │ ship: auto-generate tests, write artifact │ +// │ review: Fix-First ASK, INFORMATIONAL gaps │ +// └────────────────────────────────────────────────┘ + +type CoverageAuditMode = 'plan' | 'ship' | 'review'; + +function generateTestCoverageAuditInner(mode: CoverageAuditMode): string { + const sections: string[] = []; + + // ── Intro (mode-specific) ── + if (mode === 'ship') { + sections.push(`100% coverage is the goal — every untested path is a path where bugs hide and vibe coding becomes yolo coding. Evaluate what was ACTUALLY coded (from the diff), not what was planned.`); + } else if (mode === 'plan') { + sections.push(`100% coverage is the goal. Evaluate every codepath in the plan and ensure the plan includes tests for each one. If the plan is missing tests, add them — the plan should be complete enough that implementation includes full test coverage from the start.`); + } else { + sections.push(`100% coverage is the goal. Evaluate every codepath changed in the diff and identify test gaps. Gaps become INFORMATIONAL findings that follow the Fix-First flow.`); + } + + // ── Test framework detection (shared) ── + sections.push(` +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a \`## Testing\` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +\`\`\`bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +\`\`\` + +3. **If no framework detected:**${mode === 'ship' ? ' falls through to the Test Framework Bootstrap step (Step 2.5) which handles full setup.' : ' still produce the coverage diagram, but skip test generation.'}`); + + // ── Before/after count (ship only) ── + if (mode === 'ship') { + sections.push(` +**0. Before/after test count:** + +\`\`\`bash +# Count test files before any generation +find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +\`\`\` + +Store this number for the PR body.`); + } + + // ── Codepath tracing methodology (shared, with mode-specific source) ── + const traceSource = mode === 'plan' + ? `**Step 1. Trace every codepath in the plan:** + +Read the plan document. For each new feature, service, endpoint, or component described, trace how data will flow through the code — don't just list planned functions, actually follow the planned execution:` + : `**${mode === 'ship' ? '1' : 'Step 1'}. Trace every codepath changed** using \`git diff origin/...HEAD\`: + +Read every changed file. For each one, trace how data flows through the code — don't just list functions, actually follow the execution:`; + + const traceStep1 = mode === 'plan' + ? `1. **Read the plan.** For each planned component, understand what it does and how it connects to existing code.` + : `1. **Read the diff.** For each changed file, read the full file (not just the diff hunk) to understand context.`; + + sections.push(` +${traceSource} + +${traceStep1} +2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: + - Where does input come from? (request params, props, database, API call) + - What transforms it? (validation, mapping, computation) + - Where does it go? (database write, API response, rendered output, side effect) + - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) +3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: + - Every function/method that was added or modified + - Every conditional branch (if/else, switch, ternary, guard clause, early return) + - Every error path (try/catch, rescue, error boundary, fallback) + - Every call to another function (trace into it — does IT have untested branches?) + - Every edge: what happens with null input? Empty array? Invalid type? + +This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test.`); + + // ── User flow coverage (shared) ── + sections.push(` +**${mode === 'ship' ? '2' : 'Step 2'}. Map user flows, interactions, and error states:** + +Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: + +- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. +- **Interaction edge cases:** What happens when the user does something unexpected? + - Double-click/rapid resubmit + - Navigate away mid-operation (back button, close tab, click another link) + - Submit with stale data (page sat open for 30 minutes, session expired) + - Slow connection (API takes 10 seconds — what does the user see?) + - Concurrent actions (two tabs, same form) +- **Error states the user can see:** For every error the code handles, what does the user actually experience? + - Is there a clear error message or a silent failure? + - Can the user recover (retry, go back, fix input) or are they stuck? + - What happens with no network? With a 500 from the API? With invalid data from the server? +- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? + +Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else.`); + + // ── Check branches against tests + quality rubric (shared) ── + sections.push(` +**${mode === 'ship' ? '3' : 'Step 3'}. Check each branch against existing tests:** + +Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: +- Function \`processPayment()\` → look for \`billing.test.ts\`, \`billing.spec.ts\`, \`test/billing_test.rb\` +- An if/else → look for tests covering BOTH the true AND false path +- An error handler → look for a test that triggers that specific error condition +- A call to \`helperFn()\` that has its own branches → those branches need tests too +- A user flow → look for an integration or E2E test that walks through the journey +- An interaction edge case → look for a test that simulates the unexpected action + +Quality scoring rubric: +- ★★★ Tests behavior with edge cases AND error paths +- ★★ Tests correct behavior, happy path only +- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw")`); + + // ── E2E test decision matrix (shared) ── + sections.push(` +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing`); + + // ── Regression rule (shared) ── + sections.push(` +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is ${mode === 'plan' ? 'added to the plan as a critical requirement' : 'written immediately'}. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test.${mode !== 'plan' ? '\n\nFormat: commit as `test: regression test for {what broke}`' : ''}`); + + // ── ASCII coverage diagram (shared) ── + sections.push(` +**${mode === 'ship' ? '4' : 'Step 4'}. Output ASCII coverage diagram:** + +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: + +\`\`\` +CODE PATH COVERAGE +=========================== +[+] src/services/billing.ts + │ + ├── processPayment() + │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 + │ ├── [GAP] Network timeout — NO TEST + │ └── [GAP] Invalid currency — NO TEST + │ + └── refundPayment() + ├── [★★ TESTED] Full refund — billing.test.ts:89 + └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 + +USER FLOW COVERAGE +=========================== +[+] Payment checkout flow + │ + ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + +[+] Error states + │ + ├── [★★ TESTED] Card declined message — billing.test.ts:58 + ├── [GAP] Network timeout UX (what does user see?) — NO TEST + └── [GAP] Empty cart submission — NO TEST + +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + +───────────────────────────────── +COVERAGE: 5/13 paths tested (38%) + Code paths: 3/5 (60%) + User flows: 2/8 (25%) +QUALITY: ★★★: 2 ★★: 2 ★: 1 +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) +───────────────────────────────── +\`\`\` + +**Fast path:** All paths covered → "${mode === 'ship' ? 'Step 3.4' : mode === 'review' ? 'Step 4.75' : 'Test review'}: All new code paths have test coverage ✓" Continue.`); + + // ── Mode-specific action section ── + if (mode === 'plan') { + sections.push(` +**Step 5. Add missing tests to the plan:** + +For each GAP identified in the diagram, add a test requirement to the plan. Be specific: +- What test file to create (match existing naming conventions) +- What the test should assert (specific inputs → expected outputs/behavior) +- Whether it's a unit test, E2E test, or eval (use the decision matrix) +- For regressions: flag as **CRITICAL** and explain what broke + +The plan should be complete enough that when implementation begins, every test is written alongside the feature code — not deferred to a follow-up.`); + + // ── Test plan artifact (plan + ship) ── + sections.push(` +### Test Plan Artifact + +After producing the coverage diagram, write a test plan artifact to the project directory so \`/qa\` and \`/qa-only\` can consume it as primary test input: + +\`\`\`bash +source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG +USER=$(whoami) +DATETIME=$(date +%Y%m%d-%H%M%S) +\`\`\` + +Write to \`~/.gstack/projects/{slug}/{user}-{branch}-eng-review-test-plan-{datetime}.md\`: + +\`\`\`markdown +# Test Plan +Generated by /plan-eng-review on {date} +Branch: {branch} +Repo: {owner/repo} + +## Affected Pages/Routes +- {URL path} — {what to test and why} + +## Key Interactions to Verify +- {interaction description} on {page} + +## Edge Cases +- {edge case} on {page} + +## Critical Paths +- {end-to-end flow that must work} +\`\`\` + +This file is consumed by \`/qa\` and \`/qa-only\` as primary test input. Include only the information that helps a QA tester know **what to test and where** — not implementation details.`); + } else if (mode === 'ship') { + sections.push(` +**5. Generate tests for uncovered paths:** + +If test framework detected (or bootstrapped in Step 2.5): +- Prioritize error handlers and edge cases first (happy paths are more likely already tested) +- Read 2-3 existing test files to match conventions exactly +- Generate unit tests. Mock all external dependencies (DB, API, Redis). +- For paths marked [→E2E]: generate integration/E2E tests using the project's E2E framework (Playwright, Cypress, Capybara, etc.) +- For paths marked [→EVAL]: generate eval tests using the project's eval framework, or flag for manual eval if none exists +- Write tests that exercise the specific uncovered path with real assertions +- Run each test. Passes → commit as \`test: coverage for {feature}\` +- Fails → fix once. Still fails → revert, note gap in diagram. + +Caps: 30 code paths max, 20 tests generated max (code + user flow combined), 2-min per-test exploration cap. + +If no test framework AND user declined bootstrap → diagram only, no generation. Note: "Test generation skipped — no test framework configured." + +**Diff is test-only changes:** Skip Step 3.4 entirely: "No new application code paths to audit." + +**6. After-count and coverage summary:** + +\`\`\`bash +# Count test files after generation +find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +\`\`\` + +For PR body: \`Tests: {before} → {after} (+{delta} new)\` +Coverage line: \`Test Coverage Audit: N new code paths. M covered (X%). K tests generated, J committed.\``); + + // ── Test plan artifact (ship mode) ── + sections.push(` +### Test Plan Artifact + +After producing the coverage diagram, write a test plan artifact so \`/qa\` and \`/qa-only\` can consume it: + +\`\`\`bash +source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG +USER=$(whoami) +DATETIME=$(date +%Y%m%d-%H%M%S) +\`\`\` + +Write to \`~/.gstack/projects/{slug}/{user}-{branch}-ship-test-plan-{datetime}.md\`: + +\`\`\`markdown +# Test Plan +Generated by /ship on {date} +Branch: {branch} +Repo: {owner/repo} + +## Affected Pages/Routes +- {URL path} — {what to test and why} + +## Key Interactions to Verify +- {interaction description} on {page} + +## Edge Cases +- {edge case} on {page} + +## Critical Paths +- {end-to-end flow that must work} +\`\`\``); + } else { + // review mode + sections.push(` +**Step 5. Generate tests for gaps (Fix-First):** + +If test framework is detected and gaps were identified: +- Classify each gap as AUTO-FIX or ASK per the Fix-First Heuristic: + - **AUTO-FIX:** Simple unit tests for pure functions, edge cases of existing tested functions + - **ASK:** E2E tests, tests requiring new test infrastructure, tests for ambiguous behavior +- For AUTO-FIX gaps: generate the test, run it, commit as \`test: coverage for {feature}\` +- For ASK gaps: include in the Fix-First batch question with the other review findings +- For paths marked [→E2E]: always ASK (E2E tests are higher-effort and need user confirmation) +- For paths marked [→EVAL]: always ASK (eval tests need user confirmation on quality criteria) + +If no test framework detected → include gaps as INFORMATIONAL findings only, no generation. + +**Diff is test-only changes:** Skip Step 4.75 entirely: "No new application code paths to audit."`); + } + + return sections.join('\n'); +} + +function generateTestCoverageAuditPlan(_ctx: TemplateContext): string { + return generateTestCoverageAuditInner('plan'); +} + +function generateTestCoverageAuditShip(_ctx: TemplateContext): string { + return generateTestCoverageAuditInner('ship'); +} + +function generateTestCoverageAuditReview(_ctx: TemplateContext): string { + return generateTestCoverageAuditInner('review'); +} + function generateSpecReviewLoop(_ctx: TemplateContext): string { return `## Spec Review Loop @@ -1696,6 +2179,10 @@ const RESOLVERS: Record string> = { REVIEW_DASHBOARD: generateReviewDashboard, PLAN_FILE_REVIEW_REPORT: generatePlanFileReviewReport, TEST_BOOTSTRAP: generateTestBootstrap, + TEST_COVERAGE_AUDIT_PLAN: generateTestCoverageAuditPlan, + TEST_COVERAGE_AUDIT_SHIP: generateTestCoverageAuditShip, + TEST_COVERAGE_AUDIT_REVIEW: generateTestCoverageAuditReview, + TEST_FAILURE_TRIAGE: generateTestFailureTriage, SPEC_REVIEW_LOOP: generateSpecReviewLoop, DESIGN_SKETCH: generateDesignSketch, BENEFITS_FROM: generateBenefitsFrom, diff --git a/setup-browser-cookies/SKILL.md b/setup-browser-cookies/SKILL.md index a98ebec1041c5fa5b5f82213ef576a62e6416f63..95d70823066409defd3ba7b6151a12ceadd73a2c 100644 --- a/setup-browser-cookies/SKILL.md +++ b/setup-browser-cookies/SKILL.md @@ -28,6 +28,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -128,6 +131,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/setup-deploy/SKILL.md b/setup-deploy/SKILL.md index 7f5741c9653d1a8dc7a149d9c00624354fe825b6..b5945d9e494c9aea0ea8648131e9969edfbf7b32 100644 --- a/setup-deploy/SKILL.md +++ b/setup-deploy/SKILL.md @@ -34,6 +34,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -134,6 +137,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. diff --git a/ship/SKILL.md b/ship/SKILL.md index 6ad69ba77bf1379ca1a2c08ba2fc93b91738eb55..23b3ed1e9907d5225bd255e5cc7aa182c8a0596e 100644 --- a/ship/SKILL.md +++ b/ship/SKILL.md @@ -32,6 +32,9 @@ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") echo "BRANCH: $_BRANCH" echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") echo "LAKE_INTRO: $_LAKE_SEEN" _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) @@ -132,6 +135,18 @@ AI-assisted coding makes the marginal cost of completeness near-zero. When you p - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + ## Search Before Building Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. @@ -268,7 +283,7 @@ You are running the `/ship` workflow. This is a **non-interactive, fully automat **Only stop for:** - On the base branch (abort) - Merge conflicts that can't be auto-resolved (stop, show conflicts) -- Test failures (stop, show failures) +- In-branch test failures (pre-existing failures are triaged, not auto-blocking) - Pre-landing review finds ASK items that need user judgment - MINOR or MAJOR version bump needed (ask — see Step 4) - Greptile review comments that need user decision (complex fixes, false positives) @@ -552,7 +567,105 @@ wait After both complete, read the output files and check pass/fail. -**If any test fails:** Show the failures and **STOP**. Do not proceed. +**If any test fails:** Do NOT immediately stop. Apply the Test Failure Ownership Triage: + +## Test Failure Ownership Triage + +When tests fail, do NOT immediately stop. First, determine ownership: + +### Step T1: Classify each failure + +For each failing test: + +1. **Get the files changed on this branch:** + ```bash + git diff origin/...HEAD --name-only + ``` + +2. **Classify the failure:** + - **In-branch** if: the failing test file itself was modified on this branch, OR the test output references code that was changed on this branch, OR you can trace the failure to a change in the branch diff. + - **Likely pre-existing** if: neither the test file nor the code it tests was modified on this branch, AND the failure is unrelated to any branch change you can identify. + - **When ambiguous, default to in-branch.** It is safer to stop the developer than to let a broken test ship. Only classify as pre-existing when you are confident. + + This classification is heuristic — use your judgment reading the diff and the test output. You do not have a programmatic dependency graph. + +### Step T2: Handle in-branch failures + +**STOP.** These are your failures. Show them and do not proceed. The developer must fix their own broken tests before shipping. + +### Step T3: Handle pre-existing failures + +Check `REPO_MODE` from the preamble output. + +**If REPO_MODE is `solo`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> Since this is a solo repo, you're the only one who will fix these. +> +> RECOMMENDATION: Choose A — fix now while the context is fresh. Completeness: 9/10. +> A) Investigate and fix now (human: ~2-4h / CC: ~15min) — Completeness: 10/10 +> B) Add as P0 TODO — fix after this branch lands — Completeness: 7/10 +> C) Skip — I know about this, ship anyway — Completeness: 3/10 + +**If REPO_MODE is `collaborative` or `unknown`:** + +Use AskUserQuestion: + +> These test failures appear pre-existing (not caused by your branch changes): +> +> [list each failure with file:line and brief error description] +> +> This is a collaborative repo — these may be someone else's responsibility. +> +> RECOMMENDATION: Choose B — assign it to whoever broke it so the right person fixes it. Completeness: 9/10. +> A) Investigate and fix now anyway — Completeness: 10/10 +> B) Blame + assign GitHub issue to the author — Completeness: 9/10 +> C) Add as P0 TODO — Completeness: 7/10 +> D) Skip — ship anyway — Completeness: 3/10 + +### Step T4: Execute the chosen action + +**If "Investigate and fix now":** +- Switch to /investigate mindset: root cause first, then minimal fix. +- Fix the pre-existing failure. +- Commit the fix separately from the branch's changes: `git commit -m "fix: pre-existing test failure in "` +- Continue with the workflow. + +**If "Add as P0 TODO":** +- If `TODOS.md` exists, add the entry following the format in `review/TODOS-format.md` (or `.claude/skills/review/TODOS-format.md`). +- If `TODOS.md` does not exist, create it with the standard header and add the entry. +- Entry should include: title, the error output, which branch it was noticed on, and priority P0. +- Continue with the workflow — treat the pre-existing failure as non-blocking. + +**If "Blame + assign GitHub issue" (collaborative only):** +- Find who likely broke it. Check BOTH the test file AND the production code it tests: + ```bash + # Who last touched the failing test? + git log --format="%an (%ae)" -1 -- + # Who last touched the production code the test covers? (often the actual breaker) + git log --format="%an (%ae)" -1 -- + ``` + If these are different people, prefer the production code author — they likely introduced the regression. +- Create a GitHub issue assigned to that person: + ```bash + gh issue create \ + --title "Pre-existing test failure: " \ + --body "Found failing on branch . Failure is pre-existing.\n\n**Error:**\n```\n\n```\n\n**Last modified by:** \n**Noticed by:** gstack /ship on " \ + --assignee "" + ``` +- If `gh` is not available or `--assignee` fails (user not in org, etc.), create the issue without assignee and note who should look at it in the body. +- Continue with the workflow. + +**If "Skip":** +- Continue with the workflow. +- Note in output: "Pre-existing test failure skipped: " + +**After triage:** If any in-branch failures remain unfixed, **STOP**. Do not proceed. If all failures were pre-existing and handled (fixed, TODOed, assigned, or skipped), continue to Step 3.25. **If all pass:** Continue silently — just note the counts briefly. @@ -624,6 +737,27 @@ If multiple suites need to run, run them sequentially (each needs a test lane). 100% coverage is the goal — every untested path is a path where bugs hide and vibe coding becomes yolo coding. Evaluate what was ACTUALLY coded (from the diff), not what was planned. +### Test Framework Detection + +Before analyzing coverage, detect the project's test framework: + +1. **Read CLAUDE.md** — look for a `## Testing` section with test command and framework name. If found, use that as the authoritative source. +2. **If CLAUDE.md has no testing section, auto-detect:** + +```bash +# Detect project runtime +[ -f Gemfile ] && echo "RUNTIME:ruby" +[ -f package.json ] && echo "RUNTIME:node" +[ -f requirements.txt ] || [ -f pyproject.toml ] && echo "RUNTIME:python" +[ -f go.mod ] && echo "RUNTIME:go" +[ -f Cargo.toml ] && echo "RUNTIME:rust" +# Check for existing test infrastructure +ls jest.config.* vitest.config.* playwright.config.* cypress.config.* .rspec pytest.ini phpunit.xml 2>/dev/null +ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null +``` + +3. **If no framework detected:** falls through to the Test Framework Bootstrap step (Step 2.5) which handles full setup. + **0. Before/after test count:** ```bash @@ -686,9 +820,41 @@ Quality scoring rubric: - ★★ Tests correct behavior, happy path only - ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") +### E2E Test Decision Matrix + +When checking each branch, also determine whether a unit test or E2E/integration test is the right tool: + +**RECOMMEND E2E (mark as [→E2E] in the diagram):** +- Common user flow spanning 3+ components/services (e.g., signup → verify email → first login) +- Integration point where mocking hides real failures (e.g., API → queue → worker → DB) +- Auth/payment/data-destruction flows — too important to trust unit tests alone + +**RECOMMEND EVAL (mark as [→EVAL] in the diagram):** +- Critical LLM call that needs a quality eval (e.g., prompt change → test output still meets quality bar) +- Changes to prompt templates, system instructions, or tool definitions + +**STICK WITH UNIT TESTS:** +- Pure function with clear inputs/outputs +- Internal helper with no side effects +- Edge case of a single function (null input, empty array) +- Obscure/rare flow that isn't customer-facing + +### REGRESSION RULE (mandatory) + +**IRON RULE:** When the coverage audit identifies a REGRESSION — code that previously worked but the diff broke — a regression test is written immediately. No AskUserQuestion. No skipping. Regressions are the highest-priority test because they prove something broke. + +A regression is when: +- The diff modifies existing behavior (not new code) +- The existing test suite (if any) doesn't cover the changed path +- The change introduces a new failure mode for existing callers + +When uncertain whether a change is a regression, err on the side of writing the test. + +Format: commit as `test: regression test for {what broke}` + **4. Output ASCII coverage diagram:** -Include BOTH code paths and user flows in the same diagram: +Include BOTH code paths and user flows in the same diagram. Mark E2E-worthy and eval-worthy paths: ``` CODE PATH COVERAGE @@ -709,9 +875,9 @@ USER FLOW COVERAGE [+] Payment checkout flow │ ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 - ├── [GAP] Double-click submit — NO TEST - ├── [GAP] Navigate away during payment — NO TEST - └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 + ├── [GAP] [→E2E] Double-click submit — needs E2E, not just unit + ├── [GAP] Navigate away during payment — unit test sufficient + └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 [+] Error states │ @@ -719,12 +885,16 @@ USER FLOW COVERAGE ├── [GAP] Network timeout UX (what does user see?) — NO TEST └── [GAP] Empty cart submission — NO TEST +[+] LLM integration + │ + └── [GAP] [→EVAL] Prompt template change — needs eval test + ───────────────────────────────── -COVERAGE: 5/12 paths tested (42%) +COVERAGE: 5/13 paths tested (38%) Code paths: 3/5 (60%) - User flows: 2/7 (29%) + User flows: 2/8 (25%) QUALITY: ★★★: 2 ★★: 2 ★: 1 -GAPS: 7 paths need tests +GAPS: 8 paths need tests (2 need E2E, 1 needs eval) ───────────────────────────────── ``` @@ -736,6 +906,8 @@ If test framework detected (or bootstrapped in Step 2.5): - Prioritize error handlers and edge cases first (happy paths are more likely already tested) - Read 2-3 existing test files to match conventions exactly - Generate unit tests. Mock all external dependencies (DB, API, Redis). +- For paths marked [→E2E]: generate integration/E2E tests using the project's E2E framework (Playwright, Cypress, Capybara, etc.) +- For paths marked [→EVAL]: generate eval tests using the project's eval framework, or flag for manual eval if none exists - Write tests that exercise the specific uncovered path with real assertions - Run each test. Passes → commit as `test: coverage for {feature}` - Fails → fix once. Still fails → revert, note gap in diagram. @@ -756,6 +928,37 @@ find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec For PR body: `Tests: {before} → {after} (+{delta} new)` Coverage line: `Test Coverage Audit: N new code paths. M covered (X%). K tests generated, J committed.` +### Test Plan Artifact + +After producing the coverage diagram, write a test plan artifact so `/qa` and `/qa-only` can consume it: + +```bash +source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) && mkdir -p ~/.gstack/projects/$SLUG +USER=$(whoami) +DATETIME=$(date +%Y%m%d-%H%M%S) +``` + +Write to `~/.gstack/projects/{slug}/{user}-{branch}-ship-test-plan-{datetime}.md`: + +```markdown +# Test Plan +Generated by /ship on {date} +Branch: {branch} +Repo: {owner/repo} + +## Affected Pages/Routes +- {URL path} — {what to test and why} + +## Key Interactions to Verify +- {interaction description} on {page} + +## Edge Cases +- {edge case} on {page} + +## Critical Paths +- {end-to-end flow that must work} +``` + --- ## Step 3.5: Pre-Landing Review diff --git a/ship/SKILL.md.tmpl b/ship/SKILL.md.tmpl index a748314d1853fdfee9b7525cb695229750444c30..bd74c197ae9d156ac81e7b3e70f11898cee3d57d 100644 --- a/ship/SKILL.md.tmpl +++ b/ship/SKILL.md.tmpl @@ -27,7 +27,7 @@ You are running the `/ship` workflow. This is a **non-interactive, fully automat **Only stop for:** - On the base branch (abort) - Merge conflicts that can't be auto-resolved (stop, show conflicts) -- Test failures (stop, show failures) +- In-branch test failures (pre-existing failures are triaged, not auto-blocking) - Pre-landing review finds ASK items that need user judgment - MINOR or MAJOR version bump needed (ask — see Step 4) - Greptile review comments that need user decision (complex fixes, false positives) @@ -119,7 +119,11 @@ wait After both complete, read the output files and check pass/fail. -**If any test fails:** Show the failures and **STOP**. Do not proceed. +**If any test fails:** Do NOT immediately stop. Apply the Test Failure Ownership Triage: + +{{TEST_FAILURE_TRIAGE}} + +**After triage:** If any in-branch failures remain unfixed, **STOP**. Do not proceed. If all failures were pre-existing and handled (fixed, TODOed, assigned, or skipped), continue to Step 3.25. **If all pass:** Continue silently — just note the counts briefly. @@ -189,139 +193,7 @@ If multiple suites need to run, run them sequentially (each needs a test lane). ## Step 3.4: Test Coverage Audit -100% coverage is the goal — every untested path is a path where bugs hide and vibe coding becomes yolo coding. Evaluate what was ACTUALLY coded (from the diff), not what was planned. - -**0. Before/after test count:** - -```bash -# Count test files before any generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l -``` - -Store this number for the PR body. - -**1. Trace every codepath changed** using `git diff origin/...HEAD`: - -Read every changed file. For each one, trace how data flows through the code — don't just list functions, actually follow the execution: - -1. **Read the diff.** For each changed file, read the full file (not just the diff hunk) to understand context. -2. **Trace data flow.** Starting from each entry point (route handler, exported function, event listener, component render), follow the data through every branch: - - Where does input come from? (request params, props, database, API call) - - What transforms it? (validation, mapping, computation) - - Where does it go? (database write, API response, rendered output, side effect) - - What can go wrong at each step? (null/undefined, invalid input, network failure, empty collection) -3. **Diagram the execution.** For each changed file, draw an ASCII diagram showing: - - Every function/method that was added or modified - - Every conditional branch (if/else, switch, ternary, guard clause, early return) - - Every error path (try/catch, rescue, error boundary, fallback) - - Every call to another function (trace into it — does IT have untested branches?) - - Every edge: what happens with null input? Empty array? Invalid type? - -This is the critical step — you're building a map of every line of code that can execute differently based on input. Every branch in this diagram needs a test. - -**2. Map user flows, interactions, and error states:** - -Code coverage isn't enough — you need to cover how real users interact with the changed code. For each changed feature, think through: - -- **User flows:** What sequence of actions does a user take that touches this code? Map the full journey (e.g., "user clicks 'Pay' → form validates → API call → success/failure screen"). Each step in the journey needs a test. -- **Interaction edge cases:** What happens when the user does something unexpected? - - Double-click/rapid resubmit - - Navigate away mid-operation (back button, close tab, click another link) - - Submit with stale data (page sat open for 30 minutes, session expired) - - Slow connection (API takes 10 seconds — what does the user see?) - - Concurrent actions (two tabs, same form) -- **Error states the user can see:** For every error the code handles, what does the user actually experience? - - Is there a clear error message or a silent failure? - - Can the user recover (retry, go back, fix input) or are they stuck? - - What happens with no network? With a 500 from the API? With invalid data from the server? -- **Empty/zero/boundary states:** What does the UI show with zero results? With 10,000 results? With a single character input? With maximum-length input? - -Add these to your diagram alongside the code branches. A user flow with no test is just as much a gap as an untested if/else. - -**3. Check each branch against existing tests:** - -Go through your diagram branch by branch — both code paths AND user flows. For each one, search for a test that exercises it: -- Function `processPayment()` → look for `billing.test.ts`, `billing.spec.ts`, `test/billing_test.rb` -- An if/else → look for tests covering BOTH the true AND false path -- An error handler → look for a test that triggers that specific error condition -- A call to `helperFn()` that has its own branches → those branches need tests too -- A user flow → look for an integration or E2E test that walks through the journey -- An interaction edge case → look for a test that simulates the unexpected action - -Quality scoring rubric: -- ★★★ Tests behavior with edge cases AND error paths -- ★★ Tests correct behavior, happy path only -- ★ Smoke test / existence check / trivial assertion (e.g., "it renders", "it doesn't throw") - -**4. Output ASCII coverage diagram:** - -Include BOTH code paths and user flows in the same diagram: - -``` -CODE PATH COVERAGE -=========================== -[+] src/services/billing.ts - │ - ├── processPayment() - │ ├── [★★★ TESTED] Happy path + card declined + timeout — billing.test.ts:42 - │ ├── [GAP] Network timeout — NO TEST - │ └── [GAP] Invalid currency — NO TEST - │ - └── refundPayment() - ├── [★★ TESTED] Full refund — billing.test.ts:89 - └── [★ TESTED] Partial refund (checks non-throw only) — billing.test.ts:101 - -USER FLOW COVERAGE -=========================== -[+] Payment checkout flow - │ - ├── [★★★ TESTED] Complete purchase — checkout.e2e.ts:15 - ├── [GAP] Double-click submit — NO TEST - ├── [GAP] Navigate away during payment — NO TEST - └── [★ TESTED] Form validation errors (checks render only) — checkout.test.ts:40 - -[+] Error states - │ - ├── [★★ TESTED] Card declined message — billing.test.ts:58 - ├── [GAP] Network timeout UX (what does user see?) — NO TEST - └── [GAP] Empty cart submission — NO TEST - -───────────────────────────────── -COVERAGE: 5/12 paths tested (42%) - Code paths: 3/5 (60%) - User flows: 2/7 (29%) -QUALITY: ★★★: 2 ★★: 2 ★: 1 -GAPS: 7 paths need tests -───────────────────────────────── -``` - -**Fast path:** All paths covered → "Step 3.4: All new code paths have test coverage ✓" Continue. - -**5. Generate tests for uncovered paths:** - -If test framework detected (or bootstrapped in Step 2.5): -- Prioritize error handlers and edge cases first (happy paths are more likely already tested) -- Read 2-3 existing test files to match conventions exactly -- Generate unit tests. Mock all external dependencies (DB, API, Redis). -- Write tests that exercise the specific uncovered path with real assertions -- Run each test. Passes → commit as `test: coverage for {feature}` -- Fails → fix once. Still fails → revert, note gap in diagram. - -Caps: 30 code paths max, 20 tests generated max (code + user flow combined), 2-min per-test exploration cap. - -If no test framework AND user declined bootstrap → diagram only, no generation. Note: "Test generation skipped — no test framework configured." - -**Diff is test-only changes:** Skip Step 3.4 entirely: "No new application code paths to audit." - -**6. After-count and coverage summary:** - -```bash -# Count test files after generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l -``` - -For PR body: `Tests: {before} → {after} (+{delta} new)` -Coverage line: `Test Coverage Audit: N new code paths. M covered (X%). K tests generated, J committed.` +{{TEST_COVERAGE_AUDIT_SHIP}} --- diff --git a/test/fixtures/coverage-audit-fixture.ts b/test/fixtures/coverage-audit-fixture.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a7adcc3d35b697d9ff3d523149c7099600af6ff --- /dev/null +++ b/test/fixtures/coverage-audit-fixture.ts @@ -0,0 +1,76 @@ +/** + * Shared fixture for test coverage audit E2E tests. + * + * Creates a Node.js project with billing source code that has intentional + * test coverage gaps: processPayment has happy-path-only tests, + * refundPayment has no tests at all. + * + * Used by: ship-coverage-audit E2E, review-coverage-audit E2E + */ + +import * as fs from 'fs'; +import * as path from 'path'; +import { spawnSync } from 'child_process'; + +export function createCoverageAuditFixture(dir: string): void { + // Create a Node.js project WITH test framework but coverage gaps + fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ + name: 'test-coverage-app', + version: '1.0.0', + type: 'module', + scripts: { test: 'echo "no tests yet"' }, + devDependencies: { vitest: '^1.0.0' }, + }, null, 2)); + + // Create vitest config + fs.writeFileSync(path.join(dir, 'vitest.config.ts'), + `import { defineConfig } from 'vitest/config';\nexport default defineConfig({ test: {} });\n`); + + fs.writeFileSync(path.join(dir, 'VERSION'), '0.1.0.0\n'); + fs.writeFileSync(path.join(dir, 'CHANGELOG.md'), '# Changelog\n'); + + // Create source file with multiple code paths + fs.mkdirSync(path.join(dir, 'src'), { recursive: true }); + fs.writeFileSync(path.join(dir, 'src', 'billing.ts'), ` +export function processPayment(amount: number, currency: string) { + if (amount <= 0) throw new Error('Invalid amount'); + if (currency !== 'USD' && currency !== 'EUR') throw new Error('Unsupported currency'); + return { status: 'success', amount, currency }; +} + +export function refundPayment(paymentId: string, reason: string) { + if (!paymentId) throw new Error('Payment ID required'); + if (!reason) throw new Error('Reason required'); + return { status: 'refunded', paymentId, reason }; +} +`); + + // Create a test directory with ONE test (partial coverage) + fs.mkdirSync(path.join(dir, 'test'), { recursive: true }); + fs.writeFileSync(path.join(dir, 'test', 'billing.test.ts'), ` +import { describe, test, expect } from 'vitest'; +import { processPayment } from '../src/billing'; + +describe('processPayment', () => { + test('processes valid payment', () => { + const result = processPayment(100, 'USD'); + expect(result.status).toBe('success'); + }); + // GAP: no test for invalid amount + // GAP: no test for unsupported currency + // GAP: refundPayment not tested at all +}); +`); + + // Init git repo with main branch + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: dir, stdio: 'pipe', timeout: 5000 }); + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial commit']); + + // Create feature branch + run('git', ['checkout', '-b', 'feature/billing']); +} diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.ts index cc75da65d0d8ee875fa3139b6cd2c3419cb3fd12..d1d907a01eb2a173141f6172a14209920dfd4053 100644 --- a/test/gen-skill-docs.test.ts +++ b/test/gen-skill-docs.test.ts @@ -416,6 +416,150 @@ describe('REVIEW_DASHBOARD resolver', () => { }); }); +// ─── Test Coverage Audit Resolver Tests ───────────────────── + +describe('TEST_COVERAGE_AUDIT placeholders', () => { + const planSkill = fs.readFileSync(path.join(ROOT, 'plan-eng-review', 'SKILL.md'), 'utf-8'); + const shipSkill = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + const reviewSkill = fs.readFileSync(path.join(ROOT, 'review', 'SKILL.md'), 'utf-8'); + + test('all three modes share codepath tracing methodology', () => { + const sharedPhrases = [ + 'Trace data flow', + 'Diagram the execution', + 'Quality scoring rubric', + '★★★', + '★★', + 'GAP', + ]; + for (const phrase of sharedPhrases) { + expect(planSkill).toContain(phrase); + expect(shipSkill).toContain(phrase); + expect(reviewSkill).toContain(phrase); + } + // Plan mode traces the plan, not a git diff + expect(planSkill).toContain('Trace every codepath in the plan'); + expect(planSkill).not.toContain('git diff origin'); + // Ship and review modes trace the diff + expect(shipSkill).toContain('Trace every codepath changed'); + expect(reviewSkill).toContain('Trace every codepath changed'); + }); + + test('all three modes include E2E decision matrix', () => { + for (const skill of [planSkill, shipSkill, reviewSkill]) { + expect(skill).toContain('E2E Test Decision Matrix'); + expect(skill).toContain('→E2E'); + expect(skill).toContain('→EVAL'); + } + }); + + test('all three modes include regression rule', () => { + for (const skill of [planSkill, shipSkill, reviewSkill]) { + expect(skill).toContain('REGRESSION RULE'); + expect(skill).toContain('IRON RULE'); + } + }); + + test('all three modes include test framework detection', () => { + for (const skill of [planSkill, shipSkill, reviewSkill]) { + expect(skill).toContain('Test Framework Detection'); + expect(skill).toContain('CLAUDE.md'); + } + }); + + test('plan mode adds tests to plan + includes test plan artifact', () => { + expect(planSkill).toContain('Add missing tests to the plan'); + expect(planSkill).toContain('eng-review-test-plan'); + expect(planSkill).toContain('Test Plan Artifact'); + }); + + test('ship mode auto-generates tests + includes before/after count', () => { + expect(shipSkill).toContain('Generate tests for uncovered paths'); + expect(shipSkill).toContain('Before/after test count'); + expect(shipSkill).toContain('30 code paths max'); + expect(shipSkill).toContain('ship-test-plan'); + }); + + test('review mode generates via Fix-First + gaps are INFORMATIONAL', () => { + expect(reviewSkill).toContain('Fix-First'); + expect(reviewSkill).toContain('INFORMATIONAL'); + expect(reviewSkill).toContain('Step 4.75'); + expect(reviewSkill).toContain('subsumes the "Test Gaps" category'); + }); + + test('plan mode does NOT include ship-specific content', () => { + expect(planSkill).not.toContain('Before/after test count'); + expect(planSkill).not.toContain('30 code paths max'); + expect(planSkill).not.toContain('ship-test-plan'); + }); + + test('review mode does NOT include test plan artifact', () => { + expect(reviewSkill).not.toContain('Test Plan Artifact'); + expect(reviewSkill).not.toContain('eng-review-test-plan'); + expect(reviewSkill).not.toContain('ship-test-plan'); + }); + + // Regression guard: ship output contains key phrases from before the refactor + test('ship SKILL.md regression guard — key phrases preserved', () => { + const regressionPhrases = [ + '100% coverage is the goal', + 'ASCII coverage diagram', + 'processPayment', + 'refundPayment', + 'billing.test.ts', + 'checkout.e2e.ts', + 'COVERAGE:', + 'QUALITY:', + 'GAPS:', + 'Code paths:', + 'User flows:', + ]; + for (const phrase of regressionPhrases) { + expect(shipSkill).toContain(phrase); + } + }); +}); + +// --- {{TEST_FAILURE_TRIAGE}} resolver tests --- + +describe('TEST_FAILURE_TRIAGE resolver', () => { + const shipSkill = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + + test('contains all 4 triage steps', () => { + expect(shipSkill).toContain('Step T1: Classify each failure'); + expect(shipSkill).toContain('Step T2: Handle in-branch failures'); + expect(shipSkill).toContain('Step T3: Handle pre-existing failures'); + expect(shipSkill).toContain('Step T4: Execute the chosen action'); + }); + + test('T1 includes classification criteria (in-branch vs pre-existing)', () => { + expect(shipSkill).toContain('In-branch'); + expect(shipSkill).toContain('Likely pre-existing'); + expect(shipSkill).toContain('git diff origin/'); + }); + + test('T3 branches on REPO_MODE (solo vs collaborative)', () => { + expect(shipSkill).toContain('REPO_MODE'); + expect(shipSkill).toContain('solo'); + expect(shipSkill).toContain('collaborative'); + }); + + test('solo mode offers fix-now, TODO, and skip options', () => { + expect(shipSkill).toContain('Investigate and fix now'); + expect(shipSkill).toContain('Add as P0 TODO'); + expect(shipSkill).toContain('Skip'); + }); + + test('collaborative mode offers blame + assign option', () => { + expect(shipSkill).toContain('Blame + assign GitHub issue'); + expect(shipSkill).toContain('gh issue create'); + }); + + test('defaults ambiguous failures to in-branch (safety)', () => { + expect(shipSkill).toContain('When ambiguous, default to in-branch'); + }); +}); + // --- {{PLAN_FILE_REVIEW_REPORT}} resolver tests --- describe('PLAN_FILE_REVIEW_REPORT resolver', () => { @@ -611,11 +755,11 @@ describe('Codex generation (--host codex)', () => { test('Codex review step stripped from Codex-host ship and review', () => { const shipContent = fs.readFileSync(path.join(AGENTS_DIR, 'gstack-ship', 'SKILL.md'), 'utf-8'); expect(shipContent).not.toContain('codex review --base'); - expect(shipContent).not.toContain('Investigate and fix'); + expect(shipContent).not.toContain('CODEX_REVIEWS'); const reviewContent = fs.readFileSync(path.join(AGENTS_DIR, 'gstack-review', 'SKILL.md'), 'utf-8'); expect(reviewContent).not.toContain('codex review --base'); - expect(reviewContent).not.toContain('Investigate and fix'); + expect(reviewContent).not.toContain('CODEX_REVIEWS'); }); test('--host codex --dry-run freshness', () => { diff --git a/test/helpers/touchfiles.ts b/test/helpers/touchfiles.ts index 346ed89093139bc9b698ed017beed01d93f1e132..d68394bb97d947c345846ad768695c44a3e27d7e 100644 --- a/test/helpers/touchfiles.ts +++ b/test/helpers/touchfiles.ts @@ -70,7 +70,7 @@ export const E2E_TOUCHFILES: Record = { 'plan-eng-review-artifact': ['plan-eng-review/**'], // Ship - 'ship-base-branch': ['ship/**'], + 'ship-base-branch': ['ship/**', 'bin/gstack-repo-mode'], 'ship-local-workflow': ['ship/**', 'scripts/gen-skill-docs.ts'], // Setup browser cookies @@ -95,8 +95,11 @@ export const E2E_TOUCHFILES: Record = { 'gemini-review-findings': ['review/**', '.agents/skills/gstack-review/**', 'test/helpers/gemini-session-runner.ts'], - // Ship coverage audit - 'ship-coverage-audit': ['ship/**'], + // Coverage audit (shared fixture) + triage + 'ship-coverage-audit': ['ship/**', 'test/fixtures/coverage-audit-fixture.ts', 'bin/gstack-repo-mode'], + 'review-coverage-audit': ['review/**', 'test/fixtures/coverage-audit-fixture.ts'], + 'plan-eng-coverage-audit': ['plan-eng-review/**', 'test/fixtures/coverage-audit-fixture.ts'], + 'ship-triage': ['ship/**', 'bin/gstack-repo-mode'], // Design 'design-consultation-core': ['design-consultation/**'], diff --git a/test/skill-e2e.test.ts b/test/skill-e2e.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..91c95f7a7445cb80558f4b9a534d7a24f988794c --- /dev/null +++ b/test/skill-e2e.test.ts @@ -0,0 +1,3325 @@ +import { describe, test, expect, beforeAll, afterAll } from 'bun:test'; +import { runSkillTest } from './helpers/session-runner'; +import type { SkillTestResult } from './helpers/session-runner'; +import { outcomeJudge, callJudge } from './helpers/llm-judge'; +import { EvalCollector, judgePassed } from './helpers/eval-store'; +import type { EvalTestEntry } from './helpers/eval-store'; +import { startTestServer } from '../browse/test/test-server'; +import { selectTests, detectBaseBranch, getChangedFiles, E2E_TOUCHFILES, GLOBAL_TOUCHFILES } from './helpers/touchfiles'; +import { spawnSync } from 'child_process'; +import * as fs from 'fs'; +import * as path from 'path'; +import * as os from 'os'; + +const ROOT = path.resolve(import.meta.dir, '..'); + +// Skip unless EVALS=1. Session runner strips CLAUDE* env vars to avoid nested session issues. +// +// BLAME PROTOCOL: When an eval fails, do NOT claim "pre-existing" or "not related +// to our changes" without proof. Run the same eval on main to verify. These tests +// have invisible couplings — preamble text, SKILL.md content, and timing all affect +// agent behavior. See CLAUDE.md "E2E eval failure blame protocol" for details. +const evalsEnabled = !!process.env.EVALS; +const describeE2E = evalsEnabled ? describe : describe.skip; + +// --- Diff-based test selection --- +// When EVALS_ALL is not set, only run tests whose touchfiles were modified. +// Set EVALS_ALL=1 to force all tests. Set EVALS_BASE to override base branch. +let selectedTests: string[] | null = null; // null = run all + +if (evalsEnabled && !process.env.EVALS_ALL) { + const baseBranch = process.env.EVALS_BASE + || detectBaseBranch(ROOT) + || 'main'; + const changedFiles = getChangedFiles(baseBranch, ROOT); + + if (changedFiles.length > 0) { + const selection = selectTests(changedFiles, E2E_TOUCHFILES, GLOBAL_TOUCHFILES); + selectedTests = selection.selected; + process.stderr.write(`\nE2E selection (${selection.reason}): ${selection.selected.length}/${Object.keys(E2E_TOUCHFILES).length} tests\n`); + if (selection.skipped.length > 0) { + process.stderr.write(` Skipped: ${selection.skipped.join(', ')}\n`); + } + process.stderr.write('\n'); + } + // If changedFiles is empty (e.g., on main branch), selectedTests stays null → run all +} + +/** Wrap a describe block to skip entirely if none of its tests are selected. */ +function describeIfSelected(name: string, testNames: string[], fn: () => void) { + const anySelected = selectedTests === null || testNames.some(t => selectedTests!.includes(t)); + (anySelected ? describeE2E : describe.skip)(name, fn); +} + +/** Skip an individual test if not selected (for multi-test describe blocks). */ +function testIfSelected(testName: string, fn: () => Promise, timeout: number) { + const shouldRun = selectedTests === null || selectedTests.includes(testName); + (shouldRun ? test : test.skip)(testName, fn, timeout); +} + +// Eval result collector — accumulates test results, writes to ~/.gstack-dev/evals/ on finalize +const evalCollector = evalsEnabled ? new EvalCollector('e2e') : null; + +// Unique run ID for this E2E session — used for heartbeat + per-run log directory +const runId = new Date().toISOString().replace(/[:.]/g, '').replace('T', '-').slice(0, 15); + +/** DRY helper to record an E2E test result into the eval collector. */ +function recordE2E(name: string, suite: string, result: SkillTestResult, extra?: Partial) { + // Derive last tool call from transcript for machine-readable diagnostics + const lastTool = result.toolCalls.length > 0 + ? `${result.toolCalls[result.toolCalls.length - 1].tool}(${JSON.stringify(result.toolCalls[result.toolCalls.length - 1].input).slice(0, 60)})` + : undefined; + + evalCollector?.addTest({ + name, suite, tier: 'e2e', + passed: result.exitReason === 'success' && result.browseErrors.length === 0, + duration_ms: result.duration, + cost_usd: result.costEstimate.estimatedCost, + transcript: result.transcript, + output: result.output?.slice(0, 2000), + turns_used: result.costEstimate.turnsUsed, + browse_errors: result.browseErrors, + exit_reason: result.exitReason, + timeout_at_turn: result.exitReason === 'timeout' ? result.costEstimate.turnsUsed : undefined, + last_tool_call: lastTool, + ...extra, + }); +} + +let testServer: ReturnType; +let tmpDir: string; +const browseBin = path.resolve(ROOT, 'browse', 'dist', 'browse'); + +/** + * Copy a directory tree recursively (files only, follows structure). + */ +function copyDirSync(src: string, dest: string) { + fs.mkdirSync(dest, { recursive: true }); + for (const entry of fs.readdirSync(src, { withFileTypes: true })) { + const srcPath = path.join(src, entry.name); + const destPath = path.join(dest, entry.name); + if (entry.isDirectory()) { + copyDirSync(srcPath, destPath); + } else { + fs.copyFileSync(srcPath, destPath); + } + } +} + +/** + * Set up browse shims (binary symlink, find-browse, remote-slug) in a tmpDir. + */ +function setupBrowseShims(dir: string) { + // Symlink browse binary + const binDir = path.join(dir, 'browse', 'dist'); + fs.mkdirSync(binDir, { recursive: true }); + if (fs.existsSync(browseBin)) { + fs.symlinkSync(browseBin, path.join(binDir, 'browse')); + } + + // find-browse shim + const findBrowseDir = path.join(dir, 'browse', 'bin'); + fs.mkdirSync(findBrowseDir, { recursive: true }); + fs.writeFileSync( + path.join(findBrowseDir, 'find-browse'), + `#!/bin/bash\necho "${browseBin}"\n`, + { mode: 0o755 }, + ); + + // remote-slug shim (returns test-project) + fs.writeFileSync( + path.join(findBrowseDir, 'remote-slug'), + `#!/bin/bash\necho "test-project"\n`, + { mode: 0o755 }, + ); +} + +/** + * Print cost summary after an E2E test. + */ +function logCost(label: string, result: { costEstimate: { turnsUsed: number; estimatedTokens: number; estimatedCost: number }; duration: number }) { + const { turnsUsed, estimatedTokens, estimatedCost } = result.costEstimate; + const durationSec = Math.round(result.duration / 1000); + console.log(`${label}: $${estimatedCost.toFixed(2)} (${turnsUsed} turns, ${(estimatedTokens / 1000).toFixed(1)}k tokens, ${durationSec}s)`); +} + +/** + * Dump diagnostic info on planted-bug outcome failure (decision 1C). + */ +function dumpOutcomeDiagnostic(dir: string, label: string, report: string, judgeResult: any) { + try { + const transcriptDir = path.join(dir, '.gstack', 'test-transcripts'); + fs.mkdirSync(transcriptDir, { recursive: true }); + const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); + fs.writeFileSync( + path.join(transcriptDir, `${label}-outcome-${timestamp}.json`), + JSON.stringify({ label, report, judgeResult }, null, 2), + ); + } catch { /* non-fatal */ } +} + +// Fail fast if Anthropic API is unreachable — don't burn through 13 tests getting ConnectionRefused +if (evalsEnabled) { + const check = spawnSync('sh', ['-c', 'echo "ping" | claude -p --max-turns 1 --output-format stream-json --verbose --dangerously-skip-permissions'], { + stdio: 'pipe', timeout: 30_000, + }); + const output = check.stdout?.toString() || ''; + if (output.includes('ConnectionRefused') || output.includes('Unable to connect')) { + throw new Error('Anthropic API unreachable — aborting E2E suite. Fix connectivity and retry.'); + } +} + +describeIfSelected('Skill E2E tests', [ + 'browse-basic', 'browse-snapshot', 'skillmd-setup-discovery', + 'skillmd-no-local-binary', 'skillmd-outside-git', 'contributor-mode', 'session-awareness', +], () => { + beforeAll(() => { + testServer = startTestServer(); + tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-')); + setupBrowseShims(tmpDir); + }); + + afterAll(() => { + testServer?.server?.stop(); + try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch {} + }); + + testIfSelected('browse-basic', async () => { + const result = await runSkillTest({ + prompt: `You have a browse binary at ${browseBin}. Assign it to B variable and run these commands in sequence: +1. $B goto ${testServer.url} +2. $B snapshot -i +3. $B text +4. $B screenshot /tmp/skill-e2e-test.png +Report the results of each command.`, + workingDirectory: tmpDir, + maxTurns: 10, + timeout: 60_000, + testName: 'browse-basic', + runId, + }); + + logCost('browse basic', result); + recordE2E('browse basic commands', 'Skill E2E tests', result); + expect(result.browseErrors).toHaveLength(0); + expect(result.exitReason).toBe('success'); + }, 90_000); + + testIfSelected('browse-snapshot', async () => { + const result = await runSkillTest({ + prompt: `You have a browse binary at ${browseBin}. Assign it to B variable and run: +1. $B goto ${testServer.url} +2. $B snapshot -i +3. $B snapshot -c +4. $B snapshot -D +5. $B snapshot -i -a -o /tmp/skill-e2e-annotated.png +Report what each command returned.`, + workingDirectory: tmpDir, + maxTurns: 10, + timeout: 60_000, + testName: 'browse-snapshot', + runId, + }); + + logCost('browse snapshot', result); + recordE2E('browse snapshot flags', 'Skill E2E tests', result); + // browseErrors can include false positives from hallucinated paths (e.g. "baltimore" vs "bangalore") + if (result.browseErrors.length > 0) { + console.warn('Browse errors (non-fatal):', result.browseErrors); + } + expect(result.exitReason).toBe('success'); + }, 90_000); + + testIfSelected('skillmd-setup-discovery', async () => { + const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + const setupStart = skillMd.indexOf('## SETUP'); + const setupEnd = skillMd.indexOf('## IMPORTANT'); + const setupBlock = skillMd.slice(setupStart, setupEnd); + + // Guard: verify we extracted a valid setup block + expect(setupBlock).toContain('browse/dist/browse'); + + const result = await runSkillTest({ + prompt: `Follow these instructions to find the browse binary and run a basic command. + +${setupBlock} + +After finding the binary, run: $B goto ${testServer.url} +Then run: $B text +Report whether it worked.`, + workingDirectory: tmpDir, + maxTurns: 10, + timeout: 60_000, + testName: 'skillmd-setup-discovery', + runId, + }); + + recordE2E('SKILL.md setup block discovery', 'Skill E2E tests', result); + expect(result.browseErrors).toHaveLength(0); + expect(result.exitReason).toBe('success'); + }, 90_000); + + testIfSelected('skillmd-no-local-binary', async () => { + // Create a tmpdir with no browse binary — no local .claude/skills/gstack/browse/dist/browse + const emptyDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-empty-')); + + const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + const setupStart = skillMd.indexOf('## SETUP'); + const setupEnd = skillMd.indexOf('## IMPORTANT'); + const setupBlock = skillMd.slice(setupStart, setupEnd); + + const result = await runSkillTest({ + prompt: `Follow these instructions exactly. Run the bash code block below and report what it outputs. + +${setupBlock} + +Report the exact output. Do NOT try to fix or install anything — just report what you see.`, + workingDirectory: emptyDir, + maxTurns: 5, + timeout: 30_000, + testName: 'skillmd-no-local-binary', + runId, + }); + + // Setup block should either find the global binary (READY) or show NEEDS_SETUP. + // On dev machines with gstack installed globally, the fallback path + // ~/.claude/skills/gstack/browse/dist/browse exists, so we get READY. + // The important thing is it doesn't crash or give a confusing error. + const allText = result.output || ''; + recordE2E('SKILL.md setup block (no local binary)', 'Skill E2E tests', result); + expect(allText).toMatch(/READY|NEEDS_SETUP/); + expect(result.exitReason).toBe('success'); + + // Clean up + try { fs.rmSync(emptyDir, { recursive: true, force: true }); } catch {} + }, 60_000); + + testIfSelected('skillmd-outside-git', async () => { + // Create a tmpdir outside any git repo + const nonGitDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-nogit-')); + + const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + const setupStart = skillMd.indexOf('## SETUP'); + const setupEnd = skillMd.indexOf('## IMPORTANT'); + const setupBlock = skillMd.slice(setupStart, setupEnd); + + const result = await runSkillTest({ + prompt: `Follow these instructions exactly. Run the bash code block below and report what it outputs. + +${setupBlock} + +Report the exact output — either "READY: " or "NEEDS_SETUP".`, + workingDirectory: nonGitDir, + maxTurns: 5, + timeout: 30_000, + testName: 'skillmd-outside-git', + runId, + }); + + // Should either find global binary (READY) or show NEEDS_SETUP — not crash + const allText = result.output || ''; + recordE2E('SKILL.md outside git repo', 'Skill E2E tests', result); + expect(allText).toMatch(/READY|NEEDS_SETUP/); + + // Clean up + try { fs.rmSync(nonGitDir, { recursive: true, force: true }); } catch {} + }, 60_000); + + testIfSelected('contributor-mode', async () => { + const contribDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-contrib-')); + const logsDir = path.join(contribDir, 'contributor-logs'); + fs.mkdirSync(logsDir, { recursive: true }); + + // Extract contributor mode instructions from generated SKILL.md + const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + const contribStart = skillMd.indexOf('## Contributor Mode'); + const contribEnd = skillMd.indexOf('\n## ', contribStart + 1); + const contribBlock = skillMd.slice(contribStart, contribEnd > 0 ? contribEnd : undefined); + + const result = await runSkillTest({ + prompt: `You are in contributor mode (_CONTRIB=true). + +${contribBlock} + +OVERRIDE: Write contributor logs to ${logsDir}/ instead of ~/.gstack/contributor-logs/ + +Now try this browse command (it will fail — there is no binary at this path): +/nonexistent/path/browse goto https://example.com + +This is a gstack issue (the browse binary is missing/misconfigured). +File a contributor report about this issue. Then tell me what you filed.`, + workingDirectory: contribDir, + maxTurns: 8, + timeout: 60_000, + testName: 'contributor-mode', + runId, + }); + + logCost('contributor mode', result); + // Override passed: this test intentionally triggers a browse error (nonexistent binary) + // so browseErrors will be non-empty — that's expected, not a failure + recordE2E('contributor mode report', 'Skill E2E tests', result, { + passed: result.exitReason === 'success', + }); + + // Verify a contributor log was created with expected format + const logFiles = fs.readdirSync(logsDir).filter(f => f.endsWith('.md')); + expect(logFiles.length).toBeGreaterThan(0); + + // Verify new reflection-based format + const logContent = fs.readFileSync(path.join(logsDir, logFiles[0]), 'utf-8'); + expect(logContent).toContain('Hey gstack team'); + expect(logContent).toContain('What I was trying to do'); + expect(logContent).toContain('What happened instead'); + expect(logContent).toMatch(/rating/i); + // Verify report has repro steps (agent may use "Steps to reproduce", "Repro Steps", etc.) + expect(logContent).toMatch(/repro|steps to reproduce|how to reproduce/i); + // Verify report has date/version footer (agent may format differently) + expect(logContent).toMatch(/date.*2026|2026.*date/i); + + // Clean up + try { fs.rmSync(contribDir, { recursive: true, force: true }); } catch {} + }, 90_000); + + testIfSelected('session-awareness', async () => { + const sessionDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-session-')); + + // Set up a git repo so there's project/branch context to reference + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: sessionDir, stdio: 'pipe', timeout: 5000 }); + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + fs.writeFileSync(path.join(sessionDir, 'app.rb'), '# my app\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'init']); + run('git', ['checkout', '-b', 'feature/add-payments']); + // Add a remote so the agent can derive a project name + run('git', ['remote', 'add', 'origin', 'https://github.com/acme/billing-app.git']); + + // Extract AskUserQuestion format instructions from generated SKILL.md + const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + const aqStart = skillMd.indexOf('## AskUserQuestion Format'); + const aqEnd = skillMd.indexOf('\n## ', aqStart + 1); + const aqBlock = skillMd.slice(aqStart, aqEnd > 0 ? aqEnd : undefined); + + const outputPath = path.join(sessionDir, 'question-output.md'); + + const result = await runSkillTest({ + prompt: `You are running a gstack skill. The session preamble detected _SESSIONS=4 (the user has 4 gstack windows open). + +${aqBlock} + +You are on branch feature/add-payments in the billing-app project. You were reviewing a plan to add Stripe integration. + +You've hit a decision point: the plan doesn't specify whether to use Stripe Checkout (hosted) or Stripe Elements (embedded). You need to ask the user which approach to use. + +Since this is non-interactive, DO NOT actually call AskUserQuestion. Instead, write the EXACT text you would display to the user (the full AskUserQuestion content) to the file: ${outputPath} + +Remember: _SESSIONS=4, so ELI16 mode is active. The user is juggling multiple windows and may not remember what this conversation is about. Re-ground them.`, + workingDirectory: sessionDir, + maxTurns: 8, + timeout: 60_000, + testName: 'session-awareness', + runId, + }); + + logCost('session awareness', result); + recordE2E('session awareness ELI16', 'Skill E2E tests', result); + + // Verify the output contains ELI16 re-grounding context + if (fs.existsSync(outputPath)) { + const output = fs.readFileSync(outputPath, 'utf-8'); + const lower = output.toLowerCase(); + // Must mention project name + expect(lower.includes('billing') || lower.includes('acme')).toBe(true); + // Must mention branch + expect(lower.includes('payment') || lower.includes('feature')).toBe(true); + // Must mention what we're working on + expect(lower.includes('stripe') || lower.includes('checkout') || lower.includes('payment')).toBe(true); + // Must have a RECOMMENDATION + expect(output).toContain('RECOMMENDATION'); + } else { + // Check agent output as fallback + const output = result.output || ''; + expect(output).toContain('RECOMMENDATION'); + } + + // Clean up + try { fs.rmSync(sessionDir, { recursive: true, force: true }); } catch {} + }, 90_000); +}); + +// --- B4: QA skill E2E --- + +describeIfSelected('QA skill E2E', ['qa-quick'], () => { + let qaDir: string; + + beforeAll(() => { + testServer = testServer || startTestServer(); + qaDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-')); + setupBrowseShims(qaDir); + + // Copy qa skill files into tmpDir + copyDirSync(path.join(ROOT, 'qa'), path.join(qaDir, 'qa')); + + // Create report directory + fs.mkdirSync(path.join(qaDir, 'qa-reports'), { recursive: true }); + }); + + afterAll(() => { + testServer?.server?.stop(); + try { fs.rmSync(qaDir, { recursive: true, force: true }); } catch {} + }); + + test('/qa quick completes without browse errors', async () => { + const result = await runSkillTest({ + prompt: `B="${browseBin}" + +The test server is already running at: ${testServer.url} +Target page: ${testServer.url}/basic.html + +Read the file qa/SKILL.md for the QA workflow instructions. + +Run a Quick-depth QA test on ${testServer.url}/basic.html +Do NOT use AskUserQuestion — run Quick tier directly. +Do NOT try to start a server or discover ports — the URL above is ready. +Write your report to ${qaDir}/qa-reports/qa-report.md`, + workingDirectory: qaDir, + maxTurns: 35, + timeout: 240_000, + testName: 'qa-quick', + runId, + }); + + logCost('/qa quick', result); + recordE2E('/qa quick', 'QA skill E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + // browseErrors can include false positives from hallucinated paths + if (result.browseErrors.length > 0) { + console.warn('/qa quick browse errors (non-fatal):', result.browseErrors); + } + // Accept error_max_turns — the agent doing thorough QA work is not a failure + expect(['success', 'error_max_turns']).toContain(result.exitReason); + }, 300_000); +}); + +// --- B5: Review skill E2E --- + +describeIfSelected('Review skill E2E', ['review-sql-injection'], () => { + let reviewDir: string; + + beforeAll(() => { + reviewDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-review-')); + + // Pre-build a git repo with a vulnerable file on a feature branch (decision 5A) + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: reviewDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Commit a clean base on main + fs.writeFileSync(path.join(reviewDir, 'app.rb'), '# clean base\nclass App\nend\n'); + run('git', ['add', 'app.rb']); + run('git', ['commit', '-m', 'initial commit']); + + // Create feature branch with vulnerable code + run('git', ['checkout', '-b', 'feature/add-user-controller']); + const vulnContent = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-vuln.rb'), 'utf-8'); + fs.writeFileSync(path.join(reviewDir, 'user_controller.rb'), vulnContent); + run('git', ['add', 'user_controller.rb']); + run('git', ['commit', '-m', 'add user controller']); + + // Copy review skill files + fs.copyFileSync(path.join(ROOT, 'review', 'SKILL.md'), path.join(reviewDir, 'review-SKILL.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'checklist.md'), path.join(reviewDir, 'review-checklist.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'greptile-triage.md'), path.join(reviewDir, 'review-greptile-triage.md')); + }); + + afterAll(() => { + try { fs.rmSync(reviewDir, { recursive: true, force: true }); } catch {} + }); + + test('/review produces findings on SQL injection branch', async () => { + const result = await runSkillTest({ + prompt: `You are in a git repo on a feature branch with changes against main. +Read review-SKILL.md for the review workflow instructions. +Also read review-checklist.md and apply it. +Run /review on the current diff (git diff main...HEAD). +Write your review findings to ${reviewDir}/review-output.md`, + workingDirectory: reviewDir, + maxTurns: 15, + timeout: 90_000, + testName: 'review-sql-injection', + runId, + }); + + logCost('/review', result); + recordE2E('/review SQL injection', 'Review skill E2E', result); + expect(result.exitReason).toBe('success'); + }, 120_000); +}); + +// --- Review: Enum completeness E2E --- + +describeIfSelected('Review enum completeness E2E', ['review-enum-completeness'], () => { + let enumDir: string; + + beforeAll(() => { + enumDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-enum-')); + + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: enumDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Commit baseline on main — order model with 4 statuses + const baseContent = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-enum.rb'), 'utf-8'); + fs.writeFileSync(path.join(enumDir, 'order.rb'), baseContent); + run('git', ['add', 'order.rb']); + run('git', ['commit', '-m', 'initial order model']); + + // Feature branch adds "returned" status but misses handlers + run('git', ['checkout', '-b', 'feature/add-returned-status']); + const diffContent = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-enum-diff.rb'), 'utf-8'); + fs.writeFileSync(path.join(enumDir, 'order.rb'), diffContent); + run('git', ['add', 'order.rb']); + run('git', ['commit', '-m', 'add returned status']); + + // Copy review skill files + fs.copyFileSync(path.join(ROOT, 'review', 'SKILL.md'), path.join(enumDir, 'review-SKILL.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'checklist.md'), path.join(enumDir, 'review-checklist.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'greptile-triage.md'), path.join(enumDir, 'review-greptile-triage.md')); + }); + + afterAll(() => { + try { fs.rmSync(enumDir, { recursive: true, force: true }); } catch {} + }); + + test('/review catches missing enum handlers for new status value', async () => { + const result = await runSkillTest({ + prompt: `You are in a git repo on branch feature/add-returned-status with changes against main. +Read review-SKILL.md for the review workflow instructions. +Also read review-checklist.md and apply it — pay special attention to the Enum & Value Completeness section. +Run /review on the current diff (git diff main...HEAD). +Write your review findings to ${enumDir}/review-output.md + +The diff adds a new "returned" status to the Order model. Your job is to check if all consumers handle it.`, + workingDirectory: enumDir, + maxTurns: 15, + timeout: 90_000, + testName: 'review-enum-completeness', + runId, + }); + + logCost('/review enum', result); + recordE2E('/review enum completeness', 'Review enum completeness E2E', result); + expect(result.exitReason).toBe('success'); + + // Verify the review caught the missing enum handlers + const reviewPath = path.join(enumDir, 'review-output.md'); + if (fs.existsSync(reviewPath)) { + const review = fs.readFileSync(reviewPath, 'utf-8'); + // Should mention the missing "returned" handling in at least one of the methods + const mentionsReturned = review.toLowerCase().includes('returned'); + const mentionsEnum = review.toLowerCase().includes('enum') || review.toLowerCase().includes('status'); + const mentionsCritical = review.toLowerCase().includes('critical'); + expect(mentionsReturned).toBe(true); + expect(mentionsEnum || mentionsCritical).toBe(true); + } + }, 120_000); +}); + +// --- Review: Design review lite E2E --- + +describeE2E('Review design lite E2E', () => { + let designDir: string; + + beforeAll(() => { + designDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-design-lite-')); + + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: designDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Commit clean base on main + fs.writeFileSync(path.join(designDir, 'index.html'), '

Clean

\n'); + fs.writeFileSync(path.join(designDir, 'styles.css'), 'body { font-size: 16px; }\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial']); + + // Feature branch adds AI slop CSS + HTML + run('git', ['checkout', '-b', 'feature/add-landing-page']); + const slopCss = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-design-slop.css'), 'utf-8'); + const slopHtml = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-design-slop.html'), 'utf-8'); + fs.writeFileSync(path.join(designDir, 'styles.css'), slopCss); + fs.writeFileSync(path.join(designDir, 'landing.html'), slopHtml); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'add landing page']); + + // Copy review skill files + fs.copyFileSync(path.join(ROOT, 'review', 'SKILL.md'), path.join(designDir, 'review-SKILL.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'checklist.md'), path.join(designDir, 'review-checklist.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'design-checklist.md'), path.join(designDir, 'review-design-checklist.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'greptile-triage.md'), path.join(designDir, 'review-greptile-triage.md')); + }); + + afterAll(() => { + try { fs.rmSync(designDir, { recursive: true, force: true }); } catch {} + }); + + test('/review catches design anti-patterns in CSS/HTML diff', async () => { + const result = await runSkillTest({ + prompt: `You are in a git repo on branch feature/add-landing-page with changes against main. +Read review-SKILL.md for the review workflow instructions. +Read review-checklist.md for the code review checklist. +Read review-design-checklist.md for the design review checklist. +Run /review on the current diff (git diff main...HEAD). + +The diff adds a landing page with CSS and HTML. Check for both code issues AND design anti-patterns. +Write your review findings to ${designDir}/review-output.md + +Important: The design checklist should catch issues like blacklisted fonts, small font sizes, outline:none, !important, AI slop patterns (purple gradients, generic hero copy, 3-column feature grid), etc.`, + workingDirectory: designDir, + maxTurns: 15, + timeout: 120_000, + testName: 'review-design-lite', + runId, + }); + + logCost('/review design lite', result); + recordE2E('/review design lite', 'Review design lite E2E', result); + expect(result.exitReason).toBe('success'); + + // Verify the review caught at least 4 of 7 planted design issues + const reviewPath = path.join(designDir, 'review-output.md'); + if (fs.existsSync(reviewPath)) { + const review = fs.readFileSync(reviewPath, 'utf-8').toLowerCase(); + let detected = 0; + + // Issue 1: Blacklisted font (Papyrus) — HIGH + if (review.includes('papyrus') || review.includes('blacklisted font') || review.includes('font family')) detected++; + // Issue 2: Body text < 16px — HIGH + if (review.includes('14px') || review.includes('font-size') || review.includes('font size') || review.includes('body text')) detected++; + // Issue 3: outline: none — HIGH + if (review.includes('outline') || review.includes('focus')) detected++; + // Issue 4: !important — HIGH + if (review.includes('!important') || review.includes('important')) detected++; + // Issue 5: Purple gradient — MEDIUM + if (review.includes('gradient') || review.includes('purple') || review.includes('violet') || review.includes('#6366f1') || review.includes('#8b5cf6')) detected++; + // Issue 6: Generic hero copy — MEDIUM + if (review.includes('welcome to') || review.includes('all-in-one') || review.includes('generic') || review.includes('hero copy') || review.includes('ai slop')) detected++; + // Issue 7: 3-column feature grid — LOW + if (review.includes('3-column') || review.includes('three-column') || review.includes('feature grid') || review.includes('icon') || review.includes('circle')) detected++; + + console.log(`Design review detected ${detected}/7 planted issues`); + expect(detected).toBeGreaterThanOrEqual(4); + } + }, 150_000); +}); + +// --- B6/B7/B8: Planted-bug outcome evals --- + +// Outcome evals also need ANTHROPIC_API_KEY for the LLM judge +const hasApiKey = !!process.env.ANTHROPIC_API_KEY; +const describeOutcome = (evalsEnabled && hasApiKey) ? describe : describe.skip; + +// Wrap describeOutcome with selection — skip if no planted-bug tests are selected +const outcomeTestNames = ['qa-b6-static', 'qa-b7-spa', 'qa-b8-checkout']; +const anyOutcomeSelected = selectedTests === null || outcomeTestNames.some(t => selectedTests!.includes(t)); +(anyOutcomeSelected ? describeOutcome : describe.skip)('Planted-bug outcome evals', () => { + let outcomeDir: string; + + beforeAll(() => { + // Always start fresh — previous tests' agents may have killed the shared server + try { testServer?.server?.stop(); } catch {} + testServer = startTestServer(); + outcomeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-outcome-')); + setupBrowseShims(outcomeDir); + + // Copy qa skill files + copyDirSync(path.join(ROOT, 'qa'), path.join(outcomeDir, 'qa')); + }); + + afterAll(() => { + testServer?.server?.stop(); + try { fs.rmSync(outcomeDir, { recursive: true, force: true }); } catch {} + }); + + /** + * Shared planted-bug eval runner. + * Gives the agent concise bug-finding instructions (not the full QA workflow), + * then scores the report with an LLM outcome judge. + */ + async function runPlantedBugEval(fixture: string, groundTruthFile: string, label: string) { + // Each test gets its own isolated working directory to prevent cross-contamination + // (agents reading previous tests' reports and hallucinating those bugs) + const testWorkDir = fs.mkdtempSync(path.join(os.tmpdir(), `skill-e2e-${label}-`)); + setupBrowseShims(testWorkDir); + const reportDir = path.join(testWorkDir, 'reports'); + fs.mkdirSync(path.join(reportDir, 'screenshots'), { recursive: true }); + const reportPath = path.join(reportDir, 'qa-report.md'); + + // Direct bug-finding with browse. Keep prompt concise — no reading long SKILL.md docs. + // "Write early, update later" pattern ensures report exists even if agent hits max turns. + const targetUrl = `${testServer.url}/${fixture}`; + const result = await runSkillTest({ + prompt: `Find bugs on this page: ${targetUrl} + +Browser binary: B="${browseBin}" + +PHASE 1 — Quick scan (5 commands max): +$B goto ${targetUrl} +$B console --errors +$B snapshot -i +$B snapshot -c +$B accessibility + +PHASE 2 — Write initial report to ${reportPath}: +Write every bug you found so far. Format each as: +- Category: functional / visual / accessibility / console +- Severity: high / medium / low +- Evidence: what you observed + +PHASE 3 — Interactive testing (targeted — max 15 commands): +- Test email: type "user@" (no domain) and blur — does it validate? +- Test quantity: clear the field entirely — check the total display +- Test credit card: type a 25-character string — check for overflow +- Submit the form with zip code empty — does it require zip? +- Submit a valid form and run $B console --errors +- After finding more bugs, UPDATE ${reportPath} with new findings + +PHASE 4 — Finalize report: +- UPDATE ${reportPath} with ALL bugs found across all phases +- Include console errors, form validation issues, visual overflow, missing attributes + +CRITICAL RULES: +- ONLY test the page at ${targetUrl} — do not navigate to other sites +- Write the report file in PHASE 2 before doing interactive testing +- The report MUST exist at ${reportPath} when you finish`, + workingDirectory: testWorkDir, + maxTurns: 50, + timeout: 300_000, + testName: `qa-${label}`, + runId, + }); + + logCost(`/qa ${label}`, result); + + // Phase 1: browse mechanics. Accept error_max_turns — agent may have written + // a partial report before running out of turns. What matters is detection rate. + if (result.browseErrors.length > 0) { + console.warn(`${label} browse errors:`, result.browseErrors); + } + if (result.exitReason !== 'success' && result.exitReason !== 'error_max_turns') { + throw new Error(`${label}: unexpected exit reason: ${result.exitReason}`); + } + + // Phase 2: Outcome evaluation via LLM judge + const groundTruth = JSON.parse( + fs.readFileSync(path.join(ROOT, 'test', 'fixtures', groundTruthFile), 'utf-8'), + ); + + // Read the generated report (try expected path, then glob for any .md in reportDir or workDir) + let report: string | null = null; + if (fs.existsSync(reportPath)) { + report = fs.readFileSync(reportPath, 'utf-8'); + } else { + // Agent may have named it differently — find any .md in reportDir or testWorkDir + for (const searchDir of [reportDir, testWorkDir]) { + try { + const mdFiles = fs.readdirSync(searchDir).filter(f => f.endsWith('.md')); + if (mdFiles.length > 0) { + report = fs.readFileSync(path.join(searchDir, mdFiles[0]), 'utf-8'); + break; + } + } catch { /* dir may not exist if agent hit max_turns early */ } + } + + // Also check the agent's final output for inline report content + if (!report && result.output && result.output.length > 100) { + report = result.output; + } + } + + if (!report) { + dumpOutcomeDiagnostic(testWorkDir, label, '(no report file found)', { error: 'missing report' }); + recordE2E(`/qa ${label}`, 'Planted-bug outcome evals', result, { error: 'no report generated' }); + throw new Error(`No report file found in ${reportDir}`); + } + + const judgeResult = await outcomeJudge(groundTruth, report); + console.log(`${label} outcome:`, JSON.stringify(judgeResult, null, 2)); + + // Record to eval collector with outcome judge results + recordE2E(`/qa ${label}`, 'Planted-bug outcome evals', result, { + passed: judgePassed(judgeResult, groundTruth), + detection_rate: judgeResult.detection_rate, + false_positives: judgeResult.false_positives, + evidence_quality: judgeResult.evidence_quality, + detected_bugs: judgeResult.detected, + missed_bugs: judgeResult.missed, + }); + + // Diagnostic dump on failure (decision 1C) + if (judgeResult.detection_rate < groundTruth.minimum_detection || judgeResult.false_positives > groundTruth.max_false_positives) { + dumpOutcomeDiagnostic(testWorkDir, label, report, judgeResult); + } + + // Phase 2 assertions + expect(judgeResult.detection_rate).toBeGreaterThanOrEqual(groundTruth.minimum_detection); + expect(judgeResult.false_positives).toBeLessThanOrEqual(groundTruth.max_false_positives); + expect(judgeResult.evidence_quality).toBeGreaterThanOrEqual(2); + } + + // B6: Static dashboard — broken link, disabled submit, overflow, missing alt, console error + test('/qa finds >= 2 of 5 planted bugs (static)', async () => { + await runPlantedBugEval('qa-eval.html', 'qa-eval-ground-truth.json', 'b6-static'); + }, 360_000); + + // B7: SPA — broken route, stale state, async race, missing aria, console warning + test('/qa finds >= 2 of 5 planted SPA bugs', async () => { + await runPlantedBugEval('qa-eval-spa.html', 'qa-eval-spa-ground-truth.json', 'b7-spa'); + }, 360_000); + + // B8: Checkout — email regex, NaN total, CC overflow, missing required, stripe error + test('/qa finds >= 2 of 5 planted checkout bugs', async () => { + await runPlantedBugEval('qa-eval-checkout.html', 'qa-eval-checkout-ground-truth.json', 'b8-checkout'); + }, 360_000); + +}); + +// --- Plan CEO Review E2E --- + +describeIfSelected('Plan CEO Review E2E', ['plan-ceo-review'], () => { + let planDir: string; + + beforeAll(() => { + planDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-ceo-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: planDir, stdio: 'pipe', timeout: 5000 }); + + // Init git repo (CEO review SKILL.md has a "System Audit" step that runs git) + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create a simple plan document for the agent to review + fs.writeFileSync(path.join(planDir, 'plan.md'), `# Plan: Add User Dashboard + +## Context +We're building a new user dashboard that shows recent activity, notifications, and quick actions. + +## Changes +1. New React component \`UserDashboard\` in \`src/components/\` +2. REST API endpoint \`GET /api/dashboard\` returning user stats +3. PostgreSQL query for activity aggregation +4. Redis cache layer for dashboard data (5min TTL) + +## Architecture +- Frontend: React + TailwindCSS +- Backend: Express.js REST API +- Database: PostgreSQL with existing user/activity tables +- Cache: Redis for dashboard aggregates + +## Open questions +- Should we use WebSocket for real-time updates? +- How do we handle users with 100k+ activity records? +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'add plan']); + + // Copy plan-ceo-review skill + fs.mkdirSync(path.join(planDir, 'plan-ceo-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-ceo-review', 'SKILL.md'), + path.join(planDir, 'plan-ceo-review', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(planDir, { recursive: true, force: true }); } catch {} + }); + + test('/plan-ceo-review produces structured review output', async () => { + const result = await runSkillTest({ + prompt: `Read plan-ceo-review/SKILL.md for the review workflow. + +Read plan.md — that's the plan to review. This is a standalone plan document, not a codebase — skip any codebase exploration or system audit steps. + +Choose HOLD SCOPE mode. Skip any AskUserQuestion calls — this is non-interactive. +Write your complete review directly to ${planDir}/review-output.md + +Focus on reviewing the plan content: architecture, error handling, security, and performance.`, + workingDirectory: planDir, + maxTurns: 15, + timeout: 360_000, + testName: 'plan-ceo-review', + runId, + }); + + logCost('/plan-ceo-review', result); + recordE2E('/plan-ceo-review', 'Plan CEO Review E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + // Accept error_max_turns — the CEO review is very thorough and may exceed turns + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify the review was written + const reviewPath = path.join(planDir, 'review-output.md'); + if (fs.existsSync(reviewPath)) { + const review = fs.readFileSync(reviewPath, 'utf-8'); + expect(review.length).toBeGreaterThan(200); + } + }, 420_000); +}); + +// --- Plan CEO Review (SELECTIVE EXPANSION) E2E --- + +describeIfSelected('Plan CEO Review SELECTIVE EXPANSION E2E', ['plan-ceo-review-selective'], () => { + let planDir: string; + + beforeAll(() => { + planDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-ceo-sel-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: planDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + fs.writeFileSync(path.join(planDir, 'plan.md'), `# Plan: Add User Dashboard + +## Context +We're building a new user dashboard that shows recent activity, notifications, and quick actions. + +## Changes +1. New React component \`UserDashboard\` in \`src/components/\` +2. REST API endpoint \`GET /api/dashboard\` returning user stats +3. PostgreSQL query for activity aggregation +4. Redis cache layer for dashboard data (5min TTL) + +## Architecture +- Frontend: React + TailwindCSS +- Backend: Express.js REST API +- Database: PostgreSQL with existing user/activity tables +- Cache: Redis for dashboard aggregates + +## Open questions +- Should we use WebSocket for real-time updates? +- How do we handle users with 100k+ activity records? +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'add plan']); + + fs.mkdirSync(path.join(planDir, 'plan-ceo-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-ceo-review', 'SKILL.md'), + path.join(planDir, 'plan-ceo-review', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(planDir, { recursive: true, force: true }); } catch {} + }); + + test('/plan-ceo-review SELECTIVE EXPANSION produces structured review output', async () => { + const result = await runSkillTest({ + prompt: `Read plan-ceo-review/SKILL.md for the review workflow. + +Read plan.md — that's the plan to review. This is a standalone plan document, not a codebase — skip any codebase exploration or system audit steps. + +Choose SELECTIVE EXPANSION mode. Skip any AskUserQuestion calls — this is non-interactive. +For the cherry-pick ceremony, accept all expansion proposals automatically. +Write your complete review directly to ${planDir}/review-output-selective.md + +Focus on reviewing the plan content: architecture, error handling, security, and performance.`, + workingDirectory: planDir, + maxTurns: 15, + timeout: 360_000, + testName: 'plan-ceo-review-selective', + runId, + }); + + logCost('/plan-ceo-review (SELECTIVE)', result); + recordE2E('/plan-ceo-review-selective', 'Plan CEO Review SELECTIVE EXPANSION E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + const reviewPath = path.join(planDir, 'review-output-selective.md'); + if (fs.existsSync(reviewPath)) { + const review = fs.readFileSync(reviewPath, 'utf-8'); + expect(review.length).toBeGreaterThan(200); + } + }, 420_000); +}); + +// --- Plan Eng Review E2E --- + +describeIfSelected('Plan Eng Review E2E', ['plan-eng-review'], () => { + let planDir: string; + + beforeAll(() => { + planDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-eng-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: planDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create a plan with more engineering detail + fs.writeFileSync(path.join(planDir, 'plan.md'), `# Plan: Migrate Auth to JWT + +## Context +Replace session-cookie auth with JWT tokens. Currently using express-session + Redis store. + +## Changes +1. Add \`jsonwebtoken\` package +2. New middleware \`auth/jwt-verify.ts\` replacing \`auth/session-check.ts\` +3. Login endpoint returns { accessToken, refreshToken } +4. Refresh endpoint rotates tokens +5. Migration script to invalidate existing sessions + +## Files Modified +| File | Change | +|------|--------| +| auth/jwt-verify.ts | NEW: JWT verification middleware | +| auth/session-check.ts | DELETED | +| routes/login.ts | Return JWT instead of setting cookie | +| routes/refresh.ts | NEW: Token refresh endpoint | +| middleware/index.ts | Swap session-check for jwt-verify | + +## Error handling +- Expired token: 401 with \`token_expired\` code +- Invalid token: 401 with \`invalid_token\` code +- Refresh with revoked token: 403 + +## Not in scope +- OAuth/OIDC integration +- Rate limiting on refresh endpoint +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'add plan']); + + // Copy plan-eng-review skill + fs.mkdirSync(path.join(planDir, 'plan-eng-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-eng-review', 'SKILL.md'), + path.join(planDir, 'plan-eng-review', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(planDir, { recursive: true, force: true }); } catch {} + }); + + test('/plan-eng-review produces structured review output', async () => { + const result = await runSkillTest({ + prompt: `Read plan-eng-review/SKILL.md for the review workflow. + +Read plan.md — that's the plan to review. This is a standalone plan document, not a codebase — skip any codebase exploration steps. + +Proceed directly to the full review. Skip any AskUserQuestion calls — this is non-interactive. +Write your complete review directly to ${planDir}/review-output.md + +Focus on architecture, code quality, tests, and performance sections.`, + workingDirectory: planDir, + maxTurns: 15, + timeout: 360_000, + testName: 'plan-eng-review', + runId, + }); + + logCost('/plan-eng-review', result); + recordE2E('/plan-eng-review', 'Plan Eng Review E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify the review was written + const reviewPath = path.join(planDir, 'review-output.md'); + if (fs.existsSync(reviewPath)) { + const review = fs.readFileSync(reviewPath, 'utf-8'); + expect(review.length).toBeGreaterThan(200); + } + }, 420_000); +}); + +// --- Retro E2E --- + +describeIfSelected('Retro E2E', ['retro'], () => { + let retroDir: string; + + beforeAll(() => { + retroDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-retro-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: retroDir, stdio: 'pipe', timeout: 5000 }); + + // Create a git repo with varied commit history + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'dev@example.com']); + run('git', ['config', 'user.name', 'Dev']); + + // Day 1 commits + fs.writeFileSync(path.join(retroDir, 'app.ts'), 'console.log("hello");\n'); + run('git', ['add', 'app.ts']); + run('git', ['commit', '-m', 'feat: initial app setup', '--date', '2026-03-10T09:00:00']); + + fs.writeFileSync(path.join(retroDir, 'auth.ts'), 'export function login() {}\n'); + run('git', ['add', 'auth.ts']); + run('git', ['commit', '-m', 'feat: add auth module', '--date', '2026-03-10T11:00:00']); + + // Day 2 commits + fs.writeFileSync(path.join(retroDir, 'app.ts'), 'import { login } from "./auth";\nconsole.log("hello");\nlogin();\n'); + run('git', ['add', 'app.ts']); + run('git', ['commit', '-m', 'fix: wire up auth to app', '--date', '2026-03-11T10:00:00']); + + fs.writeFileSync(path.join(retroDir, 'test.ts'), 'import { test } from "bun:test";\ntest("login", () => {});\n'); + run('git', ['add', 'test.ts']); + run('git', ['commit', '-m', 'test: add login test', '--date', '2026-03-11T14:00:00']); + + // Day 3 commits + fs.writeFileSync(path.join(retroDir, 'api.ts'), 'export function getUsers() { return []; }\n'); + run('git', ['add', 'api.ts']); + run('git', ['commit', '-m', 'feat: add users API endpoint', '--date', '2026-03-12T09:30:00']); + + fs.writeFileSync(path.join(retroDir, 'README.md'), '# My App\nA test application.\n'); + run('git', ['add', 'README.md']); + run('git', ['commit', '-m', 'docs: add README', '--date', '2026-03-12T16:00:00']); + + // Copy retro skill + fs.mkdirSync(path.join(retroDir, 'retro'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'retro', 'SKILL.md'), + path.join(retroDir, 'retro', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(retroDir, { recursive: true, force: true }); } catch {} + }); + + test('/retro produces analysis from git history', async () => { + const result = await runSkillTest({ + prompt: `Read retro/SKILL.md for instructions on how to run a retrospective. + +Run /retro for the last 7 days of this git repo. Skip any AskUserQuestion calls — this is non-interactive. +Write your retrospective report to ${retroDir}/retro-output.md + +Analyze the git history and produce the narrative report as described in the SKILL.md.`, + workingDirectory: retroDir, + maxTurns: 30, + timeout: 300_000, + testName: 'retro', + runId, + }); + + logCost('/retro', result); + recordE2E('/retro', 'Retro E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + // Accept error_max_turns — retro does many git commands to analyze history + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify the retro was written + const retroPath = path.join(retroDir, 'retro-output.md'); + if (fs.existsSync(retroPath)) { + const retro = fs.readFileSync(retroPath, 'utf-8'); + expect(retro.length).toBeGreaterThan(100); + } + }, 420_000); +}); + +// --- QA-Only E2E (report-only, no fixes) --- + +describeIfSelected('QA-Only skill E2E', ['qa-only-no-fix'], () => { + let qaOnlyDir: string; + + beforeAll(() => { + testServer = testServer || startTestServer(); + qaOnlyDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-only-')); + setupBrowseShims(qaOnlyDir); + + // Copy qa-only skill files + copyDirSync(path.join(ROOT, 'qa-only'), path.join(qaOnlyDir, 'qa-only')); + + // Copy qa templates (qa-only references qa/templates/qa-report-template.md) + fs.mkdirSync(path.join(qaOnlyDir, 'qa', 'templates'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'qa', 'templates', 'qa-report-template.md'), + path.join(qaOnlyDir, 'qa', 'templates', 'qa-report-template.md'), + ); + + // Init git repo (qa-only checks for feature branch in diff-aware mode) + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: qaOnlyDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + fs.writeFileSync(path.join(qaOnlyDir, 'index.html'), '

Test

\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial']); + }); + + afterAll(() => { + try { fs.rmSync(qaOnlyDir, { recursive: true, force: true }); } catch {} + }); + + test('/qa-only produces report without using Edit tool', async () => { + const result = await runSkillTest({ + prompt: `IMPORTANT: The browse binary is already assigned below as B. Do NOT search for it or run the SKILL.md setup block — just use $B directly. + +B="${browseBin}" + +Read the file qa-only/SKILL.md for the QA-only workflow instructions. + +Run a Quick QA test on ${testServer.url}/qa-eval.html +Do NOT use AskUserQuestion — run Quick tier directly. +Write your report to ${qaOnlyDir}/qa-reports/qa-only-report.md`, + workingDirectory: qaOnlyDir, + maxTurns: 35, + allowedTools: ['Bash', 'Read', 'Write', 'Glob'], // NO Edit — the critical guardrail + timeout: 180_000, + testName: 'qa-only-no-fix', + runId, + }); + + logCost('/qa-only', result); + + // Verify Edit was not used — the critical guardrail for report-only mode. + // Glob is read-only and may be used for file discovery (e.g. finding SKILL.md). + const editCalls = result.toolCalls.filter(tc => tc.tool === 'Edit'); + if (editCalls.length > 0) { + console.warn('qa-only used Edit tool:', editCalls.length, 'times'); + } + + const exitOk = ['success', 'error_max_turns'].includes(result.exitReason); + recordE2E('/qa-only no-fix', 'QA-Only skill E2E', result, { + passed: exitOk && editCalls.length === 0, + }); + + expect(editCalls).toHaveLength(0); + + // Accept error_max_turns — the agent doing thorough QA is not a failure + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify git working tree is still clean (no source modifications) + const gitStatus = spawnSync('git', ['status', '--porcelain'], { + cwd: qaOnlyDir, stdio: 'pipe', + }); + const statusLines = gitStatus.stdout.toString().trim().split('\n').filter( + (l: string) => l.trim() && !l.includes('.prompt-tmp') && !l.includes('.gstack/') && !l.includes('qa-reports/'), + ); + expect(statusLines.filter((l: string) => l.startsWith(' M') || l.startsWith('M '))).toHaveLength(0); + }, 240_000); +}); + +// --- QA Fix Loop E2E --- + +describeIfSelected('QA Fix Loop E2E', ['qa-fix-loop'], () => { + let qaFixDir: string; + let qaFixServer: ReturnType | null = null; + + beforeAll(() => { + qaFixDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-fix-')); + setupBrowseShims(qaFixDir); + + // Copy qa skill files + copyDirSync(path.join(ROOT, 'qa'), path.join(qaFixDir, 'qa')); + + // Create a simple HTML page with obvious fixable bugs + fs.writeFileSync(path.join(qaFixDir, 'index.html'), ` + +Test App + +

Welcome to Test App

+ +
+ + + +
+ + + + +`); + + // Init git repo with clean working tree + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: qaFixDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial commit']); + + // Start a local server serving from the working directory so fixes are reflected on refresh + qaFixServer = Bun.serve({ + port: 0, + hostname: '127.0.0.1', + fetch(req) { + const url = new URL(req.url); + let filePath = url.pathname === '/' ? '/index.html' : url.pathname; + filePath = filePath.replace(/^\//, ''); + const fullPath = path.join(qaFixDir, filePath); + if (!fs.existsSync(fullPath)) { + return new Response('Not Found', { status: 404 }); + } + const content = fs.readFileSync(fullPath, 'utf-8'); + return new Response(content, { + headers: { 'Content-Type': 'text/html' }, + }); + }, + }); + }); + + afterAll(() => { + qaFixServer?.stop(); + try { fs.rmSync(qaFixDir, { recursive: true, force: true }); } catch {} + }); + + test('/qa fix loop finds bugs and commits fixes', async () => { + const qaFixUrl = `http://127.0.0.1:${qaFixServer!.port}`; + + const result = await runSkillTest({ + prompt: `You have a browse binary at ${browseBin}. Assign it to B variable like: B="${browseBin}" + +Read the file qa/SKILL.md for the QA workflow instructions. + +Run a Quick-tier QA test on ${qaFixUrl} +The source code for this page is at ${qaFixDir}/index.html — you can fix bugs there. +Do NOT use AskUserQuestion — run Quick tier directly. +Write your report to ${qaFixDir}/qa-reports/qa-report.md + +This is a test+fix loop: find bugs, fix them in the source code, commit each fix, and re-verify.`, + workingDirectory: qaFixDir, + maxTurns: 40, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 300_000, + testName: 'qa-fix-loop', + runId, + }); + + logCost('/qa fix loop', result); + recordE2E('/qa fix loop', 'QA Fix Loop E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + + // Accept error_max_turns — fix loop may use many turns + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify at least one fix commit was made beyond the initial commit + const gitLog = spawnSync('git', ['log', '--oneline'], { + cwd: qaFixDir, stdio: 'pipe', + }); + const commits = gitLog.stdout.toString().trim().split('\n'); + console.log(`/qa fix loop: ${commits.length} commits total (1 initial + ${commits.length - 1} fixes)`); + expect(commits.length).toBeGreaterThan(1); + + // Verify Edit tool was used (agent actually modified source code) + const editCalls = result.toolCalls.filter(tc => tc.tool === 'Edit'); + expect(editCalls.length).toBeGreaterThan(0); + }, 360_000); +}); + +// --- Plan-Eng-Review Test-Plan Artifact E2E --- + +describeIfSelected('Plan-Eng-Review Test-Plan Artifact E2E', ['plan-eng-review-artifact'], () => { + let planDir: string; + let projectDir: string; + + beforeAll(() => { + planDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-artifact-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: planDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create base commit on main + fs.writeFileSync(path.join(planDir, 'app.ts'), 'export function greet() { return "hello"; }\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial']); + + // Create feature branch with changes + run('git', ['checkout', '-b', 'feature/add-dashboard']); + fs.writeFileSync(path.join(planDir, 'dashboard.ts'), `export function Dashboard() { + const data = fetchStats(); + return { users: data.users, revenue: data.revenue }; +} +function fetchStats() { + return fetch('/api/stats').then(r => r.json()); +} +`); + fs.writeFileSync(path.join(planDir, 'app.ts'), `import { Dashboard } from "./dashboard"; +export function greet() { return "hello"; } +export function main() { return Dashboard(); } +`); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'feat: add dashboard']); + + // Plan document + fs.writeFileSync(path.join(planDir, 'plan.md'), `# Plan: Add Dashboard + +## Changes +1. New \`dashboard.ts\` with Dashboard component and fetchStats API call +2. Updated \`app.ts\` to import and use Dashboard + +## Architecture +- Dashboard fetches from \`/api/stats\` endpoint +- Returns user count and revenue metrics +`); + run('git', ['add', 'plan.md']); + run('git', ['commit', '-m', 'add plan']); + + // Copy plan-eng-review skill + fs.mkdirSync(path.join(planDir, 'plan-eng-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-eng-review', 'SKILL.md'), + path.join(planDir, 'plan-eng-review', 'SKILL.md'), + ); + + // Set up remote-slug shim and browse shims (plan-eng-review uses remote-slug for artifact path) + setupBrowseShims(planDir); + + // Create project directory for artifacts + projectDir = path.join(os.homedir(), '.gstack', 'projects', 'test-project'); + fs.mkdirSync(projectDir, { recursive: true }); + }); + + afterAll(() => { + try { fs.rmSync(planDir, { recursive: true, force: true }); } catch {} + // Clean up test-plan artifacts (but not the project dir itself) + try { + const files = fs.readdirSync(projectDir); + for (const f of files) { + if (f.includes('test-plan')) { + fs.unlinkSync(path.join(projectDir, f)); + } + } + } catch {} + }); + + test('/plan-eng-review writes test-plan artifact to ~/.gstack/projects/', async () => { + // Count existing test-plan files before + const beforeFiles = fs.readdirSync(projectDir).filter(f => f.includes('test-plan')); + + const result = await runSkillTest({ + prompt: `Read plan-eng-review/SKILL.md for the review workflow. + +Read plan.md — that's the plan to review. This is a standalone plan with source code in app.ts and dashboard.ts. + +Proceed directly to the full review. Skip any AskUserQuestion calls — this is non-interactive. + +IMPORTANT: After your review, you MUST write the test-plan artifact as described in the "Test Plan Artifact" section of SKILL.md. The remote-slug shim is at ${planDir}/browse/bin/remote-slug. + +Write your review to ${planDir}/review-output.md`, + workingDirectory: planDir, + maxTurns: 20, + allowedTools: ['Bash', 'Read', 'Write', 'Glob', 'Grep'], + timeout: 360_000, + testName: 'plan-eng-review-artifact', + runId, + }); + + logCost('/plan-eng-review artifact', result); + recordE2E('/plan-eng-review test-plan artifact', 'Plan-Eng-Review Test-Plan Artifact E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify test-plan artifact was written + const afterFiles = fs.readdirSync(projectDir).filter(f => f.includes('test-plan')); + const newFiles = afterFiles.filter(f => !beforeFiles.includes(f)); + console.log(`Test-plan artifacts: ${beforeFiles.length} before, ${afterFiles.length} after, ${newFiles.length} new`); + + if (newFiles.length > 0) { + const content = fs.readFileSync(path.join(projectDir, newFiles[0]), 'utf-8'); + console.log(`Test-plan artifact (${newFiles[0]}): ${content.length} chars`); + expect(content.length).toBeGreaterThan(50); + } else { + console.warn('No test-plan artifact found — agent may not have followed artifact instructions'); + } + + // Soft assertion: we expect an artifact but agent compliance is not guaranteed + expect(newFiles.length).toBeGreaterThanOrEqual(1); + }, 420_000); +}); + +// --- Base branch detection smoke tests --- + +describeIfSelected('Base branch detection', ['review-base-branch', 'ship-base-branch', 'retro-base-branch'], () => { + let baseBranchDir: string; + const run = (cmd: string, args: string[], cwd: string) => + spawnSync(cmd, args, { cwd, stdio: 'pipe', timeout: 5000 }); + + beforeAll(() => { + baseBranchDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-basebranch-')); + }); + + afterAll(() => { + try { fs.rmSync(baseBranchDir, { recursive: true, force: true }); } catch {} + }); + + testIfSelected('review-base-branch', async () => { + const dir = path.join(baseBranchDir, 'review-base'); + fs.mkdirSync(dir, { recursive: true }); + + // Create git repo with a feature branch off main + run('git', ['init'], dir); + run('git', ['config', 'user.email', 'test@test.com'], dir); + run('git', ['config', 'user.name', 'Test'], dir); + + fs.writeFileSync(path.join(dir, 'app.rb'), '# clean base\nclass App\nend\n'); + run('git', ['add', 'app.rb'], dir); + run('git', ['commit', '-m', 'initial commit'], dir); + + // Create feature branch with a change + run('git', ['checkout', '-b', 'feature/test-review'], dir); + fs.writeFileSync(path.join(dir, 'app.rb'), '# clean base\nclass App\n def hello; "world"; end\nend\n'); + run('git', ['add', 'app.rb'], dir); + run('git', ['commit', '-m', 'feat: add hello method'], dir); + + // Copy review skill files + fs.copyFileSync(path.join(ROOT, 'review', 'SKILL.md'), path.join(dir, 'review-SKILL.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'checklist.md'), path.join(dir, 'review-checklist.md')); + fs.copyFileSync(path.join(ROOT, 'review', 'greptile-triage.md'), path.join(dir, 'review-greptile-triage.md')); + + const result = await runSkillTest({ + prompt: `You are in a git repo on a feature branch with changes. +Read review-SKILL.md for the review workflow instructions. +Also read review-checklist.md and apply it. + +IMPORTANT: Follow Step 0 to detect the base branch. Since there is no remote, gh commands will fail — fall back to main. +Then run the review against the detected base branch. +Write your findings to ${dir}/review-output.md`, + workingDirectory: dir, + maxTurns: 15, + timeout: 90_000, + testName: 'review-base-branch', + runId, + }); + + logCost('/review base-branch', result); + recordE2E('/review base branch detection', 'Base branch detection', result); + expect(result.exitReason).toBe('success'); + + // Verify the review used "base branch" language (from Step 0) + const toolOutputs = result.toolCalls.map(tc => tc.output || '').join('\n'); + const allOutput = (result.output || '') + toolOutputs; + // The agent should have run git diff against main (the fallback) + const usedGitDiff = result.toolCalls.some(tc => + tc.tool === 'Bash' && typeof tc.input === 'string' && tc.input.includes('git diff') + ); + expect(usedGitDiff).toBe(true); + }, 120_000); + + testIfSelected('ship-base-branch', async () => { + const dir = path.join(baseBranchDir, 'ship-base'); + fs.mkdirSync(dir, { recursive: true }); + + // Create git repo with feature branch + run('git', ['init'], dir); + run('git', ['config', 'user.email', 'test@test.com'], dir); + run('git', ['config', 'user.name', 'Test'], dir); + + fs.writeFileSync(path.join(dir, 'app.ts'), 'console.log("v1");\n'); + run('git', ['add', 'app.ts'], dir); + run('git', ['commit', '-m', 'initial'], dir); + + run('git', ['checkout', '-b', 'feature/ship-test'], dir); + fs.writeFileSync(path.join(dir, 'app.ts'), 'console.log("v2");\n'); + run('git', ['add', 'app.ts'], dir); + run('git', ['commit', '-m', 'feat: update to v2'], dir); + + // Copy ship skill + fs.copyFileSync(path.join(ROOT, 'ship', 'SKILL.md'), path.join(dir, 'ship-SKILL.md')); + + const result = await runSkillTest({ + prompt: `Read ship-SKILL.md for the ship workflow. + +Run ONLY Step 0 (Detect base branch) and Step 1 (Pre-flight) from the ship workflow. +Since there is no remote, gh commands will fail — fall back to main. + +After completing Step 0 and Step 1, STOP. Do NOT proceed to Step 2 or beyond. +Do NOT push, create PRs, or modify VERSION/CHANGELOG. + +Write a summary of what you detected to ${dir}/ship-preflight.md including: +- The detected base branch name +- The current branch name +- The diff stat against the base branch`, + workingDirectory: dir, + maxTurns: 10, + timeout: 60_000, + testName: 'ship-base-branch', + runId, + }); + + logCost('/ship base-branch', result); + recordE2E('/ship base branch detection', 'Base branch detection', result); + expect(result.exitReason).toBe('success'); + + // Verify preflight output was written + const preflightPath = path.join(dir, 'ship-preflight.md'); + if (fs.existsSync(preflightPath)) { + const content = fs.readFileSync(preflightPath, 'utf-8'); + expect(content.length).toBeGreaterThan(20); + // Should mention the branch name + expect(content.toLowerCase()).toMatch(/main|base/); + } + + // Verify no destructive actions — no push, no PR creation + const destructiveTools = result.toolCalls.filter(tc => + tc.tool === 'Bash' && typeof tc.input === 'string' && + (tc.input.includes('git push') || tc.input.includes('gh pr create')) + ); + expect(destructiveTools).toHaveLength(0); + }, 90_000); + + testIfSelected('retro-base-branch', async () => { + const dir = path.join(baseBranchDir, 'retro-base'); + fs.mkdirSync(dir, { recursive: true }); + + // Create git repo with commit history + run('git', ['init'], dir); + run('git', ['config', 'user.email', 'dev@example.com'], dir); + run('git', ['config', 'user.name', 'Dev'], dir); + + fs.writeFileSync(path.join(dir, 'app.ts'), 'console.log("hello");\n'); + run('git', ['add', 'app.ts'], dir); + run('git', ['commit', '-m', 'feat: initial app', '--date', '2026-03-14T09:00:00'], dir); + + fs.writeFileSync(path.join(dir, 'auth.ts'), 'export function login() {}\n'); + run('git', ['add', 'auth.ts'], dir); + run('git', ['commit', '-m', 'feat: add auth', '--date', '2026-03-15T10:00:00'], dir); + + fs.writeFileSync(path.join(dir, 'test.ts'), 'test("it works", () => {});\n'); + run('git', ['add', 'test.ts'], dir); + run('git', ['commit', '-m', 'test: add tests', '--date', '2026-03-16T11:00:00'], dir); + + // Copy retro skill + fs.mkdirSync(path.join(dir, 'retro'), { recursive: true }); + fs.copyFileSync(path.join(ROOT, 'retro', 'SKILL.md'), path.join(dir, 'retro', 'SKILL.md')); + + const result = await runSkillTest({ + prompt: `Read retro/SKILL.md for instructions on how to run a retrospective. + +IMPORTANT: Follow the "Detect default branch" step first. Since there is no remote, gh will fail — fall back to main. +Then use the detected branch name for all git queries. + +Run /retro for the last 7 days of this git repo. Skip any AskUserQuestion calls — this is non-interactive. +This is a local-only repo so use the local branch (main) instead of origin/main for all git log commands. + +Write your retrospective to ${dir}/retro-output.md`, + workingDirectory: dir, + maxTurns: 25, + timeout: 240_000, + testName: 'retro-base-branch', + runId, + }); + + logCost('/retro base-branch', result); + recordE2E('/retro default branch detection', 'Base branch detection', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify retro output was produced + const retroPath = path.join(dir, 'retro-output.md'); + if (fs.existsSync(retroPath)) { + const content = fs.readFileSync(retroPath, 'utf-8'); + expect(content.length).toBeGreaterThan(100); + } + }, 300_000); +}); + +// --- Document-Release skill E2E --- + +describeIfSelected('Document-Release skill E2E', ['document-release'], () => { + let docReleaseDir: string; + + beforeAll(() => { + docReleaseDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-doc-release-')); + + // Copy document-release skill files + copyDirSync(path.join(ROOT, 'document-release'), path.join(docReleaseDir, 'document-release')); + + // Init git repo with initial docs + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: docReleaseDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create initial README with a features list + fs.writeFileSync(path.join(docReleaseDir, 'README.md'), + '# Test Project\n\n## Features\n\n- Feature A\n- Feature B\n\n## Install\n\n```bash\nnpm install\n```\n'); + + // Create initial CHANGELOG that must NOT be clobbered + fs.writeFileSync(path.join(docReleaseDir, 'CHANGELOG.md'), + '# Changelog\n\n## 1.0.0 — 2026-03-01\n\n- Initial release with Feature A and Feature B\n- Setup CI pipeline\n'); + + // Create VERSION file (already bumped) + fs.writeFileSync(path.join(docReleaseDir, 'VERSION'), '1.1.0\n'); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial']); + + // Create feature branch with a code change + run('git', ['checkout', '-b', 'feat/add-feature-c']); + fs.writeFileSync(path.join(docReleaseDir, 'feature-c.ts'), 'export function featureC() { return "C"; }\n'); + fs.writeFileSync(path.join(docReleaseDir, 'VERSION'), '1.1.1\n'); + fs.writeFileSync(path.join(docReleaseDir, 'CHANGELOG.md'), + '# Changelog\n\n## 1.1.1 — 2026-03-16\n\n- Added Feature C\n\n## 1.0.0 — 2026-03-01\n\n- Initial release with Feature A and Feature B\n- Setup CI pipeline\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'feat: add feature C']); + }); + + afterAll(() => { + try { fs.rmSync(docReleaseDir, { recursive: true, force: true }); } catch {} + }); + + test('/document-release updates docs without clobbering CHANGELOG', async () => { + const result = await runSkillTest({ + prompt: `Read the file document-release/SKILL.md for the document-release workflow instructions. + +Run the /document-release workflow on this repo. The base branch is "main". + +IMPORTANT: +- Do NOT use AskUserQuestion — auto-approve everything or skip if unsure. +- Do NOT push or create PRs (there is no remote). +- Do NOT run gh commands (no remote). +- Focus on updating README.md to reflect the new Feature C. +- Do NOT overwrite or regenerate CHANGELOG entries. +- Skip VERSION bump (it's already bumped). +- After editing, just commit the changes locally.`, + workingDirectory: docReleaseDir, + maxTurns: 30, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Grep', 'Glob'], + timeout: 180_000, + testName: 'document-release', + runId, + }); + + logCost('/document-release', result); + + // Read CHANGELOG to verify it was NOT clobbered + const changelog = fs.readFileSync(path.join(docReleaseDir, 'CHANGELOG.md'), 'utf-8'); + const hasOriginalEntries = changelog.includes('Initial release with Feature A and Feature B') + && changelog.includes('Setup CI pipeline') + && changelog.includes('1.0.0'); + if (!hasOriginalEntries) { + console.warn('CHANGELOG CLOBBERED — original entries missing!'); + } + + // Check if README was updated + const readme = fs.readFileSync(path.join(docReleaseDir, 'README.md'), 'utf-8'); + const readmeUpdated = readme.includes('Feature C') || readme.includes('feature-c') || readme.includes('feature C'); + + const exitOk = ['success', 'error_max_turns'].includes(result.exitReason); + recordE2E('/document-release', 'Document-Release skill E2E', result, { + passed: exitOk && hasOriginalEntries, + }); + + // Critical guardrail: CHANGELOG must not be clobbered + expect(hasOriginalEntries).toBe(true); + + // Accept error_max_turns — thorough doc review is not a failure + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Informational: did it update README? + if (readmeUpdated) { + console.log('README updated to include Feature C'); + } else { + console.warn('README was NOT updated — agent may not have found the feature'); + } + }, 240_000); +}); + +// --- Deferred skill E2E tests (destructive or require interactive UI) --- + +// Deferred tests — only test.todo entries, no selection needed +describeE2E('Deferred skill E2E', () => { + // Ship is destructive: pushes to remote, creates PRs, modifies VERSION/CHANGELOG + test.todo('/ship completes full workflow'); + + // Setup-browser-cookies requires interactive browser picker UI + test.todo('/setup-browser-cookies imports cookies'); + +}); + +// --- gstack-upgrade E2E --- + +describeIfSelected('gstack-upgrade E2E', ['gstack-upgrade-happy-path'], () => { + let upgradeDir: string; + let remoteDir: string; + + beforeAll(() => { + upgradeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-upgrade-')); + remoteDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-remote-')); + + const run = (cmd: string, args: string[], cwd: string) => + spawnSync(cmd, args, { cwd, stdio: 'pipe', timeout: 5000 }); + + // Init the "project" repo + run('git', ['init'], upgradeDir); + run('git', ['config', 'user.email', 'test@test.com'], upgradeDir); + run('git', ['config', 'user.name', 'Test'], upgradeDir); + + // Create mock gstack install directory (local-git type) + const mockGstack = path.join(upgradeDir, '.claude', 'skills', 'gstack'); + fs.mkdirSync(mockGstack, { recursive: true }); + + // Init as a git repo + run('git', ['init'], mockGstack); + run('git', ['config', 'user.email', 'test@test.com'], mockGstack); + run('git', ['config', 'user.name', 'Test'], mockGstack); + + // Create bare remote + run('git', ['init', '--bare'], remoteDir); + run('git', ['remote', 'add', 'origin', remoteDir], mockGstack); + + // Write old version files + fs.writeFileSync(path.join(mockGstack, 'VERSION'), '0.5.0\n'); + fs.writeFileSync(path.join(mockGstack, 'CHANGELOG.md'), + '# Changelog\n\n## 0.5.0 — 2026-03-01\n\n- Initial release\n'); + fs.writeFileSync(path.join(mockGstack, 'setup'), + '#!/bin/bash\necho "Setup completed"\n', { mode: 0o755 }); + + // Initial commit + push + run('git', ['add', '.'], mockGstack); + run('git', ['commit', '-m', 'initial'], mockGstack); + run('git', ['push', '-u', 'origin', 'HEAD:main'], mockGstack); + + // Create new version (simulate upstream release) + fs.writeFileSync(path.join(mockGstack, 'VERSION'), '0.6.0\n'); + fs.writeFileSync(path.join(mockGstack, 'CHANGELOG.md'), + '# Changelog\n\n## 0.6.0 — 2026-03-15\n\n- New feature: interactive design review\n- Fix: snapshot flag validation\n\n## 0.5.0 — 2026-03-01\n\n- Initial release\n'); + run('git', ['add', '.'], mockGstack); + run('git', ['commit', '-m', 'release 0.6.0'], mockGstack); + run('git', ['push', 'origin', 'HEAD:main'], mockGstack); + + // Reset working copy back to old version + run('git', ['reset', '--hard', 'HEAD~1'], mockGstack); + + // Copy gstack-upgrade skill + fs.mkdirSync(path.join(upgradeDir, 'gstack-upgrade'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'gstack-upgrade', 'SKILL.md'), + path.join(upgradeDir, 'gstack-upgrade', 'SKILL.md'), + ); + + // Commit so git repo is clean + run('git', ['add', '.'], upgradeDir); + run('git', ['commit', '-m', 'initial project'], upgradeDir); + }); + + afterAll(() => { + try { fs.rmSync(upgradeDir, { recursive: true, force: true }); } catch {} + try { fs.rmSync(remoteDir, { recursive: true, force: true }); } catch {} + }); + + testIfSelected('gstack-upgrade-happy-path', async () => { + const mockGstack = path.join(upgradeDir, '.claude', 'skills', 'gstack'); + const result = await runSkillTest({ + prompt: `Read gstack-upgrade/SKILL.md for the upgrade workflow. + +You are running /gstack-upgrade standalone. The gstack installation is at ./.claude/skills/gstack (local-git type — it has a .git directory with an origin remote). + +Current version: 0.5.0. A new version 0.6.0 is available on origin/main. + +Follow the standalone upgrade flow: +1. Detect install type (local-git) +2. Run git fetch origin && git reset --hard origin/main in the install directory +3. Run the setup script +4. Show what's new from CHANGELOG + +Skip any AskUserQuestion calls — auto-approve the upgrade. Write a summary of what you did to stdout. + +IMPORTANT: The install directory is at ./.claude/skills/gstack — use that exact path.`, + workingDirectory: upgradeDir, + maxTurns: 20, + timeout: 180_000, + testName: 'gstack-upgrade-happy-path', + runId, + }); + + logCost('/gstack-upgrade happy path', result); + + // Check that the version was updated + const versionAfter = fs.readFileSync(path.join(mockGstack, 'VERSION'), 'utf-8').trim(); + const output = result.output || ''; + const mentionsUpgrade = output.toLowerCase().includes('0.6.0') || + output.toLowerCase().includes('upgrade') || + output.toLowerCase().includes('updated'); + + recordE2E('/gstack-upgrade happy path', 'gstack-upgrade E2E', result, { + passed: versionAfter === '0.6.0' && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(versionAfter).toBe('0.6.0'); + }, 240_000); +}); + +// --- Design Consultation E2E --- + +/** + * LLM judge for DESIGN.md quality — checks font blacklist compliance, + * coherence, specificity, and AI slop avoidance. + */ +async function designQualityJudge(designMd: string): Promise<{ passed: boolean; reasoning: string }> { + return callJudge<{ passed: boolean; reasoning: string }>(`You are evaluating a generated DESIGN.md file for quality. + +Evaluate against these criteria — ALL must pass for an overall "passed: true": +1. Does NOT recommend Inter, Roboto, Arial, Helvetica, Open Sans, Lato, Montserrat, or Poppins as primary fonts +2. Aesthetic direction is coherent with color approach (e.g., brutalist aesthetic doesn't pair with expressive color without explanation) +3. Font recommendations include specific font names (not generic like "a sans-serif font") +4. Color palette includes actual hex values, not placeholders like "[hex]" +5. Rationale is provided for major decisions (not just "because it looks good") +6. No AI slop patterns: purple gradients mentioned positively, "3-column feature grid" language, generic marketing speak +7. Product context is reflected in design choices (civic tech → should have appropriate, professional aesthetic) + +DESIGN.md content: +\`\`\` +${designMd} +\`\`\` + +Return JSON: { "passed": true/false, "reasoning": "one paragraph explaining your evaluation" }`); +} + +describeIfSelected('Design Consultation E2E', [ + 'design-consultation-core', 'design-consultation-research', + 'design-consultation-existing', 'design-consultation-preview', +], () => { + let designDir: string; + + beforeAll(() => { + designDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-design-consultation-')); + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: designDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create a realistic project context + fs.writeFileSync(path.join(designDir, 'README.md'), `# CivicPulse + +A civic tech data platform for government employees to access, visualize, and share public data. Built with Next.js and PostgreSQL. + +## Features +- Real-time data dashboards for municipal budgets +- Public records search with faceted filtering +- Data export and sharing tools for inter-department collaboration +`); + fs.writeFileSync(path.join(designDir, 'package.json'), JSON.stringify({ + name: 'civicpulse', + version: '0.1.0', + dependencies: { next: '^14.0.0', react: '^18.2.0', 'tailwindcss': '^3.4.0' }, + }, null, 2)); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial project setup']); + + // Copy design-consultation skill + fs.mkdirSync(path.join(designDir, 'design-consultation'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'design-consultation', 'SKILL.md'), + path.join(designDir, 'design-consultation', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(designDir, { recursive: true, force: true }); } catch {} + }); + + testIfSelected('design-consultation-core', async () => { + const result = await runSkillTest({ + prompt: `Read design-consultation/SKILL.md for the design consultation workflow. + +This is a civic tech data platform called CivicPulse for government employees who need to access public data. Read the README.md for details. + +Skip research — work from your design knowledge. Skip the font preview page. Skip any AskUserQuestion calls — this is non-interactive. Accept your first design system proposal. + +Write DESIGN.md and CLAUDE.md (or update it) in the working directory.`, + workingDirectory: designDir, + maxTurns: 20, + timeout: 360_000, + testName: 'design-consultation-core', + runId, + }); + + logCost('/design-consultation core', result); + + const designPath = path.join(designDir, 'DESIGN.md'); + const claudePath = path.join(designDir, 'CLAUDE.md'); + const designExists = fs.existsSync(designPath); + const claudeExists = fs.existsSync(claudePath); + let designContent = ''; + + if (designExists) { + designContent = fs.readFileSync(designPath, 'utf-8'); + } + + // Structural checks + const requiredSections = ['Product Context', 'Aesthetic', 'Typography', 'Color', 'Spacing', 'Layout', 'Motion']; + const missingSections = requiredSections.filter(s => !designContent.toLowerCase().includes(s.toLowerCase())); + + // LLM judge for quality + let judgeResult = { passed: false, reasoning: 'judge not run' }; + if (designExists && designContent.length > 100) { + try { + judgeResult = await designQualityJudge(designContent); + console.log('Design quality judge:', JSON.stringify(judgeResult, null, 2)); + } catch (err) { + console.warn('Judge failed:', err); + judgeResult = { passed: true, reasoning: 'judge error — defaulting to pass' }; + } + } + + const structuralPass = designExists && claudeExists && missingSections.length === 0; + recordE2E('/design-consultation core', 'Design Consultation E2E', result, { + passed: structuralPass && judgeResult.passed && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(designExists).toBe(true); + if (designExists) { + expect(missingSections).toHaveLength(0); + } + if (claudeExists) { + const claude = fs.readFileSync(claudePath, 'utf-8'); + expect(claude.toLowerCase()).toContain('design.md'); + } + }, 420_000); + + testIfSelected('design-consultation-research', async () => { + // Clean up from previous test + try { fs.unlinkSync(path.join(designDir, 'DESIGN.md')); } catch {} + try { fs.unlinkSync(path.join(designDir, 'CLAUDE.md')); } catch {} + + const result = await runSkillTest({ + prompt: `Read design-consultation/SKILL.md for the design consultation workflow. + +This is a civic tech data platform called CivicPulse. Read the README.md. + +DO research what's out there before proposing — search for civic tech and government data platform designs. Skip the font preview page. Skip any AskUserQuestion calls — this is non-interactive. + +Write DESIGN.md to the working directory.`, + workingDirectory: designDir, + maxTurns: 30, + timeout: 360_000, + testName: 'design-consultation-research', + runId, + }); + + logCost('/design-consultation research', result); + + const designPath = path.join(designDir, 'DESIGN.md'); + const designExists = fs.existsSync(designPath); + let designContent = ''; + if (designExists) { + designContent = fs.readFileSync(designPath, 'utf-8'); + } + + // Check if WebSearch was used (may not be available in all envs) + const webSearchCalls = result.toolCalls.filter(tc => tc.tool === 'WebSearch'); + if (webSearchCalls.length > 0) { + console.log(`WebSearch used ${webSearchCalls.length} times`); + } else { + console.warn('WebSearch not used — may be unavailable in test env'); + } + + // LLM judge + let judgeResult = { passed: false, reasoning: 'judge not run' }; + if (designExists && designContent.length > 100) { + try { + judgeResult = await designQualityJudge(designContent); + console.log('Design quality judge (research):', JSON.stringify(judgeResult, null, 2)); + } catch (err) { + console.warn('Judge failed:', err); + judgeResult = { passed: true, reasoning: 'judge error — defaulting to pass' }; + } + } + + recordE2E('/design-consultation research', 'Design Consultation E2E', result, { + passed: designExists && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(designExists).toBe(true); + }, 420_000); + + testIfSelected('design-consultation-existing', async () => { + // Pre-create a minimal DESIGN.md + fs.writeFileSync(path.join(designDir, 'DESIGN.md'), `# Design System — CivicPulse + +## Typography +Body: system-ui +`); + + const result = await runSkillTest({ + prompt: `Read design-consultation/SKILL.md for the design consultation workflow. + +There is already a DESIGN.md in this repo. Update it with a complete design system for CivicPulse, a civic tech data platform for government employees. + +Skip research. Skip font preview. Skip any AskUserQuestion calls — this is non-interactive.`, + workingDirectory: designDir, + maxTurns: 20, + timeout: 360_000, + testName: 'design-consultation-existing', + runId, + }); + + logCost('/design-consultation existing', result); + + const designPath = path.join(designDir, 'DESIGN.md'); + const designExists = fs.existsSync(designPath); + let designContent = ''; + if (designExists) { + designContent = fs.readFileSync(designPath, 'utf-8'); + } + + // Should have more content than the minimal version + const hasColor = designContent.toLowerCase().includes('color'); + const hasSpacing = designContent.toLowerCase().includes('spacing'); + + recordE2E('/design-consultation existing', 'Design Consultation E2E', result, { + passed: designExists && hasColor && hasSpacing && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(designExists).toBe(true); + if (designExists) { + expect(hasColor).toBe(true); + expect(hasSpacing).toBe(true); + } + }, 420_000); + + testIfSelected('design-consultation-preview', async () => { + // Clean up + try { fs.unlinkSync(path.join(designDir, 'DESIGN.md')); } catch {} + + const result = await runSkillTest({ + prompt: `Read design-consultation/SKILL.md for the design consultation workflow. + +This is CivicPulse, a civic tech data platform. Read the README.md. + +Skip research. Skip any AskUserQuestion calls — this is non-interactive. Generate the font and color preview page but write it to ./design-preview.html instead of /tmp/ (do NOT run the open command). Then write DESIGN.md.`, + workingDirectory: designDir, + maxTurns: 20, + timeout: 360_000, + testName: 'design-consultation-preview', + runId, + }); + + logCost('/design-consultation preview', result); + + const previewPath = path.join(designDir, 'design-preview.html'); + const designPath = path.join(designDir, 'DESIGN.md'); + const previewExists = fs.existsSync(previewPath); + const designExists = fs.existsSync(designPath); + + let previewContent = ''; + if (previewExists) { + previewContent = fs.readFileSync(previewPath, 'utf-8'); + } + + const hasHtml = previewContent.includes(' 100) { + try { + judgeResult = await designQualityJudge(designContent); + console.log('Design quality judge (preview):', JSON.stringify(judgeResult, null, 2)); + } catch (err) { + console.warn('Judge failed:', err); + judgeResult = { passed: true, reasoning: 'judge error — defaulting to pass' }; + } + } + } + + recordE2E('/design-consultation preview', 'Design Consultation E2E', result, { + passed: previewExists && designExists && hasHtml && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(previewExists).toBe(true); + if (previewExists) { + expect(hasHtml).toBe(true); + expect(hasFontRef).toBe(true); + } + expect(designExists).toBe(true); + }, 420_000); +}); + +// --- Plan Design Review E2E (plan-mode) --- + +describeIfSelected('Plan Design Review E2E', ['plan-design-review-plan-mode', 'plan-design-review-no-ui-scope'], () => { + let reviewDir: string; + + beforeAll(() => { + reviewDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-design-')); + + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: reviewDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Copy plan-design-review skill + fs.mkdirSync(path.join(reviewDir, 'plan-design-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-design-review', 'SKILL.md'), + path.join(reviewDir, 'plan-design-review', 'SKILL.md'), + ); + + // Create a plan file with intentional design gaps + fs.writeFileSync(path.join(reviewDir, 'plan.md'), `# Plan: User Dashboard + +## Context +Build a user dashboard that shows account stats, recent activity, and settings. + +## Implementation +1. Create a dashboard page at /dashboard +2. Show user stats (posts, followers, engagement rate) +3. Add a recent activity feed +4. Add a settings panel +5. Use a clean, modern UI with cards and icons +6. Add a hero section at the top with a gradient background + +## Technical Details +- React components with Tailwind CSS +- API endpoint: GET /api/dashboard +- WebSocket for real-time activity updates +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial plan']); + }); + + afterAll(() => { + try { fs.rmSync(reviewDir, { recursive: true, force: true }); } catch {} + }); + + testIfSelected('plan-design-review-plan-mode', async () => { + const result = await runSkillTest({ + prompt: `Read plan-design-review/SKILL.md for the design review workflow. + +Review the plan in ./plan.md. This plan has several design gaps — it uses vague language like "clean, modern UI" and "cards and icons", mentions a "hero section with gradient" (AI slop), and doesn't specify empty states, error states, loading states, responsive behavior, or accessibility. + +Skip the preamble bash block. Skip any AskUserQuestion calls — this is non-interactive. Rate each design dimension 0-10 and explain what would make it a 10. Then EDIT plan.md to add the missing design decisions (interaction state table, empty states, responsive behavior, etc.). + +IMPORTANT: Do NOT try to browse any URLs or use a browse binary. This is a plan review, not a live site audit. Just read the plan file, review it, and edit it to fix the gaps.`, + workingDirectory: reviewDir, + maxTurns: 15, + timeout: 300_000, + testName: 'plan-design-review-plan-mode', + runId, + }); + + logCost('/plan-design-review plan-mode', result); + + // Check that the agent produced design ratings (0-10 scale) + const output = result.output || ''; + const hasRatings = /\d+\/10/.test(output); + const hasDesignContent = output.toLowerCase().includes('information architecture') || + output.toLowerCase().includes('interaction state') || + output.toLowerCase().includes('ai slop') || + output.toLowerCase().includes('hierarchy'); + + // Check that the plan file was edited (the core new behavior) + const planAfter = fs.readFileSync(path.join(reviewDir, 'plan.md'), 'utf-8'); + const planOriginal = `# Plan: User Dashboard`; + const planWasEdited = planAfter.length > 300; // Original is ~450 chars, edited should be much longer + const planHasDesignAdditions = planAfter.toLowerCase().includes('empty') || + planAfter.toLowerCase().includes('loading') || + planAfter.toLowerCase().includes('error') || + planAfter.toLowerCase().includes('state') || + planAfter.toLowerCase().includes('responsive') || + planAfter.toLowerCase().includes('accessibility'); + + recordE2E('/plan-design-review plan-mode', 'Plan Design Review E2E', result, { + passed: hasDesignContent && planWasEdited && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + // Agent should produce design-relevant output about the plan + expect(hasDesignContent).toBe(true); + // Agent should have edited the plan file to add missing design decisions + expect(planWasEdited).toBe(true); + expect(planHasDesignAdditions).toBe(true); + }, 360_000); + + testIfSelected('plan-design-review-no-ui-scope', async () => { + // Write a backend-only plan + fs.writeFileSync(path.join(reviewDir, 'backend-plan.md'), `# Plan: Database Migration + +## Context +Migrate user records from PostgreSQL to a new schema with better indexing. + +## Implementation +1. Create migration to add new columns to users table +2. Backfill data from legacy columns +3. Add database indexes for common query patterns +4. Update ActiveRecord models +5. Run migration in staging first, then production +`); + + const result = await runSkillTest({ + prompt: `Read plan-design-review/SKILL.md for the design review workflow. + +Review the plan in ./backend-plan.md. This is a pure backend database migration plan with no UI changes. + +Skip the preamble bash block. Skip any AskUserQuestion calls — this is non-interactive. Write your findings directly to stdout. + +IMPORTANT: Do NOT try to browse any URLs or use a browse binary. This is a plan review, not a live site audit.`, + workingDirectory: reviewDir, + maxTurns: 10, + timeout: 180_000, + testName: 'plan-design-review-no-ui-scope', + runId, + }); + + logCost('/plan-design-review no-ui-scope', result); + + // Agent should detect no UI scope and exit early + const output = result.output || ''; + const detectsNoUI = output.toLowerCase().includes('no ui') || + output.toLowerCase().includes('no frontend') || + output.toLowerCase().includes('no design') || + output.toLowerCase().includes('not applicable') || + output.toLowerCase().includes('backend'); + + recordE2E('/plan-design-review no-ui-scope', 'Plan Design Review E2E', result, { + passed: detectsNoUI && ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + expect(detectsNoUI).toBe(true); + }, 240_000); +}); + +// --- Design Review E2E (live-site audit + fix) --- + +describeIfSelected('Design Review E2E', ['design-review-fix'], () => { + let qaDesignDir: string; + let qaDesignServer: ReturnType | null = null; + + beforeAll(() => { + qaDesignDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-design-')); + setupBrowseShims(qaDesignDir); + + const { spawnSync } = require('child_process'); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: qaDesignDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create HTML/CSS with intentional design issues + fs.writeFileSync(path.join(qaDesignDir, 'index.html'), ` + + + + + Design Test App + + + +
+

Welcome

+

Subtitle Here

+
+
+
+

Card Title

+

Some content here with tight line height.

+
+
+

Another Card

+

Different spacing and colors for no reason.

+
+ + +
+ +`); + + fs.writeFileSync(path.join(qaDesignDir, 'style.css'), `body { + font-family: Arial, sans-serif; + margin: 0; + padding: 20px; +} +.card { + border: 1px solid #ddd; + border-radius: 4px; +} +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial design test page']); + + // Start a simple file server for the design test page + qaDesignServer = Bun.serve({ + port: 0, + fetch(req) { + const url = new URL(req.url); + const filePath = path.join(qaDesignDir, url.pathname === '/' ? 'index.html' : url.pathname.slice(1)); + try { + const content = fs.readFileSync(filePath); + const ext = path.extname(filePath); + const contentType = ext === '.css' ? 'text/css' : ext === '.html' ? 'text/html' : 'text/plain'; + return new Response(content, { headers: { 'Content-Type': contentType } }); + } catch { + return new Response('Not Found', { status: 404 }); + } + }, + }); + + // Copy design-review skill + fs.mkdirSync(path.join(qaDesignDir, 'design-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'design-review', 'SKILL.md'), + path.join(qaDesignDir, 'design-review', 'SKILL.md'), + ); + }); + + afterAll(() => { + qaDesignServer?.stop(); + try { fs.rmSync(qaDesignDir, { recursive: true, force: true }); } catch {} + }); + + test('Test 7: /design-review audits and fixes design issues', async () => { + const serverUrl = `http://localhost:${(qaDesignServer as any)?.port}`; + + const result = await runSkillTest({ + prompt: `IMPORTANT: The browse binary is already assigned below as B. Do NOT search for it or run the SKILL.md setup block — just use $B directly. + +B="${browseBin}" + +Read design-review/SKILL.md for the design review + fix workflow. + +Review the site at ${serverUrl}. Use --quick mode. Skip any AskUserQuestion calls — this is non-interactive. Fix up to 3 issues max. Write your report to ./design-audit.md.`, + workingDirectory: qaDesignDir, + maxTurns: 30, + timeout: 360_000, + testName: 'design-review-fix', + runId, + }); + + logCost('/design-review fix', result); + + const reportPath = path.join(qaDesignDir, 'design-audit.md'); + const reportExists = fs.existsSync(reportPath); + + // Check if any design fix commits were made + const gitLog = spawnSync('git', ['log', '--oneline'], { + cwd: qaDesignDir, stdio: 'pipe', + }); + const commits = gitLog.stdout.toString().trim().split('\n'); + const designFixCommits = commits.filter((c: string) => c.includes('style(design)')); + + recordE2E('/design-review fix', 'Design Review E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + + // Accept error_max_turns — the fix loop is complex + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Report and commits are best-effort — log what happened + if (reportExists) { + const report = fs.readFileSync(reportPath, 'utf-8'); + console.log(`Design audit report: ${report.length} chars`); + } else { + console.warn('No design-audit.md generated'); + } + console.log(`Design fix commits: ${designFixCommits.length}`); + }, 420_000); +}); + +// --- Test Bootstrap E2E --- + +describeIfSelected('Test Bootstrap E2E', ['qa-bootstrap'], () => { + let bootstrapDir: string; + let bootstrapServer: ReturnType; + + beforeAll(() => { + bootstrapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-bootstrap-')); + setupBrowseShims(bootstrapDir); + + // Copy qa skill files + copyDirSync(path.join(ROOT, 'qa'), path.join(bootstrapDir, 'qa')); + + // Create a minimal Node.js project with NO test framework + fs.writeFileSync(path.join(bootstrapDir, 'package.json'), JSON.stringify({ + name: 'test-bootstrap-app', + version: '1.0.0', + type: 'module', + }, null, 2)); + + // Create a simple app file with a bug + fs.writeFileSync(path.join(bootstrapDir, 'app.js'), ` +export function add(a, b) { return a + b; } +export function subtract(a, b) { return a - b; } +export function divide(a, b) { return a / b; } // BUG: no zero check +`); + + // Create a simple HTML page with a bug + fs.writeFileSync(path.join(bootstrapDir, 'index.html'), ` + +Bootstrap Test + +

Test App

+ Broken Link + + + +`); + + // Init git repo + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: bootstrapDir, stdio: 'pipe', timeout: 5000 }); + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial commit']); + + // Serve from working directory + bootstrapServer = Bun.serve({ + port: 0, + hostname: '127.0.0.1', + fetch(req) { + const url = new URL(req.url); + let filePath = url.pathname === '/' ? '/index.html' : url.pathname; + filePath = filePath.replace(/^\//, ''); + const fullPath = path.join(bootstrapDir, filePath); + if (!fs.existsSync(fullPath)) { + return new Response('Not Found', { status: 404 }); + } + const content = fs.readFileSync(fullPath, 'utf-8'); + return new Response(content, { + headers: { 'Content-Type': 'text/html' }, + }); + }, + }); + }); + + afterAll(() => { + bootstrapServer?.stop(); + try { fs.rmSync(bootstrapDir, { recursive: true, force: true }); } catch {} + }); + + test('/qa bootstrap + regression test on zero-test project', async () => { + const serverUrl = `http://127.0.0.1:${bootstrapServer!.port}`; + + const result = await runSkillTest({ + prompt: `You have a browse binary at ${browseBin}. Assign it to B variable like: B="${browseBin}" + +Read the file qa/SKILL.md for the QA workflow instructions. + +Run a Quick-tier QA test on ${serverUrl} +The source code for this page is at ${bootstrapDir}/index.html — you can fix bugs there. +Do NOT use AskUserQuestion — for any AskUserQuestion prompts, choose the RECOMMENDED option automatically. +Write your report to ${bootstrapDir}/qa-reports/qa-report.md + +This project has NO test framework. When the bootstrap asks, pick vitest (option A). +This is a test+fix loop: find bugs, fix them, write regression tests, commit each fix.`, + workingDirectory: bootstrapDir, + maxTurns: 50, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 420_000, + testName: 'qa-bootstrap', + runId, + }); + + logCost('/qa bootstrap', result); + recordE2E('/qa bootstrap + regression test', 'Test Bootstrap E2E', result, { + passed: ['success', 'error_max_turns'].includes(result.exitReason), + }); + + expect(['success', 'error_max_turns']).toContain(result.exitReason); + + // Verify bootstrap created test infrastructure + const hasTestConfig = fs.existsSync(path.join(bootstrapDir, 'vitest.config.ts')) + || fs.existsSync(path.join(bootstrapDir, 'vitest.config.js')) + || fs.existsSync(path.join(bootstrapDir, 'jest.config.js')) + || fs.existsSync(path.join(bootstrapDir, 'jest.config.ts')); + console.log(`Test config created: ${hasTestConfig}`); + + const hasTestingMd = fs.existsSync(path.join(bootstrapDir, 'TESTING.md')); + console.log(`TESTING.md created: ${hasTestingMd}`); + + // Check for bootstrap commit + const gitLog = spawnSync('git', ['log', '--oneline', '--grep=bootstrap'], { + cwd: bootstrapDir, stdio: 'pipe', + }); + const bootstrapCommits = gitLog.stdout.toString().trim(); + console.log(`Bootstrap commits: ${bootstrapCommits || 'none'}`); + + // Check for regression test commits + const regressionLog = spawnSync('git', ['log', '--oneline', '--grep=test(qa)'], { + cwd: bootstrapDir, stdio: 'pipe', + }); + const regressionCommits = regressionLog.stdout.toString().trim(); + console.log(`Regression test commits: ${regressionCommits || 'none'}`); + + // Verify at least the bootstrap happened (fix commits are bonus) + const allCommits = spawnSync('git', ['log', '--oneline'], { + cwd: bootstrapDir, stdio: 'pipe', + }); + const totalCommits = allCommits.stdout.toString().trim().split('\n').length; + console.log(`Total commits: ${totalCommits}`); + expect(totalCommits).toBeGreaterThan(1); // At least initial + bootstrap + }, 420_000); +}); + +// --- Test Coverage Audit E2E --- + +describeIfSelected('Test Coverage Audit E2E', ['ship-coverage-audit'], () => { + let coverageDir: string; + + beforeAll(() => { + coverageDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-coverage-')); + + // Copy ship skill files + copyDirSync(path.join(ROOT, 'ship'), path.join(coverageDir, 'ship')); + copyDirSync(path.join(ROOT, 'review'), path.join(coverageDir, 'review')); + + // Use shared fixture for billing project with coverage gaps + const { createCoverageAuditFixture } = require('./fixtures/coverage-audit-fixture'); + createCoverageAuditFixture(coverageDir); + }); + + afterAll(() => { + try { fs.rmSync(coverageDir, { recursive: true, force: true }); } catch {} + }); + + test('/ship Step 3.4 produces coverage diagram', async () => { + const result = await runSkillTest({ + prompt: `Read the file ship/SKILL.md for the ship workflow instructions. + +You are on the feature/billing branch. The base branch is main. +This is a test project — there is no remote, no PR to create. + +ONLY run Step 3.4 (Test Coverage Audit) from the ship workflow. +Skip all other steps (tests, evals, review, version, changelog, commit, push, PR). + +The source code is in ${coverageDir}/src/billing.ts. +Existing tests are in ${coverageDir}/test/billing.test.ts. +The test command is: echo "tests pass" (mocked — just pretend tests pass). + +Produce the ASCII coverage diagram showing which code paths are tested and which have gaps. +Do NOT generate new tests — just produce the diagram and coverage summary. +Output the diagram directly.`, + workingDirectory: coverageDir, + maxTurns: 15, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 120_000, + testName: 'ship-coverage-audit', + runId, + }); + + logCost('/ship coverage audit', result); + recordE2E('/ship Step 3.4 coverage audit', 'Test Coverage Audit E2E', result, { + passed: result.exitReason === 'success', + }); + + expect(result.exitReason).toBe('success'); + + // Check output contains coverage diagram elements + const output = result.output || ''; + const outputLower = output.toLowerCase(); + const hasGap = outputLower.includes('gap') || outputLower.includes('no test'); + const hasTested = outputLower.includes('tested') || output.includes('✓') || output.includes('★'); + const hasCoverage = outputLower.includes('coverage') || outputLower.includes('paths tested'); + + console.log(`Output has GAP markers: ${hasGap}`); + console.log(`Output has TESTED markers: ${hasTested}`); + console.log(`Output has coverage summary: ${hasCoverage}`); + + // The agent MUST produce a coverage diagram with gap and tested markers + expect(hasGap || hasTested).toBe(true); + + // At minimum, the agent should have read the source and test files + const readCalls = result.toolCalls.filter(tc => tc.tool === 'Read'); + expect(readCalls.length).toBeGreaterThan(0); + }, 180_000); +}); + +// --- Review Coverage Audit E2E --- + +describeIfSelected('Review Coverage Audit E2E', ['review-coverage-audit'], () => { + let reviewCoverageDir: string; + + beforeAll(() => { + reviewCoverageDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-review-coverage-')); + + // Copy review skill files + copyDirSync(path.join(ROOT, 'review'), path.join(reviewCoverageDir, 'review')); + + // Use shared fixture for billing project with coverage gaps + const { createCoverageAuditFixture } = require('./fixtures/coverage-audit-fixture'); + createCoverageAuditFixture(reviewCoverageDir); + }); + + afterAll(() => { + try { fs.rmSync(reviewCoverageDir, { recursive: true, force: true }); } catch {} + }); + + test('/review Step 4.75 produces coverage diagram', async () => { + const result = await runSkillTest({ + prompt: `Read the file review/SKILL.md for the review workflow instructions. + +You are on the feature/billing branch. The base branch is main. +This is a test project — there is no remote, no PR to create. + +ONLY run Step 4.75 (Test Coverage Diagram) from the review workflow. +Skip all other steps (scope drift, checklist, design review, fix-first, etc.). + +The source code is in ${reviewCoverageDir}/src/billing.ts. +Existing tests are in ${reviewCoverageDir}/test/billing.test.ts. + +Produce the ASCII coverage diagram showing which code paths are tested and which have gaps. +Output the diagram directly.`, + workingDirectory: reviewCoverageDir, + maxTurns: 15, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 120_000, + testName: 'review-coverage-audit', + runId, + }); + + logCost('/review coverage audit', result); + recordE2E('/review Step 4.75 coverage audit', 'Review Coverage Audit E2E', result, { + passed: result.exitReason === 'success', + }); + + expect(result.exitReason).toBe('success'); + + // Check output contains coverage diagram elements + const output = result.output || ''; + const outputLower = output.toLowerCase(); + const hasGap = outputLower.includes('gap') || outputLower.includes('no test'); + const hasTested = outputLower.includes('tested') || output.includes('✓') || output.includes('★'); + const hasCoverage = outputLower.includes('coverage') || outputLower.includes('paths tested'); + + console.log(`Output has GAP markers: ${hasGap}`); + console.log(`Output has TESTED markers: ${hasTested}`); + console.log(`Output has coverage summary: ${hasCoverage}`); + + // The agent MUST produce a coverage diagram with gap and tested markers + expect(hasGap || hasTested).toBe(true); + + // At minimum, the agent should have read the source and test files + const readCalls = result.toolCalls.filter(tc => tc.tool === 'Read'); + expect(readCalls.length).toBeGreaterThan(0); + }, 180_000); +}); + +// --- Plan Eng Review Coverage Audit E2E --- + +describeIfSelected('Plan Eng Review Coverage Audit E2E', ['plan-eng-coverage-audit'], () => { + let planCoverageDir: string; + + beforeAll(() => { + planCoverageDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-plan-coverage-')); + + // Copy plan-eng-review skill files + copyDirSync(path.join(ROOT, 'plan-eng-review'), path.join(planCoverageDir, 'plan-eng-review')); + + // Use shared fixture for billing project with coverage gaps + const { createCoverageAuditFixture } = require('./fixtures/coverage-audit-fixture'); + createCoverageAuditFixture(planCoverageDir); + }); + + afterAll(() => { + try { fs.rmSync(planCoverageDir, { recursive: true, force: true }); } catch {} + }); + + test('/plan-eng-review coverage audit traces plan codepaths', async () => { + const result = await runSkillTest({ + prompt: `Read the file plan-eng-review/SKILL.md for the plan review workflow instructions. + +You are on the feature/billing branch. The base branch is main. +This is a test project — there is no remote, no PR to create. + +ONLY run the Test Coverage Audit section from the plan review workflow. +Skip all other steps (architecture, code quality, performance, etc.). + +The source code is in ${planCoverageDir}/src/billing.ts. +Existing tests are in ${planCoverageDir}/test/billing.test.ts. + +Produce the ASCII coverage diagram showing which code paths are tested and which have gaps. +Output the diagram directly.`, + workingDirectory: planCoverageDir, + maxTurns: 15, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 120_000, + testName: 'plan-eng-coverage-audit', + runId, + }); + + logCost('/plan-eng-review coverage audit', result); + recordE2E('/plan-eng-review coverage audit', 'Plan Eng Review Coverage Audit E2E', result, { + passed: result.exitReason === 'success', + }); + + expect(result.exitReason).toBe('success'); + + // Check output contains coverage diagram elements + const output = result.output || ''; + const outputLower = output.toLowerCase(); + const hasGap = outputLower.includes('gap') || outputLower.includes('no test'); + const hasTested = outputLower.includes('tested') || output.includes('✓') || output.includes('★'); + const hasCoverage = outputLower.includes('coverage') || outputLower.includes('paths tested'); + + console.log(`Output has GAP markers: ${hasGap}`); + console.log(`Output has TESTED markers: ${hasTested}`); + console.log(`Output has coverage summary: ${hasCoverage}`); + + // The agent MUST produce a coverage diagram with gap and tested markers + expect(hasGap || hasTested).toBe(true); + + // At minimum, the agent should have read the source and test files + const readCalls = result.toolCalls.filter(tc => tc.tool === 'Read'); + expect(readCalls.length).toBeGreaterThan(0); + }, 180_000); +}); + +// --- Triage E2E --- + +describeIfSelected('Test Failure Triage E2E', ['ship-triage'], () => { + let triageDir: string; + + beforeAll(() => { + triageDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-triage-')); + + // Copy ship skill files + copyDirSync(path.join(ROOT, 'ship'), path.join(triageDir, 'ship')); + + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: triageDir, stdio: 'pipe', timeout: 5000 }); + + // Init git repo + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Create a project with a pre-existing test failure on main + fs.writeFileSync(path.join(triageDir, 'package.json'), JSON.stringify({ + name: 'triage-test-app', + version: '1.0.0', + scripts: { test: 'node test/run.js' }, + }, null, 2)); + + fs.mkdirSync(path.join(triageDir, 'src'), { recursive: true }); + fs.mkdirSync(path.join(triageDir, 'test'), { recursive: true }); + + // Source with a bug that exists on main (pre-existing) + fs.writeFileSync(path.join(triageDir, 'src', 'math.js'), ` +module.exports = { + add: (a, b) => a + b, + divide: (a, b) => a / b, // BUG: no zero-division check (pre-existing) +}; +`); + + // Test file that catches the pre-existing bug + fs.writeFileSync(path.join(triageDir, 'test', 'math.test.js'), ` +const { add, divide } = require('../src/math'); + +// This test passes +if (add(2, 3) !== 5) { console.error('FAIL: add(2,3) should be 5'); process.exit(1); } +console.log('PASS: add'); + +// This test FAILS — pre-existing bug (divide by zero returns Infinity, not an error) +try { + const result = divide(10, 0); + if (result === Infinity) { console.error('FAIL: divide(10,0) should throw, got Infinity'); process.exit(1); } +} catch(e) { + console.log('PASS: divide zero check'); +} +`); + + // Test runner — each test in a subprocess so one failure doesn't kill the other + fs.writeFileSync(path.join(triageDir, 'test', 'run.js'), ` +const { execSync } = require('child_process'); +const path = require('path'); +let failures = 0; +for (const f of ['math.test.js', 'string.test.js']) { + try { + execSync('node ' + path.join(__dirname, f), { stdio: 'inherit' }); + } catch (e) { + failures++; + } +} +if (failures > 0) process.exit(1); +`); + + // Commit on main with the pre-existing bug + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial: math utils with tests']); + + // Create feature branch + run('git', ['checkout', '-b', 'feature/string-utils']); + + // Add new code with a new bug (in-branch) + fs.writeFileSync(path.join(triageDir, 'src', 'string.js'), ` +module.exports = { + capitalize: (s) => s.charAt(0).toUpperCase() + s.slice(1), + reverse: (s) => s.split('').reverse().join(''), + truncate: (s, len) => s.substring(0, len), // BUG: no null check (in-branch) +}; +`); + + // Add test that catches the in-branch bug + fs.writeFileSync(path.join(triageDir, 'test', 'string.test.js'), ` +const { capitalize, reverse, truncate } = require('../src/string'); + +if (capitalize('hello') !== 'Hello') { console.error('FAIL: capitalize'); process.exit(1); } +console.log('PASS: capitalize'); + +if (reverse('abc') !== 'cba') { console.error('FAIL: reverse'); process.exit(1); } +console.log('PASS: reverse'); + +// This test FAILS — in-branch bug (null input causes TypeError) +try { + truncate(null, 5); + console.log('PASS: truncate null'); +} catch(e) { + console.error('FAIL: truncate(null, 5) threw: ' + e.message); + process.exit(1); +} +`); + + run('git', ['add', '.']); + run('git', ['commit', '-m', 'feat: add string utilities']); + }); + + afterAll(() => { + try { fs.rmSync(triageDir, { recursive: true, force: true }); } catch {} + }); + + test('/ship triage correctly classifies in-branch vs pre-existing failures', async () => { + const result = await runSkillTest({ + prompt: `Read the file ship/SKILL.md for the ship workflow instructions. + +You are on the feature/string-utils branch. The base branch is main. +This is a test project — there is no remote, no PR to create. + +Run the tests first: +\`\`\`bash +cd ${triageDir} && node test/run.js +\`\`\` + +The tests will fail. Now run ONLY the Test Failure Ownership Triage (Steps T1-T4) from the ship workflow. + +For each failing test, classify it as: +- **In-branch**: caused by changes on this branch (feature/string-utils) +- **Pre-existing**: existed before this branch (present on main) + +Use git diff origin/main...HEAD (or git diff main...HEAD since there's no remote) to determine which files changed on this branch. + +Output your classification for each failure clearly, labeling each as "IN-BRANCH" or "PRE-EXISTING" with your reasoning. + +This is a solo repo (REPO_MODE=solo). For pre-existing failures, recommend fixing now.`, + workingDirectory: triageDir, + maxTurns: 20, + allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'], + timeout: 180_000, + testName: 'ship-triage', + runId, + }); + + logCost('/ship triage', result); + + const output = result.output || ''; + const outputLower = output.toLowerCase(); + + // The triage should identify the string/truncate failure as in-branch + const hasInBranch = outputLower.includes('in-branch') || outputLower.includes('in branch') || outputLower.includes('introduced'); + // The triage should identify the math/divide failure as pre-existing + const hasPreExisting = outputLower.includes('pre-existing') || outputLower.includes('pre existing') || outputLower.includes('existed before'); + + console.log(`Output identifies IN-BRANCH failures: ${hasInBranch}`); + console.log(`Output identifies PRE-EXISTING failures: ${hasPreExisting}`); + + // Check that the string/truncate bug is classified as in-branch + const mentionsTruncate = outputLower.includes('truncate') || outputLower.includes('string'); + const mentionsDivide = outputLower.includes('divide') || outputLower.includes('math'); + + console.log(`Mentions truncate/string (in-branch bug): ${mentionsTruncate}`); + console.log(`Mentions divide/math (pre-existing bug): ${mentionsDivide}`); + + // Verify BOTH failure classes are exercised (not just detected): + // The test runner must have actually run both test files + const ranMathTest = output.includes('math.test') || output.includes('FAIL: divide'); + const ranStringTest = output.includes('string.test') || output.includes('FAIL: truncate'); + console.log(`Ran math test file (pre-existing failure): ${ranMathTest}`); + console.log(`Ran string test file (in-branch failure): ${ranStringTest}`); + + recordE2E('/ship triage', 'Test Failure Triage E2E', result, { + passed: result.exitReason === 'success' && hasInBranch && hasPreExisting, + has_in_branch_classification: hasInBranch, + has_pre_existing_classification: hasPreExisting, + mentions_truncate: mentionsTruncate, + mentions_divide: mentionsDivide, + ran_both_test_files: ranMathTest && ranStringTest, + }); + + expect(result.exitReason).toBe('success'); + // Must classify at least one failure as in-branch AND one as pre-existing + expect(hasInBranch).toBe(true); + expect(hasPreExisting).toBe(true); + // Must mention the specific bugs + expect(mentionsTruncate).toBe(true); + expect(mentionsDivide).toBe(true); + // Must have actually run both test files (exercises both failure classes) + expect(ranMathTest).toBe(true); + expect(ranStringTest).toBe(true); + }, 240_000); +}); + +// --- Codex skill E2E --- + +describeIfSelected('Codex skill E2E', ['codex-review'], () => { + let codexDir: string; + + beforeAll(() => { + codexDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-codex-')); + + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: codexDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + + // Commit a clean base on main + fs.writeFileSync(path.join(codexDir, 'app.rb'), '# clean base\nclass App\nend\n'); + run('git', ['add', 'app.rb']); + run('git', ['commit', '-m', 'initial commit']); + + // Create feature branch with vulnerable code (reuse review fixture) + run('git', ['checkout', '-b', 'feature/add-vuln']); + const vulnContent = fs.readFileSync(path.join(ROOT, 'test', 'fixtures', 'review-eval-vuln.rb'), 'utf-8'); + fs.writeFileSync(path.join(codexDir, 'user_controller.rb'), vulnContent); + run('git', ['add', 'user_controller.rb']); + run('git', ['commit', '-m', 'add vulnerable controller']); + + // Copy the codex skill file + fs.copyFileSync(path.join(ROOT, 'codex', 'SKILL.md'), path.join(codexDir, 'codex-SKILL.md')); + }); + + afterAll(() => { + try { fs.rmSync(codexDir, { recursive: true, force: true }); } catch {} + }); + + test('/codex review produces findings and GATE verdict', async () => { + // Check codex is available — skip if not installed + const codexCheck = spawnSync('which', ['codex'], { stdio: 'pipe', timeout: 3000 }); + if (codexCheck.status !== 0) { + console.warn('codex CLI not installed — skipping E2E test'); + return; + } + + const result = await runSkillTest({ + prompt: `You are in a git repo on branch feature/add-vuln with changes against main. +Read codex-SKILL.md for the /codex skill instructions. +Run /codex review to review the current diff against main. +Write the full output (including the GATE verdict) to ${codexDir}/codex-output.md`, + workingDirectory: codexDir, + maxTurns: 10, + timeout: 300_000, + testName: 'codex-review', + runId, + }); + + logCost('/codex review', result); + recordE2E('/codex review', 'Codex skill E2E', result); + expect(result.exitReason).toBe('success'); + + // Check that output file was created with review content + const outputPath = path.join(codexDir, 'codex-output.md'); + if (fs.existsSync(outputPath)) { + const output = fs.readFileSync(outputPath, 'utf-8'); + // Should contain the CODEX SAYS header or GATE verdict + const hasCodexOutput = output.includes('CODEX') || output.includes('GATE') || output.includes('codex'); + expect(hasCodexOutput).toBe(true); + } + }, 360_000); +}); + +// --- Office Hours Spec Review E2E --- + +describeIfSelected('Office Hours Spec Review E2E', ['office-hours-spec-review'], () => { + let ohDir: string; + + beforeAll(() => { + ohDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-oh-spec-')); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: ohDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + fs.writeFileSync(path.join(ohDir, 'README.md'), '# Test Project\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'init']); + + // Copy office-hours skill + fs.mkdirSync(path.join(ohDir, 'office-hours'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'office-hours', 'SKILL.md'), + path.join(ohDir, 'office-hours', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(ohDir, { recursive: true, force: true }); } catch {} + }); + + test('/office-hours SKILL.md contains spec review loop', async () => { + const result = await runSkillTest({ + prompt: `Read office-hours/SKILL.md. I want to understand the spec review loop. + +Summarize what the "Spec Review Loop" section does — specifically: +1. How many dimensions does the reviewer check? +2. What tool is used to dispatch the reviewer? +3. What's the maximum number of iterations? +4. What metrics are tracked? + +Write your summary to ${ohDir}/spec-review-summary.md`, + workingDirectory: ohDir, + maxTurns: 8, + timeout: 120_000, + testName: 'office-hours-spec-review', + runId, + }); + + logCost('/office-hours spec review', result); + recordE2E('/office-hours-spec-review', 'Office Hours Spec Review E2E', result); + expect(result.exitReason).toBe('success'); + + const summaryPath = path.join(ohDir, 'spec-review-summary.md'); + if (fs.existsSync(summaryPath)) { + const summary = fs.readFileSync(summaryPath, 'utf-8').toLowerCase(); + // Verify the agent understood the key concepts + expect(summary).toMatch(/5.*dimension|dimension.*5|completeness|consistency|clarity|scope|feasibility/); + expect(summary).toMatch(/agent|subagent/); + expect(summary).toMatch(/3.*iteration|iteration.*3|maximum.*3/); + } + }, 180_000); +}); + +// --- Plan CEO Review Benefits-From E2E --- + +describeIfSelected('Plan CEO Review Benefits-From E2E', ['plan-ceo-review-benefits'], () => { + let benefitsDir: string; + + beforeAll(() => { + benefitsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-benefits-')); + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: benefitsDir, stdio: 'pipe', timeout: 5000 }); + + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + fs.writeFileSync(path.join(benefitsDir, 'README.md'), '# Test Project\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'init']); + + // Copy plan-ceo-review skill + fs.mkdirSync(path.join(benefitsDir, 'plan-ceo-review'), { recursive: true }); + fs.copyFileSync( + path.join(ROOT, 'plan-ceo-review', 'SKILL.md'), + path.join(benefitsDir, 'plan-ceo-review', 'SKILL.md'), + ); + }); + + afterAll(() => { + try { fs.rmSync(benefitsDir, { recursive: true, force: true }); } catch {} + }); + + test('/plan-ceo-review SKILL.md contains prerequisite skill offer', async () => { + const result = await runSkillTest({ + prompt: `Read plan-ceo-review/SKILL.md. Search for sections about "Prerequisite" or "office-hours" or "design doc found". + +Summarize what happens when no design doc is found — specifically: +1. Is /office-hours offered as a prerequisite? +2. What options does the user get? +3. Is there a mid-session detection for when the user seems lost? + +Write your summary to ${benefitsDir}/benefits-summary.md`, + workingDirectory: benefitsDir, + maxTurns: 8, + timeout: 120_000, + testName: 'plan-ceo-review-benefits', + runId, + }); + + logCost('/plan-ceo-review benefits-from', result); + recordE2E('/plan-ceo-review-benefits', 'Plan CEO Review Benefits-From E2E', result); + expect(result.exitReason).toBe('success'); + + const summaryPath = path.join(benefitsDir, 'benefits-summary.md'); + if (fs.existsSync(summaryPath)) { + const summary = fs.readFileSync(summaryPath, 'utf-8').toLowerCase(); + // Verify the agent understood the skill chaining + expect(summary).toMatch(/office.hours/); + expect(summary).toMatch(/design doc|no design/i); + } + }, 180_000); +}); + +// Module-level afterAll — finalize eval collector after all tests complete +afterAll(async () => { + if (evalCollector) { + try { + await evalCollector.finalize(); + } catch (err) { + console.error('Failed to save eval results:', err); + } + } +}); diff --git a/test/skill-validation.test.ts b/test/skill-validation.test.ts index a86270943e94101caff1b1b8d44b6787828c2d84..5bddb0dec267460a6e984f30e7feff91fe91e6ca 100644 --- a/test/skill-validation.test.ts +++ b/test/skill-validation.test.ts @@ -1319,10 +1319,12 @@ describe('Codex skill', () => { test('codex-host ship/review do NOT contain adversarial review step', () => { const shipContent = fs.readFileSync(path.join(ROOT, '.agents', 'skills', 'gstack-ship', 'SKILL.md'), 'utf-8'); expect(shipContent).not.toContain('codex review --base'); - expect(shipContent).not.toContain('Investigate and fix'); + expect(shipContent).not.toContain('CODEX_REVIEWS'); const reviewContent = fs.readFileSync(path.join(ROOT, '.agents', 'skills', 'gstack-review', 'SKILL.md'), 'utf-8'); expect(reviewContent).not.toContain('codex review --base'); + expect(reviewContent).not.toContain('codex_reviews'); + expect(reviewContent).not.toContain('CODEX_REVIEWS'); expect(reviewContent).not.toContain('adversarial-review'); expect(reviewContent).not.toContain('Investigate and fix'); }); @@ -1450,3 +1452,58 @@ describe('Codex skill validation', () => { } }); }); + +// --- Repo mode and test failure triage validation --- + +describe('Repo mode preamble validation', () => { + test('generated SKILL.md preamble contains REPO_MODE output', () => { + const content = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + expect(content).toContain('REPO_MODE:'); + expect(content).toContain('gstack-repo-mode'); + }); + + test('generated SKILL.md contains See Something Say Something section', () => { + const content = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); + expect(content).toContain('See Something, Say Something'); + expect(content).toContain('REPO_MODE'); + expect(content).toContain('solo'); + expect(content).toContain('collaborative'); + }); +}); + +describe('Test failure triage in ship skill', () => { + test('ship/SKILL.md contains Test Failure Ownership Triage', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).toContain('Test Failure Ownership Triage'); + }); + + test('ship/SKILL.md triage uses git diff for classification', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).toContain('git diff origin/...HEAD --name-only'); + }); + + test('ship/SKILL.md triage has solo and collaborative paths', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).toContain('REPO_MODE'); + expect(content).toContain('solo'); + expect(content).toContain('collaborative'); + expect(content).toContain('Investigate and fix now'); + expect(content).toContain('Add as P0 TODO'); + }); + + test('ship/SKILL.md triage has GitHub issue assignment for collaborative mode', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).toContain('gh issue create'); + expect(content).toContain('--assignee'); + }); + + test('{{TEST_FAILURE_TRIAGE}} placeholder is fully resolved in ship/SKILL.md', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).not.toContain('{{TEST_FAILURE_TRIAGE}}'); + }); + + test('ship/SKILL.md uses in-branch language for stop condition', () => { + const content = fs.readFileSync(path.join(ROOT, 'ship', 'SKILL.md'), 'utf-8'); + expect(content).toContain('In-branch test failures'); + }); +});