pan-wizard 2.9.1 → 3.5.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/README.md +31 -9
- package/agents/pan-conductor.md +189 -0
- package/agents/pan-counterfactual.md +112 -0
- package/agents/pan-debugger.md +15 -1
- package/agents/pan-distiller.md +82 -0
- package/agents/pan-document_code.md +21 -0
- package/agents/pan-executor.md +16 -0
- package/agents/pan-hardener.md +113 -0
- package/agents/pan-integration-checker.md +2 -0
- package/agents/pan-knowledge.md +81 -0
- package/agents/pan-meta-reviewer.md +91 -0
- package/agents/pan-optimizer.md +242 -0
- package/agents/pan-plan-checker.md +2 -0
- package/agents/pan-previewer.md +98 -0
- package/agents/pan-project-researcher.md +4 -4
- package/agents/pan-reviewer.md +2 -0
- package/agents/pan-verifier.md +2 -0
- package/bin/install-lib.cjs +197 -0
- package/bin/install.js +2048 -1959
- package/commands/pan/cost.md +132 -0
- package/commands/pan/exec-phase.md +15 -0
- package/commands/pan/focus-auto.md +168 -3
- package/commands/pan/focus-exec.md +21 -1
- package/commands/pan/focus-scan.md +6 -0
- package/commands/pan/git.md +223 -0
- package/commands/pan/knowledge.md +129 -0
- package/commands/pan/learn.md +61 -0
- package/commands/pan/map-codebase.md +15 -0
- package/commands/pan/mcp-bridge.md +145 -0
- package/commands/pan/milestone-done.md +9 -0
- package/commands/pan/optimize.md +86 -0
- package/commands/pan/plan-phase.md +11 -0
- package/commands/pan/preview.md +114 -0
- package/commands/pan/profile.md +37 -0
- package/commands/pan/review-deep.md +128 -0
- package/commands/pan/verify-phase.md +11 -0
- package/commands/pan/what-if.md +146 -0
- package/hooks/dist/pan-cost-logger.js +102 -0
- package/hooks/dist/pan-statusline.js +154 -108
- package/hooks/dist/pan-trace-logger.js +197 -0
- package/package.json +1 -1
- package/pan-wizard-core/bin/lib/bridge.cjs +269 -0
- package/pan-wizard-core/bin/lib/bus.cjs +251 -0
- package/pan-wizard-core/bin/lib/codebase.cjs +118 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1 -0
- package/pan-wizard-core/bin/lib/constants.cjs +44 -1
- package/pan-wizard-core/bin/lib/context-budget.cjs +27 -0
- package/pan-wizard-core/bin/lib/core.cjs +91 -6
- package/pan-wizard-core/bin/lib/cost.cjs +359 -0
- package/pan-wizard-core/bin/lib/distill.cjs +510 -0
- package/pan-wizard-core/bin/lib/focus.cjs +108 -3
- package/pan-wizard-core/bin/lib/git.cjs +407 -0
- package/pan-wizard-core/bin/lib/init.cjs +5 -5
- package/pan-wizard-core/bin/lib/knowledge.cjs +331 -0
- package/pan-wizard-core/bin/lib/memory.cjs +252 -0
- package/pan-wizard-core/bin/lib/optimize.cjs +653 -0
- package/pan-wizard-core/bin/lib/phase.cjs +40 -13
- package/pan-wizard-core/bin/lib/preview.cjs +480 -0
- package/pan-wizard-core/bin/lib/review-deep.cjs +280 -0
- package/pan-wizard-core/bin/lib/roadmap.cjs +4 -4
- package/pan-wizard-core/bin/lib/state.cjs +2 -2
- package/pan-wizard-core/bin/lib/verify.cjs +34 -1
- package/pan-wizard-core/bin/lib/whatif.cjs +289 -0
- package/pan-wizard-core/bin/pan-tools.cjs +317 -4
- package/pan-wizard-core/templates/playbook.md +53 -0
- package/pan-wizard-core/templates/preview-report.md +93 -0
- package/pan-wizard-core/templates/roadmap.md +24 -24
- package/pan-wizard-core/templates/state.md +12 -9
- package/pan-wizard-core/workflows/exec-phase.md +97 -0
- package/pan-wizard-core/workflows/learn.md +91 -0
- package/pan-wizard-core/workflows/optimize.md +139 -0
- package/pan-wizard-core/workflows/plan-phase.md +28 -1
- package/pan-wizard-core/workflows/quick.md +7 -0
- package/pan-wizard-core/workflows/verify-phase.md +16 -0
- package/scripts/build-hooks.js +3 -1
|
@@ -26,6 +26,14 @@ Parse JSON for: `executor_model`, `verifier_model`, `reviewer_model`, `commit_do
|
|
|
26
26
|
**If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
|
|
27
27
|
|
|
28
28
|
When `parallelization` is false, plans within a wave execute sequentially.
|
|
29
|
+
|
|
30
|
+
**Circular optimization — start trace session for this exec:**
|
|
31
|
+
```bash
|
|
32
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init \
|
|
33
|
+
--description "exec-phase ${PHASE_ARG}" \
|
|
34
|
+
--command "exec-phase" \
|
|
35
|
+
--phase "${PHASE_ARG}" 2>/dev/null || true
|
|
36
|
+
```
|
|
29
37
|
</step>
|
|
30
38
|
|
|
31
39
|
<step name="handle_branching">
|
|
@@ -47,6 +55,33 @@ From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
|
|
|
47
55
|
Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
|
|
48
56
|
</step>
|
|
49
57
|
|
|
58
|
+
<step name="load_phase_memory">
|
|
59
|
+
**Load project memory before dispatching executors — prevents re-learning patterns already solved.**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
ls .planning/memory/*.md 2>/dev/null
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If `.planning/memory/` exists and contains `.md` files:
|
|
66
|
+
1. **Read every file** using the Read tool
|
|
67
|
+
2. Condense each entry to its rule(s) — 1–3 lines per file
|
|
68
|
+
3. Store as `MEMORY_RULES` block for injection into executor prompts in execute_waves
|
|
69
|
+
4. **Log memory priming to trace:**
|
|
70
|
+
```bash
|
|
71
|
+
MEMORY_COUNT=$(ls .planning/memory/*.md 2>/dev/null | wc -l | tr -d ' ')
|
|
72
|
+
if [ "$MEMORY_COUNT" -gt "0" ]; then
|
|
73
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
74
|
+
--type decision --category memory_primed \
|
|
75
|
+
--description "Loaded ${MEMORY_COUNT} memory entries before Wave 1 dispatch" \
|
|
76
|
+
--agent orchestrator --impact minor \
|
|
77
|
+
--context "{\"memory_count\":${MEMORY_COUNT}}" \
|
|
78
|
+
2>/dev/null || true
|
|
79
|
+
fi
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If no memory files exist: skip (no trace event needed).
|
|
83
|
+
</step>
|
|
84
|
+
|
|
50
85
|
<step name="discover_and_group_plans">
|
|
51
86
|
Load plan inventory with wave grouping in one call:
|
|
52
87
|
|
|
@@ -76,6 +111,11 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
|
|
|
76
111
|
|
|
77
112
|
**For each wave:**
|
|
78
113
|
|
|
114
|
+
0. **Record wave start time for duration tracking:**
|
|
115
|
+
```bash
|
|
116
|
+
WAVE_START_MS=$(node -e "console.log(Date.now())")
|
|
117
|
+
```
|
|
118
|
+
|
|
79
119
|
1. **Describe what's being built (BEFORE spawning):**
|
|
80
120
|
|
|
81
121
|
Read each plan's `<objective>`. Extract what's being built and why.
|
|
@@ -125,6 +165,11 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
|
|
|
125
165
|
- .agents/skills/ (Project skills, if exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
|
|
126
166
|
</files_to_read>
|
|
127
167
|
|
|
168
|
+
<project_memory>
|
|
169
|
+
{MEMORY_RULES — insert condensed content of all .planning/memory/*.md files read in load_phase_memory step. If no memory files exist, omit this block entirely.}
|
|
170
|
+
Apply every rule in this block without exception. These are lessons from previous phases that the reviewer has already verified.
|
|
171
|
+
</project_memory>
|
|
172
|
+
|
|
128
173
|
<success_criteria>
|
|
129
174
|
- [ ] All tasks executed
|
|
130
175
|
- [ ] Each task committed individually
|
|
@@ -160,6 +205,18 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
|
|
|
160
205
|
---
|
|
161
206
|
```
|
|
162
207
|
|
|
208
|
+
Log wave completion to trace (include wall-clock duration):
|
|
209
|
+
```bash
|
|
210
|
+
WAVE_END_MS=$(node -e "console.log(Date.now())")
|
|
211
|
+
WAVE_DURATION_MS=$((WAVE_END_MS - WAVE_START_MS))
|
|
212
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
213
|
+
--type decision --category wave_complete \
|
|
214
|
+
--description "Wave ${WAVE_NUM} complete: ${PLAN_IDS}" \
|
|
215
|
+
--agent pan-executor --impact trivial \
|
|
216
|
+
--context "{\"wave\":${WAVE_NUM},\"plans\":\"${PLAN_IDS}\",\"duration_ms\":${WAVE_DURATION_MS}}" \
|
|
217
|
+
2>/dev/null || true
|
|
218
|
+
```
|
|
219
|
+
|
|
163
220
|
- Bad: "Wave 2 complete. Proceeding to Wave 3."
|
|
164
221
|
- Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
|
|
165
222
|
|
|
@@ -342,6 +399,33 @@ Task(
|
|
|
342
399
|
```
|
|
343
400
|
|
|
344
401
|
**If user chooses "Continue anyway":** Proceed to verification. Review findings are informational, not blocking.
|
|
402
|
+
|
|
403
|
+
4. **Circular optimization — log reviewer corrections to trace bus (W1 fix):**
|
|
404
|
+
|
|
405
|
+
When verdict is `NEEDS_FIXES`, write a `reviewer_correction` event so the optimizer can see the primary quality signal:
|
|
406
|
+
```bash
|
|
407
|
+
# Extract error count from review output (parse "Errors: N" line)
|
|
408
|
+
REVIEW_ERROR_COUNT=$(echo "$REVIEW_OUTPUT" | grep -E "^- Errors: [0-9]+" | grep -oE "[0-9]+" | head -1)
|
|
409
|
+
REVIEW_ERROR_COUNT=${REVIEW_ERROR_COUNT:-1}
|
|
410
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
411
|
+
--type error --category reviewer_correction \
|
|
412
|
+
--description "Phase ${PHASE_NUMBER} reviewer: NEEDS_FIXES — ${REVIEW_ERROR_COUNT} error(s) found" \
|
|
413
|
+
--agent pan-reviewer --impact major \
|
|
414
|
+
--context "{\"phase\":\"${PHASE_NUMBER}\",\"verdict\":\"NEEDS_FIXES\",\"error_count\":${REVIEW_ERROR_COUNT}}" \
|
|
415
|
+
2>/dev/null || true
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
When verdict is `PASS_WITH_WARNINGS`, log a softer signal:
|
|
419
|
+
```bash
|
|
420
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
421
|
+
--type decision --category reviewer_warnings \
|
|
422
|
+
--description "Phase ${PHASE_NUMBER} reviewer: PASS_WITH_WARNINGS — warnings present" \
|
|
423
|
+
--agent pan-reviewer --impact trivial \
|
|
424
|
+
--context "{\"phase\":\"${PHASE_NUMBER}\",\"verdict\":\"PASS_WITH_WARNINGS\"}" \
|
|
425
|
+
2>/dev/null || true
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
When verdict is `PASS`, no trace event needed — clean passes are the expected baseline.
|
|
345
429
|
</step>
|
|
346
430
|
|
|
347
431
|
<step name="close_parent_artifacts">
|
|
@@ -476,6 +560,19 @@ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
|
|
|
476
560
|
```bash
|
|
477
561
|
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs commit "docs(phase-{X}): complete phase execution" --files .planning/roadmap.md .planning/state.md .planning/requirements.md {phase_dir}/*-verification.md
|
|
478
562
|
```
|
|
563
|
+
|
|
564
|
+
**Circular optimization — finalize trace session:**
|
|
565
|
+
```bash
|
|
566
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end 2>/dev/null || true
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
Log phase completion event:
|
|
570
|
+
```bash
|
|
571
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
572
|
+
--type decision --category phase_complete \
|
|
573
|
+
--description "Phase ${PHASE_NUMBER} execution complete (${VERIFICATION_STATUS:-verified})" \
|
|
574
|
+
--agent orchestrator --impact minor 2>/dev/null || true
|
|
575
|
+
```
|
|
479
576
|
</step>
|
|
480
577
|
|
|
481
578
|
<step name="offer_next">
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Workflow: /pan:learn
|
|
2
|
+
|
|
3
|
+
Analyze the most recent trace session and generate a circular optimization report.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- A trace session must exist in `.planning/optimization/traces/`
|
|
8
|
+
- If no session exists, instruct the user to start one first:
|
|
9
|
+
```
|
|
10
|
+
/pan:optimize trace init --description "what you're building"
|
|
11
|
+
[run your build: /pan:exec-phase N or /pan:focus-exec]
|
|
12
|
+
/pan:learn
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Step 1 — Identify the session
|
|
16
|
+
|
|
17
|
+
Run:
|
|
18
|
+
```
|
|
19
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If no active session, run:
|
|
23
|
+
```
|
|
24
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace list
|
|
25
|
+
```
|
|
26
|
+
Use the most recent session unless `--session <id>` was specified.
|
|
27
|
+
|
|
28
|
+
If `--session <id>` was specified, use that session ID.
|
|
29
|
+
|
|
30
|
+
## Step 2 — Generate local analysis
|
|
31
|
+
|
|
32
|
+
Run:
|
|
33
|
+
```
|
|
34
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize learn [--session <id>]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This produces `.planning/optimization/reports/{session}-analysis.json`.
|
|
38
|
+
|
|
39
|
+
Read the output and note:
|
|
40
|
+
- `summary.errors` — how many error events
|
|
41
|
+
- `summary.gaps` — how many gap events
|
|
42
|
+
- `summary.memory_misses` — how many memory miss events
|
|
43
|
+
- `summary.wasted_tokens` — tokens wasted on redundancies
|
|
44
|
+
- `top_error_patterns` — most frequent error categories
|
|
45
|
+
- `top_memory_misses` — most frequent memory miss topics
|
|
46
|
+
|
|
47
|
+
## Step 3 — Invoke pan-optimizer agent
|
|
48
|
+
|
|
49
|
+
Spawn the `pan-optimizer` agent with this instruction:
|
|
50
|
+
|
|
51
|
+
> Read the analysis at `.planning/optimization/reports/{session}-analysis.json` and the raw trace at `.planning/optimization/traces/{session}/trace.jsonl`. Also read any existing memory at `.planning/memory/*.md` to understand what's already known. Produce a full optimization report at `.planning/optimization/reports/{session}-opt-report.md` following the format in your agent definition.
|
|
52
|
+
|
|
53
|
+
Wait for the agent to complete. It will write the report to `.planning/optimization/reports/`.
|
|
54
|
+
|
|
55
|
+
## Step 4 — Present the summary
|
|
56
|
+
|
|
57
|
+
Read `.planning/optimization/reports/{session}-opt-report.md`.
|
|
58
|
+
|
|
59
|
+
Present to the user:
|
|
60
|
+
1. **Score** — the circular optimization score (0–100)
|
|
61
|
+
2. **Top 3 findings** — the most impactful recommendations
|
|
62
|
+
3. **Auto-applicable count** — how many items `/pan:optimize apply` can handle automatically
|
|
63
|
+
4. **Review required count** — how many prompt/workflow suggestions need human review
|
|
64
|
+
5. **Next step** — suggest running `/pan:optimize apply` to apply safe optimizations
|
|
65
|
+
|
|
66
|
+
## Step 5 — Auto-apply (if --apply flag)
|
|
67
|
+
|
|
68
|
+
If the `--apply` flag was passed, immediately run:
|
|
69
|
+
```
|
|
70
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize apply
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Show what was applied and what still needs review.
|
|
74
|
+
|
|
75
|
+
## Step 6 — Update the circular score baseline
|
|
76
|
+
|
|
77
|
+
After applying, tell the user what to watch in the next run:
|
|
78
|
+
- Which memory gaps were filled (will reduce `memory_miss` events)
|
|
79
|
+
- Which error patterns were documented (will reduce repeat errors if agent reads memory)
|
|
80
|
+
- Prompt/workflow changes to consider applying manually
|
|
81
|
+
|
|
82
|
+
## Edge cases
|
|
83
|
+
|
|
84
|
+
**No events in trace:**
|
|
85
|
+
- Tell the user the trace session is empty. They may need to ensure the `pan-trace-logger` hook is registered in `.claude/settings.json`.
|
|
86
|
+
|
|
87
|
+
**Too few events (< 5):**
|
|
88
|
+
- The optimizer can still run but note the small sample size.
|
|
89
|
+
|
|
90
|
+
**Analysis fails:**
|
|
91
|
+
- Check that `.planning/optimization/traces/{session}/trace.jsonl` exists and is valid JSONL.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Workflow: /pan:optimize
|
|
2
|
+
|
|
3
|
+
Manage the circular optimization loop — apply reports, check stats, control trace sessions.
|
|
4
|
+
|
|
5
|
+
## Subcommand routing
|
|
6
|
+
|
|
7
|
+
| Subcommand | Action |
|
|
8
|
+
|------------|--------|
|
|
9
|
+
| `apply` | Apply safe recommendations from most recent report |
|
|
10
|
+
| `apply --report <file>` | Apply from a specific report |
|
|
11
|
+
| `list` | List all reports |
|
|
12
|
+
| `stats` | Show cumulative stats |
|
|
13
|
+
| `trace init` | Start a new trace session |
|
|
14
|
+
| `trace end` | Finalize current session |
|
|
15
|
+
| `trace status` | Show active session |
|
|
16
|
+
| `trace list` | List all sessions |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## apply
|
|
21
|
+
|
|
22
|
+
### Step 1 — Identify the report
|
|
23
|
+
|
|
24
|
+
Run:
|
|
25
|
+
```
|
|
26
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize list
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use the most recent `.md` report (the full opt-report, not the `-analysis.json`).
|
|
30
|
+
|
|
31
|
+
If `--report <filename>` was specified, use that file from `.planning/optimization/reports/`.
|
|
32
|
+
|
|
33
|
+
### Step 2 — Run apply
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize apply [--report <path>]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Step 3 — Present results
|
|
40
|
+
|
|
41
|
+
Show the user:
|
|
42
|
+
- **Applied** — each item that was written (memory entries, notes)
|
|
43
|
+
- **Skipped** — items that already exist or had unknown types
|
|
44
|
+
- **Still needs review** — prompt/workflow suggestions in `suggestions.md`
|
|
45
|
+
|
|
46
|
+
If memory entries were written, tell the user:
|
|
47
|
+
> Memory entries have been added to `.planning/memory/`. They will be loaded on the next agent run, reducing future memory misses for these topics.
|
|
48
|
+
|
|
49
|
+
### Step 4 — Point to manual review items
|
|
50
|
+
|
|
51
|
+
If `.planning/optimization/suggestions.md` exists, tell the user to review it for:
|
|
52
|
+
- Agent prompt improvements (apply by editing `agents/pan-*.md`)
|
|
53
|
+
- Workflow step additions (apply by editing `pan-wizard-core/workflows/*.md`)
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## trace init
|
|
58
|
+
|
|
59
|
+
### Step 1 — Extract description
|
|
60
|
+
|
|
61
|
+
If `--description "..."` was provided, extract it from the args.
|
|
62
|
+
|
|
63
|
+
### Step 2 — Initialize session
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init [--description "..."]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Show the user the session ID and confirm that:
|
|
70
|
+
- The hook will automatically log agent completions to this session
|
|
71
|
+
- To log a specific decision/error manually: `pan-tools optimize trace log --type <type> --description "..."`
|
|
72
|
+
- To end the session explicitly: `/pan:optimize trace end`
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## trace end
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Show: session ID, event count, agent count, type breakdown.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## trace status
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize trace current
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If active: show session ID and instruct how to view events.
|
|
93
|
+
If none: tell user to run `/pan:optimize trace init` before their next build.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## stats
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
node .claude/pan-wizard-core/bin/pan-tools.cjs optimize stats
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Present as a summary table:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Trace sessions: N
|
|
107
|
+
Optimization reports: N
|
|
108
|
+
Total events traced: N
|
|
109
|
+
Total errors traced: N
|
|
110
|
+
Optimizations applied: N
|
|
111
|
+
Active session: sess_... (or none)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If `total_optimizations_applied` > 0, note:
|
|
115
|
+
> {N} optimizations have been applied across {apply_runs} apply runs. Each applied memory entry reduces future knowledge gaps.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## The circular optimization loop explained
|
|
120
|
+
|
|
121
|
+
When explaining the system to users:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Every agent spawn → hook logs completion event
|
|
125
|
+
↓
|
|
126
|
+
.planning/optimization/traces/{session}/trace.jsonl
|
|
127
|
+
↓
|
|
128
|
+
/pan:learn → pan-optimizer reads trace
|
|
129
|
+
↓
|
|
130
|
+
.planning/optimization/reports/{session}-opt-report.md
|
|
131
|
+
↓
|
|
132
|
+
/pan:optimize apply → writes memory entries
|
|
133
|
+
↓
|
|
134
|
+
Next build has better context → fewer errors/gaps
|
|
135
|
+
↓
|
|
136
|
+
(repeat, improving each time)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The key insight: each apply run populates `.planning/memory/` with cached knowledge. Future agent runs load this memory and skip the research/inference that caused gaps. The error rate trends down. The optimization score trends up.
|
|
@@ -24,6 +24,13 @@ Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_
|
|
|
24
24
|
|
|
25
25
|
**If `planning_exists` is false:** Error — run `/pan:new-project` first.
|
|
26
26
|
|
|
27
|
+
**Circular optimization — ensure trace session active:**
|
|
28
|
+
```bash
|
|
29
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init \
|
|
30
|
+
--description "plan-phase ${PHASE}" \
|
|
31
|
+
--command "plan-phase" --phase "${PHASE}" 2>/dev/null || true
|
|
32
|
+
```
|
|
33
|
+
|
|
27
34
|
## 2. Parse and Normalize Arguments
|
|
28
35
|
|
|
29
36
|
Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--prd <filepath>`).
|
|
@@ -231,7 +238,7 @@ grep -l "## Validation Architecture" "${PHASE_DIR}"/*-research.md 2>/dev/null
|
|
|
231
238
|
|
|
232
239
|
**If found:**
|
|
233
240
|
1. Read validation template from `~/.claude/pan-wizard-core/templates/validation.md`
|
|
234
|
-
2. Write to `${PHASE_DIR}/${PADDED_PHASE}-
|
|
241
|
+
2. Write to `${PHASE_DIR}/${PADDED_PHASE}-validation.md`
|
|
235
242
|
3. Fill frontmatter: replace `{N}` with phase number, `{phase-slug}` with phase slug, `{date}` with current date
|
|
236
243
|
4. If `commit_docs` is true:
|
|
237
244
|
```bash
|
|
@@ -383,7 +390,19 @@ Task(
|
|
|
383
390
|
## 11. Handle Checker Return
|
|
384
391
|
|
|
385
392
|
- **`## VERIFICATION PASSED`:** Display confirmation, proceed to step 13.
|
|
393
|
+
```bash
|
|
394
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
395
|
+
--type decision --category plan_verified \
|
|
396
|
+
--description "Plan-checker passed for phase ${PHASE_NUMBER}" \
|
|
397
|
+
--agent pan-plan-checker --impact trivial 2>/dev/null || true
|
|
398
|
+
```
|
|
386
399
|
- **`## ISSUES FOUND`:** Display issues, check iteration count, proceed to step 12.
|
|
400
|
+
```bash
|
|
401
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
402
|
+
--type error --category plan_checker_issues \
|
|
403
|
+
--description "Plan-checker found issues in phase ${PHASE_NUMBER} plans" \
|
|
404
|
+
--agent pan-plan-checker --impact minor 2>/dev/null || true
|
|
405
|
+
```
|
|
387
406
|
|
|
388
407
|
## 12. Revision Loop (Max 3 Iterations)
|
|
389
408
|
|
|
@@ -436,6 +455,14 @@ Offer: 1) Force proceed, 2) Provide guidance and retry, 3) Abandon
|
|
|
436
455
|
|
|
437
456
|
Route to `<offer_next>` OR `auto_advance` depending on flags/config.
|
|
438
457
|
|
|
458
|
+
**Circular optimization — log plan creation:**
|
|
459
|
+
```bash
|
|
460
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
461
|
+
--type decision --category plans_created \
|
|
462
|
+
--description "Plan-phase complete for phase ${PHASE_NUMBER}: ${PLAN_COUNT} plans created" \
|
|
463
|
+
--agent pan-planner --impact minor 2>/dev/null || true
|
|
464
|
+
```
|
|
465
|
+
|
|
439
466
|
## 14. Auto-Advance Check
|
|
440
467
|
|
|
441
468
|
Check for auto-advance trigger:
|
|
@@ -52,6 +52,13 @@ Parse JSON for: `planner_model`, `executor_model`, `checker_model`, `verifier_mo
|
|
|
52
52
|
|
|
53
53
|
Quick tasks can run mid-phase - validation only checks roadmap.md exists, not phase status.
|
|
54
54
|
|
|
55
|
+
**Circular optimization — ensure trace session active:**
|
|
56
|
+
```bash
|
|
57
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace init \
|
|
58
|
+
--description "quick: ${DESCRIPTION}" \
|
|
59
|
+
--command "quick" 2>/dev/null || true
|
|
60
|
+
```
|
|
61
|
+
|
|
55
62
|
---
|
|
56
63
|
|
|
57
64
|
**Step 3: Create task directory**
|
|
@@ -282,6 +282,22 @@ If gaps_found: list gaps + recommended fix plan names.
|
|
|
282
282
|
If human_needed: list items requiring human testing.
|
|
283
283
|
|
|
284
284
|
Orchestrator routes: `passed` → update_roadmap | `gaps_found` → create/execute fixes, re-verify | `human_needed` → present to user.
|
|
285
|
+
|
|
286
|
+
**Circular optimization — log verification outcome:**
|
|
287
|
+
```bash
|
|
288
|
+
# Map status to impact and event type
|
|
289
|
+
if [ "${STATUS}" = "passed" ]; then
|
|
290
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
291
|
+
--type decision --category verification_passed \
|
|
292
|
+
--description "Phase ${PHASE_NUMBER} verification passed (score: ${SCORE})" \
|
|
293
|
+
--agent pan-verifier --impact minor 2>/dev/null || true
|
|
294
|
+
elif [ "${STATUS}" = "gaps_found" ]; then
|
|
295
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace log \
|
|
296
|
+
--type error --category verification_gaps \
|
|
297
|
+
--description "Phase ${PHASE_NUMBER} verification found gaps (score: ${SCORE})" \
|
|
298
|
+
--agent pan-verifier --impact major 2>/dev/null || true
|
|
299
|
+
fi
|
|
300
|
+
```
|
|
285
301
|
</step>
|
|
286
302
|
|
|
287
303
|
</process>
|
package/scripts/build-hooks.js
CHANGED
|
@@ -13,7 +13,9 @@ const DIST_DIR = path.join(HOOKS_DIR, 'dist');
|
|
|
13
13
|
const HOOKS_TO_COPY = [
|
|
14
14
|
'pan-check-update.js',
|
|
15
15
|
'pan-context-monitor.js',
|
|
16
|
-
'pan-statusline.js'
|
|
16
|
+
'pan-statusline.js',
|
|
17
|
+
'pan-cost-logger.js',
|
|
18
|
+
'pan-trace-logger.js'
|
|
17
19
|
];
|
|
18
20
|
|
|
19
21
|
function build() {
|