pi-agy-acp 0.1.2 → 0.1.4

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,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4](https://github.com/fdkevin0/pi-agy-acp/compare/v0.1.3...v0.1.4) (2026-11-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * accept the flat mcp_pi_<tool> name agy 1.5.8 reports for Pi tools ([#23](https://github.com/fdkevin0/pi-agy-acp/issues/23)) ([d202134](https://github.com/fdkevin0/pi-agy-acp/commit/d2021349a4886ae34c5d4de7510da102f0e0c655))
9
+ * deliver harness system prompt in opening ACP prompt ([#24](https://github.com/fdkevin0/pi-agy-acp/issues/24)) ([#26](https://github.com/fdkevin0/pi-agy-acp/issues/26)) ([b8679b0](https://github.com/fdkevin0/pi-agy-acp/commit/b8679b0baa171d6447a1cb11195d82a949bb2adf))
10
+ * match quota groups to specific models and scope cache-warming veto ([#21](https://github.com/fdkevin0/pi-agy-acp/issues/21)) ([4f5bc7b](https://github.com/fdkevin0/pi-agy-acp/commit/4f5bc7b82f4e232ba36e2fcd3aa1e9ea5483e88b))
11
+ * preserve turn usage totals, pin CI baseline, and test permission probe timing ([#10](https://github.com/fdkevin0/pi-agy-acp/issues/10)) ([#27](https://github.com/fdkevin0/pi-agy-acp/issues/27)) ([148fb6a](https://github.com/fdkevin0/pi-agy-acp/commit/148fb6a2f9bf12b31cac4e854d22a652a72c4f3b))
12
+
13
+ ## [0.1.3]
14
+
15
+ - Default quota display to `used` across the status bar, quota panel, and warnings, with `/agy-acp quota [used|remaining]` persistence in `settings.json` and `PI_AGY_QUOTA_DISPLAY` startup override.
16
+ - Harden MCP HTTP request boundaries, runtime disposal, conversation turn ownership, and tool continuation/cancellation handling.
17
+ - Correct the minimum Node.js version to 22.19.0 to match Pi 1.5.x requirements.
18
+ - Add contribution and security policies, issue templates, dependency updates, and CI coverage for Node.js 22.19.0 and 24.
19
+
3
20
  ## [0.1.2]
4
21
 
5
22
  - Fix model refresh self-cancellation and support forced or cancelled refreshes.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # pi-agy-acp
2
2
 
3
+ [![CI](https://github.com/fdkevin0/pi-agy-acp/actions/workflows/ci.yml/badge.svg)](https://github.com/fdkevin0/pi-agy-acp/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/pi-agy-acp)](https://www.npmjs.com/package/pi-agy-acp)
5
+
3
6
  Use Google Antigravity in Pi through the official, locally installed `agy` CLI.
4
7
  This extension registers the `antigravity-acp` provider and lets Pi execute the
5
8
  model's tool calls. It supports streaming text and reasoning, images, and
@@ -7,7 +10,7 @@ parallel tool calls.
7
10
 
8
11
  ## Prerequisites
9
12
 
10
- - Node.js >= 22.18.0.
13
+ - Node.js >= 22.19.0.
11
14
  - Pi (`@earendil-works/pi-coding-agent`) 1.5.x.
12
15
  - The official `agy` CLI >= 1.4.12, signed in with your Google account.
13
16
  Run `agy` in your terminal to complete sign-in before using the extension.
@@ -44,11 +47,11 @@ automatically from your account.
44
47
  | Command | Purpose |
45
48
  | --- | --- |
46
49
  | `/agy-acp` or `/agy-acp status` | Show runtime state, account details, models, sessions, and the last turn. |
47
- | `/agy-acp quota` | Show account details, grouped quota bars, and reset countdowns. |
50
+ | `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns (remembers the last selected mode). |
48
51
  | `/agy-acp reset` | Close ACP sessions; the next request rebuilds the connection. |
49
52
 
50
- After an Antigravity turn settles, the status bar shows remaining quota (for example,
51
- `AGY 80%`) and warns when quota is low; see [quota status](docs/reference.md#quota-status-and-warnings).
53
+ After an Antigravity turn settles, the status bar shows quota usage (for example,
54
+ `AGY 20%`, or `AGY 80%` in `remaining` mode) and warns when quota is low; see [quota status](docs/reference.md#quota-status-and-warnings).
52
55
 
53
56
  Default prices are zero, not a promise of free calls. Pi pricing overrides are
54
57
  used when configured.
@@ -59,3 +62,5 @@ used when configured.
59
62
  - [Development](docs/development.md): setup, request flow, source layout, and verification.
60
63
  - [Changelog](CHANGELOG.md): release history and upcoming changes.
61
64
  - [Attribution](NOTICE) and [MIT license](LICENSE).
65
+
66
+ For contributions, see [CONTRIBUTING.md](https://github.com/fdkevin0/pi-agy-acp/blob/main/CONTRIBUTING.md). Report vulnerabilities through the [security policy](https://github.com/fdkevin0/pi-agy-acp/blob/main/SECURITY.md).
@@ -16,9 +16,11 @@ pi -e ./index.ts
16
16
 
17
17
  1. The extension registers `antigravity-acp` with Pi. The first request starts
18
18
  `agy acp --process-per-session` and a loopback MCP bridge.
19
- 2. Pi messages and tool definitions are converted into an ACP prompt. The runtime
20
- reuses a session when its history prefix still matches; otherwise it replays
21
- the available history into a new session.
19
+ 2. Session creation appends only a static MCP tool-routing preamble to `agy`'s
20
+ system prompt; Pi's system prompt, compacted initial tool schemas, and any
21
+ replayed history travel in the session's opening prompt within the 160 KB
22
+ replay budget. Later turns on an intact history prefix reuse the session and
23
+ send only new input (plus any dynamic tool deltas).
22
24
  3. Model tool calls reach the bridge and remain pending while Pi executes them.
23
25
  Pi receives a `toolUse` result, then supplies tool results on its next request.
24
26
  4. Those results resolve the pending MCP requests, allowing the same ACP turn to
@@ -33,16 +35,26 @@ pi -e ./index.ts
33
35
  caller's wait; shared discovery still closes its session and cleans its files.
34
36
  - **Session lifecycle:** The bridge binds to `127.0.0.1`, uses per-session bearer
35
37
  credentials, and validates structured tool identity before granting permissions.
38
+ Live `agy 1.5.9` sessions issue `session/request_permission` only inside an
39
+ active `session/prompt` turn (never during `session/new` or
40
+ `session/set_config_option`), so session creation and idle pre-/post-turn
41
+ windows remain fail-closed (`cancelled` before `session/new` completes;
42
+ `reject_once` when no live turn owns the session, even after MCP handshake).
36
43
  Tree navigation and compaction close conversation sessions and their files,
37
- retaining the process, bridge, and caches. Pi 1.5.0 reports completed switches
38
- through `session_start` (`new`, `resume`, or `fork`), which uses the same light
39
- reset if the runtime survives. `session_shutdown` and `/agy-acp reset` dispose
40
- the runtime. Cancelled turns wait for prompt settlement for up to five seconds,
41
- then mark the conversation for rebuilding.
44
+ retaining the process, bridge, and caches. `session_start` (`new`, `resume`, or
45
+ `fork`) uses the same light reset if the runtime survives; `session_shutdown`
46
+ and `/agy-acp reset` dispose the runtime.
47
+ Disposal is idempotent, drains in-flight startup and bridge binding, cancels
48
+ waiters, and rolls back late session replies from obsolete processes or
49
+ conversations. A turn owns cancellation through streaming and parked tool
50
+ execution until its step drains, `agent_settled` runs, or the process exits;
51
+ only a fully drained `tool-calls` handoff preserves parked tool calls.
52
+ First interruption wins (`abandon` vs. `fail`), cancellation takes priority
53
+ over buffered output, and turn/tenant identities guard all async callbacks.
42
54
  - **Quota and TUI:** Settled checks share the reader's TTL and in-flight request
43
55
  without blocking Pi. Model selection reads memory only. UI generation checks
44
- discard stale background results; warning keys include bucket, reset time, and
45
- threshold. An explicit quota query can discover uncached account tiers through
56
+ discard stale background results; warning keys include group, bucket, reset
57
+ time, and threshold. An explicit quota query can discover uncached account tiers through
46
58
  one tool-less ACP session per runtime, persisting the tier in `catalog.json`.
47
59
  Email lookup reads at most the last 64 KiB of each candidate login log and uses
48
60
  the last match in the first matching file. Runtime warnings stay off stderr to
@@ -55,6 +67,20 @@ pi -e ./index.ts
55
67
  receive `context_length_exceeded` and `quota exceeded` markers for Pi's
56
68
  compaction and retry decisions; transport timeouts remain distinct.
57
69
 
70
+ ## MCP HTTP boundary
71
+
72
+ The loopback bridge returns 400 for invalid URLs and 413 for authenticated POST
73
+ bodies exceeding 1 MiB (1,048,576 bytes), including chunked uploads. Rejected
74
+ oversized uploads close their connection after the error response. JSON parse
75
+ errors retain the MCP parse-error response. Unexpected handler failures return
76
+ 500 before headers or destroy an already-started response; listener errors go to
77
+ the diagnostic sink.
78
+
79
+ Node's HTTP parser enforces a 10-second header reception deadline and a 30-second
80
+ whole-request reception deadline, checked every second. These are reception limits
81
+ only and do not cap completed SSE tool streams. Shutdown stops accepting
82
+ connections and destroys all tracked sockets without waiting for tool promises.
83
+
58
84
  ## Source layout
59
85
 
60
86
  | File or group | Responsibility |
@@ -95,16 +121,39 @@ npm pack --dry-run
95
121
 
96
122
  ## CI and releases
97
123
 
98
- `ci.yml` checks pull requests and pushes to `main`. `release.yml` runs only for
99
- version-tag pushes or manual runs on an existing tag, so ordinary commits do not
100
- run a second test suite or trigger publication. Both use Node.js 24. There is no
101
- committed lockfile, so dependency installation uses `npm install`.
102
-
103
- To release, bump `package.json`, commit the change, and push its matching
104
- `vX.Y.Z` tag. The workflow accepts stable versions only; publish one version at
105
- a time and never move a published tag. It validates the tag and version, then
106
- checks, tests, and packs before publishing. Only a registry 404 means the version
107
- is absent; network, authentication, and server errors stop the job.
124
+ `ci.yml` checks pull requests and pushes to `main`. `release.yml` runs on pushes
125
+ to `main` (to run `release-please`), version-tag pushes, or manual runs on an
126
+ existing tag, so ordinary commits do not trigger the `publish` job. CI tests the
127
+ pinned `devDependencies` baseline on Node.js 22.19.0 and 24, plus a `pi-compat`
128
+ matrix across `@earendil-works/pi-*` `1.5.0` and latest `1.5`; releases use
129
+ Node.js 24. `.npmrc` sets `package-lock=false` so dependency installation stays
130
+ lockfile-free via `npm install`.
131
+
132
+ All changes to `main` require a pull request, passing CI on both Node versions,
133
+ and resolved review discussions. Squash merge after CI passes; no second-person
134
+ approval is required.
135
+
136
+ Releases are automated with `release-please` (`release-please-config.json` and
137
+ `.release-please-manifest.json`):
138
+ - Merging Conventional Commits (`feat:`, `fix:`, etc.) to `main` opens or updates
139
+ a release PR that bumps `package.json` and updates `CHANGELOG.md` and
140
+ `.release-please-manifest.json`.
141
+ - Squash-merging that release PR (preserving its `chore(main): release X.Y.Z`
142
+ title) creates the `vX.Y.Z` tag and GitHub Release, then triggers the
143
+ `publish` job in `release.yml` to check, test, pack, and publish to npm.
144
+ - Enable **Allow GitHub Actions to create and approve pull requests** in
145
+ repository Settings → Actions → General. Without a `RELEASE_PLEASE_TOKEN` PAT
146
+ (with `contents: write` and `pull-requests: write`) in repository secrets,
147
+ `GITHUB_TOKEN` is used; in that case, close and reopen the release PR after
148
+ its final update to trigger `ci.yml` when branch protection requires it.
149
+ - To recover a failed `publish` job, choose **Re-run failed jobs** on that
150
+ workflow run (re-running all jobs on a `main` run skips `publish` once the tag
151
+ exists) or run `gh workflow run release.yml --ref vX.Y.Z`. Manual tag pushes
152
+ (`vX.Y.Z`) also trigger `publish` but bypass `release-please`, leaving
153
+ `CHANGELOG.md` and `.release-please-manifest.json` out of sync.
154
+ - The workflow accepts stable versions only, publishes one version at a time,
155
+ and never moves a published tag. Only a registry 404 means the version is
156
+ absent; network, authentication, and server errors stop the job.
108
157
 
109
158
  Configure npm [Trusted Publishing](https://docs.npmjs.com/trusted-publishers/)
110
159
  for owner `fdkevin0`, repository `pi-agy-acp`, and workflow filename `release.yml`.
package/docs/reference.md CHANGED
@@ -7,11 +7,11 @@ For installation and your first request, start with the [installation guide](../
7
7
  | Command | Behavior |
8
8
  | --- | --- |
9
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` | Show account details, grouped quota bars, and reset countdowns. |
10
+ | `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns, optionally switching and remembering the display mode. |
11
11
  | `/agy-acp reset` | Close ACP sessions; the next request rebuilds a session from Pi's history. |
12
12
 
13
13
  Subcommands support completion with Tab. Unknown arguments display
14
- `Usage: /agy-acp [status|quota|reset]` as a warning.
14
+ `Usage: /agy-acp [status|quota [used|remaining]|reset]` as a warning.
15
15
 
16
16
  ### Status panel
17
17
 
@@ -35,8 +35,10 @@ editor. The underlying quota query may finish and update the cache, but its resu
35
35
  will not appear after cancellation. Non-TUI modes query directly without a loader.
36
36
 
37
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 showing the remaining fraction,
39
- a rounded percentage, and a relative reset time. For example:
38
+ one row per quota window, with a 12-cell bar, a rounded percentage, and a relative
39
+ reset time. By default (`used` mode), bars and percentages count up from `0%`; pass
40
+ `remaining` (`/agy-acp quota remaining`) to count down from `100%`. The last
41
+ selected mode is saved in `settings.json` inside `PI_AGY_HOME`. For example:
40
42
 
41
43
  ```text
42
44
  Antigravity Quota
@@ -44,8 +46,8 @@ Antigravity Quota
44
46
 
45
47
  Gemini Models
46
48
  Gemini Flash, Gemini Pro
47
- 5h [████████████] 100% · resets in 4h 59m
48
- weekly [███████████░] 91% · resets in 6d 7h
49
+ 5h [░░░░░░░░░░░░] 0% · resets in 4h 59m
50
+ weekly [█░░░░░░░░░░░] 9% · resets in 6d 7h
49
51
  ```
50
52
 
51
53
  Missing values display `n/a`; an elapsed reset time displays `resetting soon`.
@@ -53,13 +55,13 @@ Severity uses the actual remaining fraction rather than the rounded percentage:
53
55
 
54
56
  | Condition | Notification |
55
57
  | --- | --- |
56
- | All known windows above 20% | Info |
57
- | Any window at or below 20%, with none at or below 5% | Warning |
58
- | Any window at or below 5%, or a failed quota query | Error |
58
+ | All known windows above 20% remaining (<80% used) | Info |
59
+ | Any window at or below 20% remaining (≥80% used), with none at or below 5% remaining | Warning |
60
+ | Any window at or below 5% remaining (≥95% used), or a failed quota query | Error |
59
61
 
60
62
  Errors include the reason. If cached groups are available after a failed query,
61
- the title marks them as `(stale)` and still displays their bars. An empty successful
62
- response displays `No quota data available.`.
63
+ the title marks them as `(stale)` and still displays their bars. An empty
64
+ successful response displays `No quota data available.`.
63
65
 
64
66
  ### Account details
65
67
 
@@ -75,21 +77,25 @@ isolated. Cached plans and login logs can be stale after an account change.
75
77
  ### Quota status and warnings
76
78
 
77
79
  When a run using `antigravity-acp` fully settles, the extension checks `/usage`
78
- in the background and shows a compact status such as `AGY 80%`. It uses the
79
- lowest known window in the selected model family's group, falling back to the
80
- lowest known quota across groups when the family cannot be matched. Failed
81
- checks stay silent. Successful results and failures both respect the two-minute
82
- quota TTL, and overlapping background checks are skipped.
83
-
84
- At 20% and 5% remaining, a warning appears once per bucket, reset time, and
85
- threshold. `/agy-acp quota` explicitly refreshes quota and updates the status;
86
- `/agy-acp status` uses fresh cached quota only. Neither session start nor model
87
- selection launches a quota command. Selecting another provider hides the status;
88
- returning to Antigravity uses only a fresh in-memory snapshot. Reset and shutdown
89
- clear the status.
90
-
91
- While loaded, this extension vetoes Pi's automatic prompt-cache warming to avoid
92
- idle requests consuming quota. It does not alter explicit model requests.
80
+ in the background and shows a compact status indicator such as `AGY 20%` (or
81
+ `AGY 80%` in `remaining` mode). It uses the lowest known remaining window across
82
+ the selected model's matching quota group(s) (or an unambiguous generic family
83
+ group), and omits the status indicator and low-quota warning when group ownership is
84
+ unknown or ambiguous. Failed background checks stay silent. Successful results
85
+ and failures both respect the two-minute quota TTL, and concurrent background
86
+ checks share the in-flight query.
87
+
88
+ At or below 20% and 5% remaining (≥80% and ≥95% used), a warning appears once
89
+ per group, quota window, reset time, and threshold. `/agy-acp quota` explicitly
90
+ refreshes quota and updates the status indicator; `/agy-acp status` uses fresh
91
+ cached quota only. Neither session start nor model selection launches a quota
92
+ command. Selecting another provider hides the status indicator; returning to
93
+ Antigravity uses only a fresh in-memory snapshot. `/agy-acp reset` clears the
94
+ status indicator and warning history; shutdown clears the status indicator.
95
+
96
+ When the active model belongs to `antigravity-acp`, this extension vetoes Pi's
97
+ automatic prompt-cache warming to avoid background warming requests consuming
98
+ quota. Other providers' warming decisions are left unchanged.
93
99
 
94
100
  ## Configuration
95
101
 
@@ -99,6 +105,7 @@ Set these environment variables before starting Pi:
99
105
  | --- | --- | --- |
100
106
  | `PI_AGY_COMMAND` | Absolute path to the `agy` executable. | Automatic discovery. |
101
107
  | `PI_AGY_HOME` | Dedicated directory for this extension's agy state. | `~/.pi/agent/cache/antigravity-acp` |
108
+ | `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` |
102
109
 
103
110
  For example:
104
111
 
@@ -112,8 +119,8 @@ The dedicated directory isolates the bridge agent from your normal agy tools and
112
119
  plugins. It contains agy-managed session data, logs, and the extension's model cache.
113
120
 
114
121
  Temporary session data and old logs are removed automatically. The current log,
115
- model cache, and authentication files are retained; sessions rebuild from Pi's
116
- history. Cleanup is best-effort if files are locked. Use a different `PI_AGY_HOME`
122
+ model cache, `settings.json` (quota display preference), and authentication files
123
+ are retained; sessions rebuild from Pi's history. Cleanup is best-effort if files are locked. Use a different `PI_AGY_HOME`
117
124
  for each concurrently running Pi instance, since startup cleanup assumes exclusive
118
125
  use of the directory.
119
126
 
@@ -144,14 +151,28 @@ older history can be omitted to fit, and historical images become text placehold
144
151
 
145
152
  ## Usage and costs
146
153
 
147
- Usage comes only from the ACP `session/prompt` result. Parked tool steps have no
148
- separate usage report; statistics arrive when the full ACP turn finishes.
149
- For turns spanning multiple model steps, input token buckets use the upstream
150
- implementation's averaging method. They are not an exact per-step measurement.
154
+ Usage comes from the ACP session rather than per-step API headers. Parked `toolUse`
155
+ steps emit zero usage; statistics arrive on the final step when the full ACP turn
156
+ finishes (accumulated across any automatic `max_tokens` continuations).
157
+
158
+ The extension separates cumulative token consumption from final-call context
159
+ occupancy:
160
+
161
+ - `input`, `output`, `cacheRead`, and `cacheWrite` preserve unscaled cumulative
162
+ turn totals from `session/prompt`, so Pi's session totals and flat pricing
163
+ overrides reflect full multi-step consumption.
164
+ - `totalTokens` (which feeds Pi's context meter and auto-compaction threshold via
165
+ `calculateContextTokens`) uses the final model call's live `usage_update.used`
166
+ count when `agy` provides it. When `usage_update` is absent, it falls back to
167
+ averaging the final `session/prompt` segment's prompt tokens across that
168
+ segment's model calls plus final-segment output tokens; this fallback is an
169
+ estimate rather than an exact per-step measurement.
151
170
 
152
171
  Default model prices are zero because pricing is unavailable. If you configure
153
- Pi model pricing overrides, reported usage is priced using those rates. These
154
- estimates are not an invoice amount or a promise of free access.
172
+ Pi model pricing overrides, flat per-million rates price the cumulative turn
173
+ buckets accurately; tiered `inputTokensAbove` rules evaluate against cumulative
174
+ turn prompt tokens rather than per-call prompt sizes. These estimates are not
175
+ an invoice amount or a promise of free access.
155
176
 
156
177
  The extension does not inspect agy's private databases or invoke or distribute
157
178
  binary patch scripts.
@@ -159,9 +180,11 @@ binary patch scripts.
159
180
  ## Compatibility limits
160
181
 
161
182
  This version targets the `@earendil-works/*` Pi packages at version 1.5.x.
162
- Host peer dependencies use `*` as required by Pi package conventions; validation
163
- has been performed against version 1.5.0. Compatibility with older
164
- `@mariozechner/*` interfaces is not claimed.
183
+ Host `peerDependencies` use `*` as required by Pi package conventions;
184
+ `devDependencies` pin a reproducible CI baseline (`1.5.2`), and CI validates
185
+ both that baseline (on Node.js 22.19.0 and 24) and the `1.5.x` host range
186
+ (`1.5.0` and latest `1.5`), which requires Node.js >= 22.19.0. Compatibility
187
+ with older `@mariozechner/*` interfaces is not claimed.
165
188
 
166
189
  Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
167
190
  environment overrides are not mapped to ACP. See