@juanbenjumea/pi-agy 0.5.4 → 0.5.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.5
4
+
5
+ - Preserve completed responses past the deadline: a result that fully arrived before cancellation or timeout is returned with an explanatory note instead of being discarded — previously a kill landing between delivery and process exit threw the finished response away.
6
+ - Post-run steps cut short by the deadline (diff summary) are skipped with a note instead of failing the whole run after agy already finished.
7
+ - Persist the conversation under a fresh bounded signal on the success path too, so a save racing the deadline still records the resumable id.
8
+
3
9
  ## 0.5.4
4
10
 
5
11
  - Fix pre-existing unstaged modifications being misattributed to agy: porcelain paths are now parsed by fixed column — `line.trim()` before `slice(3)` ate the path's first character for ` M` lines, so unstaged dirt never matched `diff --name-only` and always looked newly-dirty. Found by the agy plan-mode cross-review.
@@ -1009,6 +1009,14 @@ function spawnAgyInternal(
1009
1009
  runResult = processStreamLine(lineBuffer, runResult, onProgress);
1010
1010
  }
1011
1011
 
1012
+ // A fully delivered result outranks the kill: when cancellation or
1013
+ // timeout lands after the response arrived, the work is done and the
1014
+ // response must not be discarded.
1015
+ if (runResult.response_complete) {
1016
+ resolve(finalizeRunResult(out, runResult));
1017
+ return;
1018
+ }
1019
+
1012
1020
  if (sig === "SIGTERM" || sig === "SIGKILL" || code === null) {
1013
1021
  reject(
1014
1022
  withConversationId(
@@ -185,13 +185,19 @@ export async function executeAgyTask(
185
185
 
186
186
  if (run.conversation_id) {
187
187
  try {
188
- await saveSession(options.dir, run.conversation_id, effectiveModel, abortSignal);
188
+ // Fresh bounded signal: the composed one may already be aborted
189
+ // when the run finished at the deadline edge (see below).
190
+ await saveSession(
191
+ options.dir,
192
+ run.conversation_id,
193
+ effectiveModel,
194
+ AbortSignal.timeout(10_000),
195
+ );
189
196
  } catch (error) {
190
197
  const reason = error instanceof Error ? error.message : String(error);
191
198
  onProgress?.(`agy: warning — could not persist session: ${reason}`);
192
199
  }
193
200
  }
194
- remainingBudget(startedAt, options.timeout_ms);
195
201
 
196
202
  let text = run.response;
197
203
  const quotaSummary = quota?.models.length
@@ -200,16 +206,23 @@ export async function executeAgyTask(
200
206
  if (quotaSummary) text = `${text}\n\n## agy quota snapshot\n${quotaSummary}`;
201
207
  let changedFiles: string[] | undefined;
202
208
  let preexistingFiles: string[] | undefined;
209
+ // The agy run itself is complete; from here, an expiring budget or a
210
+ // racing cancellation must never discard its response. Skip the
211
+ // post-run steps with a note instead of throwing the result away.
203
212
  if (options.mode === "accept-edits") {
204
- const diff = await summarizeGitDiffSince(baseline, options.dir, abortSignal);
205
- if (diff.summary) text = `${text}\n\n${diff.summary}`;
206
- changedFiles = diff.newFiles;
207
- preexistingFiles = diff.preexistingFiles;
213
+ try {
214
+ const diff = await summarizeGitDiffSince(baseline, options.dir, abortSignal);
215
+ if (diff.summary) text = `${text}\n\n${diff.summary}`;
216
+ changedFiles = diff.newFiles;
217
+ preexistingFiles = diff.preexistingFiles;
218
+ } catch (error) {
219
+ if (!abortSignal.aborted) throw error;
220
+ text += "\n\n(diff summary skipped: the run reached its deadline as agy finished)";
221
+ }
208
222
  }
209
223
  if (abortSignal.aborted) {
210
- throw new Error(signal?.aborted ? "agy was cancelled" : "agy timed out");
224
+ text += `\n\nagy finished as the run was ${signal?.aborted ? "cancelled" : "timing out"}; the completed result is preserved.`;
211
225
  }
212
- remainingBudget(startedAt, options.timeout_ms);
213
226
 
214
227
  return {
215
228
  text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juanbenjumea/pi-agy",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Enhanced Antigravity CLI (agy) bridge for Pi — streaming progress, conversation continuity, repo-aware verify, and diff summaries.",
5
5
  "type": "module",
6
6
  "license": "MIT",