Skip to content

OpenCode plugin (tool.execute.before) never fires on Windows — auto-rewrite broken #1993

Closed as duplicate

Description

@JettHayes

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

  1. Install RTK on Windows, place rtk.exe in a directory on PATH
  2. Run rtk init -g --opencode
  3. Open OpenCode and run any git or shell command
  4. Observe: commands are never rewritten to rtk equivalents

Additional context

  • where.exe rtk returns D:\rtk_tools\rtk.exe correctly inside OpenCode's shell
  • rtk rewrite "git status" correctly returns rtk git status when run manually
  • The hook structure appears identical to the master branch hooks/opencode/rtk.ts
  • Issue OpenCode plugin: tool.execute.before hook never fires — auto-rewrite broken #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?

Activity

  1. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    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.

  2. amnesiaof commented on Sep 2, 2026

    @amnesiaof
    Contributor

    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.

  3. KuSh commented on Sep 19, 2026

    @KuSh
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions