Skip to content

feat: add Anthropic Claude Pro/Max support + fix Windows Google path#26

Open
schlambos wants to merge 1 commit into
vbgate:mainfrom
schlambos:feat/add-anthropic-fix-windows-google
Open

feat: add Anthropic Claude Pro/Max support + fix Windows Google path#26
schlambos wants to merge 1 commit into
vbgate:mainfrom
schlambos:feat/add-anthropic-fix-windows-google

Conversation

@schlambos
Copy link
Copy Markdown

Summary

Two independent improvements, both tested against a real Windows install with live credentials.


1. Fix: Windows users get silent Google quota failures

File: \plugin/lib/google.ts\

\getAntigravityAccountsPath()\ used \APPDATA\ on Windows, but \opencode\ always writes \�ntigravity-accounts.json\ to ~/.config/opencode/\ on every platform — including Windows. The result was a silent \ENOENT\ error and no Google quota shown for any Windows user who had antigravity accounts configured.

Fix: Remove the \win32\ branch; always resolve to \homedir()/.config/opencode/antigravity-accounts.json.


2. Feature: Anthropic Claude Pro/Max quota support

Files: \plugin/lib/anthropic.ts\ (new), \plugin/lib/types.ts, \plugin/lib/i18n.ts, \plugin/mystatus.ts\

Adds a new platform module that queries the internal endpoint Claude Code uses for its HUD:

\
GET https://api.anthropic.com/api/oauth/usage
Authorization: Bearer
anthropic-beta: oauth-2025-04-20
User-Agent: claude-code/1.0.17
\\

The OAuth access token is read from \�uth.json\ under the \�nthropic\ key (stored there by \opencode-claude-auth). If the token is expired, the module attempts a refresh via \console.anthropic.com/v1/oauth/token\ using Claude Code's public client ID.

Response used: \ ive_hour.utilization\ / \seven_day.utilization\ +
esets_at\ timestamps — same fields Claude Code's own HUD reads.

Output example:
\\

Anthropic Account Quota

Account: Claude Pro/Max

5-hour limit
█████████████████████████████░ 98% remaining
Resets in: 4h 22m

7-day limit
██████████████████████████████ 100% remaining
Resets in: 6d 9h
\\

Both changes were discovered and validated while debugging a real production setup on Windows 11 where Google quota was broken and Anthropic was missing entirely.

- Add plugin/lib/anthropic.ts: queries api.anthropic.com/api/oauth/usage
  (the same internal endpoint used by Claude Code HUD) using the OAuth
  access token stored in auth.json under the 'anthropic' key.
  Handles token refresh via console.anthropic.com/v1/oauth/token.
  Displays 5-hour and 7-day rolling-window utilization.

- Fix plugin/lib/google.ts: getAntigravityAccountsPath() incorrectly used
  APPDATA on Windows instead of ~/.config/opencode/. opencode always writes
  antigravity-accounts.json to ~/.config/opencode/ on all platforms, so
  Windows users received silent quota failures. Now uses homedir()/.config
  unconditionally.

- Update plugin/lib/types.ts: add AnthropicAuthData interface and wire
  'anthropic' key into AuthData.

- Update plugin/lib/i18n.ts: add zh/en translation strings for Anthropic
  (title, error messages, limit labels).

- Update plugin/mystatus.ts: import queryAnthropicUsage, add to parallel
  Promise.all(), collect and display Anthropic results.
@schlambos schlambos marked this pull request as ready for review May 18, 2026 18:13
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