oc-go-usage-display 1.1.0 → 2.1.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.
Files changed (42) hide show
  1. package/README.md +246 -93
  2. package/bin/lib.js +395 -37
  3. package/bin/oc-go-usage-display-init.js +42 -13
  4. package/bin/oc-go-usage-display-remove.js +22 -17
  5. package/bin/oc-go-usage-display-show.js +47 -39
  6. package/bin/oc-go-usage-display-status.js +31 -52
  7. package/bin/oc-go-usage-display-update.js +27 -14
  8. package/dist/helpers.d.ts +117 -0
  9. package/dist/helpers.d.ts.map +1 -0
  10. package/dist/helpers.js +582 -0
  11. package/dist/helpers.js.map +1 -0
  12. package/dist/index.d.ts +5 -13
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +249 -159
  15. package/dist/index.js.map +1 -1
  16. package/dist/plugins/oc-go-usage-display.kilo.ts +699 -0
  17. package/dist/plugins/oc-go-usage-display.kilo.tsx +1364 -0
  18. package/dist/plugins/oc-go-usage-display.ts +699 -0
  19. package/dist/plugins/oc-go-usage-display.tsx +1108 -0
  20. package/dist/shared.d.ts +87 -8
  21. package/dist/shared.d.ts.map +1 -1
  22. package/dist/shared.js +596 -31
  23. package/dist/shared.js.map +1 -1
  24. package/dist/tui-shared.d.ts +109 -0
  25. package/dist/tui-shared.d.ts.map +1 -0
  26. package/dist/tui-shared.js +408 -0
  27. package/dist/tui-shared.js.map +1 -0
  28. package/dist/tui.d.ts +0 -17
  29. package/dist/tui.d.ts.map +1 -1
  30. package/dist/tui.js +229 -282
  31. package/dist/tui.js.map +1 -1
  32. package/dist/tui.kilo.d.ts +8 -0
  33. package/dist/tui.kilo.d.ts.map +1 -0
  34. package/dist/tui.kilo.js +502 -0
  35. package/dist/tui.kilo.js.map +1 -0
  36. package/package.json +49 -15
  37. package/src/helpers.ts +749 -0
  38. package/src/index.ts +316 -175
  39. package/src/shared.ts +693 -32
  40. package/src/tui-shared.tsx +755 -0
  41. package/src/tui.kilo.tsx +817 -0
  42. package/src/tui.tsx +352 -366
package/README.md CHANGED
@@ -2,141 +2,294 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/oc-go-usage-display.svg)](https://www.npmjs.com/package/oc-go-usage-display)
4
4
 
5
- OpenCode Go subscription usage plugin (dual target):
5
+ OpenCode Go subscription usage for [opencode](https://opencode.ai) and Kilo:
6
6
 
7
- - **server** (`src/index.ts`): `go_usage` tool (manual query: `Go 5h … | 7d … | 30d …`).
8
- - **tui** (`src/tui.tsx`): `Go Usage` sidebar block (muted `5h`/`7d`/`30d` rows) + `session_prompt_right` statusline.
7
+ | Target | Bundled entry | Surface |
8
+ | ------ | ------------- | ------- |
9
+ | server | `dist/plugins/oc-go-usage-display.ts` | `go_usage` tool (`Go 5h 42% (reset 3h12m) \| 7d 15% \| 30d 61%`) |
10
+ | tui | `dist/plugins/oc-go-usage-display.tsx` | `Go Usage` sidebar + `session_prompt_right` statusline (opencode) |
11
+ | server (kilo) | `dist/plugins/oc-go-usage-display.kilo.ts` | `go_usage` tool for Kilo; reads Kilo's own auth store |
12
+ | tui (kilo) | `dist/plugins/oc-go-usage-display.kilo.tsx` | same TUI surfaces for Kilo |
9
13
 
10
- ![Go Usage sidebar and statusline showing 5h, 7d, and 30d subscription usage](docs/screenshot.png)
14
+ `shared.ts` is inlined at build time. Requires Node >= 22 and opencode >= 1.18.
15
+ All four bundles ship in the one npm package and one version; the build fails if
16
+ either host's bundle is missing.
17
+
18
+ ![Go Usage sidebar and statusline](docs/screenshot.png)
11
19
 
12
20
  ## Install (npm)
13
21
 
14
- ```sh
15
- npm install oc-go-usage-display
16
- npx oc-go-usage-display-init
17
- ```
22
+ | Mode | Command |
23
+ | ---- | ------- |
24
+ | Persistent (recommended) | `npm install oc-go-usage-display@latest && npx oc-go-usage-display-init --copy` |
25
+ | One-shot (npx) | `npx -p oc-go-usage-display@latest oc-go-usage-display-init --copy` |
26
+ | Project scope | `npx -p oc-go-usage-display@latest oc-go-usage-display-init --copy --config-dir .opencode` |
18
27
 
19
- Or one-shot without installing:
28
+ `--copy` is the default and self-contained; `--symlink` is dev-only (rebuild +
29
+ restart). Restart opencode afterwards. `@latest` tracks the newest release; for
30
+ reproducible installs pin an exact version such as
31
+ `oc-go-usage-display@2.0.1`.
20
32
 
21
- ```sh
22
- npx -y oc-go-usage-display@latest oc-go-usage-display-init
33
+ Alternative — no files copied: declare the versioned package and let opencode
34
+ resolve it at startup:
35
+
36
+ ```jsonc
37
+ // opencode.jsonc — server target (go_usage tool)
38
+ { "plugin": ["oc-go-usage-display@latest"] }
39
+ // tui.json — TUI target (sidebar + statusline)
40
+ { "plugin": [["oc-go-usage-display@latest", { "sidebar": true, "statusline": true }]] }
23
41
  ```
24
42
 
25
- This links `src/*` into `~/.config/opencode/plugins/*` and registers the
26
- `opencode.jsonc` + `tui.json` entries. Restart opencode afterwards.
27
- No secrets are touched. Requires Node >= 22.
43
+ From a checkout: `./install.sh` (copy install; add `--target kilo` for Kilo),
44
+ `./install.sh --symlink` (dev-only), `./install-dev.sh` (latest `develop`
45
+ dev-tgz + config snapshot; there is no auto-restore — it prints the restore
46
+ command).
28
47
 
29
- ## Installation scope
48
+ ### Kilo
30
49
 
31
- | Scope | Command | Writes to | Notes |
32
- | ----- | ------- | --------- | ----- |
33
- | Global | `npx oc-go-usage-display-init` (or `bunx oc-go-usage-display-init`) | `~/.config/opencode/plugins/*` + `opencode.jsonc` + `tui.json` | Restart opencode afterwards |
34
- | Project | `npx oc-go-usage-display-init --scope project` (or manual: `.opencode/plugins/*` + `opencode.json`/`tui.json` in repo) | Repo-local `.opencode/` + `opencode.json`/`tui.json` | Restart opencode afterwards |
35
- | Bun | `bunx oc-go-usage-display-init` + `bunx oc-go-usage-display-show` | Same as global (`~/.config/opencode/…`) | `show` prints effective config (secrets redacted) |
50
+ Kilo is a separate target: `npx oc-go-usage-display-init --target kilo` copies
51
+ `oc-go-usage-display.kilo.{ts,tsx}` into `$KILO_CONFIG_DIR` /
52
+ `$XDG_CONFIG_HOME/kilo` / `~/.config/kilo` and registers `kilo.json` +
53
+ `tui.json`. Kilo's `tui.json` rejects `sidebar`/`statusline`, so its entry is a
54
+ plain plugin spec (both surfaces default on), and Kilo does not resolve
55
+ `./...` against its config dir, so the entries are absolute paths to the
56
+ installed copies. Without `--target`, hosts are detected by binary on PATH or
57
+ config dir, so brew/npm/curl/source installs all count: one detected host
58
+ installs silently, two or more offer a numbered multiselect, and nothing
59
+ detected installs both.
36
60
 
37
- Project-scope manual fallback: copy `src/index.ts` → `.opencode/plugins/oc-go-usage-display.ts`
38
- and `src/tui.tsx` → `.opencode/plugins/oc-go-usage-display.tsx`, then register the
39
- `opencode.json` (server) + `tui.json` (TUI) entries from the manual section below.
61
+ ## Commands
40
62
 
41
- ## Install (manual plugin entries)
63
+ After `npm install` the names below are on PATH; from a checkout use
64
+ `node ./bin/<bin>.js`.
42
65
 
43
- If you prefer to wire the plugin by hand (e.g. npm / OpenDock managed
44
- plugins), add the package to your config and restart opencode:
66
+ | Command | What it does |
67
+ | ------- | ------------ |
68
+ | `oc-go-usage-display-init` | install + register; `--target opencode\|kilo\|all` (default: detected hosts, else all) |
69
+ | `oc-go-usage-display-remove` | uninstall files + config entries (secrets untouched) |
70
+ | `oc-go-usage-display-show` | print effective install per host; `--json` for machine output |
71
+ | `oc-go-usage-display-status` | health check; exit 0 healthy, 1 with reasons |
72
+ | `oc-go-usage-display-update` | re-install + `git pull --ff-only` when a remote exists |
45
73
 
46
- ```jsonc
47
- // opencode.jsonc — server target (go_usage tool)
48
- {
49
- "plugin": ["oc-go-usage-display"]
50
- }
51
- ```
74
+ Flags: `--config-dir <path>` (opencode; default `$OPENCODE_CONFIG_DIR` or
75
+ `~/.config/opencode`), `--kilo-config-dir <path>` (default `$KILO_CONFIG_DIR`
76
+ or `~/.config/kilo`), `--target`, `--repo <path>`, `--copy`/`--symlink`,
77
+ `--sidebar=0/1`, `--statusline=0/1` (opencode only), `--json` (show).
52
78
 
53
- ```jsonc
54
- // tui.json — TUI target (Go Usage sidebar + statusline)
55
- {
56
- "plugin": [["oc-go-usage-display", { "sidebar": true, "statusline": true }]]
57
- }
58
- ```
79
+ ## Display toggles
59
80
 
60
- The `oc-plugin: ["server", "tui"]` manifest auto-discovers both targets
61
- from the published package (`dist/`). Set `OPENCODE_GO_API_KEY` (Bearer for
62
- `GET https://opencode.ai/zen/go/v1/usage`) or sign in via the `opencode-go`
63
- provider so `auth.json` supplies the key.
81
+ Three axes, all defaulting to on/integrated. Each is a command in the palette,
82
+ persisted per surface, and it applies to whichever sidebar mode is active:
64
83
 
65
- ## Install (local repo, easy update)
84
+ | Axis | Command | Also settable as |
85
+ | ---- | ------- | ---------------- |
86
+ | sidebar on/off | `Go usage: toggle sidebar` | `sidebar` option, `OPENCODE_OC_GO_SIDEBAR` / `KILO_OC_GO_SIDEBAR` |
87
+ | statusline on/off | `Go usage: toggle statusline` | `statusline` option, `OPENCODE_OC_GO_STATUSLINE` / `KILO_OC_GO_STATUSLINE` |
88
+ | display mode (Kilo) | `Go usage: toggle sidebar mode` | `sidebar_mode` option, `KILO_OC_GO_SIDEBAR_MODE` |
66
89
 
67
- ```sh
68
- ./install.sh
90
+ ```json
91
+ { "plugin": ["./plugins/oc-go-usage-display.tsx", { "sidebar": true, "statusline": true }] }
69
92
  ```
70
93
 
71
- This symlinks `src/*` into `~/.config/opencode/plugins/*` and registers the
72
- `opencode.jsonc` + `tui.json` entries. Edits in this repo apply after an
73
- opencode restart. No secrets are touched.
94
+ Hiding the sidebar hides it in either mode; the mode decides *what* it draws, not
95
+ whether it is there. Environment variables and the legacy `display` option apply
96
+ only when the `tui.json` toggles are absent. Restart the host after changing
97
+ static config. Kilo's `tui.json` rejects the `sidebar`/`statusline` options, so
98
+ on that host the palette and the env vars are the way to set them.
74
99
 
75
- ## Commands
100
+ ## What the sidebar shows
76
101
 
77
- ```sh
78
- node ./bin/oc-go-usage-display-init.js # (re-)install
79
- node ./bin/oc-go-usage-display-show.js # show effective config (secrets redacted)
80
- node ./bin/oc-go-usage-display-status.js # health check (exit 0/1)
81
- node ./bin/oc-go-usage-display-update.js # re-link (+ git pull when a remote exists)
82
- node ./bin/oc-go-usage-display-remove.js # uninstall (files + config entries; secrets untouched)
83
- ```
102
+ One shared implementation renders the block on both hosts; only the sidebar's
103
+ width differs (~30 cells on opencode, ~40 on Kilo), and that is what decides the
104
+ layout. Both screenshots below are real captures of the pinned hosts, taken by
105
+ `scripts/capture-shots.mjs` (mocked usage, no subscription touched).
84
106
 
85
- After installing the package, the commands are also available as
86
- `oc-go-usage-display-init|show|status|update|remove`.
107
+ | opencode | Kilo (integrated) |
108
+ | -------- | ----------------- |
109
+ | ![opencode sidebar](docs/sidebar-opencode.png) | ![Kilo sidebar](docs/sidebar-kilo.png) |
87
110
 
88
- ## Uninstall
111
+ **opencode** — the plan as meters, with the next reset on its own line, and a
112
+ model section that starts collapsed:
89
113
 
90
- ```sh
91
- npx oc-go-usage-display-remove
92
- npm uninstall oc-go-usage-display
114
+ ```
115
+ Go Usage
116
+ 5h resets in 2h5m
117
+ 5h ████░░░░░░ 42%
118
+ 7d ██░░░░░░░░ 15%
119
+ 30d ██████░░░░ 61%
120
+
121
+ ▶ Top Go models (7)
122
+ mimo 59%·qwen 25%
93
123
  ```
94
124
 
95
- Or from a checkout: `node ./bin/oc-go-usage-display-remove.js`.
96
- This removes the plugin files plus the `opencode.jsonc` (server) and
97
- `tui.json` (TUI) entries (`--config-dir` / `OPENCODE_CONFIG_DIR` supported).
98
- Secrets are never touched: env vars, `auth.json`, and
99
- `oc-go-usage-display.json` stay in place — delete them by hand if desired.
100
- Restart opencode afterwards.
125
+ Fold the section open (the header is a disclosure control, like the host's own
126
+ `MCP` / `Models` sections) for one row per model:
101
127
 
102
- Manual file list (global scope):
128
+ ```
129
+ ▾ Top Go models (7)
130
+ mimo-v2.6-p █████░ 59%
131
+ qwen3-max ███░░░░░ 25%
132
+ gpt-5.1 █░░░░░░ 12%
133
+ 2.31M of 2.4M Go tokens
134
+ 161 steps · $1.51
135
+ ```
103
136
 
104
- - `~/.config/opencode/plugins/oc-go-usage-display.ts`
105
- - `~/.config/opencode/plugins/oc-go-usage-display.tsx`
106
- - server entry (`./plugins/oc-go-usage-display.ts`) in `~/.config/opencode/opencode.jsonc`
107
- - TUI entry (`./plugins/oc-go-usage-display.tsx`) in `~/.config/opencode/tui.json`
137
+ A model's **weight** is its share of the Go tokens spent in this session, taken
138
+ from the host's own message store over the rendered session — the same scope as
139
+ opencode's `Context` panel next to it. It is a share of tokens: never a share of
140
+ the plan, a quota, or a price, because the plan's absolute limits are not
141
+ client-visible. Bars use the plan's threshold coloring (muted < 75% ≤ warning <
142
+ 90% ≤ error), and a capped window is always the error color however low its
143
+ percent reads.
108
144
 
109
- ## Display toggles
145
+ Both hosts draw the plan the same way: the next reset on one line, then three
146
+ stacked meters whose bars share a left edge and whose percents share a right
147
+ edge.
110
148
 
111
- Both surfaces default on and are independent:
149
+ **Kilo** — `sidebar_mode` picks what the block is:
112
150
 
113
- ```json
114
- ["./plugins/oc-go-usage-display.tsx", { "sidebar": true, "statusline": true }]
151
+ - **integrated** (default): the block takes over the host's own `Token Usage`
152
+ band, retires that panel, and renders `Session Tokens` / `Models`. The plan is
153
+ drawn **once**, as the `Go Plan` meters inside the `OpenCode Go` group, and
154
+ every Go model row carries its `Go share`. There is deliberately no separate
155
+ `Go Usage` block saying the same three numbers again.
156
+ - **standalone**: our block in a free band above the host's panel, and the host
157
+ panel stays.
158
+
159
+ ## Auth and config
160
+
161
+ First match wins (secrets are never logged); each host reads only its own
162
+ credential store:
163
+
164
+ | # | Source | Behavior |
165
+ | - | ------ | -------- |
166
+ | 1 | `OPENCODE_OC_GO_MOCK=1` | deterministic mock snapshot (never cached) |
167
+ | 2 | `OPENCODE_OC_GO_API_KEY` | `GET https://opencode.ai/zen/go/v1/usage` with `Authorization: Bearer <key>` |
168
+ | 3 | provider `auth.json` | same Bearer path; `opencode-go` key, else `opencode`. opencode: `$XDG_DATA_HOME/opencode/auth.json` (`~/.local/share/opencode/auth.json`), then `~/.config/opencode/auth.json`. Kilo: the same files under `kilo` (`$KILO_CONFIG_DIR` / `$XDG_CONFIG_HOME/kilo`) |
169
+ | 4 | workspace + cookie | scrape `GET https://opencode.ai/workspace/{workspaceId}/go` with the `auth` cookie; file config from the host's config dir |
170
+ | 5 | none | unavailable snapshot (`not configured (set OPENCODE_OC_GO_API_KEY)`) |
171
+
172
+ File config (`oc-go-usage-display.json` in the host's config dir, e.g.
173
+ `~/.config/opencode` or `~/.config/kilo`):
174
+
175
+ ```jsonc
176
+ { "workspaceId": "...", "authCookie": "..." }
115
177
  ```
116
178
 
117
- ![Toggle via commands](docs/commands.png)
179
+ Successful snapshots cache 60s (memory + `oc-go-usage-display-cache.json` in
180
+ the host's config dir); failures are never cached. ### Environment variables
118
181
 
119
- Sidebar/statusline toggles are also accessible via opencode commands (ctrl+p) as
120
- `Go usage: toggle sidebar` / `Go usage: toggle statusline`
121
- (`opencode-go-usage-display.toggle-sidebar` / `opencode-go-usage-display.toggle-statusline`),
122
- in addition to the `tui.json` `sidebar` / `statusline` booleans.
182
+ Every variable this plugin reads is **scoped to the coding agent that reads it**,
183
+ so one shell can drive the two hosts independently:
123
184
 
124
- `OPENCODE_GO_SIDEBAR` / `OPENCODE_GO_STATUSLINE` env vars override when the
125
- toggles are absent. Restart opencode after changing them.
185
+ | Suffix | opencode | Kilo |
186
+ | ------ | -------- | ---- |
187
+ | `API_KEY` | `OPENCODE_OC_GO_API_KEY` | `KILO_OC_GO_API_KEY` |
188
+ | `WORKSPACE_ID` | `OPENCODE_OC_GO_WORKSPACE_ID` | `KILO_OC_GO_WORKSPACE_ID` |
189
+ | `AUTH_COOKIE` | `OPENCODE_OC_GO_AUTH_COOKIE` | `KILO_OC_GO_AUTH_COOKIE` |
190
+ | `MOCK` | `OPENCODE_OC_GO_MOCK` | `KILO_OC_GO_MOCK` |
191
+ | `SIDEBAR` | `OPENCODE_OC_GO_SIDEBAR` | `KILO_OC_GO_SIDEBAR` |
192
+ | `STATUSLINE` | `OPENCODE_OC_GO_STATUSLINE` | `KILO_OC_GO_STATUSLINE` |
193
+ | `DISPLAY` (legacy) | `OPENCODE_OC_GO_DISPLAY` | `KILO_OC_GO_DISPLAY` |
194
+ | `SIDEBAR_MODE` | `OPENCODE_OC_GO_SIDEBAR_MODE` | `KILO_OC_GO_SIDEBAR_MODE` |
126
195
 
127
- ## Build
196
+ A Kilo build only reads `KILO_OC_GO_*`, so an `OPENCODE_OC_GO_*` name can never
197
+ steer it — the two hosts keep separate auth stores and config dirs for the same
198
+ reason.
128
199
 
129
200
  ```sh
130
- npm install
131
- npm run build # tsc -> dist/
132
- npm run check # typecheck only
201
+ # a different surface selection per host, from one shell
202
+ OPENCODE_OC_GO_SIDEBAR=1 KILO_OC_GO_SIDEBAR=0 opencode
133
203
  ```
134
204
 
205
+ The pre-2.0 unscoped `OPENCODE_GO_*` spelling is **no longer read**. It was
206
+ removed rather than deprecated: a fallback would keep one shared variable steering
207
+ both hosts after the split, which is the exact ambiguity the prefixes exist to
208
+ remove. If you configured credentials through it, move them to the host-scoped
209
+ name you actually run.
210
+
211
+ `OPENCODE_CONFIG_DIR` / `KILO_CONFIG_DIR` are read by the install CLIs, not by
212
+ the plugin entry modules.
213
+
214
+ ## Development
215
+
216
+ ```sh
217
+ bun install
218
+ bun run build # tsc -> dist/ + esbuild -> dist/plugins/* (both hosts)
219
+ bun run check # typecheck only
220
+ ```
221
+
222
+ `bun run build` fails unless all four bundles exist, are self-contained and
223
+ export only the default module (`scripts/verify-bundles.mjs`); packed tarballs
224
+ can be checked with `node scripts/verify-tarball.mjs <file.tgz>`.
225
+
226
+ To refresh the README screenshots (boots both hosts in tmux, writes the panes
227
+ with their colors intact to `tmp/`):
228
+
229
+ ```sh
230
+ docker compose run --rm -v "$PWD":/workspaces/oc-go-usage-display -v "$PWD/tmp:/out" \
231
+ test bun scripts/capture-shots.mjs
232
+ ```
233
+
234
+ | Test command | Tier |
235
+ | ------------ | ---- |
236
+ | `bun run test` | build + READONLY unit tier (host/CI) |
237
+ | `bun run test:unit` | helper tests + the live usage **shape** check — the one place an API key is used (a single GET; skips without `OPENCODE_OC_GO_API_KEY`) |
238
+ | `bun run test:docker` | authoritative gate: integration + e2e, incl. the real opencode/kilo TUI display checks and the per-model mix rendered against a local fake provider |
239
+ | `bun run test:integration` / `bun run test:e2e` | container-only tiers |
240
+
241
+ Unit tests are readonly by construction (`scripts/check-unit-purity.mjs` rejects
242
+ fs writes, tmp usage, child processes and sockets). Integration and e2e run only
243
+ inside the container image; host-runnable tests redirect HOME/XDG and force
244
+ `OPENCODE_OC_GO_MOCK=1`, so they never touch the real `~/.config/opencode`.
245
+
246
+ **The API key buys one thing:** a shape check that the live usage payload is
247
+ still what we parse. Every TUI display test runs on the mock instead, because it
248
+ asserts layout, which does not need live numbers — so the container gate is
249
+ hermetic and needs no secret at all.
250
+
251
+ ## CI
252
+
253
+ | Workflow | Trigger | Jobs |
254
+ | -------- | ------- | ---- |
255
+ | `test.yml` | push, PR, weekly (Mon 06:00 UTC) | `unit` always; `container-e2e` (Docker gate) only on `main` pushes, the schedule, and non-draft PRs |
256
+ | `bump-deps.yml` | weekly (Mon 12:30 UTC), manual | `bun update` within the declared ranges, the Dockerfile host pins moved with the SDKs, the Docker gate on the bumped tree, then the commit — nothing is committed unless the gate is green |
257
+ | `dev-build.yml` | push to `develop` | `dev-tgz` artifact (90 days), used by `install-dev.sh` |
258
+ | `publish.yml` | push to `main` | gate -> release-please Release PR -> OIDC provenance publish; the release carries the tarball, all four plugin bundles and `SHA256SUMS`, and the registry tarball is re-verified after publish |
259
+
260
+ Releases are cut by [release-please](https://github.com/googleapis/release-please):
261
+ merging `develop` into `main` opens/updates a `chore(main): release X.Y.Z` PR
262
+ (`feat` -> minor, `fix` -> patch, breaking change -> major; `chore`/`docs`/`ci`/
263
+ `test`/`refactor`/`style`/`build`/`perf` never cut a release on their own).
264
+ Merging that PR tags `vX.Y.Z`, creates the GitHub release, and publishes to npm
265
+ after the containerized gate. To force a version, add a `Release-As: X.Y.Z`
266
+ footer to a commit merged to `main`.
267
+
135
268
  ## Troubleshooting
136
269
 
137
- ### Pre-rename files removed in 1.0.x
270
+ - **Plugin didn't load**: check `npx oc-go-usage-display-show` / `status`, then
271
+ restart the host (`opencode debug config` shows the resolved plugin list;
272
+ `opencode --pure` skips plugins, so it is not a valid check).
273
+ - **No API key or subscription**: surfaces show `Go n/a (…)`; set
274
+ `OPENCODE_OC_GO_API_KEY` or `KILO_OC_GO_API_KEY` for the host you are
275
+ running, sign in through the
276
+ `opencode-go` provider in the host you are running, or configure workspace +
277
+ cookie. Each host reads only its own `auth.json`, so a Kilo login does not
278
+ feed the opencode plugin and vice versa.
279
+ - **Kilo only**: `npx oc-go-usage-display-init --target kilo`; Kilo ignores
280
+ `sidebar`/`statusline` options, so toggle surfaces with the command palette
281
+ instead.
282
+ - **Stale copy install**: copy installs never auto-update; re-run
283
+ `npx oc-go-usage-display-init --copy` and restart.
284
+
285
+ ## Uninstall
138
286
 
139
- Pre-rename `opencode-go-usage.*` shims were removed in 1.0.x. The installer and
140
- plugin now use only `oc-go-usage-display.*` plugin files, config entries, and
141
- the `oc-go-usage-display.json` file config. Delete any leftover
142
- `opencode-go-usage.*` files by hand if they remain from an older install.
287
+ ```sh
288
+ npx oc-go-usage-display-remove
289
+ npm uninstall oc-go-usage-display
290
+ ```
291
+
292
+ Removes the plugin files and the server + `tui.json` entries from every
293
+ installed host (`--target` or `--config-dir`/`--kilo-config-dir` narrows it).
294
+ Secrets are never touched: env vars, `auth.json`, and
295
+ `oc-go-usage-display.json` stay in place.