@slkiser/opencode-quota 2.17.0 → 3.0.1
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 +150 -50
- package/dist/bin/opencode-quota.d.ts +4 -0
- package/dist/bin/opencode-quota.d.ts.map +1 -0
- package/dist/bin/opencode-quota.js +52 -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/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 +37 -0
- 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
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
[](./package.json)
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
`opencode-quota`
|
|
9
|
+
`opencode-quota` adds usage quota and token visibility to OpenCode with zero context-window pollution.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
What you get:
|
|
12
|
+
|
|
13
|
+
- TUI sidebar panel with quota
|
|
14
|
+
- popup quota toasts after assistant responses
|
|
15
|
+
- manual `/quota`, `/quota_status`, and `/tokens_*` commands
|
|
13
16
|
|
|
14
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.
|
|
15
18
|
|
|
@@ -17,38 +20,108 @@
|
|
|
17
20
|
|
|
18
21
|
<table>
|
|
19
22
|
<tr>
|
|
20
|
-
<td width="
|
|
21
|
-
|
|
23
|
+
<td width="100%">
|
|
24
|
+
<img src="https://shawnkiser.com/opencode-quota/sidebar.webp" alt="Image of opencode-quota /tokens_weekly output" />
|
|
25
|
+
</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td width="100%" align="center">Example of TUI sidebar</td>
|
|
22
29
|
</tr>
|
|
30
|
+
</table>
|
|
31
|
+
|
|
32
|
+
<table>
|
|
33
|
+
|
|
23
34
|
<tr>
|
|
24
35
|
<td width="50%">
|
|
25
|
-
<img src="https://shawnkiser.com/opencode-quota/
|
|
36
|
+
<img src="https://shawnkiser.com/opencode-quota/toast.webp" alt="Image of opencode-quota toast" />
|
|
26
37
|
</td>
|
|
27
38
|
<td width="50%">
|
|
28
|
-
<img src="https://shawnkiser.com/opencode-quota/
|
|
39
|
+
<img src="https://shawnkiser.com/opencode-quota/token.webp" alt="Image of opencode-quota /tokens_weekly output" />
|
|
29
40
|
</td>
|
|
30
41
|
</tr>
|
|
42
|
+
<tr>
|
|
43
|
+
<td width="50%" align="center">Example of popup toast</td>
|
|
44
|
+
<td width="50%" align="center">Example of <code>/tokens_weekly</code></td>
|
|
45
|
+
</tr>
|
|
31
46
|
</table>
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
OpenCode `>= 1.4.3` is required.
|
|
49
|
+
|
|
50
|
+
If you are coming back later:
|
|
51
|
+
- see [Provider Setup At A Glance](#provider-setup-at-a-glance) for provider-specific setup needs
|
|
52
|
+
- see [Commands](#commands) for the slash commands
|
|
53
|
+
- see [Configuration Reference](#configuration-reference) when you want to customize behavior
|
|
54
|
+
- see [Troubleshooting](#troubleshooting) if something does not appear or auto-detect correctly
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
### Automatic setup (recommended)
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npx @slkiser/opencode-quota init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The installer (append-only, preserves existing values) asks for:
|
|
34
64
|
|
|
35
|
-
|
|
65
|
+
- **Scope**: `Project` or `Global`
|
|
66
|
+
- **Quota UI**: `Toast`, `Sidebar`, `Toast + Sidebar`, or `None (manual /quota and /tokens_* only)`
|
|
67
|
+
- **Provider mode**: `Auto-detect` or `Manual select`
|
|
68
|
+
- **Layout style**: `classic` or `grouped`
|
|
69
|
+
- **Show session input/output tokens**: `Yes` or `No`
|
|
36
70
|
|
|
37
|
-
|
|
71
|
+
All quota settings live in `opencode.json` or `opencode.jsonc`. `tui.json` or `tui.jsonc` is only for loading the sidebar plugin.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### After install
|
|
75
|
+
|
|
76
|
+
1. Restart OpenCode.
|
|
77
|
+
2. Run `/quota_status`.
|
|
78
|
+
3. Run `/quota`.
|
|
79
|
+
4. If you chose `Sidebar` or `Toast + Sidebar`, open the session sidebar and confirm the `Quota` panel appears.
|
|
80
|
+
|
|
81
|
+
### Manual setup
|
|
82
|
+
|
|
83
|
+
You can install manually, but the installer is easier and safer.
|
|
84
|
+
|
|
85
|
+
1. Add the server plugin to `opencode.json` or `opencode.jsonc`:
|
|
38
86
|
|
|
39
87
|
```jsonc
|
|
40
88
|
{
|
|
89
|
+
"$schema": "https://opencode.ai/config.json",
|
|
41
90
|
"plugin": ["@slkiser/opencode-quota"]
|
|
42
91
|
}
|
|
43
92
|
```
|
|
44
93
|
|
|
45
|
-
|
|
94
|
+
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):
|
|
46
95
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
96
|
+
```jsonc
|
|
97
|
+
{
|
|
98
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
99
|
+
"plugin": ["@slkiser/opencode-quota"]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
50
102
|
|
|
51
|
-
|
|
103
|
+
3. Optional settings still go in `opencode.json`, not `tui.json`.
|
|
104
|
+
|
|
105
|
+
Providers are auto-detected from your existing OpenCode setup by default, and most providers work from your existing OpenCode auth.
|
|
106
|
+
|
|
107
|
+
<details>
|
|
108
|
+
<summary><strong>Example: Sidebar only (turn off popup toasts)</strong></summary>
|
|
109
|
+
|
|
110
|
+
Keep the `tui.json` or `tui.jsonc` entry above and disable toasts in `opencode.json` or `opencode.jsonc`:
|
|
111
|
+
|
|
112
|
+
```jsonc
|
|
113
|
+
{
|
|
114
|
+
"$schema": "https://opencode.ai/config.json",
|
|
115
|
+
"plugin": ["@slkiser/opencode-quota"],
|
|
116
|
+
"experimental": {
|
|
117
|
+
"quotaToast": {
|
|
118
|
+
"enableToast": false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
</details>
|
|
52
125
|
|
|
53
126
|
<details>
|
|
54
127
|
<summary><strong>Example: Turn off auto-detection and choose providers</strong></summary>
|
|
@@ -66,13 +139,13 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
66
139
|
</details>
|
|
67
140
|
|
|
68
141
|
<details>
|
|
69
|
-
<summary><strong>Example: Grouped
|
|
142
|
+
<summary><strong>Example: Grouped quota layout instead of the default classic layout</strong></summary>
|
|
70
143
|
|
|
71
144
|
```jsonc
|
|
72
145
|
{
|
|
73
146
|
"experimental": {
|
|
74
147
|
"quotaToast": {
|
|
75
|
-
"
|
|
148
|
+
"formatStyle": "grouped"
|
|
76
149
|
}
|
|
77
150
|
}
|
|
78
151
|
}
|
|
@@ -80,7 +153,7 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
80
153
|
|
|
81
154
|
</details>
|
|
82
155
|
|
|
83
|
-
|
|
156
|
+
## Provider Setup At A Glance
|
|
84
157
|
|
|
85
158
|
| Provider | Auto setup | Authentication | Quota |
|
|
86
159
|
| --- | --- | --- | --- |
|
|
@@ -98,6 +171,7 @@ That is enough for most installs. Providers are auto-detected from your existing
|
|
|
98
171
|
| **MiniMax Coding Plan** | Yes | OpenCode auth/global config/env | Remote API |
|
|
99
172
|
| **OpenCode Go** | Needs [quick setup](#opencode-go-quick-setup) | Env/config auth | Dashboard scraping |
|
|
100
173
|
|
|
174
|
+
|
|
101
175
|
<a id="anthropic-quick-setup"></a>
|
|
102
176
|
<details>
|
|
103
177
|
<summary><strong>Quick setup: Anthropic (Claude)</strong></summary>
|
|
@@ -157,7 +231,7 @@ For behavior details and troubleshooting, see [Cursor notes](#cursor-notes).
|
|
|
157
231
|
<details>
|
|
158
232
|
<summary><strong>Quick setup: Google Antigravity</strong></summary>
|
|
159
233
|
|
|
160
|
-
Google quota support requires the `opencode-antigravity-auth` [plugin](https://github.com/NoeFabris/opencode-antigravity-auth):
|
|
234
|
+
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:
|
|
161
235
|
|
|
162
236
|
```jsonc
|
|
163
237
|
{
|
|
@@ -221,7 +295,7 @@ Environment variables take precedence over the config file. Run `/quota_status`
|
|
|
221
295
|
| Command | What it shows |
|
|
222
296
|
| --- | --- |
|
|
223
297
|
| `/quota` | Manual grouped quota report with a local call timestamp |
|
|
224
|
-
| `/quota_status` | Concise diagnostics for config, provider availability, account detection, and pricing snapshot health |
|
|
298
|
+
| `/quota_status` | Concise diagnostics for config, TUI setup, provider availability, account detection, and pricing snapshot health |
|
|
225
299
|
| `/pricing_refresh` | Pull the local runtime pricing snapshot from `models.dev` on demand |
|
|
226
300
|
| `/tokens_today` | Tokens used today (calendar day) |
|
|
227
301
|
| `/tokens_daily` | Tokens used in the last 24 hours |
|
|
@@ -232,8 +306,6 @@ Environment variables take precedence over the config file. Run `/quota_status`
|
|
|
232
306
|
| `/tokens_session_all` | Tokens used in the current session plus all descendant child/subagent sessions |
|
|
233
307
|
| `/tokens_between` | Tokens used between two dates: `YYYY-MM-DD YYYY-MM-DD` |
|
|
234
308
|
|
|
235
|
-
There is no `/token` command. The reporting commands are the `/tokens_*` family.
|
|
236
|
-
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`.
|
|
237
309
|
|
|
238
310
|
## Provider-Specific Notes
|
|
239
311
|
|
|
@@ -460,9 +532,10 @@ Example user/global config (`~/.config/opencode/opencode.jsonc` on Linux/macOS):
|
|
|
460
532
|
<details>
|
|
461
533
|
<summary><strong>Google Antigravity</strong></summary>
|
|
462
534
|
|
|
463
|
-
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.
|
|
535
|
+
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.
|
|
464
536
|
|
|
465
|
-
- `/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.
|
|
537
|
+
- `/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.
|
|
538
|
+
- If the companion plugin is missing or incompatible, `/quota_status` shows `companion_package_state` and `companion_error`.
|
|
466
539
|
- If detection looks wrong, start with the `google_antigravity` section in `/quota_status`.
|
|
467
540
|
|
|
468
541
|
</details>
|
|
@@ -523,36 +596,63 @@ OpenCode Go quota scrapes the OpenCode Go dashboard at `https://opencode.ai/work
|
|
|
523
596
|
|
|
524
597
|
## Configuration Reference
|
|
525
598
|
|
|
526
|
-
All plugin settings live under `experimental.quotaToast`.
|
|
599
|
+
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`.
|
|
600
|
+
|
|
601
|
+
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.
|
|
602
|
+
|
|
603
|
+
### Core/shared settings
|
|
604
|
+
|
|
605
|
+
| Option | Default | Meaning |
|
|
606
|
+
| --- | --- | --- |
|
|
607
|
+
| `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. |
|
|
608
|
+
| `enabledProviders` | `"auto"` | Auto-detect providers, or set an explicit provider list. |
|
|
609
|
+
| `minIntervalMs` | `300000` | Minimum fetch interval between provider updates. |
|
|
610
|
+
| `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. |
|
|
611
|
+
| `onlyCurrentModel` | `false` | Filter quota rows to the current model/provider when that session selection can be resolved. |
|
|
612
|
+
| `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. |
|
|
613
|
+
| `pricingSnapshot.source` | `"auto"` | Token pricing snapshot selection for `/tokens_*`: `auto`, `bundled`, or `runtime`. |
|
|
614
|
+
| `pricingSnapshot.autoRefresh` | `7` | Refresh stale local pricing data after this many days. |
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
### Toast settings
|
|
618
|
+
|
|
619
|
+
| Option | Default | Meaning |
|
|
620
|
+
| --- | --- | --- |
|
|
621
|
+
| `enableToast` | `true` | Show popup toasts. Disabling this does not disable `/quota` or the TUI sidebar. |
|
|
622
|
+
| `toastDurationMs` | `9000` | Toast duration in milliseconds. |
|
|
623
|
+
| `showOnIdle` | `true` | Show a toast on the idle trigger. |
|
|
624
|
+
| `showOnQuestion` | `true` | Show a toast after a question/assistant response. |
|
|
625
|
+
| `showOnCompact` | `true` | Show a toast after session compaction. |
|
|
626
|
+
| `showOnBothFail` | `true` | Show a fallback toast when providers attempted quota reads and all failed. |
|
|
627
|
+
| `layout.maxWidth` | `50` | Toast formatting width target. Ignored by the TUI sidebar. |
|
|
628
|
+
| `layout.narrowAt` | `42` | Toast compact-layout breakpoint. Ignored by the TUI sidebar. |
|
|
629
|
+
| `layout.tinyAt` | `32` | Toast tiny-layout breakpoint. Ignored by the TUI sidebar. |
|
|
630
|
+
| `debug` | `false` | Append toast debug context when troubleshooting. |
|
|
631
|
+
|
|
632
|
+
### TUI sidebar setup
|
|
633
|
+
|
|
634
|
+
If you want the `Quota` sidebar panel, you need **two files**:
|
|
635
|
+
|
|
636
|
+
1. **`tui.json` or `tui.jsonc`**: add the plugin entry so OpenCode mounts the sidebar panel.
|
|
637
|
+
2. **`opencode.json` or `opencode.jsonc`**: put all quota settings under `experimental.quotaToast`.
|
|
638
|
+
|
|
639
|
+
**Important:** `experimental.quotaToast.*` settings do **not** go in `tui.json`. `tui.json` is only for loading the TUI plugin.
|
|
640
|
+
|
|
641
|
+
| File | What goes there | Needed for sidebar? |
|
|
642
|
+
| --- | --- | --- |
|
|
643
|
+
| `tui.json` / `tui.jsonc` | `plugin: ["@slkiser/opencode-quota"]` | Yes |
|
|
644
|
+
| `opencode.json` / `opencode.jsonc` | All `experimental.quotaToast.*` settings | Yes |
|
|
527
645
|
|
|
528
|
-
|
|
646
|
+
### Provider-specific settings
|
|
529
647
|
|
|
530
648
|
| Option | Default | Meaning |
|
|
531
649
|
| --- | --- | --- |
|
|
532
|
-
| `
|
|
533
|
-
| `
|
|
534
|
-
| `
|
|
535
|
-
| `
|
|
536
|
-
| `
|
|
537
|
-
| `
|
|
538
|
-
| `toastDurationMs` | `9000` | Toast duration in milliseconds |
|
|
539
|
-
| `showOnIdle` | `true` | Show toast on idle trigger |
|
|
540
|
-
| `showOnQuestion` | `true` | Show toast after a question/assistant response |
|
|
541
|
-
| `showOnCompact` | `true` | Show toast after session compaction |
|
|
542
|
-
| `showOnBothFail` | `true` | Show a fallback toast when providers attempt and all fail |
|
|
543
|
-
| `onlyCurrentModel` | `false` | Filter to the current model when possible |
|
|
544
|
-
| `showSessionTokens` | `true` | Append current-session token totals to toast output |
|
|
545
|
-
| `layout.maxWidth` | `50` | Main formatting width target |
|
|
546
|
-
| `layout.narrowAt` | `42` | Compact layout breakpoint |
|
|
547
|
-
| `layout.tinyAt` | `32` | Tiny layout breakpoint |
|
|
548
|
-
| `googleModels` | `["CLAUDE"]` | Google model keys: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE` |
|
|
549
|
-
| `alibabaCodingPlanTier` | `"lite"` | Fallback Alibaba Coding Plan tier when auth does not include `tier` |
|
|
550
|
-
| `cursorPlan` | `"none"` | Cursor included API budget preset: `none`, `pro`, `pro-plus`, `ultra` |
|
|
551
|
-
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD |
|
|
552
|
-
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month |
|
|
553
|
-
| `pricingSnapshot.source` | `"auto"` | Token pricing snapshot selection: `auto`, `bundled`, or `runtime` |
|
|
554
|
-
| `pricingSnapshot.autoRefresh` | `5` | Refresh stale local pricing data after this many days |
|
|
555
|
-
| `debug` | `false` | Include debug context in toast output |
|
|
650
|
+
| `anthropicBinaryPath` | `"claude"` | Command/path used for local Claude CLI probing; override this for custom installs or shim locations. |
|
|
651
|
+
| `googleModels` | `["CLAUDE"]` | Google model keys to query: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE`. |
|
|
652
|
+
| `alibabaCodingPlanTier` | `"lite"` | Fallback Alibaba Coding Plan tier when auth does not include `tier`. |
|
|
653
|
+
| `cursorPlan` | `"none"` | Cursor included API budget preset: `none`, `pro`, `pro-plus`, `ultra`. |
|
|
654
|
+
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD. |
|
|
655
|
+
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month. |
|
|
556
656
|
|
|
557
657
|
## Token Pricing Snapshot
|
|
558
658
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare function cliShouldRunMain(argv1?: string | undefined, modulePath?: string, resolvePath?: (filePath: string) => string): boolean;
|
|
3
|
+
export declare function main(argv?: string[]): Promise<number>;
|
|
4
|
+
//# sourceMappingURL=opencode-quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AA6BA,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,CAmBxE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { runInitInstaller } from "../lib/init-installer.js";
|
|
6
|
+
const USAGE = [
|
|
7
|
+
"Usage:",
|
|
8
|
+
" npx @slkiser/opencode-quota init",
|
|
9
|
+
" npx @slkiser/opencode-quota --help",
|
|
10
|
+
"",
|
|
11
|
+
"Commands:",
|
|
12
|
+
" init Run the interactive quota installer",
|
|
13
|
+
].join("\n");
|
|
14
|
+
function printUsage() {
|
|
15
|
+
console.log(USAGE);
|
|
16
|
+
}
|
|
17
|
+
function resolveCliPath(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
return realpathSync.native(filePath);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return resolve(filePath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function cliShouldRunMain(argv1 = process.argv[1], modulePath = fileURLToPath(import.meta.url), resolvePath = resolveCliPath) {
|
|
26
|
+
if (!argv1) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return resolvePath(modulePath) === resolvePath(argv1);
|
|
30
|
+
}
|
|
31
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
32
|
+
const [command, ...rest] = argv;
|
|
33
|
+
if (!command) {
|
|
34
|
+
printUsage();
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
if (command === "--help" || command === "-h" || command === "help") {
|
|
38
|
+
printUsage();
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
if (command === "init" && rest.length === 0) {
|
|
42
|
+
return await runInitInstaller();
|
|
43
|
+
}
|
|
44
|
+
printUsage();
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
if (cliShouldRunMain()) {
|
|
48
|
+
void main().then((code) => {
|
|
49
|
+
process.exitCode = code;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# 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,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,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,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,QAA4B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAC3C,aAAqB,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EACnD,cAA4C,cAAc;IAE1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,WAAW,CAAC,UAAU,CAAC,KAAK,WAAW,CAAC,KAAK,CAAC,CAAC;AACxD,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,IAAI,gBAAgB,EAAE,EAAE,CAAC;IACvB,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":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC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|
* 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"}
|