pan-wizard 3.22.0 → 3.24.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 (134) hide show
  1. package/README.md +38 -24
  2. package/agents/pan-conductor.md +3 -3
  3. package/agents/pan-design-checker.md +83 -0
  4. package/agents/pan-designer.md +67 -0
  5. package/agents/pan-document_code.md +3 -2
  6. package/agents/pan-executor.md +2 -2
  7. package/agents/pan-plan-checker.md +19 -6
  8. package/agents/pan-planner.md +4 -1
  9. package/agents/pan-previewer.md +1 -1
  10. package/agents/pan-roadmapper.md +3 -1
  11. package/agents/pan-verifier.md +10 -10
  12. package/bin/install-lib.cjs +128 -17
  13. package/bin/install.js +480 -74
  14. package/commands/pan/army.md +20 -14
  15. package/commands/pan/audit-deployment.md +17 -14
  16. package/commands/pan/cost.md +2 -2
  17. package/commands/pan/debug.md +1 -1
  18. package/commands/pan/design-phase.md +77 -0
  19. package/commands/pan/exec-phase.md +2 -2
  20. package/commands/pan/experiment.md +18 -14
  21. package/commands/pan/focus-auto.md +5 -5
  22. package/commands/pan/focus-design.md +13 -1
  23. package/commands/pan/focus-exec.md +1 -1
  24. package/commands/pan/learn.md +1 -1
  25. package/commands/pan/links.md +3 -1
  26. package/commands/pan/map-codebase.md +4 -4
  27. package/commands/pan/mcp-bridge.md +1 -1
  28. package/commands/pan/milestone-new.md +3 -1
  29. package/commands/pan/optimize.md +2 -2
  30. package/commands/pan/patches.md +1 -1
  31. package/commands/pan/plan-phase.md +3 -1
  32. package/commands/pan/preview.md +3 -3
  33. package/commands/pan/profile.md +3 -3
  34. package/commands/pan/research-phase.md +1 -1
  35. package/commands/pan/retro.md +4 -1
  36. package/commands/pan/review-deep.md +1 -1
  37. package/commands/pan/settings.md +2 -2
  38. package/commands/pan/what-if.md +1 -1
  39. package/hooks/dist/pan-check-update.js +149 -38
  40. package/hooks/dist/pan-context-monitor.js +155 -81
  41. package/hooks/dist/pan-cost-logger.js +288 -13
  42. package/hooks/dist/pan-statusline.js +24 -8
  43. package/hooks/dist/pan-stop-guard.js +160 -0
  44. package/hooks/dist/pan-trace-logger.js +261 -19
  45. package/package.json +2 -2
  46. package/pan-wizard-core/bin/lib/bridge.cjs +1 -1
  47. package/pan-wizard-core/bin/lib/bus.cjs +19 -4
  48. package/pan-wizard-core/bin/lib/campaign.cjs +8 -3
  49. package/pan-wizard-core/bin/lib/codebase.cjs +15 -5
  50. package/pan-wizard-core/bin/lib/commands.cjs +88 -6
  51. package/pan-wizard-core/bin/lib/config.cjs +27 -2
  52. package/pan-wizard-core/bin/lib/constants.cjs +1 -0
  53. package/pan-wizard-core/bin/lib/core.cjs +113 -8
  54. package/pan-wizard-core/bin/lib/cost.cjs +61 -24
  55. package/pan-wizard-core/bin/lib/distill.cjs +22 -4
  56. package/pan-wizard-core/bin/lib/doc-lint.cjs +25 -7
  57. package/pan-wizard-core/bin/lib/experiment.cjs +25 -1
  58. package/pan-wizard-core/bin/lib/focus.cjs +42 -7
  59. package/pan-wizard-core/bin/lib/frontmatter.cjs +62 -31
  60. package/pan-wizard-core/bin/lib/git.cjs +51 -16
  61. package/pan-wizard-core/bin/lib/hud.cjs +17 -2
  62. package/pan-wizard-core/bin/lib/init.cjs +2 -5
  63. package/pan-wizard-core/bin/lib/knowledge.cjs +20 -1
  64. package/pan-wizard-core/bin/lib/learn-lint.cjs +50 -0
  65. package/pan-wizard-core/bin/lib/links.cjs +9 -6
  66. package/pan-wizard-core/bin/lib/lock.cjs +23 -4
  67. package/pan-wizard-core/bin/lib/memory-optimize.cjs +11 -6
  68. package/pan-wizard-core/bin/lib/milestone.cjs +11 -5
  69. package/pan-wizard-core/bin/lib/optimize.cjs +18 -7
  70. package/pan-wizard-core/bin/lib/phase-remove.cjs +41 -2
  71. package/pan-wizard-core/bin/lib/phase.cjs +82 -11
  72. package/pan-wizard-core/bin/lib/preview.cjs +23 -4
  73. package/pan-wizard-core/bin/lib/review-deep.cjs +14 -6
  74. package/pan-wizard-core/bin/lib/roadmap.cjs +6 -2
  75. package/pan-wizard-core/bin/lib/runner.cjs +17 -7
  76. package/pan-wizard-core/bin/lib/squads.cjs +43 -11
  77. package/pan-wizard-core/bin/lib/state.cjs +32 -11
  78. package/pan-wizard-core/bin/lib/template.cjs +8 -3
  79. package/pan-wizard-core/bin/lib/verify-deploy.cjs +14 -2
  80. package/pan-wizard-core/bin/lib/verify-drift.cjs +15 -1
  81. package/pan-wizard-core/bin/lib/verify-preflight.cjs +9 -3
  82. package/pan-wizard-core/bin/lib/verify.cjs +84 -39
  83. package/pan-wizard-core/bin/lib/whatif.cjs +8 -1
  84. package/pan-wizard-core/bin/pan-tools.cjs +42 -19
  85. package/pan-wizard-core/learnings/index.json +7 -7
  86. package/pan-wizard-core/learnings/universal/autonomous-loop.md +5 -3
  87. package/pan-wizard-core/learnings/universal/concurrency.md +1 -1
  88. package/pan-wizard-core/references/design-methodology.md +94 -0
  89. package/pan-wizard-core/references/git-integration.md +9 -9
  90. package/pan-wizard-core/references/guardrails.md +4 -1
  91. package/pan-wizard-core/references/model-profile-resolution.md +1 -1
  92. package/pan-wizard-core/references/model-profiles.md +44 -34
  93. package/pan-wizard-core/references/planning-config.md +5 -5
  94. package/pan-wizard-core/references/verification-patterns.md +67 -0
  95. package/pan-wizard-core/templates/codebase/architecture.md +1 -1
  96. package/pan-wizard-core/templates/codebase/concerns.md +1 -1
  97. package/pan-wizard-core/templates/codebase/conventions.md +1 -1
  98. package/pan-wizard-core/templates/codebase/integrations.md +1 -1
  99. package/pan-wizard-core/templates/codebase/stack.md +1 -1
  100. package/pan-wizard-core/templates/codebase/structure.md +1 -1
  101. package/pan-wizard-core/templates/codebase/testing.md +1 -1
  102. package/pan-wizard-core/templates/design.md +146 -0
  103. package/pan-wizard-core/templates/discovery.md +3 -3
  104. package/pan-wizard-core/templates/milestone-archive.md +2 -2
  105. package/pan-wizard-core/templates/playbook.md +1 -1
  106. package/pan-wizard-core/templates/uat.md +1 -1
  107. package/pan-wizard-core/workflows/diagnose-issues.md +9 -7
  108. package/pan-wizard-core/workflows/exec-phase.md +28 -8
  109. package/pan-wizard-core/workflows/execute-plan.md +2 -3
  110. package/pan-wizard-core/workflows/health.md +24 -1
  111. package/pan-wizard-core/workflows/help.md +5 -4
  112. package/pan-wizard-core/workflows/learn.md +5 -5
  113. package/pan-wizard-core/workflows/map-codebase.md +1 -1
  114. package/pan-wizard-core/workflows/milestone-audit.md +1 -1
  115. package/pan-wizard-core/workflows/milestone-new.md +4 -4
  116. package/pan-wizard-core/workflows/new-project.md +47 -32
  117. package/pan-wizard-core/workflows/optimize.md +8 -8
  118. package/pan-wizard-core/workflows/pause.md +1 -1
  119. package/pan-wizard-core/workflows/phase-tests.md +2 -2
  120. package/pan-wizard-core/workflows/plan-phase.md +4 -0
  121. package/pan-wizard-core/workflows/profile.md +13 -10
  122. package/pan-wizard-core/workflows/research-phase.md +1 -1
  123. package/pan-wizard-core/workflows/resume-project.md +1 -1
  124. package/pan-wizard-core/workflows/settings.md +9 -9
  125. package/pan-wizard-core/workflows/transition.md +24 -8
  126. package/pan-wizard-core/workflows/update.md +23 -20
  127. package/pan-wizard-core/workflows/verify-phase.md +7 -2
  128. package/pan-zcode/README.md +12 -2
  129. package/pan-zcode/bin/install-zcode.js +1 -1
  130. package/pan-zcode/mcp/native-tools.cjs +1 -1
  131. package/pan-zcode/mcp/server.cjs +76 -14
  132. package/scripts/build-hooks.js +2 -1
  133. package/scripts/generate-skills-docs.py +0 -4
  134. package/scripts/run-tests.cjs +11 -4
@@ -64,7 +64,7 @@ Spawning parallel debug agents to investigate root causes:
64
64
  | Delete removes comment | blocker |
65
65
 
66
66
  Each agent will:
67
- 1. Create DEBUG-{slug}.md with symptoms pre-filled
67
+ 1. Create ${DEBUG_DIR}/{slug}.md with symptoms pre-filled
68
68
  2. Investigate autonomously (read code, form hypotheses, test)
69
69
  3. Return root cause
70
70
 
@@ -80,22 +80,24 @@ For each gap, fill the debug-subagent-prompt template and spawn:
80
80
  ```
81
81
  Task(
82
82
  prompt=filled_debug_subagent_prompt + "\n\n<files_to_read>\n- {phase_dir}/{phase_num}-uat.md\n- .planning/state.md\n</files_to_read>",
83
- subagent_type="general-purpose",
84
- description="Debug: {truth_short}"
83
+ subagent_type="pan-debugger",
84
+ description="Debug: {issue_summary_short}"
85
85
  )
86
86
  ```
87
87
 
88
88
  **All agents spawn in single message** (parallel execution).
89
89
 
90
- Template placeholders:
91
- - `{truth}`: The expected behavior that failed
90
+ Template placeholders (see `debug-subagent-prompt.md`):
91
+ - `{issue_id}`: Stable id for the gap, e.g. `UAT-{test_num}`
92
+ - `{issue_summary}`: The expected behavior that failed
92
93
  - `{expected}`: From UAT test
93
94
  - `{actual}`: Verbatim user description from reason field
94
95
  - `{errors}`: Any error messages from UAT (or "None reported")
95
96
  - `{reproduction}`: "Test {test_num} in UAT"
96
97
  - `{timeline}`: "Discovered during UAT"
98
+ - `{true_or_false}`: `true` (symptoms are prefilled from the UAT gap)
97
99
  - `{goal}`: `find_root_cause_only` (UAT flow - plan-phase --gaps handles fixes)
98
- - `{slug}`: Generated from truth
100
+ - `{slug}`: Generated from the issue summary
99
101
  </step>
100
102
 
101
103
  <step name="collect_results">
@@ -200,7 +202,7 @@ Agents only diagnose—plan-phase --gaps handles fixes (no fix application).
200
202
  - Report incomplete diagnosis
201
203
 
202
204
  **Agent times out:**
203
- - Check DEBUG-{slug}.md for partial progress
205
+ - Check ${DEBUG_DIR}/{slug}.md for partial progress
204
206
  - Can resume with /pan:debug
205
207
 
206
208
  **All agents fail:**
@@ -160,7 +160,7 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
160
160
 
161
161
  2. **Spawn executor agents:**
162
162
 
163
- Pass paths only — executors read files themselves with their fresh 200k context.
163
+ Pass paths only — executors read files themselves in their own fresh context window.
164
164
  This keeps orchestrator context lean (~10-15%).
165
165
 
166
166
  ```
@@ -286,11 +286,23 @@ When executor returns a checkpoint AND `AUTO_CFG` is `"true"`:
286
286
  [Awaiting section from agent return]
287
287
  ```
288
288
  5. User responds: "approved"/"done" | issue description | decision selection
289
- 6. **Spawn continuation agent (NOT resume)** using continuation-prompt.md template:
290
- - `{completed_tasks_table}`: From checkpoint return
291
- - `{resume_task_number}` + `{resume_task_name}`: Current task
292
- - `{user_response}`: What user provided
293
- - `{resume_instructions}`: Based on checkpoint type
289
+ 6. **Spawn continuation agent (NOT resume)** with a prompt built inline from this structure:
290
+ ```
291
+ Continue executing plan {plan_id}. A previous agent paused at a checkpoint.
292
+
293
+ ## Already completed
294
+ {completed_tasks_table} ← the completed-tasks table from the checkpoint return
295
+
296
+ ## Resume point
297
+ Task {resume_task_number}: {resume_task_name} ← the current (paused) task
298
+ User response to checkpoint: {user_response} ← "approved"/"done", the chosen decision option, or the issue description the user typed
299
+
300
+ ## Instructions
301
+ {resume_instructions} ← derived from the checkpoint type: human-verify → "resume the paused task";
302
+ decision → "apply the selected option, then continue"; issue → "address the
303
+ described issue first, then continue". Verify the previous commits before proceeding.
304
+ ```
305
+ All five placeholders are defined here — there is no separate template file to load.
294
306
  7. Continuation agent verifies previous commits, continues from resume point
295
307
  8. Repeat until plan completes or user stops
296
308
 
@@ -602,7 +614,7 @@ The CLI handles:
602
614
 
603
615
  Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
604
616
 
605
- **Phase reports (opt-in build deliverable):** when `workflow.phase_reports.enabled` is `true`, generate the self-contained per-phase HTML report — and, when `workflow.phase_reports.index` is `true`, the project timeline index — at this verify→complete gate so they ship with the phase and ride the commit below. Disabled by default; phase-less projects are skipped automatically by `report`. Never opens a browser here (that's reserved for a manual `pan-tools report --open`).
617
+ **Phase reports (opt-in build deliverable):** when `workflow.phase_reports.enabled` is `true`, generate the self-contained per-phase HTML report — and, when `workflow.phase_reports.index` is `true`, the project timeline index — at this verify→complete gate so they ship with the phase and ride the commit below. Disabled by default; phase-less projects are skipped automatically by `report`. Never opens a browser here (that's reserved for a manual `pan-tools report index --open`).
606
618
 
607
619
  ```bash
608
620
  REPORT_FILES=""
@@ -704,6 +716,10 @@ STOP — do not auto-advance. Return to user.
704
716
  ```bash
705
717
  AUTO_CFG=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs config-get workflow.auto_advance 2>/dev/null || echo "false")
706
718
  ```
719
+ 3. **If `--auto` flag present AND `AUTO_CFG` is not true — persist it** (same as discuss-phase's auto_advance step). The flag lives only in this invocation's arguments; the rest of the chain, and the P-1809 stop guard, can only see the run as autonomous if the disk says so (P-1810 — the guard missed a real boundary drop because a flag-driven run left config unarmed):
720
+ ```bash
721
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs config-set workflow.auto_advance true
722
+ ```
707
723
 
708
724
  **If `--auto` flag present OR `AUTO_CFG` is true (AND verification passed with no gaps):**
709
725
 
@@ -718,6 +734,10 @@ Execute the transition workflow inline (do NOT use Task — orchestrator context
718
734
 
719
735
  Read and follow `~/.claude/pan-wizard-core/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
720
736
 
737
+ **Contract (P-1807):** transition.md's continuation gates key on the same trigger you just evaluated (`--auto` flag, `workflow.auto_advance`, or `mode: yolo`) — NOT on `mode` alone. Having announced AUTO-ADVANCING, the transition must end in a `Task(...)` spawn of the next phase (Route A) or reach the milestone boundary (Route B). If you find yourself printing a "Next Up" menu and stopping after the banner above, that is the P-1801/P-1807 regression, not a valid outcome.
738
+
739
+ **Post-transition self-check (MANDATORY final action in auto mode):** after transition.md finishes, confirm one of its two valid terminal states actually happened: (a) a `Task(...)` spawn for the next phase was issued (Route A), or (b) the milestone boundary was reached (Route B). If neither — state was updated but no spawn went out — you are inside the P-1801/P-1807 failure right now: return to transition.md `offer_next_phase` Route A and issue the Task spawn before ending your turn.
740
+
721
741
  **If neither `--auto` nor `AUTO_CFG` is true:**
722
742
 
723
743
  The workflow ends. The user runs `/pan:progress` or invokes the transition workflow manually.
@@ -726,7 +746,7 @@ The workflow ends. The user runs `/pan:progress` or invokes the transition workf
726
746
  </process>
727
747
 
728
748
  <context_efficiency>
729
- Orchestrator: ~10-15% context. Subagents: fresh 200k each. No polling (Task blocks). No context bleed.
749
+ Orchestrator: ~10-15% context. Subagents: a fresh window each. No polling (Task blocks). No context bleed.
730
750
  </context_efficiency>
731
751
 
732
752
  <failure_handling>
@@ -94,14 +94,13 @@ Fresh context per subagent preserves peak quality. Main context stays lean.
94
94
  if [ ! -f .planning/agent-history.json ]; then
95
95
  echo '{"version":"1.0","max_entries":50,"entries":[]}' > .planning/agent-history.json
96
96
  fi
97
- rm -f .planning/current-agent-id.txt
98
97
  if [ -f .planning/current-agent-id.txt ]; then
99
98
  INTERRUPTED_ID=$(cat .planning/current-agent-id.txt)
100
99
  echo "Found interrupted agent: $INTERRUPTED_ID"
101
100
  fi
102
101
  ```
103
102
 
104
- If interrupted: ask user to resume (Task `resume` parameter) or start fresh.
103
+ If interrupted: ask user to resume (Task `resume` parameter) or start fresh. Only AFTER that decision (per the tracking protocol below — resume detection must see the stale id first) clear the marker with `rm -f .planning/current-agent-id.txt`.
105
104
 
106
105
  **Tracking protocol:** On spawn: write agent_id to `current-agent-id.txt`, append to agent-history.json: `{"agent_id":"[id]","task_description":"[desc]","phase":"[phase]","plan":"[plan]","segment":[num|null],"timestamp":"[ISO]","status":"spawned","completion_timestamp":null}`. On completion: status → "completed", set completion_timestamp, delete current-agent-id.txt. Prune: if entries > max_entries, remove oldest "completed" (never "spawned").
107
106
 
@@ -423,7 +422,7 @@ FIRST_TASK=$(git log --oneline --grep="feat({phase}-{plan}):" --grep="fix({phase
423
422
  git diff --name-only ${FIRST_TASK}^..HEAD 2>/dev/null
424
423
  ```
425
424
 
426
- Update only structural changes: new src/ dir → STRUCTURE.md | deps → STACK.md | file pattern → CONVENTIONS.md | API client → INTEGRATIONS.md | config → STACK.md | renamed → update paths. Skip code-only/bugfix/content changes.
425
+ Update only structural changes: new src/ dir → structure.md | deps → stack.md | file pattern → conventions.md | API client → integrations.md | config → stack.md | renamed → update paths. Skip code-only/bugfix/content changes.
427
426
 
428
427
  ```bash
429
428
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "" --files .planning/codebase/*.md --amend
@@ -157,9 +157,32 @@ Report final status.
157
157
  | W003 | warning | config.json not found | Yes |
158
158
  | W004 | warning | config.json invalid field value | No |
159
159
  | W005 | warning | Phase directory naming mismatch | No |
160
- | W006 | warning | Phase in ROADMAP but no directory | No |
160
+ | W006 | warning | Phase in ROADMAP at or behind current phase, but no directory | No |
161
161
  | W007 | warning | Phase on disk but not in ROADMAP | No |
162
162
  | I001 | info | Plan without SUMMARY (may be in progress) | No |
163
+ | I002 | info | Phase in ROADMAP ahead of current phase, not planned yet | No |
164
+ | STATE_REQ_DRIFT | warning | state.md complete but REQUIREMENTS.md has unchecked boxes | Yes |
165
+ | STATE_ROADMAP_DRIFT | warning | state.md complete but roadmap.md has unchecked plan boxes | Yes |
166
+ | VERIFICATION_GATE_MISSING | warning | Phase has completed plans but no verification record | No |
167
+
168
+ Flag-gated codes:
169
+
170
+ | Code | Severity | Flag | Description | Repairable |
171
+ |------|----------|------|-------------|------------|
172
+ | TESTS_FAIL | error | --full | Test run exited non-zero | No |
173
+ | BUILD_FAIL | error | --full | Build exited non-zero | No |
174
+ | MEM_BUDGET | warning / info | --full | Memory injection over budget | No |
175
+ | DRIFT_HIGH | warning | --drift | Drift verdict is high | No |
176
+ | DRIFT_MEDIUM | info | --drift | Drift verdict is medium | No |
177
+ | LINKS_ERR | warning | --links | Link graph has errors | No |
178
+ | STD-000 | info | --standards | No standards.md found | No |
179
+ | STD-001 | info | --standards | standards.md has no recognized standards | No |
180
+ | STD-*id* | warning / info | --standards | Per-standard coverage (warning at 0%) | No |
181
+ | STD-SUMMARY | info | --standards | Overall coverage across standards | No |
182
+
183
+ **I002 vs W006:** a roadmap phase the project has not reached yet is normal progress,
184
+ not a defect — it reports as info and does not degrade health. Only a missing phase at
185
+ or behind the current position warns.
163
186
 
164
187
  </error_codes>
165
188
 
@@ -1,5 +1,5 @@
1
1
  <purpose>
2
- Display the complete PAN command reference. Output ONLY the reference content. Do NOT add project-specific analysis, git status, next-step suggestions, or any commentary beyond the reference.
2
+ Display the PAN command reference. Output ONLY the reference content. Do NOT add project-specific analysis, git status, next-step suggestions, or any commentary beyond the reference.
3
3
  </purpose>
4
4
 
5
5
  <reference>
@@ -148,7 +148,6 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
148
148
  **Flags:**
149
149
  - `--mode <mode>` — select execution mode (default: balanced)
150
150
  - `--budget N` — override point budget (5-100)
151
- - `--dry-run` — show what would be selected without writing
152
151
  - `--lean` — exclude items with RS < 1.5
153
152
 
154
153
  ### Step 3: `/pan:focus-exec`
@@ -208,7 +207,9 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
208
207
 
209
208
  ---
210
209
 
211
- ## All Commands (42)
210
+ ## All Commands
211
+
212
+ > This table is a **curated subset** of the most-used commands, not an exhaustive list. For the full, always-current command set, browse the `commands/pan/*.md` files in your install (each `.md` is one `/pan:<name>` command).
212
213
 
213
214
  ### Getting Started
214
215
  | Command | Description |
@@ -389,7 +390,7 @@ The Focus workflow is a **scan → plan → exec → sync** pipeline. Each step
389
390
 
390
391
  **`/pan:settings`** — Toggle researcher, plan checker, verifier agents. Select model profile.
391
392
 
392
- **`/pan:profile <name>`** — Quick profile switch: `quality` (Opus everywhere), `balanced` (Opus plan + Sonnet exec, default), `budget` (Sonnet + Haiku).
393
+ **`/pan:profile <name>`** — Quick profile switch: `quality` and `balanced` (reasoning tier for every agent; `balanced` is the default), `budget` (mid tier for writing, fast tier for research/verification).
393
394
 
394
395
  **Planning config** (`.planning/config.json`):
395
396
  - `commit_docs: true` — commit planning artifacts to git (set `false` + add `.planning/` to `.gitignore` for private planning)
@@ -16,12 +16,12 @@ Analyze the most recent trace session and generate a circular optimization repor
16
16
 
17
17
  Run:
18
18
  ```
19
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
19
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
20
20
  ```
21
21
 
22
22
  If no active session, run:
23
23
  ```
24
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace list
24
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace list
25
25
  ```
26
26
  Use the most recent session unless `--session <id>` was specified.
27
27
 
@@ -31,7 +31,7 @@ If `--session <id>` was specified, use that session ID.
31
31
 
32
32
  Run:
33
33
  ```
34
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize learn [--session <id>]
34
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize learn [--session <id>]
35
35
  ```
36
36
 
37
37
  This produces `.planning/optimization/reports/{session}-analysis.json`.
@@ -67,7 +67,7 @@ Present to the user:
67
67
 
68
68
  If the `--apply` flag was passed, immediately run:
69
69
  ```
70
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize apply
70
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize apply
71
71
  ```
72
72
 
73
73
  Show what was applied and what still needs review.
@@ -82,7 +82,7 @@ After applying, tell the user what to watch in the next run:
82
82
  ## Edge cases
83
83
 
84
84
  **No events in trace:**
85
- - Tell the user the trace session is empty. They may need to ensure the `pan-trace-logger` hook is registered in `.claude/settings.json`.
85
+ - Tell the user the trace session is empty. They may need to ensure the `pan-trace-logger` hook is registered in `~/.claude/settings.json`.
86
86
 
87
87
  **Too few events (< 5):**
88
88
  - The optimizer can still run but note the small sample size.
@@ -315,7 +315,7 @@ This would expose credentials if committed.
315
315
  **Action required:**
316
316
  1. Review the flagged content above
317
317
  2. If these are real secrets, they must be removed before committing
318
- 3. Consider adding sensitive files to Claude Code "Deny" permissions
318
+ 3. Consider adding sensitive files to your AI coding tool's deny/ignore list
319
319
 
320
320
  Pausing before commit. Reply "safe to proceed" if the flagged content is not actually sensitive, or edit the files first.
321
321
  ```
@@ -129,7 +129,7 @@ For each REQ-ID, determine status using all three sources:
129
129
 
130
130
  ## 6. Aggregate into v{version}-milestone-audit.md
131
131
 
132
- Create `.planning/v{version}-v{version}-milestone-audit.md` with:
132
+ Create `.planning/v{version}-milestone-audit.md` with:
133
133
 
134
134
  ```yaml
135
135
  ---
@@ -17,12 +17,12 @@ Read all files referenced by the invoking prompt's execution_context before star
17
17
  - Read project.md (existing project, validated requirements, decisions)
18
18
  - Read milestones.md (what shipped previously)
19
19
  - Read state.md (pending todos, blockers)
20
- - Check for MILESTONE-context.md (from /pan:discuss-milestone)
20
+ - Check for MILESTONE-context.md (optional pre-seeded context, if the user prepared one)
21
21
 
22
22
  ## 2. Gather Milestone Goals
23
23
 
24
24
  **If MILESTONE-context.md exists:**
25
- - Use features and scope from discuss-milestone
25
+ - Use features and scope from MILESTONE-context.md
26
26
  - Present summary for confirmation
27
27
 
28
28
  **If no context file:**
@@ -151,7 +151,7 @@ Use template: ~/.claude/pan-wizard-core/templates/research-project/{FILE}
151
151
  | QUESTION | What stack additions/changes are needed for [new features]? | How do [target features] typically work? Expected behavior? | How do [target features] integrate with existing architecture? | Common mistakes when adding [target features] to [domain]? |
152
152
  | CONSUMER | Specific libraries with versions for NEW capabilities, integration points, what NOT to add | Table stakes vs differentiators vs anti-features, complexity noted, dependencies on existing | Integration points, new components, data flow changes, suggested build order | Warning signs, prevention strategy, which phase should address it |
153
153
  | GATES | Versions current (verify with Context7), rationale explains WHY, integration considered | Categories clear, complexity noted, dependencies identified | Integration points identified, new vs modified explicit, build order considers deps | Pitfalls specific to adding these features, integration pitfalls covered, prevention actionable |
154
- | FILE | STACK.md | FEATURES.md | ARCHITECTURE.md | PITFALLS.md |
154
+ | FILE | stack.md | features.md | architecture.md | pitfalls.md |
155
155
 
156
156
  After all 4 complete, spawn synthesizer:
157
157
 
@@ -195,7 +195,7 @@ Display key findings from summary.md:
195
195
 
196
196
  Read project.md: core value, current milestone goals, validated requirements (what exists).
197
197
 
198
- **If research exists:** Read FEATURES.md, extract feature categories.
198
+ **If research exists:** Read features.md, extract feature categories.
199
199
 
200
200
  Present features by category:
201
201
  ```
@@ -8,6 +8,21 @@ Read all files referenced by the invoking prompt's execution_context before star
8
8
  @~/.claude/pan-wizard-core/references/guardrails.md
9
9
  </required_reading>
10
10
 
11
+ <planning_write_policy>
12
+
13
+ **P-1808 — compose once, write once.** Every planning document this workflow produces (`project.md`, `requirements.md`, `roadmap.md`, `state.md`) is composed **in full, in memory, then written exactly once**. Field transcripts (PanLoop, 2026-08-08) counted `state.md` rewritten up to **12 times inside a single step**, `roadmap.md` and `project.md` 3× each, the same files re-read up to 6× — an agent failing to converge on a document it authored moments earlier. Every in-flight version of `state.md` is a chance for a later step to read a partial write, and the rewrite churn is why this workflow's duration varied 7× on similar briefs.
14
+
15
+ Rules, for this orchestrator and every subagent it spawns:
16
+
17
+ 1. **Gather everything, then emit.** Do not write a skeleton and refine it in place. Not ready to write the final document = still in the gathering step.
18
+ 2. **One Write per file per step.** Preparing a second Write to the same file in the same step means the first was premature — stop, finish composing, write once.
19
+ 3. **Do not re-read a file you wrote this step.** You know what it says; re-reading your own output to "check" it is the non-convergence loop starting.
20
+ 4. **Post-write corrections are targeted Edits for a verified defect** (wrong value, broken parse) — never a rewrite for restructuring you should have composed the first time.
21
+
22
+ "Write files first, then return" — the persistence rule — is unchanged: it orders writes **before the return**; it does not license early drafts.
23
+
24
+ </planning_write_policy>
25
+
11
26
  ## Phase 0 — Clarify (MANDATORY, do not skip)
12
27
 
13
28
  Before scaffolding or coding anything, confirm with the user:
@@ -63,7 +78,7 @@ The document should describe what you want to build.
63
78
  **MANDATORY FIRST STEP — Execute these checks before ANY user interaction:**
64
79
 
65
80
  ```bash
66
- INIT=$(node ./.claude/pan-wizard-core/bin/pan-tools.cjs init new-project)
81
+ INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs init new-project)
67
82
  ```
68
83
 
69
84
  Parse JSON for: `researcher_model`, `synthesizer_model`, `roadmapper_model`, `commit_docs`, `project_exists`, `has_codebase_map`, `planning_exists`, `has_existing_code`, `has_package_file`, `is_brownfield`, `needs_codebase_map`, `has_git`, `project_path`.
@@ -154,13 +169,13 @@ Create `.planning/config.json` with mode set to "yolo":
154
169
 
155
170
  ```bash
156
171
  mkdir -p .planning
157
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "chore: add project config" --files .planning/config.json
172
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "chore: add project config" --files .planning/config.json
158
173
  ```
159
174
 
160
175
  **Persist auto-advance to config (survives context compaction):**
161
176
 
162
177
  ```bash
163
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs config-set workflow.auto_advance true
178
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs config-set workflow.auto_advance true
164
179
  ```
165
180
 
166
181
  Proceed to Step 4 (skip Steps 3 and 5).
@@ -304,19 +319,19 @@ Do not compress. Capture everything gathered.
304
319
 
305
320
  ```bash
306
321
  mkdir -p .planning
307
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: initialize project" --files .planning/project.md
322
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: initialize project" --files .planning/project.md
308
323
  ```
309
324
 
310
325
  ## 5. Workflow Preferences
311
326
 
312
327
  **If auto mode:** Skip — config was collected in Step 2a. Proceed to Step 5.5.
313
328
 
314
- **Check for global defaults** at `~/.pan-wizard-core/defaults.json`. If the file exists, offer to use saved defaults:
329
+ **Check for global defaults** at `~/.pan-wizard/defaults.json`. If the file exists, offer to use saved defaults:
315
330
 
316
331
  ```
317
332
  AskUserQuestion([
318
333
  {
319
- question: "Use your saved default settings? (from ~/.pan-wizard-core/defaults.json)",
334
+ question: "Use your saved default settings? (from ~/.pan-wizard/defaults.json)",
320
335
  header: "Defaults",
321
336
  multiSelect: false,
322
337
  options: [
@@ -327,9 +342,9 @@ AskUserQuestion([
327
342
  ])
328
343
  ```
329
344
 
330
- If "Yes": read `~/.pan-wizard-core/defaults.json`, use those values for config.json, and skip directly to **Commit config.json** below.
345
+ If "Yes": read `~/.pan-wizard/defaults.json`, use those values for config.json, and skip directly to **Commit config.json** below.
331
346
 
332
- If "No" or `~/.pan-wizard-core/defaults.json` doesn't exist: proceed with the questions below.
347
+ If "No" or `~/.pan-wizard/defaults.json` doesn't exist: proceed with the questions below.
333
348
 
334
349
  **Round 1 — Core workflow settings (4 questions):**
335
350
 
@@ -421,9 +436,9 @@ questions: [
421
436
  question: "Which AI models for planning agents?",
422
437
  multiSelect: false,
423
438
  options: [
424
- { label: "Balanced (Recommended)", description: "Sonnet for most agents — good quality/cost ratio" },
425
- { label: "Quality", description: "Opus for research/roadmap — higher cost, deeper analysis" },
426
- { label: "Budget", description: "Haiku where possible — fastest, lowest cost" }
439
+ { label: "Balanced (Recommended)", description: "reasoning tier for every agent — the default (identical to quality post-COST-RESET)" },
440
+ { label: "Quality", description: "reasoning tier for every agent — identical to balanced, so switching between the two changes nothing" },
441
+ { label: "Budget", description: "mid tier for writing, fast tier for research/verification — fastest, lowest cost" }
427
442
  ]
428
443
  }
429
444
  ]
@@ -456,7 +471,7 @@ Create `.planning/config.json` with all settings:
456
471
  **Commit config.json:**
457
472
 
458
473
  ```bash
459
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "chore: add project config" --files .planning/config.json
474
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "chore: add project config" --files .planning/config.json
460
475
  ```
461
476
 
462
477
  **Note:** Run `/pan:settings` anytime to update these preferences.
@@ -510,7 +525,7 @@ Display spawning indicator:
510
525
  Spawn 4 parallel pan-project-researcher agents with path references:
511
526
 
512
527
  ```
513
- Task(prompt="First, read ./.claude/agents/pan-project-researcher.md for your role and instructions.
528
+ Task(prompt="First, read ~/.claude/agents/pan-project-researcher.md for your role and instructions.
514
529
 
515
530
  <research_type>
516
531
  Project Research — Stack dimension for [domain].
@@ -546,11 +561,11 @@ Your stack.md feeds into roadmap creation. Be prescriptive:
546
561
 
547
562
  <output>
548
563
  Write to: .planning/research/stack.md
549
- Use template: ./.claude/pan-wizard-core/templates/research-project/stack.md
564
+ Use template: ~/.claude/pan-wizard-core/templates/research-project/stack.md
550
565
  </output>
551
566
  ", subagent_type="general-purpose", model="{researcher_model}", description="Stack research")
552
567
 
553
- Task(prompt="First, read ./.claude/agents/pan-project-researcher.md for your role and instructions.
568
+ Task(prompt="First, read ~/.claude/agents/pan-project-researcher.md for your role and instructions.
554
569
 
555
570
  <research_type>
556
571
  Project Research — Features dimension for [domain].
@@ -586,11 +601,11 @@ Your features.md feeds into requirements definition. Categorize clearly:
586
601
 
587
602
  <output>
588
603
  Write to: .planning/research/features.md
589
- Use template: ./.claude/pan-wizard-core/templates/research-project/features.md
604
+ Use template: ~/.claude/pan-wizard-core/templates/research-project/features.md
590
605
  </output>
591
606
  ", subagent_type="general-purpose", model="{researcher_model}", description="Features research")
592
607
 
593
- Task(prompt="First, read ./.claude/agents/pan-project-researcher.md for your role and instructions.
608
+ Task(prompt="First, read ~/.claude/agents/pan-project-researcher.md for your role and instructions.
594
609
 
595
610
  <research_type>
596
611
  Project Research — Architecture dimension for [domain].
@@ -626,11 +641,11 @@ Your architecture.md informs phase structure in roadmap. Include:
626
641
 
627
642
  <output>
628
643
  Write to: .planning/research/architecture.md
629
- Use template: ./.claude/pan-wizard-core/templates/research-project/architecture.md
644
+ Use template: ~/.claude/pan-wizard-core/templates/research-project/architecture.md
630
645
  </output>
631
646
  ", subagent_type="general-purpose", model="{researcher_model}", description="Architecture research")
632
647
 
633
- Task(prompt="First, read ./.claude/agents/pan-project-researcher.md for your role and instructions.
648
+ Task(prompt="First, read ~/.claude/agents/pan-project-researcher.md for your role and instructions.
634
649
 
635
650
  <research_type>
636
651
  Project Research — Pitfalls dimension for [domain].
@@ -666,7 +681,7 @@ Your pitfalls.md prevents mistakes in roadmap/planning. For each pitfall:
666
681
 
667
682
  <output>
668
683
  Write to: .planning/research/pitfalls.md
669
- Use template: ./.claude/pan-wizard-core/templates/research-project/pitfalls.md
684
+ Use template: ~/.claude/pan-wizard-core/templates/research-project/pitfalls.md
670
685
  </output>
671
686
  ", subagent_type="general-purpose", model="{researcher_model}", description="Pitfalls research")
672
687
  ```
@@ -688,7 +703,7 @@ Synthesize research outputs into summary.md.
688
703
 
689
704
  <output>
690
705
  Write to: .planning/research/summary.md
691
- Use template: ./.claude/pan-wizard-core/templates/research-project/summary.md
706
+ Use template: ~/.claude/pan-wizard-core/templates/research-project/summary.md
692
707
  Commit after writing.
693
708
  </output>
694
709
  ", subagent_type="pan-research-synthesizer", model="{synthesizer_model}", description="Synthesize research")
@@ -727,7 +742,7 @@ Read project.md and extract:
727
742
  - Stated constraints (budget, timeline, tech limitations)
728
743
  - Any explicit scope boundaries
729
744
 
730
- **If research exists:** Read research/FEATURES.md and extract feature categories.
745
+ **If research exists:** Read research/features.md and extract feature categories.
731
746
 
732
747
  **If auto mode:**
733
748
  - Auto-include all table stakes features (users expect these)
@@ -853,7 +868,7 @@ If "adjust": Return to scoping.
853
868
  **Commit requirements:**
854
869
 
855
870
  ```bash
856
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: define v1 requirements" --files .planning/requirements.md
871
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: define v1 requirements" --files .planning/requirements.md
857
872
  ```
858
873
 
859
874
  ## 8. Create Roadmap
@@ -888,10 +903,10 @@ Create roadmap:
888
903
  2. Map every v1 requirement to exactly one phase
889
904
  3. Derive 2-5 success criteria per phase (observable user behaviors)
890
905
  4. Validate 100% coverage
891
- 5. Write files immediately (roadmap.md, state.md, update requirements.md traceability)
906
+ 5. Compose each file in full, then write each exactly once — one Write per file, no draft-then-refine (P-1808): roadmap.md, state.md, update requirements.md traceability
892
907
  6. Return ROADMAP CREATED with summary
893
908
 
894
- Write files first, then return. This ensures artifacts persist even if context is lost.
909
+ Write files first, then return — before the return, not early and often. One complete Write per file persists the artifacts without the rewrite churn (P-1808).
895
910
  </instructions>
896
911
  ", subagent_type="pan-roadmapper", model="{roadmapper_model}", description="Create roadmap")
897
912
  ```
@@ -983,7 +998,7 @@ Use AskUserQuestion:
983
998
  **Commit roadmap (after approval or auto mode):**
984
999
 
985
1000
  ```bash
986
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: create roadmap ([N] phases)" --files .planning/roadmap.md .planning/state.md .planning/requirements.md
1001
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: create roadmap ([N] phases)" --files .planning/roadmap.md .planning/state.md .planning/requirements.md
987
1002
  ```
988
1003
 
989
1004
  ## 8.5. Standards Recommendation
@@ -991,7 +1006,7 @@ node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: create roadmap ([
991
1006
  **After roadmap is committed, offer standards selection based on project type.**
992
1007
 
993
1008
  ```bash
994
- RECOMMEND=$(node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards recommend)
1009
+ RECOMMEND=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs standards recommend)
995
1010
  ```
996
1011
 
997
1012
  If the command succeeds (project.md exists and project types detected):
@@ -1004,9 +1019,9 @@ Parse JSON for `project_types` and `recommendations` arrays.
1004
1019
  HIGH_IDS=$(echo "$RECOMMEND" | jq -r '.recommendations[] | select(.priority=="high") | .id')
1005
1020
  if [ -n "$HIGH_IDS" ]; then
1006
1021
  for id in $HIGH_IDS; do
1007
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards select "$id"
1022
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs standards select "$id"
1008
1023
  done
1009
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add recommended standards" --files .planning/standards.md
1024
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add recommended standards" --files .planning/standards.md
1010
1025
  fi
1011
1026
  ```
1012
1027
 
@@ -1036,12 +1051,12 @@ Use AskUserQuestion:
1036
1051
 
1037
1052
  For each selected standard:
1038
1053
  ```bash
1039
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards select [id]
1054
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs standards select [id]
1040
1055
  ```
1041
1056
 
1042
1057
  If any selected, commit:
1043
1058
  ```bash
1044
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add project standards" --files .planning/standards.md
1059
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add project standards" --files .planning/standards.md
1045
1060
  ```
1046
1061
 
1047
1062
  Display:
@@ -1058,7 +1073,7 @@ Run /pan:health --standards to check compliance anytime.
1058
1073
 
1059
1074
  ```bash
1060
1075
  if [ "$(git status --porcelain .planning/ 2>/dev/null)" ]; then
1061
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: bundle remaining .planning artifacts (safety-net)" --files .planning/
1076
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: bundle remaining .planning artifacts (safety-net)" --files .planning/
1062
1077
  fi
1063
1078
  ```
1064
1079
 
@@ -12,7 +12,7 @@ Manage the circular optimization loop — apply reports, check stats, control tr
12
12
  | `stats` | Show cumulative stats |
13
13
  | `trace init` | Start a new trace session |
14
14
  | `trace end` | Finalize current session |
15
- | `trace status` | Show active session |
15
+ | `trace current` | Show active session |
16
16
  | `trace list` | List all sessions |
17
17
 
18
18
  ---
@@ -23,7 +23,7 @@ Manage the circular optimization loop — apply reports, check stats, control tr
23
23
 
24
24
  Run:
25
25
  ```
26
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize list
26
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize list
27
27
  ```
28
28
 
29
29
  Use the most recent `.md` report (the full opt-report, not the `-analysis.json`).
@@ -33,7 +33,7 @@ If `--report <filename>` was specified, use that file from `.planning/optimizati
33
33
  ### Step 2 — Run apply
34
34
 
35
35
  ```
36
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize apply [--report <path>]
36
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize apply [--report <path>]
37
37
  ```
38
38
 
39
39
  ### Step 3 — Present results
@@ -63,7 +63,7 @@ If `--description "..."` was provided, extract it from the args.
63
63
  ### Step 2 — Initialize session
64
64
 
65
65
  ```
66
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init [--description "..."]
66
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init [--description "..."]
67
67
  ```
68
68
 
69
69
  Show the user the session ID and confirm that:
@@ -76,17 +76,17 @@ Show the user the session ID and confirm that:
76
76
  ## trace end
77
77
 
78
78
  ```
79
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end
79
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end
80
80
  ```
81
81
 
82
82
  Show: session ID, event count, agent count, type breakdown.
83
83
 
84
84
  ---
85
85
 
86
- ## trace status
86
+ ## trace current
87
87
 
88
88
  ```
89
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
89
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
90
90
  ```
91
91
 
92
92
  If active: show session ID and instruct how to view events.
@@ -97,7 +97,7 @@ If none: tell user to run `/pan:optimize trace init` before their next build.
97
97
  ## stats
98
98
 
99
99
  ```
100
- node .claude/pan-wizard-core/bin/pan-tools.cjs optimize stats
100
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize stats
101
101
  ```
102
102
 
103
103
  Present as a summary table:
@@ -13,7 +13,7 @@ Find current phase directory from most recently modified files:
13
13
 
14
14
  ```bash
15
15
  # Find most recent phase directory with work
16
- ls -lt .planning/phases/*/plan.md 2>/dev/null | head -1 | grep -oP 'phases/\K[^/]+'
16
+ ls -lt .planning/phases/*/*-plan.md 2>/dev/null | head -1 | sed -n 's#.*phases/\([^/]*\)/.*#\1#p'
17
17
  ```
18
18
 
19
19
  If no active phase detected, ask user which phase they're pausing work on.