@slkiser/opencode-quota 2.16.0 → 3.0.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 +145 -49
- package/dist/bin/opencode-quota.d.ts +3 -0
- package/dist/bin/opencode-quota.d.ts.map +1 -0
- package/dist/bin/opencode-quota.js +37 -0
- package/dist/bin/opencode-quota.js.map +1 -0
- package/dist/lib/config-file-utils.d.ts +18 -0
- package/dist/lib/config-file-utils.d.ts.map +1 -0
- package/dist/lib/config-file-utils.js +88 -0
- package/dist/lib/config-file-utils.js.map +1 -0
- package/dist/lib/config.d.ts +10 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +111 -31
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/cursor-detection.d.ts +1 -0
- package/dist/lib/cursor-detection.d.ts.map +1 -1
- package/dist/lib/cursor-detection.js +16 -8
- package/dist/lib/cursor-detection.js.map +1 -1
- package/dist/lib/display-sanitize.d.ts +7 -0
- package/dist/lib/display-sanitize.d.ts.map +1 -1
- package/dist/lib/display-sanitize.js +49 -0
- package/dist/lib/display-sanitize.js.map +1 -1
- package/dist/lib/entries.d.ts +1 -1
- package/dist/lib/entries.d.ts.map +1 -1
- package/dist/lib/format.js +1 -1
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/google-antigravity-companion.d.ts +29 -0
- package/dist/lib/google-antigravity-companion.d.ts.map +1 -0
- package/dist/lib/google-antigravity-companion.js +122 -0
- package/dist/lib/google-antigravity-companion.js.map +1 -0
- package/dist/lib/google.d.ts +1 -0
- package/dist/lib/google.d.ts.map +1 -1
- package/dist/lib/google.js +54 -16
- package/dist/lib/google.js.map +1 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +1 -1
- package/dist/lib/grouped-entry-normalization.js +83 -23
- package/dist/lib/grouped-entry-normalization.js.map +1 -1
- package/dist/lib/init-installer.d.ts +101 -0
- package/dist/lib/init-installer.d.ts.map +1 -0
- package/dist/lib/init-installer.js +507 -0
- package/dist/lib/init-installer.js.map +1 -0
- package/dist/lib/provider-metadata.d.ts +1 -0
- package/dist/lib/provider-metadata.d.ts.map +1 -1
- package/dist/lib/provider-metadata.js +5 -0
- package/dist/lib/provider-metadata.js.map +1 -1
- package/dist/lib/quota-render-data.d.ts +72 -0
- package/dist/lib/quota-render-data.d.ts.map +1 -0
- package/dist/lib/quota-render-data.js +315 -0
- package/dist/lib/quota-render-data.js.map +1 -0
- package/dist/lib/quota-status.d.ts +9 -0
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +39 -1
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/lib/session-tokens-format.d.ts +16 -3
- package/dist/lib/session-tokens-format.d.ts.map +1 -1
- package/dist/lib/session-tokens-format.js +65 -11
- package/dist/lib/session-tokens-format.js.map +1 -1
- package/dist/lib/toast-format-grouped.js +1 -1
- package/dist/lib/toast-format-grouped.js.map +1 -1
- package/dist/lib/tui-config-diagnostics.d.ts +12 -0
- package/dist/lib/tui-config-diagnostics.d.ts.map +1 -0
- package/dist/lib/tui-config-diagnostics.js +49 -0
- package/dist/lib/tui-config-diagnostics.js.map +1 -0
- package/dist/lib/tui-line-style.d.ts +3 -0
- package/dist/lib/tui-line-style.d.ts.map +1 -0
- package/dist/lib/tui-line-style.js +7 -0
- package/dist/lib/tui-line-style.js.map +1 -0
- package/dist/lib/tui-panel-state.d.ts +7 -0
- package/dist/lib/tui-panel-state.d.ts.map +1 -0
- package/dist/lib/tui-panel-state.js +13 -0
- package/dist/lib/tui-panel-state.js.map +1 -0
- package/dist/lib/tui-runtime.d.ts +11 -0
- package/dist/lib/tui-runtime.d.ts.map +1 -0
- package/dist/lib/tui-runtime.js +107 -0
- package/dist/lib/tui-runtime.js.map +1 -0
- package/dist/lib/tui-sidebar-format.d.ts +13 -0
- package/dist/lib/tui-sidebar-format.d.ts.map +1 -0
- package/dist/lib/tui-sidebar-format.js +29 -0
- package/dist/lib/tui-sidebar-format.js.map +1 -0
- package/dist/lib/types.d.ts +8 -5
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +66 -320
- package/dist/plugin.js.map +1 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +1 -1
- package/dist/providers/alibaba-coding-plan.js +12 -19
- package/dist/providers/alibaba-coding-plan.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +12 -19
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/chutes.d.ts.map +1 -1
- package/dist/providers/chutes.js +10 -17
- package/dist/providers/chutes.js.map +1 -1
- package/dist/providers/copilot.js +1 -1
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/cursor.js +1 -1
- package/dist/providers/cursor.js.map +1 -1
- package/dist/providers/firmware.d.ts.map +1 -1
- package/dist/providers/firmware.js +11 -18
- package/dist/providers/firmware.js.map +1 -1
- package/dist/providers/google-antigravity.js +4 -4
- package/dist/providers/google-antigravity.js.map +1 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +1 -1
- package/dist/providers/minimax-coding-plan.js +14 -29
- package/dist/providers/minimax-coding-plan.js.map +1 -1
- package/dist/providers/nanogpt.d.ts.map +1 -1
- package/dist/providers/nanogpt.js +5 -12
- package/dist/providers/nanogpt.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +13 -28
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/opencode-go.d.ts.map +1 -1
- package/dist/providers/opencode-go.js +15 -40
- package/dist/providers/opencode-go.js.map +1 -1
- package/dist/providers/qwen-code.d.ts.map +1 -1
- package/dist/providers/qwen-code.js +16 -19
- package/dist/providers/qwen-code.js.map +1 -1
- package/dist/providers/result-helpers.d.ts +5 -0
- package/dist/providers/result-helpers.d.ts.map +1 -0
- package/dist/providers/result-helpers.js +10 -0
- package/dist/providers/result-helpers.js.map +1 -0
- package/dist/providers/zai.d.ts.map +1 -1
- package/dist/providers/zai.js +13 -28
- package/dist/providers/zai.js.map +1 -1
- package/dist/tui.d.ts +7 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.tsx +155 -0
- package/package.json +27 -9
package/README.md
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
# OpenCode Quota
|
|
2
|
+
[](https://www.npmjs.com/package/@slkiser/opencode-quota)
|
|
3
|
+
[](https://www.npmjs.com/package/@slkiser/opencode-quota)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://github.com/slkiser/opencode-quota/actions/workflows/ci.yml)
|
|
6
|
+
[](./package.json)
|
|
2
7
|
|
|
3
|
-
`opencode-quota` gives you two things:
|
|
4
8
|
|
|
5
|
-
-
|
|
6
|
-
|
|
9
|
+
`opencode-quota` adds usage quota and token visibility to OpenCode with zero context-window pollution.
|
|
10
|
+
|
|
11
|
+
What you get:
|
|
12
|
+
|
|
13
|
+
- popup quota toasts after assistant responses
|
|
14
|
+
- TUI sidebar panel
|
|
15
|
+
- manual `/quota`, `/quota_status`, and `/tokens_*` commands
|
|
7
16
|
|
|
8
17
|
**Quota providers**: Anthropic (Claude), GitHub Copilot, OpenAI (Plus/Pro), Cursor, Qwen Code, Alibaba Coding Plan, MiniMax Coding Plan, Chutes AI, Firmware AI, Google Antigravity, Z.ai Coding Plan, NanoGPT, and OpenCode Go.
|
|
9
18
|
|
|
@@ -24,25 +33,85 @@
|
|
|
24
33
|
</tr>
|
|
25
34
|
</table>
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
## Start here
|
|
37
|
+
|
|
38
|
+
OpenCode `>= 1.4.3` is required.
|
|
39
|
+
|
|
40
|
+
If you are coming back later:
|
|
41
|
+
- see [Provider Setup At A Glance](#provider-setup-at-a-glance) for provider-specific setup needs
|
|
42
|
+
- see [Commands](#commands) for the slash commands
|
|
43
|
+
- see [Configuration Reference](#configuration-reference) when you want to customize behavior
|
|
44
|
+
- see [Troubleshooting](#troubleshooting) if something does not appear or auto-detect correctly
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
### Automatic setup (recommended)
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npx @slkiser/opencode-quota init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The installer (append-only, preserves existing values) asks for:
|
|
54
|
+
|
|
55
|
+
- **Scope**: `Project` or `Global` (`Project` is the usual default)
|
|
56
|
+
- **Quota UI**: `Toast`, `Sidebar`, `Toast + Sidebar`, or `None (manual /quota and /tokens_* only)`
|
|
57
|
+
- **Provider mode**: `Auto-detect` or `Manual select` (`Auto-detect` is the usual default)
|
|
58
|
+
- **Layout style**: `classic` or `grouped` (`classic` is the usual default)
|
|
59
|
+
- **Show session input/output tokens**: `Yes` or `No` (`Yes` is the usual default)
|
|
60
|
+
|
|
61
|
+
All quota settings live in `opencode.json` or `opencode.jsonc`. `tui.json` or `tui.jsonc` is only for loading the sidebar plugin.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### After install
|
|
65
|
+
|
|
66
|
+
1. Restart OpenCode.
|
|
67
|
+
2. Run `/quota_status`.
|
|
68
|
+
3. Run `/quota`.
|
|
69
|
+
4. If you chose `Sidebar` or `Toast + Sidebar`, open the session sidebar and confirm the `Quota` panel appears.
|
|
28
70
|
|
|
29
|
-
|
|
71
|
+
### Manual setup
|
|
30
72
|
|
|
31
|
-
|
|
73
|
+
You can install manually, but the installer is easier and safer.
|
|
74
|
+
|
|
75
|
+
1. Add the server plugin to `opencode.json` or `opencode.jsonc`:
|
|
32
76
|
|
|
33
77
|
```jsonc
|
|
34
78
|
{
|
|
79
|
+
"$schema": "https://opencode.ai/config.json",
|
|
35
80
|
"plugin": ["@slkiser/opencode-quota"]
|
|
36
81
|
}
|
|
37
82
|
```
|
|
38
83
|
|
|
39
|
-
|
|
84
|
+
2. If you also want the sidebar, add the same package to a `tui.json` or `tui.jsonc` file that OpenCode loads (commonly the same folder):
|
|
85
|
+
|
|
86
|
+
```jsonc
|
|
87
|
+
{
|
|
88
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
89
|
+
"plugin": ["@slkiser/opencode-quota"]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
3. Optional settings still go in `opencode.json`, not `tui.json`.
|
|
94
|
+
|
|
95
|
+
Providers are auto-detected from your existing OpenCode setup by default, and most providers work from your existing OpenCode auth.
|
|
96
|
+
|
|
97
|
+
<details>
|
|
98
|
+
<summary><strong>Example: Sidebar only (turn off popup toasts)</strong></summary>
|
|
99
|
+
|
|
100
|
+
Keep the `tui.json` or `tui.jsonc` entry above and disable toasts in `opencode.json` or `opencode.jsonc`:
|
|
40
101
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
102
|
+
```jsonc
|
|
103
|
+
{
|
|
104
|
+
"$schema": "https://opencode.ai/config.json",
|
|
105
|
+
"plugin": ["@slkiser/opencode-quota"],
|
|
106
|
+
"experimental": {
|
|
107
|
+
"quotaToast": {
|
|
108
|
+
"enableToast": false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
44
113
|
|
|
45
|
-
|
|
114
|
+
</details>
|
|
46
115
|
|
|
47
116
|
<details>
|
|
48
117
|
<summary><strong>Example: Turn off auto-detection and choose providers</strong></summary>
|
|
@@ -60,13 +129,13 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
60
129
|
</details>
|
|
61
130
|
|
|
62
131
|
<details>
|
|
63
|
-
<summary><strong>Example: Grouped
|
|
132
|
+
<summary><strong>Example: Grouped quota layout instead of the default classic layout</strong></summary>
|
|
64
133
|
|
|
65
134
|
```jsonc
|
|
66
135
|
{
|
|
67
136
|
"experimental": {
|
|
68
137
|
"quotaToast": {
|
|
69
|
-
"
|
|
138
|
+
"formatStyle": "grouped"
|
|
70
139
|
}
|
|
71
140
|
}
|
|
72
141
|
}
|
|
@@ -74,7 +143,7 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
74
143
|
|
|
75
144
|
</details>
|
|
76
145
|
|
|
77
|
-
|
|
146
|
+
## Provider Setup At A Glance
|
|
78
147
|
|
|
79
148
|
| Provider | Auto setup | Authentication | Quota |
|
|
80
149
|
| --- | --- | --- | --- |
|
|
@@ -92,6 +161,7 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
92
161
|
| **MiniMax Coding Plan** | Yes | OpenCode auth/global config/env | Remote API |
|
|
93
162
|
| **OpenCode Go** | Needs [quick setup](#opencode-go-quick-setup) | Env/config auth | Dashboard scraping |
|
|
94
163
|
|
|
164
|
+
|
|
95
165
|
<a id="anthropic-quick-setup"></a>
|
|
96
166
|
<details>
|
|
97
167
|
<summary><strong>Quick setup: Anthropic (Claude)</strong></summary>
|
|
@@ -117,12 +187,12 @@ For behavior details and troubleshooting, see [Anthropic notes](#anthropic-notes
|
|
|
117
187
|
<details>
|
|
118
188
|
<summary><strong>Quick setup: Cursor</strong></summary>
|
|
119
189
|
|
|
120
|
-
Cursor quota support requires the
|
|
190
|
+
Cursor quota support requires the `@playwo/opencode-cursor-oauth` [plugin](https://github.com/PoolPirate/opencode-cursor):
|
|
121
191
|
|
|
122
192
|
```jsonc
|
|
123
193
|
{
|
|
124
194
|
"$schema": "https://opencode.ai/config.json",
|
|
125
|
-
"plugin": ["opencode-cursor-oauth", "@slkiser/opencode-quota"],
|
|
195
|
+
"plugin": ["@playwo/opencode-cursor-oauth", "@slkiser/opencode-quota"],
|
|
126
196
|
"provider": {
|
|
127
197
|
"cursor": {
|
|
128
198
|
"name": "Cursor"
|
|
@@ -151,7 +221,7 @@ For behavior details and troubleshooting, see [Cursor notes](#cursor-notes).
|
|
|
151
221
|
<details>
|
|
152
222
|
<summary><strong>Quick setup: Google Antigravity</strong></summary>
|
|
153
223
|
|
|
154
|
-
Google quota support requires the `opencode-antigravity-auth` [plugin](https://github.com/NoeFabris/opencode-antigravity-auth):
|
|
224
|
+
Google quota support requires the `opencode-antigravity-auth` [plugin](https://github.com/NoeFabris/opencode-antigravity-auth). `@slkiser/opencode-quota` does not install that companion plugin transitively, so install/configure it separately and then enable both plugins:
|
|
155
225
|
|
|
156
226
|
```jsonc
|
|
157
227
|
{
|
|
@@ -215,7 +285,7 @@ Environment variables take precedence over the config file. Run `/quota_status`
|
|
|
215
285
|
| Command | What it shows |
|
|
216
286
|
| --- | --- |
|
|
217
287
|
| `/quota` | Manual grouped quota report with a local call timestamp |
|
|
218
|
-
| `/quota_status` | Concise diagnostics for config, provider availability, account detection, and pricing snapshot health |
|
|
288
|
+
| `/quota_status` | Concise diagnostics for config, TUI setup, provider availability, account detection, and pricing snapshot health |
|
|
219
289
|
| `/pricing_refresh` | Pull the local runtime pricing snapshot from `models.dev` on demand |
|
|
220
290
|
| `/tokens_today` | Tokens used today (calendar day) |
|
|
221
291
|
| `/tokens_daily` | Tokens used in the last 24 hours |
|
|
@@ -226,8 +296,6 @@ Environment variables take precedence over the config file. Run `/quota_status`
|
|
|
226
296
|
| `/tokens_session_all` | Tokens used in the current session plus all descendant child/subagent sessions |
|
|
227
297
|
| `/tokens_between` | Tokens used between two dates: `YYYY-MM-DD YYYY-MM-DD` |
|
|
228
298
|
|
|
229
|
-
There is no `/token` command. The reporting commands are the `/tokens_*` family.
|
|
230
|
-
Use `/tokens_session` for strict per-session accounting, and `/tokens_session_all` when you want the selected parent session plus every nested child session linked by `parent_id`.
|
|
231
299
|
|
|
232
300
|
## Provider-Specific Notes
|
|
233
301
|
|
|
@@ -289,7 +357,7 @@ Example `copilot-quota-token.json`:
|
|
|
289
357
|
<details>
|
|
290
358
|
<summary><strong>Cursor</strong></summary>
|
|
291
359
|
|
|
292
|
-
See [Cursor quick setup](#cursor-quick-setup) for companion-plugin OAuth auth. Quota and token reporting stays local to OpenCode history and local pricing data.
|
|
360
|
+
See [Cursor quick setup](#cursor-quick-setup) for companion-plugin OAuth auth. The canonical companion package is `@playwo/opencode-cursor-oauth`; older plugin names such as `opencode-cursor-oauth`, `opencode-cursor`, and `cursor-acp` are still detected as compatibility aliases. Quota and token reporting stays local to OpenCode history and local pricing data.
|
|
293
361
|
|
|
294
362
|
- Detects Cursor usage when the provider is `cursor` or the stored/current model id is `cursor/*`.
|
|
295
363
|
- `/tokens_*` maps Cursor API-pool models to official pricing and uses bundled static pricing for `auto` and `composer*`.
|
|
@@ -454,9 +522,10 @@ Example user/global config (`~/.config/opencode/opencode.jsonc` on Linux/macOS):
|
|
|
454
522
|
<details>
|
|
455
523
|
<summary><strong>Google Antigravity</strong></summary>
|
|
456
524
|
|
|
457
|
-
See [Google Antigravity quick setup](#google-antigravity-quick-setup). This companion auth flow does not use `auth.json`; it reads `antigravity-accounts.json` from the OpenCode runtime directories.
|
|
525
|
+
See [Google Antigravity quick setup](#google-antigravity-quick-setup). This companion auth flow does not use `auth.json`; it reads `antigravity-accounts.json` from the OpenCode runtime directories. `@slkiser/opencode-quota` expects the companion plugin to be installed separately.
|
|
458
526
|
|
|
459
|
-
- `/quota_status` includes a `google_antigravity` section with the selected accounts path, all present/candidate paths, account counts, valid refresh-token counts, and the Google token-cache path.
|
|
527
|
+
- `/quota_status` includes a `google_antigravity` section with the selected accounts path, all present/candidate paths, account counts, valid refresh-token counts, companion package state/path, and the Google token-cache path.
|
|
528
|
+
- If the companion plugin is missing or incompatible, `/quota_status` shows `companion_package_state` and `companion_error`.
|
|
460
529
|
- If detection looks wrong, start with the `google_antigravity` section in `/quota_status`.
|
|
461
530
|
|
|
462
531
|
</details>
|
|
@@ -517,36 +586,63 @@ OpenCode Go quota scrapes the OpenCode Go dashboard at `https://opencode.ai/work
|
|
|
517
586
|
|
|
518
587
|
## Configuration Reference
|
|
519
588
|
|
|
520
|
-
All plugin settings live under `experimental.quotaToast`.
|
|
589
|
+
All quota plugin settings live under `experimental.quotaToast` in `opencode.json` or `opencode.jsonc`. The sidebar install step is separate: add the package to `tui.json` or `tui.jsonc`, or choose `Sidebar` or `Toast + Sidebar` in `npx @slkiser/opencode-quota init`.
|
|
590
|
+
|
|
591
|
+
When both are present, user/global config provides defaults. Project/workspace config may override display-oriented settings for that project, but user/global config remains authoritative for automatic/network-affecting settings such as `enabled`, `enabledProviders`, `minIntervalMs`, `pricingSnapshot.*`, `showOnIdle`, `showOnQuestion`, `showOnCompact`, and `showOnBothFail`. SDK config is only used when no config files are found.
|
|
592
|
+
|
|
593
|
+
### Core/shared settings
|
|
594
|
+
|
|
595
|
+
| Option | Default | Meaning |
|
|
596
|
+
| --- | --- | --- |
|
|
597
|
+
| `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. |
|
|
598
|
+
| `enabledProviders` | `"auto"` | Auto-detect providers, or set an explicit provider list. |
|
|
599
|
+
| `minIntervalMs` | `300000` | Minimum fetch interval between provider updates. |
|
|
600
|
+
| `formatStyle` | `classic` | Shared quota-row style for popup toasts and the TUI sidebar: `classic` or `grouped`. Legacy `toastStyle` is still accepted on read for backward compatibility, but `formatStyle` is the canonical key. |
|
|
601
|
+
| `onlyCurrentModel` | `false` | Filter quota rows to the current model/provider when that session selection can be resolved. |
|
|
602
|
+
| `showSessionTokens` | `true` | Show the `Session input/output tokens` section in quota displays when session token data is available. Toasts and `/quota` show per-model input/output rows; the TUI sidebar shows a one-line total summary. |
|
|
603
|
+
| `pricingSnapshot.source` | `"auto"` | Token pricing snapshot selection for `/tokens_*`: `auto`, `bundled`, or `runtime`. |
|
|
604
|
+
| `pricingSnapshot.autoRefresh` | `7` | Refresh stale local pricing data after this many days. |
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
### Toast settings
|
|
608
|
+
|
|
609
|
+
| Option | Default | Meaning |
|
|
610
|
+
| --- | --- | --- |
|
|
611
|
+
| `enableToast` | `true` | Show popup toasts. Disabling this does not disable `/quota` or the TUI sidebar. |
|
|
612
|
+
| `toastDurationMs` | `9000` | Toast duration in milliseconds. |
|
|
613
|
+
| `showOnIdle` | `true` | Show a toast on the idle trigger. |
|
|
614
|
+
| `showOnQuestion` | `true` | Show a toast after a question/assistant response. |
|
|
615
|
+
| `showOnCompact` | `true` | Show a toast after session compaction. |
|
|
616
|
+
| `showOnBothFail` | `true` | Show a fallback toast when providers attempted quota reads and all failed. |
|
|
617
|
+
| `layout.maxWidth` | `50` | Toast formatting width target. Ignored by the TUI sidebar. |
|
|
618
|
+
| `layout.narrowAt` | `42` | Toast compact-layout breakpoint. Ignored by the TUI sidebar. |
|
|
619
|
+
| `layout.tinyAt` | `32` | Toast tiny-layout breakpoint. Ignored by the TUI sidebar. |
|
|
620
|
+
| `debug` | `false` | Append toast debug context when troubleshooting. |
|
|
621
|
+
|
|
622
|
+
### TUI sidebar setup
|
|
623
|
+
|
|
624
|
+
If you want the `Quota` sidebar panel, you need **two files**:
|
|
625
|
+
|
|
626
|
+
1. **`tui.json` or `tui.jsonc`**: add the plugin entry so OpenCode mounts the sidebar panel.
|
|
627
|
+
2. **`opencode.json` or `opencode.jsonc`**: put all quota settings under `experimental.quotaToast`.
|
|
628
|
+
|
|
629
|
+
**Important:** `experimental.quotaToast.*` settings do **not** go in `tui.json`. `tui.json` is only for loading the TUI plugin.
|
|
630
|
+
|
|
631
|
+
| File | What goes there | Needed for sidebar? |
|
|
632
|
+
| --- | --- | --- |
|
|
633
|
+
| `tui.json` / `tui.jsonc` | `plugin: ["@slkiser/opencode-quota"]` | Yes |
|
|
634
|
+
| `opencode.json` / `opencode.jsonc` | All `experimental.quotaToast.*` settings | Yes |
|
|
521
635
|
|
|
522
|
-
|
|
636
|
+
### Provider-specific settings
|
|
523
637
|
|
|
524
638
|
| Option | Default | Meaning |
|
|
525
639
|
| --- | --- | --- |
|
|
526
|
-
| `
|
|
527
|
-
| `
|
|
528
|
-
| `
|
|
529
|
-
| `
|
|
530
|
-
| `
|
|
531
|
-
| `
|
|
532
|
-
| `toastDurationMs` | `9000` | Toast duration in milliseconds |
|
|
533
|
-
| `showOnIdle` | `true` | Show toast on idle trigger |
|
|
534
|
-
| `showOnQuestion` | `true` | Show toast after a question/assistant response |
|
|
535
|
-
| `showOnCompact` | `true` | Show toast after session compaction |
|
|
536
|
-
| `showOnBothFail` | `true` | Show a fallback toast when providers attempt and all fail |
|
|
537
|
-
| `onlyCurrentModel` | `false` | Filter to the current model when possible |
|
|
538
|
-
| `showSessionTokens` | `true` | Append current-session token totals to toast output |
|
|
539
|
-
| `layout.maxWidth` | `50` | Main formatting width target |
|
|
540
|
-
| `layout.narrowAt` | `42` | Compact layout breakpoint |
|
|
541
|
-
| `layout.tinyAt` | `32` | Tiny layout breakpoint |
|
|
542
|
-
| `googleModels` | `["CLAUDE"]` | Google model keys: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE` |
|
|
543
|
-
| `alibabaCodingPlanTier` | `"lite"` | Fallback Alibaba Coding Plan tier when auth does not include `tier` |
|
|
544
|
-
| `cursorPlan` | `"none"` | Cursor included API budget preset: `none`, `pro`, `pro-plus`, `ultra` |
|
|
545
|
-
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD |
|
|
546
|
-
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month |
|
|
547
|
-
| `pricingSnapshot.source` | `"auto"` | Token pricing snapshot selection: `auto`, `bundled`, or `runtime` |
|
|
548
|
-
| `pricingSnapshot.autoRefresh` | `5` | Refresh stale local pricing data after this many days |
|
|
549
|
-
| `debug` | `false` | Include debug context in toast output |
|
|
640
|
+
| `anthropicBinaryPath` | `"claude"` | Command/path used for local Claude CLI probing; override this for custom installs or shim locations. |
|
|
641
|
+
| `googleModels` | `["CLAUDE"]` | Google model keys to query: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE`. |
|
|
642
|
+
| `alibabaCodingPlanTier` | `"lite"` | Fallback Alibaba Coding Plan tier when auth does not include `tier`. |
|
|
643
|
+
| `cursorPlan` | `"none"` | Cursor included API budget preset: `none`, `pro`, `pro-plus`, `ultra`. |
|
|
644
|
+
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD. |
|
|
645
|
+
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month. |
|
|
550
646
|
|
|
551
647
|
## Token Pricing Snapshot
|
|
552
648
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAmBA,wBAAsB,IAAI,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { pathToFileURL } from "url";
|
|
3
|
+
import { runInitInstaller } from "../lib/init-installer.js";
|
|
4
|
+
const USAGE = [
|
|
5
|
+
"Usage:",
|
|
6
|
+
" npx @slkiser/opencode-quota init",
|
|
7
|
+
" npx @slkiser/opencode-quota --help",
|
|
8
|
+
"",
|
|
9
|
+
"Commands:",
|
|
10
|
+
" init Run the interactive quota installer",
|
|
11
|
+
].join("\n");
|
|
12
|
+
function printUsage() {
|
|
13
|
+
console.log(USAGE);
|
|
14
|
+
}
|
|
15
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
16
|
+
const [command, ...rest] = argv;
|
|
17
|
+
if (!command) {
|
|
18
|
+
printUsage();
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
if (command === "--help" || command === "-h" || command === "help") {
|
|
22
|
+
printUsage();
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
if (command === "init" && rest.length === 0) {
|
|
26
|
+
return await runInitInstaller();
|
|
27
|
+
}
|
|
28
|
+
printUsage();
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
const isDirectRun = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
32
|
+
if (isDirectRun) {
|
|
33
|
+
void main().then((code) => {
|
|
34
|
+
process.exitCode = code;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=opencode-quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-quota.js","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,oCAAoC;IACpC,sCAAsC;IACtC,EAAE;IACF,WAAW;IACX,+CAA+C;CAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACnE,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,MAAM,gBAAgB,EAAE,CAAC;IAClC,CAAC;IAED,UAAU,EAAE,CAAC;IACb,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE7E,IAAI,WAAW,EAAE,CAAC;IAChB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ConfigFileKind = "opencode" | "tui";
|
|
2
|
+
export type ConfigFileFormat = "json" | "jsonc";
|
|
3
|
+
export interface EditableConfigPath {
|
|
4
|
+
path: string;
|
|
5
|
+
format: ConfigFileFormat;
|
|
6
|
+
existed: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function dedupeNonEmptyStrings(items: string[]): string[];
|
|
9
|
+
export declare function findGitWorktreeRoot(startDir: string): string | null;
|
|
10
|
+
export declare function getConfigFileCandidatePaths(dir: string, kind: ConfigFileKind): string[];
|
|
11
|
+
export declare function resolveEditableConfigPath(params: {
|
|
12
|
+
dir: string;
|
|
13
|
+
kind: ConfigFileKind;
|
|
14
|
+
}): EditableConfigPath;
|
|
15
|
+
export declare function getPluginSpecFromEntry(entry: unknown): string | null;
|
|
16
|
+
export declare function extractPluginSpecsFromParsedConfig(parsed: unknown): string[];
|
|
17
|
+
export declare function isQuotaPluginSpec(spec: string, kind: ConfigFileKind): boolean;
|
|
18
|
+
//# sourceMappingURL=config-file-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file-utils.d.ts","sourceRoot":"","sources":["../../src/lib/config-file-utils.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,KAAK,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcnE;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,EAAE,CAEvF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;CACtB,GAAG,kBAAkB,CAwBrB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAcpE;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAwB5E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAc7E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
export function dedupeNonEmptyStrings(items) {
|
|
4
|
+
return [...new Set(items.map((item) => item.trim()).filter(Boolean))];
|
|
5
|
+
}
|
|
6
|
+
export function findGitWorktreeRoot(startDir) {
|
|
7
|
+
let current = startDir;
|
|
8
|
+
while (true) {
|
|
9
|
+
if (existsSync(join(current, ".git"))) {
|
|
10
|
+
return current;
|
|
11
|
+
}
|
|
12
|
+
const parent = dirname(current);
|
|
13
|
+
if (parent === current) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
current = parent;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function getConfigFileCandidatePaths(dir, kind) {
|
|
20
|
+
return [join(dir, `${kind}.json`), join(dir, `${kind}.jsonc`)];
|
|
21
|
+
}
|
|
22
|
+
export function resolveEditableConfigPath(params) {
|
|
23
|
+
const jsoncPath = join(params.dir, `${params.kind}.jsonc`);
|
|
24
|
+
if (existsSync(jsoncPath)) {
|
|
25
|
+
return {
|
|
26
|
+
path: jsoncPath,
|
|
27
|
+
format: "jsonc",
|
|
28
|
+
existed: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const jsonPath = join(params.dir, `${params.kind}.json`);
|
|
32
|
+
if (existsSync(jsonPath)) {
|
|
33
|
+
return {
|
|
34
|
+
path: jsonPath,
|
|
35
|
+
format: "json",
|
|
36
|
+
existed: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
path: jsonPath,
|
|
41
|
+
format: "json",
|
|
42
|
+
existed: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function getPluginSpecFromEntry(entry) {
|
|
46
|
+
const spec = typeof entry === "string"
|
|
47
|
+
? entry
|
|
48
|
+
: Array.isArray(entry) && typeof entry[0] === "string"
|
|
49
|
+
? entry[0]
|
|
50
|
+
: null;
|
|
51
|
+
if (typeof spec !== "string") {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const trimmed = spec.trim();
|
|
55
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
56
|
+
}
|
|
57
|
+
export function extractPluginSpecsFromParsedConfig(parsed) {
|
|
58
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const root = parsed;
|
|
62
|
+
const pluginEntries = [];
|
|
63
|
+
if (Array.isArray(root.plugin)) {
|
|
64
|
+
pluginEntries.push(...root.plugin);
|
|
65
|
+
}
|
|
66
|
+
if (root.tui && typeof root.tui === "object" && !Array.isArray(root.tui)) {
|
|
67
|
+
const tuiRoot = root.tui;
|
|
68
|
+
if (Array.isArray(tuiRoot.plugin)) {
|
|
69
|
+
pluginEntries.push(...tuiRoot.plugin);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return dedupeNonEmptyStrings(pluginEntries
|
|
73
|
+
.map((entry) => getPluginSpecFromEntry(entry))
|
|
74
|
+
.filter((entry) => typeof entry === "string"));
|
|
75
|
+
}
|
|
76
|
+
export function isQuotaPluginSpec(spec, kind) {
|
|
77
|
+
const normalized = spec.replace(/\\/g, "/").toLowerCase();
|
|
78
|
+
if (normalized.includes("@slkiser/opencode-quota")) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (normalized.includes("/opencode-quota") && !normalized.includes("/opencode-quota/dist/")) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return kind === "tui"
|
|
85
|
+
? normalized.includes("opencode-quota/dist/tui.tsx")
|
|
86
|
+
: normalized.includes("opencode-quota/dist/index.js");
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=config-file-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file-utils.js","sourceRoot":"","sources":["../../src/lib/config-file-utils.ts"],"names":[],"mappings":"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"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration loader for opencode-quota plugin.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* plugin performs automatic network-backed quota fetches.
|
|
4
|
+
* Precedence model:
|
|
5
|
+
* - Global/user config provides defaults.
|
|
6
|
+
* - Project/workspace config may override display-oriented settings for the current project.
|
|
7
|
+
* - Global/user config remains authoritative for automatic/network-affecting settings.
|
|
9
8
|
* - SDK config is used only as a fallback when no config files are found.
|
|
10
9
|
*/
|
|
11
10
|
import type { QuotaToastConfig } from "./types.js";
|
|
12
11
|
export interface LoadConfigMeta {
|
|
13
12
|
source: "sdk" | "files" | "defaults";
|
|
14
13
|
paths: string[];
|
|
14
|
+
networkSettingSources: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export interface LoadConfigOptions {
|
|
17
|
+
cwd?: string;
|
|
15
18
|
}
|
|
16
19
|
export declare function createLoadConfigMeta(): LoadConfigMeta;
|
|
17
20
|
/**
|
|
18
21
|
* Load plugin configuration from OpenCode config
|
|
19
22
|
*
|
|
20
|
-
* @param client - OpenCode SDK client
|
|
23
|
+
* @param client - Optional OpenCode SDK client fallback
|
|
21
24
|
* @returns Merged configuration with defaults
|
|
22
25
|
*/
|
|
23
26
|
export declare function loadConfig(client: {
|
|
@@ -30,5 +33,5 @@ export declare function loadConfig(client: {
|
|
|
30
33
|
};
|
|
31
34
|
}>;
|
|
32
35
|
};
|
|
33
|
-
}, meta?: LoadConfigMeta): Promise<QuotaToastConfig>;
|
|
36
|
+
} | undefined, meta?: LoadConfigMeta, options?: LoadConfigOptions): Promise<QuotaToastConfig>;
|
|
34
37
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,UAAU,CAAC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,oBAAoB,IAAI,cAAc,CAErD;AA0HD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EACF;IACE,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,OAAO,CAAC;YACjB,IAAI,CAAC,EAAE;gBAAE,YAAY,CAAC,EAAE;oBAAE,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;iBAAE,CAAA;aAAE,CAAC;SACtE,CAAC,CAAC;KACJ,CAAC;CACH,GACD,SAAS,EACb,IAAI,CAAC,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAgR3B"}
|