supipowers 0.2.7 → 0.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.
- package/package.json +21 -6
- package/skills/debugging/SKILL.md +54 -15
- package/skills/fix-pr/SKILL.md +99 -0
- package/skills/planning/SKILL.md +70 -10
- package/skills/receiving-code-review/SKILL.md +87 -0
- package/skills/tdd/SKILL.md +83 -0
- package/skills/verification/SKILL.md +54 -0
- package/src/commands/fix-pr.ts +324 -0
- package/src/commands/plan.ts +96 -31
- package/src/commands/qa.ts +150 -29
- package/src/commands/release.ts +1 -1
- package/src/commands/review.ts +2 -2
- package/src/commands/run.ts +52 -2
- package/src/commands/supi.ts +1 -0
- package/src/commands/update.ts +2 -2
- package/src/discipline/debugging.ts +57 -0
- package/src/discipline/receiving-review.ts +65 -0
- package/src/discipline/tdd.ts +77 -0
- package/src/discipline/verification.ts +68 -0
- package/src/fix-pr/config.ts +36 -0
- package/src/fix-pr/prompt-builder.ts +201 -0
- package/src/fix-pr/scripts/diff-comments.sh +33 -0
- package/src/fix-pr/scripts/fetch-pr-comments.sh +25 -0
- package/src/fix-pr/scripts/trigger-review.sh +36 -0
- package/src/fix-pr/scripts/wait-and-check.sh +37 -0
- package/src/fix-pr/types.ts +71 -0
- package/src/git/branch-finish.ts +101 -0
- package/src/git/worktree.ts +119 -0
- package/src/index.ts +13 -2
- package/src/lsp/detector.ts +2 -2
- package/src/orchestrator/agent-prompts.ts +282 -0
- package/src/orchestrator/dispatcher.ts +150 -1
- package/src/orchestrator/prompts.ts +17 -31
- package/src/planning/plan-reviewer.ts +49 -0
- package/src/planning/plan-writer-prompt.ts +173 -0
- package/src/planning/prompt-builder.ts +178 -0
- package/src/planning/spec-reviewer.ts +43 -0
- package/src/qa/phases/discovery.ts +34 -0
- package/src/qa/phases/execution.ts +65 -0
- package/src/qa/phases/matrix.ts +41 -0
- package/src/qa/phases/reporting.ts +71 -0
- package/src/qa/session.ts +104 -0
- package/src/storage/fix-pr-sessions.ts +59 -0
- package/src/storage/qa-sessions.ts +83 -0
- package/src/storage/specs.ts +36 -0
- package/src/types.ts +70 -0
- package/src/visual/companion.ts +115 -0
- package/src/visual/prompt-instructions.ts +102 -0
- package/src/visual/scripts/frame-template.html +201 -0
- package/src/visual/scripts/helper.js +88 -0
- package/src/visual/scripts/index.js +148 -0
- package/src/visual/scripts/package.json +10 -0
- package/src/visual/scripts/start-server.sh +98 -0
- package/src/visual/scripts/stop-server.sh +21 -0
- package/src/visual/types.ts +16 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { PlanTask } from "../types.js";
|
|
2
|
+
import { buildTddInstructions } from "../discipline/tdd.js";
|
|
3
|
+
import { buildDebuggingInstructions } from "../discipline/debugging.js";
|
|
4
|
+
import { buildVerificationInstructions } from "../discipline/verification.js";
|
|
5
|
+
|
|
6
|
+
// ── Implementer Prompt ─────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
export interface ImplementerPromptOptions {
|
|
9
|
+
task: PlanTask;
|
|
10
|
+
planContext: string;
|
|
11
|
+
workDir: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Build the prompt for an implementer sub-agent.
|
|
16
|
+
* Follows superpowers' implementer-prompt.md pattern:
|
|
17
|
+
* - Full task description
|
|
18
|
+
* - Ask-before-starting section
|
|
19
|
+
* - TDD and code organization guidance
|
|
20
|
+
* - Escalation guidance
|
|
21
|
+
* - Self-review before reporting
|
|
22
|
+
* - Structured report format
|
|
23
|
+
*/
|
|
24
|
+
export function buildImplementerPrompt(options: ImplementerPromptOptions): string {
|
|
25
|
+
const { task, planContext, workDir } = options;
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
`You are implementing Task ${task.id}: ${task.name}`,
|
|
29
|
+
"",
|
|
30
|
+
"## Task Description",
|
|
31
|
+
"",
|
|
32
|
+
task.description,
|
|
33
|
+
"",
|
|
34
|
+
"## Target Files",
|
|
35
|
+
"",
|
|
36
|
+
...task.files.map((f) => `- ${f}`),
|
|
37
|
+
"",
|
|
38
|
+
"## Acceptance Criteria",
|
|
39
|
+
"",
|
|
40
|
+
task.criteria,
|
|
41
|
+
"",
|
|
42
|
+
"## Context",
|
|
43
|
+
"",
|
|
44
|
+
planContext,
|
|
45
|
+
"",
|
|
46
|
+
`Work from: ${workDir}`,
|
|
47
|
+
"",
|
|
48
|
+
"## Before You Begin",
|
|
49
|
+
"",
|
|
50
|
+
"If you have questions about:",
|
|
51
|
+
"- The requirements or acceptance criteria",
|
|
52
|
+
"- The approach or implementation strategy",
|
|
53
|
+
"- Dependencies or assumptions",
|
|
54
|
+
"- Anything unclear in the task description",
|
|
55
|
+
"",
|
|
56
|
+
"**Ask them now.** Raise any concerns before starting work.",
|
|
57
|
+
"",
|
|
58
|
+
"## Your Job",
|
|
59
|
+
"",
|
|
60
|
+
"Once you're clear on requirements:",
|
|
61
|
+
"1. Implement exactly what the task specifies",
|
|
62
|
+
"2. Write tests following TDD (write the failing test first, then implement)",
|
|
63
|
+
"3. Verify implementation works",
|
|
64
|
+
"4. Commit your work",
|
|
65
|
+
"5. Self-review (see below)",
|
|
66
|
+
"6. Report back",
|
|
67
|
+
"",
|
|
68
|
+
"**While you work:** If you encounter something unexpected or unclear, ask questions.",
|
|
69
|
+
"It's always OK to pause and clarify. Don't guess or make assumptions.",
|
|
70
|
+
"",
|
|
71
|
+
"## Code Organization",
|
|
72
|
+
"",
|
|
73
|
+
"- Follow the file structure defined in the plan",
|
|
74
|
+
"- Each file should have one clear responsibility with a well-defined interface",
|
|
75
|
+
"- If a file you're creating is growing beyond the plan's intent, stop and report as DONE_WITH_CONCERNS",
|
|
76
|
+
"- In existing codebases, follow established patterns",
|
|
77
|
+
"",
|
|
78
|
+
"## When You're in Over Your Head",
|
|
79
|
+
"",
|
|
80
|
+
"It is always OK to stop and escalate. Bad work is worse than no work.",
|
|
81
|
+
"",
|
|
82
|
+
"**STOP and escalate when:**",
|
|
83
|
+
"- The task requires architectural decisions with multiple valid approaches",
|
|
84
|
+
"- You need to understand code beyond what was provided",
|
|
85
|
+
"- You feel uncertain about whether your approach is correct",
|
|
86
|
+
"- The task involves restructuring existing code the plan didn't anticipate",
|
|
87
|
+
"",
|
|
88
|
+
"**How to escalate:** Report with status BLOCKED or NEEDS_CONTEXT.",
|
|
89
|
+
"Describe what you're stuck on, what you've tried, and what help you need.",
|
|
90
|
+
"",
|
|
91
|
+
"## Before Reporting Back: Self-Review",
|
|
92
|
+
"",
|
|
93
|
+
"Review your work with fresh eyes:",
|
|
94
|
+
"",
|
|
95
|
+
"**Completeness:**",
|
|
96
|
+
"- Did I fully implement everything in the spec?",
|
|
97
|
+
"- Did I miss any requirements?",
|
|
98
|
+
"- Are there edge cases I didn't handle?",
|
|
99
|
+
"",
|
|
100
|
+
"**Quality:**",
|
|
101
|
+
"- Is this my best work?",
|
|
102
|
+
"- Are names clear and accurate?",
|
|
103
|
+
"- Is the code clean and maintainable?",
|
|
104
|
+
"",
|
|
105
|
+
"**Discipline:**",
|
|
106
|
+
"- Did I avoid overbuilding (YAGNI)?",
|
|
107
|
+
"- Did I only build what was requested?",
|
|
108
|
+
"- Did I follow existing patterns?",
|
|
109
|
+
"",
|
|
110
|
+
"**Testing:**",
|
|
111
|
+
"- Do tests verify behavior (not mock behavior)?",
|
|
112
|
+
"- Did I follow TDD?",
|
|
113
|
+
"- Are tests comprehensive?",
|
|
114
|
+
"",
|
|
115
|
+
"If you find issues during self-review, fix them before reporting.",
|
|
116
|
+
"",
|
|
117
|
+
"## Report Format",
|
|
118
|
+
"",
|
|
119
|
+
"When done, report:",
|
|
120
|
+
"- **Status:** DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT",
|
|
121
|
+
"- What you implemented (or attempted, if blocked)",
|
|
122
|
+
"- What you tested and test results",
|
|
123
|
+
"- Files changed",
|
|
124
|
+
"- Self-review findings (if any)",
|
|
125
|
+
"- Any issues or concerns",
|
|
126
|
+
"",
|
|
127
|
+
"Use DONE_WITH_CONCERNS if you completed but have doubts.",
|
|
128
|
+
"Use BLOCKED if you cannot complete the task.",
|
|
129
|
+
"Use NEEDS_CONTEXT if you need information not provided.",
|
|
130
|
+
"Never silently produce work you're unsure about.",
|
|
131
|
+
"",
|
|
132
|
+
"---",
|
|
133
|
+
"",
|
|
134
|
+
buildTddInstructions(),
|
|
135
|
+
"",
|
|
136
|
+
"---",
|
|
137
|
+
"",
|
|
138
|
+
buildDebuggingInstructions(),
|
|
139
|
+
"",
|
|
140
|
+
"---",
|
|
141
|
+
"",
|
|
142
|
+
buildVerificationInstructions(),
|
|
143
|
+
].join("\n");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ── Spec Compliance Review Prompt ──────────────────────────────────
|
|
147
|
+
|
|
148
|
+
export interface SpecComplianceReviewOptions {
|
|
149
|
+
taskRequirements: string;
|
|
150
|
+
implementerReport: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Build the prompt for a spec compliance reviewer sub-agent.
|
|
155
|
+
* Follows superpowers' spec-reviewer-prompt.md pattern:
|
|
156
|
+
* - Do not trust the implementer's report
|
|
157
|
+
* - Verify by reading actual code
|
|
158
|
+
* - Check for missing, extra, and misunderstood requirements
|
|
159
|
+
*/
|
|
160
|
+
export function buildSpecComplianceReviewPrompt(options: SpecComplianceReviewOptions): string {
|
|
161
|
+
const { taskRequirements, implementerReport } = options;
|
|
162
|
+
|
|
163
|
+
return [
|
|
164
|
+
"You are reviewing whether an implementation matches its specification.",
|
|
165
|
+
"",
|
|
166
|
+
"## What Was Requested",
|
|
167
|
+
"",
|
|
168
|
+
taskRequirements,
|
|
169
|
+
"",
|
|
170
|
+
"## What Implementer Claims They Built",
|
|
171
|
+
"",
|
|
172
|
+
implementerReport,
|
|
173
|
+
"",
|
|
174
|
+
"## CRITICAL: Do Not Trust the Report",
|
|
175
|
+
"",
|
|
176
|
+
"The implementer's report may be incomplete, inaccurate, or optimistic.",
|
|
177
|
+
"You MUST verify everything independently.",
|
|
178
|
+
"",
|
|
179
|
+
"**DO NOT:**",
|
|
180
|
+
"- Take their word for what they implemented",
|
|
181
|
+
"- Trust their claims about completeness",
|
|
182
|
+
"- Accept their interpretation of requirements",
|
|
183
|
+
"",
|
|
184
|
+
"**DO:**",
|
|
185
|
+
"- Read the actual code they wrote",
|
|
186
|
+
"- Compare actual implementation to requirements line by line",
|
|
187
|
+
"- Check for missing pieces they claimed to implement",
|
|
188
|
+
"- Look for extra features they didn't mention",
|
|
189
|
+
"",
|
|
190
|
+
"## Your Job",
|
|
191
|
+
"",
|
|
192
|
+
"Read the implementation code and verify:",
|
|
193
|
+
"",
|
|
194
|
+
"**Missing requirements:**",
|
|
195
|
+
"- Did they implement everything that was requested?",
|
|
196
|
+
"- Are there requirements they skipped or missed?",
|
|
197
|
+
"- Did they claim something works but didn't actually implement it?",
|
|
198
|
+
"",
|
|
199
|
+
"**Extra/unneeded work:**",
|
|
200
|
+
"- Did they build things that weren't requested? Did they over-engineer?",
|
|
201
|
+
"- Did they add unnecessary features not in spec?",
|
|
202
|
+
"",
|
|
203
|
+
"**Misunderstandings:**",
|
|
204
|
+
"- Did they interpret requirements differently than intended?",
|
|
205
|
+
"- Did they solve the wrong problem?",
|
|
206
|
+
"",
|
|
207
|
+
"**Verify by reading code, not by trusting report.**",
|
|
208
|
+
"",
|
|
209
|
+
"## Output",
|
|
210
|
+
"",
|
|
211
|
+
"Report:",
|
|
212
|
+
"- **Spec compliant** — if everything matches after code inspection",
|
|
213
|
+
"- **Issues found:** [list specifically what's missing or extra, with file:line references]",
|
|
214
|
+
].join("\n");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ── Code Quality Review Prompt ─────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
export interface CodeQualityReviewOptions {
|
|
220
|
+
taskSummary: string;
|
|
221
|
+
implementerReport: string;
|
|
222
|
+
baseSha: string;
|
|
223
|
+
headSha: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Build the prompt for a code quality reviewer sub-agent.
|
|
228
|
+
* Follows superpowers' code-quality-reviewer-prompt.md pattern:
|
|
229
|
+
* - Review git diff between base and head
|
|
230
|
+
* - Check file responsibilities and unit decomposition
|
|
231
|
+
* - Categorize issues as Critical/Important/Minor
|
|
232
|
+
*/
|
|
233
|
+
export function buildCodeQualityReviewPrompt(options: CodeQualityReviewOptions): string {
|
|
234
|
+
const { taskSummary, implementerReport, baseSha, headSha } = options;
|
|
235
|
+
|
|
236
|
+
return [
|
|
237
|
+
"You are reviewing code quality for a completed implementation task.",
|
|
238
|
+
"",
|
|
239
|
+
"## What Was Implemented",
|
|
240
|
+
"",
|
|
241
|
+
taskSummary,
|
|
242
|
+
"",
|
|
243
|
+
"## Implementer Report",
|
|
244
|
+
"",
|
|
245
|
+
implementerReport,
|
|
246
|
+
"",
|
|
247
|
+
"## Git Diff",
|
|
248
|
+
"",
|
|
249
|
+
`Compare changes between base (\`${baseSha}\`) and head (\`${headSha}\`):`,
|
|
250
|
+
"",
|
|
251
|
+
`Run: \`git diff ${baseSha}..${headSha}\``,
|
|
252
|
+
"",
|
|
253
|
+
"## What to Check",
|
|
254
|
+
"",
|
|
255
|
+
"**Architecture & Design:**",
|
|
256
|
+
"- Does each file have one clear responsibility with a well-defined interface?",
|
|
257
|
+
"- Are units decomposed so they can be understood and tested independently?",
|
|
258
|
+
"- Did this implementation create new files that are already large?",
|
|
259
|
+
"",
|
|
260
|
+
"**Code Quality:**",
|
|
261
|
+
"- Correctness: Does the code do what it's supposed to?",
|
|
262
|
+
"- Security: Any injection, XSS, or other vulnerabilities?",
|
|
263
|
+
"- Performance: Any obvious performance issues?",
|
|
264
|
+
"- Maintainability: Is the code readable and well-organized?",
|
|
265
|
+
"- Error handling: Are failures handled appropriately?",
|
|
266
|
+
"",
|
|
267
|
+
"**Testing:**",
|
|
268
|
+
"- Do tests verify real behavior (not mock behavior)?",
|
|
269
|
+
"- Are edge cases covered?",
|
|
270
|
+
"- Is test coverage adequate?",
|
|
271
|
+
"",
|
|
272
|
+
"## Output",
|
|
273
|
+
"",
|
|
274
|
+
"Categorize issues by severity:",
|
|
275
|
+
"",
|
|
276
|
+
"- **Critical:** Must fix before proceeding (bugs, security issues, data loss risks)",
|
|
277
|
+
"- **Important:** Should fix before merging (code quality, maintainability)",
|
|
278
|
+
"- **Minor:** Nice to fix (style, naming, minor improvements)",
|
|
279
|
+
"",
|
|
280
|
+
"Report: Strengths, Issues (Critical/Important/Minor), Assessment",
|
|
281
|
+
].join("\n");
|
|
282
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
2
2
|
import type { PlanTask, AgentResult, AgentStatus, SupipowersConfig } from "../types.js";
|
|
3
3
|
import { buildTaskPrompt, buildFixPrompt } from "./prompts.js";
|
|
4
|
+
import {
|
|
5
|
+
buildSpecComplianceReviewPrompt,
|
|
6
|
+
buildCodeQualityReviewPrompt,
|
|
7
|
+
} from "./agent-prompts.js";
|
|
4
8
|
import { isLspAvailable } from "../lsp/detector.js";
|
|
5
|
-
import { notifySuccess, notifyWarning, notifyError } from "../notifications/renderer.js";
|
|
9
|
+
import { notifySuccess, notifyWarning, notifyError, notifyInfo } from "../notifications/renderer.js";
|
|
6
10
|
|
|
7
11
|
export interface DispatchOptions {
|
|
8
12
|
pi: ExtensionAPI;
|
|
@@ -76,6 +80,151 @@ async function executeSubAgent(
|
|
|
76
80
|
);
|
|
77
81
|
}
|
|
78
82
|
|
|
83
|
+
/** Review result from a spec compliance or code quality reviewer */
|
|
84
|
+
export interface ReviewResult {
|
|
85
|
+
passed: boolean;
|
|
86
|
+
issues: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Dispatch an implementer with 2-stage review (spec compliance + code quality).
|
|
91
|
+
* Follows superpowers' subagent-driven-development pattern:
|
|
92
|
+
* 1. Implementer implements + self-reviews
|
|
93
|
+
* 2. Spec compliance reviewer verifies implementation matches spec
|
|
94
|
+
* 3. If spec issues → re-dispatch implementer with feedback
|
|
95
|
+
* 4. Code quality reviewer checks implementation quality
|
|
96
|
+
* 5. If quality issues → re-dispatch implementer with feedback
|
|
97
|
+
*/
|
|
98
|
+
export async function dispatchAgentWithReview(
|
|
99
|
+
options: DispatchOptions & { workDir?: string },
|
|
100
|
+
): Promise<AgentResult> {
|
|
101
|
+
const { pi, ctx, task, planContext, config, lspAvailable, workDir } = options;
|
|
102
|
+
const maxReviewRetries = config.orchestration.maxFixRetries;
|
|
103
|
+
|
|
104
|
+
// Step 1: Dispatch implementer
|
|
105
|
+
let implementResult = await dispatchAgent(options);
|
|
106
|
+
|
|
107
|
+
// If blocked or needs context, skip reviews
|
|
108
|
+
if (implementResult.status === "blocked") {
|
|
109
|
+
return implementResult;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Step 2: Spec compliance review
|
|
113
|
+
for (let attempt = 0; attempt <= maxReviewRetries; attempt++) {
|
|
114
|
+
const specReview = await dispatchSpecReview(pi, task, implementResult, config);
|
|
115
|
+
|
|
116
|
+
if (specReview.passed) {
|
|
117
|
+
notifyInfo(ctx, `Task ${task.id} spec review passed`);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (attempt === maxReviewRetries) {
|
|
122
|
+
notifyWarning(ctx, `Task ${task.id} spec review failed after ${maxReviewRetries + 1} attempts`, specReview.issues);
|
|
123
|
+
implementResult.status = "done_with_concerns";
|
|
124
|
+
implementResult.concerns = `Spec compliance issues: ${specReview.issues}`;
|
|
125
|
+
return implementResult;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Re-dispatch implementer with spec review feedback
|
|
129
|
+
notifyInfo(ctx, `Task ${task.id} spec issues found, re-dispatching`, specReview.issues);
|
|
130
|
+
const fixResult = await dispatchFixAgent({
|
|
131
|
+
...options,
|
|
132
|
+
previousOutput: implementResult.output,
|
|
133
|
+
failureReason: `Spec compliance review failed:\n${specReview.issues}`,
|
|
134
|
+
});
|
|
135
|
+
implementResult = fixResult;
|
|
136
|
+
|
|
137
|
+
if (fixResult.status === "blocked") {
|
|
138
|
+
return fixResult;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Step 3: Code quality review
|
|
143
|
+
for (let attempt = 0; attempt <= maxReviewRetries; attempt++) {
|
|
144
|
+
const qualityReview = await dispatchQualityReview(pi, task, implementResult, config);
|
|
145
|
+
|
|
146
|
+
if (qualityReview.passed) {
|
|
147
|
+
notifyInfo(ctx, `Task ${task.id} quality review passed`);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (attempt === maxReviewRetries) {
|
|
152
|
+
notifyWarning(ctx, `Task ${task.id} quality review failed after ${maxReviewRetries + 1} attempts`, qualityReview.issues);
|
|
153
|
+
implementResult.status = "done_with_concerns";
|
|
154
|
+
implementResult.concerns = `Code quality issues: ${qualityReview.issues}`;
|
|
155
|
+
return implementResult;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Re-dispatch implementer with quality review feedback
|
|
159
|
+
notifyInfo(ctx, `Task ${task.id} quality issues found, re-dispatching`, qualityReview.issues);
|
|
160
|
+
const fixResult = await dispatchFixAgent({
|
|
161
|
+
...options,
|
|
162
|
+
previousOutput: implementResult.output,
|
|
163
|
+
failureReason: `Code quality review failed:\n${qualityReview.issues}`,
|
|
164
|
+
});
|
|
165
|
+
implementResult = fixResult;
|
|
166
|
+
|
|
167
|
+
if (fixResult.status === "blocked") {
|
|
168
|
+
return fixResult;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return implementResult;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Dispatch a spec compliance reviewer sub-agent */
|
|
176
|
+
async function dispatchSpecReview(
|
|
177
|
+
pi: ExtensionAPI,
|
|
178
|
+
task: PlanTask,
|
|
179
|
+
implementResult: AgentResult,
|
|
180
|
+
config: SupipowersConfig,
|
|
181
|
+
): Promise<ReviewResult> {
|
|
182
|
+
const prompt = buildSpecComplianceReviewPrompt({
|
|
183
|
+
taskRequirements: `Task: ${task.name}\n\n${task.description}\n\nAcceptance Criteria: ${task.criteria}`,
|
|
184
|
+
implementerReport: implementResult.output,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
const result = await executeSubAgent(pi, prompt, task, config);
|
|
189
|
+
const passed = result.status === "done" ||
|
|
190
|
+
result.output.toLowerCase().includes("spec compliant");
|
|
191
|
+
return {
|
|
192
|
+
passed,
|
|
193
|
+
issues: passed ? "" : result.output,
|
|
194
|
+
};
|
|
195
|
+
} catch {
|
|
196
|
+
// If reviewer fails, pass through — don't block on reviewer errors
|
|
197
|
+
return { passed: true, issues: "" };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Dispatch a code quality reviewer sub-agent */
|
|
202
|
+
async function dispatchQualityReview(
|
|
203
|
+
pi: ExtensionAPI,
|
|
204
|
+
task: PlanTask,
|
|
205
|
+
implementResult: AgentResult,
|
|
206
|
+
config: SupipowersConfig,
|
|
207
|
+
): Promise<ReviewResult> {
|
|
208
|
+
const prompt = buildCodeQualityReviewPrompt({
|
|
209
|
+
taskSummary: `Task ${task.id}: ${task.name}\n\n${task.description}`,
|
|
210
|
+
implementerReport: implementResult.output,
|
|
211
|
+
baseSha: "HEAD~1",
|
|
212
|
+
headSha: "HEAD",
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
const result = await executeSubAgent(pi, prompt, task, config);
|
|
217
|
+
const hasCritical = result.output.toLowerCase().includes("critical");
|
|
218
|
+
return {
|
|
219
|
+
passed: !hasCritical,
|
|
220
|
+
issues: hasCritical ? result.output : "",
|
|
221
|
+
};
|
|
222
|
+
} catch {
|
|
223
|
+
// If reviewer fails, pass through
|
|
224
|
+
return { passed: true, issues: "" };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
79
228
|
export async function dispatchFixAgent(
|
|
80
229
|
options: DispatchOptions & { previousOutput: string; failureReason: string }
|
|
81
230
|
): Promise<AgentResult> {
|
|
@@ -1,44 +1,26 @@
|
|
|
1
1
|
// src/orchestrator/prompts.ts
|
|
2
2
|
import type { PlanTask, SupipowersConfig } from "../types.js";
|
|
3
3
|
import { buildLspValidationPrompt } from "../lsp/bridge.js";
|
|
4
|
+
import { buildImplementerPrompt } from "./agent-prompts.js";
|
|
5
|
+
import { buildReceivingReviewInstructions } from "../discipline/receiving-review.js";
|
|
4
6
|
|
|
5
7
|
/** Build the system prompt for a sub-agent executing a task */
|
|
6
8
|
export function buildTaskPrompt(
|
|
7
9
|
task: PlanTask,
|
|
8
10
|
planContext: string,
|
|
9
11
|
config: SupipowersConfig,
|
|
10
|
-
lspAvailable: boolean
|
|
12
|
+
lspAvailable: boolean,
|
|
13
|
+
workDir?: string,
|
|
11
14
|
): string {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
"",
|
|
15
|
-
`## Task: ${task.name}`,
|
|
16
|
-
"",
|
|
17
|
-
task.description,
|
|
18
|
-
"",
|
|
19
|
-
"## Target Files",
|
|
20
|
-
...task.files.map((f) => `- ${f}`),
|
|
21
|
-
"",
|
|
22
|
-
"## Acceptance Criteria",
|
|
23
|
-
task.criteria,
|
|
24
|
-
"",
|
|
25
|
-
"## Context",
|
|
15
|
+
const prompt = buildImplementerPrompt({
|
|
16
|
+
task,
|
|
26
17
|
planContext,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"1. Read the target files to understand current state",
|
|
30
|
-
"2. Implement the changes described above",
|
|
31
|
-
"3. Ensure acceptance criteria are met",
|
|
32
|
-
"4. Report your status when done",
|
|
33
|
-
"",
|
|
34
|
-
"Report one of these statuses:",
|
|
35
|
-
"- DONE: Task completed successfully, all criteria met",
|
|
36
|
-
"- DONE_WITH_CONCERNS: Completed but with caveats (explain what)",
|
|
37
|
-
"- BLOCKED: Cannot complete (explain why and what's needed)",
|
|
38
|
-
];
|
|
18
|
+
workDir: workDir ?? process.cwd(),
|
|
19
|
+
});
|
|
39
20
|
|
|
40
21
|
if (lspAvailable) {
|
|
41
|
-
|
|
22
|
+
return [
|
|
23
|
+
prompt,
|
|
42
24
|
"",
|
|
43
25
|
"## LSP Available",
|
|
44
26
|
"You have access to the LSP tool. Use it to:",
|
|
@@ -46,11 +28,11 @@ export function buildTaskPrompt(
|
|
|
46
28
|
"- Find references before renaming symbols",
|
|
47
29
|
"- Validate your work has no type errors",
|
|
48
30
|
"",
|
|
49
|
-
buildLspValidationPrompt(task.files)
|
|
50
|
-
);
|
|
31
|
+
buildLspValidationPrompt(task.files),
|
|
32
|
+
].join("\n");
|
|
51
33
|
}
|
|
52
34
|
|
|
53
|
-
return
|
|
35
|
+
return prompt;
|
|
54
36
|
}
|
|
55
37
|
|
|
56
38
|
/** Build prompt for a fix agent */
|
|
@@ -82,6 +64,10 @@ export function buildFixPrompt(
|
|
|
82
64
|
"2. Identify and fix the issue",
|
|
83
65
|
"3. Verify the acceptance criteria are now met",
|
|
84
66
|
"4. Report your status",
|
|
67
|
+
"",
|
|
68
|
+
"---",
|
|
69
|
+
"",
|
|
70
|
+
buildReceivingReviewInstructions(),
|
|
85
71
|
];
|
|
86
72
|
|
|
87
73
|
if (lspAvailable) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the prompt for dispatching a plan document reviewer sub-agent.
|
|
3
|
+
* Follows the same pattern as superpowers' plan-document-reviewer-prompt.md.
|
|
4
|
+
*/
|
|
5
|
+
export function buildPlanReviewerPrompt(
|
|
6
|
+
planFilePath: string,
|
|
7
|
+
specFilePath: string,
|
|
8
|
+
chunkNumber: number,
|
|
9
|
+
): string {
|
|
10
|
+
return [
|
|
11
|
+
"You are a plan document reviewer. Verify this plan chunk is complete and ready for implementation.",
|
|
12
|
+
"",
|
|
13
|
+
`**Plan chunk to review:** ${planFilePath} — Chunk ${chunkNumber} only`,
|
|
14
|
+
`**Spec for reference:** ${specFilePath}`,
|
|
15
|
+
"",
|
|
16
|
+
"## What to Check",
|
|
17
|
+
"",
|
|
18
|
+
"| Category | What to Look For |",
|
|
19
|
+
"|----------|------------------|",
|
|
20
|
+
"| Completeness | TODO markers, placeholders, incomplete tasks, missing steps |",
|
|
21
|
+
"| Spec Alignment | Chunk covers relevant spec requirements, no scope creep |",
|
|
22
|
+
"| Task Decomposition | Tasks atomic, clear boundaries, steps actionable |",
|
|
23
|
+
"| File Structure | Files have clear single responsibilities, split by responsibility not layer |",
|
|
24
|
+
"| File Size | Would any new or modified file likely grow large enough to be hard to reason about? |",
|
|
25
|
+
"| Checkbox Syntax | Steps use checkbox (`- [ ]`) syntax for tracking |",
|
|
26
|
+
"| Chunk Size | Each chunk under 1000 lines |",
|
|
27
|
+
"",
|
|
28
|
+
"## Critical",
|
|
29
|
+
"",
|
|
30
|
+
"Look especially hard for:",
|
|
31
|
+
"- Any TODO markers or placeholder text",
|
|
32
|
+
'- Steps that say "similar to X" without actual content',
|
|
33
|
+
"- Incomplete task definitions",
|
|
34
|
+
"- Missing verification steps or expected outputs",
|
|
35
|
+
"- Files planned to hold multiple responsibilities or likely to grow unwieldy",
|
|
36
|
+
"",
|
|
37
|
+
"## Output Format",
|
|
38
|
+
"",
|
|
39
|
+
`## Plan Review — Chunk ${chunkNumber}`,
|
|
40
|
+
"",
|
|
41
|
+
"**Status:** Approved | Issues Found",
|
|
42
|
+
"",
|
|
43
|
+
"**Issues (if any):**",
|
|
44
|
+
"- [Task X, Step Y]: [specific issue] — [why it matters]",
|
|
45
|
+
"",
|
|
46
|
+
"**Recommendations (advisory):**",
|
|
47
|
+
"- [suggestions that don't block approval]",
|
|
48
|
+
].join("\n");
|
|
49
|
+
}
|