@1930dev/opencode-usage 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +48 -30
  2. package/package.json +7 -3
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # opencode-usage
2
2
 
3
- Usage tracking, cost estimation, and model ranking CLI for [opencode](https://opencode.ai).
3
+ Usage tracking, budget percentages and model ranking for [opencode](https://opencode.ai):
4
+ a CLI, and a `/usage` slash command for the TUI.
4
5
 
5
6
  ## Install
6
7
 
@@ -15,14 +16,22 @@ Requires [Bun](https://bun.sh): the CLI reads opencode's SQLite through `bun:sql
15
16
  ```bash
16
17
  # Local usage from opencode's SQLite (all providers, all projects)
17
18
  opencode-usage usage # last 7 days, grouped by provider
19
+
20
+ # Window
18
21
  opencode-usage usage --today # today only
19
22
  opencode-usage usage --since 30d # last 30 days
20
- opencode-usage usage --by model # group by model instead of provider
21
- opencode-usage usage --by project # group by project directory
22
- opencode-usage usage --by agent # group by agent (build/plan/etc)
23
- opencode-usage usage --pct # add % BUDGET column (requires --by provider)
24
- # --by provider lists every connected provider, including those idle in the window
25
- opencode-usage usage --json # machine-readable output
23
+
24
+ # Grouping
25
+ opencode-usage usage --by agent # by agent (build/plan/etc)
26
+ opencode-usage usage --by day # by day
27
+ opencode-usage usage --by model # by model
28
+ opencode-usage usage --by project # by project directory
29
+ opencode-usage usage --by provider # the default; lists every connected
30
+ # provider, idle ones included
31
+
32
+ # Output
33
+ opencode-usage usage --json # machine-readable
34
+ opencode-usage usage --pct # add the % BUDGET column (--by provider only)
26
35
 
27
36
  # Connected providers + live quota
28
37
  opencode-usage providers
@@ -74,19 +83,20 @@ Restart opencode after a rebuild: the bundle is read once at start.
74
83
  Normalized percentage of budget consumed per provider, from these sources (in priority):
75
84
 
76
85
  1. **Live quota** — provider-reported usage:
77
- - `opencode-go` (Zen): rolling 5h / weekly / monthly % (binding window)
78
86
  - `github-copilot`: premium requests entitlement (7000/mo)
87
+ - `opencode-go` (Zen): rolling 5h / weekly / monthly % (binding window)
79
88
  - `openrouter`: credits used / total credits
80
89
  - `zai`: coding plan quota
81
90
 
82
- 2. **Documented limits** — monthly equivalent of daily limits:
83
- - `groq`: 200k tokens/day 6M/month
84
- - `google`: 1500 requests/day 45k/month
85
- - `digitalocean`: 5M tokens/day → 150M/month
86
- - `cerebras`: 1M tokens/day 30M/month
87
- - `google` (Gemini free): 1500 requests/day 45k/month
88
- - `groq`: 200k tokens/day 6M/month
89
- - `cerebras`: 1M tokens/day → 30M/month
91
+ 2. **Documented limits** — published quotas, used when the provider reports none:
92
+ - `cerebras`: 1M tokens/day (free tier)
93
+ - `cloudflare-workers-ai`: 100k neurons/day (free tier)
94
+ - `digitalocean`: 5M tokens/day (paid)
95
+ - `google`: 1500 requests/day (free tier)
96
+ - `groq`: 200k tokens/day (free tier)
97
+ - `nvidia`: 1000 credits/month (free tier)
98
+ - `orcarouter`: undocumented
99
+ - `snowflake-cortex`: 100 credits/month (paid)
90
100
 
91
101
  3. **budgets.json** — your monthly USD per provider:
92
102
  ```json
@@ -118,32 +128,40 @@ table and carried in `--json`.
118
128
 
119
129
  ## Requirements
120
130
 
121
- - [Bun](https://bun.sh) 1.0
122
- - [opencode](https://opencode.ai) with existing sessions (reads `~/.local/share/opencode/opencode.db`)
123
- - For live quota: credentials already configured in opencode (`~/.local/share/opencode/auth.json`)
131
+ - [Bun](https://bun.sh) >= 1.0 — the CLI reads opencode's SQLite through `bun:sqlite`
132
+ - [opencode](https://opencode.ai) with existing sessions, at
133
+ `~/.local/share/opencode/opencode.db`
134
+ - For live quota: provider credentials already configured in opencode, at
135
+ `~/.local/share/opencode/auth.json`
124
136
 
125
137
  ## Configuration
126
138
 
127
- - `OPENCODE_DB_PATH` — override opencode database path
128
- - `OPENCODE_AUTH_PATH` — override auth.json path
129
- - `OPENCODE_IMP_CACHE` — cache directory (default `~/.cache/opencode-usage`)
130
- - `OPENCODE_IMP_BUDGETS` — budgets.json path
131
139
  - `AA_API_KEY` — Artificial Analysis key, used by `top` for the intelligence indices.
132
140
  Optional: without it `top` still prints prices, only without `IQ` and `IQ/$`.
133
141
  A free key is at [artificialanalysis.ai/data-api](https://artificialanalysis.ai/data-api)
142
+ - `OPENCODE_AUTH_PATH` — override the path to opencode's `auth.json`
143
+ - `OPENCODE_DB_PATH` — override the path to opencode's database
144
+ - `OPENCODE_USAGE_BUDGETS` — override the path to `budgets.json`
145
+ - `OPENCODE_USAGE_CACHE` — cache directory (default `~/.cache/opencode-usage`)
134
146
 
135
147
  ## Development
136
148
 
137
149
  ```bash
138
- bun install # install workspace deps
139
- bun test # run tests
140
- bunx tsc --noEmit # typecheck
150
+ bun install # install workspace deps
151
+ bun run build # write dist/tui.js and dist/cli.js
152
+ bun run preview # render the /usage dialog headless, at several widths
153
+ bun test # run tests
154
+ bunx tsc --noEmit # typecheck
141
155
  ```
142
156
 
143
- The workspace is a Bun monorepo with three packages:
144
- - `@opencode-usage/core` shared data layer (SQLite, quotas, matching)
145
- - `@opencode-usage/cli` — the `opencode-usage` CLI
146
- - `@opencode-usage/plugin` — TUI plugin for opencode itself
157
+ The workspace is a Bun monorepo. The packages are listed by dependency order,
158
+ since `cli` and `plugin` both build on `core`:
159
+
160
+ - `@opencode-usage/core` — shared data layer (SQLite, quotas, matching, ranking)
161
+ - `@opencode-usage/cli` — the `opencode-usage` binary
162
+ - `@opencode-usage/plugin` — the opencode TUI plugin
163
+
164
+ Only the root package is published; `core` is inlined into both bundles.
147
165
 
148
166
  ## License
149
167
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1930dev/opencode-usage",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Usage tracking, budget percentages and model ranking for opencode \u2014 CLI plus a /usage TUI plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/agurod42/opencode-usage.git"
18
+ "url": "git+https://github.com/1930-dev/opencode-usage.git"
19
19
  },
20
20
  "keywords": [
21
21
  "opencode",
@@ -54,5 +54,9 @@
54
54
  "@opencode-ai/plugin": ">=1.18",
55
55
  "@opentui/core": ">=0.5",
56
56
  "@opentui/solid": ">=0.5"
57
- }
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/1930-dev/opencode-usage/issues"
60
+ },
61
+ "homepage": "https://github.com/1930-dev/opencode-usage#readme"
58
62
  }