@slkiser/opencode-quota 2.2.1 → 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 CHANGED
@@ -12,7 +12,7 @@ Track OpenCode quota & tokens via Toasts/Commands with zero context window pollu
12
12
 
13
13
  ![Image of quota toasts](https://github.com/slkiser/opencode-quota/blob/main/toast.png)
14
14
 
15
- **Token Report Commands** - Track token usage and estimated costs across sessions using only local OpenCode SQLite history plus the bundled models.dev snapshot (no network calls).
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
  ![Image of /quota and /tokens_daily outputs](https://github.com/slkiser/opencode-quota/blob/main/quota.png)
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 all provider/model entries present in the bundled models.dev data snapshot.
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 |
@@ -233,6 +265,14 @@ All options go under `experimental.quotaToast` in `opencode.json` or `opencode.j
233
265
  | `googleModels` | `["CLAUDE"]` | Google models: `CLAUDE`, `G3PRO`, `G3FLASH`, `G3IMAGE` |
234
266
  | `debug` | `false` | Show debug info in toasts (and a debug-only toast when otherwise suppressed) |
235
267
 
268
+ ## Contributing
269
+
270
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full policy and workflow.
271
+
272
+ This project prefers an issue-first contribution model for features, bug fixes, refactors, and behavioral changes. Local pre-commit checks run formatting, typecheck, and tests; PR CI currently runs typecheck and build across Node versions.
273
+
274
+ Issue/PR templates are enforced in `.github/ISSUE_TEMPLATE/` and `.github/pull_request_template.md` for consistent titles and required validation details.
275
+
236
276
  ## Development
237
277
 
238
278
  ```sh