claude-bridge-cli 1.2.3 → 1.2.5
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.
- package/bin/cli.js +7 -2
- package/lib/bridge.js +14 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -107,10 +107,15 @@ async function run(config) {
|
|
|
107
107
|
if (!config.claudeBin) {
|
|
108
108
|
const { execSync } = require("node:child_process");
|
|
109
109
|
try {
|
|
110
|
-
|
|
110
|
+
const lines = execSync(
|
|
111
111
|
process.platform === "win32" ? "where claude" : "which claude",
|
|
112
112
|
{ encoding: "utf8" }
|
|
113
|
-
).trim().split(
|
|
113
|
+
).trim().split(/\r?\n/);
|
|
114
|
+
if (process.platform === "win32") {
|
|
115
|
+
config.claudeBin = lines.find(l => l.endsWith(".cmd")) || lines[0];
|
|
116
|
+
} else {
|
|
117
|
+
config.claudeBin = lines[0];
|
|
118
|
+
}
|
|
114
119
|
} catch {
|
|
115
120
|
console.error("[bridge] ERROR: claude CLI not found. Install it: npm install -g @anthropic-ai/claude-code");
|
|
116
121
|
process.exit(1);
|
package/lib/bridge.js
CHANGED
|
@@ -357,9 +357,20 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
|
|
|
357
357
|
});
|
|
358
358
|
const args = ["-p", `@${tmpFile}`, "--output-format", "json",
|
|
359
359
|
"--settings", settings, "--permission-mode", "acceptEdits"];
|
|
360
|
+
let resumeCwd = null;
|
|
360
361
|
if (session_id) {
|
|
361
|
-
const
|
|
362
|
-
|
|
362
|
+
const existing = scanSessionFiles().find(s => s.id === session_id);
|
|
363
|
+
if (existing) {
|
|
364
|
+
args.push("--resume", session_id);
|
|
365
|
+
// Read original cwd from the first line of the JSONL (Claude stores it there)
|
|
366
|
+
try {
|
|
367
|
+
const firstLine = fs.readFileSync(existing.filePath, "utf8").split("\n")[0];
|
|
368
|
+
const parsed = JSON.parse(firstLine);
|
|
369
|
+
if (parsed.cwd) resumeCwd = parsed.cwd;
|
|
370
|
+
} catch {}
|
|
371
|
+
} else {
|
|
372
|
+
args.push("--session-id", session_id);
|
|
373
|
+
}
|
|
363
374
|
}
|
|
364
375
|
if (plan_mode) args.push("--plan");
|
|
365
376
|
|
|
@@ -367,7 +378,7 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
|
|
|
367
378
|
const fullArgs = isCmdShim ? ["/c", config.claudeBin, ...args] : args;
|
|
368
379
|
|
|
369
380
|
const proc = spawn(bin, fullArgs, {
|
|
370
|
-
cwd: cwd || config.cwd,
|
|
381
|
+
cwd: cwd || resumeCwd || config.cwd,
|
|
371
382
|
timeout: config.timeout,
|
|
372
383
|
env: { ...process.env },
|
|
373
384
|
stdio: ["ignore", "pipe", "pipe"],
|
package/package.json
CHANGED