Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

docs(windows): agent hook wrappers, .cmd shims and the codex identity gate

review947d9b518d95
diff --git a/CLAUDE.md b/CLAUDE.md
index 640506558..4b093a969 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -2923,6 +2923,15 @@ else, and its context links must keep classifying across restarts).
remote installers at once; a second repair mechanism would be exactly the duplicated rule this
file warns about. It strips only OUR handler out of a definition, so a hook a user hand-merged
beside ours survives.
+ **Every agent except claude gets a Windows wrapper** (2026-10): gemini (PowerShell, its
+ `getShellConfiguration`), grok (PowerShell per its docs — unmeasured) and copilot (its
+ `powershell` key) cannot parse the POSIX line either, so `windows-hook-wrapper.ts` is the ONE
+ template (`buildWindowsHookWrapper`, codex's bytes pinned) and `buildManagedHookCommand(sp, {},
+ 'win32')` names `<agent>-hook.cmd` through the codex invocation. Its `platform` defaults to POSIX,
+ NOT `process.platform` — the SSH installers call it bare. `installHooksInto({windowsWrapper})`
+ writes the wrapper BEFORE the config; the managed-entry matcher pairs `<agent>.sh` with
+ `<agent>-hook.cmd` (`managedMarkersFor`) so an upgrade replaces the POSIX entry. Claude stays
+ POSIX (Git Bash).
- **A reused ControlMaster is not evidence of a live hook tunnel** (issue #735 — remote sessions
stuck on **Unknown**, no completion notifications, no unread dots). `connect()`'s reuse branch
returned the cached `hookEndpointPath` whenever `ssh -O check` answered, on the written-down
@@ -3980,6 +3989,14 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile
`open-agent` are verified-only at the Server handler boundary. A plain terminal keeps generic
node hook wiring but receives neither `NODETERM_AGENT_ID` nor `NODETERM_CANVAS_CONTROL`; missing
identity never defaults to Claude.
+ **Windows hosts**: a PowerShell/cmd-run agent cannot type `sh "<shim>"`, so a win32 core also
+ writes `nodeterm.cmd` / `context.cmd` beside the shims (`syncWindowsShLauncher` — finds Git for
+ Windows' `sh.exe`, passes `%*` through, fails LOUDLY without it) and the skills, the connect-time
+ note and the verify prompts say `& "<shim>.cmd"` for every agent outside
+ `POSIX_TOOL_SHELL_ON_WINDOWS` (claude only — its Bash tool is Git Bash). The dialect is
+ `shimDialectFor(agent, <the shim-owning core's platform>)` (`shared/agents/shim-invocation.ts`;
+ `context-link:info` now reports that platform); every builder defaults to POSIX, so SSH-host
+ skills and macOS/Linux bodies are byte-identical.
**SSH projects** (docs/ssh-agent-skills.md): the SAME shim + skill + blocks are put on the
remote host and KEPT current by the agent-tools check (`RemoteHooks.refreshAgentTools`: on every
connect and tunnel repair, rewriting only what differs from this build, managed-account skill
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d258adf6a..f01e746be 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -318,6 +318,13 @@ anything else. Board-level fields survive every transform — `pullLinks` is one
cannot read) and test Windows dispatch WITHOUT `windowsVerbatimArguments`; keep the `AutoRun`
refusal. Deep version: `docs/antigravity-agent.md` and CLAUDE.md § Agent support.
+- **On Windows, only claude runs POSIX.** Claude Code runs hooks and tools through Git Bash; codex,
+ gemini, grok and copilot run them in PowerShell/cmd.exe. So a hook command or a "run this shim"
+ line for any other agent goes through the `.cmd` helpers in
+ `src/core/agents/hooks/windows-hook-wrapper.ts` / `shared/agents/shim-invocation.ts`, and every
+ builder takes the RUNNING machine's platform with a POSIX default — never `process.platform`
+ inside a builder an SSH installer also calls. Deep version: CLAUDE.md § Hook installers.
+
- **Finding `agy` for hook installation is not enough to launch it.** The measured Windows
installer wrote `%LOCALAPPDATA%\agy\bin` into a `REG_SZ` user PATH, so command lookup kept the
percent expression literal and `agy` was not found even though its executable existed. Local
diff --git a/docs/codex-shared-identity.md b/docs/codex-shared-identity.md
index 5642763ea..368f1f406 100644
--- a/docs/codex-shared-identity.md
+++ b/docs/codex-shared-identity.md
@@ -321,6 +321,14 @@ both without either shell being edited (the two drifted once before — see CLAU
- **Mobile companion** (`~/projects/nodeterm-ios`) — N/A. It attaches to tmux sessions over the
transport protocol; which app-server a Codex session talks to is invisible to it, and the
`plain codex` chip is a canvas-node affordance the phone has no slot for. No protocol change owed.
+- **Windows** — deliberately OFF (phase 1). `refreshCodexIdentityCaps` returns early on `win32`
+ with `unavailableReason: 'unsupported-platform'` (no probe, no launcher write), `pty-manager`
+ prepends no launcher dir to the session PATH (`codexLauncherPathDir` is null there), and
+ Settings → Agents shows one muted line under Codex. It was already off by accident — the runtime
+ stat looks for an extensionless `codex`, and the launcher is an `sh` script cmd/PowerShell cannot
+ resolve by name — but silently. Phase 2 needs three device facts first (item 13 below) and then a
+ non-sh launcher (`nodeterm-codex.cmd` running a Node script under the Electron-as-Node or
+ session-host runtime, porting `buildCodexLauncherScript`'s bind/fallback/POST logic).
- **Kanban** — the mode lives in a store the card modal could read; the chip is on the canvas node
header only. Adding it to the card's expanded detail row is a small follow-up.
@@ -427,3 +435,10 @@ come first. Items 1, 2 and 5 fall out of a single capture run on one fresh node.
Electron's environment while the pane resolves `--remote unix://` from its own, so this is where
they diverge: confirm what actually happens — shared against the wrong home, or a start that
succeeds followed by a resume that misses.
+13. **Windows, before phase 2 is built.** On a Windows machine with the standalone codex install:
+ (a) does `%USERPROFILE%\.codex\packages\standalone\current\codex.exe` exist; (b) do
+ `codex app-server daemon start` / `version` work there, and over what control channel (named
+ pipe vs unix socket); (c) does `codex --remote <that endpoint>` accept it. Until all three hold,
+ the `unsupported-platform` gate stays. Also confirm today's gate: Settings → Agents shows the
+ muted line and a Codex node's PATH has no `codex-bin` entry.
+
diff --git a/docs/copilot-agent.md b/docs/copilot-agent.md
index 51e4a8332..12260368a 100644
--- a/docs/copilot-agent.md
+++ b/docs/copilot-agent.md
@@ -64,6 +64,11 @@ script to `~/.nodeterm/agent-hooks/copilot.sh`. It observes:
- turn completion (`Stop`);
- the closed notification types `permission_prompt` and `elicitation_dialog`.
+On Windows each entry also carries a `powershell` key — the one Copilot runs there — pointing at
+`~/.nodeterm/agent-hooks/copilot-hook.cmd` through `<abs cmd.exe> /d /c call "<wrapper> "`; the
+wrapper finds Git for Windows' `sh.exe` and runs the same `copilot.sh`. `bash` is kept, and an SSH
+host's file never gets the key.
+
`PermissionRequest` is deliberately not installed because it is a decision hook that can change
authorization. `ErrorOccurred` is omitted because recoverable errors can occur before a turn
continues. Unknown notifications are no-ops, preventing sticky NEEDS YOU badges.
@@ -112,3 +117,10 @@ suite:
progress refreshes live. Repeat from the phone's Chat screen over the relay.
8. ⌘M on a copilot node in an SSH project shows "Reading a remote GitHub Copilot session's
transcript isn't supported yet." with no Retry, and never a local conversation.
+9. Windows: `nodeterm-status.json` entries carry both `bash` and `powershell`; with Git for Windows
+ installed a turn flips RUNNING → IDLE and a permission prompt flips NEEDS YOU (i.e. Copilot does
+ run the `powershell` key, under PowerShell, and the wrapper invocation survives it). Without
+ Git, turns run with no hook error and the badge stays Unknown.
+10. Windows: from a Copilot node run `& "<userData>\canvas-control\nodeterm.cmd" list` (the line
+ the canvas skill now gives it) and a `--prompt "two words"` open; both arrive intact.
+
diff --git a/docs/gemini-agent.md b/docs/gemini-agent.md
index 88214331f..b2b38b253 100644
--- a/docs/gemini-agent.md
+++ b/docs/gemini-agent.md
@@ -609,4 +609,19 @@ SSH + surfaces
30. Phone Chat screen on a LOCAL gemini node over the relay: the same thread as ⌘M, the model
label under it.
31. Close a gemini node, reopen its transcript from "Recently closed": it reads.
+
+Windows (hook wrapper + .cmd shims; nothing here has run on a device yet)
+32. On Windows, start nodeterm once and open ~/.gemini/settings.json: every managed event holds ONE
+ entry, `C:\Windows\System32\cmd.exe /d /c call "<home>\.nodeterm\agent-hooks\gemini-hook.cmd "`,
+ and an older POSIX `if [ -r ...` entry is gone (replaced, not duplicated).
+33. With Git for Windows installed, repeat items 1-3 under BOTH pwsh.exe and Windows PowerShell
+ (gemini picks pwsh.exe when present, else powershell.exe; ComSpec=powershell wins over both):
+ RUNNING appears and clears, a real permission prompt flips the badge to NEEDS YOU.
+34. Rename/move Git out of the way (no sh.exe anywhere): a gemini turn still runs with no hook
+ error line in the TUI and the badge simply stays Unknown (the wrapper drains and exits 0).
+35. In a gemini node run the canvas skill's line, `& "<userData>\canvas-control\nodeterm.cmd" list`,
+ and the context skill's `& "<userData>\context-links\context.cmd" list`: both answer. Then
+ `... open-terminal --cmd=--version` and a `--prompt "two words"` value arrive intact.
+36. Draw a context link to a gemini node: the injected note names `context.cmd` with `& `, and
+ running it verbatim works.
```
diff --git a/docs/grok-agent.md b/docs/grok-agent.md
index e62a9b5b2..b34f0e9e4 100644
--- a/docs/grok-agent.md
+++ b/docs/grok-agent.md
@@ -748,3 +748,16 @@ Two traps with no code fix — appended so the numbering above stays stable
command palette and Settings → Agents, and flip the theme. If it reads as a smudge, the fix is a
size-specific viewBox nudge, not a colour change.
```
+33. **Windows: which interpreter runs a grok hook?** Grok's docs say PowerShell (`$VAR` is
+ rewritten to `$env:VAR` there) and the binary names both `powershell.exe` and `cmd.exe`, so on
+ Windows the hook file points at `grok-hook.cmd` through
+ `<abs cmd.exe> /d /c call "<wrapper> "` — the codex form, measured to run under either. NOT
+ measured for grok. Check `$GROK_HOME\hooks\nodeterm-status.json` holds that line, then that a
+ turn flips RUNNING → IDLE and a permission ask flips NEEDS YOU. If grok turns out to run hooks
+ through Git Bash instead, the unquoted backslashed `cmd.exe` path is mangled there and the fix
+ is to drop grok's `windowsWrapper` (one line in `hooks/grok.ts`).
+34. **Windows: grok's tool shell.** The canvas/context skills tell a grok node to run
+ `& "<userData>\canvas-control\nodeterm.cmd" <verb>` (PowerShell). Run `list` both ways from a
+ grok node; if grok's tool shell is cmd.exe the leading `& ` must go (the skill says so), and if
+ it is Git Bash grok belongs in `POSIX_TOOL_SHELL_ON_WINDOWS` beside claude.
+