opencode-claude-auth 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Self-contained Anthropic auth provider for OpenCode using your Claude Code crede
8
8
 
9
9
  ## How it works
10
10
 
11
- The plugin registers its own auth provider with a custom fetch handler that intercepts all Anthropic API requests. It reads OAuth tokens from the macOS Keychain (or `~/.claude/.credentials.json` on other platforms), caches them in memory with a 30-second TTL, and handles the full request lifecycle — no builtin Anthropic auth plugin required. On macOS, multiple Claude Code accounts are detected automatically and can be switched via `opencode auth login`.
11
+ The plugin registers its own auth provider with a custom fetch handler that intercepts all Anthropic API requests. It reads OAuth tokens from the macOS Keychain (or `~/.claude/.credentials.json` — or `$CLAUDE_CONFIG_DIR/.credentials.json` if that env var is set — on other platforms), caches them in memory with a 30-second TTL, and handles the full request lifecycle — no builtin Anthropic auth plugin required. On macOS, multiple Claude Code accounts are detected automatically and can be switched via `opencode auth login`.
12
12
 
13
13
  It also syncs credentials to OpenCode's `auth.json` as a fallback (on Windows, it writes to both `%USERPROFILE%\.local\share\opencode\auth.json` and `%LOCALAPPDATA%\opencode\auth.json` to cover all installation methods). If a token is near expiry, it refreshes directly via Anthropic's OAuth endpoint (zero LLM tokens consumed), falling back to the Claude CLI if the direct refresh fails. Background re-sync runs every 5 minutes.
14
14
 
@@ -78,7 +78,7 @@ Just run OpenCode. The plugin handles auth automatically — it reads your Claud
78
78
  The plugin checks these in order:
79
79
 
80
80
  1. macOS Keychain (all `Claude Code-credentials*` entries — multiple accounts are detected automatically)
81
- 2. `~/.claude/.credentials.json` (fallback, works on all platforms)
81
+ 2. `~/.claude/.credentials.json` (fallback, works on all platforms; if `CLAUDE_CONFIG_DIR` is set, reads `$CLAUDE_CONFIG_DIR/.credentials.json` instead)
82
82
 
83
83
  ## Multiple accounts (macOS)
84
84
 
@@ -96,17 +96,17 @@ If only one account is found, the switcher is hidden and the plugin uses it dire
96
96
 
97
97
  ## Troubleshooting
98
98
 
99
- | Problem | Solution |
100
- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
101
- | "Credentials not found" | Run `claude` to authenticate with Claude Code first |
102
- | "Keychain is locked" | Run `security unlock-keychain ~/Library/Keychains/login.keychain-db` |
103
- | "Token expired and refresh failed" | The plugin runs `claude` CLI to refresh automatically. If this fails, re-authenticate manually by running `claude` |
104
- | Not working on Linux/Windows | Ensure `~/.claude/.credentials.json` exists. Run `claude` to create it |
105
- | Keychain access denied | Grant access when macOS prompts you |
106
- | Keychain read timed out | Restart Keychain Access (can happen on macOS Tahoe) |
107
- | "Credentials are unavailable or expired" | Run `claude` to refresh your Claude Code credentials |
108
- | "Extra usage is required for long context requests" | Your plan doesn't cover long context extra usage. See [Long context (1M)](#long-context-1m) below |
109
- | Plugin not updating to latest version | Delete the cached package: `rm -rf ~/.cache/opencode/packages/opencode-claude-auth@latest/` then restart OpenCode |
99
+ | Problem | Solution |
100
+ | --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
101
+ | "Credentials not found" | Run `claude` to authenticate with Claude Code first |
102
+ | "Keychain is locked" | Run `security unlock-keychain ~/Library/Keychains/login.keychain-db` |
103
+ | "Token expired and refresh failed" | The plugin runs `claude` CLI to refresh automatically. If this fails, re-authenticate manually by running `claude` |
104
+ | Not working on Linux/Windows | Ensure `~/.claude/.credentials.json` exists (or `$CLAUDE_CONFIG_DIR/.credentials.json` if that env var is set). Run `claude` to create it |
105
+ | Keychain access denied | Grant access when macOS prompts you |
106
+ | Keychain read timed out | Restart Keychain Access (can happen on macOS Tahoe) |
107
+ | "Credentials are unavailable or expired" | Run `claude` to refresh your Claude Code credentials |
108
+ | "Extra usage is required for long context requests" | Your conversation exceeded 200k tokens. See [Long context (1M)](#long-context-1m) below |
109
+ | Plugin not updating to latest version | Delete the cached package: `rm -rf ~/.cache/opencode/packages/opencode-claude-auth@latest/` then restart OpenCode |
110
110
 
111
111
  ### Diagnostic logging
112
112
 
@@ -157,6 +157,7 @@ All configurable parameters can be overridden via environment variables. If Anth
157
157
  | `ANTHROPIC_USER_AGENT` | Full User-Agent string (overrides CLI version) | `claude-cli/{version} (external, sdk-cli)` |
158
158
  | `ANTHROPIC_BETA_FLAGS` | Comma-separated beta feature flags | `baseBetas` list in [`src/model-config.ts`](src/model-config.ts) |
159
159
  | `CLAUDE_AUTH_DEBUG` | Enable diagnostic logging (`1` for default path, or a custom file path) | disabled |
160
+ | `CLAUDE_CONFIG_DIR` | Claude Code config directory used for the credentials-file fallback (reads `$CLAUDE_CONFIG_DIR/.credentials.json`). macOS still checks the Keychain first. | `~/.claude` |
160
161
  | `OPENCODE_CLAUDE_AUTH_MAX_RETRY_MS` | Max ms the plugin waits when honouring a 429/529 `retry-after` header. Beyond this cap the response surfaces immediately so OpenCode doesn't appear to hang on hour-long quota resets. | `30000` |
161
162
 
162
163
  Example:
package/installation.md CHANGED
@@ -28,7 +28,7 @@ If this returns credentials, you're authenticated. If it fails or returns nothin
28
28
  cat ~/.claude/.credentials.json
29
29
  ```
30
30
 
31
- If this file exists and contains valid JSON, you're authenticated.
31
+ If this file exists and contains valid JSON, you're authenticated. If `CLAUDE_CONFIG_DIR` is set, check `$CLAUDE_CONFIG_DIR/.credentials.json` instead.
32
32
 
33
33
  ### If credentials don't exist
34
34
 
@@ -38,7 +38,7 @@ Run Claude Code to authenticate:
38
38
  claude
39
39
  ```
40
40
 
41
- This will prompt you to log in and store credentials in Keychain (macOS) or `~/.claude/.credentials.json` (other platforms).
41
+ This will prompt you to log in and store credentials in Keychain (macOS) or `~/.claude/.credentials.json` (other platforms; `$CLAUDE_CONFIG_DIR/.credentials.json` if `CLAUDE_CONFIG_DIR` is set).
42
42
 
43
43
  ## Installation
44
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-claude-auth",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "OpenCode plugin that uses your Claude Code credentials — no separate login needed.",
5
5
  "keywords": [
6
6
  "anthropic",