claude-bridge-cli 1.3.0 → 1.3.1

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 +14 -13
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -304,13 +304,7 @@ function extractUserText(content) {
304
304
  function shouldSkipUserText(text) {
305
305
  if (!text) return true;
306
306
  const t = text.replace(/^\s+/, "");
307
- // Skip internal command-stub patterns
308
307
  if (INTERNAL_USER_PATTERNS.some(p => t.startsWith(p))) return true;
309
- // Skip @file references — the bridge writes prompts to temp files,
310
- // claude logs the literal @path string in the JSONL even though it
311
- // reads file contents internally.
312
- if (/^@[A-Z]:[\\\/]/.test(t) && /\.txt\s*$/.test(t)) return true;
313
- if (/^@\/.*\.txt\s*$/.test(t)) return true;
314
308
  return false;
315
309
  }
316
310
 
@@ -424,10 +418,16 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
424
418
  const isWin = process.platform === "win32";
425
419
  const isCmdShim = isWin && config.claudeBin.endsWith(".cmd");
426
420
 
427
- // Write prompt to temp file avoids Windows 8K arg limit and stdin
428
- // piping issues through cmd.exe. Works on all platforms.
429
- const tmpFile = path.join(os.tmpdir(), `claude-prompt-${Date.now()}-${Math.random().toString(36).slice(2)}.txt`);
430
- fs.writeFileSync(tmpFile, finalPrompt, "utf8");
421
+ // Only fall back to @file syntax for prompts that would exceed Windows
422
+ // cmd.exe's ~8K arg limit. Direct -p means the JSONL stores the actual
423
+ // prompt text (so session history shows the real user messages, not
424
+ // temp-file paths). Threshold is conservative: 6000 chars.
425
+ const useTempFile = finalPrompt.length > 6000;
426
+ let tmpFile = null;
427
+ if (useTempFile) {
428
+ tmpFile = path.join(os.tmpdir(), `claude-prompt-${Date.now()}-${Math.random().toString(36).slice(2)}.txt`);
429
+ fs.writeFileSync(tmpFile, finalPrompt, "utf8");
430
+ }
431
431
 
432
432
  const settings = JSON.stringify({
433
433
  permissions: {
@@ -437,7 +437,8 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
437
437
  deny: ["AskUserQuestion"],
438
438
  }
439
439
  });
440
- const args = ["-p", `@${tmpFile}`, "--output-format", "json",
440
+ const promptArg = useTempFile ? `@${tmpFile}` : finalPrompt;
441
+ const args = ["-p", promptArg, "--output-format", "json",
441
442
  "--settings", settings, "--permission-mode", "acceptEdits"];
442
443
  let resumeCwd = null;
443
444
  if (session_id) {
@@ -479,7 +480,7 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
479
480
  if (session_id) running.set(session_id, proc);
480
481
 
481
482
  proc.on("close", (code) => {
482
- try { fs.unlinkSync(tmpFile); } catch {}
483
+ if (tmpFile) { try { fs.unlinkSync(tmpFile); } catch {} }
483
484
  if (session_id) running.delete(session_id);
484
485
  try {
485
486
  const result = JSON.parse(stdout);
@@ -506,7 +507,7 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
506
507
  });
507
508
 
508
509
  proc.on("error", (err) => {
509
- try { fs.unlinkSync(tmpFile); } catch {}
510
+ if (tmpFile) { try { fs.unlinkSync(tmpFile); } catch {} }
510
511
  if (session_id) running.delete(session_id);
511
512
  resolve({ error: err.message });
512
513
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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": {