opencode-manage: View Quotas for Multiple OpenCode Go Accounts on the Session Tabs Bar

Introduction

When using multiple OpenCode Go accounts in DSH, you need to frequently switch between configuration files or manually track the usage of each account. If an account’s 5-hour / weekly / monthly quota is about to run out and you don’t switch in time, it will interrupt conversations or cause request failures.

opencode-manage adds a “Go Balance” page to the session tab bar, mapping each account to a card that simultaneously displays the percentage and reset time for all three windows, with support for auto-refresh and usage notifications. It also provides an “OpenCode Go Auto” route that can automatically rotate keys in the background.

Plugin Overview

This is a DSH plugin for viewing the 5-hour / weekly / monthly quotas of multiple OpenCode Go accounts in the session tab bar. It supports manually adding accounts, auto-refresh, usage alerts, and the “OpenCode Go Auto” route for background key rotation. The plugin is maintained by pcysanji and categorized under admin-security.

Core Features

1. Multi-Account Card Display

The plugin adds a “Go Balance” page to the session tab bar. Data is fetched only when the page is opened, not via persistent polling. Each card displays three circular gauges corresponding to the 5-hour / weekly / monthly windows:

  • Window name + percentage + reset time (local timezone)
  • Colors: blue (normal), amber (≥70%), red (≥90%)
  • Card header: account name, source (DSH config / credential store / manual entry), last 4 digits of key, status
  • “Edit” button at the bottom to rename or replace the key

2. Auto-Refresh and Usage Alerts

The page header allows setting an auto-refresh interval (0 = disabled, default 0). When set to N, data is fetched in the background every N minutes, continuing to run even when you switch to other tabs.

When usage crosses 85% / 90% / 98%, a desktop notification is triggered once per threshold:

  • Title shows the window name and threshold level
  • Body includes account, percentage, and reset time
  • Each threshold fires only once; re-arms when usage drops back below 85%

Notifications use the browser Notification API: an authorization prompt appears on first configuration; if denied, only an inline status bar at the top of the page is shown, while card colors still update normally.

3. Account Sources

The plugin reads accounts from three sources:

  1. Providers in DSH model configuration whose baseURL points to opencode.ai (e.g., opencode-go-free and go163 in llm-pi-ai)
  2. Keys in .credentials.yaml refs whose names contain “opencode” and values start with oc_
  3. Manually entered keys on the page, stored in $DSH_HOME/opencode-usage/accounts.json (0600)

Duplicate keys appearing multiple times are displayed as a single entry. Keys remain only in the host process; the browser only receives the last 4 digits.

4. OpenCode Go Auto – Automatic Account Switching

An additional entry OpenCode Go Auto appears in the model list (provider id opencode-go, credential ref OPENCODE_GO_AUTO). The key it uses is rotated by the host in the background—no manual config changes needed.

This route intentionally omits api and models: pi-ai’s built-in catalog assigns each opencode-go model its own protocol (openai-completions / openai-responses / anthropic-messages / google-generative-ai). Hardcoding any single protocol would block all other models.

The auto-switching logic:

  • Every 5 minutes, checks the 5-hour / weekly / monthly quotas of all accounts; all three windows participate in the decision
  • The first slot in the queue is “Auto”: when selected, accounts are chosen by rule—earliest monthly quota reset date takes priority (if tied, compare weekly usage, then 5-hour usage)
  • 5-hour or weekly quota reaching 99.9% only yields to the next account (automatically switches back to the one with the earliest monthly reset once quota recovers); monthly quota reaching 100% truly disables the account until the next reset day
  • Clicking an account’s chip = selecting it; the plugin will keep using it, and auto-logic won’t override—only when its monthly quota is fully consumed does it fall back to auto
  • The “Auto” chip is at the same level as account chips; no extra “Manual” label is needed; the selected one is highlighted, and accounts with full monthly quota are greyed out and marked “Disabled”
  • Switching = credentials.set('OPENCODE_GO_AUTO', <new key>). Model requests fetch the key by credential ref each time, so the next request takes effect immediately without a restart

A desktop notification fires on each switch (title “Go Auto Switch: “, from → to + reason). The status bar at the top of the page synchronously displays the queue, current active account, and last switch time.

5. Manual Pinning and Locking

Queue chips in the status bar can be clicked directly:

  • Click an account → switches to it immediately; status line shows “Manually pinned”; that chip gets a dashed border and a “Manual” tag
  • During manual mode, auto-logic no longer overrides (it only refreshes numbers and monitors whether this account’s quota is exhausted)
  • Once the manually pinned account hits full monthly quota / 99.9% on weekly or 5-hour, it automatically falls back to rule-based selection, with a page-top notice: “Manually pinned account is no longer available, reverted to Auto”
  • Click the current manual account again, or click “Back to Auto” in the actions area, to hand control back to auto

Clicking an account card = locking it, so it won’t be automatically switched away due to 5-hour / weekly / monthly quota changes. The trade-off: if its monthly quota fills up, requests will fail, and the status bar shows “Quota exhausted, will not auto-switch; click ‘Auto’ to switch.” To restore auto-switching, click “Auto” in the first queue slot; or delete this account.

Installation & Enablement

The plugin is published on npm: opencode-manage; source code: https://github.com/pcysanji/opencode-manage.

Two ways to install it into a DSH profile (both require restarting the desktop client):

  • Install opencode-manage from the plugin management panel.
  • Manually: add the dependency "opencode-manage": "link:<absolute path to this repo>" (or a version number) to the profile’s package.json, add it to dsh.profile.bundles, then run pnpm install.

The plugin ships with cordis.patch.yml; the client side is automatically loaded via dsh.client in package.json—no additional configuration needed.

Typical Usage

  1. Add a provider pointing to opencode.ai in DSH model configuration, e.g., opencode-go-free or go163 in llm-pi-ai
  2. Add refs in .credentials.yaml with names containing “opencode” and values starting with oc_
  3. Click “Go Balance” in the session tab bar to view quota status for all accounts
  4. Set the auto-refresh interval in the page header (e.g., 10 minutes)
  5. When an account’s usage exceeds 85% / 90% / 98%, a desktop notification is triggered
  6. Select OpenCode Go Auto in the model list; the auto-switching feature will pick available accounts by rule

Use Cases & Notes

Suitable for DSH users who simultaneously use multiple OpenCode Go accounts, especially those who need to manage usage across multiple accounts and want automatic switching to available accounts.

The plugin runs with the current DSH process permissions. Review the source code and license before installing.

Conclusion

opencode-manage makes managing multiple OpenCode Go accounts more intuitive and automated through its card-based interface and auto-switching logic. Whether manually adding accounts or using the “OpenCode Go Auto” route, it reduces manual intervention and prevents conversation interruptions caused by exhausted quotas.

  • Plugin catalog page: https://www.skillhub.cn/plugins/pcysanji/opencode-manage
  • GitHub repository: https://github.com/pcysanji/opencode-manage
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye