@howaboua/pi-subagent-review 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/review-command.ts +2 -1
- package/src/review.ts +1 -1
- package/src/subagent.ts +10 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- `/review`
|
|
6
6
|
|
|
7
|
-
It runs an isolated review subagent against your current repo, injects the findings back into the session as a user message, and the main agent
|
|
7
|
+
It runs an isolated review subagent against your current repo, injects the findings back into the session as a user message, and asks the main agent to consider those findings in light of the prior conversation before deciding what to address. It is modelled after Codex CLI's /review command.
|
|
8
8
|
|
|
9
9
|
## What it does
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ It runs an isolated review subagent against your current repo, injects the findi
|
|
|
15
15
|
- inspects committed and dirty worktree changes
|
|
16
16
|
- runs an isolated review subagent
|
|
17
17
|
- sends the findings back into the current Pi session as a user message
|
|
18
|
-
- as a result, the main agent
|
|
18
|
+
- as a result, the main agent reviews the findings against the prior conversation and addresses only clearly worthwhile issues
|
|
19
19
|
|
|
20
20
|
## Automatic base branch selection
|
|
21
21
|
|
package/package.json
CHANGED
package/src/review-command.ts
CHANGED
|
@@ -37,7 +37,8 @@ export function registerReviewCommand(pi: ExtensionAPI) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
details = await runReviewSubagent(task, review.repoRoot, reviewConfig);
|
|
40
|
+
details = await runReviewSubagent(task, review.repoRoot, reviewConfig, ctx.signal);
|
|
41
|
+
if (ctx.signal?.aborted) return;
|
|
41
42
|
const finalOutput = getFinalOutput(details.messages).trim() || "No actionable issues found.";
|
|
42
43
|
if (isSubagentFailure(details)) throw new Error(details.errorMessage || details.stderr || finalOutput);
|
|
43
44
|
|
package/src/review.ts
CHANGED
|
@@ -140,6 +140,6 @@ export function buildReviewUserMessage(review: ReviewContext, findings: string):
|
|
|
140
140
|
"",
|
|
141
141
|
findings.trim() || "No actionable issues found.",
|
|
142
142
|
"",
|
|
143
|
-
"
|
|
143
|
+
"Review the findings above in light of the prior conversation. Some choices may reflect intentional decisions the review subagent could not see; address only clearly worthwhile issues, and ask before changing context-dependent, low-impact, or diminishing-return items.",
|
|
144
144
|
].join("\n");
|
|
145
145
|
}
|
package/src/subagent.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function getFinalOutput(messages: any[]): string {
|
|
|
18
18
|
return "";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export async function runReviewSubagent(task: string, cwd: string, config: Required<ReviewConfig
|
|
21
|
+
export async function runReviewSubagent(task: string, cwd: string, config: Required<ReviewConfig>, signal?: AbortSignal) {
|
|
22
22
|
const details = createChildRunDetails(task, cwd, config);
|
|
23
23
|
const args = [
|
|
24
24
|
"--mode",
|
|
@@ -147,6 +147,11 @@ export async function runReviewSubagent(task: string, cwd: string, config: Requi
|
|
|
147
147
|
]);
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
const abortProcess = () => {
|
|
151
|
+
void stopProcess();
|
|
152
|
+
};
|
|
153
|
+
signal?.addEventListener("abort", abortProcess, { once: true });
|
|
154
|
+
|
|
150
155
|
proc.stdout.on("data", (chunk) => {
|
|
151
156
|
stdoutBuffer += chunk.toString();
|
|
152
157
|
const lines = stdoutBuffer.split("\n");
|
|
@@ -173,13 +178,16 @@ export async function runReviewSubagent(task: string, cwd: string, config: Requi
|
|
|
173
178
|
});
|
|
174
179
|
|
|
175
180
|
try {
|
|
181
|
+
if (signal?.aborted) throw new Error(`${REVIEW_LABEL} aborted.`);
|
|
176
182
|
await sendCommand({ type: "get_state" }, RPC_READY_TIMEOUT_MS);
|
|
183
|
+
if (signal?.aborted) throw new Error(`${REVIEW_LABEL} aborted.`);
|
|
177
184
|
await sendCommand({ type: "set_auto_compaction", enabled: true });
|
|
178
185
|
await sendCommand({ type: "set_auto_retry", enabled: true });
|
|
179
186
|
await sendCommand({ type: "prompt", message: promptText });
|
|
180
187
|
promptSent = true;
|
|
181
188
|
|
|
182
189
|
while (true) {
|
|
190
|
+
if (signal?.aborted) throw new Error(`${REVIEW_LABEL} aborted.`);
|
|
183
191
|
if (processClosed) break;
|
|
184
192
|
await sleep(RPC_POLL_MS);
|
|
185
193
|
let state: { isStreaming: boolean; isCompacting: boolean; pendingMessageCount: number };
|
|
@@ -194,6 +202,7 @@ export async function runReviewSubagent(task: string, cwd: string, config: Requi
|
|
|
194
202
|
if (promptSent && agentEndCount > 0 && isIdle && isQuiet) break;
|
|
195
203
|
}
|
|
196
204
|
} finally {
|
|
205
|
+
signal?.removeEventListener("abort", abortProcess);
|
|
197
206
|
await stopProcess();
|
|
198
207
|
}
|
|
199
208
|
|