pan-wizard 3.30.0 → 3.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +30 -26
  2. package/agents/pan-design-checker.md +18 -0
  3. package/agents/pan-optimizer.md +5 -1
  4. package/agents/pan-plan-checker.md +23 -0
  5. package/agents/pan-reviewer.md +19 -0
  6. package/agents/pan-verifier.md +23 -0
  7. package/bin/install-lib.cjs +129 -33
  8. package/bin/install.js +16 -9
  9. package/commands/pan/army.md +4 -4
  10. package/commands/pan/design-phase.md +8 -0
  11. package/commands/pan/exec-phase.md +1 -1
  12. package/commands/pan/git.md +2 -2
  13. package/commands/pan/learn.md +2 -0
  14. package/commands/pan/optimize.md +14 -2
  15. package/commands/pan/review-deep.md +5 -5
  16. package/commands/pan/verify-phase.md +8 -9
  17. package/hooks/dist/pan-check-update.js +53 -2
  18. package/hooks/dist/pan-context-monitor.js +42 -1
  19. package/hooks/dist/pan-cost-logger.js +132 -11
  20. package/hooks/dist/pan-state-reinject.js +158 -0
  21. package/hooks/dist/pan-stop-guard.js +50 -4
  22. package/hooks/dist/pan-trace-logger.js +324 -18
  23. package/package.json +1 -1
  24. package/pan-wizard-core/bin/lib/commands.cjs +22 -5
  25. package/pan-wizard-core/bin/lib/config.cjs +2 -0
  26. package/pan-wizard-core/bin/lib/constants.cjs +31 -1
  27. package/pan-wizard-core/bin/lib/context-budget.cjs +27 -2
  28. package/pan-wizard-core/bin/lib/core.cjs +232 -23
  29. package/pan-wizard-core/bin/lib/cost-rebuild.cjs +11 -0
  30. package/pan-wizard-core/bin/lib/cost.cjs +135 -46
  31. package/pan-wizard-core/bin/lib/findings.cjs +381 -0
  32. package/pan-wizard-core/bin/lib/focus.cjs +72 -19
  33. package/pan-wizard-core/bin/lib/foreign-planning.cjs +24 -6
  34. package/pan-wizard-core/bin/lib/frontmatter.cjs +5 -2
  35. package/pan-wizard-core/bin/lib/hygiene.cjs +12 -2
  36. package/pan-wizard-core/bin/lib/init.cjs +4 -1
  37. package/pan-wizard-core/bin/lib/memory-optimize.cjs +12 -6
  38. package/pan-wizard-core/bin/lib/memory-rebuild.cjs +9 -2
  39. package/pan-wizard-core/bin/lib/optimize.cjs +349 -21
  40. package/pan-wizard-core/bin/lib/phase-report.cjs +4 -1
  41. package/pan-wizard-core/bin/lib/review-deep.cjs +36 -0
  42. package/pan-wizard-core/bin/lib/roadmap.cjs +87 -18
  43. package/pan-wizard-core/bin/lib/state.cjs +93 -24
  44. package/pan-wizard-core/bin/lib/suggest.cjs +21 -9
  45. package/pan-wizard-core/bin/lib/template.cjs +6 -3
  46. package/pan-wizard-core/bin/lib/verdict.cjs +431 -0
  47. package/pan-wizard-core/bin/lib/verify-deploy.cjs +19 -2
  48. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -2
  49. package/pan-wizard-core/bin/lib/verify-scope.cjs +156 -0
  50. package/pan-wizard-core/bin/lib/verify.cjs +25 -2
  51. package/pan-wizard-core/bin/pan-tools.cjs +69 -6
  52. package/pan-wizard-core/learnings/README.md +10 -7
  53. package/pan-wizard-core/mcp/tool-registry.cjs +16 -4
  54. package/pan-wizard-core/references/verdict-contract.md +101 -0
  55. package/pan-wizard-core/templates/verification-report.md +16 -0
  56. package/pan-wizard-core/workflows/exec-phase.md +73 -47
  57. package/pan-wizard-core/workflows/health.md +2 -0
  58. package/pan-wizard-core/workflows/help.md +2 -2
  59. package/pan-wizard-core/workflows/learn.md +4 -2
  60. package/pan-wizard-core/workflows/milestone-audit.md +15 -3
  61. package/pan-wizard-core/workflows/optimize.md +14 -1
  62. package/pan-wizard-core/workflows/phase-tests.md +1 -1
  63. package/pan-wizard-core/workflows/plan-phase.md +20 -15
  64. package/pan-wizard-core/workflows/progress.md +1 -1
  65. package/pan-wizard-core/workflows/todo-add.md +1 -1
  66. package/pan-wizard-core/workflows/todo-check.md +7 -6
  67. package/pan-wizard-core/workflows/verify-phase.md +3 -13
  68. package/pan-zcode/README.md +3 -3
  69. package/scripts/build-agent-plugin.js +4 -0
  70. package/scripts/build-hooks.js +2 -1
  71. package/scripts/build-plugin.js +10 -0
  72. package/scripts/git-hooks/pre-commit +2 -1
  73. package/scripts/npm-dist-tag.js +47 -0
  74. package/scripts/plugin-path.js +6 -1
  75. package/scripts/test-surface.cjs +1 -0
package/README.md CHANGED
@@ -103,18 +103,18 @@ PAN is the context engineering layer that makes Claude Code reliable. It breaks
103
103
  - **Isolated builders.** Each Build agent forks its own `army/<task>` branch + git worktree, so parallel agents never share a file.
104
104
  - **Caps.** Delegation-depth cap, per-cycle spawn + budget ceilings, and a `.planning/orchestration/abort` kill-switch, re-checked before every spawn by Mission Control's protocol (prompt-enforced; the MCP `pan_next_action` path enforces the cycle cap, the budget cap when `caps.enforceBudget` is set, an `aborted` flag the caller sets (it does not read the abort file) and the human gate in code — delegation depth is bounded by which agents hold the `Task` tool) — the same harness as hierarchical exec, at campaign scale.
105
105
 
106
- **Run it over days.** `--schedule` arms a resumable campaign with a per-day budget that burns the backlog down across sessions (the per-day budget is advisory — `campaign status` shows the day's spend — and an external scheduler triggers each `--continue`) — and *still* waits for you at every merge. **Autonomy runs up to the irreversible step; a human is at the step.**
106
+ **Run it over days.** `--schedule` arms a resumable campaign with a per-day budget that burns the backlog down across sessions (the per-day budget is advisory unless the schedule is armed with `--enforce-budget`, which pauses the day's run once spent — `campaign status` shows the day's spend — and an external scheduler triggers each `--continue`) — and *still* waits for you at every merge. **Autonomy runs up to the irreversible step; a human is at the step.**
107
107
 
108
- **Watch it live.** `/pan:hud` renders a single self-contained HTML dashboard — Mission Control over the squads, in-flight worktrees, campaign budget, telemetry, and the safety harness — in one page.
108
+ **See it.** `/pan:hud` renders a single self-contained HTML snapshot — Mission Control over the squads, in-flight worktrees, campaign budget, telemetry, and the safety harness — in one page. The page does not refresh itself; re-run the command for a fresh one.
109
109
 
110
110
  ```bash
111
111
  /pan:army "ship the v1 reporting module" # plan → delegate → build → review → human-gated ship
112
112
  /pan:army "harden auth across the app" --schedule daily --daily-budget 200
113
113
  /pan:army --status # where the campaign stands
114
- /pan:hud --open # watch the army work, live
114
+ /pan:hud --open # snapshot of the army's current state
115
115
  ```
116
116
 
117
- Resolve the live squad roster any time with `pan-tools squad list`.
117
+ Resolve the live squad roster any time with `pan-tools squad list` (`pan-tools` is shorthand; see [Operations](#operations) for how to run it).
118
118
 
119
119
  ---
120
120
 
@@ -142,7 +142,7 @@ Verify with:
142
142
 
143
143
  ### Staying Updated
144
144
 
145
- PAN evolves fast. Update periodically:
145
+ PAN evolves fast. On Claude Code, update periodically with `/pan:update`, which detects whether the install is local or global but passes no other flag, so it always updates Claude Code in its default location. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer yourself with the flags you installed with (add `--global` for a global install, since the installer defaults to the current project):
146
146
 
147
147
  ```bash
148
148
  npx pan-wizard@latest
@@ -163,8 +163,8 @@ npx pan-wizard --opencode --global # Install to ~/.config/opencode/
163
163
  npx pan-wizard --gemini --global # Install to ~/.gemini/
164
164
 
165
165
  # Codex (skills-first)
166
- npx pan-wizard --codex --global # Skills to ~/.agents/skills/, core and hooks to ~/.codex/
167
- npx pan-wizard --codex --local # Skills to ./.agents/skills/, core and hooks to ./.codex/
166
+ npx pan-wizard --codex --global # Skills to ~/.agents/skills/, core, agents and hooks to ~/.codex/
167
+ npx pan-wizard --codex --local # Skills to ./.agents/skills/, core, agents and hooks to ./.codex/
168
168
 
169
169
  # GitHub Copilot CLI (skills-first)
170
170
  npx pan-wizard --copilot --global # Install to ~/.copilot/
@@ -175,7 +175,7 @@ npx pan-wizard --all --global # Install to all directories
175
175
  ```
176
176
 
177
177
  Use `--global` (`-g`) to install into your home config directory; `--local` (`-l`) is the default and may be omitted.
178
- Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt.
178
+ Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt. A local install also writes outside the runtime directory: a marker-fenced PAN section in the project's `AGENTS.md`; for Claude Code, an `@AGENTS.md` import in `CLAUDE.md` and a `pan` MCP server in `.mcp.json`; and for Codex or `--unified-skills`, the shared `.agents/` tree (skills, plus a shared core under `--unified-skills`). `--uninstall` removes them (the `AGENTS.md` and `CLAUDE.md` blocks and the `.agents/` tree stay while another PAN runtime in the project still uses them).
179
179
  Add `--unified-skills` to install commands as one shared `.agents/skills/` tree instead of per-runtime formats. Codex, Gemini CLI, OpenCode, Copilot CLI and Antigravity CLI read that tree; Claude Code does not, so for Claude the installer also copies each skill into `.claude/skills/` and the commands become `/pan-<name>`. Gemini CLI gives skills no slash command, so on a unified Gemini install you ask for the task and `/skills list` shows what loaded. See the User Guide for details.
180
180
 
181
181
  > **Gemini CLI note:** from June 18, 2026, Google's Gemini CLI serves Gemini Code Assist (Standard/Enterprise) customers; individual free / AI Pro / Ultra accounts are directed to Antigravity CLI instead. PAN's `--gemini` target installs for Gemini CLI. Antigravity CLI is not yet a PAN install target, but it reads the shared `.agents/skills/` tree natively — install with `--unified-skills` and PAN's commands are usable from Antigravity in the same project.
@@ -190,8 +190,10 @@ directory. The installer hard-refuses to install into its own source repo (a
190
190
  `PAN_SOURCE_ROOT` guard exits with an error), so point it at a different target:
191
191
 
192
192
  ```bash
193
- # 1. Get the source
193
+ # 1. Get the source and build the hooks (hooks/dist/ is build output a clone lacks;
194
+ # the installer copies the hooks from there)
194
195
  git clone https://github.com/oharms/PanWizard.git
196
+ cd PanWizard && npm run build:hooks
195
197
 
196
198
  # 2. Install into a DIFFERENT project directory (never the PanWizard source dir)
197
199
  cd /path/to/some-test-project
@@ -346,7 +348,7 @@ The system:
346
348
 
347
349
  Each plan is small enough to execute in a fresh context window. No degradation, no "I'll be more concise now."
348
350
 
349
- **Creates:** `{phase_num}-research.md`, `{phase_num}-{N}-plan.md`
351
+ **Creates:** `{phase_num}-research.md`, `{phase_num}-{N}-plan.md`, `{phase_num}-plan-check.md` (the checker's report, when the checker runs)
350
352
 
351
353
  ---
352
354
 
@@ -397,7 +399,7 @@ Plans are grouped into "waves" based on dependencies. Within each wave, plans ru
397
399
 
398
400
  This is why "vertical slices" (Plan 01: User feature end-to-end) parallelize better than "horizontal layers" (Plan 01: All models, Plan 02: All APIs).
399
401
 
400
- **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-verification.md`
402
+ **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-review.md` (unless `--skip-review` or `--fast`), `{phase_num}-verification.md`
401
403
 
402
404
  ---
403
405
 
@@ -481,7 +483,7 @@ PAN handles it for you:
481
483
 
482
484
  | File | What it does |
483
485
  |------|--------------|
484
- | `project.md` | Project vision, always loaded |
486
+ | `project.md` | Project vision, read when PAN plans, researches or resumes work |
485
487
  | `research/` | Ecosystem knowledge (stack, features, architecture, pitfalls) |
486
488
  | `requirements.md` | Scoped v1/v2 requirements with phase traceability |
487
489
  | `roadmap.md` | Where you're going, what's done |
@@ -522,7 +524,7 @@ Every stage uses the same pattern: a thin orchestrator spawns specialized agents
522
524
  | Research | Coordinates, presents findings | Parallel researchers investigate stack, features, architecture and pitfalls |
523
525
  | Planning | Validates, manages iteration | Planner creates plans, checker verifies, up to three passes |
524
526
  | Execution | Groups into waves, tracks progress | Executors implement in parallel, each in a fresh context (native sub-agents on Claude Code, each runtime's own delegation elsewhere) |
525
- | Verification | Presents results, routes next | Verifier checks codebase against goals, debuggers diagnose failures |
527
+ | Verification | Presents results, routes next | Verifier checks codebase against goals; on Claude Code, `/pan-diagnose-issues` sends one debugger per failed UAT truth |
526
528
 
527
529
  The orchestrator never does heavy lifting. It spawns agents, waits, integrates results.
528
530
 
@@ -613,7 +615,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
613
615
  |---------|--------------|
614
616
  | `/pan:progress` | Where am I? What's next? |
615
617
  | `/pan:hud` (alias `/pan:dashboard`) | Render a self-contained HTML dashboard of project + bot-army state to `.planning/hud.html` (`--open`, `--out`, `--stdout`) |
616
- | `/pan:report phase <N> \| index \| all` | Self-contained HTML report for one phase, or a timeline index linking every phase report (`--out`, `--open`, `--stdout`; `--bundle` on `index` inlines every phase report into one file) |
618
+ | `/pan:report phase <N> \| index \| all` | Self-contained HTML report for one phase, or a timeline index linking every phase report (`--out`, `--open`, `--stdout` on `phase` and `index`; `--bundle` on `index` inlines every phase report into one file; `all` regenerates every phase report plus the index and takes only `--open`) |
617
619
  | `/pan:help` | Show all commands and usage guide |
618
620
  | `/pan:update` | Update PAN with changelog preview |
619
621
  | `/pan:discord` | Join the PAN Discord community |
@@ -657,7 +659,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
657
659
  | `/pan:todo-check` | List pending todos |
658
660
  | `/pan:debug [desc]` | Systematic debugging with persistent state |
659
661
  | `/pan:quick [--full]` | Execute ad-hoc task with PAN guarantees (`--full` adds plan-checking and verification) |
660
- | `/pan:health [--repair]` | Validate `.planning/` directory integrity; `--repair` auto-fixes detected issues |
662
+ | `/pan:health [--repair]` | Validate `.planning/` directory integrity; `--repair` fixes the issues it marks repairable |
661
663
  | `/pan:hygiene [--apply] [--trace-age-days N] [--all-tracks]` | Scan for PAN version drift and stale project artifacts (legacy filenames, .tmp orphans, memory bloat, poisoned cost ledgers, trace and report debris, cached-context bloat, fragment planning dirs); `--apply` executes the safe fixes — poisoned ledgers are quarantined by rename (only the newest quarantine copy is kept), and settled `state.md` history is archived rather than dropped |
662
664
  | `/pan:links [--strict]` | Validate the doc-code link graph: inline `[[<id>]]` refs, `// @pan:` source anchors, `require-code-mention` contracts (ADR-0027) |
663
665
  | `/pan:phase-tests <N> [instructions]` | Generate tests for a completed phase based on UAT criteria |
@@ -670,6 +672,8 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
670
672
 
671
673
  ### Operations
672
674
 
675
+ `pan-tools` is shorthand for `node .claude/pan-wizard-core/bin/pan-tools.cjs`; the installer adds no `pan-tools` command to your PATH. Use your runtime's directory in place of `.claude` (`.codex`, `.gemini`, `.opencode`, `.github`), or its global config directory after a `--global` install.
676
+
673
677
  | Command | What it does |
674
678
  |---------|--------------|
675
679
  | `pan-tools preflight [target]` | Pre-flight validation: state, blockers, git clean, config, error patterns |
@@ -687,7 +691,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
687
691
  | `/pan:focus-plan` | Create capacity-budgeted execution batch (modes: bugfix, balanced, features, full) |
688
692
  | `/pan:focus-exec` | Execute items from batch with tier-based test cadence |
689
693
  | `/pan:focus-auto` | Continuous scan→plan→exec loop with purpose-driven categories and a layered safety harness |
690
- | `/pan:focus-sync` | Detect and report stale documentation counts |
694
+ | `/pan:focus-sync` | Detect stale documentation (counts, missing commands, outdated references); `--all` also fixes it |
691
695
  | `/pan:focus-design` | Multi-phase strategic feature investigation pipeline |
692
696
  | `/pan:focus-drift-walking` | Walk project tree, detect doc-code drift, score severity, auto-repair |
693
697
  | `/pan:focus-doc-audit` | Multi-dimensional document audit with a quality score per dimension |
@@ -697,7 +701,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
697
701
  | Command | What it does |
698
702
  |---------|--------------|
699
703
  | `/pan:cost` | Token usage + estimated cost across PAN invocations (json/table/chart) |
700
- | `/pan:preview <phase\|phases\|milestone>` | Read-only foresight: blast radius, dependency graph, milestone ETA |
704
+ | `/pan:preview phase <N>\|phases\|milestone` | Read-only foresight: blast radius, dependency graph, milestone ETA |
701
705
  | `/pan:review-deep <phase>` | Security audit (OWASP + STRIDE) + cross-check by meta-reviewer |
702
706
  | `/pan:knowledge {ask\|discuss\|playbook}` | Grounded Q&A, multi-turn discussion, or aggregate memory into playbook |
703
707
  | `/pan:what-if <phase> "scenario"` | Counterfactual phase replay in isolated git worktree |
@@ -708,7 +712,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
708
712
  | Command | What it does |
709
713
  |---------|--------------|
710
714
  | `/pan:learn` | Analyze trace events, generate optimization report with auto-apply block |
711
- | `/pan:optimize {apply\|list\|stats\|trace}` | Apply optimizer recommendations, list reports, view stats, manage trace sessions |
715
+ | `/pan:optimize {apply\|revert\|list\|stats\|trace}` | Apply optimizer recommendations, undo one apply (`revert <apply_id>` or `revert --last`), list reports, view stats, manage trace sessions |
712
716
  | `/pan:git <subcommand>` | Phase-aware git workflow: commit/branch/push/status/log/stash/diff/rollback/tag/sync |
713
717
  | `/pan:audit-deployment <target-directory> [--enhancements] [--repair]` | Audit a PAN installation for integrity, project health, and draft enhancement specs |
714
718
 
@@ -725,7 +729,7 @@ PAN stores project settings in `.planning/config.json`. Configure during `/pan:n
725
729
  | Setting | Options | Default | What it controls |
726
730
  |---------|---------|---------|------------------|
727
731
  | `mode` | `yolo`, `interactive` | chosen at `/pan:new-project` (`yolo` is the recommended answer; `--auto` always sets it) | Auto-approve vs confirm at each step |
728
- | `depth` | `quick`, `standard`, `comprehensive` | chosen at `/pan:new-project` (usually `standard`) | Planning thoroughness (phases × plans) |
732
+ | `depth` | `quick`, `standard`, `comprehensive` | chosen at `/pan:new-project` (`--auto` uses `quick` unless the idea document's frontmatter sets `planning_depth`) | Planning thoroughness (phases × plans) |
729
733
 
730
734
  ### Model Profiles
731
735
 
@@ -737,7 +741,7 @@ Control which Claude model each agent uses. Balance quality vs token spend.
737
741
  | `balanced` (default) | reasoning | reasoning | reasoning |
738
742
  | `budget` | Sonnet | Sonnet | Haiku |
739
743
 
740
- > `reasoning` = the session model (inherit) — every agent runs on the model you launched the session with, except the reviewer-class agents (reviewer, hardener, meta-reviewer), which pin a reasoning-tier model on Claude Code. The other runtimes' agent files drop the pin, so there those agents inherit the session model too. Both `quality` and `balanced` resolve this way; only `budget` steps down — to a Sonnet/Haiku mix on Claude Code, and to the provider's own mid and fast models where PAN detects OpenAI (Codex, OpenCode) or Google (Gemini CLI); `pan-tools resolve-model <agent>` prints the id. Actual assignment varies by agent role — see [User Guide](docs/USER-GUIDE.md#model-profiles-per-agent-breakdown) for the full per-agent breakdown.
744
+ > `reasoning` = the session model (inherit) — every agent runs on the model you launched the session with, except the reviewer-class agents (reviewer, hardener, meta-reviewer), which pin a reasoning-tier model on Claude Code. The other runtimes' agent files drop the pin, so there those agents inherit the session model too. Both `quality` and `balanced` resolve this way; only `budget` steps down — to a Sonnet/Haiku mix on Claude Code, and to the provider's own mid and fast models where PAN detects OpenAI (Codex) or Google (Gemini CLI) — under OpenCode, as `provider/model` ids for the provider of OpenCode's configured `model`, or, when that names none PAN routes for, the provider the runtime directories suggest (`.opencode/` alone counts as OpenAI); `pan-tools resolve-model <agent>` prints the id. Actual assignment varies by agent role — see [User Guide](docs/USER-GUIDE.md#model-profiles-per-agent-breakdown) for the full per-agent breakdown.
741
745
 
742
746
  Switch profiles:
743
747
  ```text
@@ -766,7 +770,7 @@ Use `/pan:settings` to toggle these, or override per-invocation:
766
770
 
767
771
  | Setting | Default | What it controls |
768
772
  |---------|---------|------------------|
769
- | `parallelization.enabled` | `true` | Run independent plans simultaneously |
773
+ | `parallelization` | `true` | Run independent plans simultaneously |
770
774
  | `commit_docs` | `true` | Track `.planning/` in git |
771
775
 
772
776
  ### Git Branching
@@ -781,7 +785,7 @@ Control how PAN handles branches during execution.
781
785
 
782
786
  **Strategies:**
783
787
  - **`none`** — Commits to current branch (default PAN behavior)
784
- - **`phase`** — Creates a branch per phase; you merge it yourself (PAN never merges)
788
+ - **`phase`** — Creates a branch per phase; you merge it yourself (the phase workflows never merge it)
785
789
  - **`milestone`** — Creates one branch for the entire milestone; you merge it yourself
786
790
 
787
791
  At milestone completion you merge the milestone branch yourself (`git merge --squash` or `--no-ff`); `/pan:milestone-done <version>` archives and tags but does not merge.
@@ -829,20 +833,20 @@ This prevents Claude from reading these files entirely, regardless of what comma
829
833
 
830
834
  **Commands not working as expected?**
831
835
  - Run `/pan:help` (`/pan-help` on OpenCode, Copilot CLI and unified Claude installs; `$pan-help` on Codex) to verify installation
832
- - Re-run `npx pan-wizard` to reinstall
836
+ - Re-run `npx pan-wizard` with the flags you installed with (the runtime, `--global`/`--local`, and any `--config-dir` or `--unified-skills`) to reinstall
833
837
 
834
- **Updating to the latest version?**
838
+ **Updating to the latest version?** On Claude Code, run `/pan:update`. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer with the flags you installed with (`--global` for a global install):
835
839
  ```bash
836
840
  npx pan-wizard@latest
837
841
  ```
838
842
 
839
843
  **Using Docker or containerized environments?**
840
844
 
841
- If file reads fail with tilde paths (`~/.claude/...`), set `CLAUDE_CONFIG_DIR` before installing:
845
+ If Claude Code in the container reads its config from somewhere other than the installing user's `~/.claude`, set `CLAUDE_CONFIG_DIR` to that directory before installing (`--global --config-dir <path>` does the same):
842
846
  ```bash
843
847
  CLAUDE_CONFIG_DIR=/home/youruser/.claude npx pan-wizard --global
844
848
  ```
845
- This ensures absolute paths are used instead of `~` which may not expand correctly in containers.
849
+ PAN then installs into that directory and writes its absolute path into the installed commands, agents and hook commands. A global install writes absolute paths whether or not the variable is set.
846
850
 
847
851
  ### Uninstalling
848
852
 
@@ -80,4 +80,22 @@ asserting a gap that forces unnecessary rework.
80
80
  check → revise → check → final) — the same guardrail `plan-phase` uses with
81
81
  `pan-plan-checker`. On the final iteration, report remaining gaps as caveats
82
82
  rather than blocking indefinitely.
83
+
84
+ **Machine verdict (required).** End the verdict with a `pan-verdict` block. The
85
+ contract is in `~/.claude/pan-wizard-core/references/verdict-contract.md`. How to fill it:
86
+ - `verdict` is `PASS` or `GAPS`, and `outcome` is `pass` or `fail`.
87
+ - Add one finding per gap, in your ranked order.
88
+ - The class follows the dimension: requirement coverage → `missing`, architecture
89
+ conformance → `contradicts`, threat coverage → `risk`, scope discipline →
90
+ `unrequested`, every other dimension → `partial`.
91
+ - Each gap is `high`. A gap you report as a caveat on the final iteration is `medium`.
92
+ - `where` is the design section.
93
+
94
+ The orchestrator records the block, so it must say what your verdict says.
95
+
96
+ ````markdown
97
+ ```pan-verdict
98
+ {"contract":"1.0","agent":"pan-design-checker","phase":"{phase}","verdict":"GAPS","outcome":"fail","findings":[{"class":"missing","severity":"high","where":"{phase}-design.md#requirements","summary":"REQ-12 (export to CSV) maps to no design element"}]}
99
+ ```
100
+ ````
83
101
  </output_contract>
@@ -32,14 +32,18 @@ Read all inputs before producing the report.
32
32
  ### Step 1: Load the analysis JSON
33
33
 
34
34
  Read the `-analysis.json` file. It contains:
35
- - `summary` — total event counts by type
35
+ - `summary` — total event counts by type, plus `tool_errors`, `spawns_with_tool_errors` / `spawns_measured`, `verdict_failures`, `verdict_retries`
36
36
  - `error_patterns` — recurring error categories (sorted by frequency)
37
+ - `tool_error_patterns` — failed tool calls captured from the subagents' own transcripts, grouped by agent, tool, class (`exit_code`, `not_found`, `permission_denied`, …) and message. Each carries `occurrences`, `spawns` and `sessions`, ranked by `spawns`
38
+ - `verdict_stats` — per judge (verifier, plan checker, reviewer, design checker): `pass`, `fail`, `needs_human`, `retries`, `resolved_by_retry`. The findings behind them are in `.planning/findings.jsonl` (`pan-tools findings list`)
37
39
  - `gap_patterns` — knowledge gaps the model had to infer
38
40
  - `memory_miss_patterns` — topics missing from memory
39
41
  - `agent_stats` — per-agent error rates
40
42
  - `critical_events` / `major_events` — highest-impact events
41
43
  - `raw_events` — the full event stream
42
44
 
45
+ **Recurrence before memory.** A tool failure in one spawn is not a lesson: a test run expected to fail (a TDD red step) or a grep with no match exits non-zero on purpose. Write a memory entry only from a `tool_error_patterns` row with `spawns` of 2 or more, and prefer the ones that span `sessions`. The analysis may pool several sessions (`pooled_sessions`, from `pan-tools optimize learn --sessions <n>`); that window is where recurrence shows. A `permission_denied` pattern is an environment finding (the host's permission rules), not an agent's mistake: suggest a note, never a memory entry.
46
+
43
47
  ### Step 2: Read raw trace events
44
48
 
45
49
  Scan `trace.jsonl` for events. Look for:
@@ -756,6 +756,13 @@ Return all issues as a structured `issues:` YAML list (see dimension examples fo
756
756
 
757
757
  <structured_returns>
758
758
 
759
+ **Every return ends with a `pan-verdict` block.** The contract is in `~/.claude/pan-wizard-core/references/verdict-contract.md`. How to fill it:
760
+ - `verdict` is `passed` or `issues_found` (the status from Step 10), and `outcome` is `pass` or `fail`.
761
+ - Add one finding per issue you list. Blocker → `high`, warning → `medium`, info → `info`. The class follows the dimension, as mapped in the reference.
762
+ - `where` is the plan file, plus `#task-N` when the issue is about one task.
763
+
764
+ The orchestrator records the block, and the record is what it branches on. The block must say the same thing as your heading.
765
+
759
766
  ## VERIFICATION PASSED
760
767
 
761
768
  ```markdown
@@ -782,6 +789,14 @@ Return all issues as a structured `issues:` YAML list (see dimension examples fo
782
789
  Plans verified. Run `/pan:exec-phase {phase}` to proceed.
783
790
  ```
784
791
 
792
+ End it with:
793
+
794
+ ````markdown
795
+ ```pan-verdict
796
+ {"contract":"1.0","agent":"pan-plan-checker","phase":"{phase}","verdict":"passed","outcome":"pass","findings":[]}
797
+ ```
798
+ ````
799
+
785
800
  ## ISSUES FOUND
786
801
 
787
802
  ```markdown
@@ -813,6 +828,14 @@ Plans verified. Run `/pan:exec-phase {phase}` to proceed.
813
828
  {N} blocker(s) require revision. Returning to planner with feedback.
814
829
  ```
815
830
 
831
+ End it with one finding per listed issue:
832
+
833
+ ````markdown
834
+ ```pan-verdict
835
+ {"contract":"1.0","agent":"pan-plan-checker","phase":"{phase}","verdict":"issues_found","outcome":"fail","findings":[{"class":"missing","severity":"high","where":"{phase}-01-plan.md","summary":"requirement AUTH-02 (password reset) has no covering task"},{"class":"risk","severity":"medium","where":"{phase}-02-plan.md","summary":"plan 02 modifies 12 files across 5 tasks; split it"}]}
836
+ ```
837
+ ````
838
+
816
839
  </structured_returns>
817
840
 
818
841
  <anti_patterns>
@@ -69,6 +69,10 @@ If a changed file path starts with any of these prefixes, **skip it silently**.
69
69
  | Duplicate code | > 10 identical lines across files | INFO |
70
70
  | TODO/FIXME/HACK | New instances added in this phase | INFO |
71
71
 
72
+ ## Scope (unrequested work)
73
+
74
+ Compare what the changed code does with what the phase's plans asked for (their tasks and `must_haves`). Code that adds behaviour no plan task or requirement mentions is a finding: a feature nobody asked for, an unrelated refactor folded into the change, or an option no requirement needs. Use category `Unrequested` at WARNING, or at ERROR when it changes existing behaviour without a plan saying so. Its class in the `pan-verdict` block is `unrequested`. Supporting code the tasks need (tests, types, wiring) is not a finding.
75
+
72
76
  </review_checks>
73
77
 
74
78
  <output_format>
@@ -106,6 +110,21 @@ Return a structured review report:
106
110
  - **PASS**: Zero errors, zero warnings
107
111
  - **PASS_WITH_WARNINGS**: Zero errors, warnings present
108
112
  - **NEEDS_FIXES**: Any errors present
113
+
114
+ **Machine verdict (required).** End the report with a `pan-verdict` block. The contract is in `~/.claude/pan-wizard-core/references/verdict-contract.md`. How to fill it:
115
+ - `verdict` is the word under `### Verdict`; `outcome` is `fail` for NEEDS_FIXES and `pass` otherwise.
116
+ - Add one finding per table row. ERROR → `high`, WARNING → `medium`, INFO → `info`.
117
+ - Category maps to class: Convention → `quality`, Security → `risk`, Code Quality → `defect`, Unrequested → `unrequested`.
118
+ - `where` is `file:line`.
119
+ - A clean review has `"findings": []`.
120
+
121
+ The orchestrator records this block. It is how your findings reach the phase's findings ledger and `/pan:review-deep`.
122
+
123
+ ````markdown
124
+ ```pan-verdict
125
+ {"contract":"1.0","agent":"pan-reviewer","phase":"{phase_number}","verdict":"NEEDS_FIXES","outcome":"fail","findings":[{"class":"quality","severity":"high","where":"src/utils/parser.ts:42","summary":"Inconsistent naming — uses snake_case, project uses camelCase"}]}
126
+ ```
127
+ ````
109
128
  </output_format>
110
129
 
111
130
  <constraints>
@@ -450,6 +450,21 @@ Include in verification report under a "### Standards Compliance" section:
450
450
 
451
451
  This is advisory only — standards gaps do NOT block verification status. They appear as warnings/info in the report.
452
452
 
453
+ ## Step 7c: Check Scope — Unrequested Work
454
+
455
+ Find what the phase changed that no plan asked for. The file list is mechanical; the judgement is yours:
456
+
457
+ ```bash
458
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify scope "$PHASE_NUM"
459
+ ```
460
+
461
+ `candidates` are files the phase changed that no plan declared in `files_modified`. The changes come from the phase's plan commits and its summaries' key-files; the planning tree, lockfiles and PAN's own directories are already excluded. Judge each candidate:
462
+
463
+ - **Supporting work** the declared tasks need is not a finding. That includes a test for a declared file (`hint: test_for_declared`), a fixture, a config entry the feature requires, and a type the declared code imports.
464
+ - **Work the plans' intent does not cover** goes in the frontmatter as an `unrequested:` entry: `path` and `what` (what it adds that nobody asked for). Examples are a feature nobody asked for, an unrelated refactor, or a file outside the phase's purpose. Behaviour counts too: a declared file that also does something no requirement asked for is unrequested work in that file.
465
+
466
+ Unrequested work never changes the status on its own; a phase can pass with it. Keeping it (a decision) or removing it is the user's call, and the recorded finding is how the call gets made.
467
+
453
468
  ## Step 8: Identify Human Verification Needs
454
469
 
455
470
  **Always needs human:** Visual appearance, user flow completion, real-time behavior, external service integration, performance feel, error message clarity.
@@ -536,6 +551,9 @@ human_verification: # Only if status: human_needed
536
551
  - test: "What to do"
537
552
  expected: "What should happen"
538
553
  why_human: "Why can't verify programmatically"
554
+ unrequested: # Only if Step 7c found work no plan asked for
555
+ - path: "src/path/to/file.tsx"
556
+ what: "What it adds that no plan or requirement asked for"
539
557
  ---
540
558
 
541
559
  # Phase {X}: {Name} Verification Report
@@ -581,6 +599,10 @@ human_verification: # Only if status: human_needed
581
599
 
582
600
  {Items needing human testing — detailed format for user}
583
601
 
602
+ ### Unrequested Work
603
+
604
+ {Files or behaviour no plan asked for (Step 7c), each with what it adds — or "None: every change traces to a plan."}
605
+
584
606
  ### Gaps Summary
585
607
 
586
608
  {Narrative summary of what's missing and why}
@@ -706,6 +728,7 @@ return <div>No messages</div> // Always shows "no messages"
706
728
  - [ ] Requirements coverage assessed (if applicable)
707
729
  - [ ] Anti-patterns scanned and categorized
708
730
  - [ ] Human verification items identified
731
+ - [ ] Scope checked with `verify scope`; unrequested work recorded in `unrequested:`
709
732
  - [ ] Overall status determined
710
733
  - [ ] Gaps structured in YAML frontmatter (if gaps_found)
711
734
  - [ ] Re-verification metadata included (if previous existed)