Friendly OpenCode plugin to keep an eye on your GitHub Copilot premium usage.
It gives you lightweight visibility while you work:
- info toast on every user message
- warning toasts as you approach your monthly limit
copilot_usage_statustool for quick status checks
If you are on Copilot plans with premium request quotas, this plugin helps you avoid surprises by showing your usage in real time inside OpenCode.
- Fetches usage from
GET /copilot_internal/user(primary) - Falls back to GitHub billing summary if needed
- Falls back to local estimate if API data is unavailable
- Persists monthly state in
.opencode/state/copilot-usage.json - Warns at configurable thresholds (
75%,90%,100%by default) - Adds custom tool:
copilot_usage_status
Add the plugin to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-copilot-usage"]
}Restart OpenCode after updating config.
- Send a user message: you will get a short info toast.
- Ask OpenCode to run
copilot_usage_statusfor a full snapshot. - Keep coding; warning toasts appear automatically as thresholds are crossed.
Environment variables:
GITHUB_TOKEN: preferred token for usage APIGH_TOKEN: alternate token variableCOPILOT_API_GITHUB_TOKEN: alternate token variable- If no token env is set, plugin reads
~/.local/share/opencode/auth.json(github-copilot.access) GITHUB_USERNAME: optional username overrideOPENCODE_COPILOT_USAGE_MONTHLY_LIMIT: default300OPENCODE_COPILOT_USAGE_WARN_THRESHOLDS: default0.75,0.9,1OPENCODE_COPILOT_USAGE_WARN_COOLDOWN_MINUTES: default360OPENCODE_COPILOT_USAGE_REPEAT_OVER_LIMIT_EVERY: default25OPENCODE_COPILOT_USAGE_BILLING_START_DAY: default1(range1-28)OPENCODE_COPILOT_USAGE_BILLING_TIMEZONE:utc(default) orlocalOPENCODE_COPILOT_USAGE_TOAST_EVERY_PREMIUM_REQUEST: defaulttrueOPENCODE_COPILOT_USAGE_REQUEST_TOAST_DURATION_MS: default3000OPENCODE_COPILOT_USAGE_STATE_FILE: optional custom state pathOPENCODE_COPILOT_USAGE_DEBUG: defaultfalse
- OpenCode plugins currently do not expose custom sidebar widget injection.
- This plugin shows usage via toasts and tool output instead.
npm install
npm run typecheck
npm run build- Manual publish:
npm publish --access public- CI publish (recommended): push a
v*tag withNPM_TOKENconfigured in repo secrets.