Skip to content

fix(opencode): restore external plugin loading in Plugin.init() (#408)#409

Merged
randomm merged 2 commits intodevfrom
feature/issue-408-plugin-loading
Apr 10, 2026
Merged

fix(opencode): restore external plugin loading in Plugin.init() (#408)#409
randomm merged 2 commits intodevfrom
feature/issue-408-plugin-loading

Conversation

@randomm
Copy link
Copy Markdown
Owner

@randomm randomm commented Apr 10, 2026

What happened

Plugin.init() was a stub that only logged 'plugin system stub - init called'. External plugins from ~/.config/opencode/plugins/ were never loaded.

What changed

  • Replaced stub init() with real implementation that loads internal plugins (CodexAuthPlugin, CopilotAuthPlugin) and external plugins via PluginLoader.loadExternal()
  • Creates an SDK client with Server.App().fetch() adapter for in-process routing
  • Respects OPENCODE_DISABLE_DEFAULT_PLUGINS flag
  • Resets hooks on re-init to prevent accumulation across multiple calls
  • Fixed pre-existing as any casts: getServerPlugin() now uses PluginModule type, trigger() uses keyof Hooks
  • Fixed fetch adapter type: wrapped with Promise.resolve() to handle Hono's synchronous Response
  • Removed unused imports (Session, NamedError, errorMessage)
  • Added plugin-loading feature entry to fork-features manifest

Quality Gates

  • No @ts-ignore, as any, or quality gate violations in source code
  • Adversarial review: APPROVED (2 rounds)
  • Typecheck passes with 0 errors
  • Fork-features manifest updated with plugin-loading entry
  • Tests for plugin loading

Fixes #408

randomm added 2 commits April 11, 2026 00:16
- Replace stub Plugin.init() with real implementation that loads internal
  and external plugins
- Create SDK client with Server.App().fetch adapter for in-process routing
- Respect OPENCODE_DISABLE_DEFAULT_PLUGINS flag for internal plugins
- Load external plugins via PluginLoader.loadExternal() with error reporting
- Reset hooks on re-init to prevent accumulation
- Fix pre-existing as any casts: use PluginModule type and keyof Hooks
- Remove unused imports (Session, NamedError, errorMessage)
- Add plugin-loading feature entry to fork-features manifest
- Add plugin-loading tests with mockConfig helper
- Replace Promise.resolve() with async/await on fetch adapter for proper error propagation
- Remove explicit Config.PluginOrigin[] type annotation, use TypeScript inference
@randomm randomm merged commit 97e8dd7 into dev Apr 10, 2026
1 check passed
@randomm randomm deleted the feature/issue-408-plugin-loading branch April 10, 2026 21:29
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.

fix: restore external plugin loading in Plugin.init()

1 participant