@buildautomaton/cli 0.1.84 → 0.1.86

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,8 +973,8 @@ 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 path88 = __require("node:path");
977
- var fs67 = __require("node:fs");
976
+ var path90 = __require("node:path");
977
+ var fs69 = __require("node:fs");
978
978
  var process9 = __require("node:process");
979
979
  var { Argument: Argument2, humanReadableArgName } = require_argument();
980
980
  var { CommanderError: CommanderError2 } = require_error();
@@ -1906,11 +1906,11 @@ 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 = path88.resolve(baseDir, baseName);
1910
- if (fs67.existsSync(localBin)) return localBin;
1911
- if (sourceExt.includes(path88.extname(baseName))) return void 0;
1909
+ const localBin = path90.resolve(baseDir, baseName);
1910
+ if (fs69.existsSync(localBin)) return localBin;
1911
+ if (sourceExt.includes(path90.extname(baseName))) return void 0;
1912
1912
  const foundExt = sourceExt.find(
1913
- (ext) => fs67.existsSync(`${localBin}${ext}`)
1913
+ (ext) => fs69.existsSync(`${localBin}${ext}`)
1914
1914
  );
1915
1915
  if (foundExt) return `${localBin}${foundExt}`;
1916
1916
  return void 0;
@@ -1922,21 +1922,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1922
  if (this._scriptPath) {
1923
1923
  let resolvedScriptPath;
1924
1924
  try {
1925
- resolvedScriptPath = fs67.realpathSync(this._scriptPath);
1925
+ resolvedScriptPath = fs69.realpathSync(this._scriptPath);
1926
1926
  } catch (err) {
1927
1927
  resolvedScriptPath = this._scriptPath;
1928
1928
  }
1929
- executableDir = path88.resolve(
1930
- path88.dirname(resolvedScriptPath),
1929
+ executableDir = path90.resolve(
1930
+ path90.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 = path88.basename(
1937
+ const legacyName = path90.basename(
1938
1938
  this._scriptPath,
1939
- path88.extname(this._scriptPath)
1939
+ path90.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(path88.extname(executableFile));
1950
+ launchWithNode = sourceExt.includes(path90.extname(executableFile));
1951
1951
  let proc;
1952
1952
  if (process9.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 = path88.basename(filename, path88.extname(filename));
2790
+ this._name = path90.basename(filename, path90.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(path89) {
2805
- if (path89 === void 0) return this._executableDir;
2806
- this._executableDir = path89;
2804
+ executableDir(path91) {
2805
+ if (path91 === void 0) return this._executableDir;
2806
+ this._executableDir = path91;
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -7729,7 +7729,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
7729
7729
  join3(moduleDir, "..", sub, filename),
7730
7730
  join3(moduleDir, "..", "..", "dist", sub, filename)
7731
7731
  ]);
7732
- const resolved = candidates.find((path88) => existsSync(path88));
7732
+ const resolved = candidates.find((path90) => existsSync(path90));
7733
7733
  if (!resolved) {
7734
7734
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
7735
7735
  }
@@ -8807,7 +8807,7 @@ var require_ignore = __commonJS({
8807
8807
  // path matching.
8808
8808
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
8809
8809
  // @returns {TestResult} true if a file is ignored
8810
- test(path88, checkUnignored, mode) {
8810
+ test(path90, checkUnignored, mode) {
8811
8811
  let ignored = false;
8812
8812
  let unignored = false;
8813
8813
  let matchedRule;
@@ -8816,7 +8816,7 @@ var require_ignore = __commonJS({
8816
8816
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
8817
8817
  return;
8818
8818
  }
8819
- const matched = rule[mode].test(path88);
8819
+ const matched = rule[mode].test(path90);
8820
8820
  if (!matched) {
8821
8821
  return;
8822
8822
  }
@@ -8837,17 +8837,17 @@ var require_ignore = __commonJS({
8837
8837
  var throwError = (message, Ctor) => {
8838
8838
  throw new Ctor(message);
8839
8839
  };
8840
- var checkPath = (path88, originalPath, doThrow) => {
8841
- if (!isString(path88)) {
8840
+ var checkPath = (path90, originalPath, doThrow) => {
8841
+ if (!isString(path90)) {
8842
8842
  return doThrow(
8843
8843
  `path must be a string, but got \`${originalPath}\``,
8844
8844
  TypeError
8845
8845
  );
8846
8846
  }
8847
- if (!path88) {
8847
+ if (!path90) {
8848
8848
  return doThrow(`path must not be empty`, TypeError);
8849
8849
  }
8850
- if (checkPath.isNotRelative(path88)) {
8850
+ if (checkPath.isNotRelative(path90)) {
8851
8851
  const r = "`path.relative()`d";
8852
8852
  return doThrow(
8853
8853
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -8856,7 +8856,7 @@ var require_ignore = __commonJS({
8856
8856
  }
8857
8857
  return true;
8858
8858
  };
8859
- var isNotRelative = (path88) => REGEX_TEST_INVALID_PATH.test(path88);
8859
+ var isNotRelative = (path90) => REGEX_TEST_INVALID_PATH.test(path90);
8860
8860
  checkPath.isNotRelative = isNotRelative;
8861
8861
  checkPath.convert = (p) => p;
8862
8862
  var Ignore = class {
@@ -8886,19 +8886,19 @@ var require_ignore = __commonJS({
8886
8886
  }
8887
8887
  // @returns {TestResult}
8888
8888
  _test(originalPath, cache2, checkUnignored, slices) {
8889
- const path88 = originalPath && checkPath.convert(originalPath);
8889
+ const path90 = originalPath && checkPath.convert(originalPath);
8890
8890
  checkPath(
8891
- path88,
8891
+ path90,
8892
8892
  originalPath,
8893
8893
  this._strictPathCheck ? throwError : RETURN_FALSE
8894
8894
  );
8895
- return this._t(path88, cache2, checkUnignored, slices);
8895
+ return this._t(path90, cache2, checkUnignored, slices);
8896
8896
  }
8897
- checkIgnore(path88) {
8898
- if (!REGEX_TEST_TRAILING_SLASH.test(path88)) {
8899
- return this.test(path88);
8897
+ checkIgnore(path90) {
8898
+ if (!REGEX_TEST_TRAILING_SLASH.test(path90)) {
8899
+ return this.test(path90);
8900
8900
  }
8901
- const slices = path88.split(SLASH).filter(Boolean);
8901
+ const slices = path90.split(SLASH).filter(Boolean);
8902
8902
  slices.pop();
8903
8903
  if (slices.length) {
8904
8904
  const parent = this._t(
@@ -8911,18 +8911,18 @@ var require_ignore = __commonJS({
8911
8911
  return parent;
8912
8912
  }
8913
8913
  }
8914
- return this._rules.test(path88, false, MODE_CHECK_IGNORE);
8914
+ return this._rules.test(path90, false, MODE_CHECK_IGNORE);
8915
8915
  }
8916
- _t(path88, cache2, checkUnignored, slices) {
8917
- if (path88 in cache2) {
8918
- return cache2[path88];
8916
+ _t(path90, cache2, checkUnignored, slices) {
8917
+ if (path90 in cache2) {
8918
+ return cache2[path90];
8919
8919
  }
8920
8920
  if (!slices) {
8921
- slices = path88.split(SLASH).filter(Boolean);
8921
+ slices = path90.split(SLASH).filter(Boolean);
8922
8922
  }
8923
8923
  slices.pop();
8924
8924
  if (!slices.length) {
8925
- return cache2[path88] = this._rules.test(path88, checkUnignored, MODE_IGNORE);
8925
+ return cache2[path90] = this._rules.test(path90, checkUnignored, MODE_IGNORE);
8926
8926
  }
8927
8927
  const parent = this._t(
8928
8928
  slices.join(SLASH) + SLASH,
@@ -8930,29 +8930,29 @@ var require_ignore = __commonJS({
8930
8930
  checkUnignored,
8931
8931
  slices
8932
8932
  );
8933
- return cache2[path88] = parent.ignored ? parent : this._rules.test(path88, checkUnignored, MODE_IGNORE);
8933
+ return cache2[path90] = parent.ignored ? parent : this._rules.test(path90, checkUnignored, MODE_IGNORE);
8934
8934
  }
8935
- ignores(path88) {
8936
- return this._test(path88, this._ignoreCache, false).ignored;
8935
+ ignores(path90) {
8936
+ return this._test(path90, this._ignoreCache, false).ignored;
8937
8937
  }
8938
8938
  createFilter() {
8939
- return (path88) => !this.ignores(path88);
8939
+ return (path90) => !this.ignores(path90);
8940
8940
  }
8941
8941
  filter(paths) {
8942
8942
  return makeArray(paths).filter(this.createFilter());
8943
8943
  }
8944
8944
  // @returns {TestResult}
8945
- test(path88) {
8946
- return this._test(path88, this._testCache, true);
8945
+ test(path90) {
8946
+ return this._test(path90, this._testCache, true);
8947
8947
  }
8948
8948
  };
8949
8949
  var factory = (options) => new Ignore(options);
8950
- var isPathValid = (path88) => checkPath(path88 && checkPath.convert(path88), path88, RETURN_FALSE);
8950
+ var isPathValid = (path90) => checkPath(path90 && checkPath.convert(path90), path90, RETURN_FALSE);
8951
8951
  var setupWindows = () => {
8952
8952
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
8953
8953
  checkPath.convert = makePosix;
8954
8954
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
8955
- checkPath.isNotRelative = (path88) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path88) || isNotRelative(path88);
8955
+ checkPath.isNotRelative = (path90) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path90) || isNotRelative(path90);
8956
8956
  };
8957
8957
  if (
8958
8958
  // Detect `process` so that it can run in browsers.
@@ -12913,10 +12913,10 @@ function mergeDefs(...defs) {
12913
12913
  function cloneDef(schema) {
12914
12914
  return mergeDefs(schema._zod.def);
12915
12915
  }
12916
- function getElementAtPath(obj, path88) {
12917
- if (!path88)
12916
+ function getElementAtPath(obj, path90) {
12917
+ if (!path90)
12918
12918
  return obj;
12919
- return path88.reduce((acc, key) => acc?.[key], obj);
12919
+ return path90.reduce((acc, key) => acc?.[key], obj);
12920
12920
  }
12921
12921
  function promiseAllObject(promisesObj) {
12922
12922
  const keys = Object.keys(promisesObj);
@@ -13244,11 +13244,11 @@ function explicitlyAborted(x, startIndex = 0) {
13244
13244
  }
13245
13245
  return false;
13246
13246
  }
13247
- function prefixIssues(path88, issues) {
13247
+ function prefixIssues(path90, issues) {
13248
13248
  return issues.map((iss) => {
13249
13249
  var _a4;
13250
13250
  (_a4 = iss).path ?? (_a4.path = []);
13251
- iss.path.unshift(path88);
13251
+ iss.path.unshift(path90);
13252
13252
  return iss;
13253
13253
  });
13254
13254
  }
@@ -13465,16 +13465,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
13465
13465
  }
13466
13466
  function formatError(error51, mapper = (issue2) => issue2.message) {
13467
13467
  const fieldErrors = { _errors: [] };
13468
- const processError = (error52, path88 = []) => {
13468
+ const processError = (error52, path90 = []) => {
13469
13469
  for (const issue2 of error52.issues) {
13470
13470
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13471
- issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
13471
+ issue2.errors.map((issues) => processError({ issues }, [...path90, ...issue2.path]));
13472
13472
  } else if (issue2.code === "invalid_key") {
13473
- processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
13473
+ processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
13474
13474
  } else if (issue2.code === "invalid_element") {
13475
- processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
13475
+ processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
13476
13476
  } else {
13477
- const fullpath = [...path88, ...issue2.path];
13477
+ const fullpath = [...path90, ...issue2.path];
13478
13478
  if (fullpath.length === 0) {
13479
13479
  fieldErrors._errors.push(mapper(issue2));
13480
13480
  } else {
@@ -13501,17 +13501,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
13501
13501
  }
13502
13502
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
13503
13503
  const result = { errors: [] };
13504
- const processError = (error52, path88 = []) => {
13504
+ const processError = (error52, path90 = []) => {
13505
13505
  var _a4, _b;
13506
13506
  for (const issue2 of error52.issues) {
13507
13507
  if (issue2.code === "invalid_union" && issue2.errors.length) {
13508
- issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
13508
+ issue2.errors.map((issues) => processError({ issues }, [...path90, ...issue2.path]));
13509
13509
  } else if (issue2.code === "invalid_key") {
13510
- processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
13510
+ processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
13511
13511
  } else if (issue2.code === "invalid_element") {
13512
- processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
13512
+ processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
13513
13513
  } else {
13514
- const fullpath = [...path88, ...issue2.path];
13514
+ const fullpath = [...path90, ...issue2.path];
13515
13515
  if (fullpath.length === 0) {
13516
13516
  result.errors.push(mapper(issue2));
13517
13517
  continue;
@@ -13543,8 +13543,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
13543
13543
  }
13544
13544
  function toDotPath(_path) {
13545
13545
  const segs = [];
13546
- const path88 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
13547
- for (const seg of path88) {
13546
+ const path90 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
13547
+ for (const seg of path90) {
13548
13548
  if (typeof seg === "number")
13549
13549
  segs.push(`[${seg}]`);
13550
13550
  else if (typeof seg === "symbol")
@@ -26974,13 +26974,13 @@ function resolveRef(ref, ctx) {
26974
26974
  if (!ref.startsWith("#")) {
26975
26975
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
26976
26976
  }
26977
- const path88 = ref.slice(1).split("/").filter(Boolean);
26978
- if (path88.length === 0) {
26977
+ const path90 = ref.slice(1).split("/").filter(Boolean);
26978
+ if (path90.length === 0) {
26979
26979
  return ctx.rootSchema;
26980
26980
  }
26981
26981
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
26982
- if (path88[0] === defsKey) {
26983
- const key = path88[1];
26982
+ if (path90[0] === defsKey) {
26983
+ const key = path90[1];
26984
26984
  if (!key || !ctx.defs[key]) {
26985
26985
  throw new Error(`Reference not found: ${ref}`);
26986
26986
  }
@@ -30063,7 +30063,7 @@ var require_has_flag = __commonJS({
30063
30063
  var require_supports_color = __commonJS({
30064
30064
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
30065
30065
  "use strict";
30066
- var os10 = __require("os");
30066
+ var os11 = __require("os");
30067
30067
  var tty = __require("tty");
30068
30068
  var hasFlag = require_has_flag();
30069
30069
  var { env } = process;
@@ -30111,7 +30111,7 @@ var require_supports_color = __commonJS({
30111
30111
  return min;
30112
30112
  }
30113
30113
  if (process.platform === "win32") {
30114
- const osRelease = os10.release().split(".");
30114
+ const osRelease = os11.release().split(".");
30115
30115
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
30116
30116
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
30117
30117
  }
@@ -30357,10 +30357,10 @@ var require_src2 = __commonJS({
30357
30357
  var fs_1 = __require("fs");
30358
30358
  var debug_1 = __importDefault(require_src());
30359
30359
  var log2 = debug_1.default("@kwsites/file-exists");
30360
- function check2(path88, isFile, isDirectory) {
30361
- log2(`checking %s`, path88);
30360
+ function check2(path90, isFile, isDirectory) {
30361
+ log2(`checking %s`, path90);
30362
30362
  try {
30363
- const stat3 = fs_1.statSync(path88);
30363
+ const stat3 = fs_1.statSync(path90);
30364
30364
  if (stat3.isFile() && isFile) {
30365
30365
  log2(`[OK] path represents a file`);
30366
30366
  return true;
@@ -30380,8 +30380,8 @@ var require_src2 = __commonJS({
30380
30380
  throw e;
30381
30381
  }
30382
30382
  }
30383
- function exists2(path88, type = exports.READABLE) {
30384
- return check2(path88, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
30383
+ function exists2(path90, type = exports.READABLE) {
30384
+ return check2(path90, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
30385
30385
  }
30386
30386
  exports.exists = exists2;
30387
30387
  exports.FILE = 1;
@@ -30462,7 +30462,7 @@ var {
30462
30462
  } = import_index.default;
30463
30463
 
30464
30464
  // src/cli-version.ts
30465
- var CLI_VERSION = "0.1.84".length > 0 ? "0.1.84" : "0.0.0-dev";
30465
+ var CLI_VERSION = "0.1.86".length > 0 ? "0.1.86" : "0.0.0-dev";
30466
30466
 
30467
30467
  // src/cli/defaults.ts
30468
30468
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -30470,8 +30470,8 @@ var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
30470
30470
 
30471
30471
  // src/cli/run-cli-action.ts
30472
30472
  init_cli_log_level();
30473
- import * as fs66 from "node:fs";
30474
- import * as path87 from "node:path";
30473
+ import * as fs68 from "node:fs";
30474
+ import * as path89 from "node:path";
30475
30475
 
30476
30476
  // src/config.ts
30477
30477
  import fs from "node:fs";
@@ -33552,8 +33552,8 @@ async function cancelRun(ctx, runId) {
33552
33552
  }
33553
33553
 
33554
33554
  // src/agents/acp/ensure-acp-client.ts
33555
- import * as fs24 from "node:fs";
33556
- import * as path30 from "node:path";
33555
+ import * as fs25 from "node:fs";
33556
+ import * as path32 from "node:path";
33557
33557
 
33558
33558
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
33559
33559
  var external_exports = {};
@@ -34033,8 +34033,8 @@ function getErrorMap() {
34033
34033
 
34034
34034
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
34035
34035
  var makeIssue = (params) => {
34036
- const { data, path: path88, errorMaps, issueData } = params;
34037
- const fullPath = [...path88, ...issueData.path || []];
34036
+ const { data, path: path90, errorMaps, issueData } = params;
34037
+ const fullPath = [...path90, ...issueData.path || []];
34038
34038
  const fullIssue = {
34039
34039
  ...issueData,
34040
34040
  path: fullPath
@@ -34150,11 +34150,11 @@ var errorUtil;
34150
34150
 
34151
34151
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
34152
34152
  var ParseInputLazyPath = class {
34153
- constructor(parent, value, path88, key) {
34153
+ constructor(parent, value, path90, key) {
34154
34154
  this._cachedPath = [];
34155
34155
  this.parent = parent;
34156
34156
  this.data = value;
34157
- this._path = path88;
34157
+ this._path = path90;
34158
34158
  this._key = key;
34159
34159
  }
34160
34160
  get path() {
@@ -38468,6 +38468,11 @@ var INSTALLABLE_BRIDGE_AGENTS = [
38468
38468
  { value: "opencode", label: "OpenCode agent", tokenLabel: "Provider API key", tokenEnvVar: "OPENCODE_API_KEY" }
38469
38469
  ];
38470
38470
 
38471
+ // ../types/src/agent-subscriptions.ts
38472
+ var AGENT_SUBSCRIPTION_TYPES = INSTALLABLE_BRIDGE_AGENTS.map(
38473
+ (a) => a.value
38474
+ );
38475
+
38471
38476
  // src/paths/session-layout-paths.ts
38472
38477
  import * as path26 from "node:path";
38473
38478
  function resolveIsolatedSessionParentPathFromCheckouts(worktreePaths) {
@@ -39733,6 +39738,7 @@ init_log();
39733
39738
  function createCursorAcpSessionContext(options) {
39734
39739
  const suppressLoadReplayRef = { value: false };
39735
39740
  return {
39741
+ cloudSessionId: options.cloudSessionId,
39736
39742
  cwd: options.cwd,
39737
39743
  onFileChange: options.onFileChange,
39738
39744
  mcpServers: options.mcpServers ?? [],
@@ -39825,14 +39831,80 @@ function createCursorAcpHandle(options) {
39825
39831
  // src/agents/acp/clients/cursor/cursor-acp-init.ts
39826
39832
  import * as readline from "node:readline";
39827
39833
 
39834
+ // src/agents/acp/clients/cursor/cursor-incoming-cursor-create-plan.ts
39835
+ function buildCursorCreatePlanToolCallUpdate(requestId, params) {
39836
+ const toolCallId = params.toolCallId ?? params.tool_call_id;
39837
+ if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
39838
+ const name = typeof params.name === "string" ? params.name.trim() : "";
39839
+ const overview = typeof params.overview === "string" ? params.overview : void 0;
39840
+ const plan = typeof params.plan === "string" ? params.plan : "";
39841
+ const todos = Array.isArray(params.todos) ? params.todos : void 0;
39842
+ const phases = Array.isArray(params.phases) ? params.phases : void 0;
39843
+ const isProject = typeof params.isProject === "boolean" ? params.isProject : void 0;
39844
+ return {
39845
+ sessionUpdate: "tool_call",
39846
+ toolCallId,
39847
+ title: name || "Plan",
39848
+ status: "pending",
39849
+ cursorPlan: {
39850
+ requestId,
39851
+ ...name ? { name } : {},
39852
+ ...overview != null ? { overview } : {},
39853
+ plan,
39854
+ ...todos != null ? { todos } : {},
39855
+ ...phases != null ? { phases } : {},
39856
+ ...isProject != null ? { isProject } : {}
39857
+ }
39858
+ };
39859
+ }
39860
+ function queueCursorCreatePlanRequest(method, id, msg, deps) {
39861
+ const params = msg.params ?? {};
39862
+ const requestId = String(id);
39863
+ deps.pendingRequests.set(id, { method, params });
39864
+ const update = buildCursorCreatePlanToolCallUpdate(requestId, params);
39865
+ if (update) deps.onSessionUpdate?.(update);
39866
+ deps.onRequest?.({ requestId, method, params });
39867
+ }
39868
+
39869
+ // src/agents/acp/clients/cursor/cursor-incoming-cursor-task.ts
39870
+ function buildCursorTaskToolCallUpdate(params) {
39871
+ const toolCallId = params.toolCallId ?? params.tool_call_id;
39872
+ if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
39873
+ const description = typeof params.description === "string" ? params.description.trim() : "";
39874
+ const prompt = typeof params.prompt === "string" ? params.prompt : void 0;
39875
+ const subagentType = params.subagentType ?? params.subagent_type;
39876
+ const model = typeof params.model === "string" ? params.model : void 0;
39877
+ const agentId = typeof params.agentId === "string" ? params.agentId : typeof params.agent_id === "string" ? params.agent_id : void 0;
39878
+ const durationMs = typeof params.durationMs === "number" ? params.durationMs : typeof params.duration_ms === "number" ? params.duration_ms : void 0;
39879
+ return {
39880
+ sessionUpdate: "tool_call_update",
39881
+ toolCallId,
39882
+ ...description ? { title: description } : {},
39883
+ cursorTask: {
39884
+ ...description ? { description } : {},
39885
+ ...prompt != null ? { prompt } : {},
39886
+ ...subagentType != null ? { subagentType } : {},
39887
+ ...model != null ? { model } : {},
39888
+ ...agentId != null ? { agentId } : {},
39889
+ ...durationMs != null ? { durationMs } : {}
39890
+ }
39891
+ };
39892
+ }
39893
+ function handleCursorIncomingCursorTask(id, msg, deps) {
39894
+ const params = msg.params ?? {};
39895
+ deps.respond(id, {});
39896
+ const update = buildCursorTaskToolCallUpdate(params);
39897
+ if (update) deps.onSessionUpdate?.(update);
39898
+ }
39899
+
39828
39900
  // src/agents/acp/clients/cursor/cursor-incoming-cursor-methods.ts
39829
- var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/create_plan", "cursor/ask_question"]);
39830
- var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set([
39831
- "cursor/update_todos",
39832
- "cursor/task",
39833
- "cursor/generate_image"
39834
- ]);
39901
+ var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/ask_question"]);
39902
+ var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set(["cursor/update_todos", "cursor/generate_image"]);
39835
39903
  function handleCursorIncomingCursorMethods(method, id, msg, deps) {
39904
+ if (method === "cursor/create_plan") {
39905
+ queueCursorCreatePlanRequest(method, id, msg, deps);
39906
+ return true;
39907
+ }
39836
39908
  if (CURSOR_BRIDGE_METHODS.has(method)) {
39837
39909
  const params = msg.params ?? {};
39838
39910
  deps.pendingRequests.set(id, { method, params });
@@ -39843,6 +39915,10 @@ function handleCursorIncomingCursorMethods(method, id, msg, deps) {
39843
39915
  });
39844
39916
  return true;
39845
39917
  }
39918
+ if (method === "cursor/task") {
39919
+ handleCursorIncomingCursorTask(id, msg, deps);
39920
+ return true;
39921
+ }
39846
39922
  if (CURSOR_NOOP_METHODS.has(method)) {
39847
39923
  deps.respond(id, {});
39848
39924
  return true;
@@ -39942,10 +40018,71 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
39942
40018
  return true;
39943
40019
  }
39944
40020
 
40021
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
40022
+ import * as fs24 from "node:fs";
40023
+ import * as path29 from "node:path";
40024
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
40025
+
40026
+ // src/paths/session-plans-paths.ts
40027
+ import * as os8 from "node:os";
40028
+ import * as path28 from "node:path";
40029
+ function getSessionPlansRootDir() {
40030
+ return path28.join(os8.homedir(), ".buildautomaton", "plans");
40031
+ }
40032
+ function sanitizeSessionPlansKey(sessionId) {
40033
+ const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
40034
+ return t || "session";
40035
+ }
40036
+ function getSessionPlansDir(sessionId) {
40037
+ return path28.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
40038
+ }
40039
+
40040
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
40041
+ function sanitizePlanFileBase(toolCallId) {
40042
+ const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
40043
+ return t || "plan";
40044
+ }
40045
+ function writeCreatePlanFile(params) {
40046
+ const dir = getSessionPlansDir(params.cloudSessionId);
40047
+ fs24.mkdirSync(dir, { recursive: true });
40048
+ const filePath = path29.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
40049
+ fs24.writeFileSync(filePath, params.planMarkdown, "utf8");
40050
+ return pathToFileURL2(filePath).href;
40051
+ }
40052
+
40053
+ // src/agents/acp/clients/cursor/enrich-create-plan-rpc-result.ts
40054
+ function asRecord2(v) {
40055
+ return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
40056
+ }
40057
+ function enrichCreatePlanRpcResult(result, pendingParams, cloudSessionId) {
40058
+ const root = asRecord2(result);
40059
+ const outcome = asRecord2(root?.outcome);
40060
+ if (!outcome) return result;
40061
+ const kind = typeof outcome.outcome === "string" ? outcome.outcome : "";
40062
+ if (kind !== "accepted") {
40063
+ const { plan: _drop, ...rest } = outcome;
40064
+ return { ...root, outcome: rest };
40065
+ }
40066
+ const planMarkdown = typeof outcome.plan === "string" ? outcome.plan : "";
40067
+ const toolCallIdRaw = pendingParams.toolCallId ?? pendingParams.tool_call_id;
40068
+ const toolCallId = typeof toolCallIdRaw === "string" ? toolCallIdRaw.trim() : "";
40069
+ const sessionId = cloudSessionId?.trim() ?? "";
40070
+ if (planMarkdown && toolCallId && sessionId) {
40071
+ const planUri = writeCreatePlanFile({ cloudSessionId: sessionId, toolCallId, planMarkdown });
40072
+ return { outcome: { outcome: "accepted", planUri } };
40073
+ }
40074
+ return { outcome: { outcome: "accepted" } };
40075
+ }
40076
+
39945
40077
  // src/agents/acp/clients/cursor/cursor-incoming-resolve-request.ts
39946
- function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result) {
40078
+ function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result, cloudSessionId) {
39947
40079
  const pending2 = pendingRequests2.get(requestId);
39948
- const payload = pending2?.method === "session/request_permission" ? enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params) : result;
40080
+ let payload = result;
40081
+ if (pending2?.method === "session/request_permission") {
40082
+ payload = enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params);
40083
+ } else if (pending2?.method === "cursor/create_plan") {
40084
+ payload = enrichCreatePlanRpcResult(result, pending2.params, cloudSessionId ?? void 0);
40085
+ }
39949
40086
  respond(requestId, payload);
39950
40087
  pendingRequests2.delete(requestId);
39951
40088
  }
@@ -40002,10 +40139,17 @@ function createCursorAcpIncomingLineHandler(deps) {
40002
40139
  respond: deps.respond,
40003
40140
  respondJsonRpcError: deps.respondJsonRpcError,
40004
40141
  onRequest: deps.onRequest,
40142
+ onSessionUpdate: deps.onSessionUpdate,
40005
40143
  pendingRequests: deps.pendingRequests
40006
40144
  };
40007
40145
  return {
40008
- resolveRequest: (requestId, result) => resolveCursorIncomingRequest(deps.pendingRequests, deps.respond, requestId, result),
40146
+ resolveRequest: (requestId, result) => resolveCursorIncomingRequest(
40147
+ deps.pendingRequests,
40148
+ deps.respond,
40149
+ requestId,
40150
+ result,
40151
+ deps.sessionCtx.cloudSessionId
40152
+ ),
40009
40153
  handleLine(line) {
40010
40154
  const msg = safeJsonParse(line);
40011
40155
  if (!msg) return;
@@ -40208,6 +40352,7 @@ async function createCursorAcpClient(options) {
40208
40352
  const skipBrowserAuthenticate = cursorAgentUsesApiKeyAuth(spawnEnv);
40209
40353
  const sessionCtx = createCursorAcpSessionContext({
40210
40354
  cwd,
40355
+ cloudSessionId: options.cloudSessionId,
40211
40356
  mcpServers: options.mcpServers,
40212
40357
  persistedAcpSessionId,
40213
40358
  backendAgentType,
@@ -40357,18 +40502,18 @@ import { existsSync as existsSync4, statSync } from "node:fs";
40357
40502
 
40358
40503
  // src/git/get-git-repo-root-sync.ts
40359
40504
  import { execFileSync as execFileSync3 } from "node:child_process";
40360
- import * as path28 from "node:path";
40505
+ import * as path30 from "node:path";
40361
40506
  var GIT_LOOKUP_TIMEOUT_MS = 2e3;
40362
40507
  function getGitRepoRootSync(startDir) {
40363
40508
  try {
40364
40509
  const out = execFileSync3("git", ["rev-parse", "--show-toplevel"], {
40365
- cwd: path28.resolve(startDir),
40510
+ cwd: path30.resolve(startDir),
40366
40511
  encoding: "utf8",
40367
40512
  stdio: ["ignore", "pipe", "ignore"],
40368
40513
  maxBuffer: 1024 * 1024,
40369
40514
  timeout: GIT_LOOKUP_TIMEOUT_MS
40370
40515
  }).trim();
40371
- return out ? path28.resolve(out) : null;
40516
+ return out ? path30.resolve(out) : null;
40372
40517
  } catch {
40373
40518
  return null;
40374
40519
  }
@@ -40377,26 +40522,26 @@ function getGitRepoRootSync(startDir) {
40377
40522
  // src/agents/acp/workspace-files.ts
40378
40523
  import { execFileSync as execFileSync4 } from "node:child_process";
40379
40524
  import { readFileSync as readFileSync4 } from "node:fs";
40380
- import * as path29 from "node:path";
40525
+ import * as path31 from "node:path";
40381
40526
  var GIT_FILE_READ_TIMEOUT_MS = 2e3;
40382
40527
  function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
40383
40528
  const trimmed2 = rawPath.trim();
40384
40529
  if (!trimmed2) return null;
40385
- const normalizedSessionParent = path29.resolve(sessionParentPath);
40530
+ const normalizedSessionParent = path31.resolve(sessionParentPath);
40386
40531
  let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
40387
40532
  if (!resolvedPath) {
40388
- const candidate = path29.isAbsolute(trimmed2) ? path29.normalize(trimmed2) : path29.normalize(path29.resolve(normalizedSessionParent, trimmed2));
40533
+ const candidate = path31.isAbsolute(trimmed2) ? path31.normalize(trimmed2) : path31.normalize(path31.resolve(normalizedSessionParent, trimmed2));
40389
40534
  const gitRoot2 = getGitRepoRootSync(sessionParentPath);
40390
40535
  if (!gitRoot2) return null;
40391
- const rel = path29.relative(gitRoot2, candidate);
40392
- if (rel.startsWith("..") || path29.isAbsolute(rel)) return null;
40536
+ const rel = path31.relative(gitRoot2, candidate);
40537
+ if (rel.startsWith("..") || path31.isAbsolute(rel)) return null;
40393
40538
  resolvedPath = candidate;
40394
40539
  }
40395
40540
  const gitRoot = getGitRepoRootSync(sessionParentPath);
40396
40541
  if (gitRoot) {
40397
- const relFromRoot = path29.relative(gitRoot, resolvedPath);
40398
- if (!relFromRoot.startsWith("..") && !path29.isAbsolute(relFromRoot)) {
40399
- return { resolvedPath, display: relFromRoot.split(path29.sep).join("/") };
40542
+ const relFromRoot = path31.relative(gitRoot, resolvedPath);
40543
+ if (!relFromRoot.startsWith("..") && !path31.isAbsolute(relFromRoot)) {
40544
+ return { resolvedPath, display: relFromRoot.split(path31.sep).join("/") };
40400
40545
  }
40401
40546
  }
40402
40547
  return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
@@ -40405,9 +40550,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
40405
40550
  if (!displayPath || displayPath.includes("..")) return "";
40406
40551
  const gitRoot = getGitRepoRootSync(sessionParentPath);
40407
40552
  if (gitRoot) {
40408
- const resolvedPath2 = path29.resolve(gitRoot, displayPath);
40409
- const rel = path29.relative(gitRoot, resolvedPath2);
40410
- if (!rel.startsWith("..") && !path29.isAbsolute(rel)) {
40553
+ const resolvedPath2 = path31.resolve(gitRoot, displayPath);
40554
+ const rel = path31.relative(gitRoot, resolvedPath2);
40555
+ if (!rel.startsWith("..") && !path31.isAbsolute(rel)) {
40411
40556
  try {
40412
40557
  return readFileSync4(resolvedPath2, "utf8");
40413
40558
  } catch {
@@ -40426,9 +40571,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
40426
40571
  if (!displayPath || displayPath.includes("..")) return null;
40427
40572
  const gitRoot = getGitRepoRootSync(sessionParentPath);
40428
40573
  if (gitRoot) {
40429
- const resolvedPath = path29.resolve(gitRoot, displayPath);
40430
- const rel = path29.relative(gitRoot, resolvedPath);
40431
- if (!rel.startsWith("..") && !path29.isAbsolute(rel)) return resolvedPath;
40574
+ const resolvedPath = path31.resolve(gitRoot, displayPath);
40575
+ const rel = path31.relative(gitRoot, resolvedPath);
40576
+ if (!rel.startsWith("..") && !path31.isAbsolute(rel)) return resolvedPath;
40432
40577
  }
40433
40578
  return resolveSafePathUnderCwd(sessionParentPath, displayPath);
40434
40579
  }
@@ -41315,11 +41460,11 @@ init_cli_process_interrupt();
41315
41460
  var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
41316
41461
 
41317
41462
  // src/mcp/resolve-bridge-mcp-server-path.ts
41318
- import { dirname as dirname7, join as join8 } from "node:path";
41463
+ import { dirname as dirname7, join as join10 } from "node:path";
41319
41464
  import { fileURLToPath as fileURLToPath7 } from "node:url";
41320
41465
  function resolveBridgeMcpServerScriptPath() {
41321
41466
  const cliDir = dirname7(fileURLToPath7(import.meta.url));
41322
- return join8(cliDir, "bridge-mcp-server.js");
41467
+ return join10(cliDir, "bridge-mcp-server.js");
41323
41468
  }
41324
41469
 
41325
41470
  // src/mcp/build-acp-mcp-servers.ts
@@ -41378,7 +41523,7 @@ async function ensureAcpClient(options) {
41378
41523
  if (state.acpStartPromise && !state.acpHandle) {
41379
41524
  await state.acpStartPromise;
41380
41525
  }
41381
- if (state.acpHandle && state.lastAcpCwd != null && path30.resolve(state.lastAcpCwd) !== path30.resolve(targetSessionParentPath)) {
41526
+ if (state.acpHandle && state.lastAcpCwd != null && path32.resolve(state.lastAcpCwd) !== path32.resolve(targetSessionParentPath)) {
41382
41527
  try {
41383
41528
  state.acpHandle.disconnect();
41384
41529
  } catch {
@@ -41410,7 +41555,7 @@ async function ensureAcpClient(options) {
41410
41555
  if (!state.acpStartPromise) {
41411
41556
  let statOk = false;
41412
41557
  try {
41413
- const st = await fs24.promises.stat(targetSessionParentPath);
41558
+ const st = await fs25.promises.stat(targetSessionParentPath);
41414
41559
  statOk = st.isDirectory();
41415
41560
  if (!statOk) {
41416
41561
  state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
@@ -41489,6 +41634,7 @@ async function ensureAcpClient(options) {
41489
41634
  },
41490
41635
  ...hooks,
41491
41636
  cwd: targetSessionParentPath,
41637
+ cloudSessionId: cloudSessionId ?? null,
41492
41638
  mcpServers
41493
41639
  }).then(async (h) => {
41494
41640
  if (spawnEpoch !== state.clientEpoch || isCliImmediateShutdownRequested()) {
@@ -41708,8 +41854,8 @@ async function execGitFile(args, options) {
41708
41854
  }
41709
41855
 
41710
41856
  // src/git/changes/parse/normalize-git-diff-path.ts
41711
- function normalizeGitDiffPath(path88) {
41712
- return path88.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
41857
+ function normalizeGitDiffPath(path90) {
41858
+ return path90.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
41713
41859
  }
41714
41860
 
41715
41861
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -41748,7 +41894,7 @@ function parseNameStatusLines(lines) {
41748
41894
  }
41749
41895
 
41750
41896
  // src/git/snapshot/diff/messages.ts
41751
- import * as path31 from "node:path";
41897
+ import * as path33 from "node:path";
41752
41898
 
41753
41899
  // src/git/snapshot/diff/files.ts
41754
41900
  import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
@@ -41779,7 +41925,7 @@ async function buildTrackedChangeMessage(options) {
41779
41925
  const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
41780
41926
  const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
41781
41927
  if (!patchContent.trim()) return null;
41782
- const workspaceFilePath = path31.join(repoPath, rel);
41928
+ const workspaceFilePath = path33.join(repoPath, rel);
41783
41929
  const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
41784
41930
  const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
41785
41931
  return {
@@ -41811,9 +41957,9 @@ function buildUntrackedChangeMessage(options) {
41811
41957
  }
41812
41958
 
41813
41959
  // src/git/snapshot/diff/paths.ts
41814
- import * as path32 from "node:path";
41960
+ import * as path34 from "node:path";
41815
41961
  function repoDisplayPath(repoPath, multiRepo) {
41816
- const slug = path32.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
41962
+ const slug = path34.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
41817
41963
  return (rel) => multiRepo ? `${slug}/${rel}` : rel;
41818
41964
  }
41819
41965
  function safeRelPath(rel) {
@@ -41825,12 +41971,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
41825
41971
  }
41826
41972
 
41827
41973
  // src/git/snapshot/diff/move-pairs.ts
41828
- import * as path33 from "node:path";
41974
+ import * as path35 from "node:path";
41829
41975
  async function readUntrackedTexts(repoPath, untracked) {
41830
41976
  const out = /* @__PURE__ */ new Map();
41831
41977
  await forEachWithGitYield(untracked, async (rel) => {
41832
41978
  if (!safeRelPath(rel)) return;
41833
- const newText = await readWorkspaceFileAsUtf8(path33.join(repoPath, rel));
41979
+ const newText = await readWorkspaceFileAsUtf8(path35.join(repoPath, rel));
41834
41980
  if (newText !== void 0) out.set(rel, newText);
41835
41981
  });
41836
41982
  return out;
@@ -41947,12 +42093,12 @@ async function collectRepoTurnChanges(options) {
41947
42093
  import { readFile as readFile3 } from "node:fs/promises";
41948
42094
 
41949
42095
  // src/git/snapshot/types.ts
41950
- import * as path34 from "node:path";
42096
+ import * as path36 from "node:path";
41951
42097
  function snapshotsDirForCwd(agentCwd) {
41952
- return path34.join(agentCwd, ".buildautomaton", "snapshots");
42098
+ return path36.join(agentCwd, ".buildautomaton", "snapshots");
41953
42099
  }
41954
42100
  function snapshotFilePath(agentCwd, runId) {
41955
- return path34.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
42101
+ return path36.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
41956
42102
  }
41957
42103
 
41958
42104
  // src/git/snapshot/diff/load-pre-turn-snapshot.ts
@@ -42020,6 +42166,18 @@ function reportPostTurnEnrichment(options) {
42020
42166
  });
42021
42167
  }
42022
42168
 
42169
+ // src/agents/acp/clients/cursor/cleanup-session-plans.ts
42170
+ import * as fs26 from "node:fs";
42171
+ function cleanupSessionPlans(sessionId) {
42172
+ const id = typeof sessionId === "string" ? sessionId.trim() : "";
42173
+ if (!id) return;
42174
+ const dir = getSessionPlansDir(id);
42175
+ try {
42176
+ fs26.rmSync(dir, { recursive: true, force: true });
42177
+ } catch {
42178
+ }
42179
+ }
42180
+
42023
42181
  // src/agents/acp/prompts/finalize-and-send-prompt-result.ts
42024
42182
  async function finalizeAndSendPromptResult(params) {
42025
42183
  const {
@@ -42037,6 +42195,7 @@ async function finalizeAndSendPromptResult(params) {
42037
42195
  sendSessionUpdate,
42038
42196
  log: log2
42039
42197
  } = params;
42198
+ cleanupSessionPlans(sessionId);
42040
42199
  const planningTodosSubmit = isPlanningSession ? await maybeSubmitPlanningTodosAfterAgentSuccess({
42041
42200
  sessionId,
42042
42201
  runId,
@@ -43160,7 +43319,7 @@ async function createBridgeAccessState(options = {}) {
43160
43319
  }
43161
43320
 
43162
43321
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
43163
- import * as path36 from "node:path";
43322
+ import * as path38 from "node:path";
43164
43323
 
43165
43324
  // src/agents/detect-local-agent-types.ts
43166
43325
  init_yield_to_event_loop();
@@ -43265,7 +43424,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
43265
43424
  init_cli_database();
43266
43425
 
43267
43426
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
43268
- import * as path35 from "node:path";
43427
+ import * as path37 from "node:path";
43269
43428
  init_cli_database();
43270
43429
  init_cli_process_interrupt();
43271
43430
  async function probeOneAgentTypeForCapabilities(params) {
@@ -43305,7 +43464,7 @@ async function probeOneAgentTypeForCapabilities(params) {
43305
43464
  if (!canContinue()) return false;
43306
43465
  handle = await resolved.createClient({
43307
43466
  command: resolved.command,
43308
- cwd: path35.resolve(cwd),
43467
+ cwd: path37.resolve(cwd),
43309
43468
  backendAgentType: agentType,
43310
43469
  sessionMode: "agent",
43311
43470
  persistedAcpSessionId: null,
@@ -43398,7 +43557,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
43398
43557
  const { workspaceId, log: log2, getWs } = params;
43399
43558
  const isCurrent = beginAgentCapabilityWarmupRun();
43400
43559
  if (!isCurrent()) return;
43401
- const cwd = path36.resolve(getBridgeRoot());
43560
+ const cwd = path38.resolve(getBridgeRoot());
43402
43561
  async function sendBatchFromCache() {
43403
43562
  if (!isCurrent()) return;
43404
43563
  const socket = getWs();
@@ -43525,7 +43684,7 @@ async function createBridgeAccessAndAcp(options) {
43525
43684
  }
43526
43685
 
43527
43686
  // src/connection/create-bridge-preview-stack.ts
43528
- import * as path39 from "node:path";
43687
+ import * as path41 from "node:path";
43529
43688
 
43530
43689
  // src/preview-environments/manager/firehose-messages.ts
43531
43690
  function buildFirehoseSnapshotMessage(params) {
@@ -43843,7 +44002,7 @@ function attachChildErrorHandler(d) {
43843
44002
  }
43844
44003
 
43845
44004
  // src/preview-environments/process/wire/handle-exit.ts
43846
- import fs25 from "node:fs";
44005
+ import fs27 from "node:fs";
43847
44006
  function logStopLine(d, code, signal) {
43848
44007
  const { title } = d;
43849
44008
  if (signal) {
@@ -43882,7 +44041,7 @@ function attachChildExitHandler(d) {
43882
44041
  const cleanupDir = d.mergedCleanupDir;
43883
44042
  const mergedPath = d.mergedLogPath;
43884
44043
  if (mergedPath && !stale) {
43885
- fs25.readFile(mergedPath, (err, buf) => {
44044
+ fs27.readFile(mergedPath, (err, buf) => {
43886
44045
  if (!err && buf.length > d.mergedReadPos.value) {
43887
44046
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
43888
44047
  if (chunk.length > 0) {
@@ -43928,7 +44087,7 @@ function wireChildOutputPipes(d) {
43928
44087
  }
43929
44088
 
43930
44089
  // src/preview-environments/process/wire/poll-merged-log.ts
43931
- import fs26 from "node:fs";
44090
+ import fs28 from "node:fs";
43932
44091
  function startMergedLogPoll(d) {
43933
44092
  if (!d.mergedLogPath || !d.mergedCleanupDir) return;
43934
44093
  const { environmentId } = d;
@@ -43938,7 +44097,7 @@ function startMergedLogPoll(d) {
43938
44097
  d.setPollInterval(void 0);
43939
44098
  return;
43940
44099
  }
43941
- fs26.readFile(d.mergedLogPath, (err, buf) => {
44100
+ fs28.readFile(d.mergedLogPath, (err, buf) => {
43942
44101
  if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
43943
44102
  if (buf.length <= d.mergedReadPos.value) return;
43944
44103
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
@@ -44153,7 +44312,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
44153
44312
  }
44154
44313
 
44155
44314
  // src/preview-environments/manager/shell-spawn/utils.ts
44156
- import fs27 from "node:fs";
44315
+ import fs29 from "node:fs";
44157
44316
  function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
44158
44317
  return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
44159
44318
  }
@@ -44162,7 +44321,7 @@ function isSpawnEbadf(e) {
44162
44321
  }
44163
44322
  function rmDirQuiet(dir) {
44164
44323
  try {
44165
- fs27.rmSync(dir, { recursive: true, force: true });
44324
+ fs29.rmSync(dir, { recursive: true, force: true });
44166
44325
  } catch {
44167
44326
  }
44168
44327
  }
@@ -44170,7 +44329,7 @@ var cachedDevNullReadFd;
44170
44329
  function devNullReadFd() {
44171
44330
  if (cachedDevNullReadFd === void 0) {
44172
44331
  const devPath = process.platform === "win32" ? "nul" : "/dev/null";
44173
- cachedDevNullReadFd = fs27.openSync(devPath, "r");
44332
+ cachedDevNullReadFd = fs29.openSync(devPath, "r");
44174
44333
  }
44175
44334
  return cachedDevNullReadFd;
44176
44335
  }
@@ -44250,15 +44409,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
44250
44409
 
44251
44410
  // src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
44252
44411
  import { spawn as spawn6 } from "node:child_process";
44253
- import fs28 from "node:fs";
44412
+ import fs30 from "node:fs";
44254
44413
  import { tmpdir } from "node:os";
44255
- import path37 from "node:path";
44414
+ import path39 from "node:path";
44256
44415
  function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
44257
- const tmpRoot = fs28.mkdtempSync(path37.join(tmpdir(), "ba-devsrv-log-"));
44258
- const logPath = path37.join(tmpRoot, "combined.log");
44416
+ const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir(), "ba-devsrv-log-"));
44417
+ const logPath = path39.join(tmpRoot, "combined.log");
44259
44418
  let logFd;
44260
44419
  try {
44261
- logFd = fs28.openSync(logPath, "a");
44420
+ logFd = fs30.openSync(logPath, "a");
44262
44421
  } catch {
44263
44422
  rmDirQuiet(tmpRoot);
44264
44423
  return null;
@@ -44282,7 +44441,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
44282
44441
  mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
44283
44442
  );
44284
44443
  }
44285
- fs28.closeSync(logFd);
44444
+ fs30.closeSync(logFd);
44286
44445
  return {
44287
44446
  proc,
44288
44447
  pipedStdoutStderr: true,
@@ -44291,7 +44450,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
44291
44450
  };
44292
44451
  } catch (e) {
44293
44452
  try {
44294
- fs28.closeSync(logFd);
44453
+ fs30.closeSync(logFd);
44295
44454
  } catch {
44296
44455
  }
44297
44456
  rmDirQuiet(tmpRoot);
@@ -44302,22 +44461,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
44302
44461
 
44303
44462
  // src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
44304
44463
  import { spawn as spawn7 } from "node:child_process";
44305
- import fs29 from "node:fs";
44464
+ import fs31 from "node:fs";
44306
44465
  import { tmpdir as tmpdir2 } from "node:os";
44307
- import path38 from "node:path";
44466
+ import path40 from "node:path";
44308
44467
  function shSingleQuote(s) {
44309
44468
  return `'${s.replace(/'/g, `'\\''`)}'`;
44310
44469
  }
44311
44470
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
44312
- const tmpRoot = fs29.mkdtempSync(path38.join(tmpdir2(), "ba-devsrv-sh-"));
44313
- const logPath = path38.join(tmpRoot, "combined.log");
44314
- const innerPath = path38.join(tmpRoot, "_cmd.sh");
44315
- const runnerPath = path38.join(tmpRoot, "_run.sh");
44471
+ const tmpRoot = fs31.mkdtempSync(path40.join(tmpdir2(), "ba-devsrv-sh-"));
44472
+ const logPath = path40.join(tmpRoot, "combined.log");
44473
+ const innerPath = path40.join(tmpRoot, "_cmd.sh");
44474
+ const runnerPath = path40.join(tmpRoot, "_run.sh");
44316
44475
  try {
44317
- fs29.writeFileSync(innerPath, `#!/bin/sh
44476
+ fs31.writeFileSync(innerPath, `#!/bin/sh
44318
44477
  ${command}
44319
44478
  `);
44320
- fs29.writeFileSync(
44479
+ fs31.writeFileSync(
44321
44480
  runnerPath,
44322
44481
  `#!/bin/sh
44323
44482
  cd ${shSingleQuote(cwd)}
@@ -44345,13 +44504,13 @@ cd ${shSingleQuote(cwd)}
44345
44504
  }
44346
44505
  }
44347
44506
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
44348
- const tmpRoot = fs29.mkdtempSync(path38.join(tmpdir2(), "ba-devsrv-sh-"));
44349
- const logPath = path38.join(tmpRoot, "combined.log");
44350
- const runnerPath = path38.join(tmpRoot, "_run.bat");
44507
+ const tmpRoot = fs31.mkdtempSync(path40.join(tmpdir2(), "ba-devsrv-sh-"));
44508
+ const logPath = path40.join(tmpRoot, "combined.log");
44509
+ const runnerPath = path40.join(tmpRoot, "_run.bat");
44351
44510
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
44352
44511
  const com = process.env.ComSpec || "cmd.exe";
44353
44512
  try {
44354
- fs29.writeFileSync(
44513
+ fs31.writeFileSync(
44355
44514
  runnerPath,
44356
44515
  `@ECHO OFF\r
44357
44516
  CD /D ${q(cwd)}\r
@@ -44669,8 +44828,8 @@ function createBridgePreviewStack(options) {
44669
44828
  scheduleInitialIndexBuilds(getBridgeRoot());
44670
44829
  };
44671
44830
  const identifyReportedPaths = {
44672
- bridgeRootPath: path39.resolve(getBridgeRoot()),
44673
- worktreesRootPath: path39.resolve(options.worktreesRootPath),
44831
+ bridgeRootPath: path41.resolve(getBridgeRoot()),
44832
+ worktreesRootPath: path41.resolve(options.worktreesRootPath),
44674
44833
  localShortcutPort: 0,
44675
44834
  localShortcutToken: ""
44676
44835
  };
@@ -45633,17 +45792,17 @@ async function yieldSkillDiscoveryWork(entryCount) {
45633
45792
  }
45634
45793
 
45635
45794
  // src/skills/discovery/discover-local-skills.ts
45636
- import fs30 from "node:fs";
45637
- import path40 from "node:path";
45795
+ import fs32 from "node:fs";
45796
+ import path42 from "node:path";
45638
45797
  function collectSkillFromDir(rel, base, name, seenKeys, out) {
45639
- const dir = path40.join(base, name);
45798
+ const dir = path42.join(base, name);
45640
45799
  try {
45641
- if (!fs30.statSync(dir).isDirectory()) return;
45800
+ if (!fs32.statSync(dir).isDirectory()) return;
45642
45801
  } catch {
45643
45802
  return;
45644
45803
  }
45645
- const skillMd = path40.join(dir, "SKILL.md");
45646
- if (!fs30.existsSync(skillMd)) return;
45804
+ const skillMd = path42.join(dir, "SKILL.md");
45805
+ if (!fs32.existsSync(skillMd)) return;
45647
45806
  const key = `${rel}/${name}`;
45648
45807
  if (seenKeys.has(key)) return;
45649
45808
  seenKeys.add(key);
@@ -45655,11 +45814,11 @@ async function discoverLocalSkillsAsync(cwd) {
45655
45814
  let work = 0;
45656
45815
  for (const rel of SKILL_DISCOVERY_ROOTS) {
45657
45816
  await yieldSkillDiscoveryWork(++work);
45658
- const base = path40.join(cwd, rel);
45659
- if (!fs30.existsSync(base) || !fs30.statSync(base).isDirectory()) continue;
45817
+ const base = path42.join(cwd, rel);
45818
+ if (!fs32.existsSync(base) || !fs32.statSync(base).isDirectory()) continue;
45660
45819
  let entries = [];
45661
45820
  try {
45662
- entries = fs30.readdirSync(base);
45821
+ entries = fs32.readdirSync(base);
45663
45822
  } catch {
45664
45823
  continue;
45665
45824
  }
@@ -45672,16 +45831,16 @@ async function discoverLocalSkillsAsync(cwd) {
45672
45831
  }
45673
45832
 
45674
45833
  // src/skills/discovery/discover-skill-layout-roots.ts
45675
- import fs31 from "node:fs";
45676
- import path41 from "node:path";
45834
+ import fs33 from "node:fs";
45835
+ import path43 from "node:path";
45677
45836
  function collectLayoutSkill(rel, base, name, skills2) {
45678
- const dir = path41.join(base, name);
45837
+ const dir = path43.join(base, name);
45679
45838
  try {
45680
- if (!fs31.statSync(dir).isDirectory()) return;
45839
+ if (!fs33.statSync(dir).isDirectory()) return;
45681
45840
  } catch {
45682
45841
  return;
45683
45842
  }
45684
- if (!fs31.existsSync(path41.join(dir, "SKILL.md"))) return;
45843
+ if (!fs33.existsSync(path43.join(dir, "SKILL.md"))) return;
45685
45844
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
45686
45845
  skills2.push({ name, relPath });
45687
45846
  }
@@ -45690,11 +45849,11 @@ async function discoverSkillLayoutRootsAsync(cwd) {
45690
45849
  let work = 0;
45691
45850
  for (const rel of SKILL_DISCOVERY_ROOTS) {
45692
45851
  await yieldSkillDiscoveryWork(++work);
45693
- const base = path41.join(cwd, rel);
45694
- if (!fs31.existsSync(base) || !fs31.statSync(base).isDirectory()) continue;
45852
+ const base = path43.join(cwd, rel);
45853
+ if (!fs33.existsSync(base) || !fs33.statSync(base).isDirectory()) continue;
45695
45854
  let entries = [];
45696
45855
  try {
45697
- entries = fs31.readdirSync(base);
45856
+ entries = fs33.readdirSync(base);
45698
45857
  } catch {
45699
45858
  continue;
45700
45859
  }
@@ -45841,12 +46000,12 @@ function createBridgeRuntimeMessageSetup(options) {
45841
46000
  }
45842
46001
 
45843
46002
  // src/worktrees/worktree-layout-file.ts
45844
- import * as fs32 from "node:fs";
45845
- import * as path42 from "node:path";
45846
- import os8 from "node:os";
46003
+ import * as fs34 from "node:fs";
46004
+ import * as path44 from "node:path";
46005
+ import os9 from "node:os";
45847
46006
  var LAYOUT_FILENAME = "worktree-launcher-layout.json";
45848
46007
  function defaultWorktreeLayoutPath() {
45849
- return path42.join(os8.homedir(), ".buildautomaton", LAYOUT_FILENAME);
46008
+ return path44.join(os9.homedir(), ".buildautomaton", LAYOUT_FILENAME);
45850
46009
  }
45851
46010
  function normalizeLoadedLayout(raw) {
45852
46011
  if (raw && typeof raw === "object" && "launcherCwds" in raw) {
@@ -45858,8 +46017,8 @@ function normalizeLoadedLayout(raw) {
45858
46017
  function loadWorktreeLayout() {
45859
46018
  try {
45860
46019
  const p = defaultWorktreeLayoutPath();
45861
- if (!fs32.existsSync(p)) return { launcherCwds: [] };
45862
- const raw = JSON.parse(fs32.readFileSync(p, "utf8"));
46020
+ if (!fs34.existsSync(p)) return { launcherCwds: [] };
46021
+ const raw = JSON.parse(fs34.readFileSync(p, "utf8"));
45863
46022
  return normalizeLoadedLayout(raw);
45864
46023
  } catch {
45865
46024
  return { launcherCwds: [] };
@@ -45867,24 +46026,24 @@ function loadWorktreeLayout() {
45867
46026
  }
45868
46027
  function saveWorktreeLayout(layout) {
45869
46028
  try {
45870
- const dir = path42.dirname(defaultWorktreeLayoutPath());
45871
- fs32.mkdirSync(dir, { recursive: true });
45872
- fs32.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
46029
+ const dir = path44.dirname(defaultWorktreeLayoutPath());
46030
+ fs34.mkdirSync(dir, { recursive: true });
46031
+ fs34.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
45873
46032
  } catch {
45874
46033
  }
45875
46034
  }
45876
46035
  function baseNameSafe(pathString) {
45877
- return path42.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
46036
+ return path44.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
45878
46037
  }
45879
46038
  function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
45880
- const norm = path42.resolve(bridgeRootPath2);
45881
- const existing = layout.launcherCwds.find((e) => path42.resolve(e.absolutePath) === norm);
46039
+ const norm = path44.resolve(bridgeRootPath2);
46040
+ const existing = layout.launcherCwds.find((e) => path44.resolve(e.absolutePath) === norm);
45882
46041
  return existing?.dirName;
45883
46042
  }
45884
46043
  function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
45885
46044
  const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
45886
46045
  if (existing) return existing;
45887
- const norm = path42.resolve(bridgeRootPath2);
46046
+ const norm = path44.resolve(bridgeRootPath2);
45888
46047
  const base = baseNameSafe(norm);
45889
46048
  const used = new Set(layout.launcherCwds.map((e) => e.dirName));
45890
46049
  let name = base;
@@ -45977,8 +46136,8 @@ function pathspec(...paths) {
45977
46136
  cache.set(key, paths);
45978
46137
  return key;
45979
46138
  }
45980
- function isPathSpec(path88) {
45981
- return path88 instanceof String && cache.has(path88);
46139
+ function isPathSpec(path90) {
46140
+ return path90 instanceof String && cache.has(path90);
45982
46141
  }
45983
46142
  function toPaths(pathSpec) {
45984
46143
  return cache.get(pathSpec) || [];
@@ -46067,8 +46226,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
46067
46226
  function forEachLineWithContent(input, callback) {
46068
46227
  return toLinesWithContent(input, true).map((line) => callback(line));
46069
46228
  }
46070
- function folderExists(path88) {
46071
- return (0, import_file_exists.exists)(path88, import_file_exists.FOLDER);
46229
+ function folderExists(path90) {
46230
+ return (0, import_file_exists.exists)(path90, import_file_exists.FOLDER);
46072
46231
  }
46073
46232
  function append(target, item) {
46074
46233
  if (Array.isArray(target)) {
@@ -46472,8 +46631,8 @@ function checkIsRepoRootTask() {
46472
46631
  commands,
46473
46632
  format: "utf-8",
46474
46633
  onError,
46475
- parser(path88) {
46476
- return /^\.(git)?$/.test(path88.trim());
46634
+ parser(path90) {
46635
+ return /^\.(git)?$/.test(path90.trim());
46477
46636
  }
46478
46637
  };
46479
46638
  }
@@ -46907,11 +47066,11 @@ function parseGrep(grep) {
46907
47066
  const paths = /* @__PURE__ */ new Set();
46908
47067
  const results = {};
46909
47068
  forEachLineWithContent(grep, (input) => {
46910
- const [path88, line, preview] = input.split(NULL);
46911
- paths.add(path88);
46912
- (results[path88] = results[path88] || []).push({
47069
+ const [path90, line, preview] = input.split(NULL);
47070
+ paths.add(path90);
47071
+ (results[path90] = results[path90] || []).push({
46913
47072
  line: asNumber(line),
46914
- path: path88,
47073
+ path: path90,
46915
47074
  preview
46916
47075
  });
46917
47076
  });
@@ -47676,14 +47835,14 @@ var init_hash_object = __esm2({
47676
47835
  init_task();
47677
47836
  }
47678
47837
  });
47679
- function parseInit(bare, path88, text) {
47838
+ function parseInit(bare, path90, text) {
47680
47839
  const response = String(text).trim();
47681
47840
  let result;
47682
47841
  if (result = initResponseRegex.exec(response)) {
47683
- return new InitSummary(bare, path88, false, result[1]);
47842
+ return new InitSummary(bare, path90, false, result[1]);
47684
47843
  }
47685
47844
  if (result = reInitResponseRegex.exec(response)) {
47686
- return new InitSummary(bare, path88, true, result[1]);
47845
+ return new InitSummary(bare, path90, true, result[1]);
47687
47846
  }
47688
47847
  let gitDir = "";
47689
47848
  const tokens = response.split(" ");
@@ -47694,7 +47853,7 @@ function parseInit(bare, path88, text) {
47694
47853
  break;
47695
47854
  }
47696
47855
  }
47697
- return new InitSummary(bare, path88, /^re/i.test(response), gitDir);
47856
+ return new InitSummary(bare, path90, /^re/i.test(response), gitDir);
47698
47857
  }
47699
47858
  var InitSummary;
47700
47859
  var initResponseRegex;
@@ -47703,9 +47862,9 @@ var init_InitSummary = __esm2({
47703
47862
  "src/lib/responses/InitSummary.ts"() {
47704
47863
  "use strict";
47705
47864
  InitSummary = class {
47706
- constructor(bare, path88, existing, gitDir) {
47865
+ constructor(bare, path90, existing, gitDir) {
47707
47866
  this.bare = bare;
47708
- this.path = path88;
47867
+ this.path = path90;
47709
47868
  this.existing = existing;
47710
47869
  this.gitDir = gitDir;
47711
47870
  }
@@ -47717,7 +47876,7 @@ var init_InitSummary = __esm2({
47717
47876
  function hasBareCommand(command) {
47718
47877
  return command.includes(bareCommand);
47719
47878
  }
47720
- function initTask(bare = false, path88, customArgs) {
47879
+ function initTask(bare = false, path90, customArgs) {
47721
47880
  const commands = ["init", ...customArgs];
47722
47881
  if (bare && !hasBareCommand(commands)) {
47723
47882
  commands.splice(1, 0, bareCommand);
@@ -47726,7 +47885,7 @@ function initTask(bare = false, path88, customArgs) {
47726
47885
  commands,
47727
47886
  format: "utf-8",
47728
47887
  parser(text) {
47729
- return parseInit(commands.includes("--bare"), path88, text);
47888
+ return parseInit(commands.includes("--bare"), path90, text);
47730
47889
  }
47731
47890
  };
47732
47891
  }
@@ -48542,12 +48701,12 @@ var init_FileStatusSummary = __esm2({
48542
48701
  "use strict";
48543
48702
  fromPathRegex = /^(.+)\0(.+)$/;
48544
48703
  FileStatusSummary = class {
48545
- constructor(path88, index, working_dir) {
48546
- this.path = path88;
48704
+ constructor(path90, index, working_dir) {
48705
+ this.path = path90;
48547
48706
  this.index = index;
48548
48707
  this.working_dir = working_dir;
48549
48708
  if (index === "R" || working_dir === "R") {
48550
- const detail = fromPathRegex.exec(path88) || [null, path88, path88];
48709
+ const detail = fromPathRegex.exec(path90) || [null, path90, path90];
48551
48710
  this.from = detail[2] || "";
48552
48711
  this.path = detail[1] || "";
48553
48712
  }
@@ -48578,14 +48737,14 @@ function splitLine(result, lineStr) {
48578
48737
  default:
48579
48738
  return;
48580
48739
  }
48581
- function data(index, workingDir, path88) {
48740
+ function data(index, workingDir, path90) {
48582
48741
  const raw = `${index}${workingDir}`;
48583
48742
  const handler = parsers6.get(raw);
48584
48743
  if (handler) {
48585
- handler(result, path88);
48744
+ handler(result, path90);
48586
48745
  }
48587
48746
  if (raw !== "##" && raw !== "!!") {
48588
- result.files.push(new FileStatusSummary(path88, index, workingDir));
48747
+ result.files.push(new FileStatusSummary(path90, index, workingDir));
48589
48748
  }
48590
48749
  }
48591
48750
  }
@@ -48894,9 +49053,9 @@ var init_simple_git_api = __esm2({
48894
49053
  next
48895
49054
  );
48896
49055
  }
48897
- hashObject(path88, write) {
49056
+ hashObject(path90, write) {
48898
49057
  return this._runTask(
48899
- hashObjectTask(path88, write === true),
49058
+ hashObjectTask(path90, write === true),
48900
49059
  trailingFunctionArgument(arguments)
48901
49060
  );
48902
49061
  }
@@ -49249,8 +49408,8 @@ var init_branch = __esm2({
49249
49408
  }
49250
49409
  });
49251
49410
  function toPath(input) {
49252
- const path88 = input.trim().replace(/^["']|["']$/g, "");
49253
- return path88 && normalize3(path88);
49411
+ const path90 = input.trim().replace(/^["']|["']$/g, "");
49412
+ return path90 && normalize3(path90);
49254
49413
  }
49255
49414
  var parseCheckIgnore;
49256
49415
  var init_CheckIgnore = __esm2({
@@ -49564,8 +49723,8 @@ __export2(sub_module_exports, {
49564
49723
  subModuleTask: () => subModuleTask,
49565
49724
  updateSubModuleTask: () => updateSubModuleTask
49566
49725
  });
49567
- function addSubModuleTask(repo, path88) {
49568
- return subModuleTask(["add", repo, path88]);
49726
+ function addSubModuleTask(repo, path90) {
49727
+ return subModuleTask(["add", repo, path90]);
49569
49728
  }
49570
49729
  function initSubModuleTask(customArgs) {
49571
49730
  return subModuleTask(["init", ...customArgs]);
@@ -49898,8 +50057,8 @@ var require_git = __commonJS2({
49898
50057
  }
49899
50058
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
49900
50059
  };
49901
- Git2.prototype.submoduleAdd = function(repo, path88, then) {
49902
- return this._runTask(addSubModuleTask2(repo, path88), trailingFunctionArgument2(arguments));
50060
+ Git2.prototype.submoduleAdd = function(repo, path90, then) {
50061
+ return this._runTask(addSubModuleTask2(repo, path90), trailingFunctionArgument2(arguments));
49903
50062
  };
49904
50063
  Git2.prototype.submoduleUpdate = function(args, then) {
49905
50064
  return this._runTask(
@@ -50638,8 +50797,8 @@ function parseNumstatEntries(lines) {
50638
50797
  }
50639
50798
  function parseNumstat(lines) {
50640
50799
  const m = /* @__PURE__ */ new Map();
50641
- for (const [path88, entry] of parseNumstatEntries(lines)) {
50642
- m.set(path88, { additions: entry.additions, deletions: entry.deletions });
50800
+ for (const [path90, entry] of parseNumstatEntries(lines)) {
50801
+ m.set(path90, { additions: entry.additions, deletions: entry.deletions });
50643
50802
  }
50644
50803
  return m;
50645
50804
  }
@@ -50768,7 +50927,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
50768
50927
  }
50769
50928
 
50770
50929
  // src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
50771
- import * as path43 from "node:path";
50930
+ import * as path45 from "node:path";
50772
50931
  var BASE_SHA_CACHE_TTL_MS = 3e4;
50773
50932
  var baseShaCache = /* @__PURE__ */ new Map();
50774
50933
  async function resolveBaseShaForUnpushedCommitsUncached(g) {
@@ -50779,7 +50938,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
50779
50938
  }
50780
50939
  async function resolveBaseShaForUnpushedCommits(g, repoDir) {
50781
50940
  if (repoDir) {
50782
- const key = path43.resolve(repoDir);
50941
+ const key = path45.resolve(repoDir);
50783
50942
  const now = Date.now();
50784
50943
  const cached2 = baseShaCache.get(key);
50785
50944
  if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
@@ -50914,17 +51073,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
50914
51073
  }
50915
51074
 
50916
51075
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
50917
- import * as path53 from "node:path";
51076
+ import * as path55 from "node:path";
50918
51077
 
50919
51078
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
50920
- import * as path52 from "node:path";
51079
+ import * as path54 from "node:path";
50921
51080
 
50922
51081
  // src/git/is-git-repo.ts
50923
- import * as fs33 from "node:fs";
50924
- import * as path44 from "node:path";
51082
+ import * as fs35 from "node:fs";
51083
+ import * as path46 from "node:path";
50925
51084
  async function isGitRepoDirectory(dirPath) {
50926
51085
  try {
50927
- await fs33.promises.access(path44.join(dirPath, ".git"));
51086
+ await fs35.promises.access(path46.join(dirPath, ".git"));
50928
51087
  return true;
50929
51088
  } catch {
50930
51089
  return false;
@@ -50932,8 +51091,8 @@ async function isGitRepoDirectory(dirPath) {
50932
51091
  }
50933
51092
 
50934
51093
  // src/git/changes/listing/apply-untracked-file-stats.ts
50935
- import * as fs34 from "node:fs";
50936
- import * as path45 from "node:path";
51094
+ import * as fs36 from "node:fs";
51095
+ import * as path47 from "node:path";
50937
51096
 
50938
51097
  // src/git/changes/lines/count-lines.ts
50939
51098
  import { createReadStream } from "node:fs";
@@ -50965,7 +51124,7 @@ function createUntrackedStatsApplier(options) {
50965
51124
  if (!options.untrackedSet.has(pathInRepo)) return;
50966
51125
  if (options.nameByPath.has(pathInRepo)) return;
50967
51126
  if (row.change === "moved") return;
50968
- const repoFilePath = path45.join(options.repoGitCwd, pathInRepo);
51127
+ const repoFilePath = path47.join(options.repoGitCwd, pathInRepo);
50969
51128
  const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
50970
51129
  if (fromGit) {
50971
51130
  row.additions = fromGit.additions;
@@ -50973,7 +51132,7 @@ function createUntrackedStatsApplier(options) {
50973
51132
  return;
50974
51133
  }
50975
51134
  try {
50976
- const st = await fs34.promises.stat(repoFilePath);
51135
+ const st = await fs36.promises.stat(repoFilePath);
50977
51136
  row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
50978
51137
  } catch {
50979
51138
  row.additions = 0;
@@ -51050,7 +51209,7 @@ async function buildChangedFileRowsFromPaths(options) {
51050
51209
  }
51051
51210
 
51052
51211
  // src/git/changes/listing/enrich-working-tree-file-rows.ts
51053
- import * as path47 from "node:path";
51212
+ import * as path49 from "node:path";
51054
51213
 
51055
51214
  // src/git/changes/patch/patch-truncate.ts
51056
51215
  function truncatePatch(s) {
@@ -51138,10 +51297,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
51138
51297
  }
51139
51298
 
51140
51299
  // src/git/changes/patch/hydrate/read-worktree-file-lines.ts
51141
- import * as fs35 from "node:fs";
51300
+ import * as fs37 from "node:fs";
51142
51301
  async function readWorktreeFileLines(filePath) {
51143
51302
  try {
51144
- const raw = await fs35.promises.readFile(filePath, "utf8");
51303
+ const raw = await fs37.promises.readFile(filePath, "utf8");
51145
51304
  return raw.split(/\r?\n/);
51146
51305
  } catch {
51147
51306
  return null;
@@ -51279,8 +51438,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
51279
51438
  }
51280
51439
 
51281
51440
  // src/git/changes/total-lines/resolve-changed-file-total-lines.ts
51282
- import * as fs36 from "node:fs";
51283
- import * as path46 from "node:path";
51441
+ import * as fs38 from "node:fs";
51442
+ import * as path48 from "node:path";
51284
51443
  var MAX_BYTES = 512e3;
51285
51444
  async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
51286
51445
  const spec = `${ref}:${pathInRepo}`;
@@ -51300,13 +51459,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
51300
51459
  }
51301
51460
  async function resolveWorkingTreeFileTotalLines(options) {
51302
51461
  if (options.isBinary) return null;
51303
- const filePath = path46.join(options.repoGitCwd, options.pathInRepo);
51462
+ const filePath = path48.join(options.repoGitCwd, options.pathInRepo);
51304
51463
  if (options.change === "removed") {
51305
51464
  return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
51306
51465
  }
51307
51466
  if (options.change === "moved" || options.change === "modified") {
51308
51467
  try {
51309
- const st = await fs36.promises.stat(filePath);
51468
+ const st = await fs38.promises.stat(filePath);
51310
51469
  if (!st.isFile()) return null;
51311
51470
  return await countTextFileLines(filePath);
51312
51471
  } catch {
@@ -51349,7 +51508,7 @@ async function enrichWorkingTreeFileRows(options) {
51349
51508
  row.workspaceRelPath,
51350
51509
  options.repoPathRelativeToWorkspaceRoot
51351
51510
  );
51352
- const filePath = path47.join(options.repoGitCwd, filePathRelativeToRepoRoot);
51511
+ const filePath = path49.join(options.repoGitCwd, filePathRelativeToRepoRoot);
51353
51512
  const hydrateKind = row.change === "moved" ? "modified" : row.change;
51354
51513
  let patch = await unifiedDiffForFile(
51355
51514
  options.repoGitCwd,
@@ -51507,7 +51666,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
51507
51666
  }
51508
51667
 
51509
51668
  // src/git/changes/listing/list-changed-files-for-commit.ts
51510
- import * as path48 from "node:path";
51669
+ import * as path50 from "node:path";
51511
51670
 
51512
51671
  // src/git/changes/listing/enrich-commit-file-rows.ts
51513
51672
  async function enrichCommitFileRows(options) {
@@ -51552,7 +51711,7 @@ async function parentForCommitDiff(g, sha) {
51552
51711
  var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
51553
51712
  var commitFilesCache = /* @__PURE__ */ new Map();
51554
51713
  function commitFilesCacheKey(repoGitCwd, commitSha) {
51555
- return `${path48.resolve(repoGitCwd)}:${commitSha}`;
51714
+ return `${path50.resolve(repoGitCwd)}:${commitSha}`;
51556
51715
  }
51557
51716
  async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
51558
51717
  const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
@@ -51607,7 +51766,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
51607
51766
  }
51608
51767
 
51609
51768
  // src/git/commits/list-unpushed-commits.ts
51610
- import * as path49 from "node:path";
51769
+ import * as path51 from "node:path";
51611
51770
 
51612
51771
  // src/git/commits/lib/parse-log-lines.ts
51613
51772
  function parseLogShaDateSubjectLines(raw) {
@@ -51642,7 +51801,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
51642
51801
  }
51643
51802
  }
51644
51803
  async function listUnpushedCommits(repoDir) {
51645
- const key = path49.resolve(repoDir);
51804
+ const key = path51.resolve(repoDir);
51646
51805
  const now = Date.now();
51647
51806
  const cached2 = unpushedCache.get(key);
51648
51807
  if (cached2 && cached2.expiresAt > now) return cached2.commits;
@@ -51703,7 +51862,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
51703
51862
  }
51704
51863
 
51705
51864
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
51706
- import * as path50 from "node:path";
51865
+ import * as path52 from "node:path";
51707
51866
 
51708
51867
  // src/git/remote-origin-url.ts
51709
51868
  async function getRemoteOriginUrl(gitDir) {
@@ -51718,7 +51877,7 @@ async function getRemoteOriginUrl(gitDir) {
51718
51877
 
51719
51878
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
51720
51879
  async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
51721
- const resolvedCheckoutPath = path50.resolve(checkoutPath);
51880
+ const resolvedCheckoutPath = path52.resolve(checkoutPath);
51722
51881
  const git = cliSimpleGit(resolvedCheckoutPath);
51723
51882
  await yieldToEventLoop2();
51724
51883
  const [branch, remoteUrl] = await Promise.all([
@@ -51733,14 +51892,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
51733
51892
  }
51734
51893
 
51735
51894
  // src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
51736
- import * as path51 from "node:path";
51895
+ import * as path53 from "node:path";
51737
51896
  async function resolveRepoPathRelativeToWorkspaceRoot(options) {
51738
- const checkoutPath = path51.resolve(options.checkoutPath);
51897
+ const checkoutPath = path53.resolve(options.checkoutPath);
51739
51898
  const git = cliSimpleGit(checkoutPath);
51740
- const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
51899
+ const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
51741
51900
  let repoPathRelativeToWorkspaceRoot;
51742
51901
  if (sessionParentPath) {
51743
- const checkoutPathRelativeToSessionParent = path51.relative(sessionParentPath, checkoutPath);
51902
+ const checkoutPathRelativeToSessionParent = path53.relative(sessionParentPath, checkoutPath);
51744
51903
  repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
51745
51904
  } else {
51746
51905
  let gitTopLevel = checkoutPath;
@@ -51750,8 +51909,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
51750
51909
  } catch {
51751
51910
  gitTopLevel = checkoutPath;
51752
51911
  }
51753
- const gitTopLevelRelativeToBridgeRoot = path51.relative(options.bridgeRoot, path51.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
51754
- repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path51.basename(path51.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
51912
+ const gitTopLevelRelativeToBridgeRoot = path53.relative(options.bridgeRoot, path53.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
51913
+ repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path53.basename(path53.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
51755
51914
  }
51756
51915
  return normalizeRepoPathRelativeToWorkspaceRoot(
51757
51916
  repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
@@ -51760,10 +51919,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
51760
51919
 
51761
51920
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
51762
51921
  async function buildWorkingTreeChangeRepoDetail(options) {
51763
- const checkoutPath = path52.resolve(options.targetPath);
51922
+ const checkoutPath = path54.resolve(options.targetPath);
51764
51923
  if (!await isGitRepoDirectory(checkoutPath)) return null;
51765
51924
  const isCommitView = options.basis.kind === "commit";
51766
- const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
51925
+ const sessionParentPath = options.sessionParentPath ? path54.resolve(options.sessionParentPath) : null;
51767
51926
  const git = cliSimpleGit(checkoutPath);
51768
51927
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
51769
51928
  checkoutPath,
@@ -51811,8 +51970,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
51811
51970
 
51812
51971
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
51813
51972
  async function getWorkingTreeChangeRepoDetails(options) {
51814
- const bridgeRoot = path53.resolve(getBridgeRoot());
51815
- const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
51973
+ const bridgeRoot = path55.resolve(getBridgeRoot());
51974
+ const sessionParentPath = options.sessionParentPath ? path55.resolve(options.sessionParentPath) : null;
51816
51975
  const out = [];
51817
51976
  const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
51818
51977
  const basisInput = options.basis ?? { kind: "working" };
@@ -51843,9 +52002,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
51843
52002
  }
51844
52003
 
51845
52004
  // src/git/changes/repo/get-working-tree-change-file-patch.ts
51846
- import * as path54 from "node:path";
52005
+ import * as path56 from "node:path";
51847
52006
  async function getWorkingTreeChangeFilePatch(options) {
51848
- const repoGitCwd = path54.resolve(options.repoGitCwd);
52007
+ const repoGitCwd = path56.resolve(options.repoGitCwd);
51849
52008
  if (!await isGitRepoDirectory(repoGitCwd)) {
51850
52009
  throw new Error("Not a git repository");
51851
52010
  }
@@ -51884,7 +52043,7 @@ async function getWorkingTreeChangeFilePatch(options) {
51884
52043
  });
51885
52044
  return { patchContent: patchContent2, totalLines: totalLines2 };
51886
52045
  }
51887
- const filePath = path54.join(repoGitCwd, filePathRelativeToRepoRoot);
52046
+ const filePath = path56.join(repoGitCwd, filePathRelativeToRepoRoot);
51888
52047
  const hydrateKind = options.change === "moved" ? "modified" : options.change;
51889
52048
  let patchContent = await unifiedDiffForFile(
51890
52049
  repoGitCwd,
@@ -51930,18 +52089,18 @@ function parseWorkingTreeChangeKind(value) {
51930
52089
  }
51931
52090
 
51932
52091
  // src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
51933
- import * as path55 from "node:path";
52092
+ import * as path57 from "node:path";
51934
52093
  async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
51935
52094
  const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
51936
- const bridgeRoot = path55.resolve(getBridgeRoot());
51937
- const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path55.resolve(cache2.getSessionParentPath(sessionId)) : null;
52095
+ const bridgeRoot = path57.resolve(getBridgeRoot());
52096
+ const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path57.resolve(cache2.getSessionParentPath(sessionId)) : null;
51938
52097
  const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
51939
52098
  opts.repoRelPath.trim()
51940
52099
  );
51941
52100
  let result = null;
51942
52101
  await forEachWithGitYield(targets, async (targetPath) => {
51943
52102
  if (result) return;
51944
- const checkoutPath = path55.resolve(targetPath);
52103
+ const checkoutPath = path57.resolve(targetPath);
51945
52104
  if (!await isGitRepoDirectory(checkoutPath)) return;
51946
52105
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
51947
52106
  checkoutPath,
@@ -51974,13 +52133,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
51974
52133
  }
51975
52134
 
51976
52135
  // src/worktrees/remove-session-worktrees.ts
51977
- import * as fs39 from "node:fs";
52136
+ import * as fs41 from "node:fs";
51978
52137
 
51979
52138
  // src/git/worktrees/worktree-remove.ts
51980
- import * as fs38 from "node:fs";
52139
+ import * as fs40 from "node:fs";
51981
52140
 
51982
52141
  // src/worktrees/is-removable-session-worktree-checkout-path.ts
51983
- import path56 from "node:path";
52142
+ import path58 from "node:path";
51984
52143
  init_normalize_resolved_path();
51985
52144
  function isBridgeRootCheckoutPath(checkoutPath) {
51986
52145
  return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
@@ -51989,23 +52148,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
51989
52148
  if (isBridgeRootCheckoutPath(checkoutPath)) return false;
51990
52149
  const normalized = normalizeResolvedPath(checkoutPath);
51991
52150
  const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
51992
- const rel = path56.relative(worktreesRoot, normalized);
51993
- if (rel === "" || rel.startsWith("..") || path56.isAbsolute(rel)) return false;
52151
+ const rel = path58.relative(worktreesRoot, normalized);
52152
+ if (rel === "" || rel.startsWith("..") || path58.isAbsolute(rel)) return false;
51994
52153
  return true;
51995
52154
  }
51996
52155
 
51997
52156
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
51998
- import * as fs37 from "node:fs";
51999
- import * as path57 from "node:path";
52157
+ import * as fs39 from "node:fs";
52158
+ import * as path59 from "node:path";
52000
52159
  function resolveMainRepoFromWorktreeGitFile(wt) {
52001
- const gitDirFile = path57.join(wt, ".git");
52002
- if (!fs37.existsSync(gitDirFile) || !fs37.statSync(gitDirFile).isFile()) return "";
52003
- const first2 = fs37.readFileSync(gitDirFile, "utf8").trim();
52160
+ const gitDirFile = path59.join(wt, ".git");
52161
+ if (!fs39.existsSync(gitDirFile) || !fs39.statSync(gitDirFile).isFile()) return "";
52162
+ const first2 = fs39.readFileSync(gitDirFile, "utf8").trim();
52004
52163
  const m = first2.match(/^gitdir:\s*(.+)$/im);
52005
52164
  if (!m) return "";
52006
- const gitWorktreePath = path57.resolve(wt, m[1].trim());
52007
- const gitDir = path57.dirname(path57.dirname(gitWorktreePath));
52008
- return path57.dirname(gitDir);
52165
+ const gitWorktreePath = path59.resolve(wt, m[1].trim());
52166
+ const gitDir = path59.dirname(path59.dirname(gitWorktreePath));
52167
+ return path59.dirname(gitDir);
52009
52168
  }
52010
52169
 
52011
52170
  // src/git/worktrees/worktree-remove.ts
@@ -52016,7 +52175,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
52016
52175
  return true;
52017
52176
  }
52018
52177
  if (isBridgeRootCheckoutPath(worktreePath)) return false;
52019
- fs38.rmSync(worktreePath, { recursive: true, force: true });
52178
+ fs40.rmSync(worktreePath, { recursive: true, force: true });
52020
52179
  return true;
52021
52180
  }
52022
52181
 
@@ -52038,7 +52197,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
52038
52197
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
52039
52198
  if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
52040
52199
  try {
52041
- fs39.rmSync(wt, { recursive: true, force: true });
52200
+ fs41.rmSync(wt, { recursive: true, force: true });
52042
52201
  } catch {
52043
52202
  }
52044
52203
  }
@@ -52094,12 +52253,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
52094
52253
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
52095
52254
  init_cli_process_interrupt();
52096
52255
  init_yield_to_event_loop();
52097
- import * as fs43 from "node:fs";
52098
- import * as path62 from "node:path";
52256
+ import * as fs45 from "node:fs";
52257
+ import * as path64 from "node:path";
52099
52258
 
52100
52259
  // src/worktrees/discovery/collect-worktree-paths.ts
52101
- import * as fs41 from "node:fs";
52102
- import * as path59 from "node:path";
52260
+ import * as fs43 from "node:fs";
52261
+ import * as path61 from "node:path";
52103
52262
 
52104
52263
  // src/worktrees/discovery/disk-walk-constants.ts
52105
52264
  var DISK_WALK_YIELD_EVERY = 64;
@@ -52129,8 +52288,8 @@ function shouldSkipDiskWalkEntry(name) {
52129
52288
  // src/worktrees/discovery/disk-walk-utils.ts
52130
52289
  init_cli_process_interrupt();
52131
52290
  init_yield_to_event_loop();
52132
- import * as fs40 from "node:fs";
52133
- import * as path58 from "node:path";
52291
+ import * as fs42 from "node:fs";
52292
+ import * as path60 from "node:path";
52134
52293
  async function yieldDuringDiskWalk(state) {
52135
52294
  state.entries++;
52136
52295
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -52140,7 +52299,7 @@ async function yieldDuringDiskWalk(state) {
52140
52299
  }
52141
52300
  async function isGitDir(dirPath) {
52142
52301
  try {
52143
- await fs40.promises.access(path58.join(dirPath, ".git"));
52302
+ await fs42.promises.access(path60.join(dirPath, ".git"));
52144
52303
  return true;
52145
52304
  } catch {
52146
52305
  return false;
@@ -52154,23 +52313,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
52154
52313
  const walk = async (dir) => {
52155
52314
  if (!await yieldDuringDiskWalk(state)) return;
52156
52315
  if (await isGitDir(dir)) {
52157
- out.push(path59.resolve(dir));
52316
+ out.push(path61.resolve(dir));
52158
52317
  return;
52159
52318
  }
52160
52319
  let entries;
52161
52320
  try {
52162
- entries = await fs41.promises.readdir(dir, { withFileTypes: true });
52321
+ entries = await fs43.promises.readdir(dir, { withFileTypes: true });
52163
52322
  } catch {
52164
52323
  return;
52165
52324
  }
52166
52325
  for (const e of entries) {
52167
52326
  if (shouldSkipDiskWalkEntry(e.name)) continue;
52168
- const full = path59.join(dir, e.name);
52327
+ const full = path61.join(dir, e.name);
52169
52328
  if (!e.isDirectory()) continue;
52170
52329
  await walk(full);
52171
52330
  }
52172
52331
  };
52173
- await walk(path59.resolve(rootPath));
52332
+ await walk(path61.resolve(rootPath));
52174
52333
  return { paths: [...new Set(out)], entriesVisited: state.entries };
52175
52334
  }
52176
52335
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -52181,16 +52340,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
52181
52340
  if (!await yieldDuringDiskWalk(state)) return;
52182
52341
  let entries;
52183
52342
  try {
52184
- entries = await fs41.promises.readdir(dir, { withFileTypes: true });
52343
+ entries = await fs43.promises.readdir(dir, { withFileTypes: true });
52185
52344
  } catch {
52186
52345
  return;
52187
52346
  }
52188
52347
  for (const e of entries) {
52189
52348
  if (shouldSkipDiskWalkEntry(e.name)) continue;
52190
- const full = path59.join(dir, e.name);
52349
+ const full = path61.join(dir, e.name);
52191
52350
  if (!e.isDirectory()) continue;
52192
52351
  if (e.name === sessionId) {
52193
- if (await isGitDir(full)) out.push(path59.resolve(full));
52352
+ if (await isGitDir(full)) out.push(path61.resolve(full));
52194
52353
  continue;
52195
52354
  }
52196
52355
  if (await isGitDir(full)) continue;
@@ -52202,14 +52361,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
52202
52361
  }
52203
52362
 
52204
52363
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
52205
- import * as path60 from "node:path";
52364
+ import * as path62 from "node:path";
52206
52365
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
52207
- const bridge = path60.resolve(bridgeRoot);
52366
+ const bridge = path62.resolve(bridgeRoot);
52208
52367
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
52209
52368
  const relevant = layout.launcherCwds.filter((e) => {
52210
- const entry = path60.resolve(e.absolutePath);
52211
- return bridge === entry || bridge.startsWith(entry + path60.sep) || entry.startsWith(bridge + path60.sep);
52212
- }).sort((a, b) => path60.resolve(b.absolutePath).length - path60.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
52369
+ const entry = path62.resolve(e.absolutePath);
52370
+ return bridge === entry || bridge.startsWith(entry + path62.sep) || entry.startsWith(bridge + path62.sep);
52371
+ }).sort((a, b) => path62.resolve(b.absolutePath).length - path62.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
52213
52372
  const ordered = [];
52214
52373
  const seen = /* @__PURE__ */ new Set();
52215
52374
  const add = (k) => {
@@ -52227,19 +52386,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
52227
52386
  }
52228
52387
 
52229
52388
  // src/worktrees/discovery/try-binding-from-isolated-directory.ts
52230
- import * as fs42 from "node:fs";
52231
- import * as path61 from "node:path";
52389
+ import * as fs44 from "node:fs";
52390
+ import * as path63 from "node:path";
52232
52391
  async function tryBindingFromIsolatedDirectory(scopeDir) {
52233
52392
  let st;
52234
52393
  try {
52235
- st = await fs42.promises.stat(scopeDir);
52394
+ st = await fs44.promises.stat(scopeDir);
52236
52395
  } catch {
52237
52396
  return null;
52238
52397
  }
52239
52398
  if (!st.isDirectory()) return null;
52240
52399
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
52241
52400
  if (worktreePaths.length === 0) return null;
52242
- const abs = path61.resolve(scopeDir);
52401
+ const abs = path63.resolve(scopeDir);
52243
52402
  return {
52244
52403
  parentPath: abs,
52245
52404
  repoCheckoutPaths: worktreePaths
@@ -52262,7 +52421,7 @@ async function discoverSessionWorktreeOnDisk(options) {
52262
52421
  const sid = sessionId.trim();
52263
52422
  if (!sid) return null;
52264
52423
  try {
52265
- await fs43.promises.access(worktreesRootPath);
52424
+ await fs45.promises.access(worktreesRootPath);
52266
52425
  } catch {
52267
52426
  return null;
52268
52427
  }
@@ -52271,13 +52430,13 @@ async function discoverSessionWorktreeOnDisk(options) {
52271
52430
  if (preferredKey) keysOnDisk.push(preferredKey);
52272
52431
  const scanState = { entries: 0 };
52273
52432
  try {
52274
- for (const name of await fs43.promises.readdir(worktreesRootPath)) {
52433
+ for (const name of await fs45.promises.readdir(worktreesRootPath)) {
52275
52434
  if (!await yieldDuringDiskWalk(scanState)) break;
52276
52435
  if (name.startsWith(".")) continue;
52277
- const p = path62.join(worktreesRootPath, name);
52436
+ const p = path64.join(worktreesRootPath, name);
52278
52437
  let st;
52279
52438
  try {
52280
- st = await fs43.promises.stat(p);
52439
+ st = await fs45.promises.stat(p);
52281
52440
  } catch {
52282
52441
  continue;
52283
52442
  }
@@ -52291,23 +52450,23 @@ async function discoverSessionWorktreeOnDisk(options) {
52291
52450
  for (const key of keys) {
52292
52451
  if (isCliImmediateShutdownRequested()) return null;
52293
52452
  await yieldToEventLoop();
52294
- const layoutRoot = path62.join(worktreesRootPath, key);
52453
+ const layoutRoot = path64.join(worktreesRootPath, key);
52295
52454
  let layoutSt;
52296
52455
  try {
52297
- layoutSt = await fs43.promises.stat(layoutRoot);
52456
+ layoutSt = await fs45.promises.stat(layoutRoot);
52298
52457
  } catch {
52299
52458
  continue;
52300
52459
  }
52301
52460
  if (!layoutSt.isDirectory()) continue;
52302
- const sessionDir = path62.join(layoutRoot, sid);
52461
+ const sessionDir = path64.join(layoutRoot, sid);
52303
52462
  const nested = await tryBindingFromSessionDirectory(sessionDir);
52304
52463
  if (nested) return nested;
52305
52464
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
52306
52465
  if (legacy.paths.length > 0) {
52307
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path62.resolve(legacy.paths[0]);
52466
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path64.resolve(legacy.paths[0]);
52308
52467
  return {
52309
- sessionParentPath: path62.resolve(isolated),
52310
- repoCheckoutPaths: legacy.paths.map((p) => path62.resolve(p))
52468
+ sessionParentPath: path64.resolve(isolated),
52469
+ repoCheckoutPaths: legacy.paths.map((p) => path64.resolve(p))
52311
52470
  };
52312
52471
  }
52313
52472
  }
@@ -52315,31 +52474,31 @@ async function discoverSessionWorktreeOnDisk(options) {
52315
52474
  }
52316
52475
 
52317
52476
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
52318
- import * as fs44 from "node:fs";
52319
- import * as path64 from "node:path";
52477
+ import * as fs46 from "node:fs";
52478
+ import * as path66 from "node:path";
52320
52479
 
52321
52480
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
52322
52481
  init_cli_process_interrupt();
52323
52482
  init_yield_to_event_loop();
52324
- import * as path63 from "node:path";
52483
+ import * as path65 from "node:path";
52325
52484
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
52326
52485
  const sid = sessionId.trim();
52327
52486
  if (!sid) return null;
52328
- const hintR = path63.resolve(checkoutPath);
52487
+ const hintR = path65.resolve(checkoutPath);
52329
52488
  let best = null;
52330
- let cur = path63.dirname(hintR);
52489
+ let cur = path65.dirname(hintR);
52331
52490
  for (let i = 0; i < 40; i++) {
52332
52491
  if (isCliImmediateShutdownRequested()) return best;
52333
52492
  await yieldToEventLoop();
52334
52493
  const paths = await collectWorktreeRootsNamed(cur, sid);
52335
- if (paths.paths.some((p) => path63.resolve(p) === hintR)) {
52336
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path63.resolve(paths.paths[0]);
52494
+ if (paths.paths.some((p) => path65.resolve(p) === hintR)) {
52495
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path65.resolve(paths.paths[0]);
52337
52496
  best = {
52338
- sessionParentPath: path63.resolve(isolated),
52339
- repoCheckoutPaths: paths.paths.map((p) => path63.resolve(p))
52497
+ sessionParentPath: path65.resolve(isolated),
52498
+ repoCheckoutPaths: paths.paths.map((p) => path65.resolve(p))
52340
52499
  };
52341
52500
  }
52342
- const next = path63.dirname(cur);
52501
+ const next = path65.dirname(cur);
52343
52502
  if (next === cur) break;
52344
52503
  cur = next;
52345
52504
  }
@@ -52350,12 +52509,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
52350
52509
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
52351
52510
  const sid = sessionId.trim();
52352
52511
  if (!sid) return null;
52353
- const hint = path64.resolve(sessionParentPathOrHint);
52354
- const underHint = await tryBindingFromSessionDirectory(path64.join(hint, sid));
52512
+ const hint = path66.resolve(sessionParentPathOrHint);
52513
+ const underHint = await tryBindingFromSessionDirectory(path66.join(hint, sid));
52355
52514
  if (underHint) return underHint;
52356
52515
  const direct = await tryBindingFromSessionDirectory(hint);
52357
52516
  if (direct) {
52358
- if (path64.basename(hint) === sid && await isGitDir(hint)) {
52517
+ if (path66.basename(hint) === sid && await isGitDir(hint)) {
52359
52518
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
52360
52519
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
52361
52520
  return legacyFromCheckout;
@@ -52363,23 +52522,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
52363
52522
  }
52364
52523
  return direct;
52365
52524
  }
52366
- if (path64.basename(hint) === sid && await isGitDir(hint)) {
52525
+ if (path66.basename(hint) === sid && await isGitDir(hint)) {
52367
52526
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
52368
52527
  if (legacyFromCheckout) return legacyFromCheckout;
52369
52528
  }
52370
52529
  let st;
52371
52530
  try {
52372
- st = await fs44.promises.stat(hint);
52531
+ st = await fs46.promises.stat(hint);
52373
52532
  } catch {
52374
52533
  return null;
52375
52534
  }
52376
52535
  if (!st.isDirectory()) return null;
52377
52536
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
52378
52537
  if (legacyPaths.paths.length === 0) return null;
52379
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path64.resolve(legacyPaths.paths[0]);
52538
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path66.resolve(legacyPaths.paths[0]);
52380
52539
  return {
52381
- sessionParentPath: path64.resolve(isolated),
52382
- repoCheckoutPaths: legacyPaths.paths.map((p) => path64.resolve(p))
52540
+ sessionParentPath: path66.resolve(isolated),
52541
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path66.resolve(p))
52383
52542
  };
52384
52543
  }
52385
52544
 
@@ -52440,11 +52599,11 @@ function parseSessionParent(v) {
52440
52599
  }
52441
52600
 
52442
52601
  // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
52443
- import * as fs48 from "node:fs";
52602
+ import * as fs50 from "node:fs";
52444
52603
 
52445
52604
  // src/git/discover-repos.ts
52446
- import * as fs45 from "node:fs";
52447
- import * as path65 from "node:path";
52605
+ import * as fs47 from "node:fs";
52606
+ import * as path67 from "node:path";
52448
52607
  init_yield_to_event_loop();
52449
52608
  var GIT_DISCOVER_YIELD_EVERY = 32;
52450
52609
  async function yieldGitDiscoverWork(entryCount) {
@@ -52454,14 +52613,14 @@ async function yieldGitDiscoverWork(entryCount) {
52454
52613
  }
52455
52614
  async function discoverGitRepos(cwd = getBridgeRoot()) {
52456
52615
  const result = [];
52457
- const cwdResolved = path65.resolve(cwd);
52616
+ const cwdResolved = path67.resolve(cwd);
52458
52617
  if (await isGitRepoDirectory(cwdResolved)) {
52459
52618
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
52460
52619
  result.push({ absolutePath: cwdResolved, remoteUrl });
52461
52620
  }
52462
52621
  let entries;
52463
52622
  try {
52464
- entries = fs45.readdirSync(cwdResolved, { withFileTypes: true });
52623
+ entries = fs47.readdirSync(cwdResolved, { withFileTypes: true });
52465
52624
  } catch {
52466
52625
  return result;
52467
52626
  }
@@ -52469,7 +52628,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
52469
52628
  await yieldGitDiscoverWork(i + 1);
52470
52629
  const ent = entries[i];
52471
52630
  if (!ent.isDirectory()) continue;
52472
- const childPath2 = path65.join(cwdResolved, ent.name);
52631
+ const childPath2 = path67.join(cwdResolved, ent.name);
52473
52632
  if (await isGitRepoDirectory(childPath2)) {
52474
52633
  const remoteUrl = await getRemoteOriginUrl(childPath2);
52475
52634
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -52478,17 +52637,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
52478
52637
  return result;
52479
52638
  }
52480
52639
  async function discoverGitReposUnderRoot(rootPath) {
52481
- const root = path65.resolve(rootPath);
52640
+ const root = path67.resolve(rootPath);
52482
52641
  const roots = [];
52483
52642
  let walkEntries = 0;
52484
52643
  async function walk(dir) {
52485
52644
  if (await isGitRepoDirectory(dir)) {
52486
- roots.push(path65.resolve(dir));
52645
+ roots.push(path67.resolve(dir));
52487
52646
  return;
52488
52647
  }
52489
52648
  let entries;
52490
52649
  try {
52491
- entries = fs45.readdirSync(dir, { withFileTypes: true });
52650
+ entries = fs47.readdirSync(dir, { withFileTypes: true });
52492
52651
  } catch {
52493
52652
  return;
52494
52653
  }
@@ -52496,7 +52655,7 @@ async function discoverGitReposUnderRoot(rootPath) {
52496
52655
  await yieldGitDiscoverWork(++walkEntries);
52497
52656
  const ent = entries[i];
52498
52657
  if (!ent.isDirectory() || ent.name === ".git") continue;
52499
- await walk(path65.join(dir, ent.name));
52658
+ await walk(path67.join(dir, ent.name));
52500
52659
  }
52501
52660
  }
52502
52661
  await walk(root);
@@ -52512,8 +52671,8 @@ async function discoverGitReposUnderRoot(rootPath) {
52512
52671
  }
52513
52672
 
52514
52673
  // src/worktrees/prepare/add-isolated-repo-worktree.ts
52515
- import * as fs47 from "node:fs";
52516
- import * as path67 from "node:path";
52674
+ import * as fs49 from "node:fs";
52675
+ import * as path69 from "node:path";
52517
52676
 
52518
52677
  // src/git/worktrees/worktree-add.ts
52519
52678
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
@@ -52529,8 +52688,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
52529
52688
  }
52530
52689
 
52531
52690
  // src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
52532
- import * as fs46 from "node:fs";
52533
- import * as path66 from "node:path";
52691
+ import * as fs48 from "node:fs";
52692
+ import * as path68 from "node:path";
52534
52693
  var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
52535
52694
  function copyBridgeFilesAlongWorktreePath(options) {
52536
52695
  const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
@@ -52539,19 +52698,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
52539
52698
  const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
52540
52699
  for (let i = 0; i < segments.length; i++) {
52541
52700
  const prefix = segments.slice(0, i).join("/");
52542
- const bridgeDir = prefix ? path66.join(bridgeRoot, prefix) : bridgeRoot;
52543
- const destDir = prefix ? path66.join(scopeDir, prefix) : scopeDir;
52701
+ const bridgeDir = prefix ? path68.join(bridgeRoot, prefix) : bridgeRoot;
52702
+ const destDir = prefix ? path68.join(scopeDir, prefix) : scopeDir;
52544
52703
  for (const fileName of fileNames) {
52545
52704
  copyFileIfPresent(bridgeDir, destDir, fileName, log2);
52546
52705
  }
52547
52706
  }
52548
52707
  }
52549
52708
  function copyFileIfPresent(srcDir, destDir, fileName, log2) {
52550
- const src = path66.join(srcDir, fileName);
52551
- if (!fs46.existsSync(src)) return;
52552
- const dest = path66.join(destDir, fileName);
52709
+ const src = path68.join(srcDir, fileName);
52710
+ if (!fs48.existsSync(src)) return;
52711
+ const dest = path68.join(destDir, fileName);
52553
52712
  try {
52554
- fs46.copyFileSync(src, dest);
52713
+ fs48.copyFileSync(src, dest);
52555
52714
  log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
52556
52715
  } catch (e) {
52557
52716
  log2?.(
@@ -52583,16 +52742,16 @@ async function addIsolatedRepoWorktree(options) {
52583
52742
  worktreeBaseBranches,
52584
52743
  log: log2
52585
52744
  } = options;
52586
- const repoPathRelativeToBridgeRootRaw = path67.relative(bridgeResolved, repoAbsolutePath);
52587
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path67.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
52745
+ const repoPathRelativeToBridgeRootRaw = path69.relative(bridgeResolved, repoAbsolutePath);
52746
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path69.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
52588
52747
  return null;
52589
52748
  }
52590
52749
  const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
52591
52750
  repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
52592
52751
  );
52593
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path67.join(scopeDir, repoPathRelativeToBridgeRoot);
52752
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path69.join(scopeDir, repoPathRelativeToBridgeRoot);
52594
52753
  if (repoPathRelativeToBridgeRoot !== ".") {
52595
- fs47.mkdirSync(path67.dirname(worktreePath), { recursive: true });
52754
+ fs49.mkdirSync(path69.dirname(worktreePath), { recursive: true });
52596
52755
  copyBridgeFilesAlongWorktreePath({
52597
52756
  bridgeRoot: bridgeResolved,
52598
52757
  scopeDir,
@@ -52620,7 +52779,7 @@ async function addIsolatedRepoWorktree(options) {
52620
52779
  }
52621
52780
 
52622
52781
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
52623
- import * as path68 from "node:path";
52782
+ import * as path70 from "node:path";
52624
52783
 
52625
52784
  // src/worktrees/worktree-layout-kind.ts
52626
52785
  function sanitizeWorktreeBranchSegment(value) {
@@ -52650,10 +52809,10 @@ function previewDeployBranchName(environmentId) {
52650
52809
 
52651
52810
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
52652
52811
  function resolveIsolatedScopeDir(options) {
52653
- const bridgeResolved = path68.resolve(options.bridgeRoot);
52812
+ const bridgeResolved = path70.resolve(options.bridgeRoot);
52654
52813
  const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
52655
- const bridgeKeyDir = path68.join(options.worktreesRootPath, cwdKey);
52656
- const scopeDir = path68.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
52814
+ const bridgeKeyDir = path70.join(options.worktreesRootPath, cwdKey);
52815
+ const scopeDir = path70.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
52657
52816
  return { bridgeResolved, scopeDir };
52658
52817
  }
52659
52818
 
@@ -52683,7 +52842,7 @@ async function prepareNewIsolatedWorktrees(options) {
52683
52842
  return null;
52684
52843
  }
52685
52844
  const worktreePaths = [];
52686
- fs48.mkdirSync(scopeDir, { recursive: true });
52845
+ fs50.mkdirSync(scopeDir, { recursive: true });
52687
52846
  await forEachWithGitYield(repos, async (repo) => {
52688
52847
  const worktreePath = await addIsolatedRepoWorktree({
52689
52848
  kind,
@@ -52755,10 +52914,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
52755
52914
  }
52756
52915
 
52757
52916
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
52758
- import * as path69 from "node:path";
52917
+ import * as path71 from "node:path";
52759
52918
  init_yield_to_event_loop();
52760
52919
  async function resolveExplicitSessionParentPath(params) {
52761
- const resolved = path69.resolve(params.parentPathRaw);
52920
+ const resolved = path71.resolve(params.parentPathRaw);
52762
52921
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
52763
52922
  return resolved;
52764
52923
  }
@@ -52775,7 +52934,7 @@ async function resolveExplicitSessionParentPath(params) {
52775
52934
  await yieldToEventLoop();
52776
52935
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
52777
52936
  if (tryRoot) return rememberAndReturn(tryRoot);
52778
- const next = path69.dirname(cur);
52937
+ const next = path71.dirname(cur);
52779
52938
  if (next === cur) break;
52780
52939
  cur = next;
52781
52940
  }
@@ -52936,15 +53095,15 @@ var SessionWorktreeManager = class {
52936
53095
  };
52937
53096
 
52938
53097
  // src/worktrees/discovery/discover-preview-worktree-on-disk.ts
52939
- import * as fs49 from "node:fs";
52940
- import * as path70 from "node:path";
53098
+ import * as fs51 from "node:fs";
53099
+ import * as path72 from "node:path";
52941
53100
  init_yield_to_event_loop();
52942
53101
  async function discoverPreviewWorktreeOnDisk(options) {
52943
53102
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
52944
53103
  const eid = environmentId.trim();
52945
53104
  if (!eid) return null;
52946
53105
  try {
52947
- await fs49.promises.access(worktreesRootPath);
53106
+ await fs51.promises.access(worktreesRootPath);
52948
53107
  } catch {
52949
53108
  return null;
52950
53109
  }
@@ -52953,13 +53112,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
52953
53112
  if (preferredKey) keysOnDisk.push(preferredKey);
52954
53113
  const scanState = { entries: 0 };
52955
53114
  try {
52956
- for (const name of await fs49.promises.readdir(worktreesRootPath)) {
53115
+ for (const name of await fs51.promises.readdir(worktreesRootPath)) {
52957
53116
  if (!await yieldDuringDiskWalk(scanState)) break;
52958
53117
  if (name.startsWith(".")) continue;
52959
- const p = path70.join(worktreesRootPath, name);
53118
+ const p = path72.join(worktreesRootPath, name);
52960
53119
  let st;
52961
53120
  try {
52962
- st = await fs49.promises.stat(p);
53121
+ st = await fs51.promises.stat(p);
52963
53122
  } catch {
52964
53123
  continue;
52965
53124
  }
@@ -52973,7 +53132,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
52973
53132
  const previewDirRel = layoutDirSegments("preview_environment", eid);
52974
53133
  for (const key of keys) {
52975
53134
  await yieldToEventLoop();
52976
- const previewDir = path70.join(worktreesRootPath, key, ...previewDirRel);
53135
+ const previewDir = path72.join(worktreesRootPath, key, ...previewDirRel);
52977
53136
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
52978
53137
  if (binding) return binding;
52979
53138
  }
@@ -53100,7 +53259,7 @@ var PreviewWorktreeManager = class {
53100
53259
  };
53101
53260
 
53102
53261
  // src/worktrees/deploy/deploy-session-to-preview-environment.ts
53103
- import * as path74 from "node:path";
53262
+ import * as path76 from "node:path";
53104
53263
 
53105
53264
  // src/git/worktrees/reset-worktree-to-branch.ts
53106
53265
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -53111,8 +53270,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
53111
53270
  }
53112
53271
 
53113
53272
  // src/worktrees/deploy/capture-and-apply-wip.ts
53114
- import * as fs50 from "node:fs";
53115
- import * as path71 from "node:path";
53273
+ import * as fs52 from "node:fs";
53274
+ import * as path73 from "node:path";
53116
53275
 
53117
53276
  // src/git/snapshot/git.ts
53118
53277
  var SNAPSHOT_GIT_TIMEOUT_MS = 5e3;
@@ -53167,12 +53326,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
53167
53326
  if (!ap.ok) return ap;
53168
53327
  }
53169
53328
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
53170
- const src = path71.join(sourceRepoPath, rel);
53171
- const dst = path71.join(targetRepoPath, rel);
53329
+ const src = path73.join(sourceRepoPath, rel);
53330
+ const dst = path73.join(targetRepoPath, rel);
53172
53331
  try {
53173
- if (!fs50.existsSync(src)) return;
53174
- fs50.mkdirSync(path71.dirname(dst), { recursive: true });
53175
- fs50.copyFileSync(src, dst);
53332
+ if (!fs52.existsSync(src)) return;
53333
+ fs52.mkdirSync(path73.dirname(dst), { recursive: true });
53334
+ fs52.copyFileSync(src, dst);
53176
53335
  } catch (e) {
53177
53336
  log2(
53178
53337
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -53183,14 +53342,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
53183
53342
  }
53184
53343
 
53185
53344
  // src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
53186
- import * as path72 from "node:path";
53345
+ import * as path74 from "node:path";
53187
53346
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
53188
53347
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
53189
- const resolvedSessionParentPath = sessionParentPath ? path72.resolve(sessionParentPath) : null;
53348
+ const resolvedSessionParentPath = sessionParentPath ? path74.resolve(sessionParentPath) : null;
53190
53349
  let match = null;
53191
53350
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
53192
53351
  if (match) return;
53193
- const resolvedCheckoutPath = path72.resolve(checkoutPath);
53352
+ const resolvedCheckoutPath = path74.resolve(checkoutPath);
53194
53353
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
53195
53354
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
53196
53355
  checkoutPath: resolvedCheckoutPath,
@@ -53244,7 +53403,7 @@ async function applySessionWipToPreviewCheckouts(options) {
53244
53403
  }
53245
53404
 
53246
53405
  // src/worktrees/deploy/collect-session-repo-deploy-states.ts
53247
- import * as path73 from "node:path";
53406
+ import * as path75 from "node:path";
53248
53407
 
53249
53408
  // src/git/branches/create-or-update-branch.ts
53250
53409
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -53281,19 +53440,19 @@ async function collectSessionRepoDeployStates(options) {
53281
53440
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
53282
53441
  const states = [];
53283
53442
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
53284
- const checkoutPath = path73.resolve(sessionCheckout);
53443
+ const checkoutPath = path75.resolve(sessionCheckout);
53285
53444
  if (!await isGitRepoDirectory(checkoutPath)) return;
53286
53445
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
53287
53446
  checkoutPath,
53288
53447
  bridgeRoot,
53289
- sessionParentPath: sessionParentPath ? path73.resolve(sessionParentPath) : null
53448
+ sessionParentPath: sessionParentPath ? path75.resolve(sessionParentPath) : null
53290
53449
  });
53291
53450
  if (!repoPathRelativeToWorkspaceRoot) return;
53292
53451
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
53293
53452
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
53294
53453
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
53295
53454
  checkoutPaths: previewCheckoutPaths,
53296
- sessionParentPath: previewParentPath ? path73.resolve(previewParentPath) : null,
53455
+ sessionParentPath: previewParentPath ? path75.resolve(previewParentPath) : null,
53297
53456
  bridgeRoot,
53298
53457
  repoPathRelativeToWorkspaceRoot
53299
53458
  }) : null;
@@ -53313,7 +53472,7 @@ async function deploySessionToPreviewEnvironment(options) {
53313
53472
  const eid = options.environmentId.trim();
53314
53473
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
53315
53474
  const deployBranch = previewDeployBranchName(eid);
53316
- const bridgeRoot = path74.resolve(getBridgeRoot());
53475
+ const bridgeRoot = path76.resolve(getBridgeRoot());
53317
53476
  await previewWorktreeManager.ensureCached(eid);
53318
53477
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
53319
53478
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -53353,10 +53512,10 @@ async function deploySessionToPreviewEnvironment(options) {
53353
53512
  }
53354
53513
 
53355
53514
  // src/worktrees/manager/default-worktrees-root-path.ts
53356
- import * as path75 from "node:path";
53357
- import os9 from "node:os";
53515
+ import * as path77 from "node:path";
53516
+ import os10 from "node:os";
53358
53517
  function defaultWorktreesRootPath() {
53359
- return path75.join(os9.homedir(), ".buildautomaton", "worktrees");
53518
+ return path77.join(os10.homedir(), ".buildautomaton", "worktrees");
53360
53519
  }
53361
53520
 
53362
53521
  // src/connection/create-bridge-worktree-managers.ts
@@ -53486,14 +53645,14 @@ function assertBridgeWorkspace(ctx) {
53486
53645
  }
53487
53646
 
53488
53647
  // src/files/list-dir/index.ts
53489
- import fs52 from "node:fs";
53648
+ import fs54 from "node:fs";
53490
53649
 
53491
53650
  // src/files/ensure-under-cwd.ts
53492
- import path76 from "node:path";
53651
+ import path78 from "node:path";
53493
53652
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
53494
- const normalized = path76.normalize(relativePath).replace(/^(\.\/)+/, "");
53495
- const resolved = path76.resolve(cwd, normalized);
53496
- if (!resolved.startsWith(cwd + path76.sep) && resolved !== cwd) {
53653
+ const normalized = path78.normalize(relativePath).replace(/^(\.\/)+/, "");
53654
+ const resolved = path78.resolve(cwd, normalized);
53655
+ if (!resolved.startsWith(cwd + path78.sep) && resolved !== cwd) {
53497
53656
  return null;
53498
53657
  }
53499
53658
  return resolved;
@@ -53506,15 +53665,15 @@ init_yield_to_event_loop();
53506
53665
  var LIST_DIR_YIELD_EVERY = 256;
53507
53666
 
53508
53667
  // src/files/list-dir/map-dir-entry.ts
53509
- import path77 from "node:path";
53510
- import fs51 from "node:fs";
53668
+ import path79 from "node:path";
53669
+ import fs53 from "node:fs";
53511
53670
  async function mapDirEntry(d, relativePath, resolved) {
53512
- const entryPath = path77.join(relativePath || ".", d.name).replace(/\\/g, "/");
53513
- const fullPath = path77.join(resolved, d.name);
53671
+ const entryPath = path79.join(relativePath || ".", d.name).replace(/\\/g, "/");
53672
+ const fullPath = path79.join(resolved, d.name);
53514
53673
  let isDir = d.isDirectory();
53515
53674
  if (d.isSymbolicLink()) {
53516
53675
  try {
53517
- const targetStat = await fs51.promises.stat(fullPath);
53676
+ const targetStat = await fs53.promises.stat(fullPath);
53518
53677
  isDir = targetStat.isDirectory();
53519
53678
  } catch {
53520
53679
  isDir = false;
@@ -53544,7 +53703,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
53544
53703
  return { error: "Path is outside working directory" };
53545
53704
  }
53546
53705
  try {
53547
- const names = await fs52.promises.readdir(resolved, { withFileTypes: true });
53706
+ const names = await fs54.promises.readdir(resolved, { withFileTypes: true });
53548
53707
  const entries = [];
53549
53708
  for (let i = 0; i < names.length; i++) {
53550
53709
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -53560,13 +53719,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
53560
53719
  }
53561
53720
 
53562
53721
  // src/git/tree/resolve-repo-abs-path.ts
53563
- import * as path78 from "node:path";
53722
+ import * as path80 from "node:path";
53564
53723
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
53565
- const bridgeResolved = path78.resolve(bridgeRoot);
53724
+ const bridgeResolved = path80.resolve(bridgeRoot);
53566
53725
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
53567
- const repoPath = rel === "" ? bridgeResolved : path78.join(bridgeResolved, rel);
53568
- const resolved = path78.resolve(repoPath);
53569
- if (!resolved.startsWith(bridgeResolved + path78.sep) && resolved !== bridgeResolved) {
53726
+ const repoPath = rel === "" ? bridgeResolved : path80.join(bridgeResolved, rel);
53727
+ const resolved = path80.resolve(repoPath);
53728
+ if (!resolved.startsWith(bridgeResolved + path80.sep) && resolved !== bridgeResolved) {
53570
53729
  return null;
53571
53730
  }
53572
53731
  return resolved;
@@ -54047,25 +54206,25 @@ async function GET2(ctx) {
54047
54206
  init_in_flight();
54048
54207
 
54049
54208
  // src/files/read/read-file-async.ts
54050
- import fs58 from "node:fs";
54209
+ import fs60 from "node:fs";
54051
54210
  init_yield_to_event_loop();
54052
54211
 
54053
54212
  // src/files/read/resolve-file-cache.ts
54054
- import fs53 from "node:fs";
54055
- import path79 from "node:path";
54213
+ import fs55 from "node:fs";
54214
+ import path81 from "node:path";
54056
54215
  var RESOLVE_CACHE_MAX = 4096;
54057
54216
  var resolveCache = /* @__PURE__ */ new Map();
54058
54217
  function resolveCacheKey(sessionParentPath, relativePath) {
54059
54218
  return `${sessionParentPath}\0${relativePath}`;
54060
54219
  }
54061
54220
  function pathStaysUnderParent(filePath, sessionParentPath) {
54062
- const parent = path79.resolve(sessionParentPath);
54063
- const resolved = path79.resolve(filePath);
54064
- return resolved === parent || resolved.startsWith(`${parent}${path79.sep}`);
54221
+ const parent = path81.resolve(sessionParentPath);
54222
+ const resolved = path81.resolve(filePath);
54223
+ return resolved === parent || resolved.startsWith(`${parent}${path81.sep}`);
54065
54224
  }
54066
54225
  function statMatchesCacheSync(entry) {
54067
54226
  try {
54068
- const stat3 = fs53.statSync(entry.path);
54227
+ const stat3 = fs55.statSync(entry.path);
54069
54228
  return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
54070
54229
  } catch {
54071
54230
  return false;
@@ -54098,7 +54257,7 @@ function joinInflightResolve(cacheKey, factory) {
54098
54257
  }
54099
54258
 
54100
54259
  // src/files/read/resolve-file-for-read-core.ts
54101
- import fs54 from "node:fs";
54260
+ import fs56 from "node:fs";
54102
54261
  import { isMainThread as isMainThread4 } from "node:worker_threads";
54103
54262
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
54104
54263
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -54108,13 +54267,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
54108
54267
  let size;
54109
54268
  let mtimeMs;
54110
54269
  try {
54111
- const lstat = fs54.lstatSync(resolved);
54270
+ const lstat = fs56.lstatSync(resolved);
54112
54271
  if (lstat.isSymbolicLink()) {
54113
- real = fs54.realpathSync(resolved);
54272
+ real = fs56.realpathSync(resolved);
54114
54273
  if (!pathStaysUnderParent(real, sessionParentPath)) {
54115
54274
  return { error: "Path is outside working directory" };
54116
54275
  }
54117
- const stat3 = fs54.statSync(real);
54276
+ const stat3 = fs56.statSync(real);
54118
54277
  if (!stat3.isFile()) return { error: "Not a file" };
54119
54278
  size = stat3.size;
54120
54279
  mtimeMs = stat3.mtimeMs;
@@ -54142,13 +54301,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
54142
54301
  let size;
54143
54302
  let mtimeMs;
54144
54303
  try {
54145
- const lstat = await fs54.promises.lstat(resolved);
54304
+ const lstat = await fs56.promises.lstat(resolved);
54146
54305
  if (lstat.isSymbolicLink()) {
54147
- real = await fs54.promises.realpath(resolved);
54306
+ real = await fs56.promises.realpath(resolved);
54148
54307
  if (!pathStaysUnderParent(real, sessionParentPath)) {
54149
54308
  return { error: "Path is outside working directory" };
54150
54309
  }
54151
- const stat3 = await fs54.promises.stat(real);
54310
+ const stat3 = await fs56.promises.stat(real);
54152
54311
  if (!stat3.isFile()) return { error: "Not a file" };
54153
54312
  size = stat3.size;
54154
54313
  mtimeMs = stat3.mtimeMs;
@@ -54197,7 +54356,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
54197
54356
 
54198
54357
  // src/files/read/read-file-range-async.ts
54199
54358
  init_yield_to_event_loop();
54200
- import fs55 from "node:fs";
54359
+ import fs57 from "node:fs";
54201
54360
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
54202
54361
 
54203
54362
  // src/files/read/read-file-range-line-zero.ts
@@ -54311,8 +54470,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
54311
54470
 
54312
54471
  // src/files/read/read-file-range-async.ts
54313
54472
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
54314
- const fileSize = fileSizeIn ?? (await fs55.promises.stat(filePath)).size;
54315
- const fd = await fs55.promises.open(filePath, "r");
54473
+ const fileSize = fileSizeIn ?? (await fs57.promises.stat(filePath)).size;
54474
+ const fd = await fs57.promises.open(filePath, "r");
54316
54475
  const bufSize = 64 * 1024;
54317
54476
  const buf = Buffer.alloc(bufSize);
54318
54477
  const decoder = new StringDecoder2("utf8");
@@ -54413,7 +54572,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
54413
54572
  }
54414
54573
 
54415
54574
  // src/files/read/read-small-file-range-async.ts
54416
- import fs56 from "node:fs";
54575
+ import fs58 from "node:fs";
54417
54576
  import { isMainThread as isMainThread5 } from "node:worker_threads";
54418
54577
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
54419
54578
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -54443,7 +54602,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
54443
54602
  };
54444
54603
  }
54445
54604
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
54446
- const raw = fs56.readFileSync(filePath, "utf8");
54605
+ const raw = fs58.readFileSync(filePath, "utf8");
54447
54606
  const lines = raw.split(/\r?\n/);
54448
54607
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
54449
54608
  }
@@ -54451,28 +54610,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
54451
54610
  if (isMainThread5) {
54452
54611
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
54453
54612
  }
54454
- const raw = await fs56.promises.readFile(filePath, "utf8");
54613
+ const raw = await fs58.promises.readFile(filePath, "utf8");
54455
54614
  const lines = raw.split(/\r?\n/);
54456
54615
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
54457
54616
  }
54458
54617
 
54459
54618
  // src/files/read/read-file-buffer-full-async.ts
54460
54619
  init_yield_to_event_loop();
54461
- import fs57 from "node:fs";
54620
+ import fs59 from "node:fs";
54462
54621
  import { isMainThread as isMainThread6 } from "node:worker_threads";
54463
54622
  var READ_CHUNK_BYTES = 256 * 1024;
54464
54623
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
54465
54624
  async function readFileBufferFullAsync(filePath, knownSize) {
54466
54625
  if (isMainThread6) {
54467
- const size2 = knownSize ?? fs57.statSync(filePath).size;
54626
+ const size2 = knownSize ?? fs59.statSync(filePath).size;
54468
54627
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
54469
54628
  await yieldToEventLoop();
54470
- const buffer = fs57.readFileSync(filePath);
54629
+ const buffer = fs59.readFileSync(filePath);
54471
54630
  return { buffer, size: buffer.length };
54472
54631
  }
54473
54632
  }
54474
- const size = knownSize ?? (await fs57.promises.stat(filePath)).size;
54475
- const fd = await fs57.promises.open(filePath, "r");
54633
+ const size = knownSize ?? (await fs59.promises.stat(filePath)).size;
54634
+ const fd = await fs59.promises.open(filePath, "r");
54476
54635
  const chunks = [];
54477
54636
  let position = 0;
54478
54637
  let bytesSinceYield = 0;
@@ -54575,7 +54734,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
54575
54734
  }
54576
54735
  if (hasRange) {
54577
54736
  if (fileSize == null) {
54578
- const stat3 = await fs58.promises.stat(resolvedPath);
54737
+ const stat3 = await fs60.promises.stat(resolvedPath);
54579
54738
  fileSize = stat3.size;
54580
54739
  }
54581
54740
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -54873,12 +55032,12 @@ function parseOptionalInt2(raw) {
54873
55032
  return Number.isInteger(parsed) ? parsed : void 0;
54874
55033
  }
54875
55034
  function parseCodeNavParams(url2) {
54876
- const path88 = url2.searchParams.get("path") ?? "";
55035
+ const path90 = url2.searchParams.get("path") ?? "";
54877
55036
  const opRaw = url2.searchParams.get("op")?.trim();
54878
55037
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
54879
55038
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
54880
55039
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
54881
- return { path: path88, op, line, column };
55040
+ return { path: path90, op, line, column };
54882
55041
  }
54883
55042
  function parseCodeNavPath(url2) {
54884
55043
  const raw = url2.searchParams.get("path")?.trim();
@@ -55676,18 +55835,18 @@ function hasRunningTurn(turns) {
55676
55835
  }
55677
55836
 
55678
55837
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
55679
- import fs61 from "node:fs";
55838
+ import fs63 from "node:fs";
55680
55839
 
55681
55840
  // src/git/snapshot/capture.ts
55682
- import * as fs60 from "node:fs";
55683
- import * as path81 from "node:path";
55841
+ import * as fs62 from "node:fs";
55842
+ import * as path83 from "node:path";
55684
55843
 
55685
55844
  // src/git/snapshot/apply-pre-turn-snapshot.ts
55686
- import * as fs59 from "node:fs";
55845
+ import * as fs61 from "node:fs";
55687
55846
  async function applyPreTurnSnapshot(filePath, log2) {
55688
55847
  let data;
55689
55848
  try {
55690
- data = JSON.parse(fs59.readFileSync(filePath, "utf8"));
55849
+ data = JSON.parse(fs61.readFileSync(filePath, "utf8"));
55691
55850
  } catch (error51) {
55692
55851
  return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
55693
55852
  }
@@ -55716,18 +55875,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
55716
55875
  }
55717
55876
 
55718
55877
  // src/git/snapshot/resolve-repo-roots.ts
55719
- import * as path80 from "node:path";
55878
+ import * as path82 from "node:path";
55720
55879
  async function resolveSnapshotRepoRoots(options) {
55721
55880
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
55722
55881
  if (worktreePaths?.length) {
55723
- const paths = [...new Set(worktreePaths.map((p) => path80.resolve(p)))];
55882
+ const paths = [...new Set(worktreePaths.map((p) => path82.resolve(p)))];
55724
55883
  return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
55725
55884
  }
55726
55885
  try {
55727
55886
  const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
55728
55887
  const sid = sessionId?.trim();
55729
55888
  if (!sid) return roots;
55730
- const sessionRoots = roots.filter((root) => path80.basename(root) === sid);
55889
+ const sessionRoots = roots.filter((root) => path82.basename(root) === sid);
55731
55890
  return sessionRoots.length > 0 ? sessionRoots : roots;
55732
55891
  } catch (error51) {
55733
55892
  log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -55749,7 +55908,7 @@ async function capturePreTurnSnapshot(options) {
55749
55908
  });
55750
55909
  const dir = snapshotsDirForCwd(agentCwd);
55751
55910
  try {
55752
- fs60.mkdirSync(dir, { recursive: true });
55911
+ fs62.mkdirSync(dir, { recursive: true });
55753
55912
  } catch (e) {
55754
55913
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
55755
55914
  }
@@ -55758,9 +55917,9 @@ async function capturePreTurnSnapshot(options) {
55758
55917
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
55759
55918
  repos
55760
55919
  };
55761
- const filePath = path81.join(dir, `${runId}.json`);
55920
+ const filePath = path83.join(dir, `${runId}.json`);
55762
55921
  try {
55763
- fs60.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
55922
+ fs62.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
55764
55923
  } catch (e) {
55765
55924
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
55766
55925
  }
@@ -55780,7 +55939,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
55780
55939
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
55781
55940
  const file2 = snapshotFilePath(agentBase, tid);
55782
55941
  try {
55783
- await fs61.promises.access(file2, fs61.constants.F_OK);
55942
+ await fs63.promises.access(file2, fs63.constants.F_OK);
55784
55943
  } catch {
55785
55944
  deps.log(
55786
55945
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -56431,6 +56590,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
56431
56590
  var handleSessionArchivedMessage = (msg, deps) => {
56432
56591
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
56433
56592
  if (!sessionId) return;
56593
+ cleanupSessionPlans(sessionId);
56434
56594
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
56435
56595
  };
56436
56596
 
@@ -56438,11 +56598,12 @@ var handleSessionArchivedMessage = (msg, deps) => {
56438
56598
  var handleSessionDiscardedMessage = (msg, deps) => {
56439
56599
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
56440
56600
  if (!sessionId) return;
56601
+ cleanupSessionPlans(sessionId);
56441
56602
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
56442
56603
  };
56443
56604
 
56444
56605
  // src/routing/handlers/revert-turn-snapshot.ts
56445
- import * as fs62 from "node:fs";
56606
+ import * as fs64 from "node:fs";
56446
56607
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
56447
56608
  const id = typeof msg.id === "string" ? msg.id : "";
56448
56609
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -56455,7 +56616,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
56455
56616
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
56456
56617
  const file2 = snapshotFilePath(agentBase, turnId);
56457
56618
  try {
56458
- await fs62.promises.access(file2, fs62.constants.F_OK);
56619
+ await fs64.promises.access(file2, fs64.constants.F_OK);
56459
56620
  } catch {
56460
56621
  sendWsMessage(s, {
56461
56622
  type: "revert_turn_snapshot_result",
@@ -56529,8 +56690,8 @@ function randomSecret() {
56529
56690
  }
56530
56691
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
56531
56692
  }
56532
- async function requestPreviewApi(port, secret, method, path88, body) {
56533
- const url2 = `http://127.0.0.1:${port}${path88}`;
56693
+ async function requestPreviewApi(port, secret, method, path90, body) {
56694
+ const url2 = `http://127.0.0.1:${port}${path90}`;
56534
56695
  const headers = {
56535
56696
  [PREVIEW_SECRET_HEADER]: secret,
56536
56697
  "Content-Type": "application/json"
@@ -56542,7 +56703,7 @@ async function requestPreviewApi(port, secret, method, path88, body) {
56542
56703
  });
56543
56704
  const data = await res.json().catch(() => ({}));
56544
56705
  if (!res.ok) {
56545
- throw new Error(data?.error ?? `Preview API ${method} ${path88}: ${res.status}`);
56706
+ throw new Error(data?.error ?? `Preview API ${method} ${path90}: ${res.status}`);
56546
56707
  }
56547
56708
  return data;
56548
56709
  }
@@ -56727,8 +56888,8 @@ function isValidRemoteSkillInstallItem(item) {
56727
56888
 
56728
56889
  // src/skills/install/install-remote-skills-async.ts
56729
56890
  init_yield_to_event_loop();
56730
- import fs63 from "node:fs";
56731
- import path82 from "node:path";
56891
+ import fs65 from "node:fs";
56892
+ import path84 from "node:path";
56732
56893
 
56733
56894
  // src/skills/install/constants.ts
56734
56895
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -56739,12 +56900,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
56739
56900
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
56740
56901
  await yieldToEventLoop();
56741
56902
  }
56742
- const dest = path82.join(skillDir, f.path);
56743
- await fs63.promises.mkdir(path82.dirname(dest), { recursive: true });
56903
+ const dest = path84.join(skillDir, f.path);
56904
+ await fs65.promises.mkdir(path84.dirname(dest), { recursive: true });
56744
56905
  if (f.text !== void 0) {
56745
- await fs63.promises.writeFile(dest, f.text, "utf8");
56906
+ await fs65.promises.writeFile(dest, f.text, "utf8");
56746
56907
  } else if (f.base64) {
56747
- await fs63.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
56908
+ await fs65.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
56748
56909
  }
56749
56910
  }
56750
56911
  async function installRemoteSkillsAsync(cwd, targetDir, items) {
@@ -56756,7 +56917,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
56756
56917
  try {
56757
56918
  for (const item of items) {
56758
56919
  if (!isValidRemoteSkillInstallItem(item)) continue;
56759
- const skillDir = path82.join(cwd, targetDir, item.skillName);
56920
+ const skillDir = path84.join(cwd, targetDir, item.skillName);
56760
56921
  for (const f of item.files) {
56761
56922
  await writeInstallFileAsync(skillDir, f, filesWritten);
56762
56923
  }
@@ -57119,13 +57280,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
57119
57280
 
57120
57281
  // src/files/handle-file-browser-search.ts
57121
57282
  init_yield_to_event_loop();
57122
- import path83 from "node:path";
57283
+ import path85 from "node:path";
57123
57284
  var SEARCH_LIMIT = 100;
57124
57285
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
57125
57286
  void (async () => {
57126
57287
  await yieldToEventLoop();
57127
57288
  const q = typeof msg.q === "string" ? msg.q : "";
57128
- const sessionParentPath = path83.resolve(
57289
+ const sessionParentPath = path85.resolve(
57129
57290
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
57130
57291
  );
57131
57292
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -57223,7 +57384,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
57223
57384
  }
57224
57385
 
57225
57386
  // src/git/bridge-git-context.ts
57226
- import * as path84 from "node:path";
57387
+ import * as path86 from "node:path";
57227
57388
  init_yield_to_event_loop();
57228
57389
 
57229
57390
  // src/git/branches/get-current-branch.ts
@@ -57291,12 +57452,12 @@ function listPendingCheckouts() {
57291
57452
  // src/git/bridge-git-context.ts
57292
57453
  function folderNameForRelPath(relPath, bridgeRoot) {
57293
57454
  if (relPath === "." || relPath === "") {
57294
- return path84.basename(path84.resolve(bridgeRoot)) || "repo";
57455
+ return path86.basename(path86.resolve(bridgeRoot)) || "repo";
57295
57456
  }
57296
- return path84.basename(relPath) || relPath;
57457
+ return path86.basename(relPath) || relPath;
57297
57458
  }
57298
57459
  async function discoverGitReposForBridgeContext(bridgeRoot) {
57299
- const root = path84.resolve(bridgeRoot);
57460
+ const root = path86.resolve(bridgeRoot);
57300
57461
  if (await isGitRepoDirectory(root)) {
57301
57462
  const remoteUrl = await getRemoteOriginUrl(root);
57302
57463
  return [{ absolutePath: root, remoteUrl }];
@@ -57304,19 +57465,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
57304
57465
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
57305
57466
  const byPath = /* @__PURE__ */ new Map();
57306
57467
  for (const repo of [...deep, ...shallow]) {
57307
- byPath.set(path84.resolve(repo.absolutePath), repo);
57468
+ byPath.set(path86.resolve(repo.absolutePath), repo);
57308
57469
  }
57309
57470
  return [...byPath.values()];
57310
57471
  }
57311
57472
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
57312
- const bridgeResolved = path84.resolve(bridgeRoot);
57473
+ const bridgeResolved = path86.resolve(bridgeRoot);
57313
57474
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
57314
57475
  const rows = [];
57315
57476
  for (let i = 0; i < repos.length; i++) {
57316
57477
  if (i > 0) await yieldToEventLoop();
57317
57478
  const repo = repos[i];
57318
- let rel = path84.relative(bridgeResolved, repo.absolutePath);
57319
- if (rel.startsWith("..") || path84.isAbsolute(rel)) continue;
57479
+ let rel = path86.relative(bridgeResolved, repo.absolutePath);
57480
+ if (rel.startsWith("..") || path86.isAbsolute(rel)) continue;
57320
57481
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
57321
57482
  const currentBranch = await getCurrentBranch(repo.absolutePath);
57322
57483
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -57347,11 +57508,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
57347
57508
  return rows;
57348
57509
  }
57349
57510
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
57350
- const bridgeResolved = path84.resolve(bridgeRoot);
57511
+ const bridgeResolved = path86.resolve(bridgeRoot);
57351
57512
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
57352
- const repoPath = rel === "" ? bridgeResolved : path84.join(bridgeResolved, rel);
57353
- const resolved = path84.resolve(repoPath);
57354
- if (!resolved.startsWith(bridgeResolved + path84.sep) && resolved !== bridgeResolved) {
57513
+ const repoPath = rel === "" ? bridgeResolved : path86.join(bridgeResolved, rel);
57514
+ const resolved = path86.resolve(repoPath);
57515
+ if (!resolved.startsWith(bridgeResolved + path86.sep) && resolved !== bridgeResolved) {
57355
57516
  return [];
57356
57517
  }
57357
57518
  return listRepoBranchRefs(resolved);
@@ -57401,8 +57562,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
57401
57562
  }
57402
57563
 
57403
57564
  // src/git/checkout/bridge-git-checkout.ts
57404
- import * as fs65 from "node:fs/promises";
57405
- import * as path86 from "node:path";
57565
+ import * as fs67 from "node:fs/promises";
57566
+ import * as path88 from "node:path";
57406
57567
 
57407
57568
  // src/git/checkout/normalize-clone-url.ts
57408
57569
  function normalizeCloneUrl(url2) {
@@ -57422,12 +57583,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
57422
57583
  }
57423
57584
 
57424
57585
  // src/git/checkout/resolve-checkout-target.ts
57425
- import * as fs64 from "node:fs/promises";
57426
- import * as path85 from "node:path";
57586
+ import * as fs66 from "node:fs/promises";
57587
+ import * as path87 from "node:path";
57427
57588
  var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
57428
57589
  async function pathExists(p) {
57429
57590
  try {
57430
- await fs64.access(p);
57591
+ await fs66.access(p);
57431
57592
  return true;
57432
57593
  } catch {
57433
57594
  return false;
@@ -57439,7 +57600,7 @@ async function resolveCheckoutTarget(opts) {
57439
57600
  if (await isGitRepoDirectory(bridgeRoot)) {
57440
57601
  throw new Error("Bridge root is already a git repository");
57441
57602
  }
57442
- const entries = await fs64.readdir(bridgeRoot).catch(() => []);
57603
+ const entries = await fs66.readdir(bridgeRoot).catch(() => []);
57443
57604
  if (entries.length > 0) {
57444
57605
  throw new Error("Bridge root must be empty to initialize a monorepo checkout");
57445
57606
  }
@@ -57452,8 +57613,8 @@ async function resolveCheckoutTarget(opts) {
57452
57613
  if (await isGitRepoDirectory(bridgeRoot)) {
57453
57614
  throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
57454
57615
  }
57455
- const targetDir = path85.resolve(bridgeRoot, folder);
57456
- if (!targetDir.startsWith(bridgeRoot + path85.sep)) {
57616
+ const targetDir = path87.resolve(bridgeRoot, folder);
57617
+ if (!targetDir.startsWith(bridgeRoot + path87.sep)) {
57457
57618
  throw new Error("Invalid folderName");
57458
57619
  }
57459
57620
  if (await pathExists(targetDir)) {
@@ -57472,10 +57633,10 @@ async function bridgeGitCheckout(params) {
57472
57633
  });
57473
57634
  const folderName = relPath === "." ? "repo" : relPath;
57474
57635
  beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
57475
- const parent = path86.dirname(targetDir);
57476
- await fs65.mkdir(parent, { recursive: true });
57636
+ const parent = path88.dirname(targetDir);
57637
+ await fs67.mkdir(parent, { recursive: true });
57477
57638
  if (relPath !== ".") {
57478
- await fs65.mkdir(targetDir, { recursive: true });
57639
+ await fs67.mkdir(targetDir, { recursive: true });
57479
57640
  }
57480
57641
  const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
57481
57642
  try {
@@ -57486,7 +57647,7 @@ async function bridgeGitCheckout(params) {
57486
57647
  return { relPath, folderName };
57487
57648
  } catch (e) {
57488
57649
  if (relPath !== ".") {
57489
- await fs65.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
57650
+ await fs67.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
57490
57651
  }
57491
57652
  const msg = e instanceof Error ? e.message : String(e);
57492
57653
  throw new Error(
@@ -58220,9 +58381,9 @@ async function runCliAction(program2, opts) {
58220
58381
  const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
58221
58382
  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);
58222
58383
  if (bridgeRootOpt) {
58223
- const resolvedBridgeRoot = path87.resolve(process.cwd(), bridgeRootOpt);
58384
+ const resolvedBridgeRoot = path89.resolve(process.cwd(), bridgeRootOpt);
58224
58385
  try {
58225
- const st = fs66.statSync(resolvedBridgeRoot);
58386
+ const st = fs68.statSync(resolvedBridgeRoot);
58226
58387
  if (!st.isDirectory()) {
58227
58388
  console.error(`Bridge root is not a directory: ${resolvedBridgeRoot}`);
58228
58389
  process.exit(1);
@@ -58242,7 +58403,7 @@ async function runCliAction(program2, opts) {
58242
58403
  );
58243
58404
  let worktreesRootPath;
58244
58405
  if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
58245
- worktreesRootPath = path87.resolve(opts.worktreesRoot.trim());
58406
+ worktreesRootPath = path89.resolve(opts.worktreesRoot.trim());
58246
58407
  }
58247
58408
  const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
58248
58409
  if (e2eCertificates) {