@buildautomaton/cli 0.1.84 → 0.1.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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() {
@@ -32858,6 +32858,11 @@ var INSTALLABLE_BRIDGE_AGENTS = [
32858
32858
  { value: "opencode", label: "OpenCode agent", tokenLabel: "Provider API key", tokenEnvVar: "OPENCODE_API_KEY" }
32859
32859
  ];
32860
32860
 
32861
+ // ../types/src/agent-subscriptions.ts
32862
+ var AGENT_SUBSCRIPTION_TYPES = INSTALLABLE_BRIDGE_AGENTS.map(
32863
+ (a) => a.value
32864
+ );
32865
+
32861
32866
  // src/agents/acp/safe-fs-path.ts
32862
32867
  import * as path2 from "node:path";
32863
32868
  function resolveSafePathUnderCwd(cwd, filePath) {
@@ -33875,8 +33880,8 @@ function randomSecret() {
33875
33880
  }
33876
33881
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
33877
33882
  }
33878
- async function requestPreviewApi(port, secret, method, path86, body) {
33879
- 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}`;
33880
33885
  const headers = {
33881
33886
  [PREVIEW_SECRET_HEADER]: secret,
33882
33887
  "Content-Type": "application/json"
@@ -33888,7 +33893,7 @@ async function requestPreviewApi(port, secret, method, path86, body) {
33888
33893
  });
33889
33894
  const data = await res.json().catch(() => ({}));
33890
33895
  if (!res.ok) {
33891
- throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
33896
+ throw new Error(data?.error ?? `Preview API ${method} ${path88}: ${res.status}`);
33892
33897
  }
33893
33898
  return data;
33894
33899
  }
@@ -35190,7 +35195,7 @@ function createPendingAuthOnMessage(params) {
35190
35195
  }
35191
35196
 
35192
35197
  // src/cli-version.ts
35193
- var CLI_VERSION = "0.1.84".length > 0 ? "0.1.84" : "0.0.0-dev";
35198
+ var CLI_VERSION = "0.1.86".length > 0 ? "0.1.86" : "0.0.0-dev";
35194
35199
 
35195
35200
  // src/auth/pending/pending-auth-on-open.ts
35196
35201
  function createPendingAuthOnOpen(params) {
@@ -36561,8 +36566,8 @@ async function cancelRun(ctx, runId) {
36561
36566
  }
36562
36567
 
36563
36568
  // src/agents/acp/ensure-acp-client.ts
36564
- import * as fs23 from "node:fs";
36565
- import * as path29 from "node:path";
36569
+ import * as fs24 from "node:fs";
36570
+ import * as path31 from "node:path";
36566
36571
 
36567
36572
  // src/paths/session-layout-paths.ts
36568
36573
  import * as path26 from "node:path";
@@ -36752,6 +36757,7 @@ init_log();
36752
36757
  function createCursorAcpSessionContext(options) {
36753
36758
  const suppressLoadReplayRef = { value: false };
36754
36759
  return {
36760
+ cloudSessionId: options.cloudSessionId,
36755
36761
  cwd: options.cwd,
36756
36762
  onFileChange: options.onFileChange,
36757
36763
  mcpServers: options.mcpServers ?? [],
@@ -36844,14 +36850,80 @@ function createCursorAcpHandle(options) {
36844
36850
  // src/agents/acp/clients/cursor/cursor-acp-init.ts
36845
36851
  import * as readline from "node:readline";
36846
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
+
36888
+ // src/agents/acp/clients/cursor/cursor-incoming-cursor-task.ts
36889
+ function buildCursorTaskToolCallUpdate(params) {
36890
+ const toolCallId = params.toolCallId ?? params.tool_call_id;
36891
+ if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
36892
+ const description = typeof params.description === "string" ? params.description.trim() : "";
36893
+ const prompt = typeof params.prompt === "string" ? params.prompt : void 0;
36894
+ const subagentType = params.subagentType ?? params.subagent_type;
36895
+ const model = typeof params.model === "string" ? params.model : void 0;
36896
+ const agentId = typeof params.agentId === "string" ? params.agentId : typeof params.agent_id === "string" ? params.agent_id : void 0;
36897
+ const durationMs = typeof params.durationMs === "number" ? params.durationMs : typeof params.duration_ms === "number" ? params.duration_ms : void 0;
36898
+ return {
36899
+ sessionUpdate: "tool_call_update",
36900
+ toolCallId,
36901
+ ...description ? { title: description } : {},
36902
+ cursorTask: {
36903
+ ...description ? { description } : {},
36904
+ ...prompt != null ? { prompt } : {},
36905
+ ...subagentType != null ? { subagentType } : {},
36906
+ ...model != null ? { model } : {},
36907
+ ...agentId != null ? { agentId } : {},
36908
+ ...durationMs != null ? { durationMs } : {}
36909
+ }
36910
+ };
36911
+ }
36912
+ function handleCursorIncomingCursorTask(id, msg, deps) {
36913
+ const params = msg.params ?? {};
36914
+ deps.respond(id, {});
36915
+ const update = buildCursorTaskToolCallUpdate(params);
36916
+ if (update) deps.onSessionUpdate?.(update);
36917
+ }
36918
+
36847
36919
  // src/agents/acp/clients/cursor/cursor-incoming-cursor-methods.ts
36848
- var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/create_plan", "cursor/ask_question"]);
36849
- var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set([
36850
- "cursor/update_todos",
36851
- "cursor/task",
36852
- "cursor/generate_image"
36853
- ]);
36920
+ var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/ask_question"]);
36921
+ var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set(["cursor/update_todos", "cursor/generate_image"]);
36854
36922
  function handleCursorIncomingCursorMethods(method, id, msg, deps) {
36923
+ if (method === "cursor/create_plan") {
36924
+ queueCursorCreatePlanRequest(method, id, msg, deps);
36925
+ return true;
36926
+ }
36855
36927
  if (CURSOR_BRIDGE_METHODS.has(method)) {
36856
36928
  const params = msg.params ?? {};
36857
36929
  deps.pendingRequests.set(id, { method, params });
@@ -36862,6 +36934,10 @@ function handleCursorIncomingCursorMethods(method, id, msg, deps) {
36862
36934
  });
36863
36935
  return true;
36864
36936
  }
36937
+ if (method === "cursor/task") {
36938
+ handleCursorIncomingCursorTask(id, msg, deps);
36939
+ return true;
36940
+ }
36865
36941
  if (CURSOR_NOOP_METHODS.has(method)) {
36866
36942
  deps.respond(id, {});
36867
36943
  return true;
@@ -36961,10 +37037,71 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
36961
37037
  return true;
36962
37038
  }
36963
37039
 
37040
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
37041
+ import * as fs23 from "node:fs";
37042
+ import * as path28 from "node:path";
37043
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
37044
+
37045
+ // src/paths/session-plans-paths.ts
37046
+ import * as os8 from "node:os";
37047
+ import * as path27 from "node:path";
37048
+ function getSessionPlansRootDir() {
37049
+ return path27.join(os8.homedir(), ".buildautomaton", "plans");
37050
+ }
37051
+ function sanitizeSessionPlansKey(sessionId) {
37052
+ const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
37053
+ return t || "session";
37054
+ }
37055
+ function getSessionPlansDir(sessionId) {
37056
+ return path27.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
37057
+ }
37058
+
37059
+ // src/agents/acp/clients/cursor/write-create-plan-file.ts
37060
+ function sanitizePlanFileBase(toolCallId) {
37061
+ const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
37062
+ return t || "plan";
37063
+ }
37064
+ function writeCreatePlanFile(params) {
37065
+ const dir = getSessionPlansDir(params.cloudSessionId);
37066
+ fs23.mkdirSync(dir, { recursive: true });
37067
+ const filePath = path28.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
37068
+ fs23.writeFileSync(filePath, params.planMarkdown, "utf8");
37069
+ return pathToFileURL2(filePath).href;
37070
+ }
37071
+
37072
+ // src/agents/acp/clients/cursor/enrich-create-plan-rpc-result.ts
37073
+ function asRecord2(v) {
37074
+ return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
37075
+ }
37076
+ function enrichCreatePlanRpcResult(result, pendingParams, cloudSessionId) {
37077
+ const root = asRecord2(result);
37078
+ const outcome = asRecord2(root?.outcome);
37079
+ if (!outcome) return result;
37080
+ const kind = typeof outcome.outcome === "string" ? outcome.outcome : "";
37081
+ if (kind !== "accepted") {
37082
+ const { plan: _drop, ...rest } = outcome;
37083
+ return { ...root, outcome: rest };
37084
+ }
37085
+ const planMarkdown = typeof outcome.plan === "string" ? outcome.plan : "";
37086
+ const toolCallIdRaw = pendingParams.toolCallId ?? pendingParams.tool_call_id;
37087
+ const toolCallId = typeof toolCallIdRaw === "string" ? toolCallIdRaw.trim() : "";
37088
+ const sessionId = cloudSessionId?.trim() ?? "";
37089
+ if (planMarkdown && toolCallId && sessionId) {
37090
+ const planUri = writeCreatePlanFile({ cloudSessionId: sessionId, toolCallId, planMarkdown });
37091
+ return { outcome: { outcome: "accepted", planUri } };
37092
+ }
37093
+ return { outcome: { outcome: "accepted" } };
37094
+ }
37095
+
36964
37096
  // src/agents/acp/clients/cursor/cursor-incoming-resolve-request.ts
36965
- function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result) {
37097
+ function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result, cloudSessionId) {
36966
37098
  const pending2 = pendingRequests2.get(requestId);
36967
- const payload = pending2?.method === "session/request_permission" ? enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params) : result;
37099
+ let payload = result;
37100
+ if (pending2?.method === "session/request_permission") {
37101
+ payload = enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params);
37102
+ } else if (pending2?.method === "cursor/create_plan") {
37103
+ payload = enrichCreatePlanRpcResult(result, pending2.params, cloudSessionId ?? void 0);
37104
+ }
36968
37105
  respond(requestId, payload);
36969
37106
  pendingRequests2.delete(requestId);
36970
37107
  }
@@ -37021,10 +37158,17 @@ function createCursorAcpIncomingLineHandler(deps) {
37021
37158
  respond: deps.respond,
37022
37159
  respondJsonRpcError: deps.respondJsonRpcError,
37023
37160
  onRequest: deps.onRequest,
37161
+ onSessionUpdate: deps.onSessionUpdate,
37024
37162
  pendingRequests: deps.pendingRequests
37025
37163
  };
37026
37164
  return {
37027
- resolveRequest: (requestId, result) => resolveCursorIncomingRequest(deps.pendingRequests, deps.respond, requestId, result),
37165
+ resolveRequest: (requestId, result) => resolveCursorIncomingRequest(
37166
+ deps.pendingRequests,
37167
+ deps.respond,
37168
+ requestId,
37169
+ result,
37170
+ deps.sessionCtx.cloudSessionId
37171
+ ),
37028
37172
  handleLine(line) {
37029
37173
  const msg = safeJsonParse(line);
37030
37174
  if (!msg) return;
@@ -37227,6 +37371,7 @@ async function createCursorAcpClient(options) {
37227
37371
  const skipBrowserAuthenticate = cursorAgentUsesApiKeyAuth(spawnEnv);
37228
37372
  const sessionCtx = createCursorAcpSessionContext({
37229
37373
  cwd,
37374
+ cloudSessionId: options.cloudSessionId,
37230
37375
  mcpServers: options.mcpServers,
37231
37376
  persistedAcpSessionId,
37232
37377
  backendAgentType,
@@ -37376,18 +37521,18 @@ import { existsSync as existsSync4, statSync } from "node:fs";
37376
37521
 
37377
37522
  // src/git/get-git-repo-root-sync.ts
37378
37523
  import { execFileSync as execFileSync3 } from "node:child_process";
37379
- import * as path27 from "node:path";
37524
+ import * as path29 from "node:path";
37380
37525
  var GIT_LOOKUP_TIMEOUT_MS = 2e3;
37381
37526
  function getGitRepoRootSync(startDir) {
37382
37527
  try {
37383
37528
  const out = execFileSync3("git", ["rev-parse", "--show-toplevel"], {
37384
- cwd: path27.resolve(startDir),
37529
+ cwd: path29.resolve(startDir),
37385
37530
  encoding: "utf8",
37386
37531
  stdio: ["ignore", "pipe", "ignore"],
37387
37532
  maxBuffer: 1024 * 1024,
37388
37533
  timeout: GIT_LOOKUP_TIMEOUT_MS
37389
37534
  }).trim();
37390
- return out ? path27.resolve(out) : null;
37535
+ return out ? path29.resolve(out) : null;
37391
37536
  } catch {
37392
37537
  return null;
37393
37538
  }
@@ -37396,26 +37541,26 @@ function getGitRepoRootSync(startDir) {
37396
37541
  // src/agents/acp/workspace-files.ts
37397
37542
  import { execFileSync as execFileSync4 } from "node:child_process";
37398
37543
  import { readFileSync as readFileSync4 } from "node:fs";
37399
- import * as path28 from "node:path";
37544
+ import * as path30 from "node:path";
37400
37545
  var GIT_FILE_READ_TIMEOUT_MS = 2e3;
37401
37546
  function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
37402
37547
  const trimmed2 = rawPath.trim();
37403
37548
  if (!trimmed2) return null;
37404
- const normalizedSessionParent = path28.resolve(sessionParentPath);
37549
+ const normalizedSessionParent = path30.resolve(sessionParentPath);
37405
37550
  let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
37406
37551
  if (!resolvedPath) {
37407
- const candidate = path28.isAbsolute(trimmed2) ? path28.normalize(trimmed2) : path28.normalize(path28.resolve(normalizedSessionParent, trimmed2));
37552
+ const candidate = path30.isAbsolute(trimmed2) ? path30.normalize(trimmed2) : path30.normalize(path30.resolve(normalizedSessionParent, trimmed2));
37408
37553
  const gitRoot2 = getGitRepoRootSync(sessionParentPath);
37409
37554
  if (!gitRoot2) return null;
37410
- const rel = path28.relative(gitRoot2, candidate);
37411
- if (rel.startsWith("..") || path28.isAbsolute(rel)) return null;
37555
+ const rel = path30.relative(gitRoot2, candidate);
37556
+ if (rel.startsWith("..") || path30.isAbsolute(rel)) return null;
37412
37557
  resolvedPath = candidate;
37413
37558
  }
37414
37559
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37415
37560
  if (gitRoot) {
37416
- const relFromRoot = path28.relative(gitRoot, resolvedPath);
37417
- if (!relFromRoot.startsWith("..") && !path28.isAbsolute(relFromRoot)) {
37418
- return { resolvedPath, display: relFromRoot.split(path28.sep).join("/") };
37561
+ const relFromRoot = path30.relative(gitRoot, resolvedPath);
37562
+ if (!relFromRoot.startsWith("..") && !path30.isAbsolute(relFromRoot)) {
37563
+ return { resolvedPath, display: relFromRoot.split(path30.sep).join("/") };
37419
37564
  }
37420
37565
  }
37421
37566
  return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
@@ -37424,9 +37569,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
37424
37569
  if (!displayPath || displayPath.includes("..")) return "";
37425
37570
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37426
37571
  if (gitRoot) {
37427
- const resolvedPath2 = path28.resolve(gitRoot, displayPath);
37428
- const rel = path28.relative(gitRoot, resolvedPath2);
37429
- if (!rel.startsWith("..") && !path28.isAbsolute(rel)) {
37572
+ const resolvedPath2 = path30.resolve(gitRoot, displayPath);
37573
+ const rel = path30.relative(gitRoot, resolvedPath2);
37574
+ if (!rel.startsWith("..") && !path30.isAbsolute(rel)) {
37430
37575
  try {
37431
37576
  return readFileSync4(resolvedPath2, "utf8");
37432
37577
  } catch {
@@ -37445,9 +37590,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
37445
37590
  if (!displayPath || displayPath.includes("..")) return null;
37446
37591
  const gitRoot = getGitRepoRootSync(sessionParentPath);
37447
37592
  if (gitRoot) {
37448
- const resolvedPath = path28.resolve(gitRoot, displayPath);
37449
- const rel = path28.relative(gitRoot, resolvedPath);
37450
- if (!rel.startsWith("..") && !path28.isAbsolute(rel)) return resolvedPath;
37593
+ const resolvedPath = path30.resolve(gitRoot, displayPath);
37594
+ const rel = path30.relative(gitRoot, resolvedPath);
37595
+ if (!rel.startsWith("..") && !path30.isAbsolute(rel)) return resolvedPath;
37451
37596
  }
37452
37597
  return resolveSafePathUnderCwd(sessionParentPath, displayPath);
37453
37598
  }
@@ -38334,11 +38479,11 @@ init_cli_process_interrupt();
38334
38479
  var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
38335
38480
 
38336
38481
  // src/mcp/resolve-bridge-mcp-server-path.ts
38337
- import { dirname as dirname7, join as join7 } from "node:path";
38482
+ import { dirname as dirname7, join as join9 } from "node:path";
38338
38483
  import { fileURLToPath as fileURLToPath7 } from "node:url";
38339
38484
  function resolveBridgeMcpServerScriptPath() {
38340
38485
  const cliDir = dirname7(fileURLToPath7(import.meta.url));
38341
- return join7(cliDir, "bridge-mcp-server.js");
38486
+ return join9(cliDir, "bridge-mcp-server.js");
38342
38487
  }
38343
38488
 
38344
38489
  // src/mcp/build-acp-mcp-servers.ts
@@ -38397,7 +38542,7 @@ async function ensureAcpClient(options) {
38397
38542
  if (state.acpStartPromise && !state.acpHandle) {
38398
38543
  await state.acpStartPromise;
38399
38544
  }
38400
- if (state.acpHandle && state.lastAcpCwd != null && path29.resolve(state.lastAcpCwd) !== path29.resolve(targetSessionParentPath)) {
38545
+ if (state.acpHandle && state.lastAcpCwd != null && path31.resolve(state.lastAcpCwd) !== path31.resolve(targetSessionParentPath)) {
38401
38546
  try {
38402
38547
  state.acpHandle.disconnect();
38403
38548
  } catch {
@@ -38429,7 +38574,7 @@ async function ensureAcpClient(options) {
38429
38574
  if (!state.acpStartPromise) {
38430
38575
  let statOk = false;
38431
38576
  try {
38432
- const st = await fs23.promises.stat(targetSessionParentPath);
38577
+ const st = await fs24.promises.stat(targetSessionParentPath);
38433
38578
  statOk = st.isDirectory();
38434
38579
  if (!statOk) {
38435
38580
  state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
@@ -38508,6 +38653,7 @@ async function ensureAcpClient(options) {
38508
38653
  },
38509
38654
  ...hooks,
38510
38655
  cwd: targetSessionParentPath,
38656
+ cloudSessionId: cloudSessionId ?? null,
38511
38657
  mcpServers
38512
38658
  }).then(async (h) => {
38513
38659
  if (spawnEpoch !== state.clientEpoch || isCliImmediateShutdownRequested()) {
@@ -38727,8 +38873,8 @@ async function execGitFile(args, options) {
38727
38873
  }
38728
38874
 
38729
38875
  // src/git/changes/parse/normalize-git-diff-path.ts
38730
- function normalizeGitDiffPath(path86) {
38731
- return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
38876
+ function normalizeGitDiffPath(path88) {
38877
+ return path88.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
38732
38878
  }
38733
38879
 
38734
38880
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -38767,7 +38913,7 @@ function parseNameStatusLines(lines) {
38767
38913
  }
38768
38914
 
38769
38915
  // src/git/snapshot/diff/messages.ts
38770
- import * as path30 from "node:path";
38916
+ import * as path32 from "node:path";
38771
38917
 
38772
38918
  // src/git/snapshot/diff/files.ts
38773
38919
  import { readFile, stat } from "node:fs/promises";
@@ -38798,7 +38944,7 @@ async function buildTrackedChangeMessage(options) {
38798
38944
  const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
38799
38945
  const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
38800
38946
  if (!patchContent.trim()) return null;
38801
- const workspaceFilePath = path30.join(repoPath, rel);
38947
+ const workspaceFilePath = path32.join(repoPath, rel);
38802
38948
  const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
38803
38949
  const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
38804
38950
  return {
@@ -38830,9 +38976,9 @@ function buildUntrackedChangeMessage(options) {
38830
38976
  }
38831
38977
 
38832
38978
  // src/git/snapshot/diff/paths.ts
38833
- import * as path31 from "node:path";
38979
+ import * as path33 from "node:path";
38834
38980
  function repoDisplayPath(repoPath, multiRepo) {
38835
- const slug = path31.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
38981
+ const slug = path33.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
38836
38982
  return (rel) => multiRepo ? `${slug}/${rel}` : rel;
38837
38983
  }
38838
38984
  function safeRelPath(rel) {
@@ -38844,12 +38990,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
38844
38990
  }
38845
38991
 
38846
38992
  // src/git/snapshot/diff/move-pairs.ts
38847
- import * as path32 from "node:path";
38993
+ import * as path34 from "node:path";
38848
38994
  async function readUntrackedTexts(repoPath, untracked) {
38849
38995
  const out = /* @__PURE__ */ new Map();
38850
38996
  await forEachWithGitYield(untracked, async (rel) => {
38851
38997
  if (!safeRelPath(rel)) return;
38852
- const newText = await readWorkspaceFileAsUtf8(path32.join(repoPath, rel));
38998
+ const newText = await readWorkspaceFileAsUtf8(path34.join(repoPath, rel));
38853
38999
  if (newText !== void 0) out.set(rel, newText);
38854
39000
  });
38855
39001
  return out;
@@ -38966,12 +39112,12 @@ async function collectRepoTurnChanges(options) {
38966
39112
  import { readFile as readFile2 } from "node:fs/promises";
38967
39113
 
38968
39114
  // src/git/snapshot/types.ts
38969
- import * as path33 from "node:path";
39115
+ import * as path35 from "node:path";
38970
39116
  function snapshotsDirForCwd(agentCwd) {
38971
- return path33.join(agentCwd, ".buildautomaton", "snapshots");
39117
+ return path35.join(agentCwd, ".buildautomaton", "snapshots");
38972
39118
  }
38973
39119
  function snapshotFilePath(agentCwd, runId) {
38974
- return path33.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
39120
+ return path35.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
38975
39121
  }
38976
39122
 
38977
39123
  // src/git/snapshot/diff/load-pre-turn-snapshot.ts
@@ -39039,6 +39185,18 @@ function reportPostTurnEnrichment(options) {
39039
39185
  });
39040
39186
  }
39041
39187
 
39188
+ // src/agents/acp/clients/cursor/cleanup-session-plans.ts
39189
+ import * as fs25 from "node:fs";
39190
+ function cleanupSessionPlans(sessionId) {
39191
+ const id = typeof sessionId === "string" ? sessionId.trim() : "";
39192
+ if (!id) return;
39193
+ const dir = getSessionPlansDir(id);
39194
+ try {
39195
+ fs25.rmSync(dir, { recursive: true, force: true });
39196
+ } catch {
39197
+ }
39198
+ }
39199
+
39042
39200
  // src/agents/acp/prompts/finalize-and-send-prompt-result.ts
39043
39201
  async function finalizeAndSendPromptResult(params) {
39044
39202
  const {
@@ -39056,6 +39214,7 @@ async function finalizeAndSendPromptResult(params) {
39056
39214
  sendSessionUpdate,
39057
39215
  log: log2
39058
39216
  } = params;
39217
+ cleanupSessionPlans(sessionId);
39059
39218
  const planningTodosSubmit = isPlanningSession ? await maybeSubmitPlanningTodosAfterAgentSuccess({
39060
39219
  sessionId,
39061
39220
  runId,
@@ -40350,7 +40509,7 @@ async function createBridgeAccessState(options = {}) {
40350
40509
  }
40351
40510
 
40352
40511
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
40353
- import * as path35 from "node:path";
40512
+ import * as path37 from "node:path";
40354
40513
 
40355
40514
  // src/agents/detect-local-agent-types.ts
40356
40515
  init_yield_to_event_loop();
@@ -40455,7 +40614,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
40455
40614
  init_cli_database();
40456
40615
 
40457
40616
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
40458
- import * as path34 from "node:path";
40617
+ import * as path36 from "node:path";
40459
40618
  init_cli_database();
40460
40619
  init_cli_process_interrupt();
40461
40620
  async function probeOneAgentTypeForCapabilities(params) {
@@ -40495,7 +40654,7 @@ async function probeOneAgentTypeForCapabilities(params) {
40495
40654
  if (!canContinue()) return false;
40496
40655
  handle = await resolved.createClient({
40497
40656
  command: resolved.command,
40498
- cwd: path34.resolve(cwd),
40657
+ cwd: path36.resolve(cwd),
40499
40658
  backendAgentType: agentType,
40500
40659
  sessionMode: "agent",
40501
40660
  persistedAcpSessionId: null,
@@ -40588,7 +40747,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
40588
40747
  const { workspaceId, log: log2, getWs } = params;
40589
40748
  const isCurrent = beginAgentCapabilityWarmupRun();
40590
40749
  if (!isCurrent()) return;
40591
- const cwd = path35.resolve(getBridgeRoot());
40750
+ const cwd = path37.resolve(getBridgeRoot());
40592
40751
  async function sendBatchFromCache() {
40593
40752
  if (!isCurrent()) return;
40594
40753
  const socket = getWs();
@@ -40715,7 +40874,7 @@ async function createBridgeAccessAndAcp(options) {
40715
40874
  }
40716
40875
 
40717
40876
  // src/connection/create-bridge-preview-stack.ts
40718
- import * as path38 from "node:path";
40877
+ import * as path40 from "node:path";
40719
40878
 
40720
40879
  // src/preview-environments/manager/firehose-messages.ts
40721
40880
  function buildFirehoseSnapshotMessage(params) {
@@ -41033,7 +41192,7 @@ function attachChildErrorHandler(d) {
41033
41192
  }
41034
41193
 
41035
41194
  // src/preview-environments/process/wire/handle-exit.ts
41036
- import fs24 from "node:fs";
41195
+ import fs26 from "node:fs";
41037
41196
  function logStopLine(d, code, signal) {
41038
41197
  const { title } = d;
41039
41198
  if (signal) {
@@ -41072,7 +41231,7 @@ function attachChildExitHandler(d) {
41072
41231
  const cleanupDir = d.mergedCleanupDir;
41073
41232
  const mergedPath = d.mergedLogPath;
41074
41233
  if (mergedPath && !stale) {
41075
- fs24.readFile(mergedPath, (err, buf) => {
41234
+ fs26.readFile(mergedPath, (err, buf) => {
41076
41235
  if (!err && buf.length > d.mergedReadPos.value) {
41077
41236
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
41078
41237
  if (chunk.length > 0) {
@@ -41118,7 +41277,7 @@ function wireChildOutputPipes(d) {
41118
41277
  }
41119
41278
 
41120
41279
  // src/preview-environments/process/wire/poll-merged-log.ts
41121
- import fs25 from "node:fs";
41280
+ import fs27 from "node:fs";
41122
41281
  function startMergedLogPoll(d) {
41123
41282
  if (!d.mergedLogPath || !d.mergedCleanupDir) return;
41124
41283
  const { environmentId } = d;
@@ -41128,7 +41287,7 @@ function startMergedLogPoll(d) {
41128
41287
  d.setPollInterval(void 0);
41129
41288
  return;
41130
41289
  }
41131
- fs25.readFile(d.mergedLogPath, (err, buf) => {
41290
+ fs27.readFile(d.mergedLogPath, (err, buf) => {
41132
41291
  if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
41133
41292
  if (buf.length <= d.mergedReadPos.value) return;
41134
41293
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
@@ -41343,7 +41502,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
41343
41502
  }
41344
41503
 
41345
41504
  // src/preview-environments/manager/shell-spawn/utils.ts
41346
- import fs26 from "node:fs";
41505
+ import fs28 from "node:fs";
41347
41506
  function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
41348
41507
  return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
41349
41508
  }
@@ -41352,7 +41511,7 @@ function isSpawnEbadf(e) {
41352
41511
  }
41353
41512
  function rmDirQuiet(dir) {
41354
41513
  try {
41355
- fs26.rmSync(dir, { recursive: true, force: true });
41514
+ fs28.rmSync(dir, { recursive: true, force: true });
41356
41515
  } catch {
41357
41516
  }
41358
41517
  }
@@ -41360,7 +41519,7 @@ var cachedDevNullReadFd;
41360
41519
  function devNullReadFd() {
41361
41520
  if (cachedDevNullReadFd === void 0) {
41362
41521
  const devPath = process.platform === "win32" ? "nul" : "/dev/null";
41363
- cachedDevNullReadFd = fs26.openSync(devPath, "r");
41522
+ cachedDevNullReadFd = fs28.openSync(devPath, "r");
41364
41523
  }
41365
41524
  return cachedDevNullReadFd;
41366
41525
  }
@@ -41440,15 +41599,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
41440
41599
 
41441
41600
  // src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
41442
41601
  import { spawn as spawn7 } from "node:child_process";
41443
- import fs27 from "node:fs";
41602
+ import fs29 from "node:fs";
41444
41603
  import { tmpdir } from "node:os";
41445
- import path36 from "node:path";
41604
+ import path38 from "node:path";
41446
41605
  function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41447
- const tmpRoot = fs27.mkdtempSync(path36.join(tmpdir(), "ba-devsrv-log-"));
41448
- const logPath = path36.join(tmpRoot, "combined.log");
41606
+ const tmpRoot = fs29.mkdtempSync(path38.join(tmpdir(), "ba-devsrv-log-"));
41607
+ const logPath = path38.join(tmpRoot, "combined.log");
41449
41608
  let logFd;
41450
41609
  try {
41451
- logFd = fs27.openSync(logPath, "a");
41610
+ logFd = fs29.openSync(logPath, "a");
41452
41611
  } catch {
41453
41612
  rmDirQuiet(tmpRoot);
41454
41613
  return null;
@@ -41472,7 +41631,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41472
41631
  mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
41473
41632
  );
41474
41633
  }
41475
- fs27.closeSync(logFd);
41634
+ fs29.closeSync(logFd);
41476
41635
  return {
41477
41636
  proc,
41478
41637
  pipedStdoutStderr: true,
@@ -41481,7 +41640,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41481
41640
  };
41482
41641
  } catch (e) {
41483
41642
  try {
41484
- fs27.closeSync(logFd);
41643
+ fs29.closeSync(logFd);
41485
41644
  } catch {
41486
41645
  }
41487
41646
  rmDirQuiet(tmpRoot);
@@ -41492,22 +41651,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
41492
41651
 
41493
41652
  // src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
41494
41653
  import { spawn as spawn8 } from "node:child_process";
41495
- import fs28 from "node:fs";
41654
+ import fs30 from "node:fs";
41496
41655
  import { tmpdir as tmpdir2 } from "node:os";
41497
- import path37 from "node:path";
41656
+ import path39 from "node:path";
41498
41657
  function shSingleQuote(s) {
41499
41658
  return `'${s.replace(/'/g, `'\\''`)}'`;
41500
41659
  }
41501
41660
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
41502
- const tmpRoot = fs28.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
41503
- const logPath = path37.join(tmpRoot, "combined.log");
41504
- const innerPath = path37.join(tmpRoot, "_cmd.sh");
41505
- const runnerPath = path37.join(tmpRoot, "_run.sh");
41661
+ const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir2(), "ba-devsrv-sh-"));
41662
+ const logPath = path39.join(tmpRoot, "combined.log");
41663
+ const innerPath = path39.join(tmpRoot, "_cmd.sh");
41664
+ const runnerPath = path39.join(tmpRoot, "_run.sh");
41506
41665
  try {
41507
- fs28.writeFileSync(innerPath, `#!/bin/sh
41666
+ fs30.writeFileSync(innerPath, `#!/bin/sh
41508
41667
  ${command}
41509
41668
  `);
41510
- fs28.writeFileSync(
41669
+ fs30.writeFileSync(
41511
41670
  runnerPath,
41512
41671
  `#!/bin/sh
41513
41672
  cd ${shSingleQuote(cwd)}
@@ -41535,13 +41694,13 @@ cd ${shSingleQuote(cwd)}
41535
41694
  }
41536
41695
  }
41537
41696
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
41538
- const tmpRoot = fs28.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
41539
- const logPath = path37.join(tmpRoot, "combined.log");
41540
- const runnerPath = path37.join(tmpRoot, "_run.bat");
41697
+ const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir2(), "ba-devsrv-sh-"));
41698
+ const logPath = path39.join(tmpRoot, "combined.log");
41699
+ const runnerPath = path39.join(tmpRoot, "_run.bat");
41541
41700
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
41542
41701
  const com = process.env.ComSpec || "cmd.exe";
41543
41702
  try {
41544
- fs28.writeFileSync(
41703
+ fs30.writeFileSync(
41545
41704
  runnerPath,
41546
41705
  `@ECHO OFF\r
41547
41706
  CD /D ${q(cwd)}\r
@@ -41859,8 +42018,8 @@ function createBridgePreviewStack(options) {
41859
42018
  scheduleInitialIndexBuilds(getBridgeRoot());
41860
42019
  };
41861
42020
  const identifyReportedPaths = {
41862
- bridgeRootPath: path38.resolve(getBridgeRoot()),
41863
- worktreesRootPath: path38.resolve(options.worktreesRootPath),
42021
+ bridgeRootPath: path40.resolve(getBridgeRoot()),
42022
+ worktreesRootPath: path40.resolve(options.worktreesRootPath),
41864
42023
  localShortcutPort: 0,
41865
42024
  localShortcutToken: ""
41866
42025
  };
@@ -42587,17 +42746,17 @@ async function yieldSkillDiscoveryWork(entryCount) {
42587
42746
  }
42588
42747
 
42589
42748
  // src/skills/discovery/discover-local-skills.ts
42590
- import fs29 from "node:fs";
42591
- import path39 from "node:path";
42749
+ import fs31 from "node:fs";
42750
+ import path41 from "node:path";
42592
42751
  function collectSkillFromDir(rel, base, name, seenKeys, out) {
42593
- const dir = path39.join(base, name);
42752
+ const dir = path41.join(base, name);
42594
42753
  try {
42595
- if (!fs29.statSync(dir).isDirectory()) return;
42754
+ if (!fs31.statSync(dir).isDirectory()) return;
42596
42755
  } catch {
42597
42756
  return;
42598
42757
  }
42599
- const skillMd = path39.join(dir, "SKILL.md");
42600
- if (!fs29.existsSync(skillMd)) return;
42758
+ const skillMd = path41.join(dir, "SKILL.md");
42759
+ if (!fs31.existsSync(skillMd)) return;
42601
42760
  const key = `${rel}/${name}`;
42602
42761
  if (seenKeys.has(key)) return;
42603
42762
  seenKeys.add(key);
@@ -42609,11 +42768,11 @@ async function discoverLocalSkillsAsync(cwd) {
42609
42768
  let work = 0;
42610
42769
  for (const rel of SKILL_DISCOVERY_ROOTS) {
42611
42770
  await yieldSkillDiscoveryWork(++work);
42612
- const base = path39.join(cwd, rel);
42613
- if (!fs29.existsSync(base) || !fs29.statSync(base).isDirectory()) continue;
42771
+ const base = path41.join(cwd, rel);
42772
+ if (!fs31.existsSync(base) || !fs31.statSync(base).isDirectory()) continue;
42614
42773
  let entries = [];
42615
42774
  try {
42616
- entries = fs29.readdirSync(base);
42775
+ entries = fs31.readdirSync(base);
42617
42776
  } catch {
42618
42777
  continue;
42619
42778
  }
@@ -42626,16 +42785,16 @@ async function discoverLocalSkillsAsync(cwd) {
42626
42785
  }
42627
42786
 
42628
42787
  // src/skills/discovery/discover-skill-layout-roots.ts
42629
- import fs30 from "node:fs";
42630
- import path40 from "node:path";
42788
+ import fs32 from "node:fs";
42789
+ import path42 from "node:path";
42631
42790
  function collectLayoutSkill(rel, base, name, skills2) {
42632
- const dir = path40.join(base, name);
42791
+ const dir = path42.join(base, name);
42633
42792
  try {
42634
- if (!fs30.statSync(dir).isDirectory()) return;
42793
+ if (!fs32.statSync(dir).isDirectory()) return;
42635
42794
  } catch {
42636
42795
  return;
42637
42796
  }
42638
- if (!fs30.existsSync(path40.join(dir, "SKILL.md"))) return;
42797
+ if (!fs32.existsSync(path42.join(dir, "SKILL.md"))) return;
42639
42798
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
42640
42799
  skills2.push({ name, relPath });
42641
42800
  }
@@ -42644,11 +42803,11 @@ async function discoverSkillLayoutRootsAsync(cwd) {
42644
42803
  let work = 0;
42645
42804
  for (const rel of SKILL_DISCOVERY_ROOTS) {
42646
42805
  await yieldSkillDiscoveryWork(++work);
42647
- const base = path40.join(cwd, rel);
42648
- if (!fs30.existsSync(base) || !fs30.statSync(base).isDirectory()) continue;
42806
+ const base = path42.join(cwd, rel);
42807
+ if (!fs32.existsSync(base) || !fs32.statSync(base).isDirectory()) continue;
42649
42808
  let entries = [];
42650
42809
  try {
42651
- entries = fs30.readdirSync(base);
42810
+ entries = fs32.readdirSync(base);
42652
42811
  } catch {
42653
42812
  continue;
42654
42813
  }
@@ -42795,12 +42954,12 @@ function createBridgeRuntimeMessageSetup(options) {
42795
42954
  }
42796
42955
 
42797
42956
  // src/worktrees/worktree-layout-file.ts
42798
- import * as fs31 from "node:fs";
42799
- import * as path41 from "node:path";
42800
- import os8 from "node:os";
42957
+ import * as fs33 from "node:fs";
42958
+ import * as path43 from "node:path";
42959
+ import os9 from "node:os";
42801
42960
  var LAYOUT_FILENAME = "worktree-launcher-layout.json";
42802
42961
  function defaultWorktreeLayoutPath() {
42803
- return path41.join(os8.homedir(), ".buildautomaton", LAYOUT_FILENAME);
42962
+ return path43.join(os9.homedir(), ".buildautomaton", LAYOUT_FILENAME);
42804
42963
  }
42805
42964
  function normalizeLoadedLayout(raw) {
42806
42965
  if (raw && typeof raw === "object" && "launcherCwds" in raw) {
@@ -42812,8 +42971,8 @@ function normalizeLoadedLayout(raw) {
42812
42971
  function loadWorktreeLayout() {
42813
42972
  try {
42814
42973
  const p = defaultWorktreeLayoutPath();
42815
- if (!fs31.existsSync(p)) return { launcherCwds: [] };
42816
- const raw = JSON.parse(fs31.readFileSync(p, "utf8"));
42974
+ if (!fs33.existsSync(p)) return { launcherCwds: [] };
42975
+ const raw = JSON.parse(fs33.readFileSync(p, "utf8"));
42817
42976
  return normalizeLoadedLayout(raw);
42818
42977
  } catch {
42819
42978
  return { launcherCwds: [] };
@@ -42821,24 +42980,24 @@ function loadWorktreeLayout() {
42821
42980
  }
42822
42981
  function saveWorktreeLayout(layout) {
42823
42982
  try {
42824
- const dir = path41.dirname(defaultWorktreeLayoutPath());
42825
- fs31.mkdirSync(dir, { recursive: true });
42826
- fs31.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
42983
+ const dir = path43.dirname(defaultWorktreeLayoutPath());
42984
+ fs33.mkdirSync(dir, { recursive: true });
42985
+ fs33.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
42827
42986
  } catch {
42828
42987
  }
42829
42988
  }
42830
42989
  function baseNameSafe(pathString) {
42831
- return path41.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
42990
+ return path43.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
42832
42991
  }
42833
42992
  function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
42834
- const norm = path41.resolve(bridgeRootPath2);
42835
- const existing = layout.launcherCwds.find((e) => path41.resolve(e.absolutePath) === norm);
42993
+ const norm = path43.resolve(bridgeRootPath2);
42994
+ const existing = layout.launcherCwds.find((e) => path43.resolve(e.absolutePath) === norm);
42836
42995
  return existing?.dirName;
42837
42996
  }
42838
42997
  function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
42839
42998
  const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
42840
42999
  if (existing) return existing;
42841
- const norm = path41.resolve(bridgeRootPath2);
43000
+ const norm = path43.resolve(bridgeRootPath2);
42842
43001
  const base = baseNameSafe(norm);
42843
43002
  const used = new Set(layout.launcherCwds.map((e) => e.dirName));
42844
43003
  let name = base;
@@ -42931,8 +43090,8 @@ function pathspec(...paths) {
42931
43090
  cache.set(key, paths);
42932
43091
  return key;
42933
43092
  }
42934
- function isPathSpec(path86) {
42935
- return path86 instanceof String && cache.has(path86);
43093
+ function isPathSpec(path88) {
43094
+ return path88 instanceof String && cache.has(path88);
42936
43095
  }
42937
43096
  function toPaths(pathSpec) {
42938
43097
  return cache.get(pathSpec) || [];
@@ -43021,8 +43180,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
43021
43180
  function forEachLineWithContent(input, callback) {
43022
43181
  return toLinesWithContent(input, true).map((line) => callback(line));
43023
43182
  }
43024
- function folderExists(path86) {
43025
- return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
43183
+ function folderExists(path88) {
43184
+ return (0, import_file_exists.exists)(path88, import_file_exists.FOLDER);
43026
43185
  }
43027
43186
  function append(target, item) {
43028
43187
  if (Array.isArray(target)) {
@@ -43426,8 +43585,8 @@ function checkIsRepoRootTask() {
43426
43585
  commands,
43427
43586
  format: "utf-8",
43428
43587
  onError,
43429
- parser(path86) {
43430
- return /^\.(git)?$/.test(path86.trim());
43588
+ parser(path88) {
43589
+ return /^\.(git)?$/.test(path88.trim());
43431
43590
  }
43432
43591
  };
43433
43592
  }
@@ -43861,11 +44020,11 @@ function parseGrep(grep) {
43861
44020
  const paths = /* @__PURE__ */ new Set();
43862
44021
  const results = {};
43863
44022
  forEachLineWithContent(grep, (input) => {
43864
- const [path86, line, preview] = input.split(NULL);
43865
- paths.add(path86);
43866
- (results[path86] = results[path86] || []).push({
44023
+ const [path88, line, preview] = input.split(NULL);
44024
+ paths.add(path88);
44025
+ (results[path88] = results[path88] || []).push({
43867
44026
  line: asNumber(line),
43868
- path: path86,
44027
+ path: path88,
43869
44028
  preview
43870
44029
  });
43871
44030
  });
@@ -44630,14 +44789,14 @@ var init_hash_object = __esm2({
44630
44789
  init_task();
44631
44790
  }
44632
44791
  });
44633
- function parseInit(bare, path86, text) {
44792
+ function parseInit(bare, path88, text) {
44634
44793
  const response = String(text).trim();
44635
44794
  let result;
44636
44795
  if (result = initResponseRegex.exec(response)) {
44637
- return new InitSummary(bare, path86, false, result[1]);
44796
+ return new InitSummary(bare, path88, false, result[1]);
44638
44797
  }
44639
44798
  if (result = reInitResponseRegex.exec(response)) {
44640
- return new InitSummary(bare, path86, true, result[1]);
44799
+ return new InitSummary(bare, path88, true, result[1]);
44641
44800
  }
44642
44801
  let gitDir = "";
44643
44802
  const tokens = response.split(" ");
@@ -44648,7 +44807,7 @@ function parseInit(bare, path86, text) {
44648
44807
  break;
44649
44808
  }
44650
44809
  }
44651
- return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
44810
+ return new InitSummary(bare, path88, /^re/i.test(response), gitDir);
44652
44811
  }
44653
44812
  var InitSummary;
44654
44813
  var initResponseRegex;
@@ -44657,9 +44816,9 @@ var init_InitSummary = __esm2({
44657
44816
  "src/lib/responses/InitSummary.ts"() {
44658
44817
  "use strict";
44659
44818
  InitSummary = class {
44660
- constructor(bare, path86, existing, gitDir) {
44819
+ constructor(bare, path88, existing, gitDir) {
44661
44820
  this.bare = bare;
44662
- this.path = path86;
44821
+ this.path = path88;
44663
44822
  this.existing = existing;
44664
44823
  this.gitDir = gitDir;
44665
44824
  }
@@ -44671,7 +44830,7 @@ var init_InitSummary = __esm2({
44671
44830
  function hasBareCommand(command) {
44672
44831
  return command.includes(bareCommand);
44673
44832
  }
44674
- function initTask(bare = false, path86, customArgs) {
44833
+ function initTask(bare = false, path88, customArgs) {
44675
44834
  const commands = ["init", ...customArgs];
44676
44835
  if (bare && !hasBareCommand(commands)) {
44677
44836
  commands.splice(1, 0, bareCommand);
@@ -44680,7 +44839,7 @@ function initTask(bare = false, path86, customArgs) {
44680
44839
  commands,
44681
44840
  format: "utf-8",
44682
44841
  parser(text) {
44683
- return parseInit(commands.includes("--bare"), path86, text);
44842
+ return parseInit(commands.includes("--bare"), path88, text);
44684
44843
  }
44685
44844
  };
44686
44845
  }
@@ -45496,12 +45655,12 @@ var init_FileStatusSummary = __esm2({
45496
45655
  "use strict";
45497
45656
  fromPathRegex = /^(.+)\0(.+)$/;
45498
45657
  FileStatusSummary = class {
45499
- constructor(path86, index, working_dir) {
45500
- this.path = path86;
45658
+ constructor(path88, index, working_dir) {
45659
+ this.path = path88;
45501
45660
  this.index = index;
45502
45661
  this.working_dir = working_dir;
45503
45662
  if (index === "R" || working_dir === "R") {
45504
- const detail = fromPathRegex.exec(path86) || [null, path86, path86];
45663
+ const detail = fromPathRegex.exec(path88) || [null, path88, path88];
45505
45664
  this.from = detail[2] || "";
45506
45665
  this.path = detail[1] || "";
45507
45666
  }
@@ -45532,14 +45691,14 @@ function splitLine(result, lineStr) {
45532
45691
  default:
45533
45692
  return;
45534
45693
  }
45535
- function data(index, workingDir, path86) {
45694
+ function data(index, workingDir, path88) {
45536
45695
  const raw = `${index}${workingDir}`;
45537
45696
  const handler = parsers6.get(raw);
45538
45697
  if (handler) {
45539
- handler(result, path86);
45698
+ handler(result, path88);
45540
45699
  }
45541
45700
  if (raw !== "##" && raw !== "!!") {
45542
- result.files.push(new FileStatusSummary(path86, index, workingDir));
45701
+ result.files.push(new FileStatusSummary(path88, index, workingDir));
45543
45702
  }
45544
45703
  }
45545
45704
  }
@@ -45848,9 +46007,9 @@ var init_simple_git_api = __esm2({
45848
46007
  next
45849
46008
  );
45850
46009
  }
45851
- hashObject(path86, write) {
46010
+ hashObject(path88, write) {
45852
46011
  return this._runTask(
45853
- hashObjectTask(path86, write === true),
46012
+ hashObjectTask(path88, write === true),
45854
46013
  trailingFunctionArgument(arguments)
45855
46014
  );
45856
46015
  }
@@ -46203,8 +46362,8 @@ var init_branch = __esm2({
46203
46362
  }
46204
46363
  });
46205
46364
  function toPath(input) {
46206
- const path86 = input.trim().replace(/^["']|["']$/g, "");
46207
- return path86 && normalize3(path86);
46365
+ const path88 = input.trim().replace(/^["']|["']$/g, "");
46366
+ return path88 && normalize3(path88);
46208
46367
  }
46209
46368
  var parseCheckIgnore;
46210
46369
  var init_CheckIgnore = __esm2({
@@ -46518,8 +46677,8 @@ __export2(sub_module_exports, {
46518
46677
  subModuleTask: () => subModuleTask,
46519
46678
  updateSubModuleTask: () => updateSubModuleTask
46520
46679
  });
46521
- function addSubModuleTask(repo, path86) {
46522
- return subModuleTask(["add", repo, path86]);
46680
+ function addSubModuleTask(repo, path88) {
46681
+ return subModuleTask(["add", repo, path88]);
46523
46682
  }
46524
46683
  function initSubModuleTask(customArgs) {
46525
46684
  return subModuleTask(["init", ...customArgs]);
@@ -46852,8 +47011,8 @@ var require_git = __commonJS2({
46852
47011
  }
46853
47012
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
46854
47013
  };
46855
- Git2.prototype.submoduleAdd = function(repo, path86, then) {
46856
- return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
47014
+ Git2.prototype.submoduleAdd = function(repo, path88, then) {
47015
+ return this._runTask(addSubModuleTask2(repo, path88), trailingFunctionArgument2(arguments));
46857
47016
  };
46858
47017
  Git2.prototype.submoduleUpdate = function(args, then) {
46859
47018
  return this._runTask(
@@ -47592,8 +47751,8 @@ function parseNumstatEntries(lines) {
47592
47751
  }
47593
47752
  function parseNumstat(lines) {
47594
47753
  const m = /* @__PURE__ */ new Map();
47595
- for (const [path86, entry] of parseNumstatEntries(lines)) {
47596
- m.set(path86, { additions: entry.additions, deletions: entry.deletions });
47754
+ for (const [path88, entry] of parseNumstatEntries(lines)) {
47755
+ m.set(path88, { additions: entry.additions, deletions: entry.deletions });
47597
47756
  }
47598
47757
  return m;
47599
47758
  }
@@ -47722,7 +47881,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
47722
47881
  }
47723
47882
 
47724
47883
  // src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
47725
- import * as path42 from "node:path";
47884
+ import * as path44 from "node:path";
47726
47885
  var BASE_SHA_CACHE_TTL_MS = 3e4;
47727
47886
  var baseShaCache = /* @__PURE__ */ new Map();
47728
47887
  async function resolveBaseShaForUnpushedCommitsUncached(g) {
@@ -47733,7 +47892,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
47733
47892
  }
47734
47893
  async function resolveBaseShaForUnpushedCommits(g, repoDir) {
47735
47894
  if (repoDir) {
47736
- const key = path42.resolve(repoDir);
47895
+ const key = path44.resolve(repoDir);
47737
47896
  const now = Date.now();
47738
47897
  const cached2 = baseShaCache.get(key);
47739
47898
  if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
@@ -47868,17 +48027,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
47868
48027
  }
47869
48028
 
47870
48029
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
47871
- import * as path52 from "node:path";
48030
+ import * as path54 from "node:path";
47872
48031
 
47873
48032
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
47874
- import * as path51 from "node:path";
48033
+ import * as path53 from "node:path";
47875
48034
 
47876
48035
  // src/git/is-git-repo.ts
47877
- import * as fs32 from "node:fs";
47878
- import * as path43 from "node:path";
48036
+ import * as fs34 from "node:fs";
48037
+ import * as path45 from "node:path";
47879
48038
  async function isGitRepoDirectory(dirPath) {
47880
48039
  try {
47881
- await fs32.promises.access(path43.join(dirPath, ".git"));
48040
+ await fs34.promises.access(path45.join(dirPath, ".git"));
47882
48041
  return true;
47883
48042
  } catch {
47884
48043
  return false;
@@ -47886,8 +48045,8 @@ async function isGitRepoDirectory(dirPath) {
47886
48045
  }
47887
48046
 
47888
48047
  // src/git/changes/listing/apply-untracked-file-stats.ts
47889
- import * as fs33 from "node:fs";
47890
- import * as path44 from "node:path";
48048
+ import * as fs35 from "node:fs";
48049
+ import * as path46 from "node:path";
47891
48050
 
47892
48051
  // src/git/changes/lines/count-lines.ts
47893
48052
  import { createReadStream } from "node:fs";
@@ -47919,7 +48078,7 @@ function createUntrackedStatsApplier(options) {
47919
48078
  if (!options.untrackedSet.has(pathInRepo)) return;
47920
48079
  if (options.nameByPath.has(pathInRepo)) return;
47921
48080
  if (row.change === "moved") return;
47922
- const repoFilePath = path44.join(options.repoGitCwd, pathInRepo);
48081
+ const repoFilePath = path46.join(options.repoGitCwd, pathInRepo);
47923
48082
  const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
47924
48083
  if (fromGit) {
47925
48084
  row.additions = fromGit.additions;
@@ -47927,7 +48086,7 @@ function createUntrackedStatsApplier(options) {
47927
48086
  return;
47928
48087
  }
47929
48088
  try {
47930
- const st = await fs33.promises.stat(repoFilePath);
48089
+ const st = await fs35.promises.stat(repoFilePath);
47931
48090
  row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
47932
48091
  } catch {
47933
48092
  row.additions = 0;
@@ -48004,7 +48163,7 @@ async function buildChangedFileRowsFromPaths(options) {
48004
48163
  }
48005
48164
 
48006
48165
  // src/git/changes/listing/enrich-working-tree-file-rows.ts
48007
- import * as path46 from "node:path";
48166
+ import * as path48 from "node:path";
48008
48167
 
48009
48168
  // src/git/changes/patch/patch-truncate.ts
48010
48169
  function truncatePatch(s) {
@@ -48092,10 +48251,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
48092
48251
  }
48093
48252
 
48094
48253
  // src/git/changes/patch/hydrate/read-worktree-file-lines.ts
48095
- import * as fs34 from "node:fs";
48254
+ import * as fs36 from "node:fs";
48096
48255
  async function readWorktreeFileLines(filePath) {
48097
48256
  try {
48098
- const raw = await fs34.promises.readFile(filePath, "utf8");
48257
+ const raw = await fs36.promises.readFile(filePath, "utf8");
48099
48258
  return raw.split(/\r?\n/);
48100
48259
  } catch {
48101
48260
  return null;
@@ -48233,8 +48392,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
48233
48392
  }
48234
48393
 
48235
48394
  // src/git/changes/total-lines/resolve-changed-file-total-lines.ts
48236
- import * as fs35 from "node:fs";
48237
- import * as path45 from "node:path";
48395
+ import * as fs37 from "node:fs";
48396
+ import * as path47 from "node:path";
48238
48397
  var MAX_BYTES = 512e3;
48239
48398
  async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
48240
48399
  const spec = `${ref}:${pathInRepo}`;
@@ -48254,13 +48413,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
48254
48413
  }
48255
48414
  async function resolveWorkingTreeFileTotalLines(options) {
48256
48415
  if (options.isBinary) return null;
48257
- const filePath = path45.join(options.repoGitCwd, options.pathInRepo);
48416
+ const filePath = path47.join(options.repoGitCwd, options.pathInRepo);
48258
48417
  if (options.change === "removed") {
48259
48418
  return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
48260
48419
  }
48261
48420
  if (options.change === "moved" || options.change === "modified") {
48262
48421
  try {
48263
- const st = await fs35.promises.stat(filePath);
48422
+ const st = await fs37.promises.stat(filePath);
48264
48423
  if (!st.isFile()) return null;
48265
48424
  return await countTextFileLines(filePath);
48266
48425
  } catch {
@@ -48303,7 +48462,7 @@ async function enrichWorkingTreeFileRows(options) {
48303
48462
  row.workspaceRelPath,
48304
48463
  options.repoPathRelativeToWorkspaceRoot
48305
48464
  );
48306
- const filePath = path46.join(options.repoGitCwd, filePathRelativeToRepoRoot);
48465
+ const filePath = path48.join(options.repoGitCwd, filePathRelativeToRepoRoot);
48307
48466
  const hydrateKind = row.change === "moved" ? "modified" : row.change;
48308
48467
  let patch = await unifiedDiffForFile(
48309
48468
  options.repoGitCwd,
@@ -48461,7 +48620,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
48461
48620
  }
48462
48621
 
48463
48622
  // src/git/changes/listing/list-changed-files-for-commit.ts
48464
- import * as path47 from "node:path";
48623
+ import * as path49 from "node:path";
48465
48624
 
48466
48625
  // src/git/changes/listing/enrich-commit-file-rows.ts
48467
48626
  async function enrichCommitFileRows(options) {
@@ -48506,7 +48665,7 @@ async function parentForCommitDiff(g, sha) {
48506
48665
  var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
48507
48666
  var commitFilesCache = /* @__PURE__ */ new Map();
48508
48667
  function commitFilesCacheKey(repoGitCwd, commitSha) {
48509
- return `${path47.resolve(repoGitCwd)}:${commitSha}`;
48668
+ return `${path49.resolve(repoGitCwd)}:${commitSha}`;
48510
48669
  }
48511
48670
  async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
48512
48671
  const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
@@ -48561,7 +48720,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
48561
48720
  }
48562
48721
 
48563
48722
  // src/git/commits/list-unpushed-commits.ts
48564
- import * as path48 from "node:path";
48723
+ import * as path50 from "node:path";
48565
48724
 
48566
48725
  // src/git/commits/lib/parse-log-lines.ts
48567
48726
  function parseLogShaDateSubjectLines(raw) {
@@ -48596,7 +48755,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
48596
48755
  }
48597
48756
  }
48598
48757
  async function listUnpushedCommits(repoDir) {
48599
- const key = path48.resolve(repoDir);
48758
+ const key = path50.resolve(repoDir);
48600
48759
  const now = Date.now();
48601
48760
  const cached2 = unpushedCache.get(key);
48602
48761
  if (cached2 && cached2.expiresAt > now) return cached2.commits;
@@ -48657,7 +48816,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
48657
48816
  }
48658
48817
 
48659
48818
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
48660
- import * as path49 from "node:path";
48819
+ import * as path51 from "node:path";
48661
48820
 
48662
48821
  // src/git/remote-origin-url.ts
48663
48822
  async function getRemoteOriginUrl(gitDir) {
@@ -48672,7 +48831,7 @@ async function getRemoteOriginUrl(gitDir) {
48672
48831
 
48673
48832
  // src/git/changes/repo/load-working-tree-change-repo-git-info.ts
48674
48833
  async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
48675
- const resolvedCheckoutPath = path49.resolve(checkoutPath);
48834
+ const resolvedCheckoutPath = path51.resolve(checkoutPath);
48676
48835
  const git = cliSimpleGit(resolvedCheckoutPath);
48677
48836
  await yieldToEventLoop2();
48678
48837
  const [branch, remoteUrl] = await Promise.all([
@@ -48687,14 +48846,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
48687
48846
  }
48688
48847
 
48689
48848
  // src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
48690
- import * as path50 from "node:path";
48849
+ import * as path52 from "node:path";
48691
48850
  async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48692
- const checkoutPath = path50.resolve(options.checkoutPath);
48851
+ const checkoutPath = path52.resolve(options.checkoutPath);
48693
48852
  const git = cliSimpleGit(checkoutPath);
48694
- const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
48853
+ const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
48695
48854
  let repoPathRelativeToWorkspaceRoot;
48696
48855
  if (sessionParentPath) {
48697
- const checkoutPathRelativeToSessionParent = path50.relative(sessionParentPath, checkoutPath);
48856
+ const checkoutPathRelativeToSessionParent = path52.relative(sessionParentPath, checkoutPath);
48698
48857
  repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
48699
48858
  } else {
48700
48859
  let gitTopLevel = checkoutPath;
@@ -48704,8 +48863,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48704
48863
  } catch {
48705
48864
  gitTopLevel = checkoutPath;
48706
48865
  }
48707
- const gitTopLevelRelativeToBridgeRoot = path50.relative(options.bridgeRoot, path50.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
48708
- repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path50.basename(path50.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
48866
+ const gitTopLevelRelativeToBridgeRoot = path52.relative(options.bridgeRoot, path52.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
48867
+ repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path52.basename(path52.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
48709
48868
  }
48710
48869
  return normalizeRepoPathRelativeToWorkspaceRoot(
48711
48870
  repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
@@ -48714,10 +48873,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
48714
48873
 
48715
48874
  // src/git/changes/repo/build-working-tree-change-repo-detail.ts
48716
48875
  async function buildWorkingTreeChangeRepoDetail(options) {
48717
- const checkoutPath = path51.resolve(options.targetPath);
48876
+ const checkoutPath = path53.resolve(options.targetPath);
48718
48877
  if (!await isGitRepoDirectory(checkoutPath)) return null;
48719
48878
  const isCommitView = options.basis.kind === "commit";
48720
- const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
48879
+ const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
48721
48880
  const git = cliSimpleGit(checkoutPath);
48722
48881
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
48723
48882
  checkoutPath,
@@ -48765,8 +48924,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
48765
48924
 
48766
48925
  // src/git/changes/repo/get-working-tree-change-repo-details.ts
48767
48926
  async function getWorkingTreeChangeRepoDetails(options) {
48768
- const bridgeRoot = path52.resolve(getBridgeRoot());
48769
- const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
48927
+ const bridgeRoot = path54.resolve(getBridgeRoot());
48928
+ const sessionParentPath = options.sessionParentPath ? path54.resolve(options.sessionParentPath) : null;
48770
48929
  const out = [];
48771
48930
  const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
48772
48931
  const basisInput = options.basis ?? { kind: "working" };
@@ -48797,9 +48956,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
48797
48956
  }
48798
48957
 
48799
48958
  // src/git/changes/repo/get-working-tree-change-file-patch.ts
48800
- import * as path53 from "node:path";
48959
+ import * as path55 from "node:path";
48801
48960
  async function getWorkingTreeChangeFilePatch(options) {
48802
- const repoGitCwd = path53.resolve(options.repoGitCwd);
48961
+ const repoGitCwd = path55.resolve(options.repoGitCwd);
48803
48962
  if (!await isGitRepoDirectory(repoGitCwd)) {
48804
48963
  throw new Error("Not a git repository");
48805
48964
  }
@@ -48838,7 +48997,7 @@ async function getWorkingTreeChangeFilePatch(options) {
48838
48997
  });
48839
48998
  return { patchContent: patchContent2, totalLines: totalLines2 };
48840
48999
  }
48841
- const filePath = path53.join(repoGitCwd, filePathRelativeToRepoRoot);
49000
+ const filePath = path55.join(repoGitCwd, filePathRelativeToRepoRoot);
48842
49001
  const hydrateKind = options.change === "moved" ? "modified" : options.change;
48843
49002
  let patchContent = await unifiedDiffForFile(
48844
49003
  repoGitCwd,
@@ -48884,18 +49043,18 @@ function parseWorkingTreeChangeKind(value) {
48884
49043
  }
48885
49044
 
48886
49045
  // src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
48887
- import * as path54 from "node:path";
49046
+ import * as path56 from "node:path";
48888
49047
  async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
48889
49048
  const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
48890
- const bridgeRoot = path54.resolve(getBridgeRoot());
48891
- const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path54.resolve(cache2.getSessionParentPath(sessionId)) : null;
49049
+ const bridgeRoot = path56.resolve(getBridgeRoot());
49050
+ const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path56.resolve(cache2.getSessionParentPath(sessionId)) : null;
48892
49051
  const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
48893
49052
  opts.repoRelPath.trim()
48894
49053
  );
48895
49054
  let result = null;
48896
49055
  await forEachWithGitYield(targets, async (targetPath) => {
48897
49056
  if (result) return;
48898
- const checkoutPath = path54.resolve(targetPath);
49057
+ const checkoutPath = path56.resolve(targetPath);
48899
49058
  if (!await isGitRepoDirectory(checkoutPath)) return;
48900
49059
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
48901
49060
  checkoutPath,
@@ -48928,13 +49087,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
48928
49087
  }
48929
49088
 
48930
49089
  // src/worktrees/remove-session-worktrees.ts
48931
- import * as fs38 from "node:fs";
49090
+ import * as fs40 from "node:fs";
48932
49091
 
48933
49092
  // src/git/worktrees/worktree-remove.ts
48934
- import * as fs37 from "node:fs";
49093
+ import * as fs39 from "node:fs";
48935
49094
 
48936
49095
  // src/worktrees/is-removable-session-worktree-checkout-path.ts
48937
- import path55 from "node:path";
49096
+ import path57 from "node:path";
48938
49097
  init_normalize_resolved_path();
48939
49098
  function isBridgeRootCheckoutPath(checkoutPath) {
48940
49099
  return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
@@ -48943,23 +49102,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
48943
49102
  if (isBridgeRootCheckoutPath(checkoutPath)) return false;
48944
49103
  const normalized = normalizeResolvedPath(checkoutPath);
48945
49104
  const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
48946
- const rel = path55.relative(worktreesRoot, normalized);
48947
- if (rel === "" || rel.startsWith("..") || path55.isAbsolute(rel)) return false;
49105
+ const rel = path57.relative(worktreesRoot, normalized);
49106
+ if (rel === "" || rel.startsWith("..") || path57.isAbsolute(rel)) return false;
48948
49107
  return true;
48949
49108
  }
48950
49109
 
48951
49110
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
48952
- import * as fs36 from "node:fs";
48953
- import * as path56 from "node:path";
49111
+ import * as fs38 from "node:fs";
49112
+ import * as path58 from "node:path";
48954
49113
  function resolveMainRepoFromWorktreeGitFile(wt) {
48955
- const gitDirFile = path56.join(wt, ".git");
48956
- if (!fs36.existsSync(gitDirFile) || !fs36.statSync(gitDirFile).isFile()) return "";
48957
- const first2 = fs36.readFileSync(gitDirFile, "utf8").trim();
49114
+ const gitDirFile = path58.join(wt, ".git");
49115
+ if (!fs38.existsSync(gitDirFile) || !fs38.statSync(gitDirFile).isFile()) return "";
49116
+ const first2 = fs38.readFileSync(gitDirFile, "utf8").trim();
48958
49117
  const m = first2.match(/^gitdir:\s*(.+)$/im);
48959
49118
  if (!m) return "";
48960
- const gitWorktreePath = path56.resolve(wt, m[1].trim());
48961
- const gitDir = path56.dirname(path56.dirname(gitWorktreePath));
48962
- return path56.dirname(gitDir);
49119
+ const gitWorktreePath = path58.resolve(wt, m[1].trim());
49120
+ const gitDir = path58.dirname(path58.dirname(gitWorktreePath));
49121
+ return path58.dirname(gitDir);
48963
49122
  }
48964
49123
 
48965
49124
  // src/git/worktrees/worktree-remove.ts
@@ -48970,7 +49129,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
48970
49129
  return true;
48971
49130
  }
48972
49131
  if (isBridgeRootCheckoutPath(worktreePath)) return false;
48973
- fs37.rmSync(worktreePath, { recursive: true, force: true });
49132
+ fs39.rmSync(worktreePath, { recursive: true, force: true });
48974
49133
  return true;
48975
49134
  }
48976
49135
 
@@ -48992,7 +49151,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
48992
49151
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
48993
49152
  if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
48994
49153
  try {
48995
- fs38.rmSync(wt, { recursive: true, force: true });
49154
+ fs40.rmSync(wt, { recursive: true, force: true });
48996
49155
  } catch {
48997
49156
  }
48998
49157
  }
@@ -49048,12 +49207,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
49048
49207
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
49049
49208
  init_cli_process_interrupt();
49050
49209
  init_yield_to_event_loop();
49051
- import * as fs42 from "node:fs";
49052
- import * as path61 from "node:path";
49210
+ import * as fs44 from "node:fs";
49211
+ import * as path63 from "node:path";
49053
49212
 
49054
49213
  // src/worktrees/discovery/collect-worktree-paths.ts
49055
- import * as fs40 from "node:fs";
49056
- import * as path58 from "node:path";
49214
+ import * as fs42 from "node:fs";
49215
+ import * as path60 from "node:path";
49057
49216
 
49058
49217
  // src/worktrees/discovery/disk-walk-constants.ts
49059
49218
  var DISK_WALK_YIELD_EVERY = 64;
@@ -49083,8 +49242,8 @@ function shouldSkipDiskWalkEntry(name) {
49083
49242
  // src/worktrees/discovery/disk-walk-utils.ts
49084
49243
  init_cli_process_interrupt();
49085
49244
  init_yield_to_event_loop();
49086
- import * as fs39 from "node:fs";
49087
- import * as path57 from "node:path";
49245
+ import * as fs41 from "node:fs";
49246
+ import * as path59 from "node:path";
49088
49247
  async function yieldDuringDiskWalk(state) {
49089
49248
  state.entries++;
49090
49249
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -49094,7 +49253,7 @@ async function yieldDuringDiskWalk(state) {
49094
49253
  }
49095
49254
  async function isGitDir(dirPath) {
49096
49255
  try {
49097
- await fs39.promises.access(path57.join(dirPath, ".git"));
49256
+ await fs41.promises.access(path59.join(dirPath, ".git"));
49098
49257
  return true;
49099
49258
  } catch {
49100
49259
  return false;
@@ -49108,23 +49267,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
49108
49267
  const walk = async (dir) => {
49109
49268
  if (!await yieldDuringDiskWalk(state)) return;
49110
49269
  if (await isGitDir(dir)) {
49111
- out.push(path58.resolve(dir));
49270
+ out.push(path60.resolve(dir));
49112
49271
  return;
49113
49272
  }
49114
49273
  let entries;
49115
49274
  try {
49116
- entries = await fs40.promises.readdir(dir, { withFileTypes: true });
49275
+ entries = await fs42.promises.readdir(dir, { withFileTypes: true });
49117
49276
  } catch {
49118
49277
  return;
49119
49278
  }
49120
49279
  for (const e of entries) {
49121
49280
  if (shouldSkipDiskWalkEntry(e.name)) continue;
49122
- const full = path58.join(dir, e.name);
49281
+ const full = path60.join(dir, e.name);
49123
49282
  if (!e.isDirectory()) continue;
49124
49283
  await walk(full);
49125
49284
  }
49126
49285
  };
49127
- await walk(path58.resolve(rootPath));
49286
+ await walk(path60.resolve(rootPath));
49128
49287
  return { paths: [...new Set(out)], entriesVisited: state.entries };
49129
49288
  }
49130
49289
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -49135,16 +49294,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
49135
49294
  if (!await yieldDuringDiskWalk(state)) return;
49136
49295
  let entries;
49137
49296
  try {
49138
- entries = await fs40.promises.readdir(dir, { withFileTypes: true });
49297
+ entries = await fs42.promises.readdir(dir, { withFileTypes: true });
49139
49298
  } catch {
49140
49299
  return;
49141
49300
  }
49142
49301
  for (const e of entries) {
49143
49302
  if (shouldSkipDiskWalkEntry(e.name)) continue;
49144
- const full = path58.join(dir, e.name);
49303
+ const full = path60.join(dir, e.name);
49145
49304
  if (!e.isDirectory()) continue;
49146
49305
  if (e.name === sessionId) {
49147
- if (await isGitDir(full)) out.push(path58.resolve(full));
49306
+ if (await isGitDir(full)) out.push(path60.resolve(full));
49148
49307
  continue;
49149
49308
  }
49150
49309
  if (await isGitDir(full)) continue;
@@ -49156,14 +49315,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
49156
49315
  }
49157
49316
 
49158
49317
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
49159
- import * as path59 from "node:path";
49318
+ import * as path61 from "node:path";
49160
49319
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
49161
- const bridge = path59.resolve(bridgeRoot);
49320
+ const bridge = path61.resolve(bridgeRoot);
49162
49321
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
49163
49322
  const relevant = layout.launcherCwds.filter((e) => {
49164
- const entry = path59.resolve(e.absolutePath);
49165
- return bridge === entry || bridge.startsWith(entry + path59.sep) || entry.startsWith(bridge + path59.sep);
49166
- }).sort((a, b) => path59.resolve(b.absolutePath).length - path59.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
49323
+ const entry = path61.resolve(e.absolutePath);
49324
+ return bridge === entry || bridge.startsWith(entry + path61.sep) || entry.startsWith(bridge + path61.sep);
49325
+ }).sort((a, b) => path61.resolve(b.absolutePath).length - path61.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
49167
49326
  const ordered = [];
49168
49327
  const seen = /* @__PURE__ */ new Set();
49169
49328
  const add = (k) => {
@@ -49181,19 +49340,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
49181
49340
  }
49182
49341
 
49183
49342
  // src/worktrees/discovery/try-binding-from-isolated-directory.ts
49184
- import * as fs41 from "node:fs";
49185
- import * as path60 from "node:path";
49343
+ import * as fs43 from "node:fs";
49344
+ import * as path62 from "node:path";
49186
49345
  async function tryBindingFromIsolatedDirectory(scopeDir) {
49187
49346
  let st;
49188
49347
  try {
49189
- st = await fs41.promises.stat(scopeDir);
49348
+ st = await fs43.promises.stat(scopeDir);
49190
49349
  } catch {
49191
49350
  return null;
49192
49351
  }
49193
49352
  if (!st.isDirectory()) return null;
49194
49353
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
49195
49354
  if (worktreePaths.length === 0) return null;
49196
- const abs = path60.resolve(scopeDir);
49355
+ const abs = path62.resolve(scopeDir);
49197
49356
  return {
49198
49357
  parentPath: abs,
49199
49358
  repoCheckoutPaths: worktreePaths
@@ -49216,7 +49375,7 @@ async function discoverSessionWorktreeOnDisk(options) {
49216
49375
  const sid = sessionId.trim();
49217
49376
  if (!sid) return null;
49218
49377
  try {
49219
- await fs42.promises.access(worktreesRootPath);
49378
+ await fs44.promises.access(worktreesRootPath);
49220
49379
  } catch {
49221
49380
  return null;
49222
49381
  }
@@ -49225,13 +49384,13 @@ async function discoverSessionWorktreeOnDisk(options) {
49225
49384
  if (preferredKey) keysOnDisk.push(preferredKey);
49226
49385
  const scanState = { entries: 0 };
49227
49386
  try {
49228
- for (const name of await fs42.promises.readdir(worktreesRootPath)) {
49387
+ for (const name of await fs44.promises.readdir(worktreesRootPath)) {
49229
49388
  if (!await yieldDuringDiskWalk(scanState)) break;
49230
49389
  if (name.startsWith(".")) continue;
49231
- const p = path61.join(worktreesRootPath, name);
49390
+ const p = path63.join(worktreesRootPath, name);
49232
49391
  let st;
49233
49392
  try {
49234
- st = await fs42.promises.stat(p);
49393
+ st = await fs44.promises.stat(p);
49235
49394
  } catch {
49236
49395
  continue;
49237
49396
  }
@@ -49245,23 +49404,23 @@ async function discoverSessionWorktreeOnDisk(options) {
49245
49404
  for (const key of keys) {
49246
49405
  if (isCliImmediateShutdownRequested()) return null;
49247
49406
  await yieldToEventLoop();
49248
- const layoutRoot = path61.join(worktreesRootPath, key);
49407
+ const layoutRoot = path63.join(worktreesRootPath, key);
49249
49408
  let layoutSt;
49250
49409
  try {
49251
- layoutSt = await fs42.promises.stat(layoutRoot);
49410
+ layoutSt = await fs44.promises.stat(layoutRoot);
49252
49411
  } catch {
49253
49412
  continue;
49254
49413
  }
49255
49414
  if (!layoutSt.isDirectory()) continue;
49256
- const sessionDir = path61.join(layoutRoot, sid);
49415
+ const sessionDir = path63.join(layoutRoot, sid);
49257
49416
  const nested = await tryBindingFromSessionDirectory(sessionDir);
49258
49417
  if (nested) return nested;
49259
49418
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
49260
49419
  if (legacy.paths.length > 0) {
49261
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path61.resolve(legacy.paths[0]);
49420
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path63.resolve(legacy.paths[0]);
49262
49421
  return {
49263
- sessionParentPath: path61.resolve(isolated),
49264
- repoCheckoutPaths: legacy.paths.map((p) => path61.resolve(p))
49422
+ sessionParentPath: path63.resolve(isolated),
49423
+ repoCheckoutPaths: legacy.paths.map((p) => path63.resolve(p))
49265
49424
  };
49266
49425
  }
49267
49426
  }
@@ -49269,31 +49428,31 @@ async function discoverSessionWorktreeOnDisk(options) {
49269
49428
  }
49270
49429
 
49271
49430
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
49272
- import * as fs43 from "node:fs";
49273
- import * as path63 from "node:path";
49431
+ import * as fs45 from "node:fs";
49432
+ import * as path65 from "node:path";
49274
49433
 
49275
49434
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
49276
49435
  init_cli_process_interrupt();
49277
49436
  init_yield_to_event_loop();
49278
- import * as path62 from "node:path";
49437
+ import * as path64 from "node:path";
49279
49438
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
49280
49439
  const sid = sessionId.trim();
49281
49440
  if (!sid) return null;
49282
- const hintR = path62.resolve(checkoutPath);
49441
+ const hintR = path64.resolve(checkoutPath);
49283
49442
  let best = null;
49284
- let cur = path62.dirname(hintR);
49443
+ let cur = path64.dirname(hintR);
49285
49444
  for (let i = 0; i < 40; i++) {
49286
49445
  if (isCliImmediateShutdownRequested()) return best;
49287
49446
  await yieldToEventLoop();
49288
49447
  const paths = await collectWorktreeRootsNamed(cur, sid);
49289
- if (paths.paths.some((p) => path62.resolve(p) === hintR)) {
49290
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path62.resolve(paths.paths[0]);
49448
+ if (paths.paths.some((p) => path64.resolve(p) === hintR)) {
49449
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path64.resolve(paths.paths[0]);
49291
49450
  best = {
49292
- sessionParentPath: path62.resolve(isolated),
49293
- repoCheckoutPaths: paths.paths.map((p) => path62.resolve(p))
49451
+ sessionParentPath: path64.resolve(isolated),
49452
+ repoCheckoutPaths: paths.paths.map((p) => path64.resolve(p))
49294
49453
  };
49295
49454
  }
49296
- const next = path62.dirname(cur);
49455
+ const next = path64.dirname(cur);
49297
49456
  if (next === cur) break;
49298
49457
  cur = next;
49299
49458
  }
@@ -49304,12 +49463,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
49304
49463
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
49305
49464
  const sid = sessionId.trim();
49306
49465
  if (!sid) return null;
49307
- const hint = path63.resolve(sessionParentPathOrHint);
49308
- const underHint = await tryBindingFromSessionDirectory(path63.join(hint, sid));
49466
+ const hint = path65.resolve(sessionParentPathOrHint);
49467
+ const underHint = await tryBindingFromSessionDirectory(path65.join(hint, sid));
49309
49468
  if (underHint) return underHint;
49310
49469
  const direct = await tryBindingFromSessionDirectory(hint);
49311
49470
  if (direct) {
49312
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
49471
+ if (path65.basename(hint) === sid && await isGitDir(hint)) {
49313
49472
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
49314
49473
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
49315
49474
  return legacyFromCheckout;
@@ -49317,23 +49476,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
49317
49476
  }
49318
49477
  return direct;
49319
49478
  }
49320
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
49479
+ if (path65.basename(hint) === sid && await isGitDir(hint)) {
49321
49480
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
49322
49481
  if (legacyFromCheckout) return legacyFromCheckout;
49323
49482
  }
49324
49483
  let st;
49325
49484
  try {
49326
- st = await fs43.promises.stat(hint);
49485
+ st = await fs45.promises.stat(hint);
49327
49486
  } catch {
49328
49487
  return null;
49329
49488
  }
49330
49489
  if (!st.isDirectory()) return null;
49331
49490
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
49332
49491
  if (legacyPaths.paths.length === 0) return null;
49333
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path63.resolve(legacyPaths.paths[0]);
49492
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path65.resolve(legacyPaths.paths[0]);
49334
49493
  return {
49335
- sessionParentPath: path63.resolve(isolated),
49336
- repoCheckoutPaths: legacyPaths.paths.map((p) => path63.resolve(p))
49494
+ sessionParentPath: path65.resolve(isolated),
49495
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path65.resolve(p))
49337
49496
  };
49338
49497
  }
49339
49498
 
@@ -49394,11 +49553,11 @@ function parseSessionParent(v) {
49394
49553
  }
49395
49554
 
49396
49555
  // src/worktrees/prepare/prepare-new-isolated-worktrees.ts
49397
- import * as fs47 from "node:fs";
49556
+ import * as fs49 from "node:fs";
49398
49557
 
49399
49558
  // src/git/discover-repos.ts
49400
- import * as fs44 from "node:fs";
49401
- import * as path64 from "node:path";
49559
+ import * as fs46 from "node:fs";
49560
+ import * as path66 from "node:path";
49402
49561
  init_yield_to_event_loop();
49403
49562
  var GIT_DISCOVER_YIELD_EVERY = 32;
49404
49563
  async function yieldGitDiscoverWork(entryCount) {
@@ -49408,14 +49567,14 @@ async function yieldGitDiscoverWork(entryCount) {
49408
49567
  }
49409
49568
  async function discoverGitRepos(cwd = getBridgeRoot()) {
49410
49569
  const result = [];
49411
- const cwdResolved = path64.resolve(cwd);
49570
+ const cwdResolved = path66.resolve(cwd);
49412
49571
  if (await isGitRepoDirectory(cwdResolved)) {
49413
49572
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
49414
49573
  result.push({ absolutePath: cwdResolved, remoteUrl });
49415
49574
  }
49416
49575
  let entries;
49417
49576
  try {
49418
- entries = fs44.readdirSync(cwdResolved, { withFileTypes: true });
49577
+ entries = fs46.readdirSync(cwdResolved, { withFileTypes: true });
49419
49578
  } catch {
49420
49579
  return result;
49421
49580
  }
@@ -49423,7 +49582,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
49423
49582
  await yieldGitDiscoverWork(i + 1);
49424
49583
  const ent = entries[i];
49425
49584
  if (!ent.isDirectory()) continue;
49426
- const childPath2 = path64.join(cwdResolved, ent.name);
49585
+ const childPath2 = path66.join(cwdResolved, ent.name);
49427
49586
  if (await isGitRepoDirectory(childPath2)) {
49428
49587
  const remoteUrl = await getRemoteOriginUrl(childPath2);
49429
49588
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -49432,17 +49591,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
49432
49591
  return result;
49433
49592
  }
49434
49593
  async function discoverGitReposUnderRoot(rootPath) {
49435
- const root = path64.resolve(rootPath);
49594
+ const root = path66.resolve(rootPath);
49436
49595
  const roots = [];
49437
49596
  let walkEntries = 0;
49438
49597
  async function walk(dir) {
49439
49598
  if (await isGitRepoDirectory(dir)) {
49440
- roots.push(path64.resolve(dir));
49599
+ roots.push(path66.resolve(dir));
49441
49600
  return;
49442
49601
  }
49443
49602
  let entries;
49444
49603
  try {
49445
- entries = fs44.readdirSync(dir, { withFileTypes: true });
49604
+ entries = fs46.readdirSync(dir, { withFileTypes: true });
49446
49605
  } catch {
49447
49606
  return;
49448
49607
  }
@@ -49450,7 +49609,7 @@ async function discoverGitReposUnderRoot(rootPath) {
49450
49609
  await yieldGitDiscoverWork(++walkEntries);
49451
49610
  const ent = entries[i];
49452
49611
  if (!ent.isDirectory() || ent.name === ".git") continue;
49453
- await walk(path64.join(dir, ent.name));
49612
+ await walk(path66.join(dir, ent.name));
49454
49613
  }
49455
49614
  }
49456
49615
  await walk(root);
@@ -49466,8 +49625,8 @@ async function discoverGitReposUnderRoot(rootPath) {
49466
49625
  }
49467
49626
 
49468
49627
  // src/worktrees/prepare/add-isolated-repo-worktree.ts
49469
- import * as fs46 from "node:fs";
49470
- import * as path66 from "node:path";
49628
+ import * as fs48 from "node:fs";
49629
+ import * as path68 from "node:path";
49471
49630
 
49472
49631
  // src/git/worktrees/worktree-add.ts
49473
49632
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
@@ -49483,8 +49642,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
49483
49642
  }
49484
49643
 
49485
49644
  // src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
49486
- import * as fs45 from "node:fs";
49487
- import * as path65 from "node:path";
49645
+ import * as fs47 from "node:fs";
49646
+ import * as path67 from "node:path";
49488
49647
  var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
49489
49648
  function copyBridgeFilesAlongWorktreePath(options) {
49490
49649
  const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
@@ -49493,19 +49652,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
49493
49652
  const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
49494
49653
  for (let i = 0; i < segments.length; i++) {
49495
49654
  const prefix = segments.slice(0, i).join("/");
49496
- const bridgeDir = prefix ? path65.join(bridgeRoot, prefix) : bridgeRoot;
49497
- const destDir = prefix ? path65.join(scopeDir, prefix) : scopeDir;
49655
+ const bridgeDir = prefix ? path67.join(bridgeRoot, prefix) : bridgeRoot;
49656
+ const destDir = prefix ? path67.join(scopeDir, prefix) : scopeDir;
49498
49657
  for (const fileName of fileNames) {
49499
49658
  copyFileIfPresent(bridgeDir, destDir, fileName, log2);
49500
49659
  }
49501
49660
  }
49502
49661
  }
49503
49662
  function copyFileIfPresent(srcDir, destDir, fileName, log2) {
49504
- const src = path65.join(srcDir, fileName);
49505
- if (!fs45.existsSync(src)) return;
49506
- const dest = path65.join(destDir, fileName);
49663
+ const src = path67.join(srcDir, fileName);
49664
+ if (!fs47.existsSync(src)) return;
49665
+ const dest = path67.join(destDir, fileName);
49507
49666
  try {
49508
- fs45.copyFileSync(src, dest);
49667
+ fs47.copyFileSync(src, dest);
49509
49668
  log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
49510
49669
  } catch (e) {
49511
49670
  log2?.(
@@ -49537,16 +49696,16 @@ async function addIsolatedRepoWorktree(options) {
49537
49696
  worktreeBaseBranches,
49538
49697
  log: log2
49539
49698
  } = options;
49540
- const repoPathRelativeToBridgeRootRaw = path66.relative(bridgeResolved, repoAbsolutePath);
49541
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path66.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
49699
+ const repoPathRelativeToBridgeRootRaw = path68.relative(bridgeResolved, repoAbsolutePath);
49700
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path68.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
49542
49701
  return null;
49543
49702
  }
49544
49703
  const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
49545
49704
  repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
49546
49705
  );
49547
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path66.join(scopeDir, repoPathRelativeToBridgeRoot);
49706
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path68.join(scopeDir, repoPathRelativeToBridgeRoot);
49548
49707
  if (repoPathRelativeToBridgeRoot !== ".") {
49549
- fs46.mkdirSync(path66.dirname(worktreePath), { recursive: true });
49708
+ fs48.mkdirSync(path68.dirname(worktreePath), { recursive: true });
49550
49709
  copyBridgeFilesAlongWorktreePath({
49551
49710
  bridgeRoot: bridgeResolved,
49552
49711
  scopeDir,
@@ -49574,7 +49733,7 @@ async function addIsolatedRepoWorktree(options) {
49574
49733
  }
49575
49734
 
49576
49735
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
49577
- import * as path67 from "node:path";
49736
+ import * as path69 from "node:path";
49578
49737
 
49579
49738
  // src/worktrees/worktree-layout-kind.ts
49580
49739
  function sanitizeWorktreeBranchSegment(value) {
@@ -49604,10 +49763,10 @@ function previewDeployBranchName(environmentId) {
49604
49763
 
49605
49764
  // src/worktrees/prepare/resolve-isolated-scope-dir.ts
49606
49765
  function resolveIsolatedScopeDir(options) {
49607
- const bridgeResolved = path67.resolve(options.bridgeRoot);
49766
+ const bridgeResolved = path69.resolve(options.bridgeRoot);
49608
49767
  const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
49609
- const bridgeKeyDir = path67.join(options.worktreesRootPath, cwdKey);
49610
- const scopeDir = path67.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
49768
+ const bridgeKeyDir = path69.join(options.worktreesRootPath, cwdKey);
49769
+ const scopeDir = path69.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
49611
49770
  return { bridgeResolved, scopeDir };
49612
49771
  }
49613
49772
 
@@ -49637,7 +49796,7 @@ async function prepareNewIsolatedWorktrees(options) {
49637
49796
  return null;
49638
49797
  }
49639
49798
  const worktreePaths = [];
49640
- fs47.mkdirSync(scopeDir, { recursive: true });
49799
+ fs49.mkdirSync(scopeDir, { recursive: true });
49641
49800
  await forEachWithGitYield(repos, async (repo) => {
49642
49801
  const worktreePath = await addIsolatedRepoWorktree({
49643
49802
  kind,
@@ -49709,10 +49868,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
49709
49868
  }
49710
49869
 
49711
49870
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
49712
- import * as path68 from "node:path";
49871
+ import * as path70 from "node:path";
49713
49872
  init_yield_to_event_loop();
49714
49873
  async function resolveExplicitSessionParentPath(params) {
49715
- const resolved = path68.resolve(params.parentPathRaw);
49874
+ const resolved = path70.resolve(params.parentPathRaw);
49716
49875
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
49717
49876
  return resolved;
49718
49877
  }
@@ -49729,7 +49888,7 @@ async function resolveExplicitSessionParentPath(params) {
49729
49888
  await yieldToEventLoop();
49730
49889
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
49731
49890
  if (tryRoot) return rememberAndReturn(tryRoot);
49732
- const next = path68.dirname(cur);
49891
+ const next = path70.dirname(cur);
49733
49892
  if (next === cur) break;
49734
49893
  cur = next;
49735
49894
  }
@@ -49890,15 +50049,15 @@ var SessionWorktreeManager = class {
49890
50049
  };
49891
50050
 
49892
50051
  // src/worktrees/discovery/discover-preview-worktree-on-disk.ts
49893
- import * as fs48 from "node:fs";
49894
- import * as path69 from "node:path";
50052
+ import * as fs50 from "node:fs";
50053
+ import * as path71 from "node:path";
49895
50054
  init_yield_to_event_loop();
49896
50055
  async function discoverPreviewWorktreeOnDisk(options) {
49897
50056
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
49898
50057
  const eid = environmentId.trim();
49899
50058
  if (!eid) return null;
49900
50059
  try {
49901
- await fs48.promises.access(worktreesRootPath);
50060
+ await fs50.promises.access(worktreesRootPath);
49902
50061
  } catch {
49903
50062
  return null;
49904
50063
  }
@@ -49907,13 +50066,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
49907
50066
  if (preferredKey) keysOnDisk.push(preferredKey);
49908
50067
  const scanState = { entries: 0 };
49909
50068
  try {
49910
- for (const name of await fs48.promises.readdir(worktreesRootPath)) {
50069
+ for (const name of await fs50.promises.readdir(worktreesRootPath)) {
49911
50070
  if (!await yieldDuringDiskWalk(scanState)) break;
49912
50071
  if (name.startsWith(".")) continue;
49913
- const p = path69.join(worktreesRootPath, name);
50072
+ const p = path71.join(worktreesRootPath, name);
49914
50073
  let st;
49915
50074
  try {
49916
- st = await fs48.promises.stat(p);
50075
+ st = await fs50.promises.stat(p);
49917
50076
  } catch {
49918
50077
  continue;
49919
50078
  }
@@ -49927,7 +50086,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
49927
50086
  const previewDirRel = layoutDirSegments("preview_environment", eid);
49928
50087
  for (const key of keys) {
49929
50088
  await yieldToEventLoop();
49930
- const previewDir = path69.join(worktreesRootPath, key, ...previewDirRel);
50089
+ const previewDir = path71.join(worktreesRootPath, key, ...previewDirRel);
49931
50090
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
49932
50091
  if (binding) return binding;
49933
50092
  }
@@ -50054,7 +50213,7 @@ var PreviewWorktreeManager = class {
50054
50213
  };
50055
50214
 
50056
50215
  // src/worktrees/deploy/deploy-session-to-preview-environment.ts
50057
- import * as path73 from "node:path";
50216
+ import * as path75 from "node:path";
50058
50217
 
50059
50218
  // src/git/worktrees/reset-worktree-to-branch.ts
50060
50219
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -50065,8 +50224,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
50065
50224
  }
50066
50225
 
50067
50226
  // src/worktrees/deploy/capture-and-apply-wip.ts
50068
- import * as fs49 from "node:fs";
50069
- import * as path70 from "node:path";
50227
+ import * as fs51 from "node:fs";
50228
+ import * as path72 from "node:path";
50070
50229
 
50071
50230
  // src/git/snapshot/git.ts
50072
50231
  var SNAPSHOT_GIT_TIMEOUT_MS = 5e3;
@@ -50121,12 +50280,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
50121
50280
  if (!ap.ok) return ap;
50122
50281
  }
50123
50282
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
50124
- const src = path70.join(sourceRepoPath, rel);
50125
- const dst = path70.join(targetRepoPath, rel);
50283
+ const src = path72.join(sourceRepoPath, rel);
50284
+ const dst = path72.join(targetRepoPath, rel);
50126
50285
  try {
50127
- if (!fs49.existsSync(src)) return;
50128
- fs49.mkdirSync(path70.dirname(dst), { recursive: true });
50129
- fs49.copyFileSync(src, dst);
50286
+ if (!fs51.existsSync(src)) return;
50287
+ fs51.mkdirSync(path72.dirname(dst), { recursive: true });
50288
+ fs51.copyFileSync(src, dst);
50130
50289
  } catch (e) {
50131
50290
  log2(
50132
50291
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -50137,14 +50296,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
50137
50296
  }
50138
50297
 
50139
50298
  // src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
50140
- import * as path71 from "node:path";
50299
+ import * as path73 from "node:path";
50141
50300
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
50142
50301
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
50143
- const resolvedSessionParentPath = sessionParentPath ? path71.resolve(sessionParentPath) : null;
50302
+ const resolvedSessionParentPath = sessionParentPath ? path73.resolve(sessionParentPath) : null;
50144
50303
  let match = null;
50145
50304
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
50146
50305
  if (match) return;
50147
- const resolvedCheckoutPath = path71.resolve(checkoutPath);
50306
+ const resolvedCheckoutPath = path73.resolve(checkoutPath);
50148
50307
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
50149
50308
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
50150
50309
  checkoutPath: resolvedCheckoutPath,
@@ -50198,7 +50357,7 @@ async function applySessionWipToPreviewCheckouts(options) {
50198
50357
  }
50199
50358
 
50200
50359
  // src/worktrees/deploy/collect-session-repo-deploy-states.ts
50201
- import * as path72 from "node:path";
50360
+ import * as path74 from "node:path";
50202
50361
 
50203
50362
  // src/git/branches/create-or-update-branch.ts
50204
50363
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -50235,19 +50394,19 @@ async function collectSessionRepoDeployStates(options) {
50235
50394
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
50236
50395
  const states = [];
50237
50396
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
50238
- const checkoutPath = path72.resolve(sessionCheckout);
50397
+ const checkoutPath = path74.resolve(sessionCheckout);
50239
50398
  if (!await isGitRepoDirectory(checkoutPath)) return;
50240
50399
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
50241
50400
  checkoutPath,
50242
50401
  bridgeRoot,
50243
- sessionParentPath: sessionParentPath ? path72.resolve(sessionParentPath) : null
50402
+ sessionParentPath: sessionParentPath ? path74.resolve(sessionParentPath) : null
50244
50403
  });
50245
50404
  if (!repoPathRelativeToWorkspaceRoot) return;
50246
50405
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
50247
50406
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
50248
50407
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
50249
50408
  checkoutPaths: previewCheckoutPaths,
50250
- sessionParentPath: previewParentPath ? path72.resolve(previewParentPath) : null,
50409
+ sessionParentPath: previewParentPath ? path74.resolve(previewParentPath) : null,
50251
50410
  bridgeRoot,
50252
50411
  repoPathRelativeToWorkspaceRoot
50253
50412
  }) : null;
@@ -50267,7 +50426,7 @@ async function deploySessionToPreviewEnvironment(options) {
50267
50426
  const eid = options.environmentId.trim();
50268
50427
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
50269
50428
  const deployBranch = previewDeployBranchName(eid);
50270
- const bridgeRoot = path73.resolve(getBridgeRoot());
50429
+ const bridgeRoot = path75.resolve(getBridgeRoot());
50271
50430
  await previewWorktreeManager.ensureCached(eid);
50272
50431
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
50273
50432
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -50307,10 +50466,10 @@ async function deploySessionToPreviewEnvironment(options) {
50307
50466
  }
50308
50467
 
50309
50468
  // src/worktrees/manager/default-worktrees-root-path.ts
50310
- import * as path74 from "node:path";
50311
- import os9 from "node:os";
50469
+ import * as path76 from "node:path";
50470
+ import os10 from "node:os";
50312
50471
  function defaultWorktreesRootPath() {
50313
- return path74.join(os9.homedir(), ".buildautomaton", "worktrees");
50472
+ return path76.join(os10.homedir(), ".buildautomaton", "worktrees");
50314
50473
  }
50315
50474
 
50316
50475
  // src/connection/create-bridge-worktree-managers.ts
@@ -50440,14 +50599,14 @@ function assertBridgeWorkspace(ctx) {
50440
50599
  }
50441
50600
 
50442
50601
  // src/files/list-dir/index.ts
50443
- import fs51 from "node:fs";
50602
+ import fs53 from "node:fs";
50444
50603
 
50445
50604
  // src/files/ensure-under-cwd.ts
50446
- import path75 from "node:path";
50605
+ import path77 from "node:path";
50447
50606
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
50448
- const normalized = path75.normalize(relativePath).replace(/^(\.\/)+/, "");
50449
- const resolved = path75.resolve(cwd, normalized);
50450
- if (!resolved.startsWith(cwd + path75.sep) && resolved !== cwd) {
50607
+ const normalized = path77.normalize(relativePath).replace(/^(\.\/)+/, "");
50608
+ const resolved = path77.resolve(cwd, normalized);
50609
+ if (!resolved.startsWith(cwd + path77.sep) && resolved !== cwd) {
50451
50610
  return null;
50452
50611
  }
50453
50612
  return resolved;
@@ -50460,15 +50619,15 @@ init_yield_to_event_loop();
50460
50619
  var LIST_DIR_YIELD_EVERY = 256;
50461
50620
 
50462
50621
  // src/files/list-dir/map-dir-entry.ts
50463
- import path76 from "node:path";
50464
- import fs50 from "node:fs";
50622
+ import path78 from "node:path";
50623
+ import fs52 from "node:fs";
50465
50624
  async function mapDirEntry(d, relativePath, resolved) {
50466
- const entryPath = path76.join(relativePath || ".", d.name).replace(/\\/g, "/");
50467
- const fullPath = path76.join(resolved, d.name);
50625
+ const entryPath = path78.join(relativePath || ".", d.name).replace(/\\/g, "/");
50626
+ const fullPath = path78.join(resolved, d.name);
50468
50627
  let isDir = d.isDirectory();
50469
50628
  if (d.isSymbolicLink()) {
50470
50629
  try {
50471
- const targetStat = await fs50.promises.stat(fullPath);
50630
+ const targetStat = await fs52.promises.stat(fullPath);
50472
50631
  isDir = targetStat.isDirectory();
50473
50632
  } catch {
50474
50633
  isDir = false;
@@ -50498,7 +50657,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
50498
50657
  return { error: "Path is outside working directory" };
50499
50658
  }
50500
50659
  try {
50501
- const names = await fs51.promises.readdir(resolved, { withFileTypes: true });
50660
+ const names = await fs53.promises.readdir(resolved, { withFileTypes: true });
50502
50661
  const entries = [];
50503
50662
  for (let i = 0; i < names.length; i++) {
50504
50663
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -50514,13 +50673,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
50514
50673
  }
50515
50674
 
50516
50675
  // src/git/tree/resolve-repo-abs-path.ts
50517
- import * as path77 from "node:path";
50676
+ import * as path79 from "node:path";
50518
50677
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
50519
- const bridgeResolved = path77.resolve(bridgeRoot);
50678
+ const bridgeResolved = path79.resolve(bridgeRoot);
50520
50679
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
50521
- const repoPath = rel === "" ? bridgeResolved : path77.join(bridgeResolved, rel);
50522
- const resolved = path77.resolve(repoPath);
50523
- if (!resolved.startsWith(bridgeResolved + path77.sep) && resolved !== bridgeResolved) {
50680
+ const repoPath = rel === "" ? bridgeResolved : path79.join(bridgeResolved, rel);
50681
+ const resolved = path79.resolve(repoPath);
50682
+ if (!resolved.startsWith(bridgeResolved + path79.sep) && resolved !== bridgeResolved) {
50524
50683
  return null;
50525
50684
  }
50526
50685
  return resolved;
@@ -51001,25 +51160,25 @@ async function GET2(ctx) {
51001
51160
  init_in_flight();
51002
51161
 
51003
51162
  // src/files/read/read-file-async.ts
51004
- import fs57 from "node:fs";
51163
+ import fs59 from "node:fs";
51005
51164
  init_yield_to_event_loop();
51006
51165
 
51007
51166
  // src/files/read/resolve-file-cache.ts
51008
- import fs52 from "node:fs";
51009
- import path78 from "node:path";
51167
+ import fs54 from "node:fs";
51168
+ import path80 from "node:path";
51010
51169
  var RESOLVE_CACHE_MAX = 4096;
51011
51170
  var resolveCache = /* @__PURE__ */ new Map();
51012
51171
  function resolveCacheKey(sessionParentPath, relativePath) {
51013
51172
  return `${sessionParentPath}\0${relativePath}`;
51014
51173
  }
51015
51174
  function pathStaysUnderParent(filePath, sessionParentPath) {
51016
- const parent = path78.resolve(sessionParentPath);
51017
- const resolved = path78.resolve(filePath);
51018
- return resolved === parent || resolved.startsWith(`${parent}${path78.sep}`);
51175
+ const parent = path80.resolve(sessionParentPath);
51176
+ const resolved = path80.resolve(filePath);
51177
+ return resolved === parent || resolved.startsWith(`${parent}${path80.sep}`);
51019
51178
  }
51020
51179
  function statMatchesCacheSync(entry) {
51021
51180
  try {
51022
- const stat2 = fs52.statSync(entry.path);
51181
+ const stat2 = fs54.statSync(entry.path);
51023
51182
  return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
51024
51183
  } catch {
51025
51184
  return false;
@@ -51052,7 +51211,7 @@ function joinInflightResolve(cacheKey, factory) {
51052
51211
  }
51053
51212
 
51054
51213
  // src/files/read/resolve-file-for-read-core.ts
51055
- import fs53 from "node:fs";
51214
+ import fs55 from "node:fs";
51056
51215
  import { isMainThread as isMainThread4 } from "node:worker_threads";
51057
51216
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
51058
51217
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -51062,13 +51221,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
51062
51221
  let size;
51063
51222
  let mtimeMs;
51064
51223
  try {
51065
- const lstat = fs53.lstatSync(resolved);
51224
+ const lstat = fs55.lstatSync(resolved);
51066
51225
  if (lstat.isSymbolicLink()) {
51067
- real = fs53.realpathSync(resolved);
51226
+ real = fs55.realpathSync(resolved);
51068
51227
  if (!pathStaysUnderParent(real, sessionParentPath)) {
51069
51228
  return { error: "Path is outside working directory" };
51070
51229
  }
51071
- const stat2 = fs53.statSync(real);
51230
+ const stat2 = fs55.statSync(real);
51072
51231
  if (!stat2.isFile()) return { error: "Not a file" };
51073
51232
  size = stat2.size;
51074
51233
  mtimeMs = stat2.mtimeMs;
@@ -51096,13 +51255,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
51096
51255
  let size;
51097
51256
  let mtimeMs;
51098
51257
  try {
51099
- const lstat = await fs53.promises.lstat(resolved);
51258
+ const lstat = await fs55.promises.lstat(resolved);
51100
51259
  if (lstat.isSymbolicLink()) {
51101
- real = await fs53.promises.realpath(resolved);
51260
+ real = await fs55.promises.realpath(resolved);
51102
51261
  if (!pathStaysUnderParent(real, sessionParentPath)) {
51103
51262
  return { error: "Path is outside working directory" };
51104
51263
  }
51105
- const stat2 = await fs53.promises.stat(real);
51264
+ const stat2 = await fs55.promises.stat(real);
51106
51265
  if (!stat2.isFile()) return { error: "Not a file" };
51107
51266
  size = stat2.size;
51108
51267
  mtimeMs = stat2.mtimeMs;
@@ -51151,7 +51310,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
51151
51310
 
51152
51311
  // src/files/read/read-file-range-async.ts
51153
51312
  init_yield_to_event_loop();
51154
- import fs54 from "node:fs";
51313
+ import fs56 from "node:fs";
51155
51314
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
51156
51315
 
51157
51316
  // src/files/read/read-file-range-line-zero.ts
@@ -51265,8 +51424,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
51265
51424
 
51266
51425
  // src/files/read/read-file-range-async.ts
51267
51426
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
51268
- const fileSize = fileSizeIn ?? (await fs54.promises.stat(filePath)).size;
51269
- const fd = await fs54.promises.open(filePath, "r");
51427
+ const fileSize = fileSizeIn ?? (await fs56.promises.stat(filePath)).size;
51428
+ const fd = await fs56.promises.open(filePath, "r");
51270
51429
  const bufSize = 64 * 1024;
51271
51430
  const buf = Buffer.alloc(bufSize);
51272
51431
  const decoder = new StringDecoder2("utf8");
@@ -51367,7 +51526,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
51367
51526
  }
51368
51527
 
51369
51528
  // src/files/read/read-small-file-range-async.ts
51370
- import fs55 from "node:fs";
51529
+ import fs57 from "node:fs";
51371
51530
  import { isMainThread as isMainThread5 } from "node:worker_threads";
51372
51531
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
51373
51532
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -51397,7 +51556,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
51397
51556
  };
51398
51557
  }
51399
51558
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
51400
- const raw = fs55.readFileSync(filePath, "utf8");
51559
+ const raw = fs57.readFileSync(filePath, "utf8");
51401
51560
  const lines = raw.split(/\r?\n/);
51402
51561
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
51403
51562
  }
@@ -51405,28 +51564,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
51405
51564
  if (isMainThread5) {
51406
51565
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
51407
51566
  }
51408
- const raw = await fs55.promises.readFile(filePath, "utf8");
51567
+ const raw = await fs57.promises.readFile(filePath, "utf8");
51409
51568
  const lines = raw.split(/\r?\n/);
51410
51569
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
51411
51570
  }
51412
51571
 
51413
51572
  // src/files/read/read-file-buffer-full-async.ts
51414
51573
  init_yield_to_event_loop();
51415
- import fs56 from "node:fs";
51574
+ import fs58 from "node:fs";
51416
51575
  import { isMainThread as isMainThread6 } from "node:worker_threads";
51417
51576
  var READ_CHUNK_BYTES = 256 * 1024;
51418
51577
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
51419
51578
  async function readFileBufferFullAsync(filePath, knownSize) {
51420
51579
  if (isMainThread6) {
51421
- const size2 = knownSize ?? fs56.statSync(filePath).size;
51580
+ const size2 = knownSize ?? fs58.statSync(filePath).size;
51422
51581
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
51423
51582
  await yieldToEventLoop();
51424
- const buffer = fs56.readFileSync(filePath);
51583
+ const buffer = fs58.readFileSync(filePath);
51425
51584
  return { buffer, size: buffer.length };
51426
51585
  }
51427
51586
  }
51428
- const size = knownSize ?? (await fs56.promises.stat(filePath)).size;
51429
- const fd = await fs56.promises.open(filePath, "r");
51587
+ const size = knownSize ?? (await fs58.promises.stat(filePath)).size;
51588
+ const fd = await fs58.promises.open(filePath, "r");
51430
51589
  const chunks = [];
51431
51590
  let position = 0;
51432
51591
  let bytesSinceYield = 0;
@@ -51529,7 +51688,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
51529
51688
  }
51530
51689
  if (hasRange) {
51531
51690
  if (fileSize == null) {
51532
- const stat2 = await fs57.promises.stat(resolvedPath);
51691
+ const stat2 = await fs59.promises.stat(resolvedPath);
51533
51692
  fileSize = stat2.size;
51534
51693
  }
51535
51694
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -51827,12 +51986,12 @@ function parseOptionalInt2(raw) {
51827
51986
  return Number.isInteger(parsed) ? parsed : void 0;
51828
51987
  }
51829
51988
  function parseCodeNavParams(url2) {
51830
- const path86 = url2.searchParams.get("path") ?? "";
51989
+ const path88 = url2.searchParams.get("path") ?? "";
51831
51990
  const opRaw = url2.searchParams.get("op")?.trim();
51832
51991
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
51833
51992
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
51834
51993
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
51835
- return { path: path86, op, line, column };
51994
+ return { path: path88, op, line, column };
51836
51995
  }
51837
51996
  function parseCodeNavPath(url2) {
51838
51997
  const raw = url2.searchParams.get("path")?.trim();
@@ -52630,18 +52789,18 @@ function hasRunningTurn(turns) {
52630
52789
  }
52631
52790
 
52632
52791
  // src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
52633
- import fs60 from "node:fs";
52792
+ import fs62 from "node:fs";
52634
52793
 
52635
52794
  // src/git/snapshot/capture.ts
52636
- import * as fs59 from "node:fs";
52637
- import * as path80 from "node:path";
52795
+ import * as fs61 from "node:fs";
52796
+ import * as path82 from "node:path";
52638
52797
 
52639
52798
  // src/git/snapshot/apply-pre-turn-snapshot.ts
52640
- import * as fs58 from "node:fs";
52799
+ import * as fs60 from "node:fs";
52641
52800
  async function applyPreTurnSnapshot(filePath, log2) {
52642
52801
  let data;
52643
52802
  try {
52644
- data = JSON.parse(fs58.readFileSync(filePath, "utf8"));
52803
+ data = JSON.parse(fs60.readFileSync(filePath, "utf8"));
52645
52804
  } catch (error51) {
52646
52805
  return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
52647
52806
  }
@@ -52670,18 +52829,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
52670
52829
  }
52671
52830
 
52672
52831
  // src/git/snapshot/resolve-repo-roots.ts
52673
- import * as path79 from "node:path";
52832
+ import * as path81 from "node:path";
52674
52833
  async function resolveSnapshotRepoRoots(options) {
52675
52834
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
52676
52835
  if (worktreePaths?.length) {
52677
- const paths = [...new Set(worktreePaths.map((p) => path79.resolve(p)))];
52836
+ const paths = [...new Set(worktreePaths.map((p) => path81.resolve(p)))];
52678
52837
  return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
52679
52838
  }
52680
52839
  try {
52681
52840
  const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
52682
52841
  const sid = sessionId?.trim();
52683
52842
  if (!sid) return roots;
52684
- const sessionRoots = roots.filter((root) => path79.basename(root) === sid);
52843
+ const sessionRoots = roots.filter((root) => path81.basename(root) === sid);
52685
52844
  return sessionRoots.length > 0 ? sessionRoots : roots;
52686
52845
  } catch (error51) {
52687
52846
  log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -52703,7 +52862,7 @@ async function capturePreTurnSnapshot(options) {
52703
52862
  });
52704
52863
  const dir = snapshotsDirForCwd(agentCwd);
52705
52864
  try {
52706
- fs59.mkdirSync(dir, { recursive: true });
52865
+ fs61.mkdirSync(dir, { recursive: true });
52707
52866
  } catch (e) {
52708
52867
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
52709
52868
  }
@@ -52712,9 +52871,9 @@ async function capturePreTurnSnapshot(options) {
52712
52871
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
52713
52872
  repos
52714
52873
  };
52715
- const filePath = path80.join(dir, `${runId}.json`);
52874
+ const filePath = path82.join(dir, `${runId}.json`);
52716
52875
  try {
52717
- fs59.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
52876
+ fs61.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
52718
52877
  } catch (e) {
52719
52878
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
52720
52879
  }
@@ -52734,7 +52893,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
52734
52893
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
52735
52894
  const file2 = snapshotFilePath(agentBase, tid);
52736
52895
  try {
52737
- await fs60.promises.access(file2, fs60.constants.F_OK);
52896
+ await fs62.promises.access(file2, fs62.constants.F_OK);
52738
52897
  } catch {
52739
52898
  deps.log(
52740
52899
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -53385,6 +53544,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
53385
53544
  var handleSessionArchivedMessage = (msg, deps) => {
53386
53545
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
53387
53546
  if (!sessionId) return;
53547
+ cleanupSessionPlans(sessionId);
53388
53548
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
53389
53549
  };
53390
53550
 
@@ -53392,11 +53552,12 @@ var handleSessionArchivedMessage = (msg, deps) => {
53392
53552
  var handleSessionDiscardedMessage = (msg, deps) => {
53393
53553
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
53394
53554
  if (!sessionId) return;
53555
+ cleanupSessionPlans(sessionId);
53395
53556
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
53396
53557
  };
53397
53558
 
53398
53559
  // src/routing/handlers/revert-turn-snapshot.ts
53399
- import * as fs61 from "node:fs";
53560
+ import * as fs63 from "node:fs";
53400
53561
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
53401
53562
  const id = typeof msg.id === "string" ? msg.id : "";
53402
53563
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -53409,7 +53570,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
53409
53570
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
53410
53571
  const file2 = snapshotFilePath(agentBase, turnId);
53411
53572
  try {
53412
- await fs61.promises.access(file2, fs61.constants.F_OK);
53573
+ await fs63.promises.access(file2, fs63.constants.F_OK);
53413
53574
  } catch {
53414
53575
  sendWsMessage(s, {
53415
53576
  type: "revert_turn_snapshot_result",
@@ -53507,8 +53668,8 @@ function isValidRemoteSkillInstallItem(item) {
53507
53668
 
53508
53669
  // src/skills/install/install-remote-skills-async.ts
53509
53670
  init_yield_to_event_loop();
53510
- import fs62 from "node:fs";
53511
- import path81 from "node:path";
53671
+ import fs64 from "node:fs";
53672
+ import path83 from "node:path";
53512
53673
 
53513
53674
  // src/skills/install/constants.ts
53514
53675
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -53519,12 +53680,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
53519
53680
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
53520
53681
  await yieldToEventLoop();
53521
53682
  }
53522
- const dest = path81.join(skillDir, f.path);
53523
- await fs62.promises.mkdir(path81.dirname(dest), { recursive: true });
53683
+ const dest = path83.join(skillDir, f.path);
53684
+ await fs64.promises.mkdir(path83.dirname(dest), { recursive: true });
53524
53685
  if (f.text !== void 0) {
53525
- await fs62.promises.writeFile(dest, f.text, "utf8");
53686
+ await fs64.promises.writeFile(dest, f.text, "utf8");
53526
53687
  } else if (f.base64) {
53527
- await fs62.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
53688
+ await fs64.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
53528
53689
  }
53529
53690
  }
53530
53691
  async function installRemoteSkillsAsync(cwd, targetDir, items) {
@@ -53536,7 +53697,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
53536
53697
  try {
53537
53698
  for (const item of items) {
53538
53699
  if (!isValidRemoteSkillInstallItem(item)) continue;
53539
- const skillDir = path81.join(cwd, targetDir, item.skillName);
53700
+ const skillDir = path83.join(cwd, targetDir, item.skillName);
53540
53701
  for (const f of item.files) {
53541
53702
  await writeInstallFileAsync(skillDir, f, filesWritten);
53542
53703
  }
@@ -53899,13 +54060,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
53899
54060
 
53900
54061
  // src/files/handle-file-browser-search.ts
53901
54062
  init_yield_to_event_loop();
53902
- import path82 from "node:path";
54063
+ import path84 from "node:path";
53903
54064
  var SEARCH_LIMIT = 100;
53904
54065
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
53905
54066
  void (async () => {
53906
54067
  await yieldToEventLoop();
53907
54068
  const q = typeof msg.q === "string" ? msg.q : "";
53908
- const sessionParentPath = path82.resolve(
54069
+ const sessionParentPath = path84.resolve(
53909
54070
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
53910
54071
  );
53911
54072
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -54003,7 +54164,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
54003
54164
  }
54004
54165
 
54005
54166
  // src/git/bridge-git-context.ts
54006
- import * as path83 from "node:path";
54167
+ import * as path85 from "node:path";
54007
54168
  init_yield_to_event_loop();
54008
54169
 
54009
54170
  // src/git/branches/get-current-branch.ts
@@ -54071,12 +54232,12 @@ function listPendingCheckouts() {
54071
54232
  // src/git/bridge-git-context.ts
54072
54233
  function folderNameForRelPath(relPath, bridgeRoot) {
54073
54234
  if (relPath === "." || relPath === "") {
54074
- return path83.basename(path83.resolve(bridgeRoot)) || "repo";
54235
+ return path85.basename(path85.resolve(bridgeRoot)) || "repo";
54075
54236
  }
54076
- return path83.basename(relPath) || relPath;
54237
+ return path85.basename(relPath) || relPath;
54077
54238
  }
54078
54239
  async function discoverGitReposForBridgeContext(bridgeRoot) {
54079
- const root = path83.resolve(bridgeRoot);
54240
+ const root = path85.resolve(bridgeRoot);
54080
54241
  if (await isGitRepoDirectory(root)) {
54081
54242
  const remoteUrl = await getRemoteOriginUrl(root);
54082
54243
  return [{ absolutePath: root, remoteUrl }];
@@ -54084,19 +54245,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
54084
54245
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
54085
54246
  const byPath = /* @__PURE__ */ new Map();
54086
54247
  for (const repo of [...deep, ...shallow]) {
54087
- byPath.set(path83.resolve(repo.absolutePath), repo);
54248
+ byPath.set(path85.resolve(repo.absolutePath), repo);
54088
54249
  }
54089
54250
  return [...byPath.values()];
54090
54251
  }
54091
54252
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
54092
- const bridgeResolved = path83.resolve(bridgeRoot);
54253
+ const bridgeResolved = path85.resolve(bridgeRoot);
54093
54254
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
54094
54255
  const rows = [];
54095
54256
  for (let i = 0; i < repos.length; i++) {
54096
54257
  if (i > 0) await yieldToEventLoop();
54097
54258
  const repo = repos[i];
54098
- let rel = path83.relative(bridgeResolved, repo.absolutePath);
54099
- if (rel.startsWith("..") || path83.isAbsolute(rel)) continue;
54259
+ let rel = path85.relative(bridgeResolved, repo.absolutePath);
54260
+ if (rel.startsWith("..") || path85.isAbsolute(rel)) continue;
54100
54261
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
54101
54262
  const currentBranch = await getCurrentBranch(repo.absolutePath);
54102
54263
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -54127,11 +54288,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
54127
54288
  return rows;
54128
54289
  }
54129
54290
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
54130
- const bridgeResolved = path83.resolve(bridgeRoot);
54291
+ const bridgeResolved = path85.resolve(bridgeRoot);
54131
54292
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
54132
- const repoPath = rel === "" ? bridgeResolved : path83.join(bridgeResolved, rel);
54133
- const resolved = path83.resolve(repoPath);
54134
- if (!resolved.startsWith(bridgeResolved + path83.sep) && resolved !== bridgeResolved) {
54293
+ const repoPath = rel === "" ? bridgeResolved : path85.join(bridgeResolved, rel);
54294
+ const resolved = path85.resolve(repoPath);
54295
+ if (!resolved.startsWith(bridgeResolved + path85.sep) && resolved !== bridgeResolved) {
54135
54296
  return [];
54136
54297
  }
54137
54298
  return listRepoBranchRefs(resolved);
@@ -54181,8 +54342,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
54181
54342
  }
54182
54343
 
54183
54344
  // src/git/checkout/bridge-git-checkout.ts
54184
- import * as fs64 from "node:fs/promises";
54185
- import * as path85 from "node:path";
54345
+ import * as fs66 from "node:fs/promises";
54346
+ import * as path87 from "node:path";
54186
54347
 
54187
54348
  // src/git/checkout/normalize-clone-url.ts
54188
54349
  function normalizeCloneUrl(url2) {
@@ -54202,12 +54363,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
54202
54363
  }
54203
54364
 
54204
54365
  // src/git/checkout/resolve-checkout-target.ts
54205
- import * as fs63 from "node:fs/promises";
54206
- import * as path84 from "node:path";
54366
+ import * as fs65 from "node:fs/promises";
54367
+ import * as path86 from "node:path";
54207
54368
  var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
54208
54369
  async function pathExists(p) {
54209
54370
  try {
54210
- await fs63.access(p);
54371
+ await fs65.access(p);
54211
54372
  return true;
54212
54373
  } catch {
54213
54374
  return false;
@@ -54219,7 +54380,7 @@ async function resolveCheckoutTarget(opts) {
54219
54380
  if (await isGitRepoDirectory(bridgeRoot)) {
54220
54381
  throw new Error("Bridge root is already a git repository");
54221
54382
  }
54222
- const entries = await fs63.readdir(bridgeRoot).catch(() => []);
54383
+ const entries = await fs65.readdir(bridgeRoot).catch(() => []);
54223
54384
  if (entries.length > 0) {
54224
54385
  throw new Error("Bridge root must be empty to initialize a monorepo checkout");
54225
54386
  }
@@ -54232,8 +54393,8 @@ async function resolveCheckoutTarget(opts) {
54232
54393
  if (await isGitRepoDirectory(bridgeRoot)) {
54233
54394
  throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
54234
54395
  }
54235
- const targetDir = path84.resolve(bridgeRoot, folder);
54236
- if (!targetDir.startsWith(bridgeRoot + path84.sep)) {
54396
+ const targetDir = path86.resolve(bridgeRoot, folder);
54397
+ if (!targetDir.startsWith(bridgeRoot + path86.sep)) {
54237
54398
  throw new Error("Invalid folderName");
54238
54399
  }
54239
54400
  if (await pathExists(targetDir)) {
@@ -54252,10 +54413,10 @@ async function bridgeGitCheckout(params) {
54252
54413
  });
54253
54414
  const folderName = relPath === "." ? "repo" : relPath;
54254
54415
  beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
54255
- const parent = path85.dirname(targetDir);
54256
- await fs64.mkdir(parent, { recursive: true });
54416
+ const parent = path87.dirname(targetDir);
54417
+ await fs66.mkdir(parent, { recursive: true });
54257
54418
  if (relPath !== ".") {
54258
- await fs64.mkdir(targetDir, { recursive: true });
54419
+ await fs66.mkdir(targetDir, { recursive: true });
54259
54420
  }
54260
54421
  const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
54261
54422
  try {
@@ -54266,7 +54427,7 @@ async function bridgeGitCheckout(params) {
54266
54427
  return { relPath, folderName };
54267
54428
  } catch (e) {
54268
54429
  if (relPath !== ".") {
54269
- await fs64.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
54430
+ await fs66.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
54270
54431
  }
54271
54432
  const msg = e instanceof Error ? e.message : String(e);
54272
54433
  throw new Error(