pan-wizard 3.31.0 → 3.33.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 (87) hide show
  1. package/README.md +28 -24
  2. package/agents/pan-conductor.md +2 -2
  3. package/agents/pan-design-checker.md +18 -0
  4. package/agents/pan-document_code.md +2 -2
  5. package/agents/pan-executor.md +3 -3
  6. package/agents/pan-experiment-runner.md +7 -10
  7. package/agents/pan-hardener.md +15 -15
  8. package/agents/pan-knowledge.md +1 -1
  9. package/agents/pan-meta-reviewer.md +2 -2
  10. package/agents/pan-optimizer.md +7 -3
  11. package/agents/pan-phase-researcher.md +2 -2
  12. package/agents/pan-plan-checker.md +29 -2
  13. package/agents/pan-planner.md +23 -10
  14. package/agents/pan-project-researcher.md +10 -67
  15. package/agents/pan-reviewer.md +19 -0
  16. package/agents/pan-roadmapper.md +5 -48
  17. package/agents/pan-verifier.md +49 -11
  18. package/bin/install-lib.cjs +170 -15
  19. package/bin/install.js +39 -14
  20. package/commands/pan/army.md +2 -2
  21. package/commands/pan/design-phase.md +8 -0
  22. package/commands/pan/exec-phase.md +1 -1
  23. package/commands/pan/experiment.md +2 -2
  24. package/commands/pan/focus-auto.md +12 -8
  25. package/commands/pan/focus-design.md +2 -0
  26. package/commands/pan/focus-exec.md +1 -1
  27. package/commands/pan/focus-scan.md +2 -7
  28. package/commands/pan/git.md +2 -2
  29. package/commands/pan/learn.md +2 -0
  30. package/commands/pan/map-codebase.md +4 -4
  31. package/commands/pan/mcp-bridge.md +1 -1
  32. package/commands/pan/milestone-done.md +1 -2
  33. package/commands/pan/optimize.md +14 -2
  34. package/commands/pan/phase-tests.md +2 -2
  35. package/commands/pan/profile.md +2 -2
  36. package/commands/pan/research-phase.md +2 -4
  37. package/commands/pan/review-deep.md +8 -8
  38. package/commands/pan/todo-add.md +2 -2
  39. package/commands/pan/todo-check.md +2 -2
  40. package/hooks/dist/pan-context-monitor.js +1 -1
  41. package/hooks/dist/pan-cost-logger.js +63 -11
  42. package/hooks/dist/pan-state-reinject.js +142 -17
  43. package/hooks/dist/pan-stop-guard.js +2 -2
  44. package/hooks/dist/pan-trace-logger.js +283 -18
  45. package/package.json +1 -1
  46. package/pan-wizard-core/bin/lib/agents-md.cjs +4 -1
  47. package/pan-wizard-core/bin/lib/commands.cjs +95 -2
  48. package/pan-wizard-core/bin/lib/config.cjs +110 -0
  49. package/pan-wizard-core/bin/lib/constants.cjs +39 -9
  50. package/pan-wizard-core/bin/lib/core.cjs +27 -7
  51. package/pan-wizard-core/bin/lib/cost.cjs +16 -6
  52. package/pan-wizard-core/bin/lib/findings.cjs +385 -0
  53. package/pan-wizard-core/bin/lib/focus.cjs +72 -19
  54. package/pan-wizard-core/bin/lib/foreign-planning.cjs +24 -6
  55. package/pan-wizard-core/bin/lib/hygiene.cjs +12 -2
  56. package/pan-wizard-core/bin/lib/init.cjs +9 -2
  57. package/pan-wizard-core/bin/lib/optimize.cjs +349 -21
  58. package/pan-wizard-core/bin/lib/phase.cjs +52 -2
  59. package/pan-wizard-core/bin/lib/review-deep.cjs +38 -2
  60. package/pan-wizard-core/bin/lib/state.cjs +10 -4
  61. package/pan-wizard-core/bin/lib/verdict.cjs +481 -0
  62. package/pan-wizard-core/bin/lib/verify-drift.cjs +14 -5
  63. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -2
  64. package/pan-wizard-core/bin/lib/verify-scope.cjs +223 -0
  65. package/pan-wizard-core/bin/lib/verify.cjs +111 -8
  66. package/pan-wizard-core/bin/pan-tools.cjs +68 -6
  67. package/pan-wizard-core/learnings/README.md +10 -7
  68. package/pan-wizard-core/mcp/server.cjs +18 -9
  69. package/pan-wizard-core/mcp/tool-registry.cjs +2 -0
  70. package/pan-wizard-core/references/checkpoints.md +4 -2
  71. package/pan-wizard-core/references/verdict-contract.md +102 -0
  72. package/pan-wizard-core/templates/discovery.md +1 -1
  73. package/pan-wizard-core/templates/phase-prompt.md +2 -1
  74. package/pan-wizard-core/templates/verification-report.md +21 -0
  75. package/pan-wizard-core/workflows/exec-phase.md +73 -50
  76. package/pan-wizard-core/workflows/health.md +3 -0
  77. package/pan-wizard-core/workflows/learn.md +4 -2
  78. package/pan-wizard-core/workflows/milestone-audit.md +15 -3
  79. package/pan-wizard-core/workflows/new-project.md +1 -1
  80. package/pan-wizard-core/workflows/optimize.md +14 -1
  81. package/pan-wizard-core/workflows/plan-phase.md +20 -15
  82. package/pan-wizard-core/workflows/quick.md +6 -6
  83. package/pan-wizard-core/workflows/verify-phase.md +10 -15
  84. package/pan-zcode/README.md +3 -3
  85. package/scripts/build-agent-plugin.js +19 -5
  86. package/scripts/git-hooks/pre-commit +2 -1
  87. package/scripts/test-surface.cjs +4 -0
@@ -222,7 +222,7 @@ In that case, log a `decision` trace event (`type: "decision", category: "skip-r
222
222
 
223
223
  This is a workflow-level optimization — the planner still produces a plan, just without per-phase research.md. Phase 2+ phases with substantive build work still go through full research.
224
224
 
225
- **P-1602 phase_record_compact (v3.7.5+):** When `workflow.phase_record_compact: true` AND the lightweight-phase bypass above triggers, also skip per-phase context.md creation (step 4) and emit a single combined `${PHASE_NUM}-record.md` after planning containing: goal, locked decisions (from project-level context), plan summary, must_haves. Reduces 4-file phase output (context, research, plan, summary) to a 2-file output (record, plan) for trivial phases. Off by default — opt-in via `pan-tools config-set workflow.phase_record_compact true`. Substantive phases (>1 plan or non-trivial change_class) still produce full per-phase artifacts regardless of this flag.
225
+ **P-1602 phase_record_compact (v3.7.5+):** When `workflow.phase_record_compact: true` AND the lightweight-phase bypass above triggers, also skip per-phase context.md creation (step 4) and emit a single combined `${PHASE_NUM}-record.md` after planning containing: goal, locked decisions (from project-level context), plan summary, must_haves. Reduces the planning output (context, research, plan) to a record and a plan for trivial phases; execution still writes the plan's summary. Off by default — opt-in via `pan-tools config-set workflow.phase_record_compact true`. Substantive phases (>1 plan or non-trivial change_class) still produce full per-phase artifacts regardless of this flag.
226
226
 
227
227
  **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
228
228
 
@@ -448,20 +448,20 @@ Task(
448
448
 
449
449
  ## 11. Handle Checker Return
450
450
 
451
- - **`## VERIFICATION PASSED`:** Display confirmation, proceed to step 13.
452
- ```bash
453
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
454
- --type decision --category plan_verified \
455
- --description "Plan-checker passed for phase ${PHASE_NUMBER}" \
456
- --agent pan-plan-checker --impact trivial 2>/dev/null || true
457
- ```
458
- - **`## ISSUES FOUND`:** Display issues, check iteration count, proceed to step 12.
459
- ```bash
460
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
461
- --type error --category plan_checker_issues \
462
- --description "Plan-checker found issues in phase ${PHASE_NUMBER} plans" \
463
- --agent pan-plan-checker --impact minor 2>/dev/null || true
464
- ```
451
+ Save the checker's returned text, verbatim and in full (including its closing `pan-verdict` block), to `{phase_dir}/{padded_phase}-plan-check.md` with the Write tool. Then record it, and branch on the record. The record also adds the issues to the findings ledger and logs the check to the trace; there is no separate trace call:
452
+
453
+ ```bash
454
+ CHECK_FILE="{phase_dir}/{padded_phase}-plan-check.md"
455
+ CHECK_VERDICT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings record --phase "${PHASE_NUMBER}" --agent pan-plan-checker --file "$CHECK_FILE" --raw 2>/dev/null) \
456
+ || CHECK_VERDICT=$(grep -q '^## VERIFICATION PASSED' "$CHECK_FILE" && echo passed || echo issues_found)
457
+ ```
458
+
459
+ The fallback reads the heading when the report carries no valid `pan-verdict` block.
460
+
461
+ - **`passed`:** Display confirmation, proceed to step 13.
462
+ - **`issues_found`:** Display issues, check iteration count, proceed to step 12.
463
+
464
+ Each re-check in the revision loop overwrites the same file and is recorded again as the next attempt. The issues a revision resolved are closed by that record.
465
465
 
466
466
  ## 12. Revision Loop (Max 3 Iterations)
467
467
 
@@ -510,6 +510,11 @@ Display: `Max iterations reached. {N} issues remain:` + issue list
510
510
 
511
511
  Offer: 1) Force proceed, 2) Provide guidance and retry, 3) Abandon
512
512
 
513
+ **On "Force proceed":** record that planning continues past the remaining issues. Execution and the milestone audit will see them as deferred, with this reason:
514
+ ```bash
515
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings dispose --phase "${PHASE_NUMBER}" --agent pan-plan-checker --open --as deferred --reason "force proceed after 3 plan revision iterations"
516
+ ```
517
+
513
518
  ## 13. Present Final Status
514
519
 
515
520
  **Sync state.md first** — without this, state.md says "Ready to plan" until the
@@ -46,7 +46,7 @@ If `$FULL_MODE`:
46
46
  INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs init quick "$DESCRIPTION")
47
47
  ```
48
48
 
49
- Parse JSON for: `planner_model`, `executor_model`, `checker_model`, `verifier_model`, `commit_docs`, `next_num`, `slug`, `date`, `timestamp`, `quick_dir`, `task_dir`, `roadmap_exists`, `planning_exists`.
49
+ Parse JSON for: `planner_model`, `executor_model`, `checker_model`, `verifier_model`, `commit_docs`, `next_num`, `slug`, `description_cell`, `date`, `timestamp`, `quick_dir`, `task_dir`, `roadmap_exists`, `planning_exists`.
50
50
 
51
51
  **If `roadmap_exists` is false:** Error — Quick mode requires an active project with roadmap.md. Run `/pan:new-project` first.
52
52
 
@@ -365,23 +365,23 @@ Insert after `### Blockers/Concerns` section:
365
365
 
366
366
  **7c. Append new row to table:**
367
367
 
368
- Use `date` from init:
368
+ Use `date` and `description_cell` from init. Write `description_cell` exactly as init returned it, never `$DESCRIPTION`: init escapes `|` and folds line breaks, and a raw `|` in a description would split the row into an extra column and break the table for every later read.
369
369
 
370
370
  **If `$FULL_MODE` (or table has Status column):**
371
371
  ```markdown
372
- | ${next_num} | ${DESCRIPTION} | ${date} | ${commit_hash} | ${VERIFICATION_STATUS} | [${next_num}-${slug}](./quick/${next_num}-${slug}/) |
372
+ | ${next_num} | ${description_cell} | ${date} | ${commit_hash} | ${VERIFICATION_STATUS} | [${next_num}-${slug}](./quick/${next_num}-${slug}/) |
373
373
  ```
374
374
 
375
375
  **If NOT `$FULL_MODE` (and table has no Status column):**
376
376
  ```markdown
377
- | ${next_num} | ${DESCRIPTION} | ${date} | ${commit_hash} | [${next_num}-${slug}](./quick/${next_num}-${slug}/) |
377
+ | ${next_num} | ${description_cell} | ${date} | ${commit_hash} | [${next_num}-${slug}](./quick/${next_num}-${slug}/) |
378
378
  ```
379
379
 
380
380
  **7d. Update "Last activity" line:**
381
381
 
382
- Use `date` from init:
382
+ Use `date` and `description_cell` from init (one line, whatever the description held):
383
383
  ```
384
- Last activity: ${date} - Completed quick task ${next_num}: ${DESCRIPTION}
384
+ Last activity: ${date} - Completed quick task ${next_num}: ${description_cell}
385
385
  ```
386
386
 
387
387
  Use Edit tool to make these changes atomically
@@ -136,6 +136,10 @@ TEST_TOTAL: ${TEST_COUNT}
136
136
  TEST_PASSED: ${TEST_PASS}
137
137
  TEST_FAILED: ${TEST_FAIL}
138
138
  ```
139
+ Write `test_gate: ${TEST_GATE_STATUS}` into the verification.md frontmatter. When it is
140
+ `skipped`, also add a `not_checked` entry (`check: "tests"`, `reason: "no test script in
141
+ package.json"`). The recorder reads both: a pass whose tests never ran is recorded as a
142
+ pass with tests not checked, never as a plain pass.
139
143
 
140
144
  **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
145
  </step>
@@ -284,7 +288,7 @@ Format each as: Test Name → What to do → Expected result → Why can't verif
284
288
  </step>
285
289
 
286
290
  <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.
291
+ **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
292
 
289
293
  **gaps_found:** Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, blocker found, OR test gate FAILED (test regressions detected).
290
294
 
@@ -306,9 +310,10 @@ If gaps_found:
306
310
  <step name="create_report">
307
311
  ```bash
308
312
  REPORT_PATH="$PHASE_DIR/${PHASE_NUM}-verification.md"
313
+ VERIFIED_COMMIT=$(git rev-parse HEAD 2>/dev/null)
309
314
  ```
310
315
 
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.
316
+ 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
317
 
313
318
  See ~/.claude/pan-wizard-core/templates/verification-report.md for complete template.
314
319
  </step>
@@ -321,21 +326,11 @@ If human_needed: list items requiring human testing.
321
326
 
322
327
  Orchestrator routes: `passed` → update_roadmap | `gaps_found` → create/execute fixes, re-verify | `human_needed` → present to user.
323
328
 
324
- **Circular optimization — log verification outcome:**
329
+ **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
330
  ```bash
326
- # Map status to impact and event type
327
- if [ "${STATUS}" = "passed" ]; then
328
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
329
- --type decision --category verification_passed \
330
- --description "Phase ${PHASE_NUMBER} verification passed (score: ${SCORE})" \
331
- --agent pan-verifier --impact minor 2>/dev/null || true
332
- elif [ "${STATUS}" = "gaps_found" ]; then
333
- node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
334
- --type error --category verification_gaps \
335
- --description "Phase ${PHASE_NUMBER} verification found gaps (score: ${SCORE})" \
336
- --agent pan-verifier --impact major 2>/dev/null || true
337
- fi
331
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs findings record --phase "${PHASE_NUMBER}" --file "$REPORT_PATH" 2>/dev/null || true
338
332
  ```
333
+ Recording the same report twice is a no-op, so exec-phase recording it again after this workflow returns is safe.
339
334
  </step>
340
335
 
341
336
  </process>
@@ -50,7 +50,7 @@ before ADR-0028.
50
50
  preserves the body; plus a command → skill wrapper.
51
51
  - **M4 — bundle + install.** `bin/install-zcode.js` — assembles `agents/` + `pan-mcp.json` +
52
52
  manifest + `INSTALL-ZCODE.md` into a `--target` dir; refuses to write inside the source repo;
53
- drives ZCode's own Import to finish.
53
+ leaves the finish to the human in ZCode's own Settings and Import, following `INSTALL-ZCODE.md`.
54
54
  - **M5 — hardening + docs.** Full test matrix + [`KNOWN-BETA-RISKS.md`](KNOWN-BETA-RISKS.md)
55
55
  (the beta-churn ledger + the M0 go/no-go questions).
56
56
 
@@ -59,11 +59,11 @@ Tests: `tests/pan-zcode-mcp.test.cjs`, `tests/pan-zcode-orchestration.test.cjs`,
59
59
 
60
60
  ## Still pending — M0 (needs a real ZCode install)
61
61
 
62
- Two go/no-go facts can only be settled empirically: **can a subagent call MCP tools?** and **are
62
+ Among the go/no-go facts only a real install can settle (the M0 table in `KNOWN-BETA-RISKS.md`) are **can a subagent call MCP tools?** and **are
63
63
  local stdio MCP calls metered?** Both have folded-in fallbacks (see `KNOWN-BETA-RISKS.md`), so the
64
64
  design holds either way — but confirm them before relying on the richer paths.
65
65
 
66
- A third M0 checkpoint (added 2026-08): **which protocol era does the real ZCode client speak?**
66
+ Another M0 checkpoint (added 2026-08, not yet in `KNOWN-BETA-RISKS.md`): **which protocol era does the real ZCode client speak?**
67
67
  The bridge is now dual-era (ADR-0041), so it answers both a legacy `initialize` handshake and a
68
68
  modern `server/discover` probe. Confirm on a real install which path ZCode takes and that the
69
69
  version it declares is in our supported list; if ZCode ever declares a revision newer than
@@ -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);
@@ -10,7 +10,8 @@
10
10
  # Or with a symlink (Unix / Git Bash):
11
11
  # ln -sf ../../scripts/git-hooks/pre-commit .git/hooks/pre-commit
12
12
  #
13
- # Bypass for an emergency (creates a paper trail in the commit log):
13
+ # Bypass for an emergency (the hook only prints that the scan was skipped;
14
+ # nothing is recorded in the commit):
14
15
  # SKIP_GITLEAKS=1 git commit -m "..."
15
16
  #
16
17
  # Exit codes:
@@ -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) ─────────────────────────────────────────────────────────