claude-bridge-cli 2.0.20 → 2.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/bridge.js +19 -1
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -842,8 +842,26 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
842
842
  }
843
843
  } catch {}
844
844
 
845
+ // A newline in ANY argument truncates the command line there — cmd.exe's
846
+ // second parse ends the command at the line break, so every argument that
847
+ // FOLLOWS is silently discarded. The prompt was routed through @file for
848
+ // exactly this reason (see the note above), but the lesson was applied to
849
+ // one argument instead of to the rule. 2.0.18 added the first multi-line
850
+ // --append-system-prompt and re-opened the hole one argument over: the
851
+ // trailing --add-dir / --resume / --model were dropped, so on Windows
852
+ // every "resume" silently began a NEW session, on the default model, with
853
+ // no error to explain it. Newlines are not meaningful in any value we
854
+ // pass, so flatten them for cmd-shim spawns and close the whole class.
855
+ const flattenForCmd = (a) =>
856
+ typeof a === "string" ? a.replace(/\r\n|\r|\n/g, " ") : a;
857
+ const shellSafeArgs = isCmdShim ? args.map(flattenForCmd) : args;
858
+ if (isCmdShim && process.env.CLAUDE_BRIDGE_DEBUG) {
859
+ const n = args.filter((a, i) => a !== shellSafeArgs[i]).length;
860
+ if (n) console.error("[bridge] flattened newlines in %d arg(s) for cmd.exe", n);
861
+ }
862
+
845
863
  const bin = isCmdShim ? process.env.COMSPEC || "cmd.exe" : config.claudeBin;
846
- const fullArgs = isCmdShim ? ["/c", config.claudeBin, ...args] : args;
864
+ const fullArgs = isCmdShim ? ["/c", config.claudeBin, ...shellSafeArgs] : args;
847
865
 
848
866
  // Opt-in spawn tracing (CLAUDE_BRIDGE_DEBUG=1). Nothing recorded WHAT the
849
867
  // bridge actually ran, so when a turn misbehaved there was no evidence to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "description": "Use Claude Code from your browser. Runs a local server that connects your browser tools to the Claude CLI.",
5
5
  "main": "lib/bridge.js",
6
6
  "bin": {