Skip to content

OpenCode plugin missing default export — plugin never loaded by plugin loader #2516

Description

@sacrtap

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

  1. Run rtk init -g --opencode
  2. Check the generated plugin file: ~/.config/opencode/plugins/rtk.ts
  3. Start OpenCode and run git status via the bash tool
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions