@howaboua/pi-subagent-review 0.1.1 → 0.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-subagent-review",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Pi extension that adds /review via an isolated review subagent.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -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/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