pan-wizard 3.13.1 → 3.15.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 (39) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -5
  3. package/commands/pan/audit-deployment.md +384 -384
  4. package/commands/pan/focus-auto.md +683 -683
  5. package/commands/pan/focus-doc-audit.md +530 -530
  6. package/commands/pan/focus-drift-walking.md +525 -525
  7. package/commands/pan/git.md +1 -1
  8. package/commands/pan/hud.md +3 -2
  9. package/commands/pan/report.md +70 -0
  10. package/hooks/dist/pan-check-update.js +62 -62
  11. package/hooks/dist/pan-context-monitor.js +134 -122
  12. package/hooks/dist/pan-statusline.js +7 -1
  13. package/package.json +5 -5
  14. package/pan-wizard-core/bin/lib/config.cjs +14 -1
  15. package/pan-wizard-core/bin/lib/core.cjs +6 -2
  16. package/pan-wizard-core/bin/lib/doc-lint.cjs +86 -1
  17. package/pan-wizard-core/bin/lib/focus.cjs +48 -2
  18. package/pan-wizard-core/bin/lib/frontmatter.cjs +442 -442
  19. package/pan-wizard-core/bin/lib/hud.cjs +202 -17
  20. package/pan-wizard-core/bin/lib/knowledge.cjs +2 -2
  21. package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
  22. package/pan-wizard-core/bin/lib/phase-remove.cjs +1 -1
  23. package/pan-wizard-core/bin/lib/phase-report.cjs +723 -0
  24. package/pan-wizard-core/bin/lib/phase.cjs +4 -4
  25. package/pan-wizard-core/bin/lib/review-deep.cjs +3 -1
  26. package/pan-wizard-core/bin/lib/utils.cjs +171 -171
  27. package/pan-wizard-core/bin/lib/verify.cjs +172 -61
  28. package/pan-wizard-core/bin/pan-tools.cjs +1499 -1463
  29. package/pan-wizard-core/references/checkpoints.md +776 -776
  30. package/pan-wizard-core/references/continuation-format.md +249 -249
  31. package/pan-wizard-core/references/questioning.md +145 -145
  32. package/pan-wizard-core/references/tdd.md +263 -263
  33. package/pan-wizard-core/references/ui-brand.md +160 -160
  34. package/pan-wizard-core/templates/config.json +38 -38
  35. package/pan-wizard-core/workflows/exec-phase.md +14 -0
  36. package/scripts/build-hooks.js +51 -51
  37. package/scripts/git-hooks/pre-commit +0 -0
  38. package/scripts/release-check.js +53 -47
  39. package/scripts/run-tests.cjs +44 -0
@@ -1,384 +1,384 @@
1
- ---
2
- name: pan:audit-deployment
3
- group: System
4
- description: Audit a PAN Wizard deployment — verify installation integrity, project health, and draft enhancement specs
5
- argument-hint: <target-directory> [--enhancements] [--repair]
6
- allowed-tools:
7
- - Read
8
- - Bash
9
- - Write
10
- - Glob
11
- - Grep
12
- - AskUserQuestion
13
- ---
14
- <objective>
15
- Audit a directory where PAN Wizard was installed and a project was run. Verify installation integrity, validate project artifacts, assess workflow execution quality, and optionally produce a featureAI-format enhancement spec that superplan.md can consume for development planning.
16
- </objective>
17
-
18
- <execution_context>
19
- This command operates on a TARGET directory (not the PAN source repo). The target must be provided as the first argument.
20
- </execution_context>
21
-
22
- <process>
23
-
24
- <step name="parse_args">
25
- **Parse arguments:**
26
-
27
- Extract target directory path from the first argument. It is REQUIRED.
28
-
29
- ```
30
- TARGET_DIR = first positional argument
31
- ENHANCEMENTS_FLAG = "--enhancements" present?
32
- REPAIR_FLAG = "--repair" present?
33
- ```
34
-
35
- If no target directory is provided, ask the user:
36
- > Which directory should I audit? Provide the full path to the folder where PAN Wizard was installed and a project was run.
37
-
38
- Validate the directory exists before proceeding.
39
- </step>
40
-
41
- <investigate_before_judging>
42
- Never report a file as missing, broken, or misconfigured without reading it first.
43
- For every audit check: read the actual file, verify its contents, then state the finding with evidence.
44
- Do not speculate about file contents based on filenames alone.
45
- </investigate_before_judging>
46
-
47
- <step name="installation_audit">
48
- **Phase 1 — Installation Integrity Audit**
49
-
50
- Check the PAN Wizard installation artifacts in the target directory. Determine which runtime was used (Claude, Gemini, OpenCode, Codex, Copilot) by checking for config directories:
51
-
52
- ```
53
- Claude: <target>/.claude/
54
- Gemini: <target>/.gemini/
55
- OpenCode: <target>/.opencode/
56
- Codex: <target>/.codex/
57
- Copilot: <target>/.copilot/ (or ~/.copilot/)
58
- GitHub: <target>/.github/
59
- ```
60
-
61
- For the detected runtime config directory (CONFIG_DIR), audit ALL of the following:
62
-
63
- **1.1 Core Files (CRITICAL)**
64
- - [ ] `CONFIG_DIR/pan-wizard-core/VERSION` exists — read and record version
65
- - [ ] `CONFIG_DIR/pan-wizard-core/CHANGELOG.md` exists
66
- - [ ] `CONFIG_DIR/pan-file-manifest.json` exists — parse and validate JSON
67
- - [ ] `CONFIG_DIR/package.json` exists — should contain `{"type":"commonjs"}`
68
-
69
- **1.2 Core Modules**
70
- - [ ] `CONFIG_DIR/pan-wizard-core/bin/pan-tools.cjs` exists (CLI dispatcher)
71
- - [ ] `CONFIG_DIR/pan-wizard-core/bin/lib/` directory exists
72
- - Every `bin/lib/*.cjs` file listed in `pan-file-manifest.json` exists on disk (the manifest is the authoritative expected set — never hardcode a module count)
73
-
74
- **1.3 Workflows, Templates, References**
75
- - [ ] `CONFIG_DIR/pan-wizard-core/workflows/` — non-empty, every manifest-listed workflow present
76
- - [ ] `CONFIG_DIR/pan-wizard-core/templates/` — non-empty, every manifest-listed template present
77
- - [ ] `CONFIG_DIR/pan-wizard-core/references/` — non-empty, every manifest-listed reference present
78
-
79
- **1.4 Commands**
80
- - For Claude/Gemini: `CONFIG_DIR/commands/pan/` — every manifest-listed command `.md` present
81
- - For OpenCode: `CONFIG_DIR/command/` — every manifest-listed `pan-*.md` present
82
- - For Codex/Copilot: `CONFIG_DIR/skills/pan-*/SKILL.md` — every manifest-listed skill directory present
83
-
84
- **1.5 Agents**
85
- - [ ] `CONFIG_DIR/agents/` — every manifest-listed agent file present
86
- - Verify key agents exist: pan-planner, pan-executor, pan-verifier, pan-debugger
87
-
88
- **1.6 Hooks**
89
- - [ ] `CONFIG_DIR/hooks/pan-statusline.js` exists
90
- - [ ] `CONFIG_DIR/hooks/pan-check-update.js` exists
91
- - [ ] `CONFIG_DIR/hooks/pan-context-monitor.js` exists
92
-
93
- **1.7 Settings/Config**
94
- - [ ] Settings file exists (settings.json / opencode.json / config.json)
95
- - [ ] Hooks are registered in settings (SessionStart, PostToolUse, statusLine)
96
- - [ ] Hook commands point to existing files
97
-
98
- **1.8 Manifest Integrity**
99
- - Read `pan-file-manifest.json`
100
- - For each file in the manifest, verify it exists on disk
101
- - Flag any MISSING files (manifest says exists, disk says no)
102
- - Flag any MODIFIED files (hash mismatch) — these are user customizations, not errors
103
- - Flag any ORPHANED files (on disk but not in manifest)
104
-
105
- Record all findings with severity: CRITICAL (missing core), WARNING (missing optional), INFO (modifications).
106
- </step>
107
-
108
- <step name="project_audit">
109
- **Phase 2 — Project Artifacts Audit**
110
-
111
- Check `.planning/` directory in the target:
112
-
113
- **2.1 Core Planning Files**
114
- - [ ] `.planning/config.json` — exists, valid JSON, has required keys (mode, depth, model_profile, workflow)
115
- - [ ] `.planning/project.md` — exists, has "What This Is", "Core Value", "Requirements" sections
116
- - [ ] `.planning/state.md` — exists, has "Current Position", "Performance Metrics" sections
117
- - [ ] `.planning/roadmap.md` — exists, has phase table
118
- - [ ] `.planning/requirements.md` — exists if project used requirements tracking
119
-
120
- **2.2 Phase Directories**
121
- - Scan for `phase_*` or `*-*` numbered directories
122
- - For each phase directory:
123
- - [ ] PLAN.md exists (phase summary)
124
- - [ ] At least one plan_*.md file exists
125
- - [ ] verification.md exists (phase was verified)
126
- - Count: total phases, phases with plans, phases verified, phases with gaps
127
-
128
- **2.3 Research Artifacts** (if brownfield/research was enabled)
129
- - [ ] `.planning/research/` directory exists
130
- - Check for stack.md, features.md, architecture.md, pitfalls.md
131
- - [ ] `.planning/codebase/` directory exists (brownfield)
132
-
133
- **2.4 State Consistency**
134
- - Parse state.md "Current Position" — extract phase number
135
- - Count actual phase directories — do they match?
136
- - Check roadmap.md phase count vs actual directories
137
- - Verify no orphaned .continue-here-*.md files (paused but not resumed)
138
-
139
- **2.5 Config Sanity**
140
- - Validate config.json values are within expected ranges
141
- - mode: "yolo" | "interactive"
142
- - depth: "quick" | "standard" | "comprehensive"
143
- - model_profile: "quality" | "balanced" | "budget"
144
- - workflow agents: all boolean
145
- </step>
146
-
147
- <step name="workflow_quality_audit">
148
- **Phase 3 — Workflow Execution Quality**
149
-
150
- Assess how well the project workflow was followed:
151
-
152
- **3.1 Planning Quality**
153
- For each phase with a PLAN.md:
154
- - Does it have clear objectives?
155
- - Does it reference requirements?
156
- - Are plans sequential with dependencies noted?
157
- - Grade: Complete / Partial / Stub
158
-
159
- **3.2 Verification Coverage**
160
- - Count phases with verification.md vs total phases
161
- - Check if verifications have pass/fail outcomes
162
- - Flag phases that were executed but never verified
163
-
164
- **3.3 Commit History** (if git repo)
165
- - Check if `.planning/` is tracked in git (config.json commit_docs)
166
- - Look for atomic commit patterns (one commit per plan)
167
- - Check for PAN-style commit messages
168
-
169
- **3.4 Session Continuity**
170
- - Check for .continue-here-*.md files (indicates paused sessions)
171
- - Check state.md session logs for gaps
172
- - Look for evidence of context loss (repeated work, contradictory decisions)
173
-
174
- **3.5 Todo Management**
175
- - Check `.planning/todos/` directory
176
- - Count pending vs completed
177
- - Flag stale todos (captured but never addressed)
178
- </step>
179
-
180
- <step name="report">
181
- **Phase 4 — Generate Audit Report**
182
-
183
- Format findings as a structured report:
184
-
185
- ```
186
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
187
- PAN Deployment Audit
188
- Target: <target-directory>
189
- Date: <YYYY-MM-DD>
190
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
191
-
192
- ## Summary
193
-
194
- | Category | Status | Score |
195
- |------------------------|----------|-------|
196
- | Installation Integrity | ✓/⚠/✗ | N/N |
197
- | Project Artifacts | ✓/⚠/✗ | N/N |
198
- | Workflow Quality | ✓/⚠/✗ | N/N |
199
- | Overall | HEALTHY / DEGRADED / BROKEN | N% |
200
-
201
- Runtime: <detected runtime>
202
- PAN Version: <version from VERSION file>
203
- Phases: <completed>/<total>
204
- Verification Coverage: <N>%
205
-
206
- ## Installation Integrity
207
-
208
- ### Critical Issues
209
- - [I-C01] <description> — <fix>
210
-
211
- ### Warnings
212
- - [I-W01] <description> — <suggestion>
213
-
214
- ### Info
215
- - [I-I01] <description>
216
-
217
- ### Modified Files (User Customizations)
218
- - <file> — hash mismatch (expected: abc..., actual: def...)
219
-
220
- ## Project Artifacts
221
-
222
- ### Critical Issues
223
- - [P-C01] <description> — <fix>
224
-
225
- ### Warnings
226
- - [P-W01] <description> — <suggestion>
227
-
228
- ### Phase Health
229
- | Phase | PLAN.md | Plans | Verified | Status |
230
- |-------|---------|-------|----------|--------|
231
- | 01 | ✓ | 3 | ✓ | Complete |
232
- | 02 | ✓ | 5 | ✗ | Unverified |
233
-
234
- ## Workflow Quality
235
-
236
- ### Observations
237
- - Planning quality: <grade>
238
- - Verification coverage: <N>%
239
- - Commit discipline: <grade>
240
- - Session continuity: <grade>
241
-
242
- ### Recommendations
243
- 1. <actionable recommendation>
244
- 2. <actionable recommendation>
245
- ```
246
-
247
- If `--repair` flag was provided, attempt auto-fixes for repairable issues:
248
- - Regenerate missing settings.json with default hook config
249
- - Create missing .planning/config.json with defaults
250
- - Remove orphaned .continue-here-*.md files
251
-
252
- Report repairs performed.
253
- </step>
254
-
255
- <step name="enhancements">
256
- **Phase 5 — Enhancement Spec Generation** (only if `--enhancements` flag)
257
-
258
- Based on audit findings, generate a featureAI-format enhancement spec at `docs/specs/deployment_audit_findings_featureai.md` in the PAN SOURCE repository (NOT the target directory).
259
-
260
- The spec MUST follow this exact format to be consumable by superplan.md:
261
-
262
- ```markdown
263
- # [Enhancement Title] — Feature Specification
264
-
265
- **Generated:** <YYYY-MM-DD>
266
- **Version:** 1.0
267
- **Status:** Proposed
268
- **Source:** Deployment audit of <target-directory>
269
-
270
- ---
271
-
272
- ## Problem Statement
273
-
274
- [Describe the problems discovered during the audit. What is broken, missing, or suboptimal in PAN Wizard based on real-world deployment evidence?]
275
-
276
- ## Demand Evidence
277
-
278
- | Evidence Type | Source | Finding |
279
- |---|---|---|
280
- | Deployment audit | <target-dir> | <specific finding> |
281
- | ... | ... | ... |
282
-
283
- ## Success Criteria
284
-
285
- ```
286
- SC-1: <measurable criterion>
287
- SC-2: <measurable criterion>
288
- ```
289
-
290
- ## Design
291
-
292
- [Proposed changes to PAN Wizard to address the findings]
293
-
294
- ### Architecture
295
-
296
- [How the fix/enhancement integrates with existing PAN architecture]
297
-
298
- ## Feature Ladder
299
-
300
- | Version | Scope | Value | Effort |
301
- |---|---|---|---|
302
- | **v0 (MVP)** | <scope> | <value> | <effort> |
303
- | **v1** | <scope> | <value> | <effort> |
304
-
305
- ## Implementation Tasks
306
-
307
- | # | ID | Title | Files | Effort | Pts | Priority |
308
- |---|---|---|---|---|---|---|
309
- | 1 | A.1 | <task> | <files> | S/M/L | N | P1-P4 |
310
-
311
- ### Dependency Graph
312
-
313
- ```
314
- A.1 ──> A.2 ──> A.3
315
- ```
316
-
317
- ## Test Plan
318
-
319
- | Level | Count | What It Catches |
320
- |---|---|---|
321
- | Unit | N+ | <description> |
322
- | Integration | N+ | <description> |
323
-
324
- ## Risk Register
325
-
326
- | Risk | Probability | Impact | Mitigation |
327
- |---|---|---|---|
328
- | <risk> | Low/Med/High | Low/Med/High | <mitigation> |
329
-
330
- ---
331
-
332
- *Generated by /pan:audit-deployment — <YYYY-MM-DD>*
333
- ```
334
-
335
- Group findings into logical enhancement categories:
336
- 1. **Installer gaps** — Missing files, broken hooks, manifest issues
337
- 2. **Workflow gaps** — Missing verification, planning quality
338
- 3. **Template gaps** — Templates that don't match real-world needs
339
- 4. **Documentation gaps** — Unclear processes discovered during audit
340
- 5. **Tooling gaps** — Features PAN should have but doesn't
341
-
342
- For each category with findings, generate a separate featureAI spec OR consolidate into one spec if findings are cohesive.
343
-
344
- Ask the user before writing specs:
345
- > The audit found N enhancement opportunities across M categories. Should I generate featureAI specs for superplan.md to plan development? [Yes/No]
346
- </step>
347
-
348
- <step name="final_summary">
349
- **Final Summary**
350
-
351
- Display a concise summary:
352
-
353
- ```
354
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
355
- Audit Complete
356
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
357
-
358
- Score: N% (HEALTHY / DEGRADED / BROKEN)
359
- Critical: N | Warnings: N | Info: N
360
-
361
- Installation: <status>
362
- Project: <status>
363
- Workflow: <status>
364
-
365
- Enhancements drafted: N specs → docs/specs/
366
- ```
367
-
368
- If enhancements were generated:
369
- > Enhancement specs written. Run superplan.md or /pan:milestone-new to plan development work.
370
-
371
- If repairs were performed:
372
- > N issues auto-repaired. Re-run /pan:audit-deployment to verify.
373
- </step>
374
-
375
- </process>
376
-
377
- <constraints>
378
- - NEVER modify the target directory's .planning/ content unless --repair is explicitly passed
379
- - NEVER modify the target directory's PAN installation files (read-only audit)
380
- - Enhancement specs are written to the PAN SOURCE repo docs/specs/, NOT the target directory
381
- - If the target directory IS the PAN source repo, refuse with: "Cannot audit the PAN source repository. Use a separate deployment directory."
382
- - All file reads are defensive — missing files are findings, not crashes
383
- - Do not expose file hashes, absolute paths, or credentials in the report
384
- </constraints>
1
+ ---
2
+ name: pan:audit-deployment
3
+ group: System
4
+ description: Audit a PAN Wizard deployment — verify installation integrity, project health, and draft enhancement specs
5
+ argument-hint: <target-directory> [--enhancements] [--repair]
6
+ allowed-tools:
7
+ - Read
8
+ - Bash
9
+ - Write
10
+ - Glob
11
+ - Grep
12
+ - AskUserQuestion
13
+ ---
14
+ <objective>
15
+ Audit a directory where PAN Wizard was installed and a project was run. Verify installation integrity, validate project artifacts, assess workflow execution quality, and optionally produce a featureAI-format enhancement spec that superplan.md can consume for development planning.
16
+ </objective>
17
+
18
+ <execution_context>
19
+ This command operates on a TARGET directory (not the PAN source repo). The target must be provided as the first argument.
20
+ </execution_context>
21
+
22
+ <process>
23
+
24
+ <step name="parse_args">
25
+ **Parse arguments:**
26
+
27
+ Extract target directory path from the first argument. It is REQUIRED.
28
+
29
+ ```
30
+ TARGET_DIR = first positional argument
31
+ ENHANCEMENTS_FLAG = "--enhancements" present?
32
+ REPAIR_FLAG = "--repair" present?
33
+ ```
34
+
35
+ If no target directory is provided, ask the user:
36
+ > Which directory should I audit? Provide the full path to the folder where PAN Wizard was installed and a project was run.
37
+
38
+ Validate the directory exists before proceeding.
39
+ </step>
40
+
41
+ <investigate_before_judging>
42
+ Never report a file as missing, broken, or misconfigured without reading it first.
43
+ For every audit check: read the actual file, verify its contents, then state the finding with evidence.
44
+ Do not speculate about file contents based on filenames alone.
45
+ </investigate_before_judging>
46
+
47
+ <step name="installation_audit">
48
+ **Phase 1 — Installation Integrity Audit**
49
+
50
+ Check the PAN Wizard installation artifacts in the target directory. Determine which runtime was used (Claude, Gemini, OpenCode, Codex, Copilot) by checking for config directories:
51
+
52
+ ```
53
+ Claude: <target>/.claude/
54
+ Gemini: <target>/.gemini/
55
+ OpenCode: <target>/.opencode/
56
+ Codex: <target>/.codex/
57
+ Copilot: <target>/.copilot/ (or ~/.copilot/)
58
+ GitHub: <target>/.github/
59
+ ```
60
+
61
+ For the detected runtime config directory (CONFIG_DIR), audit ALL of the following:
62
+
63
+ **1.1 Core Files (CRITICAL)**
64
+ - [ ] `CONFIG_DIR/pan-wizard-core/VERSION` exists — read and record version
65
+ - [ ] `CONFIG_DIR/pan-wizard-core/CHANGELOG.md` exists
66
+ - [ ] `CONFIG_DIR/pan-file-manifest.json` exists — parse and validate JSON
67
+ - [ ] `CONFIG_DIR/package.json` exists — should contain `{"type":"commonjs"}`
68
+
69
+ **1.2 Core Modules**
70
+ - [ ] `CONFIG_DIR/pan-wizard-core/bin/pan-tools.cjs` exists (CLI dispatcher)
71
+ - [ ] `CONFIG_DIR/pan-wizard-core/bin/lib/` directory exists
72
+ - Every `bin/lib/*.cjs` file listed in `pan-file-manifest.json` exists on disk (the manifest is the authoritative expected set — never hardcode a module count)
73
+
74
+ **1.3 Workflows, Templates, References**
75
+ - [ ] `CONFIG_DIR/pan-wizard-core/workflows/` — non-empty, every manifest-listed workflow present
76
+ - [ ] `CONFIG_DIR/pan-wizard-core/templates/` — non-empty, every manifest-listed template present
77
+ - [ ] `CONFIG_DIR/pan-wizard-core/references/` — non-empty, every manifest-listed reference present
78
+
79
+ **1.4 Commands**
80
+ - For Claude/Gemini: `CONFIG_DIR/commands/pan/` — every manifest-listed command `.md` present
81
+ - For OpenCode: `CONFIG_DIR/command/` — every manifest-listed `pan-*.md` present
82
+ - For Codex/Copilot: `CONFIG_DIR/skills/pan-*/SKILL.md` — every manifest-listed skill directory present
83
+
84
+ **1.5 Agents**
85
+ - [ ] `CONFIG_DIR/agents/` — every manifest-listed agent file present
86
+ - Verify key agents exist: pan-planner, pan-executor, pan-verifier, pan-debugger
87
+
88
+ **1.6 Hooks**
89
+ - [ ] `CONFIG_DIR/hooks/pan-statusline.js` exists
90
+ - [ ] `CONFIG_DIR/hooks/pan-check-update.js` exists
91
+ - [ ] `CONFIG_DIR/hooks/pan-context-monitor.js` exists
92
+
93
+ **1.7 Settings/Config**
94
+ - [ ] Settings file exists (settings.json / opencode.json / config.json)
95
+ - [ ] Hooks are registered in settings (SessionStart, PostToolUse, statusLine)
96
+ - [ ] Hook commands point to existing files
97
+
98
+ **1.8 Manifest Integrity**
99
+ - Read `pan-file-manifest.json`
100
+ - For each file in the manifest, verify it exists on disk
101
+ - Flag any MISSING files (manifest says exists, disk says no)
102
+ - Flag any MODIFIED files (hash mismatch) — these are user customizations, not errors
103
+ - Flag any ORPHANED files (on disk but not in manifest)
104
+
105
+ Record all findings with severity: CRITICAL (missing core), WARNING (missing optional), INFO (modifications).
106
+ </step>
107
+
108
+ <step name="project_audit">
109
+ **Phase 2 — Project Artifacts Audit**
110
+
111
+ Check `.planning/` directory in the target:
112
+
113
+ **2.1 Core Planning Files**
114
+ - [ ] `.planning/config.json` — exists, valid JSON, has required keys (mode, depth, model_profile, workflow)
115
+ - [ ] `.planning/project.md` — exists, has "What This Is", "Core Value", "Requirements" sections
116
+ - [ ] `.planning/state.md` — exists, has "Current Position", "Performance Metrics" sections
117
+ - [ ] `.planning/roadmap.md` — exists, has phase table
118
+ - [ ] `.planning/requirements.md` — exists if project used requirements tracking
119
+
120
+ **2.2 Phase Directories**
121
+ - Scan for `phase_*` or `*-*` numbered directories
122
+ - For each phase directory:
123
+ - [ ] PLAN.md exists (phase summary)
124
+ - [ ] At least one plan_*.md file exists
125
+ - [ ] verification.md exists (phase was verified)
126
+ - Count: total phases, phases with plans, phases verified, phases with gaps
127
+
128
+ **2.3 Research Artifacts** (if brownfield/research was enabled)
129
+ - [ ] `.planning/research/` directory exists
130
+ - Check for stack.md, features.md, architecture.md, pitfalls.md
131
+ - [ ] `.planning/codebase/` directory exists (brownfield)
132
+
133
+ **2.4 State Consistency**
134
+ - Parse state.md "Current Position" — extract phase number
135
+ - Count actual phase directories — do they match?
136
+ - Check roadmap.md phase count vs actual directories
137
+ - Verify no orphaned .continue-here-*.md files (paused but not resumed)
138
+
139
+ **2.5 Config Sanity**
140
+ - Validate config.json values are within expected ranges
141
+ - mode: "yolo" | "interactive"
142
+ - depth: "quick" | "standard" | "comprehensive"
143
+ - model_profile: "quality" | "balanced" | "budget"
144
+ - workflow agents: all boolean
145
+ </step>
146
+
147
+ <step name="workflow_quality_audit">
148
+ **Phase 3 — Workflow Execution Quality**
149
+
150
+ Assess how well the project workflow was followed:
151
+
152
+ **3.1 Planning Quality**
153
+ For each phase with a PLAN.md:
154
+ - Does it have clear objectives?
155
+ - Does it reference requirements?
156
+ - Are plans sequential with dependencies noted?
157
+ - Grade: Complete / Partial / Stub
158
+
159
+ **3.2 Verification Coverage**
160
+ - Count phases with verification.md vs total phases
161
+ - Check if verifications have pass/fail outcomes
162
+ - Flag phases that were executed but never verified
163
+
164
+ **3.3 Commit History** (if git repo)
165
+ - Check if `.planning/` is tracked in git (config.json commit_docs)
166
+ - Look for atomic commit patterns (one commit per plan)
167
+ - Check for PAN-style commit messages
168
+
169
+ **3.4 Session Continuity**
170
+ - Check for .continue-here-*.md files (indicates paused sessions)
171
+ - Check state.md session logs for gaps
172
+ - Look for evidence of context loss (repeated work, contradictory decisions)
173
+
174
+ **3.5 Todo Management**
175
+ - Check `.planning/todos/` directory
176
+ - Count pending vs completed
177
+ - Flag stale todos (captured but never addressed)
178
+ </step>
179
+
180
+ <step name="report">
181
+ **Phase 4 — Generate Audit Report**
182
+
183
+ Format findings as a structured report:
184
+
185
+ ```
186
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
187
+ PAN Deployment Audit
188
+ Target: <target-directory>
189
+ Date: <YYYY-MM-DD>
190
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
191
+
192
+ ## Summary
193
+
194
+ | Category | Status | Score |
195
+ |------------------------|----------|-------|
196
+ | Installation Integrity | ✓/⚠/✗ | N/N |
197
+ | Project Artifacts | ✓/⚠/✗ | N/N |
198
+ | Workflow Quality | ✓/⚠/✗ | N/N |
199
+ | Overall | HEALTHY / DEGRADED / BROKEN | N% |
200
+
201
+ Runtime: <detected runtime>
202
+ PAN Version: <version from VERSION file>
203
+ Phases: <completed>/<total>
204
+ Verification Coverage: <N>%
205
+
206
+ ## Installation Integrity
207
+
208
+ ### Critical Issues
209
+ - [I-C01] <description> — <fix>
210
+
211
+ ### Warnings
212
+ - [I-W01] <description> — <suggestion>
213
+
214
+ ### Info
215
+ - [I-I01] <description>
216
+
217
+ ### Modified Files (User Customizations)
218
+ - <file> — hash mismatch (expected: abc..., actual: def...)
219
+
220
+ ## Project Artifacts
221
+
222
+ ### Critical Issues
223
+ - [P-C01] <description> — <fix>
224
+
225
+ ### Warnings
226
+ - [P-W01] <description> — <suggestion>
227
+
228
+ ### Phase Health
229
+ | Phase | PLAN.md | Plans | Verified | Status |
230
+ |-------|---------|-------|----------|--------|
231
+ | 01 | ✓ | 3 | ✓ | Complete |
232
+ | 02 | ✓ | 5 | ✗ | Unverified |
233
+
234
+ ## Workflow Quality
235
+
236
+ ### Observations
237
+ - Planning quality: <grade>
238
+ - Verification coverage: <N>%
239
+ - Commit discipline: <grade>
240
+ - Session continuity: <grade>
241
+
242
+ ### Recommendations
243
+ 1. <actionable recommendation>
244
+ 2. <actionable recommendation>
245
+ ```
246
+
247
+ If `--repair` flag was provided, attempt auto-fixes for repairable issues:
248
+ - Regenerate missing settings.json with default hook config
249
+ - Create missing .planning/config.json with defaults
250
+ - Remove orphaned .continue-here-*.md files
251
+
252
+ Report repairs performed.
253
+ </step>
254
+
255
+ <step name="enhancements">
256
+ **Phase 5 — Enhancement Spec Generation** (only if `--enhancements` flag)
257
+
258
+ Based on audit findings, generate a featureAI-format enhancement spec at `docs/specs/deployment_audit_findings_featureai.md` in the PAN SOURCE repository (NOT the target directory).
259
+
260
+ The spec MUST follow this exact format to be consumable by superplan.md:
261
+
262
+ ```markdown
263
+ # [Enhancement Title] — Feature Specification
264
+
265
+ **Generated:** <YYYY-MM-DD>
266
+ **Version:** 1.0
267
+ **Status:** Proposed
268
+ **Source:** Deployment audit of <target-directory>
269
+
270
+ ---
271
+
272
+ ## Problem Statement
273
+
274
+ [Describe the problems discovered during the audit. What is broken, missing, or suboptimal in PAN Wizard based on real-world deployment evidence?]
275
+
276
+ ## Demand Evidence
277
+
278
+ | Evidence Type | Source | Finding |
279
+ |---|---|---|
280
+ | Deployment audit | <target-dir> | <specific finding> |
281
+ | ... | ... | ... |
282
+
283
+ ## Success Criteria
284
+
285
+ ```
286
+ SC-1: <measurable criterion>
287
+ SC-2: <measurable criterion>
288
+ ```
289
+
290
+ ## Design
291
+
292
+ [Proposed changes to PAN Wizard to address the findings]
293
+
294
+ ### Architecture
295
+
296
+ [How the fix/enhancement integrates with existing PAN architecture]
297
+
298
+ ## Feature Ladder
299
+
300
+ | Version | Scope | Value | Effort |
301
+ |---|---|---|---|
302
+ | **v0 (MVP)** | <scope> | <value> | <effort> |
303
+ | **v1** | <scope> | <value> | <effort> |
304
+
305
+ ## Implementation Tasks
306
+
307
+ | # | ID | Title | Files | Effort | Pts | Priority |
308
+ |---|---|---|---|---|---|---|
309
+ | 1 | A.1 | <task> | <files> | S/M/L | N | P1-P4 |
310
+
311
+ ### Dependency Graph
312
+
313
+ ```
314
+ A.1 ──> A.2 ──> A.3
315
+ ```
316
+
317
+ ## Test Plan
318
+
319
+ | Level | Count | What It Catches |
320
+ |---|---|---|
321
+ | Unit | N+ | <description> |
322
+ | Integration | N+ | <description> |
323
+
324
+ ## Risk Register
325
+
326
+ | Risk | Probability | Impact | Mitigation |
327
+ |---|---|---|---|
328
+ | <risk> | Low/Med/High | Low/Med/High | <mitigation> |
329
+
330
+ ---
331
+
332
+ *Generated by /pan:audit-deployment — <YYYY-MM-DD>*
333
+ ```
334
+
335
+ Group findings into logical enhancement categories:
336
+ 1. **Installer gaps** — Missing files, broken hooks, manifest issues
337
+ 2. **Workflow gaps** — Missing verification, planning quality
338
+ 3. **Template gaps** — Templates that don't match real-world needs
339
+ 4. **Documentation gaps** — Unclear processes discovered during audit
340
+ 5. **Tooling gaps** — Features PAN should have but doesn't
341
+
342
+ For each category with findings, generate a separate featureAI spec OR consolidate into one spec if findings are cohesive.
343
+
344
+ Ask the user before writing specs:
345
+ > The audit found N enhancement opportunities across M categories. Should I generate featureAI specs for superplan.md to plan development? [Yes/No]
346
+ </step>
347
+
348
+ <step name="final_summary">
349
+ **Final Summary**
350
+
351
+ Display a concise summary:
352
+
353
+ ```
354
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
355
+ Audit Complete
356
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
357
+
358
+ Score: N% (HEALTHY / DEGRADED / BROKEN)
359
+ Critical: N | Warnings: N | Info: N
360
+
361
+ Installation: <status>
362
+ Project: <status>
363
+ Workflow: <status>
364
+
365
+ Enhancements drafted: N specs → docs/specs/
366
+ ```
367
+
368
+ If enhancements were generated:
369
+ > Enhancement specs written. Run superplan.md or /pan:milestone-new to plan development work.
370
+
371
+ If repairs were performed:
372
+ > N issues auto-repaired. Re-run /pan:audit-deployment to verify.
373
+ </step>
374
+
375
+ </process>
376
+
377
+ <constraints>
378
+ - NEVER modify the target directory's .planning/ content unless --repair is explicitly passed
379
+ - NEVER modify the target directory's PAN installation files (read-only audit)
380
+ - Enhancement specs are written to the PAN SOURCE repo docs/specs/, NOT the target directory
381
+ - If the target directory IS the PAN source repo, refuse with: "Cannot audit the PAN source repository. Use a separate deployment directory."
382
+ - All file reads are defensive — missing files are findings, not crashes
383
+ - Do not expose file hashes, absolute paths, or credentials in the report
384
+ </constraints>