@slkiser/opencode-quota 2.4.0 → 2.5.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/README.md +192 -226
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/copilot.d.ts +48 -16
- package/dist/lib/copilot.d.ts.map +1 -1
- package/dist/lib/copilot.js +540 -283
- package/dist/lib/copilot.js.map +1 -1
- package/dist/lib/entries.d.ts +11 -3
- package/dist/lib/entries.d.ts.map +1 -1
- package/dist/lib/entries.js.map +1 -1
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/grouped-entry-normalization.d.ts +7 -0
- package/dist/lib/grouped-entry-normalization.d.ts.map +1 -0
- package/dist/lib/grouped-entry-normalization.js +50 -0
- package/dist/lib/grouped-entry-normalization.js.map +1 -0
- package/dist/lib/grouped-header-format.d.ts +5 -0
- package/dist/lib/grouped-header-format.d.ts.map +1 -0
- package/dist/lib/grouped-header-format.js +16 -0
- package/dist/lib/grouped-header-format.js.map +1 -0
- package/dist/lib/quota-command-format.d.ts +2 -3
- package/dist/lib/quota-command-format.d.ts.map +1 -1
- package/dist/lib/quota-command-format.js +14 -43
- package/dist/lib/quota-command-format.js.map +1 -1
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +51 -0
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/lib/toast-format-grouped.d.ts +1 -9
- package/dist/lib/toast-format-grouped.d.ts.map +1 -1
- package/dist/lib/toast-format-grouped.js +8 -25
- package/dist/lib/toast-format-grouped.js.map +1 -1
- package/dist/lib/types.d.ts +56 -39
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +69 -8
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/qwen-code.d.ts.map +1 -1
- package/dist/providers/qwen-code.js.map +1 -1
- package/dist/providers/zai.d.ts.map +1 -1
- package/dist/providers/zai.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,178 +1,214 @@
|
|
|
1
1
|
# Opencode Quota
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local quota toasts and token reports for OpenCode, with zero LLM/model API calls.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`opencode-quota` gives you two things:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Automatic quota toasts after assistant responses
|
|
8
|
+
- Manual `/quota` and `/tokens_*` commands for deeper local reporting
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
**Quota Toasts** - See your remaining quota at a glance after each assistant response.
|
|
10
|
+
Supported quota providers: GitHub Copilot, OpenAI, Qwen Code, Chutes AI, Firmware AI, Google Antigravity, and Z.ai.
|
|
11
|
+
Supported token pricing: any provider/model present in the local `models.dev` snapshot shipped with the plugin.
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
15
|
-
**Token Report Commands** - Track token usage and estimated costs across sessions using local OpenCode SQLite history plus a local models.dev pricing snapshot. The plugin can refresh that local snapshot at runtime when stale.
|
|
16
|
-
|
|
17
15
|

|
|
18
16
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
- OpenCode >= 1.2.0 (uses SQLite `opencode.db` for session/message history)
|
|
22
|
-
|
|
23
|
-
This plugin no longer supports the legacy folder-based JSON session storage used by older OpenCode versions.
|
|
17
|
+
## Quick Start
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
OpenCode `>= 1.2.0` is required.
|
|
26
20
|
|
|
27
|
-
Add to your `opencode.json`
|
|
21
|
+
Add the plugin to your `opencode.json` or `opencode.jsonc`:
|
|
28
22
|
|
|
29
|
-
```
|
|
23
|
+
```jsonc
|
|
30
24
|
{
|
|
31
25
|
"plugin": ["@slkiser/opencode-quota"]
|
|
32
26
|
}
|
|
33
27
|
```
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
Then:
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
1. Restart or reload OpenCode.
|
|
32
|
+
2. Run `/quota_status` to confirm provider detection.
|
|
33
|
+
3. Run `/quota` to see the manual grouped report.
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
That is enough for most installs. Providers are auto-detected from your existing OpenCode setup.
|
|
36
|
+
|
|
37
|
+
## What You Get
|
|
38
|
+
|
|
39
|
+
- Toasts after assistant responses, idle transitions, and compaction events
|
|
40
|
+
- `/quota` for a grouped manual quota report such as `[OpenAI] (Pro)` or `[Copilot] (business)`
|
|
41
|
+
- `/tokens_*` commands backed by local OpenCode history and a local pricing snapshot
|
|
42
|
+
- No model calls to compute the toast or report output
|
|
43
|
+
|
|
44
|
+
## Common Install Patterns
|
|
45
|
+
|
|
46
|
+
### Basic install
|
|
47
|
+
|
|
48
|
+
If you already use Copilot, OpenAI, Firmware, Chutes, or Z.ai in OpenCode, start here:
|
|
49
|
+
|
|
50
|
+
```jsonc
|
|
40
51
|
{
|
|
41
|
-
"
|
|
42
|
-
"quotaToast": {
|
|
43
|
-
"enabledProviders": ["copilot", "openai", "qwen-code", "google-antigravity"]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
52
|
+
"plugin": ["@slkiser/opencode-quota"]
|
|
46
53
|
}
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
### Google Antigravity
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
Google quota support depends on the companion auth plugin:
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
| `/tokens_today` | Tokens used today (calendar day) |
|
|
59
|
-
| `/tokens_daily` | Tokens used in last 24 hours |
|
|
60
|
-
| `/tokens_weekly` | Tokens used in last 7 days |
|
|
61
|
-
| `/tokens_monthly` | Tokens used in last 30 days (incl. pricing sections) |
|
|
62
|
-
| `/tokens_all` | Tokens used all time |
|
|
63
|
-
| `/tokens_session` | Tokens used in current session |
|
|
64
|
-
| `/tokens_between` | Tokens between two dates (YYYY-MM-DD) |
|
|
60
|
+
```jsonc
|
|
61
|
+
{
|
|
62
|
+
"plugin": ["opencode-antigravity-auth", "@slkiser/opencode-quota"]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### Qwen Code
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Qwen quota support depends on the companion auth plugin:
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
| Firmware AI | `firmware` | OpenCode auth or API key |
|
|
76
|
-
| Chutes AI | `chutes` | OpenCode auth or API key |
|
|
77
|
-
| Google Antigravity | `google-antigravity` | Multi-account via `opencode-antigravity-auth` |
|
|
78
|
-
| Z.ai | `zai` | OpenCode auth (automatic) |
|
|
70
|
+
```jsonc
|
|
71
|
+
{
|
|
72
|
+
"plugin": ["opencode-qwencode-auth", "@slkiser/opencode-quota"]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+
## Commands
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
| Command | What it shows |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `/quota` | Manual grouped quota report |
|
|
81
|
+
| `/quota_status` | Diagnostics: config, provider availability, account detection, pricing snapshot health |
|
|
82
|
+
| `/tokens_today` | Tokens used today (calendar day) |
|
|
83
|
+
| `/tokens_daily` | Tokens used in the last 24 hours |
|
|
84
|
+
| `/tokens_weekly` | Tokens used in the last 7 days |
|
|
85
|
+
| `/tokens_monthly` | Tokens used in the last 30 days, including pricing sections |
|
|
86
|
+
| `/tokens_all` | Tokens used across all local history |
|
|
87
|
+
| `/tokens_session` | Tokens used in the current session |
|
|
88
|
+
| `/tokens_between` | Tokens used between two dates: `YYYY-MM-DD YYYY-MM-DD` |
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
- At plugin runtime, when `experimental.quotaToast.enabled` is `true`, pricing refresh runs as a bounded best-effort check (once per process window, plus persisted attempt tracking) during init and before `/tokens_*` / `/quota_status` report paths.
|
|
86
|
-
- If the active snapshot is older than 3 days, the plugin attempts to fetch `https://models.dev/api.json`, keeps only `input`, `output`, `cache_read`, `cache_write`, and writes a refreshed local runtime snapshot.
|
|
87
|
-
- If fetch fails, reports continue using the last local snapshot (no hard failure).
|
|
90
|
+
There is no `/token` command. The reporting commands are the `/tokens_*` family.
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
## Minimal Config
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
- `.../opencode/opencode-quota/modelsdev-pricing.refresh-state.json`
|
|
94
|
+
You do not need extra config to get started. If you want to narrow the plugin to specific providers, use:
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
```jsonc
|
|
97
|
+
{
|
|
98
|
+
"experimental": {
|
|
99
|
+
"quotaToast": {
|
|
100
|
+
"enabledProviders": ["copilot", "openai", "google-antigravity"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
95
105
|
|
|
96
|
-
|
|
97
|
-
# Disable runtime pricing refresh
|
|
98
|
-
OPENCODE_QUOTA_PRICING_AUTO_REFRESH=0
|
|
106
|
+
If you want grouped toast layout instead of the default classic toast:
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
```jsonc
|
|
109
|
+
{
|
|
110
|
+
"experimental": {
|
|
111
|
+
"quotaToast": {
|
|
112
|
+
"toastStyle": "grouped"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
102
116
|
```
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
`/quota` already uses grouped formatting by default, even if toast style stays `classic`.
|
|
105
119
|
|
|
106
|
-
|
|
107
|
-
npm run pricing:refresh
|
|
108
|
-
npm run pricing:refresh:if-stale
|
|
109
|
-
npm run build
|
|
110
|
-
```
|
|
120
|
+
## Provider Setup At A Glance
|
|
111
121
|
|
|
112
|
-
|
|
122
|
+
| Provider | Works automatically | Extra setup when needed |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| GitHub Copilot | Personal usage via existing OpenCode auth | Add `copilot-quota-token.json` for managed org or enterprise billing |
|
|
125
|
+
| OpenAI | Yes | None |
|
|
126
|
+
| Qwen Code | Needs `opencode-qwencode-auth` | Local-only quota estimation, no remote Qwen quota API |
|
|
127
|
+
| Firmware AI | Usually yes | Optional API key |
|
|
128
|
+
| Chutes AI | Usually yes | Optional API key |
|
|
129
|
+
| Google Antigravity | Needs `opencode-antigravity-auth` | Multi-account account file lives in OpenCode runtime config |
|
|
130
|
+
| Z.ai | Yes | None |
|
|
113
131
|
|
|
114
|
-
|
|
132
|
+
## Provider-Specific Notes
|
|
115
133
|
|
|
116
134
|
<details>
|
|
117
135
|
<summary><strong>GitHub Copilot</strong></summary>
|
|
118
136
|
|
|
119
|
-
|
|
137
|
+
Personal Copilot quota works automatically when OpenCode is already signed in.
|
|
120
138
|
|
|
121
|
-
|
|
139
|
+
For managed billing, create `copilot-quota-token.json` under the OpenCode runtime config directory. You can find the directory with `opencode debug paths`.
|
|
122
140
|
|
|
123
|
-
|
|
124
|
-
2. Create `copilot-quota-token.json` under OpenCode's runtime config directory (see `opencode debug paths`):
|
|
141
|
+
Organization example:
|
|
125
142
|
|
|
126
143
|
```json
|
|
127
144
|
{
|
|
128
145
|
"token": "github_pat_...",
|
|
129
|
-
"tier": "
|
|
146
|
+
"tier": "business",
|
|
147
|
+
"organization": "your-org-slug"
|
|
130
148
|
}
|
|
131
149
|
```
|
|
132
150
|
|
|
133
|
-
|
|
151
|
+
Enterprise example:
|
|
134
152
|
|
|
135
|
-
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"token": "ghp_...",
|
|
156
|
+
"tier": "enterprise",
|
|
157
|
+
"enterprise": "your-enterprise-slug",
|
|
158
|
+
"organization": "optional-org-filter",
|
|
159
|
+
"username": "optional-user-filter"
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Behavior notes:
|
|
164
|
+
|
|
165
|
+
- Personal output is labeled `[Copilot] (personal)`.
|
|
166
|
+
- Managed organization and enterprise output is labeled `[Copilot] (business)`.
|
|
167
|
+
- Managed output includes the org or enterprise slug in the value line so the billing scope is still visible.
|
|
168
|
+
- If both OpenCode OAuth and `copilot-quota-token.json` exist, the PAT config wins.
|
|
169
|
+
- If the PAT config is invalid, the plugin reports that error and does not silently fall back to OAuth.
|
|
170
|
+
- `business` requires `organization`.
|
|
171
|
+
- Enterprise premium usage does not support fine-grained PATs or GitHub App tokens. Use a supported enterprise token such as a classic PAT.
|
|
136
172
|
|
|
137
|
-
|
|
173
|
+
Useful checks:
|
|
174
|
+
|
|
175
|
+
- Run `/quota_status` and inspect `copilot_quota_auth`.
|
|
176
|
+
- Look for `billing_mode`, `billing_scope`, `effective_source`, and `billing_api_access_likely`.
|
|
138
177
|
|
|
139
178
|
</details>
|
|
140
179
|
|
|
141
180
|
<details>
|
|
142
181
|
<summary><strong>OpenAI</strong></summary>
|
|
143
182
|
|
|
144
|
-
|
|
183
|
+
No extra setup is required if OpenCode already has OpenAI or ChatGPT auth configured.
|
|
145
184
|
|
|
146
185
|
</details>
|
|
147
186
|
|
|
148
187
|
<details>
|
|
149
188
|
<summary><strong>Qwen Code</strong></summary>
|
|
150
189
|
|
|
151
|
-
|
|
190
|
+
Qwen support is local-only estimation. The plugin does not call an Alibaba quota API.
|
|
152
191
|
|
|
153
|
-
|
|
192
|
+
Current behavior:
|
|
154
193
|
|
|
155
|
-
- 1000 requests per UTC day
|
|
194
|
+
- 1000 requests per UTC day
|
|
156
195
|
- 60 requests per rolling minute
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
No remote quota endpoint is called for Qwen and Alibaba API is not used.
|
|
196
|
+
- Counters increment on successful question-tool completions while the current model is `qwen-code/*`
|
|
160
197
|
|
|
161
|
-
|
|
198
|
+
State file path:
|
|
162
199
|
|
|
163
|
-
- `.../opencode/opencode-quota/qwen-local-quota.json`
|
|
200
|
+
- `.../opencode/opencode-quota/qwen-local-quota.json`
|
|
164
201
|
|
|
165
|
-
|
|
166
|
-
If the local Qwen state file is missing, `/quota_status` reports usage from a default empty state.
|
|
202
|
+
Run `/quota_status` to verify auth detection and local counter status.
|
|
167
203
|
|
|
168
204
|
</details>
|
|
169
205
|
|
|
170
206
|
<details>
|
|
171
207
|
<summary><strong>Firmware AI</strong></summary>
|
|
172
208
|
|
|
173
|
-
|
|
209
|
+
If OpenCode already has Firmware configured, it usually works automatically. You can also provide an API key:
|
|
174
210
|
|
|
175
|
-
```
|
|
211
|
+
```jsonc
|
|
176
212
|
{
|
|
177
213
|
"provider": {
|
|
178
214
|
"firmware": {
|
|
@@ -189,16 +225,16 @@ If the local Qwen state file is missing, `/quota_status` reports usage from a de
|
|
|
189
225
|
}
|
|
190
226
|
```
|
|
191
227
|
|
|
192
|
-
|
|
228
|
+
`{env:VAR_NAME}` and direct keys are both supported.
|
|
193
229
|
|
|
194
230
|
</details>
|
|
195
231
|
|
|
196
232
|
<details>
|
|
197
233
|
<summary><strong>Chutes AI</strong></summary>
|
|
198
234
|
|
|
199
|
-
|
|
235
|
+
If OpenCode already has Chutes configured, it usually works automatically. You can also provide an API key:
|
|
200
236
|
|
|
201
|
-
```
|
|
237
|
+
```jsonc
|
|
202
238
|
{
|
|
203
239
|
"provider": {
|
|
204
240
|
"chutes": {
|
|
@@ -220,179 +256,109 @@ The `apiKey` field supports `{env:VAR_NAME}` syntax or a direct key.
|
|
|
220
256
|
<details>
|
|
221
257
|
<summary><strong>Google Antigravity</strong></summary>
|
|
222
258
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
```json
|
|
226
|
-
{
|
|
227
|
-
"plugin": ["opencode-antigravity-auth", "@slkiser/opencode-quota"]
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
Account credentials are stored under OpenCode's runtime config directory (see `opencode debug paths`).
|
|
259
|
+
This provider requires the `opencode-antigravity-auth` plugin. Account credentials are stored under the OpenCode runtime config directory.
|
|
232
260
|
|
|
233
|
-
If you are
|
|
261
|
+
If you are debugging detection, `/quota_status` prints the candidate paths checked for `antigravity-accounts.json`.
|
|
234
262
|
|
|
235
263
|
</details>
|
|
236
264
|
|
|
237
265
|
<details>
|
|
238
266
|
<summary><strong>Z.ai</strong></summary>
|
|
239
267
|
|
|
240
|
-
|
|
268
|
+
No extra setup is required if OpenCode already has Z.ai configured.
|
|
241
269
|
|
|
242
270
|
</details>
|
|
243
271
|
|
|
244
272
|
## Configuration Reference
|
|
245
273
|
|
|
246
|
-
All
|
|
274
|
+
All plugin settings live under `experimental.quotaToast`.
|
|
247
275
|
|
|
248
|
-
| Option
|
|
249
|
-
|
|
|
250
|
-
| `enabled`
|
|
251
|
-
| `enableToast`
|
|
252
|
-
| `toastStyle`
|
|
253
|
-
| `enabledProviders`
|
|
254
|
-
| `minIntervalMs`
|
|
255
|
-
| `toastDurationMs`
|
|
256
|
-
| `showOnIdle`
|
|
257
|
-
| `showOnQuestion`
|
|
258
|
-
| `showOnCompact`
|
|
259
|
-
| `showOnBothFail`
|
|
260
|
-
| `onlyCurrentModel`
|
|
261
|
-
| `showSessionTokens` | `true`
|
|
262
|
-
| `layout.maxWidth`
|
|
263
|
-
| `layout.narrowAt`
|
|
264
|
-
| `layout.tinyAt`
|
|
265
|
-
| `googleModels`
|
|
266
|
-
| `debug`
|
|
276
|
+
| Option | Default | Meaning |
|
|
277
|
+
| --- | --- | --- |
|
|
278
|
+
| `enabled` | `true` | Master switch for the plugin. When `false`, `/quota`, `/quota_status`, and `/tokens_*` are no-ops. |
|
|
279
|
+
| `enableToast` | `true` | Show popup toasts |
|
|
280
|
+
| `toastStyle` | `classic` | Toast layout: `classic` or `grouped` |
|
|
281
|
+
| `enabledProviders` | `"auto"` | Auto-detect providers, or set an explicit provider list |
|
|
282
|
+
| `minIntervalMs` | `300000` | Minimum fetch interval between provider updates |
|
|
283
|
+
| `toastDurationMs` | `9000` | Toast duration in milliseconds |
|
|
284
|
+
| `showOnIdle` | `true` | Show toast on idle trigger |
|
|
285
|
+
| `showOnQuestion` | `true` | Show toast after a question/assistant response |
|
|
286
|
+
| `showOnCompact` | `true` | Show toast after session compaction |
|
|
287
|
+
| `showOnBothFail` | `true` | Show a fallback toast when providers attempt and all fail |
|
|
288
|
+
| `onlyCurrentModel` | `false` | Filter to the current model when possible |
|
|
289
|
+
| `showSessionTokens` | `true` | Append current-session token totals to toast output |
|
|
290
|
+
| `layout.maxWidth` | `50` | Main formatting width target |
|
|
291
|
+
| `layout.narrowAt` | `42` | Compact layout breakpoint |
|
|
292
|
+
| `layout.tinyAt` | `32` | Tiny layout breakpoint |
|
|
293
|
+
| `googleModels` | `["CLAUDE"]` | Google model keys: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE` |
|
|
294
|
+
| `debug` | `false` | Include debug context in toast output |
|
|
267
295
|
|
|
268
|
-
##
|
|
296
|
+
## Token Pricing Snapshot
|
|
269
297
|
|
|
270
|
-
|
|
298
|
+
`/tokens_*` uses a local `models.dev` pricing snapshot.
|
|
271
299
|
|
|
272
|
-
|
|
300
|
+
Behavior:
|
|
273
301
|
|
|
274
|
-
|
|
302
|
+
- A bundled snapshot ships with the plugin for offline use.
|
|
303
|
+
- The plugin can refresh the local runtime snapshot when the data is stale.
|
|
304
|
+
- Reports continue to work if refresh fails.
|
|
275
305
|
|
|
276
|
-
|
|
306
|
+
Useful environment variables:
|
|
277
307
|
|
|
278
308
|
```sh
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
npm test
|
|
282
|
-
npm run test:watch
|
|
283
|
-
npm run build
|
|
309
|
+
OPENCODE_QUOTA_PRICING_AUTO_REFRESH=0
|
|
310
|
+
OPENCODE_QUOTA_PRICING_MAX_AGE_DAYS=5
|
|
284
311
|
```
|
|
285
312
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
Toast not appearing? Run `/quota_status` to check config, provider availability, and whether `opencode.db` is detected.
|
|
289
|
-
|
|
290
|
-
If `opencode.db` is missing, run OpenCode once (OpenCode performs a one-time migration into SQLite on first run after upgrade).
|
|
291
|
-
|
|
292
|
-
---
|
|
293
|
-
|
|
294
|
-
<details id="llm-agent-installation-instructions">
|
|
295
|
-
<summary><strong>LLM Agent Installation Instructions</strong></summary>
|
|
296
|
-
|
|
297
|
-
### For LLM Agents: How to Install and Configure
|
|
298
|
-
|
|
299
|
-
This section provides instructions for LLM agents to install and configure `opencode-quota` based on the user's current OpenCode setup.
|
|
313
|
+
Maintainer refresh commands:
|
|
300
314
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
2. Run `/connected` in OpenCode to see active providers
|
|
307
|
-
3. Ask the user which providers they use
|
|
308
|
-
|
|
309
|
-
#### Step 2: Install the Plugin
|
|
315
|
+
```sh
|
|
316
|
+
npm run pricing:refresh
|
|
317
|
+
npm run pricing:refresh:if-stale
|
|
318
|
+
npm run build
|
|
319
|
+
```
|
|
310
320
|
|
|
311
|
-
|
|
321
|
+
## Troubleshooting
|
|
312
322
|
|
|
313
|
-
|
|
314
|
-
{
|
|
315
|
-
"plugin": ["@slkiser/opencode-quota"]
|
|
316
|
-
}
|
|
317
|
-
```
|
|
323
|
+
If something is missing or looks wrong:
|
|
318
324
|
|
|
319
|
-
|
|
325
|
+
1. Run `/quota_status`.
|
|
326
|
+
2. Confirm the expected provider appears in the detected provider list.
|
|
327
|
+
3. If token reports are empty, make sure OpenCode has already created `opencode.db`.
|
|
328
|
+
4. If Copilot managed billing is expected, confirm `copilot-quota-token.json` is present and valid.
|
|
329
|
+
5. If Google or Qwen support is expected, confirm the companion auth plugin is installed.
|
|
320
330
|
|
|
321
|
-
|
|
331
|
+
If `opencode.db` is missing, start OpenCode once and let its local migration complete.
|
|
322
332
|
|
|
323
|
-
|
|
333
|
+
## Development
|
|
324
334
|
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
// Add only the providers the user has configured:
|
|
331
|
-
// "copilot" - if using GitHub Copilot
|
|
332
|
-
// "openai" - if using OpenAI/ChatGPT
|
|
333
|
-
// "qwen-code" - if using Qwen Code OAuth (requires opencode-qwencode-auth)
|
|
334
|
-
// "firmware" - if using Firmware AI
|
|
335
|
-
// "chutes" - if using Chutes AI
|
|
336
|
-
// "google-antigravity" - if using Google Antigravity (requires opencode-antigravity-auth)
|
|
337
|
-
],
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
}
|
|
335
|
+
```sh
|
|
336
|
+
npm install
|
|
337
|
+
npm run typecheck
|
|
338
|
+
npm test
|
|
339
|
+
npm run build
|
|
341
340
|
```
|
|
342
341
|
|
|
343
|
-
|
|
342
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for contribution workflow and repository policy.
|
|
344
343
|
|
|
345
|
-
|
|
346
|
-
| ------------------------------------------- | ----------------------- |
|
|
347
|
-
| `github-copilot` provider or Copilot models | `"copilot"` |
|
|
348
|
-
| `openai` / `chatgpt` provider | `"openai"` |
|
|
349
|
-
| `qwen-code` provider | `"qwen-code"` |
|
|
350
|
-
| `firmware` / `firmware-ai` provider | `"firmware"` |
|
|
351
|
-
| `chutes` provider | `"chutes"` |
|
|
352
|
-
| `google` provider with antigravity models | `"google-antigravity"` |
|
|
353
|
-
| `opencode-antigravity-auth` in plugins | `"google-antigravity"` |
|
|
354
|
-
| `opencode-qwencode-auth` in plugins | `"qwen-code"` |
|
|
344
|
+
## LLM Agent Installation Notes
|
|
355
345
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
For a user with Copilot and Google Antigravity:
|
|
346
|
+
If you are using an agent to install the plugin for you, the safe default is:
|
|
359
347
|
|
|
360
348
|
```jsonc
|
|
361
349
|
{
|
|
362
|
-
"plugin": [
|
|
363
|
-
"opencode-antigravity-auth", // Required for google-antigravity
|
|
364
|
-
"@slkiser/opencode-quota",
|
|
365
|
-
],
|
|
366
|
-
"experimental": {
|
|
367
|
-
"quotaToast": {
|
|
368
|
-
"enabledProviders": ["copilot", "google-antigravity"],
|
|
369
|
-
"googleModels": ["CLAUDE"], // Options: CLAUDE, G3PRO, G3FLASH
|
|
370
|
-
"minIntervalMs": 300000, // 5 minutes between fetches
|
|
371
|
-
"toastDurationMs": 9000, // Toast shows for 9 seconds
|
|
372
|
-
},
|
|
373
|
-
},
|
|
350
|
+
"plugin": ["@slkiser/opencode-quota"]
|
|
374
351
|
}
|
|
375
352
|
```
|
|
376
353
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
After configuration, instruct the user to:
|
|
380
|
-
|
|
381
|
-
1. Restart OpenCode (or reload the window)
|
|
382
|
-
2. Run `/quota_status` to verify providers are detected
|
|
383
|
-
3. Run `/quota` to manually trigger a toast
|
|
384
|
-
|
|
385
|
-
#### Common Issues
|
|
354
|
+
Then verify with `/quota_status`.
|
|
386
355
|
|
|
387
|
-
|
|
388
|
-
- **Google Antigravity not working**: Ensure `opencode-antigravity-auth` plugin is installed and accounts are configured
|
|
389
|
-
- **Copilot quota unreliable**: Consider setting up a fine-grained PAT (see Provider-Specific Setup above)
|
|
390
|
-
|
|
391
|
-
</details>
|
|
356
|
+
Only add explicit `enabledProviders` if you want to limit which providers are queried. Only add companion plugins when the user actually uses Google Antigravity or Qwen Code.
|
|
392
357
|
|
|
393
358
|
## License
|
|
394
359
|
|
|
395
360
|
MIT
|
|
396
361
|
|
|
397
362
|
## Remarks
|
|
398
|
-
|
|
363
|
+
|
|
364
|
+
Opencode Quota is not built by the OpenCode team and is not affiliated with OpenCode or any provider listed above.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
export { QuotaToastPlugin } from "./plugin.js";
|
|
9
|
-
export type { QuotaToastConfig, GoogleModelId, CopilotQuotaResult, GoogleQuotaResult, GoogleModelQuota, } from "./lib/types.js";
|
|
9
|
+
export type { QuotaToastConfig, GoogleModelId, CopilotEnterpriseUsageResult, CopilotOrganizationUsageResult, CopilotQuotaResult, GoogleQuotaResult, GoogleModelQuota, } from "./lib/types.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAC9E,iFAAiF;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAC9E,iFAAiF;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAa/C,yEAAyE;AACzE,wCAAwC;AAExC,6EAA6E;AAC7E,uFAAuF"}
|