Skip to content

Add an OpenCode collector to the agents panel - #11372

Open
gIvarsDev wants to merge 1 commit into
omacom:quattrofrom
gIvarsDev:agents-opencode-collector
Open

Add an OpenCode collector to the agents panel#11372
gIvarsDev wants to merge 1 commit into
omacom:quattrofrom
gIvarsDev:agents-opencode-collector

Conversation

@gIvarsDev

Copy link
Copy Markdown

What

Adds an opencode collector to the agents panel, so an OpenCode Go subscription gets the same meters, weekly chart, and model breakdown the other agents already have.

Why

OpenCode Go enforces three usage windows — rolling 5-hour, weekly, and monthly — and none of them surface anywhere on the desktop today.

The panel is not blind to opencode in general, but it is blind to this subscription: omarchy-agent-usage-claude counts opencode sessions that ran on an Anthropic provider, and omarchy-agent-usage-codex counts the ones that ran on Codex. A subscription burned entirely through opencode-go falls between them and shows up nowhere.

How

Following the contract in shell/plugins/agents/README.md ("adding an agent is adding a collector"):

  • bin/omarchy-agent-usage-opencode — the record, from two independent sources
  • shell/plugins/agents/assets/opencode{,-light}.svg — the mark, in both surface variants
  • manifest.json / README.md — the new agent listed alongside the others

omarchy-agent-usage-update discovers the collector by glob, so nothing in the update path or the panel changes.

Limits come from the OpenCode Go usage endpoint. Token history comes from opencode's own message database — the same database omarchy-agent-usage-claude already scans, filtered to the opencode-go and opencode providers instead of anthropic. The scan mirrors that one: read-only connection, per-row failure isolation, and the same cache so --limits-only keeps its freshness promise.

One thing worth flagging

The usage endpoint is undocumented. https://opencode.ai/zen/go/v1/usage returns exactly the three windows the panel wants, but it is not in OpenCode's published docs and is not referenced by their CLI. I found it by probing route names. It may change or disappear without notice.

I built the collector so that costs nothing when it happens: the probe failing leaves limits empty, writes a status line into the panel, and the token history below it still renders. Same shape as the claude collector without credentials. But it is a real dependency on an unpublished surface, and you should weigh that rather than discover it later.

Two smaller notes:

  • The endpoint reports whole percents (2 for 2%); the panel renders percent * 100, so the collector divides. Passing the value through paints 2% as 200% and trips the alarm state.
  • The endpoint sits behind a CDN that answers urllib's default agent string with 403, so the request names itself. Without that header the probe silently fails and the meters never appear — it is commented in place so it does not get tidied away.

Testing

./test/all — no regressions. Five files fail on this machine (bar-icon-geometry, config, locate, snapper, unowned-system-paths), and they fail identically on a clean checkout with these changes stashed; they look environment-dependent rather than related to this change. Everything else passes.

Also exercised by hand against a live subscription:

Case Result
Signed in, database present Three meters with reset countdowns, week chart, model breakdown
Signed out Not signed in to OpenCode. + how to fix; token history still renders
Invalid key / endpoint gone OpenCode usage endpoint unavailable.; meters hidden, history kept
No database Valid record, hasLocalStats: false

Screenshot

OpenCode Go subscriptions have their own rolling, weekly, and monthly
windows, and none of them surface anywhere on the desktop today. A
subscription burned through opencode on an OpenCode provider is invisible
to the panel: the claude collector only counts opencode sessions that ran
on an Anthropic provider, and the codex collector only those that ran on
Codex.

The collector reads the three windows from the OpenCode Go usage endpoint
and the token history from opencode's own message database, the same
database the claude collector already scans. omarchy-agent-usage-update
discovers it by glob, so nothing else changes.

Both sources are optional and independent: without credentials the record
still carries local token history and says why the meters are missing;
without a database it carries the meters alone.
@gIvarsDev
gIvarsDev changed the base branch from master to quattro September 11, 2026 20:58
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