claude-bridge-cli 2.0.17 → 2.0.18

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 +21 -1
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -178,6 +178,23 @@ function sanitizeAnyFilename(name) {
178
178
  .replace(/^[._ ]+|[._ ]+$/g, "");
179
179
  return (base || "upload.bin").slice(0, 200);
180
180
  }
181
+ // Tell Claude about this session's file-exchange folder. The Files drawer
182
+ // lists exactly this directory and lets the user download from it, but nothing
183
+ // ever TOLD Claude it exists — so "put that file here on the extension" was
184
+ // unanswerable and it guessed at local paths instead. Empty string when there
185
+ // is no session id yet (nothing to point at).
186
+ function filesDrawerPrompt(sid) {
187
+ if (!sid || !/^[A-Za-z0-9._-]+$/.test(sid)) return "";
188
+ const dir = path.join(dataDir(), "images", sid);
189
+ return "\n\nFILE EXCHANGE WITH THE USER'S UI: the directory " + dir +
190
+ " is this session's shared folder. Anything you write there appears immediately " +
191
+ "in the user's 'Files' drawer (they can preview/download it), and files they " +
192
+ "attach arrive there too. When the user asks to 'see/put/send a file here', 'in " +
193
+ "the extension', 'in the app', or 'in the chat' — COPY it into that directory " +
194
+ "(keep the original where it is) and say it's in the Files drawer. Use plain, " +
195
+ "safe filenames. It is a transfer folder, not storage: files older than " +
196
+ FILE_PRUNE_DAYS + " days are pruned, so never treat it as the only copy.";
197
+ }
181
198
  function sessionFilesDir(sid) {
182
199
  if (!/^[A-Za-z0-9._-]+$/.test(sid || "")) throw new Error("bad session id");
183
200
  return path.join(dataDir(), "images", sid);
@@ -758,7 +775,10 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
758
775
  const promptArg = useTempFile ? `@${tmpFile}` : finalPrompt;
759
776
  const args = ["-p", promptArg, "--output-format", "json",
760
777
  "--settings", settings, "--permission-mode", "acceptEdits",
761
- "--append-system-prompt", ATOMIC_TURN_PROMPT];
778
+ "--append-system-prompt", ATOMIC_TURN_PROMPT + filesDrawerPrompt(session_id),
779
+ // Grant write access to the file-exchange root, else Claude cannot put
780
+ // anything INTO the Files drawer it's now told about.
781
+ "--add-dir", path.join(dataDir(), "images")];
762
782
  let resumeCwd = null;
763
783
  if (session_id) {
764
784
  const existing = scanSessionFiles().find(s => s.id === session_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
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": {