@caio2a7/opencode-antigravity-quota 0.0.0-stage → 0.1.0
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 +24 -0
- package/LICENSE +21 -0
- package/README.md +159 -2
- package/dist/tui.js +1605 -0
- package/package.json +90 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-11-22
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- OpenCode V2 CLI/TUI plugin rendering an "Antigravity Quota" block in the session sidebar (`sidebar.content` slot).
|
|
14
|
+
- Unified quota bars for `Gemini-5h` (5-hour pool), `Gemini-Week` (7-day weekly pool) and `Argon` (7-day weekly pool) with severity colouring, `used`/`remaining` display modes and ticking relative reset countdowns.
|
|
15
|
+
- Primary quota fetch via `POST https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary` (with `v1internal:loadCodeAssist` project discovery when absent), with fallbacks to `v1internal:fetchAvailableModels`, `v1internal:retrieveUserQuota`, Gemini CLI `POST https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota` and `cachedQuota` from `antigravity-accounts.json`.
|
|
16
|
+
- Strictly read-only credential lookup (`ANTIGRAVITY_OAUTH_TOKEN`, `credentialsPath`, `antigravity-accounts.json`, `~/.gemini/antigravity-cli/antigravity-oauth-token`, `~/.gemini/oauth_creds.json`).
|
|
17
|
+
- In-memory-only OAuth token refresh via `https://oauth2.googleapis.com/token` with zero hardcoded OAuth secrets (resolving client credentials from `ANTIGRAVITY_CLIENT_ID`/`ANTIGRAVITY_CLIENT_SECRET` or read-only scan of installed `opencode-antigravity-auth`).
|
|
18
|
+
- Multi-window coordination through `${XDG_CACHE_HOME:-~/.cache}/opencode-antigravity-quota/state.json` (`0700`/`0600`, atomic rename) and `fetch.lock`: shared snapshot cache, single-flight requests, `Retry-After` support, persisted exponential backoff (2m → 30m) and immediate cache invalidation when the active account changes.
|
|
19
|
+
- Polite polling with a 120s default (60s minimum), stale-while-error / rate-limit display, debounced post-turn refresh and `/antigravity-quota` (`/ag-quota`) slash command / command-palette entry.
|
|
20
|
+
- Options: `refreshInterval`, `displayMode`, `showModels`, `credentialsPath`.
|
|
21
|
+
- Release automation from GitHub Actions via npm trusted publishing (OIDC) with provenance.
|
|
22
|
+
|
|
23
|
+
[Unreleased]: https://github.com/Caio2a7/opencode-antigravity-quota/compare/v0.1.0...HEAD
|
|
24
|
+
[0.1.0]: https://github.com/Caio2a7/opencode-antigravity-quota/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Caio2a7
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,160 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-antigravity-quota
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Antigravity & Gemini usage, quota and rate limits in the OpenCode TUI sidebar — Gemini 5-hour, Gemini weekly and Argon weekly pools, themed by your OpenCode theme.**
|
|
4
|
+
|
|
5
|
+
An [OpenCode](https://opencode.ai) V2 CLI/TUI plugin that displays your Google Antigravity and Gemini CLI model quotas
|
|
6
|
+
and reset countdowns right next to your active session.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
Antigravity Quota
|
|
10
|
+
Gemini-5h ━━━━━━━━────── 60%
|
|
11
|
+
resets in 1h 30m
|
|
12
|
+
Gemini-Week ━━━─────────── 20%
|
|
13
|
+
resets in 4d 12h
|
|
14
|
+
Argon ━━━━━━━━━━━─── 80%
|
|
15
|
+
resets in 5d 0h
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Unified quota bars for **Gemini-5h** (5-hour pool), **Gemini-Week** (7-day weekly pool) and **Argon** (7-day weekly
|
|
21
|
+
pool), coloured by severity (green → yellow → red).
|
|
22
|
+
- Supports both `used` (default) and `remaining` percentage display modes.
|
|
23
|
+
- Relative reset countdowns that tick without refetching; untouched buckets (`0%` used) stay on a single clean line.
|
|
24
|
+
- Polite polling: 120s default (60s minimum), shared across OpenCode windows, `Retry-After` support, persisted exponential
|
|
25
|
+
backoff and automatic cache invalidation when the active account changes.
|
|
26
|
+
- `/antigravity-quota` (alias `/ag-quota`) slash command and command-palette entry to force a refresh.
|
|
27
|
+
- Native OpenCode **V2** plugin, strictly read-only credential handling, zero runtime dependencies.
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- OpenCode **V2** (`@opencode/plugin` 2.x). CLI plugins are configured in `~/.config/opencode/cli.json`, not
|
|
32
|
+
`opencode.json` or V1 `tui.json`.
|
|
33
|
+
- Signed in through `opencode-antigravity-auth`, `antigravity-cli`, [Gemini CLI](https://github.com/google-gemini/gemini-cli),
|
|
34
|
+
or `ANTIGRAVITY_OAUTH_TOKEN` set.
|
|
35
|
+
- Linux, macOS or Windows.
|
|
36
|
+
|
|
37
|
+
## Install the OpenCode plugin
|
|
38
|
+
|
|
39
|
+
Add the package to the `plugins` array of `~/.config/opencode/cli.json` and restart the TUI:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"plugins": ["@caio2a7/opencode-antigravity-quota"]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
With options:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"plugins": [
|
|
52
|
+
{
|
|
53
|
+
"package": "@caio2a7/opencode-antigravity-quota",
|
|
54
|
+
"options": { "refreshInterval": 90, "displayMode": "remaining" }
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
From a local checkout:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
bun install
|
|
64
|
+
bun run build
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then use the absolute path of the checkout:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"plugins": ["/path/to/opencode-antigravity-quota"]
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Restart OpenCode and open a session; the sidebar must be visible (`session.sidebar` is `auto` by default and needs a
|
|
76
|
+
wide terminal).
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
| Option | Type | Default | Description |
|
|
81
|
+
| ----------------- | ---------------------- | -------- | ----------------------------------------------------------------------------- |
|
|
82
|
+
| `refreshInterval` | number | `120` | Polling interval in seconds. Values below `60` are raised to `60`. |
|
|
83
|
+
| `displayMode` | `"used" \| "remaining"` | `"used"` | Show either utilization (`used`) or remaining quota (`remaining`). |
|
|
84
|
+
| `showModels` | boolean | `true` | Show the weekly `Argon` pool alongside `Gemini-5h` and `Gemini-Week`. |
|
|
85
|
+
| `credentialsPath` | string | – | Explicit credentials file location, used as-is (`~` is not expanded). |
|
|
86
|
+
|
|
87
|
+
Invalid values fall back to the defaults.
|
|
88
|
+
|
|
89
|
+
## How it works
|
|
90
|
+
|
|
91
|
+
For Antigravity accounts, the plugin calls `POST https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary`
|
|
92
|
+
(discovering `cloudaicompanionProject` via `v1internal:loadCodeAssist` when absent) to read both the 5-hour and weekly
|
|
93
|
+
Gemini pools plus Argon in a single call, falling back to `v1internal:fetchAvailableModels` and
|
|
94
|
+
`v1internal:retrieveUserQuota` if needed. For Gemini CLI accounts, it calls
|
|
95
|
+
`POST https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota`.
|
|
96
|
+
|
|
97
|
+
Standard Gemini models (Pro, Flash, Neon, Hydrogen) report both their 5-hour (`Gemini-5h`) and 7-day weekly
|
|
98
|
+
(`Gemini-Week`) quota windows, while `Argon` tracks its separate 7-day weekly window.
|
|
99
|
+
|
|
100
|
+
Credentials are looked up **read-only**, in this order:
|
|
101
|
+
|
|
102
|
+
1. `ANTIGRAVITY_OAUTH_TOKEN` environment variable (optional `ANTIGRAVITY_PROJECT_ID`)
|
|
103
|
+
2. Explicit `credentialsPath` option (supports `antigravity-accounts.json`, `antigravity-oauth-token` and Gemini CLI JSON)
|
|
104
|
+
3. `${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-~/.config}/opencode}/antigravity-accounts.json` (plus `%APPDATA%\opencode\antigravity-accounts.json` on Windows)
|
|
105
|
+
4. `~/.gemini/antigravity-cli/antigravity-oauth-token`
|
|
106
|
+
5. `~/.gemini/oauth_creds.json` (Gemini CLI)
|
|
107
|
+
|
|
108
|
+
When an account only has a refresh token and no reusable fresh access token, the plugin exchanges it in memory using
|
|
109
|
+
Google's OAuth token endpoint (falling back to any `cachedQuota` in `antigravity-accounts.json` if OAuth client
|
|
110
|
+
credentials are unavailable).
|
|
111
|
+
|
|
112
|
+
### Multiple OpenCode windows
|
|
113
|
+
|
|
114
|
+
All OpenCode instances on a machine coordinate through `${XDG_CACHE_HOME:-~/.cache}/opencode-antigravity-quota/state.json`
|
|
115
|
+
(directory `0700`, file `0600`, written atomically) and a `fetch.lock` file (stale after 30s). Fresh snapshots are
|
|
116
|
+
adopted instead of refetching, failure backoff is shared, and switching the active account in `antigravity-accounts.json`
|
|
117
|
+
invalidates cached data from the previous account immediately.
|
|
118
|
+
|
|
119
|
+
The cache file stores only quota percentages, reset timestamps, account email, pool counts and backoff metadata — never
|
|
120
|
+
access or refresh tokens. Deleting it is always safe.
|
|
121
|
+
|
|
122
|
+
### Backoff
|
|
123
|
+
|
|
124
|
+
A 429 response blocks requests for `Retry-After` (capped at 1 hour) or 2m → 4m → 8m… up to 30m; network and HTTP errors
|
|
125
|
+
use the same schedule. While blocked, `/antigravity-quota` shows "Rate limited by Google — retrying in Xm" and the
|
|
126
|
+
sidebar shows a muted `rate limited · retry in Xm` line next to the last known snapshot. Repeated 401/403 responses back
|
|
127
|
+
off locally (up to 10 minutes) without blocking other windows.
|
|
128
|
+
|
|
129
|
+
## Privacy & security
|
|
130
|
+
|
|
131
|
+
- Tokens are sent only over HTTPS to `oauth2.googleapis.com`, `daily-cloudcode-pa.googleapis.com` and `cloudcode-pa.googleapis.com`.
|
|
132
|
+
- Credential files are read strictly **read-only**; tokens are never written back, logged or persisted to the plugin cache.
|
|
133
|
+
- Zero runtime dependencies; no telemetry, no browser scraping, no subprocesses.
|
|
134
|
+
- The Cloud Code quota endpoints are unofficial and may change without notice; responses are parsed defensively and
|
|
135
|
+
errors surface as muted sidebar rows instead of crashing the TUI.
|
|
136
|
+
|
|
137
|
+
## Troubleshooting
|
|
138
|
+
|
|
139
|
+
| Symptom | Fix |
|
|
140
|
+
| ---------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
141
|
+
| "Antigravity/Gemini credentials not found" | Sign in via `opencode-antigravity-auth`, `gemini`, or set `ANTIGRAVITY_OAUTH_TOKEN`. |
|
|
142
|
+
| "Gemini CLI token expired" | Run `gemini` once so Gemini CLI refreshes its own token. |
|
|
143
|
+
| Nothing in the sidebar | Open a session, widen the terminal and check `session.sidebar` in `cli.json`. |
|
|
144
|
+
| Numbers look stale | Run `/antigravity-quota` or `/ag-quota` to refresh (reuses data fresher than 30s).|
|
|
145
|
+
| "rate limited · retry in Xm" | Expected: backoff is shared across windows; raise `refreshInterval` if needed. |
|
|
146
|
+
|
|
147
|
+
Plugin load errors are logged to `~/.local/share/opencode/log/opencode.log`.
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
bun install
|
|
153
|
+
bun test
|
|
154
|
+
bun run typecheck
|
|
155
|
+
bun run build # compiles dist/tui.js (also runs on npm pack)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
[MIT](LICENSE)
|