Skip to content

fix(#90): detect opencode-go credentials in auth.json#162

Open
janekbaraniewski wants to merge 2 commits into
mainfrom
fix/opencode-go-detection
Open

fix(#90): detect opencode-go credentials in auth.json#162
janekbaraniewski wants to merge 2 commits into
mainfrom
fix/opencode-go-detection

Conversation

@janekbaraniewski
Copy link
Copy Markdown
Owner

Summary

  • Extends opencodeAuthMapping to recognise the new opencode-go key in OpenCode's auth.json alongside the legacy opencode (Zen) key. Both ids share OPENCODE_API_KEY upstream and hit the same Zen endpoint, so they land on the same opencode openusage account/tile.
  • Widens auth.json path resolution: honours XDG_DATA_HOME (any platform), keeps ~/.local/share/opencode/auth.json as the default, and adds a ~/Library/Application Support/opencode/auth.json fallback on macOS for users who pinned to the Apple-native location.
  • Adds tests covering opencode-go adoption, the XDG override, and the darwin Application Support fallback.
  • Docs: notes the auth.json adoption in docs/site/docs/providers/opencode.md.

Closes #90 — without this, users on the opencode-go catalog see "No providers detected" even when their key is present in auth.json, because the previous mapping only matched the legacy opencode key.

Test plan

  • go test ./internal/detect/ -run TestDetectOpenCodeAuth -v — all 7 cases pass
  • go build ./... clean
  • DOCS_PREVIEW=1 npm run build in docs/site/ finishes with [SUCCESS] and no broken-link warnings
  • Manual repro: drop {"opencode-go": {"type":"api","key":"sk-fake"}} into ~/.local/share/opencode/auth.json, run openusage detect, confirm an opencode account is reported

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

📘 Docs preview

Built and deployed for commit 4e02617.

Preview URL: https://44a54478.openusage-docs.pages.dev/

Routes to check: Home · Install · Providers · CLI reference · FAQ

Re-deployed on every push to this PR. The build artifact is also attached to the workflow run.

janekbaraniewski and others added 2 commits May 19, 2026 02:11
Extend the OpenCode auth detector so it also picks up tokens written by
the newer opencode-go client (auth.json layout with provider-keyed
entries and `key`/`apiKey` fields), in addition to the legacy single
top-level token blob. This restores auto-import for users that switched
to opencode-go.

Closes #90
Documents the auto-detection extension that picks up tokens written
by the newer opencode-go client alongside legacy opencode/Zen entries,
so users know both upstream client variants are supported.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@janekbaraniewski janekbaraniewski force-pushed the fix/opencode-go-detection branch from c2da504 to 4e02617 Compare May 19, 2026 00:11
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.

OpenCode Go not recognized

1 participant