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.
- package/CHANGELOG.md +3645 -0
- package/README.md +46 -52
- package/agents/pan-conductor.md +2 -3
- package/agents/pan-counterfactual.md +1 -2
- package/agents/pan-debugger.md +14 -3
- package/agents/pan-design-checker.md +1 -2
- package/agents/pan-designer.md +2 -3
- package/agents/pan-document_code.md +1 -2
- package/agents/pan-executor.md +25 -0
- package/agents/pan-hardener.md +4 -3
- package/agents/pan-integration-checker.md +1 -2
- package/agents/pan-knowledge.md +1 -2
- package/agents/pan-meta-reviewer.md +3 -3
- package/agents/pan-optimizer.md +4 -4
- package/agents/pan-phase-researcher.md +80 -475
- package/agents/pan-plan-checker.md +40 -3
- package/agents/pan-planner.md +21 -7
- package/agents/pan-previewer.md +3 -2
- package/agents/pan-project-researcher.md +72 -493
- package/agents/pan-release.md +1 -1
- package/agents/pan-reviewer.md +14 -3
- package/agents/pan-roadmapper.md +12 -7
- package/agents/pan-verifier.md +9 -4
- package/bin/install-lib.cjs +134 -14
- package/bin/install.js +59 -12
- package/commands/pan/army.md +1 -1
- package/commands/pan/autodev.md +76 -0
- package/commands/pan/cost.md +21 -1
- package/commands/pan/exec-phase.md +3 -4
- package/commands/pan/focus-auto.md +14 -7
- package/commands/pan/focus-design.md +4 -5
- package/commands/pan/focus-docs.md +24 -0
- package/commands/pan/learn.md +13 -6
- package/commands/pan/milestone-audit.md +8 -1
- package/commands/pan/milestone-done.md +10 -5
- package/commands/pan/milestone-new.md +2 -2
- package/commands/pan/new-project.md +15 -12
- package/commands/pan/plan-phase.md +15 -9
- package/commands/pan/preview.md +1 -1
- package/commands/pan/quick.md +1 -1
- package/commands/pan/review-deep.md +11 -5
- package/commands/pan/settings.md +6 -0
- package/commands/pan/verify-phase.md +6 -2
- package/docs/AGENTS.md +917 -0
- package/docs/ARCHITECTURE.md +1054 -0
- package/docs/CLI-REFERENCE.md +4582 -0
- package/docs/COMPARISON.md +116 -0
- package/docs/DEVELOPMENT.md +490 -0
- package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
- package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
- package/docs/EXAMPLES.md +584 -0
- package/docs/FAQ.md +254 -0
- package/docs/FIELD-HARVEST-2026-07.md +88 -0
- package/docs/FIELD-REPORT-army-2026-06.md +121 -0
- package/docs/HOOKS.md +638 -0
- package/docs/IMPROVEMENT-TODO.md +246 -0
- package/docs/INTERNALS.md +485 -0
- package/docs/MIGRATION-v2-to-v3.md +258 -0
- package/docs/SECURITY-HARDENING.md +230 -0
- package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
- package/docs/SKILLS-FULL-TEXT.md +9685 -0
- package/docs/SKILLS-REFERENCE.md +1037 -0
- package/docs/TROUBLESHOOTING.md +1084 -0
- package/docs/USER-GUIDE.md +1437 -0
- package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
- package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
- package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
- package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
- package/docs/audits/OUTSTANDING-2026-08.md +275 -0
- package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
- package/docs/branding/README-brand-draft.md +119 -0
- package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
- package/docs/branding/handoff/README-brand-draft.md +119 -0
- package/docs/branding/handoff/image-prompts.md +46 -0
- package/docs/branding/image-prompts.md +46 -0
- package/docs/branding/nano-banana-prompts.txt +60 -0
- package/docs/context-monitor.md +13 -0
- package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
- package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
- package/docs/decisions/ADR-0003-smart-execution.md +84 -0
- package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
- package/docs/decisions/ADR-0005-command-naming.md +80 -0
- package/docs/decisions/ADR-0006-focus-commands.md +101 -0
- package/docs/decisions/ADR-0007-ship-v1.md +73 -0
- package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
- package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
- package/docs/decisions/ADR-0010-standards-integration.md +79 -0
- package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
- package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
- package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
- package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
- package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
- package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
- package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
- package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
- package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
- package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
- package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
- package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
- package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
- package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
- package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
- package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
- package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
- package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
- package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
- package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
- package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
- package/docs/decisions/ADR-0032-squad-model.md +64 -0
- package/docs/decisions/ADR-0033-army-campaign.md +40 -0
- package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
- package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
- package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
- package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
- package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
- package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
- package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
- package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
- package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
- package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
- package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
- package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
- package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
- package/docs/decisions/ADR-0047-pan-harness.md +76 -0
- package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
- package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
- package/docs/specs/ai_drift_prevention_featureai.md +286 -0
- package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
- package/docs/specs/command_naming_optimization_featureai.md +930 -0
- package/docs/specs/comp_analysis_markdown_v1.md +149 -0
- package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
- package/docs/specs/contributors_attribution_index_featureai.md +476 -0
- package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
- package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
- package/docs/specs/custom-skills-assessment.md +461 -0
- package/docs/specs/deployment_audit_findings_featureai.md +243 -0
- package/docs/specs/doc_code_link_graph_featureai.md +253 -0
- package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
- package/docs/specs/e2e_visual_testing_featureai.md +615 -0
- package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
- package/docs/specs/evidence-loop-plan.md +76 -0
- package/docs/specs/evidence_loop_featureai.md +497 -0
- package/docs/specs/focus-auto-optimize-category.md +449 -0
- package/docs/specs/focus-auto-optimize-superplan.md +188 -0
- package/docs/specs/focus_auto_runner_featureai.md +1102 -0
- package/docs/specs/focus_design_v2_featureai.md +197 -0
- package/docs/specs/focus_sync_v2_featureai.md +202 -0
- package/docs/specs/git_integration_overhaul_featureai.md +326 -0
- package/docs/specs/glm_zai_provider_featureai.md +200 -0
- package/docs/specs/googlecli_adoption_featureai.md +661 -0
- package/docs/specs/help_commands_rewrite_featureai.md +860 -0
- package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
- package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
- package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
- package/docs/specs/investigations/README.md +31 -0
- package/docs/specs/investigations/digests/2026-09-28.md +47 -0
- package/docs/specs/investigations/digests/2026-10-08.md +62 -0
- package/docs/specs/investigations/digests/2026-10-10.md +61 -0
- package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
- package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
- package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
- package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
- package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
- package/docs/specs/lifecycle_completeness_featureai.md +754 -0
- package/docs/specs/local-first-ci.md +42 -0
- package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
- package/docs/specs/market-delta-2026-09-superplan.md +310 -0
- package/docs/specs/market-ideas-2026-09.md +131 -0
- package/docs/specs/market-ideas-2026-10.md +428 -0
- package/docs/specs/market-ideas-ledger.md +177 -0
- package/docs/specs/memory-optimization-2026-10.md +285 -0
- package/docs/specs/multi-track-planning-roots.md +143 -0
- package/docs/specs/multi_model_routing_featureai.md +687 -0
- package/docs/specs/multi_model_routing_superplan.md +197 -0
- package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
- package/docs/specs/opus_47_extended_features_featureai.md +363 -0
- package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
- package/docs/specs/pan_focus_commands_featureai.md +2336 -0
- package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
- package/docs/specs/product-excellence-superplan.md +315 -0
- package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
- package/docs/specs/production_deployment_readiness_featureai.md +433 -0
- package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
- package/docs/specs/real_test_enforcement_featureai.md +213 -0
- package/docs/specs/reality-check-2026-09-superplan.md +362 -0
- package/docs/specs/right-sized-ceremony.md +74 -0
- package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
- package/docs/specs/self_improvement_loop_featureai.md +875 -0
- package/docs/specs/skill-aligned-decomposition.md +155 -0
- package/docs/specs/standards_integration_featureai.md +833 -0
- package/docs/specs/testing-system-redesign-2026-09.md +267 -0
- package/docs/specs/user_reality_testing_system_featureai.md +788 -0
- package/docs/specs/watch-triggers.json +22 -0
- package/docs/specs/workflow-integration-redesign.md +742 -0
- package/docs/specs/workflow_state_consistency_featureai.md +183 -0
- package/hooks/dist/pan-context-monitor.js +9 -2
- package/hooks/dist/pan-cost-logger.js +5 -0
- package/hooks/dist/pan-guard.js +28 -5
- package/hooks/dist/pan-stop-guard.js +9 -9
- package/hooks/dist/pan-trace-logger.js +5 -0
- package/package.json +10 -2
- package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
- package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
- package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
- package/pan-wizard-core/bin/lib/ci.cjs +143 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1 -1
- package/pan-wizard-core/bin/lib/config.cjs +41 -5
- package/pan-wizard-core/bin/lib/constants.cjs +27 -1
- package/pan-wizard-core/bin/lib/core.cjs +31 -14
- package/pan-wizard-core/bin/lib/cost.cjs +160 -4
- package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
- package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
- package/pan-wizard-core/bin/lib/doc-lint.cjs +5 -3
- package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
- package/pan-wizard-core/bin/lib/findings.cjs +148 -9
- package/pan-wizard-core/bin/lib/focus.cjs +1 -1
- package/pan-wizard-core/bin/lib/git.cjs +1 -1
- package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
- package/pan-wizard-core/bin/lib/init.cjs +7 -2
- package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
- package/pan-wizard-core/bin/lib/merge.cjs +50 -0
- package/pan-wizard-core/bin/lib/mutate.cjs +268 -0
- package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
- package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
- package/pan-wizard-core/bin/lib/phase-gate.cjs +15 -9
- package/pan-wizard-core/bin/lib/phase-remove.cjs +91 -11
- package/pan-wizard-core/bin/lib/phase.cjs +85 -13
- package/pan-wizard-core/bin/lib/plan-lint.cjs +310 -0
- package/pan-wizard-core/bin/lib/preview.cjs +26 -4
- package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
- package/pan-wizard-core/bin/lib/research-lint.cjs +268 -0
- package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
- package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
- package/pan-wizard-core/bin/lib/roadmap.cjs +1 -0
- package/pan-wizard-core/bin/lib/runner.cjs +2 -16
- package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
- package/pan-wizard-core/bin/lib/squads.cjs +1 -1
- package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
- package/pan-wizard-core/bin/lib/test-gate.cjs +433 -0
- package/pan-wizard-core/bin/lib/uat.cjs +149 -0
- package/pan-wizard-core/bin/lib/usage.cjs +104 -0
- package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
- package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
- package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
- package/pan-wizard-core/bin/lib/verify-red.cjs +174 -0
- package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
- package/pan-wizard-core/bin/lib/verify-scope.cjs +143 -2
- package/pan-wizard-core/bin/lib/verify.cjs +86 -31
- package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
- package/pan-wizard-core/bin/pan-tools.cjs +257 -28
- package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
- package/pan-wizard-core/mcp/orchestrator.cjs +4 -1
- package/pan-wizard-core/references/continuation-format.md +3 -3
- package/pan-wizard-core/references/design-methodology.md +1 -1
- package/pan-wizard-core/references/guardrails.md +1 -1
- package/pan-wizard-core/references/handoff-decisions.md +1 -1
- package/pan-wizard-core/references/model-profiles.md +2 -3
- package/pan-wizard-core/references/questioning.md +24 -0
- package/pan-wizard-core/references/ui-brand.md +4 -6
- package/pan-wizard-core/references/verdict-contract.md +2 -1
- package/pan-wizard-core/templates/config.json +10 -2
- package/pan-wizard-core/templates/debug.md +1 -0
- package/pan-wizard-core/templates/design.md +5 -4
- package/pan-wizard-core/templates/discovery.md +2 -2
- package/pan-wizard-core/templates/phase-prompt.md +7 -0
- package/pan-wizard-core/templates/requirements.md +9 -0
- package/pan-wizard-core/templates/research.md +10 -0
- package/pan-wizard-core/templates/summary-complex.md +5 -1
- package/pan-wizard-core/templates/summary-minimal.md +4 -0
- package/pan-wizard-core/templates/summary-standard.md +5 -1
- package/pan-wizard-core/templates/summary.md +8 -1
- package/pan-wizard-core/workflows/add-phase.md +4 -6
- package/pan-wizard-core/workflows/assumptions.md +19 -1
- package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
- package/pan-wizard-core/workflows/discuss-phase.md +4 -2
- package/pan-wizard-core/workflows/exec-lean.md +69 -0
- package/pan-wizard-core/workflows/exec-phase.md +79 -15
- package/pan-wizard-core/workflows/execute-plan.md +3 -1
- package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
- package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
- package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
- package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
- package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
- package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
- package/pan-wizard-core/workflows/health.md +6 -0
- package/pan-wizard-core/workflows/help.md +114 -77
- package/pan-wizard-core/workflows/insert-phase.md +4 -6
- package/pan-wizard-core/workflows/learn.md +3 -3
- package/pan-wizard-core/workflows/milestone-audit.md +2 -2
- package/pan-wizard-core/workflows/milestone-new.md +38 -95
- package/pan-wizard-core/workflows/new-project.md +96 -258
- package/pan-wizard-core/workflows/optimize.md +107 -5
- package/pan-wizard-core/workflows/phase-tests.md +10 -0
- package/pan-wizard-core/workflows/plan-phase.md +106 -45
- package/pan-wizard-core/workflows/profile.md +50 -0
- package/pan-wizard-core/workflows/progress.md +10 -0
- package/pan-wizard-core/workflows/quick.md +34 -43
- package/pan-wizard-core/workflows/remove-phase.md +11 -1
- package/pan-wizard-core/workflows/research-phase.md +118 -40
- package/pan-wizard-core/workflows/resume-project.md +18 -2
- package/pan-wizard-core/workflows/settings.md +33 -19
- package/pan-wizard-core/workflows/todo-check.md +6 -2
- package/pan-wizard-core/workflows/transition.md +22 -4
- package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
- package/pan-wizard-core/workflows/update.md +1 -1
- package/pan-wizard-core/workflows/verify-phase.md +39 -46
- package/scripts/build-agent-plugin.js +35 -15
- package/scripts/build-help.cjs +106 -0
- package/scripts/build-plugin.js +10 -1
- package/scripts/deprecate-old-versions.js +70 -3
- package/scripts/generate-skills-docs.py +1 -1
- package/scripts/git-hooks/pre-push +27 -0
- package/scripts/install-git-hooks.js +7 -5
- package/scripts/install-pre-push.cjs +38 -0
- package/scripts/land.cjs +151 -0
- package/scripts/local-ci.cjs +501 -0
- package/scripts/local-schedule.cjs +277 -0
- package/scripts/mutation-probe.cjs +7 -80
- package/scripts/prompt-lint.cjs +32 -0
- package/scripts/prompt-rules.cjs +156 -0
- package/scripts/run-tests.cjs +7 -1
- package/scripts/test-quality-lint.cjs +3 -3
- package/scripts/test-surface.cjs +175 -6
- package/agents/pan-research-synthesizer.md +0 -246
- package/commands/pan/audit-deployment.md +0 -386
- package/commands/pan/dashboard.md +0 -22
- package/commands/pan/discord.md +0 -19
- package/commands/pan/mcp-bridge.md +0 -143
- package/commands/pan/milestone-cleanup.md +0 -19
- package/commands/pan/milestone-gaps.md +0 -35
- package/commands/pan/optimize.md +0 -115
- package/commands/pan/profile.md +0 -76
- package/commands/pan/research-phase.md +0 -189
- package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
- package/pan-wizard-core/templates/research-project/architecture.md +0 -204
- package/pan-wizard-core/templates/research-project/features.md +0 -147
- package/pan-wizard-core/templates/research-project/pitfalls.md +0 -200
- package/pan-wizard-core/templates/research-project/stack.md +0 -120
- package/pan-wizard-core/templates/research-project/summary.md +0 -170
|
@@ -0,0 +1,1054 @@
|
|
|
1
|
+
# PAN Wizard — Architecture Guide
|
|
2
|
+
|
|
3
|
+
A deep dive into how PAN Wizard is structured, how data flows between layers, and why key design decisions were made.
|
|
4
|
+
|
|
5
|
+
**Other docs:** [Agents](AGENTS.md) · [Hooks](HOOKS.md) · [CLI Reference](CLI-REFERENCE.md) · [Development](DEVELOPMENT.md)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [System Overview](#system-overview)
|
|
12
|
+
- [Layer 1: Commands](#layer-1-commands)
|
|
13
|
+
- [Layer 2: Workflows](#layer-2-workflows)
|
|
14
|
+
- [Layer 3: Agents](#layer-3-agents)
|
|
15
|
+
- [Layer 4: Core Library](#layer-4-core-library)
|
|
16
|
+
- [Layer 5: Persistent State](#layer-5-persistent-state)
|
|
17
|
+
- [Additional Components](#additional-components)
|
|
18
|
+
- [References](#references)
|
|
19
|
+
- [Templates](#templates)
|
|
20
|
+
- [Hooks](#hooks)
|
|
21
|
+
- [Installer](#installer)
|
|
22
|
+
- [Data Flow](#data-flow)
|
|
23
|
+
- [Module Dependency Graph](#module-dependency-graph)
|
|
24
|
+
- [Cross-Platform Runtime Support](#cross-platform-runtime-support)
|
|
25
|
+
- [Key Design Decisions](#key-design-decisions)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## System Overview
|
|
30
|
+
|
|
31
|
+
PAN Wizard is organized as a 5-layer architecture. Each layer has a single responsibility and communicates with adjacent layers through well-defined interfaces.
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
+-------------------------------------------------------------------+
|
|
35
|
+
| USER (Claude Code / OpenCode / Gemini / |
|
|
36
|
+
| Codex / Copilot CLI) |
|
|
37
|
+
+-------------------------------------------------------------------+
|
|
38
|
+
| /pan:command arg1 arg2
|
|
39
|
+
v
|
|
40
|
+
+-------------------------------------------------------------------+
|
|
41
|
+
| LAYER 1: COMMANDS commands/pan/*.md |
|
|
42
|
+
| Thin orchestrators — parse args, read state, route to workflows |
|
|
43
|
+
+-------------------------------------------------------------------+
|
|
44
|
+
| references workflow
|
|
45
|
+
v
|
|
46
|
+
+-------------------------------------------------------------------+
|
|
47
|
+
| LAYER 2: WORKFLOWS pan-wizard-core/workflows/*.md |
|
|
48
|
+
| XML-structured multi-step procedures — the core logic layer |
|
|
49
|
+
+-------------------------------------------------------------------+
|
|
50
|
+
| spawns via Task tool | calls via bash
|
|
51
|
+
v v
|
|
52
|
+
+---------------------------+ +-------------------------------+
|
|
53
|
+
| LAYER 3: AGENTS | | LAYER 4: CORE LIBRARY |
|
|
54
|
+
| agents/*.md | | pan-wizard-core/bin/lib/*.cjs |
|
|
55
|
+
| Specialized AI roles, | | Core CJS modules + CLI entry |
|
|
56
|
+
| each in a fresh context | | Zero external dependencies |
|
|
57
|
+
+---------------------------+ +-------------------------------+
|
|
58
|
+
| |
|
|
59
|
+
+----------------+------------------+
|
|
60
|
+
| reads / writes
|
|
61
|
+
v
|
|
62
|
+
+-------------------------------------------------------------------+
|
|
63
|
+
| LAYER 5: PERSISTENT STATE .planning/ |
|
|
64
|
+
| project.md, roadmap.md, state.md, config.json, phase dirs |
|
|
65
|
+
+-------------------------------------------------------------------+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Key principle:** Information flows downward through layers. Commands invoke workflows. Workflows spawn agents and call the core library. Agents and the core library read/write persistent state. No layer communicates upward except by returning results.
|
|
69
|
+
|
|
70
|
+
### Model-capability integration
|
|
71
|
+
|
|
72
|
+
PAN Wizard consumes these frontier-model capabilities across existing layers without changing the layer contracts. **There is no runtime capability gate.** PAN emits the capability unconditionally; whether it takes effect is decided by two things outside PAN's control — the **host runtime** (extended thinking directives are Claude-only; the installer rewrites or drops them for the other four) and the **model you launched the session with** (a 1M-context model can absorb a single-shot codebase map; a smaller-context one cannot). No module gates a *feature* on the model name — every workflow, mode selection, and routing decision runs the same code path whatever model you are on. (Some places do read a model name for non-gating reasons — the installer's advisory warning, described below; `cost.cjs`'s `resolveRate()`, which resolves a per-million-token price from the model ID recorded in the metrics log so `/pan:cost` can report spend; `hooks/pan-cost-logger.js`'s `tierForModel()`, which stamps a tier label onto every ledger row it writes; and the statusline hook, which displays the model's name. Those are reporting and display reads, not behavior — none of them change what PAN does. One read does steer routing: on an OpenCode install, `core.cjs`'s `opencodeConfiguredProvider()` takes the provider prefix of OpenCode's configured `model` so `resolve-model` names that provider's models; it picks ids, never whether a feature runs. Another sizes a measurement: `hooks/pan-context-monitor.js` uses the model id to find where the host compacts (a per-model `autoCompactWindow` setting) and, without a fresh status-line bridge, the context window itself (`modelWindowFor()` on the newest transcript record). That sets when its note fires, and for an id it cannot place it says nothing rather than guess. To find the current set rather than trust this list: `grep -rn "model" --include=*.cjs --include=*.js bin/ pan-wizard-core/bin/lib/ hooks/ | grep -iv comment`.)
|
|
73
|
+
|
|
74
|
+
- **Prompt caching (Layer 4/3 boundary):** the host caches each agent's prompt prefix by itself, and nothing PAN runs can mark another agent's prompt for caching. What PAN controls is how much every agent re-reads. `buildCachedContext(cwd)` names the stable `.planning/` set, and `context-budget` and hygiene's `cache-context` check measure it against thresholds (ADR-0044). Phase agents read a phase's `roadmap slice` rather than the whole roadmap and requirements. `pan-tools cache prime` reports the set and a stable sha but primes nothing (ADR-0023, amended).
|
|
75
|
+
- **Reasoning effort (Layer 3):** agents carry `effort:` frontmatter (`low`–`xhigh`; the adaptive-thinking-era replacement for the retired `thinking_budget`). Claude Code consumes it natively; the installer maps it to Codex's native `model_reasoning_effort`, and for OpenCode, Gemini and Copilot strips it and injects an effort-scaled prose preamble. Profiles modulate the base via `resolveEffortInternal()`.
|
|
76
|
+
- **Whole-project ingest (Layer 1/3):** `/pan:map-codebase` Stage 0 calls `pan-tools codebase estimate-size`; repos ≤700K tokens go single-shot, else sharded across parallel mappers. The mode is chosen from repo size alone — there is no model check in `codebase.cjs` — so the single-shot path assumes a model with a 1M-context window; lower `--threshold` (or take the sharded path) on smaller-context models. The `pan-document_code` agent has a `<mode>` block so it knows which shape it was spawned with.
|
|
77
|
+
- **Cross-phase memory (Layer 5):** `.planning/memory/<agent>.md` stores append-only per-agent lessons, recorded by hand (`memory append`, the gated `memory record`) or by `/pan:retro --write-memory`. **PAN's workflows do not load it into agents** (ADR-0036, amended `2026-10-04`). The harness found that a recorded lesson changed no phase's work beyond what `state.md`, the summaries and the code already carried. What carries knowledge between phases is that state discipline, and the project's own instructions for anything durable. `/pan:knowledge` reads the store for a person.
|
|
78
|
+
- **Capability-aware routing (Layer 4):** `resolveModelInternal(cwd, agent, {context_estimate, needs_thinking, cache_warm})` (through `adjustTierForCapabilities()` in `core.cjs`) adjusts tier upward for large context or thinking-heavy work, downward for warm cache + small context.
|
|
79
|
+
|
|
80
|
+
Memory and caching are file-based, so they work on all 5 runtimes. Extended thinking is Claude-only. (The flat `.claude/skills/pan-*.md` shims earlier installs wrote were retired on `2026-09-23`: Claude Code loads skills only as `skills/<name>/SKILL.md` directories, and the `/pan:<name>` commands already reach the model the way skills do.)
|
|
81
|
+
|
|
82
|
+
**The model-name read that users actually see** is the installer's, and it only prints advice. `detectModelCapabilities()` in `bin/install-lib.cjs` is a hand-maintained substring table over literal model-ID fragments (`opus-5`, `sonnet-4-6`, `gpt-5`, `gemini-3`, … — read the function for the current set rather than trusting this sample); `install.js` calls it once, post-install, against the `model` field in `settings.json`, and prints a note if that model is known to lack 1M context or extended thinking. That warning is the table's only consumer — it gates no feature and blocks nothing. `--skip-warnings` suppresses it.
|
|
83
|
+
|
|
84
|
+
Because it is a name table and not a live probe, it is written to lean forward-compatible. Generations the table knows map exactly. The forward threshold per family is the **last reduced-capability release the table records** for it — not the newest release it lists: any Claude ID whose parsed release number is strictly newer than that boundary inherits its family's modern profile instead of reading as capability-less. Major and point are compared as a pair (so a two-digit point release sorts above a one-digit one), which is what makes a *later point release inside an already-tabled major* forward-compatible too, not just a new major — neither draws a false "lacks 1M context" note. An ID resolves either by matching an explicit branch in the table or — for Claude names — by carrying a family plus a readable release number strictly newer than that family's last reduced-capability release; anything that resolves neither way reads as `tier: 'unknown'` with every capability flag false. Note that "its family's modern profile" means the newest profile the table records for that family, not the top-tier one: a newer Haiku inherits the newest Haiku profile (1M context and thinking, at the fast tier), never Opus's. It stays a best-effort advisory heuristic — a genuinely new family can still read as unknown and trigger the note until a branch is added.
|
|
85
|
+
|
|
86
|
+
### Spec B v2
|
|
87
|
+
|
|
88
|
+
Spec B v2 shipped a wave of new core modules (bus, cost, preview, review-deep, knowledge, whatif) and user-facing commands (cost, preview, review-deep, knowledge, what-if). None touch the focus system (`/pan:focus-*`); they interoperate via read boundaries + optional flags. See ADR-0024.
|
|
89
|
+
|
|
90
|
+
- **`bus.cjs` (Y-7 infrastructure):** file-backed message channels at `.planning/bus/<channel>.jsonl` for agent-to-agent coordination. Consumed by `review-deep.cjs` (audit trail) and `pan-conductor` (orchestrator trace). Three drain modes: peek / consume / archive.
|
|
91
|
+
- **`cost.cjs` (Y-6):** per-call cost aggregation. Reads `.planning/metrics/tokens.jsonl` (append-only log), outputs JSON/table/chart. Auto-populated from v3.4 by the `pan-cost-logger` SubagentStop hook.
|
|
92
|
+
- **`preview.cjs` (Y-1):** foresight data layer. Three modes — `buildPhasePreview` (blast radius), `buildPhaseDependencyGraph` (mermaid DAG + parallel batches), `buildMilestoneETA` (velocity + confidence + bottleneck).
|
|
93
|
+
- **`review-deep.cjs` (Y-2):** merges outputs from `pan-reviewer` + `pan-hardener` + `pan-meta-reviewer` into one verdict ladder (ok / ok_with_minor / fix_before_merge / review_required / block). Publishes audit to the `review-handoff` bus channel.
|
|
94
|
+
- **`knowledge.cjs` (Y-3):** three modes — `ask` (retrieval-grounded Q&A), `discuss` (multi-turn sessions at `.planning/conversations/<phase>/`), `playbook` (clusters agent memory into categorized lessons at `.planning/playbook.md`).
|
|
95
|
+
- **`whatif.cjs` (Y-4):** git worktree lifecycle for counterfactual phase replay. Agent explores in isolated worktree, command writes `.planning/counterfactuals/<phase>-<slug>.md` in main tree, cleans up worktree.
|
|
96
|
+
|
|
97
|
+
Hierarchical orchestration: `pan-conductor` spawns executor/reviewer/verifier sub-agents for `/pan:exec-phase <N> --hierarchical`, bounded by a safety harness (2-level nesting cap, 12-spawn cap, budget ceiling, `.planning/orchestration/abort` kill-switch). Claude Code only — it needs native sub-agent spawning; on the other four runtimes the flag is a no-op that warns and falls back to flat exec.
|
|
98
|
+
|
|
99
|
+
Automatic cost instrumentation: `hooks/pan-cost-logger.js` fires on Claude Code's `SubagentStop` event, appends to `.planning/metrics/tokens.jsonl`, flows into `/pan:cost` without caller instrumentation.
|
|
100
|
+
|
|
101
|
+
### Bot-army model (ADR-0032/0033/0034/0035)
|
|
102
|
+
|
|
103
|
+
PAN's agents run as a coordinated army when `/pan:army` drives a whole-project goal. The tiers reuse existing primitives — nothing here relaxes the `pan-conductor` safety harness:
|
|
104
|
+
|
|
105
|
+
- **Tier 0 — Mission Control:** the reasoning-tier `pan-conductor`, elevated to campaign scope. It plans the goal and delegates to squads rather than implementing; that split is a prompt-level convention, not a tool restriction — `agents/pan-conductor.md` grants `Read, Write, Bash, Glob, Grep, Task`, and nothing narrows the grant at runtime. It declares no `model:`, so it runs on the session's model. Inherits every harness cap (nesting depth 2, spawn/budget ceiling, abort kill-switch).
|
|
106
|
+
- **Tier 1 — Squads (`squads.cjs`):** role-scoped groupings of existing agents — Architecture (design), Build (code), Quality (adversarial review), Release (`pan-release`, human-gated) — each carrying an intended `access` contract the conductor is told to honour when delegating. Those `access` values are advisory metadata: the module's own header says it "modifies no agent and changes no execution path", so the enforced grant remains each agent's `tools:` frontmatter. A drift test pins squad roster ⇄ agent files ⇄ `AGENT_BASE_EFFORT`.
|
|
107
|
+
- **Build isolation (`worktree.cjs`):** each Build agent gets its own `army/<task>` branch + git worktree, so parallel builders never share a tree or file. Generalized from `whatif.cjs`.
|
|
108
|
+
- **Human-gated ship:** `pan-release` prepares a squash-merge and surfaces an `always-ask` approval; a human merges to the protected branch. Recovery is `git revert` / previous tag — never force-push.
|
|
109
|
+
- **Learn step (= "Dreaming"):** `/pan:retro` (and `/pan:learn` when traces exist) report the recurring patterns, and Mission Control carries them into the next mission's plan. A pattern that should outlast the campaign goes to the human at the merge gate as a proposed line for the project's instructions; agent memory is not loaded into agents.
|
|
110
|
+
- **Scheduled campaigns (`campaign.cjs`, ADR-0034):** `/pan:army --schedule <cadence>` arms a self-resuming campaign with a per-day budget. PAN owns the schedule descriptor + due-check; an external trigger (host scheduler / `/loop`; a session-open nudge is documented in ADR-0034 but not built) fires `/pan:army --continue` when due. It is not a daemon and never lowers the human merge gate — autonomy runs up to the merge, a human at the merge.
|
|
111
|
+
- **Observability HUD (`hud.cjs`, ADR-0035):** `/pan:hud` renders a single self-contained `.planning/hud.html` aggregating mission, roadmap, command stack (Mission Control → squads → agents), campaign schedule, safety harness, active worktrees, telemetry, and requirements/quality. A read-only **view** — it owns no state and writes only its own file, so it can never corrupt planning data. Army-only panels appear only when a campaign is scheduled or army worktrees exist.
|
|
112
|
+
|
|
113
|
+
### Optimization, git and distill additions
|
|
114
|
+
|
|
115
|
+
New core modules, commands, agents, hooks, and workflows layered on the existing architecture without breaking changes:
|
|
116
|
+
|
|
117
|
+
- **Circular optimization loop:** `optimize.cjs` + `pan-optimizer` agent + `/pan:learn` + `/pan:learn --optimize` commands. The trace → learn → apply cycle turns a session's recurring failures into ranked suggestions, each naming where a person should make the fix (the project's instructions, a test, an agent prompt); `optimize apply` records them and changes nothing an agent reads. Powered by the `pan-trace-logger.js` SubagentStop hook, which auto-creates day-scoped trace sessions with zero setup.
|
|
118
|
+
- **`/pan:git` family:** `git.cjs` gives phase-aware git subcommands (commit/branch/push/status/log/stash/diff/rollback/tag/sync) with the same safety checks as `pan-tools commit` (deleted-file detection, sensitive-file blocking via `runCommitSafetyChecks`), except that a blocked `git commit` leaves what it staged in the index, where `pan-tools commit` unstages its own additions. Branch naming follows `pan/phase-N` convention.
|
|
119
|
+
- **Distill optimizer:** `distill.cjs` + `pan-distiller` agent + `distill` focus-auto category implement the SOTA agentic-refactoring pipeline (deterministic-first, LLM-on-narrow-spans, cross-session pattern memory). 5 passes: deterministic static analysis → AST-style → cross-file graph → LLM judgment on flagged spans only → cross-session memory at `.planning/memory/distill-patterns.md`. Bloat budget gate (touched_LOC / essential_LOC, default 2.0x threshold).
|
|
120
|
+
- **Circular loop blind-spot fixes (W1+W2+W3):** exec-phase records the reviewer's verdict with `pan-tools findings record`, which logs `verdict_failed` on NEEDS_FIXES (counted as a reviewer correction); a `load_phase_memory` step injected `.planning/memory/*.md` rules into executor context before Wave 1 (retired `2026-10-04` with the rest of the agent-memory injection, ADR-0036 amended); `logTraceEvent` auto-inherits phase number from session metadata.
|
|
121
|
+
|
|
122
|
+
### Self-Improvement Loop additions
|
|
123
|
+
|
|
124
|
+
A cross-project meta-learning loop. PAN drives autonomous external builds against fresh ideas in isolated folders, harvests the resulting telemetry back to source, and promotes generalizable findings into shipped artifacts that future installs read automatically. Closes the deferred MEMORY note "Cross-Session Learning (PATTERNS.md auto-capture)".
|
|
125
|
+
|
|
126
|
+
**Core modules backing the loop:**
|
|
127
|
+
- `pan-wizard-core/bin/lib/experiment.cjs` — scaffolds isolated experiment folders at `~/pan-experiments/<slug>/` with `.planning/idea.md` + manifest. Refuses to scaffold inside source repo (mirrors installer guard). Exports `harvestExperiment` (copy telemetry back to `<source>/experiments/<slug>/`) and `pruneExperiment` (soft-rename or hard-delete). Now also runs `initExperimentGit()` to inherit `user.email`/`user.name` from PAN source so autonomous-loop commits don't silently fail (P-EXP-001 fix).
|
|
128
|
+
- `pan-wizard-core/bin/lib/runner.cjs` — spawns external AI runtime via `spawnSync` (sync with native timeout). `RUNTIME_RUNNERS` adapter map: claude/codex/gemini/opencode supported; copilot is `null` (no adapter yet, although `copilot -p` runs headless; the PAN Harness drives it that way). DEFAULT_TIMEOUT_MS bumped to 60 min after typical 3-plan phases timed out at 30 min.
|
|
129
|
+
- `pan-wizard-core/bin/lib/learn-lint.cjs` — `pan-tools learn lint` integrity checks for the patterns store. Catches L-001 duplicate IDs across files, L-002 dangling pattern cross-references, L-003 empty `source_experiments` while body cites a known experiment, L-004 universal-scope rule prose using PAN-internal terms, L-005 revision marker without `superseded_by` frontmatter on the base, L-006 universal-scope pattern citing an internal pattern id, L-007 a pattern whose `cites` no longer holds (the cited file or symbol is gone). Wired into `/check`. Exits non-zero on errors.
|
|
130
|
+
- `pan-wizard-core/bin/lib/learn-index.cjs` — `pan-tools learn build-index` generates `pan-wizard-core/learnings/index.json` with topic→agent-relevance map, byte/token-est sizes. `pan-tools learn topics-for --agent <role> [--token-budget N]` returns the budget-aware selected subset. Workflow files (`plan-phase.md`, `exec-phase.md`, `verify-phase.md`, `execute-plan.md`) now call `topics-for` instead of skim-the-folder, addressing the P-RES-002 distractor-density anti-pattern PAN was previously shipping.
|
|
131
|
+
|
|
132
|
+
**One new agent:** `pan-experiment-runner` — observation-only watchdog. Tools restricted to `[Read, Bash, Glob, Grep]`. Cannot edit experiment files; reports back to the orchestrating user.
|
|
133
|
+
|
|
134
|
+
**One new command:** `commands/pan/experiment.md` with subcommands new/list/manifest/run/status/stop/harvest/prune.
|
|
135
|
+
|
|
136
|
+
**One new template:** `pan-wizard-core/templates/idea.md` — structured idea-doc shape consumed by `experiment new`.
|
|
137
|
+
|
|
138
|
+
**Two-tier learnings layout** (new top-level dir under `pan-wizard-core/`):
|
|
139
|
+
- `learnings/universal/` — AI-derived patterns shipped to all 5 runtime installs alongside `references/`
|
|
140
|
+
- `learnings/internal/` — PAN-development-specific patterns; **source-only** (installer strips this)
|
|
141
|
+
|
|
142
|
+
The two-tier split prevents PAN-internal patterns ("always commit individually because of source repo's hooks") from leaking to user installs as universal advice. Negative test in `tests/scenarios/learnings-installed.test.cjs` enforces the split.
|
|
143
|
+
|
|
144
|
+
**Extended `optimize.cjs`:** `promotePattern` / `listPromotedPatterns` / `unpromotePattern` write findings into topic files under `learnings/{universal,internal}/`. Topic files use markdown with structured frontmatter (zero-deps minimal parser; not standard YAML).
|
|
145
|
+
|
|
146
|
+
**Workflow cross-references:** the long workflows now reference `learnings/universal/` after `references/guardrails.md`. They load only the topics `learn topics-for --cue` picks for the task; a new topic file joins that choice once `pan-tools learn build-index` has indexed it.
|
|
147
|
+
|
|
148
|
+
**Manual promote gate:** `pan-tools learn promote --pattern <id> --scope <s> --topic <t> --summary ... --rule ...` requires explicit human input. There is no auto-promote: every promotion goes through this gate.
|
|
149
|
+
|
|
150
|
+
The `references/<topic>.md` + workflow-cross-reference pattern (proven with `guardrails.md`) is now joined by `learnings/<scope>/<topic>.md` for the AI-derived counterpart. Together they form a complete behavioral surface: human-authored canonical rules (`references/`) + AI-derived advisory patterns (`learnings/universal/`).
|
|
151
|
+
|
|
152
|
+
### Evidence loop (ADR-0049)
|
|
153
|
+
|
|
154
|
+
PAN's judges emit their verdict in a machine-readable form, the verbs record it, and the workflows branch on the record:
|
|
155
|
+
- **The verdict.** The plan checker, reviewer and design checker end their report with a `pan-verdict` block. The verifier's verdict is its verification.md frontmatter.
|
|
156
|
+
- **The record.** `pan-tools findings record` writes the verdict and its findings to `.planning/findings.jsonl` and logs it to the trace. It works on every runtime, because it is a verb rather than a hook.
|
|
157
|
+
- **Dispositions.** Findings the phase continues past get one, with a reason. `findings debt` gives the milestone audit its tech debt.
|
|
158
|
+
- **Learned suppressions.** A finding dismissed with a reason is filtered when the same judge raises it again, for as long as its file is unchanged; once the file changes it comes back open. Security and logic findings, and findings with no file, are never suppressed. `findings suppressions` lists what is being filtered.
|
|
159
|
+
- **Tool failures.** On Claude Code the trace hook also records the failed tool calls inside each subagent's own transcript, redacted.
|
|
160
|
+
|
|
161
|
+
`optimize learn` ranks tool failures by the spawns they recur in and counts each judge's failures and retries, and `optimize revert` undoes an apply exactly.
|
|
162
|
+
|
|
163
|
+
### Reasoning-trace handoff (P-RES-003)
|
|
164
|
+
|
|
165
|
+
The serial pipeline (planner → researcher → executor → verifier) hands work file-mediated. Plan and summary artifacts traditionally carried only OUTPUTS, not the reasoning that produced them. Per Cognition (June 2025) "Don't build multi-agents", silent decisions in upstream artifacts force downstream agents to reconcile contradictions blindly. PAN now passes the reasoning trace explicitly:
|
|
166
|
+
|
|
167
|
+
- **`pan-wizard-core/references/handoff-decisions.md`** — schema for `## Plan Decisions` (in plan.md) and `## Implementation Decisions` (in summary.md). Plan Decisions buckets: Locked / Open / Considered+rejected; Implementation Decisions buckets: Taken / Deviations / Open questions.
|
|
168
|
+
- **`agents/pan-planner.md`** — emits `## Plan Decisions` between objective and tasks.
|
|
169
|
+
- **`agents/pan-executor.md`** — reads Plan Decisions before coding, writes Implementation Decisions when deviating from the plan.
|
|
170
|
+
- **`agents/pan-verifier.md`** — Step 1b consumes the reasoning trace; Step 1c reads `.planning/codebase/conventions.md` per P-RES-005 (repo-norm violation detection).
|
|
171
|
+
- **`agents/pan-plan-checker.md`** — Dimension 11 (Spec Sufficiency for Handoff, P-RES-004) + Dimension 12 (Decision Trace Completeness, P-RES-003) verify that plans carry enough decision context for downstream agents.
|
|
172
|
+
- **Summary templates** (`templates/summary-{minimal,standard,complex}.md`) — all three variants carry the Implementation Decisions section.
|
|
173
|
+
|
|
174
|
+
### Production-readiness gates
|
|
175
|
+
|
|
176
|
+
- **`verifyInstall()`** (in `bin/install-lib.cjs`, called post-install by `bin/install.js`) — post-install manifest walk checks every entry in `pan-file-manifest.json` exists on disk and is non-empty; missing or 0-byte files fail with exit 1. **`verifyHookEntrypoints()`** then checks that every hook command about to be registered runs a script that exists and has content; a miss (a source checkout without `npm run build:hooks`) fails with exit 1 before any runtime config is written, so no dead hook is registered. `INSTALL_WARNINGS` collector hardens `copyWithPathReplacement` (mkdir failures hard-throw; per-file failures collected as warnings rather than silently swallowed).
|
|
177
|
+
- **`scripts/release-check.js`** — multi-gate pre-publish validation (build:hooks → test:all → npm audit → doc-lint counts → links validate → npm pack + zero-dependency check → smoke install → distribution bundles → coverage gate). Wired to `package.json prepublishOnly` so `npm publish` cannot ship a broken release.
|
|
178
|
+
- **`pan-tools commit --fail-on-error`** — routes a git refusal through `error()` (bare message on stderr) rather than a `commit_failed` JSON body (closes P-EXP-001 silent-failure surface where missing git identity in fresh experiment folders looked successful). Since `output()` derives the exit code from the payload, `commit_failed` exits non-zero with or without the flag — see CLI-REFERENCE "Error Shape".
|
|
179
|
+
|
|
180
|
+
### Behavioral Guardrails Layer
|
|
181
|
+
|
|
182
|
+
A consolidated AI-behavior rules surface, adopted from Google `agents-cli` patterns. Additive only; zero breaking changes.
|
|
183
|
+
|
|
184
|
+
- **`references/guardrails.md`** — single grep-friendly file naming the top anti-patterns (silent model swaps, skipping verification, scope creep, manual focus picks, lagging docs), the **Code Preservation Principle** (surgical edits — preserve config values, comments, formatting outside the user's explicit target), and the **Stop-the-Line Rule** (regressions halt feature work).
|
|
185
|
+
- **`## Re-Read Checkpoints`** sections in long workflows (`exec-phase`, `plan-phase`, `verify-phase`, `execute-plan`) — explicit boundaries where the agent is directed to re-read specific sections, preventing context-compaction drift across long autonomous sessions.
|
|
186
|
+
- **Phase 0 Clarify gates** — MANDATORY in `new-project.md` (problem/success/scope/constraints check before scaffolding), recommended in `plan-phase.md` (phase-scope check). `--auto` mode short-circuits when a PRD is provided.
|
|
187
|
+
- **Agent cross-references** — `pan-reviewer` flags Code Preservation violations at high severity; `pan-planner` enforces guardrails in generated `<deviation_rules>` blocks.
|
|
188
|
+
|
|
189
|
+
The `references/` directory's role is now both **structural** (existing patterns: tdd, verification, checkpoints, model-profiles, etc.) and **behavioral** (guardrails). The `references/<topic>.md` + workflow-cross-reference pattern is the established way to add behavioral layers without bloating workflow files.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Layer 1: Commands
|
|
194
|
+
|
|
195
|
+
**Location:** `commands/pan/*.md`
|
|
196
|
+
|
|
197
|
+
Commands are Markdown files that become slash commands in the user's runtime, invoked as `/pan:filename` (Claude Code, Gemini), `/pan-filename` (OpenCode, Copilot CLI), or `$pan-filename` (Codex).
|
|
198
|
+
|
|
199
|
+
Commands are thin orchestrators that:
|
|
200
|
+
|
|
201
|
+
- Parse user-provided arguments
|
|
202
|
+
- Read current state from `.planning/`
|
|
203
|
+
- Reference the appropriate workflow
|
|
204
|
+
- Route results back to the user
|
|
205
|
+
|
|
206
|
+
Most commands do no heavy work directly: their substantive logic lives in workflows (Layer 2) or the core library (Layer 4). The self-contained commands below are the exception: they carry their own orchestration in the command file.
|
|
207
|
+
|
|
208
|
+
### Command Categories
|
|
209
|
+
|
|
210
|
+
| Category | Commands |
|
|
211
|
+
|----------|----------|
|
|
212
|
+
| **Getting Started** | new-project, map-codebase |
|
|
213
|
+
| **Phase Lifecycle** | discuss-phase, design-phase, plan-phase (`--research-only`), exec-phase, verify-phase |
|
|
214
|
+
| **Phase Management** | add-phase, insert-phase, remove-phase, assumptions, phase-tests, phase-budget |
|
|
215
|
+
| **Session & Progress** | progress, quick, pause, resume |
|
|
216
|
+
| **Milestone** | milestone-new, milestone-done (`--cleanup`), milestone-audit (`--gaps`) |
|
|
217
|
+
| **Focus** | focus-auto (`--step scan\|plan\|exec\|drift`), focus-docs (`--sync`), focus-design |
|
|
218
|
+
| **System** | help, health, settings (`--profile`), update, debug, todo-add, todo-check |
|
|
219
|
+
| **Deployment** | retro |
|
|
220
|
+
| **Community** | patches |
|
|
221
|
+
| **Spec B v2** | cost, preview, review-deep, knowledge, what-if |
|
|
222
|
+
| **Optimization & Git** | learn (`--optimize`), git |
|
|
223
|
+
| **Self-Improvement Loop** | experiment |
|
|
224
|
+
| **Bot Army & Observability** | army, hud, report, hygiene, links |
|
|
225
|
+
|
|
226
|
+
### Command-Only Files (No Workflow)
|
|
227
|
+
|
|
228
|
+
These commands are self-contained in their `.md` file and do not delegate to a separate workflow; so are `army`, `autodev`, `cost`, `experiment`, `git`, `hud`, `hygiene`, `knowledge`, `links`, `preview`, `report`, `review-deep` and `what-if`, none of which references a workflow file (`autodev` runs `pan-tools autodev`, whose lean execute unit reads `exec-lean.md` in its own session):
|
|
229
|
+
|
|
230
|
+
| Command | Reason |
|
|
231
|
+
|---------|--------|
|
|
232
|
+
| `phase-budget.md` | Calls `pan-tools.cjs context-budget` directly; no multi-step workflow |
|
|
233
|
+
| `patches.md` | User-guided manual process; no automated workflow |
|
|
234
|
+
| `debug.md` | Self-contained debug orchestrator; spawns pan-debugger directly |
|
|
235
|
+
| `design-phase.md` | Self-contained design orchestrator; spawns pan-designer and pan-design-checker directly (max 2 revision iterations) |
|
|
236
|
+
| `milestone-done.md` | Self-contained milestone close-out (archive, tag, offer `/pan:milestone-new`); only `--cleanup` loads a workflow (`milestone-cleanup.md`) |
|
|
237
|
+
| `focus-auto.md` | Self-contained auto-runner; calls `pan-tools focus auto` for state management. `--step` loads one stage workflow instead (see the mapping below) |
|
|
238
|
+
| `focus-design.md` | Self-contained multi-phase feature investigation pipeline |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Layer 2: Workflows
|
|
243
|
+
|
|
244
|
+
**Location:** `pan-wizard-core/workflows/*.md`
|
|
245
|
+
|
|
246
|
+
Workflows are Markdown files with XML-structured multi-step procedures. Each workflow defines:
|
|
247
|
+
|
|
248
|
+
- What files to read for context
|
|
249
|
+
- What `pan-tools.cjs` commands to run for bootstrapping
|
|
250
|
+
- What agents to spawn (and in what order / parallelism)
|
|
251
|
+
- What verification steps to perform
|
|
252
|
+
- How to commit results
|
|
253
|
+
|
|
254
|
+
Commands reference workflows. Workflows are the procedural backbone of the system.
|
|
255
|
+
|
|
256
|
+
### Command-to-Workflow Mapping
|
|
257
|
+
|
|
258
|
+
Some workflows have different names than their corresponding commands. This is intentional — workflows use descriptive internal names while commands use user-facing names:
|
|
259
|
+
|
|
260
|
+
| Command | Workflow | Reason |
|
|
261
|
+
|---------|----------|--------|
|
|
262
|
+
| `resume.md` | `resume-project.md` | Command is user action; workflow is system operation |
|
|
263
|
+
| `exec-phase.md` | `exec-phase.md` + `execute-plan.md` | Orchestrator + per-plan worker |
|
|
264
|
+
| (no command) | `transition.md` | Internal phase-to-phase transition logic |
|
|
265
|
+
| `verify-phase.md --uat` | `uat-walkthrough.md` (which follows `diagnose-issues.md` for the gaps it finds) | Folded-in command keeps its workflow behind a flag |
|
|
266
|
+
| `plan-phase.md --research-only` | `research-phase.md` | Same |
|
|
267
|
+
| `milestone-done.md --cleanup` | `milestone-cleanup.md` | Same |
|
|
268
|
+
| `milestone-audit.md --gaps` | `milestone-gaps.md` | Same |
|
|
269
|
+
| `learn.md --optimize` | `optimize.md` | Same |
|
|
270
|
+
| `settings.md --profile` | `profile.md` | Same |
|
|
271
|
+
| `focus-auto.md --step scan\|plan\|exec\|drift` | `focus-scan.md`, `focus-plan.md`, `focus-exec.md`, `focus-drift-walking.md` | Same |
|
|
272
|
+
| `focus-docs.md` (`--sync`) | `focus-doc-audit.md` (`focus-sync.md`) | Same |
|
|
273
|
+
|
|
274
|
+
### Internal Workflows
|
|
275
|
+
|
|
276
|
+
No user command runs these workflows directly: `execute-plan.md`, `transition.md` and `diagnose-issues.md` are invoked by other workflows, and `exec-lean.md` by autodev's execute unit for a lean phase:
|
|
277
|
+
|
|
278
|
+
| Workflow | Purpose |
|
|
279
|
+
|----------|---------|
|
|
280
|
+
| `execute-plan.md` | Per-plan execution worker (spawned by `exec-phase.md` per plan) |
|
|
281
|
+
| `transition.md` | Phase-to-phase transition logic |
|
|
282
|
+
| `exec-lean.md` | A lean phase in one session: the executor's work, then one reviewer pass and the verifier (autodev's execute unit, `autodev.cjs`) |
|
|
283
|
+
| `diagnose-issues.md` | One debugger per failed UAT truth, root cause only; followed by `uat-walkthrough.md` (`/pan:verify-phase --uat`) for the gaps it records, and ported to the native `/pan-diagnose-issues` script on Claude Code |
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Layer 3: Agents
|
|
288
|
+
|
|
289
|
+
**Location:** `agents/*.md`
|
|
290
|
+
|
|
291
|
+
Agents are Markdown files that define specialized AI roles. Each agent runs as a subagent in a fresh context window, spawned by workflows via the `Task` tool.
|
|
292
|
+
|
|
293
|
+
| Agent | Role | Spawned By |
|
|
294
|
+
|-------|------|-----------|
|
|
295
|
+
| `pan-project-researcher` | Answers at most five open questions that block building (opt-in research) | `/pan:new-project`, `/pan:milestone-new` |
|
|
296
|
+
| `pan-roadmapper` | Creates phased roadmaps from requirements | `/pan:new-project`, `/pan:milestone-new` |
|
|
297
|
+
| `pan-document_code` | Analyzes existing codebase (one focus area per mapper, or the whole repo in single-shot mode) | `/pan:map-codebase` (parallel when sharded; one agent in single-shot mode) |
|
|
298
|
+
| `pan-designer` | Designs specs before planning | `/pan:design-phase` |
|
|
299
|
+
| `pan-design-checker` | Validates design specs | `/pan:design-phase`, `/pan:focus-design` |
|
|
300
|
+
| `pan-phase-researcher` | Answers at most five open questions that block planning a phase (opt-in: `--research` or `workflow.research`) | `/pan:plan-phase`, `/pan:plan-phase --research-only` |
|
|
301
|
+
| `pan-planner` | Creates executable plan.md files | `/pan:plan-phase`, `/pan:quick` |
|
|
302
|
+
| `pan-plan-checker` | Validates plans against goals across multiple dimensions | `/pan:plan-phase`, `/pan:quick --full` |
|
|
303
|
+
| `pan-executor` | Executes plans with atomic commits | `/pan:exec-phase`, `/pan:quick`, `/pan:army` (Build squad) |
|
|
304
|
+
| `pan-verifier` | Verifies phase delivered what it promised | `/pan:exec-phase`, `/pan:quick --full`, autodev's `exec-lean.md` (lean phase) |
|
|
305
|
+
| `pan-reviewer` | Read-only code review (conventions, security, quality) | `/pan:exec-phase` (kept on a lean phase, which skips only test generation), autodev's `exec-lean.md` |
|
|
306
|
+
| `pan-integration-checker` | Verifies cross-phase wiring and E2E flows | `/pan:milestone-audit` |
|
|
307
|
+
| `pan-debugger` | Systematic bug investigation | `/pan:debug`, `/pan:verify-phase --uat` (the `diagnose-issues` workflow, one debugger per failed truth), native `/pan-diagnose-issues` script (Claude Code) |
|
|
308
|
+
| `pan-previewer` | Foresight — blast radius / dependency graph / milestone ETA | `/pan:preview` |
|
|
309
|
+
| `pan-hardener` | OWASP Top 10 + STRIDE security audit | `/pan:review-deep`, `/pan:exec-phase --deep-review`, `/pan:focus-auto` (security category Pass 3, and `--step exec --deep-review`) |
|
|
310
|
+
| `pan-meta-reviewer` | Reviews reviewer + hardener output; flags missed issues | `/pan:review-deep`, `/pan:exec-phase --deep-review`, `/pan:focus-auto --step exec --deep-review` |
|
|
311
|
+
| `pan-knowledge` | Grounded Q&A / multi-turn discussion / playbook generation | `/pan:knowledge` |
|
|
312
|
+
| `pan-counterfactual` | Explores alternative phase approaches in isolated worktree | `/pan:what-if` |
|
|
313
|
+
| `pan-conductor` | Top-level hierarchical exec orchestrator with safety harness | `/pan:exec-phase --hierarchical`, `/pan:army` (Mission Control) |
|
|
314
|
+
| `pan-optimizer` | Reads trace events; identifies error/gap/redundancy patterns; produces ranked optimization report with auto-apply JSON block | `/pan:learn` (`/pan:learn --optimize apply` records its suggestions) |
|
|
315
|
+
| `pan-distiller` | Read-only LLM judgment on AI code-bloat findings; receives only flagged spans (max 50 lines context); proposes minimal diff rewrite | `/pan:focus-auto --category distill` |
|
|
316
|
+
| `pan-experiment-runner` | Observation-only watchdog that drives an external AI session against an isolated experiment folder; reports back to the orchestrator | — (no shipped command spawns it directly; `/pan:experiment run` drives the runtime through `runner.cjs`; listed among the tier-2 `workers` Mission Control may delegate to under `/pan:army`) |
|
|
317
|
+
| `pan-release` | Release squad agent: prepares the squash-merge, surfaces an always-ask approval; a human merges to the protected branch | `/pan:army` (Release squad) |
|
|
318
|
+
|
|
319
|
+
Every agent starts with zero context and receives only what it needs. This is PAN's key quality guarantee — agents never suffer from context degradation.
|
|
320
|
+
|
|
321
|
+
For deep dives on each agent's inputs, outputs, behaviors, and unique features, see [AGENTS.md](AGENTS.md).
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Layer 4: Core Library
|
|
326
|
+
|
|
327
|
+
**Location:** `pan-wizard-core/bin/lib/*.cjs`
|
|
328
|
+
**CLI entry:** `pan-wizard-core/bin/pan-tools.cjs`
|
|
329
|
+
|
|
330
|
+
The Node.js runtime layer. Zero external dependencies — only Node.js built-in modules (`fs`, `path`, `child_process`, `os`, `crypto`; the CLI entry also loads `module` to turn on Node's compile cache). Commands and workflows call `pan-tools.cjs` via bash and parse JSON output.
|
|
331
|
+
|
|
332
|
+
### CLI Interface
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
node pan-tools.cjs <command> [subcommand] [args...] [--raw] [--cwd <path>]
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
All output is JSON by default. Pass `--raw` for human-readable output. When JSON output exceeds ~50KB, it is written to a tmpfile and the path is returned with an `@file:` prefix.
|
|
339
|
+
|
|
340
|
+
### CLI Command Categories
|
|
341
|
+
|
|
342
|
+
The dispatcher in `pan-tools.cjs` routes top-level commands (plus `init` sub-cases) to the modules:
|
|
343
|
+
|
|
344
|
+
| Category | Example Commands |
|
|
345
|
+
|----------|-----------------|
|
|
346
|
+
| **State** | `state load`, `state update`, `state get`, `state json`, `state advance-plan`, `state record-metric`, `state init`, `state section`, `state quick-task`, `state apply` |
|
|
347
|
+
| **Phase** | `phases list`, `phase add`, `phase insert`, `phase remove`, `phase complete [--force --reason <r>]`, `phase gate <N>`, `phase next-decimal` |
|
|
348
|
+
| **Roadmap** | `roadmap get-phase`, `roadmap analyze`, `roadmap update-plan-progress`, `roadmap slice <N> [--write]`, `roadmap compact [--apply] [--keep N]` |
|
|
349
|
+
| **Config** | `config-get`, `config-set`, `config-ensure-section` |
|
|
350
|
+
| **Frontmatter** | `frontmatter get`, `frontmatter set`, `frontmatter merge`, `frontmatter validate` |
|
|
351
|
+
| **Template** | `template select`, `template fill` |
|
|
352
|
+
| **Scaffold** | `scaffold context`, `scaffold uat`, `scaffold verification`, `scaffold phase-dir` |
|
|
353
|
+
| **Verify** | `verify plan-structure`, `verify phase-completeness`, `verify references`, `verify commits`, `verify artifacts`, `verify key-links`, `verify reconcile`, `verify stubs`, `verify scope`, `verify stale`, `verify plan-set`, `verify test-integrity`, `verify red`, `verify mutate`, `verify review-focus`, `verify decisions`, `verify gates`, `verify requirements`, `verify traceability` |
|
|
354
|
+
| **Test** | `test run [--baseline]`, `test detect` |
|
|
355
|
+
| **Review / Research** | `review scope <phase>`, `review cross-family <phase>`, `review vote`, `research lint <phase\|path>`, `research check <questions> <research> [--market]` |
|
|
356
|
+
| **Size** (right-sized ceremony) | `size phase <N> [--quality] [--full]`, `size task "<description>" \| --file <path>`, `size phase-plan <N>`, `size quick-plan --out <file> [--num N] "<description>"`, `size plan-check <N>` |
|
|
357
|
+
| **Validate** | `validate consistency`, `validate health`, `validate deployment` |
|
|
358
|
+
| **Init** | `init execute-phase`, `init plan-phase`, `init new-project`, `init quick`, `init progress` (compound commands for each major workflow) |
|
|
359
|
+
| **Milestone** | `milestone complete`, `requirements mark-complete` |
|
|
360
|
+
| **Focus** | `focus scan`, `focus plan`, `focus sync`, `focus exec`, `focus auto`, `focus design`, `focus classify-stages`, `focus reflection` |
|
|
361
|
+
| **Memory** (E-4) | `memory read`, `memory append`, `memory list`, `memory compact`, `memory select`, `memory record`, `memory prune`, `memory budget`, `memory optimize`, `memory rebuild` |
|
|
362
|
+
| **Cache** (E-1) | `cache prime [--summary]` |
|
|
363
|
+
| **Codebase** (E-2 extended) | `codebase detect-languages`, `codebase analyze-imports`, `codebase best-practices`, `codebase estimate-size` |
|
|
364
|
+
| **Cost** (Spec B v2 Y-6) | `cost report`, `cost append`, `cost clear`, `cost rebuild`, `cost limits`, `cost budget`; `usage` (installed commands and agents used, never used, unfinished) |
|
|
365
|
+
| **Bus** (Spec B v2 Y-7) | `bus publish`, `bus drain`, `bus list` |
|
|
366
|
+
| **Preview** (Spec B v2 Y-1) | `preview phase <N>`, `preview phases`, `preview milestone` |
|
|
367
|
+
| **Review-Deep** (Spec B v2 Y-2) | `review-deep merge`, `review-deep analyze` |
|
|
368
|
+
| **Findings** (evidence loop, ADR-0049) | `findings record`, `findings list`, `findings dispose`, `findings debt`, `findings suppressions`, `findings prove` |
|
|
369
|
+
| **Knowledge** (Spec B v2 Y-3) | `knowledge ask`, `knowledge discuss`, `knowledge playbook` |
|
|
370
|
+
| **What-if** (Spec B v2 Y-4) | `whatif prepare`, `whatif report`, `whatif cleanup` |
|
|
371
|
+
| **Optimize** | `optimize trace init/end/current/list/log`, `optimize learn [--sessions N]`, `optimize apply`, `optimize revert <apply_id>` / `--last`, `optimize list`, `optimize stats`, `learn` (alias) |
|
|
372
|
+
| **Git** | `git commit`, `git branch`, `git push`, `git status`, `git log`, `git stash`, `git diff`, `git rollback`, `git tag`, `git sync` |
|
|
373
|
+
| **Distill** | `distill scan`, `distill analyze`, `distill report` |
|
|
374
|
+
| **Squads** (ADR-0032) | `squad list`, `squad show <name>` |
|
|
375
|
+
| **Worktree** (ADR-0033) | `worktree list`, `worktree create <task>`, `worktree remove <path>`, `worktree cleanup` |
|
|
376
|
+
| **Campaign** (ADR-0034) | `campaign schedule`, `campaign status`, `campaign due`, `campaign record-run` |
|
|
377
|
+
| **HUD** (ADR-0035) | `hud [--out <f>] [--open] [--stdout]` |
|
|
378
|
+
| **Report** | `report phase <N>` and `report index` (`[--out <f>] [--open] [--stdout]`; `index` also `--bundle`), `report all [--open]` |
|
|
379
|
+
| **Standards** | `standards list`, `standards select`, `standards remove`, `standards status`, `standards recommend`, `standards phase-track`, `standards tools` |
|
|
380
|
+
| **Operations** | `preflight`, `dashboard`, `learnings extract`, `learnings list`, `learnings prune`, `deps validate` |
|
|
381
|
+
| **Learnings & lint** | `learn promote/unpromote/list-promoted/build-index/topics-for/lint`, `skills index/align`, `hygiene scan/clean`, `links validate`, `doc-lint` |
|
|
382
|
+
| **Autonomy** | `autodev run`, `autodev resume`, `autodev status`, `autodev report`, `autodev replay`, `next-action`, `worktree preflight` |
|
|
383
|
+
| **UAT / Debug / Merge** | `uat record`, `uat status`, `debug repro`, `debug similar`, `merge request`, `merge confirm` |
|
|
384
|
+
| **Utility** | `resolve-model`, `models check`, `generate-slug`, `current-timestamp`, `context-budget`, `websearch`, `progress`, `todo`, `version` |
|
|
385
|
+
|
|
386
|
+
### Module Inventory
|
|
387
|
+
|
|
388
|
+
| Module | Responsibility |
|
|
389
|
+
|--------|----------------|
|
|
390
|
+
| `constants.cjs` | Shared path constants, file patterns, regex patterns. Foundation module. |
|
|
391
|
+
| `core.cjs` | Model profile table, `output()`/`error()` helpers, `toPosix()`, `safeReadFile()`, `loadConfig()`, `resolveModelInternal()`, `findPhaseInternal()`, `generateSlugInternal()`, `scanPendingTodos()`, `execGit()`, and the line-ending helpers `toLf()`/`dominantEol()`/`withEol()` (parse planning files on LF, write them back in their own ending) |
|
|
392
|
+
| `utils.cjs` | Shared utilities: `readJsonFile()`, `planningPath()`, `listPhaseDirs()`, `filterPlanFiles()`, `filterSummaryFiles()`, `classifyPhaseStatus()`, `planningRel()` |
|
|
393
|
+
| `frontmatter.cjs` | YAML-like frontmatter CRUD: `extractFrontmatter()`, `reconstructFrontmatter()`, get/set/merge/validate |
|
|
394
|
+
| `config.cjs` | Config CRUD: create default `config.json`, get/set with dot-notation paths (e.g., `workflow.auto_advance`), standards catalog (list, select, remove, status, recommend, phase-track, tools) |
|
|
395
|
+
| `state.cjs` | state.md operations: load, get, update, patch, json output (`state load` and `state json` carry `contract: "1.0"`, `STATE_CONTRACT` in constants.cjs, as `progress` JSON does), `readStateSafe()`, frontmatter sync; writes serialize through lock.cjs (ADR-0030) |
|
|
396
|
+
| `lock.cjs` | Advisory file locking (`withFileLock`, stale-steal) + atomic temp-rename writes (`writeFileAtomic`) for .planning/ concurrency (ADR-0030) |
|
|
397
|
+
| `init.cjs` | Compound init commands: bootstrap all file paths and config for execute-phase, plan-phase, progress, phase-op, and the other major workflows |
|
|
398
|
+
| `phase.cjs` | Phase CRUD facade: list, add, insert (decimal numbering), complete, next-decimal; re-exports phase-remove.cjs |
|
|
399
|
+
| `phase-remove.cjs` | Phase removal + decimal/integer renumbering cascade, roadmap reference rewriting; extracted from phase.cjs |
|
|
400
|
+
| `roadmap.cjs` | roadmap.md parsing: get-phase, analyze, update-plan-progress, and `roadmap slice` (`buildRoadmapSlice`): a line for every phase, this phase's section, its dependencies' goals and its requirement lines, written with `--write` to `XX-roadmap-slice.md` for phase agents to read in place of the whole roadmap and requirements. A section `roadmap compact` left as a stub is read back from `roadmap-history.md`. |
|
|
401
|
+
| `verify.cjs` | Verification suite facade: verify-summary, validate-consistency, validate-health; re-exports the verify-* submodules below |
|
|
402
|
+
| `verify-drift.cjs` | Convention-drift detection (drift-check); extracted from verify.cjs |
|
|
403
|
+
| `verify-retro.cjs` | Milestone retrospective (retro); extracted from verify.cjs |
|
|
404
|
+
| `verify-deploy.cjs` | Deployment validation (validate deployment); extracted from verify.cjs |
|
|
405
|
+
| `verify-preflight.cjs` | Pre-execution gates (preflight, deps validate); extracted from verify.cjs |
|
|
406
|
+
| `milestone.cjs` | Milestone lifecycle: complete (archive roadmap/requirements, create milestones.md), requirements mark-complete |
|
|
407
|
+
| `commands.cjs` | Utility commands facade: history-digest, summary-extract, scaffold, progress, todo, websearch, commit, rollback-snapshot; re-exports commands-learnings.cjs |
|
|
408
|
+
| `commands-learnings.cjs` | Error patterns (PAT-NNN), session history, learnings (LEARN-NNN) lifecycle + shared phase-summary collector; extracted from commands.cjs |
|
|
409
|
+
| `template.cjs` | `template select` picks a plan's summary template (minimal/standard/complex) from its task count, file mentions and decisions; `template fill` writes pre-filled plan, summary and verification files from skeletons it builds itself. Reads no file under `pan-wizard-core/templates/`. |
|
|
410
|
+
| `context-budget.cjs` | Context window utilization estimation: token counting, budget status (healthy/warning/critical), phase file scanning |
|
|
411
|
+
| `focus.cjs` | Strategic project management: work item scanning, priority classification, capacity-budgeted batch planning, doc staleness checking, execution pipeline data layer. Also: `classifyStageDependencies()`, `determineContinuation()` (reflection gate). |
|
|
412
|
+
| `codebase.cjs` | Codebase analysis: `detect-languages`, `analyze-imports`, `best-practices` scoring across 5 categories, plus `estimateRepoTokenSize()` for single-shot mode decision. |
|
|
413
|
+
| `memory.cjs` | Cross-phase agent memory store (E-4): `readMemory`, `appendMemory`, `compactMemory`, `listMemoryAgents`, plus cited, verified, expiring entries (`selectMemory`, `pruneMemory`) and the gated `recordLesson`. Append-only files at `.planning/memory/<agent>.md`. Agent-name validated against `^[a-zA-Z0-9_-]+$` to block path traversal. No workflow loads it into agents (ADR-0036, amended `2026-10-04`). |
|
|
414
|
+
| `bus.cjs` | (Y-7) File-backed message channels at `.planning/bus/<channel>.jsonl`: `publish`, `readChannel`, `drain` (peek/consume/archive modes), `listChannels`. Agent audit trail for hierarchical exec and review-deep coordination. |
|
|
415
|
+
| `cost.cjs` | (Y-6) Per-call cost aggregation: `appendRecord`, `readRecords`, `aggregate`, `computeCost`, `renderTable`, `renderChart`. Log at `.planning/metrics/tokens.jsonl`. Ships a default per-model rate table (kept current in `cost.cjs`, matched by exact id then family prefix) plus per-tier fallbacks; override via `cost.rates` config, which wins over a managed Claude Code `modelPricing` block (its `overrides` rows × its `multiplier`; the multiplier also scales the built-in rates). |
|
|
416
|
+
| `cost-rebuild.cjs` | `cost rebuild` (reads `cost.cjs`, `core.cjs`, `utils.cjs`): regenerates the ledger from Claude Code's transcripts under `<config dir>/projects/<encoded cwd>/` — `sumTranscriptUsage` (one turn per `message.id`), `mapAgentsFromParent` (agent id → type/model from the main thread's `Agent` calls), `listAgentFiles` (direct and Workflow-tool subagents), `planRebuild` (dry run: per-session before → after), `applyRebuild` (moves the old ledger aside, idempotent). Supersedes hook rows of rebuilt sessions; keeps rows whose transcript is gone and caller-appended rows. |
|
|
417
|
+
| `preview.cjs` | (Y-1) Foresight data layer: `buildPhasePreview` (blast radius), `buildPhaseDependencyGraph` (mermaid DAG + Kahn parallel batches + hidden-dep detection), `buildMilestoneETA` (velocity + ETA + confidence + bottleneck). |
|
|
418
|
+
| `review-deep.cjs` | (Y-2) Merges reviewer + hardener + meta-reviewer findings: `parseReviewFindings`, `mergeReviews` (verdict ladder), `writeDeepReview`. A report ending in a valid `pan-verdict` block is read from the block (verdict.cjs) instead of the bullet grammar. Publishes audit to `review-handoff` bus channel. |
|
|
419
|
+
| `knowledge.cjs` | (Y-3) Grounded Q&A + session state + playbook: `ask` (keyword-scored retrieval over CITATION_ROOTS), `loadSession`/`appendTurn` (`.planning/conversations/<phase>/`), `buildPlaybook`/`writePlaybook` (clusters memory into categorized sections). |
|
|
420
|
+
| `whatif.cjs` | (Y-4) Counterfactual phase replay: `scenarioSlug`, `buildCounterfactualContext`, `writeCounterfactualReport`, `createWorktree`/`cleanupWorktree` (git worktree lifecycle). Output at `.planning/counterfactuals/<phase>-<slug>.md`. |
|
|
421
|
+
| `optimize.cjs` | Circular optimization loop: `initTraceSession`, `logTraceEvent` (auto-inherits session phase per W3 fix; opens the day's auto-session when none is active), `analyzeEvents` (surfaces `reviewer_corrections`, `memory_primed_count`, `tool_error_patterns` and per-judge `verdict_stats`), `generateLocalReport` (`generatePooledReport` for `optimize learn --sessions N`), `applyReportRecommendations` (records a report's suggestion notes in `optimization/suggestions.md` and config notes in `config-suggestions.md`, for a person to act on; an older report's `memory`/`memory_append` actions still write, but only inside `.planning/memory/` (one naming another file is skipped), with a warning that no workflow loads it, and its `memory_entry` actions go through `memory record`; logs each action in `optimization/applied.jsonl` under an `apply_id`, and skips an action an earlier apply already wrote), `revertApply` (`optimize revert <apply_id>` / `--last`: deletes the files an apply created and cuts the text it appended, refusing a file changed since or also written by a later apply). Token telemetry falls back to wall-clock timing when `usage` block unavailable. |
|
|
422
|
+
| `git.cjs` | Phase-aware git workflow: `cmdGitCommit` (reuses `runCommitSafetyChecks`), `cmdGitBranch` (create/switch/list/delete with `pan/phase-N` naming), `cmdGitPush` (remote-validated, explicit `--force`), `cmdGitStatus`, `cmdGitLog`, `cmdGitStash` (named save/pop/list/drop), `cmdGitDiff`, `cmdGitRollback` (find pan-rollback-* tags + reset), `cmdGitTag`, `cmdGitSync` (pull + optional rebase). |
|
|
423
|
+
| `distill.cjs` | AI code-bloat 5-pass optimizer: Pass 1 deterministic (`findPhantomTryCatch`, `findUnusedImports`, `findMagicNumbers`, `findLongFunctions`, `findWideParamLists`), Pass 2 AST-style (`findSingleInstanceFactories`, `findDeepNesting`), Pass 3 cross-file (`findRepeatedBlocks`, `findUnreferencedExports`), Pass 4 LLM judgment via `pan-distiller` agent on flagged spans only, Pass 5 cross-session memory (`readPatternsMemory`, `writePatternsMemory`, `detectRegressedPatterns`). Bloat budget gate: `computeBloatBudget`. |
|
|
424
|
+
| `doc-lint.cjs` | Markdown frontmatter + structure linter (vendored from the whooo experiment). Adapter over `pan-wizard-core/bin/lib/doc-lint/{frontmatter,schema,validate,walk,reporter}.js`. Validates `commands/pan/*.md` and other PAN-shipped markdown against schemas in `pan-wizard-core/references/schemas/`. Subcommands: `doc-lint <dir>` (lint), `doc-lint schema-check` (verify schema yaml), `doc-lint counts <dir>` (drift-prone counts), `doc-lint flags` (documented `pan-tools` flags the source does not parse). |
|
|
425
|
+
| `experiment.cjs` | Self-improvement loop scaffolding. `newExperiment` (slug + idea path → scaffold `<root>/<slug>/.planning/`, copy idea, write manifest, optionally run installer), `listExperiments`, `getExperimentManifest`, `harvestExperiment` (copies the experiment's `idea.md`, `experiment.json`, `state.md`, `run-state.json`, `agent-history.json`, `optimization/` (traces included) and `phases/` into `<source>/experiments/<slug>/`), `pruneExperiment`. Hard `PAN_SOURCE_ROOT` guard prevents scaffolding inside the source repo. |
|
|
426
|
+
| `runner.cjs` | External agent runner. `runExperiment` spawns the runtime adapter (Claude/Codex/Gemini/OpenCode) via `spawnSync` against an experiment folder, observes via `run-state.json`, enforces timeout + circuit breaker. `RUNTIME_RUNNERS` adapter map (per-runtime headless invocation, `shell: 'win32'` for `.cmd` shims, arg quoting). The `captureMetrics: true` opt switches the claude adapter to `--output-format json` and `parseClaudeJsonEnvelope` extracts cost/turns/tokens into `runState.metrics`. Reads state.md milestone status to distinguish `success` from `incomplete`. |
|
|
427
|
+
| `learn-lint.cjs` | Learnings-store integrity linter for `pan-wizard-core/learnings/{universal,internal}/`. `cmdLearnLint(sourceRoot, {scope, strict})` (over `lintPatterns()`) runs L-001 (duplicate IDs across files), L-002 (dangling pattern cross-references), L-003 (empty `source_experiments` while body cites a known experiment), L-004 (universal-scope rule prose using PAN-internal terms), L-005 (revision marker `-rN` without `superseded_by` frontmatter on the base), L-006 (universal-scope pattern citing an internal pattern id, which dangles after install), L-007 (a pattern's `cites` no longer holds: the cited file or symbol is gone, checked with `memory.cjs`'s `citationProblem`). Wired into `/check`. |
|
|
428
|
+
| `learn-index.cjs` | Learnings index + agent-relevance queries. `buildIndex()` walks both scopes and `writeIndex()` writes `pan-wizard-core/learnings/index.json` (`learn build-index` runs both) with topic→`{patterns, size_tokens_est, agent_relevance}` per topic; the curated `RELEVANCE` table assigns `high\|medium\|low` per `(topic, agent_role)` for `planner / executor / verifier / reviewer`. `topicsForAgent(index, {agent, minRelevance, tokenBudget, cue})` returns budget-aware topic selection: with a cue (the phase goal and the files it touches) topics are ranked by how well their names, summaries and rules match it, and by role relevance only when nothing matches. Workflow files (`plan-phase.md`, `exec-phase.md`, `verify-phase.md`, `execute-plan.md`) call `learn topics-for --cue` to load only the learnings that fit the task instead of skim-the-folder. |
|
|
429
|
+
| `links.cjs` | Doc–code link graph (ADR-0027). `validateAll(cwd, opts)` runs three passes: forward links (inline `[[<id>]]` + `must_haves.key_links`) → finding codes F-001..F-004; backlink contract for docs with `require-code-mention: true` frontmatter → B-001/B-002; anchor-target existence for `// @pan: <id>` source comments → A-001/A-002/A-004. `resolveDocId` handles `ADR-NNNN` glob, relative `.md` paths, and `<doc>#section` slug match. `cmdLinksValidate` goes through `core.output()` with an explicit exit code (`1` on fail — the verdict payload has no `error` key), which also gives it the `@file:` large-output protocol the former hand-rolled bypass lacked. Reuses `doc-lint/walk.js` and `frontmatter.cjs` — zero new dependencies. Wired into `validate health --links` for advisory pre-flight. |
|
|
430
|
+
| `squads.cjs` | **(ADR-0032)** Bot-army squad registry + resolver: `SQUADS` (architecture/build/quality/release with tier + advisory access contract), `listSquads`, `getSquad`, `squadForAgent`, `validateRoster` (drift guard: every member is a real agent, every agent placed). `cmdSquadList` / `cmdSquadShow`. Registry only — modifies no agent and no execution path. |
|
|
431
|
+
| `worktree.cjs` | **(ADR-0033)** Branch-per-agent isolation for the Build squad: `createTaskWorktree` / `removeTaskWorktree` / `listArmyWorktrees` (army/`<task>`-prefixed; removal refuses non-army branches). Generalized from `whatif.cjs`. `cmdWorktreeList` / `cmdWorktreeCreate` / `cmdWorktreeRemove`. |
|
|
432
|
+
| `campaign.cjs` | **(ADR-0034)** Scheduled self-resuming campaigns: `parseCadence`, `writeSchedule`/`readSchedule`, `isRunDue` (enabled/paused/budget/next-due), `recordRun` (advance next-due + per-day spend), `isDreamDue`. Descriptor at `.planning/orchestration/schedule.json`. PAN owns the due-check; the host scheduler fires `/pan:army --continue`. Never relaxes the human merge gate. |
|
|
433
|
+
| `hud.cjs` | **(ADR-0035)** Single-page HTML army + project dashboard. `collectHudData` (pure: aggregates state.md, roadmap/phases, squad registry, campaign schedule, army worktrees, cost ledger, requirements, verification, git log), `renderHud` (self-contained HTML — no server/network/external assets), `cmdHud`. A read-only **view**: owns no state, writes only its HTML file (`.planning/hud.html`, or the `--out` path). Army-only panels degrade gracefully when no campaign/worktrees exist. Reads `squads.cjs` + `campaign.cjs` + `worktree.cjs` + `cost.cjs`. |
|
|
434
|
+
| `skill-align.cjs` | **(ADR-0038)** Skill-Aligned Decomposition pass. `buildSkillIndex(root)` walks commands/templates/references + learnings topics on the fly (nothing persisted); `alignTasks(root, tasks, opts)` scores draft planner tasks via `scoreRelevance` (glue-word stop-list, capped scoring head) and returns per-task top-k matches plus a deduped, token-budgeted `vocabulary` hint list with explicit `dropped` overflow. Advisory + fail-open: missing roots are skipped and reported. Used by `pan-planner`'s `skill_alignment` step. `cmdSkillsIndex` / `cmdSkillsAlign`. |
|
|
435
|
+
| `hygiene.cjs` | Project cleanup + version alignment. `scanHygiene` runs the checks named by its finding ids: `version-alignment` (per-runtime manifest version vs latest, untracked installs), `legacy-filenames`, `tmp-orphans`, `memory-bloat`, `memory-stale` (entries `memory select` leaves out: cited code gone, or unused past the expiry window — fix `prune-memory`), `memory-format` (an `info` finding for a memory file with no `## Entries` list, which is never loaded), `host-memory` (read-only, once per project: Claude Code's auto-memory index past its 200-line / 25 KB session-start load limit, or holding content where a pointer belongs; PAN never writes that store, MI-010), `poisoned-ledger` (via `cost.cjs isSuspectRecord`, gated on record count *or* token mass), `stale-traces`, `stale-reports`, `cache-context` (cached-context bloat, plus the prompt-cache lifetime recommendation — `info`, raised to `warn` once the re-written tokens reach `TTL_WARN_TOKENS`), `planning-fragment`, `foreign-planning-tree` (via `foreign-planning.cjs` — a tree that belongs to another tool gets that one warning and no per-tree checks), and `shared-planning-tree` (an `info` finding for a tree another tool writes into beside PAN; the per-tree checks still run). `cleanHygiene` applies only the safe subset (case-hop renames, orphan deletion, `compactMemory`, `pruneMemory` (archive-first), `state compact` and `roadmap compact` (history-first), ledger quarantine-by-rename, pruning of old trace sessions and optimization reports) — dry-run by default, `--apply` to execute; installer re-runs and fragment removal always stay manual. `cmdHygieneScan` / `cmdHygieneClean`. |
|
|
436
|
+
| `phase-report.cjs` | Per-phase graphical HTML report + project-level timeline index (`pan-tools report phase <N>` \| `index` \| `all`). Three layers mirroring hud.cjs: `collectPhaseData`/`collectIndexData` (pure `.planning/` reads), `renderPhaseHtml`/`renderIndexHtml` (pure self-contained docs), `cmdReport` and `renderAllToDisk` (the regeneration `report all` and focus-auto's checkpoint run) as the only side-effecting layer. Reuses hud.cjs's rendering foundation verbatim so both surfaces render identically. |
|
|
437
|
+
| `agents-md.cjs` | AGENTS.md universal rules layer (ADR-0028 Phase 3). Single source of truth for the marker-fenced PAN section and PAN's `CLAUDE.md` block: the `@AGENTS.md` import plus a `# Compact instructions` section that tells Claude Code's compaction summary what to keep for PAN work to resume (an older import-only block is updated in place); lives under the core so the installer AND an installed `memory rebuild` regenerate byte-identical content. User content outside the markers is never touched. |
|
|
438
|
+
| `memory-rebuild.cjs` | `memory rebuild [--apply]` (dry-run by default; refuses inside the source repo): regenerates the derived tools memory — the marker-fenced PAN section of `AGENTS.md`, the `CLAUDE.md` `@AGENTS.md` bridge on Claude installs, and `state.md`'s frontmatter from its body (a stacked-frontmatter `state.md` is reported as refused) — and warns on directive-like lines in `AGENTS.md`/`CLAUDE.md` (ADR-0040). |
|
|
439
|
+
| `memory-optimize.cjs` | Memory compaction and the quarantine path for entries carrying injected directives (ADR-0040). |
|
|
440
|
+
| `suggest.cjs` | **(2026-08)** "Did you mean" corrections for an unknown command. PURE. `buildSubcommandIndex()` parses the dispatcher's own `Unknown <group> subcommand. Available:` strings (and the `Unknown init workflow:` / `<group> subcommand required. Available:` variants) — load-bearing text a user sees, so it cannot rot quietly — and `suggestCommand()` resolves a namespace miss (`trace` → `pan-tools optimize trace`) or a near-miss typo. Runs on the ERROR PATH ONLY, so a healthy invocation pays nothing, and fails open to the plain message. |
|
|
441
|
+
| `planning-root.cjs` | **(ADR-0043)** Resolves WHICH planning tree a command acts on (`--track` / `--planning-dir` / `PAN_TRACK` / `PAN_PLANNING_DIR`, default `.planning`), discovers tracks under `.planning/tracks/`, and reports each resolution's provenance so a wrong target is visible instead of passing for a healthy project. Leaf module — Node builtins only; `utils.planningPath()` / `utils.planningRel()` are the primary path constructors built on it; commands, hygiene, init and verify also read its root helpers directly. No CLI surface. |
|
|
442
|
+
| `state-compact.cjs` | **(ADR-0044)** `state compact [--apply] [--keep-days N]`: archives settled history out of `state.md` into `state-history.md` so it stops being re-read into every agent call. Archive first, then rewrite, nothing deleted; live sections and frontmatter-source fields are protected; dry-run by default. |
|
|
443
|
+
| `roadmap-compact.cjs` | `roadmap compact [--apply] [--keep N]`: moves shipped phases' detail sections out of `roadmap.md` into `roadmap-history.md`, the way `state compact` bounds `state.md`. History first, then rewrite, nothing deleted; a stub keeps each heading, its Goal, Depends on and Requirements lines and any `model_tier` override; the current phase and the `keep` most recently shipped (default 2) stay; dry-run by default, and it declines when nothing would shrink. Readers that need a full section (`roadmap get-phase`, `roadmap slice`, phase reports, the per-phase `model_tier` lookup) find it in the history. |
|
|
444
|
+
| `foreign-planning.cjs` | **(2026-09)** `detectForeignPlanningTree(dir)` / `detectForeignPlanningTreeAt(cwd)`: does another tool write to this `.planning/`? Answered from POSITIVE markers PAN never writes (`FOREIGN_PLANNING_MARKERS` in `constants.cjs`); never throws. **gsd-core owns its tree:** markers `HANDOFF.json`, `.gsd-allow-shrink`, two or more gsd-only directories, or its flat dotted config keys. `hygiene.cjs` gives one `foreign-planning-tree` warning, runs no per-tree checks, and `applyFix` refuses the rename. `verify.cjs` reports `E006` in `validate health` and stops before `E002`–`E005`. `init new-project` refuses. **planning-with-files shares it** (`coexists: true`): markers `.active_plan`, `.attestation`, `ledger-*.jsonl`, a dated task directory holding `task_plan.md`, or two of its directories (`sessions/`, dated task directories without the plan file). Hygiene raises a `shared-planning-tree` info finding and runs PAN's own checks, health reports `I004`, and init proceeds and reports it. |
|
|
445
|
+
| `verdict.cjs` | **(evidence loop, ADR-0049)** The `pan-verdict` contract. PURE. `parseVerdictText()` reads the last fenced `pan-verdict` block of a judge's report, or a verification.md frontmatter through its own list-of-mappings reader, which the general frontmatter parser flattens to strings. `validateVerdict()` enforces the contract and records near-misses in their closest valid form, with warnings. `findingId()` and `recordSig()` give findings and artifacts stable identities. |
|
|
446
|
+
| `findings.cjs` | **(evidence loop, ADR-0049)** The findings ledger `.planning/findings.jsonl` (verdict, finding and disposition rows; append-only; folded on read). `recordVerdict()` is idempotent per artifact, numbers attempts per agent and phase, closes earlier findings only on evidence (a judge's `resolved` answer or a passing code fact, never silence), keeps a reworded finding's id, and logs `verdict_*` / `verdict_retry` trace events. Learned suppressions: a dismissed finding is filtered on re-report while its file is unchanged (scoped to its phase, or to any phase once the same judge dismissed it in two phases), and retires when the file changes; security findings (any `pan-hardener` finding, or a security term in the summary), logic findings (`defect`, `contradicts`, `missing`, `partial`) and findings with no file are never suppressed. Also `disposeFindings()` (reason required for deferred, dismissed and decision), `listFindings()` and `findingsDebt()` (milestone-audit's tech debt). Backs `findings record/list/dispose/debt/suppressions` and `pan://findings`. |
|
|
447
|
+
| `plan-lint.cjs` | **(program P2, P4)** Plan intent checked in code. `verify review-focus <phase>`: every plan has a `## Review Focus` with at most five items, each naming a task and a test, or one `None — <reason>` line. `verify decisions <phase>`: a plan citing a `DD-N` id the phase design does not record, and a recorded decision no plan cites, are flagged; a design from before ids is `legacy` (a warning). `verify gates <phase>`: a task's `<verify>` command that already passes before any work is flagged. |
|
|
448
|
+
| `research-lint.cjs` | **(program P3)** `research lint <phase\|path>`: reads a research file's `## Claims` table. A claim with no source or no valid checked date is an error; one older than its type's freshness window (versions, prices and security 30 days, APIs 90, general claims 180, practices 365) is `stale`. The plan-checker weighs the result. |
|
|
449
|
+
| `usage.cjs` | **(program L9)** `usage`: local census of installed commands and agents against the cost ledger and trace sessions (used, never used, unfinished). Reads `cost.cjs` `readRecords` and the trace sessions' `session.json`; writes nothing. |
|
|
450
|
+
| `phase-gate.cjs` | **(program V1)** `phase gate <N>`: whether a phase may be marked complete, in code. Refuses (one reason code each) on a plan without a summary, no verification, a failed one (with code facts applied), `human_needed` without a recorded approval, a stale verification, a reconcile contradiction, a failed test gate, open critical/high findings, committed stubs, or a test-integrity violation; what it could not check is listed in `not_checked`. `workflow.phase_gate` is `enforce` by default (also when unset or unrecognised): a refusal stops `phase complete` unless `--force --reason`, which records the override as a decision; `warn` reports the reasons and proceeds. `phase complete`, the native `pan-exec-waves` script and the MCP merge request all use it. |
|
|
451
|
+
| `test-gate.cjs` | **(program V2)** `test run` / `test detect`: the engine runs the project's tests in any language (`workflow.test_command`, else package.json, pytest, go, cargo, Maven, Gradle, make), parses the runner's own output into counts and failing-test ids, and writes `{NN}-test-baseline.json` before execution and `{NN}-test-run.json` after. A failure the baseline already had is pre-existing; a new one is a regression; a suite that did not run is failed, never skipped. The verifier copies its status, reconcile cross-checks it, and the verdict recorder and the phase gate take it as a code fact. |
|
|
452
|
+
| `mutate.cjs` | **(program V5)** `verify mutate --phase N`: per-language mutation operators (JS/TS, C-family, Python) applied one at a time to the lines the phase changed, in a worktree at HEAD, with a seeded sample, a flake pre-check, and survivors written to `{NN}-mutation.json`. `workflow.mutation_gate`: `report` (default), `off`, `gate` (opt-in: a score below `workflow.mutation_floor`, 0.6, fails). `scripts/mutation-probe.cjs` imports its operator table. |
|
|
453
|
+
| `verify-red.cjs` | **(program V4)** `verify red <phase>`: each test file the phase's plan commits added or changed must fail in a throwaway worktree at the phase's base (the parent of its oldest plan commit) and pass at HEAD; a test that passes at the base is `not_red` (tautological, or testing something the phase did not change). Runs one file at a time through test-gate's `fileCommand`; exports `withWorktree` for the mutation report. |
|
|
454
|
+
| `verify-integrity.cjs` | **(program V3)** `verify test-integrity <phase>`: walks the phase's plan commits and reports a deleted test, a skip or only marker added (JS, Python, Go, Rust, Java), assertions dropped, an assertion edited in a test no plan declares, a rewritten snapshot, or an assertion that cannot fail; a renamed test is a warning. Uses verify-scope's `committedFiles()`. |
|
|
455
|
+
| `verify-plan-set.cjs` | **(program V7)** `verify plan-set <phase>`: the plan checks code can make, before the plan checker runs (requirement coverage, same-wave file overlap, missing, self and future references, cycles, wave gaps). `planCheckStatus()` binds a passing plan check to the plans it checked through the `plans_sha` the recorder stores with every plan-checker verdict; `planDrift()` lists planned files changed since a plan's `planned_commit`. `init execute-phase` carries both as `plan_check` and `plan_drift`. |
|
|
456
|
+
| `verify-scope.cjs` | **(evidence loop)** `scopePhase()`: the files a phase changed (plan commits by subject, plus summary key-files) that its plans did not declare in `files_modified`. The planning tree, lockfiles and PAN's runtime directories are excluded. Backs `verify scope`. `reviewScope()` backs `review scope <phase>`: the changed files with each plan's objective, must_haves and Review Focus, the claimed requirements' text, and `unlisted` files no summary lists, for the reviewer's `<intent>` block. Also `verificationFreshness()`: whether a phase's verification still describes the code (`fresh`, `stale`, `unverified` or `unknown`, from the covered files changed since `verified_commit`), which backs `verify stale` and the per-phase `verification` state in `progress` output. Re-exported by verify.cjs; commands.cjs reads `verificationFreshness` directly. |
|
|
457
|
+
| `autodev.cjs` | **(program A1)** `autodev run/resume/status`: the deterministic outer loop — reads `.planning/`, asks `next-action` for the next unit, decides in code whether to stop, runs each unit in a fresh headless host session; ledger and state under `.planning/autodev/`. A phase `sizing.cjs` sizes lean runs its execute unit in one session through `workflows/exec-lean.md` (`LEAN_WORKFLOW`, `unitPrompt`): the session does the executor's work, then one `pan-reviewer` pass, then the verifier; the cost and trace hooks attribute that session to command `exec-lean`. |
|
|
458
|
+
| `autodev-report.cjs` | **(program A5)** `autodev replay` (re-runs the stop logic over `blackbox.jsonl`) and `autodev report` (`dossier.md`/`dossier.html` beside the ledger). |
|
|
459
|
+
| `failure-class.cjs` | **(program A4)** Classifies a failed autodev unit and routes it: retry with the error tail, fresh restart, tier escalation, quarantine, ask a human, or stop on budget. No CLI surface. |
|
|
460
|
+
| `ci.cjs` | **(program A2)** CI as autodev's oracle: `gh pr checks` (`--ci`), or the project's own `npm run ci:local`/`npm test` (`--ci local`); fix rounds and a breaker. No CLI surface of its own. |
|
|
461
|
+
| `hosts.cjs` | **(program A0)** One table of how PAN runs each host CLI: the autonomous runner argv, the model family, the read-only review argv, the headless harness argv. No CLI surface. |
|
|
462
|
+
| `next-action.cjs` | **(program L7)** `next-action`: reads roadmap.md and the phase directories into the MCP orchestrator's snapshot and maps its decision to a command. |
|
|
463
|
+
| `sizing.cjs` | Right-sized ceremony: decides lean or full per phase and quick task (`size phase/task`). A phase is lean when every requirement mapped to it is precisely specified (an acceptance criterion or a named artifact) and there are at most `LEAN_CEILING_FACTOR` (3) × `workflow.lean_max_requirements` (default 5) of them; above `lean_max_requirements` the engine splits the lean phase into plans of at most that many tasks, each in its own wave (`size phase-plan`, `planLeanPhase`). Writes a lean quick task's plan (`size quick-plan`) and checks lean plans in code (`size plan-check`). The `quality` profile, `workflow.ceremony: full`, `--quality` and `--full` keep the full path. |
|
|
464
|
+
| `cross-family.cjs` | **(program R4)** `review cross-family <phase>`: one read-only review on another host's CLI, off unless `workflow.cross_family_review` names a host. |
|
|
465
|
+
| `review-vote.cjs` | **(program R2)** `review vote`: merges k reviewer passes; a finding survives only with a quorum. |
|
|
466
|
+
| `merge.cjs` | **(program L6a)** `merge request` / `merge confirm`: the human merge gate on the CLI; confirm only in an interactive terminal. |
|
|
467
|
+
| `uat.cjs` | **(program L8)** `uat record` / `uat status`: UAT results written through the engine into `{phase}-uat.md`. |
|
|
468
|
+
| `debug-cases.cjs` | **(program P5)** `debug repro <slug>` / `debug similar "<symptom>"`: a debug session's reproduction as its closing check, and the resolved case base. |
|
|
469
|
+
| `state-write.cjs` | **(program A7b)** `state init`, `state section`, `state quick-task`, `state apply`: the writers of state.md as a whole or by section. |
|
|
470
|
+
| `requirements-lint.cjs` | **(program V8)** `verify requirements` (EARS criteria) and `verify traceability` (runs each requirement's mapped tests); `phase complete` ticks through it. |
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Layer 5: Persistent State
|
|
475
|
+
|
|
476
|
+
**Location:** `.planning/` directory
|
|
477
|
+
|
|
478
|
+
Markdown and JSON files that survive context resets. This is the single source of truth for project state.
|
|
479
|
+
|
|
480
|
+
The tree below shows the core files. Depending on which features a project has used it also carries a phase's `.continue-here.md` (from `/pan:pause`), `learnings.md`, `standards.md`, `state-history.md`, `roadmap-history.md`, `playbook.md`, `hud.html`, `report-index.html`, `report-bundle.html` and the `milestones/`, `memory/`, `bus/`, `metrics/`, `optimization/`, `orchestration/`, `counterfactuals/`, `conversations/`, `reviews/`, `bridge/`, `focus/` and `tracks/` directories.
|
|
481
|
+
|
|
482
|
+
```text
|
|
483
|
+
.planning/
|
|
484
|
+
project.md Project definition, scope, and constraints
|
|
485
|
+
requirements.md Scoped requirements with unique IDs (REQ-01, etc.)
|
|
486
|
+
roadmap.md Phase list with status, success criteria, progress
|
|
487
|
+
state.md Current execution state (frontmatter + body)
|
|
488
|
+
config.json User configuration (models, workflow toggles)
|
|
489
|
+
milestones.md Completed milestone archive
|
|
490
|
+
patterns.md Error patterns (PAT-NNN); read when present, no verb or hook writes it
|
|
491
|
+
session-history.md Session summaries (last 20 entries); read when present, no verb or hook writes it
|
|
492
|
+
research/ Opt-in research from /pan:new-project --research or /pan:milestone-new
|
|
493
|
+
questions.md At most five open questions that block building, written by the orchestrator
|
|
494
|
+
research-summary.md One answer row per question (pan-project-researcher; older projects: summary.md)
|
|
495
|
+
codebase/ Brownfield analysis from /pan:map-codebase
|
|
496
|
+
stack.md Current tech stack
|
|
497
|
+
integrations.md External services and APIs
|
|
498
|
+
architecture.md System design and patterns
|
|
499
|
+
structure.md Directory layout guide
|
|
500
|
+
conventions.md Coding patterns and style
|
|
501
|
+
testing.md Test infrastructure and patterns
|
|
502
|
+
concerns.md Tech debt and risks
|
|
503
|
+
relationships.md Module and component dependency map
|
|
504
|
+
best-practices.md Recommended patterns for this codebase
|
|
505
|
+
todos/
|
|
506
|
+
pending/ Captured ideas awaiting work
|
|
507
|
+
completed/ Completed todos (`pan-tools todo complete` moves files here)
|
|
508
|
+
debug/ Active debug sessions
|
|
509
|
+
resolved/ Archived debug sessions
|
|
510
|
+
quick/ Quick mode task plans and summaries
|
|
511
|
+
findings.jsonl Judges' verdicts, findings and dispositions (append-only; `pan-tools findings`)
|
|
512
|
+
phases/
|
|
513
|
+
XX-<slug>/
|
|
514
|
+
XX-context.md Implementation preferences from discuss-phase
|
|
515
|
+
XX-research.md Phase research: answers to at most 5 open questions (opt-in)
|
|
516
|
+
XX-roadmap-slice.md This phase's roadmap and requirements lines (`pan-tools roadmap slice <N> --write`), read by phase agents
|
|
517
|
+
XX-validation.md Test coverage mapping (Nyquist layer)
|
|
518
|
+
XX-YY-plan.md Atomic execution plans
|
|
519
|
+
XX-YY-summary.md Post-execution summaries
|
|
520
|
+
XX-verification.md Goal-backward verification results
|
|
521
|
+
XX-review.md The reviewer's report, saved by exec-phase (read by /pan:review-deep)
|
|
522
|
+
XX-plan-check.md The plan checker's report, saved by plan-phase
|
|
523
|
+
XX-design-check.md The design checker's report, saved by design-phase
|
|
524
|
+
XX-uat.md User acceptance test results
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### File Lifecycle
|
|
528
|
+
|
|
529
|
+
| File | Created By | Updated By | Read By |
|
|
530
|
+
|------|-----------|-----------|---------|
|
|
531
|
+
| `project.md` | `/pan:new-project` | `/pan:milestone-new`, `/pan:milestone-done`, the phase transition (`transition.md`) | Orchestrators, the roadmapper, the phase researcher, and executors (plans carry `@.planning/project.md`) |
|
|
532
|
+
| `requirements.md` | `/pan:new-project` | `pan-roadmapper`, `pan-executor` (mark complete) | The roadmapper and milestone work, whole; phase agents read their phase's requirement lines in the roadmap slice |
|
|
533
|
+
| `roadmap.md` | `pan-roadmapper` | `pan-executor` (progress), phase commands, `roadmap compact` (moves shipped phases' detail to `roadmap-history.md`) | The roadmapper, milestone work and orchestrators, whole; the planner, plan checker, researcher, executors and verifier read the phase's slice (`XX-roadmap-slice.md`); the designer and design checker take the phase boundary from `roadmap.md` |
|
|
534
|
+
| `state.md` | `pan-roadmapper` | `pan-executor`, pan-tools CLI | Orchestrators, agents |
|
|
535
|
+
| `config.json` | `/pan:new-project` | `/pan:settings` | Orchestrators (model resolution, workflow toggles) |
|
|
536
|
+
| `research.md` | `pan-phase-researcher` | — (immutable after creation) | `pan-planner` |
|
|
537
|
+
| `plan.md` | `pan-planner` | `pan-planner` (revision loop, on the plan checker's issues; the checker has no Write tool) | `pan-executor` |
|
|
538
|
+
| `summary.md` | `pan-executor` | — (immutable after creation) | `pan-verifier`, `pan-integration-checker` |
|
|
539
|
+
| `verification.md` | `pan-verifier` | Re-verification overwrites | `/pan:plan-phase --gaps` |
|
|
540
|
+
| `patterns.md` | `appendErrorPattern()`, which no verb, hook or workflow calls today | `appendErrorPattern()` (auto-increment PAT-NNN) | `readErrorPatterns()` (`progress health`, `learnings extract`, `focus scan`, `focus plan`), `preflight` (counts the entries), `/pan:focus-auto --step scan` |
|
|
541
|
+
| `session-history.md` | `appendSessionSummary()`, which no verb, hook or workflow calls today | `appendSessionSummary()` (keeps last 20) | `progress health` |
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## Additional Components
|
|
546
|
+
|
|
547
|
+
### References
|
|
548
|
+
|
|
549
|
+
**Location:** `pan-wizard-core/references/*.md`
|
|
550
|
+
|
|
551
|
+
Context documents loaded by agents and workflows at runtime. These provide domain knowledge that agents need but that should not be baked into their system prompts.
|
|
552
|
+
|
|
553
|
+
| Reference | Purpose |
|
|
554
|
+
|-----------|---------|
|
|
555
|
+
| `checkpoints.md` | Checkpoint types and protocols for human interaction points |
|
|
556
|
+
| `continuation-format.md` | Standard format for presenting next steps after commands |
|
|
557
|
+
| `decimal-phase-calculation.md` | Algorithm for calculating next decimal phase number |
|
|
558
|
+
| `design-methodology.md` | Design methodology for the design phase (architecture, ADR, threat-lite) |
|
|
559
|
+
| `git-integration.md` | Commit points, commit message formats, why per-task commits |
|
|
560
|
+
| `git-planning-commit.md` | How to commit `.planning/` artifacts (respects `commit_docs` config) |
|
|
561
|
+
| `guardrails.md` | Behavioral guardrails — anti-patterns, Code Preservation Principle, Stop-the-Line Rule |
|
|
562
|
+
| `handoff-decisions.md` | Planner → executor decision-trace handoff (locked / open / rejected decisions) |
|
|
563
|
+
| `model-profile-resolution.md` | How to resolve model profiles once at orchestration start |
|
|
564
|
+
| `model-profiles.md` | Model profile table (quality/balanced/budget per agent) |
|
|
565
|
+
| `phase-argument-parsing.md` | Normalize phase arguments across commands |
|
|
566
|
+
| `planning-config.md` | Configuration options for `.planning/` directory behavior |
|
|
567
|
+
| `questioning.md` | Project initialization philosophy: dream extraction, not requirements gathering |
|
|
568
|
+
| `tdd.md` | TDD patterns and red-green-refactor discipline |
|
|
569
|
+
| `ui-brand.md` | Visual patterns for user-facing output (stage banners, formatting) |
|
|
570
|
+
| `verdict-contract.md` | The `pan-verdict` block the plan checker, reviewer and design checker end their reports with (fields, classes, severities, per-judge mapping) |
|
|
571
|
+
| `verification-patterns.md` | How to verify artifacts are real implementations, not stubs |
|
|
572
|
+
|
|
573
|
+
### Templates
|
|
574
|
+
|
|
575
|
+
**Location:** `pan-wizard-core/templates/`
|
|
576
|
+
|
|
577
|
+
Scaffold templates for all planning files. Agents, workflows and commands read them by path when they write planning files; `template select` returns the summary template's path, while `template fill` and `scaffold` write skeletons of their own. Templates cover: project.md, roadmap.md, state.md, summaries (minimal/standard/complex), research outputs, codebase mapping, plans, verification, UAT, debug, discovery, milestones, retrospectives, and more.
|
|
578
|
+
|
|
579
|
+
### Hooks
|
|
580
|
+
|
|
581
|
+
**Location:** `hooks/` (source), `hooks/dist/` (copied build output)
|
|
582
|
+
|
|
583
|
+
The shipped hooks (copied to `hooks/dist/` by `npm run build:hooks` — pure Node.js, zero deps, no bundling):
|
|
584
|
+
|
|
585
|
+
| Hook | Event Type | Function |
|
|
586
|
+
|------|-----------|----------|
|
|
587
|
+
| `pan-statusline.js` | statusLine | Renders the status line (model, task, directory, context bar) and writes the context metrics, with token counts and the model id, to the bridge file the context monitor reads |
|
|
588
|
+
| `pan-context-monitor.js` | PostToolUse | Reads the bridge file, or the session transcript when no fresh bridge exists (headless `claude -p`, a status line that is not PAN's; a subagent's call reads the subagent's own transcript), and injects a note when the room left before the host compacts is ≤35% (WARNING) or ≤25% (CRITICAL) |
|
|
589
|
+
| `pan-check-update.js` | SessionStart | Background check for PAN updates with caching |
|
|
590
|
+
| `pan-cost-logger.js` | SubagentStop | Appends subagent cost record to `.planning/metrics/tokens.jsonl` (consumed by `/pan:cost`) |
|
|
591
|
+
| `pan-trace-logger.js` | SubagentStop | Appends decision/redundancy events, plus redacted `error`/`tool_error` events for the failed tool calls in a subagent's own transcript (Claude Code), to `.planning/optimization/traces/<session>/trace.jsonl` (consumed by `/pan:learn`, `/pan:learn --optimize`); auto-creates day-scoped trace session |
|
|
592
|
+
| `pan-guard.js` | PreToolUse (Gemini CLI: BeforeTool; Copilot CLI: preToolUse) | Reports, or under `hooks.guard: enforce` denies, a credential written into a file, a direct write to PAN's state and a judge writing outside the planning tree; reports undeclared test edits (program A7, A7b) |
|
|
593
|
+
| `pan-stop-guard.js` | Stop (Copilot CLI: agentStop; Gemini CLI: AfterAgent) | Blocks a session stop once when the auto-advance chain dropped at a phase boundary (autonomy armed in config, no failure/gaps/blocker in state, roadmap phases unbuilt) and instructs the agent to continue the chain; fail-open, one-shot, escape hatch `workflow.stop_guard: false` — see `docs/HOOKS.md` |
|
|
594
|
+
| `pan-state-reinject.js` | SessionStart, matcher `compact` (Gemini CLI: PreCompress, then AfterTool; Copilot CLI: preCompact, then postToolUse) | After a context compaction, injects the phase, plan, status and stop point from `state.md` as `additionalContext`; on Gemini and Copilot in two steps, a marker before the compaction and the block on the next tool result; silent without work in flight, never writes into the project (the marker sits in the per-user temp directory) — see `docs/HOOKS.md` |
|
|
595
|
+
|
|
596
|
+
The statusline hook produces metrics; the context monitor consumes them. They communicate through a bridge file (`<os-tmpdir>/pan-hooks-{uid}/claude-ctx-{session_id}.json`, a per-user 0700 dir) to avoid coupling. Where no fresh bridge exists (a headless `claude -p` run renders no status line), the monitor reads the session transcript the hook payload names instead. The two SubagentStop hooks (cost-logger and trace-logger) fire in parallel after every sub-agent completion (recording nothing for Claude Code's own helper agents, which carry no agent type and no transcript) and write to independent log files.
|
|
597
|
+
|
|
598
|
+
**Runtime support:** Claude Code and Gemini CLI register hooks in `settings.json`, each in its own event vocabulary — Gemini's names differ (`AfterAgent` for the stop guard), and Gemini runs the update check, the guard (`BeforeTool`), the stop guard, and the state re-injection in two steps (`PreCompress` leaves a marker, the next `AfterTool` injects the position, because no Gemini post-compaction event adds context). No Gemini hook sees context usage or a subagent's completion, so the context monitor and the loggers do not run there. The context monitor is registered on Claude Code only: its numbers come from Claude Code's status-line bridge or a Claude-shaped transcript, so Codex and Copilot CLI get no `PostToolUse`/`postToolUse` entry for it. Copilot CLI registers hooks in `.github/hooks/pan.json` (its `version: 1` schema with `type: "command"` entries and `sessionStart`/`preToolUse`/`postToolUse`/`preCompact`/`subagentStop`/`agentStop` events, with the state re-injection in the same two steps as on Gemini, `preCompact` then `postToolUse`; since June 2026 — not `config.json`; Copilot also runs the hooks in `.claude/settings.json`, so where both are installed the `.github/hooks` copies defer to the Claude registration and each hook runs once). Codex registers hooks in `.codex/hooks.json` (Claude-compatible PascalCase events, PAN entries merged non-destructively alongside any user hooks; loads once the project is trusted). The Copilot statusline registers in the documented settings read paths — `~/.copilot/settings.json` (global) or `.github/copilot/settings.json` (repo-level) — and is experimental on Copilot's side (`copilot --experimental`). OpenCode runs no command hooks; PAN installs one plugin there, `.opencode/plugins/pan-wizard.js`, whose `experimental.session.compacting` hook adds PAN's position to the compaction prompt (see `docs/HOOKS.md`).
|
|
599
|
+
|
|
600
|
+
### Installer
|
|
601
|
+
|
|
602
|
+
**Location:** `bin/install.js`
|
|
603
|
+
|
|
604
|
+
Interactive CLI that copies commands, agents, hooks, and core library to the correct locations for each of the 5 supported runtimes. Handles format conversion at install time — no runtime conversion needed.
|
|
605
|
+
|
|
606
|
+
| Runtime | Target Directory (Global) | Target Directory (Local) | Format |
|
|
607
|
+
|---------|--------------------------|-------------------------|--------|
|
|
608
|
+
| Claude Code | `~/.claude/` | `.claude/` | `commands/pan/*.md`, `agents/*.md` |
|
|
609
|
+
| OpenCode | `~/.config/opencode/` | `.opencode/` | `commands/*.md`, `agents/*.md` |
|
|
610
|
+
| Gemini CLI | `~/.gemini/` | `.gemini/` | `commands/pan/*.toml`, `agents/*.md` |
|
|
611
|
+
| Codex | `~/.codex/` | `.codex/` | `.agents/skills/pan-*/SKILL.md` (shared tree, outside config dir), `agents/*.toml` |
|
|
612
|
+
| Copilot CLI | `~/.copilot/` | `.github/` | `skills/pan-*/SKILL.md`, `agents/*.agent.md` |
|
|
613
|
+
|
|
614
|
+
**Install-time conversions:**
|
|
615
|
+
- **Codex:** Commands converted to `SKILL.md` format with skill adapter headers; hooks registered in `.codex/hooks.json` (Codex has supported hooks since 2026-06)
|
|
616
|
+
- **Copilot CLI:** Commands converted to `SKILL.md` with YAML frontmatter; agents converted to `.agent.md` with tools list; hooks registered in `.github/hooks/pan.json` (`version: 1` schema, `type: "command"` entries); tool names mapped (Claude → Copilot CLI: `Read→read`, `Bash→bash`, `Grep→search`, `WebSearch→web`, `Task→agent`, etc.)
|
|
617
|
+
- **OpenCode:** Slash command prefix converted from `/pan:` to `/pan-`
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
## Data Flow
|
|
622
|
+
|
|
623
|
+
### Example: `/pan:plan-phase 1`
|
|
624
|
+
|
|
625
|
+
A complete trace from user input to approved plans:
|
|
626
|
+
|
|
627
|
+
```text
|
|
628
|
+
User Command Workflow
|
|
629
|
+
| | |
|
|
630
|
+
| /pan:plan-phase 1 | |
|
|
631
|
+
|-------------------->| |
|
|
632
|
+
| | read plan-phase.md |
|
|
633
|
+
| |---------------------->|
|
|
634
|
+
| | |
|
|
635
|
+
| | pan-tools.cjs | Core Library
|
|
636
|
+
| | init plan-phase | |
|
|
637
|
+
| | "1" | |
|
|
638
|
+
| | +--------------------------->|
|
|
639
|
+
| | | JSON: paths, config, | |
|
|
640
|
+
| | | model assignments | |
|
|
641
|
+
| | |<---------------------------|
|
|
642
|
+
| | |
|
|
643
|
+
| | spawn (opt-in) | Agents
|
|
644
|
+
| | pan-phase-researcher | |
|
|
645
|
+
| | +--------------------------->|
|
|
646
|
+
| | | write research.md | |
|
|
647
|
+
| | |<---------------------------|
|
|
648
|
+
| | |
|
|
649
|
+
| | spawn pan-planner | |
|
|
650
|
+
| | with state.md + | |
|
|
651
|
+
| | roadmap slice + | |
|
|
652
|
+
| | context.md + | |
|
|
653
|
+
| | research.md | |
|
|
654
|
+
| | +--------------------------->|
|
|
655
|
+
| | | create plan.md | |
|
|
656
|
+
| | |<---------------------------|
|
|
657
|
+
| | |
|
|
658
|
+
| | spawn | |
|
|
659
|
+
| | pan-plan-checker | |
|
|
660
|
+
| | +--------------------------->|
|
|
661
|
+
| | | pass / fail | |
|
|
662
|
+
| | |<---------------------------|
|
|
663
|
+
| | |
|
|
664
|
+
| | if fail: loop back |
|
|
665
|
+
| | to planner (1 or 2x) |
|
|
666
|
+
| | |
|
|
667
|
+
| Plans approved | |
|
|
668
|
+
|<--------------------| |
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
**Step by step:**
|
|
672
|
+
|
|
673
|
+
1. User types `/pan:plan-phase 1`
|
|
674
|
+
2. Claude reads `commands/pan/plan-phase.md`
|
|
675
|
+
3. Command references workflow: `pan-wizard-core/workflows/plan-phase.md`
|
|
676
|
+
4. Workflow calls `pan-tools.cjs init plan-phase "1"` to bootstrap context
|
|
677
|
+
5. pan-tools returns JSON with all file paths, config, and model assignments
|
|
678
|
+
6. Only when research was asked for (`--research`, or `workflow.research: true`, off by default): the workflow writes the phase's open questions and spawns one `pan-phase-researcher` to answer them
|
|
679
|
+
7. Researcher writes research.md (`pan-tools research check` verifies it); if Nyquist is enabled the workflow then writes validation.md from the template using the researcher's Validation Architecture section
|
|
680
|
+
8. On a lean phase (`pan-tools size phase` — every requirement precisely specified) the engine writes and checks the plans itself (`size phase-plan`, `size plan-check`) and steps 8–11 run only if it declines. Otherwise the workflow spawns `pan-planner` with state.md + the phase's roadmap slice (`XX-roadmap-slice.md`, from `pan-tools roadmap slice <N> --write`) + context.md + research.md
|
|
681
|
+
9. Planner creates plan.md files (typically 2-3 per phase)
|
|
682
|
+
10. Workflow spawns `pan-plan-checker` to validate plans across multiple dimensions
|
|
683
|
+
11. If checker finds blockers, loop back to planner with feedback (`MAX_CHECKS` in `plan-phase.md`: 2 checks, one revision, on the sized ceremony; 3 checks, two revisions, under the `quality` profile, `workflow.ceremony: full` or `--quality`)
|
|
684
|
+
12. Plans approved — phase is ready for `/pan:exec-phase`
|
|
685
|
+
|
|
686
|
+
### Example: `/pan:exec-phase 1`
|
|
687
|
+
|
|
688
|
+
```text
|
|
689
|
+
User Workflow Agents
|
|
690
|
+
| | |
|
|
691
|
+
| /pan:exec-phase 1 | |
|
|
692
|
+
|-------------------->| |
|
|
693
|
+
| | init execute-phase "1" |
|
|
694
|
+
| | → JSON: plans |
|
|
695
|
+
| | phase-plan-index "1" |
|
|
696
|
+
| | → JSON: waves |
|
|
697
|
+
| | test run --baseline |
|
|
698
|
+
| | |
|
|
699
|
+
| | Wave 1 (parallel): |
|
|
700
|
+
| | pan-executor Plan-01 ----------->| commit
|
|
701
|
+
| | pan-executor Plan-02 ----------->| commit
|
|
702
|
+
| | |
|
|
703
|
+
| | Wave 2 (sequential): |
|
|
704
|
+
| | pan-executor Plan-03 ----------->| commit
|
|
705
|
+
| | |
|
|
706
|
+
| | Post-execution: |
|
|
707
|
+
| | pan-reviewer ---------------------->|
|
|
708
|
+
| | → XX-review.md | |
|
|
709
|
+
| | pan-verifier ---------------------->|
|
|
710
|
+
| | → verification.md | |
|
|
711
|
+
| | phase complete "1" |
|
|
712
|
+
| | → phase gate (enforce) |
|
|
713
|
+
| | |
|
|
714
|
+
| Phase complete | |
|
|
715
|
+
|<--------------------| |
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
720
|
+
## Module Dependency Graph
|
|
721
|
+
|
|
722
|
+
```text
|
|
723
|
+
pan-tools.cjs (CLI entry point — routes to all modules)
|
|
724
|
+
│
|
|
725
|
+
│ LAYER 1: Foundation (no internal deps)
|
|
726
|
+
├── constants.cjs
|
|
727
|
+
├── planning-root.cjs (ADR-0043 — which .planning tree a command acts on)
|
|
728
|
+
├── lock.cjs (ADR-0030 — advisory file locking, used by state.cjs)
|
|
729
|
+
│
|
|
730
|
+
│ LAYER 2: Core (depends on constants, utils + Node.js builtins; roadmap-compact lazily)
|
|
731
|
+
├── core.cjs
|
|
732
|
+
│ ├── constants.cjs
|
|
733
|
+
│ ├── utils.cjs (planningPath / planningRel)
|
|
734
|
+
│ └── roadmap-compact.cjs (lazy, inside a function — a compacted phase's section)
|
|
735
|
+
│
|
|
736
|
+
│ LAYER 3: Utilities
|
|
737
|
+
├── utils.cjs
|
|
738
|
+
│ ├── constants.cjs
|
|
739
|
+
│ ├── planning-root.cjs
|
|
740
|
+
│ └── core.cjs (lazy, inside a function — comparePhaseNum)
|
|
741
|
+
│
|
|
742
|
+
│ LAYER 4: Functional modules
|
|
743
|
+
├── frontmatter.cjs
|
|
744
|
+
│ ├── core.cjs
|
|
745
|
+
│ └── constants.cjs
|
|
746
|
+
│
|
|
747
|
+
├── config.cjs
|
|
748
|
+
│ ├── core.cjs
|
|
749
|
+
│ ├── constants.cjs
|
|
750
|
+
│ └── utils.cjs
|
|
751
|
+
│
|
|
752
|
+
├── context-budget.cjs
|
|
753
|
+
│ ├── core.cjs
|
|
754
|
+
│ ├── utils.cjs
|
|
755
|
+
│ ├── constants.cjs
|
|
756
|
+
│ └── cost.cjs (lazy)
|
|
757
|
+
│
|
|
758
|
+
├── roadmap.cjs
|
|
759
|
+
│ ├── core.cjs
|
|
760
|
+
│ ├── constants.cjs
|
|
761
|
+
│ ├── utils.cjs
|
|
762
|
+
│ └── roadmap-compact.cjs (lazy)
|
|
763
|
+
│
|
|
764
|
+
├── state.cjs
|
|
765
|
+
│ ├── core.cjs
|
|
766
|
+
│ ├── frontmatter.cjs
|
|
767
|
+
│ ├── constants.cjs
|
|
768
|
+
│ ├── utils.cjs
|
|
769
|
+
│ ├── lock.cjs
|
|
770
|
+
│ └── memory-optimize.cjs (lazy)
|
|
771
|
+
│
|
|
772
|
+
├── template.cjs
|
|
773
|
+
│ ├── core.cjs
|
|
774
|
+
│ ├── constants.cjs
|
|
775
|
+
│ ├── utils.cjs
|
|
776
|
+
│ └── frontmatter.cjs
|
|
777
|
+
│
|
|
778
|
+
├── verify.cjs (facade)
|
|
779
|
+
│ ├── core.cjs
|
|
780
|
+
│ ├── frontmatter.cjs
|
|
781
|
+
│ ├── state.cjs
|
|
782
|
+
│ ├── constants.cjs
|
|
783
|
+
│ ├── utils.cjs
|
|
784
|
+
│ ├── planning-root.cjs, foreign-planning.cjs
|
|
785
|
+
│ ├── config.cjs (also lazily, for the defaults), links.cjs (lazy)
|
|
786
|
+
│ ├── roadmap.cjs (roadmapRequirementIds — the --repair requirements sync)
|
|
787
|
+
│ ├── test-gate.cjs (lazy — the recorded test run for reconcile, a full run for `validate health --full`)
|
|
788
|
+
│ └── verify-{drift,retro,deploy,preflight,scope}.cjs (re-exported)
|
|
789
|
+
│
|
|
790
|
+
├── phase.cjs (facade)
|
|
791
|
+
│ ├── core.cjs
|
|
792
|
+
│ ├── frontmatter.cjs
|
|
793
|
+
│ ├── state.cjs
|
|
794
|
+
│ ├── constants.cjs
|
|
795
|
+
│ ├── utils.cjs
|
|
796
|
+
│ ├── roadmap.cjs
|
|
797
|
+
│ ├── phase-gate.cjs (lazy — `phase complete` runs the gate first)
|
|
798
|
+
│ └── phase-remove.cjs (re-exported)
|
|
799
|
+
│
|
|
800
|
+
├── milestone.cjs
|
|
801
|
+
│ ├── core.cjs
|
|
802
|
+
│ ├── frontmatter.cjs
|
|
803
|
+
│ ├── state.cjs
|
|
804
|
+
│ ├── constants.cjs
|
|
805
|
+
│ └── utils.cjs
|
|
806
|
+
│
|
|
807
|
+
│ LAYER 5: Aggregator modules (depend on multiple Layer 4 modules)
|
|
808
|
+
├── commands.cjs
|
|
809
|
+
│ ├── core.cjs
|
|
810
|
+
│ ├── frontmatter.cjs
|
|
811
|
+
│ ├── constants.cjs
|
|
812
|
+
│ ├── utils.cjs
|
|
813
|
+
│ ├── context-budget.cjs
|
|
814
|
+
│ ├── planning-root.cjs
|
|
815
|
+
│ ├── verify-scope.cjs (verificationFreshness)
|
|
816
|
+
│ ├── hygiene.cjs (lazy — compareVersions)
|
|
817
|
+
│ ├── cost.cjs (lazy — the ledger path the commit guard exempts)
|
|
818
|
+
│ └── commands-learnings.cjs (re-exported)
|
|
819
|
+
│
|
|
820
|
+
├── focus.cjs
|
|
821
|
+
│ ├── core.cjs
|
|
822
|
+
│ ├── constants.cjs
|
|
823
|
+
│ ├── frontmatter.cjs
|
|
824
|
+
│ ├── roadmap.cjs
|
|
825
|
+
│ ├── commands.cjs
|
|
826
|
+
│ ├── utils.cjs
|
|
827
|
+
│ ├── cost.cjs (weeklyLimitStop; also lazily)
|
|
828
|
+
│ ├── memory-optimize.cjs (lazy)
|
|
829
|
+
│ └── phase-report.cjs (lazy)
|
|
830
|
+
│
|
|
831
|
+
├── init.cjs
|
|
832
|
+
│ ├── core.cjs
|
|
833
|
+
│ ├── constants.cjs
|
|
834
|
+
│ ├── utils.cjs
|
|
835
|
+
│ ├── frontmatter.cjs
|
|
836
|
+
│ ├── phase.cjs
|
|
837
|
+
│ ├── verify-plan-set.cjs (plan_check / plan_drift)
|
|
838
|
+
│ ├── codebase.cjs
|
|
839
|
+
│ ├── planning-root.cjs
|
|
840
|
+
│ └── foreign-planning.cjs
|
|
841
|
+
│
|
|
842
|
+
│ Evidence loop (ADR-0049)
|
|
843
|
+
├── verdict.cjs (pure; depends on: crypto only)
|
|
844
|
+
├── findings.cjs (depends on: core, utils, verdict; optimize, test-gate and verify-plan-set lazily)
|
|
845
|
+
│
|
|
846
|
+
│ LAYER 6: Spec B v2 modules, with the older codebase.cjs and memory.cjs
|
|
847
|
+
├── bus.cjs (depends on: core, utils)
|
|
848
|
+
├── cost.cjs (depends on: core, utils — shared infrastructure: read by commands, context-budget, cost-rebuild, focus, hud, hygiene, memory, optimize, phase-report, preview, usage)
|
|
849
|
+
├── preview.cjs (depends on: utils, frontmatter, verify; core, constants, cost and roadmap lazily — the last two for the cost forecast and phase dependencies)
|
|
850
|
+
├── review-deep.cjs (depends on: core, utils, bus, verdict — a report's pan-verdict block)
|
|
851
|
+
├── knowledge.cjs (depends on: core, utils, memory)
|
|
852
|
+
├── whatif.cjs (depends on: core, utils)
|
|
853
|
+
├── codebase.cjs (depends on: core, constants, utils — read by init)
|
|
854
|
+
├── memory.cjs (depends on: core, constants, utils; cost, memory-optimize, findings and optimize lazily — read by knowledge, verify-retro, hygiene, memory-optimize, optimize, learn-lint)
|
|
855
|
+
│
|
|
856
|
+
│ LAYER 7: optimization, git, distill
|
|
857
|
+
├── optimize.cjs (depends on: core, utils; cost and memory lazily — recordLesson, citationProblem)
|
|
858
|
+
├── git.cjs (depends on: core, commands — for runCommitSafetyChecks reuse)
|
|
859
|
+
├── distill.cjs (depends on: core, utils)
|
|
860
|
+
│
|
|
861
|
+
│ LAYER 8: bot army (ADR-0032/0033/0034/0035) — lock.cjs (ADR-0030, concurrency) is drawn in Layer 1
|
|
862
|
+
├── squads.cjs (depends on: core — registry, no agent/exec coupling)
|
|
863
|
+
├── worktree.cjs (depends on: core — git worktree lifecycle)
|
|
864
|
+
├── campaign.cjs (depends on: core, constants, utils — schedule descriptor)
|
|
865
|
+
├── hud.cjs (depends on: core, constants, utils, squads, campaign, worktree, cost — read-only aggregating view)
|
|
866
|
+
│
|
|
867
|
+
│ LAYER 9: skill alignment, hygiene
|
|
868
|
+
├── skill-align.cjs (depends on: core, constants, knowledge — scoreRelevance reuse, learn-index — topics)
|
|
869
|
+
├── hygiene.cjs (depends on: core, constants, utils, memory — compaction, cost — suspect-record quarantine, context-budget, planning-root, state-compact and roadmap-compact (lazy), foreign-planning)
|
|
870
|
+
│
|
|
871
|
+
│ LAYER 10: the cached-context bound (ADR-0044) and foreign-tree detection (2026-09) — planning-root.cjs (ADR-0043) sits in Layer 1
|
|
872
|
+
├── state-compact.cjs (depends on: core, constants, utils; state lazily — writeStateMd; read lazily by hygiene)
|
|
873
|
+
├── foreign-planning.cjs (depends on: constants — FOREIGN_PLANNING_MARKERS, utils — planningPath; consumed by hygiene, verify, init)
|
|
874
|
+
├── roadmap-compact.cjs (depends on: core, constants, utils; read lazily by core, roadmap and phase-report for a compacted phase's section, and by hygiene to offer and run the compaction)
|
|
875
|
+
│
|
|
876
|
+
│ Modules the layers above do not draw
|
|
877
|
+
├── memory-optimize.cjs (depends on: core, utils, state, memory; read by memory-rebuild, and lazily by state, memory and focus)
|
|
878
|
+
├── memory-rebuild.cjs (depends on: core, utils, state, agents-md, memory-optimize)
|
|
879
|
+
├── agents-md.cjs (no internal deps; read by memory-rebuild and bin/install-lib.cjs)
|
|
880
|
+
├── phase-report.cjs (depends on: core, constants, utils, frontmatter, verify, hud, cost; roadmap-compact lazily; read lazily by focus)
|
|
881
|
+
├── cost-rebuild.cjs (depends on: core, utils, cost)
|
|
882
|
+
├── links.cjs (depends on: core, frontmatter, doc-lint/walk.js; read lazily by verify)
|
|
883
|
+
├── doc-lint.cjs (depends on: core, doc-lint/*.js)
|
|
884
|
+
├── learn-lint.cjs (memory lazily, for citationProblem; read by learn-index)
|
|
885
|
+
├── learn-index.cjs (depends on: learn-lint; read by skill-align)
|
|
886
|
+
├── experiment.cjs (no internal deps; read by runner)
|
|
887
|
+
├── runner.cjs (depends on: experiment)
|
|
888
|
+
├── suggest.cjs (no internal deps; the dispatcher's error path)
|
|
889
|
+
├── phase-gate.cjs (depends on: core, constants, utils; verdict, findings, verify, verify-scope, verify-integrity, test-gate and optimize lazily; read by phase)
|
|
890
|
+
├── test-gate.cjs (depends on: core, utils; read by findings, verify, verify-red, mutate, phase-gate)
|
|
891
|
+
├── verify-integrity.cjs (depends on: core, constants, frontmatter, verify-scope; read by verify-red, mutate, phase-gate)
|
|
892
|
+
├── verify-red.cjs (depends on: core, test-gate, verify-integrity, verify-scope; read by mutate)
|
|
893
|
+
├── mutate.cjs (depends on: core; test-gate, verify-integrity and verify-red lazily)
|
|
894
|
+
├── verify-plan-set.cjs (depends on: core, constants, utils, frontmatter, roadmap, phase; findings and verdict lazily; read by init, plan-lint, findings)
|
|
895
|
+
├── plan-lint.cjs (depends on: core, constants, verify-plan-set, verify-scope)
|
|
896
|
+
├── research-lint.cjs (depends on: core, verify-scope)
|
|
897
|
+
├── usage.cjs (depends on: core, cost, utils)
|
|
898
|
+
└── re-exported submodules: verify-drift (core, constants, utils), verify-retro (core, frontmatter, constants, utils; memory lazily), verify-deploy (core), verify-preflight (core, state, constants, utils; focus lazily), verify-scope (core, frontmatter, constants, utils; roadmap lazily; also read by commands, verify-integrity, verify-red, phase-gate, plan-lint, research-lint), phase-remove (core, state, constants, utils), commands-learnings (core, frontmatter, constants, utils)
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
**Key observations:**
|
|
902
|
+
- `constants.cjs` is the foundation for the planning-file modules (core, utils, config, state, phase, verify, focus, init …); many leaf modules reach it only through core/utils, and `planning-root.cjs` and `lock.cjs` require nothing internal
|
|
903
|
+
- `core.cjs` depends on `constants.cjs` and `utils.cjs` (plus Node.js builtins, and `roadmap-compact.cjs` lazily, to read a compacted phase's section back from the history) and provides the `output()`/`error()` I/O contract — including the point where nearly every exit code is decided (doc-lint's `--raw` branches, `state load --raw` and `--help` exit directly): `error()` is stderr + exit 1, while `output()` derives its code from the payload (a truthy top-level key in the **error family** — `error` or `*_error` — exits non-zero) unless a command passes one explicitly or opts out with `EXIT_OK`. Sites that report a failure as `<verb>: false` carry an error-family key so this one derivation covers them too, including payloads built by pure functions elsewhere and passed straight through by the dispatcher. See CLI-REFERENCE "Error Shape".
|
|
904
|
+
- `frontmatter.cjs` is widely depended upon (state, verify, phase, milestone, commands, template all use it)
|
|
905
|
+
- Of the modules in Layers 6 and 7 only `preview`, `review-deep`, `whatif`, `git` and `distill` are leaves: `cost.cjs` and `memory.cjs` are shared infrastructure with many consumers, `bus.cjs` feeds review-deep, `codebase.cjs` feeds init, `knowledge.cjs` feeds skill-align and `optimize.cjs` feeds findings and memory (lazily, for trace events) — remove those with care
|
|
906
|
+
- `git.cjs` reuses `runCommitSafetyChecks` from `commands.cjs`; `optimize.cjs` reads `cost.cjs`; `optimize.cjs` and `distill.cjs` also use `utils.cjs` (`git.cjs` does not)
|
|
907
|
+
- Cycles exist — `core ⇄ utils`, `core ⇄ roadmap-compact` (with `utils` on the same loop), `state ⇄ memory-optimize`, `memory ⇄ memory-optimize`, `memory ⇄ optimize` (with `findings` on the same loop), `state-compact → state → … → commands → hygiene → state-compact`, `findings ⇄ verify-plan-set` (with `phase → phase-gate → findings` on the same loop) and `verify → verify-preflight → focus → phase-report → verify` — all but the first two meet in one larger knot, and each is broken by a lazy in-function `require`: the load-time (top-level) require graph is a DAG
|
|
908
|
+
- `pan-tools.cjs` requires every module with a CLI surface (the foundation and the re-exported submodules load transitively) but is itself a script (no `module.exports`)
|
|
909
|
+
|
|
910
|
+
---
|
|
911
|
+
|
|
912
|
+
## Cross-Platform Runtime Support
|
|
913
|
+
|
|
914
|
+
PAN installs to 5 runtimes with format conversion at install time. The core workflow is identical across all — only the file format and invocation syntax differ.
|
|
915
|
+
|
|
916
|
+
### Command Syntax by Runtime
|
|
917
|
+
|
|
918
|
+
| Runtime | Prefix | Example |
|
|
919
|
+
|---------|--------|---------|
|
|
920
|
+
| Claude Code | `/pan:` | `/pan:new-project` |
|
|
921
|
+
| OpenCode | `/pan-` | `/pan-new-project` |
|
|
922
|
+
| Gemini CLI | `/pan:` | `/pan:new-project` |
|
|
923
|
+
| Codex | `$pan-` | `$pan-new-project` |
|
|
924
|
+
| Copilot CLI | `/pan-` | `/pan-new-project` |
|
|
925
|
+
|
|
926
|
+
### File Format by Runtime
|
|
927
|
+
|
|
928
|
+
| Component | Claude / OpenCode / Gemini | Codex | Copilot CLI |
|
|
929
|
+
|-----------|---------------------------|-------|-------------|
|
|
930
|
+
| Commands | `commands/pan/*.md` (Claude) · `commands/pan-*.md` (OpenCode) · `commands/pan/*.toml` (Gemini) | `.agents/skills/pan-*/SKILL.md` | `skills/pan-*/SKILL.md` |
|
|
931
|
+
| Agents | `agents/*.md` | `agents/*.toml` | `agents/*.agent.md` |
|
|
932
|
+
| Hooks | `hooks/*.js` in `settings.json` (Claude, Gemini) · OpenCode: no command hooks, the plugin `plugins/pan-wizard.js` | `hooks/*.js` in `.codex/hooks.json` (since 2026-06) | `hooks/*.js` in `.github/hooks/pan.json` |
|
|
933
|
+
| Config | `settings.json` (Claude, Gemini) · `.mcp.json` at the repo root (Claude's MCP registration) · `opencode.json` (OpenCode) | `config.toml` (PAN writes nothing there; the installer prints an MCP snippet to add by hand) | `.github/copilot/settings.json` (statusline) · `.github/mcp.json` (MCP) · `.github/hooks/pan.json` (hooks) |
|
|
934
|
+
|
|
935
|
+
### Tool Name Mapping (Copilot CLI)
|
|
936
|
+
|
|
937
|
+
Copilot CLI uses different tool names than Claude Code. The installer maps them at install time:
|
|
938
|
+
|
|
939
|
+
| Claude Code | Copilot CLI |
|
|
940
|
+
|------------|-------------|
|
|
941
|
+
| Read | read |
|
|
942
|
+
| Write, Edit | edit |
|
|
943
|
+
| Bash | bash |
|
|
944
|
+
| Glob | glob |
|
|
945
|
+
| Grep | search |
|
|
946
|
+
| WebSearch, WebFetch | web |
|
|
947
|
+
| TodoWrite | todo |
|
|
948
|
+
| Task (Agent) | agent |
|
|
949
|
+
|
|
950
|
+
### The MCP bridge — a second doorway into the same engine
|
|
951
|
+
|
|
952
|
+
The five runtimes above are reached by install-time **format conversion**: the same
|
|
953
|
+
command/agent content, rewritten per runtime. The MCP bridge is the **inverse** approach —
|
|
954
|
+
rather than converting content *into* a host, it exposes PAN's engine *to* any MCP client.
|
|
955
|
+
|
|
956
|
+
It works because `pan-tools` was already stateless: every invocation reads `.planning/`,
|
|
957
|
+
writes `.planning/`, and exits. That is the shape the MCP `2026-07-28` stateless core wants,
|
|
958
|
+
so the bridge reimplements nothing — it spawns a verb and returns its JSON. As the server's
|
|
959
|
+
own header puts it, the CLI's JSON contract **is** the tool contract.
|
|
960
|
+
|
|
961
|
+
- **Location:** `pan-wizard-core/mcp/` — under the core, so it ships with the engine to every
|
|
962
|
+
install and every runtime. Zero-dependency (the protocol is hand-rolled, not an SDK) and
|
|
963
|
+
**dual-era**: it answers both the legacy `initialize` handshake and modern per-request
|
|
964
|
+
`_meta` version negotiation with a `server/discover` probe (ADR-0041).
|
|
965
|
+
- **Two surfaces, one rule.** Read-only aggregators are MCP **resources** (cheaper,
|
|
966
|
+
side-effect-free); anything actionable is a **tool** with accurate `readOnlyHint` /
|
|
967
|
+
`destructiveHint`. The dividing rule: *a resource must be readable on any project,
|
|
968
|
+
including a bare directory* — if "no data yet" is an error, it is a tool. Enumerate the
|
|
969
|
+
live surface rather than trusting a list here:
|
|
970
|
+
```bash
|
|
971
|
+
grep -oE "uri: 'pan://[a-z]+'" pan-wizard-core/mcp/tool-registry.cjs
|
|
972
|
+
grep -oE "name: 'pan_[a-z_]+'" pan-wizard-core/mcp/tool-registry.cjs pan-wizard-core/mcp/native-tools.cjs
|
|
973
|
+
```
|
|
974
|
+
- **Safety is structural, not advisory:** shell-less `execFile` with an argv array, the verb
|
|
975
|
+
always chosen from the registry allowlist, every argument validated against a whitelist
|
|
976
|
+
regex with a length bound (except `attempt`, an integer range; the per-call `cwd`, an existing absolute directory; and `pan_next_action`'s phase snapshot and `pan_request_merge`'s CI/verify flags, which never reach a process argument), a `FORBIDDEN_VERB` guard that refuses to expose any
|
|
977
|
+
history-rewriting or force git op (recovery is revert-only), and a merge gate that requires
|
|
978
|
+
an out-of-band human token an agent-supplied value cannot satisfy.
|
|
979
|
+
- **The project root travels with the call.** Every tool accepts an optional `cwd` — the
|
|
980
|
+
absolute path of the project to operate on, validated as an existing directory and used for
|
|
981
|
+
that call only; without it the server falls back to `PAN_PROJECT_ROOT` when set, else the directory it was started in.
|
|
982
|
+
Resources never take it: their argv is static, which is the whole of their safety argument.
|
|
983
|
+
The reason is the Agent Plugins format (ADR-0045): its clients launch a stdio server in the
|
|
984
|
+
**plugin root** by default, so a server that trusted its own cwd would read `.planning/`
|
|
985
|
+
from inside the plugin cache and report an empty project — cleanly. The decoration is applied
|
|
986
|
+
centrally in the registry, so a tool added later cannot miss it.
|
|
987
|
+
- **Registration** is per-runtime and non-destructive; the verified path/shape table is
|
|
988
|
+
`MCP_REGISTRATION` in `bin/install-lib.cjs`, deliberately sitting beside `HOOK_EVENT_MAP`
|
|
989
|
+
because it is the same class of problem. Paths there are **config-dir-relative**, except Claude's `.mcp.json`, which sits at the repo root. Codex and
|
|
990
|
+
Claude-global are intentionally *not* written — the table records why for each.
|
|
991
|
+
|
|
992
|
+
#### Experimental: ZCode via PAN-Z (preview)
|
|
993
|
+
|
|
994
|
+
[ZCode](https://zcode.z.ai) (z.ai's GLM harness, **beta**) has no custom slash-commands,
|
|
995
|
+
hooks, or project config, so it cannot host the converted content at all — MCP is the only
|
|
996
|
+
interface it speaks. **PAN-Z** (`pan-zcode/`) is therefore a **consumer of the shared bridge
|
|
997
|
+
above**, not the owner of it: it ports PAN's agents to ZCode subagents and emits an MCP
|
|
998
|
+
registration pointing at `pan-wizard-core/mcp/server.cjs`. It remains a **separate, opt-in
|
|
999
|
+
subsystem with its own installer** (`pan-zcode/bin/install-zcode.js`) — deliberately **not** a
|
|
1000
|
+
sixth target of `bin/install.js` — and its ZCode-runtime behaviors are still gated behind an
|
|
1001
|
+
empirical verify spike (see `pan-zcode/KNOWN-BETA-RISKS.md`).
|
|
1002
|
+
|
|
1003
|
+
---
|
|
1004
|
+
|
|
1005
|
+
## Key Design Decisions
|
|
1006
|
+
|
|
1007
|
+
### 1. CommonJS (.cjs), not ESM
|
|
1008
|
+
|
|
1009
|
+
Node's built-in `node:test` runner, which PAN's own suite uses, and the hook copy pipeline work more reliably with CommonJS. All library modules use the `.cjs` extension to make this explicit and avoid ambiguity with package.json `type` settings.
|
|
1010
|
+
|
|
1011
|
+
### 2. Zero Runtime Dependencies
|
|
1012
|
+
|
|
1013
|
+
The core library uses only Node.js built-in modules (`fs`, `path`, `child_process`, `os`, `crypto`; the CLI entry also loads `module` for Node's compile cache). This keeps installation fast, eliminates supply chain risk, and ensures the tool works offline after install.
|
|
1014
|
+
|
|
1015
|
+
### 3. Markdown-as-Code
|
|
1016
|
+
|
|
1017
|
+
Commands, workflows, agents, and references are all Markdown files. They are not executed by a runtime — they are "executed" by being read into the AI's context window. This means:
|
|
1018
|
+
|
|
1019
|
+
- No parser to maintain
|
|
1020
|
+
- Authors write in natural language with XML structure markers
|
|
1021
|
+
- Version control diffs are human-readable
|
|
1022
|
+
- Any text editor can modify the system's behavior
|
|
1023
|
+
|
|
1024
|
+
### 4. JSON CLI Bridge
|
|
1025
|
+
|
|
1026
|
+
Workflows call `pan-tools.cjs` via bash and parse the JSON output. This keeps the Node.js layer thin and independently testable. The CLI never maintains state between invocations — every call is stateless, reading from and writing to `.planning/` files.
|
|
1027
|
+
|
|
1028
|
+
### 5. Cross-Platform Path Handling
|
|
1029
|
+
|
|
1030
|
+
`toPosix()` in `core.cjs` normalizes all file paths to forward slashes in JSON output. File-based input (reading arguments from files rather than command-line strings) avoids `$` shell expansion issues across Windows, Linux, and macOS.
|
|
1031
|
+
|
|
1032
|
+
### 6. Large Output Handling
|
|
1033
|
+
|
|
1034
|
+
When JSON output from `pan-tools.cjs` exceeds approximately 50KB, it is written to a temporary file and the file path is returned with an `@file:` prefix. This prevents shell buffer overflow and keeps context consumption predictable.
|
|
1035
|
+
|
|
1036
|
+
### 7. Model Resolution via "inherit"
|
|
1037
|
+
|
|
1038
|
+
`resolveModelInternal()` / `resolveModelDetailed()` in `core.cjs` (behind `resolve-model`) return `"inherit"` for reasoning-tier agents instead of a literal model string like `"opus"`. This lets the runtime use whatever top-tier model the user has configured in their environment, rather than hard-coding a specific model identifier.
|
|
1039
|
+
|
|
1040
|
+
### 8. Install-Time Format Conversion
|
|
1041
|
+
|
|
1042
|
+
All format differences between runtimes (SKILL.md vs commands/*.md, .agent.md vs .md, tool name mappings, hook config format) are resolved at install time by the installer. Agents never need to know which runtime they're running on — the format is already correct. The core library reads the runtime it is running under in two places, both from its own install path: `hostRuntime()` in `core.cjs`, which recognises an OpenCode install so `resolve-model` returns OpenCode's `provider/model` ids, and `panVersionInfo()` in `commands.cjs`, which names the install directory so `version --check` reads that runtime's update-check cache.
|
|
1043
|
+
|
|
1044
|
+
### 9. File-Mediated Agent Communication
|
|
1045
|
+
|
|
1046
|
+
Agents never communicate directly. All data flows through `.planning/` files on disk. This makes every intermediate artifact inspectable, enables parallel execution (researchers, mappers, executors), and means failed agents can be re-run without losing sibling work. See [AGENTS.md](AGENTS.md#how-agents-collaborate) for details.
|
|
1047
|
+
|
|
1048
|
+
### 10. Layered Architecture with Strict Boundaries
|
|
1049
|
+
|
|
1050
|
+
- Commands (Layer 1) delegate substantive logic to workflows; self-contained commands (`debug`, `phase-budget`, the `focus-*` family) call `pan-tools` directly for bootstrap data
|
|
1051
|
+
- Workflows (Layer 2) never import agent `.md` files — they spawn agents via Task tool
|
|
1052
|
+
- Agents (Layer 3) never import other agents — they communicate via `.planning/` files
|
|
1053
|
+
- Core modules (Layer 4) call `output()` only on the CLI path: from `cmd*` entry points and a few CLI-only handlers they dispatch to (`focusAuto*` in focus.cjs, `renderHealthReport` in commands.cjs, `_notGitRepo`/`_noRemote` in git.cjs)
|
|
1054
|
+
- No upward dependencies (a core module never requires pan-tools.cjs)
|