Skip to content

Add oc-go-usage-display plugin - #690

Open
christophkroeppl wants to merge 5 commits into
awesome-opencode:mainfrom
christophkroeppl:add-oc-go-usage-display
Open

christophkroeppl wants to merge 5 commits into
awesome-opencode:mainfrom
christophkroeppl:add-oc-go-usage-display

Conversation

@christophkroeppl

@christophkroeppl christophkroeppl commented Sep 9, 2026 •

Copy link
Copy Markdown

Adds oc-go-usage-display — live OpenCode Go subscription usage (5h / 7d / 30d windows) for opencode and the Kilo Code CLI. Zero popups, no context injection, and the plan is read from the credential store the host already uses.

What you get

Surface What it shows
Go Usage sidebar stacked meters for 5h / 7d / 30d, the next reset on its own line (5h resets in 2h5m), plus a foldable per-model mix
statusline compact session_prompt_right line, e.g. Go 5h 42% | 7d 15%
go_usage tool lets the agent report current usage; returns one line plus a JSON snapshot (Go 5h 42% (reset 3h12m) | 7d 15% | 30d 61%)

Details that matter:

  • Model mix — one row per model with a weight bar, where the weight is that model's share of the Go tokens spent in this session, measured the way the host's own Context panel measures the number next to it. It is a share of tokens, never a share of the plan or a price, because the plan's absolute limits are not client-visible.
  • Threshold colouring — bars follow the plan's own thresholds (muted below 75%, warning at 90%, error above), and a capped window is always error-coloured however low its percent reads.
  • Kilo has two sidebar modes — integrated (default) takes over the host's own Token Usage band and draws the Go plan once inside an OpenCode Go group; standalone puts the block in its own band and leaves the host panel alone. Switch with Go usage: toggle sidebar mode.
  • Fail-safe, never noisy — no automatic toast, no transcript injection, no unstable footer slot. A failed request keeps the last good snapshot, and if the plugin can't initialise the host starts anyway.
  • Toggles — Go usage: toggle sidebar and Go usage: toggle statusline in the command palette, persisted per surface; also settable as tui.json plugin options or OPENCODE_OC_GO_* / KILO_OC_GO_* env vars.
  • One package, one version, four bundles — the same npm release ships the opencode server/TUI and Kilo server/TUI entries, and the build fails if any bundle is missing.

Requirements

  • Node >= 22
  • opencode >= 1.18 — and an OpenCode Go subscription, since there is nothing to show without one
  • Kilo Code CLI >= 7.8 (@kilocode/cli, binaries kilo / kilocode) for the Kilo target

Install

Every command below was run end-to-end against the published 2.1.0,
pulled straight from the npm registry into a throwaway HOME
(Node 22.23.3, npm 10.8.2). Each one exits 0 and prints the config entries it
wrote plus the bundles it installed. None of them needs a flag or workaround.

Install (npm, project-local — recommended)

npm install oc-go-usage-display
npx oc-go-usage-display-init --copy

Install (global npm — nothing added to your project)

npm install -g oc-go-usage-display
oc-go-usage-display-init --copy

Note the bare command: npx looks in the registry, not at globally installed bins, so npx oc-go-usage-display-init won't find it.

Install (Bun, project-local)

bun add oc-go-usage-display
bunx oc-go-usage-display-init --copy

One-shot (nothing added to your project)

npx -p oc-go-usage-display oc-go-usage-display-init --copy

Project scope (.opencode/ instead of ~/.config/opencode)

npx -p oc-go-usage-display oc-go-usage-display-init --copy --config-dir .opencode

No files copied — let the host resolve the package

// opencode.jsonc — server target (go_usage tool)
{ "plugin": ["oc-go-usage-display"] }

// tui.json — TUI target (Go Usage sidebar + statusline)
{ "plugin": [["oc-go-usage-display", { "sidebar": true, "statusline": true }]] }

This resolves the package at startup instead of copying it, so pin the version if you want reproducible installs.

Kilo Code CLI

oc-go-usage-display-init --target kilo

Kilo's tui.json rejects the sidebar / statusline options (both surfaces are on by default there), so its entry is a plain plugin spec. Toggle surfaces via the command palette or KILO_OC_GO_* — a Kilo bundle only ever reads KILO_OC_GO_*, so an OPENCODE_OC_GO_* name can never steer it.

From a checkout

./install.sh           # copy install (--target kilo for Kilo); builds via bun if dist/plugins/* is missing
./install.sh --symlink # dev-only
./install-dev.sh       # latest `develop` dev-tgz + a config snapshot (prints the restore command)

Auth

First match wins; secrets are never logged. Each host reads only its own credential store, so a Kilo login never feeds the opencode plugin or vice versa.

  1. OPENCODE_OC_GO_MOCK=1 / KILO_OC_GO_MOCK=1 — deterministic mock snapshot (testing)
  2. OPENCODE_OC_GO_API_KEY / KILO_OC_GO_API_KEY — Authorization: Bearer against GET https://opencode.ai/zen/go/v1/usage
  3. provider auth.json — same Bearer path, opencode-go key else opencode, read from that host's own store (~/.local/share/opencode/auth.json, ~/.config/kilo/auth.json), so just signing in through the opencode-go provider is enough — nothing to paste
  4. workspaceId + authCookie — env vars or oc-go-usage-display.json in the host's config dir, scraping https://opencode.ai/workspace/{workspaceId}/go
  5. nothing — surfaces show Go n/a (…)

Successful snapshots are cached for 60s (memory + oc-go-usage-display-cache.json in the host's config dir); failures are never cached, and the usage endpoint is the only network call. The old unscoped OPENCODE_GO_* spelling was removed in 2.0 — if you configured credentials with it, move them to the host-scoped name of the host you actually run.

Verify / uninstall

oc-go-usage-display-show     # effective install per host (--json for machines)
oc-go-usage-display-status   # health check: exit 0 healthy, 1 with reasons
oc-go-usage-display-remove   # drop plugin files + config entries (secrets untouched)

Entry: data/plugins/oc-go-usage-display.yaml — screenshots of both hosts' sidebars and the full feature/flag reference are in the README.

@christophkroeppl
christophkroeppl marked this pull request as ready for review September 9, 2026 11:06
- min_version 1.4.3 -> 1.18.0 (package.json engines: opencode ^1.18.0)
- description: cover both hosts, the per-model Go-token mix, toggles and
  the host-scoped auth vars (the old text still advertised the removed
  unscoped OPENCODE_GO_* spelling)
- installation: verified install commands; project-local npm needs
  --legacy-peer-deps because of the exact-pinned optional UI peers
- add kilocode/quota tags
Christoph Kröppl and others added 3 commits October 2, 2026 13:13
2.0.1 loosens the exact-pinned optional UI peers to caret ranges, so a plain
`npm install oc-go-usage-display@latest` resolves cleanly again (npm 10.8.2).
Drop the --legacy-peer-deps workaround and the ERESOLVE caveat, and lead with
the project-local npm install.
Match the upstream README: commands are unversioned so none of them goes
stale after a release. An unversioned plugin spec still resolves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant