feat(plugin): fall back to OpenCode-stored /connect credentials for plugin auth - #17
feat(plugin): fall back to OpenCode-stored /connect credentials for plugin auth#17HarelMil wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe plugin now uses OpenCode’s stored ChangesLiteLLM credential fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LiteLLMDiscovery
participant Plugin
participant OpenCodeAuthJson
participant LiteLLMAPI
LiteLLMDiscovery->>Plugin: initialize provider options
Plugin->>OpenCodeAuthJson: read stored credential when needed
OpenCodeAuthJson-->>Plugin: return provider API key
Plugin->>LiteLLMAPI: send authenticated health-check or discovery request
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 247: Update the OpenCode `/connect` table row in README.md to add the
missing trailing pipe delimiter, preserving the existing row content.
In `@src/plugin/index.ts`:
- Around line 224-232: Normalize blank credentials to unavailable values before
precedence selection. In src/plugin/index.ts lines 224-232, update the
environment credential handling around envKey so blank LITELLM_API_KEY and
LITELLM_MASTER_KEY values do not override lower-priority credentials. In
src/utils/opencode-auth.ts lines 68-74, update the type: "api" key handling so a
blank stored key is treated as unavailable; preserve fallback to the next valid
credential in both sites.
- Around line 227-229: Correct the custom-provider authentication description:
in src/plugin/index.ts lines 227-229, qualify or remove the claim that OpenCode
automatically injects auth.json credentials; in README.md line 249, state that
the plugin applies the stored key to its custom-provider flow; and in
CHANGELOG.md lines 54-60, document that the fix enables authenticated discovery
and authenticated custom-provider completions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 54571db0-d002-41d2-b9ed-8f55237fdc84
📒 Files selected for processing (4)
CHANGELOG.mdREADME.mdsrc/plugin/index.tssrc/utils/opencode-auth.ts
a588826 to
8a4abee
Compare
…lugin auth The plugin's health check and /v1/models discovery only read options.apiKey or LITELLM_API_KEY / LITELLM_MASTER_KEY, so a key stored via OpenCode's /connect command (~/.local/share/opencode/auth.json) was invisible to it: a key-only proxy failed the health check with a 401 and silently skipped discovery. Fall back to the stored credential (precedence: options.apiKey > env var > auth.json, read once per process) and write the resolved key back into provider options so real chat completions authenticate too. Updates README and CHANGELOG under [Unreleased].
8a4abee to
062ee16
Compare
|
@yuseferi would appreciate your review :) |
Summary
The plugin's own health-check and
/v1/modelsdiscovery fetches only ever readoptions.apiKeyor theLITELLM_API_KEY/LITELLM_MASTER_KEYenv vars, so a key stored via OpenCode's/connectcommand was invisible to them — a key-only proxy failed the health check with a 401 and silently skipped discovery. This PR makes the plugin fall back to that stored credential and writes the resolved key back into the provideroptionsso real chat completions authenticate too. Closes #8.Type of change
Checklist
npm run typecheckpassesCHANGELOG.mdupdated under## [Unreleased]How was this tested?
Tested against a live remote LiteLLM deployment configured with a master key (no
options.apiKey/ env var set, credential added via OpenCode/connectonly). OpenCode version: 1.18.16. LiteLLM version: N/A (remote deployment).Representative log line:
Screenshots / logs (optional)
Summary by CodeRabbit
New Features
/connectcredential support as a fallback for authentication.Documentation