Skip to content

Windows: bundled pi / opencode / omp plugins exec bare wt, which is the Windows Terminal alias #4697

Closed

Description

@tian-yu200

Summary

worktrunk ships agent plugins that invoke the CLI by the bare name wt. On Windows
wt is already taken by the Windows Terminal app-execution alias
(%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe), which is on PATH ahead of any
worktrunk install directory. So wt config state marker set 🤖 does not reach
worktrunk at all — it launches Windows Terminal, which tries to start a program named
config and pops an error window on the user's desktop.

The repo already solves this correctly for the shell hooks: plugins/worktrunk/hooks/wt.sh
honours WORKTRUNK_BIN, prefers git-wt.exe on MSYS/Cygwin, and explicitly rejects a
wt that resolves into *WindowsApps*. The three bundled TypeScript entry points don't
use that resolver — they hardcode "wt". This is a follow-up to #133 (closed by #134,
which added the worktrunk/git-wt shim): the shim exists, but the plugins don't use it.

Observed symptom

A Windows Terminal window appears spontaneously, titled config, containing:

[出现错误 2147942402 (0x80070002) (启动"config state marker set 🤖"时)] 系统找不到指定的文件。

(0x80070002 = ERROR_FILE_NOT_FOUND.) The window stays open, so every agent
start/end/clear event stacks up more of them.

Affected call sites

Verified unchanged on main today (blob SHAs 3430ac2 for dev/pi-extension.ts,
e25d45e for dev/opencode-plugin.ts); line numbers below are from commit 786978fd
(v0.81.0), reading the installed copies:

file line call
dev/pi-extension.ts 22 await pi.exec("wt", ["config", "state", "marker", ...args], { cwd })
dev/omp-hook.ts 21 await pi.exec("wt", ["config", "state", "marker", ...args], { … })
dev/opencode-plugin.ts 43 await execute("wt", ["config", "state", "marker", ...args], { cwd: directory })
dev/opencode-plugin.ts 89 const { stdout } = await execute("wt", args, …) — inside the generic wt() wrapper

That last one is the larger problem: wt() at :89 backs the switch and remove
calls at :125 and :131, so on Windows those are aimed at Windows Terminal as well —
worktree switch/remove through the OpenCode plugin cannot reach worktrunk. (Stated from
the code path; the marker calls are the ones I reproduced.)

Why nobody sees an error

execFile returns exit code 0 for these calls (Windows Terminal accepts the
invocation and reports the failure only in a GUI window), and each of the three call
sites wraps it in try { … } catch {}. So nothing is written to any log — no agent log,
no worktrunk log, no Windows Terminal log. The user just gets mystery popups. Reproduced:

node -e 'require("child_process").execFile("wt", ["config","state","marker","set","x"], (e,o,s) => console.log(e ? e.code : 0, JSON.stringify(o), JSON.stringify(s)))'
// → 0 "" ""      (and a Windows Terminal error window appears)

(Get-Command wt -All).Source → C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe.

Suggested fix

Port the existing hooks/wt.sh policy into a small shared TS helper used by all three
entry points, e.g.

function resolveWorktrunkBin(): string {
  if (process.env.WORKTRUNK_BIN) return process.env.WORKTRUNK_BIN;
  if (process.platform === "win32") return "git-wt.exe";   // unambiguous, shipped since #134
  return "wt";
}

Two notes on making it durable rather than a one-off:

  1. git-wt.exe is only guaranteed to be on PATH for some installs. If the helper can
    be given the absolute path of the binary that installed the plugin (the installer
    knows it), that is strictly better than a name lookup.
  2. Because these failures are silent, it would be worth having the plugins detect the
    collision once and surface it (e.g. if wt --version output doesn't mention
    worktrunk, warn instead of swallowing) — otherwise the next Windows name collision
    will be just as invisible.

Happy to open a PR for the helper + the four call sites if you'd like it in that shape.

Environment

  • worktrunk v0.81.0, Windows 11, Git for Windows (MSYS bash) + PowerShell + Windows Terminal 1.24
  • Agents affected on this machine: pi (D:\pi\bin\pi.exe, extension installed by wt config plugins pi install) and OpenCode (plugin installed by wt config plugins opencode install). The Claude Code and Codex plugins are not affected because they route through hooks/wt.sh.

Activity

  1. worktrunk-bot commented on Nov 4, 2026

    @worktrunk-bot
    Collaborator

    I opened #4698 with a fix, and its CI is green. A maintainer will decide whether to merge it.

    The pi, oh-my-pi, and OpenCode plugins now choose the binary the way hooks/wt.sh does. They use WORKTRUNK_BIN if it's set. On Windows they otherwise look for git-wt.exe first, and accept a wt.exe only when the first one on PATH isn't under WindowsApps. If no usable binary turns up, marker updates are skipped quietly. OpenCode's worktree switch/remove fails with an error that names git-wt.exe and WORKTRUNK_BIN, rather than handing the command to Windows Terminal.

    I checked this with a simulated Windows PATH, not on a real Windows host. Once it lands, it would help to confirm on your machine that the popups stop. Run wt config plugins pi install and wt config plugins opencode install again to replace the installed copies.

    PR #4698 doesn't include your second suggestion: warning when the wt on PATH turns out not to be worktrunk.

  2. added a commit that references this issue on Nov 4, 2026
    3bf9166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions