@sienklogic/plan-build-run 2.37.0 → 2.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.json +1 -1
  3. package/plugins/copilot-pbr/agents/audit.agent.md +1 -0
  4. package/plugins/copilot-pbr/agents/codebase-mapper.agent.md +1 -0
  5. package/plugins/copilot-pbr/agents/debugger.agent.md +3 -0
  6. package/plugins/copilot-pbr/agents/dev-sync.agent.md +23 -0
  7. package/plugins/copilot-pbr/agents/executor.agent.md +1 -0
  8. package/plugins/copilot-pbr/agents/integration-checker.agent.md +7 -4
  9. package/plugins/copilot-pbr/agents/planner.agent.md +27 -1
  10. package/plugins/copilot-pbr/agents/researcher.agent.md +4 -1
  11. package/plugins/copilot-pbr/agents/verifier.agent.md +29 -12
  12. package/plugins/copilot-pbr/commands/test.md +5 -0
  13. package/plugins/copilot-pbr/plugin.json +1 -1
  14. package/plugins/copilot-pbr/references/plan-authoring.md +28 -0
  15. package/plugins/copilot-pbr/references/verification-patterns.md +44 -17
  16. package/plugins/copilot-pbr/skills/config/SKILL.md +12 -2
  17. package/plugins/copilot-pbr/skills/health/SKILL.md +13 -5
  18. package/plugins/copilot-pbr/skills/setup/SKILL.md +9 -1
  19. package/plugins/copilot-pbr/skills/shared/context-budget.md +10 -0
  20. package/plugins/copilot-pbr/skills/shared/universal-anti-patterns.md +6 -0
  21. package/plugins/copilot-pbr/skills/test/SKILL.md +210 -0
  22. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  23. package/plugins/cursor-pbr/agents/audit.md +1 -0
  24. package/plugins/cursor-pbr/agents/codebase-mapper.md +1 -0
  25. package/plugins/cursor-pbr/agents/debugger.md +3 -0
  26. package/plugins/cursor-pbr/agents/dev-sync.md +23 -0
  27. package/plugins/cursor-pbr/agents/executor.md +1 -0
  28. package/plugins/cursor-pbr/agents/integration-checker.md +7 -4
  29. package/plugins/cursor-pbr/agents/planner.md +27 -1
  30. package/plugins/cursor-pbr/agents/researcher.md +4 -1
  31. package/plugins/cursor-pbr/agents/verifier.md +29 -12
  32. package/plugins/cursor-pbr/commands/test.md +5 -0
  33. package/plugins/cursor-pbr/references/plan-authoring.md +28 -0
  34. package/plugins/cursor-pbr/references/verification-patterns.md +44 -17
  35. package/plugins/cursor-pbr/skills/config/SKILL.md +12 -2
  36. package/plugins/cursor-pbr/skills/health/SKILL.md +14 -5
  37. package/plugins/cursor-pbr/skills/setup/SKILL.md +9 -1
  38. package/plugins/cursor-pbr/skills/shared/context-budget.md +10 -0
  39. package/plugins/cursor-pbr/skills/shared/universal-anti-patterns.md +6 -0
  40. package/plugins/cursor-pbr/skills/test/SKILL.md +211 -0
  41. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
  42. package/plugins/pbr/agents/audit.md +1 -0
  43. package/plugins/pbr/agents/codebase-mapper.md +1 -0
  44. package/plugins/pbr/agents/debugger.md +3 -0
  45. package/plugins/pbr/agents/dev-sync.md +23 -0
  46. package/plugins/pbr/agents/executor.md +1 -0
  47. package/plugins/pbr/agents/integration-checker.md +7 -4
  48. package/plugins/pbr/agents/planner.md +27 -1
  49. package/plugins/pbr/agents/researcher.md +4 -1
  50. package/plugins/pbr/agents/verifier.md +29 -12
  51. package/plugins/pbr/commands/test.md +5 -0
  52. package/plugins/pbr/references/plan-authoring.md +28 -0
  53. package/plugins/pbr/references/verification-patterns.md +44 -17
  54. package/plugins/pbr/scripts/context-bridge.js +15 -9
  55. package/plugins/pbr/scripts/lib/config.js +96 -3
  56. package/plugins/pbr/scripts/lib/core.js +9 -0
  57. package/plugins/pbr/scripts/lib/migrate.js +169 -0
  58. package/plugins/pbr/scripts/lib/todo.js +300 -0
  59. package/plugins/pbr/scripts/pbr-tools.js +82 -3
  60. package/plugins/pbr/skills/config/SKILL.md +12 -2
  61. package/plugins/pbr/skills/health/SKILL.md +14 -3
  62. package/plugins/pbr/skills/help/SKILL.md +2 -0
  63. package/plugins/pbr/skills/setup/SKILL.md +9 -1
  64. package/plugins/pbr/skills/shared/context-budget.md +10 -0
  65. package/plugins/pbr/skills/shared/universal-anti-patterns.md +6 -0
  66. package/plugins/pbr/skills/test/SKILL.md +212 -0
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: test
3
+ description: "Generate tests for completed phase code. Detects test framework and targets key files."
4
+ allowed-tools: Read, Write, Bash, Glob, Grep, Task, AskUserQuestion
5
+ argument-hint: "<phase-number>"
6
+ ---
7
+
8
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
9
+
10
+ # /pbr:test — Post-Phase Test Generation
11
+
12
+ 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.
13
+
14
+ ## Context Budget
15
+
16
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
17
+
18
+ Additionally for this skill:
19
+ - **Delegate** all test writing to executor subagents — never write test code in the main context
20
+ - Read only SUMMARY.md frontmatter for `key_files` lists — do not read full summaries
21
+
22
+ ## Step 0 — Immediate Output
23
+
24
+ **Before ANY tool calls**, display this banner:
25
+
26
+ ```
27
+ ╔══════════════════════════════════════════════════════════════╗
28
+ ║ PLAN-BUILD-RUN ► GENERATING TESTS FOR PHASE {N} ║
29
+ ╚══════════════════════════════════════════════════════════════╝
30
+ ```
31
+
32
+ Where `{N}` is the phase number from `$ARGUMENTS`. Then proceed to Step 1.
33
+
34
+ ## Prerequisites
35
+
36
+ - `.planning/config.json` exists
37
+ - Phase has been built: SUMMARY.md files exist in `.planning/phases/{NN}-{slug}/`
38
+ - 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)
39
+
40
+ ---
41
+
42
+ ## Argument Parsing
43
+
44
+ Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
45
+
46
+ | Argument | Meaning |
47
+ |----------|---------|
48
+ | `3` | Generate tests for phase 3 |
49
+ | (no number) | Use current phase from STATE.md |
50
+
51
+ ---
52
+
53
+ ## Step 1 — Gather Context
54
+
55
+ **CRITICAL: Run init command to load project state efficiently.**
56
+
57
+ ```bash
58
+ node "${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js" init execute-phase {phase_number}
59
+ ```
60
+
61
+ This returns STATE.md snapshot, phase plans, ROADMAP excerpt, and config — all in one call.
62
+
63
+ ## Step 2 — Detect Test Framework
64
+
65
+ Scan the project root for test framework indicators:
66
+
67
+ 1. Check `package.json` for `jest`, `vitest`, `mocha`, `ava` in devDependencies
68
+ 2. Check for `pytest.ini`, `pyproject.toml` (with `[tool.pytest]`), `setup.cfg` (with `[tool:pytest]`)
69
+ 3. Check for `jest.config.*`, `vitest.config.*`, `.mocharc.*`
70
+ 4. Check for existing test directories: `tests/`, `test/`, `__tests__/`, `spec/`
71
+ 5. Check for existing test file patterns: `*.test.*`, `*.spec.*`, `test_*.py`
72
+
73
+ If no test framework is detected, ask the user:
74
+
75
+ Use AskUserQuestion:
76
+ question: "No test framework detected. Which should I use?"
77
+ header: "Framework"
78
+ options:
79
+ - label: "Jest" description: "JavaScript/TypeScript testing (most common)"
80
+ - label: "Vitest" description: "Vite-native testing (faster, ESM-friendly)"
81
+ - label: "pytest" description: "Python testing framework"
82
+ multiSelect: false
83
+
84
+ ## Step 3 — Collect Target Files
85
+
86
+ Read SUMMARY.md frontmatter from each plan in the phase to extract `key_files`:
87
+
88
+ ```bash
89
+ node "${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js" frontmatter .planning/phases/{NN}-{slug}/SUMMARY.md
90
+ ```
91
+
92
+ Collect all `key_files` across all plans in the phase. Filter to only source files (exclude config, docs, assets). Group by:
93
+ - **High priority**: Files with business logic, API endpoints, data models
94
+ - **Medium priority**: Utility functions, helpers, middleware
95
+ - **Low priority**: Config, types-only files, constants
96
+
97
+ Present the file list to the user:
98
+
99
+ Use AskUserQuestion:
100
+ question: "Found {N} source files from phase {P}. Generate tests for which?"
101
+ header: "Scope"
102
+ options:
103
+ - label: "High priority only" description: "{X} files — business logic, APIs, models"
104
+ - label: "High + Medium" description: "{Y} files — adds utilities and helpers"
105
+ - label: "All files" description: "{Z} files — comprehensive coverage"
106
+ multiSelect: false
107
+
108
+ ## Step 4 — Generate Test Plans
109
+
110
+ For each target file, create a lightweight test plan (NOT a full PBR PLAN.md — just a task list):
111
+
112
+ ```
113
+ File: src/auth/login.js
114
+ Tests to generate:
115
+ - Happy path: valid credentials return token
116
+ - Error: invalid password returns 401
117
+ - Error: missing email returns 400
118
+ - Edge: expired session handling
119
+ Framework: jest
120
+ Output: tests/auth/login.test.js
121
+ ```
122
+
123
+ ## Step 5 — Spawn Executor Agents
124
+
125
+ **CRITICAL: Delegate ALL test writing to subagents. Do NOT write test code in the main context.**
126
+
127
+ For each target file (or batch of related files), spawn an executor agent:
128
+
129
+ ```
130
+ Spawn subagent_type: "pbr:executor"
131
+
132
+ Task: Generate tests for the following file(s):
133
+
134
+ <files_to_test>
135
+ {file_path}: {brief description from SUMMARY}
136
+ </files_to_test>
137
+
138
+ <test_framework>
139
+ {detected framework name and version}
140
+ Existing test directory: {path}
141
+ Test file naming: {pattern, e.g., *.test.js}
142
+ </test_framework>
143
+
144
+ <test_plan>
145
+ {test plan from Step 4}
146
+ </test_plan>
147
+
148
+ Instructions:
149
+ 1. Read each source file to understand the implementation
150
+ 2. Write test files following the project's existing test patterns
151
+ 3. Each test file should cover: happy path, error cases, edge cases
152
+ 4. Use the project's existing mocking patterns if any exist
153
+ 5. Run the tests to verify they pass: {test command}
154
+ 6. Commit with format: test({phase}-tests): add tests for {file}
155
+ ```
156
+
157
+ Spawn up to `parallelization.max_concurrent_agents` agents in parallel for independent files.
158
+
159
+ ## Step 6 — Verify and Report
160
+
161
+ After all agents complete, check results:
162
+
163
+ 1. Glob for new test files created in this session
164
+ 2. Run the test suite to verify all new tests pass:
165
+ ```bash
166
+ {test_command}
167
+ ```
168
+ 3. Count: files tested, tests written, tests passing
169
+
170
+ Display completion:
171
+
172
+ ```
173
+ ╔══════════════════════════════════════════════════════════════╗
174
+ ║ PLAN-BUILD-RUN ► TESTS GENERATED ✓ ║
175
+ ╚══════════════════════════════════════════════════════════════╝
176
+
177
+ Phase {N}: {X} test files created, {Y} tests passing
178
+
179
+ Files tested:
180
+ - src/auth/login.js → tests/auth/login.test.js (8 tests)
181
+ - src/api/users.js → tests/api/users.test.js (12 tests)
182
+
183
+
184
+
185
+ ╔══════════════════════════════════════════════════════════════╗
186
+ ║ ▶ NEXT UP ║
187
+ ╚══════════════════════════════════════════════════════════════╝
188
+
189
+ **Run coverage check** to see how much is covered
190
+
191
+ `npm test -- --coverage`
192
+
193
+ <sub>`/clear` first → fresh context window</sub>
194
+
195
+
196
+
197
+ **Also available:**
198
+ - `/pbr:review {N}` — verify the full phase
199
+ - `/pbr:continue` — execute next logical step
200
+
201
+
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Anti-Patterns
207
+
208
+ 1. **DO NOT** write test code in the main orchestrator context — always delegate to executor agents
209
+ 2. **DO NOT** generate tests for files not listed in SUMMARY.md key_files — stay scoped to the phase
210
+ 3. **DO NOT** skip running the tests — always verify they pass before reporting success
211
+ 4. **DO NOT** generate trivial tests (testing getters/setters, testing constants) — focus on behavior
212
+ 5. **DO NOT** read full source files in the orchestrator — let the executor agents read them