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
package/bin/install.js CHANGED
@@ -445,6 +445,8 @@ function copyFlattenedCommands(srcDir, destDir, prefix, pathPrefix, runtime) {
445
445
  content = content.replace(globalClaudeRegex, pathPrefix);
446
446
  content = content.replace(localClaudeRegex, `./${getDirName(runtime)}/`);
447
447
  content = content.replace(opencodeDirRegex, pathPrefix);
448
+ // As in copyWithPathReplacement: no `pan-tools` bin is on PATH.
449
+ content = content.replace(/\bpan-tools\b(?=\s+[a-z])/g, `node ${pathPrefix}pan-wizard-core/bin/pan-tools.cjs`);
448
450
  content = processAttribution(content, getCommitAttribution(runtime));
449
451
  content = convertClaudeToOpencodeFrontmatter(content);
450
452
 
@@ -504,6 +506,7 @@ function copyCommandsAsCodexSkills(srcDir, skillsDir, prefix, pathPrefix, runtim
504
506
  content = content.replace(globalClaudeRegex, pathPrefix);
505
507
  content = content.replace(localClaudeRegex, `./${getDirName(runtime)}/`);
506
508
  content = content.replace(codexDirRegex, pathPrefix);
509
+ content = lib.rewriteAgentFileRefs(content, runtime, pathPrefix);
507
510
  // Codex executes commands literally; no `pan-tools` bin on PATH.
508
511
  const panToolsPath = `${pathPrefix}pan-wizard-core/bin/pan-tools.cjs`;
509
512
  content = content.replace(/\bpan-tools\b(?=\s+[a-z])/g, `node ${panToolsPath}`);
@@ -821,6 +824,7 @@ function copyCommandsAsCopilotSkills(srcDir, skillsDir, prefix, pathPrefix, runt
821
824
  const localClaudeRegex = /\.\/\.claude\//g;
822
825
  content = content.replace(globalClaudeRegex, pathPrefix);
823
826
  content = content.replace(localClaudeRegex, `./${getDirName(runtime)}/`);
827
+ content = lib.rewriteAgentFileRefs(content, runtime, pathPrefix);
824
828
  // Copilot CLI executes commands literally; there's no `pan-tools` bin on PATH.
825
829
  // Replace bare `pan-tools` invocations with the explicit node + .cjs path.
826
830
  const panToolsPath = `${pathPrefix}pan-wizard-core/bin/pan-tools.cjs`;
@@ -876,6 +880,11 @@ function copyWithPathReplacement(srcDir, destDir, pathPrefix, runtime, isCommand
876
880
  const localClaudeRegex = /\.\/\.claude\//g;
877
881
  content = content.replace(globalClaudeRegex, pathPrefix);
878
882
  content = content.replace(localClaudeRegex, `./${dirName}/`);
883
+ // No runtime puts a `pan-tools` bin on PATH: invoke it via node, as the Codex
884
+ // and Copilot converters already did. A bare `pan-tools <verb>` in an installed
885
+ // Claude, Gemini or OpenCode command or workflow was a call that could not run.
886
+ content = content.replace(/\bpan-tools\b(?=\s+[a-z])/g, `node ${pathPrefix}pan-wizard-core/bin/pan-tools.cjs`);
887
+ content = lib.rewriteAgentFileRefs(content, runtime, pathPrefix);
879
888
  content = processAttribution(content, getCommitAttribution(runtime));
880
889
 
881
890
  // Convert frontmatter for opencode compatibility
@@ -1244,6 +1253,16 @@ function uninstall(isGlobal, runtime = 'claude') {
1244
1253
  }
1245
1254
  }
1246
1255
 
1256
+ // 4a'. Remove the OpenCode plugin (O12); the plugins directory goes too when
1257
+ // nothing else is in it.
1258
+ const opencodePlugin = path.join(targetDir, 'plugins', OPENCODE_PLUGIN_FILE);
1259
+ if (fs.existsSync(opencodePlugin)) {
1260
+ try { fs.unlinkSync(opencodePlugin); } catch {}
1261
+ try { fs.rmdirSync(path.dirname(opencodePlugin)); } catch { /* not empty: the user's own plugins stay */ }
1262
+ removedCount++;
1263
+ console.log(` ${green}✓${reset} Removed the PAN plugin`);
1264
+ }
1265
+
1247
1266
  // 4b. Codex: strip PAN entries from the shared .codex/hooks.json (foreign
1248
1267
  // hook registrations are preserved; the file is deleted only when nothing
1249
1268
  // but PAN content remained).
@@ -1842,6 +1861,8 @@ const PATCHES_DIR_NAME = 'pan-local-patches';
1842
1861
  // the patches tree stays self-contained.
1843
1862
  const EXTERNAL_PATCHES_SUBDIR = '_external';
1844
1863
  const MANIFEST_NAME = 'pan-file-manifest.json';
1864
+ // PAN's OpenCode plugin, installed as <opencode dir>/plugins/pan-wizard.js (O12).
1865
+ const OPENCODE_PLUGIN_FILE = 'pan-wizard.js';
1845
1866
 
1846
1867
  /**
1847
1868
  * Compute SHA256 hash of file contents
@@ -1963,6 +1984,11 @@ function writeManifest(configDir, runtime = 'claude', isGlobal = false) {
1963
1984
  }
1964
1985
  }
1965
1986
  }
1987
+ // The OpenCode plugin (O12)
1988
+ const opencodePlugin = path.join(configDir, 'plugins', OPENCODE_PLUGIN_FILE);
1989
+ if (isOpencode && fs.existsSync(opencodePlugin)) {
1990
+ manifest.files[`plugins/${OPENCODE_PLUGIN_FILE}`] = fileHash(opencodePlugin);
1991
+ }
1966
1992
 
1967
1993
  try {
1968
1994
  fs.writeFileSync(path.join(configDir, MANIFEST_NAME), JSON.stringify(manifest, null, 2));
@@ -2248,7 +2274,9 @@ function install(isGlobal, runtime = 'claude') {
2248
2274
  // last; the per-runtime core remains for agents/hooks.
2249
2275
  const sharedCoreDest = path.join(agentsRoot, 'pan-wizard-core');
2250
2276
  copySharedCore(path.join(src, 'pan-wizard-core'), sharedCoreDest, corePrefix, pathPrefix, runtime);
2251
- try { fs.writeFileSync(path.join(sharedCoreDest, 'VERSION'), pkg.version); } catch { /* non-fatal */ }
2277
+ // With its newline, as the per-runtime core writes it: `/pan:update` cats the file
2278
+ // and prints the runtime flag next, which glued onto a bare version.
2279
+ try { fs.writeFileSync(path.join(sharedCoreDest, 'VERSION'), pkg.version + '\n'); } catch { /* non-fatal */ }
2252
2280
 
2253
2281
  // Canonical agent-definition reference copies (ADR-0028 agent-ref
2254
2282
  // canonicalization): shared content references these instead of the
@@ -2451,6 +2479,9 @@ function install(isGlobal, runtime = 'claude') {
2451
2479
  // Always replace ~/.claude/ as it is the source of truth in the repo
2452
2480
  const dirRegex = /~\/\.claude\//g;
2453
2481
  content = content.replace(dirRegex, pathPrefix);
2482
+ // As in copyWithPathReplacement: no `pan-tools` bin is on PATH.
2483
+ content = content.replace(/\bpan-tools\b(?=\s+[a-z])/g, `node ${pathPrefix}pan-wizard-core/bin/pan-tools.cjs`);
2484
+ content = lib.rewriteAgentFileRefs(content, runtime, pathPrefix);
2454
2485
  content = processAttribution(content, getCommitAttribution(runtime));
2455
2486
  // Codex custom agents are standalone TOML files (2026-06 format);
2456
2487
  // markdown in .codex/agents/ is not recognized. Handle before
@@ -2639,6 +2670,21 @@ function install(isGlobal, runtime = 'claude') {
2639
2670
  }
2640
2671
  }
2641
2672
 
2673
+ // OpenCode plugin (memory optimisation O12). OpenCode runs no command hooks, but a
2674
+ // plugin can add to the prompt it compacts a session with; PAN's keeps the phase
2675
+ // in flight through a compaction, as hooks/pan-state-reinject.js does on the other
2676
+ // hosts. CommonJS, beside the package.json written above.
2677
+ if (isOpencode) {
2678
+ try {
2679
+ const pluginsDir = path.join(targetDir, 'plugins');
2680
+ fs.mkdirSync(pluginsDir, { recursive: true });
2681
+ fs.copyFileSync(path.join(src, 'pan-wizard-core', 'opencode', OPENCODE_PLUGIN_FILE), path.join(pluginsDir, OPENCODE_PLUGIN_FILE));
2682
+ console.log(` ${green}✓${reset} Installed the PAN plugin to plugins/ (keeps PAN's position through compaction)`);
2683
+ } catch (e) {
2684
+ pushInstallWarning('opencodePlugin', `plugins/${OPENCODE_PLUGIN_FILE}`, e);
2685
+ }
2686
+ }
2687
+
2642
2688
  if (failures.length > 0) {
2643
2689
  console.error(`\n ${yellow}Installation incomplete!${reset} Failed: ${failures.join(', ')}`);
2644
2690
  process.exit(1);
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: army
3
3
  group: Army
4
+ argument-hint: "<goal> [--source scan|backlog] [--max-cycles N] [--total-budget N] [--enforce-budget] [--verify-reserve F] [--squads a,b,c] [--no-build-worktrees] [--push] [--clean-seal] [--schedule <cadence>] [--daily-budget N] [--dry-run] [--continue] [--stop] [--status]"
4
5
  description: Bot-army campaign — Mission Control (the reasoning-tier conductor) delegates a whole-project goal to squads (architecture / build / quality / release), each squad working branch-per-agent worktrees under a hard safety harness, gated by CI + a human merge, looping plan→delegate→execute→review→integrate→learn until the goal ships or a stop condition fires.
5
6
  allowed-tools:
6
7
  - Read
@@ -25,7 +26,7 @@ The army is the campaign-scale sibling of `/pan:exec-phase --hierarchical` (one
25
26
 
26
27
  | Tier | Who | Model tier | Access |
27
28
  |------|-----|-----------|--------|
28
- | 0 · Mission Control | `pan-conductor` | `reasoning` (`mid` under `budget`) | delegation-first (Agent toolset) — instructed to route work, not write it |
29
+ | 0 · Mission Control | `pan-conductor` | the session model (spawned with no `model`, so under every profile) | delegation-first (Agent toolset) — instructed to route work, not write it |
29
30
  | 1 · Architecture | design + planning agents — `squad show architecture` lists them | `reasoning` | `read-only` |
30
31
  | 1 · Build | `pan-executor` | `reasoning` | `read-write-bash` — one branch+worktree per agent |
31
32
  | 1 · Quality | adversarial review + debug agents — `squad show quality` lists them | `mid` | `read-only`, adversarial |
@@ -34,11 +35,11 @@ The army is the campaign-scale sibling of `/pan:exec-phase --hierarchical` (one
34
35
 
35
36
  **Where each row comes from.** The tier-1 rows mirror the `squads[]` records `pan-tools squad list` prints — label, `tier`, `access` (their member names come from `squad show <name>`, since `squad list` reports only a count). The Tier 0 and Tier 2 rows are PAN's hierarchy positions: the same command names them under its `coordinator` and `workers` keys, but reports nothing else about them, so the Model-tier and Access values on those two rows are written here rather than returned by the command. Resolve the roster at runtime — never hardcode it: `pan-tools squad list` and `pan-tools squad show <name>`.
36
37
 
37
- **Reading the Model-tier column.** These are PAN *tiers*, not model names. `reasoning` resolves to `inherit` — the model you launched with — while `mid` and `fast` map to the provider's mid/fast models (Sonnet and Haiku on Anthropic).
38
+ **Reading the Model-tier column.** These are PAN *tiers*, not model names. `reasoning` resolves to `inherit` — the model you launched with — while `mid` and `fast` map to the provider's mid/fast models (Sonnet and Haiku on Anthropic). They are what `squad list` and `resolve-model` report: the army's spawns pass no model, so an agent spawned under its own type runs on its file's `model:` (the reviewer-class agents pin `opus` on Claude Code) or, without one, the session model.
38
39
 
39
40
  **Reading the Access column.** The backticked values on the tier-1 rows are the `access` labels `squad list` reports; tier 0 and tier 2 carry PAN's own. They are role contracts the conductor's prompt assigns when it delegates, not a sandbox: `squads.cjs` says of itself that it "modifies no agent and changes no execution path", so a label can differ from what an agent may actually do — expect that, since several `read-only` squad members hold `Write` to emit planning or verification artifacts. The binding grant is each agent's own `tools:` frontmatter (`grep '^tools:' ~/.claude/agents/*.md`), and Mission Control's includes `Write` and `Bash`: routing rather than coding is how it is instructed to behave, not something the runtime prevents. The rail those grants do enforce is delegation depth — `grep -l '^tools:.*Task' ~/.claude/agents/*.md` names every agent able to spawn another (today, `pan-conductor`), so a squad agent cannot fan out further.
40
41
 
41
- **Squad tier is not profile tier.** The tier column above is a `squads.cjs` grouping attribute — what `pan-tools squad list` reports — and it is not what resolves an agent's model; that comes from the active `model_profile` (`quality` and `balanced` are `reasoning` for every agent, and `budget` is the only profile that down-tiers), plus any `model:` pin in an agent's own frontmatter. So the `mid` on the Quality and Release rows does not describe what those agents run under the default profile — under `quality` and `balanced` they resolve `reasoning` like everything else. The tier-1 values above are the squad groupings; the tier-0 and tier-2 values are per-agent profile tiers. **`budget` resolves per agent, not per row:** it sends some workers to `fast` and others to `mid`, so no single value is true of the Tier 2 row — `MODEL_PROFILES` in `~/.claude/pan-wizard-core/bin/lib/core.cjs` is the table, and it is the one to read rather than a tier written into a doc. For the agents that pin a model outright, `grep -l '^model: opus' ~/.claude/agents/*.md` lists them — the pin applies on Claude Code only, since the installer strips it for the other runtimes.
42
+ **Squad tier is not profile tier.** The tier column above is a `squads.cjs` grouping attribute — what `pan-tools squad list` reports — and it is not an agent's profile tier, which is what `resolve-model` reports from the active `model_profile` (`quality` and `balanced` are `reasoning` for every agent, and `budget` is the only profile that down-tiers). The army applies neither: its spawns pass no model, so an agent runs on its own `model:` pin, else the session model, under every profile. So the `mid` on the Quality and Release rows does not describe what those agents run. The tier-1 values above are the squad groupings; the tier-2 value is the per-agent profile tier `resolve-model` reports. **`budget` resolves per agent, not per row:** `resolve-model` reports `fast` for some workers and `mid` for others, so no single value is true of the Tier 2 row — `MODEL_PROFILES` in `~/.claude/pan-wizard-core/bin/lib/core.cjs` is the table, and it is the one to read rather than a tier written into a doc. For the agents that pin a model outright, `grep -l '^model: opus' ~/.claude/agents/*.md` lists them — the pin applies on Claude Code only, since the installer strips it for the other runtimes.
42
43
 
43
44
  ---
44
45
 
@@ -75,6 +76,7 @@ Every cap the conductor enforces applies to the campaign, scaled up:
75
76
 
76
77
  ```
77
78
  /pan:army "<goal>" [--source scan|backlog] [--max-cycles N] [--total-budget N]
79
+ [--enforce-budget] [--verify-reserve F]
78
80
  [--squads a,b,c] [--no-build-worktrees] [--push] [--clean-seal]
79
81
  [--schedule <cadence>] [--daily-budget N]
80
82
  [--dry-run] [--continue] [--stop] [--status]
@@ -102,20 +104,20 @@ Every cap the conductor enforces applies to the campaign, scaled up:
102
104
 
103
105
  ```
104
106
  /pan:army
105
- Phase 0 MUSTER — squad list + roster validate · cache prime · baseline · loop-state · abort-file clear
107
+ Phase 0 MUSTER — squad list + roster validate · baseline · loop-state · abort-file clear
106
108
  Phase 1 PLAN — Mission Control (session model, xhigh effort) decomposes the goal into dependency-ordered missions
107
109
  Phase 2 DELEGATE — pick the next item (focus-auto --source) · route to the owning squad over the Agent toolset
108
110
  Phase 3 EXECUTE — Build squad: one army/<task> worktree per agent (parallel); Architecture/Quality research in parallel (read-only)
109
111
  Phase 4 REVIEW — Quality squad on the built tree: reviewer + hardener + meta → verdict ladder; a block is a hard gate
110
112
  Phase 5 INTEGRATE— Release squad: prepare squash-merge → CI/verification → ALWAYS-ASK human approval → tag → deploy hand-off
111
- Phase 6 LEARN — summaries return to Mission Control; retro/learn writes patterns to memory (this is "Dreaming")
113
+ Phase 6 LEARN — summaries return to Mission Control; retro/learn patterns go into the next mission's plan (this is "Dreaming")
112
114
  → loop to Phase 2 until a stop condition; --clean-seal once at the end
113
115
  ```
114
116
 
115
117
  ### Phase 0 — Muster (once)
116
- 1. **Onboarding gate (existing projects).** Run `pan-tools init new-project` to detect state. If `is_brownfield` (existing code) and `needs_codebase_map` (no `.planning/codebase/`), the army cannot plan blind — STOP and route through onboarding first: `/pan:map-codebase` (Architecture squad's `pan-document_code` maps the existing system into `.planning/codebase/`), then `/pan:new-project` to build `roadmap.md` + `requirements.md` *against the existing system*. Re-run `/pan:army` once a backlog exists. If a codebase map + roadmap already exist, continue.
118
+ 1. **Onboarding gate (existing projects).** Run `pan-tools init new-project` to detect state. If `is_brownfield` (existing code) and `needs_codebase_map` (no `.planning/codebase/`), the army cannot plan blind — STOP and route through onboarding first: `/pan:map-codebase` (its `pan-document_code` mappers — workers in `pan-tools squad list`, not Architecture squad members — map the existing system into `.planning/codebase/`), then `/pan:new-project` to build `roadmap.md` + `requirements.md` *against the existing system* — only when `project_exists` is false: it refuses an initialized project, which needs just the map. Re-run `/pan:army` once a backlog exists. If a codebase map + roadmap already exist, continue.
117
119
  2. `pan-tools squad list` and validate the roster is healthy.
118
- 3. Prime the cache; capture baseline (`git status` clean of project source; tests green or STOP). On a brownfield repo, the baseline is the current `main` — every `army/<task>` branch forks from it, so the existing code is never edited in place.
120
+ 3. Capture the baseline (`git status` clean of project source; tests green or STOP). On a brownfield repo, the baseline is the commit you have checked out — every `army/<task>` branch forks from it (`worktree create` bases it on `HEAD`), so the existing code is never edited in place.
119
121
  4. Ensure `.planning/orchestration/` exists; clear any stale `abort` file; init loop-state.
120
122
  5. `--dry-run` → print the plan + per-squad delegation and STOP.
121
123
 
@@ -138,7 +140,7 @@ Spawn `pan-release`. It prepares the squash-merge, runs the configured `verifica
138
140
  **Phase report (opt-in build deliverable):** when `workflow.phase_reports.enabled` is `true`, generate the mission's self-contained per-phase HTML report **in the built tree, before staging the squash-merge** — `pan-tools report phase <N>` — so the report rides along in the merge as a phase deliverable. **Never run `report index` inside a squad worktree:** the timeline index is a single shared file that aggregates *all* phases, so a worktree would see only its own phase and concurrent squads would race on it. The index is a single-writer, post-merge concern (Phase 6). Never opens a browser.
139
141
 
140
142
  ### Phase 6 — Learn (Dreaming)
141
- Squad summaries return to Mission Control. Run `/pan:retro --write-memory` (and `/pan:learn` if traces exist) so recurring patterns persist into agent memory for the next mission. Strike the landed item; update loop-state. For a scheduled campaign, also `pan-tools campaign record-run --items <n> --points <p>` so the next-due time and the day's spend advance.
143
+ Squad summaries return to Mission Control. Run `/pan:retro` (and `/pan:learn` if traces exist) and carry the recurring patterns into the next mission yourself: name them in the plan you hand the Architecture squad. Agent memory does not do this, because PAN does not load it into agents. A pattern that should outlast the campaign goes to the human at the merge gate as a proposed line for the project's instructions. Strike the landed item; update loop-state. For a scheduled campaign, also `pan-tools campaign record-run --items <n> --points <p>` so the next-due time and the day's spend advance.
142
144
 
143
145
  **Rebuild the timeline index (single writer).** When `workflow.phase_reports.enabled` and `workflow.phase_reports.index` are `true`, Mission Control — and *only* Mission Control, on the integration branch after the merge has landed — rebuilds the project index once against the now-merged set of phases: `pan-tools report index`, then commit it (the commit honors `commit_docs`). Doing this post-merge from the single conductor is what keeps `report-index.html` consistent while builds run in parallel worktrees.
144
146
 
@@ -161,7 +163,7 @@ Nothing under `pan-army-*` or on an `army/*` branch is a deliverable: the squash
161
163
  PAN is not a daemon — it cannot wake itself while the session is closed. `--schedule` arms a campaign and lets an external trigger drive it; the human merge gate is never relaxed.
162
164
 
163
165
  - **Arm:** `/pan:army "<goal>" --schedule daily --daily-budget 200` writes `.planning/orchestration/schedule.json` (cadence, daily budget, next-due) instead of running once.
164
- - **The trigger (you wire one):** a host scheduler (Claude Code routines / cron / scheduled-tasks) or a `/loop` runs `pan-tools campaign due` and, when it reports due, invokes `/pan:army --continue`. On next session open, a due campaign is surfaced as a nudge.
166
+ - **The trigger (you wire one):** a host scheduler (Claude Code routines / cron / scheduled-tasks) or a `/loop` runs `pan-tools campaign due` and, when it reports due, invokes `/pan:army --continue`. Nothing surfaces a due campaign on its own: PAN does not wake itself, so without a trigger the campaign waits until you run `/pan:army --continue` (`pan-tools campaign due` says whether one is due).
165
167
  - **Resume (`--continue`):** read the schedule + `.planning/orchestration/` + focus-auto state. If `campaign due` is true and the day's `--daily-budget` isn't spent, run the next mission(s), then `campaign record-run` (advances next-due, accrues the day's spend). If not due or budget-spent, report next-due and STOP.
166
168
  - **Bounded spend:** point budgets (`--total-budget`, `--daily-budget`) are **advisory indicators by default** — they're tracked and surfaced, not hard stops. `--enforce-budget` (or config `budget.enforce`) makes `--total-budget` a hard stop; a scheduled campaign's `--daily-budget` pauses the day's run only when the schedule was armed with `--enforce-budget` (`campaign schedule --enforce-budget`; `--advisory-budget` turns it back off). The real bounds are `--max-cycles`, the conductor caps, the abort file, and the human merge gate at every integrate. A scheduled campaign runs the backlog down to staged, reviewed, green PRs over days.
167
169
  - **Verify reserve:** a fraction of `--total-budget` (`--verify-reserve`, default 0.15) is held back so the closing Quality re-review isn't starved. Surfaced always via `campaign status` / `focus auto --status` (`into_verify_reserve`, `new_work_budget_remaining`); under `--enforce-budget` the run stops taking on new missions early (`budget_reserve_reached`) and spends the reserve on the final `--clean-seal` verification before the last INTEGRATE.
@@ -171,7 +173,9 @@ Manage it: `pan-tools campaign status` (active/paused, spent today, next-due), `
171
173
  ---
172
174
 
173
175
  ## Completion contract
174
- The campaign is complete when ANY holds: `--max-cycles` reached · backlog empty · abort file present · context < 25% · a mission cannot pass Quality and can't be cleanly reverted (HARD STOP — preserve state, report). (Budget exhaustion is advisory by default — a stop condition only when `budget.enforce`/`--enforce-budget` is set; under enforcement, crossing into the verify reserve (`budget_reserve_reached`) stops new missions but the reserved points still fund the closing re-verification.) Always run `--clean-seal` (unless omitted) after the last item.
176
+ The campaign is complete when ANY holds: `--max-cycles` reached · backlog empty · abort file present · a mission cannot pass Quality and can't be cleanly reverted (HARD STOP — preserve state, report). (Budget exhaustion is advisory by default — a stop condition only when `budget.enforce`/`--enforce-budget` is set; under enforcement, crossing into the verify reserve (`budget_reserve_reached`) stops new missions but the reserved points still fund the closing re-verification.) Before each new mission, run `pan-tools cost limits --raw`: `weekly_limit_reached` (Claude Code's 7-day usage window at `cost.weekly_limit_stop_pct`, default 90%) is a stop condition too, so the rest of the window stays the user's. Always run `--clean-seal` (unless omitted) after the last item.
177
+
178
+ The context monitor's notes are not a stop condition: they give no figure and ask for a checkpoint. On the critical note, bring the mission's state in `.planning/orchestration/` up to date and carry on. After the host compacts, re-read the campaign with `pan-tools focus auto --status` and `.planning/orchestration/`: PAN's state re-injection carries state.md's position, not the campaign's.
175
179
 
176
180
  ## NEVER DO
177
181
  - Let Mission Control write code, or let a squad agent spawn further agents (depth cap).
@@ -184,7 +188,7 @@ The campaign is complete when ANY holds: `--max-cycles` reached · backlog empty
184
188
  - Plan on the session model Mission Control inherits, delegate over the Agent toolset, keep each squad's return a tight summary.
185
189
  - One worktree per Build agent; parallel research/verify; serial human-gated integrate.
186
190
  - Check the abort file + spawn/budget caps before every spawn.
187
- - Finish with the clean-build seal; write learnings back to memory.
191
+ - Finish with the clean-build seal; carry the learnings into the next mission's plan.
188
192
 
189
193
  ## Examples
190
194
  ```
@@ -2,7 +2,7 @@
2
2
  name: pan:assumptions
3
3
  group: Phase Management
4
4
  description: Surface Claude's assumptions about a phase approach before planning
5
- argument-hint: "[phase]"
5
+ argument-hint: "<phase>"
6
6
  allowed-tools:
7
7
  - Read
8
8
  - Bash
@@ -70,7 +70,7 @@ GOOD: "Assumption: The project uses Express for routing — Evidence: require('e
70
70
  - Surface assumptions about: technical approach, implementation order, scope, risks, dependencies
71
71
  - Present assumptions clearly with file:line references where applicable
72
72
  - Prompt "What do you think?"
73
- 5. Gather feedback and offer next steps
73
+ 6. Gather feedback and offer next steps
74
74
  </process>
75
75
 
76
76
  <success_criteria>
@@ -54,8 +54,7 @@ Claude: <target>/.claude/
54
54
  Gemini: <target>/.gemini/
55
55
  OpenCode: <target>/.opencode/
56
56
  Codex: <target>/.codex/
57
- Copilot: <target>/.copilot/ (or ~/.copilot/)
58
- GitHub: <target>/.github/
57
+ Copilot: <target>/.github/ (local install) or ~/.copilot/ (global)
59
58
  ```
60
59
 
61
60
  For the detected runtime config directory (CONFIG_DIR), audit ALL of the following:
@@ -88,14 +87,14 @@ For the detected runtime config directory (CONFIG_DIR), audit ALL of the followi
88
87
  - [ ] `CONFIG_DIR/agents/` — every manifest-listed agent file present
89
88
  - Verify key agents exist: pan-planner, pan-executor, pan-verifier, pan-debugger
90
89
 
91
- **1.6 Hooks**
90
+ **1.6 Hooks** (not OpenCode: its install copies no hooks — check `CONFIG_DIR/plugins/pan-wizard.js` instead)
92
91
  - [ ] `CONFIG_DIR/hooks/pan-statusline.js` exists
93
92
  - [ ] `CONFIG_DIR/hooks/pan-check-update.js` exists
94
93
  - [ ] `CONFIG_DIR/hooks/pan-context-monitor.js` exists
95
94
 
96
95
  **1.7 Settings/Config**
97
96
  - [ ] Settings file exists (settings.json / opencode.json / config.json)
98
- - [ ] Hooks are registered — Claude `settings.json`: SessionStart, PostToolUse, SubagentStop, Stop, statusLine; Gemini `settings.json`: SessionStart and AfterAgent only (no statusLine); Codex: `.codex/hooks.json`; Copilot: `.github/hooks/pan.json`
97
+ - [ ] Hooks are registered — Claude `settings.json`: SessionStart, PostToolUse, SubagentStop, Stop, statusLine; Gemini `settings.json`: SessionStart, AfterAgent, PreCompress and AfterTool (the last two for state re-injection; no statusLine); Codex: `.codex/hooks.json`; Copilot: `.github/hooks/pan.json`
99
98
  - [ ] Hook commands point to existing files
100
99
 
101
100
  **1.8 Manifest Integrity**
@@ -137,13 +136,13 @@ Check `.planning/` directory in the target:
137
136
  - Parse state.md "Current Position" — extract phase number
138
137
  - Count actual phase directories — do they match?
139
138
  - Check roadmap.md phase count vs actual directories
140
- - Verify no orphaned .continue-here-*.md files (paused but not resumed)
139
+ - Check `.planning/phases/*/.continue-here*.md` (pause writes `.continue-here.md`): resuming does not delete it (only the transition workflow removes a completed phase's handoffs), so its presence alone does not mean the session was never resumed
141
140
 
142
141
  **2.5 Config Sanity**
143
142
  - Validate config.json values are within expected ranges
144
143
  - `model_profile`: "quality" | "balanced" | "budget"
145
144
  - `commit_docs`: boolean
146
- - `workflow.*` toggles (research, plan_check, verifier, ...): all boolean
145
+ - `workflow.*` toggles (research, plan_check, verifier, ...): boolean — except `workflow.phase_reports`, an object (`enabled`, `open`, `theme`, `index`)
147
146
  - `budget`: `default_points` numeric, `enforce` boolean
148
147
  </step>
149
148
 
@@ -170,7 +169,7 @@ For each phase with plan files (`*-plan.md`, e.g. `01-01-plan.md`):
170
169
  - Check for PAN-style commit messages
171
170
 
172
171
  **3.4 Session Continuity**
173
- - Check for .continue-here-*.md files (indicates paused sessions)
172
+ - Check for `.planning/phases/*/.continue-here*.md` files (a pause happened at some point; nothing removes them on resume)
174
173
  - Check state.md session logs for gaps
175
174
  - Look for evidence of context loss (repeated work, contradictory decisions)
176
175
 
@@ -250,7 +249,7 @@ Verification Coverage: <N>%
250
249
  If `--repair` flag was provided, attempt auto-fixes for repairable issues:
251
250
  - Regenerate missing settings.json with default hook config
252
251
  - Create missing .planning/config.json with defaults
253
- - Remove orphaned .continue-here-*.md files
252
+ - Remove `.planning/phases/*/.continue-here*.md` files the user confirms are stale
254
253
 
255
254
  Report repairs performed.
256
255
  </step>
@@ -285,10 +284,10 @@ The spec MUST follow this exact format to be consumable by superplan.md:
285
284
 
286
285
  ## Success Criteria
287
286
 
288
- ```
287
+ ~~~
289
288
  SC-1: <measurable criterion>
290
289
  SC-2: <measurable criterion>
291
- ```
290
+ ~~~
292
291
 
293
292
  ## Design
294
293
 
@@ -313,9 +312,9 @@ SC-2: <measurable criterion>
313
312
 
314
313
  ### Dependency Graph
315
314
 
316
- ```
315
+ ~~~
317
316
  A.1 ──> A.2 ──> A.3
318
- ```
317
+ ~~~
319
318
 
320
319
  ## Test Plan
321
320
 
@@ -2,7 +2,7 @@
2
2
  name: pan:cost
3
3
  group: Observability
4
4
  description: Show token usage and estimated cost across PAN commands and agents
5
- argument-hint: "[report|append|clear|rebuild] [--format json|table|chart] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--apply] [--no-main-thread]"
5
+ argument-hint: "[report|append|clear|rebuild|limits] [--format json|table|chart] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--apply] [--no-main-thread]"
6
6
  allowed-tools:
7
7
  - Read
8
8
  - Bash
@@ -13,7 +13,7 @@ Report token usage and estimated cost across all PAN invocations in this project
13
13
 
14
14
  Reads `.planning/metrics/tokens.jsonl` — an append-only log where each line is one call (agent or command) with token counts and model. Cost is computed from a built-in rate table (overridable via `.planning/config.json` → `cost.rates`).
15
15
 
16
- Default output is JSON for piping. Use `--format table` for human-readable tables or `--format chart` for an ASCII bar chart of daily spend.
16
+ Default output is JSON for piping. Use `--format table` for human-readable tables or `--format chart` for an ASCII bar chart of daily spend; both print text, with or without `--raw`.
17
17
  </objective>
18
18
 
19
19
  <execution_context>
@@ -33,7 +33,7 @@ pan-tools cost report [--format json|table|chart] [--since YYYY-MM-DD] [--until
33
33
  **Flags:**
34
34
  - `--format` — `json` (default, for tools) | `table` (aligned text columns) | `chart` (per-day ASCII bars).
35
35
  - `--since` — ISO date lower bound (inclusive). Records without `ts` always pass.
36
- - `--until` — ISO date upper bound (inclusive).
36
+ - `--until` — ISO upper bound (inclusive): a bare date covers that whole day.
37
37
 
38
38
  **JSON output shape:**
39
39
  ```json
@@ -81,6 +81,10 @@ Delete the cost log. Useful at the start of a billing cycle.
81
81
  pan-tools cost clear
82
82
  ```
83
83
 
84
+ ### `limits`
85
+
86
+ `pan-tools cost limits` shows Claude Code's 5-hour and 7-day usage windows as the status line last saw them, and whether the 7-day one has reached `cost.weekly_limit_stop_pct` (default 90%), where `/pan:focus-auto` and `/pan:army` stop. Interactive Claude Code sessions on a subscription only: headless runs and other runtimes have no reading.
87
+
84
88
  ### `rebuild`
85
89
 
86
90
  Rebuild the ledger from Claude Code's own transcripts (session file plus the per-agent files under `<session>/subagents/`, Workflow-tool subagents one level down). Rows written by hooks before v3.29 booked a slice of the parent session to whichever subagent stopped and counted turns once per content block; the rebuild replaces them with one exact row per agent transcript, typed from the main thread's `Agent` calls, plus one row per session for the main thread's own usage (`--no-main-thread` omits it). Rows whose session transcript is gone, and caller-appended rows, are kept. Dry-run by default — show the user the per-session before → after (and any `warnings`), then apply only on their say-so; the previous ledger is kept beside the new one as `tokens.jsonl.rebuilt-<date>` (a later copy never overwrites an earlier one). Run it **before** `/pan:hygiene --apply` on a poisoned ledger: quarantine moves the whole file aside, and a rebuild afterwards has no rows left to keep. The main-thread row is dated to the session's last record, so `--since`/`--until` windows and the per-day view see a session's own usage on its final day.
@@ -134,7 +138,7 @@ If `.planning/metrics/tokens.jsonl` is empty, `/pan:cost` returns zero totals
134
138
  | Runtime | Support |
135
139
  |---------|---------|
136
140
  | Claude Code | Full — data format + aggregation + all output formats |
137
- | OpenCode | Full aggregator; PAN registers no hooks on OpenCode, so records come from `pan-tools cost append` or an external script |
141
+ | OpenCode | Full aggregator; PAN's only OpenCode hook is its plugin's compaction hook (`plugins/pan-wizard.js`), so cost records come from `pan-tools cost append` or an external script |
138
142
  | Gemini | Full aggregator; PAN registers no cost hook on Gemini CLI (no subagent-completion event), so records come from `pan-tools cost append` or an external script |
139
143
  | Codex | Full — `pan-cost-logger` registered on `SubagentStop` in `.codex/hooks.json` |
140
144
  | Copilot CLI | Full aggregator; `pan-cost-logger` registered on `subagentStop` in `.github/hooks/pan.json` (token counts depend on what the payload carries) |
@@ -35,7 +35,7 @@ ls .planning/debug/*.md 2>/dev/null | grep -v resolved | head -5
35
35
  INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state load)
36
36
  ```
37
37
 
38
- Extract `commit_docs` from init JSON. Resolve debugger model:
38
+ Extract `config.commit_docs` from the JSON (`state load` nests it under `config`). Resolve debugger model:
39
39
  ```bash
40
40
  DEBUGGER_MODEL=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs resolve-model pan-debugger --raw)
41
41
  ```
@@ -125,7 +125,10 @@ Task(
125
125
 
126
126
  ## 4. Handle Agent Return
127
127
 
128
- **If `## ROOT CAUSE FOUND`:**
128
+ **If `## DEBUG COMPLETE`** (the success return for `goal: find_and_fix`, after the user confirmed the fix at the `human-verify` checkpoint):
129
+ - Display the root cause, the fix, its verification and the commit; the session file is now `.planning/debug/resolved/{slug}.md`
130
+
131
+ **If `## ROOT CAUSE FOUND`** (returned only for `goal: find_root_cause_only`, which this command does not pass):
129
132
  - Display root cause and evidence summary
130
133
  - Offer options:
131
134
  - "Fix now" - spawn fix subagent
@@ -148,7 +151,7 @@ Task(
148
151
  - "Add more context" - gather more symptoms, spawn again
149
152
 
150
153
  <debug_handoff_schema>
151
- Debug session files (`.planning/debug/{slug}.md`) MUST contain structured state for cross-agent handoff:
154
+ Debug session files (`.planning/debug/{slug}.md`) follow pan-debugger's own structure (agents/pan-debugger.md, "File Structure"): frontmatter `status: gathering | investigating | diagnosed | fixing | verifying | awaiting_human_verify | resolved`, then Current Focus, Symptoms, Reproduction, Eliminated, Evidence and Resolution. The YAML below names the facts a handoff needs; its field names and status values are not the file's:
152
155
 
153
156
  ```yaml
154
157
  # Required sections in debug session file
@@ -182,7 +185,7 @@ fix: # Populated when applied
182
185
  tests_added: ["{test paths}"]
183
186
  ```
184
187
 
185
- **Why structured:** Each continuation agent starts with 0 context. Without structured state, it re-reads the entire investigation log and may re-test eliminated hypotheses. With structured state, it reads `hypotheses_tested` (skip these), checks `hypotheses_remaining` (do these next), and picks up exactly where the previous agent stopped.
188
+ **Why structured:** Each continuation agent starts with 0 context. Without structured state, it re-reads the entire investigation log and may re-test eliminated hypotheses. With structured state, it skips the hypotheses under Eliminated, starts from Current Focus `next_action`, and picks up exactly where the previous agent stopped.
186
189
  </debug_handoff_schema>
187
190
 
188
191
  ## 5. Spawn Continuation Agent (After Checkpoint)
@@ -210,9 +213,9 @@ goal: find_and_fix
210
213
  </mode>
211
214
 
212
215
  <handoff_instructions>
213
- 1. Parse the debug file's structured sections (symptoms, investigation, root_cause, fix)
214
- 2. Do NOT re-test hypotheses marked "eliminated" — they are dead ends
215
- 3. Start from hypotheses_remaining or the checkpoint's next action
216
+ 1. Parse the debug file's sections (frontmatter status, Current Focus, Symptoms, Reproduction, Eliminated, Evidence, Resolution — the format in templates/debug.md)
217
+ 2. Do NOT re-test hypotheses listed under Eliminated — they are dead ends
218
+ 3. Start from Current Focus `next_action` or the checkpoint's next action
216
219
  4. Update the debug file's structured sections as you progress
217
220
  </handoff_instructions>
218
221
  ```
@@ -2,7 +2,7 @@
2
2
  name: pan:design-phase
3
3
  group: Phase Lifecycle
4
4
  description: Design a roadmap phase before planning — architecture, ADR, threat-lite, machine-checkable criteria — verified by an independent checker
5
- argument-hint: "[phase] [--spike] [--skip-design] [--redesign]"
5
+ argument-hint: "<phase> [--spike] [--skip-design] [--redesign]"
6
6
  agent: pan-designer
7
7
  allowed-tools:
8
8
  - Read
@@ -57,7 +57,7 @@ ELSE (default):
57
57
  - If it PASSES → done.
58
58
  - If it finds gaps (iteration 1) → `pan-designer` revises (address genuine gaps only), re-check.
59
59
  - If it finds gaps (iteration 2) → final revision, record remaining gaps as caveats.
60
- - **Max 2 revision iterations** (design → check → revise → check → final) — the same guardrail `plan-phase` uses with `pan-plan-checker`.
60
+ - **Max 2 revision iterations** (design → check → revise → check → final revision, not re-checked). `plan-phase` also caps its loop at 2 revisions, but checks a third time after the second.
61
61
  - **Record each check.** Save the checker's returned text verbatim to `{phase_dir}/{padded_phase}-design-check.md` with the Write tool. Record it and branch on the verdict it prints (`PASS` or `GAPS`):
62
62
  ```bash
63
63
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings record --phase "{phase}" --agent pan-design-checker --file "{phase_dir}/{padded_phase}-design-check.md" --raw
@@ -81,5 +81,5 @@ Design FAILS if: phase not found in roadmap, or the designer returns empty/malfo
81
81
  </completion_contract>
82
82
 
83
83
  <handoff>
84
- `{phase}-design.md` is an **optional upstream input** to `/pan:plan-phase`, consumed by `pan-planner` exactly as `{phase}-context.md` is. `pan-plan-checker` verifies the plan conforms to it (Design Conformance dimension). A phase without a design.md still plans — the design step strengthens planning, it does not gate it.
84
+ `{phase}-design.md` is an **optional upstream input** to `/pan:plan-phase`, consumed by `pan-planner` like `{phase}-context.md` — except that the plan-phase workflow does not list it in the planner's or checker's `<files_to_read>`, so both use it only when they find it in the phase directory. `pan-plan-checker` verifies the plan conforms to it (Design Conformance dimension). A phase without a design.md still plans — the design step strengthens planning, it does not gate it.
85
85
  </handoff>
@@ -33,6 +33,8 @@ Extract implementation decisions that downstream agents need — researcher and
33
33
  <context>
34
34
  Phase number: $ARGUMENTS (required)
35
35
 
36
+ **`--auto`** (or `workflow.auto_advance: true`): no questions — the workflow writes a minimal context.md from the roadmap goal, idea.md, project.md and requirements.md, then spawns plan-phase with `--auto`; the interactive steps below are skipped.
37
+
36
38
  Context files are resolved in-workflow using `init phase-op` and roadmap/state tool calls.
37
39
  </context>
38
40
 
@@ -2,7 +2,7 @@
2
2
  name: pan:exec-phase
3
3
  group: Phase Lifecycle
4
4
  description: Execute all plans in a phase with wave-based parallelization
5
- argument-hint: "<phase-number> [--gaps-only] [--skip-tests] [--skip-review] [--fast]"
5
+ argument-hint: "<phase-number> [--gaps-only] [--skip-tests] [--skip-review] [--fast] [--deep-review] [--hierarchical] [--auto]"
6
6
  allowed-tools:
7
7
  - Read
8
8
  - Write
@@ -31,38 +31,36 @@ Context budget: ~15% orchestrator, 100% fresh per subagent.
31
31
  Execution is complete when ALL conditions are met:
32
32
  1. Every plan in the phase has been dispatched to a subagent
33
33
  2. All subagents have returned (success or failure)
34
- 3. Full test suite passes with count >= pre-execution baseline
34
+ 3. The verifier's test gate ran the suite (or verification was skipped because `workflow.verifier` is off)
35
35
  4. All verified tasks committed with accurate commit messages
36
36
  5. state.md updated with phase progress
37
37
  6. Failed tasks (if any) logged with error classification and root cause
38
38
 
39
- Execution FAILS if: test count drops below baseline after all retries, or state corruption is detected.
39
+ Execution FAILS if: a plan fails and the user stops the run, or state corruption is detected.
40
40
  </completion_contract>
41
41
 
42
42
  <wave_dependencies>
43
- Discovery → Baseline: Test baseline MUST be captured before any wave executes (regression detection requires it)
44
- Baseline → Wave N: Each wave MUST wait for the previous wave to complete and pass verification
45
- Wave N → Commit N: Wave changes MUST pass tests before committing (don't commit broken code)
46
- All Waves → Final Verify: Full test suite MUST pass after all waves complete
47
- Final Verify → State Update: state.md MUST only be updated after verification passes
43
+ Discovery → Waves: executors commit each task themselves; the workflow's generate_tests step and the verifier's test gate run the suite (the orchestrator does not commit waves)
44
+ Wave N → Wave N+1: Each wave waits for the previous wave's executors to return; their summaries are spot-checked (summary.md, commits, no `## Self-Check: FAILED`) before the next wave starts
45
+ All Waves → Verify: the verifier's test gate judges the suite; a failed gate is a gap for `/pan:plan-phase <N> --gaps`, not a revert
46
+ Verify → Phase complete: `phase complete` runs only after verification passes (or a `human_needed` verdict is approved), or after the "verification skipped" report when `workflow.verifier` is off
48
47
 
49
48
  HARD STOP conditions (do not proceed to next wave):
50
- - Baseline capture fails (test suite broken before we start) → STOP, report to user
51
- - Wave N test count drops below baseline after 3 retries → revert wave, mark all wave tasks FAILED, continue to next wave
52
49
  - State corruption detected (malformed state.md or plan files) → STOP execution entirely, report to user
53
- - All waves complete but final test count < baseline → revert last wave, re-verify
50
+ - A plan failed and the user chose "Stop?" → partial completion report; if they continue, never run a plan that depends on a failed one (`phase-plan-index --failed`)
54
51
  </wave_dependencies>
55
52
 
56
53
  <context>
57
54
  Phase: $ARGUMENTS
58
55
 
59
56
  **Flags:**
60
- - `--gaps-only` — Execute only gap closure plans (plans with `gap_closure: true` in frontmatter). Use after verify-work creates fix plans.
57
+ - `--gaps-only` — Execute only gap closure plans (plans with `gap_closure: true` in frontmatter). Use after `/pan:plan-phase <N> --gaps` creates fix plans.
61
58
  - `--skip-tests` — Skip automatic test generation after execution completes.
62
59
  - `--skip-review` — Skip automatic code review after execution completes.
63
60
  - `--fast` — Skip both test generation and code review (implies `--skip-tests --skip-review`).
64
61
  - `--deep-review` — After the normal code review, run the deep review inline: the `/pan:review-deep` process, a security audit by pan-hardener plus a cross-check by pan-meta-reviewer, merged into `.planning/reviews/<N>/deep-review.md`. It builds on the normal review, so it is skipped with `--skip-review` or `--fast`. Recommended for phases touching auth, payment, PII, migrations, or public APIs. Costs roughly 3× a normal review.
65
- - `--hierarchical` (v3.4+, Claude Code only — needs native sub-agent spawning) — Spawn `pan-conductor` as a top-level orchestrator that decomposes the phase and spawns executor/reviewer/verifier sub-agents in sequence. `pan-conductor` runs on the reasoning tier under the default profile, which inherits the model you launched with (the `budget` profile drops it to mid). Bounded by safety harness: max 2 nesting levels, 12 spawns per phase, budget ceiling, `.planning/orchestration/abort` kill-switch. On runtimes that cannot spawn nested agents, this flag is a no-op with a warning and falls back to flat exec. Use only for large phases (≥4 autonomous plans) where wall-clock reduction justifies the ~20-30% orchestration tax.
62
+ - `--hierarchical` (v3.4+, Claude Code only — needs native sub-agent spawning) — Spawn `pan-conductor` as a top-level orchestrator that decomposes the phase and spawns executor/reviewer/verifier sub-agents in sequence. `pan-conductor` carries no `model:` and is spawned without one, so it runs on the model you launched the session with under every profile. Bounded by safety harness: max 2 nesting levels, 12 spawns per phase, budget ceiling, `.planning/orchestration/abort` kill-switch. On runtimes that cannot spawn nested agents, this flag is a no-op with a warning and falls back to flat exec. Use only for large phases (≥4 autonomous plans) where wall-clock reduction justifies the ~20-30% orchestration tax.
63
+ - `--auto` — Autonomous chain: sets `workflow.auto_advance`, and once verification passes with no gaps runs the transition to the next phase instead of stopping at a menu. `/pan:plan-phase --auto` passes `--auto --no-transition`, which stops after verification and the roadmap update and returns `PHASE COMPLETE`, or returns `GAPS FOUND` (no roadmap update) when verification finds gaps.
66
64
 
67
65
  Context files are resolved inside the workflow via `pan-tools init execute-phase` and per-subagent `<files_to_read>` blocks.
68
66
  </context>
@@ -73,34 +71,20 @@ Each execution stage has a restricted set of appropriate actions. Using the wron
73
71
  | Stage | Read | Grep/Glob | Edit/Write | Bash (tests) | Bash (git) | Agent |
74
72
  |-------|------|-----------|------------|--------------|------------|-------|
75
73
  | Discovery (find plans) | YES | YES | NO | NO | NO | NO |
76
- | Baseline capture | YES | NO | NO | YES | YES | NO |
77
74
  | Wave execution | YES | YES | YES | YES | NO | YES |
78
75
  | Wave verification | YES | YES | NO | YES | NO | NO |
79
- | Wave commit | NO | NO | NO | NO | YES | NO |
80
76
  | Final verification | YES | YES | NO | YES | NO | NO |
81
77
  | State update | YES | NO | YES | NO | YES | NO |
82
78
 
83
79
  **Key constraints:**
84
80
  - Discovery: read-only — do not modify files while figuring out what to execute
85
- - Baseline: run tests + git status only — no code changes before baseline is captured
86
81
  - Wave verification: NO Edit/Write — you are checking work, not doing more work
87
- - Wave commit: git operations only — all code changes must be done before committing
82
+ - Commits: each executor commits its own tasks; the orchestrator makes no wave commits, and commits the phase's tracking files after `phase complete`
88
83
  </action_gating>
89
84
 
90
- <cache_priming>
91
- **Before Discovery, prime the prompt cache once per invocation.** All subagents spawned within the next 5 minutes will hit the cache instead of re-sending the full context.
92
-
93
- Run once:
94
- ```
95
- pan-tools cache prime --summary
96
- ```
97
-
98
- This returns `{blocks: [{path, bytes, cache}], total_bytes, sha}` for the cacheable set (project.md, requirements.md, roadmap.md, state.md, standards.md). The `sha` is stable across identical inputs, so repeated calls within the phase hit cached reads.
99
-
100
- When spawning subagents for wave execution, include the cacheable block paths in each agent's system-context so a host runtime that supports prompt caching (Claude Code does) can mark them `cache_control: ephemeral`. Where prompt caching is unavailable, this step is a no-op — nothing breaks, just no savings.
101
- </cache_priming>
102
-
103
85
  <process>
86
+ **With `--hierarchical` on Claude Code:** run the workflow below, but in place of its wave execution, code review and `verify_phase_goal` spawn, spawn `pan-conductor` (`subagent_type="pan-conductor"`) with the phase number and the other flags: it runs the executors, the reviewer and the verifier itself, under its safety harness. When it returns, route on the verification its verifier wrote, as `verify_phase_goal` does, and carry on with the steps after it. On any other runtime, print `--hierarchical is not supported on <runtime>. Falling back to flat exec.` and run the workflow unchanged.
87
+
104
88
  Execute the execute-phase workflow from @~/.claude/pan-wizard-core/workflows/exec-phase.md end-to-end.
105
89
  Preserve all workflow gates (wave execution, checkpoint handling, verification, state updates, routing).
106
90
 
@@ -111,25 +95,25 @@ Preserve all workflow gates (wave execution, checkpoint handling, verification,
111
95
 
112
96
  **Attention Anchor — emit after each wave completes:**
113
97
  ```
114
- Wave {N}/{total} complete | Tasks: {done}/{total} | Tests: {baseline} → {current}
98
+ Wave {N}/{total} complete | Plans: {done}/{total} | Failed: {plan IDs, or none}
115
99
  Remaining waves: {list of wave numbers with task counts}
116
100
  Next: Wave {N+1} — {task count} tasks [{task IDs}]
117
101
  ```
118
- This prevents drift in multi-wave phases where the agent loses track of which waves remain and what the test baseline was.
102
+ This prevents drift in multi-wave phases where the agent loses track of which waves remain and which plans failed.
119
103
 
120
104
  **Task tracking:** where your runtime offers a todo or task-tracking tool, you may keep the wave list in it. Do not depend on one: some runtimes offer none on their newest models (Claude Code gates its task tools behind `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` there). The attention anchor above, the wave summaries and state.md are the record either way.
121
105
 
122
106
  **State Intent Before Implementing (M+ tasks):**
123
107
  For each STANDARD or FULL task, state before coding: "I will modify [files], adding [what], to achieve [goal]. Risk: [what could break]."
124
108
 
125
- **Pre-Commit Verification Checklist — apply before each wave commit:**
109
+ **Pre-Commit Verification Checklist — the executors commit each task themselves (there is no wave commit); check their work against it when a wave returns:**
126
110
  1. Every modified file was read before editing
127
- 2. `git diff --stat` contains only files related to the current wave's tasks
128
- 3. Test suite passes and count meets or exceeds pre-wave baseline
111
+ 2. The wave's commits touch only files related to its tasks
112
+ 3. No summary carries `## Self-Check: FAILED` (the suite as a whole is judged by the verifier's test gate)
129
113
  4. Commit message lists only tasks that are verified (tests ran, tests passed)
130
- 5. No secrets or credentials staged
114
+ 5. No secrets or credentials in the wave's commits
131
115
 
132
- If any check fails: fix and re-verify before committing.
116
+ If any check fails: treat that plan as failed and route it as the workflow's spot-check does ("Retry plan?" or "Continue with remaining waves?").
133
117
 
134
118
  **Error Recovery Classification — apply when any task fails:**
135
119
  - RECOVERABLE (retry up to 3 times): test failure after code change, build syntax error, file not found (search for moved path)