@slkiser/opencode-quota 2.3.0 → 2.4.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 +35 -3
- package/dist/data/modelsdev-pricing.min.json +462 -281
- package/dist/lib/modelsdev-pricing.d.ts +57 -3
- package/dist/lib/modelsdev-pricing.d.ts.map +1 -1
- package/dist/lib/modelsdev-pricing.js +510 -4
- package/dist/lib/modelsdev-pricing.js.map +1 -1
- package/dist/lib/quota-stats.d.ts.map +1 -1
- package/dist/lib/quota-stats.js +89 -26
- package/dist/lib/quota-stats.js.map +1 -1
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +22 -1
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +42 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Track OpenCode quota & tokens via Toasts/Commands with zero context window pollu
|
|
|
12
12
|
|
|
13
13
|

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

|
|
18
18
|
|
|
@@ -77,7 +77,39 @@ Token reporting commands are the `/tokens_*` family (there is no `/token` comman
|
|
|
77
77
|
| Google Antigravity | `google-antigravity` | Multi-account via `opencode-antigravity-auth` |
|
|
78
78
|
| Z.ai | `zai` | OpenCode auth (automatic) |
|
|
79
79
|
|
|
80
|
-
Token pricing coverage is broader than quota provider support: `/tokens_*` maps usage against
|
|
80
|
+
Token pricing coverage is broader than quota provider support: `/tokens_*` maps usage against provider/model entries in the active local models.dev pricing snapshot.
|
|
81
|
+
|
|
82
|
+
Pricing refresh ownership is now runtime-based:
|
|
83
|
+
|
|
84
|
+
- A bundled snapshot (`src/data/modelsdev-pricing.min.json`) is always shipped as bootstrap/offline fallback.
|
|
85
|
+
- At plugin runtime, when `experimental.quotaToast.enabled` is `true`, pricing refresh runs as a bounded best-effort check (once per process window, plus persisted attempt tracking) during init and before `/tokens_*` / `/quota_status` report paths.
|
|
86
|
+
- If the active snapshot is older than 3 days, the plugin attempts to fetch `https://models.dev/api.json`, keeps only `input`, `output`, `cache_read`, `cache_write`, and writes a refreshed local runtime snapshot.
|
|
87
|
+
- If fetch fails, reports continue using the last local snapshot (no hard failure).
|
|
88
|
+
|
|
89
|
+
Runtime snapshot files are stored under the OpenCode cache directory:
|
|
90
|
+
|
|
91
|
+
- `.../opencode/opencode-quota/modelsdev-pricing.runtime.min.json`
|
|
92
|
+
- `.../opencode/opencode-quota/modelsdev-pricing.refresh-state.json`
|
|
93
|
+
|
|
94
|
+
Runtime refresh toggles:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
# Disable runtime pricing refresh
|
|
98
|
+
OPENCODE_QUOTA_PRICING_AUTO_REFRESH=0
|
|
99
|
+
|
|
100
|
+
# Change stale threshold (default: 3 days)
|
|
101
|
+
OPENCODE_QUOTA_PRICING_MAX_AGE_DAYS=5
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Maintainer-only bundled snapshot refresh (manual):
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
npm run pricing:refresh
|
|
108
|
+
npm run pricing:refresh:if-stale
|
|
109
|
+
npm run build
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`pricing:refresh:if-stale` uses the same env knobs as runtime refresh (`OPENCODE_QUOTA_PRICING_AUTO_REFRESH`, `OPENCODE_QUOTA_PRICING_MAX_AGE_DAYS`).
|
|
81
113
|
|
|
82
114
|
### Provider-Specific Setup
|
|
83
115
|
|
|
@@ -215,7 +247,7 @@ All options go under `experimental.quotaToast` in `opencode.json` or `opencode.j
|
|
|
215
247
|
|
|
216
248
|
| Option | Default | Description |
|
|
217
249
|
| ------------------- | ------------ | ---------------------------------------------------------------------------------------------------- |
|
|
218
|
-
| `enabled` | `true` | Enable/disable plugin
|
|
250
|
+
| `enabled` | `true` | Enable/disable plugin. When `false`, `/quota`, `/quota_status`, and `/tokens_*` are strict no-ops. |
|
|
219
251
|
| `enableToast` | `true` | Show popup toasts |
|
|
220
252
|
| `toastStyle` | `classic` | Toast layout style: `classic` or `grouped` |
|
|
221
253
|
| `enabledProviders` | `"auto"` | Provider IDs to query, or `"auto"` to detect |
|