pan-wizard 3.36.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 (314) hide show
  1. package/CHANGELOG.md +3645 -0
  2. package/README.md +36 -48
  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 +1 -2
  8. package/agents/pan-document_code.md +1 -2
  9. package/agents/pan-hardener.md +2 -3
  10. package/agents/pan-integration-checker.md +1 -2
  11. package/agents/pan-knowledge.md +1 -2
  12. package/agents/pan-meta-reviewer.md +3 -3
  13. package/agents/pan-optimizer.md +4 -4
  14. package/agents/pan-phase-researcher.md +79 -488
  15. package/agents/pan-plan-checker.md +12 -2
  16. package/agents/pan-planner.md +10 -6
  17. package/agents/pan-previewer.md +1 -2
  18. package/agents/pan-project-researcher.md +70 -499
  19. package/agents/pan-release.md +1 -1
  20. package/agents/pan-reviewer.md +9 -3
  21. package/agents/pan-roadmapper.md +12 -7
  22. package/agents/pan-verifier.md +7 -2
  23. package/bin/install-lib.cjs +134 -14
  24. package/bin/install.js +59 -12
  25. package/commands/pan/army.md +1 -1
  26. package/commands/pan/autodev.md +76 -0
  27. package/commands/pan/exec-phase.md +3 -4
  28. package/commands/pan/focus-auto.md +14 -7
  29. package/commands/pan/focus-design.md +4 -5
  30. package/commands/pan/focus-docs.md +24 -0
  31. package/commands/pan/learn.md +13 -6
  32. package/commands/pan/milestone-audit.md +8 -1
  33. package/commands/pan/milestone-done.md +10 -5
  34. package/commands/pan/milestone-new.md +2 -2
  35. package/commands/pan/new-project.md +15 -12
  36. package/commands/pan/plan-phase.md +15 -9
  37. package/commands/pan/quick.md +1 -1
  38. package/commands/pan/review-deep.md +11 -5
  39. package/commands/pan/settings.md +6 -0
  40. package/commands/pan/verify-phase.md +6 -2
  41. package/docs/AGENTS.md +917 -0
  42. package/docs/ARCHITECTURE.md +1054 -0
  43. package/docs/CLI-REFERENCE.md +4582 -0
  44. package/docs/COMPARISON.md +116 -0
  45. package/docs/DEVELOPMENT.md +490 -0
  46. package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
  47. package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
  48. package/docs/EXAMPLES.md +584 -0
  49. package/docs/FAQ.md +254 -0
  50. package/docs/FIELD-HARVEST-2026-07.md +88 -0
  51. package/docs/FIELD-REPORT-army-2026-06.md +121 -0
  52. package/docs/HOOKS.md +638 -0
  53. package/docs/IMPROVEMENT-TODO.md +246 -0
  54. package/docs/INTERNALS.md +485 -0
  55. package/docs/MIGRATION-v2-to-v3.md +258 -0
  56. package/docs/SECURITY-HARDENING.md +230 -0
  57. package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
  58. package/docs/SKILLS-FULL-TEXT.md +9685 -0
  59. package/docs/SKILLS-REFERENCE.md +1037 -0
  60. package/docs/TROUBLESHOOTING.md +1084 -0
  61. package/docs/USER-GUIDE.md +1437 -0
  62. package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
  63. package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
  64. package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
  65. package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
  66. package/docs/audits/OUTSTANDING-2026-08.md +275 -0
  67. package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
  68. package/docs/branding/README-brand-draft.md +119 -0
  69. package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
  70. package/docs/branding/handoff/README-brand-draft.md +119 -0
  71. package/docs/branding/handoff/image-prompts.md +46 -0
  72. package/docs/branding/image-prompts.md +46 -0
  73. package/docs/branding/nano-banana-prompts.txt +60 -0
  74. package/docs/context-monitor.md +13 -0
  75. package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
  76. package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
  77. package/docs/decisions/ADR-0003-smart-execution.md +84 -0
  78. package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
  79. package/docs/decisions/ADR-0005-command-naming.md +80 -0
  80. package/docs/decisions/ADR-0006-focus-commands.md +101 -0
  81. package/docs/decisions/ADR-0007-ship-v1.md +73 -0
  82. package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
  83. package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
  84. package/docs/decisions/ADR-0010-standards-integration.md +79 -0
  85. package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
  86. package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
  87. package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
  88. package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
  89. package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
  90. package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
  91. package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
  92. package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
  93. package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
  94. package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
  95. package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
  96. package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
  97. package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
  98. package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
  99. package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
  100. package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
  101. package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
  102. package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
  103. package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
  104. package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
  105. package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
  106. package/docs/decisions/ADR-0032-squad-model.md +64 -0
  107. package/docs/decisions/ADR-0033-army-campaign.md +40 -0
  108. package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
  109. package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
  110. package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
  111. package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
  112. package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
  113. package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
  114. package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
  115. package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
  116. package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
  117. package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
  118. package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
  119. package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
  120. package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
  121. package/docs/decisions/ADR-0047-pan-harness.md +76 -0
  122. package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
  123. package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
  124. package/docs/specs/ai_drift_prevention_featureai.md +286 -0
  125. package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
  126. package/docs/specs/command_naming_optimization_featureai.md +930 -0
  127. package/docs/specs/comp_analysis_markdown_v1.md +149 -0
  128. package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
  129. package/docs/specs/contributors_attribution_index_featureai.md +476 -0
  130. package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
  131. package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
  132. package/docs/specs/custom-skills-assessment.md +461 -0
  133. package/docs/specs/deployment_audit_findings_featureai.md +243 -0
  134. package/docs/specs/doc_code_link_graph_featureai.md +253 -0
  135. package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
  136. package/docs/specs/e2e_visual_testing_featureai.md +615 -0
  137. package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
  138. package/docs/specs/evidence-loop-plan.md +76 -0
  139. package/docs/specs/evidence_loop_featureai.md +497 -0
  140. package/docs/specs/focus-auto-optimize-category.md +449 -0
  141. package/docs/specs/focus-auto-optimize-superplan.md +188 -0
  142. package/docs/specs/focus_auto_runner_featureai.md +1102 -0
  143. package/docs/specs/focus_design_v2_featureai.md +197 -0
  144. package/docs/specs/focus_sync_v2_featureai.md +202 -0
  145. package/docs/specs/git_integration_overhaul_featureai.md +326 -0
  146. package/docs/specs/glm_zai_provider_featureai.md +200 -0
  147. package/docs/specs/googlecli_adoption_featureai.md +661 -0
  148. package/docs/specs/help_commands_rewrite_featureai.md +860 -0
  149. package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
  150. package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
  151. package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
  152. package/docs/specs/investigations/README.md +31 -0
  153. package/docs/specs/investigations/digests/2026-09-28.md +47 -0
  154. package/docs/specs/investigations/digests/2026-10-08.md +62 -0
  155. package/docs/specs/investigations/digests/2026-10-10.md +61 -0
  156. package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
  157. package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
  158. package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
  159. package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
  160. package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
  161. package/docs/specs/lifecycle_completeness_featureai.md +754 -0
  162. package/docs/specs/local-first-ci.md +42 -0
  163. package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
  164. package/docs/specs/market-delta-2026-09-superplan.md +310 -0
  165. package/docs/specs/market-ideas-2026-09.md +131 -0
  166. package/docs/specs/market-ideas-2026-10.md +428 -0
  167. package/docs/specs/market-ideas-ledger.md +177 -0
  168. package/docs/specs/memory-optimization-2026-10.md +285 -0
  169. package/docs/specs/multi-track-planning-roots.md +143 -0
  170. package/docs/specs/multi_model_routing_featureai.md +687 -0
  171. package/docs/specs/multi_model_routing_superplan.md +197 -0
  172. package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
  173. package/docs/specs/opus_47_extended_features_featureai.md +363 -0
  174. package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
  175. package/docs/specs/pan_focus_commands_featureai.md +2336 -0
  176. package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
  177. package/docs/specs/product-excellence-superplan.md +315 -0
  178. package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
  179. package/docs/specs/production_deployment_readiness_featureai.md +433 -0
  180. package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
  181. package/docs/specs/real_test_enforcement_featureai.md +213 -0
  182. package/docs/specs/reality-check-2026-09-superplan.md +362 -0
  183. package/docs/specs/right-sized-ceremony.md +74 -0
  184. package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
  185. package/docs/specs/self_improvement_loop_featureai.md +875 -0
  186. package/docs/specs/skill-aligned-decomposition.md +155 -0
  187. package/docs/specs/standards_integration_featureai.md +833 -0
  188. package/docs/specs/testing-system-redesign-2026-09.md +267 -0
  189. package/docs/specs/user_reality_testing_system_featureai.md +788 -0
  190. package/docs/specs/watch-triggers.json +22 -0
  191. package/docs/specs/workflow-integration-redesign.md +742 -0
  192. package/docs/specs/workflow_state_consistency_featureai.md +183 -0
  193. package/hooks/dist/pan-context-monitor.js +9 -2
  194. package/hooks/dist/pan-cost-logger.js +5 -0
  195. package/hooks/dist/pan-guard.js +28 -5
  196. package/hooks/dist/pan-stop-guard.js +9 -9
  197. package/hooks/dist/pan-trace-logger.js +5 -0
  198. package/package.json +10 -2
  199. package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
  200. package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
  201. package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
  202. package/pan-wizard-core/bin/lib/ci.cjs +143 -0
  203. package/pan-wizard-core/bin/lib/commands.cjs +1 -1
  204. package/pan-wizard-core/bin/lib/config.cjs +31 -2
  205. package/pan-wizard-core/bin/lib/constants.cjs +27 -1
  206. package/pan-wizard-core/bin/lib/core.cjs +22 -10
  207. package/pan-wizard-core/bin/lib/cost.cjs +14 -4
  208. package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
  209. package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
  210. package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
  211. package/pan-wizard-core/bin/lib/findings.cjs +34 -4
  212. package/pan-wizard-core/bin/lib/focus.cjs +1 -1
  213. package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
  214. package/pan-wizard-core/bin/lib/init.cjs +7 -2
  215. package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
  216. package/pan-wizard-core/bin/lib/merge.cjs +50 -0
  217. package/pan-wizard-core/bin/lib/mutate.cjs +16 -5
  218. package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
  219. package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
  220. package/pan-wizard-core/bin/lib/phase.cjs +48 -4
  221. package/pan-wizard-core/bin/lib/plan-lint.cjs +150 -1
  222. package/pan-wizard-core/bin/lib/preview.cjs +23 -4
  223. package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
  224. package/pan-wizard-core/bin/lib/research-lint.cjs +150 -3
  225. package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
  226. package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
  227. package/pan-wizard-core/bin/lib/runner.cjs +2 -16
  228. package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
  229. package/pan-wizard-core/bin/lib/squads.cjs +1 -1
  230. package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
  231. package/pan-wizard-core/bin/lib/uat.cjs +149 -0
  232. package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
  233. package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
  234. package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
  235. package/pan-wizard-core/bin/lib/verify-red.cjs +37 -1
  236. package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
  237. package/pan-wizard-core/bin/lib/verify.cjs +59 -4
  238. package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
  239. package/pan-wizard-core/bin/pan-tools.cjs +168 -27
  240. package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
  241. package/pan-wizard-core/references/continuation-format.md +3 -3
  242. package/pan-wizard-core/references/guardrails.md +1 -1
  243. package/pan-wizard-core/references/model-profiles.md +2 -3
  244. package/pan-wizard-core/references/questioning.md +24 -0
  245. package/pan-wizard-core/references/ui-brand.md +4 -6
  246. package/pan-wizard-core/references/verdict-contract.md +2 -1
  247. package/pan-wizard-core/templates/config.json +5 -1
  248. package/pan-wizard-core/templates/debug.md +1 -0
  249. package/pan-wizard-core/templates/discovery.md +2 -2
  250. package/pan-wizard-core/templates/requirements.md +9 -0
  251. package/pan-wizard-core/workflows/add-phase.md +4 -6
  252. package/pan-wizard-core/workflows/assumptions.md +19 -1
  253. package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
  254. package/pan-wizard-core/workflows/discuss-phase.md +4 -2
  255. package/pan-wizard-core/workflows/exec-lean.md +69 -0
  256. package/pan-wizard-core/workflows/exec-phase.md +36 -8
  257. package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
  258. package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
  259. package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
  260. package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
  261. package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
  262. package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
  263. package/pan-wizard-core/workflows/health.md +6 -0
  264. package/pan-wizard-core/workflows/help.md +31 -53
  265. package/pan-wizard-core/workflows/insert-phase.md +4 -6
  266. package/pan-wizard-core/workflows/learn.md +3 -3
  267. package/pan-wizard-core/workflows/milestone-audit.md +2 -2
  268. package/pan-wizard-core/workflows/milestone-new.md +38 -95
  269. package/pan-wizard-core/workflows/new-project.md +96 -258
  270. package/pan-wizard-core/workflows/optimize.md +107 -5
  271. package/pan-wizard-core/workflows/phase-tests.md +10 -0
  272. package/pan-wizard-core/workflows/plan-phase.md +86 -43
  273. package/pan-wizard-core/workflows/profile.md +50 -0
  274. package/pan-wizard-core/workflows/progress.md +10 -0
  275. package/pan-wizard-core/workflows/quick.md +34 -43
  276. package/pan-wizard-core/workflows/research-phase.md +118 -40
  277. package/pan-wizard-core/workflows/resume-project.md +18 -2
  278. package/pan-wizard-core/workflows/settings.md +21 -24
  279. package/pan-wizard-core/workflows/todo-check.md +6 -2
  280. package/pan-wizard-core/workflows/transition.md +22 -4
  281. package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
  282. package/pan-wizard-core/workflows/update.md +1 -1
  283. package/pan-wizard-core/workflows/verify-phase.md +2 -2
  284. package/scripts/build-agent-plugin.js +35 -15
  285. package/scripts/build-plugin.js +10 -1
  286. package/scripts/deprecate-old-versions.js +70 -3
  287. package/scripts/generate-skills-docs.py +1 -1
  288. package/scripts/git-hooks/pre-push +27 -0
  289. package/scripts/install-git-hooks.js +7 -5
  290. package/scripts/install-pre-push.cjs +38 -0
  291. package/scripts/land.cjs +151 -0
  292. package/scripts/local-ci.cjs +501 -0
  293. package/scripts/local-schedule.cjs +277 -0
  294. package/scripts/prompt-lint.cjs +32 -0
  295. package/scripts/prompt-rules.cjs +156 -0
  296. package/scripts/run-tests.cjs +7 -1
  297. package/scripts/test-quality-lint.cjs +3 -3
  298. package/scripts/test-surface.cjs +9 -2
  299. package/agents/pan-research-synthesizer.md +0 -246
  300. package/commands/pan/audit-deployment.md +0 -386
  301. package/commands/pan/dashboard.md +0 -22
  302. package/commands/pan/discord.md +0 -19
  303. package/commands/pan/mcp-bridge.md +0 -143
  304. package/commands/pan/milestone-cleanup.md +0 -19
  305. package/commands/pan/milestone-gaps.md +0 -35
  306. package/commands/pan/optimize.md +0 -115
  307. package/commands/pan/profile.md +0 -76
  308. package/commands/pan/research-phase.md +0 -189
  309. package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
  310. package/pan-wizard-core/templates/research-project/architecture.md +0 -210
  311. package/pan-wizard-core/templates/research-project/features.md +0 -153
  312. package/pan-wizard-core/templates/research-project/pitfalls.md +0 -206
  313. package/pan-wizard-core/templates/research-project/stack.md +0 -126
  314. package/pan-wizard-core/templates/research-project/summary.md +0 -170
@@ -0,0 +1,788 @@
1
+ # User Reality Testing System — Feature Specification
2
+
3
+ **Mode:** `--internal` | **Date:** 2026-03-04 | **ADR:** ADR-0018
4
+
5
+ ---
6
+
7
+ ## Phase 0: Problem Framing & Demand Validation
8
+
9
+ ### 0.1 Problem Statement
10
+
11
+ PAN Wizard's 1,314 unit/integration tests validate individual modules in isolation, but they do not replicate how real users interact with the tool across 5 runtimes (Claude Code, OpenCode, Gemini CLI, Codex, Copilot CLI) on 3 platforms (Windows, Mac, Linux). The gap between "tests pass" and "users report it works" manifests as: installer path failures in containers, multi-word argument breakage in real shells, runtime-specific command syntax mismatches, and state corruption during interrupted sessions. Users discover these bugs only after installation — there is no automated system that simulates a user installing PAN, running a workflow end-to-end, and verifying the output matches expectations across all environments.
12
+
13
+ ### 0.2 Demand Evidence
14
+
15
+ | Evidence Type | Source | Finding |
16
+ |--------------|--------|---------|
17
+ | Personal pain (user-stated) | This conversation | "I am struggling to test it and the testing done is not replicating user testing, would like to design a testing system that can actually replicate on all environment the user testing and feedback to close the loop" |
18
+ | Known deferred items | MEMORY.md | "parseJsonc unit tests: blocked because installer is script-only", "Health --full: M effort, shelling out to npm test risky" |
19
+ | Architecture gap | Codebase investigation | 42 test files test pan-tools CLI in temp dirs, but 0 tests exercise: shell argument parsing, runtime command discovery, hook execution, agent delegation, or multi-step user workflows end-to-end |
20
+ | Cross-platform gap | CI analysis | No CI workflow file found; tests run only on developer's local machine (Windows); Mac/Linux coverage = 0 |
21
+
22
+ ### 0.2.5 Before/After State
23
+
24
+ **Current behavior (before):**
25
+ - `npm test` runs 1,314 tests via `node --test tests/*.test.cjs`
26
+ - Tests call `runPanTools(args, cwd)` which uses `execSync('node pan-tools.cjs args')`
27
+ - E2E install tests run the installer with `--claude --local`, verify file structure, then run commands
28
+ - 5 runtime-specific install tests verify directory structure and file conversion
29
+ - All tests run on a single platform (developer's Windows machine)
30
+ - No test validates: shell argument quoting, hook firing, agent-to-CLI round-trips, multi-command workflows, or platform-specific path behavior
31
+
32
+ **Desired behavior (after):**
33
+ - A "scenario runner" that executes multi-step user workflows (install → init → plan → exec → verify) against real runtime directories
34
+ - Platform matrix testing via CI (Windows, Ubuntu, macOS)
35
+ - Runtime matrix testing: all 5 runtimes verified per commit
36
+ - Feedback loop: test failures produce structured diagnostic output identifying the exact runtime/platform/step that broke
37
+ - Installer internal functions testable via extracted module (not script-only)
38
+
39
+ **Delta:**
40
+ - New `tests/scenarios/` directory with multi-step workflow test files
41
+ - New test helper: `createScenarioRunner(runtime, platform)` for structured scenario execution
42
+ - New `pan-tools test-scenario` command for running scenarios from CLI
43
+ - CI workflow running tests on 3 platforms x core runtime coverage
44
+ - Installer refactor: extract testable functions to `bin/install-lib.cjs`
45
+
46
+ ### 0.3 Scope Definition
47
+
48
+ | In Scope | Out of Scope (and why) |
49
+ |----------|------------------------|
50
+ | Multi-step workflow scenario tests | Network API testing (BraveSearch, etc.) — external dependency |
51
+ | Platform matrix CI (Win/Mac/Linux) | Interactive readline prompts — requires stdin mocking library (runtime dep) |
52
+ | Runtime matrix tests (all 5 runtimes) | Performance benchmarks — separate concern, not user-facing |
53
+ | Installer function extraction for testability | Installer UI redesign — separate feature, would bloat scope |
54
+ | Structured diagnostic output on failure | Docker/container testing — infrastructure dependency, CI covers platforms |
55
+ | Hook execution verification | Agent LLM response testing — non-deterministic, can't unit test |
56
+ | State transition integrity tests | |
57
+ | Scenario replay from recorded user sessions | |
58
+
59
+ ### 0.4 Success Criteria
60
+
61
+ | ID | Criterion | Verification Method | Pass Condition |
62
+ |----|-----------|-------------------|----------------|
63
+ | SC-1 | Scenario runner executes multi-step workflows | `npm test` includes scenario tests | All scenario tests pass |
64
+ | SC-2 | All 5 runtimes have install+run scenario coverage | Grep for runtime names in scenario tests | >= 1 scenario per runtime |
65
+ | SC-3 | No regression in existing tests | `npm test` | All tests pass, count >= 1314 |
66
+ | SC-4 | CI runs on Windows, Mac, and Linux | `.github/workflows/ci.yml` | Matrix build passing on 3 OS |
67
+ | SC-5 | Failure diagnostics include runtime, platform, step | Test output format check | Error output contains `{runtime, platform, step, expected, actual}` |
68
+ | SC-6 | Installer functions are independently testable | `require('bin/install-lib.cjs')` succeeds | Exports >= 10 functions |
69
+
70
+ ### 0.5 User Stories
71
+
72
+ ```
73
+ As a PAN Wizard maintainer, I want scenario-based tests that simulate real user workflows,
74
+ so that I catch integration bugs before users do, instead of relying on isolated unit tests.
75
+ ```
76
+
77
+ ```
78
+ As a PAN Wizard contributor, I want CI that runs tests on all 3 platforms,
79
+ so that I know my changes work cross-platform, instead of discovering Windows/Mac issues post-release.
80
+ ```
81
+
82
+ ```
83
+ As a PAN Wizard user on Codex CLI, I want confidence that my runtime is tested,
84
+ so that skill installation and invocation work correctly, instead of finding broken commands after install.
85
+ ```
86
+
87
+ ```
88
+ As a PAN Wizard maintainer, I want structured failure diagnostics,
89
+ so that I can quickly identify which runtime/platform/step failed, instead of reading raw test output.
90
+ ```
91
+
92
+ ### 0.6 Cannibalization Check
93
+
94
+ | Existing Command/Agent | Overlap? | Impact |
95
+ |-----------------------|----------|--------|
96
+ | `pan-tools validate health` | Partial | Health checks validate file structure, not workflow execution. New scenarios cover workflows; health stays for quick structural checks. |
97
+ | `e2e-install.test.cjs` | Partial | Current E2E tests verify structure + basic commands. New scenarios ADD multi-step workflows on top. E2E tests stay as fast structural validation. |
98
+ | `verify-phase` command | None | Verifies phase artifacts, not test infrastructure. |
99
+ | `pan:phase-tests` | None | Generates tests for user project phases, not PAN's own testing. |
100
+
101
+ No full overlap — this is new infrastructure.
102
+
103
+ ### 0.7 Cognitive Load Assessment
104
+
105
+ | Metric | Before | After | Delta |
106
+ |--------|--------|-------|-------|
107
+ | Commands a new user must learn | 0 (internal) | 0 (internal) | 0 |
108
+ | New concepts introduced | 0 | 1 (scenario runner) | +1 |
109
+ | Score | — | — | neutral (0) — internal tool, no user-facing complexity |
110
+
111
+ ---
112
+
113
+ ## Phase 0.8: Autonomous Codebase Investigation — Summary
114
+
115
+ ### Files Read & Patterns Discovered
116
+
117
+ **Test Infrastructure:**
118
+ - `tests/helpers.cjs`: 3 functions (`runPanTools`, `createTempProject`, `cleanup`) — minimal but consistent
119
+ - `runPanTools` uses `execSync` with `stdio: ['pipe', 'pipe', 'pipe']` — captures stdout/stderr separately
120
+ - All 42 test files follow identical lifecycle: `beforeEach(createTempProject)`, `afterEach(cleanup)`
121
+ - JSON output parsed inline: `const output = JSON.parse(result.output)`
122
+
123
+ **E2E Install Pattern (e2e-install.test.cjs):**
124
+ - Single `before()` installs once, all tests share the same installed directory
125
+ - `runInstalled(args, cwd)` — identical to `runPanTools` but uses installed path
126
+ - Tests verify: directory structure, file existence, then CLI commands from installed location
127
+
128
+ **Multi-Runtime Install Tests (opencode/gemini/codex/copilot):**
129
+ - Each test file: `before()` installs with runtime flag, verifies directory structure
130
+ - Tests verify: config dir name, command file format, tool conversion, agent conversion
131
+ - No test runs a command from the installed runtime location (structure-only)
132
+
133
+ **Critical Gap Discovered:**
134
+ - Runtime install tests verify FILES exist but never RUN commands from the installed location
135
+ - Only `e2e-install.test.cjs` (Claude) runs commands from installed path — other 4 runtimes don't
136
+ - No test validates that converted TOML/SKILL.md files are syntactically valid
137
+ - No test validates hook execution (hooks require event triggers that don't exist in test env)
138
+
139
+ ### Impact Analysis
140
+
141
+ | Affected Area | Specific Item | How Affected | Risk Level |
142
+ |--------------|---------------|-------------|------------|
143
+ | Core module | None — tests are additive | No changes to core | Low |
144
+ | Test helpers | `tests/helpers.cjs` | New `createScenarioRunner()` function added | Medium |
145
+ | Installer | `bin/install.js` | Extract functions to `bin/install-lib.cjs` | High |
146
+ | CI | `.github/workflows/ci.yml` | New file (or update if exists) | Medium |
147
+ | Test directory | `tests/scenarios/` | New directory with scenario test files | Low |
148
+ | Constants | `constants.cjs` | New test-related constants possible | Low |
149
+ | Dispatcher | `pan-tools.cjs` | New `test-scenario` subcommand (optional) | Low |
150
+
151
+ ---
152
+
153
+ ## Phase 1: Internal Reconnaissance — Summary
154
+
155
+ ### 1.1 Existing Capabilities Inventory
156
+
157
+ | Capability | Status | Location | Relevance |
158
+ |------------|--------|----------|-----------|
159
+ | Unit test framework | Complete | `node:test` + `node:assert/strict` | Foundation — extend, don't replace |
160
+ | CLI integration testing | Complete | `runPanTools()` helper | Reuse for scenario steps |
161
+ | E2E install + run (Claude) | Complete | `e2e-install.test.cjs` | Template for multi-runtime E2E |
162
+ | Runtime install verification | Partial (structure only) | `*-install.test.cjs` | Extend to run commands |
163
+ | CI pipeline | Missing | No `.github/workflows/` in repo | Must create |
164
+ | Diagnostic output | Missing | — | Must design |
165
+ | Multi-step workflow tests | Missing | — | Core deliverable |
166
+ | Installer function testing | Blocked | `bin/install.js` is script-only | Must extract |
167
+
168
+ ### 1.3 Convention Enforcement Checklist
169
+
170
+ - [x] Functions named `cmd<Module><Action>(cwd, raw, ...args)` — scenario runner won't be a pan-tools command; test helper only
171
+ - [x] File reads use try-catch pattern — test helpers already use this
172
+ - [x] JSON output via `output(data, raw, humanLabel)` — N/A for test infrastructure
173
+ - [x] CommonJS only (`.cjs` with `require()`) — all test files are `.cjs`
174
+ - [x] Zero runtime dependencies — test infra uses only `node:test`, `node:assert`, `node:fs`, `node:child_process`
175
+ - [x] Functions stay within complexity budget — 50 lines max
176
+ - [x] `fileAccessible()` instead of existsSync — will use in new test helpers
177
+
178
+ ### 1.4 Dependency & Integration Map
179
+
180
+ ```
181
+ [Scenario Runner (new)]
182
+ ├── depends on: tests/helpers.cjs (runPanTools, createTempProject, cleanup)
183
+ ├── depends on: bin/install.js (installer execution)
184
+ ├── depends on: bin/install-lib.cjs (NEW — extracted installer functions)
185
+ ├── depends on: pan-wizard-core/bin/pan-tools.cjs (CLI under test)
186
+ ├── extends: e2e-install.test.cjs (pattern for installed-path execution)
187
+ ├── conflicts with: nothing
188
+ └── enables: CI matrix testing, regression detection, runtime certification
189
+ ```
190
+
191
+ No circular dependencies.
192
+
193
+ ---
194
+
195
+ ## Phase 3: Strategic Analysis
196
+
197
+ ### 3.1 Blue Ocean Four Actions Framework
198
+
199
+ | Action | Question | Decisions |
200
+ |--------|----------|-----------|
201
+ | **ELIMINATE** | What testing complexity can we drop? | Eliminate need for Docker/containers — CI matrix covers platforms. Eliminate mock-heavy approach — test real CLI execution. |
202
+ | **REDUCE** | What test boilerplate should decrease? | Reduce per-test setup cost with shared scenario fixtures. Reduce diagnostic noise with structured failure output. |
203
+ | **RAISE** | What should be raised above current state? | Raise confidence in multi-runtime compatibility. Raise cross-platform test coverage from 1 to 3 platforms. Raise workflow coverage from unit-level to user-journey-level. |
204
+ | **CREATE** | What testing capability doesn't exist yet? | Create scenario-based testing that simulates full user workflows. Create runtime certification matrix. Create structured diagnostic feedback loop. |
205
+
206
+ ### 3.2 Wardley Evolution Assessment
207
+
208
+ ```
209
+ Genesis ──── Custom-Built ──── Product ──── Commodity
210
+ ^
211
+ [User Reality Testing]
212
+ ```
213
+
214
+ User-journey testing for multi-runtime CLI tools is **custom-built** territory. No off-the-shelf framework handles "install a CLI tool for 5 different AI assistants, verify each one works." In 2-3 years, as the AI coding tool ecosystem matures, shared test harnesses may emerge — but today this must be purpose-built.
215
+
216
+ ### 3.3 Strategic Moat Analysis
217
+
218
+ | Moat Type | Contribution | Score (0-5) |
219
+ |-----------|-------------|-------------|
220
+ | **Context Engineering** | Tests validate that context (commands, agents) is correctly formatted per runtime | 3 |
221
+ | **Cross-Platform** | CI matrix ensures Win/Mac/Linux compatibility — direct moat strengthener | 5 |
222
+ | **Developer Experience** | Faster bug detection = fewer broken releases = happier users | 4 |
223
+ | **Zero Dependencies** | Test infra uses only Node.js built-ins — maintains constraint | 5 |
224
+ | **State Persistence** | Scenario tests validate state transitions across multi-step workflows | 3 |
225
+ | **Verification Quality** | Runtime certification gives measurable quality signal | 4 |
226
+ | **Total** | | **24/30** |
227
+
228
+ ### 3.4 Strategic Recommendation
229
+
230
+ **Build it.** PAN Wizard supports 5 runtimes on 3 platforms — that's a 15-cell matrix with only 1 cell currently tested (Claude on Windows). The user explicitly reports testing doesn't replicate real usage. This infrastructure is the highest-leverage investment possible: it protects every future feature from cross-runtime regression and closes the feedback loop between development and user experience. The unique angle is scenario-based multi-runtime certification — no competing tool tests like this because no competing tool supports 5 runtimes from a single codebase.
231
+
232
+ ---
233
+
234
+ ## Phase 3.5: Architecture & Implementation Pattern Assessment
235
+
236
+ ### 3.5.1 Feature Type Classification
237
+
238
+ **Type: Core Enhancement + Test Infrastructure**
239
+ - Modify: `tests/helpers.cjs` (add scenario runner helper)
240
+ - Extract: `bin/install-lib.cjs` (from `bin/install.js`)
241
+ - Create: `tests/scenarios/*.test.cjs` (scenario test files)
242
+ - Create: `.github/workflows/ci.yml` (CI pipeline)
243
+
244
+ ### 3.5.2 Layer Violation Check
245
+
246
+ - [x] Scenario tests call CLI via `execSync` — same pattern as existing tests, no layer violation
247
+ - [x] `install-lib.cjs` exports pure functions — no side effects on import
248
+ - [x] No test file imports agent/command files — tests exercise CLI interface only
249
+ - [x] No upward dependencies
250
+
251
+ ### 3.5.3 Output Contract Design
252
+
253
+ **Scenario Runner Return Value:**
254
+ ```json
255
+ {
256
+ "scenario": "string — scenario name",
257
+ "runtime": "string — claude|opencode|gemini|codex|copilot",
258
+ "steps": [
259
+ {
260
+ "name": "string — step name",
261
+ "command": "string — CLI command executed",
262
+ "success": "boolean",
263
+ "output": "string — stdout",
264
+ "error": "string — stderr (if failed)",
265
+ "duration_ms": "number",
266
+ "assertions_passed": "number",
267
+ "assertions_failed": "number"
268
+ }
269
+ ],
270
+ "passed": "boolean — all steps passed",
271
+ "duration_ms": "number — total scenario time",
272
+ "diagnostics": {
273
+ "platform": "string — win32|darwin|linux",
274
+ "node_version": "string",
275
+ "runtime": "string",
276
+ "failed_step": "string|null — first failed step name",
277
+ "error_summary": "string|null — concise error description"
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### 3.5.4 State Transition Modeling
283
+
284
+ N/A — test infrastructure doesn't mutate `.planning/` state. It creates temp projects and destroys them.
285
+
286
+ ### 3.5.5 Breaking Change Assessment
287
+
288
+ | Question | Answer |
289
+ |----------|--------|
290
+ | Changes any existing command's output schema? | No |
291
+ | Changes file formats? | No |
292
+ | Changes directory structure? | No — new `tests/scenarios/` dir is additive |
293
+ | Changes installer output? | No — extraction preserves all behavior |
294
+
295
+ ### 3.5.6 Composability Analysis
296
+
297
+ | Interaction | Works? | How |
298
+ |-------------|--------|-----|
299
+ | CI runs scenarios automatically | Yes | `npm test` includes scenario files |
300
+ | Developer runs single scenario | Yes | `node --test tests/scenarios/workflow.test.cjs` |
301
+ | Scenario results feed CI reporting | Yes | node:test TAP output parsed by CI |
302
+
303
+ ### 3.5.7 Performance Budget
304
+
305
+ | Operation | Cost | Notes |
306
+ |-----------|------|-------|
307
+ | Install per runtime (~200ms) | ~1000ms for 5 | Shared per describe block |
308
+ | Run 5-step scenario | ~500ms | 5 x execSync ~100ms each |
309
+ | Full scenario suite (est. 10 scenarios) | ~10s | Acceptable for CI |
310
+ | **Total** | **~15s added to test suite** | node:test parallelizes describe blocks |
311
+
312
+ ### 3.5.8 Cross-Platform Considerations
313
+
314
+ | Platform | Consideration |
315
+ |----------|---------------|
316
+ | Windows | `execSync` uses cmd.exe shell — arg quoting differs from bash; test with real shell |
317
+ | Mac/Linux | POSIX shell — no issues with arg quoting |
318
+ | All | Use `path.join()` everywhere; `toPosix()` for output comparison |
319
+ | CI | GitHub Actions `runs-on: [ubuntu-latest, windows-latest, macos-latest]` |
320
+ | Git | `git config user.email/name` required in CI (no global config) |
321
+
322
+ ---
323
+
324
+ ## Phase 4: Design Synthesis
325
+
326
+ ### 4.1 Guide-Level Explanation
327
+
328
+ **User Reality Testing** is PAN Wizard's scenario-based test infrastructure that exercises complete user workflows — install, configure, run multi-step commands, verify output — across all 5 supported runtimes and 3 platforms.
329
+
330
+ **Example 1: Full Workflow Scenario**
331
+ ```javascript
332
+ // tests/scenarios/workflow-init.test.cjs
333
+ describe('Scenario: Initialize and plan a project', () => {
334
+ const runner = createScenarioRunner('claude');
335
+
336
+ test('install → init → create state → plan phase', () => {
337
+ const result = runner.execute([
338
+ { step: 'install', command: '--claude --local' },
339
+ { step: 'init', command: 'init --name test-project' },
340
+ { step: 'state', command: 'state-snapshot' },
341
+ { step: 'plan', command: 'roadmap get-progress' },
342
+ ]);
343
+ assert.ok(result.passed, result.diagnostics.error_summary);
344
+ });
345
+ });
346
+ ```
347
+
348
+ **Example 2: Multi-Runtime Install Verification**
349
+ ```javascript
350
+ // tests/scenarios/runtime-matrix.test.cjs
351
+ for (const runtime of ['claude', 'opencode', 'gemini', 'codex', 'copilot']) {
352
+ describe(`Scenario: ${runtime} install and basic commands`, () => {
353
+ const runner = createScenarioRunner(runtime);
354
+
355
+ test('install + version + help', () => {
356
+ const result = runner.execute([
357
+ { step: 'install', command: `--${runtime} --local` },
358
+ { step: 'version', command: 'version', expect: { field: 'version' } },
359
+ { step: 'help', command: 'help', expect: { success: true } },
360
+ ]);
361
+ assert.ok(result.passed, result.diagnostics.error_summary);
362
+ });
363
+ });
364
+ }
365
+ ```
366
+
367
+ **Example 3: Diagnostic Output on Failure**
368
+ ```
369
+ FAIL: Scenario "codex install and commands" — step "version" failed
370
+ Platform: win32 | Node: 22.5.0 | Runtime: codex
371
+ Command: node ".codex/pan-wizard-core/bin/pan-tools.cjs" version
372
+ Expected: success=true, field "version" present
373
+ Actual: success=false, error="Cannot find module '.codex/pan-wizard-core/bin/lib/core.cjs'"
374
+ Fix hint: Check installer copies all lib modules for codex runtime
375
+ ```
376
+
377
+ ### 4.2 Reference-Level Explanation
378
+
379
+ #### 4.2.1 Component 1: Scenario Runner (`tests/helpers.cjs` extension)
380
+
381
+ ```javascript
382
+ /**
383
+ * Create a scenario runner for a specific runtime.
384
+ * @param {string} runtime - 'claude'|'opencode'|'gemini'|'codex'|'copilot'
385
+ * @returns {{ execute: Function, cleanup: Function, tmpDir: string }}
386
+ */
387
+ function createScenarioRunner(runtime) { /* ... */ }
388
+ ```
389
+
390
+ **Behavior:**
391
+ 1. Creates a temp directory
392
+ 2. Runs the installer with `--${runtime} --local`
393
+ 3. Resolves the installed `pan-tools.cjs` path based on runtime config dir
394
+ 4. Returns an `execute(steps)` function that runs each step sequentially
395
+ 5. Each step runs `execSync` against the installed pan-tools
396
+ 6. Collects structured results with timing and diagnostics
397
+ 7. Returns comprehensive result object (see 3.5.3 contract)
398
+
399
+ **Runtime → Config Dir Mapping (mirrors installer):**
400
+ ```
401
+ claude → .claude
402
+ opencode → .opencode
403
+ gemini → .gemini
404
+ codex → .codex
405
+ copilot → .github
406
+ ```
407
+
408
+ #### 4.2.2 Component 2: Installer Function Extraction (`bin/install-lib.cjs`)
409
+
410
+ Extract these pure/testable functions from `bin/install.js`:
411
+
412
+ | Function | Lines in install.js | Purpose |
413
+ |----------|-------------------|---------|
414
+ | `getDirName(runtime)` | 46-52 | Runtime → config dir name |
415
+ | `getConfigDirFromHome(runtime)` | 53-97 | Runtime → global config path |
416
+ | `expandTilde(p)` | ~160 | Expand `~` to home dir |
417
+ | `convertClaudeToOpencodeFrontmatter(content)` | 798-902 | Frontmatter conversion |
418
+ | `convertClaudeToGeminiToml(content)` | 909-943 | Claude MD → Gemini TOML |
419
+ | `convertClaudeToCodexMarkdown(content)` | ~400 | Claude MD → Codex SKILL.md |
420
+ | `convertClaudeToCopilotMarkdown(content)` | ~500 | Claude MD → Copilot SKILL.md |
421
+ | `processAttribution(content, attribution)` | 250-326 | Commit attribution processing |
422
+ | `getCommitAttribution(runtime, dir)` | ~330 | Read attribution from settings |
423
+ | `parseJsonc(str)` | (exists) | Parse JSON with comments |
424
+
425
+ **Strategy:** `install.js` will `require('./install-lib.cjs')` for these functions. The script's main logic stays in `install.js`. This is a non-breaking refactor.
426
+
427
+ #### 4.2.3 Component 3: Scenario Test Files (`tests/scenarios/`)
428
+
429
+ | File | Scenarios | What It Validates |
430
+ |------|-----------|-------------------|
431
+ | `runtime-matrix.test.cjs` | 5 | All runtimes: install + version + help commands work |
432
+ | `workflow-init.test.cjs` | 2 | Init project → create state → snapshot |
433
+ | `workflow-phases.test.cjs` | 2 | Create phase → list → roadmap integration |
434
+ | `workflow-focus.test.cjs` | 1 | Focus scan → plan (scan writes, plan reads) |
435
+ | `state-integrity.test.cjs` | 3 | State mutations don't corrupt across operations |
436
+ | `installer-functions.test.cjs` | 15+ | Direct tests of extracted installer functions |
437
+ | `cross-platform-paths.test.cjs` | 5 | Path normalization, toPosix, separator handling |
438
+
439
+ #### 4.2.4 Component 4: CI Pipeline (`.github/workflows/ci.yml`)
440
+
441
+ ```yaml
442
+ name: CI
443
+ on: [push, pull_request]
444
+ jobs:
445
+ test:
446
+ strategy:
447
+ matrix:
448
+ os: [ubuntu-latest, windows-latest, macos-latest]
449
+ node: [18, 20, 22]
450
+ runs-on: ${{ matrix.os }}
451
+ steps:
452
+ - uses: actions/checkout@v4
453
+ - uses: actions/setup-node@v4
454
+ with:
455
+ node-version: ${{ matrix.node }}
456
+ - run: npm test
457
+ ```
458
+
459
+ ### 4.3 Design Decisions
460
+
461
+ | Decision | Rationale | What We Did NOT Do (and Why) |
462
+ |----------|-----------|-------------------------------|
463
+ | Extend `tests/helpers.cjs` rather than new helper file | Follows existing pattern; all test files already import from helpers.cjs | Didn't create separate test framework — would violate zero-dep constraint |
464
+ | Extract installer functions, don't rewrite installer | Minimal blast radius; preserves working installer | Didn't refactor entire installer — too risky, scope creep |
465
+ | Scenario files in `tests/scenarios/` subdirectory | Separates slow E2E from fast unit tests; `node --test tests/*.test.cjs` still runs fast tests only | Didn't mix with existing test files — scenarios are 10x slower |
466
+ | Use `node:test` for scenarios (not Jest/Mocha) | Zero deps, project convention | Didn't add test framework dependency |
467
+ | CI matrix: 3 OS x 3 Node versions | Covers real user spread (Win/Mac/Linux, Node 18/20/22) | Didn't add Docker — CI matrix covers platforms already |
468
+
469
+ ### 4.4 Drawbacks & Alternatives
470
+
471
+ | Decision Point | Chosen | Alternative | Why Not | Drawback of Chosen |
472
+ |----------------|--------|------------|---------|-------------------|
473
+ | Scenario execution | Sequential execSync | Parallel with worker_threads | Ordering matters in multi-step scenarios | Slower (~15s total) |
474
+ | Installer extraction | Extract to install-lib.cjs | Rewrite installer as module | Rewrite too risky for v2.3 | Two files to maintain |
475
+ | CI platform | GitHub Actions | None (manual) | Manual testing doesn't scale | CI minutes cost |
476
+ | Runtime coverage | All 5 runtimes | Just Claude + OpenCode | Other runtimes have real users | More tests = slower suite |
477
+
478
+ ### 4.5 Feature Ladder
479
+
480
+ | Version | Scope | Value Delivered | Effort |
481
+ |---------|-------|----------------|--------|
482
+ | **v0 (MVP)** | Scenario runner helper + runtime-matrix test + CI yml | All 5 runtimes tested on 3 platforms | S (2 pts) |
483
+ | **v1 (Complete)** | + installer extraction + workflow scenarios + diagnostics | Full user-journey coverage + installer testability | M (4 pts) |
484
+ | **v2 (Enhanced)** | + scenario recording/replay + regression dashboard + hook verification | Recorded real-user sessions replayed as tests | L (10 pts) |
485
+
486
+ ### 4.6 Adoption Analysis
487
+
488
+ | Question | Answer |
489
+ |----------|--------|
490
+ | How does the user discover this feature? | Internal — maintainers see it in `tests/scenarios/` and CI |
491
+ | What's the learning curve? | Low — follows existing test patterns with `createScenarioRunner()` |
492
+ | Does it require changing existing workflows? | No — `npm test` still works; scenarios are opt-in via `node --test tests/scenarios/*.test.cjs` |
493
+ | What's the "aha moment"? | First time CI catches a bug on Linux that passed on Windows locally |
494
+
495
+ ---
496
+
497
+ ## Phase 5: Architecture Decision Record
498
+
499
+ See `docs/decisions/ADR-0018-user-reality-testing.md` (saved separately).
500
+
501
+ ---
502
+
503
+ ## Phase 6: Error Handling & Diagnostics Design
504
+
505
+ ### 6.1 Failure Mode Analysis
506
+
507
+ | Failure Mode | Category | Detection Pattern | Recovery | User Sees |
508
+ |-------------|----------|-------------------|----------|-----------|
509
+ | Installer fails for runtime X | Environment | execSync throws | Catch, report runtime + error | Diagnostic: "codex install failed: ENOENT..." |
510
+ | Command returns error JSON | Expected failure | `result.success === false` | Check against expected behavior | Step marked failed with error details |
511
+ | Command returns malformed output | Bug | `JSON.parse` throws | Catch, include raw output in diagnostic | "Expected JSON, got: [raw output]" |
512
+ | Timeout (command hangs) | Environment | execSync timeout option | Kill process, mark step as timeout | "Step 'init' timed out after 30s" |
513
+ | File not found after install | Installer bug | fileAccessible check | Report missing file path | "Expected .codex/pan-wizard-core/... not found" |
514
+ | Permission denied | Environment | EACCES in error | Report platform + path | "Permission denied: /tmp/pan-test-xxx/..." |
515
+
516
+ ### 6.2 Diagnostic Output Format
517
+
518
+ Every scenario failure includes:
519
+ ```
520
+ FAIL: Scenario "<name>" — step "<step_name>" failed
521
+ Platform: <platform> | Node: <version> | Runtime: <runtime>
522
+ Command: <full command>
523
+ Expected: <expected outcome>
524
+ Actual: <actual outcome>
525
+ Duration: <ms>
526
+ Files checked: [list of verified files]
527
+ Fix hint: <actionable suggestion>
528
+ ```
529
+
530
+ ---
531
+
532
+ ## Phase 7: Security & Threat Model
533
+
534
+ ### 7.1 Asset & Input Inventory
535
+
536
+ | Asset | Accessed How | Trust Level |
537
+ |-------|-------------|-------------|
538
+ | Temp directories | Created by test, destroyed after | System-generated, fully trusted |
539
+ | Installer script | Executed via `node bin/install.js` | Internal, trusted |
540
+ | pan-tools CLI | Executed via `execSync` | Internal, trusted |
541
+ | Test scenario definitions | Hardcoded in test files | Developer-controlled, trusted |
542
+
543
+ | Input Vector | Source | Validation Required |
544
+ |-------------|--------|-------------------|
545
+ | Runtime flag (--claude, etc.) | Hardcoded in test | Allowlist validation |
546
+ | Temp directory path | `os.tmpdir()` | Path within temp dir verified |
547
+ | CLI output | stdout from execSync | JSON.parse in try-catch |
548
+
549
+ ### 7.2 Path Safety
550
+
551
+ - All temp directories created via `fs.mkdtempSync` — OS-guaranteed unique
552
+ - All paths resolved relative to temp dir — no escape possible
553
+ - Cleanup uses `fs.rmSync(tmpDir, { recursive: true, force: true })` — existing pattern
554
+ - No user-supplied paths — all test paths are hardcoded
555
+
556
+ ### 7.3 Output Sanitization
557
+
558
+ - [x] No absolute filesystem paths in test assertions (use relative)
559
+ - [x] No environment variable values exposed in diagnostics
560
+ - [x] No stack traces in diagnostic output (structured errors only)
561
+ - [x] Temp directories cleaned up after test — no sensitive data persists
562
+
563
+ ### 7.5 Privilege Scope
564
+
565
+ ```
566
+ Reads from: tests/, bin/, pan-wizard-core/
567
+ Writes to: temp directories only (os.tmpdir())
568
+ Executes shell: Yes — node bin/install.js, node pan-tools.cjs (internal tools only)
569
+ Reads outside project: No
570
+ ```
571
+
572
+ ---
573
+
574
+ ## Phase 8: Implementation Roadmap
575
+
576
+ ### 8.1 Command .md Definition
577
+
578
+ N/A — this is test infrastructure, not a user-facing command. The `npm test` script is the interface.
579
+
580
+ **Updated `package.json` scripts:**
581
+ ```json
582
+ {
583
+ "scripts": {
584
+ "test": "node --test tests/*.test.cjs",
585
+ "test:scenarios": "node --test tests/scenarios/*.test.cjs",
586
+ "test:all": "node --test tests/*.test.cjs tests/scenarios/*.test.cjs",
587
+ "test:watch": "node --test --watch tests/*.test.cjs"
588
+ }
589
+ }
590
+ ```
591
+
592
+ ### 8.2 Implementation Tasks
593
+
594
+ ```
595
+ ### Task 1: Extract installer functions to install-lib.cjs
596
+ Files: bin/install-lib.cjs (new), bin/install.js (modify to require install-lib)
597
+ Test: node --test tests/scenarios/installer-functions.test.cjs
598
+ Estimate: M
599
+ Priority: P2
600
+
601
+ ### Task 2: Create scenario runner helper
602
+ Files: tests/helpers.cjs (add createScenarioRunner, runInstalledForRuntime)
603
+ Test: Used by all scenario tests
604
+ Estimate: S
605
+ Priority: P2
606
+
607
+ ### Task 3: Runtime matrix scenario test
608
+ Files: tests/scenarios/runtime-matrix.test.cjs (new)
609
+ Test: node --test tests/scenarios/runtime-matrix.test.cjs
610
+ Estimate: S
611
+ Priority: P2
612
+
613
+ ### Task 4: Workflow scenario tests (init, phases, focus)
614
+ Files: tests/scenarios/workflow-init.test.cjs, workflow-phases.test.cjs, workflow-focus.test.cjs (new)
615
+ Test: node --test tests/scenarios/workflow-*.test.cjs
616
+ Estimate: M
617
+ Priority: P3
618
+
619
+ ### Task 5: Installer function unit tests
620
+ Files: tests/scenarios/installer-functions.test.cjs (new)
621
+ Test: node --test tests/scenarios/installer-functions.test.cjs
622
+ Estimate: S
623
+ Priority: P2
624
+
625
+ ### Task 6: State integrity scenario tests
626
+ Files: tests/scenarios/state-integrity.test.cjs (new)
627
+ Test: node --test tests/scenarios/state-integrity.test.cjs
628
+ Estimate: S
629
+ Priority: P3
630
+
631
+ ### Task 7: Cross-platform path scenario tests
632
+ Files: tests/scenarios/cross-platform-paths.test.cjs (new)
633
+ Test: node --test tests/scenarios/cross-platform-paths.test.cjs
634
+ Estimate: XS
635
+ Priority: P3
636
+
637
+ ### Task 8: CI pipeline configuration
638
+ Files: .github/workflows/ci.yml (new)
639
+ Test: Push to branch, verify CI runs
640
+ Estimate: S
641
+ Priority: P3
642
+
643
+ ### Task 9: Update package.json scripts
644
+ Files: package.json (modify)
645
+ Test: npm run test:scenarios works
646
+ Estimate: XS
647
+ Priority: P3
648
+ ```
649
+
650
+ ### 8.3 Dependency Graph
651
+
652
+ ```
653
+ Task 1 (extract installer) ──┐
654
+ ├── Task 5 (installer function tests)
655
+ Task 2 (scenario runner) ────┤
656
+ ├── Task 3 (runtime matrix) ──┐
657
+ ├── Task 4 (workflow tests) ├── Task 8 (CI)
658
+ ├── Task 6 (state integrity) │
659
+ └── Task 7 (path tests) ──────┘
660
+ └── Task 9 (package.json)
661
+ ```
662
+
663
+ **Critical path:** Task 1 + Task 2 → Task 3 → Task 8
664
+
665
+ ### 8.4 Risk Register
666
+
667
+ | Risk | Probability | Impact | Mitigation |
668
+ |------|------------|--------|------------|
669
+ | Installer extraction breaks install flow | Medium | High | Run full E2E test suite after extraction; git tag before refactor |
670
+ | Scenarios too slow for regular `npm test` | Medium | Medium | Separate script: `npm run test:scenarios`; keep `npm test` fast |
671
+ | CI minutes cost on 3x3 matrix | Low | Low | Start with 3 OS x 1 Node version; expand later |
672
+ | Runtime install paths differ on CI vs local | Medium | Medium | Use relative paths; verify with `path.resolve` |
673
+ | Flaky tests due to filesystem timing | Low | Medium | Add retry logic for install step only; deterministic assertions |
674
+
675
+ ### 8.5 Cognitive Complexity Budget
676
+
677
+ - Max lines per function: 50
678
+ - Max nesting depth: 3 levels
679
+ - Max parameters: 4 (use options object if more)
680
+ - `createScenarioRunner(runtime, options?)` — 2 params
681
+ - `executeScenarioStep(command, cwd, timeout?)` — 3 params
682
+
683
+ ---
684
+
685
+ ## Phase 9: Test Plan
686
+
687
+ ### 9.1 Test Pyramid
688
+
689
+ | Level | Pattern | Minimum Count | What It Catches |
690
+ |-------|---------|---------------|-----------------|
691
+ | **Unit** | Test installer functions directly | 15+ | Conversion bugs, path resolution, attribution |
692
+ | **Integration** | Runtime matrix (install + commands) | 10+ (2 per runtime) | Runtime-specific wiring, file format, tool names |
693
+ | **E2E** | Multi-step workflow scenarios | 5+ | State transitions, cross-command interaction, data flow |
694
+
695
+ ### 9.2 Assertion Density Requirements
696
+
697
+ Every scenario step asserts:
698
+ - (a) `result.success === expected.success` — command succeeds/fails as expected
699
+ - (b) If JSON: parsed output has expected fields
700
+ - (c) If file operation: file exists at expected path with expected content
701
+ - (d) No `error` field when success expected
702
+
703
+ Every installer function test asserts:
704
+ - (a) Return value type and shape
705
+ - (b) Edge case handling (empty input, null, undefined)
706
+ - (c) Cross-platform behavior (forward/backward slashes)
707
+
708
+ ### 9.3 Boundary Value Analysis
709
+
710
+ - [x] Empty project (no `.planning/` directory) — install should still work
711
+ - [x] Runtime name edge cases — only 5 valid names, reject others
712
+ - [x] Path with spaces in directory name — common on Windows
713
+ - [x] Very long phase names (near 40-char slug limit)
714
+ - [x] Installer run twice (idempotent check)
715
+ - [x] Missing Node.js in PATH (graceful error)
716
+ - [x] Read-only filesystem (permission denied on write)
717
+
718
+ ### 9.4 Regression Verification
719
+
720
+ - [x] All 1,314 existing tests pass unchanged
721
+ - [x] `npm test` still runs only fast tests (no scenarios)
722
+ - [x] `npm run test:all` runs everything
723
+ - [x] E2E install tests remain independent of new scenarios
724
+
725
+ ### 9.5 Performance Validation
726
+
727
+ - [x] `npm test` (unit/integration only) completes in < 30s
728
+ - [x] `npm run test:scenarios` completes in < 60s
729
+ - [x] `npm run test:all` completes in < 90s
730
+ - [x] Individual scenario file runs in < 15s
731
+
732
+ ---
733
+
734
+ ## Phase 10: Report Summary
735
+
736
+ ### Problem & Evidence
737
+ PAN Wizard's 1,314 tests validate modules in isolation but don't replicate real user workflows across 5 runtimes and 3 platforms. User explicitly reports the testing gap.
738
+
739
+ ### Investigation Depth
740
+ - 42 test files analyzed, 15 core modules read, 5 runtime adapters traced
741
+ - Installer flow traced through all 2,636 lines
742
+ - Patterns: `runPanTools()`, `createTempProject()`, `runInstalled()`, `execSync` CLI testing
743
+ - Impact: 1 High-risk item (installer extraction), 3 Medium, rest Low
744
+
745
+ ### Strategic Assessment
746
+ - **Blue Ocean:** CREATE scenario-based multi-runtime certification (no tool does this)
747
+ - **Wardley:** Custom-built — no off-the-shelf framework for this
748
+ - **Moat Score:** 24/30 — strengthens cross-platform, DX, zero-dep, verification moats
749
+ - **Cognitive Load:** 0 (internal tool, no user-facing complexity)
750
+ - **Recommendation:** Build — highest-leverage testing investment, protects all future features
751
+
752
+ ### Design Summary
753
+ - **Type:** Test infrastructure (helpers + scenario files + CI + installer extraction)
754
+ - **Modules affected:** `tests/helpers.cjs` (extend), `bin/install.js` (refactor), `package.json` (scripts)
755
+ - **New files:** `bin/install-lib.cjs`, `tests/scenarios/*.test.cjs` (7 files), `.github/workflows/ci.yml`
756
+ - **Error handling:** Structured diagnostics with platform/runtime/step/fix-hint
757
+ - **Breaking changes:** None
758
+
759
+ ### Feature Ladder
760
+ - **v0 (MVP):** Scenario runner + runtime matrix test + CI = S effort
761
+ - **v1 (Complete):** + installer extraction + workflow scenarios + diagnostics = M effort
762
+ - **v2 (Enhanced):** + scenario recording/replay + regression dashboard = L effort
763
+
764
+ ### Implementation Tasks
765
+ - 9 tasks, total complexity: 1 XS + 4 S + 2 M = ~18 points
766
+ - Files to create: 9 new files
767
+ - Files to modify: 3 existing files
768
+
769
+ ### Security
770
+ - All operations in temp directories — no production risk
771
+ - No user-supplied paths — all hardcoded test paths
772
+ - Cleanup guaranteed by afterEach hooks
773
+
774
+ ### Acceptance Criteria
775
+ - 6 criteria, 5 machine-checkable (SC-1 through SC-5), 1 structural (SC-6)
776
+
777
+ ### Documents Created
778
+ - Spec: `docs/specs/user_reality_testing_system_featureai.md`
779
+ - ADR: `docs/decisions/ADR-0018-user-reality-testing.md`
780
+
781
+ ### Next Step
782
+ Recommended: `/pan:plan-phase` to create implementation plan from this spec, starting with Task 1 (installer extraction) and Task 2 (scenario runner helper).
783
+
784
+ ---
785
+
786
+ ## Post-Implementation Note (2026-03-04)
787
+
788
+ ADR-0018 implemented: installer extraction (`install-lib.cjs`), scenario runner (`createScenarioRunner`), 47 scenario tests, CI pipeline. ADR-0019 followed with 52 additional E2E tests. Counts at spec time: 1,314 tests, 42 test files. Counts after both ADRs: 1,518 tests (1,419 unit + 99 scenario), 52 test files (43 unit + 9 scenario). Commits: 90f0da8 (ADR-0018), cd86512 (ADR-0019).