Repository navigation
Description
On Windows + Git Bash, Cursor agent breaks two ways: prompt injection is mangled, and hooks block every prompt
Summary
On Windows, when the terminal shell is Git Bash (the default many users pick, and the case where cursor-agent ships as a bash wrapper), Orca's Cursor integration is broken in two independent but same-root ways:
- Prompt injection is mangled — the initial task prompt is quoted with PowerShell rules but executed by bash, so any prompt containing
',!,\, etc. gets corrupted. - Every hook blocks the prompt — Orca writes Cursor's
hooks.jsoncommands in PowerShell form, butcursor-agentexecutes hook commands via/bin/sh -c, so they fail withsyntax error near unexpected token '&', and Cursor treats the failedbeforeSubmitPrompthook as a block.
Both stem from the same wrong assumption: on Windows, Orca hardcodes "shell = PowerShell", but the Cursor CLI toolchain (launcher + hooks) runs under POSIX shell / bash.
Environment
- OS: Windows 10/11
- Terminal shell: Git Bash (
settings.terminalWindowsShell: "git-bash") defaultTuiAgent: "cursor"cursor-agenton PATH is a Git Bash wrapper script (common on Windows);cursor-agentitself runs hook commands withprocess.env.SHELL || "/bin/sh".
Bug 1 — Prompt injection quoted for the wrong shell
Root cause
resolveStartupShell defaults to 'powershell' on win32 whenever no explicit shell is provided:
// src/shared/tui-agent-startup-shell.ts
export function resolveStartupShell(platform, shell) {
return shell ?? (platform === 'win32' ? 'powershell' : 'posix')
}buildAgentStartupPlan then quotes the prompt with quoteStartupArg(prompt, shell) and, for argv agents (cursor, codex, …), builds `${baseCommand} ${quotedPrompt}`.
But every caller of buildAgentStartupPlan passes platform but never shell (src/renderer/src/lib/launch-agent-in-new-tab.ts, launch-work-item-direct-agent.ts, worktree-activation.ts, FloatingTerminalWindowControls.tsx, …). So on Windows the prompt is always PowerShell-quoted, regardless of the pane's actual shell. The pane shell, however, is chosen later from settings.terminalWindowsShell (and per-tab shellOverride); git-bash routes to bash.exe --login -i. A PowerShell-quoted command string is then handed to bash.
Demonstration
PowerShell quoting of don't delete → 'don''t delete'. Parsed by bash:
$ bash -c "printf '[%s]\n' 'don''t delete'"
[dont delete] # apostrophe swallowed — WRONG
$ bash -c "printf '[%s]\n' 'don'\''t delete'"
[don't delete] # POSIX quoting — correct
Proposed fix
Thread the effective pane shell into the startup plan instead of assuming PowerShell on Windows.
// shared
export function windowsTerminalShellToStartupShell(
windowsShell: string | undefined
): AgentStartupShell {
const s = (windowsShell ?? 'powershell.exe').toLowerCase()
if (s === 'git-bash' || s.endsWith('bash.exe') || s === 'wsl.exe') return 'posix'
if (s === 'cmd.exe' || s === 'command_prompt') return 'cmd'
return 'powershell'
}// each launcher (already reads settings via the app store)
const windowsShell = perTabShellOverride ?? settings.terminalWindowsShell
const shell =
resolvedLaunchPlatform === 'win32'
? windowsTerminalShellToStartupShell(windowsShell)
: undefined // resolveStartupShell -> 'posix'
const startupPlan = buildAgentStartupPlan({ agent, prompt, cmdOverrides, platform: resolvedLaunchPlatform, shell, /* … */ })buildAgentStartupPlan already forwards shell into resolveStartupShell; only the call sites must supply it. Per-tab shellOverride must win over the global setting. WSL panes also need POSIX quoting.
Bug 2 — Hook commands written for PowerShell but executed by /bin/sh
Root cause
Orca writes Cursor's ~/.cursor/hooks.json command in PowerShell form for all Windows installs:
// src/main/cursor/hook-service.ts
function getManagedScriptFileName(): string {
return process.platform === 'win32' ? 'cursor-hook.cmd' : 'cursor-hook.sh'
}
function getManagedCommand(scriptPath: string): string {
return process.platform === 'win32'
? wrapWindowsHookCommand(scriptPath) // powershell.exe -EncodedCommand …
: wrapPosixHookCommand(scriptPath)
}The resulting hooks.json command (decoded) is:
powershell.exe -NoProfile -ExecutionPolicy Bypass -EncodedCommand <…>
# decodes to: & 'C:\Users\<u>\.orca\agent-hooks\cursor-hook.cmd'; exit $LASTEXITCODE
But cursor-agent runs hook commands through a POSIX shell:
// cursor-agent index.js
te(this.options?.shell || process.env.SHELL || "/bin/sh", [...shellArgs, "-c", u], …)So bash receives a PowerShell statement and fails:
Hook blocked with message: --: eval: line 1: syntax error near unexpected token `&'
--: eval: line 1: `$OutputEncoding = …; … | & { $input | powershell.exe -EncodedCommand … }'
A non-zero hook exit on beforeSubmitPrompt is treated by Cursor as blocking the prompt, so the user cannot submit anything.
Evidence this is just a missing branch
Orca already knows Cursor hooks must be POSIX: the remote path uses cursor-hook.sh + wrapPosixHookCommand unconditionally:
// src/main/cursor/hook-service.ts (remote)
const remoteScriptPath = `${remoteHome}/.orca/agent-hooks/cursor-hook.sh`
const command = wrapPosixHookCommand(remoteScriptPath)Only the local win32 branch wrongly assumes PowerShell.
Proposed fix
Cursor's hook commands are executed by Cursor's own shell ($SHELL//bin/sh), not by Orca's terminal shell. On Windows, Cursor still runs hooks via the bundled bash, so Cursor's managed hook should use the POSIX .sh script + wrapPosixHookCommand on all platforms (the script already exists — see getManagedScript POSIX branch). At minimum, choose the hook form based on how Cursor invokes hooks, not on process.platform.
Workarounds (no code change)
- Bug 1: set
terminalWindowsShellto PowerShell and pointagentCmdOverrides.cursorat the nativecursor-agent.cmdso the quoting matches the executing shell. (Keep day-to-day terminals on Git Bash via per-tabshellOverride.) - Bug 2: disable Orca-managed agent hooks (
agentStatusHooksEnabled: false) and clear the broken entries in~/.cursor/hooks.json. This unblocks prompts but loses Orca's live status/title/permission UI for all agents.
Both workarounds are obviously band-aids; the real fix is to stop assuming PowerShell on Windows for the Cursor (and other POSIX-toolchain) integration.
Activity
OrcaWin commentedon Jul 17, 2026
Agent reproduction package (Windows orchestration 2026-07-16)
Host context: Windows 11 / Orca 1.4.143.0 / repo path used:
docs/bug-reproductions/Labels applied: see issue labels (
has_reproorcannot_repro).Security: Do not run user-uploaded binaries from issue attachments. Recreate fixtures from the steps/scripts below.
Issue 6694 — Git Bash + Cursor agent prompt mangled + hooks block
Status:
needs_setup/ treated ascannot_reproon this host until prerequisites landHost: Windows 11, Orca 1.4.143
Label:
cannot_repro(attempted; blocked)What we tried
Git Bash present. Cursor agent.cmd NOT installed. Source analysis matches issue: resolveStartupShell defaults to powershell on win32; hooks written PowerShell-style while cursor-agent may run via /bin/sh.
What is needed Install Cursor Agent CLI; set terminalWindowsShell=git-bash; launch Cursor with prompt containing apostrophe; inspect hooks.json command shell.
Install Cursor Agent CLI; set terminalWindowsShell=git-bash; launch Cursor with prompt containing apostrophe; inspect hooks.json command shell.
Notes
docs/bug-reproductions/. Re-run once prerequisites exist.How another agent should use this
%LOCALAPPDATA%\Programs\orca).--json, screenshots, logs) under a local folder; optionally comment results back here.cannot_repro/ needs_setup, satisfy the listed prerequisites first, then re-attempt and flip labels: removecannot_repro, addhas_reprowhen conclusive.nwparker commentedon Oct 24, 2026
Thanks for the thorough report. Prompt quoting now follows the actual shell (Git Bash included) and the Cursor hook command was reworked so it runs under the shell Cursor uses. Could you confirm on the latest build with Git Bash? If it still happens on the latest build, please reply or reopen and we'll take another look.