An OpenCode Go usage card for the Hermes Agent TUI. Docks above the status bar and refreshes every 60 seconds.
⚡ OpenCode · Go
5h ░░░░░░░░░░░░ 0% $0.00/$12 ·4h 33m
week █░░░░░░░░░░░ 7% $2.21/$30 ·4d 18h
month ███████░░░░░ 55% $33.17/$60 ·14d 23h
Rolling 5-hour, weekly and monthly windows with reset countdowns. Bars turn yellow at 50% and red at 80%. Percentages come from OpenCode's public usage endpoint and need only an API key. Dollar amounts ($used/$limit, cent precision) come from your opencode.ai console session via a one-time cookie extraction — macOS + Chrome today; without it the card stays in percent mode.
Requires Node 18+ and a working Hermes Agent install.
git clone https://github.com/E-R-Butch/hermes-opencode-go-widget.git
cd hermes-opencode-go-widget
./install.shThat copies the widget to ~/.hermes/tui-widgets/ and the console helper to ~/.hermes/opencode-go/. Hermes hot-loads widgets from there — no restart needed.
The card resolves your key from, in order: OPENCODE_API_KEY / OPENCODE_GO_API_KEY in the environment, either name in ~/.hermes/.env, or the OpenCode CLI's stored auth (~/.local/share/opencode/auth.json).
Toggle it in the TUI with /opencode-go.
The public usage endpoint only exposes integer percentages. The web console exposes the real meters in micro-cents behind your login session, so:
node ~/.hermes/opencode-go/fetch_console.mjs --extractIt makes a read-only copy of Chrome's cookie database, decrypts only the opencode.ai cookies using the "Chrome Safe Storage" key from your login keychain (one approval prompt), and stores the resulting cookie header in ~/.hermes/opencode-go/console_cookie (chmod 600). It only ever talks to opencode.ai; nothing is sent anywhere else and the cookie is never printed. After the first run, normal refreshes reuse the cached cookie and never touch the keychain.
When the session expires the card shows console session expired — rerun the command above.
Details worth knowing: it reads the Default Chrome profile (edit the path in fetch_console.mjs for another profile) and needs the sqlite3 CLI (ships with macOS).
- One snapshot is kept in memory; reopening the card renders instantly and the next poll lands in the background.
- When the console cache goes stale the card silently respawns the fetcher (throttled), then picks up the result.
- Network failures never crash the TUI: the card shows an
offline — retryinghint and keeps polling.
node test.mjsParsers, dollar formatting, severity ladder and width budgets run against fixtures. The live sections exercise the real endpoints and self-skip when the machine isn't set up.
- OpenCode doesn't expose request counts for this plan, so the card can't show them.
- The console path is macOS + Chrome only for now; everything else works cross-platform.
- Built against the current Hermes user-widget API — if a Hermes update changes it, the widget may need a touch-up.
MIT — see LICENSE.