Repository navigation
Description
Summary
The OpenCode plugin generated by rtk init -g --opencode exports only a named export (RtkOpenCodePlugin) but lacks a default export. OpenCode's plugin loader requires a default export to load the plugin module, so the RTK plugin is silently never loaded — the tool.execute.before hook never fires, and all bash commands execute without RTK rewriting.
Environment
- rtk version: 0.42.4
- opencode version: 1.17.8
- OS: macOS (darwin)
- Install method: Homebrew
Steps to Reproduce
- Run
rtk init -g --opencode - Check the generated plugin file:
~/.config/opencode/plugins/rtk.ts - Start OpenCode and run
git statusvia the bash tool - Observe: command executes as raw
git status, notrtk git status
Root Cause
OpenCode's plugin type definition (@opencode-ai/plugin) specifies:
export type PluginModule = {
id?: string;
server: Plugin;
tui?: never;
};The plugin loader expects a default export matching the Plugin type. The generated rtk.ts only has:
export const RtkOpenCodePlugin: Plugin = async ({ $ }) => { ... }
// ← missing: export default RtkOpenCodePluginCompare with a working plugin in the same directory (openviking-memory.ts), which has both:
export const OpenVikingMemoryPlugin = async (input: PluginInput): Promise<Hooks> => { ... }
export default OpenVikingMemoryPlugin // ← this makes it loadImpact
- 100% of OpenCode users who install via
rtk init -g --opencodehave RTK silently disabled rtk init --showreports[ok] OpenCode: plugin installed— no warning that the plugin won't load- Users see no errors; commands just pass through unfiltered
Fix
Add export default RtkOpenCodePlugin to the end of the generated plugin template.
The source template is likely in src/ or hooks/ — wherever rtk init --opencode generates the rtk.ts content.
Verification
After manually adding export default RtkOpenCodePlugin to ~/.config/opencode/plugins/rtk.ts and restarting OpenCode:
git status→ rewritten tortk git status✅git diff→ rewritten tortk git diff✅docker ps→ rewritten tortk docker ps✅make test-parallel→ rewritten tortk make test-parallel✅playwright test→ rewritten tortk playwright test✅sudo npm run build→ rewritten tosudo rtk npm run build✅ (transparent prefix)
Suggested Improvement
Add a runtime check in rtk init --show that verifies the plugin file contains export default. If missing, warn the user.
Activity
molloyzak13 commentedon Jun 19, 2026
Adding
export default RtkOpenCodePlugintohooks/opencode/rtk.tsshould fix this. The file gets embedded at build time and re-written on eachrtk init -g --opencode, so it covers both fresh installs and existing setups.molloyzak13 commentedon Jun 19, 2026
Adding
export default RtkOpenCodePlugintohooks/opencode/rtk.tsshould fix this. The file gets embedded at build time and re-written on eachrtk init -g --opencode, so it covers both fresh installs and existing setups.pszymkowiak commentedon Jun 25, 2026
🔍 Automated Triage
bughighSummary
Generated OpenCode plugin template missing
export default— RTK is silently disabled for 100% of OpenCode users; PR #2566 already open with a fix.📁 Relevant files
src/init/opencode_plugin_template.tsTriaged automatically by wshm · This is an automated analysis, not a human review.
fix(rtk): fix OpenCode plugin, Maven support, loop/builtin warnings
santiago1393 commentedon Jul 19, 2026
Hey team, just tried this in my local and it does not seem to be working as expected. Is there another solution to this problem? thks.
dylldev commentedon Oct 4, 2026
Heads up on the suggested fix in this thread: adding a bare
export default RtkOpenCodePluginresolves this on OpenCode 1.17.x (V1 loader), but it is no longer sufficient on current OpenCode, and it now fails differently.On OpenCode 1.18.34 the TUI/desktop/shared server uses the V2 loader. With a bare default export you get past the first schema check and straight into the next one:
The V2 loader requires the default export to carry an
idplussetup()(oreffect()), and it ignoresserver()entirely — so a V1 plugin exported as the default loads without error and then silently does nothing. That silent case is what #4311 and the discussion in #3463 cover.Verified working shape on 1.18.34 + rtk 0.51.0 (both halves kept, so the V1
opencode runCLI keeps working too):A plain object works in place of
Plugin.define(...)—~/.config/opencode/plugins/has nonode_modules, and the generated file's only import is type-only, so there is no runtime@opencode/pluginto resolve.Full working notes and the three porting gotchas are in #3463. Suggest closing this in favour of that one.