@sienklogic/plan-build-run 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +54 -20
  3. package/dashboard/src/services/dashboard.service.js +24 -1
  4. package/dashboard/src/services/milestone.service.js +68 -17
  5. package/package.json +1 -1
  6. package/plugins/copilot-pbr/CHANGELOG.md +19 -0
  7. package/plugins/copilot-pbr/README.md +129 -0
  8. package/plugins/copilot-pbr/agents/codebase-mapper.agent.md +109 -0
  9. package/plugins/copilot-pbr/agents/debugger.agent.md +169 -0
  10. package/plugins/copilot-pbr/agents/executor.agent.md +237 -0
  11. package/plugins/copilot-pbr/agents/general.agent.md +88 -0
  12. package/plugins/copilot-pbr/agents/integration-checker.agent.md +88 -0
  13. package/plugins/copilot-pbr/agents/plan-checker.agent.md +199 -0
  14. package/plugins/copilot-pbr/agents/planner.agent.md +181 -0
  15. package/plugins/copilot-pbr/agents/researcher.agent.md +163 -0
  16. package/plugins/copilot-pbr/agents/synthesizer.agent.md +102 -0
  17. package/plugins/copilot-pbr/agents/verifier.agent.md +194 -0
  18. package/plugins/copilot-pbr/hooks/hooks.json +144 -0
  19. package/plugins/copilot-pbr/plugin.json +30 -0
  20. package/plugins/copilot-pbr/references/agent-anti-patterns.md +25 -0
  21. package/plugins/copilot-pbr/references/agent-interactions.md +135 -0
  22. package/plugins/copilot-pbr/references/agent-teams.md +55 -0
  23. package/plugins/copilot-pbr/references/checkpoints.md +158 -0
  24. package/plugins/copilot-pbr/references/common-bug-patterns.md +14 -0
  25. package/plugins/copilot-pbr/references/config-reference.md +442 -0
  26. package/plugins/copilot-pbr/references/continuation-format.md +213 -0
  27. package/plugins/copilot-pbr/references/deviation-rules.md +113 -0
  28. package/plugins/copilot-pbr/references/git-integration.md +227 -0
  29. package/plugins/copilot-pbr/references/integration-patterns.md +118 -0
  30. package/plugins/copilot-pbr/references/model-profiles.md +100 -0
  31. package/plugins/copilot-pbr/references/model-selection.md +32 -0
  32. package/plugins/copilot-pbr/references/pbr-rules.md +194 -0
  33. package/plugins/copilot-pbr/references/plan-authoring.md +182 -0
  34. package/plugins/copilot-pbr/references/plan-format.md +288 -0
  35. package/plugins/copilot-pbr/references/planning-config.md +214 -0
  36. package/plugins/copilot-pbr/references/questioning.md +215 -0
  37. package/plugins/copilot-pbr/references/reading-verification.md +128 -0
  38. package/plugins/copilot-pbr/references/stub-patterns.md +161 -0
  39. package/plugins/copilot-pbr/references/subagent-coordination.md +120 -0
  40. package/plugins/copilot-pbr/references/ui-formatting.md +462 -0
  41. package/plugins/copilot-pbr/references/verification-patterns.md +199 -0
  42. package/plugins/copilot-pbr/references/wave-execution.md +96 -0
  43. package/plugins/copilot-pbr/rules/pbr-workflow.mdc +48 -0
  44. package/plugins/copilot-pbr/setup.ps1 +93 -0
  45. package/plugins/copilot-pbr/setup.sh +92 -0
  46. package/plugins/copilot-pbr/skills/begin/SKILL.md +566 -0
  47. package/plugins/copilot-pbr/skills/begin/templates/PROJECT.md.tmpl +34 -0
  48. package/plugins/copilot-pbr/skills/begin/templates/REQUIREMENTS.md.tmpl +19 -0
  49. package/plugins/copilot-pbr/skills/begin/templates/STATE.md.tmpl +50 -0
  50. package/plugins/copilot-pbr/skills/begin/templates/config.json.tmpl +64 -0
  51. package/plugins/copilot-pbr/skills/begin/templates/researcher-prompt.md.tmpl +20 -0
  52. package/plugins/copilot-pbr/skills/begin/templates/roadmap-prompt.md.tmpl +31 -0
  53. package/plugins/copilot-pbr/skills/begin/templates/synthesis-prompt.md.tmpl +17 -0
  54. package/plugins/copilot-pbr/skills/build/SKILL.md +901 -0
  55. package/plugins/copilot-pbr/skills/config/SKILL.md +253 -0
  56. package/plugins/copilot-pbr/skills/continue/SKILL.md +159 -0
  57. package/plugins/copilot-pbr/skills/dashboard/SKILL.md +31 -0
  58. package/plugins/copilot-pbr/skills/debug/SKILL.md +511 -0
  59. package/plugins/copilot-pbr/skills/debug/templates/continuation-prompt.md.tmpl +17 -0
  60. package/plugins/copilot-pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +28 -0
  61. package/plugins/copilot-pbr/skills/discuss/SKILL.md +343 -0
  62. package/plugins/copilot-pbr/skills/discuss/templates/CONTEXT.md.tmpl +62 -0
  63. package/plugins/copilot-pbr/skills/discuss/templates/decision-categories.md +10 -0
  64. package/plugins/copilot-pbr/skills/do/SKILL.md +66 -0
  65. package/plugins/copilot-pbr/skills/explore/SKILL.md +374 -0
  66. package/plugins/copilot-pbr/skills/health/SKILL.md +218 -0
  67. package/plugins/copilot-pbr/skills/health/templates/check-pattern.md.tmpl +31 -0
  68. package/plugins/copilot-pbr/skills/health/templates/output-format.md.tmpl +64 -0
  69. package/plugins/copilot-pbr/skills/help/SKILL.md +152 -0
  70. package/plugins/copilot-pbr/skills/import/SKILL.md +498 -0
  71. package/plugins/copilot-pbr/skills/milestone/SKILL.md +703 -0
  72. package/plugins/copilot-pbr/skills/milestone/templates/audit-report.md.tmpl +49 -0
  73. package/plugins/copilot-pbr/skills/milestone/templates/stats-file.md.tmpl +31 -0
  74. package/plugins/copilot-pbr/skills/note/SKILL.md +227 -0
  75. package/plugins/copilot-pbr/skills/pause/SKILL.md +246 -0
  76. package/plugins/copilot-pbr/skills/pause/templates/continue-here.md.tmpl +72 -0
  77. package/plugins/copilot-pbr/skills/plan/SKILL.md +649 -0
  78. package/plugins/copilot-pbr/skills/plan/templates/checker-prompt.md.tmpl +22 -0
  79. package/plugins/copilot-pbr/skills/plan/templates/gap-closure-prompt.md.tmpl +33 -0
  80. package/plugins/copilot-pbr/skills/plan/templates/planner-prompt.md.tmpl +39 -0
  81. package/plugins/copilot-pbr/skills/plan/templates/researcher-prompt.md.tmpl +20 -0
  82. package/plugins/copilot-pbr/skills/plan/templates/revision-prompt.md.tmpl +24 -0
  83. package/plugins/copilot-pbr/skills/quick/SKILL.md +351 -0
  84. package/plugins/copilot-pbr/skills/resume/SKILL.md +399 -0
  85. package/plugins/copilot-pbr/skills/review/SKILL.md +648 -0
  86. package/plugins/copilot-pbr/skills/review/templates/debugger-prompt.md.tmpl +61 -0
  87. package/plugins/copilot-pbr/skills/review/templates/gap-planner-prompt.md.tmpl +41 -0
  88. package/plugins/copilot-pbr/skills/review/templates/verifier-prompt.md.tmpl +116 -0
  89. package/plugins/copilot-pbr/skills/scan/SKILL.md +301 -0
  90. package/plugins/copilot-pbr/skills/scan/templates/mapper-prompt.md.tmpl +202 -0
  91. package/plugins/copilot-pbr/skills/setup/SKILL.md +250 -0
  92. package/plugins/copilot-pbr/skills/shared/commit-planning-docs.md +36 -0
  93. package/plugins/copilot-pbr/skills/shared/config-loading.md +103 -0
  94. package/plugins/copilot-pbr/skills/shared/context-budget.md +41 -0
  95. package/plugins/copilot-pbr/skills/shared/context-loader-task.md +87 -0
  96. package/plugins/copilot-pbr/skills/shared/digest-select.md +80 -0
  97. package/plugins/copilot-pbr/skills/shared/domain-probes.md +126 -0
  98. package/plugins/copilot-pbr/skills/shared/error-reporting.md +80 -0
  99. package/plugins/copilot-pbr/skills/shared/gate-prompts.md +389 -0
  100. package/plugins/copilot-pbr/skills/shared/phase-argument-parsing.md +46 -0
  101. package/plugins/copilot-pbr/skills/shared/progress-display.md +54 -0
  102. package/plugins/copilot-pbr/skills/shared/revision-loop.md +82 -0
  103. package/plugins/copilot-pbr/skills/shared/state-loading.md +63 -0
  104. package/plugins/copilot-pbr/skills/shared/state-update.md +162 -0
  105. package/plugins/copilot-pbr/skills/shared/universal-anti-patterns.md +34 -0
  106. package/plugins/copilot-pbr/skills/status/SKILL.md +362 -0
  107. package/plugins/copilot-pbr/skills/todo/SKILL.md +256 -0
  108. package/plugins/copilot-pbr/templates/CONTEXT.md.tmpl +53 -0
  109. package/plugins/copilot-pbr/templates/INTEGRATION-REPORT.md.tmpl +152 -0
  110. package/plugins/copilot-pbr/templates/RESEARCH-SUMMARY.md.tmpl +98 -0
  111. package/plugins/copilot-pbr/templates/ROADMAP.md.tmpl +41 -0
  112. package/plugins/copilot-pbr/templates/SUMMARY.md.tmpl +82 -0
  113. package/plugins/copilot-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  114. package/plugins/copilot-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  115. package/plugins/copilot-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  116. package/plugins/copilot-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  117. package/plugins/copilot-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  118. package/plugins/copilot-pbr/templates/codebase/STACK.md.tmpl +78 -0
  119. package/plugins/copilot-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  120. package/plugins/copilot-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  121. package/plugins/copilot-pbr/templates/continue-here.md.tmpl +74 -0
  122. package/plugins/copilot-pbr/templates/prompt-partials/phase-project-context.md.tmpl +38 -0
  123. package/plugins/copilot-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  124. package/plugins/copilot-pbr/templates/research/STACK.md.tmpl +71 -0
  125. package/plugins/copilot-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  126. package/plugins/copilot-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  127. package/plugins/copilot-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  128. package/plugins/copilot-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  129. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +13 -3
  130. package/plugins/cursor-pbr/skills/dashboard/SKILL.md +14 -4
  131. package/plugins/cursor-pbr/skills/do/SKILL.md +67 -0
  132. package/plugins/cursor-pbr/skills/milestone/SKILL.md +10 -7
  133. package/plugins/cursor-pbr/skills/todo/SKILL.md +28 -5
  134. package/plugins/cursor-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  135. package/plugins/cursor-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  136. package/plugins/cursor-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  137. package/plugins/cursor-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  138. package/plugins/cursor-pbr/templates/codebase/STACK.md.tmpl +78 -0
  139. package/plugins/cursor-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  140. package/plugins/cursor-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  141. package/plugins/cursor-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  142. package/plugins/cursor-pbr/templates/research/STACK.md.tmpl +71 -0
  143. package/plugins/cursor-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  144. package/plugins/cursor-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  145. package/plugins/cursor-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  146. package/plugins/cursor-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  147. package/plugins/pbr/.claude-plugin/plugin.json +7 -2
  148. package/plugins/pbr/scripts/validate-skill-args.js +54 -10
  149. package/plugins/pbr/skills/do/SKILL.md +70 -0
  150. package/plugins/pbr/skills/milestone/SKILL.md +10 -7
  151. package/plugins/pbr/skills/todo/SKILL.md +29 -6
@@ -0,0 +1,649 @@
1
+ ---
2
+ name: plan
3
+ description: "Create a detailed plan for a phase. Research, plan, and verify before building."
4
+ ---
5
+
6
+ # /pbr:plan — Phase Planning
7
+
8
+ You are the orchestrator for `/pbr:plan`. This skill creates detailed, executable plans for a specific phase. Plans are the bridge between the roadmap and actual code — they must be specific enough for an executor agent to follow mechanically. Your job is to stay lean, delegate heavy work to agents, and keep the user's main context window clean.
9
+
10
+ ## Context Budget
11
+
12
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
13
+
14
+ Additionally for this skill:
15
+ - **Minimize** reading agent output — read only plan frontmatter for summaries
16
+ - **Delegate** all research and planning work to agents — the orchestrator routes, it doesn't plan
17
+
18
+ ## Step 0 — Immediate Output
19
+
20
+ **Before ANY tool calls**, display this banner:
21
+
22
+ ```
23
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
24
+ PLAN-BUILD-RUN ► PLANNING PHASE {N}
25
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
26
+ ```
27
+
28
+ Where `{N}` is the phase number from `$ARGUMENTS`. Then proceed to Step 1.
29
+
30
+ ## Prerequisites
31
+
32
+ - `.planning/config.json` exists (run `/pbr:begin` first)
33
+ - `.planning/ROADMAP.md` exists with at least one phase
34
+ - `.planning/REQUIREMENTS.md` exists
35
+
36
+ ---
37
+
38
+ ## Argument Parsing
39
+
40
+ Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
41
+
42
+ ### Standard Invocation
43
+
44
+ `/pbr:plan <N>` — Plan phase N
45
+
46
+ Parse the phase number and optional flags:
47
+
48
+ | Argument | Meaning |
49
+ |----------|---------|
50
+ | `3` | Plan phase 3 |
51
+ | `3 --skip-research` | Plan phase 3, skip research step |
52
+ | `3 --assumptions` | Surface assumptions before planning phase 3 |
53
+ | `3 --gaps` | Create gap-closure plans for phase 3 (from VERIFICATION.md) |
54
+ | `3 --teams` | Plan phase 3 using specialist agent teams |
55
+ | (no number) | Use current phase from STATE.md |
56
+
57
+ ### Subcommands
58
+
59
+ | Subcommand | Meaning |
60
+ |------------|---------|
61
+ | `add` | Append a new phase to the end of the roadmap |
62
+ | `insert <N>` | Insert a new phase at position N (uses decimal numbering) |
63
+ | `remove <N>` | Remove phase N from the roadmap |
64
+
65
+ ### Freeform Text Guard — CRITICAL
66
+
67
+ **STOP. Before ANY context loading or Step 1 work**, you MUST check whether `$ARGUMENTS` looks like freeform text rather than a valid invocation. This check is non-negotiable. Valid patterns are:
68
+
69
+ - Empty (no arguments)
70
+ - A phase number: integer (`3`, `03`) or decimal (`3.1`)
71
+ - A subcommand: `add`, `insert <N>`, `remove <N>`
72
+ - A phase number followed by flags: `3 --skip-research`, `3 --assumptions`, `3 --gaps`, `3 --teams`
73
+ - The word `check` (legacy alias)
74
+
75
+ If `$ARGUMENTS` does NOT match any of these patterns — i.e., it contains freeform words that are not a recognized subcommand or flag — then **stop execution** and respond:
76
+
77
+ ```
78
+ `/pbr:plan` expects a phase number or subcommand.
79
+
80
+ Usage:
81
+ /pbr:plan <N> Plan phase N
82
+ /pbr:plan <N> --gaps Create gap-closure plans
83
+ /pbr:plan add Add a new phase
84
+ /pbr:plan insert <N> Insert a phase at position N
85
+ /pbr:plan remove <N> Remove phase N
86
+ ```
87
+
88
+ Then suggest the appropriate skill based on the text content:
89
+
90
+ | If the text looks like... | Suggest |
91
+ |---------------------------|---------|
92
+ | A task, idea, or feature request | `/pbr:todo` to capture it, or `/pbr:explore` to investigate |
93
+ | A bug or debugging request | `/pbr:debug` to investigate the issue |
94
+ | A review or quality concern | `/pbr:review` to assess existing work |
95
+ | Anything else | `/pbr:explore` for open-ended work |
96
+
97
+ Do NOT proceed with planning. The user needs to use the correct skill.
98
+
99
+ **Self-check**: If you reach Step 1 without having matched a valid argument pattern above, you have a bug. Stop immediately and show the usage block.
100
+
101
+ ---
102
+
103
+ ## Orchestration Flow: Standard Planning
104
+
105
+ Execute these steps in order for standard `/pbr:plan <N>` invocations.
106
+
107
+ ---
108
+
109
+ ### Step 1: Parse and Validate (inline)
110
+
111
+ Reference: `skills/shared/config-loading.md` for the tooling shortcut (`state load`, `plan-index`, `phase-info`) and config field reference.
112
+
113
+ 1. Parse `$ARGUMENTS` for phase number and flags
114
+ 2. Read `.planning/config.json` for settings (see config-loading.md for field reference)
115
+ 3. Resolve depth profile: run `node ${PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` to get the effective feature/gate settings for the current depth. Store the result for use in later gating decisions.
116
+ 4. Validate:
117
+ - Phase exists in ROADMAP.md
118
+ - Phase directory exists at `.planning/phases/{NN}-{slug}/`
119
+ - Phase does not already have PLAN.md files (unless user confirms re-planning)
120
+ 5. If no phase number given, read current phase from `.planning/STATE.md`
121
+ 6. **CONTEXT.md existence check**: If the phase is non-trivial (has 2+ requirements or success criteria), check whether a CONTEXT.md exists at EITHER `.planning/CONTEXT.md` (project-level) OR `.planning/phases/{NN}-{slug}/CONTEXT.md` (phase-level). If NEITHER exists, warn: "Phase {N} has no CONTEXT.md. Consider running `/pbr:discuss {N}` first to capture your preferences. Continue anyway?" If user says no, stop. If yes, continue. If at least one exists, proceed without warning.
122
+
123
+ **If phase already has plans:**
124
+ - Use the yes-no pattern from `skills/shared/gate-prompts.md`:
125
+ question: "Phase {N} already has plans. Re-plan from scratch?"
126
+ header: "Re-plan?"
127
+ options:
128
+ - label: "Yes" description: "Delete existing plans and create new ones"
129
+ - label: "No" description: "Keep existing plans unchanged"
130
+ - If "Yes": delete existing PLAN.md files in the phase directory
131
+ - If "No" or "Other": stop
132
+
133
+ ---
134
+
135
+ ### Step 2: Load Context (inline)
136
+
137
+ Read context file PATHS and metadata. Build lean context bundles for agent prompts — include paths and one-line descriptions, NOT full file bodies. Agents have the Read tool and will pull file contents on-demand.
138
+
139
+ ```
140
+ 1. Read .planning/ROADMAP.md — extract current phase goal, dependencies, requirements
141
+ 2. Read .planning/REQUIREMENTS.md — extract requirements mapped to this phase
142
+ 3. Read .planning/CONTEXT.md (if exists) — extract only the `## Decision Summary` section (everything from `## Decision Summary` to the next `##` heading). If no Decision Summary section exists (legacy CONTEXT.md), fall back to extracting the full `## Decisions (LOCKED...)` and `## Deferred Ideas` sections.
143
+ 4. Read .planning/phases/{NN}-{slug}/CONTEXT.md (if exists) — extract only the `## Decision Summary` section. Fall back to full locked decisions + deferred sections if no Decision Summary exists.
144
+ 5. Read .planning/config.json — extract feature flags, depth, model settings
145
+ 6. List prior SUMMARY.md file paths and extract frontmatter metadata only (status, provides, key_files). Do NOT read full SUMMARY bodies — agents pull these on-demand via Read tool.
146
+ 7. Read .planning/research/SUMMARY.md (if exists) — extract research findings
147
+ ```
148
+
149
+ **Digest-select depth for prior SUMMARYs (Step 6):**
150
+
151
+ Reference: `skills/shared/digest-select.md` for the full depth rules and examples. In short: direct dependencies get frontmatter + key decisions, transitive get frontmatter only, 2+ back get skipped.
152
+
153
+ Collect all of this into a context bundle that will be passed to agents.
154
+
155
+ ---
156
+
157
+ ### Step 3: Assumption Surfacing (inline, if `--assumptions` flag)
158
+
159
+ **IMPORTANT**: This step is FREE (no agents). It happens entirely inline.
160
+
161
+ Before spawning any agents, present your assumptions about how this phase should be approached:
162
+
163
+ ```
164
+ Phase {N}: {Name}
165
+ Goal: {from roadmap}
166
+
167
+ My assumptions about this phase:
168
+
169
+ 1. **Approach**: I'm assuming we'll {approach}
170
+ - Correct? [yes/no/adjust]
171
+
172
+ 2. **Key technology**: I'm assuming we'll use {tech}
173
+ - Correct? [yes/no/adjust]
174
+
175
+ 3. **Architecture**: I'm assuming {architectural assumption}
176
+ - Correct? [yes/no/adjust]
177
+
178
+ 4. **Scope boundary**: I'm assuming {scope assumption}
179
+ - Correct? [yes/no/adjust]
180
+ ```
181
+
182
+ For each assumption the user corrects:
183
+ - Record the correction
184
+ - These corrections become additional CONTEXT.md entries
185
+
186
+ After all assumptions are confirmed/corrected:
187
+ - Update `.planning/CONTEXT.md` with any new locked decisions
188
+ - Continue to Step 4
189
+
190
+ ---
191
+
192
+ ### Step 4: Phase Research (delegated, conditional)
193
+
194
+ **Skip this step if ANY of these are true:**
195
+ - `--skip-research` flag is set
196
+ - `--gaps` flag is set
197
+ - Depth profile has `features.research_phase: false`
198
+
199
+ To check: run `node ${PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` and read `profile["features.research_phase"]`. This replaces checking `features.research_phase` and `depth` separately -- the depth profile already incorporates both.
200
+
201
+ **Conditional research (standard/balanced mode):** When the profile has `features.research_phase: true`, also check whether `.planning/codebase/` or `.planning/research/` already contains relevant context for this phase. If substantial context exists (>3 files in codebase/ or a RESEARCH.md mentioning this phase's technologies), skip research and note: "Skipping research -- existing context found in {directory}." This implements the balanced mode's "conditional research" behavior.
202
+
203
+ **If research is needed:**
204
+
205
+ Display to the user: `Spawning researcher...`
206
+
207
+ Invoke the `@researcher` agent with the phase research prompt.
208
+
209
+ **NOTE**: The `@researcher` agent is defined in `agents/researcher.md`. Do NOT inline it.
210
+
211
+ **Path resolution**: Before constructing the agent prompt, resolve plugin root to its absolute path. Do not pass the variable literally in prompts. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
212
+
213
+ #### Phase Research Prompt Template
214
+
215
+ Read `skills/plan/templates/researcher-prompt.md.tmpl` and use it as the prompt template for the researcher agent. Fill in the placeholders with phase-specific context:
216
+ - `{NN}` - phase number (zero-padded)
217
+ - `{phase name}` - phase name from roadmap
218
+ - `{goal from roadmap}` - phase goal statement
219
+ - `{REQ-IDs mapped to this phase}` - requirement IDs
220
+ - `{dependencies from roadmap}` - dependency list
221
+ - Fill `<project_context>` and `<prior_work>` blocks per the shared partial (`templates/prompt-partials/phase-project-context.md.tmpl`): Decision Summary for context, manifest table for prior work
222
+
223
+ Wait for the researcher to complete before proceeding.
224
+
225
+ ---
226
+
227
+ ### Step 4.5: Seed Scanning (inline, before planning)
228
+
229
+ Before invoking the planner, scan `.planning/seeds/` for seeds whose trigger matches the current phase:
230
+
231
+ 1. Glob for `.planning/seeds/*.md`
232
+ 2. For each seed file, read its frontmatter and check the `trigger` field
233
+ 3. A seed matches if ANY of these are true:
234
+ - `trigger` equals the phase slug (e.g., `trigger: authentication`) — **preferred**
235
+ - `trigger` is a substring of the phase directory name (e.g., `trigger: auth` matches `03-authentication`)
236
+ - `trigger` equals the current phase number as integer (e.g., `trigger: 3`) — backward compatible but NOT recommended for new seeds (breaks with decimal phases like 3.1)
237
+ - `trigger` equals `*` (always matches)
238
+ 4. If matching seeds are found, present them to the user:
239
+ ```
240
+ Found {N} seeds related to Phase {NN}:
241
+ - {seed_name}: {seed description}
242
+ - {seed_name}: {seed description}
243
+ ```
244
+
245
+ Use the yes-no-pick pattern from `skills/shared/gate-prompts.md`:
246
+ question: "Include these {N} seeds in planning?"
247
+ header: "Seeds?"
248
+ options:
249
+ - label: "Yes, all" description: "Include all {N} matching seeds"
250
+ - label: "Let me pick" description: "Choose which seeds to include"
251
+ - label: "No" description: "Proceed without seeds"
252
+ 5. If "Yes, all": include all matching seed content in the planner's context
253
+ 6. If "Let me pick": present individual seeds for selection
254
+ 7. If "No" or "Other": proceed without seeds
255
+ 8. If no matching seeds found: proceed silently
256
+
257
+ ---
258
+
259
+ ### Step 4.6: Surface Deferred Ideas (inline, before planning)
260
+
261
+ Before invoking the planner, check `.planning/CONTEXT.md` for deferred ideas that may be relevant to this phase:
262
+
263
+ 1. If `.planning/CONTEXT.md` does NOT exist, skip this step silently
264
+ 2. If it exists, scan for sections named "Deferred Ideas", "Deferred", "Ideas", or "Seeds" (case-insensitive heading match)
265
+ 3. For each deferred item found, check relevance to the current phase by comparing the item text against the phase goal, requirements, and slug
266
+ 4. If relevant deferred items are found, present them to the user:
267
+ ```
268
+ Found {N} deferred idea(s) from previous discussions that may be relevant to Phase {NN}:
269
+ - {deferred item summary}
270
+ - {deferred item summary}
271
+ ```
272
+ Use the yes-no pattern from `skills/shared/gate-prompts.md`:
273
+ question: "Include these deferred ideas in the planning context?"
274
+ header: "Deferred Ideas"
275
+ options:
276
+ - label: "Yes" description: "Pass relevant deferred ideas to the planner"
277
+ - label: "No" description: "Proceed without deferred ideas"
278
+ 5. If "Yes": append the relevant deferred items to the context bundle for the planner prompt (add them to the `<project_context>` block under a `Deferred ideas to consider:` heading)
279
+ 6. If "No" or no relevant items found: proceed without changes
280
+
281
+ This is a lightweight relevance filter — do NOT invoke an agent for this. Just match keywords from the deferred items against the phase goal and requirement text.
282
+
283
+ ---
284
+
285
+ ### Step 5: Planning (delegated)
286
+
287
+ #### Team Mode (--teams)
288
+
289
+ Reference: `references/agent-teams.md` for team role definitions and coordination details.
290
+
291
+ If `--teams` flag is set OR `config.parallelization.use_teams` is true:
292
+
293
+ 1. Create the team output directory: `.planning/phases/{NN}-{slug}/team/`
294
+ 2. Display to the user: `Spawning 3 planners in parallel (architect, security, test)...`
295
+
296
+ Invoke THREE `@planner` agents in parallel:
297
+
298
+ **Agent 1 -- Architect**:
299
+ - Invoke `@planner` with: "You are the ARCHITECT role in a planning team. Focus on: structure, file boundaries, dependency ordering, wave assignment. Write your output to `.planning/phases/{NN}-{slug}/team/architect-PLAN.md`. Do NOT write final PLAN.md files -- your output will be synthesized."
300
+ - Include phase goal, research doc paths, CONTEXT.md path in the prompt
301
+
302
+ **Agent 2 -- Security Reviewer**:
303
+ - Invoke `@planner` with: "You are the SECURITY REVIEWER role in a planning team. Focus on: authentication checks, input validation tasks, secrets handling, permission boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/security-PLAN.md`. Do NOT write final PLAN.md files."
304
+ - Include same context as Agent 1
305
+
306
+ **Agent 3 -- Test Designer**:
307
+ - Invoke `@planner` with: "You are the TEST DESIGNER role in a planning team. Focus on: test strategy, coverage targets, edge cases, which tasks should use TDD, integration test boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/test-PLAN.md`. Do NOT write final PLAN.md files."
308
+ - Include same context as Agent 1
309
+
310
+ 3. Wait for all three to complete
311
+ 4. Display to the user: `Spawning synthesizer...`
312
+
313
+ Invoke `@synthesizer` with: "Read all files in `.planning/phases/{NN}-{slug}/team/`. Synthesize them into unified PLAN.md files in `.planning/phases/{NN}-{slug}/`. The architect output provides structure, the security output adds security-related tasks or checks, and the test output informs TDD flags and test tasks. Resolve any contradictions by preferring the architect's structure with security and test additions."
314
+ 5. Proceed to plan checking as normal
315
+
316
+ If `--teams` is NOT set and `config.parallelization.use_teams` is false or unset, proceed with the existing single-planner flow below.
317
+
318
+ #### Single-Planner Flow (default)
319
+
320
+ Display to the user: `Spawning planner...`
321
+
322
+ Invoke the `@planner` agent with all context inlined.
323
+
324
+ **NOTE**: The `@planner` agent is defined in `agents/planner.md`. Do NOT inline it.
325
+
326
+ **Path resolution**: Before constructing the agent prompt, resolve plugin root to its absolute path. Do not pass the variable literally in prompts. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
327
+
328
+ #### Planning Prompt Template
329
+
330
+ Read `skills/plan/templates/planner-prompt.md.tmpl` and use it as the prompt template for the planner agent. Fill in all placeholder blocks with phase-specific context:
331
+ - `<phase_context>` - phase number, directory, goal, requirements, dependencies, success criteria
332
+ - `<project_context>` - locked decisions, user constraints, deferred ideas, phase-specific decisions
333
+ - `<prior_work>` - manifest table of preceding phase SUMMARY.md file paths with status and one-line exports (NOT full bodies)
334
+ - `<research>` - file path to RESEARCH.md if it exists (NOT inlined content)
335
+ - `<config>` - max tasks, parallelization, TDD mode from config.json
336
+ - `<planning_instructions>` - phase-specific planning rules and output path
337
+
338
+ Wait for the planner to complete.
339
+
340
+ After the planner returns, read the plan files it created to extract counts. Display a completion summary:
341
+
342
+ ```
343
+ Planner created {N} plan(s) across {M} wave(s)
344
+ ```
345
+
346
+ Where `{N}` is the number of PLAN.md files written and `{M}` is the number of distinct wave values across those plans (from frontmatter).
347
+
348
+ ---
349
+
350
+ ### Step 6: Plan Validation (delegated, conditional)
351
+
352
+ **Skip this step if:**
353
+ - Depth profile has `features.plan_checking: false`
354
+
355
+ To check: use the resolved depth profile from Step 1. The profile consolidates the depth setting and any user overrides into a single boolean.
356
+
357
+ **If validation is enabled:**
358
+
359
+ Display to the user: `Spawning plan checker...`
360
+
361
+ Invoke the `@plan-checker` agent with the checker prompt.
362
+
363
+ **NOTE**: The `@plan-checker` agent is defined in `agents/plan-checker.md`. Do NOT inline it.
364
+
365
+ **Path resolution**: Before constructing the agent prompt, resolve plugin root to its absolute path. Do not pass the variable literally in prompts. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
366
+
367
+ #### Checker Prompt Template
368
+
369
+ Read `skills/plan/templates/checker-prompt.md.tmpl` and use it as the prompt template for the plan checker agent. Fill in the placeholders:
370
+ - `<plans_to_check>` - manifest table of PLAN.md file paths (checker reads each via Read tool)
371
+ - `<phase_context>` - phase goal and requirement IDs
372
+ - `<context>` - file paths to project-level and phase-level CONTEXT.md files (checker reads via Read tool)
373
+
374
+ **Process checker results:**
375
+
376
+ After the plan checker returns, display its result:
377
+
378
+ - If `VERIFICATION PASSED`: display `Plan checker: all plans passed` and proceed to Step 8
379
+ - If issues found: display `Plan checker found {N} issue(s) — entering revision loop` and proceed to Step 7
380
+
381
+ ---
382
+
383
+ ### Step 7: Revision Loop (max 3 iterations)
384
+
385
+ Reference: `skills/shared/revision-loop.md` for the full Check-Revise-Escalate pattern.
386
+
387
+ Follow the revision loop pattern with:
388
+ - **Producer**: planner (re-invoked with `skills/plan/templates/revision-prompt.md.tmpl`)
389
+ - **Checker**: plan-checker (back to Step 6)
390
+ - **Escalation**: present issues to user, offer "Proceed anyway" or "Adjust approach" (re-enter Step 5)
391
+
392
+ ---
393
+
394
+ ### Step 8: User Approval (inline, conditional)
395
+
396
+ **Skip if:**
397
+ - `gates.confirm_plan` is `false` in config
398
+ - `mode` is `autonomous` in config
399
+
400
+ **If approval is needed:**
401
+
402
+ Present a summary of all plans to the user:
403
+
404
+ ```
405
+ Phase {N}: {name}
406
+ Plans: {count}
407
+
408
+ Plan {phase}-01: {plan name} (Wave {W}, {task_count} tasks)
409
+ Must-haves: {list truths}
410
+ Files: {list files_modified}
411
+ Tasks:
412
+ 1. {task name}
413
+ 2. {task name}
414
+
415
+ Plan {phase}-02: {plan name} (Wave {W}, {task_count} tasks)
416
+ ...
417
+
418
+ Wave execution order:
419
+ Wave 1: Plan 01, Plan 02 (parallel)
420
+ Wave 2: Plan 03 (depends on 01, 02)
421
+
422
+ Use the approve-revise-abort pattern from `skills/shared/gate-prompts.md`:
423
+ question: "Approve these {count} plans for Phase {N}?"
424
+ header: "Approve?"
425
+ options:
426
+ - label: "Approve" description: "Proceed to build phase"
427
+ - label: "Request changes" description: "Discuss adjustments before proceeding"
428
+ - label: "Abort" description: "Cancel planning for this phase"
429
+ ```
430
+
431
+ **If user selects 'Request changes' or 'Other':**
432
+ - Discuss what needs to change
433
+ - Re-enter Step 5 with updated context/constraints
434
+ - Or make small inline edits to plan files directly
435
+
436
+ **If user selects 'Approve':**
437
+ - **CONTEXT.md compliance reporting**: If `.planning/CONTEXT.md` exists, compare all locked decisions against the generated plans. Print: "CONTEXT.md compliance: {M}/{N} locked decisions mapped to tasks" where M = locked decisions that are reflected in at least one task, N = total locked decisions. If any locked decisions are unmapped, list them as warnings.
438
+ - **Dependency fingerprinting**: For each dependency phase (phases that this phase depends on, per ROADMAP.md):
439
+ 1. Find all SUMMARY.md files in the dependency phase directory
440
+ 2. Compute a simple hash of each SUMMARY.md file (e.g., first 8 chars of a SHA-256 of the file content, or a simpler approach: use the file's byte length + last-modified timestamp as a fingerprint string)
441
+ 3. Add a `dependency_fingerprints` field to each plan's YAML frontmatter:
442
+ ```yaml
443
+ dependency_fingerprints:
444
+ "01-01": "len:4856-mod:2025-02-08T09:40"
445
+ "01-02": "len:4375-mod:2025-02-08T09:43"
446
+ ```
447
+ 4. This allows the build skill to detect if dependency phases were re-built after this plan was created
448
+ - **Update ROADMAP.md Progress table** (REQUIRED — do this BEFORE updating STATE.md):
449
+
450
+ **Tooling shortcut**: Use the CLI for atomic updates:
451
+ ```bash
452
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-plans {phase} 0 {N}
453
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-status {phase} planned
454
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js state update status planned
455
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js state update last_activity now
456
+ ```
457
+
458
+ 1. Open `.planning/ROADMAP.md`
459
+ 2. Find the `## Progress` table
460
+ 3. Locate the row matching this phase number
461
+ 4. Update the `Plans Complete` column to `0/{N}` where N = number of plan files just created
462
+ 5. Update the `Status` column to `planned`
463
+ 6. Save the file — do NOT skip this step
464
+ - Update STATE.md: set current phase plan status to "planned"
465
+ - **If `features.auto_advance` is `true` AND `mode` is `autonomous`:** Chain directly to build. This continues the build->review->plan->build cycle automatically.
466
+ - **Otherwise:** Suggest next action: `/pbr:build {N}`
467
+
468
+ ---
469
+
470
+ ## Orchestration Flow: Subcommands
471
+
472
+ ### Subcommand: `add`
473
+
474
+ 1. Read `.planning/ROADMAP.md`
475
+ 2. Calculate next phase number (last phase + 1)
476
+ 3. Ask user: "What's the goal for this new phase?"
477
+ 4. Ask user: "What requirements does it address?" (show available unassigned REQ-IDs)
478
+ 5. Ask user: "What phases does it depend on?"
479
+ 6. Append phase to ROADMAP.md
480
+ 7. Create phase directory: `.planning/phases/{NN}-{slug}/`
481
+ 8. Update STATE.md if needed
482
+ 9. Suggest: `/pbr:plan {N}` to plan the new phase
483
+
484
+ ### Subcommand: `insert <N>`
485
+
486
+ Reference: `skills/plan/decimal-phase-calc.md` for decimal numbering rules.
487
+
488
+ 1. Read `.planning/ROADMAP.md`
489
+ 2. Calculate decimal phase number:
490
+ - If inserting at position 3: becomes 3.1
491
+ - If 3.1 already exists: becomes 3.2
492
+ - Etc. (see decimal-phase-calc.md)
493
+ 3. Ask user for phase goal, requirements, dependencies
494
+ 4. Insert phase into ROADMAP.md at the correct position
495
+ 5. Create phase directory: `.planning/phases/{NN.M}-{slug}/`
496
+ 6. Update dependencies of subsequent phases if affected
497
+ 7. Suggest: `/pbr:plan {N.M}` to plan the new phase
498
+
499
+ ### Subcommand: `remove <N>`
500
+
501
+ 1. Read `.planning/ROADMAP.md`
502
+ 2. Validate:
503
+ - Phase must exist
504
+ - Phase must be in `pending` or `not started` status (cannot remove completed/in-progress phases)
505
+ - No other phases depend on this phase (or user confirms breaking dependencies)
506
+ 3. Confirm with user: "Remove Phase {N}: {name}? This will delete the phase directory and renumber subsequent phases."
507
+ 4. If confirmed:
508
+ - Delete `.planning/phases/{NN}-{slug}/` directory
509
+ - Remove phase from ROADMAP.md
510
+ - Renumber subsequent phases (N+1 becomes N, etc.)
511
+ - Update all `depends_on` references in ROADMAP.md
512
+ - Update STATE.md if needed
513
+
514
+ ---
515
+
516
+ ## Orchestration Flow: Gap Closure (`--gaps`)
517
+
518
+ When invoked with `--gaps`:
519
+
520
+ 1. Read `.planning/phases/{NN}-{slug}/VERIFICATION.md`
521
+ - If no VERIFICATION.md exists: tell user "No verification report found. Run `/pbr:review {N}` first."
522
+ 2. Extract all gaps from the verification report
523
+ 3. Invoke `@planner` in Gap Closure mode:
524
+
525
+ Read `skills/plan/templates/gap-closure-prompt.md.tmpl` and use it as the prompt template for the gap closure planner. Fill in the placeholders:
526
+ - `<verification_report>` - inline the FULL VERIFICATION.md content
527
+ - `<existing_plans>` - inline all existing PLAN.md files for the phase
528
+ - `<gap_closure_instructions>` - specify output path and gap_closure frontmatter flag
529
+
530
+ 4. After gap-closure plans are created:
531
+ - Run plan checker (if enabled)
532
+ - Present to user for approval
533
+ - Suggest: `/pbr:build {N} --gaps-only`
534
+
535
+ ---
536
+
537
+ ## Error Handling
538
+
539
+ ### Phase not found
540
+ If the specified phase doesn't exist in ROADMAP.md, display:
541
+ ```
542
+ ERROR
543
+
544
+ Phase {N} not found in ROADMAP.md.
545
+
546
+ **To fix:** Run `/pbr:status` to see available phases.
547
+ ```
548
+
549
+ ### Missing prerequisites
550
+ If REQUIREMENTS.md or ROADMAP.md don't exist, display:
551
+ ```
552
+ ERROR
553
+
554
+ Project not initialized. Missing REQUIREMENTS.md or ROADMAP.md.
555
+
556
+ **To fix:** Run `/pbr:begin` first.
557
+ ```
558
+
559
+ ### Research agent fails
560
+ If the researcher agent fails, display:
561
+ ```
562
+ Research agent failed. Planning without phase-specific research.
563
+ This may result in less accurate plans.
564
+ ```
565
+ Continue to the planning step.
566
+
567
+ ### Planner agent fails
568
+ If the planner agent fails, display:
569
+ ```
570
+ ERROR
571
+
572
+ Planner agent failed for Phase {N}.
573
+
574
+ **To fix:**
575
+ - Try again with `/pbr:plan {N} --skip-research`
576
+ - Check `.planning/CONTEXT.md` for conflicting constraints
577
+ ```
578
+
579
+ ### Checker loops forever
580
+ After 3 revision iterations without passing, display:
581
+ ```
582
+ ERROR
583
+
584
+ Plan checker failed to pass after 3 revision iterations for Phase {N}.
585
+
586
+ **To fix:**
587
+ - Review the remaining issues below and decide whether to proceed or revise manually
588
+ - Run `/pbr:plan {N}` to restart planning from scratch
589
+ ```
590
+
591
+ Present remaining issues and ask user to decide: proceed or intervene.
592
+
593
+ ---
594
+
595
+ ## Files Created/Modified by /pbr:plan
596
+
597
+ | File | Purpose | When |
598
+ |------|---------|------|
599
+ | `.planning/phases/{NN}-{slug}/RESEARCH.md` | Phase-specific research | Step 4 |
600
+ | `.planning/phases/{NN}-{slug}/{phase}-{NN}-PLAN.md` | Executable plan files | Step 5 |
601
+ | `.planning/CONTEXT.md` | Updated with assumptions | Step 3 (--assumptions) |
602
+ | `.planning/ROADMAP.md` | Plans Complete + Status -> `planned`; updated for add/insert/remove | Step 8, Subcommands |
603
+ | `.planning/STATE.md` | Updated with plan status | Step 8 |
604
+
605
+ ---
606
+
607
+ ## Completion
608
+
609
+ After planning completes, present:
610
+
611
+ Use the branded stage banner from `references/ui-formatting.md`:
612
+
613
+ ```
614
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
615
+ PLAN-BUILD-RUN ► PLANNING PHASE {N}
616
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
617
+
618
+ **Phase {N}: {name}** — {plan_count} plans created
619
+
620
+ Plans:
621
+ {phase}-01: {name} (Wave 1, {task_count} tasks)
622
+ {phase}-02: {name} (Wave 1, {task_count} tasks)
623
+ {phase}-03: {name} (Wave 2, {task_count} tasks)
624
+
625
+ Wave execution:
626
+ Wave 1: Plans 01, 02 (parallel)
627
+ Wave 2: Plan 03
628
+ ```
629
+
630
+ Then use the "Next Up" routing block:
631
+ ```
632
+ ---
633
+
634
+ ## Next Up
635
+
636
+ **Build Phase {N}** — execute these plans
637
+
638
+ /pbr:build {N}
639
+
640
+ `/clear` first for a fresh context window
641
+
642
+ ---
643
+
644
+ **Also available:**
645
+ - /pbr:plan {N} --assumptions — review assumptions first
646
+ - /pbr:discuss {N} — talk through details before building
647
+
648
+ ---
649
+ ```
@@ -0,0 +1,22 @@
1
+ <\!-- canonical: ../../../../pbr/skills/plan/templates/checker-prompt.md.tmpl -->
2
+ <!-- Source: plan/SKILL.md | Purpose: Prompt template for spawning plan checker agent -->
3
+ <!-- Depends on: templates/prompt-partials/phase-project-context.md.tmpl -->
4
+
5
+ You are the plan-checker agent.
6
+
7
+ <plans_to_check>
8
+ Read and check each of these plan files:
9
+
10
+ | Plan | File Path |
11
+ |------|-----------|
12
+ {For each PLAN.md file in .planning/phases/{NN}-{slug}/:}
13
+ | {plan_id} | {absolute path to PLAN.md} |
14
+
15
+ Read each plan file using the Read tool. Verify all 7 dimensions against each plan.
16
+ </plans_to_check>
17
+
18
+ <!-- Context blocks: Read and fill templates/prompt-partials/phase-project-context.md.tmpl -->
19
+ <!-- Omit <prior_work> -- checker only needs plans and context -->
20
+
21
+ Run all 7 verification dimensions on these plans. Return your structured report.
22
+ Do NOT write any files. Return your findings as your response text.