opencode
opencode copied to clipboard
Bug: file:// plugins with same filename incorrectly deduplicated
Bug Description
Multiple file:// plugins with the same entry point filename (e.g., index.js) are incorrectly treated as duplicates during plugin loading, causing only the last one to load.
Steps to Reproduce
- Create a config with multiple file:// plugins using standard entry points:
{
"plugin": [
"file:///path/to/plugin-a/dist/index.js",
"file:///path/to/plugin-b/dist/index.js",
"file:///path/to/plugin-c/dist/index.js"
]
}
- Start OpenCode with debug logging:
OPENCODE_LOG_LEVEL=DEBUG opencode run "test" 2>&1 | grep "loading plugin"
- Observe that only the last plugin loads
Expected Behavior
All three plugins should load since they have different paths.
Actual Behavior
Only plugin-c loads. The deduplication logic in getPluginName() extracts only the filename ("index") for all three plugins, marking them as duplicates.
Root Cause
In packages/opencode/src/config/config.ts, the getPluginName() function extracts only the filename for file:// URLs:
if (plugin.startsWith("file://")) {
return path.parse(new URL(plugin).pathname).name // Returns "index" for all
}
This was designed for npm package deduplication but doesn't account for file:// plugins where:
- Multiple plugins may use the same filename (standard practice:
index.js) - Plugins in different directories should not be considered duplicates
- Even plugins in the same directory with different filenames should be allowed
Impact
- Users cannot use multiple local plugins with standard entry point names
- No warning is shown when plugins are silently dropped
- Workaround requires renaming entry points to unique names (non-standard)
Environment
- OpenCode version: 1.1.23
- Node/Bun version: Bun 1.3.5
- OS: Linux
Related
This affects anyone using local plugin development with standard JavaScript conventions.