claude-bridge-cli 2.0.0 → 2.0.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 +33 -4
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -290,15 +290,44 @@ const INTERNAL_USER_PATTERNS = [
290
290
  function extractUserText(content) {
291
291
  // Only extract type:"text" parts. tool_result records don't have a text
292
292
  // part so they return empty string and get filtered out.
293
- if (typeof content === "string") return content;
294
- if (Array.isArray(content)) {
293
+ let raw = "";
294
+ if (typeof content === "string") raw = content;
295
+ else if (Array.isArray(content)) {
295
296
  for (const part of content) {
296
297
  if (part && typeof part === "object" && part.type === "text") {
297
- return part.text || "";
298
+ raw = part.text || "";
299
+ break;
298
300
  }
299
301
  }
300
302
  }
301
- return "";
303
+ return resolveAtFileRefs(raw);
304
+ }
305
+
306
+ // When the bridge sends a multi-line prompt to claude on Windows it writes
307
+ // the prompt to a temp file and passes "@C:\...\claude-prompt-NNN.txt" as
308
+ // the -p arg. claude records that literal @path in the session JSONL as
309
+ // the user message. When we read the session back we want to show the
310
+ // actual content, not the path — otherwise history looks like a wall of
311
+ // temp-file paths. If the file still exists on disk, inline its contents;
312
+ // otherwise leave the @path alone so the user at least sees something.
313
+ function resolveAtFileRefs(text) {
314
+ if (!text || typeof text !== "string") return text;
315
+ // Match a leading @<path> that points at a claude-prompt-*.txt temp file.
316
+ // Restrict to the temp-file pattern we generate ourselves — never inline
317
+ // arbitrary user-typed @file references (which are a real Claude Code
318
+ // feature that should remain as-is).
319
+ const trimmed = text.trim();
320
+ if (!trimmed.startsWith("@")) return text;
321
+ const m = trimmed.match(/^@(.+?claude-prompt-\d+-[a-z0-9]+\.txt)\s*$/i);
322
+ if (!m) return text;
323
+ const filePath = m[1];
324
+ try {
325
+ if (fs.existsSync(filePath)) {
326
+ const body = fs.readFileSync(filePath, "utf8");
327
+ if (body && body.length) return body;
328
+ }
329
+ } catch {}
330
+ return text;
302
331
  }
303
332
 
304
333
  function shouldSkipUserText(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.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": {