@sienklogic/plan-build-run 2.34.0 → 2.38.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 (160) hide show
  1. package/CHANGELOG.md +683 -0
  2. package/dashboard/public/css/command-center.css +152 -65
  3. package/dashboard/public/css/explorer.css +22 -41
  4. package/dashboard/public/css/layout.css +119 -1
  5. package/dashboard/public/css/tokens.css +13 -0
  6. package/dashboard/src/components/Layout.tsx +32 -6
  7. package/dashboard/src/components/explorer/tabs/PhasesTab.tsx +11 -1
  8. package/dashboard/src/components/explorer/tabs/TodosTab.tsx +18 -2
  9. package/dashboard/src/components/partials/AttentionPanel.tsx +7 -1
  10. package/dashboard/src/components/partials/CurrentPhaseCard.tsx +26 -24
  11. package/dashboard/src/components/partials/QuickActions.tsx +21 -11
  12. package/dashboard/src/components/partials/StatCardGrid.tsx +67 -0
  13. package/dashboard/src/components/partials/StatusHeader.tsx +1 -0
  14. package/dashboard/src/routes/command-center.routes.tsx +8 -7
  15. package/dashboard/src/routes/index.routes.tsx +32 -29
  16. package/package.json +2 -2
  17. package/plugins/copilot-pbr/agents/audit.agent.md +129 -16
  18. package/plugins/copilot-pbr/agents/codebase-mapper.agent.md +49 -1
  19. package/plugins/copilot-pbr/agents/debugger.agent.md +50 -1
  20. package/plugins/copilot-pbr/agents/dev-sync.agent.md +23 -0
  21. package/plugins/copilot-pbr/agents/executor.agent.md +153 -8
  22. package/plugins/copilot-pbr/agents/general.agent.md +46 -1
  23. package/plugins/copilot-pbr/agents/integration-checker.agent.md +55 -2
  24. package/plugins/copilot-pbr/agents/plan-checker.agent.md +50 -2
  25. package/plugins/copilot-pbr/agents/planner.agent.md +80 -1
  26. package/plugins/copilot-pbr/agents/researcher.agent.md +50 -2
  27. package/plugins/copilot-pbr/agents/synthesizer.agent.md +49 -1
  28. package/plugins/copilot-pbr/agents/verifier.agent.md +114 -13
  29. package/plugins/copilot-pbr/commands/test.md +5 -0
  30. package/plugins/copilot-pbr/hooks/hooks.json +11 -0
  31. package/plugins/copilot-pbr/plugin.json +1 -1
  32. package/plugins/copilot-pbr/references/agent-contracts.md +27 -0
  33. package/plugins/copilot-pbr/references/checkpoints.md +32 -1
  34. package/plugins/copilot-pbr/references/context-quality-tiers.md +45 -0
  35. package/plugins/copilot-pbr/references/pbr-tools-cli.md +115 -0
  36. package/plugins/copilot-pbr/references/questioning.md +21 -1
  37. package/plugins/copilot-pbr/references/verification-patterns.md +96 -18
  38. package/plugins/copilot-pbr/skills/audit/SKILL.md +19 -3
  39. package/plugins/copilot-pbr/skills/begin/SKILL.md +57 -4
  40. package/plugins/copilot-pbr/skills/build/SKILL.md +39 -2
  41. package/plugins/copilot-pbr/skills/config/SKILL.md +12 -2
  42. package/plugins/copilot-pbr/skills/debug/SKILL.md +12 -1
  43. package/plugins/copilot-pbr/skills/explore/SKILL.md +13 -2
  44. package/plugins/copilot-pbr/skills/health/SKILL.md +13 -5
  45. package/plugins/copilot-pbr/skills/import/SKILL.md +26 -1
  46. package/plugins/copilot-pbr/skills/milestone/SKILL.md +15 -3
  47. package/plugins/copilot-pbr/skills/plan/SKILL.md +50 -0
  48. package/plugins/copilot-pbr/skills/quick/SKILL.md +21 -0
  49. package/plugins/copilot-pbr/skills/review/SKILL.md +45 -0
  50. package/plugins/copilot-pbr/skills/scan/SKILL.md +20 -0
  51. package/plugins/copilot-pbr/skills/setup/SKILL.md +9 -1
  52. package/plugins/copilot-pbr/skills/shared/context-budget.md +10 -0
  53. package/plugins/copilot-pbr/skills/shared/universal-anti-patterns.md +6 -0
  54. package/plugins/copilot-pbr/skills/test/SKILL.md +210 -0
  55. package/plugins/copilot-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  56. package/plugins/copilot-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  57. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  58. package/plugins/cursor-pbr/agents/audit.md +52 -5
  59. package/plugins/cursor-pbr/agents/codebase-mapper.md +49 -1
  60. package/plugins/cursor-pbr/agents/debugger.md +50 -1
  61. package/plugins/cursor-pbr/agents/dev-sync.md +23 -0
  62. package/plugins/cursor-pbr/agents/executor.md +153 -8
  63. package/plugins/cursor-pbr/agents/general.md +46 -1
  64. package/plugins/cursor-pbr/agents/integration-checker.md +54 -1
  65. package/plugins/cursor-pbr/agents/plan-checker.md +49 -1
  66. package/plugins/cursor-pbr/agents/planner.md +80 -1
  67. package/plugins/cursor-pbr/agents/researcher.md +49 -1
  68. package/plugins/cursor-pbr/agents/synthesizer.md +49 -1
  69. package/plugins/cursor-pbr/agents/verifier.md +113 -12
  70. package/plugins/cursor-pbr/commands/test.md +5 -0
  71. package/plugins/cursor-pbr/hooks/hooks.json +9 -0
  72. package/plugins/cursor-pbr/references/agent-contracts.md +27 -0
  73. package/plugins/cursor-pbr/references/checkpoints.md +32 -1
  74. package/plugins/cursor-pbr/references/context-quality-tiers.md +45 -0
  75. package/plugins/cursor-pbr/references/pbr-tools-cli.md +115 -0
  76. package/plugins/cursor-pbr/references/questioning.md +21 -1
  77. package/plugins/cursor-pbr/references/verification-patterns.md +96 -18
  78. package/plugins/cursor-pbr/skills/audit/SKILL.md +19 -3
  79. package/plugins/cursor-pbr/skills/begin/SKILL.md +57 -4
  80. package/plugins/cursor-pbr/skills/build/SKILL.md +37 -2
  81. package/plugins/cursor-pbr/skills/config/SKILL.md +12 -2
  82. package/plugins/cursor-pbr/skills/debug/SKILL.md +12 -1
  83. package/plugins/cursor-pbr/skills/explore/SKILL.md +13 -2
  84. package/plugins/cursor-pbr/skills/health/SKILL.md +14 -5
  85. package/plugins/cursor-pbr/skills/import/SKILL.md +26 -1
  86. package/plugins/cursor-pbr/skills/milestone/SKILL.md +15 -3
  87. package/plugins/cursor-pbr/skills/plan/SKILL.md +50 -0
  88. package/plugins/cursor-pbr/skills/quick/SKILL.md +21 -0
  89. package/plugins/cursor-pbr/skills/review/SKILL.md +45 -0
  90. package/plugins/cursor-pbr/skills/scan/SKILL.md +20 -0
  91. package/plugins/cursor-pbr/skills/setup/SKILL.md +9 -1
  92. package/plugins/cursor-pbr/skills/shared/context-budget.md +10 -0
  93. package/plugins/cursor-pbr/skills/shared/universal-anti-patterns.md +6 -0
  94. package/plugins/cursor-pbr/skills/test/SKILL.md +211 -0
  95. package/plugins/cursor-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  96. package/plugins/cursor-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  97. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
  98. package/plugins/pbr/agents/audit.md +45 -0
  99. package/plugins/pbr/agents/codebase-mapper.md +48 -0
  100. package/plugins/pbr/agents/debugger.md +49 -0
  101. package/plugins/pbr/agents/dev-sync.md +23 -0
  102. package/plugins/pbr/agents/executor.md +151 -6
  103. package/plugins/pbr/agents/general.md +45 -0
  104. package/plugins/pbr/agents/integration-checker.md +53 -0
  105. package/plugins/pbr/agents/plan-checker.md +48 -0
  106. package/plugins/pbr/agents/planner.md +78 -1
  107. package/plugins/pbr/agents/researcher.md +48 -0
  108. package/plugins/pbr/agents/synthesizer.md +48 -0
  109. package/plugins/pbr/agents/verifier.md +112 -11
  110. package/plugins/pbr/commands/test.md +5 -0
  111. package/plugins/pbr/hooks/hooks.json +9 -0
  112. package/plugins/pbr/references/agent-contracts.md +27 -0
  113. package/plugins/pbr/references/checkpoints.md +32 -0
  114. package/plugins/pbr/references/context-quality-tiers.md +45 -0
  115. package/plugins/pbr/references/pbr-tools-cli.md +115 -0
  116. package/plugins/pbr/references/questioning.md +21 -0
  117. package/plugins/pbr/references/verification-patterns.md +96 -17
  118. package/plugins/pbr/scripts/check-plan-format.js +13 -1
  119. package/plugins/pbr/scripts/check-state-sync.js +26 -7
  120. package/plugins/pbr/scripts/check-subagent-output.js +30 -2
  121. package/plugins/pbr/scripts/config-schema.json +11 -1
  122. package/plugins/pbr/scripts/context-bridge.js +265 -0
  123. package/plugins/pbr/scripts/lib/config.js +271 -0
  124. package/plugins/pbr/scripts/lib/core.js +587 -0
  125. package/plugins/pbr/scripts/lib/history.js +73 -0
  126. package/plugins/pbr/scripts/lib/init.js +166 -0
  127. package/plugins/pbr/scripts/lib/migrate.js +169 -0
  128. package/plugins/pbr/scripts/lib/phase.js +364 -0
  129. package/plugins/pbr/scripts/lib/roadmap.js +175 -0
  130. package/plugins/pbr/scripts/lib/state.js +397 -0
  131. package/plugins/pbr/scripts/lib/todo.js +300 -0
  132. package/plugins/pbr/scripts/pbr-tools.js +425 -1310
  133. package/plugins/pbr/scripts/post-write-dispatch.js +5 -4
  134. package/plugins/pbr/scripts/pre-write-dispatch.js +1 -1
  135. package/plugins/pbr/scripts/progress-tracker.js +1 -1
  136. package/plugins/pbr/scripts/suggest-compact.js +1 -1
  137. package/plugins/pbr/scripts/track-context-budget.js +53 -2
  138. package/plugins/pbr/scripts/validate-task.js +20 -28
  139. package/plugins/pbr/skills/audit/SKILL.md +19 -3
  140. package/plugins/pbr/skills/begin/SKILL.md +48 -2
  141. package/plugins/pbr/skills/build/SKILL.md +39 -2
  142. package/plugins/pbr/skills/config/SKILL.md +12 -2
  143. package/plugins/pbr/skills/debug/SKILL.md +12 -1
  144. package/plugins/pbr/skills/debug/templates/continuation-prompt.md.tmpl +12 -1
  145. package/plugins/pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +12 -5
  146. package/plugins/pbr/skills/explore/SKILL.md +13 -2
  147. package/plugins/pbr/skills/health/SKILL.md +14 -3
  148. package/plugins/pbr/skills/help/SKILL.md +2 -0
  149. package/plugins/pbr/skills/import/SKILL.md +26 -1
  150. package/plugins/pbr/skills/milestone/SKILL.md +15 -3
  151. package/plugins/pbr/skills/plan/SKILL.md +52 -2
  152. package/plugins/pbr/skills/quick/SKILL.md +21 -0
  153. package/plugins/pbr/skills/review/SKILL.md +46 -0
  154. package/plugins/pbr/skills/scan/SKILL.md +20 -0
  155. package/plugins/pbr/skills/setup/SKILL.md +9 -1
  156. package/plugins/pbr/skills/shared/context-budget.md +10 -0
  157. package/plugins/pbr/skills/shared/universal-anti-patterns.md +6 -0
  158. package/plugins/pbr/skills/test/SKILL.md +212 -0
  159. package/plugins/pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  160. package/plugins/pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
@@ -61,6 +61,8 @@ Execute these steps in order.
61
61
 
62
62
  ### Step 1: Parse and Validate (inline)
63
63
 
64
+ **Init-first pattern**: When spawning agents, pass the output of `node plugins/pbr/scripts/pbr-tools.js init verify-work {N}` as context rather than having the agent read multiple files separately. This reduces file reads and prevents context-loading failures.
65
+
64
66
  1. Parse `$ARGUMENTS` for phase number and `--auto-fix` flag
65
67
  2. Read `.planning/config.json`
66
68
  **CRITICAL: Write .active-skill NOW.** Write the text "review" to `.planning/.active-skill` using the Write tool.
@@ -155,6 +157,16 @@ Invoke the `@verifier` agent to run three-layer checks.
155
157
 
156
158
  Read `skills/review/templates/verifier-prompt.md.tmpl` and use its content as the verifier prompt.
157
159
 
160
+ **Prepend this block to the verifier prompt before sending:**
161
+ ```
162
+ <files_to_read>
163
+ CRITICAL: Read these files BEFORE any other action:
164
+ 1. .planning/phases/{NN}-{slug}/PLAN-*.md — must-haves to verify against
165
+ 2. .planning/phases/{NN}-{slug}/SUMMARY-*.md — executor build summaries
166
+ 3. .planning/phases/{NN}-{slug}/VERIFICATION.md — prior verification results (if exists)
167
+ </files_to_read>
168
+ ```
169
+
158
170
  **Placeholders to fill before sending:**
159
171
  - `{For each PLAN.md file in the phase directory:}` — inline each plan's must_haves frontmatter block
160
172
  - `{For each SUMMARY.md file in the phase directory:}` — provide manifest table with file paths and status from frontmatter. The verifier reads full content from disk via Read tool.
@@ -181,6 +193,17 @@ Then show a brief table of must-haves with pass/fail status:
181
193
 
182
194
  Then display the overall verdict (`PASSED`, `GAPS FOUND`, or `HUMAN NEEDED`) before proceeding to the full results presentation.
183
195
 
196
+ ### Step 3a: Spot-Check Verifier Output
197
+
198
+ CRITICAL: Verify verifier output before proceeding.
199
+
200
+ 1. **VERIFICATION.md exists**: Check `.planning/phases/{NN}-{slug}/VERIFICATION.md` exists on disk
201
+ 2. **Status field present**: Read VERIFICATION.md frontmatter — verify `status` field is present and is one of: pass, fail, partial
202
+ 3. **Must-haves checked**: Verify `must_haves_checked` count > 0 in frontmatter
203
+ 4. **Completion marker**: Look for `## VERIFICATION COMPLETE` in the Task() output
204
+
205
+ If ANY spot-check fails, present the user with options: **Retry** / **Continue anyway** / **Abort**
206
+
184
207
  ---
185
208
 
186
209
  ### Step 3b: Local LLM Verification Quality Check (optional, advisory)
@@ -368,6 +391,16 @@ Invoke the `@debugger` agent to analyze each failure.
368
391
 
369
392
  Read `skills/review/templates/debugger-prompt.md.tmpl` and use its content as the debugger prompt.
370
393
 
394
+ **Prepend this block to the debugger prompt before sending:**
395
+ ```
396
+ <files_to_read>
397
+ CRITICAL: Read these files BEFORE any other action:
398
+ 1. .planning/phases/{NN}-{slug}/VERIFICATION.md — gaps and failure details
399
+ 2. .planning/phases/{NN}-{slug}/SUMMARY-*.md — what was built
400
+ 3. .planning/phases/{NN}-{slug}/PLAN-*.md — original plan must-haves
401
+ </files_to_read>
402
+ ```
403
+
371
404
  **Placeholders to fill before sending:**
372
405
  - `[Inline the VERIFICATION.md content]` — provide file path; debugger reads via Read tool
373
406
  - `[Inline all SUMMARY.md files for the phase]` — provide manifest table of file paths
@@ -383,6 +416,16 @@ Invoke the `@planner` agent in gap-closure mode.
383
416
 
384
417
  Read `skills/review/templates/gap-planner-prompt.md.tmpl` and use its content as the gap planner prompt.
385
418
 
419
+ **Prepend this block to the gap planner prompt before sending:**
420
+ ```
421
+ <files_to_read>
422
+ CRITICAL: Read these files BEFORE any other action:
423
+ 1. .planning/phases/{NN}-{slug}/VERIFICATION.md — gaps to close
424
+ 2. .planning/phases/{NN}-{slug}/PLAN-*.md — existing plans for context
425
+ 3. .planning/CONTEXT.md — locked decisions and constraints (if exists)
426
+ </files_to_read>
427
+ ```
428
+
386
429
  **Placeholders to fill before sending:**
387
430
  - `[Inline VERIFICATION.md]` — provide file path; planner reads via Read tool
388
431
  - `[Inline the debugger's root cause analysis]` — keep inline (already in conversation context)
@@ -563,6 +606,8 @@ After review completes, always present a clear next action using the completion
563
606
  - **If gaps remain:** Use the "Gaps Found" template. Fill in phase number, name, gap count, and gap summaries.
564
607
  - **If final phase:** Use the "Milestone Complete" template. Fill in phase count.
565
608
 
609
+ Include `<sub>/clear first → fresh context window</sub>` inside the Next Up routing block of the completion template.
610
+
566
611
  ---
567
612
 
568
613
  ## Notes
@@ -123,6 +123,14 @@ For each agent, read `skills/scan/templates/mapper-prompt.md.tmpl` and fill in t
123
123
  - `{scale}`: detected scale from Step 2
124
124
  - `{output_path}`: `.planning/codebase/`
125
125
 
126
+ **Prepend this block to each mapper prompt before sending:**
127
+ ```
128
+ <files_to_read>
129
+ CRITICAL: Read these files BEFORE any other action:
130
+ 1. .planning/codebase/RECON.md — baseline reconnaissance data (if exists)
131
+ </files_to_read>
132
+ ```
133
+
126
134
  | Agent | Focus | Output Files | When |
127
135
  |-------|-------|-------------|------|
128
136
  | 1 | tech | STACK.md, INTEGRATIONS.md | Always |
@@ -142,6 +150,18 @@ All agents run in parallel. As each completes, display:
142
150
 
143
151
  (Only display lines for the focus areas that were actually spawned.)
144
152
 
153
+ ### Step 4b: Check Completion Markers
154
+
155
+ After each codebase-mapper Task() completes, check the Task() output for the `## MAPPING COMPLETE` marker:
156
+
157
+ - If `## MAPPING COMPLETE` is present: the mapper finished successfully, proceed normally
158
+ - If the marker is missing: warn the user that the mapper may not have completed successfully:
159
+ ```
160
+ ⚠ Codebase mapper ({focus_area}) did not report MAPPING COMPLETE.
161
+ Output may be incomplete — check .planning/codebase/ for partial results.
162
+ ```
163
+ Continue to Step 5 verification regardless (the file existence checks will catch truly missing output).
164
+
145
165
  ### Step 5: Verify Output
146
166
 
147
167
  After all agents complete, verify the expected files exist:
@@ -71,7 +71,15 @@ mkdir -p .planning/phases .planning/todos/pending .planning/todos/done .planning
71
71
 
72
72
  **CRITICAL: Write .planning/config.json NOW. Do NOT skip this step.**
73
73
 
74
- Create `.planning/config.json` with defaults:
74
+ Before writing config.json, check for user-level defaults:
75
+
76
+ ```bash
77
+ node "${PLUGIN_ROOT}/scripts/pbr-tools.js" config load-defaults
78
+ ```
79
+
80
+ If user defaults exist (the output has keys like `mode`, `features`, etc.), inform the user: "Found your saved preferences from ~/.claude/pbr-defaults.json. These will be merged into your project config (project-specific settings take precedence)." Then deep-merge user defaults into the config below before writing.
81
+
82
+ Create `.planning/config.json` with defaults (merged with user defaults if they exist):
75
83
  ```json
76
84
  {
77
85
  "version": 2,
@@ -17,6 +17,16 @@ Every skill that spawns agents or reads significant content must follow these ru
17
17
  4. **Delegate** heavy work to agents — the orchestrator routes, it doesn't execute
18
18
  5. **Before spawning agents**: If you've already consumed significant context (large file reads, multiple subagent results), warn the user: "Context budget is getting heavy. Consider running `/pbr:pause` to checkpoint progress." Suggest pause proactively rather than waiting for compaction.
19
19
 
20
+ ## Context Degradation Awareness
21
+
22
+ Quality degrades gradually before panic thresholds fire. Watch for these early warning signs:
23
+
24
+ - **Silent partial completion** — agent claims task is done but implementation is incomplete. Self-check catches file existence but not semantic completeness. Always verify agent output meets the plan's must_haves, not just that files exist.
25
+ - **Increasing vagueness** — agent starts using phrases like "appropriate handling" or "standard patterns" instead of specific code. This indicates context pressure even before budget warnings fire.
26
+ - **Skipped steps** — agent omits protocol steps it would normally follow. If an agent's success criteria has 8 items but it only reports 5, suspect context pressure.
27
+
28
+ When delegating to agents, the orchestrator cannot verify semantic correctness of agent output — only structural completeness. This is a fundamental limitation. Mitigate with must_haves.truths and spot-check verification.
29
+
20
30
  ## Customization
21
31
 
22
32
  Skills should add skill-specific rules below the reference line. Common skill-specific additions:
@@ -36,3 +36,9 @@ These rules prevent context rot -- quality degradation as the context window fil
36
36
  14. **Do not** suggest multiple next actions without clear priority -- one primary suggestion, alternatives listed secondary.
37
37
  15. **Do not** use `git add .` or `git add -A` -- stage specific files only.
38
38
  16. **Do not** include sensitive information (API keys, passwords, tokens) in planning documents or commits.
39
+
40
+ ## Error Recovery Rules (apply to every skill)
41
+
42
+ 17. **Git lock detection**: Before any git operation, if it fails with "Unable to create lock file", check for stale `.git/index.lock` and advise the user to remove it (do not remove automatically — another process may hold it legitimately).
43
+ 18. **Config fallback awareness**: `configLoad()` returns `null` silently on invalid JSON. If your skill depends on config values, check for null and warn the user: "config.json is invalid or missing — running with defaults. Run `/pbr:health` to diagnose."
44
+ 19. **Partial state recovery**: If STATE.md references a phase directory that doesn't exist, do not proceed silently. Warn the user and suggest `/pbr:health` to diagnose the mismatch.
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: test
3
+ description: "Generate tests for completed phase code. Detects test framework and targets key files."
4
+ argument-hint: "<phase-number>"
5
+ ---
6
+
7
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by the plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
8
+
9
+ # /pbr:test — Post-Phase Test Generation
10
+
11
+ You are the orchestrator for `/pbr:test`. This skill generates tests for code that was built WITHOUT TDD mode. It targets key files from completed phases and creates meaningful test coverage.
12
+
13
+ ## Context Budget
14
+
15
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
16
+
17
+ Additionally for this skill:
18
+ - **Delegate** all test writing to executor agents — never write test code in the main context
19
+ - Read only SUMMARY.md frontmatter for `key_files` lists — do not read full summaries
20
+
21
+ ## Step 0 — Immediate Output
22
+
23
+ **Before ANY tool calls**, display this banner:
24
+
25
+ ```
26
+ ╔══════════════════════════════════════════════════════════════╗
27
+ ║ PLAN-BUILD-RUN ► GENERATING TESTS FOR PHASE {N} ║
28
+ ╚══════════════════════════════════════════════════════════════╝
29
+ ```
30
+
31
+ Where `{N}` is the phase number from `$ARGUMENTS`. Then proceed to Step 1.
32
+
33
+ ## Prerequisites
34
+
35
+ - `.planning/config.json` exists
36
+ - Phase has been built: SUMMARY.md files exist in `.planning/phases/{NN}-{slug}/`
37
+ - Phase should NOT already have TDD coverage (check if `features.tdd_mode` is false in config — if TDD mode is enabled, warn user that tests should already exist and ask to proceed anyway)
38
+
39
+ ---
40
+
41
+ ## Argument Parsing
42
+
43
+ Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
44
+
45
+ | Argument | Meaning |
46
+ |----------|---------|
47
+ | `3` | Generate tests for phase 3 |
48
+ | (no number) | Use current phase from STATE.md |
49
+
50
+ ---
51
+
52
+ ## Step 1 — Gather Context
53
+
54
+ **CRITICAL: Run init command to load project state efficiently.**
55
+
56
+ ```bash
57
+ node "${PLUGIN_ROOT}/scripts/pbr-tools.js" init execute-phase {phase_number}
58
+ ```
59
+
60
+ This returns STATE.md snapshot, phase plans, ROADMAP excerpt, and config — all in one call.
61
+
62
+ ## Step 2 — Detect Test Framework
63
+
64
+ Scan the project root for test framework indicators:
65
+
66
+ 1. Check `package.json` for `jest`, `vitest`, `mocha`, `ava` in devDependencies
67
+ 2. Check for `pytest.ini`, `pyproject.toml` (with `[tool.pytest]`), `setup.cfg` (with `[tool:pytest]`)
68
+ 3. Check for `jest.config.*`, `vitest.config.*`, `.mocharc.*`
69
+ 4. Check for existing test directories: `tests/`, `test/`, `__tests__/`, `spec/`
70
+ 5. Check for existing test file patterns: `*.test.*`, `*.spec.*`, `test_*.py`
71
+
72
+ If no test framework is detected, ask the user:
73
+
74
+ Use AskUserQuestion:
75
+ question: "No test framework detected. Which should I use?"
76
+ header: "Framework"
77
+ options:
78
+ - label: "Jest" description: "JavaScript/TypeScript testing (most common)"
79
+ - label: "Vitest" description: "Vite-native testing (faster, ESM-friendly)"
80
+ - label: "pytest" description: "Python testing framework"
81
+ multiSelect: false
82
+
83
+ ## Step 3 — Collect Target Files
84
+
85
+ Read SUMMARY.md frontmatter from each plan in the phase to extract `key_files`:
86
+
87
+ ```bash
88
+ node "${PLUGIN_ROOT}/scripts/pbr-tools.js" frontmatter .planning/phases/{NN}-{slug}/SUMMARY.md
89
+ ```
90
+
91
+ Collect all `key_files` across all plans in the phase. Filter to only source files (exclude config, docs, assets). Group by:
92
+ - **High priority**: Files with business logic, API endpoints, data models
93
+ - **Medium priority**: Utility functions, helpers, middleware
94
+ - **Low priority**: Config, types-only files, constants
95
+
96
+ Present the file list to the user:
97
+
98
+ Use AskUserQuestion:
99
+ question: "Found {N} source files from phase {P}. Generate tests for which?"
100
+ header: "Scope"
101
+ options:
102
+ - label: "High priority only" description: "{X} files — business logic, APIs, models"
103
+ - label: "High + Medium" description: "{Y} files — adds utilities and helpers"
104
+ - label: "All files" description: "{Z} files — comprehensive coverage"
105
+ multiSelect: false
106
+
107
+ ## Step 4 — Generate Test Plans
108
+
109
+ For each target file, create a lightweight test plan (NOT a full PBR PLAN.md — just a task list):
110
+
111
+ ```
112
+ File: src/auth/login.js
113
+ Tests to generate:
114
+ - Happy path: valid credentials return token
115
+ - Error: invalid password returns 401
116
+ - Error: missing email returns 400
117
+ - Edge: expired session handling
118
+ Framework: jest
119
+ Output: tests/auth/login.test.js
120
+ ```
121
+
122
+ ## Step 5 — Spawn Executor Agents
123
+
124
+ **CRITICAL: Delegate ALL test writing to agents. Do NOT write test code in the main context.**
125
+
126
+ For each target file (or batch of related files), spawn an executor agent:
127
+
128
+ ```
129
+ Spawn agent_type: "pbr:executor"
130
+
131
+ Task: Generate tests for the following file(s):
132
+
133
+ <files_to_test>
134
+ {file_path}: {brief description from SUMMARY}
135
+ </files_to_test>
136
+
137
+ <test_framework>
138
+ {detected framework name and version}
139
+ Existing test directory: {path}
140
+ Test file naming: {pattern, e.g., *.test.js}
141
+ </test_framework>
142
+
143
+ <test_plan>
144
+ {test plan from Step 4}
145
+ </test_plan>
146
+
147
+ Instructions:
148
+ 1. Read each source file to understand the implementation
149
+ 2. Write test files following the project's existing test patterns
150
+ 3. Each test file should cover: happy path, error cases, edge cases
151
+ 4. Use the project's existing mocking patterns if any exist
152
+ 5. Run the tests to verify they pass: {test command}
153
+ 6. Commit with format: test({phase}-tests): add tests for {file}
154
+ ```
155
+
156
+ Spawn up to `parallelization.max_concurrent_agents` agents in parallel for independent files.
157
+
158
+ ## Step 6 — Verify and Report
159
+
160
+ After all agents complete, check results:
161
+
162
+ 1. Glob for new test files created in this session
163
+ 2. Run the test suite to verify all new tests pass:
164
+ ```bash
165
+ {test_command}
166
+ ```
167
+ 3. Count: files tested, tests written, tests passing
168
+
169
+ Display completion:
170
+
171
+ ```
172
+ ╔══════════════════════════════════════════════════════════════╗
173
+ ║ PLAN-BUILD-RUN ► TESTS GENERATED ✓ ║
174
+ ╚══════════════════════════════════════════════════════════════╝
175
+
176
+ Phase {N}: {X} test files created, {Y} tests passing
177
+
178
+ Files tested:
179
+ - src/auth/login.js → tests/auth/login.test.js (8 tests)
180
+ - src/api/users.js → tests/api/users.test.js (12 tests)
181
+
182
+
183
+
184
+ ╔══════════════════════════════════════════════════════════════╗
185
+ ║ ▶ NEXT UP ║
186
+ ╚══════════════════════════════════════════════════════════════╝
187
+
188
+ **Run coverage check** to see how much is covered
189
+
190
+ `npm test -- --coverage`
191
+
192
+ <sub>`/clear` first → fresh context window</sub>
193
+
194
+
195
+
196
+ **Also available:**
197
+ - `/pbr:review {N}` — verify the full phase
198
+ - `/pbr:continue` — execute next logical step
199
+
200
+
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Anti-Patterns
206
+
207
+ 1. **DO NOT** write test code in the main orchestrator context — always delegate to executor agents
208
+ 2. **DO NOT** generate tests for files not listed in SUMMARY.md key_files — stay scoped to the phase
209
+ 3. **DO NOT** skip running the tests — always verify they pass before reporting success
210
+ 4. **DO NOT** generate trivial tests (testing getters/setters, testing constants) — focus on behavior
211
+ 5. **DO NOT** read full source files in the orchestrator — let the executor agents read them
@@ -0,0 +1,95 @@
1
+ # SUMMARY-complex.md Template
2
+
3
+ > Use when: decisions were made OR fileCount > 6
4
+ > Referenced by: executor agent (complex plans, architectural work)
5
+
6
+ ## Frontmatter (YAML)
7
+
8
+ ```yaml
9
+ ---
10
+ phase: "{phase_id}"
11
+ plan: "{plan_id}"
12
+ status: "complete" # complete | partial | checkpoint
13
+ subsystem: "{main subsystem affected}"
14
+ tags:
15
+ - "{tag1}"
16
+ requires:
17
+ - "{plan_id}: {artifact}"
18
+ provides:
19
+ - "{export/artifact description}"
20
+ affects:
21
+ - "{affected area 1}"
22
+ tech_stack:
23
+ - "{technology used}"
24
+ key_files:
25
+ - "{file1}: {what it does}"
26
+ key_decisions:
27
+ - "{decision 1}: {rationale}"
28
+ patterns:
29
+ - "{pattern used}: {where}"
30
+ metrics:
31
+ duration_minutes: {n}
32
+ tasks_completed: {n}
33
+ tasks_total: {n}
34
+ commits: {n}
35
+ files_created: {n}
36
+ files_modified: {n}
37
+ deferred:
38
+ - "{thing noticed but not implemented}"
39
+ self_check_failures:
40
+ - "{failure description}"
41
+ architecture_notes:
42
+ - "{key architectural decision and why}"
43
+ ---
44
+ ```
45
+
46
+ ## Body Structure
47
+
48
+ ```markdown
49
+ # Plan Summary: {plan_id}
50
+
51
+ ## What Was Built
52
+
53
+ {2-3 paragraph description of what was accomplished}
54
+
55
+ ## Architecture Decisions
56
+
57
+ | Decision | Options Considered | Chosen | Rationale |
58
+ |----------|-------------------|--------|-----------|
59
+ | {decision} | {opt1}, {opt2} | {chosen} | {why} |
60
+
61
+ ## Task Results
62
+
63
+ | Task | Status | Commit | Files | Verify |
64
+ |------|--------|--------|-------|--------|
65
+ | {task_id}: {name} | done | {hash} | {count} | passed |
66
+
67
+ ## Key Implementation Details
68
+
69
+ {Important details about HOW things were implemented}
70
+
71
+ ## Integration Points
72
+
73
+ {How this plan connects to other plans - imports, exports, shared state}
74
+
75
+ ## Known Issues
76
+
77
+ {Issues discovered during execution}
78
+
79
+ ## Dependencies Provided
80
+
81
+ {What other plans can now depend on}
82
+
83
+ ## Deferred Items
84
+
85
+ {Items noticed but intentionally deferred - with rationale}
86
+ ```
87
+
88
+ ## Selection Heuristic
89
+
90
+ Use this template when ANY of the following are true:
91
+ - Key architectural decisions were made during execution
92
+ - Total files created or modified > 6
93
+ - Deviations from the plan occurred
94
+ - Multiple integration points were established
95
+ - The plan touched shared infrastructure or patterns
@@ -0,0 +1,48 @@
1
+ # SUMMARY-minimal.md Template
2
+
3
+ > Use when: taskCount <= 2 AND fileCount <= 3
4
+ > Referenced by: executor agent (quick tasks, simple plans)
5
+
6
+ ## Frontmatter (YAML)
7
+
8
+ ```yaml
9
+ ---
10
+ phase: "{phase_id}"
11
+ plan: "{plan_id}"
12
+ status: "complete" # complete | partial | checkpoint
13
+ requires: []
14
+ provides:
15
+ - "{export/artifact description}"
16
+ key_files:
17
+ - "{file1}: {what it does}"
18
+ deferred: []
19
+ metrics:
20
+ tasks_completed: {n}
21
+ tasks_total: {n}
22
+ commits: {n}
23
+ ---
24
+ ```
25
+
26
+ ## Body Structure
27
+
28
+ ```markdown
29
+ # Plan Summary: {plan_id}
30
+
31
+ ## What Was Built
32
+
33
+ {1 paragraph description}
34
+
35
+ ## Task Results
36
+
37
+ | Task | Status | Commit | Files |
38
+ |------|--------|--------|-------|
39
+ | {task_id}: {name} | done | {hash} | {count} |
40
+ ```
41
+
42
+ ## Selection Heuristic
43
+
44
+ Use this template when ALL of the following are true:
45
+ - Total tasks in the plan <= 2
46
+ - Total files created or modified <= 3
47
+ - No key decisions were made
48
+ - No deviations from the plan occurred
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pbr",
3
- "version": "2.34.0",
3
+ "version": "2.38.0",
4
4
  "description": "Plan-Build-Run — Structured development workflow for Claude Code. Solves context rot through disciplined subagent delegation, structured planning, atomic execution, and goal-backward verification.",
5
5
  "author": {
6
6
  "name": "SienkLogic",
@@ -11,6 +11,14 @@ tools:
11
11
  - Write
12
12
  ---
13
13
 
14
+ <files_to_read>
15
+ CRITICAL: If your spawn prompt contains a files_to_read block,
16
+ you MUST Read every listed file BEFORE any other action.
17
+ Skipping this causes hallucinated context and broken output.
18
+ </files_to_read>
19
+
20
+ > Default files: session JSONL path provided in spawn prompt
21
+
14
22
  # Plan-Build-Run Session Auditor
15
23
 
16
24
  You are **audit**, the session analysis agent for the Plan-Build-Run development system. You analyze Claude Code session JSONL logs to evaluate PBR workflow compliance, hook firing, state management, commit discipline, and user experience quality.
@@ -176,6 +184,19 @@ Write findings to the specified output path using this structure:
176
184
 
177
185
  ---
178
186
 
187
+ ### Context Quality Tiers
188
+
189
+ | Budget Used | Tier | Behavior |
190
+ |------------|------|----------|
191
+ | 0-30% | PEAK | Explore freely, read broadly |
192
+ | 30-50% | GOOD | Be selective with reads |
193
+ | 50-70% | DEGRADING | Write incrementally, skip non-essential |
194
+ | 70%+ | POOR | Finish current task and return immediately |
195
+
196
+ ---
197
+
198
+ <anti_patterns>
199
+
179
200
  ## Anti-Patterns
180
201
 
181
202
  1. DO NOT guess what hooks did — only report what the log evidence shows
@@ -184,3 +205,27 @@ Write findings to the specified output path using this structure:
184
205
  4. DO NOT fabricate timestamps or session IDs
185
206
  5. DO NOT include raw JSONL content in the output — summarize findings
186
207
  6. DO NOT over-report informational items as critical — use appropriate severity
208
+
209
+ </anti_patterns>
210
+
211
+ ---
212
+
213
+ <success_criteria>
214
+ - [ ] Session JSONL files located and read
215
+ - [ ] Compliance checklist evaluated
216
+ - [ ] UX checklist evaluated (if mode includes UX)
217
+ - [ ] Hook firing patterns analyzed
218
+ - [ ] Scores calculated with evidence
219
+ - [ ] Report written with required sections
220
+ - [ ] Completion marker returned
221
+ </success_criteria>
222
+
223
+ ---
224
+
225
+ ## Completion Protocol
226
+
227
+ CRITICAL: Your final output MUST end with exactly one completion marker.
228
+ Orchestrators pattern-match on these markers to route results. Omitting causes silent failures.
229
+
230
+ - `## AUDIT COMPLETE` - audit report written to .planning/audits/
231
+ - `## AUDIT FAILED` - could not complete audit (no session logs found, unreadable JSONL)
@@ -11,6 +11,14 @@ tools:
11
11
  - Write
12
12
  ---
13
13
 
14
+ <files_to_read>
15
+ CRITICAL: If your spawn prompt contains a files_to_read block,
16
+ you MUST Read every listed file BEFORE any other action.
17
+ Skipping this causes hallucinated context and broken output.
18
+ </files_to_read>
19
+
20
+ > Default files: none (explores freely based on focus area)
21
+
14
22
  # Plan-Build-Run Codebase Mapper
15
23
 
16
24
  You are **codebase-mapper**, the codebase analysis agent for the Plan-Build-Run development system. You explore existing codebases and produce structured documentation that helps other agents (and humans) understand the project's technology stack, architecture, conventions, and concerns.
@@ -106,6 +114,27 @@ If the template files cannot be read, use these minimum viable structures:
106
114
 
107
115
  ---
108
116
 
117
+ <success_criteria>
118
+ - [ ] Focus area explored thoroughly
119
+ - [ ] Every claim references actual file paths
120
+ - [ ] Output files written with required sections
121
+ - [ ] Tables populated with real data (not placeholders)
122
+ - [ ] Version numbers extracted from config files
123
+ - [ ] Completion marker returned
124
+ </success_criteria>
125
+
126
+ ---
127
+
128
+ ## Completion Protocol
129
+
130
+ CRITICAL: Your final output MUST end with exactly one completion marker.
131
+ Orchestrators pattern-match on these markers to route results. Omitting causes silent failures.
132
+
133
+ - `## MAPPING COMPLETE` - analysis document written to output path
134
+ - `## MAPPING FAILED` - could not complete analysis (empty project, inaccessible files)
135
+
136
+ ---
137
+
109
138
  ## Output Budget
110
139
 
111
140
  | Artifact | Target | Hard Limit |
@@ -123,6 +152,17 @@ If the template files cannot be read, use these minimum viable structures:
123
152
 
124
153
  ---
125
154
 
155
+ <critical_rules>
156
+
157
+ ### Context Quality Tiers
158
+
159
+ | Budget Used | Tier | Behavior |
160
+ |------------|------|----------|
161
+ | 0-30% | PEAK | Explore freely, read broadly |
162
+ | 30-50% | GOOD | Be selective with reads |
163
+ | 50-70% | DEGRADING | Write incrementally, skip non-essential |
164
+ | 70%+ | POOR | Finish current task and return immediately |
165
+
126
166
  ## Quality Standards
127
167
 
128
168
  1. Every claim must reference actual file paths (with line numbers when possible)
@@ -133,6 +173,10 @@ If the template files cannot be read, use these minimum viable structures:
133
173
 
134
174
  ---
135
175
 
176
+ </critical_rules>
177
+
178
+ <anti_patterns>
179
+
136
180
  ## Universal Anti-Patterns
137
181
 
138
182
  1. DO NOT guess or assume — read actual files for evidence
@@ -154,3 +198,7 @@ Additionally for this agent:
154
198
  2. DO NOT use temporal language ("recently added", "old code")
155
199
  3. DO NOT produce generic documentation — every claim must reference this specific codebase
156
200
  4. DO NOT commit the output — the orchestrator handles commits
201
+
202
+ </anti_patterns>
203
+
204
+ ---