@juanbenjumea/pi-agy 0.5.9 → 0.6.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/CHANGELOG.md +17 -0
- package/README.md +11 -3
- package/extensions/commands.ts +3 -13
- package/extensions/index.ts +52 -1
- package/extensions/lib/cli.ts +13 -2
- package/extensions/lib/execute.ts +86 -20
- package/extensions/lib/output.ts +12 -0
- package/extensions/lib/sessions.ts +22 -3
- package/package.json +1 -1
- package/skills/agy/SKILL.md +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
- Omit unsupported `--effort` flags for Claude thinking and Gemini variant aliases; retain effort selection for GPT-OSS.
|
|
6
|
+
- Refresh quota state after `RESOURCE_EXHAUSTED` responses and back off before retrying.
|
|
7
|
+
- Automatically fall back from an exhausted implicit quota-balanced default while preserving explicit model selections.
|
|
8
|
+
- Add regression coverage for the agy 1.2.7 model and quota behavior.
|
|
9
|
+
|
|
10
|
+
## 0.6.1
|
|
11
|
+
|
|
12
|
+
- Supersede 0.6.0, whose publish run failed: a fixed 300 ms abort in two delivery-vs-cancellation tests raced preflight on slow CI runners (the abort must land after the result arrives). The cancels are now event-driven (fired when the SUCCESS progress arrives, i.e. strictly after delivery) and tight budget margins widened 6×.
|
|
13
|
+
|
|
14
|
+
## 0.6.0
|
|
15
|
+
|
|
16
|
+
- New `agy_history` tool: list recorded agy conversations for a working directory (ids, models, ages, task summaries) so agents can discover and resume past work without remembering ids; read-only, no model turn spent.
|
|
17
|
+
- Record a one-line task summary (collapsed first ~80 chars of the prompt) with every saved conversation — surfaced in `agy_history` and the `/agy sessions` picker; stored locally, backward compatible with existing stores.
|
|
18
|
+
- `getHistory` normalizes entries (drops malformed fields, keeps only known ones).
|
|
19
|
+
|
|
3
20
|
## 0.5.9
|
|
4
21
|
|
|
5
22
|
- Parse the real agy 1.2.6 `/usage` schema (`command.data.groups[].buckets[]`): usage groups carry the model family in `name`, which the quota reader now honors — live runs previously fell back to dumping the raw JSON envelope and reported `quota_status: unknown`. Found by an end-to-end run against the real CLI.
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Requires Node.js >= 20.3.
|
|
|
18
18
|
|---------|----------|-----------|
|
|
19
19
|
| Live progress | Final text only | `stream-json` → Pi `onUpdate` cards |
|
|
20
20
|
| Model aliases | Hardcoded ids | Live `agy models` catalog (newest stable generation wins; preview/experimental ignored), static map fallback |
|
|
21
|
-
| Conversation resume | None | `conversation_id`, `continue`, session store, `/agy sessions` picker — runs that time out or are cancelled are recorded too |
|
|
21
|
+
| Conversation resume | None | `conversation_id`, `continue`, session store with task summaries, `/agy sessions` picker, `agy_history` discovery tool — runs that time out or are cancelled are recorded too |
|
|
22
22
|
| Verify injection | `npm test` only | `just ci` first, then `npm test`/`uv run pytest` |
|
|
23
23
|
| Post-write summary | None | Appends `git diff --stat` for newly-dirty files only; pre-existing dirt (including renames and unstaged edits) is listed separately and never misattributed |
|
|
24
24
|
| Preflight | Every call | Health/model checks cached 5 min per process; model quotas refresh every minute |
|
|
@@ -53,7 +53,7 @@ The deadline never discards finished work:
|
|
|
53
53
|
| `conversation_id` | Resume agy conversation by ID |
|
|
54
54
|
| `continue` | `--continue` most recent conversation |
|
|
55
55
|
| `new_session` | Force fresh session; set `false` to reuse last ID for dir |
|
|
56
|
-
| `effort` | Reasoning effort via `--effort`
|
|
56
|
+
| `effort` | Reasoning effort via `--effort` where supported; `gpt-oss` accepts it, while Claude thinking models reject it and Gemini aliases already encode it |
|
|
57
57
|
| `stream` | Use `stream-json` (default `true`) |
|
|
58
58
|
| `mode` | `accept-edits` by default; use `plan` for exploration/review |
|
|
59
59
|
|
|
@@ -62,13 +62,21 @@ returns it in `details.quota`/`details.quota_status` and the response when
|
|
|
62
62
|
the CLI exposes structured model records. Use the separate `agy_usage` tool
|
|
63
63
|
when choosing a model before execution. If the selected model is explicitly
|
|
64
64
|
reported as exhausted, the run stops before spending another agent turn and
|
|
65
|
-
reports the reset information.
|
|
65
|
+
reports the reset information. When no model is explicitly requested, an exhausted
|
|
66
|
+
quota-balanced default automatically falls back to the first reported available
|
|
67
|
+
model family. Explicit model selections fail clearly instead of silently
|
|
68
|
+
switching models.
|
|
66
69
|
Use `agy_usage` with `model` (for example `model=sonnet`) for a targeted
|
|
67
70
|
`available`/`exhausted`/`unknown` status. Older agy versions that do not support
|
|
68
71
|
headless `/usage` continue without failing the task. The extension requires
|
|
69
72
|
agy 1.1.11+ before invoking `/usage`; older versions are refused safely because
|
|
70
73
|
that command could otherwise consume model quota as a prompt.
|
|
71
74
|
|
|
75
|
+
The `agy_history` tool lists recorded conversations for a directory — ids,
|
|
76
|
+
models, ages, and one-line task summaries — so agents can find a
|
|
77
|
+
`conversation_id` to resume; `/agy sessions` offers the same in the TUI
|
|
78
|
+
picker. Summaries are stored locally (first ~80 chars of each prompt).
|
|
79
|
+
|
|
72
80
|
## Human-callable `/agy` command
|
|
73
81
|
|
|
74
82
|
Run agy directly from the Pi TUI — fast path when fully specified, wizard otherwise:
|
package/extensions/commands.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type AgyModel,
|
|
9
9
|
} from "./lib/cli.js";
|
|
10
10
|
import { executeAgyTask } from "./lib/execute.js";
|
|
11
|
-
import { truncate } from "./lib/output.js";
|
|
11
|
+
import { describeWhen, truncate } from "./lib/output.js";
|
|
12
12
|
import { describePreRunDirt } from "./lib/postflight.js";
|
|
13
13
|
import { getHistory, getSession } from "./lib/sessions.js";
|
|
14
14
|
|
|
@@ -263,7 +263,8 @@ async function runSessionsPicker(ctx: ExtensionCommandContext): Promise<void> {
|
|
|
263
263
|
const options = history.map((entry, index) => {
|
|
264
264
|
const id = entry.conversation_id.slice(0, 8);
|
|
265
265
|
const model = entry.model ?? "unknown model";
|
|
266
|
-
|
|
266
|
+
const summary = entry.summary ? `${entry.summary.slice(0, 50)} · ` : "";
|
|
267
|
+
return `${index + 1}. ${summary}${model} · ${describeWhen(entry.updated_at)} · ${id}…`;
|
|
267
268
|
});
|
|
268
269
|
const pick = await ctx.ui.select("resume agy conversation", options);
|
|
269
270
|
if (!pick) {
|
|
@@ -382,17 +383,6 @@ function createStatusThrottler(ctx: ExtensionCommandContext, intervalMs = 300) {
|
|
|
382
383
|
};
|
|
383
384
|
}
|
|
384
385
|
|
|
385
|
-
function describeWhen(iso: string): string {
|
|
386
|
-
const ms = Date.now() - Date.parse(iso);
|
|
387
|
-
if (!Number.isFinite(ms)) return "unknown age";
|
|
388
|
-
const minutes = Math.round(ms / 60_000);
|
|
389
|
-
if (minutes < 1) return "just now";
|
|
390
|
-
if (minutes < 60) return `${minutes}m ago`;
|
|
391
|
-
const hours = Math.round(minutes / 60);
|
|
392
|
-
if (hours < 24) return `${hours}h ago`;
|
|
393
|
-
return `${Math.round(hours / 24)}d ago`;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
386
|
function optionKey(option: string): string {
|
|
397
387
|
return option.split(" — ")[0];
|
|
398
388
|
}
|
package/extensions/index.ts
CHANGED
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
validateAgyExecutionOptions,
|
|
20
20
|
type AgyMode,
|
|
21
21
|
} from "./lib/execute.js";
|
|
22
|
-
import { truncate } from "./lib/output.js";
|
|
22
|
+
import { describeWhen, truncate } from "./lib/output.js";
|
|
23
|
+
import { getHistory } from "./lib/sessions.js";
|
|
23
24
|
|
|
24
25
|
const DEFAULT_TIMEOUT_MS = 300_000;
|
|
25
26
|
const MAX_TIMEOUT_MS = 600_000;
|
|
@@ -195,6 +196,56 @@ export default function piAgyExtension(pi: ExtensionAPI) {
|
|
|
195
196
|
},
|
|
196
197
|
});
|
|
197
198
|
|
|
199
|
+
pi.registerTool({
|
|
200
|
+
name: "agy_history",
|
|
201
|
+
label: "Antigravity Conversations",
|
|
202
|
+
description:
|
|
203
|
+
"List recorded agy conversations for a working directory (most recent first) with ids, models, ages, and task summaries — find a conversation_id to resume with agy_execute. Read-only; no model turn is spent.",
|
|
204
|
+
promptSnippet: "List recorded agy conversations before resuming one",
|
|
205
|
+
parameters: Type.Object({
|
|
206
|
+
dir: Type.Optional(
|
|
207
|
+
Type.String({
|
|
208
|
+
description: "Working directory. Defaults to current project root.",
|
|
209
|
+
}),
|
|
210
|
+
),
|
|
211
|
+
limit: Type.Optional(
|
|
212
|
+
Type.Number({
|
|
213
|
+
description: "Maximum conversations to list (default 10).",
|
|
214
|
+
minimum: 1,
|
|
215
|
+
maximum: 10,
|
|
216
|
+
default: 10,
|
|
217
|
+
}),
|
|
218
|
+
),
|
|
219
|
+
}),
|
|
220
|
+
|
|
221
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
222
|
+
const cwd = params.dir ? path.resolve(ctx.cwd, params.dir) : ctx.cwd;
|
|
223
|
+
const history = await getHistory(cwd);
|
|
224
|
+
const limited = history.slice(0, params.limit ?? 10);
|
|
225
|
+
if (limited.length === 0) {
|
|
226
|
+
return {
|
|
227
|
+
content: [{
|
|
228
|
+
type: "text",
|
|
229
|
+
text: `No agy conversations are recorded for ${cwd} yet. They are recorded automatically when agy_execute completes or is interrupted with a conversation id.`,
|
|
230
|
+
}],
|
|
231
|
+
details: { dir: cwd, conversations: [] },
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const lines = limited.map((entry, index) => {
|
|
235
|
+
const model = entry.model ?? "unknown model";
|
|
236
|
+
const summary = entry.summary ? ` · ${entry.summary}` : "";
|
|
237
|
+
return `${index + 1}. ${entry.conversation_id} · ${model} · ${describeWhen(entry.updated_at)}${summary}`;
|
|
238
|
+
});
|
|
239
|
+
const text =
|
|
240
|
+
`agy conversations for ${cwd} (most recent first):\n${lines.join("\n")}\n\n` +
|
|
241
|
+
"Resume with agy_execute conversation_id=<id>, or continue=true for the most recent.";
|
|
242
|
+
return {
|
|
243
|
+
content: [{ type: "text", text }],
|
|
244
|
+
details: { dir: cwd, conversations: limited },
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
|
|
198
249
|
pi.registerTool({
|
|
199
250
|
name: "agy_usage",
|
|
200
251
|
label: "Antigravity Quota",
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -222,8 +222,17 @@ export function resolveAgyModelId(model?: AgyModel, tier?: AgyOptions["tier"]):
|
|
|
222
222
|
return modelCatalog[alias] ?? MODEL_MAP[alias];
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Gemini aliases already select a low/medium/high model variant. Claude's
|
|
227
|
+
* thinking models also reject --effort; keep the flag for model families that
|
|
228
|
+
* expose it without turning a valid tool call into an argument error.
|
|
229
|
+
*/
|
|
230
|
+
export function supportsAgyEffort(model?: AgyModel, tier?: AgyOptions["tier"]): boolean {
|
|
231
|
+
return resolveAgyModelId(model, tier).startsWith("gpt-oss-");
|
|
232
|
+
}
|
|
233
|
+
|
|
225
234
|
const TRANSIENT_FAILURE_PATTERN =
|
|
226
|
-
/rate.?limit|429|overloaded|temporarily unavailable|network|connection (reset|refused)|econnreset|etimedout|socket hang up|\b50[023]\b/i;
|
|
235
|
+
/rate.?limit|resource[_ -]?exhausted|429|overloaded|temporarily unavailable|network|connection (reset|refused)|econnreset|etimedout|socket hang up|\b50[023]\b/i;
|
|
227
236
|
|
|
228
237
|
/** Heuristic for transient agy failures that are safe to retry once. */
|
|
229
238
|
export function isTransientAgyFailure(message: string): boolean {
|
|
@@ -254,7 +263,9 @@ export function buildAgyArgs(options: AgyOptions): string[] {
|
|
|
254
263
|
"--disable-slash-commands",
|
|
255
264
|
...(mode === "sandbox" ? ["--sandbox"] : ["--mode", mode]),
|
|
256
265
|
...(writes && skipPermissions ? ["--dangerously-skip-permissions"] : []),
|
|
257
|
-
...(options.effort
|
|
266
|
+
...(options.effort && supportsAgyEffort(options.model, options.tier)
|
|
267
|
+
? ["--effort", options.effort]
|
|
268
|
+
: []),
|
|
258
269
|
];
|
|
259
270
|
|
|
260
271
|
if (options.continue) {
|
|
@@ -23,8 +23,8 @@ import {
|
|
|
23
23
|
summarizeGitDiffSince,
|
|
24
24
|
type GitBaseline,
|
|
25
25
|
} from "./postflight.js";
|
|
26
|
-
import { runPreflight } from "./preflight.js";
|
|
27
|
-
import { getSession, saveSession } from "./sessions.js";
|
|
26
|
+
import { resetPreflightCache, runPreflight } from "./preflight.js";
|
|
27
|
+
import { getSession, saveSession, conversationSummary } from "./sessions.js";
|
|
28
28
|
|
|
29
29
|
export type AgyMode = "plan" | "accept-edits" | "sandbox";
|
|
30
30
|
|
|
@@ -86,9 +86,11 @@ export async function executeAgyTask(
|
|
|
86
86
|
const config = await loadAgyConfig(undefined, abortSignal);
|
|
87
87
|
// Explicit model → legacy tier → configured default → flash-medium.
|
|
88
88
|
const selectedModel = resolveAgyModelAlias(options.model, options.tier);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
effectiveModel = model
|
|
89
|
+
const resolvedModel = selectedModel ?? (await resolveDefaultModel(config, abortSignal));
|
|
90
|
+
let model: AgyModel = resolvedModel ?? "flash-medium";
|
|
91
|
+
effectiveModel = model;
|
|
92
|
+
const autoModelSelection =
|
|
93
|
+
!selectedModel && !config.defaultModel && !config.defaultModelCommand;
|
|
92
94
|
const skipPermissions = config.skipPermissions !== false;
|
|
93
95
|
|
|
94
96
|
return await withDirLock(
|
|
@@ -143,20 +145,31 @@ export async function executeAgyTask(
|
|
|
143
145
|
const quotaSummary = quota ? formatAgyUsage(quota, selectedModelId) : undefined;
|
|
144
146
|
if (quotaSummary) onProgress?.(quotaSummary);
|
|
145
147
|
if (selectedQuotas.some((entry) => isAgyQuotaExhausted(entry))) {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.every((entry) => !isAgyQuotaExhausted(entry)),
|
|
148
|
+
const fallback = autoModelSelection
|
|
149
|
+
? findAvailableFallbackModel(quota, model)
|
|
150
|
+
: undefined;
|
|
151
|
+
if (fallback) {
|
|
152
|
+
onProgress?.(
|
|
153
|
+
`agy: ${selectedModelId} quota exhausted; falling back to ${resolveAgyModelId(fallback)}…`,
|
|
153
154
|
);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
model = fallback;
|
|
156
|
+
effectiveModel = fallback;
|
|
157
|
+
} else {
|
|
158
|
+
const quotaEntries = quota?.models ?? [];
|
|
159
|
+
const alternatives = [...new Set(quotaEntries.map((entry) => entry.model))]
|
|
160
|
+
.filter((candidate) => candidate.toLowerCase() !== selectedModelId.toLowerCase())
|
|
161
|
+
.filter((candidate) =>
|
|
162
|
+
quotaEntries
|
|
163
|
+
.filter((entry) => entry.model === candidate)
|
|
164
|
+
.every((entry) => !isAgyQuotaExhausted(entry)),
|
|
165
|
+
);
|
|
166
|
+
const alternativeText = alternatives.length
|
|
167
|
+
? ` Available reported alternatives: ${alternatives.join(", ")}.`
|
|
168
|
+
: " No available alternative was reported.";
|
|
169
|
+
throw new Error(
|
|
170
|
+
`agy quota exhausted for ${selectedModelId}; choose another model or run agy_usage first.${alternativeText}\n${quotaSummary ?? ""}`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
160
173
|
}
|
|
161
174
|
const runTimeoutMs = remainingBudget(startedAt, options.timeout_ms);
|
|
162
175
|
// Emitted via onProgress directly: progress tracking (and therefore
|
|
@@ -181,7 +194,7 @@ export async function executeAgyTask(
|
|
|
181
194
|
abortSignal,
|
|
182
195
|
trackProgress,
|
|
183
196
|
);
|
|
184
|
-
}, onProgress);
|
|
197
|
+
}, onProgress, abortSignal);
|
|
185
198
|
|
|
186
199
|
if (run.conversation_id) {
|
|
187
200
|
try {
|
|
@@ -192,6 +205,7 @@ export async function executeAgyTask(
|
|
|
192
205
|
run.conversation_id,
|
|
193
206
|
effectiveModel,
|
|
194
207
|
AbortSignal.timeout(10_000),
|
|
208
|
+
conversationSummary(options.prompt),
|
|
195
209
|
);
|
|
196
210
|
} catch (error) {
|
|
197
211
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -260,6 +274,7 @@ export async function executeAgyTask(
|
|
|
260
274
|
conversationId,
|
|
261
275
|
effectiveModel,
|
|
262
276
|
AbortSignal.timeout(10_000),
|
|
277
|
+
conversationSummary(options.prompt),
|
|
263
278
|
);
|
|
264
279
|
} catch {
|
|
265
280
|
// Preserve the original agy failure; session persistence is best effort.
|
|
@@ -293,6 +308,29 @@ function remainingBudget(startedAt: number, timeoutMs: number): number {
|
|
|
293
308
|
return remaining;
|
|
294
309
|
}
|
|
295
310
|
|
|
311
|
+
const FALLBACK_MODELS: readonly AgyModel[] = [
|
|
312
|
+
"flash-medium",
|
|
313
|
+
"flash-low",
|
|
314
|
+
"flash-high",
|
|
315
|
+
"pro-low",
|
|
316
|
+
"pro-high",
|
|
317
|
+
"gpt-oss",
|
|
318
|
+
"sonnet",
|
|
319
|
+
"opus",
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
function findAvailableFallbackModel(
|
|
323
|
+
snapshot: AgyUsageSnapshot | undefined,
|
|
324
|
+
current: AgyModel,
|
|
325
|
+
): AgyModel | undefined {
|
|
326
|
+
if (!snapshot) return undefined;
|
|
327
|
+
return FALLBACK_MODELS.find((candidate) => {
|
|
328
|
+
if (candidate === current) return false;
|
|
329
|
+
const entries = findAgyQuotaEntries(snapshot, resolveAgyModelId(candidate));
|
|
330
|
+
return entries.length > 0 && entries.every((entry) => !isAgyQuotaExhausted(entry));
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
296
334
|
/**
|
|
297
335
|
* Retry once when agy fails before emitting any activity (tool step or model
|
|
298
336
|
* response) with a transient error (rate limit, network blip). Zero activity
|
|
@@ -301,6 +339,7 @@ function remainingBudget(startedAt: number, timeoutMs: number): number {
|
|
|
301
339
|
async function runWithTransientRetry<T>(
|
|
302
340
|
attempt: (trackProgress: (message: string) => void) => Promise<T>,
|
|
303
341
|
onProgress?: (message: string) => void,
|
|
342
|
+
signal?: AbortSignal,
|
|
304
343
|
): Promise<T> {
|
|
305
344
|
for (let tries = 0; ; tries++) {
|
|
306
345
|
let sawActivity = false;
|
|
@@ -318,10 +357,37 @@ async function runWithTransientRetry<T>(
|
|
|
318
357
|
isTransientAgyFailure(message) &&
|
|
319
358
|
!/\b(?:ETIMEDOUT|timed out)\b/i.test(message)
|
|
320
359
|
) {
|
|
321
|
-
|
|
360
|
+
const quotaMayHaveChanged = /resource[_ -]?exhausted|429/i.test(message);
|
|
361
|
+
if (quotaMayHaveChanged) resetPreflightCache();
|
|
362
|
+
onProgress?.(
|
|
363
|
+
quotaMayHaveChanged
|
|
364
|
+
? "agy: quota request was rejected before any work — refreshing quota and retrying once…"
|
|
365
|
+
: "agy: transient failure before any work — retrying once…",
|
|
366
|
+
);
|
|
367
|
+
await delayBeforeRetry(signal);
|
|
322
368
|
continue;
|
|
323
369
|
}
|
|
324
370
|
throw error;
|
|
325
371
|
}
|
|
326
372
|
}
|
|
327
373
|
}
|
|
374
|
+
|
|
375
|
+
function delayBeforeRetry(signal?: AbortSignal): Promise<void> {
|
|
376
|
+
return new Promise((resolve, reject) => {
|
|
377
|
+
const timer = setTimeout(resolve, 1_000);
|
|
378
|
+
if (!signal) return;
|
|
379
|
+
if (signal.aborted) {
|
|
380
|
+
clearTimeout(timer);
|
|
381
|
+
reject(signal.reason ?? new Error("agy retry cancelled"));
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
signal.addEventListener(
|
|
385
|
+
"abort",
|
|
386
|
+
() => {
|
|
387
|
+
clearTimeout(timer);
|
|
388
|
+
reject(signal.reason ?? new Error("agy retry cancelled"));
|
|
389
|
+
},
|
|
390
|
+
{ once: true },
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
}
|
package/extensions/lib/output.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
const DEFAULT_MAX_OUTPUT_CHARS = 8000;
|
|
2
2
|
|
|
3
|
+
/** Human-facing relative age for an ISO timestamp ("5m ago", "2h ago", …). */
|
|
4
|
+
export function describeWhen(iso: string): string {
|
|
5
|
+
const ms = Date.now() - Date.parse(iso);
|
|
6
|
+
if (!Number.isFinite(ms)) return "unknown age";
|
|
7
|
+
const minutes = Math.round(ms / 60_000);
|
|
8
|
+
if (minutes < 1) return "just now";
|
|
9
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
10
|
+
const hours = Math.round(minutes / 60);
|
|
11
|
+
if (hours < 24) return `${hours}h ago`;
|
|
12
|
+
return `${Math.round(hours / 24)}d ago`;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export function truncate(text: string, max = DEFAULT_MAX_OUTPUT_CHARS): string {
|
|
4
16
|
if (text.length <= max) return text;
|
|
5
17
|
if (max <= 0) return "";
|
|
@@ -17,6 +17,8 @@ export interface AgyConversationEntry {
|
|
|
17
17
|
conversation_id: string;
|
|
18
18
|
model?: string;
|
|
19
19
|
updated_at: string;
|
|
20
|
+
/** Short task excerpt so humans and agents can tell conversations apart. */
|
|
21
|
+
summary?: string;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface AgySessionRecord {
|
|
@@ -66,9 +68,16 @@ export interface AgySessionStore {
|
|
|
66
68
|
conversationId: string,
|
|
67
69
|
model?: string,
|
|
68
70
|
signal?: AbortSignal,
|
|
71
|
+
summary?: string,
|
|
69
72
|
): Promise<void>;
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
/** Collapse a prompt into a short one-line task summary. */
|
|
76
|
+
export function conversationSummary(prompt: string, max = 80): string {
|
|
77
|
+
const collapsed = prompt.trim().replace(/\s+/g, " ");
|
|
78
|
+
return collapsed.length > max ? collapsed.slice(0, max) + "…" : collapsed;
|
|
79
|
+
}
|
|
80
|
+
|
|
72
81
|
/**
|
|
73
82
|
* Create a session store. The optional path (string or lazy resolver) makes
|
|
74
83
|
* persistence testable; the lazy form re-reads `PI_CODING_AGENT_DIR` on each
|
|
@@ -145,7 +154,15 @@ export function createSessionStore(
|
|
|
145
154
|
typeof entry.conversation_id === "string" &&
|
|
146
155
|
typeof entry.updated_at === "string",
|
|
147
156
|
)
|
|
148
|
-
.
|
|
157
|
+
.map((entry) => {
|
|
158
|
+
const normalized: AgyConversationEntry = {
|
|
159
|
+
conversation_id: entry.conversation_id,
|
|
160
|
+
updated_at: entry.updated_at,
|
|
161
|
+
};
|
|
162
|
+
if (typeof entry.model === "string") normalized.model = entry.model;
|
|
163
|
+
if (typeof entry.summary === "string") normalized.summary = entry.summary;
|
|
164
|
+
return normalized;
|
|
165
|
+
})
|
|
149
166
|
: [];
|
|
150
167
|
}
|
|
151
168
|
|
|
@@ -227,6 +244,7 @@ export function createSessionStore(
|
|
|
227
244
|
conversationId: string,
|
|
228
245
|
model?: string,
|
|
229
246
|
signal?: AbortSignal,
|
|
247
|
+
summary?: string,
|
|
230
248
|
): Promise<void> {
|
|
231
249
|
const operation = waitForMutation(signal).then(() =>
|
|
232
250
|
withStoreLock(async () => {
|
|
@@ -239,7 +257,7 @@ export function createSessionStore(
|
|
|
239
257
|
last_model: model,
|
|
240
258
|
updated_at: updatedAt,
|
|
241
259
|
history: [
|
|
242
|
-
{ conversation_id: conversationId, model, updated_at: updatedAt },
|
|
260
|
+
{ conversation_id: conversationId, model, updated_at: updatedAt, summary },
|
|
243
261
|
...(Array.isArray(record.history) ? record.history : []).filter(
|
|
244
262
|
(entry) =>
|
|
245
263
|
entry &&
|
|
@@ -276,6 +294,7 @@ export function saveSession(
|
|
|
276
294
|
conversationId: string,
|
|
277
295
|
model?: string,
|
|
278
296
|
signal?: AbortSignal,
|
|
297
|
+
summary?: string,
|
|
279
298
|
): Promise<void> {
|
|
280
|
-
return defaultStore.saveSession(dir, conversationId, model, signal);
|
|
299
|
+
return defaultStore.saveSession(dir, conversationId, model, signal, summary);
|
|
281
300
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanbenjumea/pi-agy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
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",
|
package/skills/agy/SKILL.md
CHANGED
|
@@ -42,6 +42,7 @@ agy_execute prompt="Generate exhaustive unit tests for src/auth/" model=flash-lo
|
|
|
42
42
|
agy_execute prompt="Plan the migration to ESM" model=sonnet mode=plan digest=true
|
|
43
43
|
agy_execute prompt="Implement the approved plan" conversation_id=<id> mode=accept-edits
|
|
44
44
|
agy_execute prompt="Adversarial review the diff" model=opus effort=high mode=plan
|
|
45
|
+
agy_history
|
|
45
46
|
agy_usage
|
|
46
47
|
```
|
|
47
48
|
|
|
@@ -64,15 +65,15 @@ agy_usage
|
|
|
64
65
|
- Escalate within the Gemini quota group to `pro-low` or `pro-high` only when needed.
|
|
65
66
|
- Use `sonnet` for normal Claude-group coding/review; reserve `opus` for the hardest architecture or root-cause work.
|
|
66
67
|
- Use `gpt-oss` when an open-model alternative is specifically desired.
|
|
67
|
-
- Set `effort`
|
|
68
|
+
- Set `effort` only for `gpt-oss`; Claude thinking models reject `--effort`, and Gemini aliases encode effort in the model id.
|
|
68
69
|
- For consequential work, have one family produce and the opposite family review with `mode=plan`; do not spend both groups on trivial tasks.
|
|
69
70
|
- Batch related work, avoid parallel calls within one shared-quota group or directory, and use `digest=true` (default) for non-write tasks.
|
|
70
71
|
|
|
71
72
|
## Enhancements over upstream pi-agy
|
|
72
73
|
|
|
73
|
-
- **Quota discovery** — `agy_usage` and `/agy usage` report model-specific remaining quota and reset times; executions refresh quota snapshots and return machine-readable `quota_status` as well.
|
|
74
|
+
- **Quota discovery** — `agy_usage` and `/agy usage` report model-specific remaining quota and reset times; executions refresh quota snapshots, automatically fall back when an implicit default is exhausted, and return machine-readable `quota_status` as well.
|
|
74
75
|
- **Streaming progress** — live tool steps via `stream-json` and Pi `onUpdate`.
|
|
75
|
-
- **Conversation continuity** — `conversation_id`, `continue`, session store under `$PI_CODING_AGENT_DIR/agy-sessions.json` (or `~/.pi/agent/agy-sessions.json` by default); runs that time out or are cancelled are recorded too and stay resumable.
|
|
76
|
+
- **Conversation continuity** — `conversation_id`, `continue`, session store under `$PI_CODING_AGENT_DIR/agy-sessions.json` (or `~/.pi/agent/agy-sessions.json` by default) with one-line task summaries; runs that time out or are cancelled are recorded too and stay resumable, and the `agy_history` tool lets agents list past conversations.
|
|
76
77
|
- **Repo-aware verify** — prefers `just ci` when a justfile defines `ci:`.
|
|
77
78
|
- **Diff summary** — accept-edits results append newly-dirty files only; pre-existing dirt is listed separately, never misattributed.
|
|
78
79
|
- **Per-directory lock** — serializes concurrent agy calls on the same tree across Pi processes (symlink-aware).
|