pi-agy-acp 0.2.2 → 0.2.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/docs/reference.md CHANGED
@@ -1,23 +1,35 @@
1
1
  # Reference
2
2
 
3
- For installation and your first request, start with the [installation guide](../README.md#install).
3
+ For installation and your first request, start with the
4
+ [installation guide](../README.md#install). For internal protocol and runtime
5
+ details, see [architecture](architecture.md).
4
6
 
5
7
  ## Commands
6
8
 
7
9
  | Command | Behavior |
8
10
  | --- | --- |
9
- | `/agy-acp` or `/agy-acp status` | Show a status panel with runtime state, paths, sessions, model reasoning levels, and the last turn. |
10
- | `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns, optionally switching and remembering the display mode. |
11
- | `/agy-acp reset` | Close ACP sessions; the next request rebuilds a session from Pi's history. |
12
-
13
- Subcommands support completion with Tab. Unknown arguments display
14
- `Usage: /agy-acp [status|quota [used|remaining]|reset]` as a warning.
11
+ | `/agy-acp` or `/agy-acp status` | Show a status panel with runtime state, paths, account details, sessions, model reasoning levels, and the last turn. |
12
+ | `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns, optionally switching and saving the display mode. |
13
+ | `/agy-acp refresh` | Force a live model catalog refresh from `agy` and update `catalog.json`. |
14
+ | `/agy-acp reset` | Dispose the ACP runtime (stopping `agy`), clear sessions, status indicator, quota cache, and warning history; the next request rebuilds from Pi's history. |
15
+
16
+ Subcommands support Tab completion (`status`, `quota`, `quota used`,
17
+ `quota remaining`, `refresh`, `reset`). Unknown arguments show
18
+ `Usage: /agy-acp [status|quota [used|remaining]|refresh|reset]` as a warning.
19
+
20
+ In interactive TUI mode, `/agy-acp quota` (`Fetching Antigravity quota...`) and
21
+ `/agy-acp refresh` (`Refreshing Antigravity models...`) display a cancellable
22
+ loader. Pressing Escape returns to the editor: `/agy-acp refresh` cancels the
23
+ caller's wait, while `/agy-acp quota` hides the pending panel even if the
24
+ underlying `/usage` query finishes updating the cache. Non-TUI modes run
25
+ directly without a loader.
15
26
 
16
27
  ### Status panel
17
28
 
18
- The panel marks the runtime as idle, starting, ready, or in error. Before the first
19
- turn, it shows the isolated home and notes that agy has not been probed yet;
20
- viewing status does not start it. Models list their supported reasoning levels,
29
+ The panel reports the runtime as `idle`, `starting`, `ready`, or `error`.
30
+ Viewing status never starts `agy`; before `agy` has been probed (by a turn,
31
+ `/agy-acp refresh`, or plan discovery), it shows the isolated home and notes
32
+ that `agy` starts lazily. Models list their supported reasoning levels,
21
33
  including a fixed level where applicable.
22
34
 
23
35
  Once a turn finishes, its summary shows the model, effort, outcome (`completed`,
@@ -29,18 +41,9 @@ healthy runtime uses a warning.
29
41
 
30
42
  ### Quota panel
31
43
 
32
- In interactive TUI mode, a bordered loader displays `Fetching Antigravity quota...`
33
- while the request is pending. Press Escape to cancel waiting and return to the
34
- editor. The underlying quota query may finish and update the cache, but its result
35
- will not appear after cancellation. Non-TUI modes query directly without a loader.
36
-
37
- Quota is read through `agy -p /usage --output-format json`. Each model group has
38
- one row per quota window, with a 12-cell bar, a rounded percentage, and a relative
39
- reset time (omitted for untouched rolling windows at `0%` used / `100%` remaining
40
- whose reset time is still a full window away). By default (`used` mode), bars and
41
- percentages count up from `0%`; pass `remaining` (`/agy-acp quota remaining`) to
42
- count down from `100%`. The last selected mode is saved in `settings.json` inside
43
- `PI_AGY_HOME`. For example:
44
+ Quota is read through `agy -p /usage --output-format json`. Disabled quota
45
+ buckets are excluded. Each model group renders one row per usable quota window
46
+ with a 12-cell bar, a rounded percentage, and a relative reset countdown:
44
47
 
45
48
  ```text
46
49
  Antigravity Quota
@@ -52,68 +55,84 @@ Antigravity Quota
52
55
  weekly [█░░░░░░░░░░░] 9% · resets in 6d 7h
53
56
  ```
54
57
 
55
- Missing values display `n/a`; an elapsed reset time displays `resetting soon`.
56
- Severity uses the actual remaining fraction rather than the rounded percentage:
58
+ - **Display mode:** Default is `used` (bars and percentages count up from `0%`).
59
+ Pass `remaining` (`/agy-acp quota remaining`) to count down from `100%`. When
60
+ a mode is passed, it is saved to `<PI_AGY_HOME>/settings.json` immediately,
61
+ even if the quota query is cancelled or fails.
62
+ - **Reset labels:** Untouched rolling windows at `0%` used (`100%` remaining)
63
+ whose reset time is still a full window away omit the countdown. Otherwise,
64
+ missing values show `n/a`, elapsed resets show `resetting soon`, unparseable
65
+ timestamps show `reset time unavailable`, and sub-minute windows show
66
+ `resets in <1m`.
67
+ - **Empty and stale responses:** A group with no usable windows shows
68
+ `No quota windows available.`, and an empty successful response shows
69
+ `No quota data available.`. Failed queries include the reason; if cached
70
+ groups exist, the title marks them `(stale)` and still renders their bars.
71
+
72
+ Notification severity uses the actual remaining fraction rather than the rounded
73
+ percentage:
57
74
 
58
75
  | Condition | Notification |
59
76
  | --- | --- |
60
77
  | All known windows above 20% remaining (<80% used) | Info |
61
- | Any window at or below 20% remaining (≥80% used), with none at or below 5% remaining | Warning |
78
+ | Any window at or below 20% remaining (≥80% used), none at or below 5% remaining | Warning |
62
79
  | Any window at or below 5% remaining (≥95% used), or a failed quota query | Error |
63
80
 
64
- Errors include the reason. If cached groups are available after a failed query,
65
- the title marks them as `(stale)` and still displays their bars. An empty
66
- successful response displays `No quota data available.`.
67
-
68
81
  ### Account details
69
82
 
70
- Both panels show the email and subscription plan when known, omitting unavailable
71
- fields. If no plan is cached, the first `/agy-acp quota` query also tries to discover
72
- it. This may start ACP but sends no model prompt; failure does not prevent quota
73
- from appearing. Use `/agy-acp reset` to retry discovery. Viewing status never starts it.
83
+ Both panels display the email and subscription plan when known and omit
84
+ unavailable fields:
74
85
 
75
- The email comes from login logs. With the default home only, the extension also
76
- checks `ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, and `~/.gemini/antigravity-cli`
77
- (`cli.log` plus the newest 10 `log/cli-*.log` and `log/acp-server-*.log` files,
78
- scanning each log's tail 64 KiB and falling back to its head 64 KiB when larger);
79
- a custom `PI_AGY_HOME` stays isolated. Cached plans and login logs can be stale
80
- after an account change.
86
+ - **Plan:** If no plan is cached, the first `/agy-acp quota` query attempts
87
+ discovery using a temporary tool-less ACP session (stopped afterward if the
88
+ runtime was idle) without sending a model prompt. Failure does not block quota
89
+ display; use `/agy-acp reset` to retry discovery. Viewing status never probes
90
+ `agy`.
91
+ - **Email:** Read from `agy` login logs. With the default `PI_AGY_HOME`, the
92
+ extension also checks `ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, and
93
+ `~/.gemini/antigravity-cli`; a custom `PI_AGY_HOME` stays isolated. Cached
94
+ plans and login logs can be stale after an account change.
81
95
 
82
96
  ### Quota status and warnings
83
97
 
84
- When a run using `antigravity-acp` fully settles, the extension checks `/usage`
85
- in the background and shows a compact status indicator such as `AGY 20%` (or
86
- `AGY 80%` in `remaining` mode). It uses the lowest known remaining window across
87
- the selected model's matching quota group(s) (or an unambiguous generic family
88
- group), and omits the status indicator and low-quota warning when group ownership is
89
- unknown or ambiguous. Failed background checks stay silent. Successful results
90
- and failures both respect the two-minute quota TTL, and concurrent background
91
- checks share the in-flight query.
92
-
93
- At or below 20% and 5% remaining (≥80% and ≥95% used), a warning appears once
94
- per group, quota window, reset time, and threshold. `/agy-acp quota` explicitly
95
- refreshes quota and updates the status indicator; `/agy-acp status` uses fresh
96
- cached quota only. Neither session start nor model selection launches a quota
97
- command. Selecting another provider hides the status indicator; returning to
98
- Antigravity uses only a fresh in-memory snapshot. `/agy-acp reset` clears the
99
- status indicator and warning history; shutdown clears the status indicator.
100
-
101
- When the active model belongs to `antigravity-acp`, this extension vetoes Pi's
102
- automatic prompt-cache warming to avoid background warming requests consuming
103
- quota. Other providers' warming decisions are left unchanged.
98
+ After an `antigravity-acp` run settles, the extension refreshes `/usage` in the
99
+ background (sharing any in-flight request and respecting the 2-minute TTL) and
100
+ displays a compact status bar indicator such as `AGY 20%` (or `AGY 80%` in
101
+ `remaining` mode):
102
+
103
+ - The percentage reflects the lowest known remaining window across the active
104
+ model's matching quota group(s). When group ownership is unknown or ambiguous
105
+ (including effort-capped pools without a known effort), the indicator and
106
+ low-quota warning are omitted.
107
+ - Background query failures stay silent and also respect the 2-minute TTL.
108
+ - Low-quota warnings fire once per group, window, reset time, and threshold at
109
+ or below 20% remaining (≥80% used) and 5% remaining (≥95% used).
110
+ - `/agy-acp quota` refreshes quota and updates the indicator; `/agy-acp status`
111
+ uses fresh cached quota only. Neither session start nor model selection starts
112
+ a quota command (switching between `antigravity-acp` models while a post-turn
113
+ check is already in flight retargets that check to the newly selected model).
114
+ - Selecting another provider hides the indicator; returning to Antigravity uses
115
+ only a fresh in-memory snapshot. `/agy-acp reset` clears the indicator and
116
+ warning history; shutdown clears the indicator.
117
+
118
+ Two automatic Pi safeguards also apply when `antigravity-acp` is the active
119
+ provider (other providers are untouched):
120
+
121
+ - **Prompt-cache warming veto:** Cancels Pi's automatic prompt-cache warming so
122
+ background warming requests do not consume Antigravity quota.
123
+ - **Auto-compaction threshold guard:** Cancels threshold-triggered compaction
124
+ while a model's context window is still unknown (`0`).
104
125
 
105
126
  ## Configuration
106
127
 
107
- Set these environment variables before starting Pi:
128
+ Set environment variables before starting Pi:
108
129
 
109
130
  | Variable | Purpose | Default |
110
131
  | --- | --- | --- |
111
132
  | `PI_AGY_COMMAND` | Absolute path to the `agy` executable. | Automatic discovery. |
112
- | `PI_AGY_HOME` | Dedicated directory for this extension's agy state. | `~/.pi/agent/cache/antigravity-acp` |
133
+ | `PI_AGY_HOME` | Dedicated directory for this extension's state. | `~/.pi/agent/cache/antigravity-acp` |
113
134
  | `PI_AGY_QUOTA_DISPLAY` | Startup quota display mode (`used` or `remaining`), overriding `settings.json` for startup. Invalid values are ignored; `/agy-acp quota <mode>` overrides it for the active session. | `settings.json`, then `used` |
114
- | `PI_AGY_DEBUG` | Set to `1` to emit runtime warnings on `stderr` (silent by default to protect the TUI). | Unset (silent) |
115
-
116
- For example:
135
+ | `PI_AGY_DEBUG` | Set to `1` to print runtime warnings on `stderr` (silent by default to protect the TUI). | Unset (silent) |
117
136
 
118
137
  ```sh
119
138
  PI_AGY_COMMAND=/absolute/path/to/agy pi -e ./index.ts
@@ -121,86 +140,83 @@ PI_AGY_COMMAND=/absolute/path/to/agy pi -e ./index.ts
121
140
 
122
141
  ### Stored data and authentication
123
142
 
124
- The dedicated directory isolates the bridge agent from your normal agy tools and
125
- plugins. It contains agy-managed session data, logs, and the extension's model cache.
126
-
127
- Temporary session data and old logs are removed automatically. The current log,
128
- model cache, `settings.json` (quota display preference), and authentication files
129
- are retained; sessions rebuild from Pi's history. Cleanup is best-effort if files are locked. Use a different `PI_AGY_HOME`
130
- for each concurrently running Pi instance, since startup cleanup assumes exclusive
131
- use of the directory.
132
-
133
- With file-backed authentication and the default `PI_AGY_HOME`, the extension
134
- atomically syncs the existing OAuth token from your normal agy directory
135
- (`ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, or `~/.gemini/antigravity-cli`) with `0600`
136
- permissions while refusing symlinked paths. A custom `PI_AGY_HOME` stays
137
- isolated and does not copy tokens from default agy directories. Note that quota
138
- queries (`agy -p /usage`) always query the global `agy` CLI account because
139
- `agy` does not accept `--gemini-dir` on `/usage`. Do not commit or share this
140
- directory. Authentication and token refresh remain agy's responsibility.
143
+ `PI_AGY_HOME` isolates the bridge agent from your normal `agy` tools and
144
+ plugins. It stores the extension's `catalog.json`, `settings.json` (quota
145
+ display preference), ACP logs, and `agy/` (isolated `agy` state, settings, and
146
+ session databases).
147
+
148
+ - **Cleanup:** Temporary session artifacts and old logs are removed
149
+ automatically (best-effort if locked). Current logs, `catalog.json`,
150
+ `settings.json`, and authentication files are retained; sessions rebuild from
151
+ Pi's history. Use a separate `PI_AGY_HOME` for each concurrently running Pi
152
+ instance because startup cleanup assumes exclusive directory ownership.
153
+ - **OAuth sync:** With the default `PI_AGY_HOME` and file-backed auth, the
154
+ extension atomically syncs `antigravity-oauth-token` from your normal `agy`
155
+ directory (`ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, or `~/.gemini/antigravity-cli`)
156
+ with `0600` permissions when the isolated copy is missing, empty, or older,
157
+ refusing symlinked paths. Sync failures warn rather than aborting startup. A
158
+ custom `PI_AGY_HOME` stays isolated and never copies tokens from default `agy`
159
+ directories.
160
+ - **Global quota scope:** `agy -p /usage` does not accept `--gemini-dir`, so
161
+ quota queries always reflect the global `agy` CLI account. Do not commit or
162
+ share `PI_AGY_HOME`; authentication and token refresh remain `agy`'s
163
+ responsibility.
141
164
 
142
165
  ## Models and context
143
166
 
144
- Loading the extension restores the cached catalog from `catalog.json` (or starts
145
- empty on a fresh install) without starting agy. Model refresh (such as opening
146
- `/model`) or the first request discovers available models, reasoning levels
147
- (including grouped select options and `-effort` suffix variants), and image input
148
- capability (`promptCapabilities.image`) dynamically from ACP. A forced refresh
149
- queries again; refreshes can be cancelled. The selector exposes only the
150
- reasoning levels offered for each model (`low`, `medium`, `high`, `xhigh`, `max`).
151
- Direct requests map `minimal` to `low` and forward `xhigh` and `max` (clamping to
152
- the nearest effort offered by that model); `off` uses the runtime default.
153
-
154
- Model context windows start at `0` until learned dynamically from the
155
- server-issued `max_context_tokens` metadata in the session database and cached
156
- per model in `catalog.json` alongside the `agy` binary fingerprint; updating the
157
- `agy` binary invalidates cached context windows and triggers re-discovery on the
158
- next refresh or session. The history replay budget is 160,000 bytes; older
159
- history can be omitted to fit, and historical images become text placeholders.
167
+ - **Discovery and caching:** Loading the extension restores `catalog.json` (or
168
+ starts empty on a fresh install) without starting `agy`. Non-forced refreshes
169
+ (Pi startup or opening `/model`) reuse `catalog.json` without spawning `agy`
170
+ whenever cached models match the current `agy` binary fingerprint. Live ACP
171
+ discovery runs when no matching cache exists, on `/agy-acp refresh`, on the
172
+ first live request, or after an `agy` binary upgrade once refreshed or
173
+ restarted. Standalone discovery stops its temporary ACP process afterward,
174
+ and idle ACP processes shut down automatically after sessions expire.
175
+ - **Reasoning levels:** The `/model` selector exposes only the levels offered
176
+ for each model (`low`, `medium`, `high`, `xhigh`, `max`). Direct requests map
177
+ `minimal` to `low`, clamp requested levels to the nearest offered effort, and
178
+ treat `off` as the runtime default (`high`).
179
+ - **Context windows and replay:** Context windows start at `0` until learned
180
+ dynamically from session metadata and cached per model in `catalog.json`
181
+ against the `agy` binary fingerprint; upgrading `agy` invalidates cached
182
+ context windows. History replay uses a 160,000-byte budget—older turns can be
183
+ omitted to fit, and historical images become `[image]` placeholders.
160
184
 
161
185
  ## Usage and costs
162
186
 
163
- Usage comes from the ACP session rather than per-step API headers. Parked `toolUse`
164
- steps emit zero usage; statistics arrive on the final step when the full ACP turn
165
- finishes (accumulated across any automatic `max_tokens` continuations). `max_context_tokens`
166
- recorded in the session SQLite metadata supplies the model's context window, while
167
- `usage_update` (and same-turn `estimated_tokens_used` metadata when `usage_update`
168
- is absent) supplies live token occupancy.
187
+ Usage comes from the ACP session rather than per-step HTTP headers. Parked
188
+ `toolUse` steps emit zero usage; statistics arrive on the final step when the
189
+ ACP turn completes (accumulated across any automatic `max_tokens` continuations)
190
+ whenever `session/prompt` reports usage.
169
191
 
170
- The extension separates cumulative token consumption from final-call context
192
+ The extension separates cumulative turn consumption from final-call context
171
193
  occupancy:
172
194
 
173
- - `input`, `output`, `cacheRead`, and `cacheWrite` preserve unscaled cumulative
174
- turn totals from `session/prompt`, so Pi's session totals and flat pricing
195
+ - `input`, `output`, `cacheRead`, `cacheWrite`, and `reasoning` preserve
196
+ unscaled cumulative turn totals, so Pi session totals and flat pricing
175
197
  overrides reflect full multi-step consumption.
176
- - `totalTokens` (which feeds Pi's context meter and auto-compaction threshold via
177
- `calculateContextTokens`) uses the final model call's live `usage_update.used`
178
- count when `agy` provides it. When `usage_update` is absent, it prefers the
179
- same turn's `estimated_tokens_used` from `gen_metadata`, and otherwise falls
180
- back to averaging the final `session/prompt` segment's prompt tokens across
181
- that segment's model calls plus final-segment output tokens; this fallback is
182
- an estimate rather than an exact per-step measurement.
183
-
184
- Default model prices are zero because pricing is unavailable. If you configure
185
- Pi model pricing overrides, flat per-million rates price the cumulative turn
186
- buckets accurately; tiered `inputTokensAbove` rules evaluate against cumulative
187
- turn prompt tokens rather than per-call prompt sizes. These estimates are not
188
- an invoice amount or a promise of free access.
189
-
190
- The extension reads only session-scoped `max_context_tokens` metadata inside `PI_AGY_HOME`;
191
- it never inspects your global `agy` databases or invokes or distributes binary patch
192
- scripts.
198
+ - `totalTokens` (feeding Pi's context meter and auto-compaction threshold) uses
199
+ the final call's live token occupancy when reported by `agy`, falling back to
200
+ the same turn's session metadata estimate and then a final-segment average
201
+ estimate.
202
+
203
+ Default model prices are zero because upstream pricing is unavailable. With Pi
204
+ pricing overrides, flat per-million rates price cumulative turn buckets
205
+ accurately; tiered `inputTokensAbove` rules evaluate against cumulative turn
206
+ prompt tokens rather than per-call prompt sizes. These numbers are estimates,
207
+ not an invoice or a promise of free access.
208
+
209
+ Read-only SQLite inspection is restricted strictly to session-scoped databases
210
+ inside `PI_AGY_HOME` (for context windows, occupancy estimates, and hidden
211
+ terminal API error detection); the extension never reads global `agy` databases
212
+ or invokes/distributes binary patches.
193
213
 
194
214
  ## Compatibility limits
195
215
 
196
- This version requires `agy` CLI >= 1.5.10 and targets the `@earendil-works/*`
197
- Pi packages at version 1.5.x.
198
- Host `peerDependencies` use `*` as required by Pi package conventions;
199
- `devDependencies` pin a reproducible CI baseline (`1.5.2`), and CI validates
200
- both that baseline (on Node.js 22.19.0 and 24) and the `1.5.x` host range
201
- (`1.5.0` and latest `1.5`), which requires Node.js >= 22.19.0. Compatibility
202
- with older `@mariozechner/*` interfaces is not claimed.
203
-
204
- Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
205
- environment overrides are not mapped to ACP. See
206
- [development checks](development.md#verification) for the scope of automated validation.
216
+ - Requires Node.js >= 22.19.0, Pi (`@earendil-works/*`) 1.5.x, and `agy` >=
217
+ 1.5.10. Older `@mariozechner/*` Pi interfaces are not supported.
218
+ - Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
219
+ environment overrides are not mapped to ACP.
220
+
221
+ See [verification](development.md#verification) for the automated test and
222
+ compatibility scope.
@@ -0,0 +1,56 @@
1
+ # Releasing
2
+
3
+ Maintainer guide for automated releases and publishing recovery. For everyday
4
+ CI checks and pull request rules, see
5
+ [CI and pull requests](development.md#ci-and-pull-requests).
6
+
7
+ ## Automated release flow
8
+
9
+ Releases are managed by `release-please` (`release-please-config.json` and
10
+ `.release-please-manifest.json`) via `.github/workflows/release.yml` on Node.js
11
+ 24:
12
+
13
+ 1. Merging Conventional Commits (`feat:`, `fix:`, etc.) to `main` runs the
14
+ `release-please` job, which opens or updates a release PR updating
15
+ `package.json`, `CHANGELOG.md`, and `.release-please-manifest.json`.
16
+ 2. Squash-merging that release PR (preserving its `chore(main): release X.Y.Z`
17
+ title) creates the `vX.Y.Z` tag and GitHub Release, then triggers the
18
+ `publish` job to run `npm run check`, `npm test`, `npm pack --dry-run`, and
19
+ `npm publish --access public --provenance`.
20
+
21
+ Ordinary commits to `main` run `release-please` only and do not trigger
22
+ `publish`.
23
+
24
+ ## Repository settings and credentials
25
+
26
+ - **GitHub Actions PR permissions:** Enable **Allow GitHub Actions to create and
27
+ approve pull requests** in Settings → Actions → General. Without a
28
+ `RELEASE_PLEASE_TOKEN` PAT (`contents: write` and `pull-requests: write`) in
29
+ repository secrets, `GITHUB_TOKEN` is used; close and reopen the release PR
30
+ after its final update to trigger `ci.yml` when branch protection requires it.
31
+ - **npm Trusted Publishing (OIDC):** Configure Trusted Publishing on npm for
32
+ owner `fdkevin0`, repository `pi-agy-acp`, and workflow `release.yml`. The
33
+ `publish` job grants `id-token: write` and updates npm to `^11.5.1`.
34
+ - **Token fallback:** An optional `NPM_TOKEN` repository secret supplies
35
+ `NODE_AUTH_TOKEN` (use a granular write token with 2FA bypass if needed).
36
+
37
+ ## Guardrails and recovery
38
+
39
+ - The `publish` job accepts stable semver tags (`vX.Y.Z`) matching
40
+ `package.json` only, publishes one version at a time, and never moves an
41
+ existing tag. Branch-based `workflow_dispatch` runs are rejected.
42
+ - Only an npm registry HTTP `404` is treated as unpublished; HTTP `200` skips
43
+ republishing, and network, auth, or server errors stop the job.
44
+ - **Recovering a failed `publish` job** (or missing GitHub Release after npm
45
+ publication succeeded): choose **Re-run failed jobs** on that workflow run
46
+ (re-running all jobs on a `main` run skips `publish` once the tag exists), or
47
+ run:
48
+
49
+ ```sh
50
+ gh workflow run release.yml --ref vX.Y.Z
51
+ ```
52
+
53
+ GitHub Releases are created only for existing tags via
54
+ `gh release create --verify-tag`. Manual tag pushes (`vX.Y.Z`) also trigger
55
+ `publish` but bypass `release-please`, leaving `CHANGELOG.md` and
56
+ `.release-please-manifest.json` out of sync.
package/index.ts CHANGED
@@ -285,8 +285,49 @@ export default function (
285
285
  }
286
286
  }
287
287
  }
288
+ type RefreshOutcome =
289
+ | { status: 'ok'; count: number }
290
+ | { status: 'cancelled' }
291
+ | { status: 'error'; error: string }
292
+ const refreshModelsSafe = async (
293
+ signal?: AbortSignal,
294
+ ): Promise<RefreshOutcome> => {
295
+ const current = activeRuntime
296
+ if (!current) {
297
+ return {
298
+ status: 'error',
299
+ error: 'Antigravity ACP runtime is disposed.',
300
+ }
301
+ }
302
+ try {
303
+ await current.warmup({ force: true, signal })
304
+ return { status: 'ok', count: current.catalog.list().length }
305
+ } catch (err) {
306
+ if (signal?.aborted) return { status: 'cancelled' }
307
+ return {
308
+ status: 'error',
309
+ error: err instanceof Error ? err.message : String(err),
310
+ }
311
+ }
312
+ }
313
+ const withLoader = <T>(
314
+ ctx: ExtensionContext,
315
+ label: string,
316
+ cancelled: T,
317
+ run: (signal?: AbortSignal) => Promise<T>,
318
+ ): Promise<T> =>
319
+ ctx.mode === 'tui' && typeof ctx.ui.custom === 'function'
320
+ ? ctx.ui.custom<T>((tui, theme, _kb, done) => {
321
+ const loader = new BorderedLoader(tui, theme, label)
322
+ loader.onAbort = () => done(cancelled)
323
+ void run(loader.signal).then((result) => {
324
+ if (!loader.signal.aborted) done(result)
325
+ })
326
+ return loader
327
+ })
328
+ : run()
288
329
  pi.registerCommand('agy-acp', {
289
- description: 'Antigravity ACP status, quota, or reset',
330
+ description: 'Antigravity ACP status, quota, refresh, or reset',
290
331
  getArgumentCompletions: (prefix) => {
291
332
  const normalized = prefix.trimStart()
292
333
  const items = [
@@ -294,6 +335,7 @@ export default function (
294
335
  'quota',
295
336
  'quota used',
296
337
  'quota remaining',
338
+ 'refresh',
297
339
  'reset',
298
340
  ]
299
341
  .filter((command) => command.startsWith(normalized))
@@ -308,6 +350,31 @@ export default function (
308
350
  command === 'quota' && tokens.length === 2
309
351
  ? asQuotaDisplay(tokens[1])
310
352
  : undefined
353
+ if (command === 'refresh' && tokens.length === 1) {
354
+ const outcome = await withLoader<RefreshOutcome>(
355
+ ctx,
356
+ 'Refreshing Antigravity models...',
357
+ { status: 'cancelled' },
358
+ refreshModelsSafe,
359
+ )
360
+ if (shutDown) return
361
+ if (outcome.status === 'cancelled') {
362
+ ctx.ui.notify('Model refresh cancelled', 'info')
363
+ return
364
+ }
365
+ if (outcome.status === 'error') {
366
+ ctx.ui.notify(
367
+ `Antigravity model refresh failed: ${outcome.error}`,
368
+ 'error',
369
+ )
370
+ return
371
+ }
372
+ ctx.ui.notify(
373
+ `Refreshed Antigravity catalog (${outcome.count} model${outcome.count === 1 ? '' : 's'})`,
374
+ 'info',
375
+ )
376
+ return
377
+ }
311
378
  if (command === 'reset' && tokens.length === 1) {
312
379
  clearStatus(ctx)
313
380
  await reset()
@@ -321,7 +388,7 @@ export default function (
321
388
  (tokens.length === 1 || requestedDisplay !== undefined)
322
389
  if (!isStatus && !isQuota) {
323
390
  ctx.ui.notify(
324
- 'Usage: /agy-acp [status|quota [used|remaining]|reset]',
391
+ 'Usage: /agy-acp [status|quota [used|remaining]|refresh|reset]',
325
392
  'warning',
326
393
  )
327
394
  return
@@ -333,24 +400,13 @@ export default function (
333
400
  let snapshot: QuotaSnapshot | null = null
334
401
  const epoch = uiEpoch
335
402
  if (command === 'quota') {
336
- snapshot =
337
- ctx.mode === 'tui' && typeof ctx.ui.custom === 'function'
338
- ? await ctx.ui.custom<QuotaSnapshot | null>(
339
- (tui, theme, _kb, done) => {
340
- const loader = new BorderedLoader(
341
- tui,
342
- theme,
343
- 'Fetching Antigravity quota...',
344
- )
345
- loader.onAbort = () => done(null)
346
- // readQuotaSafe converts runtime errors into snapshots so loaders always close cleanly.
347
- void readQuotaSafe().then((result) => {
348
- if (!loader.signal.aborted) done(result)
349
- })
350
- return loader
351
- },
352
- )
353
- : await readQuotaSafe()
403
+ // readQuotaSafe converts runtime errors into snapshots so loaders always close cleanly.
404
+ snapshot = await withLoader<QuotaSnapshot | null>(
405
+ ctx,
406
+ 'Fetching Antigravity quota...',
407
+ null,
408
+ () => readQuotaSafe(),
409
+ )
354
410
  if (shutDown) return
355
411
  if (snapshot === null) {
356
412
  if (epoch === uiEpoch) updateStatus(ctx, activeRuntime?.quota.peek())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agy-acp",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Google Antigravity ACP provider extension for Pi Coding Agent",