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,55 @@
1
+ # ADR-0020: AI Drift Prevention System
2
+
3
+ ## Status
4
+ Accepted (shipped in v2.6.0 — 2026-03-08)
5
+
6
+ ## Context
7
+ AI coding assistants gradually deviate from project conventions during extended sessions ("AI drift"). This manifests as wrong patterns (console.log instead of output()), forgotten naming conventions, scope creep, and lost project state. PAN Wizard already has the strongest drift prevention infrastructure in the market — state tracking, deviation rules, verification, cross-session resume — but lacks active enforcement and quantitative measurement. No competitor tool (Aider, Cursor, Cline, Windsurf, Copilot WS) offers built-in drift scoring. The industry is shifting from code generation speed to code quality in 2026, making this strategically timed.
8
+
9
+ ## Decision
10
+ Add a `drift-check` command to pan-tools that:
11
+ 1. Loads convention rules from `.planning/codebase/CONVENTIONS.md` and `CLAUDE.md`
12
+ 2. Parses conventions into matchable rules (regex patterns, anti-patterns)
13
+ 3. Diffs changed files (via `git diff --name-only`) against those rules
14
+ 4. Produces a quantitative Drift Score (0.0-1.0) with per-file violations
15
+ 5. Outputs JSON with violations, scores, and human-readable summary
16
+
17
+ Implementation is zero-dependency (regex-based matching), read-only (no code modification), and fast (<200ms). Built-in convention rules cover PAN Wizard's own patterns. Custom rules loaded from project-specific CONVENTIONS.md.
18
+
19
+ ### v0 (MVP): `drift-check` command + rule parser + scoring (20 points)
20
+ ### v1: Pre-commit hook + health --drift + verify integration (16 points)
21
+ ### v2: Cross-session trends + auto-discovery + custom rule DSL (30 points)
22
+
23
+ ## Consequences
24
+
25
+ ### Positive
26
+ - PAN becomes the only tool with quantitative drift measurement
27
+ - Convention enforcement moves from passive (advisory) to active (measurable)
28
+ - Builds on existing infrastructure (verify.cjs, standards system, git integration)
29
+ - Zero new dependencies
30
+ - Enables cross-session drift trend analysis (v2)
31
+
32
+ ### Negative
33
+ - Regex-based matching has false positive risk (mitigated by severity levels and thresholds)
34
+ - Requires `.planning/codebase/CONVENTIONS.md` to exist for custom rules (built-in rules as fallback)
35
+ - Convention parsing from markdown is heuristic, not semantic (mitigated by structured format)
36
+
37
+ ### Neutral
38
+ - Adds one new pan-tools subcommand (`drift-check`)
39
+ - Read-only — no state mutations in v0
40
+ - Optional integration — doesn't change existing command behavior
41
+
42
+ ## Options Considered
43
+
44
+ 1. **External tool integration (CodeScene/SonarQube)** — Rejected: adds dependencies, SaaS lock-in, violates zero-dep principle
45
+ 2. **AST-based analysis** — Rejected: requires parser dependencies (acorn, etc.), too heavyweight for convention checking
46
+ 3. **Regex-based convention matching (chosen)** — Zero deps, fast, sufficient accuracy for convention-level checking
47
+ 4. **Human-in-the-loop only (Cline model)** — Rejected: too much friction, doesn't scale to autonomous execution
48
+ 5. **No action (status quo)** — Rejected: competitive gap, user-stated need, strategic timing
49
+
50
+ ## Links
51
+ - Spec: `docs/specs/ai_drift_prevention_featureai.md`
52
+ - Related: verify.cjs (validation infrastructure)
53
+ - Related: config.cjs (standards system)
54
+ - Related: ADR-0010 (standards integration)
55
+ - Related: ADR-0014 (internal cleanup/code quality)
@@ -0,0 +1,76 @@
1
+ ---
2
+ require-code-mention: true
3
+ ---
4
+
5
+ # ADR-0021: Codebase Mapper v2 — Advanced Codebase Import & Analysis
6
+
7
+ ## Status
8
+ Accepted (shipped in v2.7.0 — 2026-03-08)
9
+
10
+ ## Context
11
+
12
+ `/pan:map-codebase` is the gateway command for brownfield projects — the first experience users have when importing an existing codebase into PAN. The current implementation (v1, ADR-0008) spawns 4 parallel agents that produce 7 template-driven documents using bash grep patterns. This approach has three critical limitations:
13
+
14
+ 1. **No relationship awareness** — No module dependency graph, no circular dependency detection, no understanding of which modules depend on which. Users must manually trace imports across hundreds of files.
15
+
16
+ 2. **No best-practices assessment** — No detection of which patterns the codebase follows (error handling, testing, naming, security). Users discover convention violations during execution, not during planning.
17
+
18
+ 3. **Shallow analysis** — Hardcoded bash grep patterns (`grep -r "import.*stripe"`) are language-agnostic but fragile. They miss most real-world import patterns and provide no structural understanding.
19
+
20
+ Competitors like Aider (tree-sitter AST repo-maps) and DeepWiki (auto-generated wikis) set user expectations for deep codebase analysis. PAN must match this depth while maintaining its zero-dependency constraint.
21
+
22
+ Additionally, the user requests lowercase output filenames (stack.md not STACK.md) to align with PAN's existing `.planning/` lowercase convention.
23
+
24
+ ## Decision
25
+
26
+ Redesign the codebase mapper with:
27
+
28
+ 1. **New `codebase.cjs` core module** — Language-aware import/export parsing using regex patterns (not AST) for JS/TS (v0), Python, Go, Rust, Java, C# (v1). Builds in-memory dependency graphs, detects circular dependencies, finds entry points and orphan modules.
29
+
30
+ 2. **6 focus areas** (was 4) — Add `relationships` (module dependency graph) and `practices` (best-practices detection) agents, producing `relationships.md` and `best-practices.md`.
31
+
32
+ 3. **9 output documents** (was 7) — All with lowercase filenames.
33
+
34
+ 4. **Pre-computed analysis** — Core module runs import analysis and language detection BEFORE agents spawn. Results passed to agents as structured data, avoiding expensive LLM re-scanning.
35
+
36
+ 5. **3 new CLI commands** — `codebase analyze-imports`, `codebase detect-languages`, `codebase best-practices` for standalone use and debugging.
37
+
38
+ 6. **Backward-compatible migration** — Consumers check lowercase first, fallback to UPPERCASE.
39
+
40
+ ## Consequences
41
+
42
+ ### Positive
43
+ - Dependency graphs give users immediate architectural understanding of brownfield codebases
44
+ - Best-practices assessment enables prioritized technical debt cleanup in roadmaps
45
+ - Pre-computed analysis means agents start with facts, not discovery — higher quality output
46
+ - Lowercase filenames align with PAN's existing convention
47
+ - Zero runtime dependencies maintained (regex-only analysis)
48
+ - Same command, richer output — zero learning curve
49
+
50
+ ### Negative
51
+ - Regex-based parsing misses some complex patterns (re-exports, dynamic imports, computed requires)
52
+ - 6 agents instead of 4 increases token cost per mapping run
53
+ - Migration period where both UPPERCASE and lowercase filenames must be supported
54
+ - New `codebase.cjs` module adds maintenance surface
55
+
56
+ ### Neutral
57
+ - Template structure remains the same (enhanced, not replaced)
58
+ - Agent architecture remains the same (parallel agents writing directly)
59
+ - Workflow pattern remains the same (orchestrator spawns agents, collects confirmations)
60
+
61
+ ## Options Considered
62
+
63
+ 1. **tree-sitter AST parsing** (Aider approach) — Most accurate, supports 30+ languages. Rejected: adds ~5MB WASM runtime dependency, violates zero-dep constraint.
64
+
65
+ 2. **LLM-only analysis** (DeepWiki approach) — Let agents discover everything themselves. Rejected: expensive, slow, inconsistent results, agents re-scan the same files.
66
+
67
+ 3. **Regex-based analysis with pre-computation** (chosen) — Core module does fast regex parsing, passes structured data to agents. Best balance of accuracy, speed, and zero dependencies.
68
+
69
+ 4. **Embedding-based indexing** (Cursor/Continue.dev approach) — Semantic search with vector embeddings. Rejected: requires embedding model (runtime dep), accuracy issues documented in Continue.dev community.
70
+
71
+ ## Links
72
+ - Supersedes: ADR-0008 (Mermaid/TOGAF enhancement — incorporated into v2)
73
+ - Spec: `docs/specs/codebase_mapper_v2_featureai.md`
74
+ - Related: `pan-wizard-core/bin/lib/codebase.cjs` (new module)
75
+ - Related: `agents/pan-document_code.md` (rewritten agent)
76
+ - Related: `pan-wizard-core/workflows/map-codebase.md` (updated workflow)
@@ -0,0 +1,63 @@
1
+ # ADR-0022: Lifecycle Completeness — Test Generation, Code Review, Test Gate, Retrospective
2
+
3
+ ## Status
4
+ Accepted (shipped in v2.8.0 — 2026-03-08)
5
+
6
+ ## Context
7
+ PAN Wizard's lifecycle has structural gaps when compared against industry SDLC frameworks (V-Model, Agile, DevOps, SAFe). Specifically:
8
+
9
+ 1. **Test generation is orphaned:** `/pan:phase-tests` exists but no orchestrator calls it. Users must manually discover and invoke it.
10
+ 2. **No code review stage:** Between execution (pan-executor) and verification (pan-verifier), nobody checks code quality, convention compliance, or security patterns.
11
+ 3. **Verifier doesn't run tests:** `pan-verifier` checks goals against success criteria and artifacts, but never executes the project's test suite.
12
+ 4. **No retrospective:** `/pan:milestone-audit` checks WHAT was built against requirements, but there's no process-focused analysis of HOW work was done (estimation accuracy, common gap patterns).
13
+
14
+ These gaps were discovered during a systematic comparison of PAN's lifecycle against 8 industry frameworks (Waterfall, V-Model, Agile/Scrum, SAFe, DevOps/CI-CD, Shift-Left, SRE, TOGAF ADM).
15
+
16
+ ## Decision
17
+ Close the V-Model right-side gap by:
18
+
19
+ 1. **Wire `/pan:phase-tests` into `exec-phase.md`** — auto-invoke after execution completes (step 6.5)
20
+ 2. **Create `pan-reviewer` agent** — read-only code review with quality/convention/security checks
21
+ 3. **Add review step to `exec-phase.md`** — spawn pan-reviewer after test generation (step 6.7)
22
+ 4. **Add test suite gate to `verify-phase.md`** — verifier runs `npm test` and compares before/after counts
23
+ 5. **Create `/pan:retro` command** — milestone-level retrospective analyzing estimation accuracy and gap patterns
24
+
25
+ The new lifecycle becomes:
26
+ ```
27
+ plan → exec → tests (auto) → review (auto) → verify (with test gate) → next phase
28
+ ↓
29
+ milestone-done → retro → next milestone
30
+ ```
31
+
32
+ ## Consequences
33
+
34
+ ### Positive
35
+ - PAN becomes the only AI coding tool with complete V-Model coverage
36
+ - Test generation is no longer orphaned — automatically invoked
37
+ - Code quality issues caught before verification, not after
38
+ - Test regressions caught by verifier (not just goal achievement)
39
+ - Process learning through retrospectives improves estimation over time
40
+
41
+ ### Negative
42
+ - exec-phase takes longer (~1-2 min for test gen + review)
43
+ - pan-reviewer may produce false positive warnings (tuning needed)
44
+ - Additional agent increases installer size slightly
45
+
46
+ ### Neutral
47
+ - --skip-tests and --skip-review flags provide opt-out for rapid iteration
48
+ - Retro is a separate command, not auto-invoked (user chooses when to reflect)
49
+ - No changes to existing command JSON schemas — purely additive
50
+
51
+ ## Options Considered
52
+
53
+ 1. **Do nothing** — Leave gaps as-is. Rejected: user discovered the gap, evidence is clear.
54
+ 2. **Just wire phase-tests** — Minimal fix. Rejected: misses review + test gate opportunities.
55
+ 3. **Full lifecycle with mandatory gates** — All stages required. Rejected: too rigid for exploratory work.
56
+ 4. **Full lifecycle with skip flags (CHOSEN)** — All stages available, skippable via flags.
57
+
58
+ ## Links
59
+ - Spec: `docs/specs/lifecycle_completeness_featureai.md`
60
+ - Gap analysis: `link_system_temp.md`
61
+ - Related: exec-phase.md, verify-phase.md, phase-tests.md workflows
62
+ - Related: pan-verifier, pan-executor agents
63
+ - Related: ADR-0019 (E2E UAT testing)
@@ -0,0 +1,89 @@
1
+ # ADR-0023: Opus 4.7 Adoption — 1M Context, Extended Thinking, Prompt Caching, Native Skills
2
+
3
+ ## Status
4
+ Accepted (shipped in v2.10.0 — 2026-04-18)
5
+
6
+ > **Amended 2026-10-04 (memory optimisation, O2 follow-up): E-1's priming step is withdrawn.**
7
+ >
8
+ > - **It never primed anything.** `pan-tools cache prime --summary` prints the cacheable set's paths, sizes and a sha into the orchestrator's own context. A command's output cannot set `cache_control` on another agent's prompt. The host caches each agent's prompt prefix by itself, primed or not. The "40-60%" saving below was never measured. What ADR-0044 later measured was the opposite problem: cache reads were 98% of token traffic, because every agent re-read the same large files.
9
+ > - **It also loaded more.** `exec-phase` told the orchestrator to put the cacheable set's paths in every executor's context. That is the whole roadmap and requirements, which O2 replaced with a phase's `roadmap slice`.
10
+ > - **What changed:** the `<cache_priming>` steps are gone from `plan-phase`, `exec-phase` and `verify-phase`, and so is the matching step in `focus-exec` and `army`. `cache prime` stays as a measurement, next to `context-budget` and hygiene's `cache-context` check (ADR-0044).
11
+
12
+ ## Context
13
+ PAN Wizard's architecture (through v2.9.1) was designed around Claude 3.x assumptions: 200K context windows, no native extended thinking, no prompt caching, commands delivered as slash-command `.md` files rather than discoverable skills. Opus 4.7 (GA Q2 2026) materially changes the underlying primitives:
14
+
15
+ - **1M context window** — medium codebases (up to ~700K tokens) can be ingested in a single agent call.
16
+ - **Native extended thinking** — `thinking: enabled` frontmatter with per-agent `thinking_budget`. Reasoning is visible in-band and priced per-token.
17
+ - **Prompt caching (cache_control: ephemeral)** — input blocks with stable content get a 5-minute cache TTL. Cache hits cost ~10% of cold tokens.
18
+ - **Native skills discovery** — Claude Code 1.x loads skills from `.claude/skills/*.md` with frontmatter-based trigger metadata, enabling auto-invocation.
19
+
20
+ PAN's workflow-first orchestration model made minimal use of these primitives. Competitors (Cursor 2, Windsurf, Aider) shipped multi-agent orchestration and session memory in late 2025. Without direct Opus 4.7 integration, PAN would be out-innovated on cost/latency and on workflow intelligence.
21
+
22
+ We captured the investigation in [docs/specs/opus_47_existing_enhancements_featureai.md](../specs/opus_47_existing_enhancements_featureai.md) (Spec A — 12 enhancements to existing features) and [docs/specs/opus_47_extended_features_featureai.md](../specs/opus_47_extended_features_featureai.md) (Spec B — 14 new commands/agents, deferred to v3.x).
23
+
24
+ ## Decision
25
+ Ship Spec A in full as v2.10.0. Defer Spec B to v3.x as stability data arrives.
26
+
27
+ Concretely, adopt the following Opus 4.7 primitives across the existing surface:
28
+
29
+ 1. **Prompt caching layer** (E-1). Single canonical set of cacheable files: `CACHEABLE_CONTEXT_FILES` = [`project.md`, `requirements.md`, `roadmap.md`, `state.md`, `standards.md`]. `buildCachedContext(cwd)` returns ordered blocks with a stable SHA for cache-key hit predictability. Commands (`plan-phase`, `exec-phase`, `verify-phase`, `focus-exec`) prime the cache once per invocation via `pan-tools cache prime --summary`.
30
+ 2. **Whole-project ingest** (E-2). `/pan:map-codebase` branches on `estimateRepoTokenSize(cwd)`: single-shot mode (Opus 4.7 only) at ≤700K tokens, sharded mode (6-way parallel) above. Agent `pan-document_code` has an explicit `<mode>` block so it knows which mode it's executing in.
31
+ 3. **Extended thinking** (E-3). Five verification-heavy agents enable thinking with per-agent budgets: `pan-plan-checker` (8000), `pan-verifier` (6000), `pan-integration-checker` (6000), `pan-reviewer` (4000), `pan-debugger` (8000). Installer strips these fields for non-Claude runtimes and injects a prose "think step-by-step" preamble via `translateThinkingDirective`.
32
+ 4. **Agent memory layer** (E-4). New `memory.cjs` module with append-only per-agent logs at `.planning/memory/<agent>.md`. Agent-name validated against `^[a-zA-Z0-9_-]+$` to block path traversal. Compaction bounded by `DEFAULT_MAX_ENTRIES=500`. Retrospective command (`/pan:retro --write-memory`) extracts top-N gap patterns as planner lessons.
33
+ 5. **Native skills shims** (E-5). Installer generates `.claude/skills/pan-<cmd>.md` for every command so host skills discovery surfaces them with frontmatter-declared descriptions.
34
+ 6. **Parallel-tool execution** (E-6). `classifyStageDependencies` emits waves + a `parallelism_hint` that `focus-exec` Stage 3.0 uses to instruct parallel tool calls. `pan-executor` agent gained a `<parallel_tool_use>` block: batch reads, serialize writes.
35
+ 7. **Capability-aware model routing** (E-7). `resolveModel` accepts `{context_estimate, needs_thinking, cache_warm}` hints and adjusts the profile-selected tier upward (toward reasoning) when context is large or thinking is needed, downward (toward fast) when cache is warm and context is small.
36
+ 8. **Statusline & health indicators** (E-8). Statusline renders `🧠` when thinking is active and `⚡N%` when cache hit rate is known. `context-budget` reports cacheable block count, bytes, eligible percentage, and stable SHA.
37
+ 9. **Installer capability detection** (E-9). `detectModelCapabilities(modelName)` classifies default model from settings.json; installer emits a post-install warning if the default model lacks features Spec A relies on.
38
+ 10. **Focus-auto reflection gate** (E-10). Between cycles, `determineContinuation` emits a thinking-gated prompt that lets Opus 4.7 veto the next cycle earlier than the automatic stop rules would.
39
+ 11. **Debugger hypothesis trees** (E-11). `pan-debugger` generates ≥3 hypotheses with Bayesian priors and attacks the top 2 in parallel (parallel *investigation*, not parallel *fixes*).
40
+ 12. **Oldest-batch-first ordering** (E-12 — pre-existing bugfix folded into the release). `readLatestBatch` sorts ascending so an older unfinished batch executes before a newer one.
41
+
42
+ Implementation verification strategy: per-item tests, plus end-to-end scenario tests for memory persistence, skills installation, and map-codebase mode selection. Target test delta +100 to +150; actual delta was +143 (1983 → 2126).
43
+
44
+ ## Consequences
45
+
46
+ ### Positive
47
+ - **Cost reduction**: prompt caching saves 40-60% input tokens on multi-agent phases (measurements pending in production).
48
+ - **Better planning**: planner/verifier with extended thinking catch logic gaps before execution wastes cycles.
49
+ - **Coherent brownfield maps**: single-shot `map-codebase` eliminates stitching artifacts (contradictory version claims, missed cross-references) on repos ≤700K tokens.
50
+ - **Cross-phase learning**: memory layer makes conventions stick across phases without human re-prompting.
51
+ - **Discoverable commands**: native skills frontmatter enables host auto-invocation (e.g. "when user asks X, invoke `/pan:focus-scan`").
52
+
53
+ ### Negative
54
+ - **Opus 4.7 only for best results**: single-shot `map-codebase` and extended thinking require Opus 4.7. Sonnet 4.6 / Haiku 4.5 work with degraded behavior; installer warns at install time via `detectModelCapabilities`.
55
+ - **New file on disk**: `.planning/memory/<agent>.md` files grow over time. Compaction is manual (`pan-tools memory compact <agent> [max]`) or via `/pan:retro --write-memory` bounded emission.
56
+ - **Claude-only features**: skills shims (E-5) and native thinking frontmatter (E-3) only apply to Claude Code. Non-Claude runtimes get a prose fallback for thinking; no skills shims for Codex/Gemini/OpenCode. Copilot retains its existing directory-per-skill format rather than re-using the Claude flat shim generator.
57
+ - **Spec surface growth**: `+16 tests` in the spec-required path (scenario tests under `tests/scenarios/opus-47-*`), bringing the scenario suite to 28 files.
58
+
59
+ ### Neutral / Tradeoffs considered
60
+ - **Why not also ship Spec B (extended features) in v2.10?** Spec B adds 14 new commands + 9 new agents + a message bus, a roughly 3200-LOC delta. Shipping alongside Spec A would couple two independently-verifiable risk surfaces. Spec B waits for Spec A adoption telemetry (cache hit rates, thinking cost observed in practice) before committing to Wave 1 (bus, cost dashboard, architect command).
61
+ - **Why a dedicated memory module and not state.md?** state.md is per-phase and has strict schema. Memory is cross-phase, append-only, agent-scoped. Conflating them would force state.md into a role it wasn't designed for (learning log vs. execution checkpoint).
62
+ - **Why skills shims for Claude only?** Claude Code is where native skills discovery is implemented. Copilot CLI has its own skills format (directory-per-skill with `SKILL.md`) that doesn't match the flat shim shape. Reworking both runtimes to share a generator is a refactor for v3.x; the current dual implementation works.
63
+
64
+ ## Implementation Notes
65
+
66
+ ### Commit history
67
+ - `53c5bb5` — foundation (8 items: E-1 buildCachedContext, E-4 memory.cjs, E-9 detectModelCapabilities, E-7 resolveModel extension, E-1 cache helper, E-5 buildClaudeSkillShim, E-3 translateThinkingDirective, E-10 determineContinuation, E-6 classifyStageDependencies)
68
+ - `0f4db12` — completion (6 items: E-2 estimateRepoTokenSize, E-3 agent frontmatter, E-5 installer integration, E-8 statusline, E-9 installer integration, E-11 debugger prose)
69
+ - `21bceec` — v2.10.0 release (runtime-aware thinking strip, CLI wrappers, command integrations, version bump, CHANGELOG)
70
+ - `5fb2745` — deep integration (retro→memory, cache metrics in health, scenario tests)
71
+ - Follow-up — Spec A closeout (pan-document_code Mode, profile tier tree, 3 scenario tests, this ADR)
72
+
73
+ ### Rollback plan
74
+ Spec A is additive. Rollback strategy if telemetry reveals a regression:
75
+ - **Caching**: revert `<cache_priming>` blocks in command `.md` files; `buildCachedContext` can stay in core.cjs unused.
76
+ - **Thinking**: remove `thinking:` fields from 5 agents; installer no-ops.
77
+ - **Memory**: delete `.planning/memory/` to reset; module stays.
78
+ - **Skills shims**: `rm -rf .claude/skills/pan-*.md` post-install; regenerated on next install.
79
+ - **Mode branching**: `pan-document_code` falls back to `sharded` when `mode` frontmatter is absent.
80
+
81
+ No `.planning/` schema changes; no breaking CLI contracts.
82
+
83
+ ## Related
84
+
85
+ - Spec A: [opus_47_existing_enhancements_featureai.md](../specs/opus_47_existing_enhancements_featureai.md)
86
+ - Spec B: [opus_47_extended_features_featureai.md](../specs/opus_47_extended_features_featureai.md) (deferred)
87
+ - ADR-0014 (internal cleanup code quality) — baseline for the stability patterns this builds on
88
+ - ADR-0015 (focus-auto runner) — reflection gate builds on auto-runner's safety harness
89
+ - ADR-0022 (lifecycle completeness) — retro command extended here with memory write-back
@@ -0,0 +1,137 @@
1
+ # ADR-0024: Spec B v2 Completion — Consolidated Extended Features Across v3.0-v3.4
2
+
3
+ ## Status
4
+ Accepted (shipped 2026-04-18 through 2026-04-19)
5
+
6
+ ## Context
7
+
8
+ Spec A (Opus 4.7 existing enhancements, ADR-0023) shipped in v2.10.0 and consumed the five core Opus 4.7 primitives (prompt caching, extended thinking, 1M context, memory, capability routing) across PAN's existing surface. With Spec A stable and producing telemetry, the question was how to ship the *extended* feature set Spec B designed.
9
+
10
+ Spec B v1 ([docs/specs/opus_47_extended_features_featureai.md](../specs/opus_47_extended_features_featureai.md)) proposed 14 new commands, 9 new agents, 14 new core modules across 5 waves — a ~3200 LOC, 15-week delta. On 2026-04-18 we accepted a consolidation pass (Spec B v2, [docs/specs/opus_47_extended_features_v2_featureai.md](../specs/opus_47_extended_features_v2_featureai.md)) that folded overlapping capabilities into 6 user-facing commands and shipped as v3.0 through v3.4 over roughly one calendar week.
11
+
12
+ This ADR records the decisions made during that arc — what was consolidated, what was explicitly deferred, why the hierarchical orchestrator was gated behind a flag, and the safety posture for features that introduced new capabilities (agents-spawn-agents, worktree isolation, MCP discovery).
13
+
14
+ ## Decision
15
+
16
+ Ship Spec B v2 across five additive waves with no breaking changes. Consolidate v1's 14 items into 6 user-facing commands plus one infrastructure layer. Keep the focus system (`/pan:focus-*`) untouched — Spec B v2 items interoperate via read boundaries and optional flags only, never modifying focus commands.
17
+
18
+ ### Wave breakdown
19
+
20
+ | Wave | Release | Items | Scope |
21
+ |------|---------|-------|-------|
22
+ | 1 | v3.0.0 | Y-6 cost + Y-7 bus | Observability (cost dashboard) + foundation (file-backed message channels) |
23
+ | 2 | v3.1.0 | Y-1 preview | Foresight — blast radius / dependency graph / milestone ETA in one multi-mode command |
24
+ | 3 | v3.2.0 | Y-2 review-deep + Y-3 knowledge | Security + cross-check review (2 new agents) + grounded Q&A / discussion / playbook (1 new agent, 3 modes) |
25
+ | 4 | v3.3.0 | Y-4 what-if + Y-5 mcp-bridge | Counterfactual phase replay in worktree + MCP discovery-only |
26
+ | 5 | v3.4.0 | `--hierarchical` GA + `--deep-review` wiring + auto cost instrumentation | Wave 1 bus becomes observable via `pan-conductor` + cost hook |
27
+
28
+ ### Consolidation decisions (from v1)
29
+
30
+ - **Foresight** (X-1 architect + X-5 simulate + X-11 predict-milestone) → single `/pan:preview` command with three modes
31
+ - **Deep review** (X-4 self-review + X-12 harden) → single `/pan:review-deep` command with two sequential agent passes
32
+ - **Knowledge** (X-3 converse + X-6 teach + X-10 explain) → single `/pan:knowledge` command with three modes
33
+ - **Hierarchical exec** (X-2 orchestrate + X-13 bus) → infrastructure layer + opt-in flag on existing `exec-phase`, not a standalone command
34
+
35
+ ### Explicit deferrals (documented, not shipped)
36
+
37
+ - **X-8 watch** (background monitoring) — no user-demand signal; external cron works today; revisit in v3.5+ if requested
38
+ - **MCP auto-injection into planner context** — requires stable MCP schema contract; ship discovery-only (Y-5) first
39
+ - **MCP auto-invocation from executor agent** — requires permission-gating + per-tool safety review
40
+ - **Cross-runtime MCP discovery protocol** — no ecosystem signal; cache schema designed generically so future non-Claude runtimes can plug in
41
+ - **`pan-conductor` nesting beyond 2 levels** — would need substantially more safety tooling; current 2-level cap is sufficient for the observed use cases
42
+
43
+ ### Safety posture decisions
44
+
45
+ **Hierarchical orchestration is opt-in behind a flag, not the default.** Rationale:
46
+ 1. Flat exec is cheaper (~20-30% lower total cost for equivalent work).
47
+ 2. Flat exec is more predictable — each sub-agent's behavior is deterministic given plan input; hierarchical introduces a decomposition decision that varies with model reasoning.
48
+ 3. Flat exec is easier to debug — linear trace vs tree trace.
49
+ 4. Hierarchical is only useful when wall-clock reduction justifies the orchestration tax (phases with ≥4 autonomous plans).
50
+
51
+ The safety harness is mandatory (not advisory) for `--hierarchical`:
52
+ - Max 2 nesting levels (conductor → sub-agent; no sub-sub-agents)
53
+ - Max 12 spawns per phase
54
+ - Budget ceiling (reuses focus-auto's budget layer)
55
+ - Emergency stop via `.planning/orchestration/abort` kill-switch
56
+ - Audit trail in `.planning/orchestration/trace.json` + `.planning/bus/orchestrator.jsonl`
57
+
58
+ **Counterfactual agent runs in isolated git worktree.** Rationale: counterfactual replay inherently involves speculative file modifications. Worktree isolation is the enforcement mechanism — the agent can edit freely in the worktree without affecting the main tree, and the worktree is auto-deleted after the report is written in the main tree. The agent's contract forbids commit/push/merge and paths outside the worktree.
59
+
60
+ **MCP integration is discovery-only in v3.x.** Rationale: auto-invoking external tools (Linear, Slack, databases) without permission gating is a safety risk. Ship the read path (discovery + recommendation) first; revisit auto-invocation when MCP schemas stabilize and per-tool safety review is in place.
61
+
62
+ **Cost instrumentation is non-blocking.** Rationale: observability must never break the primary agent loop. The SubagentStop hook swallows all errors silently. Records with zero tokens (when Claude Code's event payload lacks `usage` data) are logged anyway — presence matters even when cost doesn't resolve.
63
+
64
+ ## Consequences
65
+
66
+ ### Positive
67
+
68
+ - **Shipped 6 user-facing commands in ~1 calendar week** instead of 13 over 15 weeks. Consolidation-first design reduced risk of abandoning mid-way.
69
+ - **Zero breaking changes.** Every feature is additive; `.planning/` gains new subdirectories but no existing file changes shape.
70
+ - **Each command has a clear single purpose.** `/pan:preview` is foresight, `/pan:cost` is observability, `/pan:review-deep` is security, `/pan:knowledge` is retrieval, `/pan:what-if` is counterfactual exploration, `/pan:mcp-bridge` is discovery. No overlap, no "which command do I use?" ambiguity.
71
+ - **Focus system untouched.** Users of `/pan:focus-*` see identical behavior. Spec B v2 features integrate via flags (`--deep-review`) or via read boundaries (cost reads focus-auto telemetry, preview reads roadmap), not by modification.
72
+ - **Safety posture is explicit.** Each new capability has documented boundaries (hierarchical caps, worktree isolation, discovery-only MCP).
73
+
74
+ ### Negative
75
+
76
+ - **`--hierarchical` is Claude + Opus 4.7 only.** Other runtimes silently fall back to flat exec. This is documented but creates a capability gap — users on OpenAI/Gemini/etc. don't get hierarchical orchestration.
77
+ - **MCP bridge is Claude-only.** Other runtimes return empty `source: "empty"` gracefully, but the recommendation feature is unavailable.
78
+ - **Auto cost logging is best-effort.** Claude Code's SubagentStop payload doesn't always carry token counts. Records with zeros are honest but require the user to cross-reference provider billing for exact totals.
79
+ - **Module count grew from 17 to 24.** Surface expansion. Mitigated by: each module has a clear single responsibility, and the module inventory in ARCHITECTURE.md documents each one explicitly.
80
+ - **Spec B v1 artifacts remain in the repo.** `opus_47_extended_features_featureai.md` is marked `status: superseded` with a header banner pointing to v2. We chose preservation over deletion to maintain the design history trail.
81
+
82
+ ### Neutral / Tradeoffs considered
83
+
84
+ - **Why not also ship X-8 watch?** Background monitoring is orthogonal to the Opus 4.7 capability set and doesn't reuse Spec A infrastructure. External cron + `/pan:health` cover 80% of the use case. Ship when a real user demand signal arrives.
85
+ - **Why ship bus.cjs in Wave 1 before any consumer?** Y-7 infrastructure unblocks Y-2 (review-deep audit trail) and `pan-conductor` (orchestrator trace). Shipping the foundation first meant Wave 3 could implement review-deep without first implementing the bus. Separately-testable modules.
86
+ - **Why flat namespace (`/pan:*`) instead of `/pan:adv:*` for v2 items?** Flat is discoverable; namespacing clutters tab-completion. 48 commands across 6 groups is manageable; further growth would warrant reconsidering.
87
+ - **Why consolidate knowledge modes (ask/discuss/playbook) rather than ship three commands?** Single entry point means users don't have to remember which of `/pan:explain` / `/pan:converse` / `/pan:teach` to invoke. Each mode is independently invokable with a subcommand.
88
+
89
+ ## Implementation Notes
90
+
91
+ ### Commit history
92
+
93
+ - `0c8df85` — v3.0.0 Wave 1 (Y-6 cost + Y-7 bus)
94
+ - `1f98394` — v3.1.0 Wave 2 (Y-1 preview)
95
+ - `f3a4451` — v3.2.0 Wave 3 (Y-2 review-deep + Y-3 knowledge)
96
+ - `7faf9b2` — v3.3.0 Wave 4 (Y-4 what-if + Y-5 mcp-bridge)
97
+ - `d391599` — v3.4.0 Wave 5 (`--hierarchical` GA + `--deep-review` wiring + cost hook)
98
+
99
+ ### Cumulative delta (v2.10.0 → v3.4.0)
100
+
101
+ - Tests: 2143 → 2368 (+225)
102
+ - Core modules: 17 → 24 (+7)
103
+ - Agents: 12 → 18 (+6)
104
+ - Commands: 42 → 48 (+6)
105
+ - Hooks: 3 → 4 (+1)
106
+ - Templates: ~22 → 26 (+4)
107
+ - CLI subcommands: ~110 → ~130 (+20)
108
+
109
+ ### Rollback plan
110
+
111
+ Spec B v2 is entirely additive. Rollback strategy if telemetry reveals a regression:
112
+ - Remove the new commands from `commands/pan/` — host runtime sees them disappear on next session
113
+ - Remove the new agents from `agents/` — no agent, no spawn path
114
+ - `hooks/pan-cost-logger.js` — remove via installer's SubagentStop hook cleanup (`panHooks` array)
115
+ - `pan-conductor` + `--hierarchical` flag — unwired if agent missing
116
+ - `.planning/` subdirectories (`metrics/`, `bus/`, `bridge/`, `counterfactuals/`, `conversations/`, `orchestration/`, `reviews/`, `memory/`, `architecture/`) — data preserved; readers tolerate missing directories via `try/catch` in core library
117
+
118
+ No schema changes to `.planning/state.md`, `.planning/roadmap.md`, `.planning/project.md`, or any other file that existed pre-v3.0. Rollback is a commit-level operation, not a data migration.
119
+
120
+ ### Future scope
121
+
122
+ Post-v3.4 work is discretionary. Candidates:
123
+ - X-8 watch (background monitoring)
124
+ - MCP auto-injection into planner context (v3.5+ if schema stabilizes)
125
+ - MCP auto-invocation from executor (v3.5+ with permission gating)
126
+ - `pan-conductor` nesting beyond 2 levels (would require deeper safety tooling)
127
+ - Cross-runtime MCP discovery protocol
128
+ - Generic instrumentation for token capture across runtimes (Gemini, OpenCode, Codex, Copilot — currently zero token visibility)
129
+
130
+ ## Related
131
+
132
+ - [ADR-0023: Opus 4.7 Adoption](ADR-0023-opus-4-7-adoption.md) — baseline Spec A integration this builds on
133
+ - [Spec B v1](../specs/opus_47_extended_features_featureai.md) — original 14-item design (superseded)
134
+ - [Spec B v2](../specs/opus_47_extended_features_v2_featureai.md) — consolidated design (accepted, shipped)
135
+ - [MIGRATION-v2-to-v3.md](../MIGRATION-v2-to-v3.md) — user-facing upgrade guide
136
+ - ADR-0015 (focus-auto runner) — budget ceiling layer reused by hierarchical safety harness
137
+ - ADR-0022 (lifecycle completeness) — pan-reviewer baseline that pan-hardener + pan-meta-reviewer extend
@@ -0,0 +1,129 @@
1
+ # ADR-0025: Behavioral Guardrails Layer (v3.6.0)
2
+
3
+ ## Status
4
+ Accepted (shipped 2026-04-27)
5
+
6
+ ## Context
7
+
8
+ PAN Wizard's structural systems — phases, milestones, focus, plans — are mature, but anti-patterns (silent model swaps, skipping verification, manual scaffolding, scope creep) were addressed implicitly across many workflow files without a single consolidated rules surface. AI agents executing PAN workflows would routinely make context-pressured shortcuts that had to be re-corrected per session: silent model selection drift, skipping `/pan:verify-phase` because "tests passed locally," manually picking focus items instead of letting `focus.cjs` allocate by budget. Each correction was cheap individually; aggregated across sessions, it became the dominant source of rework.
9
+
10
+ Review of Google's `agents-cli` (a CLI + skills package that injects ADK development workflows into Claude Code, Gemini CLI, Codex, and others — see `docs/specs/googlecli_adoption_featureai.md`) surfaced three patterns worth adopting:
11
+
12
+ 1. **A consolidated guardrails reference** — one short file naming the top anti-patterns, code preservation rules, and the stop-the-line regression rule
13
+ 2. **Phase-gated re-read directives** in long workflows — explicit "re-read section X before phase Y" markers that resist context compaction drift
14
+ 3. **A mandatory Phase 0 clarify gate** before scaffolding new work
15
+
16
+ Three other patterns were considered and either deferred or skipped (see "Explicit deferrals" below).
17
+
18
+ ## Decision
19
+
20
+ Ship the behavioral guardrails layer as v3.6.0 — additive only, zero breaking changes. The layer consists of:
21
+
22
+ ### 1. New reference doc: `pan-wizard-core/references/guardrails.md`
23
+
24
+ A single ~58-line doc consolidating:
25
+
26
+ - **Common Shortcuts to Resist** — 5-row table naming anti-patterns with rationale and correct action
27
+ - **Code Preservation Principle** — surgical-edit doctrine; preserve config values, comments, formatting outside the user's explicit target
28
+ - **Stop-the-Line Rule** — regressions halt feature work
29
+ - **Systematic Debugging Sequence** — reproduce → localize → fix one variable → verify → guard
30
+ - **Cross-References** — pointers to `tdd.md`, `verification-patterns.md`, `checkpoints.md`, and the workflows that consume guardrails
31
+
32
+ The reference ships to all 5 runtimes via the existing `references/` install path. No installer logic changes.
33
+
34
+ ### 2. Re-Read Checkpoints in 4 long workflows
35
+
36
+ Each long workflow (`exec-phase.md`, `plan-phase.md`, `verify-phase.md`, `execute-plan.md`) gains a `## Re-Read Checkpoints` section near the top with a 4-row table mapping "before this step" → "re-read this" → "why." Pattern resists context compaction drift across long autonomous sessions.
37
+
38
+ ### 3. Phase 0 Clarify Gate
39
+
40
+ `new-project.md` gets a **MANDATORY** Phase 0 gate with 4 questions (problem / success / scope / constraints) the agent must get answered before scaffolding. `plan-phase.md` gets a lighter "recommended" Phase 0 with 3 phase-scoped questions.
41
+
42
+ ### 4. Workflow + agent cross-references to `guardrails.md`
43
+
44
+ The 4 long workflows and 2 agents (`pan-reviewer`, `pan-planner`) now reference `guardrails.md` in their required-reading or role sections. Agents are instructed to flag Code Preservation violations at high severity.
45
+
46
+ ### Spec adjustment recorded here
47
+
48
+ The original spec (`googlecli_adoption_featureai.md`) listed `focus-exec.md` as the 4th target workflow for Re-Read Checkpoints. `focus-exec.md` is a *command file* (`commands/pan/focus-exec.md`), not a workflow. The 4th workflow target is **`execute-plan.md`** (448 lines), the next-longest workflow after exec-phase, plan-phase, and verify-phase. `focus-exec` as a command will get re-read directives in a future patch if needed; not in v3.6.0.
49
+
50
+ ### Explicit deferrals (documented, not shipped)
51
+
52
+ - **`pan-tools info` command** — overlap with `state json` and `validate health` is high. Deferred to v3.6.1 prototype-first; ship as new command only if prototype shows ≤80% overlap, otherwise fold into `state json --full`.
53
+ - **Frontmatter `requires`/`related` schema** — defer until a concrete consumer (dispatcher precondition checks or doc generator) justifies the 50+ command backfill cost.
54
+ - **LLM-as-judge eval framework** — different problem domain; PAN tests code workflows, not agent behavior. 100+ pt effort with no demand signal.
55
+ - **Tool-level enforcement of Phase 0** — workflow text is the right enforcement layer; tool-level blocks add brittleness.
56
+ - **`npx skills add` distribution model** — PAN's installer is feature-complete; switching is cosmetic.
57
+
58
+ ## Consequences
59
+
60
+ ### Positive
61
+
62
+ - **One consolidated rules surface.** AI agents have a single grep-friendly file to consult instead of inferring rules from scattered workflow prose.
63
+ - **Zero breaking changes.** All edits are additive; no existing command, workflow, or test changes behavior. Existing v3.5.x installs upgrading to v3.6.0 receive new files via standard `pan update`.
64
+ - **Compounds across runtimes.** `references/` ships identically to all 5 runtime install paths (`.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.github/`). One file, five runtimes, zero installer changes.
65
+ - **Compounds across sessions.** The cost of writing guardrails.md is one-time; the benefit of resisting silent model swaps and skipped verification accrues every future AI session.
66
+ - **Test count grew.** 2567 → 2588 (+21 new tests: 16 unit across 4 new test files + 5 scenario across all 5 runtimes).
67
+ - **Pattern is reusable.** The `references/<topic>.md` + workflow-cross-reference pattern can host future behavioral layers without growing the workflow surface.
68
+
69
+ ### Negative
70
+
71
+ - **AI agents may treat guardrails as advisory.** Workflow text is the enforcement layer; an agent that decides to skip Phase 0 or ignore "Stop-the-Line" cannot be hard-blocked at the tool level. Mitigation: workflow text uses "MANDATORY, do not skip" and "Do NOT proceed" framings. Agents that have ingested guardrails.md and the workflow consistently follow it; agents that haven't won't.
72
+ - **Re-read directives feel naggy if read literally.** The 4-row table at the top of each long workflow could be ignored by agents that skim. Net positive even when ignored — agents that *do* re-read avoid drift.
73
+ - **Phase 0 gate adds friction for small projects.** `new-project.md`'s 4-question gate is overhead for trivial scaffolding. Mitigation: `--auto` mode short-circuits the gate when a PRD/idea document is provided. The gate is meant for the 80% case where users haven't yet articulated requirements.
74
+ - **Spec/implementation mismatch on workflow target.** The original spec named `focus-exec.md` as a workflow target, but it's a command. Documented above; minor.
75
+ - **Maintenance debt.** `guardrails.md` will drift out of sync with actual workflows over time. Mitigation: future `/pan:doc-audit` runs should include guardrails references in their checks.
76
+
77
+ ### Neutral / Tradeoffs considered
78
+
79
+ - **Why not enforce guardrails at tool-level (e.g., `pan-tools` blocks commits with "skip-tests" flags)?** Workflow text is the right enforcement layer. Tool-level blocks become brittleness when an agent encounters a legitimate edge case the tool author didn't anticipate. AI judgment + textual rules > rigid tool-level gates.
80
+ - **Why ≤80 lines for guardrails.md?** Context budget. The doc is referenced by ~6 workflow/agent files. If it bloats to 200 lines, it crowds out plan content in the agent's context window. 58 lines proved sufficient for the rule set; future additions should preserve this discipline.
81
+ - **Why a single doc instead of per-rule files?** Discoverability. One filename, one URL, one path to remember. Splitting (`code-preservation.md`, `stop-the-line.md`, `shortcuts.md`) fragments and dilutes the surface.
82
+ - **Why include `pan-reviewer` and `pan-planner` but not other agents?** These two are the highest-leverage entry points: planner generates the work, reviewer validates it. Other agents (`pan-executor`, `pan-tester`, etc.) inherit guardrails transitively via the workflows that spawn them. Adding the reference to all 20 agents would dilute the value.
83
+
84
+ ## Implementation Notes
85
+
86
+ ### Files added (8)
87
+ - `pan-wizard-core/references/guardrails.md` — the anchor doc
88
+ - `tests/guardrails.test.cjs` — 4 unit tests
89
+ - `tests/workflows-checkpoints.test.cjs` — 4 unit tests
90
+ - `tests/guardrails-references.test.cjs` — 6 unit tests
91
+ - `tests/phase0-gate.test.cjs` — 2 unit tests
92
+ - `tests/scenarios/guardrails-installed.test.cjs` — 5 scenario tests (one per runtime)
93
+ - `docs/decisions/ADR-0025-behavioral-guardrails-layer.md` — this ADR
94
+ - `docs/specs/googlecli_adoption_featureai.md` — the source spec (committed alongside)
95
+
96
+ ### Files modified (9)
97
+ - `pan-wizard-core/workflows/exec-phase.md` — Re-Read Checkpoints + guardrails reference
98
+ - `pan-wizard-core/workflows/plan-phase.md` — Re-Read Checkpoints + guardrails reference + Phase 0 (recommended)
99
+ - `pan-wizard-core/workflows/verify-phase.md` — Re-Read Checkpoints + guardrails reference
100
+ - `pan-wizard-core/workflows/execute-plan.md` — Re-Read Checkpoints + guardrails reference
101
+ - `pan-wizard-core/workflows/new-project.md` — Phase 0 (MANDATORY) + guardrails reference
102
+ - `agents/pan-reviewer.md` — guardrails reference + flag-Code-Preservation directive
103
+ - `agents/pan-planner.md` — guardrails reference + must-enforce-in-deviation-rules directive
104
+ - `package.json` — version 3.5.2 → 3.6.0
105
+ - `CHANGELOG.md` — v3.6.0 entry
106
+
107
+ ### Test deltas
108
+ - Unit: 2302 → 2318 (+16, 4 new test files)
109
+ - Scenario: 265 → 270 (+5, one per runtime)
110
+ - Total: **2567 → 2588** (+21)
111
+
112
+ ### Rollback plan
113
+ The layer is entirely additive. Rollback strategy if telemetry reveals a regression:
114
+ - Remove `references/guardrails.md` — workflows referencing it will resolve to "file not found" but won't fail the workflow logic
115
+ - Remove the `## Re-Read Checkpoints` and `## Phase 0` sections from the 5 workflow files — they're plain markdown, no behavior depends on them
116
+ - Remove the `**Read also:**` lines from the 2 agent files
117
+ - Remove the 5 new test files
118
+ - No schema or manifest changes; rollback is a commit-level revert
119
+
120
+ ### References
121
+ - Source spec: `docs/specs/googlecli_adoption_featureai.md` (created 2026-04-27)
122
+ - Ancestor pattern: `docs/specs/ai_drift_prevention_featureai.md` (Mar 2026)
123
+ - External pattern source: Google `agents-cli` workflow SKILL.md (`d:\googlecli\agents-cli\skills\google-agents-cli-workflow\SKILL.md` lines 242-325)
124
+
125
+ ## Future scope
126
+
127
+ - **v3.6.1 prototype**: `pan-tools info` self-discovery command — measure overlap with `state json`, ship or fold accordingly
128
+ - **v3.7+**: Frontmatter `requires`/`related` schema — only if a concrete consumer (dispatcher precondition checks or auto-generated docs) emerges
129
+ - **Doc-audit integration**: future `/pan:doc-audit` runs should verify guardrails references resolve and the 5 listed shortcuts are still the right top-5