pan-wizard 3.33.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 (197) hide show
  1. package/README.md +23 -20
  2. package/agents/pan-conductor.md +17 -16
  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 +14 -14
  9. package/agents/pan-executor.md +12 -8
  10. package/agents/pan-experiment-runner.md +8 -7
  11. package/agents/pan-integration-checker.md +2 -2
  12. package/agents/pan-knowledge.md +1 -1
  13. package/agents/pan-meta-reviewer.md +3 -3
  14. package/agents/pan-optimizer.md +39 -43
  15. package/agents/pan-phase-researcher.md +8 -8
  16. package/agents/pan-plan-checker.md +30 -28
  17. package/agents/pan-planner.md +54 -43
  18. package/agents/pan-previewer.md +1 -1
  19. package/agents/pan-project-researcher.md +11 -11
  20. package/agents/pan-release.md +1 -1
  21. package/agents/pan-research-synthesizer.md +2 -2
  22. package/agents/pan-reviewer.md +24 -2
  23. package/agents/pan-roadmapper.md +15 -14
  24. package/agents/pan-verifier.md +32 -24
  25. package/bin/install-lib.cjs +58 -23
  26. package/bin/install.js +47 -1
  27. package/commands/pan/army.md +15 -11
  28. package/commands/pan/assumptions.md +2 -2
  29. package/commands/pan/audit-deployment.md +11 -12
  30. package/commands/pan/cost.md +8 -4
  31. package/commands/pan/debug.md +10 -7
  32. package/commands/pan/design-phase.md +3 -3
  33. package/commands/pan/discuss-phase.md +2 -0
  34. package/commands/pan/exec-phase.md +21 -37
  35. package/commands/pan/experiment.md +9 -8
  36. package/commands/pan/focus-auto.md +22 -20
  37. package/commands/pan/focus-design.md +7 -6
  38. package/commands/pan/focus-doc-audit.md +4 -3
  39. package/commands/pan/focus-drift-walking.md +4 -3
  40. package/commands/pan/focus-exec.md +6 -6
  41. package/commands/pan/focus-plan.md +12 -11
  42. package/commands/pan/focus-scan.md +5 -3
  43. package/commands/pan/focus-sync.md +3 -2
  44. package/commands/pan/git.md +8 -8
  45. package/commands/pan/health.md +2 -2
  46. package/commands/pan/hud.md +3 -2
  47. package/commands/pan/hygiene.md +14 -7
  48. package/commands/pan/knowledge.md +9 -9
  49. package/commands/pan/learn.md +10 -7
  50. package/commands/pan/links.md +4 -1
  51. package/commands/pan/map-codebase.md +1 -1
  52. package/commands/pan/mcp-bridge.md +18 -18
  53. package/commands/pan/milestone-done.md +6 -3
  54. package/commands/pan/milestone-new.md +1 -1
  55. package/commands/pan/new-project.md +10 -10
  56. package/commands/pan/optimize.md +16 -14
  57. package/commands/pan/patches.md +2 -6
  58. package/commands/pan/pause.md +1 -1
  59. package/commands/pan/phase-tests.md +2 -1
  60. package/commands/pan/plan-phase.md +9 -19
  61. package/commands/pan/preview.md +1 -1
  62. package/commands/pan/profile.md +2 -2
  63. package/commands/pan/quick.md +1 -1
  64. package/commands/pan/remove-phase.md +1 -1
  65. package/commands/pan/report.md +2 -2
  66. package/commands/pan/research-phase.md +12 -11
  67. package/commands/pan/resume.md +9 -11
  68. package/commands/pan/retro.md +5 -3
  69. package/commands/pan/review-deep.md +7 -7
  70. package/commands/pan/settings.md +1 -1
  71. package/commands/pan/verify-phase.md +0 -11
  72. package/commands/pan/what-if.md +2 -2
  73. package/hooks/dist/pan-context-monitor.js +343 -44
  74. package/hooks/dist/pan-cost-logger.js +30 -0
  75. package/hooks/dist/pan-statusline.js +68 -22
  76. package/hooks/dist/pan-stop-guard.js +7 -2
  77. package/package.json +1 -1
  78. package/pan-wizard-core/bin/lib/agents-md.cjs +44 -6
  79. package/pan-wizard-core/bin/lib/bridge.cjs +6 -5
  80. package/pan-wizard-core/bin/lib/campaign.cjs +4 -2
  81. package/pan-wizard-core/bin/lib/commands-learnings.cjs +19 -2
  82. package/pan-wizard-core/bin/lib/commands.cjs +33 -4
  83. package/pan-wizard-core/bin/lib/config.cjs +2 -1
  84. package/pan-wizard-core/bin/lib/constants.cjs +18 -6
  85. package/pan-wizard-core/bin/lib/context-budget.cjs +12 -9
  86. package/pan-wizard-core/bin/lib/core.cjs +53 -19
  87. package/pan-wizard-core/bin/lib/cost-rebuild.cjs +13 -1
  88. package/pan-wizard-core/bin/lib/cost.cjs +142 -13
  89. package/pan-wizard-core/bin/lib/distill.cjs +6 -3
  90. package/pan-wizard-core/bin/lib/doc-lint.cjs +30 -11
  91. package/pan-wizard-core/bin/lib/findings.cjs +9 -2
  92. package/pan-wizard-core/bin/lib/focus.cjs +13 -4
  93. package/pan-wizard-core/bin/lib/frontmatter.cjs +105 -26
  94. package/pan-wizard-core/bin/lib/hygiene.cjs +178 -17
  95. package/pan-wizard-core/bin/lib/init.cjs +7 -4
  96. package/pan-wizard-core/bin/lib/knowledge.cjs +17 -1
  97. package/pan-wizard-core/bin/lib/learn-index.cjs +111 -10
  98. package/pan-wizard-core/bin/lib/learn-lint.cjs +30 -3
  99. package/pan-wizard-core/bin/lib/memory-optimize.cjs +8 -4
  100. package/pan-wizard-core/bin/lib/memory.cjs +508 -54
  101. package/pan-wizard-core/bin/lib/milestone.cjs +8 -3
  102. package/pan-wizard-core/bin/lib/optimize.cjs +84 -16
  103. package/pan-wizard-core/bin/lib/phase-remove.cjs +85 -21
  104. package/pan-wizard-core/bin/lib/phase-report.cjs +8 -2
  105. package/pan-wizard-core/bin/lib/phase.cjs +15 -13
  106. package/pan-wizard-core/bin/lib/preview.cjs +3 -1
  107. package/pan-wizard-core/bin/lib/roadmap-compact.cjs +267 -0
  108. package/pan-wizard-core/bin/lib/roadmap.cjs +243 -9
  109. package/pan-wizard-core/bin/lib/runner.cjs +2 -1
  110. package/pan-wizard-core/bin/lib/state-compact.cjs +11 -6
  111. package/pan-wizard-core/bin/lib/state.cjs +43 -28
  112. package/pan-wizard-core/bin/lib/template.cjs +11 -4
  113. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -13
  114. package/pan-wizard-core/bin/lib/verify-retro.cjs +5 -3
  115. package/pan-wizard-core/bin/lib/verify-scope.cjs +5 -2
  116. package/pan-wizard-core/bin/lib/verify.cjs +30 -28
  117. package/pan-wizard-core/bin/lib/whatif.cjs +5 -3
  118. package/pan-wizard-core/bin/pan-tools.cjs +101 -15
  119. package/pan-wizard-core/learnings/index.json +5 -5
  120. package/pan-wizard-core/opencode/pan-wizard.js +111 -0
  121. package/pan-wizard-core/references/checkpoints.md +3 -3
  122. package/pan-wizard-core/references/continuation-format.md +3 -3
  123. package/pan-wizard-core/references/decimal-phase-calculation.md +2 -3
  124. package/pan-wizard-core/references/design-methodology.md +1 -1
  125. package/pan-wizard-core/references/git-integration.md +4 -6
  126. package/pan-wizard-core/references/git-planning-commit.md +2 -2
  127. package/pan-wizard-core/references/guardrails.md +2 -2
  128. package/pan-wizard-core/references/handoff-decisions.md +3 -3
  129. package/pan-wizard-core/references/model-profile-resolution.md +5 -5
  130. package/pan-wizard-core/references/model-profiles.md +14 -9
  131. package/pan-wizard-core/references/phase-argument-parsing.md +7 -7
  132. package/pan-wizard-core/references/planning-config.md +4 -4
  133. package/pan-wizard-core/references/tdd.md +10 -1
  134. package/pan-wizard-core/references/verification-patterns.md +5 -5
  135. package/pan-wizard-core/templates/codebase/architecture.md +2 -2
  136. package/pan-wizard-core/templates/codebase/best-practices.md +2 -2
  137. package/pan-wizard-core/templates/codebase/concerns.md +3 -3
  138. package/pan-wizard-core/templates/codebase/integrations.md +6 -6
  139. package/pan-wizard-core/templates/codebase/relationships.md +2 -2
  140. package/pan-wizard-core/templates/codebase/stack.md +2 -2
  141. package/pan-wizard-core/templates/codebase/structure.md +4 -4
  142. package/pan-wizard-core/templates/codebase/testing.md +4 -4
  143. package/pan-wizard-core/templates/continue-here.md +1 -1
  144. package/pan-wizard-core/templates/debug-subagent-prompt.md +3 -2
  145. package/pan-wizard-core/templates/debug.md +15 -1
  146. package/pan-wizard-core/templates/milestone-archive.md +6 -6
  147. package/pan-wizard-core/templates/milestone.md +1 -1
  148. package/pan-wizard-core/templates/phase-prompt.md +29 -17
  149. package/pan-wizard-core/templates/planner-subagent-prompt.md +3 -5
  150. package/pan-wizard-core/templates/research-project/architecture.md +3 -3
  151. package/pan-wizard-core/templates/research-project/features.md +1 -1
  152. package/pan-wizard-core/templates/research-project/pitfalls.md +1 -1
  153. package/pan-wizard-core/templates/research-project/stack.md +3 -3
  154. package/pan-wizard-core/templates/research.md +5 -5
  155. package/pan-wizard-core/templates/retrospective.md +1 -1
  156. package/pan-wizard-core/templates/roadmap.md +15 -15
  157. package/pan-wizard-core/templates/summary-complex.md +1 -0
  158. package/pan-wizard-core/templates/summary-minimal.md +1 -0
  159. package/pan-wizard-core/templates/summary-standard.md +2 -1
  160. package/pan-wizard-core/templates/summary.md +18 -2
  161. package/pan-wizard-core/templates/uat.md +3 -3
  162. package/pan-wizard-core/templates/user-setup.md +8 -8
  163. package/pan-wizard-core/templates/verification-report.md +53 -8
  164. package/pan-wizard-core/workflows/add-phase.md +1 -1
  165. package/pan-wizard-core/workflows/assumptions.md +1 -1
  166. package/pan-wizard-core/workflows/discuss-phase.md +9 -8
  167. package/pan-wizard-core/workflows/exec-phase.md +26 -57
  168. package/pan-wizard-core/workflows/execute-plan.md +8 -7
  169. package/pan-wizard-core/workflows/health.md +13 -12
  170. package/pan-wizard-core/workflows/help.md +8 -9
  171. package/pan-wizard-core/workflows/learn.md +13 -11
  172. package/pan-wizard-core/workflows/map-codebase.md +10 -10
  173. package/pan-wizard-core/workflows/milestone-audit.md +10 -10
  174. package/pan-wizard-core/workflows/milestone-gaps.md +17 -24
  175. package/pan-wizard-core/workflows/milestone-new.md +7 -6
  176. package/pan-wizard-core/workflows/new-project.md +9 -9
  177. package/pan-wizard-core/workflows/optimize.md +11 -9
  178. package/pan-wizard-core/workflows/pause.md +6 -1
  179. package/pan-wizard-core/workflows/phase-tests.md +4 -4
  180. package/pan-wizard-core/workflows/plan-phase.md +31 -34
  181. package/pan-wizard-core/workflows/profile.md +2 -2
  182. package/pan-wizard-core/workflows/progress.md +5 -7
  183. package/pan-wizard-core/workflows/quick.md +5 -3
  184. package/pan-wizard-core/workflows/remove-phase.md +1 -1
  185. package/pan-wizard-core/workflows/research-phase.md +9 -5
  186. package/pan-wizard-core/workflows/resume-project.md +4 -6
  187. package/pan-wizard-core/workflows/retro.md +3 -1
  188. package/pan-wizard-core/workflows/settings.md +16 -24
  189. package/pan-wizard-core/workflows/todo-check.md +1 -1
  190. package/pan-wizard-core/workflows/transition.md +12 -12
  191. package/pan-wizard-core/workflows/update.md +25 -17
  192. package/pan-wizard-core/workflows/verify-phase.md +17 -15
  193. package/pan-zcode/KNOWN-BETA-RISKS.md +2 -2
  194. package/pan-zcode/README.md +7 -7
  195. package/pan-zcode/bin/install-zcode.js +1 -1
  196. package/scripts/build-plugin.js +3 -1
  197. package/scripts/generate-skills-docs.py +13 -4
@@ -10,16 +10,34 @@ Template for `.planning/phases/XX-name/{phase_num}-verification.md` — phase go
10
10
  ---
11
11
  phase: XX-name
12
12
  verified: YYYY-MM-DDTHH:MM:SSZ
13
- verified_commit: <sha> # git rev-parse HEAD before writing this file; `pan-tools verify stale` compares against it
13
+ # verified_commit: git rev-parse HEAD before writing this file; `pan-tools verify stale` compares against it
14
+ verified_commit: <sha>
14
15
  status: passed | gaps_found | human_needed
15
16
  score: N/M must-haves verified
16
17
  test_gate: passed | failed | skipped
17
- not_checked: # Only for checks that could not run, with why — a skipped test gate is one
18
- - check: "tests"
19
- reason: "no test script in package.json"
20
- unrequested: # Only when the scope check (`pan-tools verify scope <phase>`) found work no plan asked for
21
- - path: "src/admin/panel.tsx"
22
- what: "An admin panel no plan or requirement asked for"
18
+ # Only for checks that could not run, with why (a skipped test gate is one): write not_checked uncommented
19
+ # not_checked:
20
+ # - check: "tests"
21
+ # reason: "no test script in package.json"
22
+ # Only if status: gaps_found; read by `findings record` and /pan:plan-phase --gaps: write gaps uncommented
23
+ # gaps:
24
+ # - truth: "Observable truth that failed"
25
+ # status: failed
26
+ # reason: "Why it failed"
27
+ # artifacts:
28
+ # - path: "src/path/to/file.tsx"
29
+ # issue: "What's wrong"
30
+ # missing:
31
+ # - "Specific thing to add/fix"
32
+ # Only if status: human_needed: write human_verification uncommented
33
+ # human_verification:
34
+ # - test: "What to do"
35
+ # expected: "What should happen"
36
+ # why_human: "Why it cannot be verified programmatically"
37
+ # Only when the scope check (`pan-tools verify scope <phase>`) found work no plan asked for: write unrequested uncommented
38
+ # unrequested:
39
+ # - path: "src/admin/panel.tsx"
40
+ # what: "An admin panel no plan or requirement asked for"
23
41
  ---
24
42
 
25
43
  # Phase {X}: {Name} Verification Report
@@ -212,8 +230,35 @@ Unrequested work is recorded, not blocking: the status does not change because o
212
230
  ---
213
231
  phase: 03-chat
214
232
  verified: 2025-01-15T14:30:00Z
233
+ verified_commit: 4f2a9c1
215
234
  status: gaps_found
216
- score: 2/5 must-haves verified
235
+ score: 1/5 must-haves verified
236
+ test_gate: passed
237
+ gaps:
238
+ - truth: "User can see existing messages"
239
+ status: failed
240
+ reason: "Chat.tsx renders a placeholder, not message data"
241
+ artifacts:
242
+ - path: "src/components/Chat.tsx"
243
+ issue: "Returns a placeholder div and fetches nothing"
244
+ missing:
245
+ - "Fetch from /api/chat and render the messages"
246
+ - truth: "User can send a message"
247
+ status: failed
248
+ reason: "The onSubmit handler only logs"
249
+ artifacts:
250
+ - path: "src/components/ChatInput.tsx"
251
+ issue: "onSubmit calls console.log, no fetch"
252
+ missing:
253
+ - "POST to /api/chat on submit"
254
+ - truth: "Sent message appears in list"
255
+ status: failed
256
+ reason: "No state update after send, and the API routes return hardcoded values"
257
+ artifacts:
258
+ - path: "src/app/api/chat/route.ts"
259
+ issue: "GET returns [], POST returns { ok: true }, no database call"
260
+ missing:
261
+ - "prisma.message.findMany and create in the route handlers, and a list refresh after send"
217
262
  ---
218
263
 
219
264
  # Phase 3: Chat Interface Verification Report
@@ -52,7 +52,7 @@ The CLI handles:
52
52
  - Calculating next phase number (max + 1)
53
53
  - Generating slug from description
54
54
  - Creating the phase directory (`.planning/phases/{NN}-{slug}/`)
55
- - Inserting the phase entry into roadmap.md with Goal, Depends on, and Plans sections
55
+ - Inserting the phase into roadmap.md: its checklist line, and a section with Goal, Requirements, Depends on and Plans lines
56
56
 
57
57
  Extract from result: `phase_number`, `padded`, `name`, `slug`, `directory`.
58
58
  </step>
@@ -24,7 +24,7 @@ Exit workflow.
24
24
  Validate phase exists in roadmap:
25
25
 
26
26
  ```bash
27
- cat .planning/roadmap.md | grep -i "Phase ${PHASE}"
27
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${PHASE}" # found, phase_name, goal, success_criteria, section
28
28
  ```
29
29
 
30
30
  **If phase not found:**
@@ -130,7 +130,7 @@ Exit workflow.
130
130
  </step>
131
131
 
132
132
  <step name="auto_mode_bypass">
133
- **P-1803 fix (v3.7.8):** When `--auto` is set or `workflow.auto_advance: true`, **skip the entire question-driven discussion** and synthesize a minimal `context.md` directly from upstream artifacts. The 6 unguarded `AskUserQuestion` calls in this workflow (lines ~140, 156, 208, 261, 264, 278) all stall headless `claude -p` sessions immediately. Surfaced by the wookie autonomous build (v3.7.7): retry attempts via `/pan:discuss-phase 3 --auto` exited in 75s with $0.42 cost and zero commits before plan-phase auto-mode was patched to bypass discuss-phase entirely. This step makes discuss-phase itself auto-mode-safe, so it can be re-introduced into the auto pipeline cleanly.
133
+ **P-1803 fix (v3.7.8):** When `--auto` is set or `workflow.auto_advance: true`, **skip the entire question-driven discussion** and synthesize a minimal `context.md` directly from upstream artifacts. The unguarded `AskUserQuestion` calls in `check_existing`, `present_gray_areas` and `discuss_areas` all stall headless `claude -p` sessions immediately. Surfaced by the wookie autonomous build (v3.7.7): retry attempts via `/pan:discuss-phase 3 --auto` exited in 75s with $0.42 cost and zero commits before plan-phase auto-mode was patched to bypass discuss-phase entirely. This step makes discuss-phase itself auto-mode-safe, so it can be re-introduced into the auto pipeline cleanly.
134
134
 
135
135
  Detect auto mode:
136
136
 
@@ -152,7 +152,7 @@ Skip the interactive flow. Generate `context.md` from the roadmap goal + idea.md
152
152
 
153
153
  2. Read inputs:
154
154
  ```bash
155
- ROADMAP_GOAL=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${PHASE}" --raw | sed -n '/^Goal:/,/^$/p')
155
+ PHASE_JSON=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${PHASE}") # JSON: goal, success_criteria, section
156
156
  IDEA_PATH=".planning/idea.md"
157
157
  PROJECT_PATH=".planning/project.md"
158
158
  REQ_PATH=".planning/requirements.md"
@@ -170,7 +170,7 @@ REQ_PATH=".planning/requirements.md"
170
170
  <domain>
171
171
  ## Phase Boundary
172
172
 
173
- [Goal extracted verbatim from roadmap.md]
173
+ [The `goal` from PHASE_JSON, verbatim]
174
174
 
175
175
  </domain>
176
176
 
@@ -181,7 +181,7 @@ REQ_PATH=".planning/requirements.md"
181
181
  [For each item in idea.md "Constraints" / "Scope" / "Notes for the planner" sections that mentions Phase ${PHASE} or its domain keywords (e.g., "image pipeline" for Phase 3) — extract as a locked decision, prefixed with the domain name]
182
182
 
183
183
  ### From requirements.md
184
- [For each requirement marked Active that maps to Phase ${PHASE} via `requirements.md`'s phase column — list as a locked decision]
184
+ [For each requirement the phase's slice lists under "Its requirements" (`pan-tools roadmap slice ${PHASE} --raw`) — list as a locked decision]
185
185
 
186
186
  ### Claude's Discretion
187
187
  - Implementation patterns within the constraints above (the planner decides specific libraries / file layouts / function shapes)
@@ -213,7 +213,8 @@ None — auto-mode synthesis honors the original idea.md scope.
213
213
 
214
214
  Write the file:
215
215
  ```bash
216
- mkdir -p "${phase_dir}"
216
+ # phase_dir is null when the phase has no directory yet: create it (the printed path is phase_dir)
217
+ case "{phase_dir}" in ""|null) node ~/.claude/pan-wizard-core/bin/pan-tools.cjs scaffold phase-dir --phase "${PHASE}" --name "{phase_name}" --raw ;; esac
217
218
  # Use Write tool (NOT heredoc) to create ${phase_dir}/${PADDED_PHASE}-context.md
218
219
  ```
219
220
 
@@ -278,7 +279,7 @@ If "Cancel": Exit workflow.
278
279
  <step name="analyze_phase">
279
280
  Analyze the phase to identify gray areas worth discussing.
280
281
 
281
- **Read the phase description from roadmap.md and determine:**
282
+ **Read the phase's section (`roadmap get-phase "${PHASE}"`: `goal`, `success_criteria`, `section`) and determine:**
282
283
 
283
284
  1. **Domain boundary** — What capability is this phase delivering? State it clearly.
284
285
 
@@ -416,9 +417,9 @@ Create context.md capturing decisions made.
416
417
 
417
418
  Use values from init: `phase_dir`, `phase_slug`, `padded_phase`.
418
419
 
419
- If `phase_dir` is null (phase exists in roadmap but no directory):
420
+ If `phase_dir` is null (phase exists in roadmap but no directory), create it and use the printed path as `phase_dir`:
420
421
  ```bash
421
- mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
422
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs scaffold phase-dir --phase "${PHASE}" --name "{phase_name}" --raw
422
423
  ```
423
424
 
424
425
  **File location:** `${phase_dir}/${padded_phase}-context.md`
@@ -11,7 +11,7 @@ Read state.md before any operation to load project context.
11
11
 
12
12
  @~/.claude/pan-wizard-core/references/guardrails.md
13
13
 
14
- > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --token-budget 5000 --raw` to load only the topics tagged relevant for execution at the configured budget. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts. Files appear here over time as `pan-tools learn promote` adds findings.
14
+ > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --cue "<phase goal; the files it touches>" --token-budget 5000 --raw` to load the topics that match this task, within the budget; if none matches, it falls back to the topics tagged relevant for execution. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts. Files appear here over time as `pan-tools learn promote` adds findings.
15
15
  </required_reading>
16
16
 
17
17
  ## Re-Read Checkpoints
@@ -20,7 +20,7 @@ Context compaction may have dropped earlier sections. Re-read the relevant secti
20
20
 
21
21
  | Before this step | Re-read | Why |
22
22
  |------------------|---------|-----|
23
- | Spawning a subagent | This workflow's `<step name="execute">` block | Wave/segment routing is easy to misremember after compaction |
23
+ | Spawning a subagent | This workflow's `<step name="execute_waves">` block | Wave/segment routing is easy to misremember after compaction |
24
24
  | Writing code in a plan | `references/tdd.md` + plan file | Conventions and the plan's tasks drift across long sessions |
25
25
  | Committing | `references/guardrails.md` | Pre-commit shortcuts (silent model swaps, scope creep) are tempting under pressure |
26
26
  | Marking phase complete | `workflows/verify-phase.md` | Completion criteria are easy to misremember |
@@ -34,7 +34,7 @@ Load all context in one call:
34
34
  INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs init execute-phase "${PHASE_ARG}")
35
35
  ```
36
36
 
37
- Parse JSON for: `executor_model`, `verifier_model`, `reviewer_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
37
+ Parse JSON for: `executor_model`, `verifier_model`, `reviewer_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `verifier_enabled`.
38
38
 
39
39
  **If `phase_found` is false:** Error — phase directory not found.
40
40
  **If `plan_count` is 0:** Error — no plans found in phase.
@@ -49,6 +49,11 @@ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init \
49
49
  --command "exec-phase" \
50
50
  --phase "${PHASE_ARG}" 2>/dev/null || true
51
51
  ```
52
+
53
+ **The phase's roadmap slice** — what executing this phase needs from roadmap.md and requirements.md (a line per phase, this phase's section, its dependencies' goals, its requirement lines). Plans name it in their `<context>`; this writes it for plans made before it existed:
54
+ ```bash
55
+ SLICE_PATH=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap slice "${phase_number}" --write --raw)
56
+ ```
52
57
  </step>
53
58
 
54
59
  <step name="handle_branching">
@@ -70,42 +75,6 @@ From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
70
75
  Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
71
76
  </step>
72
77
 
73
- <step name="load_phase_memory">
74
- **Load project memory before dispatching executors — prevents re-learning patterns already solved.**
75
-
76
- ```bash
77
- ls .planning/memory/*.md 2>/dev/null
78
- ```
79
-
80
- If `.planning/memory/` exists and contains `.md` files:
81
- 1. **Check the memory-load budget first** (ADR-0036 — keeps per-agent injection bounded as logs grow):
82
- ```bash
83
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs memory budget --raw
84
- ```
85
- 2. **Load, size-gated — whole-file is the default:**
86
- - If `status` is `ok`: **read every file whole** (Read tool) and condense each entry to its rule(s) — 1–3 lines per file. This preserves the "apply every rule" contract for normal-sized logs.
87
- - If `status` is `warning` or `critical` (a log has grown large): load a **cue-scoped** slice per agent instead of the whole log, using the phase objective + the files this phase touches as the cue:
88
- ```bash
89
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs memory select <agent> --cue "<phase objective; changed files>" --raw
90
- ```
91
- Run once per agent that has a memory file. The returned `selected` entries are already recency-floored and token-budgeted (the newest lessons are always included). If `selected` is empty for an agent, **fall back to reading that file whole** — never silently drop an agent's memory.
92
- 3. Store the condensed rules as a `MEMORY_RULES` block for injection into executor prompts in execute_waves.
93
- 4. **Log memory priming to trace:**
94
- ```bash
95
- MEMORY_COUNT=$(ls .planning/memory/*.md 2>/dev/null | wc -l | tr -d ' ')
96
- if [ "$MEMORY_COUNT" -gt "0" ]; then
97
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
98
- --type decision --category memory_primed \
99
- --description "Loaded ${MEMORY_COUNT} memory entries before Wave 1 dispatch" \
100
- --agent orchestrator --impact minor \
101
- --context "{\"memory_count\":${MEMORY_COUNT}}" \
102
- 2>/dev/null || true
103
- fi
104
- ```
105
-
106
- If no memory files exist: skip (no trace event needed).
107
- </step>
108
-
109
78
  <step name="discover_and_group_plans">
110
79
  Load plan inventory with wave grouping in one call:
111
80
 
@@ -115,7 +84,7 @@ PLAN_INDEX=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs phase-plan-index "
115
84
 
116
85
  Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
117
86
 
118
- **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If all filtered: "No matching incomplete plans" → exit.
87
+ **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip plans whose frontmatter lacks `gap_closure: true` (`phase-plan-index` does not report it; `frontmatter get <plan> --field gap_closure` exits 1 when it is absent). If all filtered: "No matching incomplete plans" → exit.
119
88
 
120
89
  **If `--gaps-only`:** this run is the fix round after a verification found gaps — a second attempt at work that failed once. Resolve the executor for that attempt and use it in place of `executor_model` for every spawn in this run:
121
90
 
@@ -197,10 +166,7 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
197
166
  - .agents/skills/ (Project skills, if exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
198
167
  </files_to_read>
199
168
 
200
- <project_memory>
201
- {MEMORY_RULES — insert condensed content of all .planning/memory/*.md files read in load_phase_memory step. If no memory files exist, omit this block entirely.}
202
- Apply every rule in this block without exception. These are lessons from previous phases that the reviewer has already verified.
203
- </project_memory>
169
+ If the plan's `<context>` names `@.planning/roadmap.md`, read `{slice_path}` in its place: it carries this phase's section, its dependencies' goals and its requirements, and the whole roadmap is the largest file in `.planning/` on a long project. Open the whole file only for something the slice leaves out.
204
170
 
205
171
  <success_criteria>
206
172
  - [ ] All tasks executed
@@ -525,8 +491,8 @@ fi
525
491
 
526
492
  **2. Find parent UAT file:**
527
493
  ```bash
528
- PARENT_INFO=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs find-phase "${PARENT_PHASE}" --raw)
529
- # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
494
+ PARENT_DIR=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs find-phase "${PARENT_PHASE}" --raw)
495
+ # --raw prints the phase directory itself (empty when not found); find the UAT file in it
530
496
  ```
531
497
 
532
498
  **If no parent UAT found:** Skip this step (gap-closure may have been triggered by verification.md instead).
@@ -556,21 +522,24 @@ mv .planning/debug/{slug}.md .planning/debug/resolved/
556
522
 
557
523
  **6. Commit updated artifacts:**
558
524
  ```bash
559
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-uat.md .planning/debug/resolved/*.md
525
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-uat.md .planning/debug/
560
526
  ```
561
527
  </step>
562
528
 
563
529
  <step name="verify_phase_goal">
564
530
  Verify phase achieved its GOAL, not just completed tasks.
565
531
 
532
+ **If `verifier_enabled` is false** (`workflow.verifier: false`, set by `/pan:settings` or at project setup): skip this step. Say "verification skipped (workflow.verifier is off)" when you report the phase, and go to update_roadmap. `/pan:verify-phase {X}` still verifies on demand.
533
+
566
534
  ```
567
535
  Task(
568
536
  prompt="Verify phase {phase_number} goal achievement.
569
537
  Phase directory: {phase_dir}
570
538
  Phase goal: {goal from roadmap.md}
571
539
  Phase requirement IDs: {phase_req_ids}
540
+ Roadmap slice: {slice_path} — this phase's section, its dependencies' goals and its requirement lines. Read it instead of roadmap.md and requirements.md.
572
541
  Check must_haves against actual codebase.
573
- Cross-reference requirement IDs from PLAN frontmatter against requirements.md — every ID MUST be accounted for.
542
+ Cross-reference requirement IDs from PLAN frontmatter against the slice's requirement lines — every ID MUST be accounted for.
574
543
  Run the project's test suite as the test gate (the run_test_suite step of @~/.claude/pan-wizard-core/workflows/verify-phase.md) and record test_gate in the frontmatter.
575
544
  Create verification.md.",
576
545
  subagent_type="pan-verifier",
@@ -665,18 +634,18 @@ The report files are appended to the completion commit's `--files` list (`$REPOR
665
634
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs(phase-{X}): complete phase execution" --files .planning/roadmap.md .planning/state.md .planning/requirements.md {phase_dir}/*-verification.md $REPORT_FILES
666
635
  ```
667
636
 
668
- **Circular optimization — finalize trace session:**
669
- ```bash
670
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end 2>/dev/null || true
671
- ```
672
-
673
- Log phase completion event:
637
+ Log phase completion event (before the session ends: `trace end` clears the active-session pointer, and a `trace log` after it lands in a separate day-scoped `sess_auto_*` session):
674
638
  ```bash
675
639
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
676
640
  --type decision --category phase_complete \
677
- --description "Phase ${PHASE_NUMBER} execution complete (${VERIFICATION_STATUS:-verified})" \
641
+ --description "Phase ${PHASE_NUMBER} execution complete (${VERIF_STATUS:-verified})" \
678
642
  --agent orchestrator --impact minor 2>/dev/null || true
679
643
  ```
644
+
645
+ **Circular optimization — finalize trace session:**
646
+ ```bash
647
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end 2>/dev/null || true
648
+ ```
680
649
  </step>
681
650
 
682
651
  <step name="offer_next">
@@ -690,14 +659,14 @@ Parse `--no-transition` flag from $ARGUMENTS.
690
659
  **If `--no-transition` flag present:**
691
660
 
692
661
  Execute-phase was spawned by plan-phase's auto-advance. Do NOT run transition.md.
693
- After verification passes and roadmap is updated, return completion status to parent:
662
+ If verification found gaps, return `## GAPS FOUND` with the phase, score and gap summaries (plan-phase and discuss-phase stop the chain on it). After verification passes and roadmap is updated, return completion status to parent:
694
663
 
695
664
  ```
696
665
  ## PHASE COMPLETE
697
666
 
698
667
  Phase: ${PHASE_NUMBER} - ${PHASE_NAME}
699
668
  Plans: ${completed_count}/${total_count}
700
- Verification: {Passed | Gaps Found}
669
+ Verification: {Passed | Skipped (workflow.verifier is off)}
701
670
 
702
671
  [Include aggregate_results output]
703
672
  ```
@@ -9,7 +9,7 @@ Read config.json for planning behavior settings.
9
9
  @~/.claude/pan-wizard-core/references/git-integration.md
10
10
  @~/.claude/pan-wizard-core/references/guardrails.md
11
11
 
12
- > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --token-budget 5000 --raw` to load only the topics tagged relevant for execution at the configured budget. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts.
12
+ > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --cue "<plan objective; the files it modifies>" --token-budget 5000 --raw` to load the topics that match this task, within the budget; if none matches, it falls back to the topics tagged relevant for execution. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts.
13
13
  </required_reading>
14
14
 
15
15
  ## Re-Read Checkpoints
@@ -47,7 +47,8 @@ ls .planning/phases/XX-name/*-summary.md 2>/dev/null | sort
47
47
  Find first PLAN without matching SUMMARY. Decimal phases supported (`01.1-hotfix/`):
48
48
 
49
49
  ```bash
50
- PHASE=$(echo "$PLAN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
50
+ PHASE=$(basename "$PLAN_PATH" | grep -oE '^[0-9]+(\.[0-9]+)?')
51
+ PLAN=$(basename "$PLAN_PATH" | grep -oE '^[0-9]+(\.[0-9]+)?-[0-9]+' | cut -d- -f2)
51
52
  # config settings can be fetched via pan-tools config-get if needed
52
53
  ```
53
54
 
@@ -137,8 +138,8 @@ This IS the execution instructions. Follow exactly. If plan references context.m
137
138
 
138
139
  <step name="previous_phase_check">
139
140
  ```bash
140
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs phases list --type summaries --raw
141
- # Extract the second-to-last summary from the JSON result
141
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs phases list --type summaries
142
+ # Extract the second-to-last summary from the JSON result's files[] (file names only, in phase order)
142
143
  ```
143
144
  If previous SUMMARY has unresolved "Issues Encountered" or "Next Phase Readiness" blockers: AskUserQuestion(header="Previous Issues", options: "Proceed anyway" | "Address first" | "Review previous").
144
145
  </step>
@@ -277,7 +278,7 @@ TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
277
278
  <step name="checkpoint_protocol">
278
279
  On `type="checkpoint:*"`: automate everything possible first. Checkpoints are for verification/decisions only.
279
280
 
280
- Display: `CHECKPOINT: [Type]` box → Progress {X}/{Y} → Task name → type-specific content → `YOUR ACTION: [signal]`
281
+ Display: `CHECKPOINT: [Type]` box → Progress {X}/{Y} → Task name → type-specific content → the action prompt line `→ [signal]`
281
282
 
282
283
  | Type | Content | Resume signal |
283
284
  |------|---------|---------------|
@@ -333,7 +334,7 @@ Create `{phase}-{plan}-summary.md` at `.planning/phases/XX-name/`. Use `~/.claud
333
334
 
334
335
  **Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (**MUST** copy `requirements` array from plan.md frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date).
335
336
 
336
- Title: `# Phase [X] Plan [Y]: [Name] Summary`
337
+ Title: `# Phase [X]: [Name] Summary` (the summary template's)
337
338
 
338
339
  One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
339
340
 
@@ -382,7 +383,7 @@ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state record-session \
382
383
  --resume-file "None"
383
384
  ```
384
385
 
385
- Keep state.md under 150 lines.
386
+ Keep state.md under 100 lines (the state template's size constraint).
386
387
  </step>
387
388
 
388
389
  <step name="issues_review_gate">
@@ -11,13 +11,13 @@ Read all files referenced by the invoking prompt's execution_context before star
11
11
  <step name="parse_args">
12
12
  **Parse arguments:**
13
13
 
14
- Check if `--repair` flag is present in the command arguments.
14
+ Check which of `--repair`, `--standards`, `--full`, `--drift` and `--links` are present in the command arguments; `validate health` reads all five.
15
15
 
16
16
  ```
17
- REPAIR_FLAG=""
18
- if arguments contain "--repair"; then
19
- REPAIR_FLAG="--repair"
20
- fi
17
+ HEALTH_FLAGS=""
18
+ for flag in --repair --standards --full --drift --links; do
19
+ if arguments contain "$flag"; then HEALTH_FLAGS="$HEALTH_FLAGS $flag"; fi
20
+ done
21
21
  ```
22
22
  </step>
23
23
 
@@ -25,7 +25,7 @@ fi
25
25
  **Run health validation:**
26
26
 
27
27
  ```bash
28
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs validate health $REPAIR_FLAG
28
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs validate health $HEALTH_FLAGS
29
29
  ```
30
30
 
31
31
  Parse JSON output:
@@ -84,7 +84,7 @@ Errors: N | Warnings: N | Info: N
84
84
  ```
85
85
  ## Errors
86
86
 
87
- - [E001] config.json: JSON parse error at line 5
87
+ - [E005] config.json: JSON parse error - <parser message>
88
88
  Fix: Run /pan:health --repair to reset to defaults
89
89
 
90
90
  - [E002] project.md not found
@@ -95,7 +95,7 @@ Errors: N | Warnings: N | Info: N
95
95
  ```
96
96
  ## Warnings
97
97
 
98
- - [W001] state.md references phase 5, but only phases 1-3 exist
98
+ - [W002] state.md references phase 5, but only phases 01, 02, 03 exist
99
99
  Fix: Run /pan:health --repair to regenerate
100
100
 
101
101
  - [W005] Phase directory "1-setup" doesn't follow NN-name format
@@ -165,8 +165,8 @@ Report final status.
165
165
  | I003 | info | Focus-model or campaign tree — the phase-model checks do not apply | No |
166
166
  | I004 | info | planning-with-files shares the tree — PAN leaves its files alone | No |
167
167
  | I005 | info | The planning tree is gitignored while commit_docs is true — planning commits commit nothing | No |
168
- | I006 | info | config.json holds keys PAN does not read (usually a typo); the fix names the nearest known key | No |
169
- | STATE_REQ_DRIFT | warning | state.md complete but REQUIREMENTS.md has unchecked boxes | Yes |
168
+ | I006 | info | config.json holds keys PAN's code does not read (usually a typo); the fix names the nearest known key. It also lists `gates` and `safety` from templates/config.json: the `custom`-mode conditions in transition.md and execute-plan.md read `gates`; nothing reads `safety` (transition.md asks before skipping plans in every mode) | No |
169
+ | STATE_REQ_DRIFT | warning | state.md complete but requirements.md has unchecked boxes | Yes |
170
170
  | STATE_ROADMAP_DRIFT | warning | state.md complete but roadmap.md has unchecked plan boxes | Yes |
171
171
  | VERIFICATION_GATE_MISSING | warning | Phase has completed plans but no verification record | No |
172
172
 
@@ -176,7 +176,6 @@ Flag-gated codes:
176
176
  |------|----------|------|-------------|------------|
177
177
  | TESTS_FAIL | error | --full | Test run exited non-zero | No |
178
178
  | BUILD_FAIL | error | --full | Build exited non-zero | No |
179
- | MEM_BUDGET | warning / info | --full | Memory injection over budget | No |
180
179
  | DRIFT_HIGH | warning | --drift | Drift verdict is high | No |
181
180
  | DRIFT_MEDIUM | info | --drift | Drift verdict is medium | No |
182
181
  | LINKS_ERR | warning | --links | Link graph has errors | No |
@@ -197,7 +196,9 @@ or behind the current position warns.
197
196
  |--------|--------|------|
198
197
  | createConfig | Create config.json with defaults | None |
199
198
  | resetConfig | Delete + recreate config.json | Loses custom settings |
200
- | regenerateState | Create state.md from ROADMAP structure | Loses session history |
199
+ | regenerateState | Back up state.md to `state.md.bak-<timestamp>`, then create state.md from ROADMAP structure | Session history only in the backup |
200
+ | syncRequirements | Tick requirements.md boxes when state.md says every plan is done (STATE_REQ_DRIFT) | Edits requirements.md checkboxes |
201
+ | syncRoadmap | Tick roadmap.md plan boxes when state.md says every plan is done (STATE_ROADMAP_DRIFT) | Edits roadmap.md checkboxes |
201
202
 
202
203
  **Not repairable (too risky):**
203
204
  - project.md, roadmap.md content
@@ -119,7 +119,7 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
119
119
 
120
120
  **Reality Score:** Every P3-P6 item gets scored: `RS = (User Value + Time Criticality + Risk Reduction) / Job Size`. Items below RS 3.0 get deferred, below 1.5 get dropped.
121
121
 
122
- **Output:** `.planning/superplan_<date>.md` — the prioritized work list that `/pan:focus-plan` reads.
122
+ **Output:** the prioritized work list, returned by `pan-tools focus scan` as JSON (`/pan:focus-plan` collects the items again itself).
123
123
 
124
124
  **Flags:**
125
125
  - `--quick` — skip strategic analysis and validation phases
@@ -136,10 +136,10 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
136
136
  **Modes:**
137
137
  | Mode | Budget | Strategy |
138
138
  |------|--------|----------|
139
- | `bugfix` | 40 pts | P0→P1→smallest-first, no features |
139
+ | `bugfix` | 40 pts | One pass over P0→P4 in priority order, smallest first within a priority (P5–P6 excluded; no item-type filter) |
140
140
  | `balanced` | 50 pts | 60% stability / 40% features (default) |
141
141
  | `features` | 50 pts | 80% features, P0 crashes still mandatory |
142
- | `full` | 60 pts | All priorities equally weighted |
142
+ | `full` | 60 pts | One pass over every priority in priority order (P0 first, smallest first within a priority) |
143
143
 
144
144
  **Point system:** XS=1, S=2, M=4, L=10, XL=20 points.
145
145
 
@@ -183,8 +183,8 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
183
183
 
184
184
  **Flags:**
185
185
  - `--readme` — check README only
186
- - `--commands` — verify command files match implementations
187
- - `--agents` — verify agent files
186
+ - `--docs` — verify documentation matches implementations
187
+ - `--arch` — verify architecture docs match actual structure
188
188
  - `--all` — full sync + auto-fix
189
189
 
190
190
  ### Standalone: `/pan:focus-design <description>`
@@ -336,7 +336,7 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
336
336
 
337
337
  **`/pan:new-project`** — One command: deep questioning → optional domain research (4 parallel agents) → requirements → roadmap. Creates `.planning/` with project.md, roadmap.md, state.md, config.json, requirements.md.
338
338
 
339
- **`/pan:map-codebase`** — Analyze existing codebase before `/pan:new-project`. Creates `.planning/codebase/` with 7 documents (stack, architecture, structure, conventions, testing, integrations, concerns).
339
+ **`/pan:map-codebase`** — Analyze existing codebase before `/pan:new-project`. Creates `.planning/codebase/` with its codebase documents (stack, architecture, structure, conventions, testing, integrations, concerns, relationships, best-practices).
340
340
 
341
341
  **`/pan:discuss-phase <N>`** — Capture your vision for a phase before planning. Creates context.md.
342
342
 
@@ -394,7 +394,7 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
394
394
 
395
395
  **Planning config** (`.planning/config.json`):
396
396
  - `commit_docs: true` — commit planning artifacts to git (set `false` + add `.planning/` to `.gitignore` for private planning)
397
- - `search_gitignored: false` — add `--no-ignore` to ripgrep when `.planning/` is gitignored
397
+ - `search_gitignored: false` — reserved: read by `loadConfig` and reported by `init map-codebase`, but no workflow or agent acts on it (to search a gitignored `.planning/`, add `--no-ignore` to `rg` yourself)
398
398
 
399
399
  ---
400
400
 
@@ -409,10 +409,9 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
409
409
  ├── config.json # Workflow & gate configuration
410
410
  ├── focus/ # Focus batch files
411
411
  │ └── batch-YYYY-MM-DD.json
412
- ├── superplan_*.md # Focus scan output
413
412
  ├── todos/
414
413
  │ ├── pending/ # Todos waiting
415
- │ └── done/ # Completed todos
414
+ │ └── completed/ # Completed todos
416
415
  ├── debug/ # Active debug sessions
417
416
  │ └── resolved/ # Archived resolved issues
418
417
  ├── milestones/ # Archived milestones
@@ -27,11 +27,13 @@ Use the most recent session unless `--session <id>` was specified.
27
27
 
28
28
  If `--session <id>` was specified, use that session ID.
29
29
 
30
+ If `--experiment <slug>` was specified, set `EXP` to the harvest folder (the `harvest_path` `/pan:experiment harvest <slug>` printed, `<source-repo>/experiments/<slug>/` by default), add `--cwd "$EXP"` to every `pan-tools` call in this workflow, and read and write every `.planning/optimization/` path below under `$EXP/`.
31
+
30
32
  ## Step 2 — Generate local analysis
31
33
 
32
34
  Run:
33
35
  ```
34
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize learn [--session <id> | --sessions <n>]
36
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize learn [--session <id> | --sessions <n>] # with no active session, pass --session <id> for the session Step 1 chose: a bare call errors "No trace session active"
35
37
  ```
36
38
 
37
39
  This produces `.planning/optimization/reports/{session}-analysis.json`. With `--sessions <n>` it pools the last n sessions into `pooled-<n>-{session}-analysis.json`: a recommendation should explain failures that recur across runs, not one run's accident.
@@ -39,18 +41,18 @@ This produces `.planning/optimization/reports/{session}-analysis.json`. With `--
39
41
  Read the output and note:
40
42
  - `summary.errors` — how many error events
41
43
  - `summary.gaps` — how many gap events
42
- - `summary.memory_misses` — how many memory miss events
44
+ - `summary.memory_misses` — how many times an agent logged missing knowledge (`memory_miss` events)
43
45
  - `summary.wasted_tokens` — tokens wasted on redundancies
44
46
  - `top_error_patterns` — most frequent error categories
45
47
  - `top_tool_error_patterns` — failed tool calls captured from the subagents' own transcripts, ranked by how many spawns hit them
46
48
  - `verdict_stats` — each judge's pass/fail counts, retries, and the retries that resolved a failure
47
- - `top_memory_misses` — most frequent memory miss topics
49
+ - `top_memory_misses` — the topics most often logged as missing
48
50
 
49
51
  ## Step 3 — Invoke pan-optimizer agent
50
52
 
51
53
  Spawn the `pan-optimizer` agent with this instruction:
52
54
 
53
- > Read the analysis at `.planning/optimization/reports/{session}-analysis.json` and the raw trace at `.planning/optimization/traces/{session}/trace.jsonl`. Also read any existing memory at `.planning/memory/*.md` to understand what's already known. Produce a full optimization report at `.planning/optimization/reports/{session}-opt-report.md` following the format in your agent definition.
55
+ > Read the analysis at `{analysis_path}` (the path `optimize learn` printed: `{session}-analysis.json`, or `pooled-<n>-{session}-analysis.json` with `--sessions`) and the raw trace at `.planning/optimization/traces/{session}/trace.jsonl`. Produce a full optimization report at `.planning/optimization/reports/{session}-opt-report.md` following the format in your agent definition.
54
56
 
55
57
  Wait for the agent to complete. It will write the report to `.planning/optimization/reports/`.
56
58
 
@@ -61,9 +63,9 @@ Read `.planning/optimization/reports/{session}-opt-report.md`.
61
63
  Present to the user:
62
64
  1. **Score** — the circular optimization score (0–100)
63
65
  2. **Top 3 findings** — the most impactful recommendations
64
- 3. **Auto-applicable count** — how many items `/pan:optimize apply` can handle automatically
65
- 4. **Review required count** — how many prompt/workflow suggestions need human review
66
- 5. **Next step** — suggest running `/pan:optimize apply` to apply safe optimizations
66
+ 3. **Lessons** — how many, and where each belongs: the project's instructions (CLAUDE.md or AGENTS.md, outside PAN's section), a test, or a comment at the cited code
67
+ 4. **Prompt and workflow changes** — how many, for human review
68
+ 5. **Next step** — `/pan:optimize apply` records the suggestions in `.planning/optimization/suggestions.md`; a person makes the changes, because nothing in the report reaches an agent until it is written where the agents read
67
69
 
68
70
  ## Step 5 — Auto-apply (if --apply flag)
69
71
 
@@ -72,14 +74,14 @@ If the `--apply` flag was passed, immediately run:
72
74
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize apply
73
75
  ```
74
76
 
75
- Show what was applied and what still needs review.
77
+ Show what was recorded and where each suggestion belongs.
76
78
 
77
79
  ## Step 6 — Update the circular score baseline
78
80
 
79
81
  After applying, tell the user what to watch in the next run:
80
- - Which memory gaps were filled (will reduce `memory_miss` events)
81
- - Which error patterns were documented (will reduce repeat errors if agent reads memory)
82
- - Prompt/workflow changes to consider applying manually
82
+ - Which lessons they wrote into the project's instructions, tests or code (the next trace should show fewer of those gaps and `memory_miss` events)
83
+ - Which error patterns a prompt or workflow change addressed
84
+ - Prompt/workflow changes still to consider
83
85
 
84
86
  ## Edge cases
85
87