Skip to content

feat: opencode reads its key from the opencode cli login (0.0.91) - #123

Merged
okisdev merged 2 commits into
mainfrom
opencode-auth-fallback
Nov 22, 2026
Merged

okisdev merged 2 commits into
mainfrom
opencode-auth-fallback

Conversation

@okisdev

@okisdev okisdev commented Nov 22, 2026

Copy link
Copy Markdown
Owner

summary

  • the opencode companion takes its key from OPENCODE_GO_API_KEY or, when that is unset or blank, from the opencode-go entry that opencode auth login writes to $XDG_DATA_HOME/opencode/auth.json (default ~/.local/share/opencode/auth.json), so one login configures the lane and a rotation needs no env var edit
  • the store is read, never written; an oauth entry, a blank key, or an unreadable or malformed file counts as no key and fails as auth with the login hint. the key reaches the codex child as OPENCODE_GO_API_KEY and still never lands in args, job records, or tool subprocesses
  • logic is in plugins/opencode/scripts/lib/opencode-provider.mjs (resolveApiKey, opencodeAuthFile); the rest is the contract, troubleshooting, skill wording, and tests

test plan

already verified

  • node --test tests/opencode-*.test.mjs: 36/36, including env over store precedence, the XDG_DATA_HOME path, rejected entry shapes, and an end to end task whose stored key reaches the codex child and the Go API stub but no arg or job record
  • npm test: 3182 tests, 3179 pass, 3 skipped, 0 fail; node shared/sync.mjs --check and claude plugin validate for opencode, fusion, and the root pass
  • live, env var unset: /opencode:setup with a store holding a valid Go key reports ready and quota --json reads 4/1/0 percent; with this machine's stale stored key it reports HTTP 401; with no store it prints the opencode auth login hint

reviewer should verify

  • after opencode auth login for OpenCode Go and with OPENCODE_GO_API_KEY unset, /opencode:setup reports ready

… var is unset

reads the opencode-go api key that opencode auth login writes to $XDG_DATA_HOME/opencode/auth.json (default ~/.local/share/opencode/auth.json) when OPENCODE_GO_API_KEY is unset or blank, passes it to the codex child, and never writes the store.
@okisdev
okisdev merged commit 3dc4520 into main Nov 22, 2026
4 checks passed
@okisdev
okisdev deleted the opencode-auth-fallback branch November 22, 2026 10:48
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