@slkiser/opencode-quota 3.4.0 → 3.6.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 +167 -75
- package/dist/bin/opencode-quota.d.ts.map +1 -1
- package/dist/bin/opencode-quota.js +9 -3
- package/dist/bin/opencode-quota.js.map +1 -1
- package/dist/lib/anthropic.d.ts +1 -0
- package/dist/lib/anthropic.d.ts.map +1 -1
- package/dist/lib/anthropic.js +12 -4
- package/dist/lib/anthropic.js.map +1 -1
- package/dist/lib/chutes.d.ts +3 -1
- package/dist/lib/chutes.d.ts.map +1 -1
- package/dist/lib/chutes.js +2 -2
- package/dist/lib/chutes.js.map +1 -1
- package/dist/lib/cli-show.d.ts.map +1 -1
- package/dist/lib/cli-show.js +4 -2
- package/dist/lib/cli-show.js.map +1 -1
- package/dist/lib/config-file-utils.d.ts +11 -0
- package/dist/lib/config-file-utils.d.ts.map +1 -1
- package/dist/lib/config-file-utils.js +24 -3
- package/dist/lib/config-file-utils.js.map +1 -1
- package/dist/lib/config.d.ts +3 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +77 -19
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/copilot.d.ts +4 -1
- package/dist/lib/copilot.d.ts.map +1 -1
- package/dist/lib/copilot.js +57 -11
- package/dist/lib/copilot.js.map +1 -1
- package/dist/lib/entries.d.ts +4 -1
- package/dist/lib/entries.d.ts.map +1 -1
- package/dist/lib/format-utils.d.ts +7 -0
- package/dist/lib/format-utils.d.ts.map +1 -1
- package/dist/lib/format-utils.js +7 -0
- package/dist/lib/format-utils.js.map +1 -1
- package/dist/lib/format.d.ts.map +1 -1
- package/dist/lib/format.js +49 -3
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +1 -1
- package/dist/lib/google-gemini-cli-companion.js +46 -18
- package/dist/lib/google-gemini-cli-companion.js.map +1 -1
- package/dist/lib/google-gemini-cli.d.ts +3 -1
- package/dist/lib/google-gemini-cli.d.ts.map +1 -1
- package/dist/lib/google-gemini-cli.js +9 -6
- package/dist/lib/google-gemini-cli.js.map +1 -1
- package/dist/lib/google.d.ts +3 -1
- package/dist/lib/google.d.ts.map +1 -1
- package/dist/lib/google.js +12 -4
- package/dist/lib/google.js.map +1 -1
- package/dist/lib/init-installer.d.ts +4 -1
- package/dist/lib/init-installer.d.ts.map +1 -1
- package/dist/lib/init-installer.js +113 -24
- package/dist/lib/init-installer.js.map +1 -1
- package/dist/lib/kimi.d.ts +3 -1
- package/dist/lib/kimi.d.ts.map +1 -1
- package/dist/lib/kimi.js +4 -4
- package/dist/lib/kimi.js.map +1 -1
- package/dist/lib/nanogpt.d.ts +3 -1
- package/dist/lib/nanogpt.d.ts.map +1 -1
- package/dist/lib/nanogpt.js +7 -7
- package/dist/lib/nanogpt.js.map +1 -1
- package/dist/lib/openai.d.ts +3 -1
- package/dist/lib/openai.d.ts.map +1 -1
- package/dist/lib/openai.js +2 -2
- package/dist/lib/openai.js.map +1 -1
- package/dist/lib/opencode-go.d.ts +3 -1
- package/dist/lib/opencode-go.d.ts.map +1 -1
- package/dist/lib/opencode-go.js +2 -2
- package/dist/lib/opencode-go.js.map +1 -1
- package/dist/lib/quota-render-data.d.ts +5 -0
- package/dist/lib/quota-render-data.d.ts.map +1 -1
- package/dist/lib/quota-render-data.js +67 -6
- package/dist/lib/quota-render-data.js.map +1 -1
- package/dist/lib/synthetic.d.ts +3 -1
- package/dist/lib/synthetic.d.ts.map +1 -1
- package/dist/lib/synthetic.js +2 -2
- package/dist/lib/synthetic.js.map +1 -1
- package/dist/lib/toast-format-grouped.d.ts.map +1 -1
- package/dist/lib/toast-format-grouped.js +45 -9
- package/dist/lib/toast-format-grouped.js.map +1 -1
- package/dist/lib/tui-runtime.d.ts.map +1 -1
- package/dist/lib/tui-runtime.js +14 -2
- package/dist/lib/tui-runtime.js.map +1 -1
- package/dist/lib/types.d.ts +6 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +3 -2
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/zai.d.ts +3 -1
- package/dist/lib/zai.d.ts.map +1 -1
- package/dist/lib/zai.js +2 -2
- package/dist/lib/zai.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +8 -2
- package/dist/plugin.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +4 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/chutes.js +2 -2
- package/dist/providers/chutes.js.map +1 -1
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +25 -4
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/google-antigravity.d.ts.map +1 -1
- package/dist/providers/google-antigravity.js +3 -1
- package/dist/providers/google-antigravity.js.map +1 -1
- package/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/dist/providers/google-gemini-cli.js +5 -1
- package/dist/providers/google-gemini-cli.js.map +1 -1
- package/dist/providers/kimi-code.js +1 -1
- package/dist/providers/kimi-code.js.map +1 -1
- package/dist/providers/minimax-coding-plan.d.ts +3 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +1 -1
- package/dist/providers/minimax-coding-plan.js +6 -4
- package/dist/providers/minimax-coding-plan.js.map +1 -1
- package/dist/providers/nanogpt.js +1 -1
- package/dist/providers/nanogpt.js.map +1 -1
- package/dist/providers/openai.js +4 -4
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/opencode-go.d.ts.map +1 -1
- package/dist/providers/opencode-go.js +7 -3
- package/dist/providers/opencode-go.js.map +1 -1
- package/dist/providers/synthetic.js +1 -1
- package/dist/providers/synthetic.js.map +1 -1
- package/dist/providers/zai.js +1 -1
- package/dist/providers/zai.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### Quick start
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
npx @slkiser/opencode-quota init
|
|
@@ -28,24 +28,28 @@ npx @slkiser/opencode-quota init
|
|
|
28
28
|
> [!IMPORTANT]
|
|
29
29
|
> OpenCode `>= 1.4.3` and Node.js `>= 18` are required.
|
|
30
30
|
|
|
31
|
-
The installer is append-only
|
|
31
|
+
The installer is append-only: it adds the plugin, asks a few display/provider questions, and leaves existing values alone.
|
|
32
32
|
|
|
33
33
|
After install:
|
|
34
34
|
|
|
35
35
|
1. Restart OpenCode.
|
|
36
|
-
2. Run `/
|
|
37
|
-
3.
|
|
38
|
-
4. If you enabled the sidebar, open the session sidebar and
|
|
36
|
+
2. Run `/quota`.
|
|
37
|
+
3. If something looks wrong, run `/quota_status`.
|
|
38
|
+
4. If you enabled the sidebar, open the session sidebar and look for the `Quota` panel.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
Terminal-only check:
|
|
41
|
+
|
|
42
|
+
Use `npx` when you want to run the published package without installing the binary first:
|
|
41
43
|
|
|
42
44
|
```bash
|
|
43
45
|
npx @slkiser/opencode-quota show
|
|
44
|
-
# or, if installed/on PATH:
|
|
45
|
-
opencode-quota show --provider copilot
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
`
|
|
48
|
+
Use `opencode-quota` directly when the package binary is already installed or on your `PATH`. Add `--provider` to show only one provider:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
opencode-quota show --provider copilot
|
|
52
|
+
```
|
|
49
53
|
|
|
50
54
|
### Manual setup
|
|
51
55
|
|
|
@@ -67,9 +71,68 @@ If you also want the sidebar, add the same package to the `tui.json` or `tui.jso
|
|
|
67
71
|
}
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
Quota settings go in `opencode-quota/quota-toast.json` next to the OpenCode config file you chose during install. Existing `experimental.quotaToast` settings still work when no sidecar file exists. Quota settings do not live in `tui.json`.
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary><em>Full configuration reference</em></summary>
|
|
78
|
+
|
|
79
|
+
#### Core/shared settings
|
|
80
|
+
|
|
81
|
+
| Option | Default | Meaning |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `enabled` | `true` | Master switch for quota collection and handled slash commands. When `false`, `/quota`, `/quota_status`, `/pricing_refresh`, and `/tokens_*` are handled as no-ops. |
|
|
84
|
+
| `enabledProviders` | `"auto"` | Auto-detect providers, or set an explicit provider list. Unknown provider ids are reported under `config_errors` in `/quota_status`; an explicit list with no valid providers resolves to none instead of falling back to auto-detect. |
|
|
85
|
+
| `minIntervalMs` | `300000` | Minimum fetch interval between provider updates. |
|
|
86
|
+
| `requestTimeoutMs` | `5000` | Remote provider request timeout in milliseconds. Providers with custom defaults, such as Gemini CLI and OpenCode Go, keep their provider default unless this is explicitly configured. |
|
|
87
|
+
| `formatStyle` | `singleWindow` | Shared quota-row style for popup toasts and the TUI sidebar: `singleWindow` or `allWindows`. Legacy `classic`/`grouped` aliases still work, and legacy `toastStyle` is still accepted on read for backward compatibility. |
|
|
88
|
+
| `percentDisplayMode` | `remaining` | Shared percent meaning for popup toasts and the TUI sidebar: `remaining` renders labels like `81% left`; `used` renders labels like `19% used` or `125% used` when over quota. |
|
|
89
|
+
| `onlyCurrentModel` | `false` | Filter quota rows to the current model/provider when that session selection can be resolved. |
|
|
90
|
+
| `showSessionTokens` | `true` | Show the `Session input/output tokens` section in quota displays when session token data is available. |
|
|
91
|
+
| `pricingSnapshot.source` | `"auto"` | Token pricing snapshot selection for `/tokens_*`: `auto`, `bundled`, or `runtime`. |
|
|
92
|
+
| `pricingSnapshot.autoRefresh` | `7` | Refresh stale local pricing data after this many days. |
|
|
93
|
+
|
|
94
|
+
`percentDisplayMode` affects popup toasts and the TUI sidebar only. `/quota` keeps its existing remaining-oriented percentage output.
|
|
95
|
+
|
|
96
|
+
#### Toast settings
|
|
97
|
+
|
|
98
|
+
| Option | Default | Meaning |
|
|
99
|
+
| --- | --- | --- |
|
|
100
|
+
| `enableToast` | `true` | Show popup toasts. Disabling this does not disable `/quota` or the TUI sidebar. |
|
|
101
|
+
| `toastDurationMs` | `9000` | Toast duration in milliseconds. |
|
|
102
|
+
| `showOnIdle` | `true` | Show a toast on the idle trigger. |
|
|
103
|
+
| `showOnQuestion` | `true` | Show a toast after a question/assistant response. |
|
|
104
|
+
| `showOnCompact` | `true` | Show a toast after session compaction. |
|
|
105
|
+
| `showOnBothFail` | `true` | Show a fallback toast when providers attempted quota reads and all failed. |
|
|
106
|
+
| `layout.maxWidth` | `50` | Toast formatting width target. Ignored by the TUI sidebar. |
|
|
107
|
+
| `layout.narrowAt` | `42` | Toast compact-layout breakpoint. Ignored by the TUI sidebar. |
|
|
108
|
+
| `layout.tinyAt` | `32` | Toast tiny-layout breakpoint. Ignored by the TUI sidebar. |
|
|
109
|
+
| `debug` | `false` | Append toast debug context when troubleshooting. |
|
|
110
|
+
|
|
111
|
+
#### TUI sidebar setup
|
|
112
|
+
|
|
113
|
+
If you want the `Quota` sidebar panel, you need the plugin in both OpenCode config surfaces:
|
|
114
|
+
|
|
115
|
+
| File | What goes there | Needed for sidebar? |
|
|
116
|
+
| --- | --- | --- |
|
|
117
|
+
| `tui.json` / `tui.jsonc` | `plugin: ["@slkiser/opencode-quota"]` | Yes |
|
|
118
|
+
| `opencode.json` / `opencode.jsonc` | Server plugin entry | Yes |
|
|
119
|
+
| `opencode-quota/quota-toast.json` | Quota settings | No, but controls quota behavior |
|
|
120
|
+
|
|
121
|
+
#### Provider-specific settings
|
|
122
|
+
|
|
123
|
+
| Option | Default | Meaning |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| `anthropicBinaryPath` | `"claude"` | Command/path used for local Claude CLI probing; override this for custom installs or shim locations. |
|
|
126
|
+
| `googleModels` | `["CLAUDE"]` | Google model keys to query: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE`. |
|
|
127
|
+
| `opencodeGoWindows` | `["rolling", "weekly", "monthly"]` | OpenCode Go usage windows to display. |
|
|
128
|
+
| `alibabaCodingPlanTier` | `"lite"` | Fallback Alibaba Coding Plan tier when auth does not include `tier`. |
|
|
129
|
+
| `cursorPlan` | `"none"` | Cursor included API budget preset: `none`, `pro`, `pro-plus`, `ultra`. |
|
|
130
|
+
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD. |
|
|
131
|
+
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month. |
|
|
132
|
+
|
|
133
|
+
</details>
|
|
71
134
|
|
|
72
|
-
### What
|
|
135
|
+
### What opencode-quota adds
|
|
73
136
|
|
|
74
137
|
- TUI sidebar panel with quota rows
|
|
75
138
|
- Popup quota toasts after assistant responses
|
|
@@ -99,7 +162,7 @@ All quota settings live in `opencode.json` or `opencode.jsonc`, not `tui.json`.
|
|
|
99
162
|
| ----------------------- | ------------------ | --------------------------------------------------------- | ------------------------ |
|
|
100
163
|
| Anthropic (Claude) | [Needs quick setup](#anthropic-claude-quick-setup) | Install and authenticate Claude CLI | Local CLI or OAuth usage |
|
|
101
164
|
| GitHub Copilot | Usually automatic | Existing OpenCode auth, or optional PAT config | Remote API |
|
|
102
|
-
| OpenAI | Automatic | Existing OpenCode
|
|
165
|
+
| OpenAI | Automatic | Existing OpenCode OAuth | Remote API |
|
|
103
166
|
| Cursor | [Needs quick setup](#cursor-quick-setup) | `["@playwo/opencode-cursor-oauth", "@slkiser/opencode-quota"]` | Local estimation |
|
|
104
167
|
| Qwen Code | [Needs quick setup](#qwen-code-quick-setup) | `["opencode-qwencode-auth", "@slkiser/opencode-quota"]` | Local estimation |
|
|
105
168
|
| Alibaba Coding Plan | Automatic | Existing OpenCode auth, global config, or env | Local estimation |
|
|
@@ -113,70 +176,96 @@ All quota settings live in `opencode.json` or `opencode.jsonc`, not `tui.json`.
|
|
|
113
176
|
| NanoGPT | Usually automatic | Existing OpenCode auth, global config, or env | Remote API |
|
|
114
177
|
| OpenCode Go | [Needs quick setup](#opencode-go-quick-setup) | Set workspace ID and `auth` cookie | Dashboard scraping |
|
|
115
178
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Providers are auto-detected by default. To choose providers explicitly:
|
|
179
|
+
Providers are auto-detected by default. To choose providers explicitly, set `enabledProviders` in `opencode-quota/quota-toast.json`:
|
|
119
180
|
|
|
120
181
|
```jsonc
|
|
121
182
|
{
|
|
122
|
-
"
|
|
123
|
-
"quotaToast": {
|
|
124
|
-
"enabledProviders": ["copilot", "openai", "google-gemini-cli"],
|
|
125
|
-
},
|
|
126
|
-
},
|
|
183
|
+
"enabledProviders": ["copilot", "openai", "google-gemini-cli"],
|
|
127
184
|
}
|
|
128
185
|
```
|
|
129
186
|
|
|
130
|
-
###
|
|
187
|
+
### Common Options
|
|
188
|
+
|
|
189
|
+
Customize these settings in `opencode-quota/quota-toast.json`.
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
<summary><em>Show every quota window</em></summary>
|
|
131
193
|
|
|
132
|
-
|
|
194
|
+
Instead of the default most-constrained window:
|
|
133
195
|
|
|
134
196
|
```jsonc
|
|
135
197
|
{
|
|
136
|
-
"
|
|
137
|
-
"quotaToast": {
|
|
138
|
-
"formatStyle": "allWindows",
|
|
139
|
-
},
|
|
140
|
-
},
|
|
198
|
+
"formatStyle": "allWindows",
|
|
141
199
|
}
|
|
142
200
|
```
|
|
143
201
|
|
|
144
|
-
|
|
202
|
+
</details>
|
|
203
|
+
|
|
204
|
+
<details>
|
|
205
|
+
<summary><em>Choose OpenCode Go windows</em></summary>
|
|
206
|
+
|
|
207
|
+
Choose which OpenCode Go windows to display:
|
|
145
208
|
|
|
146
209
|
```jsonc
|
|
147
210
|
{
|
|
148
|
-
"
|
|
149
|
-
"quotaToast": {
|
|
150
|
-
"opencodeGoWindows": ["rolling", "weekly", "monthly"],
|
|
151
|
-
},
|
|
152
|
-
},
|
|
211
|
+
"opencodeGoWindows": ["rolling", "weekly", "monthly"],
|
|
153
212
|
}
|
|
154
213
|
```
|
|
155
214
|
|
|
215
|
+
</details>
|
|
216
|
+
|
|
217
|
+
<details>
|
|
218
|
+
<summary><em>Show used percentages</em></summary>
|
|
219
|
+
|
|
156
220
|
Show percentages as used instead of remaining in toasts and the sidebar:
|
|
157
221
|
|
|
158
222
|
```jsonc
|
|
159
223
|
{
|
|
160
|
-
"
|
|
161
|
-
"quotaToast": {
|
|
162
|
-
"percentDisplayMode": "used",
|
|
163
|
-
},
|
|
164
|
-
},
|
|
224
|
+
"percentDisplayMode": "used",
|
|
165
225
|
}
|
|
166
226
|
```
|
|
167
227
|
|
|
168
|
-
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary><em>Turn off popup toasts</em></summary>
|
|
232
|
+
|
|
233
|
+
Keep `/quota` and the sidebar enabled:
|
|
169
234
|
|
|
170
235
|
```jsonc
|
|
171
236
|
{
|
|
172
|
-
"
|
|
173
|
-
"quotaToast": {
|
|
174
|
-
"enableToast": false,
|
|
175
|
-
},
|
|
176
|
-
},
|
|
237
|
+
"enableToast": false,
|
|
177
238
|
}
|
|
178
239
|
```
|
|
179
240
|
|
|
241
|
+
</details>
|
|
242
|
+
|
|
243
|
+
<details>
|
|
244
|
+
<summary><em>Increase request timeout</em></summary>
|
|
245
|
+
|
|
246
|
+
Increase the remote provider request timeout from the default 5000ms. Providers with custom defaults, such as Gemini CLI and OpenCode Go, keep their provider default unless you set this.
|
|
247
|
+
|
|
248
|
+
```jsonc
|
|
249
|
+
{
|
|
250
|
+
"requestTimeoutMs": 12000,
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
</details>
|
|
255
|
+
|
|
256
|
+
<details>
|
|
257
|
+
<summary><em>Advanced: legacy config sync</em></summary>
|
|
258
|
+
|
|
259
|
+
By default, the installer writes quota settings only to `opencode-quota/quota-toast.json`. If you also want it to write the legacy OpenCode block, run:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npx @slkiser/opencode-quota init --sync-legacy-config
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
This is only for users who intentionally want `experimental.quotaToast` mirrored into `opencode.json` / `opencode.jsonc`.
|
|
266
|
+
|
|
267
|
+
</details>
|
|
268
|
+
|
|
180
269
|
### Commands
|
|
181
270
|
|
|
182
271
|
| Command | What it shows |
|
|
@@ -198,18 +287,18 @@ Turn off popup toasts while keeping `/quota` and the sidebar:
|
|
|
198
287
|
|
|
199
288
|
### Anthropic quick setup
|
|
200
289
|
|
|
201
|
-
|
|
290
|
+
Install Claude Code, authenticate it, and make sure `claude` is on your `PATH`:
|
|
202
291
|
|
|
203
292
|
```bash
|
|
204
293
|
claude auth login
|
|
205
294
|
claude auth status
|
|
206
295
|
```
|
|
207
296
|
|
|
208
|
-
If Claude lives at a custom path, set `
|
|
297
|
+
If Claude lives at a custom path, set `anthropicBinaryPath` in `opencode-quota/quota-toast.json`.
|
|
209
298
|
|
|
210
299
|
### Companion providers
|
|
211
300
|
|
|
212
|
-
Some providers need an auth companion plugin
|
|
301
|
+
Some providers need an auth companion plugin. Add the companion plugin first and `@slkiser/opencode-quota` second.
|
|
213
302
|
|
|
214
303
|
<a id="cursor-quick-setup"></a>
|
|
215
304
|
|
|
@@ -273,17 +362,12 @@ Add both plugins to `opencode.json`, with the Antigravity auth plugin first:
|
|
|
273
362
|
|
|
274
363
|
Companion plugin: [`opencode-gemini-auth`](https://github.com/jenslys/opencode-gemini-auth#readme)
|
|
275
364
|
|
|
276
|
-
Add both plugins to `opencode.json`, with the Gemini auth plugin first
|
|
365
|
+
Add both plugins to `opencode.json`, with the Gemini auth plugin first:
|
|
277
366
|
|
|
278
367
|
```jsonc
|
|
279
368
|
{
|
|
280
369
|
"$schema": "https://opencode.ai/config.json",
|
|
281
|
-
"plugin": ["opencode-gemini-auth", "@slkiser/opencode-quota"]
|
|
282
|
-
"experimental": {
|
|
283
|
-
"quotaToast": {
|
|
284
|
-
"enabledProviders": ["google-gemini-cli"]
|
|
285
|
-
}
|
|
286
|
-
}
|
|
370
|
+
"plugin": ["opencode-gemini-auth", "@slkiser/opencode-quota"]
|
|
287
371
|
}
|
|
288
372
|
```
|
|
289
373
|
|
|
@@ -293,6 +377,8 @@ Then authenticate Google once:
|
|
|
293
377
|
opencode auth login --provider google
|
|
294
378
|
```
|
|
295
379
|
|
|
380
|
+
If you use manual provider selection, include `google-gemini-cli` in `enabledProviders`.
|
|
381
|
+
|
|
296
382
|
### OpenCode Go
|
|
297
383
|
|
|
298
384
|
<a id="opencode-go-quick-setup"></a>
|
|
@@ -304,9 +390,9 @@ export OPENCODE_GO_WORKSPACE_ID="your-workspace-id"
|
|
|
304
390
|
export OPENCODE_GO_AUTH_COOKIE="your-auth-cookie"
|
|
305
391
|
```
|
|
306
392
|
|
|
307
|
-
|
|
393
|
+
OpenCode Go can show **5h**, **Weekly**, and **Monthly** windows. Use `opencodeGoWindows` in `opencode-quota/quota-toast.json` to choose a subset.
|
|
308
394
|
|
|
309
|
-
Environment variables take precedence over the optional `opencode-go.json`
|
|
395
|
+
Environment variables take precedence over the optional `opencode-go.json` file. Run `/quota_status` to see the exact paths checked.
|
|
310
396
|
|
|
311
397
|
### Troubleshooting
|
|
312
398
|
|
|
@@ -320,15 +406,17 @@ If quota or token data looks wrong:
|
|
|
320
406
|
|
|
321
407
|
### Provider Troubleshooting
|
|
322
408
|
|
|
409
|
+
For companion providers, confirm the auth plugin appears before `@slkiser/opencode-quota` in `opencode.json`.
|
|
410
|
+
|
|
323
411
|
<details>
|
|
324
|
-
<summary><
|
|
412
|
+
<summary><em>Anthropic (Claude)</em></summary>
|
|
325
413
|
|
|
326
414
|
Run `/quota_status` and check the Anthropic section.
|
|
327
415
|
|
|
328
416
|
| Symptom | Fix |
|
|
329
417
|
| --- | --- |
|
|
330
418
|
| `claude` not found | Install Claude Code and make sure `claude` is on your `PATH`. |
|
|
331
|
-
| Claude is installed at a custom path | Set `
|
|
419
|
+
| Claude is installed at a custom path | Set `anthropicBinaryPath` in `opencode-quota/quota-toast.json`. |
|
|
332
420
|
| Not authenticated | Run `claude auth login`, then confirm `claude auth status` works. |
|
|
333
421
|
| Auth works but no quota rows appear | Check `quota_source` and `message` in `/quota_status`; re-authenticate Claude if the OAuth credential fallback is missing or stale. |
|
|
334
422
|
| Provider not detected | Confirm OpenCode is configured to use the `anthropic` provider. |
|
|
@@ -336,7 +424,7 @@ Run `/quota_status` and check the Anthropic section.
|
|
|
336
424
|
</details>
|
|
337
425
|
|
|
338
426
|
<details>
|
|
339
|
-
<summary><
|
|
427
|
+
<summary><em>GitHub Copilot</em></summary>
|
|
340
428
|
|
|
341
429
|
Run `/quota_status` and check `copilot_quota_auth`, `billing_mode`, `billing_scope`, and `quota_api`.
|
|
342
430
|
|
|
@@ -350,20 +438,20 @@ Run `/quota_status` and check `copilot_quota_auth`, `billing_mode`, `billing_sco
|
|
|
350
438
|
</details>
|
|
351
439
|
|
|
352
440
|
<details>
|
|
353
|
-
<summary><
|
|
441
|
+
<summary><em>OpenAI</em></summary>
|
|
354
442
|
|
|
355
443
|
Run `/quota_status` and check the OpenAI auth source and token status.
|
|
356
444
|
|
|
357
445
|
| Symptom | Fix |
|
|
358
446
|
| --- | --- |
|
|
359
|
-
| OpenAI quota missing | Confirm OpenCode native OpenAI
|
|
447
|
+
| OpenAI quota missing | Confirm OpenCode native OpenAI OAuth is present in `auth.json`. |
|
|
360
448
|
| Token expired | Re-run OpenCode's OpenAI auth flow. |
|
|
361
449
|
| Provider not detected | Confirm your OpenCode config uses the `openai` provider or a compatible OpenAI auth entry. |
|
|
362
450
|
|
|
363
451
|
</details>
|
|
364
452
|
|
|
365
453
|
<details>
|
|
366
|
-
<summary><
|
|
454
|
+
<summary><em>Cursor</em></summary>
|
|
367
455
|
|
|
368
456
|
Run `/quota_status` and check the Cursor section.
|
|
369
457
|
|
|
@@ -371,14 +459,14 @@ Run `/quota_status` and check the Cursor section.
|
|
|
371
459
|
| --- | --- |
|
|
372
460
|
| Cursor not detected | Put `@playwo/opencode-cursor-oauth` before `@slkiser/opencode-quota` in `opencode.json`. |
|
|
373
461
|
| Cursor auth missing | Run `opencode auth login --provider cursor`. |
|
|
374
|
-
| Quota appears but no remaining percentage | Set `
|
|
375
|
-
| Billing cycle looks wrong | Set `
|
|
462
|
+
| Quota appears but no remaining percentage | Set `cursorPlan` or `cursorIncludedApiUsd` in `opencode-quota/quota-toast.json`. |
|
|
463
|
+
| Billing cycle looks wrong | Set `cursorBillingCycleStartDay` in `opencode-quota/quota-toast.json` to your local billing anchor day. |
|
|
376
464
|
| Unknown Cursor pricing | Run `/pricing_refresh`; if still unknown, check `/quota_status` for unknown model ids. |
|
|
377
465
|
|
|
378
466
|
</details>
|
|
379
467
|
|
|
380
468
|
<details>
|
|
381
|
-
<summary><
|
|
469
|
+
<summary><em>Qwen Code</em></summary>
|
|
382
470
|
|
|
383
471
|
Run `/quota_status` and check `qwen_oauth_source`, `qwen_local_plan`, and the `qwen_code` live probe section.
|
|
384
472
|
|
|
@@ -392,21 +480,21 @@ Run `/quota_status` and check `qwen_oauth_source`, `qwen_local_plan`, and the `q
|
|
|
392
480
|
</details>
|
|
393
481
|
|
|
394
482
|
<details>
|
|
395
|
-
<summary><
|
|
483
|
+
<summary><em>Alibaba Coding Plan</em></summary>
|
|
396
484
|
|
|
397
485
|
Run `/quota_status` and check the Alibaba auth, resolved tier, state-file path, and `alibaba_coding_plan` live probe section.
|
|
398
486
|
|
|
399
487
|
| Symptom | Fix |
|
|
400
488
|
| --- | --- |
|
|
401
489
|
| API key not detected | Use `ALIBABA_CODING_PLAN_API_KEY`, `ALIBABA_API_KEY`, trusted user/global OpenCode config, or OpenCode auth. Repo-local provider secrets are ignored. |
|
|
402
|
-
| Wrong tier | Set `
|
|
490
|
+
| Wrong tier | Set `alibabaCodingPlanTier` to `lite` or `pro` in `opencode-quota/quota-toast.json`. |
|
|
403
491
|
| Counters do not move | Confirm the current model is `alibaba/*` or `alibaba-cn/*`. |
|
|
404
492
|
| Quota seems stale | Check the state-file path shown in `/quota_status`. |
|
|
405
493
|
|
|
406
494
|
</details>
|
|
407
495
|
|
|
408
496
|
<details>
|
|
409
|
-
<summary><
|
|
497
|
+
<summary><em>MiniMax, Kimi, Chutes AI, Synthetic, Z.ai, and NanoGPT</em></summary>
|
|
410
498
|
|
|
411
499
|
These providers use trusted env vars, trusted user/global OpenCode config, or native OpenCode auth. Run `/quota_status` and check the provider-specific API-key diagnostics.
|
|
412
500
|
|
|
@@ -424,7 +512,7 @@ For security, repo-local `opencode.json` / `opencode.jsonc` is ignored for provi
|
|
|
424
512
|
</details>
|
|
425
513
|
|
|
426
514
|
<details>
|
|
427
|
-
<summary><
|
|
515
|
+
<summary><em>Google Antigravity</em></summary>
|
|
428
516
|
|
|
429
517
|
Run `/quota_status` and check the `google_antigravity` section.
|
|
430
518
|
|
|
@@ -438,21 +526,21 @@ Run `/quota_status` and check the `google_antigravity` section.
|
|
|
438
526
|
</details>
|
|
439
527
|
|
|
440
528
|
<details>
|
|
441
|
-
<summary><
|
|
529
|
+
<summary><em>Gemini CLI</em></summary>
|
|
442
530
|
|
|
443
531
|
Run `/quota_status` and check the Gemini CLI live probe rows.
|
|
444
532
|
|
|
445
533
|
| Symptom | Fix |
|
|
446
534
|
| --- | --- |
|
|
447
535
|
| Companion missing | Put `opencode-gemini-auth` before `@slkiser/opencode-quota` in `opencode.json`. |
|
|
448
|
-
| Provider not enabled in manual mode | Include `google-gemini-cli` in `
|
|
536
|
+
| Provider not enabled in manual mode | Include `google-gemini-cli` in `enabledProviders` in `opencode-quota/quota-toast.json`. |
|
|
449
537
|
| Auth missing | Run `opencode auth login --provider google`. |
|
|
450
538
|
| Project missing | Set `provider.google.options.projectId`, `OPENCODE_GEMINI_PROJECT_ID`, `GOOGLE_CLOUD_PROJECT`, or `GOOGLE_CLOUD_PROJECT_ID`. |
|
|
451
539
|
|
|
452
540
|
</details>
|
|
453
541
|
|
|
454
542
|
<details>
|
|
455
|
-
<summary><
|
|
543
|
+
<summary><em>OpenCode Go</em></summary>
|
|
456
544
|
|
|
457
545
|
Run `/quota_status` and check the `opencode_go` section.
|
|
458
546
|
|
|
@@ -461,13 +549,13 @@ Run `/quota_status` and check the `opencode_go` section.
|
|
|
461
549
|
| Config not detected | Set both `OPENCODE_GO_WORKSPACE_ID` and `OPENCODE_GO_AUTH_COOKIE`, then rerun `/quota_status`. |
|
|
462
550
|
| Incomplete config | `workspaceId` and `authCookie` must come from the same source. |
|
|
463
551
|
| Scrape returns no data | Refresh the browser `auth` cookie from `opencode.ai`. |
|
|
464
|
-
| Selected window missing | Check `/quota_status` for `selected_windows` and `live_fetch_error`; remove unavailable windows from `
|
|
552
|
+
| Selected window missing | Check `/quota_status` for `selected_windows` and `live_fetch_error`; remove unavailable windows from `opencodeGoWindows` in `opencode-quota/quota-toast.json` or refresh the dashboard cookie. |
|
|
465
553
|
| Dashboard format changed | This integration scrapes the dashboard, so it can break if the dashboard markup changes. |
|
|
466
554
|
|
|
467
555
|
</details>
|
|
468
556
|
|
|
469
557
|
<details>
|
|
470
|
-
<summary><
|
|
558
|
+
<summary><em>Token Reports</em></summary>
|
|
471
559
|
|
|
472
560
|
Run `/quota_status` and check pricing snapshot health plus OpenCode database paths.
|
|
473
561
|
|
|
@@ -475,11 +563,15 @@ Run `/quota_status` and check pricing snapshot health plus OpenCode database pat
|
|
|
475
563
|
| --- | --- |
|
|
476
564
|
| `/tokens_*` is empty | Start OpenCode once so it creates `opencode.db`, then run a session with model usage. |
|
|
477
565
|
| Pricing looks stale | Run `/pricing_refresh`. |
|
|
478
|
-
| Runtime pricing does not change output | Check `
|
|
566
|
+
| Runtime pricing does not change output | Check `pricingSnapshot.source` in `opencode-quota/quota-toast.json`; `bundled` keeps packaged pricing active. |
|
|
479
567
|
| Cursor model has unknown pricing | Run `/pricing_refresh`; Cursor `auto` and `composer*` use bundled deterministic pricing. |
|
|
480
568
|
|
|
481
569
|
</details>
|
|
482
570
|
|
|
571
|
+
### Issues
|
|
572
|
+
|
|
573
|
+
Please use the Bug report or Feature request templates when opening issues. Freeform issues, or bug/feature issues missing the required template sections, may be automatically commented on and closed.
|
|
574
|
+
|
|
483
575
|
### License
|
|
484
576
|
|
|
485
577
|
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAgCA,wBAAgB,gBAAgB,CAC9B,KAAK,GAAE,MAAM,GAAG,SAA2B,EAC3C,UAAU,GAAE,MAAuC,EACnD,WAAW,GAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAuB,GACzD,OAAO,CAMT;AAED,wBAAsB,IAAI,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BxE"}
|
|
@@ -5,12 +5,13 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { runInitInstaller } from "../lib/init-installer.js";
|
|
6
6
|
const USAGE = [
|
|
7
7
|
"Usage:",
|
|
8
|
-
" npx @slkiser/opencode-quota init",
|
|
8
|
+
" npx @slkiser/opencode-quota init [--sync-legacy-config]",
|
|
9
9
|
" npx @slkiser/opencode-quota show [--provider <provider-id>]",
|
|
10
10
|
" npx @slkiser/opencode-quota --help",
|
|
11
11
|
"",
|
|
12
12
|
"Commands:",
|
|
13
13
|
" init Run the interactive quota installer",
|
|
14
|
+
" --sync-legacy-config also writes experimental.quotaToast",
|
|
14
15
|
" show Print a quick quota glance",
|
|
15
16
|
].join("\n");
|
|
16
17
|
function printUsage() {
|
|
@@ -40,8 +41,13 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
40
41
|
printUsage();
|
|
41
42
|
return 0;
|
|
42
43
|
}
|
|
43
|
-
if (command === "init"
|
|
44
|
-
|
|
44
|
+
if (command === "init") {
|
|
45
|
+
if (rest.length === 0) {
|
|
46
|
+
return await runInitInstaller();
|
|
47
|
+
}
|
|
48
|
+
if (rest.length === 1 && rest[0] === "--sync-legacy-config") {
|
|
49
|
+
return await runInitInstaller({ syncLegacyConfig: true });
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
if (command === "show") {
|
|
47
53
|
const { runCliShowCommand } = await import("../lib/cli-show.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-quota.js","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,
|
|
1
|
+
{"version":3,"file":"opencode-quota.js","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,2DAA2D;IAC3D,+DAA+D;IAC/D,sCAAsC;IACtC,EAAE;IACF,WAAW;IACX,+CAA+C;IAC/C,oEAAoE;IACpE,sCAAsC;CACvC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,MAAM,CAAC,Q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;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmEF,wBAAgB,0BAA0B,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAGtE;AAyBD,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7D,uBAAuB,CAoBzB;AAsHD,iBAAS,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAiBtE;AAulBD,wBAAgB,sCAAsC,IAAI,IAAI,CAG7D;AAmDD,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CA4F/B;AAED,wBAAsB,iCAAiC,CACrD,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/lib/anthropic.js
CHANGED
|
@@ -37,10 +37,18 @@ function quoteWindowsCmdArg(value) {
|
|
|
37
37
|
const escaped = value.replace(/(\\*)"/g, "$1$1\\\"").replace(/(\\+)$/g, "$1$1");
|
|
38
38
|
return `"${escaped}"`;
|
|
39
39
|
}
|
|
40
|
+
function shouldBridgeClaudeCommandThroughWindowsShell(binaryPath) {
|
|
41
|
+
const normalized = binaryPath.trim().toLowerCase();
|
|
42
|
+
if (!/[\\/]/u.test(normalized)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return /\.(?:cmd|bat)$/u.test(normalized);
|
|
46
|
+
}
|
|
40
47
|
export function buildClaudeCommandInvocation(binaryPath, args, runtime = {}) {
|
|
41
48
|
const resolvedBinaryPath = resolveAnthropicBinaryPath(binaryPath);
|
|
42
49
|
const display = formatCommandDisplay([resolvedBinaryPath, ...args]);
|
|
43
|
-
if ((runtime.platform ?? process.platform) === "win32"
|
|
50
|
+
if ((runtime.platform ?? process.platform) === "win32" &&
|
|
51
|
+
shouldBridgeClaudeCommandThroughWindowsShell(resolvedBinaryPath)) {
|
|
44
52
|
return {
|
|
45
53
|
file: runtime.comspec?.trim() || process.env["ComSpec"]?.trim() || "cmd.exe",
|
|
46
54
|
args: ["/d", "/s", "/c", [resolvedBinaryPath, ...args].map(quoteWindowsCmdArg).join(" ")],
|
|
@@ -353,7 +361,7 @@ async function readClaudeCredentialsAccessToken() {
|
|
|
353
361
|
detail: unavailableDetails[0] ?? getClaudeCredentialsNotFoundDetail(locationsChecked),
|
|
354
362
|
};
|
|
355
363
|
}
|
|
356
|
-
async function queryAnthropicQuotaFromOAuthAccessToken(accessToken) {
|
|
364
|
+
async function queryAnthropicQuotaFromOAuthAccessToken(accessToken, requestTimeoutMs) {
|
|
357
365
|
let response;
|
|
358
366
|
try {
|
|
359
367
|
response = await fetchWithTimeout(ANTHROPIC_USAGE_URL, {
|
|
@@ -361,7 +369,7 @@ async function queryAnthropicQuotaFromOAuthAccessToken(accessToken) {
|
|
|
361
369
|
Authorization: `Bearer ${accessToken}`,
|
|
362
370
|
"anthropic-beta": ANTHROPIC_BETA_HEADER,
|
|
363
371
|
},
|
|
364
|
-
});
|
|
372
|
+
}, requestTimeoutMs);
|
|
365
373
|
}
|
|
366
374
|
catch (error) {
|
|
367
375
|
return {
|
|
@@ -731,7 +739,7 @@ export async function getAnthropicDiagnostics(options = {}) {
|
|
|
731
739
|
};
|
|
732
740
|
return diagnostics;
|
|
733
741
|
}
|
|
734
|
-
const fallbackQuota = await queryAnthropicQuotaFromOAuthAccessToken(credentials.accessToken);
|
|
742
|
+
const fallbackQuota = await queryAnthropicQuotaFromOAuthAccessToken(credentials.accessToken, options.requestTimeoutMs);
|
|
735
743
|
if (fallbackQuota.state !== "success") {
|
|
736
744
|
const diagnostics = {
|
|
737
745
|
installed: localDiagnostics.installed,
|