You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenCode plugin: tool.execute.before hook never fires — auto-rewrite broken #1706
After rtk init -g --opencode, the plugin file is created at ~/.config/opencode/plugins/rtk.ts. The plugin loads successfully (verified), but Bash commands are never auto-rewritten. Running git status produces raw output instead of rtk git status.
Root Cause Found
The plugin's tool.execute.before hook is never dispatched by OpenCode. I added file-based debug logging to both tool.execute.before and tool.execute.after hooks in the plugin:
Result: The plugin loads (10+ PLUGIN_LOADED log files created), but zeroBEFORE_ENTER or AFTER log files are ever created. The hooks are returned by the plugin initialization function but OpenCode never calls them.
Key Finding
The engram plugin (~/.config/opencode/plugins/engram.ts) uses tool.execute.after in the same project, with the same import (@opencode-ai/plugin), and its hooks do fire correctly. This suggests the issue is specific to how the RTK plugin is structured, not a general OpenCode plugin dispatch problem.
The OpenCode plugin works correctly. The issue was stale opencode web processes that prevented plugin hooks from dispatching to newly installed plugins.
Root cause: Multiple opencode web processes were running (PIDs: 278, 99331, 99307). The plugin file was created by rtk init, but the hooks were never dispatched because the old processes cached the plugin state from before RTK was installed.
Fix: Kill all opencode processes and restart cleanly:
pkill -f "opencode web"&& pkill -f "opencode-cli"# Then restart opencode
Verification: After clean restart, the plugin auto-rewrites all bash commands:
git status → rtk git status (50% token savings)
ls -la → rtk ls -la . (78% savings)
date → rtk fallback: date (0% savings, passthrough — proves intercept)
The plugin code itself (hooks/opencode/rtk.ts) is correct — no modifications needed.
Activity
rocordov commentedon May 4, 2026
Resolution: Stale Processes, Not a Plugin Bug
The OpenCode plugin works correctly. The issue was stale
opencode webprocesses that prevented plugin hooks from dispatching to newly installed plugins.Root cause: Multiple
opencode webprocesses were running (PIDs: 278, 99331, 99307). The plugin file was created byrtk init, but the hooks were never dispatched because the old processes cached the plugin state from before RTK was installed.Fix: Kill all opencode processes and restart cleanly:
Verification: After clean restart, the plugin auto-rewrites all bash commands:
git status→rtk git status(50% token savings)ls -la→rtk ls -la .(78% savings)date→rtk fallback: date(0% savings, passthrough — proves intercept)The plugin code itself (hooks/opencode/rtk.ts) is correct — no modifications needed.
rocordov commentedon May 4, 2026
Closing: plugin works correctly. Stale processes were the cause, not a code bug.