anomalyco / anomalyco/opencode
[FEATURE]: report plan usage (Go limits, Zen balance) to ACP clients
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
opencode acp already sends usage_update with the context size and the session's cost. What an ACP client still can't see is the account's plan standing:
- Go: the rolling 5-hour, weekly and monthly usage that
GET /zen/go/v1/usagereturns (#16017). - Zen: the remaining balance (#10448).
Today an ACP client (Zed, HarnessDesk, others) has to find the user's key and call those endpoints itself, which it may not be able to do.
Suggestion: have the ACP server attach these figures itself. ACP has no standard plan-usage message yet, so _meta or an extension method is the sanctioned place. Either of these would work:
- a
_metablock onusage_update:
{ "sessionUpdate": "usage_update", "used": 53000, "size": 200000,
"_meta": { "opencode": { "go": { "rolling": { "percent": 19.5, "resetsAt": "…" }, "weekly": { … }, "monthly": { … } } } } }
- a custom request such as
_opencode/usage, returning the same object.
In the meantime, HarnessDesk reads each session's cost from opencode.db (HarnessDesk/HarnessDesk#772), but that shows spend, not the plan's limits.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the opencode acp handling for usage_update, then review the Go usage endpoint GET /zen/go/v1/usage and the Zen balance flow referenced in the issue. Compare the _meta and custom _opencode/usage options, and define completion as ACP clients receiving rolling, weekly, monthly, and balance information without querying account endpoints themselves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100