@buildautomaton/cli 0.1.68 → 0.1.69

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: path80, errorMaps, issueData } = params;
4212
- const fullPath = [...path80, ...issueData.path || []];
4211
+ const { data, path: path82, errorMaps, issueData } = params;
4212
+ const fullPath = [...path82, ...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, path80, key) {
4520
+ constructor(parent, value, path82, key) {
4521
4521
  this._cachedPath = [];
4522
4522
  this.parent = parent;
4523
4523
  this.data = value;
4524
- this._path = path80;
4524
+ this._path = path82;
4525
4525
  this._key = key;
4526
4526
  }
4527
4527
  get path() {
@@ -8182,10 +8182,10 @@ function assignProp(target, prop, value) {
8182
8182
  configurable: true
8183
8183
  });
8184
8184
  }
8185
- function getElementAtPath(obj, path80) {
8186
- if (!path80)
8185
+ function getElementAtPath(obj, path82) {
8186
+ if (!path82)
8187
8187
  return obj;
8188
- return path80.reduce((acc, key) => acc?.[key], obj);
8188
+ return path82.reduce((acc, key) => acc?.[key], obj);
8189
8189
  }
8190
8190
  function promiseAllObject(promisesObj) {
8191
8191
  const keys = Object.keys(promisesObj);
@@ -8434,11 +8434,11 @@ function aborted(x, startIndex = 0) {
8434
8434
  }
8435
8435
  return false;
8436
8436
  }
8437
- function prefixIssues(path80, issues) {
8437
+ function prefixIssues(path82, issues) {
8438
8438
  return issues.map((iss) => {
8439
8439
  var _a2;
8440
8440
  (_a2 = iss).path ?? (_a2.path = []);
8441
- iss.path.unshift(path80);
8441
+ iss.path.unshift(path82);
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, path80 = []) => {
8630
+ const processError = (error41, path82 = []) => {
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 = [...path80, ...issue2.path];
8640
+ const fullpath = [...path82, ...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(path80) {
8670
+ function toDotPath(path82) {
8671
8671
  const segs = [];
8672
- for (const seg of path80) {
8672
+ for (const seg of path82) {
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
  join(moduleDir, "..", sub, filename),
22377
22377
  join(moduleDir, "..", "..", "dist", sub, filename)
22378
22378
  ]);
22379
- const resolved = candidates.find((path80) => existsSync(path80));
22379
+ const resolved = candidates.find((path82) => existsSync(path82));
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(path80, checkUnignored, mode) {
23450
+ test(path82, 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(path80);
23459
+ const matched = rule[mode].test(path82);
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 = (path80, originalPath, doThrow) => {
23481
- if (!isString(path80)) {
23480
+ var checkPath = (path82, originalPath, doThrow) => {
23481
+ if (!isString(path82)) {
23482
23482
  return doThrow(
23483
23483
  `path must be a string, but got \`${originalPath}\``,
23484
23484
  TypeError
23485
23485
  );
23486
23486
  }
23487
- if (!path80) {
23487
+ if (!path82) {
23488
23488
  return doThrow(`path must not be empty`, TypeError);
23489
23489
  }
23490
- if (checkPath.isNotRelative(path80)) {
23490
+ if (checkPath.isNotRelative(path82)) {
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 = (path80) => REGEX_TEST_INVALID_PATH.test(path80);
23499
+ var isNotRelative = (path82) => REGEX_TEST_INVALID_PATH.test(path82);
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 path80 = originalPath && checkPath.convert(originalPath);
23529
+ const path82 = originalPath && checkPath.convert(originalPath);
23530
23530
  checkPath(
23531
- path80,
23531
+ path82,
23532
23532
  originalPath,
23533
23533
  this._strictPathCheck ? throwError : RETURN_FALSE
23534
23534
  );
23535
- return this._t(path80, cache2, checkUnignored, slices);
23535
+ return this._t(path82, cache2, checkUnignored, slices);
23536
23536
  }
23537
- checkIgnore(path80) {
23538
- if (!REGEX_TEST_TRAILING_SLASH.test(path80)) {
23539
- return this.test(path80);
23537
+ checkIgnore(path82) {
23538
+ if (!REGEX_TEST_TRAILING_SLASH.test(path82)) {
23539
+ return this.test(path82);
23540
23540
  }
23541
- const slices = path80.split(SLASH).filter(Boolean);
23541
+ const slices = path82.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(path80, false, MODE_CHECK_IGNORE);
23554
+ return this._rules.test(path82, false, MODE_CHECK_IGNORE);
23555
23555
  }
23556
- _t(path80, cache2, checkUnignored, slices) {
23557
- if (path80 in cache2) {
23558
- return cache2[path80];
23556
+ _t(path82, cache2, checkUnignored, slices) {
23557
+ if (path82 in cache2) {
23558
+ return cache2[path82];
23559
23559
  }
23560
23560
  if (!slices) {
23561
- slices = path80.split(SLASH).filter(Boolean);
23561
+ slices = path82.split(SLASH).filter(Boolean);
23562
23562
  }
23563
23563
  slices.pop();
23564
23564
  if (!slices.length) {
23565
- return cache2[path80] = this._rules.test(path80, checkUnignored, MODE_IGNORE);
23565
+ return cache2[path82] = this._rules.test(path82, 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[path80] = parent.ignored ? parent : this._rules.test(path80, checkUnignored, MODE_IGNORE);
23573
+ return cache2[path82] = parent.ignored ? parent : this._rules.test(path82, checkUnignored, MODE_IGNORE);
23574
23574
  }
23575
- ignores(path80) {
23576
- return this._test(path80, this._ignoreCache, false).ignored;
23575
+ ignores(path82) {
23576
+ return this._test(path82, this._ignoreCache, false).ignored;
23577
23577
  }
23578
23578
  createFilter() {
23579
- return (path80) => !this.ignores(path80);
23579
+ return (path82) => !this.ignores(path82);
23580
23580
  }
23581
23581
  filter(paths) {
23582
23582
  return makeArray(paths).filter(this.createFilter());
23583
23583
  }
23584
23584
  // @returns {TestResult}
23585
- test(path80) {
23586
- return this._test(path80, this._testCache, true);
23585
+ test(path82) {
23586
+ return this._test(path82, this._testCache, true);
23587
23587
  }
23588
23588
  };
23589
23589
  var factory = (options) => new Ignore(options);
23590
- var isPathValid = (path80) => checkPath(path80 && checkPath.convert(path80), path80, RETURN_FALSE);
23590
+ var isPathValid = (path82) => checkPath(path82 && checkPath.convert(path82), path82, 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 = (path80) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path80) || isNotRelative(path80);
23595
+ checkPath.isNotRelative = (path82) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path82) || isNotRelative(path82);
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(path80, isFile, isDirectory) {
27964
- log2(`checking %s`, path80);
27963
+ function check2(path82, isFile, isDirectory) {
27964
+ log2(`checking %s`, path82);
27965
27965
  try {
27966
- const stat2 = fs_1.statSync(path80);
27966
+ const stat2 = fs_1.statSync(path82);
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(path80, type = exports.READABLE) {
27987
- return check2(path80, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27986
+ function exists2(path82, type = exports.READABLE) {
27987
+ return check2(path82, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27988
27988
  }
27989
27989
  exports.exists = exists2;
27990
27990
  exports.FILE = 1;
@@ -30338,8 +30338,8 @@ function randomSecret() {
30338
30338
  }
30339
30339
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
30340
30340
  }
30341
- async function requestPreviewApi(port, secret, method, path80, body) {
30342
- const url2 = `http://127.0.0.1:${port}${path80}`;
30341
+ async function requestPreviewApi(port, secret, method, path82, body) {
30342
+ const url2 = `http://127.0.0.1:${port}${path82}`;
30343
30343
  const headers = {
30344
30344
  [PREVIEW_SECRET_HEADER]: secret,
30345
30345
  "Content-Type": "application/json"
@@ -30351,7 +30351,7 @@ async function requestPreviewApi(port, secret, method, path80, body) {
30351
30351
  });
30352
30352
  const data = await res.json().catch(() => ({}));
30353
30353
  if (!res.ok) {
30354
- throw new Error(data?.error ?? `Preview API ${method} ${path80}: ${res.status}`);
30354
+ throw new Error(data?.error ?? `Preview API ${method} ${path82}: ${res.status}`);
30355
30355
  }
30356
30356
  return data;
30357
30357
  }
@@ -30574,7 +30574,7 @@ function installBridgeProcessResilience() {
30574
30574
  }
30575
30575
 
30576
30576
  // src/cli-version.ts
30577
- var CLI_VERSION = "0.1.68".length > 0 ? "0.1.68" : "0.0.0-dev";
30577
+ var CLI_VERSION = "0.1.69".length > 0 ? "0.1.69" : "0.0.0-dev";
30578
30578
 
30579
30579
  // src/connection/heartbeat/constants.ts
30580
30580
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -34971,8 +34971,8 @@ async function execGitFile(args, options) {
34971
34971
  }
34972
34972
 
34973
34973
  // src/git/changes/parse/normalize-git-diff-path.ts
34974
- function normalizeGitDiffPath(path80) {
34975
- return path80.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
34974
+ function normalizeGitDiffPath(path82) {
34975
+ return path82.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
34976
34976
  }
34977
34977
 
34978
34978
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -36481,6 +36481,21 @@ function createBridgeMcpToolRegistry(shared) {
36481
36481
  // src/mcp/bridge-access/start-server.ts
36482
36482
  import * as http from "node:http";
36483
36483
 
36484
+ // src/http/close-http-server.ts
36485
+ function isServerNotRunningError(err) {
36486
+ return err.code === "ERR_SERVER_NOT_RUNNING";
36487
+ }
36488
+ function closeHttpServer(server) {
36489
+ if (!server) return Promise.resolve();
36490
+ return new Promise((resolve35) => {
36491
+ server.close((err) => {
36492
+ if (err && !isServerNotRunningError(err)) {
36493
+ }
36494
+ resolve35();
36495
+ });
36496
+ });
36497
+ }
36498
+
36484
36499
  // src/mcp/bridge-access/read-json-body.ts
36485
36500
  function readJsonBody(req) {
36486
36501
  return new Promise((resolve35, reject) => {
@@ -36562,9 +36577,7 @@ function startBridgeAccessServer(registry2) {
36562
36577
  }
36563
36578
  resolve35({
36564
36579
  port: addr.port,
36565
- close: () => new Promise((closeResolve, closeReject) => {
36566
- server.close((err) => err ? closeReject(err) : closeResolve());
36567
- })
36580
+ close: () => closeHttpServer(server)
36568
36581
  });
36569
36582
  });
36570
36583
  });
@@ -39169,8 +39182,8 @@ function pathspec(...paths) {
39169
39182
  cache.set(key, paths);
39170
39183
  return key;
39171
39184
  }
39172
- function isPathSpec(path80) {
39173
- return path80 instanceof String && cache.has(path80);
39185
+ function isPathSpec(path82) {
39186
+ return path82 instanceof String && cache.has(path82);
39174
39187
  }
39175
39188
  function toPaths(pathSpec) {
39176
39189
  return cache.get(pathSpec) || [];
@@ -39259,8 +39272,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
39259
39272
  function forEachLineWithContent(input, callback) {
39260
39273
  return toLinesWithContent(input, true).map((line) => callback(line));
39261
39274
  }
39262
- function folderExists(path80) {
39263
- return (0, import_file_exists.exists)(path80, import_file_exists.FOLDER);
39275
+ function folderExists(path82) {
39276
+ return (0, import_file_exists.exists)(path82, import_file_exists.FOLDER);
39264
39277
  }
39265
39278
  function append(target, item) {
39266
39279
  if (Array.isArray(target)) {
@@ -39664,8 +39677,8 @@ function checkIsRepoRootTask() {
39664
39677
  commands,
39665
39678
  format: "utf-8",
39666
39679
  onError,
39667
- parser(path80) {
39668
- return /^\.(git)?$/.test(path80.trim());
39680
+ parser(path82) {
39681
+ return /^\.(git)?$/.test(path82.trim());
39669
39682
  }
39670
39683
  };
39671
39684
  }
@@ -40099,11 +40112,11 @@ function parseGrep(grep) {
40099
40112
  const paths = /* @__PURE__ */ new Set();
40100
40113
  const results = {};
40101
40114
  forEachLineWithContent(grep, (input) => {
40102
- const [path80, line, preview] = input.split(NULL);
40103
- paths.add(path80);
40104
- (results[path80] = results[path80] || []).push({
40115
+ const [path82, line, preview] = input.split(NULL);
40116
+ paths.add(path82);
40117
+ (results[path82] = results[path82] || []).push({
40105
40118
  line: asNumber(line),
40106
- path: path80,
40119
+ path: path82,
40107
40120
  preview
40108
40121
  });
40109
40122
  });
@@ -40868,14 +40881,14 @@ var init_hash_object = __esm2({
40868
40881
  init_task();
40869
40882
  }
40870
40883
  });
40871
- function parseInit(bare, path80, text) {
40884
+ function parseInit(bare, path82, text) {
40872
40885
  const response = String(text).trim();
40873
40886
  let result;
40874
40887
  if (result = initResponseRegex.exec(response)) {
40875
- return new InitSummary(bare, path80, false, result[1]);
40888
+ return new InitSummary(bare, path82, false, result[1]);
40876
40889
  }
40877
40890
  if (result = reInitResponseRegex.exec(response)) {
40878
- return new InitSummary(bare, path80, true, result[1]);
40891
+ return new InitSummary(bare, path82, true, result[1]);
40879
40892
  }
40880
40893
  let gitDir = "";
40881
40894
  const tokens = response.split(" ");
@@ -40886,7 +40899,7 @@ function parseInit(bare, path80, text) {
40886
40899
  break;
40887
40900
  }
40888
40901
  }
40889
- return new InitSummary(bare, path80, /^re/i.test(response), gitDir);
40902
+ return new InitSummary(bare, path82, /^re/i.test(response), gitDir);
40890
40903
  }
40891
40904
  var InitSummary;
40892
40905
  var initResponseRegex;
@@ -40895,9 +40908,9 @@ var init_InitSummary = __esm2({
40895
40908
  "src/lib/responses/InitSummary.ts"() {
40896
40909
  "use strict";
40897
40910
  InitSummary = class {
40898
- constructor(bare, path80, existing, gitDir) {
40911
+ constructor(bare, path82, existing, gitDir) {
40899
40912
  this.bare = bare;
40900
- this.path = path80;
40913
+ this.path = path82;
40901
40914
  this.existing = existing;
40902
40915
  this.gitDir = gitDir;
40903
40916
  }
@@ -40909,7 +40922,7 @@ var init_InitSummary = __esm2({
40909
40922
  function hasBareCommand(command) {
40910
40923
  return command.includes(bareCommand);
40911
40924
  }
40912
- function initTask(bare = false, path80, customArgs) {
40925
+ function initTask(bare = false, path82, customArgs) {
40913
40926
  const commands = ["init", ...customArgs];
40914
40927
  if (bare && !hasBareCommand(commands)) {
40915
40928
  commands.splice(1, 0, bareCommand);
@@ -40918,7 +40931,7 @@ function initTask(bare = false, path80, customArgs) {
40918
40931
  commands,
40919
40932
  format: "utf-8",
40920
40933
  parser(text) {
40921
- return parseInit(commands.includes("--bare"), path80, text);
40934
+ return parseInit(commands.includes("--bare"), path82, text);
40922
40935
  }
40923
40936
  };
40924
40937
  }
@@ -41734,12 +41747,12 @@ var init_FileStatusSummary = __esm2({
41734
41747
  "use strict";
41735
41748
  fromPathRegex = /^(.+)\0(.+)$/;
41736
41749
  FileStatusSummary = class {
41737
- constructor(path80, index, working_dir) {
41738
- this.path = path80;
41750
+ constructor(path82, index, working_dir) {
41751
+ this.path = path82;
41739
41752
  this.index = index;
41740
41753
  this.working_dir = working_dir;
41741
41754
  if (index === "R" || working_dir === "R") {
41742
- const detail = fromPathRegex.exec(path80) || [null, path80, path80];
41755
+ const detail = fromPathRegex.exec(path82) || [null, path82, path82];
41743
41756
  this.from = detail[2] || "";
41744
41757
  this.path = detail[1] || "";
41745
41758
  }
@@ -41770,14 +41783,14 @@ function splitLine(result, lineStr) {
41770
41783
  default:
41771
41784
  return;
41772
41785
  }
41773
- function data(index, workingDir, path80) {
41786
+ function data(index, workingDir, path82) {
41774
41787
  const raw = `${index}${workingDir}`;
41775
41788
  const handler = parsers6.get(raw);
41776
41789
  if (handler) {
41777
- handler(result, path80);
41790
+ handler(result, path82);
41778
41791
  }
41779
41792
  if (raw !== "##" && raw !== "!!") {
41780
- result.files.push(new FileStatusSummary(path80, index, workingDir));
41793
+ result.files.push(new FileStatusSummary(path82, index, workingDir));
41781
41794
  }
41782
41795
  }
41783
41796
  }
@@ -42086,9 +42099,9 @@ var init_simple_git_api = __esm2({
42086
42099
  next
42087
42100
  );
42088
42101
  }
42089
- hashObject(path80, write) {
42102
+ hashObject(path82, write) {
42090
42103
  return this._runTask(
42091
- hashObjectTask(path80, write === true),
42104
+ hashObjectTask(path82, write === true),
42092
42105
  trailingFunctionArgument(arguments)
42093
42106
  );
42094
42107
  }
@@ -42441,8 +42454,8 @@ var init_branch = __esm2({
42441
42454
  }
42442
42455
  });
42443
42456
  function toPath(input) {
42444
- const path80 = input.trim().replace(/^["']|["']$/g, "");
42445
- return path80 && normalize3(path80);
42457
+ const path82 = input.trim().replace(/^["']|["']$/g, "");
42458
+ return path82 && normalize3(path82);
42446
42459
  }
42447
42460
  var parseCheckIgnore;
42448
42461
  var init_CheckIgnore = __esm2({
@@ -42756,8 +42769,8 @@ __export2(sub_module_exports, {
42756
42769
  subModuleTask: () => subModuleTask,
42757
42770
  updateSubModuleTask: () => updateSubModuleTask
42758
42771
  });
42759
- function addSubModuleTask(repo, path80) {
42760
- return subModuleTask(["add", repo, path80]);
42772
+ function addSubModuleTask(repo, path82) {
42773
+ return subModuleTask(["add", repo, path82]);
42761
42774
  }
42762
42775
  function initSubModuleTask(customArgs) {
42763
42776
  return subModuleTask(["init", ...customArgs]);
@@ -43090,8 +43103,8 @@ var require_git = __commonJS2({
43090
43103
  }
43091
43104
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
43092
43105
  };
43093
- Git2.prototype.submoduleAdd = function(repo, path80, then) {
43094
- return this._runTask(addSubModuleTask2(repo, path80), trailingFunctionArgument2(arguments));
43106
+ Git2.prototype.submoduleAdd = function(repo, path82, then) {
43107
+ return this._runTask(addSubModuleTask2(repo, path82), trailingFunctionArgument2(arguments));
43095
43108
  };
43096
43109
  Git2.prototype.submoduleUpdate = function(args, then) {
43097
43110
  return this._runTask(
@@ -43830,8 +43843,8 @@ function parseNumstatEntries(lines) {
43830
43843
  }
43831
43844
  function parseNumstat(lines) {
43832
43845
  const m = /* @__PURE__ */ new Map();
43833
- for (const [path80, entry] of parseNumstatEntries(lines)) {
43834
- m.set(path80, { additions: entry.additions, deletions: entry.deletions });
43846
+ for (const [path82, entry] of parseNumstatEntries(lines)) {
43847
+ m.set(path82, { additions: entry.additions, deletions: entry.deletions });
43835
43848
  }
43836
43849
  return m;
43837
43850
  }
@@ -45626,9 +45639,8 @@ function parseSessionParent(v) {
45626
45639
  return null;
45627
45640
  }
45628
45641
 
45629
- // src/worktrees/prepare-new-isolated-worktrees.ts
45630
- import * as fs44 from "node:fs";
45631
- import * as path64 from "node:path";
45642
+ // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
45643
+ import * as fs46 from "node:fs";
45632
45644
 
45633
45645
  // src/git/discover-repos.ts
45634
45646
  import * as fs43 from "node:fs";
@@ -45699,6 +45711,10 @@ async function discoverGitReposUnderRoot(rootPath) {
45699
45711
  return out;
45700
45712
  }
45701
45713
 
45714
+ // src/worktrees/prepare/add-isolated-repo-worktree.ts
45715
+ import * as fs45 from "node:fs";
45716
+ import * as path65 from "node:path";
45717
+
45702
45718
  // src/git/worktrees/worktree-add.ts
45703
45719
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
45704
45720
  const mainGit = cliSimpleGit(mainRepoPath);
@@ -45712,6 +45728,100 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
45712
45728
  await mainGit.raw(["worktree", "add", worktreePath, branch]);
45713
45729
  }
45714
45730
 
45731
+ // src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
45732
+ import * as fs44 from "node:fs";
45733
+ import * as path64 from "node:path";
45734
+ var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
45735
+ function copyBridgeFilesAlongWorktreePath(options) {
45736
+ const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
45737
+ const fileNames = options.fileNames ?? BRIDGE_FILES_ALONG_WORKTREE_PATH;
45738
+ if (repoPathRelativeToBridgeRoot === ".") return;
45739
+ const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
45740
+ for (let i = 0; i < segments.length; i++) {
45741
+ const prefix = segments.slice(0, i).join("/");
45742
+ const bridgeDir = prefix ? path64.join(bridgeRoot, prefix) : bridgeRoot;
45743
+ const destDir = prefix ? path64.join(scopeDir, prefix) : scopeDir;
45744
+ for (const fileName of fileNames) {
45745
+ copyFileIfPresent(bridgeDir, destDir, fileName, log2);
45746
+ }
45747
+ }
45748
+ }
45749
+ function copyFileIfPresent(srcDir, destDir, fileName, log2) {
45750
+ const src = path64.join(srcDir, fileName);
45751
+ if (!fs44.existsSync(src)) return;
45752
+ const dest = path64.join(destDir, fileName);
45753
+ try {
45754
+ fs44.copyFileSync(src, dest);
45755
+ log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
45756
+ } catch (e) {
45757
+ log2?.(
45758
+ `[worktrees] Failed to copy ${fileName} to ${dest}: ${e instanceof Error ? e.message : String(e)}`
45759
+ );
45760
+ }
45761
+ }
45762
+
45763
+ // src/worktrees/prepare/resolve-base-ref-for-repo.ts
45764
+ function resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, baseBranches) {
45765
+ if (!baseBranches) return "HEAD";
45766
+ const direct = baseBranches[repoPathRelativeToBridgeRoot]?.trim();
45767
+ if (direct) return direct;
45768
+ if (repoPathRelativeToBridgeRoot !== "." && baseBranches["."]?.trim()) {
45769
+ return baseBranches["."].trim();
45770
+ }
45771
+ return "HEAD";
45772
+ }
45773
+
45774
+ // src/worktrees/prepare/add-isolated-repo-worktree.ts
45775
+ async function addIsolatedRepoWorktree(options) {
45776
+ const {
45777
+ kind,
45778
+ bridgeResolved,
45779
+ scopeDir,
45780
+ repoAbsolutePath,
45781
+ branch,
45782
+ existingBranch,
45783
+ worktreeBaseBranches,
45784
+ log: log2
45785
+ } = options;
45786
+ const repoPathRelativeToBridgeRootRaw = path65.relative(bridgeResolved, repoAbsolutePath);
45787
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path65.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
45788
+ return null;
45789
+ }
45790
+ const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
45791
+ repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
45792
+ );
45793
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path65.join(scopeDir, repoPathRelativeToBridgeRoot);
45794
+ if (repoPathRelativeToBridgeRoot !== ".") {
45795
+ fs45.mkdirSync(path65.dirname(worktreePath), { recursive: true });
45796
+ copyBridgeFilesAlongWorktreePath({
45797
+ bridgeRoot: bridgeResolved,
45798
+ scopeDir,
45799
+ repoPathRelativeToBridgeRoot,
45800
+ log: log2
45801
+ });
45802
+ }
45803
+ const checkoutBranch = existingBranch?.trim() || branch;
45804
+ try {
45805
+ if (existingBranch?.trim()) {
45806
+ await gitWorktreeAddExistingBranch(repoAbsolutePath, worktreePath, checkoutBranch);
45807
+ log2(`[worktrees] Added ${kind} worktree ${worktreePath} (existing branch ${checkoutBranch}).`);
45808
+ } else {
45809
+ const baseRef = resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, worktreeBaseBranches);
45810
+ await gitWorktreeAddBranch(repoAbsolutePath, worktreePath, branch, baseRef);
45811
+ log2(`[worktrees] Added ${kind} worktree ${worktreePath} (branch ${branch}, base ${baseRef}).`);
45812
+ }
45813
+ return worktreePath;
45814
+ } catch (e) {
45815
+ log2(
45816
+ `[worktrees] Worktree add failed for ${repoAbsolutePath}: ${e instanceof Error ? e.message : String(e)}`
45817
+ );
45818
+ return null;
45819
+ }
45820
+ }
45821
+
45822
+ // src/worktrees/prepare/resolve-isolated-scope-dir.ts
45823
+ import * as path66 from "node:path";
45824
+
45715
45825
  // src/worktrees/worktree-layout-kind.ts
45716
45826
  function sanitizeWorktreeBranchSegment(value) {
45717
45827
  return value.replace(/[^a-zA-Z0-9/_-]+/g, "-").slice(0, 80) || "worktree";
@@ -45738,16 +45848,16 @@ function previewDeployBranchName(environmentId) {
45738
45848
  return `preview-deploy-${sanitizeWorktreeBranchSegment(environmentId.trim())}`;
45739
45849
  }
45740
45850
 
45741
- // src/worktrees/prepare-new-isolated-worktrees.ts
45742
- function resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, baseBranches) {
45743
- if (!baseBranches) return "HEAD";
45744
- const direct = baseBranches[repoPathRelativeToBridgeRoot]?.trim();
45745
- if (direct) return direct;
45746
- if (repoPathRelativeToBridgeRoot !== "." && baseBranches["."]?.trim()) {
45747
- return baseBranches["."].trim();
45748
- }
45749
- return "HEAD";
45851
+ // src/worktrees/prepare/resolve-isolated-scope-dir.ts
45852
+ function resolveIsolatedScopeDir(options) {
45853
+ const bridgeResolved = path66.resolve(options.bridgeRoot);
45854
+ const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
45855
+ const bridgeKeyDir = path66.join(options.worktreesRootPath, cwdKey);
45856
+ const scopeDir = path66.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
45857
+ return { bridgeResolved, scopeDir };
45750
45858
  }
45859
+
45860
+ // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
45751
45861
  async function prepareNewIsolatedWorktrees(options) {
45752
45862
  const {
45753
45863
  kind,
@@ -45760,45 +45870,32 @@ async function prepareNewIsolatedWorktrees(options) {
45760
45870
  worktreeBaseBranches,
45761
45871
  existingBranch
45762
45872
  } = options;
45763
- const bridgeResolved = path64.resolve(bridgeRoot);
45764
- const cwdKey = allocateDirNameForLauncherCwd(layout, bridgeResolved);
45765
- const bridgeKeyDir = path64.join(worktreesRootPath, cwdKey);
45766
- const scopeDir = path64.join(bridgeKeyDir, ...layoutDirSegments(kind, scopeId));
45873
+ const { bridgeResolved, scopeDir } = resolveIsolatedScopeDir({
45874
+ worktreesRootPath,
45875
+ bridgeRoot,
45876
+ kind,
45877
+ scopeId,
45878
+ layout
45879
+ });
45767
45880
  const repos = await discoverGitReposUnderRoot(bridgeResolved);
45768
45881
  if (repos.length === 0) {
45769
45882
  log2(`[worktrees] No Git repositories under bridge root; skipping ${kind} worktree creation.`);
45770
45883
  return null;
45771
45884
  }
45772
45885
  const worktreePaths = [];
45773
- fs44.mkdirSync(scopeDir, { recursive: true });
45886
+ fs46.mkdirSync(scopeDir, { recursive: true });
45774
45887
  await forEachWithGitYield(repos, async (repo) => {
45775
- const repoPathRelativeToBridgeRootRaw = path64.relative(bridgeResolved, repo.absolutePath);
45776
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path64.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
45777
- return;
45778
- }
45779
- const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
45780
- repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
45781
- );
45782
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path64.join(scopeDir, repoPathRelativeToBridgeRoot);
45783
- if (repoPathRelativeToBridgeRoot !== ".") {
45784
- fs44.mkdirSync(path64.dirname(worktreePath), { recursive: true });
45785
- }
45786
- const checkoutBranch = existingBranch?.trim() || branch;
45787
- try {
45788
- if (existingBranch?.trim()) {
45789
- await gitWorktreeAddExistingBranch(repo.absolutePath, worktreePath, checkoutBranch);
45790
- log2(`[worktrees] Added ${kind} worktree ${worktreePath} (existing branch ${checkoutBranch}).`);
45791
- } else {
45792
- const baseRef = resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, worktreeBaseBranches);
45793
- await gitWorktreeAddBranch(repo.absolutePath, worktreePath, branch, baseRef);
45794
- log2(`[worktrees] Added ${kind} worktree ${worktreePath} (branch ${branch}, base ${baseRef}).`);
45795
- }
45796
- worktreePaths.push(worktreePath);
45797
- } catch (e) {
45798
- log2(
45799
- `[worktrees] Worktree add failed for ${repo.absolutePath}: ${e instanceof Error ? e.message : String(e)}`
45800
- );
45801
- }
45888
+ const worktreePath = await addIsolatedRepoWorktree({
45889
+ kind,
45890
+ bridgeResolved,
45891
+ scopeDir,
45892
+ repoAbsolutePath: repo.absolutePath,
45893
+ branch,
45894
+ existingBranch,
45895
+ worktreeBaseBranches,
45896
+ log: log2
45897
+ });
45898
+ if (worktreePath) worktreePaths.push(worktreePath);
45802
45899
  });
45803
45900
  if (worktreePaths.length === 0) return null;
45804
45901
  return {
@@ -45858,10 +45955,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
45858
45955
  }
45859
45956
 
45860
45957
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
45861
- import * as path65 from "node:path";
45958
+ import * as path67 from "node:path";
45862
45959
  init_yield_to_event_loop();
45863
45960
  async function resolveExplicitSessionParentPath(params) {
45864
- const resolved = path65.resolve(params.parentPathRaw);
45961
+ const resolved = path67.resolve(params.parentPathRaw);
45865
45962
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
45866
45963
  return resolved;
45867
45964
  }
@@ -45878,7 +45975,7 @@ async function resolveExplicitSessionParentPath(params) {
45878
45975
  await yieldToEventLoop();
45879
45976
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
45880
45977
  if (tryRoot) return rememberAndReturn(tryRoot);
45881
- const next = path65.dirname(cur);
45978
+ const next = path67.dirname(cur);
45882
45979
  if (next === cur) break;
45883
45980
  cur = next;
45884
45981
  }
@@ -46026,15 +46123,15 @@ var SessionWorktreeManager = class {
46026
46123
  };
46027
46124
 
46028
46125
  // src/worktrees/discovery/discover-preview-worktree-on-disk.ts
46029
- import * as fs45 from "node:fs";
46030
- import * as path66 from "node:path";
46126
+ import * as fs47 from "node:fs";
46127
+ import * as path68 from "node:path";
46031
46128
  init_yield_to_event_loop();
46032
46129
  async function discoverPreviewWorktreeOnDisk(options) {
46033
46130
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
46034
46131
  const eid = environmentId.trim();
46035
46132
  if (!eid) return null;
46036
46133
  try {
46037
- await fs45.promises.access(worktreesRootPath);
46134
+ await fs47.promises.access(worktreesRootPath);
46038
46135
  } catch {
46039
46136
  return null;
46040
46137
  }
@@ -46043,13 +46140,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
46043
46140
  if (preferredKey) keysOnDisk.push(preferredKey);
46044
46141
  const scanState = { entries: 0 };
46045
46142
  try {
46046
- for (const name of await fs45.promises.readdir(worktreesRootPath)) {
46143
+ for (const name of await fs47.promises.readdir(worktreesRootPath)) {
46047
46144
  if (!await yieldDuringDiskWalk(scanState)) break;
46048
46145
  if (name.startsWith(".")) continue;
46049
- const p = path66.join(worktreesRootPath, name);
46146
+ const p = path68.join(worktreesRootPath, name);
46050
46147
  let st;
46051
46148
  try {
46052
- st = await fs45.promises.stat(p);
46149
+ st = await fs47.promises.stat(p);
46053
46150
  } catch {
46054
46151
  continue;
46055
46152
  }
@@ -46063,7 +46160,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
46063
46160
  const previewDirRel = layoutDirSegments("preview_environment", eid);
46064
46161
  for (const key of keys) {
46065
46162
  await yieldToEventLoop();
46066
- const previewDir = path66.join(worktreesRootPath, key, ...previewDirRel);
46163
+ const previewDir = path68.join(worktreesRootPath, key, ...previewDirRel);
46067
46164
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
46068
46165
  if (binding) return binding;
46069
46166
  }
@@ -46190,7 +46287,7 @@ var PreviewWorktreeManager = class {
46190
46287
  };
46191
46288
 
46192
46289
  // src/worktrees/deploy/deploy-session-to-preview-environment.ts
46193
- import * as path70 from "node:path";
46290
+ import * as path72 from "node:path";
46194
46291
 
46195
46292
  // src/git/worktrees/reset-worktree-to-branch.ts
46196
46293
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -46201,8 +46298,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
46201
46298
  }
46202
46299
 
46203
46300
  // src/worktrees/deploy/capture-and-apply-wip.ts
46204
- import * as fs46 from "node:fs";
46205
- import * as path67 from "node:path";
46301
+ import * as fs48 from "node:fs";
46302
+ import * as path69 from "node:path";
46206
46303
 
46207
46304
  // src/git/snapshot/git.ts
46208
46305
  async function gitStashCreate(repoRoot, log2) {
@@ -46250,12 +46347,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
46250
46347
  if (!ap.ok) return ap;
46251
46348
  }
46252
46349
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
46253
- const src = path67.join(sourceRepoPath, rel);
46254
- const dst = path67.join(targetRepoPath, rel);
46350
+ const src = path69.join(sourceRepoPath, rel);
46351
+ const dst = path69.join(targetRepoPath, rel);
46255
46352
  try {
46256
- if (!fs46.existsSync(src)) return;
46257
- fs46.mkdirSync(path67.dirname(dst), { recursive: true });
46258
- fs46.copyFileSync(src, dst);
46353
+ if (!fs48.existsSync(src)) return;
46354
+ fs48.mkdirSync(path69.dirname(dst), { recursive: true });
46355
+ fs48.copyFileSync(src, dst);
46259
46356
  } catch (e) {
46260
46357
  log2(
46261
46358
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -46266,14 +46363,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
46266
46363
  }
46267
46364
 
46268
46365
  // src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
46269
- import * as path68 from "node:path";
46366
+ import * as path70 from "node:path";
46270
46367
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
46271
46368
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
46272
- const resolvedSessionParentPath = sessionParentPath ? path68.resolve(sessionParentPath) : null;
46369
+ const resolvedSessionParentPath = sessionParentPath ? path70.resolve(sessionParentPath) : null;
46273
46370
  let match = null;
46274
46371
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
46275
46372
  if (match) return;
46276
- const resolvedCheckoutPath = path68.resolve(checkoutPath);
46373
+ const resolvedCheckoutPath = path70.resolve(checkoutPath);
46277
46374
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
46278
46375
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
46279
46376
  checkoutPath: resolvedCheckoutPath,
@@ -46327,7 +46424,7 @@ async function applySessionWipToPreviewCheckouts(options) {
46327
46424
  }
46328
46425
 
46329
46426
  // src/worktrees/deploy/collect-session-repo-deploy-states.ts
46330
- import * as path69 from "node:path";
46427
+ import * as path71 from "node:path";
46331
46428
 
46332
46429
  // src/git/branches/create-or-update-branch.ts
46333
46430
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -46364,19 +46461,19 @@ async function collectSessionRepoDeployStates(options) {
46364
46461
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
46365
46462
  const states = [];
46366
46463
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
46367
- const checkoutPath = path69.resolve(sessionCheckout);
46464
+ const checkoutPath = path71.resolve(sessionCheckout);
46368
46465
  if (!await isGitRepoDirectory(checkoutPath)) return;
46369
46466
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
46370
46467
  checkoutPath,
46371
46468
  bridgeRoot,
46372
- sessionParentPath: sessionParentPath ? path69.resolve(sessionParentPath) : null
46469
+ sessionParentPath: sessionParentPath ? path71.resolve(sessionParentPath) : null
46373
46470
  });
46374
46471
  if (!repoPathRelativeToWorkspaceRoot) return;
46375
46472
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
46376
46473
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
46377
46474
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
46378
46475
  checkoutPaths: previewCheckoutPaths,
46379
- sessionParentPath: previewParentPath ? path69.resolve(previewParentPath) : null,
46476
+ sessionParentPath: previewParentPath ? path71.resolve(previewParentPath) : null,
46380
46477
  bridgeRoot,
46381
46478
  repoPathRelativeToWorkspaceRoot
46382
46479
  }) : null;
@@ -46396,7 +46493,7 @@ async function deploySessionToPreviewEnvironment(options) {
46396
46493
  const eid = options.environmentId.trim();
46397
46494
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
46398
46495
  const deployBranch = previewDeployBranchName(eid);
46399
- const bridgeRoot = path70.resolve(getBridgeRoot());
46496
+ const bridgeRoot = path72.resolve(getBridgeRoot());
46400
46497
  await previewWorktreeManager.ensureCached(eid);
46401
46498
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
46402
46499
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -46436,10 +46533,10 @@ async function deploySessionToPreviewEnvironment(options) {
46436
46533
  }
46437
46534
 
46438
46535
  // src/worktrees/manager/default-worktrees-root-path.ts
46439
- import * as path71 from "node:path";
46536
+ import * as path73 from "node:path";
46440
46537
  import os9 from "node:os";
46441
46538
  function defaultWorktreesRootPath() {
46442
- return path71.join(os9.homedir(), ".buildautomaton", "worktrees");
46539
+ return path73.join(os9.homedir(), ".buildautomaton", "worktrees");
46443
46540
  }
46444
46541
 
46445
46542
  // src/connection/create-bridge-worktree-managers.ts
@@ -46569,14 +46666,14 @@ function assertBridgeWorkspace(ctx) {
46569
46666
  }
46570
46667
 
46571
46668
  // src/files/list-dir/index.ts
46572
- import fs48 from "node:fs";
46669
+ import fs50 from "node:fs";
46573
46670
 
46574
46671
  // src/files/ensure-under-cwd.ts
46575
- import path72 from "node:path";
46672
+ import path74 from "node:path";
46576
46673
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
46577
- const normalized = path72.normalize(relativePath).replace(/^(\.\/)+/, "");
46578
- const resolved = path72.resolve(cwd, normalized);
46579
- if (!resolved.startsWith(cwd + path72.sep) && resolved !== cwd) {
46674
+ const normalized = path74.normalize(relativePath).replace(/^(\.\/)+/, "");
46675
+ const resolved = path74.resolve(cwd, normalized);
46676
+ if (!resolved.startsWith(cwd + path74.sep) && resolved !== cwd) {
46580
46677
  return null;
46581
46678
  }
46582
46679
  return resolved;
@@ -46589,15 +46686,15 @@ init_yield_to_event_loop();
46589
46686
  var LIST_DIR_YIELD_EVERY = 256;
46590
46687
 
46591
46688
  // src/files/list-dir/map-dir-entry.ts
46592
- import path73 from "node:path";
46593
- import fs47 from "node:fs";
46689
+ import path75 from "node:path";
46690
+ import fs49 from "node:fs";
46594
46691
  async function mapDirEntry(d, relativePath, resolved) {
46595
- const entryPath = path73.join(relativePath || ".", d.name).replace(/\\/g, "/");
46596
- const fullPath = path73.join(resolved, d.name);
46692
+ const entryPath = path75.join(relativePath || ".", d.name).replace(/\\/g, "/");
46693
+ const fullPath = path75.join(resolved, d.name);
46597
46694
  let isDir = d.isDirectory();
46598
46695
  if (d.isSymbolicLink()) {
46599
46696
  try {
46600
- const targetStat = await fs47.promises.stat(fullPath);
46697
+ const targetStat = await fs49.promises.stat(fullPath);
46601
46698
  isDir = targetStat.isDirectory();
46602
46699
  } catch {
46603
46700
  isDir = false;
@@ -46627,7 +46724,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
46627
46724
  return { error: "Path is outside working directory" };
46628
46725
  }
46629
46726
  try {
46630
- const names = await fs48.promises.readdir(resolved, { withFileTypes: true });
46727
+ const names = await fs50.promises.readdir(resolved, { withFileTypes: true });
46631
46728
  const entries = [];
46632
46729
  for (let i = 0; i < names.length; i++) {
46633
46730
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -46643,13 +46740,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
46643
46740
  }
46644
46741
 
46645
46742
  // src/git/tree/resolve-repo-abs-path.ts
46646
- import * as path74 from "node:path";
46743
+ import * as path76 from "node:path";
46647
46744
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
46648
- const bridgeResolved = path74.resolve(bridgeRoot);
46745
+ const bridgeResolved = path76.resolve(bridgeRoot);
46649
46746
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
46650
- const repoPath = rel === "" ? bridgeResolved : path74.join(bridgeResolved, rel);
46651
- const resolved = path74.resolve(repoPath);
46652
- if (!resolved.startsWith(bridgeResolved + path74.sep) && resolved !== bridgeResolved) {
46747
+ const repoPath = rel === "" ? bridgeResolved : path76.join(bridgeResolved, rel);
46748
+ const resolved = path76.resolve(repoPath);
46749
+ if (!resolved.startsWith(bridgeResolved + path76.sep) && resolved !== bridgeResolved) {
46653
46750
  return null;
46654
46751
  }
46655
46752
  return resolved;
@@ -47130,25 +47227,25 @@ async function GET2(ctx) {
47130
47227
  init_in_flight();
47131
47228
 
47132
47229
  // src/files/read/read-file-async.ts
47133
- import fs54 from "node:fs";
47230
+ import fs56 from "node:fs";
47134
47231
  init_yield_to_event_loop();
47135
47232
 
47136
47233
  // src/files/read/resolve-file-cache.ts
47137
- import fs49 from "node:fs";
47138
- import path75 from "node:path";
47234
+ import fs51 from "node:fs";
47235
+ import path77 from "node:path";
47139
47236
  var RESOLVE_CACHE_MAX = 4096;
47140
47237
  var resolveCache = /* @__PURE__ */ new Map();
47141
47238
  function resolveCacheKey(sessionParentPath, relativePath) {
47142
47239
  return `${sessionParentPath}\0${relativePath}`;
47143
47240
  }
47144
47241
  function pathStaysUnderParent(filePath, sessionParentPath) {
47145
- const parent = path75.resolve(sessionParentPath);
47146
- const resolved = path75.resolve(filePath);
47147
- return resolved === parent || resolved.startsWith(`${parent}${path75.sep}`);
47242
+ const parent = path77.resolve(sessionParentPath);
47243
+ const resolved = path77.resolve(filePath);
47244
+ return resolved === parent || resolved.startsWith(`${parent}${path77.sep}`);
47148
47245
  }
47149
47246
  function statMatchesCacheSync(entry) {
47150
47247
  try {
47151
- const stat2 = fs49.statSync(entry.path);
47248
+ const stat2 = fs51.statSync(entry.path);
47152
47249
  return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
47153
47250
  } catch {
47154
47251
  return false;
@@ -47181,7 +47278,7 @@ function joinInflightResolve(cacheKey, factory) {
47181
47278
  }
47182
47279
 
47183
47280
  // src/files/read/resolve-file-for-read-core.ts
47184
- import fs50 from "node:fs";
47281
+ import fs52 from "node:fs";
47185
47282
  import { isMainThread as isMainThread4 } from "node:worker_threads";
47186
47283
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
47187
47284
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -47191,13 +47288,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
47191
47288
  let size;
47192
47289
  let mtimeMs;
47193
47290
  try {
47194
- const lstat = fs50.lstatSync(resolved);
47291
+ const lstat = fs52.lstatSync(resolved);
47195
47292
  if (lstat.isSymbolicLink()) {
47196
- real = fs50.realpathSync(resolved);
47293
+ real = fs52.realpathSync(resolved);
47197
47294
  if (!pathStaysUnderParent(real, sessionParentPath)) {
47198
47295
  return { error: "Path is outside working directory" };
47199
47296
  }
47200
- const stat2 = fs50.statSync(real);
47297
+ const stat2 = fs52.statSync(real);
47201
47298
  if (!stat2.isFile()) return { error: "Not a file" };
47202
47299
  size = stat2.size;
47203
47300
  mtimeMs = stat2.mtimeMs;
@@ -47225,13 +47322,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
47225
47322
  let size;
47226
47323
  let mtimeMs;
47227
47324
  try {
47228
- const lstat = await fs50.promises.lstat(resolved);
47325
+ const lstat = await fs52.promises.lstat(resolved);
47229
47326
  if (lstat.isSymbolicLink()) {
47230
- real = await fs50.promises.realpath(resolved);
47327
+ real = await fs52.promises.realpath(resolved);
47231
47328
  if (!pathStaysUnderParent(real, sessionParentPath)) {
47232
47329
  return { error: "Path is outside working directory" };
47233
47330
  }
47234
- const stat2 = await fs50.promises.stat(real);
47331
+ const stat2 = await fs52.promises.stat(real);
47235
47332
  if (!stat2.isFile()) return { error: "Not a file" };
47236
47333
  size = stat2.size;
47237
47334
  mtimeMs = stat2.mtimeMs;
@@ -47280,7 +47377,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
47280
47377
 
47281
47378
  // src/files/read/read-file-range-async.ts
47282
47379
  init_yield_to_event_loop();
47283
- import fs51 from "node:fs";
47380
+ import fs53 from "node:fs";
47284
47381
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
47285
47382
 
47286
47383
  // src/files/read/read-file-range-line-zero.ts
@@ -47394,8 +47491,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
47394
47491
 
47395
47492
  // src/files/read/read-file-range-async.ts
47396
47493
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
47397
- const fileSize = fileSizeIn ?? (await fs51.promises.stat(filePath)).size;
47398
- const fd = await fs51.promises.open(filePath, "r");
47494
+ const fileSize = fileSizeIn ?? (await fs53.promises.stat(filePath)).size;
47495
+ const fd = await fs53.promises.open(filePath, "r");
47399
47496
  const bufSize = 64 * 1024;
47400
47497
  const buf = Buffer.alloc(bufSize);
47401
47498
  const decoder = new StringDecoder2("utf8");
@@ -47496,7 +47593,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
47496
47593
  }
47497
47594
 
47498
47595
  // src/files/read/read-small-file-range-async.ts
47499
- import fs52 from "node:fs";
47596
+ import fs54 from "node:fs";
47500
47597
  import { isMainThread as isMainThread5 } from "node:worker_threads";
47501
47598
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
47502
47599
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -47526,7 +47623,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
47526
47623
  };
47527
47624
  }
47528
47625
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
47529
- const raw = fs52.readFileSync(filePath, "utf8");
47626
+ const raw = fs54.readFileSync(filePath, "utf8");
47530
47627
  const lines = raw.split(/\r?\n/);
47531
47628
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
47532
47629
  }
@@ -47534,28 +47631,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
47534
47631
  if (isMainThread5) {
47535
47632
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
47536
47633
  }
47537
- const raw = await fs52.promises.readFile(filePath, "utf8");
47634
+ const raw = await fs54.promises.readFile(filePath, "utf8");
47538
47635
  const lines = raw.split(/\r?\n/);
47539
47636
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
47540
47637
  }
47541
47638
 
47542
47639
  // src/files/read/read-file-buffer-full-async.ts
47543
47640
  init_yield_to_event_loop();
47544
- import fs53 from "node:fs";
47641
+ import fs55 from "node:fs";
47545
47642
  import { isMainThread as isMainThread6 } from "node:worker_threads";
47546
47643
  var READ_CHUNK_BYTES = 256 * 1024;
47547
47644
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
47548
47645
  async function readFileBufferFullAsync(filePath, knownSize) {
47549
47646
  if (isMainThread6) {
47550
- const size2 = knownSize ?? fs53.statSync(filePath).size;
47647
+ const size2 = knownSize ?? fs55.statSync(filePath).size;
47551
47648
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
47552
47649
  await yieldToEventLoop();
47553
- const buffer = fs53.readFileSync(filePath);
47650
+ const buffer = fs55.readFileSync(filePath);
47554
47651
  return { buffer, size: buffer.length };
47555
47652
  }
47556
47653
  }
47557
- const size = knownSize ?? (await fs53.promises.stat(filePath)).size;
47558
- const fd = await fs53.promises.open(filePath, "r");
47654
+ const size = knownSize ?? (await fs55.promises.stat(filePath)).size;
47655
+ const fd = await fs55.promises.open(filePath, "r");
47559
47656
  const chunks = [];
47560
47657
  let position = 0;
47561
47658
  let bytesSinceYield = 0;
@@ -47658,7 +47755,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
47658
47755
  }
47659
47756
  if (hasRange) {
47660
47757
  if (fileSize == null) {
47661
- const stat2 = await fs54.promises.stat(resolvedPath);
47758
+ const stat2 = await fs56.promises.stat(resolvedPath);
47662
47759
  fileSize = stat2.size;
47663
47760
  }
47664
47761
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -47956,12 +48053,12 @@ function parseOptionalInt2(raw) {
47956
48053
  return Number.isInteger(parsed) ? parsed : void 0;
47957
48054
  }
47958
48055
  function parseCodeNavParams(url2) {
47959
- const path80 = url2.searchParams.get("path") ?? "";
48056
+ const path82 = url2.searchParams.get("path") ?? "";
47960
48057
  const opRaw = url2.searchParams.get("op")?.trim();
47961
48058
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
47962
48059
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
47963
48060
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
47964
- return { path: path80, op, line, column };
48061
+ return { path: path82, op, line, column };
47965
48062
  }
47966
48063
  function parseCodeNavPath(url2) {
47967
48064
  const raw = url2.searchParams.get("path")?.trim();
@@ -48149,12 +48246,6 @@ function listenOnPort(server, port) {
48149
48246
  });
48150
48247
  });
48151
48248
  }
48152
- function closeServer(server) {
48153
- if (!server) return Promise.resolve();
48154
- return new Promise((resolve35, reject) => {
48155
- server.close((err) => err ? reject(err) : resolve35());
48156
- });
48157
- }
48158
48249
  function delay3(ms) {
48159
48250
  return new Promise((resolve35) => setTimeout(resolve35, ms));
48160
48251
  }
@@ -48179,8 +48270,7 @@ function startLocalShortcutServer(ctx) {
48179
48270
  if (restartAttempts >= MAX_RESTART_ATTEMPTS) return;
48180
48271
  restartAttempts += 1;
48181
48272
  restarting = (async () => {
48182
- await closeServer(currentServer).catch(() => {
48183
- });
48273
+ await closeHttpServer(currentServer);
48184
48274
  currentServer = null;
48185
48275
  if (closed) return;
48186
48276
  await delay3(RESTART_DELAY_MS);
@@ -48200,7 +48290,7 @@ function startLocalShortcutServer(ctx) {
48200
48290
  token: ctx.token,
48201
48291
  close: async () => {
48202
48292
  closed = true;
48203
- await closeServer(currentServer);
48293
+ await closeHttpServer(currentServer);
48204
48294
  currentServer = null;
48205
48295
  }
48206
48296
  }));
@@ -48577,15 +48667,15 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
48577
48667
  }
48578
48668
 
48579
48669
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
48580
- import fs56 from "node:fs";
48670
+ import fs58 from "node:fs";
48581
48671
 
48582
48672
  // src/git/snapshot/capture.ts
48583
- import * as fs55 from "node:fs";
48584
- import * as path76 from "node:path";
48673
+ import * as fs57 from "node:fs";
48674
+ import * as path78 from "node:path";
48585
48675
  async function resolveSnapshotRepoRoots(options) {
48586
48676
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
48587
48677
  if (worktreePaths?.length) {
48588
- const uniq = [...new Set(worktreePaths.map((p) => path76.resolve(p)))];
48678
+ const uniq = [...new Set(worktreePaths.map((p) => path78.resolve(p)))];
48589
48679
  return uniq;
48590
48680
  }
48591
48681
  try {
@@ -48593,7 +48683,7 @@ async function resolveSnapshotRepoRoots(options) {
48593
48683
  const mapped = repos.map((r) => r.absolutePath);
48594
48684
  const sid = sessionId?.trim();
48595
48685
  if (sid) {
48596
- const filtered = mapped.filter((root) => path76.basename(root) === sid);
48686
+ const filtered = mapped.filter((root) => path78.basename(root) === sid);
48597
48687
  if (filtered.length > 0) return filtered;
48598
48688
  }
48599
48689
  return mapped;
@@ -48615,7 +48705,7 @@ async function capturePreTurnSnapshot(options) {
48615
48705
  });
48616
48706
  const dir = snapshotsDirForCwd(agentCwd);
48617
48707
  try {
48618
- fs55.mkdirSync(dir, { recursive: true });
48708
+ fs57.mkdirSync(dir, { recursive: true });
48619
48709
  } catch (e) {
48620
48710
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
48621
48711
  }
@@ -48624,9 +48714,9 @@ async function capturePreTurnSnapshot(options) {
48624
48714
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
48625
48715
  repos
48626
48716
  };
48627
- const filePath = path76.join(dir, `${runId}.json`);
48717
+ const filePath = path78.join(dir, `${runId}.json`);
48628
48718
  try {
48629
- fs55.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
48719
+ fs57.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
48630
48720
  } catch (e) {
48631
48721
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
48632
48722
  }
@@ -48639,7 +48729,7 @@ async function capturePreTurnSnapshot(options) {
48639
48729
  async function applyPreTurnSnapshot(filePath, log2) {
48640
48730
  let data;
48641
48731
  try {
48642
- const raw = fs55.readFileSync(filePath, "utf8");
48732
+ const raw = fs57.readFileSync(filePath, "utf8");
48643
48733
  data = JSON.parse(raw);
48644
48734
  } catch (e) {
48645
48735
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
@@ -48679,7 +48769,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
48679
48769
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
48680
48770
  const file2 = snapshotFilePath(agentBase, tid);
48681
48771
  try {
48682
- await fs56.promises.access(file2, fs56.constants.F_OK);
48772
+ await fs58.promises.access(file2, fs58.constants.F_OK);
48683
48773
  } catch {
48684
48774
  deps.log(
48685
48775
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -49151,13 +49241,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
49151
49241
 
49152
49242
  // src/files/handle-file-browser-search.ts
49153
49243
  init_yield_to_event_loop();
49154
- import path77 from "node:path";
49244
+ import path79 from "node:path";
49155
49245
  var SEARCH_LIMIT = 100;
49156
49246
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
49157
49247
  void (async () => {
49158
49248
  await yieldToEventLoop();
49159
49249
  const q = typeof msg.q === "string" ? msg.q : "";
49160
- const sessionParentPath = path77.resolve(
49250
+ const sessionParentPath = path79.resolve(
49161
49251
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
49162
49252
  );
49163
49253
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -49275,8 +49365,8 @@ function isValidRemoteSkillInstallItem(item) {
49275
49365
 
49276
49366
  // src/skills/install/install-remote-skills-async.ts
49277
49367
  init_yield_to_event_loop();
49278
- import fs57 from "node:fs";
49279
- import path78 from "node:path";
49368
+ import fs59 from "node:fs";
49369
+ import path80 from "node:path";
49280
49370
 
49281
49371
  // src/skills/install/constants.ts
49282
49372
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -49287,12 +49377,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
49287
49377
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
49288
49378
  await yieldToEventLoop();
49289
49379
  }
49290
- const dest = path78.join(skillDir, f.path);
49291
- await fs57.promises.mkdir(path78.dirname(dest), { recursive: true });
49380
+ const dest = path80.join(skillDir, f.path);
49381
+ await fs59.promises.mkdir(path80.dirname(dest), { recursive: true });
49292
49382
  if (f.text !== void 0) {
49293
- await fs57.promises.writeFile(dest, f.text, "utf8");
49383
+ await fs59.promises.writeFile(dest, f.text, "utf8");
49294
49384
  } else if (f.base64) {
49295
- await fs57.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
49385
+ await fs59.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
49296
49386
  }
49297
49387
  }
49298
49388
  async function installRemoteSkillsAsync(cwd, targetDir, items) {
@@ -49304,7 +49394,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
49304
49394
  try {
49305
49395
  for (const item of items) {
49306
49396
  if (!isValidRemoteSkillInstallItem(item)) continue;
49307
- const skillDir = path78.join(cwd, targetDir, item.skillName);
49397
+ const skillDir = path80.join(cwd, targetDir, item.skillName);
49308
49398
  for (const f of item.files) {
49309
49399
  await writeInstallFileAsync(skillDir, f, filesWritten);
49310
49400
  }
@@ -49586,7 +49676,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
49586
49676
  };
49587
49677
 
49588
49678
  // src/routing/handlers/revert-turn-snapshot.ts
49589
- import * as fs58 from "node:fs";
49679
+ import * as fs60 from "node:fs";
49590
49680
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
49591
49681
  const id = typeof msg.id === "string" ? msg.id : "";
49592
49682
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -49599,7 +49689,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
49599
49689
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
49600
49690
  const file2 = snapshotFilePath(agentBase, turnId);
49601
49691
  try {
49602
- await fs58.promises.access(file2, fs58.constants.F_OK);
49692
+ await fs60.promises.access(file2, fs60.constants.F_OK);
49603
49693
  } catch {
49604
49694
  sendWsMessage(s, {
49605
49695
  type: "revert_turn_snapshot_result",
@@ -49684,7 +49774,7 @@ var handleDeploySessionToPreviewMessage = (msg, deps) => {
49684
49774
  };
49685
49775
 
49686
49776
  // src/git/bridge-git-context.ts
49687
- import * as path79 from "node:path";
49777
+ import * as path81 from "node:path";
49688
49778
  init_yield_to_event_loop();
49689
49779
 
49690
49780
  // src/git/branches/get-current-branch.ts
@@ -49735,12 +49825,12 @@ async function listRepoBranchRefs(repoPath) {
49735
49825
  // src/git/bridge-git-context.ts
49736
49826
  function folderNameForRelPath(relPath, bridgeRoot) {
49737
49827
  if (relPath === "." || relPath === "") {
49738
- return path79.basename(path79.resolve(bridgeRoot)) || "repo";
49828
+ return path81.basename(path81.resolve(bridgeRoot)) || "repo";
49739
49829
  }
49740
- return path79.basename(relPath) || relPath;
49830
+ return path81.basename(relPath) || relPath;
49741
49831
  }
49742
49832
  async function discoverGitReposForBridgeContext(bridgeRoot) {
49743
- const root = path79.resolve(bridgeRoot);
49833
+ const root = path81.resolve(bridgeRoot);
49744
49834
  if (await isGitRepoDirectory(root)) {
49745
49835
  const remoteUrl = await getRemoteOriginUrl(root);
49746
49836
  return [{ absolutePath: root, remoteUrl }];
@@ -49748,19 +49838,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
49748
49838
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
49749
49839
  const byPath = /* @__PURE__ */ new Map();
49750
49840
  for (const repo of [...deep, ...shallow]) {
49751
- byPath.set(path79.resolve(repo.absolutePath), repo);
49841
+ byPath.set(path81.resolve(repo.absolutePath), repo);
49752
49842
  }
49753
49843
  return [...byPath.values()];
49754
49844
  }
49755
49845
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
49756
- const bridgeResolved = path79.resolve(bridgeRoot);
49846
+ const bridgeResolved = path81.resolve(bridgeRoot);
49757
49847
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
49758
49848
  const rows = [];
49759
49849
  for (let i = 0; i < repos.length; i++) {
49760
49850
  if (i > 0) await yieldToEventLoop();
49761
49851
  const repo = repos[i];
49762
- let rel = path79.relative(bridgeResolved, repo.absolutePath);
49763
- if (rel.startsWith("..") || path79.isAbsolute(rel)) continue;
49852
+ let rel = path81.relative(bridgeResolved, repo.absolutePath);
49853
+ if (rel.startsWith("..") || path81.isAbsolute(rel)) continue;
49764
49854
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
49765
49855
  const currentBranch = await getCurrentBranch(repo.absolutePath);
49766
49856
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -49775,11 +49865,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
49775
49865
  return rows;
49776
49866
  }
49777
49867
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
49778
- const bridgeResolved = path79.resolve(bridgeRoot);
49868
+ const bridgeResolved = path81.resolve(bridgeRoot);
49779
49869
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
49780
- const repoPath = rel === "" ? bridgeResolved : path79.join(bridgeResolved, rel);
49781
- const resolved = path79.resolve(repoPath);
49782
- if (!resolved.startsWith(bridgeResolved + path79.sep) && resolved !== bridgeResolved) {
49870
+ const repoPath = rel === "" ? bridgeResolved : path81.join(bridgeResolved, rel);
49871
+ const resolved = path81.resolve(repoPath);
49872
+ if (!resolved.startsWith(bridgeResolved + path81.sep) && resolved !== bridgeResolved) {
49783
49873
  return [];
49784
49874
  }
49785
49875
  return listRepoBranchRefs(resolved);
@@ -50295,15 +50385,18 @@ async function runConnectedBridge(options, restartWithoutAuth) {
50295
50385
  const firehoseServerUrl = options.firehoseServerUrl ?? options.proxyServerUrl;
50296
50386
  let cleanupKeyCommand;
50297
50387
  let bridgeClose = null;
50388
+ let shutdownStarted = false;
50298
50389
  const onSignal = (kind) => {
50299
50390
  requestCliImmediateShutdown();
50300
50391
  abortActiveGitChildProcesses();
50301
50392
  cleanupKeyCommand?.();
50393
+ if (shutdownStarted) return;
50394
+ shutdownStarted = true;
50302
50395
  logImmediate(
50303
50396
  kind === "interrupt" ? "Keyboard interrupt (Ctrl+C) \u2014 stopping\u2026" : "Stop requested \u2014 shutting down\u2026"
50304
50397
  );
50305
50398
  if (bridgeClose) {
50306
- void bridgeClose().then(() => process.exit(0));
50399
+ void bridgeClose().finally(() => process.exit(0));
50307
50400
  return;
50308
50401
  }
50309
50402
  process.exit(0);