@buildautomaton/cli 0.1.85 → 0.1.87

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
@@ -4089,10 +4089,10 @@ function mergeDefs(...defs) {
4089
4089
  function cloneDef(schema) {
4090
4090
  return mergeDefs(schema._zod.def);
4091
4091
  }
4092
- function getElementAtPath(obj, path86) {
4093
- if (!path86)
4092
+ function getElementAtPath(obj, path88) {
4093
+ if (!path88)
4094
4094
  return obj;
4095
- return path86.reduce((acc, key) => acc?.[key], obj);
4095
+ return path88.reduce((acc, key) => acc?.[key], obj);
4096
4096
  }
4097
4097
  function promiseAllObject(promisesObj) {
4098
4098
  const keys = Object.keys(promisesObj);
@@ -4420,11 +4420,11 @@ function explicitlyAborted(x, startIndex = 0) {
4420
4420
  }
4421
4421
  return false;
4422
4422
  }
4423
- function prefixIssues(path86, issues) {
4423
+ function prefixIssues(path88, issues) {
4424
4424
  return issues.map((iss) => {
4425
4425
  var _a4;
4426
4426
  (_a4 = iss).path ?? (_a4.path = []);
4427
- iss.path.unshift(path86);
4427
+ iss.path.unshift(path88);
4428
4428
  return iss;
4429
4429
  });
4430
4430
  }
@@ -4641,16 +4641,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
4641
4641
  }
4642
4642
  function formatError(error51, mapper = (issue2) => issue2.message) {
4643
4643
  const fieldErrors = { _errors: [] };
4644
- const processError = (error52, path86 = []) => {
4644
+ const processError = (error52, path88 = []) => {
4645
4645
  for (const issue2 of error52.issues) {
4646
4646
  if (issue2.code === "invalid_union" && issue2.errors.length) {
4647
- issue2.errors.map((issues) => processError({ issues }, [...path86, ...issue2.path]));
4647
+ issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
4648
4648
  } else if (issue2.code === "invalid_key") {
4649
- processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
4649
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
4650
4650
  } else if (issue2.code === "invalid_element") {
4651
- processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
4651
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
4652
4652
  } else {
4653
- const fullpath = [...path86, ...issue2.path];
4653
+ const fullpath = [...path88, ...issue2.path];
4654
4654
  if (fullpath.length === 0) {
4655
4655
  fieldErrors._errors.push(mapper(issue2));
4656
4656
  } else {
@@ -4677,17 +4677,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
4677
4677
  }
4678
4678
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
4679
4679
  const result = { errors: [] };
4680
- const processError = (error52, path86 = []) => {
4680
+ const processError = (error52, path88 = []) => {
4681
4681
  var _a4, _b;
4682
4682
  for (const issue2 of error52.issues) {
4683
4683
  if (issue2.code === "invalid_union" && issue2.errors.length) {
4684
- issue2.errors.map((issues) => processError({ issues }, [...path86, ...issue2.path]));
4684
+ issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
4685
4685
  } else if (issue2.code === "invalid_key") {
4686
- processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
4686
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
4687
4687
  } else if (issue2.code === "invalid_element") {
4688
- processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
4688
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
4689
4689
  } else {
4690
- const fullpath = [...path86, ...issue2.path];
4690
+ const fullpath = [...path88, ...issue2.path];
4691
4691
  if (fullpath.length === 0) {
4692
4692
  result.errors.push(mapper(issue2));
4693
4693
  continue;
@@ -4719,8 +4719,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
4719
4719
  }
4720
4720
  function toDotPath(_path) {
4721
4721
  const segs = [];
4722
- const path86 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
4723
- for (const seg of path86) {
4722
+ const path88 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
4723
+ for (const seg of path88) {
4724
4724
  if (typeof seg === "number")
4725
4725
  segs.push(`[${seg}]`);
4726
4726
  else if (typeof seg === "symbol")
@@ -18150,13 +18150,13 @@ function resolveRef(ref, ctx) {
18150
18150
  if (!ref.startsWith("#")) {
18151
18151
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18152
18152
  }
18153
- const path86 = ref.slice(1).split("/").filter(Boolean);
18154
- if (path86.length === 0) {
18153
+ const path88 = ref.slice(1).split("/").filter(Boolean);
18154
+ if (path88.length === 0) {
18155
18155
  return ctx.rootSchema;
18156
18156
  }
18157
18157
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18158
- if (path86[0] === defsKey) {
18159
- const key = path86[1];
18158
+ if (path88[0] === defsKey) {
18159
+ const key = path88[1];
18160
18160
  if (!key || !ctx.defs[key]) {
18161
18161
  throw new Error(`Reference not found: ${ref}`);
18162
18162
  }
@@ -21757,7 +21757,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
21757
21757
  join2(moduleDir, "..", sub, filename),
21758
21758
  join2(moduleDir, "..", "..", "dist", sub, filename)
21759
21759
  ]);
21760
- const resolved = candidates.find((path86) => existsSync(path86));
21760
+ const resolved = candidates.find((path88) => existsSync(path88));
21761
21761
  if (!resolved) {
21762
21762
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
21763
21763
  }
@@ -22835,7 +22835,7 @@ var require_ignore = __commonJS({
22835
22835
  // path matching.
22836
22836
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
22837
22837
  // @returns {TestResult} true if a file is ignored
22838
- test(path86, checkUnignored, mode) {
22838
+ test(path88, checkUnignored, mode) {
22839
22839
  let ignored = false;
22840
22840
  let unignored = false;
22841
22841
  let matchedRule;
@@ -22844,7 +22844,7 @@ var require_ignore = __commonJS({
22844
22844
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
22845
22845
  return;
22846
22846
  }
22847
- const matched = rule[mode].test(path86);
22847
+ const matched = rule[mode].test(path88);
22848
22848
  if (!matched) {
22849
22849
  return;
22850
22850
  }
@@ -22865,17 +22865,17 @@ var require_ignore = __commonJS({
22865
22865
  var throwError = (message, Ctor) => {
22866
22866
  throw new Ctor(message);
22867
22867
  };
22868
- var checkPath = (path86, originalPath, doThrow) => {
22869
- if (!isString(path86)) {
22868
+ var checkPath = (path88, originalPath, doThrow) => {
22869
+ if (!isString(path88)) {
22870
22870
  return doThrow(
22871
22871
  `path must be a string, but got \`${originalPath}\``,
22872
22872
  TypeError
22873
22873
  );
22874
22874
  }
22875
- if (!path86) {
22875
+ if (!path88) {
22876
22876
  return doThrow(`path must not be empty`, TypeError);
22877
22877
  }
22878
- if (checkPath.isNotRelative(path86)) {
22878
+ if (checkPath.isNotRelative(path88)) {
22879
22879
  const r = "`path.relative()`d";
22880
22880
  return doThrow(
22881
22881
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -22884,7 +22884,7 @@ var require_ignore = __commonJS({
22884
22884
  }
22885
22885
  return true;
22886
22886
  };
22887
- var isNotRelative = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
22887
+ var isNotRelative = (path88) => REGEX_TEST_INVALID_PATH.test(path88);
22888
22888
  checkPath.isNotRelative = isNotRelative;
22889
22889
  checkPath.convert = (p) => p;
22890
22890
  var Ignore = class {
@@ -22914,19 +22914,19 @@ var require_ignore = __commonJS({
22914
22914
  }
22915
22915
  // @returns {TestResult}
22916
22916
  _test(originalPath, cache2, checkUnignored, slices) {
22917
- const path86 = originalPath && checkPath.convert(originalPath);
22917
+ const path88 = originalPath && checkPath.convert(originalPath);
22918
22918
  checkPath(
22919
- path86,
22919
+ path88,
22920
22920
  originalPath,
22921
22921
  this._strictPathCheck ? throwError : RETURN_FALSE
22922
22922
  );
22923
- return this._t(path86, cache2, checkUnignored, slices);
22923
+ return this._t(path88, cache2, checkUnignored, slices);
22924
22924
  }
22925
- checkIgnore(path86) {
22926
- if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
22927
- return this.test(path86);
22925
+ checkIgnore(path88) {
22926
+ if (!REGEX_TEST_TRAILING_SLASH.test(path88)) {
22927
+ return this.test(path88);
22928
22928
  }
22929
- const slices = path86.split(SLASH).filter(Boolean);
22929
+ const slices = path88.split(SLASH).filter(Boolean);
22930
22930
  slices.pop();
22931
22931
  if (slices.length) {
22932
22932
  const parent = this._t(
@@ -22939,18 +22939,18 @@ var require_ignore = __commonJS({
22939
22939
  return parent;
22940
22940
  }
22941
22941
  }
22942
- return this._rules.test(path86, false, MODE_CHECK_IGNORE);
22942
+ return this._rules.test(path88, false, MODE_CHECK_IGNORE);
22943
22943
  }
22944
- _t(path86, cache2, checkUnignored, slices) {
22945
- if (path86 in cache2) {
22946
- return cache2[path86];
22944
+ _t(path88, cache2, checkUnignored, slices) {
22945
+ if (path88 in cache2) {
22946
+ return cache2[path88];
22947
22947
  }
22948
22948
  if (!slices) {
22949
- slices = path86.split(SLASH).filter(Boolean);
22949
+ slices = path88.split(SLASH).filter(Boolean);
22950
22950
  }
22951
22951
  slices.pop();
22952
22952
  if (!slices.length) {
22953
- return cache2[path86] = this._rules.test(path86, checkUnignored, MODE_IGNORE);
22953
+ return cache2[path88] = this._rules.test(path88, checkUnignored, MODE_IGNORE);
22954
22954
  }
22955
22955
  const parent = this._t(
22956
22956
  slices.join(SLASH) + SLASH,
@@ -22958,29 +22958,29 @@ var require_ignore = __commonJS({
22958
22958
  checkUnignored,
22959
22959
  slices
22960
22960
  );
22961
- return cache2[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
22961
+ return cache2[path88] = parent.ignored ? parent : this._rules.test(path88, checkUnignored, MODE_IGNORE);
22962
22962
  }
22963
- ignores(path86) {
22964
- return this._test(path86, this._ignoreCache, false).ignored;
22963
+ ignores(path88) {
22964
+ return this._test(path88, this._ignoreCache, false).ignored;
22965
22965
  }
22966
22966
  createFilter() {
22967
- return (path86) => !this.ignores(path86);
22967
+ return (path88) => !this.ignores(path88);
22968
22968
  }
22969
22969
  filter(paths) {
22970
22970
  return makeArray(paths).filter(this.createFilter());
22971
22971
  }
22972
22972
  // @returns {TestResult}
22973
- test(path86) {
22974
- return this._test(path86, this._testCache, true);
22973
+ test(path88) {
22974
+ return this._test(path88, this._testCache, true);
22975
22975
  }
22976
22976
  };
22977
22977
  var factory = (options) => new Ignore(options);
22978
- var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, RETURN_FALSE);
22978
+ var isPathValid = (path88) => checkPath(path88 && checkPath.convert(path88), path88, RETURN_FALSE);
22979
22979
  var setupWindows = () => {
22980
22980
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
22981
22981
  checkPath.convert = makePosix;
22982
22982
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
22983
- checkPath.isNotRelative = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
22983
+ checkPath.isNotRelative = (path88) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path88) || isNotRelative(path88);
22984
22984
  };
22985
22985
  if (
22986
22986
  // Detect `process` so that it can run in browsers.
@@ -27064,7 +27064,7 @@ var require_has_flag = __commonJS({
27064
27064
  var require_supports_color = __commonJS({
27065
27065
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
27066
27066
  "use strict";
27067
- var os10 = __require("os");
27067
+ var os11 = __require("os");
27068
27068
  var tty = __require("tty");
27069
27069
  var hasFlag = require_has_flag();
27070
27070
  var { env } = process;
@@ -27112,7 +27112,7 @@ var require_supports_color = __commonJS({
27112
27112
  return min;
27113
27113
  }
27114
27114
  if (process.platform === "win32") {
27115
- const osRelease = os10.release().split(".");
27115
+ const osRelease = os11.release().split(".");
27116
27116
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
27117
27117
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
27118
27118
  }
@@ -27358,10 +27358,10 @@ var require_src2 = __commonJS({
27358
27358
  var fs_1 = __require("fs");
27359
27359
  var debug_1 = __importDefault(require_src());
27360
27360
  var log2 = debug_1.default("@kwsites/file-exists");
27361
- function check2(path86, isFile, isDirectory) {
27362
- log2(`checking %s`, path86);
27361
+ function check2(path88, isFile, isDirectory) {
27362
+ log2(`checking %s`, path88);
27363
27363
  try {
27364
- const stat2 = fs_1.statSync(path86);
27364
+ const stat2 = fs_1.statSync(path88);
27365
27365
  if (stat2.isFile() && isFile) {
27366
27366
  log2(`[OK] path represents a file`);
27367
27367
  return true;
@@ -27381,8 +27381,8 @@ var require_src2 = __commonJS({
27381
27381
  throw e;
27382
27382
  }
27383
27383
  }
27384
- function exists2(path86, type = exports.READABLE) {
27385
- return check2(path86, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27384
+ function exists2(path88, type = exports.READABLE) {
27385
+ return check2(path88, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
27386
27386
  }
27387
27387
  exports.exists = exists2;
27388
27388
  exports.FILE = 1;
@@ -28423,8 +28423,8 @@ function getErrorMap() {
28423
28423
 
28424
28424
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
28425
28425
  var makeIssue = (params) => {
28426
- const { data, path: path86, errorMaps, issueData } = params;
28427
- const fullPath = [...path86, ...issueData.path || []];
28426
+ const { data, path: path88, errorMaps, issueData } = params;
28427
+ const fullPath = [...path88, ...issueData.path || []];
28428
28428
  const fullIssue = {
28429
28429
  ...issueData,
28430
28430
  path: fullPath
@@ -28540,11 +28540,11 @@ var errorUtil;
28540
28540
 
28541
28541
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
28542
28542
  var ParseInputLazyPath = class {
28543
- constructor(parent, value, path86, key) {
28543
+ constructor(parent, value, path88, key) {
28544
28544
  this._cachedPath = [];
28545
28545
  this.parent = parent;
28546
28546
  this.data = value;
28547
- this._path = path86;
28547
+ this._path = path88;
28548
28548
  this._key = key;
28549
28549
  }
28550
28550
  get path() {
@@ -33880,8 +33880,8 @@ function randomSecret() {
33880
33880
  }
33881
33881
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
33882
33882
  }
33883
- async function requestPreviewApi(port, secret, method, path86, body) {
33884
- const url2 = `http://127.0.0.1:${port}${path86}`;
33883
+ async function requestPreviewApi(port, secret, method, path88, body) {
33884
+ const url2 = `http://127.0.0.1:${port}${path88}`;
33885
33885
  const headers = {
33886
33886
  [PREVIEW_SECRET_HEADER]: secret,
33887
33887
  "Content-Type": "application/json"
@@ -33893,7 +33893,7 @@ async function requestPreviewApi(port, secret, method, path86, body) {
33893
33893
  });
33894
33894
  const data = await res.json().catch(() => ({}));
33895
33895
  if (!res.ok) {
33896
- throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
33896
+ throw new Error(data?.error ?? `Preview API ${method} ${path88}: ${res.status}`);
33897
33897
  }
33898
33898
  return data;
33899
33899
  }
@@ -35195,7 +35195,7 @@ function createPendingAuthOnMessage(params) {
35195
35195
  }
35196
35196
 
35197
35197
  // src/cli-version.ts
35198
- var CLI_VERSION = "0.1.85".length > 0 ? "0.1.85" : "0.0.0-dev";
35198
+ var CLI_VERSION = "0.1.87".length > 0 ? "0.1.87" : "0.0.0-dev";
35199
35199
 
35200
35200
  // src/auth/pending/pending-auth-on-open.ts
35201
35201
  function createPendingAuthOnOpen(params) {
@@ -36566,8 +36566,8 @@ async function cancelRun(ctx, runId) {
36566
36566
  }
36567
36567
 
36568
36568
  // src/agents/acp/ensure-acp-client.ts
36569
- import * as fs23 from "node:fs";
36570
- import * as path29 from "node:path";
36569
+ import * as fs24 from "node:fs";
36570
+ import * as path31 from "node:path";
36571
36571
 
36572
36572
  // src/paths/session-layout-paths.ts
36573
36573
  import * as path26 from "node:path";
@@ -36757,6 +36757,7 @@ init_log();
36757
36757
  function createCursorAcpSessionContext(options) {
36758
36758
  const suppressLoadReplayRef = { value: false };
36759
36759
  return {
36760
+ cloudSessionId: options.cloudSessionId,
36760
36761
  cwd: options.cwd,
36761
36762
  onFileChange: options.onFileChange,
36762
36763
  mcpServers: options.mcpServers ?? [],
@@ -36849,6 +36850,41 @@ function createCursorAcpHandle(options) {
36849
36850
  // src/agents/acp/clients/cursor/cursor-acp-init.ts
36850
36851
  import * as readline from "node:readline";
36851
36852
 
36853
+ // src/agents/acp/clients/cursor/cursor-incoming-cursor-create-plan.ts
36854
+ function buildCursorCreatePlanToolCallUpdate(requestId, params) {
36855
+ const toolCallId = params.toolCallId ?? params.tool_call_id;
36856
+ if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
36857
+ const name = typeof params.name === "string" ? params.name.trim() : "";
36858
+ const overview = typeof params.overview === "string" ? params.overview : void 0;
36859
+ const plan = typeof params.plan === "string" ? params.plan : "";
36860
+ const todos = Array.isArray(params.todos) ? params.todos : void 0;
36861
+ const phases = Array.isArray(params.phases) ? params.phases : void 0;
36862
+ const isProject = typeof params.isProject === "boolean" ? params.isProject : void 0;
36863
+ return {
36864
+ sessionUpdate: "tool_call",
36865
+ toolCallId,
36866
+ title: name || "Plan",
36867
+ status: "pending",
36868
+ cursorPlan: {
36869
+ requestId,
36870
+ ...name ? { name } : {},
36871
+ ...overview != null ? { overview } : {},
36872
+ plan,
36873
+ ...todos != null ? { todos } : {},
36874
+ ...phases != null ? { phases } : {},
36875
+ ...isProject != null ? { isProject } : {}
36876
+ }
36877
+ };
36878
+ }
36879
+ function queueCursorCreatePlanRequest(method, id, msg, deps) {
36880
+ const params = msg.params ?? {};
36881
+ const requestId = String(id);
36882
+ deps.pendingRequests.set(id, { method, params });
36883
+ const update = buildCursorCreatePlanToolCallUpdate(requestId, params);
36884
+ if (update) deps.onSessionUpdate?.(update);
36885
+ deps.onRequest?.({ requestId, method, params });
36886
+ }
36887
+
36852
36888
  // src/agents/acp/clients/cursor/cursor-incoming-cursor-task.ts
36853
36889
  function buildCursorTaskToolCallUpdate(params) {
36854
36890
  const toolCallId = params.toolCallId ?? params.tool_call_id;
@@ -36859,6 +36895,7 @@ function buildCursorTaskToolCallUpdate(params) {
36859
36895
  const model = typeof params.model === "string" ? params.model : void 0;
36860
36896
  const agentId = typeof params.agentId === "string" ? params.agentId : typeof params.agent_id === "string" ? params.agent_id : void 0;
36861
36897
  const durationMs = typeof params.durationMs === "number" ? params.durationMs : typeof params.duration_ms === "number" ? params.duration_ms : void 0;
36898
+ const isBackground = typeof params.isBackground === "boolean" ? params.isBackground : typeof params.is_background === "boolean" ? params.is_background : typeof params.runInBackground === "boolean" ? params.runInBackground : typeof params.run_in_background === "boolean" ? params.run_in_background : void 0;
36862
36899
  return {
36863
36900
  sessionUpdate: "tool_call_update",
36864
36901
  toolCallId,
@@ -36869,7 +36906,8 @@ function buildCursorTaskToolCallUpdate(params) {
36869
36906
  ...subagentType != null ? { subagentType } : {},
36870
36907
  ...model != null ? { model } : {},
36871
36908
  ...agentId != null ? { agentId } : {},
36872
- ...durationMs != null ? { durationMs } : {}
36909
+ ...durationMs != null ? { durationMs } : {},
36910
+ ...isBackground != null ? { isBackground } : {}
36873
36911
  }
36874
36912
  };
36875
36913
  }
@@ -36881,9 +36919,13 @@ function handleCursorIncomingCursorTask(id, msg, deps) {
36881
36919
  }
36882
36920
 
36883
36921
  // src/agents/acp/clients/cursor/cursor-incoming-cursor-methods.ts
36884
- var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/create_plan", "cursor/ask_question"]);
36922
+ var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/ask_question"]);
36885
36923
  var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set(["cursor/update_todos", "cursor/generate_image"]);
36886
36924
  function handleCursorIncomingCursorMethods(method, id, msg, deps) {
36925
+ if (method === "cursor/create_plan") {
36926
+ queueCursorCreatePlanRequest(method, id, msg, deps);
36927
+ return true;
36928
+ }
36887
36929
  if (CURSOR_BRIDGE_METHODS.has(method)) {
36888
36930
  const params = msg.params ?? {};
36889
36931
  deps.pendingRequests.set(id, { method, params });
@@ -36997,10 +37039,71 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
36997
37039
  return true;
36998
37040
  }
36999
37041
 
37042
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
37043
+ import * as fs23 from "node:fs";
37044
+ import * as path28 from "node:path";
37045
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
37046
+
37047
+ // src/paths/session-plans-paths.ts
37048
+ import * as os8 from "node:os";
37049
+ import * as path27 from "node:path";
37050
+ function getSessionPlansRootDir() {
37051
+ return path27.join(os8.homedir(), ".buildautomaton", "plans");
37052
+ }
37053
+ function sanitizeSessionPlansKey(sessionId) {
37054
+ const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
37055
+ return t || "session";
37056
+ }
37057
+ function getSessionPlansDir(sessionId) {
37058
+ return path27.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
37059
+ }
37060
+
37061
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
37062
+ function sanitizePlanFileBase(toolCallId) {
37063
+ const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
37064
+ return t || "plan";
37065
+ }
37066
+ function writeCreatePlanFile(params) {
37067
+ const dir = getSessionPlansDir(params.cloudSessionId);
37068
+ fs23.mkdirSync(dir, { recursive: true });
37069
+ const filePath = path28.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
37070
+ fs23.writeFileSync(filePath, params.planMarkdown, "utf8");
37071
+ return pathToFileURL2(filePath).href;
37072
+ }
37073
+
37074
+ // src/agents/acp/clients/cursor/enrich-create-plan-rpc-result.ts
37075
+ function asRecord2(v) {
37076
+ return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
37077
+ }
37078
+ function enrichCreatePlanRpcResult(result, pendingParams, cloudSessionId) {
37079
+ const root = asRecord2(result);
37080
+ const outcome = asRecord2(root?.outcome);
37081
+ if (!outcome) return result;
37082
+ const kind = typeof outcome.outcome === "string" ? outcome.outcome : "";
37083
+ if (kind !== "accepted") {
37084
+ const { plan: _drop, ...rest } = outcome;
37085
+ return { ...root, outcome: rest };
37086
+ }
37087
+ const planMarkdown = typeof outcome.plan === "string" ? outcome.plan : "";
37088
+ const toolCallIdRaw = pendingParams.toolCallId ?? pendingParams.tool_call_id;
37089
+ const toolCallId = typeof toolCallIdRaw === "string" ? toolCallIdRaw.trim() : "";
37090
+ const sessionId = cloudSessionId?.trim() ?? "";
37091
+ if (planMarkdown && toolCallId && sessionId) {
37092
+ const planUri = writeCreatePlanFile({ cloudSessionId: sessionId, toolCallId, planMarkdown });
37093
+ return { outcome: { outcome: "accepted", planUri } };
37094
+ }
37095
+ return { outcome: { outcome: "accepted" } };
37096
+ }
37097
+
37000
37098
  // src/agents/acp/clients/cursor/cursor-incoming-resolve-request.ts
37001
- function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result) {
37099
+ function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result, cloudSessionId) {
37002
37100
  const pending2 = pendingRequests2.get(requestId);
37003
- const payload = pending2?.method === "session/request_permission" ? enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params) : result;
37101
+ let payload = result;
37102
+ if (pending2?.method === "session/request_permission") {
37103
+ payload = enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params);
37104
+ } else if (pending2?.method === "cursor/create_plan") {
37105
+ payload = enrichCreatePlanRpcResult(result, pending2.params, cloudSessionId ?? void 0);
37106
+ }
37004
37107
  respond(requestId, payload);
37005
37108
  pendingRequests2.delete(requestId);
37006
37109
  }
@@ -37061,7 +37164,13 @@ function createCursorAcpIncomingLineHandler(deps) {
37061
37164
  pendingRequests: deps.pendingRequests
37062
37165
  };
37063
37166
  return {
37064
- resolveRequest: (requestId, result) => resolveCursorIncomingRequest(deps.pendingRequests, deps.respond, requestId, result),
37167
+ resolveRequest: (requestId, result) => resolveCursorIncomingRequest(
37168
+ deps.pendingRequests,
37169
+ deps.respond,
37170
+ requestId,
37171
+ result,
37172
+ deps.sessionCtx.cloudSessionId
37173
+ ),
37065
37174
  handleLine(line) {
37066
37175
  const msg = safeJsonParse(line);
37067
37176
  if (!msg) return;
@@ -37264,6 +37373,7 @@ async function createCursorAcpClient(options) {
37264
37373
  const skipBrowserAuthenticate = cursorAgentUsesApiKeyAuth(spawnEnv);
37265
37374
  const sessionCtx = createCursorAcpSessionContext({
37266
37375
  cwd,
37376
+ cloudSessionId: options.cloudSessionId,
37267
37377
  mcpServers: options.mcpServers,
37268
37378
  persistedAcpSessionId,
37269
37379
  backendAgentType,
@@ -37413,18 +37523,18 @@ import { existsSync as existsSync4, statSync } from "node:fs";
37413
37523
 
37414
37524
  // src/git/get-git-repo-root-sync.ts
37415
37525
  import { execFileSync as execFileSync3 } from "node:child_process";
37416
- import * as path27 from "node:path";
37526
+ import * as path29 from "node:path";
37417
37527
  var GIT_LOOKUP_TIMEOUT_MS = 2e3;
37418
37528
  function getGitRepoRootSync(startDir) {
37419
37529
  try {
37420
37530
  const out = execFileSync3("git", ["rev-parse", "--show-toplevel"], {
37421
- cwd: path27.resolve(startDir),
37531
+ cwd: path29.resolve(startDir),
37422
37532
  encoding: "utf8",
37423
37533
  stdio: ["ignore", "pipe", "ignore"],
37424
37534
  maxBuffer: 1024 * 1024,
37425
37535
  timeout: GIT_LOOKUP_TIMEOUT_MS
37426
37536
  }).trim();
37427
- return out ? path27.resolve(out) : null;
37537
+ return out ? path29.resolve(out) : null;
37428
37538
  } catch {
37429
37539
  return null;
37430
37540
  }
@@ -37433,26 +37543,26 @@ function getGitRepoRootSync(startDir) {
37433
37543
  // src/agents/acp/workspace-files.ts
37434
37544
  import { execFileSync as execFileSync4 } from "node:child_process";
37435
37545
  import { readFileSync as readFileSync4 } from "node:fs";
37436
- import * as path28 from "node:path";
37546
+ import * as path30 from "node:path";
37437
37547
  var GIT_FILE_READ_TIMEOUT_MS = 2e3;
37438
37548
  function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
37439
37549
  const trimmed2 = rawPath.trim();
37440
37550
  if (!trimmed2) return null;
37441
- const normalizedSessionParent = path28.resolve(sessionParentPath);
37551
+ const normalizedSessionParent = path30.resolve(sessionParentPath);
37442
37552
  let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
37443
37553
  if (!resolvedPath) {
37444
- const candidate = path28.isAbsolute(trimmed2) ? path28.normalize(trimmed2) : path28.normalize(path28.resolve(normalizedSessionParent, trimmed2));
37554
+ const candidate = path30.isAbsolute(trimmed2) ? path30.normalize(trimmed2) : path30.normalize(path30.resolve(normalizedSessionParent, trimmed2));
37445
37555
  const gitRoot2 = getGitRepoRootSync(sessionParentPath);
37446
37556
  if (!gitRoot2) return null;
37447
- const rel = path28.relative(gitRoot2, candidate);
37448
- if (rel.startsWith("..") || path28.isAbsolute(rel)) return null;
37557
+ const rel = path30.relative(gitRoot2, candidate);
37558
+ if (rel.startsWith("..") || path30.isAbsolute(rel)) return null;
37449
37559
  resolvedPath = candidate;
37450
37560
  }
37451
37561
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37452
37562
  if (gitRoot) {
37453
- const relFromRoot = path28.relative(gitRoot, resolvedPath);
37454
- if (!relFromRoot.startsWith("..") && !path28.isAbsolute(relFromRoot)) {
37455
- return { resolvedPath, display: relFromRoot.split(path28.sep).join("/") };
37563
+ const relFromRoot = path30.relative(gitRoot, resolvedPath);
37564
+ if (!relFromRoot.startsWith("..") && !path30.isAbsolute(relFromRoot)) {
37565
+ return { resolvedPath, display: relFromRoot.split(path30.sep).join("/") };
37456
37566
  }
37457
37567
  }
37458
37568
  return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
@@ -37461,9 +37571,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
37461
37571
  if (!displayPath || displayPath.includes("..")) return "";
37462
37572
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37463
37573
  if (gitRoot) {
37464
- const resolvedPath2 = path28.resolve(gitRoot, displayPath);
37465
- const rel = path28.relative(gitRoot, resolvedPath2);
37466
- if (!rel.startsWith("..") && !path28.isAbsolute(rel)) {
37574
+ const resolvedPath2 = path30.resolve(gitRoot, displayPath);
37575
+ const rel = path30.relative(gitRoot, resolvedPath2);
37576
+ if (!rel.startsWith("..") && !path30.isAbsolute(rel)) {
37467
37577
  try {
37468
37578
  return readFileSync4(resolvedPath2, "utf8");
37469
37579
  } catch {
@@ -37482,9 +37592,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
37482
37592
  if (!displayPath || displayPath.includes("..")) return null;
37483
37593
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37484
37594
  if (gitRoot) {
37485
- const resolvedPath = path28.resolve(gitRoot, displayPath);
37486
- const rel = path28.relative(gitRoot, resolvedPath);
37487
- if (!rel.startsWith("..") && !path28.isAbsolute(rel)) return resolvedPath;
37595
+ const resolvedPath = path30.resolve(gitRoot, displayPath);
37596
+ const rel = path30.relative(gitRoot, resolvedPath);
37597
+ if (!rel.startsWith("..") && !path30.isAbsolute(rel)) return resolvedPath;
37488
37598
  }
37489
37599
  return resolveSafePathUnderCwd(sessionParentPath, displayPath);
37490
37600
  }
@@ -38371,11 +38481,11 @@ init_cli_process_interrupt();
38371
38481
  var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
38372
38482
 
38373
38483
  // src/mcp/resolve-bridge-mcp-server-path.ts
38374
- import { dirname as dirname7, join as join7 } from "node:path";
38484
+ import { dirname as dirname7, join as join9 } from "node:path";
38375
38485
  import { fileURLToPath as fileURLToPath7 } from "node:url";
38376
38486
  function resolveBridgeMcpServerScriptPath() {
38377
38487
  const cliDir = dirname7(fileURLToPath7(import.meta.url));
38378
- return join7(cliDir, "bridge-mcp-server.js");
38488
+ return join9(cliDir, "bridge-mcp-server.js");
38379
38489
  }
38380
38490
 
38381
38491
  // src/mcp/build-acp-mcp-servers.ts
@@ -38434,7 +38544,7 @@ async function ensureAcpClient(options) {
38434
38544
  if (state.acpStartPromise && !state.acpHandle) {
38435
38545
  await state.acpStartPromise;
38436
38546
  }
38437
- if (state.acpHandle && state.lastAcpCwd != null && path29.resolve(state.lastAcpCwd) !== path29.resolve(targetSessionParentPath)) {
38547
+ if (state.acpHandle && state.lastAcpCwd != null && path31.resolve(state.lastAcpCwd) !== path31.resolve(targetSessionParentPath)) {
38438
38548
  try {
38439
38549
  state.acpHandle.disconnect();
38440
38550
  } catch {
@@ -38466,7 +38576,7 @@ async function ensureAcpClient(options) {
38466
38576
  if (!state.acpStartPromise) {
38467
38577
  let statOk = false;
38468
38578
  try {
38469
- const st = await fs23.promises.stat(targetSessionParentPath);
38579
+ const st = await fs24.promises.stat(targetSessionParentPath);
38470
38580
  statOk = st.isDirectory();
38471
38581
  if (!statOk) {
38472
38582
  state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
@@ -38545,6 +38655,7 @@ async function ensureAcpClient(options) {
38545
38655
  },
38546
38656
  ...hooks,
38547
38657
  cwd: targetSessionParentPath,
38658
+ cloudSessionId: cloudSessionId ?? null,
38548
38659
  mcpServers
38549
38660
  }).then(async (h) => {
38550
38661
  if (spawnEpoch !== state.clientEpoch || isCliImmediateShutdownRequested()) {
@@ -38764,8 +38875,8 @@ async function execGitFile(args, options) {
38764
38875
  }
38765
38876
 
38766
38877
  // src/git/changes/parse/normalize-git-diff-path.ts
38767
- function normalizeGitDiffPath(path86) {
38768
- return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
38878
+ function normalizeGitDiffPath(path88) {
38879
+ return path88.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
38769
38880
  }
38770
38881
 
38771
38882
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -38804,7 +38915,7 @@ function parseNameStatusLines(lines) {
38804
38915
  }
38805
38916
 
38806
38917
  // src/git/snapshot/diff/messages.ts
38807
- import * as path30 from "node:path";
38918
+ import * as path32 from "node:path";
38808
38919
 
38809
38920
  // src/git/snapshot/diff/files.ts
38810
38921
  import { readFile, stat } from "node:fs/promises";
@@ -38835,7 +38946,7 @@ async function buildTrackedChangeMessage(options) {
38835
38946
  const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
38836
38947
  const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
38837
38948
  if (!patchContent.trim()) return null;
38838
- const workspaceFilePath = path30.join(repoPath, rel);
38949
+ const workspaceFilePath = path32.join(repoPath, rel);
38839
38950
  const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
38840
38951
  const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
38841
38952
  return {
@@ -38867,9 +38978,9 @@ function buildUntrackedChangeMessage(options) {
38867
38978
  }
38868
38979
 
38869
38980
  // src/git/snapshot/diff/paths.ts
38870
- import * as path31 from "node:path";
38981
+ import * as path33 from "node:path";
38871
38982
  function repoDisplayPath(repoPath, multiRepo) {
38872
- const slug = path31.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
38983
+ const slug = path33.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
38873
38984
  return (rel) => multiRepo ? `${slug}/${rel}` : rel;
38874
38985
  }
38875
38986
  function safeRelPath(rel) {
@@ -38881,12 +38992,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
38881
38992
  }
38882
38993
 
38883
38994
  // src/git/snapshot/diff/move-pairs.ts
38884
- import * as path32 from "node:path";
38995
+ import * as path34 from "node:path";
38885
38996
  async function readUntrackedTexts(repoPath, untracked) {
38886
38997
  const out = /* @__PURE__ */ new Map();
38887
38998
  await forEachWithGitYield(untracked, async (rel) => {
38888
38999
  if (!safeRelPath(rel)) return;
38889
- const newText = await readWorkspaceFileAsUtf8(path32.join(repoPath, rel));
39000
+ const newText = await readWorkspaceFileAsUtf8(path34.join(repoPath, rel));
38890
39001
  if (newText !== void 0) out.set(rel, newText);
38891
39002
  });
38892
39003
  return out;
@@ -39003,12 +39114,12 @@ async function collectRepoTurnChanges(options) {
39003
39114
  import { readFile as readFile2 } from "node:fs/promises";
39004
39115
 
39005
39116
  // src/git/snapshot/types.ts
39006
- import * as path33 from "node:path";
39117
+ import * as path35 from "node:path";
39007
39118
  function snapshotsDirForCwd(agentCwd) {
39008
- return path33.join(agentCwd, ".buildautomaton", "snapshots");
39119
+ return path35.join(agentCwd, ".buildautomaton", "snapshots");
39009
39120
  }
39010
39121
  function snapshotFilePath(agentCwd, runId) {
39011
- return path33.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
39122
+ return path35.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
39012
39123
  }
39013
39124
 
39014
39125
  // src/git/snapshot/diff/load-pre-turn-snapshot.ts
@@ -39076,6 +39187,18 @@ function reportPostTurnEnrichment(options) {
39076
39187
  });
39077
39188
  }
39078
39189
 
39190
+ // src/agents/acp/clients/cursor/cleanup-session-plans.ts
39191
+ import * as fs25 from "node:fs";
39192
+ function cleanupSessionPlans(sessionId) {
39193
+ const id = typeof sessionId === "string" ? sessionId.trim() : "";
39194
+ if (!id) return;
39195
+ const dir = getSessionPlansDir(id);
39196
+ try {
39197
+ fs25.rmSync(dir, { recursive: true, force: true });
39198
+ } catch {
39199
+ }
39200
+ }
39201
+
39079
39202
  // src/agents/acp/prompts/finalize-and-send-prompt-result.ts
39080
39203
  async function finalizeAndSendPromptResult(params) {
39081
39204
  const {
@@ -39093,6 +39216,7 @@ async function finalizeAndSendPromptResult(params) {
39093
39216
  sendSessionUpdate,
39094
39217
  log: log2
39095
39218
  } = params;
39219
+ cleanupSessionPlans(sessionId);
39096
39220
  const planningTodosSubmit = isPlanningSession ? await maybeSubmitPlanningTodosAfterAgentSuccess({
39097
39221
  sessionId,
39098
39222
  runId,
@@ -40387,7 +40511,7 @@ async function createBridgeAccessState(options = {}) {
40387
40511
  }
40388
40512
 
40389
40513
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
40390
- import * as path35 from "node:path";
40514
+ import * as path37 from "node:path";
40391
40515
 
40392
40516
  // src/agents/detect-local-agent-types.ts
40393
40517
  init_yield_to_event_loop();
@@ -40492,7 +40616,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
40492
40616
  init_cli_database();
40493
40617
 
40494
40618
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
40495
- import * as path34 from "node:path";
40619
+ import * as path36 from "node:path";
40496
40620
  init_cli_database();
40497
40621
  init_cli_process_interrupt();
40498
40622
  async function probeOneAgentTypeForCapabilities(params) {
@@ -40532,7 +40656,7 @@ async function probeOneAgentTypeForCapabilities(params) {
40532
40656
  if (!canContinue()) return false;
40533
40657
  handle = await resolved.createClient({
40534
40658
  command: resolved.command,
40535
- cwd: path34.resolve(cwd),
40659
+ cwd: path36.resolve(cwd),
40536
40660
  backendAgentType: agentType,
40537
40661
  sessionMode: "agent",
40538
40662
  persistedAcpSessionId: null,
@@ -40625,7 +40749,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
40625
40749
  const { workspaceId, log: log2, getWs } = params;
40626
40750
  const isCurrent = beginAgentCapabilityWarmupRun();
40627
40751
  if (!isCurrent()) return;
40628
- const cwd = path35.resolve(getBridgeRoot());
40752
+ const cwd = path37.resolve(getBridgeRoot());
40629
40753
  async function sendBatchFromCache() {
40630
40754
  if (!isCurrent()) return;
40631
40755
  const socket = getWs();
@@ -40752,7 +40876,7 @@ async function createBridgeAccessAndAcp(options) {
40752
40876
  }
40753
40877
 
40754
40878
  // src/connection/create-bridge-preview-stack.ts
40755
- import * as path38 from "node:path";
40879
+ import * as path40 from "node:path";
40756
40880
 
40757
40881
  // src/preview-environments/manager/firehose-messages.ts
40758
40882
  function buildFirehoseSnapshotMessage(params) {
@@ -41070,7 +41194,7 @@ function attachChildErrorHandler(d) {
41070
41194
  }
41071
41195
 
41072
41196
  // src/preview-environments/process/wire/handle-exit.ts
41073
- import fs24 from "node:fs";
41197
+ import fs26 from "node:fs";
41074
41198
  function logStopLine(d, code, signal) {
41075
41199
  const { title } = d;
41076
41200
  if (signal) {
@@ -41109,7 +41233,7 @@ function attachChildExitHandler(d) {
41109
41233
  const cleanupDir = d.mergedCleanupDir;
41110
41234
  const mergedPath = d.mergedLogPath;
41111
41235
  if (mergedPath && !stale) {
41112
- fs24.readFile(mergedPath, (err, buf) => {
41236
+ fs26.readFile(mergedPath, (err, buf) => {
41113
41237
  if (!err && buf.length > d.mergedReadPos.value) {
41114
41238
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
41115
41239
  if (chunk.length > 0) {
@@ -41155,7 +41279,7 @@ function wireChildOutputPipes(d) {
41155
41279
  }
41156
41280
 
41157
41281
  // src/preview-environments/process/wire/poll-merged-log.ts
41158
- import fs25 from "node:fs";
41282
+ import fs27 from "node:fs";
41159
41283
  function startMergedLogPoll(d) {
41160
41284
  if (!d.mergedLogPath || !d.mergedCleanupDir) return;
41161
41285
  const { environmentId } = d;
@@ -41165,7 +41289,7 @@ function startMergedLogPoll(d) {
41165
41289
  d.setPollInterval(void 0);
41166
41290
  return;
41167
41291
  }
41168
- fs25.readFile(d.mergedLogPath, (err, buf) => {
41292
+ fs27.readFile(d.mergedLogPath, (err, buf) => {
41169
41293
  if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
41170
41294
  if (buf.length <= d.mergedReadPos.value) return;
41171
41295
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
@@ -41380,7 +41504,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
41380
41504
  }
41381
41505
 
41382
41506
  // src/preview-environments/manager/shell-spawn/utils.ts
41383
- import fs26 from "node:fs";
41507
+ import fs28 from "node:fs";
41384
41508
  function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
41385
41509
  return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
41386
41510
  }
@@ -41389,7 +41513,7 @@ function isSpawnEbadf(e) {
41389
41513
  }
41390
41514
  function rmDirQuiet(dir) {
41391
41515
  try {
41392
- fs26.rmSync(dir, { recursive: true, force: true });
41516
+ fs28.rmSync(dir, { recursive: true, force: true });
41393
41517
  } catch {
41394
41518
  }
41395
41519
  }
@@ -41397,7 +41521,7 @@ var cachedDevNullReadFd;
41397
41521
  function devNullReadFd() {
41398
41522
  if (cachedDevNullReadFd === void 0) {
41399
41523
  const devPath = process.platform === "win32" ? "nul" : "/dev/null";
41400
- cachedDevNullReadFd = fs26.openSync(devPath, "r");
41524
+ cachedDevNullReadFd = fs28.openSync(devPath, "r");
41401
41525
  }
41402
41526
  return cachedDevNullReadFd;
41403
41527
  }
@@ -41477,15 +41601,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
41477
41601
 
41478
41602
  // src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
41479
41603
  import { spawn as spawn7 } from "node:child_process";
41480
- import fs27 from "node:fs";
41604
+ import fs29 from "node:fs";
41481
41605
  import { tmpdir } from "node:os";
41482
- import path36 from "node:path";
41606
+ import path38 from "node:path";
41483
41607
  function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41484
- const tmpRoot = fs27.mkdtempSync(path36.join(tmpdir(), "ba-devsrv-log-"));
41485
- const logPath = path36.join(tmpRoot, "combined.log");
41608
+ const tmpRoot = fs29.mkdtempSync(path38.join(tmpdir(), "ba-devsrv-log-"));
41609
+ const logPath = path38.join(tmpRoot, "combined.log");
41486
41610
  let logFd;
41487
41611
  try {
41488
- logFd = fs27.openSync(logPath, "a");
41612
+ logFd = fs29.openSync(logPath, "a");
41489
41613
  } catch {
41490
41614
  rmDirQuiet(tmpRoot);
41491
41615
  return null;
@@ -41509,7 +41633,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41509
41633
  mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
41510
41634
  );
41511
41635
  }
41512
- fs27.closeSync(logFd);
41636
+ fs29.closeSync(logFd);
41513
41637
  return {
41514
41638
  proc,
41515
41639
  pipedStdoutStderr: true,
@@ -41518,7 +41642,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41518
41642
  };
41519
41643
  } catch (e) {
41520
41644
  try {
41521
- fs27.closeSync(logFd);
41645
+ fs29.closeSync(logFd);
41522
41646
  } catch {
41523
41647
  }
41524
41648
  rmDirQuiet(tmpRoot);
@@ -41529,22 +41653,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41529
41653
 
41530
41654
  // src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
41531
41655
  import { spawn as spawn8 } from "node:child_process";
41532
- import fs28 from "node:fs";
41656
+ import fs30 from "node:fs";
41533
41657
  import { tmpdir as tmpdir2 } from "node:os";
41534
- import path37 from "node:path";
41658
+ import path39 from "node:path";
41535
41659
  function shSingleQuote(s) {
41536
41660
  return `'${s.replace(/'/g, `'\\''`)}'`;
41537
41661
  }
41538
41662
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
41539
- const tmpRoot = fs28.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
41540
- const logPath = path37.join(tmpRoot, "combined.log");
41541
- const innerPath = path37.join(tmpRoot, "_cmd.sh");
41542
- const runnerPath = path37.join(tmpRoot, "_run.sh");
41663
+ const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir2(), "ba-devsrv-sh-"));
41664
+ const logPath = path39.join(tmpRoot, "combined.log");
41665
+ const innerPath = path39.join(tmpRoot, "_cmd.sh");
41666
+ const runnerPath = path39.join(tmpRoot, "_run.sh");
41543
41667
  try {
41544
- fs28.writeFileSync(innerPath, `#!/bin/sh
41668
+ fs30.writeFileSync(innerPath, `#!/bin/sh
41545
41669
  ${command}
41546
41670
  `);
41547
- fs28.writeFileSync(
41671
+ fs30.writeFileSync(
41548
41672
  runnerPath,
41549
41673
  `#!/bin/sh
41550
41674
  cd ${shSingleQuote(cwd)}
@@ -41572,13 +41696,13 @@ cd ${shSingleQuote(cwd)}
41572
41696
  }
41573
41697
  }
41574
41698
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
41575
- const tmpRoot = fs28.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
41576
- const logPath = path37.join(tmpRoot, "combined.log");
41577
- const runnerPath = path37.join(tmpRoot, "_run.bat");
41699
+ const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir2(), "ba-devsrv-sh-"));
41700
+ const logPath = path39.join(tmpRoot, "combined.log");
41701
+ const runnerPath = path39.join(tmpRoot, "_run.bat");
41578
41702
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
41579
41703
  const com = process.env.ComSpec || "cmd.exe";
41580
41704
  try {
41581
- fs28.writeFileSync(
41705
+ fs30.writeFileSync(
41582
41706
  runnerPath,
41583
41707
  `@ECHO OFF\r
41584
41708
  CD /D ${q(cwd)}\r
@@ -41896,8 +42020,8 @@ function createBridgePreviewStack(options) {
41896
42020
  scheduleInitialIndexBuilds(getBridgeRoot());
41897
42021
  };
41898
42022
  const identifyReportedPaths = {
41899
- bridgeRootPath: path38.resolve(getBridgeRoot()),
41900
- worktreesRootPath: path38.resolve(options.worktreesRootPath),
42023
+ bridgeRootPath: path40.resolve(getBridgeRoot()),
42024
+ worktreesRootPath: path40.resolve(options.worktreesRootPath),
41901
42025
  localShortcutPort: 0,
41902
42026
  localShortcutToken: ""
41903
42027
  };
@@ -42624,17 +42748,17 @@ async function yieldSkillDiscoveryWork(entryCount) {
42624
42748
  }
42625
42749
 
42626
42750
  // src/skills/discovery/discover-local-skills.ts
42627
- import fs29 from "node:fs";
42628
- import path39 from "node:path";
42751
+ import fs31 from "node:fs";
42752
+ import path41 from "node:path";
42629
42753
  function collectSkillFromDir(rel, base, name, seenKeys, out) {
42630
- const dir = path39.join(base, name);
42754
+ const dir = path41.join(base, name);
42631
42755
  try {
42632
- if (!fs29.statSync(dir).isDirectory()) return;
42756
+ if (!fs31.statSync(dir).isDirectory()) return;
42633
42757
  } catch {
42634
42758
  return;
42635
42759
  }
42636
- const skillMd = path39.join(dir, "SKILL.md");
42637
- if (!fs29.existsSync(skillMd)) return;
42760
+ const skillMd = path41.join(dir, "SKILL.md");
42761
+ if (!fs31.existsSync(skillMd)) return;
42638
42762
  const key = `${rel}/${name}`;
42639
42763
  if (seenKeys.has(key)) return;
42640
42764
  seenKeys.add(key);
@@ -42646,11 +42770,11 @@ async function discoverLocalSkillsAsync(cwd) {
42646
42770
  let work = 0;
42647
42771
  for (const rel of SKILL_DISCOVERY_ROOTS) {
42648
42772
  await yieldSkillDiscoveryWork(++work);
42649
- const base = path39.join(cwd, rel);
42650
- if (!fs29.existsSync(base) || !fs29.statSync(base).isDirectory()) continue;
42773
+ const base = path41.join(cwd, rel);
42774
+ if (!fs31.existsSync(base) || !fs31.statSync(base).isDirectory()) continue;
42651
42775
  let entries = [];
42652
42776
  try {
42653
- entries = fs29.readdirSync(base);
42777
+ entries = fs31.readdirSync(base);
42654
42778
  } catch {
42655
42779
  continue;
42656
42780
  }
@@ -42663,16 +42787,16 @@ async function discoverLocalSkillsAsync(cwd) {
42663
42787
  }
42664
42788
 
42665
42789
  // src/skills/discovery/discover-skill-layout-roots.ts
42666
- import fs30 from "node:fs";
42667
- import path40 from "node:path";
42790
+ import fs32 from "node:fs";
42791
+ import path42 from "node:path";
42668
42792
  function collectLayoutSkill(rel, base, name, skills2) {
42669
- const dir = path40.join(base, name);
42793
+ const dir = path42.join(base, name);
42670
42794
  try {
42671
- if (!fs30.statSync(dir).isDirectory()) return;
42795
+ if (!fs32.statSync(dir).isDirectory()) return;
42672
42796
  } catch {
42673
42797
  return;
42674
42798
  }
42675
- if (!fs30.existsSync(path40.join(dir, "SKILL.md"))) return;
42799
+ if (!fs32.existsSync(path42.join(dir, "SKILL.md"))) return;
42676
42800
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
42677
42801
  skills2.push({ name, relPath });
42678
42802
  }
@@ -42681,11 +42805,11 @@ async function discoverSkillLayoutRootsAsync(cwd) {
42681
42805
  let work = 0;
42682
42806
  for (const rel of SKILL_DISCOVERY_ROOTS) {
42683
42807
  await yieldSkillDiscoveryWork(++work);
42684
- const base = path40.join(cwd, rel);
42685
- if (!fs30.existsSync(base) || !fs30.statSync(base).isDirectory()) continue;
42808
+ const base = path42.join(cwd, rel);
42809
+ if (!fs32.existsSync(base) || !fs32.statSync(base).isDirectory()) continue;
42686
42810
  let entries = [];
42687
42811
  try {
42688
- entries = fs30.readdirSync(base);
42812
+ entries = fs32.readdirSync(base);
42689
42813
  } catch {
42690
42814
  continue;
42691
42815
  }
@@ -42832,12 +42956,12 @@ function createBridgeRuntimeMessageSetup(options) {
42832
42956
  }
42833
42957
 
42834
42958
  // src/worktrees/worktree-layout-file.ts
42835
- import * as fs31 from "node:fs";
42836
- import * as path41 from "node:path";
42837
- import os8 from "node:os";
42959
+ import * as fs33 from "node:fs";
42960
+ import * as path43 from "node:path";
42961
+ import os9 from "node:os";
42838
42962
  var LAYOUT_FILENAME = "worktree-launcher-layout.json";
42839
42963
  function defaultWorktreeLayoutPath() {
42840
- return path41.join(os8.homedir(), ".buildautomaton", LAYOUT_FILENAME);
42964
+ return path43.join(os9.homedir(), ".buildautomaton", LAYOUT_FILENAME);
42841
42965
  }
42842
42966
  function normalizeLoadedLayout(raw) {
42843
42967
  if (raw && typeof raw === "object" && "launcherCwds" in raw) {
@@ -42849,8 +42973,8 @@ function normalizeLoadedLayout(raw) {
42849
42973
  function loadWorktreeLayout() {
42850
42974
  try {
42851
42975
  const p = defaultWorktreeLayoutPath();
42852
- if (!fs31.existsSync(p)) return { launcherCwds: [] };
42853
- const raw = JSON.parse(fs31.readFileSync(p, "utf8"));
42976
+ if (!fs33.existsSync(p)) return { launcherCwds: [] };
42977
+ const raw = JSON.parse(fs33.readFileSync(p, "utf8"));
42854
42978
  return normalizeLoadedLayout(raw);
42855
42979
  } catch {
42856
42980
  return { launcherCwds: [] };
@@ -42858,24 +42982,24 @@ function loadWorktreeLayout() {
42858
42982
  }
42859
42983
  function saveWorktreeLayout(layout) {
42860
42984
  try {
42861
- const dir = path41.dirname(defaultWorktreeLayoutPath());
42862
- fs31.mkdirSync(dir, { recursive: true });
42863
- fs31.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
42985
+ const dir = path43.dirname(defaultWorktreeLayoutPath());
42986
+ fs33.mkdirSync(dir, { recursive: true });
42987
+ fs33.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
42864
42988
  } catch {
42865
42989
  }
42866
42990
  }
42867
42991
  function baseNameSafe(pathString) {
42868
- return path41.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
42992
+ return path43.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
42869
42993
  }
42870
42994
  function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
42871
- const norm = path41.resolve(bridgeRootPath2);
42872
- const existing = layout.launcherCwds.find((e) => path41.resolve(e.absolutePath) === norm);
42995
+ const norm = path43.resolve(bridgeRootPath2);
42996
+ const existing = layout.launcherCwds.find((e) => path43.resolve(e.absolutePath) === norm);
42873
42997
  return existing?.dirName;
42874
42998
  }
42875
42999
  function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
42876
43000
  const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
42877
43001
  if (existing) return existing;
42878
- const norm = path41.resolve(bridgeRootPath2);
43002
+ const norm = path43.resolve(bridgeRootPath2);
42879
43003
  const base = baseNameSafe(norm);
42880
43004
  const used = new Set(layout.launcherCwds.map((e) => e.dirName));
42881
43005
  let name = base;
@@ -42968,8 +43092,8 @@ function pathspec(...paths) {
42968
43092
  cache.set(key, paths);
42969
43093
  return key;
42970
43094
  }
42971
- function isPathSpec(path86) {
42972
- return path86 instanceof String && cache.has(path86);
43095
+ function isPathSpec(path88) {
43096
+ return path88 instanceof String && cache.has(path88);
42973
43097
  }
42974
43098
  function toPaths(pathSpec) {
42975
43099
  return cache.get(pathSpec) || [];
@@ -43058,8 +43182,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
43058
43182
  function forEachLineWithContent(input, callback) {
43059
43183
  return toLinesWithContent(input, true).map((line) => callback(line));
43060
43184
  }
43061
- function folderExists(path86) {
43062
- return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
43185
+ function folderExists(path88) {
43186
+ return (0, import_file_exists.exists)(path88, import_file_exists.FOLDER);
43063
43187
  }
43064
43188
  function append(target, item) {
43065
43189
  if (Array.isArray(target)) {
@@ -43463,8 +43587,8 @@ function checkIsRepoRootTask() {
43463
43587
  commands,
43464
43588
  format: "utf-8",
43465
43589
  onError,
43466
- parser(path86) {
43467
- return /^\.(git)?$/.test(path86.trim());
43590
+ parser(path88) {
43591
+ return /^\.(git)?$/.test(path88.trim());
43468
43592
  }
43469
43593
  };
43470
43594
  }
@@ -43898,11 +44022,11 @@ function parseGrep(grep) {
43898
44022
  const paths = /* @__PURE__ */ new Set();
43899
44023
  const results = {};
43900
44024
  forEachLineWithContent(grep, (input) => {
43901
- const [path86, line, preview] = input.split(NULL);
43902
- paths.add(path86);
43903
- (results[path86] = results[path86] || []).push({
44025
+ const [path88, line, preview] = input.split(NULL);
44026
+ paths.add(path88);
44027
+ (results[path88] = results[path88] || []).push({
43904
44028
  line: asNumber(line),
43905
- path: path86,
44029
+ path: path88,
43906
44030
  preview
43907
44031
  });
43908
44032
  });
@@ -44667,14 +44791,14 @@ var init_hash_object = __esm2({
44667
44791
  init_task();
44668
44792
  }
44669
44793
  });
44670
- function parseInit(bare, path86, text) {
44794
+ function parseInit(bare, path88, text) {
44671
44795
  const response = String(text).trim();
44672
44796
  let result;
44673
44797
  if (result = initResponseRegex.exec(response)) {
44674
- return new InitSummary(bare, path86, false, result[1]);
44798
+ return new InitSummary(bare, path88, false, result[1]);
44675
44799
  }
44676
44800
  if (result = reInitResponseRegex.exec(response)) {
44677
- return new InitSummary(bare, path86, true, result[1]);
44801
+ return new InitSummary(bare, path88, true, result[1]);
44678
44802
  }
44679
44803
  let gitDir = "";
44680
44804
  const tokens = response.split(" ");
@@ -44685,7 +44809,7 @@ function parseInit(bare, path86, text) {
44685
44809
  break;
44686
44810
  }
44687
44811
  }
44688
- return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
44812
+ return new InitSummary(bare, path88, /^re/i.test(response), gitDir);
44689
44813
  }
44690
44814
  var InitSummary;
44691
44815
  var initResponseRegex;
@@ -44694,9 +44818,9 @@ var init_InitSummary = __esm2({
44694
44818
  "src/lib/responses/InitSummary.ts"() {
44695
44819
  "use strict";
44696
44820
  InitSummary = class {
44697
- constructor(bare, path86, existing, gitDir) {
44821
+ constructor(bare, path88, existing, gitDir) {
44698
44822
  this.bare = bare;
44699
- this.path = path86;
44823
+ this.path = path88;
44700
44824
  this.existing = existing;
44701
44825
  this.gitDir = gitDir;
44702
44826
  }
@@ -44708,7 +44832,7 @@ var init_InitSummary = __esm2({
44708
44832
  function hasBareCommand(command) {
44709
44833
  return command.includes(bareCommand);
44710
44834
  }
44711
- function initTask(bare = false, path86, customArgs) {
44835
+ function initTask(bare = false, path88, customArgs) {
44712
44836
  const commands = ["init", ...customArgs];
44713
44837
  if (bare && !hasBareCommand(commands)) {
44714
44838
  commands.splice(1, 0, bareCommand);
@@ -44717,7 +44841,7 @@ function initTask(bare = false, path86, customArgs) {
44717
44841
  commands,
44718
44842
  format: "utf-8",
44719
44843
  parser(text) {
44720
- return parseInit(commands.includes("--bare"), path86, text);
44844
+ return parseInit(commands.includes("--bare"), path88, text);
44721
44845
  }
44722
44846
  };
44723
44847
  }
@@ -45533,12 +45657,12 @@ var init_FileStatusSummary = __esm2({
45533
45657
  "use strict";
45534
45658
  fromPathRegex = /^(.+)\0(.+)$/;
45535
45659
  FileStatusSummary = class {
45536
- constructor(path86, index, working_dir) {
45537
- this.path = path86;
45660
+ constructor(path88, index, working_dir) {
45661
+ this.path = path88;
45538
45662
  this.index = index;
45539
45663
  this.working_dir = working_dir;
45540
45664
  if (index === "R" || working_dir === "R") {
45541
- const detail = fromPathRegex.exec(path86) || [null, path86, path86];
45665
+ const detail = fromPathRegex.exec(path88) || [null, path88, path88];
45542
45666
  this.from = detail[2] || "";
45543
45667
  this.path = detail[1] || "";
45544
45668
  }
@@ -45569,14 +45693,14 @@ function splitLine(result, lineStr) {
45569
45693
  default:
45570
45694
  return;
45571
45695
  }
45572
- function data(index, workingDir, path86) {
45696
+ function data(index, workingDir, path88) {
45573
45697
  const raw = `${index}${workingDir}`;
45574
45698
  const handler = parsers6.get(raw);
45575
45699
  if (handler) {
45576
- handler(result, path86);
45700
+ handler(result, path88);
45577
45701
  }
45578
45702
  if (raw !== "##" && raw !== "!!") {
45579
- result.files.push(new FileStatusSummary(path86, index, workingDir));
45703
+ result.files.push(new FileStatusSummary(path88, index, workingDir));
45580
45704
  }
45581
45705
  }
45582
45706
  }
@@ -45885,9 +46009,9 @@ var init_simple_git_api = __esm2({
45885
46009
  next
45886
46010
  );
45887
46011
  }
45888
- hashObject(path86, write) {
46012
+ hashObject(path88, write) {
45889
46013
  return this._runTask(
45890
- hashObjectTask(path86, write === true),
46014
+ hashObjectTask(path88, write === true),
45891
46015
  trailingFunctionArgument(arguments)
45892
46016
  );
45893
46017
  }
@@ -46240,8 +46364,8 @@ var init_branch = __esm2({
46240
46364
  }
46241
46365
  });
46242
46366
  function toPath(input) {
46243
- const path86 = input.trim().replace(/^["']|["']$/g, "");
46244
- return path86 && normalize3(path86);
46367
+ const path88 = input.trim().replace(/^["']|["']$/g, "");
46368
+ return path88 && normalize3(path88);
46245
46369
  }
46246
46370
  var parseCheckIgnore;
46247
46371
  var init_CheckIgnore = __esm2({
@@ -46555,8 +46679,8 @@ __export2(sub_module_exports, {
46555
46679
  subModuleTask: () => subModuleTask,
46556
46680
  updateSubModuleTask: () => updateSubModuleTask
46557
46681
  });
46558
- function addSubModuleTask(repo, path86) {
46559
- return subModuleTask(["add", repo, path86]);
46682
+ function addSubModuleTask(repo, path88) {
46683
+ return subModuleTask(["add", repo, path88]);
46560
46684
  }
46561
46685
  function initSubModuleTask(customArgs) {
46562
46686
  return subModuleTask(["init", ...customArgs]);
@@ -46889,8 +47013,8 @@ var require_git = __commonJS2({
46889
47013
  }
46890
47014
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
46891
47015
  };
46892
- Git2.prototype.submoduleAdd = function(repo, path86, then) {
46893
- return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
47016
+ Git2.prototype.submoduleAdd = function(repo, path88, then) {
47017
+ return this._runTask(addSubModuleTask2(repo, path88), trailingFunctionArgument2(arguments));
46894
47018
  };
46895
47019
  Git2.prototype.submoduleUpdate = function(args, then) {
46896
47020
  return this._runTask(
@@ -47629,8 +47753,8 @@ function parseNumstatEntries(lines) {
47629
47753
  }
47630
47754
  function parseNumstat(lines) {
47631
47755
  const m = /* @__PURE__ */ new Map();
47632
- for (const [path86, entry] of parseNumstatEntries(lines)) {
47633
- m.set(path86, { additions: entry.additions, deletions: entry.deletions });
47756
+ for (const [path88, entry] of parseNumstatEntries(lines)) {
47757
+ m.set(path88, { additions: entry.additions, deletions: entry.deletions });
47634
47758
  }
47635
47759
  return m;
47636
47760
  }
@@ -47759,7 +47883,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
47759
47883
  }
47760
47884
 
47761
47885
  // src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
47762
- import * as path42 from "node:path";
47886
+ import * as path44 from "node:path";
47763
47887
  var BASE_SHA_CACHE_TTL_MS = 3e4;
47764
47888
  var baseShaCache = /* @__PURE__ */ new Map();
47765
47889
  async function resolveBaseShaForUnpushedCommitsUncached(g) {
@@ -47770,7 +47894,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
47770
47894
  }
47771
47895
  async function resolveBaseShaForUnpushedCommits(g, repoDir) {
47772
47896
  if (repoDir) {
47773
- const key = path42.resolve(repoDir);
47897
+ const key = path44.resolve(repoDir);
47774
47898
  const now = Date.now();
47775
47899
  const cached2 = baseShaCache.get(key);
47776
47900
  if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
@@ -47905,17 +48029,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
47905
48029
  }
47906
48030
 
47907
48031
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
47908
- import * as path52 from "node:path";
48032
+ import * as path54 from "node:path";
47909
48033
 
47910
48034
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
47911
- import * as path51 from "node:path";
48035
+ import * as path53 from "node:path";
47912
48036
 
47913
48037
  // src/git/is-git-repo.ts
47914
- import * as fs32 from "node:fs";
47915
- import * as path43 from "node:path";
48038
+ import * as fs34 from "node:fs";
48039
+ import * as path45 from "node:path";
47916
48040
  async function isGitRepoDirectory(dirPath) {
47917
48041
  try {
47918
- await fs32.promises.access(path43.join(dirPath, ".git"));
48042
+ await fs34.promises.access(path45.join(dirPath, ".git"));
47919
48043
  return true;
47920
48044
  } catch {
47921
48045
  return false;
@@ -47923,8 +48047,8 @@ async function isGitRepoDirectory(dirPath) {
47923
48047
  }
47924
48048
 
47925
48049
  // src/git/changes/listing/apply-untracked-file-stats.ts
47926
- import * as fs33 from "node:fs";
47927
- import * as path44 from "node:path";
48050
+ import * as fs35 from "node:fs";
48051
+ import * as path46 from "node:path";
47928
48052
 
47929
48053
  // src/git/changes/lines/count-lines.ts
47930
48054
  import { createReadStream } from "node:fs";
@@ -47956,7 +48080,7 @@ function createUntrackedStatsApplier(options) {
47956
48080
  if (!options.untrackedSet.has(pathInRepo)) return;
47957
48081
  if (options.nameByPath.has(pathInRepo)) return;
47958
48082
  if (row.change === "moved") return;
47959
- const repoFilePath = path44.join(options.repoGitCwd, pathInRepo);
48083
+ const repoFilePath = path46.join(options.repoGitCwd, pathInRepo);
47960
48084
  const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
47961
48085
  if (fromGit) {
47962
48086
  row.additions = fromGit.additions;
@@ -47964,7 +48088,7 @@ function createUntrackedStatsApplier(options) {
47964
48088
  return;
47965
48089
  }
47966
48090
  try {
47967
- const st = await fs33.promises.stat(repoFilePath);
48091
+ const st = await fs35.promises.stat(repoFilePath);
47968
48092
  row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
47969
48093
  } catch {
47970
48094
  row.additions = 0;
@@ -48041,7 +48165,7 @@ async function buildChangedFileRowsFromPaths(options) {
48041
48165
  }
48042
48166
 
48043
48167
  // src/git/changes/listing/enrich-working-tree-file-rows.ts
48044
- import * as path46 from "node:path";
48168
+ import * as path48 from "node:path";
48045
48169
 
48046
48170
  // src/git/changes/patch/patch-truncate.ts
48047
48171
  function truncatePatch(s) {
@@ -48129,10 +48253,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
48129
48253
  }
48130
48254
 
48131
48255
  // src/git/changes/patch/hydrate/read-worktree-file-lines.ts
48132
- import * as fs34 from "node:fs";
48256
+ import * as fs36 from "node:fs";
48133
48257
  async function readWorktreeFileLines(filePath) {
48134
48258
  try {
48135
- const raw = await fs34.promises.readFile(filePath, "utf8");
48259
+ const raw = await fs36.promises.readFile(filePath, "utf8");
48136
48260
  return raw.split(/\r?\n/);
48137
48261
  } catch {
48138
48262
  return null;
@@ -48270,8 +48394,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
48270
48394
  }
48271
48395
 
48272
48396
  // src/git/changes/total-lines/resolve-changed-file-total-lines.ts
48273
- import * as fs35 from "node:fs";
48274
- import * as path45 from "node:path";
48397
+ import * as fs37 from "node:fs";
48398
+ import * as path47 from "node:path";
48275
48399
  var MAX_BYTES = 512e3;
48276
48400
  async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
48277
48401
  const spec = `${ref}:${pathInRepo}`;
@@ -48291,13 +48415,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
48291
48415
  }
48292
48416
  async function resolveWorkingTreeFileTotalLines(options) {
48293
48417
  if (options.isBinary) return null;
48294
- const filePath = path45.join(options.repoGitCwd, options.pathInRepo);
48418
+ const filePath = path47.join(options.repoGitCwd, options.pathInRepo);
48295
48419
  if (options.change === "removed") {
48296
48420
  return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
48297
48421
  }
48298
48422
  if (options.change === "moved" || options.change === "modified") {
48299
48423
  try {
48300
- const st = await fs35.promises.stat(filePath);
48424
+ const st = await fs37.promises.stat(filePath);
48301
48425
  if (!st.isFile()) return null;
48302
48426
  return await countTextFileLines(filePath);
48303
48427
  } catch {
@@ -48340,7 +48464,7 @@ async function enrichWorkingTreeFileRows(options) {
48340
48464
  row.workspaceRelPath,
48341
48465
  options.repoPathRelativeToWorkspaceRoot
48342
48466
  );
48343
- const filePath = path46.join(options.repoGitCwd, filePathRelativeToRepoRoot);
48467
+ const filePath = path48.join(options.repoGitCwd, filePathRelativeToRepoRoot);
48344
48468
  const hydrateKind = row.change === "moved" ? "modified" : row.change;
48345
48469
  let patch = await unifiedDiffForFile(
48346
48470
  options.repoGitCwd,
@@ -48498,7 +48622,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
48498
48622
  }
48499
48623
 
48500
48624
  // src/git/changes/listing/list-changed-files-for-commit.ts
48501
- import * as path47 from "node:path";
48625
+ import * as path49 from "node:path";
48502
48626
 
48503
48627
  // src/git/changes/listing/enrich-commit-file-rows.ts
48504
48628
  async function enrichCommitFileRows(options) {
@@ -48543,7 +48667,7 @@ async function parentForCommitDiff(g, sha) {
48543
48667
  var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
48544
48668
  var commitFilesCache = /* @__PURE__ */ new Map();
48545
48669
  function commitFilesCacheKey(repoGitCwd, commitSha) {
48546
- return `${path47.resolve(repoGitCwd)}:${commitSha}`;
48670
+ return `${path49.resolve(repoGitCwd)}:${commitSha}`;
48547
48671
  }
48548
48672
  async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
48549
48673
  const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
@@ -48598,7 +48722,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
48598
48722
  }
48599
48723
 
48600
48724
  // src/git/commits/list-unpushed-commits.ts
48601
- import * as path48 from "node:path";
48725
+ import * as path50 from "node:path";
48602
48726
 
48603
48727
  // src/git/commits/lib/parse-log-lines.ts
48604
48728
  function parseLogShaDateSubjectLines(raw) {
@@ -48633,7 +48757,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
48633
48757
  }
48634
48758
  }
48635
48759
  async function listUnpushedCommits(repoDir) {
48636
- const key = path48.resolve(repoDir);
48760
+ const key = path50.resolve(repoDir);
48637
48761
  const now = Date.now();
48638
48762
  const cached2 = unpushedCache.get(key);
48639
48763
  if (cached2 && cached2.expiresAt > now) return cached2.commits;
@@ -48694,7 +48818,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
48694
48818
  }
48695
48819
 
48696
48820
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
48697
- import * as path49 from "node:path";
48821
+ import * as path51 from "node:path";
48698
48822
 
48699
48823
  // src/git/remote-origin-url.ts
48700
48824
  async function getRemoteOriginUrl(gitDir) {
@@ -48709,7 +48833,7 @@ async function getRemoteOriginUrl(gitDir) {
48709
48833
 
48710
48834
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
48711
48835
  async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
48712
- const resolvedCheckoutPath = path49.resolve(checkoutPath);
48836
+ const resolvedCheckoutPath = path51.resolve(checkoutPath);
48713
48837
  const git = cliSimpleGit(resolvedCheckoutPath);
48714
48838
  await yieldToEventLoop2();
48715
48839
  const [branch, remoteUrl] = await Promise.all([
@@ -48724,14 +48848,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
48724
48848
  }
48725
48849
 
48726
48850
  // src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
48727
- import * as path50 from "node:path";
48851
+ import * as path52 from "node:path";
48728
48852
  async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48729
- const checkoutPath = path50.resolve(options.checkoutPath);
48853
+ const checkoutPath = path52.resolve(options.checkoutPath);
48730
48854
  const git = cliSimpleGit(checkoutPath);
48731
- const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
48855
+ const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
48732
48856
  let repoPathRelativeToWorkspaceRoot;
48733
48857
  if (sessionParentPath) {
48734
- const checkoutPathRelativeToSessionParent = path50.relative(sessionParentPath, checkoutPath);
48858
+ const checkoutPathRelativeToSessionParent = path52.relative(sessionParentPath, checkoutPath);
48735
48859
  repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
48736
48860
  } else {
48737
48861
  let gitTopLevel = checkoutPath;
@@ -48741,8 +48865,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48741
48865
  } catch {
48742
48866
  gitTopLevel = checkoutPath;
48743
48867
  }
48744
- const gitTopLevelRelativeToBridgeRoot = path50.relative(options.bridgeRoot, path50.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
48745
- repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path50.basename(path50.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
48868
+ const gitTopLevelRelativeToBridgeRoot = path52.relative(options.bridgeRoot, path52.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
48869
+ repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path52.basename(path52.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
48746
48870
  }
48747
48871
  return normalizeRepoPathRelativeToWorkspaceRoot(
48748
48872
  repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
@@ -48751,10 +48875,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48751
48875
 
48752
48876
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
48753
48877
  async function buildWorkingTreeChangeRepoDetail(options) {
48754
- const checkoutPath = path51.resolve(options.targetPath);
48878
+ const checkoutPath = path53.resolve(options.targetPath);
48755
48879
  if (!await isGitRepoDirectory(checkoutPath)) return null;
48756
48880
  const isCommitView = options.basis.kind === "commit";
48757
- const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
48881
+ const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
48758
48882
  const git = cliSimpleGit(checkoutPath);
48759
48883
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
48760
48884
  checkoutPath,
@@ -48802,8 +48926,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
48802
48926
 
48803
48927
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
48804
48928
  async function getWorkingTreeChangeRepoDetails(options) {
48805
- const bridgeRoot = path52.resolve(getBridgeRoot());
48806
- const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
48929
+ const bridgeRoot = path54.resolve(getBridgeRoot());
48930
+ const sessionParentPath = options.sessionParentPath ? path54.resolve(options.sessionParentPath) : null;
48807
48931
  const out = [];
48808
48932
  const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
48809
48933
  const basisInput = options.basis ?? { kind: "working" };
@@ -48834,9 +48958,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
48834
48958
  }
48835
48959
 
48836
48960
  // src/git/changes/repo/get-working-tree-change-file-patch.ts
48837
- import * as path53 from "node:path";
48961
+ import * as path55 from "node:path";
48838
48962
  async function getWorkingTreeChangeFilePatch(options) {
48839
- const repoGitCwd = path53.resolve(options.repoGitCwd);
48963
+ const repoGitCwd = path55.resolve(options.repoGitCwd);
48840
48964
  if (!await isGitRepoDirectory(repoGitCwd)) {
48841
48965
  throw new Error("Not a git repository");
48842
48966
  }
@@ -48875,7 +48999,7 @@ async function getWorkingTreeChangeFilePatch(options) {
48875
48999
  });
48876
49000
  return { patchContent: patchContent2, totalLines: totalLines2 };
48877
49001
  }
48878
- const filePath = path53.join(repoGitCwd, filePathRelativeToRepoRoot);
49002
+ const filePath = path55.join(repoGitCwd, filePathRelativeToRepoRoot);
48879
49003
  const hydrateKind = options.change === "moved" ? "modified" : options.change;
48880
49004
  let patchContent = await unifiedDiffForFile(
48881
49005
  repoGitCwd,
@@ -48921,18 +49045,18 @@ function parseWorkingTreeChangeKind(value) {
48921
49045
  }
48922
49046
 
48923
49047
  // src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
48924
- import * as path54 from "node:path";
49048
+ import * as path56 from "node:path";
48925
49049
  async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
48926
49050
  const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
48927
- const bridgeRoot = path54.resolve(getBridgeRoot());
48928
- const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path54.resolve(cache2.getSessionParentPath(sessionId)) : null;
49051
+ const bridgeRoot = path56.resolve(getBridgeRoot());
49052
+ const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path56.resolve(cache2.getSessionParentPath(sessionId)) : null;
48929
49053
  const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
48930
49054
  opts.repoRelPath.trim()
48931
49055
  );
48932
49056
  let result = null;
48933
49057
  await forEachWithGitYield(targets, async (targetPath) => {
48934
49058
  if (result) return;
48935
- const checkoutPath = path54.resolve(targetPath);
49059
+ const checkoutPath = path56.resolve(targetPath);
48936
49060
  if (!await isGitRepoDirectory(checkoutPath)) return;
48937
49061
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
48938
49062
  checkoutPath,
@@ -48965,13 +49089,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
48965
49089
  }
48966
49090
 
48967
49091
  // src/worktrees/remove-session-worktrees.ts
48968
- import * as fs38 from "node:fs";
49092
+ import * as fs40 from "node:fs";
48969
49093
 
48970
49094
  // src/git/worktrees/worktree-remove.ts
48971
- import * as fs37 from "node:fs";
49095
+ import * as fs39 from "node:fs";
48972
49096
 
48973
49097
  // src/worktrees/is-removable-session-worktree-checkout-path.ts
48974
- import path55 from "node:path";
49098
+ import path57 from "node:path";
48975
49099
  init_normalize_resolved_path();
48976
49100
  function isBridgeRootCheckoutPath(checkoutPath) {
48977
49101
  return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
@@ -48980,23 +49104,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
48980
49104
  if (isBridgeRootCheckoutPath(checkoutPath)) return false;
48981
49105
  const normalized = normalizeResolvedPath(checkoutPath);
48982
49106
  const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
48983
- const rel = path55.relative(worktreesRoot, normalized);
48984
- if (rel === "" || rel.startsWith("..") || path55.isAbsolute(rel)) return false;
49107
+ const rel = path57.relative(worktreesRoot, normalized);
49108
+ if (rel === "" || rel.startsWith("..") || path57.isAbsolute(rel)) return false;
48985
49109
  return true;
48986
49110
  }
48987
49111
 
48988
49112
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
48989
- import * as fs36 from "node:fs";
48990
- import * as path56 from "node:path";
49113
+ import * as fs38 from "node:fs";
49114
+ import * as path58 from "node:path";
48991
49115
  function resolveMainRepoFromWorktreeGitFile(wt) {
48992
- const gitDirFile = path56.join(wt, ".git");
48993
- if (!fs36.existsSync(gitDirFile) || !fs36.statSync(gitDirFile).isFile()) return "";
48994
- const first2 = fs36.readFileSync(gitDirFile, "utf8").trim();
49116
+ const gitDirFile = path58.join(wt, ".git");
49117
+ if (!fs38.existsSync(gitDirFile) || !fs38.statSync(gitDirFile).isFile()) return "";
49118
+ const first2 = fs38.readFileSync(gitDirFile, "utf8").trim();
48995
49119
  const m = first2.match(/^gitdir:\s*(.+)$/im);
48996
49120
  if (!m) return "";
48997
- const gitWorktreePath = path56.resolve(wt, m[1].trim());
48998
- const gitDir = path56.dirname(path56.dirname(gitWorktreePath));
48999
- return path56.dirname(gitDir);
49121
+ const gitWorktreePath = path58.resolve(wt, m[1].trim());
49122
+ const gitDir = path58.dirname(path58.dirname(gitWorktreePath));
49123
+ return path58.dirname(gitDir);
49000
49124
  }
49001
49125
 
49002
49126
  // src/git/worktrees/worktree-remove.ts
@@ -49007,7 +49131,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
49007
49131
  return true;
49008
49132
  }
49009
49133
  if (isBridgeRootCheckoutPath(worktreePath)) return false;
49010
- fs37.rmSync(worktreePath, { recursive: true, force: true });
49134
+ fs39.rmSync(worktreePath, { recursive: true, force: true });
49011
49135
  return true;
49012
49136
  }
49013
49137
 
@@ -49029,7 +49153,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
49029
49153
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
49030
49154
  if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
49031
49155
  try {
49032
- fs38.rmSync(wt, { recursive: true, force: true });
49156
+ fs40.rmSync(wt, { recursive: true, force: true });
49033
49157
  } catch {
49034
49158
  }
49035
49159
  }
@@ -49085,12 +49209,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
49085
49209
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
49086
49210
  init_cli_process_interrupt();
49087
49211
  init_yield_to_event_loop();
49088
- import * as fs42 from "node:fs";
49089
- import * as path61 from "node:path";
49212
+ import * as fs44 from "node:fs";
49213
+ import * as path63 from "node:path";
49090
49214
 
49091
49215
  // src/worktrees/discovery/collect-worktree-paths.ts
49092
- import * as fs40 from "node:fs";
49093
- import * as path58 from "node:path";
49216
+ import * as fs42 from "node:fs";
49217
+ import * as path60 from "node:path";
49094
49218
 
49095
49219
  // src/worktrees/discovery/disk-walk-constants.ts
49096
49220
  var DISK_WALK_YIELD_EVERY = 64;
@@ -49120,8 +49244,8 @@ function shouldSkipDiskWalkEntry(name) {
49120
49244
  // src/worktrees/discovery/disk-walk-utils.ts
49121
49245
  init_cli_process_interrupt();
49122
49246
  init_yield_to_event_loop();
49123
- import * as fs39 from "node:fs";
49124
- import * as path57 from "node:path";
49247
+ import * as fs41 from "node:fs";
49248
+ import * as path59 from "node:path";
49125
49249
  async function yieldDuringDiskWalk(state) {
49126
49250
  state.entries++;
49127
49251
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -49131,7 +49255,7 @@ async function yieldDuringDiskWalk(state) {
49131
49255
  }
49132
49256
  async function isGitDir(dirPath) {
49133
49257
  try {
49134
- await fs39.promises.access(path57.join(dirPath, ".git"));
49258
+ await fs41.promises.access(path59.join(dirPath, ".git"));
49135
49259
  return true;
49136
49260
  } catch {
49137
49261
  return false;
@@ -49145,23 +49269,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
49145
49269
  const walk = async (dir) => {
49146
49270
  if (!await yieldDuringDiskWalk(state)) return;
49147
49271
  if (await isGitDir(dir)) {
49148
- out.push(path58.resolve(dir));
49272
+ out.push(path60.resolve(dir));
49149
49273
  return;
49150
49274
  }
49151
49275
  let entries;
49152
49276
  try {
49153
- entries = await fs40.promises.readdir(dir, { withFileTypes: true });
49277
+ entries = await fs42.promises.readdir(dir, { withFileTypes: true });
49154
49278
  } catch {
49155
49279
  return;
49156
49280
  }
49157
49281
  for (const e of entries) {
49158
49282
  if (shouldSkipDiskWalkEntry(e.name)) continue;
49159
- const full = path58.join(dir, e.name);
49283
+ const full = path60.join(dir, e.name);
49160
49284
  if (!e.isDirectory()) continue;
49161
49285
  await walk(full);
49162
49286
  }
49163
49287
  };
49164
- await walk(path58.resolve(rootPath));
49288
+ await walk(path60.resolve(rootPath));
49165
49289
  return { paths: [...new Set(out)], entriesVisited: state.entries };
49166
49290
  }
49167
49291
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -49172,16 +49296,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
49172
49296
  if (!await yieldDuringDiskWalk(state)) return;
49173
49297
  let entries;
49174
49298
  try {
49175
- entries = await fs40.promises.readdir(dir, { withFileTypes: true });
49299
+ entries = await fs42.promises.readdir(dir, { withFileTypes: true });
49176
49300
  } catch {
49177
49301
  return;
49178
49302
  }
49179
49303
  for (const e of entries) {
49180
49304
  if (shouldSkipDiskWalkEntry(e.name)) continue;
49181
- const full = path58.join(dir, e.name);
49305
+ const full = path60.join(dir, e.name);
49182
49306
  if (!e.isDirectory()) continue;
49183
49307
  if (e.name === sessionId) {
49184
- if (await isGitDir(full)) out.push(path58.resolve(full));
49308
+ if (await isGitDir(full)) out.push(path60.resolve(full));
49185
49309
  continue;
49186
49310
  }
49187
49311
  if (await isGitDir(full)) continue;
@@ -49193,14 +49317,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
49193
49317
  }
49194
49318
 
49195
49319
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
49196
- import * as path59 from "node:path";
49320
+ import * as path61 from "node:path";
49197
49321
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
49198
- const bridge = path59.resolve(bridgeRoot);
49322
+ const bridge = path61.resolve(bridgeRoot);
49199
49323
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
49200
49324
  const relevant = layout.launcherCwds.filter((e) => {
49201
- const entry = path59.resolve(e.absolutePath);
49202
- return bridge === entry || bridge.startsWith(entry + path59.sep) || entry.startsWith(bridge + path59.sep);
49203
- }).sort((a, b) => path59.resolve(b.absolutePath).length - path59.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
49325
+ const entry = path61.resolve(e.absolutePath);
49326
+ return bridge === entry || bridge.startsWith(entry + path61.sep) || entry.startsWith(bridge + path61.sep);
49327
+ }).sort((a, b) => path61.resolve(b.absolutePath).length - path61.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
49204
49328
  const ordered = [];
49205
49329
  const seen = /* @__PURE__ */ new Set();
49206
49330
  const add = (k) => {
@@ -49218,19 +49342,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
49218
49342
  }
49219
49343
 
49220
49344
  // src/worktrees/discovery/try-binding-from-isolated-directory.ts
49221
- import * as fs41 from "node:fs";
49222
- import * as path60 from "node:path";
49345
+ import * as fs43 from "node:fs";
49346
+ import * as path62 from "node:path";
49223
49347
  async function tryBindingFromIsolatedDirectory(scopeDir) {
49224
49348
  let st;
49225
49349
  try {
49226
- st = await fs41.promises.stat(scopeDir);
49350
+ st = await fs43.promises.stat(scopeDir);
49227
49351
  } catch {
49228
49352
  return null;
49229
49353
  }
49230
49354
  if (!st.isDirectory()) return null;
49231
49355
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
49232
49356
  if (worktreePaths.length === 0) return null;
49233
- const abs = path60.resolve(scopeDir);
49357
+ const abs = path62.resolve(scopeDir);
49234
49358
  return {
49235
49359
  parentPath: abs,
49236
49360
  repoCheckoutPaths: worktreePaths
@@ -49253,7 +49377,7 @@ async function discoverSessionWorktreeOnDisk(options) {
49253
49377
  const sid = sessionId.trim();
49254
49378
  if (!sid) return null;
49255
49379
  try {
49256
- await fs42.promises.access(worktreesRootPath);
49380
+ await fs44.promises.access(worktreesRootPath);
49257
49381
  } catch {
49258
49382
  return null;
49259
49383
  }
@@ -49262,13 +49386,13 @@ async function discoverSessionWorktreeOnDisk(options) {
49262
49386
  if (preferredKey) keysOnDisk.push(preferredKey);
49263
49387
  const scanState = { entries: 0 };
49264
49388
  try {
49265
- for (const name of await fs42.promises.readdir(worktreesRootPath)) {
49389
+ for (const name of await fs44.promises.readdir(worktreesRootPath)) {
49266
49390
  if (!await yieldDuringDiskWalk(scanState)) break;
49267
49391
  if (name.startsWith(".")) continue;
49268
- const p = path61.join(worktreesRootPath, name);
49392
+ const p = path63.join(worktreesRootPath, name);
49269
49393
  let st;
49270
49394
  try {
49271
- st = await fs42.promises.stat(p);
49395
+ st = await fs44.promises.stat(p);
49272
49396
  } catch {
49273
49397
  continue;
49274
49398
  }
@@ -49282,23 +49406,23 @@ async function discoverSessionWorktreeOnDisk(options) {
49282
49406
  for (const key of keys) {
49283
49407
  if (isCliImmediateShutdownRequested()) return null;
49284
49408
  await yieldToEventLoop();
49285
- const layoutRoot = path61.join(worktreesRootPath, key);
49409
+ const layoutRoot = path63.join(worktreesRootPath, key);
49286
49410
  let layoutSt;
49287
49411
  try {
49288
- layoutSt = await fs42.promises.stat(layoutRoot);
49412
+ layoutSt = await fs44.promises.stat(layoutRoot);
49289
49413
  } catch {
49290
49414
  continue;
49291
49415
  }
49292
49416
  if (!layoutSt.isDirectory()) continue;
49293
- const sessionDir = path61.join(layoutRoot, sid);
49417
+ const sessionDir = path63.join(layoutRoot, sid);
49294
49418
  const nested = await tryBindingFromSessionDirectory(sessionDir);
49295
49419
  if (nested) return nested;
49296
49420
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
49297
49421
  if (legacy.paths.length > 0) {
49298
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path61.resolve(legacy.paths[0]);
49422
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path63.resolve(legacy.paths[0]);
49299
49423
  return {
49300
- sessionParentPath: path61.resolve(isolated),
49301
- repoCheckoutPaths: legacy.paths.map((p) => path61.resolve(p))
49424
+ sessionParentPath: path63.resolve(isolated),
49425
+ repoCheckoutPaths: legacy.paths.map((p) => path63.resolve(p))
49302
49426
  };
49303
49427
  }
49304
49428
  }
@@ -49306,31 +49430,31 @@ async function discoverSessionWorktreeOnDisk(options) {
49306
49430
  }
49307
49431
 
49308
49432
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
49309
- import * as fs43 from "node:fs";
49310
- import * as path63 from "node:path";
49433
+ import * as fs45 from "node:fs";
49434
+ import * as path65 from "node:path";
49311
49435
 
49312
49436
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
49313
49437
  init_cli_process_interrupt();
49314
49438
  init_yield_to_event_loop();
49315
- import * as path62 from "node:path";
49439
+ import * as path64 from "node:path";
49316
49440
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
49317
49441
  const sid = sessionId.trim();
49318
49442
  if (!sid) return null;
49319
- const hintR = path62.resolve(checkoutPath);
49443
+ const hintR = path64.resolve(checkoutPath);
49320
49444
  let best = null;
49321
- let cur = path62.dirname(hintR);
49445
+ let cur = path64.dirname(hintR);
49322
49446
  for (let i = 0; i < 40; i++) {
49323
49447
  if (isCliImmediateShutdownRequested()) return best;
49324
49448
  await yieldToEventLoop();
49325
49449
  const paths = await collectWorktreeRootsNamed(cur, sid);
49326
- if (paths.paths.some((p) => path62.resolve(p) === hintR)) {
49327
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path62.resolve(paths.paths[0]);
49450
+ if (paths.paths.some((p) => path64.resolve(p) === hintR)) {
49451
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path64.resolve(paths.paths[0]);
49328
49452
  best = {
49329
- sessionParentPath: path62.resolve(isolated),
49330
- repoCheckoutPaths: paths.paths.map((p) => path62.resolve(p))
49453
+ sessionParentPath: path64.resolve(isolated),
49454
+ repoCheckoutPaths: paths.paths.map((p) => path64.resolve(p))
49331
49455
  };
49332
49456
  }
49333
- const next = path62.dirname(cur);
49457
+ const next = path64.dirname(cur);
49334
49458
  if (next === cur) break;
49335
49459
  cur = next;
49336
49460
  }
@@ -49341,12 +49465,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
49341
49465
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
49342
49466
  const sid = sessionId.trim();
49343
49467
  if (!sid) return null;
49344
- const hint = path63.resolve(sessionParentPathOrHint);
49345
- const underHint = await tryBindingFromSessionDirectory(path63.join(hint, sid));
49468
+ const hint = path65.resolve(sessionParentPathOrHint);
49469
+ const underHint = await tryBindingFromSessionDirectory(path65.join(hint, sid));
49346
49470
  if (underHint) return underHint;
49347
49471
  const direct = await tryBindingFromSessionDirectory(hint);
49348
49472
  if (direct) {
49349
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
49473
+ if (path65.basename(hint) === sid && await isGitDir(hint)) {
49350
49474
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
49351
49475
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
49352
49476
  return legacyFromCheckout;
@@ -49354,23 +49478,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
49354
49478
  }
49355
49479
  return direct;
49356
49480
  }
49357
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
49481
+ if (path65.basename(hint) === sid && await isGitDir(hint)) {
49358
49482
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
49359
49483
  if (legacyFromCheckout) return legacyFromCheckout;
49360
49484
  }
49361
49485
  let st;
49362
49486
  try {
49363
- st = await fs43.promises.stat(hint);
49487
+ st = await fs45.promises.stat(hint);
49364
49488
  } catch {
49365
49489
  return null;
49366
49490
  }
49367
49491
  if (!st.isDirectory()) return null;
49368
49492
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
49369
49493
  if (legacyPaths.paths.length === 0) return null;
49370
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path63.resolve(legacyPaths.paths[0]);
49494
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path65.resolve(legacyPaths.paths[0]);
49371
49495
  return {
49372
- sessionParentPath: path63.resolve(isolated),
49373
- repoCheckoutPaths: legacyPaths.paths.map((p) => path63.resolve(p))
49496
+ sessionParentPath: path65.resolve(isolated),
49497
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path65.resolve(p))
49374
49498
  };
49375
49499
  }
49376
49500
 
@@ -49431,11 +49555,11 @@ function parseSessionParent(v) {
49431
49555
  }
49432
49556
 
49433
49557
  // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
49434
- import * as fs47 from "node:fs";
49558
+ import * as fs49 from "node:fs";
49435
49559
 
49436
49560
  // src/git/discover-repos.ts
49437
- import * as fs44 from "node:fs";
49438
- import * as path64 from "node:path";
49561
+ import * as fs46 from "node:fs";
49562
+ import * as path66 from "node:path";
49439
49563
  init_yield_to_event_loop();
49440
49564
  var GIT_DISCOVER_YIELD_EVERY = 32;
49441
49565
  async function yieldGitDiscoverWork(entryCount) {
@@ -49445,14 +49569,14 @@ async function yieldGitDiscoverWork(entryCount) {
49445
49569
  }
49446
49570
  async function discoverGitRepos(cwd = getBridgeRoot()) {
49447
49571
  const result = [];
49448
- const cwdResolved = path64.resolve(cwd);
49572
+ const cwdResolved = path66.resolve(cwd);
49449
49573
  if (await isGitRepoDirectory(cwdResolved)) {
49450
49574
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
49451
49575
  result.push({ absolutePath: cwdResolved, remoteUrl });
49452
49576
  }
49453
49577
  let entries;
49454
49578
  try {
49455
- entries = fs44.readdirSync(cwdResolved, { withFileTypes: true });
49579
+ entries = fs46.readdirSync(cwdResolved, { withFileTypes: true });
49456
49580
  } catch {
49457
49581
  return result;
49458
49582
  }
@@ -49460,7 +49584,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
49460
49584
  await yieldGitDiscoverWork(i + 1);
49461
49585
  const ent = entries[i];
49462
49586
  if (!ent.isDirectory()) continue;
49463
- const childPath2 = path64.join(cwdResolved, ent.name);
49587
+ const childPath2 = path66.join(cwdResolved, ent.name);
49464
49588
  if (await isGitRepoDirectory(childPath2)) {
49465
49589
  const remoteUrl = await getRemoteOriginUrl(childPath2);
49466
49590
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -49469,17 +49593,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
49469
49593
  return result;
49470
49594
  }
49471
49595
  async function discoverGitReposUnderRoot(rootPath) {
49472
- const root = path64.resolve(rootPath);
49596
+ const root = path66.resolve(rootPath);
49473
49597
  const roots = [];
49474
49598
  let walkEntries = 0;
49475
49599
  async function walk(dir) {
49476
49600
  if (await isGitRepoDirectory(dir)) {
49477
- roots.push(path64.resolve(dir));
49601
+ roots.push(path66.resolve(dir));
49478
49602
  return;
49479
49603
  }
49480
49604
  let entries;
49481
49605
  try {
49482
- entries = fs44.readdirSync(dir, { withFileTypes: true });
49606
+ entries = fs46.readdirSync(dir, { withFileTypes: true });
49483
49607
  } catch {
49484
49608
  return;
49485
49609
  }
@@ -49487,7 +49611,7 @@ async function discoverGitReposUnderRoot(rootPath) {
49487
49611
  await yieldGitDiscoverWork(++walkEntries);
49488
49612
  const ent = entries[i];
49489
49613
  if (!ent.isDirectory() || ent.name === ".git") continue;
49490
- await walk(path64.join(dir, ent.name));
49614
+ await walk(path66.join(dir, ent.name));
49491
49615
  }
49492
49616
  }
49493
49617
  await walk(root);
@@ -49503,8 +49627,8 @@ async function discoverGitReposUnderRoot(rootPath) {
49503
49627
  }
49504
49628
 
49505
49629
  // src/worktrees/prepare/add-isolated-repo-worktree.ts
49506
- import * as fs46 from "node:fs";
49507
- import * as path66 from "node:path";
49630
+ import * as fs48 from "node:fs";
49631
+ import * as path68 from "node:path";
49508
49632
 
49509
49633
  // src/git/worktrees/worktree-add.ts
49510
49634
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
@@ -49520,8 +49644,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
49520
49644
  }
49521
49645
 
49522
49646
  // src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
49523
- import * as fs45 from "node:fs";
49524
- import * as path65 from "node:path";
49647
+ import * as fs47 from "node:fs";
49648
+ import * as path67 from "node:path";
49525
49649
  var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
49526
49650
  function copyBridgeFilesAlongWorktreePath(options) {
49527
49651
  const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
@@ -49530,19 +49654,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
49530
49654
  const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
49531
49655
  for (let i = 0; i < segments.length; i++) {
49532
49656
  const prefix = segments.slice(0, i).join("/");
49533
- const bridgeDir = prefix ? path65.join(bridgeRoot, prefix) : bridgeRoot;
49534
- const destDir = prefix ? path65.join(scopeDir, prefix) : scopeDir;
49657
+ const bridgeDir = prefix ? path67.join(bridgeRoot, prefix) : bridgeRoot;
49658
+ const destDir = prefix ? path67.join(scopeDir, prefix) : scopeDir;
49535
49659
  for (const fileName of fileNames) {
49536
49660
  copyFileIfPresent(bridgeDir, destDir, fileName, log2);
49537
49661
  }
49538
49662
  }
49539
49663
  }
49540
49664
  function copyFileIfPresent(srcDir, destDir, fileName, log2) {
49541
- const src = path65.join(srcDir, fileName);
49542
- if (!fs45.existsSync(src)) return;
49543
- const dest = path65.join(destDir, fileName);
49665
+ const src = path67.join(srcDir, fileName);
49666
+ if (!fs47.existsSync(src)) return;
49667
+ const dest = path67.join(destDir, fileName);
49544
49668
  try {
49545
- fs45.copyFileSync(src, dest);
49669
+ fs47.copyFileSync(src, dest);
49546
49670
  log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
49547
49671
  } catch (e) {
49548
49672
  log2?.(
@@ -49574,16 +49698,16 @@ async function addIsolatedRepoWorktree(options) {
49574
49698
  worktreeBaseBranches,
49575
49699
  log: log2
49576
49700
  } = options;
49577
- const repoPathRelativeToBridgeRootRaw = path66.relative(bridgeResolved, repoAbsolutePath);
49578
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path66.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
49701
+ const repoPathRelativeToBridgeRootRaw = path68.relative(bridgeResolved, repoAbsolutePath);
49702
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path68.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
49579
49703
  return null;
49580
49704
  }
49581
49705
  const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
49582
49706
  repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
49583
49707
  );
49584
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path66.join(scopeDir, repoPathRelativeToBridgeRoot);
49708
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path68.join(scopeDir, repoPathRelativeToBridgeRoot);
49585
49709
  if (repoPathRelativeToBridgeRoot !== ".") {
49586
- fs46.mkdirSync(path66.dirname(worktreePath), { recursive: true });
49710
+ fs48.mkdirSync(path68.dirname(worktreePath), { recursive: true });
49587
49711
  copyBridgeFilesAlongWorktreePath({
49588
49712
  bridgeRoot: bridgeResolved,
49589
49713
  scopeDir,
@@ -49611,7 +49735,7 @@ async function addIsolatedRepoWorktree(options) {
49611
49735
  }
49612
49736
 
49613
49737
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
49614
- import * as path67 from "node:path";
49738
+ import * as path69 from "node:path";
49615
49739
 
49616
49740
  // src/worktrees/worktree-layout-kind.ts
49617
49741
  function sanitizeWorktreeBranchSegment(value) {
@@ -49641,10 +49765,10 @@ function previewDeployBranchName(environmentId) {
49641
49765
 
49642
49766
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
49643
49767
  function resolveIsolatedScopeDir(options) {
49644
- const bridgeResolved = path67.resolve(options.bridgeRoot);
49768
+ const bridgeResolved = path69.resolve(options.bridgeRoot);
49645
49769
  const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
49646
- const bridgeKeyDir = path67.join(options.worktreesRootPath, cwdKey);
49647
- const scopeDir = path67.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
49770
+ const bridgeKeyDir = path69.join(options.worktreesRootPath, cwdKey);
49771
+ const scopeDir = path69.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
49648
49772
  return { bridgeResolved, scopeDir };
49649
49773
  }
49650
49774
 
@@ -49674,7 +49798,7 @@ async function prepareNewIsolatedWorktrees(options) {
49674
49798
  return null;
49675
49799
  }
49676
49800
  const worktreePaths = [];
49677
- fs47.mkdirSync(scopeDir, { recursive: true });
49801
+ fs49.mkdirSync(scopeDir, { recursive: true });
49678
49802
  await forEachWithGitYield(repos, async (repo) => {
49679
49803
  const worktreePath = await addIsolatedRepoWorktree({
49680
49804
  kind,
@@ -49746,10 +49870,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
49746
49870
  }
49747
49871
 
49748
49872
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
49749
- import * as path68 from "node:path";
49873
+ import * as path70 from "node:path";
49750
49874
  init_yield_to_event_loop();
49751
49875
  async function resolveExplicitSessionParentPath(params) {
49752
- const resolved = path68.resolve(params.parentPathRaw);
49876
+ const resolved = path70.resolve(params.parentPathRaw);
49753
49877
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
49754
49878
  return resolved;
49755
49879
  }
@@ -49766,7 +49890,7 @@ async function resolveExplicitSessionParentPath(params) {
49766
49890
  await yieldToEventLoop();
49767
49891
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
49768
49892
  if (tryRoot) return rememberAndReturn(tryRoot);
49769
- const next = path68.dirname(cur);
49893
+ const next = path70.dirname(cur);
49770
49894
  if (next === cur) break;
49771
49895
  cur = next;
49772
49896
  }
@@ -49927,15 +50051,15 @@ var SessionWorktreeManager = class {
49927
50051
  };
49928
50052
 
49929
50053
  // src/worktrees/discovery/discover-preview-worktree-on-disk.ts
49930
- import * as fs48 from "node:fs";
49931
- import * as path69 from "node:path";
50054
+ import * as fs50 from "node:fs";
50055
+ import * as path71 from "node:path";
49932
50056
  init_yield_to_event_loop();
49933
50057
  async function discoverPreviewWorktreeOnDisk(options) {
49934
50058
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
49935
50059
  const eid = environmentId.trim();
49936
50060
  if (!eid) return null;
49937
50061
  try {
49938
- await fs48.promises.access(worktreesRootPath);
50062
+ await fs50.promises.access(worktreesRootPath);
49939
50063
  } catch {
49940
50064
  return null;
49941
50065
  }
@@ -49944,13 +50068,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
49944
50068
  if (preferredKey) keysOnDisk.push(preferredKey);
49945
50069
  const scanState = { entries: 0 };
49946
50070
  try {
49947
- for (const name of await fs48.promises.readdir(worktreesRootPath)) {
50071
+ for (const name of await fs50.promises.readdir(worktreesRootPath)) {
49948
50072
  if (!await yieldDuringDiskWalk(scanState)) break;
49949
50073
  if (name.startsWith(".")) continue;
49950
- const p = path69.join(worktreesRootPath, name);
50074
+ const p = path71.join(worktreesRootPath, name);
49951
50075
  let st;
49952
50076
  try {
49953
- st = await fs48.promises.stat(p);
50077
+ st = await fs50.promises.stat(p);
49954
50078
  } catch {
49955
50079
  continue;
49956
50080
  }
@@ -49964,7 +50088,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
49964
50088
  const previewDirRel = layoutDirSegments("preview_environment", eid);
49965
50089
  for (const key of keys) {
49966
50090
  await yieldToEventLoop();
49967
- const previewDir = path69.join(worktreesRootPath, key, ...previewDirRel);
50091
+ const previewDir = path71.join(worktreesRootPath, key, ...previewDirRel);
49968
50092
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
49969
50093
  if (binding) return binding;
49970
50094
  }
@@ -50091,7 +50215,7 @@ var PreviewWorktreeManager = class {
50091
50215
  };
50092
50216
 
50093
50217
  // src/worktrees/deploy/deploy-session-to-preview-environment.ts
50094
- import * as path73 from "node:path";
50218
+ import * as path75 from "node:path";
50095
50219
 
50096
50220
  // src/git/worktrees/reset-worktree-to-branch.ts
50097
50221
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -50102,8 +50226,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
50102
50226
  }
50103
50227
 
50104
50228
  // src/worktrees/deploy/capture-and-apply-wip.ts
50105
- import * as fs49 from "node:fs";
50106
- import * as path70 from "node:path";
50229
+ import * as fs51 from "node:fs";
50230
+ import * as path72 from "node:path";
50107
50231
 
50108
50232
  // src/git/snapshot/git.ts
50109
50233
  var SNAPSHOT_GIT_TIMEOUT_MS = 5e3;
@@ -50158,12 +50282,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
50158
50282
  if (!ap.ok) return ap;
50159
50283
  }
50160
50284
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
50161
- const src = path70.join(sourceRepoPath, rel);
50162
- const dst = path70.join(targetRepoPath, rel);
50285
+ const src = path72.join(sourceRepoPath, rel);
50286
+ const dst = path72.join(targetRepoPath, rel);
50163
50287
  try {
50164
- if (!fs49.existsSync(src)) return;
50165
- fs49.mkdirSync(path70.dirname(dst), { recursive: true });
50166
- fs49.copyFileSync(src, dst);
50288
+ if (!fs51.existsSync(src)) return;
50289
+ fs51.mkdirSync(path72.dirname(dst), { recursive: true });
50290
+ fs51.copyFileSync(src, dst);
50167
50291
  } catch (e) {
50168
50292
  log2(
50169
50293
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -50174,14 +50298,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
50174
50298
  }
50175
50299
 
50176
50300
  // src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
50177
- import * as path71 from "node:path";
50301
+ import * as path73 from "node:path";
50178
50302
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
50179
50303
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
50180
- const resolvedSessionParentPath = sessionParentPath ? path71.resolve(sessionParentPath) : null;
50304
+ const resolvedSessionParentPath = sessionParentPath ? path73.resolve(sessionParentPath) : null;
50181
50305
  let match = null;
50182
50306
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
50183
50307
  if (match) return;
50184
- const resolvedCheckoutPath = path71.resolve(checkoutPath);
50308
+ const resolvedCheckoutPath = path73.resolve(checkoutPath);
50185
50309
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
50186
50310
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
50187
50311
  checkoutPath: resolvedCheckoutPath,
@@ -50235,7 +50359,7 @@ async function applySessionWipToPreviewCheckouts(options) {
50235
50359
  }
50236
50360
 
50237
50361
  // src/worktrees/deploy/collect-session-repo-deploy-states.ts
50238
- import * as path72 from "node:path";
50362
+ import * as path74 from "node:path";
50239
50363
 
50240
50364
  // src/git/branches/create-or-update-branch.ts
50241
50365
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -50272,19 +50396,19 @@ async function collectSessionRepoDeployStates(options) {
50272
50396
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
50273
50397
  const states = [];
50274
50398
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
50275
- const checkoutPath = path72.resolve(sessionCheckout);
50399
+ const checkoutPath = path74.resolve(sessionCheckout);
50276
50400
  if (!await isGitRepoDirectory(checkoutPath)) return;
50277
50401
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
50278
50402
  checkoutPath,
50279
50403
  bridgeRoot,
50280
- sessionParentPath: sessionParentPath ? path72.resolve(sessionParentPath) : null
50404
+ sessionParentPath: sessionParentPath ? path74.resolve(sessionParentPath) : null
50281
50405
  });
50282
50406
  if (!repoPathRelativeToWorkspaceRoot) return;
50283
50407
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
50284
50408
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
50285
50409
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
50286
50410
  checkoutPaths: previewCheckoutPaths,
50287
- sessionParentPath: previewParentPath ? path72.resolve(previewParentPath) : null,
50411
+ sessionParentPath: previewParentPath ? path74.resolve(previewParentPath) : null,
50288
50412
  bridgeRoot,
50289
50413
  repoPathRelativeToWorkspaceRoot
50290
50414
  }) : null;
@@ -50304,7 +50428,7 @@ async function deploySessionToPreviewEnvironment(options) {
50304
50428
  const eid = options.environmentId.trim();
50305
50429
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
50306
50430
  const deployBranch = previewDeployBranchName(eid);
50307
- const bridgeRoot = path73.resolve(getBridgeRoot());
50431
+ const bridgeRoot = path75.resolve(getBridgeRoot());
50308
50432
  await previewWorktreeManager.ensureCached(eid);
50309
50433
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
50310
50434
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -50344,10 +50468,10 @@ async function deploySessionToPreviewEnvironment(options) {
50344
50468
  }
50345
50469
 
50346
50470
  // src/worktrees/manager/default-worktrees-root-path.ts
50347
- import * as path74 from "node:path";
50348
- import os9 from "node:os";
50471
+ import * as path76 from "node:path";
50472
+ import os10 from "node:os";
50349
50473
  function defaultWorktreesRootPath() {
50350
- return path74.join(os9.homedir(), ".buildautomaton", "worktrees");
50474
+ return path76.join(os10.homedir(), ".buildautomaton", "worktrees");
50351
50475
  }
50352
50476
 
50353
50477
  // src/connection/create-bridge-worktree-managers.ts
@@ -50477,14 +50601,14 @@ function assertBridgeWorkspace(ctx) {
50477
50601
  }
50478
50602
 
50479
50603
  // src/files/list-dir/index.ts
50480
- import fs51 from "node:fs";
50604
+ import fs53 from "node:fs";
50481
50605
 
50482
50606
  // src/files/ensure-under-cwd.ts
50483
- import path75 from "node:path";
50607
+ import path77 from "node:path";
50484
50608
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
50485
- const normalized = path75.normalize(relativePath).replace(/^(\.\/)+/, "");
50486
- const resolved = path75.resolve(cwd, normalized);
50487
- if (!resolved.startsWith(cwd + path75.sep) && resolved !== cwd) {
50609
+ const normalized = path77.normalize(relativePath).replace(/^(\.\/)+/, "");
50610
+ const resolved = path77.resolve(cwd, normalized);
50611
+ if (!resolved.startsWith(cwd + path77.sep) && resolved !== cwd) {
50488
50612
  return null;
50489
50613
  }
50490
50614
  return resolved;
@@ -50497,15 +50621,15 @@ init_yield_to_event_loop();
50497
50621
  var LIST_DIR_YIELD_EVERY = 256;
50498
50622
 
50499
50623
  // src/files/list-dir/map-dir-entry.ts
50500
- import path76 from "node:path";
50501
- import fs50 from "node:fs";
50624
+ import path78 from "node:path";
50625
+ import fs52 from "node:fs";
50502
50626
  async function mapDirEntry(d, relativePath, resolved) {
50503
- const entryPath = path76.join(relativePath || ".", d.name).replace(/\\/g, "/");
50504
- const fullPath = path76.join(resolved, d.name);
50627
+ const entryPath = path78.join(relativePath || ".", d.name).replace(/\\/g, "/");
50628
+ const fullPath = path78.join(resolved, d.name);
50505
50629
  let isDir = d.isDirectory();
50506
50630
  if (d.isSymbolicLink()) {
50507
50631
  try {
50508
- const targetStat = await fs50.promises.stat(fullPath);
50632
+ const targetStat = await fs52.promises.stat(fullPath);
50509
50633
  isDir = targetStat.isDirectory();
50510
50634
  } catch {
50511
50635
  isDir = false;
@@ -50535,7 +50659,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
50535
50659
  return { error: "Path is outside working directory" };
50536
50660
  }
50537
50661
  try {
50538
- const names = await fs51.promises.readdir(resolved, { withFileTypes: true });
50662
+ const names = await fs53.promises.readdir(resolved, { withFileTypes: true });
50539
50663
  const entries = [];
50540
50664
  for (let i = 0; i < names.length; i++) {
50541
50665
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -50551,13 +50675,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
50551
50675
  }
50552
50676
 
50553
50677
  // src/git/tree/resolve-repo-abs-path.ts
50554
- import * as path77 from "node:path";
50678
+ import * as path79 from "node:path";
50555
50679
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
50556
- const bridgeResolved = path77.resolve(bridgeRoot);
50680
+ const bridgeResolved = path79.resolve(bridgeRoot);
50557
50681
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
50558
- const repoPath = rel === "" ? bridgeResolved : path77.join(bridgeResolved, rel);
50559
- const resolved = path77.resolve(repoPath);
50560
- if (!resolved.startsWith(bridgeResolved + path77.sep) && resolved !== bridgeResolved) {
50682
+ const repoPath = rel === "" ? bridgeResolved : path79.join(bridgeResolved, rel);
50683
+ const resolved = path79.resolve(repoPath);
50684
+ if (!resolved.startsWith(bridgeResolved + path79.sep) && resolved !== bridgeResolved) {
50561
50685
  return null;
50562
50686
  }
50563
50687
  return resolved;
@@ -51038,25 +51162,25 @@ async function GET2(ctx) {
51038
51162
  init_in_flight();
51039
51163
 
51040
51164
  // src/files/read/read-file-async.ts
51041
- import fs57 from "node:fs";
51165
+ import fs59 from "node:fs";
51042
51166
  init_yield_to_event_loop();
51043
51167
 
51044
51168
  // src/files/read/resolve-file-cache.ts
51045
- import fs52 from "node:fs";
51046
- import path78 from "node:path";
51169
+ import fs54 from "node:fs";
51170
+ import path80 from "node:path";
51047
51171
  var RESOLVE_CACHE_MAX = 4096;
51048
51172
  var resolveCache = /* @__PURE__ */ new Map();
51049
51173
  function resolveCacheKey(sessionParentPath, relativePath) {
51050
51174
  return `${sessionParentPath}\0${relativePath}`;
51051
51175
  }
51052
51176
  function pathStaysUnderParent(filePath, sessionParentPath) {
51053
- const parent = path78.resolve(sessionParentPath);
51054
- const resolved = path78.resolve(filePath);
51055
- return resolved === parent || resolved.startsWith(`${parent}${path78.sep}`);
51177
+ const parent = path80.resolve(sessionParentPath);
51178
+ const resolved = path80.resolve(filePath);
51179
+ return resolved === parent || resolved.startsWith(`${parent}${path80.sep}`);
51056
51180
  }
51057
51181
  function statMatchesCacheSync(entry) {
51058
51182
  try {
51059
- const stat2 = fs52.statSync(entry.path);
51183
+ const stat2 = fs54.statSync(entry.path);
51060
51184
  return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
51061
51185
  } catch {
51062
51186
  return false;
@@ -51089,7 +51213,7 @@ function joinInflightResolve(cacheKey, factory) {
51089
51213
  }
51090
51214
 
51091
51215
  // src/files/read/resolve-file-for-read-core.ts
51092
- import fs53 from "node:fs";
51216
+ import fs55 from "node:fs";
51093
51217
  import { isMainThread as isMainThread4 } from "node:worker_threads";
51094
51218
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
51095
51219
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -51099,13 +51223,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
51099
51223
  let size;
51100
51224
  let mtimeMs;
51101
51225
  try {
51102
- const lstat = fs53.lstatSync(resolved);
51226
+ const lstat = fs55.lstatSync(resolved);
51103
51227
  if (lstat.isSymbolicLink()) {
51104
- real = fs53.realpathSync(resolved);
51228
+ real = fs55.realpathSync(resolved);
51105
51229
  if (!pathStaysUnderParent(real, sessionParentPath)) {
51106
51230
  return { error: "Path is outside working directory" };
51107
51231
  }
51108
- const stat2 = fs53.statSync(real);
51232
+ const stat2 = fs55.statSync(real);
51109
51233
  if (!stat2.isFile()) return { error: "Not a file" };
51110
51234
  size = stat2.size;
51111
51235
  mtimeMs = stat2.mtimeMs;
@@ -51133,13 +51257,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
51133
51257
  let size;
51134
51258
  let mtimeMs;
51135
51259
  try {
51136
- const lstat = await fs53.promises.lstat(resolved);
51260
+ const lstat = await fs55.promises.lstat(resolved);
51137
51261
  if (lstat.isSymbolicLink()) {
51138
- real = await fs53.promises.realpath(resolved);
51262
+ real = await fs55.promises.realpath(resolved);
51139
51263
  if (!pathStaysUnderParent(real, sessionParentPath)) {
51140
51264
  return { error: "Path is outside working directory" };
51141
51265
  }
51142
- const stat2 = await fs53.promises.stat(real);
51266
+ const stat2 = await fs55.promises.stat(real);
51143
51267
  if (!stat2.isFile()) return { error: "Not a file" };
51144
51268
  size = stat2.size;
51145
51269
  mtimeMs = stat2.mtimeMs;
@@ -51188,7 +51312,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
51188
51312
 
51189
51313
  // src/files/read/read-file-range-async.ts
51190
51314
  init_yield_to_event_loop();
51191
- import fs54 from "node:fs";
51315
+ import fs56 from "node:fs";
51192
51316
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
51193
51317
 
51194
51318
  // src/files/read/read-file-range-line-zero.ts
@@ -51302,8 +51426,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
51302
51426
 
51303
51427
  // src/files/read/read-file-range-async.ts
51304
51428
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
51305
- const fileSize = fileSizeIn ?? (await fs54.promises.stat(filePath)).size;
51306
- const fd = await fs54.promises.open(filePath, "r");
51429
+ const fileSize = fileSizeIn ?? (await fs56.promises.stat(filePath)).size;
51430
+ const fd = await fs56.promises.open(filePath, "r");
51307
51431
  const bufSize = 64 * 1024;
51308
51432
  const buf = Buffer.alloc(bufSize);
51309
51433
  const decoder = new StringDecoder2("utf8");
@@ -51404,7 +51528,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
51404
51528
  }
51405
51529
 
51406
51530
  // src/files/read/read-small-file-range-async.ts
51407
- import fs55 from "node:fs";
51531
+ import fs57 from "node:fs";
51408
51532
  import { isMainThread as isMainThread5 } from "node:worker_threads";
51409
51533
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
51410
51534
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -51434,7 +51558,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
51434
51558
  };
51435
51559
  }
51436
51560
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
51437
- const raw = fs55.readFileSync(filePath, "utf8");
51561
+ const raw = fs57.readFileSync(filePath, "utf8");
51438
51562
  const lines = raw.split(/\r?\n/);
51439
51563
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
51440
51564
  }
@@ -51442,28 +51566,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
51442
51566
  if (isMainThread5) {
51443
51567
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
51444
51568
  }
51445
- const raw = await fs55.promises.readFile(filePath, "utf8");
51569
+ const raw = await fs57.promises.readFile(filePath, "utf8");
51446
51570
  const lines = raw.split(/\r?\n/);
51447
51571
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
51448
51572
  }
51449
51573
 
51450
51574
  // src/files/read/read-file-buffer-full-async.ts
51451
51575
  init_yield_to_event_loop();
51452
- import fs56 from "node:fs";
51576
+ import fs58 from "node:fs";
51453
51577
  import { isMainThread as isMainThread6 } from "node:worker_threads";
51454
51578
  var READ_CHUNK_BYTES = 256 * 1024;
51455
51579
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
51456
51580
  async function readFileBufferFullAsync(filePath, knownSize) {
51457
51581
  if (isMainThread6) {
51458
- const size2 = knownSize ?? fs56.statSync(filePath).size;
51582
+ const size2 = knownSize ?? fs58.statSync(filePath).size;
51459
51583
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
51460
51584
  await yieldToEventLoop();
51461
- const buffer = fs56.readFileSync(filePath);
51585
+ const buffer = fs58.readFileSync(filePath);
51462
51586
  return { buffer, size: buffer.length };
51463
51587
  }
51464
51588
  }
51465
- const size = knownSize ?? (await fs56.promises.stat(filePath)).size;
51466
- const fd = await fs56.promises.open(filePath, "r");
51589
+ const size = knownSize ?? (await fs58.promises.stat(filePath)).size;
51590
+ const fd = await fs58.promises.open(filePath, "r");
51467
51591
  const chunks = [];
51468
51592
  let position = 0;
51469
51593
  let bytesSinceYield = 0;
@@ -51566,7 +51690,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
51566
51690
  }
51567
51691
  if (hasRange) {
51568
51692
  if (fileSize == null) {
51569
- const stat2 = await fs57.promises.stat(resolvedPath);
51693
+ const stat2 = await fs59.promises.stat(resolvedPath);
51570
51694
  fileSize = stat2.size;
51571
51695
  }
51572
51696
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -51864,12 +51988,12 @@ function parseOptionalInt2(raw) {
51864
51988
  return Number.isInteger(parsed) ? parsed : void 0;
51865
51989
  }
51866
51990
  function parseCodeNavParams(url2) {
51867
- const path86 = url2.searchParams.get("path") ?? "";
51991
+ const path88 = url2.searchParams.get("path") ?? "";
51868
51992
  const opRaw = url2.searchParams.get("op")?.trim();
51869
51993
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
51870
51994
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
51871
51995
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
51872
- return { path: path86, op, line, column };
51996
+ return { path: path88, op, line, column };
51873
51997
  }
51874
51998
  function parseCodeNavPath(url2) {
51875
51999
  const raw = url2.searchParams.get("path")?.trim();
@@ -52667,18 +52791,18 @@ function hasRunningTurn(turns) {
52667
52791
  }
52668
52792
 
52669
52793
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
52670
- import fs60 from "node:fs";
52794
+ import fs62 from "node:fs";
52671
52795
 
52672
52796
  // src/git/snapshot/capture.ts
52673
- import * as fs59 from "node:fs";
52674
- import * as path80 from "node:path";
52797
+ import * as fs61 from "node:fs";
52798
+ import * as path82 from "node:path";
52675
52799
 
52676
52800
  // src/git/snapshot/apply-pre-turn-snapshot.ts
52677
- import * as fs58 from "node:fs";
52801
+ import * as fs60 from "node:fs";
52678
52802
  async function applyPreTurnSnapshot(filePath, log2) {
52679
52803
  let data;
52680
52804
  try {
52681
- data = JSON.parse(fs58.readFileSync(filePath, "utf8"));
52805
+ data = JSON.parse(fs60.readFileSync(filePath, "utf8"));
52682
52806
  } catch (error51) {
52683
52807
  return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
52684
52808
  }
@@ -52707,18 +52831,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
52707
52831
  }
52708
52832
 
52709
52833
  // src/git/snapshot/resolve-repo-roots.ts
52710
- import * as path79 from "node:path";
52834
+ import * as path81 from "node:path";
52711
52835
  async function resolveSnapshotRepoRoots(options) {
52712
52836
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
52713
52837
  if (worktreePaths?.length) {
52714
- const paths = [...new Set(worktreePaths.map((p) => path79.resolve(p)))];
52838
+ const paths = [...new Set(worktreePaths.map((p) => path81.resolve(p)))];
52715
52839
  return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
52716
52840
  }
52717
52841
  try {
52718
52842
  const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
52719
52843
  const sid = sessionId?.trim();
52720
52844
  if (!sid) return roots;
52721
- const sessionRoots = roots.filter((root) => path79.basename(root) === sid);
52845
+ const sessionRoots = roots.filter((root) => path81.basename(root) === sid);
52722
52846
  return sessionRoots.length > 0 ? sessionRoots : roots;
52723
52847
  } catch (error51) {
52724
52848
  log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -52740,7 +52864,7 @@ async function capturePreTurnSnapshot(options) {
52740
52864
  });
52741
52865
  const dir = snapshotsDirForCwd(agentCwd);
52742
52866
  try {
52743
- fs59.mkdirSync(dir, { recursive: true });
52867
+ fs61.mkdirSync(dir, { recursive: true });
52744
52868
  } catch (e) {
52745
52869
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
52746
52870
  }
@@ -52749,9 +52873,9 @@ async function capturePreTurnSnapshot(options) {
52749
52873
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
52750
52874
  repos
52751
52875
  };
52752
- const filePath = path80.join(dir, `${runId}.json`);
52876
+ const filePath = path82.join(dir, `${runId}.json`);
52753
52877
  try {
52754
- fs59.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
52878
+ fs61.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
52755
52879
  } catch (e) {
52756
52880
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
52757
52881
  }
@@ -52771,7 +52895,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
52771
52895
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
52772
52896
  const file2 = snapshotFilePath(agentBase, tid);
52773
52897
  try {
52774
- await fs60.promises.access(file2, fs60.constants.F_OK);
52898
+ await fs62.promises.access(file2, fs62.constants.F_OK);
52775
52899
  } catch {
52776
52900
  deps.log(
52777
52901
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -53422,6 +53546,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
53422
53546
  var handleSessionArchivedMessage = (msg, deps) => {
53423
53547
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
53424
53548
  if (!sessionId) return;
53549
+ cleanupSessionPlans(sessionId);
53425
53550
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
53426
53551
  };
53427
53552
 
@@ -53429,11 +53554,12 @@ var handleSessionArchivedMessage = (msg, deps) => {
53429
53554
  var handleSessionDiscardedMessage = (msg, deps) => {
53430
53555
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
53431
53556
  if (!sessionId) return;
53557
+ cleanupSessionPlans(sessionId);
53432
53558
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
53433
53559
  };
53434
53560
 
53435
53561
  // src/routing/handlers/revert-turn-snapshot.ts
53436
- import * as fs61 from "node:fs";
53562
+ import * as fs63 from "node:fs";
53437
53563
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
53438
53564
  const id = typeof msg.id === "string" ? msg.id : "";
53439
53565
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -53446,7 +53572,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
53446
53572
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
53447
53573
  const file2 = snapshotFilePath(agentBase, turnId);
53448
53574
  try {
53449
- await fs61.promises.access(file2, fs61.constants.F_OK);
53575
+ await fs63.promises.access(file2, fs63.constants.F_OK);
53450
53576
  } catch {
53451
53577
  sendWsMessage(s, {
53452
53578
  type: "revert_turn_snapshot_result",
@@ -53544,8 +53670,8 @@ function isValidRemoteSkillInstallItem(item) {
53544
53670
 
53545
53671
  // src/skills/install/install-remote-skills-async.ts
53546
53672
  init_yield_to_event_loop();
53547
- import fs62 from "node:fs";
53548
- import path81 from "node:path";
53673
+ import fs64 from "node:fs";
53674
+ import path83 from "node:path";
53549
53675
 
53550
53676
  // src/skills/install/constants.ts
53551
53677
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -53556,12 +53682,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
53556
53682
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
53557
53683
  await yieldToEventLoop();
53558
53684
  }
53559
- const dest = path81.join(skillDir, f.path);
53560
- await fs62.promises.mkdir(path81.dirname(dest), { recursive: true });
53685
+ const dest = path83.join(skillDir, f.path);
53686
+ await fs64.promises.mkdir(path83.dirname(dest), { recursive: true });
53561
53687
  if (f.text !== void 0) {
53562
- await fs62.promises.writeFile(dest, f.text, "utf8");
53688
+ await fs64.promises.writeFile(dest, f.text, "utf8");
53563
53689
  } else if (f.base64) {
53564
- await fs62.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
53690
+ await fs64.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
53565
53691
  }
53566
53692
  }
53567
53693
  async function installRemoteSkillsAsync(cwd, targetDir, items) {
@@ -53573,7 +53699,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
53573
53699
  try {
53574
53700
  for (const item of items) {
53575
53701
  if (!isValidRemoteSkillInstallItem(item)) continue;
53576
- const skillDir = path81.join(cwd, targetDir, item.skillName);
53702
+ const skillDir = path83.join(cwd, targetDir, item.skillName);
53577
53703
  for (const f of item.files) {
53578
53704
  await writeInstallFileAsync(skillDir, f, filesWritten);
53579
53705
  }
@@ -53936,13 +54062,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
53936
54062
 
53937
54063
  // src/files/handle-file-browser-search.ts
53938
54064
  init_yield_to_event_loop();
53939
- import path82 from "node:path";
54065
+ import path84 from "node:path";
53940
54066
  var SEARCH_LIMIT = 100;
53941
54067
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
53942
54068
  void (async () => {
53943
54069
  await yieldToEventLoop();
53944
54070
  const q = typeof msg.q === "string" ? msg.q : "";
53945
- const sessionParentPath = path82.resolve(
54071
+ const sessionParentPath = path84.resolve(
53946
54072
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
53947
54073
  );
53948
54074
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -54040,7 +54166,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
54040
54166
  }
54041
54167
 
54042
54168
  // src/git/bridge-git-context.ts
54043
- import * as path83 from "node:path";
54169
+ import * as path85 from "node:path";
54044
54170
  init_yield_to_event_loop();
54045
54171
 
54046
54172
  // src/git/branches/get-current-branch.ts
@@ -54108,12 +54234,12 @@ function listPendingCheckouts() {
54108
54234
  // src/git/bridge-git-context.ts
54109
54235
  function folderNameForRelPath(relPath, bridgeRoot) {
54110
54236
  if (relPath === "." || relPath === "") {
54111
- return path83.basename(path83.resolve(bridgeRoot)) || "repo";
54237
+ return path85.basename(path85.resolve(bridgeRoot)) || "repo";
54112
54238
  }
54113
- return path83.basename(relPath) || relPath;
54239
+ return path85.basename(relPath) || relPath;
54114
54240
  }
54115
54241
  async function discoverGitReposForBridgeContext(bridgeRoot) {
54116
- const root = path83.resolve(bridgeRoot);
54242
+ const root = path85.resolve(bridgeRoot);
54117
54243
  if (await isGitRepoDirectory(root)) {
54118
54244
  const remoteUrl = await getRemoteOriginUrl(root);
54119
54245
  return [{ absolutePath: root, remoteUrl }];
@@ -54121,19 +54247,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
54121
54247
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
54122
54248
  const byPath = /* @__PURE__ */ new Map();
54123
54249
  for (const repo of [...deep, ...shallow]) {
54124
- byPath.set(path83.resolve(repo.absolutePath), repo);
54250
+ byPath.set(path85.resolve(repo.absolutePath), repo);
54125
54251
  }
54126
54252
  return [...byPath.values()];
54127
54253
  }
54128
54254
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
54129
- const bridgeResolved = path83.resolve(bridgeRoot);
54255
+ const bridgeResolved = path85.resolve(bridgeRoot);
54130
54256
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
54131
54257
  const rows = [];
54132
54258
  for (let i = 0; i < repos.length; i++) {
54133
54259
  if (i > 0) await yieldToEventLoop();
54134
54260
  const repo = repos[i];
54135
- let rel = path83.relative(bridgeResolved, repo.absolutePath);
54136
- if (rel.startsWith("..") || path83.isAbsolute(rel)) continue;
54261
+ let rel = path85.relative(bridgeResolved, repo.absolutePath);
54262
+ if (rel.startsWith("..") || path85.isAbsolute(rel)) continue;
54137
54263
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
54138
54264
  const currentBranch = await getCurrentBranch(repo.absolutePath);
54139
54265
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -54164,11 +54290,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
54164
54290
  return rows;
54165
54291
  }
54166
54292
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
54167
- const bridgeResolved = path83.resolve(bridgeRoot);
54293
+ const bridgeResolved = path85.resolve(bridgeRoot);
54168
54294
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
54169
- const repoPath = rel === "" ? bridgeResolved : path83.join(bridgeResolved, rel);
54170
- const resolved = path83.resolve(repoPath);
54171
- if (!resolved.startsWith(bridgeResolved + path83.sep) && resolved !== bridgeResolved) {
54295
+ const repoPath = rel === "" ? bridgeResolved : path85.join(bridgeResolved, rel);
54296
+ const resolved = path85.resolve(repoPath);
54297
+ if (!resolved.startsWith(bridgeResolved + path85.sep) && resolved !== bridgeResolved) {
54172
54298
  return [];
54173
54299
  }
54174
54300
  return listRepoBranchRefs(resolved);
@@ -54218,8 +54344,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
54218
54344
  }
54219
54345
 
54220
54346
  // src/git/checkout/bridge-git-checkout.ts
54221
- import * as fs64 from "node:fs/promises";
54222
- import * as path85 from "node:path";
54347
+ import * as fs66 from "node:fs/promises";
54348
+ import * as path87 from "node:path";
54223
54349
 
54224
54350
  // src/git/checkout/normalize-clone-url.ts
54225
54351
  function normalizeCloneUrl(url2) {
@@ -54239,12 +54365,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
54239
54365
  }
54240
54366
 
54241
54367
  // src/git/checkout/resolve-checkout-target.ts
54242
- import * as fs63 from "node:fs/promises";
54243
- import * as path84 from "node:path";
54368
+ import * as fs65 from "node:fs/promises";
54369
+ import * as path86 from "node:path";
54244
54370
  var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
54245
54371
  async function pathExists(p) {
54246
54372
  try {
54247
- await fs63.access(p);
54373
+ await fs65.access(p);
54248
54374
  return true;
54249
54375
  } catch {
54250
54376
  return false;
@@ -54256,7 +54382,7 @@ async function resolveCheckoutTarget(opts) {
54256
54382
  if (await isGitRepoDirectory(bridgeRoot)) {
54257
54383
  throw new Error("Bridge root is already a git repository");
54258
54384
  }
54259
- const entries = await fs63.readdir(bridgeRoot).catch(() => []);
54385
+ const entries = await fs65.readdir(bridgeRoot).catch(() => []);
54260
54386
  if (entries.length > 0) {
54261
54387
  throw new Error("Bridge root must be empty to initialize a monorepo checkout");
54262
54388
  }
@@ -54269,8 +54395,8 @@ async function resolveCheckoutTarget(opts) {
54269
54395
  if (await isGitRepoDirectory(bridgeRoot)) {
54270
54396
  throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
54271
54397
  }
54272
- const targetDir = path84.resolve(bridgeRoot, folder);
54273
- if (!targetDir.startsWith(bridgeRoot + path84.sep)) {
54398
+ const targetDir = path86.resolve(bridgeRoot, folder);
54399
+ if (!targetDir.startsWith(bridgeRoot + path86.sep)) {
54274
54400
  throw new Error("Invalid folderName");
54275
54401
  }
54276
54402
  if (await pathExists(targetDir)) {
@@ -54289,10 +54415,10 @@ async function bridgeGitCheckout(params) {
54289
54415
  });
54290
54416
  const folderName = relPath === "." ? "repo" : relPath;
54291
54417
  beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
54292
- const parent = path85.dirname(targetDir);
54293
- await fs64.mkdir(parent, { recursive: true });
54418
+ const parent = path87.dirname(targetDir);
54419
+ await fs66.mkdir(parent, { recursive: true });
54294
54420
  if (relPath !== ".") {
54295
- await fs64.mkdir(targetDir, { recursive: true });
54421
+ await fs66.mkdir(targetDir, { recursive: true });
54296
54422
  }
54297
54423
  const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
54298
54424
  try {
@@ -54303,7 +54429,7 @@ async function bridgeGitCheckout(params) {
54303
54429
  return { relPath, folderName };
54304
54430
  } catch (e) {
54305
54431
  if (relPath !== ".") {
54306
- await fs64.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
54432
+ await fs66.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
54307
54433
  }
54308
54434
  const msg = e instanceof Error ? e.message : String(e);
54309
54435
  throw new Error(