@buildautomaton/cli 0.1.74 → 0.1.75

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/index.js CHANGED
@@ -4208,8 +4208,8 @@ var init_parseUtil = __esm({
4208
4208
  init_errors();
4209
4209
  init_en();
4210
4210
  makeIssue = (params) => {
4211
- const { data, path: path82, errorMaps, issueData } = params;
4212
- const fullPath = [...path82, ...issueData.path || []];
4211
+ const { data, path: path84, errorMaps, issueData } = params;
4212
+ const fullPath = [...path84, ...issueData.path || []];
4213
4213
  const fullIssue = {
4214
4214
  ...issueData,
4215
4215
  path: fullPath
@@ -4517,11 +4517,11 @@ var init_types = __esm({
4517
4517
  init_parseUtil();
4518
4518
  init_util();
4519
4519
  ParseInputLazyPath = class {
4520
- constructor(parent, value, path82, key) {
4520
+ constructor(parent, value, path84, key) {
4521
4521
  this._cachedPath = [];
4522
4522
  this.parent = parent;
4523
4523
  this.data = value;
4524
- this._path = path82;
4524
+ this._path = path84;
4525
4525
  this._key = key;
4526
4526
  }
4527
4527
  get path() {
@@ -8182,15 +8182,15 @@ function assignProp(target, prop, value) {
8182
8182
  configurable: true
8183
8183
  });
8184
8184
  }
8185
- function getElementAtPath(obj, path82) {
8186
- if (!path82)
8185
+ function getElementAtPath(obj, path84) {
8186
+ if (!path84)
8187
8187
  return obj;
8188
- return path82.reduce((acc, key) => acc?.[key], obj);
8188
+ return path84.reduce((acc, key) => acc?.[key], obj);
8189
8189
  }
8190
8190
  function promiseAllObject(promisesObj) {
8191
8191
  const keys = Object.keys(promisesObj);
8192
- const promises12 = keys.map((key) => promisesObj[key]);
8193
- return Promise.all(promises12).then((results) => {
8192
+ const promises13 = keys.map((key) => promisesObj[key]);
8193
+ return Promise.all(promises13).then((results) => {
8194
8194
  const resolvedObj = {};
8195
8195
  for (let i = 0; i < keys.length; i++) {
8196
8196
  resolvedObj[keys[i]] = results[i];
@@ -8434,11 +8434,11 @@ function aborted(x, startIndex = 0) {
8434
8434
  }
8435
8435
  return false;
8436
8436
  }
8437
- function prefixIssues(path82, issues) {
8437
+ function prefixIssues(path84, issues) {
8438
8438
  return issues.map((iss) => {
8439
8439
  var _a2;
8440
8440
  (_a2 = iss).path ?? (_a2.path = []);
8441
- iss.path.unshift(path82);
8441
+ iss.path.unshift(path84);
8442
8442
  return iss;
8443
8443
  });
8444
8444
  }
@@ -8627,7 +8627,7 @@ function treeifyError(error40, _mapper) {
8627
8627
  return issue2.message;
8628
8628
  };
8629
8629
  const result = { errors: [] };
8630
- const processError = (error41, path82 = []) => {
8630
+ const processError = (error41, path84 = []) => {
8631
8631
  var _a2, _b;
8632
8632
  for (const issue2 of error41.issues) {
8633
8633
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -8637,7 +8637,7 @@ function treeifyError(error40, _mapper) {
8637
8637
  } else if (issue2.code === "invalid_element") {
8638
8638
  processError({ issues: issue2.issues }, issue2.path);
8639
8639
  } else {
8640
- const fullpath = [...path82, ...issue2.path];
8640
+ const fullpath = [...path84, ...issue2.path];
8641
8641
  if (fullpath.length === 0) {
8642
8642
  result.errors.push(mapper(issue2));
8643
8643
  continue;
@@ -8667,9 +8667,9 @@ function treeifyError(error40, _mapper) {
8667
8667
  processError(error40);
8668
8668
  return result;
8669
8669
  }
8670
- function toDotPath(path82) {
8670
+ function toDotPath(path84) {
8671
8671
  const segs = [];
8672
- for (const seg of path82) {
8672
+ for (const seg of path84) {
8673
8673
  if (typeof seg === "number")
8674
8674
  segs.push(`[${seg}]`);
8675
8675
  else if (typeof seg === "symbol")
@@ -22376,7 +22376,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
22376
22376
  join2(moduleDir, "..", sub, filename),
22377
22377
  join2(moduleDir, "..", "..", "dist", sub, filename)
22378
22378
  ]);
22379
- const resolved = candidates.find((path82) => existsSync(path82));
22379
+ const resolved = candidates.find((path84) => existsSync(path84));
22380
22380
  if (!resolved) {
22381
22381
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
22382
22382
  }
@@ -23447,7 +23447,7 @@ var require_ignore = __commonJS({
23447
23447
  // path matching.
23448
23448
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
23449
23449
  // @returns {TestResult} true if a file is ignored
23450
- test(path82, checkUnignored, mode) {
23450
+ test(path84, checkUnignored, mode) {
23451
23451
  let ignored = false;
23452
23452
  let unignored = false;
23453
23453
  let matchedRule;
@@ -23456,7 +23456,7 @@ var require_ignore = __commonJS({
23456
23456
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
23457
23457
  return;
23458
23458
  }
23459
- const matched = rule[mode].test(path82);
23459
+ const matched = rule[mode].test(path84);
23460
23460
  if (!matched) {
23461
23461
  return;
23462
23462
  }
@@ -23477,17 +23477,17 @@ var require_ignore = __commonJS({
23477
23477
  var throwError = (message, Ctor) => {
23478
23478
  throw new Ctor(message);
23479
23479
  };
23480
- var checkPath = (path82, originalPath, doThrow) => {
23481
- if (!isString(path82)) {
23480
+ var checkPath = (path84, originalPath, doThrow) => {
23481
+ if (!isString(path84)) {
23482
23482
  return doThrow(
23483
23483
  `path must be a string, but got \`${originalPath}\``,
23484
23484
  TypeError
23485
23485
  );
23486
23486
  }
23487
- if (!path82) {
23487
+ if (!path84) {
23488
23488
  return doThrow(`path must not be empty`, TypeError);
23489
23489
  }
23490
- if (checkPath.isNotRelative(path82)) {
23490
+ if (checkPath.isNotRelative(path84)) {
23491
23491
  const r = "`path.relative()`d";
23492
23492
  return doThrow(
23493
23493
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -23496,7 +23496,7 @@ var require_ignore = __commonJS({
23496
23496
  }
23497
23497
  return true;
23498
23498
  };
23499
- var isNotRelative = (path82) => REGEX_TEST_INVALID_PATH.test(path82);
23499
+ var isNotRelative = (path84) => REGEX_TEST_INVALID_PATH.test(path84);
23500
23500
  checkPath.isNotRelative = isNotRelative;
23501
23501
  checkPath.convert = (p) => p;
23502
23502
  var Ignore = class {
@@ -23526,19 +23526,19 @@ var require_ignore = __commonJS({
23526
23526
  }
23527
23527
  // @returns {TestResult}
23528
23528
  _test(originalPath, cache2, checkUnignored, slices) {
23529
- const path82 = originalPath && checkPath.convert(originalPath);
23529
+ const path84 = originalPath && checkPath.convert(originalPath);
23530
23530
  checkPath(
23531
- path82,
23531
+ path84,
23532
23532
  originalPath,
23533
23533
  this._strictPathCheck ? throwError : RETURN_FALSE
23534
23534
  );
23535
- return this._t(path82, cache2, checkUnignored, slices);
23535
+ return this._t(path84, cache2, checkUnignored, slices);
23536
23536
  }
23537
- checkIgnore(path82) {
23538
- if (!REGEX_TEST_TRAILING_SLASH.test(path82)) {
23539
- return this.test(path82);
23537
+ checkIgnore(path84) {
23538
+ if (!REGEX_TEST_TRAILING_SLASH.test(path84)) {
23539
+ return this.test(path84);
23540
23540
  }
23541
- const slices = path82.split(SLASH).filter(Boolean);
23541
+ const slices = path84.split(SLASH).filter(Boolean);
23542
23542
  slices.pop();
23543
23543
  if (slices.length) {
23544
23544
  const parent = this._t(
@@ -23551,18 +23551,18 @@ var require_ignore = __commonJS({
23551
23551
  return parent;
23552
23552
  }
23553
23553
  }
23554
- return this._rules.test(path82, false, MODE_CHECK_IGNORE);
23554
+ return this._rules.test(path84, false, MODE_CHECK_IGNORE);
23555
23555
  }
23556
- _t(path82, cache2, checkUnignored, slices) {
23557
- if (path82 in cache2) {
23558
- return cache2[path82];
23556
+ _t(path84, cache2, checkUnignored, slices) {
23557
+ if (path84 in cache2) {
23558
+ return cache2[path84];
23559
23559
  }
23560
23560
  if (!slices) {
23561
- slices = path82.split(SLASH).filter(Boolean);
23561
+ slices = path84.split(SLASH).filter(Boolean);
23562
23562
  }
23563
23563
  slices.pop();
23564
23564
  if (!slices.length) {
23565
- return cache2[path82] = this._rules.test(path82, checkUnignored, MODE_IGNORE);
23565
+ return cache2[path84] = this._rules.test(path84, checkUnignored, MODE_IGNORE);
23566
23566
  }
23567
23567
  const parent = this._t(
23568
23568
  slices.join(SLASH) + SLASH,
@@ -23570,29 +23570,29 @@ var require_ignore = __commonJS({
23570
23570
  checkUnignored,
23571
23571
  slices
23572
23572
  );
23573
- return cache2[path82] = parent.ignored ? parent : this._rules.test(path82, checkUnignored, MODE_IGNORE);
23573
+ return cache2[path84] = parent.ignored ? parent : this._rules.test(path84, checkUnignored, MODE_IGNORE);
23574
23574
  }
23575
- ignores(path82) {
23576
- return this._test(path82, this._ignoreCache, false).ignored;
23575
+ ignores(path84) {
23576
+ return this._test(path84, this._ignoreCache, false).ignored;
23577
23577
  }
23578
23578
  createFilter() {
23579
- return (path82) => !this.ignores(path82);
23579
+ return (path84) => !this.ignores(path84);
23580
23580
  }
23581
23581
  filter(paths) {
23582
23582
  return makeArray(paths).filter(this.createFilter());
23583
23583
  }
23584
23584
  // @returns {TestResult}
23585
- test(path82) {
23586
- return this._test(path82, this._testCache, true);
23585
+ test(path84) {
23586
+ return this._test(path84, this._testCache, true);
23587
23587
  }
23588
23588
  };
23589
23589
  var factory = (options) => new Ignore(options);
23590
- var isPathValid = (path82) => checkPath(path82 && checkPath.convert(path82), path82, RETURN_FALSE);
23590
+ var isPathValid = (path84) => checkPath(path84 && checkPath.convert(path84), path84, RETURN_FALSE);
23591
23591
  var setupWindows = () => {
23592
23592
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
23593
23593
  checkPath.convert = makePosix;
23594
23594
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
23595
- checkPath.isNotRelative = (path82) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path82) || isNotRelative(path82);
23595
+ checkPath.isNotRelative = (path84) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path84) || isNotRelative(path84);
23596
23596
  };
23597
23597
  if (
23598
23598
  // Detect `process` so that it can run in browsers.
@@ -27960,10 +27960,10 @@ var require_src2 = __commonJS({
27960
27960
  var fs_1 = __require("fs");
27961
27961
  var debug_1 = __importDefault(require_src());
27962
27962
  var log2 = debug_1.default("@kwsites/file-exists");
27963
- function check2(path82, isFile, isDirectory) {
27964
- log2(`checking %s`, path82);
27963
+ function check2(path84, isFile, isDirectory) {
27964
+ log2(`checking %s`, path84);
27965
27965
  try {
27966
- const stat2 = fs_1.statSync(path82);
27966
+ const stat2 = fs_1.statSync(path84);
27967
27967
  if (stat2.isFile() && isFile) {
27968
27968
  log2(`[OK] path represents a file`);
27969
27969
  return true;
@@ -27983,8 +27983,8 @@ var require_src2 = __commonJS({
27983
27983
  throw e;
27984
27984
  }
27985
27985
  }
27986
- function exists2(path82, type = exports.READABLE) {
27987
- return check2(path82, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27986
+ function exists2(path84, type = exports.READABLE) {
27987
+ return check2(path84, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27988
27988
  }
27989
27989
  exports.exists = exists2;
27990
27990
  exports.FILE = 1;
@@ -30370,8 +30370,8 @@ function randomSecret() {
30370
30370
  }
30371
30371
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
30372
30372
  }
30373
- async function requestPreviewApi(port, secret, method, path82, body) {
30374
- const url2 = `http://127.0.0.1:${port}${path82}`;
30373
+ async function requestPreviewApi(port, secret, method, path84, body) {
30374
+ const url2 = `http://127.0.0.1:${port}${path84}`;
30375
30375
  const headers = {
30376
30376
  [PREVIEW_SECRET_HEADER]: secret,
30377
30377
  "Content-Type": "application/json"
@@ -30383,7 +30383,7 @@ async function requestPreviewApi(port, secret, method, path82, body) {
30383
30383
  });
30384
30384
  const data = await res.json().catch(() => ({}));
30385
30385
  if (!res.ok) {
30386
- throw new Error(data?.error ?? `Preview API ${method} ${path82}: ${res.status}`);
30386
+ throw new Error(data?.error ?? `Preview API ${method} ${path84}: ${res.status}`);
30387
30387
  }
30388
30388
  return data;
30389
30389
  }
@@ -30606,7 +30606,7 @@ function installBridgeProcessResilience() {
30606
30606
  }
30607
30607
 
30608
30608
  // src/cli-version.ts
30609
- var CLI_VERSION = "0.1.74".length > 0 ? "0.1.74" : "0.0.0-dev";
30609
+ var CLI_VERSION = "0.1.75".length > 0 ? "0.1.75" : "0.0.0-dev";
30610
30610
 
30611
30611
  // src/connection/heartbeat/constants.ts
30612
30612
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -35084,8 +35084,8 @@ async function execGitFile(args, options) {
35084
35084
  }
35085
35085
 
35086
35086
  // src/git/changes/parse/normalize-git-diff-path.ts
35087
- function normalizeGitDiffPath(path82) {
35088
- return path82.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35087
+ function normalizeGitDiffPath(path84) {
35088
+ return path84.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35089
35089
  }
35090
35090
 
35091
35091
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -39314,8 +39314,8 @@ function pathspec(...paths) {
39314
39314
  cache.set(key, paths);
39315
39315
  return key;
39316
39316
  }
39317
- function isPathSpec(path82) {
39318
- return path82 instanceof String && cache.has(path82);
39317
+ function isPathSpec(path84) {
39318
+ return path84 instanceof String && cache.has(path84);
39319
39319
  }
39320
39320
  function toPaths(pathSpec) {
39321
39321
  return cache.get(pathSpec) || [];
@@ -39404,8 +39404,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
39404
39404
  function forEachLineWithContent(input, callback) {
39405
39405
  return toLinesWithContent(input, true).map((line) => callback(line));
39406
39406
  }
39407
- function folderExists(path82) {
39408
- return (0, import_file_exists.exists)(path82, import_file_exists.FOLDER);
39407
+ function folderExists(path84) {
39408
+ return (0, import_file_exists.exists)(path84, import_file_exists.FOLDER);
39409
39409
  }
39410
39410
  function append(target, item) {
39411
39411
  if (Array.isArray(target)) {
@@ -39809,8 +39809,8 @@ function checkIsRepoRootTask() {
39809
39809
  commands,
39810
39810
  format: "utf-8",
39811
39811
  onError,
39812
- parser(path82) {
39813
- return /^\.(git)?$/.test(path82.trim());
39812
+ parser(path84) {
39813
+ return /^\.(git)?$/.test(path84.trim());
39814
39814
  }
39815
39815
  };
39816
39816
  }
@@ -40244,11 +40244,11 @@ function parseGrep(grep) {
40244
40244
  const paths = /* @__PURE__ */ new Set();
40245
40245
  const results = {};
40246
40246
  forEachLineWithContent(grep, (input) => {
40247
- const [path82, line, preview] = input.split(NULL);
40248
- paths.add(path82);
40249
- (results[path82] = results[path82] || []).push({
40247
+ const [path84, line, preview] = input.split(NULL);
40248
+ paths.add(path84);
40249
+ (results[path84] = results[path84] || []).push({
40250
40250
  line: asNumber(line),
40251
- path: path82,
40251
+ path: path84,
40252
40252
  preview
40253
40253
  });
40254
40254
  });
@@ -41013,14 +41013,14 @@ var init_hash_object = __esm2({
41013
41013
  init_task();
41014
41014
  }
41015
41015
  });
41016
- function parseInit(bare, path82, text) {
41016
+ function parseInit(bare, path84, text) {
41017
41017
  const response = String(text).trim();
41018
41018
  let result;
41019
41019
  if (result = initResponseRegex.exec(response)) {
41020
- return new InitSummary(bare, path82, false, result[1]);
41020
+ return new InitSummary(bare, path84, false, result[1]);
41021
41021
  }
41022
41022
  if (result = reInitResponseRegex.exec(response)) {
41023
- return new InitSummary(bare, path82, true, result[1]);
41023
+ return new InitSummary(bare, path84, true, result[1]);
41024
41024
  }
41025
41025
  let gitDir = "";
41026
41026
  const tokens = response.split(" ");
@@ -41031,7 +41031,7 @@ function parseInit(bare, path82, text) {
41031
41031
  break;
41032
41032
  }
41033
41033
  }
41034
- return new InitSummary(bare, path82, /^re/i.test(response), gitDir);
41034
+ return new InitSummary(bare, path84, /^re/i.test(response), gitDir);
41035
41035
  }
41036
41036
  var InitSummary;
41037
41037
  var initResponseRegex;
@@ -41040,9 +41040,9 @@ var init_InitSummary = __esm2({
41040
41040
  "src/lib/responses/InitSummary.ts"() {
41041
41041
  "use strict";
41042
41042
  InitSummary = class {
41043
- constructor(bare, path82, existing, gitDir) {
41043
+ constructor(bare, path84, existing, gitDir) {
41044
41044
  this.bare = bare;
41045
- this.path = path82;
41045
+ this.path = path84;
41046
41046
  this.existing = existing;
41047
41047
  this.gitDir = gitDir;
41048
41048
  }
@@ -41054,7 +41054,7 @@ var init_InitSummary = __esm2({
41054
41054
  function hasBareCommand(command) {
41055
41055
  return command.includes(bareCommand);
41056
41056
  }
41057
- function initTask(bare = false, path82, customArgs) {
41057
+ function initTask(bare = false, path84, customArgs) {
41058
41058
  const commands = ["init", ...customArgs];
41059
41059
  if (bare && !hasBareCommand(commands)) {
41060
41060
  commands.splice(1, 0, bareCommand);
@@ -41063,7 +41063,7 @@ function initTask(bare = false, path82, customArgs) {
41063
41063
  commands,
41064
41064
  format: "utf-8",
41065
41065
  parser(text) {
41066
- return parseInit(commands.includes("--bare"), path82, text);
41066
+ return parseInit(commands.includes("--bare"), path84, text);
41067
41067
  }
41068
41068
  };
41069
41069
  }
@@ -41879,12 +41879,12 @@ var init_FileStatusSummary = __esm2({
41879
41879
  "use strict";
41880
41880
  fromPathRegex = /^(.+)\0(.+)$/;
41881
41881
  FileStatusSummary = class {
41882
- constructor(path82, index, working_dir) {
41883
- this.path = path82;
41882
+ constructor(path84, index, working_dir) {
41883
+ this.path = path84;
41884
41884
  this.index = index;
41885
41885
  this.working_dir = working_dir;
41886
41886
  if (index === "R" || working_dir === "R") {
41887
- const detail = fromPathRegex.exec(path82) || [null, path82, path82];
41887
+ const detail = fromPathRegex.exec(path84) || [null, path84, path84];
41888
41888
  this.from = detail[2] || "";
41889
41889
  this.path = detail[1] || "";
41890
41890
  }
@@ -41915,14 +41915,14 @@ function splitLine(result, lineStr) {
41915
41915
  default:
41916
41916
  return;
41917
41917
  }
41918
- function data(index, workingDir, path82) {
41918
+ function data(index, workingDir, path84) {
41919
41919
  const raw = `${index}${workingDir}`;
41920
41920
  const handler = parsers6.get(raw);
41921
41921
  if (handler) {
41922
- handler(result, path82);
41922
+ handler(result, path84);
41923
41923
  }
41924
41924
  if (raw !== "##" && raw !== "!!") {
41925
- result.files.push(new FileStatusSummary(path82, index, workingDir));
41925
+ result.files.push(new FileStatusSummary(path84, index, workingDir));
41926
41926
  }
41927
41927
  }
41928
41928
  }
@@ -42231,9 +42231,9 @@ var init_simple_git_api = __esm2({
42231
42231
  next
42232
42232
  );
42233
42233
  }
42234
- hashObject(path82, write) {
42234
+ hashObject(path84, write) {
42235
42235
  return this._runTask(
42236
- hashObjectTask(path82, write === true),
42236
+ hashObjectTask(path84, write === true),
42237
42237
  trailingFunctionArgument(arguments)
42238
42238
  );
42239
42239
  }
@@ -42586,8 +42586,8 @@ var init_branch = __esm2({
42586
42586
  }
42587
42587
  });
42588
42588
  function toPath(input) {
42589
- const path82 = input.trim().replace(/^["']|["']$/g, "");
42590
- return path82 && normalize3(path82);
42589
+ const path84 = input.trim().replace(/^["']|["']$/g, "");
42590
+ return path84 && normalize3(path84);
42591
42591
  }
42592
42592
  var parseCheckIgnore;
42593
42593
  var init_CheckIgnore = __esm2({
@@ -42901,8 +42901,8 @@ __export2(sub_module_exports, {
42901
42901
  subModuleTask: () => subModuleTask,
42902
42902
  updateSubModuleTask: () => updateSubModuleTask
42903
42903
  });
42904
- function addSubModuleTask(repo, path82) {
42905
- return subModuleTask(["add", repo, path82]);
42904
+ function addSubModuleTask(repo, path84) {
42905
+ return subModuleTask(["add", repo, path84]);
42906
42906
  }
42907
42907
  function initSubModuleTask(customArgs) {
42908
42908
  return subModuleTask(["init", ...customArgs]);
@@ -43235,8 +43235,8 @@ var require_git = __commonJS2({
43235
43235
  }
43236
43236
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
43237
43237
  };
43238
- Git2.prototype.submoduleAdd = function(repo, path82, then) {
43239
- return this._runTask(addSubModuleTask2(repo, path82), trailingFunctionArgument2(arguments));
43238
+ Git2.prototype.submoduleAdd = function(repo, path84, then) {
43239
+ return this._runTask(addSubModuleTask2(repo, path84), trailingFunctionArgument2(arguments));
43240
43240
  };
43241
43241
  Git2.prototype.submoduleUpdate = function(args, then) {
43242
43242
  return this._runTask(
@@ -43975,8 +43975,8 @@ function parseNumstatEntries(lines) {
43975
43975
  }
43976
43976
  function parseNumstat(lines) {
43977
43977
  const m = /* @__PURE__ */ new Map();
43978
- for (const [path82, entry] of parseNumstatEntries(lines)) {
43979
- m.set(path82, { additions: entry.additions, deletions: entry.deletions });
43978
+ for (const [path84, entry] of parseNumstatEntries(lines)) {
43979
+ m.set(path84, { additions: entry.additions, deletions: entry.deletions });
43980
43980
  }
43981
43981
  return m;
43982
43982
  }
@@ -44259,23 +44259,26 @@ function formatRemoteDisplayLabel(remoteUrl) {
44259
44259
  }
44260
44260
 
44261
44261
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
44262
- import * as path51 from "node:path";
44262
+ import * as path52 from "node:path";
44263
44263
 
44264
44264
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
44265
- import * as path50 from "node:path";
44265
+ import * as path51 from "node:path";
44266
44266
 
44267
44267
  // src/git/is-git-repo.ts
44268
+ import * as fs32 from "node:fs";
44269
+ import * as path43 from "node:path";
44268
44270
  async function isGitRepoDirectory(dirPath) {
44269
44271
  try {
44270
- return await cliSimpleGit(dirPath).checkIsRepo();
44272
+ await fs32.promises.access(path43.join(dirPath, ".git"));
44273
+ return true;
44271
44274
  } catch {
44272
44275
  return false;
44273
44276
  }
44274
44277
  }
44275
44278
 
44276
44279
  // src/git/changes/listing/apply-untracked-file-stats.ts
44277
- import * as fs32 from "node:fs";
44278
- import * as path43 from "node:path";
44280
+ import * as fs33 from "node:fs";
44281
+ import * as path44 from "node:path";
44279
44282
 
44280
44283
  // src/git/changes/lines/count-lines.ts
44281
44284
  import { createReadStream } from "node:fs";
@@ -44307,7 +44310,7 @@ function createUntrackedStatsApplier(options) {
44307
44310
  if (!options.untrackedSet.has(pathInRepo)) return;
44308
44311
  if (options.nameByPath.has(pathInRepo)) return;
44309
44312
  if (row.change === "moved") return;
44310
- const repoFilePath = path43.join(options.repoGitCwd, pathInRepo);
44313
+ const repoFilePath = path44.join(options.repoGitCwd, pathInRepo);
44311
44314
  const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
44312
44315
  if (fromGit) {
44313
44316
  row.additions = fromGit.additions;
@@ -44315,7 +44318,7 @@ function createUntrackedStatsApplier(options) {
44315
44318
  return;
44316
44319
  }
44317
44320
  try {
44318
- const st = await fs32.promises.stat(repoFilePath);
44321
+ const st = await fs33.promises.stat(repoFilePath);
44319
44322
  row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
44320
44323
  } catch {
44321
44324
  row.additions = 0;
@@ -44392,7 +44395,7 @@ async function buildChangedFileRowsFromPaths(options) {
44392
44395
  }
44393
44396
 
44394
44397
  // src/git/changes/listing/enrich-working-tree-file-rows.ts
44395
- import * as path45 from "node:path";
44398
+ import * as path46 from "node:path";
44396
44399
 
44397
44400
  // src/git/changes/patch/patch-truncate.ts
44398
44401
  function truncatePatch(s) {
@@ -44480,10 +44483,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
44480
44483
  }
44481
44484
 
44482
44485
  // src/git/changes/patch/hydrate/read-worktree-file-lines.ts
44483
- import * as fs33 from "node:fs";
44486
+ import * as fs34 from "node:fs";
44484
44487
  async function readWorktreeFileLines(filePath) {
44485
44488
  try {
44486
- const raw = await fs33.promises.readFile(filePath, "utf8");
44489
+ const raw = await fs34.promises.readFile(filePath, "utf8");
44487
44490
  return raw.split(/\r?\n/);
44488
44491
  } catch {
44489
44492
  return null;
@@ -44621,8 +44624,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
44621
44624
  }
44622
44625
 
44623
44626
  // src/git/changes/total-lines/resolve-changed-file-total-lines.ts
44624
- import * as fs34 from "node:fs";
44625
- import * as path44 from "node:path";
44627
+ import * as fs35 from "node:fs";
44628
+ import * as path45 from "node:path";
44626
44629
  var MAX_BYTES = 512e3;
44627
44630
  async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
44628
44631
  const spec = `${ref}:${pathInRepo}`;
@@ -44642,13 +44645,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
44642
44645
  }
44643
44646
  async function resolveWorkingTreeFileTotalLines(options) {
44644
44647
  if (options.isBinary) return null;
44645
- const filePath = path44.join(options.repoGitCwd, options.pathInRepo);
44648
+ const filePath = path45.join(options.repoGitCwd, options.pathInRepo);
44646
44649
  if (options.change === "removed") {
44647
44650
  return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
44648
44651
  }
44649
44652
  if (options.change === "moved" || options.change === "modified") {
44650
44653
  try {
44651
- const st = await fs34.promises.stat(filePath);
44654
+ const st = await fs35.promises.stat(filePath);
44652
44655
  if (!st.isFile()) return null;
44653
44656
  return await countTextFileLines(filePath);
44654
44657
  } catch {
@@ -44691,7 +44694,7 @@ async function enrichWorkingTreeFileRows(options) {
44691
44694
  row.workspaceRelPath,
44692
44695
  options.repoPathRelativeToWorkspaceRoot
44693
44696
  );
44694
- const filePath = path45.join(options.repoGitCwd, filePathRelativeToRepoRoot);
44697
+ const filePath = path46.join(options.repoGitCwd, filePathRelativeToRepoRoot);
44695
44698
  const hydrateKind = row.change === "moved" ? "modified" : row.change;
44696
44699
  let patch = await unifiedDiffForFile(
44697
44700
  options.repoGitCwd,
@@ -44849,7 +44852,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
44849
44852
  }
44850
44853
 
44851
44854
  // src/git/changes/listing/list-changed-files-for-commit.ts
44852
- import * as path46 from "node:path";
44855
+ import * as path47 from "node:path";
44853
44856
 
44854
44857
  // src/git/changes/listing/enrich-commit-file-rows.ts
44855
44858
  async function enrichCommitFileRows(options) {
@@ -44894,7 +44897,7 @@ async function parentForCommitDiff(g, sha) {
44894
44897
  var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
44895
44898
  var commitFilesCache = /* @__PURE__ */ new Map();
44896
44899
  function commitFilesCacheKey(repoGitCwd, commitSha) {
44897
- return `${path46.resolve(repoGitCwd)}:${commitSha}`;
44900
+ return `${path47.resolve(repoGitCwd)}:${commitSha}`;
44898
44901
  }
44899
44902
  async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
44900
44903
  const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
@@ -44949,7 +44952,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
44949
44952
  }
44950
44953
 
44951
44954
  // src/git/commits/list-unpushed-commits.ts
44952
- import * as path47 from "node:path";
44955
+ import * as path48 from "node:path";
44953
44956
 
44954
44957
  // src/git/commits/lib/parse-log-lines.ts
44955
44958
  function parseLogShaDateSubjectLines(raw) {
@@ -44984,7 +44987,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
44984
44987
  }
44985
44988
  }
44986
44989
  async function listUnpushedCommits(repoDir) {
44987
- const key = path47.resolve(repoDir);
44990
+ const key = path48.resolve(repoDir);
44988
44991
  const now = Date.now();
44989
44992
  const cached2 = unpushedCache.get(key);
44990
44993
  if (cached2 && cached2.expiresAt > now) return cached2.commits;
@@ -45045,7 +45048,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
45045
45048
  }
45046
45049
 
45047
45050
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
45048
- import * as path48 from "node:path";
45051
+ import * as path49 from "node:path";
45049
45052
 
45050
45053
  // src/git/remote-origin-url.ts
45051
45054
  async function getRemoteOriginUrl(gitDir) {
@@ -45060,7 +45063,7 @@ async function getRemoteOriginUrl(gitDir) {
45060
45063
 
45061
45064
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
45062
45065
  async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
45063
- const resolvedCheckoutPath = path48.resolve(checkoutPath);
45066
+ const resolvedCheckoutPath = path49.resolve(checkoutPath);
45064
45067
  const git = cliSimpleGit(resolvedCheckoutPath);
45065
45068
  await yieldToEventLoop2();
45066
45069
  const [branch, remoteUrl] = await Promise.all([
@@ -45075,14 +45078,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
45075
45078
  }
45076
45079
 
45077
45080
  // src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
45078
- import * as path49 from "node:path";
45081
+ import * as path50 from "node:path";
45079
45082
  async function resolveRepoPathRelativeToWorkspaceRoot(options) {
45080
- const checkoutPath = path49.resolve(options.checkoutPath);
45083
+ const checkoutPath = path50.resolve(options.checkoutPath);
45081
45084
  const git = cliSimpleGit(checkoutPath);
45082
- const sessionParentPath = options.sessionParentPath ? path49.resolve(options.sessionParentPath) : null;
45085
+ const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
45083
45086
  let repoPathRelativeToWorkspaceRoot;
45084
45087
  if (sessionParentPath) {
45085
- const checkoutPathRelativeToSessionParent = path49.relative(sessionParentPath, checkoutPath);
45088
+ const checkoutPathRelativeToSessionParent = path50.relative(sessionParentPath, checkoutPath);
45086
45089
  repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
45087
45090
  } else {
45088
45091
  let gitTopLevel = checkoutPath;
@@ -45092,8 +45095,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
45092
45095
  } catch {
45093
45096
  gitTopLevel = checkoutPath;
45094
45097
  }
45095
- const gitTopLevelRelativeToBridgeRoot = path49.relative(options.bridgeRoot, path49.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
45096
- repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path49.basename(path49.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
45098
+ const gitTopLevelRelativeToBridgeRoot = path50.relative(options.bridgeRoot, path50.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
45099
+ repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path50.basename(path50.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
45097
45100
  }
45098
45101
  return normalizeRepoPathRelativeToWorkspaceRoot(
45099
45102
  repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
@@ -45102,10 +45105,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
45102
45105
 
45103
45106
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
45104
45107
  async function buildWorkingTreeChangeRepoDetail(options) {
45105
- const checkoutPath = path50.resolve(options.targetPath);
45108
+ const checkoutPath = path51.resolve(options.targetPath);
45106
45109
  if (!await isGitRepoDirectory(checkoutPath)) return null;
45107
45110
  const isCommitView = options.basis.kind === "commit";
45108
- const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
45111
+ const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
45109
45112
  const git = cliSimpleGit(checkoutPath);
45110
45113
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
45111
45114
  checkoutPath,
@@ -45153,8 +45156,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
45153
45156
 
45154
45157
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
45155
45158
  async function getWorkingTreeChangeRepoDetails(options) {
45156
- const bridgeRoot = path51.resolve(getBridgeRoot());
45157
- const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
45159
+ const bridgeRoot = path52.resolve(getBridgeRoot());
45160
+ const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
45158
45161
  const out = [];
45159
45162
  const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
45160
45163
  const basisInput = options.basis ?? { kind: "working" };
@@ -45185,9 +45188,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
45185
45188
  }
45186
45189
 
45187
45190
  // src/git/changes/repo/get-working-tree-change-file-patch.ts
45188
- import * as path52 from "node:path";
45191
+ import * as path53 from "node:path";
45189
45192
  async function getWorkingTreeChangeFilePatch(options) {
45190
- const repoGitCwd = path52.resolve(options.repoGitCwd);
45193
+ const repoGitCwd = path53.resolve(options.repoGitCwd);
45191
45194
  if (!await isGitRepoDirectory(repoGitCwd)) {
45192
45195
  throw new Error("Not a git repository");
45193
45196
  }
@@ -45226,7 +45229,7 @@ async function getWorkingTreeChangeFilePatch(options) {
45226
45229
  });
45227
45230
  return { patchContent: patchContent2, totalLines: totalLines2 };
45228
45231
  }
45229
- const filePath = path52.join(repoGitCwd, filePathRelativeToRepoRoot);
45232
+ const filePath = path53.join(repoGitCwd, filePathRelativeToRepoRoot);
45230
45233
  const hydrateKind = options.change === "moved" ? "modified" : options.change;
45231
45234
  let patchContent = await unifiedDiffForFile(
45232
45235
  repoGitCwd,
@@ -45272,18 +45275,18 @@ function parseWorkingTreeChangeKind(value) {
45272
45275
  }
45273
45276
 
45274
45277
  // src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
45275
- import * as path53 from "node:path";
45278
+ import * as path54 from "node:path";
45276
45279
  async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
45277
45280
  const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
45278
- const bridgeRoot = path53.resolve(getBridgeRoot());
45279
- const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path53.resolve(cache2.getSessionParentPath(sessionId)) : null;
45281
+ const bridgeRoot = path54.resolve(getBridgeRoot());
45282
+ const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path54.resolve(cache2.getSessionParentPath(sessionId)) : null;
45280
45283
  const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
45281
45284
  opts.repoRelPath.trim()
45282
45285
  );
45283
45286
  let result = null;
45284
45287
  await forEachWithGitYield(targets, async (targetPath) => {
45285
45288
  if (result) return;
45286
- const checkoutPath = path53.resolve(targetPath);
45289
+ const checkoutPath = path54.resolve(targetPath);
45287
45290
  if (!await isGitRepoDirectory(checkoutPath)) return;
45288
45291
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
45289
45292
  checkoutPath,
@@ -45316,13 +45319,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
45316
45319
  }
45317
45320
 
45318
45321
  // src/worktrees/remove-session-worktrees.ts
45319
- import * as fs37 from "node:fs";
45322
+ import * as fs38 from "node:fs";
45320
45323
 
45321
45324
  // src/git/worktrees/worktree-remove.ts
45322
- import * as fs36 from "node:fs";
45325
+ import * as fs37 from "node:fs";
45323
45326
 
45324
45327
  // src/worktrees/is-removable-session-worktree-checkout-path.ts
45325
- import path54 from "node:path";
45328
+ import path55 from "node:path";
45326
45329
  init_normalize_resolved_path();
45327
45330
  function isBridgeRootCheckoutPath(checkoutPath) {
45328
45331
  return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
@@ -45331,23 +45334,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
45331
45334
  if (isBridgeRootCheckoutPath(checkoutPath)) return false;
45332
45335
  const normalized = normalizeResolvedPath(checkoutPath);
45333
45336
  const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
45334
- const rel = path54.relative(worktreesRoot, normalized);
45335
- if (rel === "" || rel.startsWith("..") || path54.isAbsolute(rel)) return false;
45337
+ const rel = path55.relative(worktreesRoot, normalized);
45338
+ if (rel === "" || rel.startsWith("..") || path55.isAbsolute(rel)) return false;
45336
45339
  return true;
45337
45340
  }
45338
45341
 
45339
45342
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
45340
- import * as fs35 from "node:fs";
45341
- import * as path55 from "node:path";
45343
+ import * as fs36 from "node:fs";
45344
+ import * as path56 from "node:path";
45342
45345
  function resolveMainRepoFromWorktreeGitFile(wt) {
45343
- const gitDirFile = path55.join(wt, ".git");
45344
- if (!fs35.existsSync(gitDirFile) || !fs35.statSync(gitDirFile).isFile()) return "";
45345
- const first2 = fs35.readFileSync(gitDirFile, "utf8").trim();
45346
+ const gitDirFile = path56.join(wt, ".git");
45347
+ if (!fs36.existsSync(gitDirFile) || !fs36.statSync(gitDirFile).isFile()) return "";
45348
+ const first2 = fs36.readFileSync(gitDirFile, "utf8").trim();
45346
45349
  const m = first2.match(/^gitdir:\s*(.+)$/im);
45347
45350
  if (!m) return "";
45348
- const gitWorktreePath = path55.resolve(wt, m[1].trim());
45349
- const gitDir = path55.dirname(path55.dirname(gitWorktreePath));
45350
- return path55.dirname(gitDir);
45351
+ const gitWorktreePath = path56.resolve(wt, m[1].trim());
45352
+ const gitDir = path56.dirname(path56.dirname(gitWorktreePath));
45353
+ return path56.dirname(gitDir);
45351
45354
  }
45352
45355
 
45353
45356
  // src/git/worktrees/worktree-remove.ts
@@ -45358,7 +45361,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
45358
45361
  return true;
45359
45362
  }
45360
45363
  if (isBridgeRootCheckoutPath(worktreePath)) return false;
45361
- fs36.rmSync(worktreePath, { recursive: true, force: true });
45364
+ fs37.rmSync(worktreePath, { recursive: true, force: true });
45362
45365
  return true;
45363
45366
  }
45364
45367
 
@@ -45380,7 +45383,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
45380
45383
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
45381
45384
  if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
45382
45385
  try {
45383
- fs37.rmSync(wt, { recursive: true, force: true });
45386
+ fs38.rmSync(wt, { recursive: true, force: true });
45384
45387
  } catch {
45385
45388
  }
45386
45389
  }
@@ -45405,6 +45408,7 @@ async function gitRenameCurrentBranch(repoDir, newName) {
45405
45408
  async function renameSessionWorktreeBranches(paths, newBranch, log2) {
45406
45409
  const safe = newBranch.replace(/[^a-zA-Z0-9/_-]+/g, "-").slice(0, 80) || "session-branch";
45407
45410
  await forEachWithGitYield(paths, async (wt) => {
45411
+ if (!await isGitRepoDirectory(wt)) return;
45408
45412
  try {
45409
45413
  await gitRenameCurrentBranch(wt, safe);
45410
45414
  log2(`[worktrees] Renamed branch in ${wt} \u2192 ${safe}`);
@@ -45426,12 +45430,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
45426
45430
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
45427
45431
  init_cli_process_interrupt();
45428
45432
  init_yield_to_event_loop();
45429
- import * as fs41 from "node:fs";
45430
- import * as path60 from "node:path";
45433
+ import * as fs42 from "node:fs";
45434
+ import * as path61 from "node:path";
45431
45435
 
45432
45436
  // src/worktrees/discovery/collect-worktree-paths.ts
45433
- import * as fs39 from "node:fs";
45434
- import * as path57 from "node:path";
45437
+ import * as fs40 from "node:fs";
45438
+ import * as path58 from "node:path";
45435
45439
 
45436
45440
  // src/worktrees/discovery/disk-walk-constants.ts
45437
45441
  var DISK_WALK_YIELD_EVERY = 64;
@@ -45461,8 +45465,8 @@ function shouldSkipDiskWalkEntry(name) {
45461
45465
  // src/worktrees/discovery/disk-walk-utils.ts
45462
45466
  init_cli_process_interrupt();
45463
45467
  init_yield_to_event_loop();
45464
- import * as fs38 from "node:fs";
45465
- import * as path56 from "node:path";
45468
+ import * as fs39 from "node:fs";
45469
+ import * as path57 from "node:path";
45466
45470
  async function yieldDuringDiskWalk(state) {
45467
45471
  state.entries++;
45468
45472
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -45472,7 +45476,7 @@ async function yieldDuringDiskWalk(state) {
45472
45476
  }
45473
45477
  async function isGitDir(dirPath) {
45474
45478
  try {
45475
- await fs38.promises.access(path56.join(dirPath, ".git"));
45479
+ await fs39.promises.access(path57.join(dirPath, ".git"));
45476
45480
  return true;
45477
45481
  } catch {
45478
45482
  return false;
@@ -45486,23 +45490,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
45486
45490
  const walk = async (dir) => {
45487
45491
  if (!await yieldDuringDiskWalk(state)) return;
45488
45492
  if (await isGitDir(dir)) {
45489
- out.push(path57.resolve(dir));
45493
+ out.push(path58.resolve(dir));
45490
45494
  return;
45491
45495
  }
45492
45496
  let entries;
45493
45497
  try {
45494
- entries = await fs39.promises.readdir(dir, { withFileTypes: true });
45498
+ entries = await fs40.promises.readdir(dir, { withFileTypes: true });
45495
45499
  } catch {
45496
45500
  return;
45497
45501
  }
45498
45502
  for (const e of entries) {
45499
45503
  if (shouldSkipDiskWalkEntry(e.name)) continue;
45500
- const full = path57.join(dir, e.name);
45504
+ const full = path58.join(dir, e.name);
45501
45505
  if (!e.isDirectory()) continue;
45502
45506
  await walk(full);
45503
45507
  }
45504
45508
  };
45505
- await walk(path57.resolve(rootPath));
45509
+ await walk(path58.resolve(rootPath));
45506
45510
  return { paths: [...new Set(out)], entriesVisited: state.entries };
45507
45511
  }
45508
45512
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -45513,16 +45517,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
45513
45517
  if (!await yieldDuringDiskWalk(state)) return;
45514
45518
  let entries;
45515
45519
  try {
45516
- entries = await fs39.promises.readdir(dir, { withFileTypes: true });
45520
+ entries = await fs40.promises.readdir(dir, { withFileTypes: true });
45517
45521
  } catch {
45518
45522
  return;
45519
45523
  }
45520
45524
  for (const e of entries) {
45521
45525
  if (shouldSkipDiskWalkEntry(e.name)) continue;
45522
- const full = path57.join(dir, e.name);
45526
+ const full = path58.join(dir, e.name);
45523
45527
  if (!e.isDirectory()) continue;
45524
45528
  if (e.name === sessionId) {
45525
- if (await isGitDir(full)) out.push(path57.resolve(full));
45529
+ if (await isGitDir(full)) out.push(path58.resolve(full));
45526
45530
  continue;
45527
45531
  }
45528
45532
  if (await isGitDir(full)) continue;
@@ -45534,14 +45538,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
45534
45538
  }
45535
45539
 
45536
45540
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
45537
- import * as path58 from "node:path";
45541
+ import * as path59 from "node:path";
45538
45542
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
45539
- const bridge = path58.resolve(bridgeRoot);
45543
+ const bridge = path59.resolve(bridgeRoot);
45540
45544
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
45541
45545
  const relevant = layout.launcherCwds.filter((e) => {
45542
- const entry = path58.resolve(e.absolutePath);
45543
- return bridge === entry || bridge.startsWith(entry + path58.sep) || entry.startsWith(bridge + path58.sep);
45544
- }).sort((a, b) => path58.resolve(b.absolutePath).length - path58.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
45546
+ const entry = path59.resolve(e.absolutePath);
45547
+ return bridge === entry || bridge.startsWith(entry + path59.sep) || entry.startsWith(bridge + path59.sep);
45548
+ }).sort((a, b) => path59.resolve(b.absolutePath).length - path59.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
45545
45549
  const ordered = [];
45546
45550
  const seen = /* @__PURE__ */ new Set();
45547
45551
  const add = (k) => {
@@ -45559,19 +45563,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
45559
45563
  }
45560
45564
 
45561
45565
  // src/worktrees/discovery/try-binding-from-isolated-directory.ts
45562
- import * as fs40 from "node:fs";
45563
- import * as path59 from "node:path";
45566
+ import * as fs41 from "node:fs";
45567
+ import * as path60 from "node:path";
45564
45568
  async function tryBindingFromIsolatedDirectory(scopeDir) {
45565
45569
  let st;
45566
45570
  try {
45567
- st = await fs40.promises.stat(scopeDir);
45571
+ st = await fs41.promises.stat(scopeDir);
45568
45572
  } catch {
45569
45573
  return null;
45570
45574
  }
45571
45575
  if (!st.isDirectory()) return null;
45572
45576
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
45573
45577
  if (worktreePaths.length === 0) return null;
45574
- const abs = path59.resolve(scopeDir);
45578
+ const abs = path60.resolve(scopeDir);
45575
45579
  return {
45576
45580
  parentPath: abs,
45577
45581
  repoCheckoutPaths: worktreePaths
@@ -45594,7 +45598,7 @@ async function discoverSessionWorktreeOnDisk(options) {
45594
45598
  const sid = sessionId.trim();
45595
45599
  if (!sid) return null;
45596
45600
  try {
45597
- await fs41.promises.access(worktreesRootPath);
45601
+ await fs42.promises.access(worktreesRootPath);
45598
45602
  } catch {
45599
45603
  return null;
45600
45604
  }
@@ -45603,13 +45607,13 @@ async function discoverSessionWorktreeOnDisk(options) {
45603
45607
  if (preferredKey) keysOnDisk.push(preferredKey);
45604
45608
  const scanState = { entries: 0 };
45605
45609
  try {
45606
- for (const name of await fs41.promises.readdir(worktreesRootPath)) {
45610
+ for (const name of await fs42.promises.readdir(worktreesRootPath)) {
45607
45611
  if (!await yieldDuringDiskWalk(scanState)) break;
45608
45612
  if (name.startsWith(".")) continue;
45609
- const p = path60.join(worktreesRootPath, name);
45613
+ const p = path61.join(worktreesRootPath, name);
45610
45614
  let st;
45611
45615
  try {
45612
- st = await fs41.promises.stat(p);
45616
+ st = await fs42.promises.stat(p);
45613
45617
  } catch {
45614
45618
  continue;
45615
45619
  }
@@ -45623,23 +45627,23 @@ async function discoverSessionWorktreeOnDisk(options) {
45623
45627
  for (const key of keys) {
45624
45628
  if (isCliImmediateShutdownRequested()) return null;
45625
45629
  await yieldToEventLoop();
45626
- const layoutRoot = path60.join(worktreesRootPath, key);
45630
+ const layoutRoot = path61.join(worktreesRootPath, key);
45627
45631
  let layoutSt;
45628
45632
  try {
45629
- layoutSt = await fs41.promises.stat(layoutRoot);
45633
+ layoutSt = await fs42.promises.stat(layoutRoot);
45630
45634
  } catch {
45631
45635
  continue;
45632
45636
  }
45633
45637
  if (!layoutSt.isDirectory()) continue;
45634
- const sessionDir = path60.join(layoutRoot, sid);
45638
+ const sessionDir = path61.join(layoutRoot, sid);
45635
45639
  const nested = await tryBindingFromSessionDirectory(sessionDir);
45636
45640
  if (nested) return nested;
45637
45641
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
45638
45642
  if (legacy.paths.length > 0) {
45639
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path60.resolve(legacy.paths[0]);
45643
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path61.resolve(legacy.paths[0]);
45640
45644
  return {
45641
- sessionParentPath: path60.resolve(isolated),
45642
- repoCheckoutPaths: legacy.paths.map((p) => path60.resolve(p))
45645
+ sessionParentPath: path61.resolve(isolated),
45646
+ repoCheckoutPaths: legacy.paths.map((p) => path61.resolve(p))
45643
45647
  };
45644
45648
  }
45645
45649
  }
@@ -45647,31 +45651,31 @@ async function discoverSessionWorktreeOnDisk(options) {
45647
45651
  }
45648
45652
 
45649
45653
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
45650
- import * as fs42 from "node:fs";
45651
- import * as path62 from "node:path";
45654
+ import * as fs43 from "node:fs";
45655
+ import * as path63 from "node:path";
45652
45656
 
45653
45657
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
45654
45658
  init_cli_process_interrupt();
45655
45659
  init_yield_to_event_loop();
45656
- import * as path61 from "node:path";
45660
+ import * as path62 from "node:path";
45657
45661
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
45658
45662
  const sid = sessionId.trim();
45659
45663
  if (!sid) return null;
45660
- const hintR = path61.resolve(checkoutPath);
45664
+ const hintR = path62.resolve(checkoutPath);
45661
45665
  let best = null;
45662
- let cur = path61.dirname(hintR);
45666
+ let cur = path62.dirname(hintR);
45663
45667
  for (let i = 0; i < 40; i++) {
45664
45668
  if (isCliImmediateShutdownRequested()) return best;
45665
45669
  await yieldToEventLoop();
45666
45670
  const paths = await collectWorktreeRootsNamed(cur, sid);
45667
- if (paths.paths.some((p) => path61.resolve(p) === hintR)) {
45668
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path61.resolve(paths.paths[0]);
45671
+ if (paths.paths.some((p) => path62.resolve(p) === hintR)) {
45672
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path62.resolve(paths.paths[0]);
45669
45673
  best = {
45670
- sessionParentPath: path61.resolve(isolated),
45671
- repoCheckoutPaths: paths.paths.map((p) => path61.resolve(p))
45674
+ sessionParentPath: path62.resolve(isolated),
45675
+ repoCheckoutPaths: paths.paths.map((p) => path62.resolve(p))
45672
45676
  };
45673
45677
  }
45674
- const next = path61.dirname(cur);
45678
+ const next = path62.dirname(cur);
45675
45679
  if (next === cur) break;
45676
45680
  cur = next;
45677
45681
  }
@@ -45682,12 +45686,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
45682
45686
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
45683
45687
  const sid = sessionId.trim();
45684
45688
  if (!sid) return null;
45685
- const hint = path62.resolve(sessionParentPathOrHint);
45686
- const underHint = await tryBindingFromSessionDirectory(path62.join(hint, sid));
45689
+ const hint = path63.resolve(sessionParentPathOrHint);
45690
+ const underHint = await tryBindingFromSessionDirectory(path63.join(hint, sid));
45687
45691
  if (underHint) return underHint;
45688
45692
  const direct = await tryBindingFromSessionDirectory(hint);
45689
45693
  if (direct) {
45690
- if (path62.basename(hint) === sid && await isGitDir(hint)) {
45694
+ if (path63.basename(hint) === sid && await isGitDir(hint)) {
45691
45695
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
45692
45696
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
45693
45697
  return legacyFromCheckout;
@@ -45695,23 +45699,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
45695
45699
  }
45696
45700
  return direct;
45697
45701
  }
45698
- if (path62.basename(hint) === sid && await isGitDir(hint)) {
45702
+ if (path63.basename(hint) === sid && await isGitDir(hint)) {
45699
45703
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
45700
45704
  if (legacyFromCheckout) return legacyFromCheckout;
45701
45705
  }
45702
45706
  let st;
45703
45707
  try {
45704
- st = await fs42.promises.stat(hint);
45708
+ st = await fs43.promises.stat(hint);
45705
45709
  } catch {
45706
45710
  return null;
45707
45711
  }
45708
45712
  if (!st.isDirectory()) return null;
45709
45713
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
45710
45714
  if (legacyPaths.paths.length === 0) return null;
45711
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path62.resolve(legacyPaths.paths[0]);
45715
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path63.resolve(legacyPaths.paths[0]);
45712
45716
  return {
45713
- sessionParentPath: path62.resolve(isolated),
45714
- repoCheckoutPaths: legacyPaths.paths.map((p) => path62.resolve(p))
45717
+ sessionParentPath: path63.resolve(isolated),
45718
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path63.resolve(p))
45715
45719
  };
45716
45720
  }
45717
45721
 
@@ -45772,11 +45776,11 @@ function parseSessionParent(v) {
45772
45776
  }
45773
45777
 
45774
45778
  // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
45775
- import * as fs46 from "node:fs";
45779
+ import * as fs47 from "node:fs";
45776
45780
 
45777
45781
  // src/git/discover-repos.ts
45778
- import * as fs43 from "node:fs";
45779
- import * as path63 from "node:path";
45782
+ import * as fs44 from "node:fs";
45783
+ import * as path64 from "node:path";
45780
45784
  init_yield_to_event_loop();
45781
45785
  var GIT_DISCOVER_YIELD_EVERY = 32;
45782
45786
  async function yieldGitDiscoverWork(entryCount) {
@@ -45786,14 +45790,14 @@ async function yieldGitDiscoverWork(entryCount) {
45786
45790
  }
45787
45791
  async function discoverGitRepos(cwd = getBridgeRoot()) {
45788
45792
  const result = [];
45789
- const cwdResolved = path63.resolve(cwd);
45793
+ const cwdResolved = path64.resolve(cwd);
45790
45794
  if (await isGitRepoDirectory(cwdResolved)) {
45791
45795
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
45792
45796
  result.push({ absolutePath: cwdResolved, remoteUrl });
45793
45797
  }
45794
45798
  let entries;
45795
45799
  try {
45796
- entries = fs43.readdirSync(cwdResolved, { withFileTypes: true });
45800
+ entries = fs44.readdirSync(cwdResolved, { withFileTypes: true });
45797
45801
  } catch {
45798
45802
  return result;
45799
45803
  }
@@ -45801,7 +45805,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
45801
45805
  await yieldGitDiscoverWork(i + 1);
45802
45806
  const ent = entries[i];
45803
45807
  if (!ent.isDirectory()) continue;
45804
- const childPath2 = path63.join(cwdResolved, ent.name);
45808
+ const childPath2 = path64.join(cwdResolved, ent.name);
45805
45809
  if (await isGitRepoDirectory(childPath2)) {
45806
45810
  const remoteUrl = await getRemoteOriginUrl(childPath2);
45807
45811
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -45810,17 +45814,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
45810
45814
  return result;
45811
45815
  }
45812
45816
  async function discoverGitReposUnderRoot(rootPath) {
45813
- const root = path63.resolve(rootPath);
45817
+ const root = path64.resolve(rootPath);
45814
45818
  const roots = [];
45815
45819
  let walkEntries = 0;
45816
45820
  async function walk(dir) {
45817
45821
  if (await isGitRepoDirectory(dir)) {
45818
- roots.push(path63.resolve(dir));
45822
+ roots.push(path64.resolve(dir));
45819
45823
  return;
45820
45824
  }
45821
45825
  let entries;
45822
45826
  try {
45823
- entries = fs43.readdirSync(dir, { withFileTypes: true });
45827
+ entries = fs44.readdirSync(dir, { withFileTypes: true });
45824
45828
  } catch {
45825
45829
  return;
45826
45830
  }
@@ -45828,7 +45832,7 @@ async function discoverGitReposUnderRoot(rootPath) {
45828
45832
  await yieldGitDiscoverWork(++walkEntries);
45829
45833
  const ent = entries[i];
45830
45834
  if (!ent.isDirectory() || ent.name === ".git") continue;
45831
- await walk(path63.join(dir, ent.name));
45835
+ await walk(path64.join(dir, ent.name));
45832
45836
  }
45833
45837
  }
45834
45838
  await walk(root);
@@ -45844,8 +45848,8 @@ async function discoverGitReposUnderRoot(rootPath) {
45844
45848
  }
45845
45849
 
45846
45850
  // src/worktrees/prepare/add-isolated-repo-worktree.ts
45847
- import * as fs45 from "node:fs";
45848
- import * as path65 from "node:path";
45851
+ import * as fs46 from "node:fs";
45852
+ import * as path66 from "node:path";
45849
45853
 
45850
45854
  // src/git/worktrees/worktree-add.ts
45851
45855
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
@@ -45861,8 +45865,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
45861
45865
  }
45862
45866
 
45863
45867
  // src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
45864
- import * as fs44 from "node:fs";
45865
- import * as path64 from "node:path";
45868
+ import * as fs45 from "node:fs";
45869
+ import * as path65 from "node:path";
45866
45870
  var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
45867
45871
  function copyBridgeFilesAlongWorktreePath(options) {
45868
45872
  const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
@@ -45871,19 +45875,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
45871
45875
  const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
45872
45876
  for (let i = 0; i < segments.length; i++) {
45873
45877
  const prefix = segments.slice(0, i).join("/");
45874
- const bridgeDir = prefix ? path64.join(bridgeRoot, prefix) : bridgeRoot;
45875
- const destDir = prefix ? path64.join(scopeDir, prefix) : scopeDir;
45878
+ const bridgeDir = prefix ? path65.join(bridgeRoot, prefix) : bridgeRoot;
45879
+ const destDir = prefix ? path65.join(scopeDir, prefix) : scopeDir;
45876
45880
  for (const fileName of fileNames) {
45877
45881
  copyFileIfPresent(bridgeDir, destDir, fileName, log2);
45878
45882
  }
45879
45883
  }
45880
45884
  }
45881
45885
  function copyFileIfPresent(srcDir, destDir, fileName, log2) {
45882
- const src = path64.join(srcDir, fileName);
45883
- if (!fs44.existsSync(src)) return;
45884
- const dest = path64.join(destDir, fileName);
45886
+ const src = path65.join(srcDir, fileName);
45887
+ if (!fs45.existsSync(src)) return;
45888
+ const dest = path65.join(destDir, fileName);
45885
45889
  try {
45886
- fs44.copyFileSync(src, dest);
45890
+ fs45.copyFileSync(src, dest);
45887
45891
  log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
45888
45892
  } catch (e) {
45889
45893
  log2?.(
@@ -45915,16 +45919,16 @@ async function addIsolatedRepoWorktree(options) {
45915
45919
  worktreeBaseBranches,
45916
45920
  log: log2
45917
45921
  } = options;
45918
- const repoPathRelativeToBridgeRootRaw = path65.relative(bridgeResolved, repoAbsolutePath);
45919
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path65.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
45922
+ const repoPathRelativeToBridgeRootRaw = path66.relative(bridgeResolved, repoAbsolutePath);
45923
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path66.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
45920
45924
  return null;
45921
45925
  }
45922
45926
  const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
45923
45927
  repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
45924
45928
  );
45925
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path65.join(scopeDir, repoPathRelativeToBridgeRoot);
45929
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path66.join(scopeDir, repoPathRelativeToBridgeRoot);
45926
45930
  if (repoPathRelativeToBridgeRoot !== ".") {
45927
- fs45.mkdirSync(path65.dirname(worktreePath), { recursive: true });
45931
+ fs46.mkdirSync(path66.dirname(worktreePath), { recursive: true });
45928
45932
  copyBridgeFilesAlongWorktreePath({
45929
45933
  bridgeRoot: bridgeResolved,
45930
45934
  scopeDir,
@@ -45952,7 +45956,7 @@ async function addIsolatedRepoWorktree(options) {
45952
45956
  }
45953
45957
 
45954
45958
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
45955
- import * as path66 from "node:path";
45959
+ import * as path67 from "node:path";
45956
45960
 
45957
45961
  // src/worktrees/worktree-layout-kind.ts
45958
45962
  function sanitizeWorktreeBranchSegment(value) {
@@ -45982,10 +45986,10 @@ function previewDeployBranchName(environmentId) {
45982
45986
 
45983
45987
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
45984
45988
  function resolveIsolatedScopeDir(options) {
45985
- const bridgeResolved = path66.resolve(options.bridgeRoot);
45989
+ const bridgeResolved = path67.resolve(options.bridgeRoot);
45986
45990
  const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
45987
- const bridgeKeyDir = path66.join(options.worktreesRootPath, cwdKey);
45988
- const scopeDir = path66.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
45991
+ const bridgeKeyDir = path67.join(options.worktreesRootPath, cwdKey);
45992
+ const scopeDir = path67.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
45989
45993
  return { bridgeResolved, scopeDir };
45990
45994
  }
45991
45995
 
@@ -46015,7 +46019,7 @@ async function prepareNewIsolatedWorktrees(options) {
46015
46019
  return null;
46016
46020
  }
46017
46021
  const worktreePaths = [];
46018
- fs46.mkdirSync(scopeDir, { recursive: true });
46022
+ fs47.mkdirSync(scopeDir, { recursive: true });
46019
46023
  await forEachWithGitYield(repos, async (repo) => {
46020
46024
  const worktreePath = await addIsolatedRepoWorktree({
46021
46025
  kind,
@@ -46087,10 +46091,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
46087
46091
  }
46088
46092
 
46089
46093
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
46090
- import * as path67 from "node:path";
46094
+ import * as path68 from "node:path";
46091
46095
  init_yield_to_event_loop();
46092
46096
  async function resolveExplicitSessionParentPath(params) {
46093
- const resolved = path67.resolve(params.parentPathRaw);
46097
+ const resolved = path68.resolve(params.parentPathRaw);
46094
46098
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
46095
46099
  return resolved;
46096
46100
  }
@@ -46107,7 +46111,7 @@ async function resolveExplicitSessionParentPath(params) {
46107
46111
  await yieldToEventLoop();
46108
46112
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
46109
46113
  if (tryRoot) return rememberAndReturn(tryRoot);
46110
- const next = path67.dirname(cur);
46114
+ const next = path68.dirname(cur);
46111
46115
  if (next === cur) break;
46112
46116
  cur = next;
46113
46117
  }
@@ -46255,15 +46259,15 @@ var SessionWorktreeManager = class {
46255
46259
  };
46256
46260
 
46257
46261
  // src/worktrees/discovery/discover-preview-worktree-on-disk.ts
46258
- import * as fs47 from "node:fs";
46259
- import * as path68 from "node:path";
46262
+ import * as fs48 from "node:fs";
46263
+ import * as path69 from "node:path";
46260
46264
  init_yield_to_event_loop();
46261
46265
  async function discoverPreviewWorktreeOnDisk(options) {
46262
46266
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
46263
46267
  const eid = environmentId.trim();
46264
46268
  if (!eid) return null;
46265
46269
  try {
46266
- await fs47.promises.access(worktreesRootPath);
46270
+ await fs48.promises.access(worktreesRootPath);
46267
46271
  } catch {
46268
46272
  return null;
46269
46273
  }
@@ -46272,13 +46276,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
46272
46276
  if (preferredKey) keysOnDisk.push(preferredKey);
46273
46277
  const scanState = { entries: 0 };
46274
46278
  try {
46275
- for (const name of await fs47.promises.readdir(worktreesRootPath)) {
46279
+ for (const name of await fs48.promises.readdir(worktreesRootPath)) {
46276
46280
  if (!await yieldDuringDiskWalk(scanState)) break;
46277
46281
  if (name.startsWith(".")) continue;
46278
- const p = path68.join(worktreesRootPath, name);
46282
+ const p = path69.join(worktreesRootPath, name);
46279
46283
  let st;
46280
46284
  try {
46281
- st = await fs47.promises.stat(p);
46285
+ st = await fs48.promises.stat(p);
46282
46286
  } catch {
46283
46287
  continue;
46284
46288
  }
@@ -46292,7 +46296,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
46292
46296
  const previewDirRel = layoutDirSegments("preview_environment", eid);
46293
46297
  for (const key of keys) {
46294
46298
  await yieldToEventLoop();
46295
- const previewDir = path68.join(worktreesRootPath, key, ...previewDirRel);
46299
+ const previewDir = path69.join(worktreesRootPath, key, ...previewDirRel);
46296
46300
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
46297
46301
  if (binding) return binding;
46298
46302
  }
@@ -46419,7 +46423,7 @@ var PreviewWorktreeManager = class {
46419
46423
  };
46420
46424
 
46421
46425
  // src/worktrees/deploy/deploy-session-to-preview-environment.ts
46422
- import * as path72 from "node:path";
46426
+ import * as path73 from "node:path";
46423
46427
 
46424
46428
  // src/git/worktrees/reset-worktree-to-branch.ts
46425
46429
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -46430,8 +46434,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
46430
46434
  }
46431
46435
 
46432
46436
  // src/worktrees/deploy/capture-and-apply-wip.ts
46433
- import * as fs48 from "node:fs";
46434
- import * as path69 from "node:path";
46437
+ import * as fs49 from "node:fs";
46438
+ import * as path70 from "node:path";
46435
46439
 
46436
46440
  // src/git/snapshot/git.ts
46437
46441
  async function gitStashCreate(repoRoot, log2) {
@@ -46479,12 +46483,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
46479
46483
  if (!ap.ok) return ap;
46480
46484
  }
46481
46485
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
46482
- const src = path69.join(sourceRepoPath, rel);
46483
- const dst = path69.join(targetRepoPath, rel);
46486
+ const src = path70.join(sourceRepoPath, rel);
46487
+ const dst = path70.join(targetRepoPath, rel);
46484
46488
  try {
46485
- if (!fs48.existsSync(src)) return;
46486
- fs48.mkdirSync(path69.dirname(dst), { recursive: true });
46487
- fs48.copyFileSync(src, dst);
46489
+ if (!fs49.existsSync(src)) return;
46490
+ fs49.mkdirSync(path70.dirname(dst), { recursive: true });
46491
+ fs49.copyFileSync(src, dst);
46488
46492
  } catch (e) {
46489
46493
  log2(
46490
46494
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -46495,14 +46499,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
46495
46499
  }
46496
46500
 
46497
46501
  // src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
46498
- import * as path70 from "node:path";
46502
+ import * as path71 from "node:path";
46499
46503
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
46500
46504
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
46501
- const resolvedSessionParentPath = sessionParentPath ? path70.resolve(sessionParentPath) : null;
46505
+ const resolvedSessionParentPath = sessionParentPath ? path71.resolve(sessionParentPath) : null;
46502
46506
  let match = null;
46503
46507
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
46504
46508
  if (match) return;
46505
- const resolvedCheckoutPath = path70.resolve(checkoutPath);
46509
+ const resolvedCheckoutPath = path71.resolve(checkoutPath);
46506
46510
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
46507
46511
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
46508
46512
  checkoutPath: resolvedCheckoutPath,
@@ -46556,7 +46560,7 @@ async function applySessionWipToPreviewCheckouts(options) {
46556
46560
  }
46557
46561
 
46558
46562
  // src/worktrees/deploy/collect-session-repo-deploy-states.ts
46559
- import * as path71 from "node:path";
46563
+ import * as path72 from "node:path";
46560
46564
 
46561
46565
  // src/git/branches/create-or-update-branch.ts
46562
46566
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -46593,19 +46597,19 @@ async function collectSessionRepoDeployStates(options) {
46593
46597
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
46594
46598
  const states = [];
46595
46599
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
46596
- const checkoutPath = path71.resolve(sessionCheckout);
46600
+ const checkoutPath = path72.resolve(sessionCheckout);
46597
46601
  if (!await isGitRepoDirectory(checkoutPath)) return;
46598
46602
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
46599
46603
  checkoutPath,
46600
46604
  bridgeRoot,
46601
- sessionParentPath: sessionParentPath ? path71.resolve(sessionParentPath) : null
46605
+ sessionParentPath: sessionParentPath ? path72.resolve(sessionParentPath) : null
46602
46606
  });
46603
46607
  if (!repoPathRelativeToWorkspaceRoot) return;
46604
46608
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
46605
46609
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
46606
46610
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
46607
46611
  checkoutPaths: previewCheckoutPaths,
46608
- sessionParentPath: previewParentPath ? path71.resolve(previewParentPath) : null,
46612
+ sessionParentPath: previewParentPath ? path72.resolve(previewParentPath) : null,
46609
46613
  bridgeRoot,
46610
46614
  repoPathRelativeToWorkspaceRoot
46611
46615
  }) : null;
@@ -46625,7 +46629,7 @@ async function deploySessionToPreviewEnvironment(options) {
46625
46629
  const eid = options.environmentId.trim();
46626
46630
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
46627
46631
  const deployBranch = previewDeployBranchName(eid);
46628
- const bridgeRoot = path72.resolve(getBridgeRoot());
46632
+ const bridgeRoot = path73.resolve(getBridgeRoot());
46629
46633
  await previewWorktreeManager.ensureCached(eid);
46630
46634
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
46631
46635
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -46665,10 +46669,10 @@ async function deploySessionToPreviewEnvironment(options) {
46665
46669
  }
46666
46670
 
46667
46671
  // src/worktrees/manager/default-worktrees-root-path.ts
46668
- import * as path73 from "node:path";
46672
+ import * as path74 from "node:path";
46669
46673
  import os9 from "node:os";
46670
46674
  function defaultWorktreesRootPath() {
46671
- return path73.join(os9.homedir(), ".buildautomaton", "worktrees");
46675
+ return path74.join(os9.homedir(), ".buildautomaton", "worktrees");
46672
46676
  }
46673
46677
 
46674
46678
  // src/connection/create-bridge-worktree-managers.ts
@@ -46798,14 +46802,14 @@ function assertBridgeWorkspace(ctx) {
46798
46802
  }
46799
46803
 
46800
46804
  // src/files/list-dir/index.ts
46801
- import fs50 from "node:fs";
46805
+ import fs51 from "node:fs";
46802
46806
 
46803
46807
  // src/files/ensure-under-cwd.ts
46804
- import path74 from "node:path";
46808
+ import path75 from "node:path";
46805
46809
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
46806
- const normalized = path74.normalize(relativePath).replace(/^(\.\/)+/, "");
46807
- const resolved = path74.resolve(cwd, normalized);
46808
- if (!resolved.startsWith(cwd + path74.sep) && resolved !== cwd) {
46810
+ const normalized = path75.normalize(relativePath).replace(/^(\.\/)+/, "");
46811
+ const resolved = path75.resolve(cwd, normalized);
46812
+ if (!resolved.startsWith(cwd + path75.sep) && resolved !== cwd) {
46809
46813
  return null;
46810
46814
  }
46811
46815
  return resolved;
@@ -46818,15 +46822,15 @@ init_yield_to_event_loop();
46818
46822
  var LIST_DIR_YIELD_EVERY = 256;
46819
46823
 
46820
46824
  // src/files/list-dir/map-dir-entry.ts
46821
- import path75 from "node:path";
46822
- import fs49 from "node:fs";
46825
+ import path76 from "node:path";
46826
+ import fs50 from "node:fs";
46823
46827
  async function mapDirEntry(d, relativePath, resolved) {
46824
- const entryPath = path75.join(relativePath || ".", d.name).replace(/\\/g, "/");
46825
- const fullPath = path75.join(resolved, d.name);
46828
+ const entryPath = path76.join(relativePath || ".", d.name).replace(/\\/g, "/");
46829
+ const fullPath = path76.join(resolved, d.name);
46826
46830
  let isDir = d.isDirectory();
46827
46831
  if (d.isSymbolicLink()) {
46828
46832
  try {
46829
- const targetStat = await fs49.promises.stat(fullPath);
46833
+ const targetStat = await fs50.promises.stat(fullPath);
46830
46834
  isDir = targetStat.isDirectory();
46831
46835
  } catch {
46832
46836
  isDir = false;
@@ -46856,7 +46860,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
46856
46860
  return { error: "Path is outside working directory" };
46857
46861
  }
46858
46862
  try {
46859
- const names = await fs50.promises.readdir(resolved, { withFileTypes: true });
46863
+ const names = await fs51.promises.readdir(resolved, { withFileTypes: true });
46860
46864
  const entries = [];
46861
46865
  for (let i = 0; i < names.length; i++) {
46862
46866
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -46872,13 +46876,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
46872
46876
  }
46873
46877
 
46874
46878
  // src/git/tree/resolve-repo-abs-path.ts
46875
- import * as path76 from "node:path";
46879
+ import * as path77 from "node:path";
46876
46880
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
46877
- const bridgeResolved = path76.resolve(bridgeRoot);
46881
+ const bridgeResolved = path77.resolve(bridgeRoot);
46878
46882
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
46879
- const repoPath = rel === "" ? bridgeResolved : path76.join(bridgeResolved, rel);
46880
- const resolved = path76.resolve(repoPath);
46881
- if (!resolved.startsWith(bridgeResolved + path76.sep) && resolved !== bridgeResolved) {
46883
+ const repoPath = rel === "" ? bridgeResolved : path77.join(bridgeResolved, rel);
46884
+ const resolved = path77.resolve(repoPath);
46885
+ if (!resolved.startsWith(bridgeResolved + path77.sep) && resolved !== bridgeResolved) {
46882
46886
  return null;
46883
46887
  }
46884
46888
  return resolved;
@@ -47359,25 +47363,25 @@ async function GET2(ctx) {
47359
47363
  init_in_flight();
47360
47364
 
47361
47365
  // src/files/read/read-file-async.ts
47362
- import fs56 from "node:fs";
47366
+ import fs57 from "node:fs";
47363
47367
  init_yield_to_event_loop();
47364
47368
 
47365
47369
  // src/files/read/resolve-file-cache.ts
47366
- import fs51 from "node:fs";
47367
- import path77 from "node:path";
47370
+ import fs52 from "node:fs";
47371
+ import path78 from "node:path";
47368
47372
  var RESOLVE_CACHE_MAX = 4096;
47369
47373
  var resolveCache = /* @__PURE__ */ new Map();
47370
47374
  function resolveCacheKey(sessionParentPath, relativePath) {
47371
47375
  return `${sessionParentPath}\0${relativePath}`;
47372
47376
  }
47373
47377
  function pathStaysUnderParent(filePath, sessionParentPath) {
47374
- const parent = path77.resolve(sessionParentPath);
47375
- const resolved = path77.resolve(filePath);
47376
- return resolved === parent || resolved.startsWith(`${parent}${path77.sep}`);
47378
+ const parent = path78.resolve(sessionParentPath);
47379
+ const resolved = path78.resolve(filePath);
47380
+ return resolved === parent || resolved.startsWith(`${parent}${path78.sep}`);
47377
47381
  }
47378
47382
  function statMatchesCacheSync(entry) {
47379
47383
  try {
47380
- const stat2 = fs51.statSync(entry.path);
47384
+ const stat2 = fs52.statSync(entry.path);
47381
47385
  return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
47382
47386
  } catch {
47383
47387
  return false;
@@ -47410,7 +47414,7 @@ function joinInflightResolve(cacheKey, factory) {
47410
47414
  }
47411
47415
 
47412
47416
  // src/files/read/resolve-file-for-read-core.ts
47413
- import fs52 from "node:fs";
47417
+ import fs53 from "node:fs";
47414
47418
  import { isMainThread as isMainThread4 } from "node:worker_threads";
47415
47419
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
47416
47420
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -47420,13 +47424,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
47420
47424
  let size;
47421
47425
  let mtimeMs;
47422
47426
  try {
47423
- const lstat = fs52.lstatSync(resolved);
47427
+ const lstat = fs53.lstatSync(resolved);
47424
47428
  if (lstat.isSymbolicLink()) {
47425
- real = fs52.realpathSync(resolved);
47429
+ real = fs53.realpathSync(resolved);
47426
47430
  if (!pathStaysUnderParent(real, sessionParentPath)) {
47427
47431
  return { error: "Path is outside working directory" };
47428
47432
  }
47429
- const stat2 = fs52.statSync(real);
47433
+ const stat2 = fs53.statSync(real);
47430
47434
  if (!stat2.isFile()) return { error: "Not a file" };
47431
47435
  size = stat2.size;
47432
47436
  mtimeMs = stat2.mtimeMs;
@@ -47454,13 +47458,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
47454
47458
  let size;
47455
47459
  let mtimeMs;
47456
47460
  try {
47457
- const lstat = await fs52.promises.lstat(resolved);
47461
+ const lstat = await fs53.promises.lstat(resolved);
47458
47462
  if (lstat.isSymbolicLink()) {
47459
- real = await fs52.promises.realpath(resolved);
47463
+ real = await fs53.promises.realpath(resolved);
47460
47464
  if (!pathStaysUnderParent(real, sessionParentPath)) {
47461
47465
  return { error: "Path is outside working directory" };
47462
47466
  }
47463
- const stat2 = await fs52.promises.stat(real);
47467
+ const stat2 = await fs53.promises.stat(real);
47464
47468
  if (!stat2.isFile()) return { error: "Not a file" };
47465
47469
  size = stat2.size;
47466
47470
  mtimeMs = stat2.mtimeMs;
@@ -47509,7 +47513,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
47509
47513
 
47510
47514
  // src/files/read/read-file-range-async.ts
47511
47515
  init_yield_to_event_loop();
47512
- import fs53 from "node:fs";
47516
+ import fs54 from "node:fs";
47513
47517
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
47514
47518
 
47515
47519
  // src/files/read/read-file-range-line-zero.ts
@@ -47623,8 +47627,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
47623
47627
 
47624
47628
  // src/files/read/read-file-range-async.ts
47625
47629
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
47626
- const fileSize = fileSizeIn ?? (await fs53.promises.stat(filePath)).size;
47627
- const fd = await fs53.promises.open(filePath, "r");
47630
+ const fileSize = fileSizeIn ?? (await fs54.promises.stat(filePath)).size;
47631
+ const fd = await fs54.promises.open(filePath, "r");
47628
47632
  const bufSize = 64 * 1024;
47629
47633
  const buf = Buffer.alloc(bufSize);
47630
47634
  const decoder = new StringDecoder2("utf8");
@@ -47725,7 +47729,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
47725
47729
  }
47726
47730
 
47727
47731
  // src/files/read/read-small-file-range-async.ts
47728
- import fs54 from "node:fs";
47732
+ import fs55 from "node:fs";
47729
47733
  import { isMainThread as isMainThread5 } from "node:worker_threads";
47730
47734
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
47731
47735
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -47755,7 +47759,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
47755
47759
  };
47756
47760
  }
47757
47761
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
47758
- const raw = fs54.readFileSync(filePath, "utf8");
47762
+ const raw = fs55.readFileSync(filePath, "utf8");
47759
47763
  const lines = raw.split(/\r?\n/);
47760
47764
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
47761
47765
  }
@@ -47763,28 +47767,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
47763
47767
  if (isMainThread5) {
47764
47768
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
47765
47769
  }
47766
- const raw = await fs54.promises.readFile(filePath, "utf8");
47770
+ const raw = await fs55.promises.readFile(filePath, "utf8");
47767
47771
  const lines = raw.split(/\r?\n/);
47768
47772
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
47769
47773
  }
47770
47774
 
47771
47775
  // src/files/read/read-file-buffer-full-async.ts
47772
47776
  init_yield_to_event_loop();
47773
- import fs55 from "node:fs";
47777
+ import fs56 from "node:fs";
47774
47778
  import { isMainThread as isMainThread6 } from "node:worker_threads";
47775
47779
  var READ_CHUNK_BYTES = 256 * 1024;
47776
47780
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
47777
47781
  async function readFileBufferFullAsync(filePath, knownSize) {
47778
47782
  if (isMainThread6) {
47779
- const size2 = knownSize ?? fs55.statSync(filePath).size;
47783
+ const size2 = knownSize ?? fs56.statSync(filePath).size;
47780
47784
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
47781
47785
  await yieldToEventLoop();
47782
- const buffer = fs55.readFileSync(filePath);
47786
+ const buffer = fs56.readFileSync(filePath);
47783
47787
  return { buffer, size: buffer.length };
47784
47788
  }
47785
47789
  }
47786
- const size = knownSize ?? (await fs55.promises.stat(filePath)).size;
47787
- const fd = await fs55.promises.open(filePath, "r");
47790
+ const size = knownSize ?? (await fs56.promises.stat(filePath)).size;
47791
+ const fd = await fs56.promises.open(filePath, "r");
47788
47792
  const chunks = [];
47789
47793
  let position = 0;
47790
47794
  let bytesSinceYield = 0;
@@ -47887,7 +47891,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
47887
47891
  }
47888
47892
  if (hasRange) {
47889
47893
  if (fileSize == null) {
47890
- const stat2 = await fs56.promises.stat(resolvedPath);
47894
+ const stat2 = await fs57.promises.stat(resolvedPath);
47891
47895
  fileSize = stat2.size;
47892
47896
  }
47893
47897
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -48185,12 +48189,12 @@ function parseOptionalInt2(raw) {
48185
48189
  return Number.isInteger(parsed) ? parsed : void 0;
48186
48190
  }
48187
48191
  function parseCodeNavParams(url2) {
48188
- const path82 = url2.searchParams.get("path") ?? "";
48192
+ const path84 = url2.searchParams.get("path") ?? "";
48189
48193
  const opRaw = url2.searchParams.get("op")?.trim();
48190
48194
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
48191
48195
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
48192
48196
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
48193
- return { path: path82, op, line, column };
48197
+ return { path: path84, op, line, column };
48194
48198
  }
48195
48199
  function parseCodeNavPath(url2) {
48196
48200
  const raw = url2.searchParams.get("path")?.trim();
@@ -48995,31 +48999,66 @@ function hasRunningTurn(turns) {
48995
48999
  }
48996
49000
 
48997
49001
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
48998
- import fs58 from "node:fs";
49002
+ import fs60 from "node:fs";
48999
49003
 
49000
49004
  // src/git/snapshot/capture.ts
49001
- import * as fs57 from "node:fs";
49002
- import * as path78 from "node:path";
49005
+ import * as fs59 from "node:fs";
49006
+ import * as path80 from "node:path";
49007
+
49008
+ // src/git/snapshot/apply-pre-turn-snapshot.ts
49009
+ import * as fs58 from "node:fs";
49010
+ async function applyPreTurnSnapshot(filePath, log2) {
49011
+ let data;
49012
+ try {
49013
+ data = JSON.parse(fs58.readFileSync(filePath, "utf8"));
49014
+ } catch (error40) {
49015
+ return { ok: false, error: error40 instanceof Error ? error40.message : String(error40) };
49016
+ }
49017
+ if (!Array.isArray(data.repos)) return { ok: false, error: "Invalid snapshot file" };
49018
+ let applyError = null;
49019
+ await forEachWithGitYield(data.repos, async (repo) => {
49020
+ if (applyError || !repo.path) return;
49021
+ const reset = await gitRun(repo.path, ["reset", "--hard", "HEAD"], log2, "reset --hard");
49022
+ if (!reset.ok) {
49023
+ applyError = reset;
49024
+ return;
49025
+ }
49026
+ const clean = await gitRun(repo.path, ["clean", "-fd"], log2, "clean -fd");
49027
+ if (!clean.ok) {
49028
+ applyError = clean;
49029
+ return;
49030
+ }
49031
+ if (repo.stashSha) {
49032
+ const applied = await gitRun(repo.path, ["stash", "apply", repo.stashSha], log2, "stash apply");
49033
+ if (!applied.ok) applyError = applied;
49034
+ }
49035
+ });
49036
+ if (applyError) return applyError;
49037
+ log2(`[snapshot] Restored pre-turn state for ${data.runId.slice(0, 8)}\u2026`);
49038
+ return { ok: true };
49039
+ }
49040
+
49041
+ // src/git/snapshot/resolve-repo-roots.ts
49042
+ import * as path79 from "node:path";
49003
49043
  async function resolveSnapshotRepoRoots(options) {
49004
49044
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
49005
49045
  if (worktreePaths?.length) {
49006
- const uniq = [...new Set(worktreePaths.map((p) => path78.resolve(p)))];
49007
- return uniq;
49046
+ const paths = [...new Set(worktreePaths.map((p) => path79.resolve(p)))];
49047
+ return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
49008
49048
  }
49009
49049
  try {
49010
- const repos = await discoverGitReposUnderRoot(fallbackCwd);
49011
- const mapped = repos.map((r) => r.absolutePath);
49050
+ const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
49012
49051
  const sid = sessionId?.trim();
49013
- if (sid) {
49014
- const filtered = mapped.filter((root) => path78.basename(root) === sid);
49015
- if (filtered.length > 0) return filtered;
49016
- }
49017
- return mapped;
49018
- } catch (e) {
49019
- log2(`[snapshot] Discover repositories failed: ${e instanceof Error ? e.message : String(e)}`);
49052
+ if (!sid) return roots;
49053
+ const sessionRoots = roots.filter((root) => path79.basename(root) === sid);
49054
+ return sessionRoots.length > 0 ? sessionRoots : roots;
49055
+ } catch (error40) {
49056
+ log2(`[snapshot] Discover repositories failed: ${error40 instanceof Error ? error40.message : String(error40)}`);
49020
49057
  return [];
49021
49058
  }
49022
49059
  }
49060
+
49061
+ // src/git/snapshot/capture.ts
49023
49062
  async function capturePreTurnSnapshot(options) {
49024
49063
  const { runId, repoRoots, agentCwd, log: log2 } = options;
49025
49064
  if (!runId || !repoRoots.length) {
@@ -49033,7 +49072,7 @@ async function capturePreTurnSnapshot(options) {
49033
49072
  });
49034
49073
  const dir = snapshotsDirForCwd(agentCwd);
49035
49074
  try {
49036
- fs57.mkdirSync(dir, { recursive: true });
49075
+ fs59.mkdirSync(dir, { recursive: true });
49037
49076
  } catch (e) {
49038
49077
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
49039
49078
  }
@@ -49042,9 +49081,9 @@ async function capturePreTurnSnapshot(options) {
49042
49081
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
49043
49082
  repos
49044
49083
  };
49045
- const filePath = path78.join(dir, `${runId}.json`);
49084
+ const filePath = path80.join(dir, `${runId}.json`);
49046
49085
  try {
49047
- fs57.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
49086
+ fs59.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
49048
49087
  } catch (e) {
49049
49088
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
49050
49089
  }
@@ -49054,39 +49093,6 @@ async function capturePreTurnSnapshot(options) {
49054
49093
  );
49055
49094
  return { ok: true, filePath, repos };
49056
49095
  }
49057
- async function applyPreTurnSnapshot(filePath, log2) {
49058
- let data;
49059
- try {
49060
- const raw = fs57.readFileSync(filePath, "utf8");
49061
- data = JSON.parse(raw);
49062
- } catch (e) {
49063
- return { ok: false, error: e instanceof Error ? e.message : String(e) };
49064
- }
49065
- if (!Array.isArray(data.repos)) {
49066
- return { ok: false, error: "Invalid snapshot file" };
49067
- }
49068
- let applyError = null;
49069
- await forEachWithGitYield(data.repos, async (r) => {
49070
- if (applyError || !r.path) return;
49071
- const reset = await gitRun(r.path, ["reset", "--hard", "HEAD"], log2, "reset --hard");
49072
- if (!reset.ok) {
49073
- applyError = reset;
49074
- return;
49075
- }
49076
- const clean = await gitRun(r.path, ["clean", "-fd"], log2, "clean -fd");
49077
- if (!clean.ok) {
49078
- applyError = clean;
49079
- return;
49080
- }
49081
- if (r.stashSha) {
49082
- const ap = await gitRun(r.path, ["stash", "apply", r.stashSha], log2, "stash apply");
49083
- if (!ap.ok) applyError = ap;
49084
- }
49085
- });
49086
- if (applyError) return applyError;
49087
- log2(`[snapshot] Restored pre-turn state for ${data.runId.slice(0, 8)}\u2026`);
49088
- return { ok: true };
49089
- }
49090
49096
 
49091
49097
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
49092
49098
  async function runLocalRevertBeforeQueuedPrompt(next, deps) {
@@ -49097,7 +49103,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
49097
49103
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
49098
49104
  const file2 = snapshotFilePath(agentBase, tid);
49099
49105
  try {
49100
- await fs58.promises.access(file2, fs58.constants.F_OK);
49106
+ await fs60.promises.access(file2, fs60.constants.F_OK);
49101
49107
  } catch {
49102
49108
  deps.log(
49103
49109
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -49246,8 +49252,8 @@ async function runBridgePromptPreamble(params) {
49246
49252
  log: log2
49247
49253
  });
49248
49254
  if (s && sessionId) {
49249
- const cliGitBranch = await readGitBranch(effectiveCwd);
49250
49255
  const usesWt = sessionWorktreeManager.usesWorktreeSession(sessionId);
49256
+ const cliGitBranch = repoRoots.length > 0 ? await readGitBranch(effectiveCwd) : null;
49251
49257
  const isolatedSessionParentPath = sessionWorktreeManager.getIsolatedSessionParentPathForSession(sessionId);
49252
49258
  sendWsMessage(s, {
49253
49259
  type: "session_git_context_report",
@@ -49689,7 +49695,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
49689
49695
  };
49690
49696
 
49691
49697
  // src/routing/handlers/revert-turn-snapshot.ts
49692
- import * as fs59 from "node:fs";
49698
+ import * as fs61 from "node:fs";
49693
49699
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
49694
49700
  const id = typeof msg.id === "string" ? msg.id : "";
49695
49701
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -49702,7 +49708,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
49702
49708
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
49703
49709
  const file2 = snapshotFilePath(agentBase, turnId);
49704
49710
  try {
49705
- await fs59.promises.access(file2, fs59.constants.F_OK);
49711
+ await fs61.promises.access(file2, fs61.constants.F_OK);
49706
49712
  } catch {
49707
49713
  sendWsMessage(s, {
49708
49714
  type: "revert_turn_snapshot_result",
@@ -49800,8 +49806,8 @@ function isValidRemoteSkillInstallItem(item) {
49800
49806
 
49801
49807
  // src/skills/install/install-remote-skills-async.ts
49802
49808
  init_yield_to_event_loop();
49803
- import fs60 from "node:fs";
49804
- import path79 from "node:path";
49809
+ import fs62 from "node:fs";
49810
+ import path81 from "node:path";
49805
49811
 
49806
49812
  // src/skills/install/constants.ts
49807
49813
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -49812,12 +49818,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
49812
49818
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
49813
49819
  await yieldToEventLoop();
49814
49820
  }
49815
- const dest = path79.join(skillDir, f.path);
49816
- await fs60.promises.mkdir(path79.dirname(dest), { recursive: true });
49821
+ const dest = path81.join(skillDir, f.path);
49822
+ await fs62.promises.mkdir(path81.dirname(dest), { recursive: true });
49817
49823
  if (f.text !== void 0) {
49818
- await fs60.promises.writeFile(dest, f.text, "utf8");
49824
+ await fs62.promises.writeFile(dest, f.text, "utf8");
49819
49825
  } else if (f.base64) {
49820
- await fs60.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
49826
+ await fs62.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
49821
49827
  }
49822
49828
  }
49823
49829
  async function installRemoteSkillsAsync(cwd, targetDir, items) {
@@ -49829,7 +49835,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
49829
49835
  try {
49830
49836
  for (const item of items) {
49831
49837
  if (!isValidRemoteSkillInstallItem(item)) continue;
49832
- const skillDir = path79.join(cwd, targetDir, item.skillName);
49838
+ const skillDir = path81.join(cwd, targetDir, item.skillName);
49833
49839
  for (const f of item.files) {
49834
49840
  await writeInstallFileAsync(skillDir, f, filesWritten);
49835
49841
  }
@@ -50136,13 +50142,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
50136
50142
 
50137
50143
  // src/files/handle-file-browser-search.ts
50138
50144
  init_yield_to_event_loop();
50139
- import path80 from "node:path";
50145
+ import path82 from "node:path";
50140
50146
  var SEARCH_LIMIT = 100;
50141
50147
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
50142
50148
  void (async () => {
50143
50149
  await yieldToEventLoop();
50144
50150
  const q = typeof msg.q === "string" ? msg.q : "";
50145
- const sessionParentPath = path80.resolve(
50151
+ const sessionParentPath = path82.resolve(
50146
50152
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
50147
50153
  );
50148
50154
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -50240,7 +50246,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
50240
50246
  }
50241
50247
 
50242
50248
  // src/git/bridge-git-context.ts
50243
- import * as path81 from "node:path";
50249
+ import * as path83 from "node:path";
50244
50250
  init_yield_to_event_loop();
50245
50251
 
50246
50252
  // src/git/branches/get-current-branch.ts
@@ -50291,12 +50297,12 @@ async function listRepoBranchRefs(repoPath) {
50291
50297
  // src/git/bridge-git-context.ts
50292
50298
  function folderNameForRelPath(relPath, bridgeRoot) {
50293
50299
  if (relPath === "." || relPath === "") {
50294
- return path81.basename(path81.resolve(bridgeRoot)) || "repo";
50300
+ return path83.basename(path83.resolve(bridgeRoot)) || "repo";
50295
50301
  }
50296
- return path81.basename(relPath) || relPath;
50302
+ return path83.basename(relPath) || relPath;
50297
50303
  }
50298
50304
  async function discoverGitReposForBridgeContext(bridgeRoot) {
50299
- const root = path81.resolve(bridgeRoot);
50305
+ const root = path83.resolve(bridgeRoot);
50300
50306
  if (await isGitRepoDirectory(root)) {
50301
50307
  const remoteUrl = await getRemoteOriginUrl(root);
50302
50308
  return [{ absolutePath: root, remoteUrl }];
@@ -50304,19 +50310,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
50304
50310
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
50305
50311
  const byPath = /* @__PURE__ */ new Map();
50306
50312
  for (const repo of [...deep, ...shallow]) {
50307
- byPath.set(path81.resolve(repo.absolutePath), repo);
50313
+ byPath.set(path83.resolve(repo.absolutePath), repo);
50308
50314
  }
50309
50315
  return [...byPath.values()];
50310
50316
  }
50311
50317
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
50312
- const bridgeResolved = path81.resolve(bridgeRoot);
50318
+ const bridgeResolved = path83.resolve(bridgeRoot);
50313
50319
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
50314
50320
  const rows = [];
50315
50321
  for (let i = 0; i < repos.length; i++) {
50316
50322
  if (i > 0) await yieldToEventLoop();
50317
50323
  const repo = repos[i];
50318
- let rel = path81.relative(bridgeResolved, repo.absolutePath);
50319
- if (rel.startsWith("..") || path81.isAbsolute(rel)) continue;
50324
+ let rel = path83.relative(bridgeResolved, repo.absolutePath);
50325
+ if (rel.startsWith("..") || path83.isAbsolute(rel)) continue;
50320
50326
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
50321
50327
  const currentBranch = await getCurrentBranch(repo.absolutePath);
50322
50328
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -50331,11 +50337,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
50331
50337
  return rows;
50332
50338
  }
50333
50339
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
50334
- const bridgeResolved = path81.resolve(bridgeRoot);
50340
+ const bridgeResolved = path83.resolve(bridgeRoot);
50335
50341
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
50336
- const repoPath = rel === "" ? bridgeResolved : path81.join(bridgeResolved, rel);
50337
- const resolved = path81.resolve(repoPath);
50338
- if (!resolved.startsWith(bridgeResolved + path81.sep) && resolved !== bridgeResolved) {
50342
+ const repoPath = rel === "" ? bridgeResolved : path83.join(bridgeResolved, rel);
50343
+ const resolved = path83.resolve(repoPath);
50344
+ if (!resolved.startsWith(bridgeResolved + path83.sep) && resolved !== bridgeResolved) {
50339
50345
  return [];
50340
50346
  }
50341
50347
  return listRepoBranchRefs(resolved);