fix: allow user plugins to override built-in auth plugins #11058
+45
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
.find()to.findLast()in CLI auth flow so user plugins take precedence over internal plugins (e.g., github-copilot). This aligns CLI behavior withProviderAuth.methods()which already uses last-wins semantics viafromEntries().What does this PR do?
Fixes a bug where user/external plugins cannot override built-in auth plugins. The root cause is that
Plugin.list()returns internal plugins first, then user plugins. The CLI auth command used.find()(first match wins), meaning the built-in plugin always took precedence. Meanwhile,ProviderAuth.methods()(used by TUI) already usedfromEntries()which is last-wins.This PR changes two
.find()calls to.findLast()inpackages/opencode/src/cli/cmd/auth.tsso user plugins can fully override built-in auth behavior (e.g., a company plugin replacing the default GitHub Copilot OAuth flow with a custom enterprise auth).How did you verify your code works?
Added
packages/opencode/test/plugin/auth-override.test.tswhich:auth.provider: "github-copilot"with a custom methodProviderAuth.methods()and asserts the user plugin's method takes precedence over the built-in