Skip to content

Conversation

@JosXa
Copy link
Contributor

@JosXa JosXa commented Jan 28, 2026

Fixes #11475

Change .find() to .findLast() in CLI auth flow so user plugins take precedence over internal plugins (e.g., github-copilot). This aligns CLI behavior with ProviderAuth.methods() which already uses last-wins semantics via fromEntries().

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 used fromEntries() which is last-wins.

This PR changes two .find() calls to .findLast() in packages/opencode/src/cli/cmd/auth.ts so 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.ts which:

  1. Creates a temp directory with a user plugin that registers auth.provider: "github-copilot" with a custom method
  2. Calls ProviderAuth.methods() and asserts the user plugin's method takes precedence over the built-in

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

feat(auth): merge auth methods from multiple plugins for same provider

This PR appears related because it addresses how auth methods are merged from multiple plugins for the same provider. Your PR (11058) is about ensuring user plugins can override built-in auth plugins, which is related to how multiple plugins providing the same auth method are handled and prioritized.

These PRs may be addressing related or overlapping concerns around plugin precedence and auth method resolution, so it would be worth checking if one approach conflicts with or complements the other.

@thdxr thdxr force-pushed the dev branch 4 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@JosXa JosXa marked this pull request as ready for review January 31, 2026 14:32
@JosXa JosXa force-pushed the fix/auth-plugin-override branch 3 times, most recently from 0ec90e7 to c441dbf Compare January 31, 2026 15:00
@rekram1-node
Copy link
Collaborator

/review

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be doing the same here?

if (prompts.isCancel(provider)) throw new UI.CancelledError()

const plugin = await Plugin.list().then((x) => x.find((x) => x.auth?.provider === provider))
const plugin = await Plugin.list().then((x) => x.findLast((x) => x.auth?.provider === provider))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: The PR description states that two .find() calls are changed to .findLast(), but only this call (line 310) was updated. Line 326 (const customPlugin = await Plugin.list().then((x) => x.find(...)) still uses .find(), which means custom provider overrides entered via the "other" option will not work as intended. Consider also updating line 326 for consistency with the fix.

User plugins should override built-in auth plugins. Changed .find() to
.findLast() in auth.ts so the last registered plugin (user plugin) takes
precedence.

Also fixed the test to export a function instead of an object, matching
the expected plugin signature.
@JosXa JosXa force-pushed the fix/auth-plugin-override branch from 631d0c7 to 5e319cf Compare February 1, 2026 12:53
@rekram1-node rekram1-node merged commit 3577d82 into anomalyco:dev Feb 1, 2026
4 checks passed
kiennq pushed a commit to kiennq/opencode that referenced this pull request Feb 2, 2026
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
pRizz added a commit to pRizz/opencode that referenced this pull request Feb 6, 2026
* release: v1.1.42

* feat(desktop): Add desktop deep link (anomalyco#10072)

Co-authored-by: Brendan Allan <git@brendonovich.dev>

* chore: generate

* chore: update nix node_modules hashes

* fix: remove redundant Highlights heading from publish template (anomalyco#11121)

* ignore: update download stats 2026-01-29

* fix(telemetry): restore userId and sessionId metadata in experimental_telemetry (anomalyco#8195)

* fix: ensure kimi k2.5 from fireworks ai and kimi for coding providers properly set temperature

* ci: added gh workflow that adds 'contributor' label to PRs/Issues (anomalyco#11118)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>

* tweak: add 'skill' to permissions config section so that ides will show it as autocomplete option (this is already a respected setting)

* zen: m2.1 and glm4.7 free models

* feat: support config skill registration (anomalyco#9640)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>

* chore: regen sdk

* chore: format code

* chore: generate

* ci (anomalyco#11149)

Co-authored-by: opencode <opencode@sst.dev>

* test: skip failing tests (anomalyco#11184)

* chore: consolidate and standardize workflow files (anomalyco#11183)

* ci: disable nix-desktop workflow (anomalyco#11188)

* ci: remove push triggers from workflow files (anomalyco#11186)

* feat: add beta branch sync workflow for contributor PRs (anomalyco#11190)

* feat: expose acp thinking variants (anomalyco#9064)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>

* fix(app): better header item wrapping (anomalyco#10831)

* fix: show all provider models when no providers connected (anomalyco#11198)

* zen: kimi k2.5 free (anomalyco#11199)

* fix: use ?? to prevent args being undefined for mcp server in some cases (anomalyco#11203)

* feat(config): add managed settings support for enterprise deployments (anomalyco#6441)

Co-authored-by: Dax <mail@thdxr.com>

* chore: update nix node_modules hashes

* ci

* ci

* ci

* ci

* release: v1.1.43

* ci: upgrade bun cache to stickydisk for faster ci builds

* ci

* ci: trigger publish workflow automatically after beta builds complete

* ci

* test(app): test for toggling model variant (anomalyco#11221)

* fix(app): version to latest to avoid errors for new devs (anomalyco#11201)

* ci

* ci

* ci

* fix(beta): use local git rebase instead of gh pr update-branch

* fix(app): dialog not closing

* fix(app): free model scroll

* sync

* fix(app): free model layout

* ci: cache apt packages to reduce CI build times on ubuntu

* ci: add container build workflow

Add prebuilt build images and a publish workflow to speed CI by reusing heavy dependencies.

* ci: fix container build script

Invoke docker build with Bun shell so commands run correctly, and document default automation behavior.

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* release: v1.1.45

* fix: rm ai sdk middleware that was preventing <think> blocks from being sent back as assistant message content (anomalyco#11270)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>

* ci

* ci

* ci

* ci

* sync

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* wip: zen (anomalyco#11343)

* chore: generate

* ci: update pr template (anomalyco#11341)

* ci

* feat: Transitions, spacing, scroll fade, prompt area update (anomalyco#11168)

Co-authored-by: Github Action <action@github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aaroniker <4730431+aaroniker@users.noreply.github.com>

* chore: generate

* test(app): change language test (anomalyco#11295)

* chore(tui): remove unused experimental keys (anomalyco#11195)

* chore: generate

* release: v1.1.46

* commit

* fix(github): add owner parameter to app token for org-wide repo access

* release: v1.1.47

* ci: increase ARM runner to 8 vCPUs for faster Tauri builds

* fix(provider): exclude chat models from textVerbosity setting (anomalyco#11363)

* refactor(app): refactored tests + added project tests (anomalyco#11349)

* refactor(provider): remove google-vertex-anthropic special case in ge… (anomalyco#10743)

* fix: handle redirected_statement treesitter node in bash permissions (anomalyco#6737)

* test: add llm.test.ts (anomalyco#11375)

* docs: update agents options section to include color and top_p options (anomalyco#11355)

* fix: ensure ask question tool isn't included when using acp (anomalyco#11379)

* chore(deps): bump ai-sdk packages (anomalyco#11383)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>

* fix(provider): use snake_case for thinking param with OpenAI-compatible APIs (anomalyco#10109)

* chore: generate

* feat: make skills invokable as slash commands in the TUI

- Add Skill.content() method to load skill template content from SKILL.md files
- Modify Command.list() to include skills as invokable commands
- Add 'skill' boolean property to Command.Info schema
- Update autocomplete to show skills with (Skill) label in slash commands
- Regenerate SDK to include skill property in Command type

* feat(build): respect OPENCODE_MODELS_URL env var (anomalyco#11384)

* Revert "feat: make skills invokable as slash commands in the TUI"

This reverts commit 8512655.

* feat(opencode): add copilot specific provider to properly handle copilot reasoning tokens (anomalyco#8900)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>

* chore: generate

* ci: schedule beta workflow hourly to automate sync runs

* ci: allow manual beta workflow trigger so users can release on demand instead of waiting for hourly schedule

* ci: remove workflow restrictions to allow all PR triggers for broader CI coverage

* ci: remove pull-request write permissions from beta workflow

* fix: ensure the mistral ordering fixes also apply to devstral (anomalyco#11412)

* core: prevent parallel test runs from contaminating environment variables

* ci: run tests automatically when code is pushed to dev branch

* fix: don't --follow by default for grep and other things using ripgrep (anomalyco#11415)

* feat: make skills invokable as slash commands in the TUI (anomalyco#11390)

* chore: generate

* core: ensure models configuration is not empty before loading

* ci: copy models fixture for e2e test consistency

* tui: allow specifying custom models file path via OPENCODE_MODELS_PATH

 Users can now configure their own models configuration file by setting the OPENCODE_MODELS_PATH environment variable, providing more flexibility for testing and configuration.

* sync

* chore: generate

* test: fix flaky test (anomalyco#11427)

* test(app): session actions (anomalyco#11386)

* Revert "feat: Transitions, spacing, scroll fade, prompt area update (anomalyco#11168)" (anomalyco#11461)

Co-authored-by: adamelmore <2363879+adamdottv@users.noreply.github.com>

* release: v1.1.48

* fix(app): session header 'share' button to hug content (anomalyco#11371)

* fix(pty): Add UTF-8 encoding defaults for Windows PTY (anomalyco#11459)

* feat(app): add skill slash commands (anomalyco#11369)

* Revert "feat(app): add skill slash commands" (anomalyco#11484)

* feat(opencode): add reasoning variants support for SAP AI Core (anomalyco#8753)

Co-authored-by: Github Action <action@github.com>

* docs: fix documentation issues (anomalyco#11435)

Co-authored-by: damaozi <1811866786@qq.com>

* fix(nix): restore native runners for darwin hash computation (anomalyco#11495)

* fix(provider): use process.env directly for runtime env mutations (anomalyco#11482)

* tweak: show actual retry error message instead of generic error msg (anomalyco#11520)

* tui: enable password authentication for remote session attachment

Allow users to authenticate when attaching to a remote OpenCode session by supporting basic auth via a password flag or OPENCODE_SERVER_PASSWORD environment variable

* test(app): general settings, shortcuts, providers and status popover  (anomalyco#11517)

* chore: generate

* fix(ci): portable hash parsing in nix-hashes workflow (anomalyco#11533)

* ci: fix nix hash issue (anomalyco#11530)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>

* chore: update nix node_modules hashes

* fix(app): rendering question tool when the step are collapsed (anomalyco#11539)

* feat: add skill dialog for selecting and inserting skills (anomalyco#11547)

* fix: issue where you couldn't @ folders/files that started with a "." (anomalyco#11553)

* ci: fixed stale pr workflow (anomalyco#11310)

* fix(tui): conditionally render bash tool output (anomalyco#11558)

* feat(tui): add UI for skill tool in session view (anomalyco#11561)

* fix(tui): remove extra padding between search and results in dialog-select (anomalyco#11564)

* fix: correct pluralization of match count in grep and glob tools (anomalyco#11565)

* fix: ensure switching anthropic models mid convo on copilot works without errors, fix issue with reasoning opaque not being picked up for gemini models (anomalyco#11569)

* fix(app): show retry status only on active turn (anomalyco#11543)

* docs: improve zh-TW punctuation to match Taiwan usage (anomalyco#11574) (anomalyco#11589)

* docs: add Turkish README translation (anomalyco#11524)

* fix(app): use static language names in Thai localization (anomalyco#11496)

* fix(app): binary file handling in file view (anomalyco#11312)

* chore: generate

* fix: allow user plugins to override built-in auth plugins (anomalyco#11058)

Co-authored-by: JosXa <info@josxa.dev>

* docs: prefer wsl over native windows stuff (anomalyco#11637)

* fix(ecosystem): fix link Daytona  (anomalyco#11621)

* fix(tui): remove outer backtick wrapper in session transcript tool formatting (anomalyco#11566)

Co-authored-by: Claude <noreply@anthropic.com>

* fix: opencode hanging when using client.app.log() during initialization (anomalyco#11642)

* fix: prevent duplicate AGENTS.md injection when reading instruction files (anomalyco#11581)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>

* fix(opencode): scope agent variant to model (anomalyco#11410)

* chore: reduce nix fetching (anomalyco#11660)

* chore: generate

* fix(desktop): nix - add missing dep (anomalyco#11656)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>

* fix: prompt caching for opus on bedrock (anomalyco#11664)

* chore: update nix node_modules hashes

* fix: variant logic for anthropic models through openai compat endpoint (anomalyco#11665)

* fix: when using codex sub, send the custom agent prompts as a separate developer message (previously sent as user message but api allows for instructions AND developer messages) (anomalyco#11667)

Co-authored-by: Carlos <carloscanas942@gmail.com>

* test(app): workspace tests (anomalyco#11659)

* docs (web): Update incorrect Kimi model name in zen.mdx (anomalyco#11677)

* zen: add minimax logo (anomalyco#11682)

* feat(ui): Select, dropdown, popover styles & transitions (anomalyco#11675)

* chore: generate

* feat(ui): Smooth fading out on scroll, style fixes (anomalyco#11683)

* chore: generate

* feat(app): show skill/mcp badges for slash commands

Display 'skill' or 'mcp' badge instead of 'custom' for slash commands
based on their source type. This provides better clarity to users about
where each command comes from.

* fix(app): hide badge for builtin slash commands

Add source: 'command' to builtin and config-defined commands so they
don't show a 'custom' badge. Only MCP and skill commands show badges.

* fix: adjust resolve parts so that when messages with multiple @ references occur, the tool calls are properly ordered

* test: add unit test

* fix(plugin): correct exports to point to dist instead of src

The package.json exports were pointing to ./src/*.ts but the published
package only includes the dist/ folder. This caused 'Cannot find module'
errors when custom tools tried to import @opencode-ai/plugin.

Changed exports from:
  ".": "./src/index.ts"
  "./tool": "./src/tool.ts"

To:
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
  "./tool": { "types": "./dist/tool.d.ts", "import": "./dist/tool.js" }

* ci: prevent rate limit errors when fetching team PRs for beta releases

* ci: collect all failed PR merges and notify Discord

* ci: add DISCORD_ISSUES_WEBHOOK_URL secret to beta workflow

* ci: add --discord-webhook / -d CLI option for custom Discord webhook URL

* ci: remove parseArgs CLI option and use environment variable directly

* ci: rewrite beta script to use proper Bun shell patterns

* ci: post PR comments when beta merge fails instead of Discord notifications

* ci: add --label beta filter to only process PRs with beta label

* ci: change trigger from scheduled cron to PR labeled events with beta label condition

* ci: add synchronize event and check for beta label using contains()

* ci: centralize team list in @opencode-ai/script package and use beta label filter

* ci: run beta workflow on hourly schedule only

* ci: allow manual dispatch for beta workflow

* ci: skip force push when beta branch is unchanged

* core: allow starting new sessions after errors by fixing stuck session status

* tui: fix task status to show current tool state from message store

* ci: skip unicode filename test due to inconsistent behavior causing CI failures

* ignore: switch commit model to kimi-k2.5 for improved command execution reliability

* ci: restrict nix-hashes workflow to dev branch pushes only

Remove pull_request trigger and limit push trigger to dev branch to prevent

unnecessary workflow runs on feature branches and PRs. The workflow will now

only execute when dependency files change on the dev branch.

* ci: Fix Pulumi version conflict in deploy workflow

Added a workaround to fix Pulumi version conflict in the deployment workflow.

* docs: Restructure AGENTS.md style guide with organized sections and code examples

* Revert "fix(plugin): correct exports to point to dist instead of src"

This reverts commit 7417e6e.

* ci: enable typecheck on push to dev branch to catch type errors immediately after merge

* Use opentui OSC52 clipboard (anomalyco#11718)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>

* Add spinner animation for Task tool (anomalyco#11725)

* Simplify directory tree output for prompts (anomalyco#11731)

* fix: session title generation with OpenAI models. (anomalyco#11678)

* fix(opencode): give OPENCODE_CONFIG_CONTENT proper priority for setting config based on docs (anomalyco#11670)

* Revert "Use opentui OSC52 clipboard (anomalyco#11718)"

This reverts commit 8e985e0.

* tui: show exit message banner (anomalyco#11733)

* fix: convert system message content to string for Copilot provider (anomalyco#11600)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Resolve catchup-001 app/ui conflict set

* Fix app/desktop type drift in catchup batch 001

* Use GitHub-hosted Ubuntu runners for PR checks

* Replace Blacksmith workflow runners with GitHub-hosted labels

* Honor OPENCODE_DISABLE_PROJECT_CONFIG in config loading

* Order turbo typecheck by dependency graph

* Exit e2e seed script after completion

* Default auth config to disabled

* Run app e2e only in Linux test workflow

* Align Playwright install cache with test runtime env

* Respect disable-project-config in server auth loader

* Fix app e2e local server cleanup

* Default local e2e runner to disable project config

---------

Co-authored-by: opencode <opencode@sst.dev>
Co-authored-by: Hegyi Áron Ferenc <hegyi.aron101@gmail.com>
Co-authored-by: Brendan Allan <git@brendonovich.dev>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Ryan Vogel <ryan@mandarin3d.com>
Co-authored-by: Ravi Kumar <82090231+Raviguntakala@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Goni Zahavy <goni1993@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Frank <frank@anoma.ly>
Co-authored-by: Spoon <212802214+spoons-and-mirrors@users.noreply.github.com>
Co-authored-by: Dax <mail@thdxr.com>
Co-authored-by: Mert Can Demir <validatedev@gmail.com>
Co-authored-by: Filip <34747899+neriousy@users.noreply.github.com>
Co-authored-by: Mikhail Levchenko <mishkun.lev@gmail.com>
Co-authored-by: Dax Raad <d@ironbay.co>
Co-authored-by: Rahul A Mistry <149420892+ProdigyRahul@users.noreply.github.com>
Co-authored-by: adamelmore <2363879+adamdottv@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Aaron Iker <aaron@anoma.ly>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aaroniker <4730431+aaroniker@users.noreply.github.com>
Co-authored-by: Idris Gadi <85882535+IdrisGit@users.noreply.github.com>
Co-authored-by: Michael Yochpaz <myochpaz@redhat.com>
Co-authored-by: Patrick Schiel <p.schiel@gmail.com>
Co-authored-by: Cesar Garcia <128240629+Chesars@users.noreply.github.com>
Co-authored-by: Benjamin Bartels <benjamin@bartels.dev>
Co-authored-by: Steffen Deusch <steffen@deusch.me>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
Co-authored-by: Alex Yaroshuk <34632190+alexyaroshuk@users.noreply.github.com>
Co-authored-by: 陆奕丞 <01luyicheng@gmail.com>
Co-authored-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Co-authored-by: 大猫子 <ll1042668699@gmail.com>
Co-authored-by: damaozi <1811866786@qq.com>
Co-authored-by: Jérôme Benoit <jerome.benoit@sap.com>
Co-authored-by: adamjhf <50264672+adamjhf@users.noreply.github.com>
Co-authored-by: Alper Kartkaya <114335677+AlperKartkaya@users.noreply.github.com>
Co-authored-by: Joscha Götzer <joscha.goetzer@gmail.com>
Co-authored-by: JosXa <info@josxa.dev>
Co-authored-by: Axel Sarmiento Mrak <96851183+AxelMrak@users.noreply.github.com>
Co-authored-by: zerone0x <hi@trine.dev>
Co-authored-by: Desmond Sow <desmondsow@hotmail.com>
Co-authored-by: YeonGyu-Kim <code.yeon.gyu@gmail.com>
Co-authored-by: neavo <neavo@neavo.me>
Co-authored-by: Caleb Norton <n0603919@outlook.com>
Co-authored-by: Rohan Godha <git@rohangodha.com>
Co-authored-by: Carlos <carloscanas942@gmail.com>
Co-authored-by: Sumit Srivastava <sumitsrisumit@gmail.com>
Co-authored-by: R44VC0RP <n01508660@unf.edu>
Co-authored-by: Sebastian <hasta84@gmail.com>
Co-authored-by: Mathias Beugnon <mathias@beugnon.fr>
Co-authored-by: OpeOginni <107570612+OpeOginni@users.noreply.github.com>
Co-authored-by: Jigar <jpatel4404@gmail.com>
fanjia1024 pushed a commit to fanjia1024/opencode that referenced this pull request Feb 10, 2026
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.

User auth plugins cannot override built-in plugins in CLI auth flow

2 participants