pan-wizard 3.5.2 → 3.8.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 (98) hide show
  1. package/README.md +28 -9
  2. package/agents/pan-executor.md +18 -0
  3. package/agents/pan-experiment-runner.md +126 -0
  4. package/agents/pan-phase-researcher.md +16 -0
  5. package/agents/pan-plan-checker.md +80 -0
  6. package/agents/pan-planner.md +19 -0
  7. package/agents/pan-reviewer.md +2 -0
  8. package/agents/pan-verifier.md +41 -0
  9. package/bin/install-lib.cjs +55 -0
  10. package/bin/install.js +71 -22
  11. package/commands/pan/debug.md +1 -1
  12. package/commands/pan/experiment.md +219 -0
  13. package/commands/pan/health.md +1 -1
  14. package/commands/pan/learn.md +15 -1
  15. package/commands/pan/links.md +102 -0
  16. package/commands/pan/optimize.md +13 -0
  17. package/commands/pan/patches.md +10 -1
  18. package/commands/pan/phase-tests.md +1 -4
  19. package/commands/pan/todo-add.md +1 -1
  20. package/commands/pan/todo-check.md +1 -1
  21. package/hooks/dist/pan-cost-logger.js +54 -4
  22. package/hooks/dist/pan-trace-logger.js +72 -3
  23. package/package.json +67 -66
  24. package/pan-wizard-core/bin/lib/codebase.cjs +2 -0
  25. package/pan-wizard-core/bin/lib/commands.cjs +8 -0
  26. package/pan-wizard-core/bin/lib/config.cjs +13 -2
  27. package/pan-wizard-core/bin/lib/context-budget.cjs +73 -0
  28. package/pan-wizard-core/bin/lib/core.cjs +13 -0
  29. package/pan-wizard-core/bin/lib/doc-lint/frontmatter.js +270 -0
  30. package/pan-wizard-core/bin/lib/doc-lint/reporter.js +45 -0
  31. package/pan-wizard-core/bin/lib/doc-lint/schema.js +202 -0
  32. package/pan-wizard-core/bin/lib/doc-lint/validate.js +190 -0
  33. package/pan-wizard-core/bin/lib/doc-lint/walk.js +135 -0
  34. package/pan-wizard-core/bin/lib/doc-lint.cjs +287 -0
  35. package/pan-wizard-core/bin/lib/experiment.cjs +502 -0
  36. package/pan-wizard-core/bin/lib/learn-index.cjs +235 -0
  37. package/pan-wizard-core/bin/lib/learn-lint.cjs +292 -0
  38. package/pan-wizard-core/bin/lib/links.cjs +549 -0
  39. package/pan-wizard-core/bin/lib/optimize.cjs +474 -1
  40. package/pan-wizard-core/bin/lib/runner.cjs +473 -0
  41. package/pan-wizard-core/bin/lib/verify.cjs +23 -0
  42. package/pan-wizard-core/bin/pan-tools.cjs +247 -3
  43. package/pan-wizard-core/learnings/README.md +70 -0
  44. package/pan-wizard-core/learnings/index.json +540 -0
  45. package/pan-wizard-core/learnings/internal/.gitkeep +2 -0
  46. package/pan-wizard-core/learnings/internal/experiment-runner.md +81 -0
  47. package/pan-wizard-core/learnings/internal/external-research.md +93 -0
  48. package/pan-wizard-core/learnings/internal/loop-design.md +33 -0
  49. package/pan-wizard-core/learnings/internal/pan-dev-bugs.md +181 -0
  50. package/pan-wizard-core/learnings/universal/.gitkeep +2 -0
  51. package/pan-wizard-core/learnings/universal/atomic-state.md +21 -0
  52. package/pan-wizard-core/learnings/universal/binary-io.md +21 -0
  53. package/pan-wizard-core/learnings/universal/comment-syntax.md +21 -0
  54. package/pan-wizard-core/learnings/universal/composition.md +33 -0
  55. package/pan-wizard-core/learnings/universal/concurrency.md +33 -0
  56. package/pan-wizard-core/learnings/universal/dag-scheduler.md +33 -0
  57. package/pan-wizard-core/learnings/universal/data-driven-design.md +21 -0
  58. package/pan-wizard-core/learnings/universal/design-process.md +21 -0
  59. package/pan-wizard-core/learnings/universal/empirical-spike.md +21 -0
  60. package/pan-wizard-core/learnings/universal/error-handling.md +23 -0
  61. package/pan-wizard-core/learnings/universal/error-paths.md +21 -0
  62. package/pan-wizard-core/learnings/universal/glob-semantics.md +21 -0
  63. package/pan-wizard-core/learnings/universal/idempotency.md +21 -0
  64. package/pan-wizard-core/learnings/universal/invariants.md +21 -0
  65. package/pan-wizard-core/learnings/universal/io-patterns.md +21 -0
  66. package/pan-wizard-core/learnings/universal/numeric-edge-cases.md +21 -0
  67. package/pan-wizard-core/learnings/universal/output-conventions.md +21 -0
  68. package/pan-wizard-core/learnings/universal/parser-design.md +21 -0
  69. package/pan-wizard-core/learnings/universal/phase-locking.md +21 -0
  70. package/pan-wizard-core/learnings/universal/pipe-friendly-cli.md +21 -0
  71. package/pan-wizard-core/learnings/universal/schema-design.md +21 -0
  72. package/pan-wizard-core/learnings/universal/secret-handling.md +21 -0
  73. package/pan-wizard-core/learnings/universal/streaming-io.md +21 -0
  74. package/pan-wizard-core/learnings/universal/test-patterns.md +57 -0
  75. package/pan-wizard-core/learnings/universal/test-strategy.md +33 -0
  76. package/pan-wizard-core/learnings/universal/unicode.md +21 -0
  77. package/pan-wizard-core/learnings/universal/vendor-pattern.md +21 -0
  78. package/pan-wizard-core/references/guardrails.md +58 -0
  79. package/pan-wizard-core/references/handoff-decisions.md +156 -0
  80. package/pan-wizard-core/references/schemas/pan-command.schema.yml +39 -0
  81. package/pan-wizard-core/references/verification-patterns.md +31 -0
  82. package/pan-wizard-core/templates/config.json +2 -1
  83. package/pan-wizard-core/templates/idea.md +52 -0
  84. package/pan-wizard-core/templates/summary-complex.md +14 -5
  85. package/pan-wizard-core/templates/summary-minimal.md +6 -0
  86. package/pan-wizard-core/templates/summary-standard.md +14 -3
  87. package/pan-wizard-core/workflows/discuss-phase.md +108 -1
  88. package/pan-wizard-core/workflows/exec-phase.md +37 -1
  89. package/pan-wizard-core/workflows/execute-plan.md +14 -0
  90. package/pan-wizard-core/workflows/health.md +23 -0
  91. package/pan-wizard-core/workflows/new-project.md +65 -81
  92. package/pan-wizard-core/workflows/plan-phase.md +58 -0
  93. package/pan-wizard-core/workflows/transition.md +102 -7
  94. package/pan-wizard-core/workflows/verify-phase.md +14 -0
  95. package/scripts/build-hooks.js +7 -1
  96. package/scripts/generate-skills-docs.py +10 -8
  97. package/scripts/git-hooks/pre-commit +40 -0
  98. package/scripts/release-check.js +184 -0
@@ -0,0 +1,39 @@
1
+ # Schema describing PAN's commands/pan/*.md frontmatter shape.
2
+ # Used by the dogfood gate (REQ-06) and shipped to PAN as the canonical
3
+ # command-frontmatter schema (consumed by `pan-tools doc-lint`).
4
+ #
5
+ # Schema evolved across two dogfood passes:
6
+ # - Pass 1: pattern accommodates "pan:" prefix; argument-hint added
7
+ # - Pass 2 (v3.7.1): added agent, type, argument-instructions per real usage
8
+ #
9
+ # Per P-202 (universal): schemas should be inferred from real files, not authored
10
+ # from imagination. Every field below was added because a real PAN command file
11
+ # uses it.
12
+
13
+ fields:
14
+ name:
15
+ required: true
16
+ type: string
17
+ pattern: ^(pan:)?[a-z][a-z0-9-]*$
18
+ group:
19
+ required: false
20
+ type: string
21
+ description:
22
+ required: false
23
+ type: string
24
+ allowed-tools:
25
+ required: false
26
+ type: array
27
+ items: string
28
+ argument-hint:
29
+ required: false
30
+ type: string
31
+ argument-instructions:
32
+ required: false
33
+ type: string
34
+ agent:
35
+ required: false
36
+ type: string
37
+ type:
38
+ required: false
39
+ type: string
@@ -558,6 +558,37 @@ Run these checks against each must-have artifact. Aggregate results into VERIFIC
558
558
 
559
559
  <human_verification_triggers>
560
560
 
561
+ ## Verifiable Signals Beat Prose Judgment (P-RES-006)
562
+
563
+ **Principle:** When evaluating a plan, a phase, or a code change, prefer signals you can MECHANICALLY check over signals that require LLM-as-judge prose review. Naive self-critique without grounded rewards is largely ineffective and can hurt via overthinking (S2R, ACL 2025; broader RLVR thread). The structural value of PAN's verification roles is in the **fresh-context restart** and **file-mediated re-reading**, not in the prose verdict itself.
564
+
565
+ **For every verification dimension, ask first: is there a verifiable check that produces this signal mechanically?**
566
+
567
+ | Verification need | Prose-judge approach (weak) | Verifiable approach (strong) |
568
+ |---|---|---|
569
+ | "Does the code work?" | Read the code, decide | `npm test` exit 0; `npm run build` exit 0 |
570
+ | "Does it follow conventions?" | Read it, judge style | `npm run lint`; `prettier --check`; AST scan against codebase/CONVENTIONS.md |
571
+ | "Are there security issues?" | Read for OWASP patterns | `npm audit`; `semgrep`; regex anti-pattern scan; explicit threat-model checklist with bool answers |
572
+ | "Are types coherent?" | Read for likely mismatches | `tsc --noEmit`; type-graph verify |
573
+ | "Does the plan cover the goal?" | Judge whether the plan is "good" | Mechanical check: every must_have appears as a `<task>` `<verify>`; every requirement ID appears in `requirements:` frontmatter (this is what Dimensions 1, 6 already do) |
574
+ | "Did the executor diverge?" | Re-read the code, decide | `git diff` against the plan's `<files>` list; flag files touched outside the plan; flag missing files from the plan |
575
+
576
+ **When prose review IS the right tool:**
577
+ - The signal is genuinely subjective (UX feel, error-message helpfulness)
578
+ - The check would require so much custom code that the cost dwarfs an agent invocation
579
+ - The output is for a human reader, not a downstream agent
580
+
581
+ **When prose review is theatre and should be cut:**
582
+ - A verifiable check exists but wasn't wired in (cheap to fix)
583
+ - The reviewer is judging another reviewer's prose (meta-judgment compounds noise)
584
+ - The verdict is a binary that boils down to "does X exist in Y" (a grep, not a chat)
585
+
586
+ **Implication for the agents:** `pan-plan-checker`, `pan-verifier`, `pan-reviewer`, `pan-meta-reviewer`, `pan-hardener` should each periodically audit their own prose-vs-mechanical check ratio. If a dimension is 100% prose, ask whether the role earns its compute or whether the structural reset (fresh context, forced re-reading of plan/code) is doing the real work.
587
+
588
+ **Source:** `pan-wizard-core/learnings/internal/external-research.md` P-RES-006 (S2R / RLVR, ACL 2025).
589
+
590
+ ---
591
+
561
592
  ## When to Require Human Verification
562
593
 
563
594
  Some things can't be verified programmatically. Flag these for human testing:
@@ -6,7 +6,8 @@
6
6
  "plan_check": true,
7
7
  "verifier": true,
8
8
  "auto_advance": false,
9
- "nyquist_validation": false
9
+ "nyquist_validation": false,
10
+ "phase_record_compact": false
10
11
  },
11
12
  "planning": {
12
13
  "commit_docs": true,
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: "<one-line idea title>"
3
+ created: "<ISO-8601>"
4
+ created_by: "<user>"
5
+ runtime_preference: claude
6
+ budget: 80
7
+ priority: medium
8
+ ---
9
+
10
+ # Idea: <title>
11
+
12
+ ## Problem
13
+
14
+ What user pain does this address? Be concrete — what's broken, slow, or missing today?
15
+
16
+ ## Success Criteria
17
+
18
+ What does "this works" look like? List 3-5 measurable outcomes:
19
+
20
+ - SC-1: [observable, testable]
21
+ - SC-2: ...
22
+ - SC-3: ...
23
+
24
+ ## Scope
25
+
26
+ | In Scope | Out of Scope |
27
+ |----------|--------------|
28
+ | ... | ... |
29
+
30
+ ## Constraints
31
+
32
+ - **Tech stack:** <language, framework>
33
+ - **Dependencies:** <required libs, services>
34
+ - **Deadlines:** <if any>
35
+ - **Runtime support:** <which AI coding tools must work>
36
+ - **Performance:** <if any non-functional requirements>
37
+
38
+ ## Reference Material (optional)
39
+
40
+ - @path/to/related-doc.md
41
+ - https://link/to/inspiration
42
+
43
+ ## Notes (optional)
44
+
45
+ Free-form context the external agent should know — design preferences, prior
46
+ art to mimic, things explicitly to avoid.
47
+
48
+ ---
49
+
50
+ > **How this is consumed:** This file is read by `/pan:experiment new <slug>`
51
+ > and copied to `<experiment-folder>/.planning/idea.md`. The experiment's
52
+ > external AI session reads it as the Phase 0 answer when scaffolding.
@@ -45,14 +45,23 @@ completed: YYYY-MM-DD
45
45
  - `path/to/file.ts` - What it does
46
46
  - `path/to/another.ts` - What it does
47
47
 
48
- ## Decisions Made
49
- [Key decisions with brief rationale]
48
+ ## Implementation Decisions
49
+ <!-- Schema: @~/.claude/pan-wizard-core/references/handoff-decisions.md -->
50
50
 
51
- ## Deviations from Plan (Auto-fixed)
52
- [Detailed auto-fix records per PAN deviation rules]
51
+ ### Taken (within plan's discretion)
52
+ - DT-1: Chose [option] for O-N. Reason: [rationale].
53
+
54
+ ### Deviations (from plan; must explain)
55
+ - DV-1: Plan said [X]; I did [Y]. Reason: [rationale]. Verification: [how I confirmed Y is acceptable].
56
+
57
+ ### Open questions for verifier
58
+ - Q-1: [question]. Why it matters: [stake].
59
+
60
+ <!-- If none: "No deviations or open questions — implementation followed plan exactly." -->
53
61
 
54
62
  ## Issues Encountered
55
- [Problems during planned work and resolutions]
63
+ [Problems during planned work and resolutions — distinct from Deviations above:
64
+ Issues = bugs/blockers fixed; Deviations = intentional departures from plan]
56
65
 
57
66
  ## Next Phase Readiness
58
67
  [What's ready for next phase]
@@ -37,5 +37,11 @@ completed: YYYY-MM-DD
37
37
  ## Files Created/Modified
38
38
  - `path/to/file.ts` - What it does
39
39
 
40
+ ## Implementation Decisions
41
+ <!-- Compact form for minimal summaries. Schema: @~/.claude/pan-wizard-core/references/handoff-decisions.md -->
42
+
43
+ [One line each, or this single line if none:
44
+ "No deviations or open questions — implementation followed plan exactly."]
45
+
40
46
  ## Next Phase Readiness
41
47
  [Ready for next phase]
@@ -41,9 +41,20 @@ completed: YYYY-MM-DD
41
41
  - `path/to/file.ts` - What it does
42
42
  - `path/to/another.ts` - What it does
43
43
 
44
- ## Decisions & Deviations
45
- [Key decisions or "None - followed plan as specified"]
46
- [Minor deviations if any, or "None"]
44
+ ## Implementation Decisions
45
+ <!-- Schema: @~/.claude/pan-wizard-core/references/handoff-decisions.md -->
46
+
47
+ ### Taken (within plan's discretion)
48
+ - DT-1: Chose [option] for O-N. Reason: [rationale].
49
+
50
+ ### Deviations (from plan; must explain)
51
+ - DV-1: Plan said [X]; I did [Y]. Reason: [rationale]. Verification: [how I confirmed Y is acceptable].
52
+
53
+ ### Open questions for verifier
54
+ - Q-1: [question]. Why it matters: [stake].
55
+
56
+ <!-- If none: replace ALL three buckets with:
57
+ "No deviations or open questions — implementation followed plan exactly." -->
47
58
 
48
59
  ## Next Phase Readiness
49
60
  [What's ready for next phase]
@@ -126,7 +126,114 @@ Use /pan:progress to see available phases.
126
126
  ```
127
127
  Exit workflow.
128
128
 
129
- **If `phase_found` is true:** Continue to check_existing.
129
+ **If `phase_found` is true:** Continue to auto_mode_bypass.
130
+ </step>
131
+
132
+ <step name="auto_mode_bypass">
133
+ **P-1803 fix (v3.7.8):** When `--auto` is set or `workflow.auto_advance: true`, **skip the entire question-driven discussion** and synthesize a minimal `context.md` directly from upstream artifacts. The 6 unguarded `AskUserQuestion` calls in this workflow (lines ~140, 156, 208, 261, 264, 278) all stall headless `claude -p` sessions immediately. Surfaced by the wookie autonomous build (v3.7.7): retry attempts via `/pan:discuss-phase 3 --auto` exited in 75s with $0.42 cost and zero commits before plan-phase auto-mode was patched to bypass discuss-phase entirely. This step makes discuss-phase itself auto-mode-safe, so it can be re-introduced into the auto pipeline cleanly.
134
+
135
+ Detect auto mode:
136
+
137
+ ```bash
138
+ HAS_AUTO_FLAG=$(echo "$ARGUMENTS" | grep -c -- '--auto' || true)
139
+ AUTO_CFG=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs config-get workflow.auto_advance 2>/dev/null || echo "false")
140
+ ```
141
+
142
+ **If `HAS_AUTO_FLAG` > 0 OR `AUTO_CFG` is `true`:**
143
+
144
+ Skip the interactive flow. Generate `context.md` from the roadmap goal + idea.md (if present) + project.md + requirements.md, then jump to `write_context` with the synthesized content. Specifically:
145
+
146
+ 1. Display banner:
147
+ ```
148
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
149
+ PAN ► AUTO-MODE: synthesizing context from upstream artifacts
150
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
151
+ ```
152
+
153
+ 2. Read inputs:
154
+ ```bash
155
+ ROADMAP_GOAL=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${PHASE}" --raw | sed -n '/^Goal:/,/^$/p')
156
+ IDEA_PATH=".planning/idea.md"
157
+ PROJECT_PATH=".planning/project.md"
158
+ REQ_PATH=".planning/requirements.md"
159
+ ```
160
+
161
+ 3. Build a synthesized context.md (skip `analyze_phase`, `present_gray_areas`, `discuss_areas`, `summarize_decisions`, and the Plans-exist branch — go directly to a minimal but valid context.md):
162
+
163
+ ```markdown
164
+ # Phase ${PHASE}: ${PHASE_NAME} - Context
165
+
166
+ **Gathered:** [today]
167
+ **Status:** Ready for planning
168
+ **Source:** Auto-mode synthesis (P-1803, v3.7.8) — derived from idea.md + project.md + requirements.md without user dialogue
169
+
170
+ <domain>
171
+ ## Phase Boundary
172
+
173
+ [Goal extracted verbatim from roadmap.md]
174
+
175
+ </domain>
176
+
177
+ <decisions>
178
+ ## Implementation Decisions
179
+
180
+ ### From idea.md
181
+ [For each item in idea.md "Constraints" / "Scope" / "Notes for the planner" sections that mentions Phase ${PHASE} or its domain keywords (e.g., "image pipeline" for Phase 3) — extract as a locked decision, prefixed with the domain name]
182
+
183
+ ### From requirements.md
184
+ [For each requirement marked Active that maps to Phase ${PHASE} via `requirements.md`'s phase column — list as a locked decision]
185
+
186
+ ### Claude's Discretion
187
+ - Implementation patterns within the constraints above (the planner decides specific libraries / file layouts / function shapes)
188
+ - Test names, fixture data, mock strategy
189
+ - Internal variable / function naming
190
+ - Comment density and inline doc style
191
+
192
+ </decisions>
193
+
194
+ <specifics>
195
+ ## Specific References
196
+
197
+ [Any concrete examples, library names, or file paths mentioned in idea.md "Reference material" or "Notes" sections that apply to this phase]
198
+
199
+ </specifics>
200
+
201
+ <deferred>
202
+ ## Deferred Ideas
203
+
204
+ None — auto-mode synthesis honors the original idea.md scope.
205
+
206
+ </deferred>
207
+
208
+ ---
209
+
210
+ *Phase: ${PADDED_PHASE}-${PHASE_SLUG}*
211
+ *Context auto-synthesized: [today] via discuss-phase P-1803 bypass — no user dialogue*
212
+ ```
213
+
214
+ Write the file:
215
+ ```bash
216
+ mkdir -p "${phase_dir}"
217
+ # Use Write tool (NOT heredoc) to create ${phase_dir}/${PADDED_PHASE}-context.md
218
+ ```
219
+
220
+ 4. Commit if `commit_docs` is true:
221
+ ```bash
222
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs(${PADDED_PHASE}): auto-synthesize phase context (P-1803)" --files "${phase_dir}/${PADDED_PHASE}-context.md"
223
+ ```
224
+
225
+ 5. Log a trace event:
226
+ ```bash
227
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
228
+ --type decision --category context-auto-synthesized \
229
+ --description "Phase ${PHASE} P-1803 bypass: context.md auto-synthesized in auto-mode without user dialogue" \
230
+ --agent orchestrator --impact minor 2>/dev/null || true
231
+ ```
232
+
233
+ 6. **Skip ahead to `auto_advance` step** (existing step that spawns plan-phase via Task). Do NOT pass through `check_existing`, `analyze_phase`, `present_gray_areas`, `discuss_areas`, `summarize_decisions` — those all contain unguarded AskUserQuestion calls.
234
+
235
+ **If neither `HAS_AUTO_FLAG` > 0 nor `AUTO_CFG` is true:** Continue to `check_existing` (interactive flow with full question-driven discussion).
236
+
130
237
  </step>
131
238
 
132
239
  <step name="check_existing">
@@ -8,8 +8,23 @@ Orchestrator coordinates, not executes. Each subagent loads the full execute-pla
8
8
 
9
9
  <required_reading>
10
10
  Read state.md before any operation to load project context.
11
+
12
+ @~/.claude/pan-wizard-core/references/guardrails.md
13
+
14
+ > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --token-budget 5000 --raw` to load only the topics tagged relevant for execution at the configured budget. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts. Files appear here over time as `pan-tools learn promote` adds findings.
11
15
  </required_reading>
12
16
 
17
+ ## Re-Read Checkpoints
18
+
19
+ Context compaction may have dropped earlier sections. Re-read the relevant section *before* you begin each step — not after you hit a problem.
20
+
21
+ | Before this step | Re-read | Why |
22
+ |------------------|---------|-----|
23
+ | Spawning a subagent | This workflow's `<step name="execute">` block | Wave/segment routing is easy to misremember after compaction |
24
+ | Writing code in a plan | `references/tdd.md` + plan file | Conventions and the plan's tasks drift across long sessions |
25
+ | Committing | `references/guardrails.md` | Pre-commit shortcuts (silent model swaps, scope creep) are tempting under pressure |
26
+ | Marking phase complete | `workflows/verify-phase.md` | Completion criteria are easy to misremember |
27
+
13
28
  <process>
14
29
 
15
30
  <step name="initialize" priority="first">
@@ -497,7 +512,28 @@ Create verification.md.",
497
512
 
498
513
  Read status:
499
514
  ```bash
500
- grep "^status:" "$PHASE_DIR"/*-verification.md | cut -d: -f2 | tr -d ' '
515
+ VERIF_STATUS=$(grep "^status:" "$PHASE_DIR"/*-verification.md | cut -d: -f2 | tr -d ' ')
516
+ ```
517
+
518
+ **P-1806 fix (v3.7.8):** the trace event for verify-phase outcome is logged HERE (in exec-phase.md after the verifier returns) rather than only at the end of verify-phase.md. When verification runs inline (orchestrator-as-verifier in auto mode, no separate Task spawn), the trace.log block at the bottom of verify-phase.md never executes — the orchestrator just writes verification.md and continues. By logging here, the event fires regardless of the verification path taken. Surfaced by the wookie autonomous build (v3.7.5–v3.7.7): all 5 phases used inline verification, no `verification_passed` events appeared in the trace despite v3.7.5 adding the trace block to verify-phase.md.
519
+
520
+ ```bash
521
+ if [ "$VERIF_STATUS" = "passed" ]; then
522
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
523
+ --type decision --category verification_passed \
524
+ --description "Phase ${PHASE_NUMBER} verification passed (logged from exec-phase, P-1806)" \
525
+ --agent pan-verifier --impact minor 2>/dev/null || true
526
+ elif [ "$VERIF_STATUS" = "gaps_found" ]; then
527
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
528
+ --type error --category verification_gaps \
529
+ --description "Phase ${PHASE_NUMBER} verification found gaps" \
530
+ --agent pan-verifier --impact major 2>/dev/null || true
531
+ elif [ "$VERIF_STATUS" = "human_needed" ]; then
532
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
533
+ --type decision --category verification_human_needed \
534
+ --description "Phase ${PHASE_NUMBER} verification awaiting human review" \
535
+ --agent pan-verifier --impact minor 2>/dev/null || true
536
+ fi
501
537
  ```
502
538
 
503
539
  | Status | Action |
@@ -7,8 +7,22 @@ Read state.md before any operation to load project context.
7
7
  Read config.json for planning behavior settings.
8
8
 
9
9
  @~/.claude/pan-wizard-core/references/git-integration.md
10
+ @~/.claude/pan-wizard-core/references/guardrails.md
11
+
12
+ > **Also see:** `~/.claude/pan-wizard-core/learnings/universal/` — AI-derived patterns from prior experiments. **Don't skim the whole folder.** Run `pan-tools learn topics-for --agent executor --token-budget 5000 --raw` to load only the topics tagged relevant for execution at the configured budget. Per P-RES-002 (distractor-density research), reading every topic degrades reasoning even at modest token counts.
10
13
  </required_reading>
11
14
 
15
+ ## Re-Read Checkpoints
16
+
17
+ Context compaction may have dropped earlier sections. Re-read the relevant section *before* you begin each step — not after you hit a problem.
18
+
19
+ | Before this step | Re-read | Why |
20
+ |------------------|---------|-----|
21
+ | Each task in the plan | This workflow's `<deviation_rules>` block | Rule 1-4 boundaries are easy to misremember |
22
+ | Hitting an unexpected error | This workflow's `<authentication_gates>` block | Auth errors are not failures — recognize the pattern |
23
+ | Committing | `references/guardrails.md` + `references/git-planning-commit.md` | Commit conventions and Code Preservation apply to every commit |
24
+ | Writing the summary | This workflow's `<deviation_documentation>` block | Summary shape is checked by verify-phase |
25
+
12
26
  <process>
13
27
 
14
28
  <step name="init_context" priority="first">
@@ -37,6 +37,29 @@ Parse JSON output:
37
37
  - `repairs_performed[]`: Actions taken if --repair was used
38
38
  </step>
39
39
 
40
+ <step name="run_doc_lint">
41
+ **Run frontmatter doc-lint (v3.7.1+):**
42
+
43
+ Lints the project's markdown files (commands, agents, workflows) against
44
+ the PAN command schema. Catches frontmatter drift at author time —
45
+ missing `name`, wrong types, malformed YAML — before they cause runtime
46
+ issues during install or dispatch.
47
+
48
+ ```bash
49
+ # Lint commands/pan/ if it exists in the host project (PAN-source dogfood)
50
+ if [ -d commands/pan ]; then
51
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs doc-lint commands/pan --raw 2>&1
52
+ fi
53
+ ```
54
+
55
+ A clean run prints `Linted N file(s): 0 error(s), 0 warning(s)`. Any errors
56
+ get folded into the health report's `warnings[]` section as
57
+ `code: doc-lint-frontmatter` entries — they're non-blocking but actionable.
58
+
59
+ Skip silently if `commands/pan/` doesn't exist (most user projects).
60
+ Pattern source: P-201 + P-202 + P-301 (whooo experiment, ADR-0026).
61
+ </step>
62
+
40
63
  <step name="format_output">
41
64
  **Format and display results:**
42
65
 
@@ -4,8 +4,25 @@ Initialize a new project through unified flow: questioning, research (optional),
4
4
 
5
5
  <required_reading>
6
6
  Read all files referenced by the invoking prompt's execution_context before starting.
7
+
8
+ @~/.claude/pan-wizard-core/references/guardrails.md
7
9
  </required_reading>
8
10
 
11
+ ## Phase 0 — Clarify (MANDATORY, do not skip)
12
+
13
+ Before scaffolding or coding anything, confirm with the user:
14
+
15
+ 1. **What problem will this solve?** — Core purpose, not the implementation
16
+ 2. **What does success look like?** — Concrete, measurable outcomes
17
+ 3. **What's in scope vs out of scope?** — Boundary definition
18
+ 4. **Constraints?** — Tech stack, dependencies, deadlines, runtime support requirements
19
+
20
+ **Do NOT proceed** until the user has answered. Do not assume, research, or fill in blanks yourself. The user's intent drives everything — skipping this step leads to wasted scaffolding and mis-aligned implementation.
21
+
22
+ Save answers to `.planning/requirements.md` (or update if exists). Confirm with the user before scaffolding.
23
+
24
+ > **Auto mode exception:** If `--auto` is set with a provided idea document (see `<auto_mode>` below), the document IS the Phase 0 answer. Read it carefully and extract problem / success / scope / constraints from its contents.
25
+
9
26
  <auto_mode>
10
27
  ## Auto Mode Detection
11
28
 
@@ -81,89 +98,38 @@ Exit command.
81
98
 
82
99
  ## 2a. Auto Mode Config (auto mode only)
83
100
 
84
- **If auto mode:** Collect config settings upfront before processing the idea document.
101
+ **If auto mode:** Apply defaults silently do NOT call AskUserQuestion. The whole point of `--auto` is non-interactive execution; asking questions here blocks autonomous runs (P-1301 fix, v3.7.2).
85
102
 
86
- YOLO mode is implicit (auto = YOLO). Ask remaining config questions:
103
+ **Auto-mode defaults (applied without asking):**
87
104
 
88
- **Round 1 Core settings (3 questions, no Mode question):**
105
+ | Setting | Default | Override via |
106
+ |---------|---------|--------------|
107
+ | Depth | `quick` (3-5 phases, 1-3 plans each) | idea.md frontmatter `planning_depth: standard\|comprehensive` |
108
+ | Execution | `parallel` | idea.md frontmatter `parallelization: false` to switch to sequential |
109
+ | Git Tracking | `yes` (commit_planning_docs: true) | idea.md frontmatter `commit_planning_docs: false` |
110
+ | Research | `yes` (each phase researched before planning) | idea.md frontmatter `research_enabled: false` |
111
+ | Plan Check | `yes` (verify plans before exec) | idea.md frontmatter `plan_checker_enabled: false` |
112
+ | Verifier | `yes` (verify work after each phase) | idea.md frontmatter `verifier_enabled: false` |
113
+ | AI Models | `balanced` profile | idea.md frontmatter `model_profile: quality\|budget` |
89
114
 
90
- ```
91
- AskUserQuestion([
92
- {
93
- header: "Depth",
94
- question: "How thorough should planning be?",
95
- multiSelect: false,
96
- options: [
97
- { label: "Quick (Recommended)", description: "Ship fast (3-5 phases, 1-3 plans each)" },
98
- { label: "Standard", description: "Balanced scope and speed (5-8 phases, 3-5 plans each)" },
99
- { label: "Comprehensive", description: "Thorough coverage (8-12 phases, 5-10 plans each)" }
100
- ]
101
- },
102
- {
103
- header: "Execution",
104
- question: "Run plans in parallel?",
105
- multiSelect: false,
106
- options: [
107
- { label: "Parallel (Recommended)", description: "Independent plans run simultaneously" },
108
- { label: "Sequential", description: "One plan at a time" }
109
- ]
110
- },
111
- {
112
- header: "Git Tracking",
113
- question: "Commit planning docs to git?",
114
- multiSelect: false,
115
- options: [
116
- { label: "Yes (Recommended)", description: "Planning docs tracked in version control" },
117
- { label: "No", description: "Keep .planning/ local-only (add to .gitignore)" }
118
- ]
119
- }
120
- ])
121
- ```
122
-
123
- **Round 2 — Workflow agents (same as Step 5):**
115
+ **To use a non-default value in auto mode, embed it in the idea.md frontmatter:**
124
116
 
125
- ```
126
- AskUserQuestion([
127
- {
128
- header: "Research",
129
- question: "Research before planning each phase? (adds tokens/time)",
130
- multiSelect: false,
131
- options: [
132
- { label: "Yes (Recommended)", description: "Investigate domain, find patterns, surface gotchas" },
133
- { label: "No", description: "Plan directly from requirements" }
134
- ]
135
- },
136
- {
137
- header: "Plan Check",
138
- question: "Verify plans will achieve their goals? (adds tokens/time)",
139
- multiSelect: false,
140
- options: [
141
- { label: "Yes (Recommended)", description: "Catch gaps before execution starts" },
142
- { label: "No", description: "Execute plans without verification" }
143
- ]
144
- },
145
- {
146
- header: "Verifier",
147
- question: "Verify work satisfies requirements after each phase? (adds tokens/time)",
148
- multiSelect: false,
149
- options: [
150
- { label: "Yes (Recommended)", description: "Confirm deliverables match phase goals" },
151
- { label: "No", description: "Trust execution, skip verification" }
152
- ]
153
- },
154
- {
155
- header: "AI Models",
156
- question: "Which AI models for planning agents?",
157
- multiSelect: false,
158
- options: [
159
- { label: "Balanced (Recommended)", description: "Sonnet for most agents — good quality/cost ratio" },
160
- { label: "Quality", description: "Opus for research/roadmap — higher cost, deeper analysis" },
161
- { label: "Budget", description: "Haiku where possible — fastest, lowest cost" }
162
- ]
163
- }
164
- ])
117
+ ```yaml
118
+ ---
119
+ title: "..."
120
+ runtime_preference: claude
121
+ budget: 30
122
+ priority: medium
123
+ # Optional auto-mode overrides:
124
+ planning_depth: standard
125
+ parallelization: false
126
+ research_enabled: false
127
+ model_profile: quality
128
+ ---
165
129
  ```
166
130
 
131
+ **Read the idea.md frontmatter once, apply the defaults, log them, proceed.** No AskUserQuestion in this block. If frontmatter is missing/silent on a setting, use the table default.
132
+
167
133
  Create `.planning/config.json` with mode set to "yolo":
168
134
 
169
135
  ```json
@@ -1032,14 +998,20 @@ If the command succeeds (project.md exists and project types detected):
1032
998
 
1033
999
  Parse JSON for `project_types` and `recommendations` arrays.
1034
1000
 
1035
- **If auto mode:** Auto-select the top 2 recommended standards and commit:
1001
+ **If auto mode (P-1601 v3.7.5):** Auto-select ONLY `priority: "high"` recommendations. These are recommendations from explicitly-detected non-general project types (e.g., a recognized `web` or `ai` project). For `general` fallback projects with no explicit type signal, **skip auto-selection entirely** — leave `standards.md` absent rather than impose unrelated standards.
1036
1002
 
1037
1003
  ```bash
1038
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards select [first_id]
1039
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards select [second_id]
1040
- node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add recommended standards" --files .planning/standards.md
1004
+ HIGH_IDS=$(echo "$RECOMMEND" | jq -r '.recommendations[] | select(.priority=="high") | .id')
1005
+ if [ -n "$HIGH_IDS" ]; then
1006
+ for id in $HIGH_IDS; do
1007
+ node ./.claude/pan-wizard-core/bin/pan-tools.cjs standards select "$id"
1008
+ done
1009
+ node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: add recommended standards" --files .planning/standards.md
1010
+ fi
1041
1011
  ```
1042
1012
 
1013
+ Skipping auto-select when the project is `general` keeps `.planning/` minimal for trivial CLIs / scripts and avoids inflating agent context with irrelevant compliance checklists.
1014
+
1043
1015
  **If interactive mode:**
1044
1016
 
1045
1017
  Present recommendations:
@@ -1080,6 +1052,18 @@ Run /pan:health --standards to check compliance anytime.
1080
1052
 
1081
1053
  **If command fails** (no project.md or no recommendations): Skip silently — standards are optional.
1082
1054
 
1055
+ ## 8.9. Safety-Net Commit (P-EXP-001 fix)
1056
+
1057
+ **MANDATORY in auto mode, optional in interactive.** Defensive sweep — if any prior commit step was skipped (auto mode hit context budget early, interactive user dismissed a prompt, etc.), fold any uncommitted `.planning/` artifacts into a single bundle commit so the next workflow run starts from a clean tree.
1058
+
1059
+ ```bash
1060
+ if [ "$(git status --porcelain .planning/ 2>/dev/null)" ]; then
1061
+ node ./.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs: bundle remaining .planning artifacts (safety-net)" --files .planning/
1062
+ fi
1063
+ ```
1064
+
1065
+ **Why:** the `whoocache` experiment (2026-05-02) finished new-project with all artifacts on disk (`project.md`, `requirements.md`, `roadmap.md`, src code) but ZERO commits — the autonomous loop reached natural completion before any per-stage `pan-tools commit` invocation. This safety-net catches that pattern.
1066
+
1083
1067
  ## 9. Done
1084
1068
 
1085
1069
  Present completion summary: