OpenCode plugin (tool.execute.before) never fires on Windows — auto-rewrite broken
Title
OpenCode plugin (tool.execute.before) never fires on Windows — auto-rewrite broken
Environment
- RTK: latest (binary at D:\rtk_tools\rtk.exe)
- OpenCode: latest
- OS: Windows 11
- Shell: CMD / PowerShell
Symptom
After rtk init -g --opencode, the plugin file is created at C:\Users\<user>\.config\opencode\plugins\rtk.ts. The plugin loads successfully, but bash commands are never auto-rewritten. Running git status produces raw output instead of rtk git status.
Root cause identified
The original rtk.ts uses which rtk to detect the binary, which does not exist on Windows. This causes the plugin to immediately return {} and disable itself. Replaced with where.exe rtk as primary check with which rtk as fallback — binary is confirmed in PATH — but the tool.execute.before hook still never fires.
Steps to reproduce
- Install RTK on Windows, place
rtk.exein a directory on PATH - Run
rtk init -g --opencode - Open OpenCode and run any git or shell command
- Observe: commands are never rewritten to
rtkequivalents
Additional context
where.exe rtkreturnsD:\rtk_tools\rtk.execorrectly inside OpenCode's shellrtk rewrite "git status"correctly returnsrtk git statuswhen run manually- The hook structure appears identical to the master branch
hooks/opencode/rtk.ts - Issue #1706 (macOS) was resolved by killing stale processes — no stale processes exist on this Windows setup, issue persists after clean restart
Question
Is tool.execute.before hook dispatch broken specifically on Windows, or is there a Windows-specific plugin format required?
wshm · Automated triage by AI
🔍 Automated Triage
| 🐛 Category | bug |
| 🟠 Priority | high |
| 🎯 Confidence | 83% |
Summary
OpenCode tool.execute.before hook dispatch does not fire on Windows, completely breaking auto-rewrite; investigate Windows-specific plugin execution path in hooks/opencode/rtk.ts
📁 Relevant files
hooks/opencode/rtk.ts
Triaged automatically by wshm · This is an automated analysis, not a human review.
Confirmed on Windows 11 + OpenCode CLI (rtk 0.47.0). Root causes: (1) no Bun $ shell in the plugin context → silent TypeError, hooks never register; (2) which is Unix-only; (3) rtk rewrite exits non-zero on success (exit 3), so stdout must be recovered from the exception. Same approach as #3330 (which closes #3326) works — worth combining efforts there.
Closing as a duplicate of #3326, which tracks the same problem with the more complete discussion. Please follow up there; if your case differs in a way that issue does not cover, comment here and it can be reopened.