@buildautomaton/cli 0.1.51 → 0.1.52

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/dist/cli.js CHANGED
@@ -973,7 +973,7 @@ var require_command = __commonJS({
973
973
  "../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
974
974
  var EventEmitter2 = __require("node:events").EventEmitter;
975
975
  var childProcess2 = __require("node:child_process");
976
- var path62 = __require("node:path");
976
+ var path63 = __require("node:path");
977
977
  var fs47 = __require("node:fs");
978
978
  var process8 = __require("node:process");
979
979
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1906,9 +1906,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1906
1906
  let launchWithNode = false;
1907
1907
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1908
1908
  function findFile(baseDir, baseName) {
1909
- const localBin = path62.resolve(baseDir, baseName);
1909
+ const localBin = path63.resolve(baseDir, baseName);
1910
1910
  if (fs47.existsSync(localBin)) return localBin;
1911
- if (sourceExt.includes(path62.extname(baseName))) return void 0;
1911
+ if (sourceExt.includes(path63.extname(baseName))) return void 0;
1912
1912
  const foundExt = sourceExt.find(
1913
1913
  (ext) => fs47.existsSync(`${localBin}${ext}`)
1914
1914
  );
@@ -1926,17 +1926,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1926
1926
  } catch (err) {
1927
1927
  resolvedScriptPath = this._scriptPath;
1928
1928
  }
1929
- executableDir = path62.resolve(
1930
- path62.dirname(resolvedScriptPath),
1929
+ executableDir = path63.resolve(
1930
+ path63.dirname(resolvedScriptPath),
1931
1931
  executableDir
1932
1932
  );
1933
1933
  }
1934
1934
  if (executableDir) {
1935
1935
  let localFile = findFile(executableDir, executableFile);
1936
1936
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1937
- const legacyName = path62.basename(
1937
+ const legacyName = path63.basename(
1938
1938
  this._scriptPath,
1939
- path62.extname(this._scriptPath)
1939
+ path63.extname(this._scriptPath)
1940
1940
  );
1941
1941
  if (legacyName !== this._name) {
1942
1942
  localFile = findFile(
@@ -1947,7 +1947,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1947
1947
  }
1948
1948
  executableFile = localFile || executableFile;
1949
1949
  }
1950
- launchWithNode = sourceExt.includes(path62.extname(executableFile));
1950
+ launchWithNode = sourceExt.includes(path63.extname(executableFile));
1951
1951
  let proc;
1952
1952
  if (process8.platform !== "win32") {
1953
1953
  if (launchWithNode) {
@@ -2787,7 +2787,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2787
2787
  * @return {Command}
2788
2788
  */
2789
2789
  nameFromFilename(filename) {
2790
- this._name = path62.basename(filename, path62.extname(filename));
2790
+ this._name = path63.basename(filename, path63.extname(filename));
2791
2791
  return this;
2792
2792
  }
2793
2793
  /**
@@ -2801,9 +2801,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2801
2801
  * @param {string} [path]
2802
2802
  * @return {(string|null|Command)}
2803
2803
  */
2804
- executableDir(path63) {
2805
- if (path63 === void 0) return this._executableDir;
2806
- this._executableDir = path63;
2804
+ executableDir(path64) {
2805
+ if (path64 === void 0) return this._executableDir;
2806
+ this._executableDir = path64;
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -7061,8 +7061,8 @@ var init_parseUtil = __esm({
7061
7061
  init_errors();
7062
7062
  init_en();
7063
7063
  makeIssue = (params) => {
7064
- const { data, path: path62, errorMaps, issueData } = params;
7065
- const fullPath = [...path62, ...issueData.path || []];
7064
+ const { data, path: path63, errorMaps, issueData } = params;
7065
+ const fullPath = [...path63, ...issueData.path || []];
7066
7066
  const fullIssue = {
7067
7067
  ...issueData,
7068
7068
  path: fullPath
@@ -7370,11 +7370,11 @@ var init_types = __esm({
7370
7370
  init_parseUtil();
7371
7371
  init_util();
7372
7372
  ParseInputLazyPath = class {
7373
- constructor(parent, value, path62, key) {
7373
+ constructor(parent, value, path63, key) {
7374
7374
  this._cachedPath = [];
7375
7375
  this.parent = parent;
7376
7376
  this.data = value;
7377
- this._path = path62;
7377
+ this._path = path63;
7378
7378
  this._key = key;
7379
7379
  }
7380
7380
  get path() {
@@ -11099,10 +11099,10 @@ function assignProp(target, prop, value) {
11099
11099
  configurable: true
11100
11100
  });
11101
11101
  }
11102
- function getElementAtPath(obj, path62) {
11103
- if (!path62)
11102
+ function getElementAtPath(obj, path63) {
11103
+ if (!path63)
11104
11104
  return obj;
11105
- return path62.reduce((acc, key) => acc?.[key], obj);
11105
+ return path63.reduce((acc, key) => acc?.[key], obj);
11106
11106
  }
11107
11107
  function promiseAllObject(promisesObj) {
11108
11108
  const keys = Object.keys(promisesObj);
@@ -11351,11 +11351,11 @@ function aborted(x, startIndex = 0) {
11351
11351
  }
11352
11352
  return false;
11353
11353
  }
11354
- function prefixIssues(path62, issues) {
11354
+ function prefixIssues(path63, issues) {
11355
11355
  return issues.map((iss) => {
11356
11356
  var _a2;
11357
11357
  (_a2 = iss).path ?? (_a2.path = []);
11358
- iss.path.unshift(path62);
11358
+ iss.path.unshift(path63);
11359
11359
  return iss;
11360
11360
  });
11361
11361
  }
@@ -11544,7 +11544,7 @@ function treeifyError(error40, _mapper) {
11544
11544
  return issue2.message;
11545
11545
  };
11546
11546
  const result = { errors: [] };
11547
- const processError = (error41, path62 = []) => {
11547
+ const processError = (error41, path63 = []) => {
11548
11548
  var _a2, _b;
11549
11549
  for (const issue2 of error41.issues) {
11550
11550
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -11554,7 +11554,7 @@ function treeifyError(error40, _mapper) {
11554
11554
  } else if (issue2.code === "invalid_element") {
11555
11555
  processError({ issues: issue2.issues }, issue2.path);
11556
11556
  } else {
11557
- const fullpath = [...path62, ...issue2.path];
11557
+ const fullpath = [...path63, ...issue2.path];
11558
11558
  if (fullpath.length === 0) {
11559
11559
  result.errors.push(mapper(issue2));
11560
11560
  continue;
@@ -11584,9 +11584,9 @@ function treeifyError(error40, _mapper) {
11584
11584
  processError(error40);
11585
11585
  return result;
11586
11586
  }
11587
- function toDotPath(path62) {
11587
+ function toDotPath(path63) {
11588
11588
  const segs = [];
11589
- for (const seg of path62) {
11589
+ for (const seg of path63) {
11590
11590
  if (typeof seg === "number")
11591
11591
  segs.push(`[${seg}]`);
11592
11592
  else if (typeof seg === "symbol")
@@ -24049,8 +24049,8 @@ var init_acp = __esm({
24049
24049
  this.#requestHandler = requestHandler;
24050
24050
  this.#notificationHandler = notificationHandler;
24051
24051
  this.#stream = stream;
24052
- this.#closedPromise = new Promise((resolve34) => {
24053
- this.#abortController.signal.addEventListener("abort", () => resolve34());
24052
+ this.#closedPromise = new Promise((resolve35) => {
24053
+ this.#abortController.signal.addEventListener("abort", () => resolve35());
24054
24054
  });
24055
24055
  this.#receive();
24056
24056
  }
@@ -24199,8 +24199,8 @@ var init_acp = __esm({
24199
24199
  }
24200
24200
  async sendRequest(method, params) {
24201
24201
  const id = this.#nextRequestId++;
24202
- const responsePromise = new Promise((resolve34, reject) => {
24203
- this.#pendingResponses.set(id, { resolve: resolve34, reject });
24202
+ const responsePromise = new Promise((resolve35, reject) => {
24203
+ this.#pendingResponses.set(id, { resolve: resolve35, reject });
24204
24204
  });
24205
24205
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
24206
24206
  return responsePromise;
@@ -25069,10 +25069,10 @@ var require_src2 = __commonJS({
25069
25069
  var fs_1 = __require("fs");
25070
25070
  var debug_1 = __importDefault(require_src());
25071
25071
  var log2 = debug_1.default("@kwsites/file-exists");
25072
- function check2(path62, isFile, isDirectory) {
25073
- log2(`checking %s`, path62);
25072
+ function check2(path63, isFile, isDirectory) {
25073
+ log2(`checking %s`, path63);
25074
25074
  try {
25075
- const stat3 = fs_1.statSync(path62);
25075
+ const stat3 = fs_1.statSync(path63);
25076
25076
  if (stat3.isFile() && isFile) {
25077
25077
  log2(`[OK] path represents a file`);
25078
25078
  return true;
@@ -25092,8 +25092,8 @@ var require_src2 = __commonJS({
25092
25092
  throw e;
25093
25093
  }
25094
25094
  }
25095
- function exists2(path62, type = exports.READABLE) {
25096
- return check2(path62, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
25095
+ function exists2(path63, type = exports.READABLE) {
25096
+ return check2(path63, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
25097
25097
  }
25098
25098
  exports.exists = exists2;
25099
25099
  exports.FILE = 1;
@@ -25174,7 +25174,7 @@ var {
25174
25174
  } = import_index.default;
25175
25175
 
25176
25176
  // src/cli-version.ts
25177
- var CLI_VERSION = "0.1.51".length > 0 ? "0.1.51" : "0.0.0-dev";
25177
+ var CLI_VERSION = "0.1.52".length > 0 ? "0.1.52" : "0.0.0-dev";
25178
25178
 
25179
25179
  // src/cli/defaults.ts
25180
25180
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -25182,7 +25182,7 @@ var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
25182
25182
 
25183
25183
  // src/cli/run-cli-action.ts
25184
25184
  import * as fs46 from "node:fs";
25185
- import * as path61 from "node:path";
25185
+ import * as path62 from "node:path";
25186
25186
 
25187
25187
  // src/cli-log-level.ts
25188
25188
  var verbosity = "info";
@@ -26297,14 +26297,14 @@ var baseOpen = async (options) => {
26297
26297
  }
26298
26298
  const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
26299
26299
  if (options.wait) {
26300
- return new Promise((resolve34, reject) => {
26300
+ return new Promise((resolve35, reject) => {
26301
26301
  subprocess.once("error", reject);
26302
26302
  subprocess.once("close", (exitCode) => {
26303
26303
  if (!options.allowNonzeroExitCode && exitCode > 0) {
26304
26304
  reject(new Error(`Exited with code ${exitCode}`));
26305
26305
  return;
26306
26306
  }
26307
- resolve34(subprocess);
26307
+ resolve35(subprocess);
26308
26308
  });
26309
26309
  });
26310
26310
  }
@@ -26848,8 +26848,8 @@ function runPendingAuth(options) {
26848
26848
  let hasOpenedBrowser = false;
26849
26849
  let resolved = false;
26850
26850
  let resolveAuth;
26851
- const authPromise = new Promise((resolve34) => {
26852
- resolveAuth = resolve34;
26851
+ const authPromise = new Promise((resolve35) => {
26852
+ resolveAuth = resolve35;
26853
26853
  });
26854
26854
  let reconnectAttempt = 0;
26855
26855
  const signInQuiet = createEmptyReconnectQuietSlot();
@@ -27000,7 +27000,7 @@ import sqliteWasm from "node-sqlite3-wasm";
27000
27000
 
27001
27001
  // src/runtime/yield-to-event-loop.ts
27002
27002
  function yieldToEventLoop() {
27003
- return new Promise((resolve34) => setImmediate(resolve34));
27003
+ return new Promise((resolve35) => setImmediate(resolve35));
27004
27004
  }
27005
27005
 
27006
27006
  // src/sqlite/cli-sqlite-paths.ts
@@ -28117,9 +28117,9 @@ function parseChangeSummaryJson(raw, allowedPaths, options) {
28117
28117
  const rawPath = typeof o.path === "string" ? o.path.trim() : "";
28118
28118
  const summary = typeof o.summary === "string" ? o.summary.trim() : "";
28119
28119
  if (!rawPath || !summary) continue;
28120
- const path62 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
28121
- if (!path62) continue;
28122
- rows.push({ path: path62, summary: clampSummaryToAtMostTwoLines(summary) });
28120
+ const path63 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
28121
+ if (!path63) continue;
28122
+ rows.push({ path: path63, summary: clampSummaryToAtMostTwoLines(summary) });
28123
28123
  }
28124
28124
  return rows;
28125
28125
  }
@@ -28631,10 +28631,10 @@ async function killChildProcessTreeGracefully(child, graceMs = ACP_PROCESS_TREE_
28631
28631
  }
28632
28632
  await killProcessTree(pid, "SIGTERM");
28633
28633
  if (graceMs <= 0) return;
28634
- const exited = new Promise((resolve34) => {
28635
- child.once("exit", () => resolve34());
28634
+ const exited = new Promise((resolve35) => {
28635
+ child.once("exit", () => resolve35());
28636
28636
  });
28637
- await Promise.race([exited, new Promise((resolve34) => setTimeout(resolve34, graceMs))]);
28637
+ await Promise.race([exited, new Promise((resolve35) => setTimeout(resolve35, graceMs))]);
28638
28638
  if (child.exitCode == null && child.signalCode == null) {
28639
28639
  await killProcessTree(pid, "SIGKILL");
28640
28640
  }
@@ -28651,8 +28651,8 @@ async function gracefulAcpSubprocessDisconnect(params) {
28651
28651
  await transport.closeSession?.(sessionId);
28652
28652
  } catch {
28653
28653
  }
28654
- await new Promise((resolve34) => {
28655
- const timer = setTimeout(resolve34, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
28654
+ await new Promise((resolve35) => {
28655
+ const timer = setTimeout(resolve35, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
28656
28656
  timer.unref?.();
28657
28657
  });
28658
28658
  }
@@ -28927,11 +28927,11 @@ function createSdkStdioExtNotificationHandler(options) {
28927
28927
  // src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
28928
28928
  function awaitSdkStdioPermissionRequestHandshake(params) {
28929
28929
  const { requestId, paramsRecord, pending, onRequest } = params;
28930
- return new Promise((resolve34) => {
28931
- pending.set(requestId, { resolve: resolve34, params: paramsRecord });
28930
+ return new Promise((resolve35) => {
28931
+ pending.set(requestId, { resolve: resolve35, params: paramsRecord });
28932
28932
  if (onRequest == null) {
28933
28933
  pending.delete(requestId);
28934
- resolve34({ outcome: { outcome: "denied" } });
28934
+ resolve35({ outcome: { outcome: "denied" } });
28935
28935
  return;
28936
28936
  }
28937
28937
  try {
@@ -29441,10 +29441,10 @@ function createSdkStdioInitSettle(child) {
29441
29441
  forceAcpSubprocessDisconnect(child);
29442
29442
  reject(err);
29443
29443
  },
29444
- settleResolve(resolve34, handle) {
29444
+ settleResolve(resolve35, handle) {
29445
29445
  if (initSettled) return;
29446
29446
  initSettled = true;
29447
- resolve34(handle);
29447
+ resolve35(handle);
29448
29448
  }
29449
29449
  };
29450
29450
  }
@@ -29513,7 +29513,7 @@ async function createSdkStdioAcpClient(options) {
29513
29513
  onFileChange,
29514
29514
  stderrCapture
29515
29515
  });
29516
- return new Promise((resolve34, reject) => {
29516
+ return new Promise((resolve35, reject) => {
29517
29517
  const init = createSdkStdioInitSettle(child);
29518
29518
  child.on("error", (err) => {
29519
29519
  init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
@@ -29538,7 +29538,7 @@ async function createSdkStdioAcpClient(options) {
29538
29538
  protocolVersion: PROTOCOL_VERSION2
29539
29539
  });
29540
29540
  init.settleResolve(
29541
- resolve34,
29541
+ resolve35,
29542
29542
  createSdkStdioHandle({
29543
29543
  child,
29544
29544
  sessionId: established.sessionId,
@@ -30071,7 +30071,7 @@ async function createCursorAcpClient(options) {
30071
30071
  onFileChange,
30072
30072
  stderrCapture
30073
30073
  });
30074
- return new Promise((resolve34, reject) => {
30074
+ return new Promise((resolve35, reject) => {
30075
30075
  child.on("error", (err) => {
30076
30076
  killChildProcessTree(child, "SIGKILL");
30077
30077
  reject(new Error(formatSpawnError(err, command[0])));
@@ -30083,7 +30083,7 @@ async function createCursorAcpClient(options) {
30083
30083
  sessionCtx,
30084
30084
  incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
30085
30085
  });
30086
- resolve34(
30086
+ resolve35(
30087
30087
  createCursorAcpHandle({
30088
30088
  child,
30089
30089
  sessionId: established.sessionId,
@@ -31289,8 +31289,8 @@ function pathspec(...paths) {
31289
31289
  cache.set(key, paths);
31290
31290
  return key;
31291
31291
  }
31292
- function isPathSpec(path62) {
31293
- return path62 instanceof String && cache.has(path62);
31292
+ function isPathSpec(path63) {
31293
+ return path63 instanceof String && cache.has(path63);
31294
31294
  }
31295
31295
  function toPaths(pathSpec) {
31296
31296
  return cache.get(pathSpec) || [];
@@ -31379,8 +31379,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
31379
31379
  function forEachLineWithContent(input, callback) {
31380
31380
  return toLinesWithContent(input, true).map((line) => callback(line));
31381
31381
  }
31382
- function folderExists(path62) {
31383
- return (0, import_file_exists.exists)(path62, import_file_exists.FOLDER);
31382
+ function folderExists(path63) {
31383
+ return (0, import_file_exists.exists)(path63, import_file_exists.FOLDER);
31384
31384
  }
31385
31385
  function append(target, item) {
31386
31386
  if (Array.isArray(target)) {
@@ -31784,8 +31784,8 @@ function checkIsRepoRootTask() {
31784
31784
  commands,
31785
31785
  format: "utf-8",
31786
31786
  onError,
31787
- parser(path62) {
31788
- return /^\.(git)?$/.test(path62.trim());
31787
+ parser(path63) {
31788
+ return /^\.(git)?$/.test(path63.trim());
31789
31789
  }
31790
31790
  };
31791
31791
  }
@@ -32219,11 +32219,11 @@ function parseGrep(grep) {
32219
32219
  const paths = /* @__PURE__ */ new Set();
32220
32220
  const results = {};
32221
32221
  forEachLineWithContent(grep, (input) => {
32222
- const [path62, line, preview] = input.split(NULL);
32223
- paths.add(path62);
32224
- (results[path62] = results[path62] || []).push({
32222
+ const [path63, line, preview] = input.split(NULL);
32223
+ paths.add(path63);
32224
+ (results[path63] = results[path63] || []).push({
32225
32225
  line: asNumber(line),
32226
- path: path62,
32226
+ path: path63,
32227
32227
  preview
32228
32228
  });
32229
32229
  });
@@ -32988,14 +32988,14 @@ var init_hash_object = __esm2({
32988
32988
  init_task();
32989
32989
  }
32990
32990
  });
32991
- function parseInit(bare, path62, text) {
32991
+ function parseInit(bare, path63, text) {
32992
32992
  const response = String(text).trim();
32993
32993
  let result;
32994
32994
  if (result = initResponseRegex.exec(response)) {
32995
- return new InitSummary(bare, path62, false, result[1]);
32995
+ return new InitSummary(bare, path63, false, result[1]);
32996
32996
  }
32997
32997
  if (result = reInitResponseRegex.exec(response)) {
32998
- return new InitSummary(bare, path62, true, result[1]);
32998
+ return new InitSummary(bare, path63, true, result[1]);
32999
32999
  }
33000
33000
  let gitDir = "";
33001
33001
  const tokens = response.split(" ");
@@ -33006,7 +33006,7 @@ function parseInit(bare, path62, text) {
33006
33006
  break;
33007
33007
  }
33008
33008
  }
33009
- return new InitSummary(bare, path62, /^re/i.test(response), gitDir);
33009
+ return new InitSummary(bare, path63, /^re/i.test(response), gitDir);
33010
33010
  }
33011
33011
  var InitSummary;
33012
33012
  var initResponseRegex;
@@ -33015,9 +33015,9 @@ var init_InitSummary = __esm2({
33015
33015
  "src/lib/responses/InitSummary.ts"() {
33016
33016
  "use strict";
33017
33017
  InitSummary = class {
33018
- constructor(bare, path62, existing, gitDir) {
33018
+ constructor(bare, path63, existing, gitDir) {
33019
33019
  this.bare = bare;
33020
- this.path = path62;
33020
+ this.path = path63;
33021
33021
  this.existing = existing;
33022
33022
  this.gitDir = gitDir;
33023
33023
  }
@@ -33029,7 +33029,7 @@ var init_InitSummary = __esm2({
33029
33029
  function hasBareCommand(command) {
33030
33030
  return command.includes(bareCommand);
33031
33031
  }
33032
- function initTask(bare = false, path62, customArgs) {
33032
+ function initTask(bare = false, path63, customArgs) {
33033
33033
  const commands = ["init", ...customArgs];
33034
33034
  if (bare && !hasBareCommand(commands)) {
33035
33035
  commands.splice(1, 0, bareCommand);
@@ -33038,7 +33038,7 @@ function initTask(bare = false, path62, customArgs) {
33038
33038
  commands,
33039
33039
  format: "utf-8",
33040
33040
  parser(text) {
33041
- return parseInit(commands.includes("--bare"), path62, text);
33041
+ return parseInit(commands.includes("--bare"), path63, text);
33042
33042
  }
33043
33043
  };
33044
33044
  }
@@ -33854,12 +33854,12 @@ var init_FileStatusSummary = __esm2({
33854
33854
  "use strict";
33855
33855
  fromPathRegex = /^(.+)\0(.+)$/;
33856
33856
  FileStatusSummary = class {
33857
- constructor(path62, index, working_dir) {
33858
- this.path = path62;
33857
+ constructor(path63, index, working_dir) {
33858
+ this.path = path63;
33859
33859
  this.index = index;
33860
33860
  this.working_dir = working_dir;
33861
33861
  if (index === "R" || working_dir === "R") {
33862
- const detail = fromPathRegex.exec(path62) || [null, path62, path62];
33862
+ const detail = fromPathRegex.exec(path63) || [null, path63, path63];
33863
33863
  this.from = detail[2] || "";
33864
33864
  this.path = detail[1] || "";
33865
33865
  }
@@ -33890,14 +33890,14 @@ function splitLine(result, lineStr) {
33890
33890
  default:
33891
33891
  return;
33892
33892
  }
33893
- function data(index, workingDir, path62) {
33893
+ function data(index, workingDir, path63) {
33894
33894
  const raw = `${index}${workingDir}`;
33895
33895
  const handler = parsers6.get(raw);
33896
33896
  if (handler) {
33897
- handler(result, path62);
33897
+ handler(result, path63);
33898
33898
  }
33899
33899
  if (raw !== "##" && raw !== "!!") {
33900
- result.files.push(new FileStatusSummary(path62, index, workingDir));
33900
+ result.files.push(new FileStatusSummary(path63, index, workingDir));
33901
33901
  }
33902
33902
  }
33903
33903
  }
@@ -34206,9 +34206,9 @@ var init_simple_git_api = __esm2({
34206
34206
  next
34207
34207
  );
34208
34208
  }
34209
- hashObject(path62, write) {
34209
+ hashObject(path63, write) {
34210
34210
  return this._runTask(
34211
- hashObjectTask(path62, write === true),
34211
+ hashObjectTask(path63, write === true),
34212
34212
  trailingFunctionArgument(arguments)
34213
34213
  );
34214
34214
  }
@@ -34561,8 +34561,8 @@ var init_branch = __esm2({
34561
34561
  }
34562
34562
  });
34563
34563
  function toPath(input) {
34564
- const path62 = input.trim().replace(/^["']|["']$/g, "");
34565
- return path62 && normalize3(path62);
34564
+ const path63 = input.trim().replace(/^["']|["']$/g, "");
34565
+ return path63 && normalize3(path63);
34566
34566
  }
34567
34567
  var parseCheckIgnore;
34568
34568
  var init_CheckIgnore = __esm2({
@@ -34876,8 +34876,8 @@ __export2(sub_module_exports, {
34876
34876
  subModuleTask: () => subModuleTask,
34877
34877
  updateSubModuleTask: () => updateSubModuleTask
34878
34878
  });
34879
- function addSubModuleTask(repo, path62) {
34880
- return subModuleTask(["add", repo, path62]);
34879
+ function addSubModuleTask(repo, path63) {
34880
+ return subModuleTask(["add", repo, path63]);
34881
34881
  }
34882
34882
  function initSubModuleTask(customArgs) {
34883
34883
  return subModuleTask(["init", ...customArgs]);
@@ -35210,8 +35210,8 @@ var require_git = __commonJS2({
35210
35210
  }
35211
35211
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
35212
35212
  };
35213
- Git2.prototype.submoduleAdd = function(repo, path62, then) {
35214
- return this._runTask(addSubModuleTask2(repo, path62), trailingFunctionArgument2(arguments));
35213
+ Git2.prototype.submoduleAdd = function(repo, path63, then) {
35214
+ return this._runTask(addSubModuleTask2(repo, path63), trailingFunctionArgument2(arguments));
35215
35215
  };
35216
35216
  Git2.prototype.submoduleUpdate = function(args, then) {
35217
35217
  return this._runTask(
@@ -35848,8 +35848,8 @@ async function runGitTask(fn) {
35848
35848
  }
35849
35849
  async function yieldToEventLoop2() {
35850
35850
  throwIfGitShutdownRequested();
35851
- await new Promise((resolve34) => {
35852
- setImmediate(resolve34);
35851
+ await new Promise((resolve35) => {
35852
+ setImmediate(resolve35);
35853
35853
  });
35854
35854
  throwIfGitShutdownRequested();
35855
35855
  }
@@ -35929,10 +35929,10 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
35929
35929
  await yieldGitDiscoverWork(i + 1);
35930
35930
  const ent = entries[i];
35931
35931
  if (!ent.isDirectory()) continue;
35932
- const childPath = path17.join(cwdResolved, ent.name);
35933
- if (await isGitRepoDirectory(childPath)) {
35934
- const remoteUrl = await getRemoteOriginUrl(childPath);
35935
- result.push({ absolutePath: childPath, remoteUrl });
35932
+ const childPath2 = path17.join(cwdResolved, ent.name);
35933
+ if (await isGitRepoDirectory(childPath2)) {
35934
+ const remoteUrl = await getRemoteOriginUrl(childPath2);
35935
+ result.push({ absolutePath: childPath2, remoteUrl });
35936
35936
  }
35937
35937
  }
35938
35938
  return result;
@@ -36184,9 +36184,9 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
36184
36184
  // src/agents/acp/put-summarize-change-summaries.ts
36185
36185
  async function putEncryptedChangeSummaryRows(params) {
36186
36186
  const base = params.apiBaseUrl.replace(/\/+$/, "");
36187
- const entries = params.rows.map(({ path: path62, summary }) => {
36187
+ const entries = params.rows.map(({ path: path63, summary }) => {
36188
36188
  const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
36189
- return { path: path62, summary: JSON.stringify(enc) };
36189
+ return { path: path63, summary: JSON.stringify(enc) };
36190
36190
  });
36191
36191
  const res = await fetch(
36192
36192
  `${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
@@ -37034,8 +37034,8 @@ async function commitSessionWorktree(cache2, params) {
37034
37034
  }
37035
37035
 
37036
37036
  // src/git/changes/parse/normalize-git-diff-path.ts
37037
- function normalizeGitDiffPath(path62) {
37038
- return path62.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
37037
+ function normalizeGitDiffPath(path63) {
37038
+ return path63.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
37039
37039
  }
37040
37040
 
37041
37041
  // src/git/changes/parse/expand-git-rename-numstat-path.ts
@@ -37135,8 +37135,8 @@ function parseNumstatEntries(lines) {
37135
37135
  }
37136
37136
  function parseNumstat(lines) {
37137
37137
  const m = /* @__PURE__ */ new Map();
37138
- for (const [path62, entry] of parseNumstatEntries(lines)) {
37139
- m.set(path62, { additions: entry.additions, deletions: entry.deletions });
37138
+ for (const [path63, entry] of parseNumstatEntries(lines)) {
37139
+ m.set(path63, { additions: entry.additions, deletions: entry.deletions });
37140
37140
  }
37141
37141
  return m;
37142
37142
  }
@@ -39362,7 +39362,7 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
39362
39362
  }
39363
39363
 
39364
39364
  // src/connection/create-bridge-connection.ts
39365
- import * as path60 from "node:path";
39365
+ import * as path61 from "node:path";
39366
39366
 
39367
39367
  // src/dev-servers/manager/dev-server-manager.ts
39368
39368
  import { rm as rm2 } from "node:fs/promises";
@@ -39384,15 +39384,15 @@ function sendDevServerStatus(getWs, serverId, status, options) {
39384
39384
 
39385
39385
  // src/dev-servers/process/terminate-child-process.ts
39386
39386
  async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
39387
- const exited = new Promise((resolve34) => {
39388
- proc.once("exit", () => resolve34());
39387
+ const exited = new Promise((resolve35) => {
39388
+ proc.once("exit", () => resolve35());
39389
39389
  });
39390
39390
  log2(`[dev-server] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
39391
39391
  try {
39392
39392
  proc.kill("SIGTERM");
39393
39393
  } catch {
39394
39394
  }
39395
- await Promise.race([exited, new Promise((resolve34) => setTimeout(resolve34, graceMs))]);
39395
+ await Promise.race([exited, new Promise((resolve35) => setTimeout(resolve35, graceMs))]);
39396
39396
  }
39397
39397
  function forceKillChild(proc, log2, shortId, graceMs) {
39398
39398
  log2(
@@ -40273,7 +40273,7 @@ async function proxyToLocal(request) {
40273
40273
  };
40274
40274
  const maxAttempts = isIdempotentProxyMethod(request.method) ? LOCAL_PREVIEW_FETCH_RETRY_DELAYS_MS.length + 1 : 1;
40275
40275
  for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
40276
- const once = await new Promise((resolve34) => {
40276
+ const once = await new Promise((resolve35) => {
40277
40277
  const req = mod.request(opts, (res) => {
40278
40278
  const chunks = [];
40279
40279
  res.on("data", (c) => chunks.push(c));
@@ -40284,7 +40284,7 @@ async function proxyToLocal(request) {
40284
40284
  if (typeof v === "string") headers[k] = v;
40285
40285
  else if (Array.isArray(v) && v[0]) headers[k] = v[0];
40286
40286
  }
40287
- resolve34({
40287
+ resolve35({
40288
40288
  id: request.id,
40289
40289
  statusCode: res.statusCode ?? 0,
40290
40290
  headers,
@@ -40293,7 +40293,7 @@ async function proxyToLocal(request) {
40293
40293
  });
40294
40294
  });
40295
40295
  req.on("error", (err) => {
40296
- resolve34({
40296
+ resolve35({
40297
40297
  id: request.id,
40298
40298
  statusCode: 0,
40299
40299
  headers: {},
@@ -41430,9 +41430,9 @@ function parseChangeSummarySnapshots(raw) {
41430
41430
  for (const item of raw) {
41431
41431
  if (!item || typeof item !== "object") continue;
41432
41432
  const o = item;
41433
- const path62 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
41434
- if (!path62) continue;
41435
- const row = { path: path62 };
41433
+ const path63 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
41434
+ if (!path63) continue;
41435
+ const row = { path: path63 };
41436
41436
  if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
41437
41437
  if (typeof o.oldText === "string") row.oldText = o.oldText;
41438
41438
  if (typeof o.newText === "string") row.newText = o.newText;
@@ -41642,8 +41642,8 @@ function randomSecret() {
41642
41642
  }
41643
41643
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
41644
41644
  }
41645
- async function requestPreviewApi(port, secret, method, path62, body) {
41646
- const url2 = `http://127.0.0.1:${port}${path62}`;
41645
+ async function requestPreviewApi(port, secret, method, path63, body) {
41646
+ const url2 = `http://127.0.0.1:${port}${path63}`;
41647
41647
  const headers = {
41648
41648
  [PREVIEW_SECRET_HEADER]: secret,
41649
41649
  "Content-Type": "application/json"
@@ -41655,7 +41655,7 @@ async function requestPreviewApi(port, secret, method, path62, body) {
41655
41655
  });
41656
41656
  const data = await res.json().catch(() => ({}));
41657
41657
  if (!res.ok) {
41658
- throw new Error(data?.error ?? `Preview API ${method} ${path62}: ${res.status}`);
41658
+ throw new Error(data?.error ?? `Preview API ${method} ${path63}: ${res.status}`);
41659
41659
  }
41660
41660
  return data;
41661
41661
  }
@@ -41819,6 +41819,17 @@ var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
41819
41819
  );
41820
41820
  };
41821
41821
 
41822
+ // src/files/resolve-file-browser-session-parent.ts
41823
+ async function resolveFileBrowserSessionParent(sessionWorktreeManager, sessionId) {
41824
+ const sid = sessionId?.trim();
41825
+ if (sid) {
41826
+ await sessionWorktreeManager.ensureRepoCheckoutPathsForSessionAsync(sid);
41827
+ const worktreeRoot = sessionWorktreeManager.getSessionWorktreeRootForSession(sid);
41828
+ if (worktreeRoot) return worktreeRoot;
41829
+ }
41830
+ return getBridgeRoot();
41831
+ }
41832
+
41822
41833
  // src/files/list-dir/index.ts
41823
41834
  import fs40 from "node:fs";
41824
41835
 
@@ -41890,10 +41901,447 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
41890
41901
  }
41891
41902
  }
41892
41903
 
41904
+ // src/files/handle-file-browser-search.ts
41905
+ import path55 from "node:path";
41906
+ var SEARCH_LIMIT = 100;
41907
+ function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
41908
+ void (async () => {
41909
+ await yieldToEventLoop();
41910
+ const q = typeof msg.q === "string" ? msg.q : "";
41911
+ const sessionParentPath = path55.resolve(
41912
+ sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
41913
+ );
41914
+ if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
41915
+ const payload2 = {
41916
+ type: "file_browser_search_response",
41917
+ id: msg.id,
41918
+ paths: [],
41919
+ indexReady: false
41920
+ };
41921
+ sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload2, ["paths"]) : payload2);
41922
+ return;
41923
+ }
41924
+ const results = await searchBridgeFilePathsAsync(sessionParentPath, q, SEARCH_LIMIT);
41925
+ const payload = {
41926
+ type: "file_browser_search_response",
41927
+ id: msg.id,
41928
+ paths: results,
41929
+ indexReady: true
41930
+ };
41931
+ sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["paths"]) : payload);
41932
+ })();
41933
+ }
41934
+ function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
41935
+ setImmediate(() => {
41936
+ void ensureFileIndexAsync(sessionParentPath).catch((e) => {
41937
+ console.error("[file-index] Background build failed:", e);
41938
+ });
41939
+ });
41940
+ }
41941
+
41942
+ // src/git/tree/resolve-repo-abs-path.ts
41943
+ import * as path56 from "node:path";
41944
+ function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
41945
+ const bridgeResolved = path56.resolve(bridgeRoot);
41946
+ const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
41947
+ const repoPath = rel === "" ? bridgeResolved : path56.join(bridgeResolved, rel);
41948
+ const resolved = path56.resolve(repoPath);
41949
+ if (!resolved.startsWith(bridgeResolved + path56.sep) && resolved !== bridgeResolved) {
41950
+ return null;
41951
+ }
41952
+ return resolved;
41953
+ }
41954
+
41955
+ // src/git/tree/resolve-branch-commit.ts
41956
+ async function resolveBranchCommit(repoAbsPath, branch) {
41957
+ const branchRef = branch.trim();
41958
+ if (!branchRef) return null;
41959
+ try {
41960
+ return (await cliSimpleGit(repoAbsPath).revparse([`${branchRef}^{commit}`])).trim();
41961
+ } catch {
41962
+ return null;
41963
+ }
41964
+ }
41965
+
41966
+ // src/git/tree/list-git-tree-dir.ts
41967
+ function parseLsTreeLine(line) {
41968
+ const tab = line.indexOf(" ");
41969
+ if (tab < 0) return null;
41970
+ const meta = line.slice(0, tab).trim().split(/\s+/);
41971
+ if (meta.length < 3) return null;
41972
+ const mode = meta[0];
41973
+ const objectType2 = meta[1];
41974
+ let name = line.slice(tab + 1);
41975
+ if (name.startsWith('"') && name.endsWith('"')) {
41976
+ name = name.slice(1, -1).replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
41977
+ }
41978
+ return { mode, objectType: objectType2, name };
41979
+ }
41980
+ function childPath(relativePath, name) {
41981
+ const base = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
41982
+ if (!base || base === ".") return name;
41983
+ return `${base}/${name}`.replace(/\\/g, "/");
41984
+ }
41985
+ function lsTreeArgs(commit, relativePath) {
41986
+ const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
41987
+ if (!rel || rel === ".") return ["ls-tree", commit];
41988
+ return ["ls-tree", `${commit}:${rel}`];
41989
+ }
41990
+ async function listGitTreeDirAsync(repoAbsPath, branch, relativePath) {
41991
+ await yieldToEventLoop();
41992
+ const commit = await resolveBranchCommit(repoAbsPath, branch);
41993
+ if (!commit) return { error: "Branch not found" };
41994
+ try {
41995
+ const raw = await cliSimpleGit(repoAbsPath).raw(lsTreeArgs(commit, relativePath));
41996
+ await yieldToEventLoop();
41997
+ const lines = String(raw ?? "").split(/\r?\n/).filter((line) => line.trim().length > 0);
41998
+ const entries = [];
41999
+ for (let i = 0; i < lines.length; i++) {
42000
+ if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
42001
+ await yieldToEventLoop();
42002
+ }
42003
+ const parsed = parseLsTreeLine(lines[i]);
42004
+ if (!parsed) continue;
42005
+ const { mode, objectType: objectType2, name } = parsed;
42006
+ if (!name || name === "." || name === "..") continue;
42007
+ const isSymlink = mode === "120000";
42008
+ const isDir = objectType2 === "tree";
42009
+ entries.push({
42010
+ name,
42011
+ path: childPath(relativePath, name),
42012
+ isDir,
42013
+ ...isSymlink ? { isSymlink: true } : {}
42014
+ });
42015
+ }
42016
+ if (entries.length >= LIST_DIR_YIELD_EVERY) {
42017
+ await yieldToEventLoop();
42018
+ }
42019
+ return { entries: sortListEntries(entries) };
42020
+ } catch (err) {
42021
+ const message = err instanceof Error ? err.message : String(err);
42022
+ if (/not a tree object|does not exist|bad revision/i.test(message)) {
42023
+ return { error: "Path not found in branch" };
42024
+ }
42025
+ return { error: message };
42026
+ }
42027
+ }
42028
+
41893
42029
  // src/files/read-file/types.ts
41894
42030
  var LINE_CHUNK_SIZE = 64 * 1024;
41895
42031
  var READ_RANGE_YIELD_EVERY_BYTES = 256 * 1024;
41896
42032
 
42033
+ // src/files/read-file/guess-mime-type.ts
42034
+ var MIME_BY_EXT = {
42035
+ png: "image/png",
42036
+ jpg: "image/jpeg",
42037
+ jpeg: "image/jpeg",
42038
+ gif: "image/gif",
42039
+ bmp: "image/bmp",
42040
+ ico: "image/x-icon",
42041
+ webp: "image/webp",
42042
+ avif: "image/avif",
42043
+ svg: "image/svg+xml",
42044
+ pdf: "application/pdf",
42045
+ json: "application/json",
42046
+ html: "text/html",
42047
+ htm: "text/html",
42048
+ css: "text/css",
42049
+ js: "text/javascript",
42050
+ mjs: "text/javascript",
42051
+ ts: "text/typescript",
42052
+ txt: "text/plain",
42053
+ md: "text/markdown",
42054
+ xml: "application/xml",
42055
+ zip: "application/zip",
42056
+ gz: "application/gzip",
42057
+ wasm: "application/wasm"
42058
+ };
42059
+ function guessMimeType(filePath) {
42060
+ const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
42061
+ return MIME_BY_EXT[ext] ?? "application/octet-stream";
42062
+ }
42063
+
42064
+ // src/git/tree/file/git-blob-ref.ts
42065
+ async function gitBlobRef(repoAbsPath, branch, relativePath) {
42066
+ const commit = await resolveBranchCommit(repoAbsPath, branch);
42067
+ await yieldToEventLoop();
42068
+ if (!commit) return null;
42069
+ const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
42070
+ if (!rel || rel === ".") return null;
42071
+ return `${commit}:${rel}`;
42072
+ }
42073
+
42074
+ // src/git/tree/file/is-binary-buffer.ts
42075
+ function isBinaryBuffer(buf) {
42076
+ const sample = buf.subarray(0, Math.min(buf.length, 8192));
42077
+ for (let i = 0; i < sample.length; i++) {
42078
+ if (sample[i] === 0) return true;
42079
+ }
42080
+ return false;
42081
+ }
42082
+
42083
+ // src/git/tree/file/read-git-blob-text-async.ts
42084
+ import { StringDecoder } from "node:string_decoder";
42085
+ async function countGitBlobLinesAsync(buf) {
42086
+ if (buf.length === 0) return 1;
42087
+ let lines = 1;
42088
+ let bytesSinceYield = 0;
42089
+ for (let i = 0; i < buf.length; i++) {
42090
+ const b = buf[i];
42091
+ if (b === 10) {
42092
+ lines++;
42093
+ } else if (b === 13) {
42094
+ if (i + 1 < buf.length && buf[i + 1] === 10) {
42095
+ lines++;
42096
+ i++;
42097
+ } else {
42098
+ lines++;
42099
+ }
42100
+ }
42101
+ bytesSinceYield++;
42102
+ if (bytesSinceYield >= READ_RANGE_YIELD_EVERY_BYTES) {
42103
+ await yieldToEventLoop();
42104
+ bytesSinceYield = 0;
42105
+ }
42106
+ }
42107
+ return lines;
42108
+ }
42109
+ async function readGitBlobLineRangeAsync(buf, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
42110
+ const bufSize = 64 * 1024;
42111
+ const decoder = new StringDecoder("utf8");
42112
+ let currentLine = 0;
42113
+ const resultLines = [];
42114
+ let partial2 = "";
42115
+ let done = false;
42116
+ let skipLine0Chars = typeof lineOffsetIn === "number" ? lineOffsetIn : 0;
42117
+ let line0CharsReturned = 0;
42118
+ let line0Accum = "";
42119
+ let bytesSinceYield = 0;
42120
+ let position = 0;
42121
+ const finish = async () => {
42122
+ const totalLines = await countGitBlobLinesAsync(buf);
42123
+ return { content: resultLines.join("\n"), totalLines };
42124
+ };
42125
+ while (!done && position < buf.length) {
42126
+ const chunkEnd = Math.min(position + bufSize, buf.length);
42127
+ const bytesRead = chunkEnd - position;
42128
+ position = chunkEnd;
42129
+ bytesSinceYield += bytesRead;
42130
+ if (bytesSinceYield >= READ_RANGE_YIELD_EVERY_BYTES) {
42131
+ await yieldToEventLoop();
42132
+ bytesSinceYield = 0;
42133
+ }
42134
+ const text = partial2 + decoder.write(buf.subarray(position - bytesRead, position));
42135
+ partial2 = "";
42136
+ let lineStart = 0;
42137
+ for (let i = 0; i < text.length; i++) {
42138
+ if (text[i] === "\n") {
42139
+ const lineContent = (() => {
42140
+ let lineEnd = i;
42141
+ if (lineEnd > lineStart && text[lineEnd - 1] === "\r") lineEnd--;
42142
+ return text.slice(lineStart, lineEnd);
42143
+ })();
42144
+ if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0)) {
42145
+ line0Accum += lineContent;
42146
+ const totalLine0 = line0Accum.length;
42147
+ if (skipLine0Chars > 0) {
42148
+ if (totalLine0 <= skipLine0Chars) {
42149
+ skipLine0Chars -= totalLine0;
42150
+ line0Accum = "";
42151
+ currentLine++;
42152
+ lineStart = i + 1;
42153
+ if (currentLine > endLine) {
42154
+ done = true;
42155
+ break;
42156
+ }
42157
+ continue;
42158
+ }
42159
+ const from = skipLine0Chars;
42160
+ const take = Math.min(lineChunkSize, totalLine0 - from);
42161
+ resultLines.push(line0Accum.slice(from, from + take));
42162
+ line0CharsReturned += take;
42163
+ if (from + take < totalLine0) {
42164
+ const totalLines = await countGitBlobLinesAsync(buf);
42165
+ return {
42166
+ content: resultLines.join("\n"),
42167
+ totalLines,
42168
+ lineOffset: lineOffsetIn + line0CharsReturned
42169
+ };
42170
+ }
42171
+ line0Accum = "";
42172
+ skipLine0Chars = 0;
42173
+ line0CharsReturned = 0;
42174
+ } else if (totalLine0 > lineChunkSize) {
42175
+ resultLines.push(line0Accum.slice(0, lineChunkSize));
42176
+ const totalLines = await countGitBlobLinesAsync(buf);
42177
+ return {
42178
+ content: resultLines.join("\n"),
42179
+ totalLines,
42180
+ lineOffset: lineChunkSize
42181
+ };
42182
+ } else {
42183
+ resultLines.push(line0Accum);
42184
+ line0Accum = "";
42185
+ }
42186
+ } else if (currentLine >= startLine && currentLine <= endLine) {
42187
+ resultLines.push(lineContent);
42188
+ }
42189
+ currentLine++;
42190
+ lineStart = i + 1;
42191
+ if (currentLine > endLine) {
42192
+ done = true;
42193
+ break;
42194
+ }
42195
+ }
42196
+ }
42197
+ if (!done) {
42198
+ const lineContent = text.slice(lineStart);
42199
+ if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0)) {
42200
+ line0Accum += lineContent;
42201
+ const totalLine0 = line0Accum.length;
42202
+ if (skipLine0Chars > 0) {
42203
+ if (totalLine0 <= skipLine0Chars) {
42204
+ skipLine0Chars -= totalLine0;
42205
+ line0Accum = "";
42206
+ } else {
42207
+ const from = skipLine0Chars;
42208
+ const take = Math.min(lineChunkSize, totalLine0 - from);
42209
+ resultLines.push(line0Accum.slice(from, from + take));
42210
+ const totalLines = await countGitBlobLinesAsync(buf);
42211
+ return {
42212
+ content: resultLines.join("\n"),
42213
+ totalLines,
42214
+ lineOffset: (lineOffsetIn ?? 0) + take
42215
+ };
42216
+ }
42217
+ } else if (totalLine0 > lineChunkSize) {
42218
+ resultLines.push(line0Accum.slice(0, lineChunkSize));
42219
+ const totalLines = await countGitBlobLinesAsync(buf);
42220
+ return {
42221
+ content: resultLines.join("\n"),
42222
+ totalLines,
42223
+ lineOffset: lineChunkSize
42224
+ };
42225
+ }
42226
+ }
42227
+ partial2 = text.slice(lineStart);
42228
+ }
42229
+ }
42230
+ if (!done) {
42231
+ const tail = partial2 + decoder.end();
42232
+ if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0) && tail.length > 0) {
42233
+ line0Accum += tail.endsWith("\r") ? tail.slice(0, -1) : tail;
42234
+ const totalLine0 = line0Accum.length;
42235
+ if (skipLine0Chars > 0) {
42236
+ if (totalLine0 <= skipLine0Chars) {
42237
+ return finish();
42238
+ }
42239
+ const from = skipLine0Chars;
42240
+ const take = Math.min(lineChunkSize, totalLine0 - from);
42241
+ resultLines.push(line0Accum.slice(from, from + take));
42242
+ line0CharsReturned += take;
42243
+ if (from + take < totalLine0) {
42244
+ const totalLines = await countGitBlobLinesAsync(buf);
42245
+ return {
42246
+ content: resultLines.join("\n"),
42247
+ totalLines,
42248
+ lineOffset: (lineOffsetIn ?? 0) + line0CharsReturned
42249
+ };
42250
+ }
42251
+ } else if (totalLine0 > lineChunkSize) {
42252
+ resultLines.push(line0Accum.slice(0, lineChunkSize));
42253
+ const totalLines = await countGitBlobLinesAsync(buf);
42254
+ return {
42255
+ content: resultLines.join("\n"),
42256
+ totalLines,
42257
+ lineOffset: lineChunkSize
42258
+ };
42259
+ } else {
42260
+ resultLines.push(line0Accum);
42261
+ }
42262
+ } else if (tail.length > 0 && currentLine >= startLine && currentLine <= endLine) {
42263
+ resultLines.push(tail.endsWith("\r") ? tail.slice(0, -1) : tail);
42264
+ }
42265
+ }
42266
+ return finish();
42267
+ }
42268
+ async function decodeGitBlobUtf8Async(buf) {
42269
+ await yieldToEventLoop();
42270
+ const text = buf.toString("utf8");
42271
+ await yieldToEventLoop();
42272
+ return text;
42273
+ }
42274
+ async function readGitBlobUtf8FullAsync(buf) {
42275
+ const text = await decodeGitBlobUtf8Async(buf);
42276
+ const totalLines = await countGitBlobLinesAsync(buf);
42277
+ return { content: text, totalLines };
42278
+ }
42279
+
42280
+ // src/git/tree/file/index.ts
42281
+ async function readGitTreeFileAsync(repoAbsPath, branch, relativePath, startLine, endLine, lineOffset, lineChunkSize = LINE_CHUNK_SIZE, encoding = "utf8") {
42282
+ await yieldToEventLoop();
42283
+ const branchRef = branch.trim();
42284
+ if (!branchRef) return { error: "branch required" };
42285
+ const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
42286
+ if (!rel || rel === ".") return { error: "file path required" };
42287
+ const blobRef = await gitBlobRef(repoAbsPath, branchRef, rel);
42288
+ if (!blobRef) return { error: "Branch not found" };
42289
+ const hasRange = typeof startLine === "number" && typeof endLine === "number";
42290
+ try {
42291
+ if (encoding === "base64") {
42292
+ if (hasRange) return { error: "base64 encoding requires a full file read (no line range)" };
42293
+ const buf2 = await cliSimpleGit(repoAbsPath).showBuffer([blobRef]);
42294
+ await yieldToEventLoop();
42295
+ return {
42296
+ content: buf2.toString("base64"),
42297
+ size: buf2.length,
42298
+ mimeType: guessMimeType(rel)
42299
+ };
42300
+ }
42301
+ const buf = await cliSimpleGit(repoAbsPath).showBuffer([blobRef]);
42302
+ await yieldToEventLoop();
42303
+ const size = buf.length;
42304
+ if (isBinaryBuffer(buf)) {
42305
+ return { error: "Binary file cannot be displayed as text" };
42306
+ }
42307
+ if (hasRange) {
42308
+ const ranged = await readGitBlobLineRangeAsync(buf, startLine, endLine, lineOffset, lineChunkSize);
42309
+ return {
42310
+ content: ranged.content,
42311
+ totalLines: ranged.totalLines,
42312
+ size,
42313
+ ...ranged.lineOffset != null ? { lineOffset: ranged.lineOffset } : {}
42314
+ };
42315
+ }
42316
+ const full = await readGitBlobUtf8FullAsync(buf);
42317
+ return { content: full.content, totalLines: full.totalLines, size, mimeType: guessMimeType(rel) };
42318
+ } catch (err) {
42319
+ const message = err instanceof Error ? err.message : String(err);
42320
+ if (/does not exist|bad revision|exists on disk, but not in/i.test(message)) {
42321
+ return { error: "File not found in branch" };
42322
+ }
42323
+ return { error: message };
42324
+ }
42325
+ }
42326
+
42327
+ // src/files/browser/send-file-browser-message.ts
42328
+ function sendFileBrowserMessage(socket, e2ee, payload) {
42329
+ sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
42330
+ }
42331
+
42332
+ // src/files/browser/handle-file-browser-list.ts
42333
+ async function handleFileBrowserList(socket, e2ee, id, reqPath, sessionParentPath, gitScope) {
42334
+ const result = gitScope ? await listGitTreeDirAsync(gitScope.repoAbsPath, gitScope.branch, reqPath) : await listDirAsync(reqPath, sessionParentPath);
42335
+ if ("error" in result) {
42336
+ sendWsMessage(socket, { type: "file_browser_response", id, error: result.error });
42337
+ return;
42338
+ }
42339
+ sendFileBrowserMessage(socket, e2ee, { type: "file_browser_response", id, entries: result.entries });
42340
+ if (!gitScope && (reqPath === "." || reqPath === "")) {
42341
+ triggerFileIndexBuild(sessionParentPath);
42342
+ }
42343
+ }
42344
+
41897
42345
  // src/files/read-file/resolve-file-path.ts
41898
42346
  import fs41 from "node:fs";
41899
42347
  async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeRoot()) {
@@ -41916,13 +42364,13 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
41916
42364
 
41917
42365
  // src/files/read-file/read-file-range-async.ts
41918
42366
  import fs42 from "node:fs";
41919
- import { StringDecoder } from "node:string_decoder";
42367
+ import { StringDecoder as StringDecoder2 } from "node:string_decoder";
41920
42368
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
41921
42369
  const fileSize = (await fs42.promises.stat(filePath)).size;
41922
42370
  const fd = await fs42.promises.open(filePath, "r");
41923
42371
  const bufSize = 64 * 1024;
41924
42372
  const buf = Buffer.alloc(bufSize);
41925
- const decoder = new StringDecoder("utf8");
42373
+ const decoder = new StringDecoder2("utf8");
41926
42374
  let currentLine = 0;
41927
42375
  const resultLines = [];
41928
42376
  let partial2 = "";
@@ -42116,37 +42564,6 @@ async function readFileFullAsync(filePath) {
42116
42564
  return { content: raw, totalLines: lines.length, size };
42117
42565
  }
42118
42566
 
42119
- // src/files/read-file/guess-mime-type.ts
42120
- var MIME_BY_EXT = {
42121
- png: "image/png",
42122
- jpg: "image/jpeg",
42123
- jpeg: "image/jpeg",
42124
- gif: "image/gif",
42125
- bmp: "image/bmp",
42126
- ico: "image/x-icon",
42127
- webp: "image/webp",
42128
- avif: "image/avif",
42129
- svg: "image/svg+xml",
42130
- pdf: "application/pdf",
42131
- json: "application/json",
42132
- html: "text/html",
42133
- htm: "text/html",
42134
- css: "text/css",
42135
- js: "text/javascript",
42136
- mjs: "text/javascript",
42137
- ts: "text/typescript",
42138
- txt: "text/plain",
42139
- md: "text/markdown",
42140
- xml: "application/xml",
42141
- zip: "application/zip",
42142
- gz: "application/gzip",
42143
- wasm: "application/wasm"
42144
- };
42145
- function guessMimeType(filePath) {
42146
- const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
42147
- return MIME_BY_EXT[ext] ?? "application/octet-stream";
42148
- }
42149
-
42150
42567
  // src/files/read-file/read-file-binary-full-async.ts
42151
42568
  async function readFileBinaryFullAsync(filePath) {
42152
42569
  const { buffer, size } = await readFileBufferFullAsync(filePath);
@@ -42180,104 +42597,72 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
42180
42597
  }
42181
42598
  }
42182
42599
 
42183
- // src/files/resolve-file-browser-session-parent.ts
42184
- async function resolveFileBrowserSessionParent(sessionWorktreeManager, sessionId) {
42185
- const sid = sessionId?.trim();
42186
- if (sid) {
42187
- await sessionWorktreeManager.ensureRepoCheckoutPathsForSessionAsync(sid);
42188
- const worktreeRoot = sessionWorktreeManager.getSessionWorktreeRootForSession(sid);
42189
- if (worktreeRoot) return worktreeRoot;
42600
+ // src/files/browser/handle-file-browser-read.ts
42601
+ async function handleFileBrowserRead(socket, e2ee, msg, reqPath, sessionParentPath, gitScope) {
42602
+ const startLine = typeof msg.startLine === "number" ? msg.startLine : void 0;
42603
+ const endLine = typeof msg.endLine === "number" ? msg.endLine : void 0;
42604
+ const lineOffset = typeof msg.lineOffset === "number" ? msg.lineOffset : void 0;
42605
+ const lineChunkSize = typeof msg.lineChunkSize === "number" ? msg.lineChunkSize : void 0;
42606
+ const encoding = msg.encoding === "base64" ? "base64" : "utf8";
42607
+ const result = gitScope ? await readGitTreeFileAsync(
42608
+ gitScope.repoAbsPath,
42609
+ gitScope.branch,
42610
+ reqPath,
42611
+ startLine,
42612
+ endLine,
42613
+ lineOffset,
42614
+ lineChunkSize,
42615
+ encoding
42616
+ ) : await readFileAsync(
42617
+ reqPath,
42618
+ startLine,
42619
+ endLine,
42620
+ lineOffset,
42621
+ lineChunkSize,
42622
+ sessionParentPath,
42623
+ encoding
42624
+ );
42625
+ if ("error" in result) {
42626
+ sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
42627
+ return;
42190
42628
  }
42191
- return getBridgeRoot();
42629
+ const payload = {
42630
+ type: "file_browser_response",
42631
+ id: msg.id,
42632
+ content: result.content,
42633
+ totalLines: result.totalLines,
42634
+ size: result.size
42635
+ };
42636
+ if (result.lineOffset != null) payload.lineOffset = result.lineOffset;
42637
+ if (result.mimeType != null) payload.mimeType = result.mimeType;
42638
+ if (result.resolvedPath != null) payload.resolvedPath = result.resolvedPath;
42639
+ sendFileBrowserMessage(socket, e2ee, payload);
42192
42640
  }
42193
42641
 
42194
- // src/files/handle-file-browser-search.ts
42195
- import path55 from "node:path";
42196
- var SEARCH_LIMIT = 100;
42197
- function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
42198
- void (async () => {
42199
- await yieldToEventLoop();
42200
- const q = typeof msg.q === "string" ? msg.q : "";
42201
- const sessionParentPath = path55.resolve(
42202
- sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
42203
- );
42204
- if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
42205
- const payload2 = {
42206
- type: "file_browser_search_response",
42207
- id: msg.id,
42208
- paths: [],
42209
- indexReady: false
42210
- };
42211
- sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload2, ["paths"]) : payload2);
42212
- return;
42213
- }
42214
- const results = await searchBridgeFilePathsAsync(sessionParentPath, q, SEARCH_LIMIT);
42215
- const payload = {
42216
- type: "file_browser_search_response",
42217
- id: msg.id,
42218
- paths: results,
42219
- indexReady: true
42220
- };
42221
- sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["paths"]) : payload);
42222
- })();
42223
- }
42224
- function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
42225
- setImmediate(() => {
42226
- void ensureFileIndexAsync(sessionParentPath).catch((e) => {
42227
- console.error("[file-index] Background build failed:", e);
42228
- });
42229
- });
42642
+ // src/files/browser/resolve-git-branch-scope.ts
42643
+ function resolveGitBranchScope(msg) {
42644
+ const gitBranchScope = msg.source === "git_branch" && typeof msg.repoRelPath === "string" && typeof msg.branch === "string" && msg.branch.trim().length > 0;
42645
+ if (!gitBranchScope) return null;
42646
+ const repoAbsPath = resolveRepoAbsPathFromBridge(msg.repoRelPath);
42647
+ if (!repoAbsPath) return null;
42648
+ return { repoAbsPath, branch: msg.branch.trim() };
42230
42649
  }
42231
42650
 
42232
- // src/files/handle-file-browser-request.ts
42233
- function sendFileBrowserMessage(socket, e2ee, payload) {
42234
- sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
42235
- }
42651
+ // src/files/browser/index.ts
42236
42652
  function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
42237
42653
  void (async () => {
42238
42654
  const reqPath = msg.path.replace(/^\/+/, "") || ".";
42239
42655
  const op = msg.op === "read" ? "read" : "list";
42240
42656
  const sessionParentPath = sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : void 0;
42657
+ const gitScope = resolveGitBranchScope(msg);
42658
+ if (msg.source === "git_branch" && typeof msg.repoRelPath === "string" && typeof msg.branch === "string" && msg.branch.trim().length > 0 && !gitScope) {
42659
+ sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: "Invalid repository path" });
42660
+ return;
42661
+ }
42241
42662
  if (op === "list") {
42242
- const result = await listDirAsync(reqPath, sessionParentPath);
42243
- if ("error" in result) {
42244
- sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
42245
- } else {
42246
- sendFileBrowserMessage(socket, e2ee, { type: "file_browser_response", id: msg.id, entries: result.entries });
42247
- if (reqPath === "." || reqPath === "") {
42248
- triggerFileIndexBuild(sessionParentPath);
42249
- }
42250
- }
42663
+ await handleFileBrowserList(socket, e2ee, msg.id, reqPath, sessionParentPath, gitScope);
42251
42664
  } else {
42252
- const startLine = typeof msg.startLine === "number" ? msg.startLine : void 0;
42253
- const endLine = typeof msg.endLine === "number" ? msg.endLine : void 0;
42254
- const lineOffset = typeof msg.lineOffset === "number" ? msg.lineOffset : void 0;
42255
- const lineChunkSize = typeof msg.lineChunkSize === "number" ? msg.lineChunkSize : void 0;
42256
- const encoding = msg.encoding === "base64" ? "base64" : "utf8";
42257
- const result = await readFileAsync(
42258
- reqPath,
42259
- startLine,
42260
- endLine,
42261
- lineOffset,
42262
- lineChunkSize,
42263
- sessionParentPath,
42264
- encoding
42265
- );
42266
- if ("error" in result) {
42267
- sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
42268
- } else {
42269
- const payload = {
42270
- type: "file_browser_response",
42271
- id: msg.id,
42272
- content: result.content,
42273
- totalLines: result.totalLines,
42274
- size: result.size
42275
- };
42276
- if (result.lineOffset != null) payload.lineOffset = result.lineOffset;
42277
- if (result.mimeType != null) payload.mimeType = result.mimeType;
42278
- if (result.resolvedPath != null) payload.resolvedPath = result.resolvedPath;
42279
- sendFileBrowserMessage(socket, e2ee, payload);
42280
- }
42665
+ await handleFileBrowserRead(socket, e2ee, msg, reqPath, sessionParentPath, gitScope);
42281
42666
  }
42282
42667
  })();
42283
42668
  }
@@ -42287,12 +42672,7 @@ function handleFileBrowserRequestMessage(msg, { getWs, e2ee, sessionWorktreeMana
42287
42672
  if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
42288
42673
  const socket = getWs();
42289
42674
  if (!socket) return;
42290
- handleFileBrowserRequest(
42291
- msg,
42292
- socket,
42293
- e2ee,
42294
- sessionWorktreeManager
42295
- );
42675
+ handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager);
42296
42676
  }
42297
42677
  function handleFileBrowserSearchMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
42298
42678
  if (typeof msg.id !== "string") return;
@@ -42327,7 +42707,7 @@ function isValidRemoteSkillInstallItem(item) {
42327
42707
 
42328
42708
  // src/skills/install/install-remote-skills-async.ts
42329
42709
  import fs44 from "node:fs";
42330
- import path56 from "node:path";
42710
+ import path57 from "node:path";
42331
42711
 
42332
42712
  // src/skills/install/constants.ts
42333
42713
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -42338,8 +42718,8 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
42338
42718
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
42339
42719
  await yieldToEventLoop();
42340
42720
  }
42341
- const dest = path56.join(skillDir, f.path);
42342
- await fs44.promises.mkdir(path56.dirname(dest), { recursive: true });
42721
+ const dest = path57.join(skillDir, f.path);
42722
+ await fs44.promises.mkdir(path57.dirname(dest), { recursive: true });
42343
42723
  if (f.text !== void 0) {
42344
42724
  await fs44.promises.writeFile(dest, f.text, "utf8");
42345
42725
  } else if (f.base64) {
@@ -42355,7 +42735,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
42355
42735
  try {
42356
42736
  for (const item of items) {
42357
42737
  if (!isValidRemoteSkillInstallItem(item)) continue;
42358
- const skillDir = path56.join(cwd, targetDir, item.skillName);
42738
+ const skillDir = path57.join(cwd, targetDir, item.skillName);
42359
42739
  for (const f of item.files) {
42360
42740
  await writeInstallFileAsync(skillDir, f, filesWritten);
42361
42741
  }
@@ -42694,7 +43074,7 @@ var handleDevServersConfig = (msg, deps) => {
42694
43074
  };
42695
43075
 
42696
43076
  // src/git/bridge-git-context.ts
42697
- import * as path57 from "node:path";
43077
+ import * as path58 from "node:path";
42698
43078
 
42699
43079
  // src/git/branches/get-current-branch.ts
42700
43080
  async function getCurrentBranch(repoPath) {
@@ -42744,12 +43124,12 @@ async function listRepoBranchRefs(repoPath) {
42744
43124
  // src/git/bridge-git-context.ts
42745
43125
  function folderNameForRelPath(relPath, bridgeRoot) {
42746
43126
  if (relPath === "." || relPath === "") {
42747
- return path57.basename(path57.resolve(bridgeRoot)) || "repo";
43127
+ return path58.basename(path58.resolve(bridgeRoot)) || "repo";
42748
43128
  }
42749
- return path57.basename(relPath) || relPath;
43129
+ return path58.basename(relPath) || relPath;
42750
43130
  }
42751
43131
  async function discoverGitReposForBridgeContext(bridgeRoot) {
42752
- const root = path57.resolve(bridgeRoot);
43132
+ const root = path58.resolve(bridgeRoot);
42753
43133
  if (await isGitRepoDirectory(root)) {
42754
43134
  const remoteUrl = await getRemoteOriginUrl(root);
42755
43135
  return [{ absolutePath: root, remoteUrl }];
@@ -42757,19 +43137,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
42757
43137
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
42758
43138
  const byPath = /* @__PURE__ */ new Map();
42759
43139
  for (const repo of [...deep, ...shallow]) {
42760
- byPath.set(path57.resolve(repo.absolutePath), repo);
43140
+ byPath.set(path58.resolve(repo.absolutePath), repo);
42761
43141
  }
42762
43142
  return [...byPath.values()];
42763
43143
  }
42764
43144
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
42765
- const bridgeResolved = path57.resolve(bridgeRoot);
43145
+ const bridgeResolved = path58.resolve(bridgeRoot);
42766
43146
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
42767
43147
  const rows = [];
42768
43148
  for (let i = 0; i < repos.length; i++) {
42769
43149
  if (i > 0) await yieldToEventLoop();
42770
43150
  const repo = repos[i];
42771
- let rel = path57.relative(bridgeResolved, repo.absolutePath);
42772
- if (rel.startsWith("..") || path57.isAbsolute(rel)) continue;
43151
+ let rel = path58.relative(bridgeResolved, repo.absolutePath);
43152
+ if (rel.startsWith("..") || path58.isAbsolute(rel)) continue;
42773
43153
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
42774
43154
  const currentBranch = await getCurrentBranch(repo.absolutePath);
42775
43155
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -42784,11 +43164,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
42784
43164
  return rows;
42785
43165
  }
42786
43166
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
42787
- const bridgeResolved = path57.resolve(bridgeRoot);
43167
+ const bridgeResolved = path58.resolve(bridgeRoot);
42788
43168
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
42789
- const repoPath = rel === "" ? bridgeResolved : path57.join(bridgeResolved, rel);
42790
- const resolved = path57.resolve(repoPath);
42791
- if (!resolved.startsWith(bridgeResolved + path57.sep) && resolved !== bridgeResolved) {
43169
+ const repoPath = rel === "" ? bridgeResolved : path58.join(bridgeResolved, rel);
43170
+ const resolved = path58.resolve(repoPath);
43171
+ if (!resolved.startsWith(bridgeResolved + path58.sep) && resolved !== bridgeResolved) {
42792
43172
  return [];
42793
43173
  }
42794
43174
  return listRepoBranchRefs(resolved);
@@ -43293,10 +43673,10 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
43293
43673
  }
43294
43674
 
43295
43675
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
43296
- import * as path59 from "node:path";
43676
+ import * as path60 from "node:path";
43297
43677
 
43298
43678
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
43299
- import * as path58 from "node:path";
43679
+ import * as path59 from "node:path";
43300
43680
  async function probeOneAgentTypeForCapabilities(params) {
43301
43681
  const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
43302
43682
  const canContinue = () => shouldContinue?.() !== false;
@@ -43334,7 +43714,7 @@ async function probeOneAgentTypeForCapabilities(params) {
43334
43714
  if (!canContinue()) return false;
43335
43715
  handle = await resolved.createClient({
43336
43716
  command: resolved.command,
43337
- cwd: path58.resolve(cwd),
43717
+ cwd: path59.resolve(cwd),
43338
43718
  backendAgentType: agentType,
43339
43719
  sessionMode: "agent",
43340
43720
  persistedAcpSessionId: null,
@@ -43412,7 +43792,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
43412
43792
  const { workspaceId, log: log2, getWs } = params;
43413
43793
  const isCurrent = beginAgentCapabilityWarmupRun();
43414
43794
  if (!isCurrent()) return;
43415
- const cwd = path59.resolve(getBridgeRoot());
43795
+ const cwd = path60.resolve(getBridgeRoot());
43416
43796
  async function sendBatchFromCache() {
43417
43797
  if (!isCurrent()) return;
43418
43798
  const socket = getWs();
@@ -43758,18 +44138,18 @@ import * as http from "node:http";
43758
44138
 
43759
44139
  // src/mcp/bridge-access/read-json-body.ts
43760
44140
  function readJsonBody(req) {
43761
- return new Promise((resolve34, reject) => {
44141
+ return new Promise((resolve35, reject) => {
43762
44142
  const chunks = [];
43763
44143
  req.on("data", (chunk) => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
43764
44144
  req.on("end", () => {
43765
44145
  try {
43766
44146
  const raw = Buffer.concat(chunks).toString("utf8").trim();
43767
44147
  if (!raw) {
43768
- resolve34({});
44148
+ resolve35({});
43769
44149
  return;
43770
44150
  }
43771
44151
  const parsed = JSON.parse(raw);
43772
- resolve34(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
44152
+ resolve35(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
43773
44153
  } catch (e) {
43774
44154
  reject(e);
43775
44155
  }
@@ -43827,7 +44207,7 @@ function createBridgeAccessRequestHandler(registry2) {
43827
44207
  // src/mcp/bridge-access/start-server.ts
43828
44208
  function startBridgeAccessServer(registry2) {
43829
44209
  const server = http.createServer(createBridgeAccessRequestHandler(registry2));
43830
- return new Promise((resolve34, reject) => {
44210
+ return new Promise((resolve35, reject) => {
43831
44211
  server.once("error", reject);
43832
44212
  server.listen(0, "127.0.0.1", () => {
43833
44213
  const addr = server.address();
@@ -43835,7 +44215,7 @@ function startBridgeAccessServer(registry2) {
43835
44215
  reject(new Error("Bridge access server did not bind"));
43836
44216
  return;
43837
44217
  }
43838
- resolve34({
44218
+ resolve35({
43839
44219
  port: addr.port,
43840
44220
  close: () => new Promise((closeResolve, closeReject) => {
43841
44221
  server.close((err) => err ? closeReject(err) : closeResolve());
@@ -43975,8 +44355,8 @@ async function createBridgeConnection(options) {
43975
44355
  getCloudAccessToken: () => tokens.accessToken
43976
44356
  };
43977
44357
  const identifyReportedPaths = {
43978
- bridgeRootPath: path60.resolve(getBridgeRoot()),
43979
- worktreesRootPath: path60.resolve(worktreesRootPath)
44358
+ bridgeRootPath: path61.resolve(getBridgeRoot()),
44359
+ worktreesRootPath: path61.resolve(worktreesRootPath)
43980
44360
  };
43981
44361
  const { connect } = createMainBridgeWebSocketLifecycle({
43982
44362
  state,
@@ -44231,7 +44611,7 @@ async function runCliAction(program2, opts) {
44231
44611
  const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
44232
44612
  const bridgeRootOpt = (opts.bridgeRoot && typeof opts.bridgeRoot === "string" && opts.bridgeRoot.trim() ? opts.bridgeRoot.trim() : null) ?? (opts.cwd && typeof opts.cwd === "string" && opts.cwd.trim() ? opts.cwd.trim() : null);
44233
44613
  if (bridgeRootOpt) {
44234
- const resolvedBridgeRoot = path61.resolve(process.cwd(), bridgeRootOpt);
44614
+ const resolvedBridgeRoot = path62.resolve(process.cwd(), bridgeRootOpt);
44235
44615
  try {
44236
44616
  const st = fs46.statSync(resolvedBridgeRoot);
44237
44617
  if (!st.isDirectory()) {
@@ -44253,7 +44633,7 @@ async function runCliAction(program2, opts) {
44253
44633
  );
44254
44634
  let worktreesRootPath;
44255
44635
  if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
44256
- worktreesRootPath = path61.resolve(opts.worktreesRoot.trim());
44636
+ worktreesRootPath = path62.resolve(opts.worktreesRoot.trim());
44257
44637
  }
44258
44638
  const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
44259
44639
  if (e2eCertificates) {