pan-wizard 3.35.0 → 3.37.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 (339) hide show
  1. package/CHANGELOG.md +3645 -0
  2. package/README.md +46 -52
  3. package/agents/pan-conductor.md +2 -3
  4. package/agents/pan-counterfactual.md +1 -2
  5. package/agents/pan-debugger.md +14 -3
  6. package/agents/pan-design-checker.md +1 -2
  7. package/agents/pan-designer.md +2 -3
  8. package/agents/pan-document_code.md +1 -2
  9. package/agents/pan-executor.md +25 -0
  10. package/agents/pan-hardener.md +4 -3
  11. package/agents/pan-integration-checker.md +1 -2
  12. package/agents/pan-knowledge.md +1 -2
  13. package/agents/pan-meta-reviewer.md +3 -3
  14. package/agents/pan-optimizer.md +4 -4
  15. package/agents/pan-phase-researcher.md +80 -475
  16. package/agents/pan-plan-checker.md +40 -3
  17. package/agents/pan-planner.md +21 -7
  18. package/agents/pan-previewer.md +3 -2
  19. package/agents/pan-project-researcher.md +72 -493
  20. package/agents/pan-release.md +1 -1
  21. package/agents/pan-reviewer.md +14 -3
  22. package/agents/pan-roadmapper.md +12 -7
  23. package/agents/pan-verifier.md +9 -4
  24. package/bin/install-lib.cjs +134 -14
  25. package/bin/install.js +59 -12
  26. package/commands/pan/army.md +1 -1
  27. package/commands/pan/autodev.md +76 -0
  28. package/commands/pan/cost.md +21 -1
  29. package/commands/pan/exec-phase.md +3 -4
  30. package/commands/pan/focus-auto.md +14 -7
  31. package/commands/pan/focus-design.md +4 -5
  32. package/commands/pan/focus-docs.md +24 -0
  33. package/commands/pan/learn.md +13 -6
  34. package/commands/pan/milestone-audit.md +8 -1
  35. package/commands/pan/milestone-done.md +10 -5
  36. package/commands/pan/milestone-new.md +2 -2
  37. package/commands/pan/new-project.md +15 -12
  38. package/commands/pan/plan-phase.md +15 -9
  39. package/commands/pan/preview.md +1 -1
  40. package/commands/pan/quick.md +1 -1
  41. package/commands/pan/review-deep.md +11 -5
  42. package/commands/pan/settings.md +6 -0
  43. package/commands/pan/verify-phase.md +6 -2
  44. package/docs/AGENTS.md +917 -0
  45. package/docs/ARCHITECTURE.md +1054 -0
  46. package/docs/CLI-REFERENCE.md +4582 -0
  47. package/docs/COMPARISON.md +116 -0
  48. package/docs/DEVELOPMENT.md +490 -0
  49. package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
  50. package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
  51. package/docs/EXAMPLES.md +584 -0
  52. package/docs/FAQ.md +254 -0
  53. package/docs/FIELD-HARVEST-2026-07.md +88 -0
  54. package/docs/FIELD-REPORT-army-2026-06.md +121 -0
  55. package/docs/HOOKS.md +638 -0
  56. package/docs/IMPROVEMENT-TODO.md +246 -0
  57. package/docs/INTERNALS.md +485 -0
  58. package/docs/MIGRATION-v2-to-v3.md +258 -0
  59. package/docs/SECURITY-HARDENING.md +230 -0
  60. package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
  61. package/docs/SKILLS-FULL-TEXT.md +9685 -0
  62. package/docs/SKILLS-REFERENCE.md +1037 -0
  63. package/docs/TROUBLESHOOTING.md +1084 -0
  64. package/docs/USER-GUIDE.md +1437 -0
  65. package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
  66. package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
  67. package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
  68. package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
  69. package/docs/audits/OUTSTANDING-2026-08.md +275 -0
  70. package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
  71. package/docs/branding/README-brand-draft.md +119 -0
  72. package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
  73. package/docs/branding/handoff/README-brand-draft.md +119 -0
  74. package/docs/branding/handoff/image-prompts.md +46 -0
  75. package/docs/branding/image-prompts.md +46 -0
  76. package/docs/branding/nano-banana-prompts.txt +60 -0
  77. package/docs/context-monitor.md +13 -0
  78. package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
  79. package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
  80. package/docs/decisions/ADR-0003-smart-execution.md +84 -0
  81. package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
  82. package/docs/decisions/ADR-0005-command-naming.md +80 -0
  83. package/docs/decisions/ADR-0006-focus-commands.md +101 -0
  84. package/docs/decisions/ADR-0007-ship-v1.md +73 -0
  85. package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
  86. package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
  87. package/docs/decisions/ADR-0010-standards-integration.md +79 -0
  88. package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
  89. package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
  90. package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
  91. package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
  92. package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
  93. package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
  94. package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
  95. package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
  96. package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
  97. package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
  98. package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
  99. package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
  100. package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
  101. package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
  102. package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
  103. package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
  104. package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
  105. package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
  106. package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
  107. package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
  108. package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
  109. package/docs/decisions/ADR-0032-squad-model.md +64 -0
  110. package/docs/decisions/ADR-0033-army-campaign.md +40 -0
  111. package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
  112. package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
  113. package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
  114. package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
  115. package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
  116. package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
  117. package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
  118. package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
  119. package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
  120. package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
  121. package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
  122. package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
  123. package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
  124. package/docs/decisions/ADR-0047-pan-harness.md +76 -0
  125. package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
  126. package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
  127. package/docs/specs/ai_drift_prevention_featureai.md +286 -0
  128. package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
  129. package/docs/specs/command_naming_optimization_featureai.md +930 -0
  130. package/docs/specs/comp_analysis_markdown_v1.md +149 -0
  131. package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
  132. package/docs/specs/contributors_attribution_index_featureai.md +476 -0
  133. package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
  134. package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
  135. package/docs/specs/custom-skills-assessment.md +461 -0
  136. package/docs/specs/deployment_audit_findings_featureai.md +243 -0
  137. package/docs/specs/doc_code_link_graph_featureai.md +253 -0
  138. package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
  139. package/docs/specs/e2e_visual_testing_featureai.md +615 -0
  140. package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
  141. package/docs/specs/evidence-loop-plan.md +76 -0
  142. package/docs/specs/evidence_loop_featureai.md +497 -0
  143. package/docs/specs/focus-auto-optimize-category.md +449 -0
  144. package/docs/specs/focus-auto-optimize-superplan.md +188 -0
  145. package/docs/specs/focus_auto_runner_featureai.md +1102 -0
  146. package/docs/specs/focus_design_v2_featureai.md +197 -0
  147. package/docs/specs/focus_sync_v2_featureai.md +202 -0
  148. package/docs/specs/git_integration_overhaul_featureai.md +326 -0
  149. package/docs/specs/glm_zai_provider_featureai.md +200 -0
  150. package/docs/specs/googlecli_adoption_featureai.md +661 -0
  151. package/docs/specs/help_commands_rewrite_featureai.md +860 -0
  152. package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
  153. package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
  154. package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
  155. package/docs/specs/investigations/README.md +31 -0
  156. package/docs/specs/investigations/digests/2026-09-28.md +47 -0
  157. package/docs/specs/investigations/digests/2026-10-08.md +62 -0
  158. package/docs/specs/investigations/digests/2026-10-10.md +61 -0
  159. package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
  160. package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
  161. package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
  162. package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
  163. package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
  164. package/docs/specs/lifecycle_completeness_featureai.md +754 -0
  165. package/docs/specs/local-first-ci.md +42 -0
  166. package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
  167. package/docs/specs/market-delta-2026-09-superplan.md +310 -0
  168. package/docs/specs/market-ideas-2026-09.md +131 -0
  169. package/docs/specs/market-ideas-2026-10.md +428 -0
  170. package/docs/specs/market-ideas-ledger.md +177 -0
  171. package/docs/specs/memory-optimization-2026-10.md +285 -0
  172. package/docs/specs/multi-track-planning-roots.md +143 -0
  173. package/docs/specs/multi_model_routing_featureai.md +687 -0
  174. package/docs/specs/multi_model_routing_superplan.md +197 -0
  175. package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
  176. package/docs/specs/opus_47_extended_features_featureai.md +363 -0
  177. package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
  178. package/docs/specs/pan_focus_commands_featureai.md +2336 -0
  179. package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
  180. package/docs/specs/product-excellence-superplan.md +315 -0
  181. package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
  182. package/docs/specs/production_deployment_readiness_featureai.md +433 -0
  183. package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
  184. package/docs/specs/real_test_enforcement_featureai.md +213 -0
  185. package/docs/specs/reality-check-2026-09-superplan.md +362 -0
  186. package/docs/specs/right-sized-ceremony.md +74 -0
  187. package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
  188. package/docs/specs/self_improvement_loop_featureai.md +875 -0
  189. package/docs/specs/skill-aligned-decomposition.md +155 -0
  190. package/docs/specs/standards_integration_featureai.md +833 -0
  191. package/docs/specs/testing-system-redesign-2026-09.md +267 -0
  192. package/docs/specs/user_reality_testing_system_featureai.md +788 -0
  193. package/docs/specs/watch-triggers.json +22 -0
  194. package/docs/specs/workflow-integration-redesign.md +742 -0
  195. package/docs/specs/workflow_state_consistency_featureai.md +183 -0
  196. package/hooks/dist/pan-context-monitor.js +9 -2
  197. package/hooks/dist/pan-cost-logger.js +5 -0
  198. package/hooks/dist/pan-guard.js +28 -5
  199. package/hooks/dist/pan-stop-guard.js +9 -9
  200. package/hooks/dist/pan-trace-logger.js +5 -0
  201. package/package.json +10 -2
  202. package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
  203. package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
  204. package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
  205. package/pan-wizard-core/bin/lib/ci.cjs +143 -0
  206. package/pan-wizard-core/bin/lib/commands.cjs +1 -1
  207. package/pan-wizard-core/bin/lib/config.cjs +41 -5
  208. package/pan-wizard-core/bin/lib/constants.cjs +27 -1
  209. package/pan-wizard-core/bin/lib/core.cjs +31 -14
  210. package/pan-wizard-core/bin/lib/cost.cjs +160 -4
  211. package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
  212. package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
  213. package/pan-wizard-core/bin/lib/doc-lint.cjs +5 -3
  214. package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
  215. package/pan-wizard-core/bin/lib/findings.cjs +148 -9
  216. package/pan-wizard-core/bin/lib/focus.cjs +1 -1
  217. package/pan-wizard-core/bin/lib/git.cjs +1 -1
  218. package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
  219. package/pan-wizard-core/bin/lib/init.cjs +7 -2
  220. package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
  221. package/pan-wizard-core/bin/lib/merge.cjs +50 -0
  222. package/pan-wizard-core/bin/lib/mutate.cjs +268 -0
  223. package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
  224. package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
  225. package/pan-wizard-core/bin/lib/phase-gate.cjs +15 -9
  226. package/pan-wizard-core/bin/lib/phase-remove.cjs +91 -11
  227. package/pan-wizard-core/bin/lib/phase.cjs +85 -13
  228. package/pan-wizard-core/bin/lib/plan-lint.cjs +310 -0
  229. package/pan-wizard-core/bin/lib/preview.cjs +26 -4
  230. package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
  231. package/pan-wizard-core/bin/lib/research-lint.cjs +268 -0
  232. package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
  233. package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
  234. package/pan-wizard-core/bin/lib/roadmap.cjs +1 -0
  235. package/pan-wizard-core/bin/lib/runner.cjs +2 -16
  236. package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
  237. package/pan-wizard-core/bin/lib/squads.cjs +1 -1
  238. package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
  239. package/pan-wizard-core/bin/lib/test-gate.cjs +433 -0
  240. package/pan-wizard-core/bin/lib/uat.cjs +149 -0
  241. package/pan-wizard-core/bin/lib/usage.cjs +104 -0
  242. package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
  243. package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
  244. package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
  245. package/pan-wizard-core/bin/lib/verify-red.cjs +174 -0
  246. package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
  247. package/pan-wizard-core/bin/lib/verify-scope.cjs +143 -2
  248. package/pan-wizard-core/bin/lib/verify.cjs +86 -31
  249. package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
  250. package/pan-wizard-core/bin/pan-tools.cjs +257 -28
  251. package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
  252. package/pan-wizard-core/mcp/orchestrator.cjs +4 -1
  253. package/pan-wizard-core/references/continuation-format.md +3 -3
  254. package/pan-wizard-core/references/design-methodology.md +1 -1
  255. package/pan-wizard-core/references/guardrails.md +1 -1
  256. package/pan-wizard-core/references/handoff-decisions.md +1 -1
  257. package/pan-wizard-core/references/model-profiles.md +2 -3
  258. package/pan-wizard-core/references/questioning.md +24 -0
  259. package/pan-wizard-core/references/ui-brand.md +4 -6
  260. package/pan-wizard-core/references/verdict-contract.md +2 -1
  261. package/pan-wizard-core/templates/config.json +10 -2
  262. package/pan-wizard-core/templates/debug.md +1 -0
  263. package/pan-wizard-core/templates/design.md +5 -4
  264. package/pan-wizard-core/templates/discovery.md +2 -2
  265. package/pan-wizard-core/templates/phase-prompt.md +7 -0
  266. package/pan-wizard-core/templates/requirements.md +9 -0
  267. package/pan-wizard-core/templates/research.md +10 -0
  268. package/pan-wizard-core/templates/summary-complex.md +5 -1
  269. package/pan-wizard-core/templates/summary-minimal.md +4 -0
  270. package/pan-wizard-core/templates/summary-standard.md +5 -1
  271. package/pan-wizard-core/templates/summary.md +8 -1
  272. package/pan-wizard-core/workflows/add-phase.md +4 -6
  273. package/pan-wizard-core/workflows/assumptions.md +19 -1
  274. package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
  275. package/pan-wizard-core/workflows/discuss-phase.md +4 -2
  276. package/pan-wizard-core/workflows/exec-lean.md +69 -0
  277. package/pan-wizard-core/workflows/exec-phase.md +79 -15
  278. package/pan-wizard-core/workflows/execute-plan.md +3 -1
  279. package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
  280. package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
  281. package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
  282. package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
  283. package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
  284. package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
  285. package/pan-wizard-core/workflows/health.md +6 -0
  286. package/pan-wizard-core/workflows/help.md +114 -77
  287. package/pan-wizard-core/workflows/insert-phase.md +4 -6
  288. package/pan-wizard-core/workflows/learn.md +3 -3
  289. package/pan-wizard-core/workflows/milestone-audit.md +2 -2
  290. package/pan-wizard-core/workflows/milestone-new.md +38 -95
  291. package/pan-wizard-core/workflows/new-project.md +96 -258
  292. package/pan-wizard-core/workflows/optimize.md +107 -5
  293. package/pan-wizard-core/workflows/phase-tests.md +10 -0
  294. package/pan-wizard-core/workflows/plan-phase.md +106 -45
  295. package/pan-wizard-core/workflows/profile.md +50 -0
  296. package/pan-wizard-core/workflows/progress.md +10 -0
  297. package/pan-wizard-core/workflows/quick.md +34 -43
  298. package/pan-wizard-core/workflows/remove-phase.md +11 -1
  299. package/pan-wizard-core/workflows/research-phase.md +118 -40
  300. package/pan-wizard-core/workflows/resume-project.md +18 -2
  301. package/pan-wizard-core/workflows/settings.md +33 -19
  302. package/pan-wizard-core/workflows/todo-check.md +6 -2
  303. package/pan-wizard-core/workflows/transition.md +22 -4
  304. package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
  305. package/pan-wizard-core/workflows/update.md +1 -1
  306. package/pan-wizard-core/workflows/verify-phase.md +39 -46
  307. package/scripts/build-agent-plugin.js +35 -15
  308. package/scripts/build-help.cjs +106 -0
  309. package/scripts/build-plugin.js +10 -1
  310. package/scripts/deprecate-old-versions.js +70 -3
  311. package/scripts/generate-skills-docs.py +1 -1
  312. package/scripts/git-hooks/pre-push +27 -0
  313. package/scripts/install-git-hooks.js +7 -5
  314. package/scripts/install-pre-push.cjs +38 -0
  315. package/scripts/land.cjs +151 -0
  316. package/scripts/local-ci.cjs +501 -0
  317. package/scripts/local-schedule.cjs +277 -0
  318. package/scripts/mutation-probe.cjs +7 -80
  319. package/scripts/prompt-lint.cjs +32 -0
  320. package/scripts/prompt-rules.cjs +156 -0
  321. package/scripts/run-tests.cjs +7 -1
  322. package/scripts/test-quality-lint.cjs +3 -3
  323. package/scripts/test-surface.cjs +175 -6
  324. package/agents/pan-research-synthesizer.md +0 -246
  325. package/commands/pan/audit-deployment.md +0 -386
  326. package/commands/pan/dashboard.md +0 -22
  327. package/commands/pan/discord.md +0 -19
  328. package/commands/pan/mcp-bridge.md +0 -143
  329. package/commands/pan/milestone-cleanup.md +0 -19
  330. package/commands/pan/milestone-gaps.md +0 -35
  331. package/commands/pan/optimize.md +0 -115
  332. package/commands/pan/profile.md +0 -76
  333. package/commands/pan/research-phase.md +0 -189
  334. package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
  335. package/pan-wizard-core/templates/research-project/architecture.md +0 -204
  336. package/pan-wizard-core/templates/research-project/features.md +0 -147
  337. package/pan-wizard-core/templates/research-project/pitfalls.md +0 -200
  338. package/pan-wizard-core/templates/research-project/stack.md +0 -120
  339. package/pan-wizard-core/templates/research-project/summary.md +0 -170
@@ -0,0 +1,243 @@
1
+ # Deployment Integrity & Post-Install Validation — Feature Specification
2
+
3
+ **Generated:** 2026-03-09
4
+ **Version:** 1.0
5
+ **Status:** Proposed
6
+ **Source:** Deployment audit of d:\pantesting (PAN v2.8.0, Claude Code runtime)
7
+
8
+ ---
9
+
10
+ ## Problem Statement
11
+
12
+ A real-world deployment audit of PAN Wizard v2.8.0 revealed gaps in installation integrity tracking, post-install guidance, and self-validation tooling. Specifically:
13
+
14
+ 1. **Hook files are not tracked in the manifest.** The 3 hook scripts (`pan-check-update.js`, `pan-context-monitor.js`, `pan-statusline.js`) exist on disk but are absent from `pan-file-manifest.json`. This means user modifications to hooks are invisible during upgrades — `saveLocalPatches()` cannot detect or preserve them, and the update process silently overwrites customized hooks.
15
+
16
+ 2. **No post-install self-validation.** After installation the user gets "Done! Run /pan:new-project" but there is no programmatic way to verify the installation succeeded. If a file copy failed silently, anti-virus quarantined a `.cjs` file, or a partial install occurred, the user discovers it only when a command crashes at runtime.
17
+
18
+ 3. **No built-in deployment audit.** The `/pan:health` command validates `.planning/` state but has zero coverage of the installation itself — core modules, settings.json hook wiring, manifest integrity, and agent/command completeness are never checked. Users who modify PAN files, run partial upgrades, or experience filesystem issues have no diagnostic tool.
19
+
20
+ 4. **`audit-deployment` command has no backing workflow or CLI route.** The new command we created is prompt-only — it relies on the AI reading instructions and executing steps manually. Unlike `/pan:health` which calls `pan-tools.cjs validate health`, there is no `pan-tools.cjs validate deployment` route, making the audit non-deterministic and unrepeatable.
21
+
22
+ ## Demand Evidence
23
+
24
+ | Evidence Type | Source | Finding |
25
+ |---|---|---|
26
+ | Deployment audit | d:\pantesting | 3 hook files orphaned from manifest — untracked modifications |
27
+ | Deployment audit | d:\pantesting | Fresh install has no self-test mechanism |
28
+ | Code review | install-lib.cjs | `generateManifest()` skips `hooks/` directory entirely |
29
+ | Code review | pan-tools.cjs | `validate health` route exists but no `validate deployment` route |
30
+ | Code review | settings.json | Hook paths are hardcoded strings — no validation they resolve to real files |
31
+ | User workflow | Post-install | Users must manually verify installation by running commands and hoping they work |
32
+ | Upgrade flow | saveLocalPatches() | Hook modifications are silently lost on upgrade since they aren't in the manifest |
33
+
34
+ ## Success Criteria
35
+
36
+ ```
37
+ SC-1: All installed files including hooks are tracked in pan-file-manifest.json with SHA256 hashes
38
+ SC-2: `pan-tools.cjs validate deployment` returns structured JSON with pass/fail for every installation component
39
+ SC-3: Post-install automatically runs a lightweight self-check and reports issues before the "Done!" message
40
+ SC-4: Settings.json hook paths are validated against actual file existence during install and health checks
41
+ SC-5: No regression in existing 1622+ tests
42
+ SC-6: Works across all 5 runtimes (Claude, Gemini, OpenCode, Codex, Copilot)
43
+ SC-7: Audit results are deterministic and reproducible (CLI-driven, not prompt-dependent)
44
+ ```
45
+
46
+ ## Competitive Landscape
47
+
48
+ No competing tool (Aider, Cursor, Cline, Windsurf) has post-install self-validation or deployment auditing. This is brownfield territory.
49
+
50
+ | Tool | Install Validation | Manifest Tracking | Deployment Audit |
51
+ |---|---|---|---|
52
+ | **PAN Wizard** | None | Partial (no hooks) | None (prompt-only) |
53
+ | **Aider** | pip install + import check | None | None |
54
+ | **Cursor** | Extension marketplace | None | None |
55
+ | **Cline** | Extension marketplace | None | None |
56
+ | **Windsurf** | N/A (SaaS) | N/A | N/A |
57
+
58
+ ## Design
59
+
60
+ ### Architecture
61
+
62
+ ```
63
+ install.js (existing)
64
+ └─ NEW: runPostInstallValidation(configDir, runtime)
65
+ ├─ verifyAllManifestFiles(configDir)
66
+ ├─ verifySettingsHookPaths(configDir, runtime)
67
+ └─ output summary or warnings
68
+
69
+ pan-tools.cjs → 'validate' → 'deployment' case (NEW)
70
+ └─ verify.cjs: cmdValidateDeployment(cwd, raw, args)
71
+ ├─ loadManifest(configDir)
72
+ ├─ verifyAllHashes(configDir, manifest)
73
+ ├─ findOrphanedFiles(configDir, manifest)
74
+ ├─ verifySettingsIntegrity(configDir, runtime)
75
+ ├─ verifyAgentCompleteness(configDir)
76
+ ├─ verifyCommandCompleteness(configDir, runtime)
77
+ └─ output(result, raw, summary)
78
+
79
+ generateManifest() (existing, modified)
80
+ └─ CHANGE: Include hooks/ directory in file manifest
81
+ ```
82
+
83
+ ### Command Interface
84
+
85
+ ```
86
+ pan-tools.cjs validate deployment [--fix]
87
+
88
+ Output (JSON):
89
+ {
90
+ "status": "healthy" | "degraded" | "broken",
91
+ "version": "2.8.0",
92
+ "runtime": "claude",
93
+ "checks": {
94
+ "manifest_files": { "total": 157, "present": 157, "missing": 0 },
95
+ "hash_integrity": { "verified": 157, "modified": 0, "files": [] },
96
+ "orphaned_files": { "count": 0, "files": [] },
97
+ "hooks": { "registered": 3, "files_exist": 3, "paths_valid": true },
98
+ "agents": { "expected": 12, "found": 12 },
99
+ "commands": { "expected": 40, "found": 40 },
100
+ "core_modules": { "expected": 16, "found": 16 },
101
+ "workflows": { "min": 25, "found": 31 },
102
+ "templates": { "min": 20, "found": 27 },
103
+ "references": { "min": 10, "found": 13 }
104
+ },
105
+ "errors": [],
106
+ "warnings": [],
107
+ "fixable_count": 0,
108
+ "summary": "deployment: healthy — 157 files verified, 0 issues"
109
+ }
110
+ ```
111
+
112
+ ### Post-Install Self-Check
113
+
114
+ Added to `install.js` after the "Done!" message:
115
+
116
+ ```javascript
117
+ // Lightweight self-check (< 100ms)
118
+ const selfCheck = verifyInstallation(configDir, runtime);
119
+ if (selfCheck.errors.length > 0) {
120
+ console.log(`\n ⚠ ${selfCheck.errors.length} issue(s) detected:`);
121
+ selfCheck.errors.forEach(e => console.log(` • ${e}`));
122
+ console.log(`\n Run: node ${configDir}/pan-wizard-core/bin/pan-tools.cjs validate deployment`);
123
+ }
124
+ ```
125
+
126
+ ### Error Handling
127
+
128
+ | Condition | Behavior |
129
+ |---|---|
130
+ | No manifest file | Return "broken" with instruction to reinstall |
131
+ | Corrupt manifest JSON | Return "broken" with instruction to reinstall |
132
+ | Missing hook files | Return "degraded" with list + fix instructions |
133
+ | Modified PAN files | Return "healthy" with info about modifications |
134
+ | Wrong runtime detected | Try all runtimes, report whichever matches |
135
+
136
+ ## Feature Ladder
137
+
138
+ | Version | Scope | Value | Effort |
139
+ |---|---|---|---|
140
+ | **v0 (MVP)** | Include hooks in manifest + `validate deployment` CLI + post-install self-check | Deterministic deployment validation | S-M (14 pts) |
141
+ | **v1** | Settings.json deep validation + cross-runtime audit + `--fix` flag | Self-healing deployments | M (12 pts) |
142
+ | **v2** | Deployment health dashboard in statusline + scheduled re-validation hook | Continuous deployment health | M (10 pts) |
143
+
144
+ ## Implementation Tasks
145
+
146
+ | # | ID | Title | Files | Effort | Pts | Priority |
147
+ |---|---|---|---|---|---|---|
148
+ | 1 | A.1 | Include hooks in generateManifest | install-lib.cjs, install.js | XS | 1 | P1 |
149
+ | 2 | A.2 | cmdValidateDeployment function | pan-wizard-core/bin/lib/verify.cjs | M | 4 | P1 |
150
+ | 3 | A.3 | Route validate deployment in dispatcher | pan-wizard-core/bin/pan-tools.cjs | XS | 1 | P1 |
151
+ | 4 | A.4 | Post-install self-check in installer | bin/install.js | S | 2 | P1 |
152
+ | 5 | A.5 | Settings.json hook path validation | pan-wizard-core/bin/lib/verify.cjs | S | 2 | P2 |
153
+ | 6 | A.6 | Agent/command completeness checks | pan-wizard-core/bin/lib/verify.cjs | S | 2 | P2 |
154
+ | 7 | A.7 | Audit-deployment workflow (backing) | pan-wizard-core/workflows/audit-deployment.md | S | 2 | P2 |
155
+ | 8 | A.8 | Test suite (25+ tests) | tests/deployment-audit.test.cjs | M | 4 | P1 |
156
+ | 9 | A.9 | Cross-runtime audit support | pan-wizard-core/bin/lib/verify.cjs | M | 3 | P3 |
157
+ | 10 | A.10 | Documentation | README, USER-GUIDE, CLI-REFERENCE, CHANGELOG | S | 2 | P3 |
158
+
159
+ **Total: 23 points (v0+v1 MVP)**
160
+
161
+ ### Dependency Graph
162
+
163
+ ```
164
+ A.1 (Manifest hooks) ──> A.2 (Validate cmd) ──> A.3 (Dispatcher route)
165
+ │
166
+ ├──> A.5 (Settings validation)
167
+ ├──> A.6 (Completeness checks)
168
+ └──> A.8 (Tests)
169
+
170
+ A.4 (Post-install check) ── standalone, uses A.2 internally
171
+
172
+ A.7 (Workflow) ── standalone, wraps A.3
173
+
174
+ A.9 (Cross-runtime) ──> depends on A.2 + A.6
175
+ A.10 (Docs) ──> after A.2, A.3, A.4
176
+ ```
177
+
178
+ ## Test Plan
179
+
180
+ ### Test Pyramid
181
+
182
+ | Level | Count | What It Catches |
183
+ |---|---|---|
184
+ | Unit | 12+ | Manifest generation with hooks, hash verification, orphan detection, settings validation |
185
+ | Integration | 8+ | Full validate deployment JSON output, --fix flag, missing files, corrupt manifest |
186
+ | E2E | 5+ | Real install → validate → modify → re-validate → fix cycle |
187
+
188
+ ### Key Test Cases
189
+
190
+ 1. generateManifest includes hooks/ directory files
191
+ 2. generateManifest hook hashes match actual file content
192
+ 3. cmdValidateDeployment: clean install → "healthy"
193
+ 4. cmdValidateDeployment: missing core module → "broken"
194
+ 5. cmdValidateDeployment: missing hook → "degraded"
195
+ 6. cmdValidateDeployment: hash mismatch → reported as "modified"
196
+ 7. cmdValidateDeployment: orphaned files detected
197
+ 8. cmdValidateDeployment: corrupt manifest → "broken"
198
+ 9. cmdValidateDeployment: no manifest → "broken" with reinstall instruction
199
+ 10. cmdValidateDeployment: settings.json missing hook entry → warning
200
+ 11. cmdValidateDeployment: settings.json hook path points to nonexistent file → error
201
+ 12. cmdValidateDeployment: agent count < 12 → warning
202
+ 13. cmdValidateDeployment: command count < expected → warning
203
+ 14. Post-install self-check: clean install → no warnings
204
+ 15. Post-install self-check: simulated missing file → warning printed
205
+ 16. --fix flag: regenerates missing settings.json
206
+ 17. --fix flag: does NOT regenerate missing core modules (reinstall required)
207
+ 18. Cross-runtime: Claude config dir detection
208
+ 19. Cross-runtime: Gemini config dir detection
209
+ 20. Raw JSON output format matches schema
210
+ 21. Summary string format is correct
211
+ 22. Exit code 0 for healthy, 1 for broken
212
+ 23. Binary/large files skipped in hash verification
213
+ 24. CRLF vs LF handling in hash comparison
214
+ 25. Partial install recovery path
215
+
216
+ ## Security
217
+
218
+ - **Attack surface:** Read-only analysis of local files. No network calls. No code execution beyond Node.js.
219
+ - **Path safety:** All paths resolved relative to configDir with `path.resolve()` + containment check.
220
+ - **No eval/Function:** Pure file reads and hash comparisons.
221
+ - **Manifest tampering:** If manifest is tampered, hash mismatches are detected. If manifest is deleted, reported as "broken".
222
+
223
+ ## Risk Register
224
+
225
+ | Risk | Probability | Impact | Mitigation |
226
+ |---|---|---|---|
227
+ | Hook hashes differ across platforms (CRLF) | Medium | Low | Normalize line endings before hashing or use git-style normalization |
228
+ | Manifest size growth with hooks | Low | Low | 3 additional entries — negligible |
229
+ | Post-install self-check slows install | Low | Low | < 100ms budget enforced via async file stats |
230
+ | False positives from AV-quarantined files | Medium | Medium | Clear error message: "file missing, check antivirus quarantine" |
231
+ | Breaking change to manifest format | Low | High | Version field in manifest already exists, add migration path |
232
+
233
+ ## Sources
234
+
235
+ - PAN Wizard deployment audit of d:\pantesting (2026-03-09)
236
+ - install-lib.cjs `generateManifest()` code review
237
+ - pan-tools.cjs dispatcher code review
238
+ - settings.json hook configuration analysis
239
+ - install.js post-install flow analysis
240
+
241
+ ---
242
+
243
+ *Generated by /pan:audit-deployment — 2026-03-09*
@@ -0,0 +1,253 @@
1
+ ---
2
+ spec: doc-code-link-graph
3
+ adr: ADR-0027
4
+ status: accepted
5
+ created: 2026-05-03
6
+ ---
7
+
8
+ # Spec: Doc–Code Link Graph
9
+
10
+ This spec is the W0 gate for [ADR-0027](../decisions/ADR-0027-doc-code-link-graph.md). It defines the on-disk grammars, the scanner contracts, the lint passes, the output schema, and the failure modes that the W1–W3 implementation must satisfy. Where this spec and the ADR diverge, the spec is authoritative for behavior; the ADR is authoritative for rationale.
11
+
12
+ ## 1. Surfaces
13
+
14
+ The link graph spans **two surfaces**:
15
+
16
+ | Surface | Files | What it carries |
17
+ |---|---|---|
18
+ | Docs | `docs/`, `pan-wizard-core/{workflows,templates,references,learnings}/`, `commands/`, `agents/`, `CLAUDE.md`, `README.md` | Inline `[[<id>]]` body refs, `must_haves.key_links` frontmatter, `require-code-mention: true` frontmatter |
19
+ | Code | `pan-wizard-core/`, `bin/`, `hooks/`, `scripts/` | `@pan: <id>` source-comment anchors |
20
+
21
+ Source roots are configurable via `--source-root` and `--doc-root` flags (repeatable); defaults match the table above.
22
+
23
+ ## 2. Doc-side grammars
24
+
25
+ ### 2.1 Inline link `[[<id>]]`
26
+
27
+ Body-text reference. Forms:
28
+
29
+ ```
30
+ [[ADR-0021]] → resolves to docs/decisions/ADR-0021-*.md
31
+ [[docs/specs/example.md]] → resolves to that exact path
32
+ [[learnings/universal/test-iso]] → resolves to pan-wizard-core/learnings/universal/test-iso.md
33
+ [[ADR-0021#Decision]] → file + section anchor
34
+ ```
35
+
36
+ Recognition regex: `\[\[([^\[\]\s|][^\[\]]*?)\]\]` (anchored to non-bracket, non-leading-pipe to keep markdown table cells safe).
37
+
38
+ ### 2.2 Frontmatter `must_haves.key_links`
39
+
40
+ Existing mechanism, unchanged. Continues to be verified by [verify.cjs:cmdVerifyKeyLinks](../../pan-wizard-core/bin/lib/verify.cjs). The link-graph forward pass treats each `key_links` entry as one forward link with a regex-backed assertion; integration is read-only — `links validate` never rewrites `key_links` blocks.
41
+
42
+ ### 2.3 Frontmatter `require-code-mention: true`
43
+
44
+ Optional. When set, the doc declares that at least one source-anchor (`@pan:`) under the configured source roots must resolve to it. Default is `false`/absent (advisory). Authors opt docs in; the tool does not.
45
+
46
+ ## 3. Code-side grammar: `@pan: <id>`
47
+
48
+ A source comment of the form:
49
+
50
+ ```
51
+ <comment-leader>[whitespace]@pan:[whitespace]<id>
52
+ ```
53
+
54
+ `<comment-leader>` is one of:
55
+
56
+ | Leader | Used by | Languages |
57
+ |---|---|---|
58
+ | `//` | JS, TS, CJS | `*.cjs`, `*.js`, `*.ts`, `*.mjs` |
59
+ | `#` | Shell, Python | `*.sh`, `*.py`, `*.ps1` |
60
+ | `<!--` | HTML / Markdown | `*.md`, `*.html` (closing `-->` is permitted on the same line and ignored) |
61
+
62
+ `<id>` matches one of the doc-id forms in §4.
63
+
64
+ Recognition regex (per leader, line-anchored, leading whitespace permitted):
65
+
66
+ - JS/TS: `^\s*//\s*@pan:\s*([^\s].*?)\s*$`
67
+ - Shell: `^\s*#\s*@pan:\s*([^\s].*?)\s*$`
68
+ - HTML: `^\s*<!--\s*@pan:\s*([^\s].*?)\s*(?:-->)?\s*$`
69
+
70
+ Anchors are line-scoped — multi-line block comments are not parsed. Anchors found inside string literals are out of scope; the line-anchor regex avoids most false positives because string literals on a line do not begin with the comment leader.
71
+
72
+ A file may carry multiple anchors. Convention: cluster anchors at the top of the file under a single banner comment.
73
+
74
+ ## 4. Doc-id resolution
75
+
76
+ Input form → resolution order (first match wins):
77
+
78
+ 1. **`ADR-NNNN`** (case-insensitive `ADR-` prefix, exactly 4 digits) → glob `docs/decisions/ADR-NNNN-*.md`. Zero or many matches → unresolved.
79
+ 2. **`<path>` ending in `.md`** → exact relative-to-repo-root path.
80
+ 3. **`<path>` not ending in `.md`** → try `<path>.md` first, else `<path>/README.md`. Used by `learnings/universal/<topic>` shorthand.
81
+ 4. **`<doc>#<section>`** → split on `#`; resolve `<doc>` per (1)–(3); then verify a markdown heading whose flattened slug matches `<section>`. Slug = lowercase + spaces→`-` + remove non-`[a-z0-9-]`.
82
+
83
+ Doc-ids are stored canonically as POSIX-style paths. The resolver returns `{ resolved: boolean, path?: string, section?: string, reason?: string }`.
84
+
85
+ ## 5. Lint passes
86
+
87
+ `pan-tools links validate [--strict] [--json] [--source-root <p>...] [--doc-root <p>...] [--root <p>]`
88
+
89
+ Three sequential passes; all findings collected into one report.
90
+
91
+ ### 5.1 Forward-link resolution (`F-001` through `F-099`)
92
+
93
+ For each markdown file under doc roots:
94
+
95
+ | Code | Severity | Trigger |
96
+ |---|---|---|
97
+ | F-001 | error | `[[<id>]]` does not resolve to a file |
98
+ | F-002 | error | `[[<doc>#<section>]]` resolves a file but the named section is missing |
99
+ | F-003 | warning | `must_haves.key_links` entry's `from` or `to` path does not exist |
100
+ | F-004 | warning | `must_haves.key_links` entry's `pattern` is not a valid regex |
101
+
102
+ `F-003` and `F-004` are the existing `cmdVerifyKeyLinks` checks reframed as graph findings. The original command keeps working in parallel; calling it from the new lint is left to a follow-up to avoid double-walks.
103
+
104
+ ### 5.2 Backlink contract (`B-001` through `B-099`)
105
+
106
+ For each doc with `require-code-mention: true` in frontmatter:
107
+
108
+ | Code | Severity | Trigger |
109
+ |---|---|---|
110
+ | B-001 | error | Zero `@pan:` anchors under source roots resolve to this doc |
111
+ | B-002 | warning | All resolving anchors are in the same single source file (single-point-of-truth signal — informational) |
112
+
113
+ `B-001` is the load-bearing check. `B-002` is informational and does not flip the report status under `--strict`.
114
+
115
+ ### 5.3 Anchor-target existence (`A-001` through `A-099`)
116
+
117
+ For each `@pan: <id>` anchor under source roots:
118
+
119
+ | Code | Severity | Trigger |
120
+ |---|---|---|
121
+ | A-001 | error | `<id>` does not resolve to a file under doc roots |
122
+ | A-002 | warning | `<id>` includes a `#section` that doesn't match any heading in the resolved file |
123
+ | A-003 | warning | Anchor uses a deprecated form (reserved for future migrations; no triggers in v1) |
124
+
125
+ ## 6. Output schema
126
+
127
+ Both `--json` and human modes share the same underlying object; human mode adds a flat-text summary line via `output()`.
128
+
129
+ ```json
130
+ {
131
+ "ok": false,
132
+ "summary": {
133
+ "total_findings": 3,
134
+ "errors": 2,
135
+ "warnings": 1,
136
+ "status": "fail",
137
+ "doc_files_scanned": 142,
138
+ "source_files_scanned": 38,
139
+ "anchors_found": 7,
140
+ "forward_links_found": 51,
141
+ "backlink_contracts_checked": 3
142
+ },
143
+ "findings": [
144
+ {
145
+ "code": "F-001",
146
+ "severity": "error",
147
+ "source": "docs/USER-GUIDE.md",
148
+ "source_line": 87,
149
+ "target": "ADR-9999",
150
+ "detail": "ADR-9999 did not match any file under docs/decisions/"
151
+ },
152
+ {
153
+ "code": "B-001",
154
+ "severity": "error",
155
+ "source": "docs/decisions/ADR-0026-self-improvement-loop.md",
156
+ "target": null,
157
+ "detail": "require-code-mention is true but no @pan: anchors resolve to this doc"
158
+ },
159
+ {
160
+ "code": "A-002",
161
+ "severity": "warning",
162
+ "source": "pan-wizard-core/bin/lib/experiment.cjs",
163
+ "source_line": 3,
164
+ "target": "ADR-0026#NonexistentSection",
165
+ "detail": "Section anchor not found in resolved file"
166
+ }
167
+ ]
168
+ }
169
+ ```
170
+
171
+ `status` is `pass` when `errors === 0` and (without `--strict`) is also `pass` when only warnings are present. `--strict` flips status to `fail` if any finding exists. Process exit code is `0` for `pass`, `1` for `fail`.
172
+
173
+ ## 7. Module API surface
174
+
175
+ `pan-wizard-core/bin/lib/links.cjs` exports:
176
+
177
+ ```
178
+ validateAll(rootDir, opts) → { ok, summary, findings }
179
+ scanForwardLinks(docRoots, cwd) → [{ source, sourceLine, rawId, resolved, ... }]
180
+ scanAnchors(sourceRoots, cwd) → [{ source, sourceLine, rawId, resolved, ... }]
181
+ resolveDocId(rawId, cwd) → { resolved, path?, section?, reason? }
182
+ parseAnchorLine(line, leader) → string|null (returns the rawId or null)
183
+ parseInlineLinks(text) → [{ rawId, line }]
184
+ cmdLinksValidate(cwd, opts) → void (writes to stdout via output())
185
+ ```
186
+
187
+ `opts` shape:
188
+
189
+ ```
190
+ {
191
+ sourceRoots: string[]?, // defaults to ['pan-wizard-core', 'bin', 'hooks', 'scripts']
192
+ docRoots: string[]?, // defaults to ['docs', 'pan-wizard-core/workflows',
193
+ // 'pan-wizard-core/templates',
194
+ // 'pan-wizard-core/references',
195
+ // 'pan-wizard-core/learnings',
196
+ // 'commands', 'agents']
197
+ strict: boolean, // default false
198
+ raw: boolean, // for output() — passed through
199
+ }
200
+ ```
201
+
202
+ ## 8. Reuse contracts
203
+
204
+ The implementation MUST reuse the following existing modules; no parallel walkers, no parallel parsers.
205
+
206
+ | Concern | Module | Function |
207
+ |---|---|---|
208
+ | Recursive markdown walk | [doc-lint/walk.js](../../pan-wizard-core/bin/lib/doc-lint/walk.js) | `walkMarkdownFiles(dir, {exclude})` |
209
+ | Frontmatter parse | [frontmatter.cjs](../../pan-wizard-core/bin/lib/frontmatter.cjs) | `extractFrontmatter(content)` |
210
+ | `key_links` block parse | [frontmatter.cjs](../../pan-wizard-core/bin/lib/frontmatter.cjs) | `parseMustHavesBlock(content, 'key_links')` |
211
+ | File reads + path normalization | [core.cjs](../../pan-wizard-core/bin/lib/core.cjs) | `safeReadFile`, `toPosix` |
212
+ | Output framing | [core.cjs](../../pan-wizard-core/bin/lib/core.cjs) | `output(obj, raw, humanLine?)` |
213
+
214
+ For source-side scanning the implementation walks file extensions directly via `fs.readdirSync` recursion — no dependency on the `walkMarkdownFiles` walker (which is markdown-only).
215
+
216
+ ## 9. Failure modes
217
+
218
+ | Mode | Behavior |
219
+ |---|---|
220
+ | Doc root does not exist | Skip silently; record skipped roots in summary as informational |
221
+ | Source root does not exist | Skip silently; record skipped roots in summary as informational |
222
+ | File read error mid-walk | Emit a finding with code `F-005` or `A-005` (severity warning) — do not abort |
223
+ | Frontmatter parse error | Treat doc as having no frontmatter for that file's contract checks; not a finding |
224
+ | Regex pattern in `key_links` is invalid | Emit `F-004`; do not abort |
225
+ | Anchor with empty id (`@pan:` followed by nothing) | Emit `A-004` warning; skip resolution |
226
+
227
+ `links validate` MUST NOT throw under any normal repo state. All errors are findings.
228
+
229
+ ## 10. Cross-platform requirements
230
+
231
+ - All path output uses POSIX-style forward slashes via `toPosix()`.
232
+ - All path comparisons normalize via `toPosix()` before equality.
233
+ - Doc-ids that are ADR shortcuts are case-insensitive on the `ADR-` prefix only (the `NNNN-<slug>` portion preserves case as on disk).
234
+ - The walker must not follow symlinks (matches existing `walkMarkdownFiles` behavior).
235
+
236
+ ## 11. Acceptance criteria
237
+
238
+ The W1–W3 implementation is acceptance-complete when:
239
+
240
+ 1. **W1**: `node pan-wizard-core/bin/pan-tools.cjs links validate --json` runs against a hand-crafted fixture project (under `tests/fixtures/links-graph/`) and emits the schema in §6 with correct findings for: a deliberately broken `[[<id>]]`, a deliberately stale `@pan:` anchor, a doc with `require-code-mention` and zero anchors, and a clean control case. Unit tests in `tests/links.test.cjs` assert all four findings.
241
+ 2. **W2**: Running against the source repo of PAN itself (the real `docs/` + source tree) returns `status: pass` in advisory mode (warnings allowed), excluding `require-code-mention` opt-ins (none yet at W2).
242
+ 3. **W3**: After opting three canary ADRs into `require-code-mention: true` and placing the corresponding `@pan:` anchors in their primary implementation files, `pan-tools links validate --strict` returns `status: pass`. `pan-tools validate health` shows a `link_graph` summary line.
243
+
244
+ ## 12. Out of scope (explicit deferrals)
245
+
246
+ These are listed in [ADR-0027](../decisions/ADR-0027-doc-code-link-graph.md#future-scope) and intentionally not specified here:
247
+
248
+ - `pan-tools links refs <doc>` (reverse query)
249
+ - `pan-tools links expand <file>` (inline expansion into prompts)
250
+ - Auto-anchor suggestion path inside `pan-optimizer`
251
+ - Migration of `must_haves.key_links` to inline `[[<id>]]`
252
+ - Commit-time hook gating
253
+ - AST-based code parsing
@@ -0,0 +1,69 @@
1
+ # Documentation Alignment & Cleanup — Feature AI Specification
2
+
3
+ **Mode:** `--spike` (internal cleanup, no competitive research needed)
4
+ **Date:** 2026-03-02
5
+
6
+ ---
7
+
8
+ ## Phase 0: Problem Statement & Scope
9
+
10
+ PAN Wizard v1.0.0 has accumulated stale counts and orphaned artifacts across 21 development sessions. Documentation references 33 workflows (actual: 30), 1012 tests (actual: 1065), and 875 tests in the ship spec (actual: 1065). Three runtime installation directories (.codex/, .gemini/, .opencode/) are untracked 5MB of clutter. Two completed batch files should be archived. FAQ.md is missing Copilot CLI from the runtime table.
11
+
12
+ ### Scope
13
+
14
+ | In Scope | Out of Scope |
15
+ |----------|-------------|
16
+ | Fix stale counts in DEVELOPMENT.md | Rewriting spec content (historical docs) |
17
+ | Fix FAQ.md missing Copilot CLI | Adding new documentation |
18
+ | Archive completed batch files | Changing any code |
19
+ | Add runtime dirs to .gitignore | Modifying the installer |
20
+ | Update production_readiness spec counts | CI/CD changes |
21
+ | Fix ADR-0009 workflow count reference | |
22
+
23
+ ---
24
+
25
+ ## Phase 4: Design — Task List
26
+
27
+ ### CRITICAL (P1)
28
+
29
+ **Task 1: Fix DEVELOPMENT.md stale counts**
30
+ - Line 33: workflow count 33 → 30
31
+ - Line 45: test count "1012 tests, 206 suites" → "1065 tests, 218 suites"
32
+ - Line 56: "Run all 1012 tests" → "Run all 1065 tests"
33
+ Files: docs/DEVELOPMENT.md
34
+
35
+ **Task 2: Fix FAQ.md missing Copilot CLI**
36
+ - Add Copilot CLI row to runtime table
37
+ Files: docs/FAQ.md
38
+
39
+ ### HIGH (P2)
40
+
41
+ **Task 3: Fix production_readiness_ship_v1 spec stale counts**
42
+ - Replace "33 test files, 875 tests" with "37 test files, 1065 tests" (4 locations)
43
+ Files: docs/specs/production_readiness_ship_v1_featureai.md
44
+
45
+ **Task 4: Fix ADR-0009 workflow count**
46
+ - "33 workflows when 31 exist" → "33 workflows when 30 exist"
47
+ Files: docs/decisions/ADR-0009-production-deployment-checklist.md
48
+
49
+ ### MEDIUM (P3)
50
+
51
+ **Task 5: Add runtime install dirs to .gitignore**
52
+ - Add .codex/, .gemini/, .opencode/ to .gitignore
53
+ Files: .gitignore
54
+
55
+ **Task 6: Archive completed batch files**
56
+ - Move batch-2026-03-01-c.json to .planning/focus/archive/
57
+ - Move batch-2026-03-02.json to .planning/focus/archive/
58
+ Files: .planning/focus/
59
+
60
+ ### LOW (P6)
61
+
62
+ **Task 7: Fix stale counts in historical specs (optional)**
63
+ - copilot_cli_runtime_featureai.md: "32 workflow commands" → updated to 37
64
+ - industry_comparison_and_feature_gaps_featureai.md: "4 runtimes" → updated to 5
65
+ Files: docs/specs/
66
+
67
+ ---
68
+
69
+ ## Total: 7 tasks, all XS size, ~10 minutes