Skip to content

[Agent Usage] Use the new OpenCode Go usage API instead of scraping the workspace web page #30848

Closed

Description

@ericrocha97

Extension

https://www.raycast.com/thuggyduck/agent-usage

OS Version

Windows Windows 11 Professional 10.0.26200.0 amd64

Description

OpenCode Zen (OpenCode Go) now provides a usage API that returns the usage data directly as JSON:

curl https://opencode.ai/zen/go/v1/usage \
  -H "Authorization: Bearer $API_KEY"

Example response:

{
  "usage": {
    "rolling": {
      "status": "ok",
      "percent": 15,
      "resetsAt": "2026-09-07T06:54:09.396Z"
    },
    "weekly": {
      "status": "ok",
      "percent": 25,
      "resetsAt": "2026-09-14T00:00:00.396Z"
    },
    "monthly": {
      "status": "ok",
      "percent": 50,
      "resetsAt": "2026-10-03T03:17:02.396Z"
    }
  }
}

The current implementation in the extension (extensions/agent-usage/src/opencode-go/fetcher.ts) fetches the workspace web page (https://opencode.ai/workspace/wrk_.../go) using the auth cookie and parses the usage data out of the HTML (parser.ts). This is currently broken and is inherently fragile, since any change to the page markup breaks parsing.
Proposal: replace the HTML scraping with a request to the new API using the user's OpenCode API key (Bearer auth), mapping:

  • usage.rolling → rolling limit (percent + resetsAt)
  • usage.weekly → weekly limit (percent + resetsAt)
  • usage.monthly → monthly limit (percent + resetsAt)

Who will benefit from this feature?

All OpenCode Go users of the Agent Usage extension — usage data will work again and will no longer break whenever the web page markup changes.

Anything else?

Activity

  1. added
    feature request
    extension
    on Sep 7, 2026
  2. added
    extension: agent-usage
    on Sep 7, 2026
  3. raycastbot commented on Sep 7, 2026

    @raycastbot
    Collaborator

    Thank you for opening this issue!

    🔔 @natsustan @alexibuild @AdrianBonpin @GarrickZ2 @EDM115 @chingweih @natsustan @jakoss you might want to have a look.

    💡 Author and Contributors commands

    The author and contributors of thuggyduck/agent-usage can trigger bot actions by commenting:

    • @raycastbot close this issue Closes the issue.
    • @raycastbot close as not planned Closes the issue as not planned.
    • @raycastbot close as duplicate Closes the issue as duplicate.
    • @raycastbot rename this issue to "Awesome new title" Renames the issue.
    • @raycastbot reopen this issue Reopens the issue.
    • @raycastbot assign me Assigns yourself to the issue.
    • @raycastbot good first issue Adds the "Good first issue" label to the issue.
    • @raycastbot keep this issue open Make sure the issue won't go stale and will be kept open by the bot.
  4. ericrocha97 commented on Sep 8, 2026

    @ericrocha97
    ContributorAuthor

    Implemented in #30849 — merged 🎉

    The Agent Usage extension now fetches OpenCode Go usage from the Zen JSON API (https://opencode.ai/zen/go/v1/usage) with Bearer auth instead of scraping the workspace web page, mapping rolling/weekly/monthly (percent + resetsAt) as proposed. The workspace ID and auth cookie preferences were replaced by an optional OpenCode Go API key, auto-detected from ~/.local/share/opencode/auth.json (opencode-go entry).

    Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extensionextension: agent-usagefeature requestplatform: Windows

    Fields

    Priority

    None yet

    Severity

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions