pan-wizard 3.32.0 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/README.md +23 -20
  2. package/agents/pan-conductor.md +18 -17
  3. package/agents/pan-counterfactual.md +2 -2
  4. package/agents/pan-debugger.md +27 -8
  5. package/agents/pan-design-checker.md +1 -1
  6. package/agents/pan-designer.md +2 -2
  7. package/agents/pan-distiller.md +3 -3
  8. package/agents/pan-document_code.md +16 -16
  9. package/agents/pan-executor.md +15 -11
  10. package/agents/pan-experiment-runner.md +15 -17
  11. package/agents/pan-hardener.md +15 -15
  12. package/agents/pan-integration-checker.md +2 -2
  13. package/agents/pan-knowledge.md +2 -2
  14. package/agents/pan-meta-reviewer.md +5 -5
  15. package/agents/pan-optimizer.md +40 -44
  16. package/agents/pan-phase-researcher.md +10 -10
  17. package/agents/pan-plan-checker.md +36 -30
  18. package/agents/pan-planner.md +77 -53
  19. package/agents/pan-previewer.md +1 -1
  20. package/agents/pan-project-researcher.md +21 -78
  21. package/agents/pan-release.md +1 -1
  22. package/agents/pan-research-synthesizer.md +2 -2
  23. package/agents/pan-reviewer.md +24 -2
  24. package/agents/pan-roadmapper.md +20 -62
  25. package/agents/pan-verifier.md +53 -30
  26. package/bin/install-lib.cjs +228 -38
  27. package/bin/install.js +86 -15
  28. package/commands/pan/army.md +16 -12
  29. package/commands/pan/assumptions.md +2 -2
  30. package/commands/pan/audit-deployment.md +11 -12
  31. package/commands/pan/cost.md +8 -4
  32. package/commands/pan/debug.md +10 -7
  33. package/commands/pan/design-phase.md +3 -3
  34. package/commands/pan/discuss-phase.md +2 -0
  35. package/commands/pan/exec-phase.md +21 -37
  36. package/commands/pan/experiment.md +11 -10
  37. package/commands/pan/focus-auto.md +33 -27
  38. package/commands/pan/focus-design.md +9 -6
  39. package/commands/pan/focus-doc-audit.md +4 -3
  40. package/commands/pan/focus-drift-walking.md +4 -3
  41. package/commands/pan/focus-exec.md +7 -7
  42. package/commands/pan/focus-plan.md +12 -11
  43. package/commands/pan/focus-scan.md +7 -10
  44. package/commands/pan/focus-sync.md +3 -2
  45. package/commands/pan/git.md +8 -8
  46. package/commands/pan/health.md +2 -2
  47. package/commands/pan/hud.md +3 -2
  48. package/commands/pan/hygiene.md +14 -7
  49. package/commands/pan/knowledge.md +9 -9
  50. package/commands/pan/learn.md +10 -7
  51. package/commands/pan/links.md +4 -1
  52. package/commands/pan/map-codebase.md +5 -5
  53. package/commands/pan/mcp-bridge.md +18 -18
  54. package/commands/pan/milestone-done.md +7 -5
  55. package/commands/pan/milestone-new.md +1 -1
  56. package/commands/pan/new-project.md +10 -10
  57. package/commands/pan/optimize.md +16 -14
  58. package/commands/pan/patches.md +2 -6
  59. package/commands/pan/pause.md +1 -1
  60. package/commands/pan/phase-tests.md +4 -3
  61. package/commands/pan/plan-phase.md +9 -19
  62. package/commands/pan/preview.md +1 -1
  63. package/commands/pan/profile.md +4 -4
  64. package/commands/pan/quick.md +1 -1
  65. package/commands/pan/remove-phase.md +1 -1
  66. package/commands/pan/report.md +2 -2
  67. package/commands/pan/research-phase.md +14 -15
  68. package/commands/pan/resume.md +9 -11
  69. package/commands/pan/retro.md +5 -3
  70. package/commands/pan/review-deep.md +10 -10
  71. package/commands/pan/settings.md +1 -1
  72. package/commands/pan/todo-add.md +2 -2
  73. package/commands/pan/todo-check.md +2 -2
  74. package/commands/pan/verify-phase.md +0 -11
  75. package/commands/pan/what-if.md +2 -2
  76. package/hooks/dist/pan-context-monitor.js +343 -44
  77. package/hooks/dist/pan-cost-logger.js +30 -0
  78. package/hooks/dist/pan-state-reinject.js +140 -15
  79. package/hooks/dist/pan-statusline.js +68 -22
  80. package/hooks/dist/pan-stop-guard.js +7 -2
  81. package/package.json +1 -1
  82. package/pan-wizard-core/bin/lib/agents-md.cjs +48 -7
  83. package/pan-wizard-core/bin/lib/bridge.cjs +6 -5
  84. package/pan-wizard-core/bin/lib/campaign.cjs +4 -2
  85. package/pan-wizard-core/bin/lib/commands-learnings.cjs +19 -2
  86. package/pan-wizard-core/bin/lib/commands.cjs +126 -5
  87. package/pan-wizard-core/bin/lib/config.cjs +112 -1
  88. package/pan-wizard-core/bin/lib/constants.cjs +29 -15
  89. package/pan-wizard-core/bin/lib/context-budget.cjs +12 -9
  90. package/pan-wizard-core/bin/lib/core.cjs +77 -23
  91. package/pan-wizard-core/bin/lib/cost-rebuild.cjs +13 -1
  92. package/pan-wizard-core/bin/lib/cost.cjs +149 -10
  93. package/pan-wizard-core/bin/lib/distill.cjs +6 -3
  94. package/pan-wizard-core/bin/lib/doc-lint.cjs +30 -11
  95. package/pan-wizard-core/bin/lib/findings.cjs +15 -4
  96. package/pan-wizard-core/bin/lib/focus.cjs +13 -4
  97. package/pan-wizard-core/bin/lib/frontmatter.cjs +105 -26
  98. package/pan-wizard-core/bin/lib/hygiene.cjs +178 -17
  99. package/pan-wizard-core/bin/lib/init.cjs +12 -5
  100. package/pan-wizard-core/bin/lib/knowledge.cjs +17 -1
  101. package/pan-wizard-core/bin/lib/learn-index.cjs +111 -10
  102. package/pan-wizard-core/bin/lib/learn-lint.cjs +30 -3
  103. package/pan-wizard-core/bin/lib/memory-optimize.cjs +8 -4
  104. package/pan-wizard-core/bin/lib/memory.cjs +508 -54
  105. package/pan-wizard-core/bin/lib/milestone.cjs +8 -3
  106. package/pan-wizard-core/bin/lib/optimize.cjs +84 -16
  107. package/pan-wizard-core/bin/lib/phase-remove.cjs +85 -21
  108. package/pan-wizard-core/bin/lib/phase-report.cjs +8 -2
  109. package/pan-wizard-core/bin/lib/phase.cjs +67 -15
  110. package/pan-wizard-core/bin/lib/preview.cjs +3 -1
  111. package/pan-wizard-core/bin/lib/review-deep.cjs +2 -2
  112. package/pan-wizard-core/bin/lib/roadmap-compact.cjs +267 -0
  113. package/pan-wizard-core/bin/lib/roadmap.cjs +243 -9
  114. package/pan-wizard-core/bin/lib/runner.cjs +2 -1
  115. package/pan-wizard-core/bin/lib/state-compact.cjs +11 -6
  116. package/pan-wizard-core/bin/lib/state.cjs +47 -31
  117. package/pan-wizard-core/bin/lib/template.cjs +11 -4
  118. package/pan-wizard-core/bin/lib/verdict.cjs +54 -4
  119. package/pan-wizard-core/bin/lib/verify-drift.cjs +14 -5
  120. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -13
  121. package/pan-wizard-core/bin/lib/verify-retro.cjs +5 -3
  122. package/pan-wizard-core/bin/lib/verify-scope.cjs +74 -4
  123. package/pan-wizard-core/bin/lib/verify.cjs +117 -35
  124. package/pan-wizard-core/bin/lib/whatif.cjs +5 -3
  125. package/pan-wizard-core/bin/pan-tools.cjs +111 -17
  126. package/pan-wizard-core/learnings/index.json +5 -5
  127. package/pan-wizard-core/mcp/server.cjs +18 -9
  128. package/pan-wizard-core/opencode/pan-wizard.js +111 -0
  129. package/pan-wizard-core/references/checkpoints.md +7 -5
  130. package/pan-wizard-core/references/continuation-format.md +3 -3
  131. package/pan-wizard-core/references/decimal-phase-calculation.md +2 -3
  132. package/pan-wizard-core/references/design-methodology.md +1 -1
  133. package/pan-wizard-core/references/git-integration.md +4 -6
  134. package/pan-wizard-core/references/git-planning-commit.md +2 -2
  135. package/pan-wizard-core/references/guardrails.md +2 -2
  136. package/pan-wizard-core/references/handoff-decisions.md +3 -3
  137. package/pan-wizard-core/references/model-profile-resolution.md +5 -5
  138. package/pan-wizard-core/references/model-profiles.md +14 -9
  139. package/pan-wizard-core/references/phase-argument-parsing.md +7 -7
  140. package/pan-wizard-core/references/planning-config.md +4 -4
  141. package/pan-wizard-core/references/tdd.md +10 -1
  142. package/pan-wizard-core/references/verdict-contract.md +2 -1
  143. package/pan-wizard-core/references/verification-patterns.md +5 -5
  144. package/pan-wizard-core/templates/codebase/architecture.md +2 -2
  145. package/pan-wizard-core/templates/codebase/best-practices.md +2 -2
  146. package/pan-wizard-core/templates/codebase/concerns.md +3 -3
  147. package/pan-wizard-core/templates/codebase/integrations.md +6 -6
  148. package/pan-wizard-core/templates/codebase/relationships.md +2 -2
  149. package/pan-wizard-core/templates/codebase/stack.md +2 -2
  150. package/pan-wizard-core/templates/codebase/structure.md +4 -4
  151. package/pan-wizard-core/templates/codebase/testing.md +4 -4
  152. package/pan-wizard-core/templates/continue-here.md +1 -1
  153. package/pan-wizard-core/templates/debug-subagent-prompt.md +3 -2
  154. package/pan-wizard-core/templates/debug.md +15 -1
  155. package/pan-wizard-core/templates/discovery.md +1 -1
  156. package/pan-wizard-core/templates/milestone-archive.md +6 -6
  157. package/pan-wizard-core/templates/milestone.md +1 -1
  158. package/pan-wizard-core/templates/phase-prompt.md +31 -18
  159. package/pan-wizard-core/templates/planner-subagent-prompt.md +3 -5
  160. package/pan-wizard-core/templates/research-project/architecture.md +3 -3
  161. package/pan-wizard-core/templates/research-project/features.md +1 -1
  162. package/pan-wizard-core/templates/research-project/pitfalls.md +1 -1
  163. package/pan-wizard-core/templates/research-project/stack.md +3 -3
  164. package/pan-wizard-core/templates/research.md +5 -5
  165. package/pan-wizard-core/templates/retrospective.md +1 -1
  166. package/pan-wizard-core/templates/roadmap.md +15 -15
  167. package/pan-wizard-core/templates/summary-complex.md +1 -0
  168. package/pan-wizard-core/templates/summary-minimal.md +1 -0
  169. package/pan-wizard-core/templates/summary-standard.md +2 -1
  170. package/pan-wizard-core/templates/summary.md +18 -2
  171. package/pan-wizard-core/templates/uat.md +3 -3
  172. package/pan-wizard-core/templates/user-setup.md +8 -8
  173. package/pan-wizard-core/templates/verification-report.md +54 -4
  174. package/pan-wizard-core/workflows/add-phase.md +1 -1
  175. package/pan-wizard-core/workflows/assumptions.md +1 -1
  176. package/pan-wizard-core/workflows/discuss-phase.md +9 -8
  177. package/pan-wizard-core/workflows/exec-phase.md +34 -60
  178. package/pan-wizard-core/workflows/execute-plan.md +8 -7
  179. package/pan-wizard-core/workflows/health.md +13 -11
  180. package/pan-wizard-core/workflows/help.md +8 -9
  181. package/pan-wizard-core/workflows/learn.md +13 -11
  182. package/pan-wizard-core/workflows/map-codebase.md +10 -10
  183. package/pan-wizard-core/workflows/milestone-audit.md +10 -10
  184. package/pan-wizard-core/workflows/milestone-gaps.md +17 -24
  185. package/pan-wizard-core/workflows/milestone-new.md +7 -6
  186. package/pan-wizard-core/workflows/new-project.md +10 -10
  187. package/pan-wizard-core/workflows/optimize.md +11 -9
  188. package/pan-wizard-core/workflows/pause.md +6 -1
  189. package/pan-wizard-core/workflows/phase-tests.md +4 -4
  190. package/pan-wizard-core/workflows/plan-phase.md +31 -34
  191. package/pan-wizard-core/workflows/profile.md +2 -2
  192. package/pan-wizard-core/workflows/progress.md +5 -7
  193. package/pan-wizard-core/workflows/quick.md +10 -8
  194. package/pan-wizard-core/workflows/remove-phase.md +1 -1
  195. package/pan-wizard-core/workflows/research-phase.md +9 -5
  196. package/pan-wizard-core/workflows/resume-project.md +4 -6
  197. package/pan-wizard-core/workflows/retro.md +3 -1
  198. package/pan-wizard-core/workflows/settings.md +16 -24
  199. package/pan-wizard-core/workflows/todo-check.md +1 -1
  200. package/pan-wizard-core/workflows/transition.md +12 -12
  201. package/pan-wizard-core/workflows/update.md +25 -17
  202. package/pan-wizard-core/workflows/verify-phase.md +24 -17
  203. package/pan-zcode/KNOWN-BETA-RISKS.md +2 -2
  204. package/pan-zcode/README.md +7 -7
  205. package/pan-zcode/bin/install-zcode.js +1 -1
  206. package/scripts/build-agent-plugin.js +19 -5
  207. package/scripts/build-plugin.js +3 -1
  208. package/scripts/generate-skills-docs.py +13 -4
  209. package/scripts/test-surface.cjs +4 -0
@@ -24,19 +24,32 @@ case "$VERSION_FILE" in
24
24
  ./*) SCOPE="LOCAL" ;;
25
25
  *) SCOPE="GLOBAL" ;;
26
26
  esac
27
+ # The same templated path names the runtime: the installer rewrites ~/.claude/ to
28
+ # this runtime's own directory. With no runtime flag the installer installs Claude
29
+ # Code only, so the flag must be passed.
30
+ case "$VERSION_FILE" in
31
+ *.codex/*) RUNTIME="--codex" ;;
32
+ *.gemini/*) RUNTIME="--gemini" ;;
33
+ *opencode/*) RUNTIME="--opencode" ;;
34
+ *.github/*|*.copilot/*) RUNTIME="--copilot" ;;
35
+ *) RUNTIME="--claude" ;;
36
+ esac
27
37
 
28
38
  if [ -f "$VERSION_FILE" ] && [ -f "$MARKER_FILE" ] && grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+' "$VERSION_FILE"; then
29
39
  cat "$VERSION_FILE"
40
+ echo "$RUNTIME"
30
41
  echo "$SCOPE"
31
42
  else
32
43
  echo "UNKNOWN"
44
+ echo "$RUNTIME"
45
+ echo "$SCOPE"
33
46
  fi
34
47
  ```
35
48
 
36
- Parse output (there is ONE install; scope is derived from the shape of the single templated prefix):
37
- - If last line is "LOCAL": this install is local-scoped (templated prefix is `./`-relative); installed version is first line; use `--local`
38
- - If last line is "GLOBAL": this install is global-scoped (templated prefix is an absolute path); installed version is first line; use `--global`
39
- - If "UNKNOWN": the VERSION/marker files are missing or invalid; proceed to install step (treat as version 0.0.0)
49
+ Parse output (there is ONE install; scope and runtime are derived from the single templated prefix). The output is three lines: the installed version (or `UNKNOWN`), the runtime flag (`--claude`, `--codex`, `--gemini`, `--opencode` or `--copilot`) and the scope. Remember the runtime flag: the install step writes it into its command.
50
+ - If last line is "LOCAL": this install is local-scoped (templated prefix is `./`-relative); use `--local`
51
+ - If last line is "GLOBAL": this install is global-scoped (templated prefix is an absolute path); use `--global`
52
+ - If the first line is "UNKNOWN": the VERSION/marker files are missing or invalid; proceed to install step (treat as version 0.0.0) — the runtime and scope lines still apply
40
53
 
41
54
  **If VERSION file missing:**
42
55
  ```
@@ -63,7 +76,7 @@ npm view pan-wizard version 2>/dev/null
63
76
  ```
64
77
  Couldn't check for updates (offline or npm unavailable).
65
78
 
66
- To update manually: `npx pan-wizard --global`
79
+ To update manually: `npx -y pan-wizard@latest {runtime_flag} --global` (`--local` for a local install), with the runtime flag and scope step 1 printed
67
80
  ```
68
81
 
69
82
  Exit.
@@ -155,28 +168,23 @@ Run the update using the install type detected in step 1:
155
168
 
156
169
  **If LOCAL install:**
157
170
  ```bash
158
- npx -y pan-wizard@latest --local
171
+ npx -y pan-wizard@latest {runtime_flag} --local
159
172
  ```
160
173
 
161
- **If GLOBAL install (or unknown):**
174
+ **If GLOBAL install:**
162
175
  ```bash
163
- npx -y pan-wizard@latest --global
176
+ npx -y pan-wizard@latest {runtime_flag} --global
164
177
  ```
165
178
 
166
- Capture output. If install fails, show error and exit.
179
+ `{runtime_flag}` is the runtime line step 1 printed: write the flag itself into the command. A variable set in step 1's shell call is gone in this one (each Bash call starts a new shell), and an empty `""` argument in its place installs Claude Code only. A `--config-dir` or `--unified-skills` install is not recognised from its path: for those, re-run the installer with your original flags instead.
167
180
 
168
- Clear the update cache so statusline indicator disappears:
181
+ Capture output. If install fails, show error and exit.
169
182
 
170
- **If LOCAL install:**
171
- ```bash
172
- rm -f ~/.claude/cache/pan-update-check.json
173
- ```
183
+ Clear the update cache so the statusline indicator disappears. The update-check hook keeps it under your home directory for every install, local or global, in the runtime's own config directory: `.claude` (Claude Code), `.codex` (Codex), `.gemini` (Gemini CLI) or `.copilot` (Copilot CLI); OpenCode runs no update-check hook, so there is nothing to clear there:
174
184
 
175
- **If GLOBAL install:**
176
185
  ```bash
177
- rm -f ~/.claude/cache/pan-update-check.json
186
+ rm -f "$HOME/<config dir from the list above>/cache/pan-update-check.json"
178
187
  ```
179
- (Paths are templated at install time for runtime compatibility)
180
188
  </step>
181
189
 
182
190
  <step name="display_result">
@@ -22,7 +22,7 @@ Then verify each level against the actual codebase.
22
22
  @~/.claude/pan-wizard-core/references/guardrails.md
23
23
  @~/.claude/pan-wizard-core/templates/verification-report.md
24
24
 
25
- > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent verifier --token-budget 5000 --raw` to load only the topics tagged relevant for verification at the configured budget. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts.
25
+ > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent verifier --cue "<phase goal; the files it touches>" --token-budget 5000 --raw` to load the topics that match this task, within the budget; if none matches, it falls back to the topics tagged relevant for verification. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts.
26
26
  </required_reading>
27
27
 
28
28
  ## Re-Read Checkpoints
@@ -47,14 +47,15 @@ INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs init phase-op "${PHASE_A
47
47
 
48
48
  Extract from init JSON: `phase_dir`, `phase_number`, `phase_name`, `has_plans`, `plan_count`.
49
49
 
50
- Then load phase details and list plans/summaries:
50
+ Then load phase details, write the phase's roadmap slice, and list plans/summaries:
51
51
  ```bash
52
52
  node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${phase_number}"
53
- grep -E "^\|[^|]*\| *Phase +${phase_number} " .planning/requirements.md 2>/dev/null
53
+ SLICE_PATH=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap slice "${phase_number}" --write --raw)
54
+ grep -E "^\|[^|]*\| *Phase +0*${phase_number#0} " .planning/requirements.md 2>/dev/null
54
55
  ls "$phase_dir"/*-summary.md "$phase_dir"/*-plan.md 2>/dev/null
55
56
  ```
56
57
 
57
- Extract **phase goal** from roadmap.md (the outcome to verify, not tasks) and **requirements** from requirements.md if it exists.
58
+ Extract the **phase goal** and success criteria from `get-phase` (the outcome to verify, not tasks), and the phase's **requirements** from `$SLICE_PATH` (its `## Its requirements` lines). Do not read roadmap.md or requirements.md whole: on a long project they are the largest files in `.planning/`, and the slice carries what verification needs from them. If `SLICE_PATH` is empty, grep requirements.md for the phase's IDs instead.
58
59
  </step>
59
60
 
60
61
  <step name="check_prior_verification">
@@ -62,7 +63,7 @@ Extract **phase goal** from roadmap.md (the outcome to verify, not tasks) and **
62
63
 
63
64
  If `phase_number` > 1:
64
65
  ```bash
65
- PREV=$((phase_number - 1))
66
+ case "$phase_number" in *.*) PREV="${phase_number%%.*}" ;; *[A-Za-z]) PREV="${phase_number%[A-Za-z]}" ;; *) PREV=$((10#$phase_number - 1)) ;; esac
66
67
  # Resolve the previous phase's directory via find-phase (handles zero-padding
67
68
  # and the .planning/phases/ layout), like exec-phase does — do NOT glob
68
69
  # .planning/phase-N*/ (wrong dir, unpadded, matches nothing). With --raw,
@@ -120,6 +121,7 @@ executed. Empty is not zero. Judge the exit code, then the counts.
120
121
  | Condition | Action |
121
122
  |-----------|--------|
122
123
  | `TEST_EXIT` = 0 **and** `TEST_FAIL` = 0 (a real number) | Record counts, continue to must-haves |
124
+ | `TEST_EXIT` = 0 **and** no `ℹ` count lines (a runner other than Node's built-in one) | Set `test_gate_status: passed`; record the runner's own summary line as the counts |
123
125
  | `TEST_EXIT` ≠ 0 **and** failures were reported | Set `test_gate_status: failed`, include failure details |
124
126
  | `TEST_EXIT` ≠ 0 **and** `TEST_FAIL` is empty/absent — the suite CRASHED or could not run (syntax error, missing module, bad import, no runner) | Set `test_gate_status: failed`, and record the reason as `suite did not run`. **Never `skipped`, never `passed`.** A suite that cannot execute is stronger evidence of a broken phase than one that runs and fails |
125
127
  | `HAS_TEST` = `no` (handled in step 1) | Record as `test_gate_status: skipped`, continue. This is the ONLY legitimate route to `skipped` |
@@ -136,6 +138,10 @@ TEST_TOTAL: ${TEST_COUNT}
136
138
  TEST_PASSED: ${TEST_PASS}
137
139
  TEST_FAILED: ${TEST_FAIL}
138
140
  ```
141
+ Write `test_gate: ${TEST_GATE_STATUS}` into the verification.md frontmatter. When it is
142
+ `skipped`, also add a `not_checked` entry (`check: "tests"`, `reason: "no test script in
143
+ package.json"`). The recorder reads both: a pass whose tests never ran is recorded as a
144
+ pass with tests not checked, never as a plain pass.
139
145
 
140
146
  **If test gate FAILED:** Continue verification (gather full picture) but set overall status to `gaps_found` regardless of goal-backward results. Include test failures as gaps in the report.
141
147
  </step>
@@ -146,13 +152,13 @@ TEST_FAILED: ${TEST_FAIL}
146
152
  Use pan-tools to extract must_haves from each PLAN:
147
153
 
148
154
  ```bash
149
- for plan in "$PHASE_DIR"/*-plan.md; do
155
+ for plan in "$phase_dir"/*-plan.md; do
150
156
  MUST_HAVES=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs frontmatter get "$plan" --field must_haves)
151
157
  echo "=== $plan ===" && echo "$MUST_HAVES"
152
158
  done
153
159
  ```
154
160
 
155
- Returns JSON: `{ truths: [...], artifacts: [...], key_links: [...] }`
161
+ Returns `{ "must_haves": { truths: [...], artifacts: [...], key_links: [...] } }`: each truth a string, each artifact an object (`path`, `provides`, …), each key link an object (`from`, `to`, `via`).
156
162
 
157
163
  Aggregate all must_haves across plans for phase-level verification.
158
164
 
@@ -161,7 +167,7 @@ Aggregate all must_haves across plans for phase-level verification.
161
167
  If no must_haves in frontmatter (MUST_HAVES returns error or empty), check for Success Criteria:
162
168
 
163
169
  ```bash
164
- PHASE_DATA=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${phase_number}" --raw)
170
+ PHASE_DATA=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${phase_number}")
165
171
  ```
166
172
 
167
173
  Parse the `success_criteria` array from the JSON output. If non-empty:
@@ -196,7 +202,7 @@ For each truth: identify supporting artifacts → check artifact status → chec
196
202
  Use pan-tools for artifact verification against must_haves in each PLAN:
197
203
 
198
204
  ```bash
199
- for plan in "$PHASE_DIR"/*-plan.md; do
205
+ for plan in "$phase_dir"/*-plan.md; do
200
206
  ARTIFACT_RESULT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify artifacts "$plan")
201
207
  echo "=== $plan ===" && echo "$ARTIFACT_RESULT"
202
208
  done
@@ -228,7 +234,7 @@ WIRED = imported AND used. ORPHANED = exists but not imported/used.
228
234
  Use pan-tools for key link verification against must_haves in each PLAN:
229
235
 
230
236
  ```bash
231
- for plan in "$PHASE_DIR"/*-plan.md; do
237
+ for plan in "$phase_dir"/*-plan.md; do
232
238
  LINKS_RESULT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify key-links "$plan")
233
239
  echo "=== $plan ===" && echo "$LINKS_RESULT"
234
240
  done
@@ -238,8 +244,8 @@ Parse JSON result: `{ all_verified, verified, total, links: [{from, to, via, ver
238
244
 
239
245
  **Link status from result:**
240
246
  - `verified=true` → WIRED
241
- - `verified=false` with "not found" → NOT_WIRED
242
- - `verified=false` with "Pattern not found" → PARTIAL
247
+ - `verified=false` with detail "Source file not found" or "Target not referenced in source" → NOT_WIRED
248
+ - `verified=false` with detail `Pattern "…" not found in source or target` → PARTIAL
243
249
 
244
250
  **Fallback patterns (if key_links not in must_haves):**
245
251
 
@@ -256,7 +262,7 @@ Record status and evidence for each key link.
256
262
  <step name="verify_requirements">
257
263
  If requirements.md exists:
258
264
  ```bash
259
- grep -E "Phase ${PHASE_NUM}" .planning/requirements.md 2>/dev/null
265
+ grep -E "^\|[^|]*\| *Phase +0*${phase_number#0} " .planning/requirements.md 2>/dev/null
260
266
  ```
261
267
 
262
268
  For each requirement: parse description → identify supporting truths/artifacts → status: ✓ SATISFIED / ✗ BLOCKED / ? NEEDS HUMAN.
@@ -284,7 +290,7 @@ Format each as: Test Name → What to do → Expected result → Why can't verif
284
290
  </step>
285
291
 
286
292
  <step name="determine_status">
287
- **passed:** All truths VERIFIED, all artifacts pass levels 1-3, all key links WIRED, no blocker anti-patterns, AND test gate passed or skipped.
293
+ **passed:** All truths VERIFIED, all artifacts pass levels 1-3, all key links WIRED, no blocker anti-patterns, AND test gate passed or skipped. A skipped gate is listed in `not_checked` with its reason, and the report to the user says the tests did not run.
288
294
 
289
295
  **gaps_found:** Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, blocker found, OR test gate FAILED (test regressions detected).
290
296
 
@@ -305,10 +311,11 @@ If gaps_found:
305
311
 
306
312
  <step name="create_report">
307
313
  ```bash
308
- REPORT_PATH="$PHASE_DIR/${PHASE_NUM}-verification.md"
314
+ REPORT_PATH="$phase_dir/${phase_number}-verification.md"
315
+ VERIFIED_COMMIT=$(git rev-parse HEAD 2>/dev/null)
309
316
  ```
310
317
 
311
- Fill template sections: frontmatter (phase/timestamp/status/score), **test gate results** (status/total/passed/failed), goal achievement, artifact table, wiring table, requirements coverage, anti-patterns, human verification, gaps summary, fix plans (if gaps_found), metadata.
318
+ Fill template sections: frontmatter (phase/timestamp/`verified_commit: ${VERIFIED_COMMIT}`/status/score/`test_gate`), **test gate results** (status/total/passed/failed), goal achievement, artifact table, wiring table, requirements coverage, anti-patterns, human verification, gaps summary, fix plans (if gaps_found), metadata.
312
319
 
313
320
  See ~/.claude/pan-wizard-core/templates/verification-report.md for complete template.
314
321
  </step>
@@ -323,7 +330,7 @@ Orchestrator routes: `passed` → update_roadmap | `gaps_found` → create/execu
323
330
 
324
331
  **Record the verification.** The record adds its findings to the ledger and logs the outcome to the trace (`verdict_passed`, `verdict_failed` or `verdict_needs_human`). A re-verification is the next attempt, and it closes the gaps it no longer reports:
325
332
  ```bash
326
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings record --phase "${PHASE_NUMBER}" --file "$REPORT_PATH" 2>/dev/null || true
333
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings record --phase "${phase_number}" --file "$REPORT_PATH" 2>/dev/null || true
327
334
  ```
328
335
  Recording the same report twice is a no-op, so exec-phase recording it again after this workflow returns is safe.
329
336
  </step>
@@ -11,7 +11,7 @@ hard-depend on, and the go/no-go facts that can only be settled on a real ZCode
11
11
  | # | Question | If NO → fallback (already in the design) |
12
12
  |---|----------|------------------------------------------|
13
13
  | 1 | Can a **subagent call MCP tools**? | Primary Agent makes every `pan-mcp` call and feeds results into subagent prompts. Determinism unaffected. |
14
- | 2 | Are **local stdio MCP calls metered** against the MCP-Calls quota? | Read verbs are MCP *resources*, not tools; batch/cache; never make a hosted z.ai MCP load-bearing. |
14
+ | 2 | Are **local stdio MCP calls metered** against the MCP-Calls quota? | The read-only aggregators (`pan://state`, `pan://phases`, `pan://progress`, `pan://health`, `pan://links`, `pan://cost`, `pan://findings`) are MCP *resources*; reads that take an argument or fail without a roadmap (`pan_find_phase`, `pan_resolve_model`, `pan_roadmap_analyze`, `pan_preview_phases`, `pan_preview_phase`) and the per-step `pan_next_action` poll are tools, which a metered quota would count; batch/cache; never make a hosted z.ai MCP load-bearing. |
15
15
  | 3 | Exact **subagent frontmatter schema** / plugin layout / MCP config path? | Drive ZCode's own Import / Settings; treat `pan-zcode/lib/convert-agent.cjs` output as a labelled fallback, not a contract. |
16
16
  | 4 | Any **file-based / headless** way to register an MCP server, or GUI-only? | `install-zcode.js` emits a bundle + `INSTALL-ZCODE.md`; the human finishes in ZCode's UI. |
17
17
  | 5 | Any **lifecycle hook** that can hard-gate a spawn? | Enforce caps at the MCP-tool-call boundary (the orchestrator), not pre-spawn. |
@@ -21,7 +21,7 @@ hard-depend on, and the go/no-go facts that can only be settled on a real ZCode
21
21
  - **The merge gate is not self-sufficient.** Under ZCode Full Access, a raw Bash
22
22
  `git push` bypasses `pan_confirm_merge`. Non-bypassability rests on **server-side
23
23
  branch protection**; the MCP gate is the second, in-process lock. `INSTALL-ZCODE.md`
24
- mandates branch protection and "never Full Access during install."
24
+ mandates branch protection and "Never run the install/import step in ZCode Full Access mode."
25
25
  - **No subagent nesting.** The army flattens to one delegation layer (PAN already caps
26
26
  nesting at 2, so this is tolerable). `Task` is dropped from ported subagents.
27
27
  - **User-global subagents only.** No repo-scoped rosters or per-project model profiles.
@@ -1,6 +1,6 @@
1
1
  # PAN-Z — a ZCode-native PAN subsystem
2
2
 
3
- PAN-Z gives [ZCode](https://zcode.z.ai) (z.ai's GLM-5.2 coding harness) the PAN Wizard
3
+ PAN-Z gives [ZCode](https://zcode.z.ai) (z.ai's GLM coding harness) the PAN Wizard
4
4
  workflow — the multi-phase lifecycle, the bot-army with a human merge gate, deterministic
5
5
  state tracking — **without** cloning PAN's slash-commands or hooks (ZCode has neither).
6
6
 
@@ -14,7 +14,7 @@ ZCode through the one interface it speaks: **MCP**.
14
14
  ## How it fits
15
15
 
16
16
  ```text
17
- ZCode harness (GLM-5.2) primary Agent drives everything; ported subagents fan out
17
+ ZCode harness (GLM) primary Agent drives everything; ported subagents fan out
18
18
  │ MCP · local stdio
19
19
  pan-wizard-core/mcp (SHARED) a thin, zero-dep bridge — verbs → MCP tools/resources
20
20
  │ spawn: node pan-tools.cjs <verb> --cwd <root>
@@ -28,13 +28,13 @@ registration pointing at that shared path. **Never fork a copy back under `pan-z
28
28
  protocol layer, many consumers, or the two drift the way the per-runtime command trees did
29
29
  before ADR-0028.
30
30
 
31
- **Scope boundary (by design):** the bridge exposes `pan-tools` verbs as MCP tools/resources and nothing more. It intentionally does **not** carry rich agent *session state* — diffs, streaming, live thread lifecycle — because MCP can't faithfully represent it (the reason OpenAI built the Codex harness as a native Rust core rather than over MCP). Keep the bridge to tool/resource exposure; the CLI's JSON contract is the tool contract. See `KNOWN-BETA-RISKS.md`.
31
+ **Scope boundary (by design):** the bridge exposes `pan-tools` verbs as MCP tools/resources, plus the in-process `next-action` and merge-gate tools (M2), and nothing more. It intentionally does **not** carry rich agent *session state* — diffs, streaming, live thread lifecycle — because MCP can't faithfully represent it (the reason OpenAI built the Codex harness as a native Rust core rather than over MCP). Keep the bridge to tool/resource exposure; the CLI's JSON contract is the tool contract. See `KNOWN-BETA-RISKS.md`.
32
32
 
33
33
  ## Status — M1–M5 built (M0 is the human verify spike)
34
34
 
35
35
  - **M1 — bridge core.** `pan-wizard-core/mcp/tool-registry.cjs` (pure verb→tool/resource map, with a hard
36
36
  guardrail against exposing a force/reset/rebase/push verb) + `pan-wizard-core/mcp/server.cjs` (a
37
- **zero-dependency** JSON-RPC 2.0 stdio MCP server; reads → resources, actions → tools with
37
+ **zero-dependency** JSON-RPC 2.0 stdio MCP server; read-only aggregators readable on any project → resources; reads that take an argument or fail without a roadmap, and actions → tools with
38
38
  accurate hints; shell-less `execFile` spawn; `@file:` overflow protocol; strict per-arg
39
39
  validation). **Dual-era** per the MCP 2026-07-28 stateless spec (ADR-0041): legacy clients
40
40
  use the `initialize` handshake; modern clients declare their protocol version in each
@@ -73,6 +73,6 @@ implemented.
73
73
  ## Zero dependencies
74
74
 
75
75
  Like the rest of PAN, this subsystem ships **no runtime dependencies**. The MCP protocol is
76
- implemented directly rather than via an SDK. If protocol drift ever makes that costly, the
77
- escape hatch is to vendor an MCP SDK **inside this package only**, leaving `pan-wizard-core`
78
- untouched.
76
+ implemented directly, in the shared bridge under `pan-wizard-core/mcp/`, rather than via an
77
+ SDK; `pan-zcode/` holds no protocol code of its own, so a dependency added here would not
78
+ reach the bridge.
@@ -38,7 +38,7 @@ PAN-Z bridges PAN's engine to ZCode over MCP. Finish setup inside ZCode:
38
38
 
39
39
  1. **Register the MCP server.** Add the contents of \`pan-mcp.json\` to ZCode's MCP
40
40
  configuration (Settings → MCP), or point ZCode's MCP config at this file. This
41
- exposes the \`pan_*\` tools (state, plan, verify, report, next-action, merge gate).
41
+ exposes the \`pan_*\` tools (roadmap analysis, phase lookup and previews, model resolution, phase report, next-action, merge gate) and the \`pan://\` resources (state, phases, progress, health, links, cost, findings).
42
42
 
43
43
  2. **Import the subagents.** The \`agents/\` folder holds PAN agents in ZCode subagent
44
44
  form. Prefer ZCode's **Import from Claude Code** / Settings → Subagents to register
@@ -5,7 +5,9 @@
5
5
  *
6
6
  * plugin.json closed-schema manifest ($schema + name + metadata)
7
7
  * skills/pan-<name>/SKILL.md every PAN command as an Agent Skill, from the
8
- * ONE unified-skills compiler (ADR-0028)
8
+ * ONE unified-skills compiler (ADR-0028); a skill
9
+ * over Codex's 8,000-byte plugin cut is a pointer
10
+ * page plus references/instructions.md (S8)
9
11
  * mcp.json the bundled bridge, launched as
10
12
  * `node ${PLUGIN_ROOT}/pan-wizard-core/mcp/server.cjs`
11
13
  * pan-wizard-core/ dispatcher + modules + workflows + templates +
@@ -74,9 +76,14 @@ function assertSafeToReplace(dir) {
74
76
  throw new Error(`build-agent-plugin: refusing to replace ${dir} — it is non-empty and does not look like a previous bundle build (no Agent Plugins plugin.json)`);
75
77
  }
76
78
 
77
- /** commands/pan/**.md → skills/pan-<name>/SKILL.md, mirroring the installer's recursion. */
79
+ /**
80
+ * commands/pan/**.md → skills/pan-<name>/SKILL.md, mirroring the installer's recursion.
81
+ * A skill longer than Codex loads from a plugin (8,000 bytes) is split: a pointer
82
+ * SKILL.md plus references/instructions.md (lib.splitOversizedSkill, market-ideas S8).
83
+ */
78
84
  function emitSkills(srcDir, skillsDir, prefix) {
79
85
  let count = 0;
86
+ let split = 0;
80
87
  (function recurse(currentSrc, currentPrefix) {
81
88
  for (const entry of fs.readdirSync(currentSrc, { withFileTypes: true })) {
82
89
  const srcPath = path.join(currentSrc, entry.name);
@@ -88,11 +95,18 @@ function emitSkills(srcDir, skillsDir, prefix) {
88
95
  let content = fs.readFileSync(srcPath, 'utf8');
89
96
  content = lib.rewriteUnifiedSkillCommandContent(content, REWRITE);
90
97
  content = lib.convertClaudeCommandToUnifiedSkill(content, skillName, { adapterNote: lib.agentPluginSkillAdapterNote() });
91
- fs.writeFileSync(path.join(skillDir, 'SKILL.md'), content);
98
+ const { skill, reference } = lib.splitOversizedSkill(content, skillName);
99
+ fs.writeFileSync(path.join(skillDir, 'SKILL.md'), skill);
100
+ if (reference) {
101
+ const refPath = path.join(skillDir, ...lib.AGENT_PLUGIN_SKILL_REFERENCE.split('/'));
102
+ fs.mkdirSync(path.dirname(refPath), { recursive: true });
103
+ fs.writeFileSync(refPath, reference);
104
+ split++;
105
+ }
92
106
  count++;
93
107
  }
94
108
  })(srcDir, prefix);
95
- return count;
109
+ return { count, split };
96
110
  }
97
111
 
98
112
  /** pan-wizard-core → bundle, markdown rewritten, everything else verbatim. */
@@ -214,7 +228,7 @@ function main() {
214
228
  const copilotAgents = emitCopilotNamespace(path.join(ROOT, 'agents'), path.join(OUT, lib.COPILOT_PLUGIN_NAMESPACE));
215
229
 
216
230
  console.log('PAN Agent Plugins bundle built at', path.relative(ROOT, OUT) || OUT);
217
- console.log(' skills:', skills);
231
+ console.log(' skills:', skills.count, `(${skills.split} as a short SKILL.md + ${lib.AGENT_PLUGIN_SKILL_REFERENCE})`);
218
232
  console.log(' agent reference copies:', agents);
219
233
  console.log(' hook scripts:', hookScripts.length);
220
234
  console.log(` ${lib.COPILOT_PLUGIN_NAMESPACE}/agents:`, copilotAgents);
@@ -77,7 +77,9 @@ function rewriteContent(content) {
77
77
  .replace(/~\/\.claude\/agents\//g, `${CONTENT_PREFIX}agents/`)
78
78
  .replace(/\.\/\.claude\/agents\//g, `${CONTENT_PREFIX}agents/`)
79
79
  .replace(/~\/\.claude\//g, CONTENT_PREFIX)
80
- .replace(/\.\/\.claude\//g, CONTENT_PREFIX);
80
+ .replace(/\.\/\.claude\//g, CONTENT_PREFIX)
81
+ // No `pan-tools` bin is on PATH under a plugin either: invoke it via node.
82
+ .replace(/\bpan-tools\b(?=\s+[a-z])/g, `node ${CONTENT_PREFIX}pan-wizard-core/bin/pan-tools.cjs`);
81
83
  }
82
84
 
83
85
  function copyTree(srcDir, destDir, transformMd) {
@@ -222,6 +222,13 @@ def get_version() -> str:
222
222
  # SKILLS-FULL-TEXT.md generator
223
223
  # ---------------------------------------------------------------------------
224
224
 
225
+ def wrapper_fence(content: str) -> str:
226
+ """A backtick fence longer than any fence inside the content, so the skill's own
227
+ code blocks cannot close the block that wraps it."""
228
+ longest = max((len(m.group(1)) for m in re.finditer(r"^ {0,3}(`{3,})", content, re.M)), default=0)
229
+ return "`" * max(3, longest + 1)
230
+
231
+
225
232
  def generate_full_text(shipped: list[Skill], dev: list[Skill], version: str) -> str:
226
233
  """Generate the complete full-text document."""
227
234
  lines = []
@@ -247,9 +254,10 @@ def generate_full_text(shipped: list[Skill], dev: list[Skill], version: str) ->
247
254
  w("")
248
255
  w(f"### {skill.command} ({skill.line_count} lines)")
249
256
  w("")
250
- w("```markdown")
257
+ fence = wrapper_fence(skill.content)
258
+ w(f"{fence}markdown")
251
259
  w(skill.content.rstrip())
252
- w("```")
260
+ w(fence)
253
261
  w("")
254
262
 
255
263
  w("")
@@ -265,9 +273,10 @@ def generate_full_text(shipped: list[Skill], dev: list[Skill], version: str) ->
265
273
  w("")
266
274
  w(f"### {skill.command} ({skill.line_count} lines)")
267
275
  w("")
268
- w("```markdown")
276
+ fence = wrapper_fence(skill.content)
277
+ w(f"{fence}markdown")
269
278
  w(skill.content.rstrip())
270
- w("```")
279
+ w(fence)
271
280
  w("")
272
281
 
273
282
  return "\n".join(lines)
@@ -69,6 +69,10 @@ const EVENT_HOOKS = Object.freeze({
69
69
  subagentStop: ['pan-cost-logger.js', 'pan-trace-logger.js'],
70
70
  stop: ['pan-stop-guard.js'],
71
71
  compact: ['pan-state-reinject.js'],
72
+ // Gemini and Copilot (market-ideas M33): the marker before a compaction, and the
73
+ // block on the next tool result — the same script in two modes.
74
+ compactMark: ['pan-state-reinject.js'],
75
+ compactInject: ['pan-state-reinject.js'],
72
76
  });
73
77
 
74
78
  // ─── Parsers (pure) ─────────────────────────────────────────────────────────