pan-wizard 3.32.0 → 3.34.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 (209) hide show
  1. package/README.md +23 -20
  2. package/agents/pan-conductor.md +18 -17
  3. package/agents/pan-counterfactual.md +2 -2
  4. package/agents/pan-debugger.md +27 -8
  5. package/agents/pan-design-checker.md +1 -1
  6. package/agents/pan-designer.md +2 -2
  7. package/agents/pan-distiller.md +3 -3
  8. package/agents/pan-document_code.md +16 -16
  9. package/agents/pan-executor.md +15 -11
  10. package/agents/pan-experiment-runner.md +15 -17
  11. package/agents/pan-hardener.md +15 -15
  12. package/agents/pan-integration-checker.md +2 -2
  13. package/agents/pan-knowledge.md +2 -2
  14. package/agents/pan-meta-reviewer.md +5 -5
  15. package/agents/pan-optimizer.md +40 -44
  16. package/agents/pan-phase-researcher.md +10 -10
  17. package/agents/pan-plan-checker.md +36 -30
  18. package/agents/pan-planner.md +77 -53
  19. package/agents/pan-previewer.md +1 -1
  20. package/agents/pan-project-researcher.md +21 -78
  21. package/agents/pan-release.md +1 -1
  22. package/agents/pan-research-synthesizer.md +2 -2
  23. package/agents/pan-reviewer.md +24 -2
  24. package/agents/pan-roadmapper.md +20 -62
  25. package/agents/pan-verifier.md +53 -30
  26. package/bin/install-lib.cjs +228 -38
  27. package/bin/install.js +86 -15
  28. package/commands/pan/army.md +16 -12
  29. package/commands/pan/assumptions.md +2 -2
  30. package/commands/pan/audit-deployment.md +11 -12
  31. package/commands/pan/cost.md +8 -4
  32. package/commands/pan/debug.md +10 -7
  33. package/commands/pan/design-phase.md +3 -3
  34. package/commands/pan/discuss-phase.md +2 -0
  35. package/commands/pan/exec-phase.md +21 -37
  36. package/commands/pan/experiment.md +11 -10
  37. package/commands/pan/focus-auto.md +33 -27
  38. package/commands/pan/focus-design.md +9 -6
  39. package/commands/pan/focus-doc-audit.md +4 -3
  40. package/commands/pan/focus-drift-walking.md +4 -3
  41. package/commands/pan/focus-exec.md +7 -7
  42. package/commands/pan/focus-plan.md +12 -11
  43. package/commands/pan/focus-scan.md +7 -10
  44. package/commands/pan/focus-sync.md +3 -2
  45. package/commands/pan/git.md +8 -8
  46. package/commands/pan/health.md +2 -2
  47. package/commands/pan/hud.md +3 -2
  48. package/commands/pan/hygiene.md +14 -7
  49. package/commands/pan/knowledge.md +9 -9
  50. package/commands/pan/learn.md +10 -7
  51. package/commands/pan/links.md +4 -1
  52. package/commands/pan/map-codebase.md +5 -5
  53. package/commands/pan/mcp-bridge.md +18 -18
  54. package/commands/pan/milestone-done.md +7 -5
  55. package/commands/pan/milestone-new.md +1 -1
  56. package/commands/pan/new-project.md +10 -10
  57. package/commands/pan/optimize.md +16 -14
  58. package/commands/pan/patches.md +2 -6
  59. package/commands/pan/pause.md +1 -1
  60. package/commands/pan/phase-tests.md +4 -3
  61. package/commands/pan/plan-phase.md +9 -19
  62. package/commands/pan/preview.md +1 -1
  63. package/commands/pan/profile.md +4 -4
  64. package/commands/pan/quick.md +1 -1
  65. package/commands/pan/remove-phase.md +1 -1
  66. package/commands/pan/report.md +2 -2
  67. package/commands/pan/research-phase.md +14 -15
  68. package/commands/pan/resume.md +9 -11
  69. package/commands/pan/retro.md +5 -3
  70. package/commands/pan/review-deep.md +10 -10
  71. package/commands/pan/settings.md +1 -1
  72. package/commands/pan/todo-add.md +2 -2
  73. package/commands/pan/todo-check.md +2 -2
  74. package/commands/pan/verify-phase.md +0 -11
  75. package/commands/pan/what-if.md +2 -2
  76. package/hooks/dist/pan-context-monitor.js +343 -44
  77. package/hooks/dist/pan-cost-logger.js +30 -0
  78. package/hooks/dist/pan-state-reinject.js +140 -15
  79. package/hooks/dist/pan-statusline.js +68 -22
  80. package/hooks/dist/pan-stop-guard.js +7 -2
  81. package/package.json +1 -1
  82. package/pan-wizard-core/bin/lib/agents-md.cjs +48 -7
  83. package/pan-wizard-core/bin/lib/bridge.cjs +6 -5
  84. package/pan-wizard-core/bin/lib/campaign.cjs +4 -2
  85. package/pan-wizard-core/bin/lib/commands-learnings.cjs +19 -2
  86. package/pan-wizard-core/bin/lib/commands.cjs +126 -5
  87. package/pan-wizard-core/bin/lib/config.cjs +112 -1
  88. package/pan-wizard-core/bin/lib/constants.cjs +29 -15
  89. package/pan-wizard-core/bin/lib/context-budget.cjs +12 -9
  90. package/pan-wizard-core/bin/lib/core.cjs +77 -23
  91. package/pan-wizard-core/bin/lib/cost-rebuild.cjs +13 -1
  92. package/pan-wizard-core/bin/lib/cost.cjs +149 -10
  93. package/pan-wizard-core/bin/lib/distill.cjs +6 -3
  94. package/pan-wizard-core/bin/lib/doc-lint.cjs +30 -11
  95. package/pan-wizard-core/bin/lib/findings.cjs +15 -4
  96. package/pan-wizard-core/bin/lib/focus.cjs +13 -4
  97. package/pan-wizard-core/bin/lib/frontmatter.cjs +105 -26
  98. package/pan-wizard-core/bin/lib/hygiene.cjs +178 -17
  99. package/pan-wizard-core/bin/lib/init.cjs +12 -5
  100. package/pan-wizard-core/bin/lib/knowledge.cjs +17 -1
  101. package/pan-wizard-core/bin/lib/learn-index.cjs +111 -10
  102. package/pan-wizard-core/bin/lib/learn-lint.cjs +30 -3
  103. package/pan-wizard-core/bin/lib/memory-optimize.cjs +8 -4
  104. package/pan-wizard-core/bin/lib/memory.cjs +508 -54
  105. package/pan-wizard-core/bin/lib/milestone.cjs +8 -3
  106. package/pan-wizard-core/bin/lib/optimize.cjs +84 -16
  107. package/pan-wizard-core/bin/lib/phase-remove.cjs +85 -21
  108. package/pan-wizard-core/bin/lib/phase-report.cjs +8 -2
  109. package/pan-wizard-core/bin/lib/phase.cjs +67 -15
  110. package/pan-wizard-core/bin/lib/preview.cjs +3 -1
  111. package/pan-wizard-core/bin/lib/review-deep.cjs +2 -2
  112. package/pan-wizard-core/bin/lib/roadmap-compact.cjs +267 -0
  113. package/pan-wizard-core/bin/lib/roadmap.cjs +243 -9
  114. package/pan-wizard-core/bin/lib/runner.cjs +2 -1
  115. package/pan-wizard-core/bin/lib/state-compact.cjs +11 -6
  116. package/pan-wizard-core/bin/lib/state.cjs +47 -31
  117. package/pan-wizard-core/bin/lib/template.cjs +11 -4
  118. package/pan-wizard-core/bin/lib/verdict.cjs +54 -4
  119. package/pan-wizard-core/bin/lib/verify-drift.cjs +14 -5
  120. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -13
  121. package/pan-wizard-core/bin/lib/verify-retro.cjs +5 -3
  122. package/pan-wizard-core/bin/lib/verify-scope.cjs +74 -4
  123. package/pan-wizard-core/bin/lib/verify.cjs +117 -35
  124. package/pan-wizard-core/bin/lib/whatif.cjs +5 -3
  125. package/pan-wizard-core/bin/pan-tools.cjs +111 -17
  126. package/pan-wizard-core/learnings/index.json +5 -5
  127. package/pan-wizard-core/mcp/server.cjs +18 -9
  128. package/pan-wizard-core/opencode/pan-wizard.js +111 -0
  129. package/pan-wizard-core/references/checkpoints.md +7 -5
  130. package/pan-wizard-core/references/continuation-format.md +3 -3
  131. package/pan-wizard-core/references/decimal-phase-calculation.md +2 -3
  132. package/pan-wizard-core/references/design-methodology.md +1 -1
  133. package/pan-wizard-core/references/git-integration.md +4 -6
  134. package/pan-wizard-core/references/git-planning-commit.md +2 -2
  135. package/pan-wizard-core/references/guardrails.md +2 -2
  136. package/pan-wizard-core/references/handoff-decisions.md +3 -3
  137. package/pan-wizard-core/references/model-profile-resolution.md +5 -5
  138. package/pan-wizard-core/references/model-profiles.md +14 -9
  139. package/pan-wizard-core/references/phase-argument-parsing.md +7 -7
  140. package/pan-wizard-core/references/planning-config.md +4 -4
  141. package/pan-wizard-core/references/tdd.md +10 -1
  142. package/pan-wizard-core/references/verdict-contract.md +2 -1
  143. package/pan-wizard-core/references/verification-patterns.md +5 -5
  144. package/pan-wizard-core/templates/codebase/architecture.md +2 -2
  145. package/pan-wizard-core/templates/codebase/best-practices.md +2 -2
  146. package/pan-wizard-core/templates/codebase/concerns.md +3 -3
  147. package/pan-wizard-core/templates/codebase/integrations.md +6 -6
  148. package/pan-wizard-core/templates/codebase/relationships.md +2 -2
  149. package/pan-wizard-core/templates/codebase/stack.md +2 -2
  150. package/pan-wizard-core/templates/codebase/structure.md +4 -4
  151. package/pan-wizard-core/templates/codebase/testing.md +4 -4
  152. package/pan-wizard-core/templates/continue-here.md +1 -1
  153. package/pan-wizard-core/templates/debug-subagent-prompt.md +3 -2
  154. package/pan-wizard-core/templates/debug.md +15 -1
  155. package/pan-wizard-core/templates/discovery.md +1 -1
  156. package/pan-wizard-core/templates/milestone-archive.md +6 -6
  157. package/pan-wizard-core/templates/milestone.md +1 -1
  158. package/pan-wizard-core/templates/phase-prompt.md +31 -18
  159. package/pan-wizard-core/templates/planner-subagent-prompt.md +3 -5
  160. package/pan-wizard-core/templates/research-project/architecture.md +3 -3
  161. package/pan-wizard-core/templates/research-project/features.md +1 -1
  162. package/pan-wizard-core/templates/research-project/pitfalls.md +1 -1
  163. package/pan-wizard-core/templates/research-project/stack.md +3 -3
  164. package/pan-wizard-core/templates/research.md +5 -5
  165. package/pan-wizard-core/templates/retrospective.md +1 -1
  166. package/pan-wizard-core/templates/roadmap.md +15 -15
  167. package/pan-wizard-core/templates/summary-complex.md +1 -0
  168. package/pan-wizard-core/templates/summary-minimal.md +1 -0
  169. package/pan-wizard-core/templates/summary-standard.md +2 -1
  170. package/pan-wizard-core/templates/summary.md +18 -2
  171. package/pan-wizard-core/templates/uat.md +3 -3
  172. package/pan-wizard-core/templates/user-setup.md +8 -8
  173. package/pan-wizard-core/templates/verification-report.md +54 -4
  174. package/pan-wizard-core/workflows/add-phase.md +1 -1
  175. package/pan-wizard-core/workflows/assumptions.md +1 -1
  176. package/pan-wizard-core/workflows/discuss-phase.md +9 -8
  177. package/pan-wizard-core/workflows/exec-phase.md +34 -60
  178. package/pan-wizard-core/workflows/execute-plan.md +8 -7
  179. package/pan-wizard-core/workflows/health.md +13 -11
  180. package/pan-wizard-core/workflows/help.md +8 -9
  181. package/pan-wizard-core/workflows/learn.md +13 -11
  182. package/pan-wizard-core/workflows/map-codebase.md +10 -10
  183. package/pan-wizard-core/workflows/milestone-audit.md +10 -10
  184. package/pan-wizard-core/workflows/milestone-gaps.md +17 -24
  185. package/pan-wizard-core/workflows/milestone-new.md +7 -6
  186. package/pan-wizard-core/workflows/new-project.md +10 -10
  187. package/pan-wizard-core/workflows/optimize.md +11 -9
  188. package/pan-wizard-core/workflows/pause.md +6 -1
  189. package/pan-wizard-core/workflows/phase-tests.md +4 -4
  190. package/pan-wizard-core/workflows/plan-phase.md +31 -34
  191. package/pan-wizard-core/workflows/profile.md +2 -2
  192. package/pan-wizard-core/workflows/progress.md +5 -7
  193. package/pan-wizard-core/workflows/quick.md +10 -8
  194. package/pan-wizard-core/workflows/remove-phase.md +1 -1
  195. package/pan-wizard-core/workflows/research-phase.md +9 -5
  196. package/pan-wizard-core/workflows/resume-project.md +4 -6
  197. package/pan-wizard-core/workflows/retro.md +3 -1
  198. package/pan-wizard-core/workflows/settings.md +16 -24
  199. package/pan-wizard-core/workflows/todo-check.md +1 -1
  200. package/pan-wizard-core/workflows/transition.md +12 -12
  201. package/pan-wizard-core/workflows/update.md +25 -17
  202. package/pan-wizard-core/workflows/verify-phase.md +24 -17
  203. package/pan-zcode/KNOWN-BETA-RISKS.md +2 -2
  204. package/pan-zcode/README.md +7 -7
  205. package/pan-zcode/bin/install-zcode.js +1 -1
  206. package/scripts/build-agent-plugin.js +19 -5
  207. package/scripts/build-plugin.js +3 -1
  208. package/scripts/generate-skills-docs.py +13 -4
  209. package/scripts/test-surface.cjs +4 -0
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  name: focus-exec
3
3
  group: Focus
4
- description: Automated batch execution pipeline with 6 stages, 9 behavioral rules, 3 execution tiers
4
+ description: Automated batch execution pipeline with 6 stages, behavioral rules, 3 execution tiers
5
+ argument-hint: "[--budget N] [--mode bugfix|balanced|features|full] [--priority P0-P6] [--dry-run] [--no-commit] [--continue] [--deep-review]"
5
6
  allowed-tools:
6
7
  - Read
7
8
  - Write
@@ -85,7 +86,7 @@ Each stage has a restricted set of appropriate actions. Using the wrong tool at
85
86
  This command executes work on the **host project's source code** — not on PAN Wizard's own infrastructure.
86
87
 
87
88
  **Do not read, modify, or fix files in these PAN directories:**
88
- - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
89
+ - `.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.agents/`, and the Copilot runtime paths PAN installs into under `.github/` (`agents/`, `skills/`, `hooks/`, `copilot/`, `pan-wizard-core/`, `pan-local-patches/`, `mcp.json`, `package.json`, `pan-file-manifest.json`) — PAN runtime directories
89
90
  - Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
90
91
 
91
92
  **These directories are PAN's own tooling installed into the project.** If a batch item targets a PAN infrastructure file, SKIP it with reason "PAN infrastructure — out of scope." Never modify PAN's agents, commands, core modules, or dispatcher as part of project work.
@@ -116,7 +117,7 @@ HARD STOP conditions (do not proceed to next stage):
116
117
  - `--dry-run` — Run Stages 1-2 only (show what WOULD be executed)
117
118
  - `--no-commit` — Skip the commit step in Stage 6
118
119
  - `--continue` — Resume a previously interrupted execution
119
- - `--deep-review` (v3.4+) — After each high-stakes item's execution, run `/pan:review-deep` for that item (pan-hardener + pan-meta-reviewer security + cross-check). Slows the campaign by roughly 3× per item that triggers the deep pass; use for batches touching auth/payment/migrations.
120
+ - `--deep-review` (v3.4+) — After each high-stakes item's execution, run the deep pass on that item's changed files: spawn pan-hardener (`<output_path>` `.planning/reviews/<item-id>/hardener.md`), then pan-meta-reviewer on its report (`.planning/reviews/<item-id>/meta.md`), and merge with `pan-tools review-deep merge <item-id> --hardener-file … --meta-file …` (no first-pass review, so no `--reviewer-file`; `/pan:review-deep` itself needs a phase). Slows the campaign by roughly 3× per item that triggers the deep pass; use for batches touching auth/payment/migrations.
120
121
 
121
122
  ---
122
123
 
@@ -161,7 +162,7 @@ Every code change must be tested before moving to the next item.
161
162
  Test cadence by tier:
162
163
  - **MICRO (XS/S):** Run specific test after implementing. Batch up to 3 independent items before smoke.
163
164
  - **STANDARD (M):** Full test suite after each item.
164
- - **FULL (L/XL):** Build hooks + full test suite after each item.
165
+ - **FULL (L/XL):** The project's build step (if it has one) + full test suite after each item.
165
166
 
166
167
  ### Rule 4: Don't Invent — Follow the Plan
167
168
  Implement exactly what the batch says. Do not:
@@ -210,8 +211,7 @@ This catches emergent interactions: 5 "add try-catch" fixes might reveal the mod
210
211
  1. **Check Project Status** — git status, recent commits
211
212
  2. **Test Baseline** — run test suite, record current counts
212
213
  3. **Create rollback snapshot** — git tag for safety
213
- 4. **Prime prompt cache** — `pan-tools cache prime --summary` (once; all sub-agents in the next 5 min hit cached context)
214
- 5. **Report** — Output session start summary
214
+ 4. **Report** — Output session start summary
215
215
 
216
216
  **Circular optimization — init trace:**
217
217
  ```bash
@@ -286,7 +286,7 @@ Display the execution batch to user, then continue automatically.
286
286
  3. DESIGN — outline approach before coding
287
287
  4. STATE INTENT — "I will modify [files]. Risk: [what could break]"
288
288
  5. IMPLEMENT in logical chunks
289
- 6. BUILD — build hooks if hooks changed
289
+ 6. BUILD — run the project's build step if the item changed what it builds
290
290
  7. TEST — full test suite
291
291
  8. CONFIRM — all pass -> DONE | fail -> investigate (15 min max) -> REVERT -> FAILED
292
292
  ```
@@ -2,6 +2,7 @@
2
2
  name: focus-plan
3
3
  group: Focus
4
4
  description: Create capacity-budgeted work batch with spec coverage verification and 4 execution modes
5
+ argument-hint: "[--budget N] [--mode bugfix|balanced|features|full] [--priority P0-P6] [--lean] [--no-spec-check]"
5
6
  allowed-tools:
6
7
  - Read
7
8
  - Write
@@ -24,7 +25,7 @@ Create a capacity-budgeted work batch from focus-scan results **with mandatory v
24
25
  This command plans work batches for the **host project** — NOT for PAN Wizard's own infrastructure.
25
26
 
26
27
  **NEVER include items targeting these PAN directories:**
27
- - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
28
+ - `.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.agents/`, and the Copilot runtime paths PAN installs into under `.github/` (`agents/`, `skills/`, `hooks/`, `copilot/`, `pan-wizard-core/`, `pan-local-patches/`, `mcp.json`, `package.json`, `pan-file-manifest.json`) — PAN runtime directories
28
29
  - Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
29
30
 
30
31
  If a scan item points to a PAN infrastructure file, DROP it from the batch. PAN's files are not the project's responsibility.
@@ -38,11 +39,11 @@ If no recent scan exists, run `/pan:focus-scan` automatically before proceeding.
38
39
  **Flags:**
39
40
  - `--budget N` — Override capacity budget in points (default: 50, min: 5, max: 100)
40
41
  - `--mode MODE` — Execution mode. Default: `balanced`
41
- - `bugfix` — P0->P1->smallest-first, no feature work (40 pts)
42
+ - `bugfix` — one pass over P0-P4 in priority order, smallest-first within each; P5-P6 left out (40 pts)
42
43
  - `balanced` — **Default.** Mix of stability fixes + feature development, 60/40 split (50 pts)
43
- - `features` — Feature-focused: 80% budget on P3-P5, P0 crashes still mandatory (50 pts)
44
- - `full` — Full-spectrum: enhanced budget, all priorities equally weighted (60 pts)
45
- - `--priority P0-P6` — Only pick items from these priority tiers
44
+ - `features` — Feature-focused: P0 crashes mandatory, then 80% of what that leaves on P3-P5 (50 pts)
45
+ - `full` — Full-spectrum: one pass over every priority, P0 first and smallest-first within each; budget raised to at least 60 (60 pts)
46
+ - `--priority PN` — Only pick items at priority PN or higher (P0 through PN), e.g. `--priority P2`
46
47
  - `--lean` — Apply RS filtering: exclude items with RS < 1.5
47
48
  - `--no-spec-check` — Skip spec coverage verification (NOT recommended — use only for pure bugfix batches)
48
49
 
@@ -133,13 +134,13 @@ This becomes the **spec gap backlog** — items that specs/ADRs promised but the
133
134
  ### `features` — Feature-Focused Sprint
134
135
  - **Budget:** 50 pts
135
136
  - **Mandatory pass:** All P0 items
136
- - **Feature pass (80%):** 40 pts for P3-P5
137
- - **Stability pass (20%):** 10 pts for P1-P2 quick wins
137
+ - **Feature pass (80%):** 80% of what the P0 pass left, for P3-P5 (40 pts when there are no P0 items)
138
+ - **Stability pass (20%):** the rest of it, for P1-P2 quick wins (10 pts when there are no P0 items)
138
139
  - **Spec coverage:** Feature items MUST map to spec requirements — reject unspecified feature work
139
140
 
140
141
  ### `full` — Full-Spectrum Marathon
141
142
  - **Budget:** 60 pts
142
- - **All priorities weighted equally, largest-impact-first**
143
+ - **One pass over every priority in priority order, smallest-first within each**
143
144
  - **Spec coverage:** Full traceability — every item maps to a spec/ADR requirement or is flagged as unspecified
144
145
 
145
146
  ### Batch Selection Algorithm
@@ -220,7 +221,7 @@ This becomes the post-execution checklist for `/pan:focus-exec`.
220
221
 
221
222
  ## Phase 5: Output
222
223
 
223
- Produce a batch file at `.planning/focus/batch-<YYYY-MM-DD>.json` via `pan-tools focus plan`:
224
+ Write the batch to `.planning/focus/batch-<YYYY-MM-DD>.json` yourself — `{date, mode, budget, allocated, items: [...]}`, each item `{id, title, priority, effort, points, tier, files}` with `tier` one of `MICRO`, `STANDARD`, `FULL` (`focus exec` and `focus classify-stages` group items by it, and an item without it lands in no wave); `focus exec`, `focus classify-stages` and `/pan:focus-exec` read an `items` or `batch` array. Do not hand this step to `pan-tools focus plan`: it ignores the scan and the spec mapping, batches only incomplete roadmap phases, pending todos and `.planning/patterns.md` entries, and overwrites the day's batch file:
224
225
 
225
226
  ```markdown
226
227
  ## Focus Batch — <date>
@@ -252,11 +253,11 @@ Produce a batch file at `.planning/focus/batch-<YYYY-MM-DD>.json` via `pan-tools
252
253
  | NCA affordability | ADR-0018 SC-4 | Blocked by SC-1, SC-2 | After this batch |
253
254
 
254
255
  ### Dependency Order
255
- ```
256
+ ~~~
256
257
  #1 (P0 crash fix) → independent
257
258
  #3 (categories) → #4 (keywords) → #5 (match types)
258
259
  #2 (tests) → independent
259
- ```
260
+ ~~~
260
261
 
261
262
  ### Post-Execution Verification Checklist
262
263
  - [ ] SC-1: Category count >= 65 → `SELECT COUNT(*) FROM stx_category`
@@ -2,8 +2,10 @@
2
2
  name: focus-scan
3
3
  group: Focus
4
4
  description: Deep-dive strategic work scan with prioritized items and Reality Score filtering
5
+ argument-hint: "[--focus <area>] [--quick] [--refresh] [--lean]"
5
6
  allowed-tools:
6
7
  - Read
8
+ - Write
7
9
  - Bash
8
10
  - Grep
9
11
  - Glob
@@ -22,13 +24,13 @@ Survey the project for prioritized work items with evidence-based scoring. $ARGU
22
24
  This command scans the **host project's source code** for work items — not PAN Wizard's own infrastructure.
23
25
 
24
26
  **Exclude these directories from scanning:**
25
- - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
27
+ - `.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.agents/`, and the Copilot runtime paths PAN installs into under `.github/` (`agents/`, `skills/`, `hooks/`, `copilot/`, `pan-wizard-core/`, `pan-local-patches/`, `mcp.json`, `package.json`, `pan-file-manifest.json`) — PAN runtime directories
26
28
  - `.planning/` — PAN planning state (read for context, but never report PAN planning files as "issues")
27
29
  - Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
28
30
 
29
31
  **These directories are PAN's own tooling installed into the project.** Do not report TODO/FIXME items found in PAN files. Do not flag PAN files as lacking test coverage. Do not suggest improvements to PAN's agents, commands, or core modules.
30
32
 
31
- If a scan finding points to a file inside `.claude/`, `.github/`, `.opencode/`, `.gemini/`, or `.codex/` — DROP IT. It is not the project's responsibility.
33
+ If a scan finding points to a file in one of the PAN paths listed above — DROP IT. It is not the project's responsibility.
32
34
 
33
35
  ---
34
36
 
@@ -73,10 +75,7 @@ Read these files to establish baseline:
73
75
 
74
76
  **Project Structure:**
75
77
  - All core modules in the project's source directories
76
- - All command definitions
77
- - All agent definitions
78
- - All workflow definitions
79
- - All hook source files
78
+ - The project's own command, agent, workflow and hook definitions, if it has any (never PAN's, which the Project Scope Boundary excludes)
80
79
 
81
80
  **Planning State:**
82
81
  - `.planning/state.md` — Current state
@@ -95,9 +94,7 @@ In: source directories, hooks, tests
95
94
  Cross-reference found issues with documented items — flag any UNDOCUMENTED issues as new findings.
96
95
 
97
96
  ### 0.3 Check Test Results
98
- ```bash
99
- npm test 2>&1
100
- ```
97
+ Run the project's test suite: the commands in `.planning/config.json → verification` when set, otherwise the test command discovered from `package.json` scripts, `Makefile`, or project docs.
101
98
  Record: total tests, passing, failing, suites.
102
99
 
103
100
  ### 0.4 Baseline Snapshot Table
@@ -240,7 +237,7 @@ Gather items from:
240
237
  ## Phase 5: Scan Assembly
241
238
 
242
239
  ### 5.1 Output
243
- Return JSON via `pan-tools focus scan` with all items, or write to `.planning/focus/` for persistence.
240
+ Write the scan to `.planning/focus/scan-<YYYY-MM-DD>.md`, where `/pan:focus-plan` builds from it and `/pan:focus-exec` updates it (Stage 5.2). `pan-tools focus scan` does not take these items: it lists only incomplete roadmap phases that have a directory, pending todos and `.planning/patterns.md` entries.
244
241
 
245
242
  ### 5.2 Document Structure
246
243
 
@@ -2,6 +2,7 @@
2
2
  name: focus-sync
3
3
  group: Focus
4
4
  description: Synchronize documentation after changes — check staleness and update counts
5
+ argument-hint: "[--readme | --docs | --arch | --all]"
5
6
  allowed-tools:
6
7
  - Read
7
8
  - Bash
@@ -24,7 +25,7 @@ Synchronize project documentation across all files. $ARGUMENTS
24
25
  This command synchronizes the **host project's documentation** — NOT PAN Wizard's own infrastructure files.
25
26
 
26
27
  **NEVER sync, modify, or report staleness in these PAN directories:**
27
- - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
28
+ - `.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.agents/`, and the Copilot runtime paths PAN installs into under `.github/` (`agents/`, `skills/`, `hooks/`, `copilot/`, `pan-wizard-core/`, `pan-local-patches/`, `mcp.json`, `package.json`, `pan-file-manifest.json`) — PAN runtime directories
28
29
  - Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
29
30
 
30
31
  **These directories are PAN's own tooling.** Documentation sync applies to the project's README, docs, guides, and code comments — not to PAN's installed agents or command definitions.
@@ -91,7 +92,7 @@ CHANGELOG.md <- Version history
91
92
 
92
93
  ## Report
93
94
 
94
- Output via `pan-tools focus sync`:
95
+ Report in this shape (`pan-tools focus sync` itself returns only JSON — `actuals` (counts of commands, agents and modules), `stale` / `current` entries for those counts, any `--tests` / `--suites` counts, renamed `/pan:` commands and the package.json-vs-CHANGELOG version, plus `stale_count` and `needs_sync`):
95
96
 
96
97
  ```
97
98
  | Area | Status | Finding |
@@ -15,7 +15,7 @@ allowed-tools:
15
15
  <objective>
16
16
  Phase-aware git workflow with safety guardrails built in. Every subcommand that modifies history runs safety checks. Rollback uses PAN snapshot tags (`pan-rollback-*`), which `pan-tools rollback-snapshot <phase>` creates; no workflow creates them for you.
17
17
 
18
- Works with any git repository — PAN installation not required.
18
+ Works with any git repository — no PAN project (`.planning/`) needed, only the installed `pan-tools.cjs`.
19
19
  </objective>
20
20
 
21
21
  <subcommands>
@@ -59,19 +59,19 @@ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git commit \
59
59
  ```
60
60
 
61
61
  **Options:**
62
- - `--type` — `feat | fix | docs | test | refactor | chore`
62
+ - `--type` — `feat | fix | docs | test | refactor | perf | chore`
63
63
  - `--message` — Commit message body
64
64
  - `--all` — Stage all changes before committing
65
65
  - `--files f1 f2` — Stage specific files
66
66
  - `--amend` — Amend last commit (no message needed)
67
- - `--force` — Bypass deleted-file and sensitive-file blocks
67
+ - `--force` — Bypass the deleted-file block (not the sensitive-file block)
68
68
 
69
69
  **Safety checks run automatically:**
70
70
 
71
71
  | Check | Blocks on | Override |
72
72
  |-------|-----------|---------|
73
- | Deleted files | Staged deletions found | `--force` |
74
- | Sensitive files | `.env`, `.pem`, `.key`, `secret`, `password`, `token` | `--force` |
73
+ | Deleted files | A deletion anywhere in the repository (`git status --porcelain`, staged or not) | `--force` |
74
+ | Sensitive files | A staged path ending `.env`, `.pem` or `.key`, or containing `credentials`, `secret`, `password` or `token` (PAN's own `.planning/metrics/tokens.jsonl` is exempt) | None: narrow `commit.sensitive_patterns` in `.planning/config.json`, or commit the file yourself |
75
75
 
76
76
  **Output:** `{committed, hash, type, safety_checks}`
77
77
 
@@ -174,14 +174,14 @@ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git diff --staged --file src/ap
174
174
  ### rollback — Revert to PAN Snapshot
175
175
 
176
176
  ```bash
177
- # Rollback to latest PAN snapshot tag (requires clean working tree)
177
+ # Rollback to the last pan-rollback-* tag in name order — the newest only among one phase's snapshots (requires clean working tree)
178
178
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback
179
179
 
180
180
  # Preview — does NOT reset, shows what would happen
181
181
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback --dry-run
182
182
 
183
183
  # Rollback to specific tag
184
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback --tag pan-rollback-03-1714000000
184
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback --tag pan-rollback-3-20260415T101500
185
185
  ```
186
186
 
187
187
  **Rollback workflow:**
@@ -219,5 +219,5 @@ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git sync --remote upstream --br
219
219
  </workflow>
220
220
 
221
221
  <runtime_note>
222
- All subcommands work with any git repository regardless of whether PAN is installed or `.planning/` exists. The only requirement is a valid git repo (`git init` or cloned).
222
+ All subcommands work with any git repository, whether or not it holds a PAN project (`.planning/`); they run the installed `pan-tools.cjs`. The only requirement is a valid git repo (`git init` or cloned).
223
223
  </runtime_note>
@@ -2,7 +2,7 @@
2
2
  name: pan:health
3
3
  group: System
4
4
  description: Diagnose planning directory health and optionally repair issues
5
- argument-hint: "[--repair]"
5
+ argument-hint: "[--repair] [--standards] [--full] [--drift] [--links]"
6
6
  allowed-tools:
7
7
  - Read
8
8
  - Bash
@@ -19,5 +19,5 @@ Validate `.planning/` directory integrity and report actionable issues. Checks f
19
19
 
20
20
  <process>
21
21
  Execute the health workflow from @~/.claude/pan-wizard-core/workflows/health.md end-to-end.
22
- Parse --repair flag from arguments and pass to workflow.
22
+ Pass the arguments to the workflow, which forwards `--repair`, `--standards`, `--full`, `--drift` and `--links` to `validate health`.
23
23
  </process>
@@ -34,10 +34,10 @@ pan-tools hud [--out <file>] [--open] [--stdout]
34
34
  **JSON result shape** (default, when not `--stdout`):
35
35
  ```json
36
36
  {
37
- "path": ".planning/hud.html",
37
+ "path": "/abs/path/to/project/.planning/hud.html",
38
38
  "bytes": 18234,
39
39
  "army_active": true,
40
- "sections": ["mission", "command-stack", "campaign", "safety-harness", "worktrees", "roadmap", "telemetry", "requirements-quality", "activity"],
40
+ "sections": ["mission", "now-building", "command-stack", "campaign", "safety-harness", "worktrees", "roadmap", "telemetry", "requirements-quality", "activity"],
41
41
  "opened": false
42
42
  }
43
43
  ```
@@ -51,6 +51,7 @@ Panels render only when they have data — a plain (non-army) project still gets
51
51
  | Panel | What it shows | Source |
52
52
  |-------|---------------|--------|
53
53
  | **Mission banner** | Project, core value, status, version/milestone + metric cards (progress, phase, requirements, spend) | `package.json`, `project.md`, `state.md`, phase scan, cost ledger |
54
+ | **Now building** | Current phase on a phase stepper, its pipeline stage (research → plan → execute → verify), and the army tasks in flight or the phase's plan/summary counts | phases on disk + army worktrees |
54
55
  | **Command stack** *(army)* | Mission Control over the four squads with per-squad agent drill-down (active / idle, calls, tokens) | squad registry + cost ledger |
55
56
  | **Campaign** *(army)* | Cadence, next-due, daily-budget bar, last run, run history | `schedule.json` |
56
57
  | **Safety harness** *(army)* | Merge gate, abort switch (pause), active worktrees, daily budget, concurrency | config + pause file + worktrees + schedule |
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: pan:hygiene
3
3
  group: System
4
- description: Scan the project for PAN version drift and stale artifacts (legacy filenames, memory bloat, poisoned ledgers, trace debris) and apply safe cleanups
4
+ description: Scan the project for PAN version drift and stale artifacts (legacy filenames, memory bloat and stale entries, poisoned ledgers, trace debris, oversized planning files) and apply safe cleanups
5
5
  argument-hint: "[--apply] [--trace-age-days N] [--all-tracks] [--track <name>]"
6
6
  allowed-tools:
7
7
  - Read
@@ -9,7 +9,14 @@ allowed-tools:
9
9
  - AskUserQuestion
10
10
  ---
11
11
  <objective>
12
- Keep a PAN-managed project aligned with the latest PAN version and free of accumulated history debris. Detects: outdated runtime installs (per-runtime manifest version vs latest), legacy uppercase planning filenames, orphaned atomic-write .tmp files, per-agent memory logs past the compaction cap, cost ledgers poisoned by pre-v3.12.4 telemetry, stale optimization trace sessions, and stray fragment `.planning/` directories.
12
+ Keep a PAN-managed project aligned with the latest PAN version and free of accumulated history debris. Detects:
13
+ - outdated runtime installs (per-runtime manifest version vs latest);
14
+ - legacy uppercase planning filenames and orphaned atomic-write .tmp files;
15
+ - per-agent memory logs past the compaction cap (`memory-bloat`), memory entries whose cited code is gone or that went unused past the expiry window (`memory-stale`), and files in `.planning/memory/` that are not read as memory (`memory-format`);
16
+ - planning files past their budget (`cache-context`): state.md, which every agent call re-reads, and roadmap.md and requirements.md, which only the roadmapper and milestone work read whole (phase agents read `roadmap slice`); state.md's settled history and roadmap.md's shipped phases can be archived;
17
+ - cost ledgers poisoned by pre-v3.12.4 telemetry, stale optimization trace sessions and reports, and stray fragment `.planning/` directories;
18
+ - a planning tree another tool writes into too (`shared-planning-tree`) or owns (`foreign-planning-tree`);
19
+ - Claude Code's own memory index past or near its load limit, or holding content where a one-line pointer belongs (`host-memory`). PAN only reports this one: it never writes the host's memory.
13
20
  </objective>
14
21
 
15
22
  <process>
@@ -28,7 +35,7 @@ Display the findings grouped by severity (critical → warn → info), labelling
28
35
 
29
36
  **Always state which trees were scanned** — read `roots_scanned[]` and name them. If `summary.total` is 0, report "Project is clean and aligned" *together with* the list of trees that were read. A clean verdict without its scope is what let stale debris hide in an unscanned track; never report one without the other.
30
37
 
31
- If any root has `planning_root_exists: false`, say so plainly — that is a mistyped `--track`, not a clean tree.
38
+ If the top-level `planning_root_exists` is `false`, or a `roots_scanned[]` entry has `planning_exists: false`, say so plainly — that is a mistyped `--track`, not a clean tree.
32
39
 
33
40
  ## 2. Version drift (manual remediation)
34
41
 
@@ -36,7 +43,7 @@ If any `version-alignment` findings exist, list the outdated runtimes and show t
36
43
 
37
44
  ```
38
45
  Re-run the installer from the project root to align all runtimes:
39
- node <pan-source>/bin/install.js --claude --codex --gemini --opencode --copilot --local
46
+ npx pan-wizard@latest --claude --codex --gemini --opencode --copilot --local
40
47
  (use the flags matching the runtimes reported in installs[])
41
48
  ```
42
49
 
@@ -58,11 +65,11 @@ Then ask the user (AskUserQuestion, header "Apply fixes", options: "Apply safe f
58
65
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs hygiene clean --all-tracks --apply
59
66
  ```
60
67
 
61
- Safe fixes are: lowercase renames of legacy planning filenames, deletion of aged .tmp orphans, memory-log compaction, poisoned-ledger quarantine (rename in place — never deleted), pruning of trace sessions **and optimization reports** past retention (newest 5 of each always kept), and **state.md compaction** (`compact-state`) — settled history is archived to `state-history.md` so it stops being re-read into every agent call. Nothing is deleted by any of these: the ledger is renamed, and state history is written to the archive before state.md is rewritten. Each fix is applied inside its own tree's scope, so a track's debris is cleaned in that track. Pass through `--trace-age-days N` and any `--track <name>` if provided.
68
+ Safe fixes are: lowercase renames of legacy planning filenames, deletion of aged .tmp orphans, memory-log compaction, **memory pruning** (`prune-memory`: stale and expired entries move to `.planning/memory/archive/<agent>.md`), poisoned-ledger quarantine (renamed in place; only the newest quarantined copy is kept, older ones are deleted), pruning of trace sessions **and optimization reports** past retention (newest 5 of each always kept), **state.md compaction** (`compact-state`) — settled history is archived to `state-history.md` so it stops being re-read into every agent call — and **roadmap compaction** (`compact-roadmap`): shipped phases' sections move to `roadmap-history.md`, leaving a stub that `roadmap get-phase` reads back through. None of these deletes anything you wrote: the ledger is renamed, and each archive is written before the file it came from is rewritten. Each fix is applied inside its own tree's scope, so a track's debris is cleaned in that track. Pass through `--trace-age-days N` if provided. With `--track <name>`, use it **in place of** `--all-tracks` in both commands: given both, `--all-tracks` wins and every tree is cleaned.
62
69
 
63
70
  ## 4. Report
64
71
 
65
- Summarize: the trees scanned, fixes executed / failed / left manual (attributed per track), plus the installer command if version drift remains. If a `cache-context` finding appeared, state the per-call token cost it represents — that block is re-read on **every** agent call, so it is the project's largest recurring expense. Recommend re-running `/pan:hygiene` after the installer to confirm alignment.
72
+ Summarize: the trees scanned, fixes executed / failed / left manual (attributed per track), plus the installer command if version drift remains. If a `cache-context` finding appeared, state the token cost its detail names and who pays it: state.md is re-read on **every** agent call, the project's largest recurring expense, while roadmap.md and requirements.md cost only when the roadmapper or milestone work reads them whole. If a `host-memory` finding appeared, name the index and the lines it flags so the user can tidy them: Claude Code loads only the head of that index, and PAN never edits it. Recommend re-running `/pan:hygiene` after the installer to confirm alignment.
66
73
 
67
74
  </process>
68
75
 
@@ -70,6 +77,6 @@ Summarize: the trees scanned, fixes executed / failed / left manual (attributed
70
77
  - [ ] Scan run and findings presented by severity
71
78
  - [ ] Version drift reported with the exact installer command (never auto-run)
72
79
  - [ ] Safe fixes applied only with --apply or explicit user confirmation
73
- - [ ] Nothing user-authored deleted — quarantine renames only
80
+ - [ ] Nothing user-authored deleted — the ledger quarantine is a rename (older quarantined copies, PAN's own data, are removed), and memory compaction archives what it drops
74
81
  - [ ] Final summary states executed/failed/manual counts
75
82
  </success_criteria>
@@ -16,7 +16,7 @@ allowed-tools:
16
16
  Retrieve, refine, or consolidate project knowledge. Three modes:
17
17
 
18
18
  - **ask** — answer a natural-language question with inline citations grounded in `.planning/` + `docs/`.
19
- - **discuss** — multi-turn refinement of a phase's context. Session state persists across invocations; prompt caching keeps turn 3 cheap.
19
+ - **discuss** — multi-turn refinement of a phase's context. Session state persists across invocations.
20
20
  - **playbook** — aggregate all agents' memory (E-4 layer) into `.planning/playbook.md`, organized by category (Conventions / Gotchas / Decisions / Tool choices / Anti-patterns / Recurring gaps).
21
21
 
22
22
  Consolidates Spec B v1's X-3 converse + X-6 teach + X-10 explain into one command.
@@ -54,10 +54,10 @@ Consolidates Spec B v1's X-3 converse + X-6 teach + X-10 explain into one comman
54
54
  2. `pan-tools knowledge discuss <phase> --subcmd append --role user --content "<topic>"` persists the user turn.
55
55
  3. Spawn `pan-knowledge` with `<mode>discuss</mode>`, session history, phase context, and the new turn.
56
56
  4. Agent responds.
57
- 5. `pan-tools knowledge discuss <phase> --subcmd append --role agent --content "<response>" --cites "a.md,b.md"` persists the response.
58
- 6. If after ≥3 substantive turns the agent offered to emit `context.md`, user can follow up with another `/pan:knowledge discuss <phase>` invocation or run the commit subcommand the agent suggested.
57
+ 5. Write the agent's response to a file, then `pan-tools knowledge discuss <phase> --subcmd append --role agent --content "$(cat <response-file>)" --cites "a.md,b.md"` persists it — a reply pasted between the quotes breaks the shell line at its first `"`, `$` or backtick.
58
+ 6. If after ≥3 substantive turns the agent offered to emit `context.md`, the user accepts in another `/pan:knowledge discuss <phase>` turn and the agent writes it (there is no commit subcommand).
59
59
 
60
- **Session persistence:** `.planning/conversations/<phase>/session.json` — array of turns with ts/role/content/cites. Multi-turn cost is dominated by cache hits on stable `.planning/` files.
60
+ **Session persistence:** `.planning/conversations/<phase>/session.json` — `{phase, turns: [...], created, last_updated}`, each turn with ts/role/content/cites.
61
61
 
62
62
  ### `playbook`
63
63
 
@@ -66,12 +66,12 @@ Consolidates Spec B v1's X-3 converse + X-6 teach + X-10 explain into one comman
66
66
  ```
67
67
 
68
68
  **Flow:**
69
- 1. `pan-tools knowledge playbook` reads all agents' memory (`.planning/memory/*.md`), clusters entries by category, writes `.planning/playbook.md` directly.
69
+ 1. `pan-tools knowledge playbook` reads every agent log that `memory list` names in `.planning/memory/`, clusters entries by category, writes `.planning/playbook.md` directly.
70
70
  2. Optionally spawn `pan-knowledge` with `<mode>playbook</mode>` to polish (dedupe contradictions, consolidate similar entries). Skip the polish step if the draft looks clean.
71
71
 
72
72
  **Output:** `.planning/playbook.md` — team-readable summary of accumulated lessons.
73
73
 
74
- **Auto-invocation:** `/pan:milestone-done` can optionally run this (flag-gated, not default). Manual invocation any time.
74
+ **Auto-invocation:** none — no workflow runs it (`/pan:milestone-done` has no playbook step). Run it by hand any time.
75
75
 
76
76
  </modes>
77
77
 
@@ -83,7 +83,7 @@ Consolidates Spec B v1's X-3 converse + X-6 teach + X-10 explain into one comman
83
83
 
84
84
  **Bug investigation:** `/pan:knowledge ask "why did we add the retry in phase 4?"` — faster than grepping for historical context.
85
85
 
86
- **Before milestone-done:** run `/pan:knowledge playbook` to capture what the team learned. Gives contributors something to reference when starting the next milestone.
86
+ **Before milestone-done:** run `/pan:knowledge playbook` to collect the lessons the agent logs hold. PAN no longer writes those logs on its own (ADR-0036, amended `2026-10-04`): they hold what someone recorded with `memory append`, `memory record` or `/pan:retro` with `--write-memory`, or an older report applied, so on a project without such entries the playbook is empty.
87
87
 
88
88
  </workflow>
89
89
 
@@ -106,8 +106,8 @@ The agent should NEVER fabricate citations. The retrieval layer's `sources` list
106
106
 
107
107
  | Runtime | ask | discuss | playbook |
108
108
  |---------|-----|---------|----------|
109
- | Claude Code | Full, thinking enabled | Full, prompt caching bonus | Full |
110
- | OpenCode | Full | Full (no cache bonus) | Full |
109
+ | Claude Code | Full, thinking enabled | Full | Full |
110
+ | OpenCode | Full | Full | Full |
111
111
  | Gemini | Full | Full | Full |
112
112
  | Codex | Full | Full | Full |
113
113
  | Copilot | Full | Full | Full |
@@ -2,6 +2,7 @@
2
2
  name: pan:learn
3
3
  group: Self-Improvement
4
4
  description: Analyze trace sessions or harvested experiments via pan-optimizer; generate ranked optimization reports
5
+ argument-hint: "[--session <id> | --sessions <n> | --experiment <slug>] [--apply]"
5
6
  allowed-tools:
6
7
  - Read
7
8
  - Bash
@@ -26,8 +27,8 @@ Analyze the most recent trace session and generate an optimization report.
26
27
  **Flags:**
27
28
  - `--session <id>` — analyze a specific session instead of the most recent
28
29
  - `--sessions <n>` — pool the last n sessions into one analysis, so recommendations rest on failures that recur across runs
29
- - `--experiment <slug>` *(v3.7.0+, W3)* — analyze a harvested experiment instead of the current project's traces. Reads from `<source-repo>/experiments/<slug>/.planning/optimization/` and writes the report to `<source-repo>/experiments/<slug>/learnings/report-<timestamp>.md`. Used by the self-improvement loop. Run `/pan:experiment harvest <slug>` first.
30
- - `--apply` — automatically apply safe optimizations after generating the report (equivalent to running `/pan:optimize apply` immediately after)
30
+ - `--experiment <slug>` *(v3.7.0+, W3)* — analyze a harvested experiment instead of the current project's traces: the workflow runs its `pan-tools` steps with `--cwd` set to the harvest folder (the `harvest_path` `/pan:experiment harvest <slug>` printed, `<source-repo>/experiments/<slug>/` by default), so the analysis and the optimizer's report land in that folder's `.planning/optimization/reports/`. Used by the self-improvement loop. Run `/pan:experiment harvest <slug>` first.
31
+ - `--apply` — record the report's suggestions right after generating it (equivalent to running `/pan:optimize apply` immediately after)
31
32
 
32
33
  **What it does:**
33
34
 
@@ -47,28 +48,30 @@ Analyze the most recent trace session and generate an optimization report.
47
48
  - Tool failures and correction loops (error events)
48
49
  - Topics the model had to infer without context (gap events)
49
50
  - Repeated research on the same topic (redundancy events)
50
- - Memory cache misses (memory_miss events)
51
+ - Missing knowledge an agent logged (memory_miss events)
51
52
  - Unexpected outcomes (surprise events)
52
53
 
53
54
  **Output:**
54
55
 
55
56
  The optimization report in `.planning/optimization/reports/` contains:
56
57
  - Ranked error patterns with fix recommendations
57
- - Memory gap findings with ready-to-apply memory entry content
58
+ - Lessons the agents lacked, each with where it belongs: the project's instructions (CLAUDE.md or AGENTS.md, outside PAN's section), a test, or a comment at the cited code
58
59
  - Redundancy analysis with token waste estimates
59
60
  - Prompt improvement suggestions (require human review before applying)
60
61
  - Workflow gap suggestions (require human review)
61
- - An `## Auto-Apply Actions` JSON block for `/pan:optimize apply`
62
+ - An `## Auto-Apply Actions` JSON block, which `/pan:optimize apply` records in `.planning/optimization/suggestions.md`
62
63
  - A circular optimization score (0–100)
63
64
 
65
+ Nothing in the report reaches an agent until a person writes it where the agents read. PAN's workflows do not load `.planning/memory/` into agents.
66
+
64
67
  **Example:**
65
68
  ```
66
69
  /pan:learn
67
70
  → Session sess_20260421T180000: 47 events (8 errors, 12 gaps, 3 redundancies)
68
71
  → Report: .planning/optimization/reports/sess_20260421T180000-opt-report.md
69
72
  → Optimization score: 72/100
70
- → Top finding: M1 — Express middleware order missing from memory (5 misses)
71
- → Auto-applicable: 3 memory entries
73
+ → Top finding: L1 — Express middleware order inferred 5 times (belongs in CLAUDE.md)
74
+ → Lessons: 3
72
75
  → Needs review: 2 prompt improvements, 1 workflow gap
73
76
  ```
74
77
 
@@ -2,6 +2,7 @@
2
2
  name: pan:links
3
3
  group: Validation
4
4
  description: Validate the doc-code link graph — inline wiki-style refs, source-comment anchors, and require-code-mention contracts (ADR-0027, v3.8.0+)
5
+ argument-hint: "[--strict] [--doc-root <path>]... [--source-root <path>]... [--raw]"
5
6
  allowed-tools:
6
7
  - Bash
7
8
  - Read
@@ -10,7 +11,7 @@ allowed-tools:
10
11
 
11
12
  # /pan:links
12
13
 
13
- Validate the doc-code link graph. Walks `docs/`, `pan-wizard-core/`, `commands/`, and `agents/` for inline `[[<id>]]` references and `// @pan: <id>` source-comment anchors. Reports broken refs, stale anchors, and uncovered backlink contracts.
14
+ Validate the doc-code link graph. Walks `docs/`, `commands/`, `agents/` and `pan-wizard-core/`'s workflows, templates, references and learnings for inline `[[<id>]]` references, and `pan-wizard-core/`, `bin/`, `hooks/` and `scripts/` for `// @pan: <id>` source-comment anchors. Reports broken refs, stale anchors, and uncovered backlink contracts.
14
15
 
15
16
  > **User projects:** the default roots (`docs/`, `pan-wizard-core/`, `commands/`, `agents/`) are the **PAN source-repo** layout. A typical user project has none of these, so a bare `/pan:links` scans almost nothing and reports a hollow `pass`. In a user project you **must** point it at your own layout with `--doc-root` / `--source-root` (both repeatable), e.g. `/pan:links --doc-root docs --source-root src`. Treat any run where `doc_files_scanned` (or `source_files_scanned`) is `0` as a **warning that the roots are misconfigured**, not a clean pass.
16
17
 
@@ -28,6 +29,8 @@ Validate the doc-code link graph. Walks `docs/`, `pan-wizard-core/`, `commands/`
28
29
  - `--source-root <path>` — override default source roots. Repeatable.
29
30
  - `--raw` — human-readable output instead of JSON.
30
31
 
32
+ **Run:** `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs links validate [--strict] [--doc-root <path>]... [--source-root <path>]... [--raw]` (`validate` may be left out when a flag comes first).
33
+
31
34
  **What it does:**
32
35
 
33
36
  Three sequential passes share one walk pair:
@@ -17,7 +17,7 @@ Analyze existing codebase using parallel pan-document_code agents to produce str
17
17
 
18
18
  Each mapper agent explores a focus area and **writes documents directly** to `.planning/codebase/`. The orchestrator only receives confirmations, keeping context usage minimal.
19
19
 
20
- Output: .planning/codebase/ folder with 7 structured documents about the codebase state.
20
+ Output: .planning/codebase/ folder with structured documents about the codebase state.
21
21
  </objective>
22
22
 
23
23
  <execution_context>
@@ -59,9 +59,9 @@ The CLI returns `{mode, total_tokens, file_count, languages}`:
59
59
  - **`mode: "single-shot"`** — repo is small enough (≤700K tokens) for one agent with a 1M-context window to ingest the whole thing. Spawn a single `pan-document_code` agent with the full repo in context. This avoids the 6-way stitching artifacts of sharded mode (contradictory version claims, duplicated mentions, missed cross-file references).
60
60
  - **`mode: "sharded"`** — repo exceeds 700K tokens. Fall back to the default 6-way parallel sharding (tech, arch, quality, concerns, relationships, practices). Each shard is mapped by its own agent in its own context window, so no single agent has to hold the whole repo.
61
61
 
62
- Record the chosen mode + telemetry in the final `.planning/codebase/overview.md` so future runs can reason about drift.
62
+ Record the chosen mode + telemetry in a `.planning/codebase/overview.md` you write yourself. The map-codebase workflow has no single-shot branch — it always spawns the sharded mappers and writes no overview.md — so in `single-shot` mode spawn the one agent in place of its spawn step.
63
63
 
64
- **The mode is decided by repo size alone** — `estimate-size` compares the token estimate to `--threshold` and applies no model check. So single-shot only pays off when the model you launched with actually has a 1M-context window (the default Opus and current Sonnet-class models do; legacy 200K-context models do not). On a 200K-context model, pass a threshold that matches your real window (e.g. `--threshold 150000`) so anything larger resolves to `sharded` instead of overflowing a single agent.
64
+ **The mode is decided by repo size alone** — `estimate-size` compares the token estimate to `--threshold` and applies no model check. So single-shot only pays off when the model you launched with actually has a 1M-context window. On a model with a smaller window, pass a threshold that matches your real window (e.g. `--threshold 150000`) so anything larger resolves to `sharded` instead of overflowing a single agent.
65
65
  </stage_0_ingest_mode>
66
66
 
67
67
  <tool_priority>
@@ -99,14 +99,14 @@ The orchestrator loads context in layers — NOT everything upfront. Mapper agen
99
99
  - Agent 5: relationships focus → writes relationships.md
100
100
  - Agent 6: practices focus → writes best-practices.md
101
101
  4. Wait for agents to complete, collect confirmations (NOT document contents)
102
- 5. Verify all 9 documents exist with line counts
102
+ 5. Verify all documents exist with line counts
103
103
  6. Commit codebase map
104
104
  7. Offer next steps (typically: /pan:new-project or /pan:plan-phase)
105
105
  </process>
106
106
 
107
107
  <success_criteria>
108
108
  - [ ] .planning/codebase/ directory created
109
- - [ ] All 7 codebase documents written by mapper agents
109
+ - [ ] All codebase documents written by mapper agents
110
110
  - [ ] Documents follow template structure
111
111
  - [ ] Parallel agents completed without errors
112
112
  - [ ] User knows next steps