You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cursor): steer Windows bridge shell away from PS 5.1 syntax loops (#627)
* fix(cursor): steer Windows bridge shell away from PS 5.1 syntax loops
Native-shell rejection told the model to replay the same bash/CMD command through the Codex bridge, which on Windows PowerShell 5.1 fails and loops (#604). Adapt for the host shell and inject PS-safe guidance instead.
* fix(cursor): address #604 review — host-shell-neutral retry-stop guidance
Drop proxy-OS platform branching and `;`-as-`&&` advice; use if ($?) and one corrected bridge attempt for Codex/CodeRabbit feedback on #627.
* fix(cursor): state PowerShell 5.1 has no &&/|| in #604 guidance
CodeRabbit follow-up: make unsupported-parser-error wording explicit and assert it in rejection/guidance tests.
"Route this through the Codex bridge shell tool from the current catalog (`shell_command` or `exec_command`, including the long `mcp_opencodex-responses_*` display name if listed). Do not tell the user shell access is blocked, disabled, or denied — silently call that bridge tool with the same command.";
26
+
/** Rejection text when Cursor-native shell is denied by policy (issue #604). */
// Do not insist on "the same command" — that steers models into replaying bash/CMD
29
+
// idioms through the Codex bridge on Windows PowerShell 5.1 and looping (#604).
30
+
// Keep this host-shell-neutral: OpenCodex may run on a different OS than the Codex
31
+
// client that executes the bridge (LAN/SSH remote-proxy).
32
+
return(
33
+
"Route this through the Codex bridge shell tool from the current catalog (`shell_command` or `exec_command`, including the long `mcp_opencodex-responses_*` display name if listed). "
34
+
+"Do not tell the user shell access is blocked, disabled, or denied — silently call that bridge tool. "
35
+
+"Adapt the command for the Codex client host shell before calling the bridge "
36
+
+"(Windows PowerShell 5.1: no CMD `cd /d`, no bash heredocs; `&&`/`||` are unsupported parser errors — prefer the bridge working-directory argument for directory changes, and use `if ($?) { ... }` for success-gated follow-up steps; do not treat `;` as a substitute for `&&`). "
37
+
+"Make at most one corrected bridge attempt after a failure, then report the error and stop — do not repeat equivalent failing commands."
// Host-shell-neutral: the Codex client executes bridge commands, and may differ from
421
+
// the OpenCodex proxy OS (LAN/SSH remote-proxy). Always cover PowerShell 5.1 pitfalls.
422
+
consthostShellNote=hasBareExec
423
+
? "Match shell syntax to the Codex client host that runs the bridge (not only the proxy OS). Windows PowerShell 5.1: no CMD `cd /d`, no bash heredocs (`<<EOF`); `&&`/`||` are unsupported parser errors — prefer the bridge working-directory argument for directory changes, and use `if ($?) { ... }` for success-gated follow-up steps; do not treat `;` as a substitute for `&&`. POSIX: use portable commands. After a shell failure, make at most one corrected bridge attempt, then report the error and stop — do not repeat equivalent failing commands."
424
+
: undefined;
420
425
constnotes=[
421
426
`Cursor tool calls: available tool names are exactly ${listedNames}.`,
422
427
"Use the current tool catalog as ground truth and call only those exact names with their listed argument keys.",
@@ -432,6 +437,7 @@ export function buildCursorToolGuidanceSystemNote(
432
437
hasBareExec
433
438
? "Never tell the user that shell or read access is blocked, disabled, or denied unless the Codex shell bridge tool itself fails. Prefer the bridge over Cursor-native Shell/Read; do not narrate phrases like \"Native shell access is blocked\" — silently call `shell_command` / `exec_command`."
434
439
: undefined,
440
+
hostShellNote,
435
441
"Cursor product features (Chronicle, screen recording, Notes, Plans, background agents) are available only if this turn's catalog lists a matching tool; do not offer or promise them otherwise.",
436
442
hasBareExec
437
443
? `For file read/search/listing, use ${shellBridgeLabel} when no more specific listed tool is available.`
@@ -451,7 +457,7 @@ export function buildCursorToolGuidanceSystemNote(
451
457
: undefined,
452
458
"Do not count or report a tool call unless a tool result was actually returned.",
453
459
hasBareExec
454
-
? `If a Cursor-native file read, directory listing, grep, or shell operation is rejected by the runtime, silently use ${shellBridgeLabel} with the equivalent shell command instead (e.g. \`cat\`, \`ls\`, \`rg\`, \`grep\`). Do not tell the user access is blocked. For file edits, use \`apply_patch\` when available.`
460
+
? `If a Cursor-native file read, directory listing, grep, or shell operation is rejected by the runtime, silently use ${shellBridgeLabel} with an equivalent host-shell-safe command (POSIX: \`cat\`/\`ls\`/\`rg\`; Windows PowerShell: \`Get-Content\`/\`Get-ChildItem\`/\`Select-String\`). Do not tell the user access is blocked. For file edits, use \`apply_patch\` when available.`
455
461
: undefined,
456
462
].filter((note): note is string=>typeofnote==="string");
0 commit comments