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 status via the bash tool
- Observe: command executes as raw
git status, not rtk 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 RtkOpenCodePlugin
Compare 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 load
Impact
- 100% of OpenCode users who install via
rtk init -g --opencode have RTK silently disabled
rtk init --show reports [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 to rtk git status ✅
git diff → rewritten to rtk git diff ✅
docker ps → rewritten to rtk docker ps ✅
make test-parallel → rewritten to rtk make test-parallel ✅
playwright test → rewritten to rtk playwright test ✅
sudo npm run build → rewritten to sudo 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.
Summary
The OpenCode plugin generated by
rtk init -g --opencodeexports only a named export (RtkOpenCodePlugin) but lacks adefault export. OpenCode's plugin loader requires a default export to load the plugin module, so the RTK plugin is silently never loaded — thetool.execute.beforehook never fires, and all bash commands execute without RTK rewriting.Environment
Steps to Reproduce
rtk init -g --opencode~/.config/opencode/plugins/rtk.tsgit statusvia the bash toolgit status, notrtk git statusRoot Cause
OpenCode's plugin type definition (
@opencode-ai/plugin) specifies:The plugin loader expects a
default exportmatching thePlugintype. The generatedrtk.tsonly has:Compare with a working plugin in the same directory (
openviking-memory.ts), which has both:Impact
rtk init -g --opencodehave RTK silently disabledrtk init --showreports[ok] OpenCode: plugin installed— no warning that the plugin won't loadFix
Add
export default RtkOpenCodePluginto the end of the generated plugin template.The source template is likely in
src/orhooks/— whereverrtk init --opencodegenerates thertk.tscontent.Verification
After manually adding
export default RtkOpenCodePluginto~/.config/opencode/plugins/rtk.tsand 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 --showthat verifies the plugin file containsexport default. If missing, warn the user.