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
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pan:git
|
|
3
|
+
group: Git Workflow
|
|
4
|
+
description: Safe, phase-aware git workflow commands — commit, branch, push, status, log, stash, diff, rollback, tag, sync
|
|
5
|
+
argument-hint: "<subcommand> [options]"
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Edit
|
|
10
|
+
- Glob
|
|
11
|
+
- Grep
|
|
12
|
+
- Bash
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Phase-aware git workflow with safety guardrails built in. Every subcommand that modifies history runs safety checks. Rollback uses PAN snapshot tags created by exec-phase.
|
|
17
|
+
|
|
18
|
+
Works with any git repository — PAN installation not required.
|
|
19
|
+
</objective>
|
|
20
|
+
|
|
21
|
+
<subcommands>
|
|
22
|
+
|
|
23
|
+
## Subcommands
|
|
24
|
+
|
|
25
|
+
| Subcommand | Usage | What it does |
|
|
26
|
+
|------------|-------|--------------|
|
|
27
|
+
| `commit` | `git commit --type feat --message "add X"` | Safe commit: checks deleted files + secrets, conventional type prefix |
|
|
28
|
+
| `branch` | `git branch create --phase 3` | Create / switch / list / delete branches; phase-aware naming |
|
|
29
|
+
| `push` | `git push [--remote origin] [--branch main]` | Push with remote validation; requires `--force` for force-push |
|
|
30
|
+
| `status` | `git status` | Branch + staged/unstaged/untracked counts |
|
|
31
|
+
| `log` | `git log [--count 20]` | Formatted history, default 10 entries |
|
|
32
|
+
| `stash` | `git stash save --name "WIP auth"` | Named stash save / pop / list / drop |
|
|
33
|
+
| `diff` | `git diff [--staged] [--file path]` | Diff with line counts |
|
|
34
|
+
| `rollback` | `git rollback [--tag pan-rollback-X] [--dry-run]` | Reset to PAN snapshot tag |
|
|
35
|
+
| `tag` | `git tag list [--pattern v*]` | List / create / delete tags |
|
|
36
|
+
| `sync` | `git sync [--rebase]` | Fetch + pull from origin |
|
|
37
|
+
|
|
38
|
+
</subcommands>
|
|
39
|
+
|
|
40
|
+
<workflow>
|
|
41
|
+
|
|
42
|
+
## Execution
|
|
43
|
+
|
|
44
|
+
Run the appropriate subcommand via pan-tools:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git <subcommand> [opts]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or invoke directly in conversation: `/pan:git <subcommand> [opts]`
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### commit — Safe Commit
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git commit \
|
|
58
|
+
--type feat --message "implement user auth"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Options:**
|
|
62
|
+
- `--type` — `feat | fix | docs | test | refactor | chore`
|
|
63
|
+
- `--message` — Commit message body
|
|
64
|
+
- `--all` — Stage all changes before committing
|
|
65
|
+
- `--files f1 f2` — Stage specific files
|
|
66
|
+
- `--amend` — Amend last commit (no message needed)
|
|
67
|
+
- `--force` — Bypass deleted-file and sensitive-file blocks
|
|
68
|
+
|
|
69
|
+
**Safety checks run automatically:**
|
|
70
|
+
|
|
71
|
+
| Check | Blocks on | Override |
|
|
72
|
+
|-------|-----------|---------|
|
|
73
|
+
| Deleted files | Staged deletions found | `--force` |
|
|
74
|
+
| Sensitive files | `.env`, `.pem`, `.key`, `secret`, `password`, `token` | `--force` |
|
|
75
|
+
|
|
76
|
+
**Output:** `{committed, hash, type, safety_checks}`
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### branch — Branch Management
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Phase-aware branch (names as pan/phase-3)
|
|
84
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch create --phase 3
|
|
85
|
+
|
|
86
|
+
# Custom name
|
|
87
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch create --name feature/auth
|
|
88
|
+
|
|
89
|
+
# Switch
|
|
90
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch switch --name main
|
|
91
|
+
|
|
92
|
+
# List all branches
|
|
93
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch list
|
|
94
|
+
|
|
95
|
+
# Delete (safe — merged only)
|
|
96
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch delete --name feature/old
|
|
97
|
+
|
|
98
|
+
# Delete unmerged (force)
|
|
99
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch delete --name feature/old --force
|
|
100
|
+
|
|
101
|
+
# Current branch
|
|
102
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git branch current
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Phase naming convention:** `pan/phase-{N}` — matches `phase_branch_template` in `.planning/config.json`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### push — Safe Push
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git push
|
|
113
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git push --remote upstream --branch main
|
|
114
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git push --force # requires explicit flag
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Output:** `{pushed, remote, branch, force}`
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### status — Phase-Aware Status
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git status
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Output:** `{branch, clean, staged_count, unstaged_count, untracked_count, files}`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### log — Commit History
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git log --count 20
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Output:** `{commits: [{hash, message}], total}`
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### stash — Named Stash
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Save
|
|
145
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git stash save --name "WIP: auth refactor"
|
|
146
|
+
|
|
147
|
+
# List all stashes
|
|
148
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git stash list
|
|
149
|
+
|
|
150
|
+
# Pop latest
|
|
151
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git stash pop
|
|
152
|
+
|
|
153
|
+
# Pop by index
|
|
154
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git stash pop --index 1
|
|
155
|
+
|
|
156
|
+
# Drop
|
|
157
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git stash drop --index 0
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### diff — Staged/Unstaged Diff
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git diff
|
|
166
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git diff --staged
|
|
167
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git diff --staged --file src/api.js
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Output:** `{diff, lines_added, lines_removed, files_changed}`
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### rollback — Revert to PAN Snapshot
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Rollback to latest PAN snapshot tag (requires clean working tree)
|
|
178
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback
|
|
179
|
+
|
|
180
|
+
# Preview — does NOT reset, shows what would happen
|
|
181
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback --dry-run
|
|
182
|
+
|
|
183
|
+
# Rollback to specific tag
|
|
184
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git rollback --tag pan-rollback-03-1714000000
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Rollback workflow:**
|
|
188
|
+
1. Lists all `pan-rollback-*` tags (created by exec-phase before wave execution)
|
|
189
|
+
2. Verifies working tree is clean (blocks on dirty tree unless `--dry-run`)
|
|
190
|
+
3. Runs `git reset --hard <tag>`
|
|
191
|
+
|
|
192
|
+
**Output:** `{rolled_back, tag, hash, dry_run}`
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### tag — Tag Management
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git tag list
|
|
200
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git tag list --pattern "v*"
|
|
201
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git tag create --name v3.6.0 --message "Release 3.6.0"
|
|
202
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git tag delete --name v3.6.0-rc1
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Output:** `{tags, count}` / `{created, tag}` / `{deleted, tag}`
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### sync — Pull from Upstream
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git sync
|
|
213
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git sync --rebase
|
|
214
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs git sync --remote upstream --branch main
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Output:** `{synced, remote, branch, rebase, commits_received}`
|
|
218
|
+
|
|
219
|
+
</workflow>
|
|
220
|
+
|
|
221
|
+
<runtime_note>
|
|
222
|
+
All subcommands work with any git repository regardless of whether PAN is installed or `.planning/` exists. The only requirement is a valid git repo (`git init` or cloned).
|
|
223
|
+
</runtime_note>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pan:knowledge
|
|
3
|
+
group: Knowledge
|
|
4
|
+
description: Grounded Q&A, multi-turn design discussion, and playbook generation. Three modes in one command.
|
|
5
|
+
argument-hint: "ask <question> | discuss <phase> <topic> | playbook"
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Bash
|
|
10
|
+
- Grep
|
|
11
|
+
- Glob
|
|
12
|
+
- Task
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Retrieve, refine, or consolidate project knowledge. Three modes:
|
|
17
|
+
|
|
18
|
+
- **ask** — answer a natural-language question with inline citations grounded in `.planning/` + `docs/`.
|
|
19
|
+
- **discuss** — multi-turn refinement of a phase's context. Session state persists across invocations; prompt caching keeps turn 3 cheap.
|
|
20
|
+
- **playbook** — aggregate all agents' memory (E-4 layer) into `.planning/playbook.md`, organized by category (Conventions / Gotchas / Decisions / Tool choices / Anti-patterns / Recurring gaps).
|
|
21
|
+
|
|
22
|
+
Consolidates Spec B v1's X-3 converse + X-6 teach + X-10 explain into one command.
|
|
23
|
+
</objective>
|
|
24
|
+
|
|
25
|
+
<execution_context>
|
|
26
|
+
@~/.claude/pan-wizard-core/bin/lib/knowledge.cjs
|
|
27
|
+
@~/.claude/agents/pan-knowledge.md
|
|
28
|
+
@~/.claude/pan-wizard-core/templates/playbook.md
|
|
29
|
+
</execution_context>
|
|
30
|
+
|
|
31
|
+
<modes>
|
|
32
|
+
|
|
33
|
+
### `ask <question>`
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
/pan:knowledge ask "why does phase 4 have a race condition fix?"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Flow:**
|
|
40
|
+
1. `pan-tools knowledge ask "<question>"` returns a ranked list of candidate files.
|
|
41
|
+
2. Spawn `pan-knowledge` with `<mode>ask</mode>`, the question, and the top sources as `<files_to_read>`.
|
|
42
|
+
3. Agent reads sources, answers with citations, returns the answer to stdout. No file is written.
|
|
43
|
+
|
|
44
|
+
**Output:** inline markdown answer with `[file.md:LINE]` and `[ADR-NNNN]` citations.
|
|
45
|
+
|
|
46
|
+
### `discuss <phase> <topic-or-question>`
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
/pan:knowledge discuss 12 "should we use Redis or Memcached?"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Flow:**
|
|
53
|
+
1. `pan-tools knowledge discuss <phase> --subcmd read` loads session state from `.planning/conversations/<phase>/session.json` (empty for new phase).
|
|
54
|
+
2. `pan-tools knowledge discuss <phase> --subcmd append --role user --content "<topic>"` persists the user turn.
|
|
55
|
+
3. Spawn `pan-knowledge` with `<mode>discuss</mode>`, session history, phase context, and the new turn.
|
|
56
|
+
4. Agent responds.
|
|
57
|
+
5. `pan-tools knowledge discuss <phase> --subcmd append --role agent --content "<response>" --cites "a.md,b.md"` persists the response.
|
|
58
|
+
6. If after ≥3 substantive turns the agent offered to emit `context.md`, user can follow up with another `/pan:knowledge discuss <phase>` invocation or run the commit subcommand the agent suggested.
|
|
59
|
+
|
|
60
|
+
**Session persistence:** `.planning/conversations/<phase>/session.json` — array of turns with ts/role/content/cites. Multi-turn cost is dominated by cache hits on stable `.planning/` files.
|
|
61
|
+
|
|
62
|
+
### `playbook`
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
/pan:knowledge playbook
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Flow:**
|
|
69
|
+
1. `pan-tools knowledge playbook` reads all agents' memory (`.planning/memory/*.md`), clusters entries by category, writes `.planning/playbook.md` directly.
|
|
70
|
+
2. Optionally spawn `pan-knowledge` with `<mode>playbook</mode>` to polish (dedupe contradictions, consolidate similar entries). Skip the polish step if the draft looks clean.
|
|
71
|
+
|
|
72
|
+
**Output:** `.planning/playbook.md` — team-readable summary of accumulated lessons.
|
|
73
|
+
|
|
74
|
+
**Auto-invocation:** `/pan:milestone-done` can optionally run this (flag-gated, not default). Manual invocation any time.
|
|
75
|
+
|
|
76
|
+
</modes>
|
|
77
|
+
|
|
78
|
+
<workflow>
|
|
79
|
+
|
|
80
|
+
**Onboarding a new team member:** have them run `/pan:knowledge playbook` then `/pan:knowledge ask "what conventions matter in this codebase?"`.
|
|
81
|
+
|
|
82
|
+
**Design debate:** run `/pan:knowledge discuss <phase> "<question>"` iteratively. The agent refines as the debate narrows. After convergence, accept the proposed `context.md` update.
|
|
83
|
+
|
|
84
|
+
**Bug investigation:** `/pan:knowledge ask "why did we add the retry in phase 4?"` — faster than grepping for historical context.
|
|
85
|
+
|
|
86
|
+
**Before milestone-done:** run `/pan:knowledge playbook` to capture what the team learned. Gives contributors something to reference when starting the next milestone.
|
|
87
|
+
|
|
88
|
+
</workflow>
|
|
89
|
+
|
|
90
|
+
<citation_format>
|
|
91
|
+
|
|
92
|
+
Agent output uses bracketed citations that link to files. Supported forms:
|
|
93
|
+
|
|
94
|
+
| Form | Example | Renders as |
|
|
95
|
+
|------|---------|-----------|
|
|
96
|
+
| Plain file | `[README.md]` | markdown link to the file |
|
|
97
|
+
| File + line | `[docs/ARCHITECTURE.md:200]` | link to line 200 |
|
|
98
|
+
| ADR | `[ADR-0015]` | link to ADR file |
|
|
99
|
+
| Phase artifact | `[phase-4/summary.md]` | link to phase summary |
|
|
100
|
+
|
|
101
|
+
The agent should NEVER fabricate citations. The retrieval layer's `sources` list is the allowlist.
|
|
102
|
+
|
|
103
|
+
</citation_format>
|
|
104
|
+
|
|
105
|
+
<runtime_compatibility>
|
|
106
|
+
|
|
107
|
+
| Runtime | ask | discuss | playbook |
|
|
108
|
+
|---------|-----|---------|----------|
|
|
109
|
+
| Claude Code | Full, thinking enabled | Full, prompt caching bonus | Full |
|
|
110
|
+
| OpenCode | Full | Full (no cache bonus) | Full |
|
|
111
|
+
| Gemini | Full | Full | Full |
|
|
112
|
+
| Codex | Full | Full | Full |
|
|
113
|
+
| Copilot | Full | Full | Full |
|
|
114
|
+
|
|
115
|
+
The data layer (retrieval, session state, playbook clustering) is pure Node.js and runtime-agnostic. Only answer synthesis quality varies with model capability.
|
|
116
|
+
|
|
117
|
+
</runtime_compatibility>
|
|
118
|
+
|
|
119
|
+
<privacy_note>
|
|
120
|
+
|
|
121
|
+
`session.json` is persisted to disk and committed unless `.planning/conversations/` is gitignored. For sensitive design discussions, consider:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
echo '.planning/conversations/' >> .gitignore
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
before starting a `discuss` session. Session turns are not auto-encrypted.
|
|
128
|
+
|
|
129
|
+
</privacy_note>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# /pan:learn
|
|
2
|
+
|
|
3
|
+
Analyze the most recent trace session and generate an optimization report.
|
|
4
|
+
|
|
5
|
+
**Usage:**
|
|
6
|
+
```
|
|
7
|
+
/pan:learn
|
|
8
|
+
/pan:learn --session <session-id>
|
|
9
|
+
/pan:learn --apply
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**Flags:**
|
|
13
|
+
- `--session <id>` — analyze a specific session instead of the most recent
|
|
14
|
+
- `--apply` — automatically apply safe optimizations after generating the report (equivalent to running `/pan:optimize apply` immediately after)
|
|
15
|
+
|
|
16
|
+
**What it does:**
|
|
17
|
+
|
|
18
|
+
1. Reads trace events from `.planning/optimization/traces/{session}/trace.jsonl`
|
|
19
|
+
2. Performs local analysis (error/gap/redundancy patterns, agent stats)
|
|
20
|
+
3. Writes `.planning/optimization/reports/{session}-analysis.json`
|
|
21
|
+
4. Invokes `pan-optimizer` agent to produce `.planning/optimization/reports/{session}-opt-report.md`
|
|
22
|
+
5. If `--apply` flag: immediately runs `/pan:optimize apply` on the new report
|
|
23
|
+
6. Prints the optimization summary
|
|
24
|
+
|
|
25
|
+
**When to run:**
|
|
26
|
+
- After any `/pan:exec-phase` or `/pan:focus-exec` that had a trace session active
|
|
27
|
+
- After a full build cycle to capture all decisions and errors
|
|
28
|
+
- On demand to understand what PAN did and how to make it smarter
|
|
29
|
+
|
|
30
|
+
**What it learns from:**
|
|
31
|
+
- Tool failures and correction loops (error events)
|
|
32
|
+
- Topics the model had to infer without context (gap events)
|
|
33
|
+
- Repeated research on the same topic (redundancy events)
|
|
34
|
+
- Memory cache misses (memory_miss events)
|
|
35
|
+
- Unexpected outcomes (surprise events)
|
|
36
|
+
|
|
37
|
+
**Output:**
|
|
38
|
+
|
|
39
|
+
The optimization report in `.planning/optimization/reports/` contains:
|
|
40
|
+
- Ranked error patterns with fix recommendations
|
|
41
|
+
- Memory gap findings with ready-to-apply memory entry content
|
|
42
|
+
- Redundancy analysis with token waste estimates
|
|
43
|
+
- Prompt improvement suggestions (require human review before applying)
|
|
44
|
+
- Workflow gap suggestions (require human review)
|
|
45
|
+
- An `## Auto-Apply Actions` JSON block for `/pan:optimize apply`
|
|
46
|
+
- A circular optimization score (0–100)
|
|
47
|
+
|
|
48
|
+
**Example:**
|
|
49
|
+
```
|
|
50
|
+
/pan:learn
|
|
51
|
+
→ Session sess_20260421T180000: 47 events (8 errors, 12 gaps, 3 redundancies)
|
|
52
|
+
→ Report: .planning/optimization/reports/sess_20260421T180000-opt-report.md
|
|
53
|
+
→ Optimization score: 72/100
|
|
54
|
+
→ Top finding: M1 — Express middleware order missing from memory (5 misses)
|
|
55
|
+
→ Auto-applicable: 3 memory entries
|
|
56
|
+
→ Needs review: 2 prompt improvements, 1 workflow gap
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**See also:** `/pan:optimize`, `/pan:exec-phase`
|
|
60
|
+
|
|
61
|
+
Follow the workflow at `.claude/workflows/learn.md` (or `pan-wizard-core/workflows/learn.md`).
|
|
@@ -49,6 +49,21 @@ 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
|
+
<stage_0_ingest_mode>
|
|
53
|
+
**Before spawning mapper agents**, determine whether the repo fits in a single 1M-context window.
|
|
54
|
+
|
|
55
|
+
Run: `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs codebase estimate-size --threshold 700000`
|
|
56
|
+
|
|
57
|
+
The CLI returns `{mode, total_tokens, file_count, languages}`:
|
|
58
|
+
|
|
59
|
+
- **`mode: "single-shot"`** — repo is small enough (≤700K tokens) for one Opus 4.7 agent to ingest the whole thing. Spawn a single `pan-document_code` agent with the full repo in context. This avoids the 6-way stitching artifacts of sharded mode (contradictory version claims, duplicated mentions, missed cross-file references).
|
|
60
|
+
- **`mode: "sharded"`** — repo exceeds 700K tokens. Fall back to the default 6-way parallel sharding (tech, arch, quality, concerns, relationships, practices). Each shard gets a 200K budget.
|
|
61
|
+
|
|
62
|
+
Record the chosen mode + telemetry in the final `.planning/codebase/overview.md` so future runs can reason about drift.
|
|
63
|
+
|
|
64
|
+
Opus 4.7 is required for single-shot mode (only model with a 1M context window). Other models always take the sharded path regardless of size.
|
|
65
|
+
</stage_0_ingest_mode>
|
|
66
|
+
|
|
52
67
|
<tool_priority>
|
|
53
68
|
Each mapper agent should use the simplest sufficient tool:
|
|
54
69
|
1. Glob — discover files by pattern (find all .ts files, config files, test files)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pan:mcp-bridge
|
|
3
|
+
group: External tools
|
|
4
|
+
description: Discover available MCP tools and recommend which ones apply to a phase. Discovery-only; auto-invocation deferred.
|
|
5
|
+
argument-hint: "list | recommend <phase> | cache [--servers <json>] [--runtime <name>]"
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Bash
|
|
9
|
+
- Write
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<objective>
|
|
13
|
+
Surface Model Context Protocol (MCP) tools visible to the host runtime and recommend which ones might apply to a specific phase plan.
|
|
14
|
+
|
|
15
|
+
Reduced scope from Spec B v1's X-7: **discovery and recommendation only**. Auto-injection of MCP tools into planner context and auto-invocation from executor agents are deliberately deferred (likely Wave 5+ or v3.5). This keeps v3.3 narrow and avoids coupling PAN to Claude Code's MCP schema stability.
|
|
16
|
+
</objective>
|
|
17
|
+
|
|
18
|
+
<execution_context>
|
|
19
|
+
@~/.claude/pan-wizard-core/bin/lib/bridge.cjs
|
|
20
|
+
</execution_context>
|
|
21
|
+
|
|
22
|
+
<subcommands>
|
|
23
|
+
|
|
24
|
+
### `list`
|
|
25
|
+
|
|
26
|
+
Show cached MCP tools with server grouping and schemas.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
/pan:mcp-bridge list
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Output (JSON):**
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"cached_at": "2026-04-18T12:34:56Z",
|
|
36
|
+
"runtime": "claude",
|
|
37
|
+
"server_count": 3,
|
|
38
|
+
"tool_count": 12,
|
|
39
|
+
"tools": [
|
|
40
|
+
{ "server": "linear", "name": "linear.updateTicket", "description": "...", "schema": {...} },
|
|
41
|
+
...
|
|
42
|
+
],
|
|
43
|
+
"source": "cache" | "empty"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
When `source: "empty"`, either no MCP servers are configured or the host runtime hasn't populated the cache yet. See the `cache` subcommand for manual seeding.
|
|
48
|
+
|
|
49
|
+
### `recommend <phase>`
|
|
50
|
+
|
|
51
|
+
Given a phase number, match cached MCP tools against the phase's plan text and return tools ranked by keyword relevance.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
/pan:mcp-bridge recommend 7
|
|
55
|
+
/pan:mcp-bridge recommend 12 --max 5 --min-score 2
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Flags:**
|
|
59
|
+
- `--max N` — cap recommendations (default 10)
|
|
60
|
+
- `--min-score N` — minimum keyword hit count (default 1)
|
|
61
|
+
|
|
62
|
+
**Output (JSON):**
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"phase": "7",
|
|
66
|
+
"phase_name": "API refactor",
|
|
67
|
+
"runtime": "claude",
|
|
68
|
+
"total_candidates": 12,
|
|
69
|
+
"recommendations": [
|
|
70
|
+
{
|
|
71
|
+
"server": "linear",
|
|
72
|
+
"name": "linear.updateTicket",
|
|
73
|
+
"description": "Update a Linear issue",
|
|
74
|
+
"score": 3,
|
|
75
|
+
"hits": ["linear", "ticket", "update"]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Scoring is naive keyword frequency with word boundaries — not semantic embeddings. A tool's name and description are tokenized into keywords (≥3 chars); each match in the phase plan text scores 1 point.
|
|
82
|
+
|
|
83
|
+
### `cache`
|
|
84
|
+
|
|
85
|
+
Write or inspect the MCP tools cache at `.planning/bridge/available-tools.json`.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
# Inspect current cache (same as `list` but raw)
|
|
89
|
+
/pan:mcp-bridge cache
|
|
90
|
+
|
|
91
|
+
# Seed cache from scripted discovery (for testing or external pipeline)
|
|
92
|
+
/pan:mcp-bridge cache --runtime claude --servers '[{"name":"linear","tools":[{"name":"linear.updateTicket","description":"Update ticket"}]}]'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Normally the host runtime writes this file. The CLI path exists for test fixtures and external-script integration.
|
|
96
|
+
|
|
97
|
+
</subcommands>
|
|
98
|
+
|
|
99
|
+
<workflow>
|
|
100
|
+
|
|
101
|
+
**New to a project with MCP tools?** Run `/pan:mcp-bridge list` to see what's available. If empty, check the host runtime's MCP config — `.claude/settings.json` for Claude Code, or the runtime's equivalent.
|
|
102
|
+
|
|
103
|
+
**Planning a phase that might touch external systems?** Run `/pan:mcp-bridge recommend <phase>` to get a ranked shortlist. Copy relevant tool names into the phase plan's "External tools" section so the executor knows to invoke them.
|
|
104
|
+
|
|
105
|
+
**Pre-milestone review:** walk through each remaining phase with `/pan:mcp-bridge recommend` to catch "we should have automated this via Linear/Slack/etc." realizations before shipping.
|
|
106
|
+
|
|
107
|
+
</workflow>
|
|
108
|
+
|
|
109
|
+
<caveats>
|
|
110
|
+
|
|
111
|
+
**Discovery is a cache, not a live probe.** The host runtime owns populating `.planning/bridge/available-tools.json`. PAN does not query MCP servers directly — that would require runtime-specific HTTP or IPC integration this command deliberately avoids.
|
|
112
|
+
|
|
113
|
+
**Keyword scoring is crude.** "Postgres" and "PostgreSQL" are different tokens; `postgresql` in a plan won't match a `postgres.query` tool unless the plan also says "postgres." Tune your plan language or expand tool descriptions to improve matches.
|
|
114
|
+
|
|
115
|
+
**Claude Code is the primary target.** MCP is a Claude-first protocol. Other runtimes may have their own tool-discovery mechanisms; the cache schema is intentionally generic so a future Codex/Gemini equivalent could populate the same file.
|
|
116
|
+
|
|
117
|
+
**No automatic invocation.** This command never calls MCP tools. It tells you what's available and what might apply. The actual invocation happens via the host runtime's normal tool-use flow (Claude Code's tool calls, etc.) when the executor agent decides to use a recommended tool.
|
|
118
|
+
|
|
119
|
+
</caveats>
|
|
120
|
+
|
|
121
|
+
<runtime_compatibility>
|
|
122
|
+
|
|
123
|
+
| Runtime | list | recommend | cache |
|
|
124
|
+
|---------|------|-----------|-------|
|
|
125
|
+
| Claude Code | Full | Full | Full (host-populated) |
|
|
126
|
+
| OpenCode | Stub (empty cache returns gracefully) | Stub | CLI write works |
|
|
127
|
+
| Gemini CLI | Stub | Stub | CLI write works |
|
|
128
|
+
| Codex CLI | Stub | Stub | CLI write works |
|
|
129
|
+
| Copilot CLI | Stub | Stub | CLI write works |
|
|
130
|
+
|
|
131
|
+
On non-Claude runtimes, the aggregator and recommendation logic still work — they just report zero tools until something populates the cache.
|
|
132
|
+
|
|
133
|
+
</runtime_compatibility>
|
|
134
|
+
|
|
135
|
+
<future_scope>
|
|
136
|
+
|
|
137
|
+
Explicitly deferred from v3.3 (documented in ADR-0023 / Spec B v2 notes):
|
|
138
|
+
|
|
139
|
+
1. **Auto-inject recommended tools into planner context** — requires a stable MCP schema contract and a plan-template extension. Candidate for v3.5.
|
|
140
|
+
2. **Auto-invoke MCP tools from executor agent** — requires permission-gating and per-tool safety review. Candidate for v3.5+.
|
|
141
|
+
3. **Cross-runtime tool discovery** — generic MCP-like protocol for non-Claude runtimes. No timeline; needs ecosystem signal.
|
|
142
|
+
|
|
143
|
+
Until those land, this command is the minimum viable integration: you see what's there, you get suggestions, you decide manually.
|
|
144
|
+
|
|
145
|
+
</future_scope>
|
|
@@ -111,6 +111,15 @@ Output: Milestone archived (roadmap + requirements), project.md evolved, git tag
|
|
|
111
111
|
8. **Offer next steps:**
|
|
112
112
|
- `/pan:milestone-new` — start next milestone (questioning → research → requirements → roadmap)
|
|
113
113
|
|
|
114
|
+
9. **Circular optimization — summarize what was learned this milestone:**
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize trace end 2>/dev/null || true
|
|
118
|
+
node ~/.claude/pan-wizard-core/bin/pan-tools.cjs optimize learn 2>/dev/null || true
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Present the optimization summary to the user and suggest `/pan:optimize apply` to write memory entries.
|
|
122
|
+
|
|
114
123
|
</process>
|
|
115
124
|
|
|
116
125
|
<success_criteria>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# /pan:optimize
|
|
2
|
+
|
|
3
|
+
Manage the circular optimization loop: apply recommendations, view stats, list reports.
|
|
4
|
+
|
|
5
|
+
**Usage:**
|
|
6
|
+
```
|
|
7
|
+
/pan:optimize apply
|
|
8
|
+
/pan:optimize apply --report <filename>
|
|
9
|
+
/pan:optimize list
|
|
10
|
+
/pan:optimize stats
|
|
11
|
+
/pan:optimize trace init [--description "what you're building"]
|
|
12
|
+
/pan:optimize trace end
|
|
13
|
+
/pan:optimize trace status
|
|
14
|
+
/pan:optimize trace list
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Subcommands:**
|
|
18
|
+
|
|
19
|
+
### apply
|
|
20
|
+
Apply safe optimizations from the most recent (or specified) optimization report.
|
|
21
|
+
|
|
22
|
+
Auto-applied automatically:
|
|
23
|
+
- New memory entries (`.planning/memory/*.md`) — skipped if file already exists
|
|
24
|
+
- Suggestions appended to `.planning/optimization/suggestions.md`
|
|
25
|
+
- Config notes appended to `.planning/optimization/config-suggestions.md`
|
|
26
|
+
|
|
27
|
+
Requires human review (never auto-applied):
|
|
28
|
+
- Agent prompt changes
|
|
29
|
+
- Workflow step additions
|
|
30
|
+
- Structural changes to commands
|
|
31
|
+
|
|
32
|
+
After applying, the report lists what was applied and what still needs review.
|
|
33
|
+
|
|
34
|
+
### list
|
|
35
|
+
List all optimization reports in `.planning/optimization/reports/`, most recent first.
|
|
36
|
+
|
|
37
|
+
### stats
|
|
38
|
+
Show cumulative optimization statistics:
|
|
39
|
+
- Total trace sessions run
|
|
40
|
+
- Total events traced
|
|
41
|
+
- Total errors/gaps/redundancies seen
|
|
42
|
+
- Total optimizations applied across all runs
|
|
43
|
+
- Current active trace session (if any)
|
|
44
|
+
|
|
45
|
+
### trace init
|
|
46
|
+
Start a new trace session before running a build. The hook fires automatically on SubagentStop, but calling `trace init` first lets you attach a description to the session.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
/pan:optimize trace init --description "building express web server"
|
|
50
|
+
/pan:exec-phase 1
|
|
51
|
+
/pan:learn
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### trace end
|
|
55
|
+
Finalize the current trace session (writes summary stats to session.json).
|
|
56
|
+
|
|
57
|
+
### trace status
|
|
58
|
+
Show the active trace session ID and event count.
|
|
59
|
+
|
|
60
|
+
### trace list
|
|
61
|
+
List all trace sessions, most recent first.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
**The circular loop:**
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
┌─────────────────────────────────────────────────────┐
|
|
69
|
+
│ │
|
|
70
|
+
│ /pan:optimize trace init │
|
|
71
|
+
│ ↓ │
|
|
72
|
+
│ /pan:exec-phase N ← agents run, hook traces │
|
|
73
|
+
│ ↓ │
|
|
74
|
+
│ /pan:learn ← analyze + report │
|
|
75
|
+
│ ↓ │
|
|
76
|
+
│ /pan:optimize apply ← write memory entries │
|
|
77
|
+
│ ↓ │
|
|
78
|
+
│ Next run is smarter ← memory populated │
|
|
79
|
+
│ ↑ │
|
|
80
|
+
│ └──────────────────────────────────────────┘
|
|
81
|
+
└─────────────────────────────────────────────────────┘
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Each iteration improves the model's context: fewer memory misses, fewer repeated errors, better decisions.
|
|
85
|
+
|
|
86
|
+
**See also:** `/pan:learn`, `/pan:exec-phase`
|