pan-wizard 2.8.1

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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +772 -0
  3. package/agents/pan-debugger.md +1246 -0
  4. package/agents/pan-document_code.md +965 -0
  5. package/agents/pan-executor.md +469 -0
  6. package/agents/pan-integration-checker.md +443 -0
  7. package/agents/pan-phase-researcher.md +572 -0
  8. package/agents/pan-plan-checker.md +763 -0
  9. package/agents/pan-planner.md +1297 -0
  10. package/agents/pan-project-researcher.md +647 -0
  11. package/agents/pan-research-synthesizer.md +239 -0
  12. package/agents/pan-reviewer.md +112 -0
  13. package/agents/pan-roadmapper.md +642 -0
  14. package/agents/pan-verifier.md +672 -0
  15. package/assets/pan-logo-2000-transparent.svg +30 -0
  16. package/assets/pan-logo-2000.svg +43 -0
  17. package/assets/terminal.svg +119 -0
  18. package/bin/install-lib.cjs +616 -0
  19. package/bin/install.js +1936 -0
  20. package/commands/pan/add-phase.md +44 -0
  21. package/commands/pan/assumptions.md +47 -0
  22. package/commands/pan/audit-deployment.md +378 -0
  23. package/commands/pan/debug.md +168 -0
  24. package/commands/pan/discord.md +19 -0
  25. package/commands/pan/discuss-phase.md +84 -0
  26. package/commands/pan/exec-phase.md +45 -0
  27. package/commands/pan/focus-auto.md +323 -0
  28. package/commands/pan/focus-design.md +816 -0
  29. package/commands/pan/focus-exec.md +316 -0
  30. package/commands/pan/focus-plan.md +101 -0
  31. package/commands/pan/focus-scan.md +272 -0
  32. package/commands/pan/focus-sync.md +104 -0
  33. package/commands/pan/health.md +23 -0
  34. package/commands/pan/help.md +23 -0
  35. package/commands/pan/insert-phase.md +33 -0
  36. package/commands/pan/map-codebase.md +72 -0
  37. package/commands/pan/milestone-audit.md +37 -0
  38. package/commands/pan/milestone-cleanup.md +19 -0
  39. package/commands/pan/milestone-done.md +137 -0
  40. package/commands/pan/milestone-gaps.md +35 -0
  41. package/commands/pan/milestone-new.md +45 -0
  42. package/commands/pan/new-project.md +43 -0
  43. package/commands/pan/patches.md +110 -0
  44. package/commands/pan/pause.md +39 -0
  45. package/commands/pan/phase-budget.md +23 -0
  46. package/commands/pan/phase-tests.md +42 -0
  47. package/commands/pan/plan-phase.md +46 -0
  48. package/commands/pan/profile.md +36 -0
  49. package/commands/pan/progress.md +25 -0
  50. package/commands/pan/quick.md +42 -0
  51. package/commands/pan/remove-phase.md +32 -0
  52. package/commands/pan/research-phase.md +190 -0
  53. package/commands/pan/resume.md +41 -0
  54. package/commands/pan/retro.md +33 -0
  55. package/commands/pan/settings.md +37 -0
  56. package/commands/pan/todo-add.md +48 -0
  57. package/commands/pan/todo-check.md +46 -0
  58. package/commands/pan/update.md +38 -0
  59. package/commands/pan/verify-phase.md +39 -0
  60. package/hooks/dist/pan-check-update.js +62 -0
  61. package/hooks/dist/pan-context-monitor.js +122 -0
  62. package/hooks/dist/pan-statusline.js +108 -0
  63. package/package.json +66 -0
  64. package/pan-wizard-core/bin/lib/codebase.cjs +746 -0
  65. package/pan-wizard-core/bin/lib/commands.cjs +1435 -0
  66. package/pan-wizard-core/bin/lib/config.cjs +611 -0
  67. package/pan-wizard-core/bin/lib/constants.cjs +696 -0
  68. package/pan-wizard-core/bin/lib/context-budget.cjs +150 -0
  69. package/pan-wizard-core/bin/lib/core.cjs +650 -0
  70. package/pan-wizard-core/bin/lib/focus.cjs +900 -0
  71. package/pan-wizard-core/bin/lib/frontmatter.cjs +442 -0
  72. package/pan-wizard-core/bin/lib/init.cjs +881 -0
  73. package/pan-wizard-core/bin/lib/milestone.cjs +276 -0
  74. package/pan-wizard-core/bin/lib/phase.cjs +1212 -0
  75. package/pan-wizard-core/bin/lib/roadmap.cjs +470 -0
  76. package/pan-wizard-core/bin/lib/state.cjs +1029 -0
  77. package/pan-wizard-core/bin/lib/template.cjs +314 -0
  78. package/pan-wizard-core/bin/lib/utils.cjs +171 -0
  79. package/pan-wizard-core/bin/lib/verify.cjs +1808 -0
  80. package/pan-wizard-core/bin/pan-tools.cjs +773 -0
  81. package/pan-wizard-core/references/checkpoints.md +776 -0
  82. package/pan-wizard-core/references/continuation-format.md +249 -0
  83. package/pan-wizard-core/references/decimal-phase-calculation.md +65 -0
  84. package/pan-wizard-core/references/git-integration.md +248 -0
  85. package/pan-wizard-core/references/git-planning-commit.md +38 -0
  86. package/pan-wizard-core/references/model-profile-resolution.md +34 -0
  87. package/pan-wizard-core/references/model-profiles.md +111 -0
  88. package/pan-wizard-core/references/phase-argument-parsing.md +61 -0
  89. package/pan-wizard-core/references/planning-config.md +196 -0
  90. package/pan-wizard-core/references/questioning.md +145 -0
  91. package/pan-wizard-core/references/tdd.md +263 -0
  92. package/pan-wizard-core/references/ui-brand.md +160 -0
  93. package/pan-wizard-core/references/verification-patterns.md +612 -0
  94. package/pan-wizard-core/templates/codebase/architecture.md +283 -0
  95. package/pan-wizard-core/templates/codebase/best-practices.md +133 -0
  96. package/pan-wizard-core/templates/codebase/concerns.md +325 -0
  97. package/pan-wizard-core/templates/codebase/conventions.md +307 -0
  98. package/pan-wizard-core/templates/codebase/integrations.md +305 -0
  99. package/pan-wizard-core/templates/codebase/relationships.md +124 -0
  100. package/pan-wizard-core/templates/codebase/stack.md +199 -0
  101. package/pan-wizard-core/templates/codebase/structure.md +298 -0
  102. package/pan-wizard-core/templates/codebase/testing.md +480 -0
  103. package/pan-wizard-core/templates/config.json +37 -0
  104. package/pan-wizard-core/templates/context.md +283 -0
  105. package/pan-wizard-core/templates/continue-here.md +78 -0
  106. package/pan-wizard-core/templates/debug-subagent-prompt.md +91 -0
  107. package/pan-wizard-core/templates/debug.md +164 -0
  108. package/pan-wizard-core/templates/discovery.md +146 -0
  109. package/pan-wizard-core/templates/milestone-archive.md +123 -0
  110. package/pan-wizard-core/templates/milestone.md +115 -0
  111. package/pan-wizard-core/templates/phase-prompt.md +593 -0
  112. package/pan-wizard-core/templates/planner-subagent-prompt.md +117 -0
  113. package/pan-wizard-core/templates/project.md +184 -0
  114. package/pan-wizard-core/templates/requirements.md +231 -0
  115. package/pan-wizard-core/templates/research-project/architecture.md +204 -0
  116. package/pan-wizard-core/templates/research-project/features.md +147 -0
  117. package/pan-wizard-core/templates/research-project/pitfalls.md +200 -0
  118. package/pan-wizard-core/templates/research-project/stack.md +120 -0
  119. package/pan-wizard-core/templates/research-project/summary.md +170 -0
  120. package/pan-wizard-core/templates/research.md +552 -0
  121. package/pan-wizard-core/templates/retrospective.md +54 -0
  122. package/pan-wizard-core/templates/roadmap.md +202 -0
  123. package/pan-wizard-core/templates/standards.md +24 -0
  124. package/pan-wizard-core/templates/state.md +176 -0
  125. package/pan-wizard-core/templates/summary-complex.md +59 -0
  126. package/pan-wizard-core/templates/summary-minimal.md +41 -0
  127. package/pan-wizard-core/templates/summary-standard.md +49 -0
  128. package/pan-wizard-core/templates/summary.md +249 -0
  129. package/pan-wizard-core/templates/uat.md +247 -0
  130. package/pan-wizard-core/templates/user-setup.md +311 -0
  131. package/pan-wizard-core/templates/validation.md +76 -0
  132. package/pan-wizard-core/templates/verification-report.md +322 -0
  133. package/pan-wizard-core/workflows/add-phase.md +111 -0
  134. package/pan-wizard-core/workflows/assumptions.md +178 -0
  135. package/pan-wizard-core/workflows/diagnose-issues.md +219 -0
  136. package/pan-wizard-core/workflows/discuss-phase.md +542 -0
  137. package/pan-wizard-core/workflows/exec-phase.md +572 -0
  138. package/pan-wizard-core/workflows/execute-plan.md +448 -0
  139. package/pan-wizard-core/workflows/health.md +156 -0
  140. package/pan-wizard-core/workflows/help.md +431 -0
  141. package/pan-wizard-core/workflows/insert-phase.md +129 -0
  142. package/pan-wizard-core/workflows/map-codebase.md +401 -0
  143. package/pan-wizard-core/workflows/milestone-audit.md +297 -0
  144. package/pan-wizard-core/workflows/milestone-cleanup.md +152 -0
  145. package/pan-wizard-core/workflows/milestone-gaps.md +274 -0
  146. package/pan-wizard-core/workflows/milestone-new.md +382 -0
  147. package/pan-wizard-core/workflows/new-project.md +1178 -0
  148. package/pan-wizard-core/workflows/pause.md +122 -0
  149. package/pan-wizard-core/workflows/phase-tests.md +388 -0
  150. package/pan-wizard-core/workflows/plan-phase.md +569 -0
  151. package/pan-wizard-core/workflows/profile.md +115 -0
  152. package/pan-wizard-core/workflows/progress.md +381 -0
  153. package/pan-wizard-core/workflows/quick.md +453 -0
  154. package/pan-wizard-core/workflows/remove-phase.md +154 -0
  155. package/pan-wizard-core/workflows/research-phase.md +73 -0
  156. package/pan-wizard-core/workflows/resume-project.md +306 -0
  157. package/pan-wizard-core/workflows/retro.md +121 -0
  158. package/pan-wizard-core/workflows/settings.md +213 -0
  159. package/pan-wizard-core/workflows/todo-add.md +157 -0
  160. package/pan-wizard-core/workflows/todo-check.md +176 -0
  161. package/pan-wizard-core/workflows/transition.md +544 -0
  162. package/pan-wizard-core/workflows/update.md +219 -0
  163. package/pan-wizard-core/workflows/verify-phase.md +301 -0
  164. package/scripts/build-hooks.js +43 -0
@@ -0,0 +1,219 @@
1
+ <purpose>
2
+ Check for PAN updates via npm, display changelog for versions between installed and latest, obtain user confirmation, and execute clean installation with cache clearing.
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ Read all files referenced by the invoking prompt's execution_context before starting.
7
+ </required_reading>
8
+
9
+ <process>
10
+
11
+ <step name="get_installed_version">
12
+ Detect whether PAN is installed locally or globally by checking both locations and validating install integrity:
13
+
14
+ ```bash
15
+ # Check local first (takes priority only if valid)
16
+ # Paths templated at install time for runtime compatibility
17
+ LOCAL_VERSION_FILE="./.claude/pan-wizard-core/VERSION"
18
+ LOCAL_MARKER_FILE="./.claude/pan-wizard-core/workflows/update.md"
19
+ GLOBAL_VERSION_FILE="$HOME/.claude/pan-wizard-core/VERSION"
20
+ GLOBAL_MARKER_FILE="$HOME/.claude/pan-wizard-core/workflows/update.md"
21
+
22
+ if [ -f "$LOCAL_VERSION_FILE" ] && [ -f "$LOCAL_MARKER_FILE" ] && grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+' "$LOCAL_VERSION_FILE"; then
23
+ cat "$LOCAL_VERSION_FILE"
24
+ echo "LOCAL"
25
+ elif [ -f "$GLOBAL_VERSION_FILE" ] && [ -f "$GLOBAL_MARKER_FILE" ] && grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+' "$GLOBAL_VERSION_FILE"; then
26
+ cat "$GLOBAL_VERSION_FILE"
27
+ echo "GLOBAL"
28
+ else
29
+ echo "UNKNOWN"
30
+ fi
31
+ ```
32
+
33
+ Parse output:
34
+ - If last line is "LOCAL": local install is valid; installed version is first line; use `--local`
35
+ - If last line is "GLOBAL": local missing/invalid, global install is valid; installed version is first line; use `--global`
36
+ - If "UNKNOWN": proceed to install step (treat as version 0.0.0)
37
+
38
+ **If VERSION file missing:**
39
+ ```
40
+ ## PAN Update
41
+
42
+ **Installed version:** Unknown
43
+
44
+ Your installation doesn't include version tracking.
45
+
46
+ Running fresh install...
47
+ ```
48
+
49
+ Proceed to install step (treat as version 0.0.0 for comparison).
50
+ </step>
51
+
52
+ <step name="check_latest_version">
53
+ Check npm for latest version:
54
+
55
+ ```bash
56
+ npm view pan-wizard version 2>/dev/null
57
+ ```
58
+
59
+ **If npm check fails:**
60
+ ```
61
+ Couldn't check for updates (offline or npm unavailable).
62
+
63
+ To update manually: `npx pan-wizard --global`
64
+ ```
65
+
66
+ Exit.
67
+ </step>
68
+
69
+ <step name="compare_versions">
70
+ Compare installed vs latest:
71
+
72
+ **If installed == latest:**
73
+ ```
74
+ ## PAN Update
75
+
76
+ **Installed:** X.Y.Z
77
+ **Latest:** X.Y.Z
78
+
79
+ You're already on the latest version.
80
+ ```
81
+
82
+ Exit.
83
+
84
+ **If installed > latest:**
85
+ ```
86
+ ## PAN Update
87
+
88
+ **Installed:** X.Y.Z
89
+ **Latest:** A.B.C
90
+
91
+ You're ahead of the latest release (development version?).
92
+ ```
93
+
94
+ Exit.
95
+ </step>
96
+
97
+ <step name="show_changes_and_confirm">
98
+ **If update available**, fetch and show what's new BEFORE updating:
99
+
100
+ 1. Fetch changelog from GitHub raw URL
101
+ 2. Extract entries between installed and latest versions
102
+ 3. Display preview and ask for confirmation:
103
+
104
+ ```
105
+ ## PAN Update Available
106
+
107
+ **Installed:** 1.5.10
108
+ **Latest:** 1.5.15
109
+
110
+ ### What's New
111
+ ────────────────────────────────────────────────────────────
112
+
113
+ ## [1.5.15] - 2026-01-20
114
+
115
+ ### Added
116
+ - Feature X
117
+
118
+ ## [1.5.14] - 2026-01-18
119
+
120
+ ### Fixed
121
+ - Bug fix Y
122
+
123
+ ────────────────────────────────────────────────────────────
124
+
125
+ ⚠️ **Note:** The installer performs a clean install of PAN folders:
126
+ - `commands/pan/` will be wiped and replaced
127
+ - `pan-wizard-core/` will be wiped and replaced
128
+ - `agents/pan-*` files will be replaced
129
+
130
+ (Paths are relative to your install location: `~/.claude/` for global, `./.claude/` for local)
131
+
132
+ Your custom files in other locations are preserved:
133
+ - Custom commands not in `commands/pan/` ✓
134
+ - Custom agents not prefixed with `pan-` ✓
135
+ - Custom hooks ✓
136
+ - Your CLAUDE.md files ✓
137
+
138
+ If you've modified any PAN files directly, they'll be automatically backed up to `pan-local-patches/` and can be reapplied with `/pan:patches` after the update.
139
+ ```
140
+
141
+ Use AskUserQuestion:
142
+ - Question: "Proceed with update?"
143
+ - Options:
144
+ - "Yes, update now"
145
+ - "No, cancel"
146
+
147
+ **If user cancels:** Exit.
148
+ </step>
149
+
150
+ <step name="run_update">
151
+ Run the update using the install type detected in step 1:
152
+
153
+ **If LOCAL install:**
154
+ ```bash
155
+ npx -y pan-wizard@latest --local
156
+ ```
157
+
158
+ **If GLOBAL install (or unknown):**
159
+ ```bash
160
+ npx -y pan-wizard@latest --global
161
+ ```
162
+
163
+ Capture output. If install fails, show error and exit.
164
+
165
+ Clear the update cache so statusline indicator disappears:
166
+
167
+ **If LOCAL install:**
168
+ ```bash
169
+ rm -f ./.claude/cache/pan-update-check.json
170
+ ```
171
+
172
+ **If GLOBAL install:**
173
+ ```bash
174
+ rm -f ~/.claude/cache/pan-update-check.json
175
+ ```
176
+ (Paths are templated at install time for runtime compatibility)
177
+ </step>
178
+
179
+ <step name="display_result">
180
+ Format completion message (changelog was already shown in confirmation step):
181
+
182
+ ```
183
+ ╔═══════════════════════════════════════════════════════════╗
184
+ ║ PAN Updated: v1.5.10 → v1.5.15 ║
185
+ ╚═══════════════════════════════════════════════════════════╝
186
+
187
+ ⚠️ Restart Claude Code to pick up the new commands.
188
+
189
+ [View full changelog](https://github.com/pan-wizard-core/blob/main/CHANGELOG.md)
190
+ ```
191
+ </step>
192
+
193
+
194
+ <step name="check_local_patches">
195
+ After update completes, check if the installer detected and backed up any locally modified files:
196
+
197
+ Check for pan-local-patches/backup-meta.json in the config directory.
198
+
199
+ **If patches found:**
200
+
201
+ ```
202
+ Local patches were backed up before the update.
203
+ Run /pan:patches to merge your modifications into the new version.
204
+ ```
205
+
206
+ **If no patches:** Continue normally.
207
+ </step>
208
+ </process>
209
+
210
+ <success_criteria>
211
+ - [ ] Installed version read correctly
212
+ - [ ] Latest version checked via npm
213
+ - [ ] Update skipped if already current
214
+ - [ ] Changelog fetched and displayed BEFORE update
215
+ - [ ] Clean install warning shown
216
+ - [ ] User confirmation obtained
217
+ - [ ] Update executed successfully
218
+ - [ ] Restart reminder shown
219
+ </success_criteria>
@@ -0,0 +1,301 @@
1
+ <purpose>
2
+ Verify phase goal achievement through goal-backward analysis. Check that the codebase delivers what the phase promised, not just that tasks completed.
3
+
4
+ Executed by a verification subagent spawned from exec-phase.md.
5
+ </purpose>
6
+
7
+ <core_principle>
8
+ **Task completion ≠ Goal achievement**
9
+
10
+ A task "create chat component" can be marked complete when the component is a placeholder. The task was done — but the goal "working chat interface" was not achieved.
11
+
12
+ Goal-backward verification:
13
+ 1. What must be TRUE for the goal to be achieved?
14
+ 2. What must EXIST for those truths to hold?
15
+ 3. What must be WIRED for those artifacts to function?
16
+
17
+ Then verify each level against the actual codebase.
18
+ </core_principle>
19
+
20
+ <required_reading>
21
+ @~/.claude/pan-wizard-core/references/verification-patterns.md
22
+ @~/.claude/pan-wizard-core/templates/verification-report.md
23
+ </required_reading>
24
+
25
+ <process>
26
+
27
+ <step name="load_context" priority="first">
28
+ Load phase operation context:
29
+
30
+ ```bash
31
+ INIT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs init phase-op "${PHASE_ARG}")
32
+ ```
33
+
34
+ Extract from init JSON: `phase_dir`, `phase_number`, `phase_name`, `has_plans`, `plan_count`.
35
+
36
+ Then load phase details and list plans/summaries:
37
+ ```bash
38
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${phase_number}"
39
+ grep -E "^| ${phase_number}" .planning/requirements.md 2>/dev/null
40
+ ls "$phase_dir"/*-summary.md "$phase_dir"/*-plan.md 2>/dev/null
41
+ ```
42
+
43
+ Extract **phase goal** from roadmap.md (the outcome to verify, not tasks) and **requirements** from requirements.md if it exists.
44
+ </step>
45
+
46
+ <step name="check_prior_verification">
47
+ **Check that previous phase (if any) has been verified.**
48
+
49
+ If `phase_number` > 1:
50
+ ```bash
51
+ PREV=$((phase_number - 1))
52
+ PREV_VERIF=$(ls .planning/phase-${PREV}*/*-verification.md 2>/dev/null | head -1)
53
+ ```
54
+
55
+ If `PREV_VERIF` is empty:
56
+ - Log: `⚠ Phase ${PREV} has no verification record`
57
+ - Continue (informational warning, not a blocker at verification time)
58
+
59
+ If `PREV_VERIF` exists, check its frontmatter `status:`:
60
+ - `passed` → OK, continue
61
+ - `gaps_found` → Log: `⚠ Phase ${PREV} has unresolved gaps` and continue
62
+ - `human_needed` → Log: `ℹ Phase ${PREV} awaiting human review` and continue
63
+
64
+ This step provides awareness; the hard gate is enforced by exec-phase.
65
+ </step>
66
+
67
+ <step name="run_test_suite">
68
+ **Run the project's test suite as a verification gate.**
69
+
70
+ This step catches test regressions that goal-backward analysis cannot detect.
71
+
72
+ 1. Detect test command:
73
+ ```bash
74
+ TEST_CMD=$(node -e "const p=require('./package.json'); console.log(p.scripts && p.scripts.test || 'echo no test')")
75
+ ```
76
+
77
+ 2. Run test suite and capture results:
78
+ ```bash
79
+ TEST_OUTPUT=$(npm test 2>&1)
80
+ TEST_EXIT=$?
81
+ TEST_COUNT=$(echo "$TEST_OUTPUT" | grep -E "^ℹ tests" | awk '{print $NF}')
82
+ TEST_PASS=$(echo "$TEST_OUTPUT" | grep -E "^ℹ pass" | awk '{print $NF}')
83
+ TEST_FAIL=$(echo "$TEST_OUTPUT" | grep -E "^ℹ fail" | awk '{print $NF}')
84
+ ```
85
+
86
+ 3. Evaluate results:
87
+
88
+ | Condition | Action |
89
+ |-----------|--------|
90
+ | All tests pass (`TEST_FAIL` = 0) | Record counts, continue to must-haves |
91
+ | Tests regress (failures exist) | Set `test_gate_status: failed`, include failure details in verification report |
92
+ | No test command found | Record as `test_gate_status: skipped`, continue |
93
+
94
+ 4. Store test gate results for inclusion in verification.md:
95
+ ```
96
+ TEST_GATE_STATUS: passed | failed | skipped
97
+ TEST_TOTAL: ${TEST_COUNT}
98
+ TEST_PASSED: ${TEST_PASS}
99
+ TEST_FAILED: ${TEST_FAIL}
100
+ ```
101
+
102
+ **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.
103
+ </step>
104
+
105
+ <step name="establish_must_haves">
106
+ **Option A: Must-haves in PLAN frontmatter**
107
+
108
+ Use pan-tools to extract must_haves from each PLAN:
109
+
110
+ ```bash
111
+ for plan in "$PHASE_DIR"/*-plan.md; do
112
+ MUST_HAVES=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs frontmatter get "$plan" --field must_haves)
113
+ echo "=== $plan ===" && echo "$MUST_HAVES"
114
+ done
115
+ ```
116
+
117
+ Returns JSON: `{ truths: [...], artifacts: [...], key_links: [...] }`
118
+
119
+ Aggregate all must_haves across plans for phase-level verification.
120
+
121
+ **Option B: Use Success Criteria from roadmap.md**
122
+
123
+ If no must_haves in frontmatter (MUST_HAVES returns error or empty), check for Success Criteria:
124
+
125
+ ```bash
126
+ PHASE_DATA=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs roadmap get-phase "${phase_number}" --raw)
127
+ ```
128
+
129
+ Parse the `success_criteria` array from the JSON output. If non-empty:
130
+ 1. Use each Success Criterion directly as a **truth** (they are already written as observable, testable behaviors)
131
+ 2. Derive **artifacts** (concrete file paths for each truth)
132
+ 3. Derive **key links** (critical wiring where stubs hide)
133
+ 4. Document the must-haves before proceeding
134
+
135
+ Success Criteria from roadmap.md are the contract — they override PLAN-level must_haves when both exist.
136
+
137
+ **Option C: Derive from phase goal (fallback)**
138
+
139
+ If no must_haves in frontmatter AND no Success Criteria in ROADMAP:
140
+ 1. State the goal from roadmap.md
141
+ 2. Derive **truths** (3-7 observable behaviors, each testable)
142
+ 3. Derive **artifacts** (concrete file paths for each truth)
143
+ 4. Derive **key links** (critical wiring where stubs hide)
144
+ 5. Document derived must-haves before proceeding
145
+ </step>
146
+
147
+ <step name="verify_truths">
148
+ For each observable truth, determine if the codebase enables it.
149
+
150
+ **Status:** ✓ VERIFIED (all supporting artifacts pass) | ✗ FAILED (artifact missing/stub/unwired) | ? UNCERTAIN (needs human)
151
+
152
+ For each truth: identify supporting artifacts → check artifact status → check wiring → determine truth status.
153
+
154
+ **Example:** Truth "User can see existing messages" depends on Chat.tsx (renders), /api/chat GET (provides), Message model (schema). If Chat.tsx is a stub or API returns hardcoded [] → FAILED. If all exist, are substantive, and connected → VERIFIED.
155
+ </step>
156
+
157
+ <step name="verify_artifacts">
158
+ Use pan-tools for artifact verification against must_haves in each PLAN:
159
+
160
+ ```bash
161
+ for plan in "$PHASE_DIR"/*-plan.md; do
162
+ ARTIFACT_RESULT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify artifacts "$plan")
163
+ echo "=== $plan ===" && echo "$ARTIFACT_RESULT"
164
+ done
165
+ ```
166
+
167
+ Parse JSON result: `{ all_passed, passed, total, artifacts: [{path, exists, issues, passed}] }`
168
+
169
+ **Artifact status from result:**
170
+ - `exists=false` → MISSING
171
+ - `issues` not empty → STUB (check issues for "Only N lines" or "Missing pattern")
172
+ - `passed=true` → VERIFIED (Levels 1-2 pass)
173
+
174
+ **Level 3 — Wired (manual check for artifacts that pass Levels 1-2):**
175
+ ```bash
176
+ grep -r "import.*$artifact_name" src/ --include="*.ts" --include="*.tsx" # IMPORTED
177
+ grep -r "$artifact_name" src/ --include="*.ts" --include="*.tsx" | grep -v "import" # USED
178
+ ```
179
+ WIRED = imported AND used. ORPHANED = exists but not imported/used.
180
+
181
+ | Exists | Substantive | Wired | Status |
182
+ |--------|-------------|-------|--------|
183
+ | ✓ | ✓ | ✓ | ✓ VERIFIED |
184
+ | ✓ | ✓ | ✗ | ⚠️ ORPHANED |
185
+ | ✓ | ✗ | - | ✗ STUB |
186
+ | ✗ | - | - | ✗ MISSING |
187
+ </step>
188
+
189
+ <step name="verify_wiring">
190
+ Use pan-tools for key link verification against must_haves in each PLAN:
191
+
192
+ ```bash
193
+ for plan in "$PHASE_DIR"/*-plan.md; do
194
+ LINKS_RESULT=$(node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify key-links "$plan")
195
+ echo "=== $plan ===" && echo "$LINKS_RESULT"
196
+ done
197
+ ```
198
+
199
+ Parse JSON result: `{ all_verified, verified, total, links: [{from, to, via, verified, detail}] }`
200
+
201
+ **Link status from result:**
202
+ - `verified=true` → WIRED
203
+ - `verified=false` with "not found" → NOT_WIRED
204
+ - `verified=false` with "Pattern not found" → PARTIAL
205
+
206
+ **Fallback patterns (if key_links not in must_haves):**
207
+
208
+ | Pattern | Check | Status |
209
+ |---------|-------|--------|
210
+ | Component → API | fetch/axios call to API path, response used (await/.then/setState) | WIRED / PARTIAL (call but unused response) / NOT_WIRED |
211
+ | API → Database | Prisma/DB query on model, result returned via res.json() | WIRED / PARTIAL (query but not returned) / NOT_WIRED |
212
+ | Form → Handler | onSubmit with real implementation (fetch/axios/mutate/dispatch), not console.log/empty | WIRED / STUB (log-only/empty) / NOT_WIRED |
213
+ | State → Render | useState variable appears in JSX (`{stateVar}` or `{stateVar.property}`) | WIRED / NOT_WIRED |
214
+
215
+ Record status and evidence for each key link.
216
+ </step>
217
+
218
+ <step name="verify_requirements">
219
+ If requirements.md exists:
220
+ ```bash
221
+ grep -E "Phase ${PHASE_NUM}" .planning/requirements.md 2>/dev/null
222
+ ```
223
+
224
+ For each requirement: parse description → identify supporting truths/artifacts → status: ✓ SATISFIED / ✗ BLOCKED / ? NEEDS HUMAN.
225
+ </step>
226
+
227
+ <step name="scan_antipatterns">
228
+ Extract files modified in this phase from summary.md, scan each:
229
+
230
+ | Pattern | Search | Severity |
231
+ |---------|--------|----------|
232
+ | TODO/FIXME/XXX/HACK | `grep -n -E "TODO\|FIXME\|XXX\|HACK"` | ⚠️ Warning |
233
+ | Placeholder content | `grep -n -iE "placeholder\|coming soon\|will be here"` | 🛑 Blocker |
234
+ | Empty returns | `grep -n -E "return null\|return \{\}\|return \[\]\|=> \{\}"` | ⚠️ Warning |
235
+ | Log-only functions | Functions containing only console.log | ⚠️ Warning |
236
+
237
+ Categorize: 🛑 Blocker (prevents goal) | ⚠️ Warning (incomplete) | ℹ️ Info (notable).
238
+ </step>
239
+
240
+ <step name="identify_human_verification">
241
+ **Always needs human:** Visual appearance, user flow completion, real-time behavior (WebSocket/SSE), external service integration, performance feel, error message clarity.
242
+
243
+ **Needs human if uncertain:** Complex wiring grep can't trace, dynamic state-dependent behavior, edge cases.
244
+
245
+ Format each as: Test Name → What to do → Expected result → Why can't verify programmatically.
246
+ </step>
247
+
248
+ <step name="determine_status">
249
+ **passed:** All truths VERIFIED, all artifacts pass levels 1-3, all key links WIRED, no blocker anti-patterns, AND test gate passed or skipped.
250
+
251
+ **gaps_found:** Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, blocker found, OR test gate FAILED (test regressions detected).
252
+
253
+ **human_needed:** All automated checks pass and test gate passed, but human verification items remain.
254
+
255
+ **Score:** `verified_truths / total_truths` + test gate status
256
+ </step>
257
+
258
+ <step name="generate_fix_plans">
259
+ If gaps_found:
260
+
261
+ 1. **Cluster related gaps:** API stub + component unwired → "Wire frontend to backend". Multiple missing → "Complete core implementation". Wiring only → "Connect existing components".
262
+
263
+ 2. **Generate plan per cluster:** Objective, 2-3 tasks (files/action/verify each), re-verify step. Keep focused: single concern per plan.
264
+
265
+ 3. **Order by dependency:** Fix missing → fix stubs → fix wiring → verify.
266
+ </step>
267
+
268
+ <step name="create_report">
269
+ ```bash
270
+ REPORT_PATH="$PHASE_DIR/${PHASE_NUM}-verification.md"
271
+ ```
272
+
273
+ 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.
274
+
275
+ See ~/.claude/pan-wizard-core/templates/verification-report.md for complete template.
276
+ </step>
277
+
278
+ <step name="return_to_orchestrator">
279
+ Return status (`passed` | `gaps_found` | `human_needed`), score (N/M must-haves), report path.
280
+
281
+ If gaps_found: list gaps + recommended fix plan names.
282
+ If human_needed: list items requiring human testing.
283
+
284
+ Orchestrator routes: `passed` → update_roadmap | `gaps_found` → create/execute fixes, re-verify | `human_needed` → present to user.
285
+ </step>
286
+
287
+ </process>
288
+
289
+ <success_criteria>
290
+ - [ ] Must-haves established (from frontmatter or derived)
291
+ - [ ] All truths verified with status and evidence
292
+ - [ ] All artifacts checked at all three levels
293
+ - [ ] All key links verified
294
+ - [ ] Requirements coverage assessed (if applicable)
295
+ - [ ] Anti-patterns scanned and categorized
296
+ - [ ] Human verification items identified
297
+ - [ ] Overall status determined
298
+ - [ ] Fix plans generated (if gaps_found)
299
+ - [ ] verification.md created with complete report
300
+ - [ ] Results returned to orchestrator
301
+ </success_criteria>
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copy PAN hooks to dist for installation.
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ const HOOKS_DIR = path.join(__dirname, '..', 'hooks');
10
+ const DIST_DIR = path.join(HOOKS_DIR, 'dist');
11
+
12
+ // Hooks to copy (pure Node.js, no bundling needed)
13
+ const HOOKS_TO_COPY = [
14
+ 'pan-check-update.js',
15
+ 'pan-context-monitor.js',
16
+ 'pan-statusline.js'
17
+ ];
18
+
19
+ function build() {
20
+ // Ensure dist directory exists
21
+ if (!fs.existsSync(DIST_DIR)) {
22
+ fs.mkdirSync(DIST_DIR, { recursive: true });
23
+ }
24
+
25
+ // Copy hooks to dist
26
+ for (const hook of HOOKS_TO_COPY) {
27
+ const src = path.join(HOOKS_DIR, hook);
28
+ const dest = path.join(DIST_DIR, hook);
29
+
30
+ if (!fs.existsSync(src)) {
31
+ console.warn(`Warning: ${hook} not found, skipping`);
32
+ continue;
33
+ }
34
+
35
+ console.log(`Copying ${hook}...`);
36
+ fs.copyFileSync(src, dest);
37
+ console.log(` → ${dest}`);
38
+ }
39
+
40
+ console.log('\nBuild complete.');
41
+ }
42
+
43
+ build();