pan-wizard 2.8.1 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +4 -2
  2. package/bin/install.js +23 -0
  3. package/commands/pan/assumptions.md +38 -3
  4. package/commands/pan/audit-deployment.md +6 -0
  5. package/commands/pan/debug.md +71 -2
  6. package/commands/pan/exec-phase.md +90 -0
  7. package/commands/pan/focus-auto.md +181 -18
  8. package/commands/pan/focus-design.md +302 -14
  9. package/commands/pan/focus-doc-audit.md +530 -0
  10. package/commands/pan/focus-drift-walking.md +525 -0
  11. package/commands/pan/focus-exec.md +168 -46
  12. package/commands/pan/focus-plan.md +204 -12
  13. package/commands/pan/focus-scan.md +17 -5
  14. package/commands/pan/map-codebase.md +32 -6
  15. package/commands/pan/milestone-audit.md +23 -0
  16. package/commands/pan/new-project.md +64 -0
  17. package/commands/pan/pause.md +42 -1
  18. package/commands/pan/plan-phase.md +84 -0
  19. package/commands/pan/profile.md +2 -1
  20. package/commands/pan/quick.md +15 -0
  21. package/commands/pan/resume.md +62 -2
  22. package/commands/pan/verify-phase.md +42 -0
  23. package/package.json +1 -1
  24. package/pan-wizard-core/bin/lib/commands.cjs +29 -7
  25. package/pan-wizard-core/bin/lib/config.cjs +10 -0
  26. package/pan-wizard-core/bin/lib/constants.cjs +3 -1
  27. package/pan-wizard-core/bin/lib/core.cjs +168 -21
  28. package/pan-wizard-core/bin/lib/focus.cjs +5 -0
  29. package/pan-wizard-core/bin/lib/verify.cjs +283 -4
  30. package/pan-wizard-core/bin/pan-tools.cjs +11 -2
  31. package/pan-wizard-core/references/model-profiles.md +191 -62
  32. package/pan-wizard-core/workflows/help.md +11 -1
  33. package/pan-wizard-core/workflows/profile.md +8 -1
  34. package/pan-wizard-core/workflows/settings.md +14 -0
  35. package/scripts/generate-skills-docs.py +560 -0
@@ -49,16 +49,42 @@ Check for .planning/state.md - loads context if project already initialized
49
49
  - Trivial codebases (<5 files)
50
50
  </when_to_use>
51
51
 
52
+ <tool_priority>
53
+ Each mapper agent should use the simplest sufficient tool:
54
+ 1. Glob — discover files by pattern (find all .ts files, config files, test files)
55
+ 2. Grep — search for patterns across the codebase (imports, exports, function names)
56
+ 3. Read — examine specific files found by Glob/Grep
57
+ 4. Bash — only for git history or commands dedicated tools cannot handle
58
+ </tool_priority>
59
+
60
+ <progressive_context>
61
+ The orchestrator loads context in layers — NOT everything upfront. Mapper agents receive only what they need.
62
+
63
+ **Orchestrator layers (before spawning agents):**
64
+ 1. **Manifest** — package.json/Cargo.toml, project identity, entry points
65
+ 2. **Structure** — top-level directory listing, file count by extension, test presence
66
+ 3. **Git summary** — recent commits (10), contributors, branch info
67
+
68
+ **Per-agent context (each agent loads its own):**
69
+ - Each agent starts with: project manifest + directory structure + its focus area description
70
+ - Each agent discovers its own details via Glob/Grep/Read within its focus area
71
+ - Agents do NOT receive other agents' output (parallel, independent)
72
+
73
+ **Why:** Loading the entire codebase into the orchestrator before spawning agents wastes orchestrator context. Each agent has a fresh 200k window — let them explore independently. The orchestrator only needs enough context to spawn correctly and verify outputs exist.
74
+ </progressive_context>
75
+
52
76
  <process>
53
77
  1. Check if .planning/codebase/ already exists (offer to refresh or skip)
54
78
  2. Create .planning/codebase/ directory structure
55
- 3. Spawn 4 parallel pan-document_code agents:
56
- - Agent 1: tech focus → writes STACK.md, INTEGRATIONS.md
57
- - Agent 2: arch focus → writes ARCHITECTURE.md, STRUCTURE.md
58
- - Agent 3: quality focus → writes CONVENTIONS.md, TESTING.md
59
- - Agent 4: concerns focus → writes CONCERNS.md
79
+ 3. Spawn 6 parallel pan-document_code agents:
80
+ - Agent 1: tech focus → writes stack.md, integrations.md
81
+ - Agent 2: arch focus → writes architecture.md, structure.md
82
+ - Agent 3: quality focus → writes conventions.md, testing.md
83
+ - Agent 4: concerns focus → writes concerns.md
84
+ - Agent 5: relationships focus → writes relationships.md
85
+ - Agent 6: practices focus → writes best-practices.md
60
86
  4. Wait for agents to complete, collect confirmations (NOT document contents)
61
- 5. Verify all 7 documents exist with line counts
87
+ 5. Verify all 9 documents exist with line counts
62
88
  6. Commit codebase map
63
89
  7. Offer next steps (typically: /pan:new-project or /pan:plan-phase)
64
90
  </process>
@@ -31,6 +31,29 @@ Glob: .planning/phases/*/*-summary.md
31
31
  Glob: .planning/phases/*/*-verification.md
32
32
  </context>
33
33
 
34
+ <citation_requirement>
35
+ Every coverage judgment in the audit MUST cite evidence from the codebase.
36
+
37
+ **Before writing any requirement as "covered" or "not covered", verify by reading the code.**
38
+
39
+ **Grounding rules:**
40
+ - "Covered" requires: file:line where the requirement is implemented + verification.md or test evidence
41
+ - "Partially covered" requires: file:line showing what exists + specific gap description with expected location
42
+ - "Not covered" requires: grep showing the expected functionality doesn't exist (show the search and empty result)
43
+ - Cross-phase integration claims require: file:line in phase A's output + file:line in phase B's consumer
44
+
45
+ **Anti-pattern:**
46
+ ```
47
+ BAD: "Requirement R3 is covered — the billing module handles this"
48
+ → Which file? Which function? How do you know?
49
+ GOOD: "Requirement R3 is covered — generateInvoice() at src/billing.ts:42 implements line-item
50
+ calculation. Verified in phase-2-verification.md (line 18). Integration: called from
51
+ src/api/orders.ts:156 (phase 3)."
52
+ ```
53
+
54
+ Do not trust summary files at face value. If a verification.md says "all tests pass" but you haven't confirmed the test count, that claim is ungrounded. Spot-check at least 2 verification files by running the actual tests.
55
+ </citation_requirement>
56
+
34
57
  <process>
35
58
  Execute the audit-milestone workflow from @~/.claude/pan-wizard-core/workflows/milestone-audit.md end-to-end.
36
59
  Preserve all workflow gates (scope determination, verification reading, integration check, requirements coverage, routing).
@@ -37,6 +37,70 @@ Initialize a new project through unified flow: questioning → research (optiona
37
37
  @~/.claude/pan-wizard-core/templates/requirements.md
38
38
  </execution_context>
39
39
 
40
+ <progressive_context>
41
+ Load context in layers — do NOT read everything upfront. Each layer builds on the previous.
42
+
43
+ **Layer 1: Manifest (always load first)**
44
+ - package.json / Cargo.toml / pyproject.toml — project identity, deps, scripts
45
+ - .planning/ existence check — is this a fresh start or existing project?
46
+ - README.md first 50 lines — what the project claims to be
47
+
48
+ **Layer 2: Structure (load during questioning)**
49
+ - Directory tree (Glob top-level patterns) — understand project shape
50
+ - Entry points — main files, index files, server files
51
+ - Test infrastructure — test framework, test directory
52
+
53
+ **Layer 3: Hotspots (load during research, if research is enabled)**
54
+ - Most-changed files (git log --name-only) — where active work happens
55
+ - Largest files — complexity centers
56
+ - Import graph roots — most-depended-on modules
57
+
58
+ **Layer 4: Baselines (load only when generating requirements/roadmap)**
59
+ - Test count + pass rate
60
+ - Build status
61
+ - Dependency audit (outdated, vulnerable)
62
+
63
+ **Why layered:** Loading everything at Layer 1 wastes 40-60% of context on information not needed until later. For greenfield projects, Layers 3-4 are empty and should be skipped entirely.
64
+ </progressive_context>
65
+
66
+ <routing_decision_tree>
67
+ Use this decision tree to select the correct path. Evaluate conditions top-to-bottom; take the FIRST match.
68
+
69
+ ```
70
+ IF .planning/ already exists AND contains project.md:
71
+ → WARN: "Project already initialized. Use /pan:resume to continue."
72
+ → STOP (do not overwrite existing project)
73
+
74
+ ELSE IF --auto flag AND @ reference document provided:
75
+ → ASK config questions only (commit_docs, model_profile)
76
+ → SKIP interactive questioning (use the @ document as project context)
77
+ → RUN research automatically
78
+ → GENERATE requirements from research + @ document
79
+ → GENERATE roadmap from requirements
80
+ → No further interaction until complete
81
+
82
+ ELSE IF --auto flag WITHOUT @ reference:
83
+ → ERROR: "--auto requires an @ referenced idea document"
84
+ → STOP
85
+
86
+ ELSE (interactive mode — default):
87
+ → RUN questioning flow (5-area deep questioning)
88
+ → ASK: "Should I research the domain ecosystem?" (Y/N)
89
+ → IF Y: spawn researchers → synthesize → continue
90
+ → IF N: skip research → continue
91
+ → PRESENT requirements for approval
92
+ → PRESENT roadmap for approval
93
+ → COMMIT if commit_docs=true
94
+ ```
95
+
96
+ **Research routing:**
97
+ ```
98
+ IF user says research: spawn pan-project-researcher agents
99
+ IF user declines research: skip directly to requirements generation
100
+ IF codebase already has substantial code: suggest skipping research (existing code IS the context)
101
+ ```
102
+ </routing_decision_tree>
103
+
40
104
  <process>
41
105
  Execute the new-project workflow from @~/.claude/pan-wizard-core/workflows/new-project.md end-to-end.
42
106
  Preserve all workflow gates (validation, approvals, commits, routing).
@@ -27,13 +27,54 @@ Routes to the pause-work workflow which handles:
27
27
  State and phase progress are gathered in-workflow with targeted reads.
28
28
  </context>
29
29
 
30
+ <handoff_schema>
31
+ The `.continue-here.md` file MUST contain ALL of the following sections. Missing sections cause resume failures.
32
+
33
+ ```yaml
34
+ # Required fields for .continue-here.md
35
+ session_id: "{date}-{slug}" # Unique session identifier
36
+ paused_at: "{ISO-8601 timestamp}" # When work was paused
37
+ phase: "{phase number and name}" # Current phase being worked on
38
+ plan: "{plan file path}" # Which plan was active
39
+
40
+ position:
41
+ last_completed_task: "{task ID}" # Last task that was fully done
42
+ next_task: "{task ID}" # What to do next
43
+ wave: "{wave number, if applicable}"
44
+
45
+ progress:
46
+ tasks_done: [{id, title, status}] # All completed tasks this session
47
+ tasks_remaining: [{id, title}] # What's left in the plan
48
+ test_baseline: "{N passing}" # Test count when session started
49
+ test_current: "{N passing}" # Test count at pause time
50
+
51
+ decisions:
52
+ - "{decision made and why}" # Choices that affect remaining work
53
+
54
+ blockers:
55
+ - "{blocker description}" # Anything preventing progress
56
+
57
+ context:
58
+ files_modified: ["{paths}"] # Files changed this session
59
+ key_findings: ["{findings}"] # Non-obvious discoveries
60
+ next_action: "{specific action}" # Exact first step on resume
61
+ ```
62
+
63
+ **Why every field matters:**
64
+ - `position` → resume agent knows WHERE to start (not re-reading the whole plan)
65
+ - `progress` → resume agent knows test baseline (detects regressions vs pre-existing)
66
+ - `decisions` → resume agent won't re-debate settled questions
67
+ - `blockers` → resume agent can flag to user immediately instead of rediscovering
68
+ - `context.next_action` → resume agent's first action is productive, not exploratory
69
+ </handoff_schema>
70
+
30
71
  <process>
31
72
  **Follow the pause-work workflow** from `@~/.claude/pan-wizard-core/workflows/pause.md`.
32
73
 
33
74
  The workflow handles all logic including:
34
75
  1. Phase directory detection
35
76
  2. State gathering with user clarifications
36
- 3. Handoff file writing with timestamp
77
+ 3. Handoff file writing with timestamp — **using the schema from `<handoff_schema>`**
37
78
  4. Git commit
38
79
  5. Confirmation with resume instructions
39
80
  </process>
@@ -40,6 +40,90 @@ Phase number: $ARGUMENTS (optional — auto-detects next unplanned phase if omit
40
40
  Normalize phase input in step 2 before any directory lookups.
41
41
  </context>
42
42
 
43
+ <reflexion_loop>
44
+ During the plan-checker verification iteration:
45
+ 1. Read the plan-checker's critique carefully
46
+ 2. For each identified gap: verify it is a genuine gap by re-reading the relevant requirement
47
+ 3. Do not blindly accept all critiques — some may be false positives from missing context
48
+ 4. Revise the plan to address genuine gaps only
49
+ 5. Maximum 2 revision iterations (plan → check → revise → check → final)
50
+ This prevents over-revision while ensuring real gaps are closed.
51
+ </reflexion_loop>
52
+
53
+ <completion_contract>
54
+ Planning is complete when ALL conditions are met:
55
+ 1. At least one plan.md file created in the phase directory
56
+ 2. Plan-checker passed (or max 2 revision iterations exhausted with final approval)
57
+ 3. Each plan contains: objective, task breakdown with estimates, dependency ordering, and key file links
58
+ 4. Research.md exists (unless --skip-research was used)
59
+ 5. User presented with results and next-step options
60
+
61
+ Planning FAILS if: phase not found in roadmap, or planner agent returns empty/malformed output after retries.
62
+ </completion_contract>
63
+
64
+ <common_mistakes>
65
+ Avoid these planning anti-patterns:
66
+ ```
67
+ BAD: Plan has 25 tasks for a single phase → too granular, executor loses context
68
+ GOOD: 5-8 tasks per plan, each with clear scope and testable outcome
69
+
70
+ BAD: Task says "Implement the feature" with no file links or acceptance criteria
71
+ → Executor guesses at scope, misses edge cases
72
+ GOOD: Task says "Add retry logic to api/client.ts:fetchData() — 3 retries with exponential backoff, tested by tests/client.test.ts"
73
+
74
+ BAD: Plan-checker flags a gap → blindly add a task without re-reading the requirement
75
+ → False positive becomes unnecessary work
76
+ GOOD: Re-read the requirement → confirm the gap is real → then add the task
77
+ ```
78
+ </common_mistakes>
79
+
80
+ <routing_decision_tree>
81
+ Use this decision tree to select the correct path. Evaluate conditions top-to-bottom; take the FIRST match.
82
+
83
+ ```
84
+ IF --gaps flag is set:
85
+ → SKIP research (gap closure uses verification.md instead)
86
+ → READ verification.md for the phase
87
+ → PLAN with gap context
88
+ → VERIFY (unless --skip-verify)
89
+
90
+ ELSE IF --prd <file> flag is set:
91
+ → SKIP discuss-phase entirely
92
+ → PARSE PRD file into context.md
93
+ → SKIP research (PRD provides requirements)
94
+ → PLAN from parsed requirements
95
+ → VERIFY (unless --skip-verify)
96
+
97
+ ELSE IF --skip-research flag is set:
98
+ → SKIP research
99
+ → PLAN directly (must have roadmap context)
100
+ → VERIFY (unless --skip-verify)
101
+
102
+ ELSE IF research.md already exists AND --research NOT set:
103
+ → SKIP research (reuse existing)
104
+ → PLAN using existing research.md
105
+ → VERIFY (unless --skip-verify)
106
+
107
+ ELSE (default path):
108
+ → RUN research (spawn pan-phase-researcher)
109
+ → PLAN from research results
110
+ → VERIFY (unless --skip-verify)
111
+ ```
112
+
113
+ **Verification loop routing:**
114
+ ```
115
+ IF --skip-verify:
116
+ → Present plan, done
117
+
118
+ ELSE:
119
+ → Spawn pan-plan-checker
120
+ → IF checker PASSES: done
121
+ → IF checker finds gaps (iteration 1): revise plan, re-check
122
+ → IF checker finds gaps (iteration 2): final revision, present with caveats
123
+ → Max 2 revision iterations
124
+ ```
125
+ </routing_decision_tree>
126
+
43
127
  <process>
44
128
  Execute the plan-phase workflow from @~/.claude/pan-wizard-core/workflows/plan-phase.md end-to-end.
45
129
  Preserve all workflow gates (validation, research, planning, verification loop, routing).
@@ -32,5 +32,6 @@ The workflow handles all logic including:
32
32
  2. Config file ensuring
33
33
  3. Config reading and updating
34
34
  4. Model table generation from MODEL_PROFILES
35
- 5. Confirmation display
35
+ 5. Cost estimation display (relative cost multiplier per profile)
36
+ 6. Confirmation display
36
37
  </process>
@@ -39,4 +39,19 @@ Context files are resolved inside the workflow (`init quick`) and delegated via
39
39
  <process>
40
40
  Execute the quick workflow from @~/.claude/pan-wizard-core/workflows/quick.md end-to-end.
41
41
  Preserve all workflow gates (validation, task description, planning, execution, state updates, commits).
42
+
43
+ **Scope Containment:**
44
+ Implement only what was asked. Do not refactor surrounding code, add unrelated improvements, or create abstractions for one-time fixes.
45
+
46
+ **State Intent Before Implementing:**
47
+ Before coding, state: "I will modify [files], adding [what], to achieve [goal]."
48
+
49
+ **Pre-Commit Verification Checklist — apply before the final commit:**
50
+ 1. Every modified file was read before editing
51
+ 2. `git diff --stat` contains only files related to the task
52
+ 3. Tests pass (run the project's test suite)
53
+ 4. Commit message accurately describes the verified change
54
+ 5. No secrets or credentials staged
55
+
56
+ If any check fails: fix and re-verify before committing.
42
57
  </process>
@@ -26,6 +26,66 @@ Routes to the resume-project workflow which handles:
26
26
  @~/.claude/pan-wizard-core/workflows/resume-project.md
27
27
  </execution_context>
28
28
 
29
+ <handoff_consumption>
30
+ When a `.continue-here.md` file exists, parse it as structured handoff data before presenting options.
31
+
32
+ **Required extraction (in order):**
33
+ 1. `position.next_task` → This is the FIRST thing to tell the user
34
+ 2. `blockers` → If non-empty, surface BEFORE offering to continue
35
+ 3. `decisions` → Load into context so they are not re-debated
36
+ 4. `progress.test_baseline` + `progress.test_current` → Verify current test count matches `test_current` (detect drift since pause)
37
+ 5. `context.next_action` → Use as the default suggested action
38
+
39
+ **Resume validation:**
40
+ - If `test_current` at resume time differs from stored value → warn user: "Test count changed since pause ({stored} → {current}). Someone else may have committed."
41
+ - If `position.next_task` references a task not in the plan → warn: plan may have been revised since pause
42
+ - If `blockers` exist → present them and ask if resolved before continuing
43
+
44
+ **Anti-pattern:**
45
+ ```
46
+ BAD: Resume reads .continue-here.md, ignores position, re-reads entire plan from scratch
47
+ → Wastes context on already-completed work, may re-implement done tasks
48
+ GOOD: Resume extracts position.next_task, skips completed tasks, starts exactly where paused
49
+ ```
50
+ </handoff_consumption>
51
+
52
+ <routing_decision_tree>
53
+ Use this decision tree to select the correct resumption path. Evaluate top-to-bottom; take the FIRST match.
54
+
55
+ ```
56
+ IF .planning/ does not exist:
57
+ → "No project found. Run /pan:new-project to get started."
58
+ → STOP
59
+
60
+ ELSE IF .continue-here.md exists:
61
+ → PARSE handoff file using <handoff_consumption> protocol
62
+ → PRESENT: position, blockers, next action
63
+ → ROUTE to the command that was paused (exec-phase, plan-phase, etc.)
64
+
65
+ ELSE IF state.md exists AND has status "in_progress":
66
+ → FIND incomplete work: plans without summaries, phases mid-execution
67
+ → IF incomplete phase found:
68
+ → PRESENT phase status + what remains
69
+ → OFFER: continue execution (/pan:exec-phase) or verify (/pan:verify-phase)
70
+ → IF no incomplete work but active milestone:
71
+ → PRESENT milestone progress
72
+ → OFFER: next unplanned phase (/pan:plan-phase) or audit (/pan:milestone-audit)
73
+
74
+ ELSE IF state.md exists AND has status "blocked":
75
+ → PRESENT blockers from state.md
76
+ → OFFER: debug (/pan:debug) or unblock manually
77
+
78
+ ELSE IF state.md exists AND has status "completed":
79
+ → "Current milestone is complete. Run /pan:milestone-done or /pan:milestone-new."
80
+ → STOP
81
+
82
+ ELSE (state.md missing or unreadable):
83
+ → ATTEMPT reconstruction from .planning/ artifacts
84
+ → IF reconstruction succeeds: re-enter tree above
85
+ → IF reconstruction fails: "State is corrupted. Run /pan:new-project or restore from git."
86
+ ```
87
+ </routing_decision_tree>
88
+
29
89
  <process>
30
90
  **Follow the resume-project workflow** from `@~/.claude/pan-wizard-core/workflows/resume-project.md`.
31
91
 
@@ -33,9 +93,9 @@ The workflow handles all resumption logic including:
33
93
 
34
94
  1. Project existence verification
35
95
  2. state.md loading or reconstruction
36
- 3. Checkpoint and incomplete work detection
96
+ 3. Checkpoint and incomplete work detection — **parse using `<handoff_consumption>` protocol**
37
97
  4. Visual status presentation
38
98
  5. Context-aware option offering (checks context.md before suggesting plan vs discuss)
39
- 6. Routing to appropriate next command
99
+ 6. Routing to appropriate next command — **following `<routing_decision_tree>`**
40
100
  7. Session continuity updates
41
101
  </process>
@@ -33,6 +33,48 @@ Phase: $ARGUMENTS (optional)
33
33
  Context files are resolved inside the workflow (`init verify-work`) and delegated via `<files_to_read>` blocks.
34
34
  </context>
35
35
 
36
+ <investigate_before_judging>
37
+ Never claim a feature works or doesn't work without reading the implementation first.
38
+ Before each verification judgment:
39
+ 1. Read the source file(s) that implement the feature
40
+ 2. Read the test file(s) that cover it
41
+ 3. Run the tests
42
+ 4. Only then state your assessment with file:line evidence
43
+ Do not speculate about code you have not opened.
44
+ </investigate_before_judging>
45
+
46
+ <citation_requirement>
47
+ Every verdict (PASS, PARTIAL, FAIL) MUST include at least one file:line citation as evidence.
48
+
49
+ **Before writing any judgment, scan your draft for unsourced claims.** If you find an assertion without evidence, stop and gather it before continuing.
50
+
51
+ Format: `verdict: PASS — feature works as specified (src/billing.ts:42, tests/billing.test.ts:18-35)`
52
+
53
+ **Grounding rules:**
54
+ - PASS requires: file:line where the feature is implemented + test file:line where it's verified
55
+ - PARTIAL requires: file:line showing what works + description of what's missing with expected location
56
+ - FAIL requires: file:line showing the defect OR absence (grep result showing the expected function/export doesn't exist)
57
+ - "I checked and it's not there" is NOT evidence — show the grep command and its empty result
58
+
59
+ **Anti-pattern:**
60
+ ```
61
+ BAD: "FAIL — the retry logic doesn't handle timeouts"
62
+ → No evidence. Maybe it does handle timeouts and you didn't read far enough.
63
+ GOOD: "FAIL — retry logic at api/client.ts:67-89 catches ConnectionError but not TimeoutError.
64
+ Grep for 'TimeoutError' in api/: 0 matches. tests/client.test.ts has no timeout test cases."
65
+ ```
66
+ </citation_requirement>
67
+
68
+ <reflexion_loop>
69
+ After initial verification of each requirement:
70
+ 1. Score each requirement: PASS / PARTIAL / FAIL
71
+ 2. For PARTIAL or FAIL: state specifically what is missing or broken
72
+ 3. Re-read the requirement text and the implementation — did you miss anything?
73
+ 4. Revise the score if the re-read reveals evidence you overlooked
74
+ 5. Report only final scores after this review cycle
75
+ This prevents premature FAIL verdicts from incomplete investigation.
76
+ </reflexion_loop>
77
+
36
78
  <process>
37
79
  Execute the verify-work workflow from @~/.claude/pan-wizard-core/workflows/verify-phase.md end-to-end.
38
80
  Preserve all workflow gates (session management, test presentation, diagnosis, fix planning, routing).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pan-wizard",
3
- "version": "2.8.1",
3
+ "version": "2.9.1",
4
4
  "description": "A lightweight workflow automation and context engineering system for Claude Code, OpenCode, Gemini CLI, Codex, and Copilot CLI.",
5
5
  "bin": {
6
6
  "pan-wizard": "bin/install.js"
@@ -3,7 +3,7 @@
3
3
  */
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
- const { safeReadFile, loadConfig, isGitIgnored, isGitRepo, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, output, error, findPhaseInternal, scanPendingTodos, toPosix } = require('./core.cjs');
6
+ const { safeReadFile, loadConfig, isGitIgnored, isGitRepo, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, detectProvider, resolveTierToModel, estimateCostMultiplier, MODEL_PROFILES, output, error, findPhaseInternal, scanPendingTodos, toPosix } = require('./core.cjs');
7
7
  const { extractFrontmatter } = require('./frontmatter.cjs');
8
8
  const { PLANNING_DIR, PHASES_DIR, MILESTONES_DIR, QUICK_DIR, STATE_FILE, ROADMAP_FILE, PROJECT_FILE, PATTERNS_FILE, SESSION_HISTORY_FILE, LEARNINGS_FILE, CONTEXT_SUFFIX, UAT_SUFFIX, VERIFICATION_SUFFIX, isPlanFile, isSummaryFile, ARCHIVE_DIR_RE, PHASE_DIR_RE, CONTEXT_WINDOW, WARNING_THRESHOLD, CRITICAL_THRESHOLD, VALID_COMMIT_TYPES, DEFAULT_SENSITIVE_PATTERNS } = require('./constants.cjs');
9
9
  const { planningPath, phasesPath, filterPlanFiles, filterSummaryFiles } = require('./utils.cjs');
@@ -272,29 +272,50 @@ function cmdHistoryDigest(cwd, raw) {
272
272
  * @param {string} cwd - Working directory path
273
273
  * @param {string} agentType - Agent type identifier (e.g., "pan-executor", "pan-planner")
274
274
  * @param {boolean} raw - If true, output raw model name instead of JSON
275
+ * @param {string} [metadataJson] - Optional JSON string with task metadata for complexity routing
275
276
  * @returns {void}
276
277
  */
277
- function cmdResolveModel(cwd, agentType, raw) {
278
+ function cmdResolveModel(cwd, agentType, raw, metadataJson) {
278
279
  if (!agentType) {
279
280
  error('agent-type required');
280
281
  }
281
282
 
283
+ let taskMetadata = null;
284
+ if (metadataJson) {
285
+ try { taskMetadata = JSON.parse(metadataJson); }
286
+ catch { /* ignore invalid metadata, use static routing */ }
287
+ }
288
+
282
289
  const config = loadConfig(cwd);
283
290
  const profile = config.model_profile || 'balanced';
291
+ const strategy = config.routing?.strategy || 'static';
284
292
 
285
293
  const agentModels = MODEL_PROFILES[agentType];
286
294
  if (!agentModels) {
287
- const result = { model: 'sonnet', profile, unknown_agent: true };
288
- output(result, raw, 'sonnet');
295
+ const model = resolveTierToModel('mid', detectProvider(cwd, config));
296
+ const result = { model, profile, strategy, unknown_agent: true };
297
+ output(result, raw, model);
289
298
  return;
290
299
  }
291
300
 
292
- const resolved = agentModels[profile] || agentModels['balanced'] || 'sonnet';
293
- const model = resolved === 'opus' ? 'inherit' : resolved;
294
- const result = { model, profile };
301
+ const model = resolveModelInternal(cwd, agentType, taskMetadata);
302
+ const result = { model, profile, strategy };
295
303
  output(result, raw, model);
296
304
  }
297
305
 
306
+ /**
307
+ * Estimate cost multipliers for all profiles.
308
+ * @param {string} cwd - Working directory path
309
+ * @param {boolean} raw - If true, output formatted text instead of JSON
310
+ * @returns {void}
311
+ */
312
+ function cmdEstimateCost(cwd, raw) {
313
+ const estimates = ['quality', 'balanced', 'budget'].map(estimateCostMultiplier);
314
+ output({ estimates }, raw, estimates.map(e =>
315
+ `${e.profile}: ~${e.average}x baseline (${e.agentCount} agents)`
316
+ ).join('\n'));
317
+ }
318
+
298
319
 
299
320
  /**
300
321
  * Stage and commit planning files to git, respecting commit_docs config and gitignore.
@@ -1416,6 +1437,7 @@ module.exports = {
1416
1437
  cmdVerifyPathExists,
1417
1438
  cmdHistoryDigest,
1418
1439
  cmdResolveModel,
1440
+ cmdEstimateCost,
1419
1441
  cmdCommit,
1420
1442
  cmdSummaryExtract,
1421
1443
  cmdWebsearch,
@@ -70,6 +70,15 @@ function buildConfigDefaults(hasBraveSearch, userDefaults) {
70
70
  rollback_snapshots: true,
71
71
  error_pattern_learning: true,
72
72
  },
73
+ routing: {
74
+ strategy: 'static',
75
+ provider: 'auto',
76
+ cascade_quality_gate: true,
77
+ complexity_thresholds: {
78
+ downgrade_max: 2,
79
+ upgrade_min: 6,
80
+ },
81
+ },
73
82
  };
74
83
  return {
75
84
  ...hardcoded,
@@ -78,6 +87,7 @@ function buildConfigDefaults(hasBraveSearch, userDefaults) {
78
87
  budget: { ...hardcoded.budget, ...(userDefaults.budget || {}) },
79
88
  commit: { ...hardcoded.commit, ...(userDefaults.commit || {}) },
80
89
  execution: { ...hardcoded.execution, ...(userDefaults.execution || {}) },
90
+ routing: { ...hardcoded.routing, ...(userDefaults.routing || {}) },
81
91
  };
82
92
  }
83
93
 
@@ -123,7 +123,7 @@ const FOCUS_DIR = 'focus';
123
123
  const AUTO_RUN_FILE = 'auto-run.json';
124
124
 
125
125
  /** Focus auto-runner categories */
126
- const FOCUS_CATEGORIES = ['cleanup', 'tests', 'stability', 'features', 'docs', 'optimize'];
126
+ const FOCUS_CATEGORIES = ['cleanup', 'tests', 'stability', 'features', 'docs', 'optimize', 'prompts'];
127
127
 
128
128
  /** Category → priority index range (indices into PRIORITY_LEVELS) */
129
129
  const CATEGORY_PRIORITY_RANGE = {
@@ -133,6 +133,7 @@ const CATEGORY_PRIORITY_RANGE = {
133
133
  features: { min: 3, max: 5 }, // P3-P5
134
134
  docs: { min: 5, max: 6 }, // P5-P6
135
135
  optimize: { min: 1, max: 4 }, // P1-P4
136
+ prompts: { min: 0, max: 6 }, // P0-P6 (all priorities — prompt order is authoritative)
136
137
  };
137
138
 
138
139
  /** Category → default mode + budget */
@@ -143,6 +144,7 @@ const CATEGORY_DEFAULTS = {
143
144
  features: { mode: 'features', budget: 50 },
144
145
  docs: { mode: 'balanced', budget: 30 },
145
146
  optimize: { mode: 'balanced', budget: 50 },
147
+ prompts: { mode: 'balanced', budget: 100 },
146
148
  };
147
149
 
148
150
  /** Doc files to scan for staleness (focus sync) */