opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(config): deduplicate plugins by name with priority-based resolution

Open devxoul opened this issue 2 months ago • 2 comments

Summary

  • Deduplicate plugins by name so that when the same plugin is loaded from multiple sources, only the highest priority one is used

Problem

Previously, if the same plugin existed in both opencode.json and .opencode/plugin/ directory, both would be loaded.

Solution

  • getPluginName: Extract canonical name from plugin specifier (supports file:// URLs, npm packages, scoped packages)
  • deduplicatePlugins: Deduplicate by name, later entries (higher priority) win

Priority (highest to lowest)

  1. Local plugin/ directory
  2. Local opencode.json
  3. Global plugin/ directory
  4. Global opencode.json

Tests

  • Unit tests for getPluginName (file URLs, npm packages, scoped packages)
  • Unit tests for deduplicatePlugins (priority resolution, order preservation)
  • Integration test for local plugin overriding global config

devxoul avatar Dec 22 '25 13:12 devxoul

@rekram1-node Thanks for the review. I updated some implementation. Feel free to check when you're available!

devxoul avatar Dec 23 '25 06:12 devxoul

Just rebased the latest dev branch and resolved conflicts.

devxoul avatar Dec 29 '25 06:12 devxoul

this pr is genius

junhoyeo avatar Jan 09 '26 04:01 junhoyeo

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[bot] avatar Jan 09 '26 05:01 github-actions[bot]

Fixes #7427

devxoul avatar Jan 09 '26 05:01 devxoul

/review

rekram1-node avatar Jan 09 '26 07:01 rekram1-node

lgtm

github-actions[bot] avatar Jan 09 '26 07:01 github-actions[bot]

can u rebase this? looks like a bunch of random commits got picked up

rekram1-node avatar Jan 09 '26 07:01 rekram1-node

can u rebase this? looks like a bunch of random commits got picked up

sure thing, just rebased @rekram1-node

devxoul avatar Jan 09 '26 07:01 devxoul

/review

rekram1-node avatar Jan 09 '26 08:01 rekram1-node

lgtm

github-actions[bot] avatar Jan 09 '26 08:01 github-actions[bot]