@buildautomaton/cli 0.1.0 → 0.1.1

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
@@ -4065,8 +4065,8 @@ var init_parseUtil = __esm({
4065
4065
  init_errors();
4066
4066
  init_en();
4067
4067
  makeIssue = (params) => {
4068
- const { data, path: path22, errorMaps, issueData } = params;
4069
- const fullPath = [...path22, ...issueData.path || []];
4068
+ const { data, path: path23, errorMaps, issueData } = params;
4069
+ const fullPath = [...path23, ...issueData.path || []];
4070
4070
  const fullIssue = {
4071
4071
  ...issueData,
4072
4072
  path: fullPath
@@ -4374,11 +4374,11 @@ var init_types = __esm({
4374
4374
  init_parseUtil();
4375
4375
  init_util();
4376
4376
  ParseInputLazyPath = class {
4377
- constructor(parent, value, path22, key) {
4377
+ constructor(parent, value, path23, key) {
4378
4378
  this._cachedPath = [];
4379
4379
  this.parent = parent;
4380
4380
  this.data = value;
4381
- this._path = path22;
4381
+ this._path = path23;
4382
4382
  this._key = key;
4383
4383
  }
4384
4384
  get path() {
@@ -7993,10 +7993,10 @@ function assignProp(target, prop, value) {
7993
7993
  configurable: true
7994
7994
  });
7995
7995
  }
7996
- function getElementAtPath(obj, path22) {
7997
- if (!path22)
7996
+ function getElementAtPath(obj, path23) {
7997
+ if (!path23)
7998
7998
  return obj;
7999
- return path22.reduce((acc, key) => acc?.[key], obj);
7999
+ return path23.reduce((acc, key) => acc?.[key], obj);
8000
8000
  }
8001
8001
  function promiseAllObject(promisesObj) {
8002
8002
  const keys = Object.keys(promisesObj);
@@ -8245,11 +8245,11 @@ function aborted(x, startIndex = 0) {
8245
8245
  }
8246
8246
  return false;
8247
8247
  }
8248
- function prefixIssues(path22, issues) {
8248
+ function prefixIssues(path23, issues) {
8249
8249
  return issues.map((iss) => {
8250
8250
  var _a2;
8251
8251
  (_a2 = iss).path ?? (_a2.path = []);
8252
- iss.path.unshift(path22);
8252
+ iss.path.unshift(path23);
8253
8253
  return iss;
8254
8254
  });
8255
8255
  }
@@ -8438,7 +8438,7 @@ function treeifyError(error40, _mapper) {
8438
8438
  return issue2.message;
8439
8439
  };
8440
8440
  const result = { errors: [] };
8441
- const processError = (error41, path22 = []) => {
8441
+ const processError = (error41, path23 = []) => {
8442
8442
  var _a2, _b;
8443
8443
  for (const issue2 of error41.issues) {
8444
8444
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -8448,7 +8448,7 @@ function treeifyError(error40, _mapper) {
8448
8448
  } else if (issue2.code === "invalid_element") {
8449
8449
  processError({ issues: issue2.issues }, issue2.path);
8450
8450
  } else {
8451
- const fullpath = [...path22, ...issue2.path];
8451
+ const fullpath = [...path23, ...issue2.path];
8452
8452
  if (fullpath.length === 0) {
8453
8453
  result.errors.push(mapper(issue2));
8454
8454
  continue;
@@ -8478,9 +8478,9 @@ function treeifyError(error40, _mapper) {
8478
8478
  processError(error40);
8479
8479
  return result;
8480
8480
  }
8481
- function toDotPath(path22) {
8481
+ function toDotPath(path23) {
8482
8482
  const segs = [];
8483
- for (const seg of path22) {
8483
+ for (const seg of path23) {
8484
8484
  if (typeof seg === "number")
8485
8485
  segs.push(`[${seg}]`);
8486
8486
  else if (typeof seg === "symbol")
@@ -21963,10 +21963,10 @@ var require_src2 = __commonJS({
21963
21963
  var fs_1 = __require("fs");
21964
21964
  var debug_1 = __importDefault(require_src());
21965
21965
  var log2 = debug_1.default("@kwsites/file-exists");
21966
- function check2(path22, isFile, isDirectory) {
21967
- log2(`checking %s`, path22);
21966
+ function check2(path23, isFile, isDirectory) {
21967
+ log2(`checking %s`, path23);
21968
21968
  try {
21969
- const stat4 = fs_1.statSync(path22);
21969
+ const stat4 = fs_1.statSync(path23);
21970
21970
  if (stat4.isFile() && isFile) {
21971
21971
  log2(`[OK] path represents a file`);
21972
21972
  return true;
@@ -21986,8 +21986,8 @@ var require_src2 = __commonJS({
21986
21986
  throw e;
21987
21987
  }
21988
21988
  }
21989
- function exists2(path22, type = exports.READABLE) {
21990
- return check2(path22, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
21989
+ function exists2(path23, type = exports.READABLE) {
21990
+ return check2(path23, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
21991
21991
  }
21992
21992
  exports.exists = exists2;
21993
21993
  exports.FILE = 1;
@@ -22114,24 +22114,48 @@ function sendWsMessage(ws, payload) {
22114
22114
 
22115
22115
  // src/acp/clients/acp-client.ts
22116
22116
  import { spawn } from "node:child_process";
22117
+ import path from "node:path";
22117
22118
  import { Readable, Writable } from "node:stream";
22119
+
22120
+ // src/acp/format-acp-rpc-error.ts
22121
+ function formatAcpRpcError(err) {
22122
+ if (err instanceof Error) return err.message;
22123
+ if (err != null && typeof err === "object") {
22124
+ const o = err;
22125
+ if (typeof o.message === "string") {
22126
+ const code = typeof o.code === "number" ? ` (code ${o.code})` : "";
22127
+ return `${o.message}${code}`;
22128
+ }
22129
+ }
22130
+ if (typeof err === "string") return err;
22131
+ try {
22132
+ return JSON.stringify(err);
22133
+ } catch {
22134
+ return String(err);
22135
+ }
22136
+ }
22137
+ function isAcpAuthenticationRequiredError(err) {
22138
+ if (err == null || typeof err !== "object") return false;
22139
+ const o = err;
22140
+ if (o.code === -32e3 && typeof o.message === "string") {
22141
+ const m2 = o.message.toLowerCase();
22142
+ if (m2.includes("authentication") || m2.includes("auth")) return true;
22143
+ }
22144
+ const m = typeof o.message === "string" ? o.message.toLowerCase() : "";
22145
+ return m.includes("authentication required") || m.includes("auth_required");
22146
+ }
22147
+
22148
+ // src/acp/clients/acp-client.ts
22118
22149
  function formatSpawnError(err, command) {
22119
22150
  if (err.code === "ENOENT") {
22120
22151
  return `Command "${command}" not found. Install the agent (e.g. Cursor CLI) or add it to PATH.`;
22121
22152
  }
22122
22153
  return err.message || String(err);
22123
22154
  }
22124
- function toErrorMessage(err) {
22125
- if (err instanceof Error) return err.message;
22126
- if (err != null && typeof err === "object" && "message" in err)
22127
- return String(err.message);
22128
- if (typeof err === "string") return err;
22129
- if (err != null && typeof err === "object") return JSON.stringify(err);
22130
- return String(err);
22131
- }
22132
22155
  async function createAcpClient(options) {
22133
- const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
22156
+ const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
22134
22157
  const { command, cwd: cwd3 = process.cwd(), onSessionUpdate } = options;
22158
+ const sessionCwd = path.resolve(cwd3);
22135
22159
  const isWindows2 = process.platform === "win32";
22136
22160
  const child = spawn(command[0], command.slice(1), {
22137
22161
  cwd: cwd3,
@@ -22162,11 +22186,13 @@ async function createAcpClient(options) {
22162
22186
  child.kill();
22163
22187
  });
22164
22188
  await connection.initialize({
22165
- protocolVersion: "0.1.0",
22166
- capabilities: {},
22189
+ protocolVersion: PROTOCOL_VERSION2,
22167
22190
  clientInfo: { name: "buildautomaton-cli", version: "0.1.0" }
22168
22191
  });
22169
- const newSessionRes = await connection.newSession({ workingDirectory: cwd3 });
22192
+ const newSessionRes = await connection.newSession({
22193
+ cwd: sessionCwd,
22194
+ mcpServers: []
22195
+ });
22170
22196
  const sessionId = newSessionRes.sessionId;
22171
22197
  resolve16({
22172
22198
  sessionId,
@@ -22174,7 +22200,7 @@ async function createAcpClient(options) {
22174
22200
  try {
22175
22201
  const response = await connection.prompt({
22176
22202
  sessionId,
22177
- prompt: { type: "text", text: prompt }
22203
+ prompt: [{ type: "text", text: prompt }]
22178
22204
  });
22179
22205
  const r = response;
22180
22206
  const cancelled = (r?.stopReason ?? "").toLowerCase() === "cancelled";
@@ -22187,7 +22213,8 @@ async function createAcpClient(options) {
22187
22213
  } catch (err) {
22188
22214
  return {
22189
22215
  success: false,
22190
- error: err instanceof Error ? err.message : String(err)
22216
+ error: formatAcpRpcError(err),
22217
+ ...isAcpAuthenticationRequiredError(err) ? { authRequired: true } : {}
22191
22218
  };
22192
22219
  }
22193
22220
  },
@@ -22205,7 +22232,7 @@ async function createAcpClient(options) {
22205
22232
  });
22206
22233
  } catch (err) {
22207
22234
  child.kill();
22208
- reject(new Error(toErrorMessage(err)));
22235
+ reject(new Error(formatAcpRpcError(err)));
22209
22236
  }
22210
22237
  })();
22211
22238
  });
@@ -22339,8 +22366,8 @@ function randomSecret() {
22339
22366
  }
22340
22367
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
22341
22368
  }
22342
- async function requestPreviewApi(port, secret, method, path22, body) {
22343
- const url2 = `http://127.0.0.1:${port}${path22}`;
22369
+ async function requestPreviewApi(port, secret, method, path23, body) {
22370
+ const url2 = `http://127.0.0.1:${port}${path23}`;
22344
22371
  const headers = {
22345
22372
  [PREVIEW_SECRET_HEADER]: secret,
22346
22373
  "Content-Type": "application/json"
@@ -22352,7 +22379,7 @@ async function requestPreviewApi(port, secret, method, path22, body) {
22352
22379
  });
22353
22380
  const data = await res.json().catch(() => ({}));
22354
22381
  if (!res.ok) {
22355
- throw new Error(data?.error ?? `Preview API ${method} ${path22}: ${res.status}`);
22382
+ throw new Error(data?.error ?? `Preview API ${method} ${path23}: ${res.status}`);
22356
22383
  }
22357
22384
  return data;
22358
22385
  }
@@ -22503,11 +22530,11 @@ function log(line) {
22503
22530
 
22504
22531
  // src/config.ts
22505
22532
  import fs from "node:fs";
22506
- import path from "node:path";
22533
+ import path2 from "node:path";
22507
22534
  import os from "node:os";
22508
22535
  function getConfigPath() {
22509
- const dir = path.join(os.homedir(), ".buildautomaton");
22510
- return path.join(dir, "config.json");
22536
+ const dir = path2.join(os.homedir(), ".buildautomaton");
22537
+ return path2.join(dir, "config.json");
22511
22538
  }
22512
22539
  function normalizeApiUrl(url2) {
22513
22540
  return url2.replace(/\/$/, "");
@@ -22523,7 +22550,7 @@ function readRawConfig() {
22523
22550
  }
22524
22551
  function writeConfigForApi(apiUrl, auth) {
22525
22552
  const p = getConfigPath();
22526
- const dir = path.dirname(p);
22553
+ const dir = path2.dirname(p);
22527
22554
  const key = normalizeApiUrl(apiUrl);
22528
22555
  const prev = readRawConfig() ?? {};
22529
22556
  const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
@@ -22715,13 +22742,13 @@ function runPendingAuth(options) {
22715
22742
 
22716
22743
  // src/skills/discover-local-agent-skills.ts
22717
22744
  import fs2 from "node:fs";
22718
- import path2 from "node:path";
22745
+ import path3 from "node:path";
22719
22746
  var SKILL_DISCOVERY_ROOTS = [".agents/skills", ".claude/skills", ".cursor/skills", "skills"];
22720
22747
  function discoverLocalSkills(cwd3) {
22721
22748
  const out = [];
22722
22749
  const seenKeys = /* @__PURE__ */ new Set();
22723
22750
  for (const rel of SKILL_DISCOVERY_ROOTS) {
22724
- const base = path2.join(cwd3, rel);
22751
+ const base = path3.join(cwd3, rel);
22725
22752
  if (!fs2.existsSync(base) || !fs2.statSync(base).isDirectory()) continue;
22726
22753
  let entries = [];
22727
22754
  try {
@@ -22730,13 +22757,13 @@ function discoverLocalSkills(cwd3) {
22730
22757
  continue;
22731
22758
  }
22732
22759
  for (const name of entries) {
22733
- const dir = path2.join(base, name);
22760
+ const dir = path3.join(base, name);
22734
22761
  try {
22735
22762
  if (!fs2.statSync(dir).isDirectory()) continue;
22736
22763
  } catch {
22737
22764
  continue;
22738
22765
  }
22739
- const skillMd = path2.join(dir, "SKILL.md");
22766
+ const skillMd = path3.join(dir, "SKILL.md");
22740
22767
  if (!fs2.existsSync(skillMd)) continue;
22741
22768
  const key = `${rel}/${name}`;
22742
22769
  if (seenKeys.has(key)) continue;
@@ -22749,7 +22776,7 @@ function discoverLocalSkills(cwd3) {
22749
22776
  function discoverSkillLayoutRoots(cwd3) {
22750
22777
  const roots = [];
22751
22778
  for (const rel of SKILL_DISCOVERY_ROOTS) {
22752
- const base = path2.join(cwd3, rel);
22779
+ const base = path3.join(cwd3, rel);
22753
22780
  if (!fs2.existsSync(base) || !fs2.statSync(base).isDirectory()) continue;
22754
22781
  let entries = [];
22755
22782
  try {
@@ -22759,13 +22786,13 @@ function discoverSkillLayoutRoots(cwd3) {
22759
22786
  }
22760
22787
  const skills2 = [];
22761
22788
  for (const name of entries) {
22762
- const dir = path2.join(base, name);
22789
+ const dir = path3.join(base, name);
22763
22790
  try {
22764
22791
  if (!fs2.statSync(dir).isDirectory()) continue;
22765
22792
  } catch {
22766
22793
  continue;
22767
22794
  }
22768
- if (!fs2.existsSync(path2.join(dir, "SKILL.md"))) continue;
22795
+ if (!fs2.existsSync(path3.join(dir, "SKILL.md"))) continue;
22769
22796
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
22770
22797
  skills2.push({ name, relPath });
22771
22798
  }
@@ -22785,7 +22812,7 @@ function buildBridgeUrl(apiUrl, workspaceId, authToken) {
22785
22812
 
22786
22813
  // src/git/discover-repos.ts
22787
22814
  import * as fs3 from "node:fs";
22788
- import * as path3 from "node:path";
22815
+ import * as path4 from "node:path";
22789
22816
 
22790
22817
  // ../../node_modules/.pnpm/simple-git@3.32.3/node_modules/simple-git/dist/esm/index.js
22791
22818
  var import_file_exists = __toESM(require_dist(), 1);
@@ -22824,8 +22851,8 @@ function pathspec(...paths) {
22824
22851
  cache.set(key, paths);
22825
22852
  return key;
22826
22853
  }
22827
- function isPathSpec(path22) {
22828
- return path22 instanceof String && cache.has(path22);
22854
+ function isPathSpec(path23) {
22855
+ return path23 instanceof String && cache.has(path23);
22829
22856
  }
22830
22857
  function toPaths(pathSpec) {
22831
22858
  return cache.get(pathSpec) || [];
@@ -22914,8 +22941,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
22914
22941
  function forEachLineWithContent(input, callback) {
22915
22942
  return toLinesWithContent(input, true).map((line) => callback(line));
22916
22943
  }
22917
- function folderExists(path22) {
22918
- return (0, import_file_exists.exists)(path22, import_file_exists.FOLDER);
22944
+ function folderExists(path23) {
22945
+ return (0, import_file_exists.exists)(path23, import_file_exists.FOLDER);
22919
22946
  }
22920
22947
  function append(target, item) {
22921
22948
  if (Array.isArray(target)) {
@@ -23319,8 +23346,8 @@ function checkIsRepoRootTask() {
23319
23346
  commands,
23320
23347
  format: "utf-8",
23321
23348
  onError,
23322
- parser(path22) {
23323
- return /^\.(git)?$/.test(path22.trim());
23349
+ parser(path23) {
23350
+ return /^\.(git)?$/.test(path23.trim());
23324
23351
  }
23325
23352
  };
23326
23353
  }
@@ -23754,11 +23781,11 @@ function parseGrep(grep) {
23754
23781
  const paths = /* @__PURE__ */ new Set();
23755
23782
  const results = {};
23756
23783
  forEachLineWithContent(grep, (input) => {
23757
- const [path22, line, preview] = input.split(NULL);
23758
- paths.add(path22);
23759
- (results[path22] = results[path22] || []).push({
23784
+ const [path23, line, preview] = input.split(NULL);
23785
+ paths.add(path23);
23786
+ (results[path23] = results[path23] || []).push({
23760
23787
  line: asNumber(line),
23761
- path: path22,
23788
+ path: path23,
23762
23789
  preview
23763
23790
  });
23764
23791
  });
@@ -24523,14 +24550,14 @@ var init_hash_object = __esm2({
24523
24550
  init_task();
24524
24551
  }
24525
24552
  });
24526
- function parseInit(bare, path22, text) {
24553
+ function parseInit(bare, path23, text) {
24527
24554
  const response = String(text).trim();
24528
24555
  let result;
24529
24556
  if (result = initResponseRegex.exec(response)) {
24530
- return new InitSummary(bare, path22, false, result[1]);
24557
+ return new InitSummary(bare, path23, false, result[1]);
24531
24558
  }
24532
24559
  if (result = reInitResponseRegex.exec(response)) {
24533
- return new InitSummary(bare, path22, true, result[1]);
24560
+ return new InitSummary(bare, path23, true, result[1]);
24534
24561
  }
24535
24562
  let gitDir = "";
24536
24563
  const tokens = response.split(" ");
@@ -24541,7 +24568,7 @@ function parseInit(bare, path22, text) {
24541
24568
  break;
24542
24569
  }
24543
24570
  }
24544
- return new InitSummary(bare, path22, /^re/i.test(response), gitDir);
24571
+ return new InitSummary(bare, path23, /^re/i.test(response), gitDir);
24545
24572
  }
24546
24573
  var InitSummary;
24547
24574
  var initResponseRegex;
@@ -24550,9 +24577,9 @@ var init_InitSummary = __esm2({
24550
24577
  "src/lib/responses/InitSummary.ts"() {
24551
24578
  "use strict";
24552
24579
  InitSummary = class {
24553
- constructor(bare, path22, existing, gitDir) {
24580
+ constructor(bare, path23, existing, gitDir) {
24554
24581
  this.bare = bare;
24555
- this.path = path22;
24582
+ this.path = path23;
24556
24583
  this.existing = existing;
24557
24584
  this.gitDir = gitDir;
24558
24585
  }
@@ -24564,7 +24591,7 @@ var init_InitSummary = __esm2({
24564
24591
  function hasBareCommand(command) {
24565
24592
  return command.includes(bareCommand);
24566
24593
  }
24567
- function initTask(bare = false, path22, customArgs) {
24594
+ function initTask(bare = false, path23, customArgs) {
24568
24595
  const commands = ["init", ...customArgs];
24569
24596
  if (bare && !hasBareCommand(commands)) {
24570
24597
  commands.splice(1, 0, bareCommand);
@@ -24573,7 +24600,7 @@ function initTask(bare = false, path22, customArgs) {
24573
24600
  commands,
24574
24601
  format: "utf-8",
24575
24602
  parser(text) {
24576
- return parseInit(commands.includes("--bare"), path22, text);
24603
+ return parseInit(commands.includes("--bare"), path23, text);
24577
24604
  }
24578
24605
  };
24579
24606
  }
@@ -25389,12 +25416,12 @@ var init_FileStatusSummary = __esm2({
25389
25416
  "use strict";
25390
25417
  fromPathRegex = /^(.+)\0(.+)$/;
25391
25418
  FileStatusSummary = class {
25392
- constructor(path22, index, working_dir) {
25393
- this.path = path22;
25419
+ constructor(path23, index, working_dir) {
25420
+ this.path = path23;
25394
25421
  this.index = index;
25395
25422
  this.working_dir = working_dir;
25396
25423
  if (index === "R" || working_dir === "R") {
25397
- const detail = fromPathRegex.exec(path22) || [null, path22, path22];
25424
+ const detail = fromPathRegex.exec(path23) || [null, path23, path23];
25398
25425
  this.from = detail[2] || "";
25399
25426
  this.path = detail[1] || "";
25400
25427
  }
@@ -25425,14 +25452,14 @@ function splitLine(result, lineStr) {
25425
25452
  default:
25426
25453
  return;
25427
25454
  }
25428
- function data(index, workingDir, path22) {
25455
+ function data(index, workingDir, path23) {
25429
25456
  const raw = `${index}${workingDir}`;
25430
25457
  const handler = parsers6.get(raw);
25431
25458
  if (handler) {
25432
- handler(result, path22);
25459
+ handler(result, path23);
25433
25460
  }
25434
25461
  if (raw !== "##" && raw !== "!!") {
25435
- result.files.push(new FileStatusSummary(path22, index, workingDir));
25462
+ result.files.push(new FileStatusSummary(path23, index, workingDir));
25436
25463
  }
25437
25464
  }
25438
25465
  }
@@ -25741,9 +25768,9 @@ var init_simple_git_api = __esm2({
25741
25768
  next
25742
25769
  );
25743
25770
  }
25744
- hashObject(path22, write) {
25771
+ hashObject(path23, write) {
25745
25772
  return this._runTask(
25746
- hashObjectTask(path22, write === true),
25773
+ hashObjectTask(path23, write === true),
25747
25774
  trailingFunctionArgument(arguments)
25748
25775
  );
25749
25776
  }
@@ -26096,8 +26123,8 @@ var init_branch = __esm2({
26096
26123
  }
26097
26124
  });
26098
26125
  function toPath(input) {
26099
- const path22 = input.trim().replace(/^["']|["']$/g, "");
26100
- return path22 && normalize(path22);
26126
+ const path23 = input.trim().replace(/^["']|["']$/g, "");
26127
+ return path23 && normalize(path23);
26101
26128
  }
26102
26129
  var parseCheckIgnore;
26103
26130
  var init_CheckIgnore = __esm2({
@@ -26411,8 +26438,8 @@ __export2(sub_module_exports, {
26411
26438
  subModuleTask: () => subModuleTask,
26412
26439
  updateSubModuleTask: () => updateSubModuleTask
26413
26440
  });
26414
- function addSubModuleTask(repo, path22) {
26415
- return subModuleTask(["add", repo, path22]);
26441
+ function addSubModuleTask(repo, path23) {
26442
+ return subModuleTask(["add", repo, path23]);
26416
26443
  }
26417
26444
  function initSubModuleTask(customArgs) {
26418
26445
  return subModuleTask(["init", ...customArgs]);
@@ -26745,8 +26772,8 @@ var require_git = __commonJS2({
26745
26772
  }
26746
26773
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
26747
26774
  };
26748
- Git2.prototype.submoduleAdd = function(repo, path22, then) {
26749
- return this._runTask(addSubModuleTask2(repo, path22), trailingFunctionArgument2(arguments));
26775
+ Git2.prototype.submoduleAdd = function(repo, path23, then) {
26776
+ return this._runTask(addSubModuleTask2(repo, path23), trailingFunctionArgument2(arguments));
26750
26777
  };
26751
26778
  Git2.prototype.submoduleUpdate = function(args, then) {
26752
26779
  return this._runTask(
@@ -27372,7 +27399,7 @@ async function isGitRepoDirectory(dirPath) {
27372
27399
  // src/git/discover-repos.ts
27373
27400
  async function discoverGitRepos(cwd3 = process.cwd()) {
27374
27401
  const result = [];
27375
- const cwdResolved = path3.resolve(cwd3);
27402
+ const cwdResolved = path4.resolve(cwd3);
27376
27403
  if (await isGitRepoDirectory(cwdResolved)) {
27377
27404
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
27378
27405
  result.push({ absolutePath: cwdResolved, remoteUrl });
@@ -27385,7 +27412,7 @@ async function discoverGitRepos(cwd3 = process.cwd()) {
27385
27412
  }
27386
27413
  for (const ent of entries) {
27387
27414
  if (!ent.isDirectory()) continue;
27388
- const childPath = path3.join(cwdResolved, ent.name);
27415
+ const childPath = path4.join(cwdResolved, ent.name);
27389
27416
  if (await isGitRepoDirectory(childPath)) {
27390
27417
  const remoteUrl = await getRemoteOriginUrl(childPath);
27391
27418
  result.push({ absolutePath: childPath, remoteUrl });
@@ -27394,11 +27421,11 @@ async function discoverGitRepos(cwd3 = process.cwd()) {
27394
27421
  return result;
27395
27422
  }
27396
27423
  async function discoverGitReposUnderRoot(rootAbs) {
27397
- const root = path3.resolve(rootAbs);
27424
+ const root = path4.resolve(rootAbs);
27398
27425
  const roots = [];
27399
27426
  async function walk(dir) {
27400
27427
  if (await isGitRepoDirectory(dir)) {
27401
- roots.push(path3.resolve(dir));
27428
+ roots.push(path4.resolve(dir));
27402
27429
  return;
27403
27430
  }
27404
27431
  let entries;
@@ -27409,7 +27436,7 @@ async function discoverGitReposUnderRoot(rootAbs) {
27409
27436
  }
27410
27437
  for (const ent of entries) {
27411
27438
  if (!ent.isDirectory() || ent.name === ".git") continue;
27412
- await walk(path3.join(dir, ent.name));
27439
+ await walk(path4.join(dir, ent.name));
27413
27440
  }
27414
27441
  }
27415
27442
  await walk(root);
@@ -27598,7 +27625,7 @@ function connectProxy(options) {
27598
27625
  // src/git/session-git-queue.ts
27599
27626
  import { execFile } from "node:child_process";
27600
27627
  import { promisify } from "node:util";
27601
- import * as path4 from "node:path";
27628
+ import * as path5 from "node:path";
27602
27629
  var execFileAsync = promisify(execFile);
27603
27630
  var sessionBoundaryBySessionId = /* @__PURE__ */ new Map();
27604
27631
  async function gitStashCreate(repoRoot, log2) {
@@ -27649,7 +27676,7 @@ async function collectSessionDiffAndNotify(options) {
27649
27676
  continue;
27650
27677
  }
27651
27678
  const lines = namesRaw.split("\n").map((l) => l.trim()).filter(Boolean);
27652
- const slug = path4.basename(repo.path).replace(/[^\w.-]+/g, "_") || "repo";
27679
+ const slug = path5.basename(repo.path).replace(/[^\w.-]+/g, "_") || "repo";
27653
27680
  for (const rel of lines) {
27654
27681
  if (rel.includes("..")) continue;
27655
27682
  try {
@@ -27688,6 +27715,7 @@ async function sendPromptToAgent(options) {
27688
27715
  sendResult,
27689
27716
  sendSessionUpdate,
27690
27717
  collectSessionDiffAfterTurn,
27718
+ agentType,
27691
27719
  log: log2
27692
27720
  } = options;
27693
27721
  log2("[prompt] Sending to agent\u2026");
@@ -27701,7 +27729,12 @@ async function sendPromptToAgent(options) {
27701
27729
  id: promptId,
27702
27730
  ...sessionId ? { sessionId } : {},
27703
27731
  ...runId ? { runId } : {},
27704
- ...result
27732
+ success: result.success,
27733
+ ...typeof result.stopReason === "string" ? { stopReason: result.stopReason } : {},
27734
+ ...typeof result.output === "string" ? { output: result.output } : {},
27735
+ ...typeof result.error === "string" ? { error: result.error } : {},
27736
+ ...result.authRequired ? { authRequired: true } : {},
27737
+ ...agentType ? { agentType } : {}
27705
27738
  });
27706
27739
  if (result.success) {
27707
27740
  const out = result.output ?? "";
@@ -27709,10 +27742,11 @@ async function sendPromptToAgent(options) {
27709
27742
  log2(`[prompt] Done; sent response (${out.length} chars)`);
27710
27743
  if (preview) log2(`[prompt] Response: ${preview}`);
27711
27744
  } else {
27712
- log2(`[prompt] Agent error: ${result.error}`);
27745
+ log2(`[prompt] Agent error: ${result.error ?? "(unknown)"}`);
27713
27746
  }
27714
27747
  } catch (err) {
27715
- const errMsg = err instanceof Error ? err.message : String(err);
27748
+ const errMsg = formatAcpRpcError(err);
27749
+ const authRequired = isAcpAuthenticationRequiredError(err);
27716
27750
  log2(`[prompt] Send failed: ${errMsg}`);
27717
27751
  if (err instanceof Error && err.stack) log2(`[prompt] ${err.stack}`);
27718
27752
  sendResult({
@@ -27721,13 +27755,15 @@ async function sendPromptToAgent(options) {
27721
27755
  ...sessionId ? { sessionId } : {},
27722
27756
  ...runId ? { runId } : {},
27723
27757
  success: false,
27724
- error: errMsg
27758
+ error: errMsg,
27759
+ ...authRequired ? { authRequired: true } : {},
27760
+ ...agentType ? { agentType } : {}
27725
27761
  });
27726
27762
  }
27727
27763
  }
27728
27764
 
27729
27765
  // src/acp/ensure-acp-client.ts
27730
- import * as path8 from "node:path";
27766
+ import * as path9 from "node:path";
27731
27767
 
27732
27768
  // src/error-message.ts
27733
27769
  function errorMessage(err) {
@@ -27739,6 +27775,17 @@ function errorMessage(err) {
27739
27775
  return String(err);
27740
27776
  }
27741
27777
 
27778
+ // src/acp/clients/claude-agent-acp-client.ts
27779
+ var DEFAULT_CLAUDE_AGENT_ACP_COMMAND = ["npx", "--yes", "@agentclientprotocol/claude-agent-acp"];
27780
+ function isClaudeAgentAcpCommand(command) {
27781
+ const i = command.indexOf("@agentclientprotocol/claude-agent-acp");
27782
+ return i >= 0 && (i === 0 || command[i - 1] === "npx" || command[i - 1] === "bunx");
27783
+ }
27784
+ async function createClaudeAgentAcpClient(options) {
27785
+ const command = options.command?.length && options.command.some((a) => a.includes("claude-agent-acp")) ? options.command : [...DEFAULT_CLAUDE_AGENT_ACP_COMMAND];
27786
+ return createAcpClient({ ...options, command });
27787
+ }
27788
+
27742
27789
  // src/acp/clients/codex-acp-client.ts
27743
27790
  var DEFAULT_CODEX_ACP_COMMAND = ["npx", "--yes", "@zed-industries/codex-acp"];
27744
27791
  function isCodexAcpCommand(command) {
@@ -27757,21 +27804,21 @@ import { spawn as spawn4 } from "node:child_process";
27757
27804
  import * as readline from "node:readline";
27758
27805
 
27759
27806
  // src/acp/safe-fs-path.ts
27760
- import * as path5 from "node:path";
27807
+ import * as path6 from "node:path";
27761
27808
  function resolveSafePathUnderCwd(cwd3, filePath) {
27762
27809
  const trimmed2 = filePath.trim();
27763
27810
  if (!trimmed2) return null;
27764
- const normalizedCwd = path5.resolve(cwd3);
27765
- const resolved = path5.isAbsolute(trimmed2) ? path5.normalize(trimmed2) : path5.resolve(normalizedCwd, trimmed2);
27766
- const rel = path5.relative(normalizedCwd, resolved);
27767
- if (rel.startsWith("..") || path5.isAbsolute(rel)) return null;
27811
+ const normalizedCwd = path6.resolve(cwd3);
27812
+ const resolved = path6.isAbsolute(trimmed2) ? path6.normalize(trimmed2) : path6.resolve(normalizedCwd, trimmed2);
27813
+ const rel = path6.relative(normalizedCwd, resolved);
27814
+ if (rel.startsWith("..") || path6.isAbsolute(rel)) return null;
27768
27815
  return resolved;
27769
27816
  }
27770
27817
  function toDisplayPathRelativeToCwd(cwd3, absolutePath) {
27771
- const normalizedCwd = path5.resolve(cwd3);
27772
- const rel = path5.relative(normalizedCwd, path5.resolve(absolutePath));
27773
- if (!rel || rel === "") return path5.basename(absolutePath);
27774
- return rel.split(path5.sep).join("/");
27818
+ const normalizedCwd = path6.resolve(cwd3);
27819
+ const rel = path6.relative(normalizedCwd, path6.resolve(absolutePath));
27820
+ if (!rel || rel === "") return path6.basename(absolutePath);
27821
+ return rel.split(path6.sep).join("/");
27775
27822
  }
27776
27823
 
27777
27824
  // src/files/diff/unified-diff.ts
@@ -28073,7 +28120,7 @@ async function createCursorAcpClient(options) {
28073
28120
  var AGENT_TYPE_DEFAULT_COMMANDS = {
28074
28121
  "cursor-cli": ["agent", "acp"],
28075
28122
  "codex-acp": [...DEFAULT_CODEX_ACP_COMMAND],
28076
- "claude-code": ["npx", "--yes", "@anthropic-ai/claude-code"]
28123
+ "claude-code": [...DEFAULT_CLAUDE_AGENT_ACP_COMMAND]
28077
28124
  };
28078
28125
  function useCursorAcp(agentType, command) {
28079
28126
  if (agentType === "cursor-cli") return true;
@@ -28083,12 +28130,16 @@ function useCodexAcp(agentType, command) {
28083
28130
  if (agentType === "codex-acp") return true;
28084
28131
  return isCodexAcpCommand(command);
28085
28132
  }
28133
+ function useClaudeAgentAcp(agentType, command) {
28134
+ if (agentType === "claude-code") return true;
28135
+ return isClaudeAgentAcpCommand(command);
28136
+ }
28086
28137
  function resolveAgentCommand(agentCommand, preferredAgentType) {
28087
28138
  const explicitCmd = agentCommand?.length ? agentCommand : void 0;
28088
28139
  const typeCmd = preferredAgentType ? AGENT_TYPE_DEFAULT_COMMANDS[preferredAgentType] : void 0;
28089
28140
  const command = explicitCmd ?? typeCmd;
28090
28141
  if (!command?.length) return null;
28091
- const createClient = useCursorAcp(preferredAgentType, command) ? createCursorAcpClient : useCodexAcp(preferredAgentType, command) ? createCodexAcpClient : createAcpClient;
28142
+ const createClient = useCursorAcp(preferredAgentType, command) ? createCursorAcpClient : useCodexAcp(preferredAgentType, command) ? createCodexAcpClient : useClaudeAgentAcp(preferredAgentType, command) ? createClaudeAgentAcpClient : createAcpClient;
28092
28143
  const label = preferredAgentType ?? "--agent";
28093
28144
  return { command, label, createClient };
28094
28145
  }
@@ -28099,16 +28150,16 @@ import { existsSync, statSync } from "node:fs";
28099
28150
 
28100
28151
  // src/git/get-git-repo-root-sync.ts
28101
28152
  import { execFileSync } from "node:child_process";
28102
- import * as path6 from "node:path";
28153
+ import * as path7 from "node:path";
28103
28154
  function getGitRepoRootSync(startDir) {
28104
28155
  try {
28105
28156
  const out = execFileSync("git", ["rev-parse", "--show-toplevel"], {
28106
- cwd: path6.resolve(startDir),
28157
+ cwd: path7.resolve(startDir),
28107
28158
  encoding: "utf8",
28108
28159
  stdio: ["ignore", "pipe", "ignore"],
28109
28160
  maxBuffer: 1024 * 1024
28110
28161
  }).trim();
28111
- return out ? path6.resolve(out) : null;
28162
+ return out ? path7.resolve(out) : null;
28112
28163
  } catch {
28113
28164
  return null;
28114
28165
  }
@@ -28117,25 +28168,25 @@ function getGitRepoRootSync(startDir) {
28117
28168
  // src/acp/workspace-files.ts
28118
28169
  import { execFileSync as execFileSync2 } from "node:child_process";
28119
28170
  import { readFileSync as readFileSync2 } from "node:fs";
28120
- import * as path7 from "node:path";
28171
+ import * as path8 from "node:path";
28121
28172
  function resolveWorkspaceFilePath(cwd3, rawPath) {
28122
28173
  const trimmed2 = rawPath.trim();
28123
28174
  if (!trimmed2) return null;
28124
- const normalizedCwd = path7.resolve(cwd3);
28175
+ const normalizedCwd = path8.resolve(cwd3);
28125
28176
  let abs = resolveSafePathUnderCwd(cwd3, trimmed2);
28126
28177
  if (!abs) {
28127
- const candidate = path7.isAbsolute(trimmed2) ? path7.normalize(trimmed2) : path7.normalize(path7.resolve(normalizedCwd, trimmed2));
28178
+ const candidate = path8.isAbsolute(trimmed2) ? path8.normalize(trimmed2) : path8.normalize(path8.resolve(normalizedCwd, trimmed2));
28128
28179
  const gitRoot2 = getGitRepoRootSync(cwd3);
28129
28180
  if (!gitRoot2) return null;
28130
- const rel = path7.relative(gitRoot2, candidate);
28131
- if (rel.startsWith("..") || path7.isAbsolute(rel)) return null;
28181
+ const rel = path8.relative(gitRoot2, candidate);
28182
+ if (rel.startsWith("..") || path8.isAbsolute(rel)) return null;
28132
28183
  abs = candidate;
28133
28184
  }
28134
28185
  const gitRoot = getGitRepoRootSync(cwd3);
28135
28186
  if (gitRoot) {
28136
- const relFromRoot = path7.relative(gitRoot, abs);
28137
- if (!relFromRoot.startsWith("..") && !path7.isAbsolute(relFromRoot)) {
28138
- return { abs, display: relFromRoot.split(path7.sep).join("/") };
28187
+ const relFromRoot = path8.relative(gitRoot, abs);
28188
+ if (!relFromRoot.startsWith("..") && !path8.isAbsolute(relFromRoot)) {
28189
+ return { abs, display: relFromRoot.split(path8.sep).join("/") };
28139
28190
  }
28140
28191
  }
28141
28192
  return { abs, display: toDisplayPathRelativeToCwd(cwd3, abs) };
@@ -28144,9 +28195,9 @@ function readUtf8WorkspaceFile(cwd3, displayPath) {
28144
28195
  if (!displayPath || displayPath.includes("..")) return "";
28145
28196
  const gitRoot = getGitRepoRootSync(cwd3);
28146
28197
  if (gitRoot) {
28147
- const abs2 = path7.resolve(gitRoot, displayPath);
28148
- const rel = path7.relative(gitRoot, abs2);
28149
- if (!rel.startsWith("..") && !path7.isAbsolute(rel)) {
28198
+ const abs2 = path8.resolve(gitRoot, displayPath);
28199
+ const rel = path8.relative(gitRoot, abs2);
28200
+ if (!rel.startsWith("..") && !path8.isAbsolute(rel)) {
28150
28201
  try {
28151
28202
  return readFileSync2(abs2, "utf8");
28152
28203
  } catch {
@@ -28165,9 +28216,9 @@ function tryWorkspaceDisplayToAbs(cwd3, displayPath) {
28165
28216
  if (!displayPath || displayPath.includes("..")) return null;
28166
28217
  const gitRoot = getGitRepoRootSync(cwd3);
28167
28218
  if (gitRoot) {
28168
- const abs = path7.resolve(gitRoot, displayPath);
28169
- const rel = path7.relative(gitRoot, abs);
28170
- if (!rel.startsWith("..") && !path7.isAbsolute(rel)) return abs;
28219
+ const abs = path8.resolve(gitRoot, displayPath);
28220
+ const rel = path8.relative(gitRoot, abs);
28221
+ if (!rel.startsWith("..") && !path8.isAbsolute(rel)) return abs;
28171
28222
  }
28172
28223
  return resolveSafePathUnderCwd(cwd3, displayPath);
28173
28224
  }
@@ -28461,6 +28512,11 @@ function isCompletedToolStatus(status) {
28461
28512
  const s = status.toLowerCase();
28462
28513
  return s === "completed" || s === "complete" || s === "succeeded" || s === "success";
28463
28514
  }
28515
+ function isTerminalToolStatus(status) {
28516
+ if (typeof status !== "string") return false;
28517
+ const s = status.toLowerCase();
28518
+ return isCompletedToolStatus(status) || s === "failed" || s === "cancelled" || s === "canceled";
28519
+ }
28464
28520
  function accumulateToolPaths(toolKey, paths, acc) {
28465
28521
  if (!toolKey || paths.length === 0) return;
28466
28522
  let s = acc.get(toolKey);
@@ -28723,7 +28779,7 @@ function buildAcpSessionBridgeHooks(opts) {
28723
28779
  async function ensureAcpClient(options) {
28724
28780
  const { state, agentCommand, preferredAgentType, mode, cwd: cwd3, routing, sendSessionUpdate, sendRequest, log: log2 } = options;
28725
28781
  const targetCwd = cwd3 ?? process.cwd();
28726
- if (state.acpHandle && state.lastAcpCwd != null && path8.resolve(state.lastAcpCwd) !== path8.resolve(targetCwd)) {
28782
+ if (state.acpHandle && state.lastAcpCwd != null && path9.resolve(state.lastAcpCwd) !== path9.resolve(targetCwd)) {
28727
28783
  try {
28728
28784
  state.acpHandle.disconnect();
28729
28785
  } catch {
@@ -28865,6 +28921,7 @@ async function createAcpManager(options) {
28865
28921
  promptId,
28866
28922
  sessionId,
28867
28923
  runId,
28924
+ agentType: preferredForPrompt,
28868
28925
  sendResult,
28869
28926
  sendSessionUpdate,
28870
28927
  collectSessionDiffAfterTurn,
@@ -28952,12 +29009,12 @@ function handleBridgeAgentConfig(msg, { acpManager }) {
28952
29009
  var handleAgentConfigMessage = (msg, deps) => handleBridgeAgentConfig(msg, deps);
28953
29010
 
28954
29011
  // src/acp/from-bridge/handle-bridge-prompt.ts
28955
- import * as path11 from "node:path";
29012
+ import * as path12 from "node:path";
28956
29013
  import { execFile as execFile3 } from "node:child_process";
28957
29014
  import { promisify as promisify3 } from "node:util";
28958
29015
 
28959
29016
  // src/git/bridge-queue-key.ts
28960
- import * as path9 from "node:path";
29017
+ import * as path10 from "node:path";
28961
29018
  import { createHash } from "node:crypto";
28962
29019
  function normalizeCanonicalGitUrl(url2) {
28963
29020
  let s = url2.trim();
@@ -28985,11 +29042,11 @@ function canonicalUrlToRepoIdSync(url2) {
28985
29042
  return createHash("sha256").update(normalized).digest("hex").slice(0, 32);
28986
29043
  }
28987
29044
  function fallbackRepoIdFromPath(absPath) {
28988
- return createHash("sha256").update(path9.resolve(absPath)).digest("hex").slice(0, 32);
29045
+ return createHash("sha256").update(path10.resolve(absPath)).digest("hex").slice(0, 32);
28989
29046
  }
28990
29047
  async function resolveBridgeQueueBindFields(options) {
28991
29048
  const { effectiveCwd, worktreePaths, primaryRepoRoots, log: log2 } = options;
28992
- const cwdAbs = worktreePaths.length > 0 ? path9.resolve(worktreePaths[0]) : path9.resolve(effectiveCwd);
29049
+ const cwdAbs = worktreePaths.length > 0 ? path10.resolve(worktreePaths[0]) : path10.resolve(effectiveCwd);
28993
29050
  if (!primaryRepoRoots.length) {
28994
29051
  log2("[bridge-queue] bind skipped: no git repo roots");
28995
29052
  return null;
@@ -29013,12 +29070,12 @@ async function resolveBridgeQueueBindFields(options) {
29013
29070
 
29014
29071
  // src/git/pre-turn-snapshot.ts
29015
29072
  import * as fs4 from "node:fs";
29016
- import * as path10 from "node:path";
29073
+ import * as path11 from "node:path";
29017
29074
  import { execFile as execFile2 } from "node:child_process";
29018
29075
  import { promisify as promisify2 } from "node:util";
29019
29076
  var execFileAsync2 = promisify2(execFile2);
29020
29077
  function snapshotsDirForCwd(agentCwd) {
29021
- return path10.join(agentCwd, ".buildautomaton", "snapshots");
29078
+ return path11.join(agentCwd, ".buildautomaton", "snapshots");
29022
29079
  }
29023
29080
  async function gitStashCreate2(repoRoot, log2) {
29024
29081
  try {
@@ -29045,7 +29102,7 @@ async function gitRun(repoRoot, args, log2, label) {
29045
29102
  async function resolveSnapshotRepoRoots(options) {
29046
29103
  const { worktreePaths, fallbackCwd, log: log2 } = options;
29047
29104
  if (worktreePaths?.length) {
29048
- const uniq = [...new Set(worktreePaths.map((p) => path10.resolve(p)))];
29105
+ const uniq = [...new Set(worktreePaths.map((p) => path11.resolve(p)))];
29049
29106
  return uniq;
29050
29107
  }
29051
29108
  try {
@@ -29077,7 +29134,7 @@ async function capturePreTurnSnapshot(options) {
29077
29134
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
29078
29135
  repos
29079
29136
  };
29080
- const filePath = path10.join(dir, `${runId}.json`);
29137
+ const filePath = path11.join(dir, `${runId}.json`);
29081
29138
  try {
29082
29139
  fs4.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
29083
29140
  } catch (e) {
@@ -29112,7 +29169,7 @@ async function applyPreTurnSnapshot(filePath, log2) {
29112
29169
  return { ok: true };
29113
29170
  }
29114
29171
  function snapshotFilePath(agentCwd, runId) {
29115
- return path10.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
29172
+ return path11.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
29116
29173
  }
29117
29174
 
29118
29175
  // src/acp/from-bridge/handle-bridge-prompt.ts
@@ -29152,15 +29209,27 @@ function handleBridgePrompt(msg, deps) {
29152
29209
  return;
29153
29210
  }
29154
29211
  const p = payload;
29155
- const patchHint = p.type === "session_file_change" && typeof p.patchContent === "string" ? ` patchBytes=${p.patchContent.length}` : "";
29156
- log2(
29157
- `[bridge\u2192ws] ${p.type ?? "payload"} runId=${p.runId?.slice(0, 8) ?? "?"}\u2026 kind=${p.kind ?? "?"}${p.path ? ` path=${p.path}` : ""}${patchHint}`
29158
- );
29212
+ if (p.type === "session_file_change" && typeof p.path === "string") {
29213
+ log2(
29214
+ `[bridge\u2192ws] session_file_change runId=${p.runId?.slice(0, 8) ?? "?"}\u2026 path=${p.path}`
29215
+ );
29216
+ } else if (p.type === "session_update" && (p.kind === "tool_call_update" || p.kind === "tool_call")) {
29217
+ const inner = p.payload && typeof p.payload === "object" ? p.payload : null;
29218
+ const status = inner?.status;
29219
+ if (isTerminalToolStatus(status)) {
29220
+ const tc = inner?.toolCall ?? inner?.tool_call;
29221
+ const toolName = typeof tc?.name === "string" ? tc.name : "";
29222
+ const st = typeof status === "string" ? status : String(status);
29223
+ log2(
29224
+ `[bridge\u2192ws] tool finished runId=${p.runId?.slice(0, 8) ?? "?"}\u2026 tool=${toolName || "?"} status=${st}`
29225
+ );
29226
+ }
29227
+ }
29159
29228
  sendWsMessage(s, payload);
29160
29229
  };
29161
29230
  async function preambleAndPrompt(resolvedCwd) {
29162
29231
  const s = getWs();
29163
- const effectiveCwd = path11.resolve(resolvedCwd ?? process.cwd());
29232
+ const effectiveCwd = path12.resolve(resolvedCwd ?? process.cwd());
29164
29233
  const worktreePaths = sessionWorktreeManager.getWorktreePathsForSession(sessionId) ?? [];
29165
29234
  const repoRoots = await resolveSnapshotRepoRoots({
29166
29235
  worktreePaths,
@@ -29282,14 +29351,14 @@ var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
29282
29351
 
29283
29352
  // src/files/list-dir.ts
29284
29353
  import fs5 from "node:fs";
29285
- import path13 from "node:path";
29354
+ import path14 from "node:path";
29286
29355
 
29287
29356
  // src/files/ensure-under-cwd.ts
29288
- import path12 from "node:path";
29357
+ import path13 from "node:path";
29289
29358
  function ensureUnderCwd(relativePath, cwd3 = process.cwd()) {
29290
- const normalized = path12.normalize(relativePath).replace(/^(\.\/)+/, "");
29291
- const resolved = path12.resolve(cwd3, normalized);
29292
- if (!resolved.startsWith(cwd3 + path12.sep) && resolved !== cwd3) {
29359
+ const normalized = path13.normalize(relativePath).replace(/^(\.\/)+/, "");
29360
+ const resolved = path13.resolve(cwd3, normalized);
29361
+ if (!resolved.startsWith(cwd3 + path13.sep) && resolved !== cwd3) {
29293
29362
  return null;
29294
29363
  }
29295
29364
  return resolved;
@@ -29305,8 +29374,8 @@ function listDir(relativePath) {
29305
29374
  try {
29306
29375
  const names = fs5.readdirSync(resolved, { withFileTypes: true });
29307
29376
  const entries = names.filter((d) => !d.name.startsWith(".")).map((d) => {
29308
- const entryPath = path13.join(relativePath || ".", d.name).replace(/\\/g, "/");
29309
- const fullPath = path13.join(resolved, d.name);
29377
+ const entryPath = path14.join(relativePath || ".", d.name).replace(/\\/g, "/");
29378
+ const fullPath = path14.join(resolved, d.name);
29310
29379
  let isDir = d.isDirectory();
29311
29380
  if (d.isSymbolicLink()) {
29312
29381
  try {
@@ -29523,15 +29592,15 @@ function readFile(relativePath, startLine, endLine, lineOffset, lineChunkSize =
29523
29592
 
29524
29593
  // src/files/file-index.ts
29525
29594
  import fs7 from "node:fs";
29526
- import path14 from "node:path";
29595
+ import path15 from "node:path";
29527
29596
  import os2 from "node:os";
29528
29597
  import crypto2 from "node:crypto";
29529
- var INDEX_DIR = path14.join(os2.homedir(), ".buildautomaton");
29598
+ var INDEX_DIR = path15.join(os2.homedir(), ".buildautomaton");
29530
29599
  var HASH_LEN = 16;
29531
29600
  var INDEX_VERSION = 2;
29532
29601
  function getIndexPath(cwd3) {
29533
29602
  const hash = crypto2.createHash("sha256").update(cwd3).digest("hex").slice(0, HASH_LEN);
29534
- return path14.join(INDEX_DIR, `.file-index-${hash}.json`);
29603
+ return path15.join(INDEX_DIR, `.file-index-${hash}.json`);
29535
29604
  }
29536
29605
  function getTrigrams(s) {
29537
29606
  const lower = s.toLowerCase();
@@ -29575,14 +29644,14 @@ function walkDir(dir, baseDir, out) {
29575
29644
  }
29576
29645
  for (const name of names) {
29577
29646
  if (name.startsWith(".")) continue;
29578
- const full = path14.join(dir, name);
29647
+ const full = path15.join(dir, name);
29579
29648
  let stat4;
29580
29649
  try {
29581
29650
  stat4 = fs7.statSync(full);
29582
29651
  } catch {
29583
29652
  continue;
29584
29653
  }
29585
- const relative6 = path14.relative(baseDir, full).replace(/\\/g, "/");
29654
+ const relative6 = path15.relative(baseDir, full).replace(/\\/g, "/");
29586
29655
  if (stat4.isDirectory()) {
29587
29656
  walkDir(full, baseDir, out);
29588
29657
  } else if (stat4.isFile()) {
@@ -29591,7 +29660,7 @@ function walkDir(dir, baseDir, out) {
29591
29660
  }
29592
29661
  }
29593
29662
  function buildFileIndex(cwd3) {
29594
- const resolved = path14.resolve(cwd3);
29663
+ const resolved = path15.resolve(cwd3);
29595
29664
  const paths = [];
29596
29665
  walkDir(resolved, resolved, paths);
29597
29666
  paths.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" }));
@@ -29617,7 +29686,7 @@ function buildFileIndex(cwd3) {
29617
29686
  return data;
29618
29687
  }
29619
29688
  function loadFileIndex(cwd3) {
29620
- const resolved = path14.resolve(cwd3);
29689
+ const resolved = path15.resolve(cwd3);
29621
29690
  const indexPath = getIndexPath(resolved);
29622
29691
  try {
29623
29692
  const raw = fs7.readFileSync(indexPath, "utf8");
@@ -29638,7 +29707,7 @@ function loadFileIndex(cwd3) {
29638
29707
  }
29639
29708
  }
29640
29709
  function ensureFileIndex(cwd3) {
29641
- const resolved = path14.resolve(cwd3);
29710
+ const resolved = path15.resolve(cwd3);
29642
29711
  const cached2 = loadFileIndex(resolved);
29643
29712
  if (cached2 !== null) return { data: cached2, fromCache: true };
29644
29713
  const data = buildFileIndex(resolved);
@@ -29777,7 +29846,7 @@ function registerFileBrowserHandlers(router2) {
29777
29846
 
29778
29847
  // src/skills/install-remote-skills.ts
29779
29848
  import fs8 from "node:fs";
29780
- import path15 from "node:path";
29849
+ import path16 from "node:path";
29781
29850
  function installRemoteSkills(cwd3, targetDir, items) {
29782
29851
  const installed = [];
29783
29852
  if (!Array.isArray(items)) {
@@ -29788,11 +29857,11 @@ function installRemoteSkills(cwd3, targetDir, items) {
29788
29857
  if (typeof item.sourceId !== "string" || typeof item.skillName !== "string" || typeof item.versionHash !== "string" || !Array.isArray(item.files)) {
29789
29858
  continue;
29790
29859
  }
29791
- const skillDir = path15.join(cwd3, targetDir, item.skillName);
29860
+ const skillDir = path16.join(cwd3, targetDir, item.skillName);
29792
29861
  for (const f of item.files) {
29793
29862
  if (typeof f.path !== "string" || !f.text && !f.base64) continue;
29794
- const dest = path15.join(skillDir, f.path);
29795
- fs8.mkdirSync(path15.dirname(dest), { recursive: true });
29863
+ const dest = path16.join(skillDir, f.path);
29864
+ fs8.mkdirSync(path16.dirname(dest), { recursive: true });
29796
29865
  if (f.text !== void 0) {
29797
29866
  fs8.writeFileSync(dest, f.text, "utf8");
29798
29867
  } else if (f.base64) {
@@ -29902,7 +29971,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
29902
29971
 
29903
29972
  // src/bridge/routing/handlers/revert-turn-snapshot.ts
29904
29973
  import * as fs9 from "node:fs";
29905
- import * as path16 from "node:path";
29974
+ import * as path17 from "node:path";
29906
29975
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
29907
29976
  if (msg.type !== "revert_turn_snapshot") return false;
29908
29977
  const id = typeof msg.id === "string" ? msg.id : "";
@@ -29913,7 +29982,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
29913
29982
  void (async () => {
29914
29983
  const s = getWs();
29915
29984
  if (!s) return;
29916
- const agentBase = sessionWorktreeManager.getAgentCwdForSession(sessionId) ?? path16.resolve(process.cwd());
29985
+ const agentBase = sessionWorktreeManager.getAgentCwdForSession(sessionId) ?? path17.resolve(process.cwd());
29917
29986
  const file2 = snapshotFilePath(agentBase, turnId);
29918
29987
  if (!fs9.existsSync(file2)) {
29919
29988
  sendWsMessage(s, {
@@ -29960,12 +30029,12 @@ function handleBridgeMessage(data, deps) {
29960
30029
  }
29961
30030
 
29962
30031
  // src/worktrees/session-worktree-manager.ts
29963
- import * as path20 from "node:path";
30032
+ import * as path21 from "node:path";
29964
30033
  import os4 from "node:os";
29965
30034
 
29966
30035
  // src/worktrees/prepare-new-session-worktrees.ts
29967
30036
  import * as fs11 from "node:fs";
29968
- import * as path18 from "node:path";
30037
+ import * as path19 from "node:path";
29969
30038
 
29970
30039
  // src/git/worktree-add.ts
29971
30040
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
@@ -29975,11 +30044,11 @@ async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
29975
30044
 
29976
30045
  // src/worktrees/worktree-layout-file.ts
29977
30046
  import * as fs10 from "node:fs";
29978
- import * as path17 from "node:path";
30047
+ import * as path18 from "node:path";
29979
30048
  import os3 from "node:os";
29980
30049
  var LAYOUT_FILENAME = "worktree-launcher-layout.json";
29981
30050
  function defaultWorktreeLayoutPath() {
29982
- return path17.join(os3.homedir(), ".buildautomaton", LAYOUT_FILENAME);
30051
+ return path18.join(os3.homedir(), ".buildautomaton", LAYOUT_FILENAME);
29983
30052
  }
29984
30053
  function normalizeLoadedLayout(raw) {
29985
30054
  if (raw && typeof raw === "object" && "launcherCwds" in raw) {
@@ -30000,18 +30069,18 @@ function loadWorktreeLayout() {
30000
30069
  }
30001
30070
  function saveWorktreeLayout(layout) {
30002
30071
  try {
30003
- const dir = path17.dirname(defaultWorktreeLayoutPath());
30072
+ const dir = path18.dirname(defaultWorktreeLayoutPath());
30004
30073
  fs10.mkdirSync(dir, { recursive: true });
30005
30074
  fs10.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
30006
30075
  } catch {
30007
30076
  }
30008
30077
  }
30009
30078
  function baseNameSafe(abs) {
30010
- return path17.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
30079
+ return path18.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
30011
30080
  }
30012
30081
  function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
30013
- const norm = path17.resolve(launcherCwdAbs);
30014
- const existing = layout.launcherCwds.find((e) => path17.resolve(e.absolutePath) === norm);
30082
+ const norm = path18.resolve(launcherCwdAbs);
30083
+ const existing = layout.launcherCwds.find((e) => path18.resolve(e.absolutePath) === norm);
30015
30084
  if (existing) return existing.dirName;
30016
30085
  const base = baseNameSafe(norm);
30017
30086
  const used = new Set(layout.launcherCwds.map((e) => e.dirName));
@@ -30029,9 +30098,9 @@ function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
30029
30098
  // src/worktrees/prepare-new-session-worktrees.ts
30030
30099
  async function prepareNewSessionWorktrees(options) {
30031
30100
  const { rootAbs, launcherCwd, sessionId, layout, log: log2 } = options;
30032
- const launcherResolved = path18.resolve(launcherCwd);
30101
+ const launcherResolved = path19.resolve(launcherCwd);
30033
30102
  const cwdKey = allocateDirNameForLauncherCwd(layout, launcherResolved);
30034
- const agentMirrorRoot = path18.join(rootAbs, cwdKey);
30103
+ const agentMirrorRoot = path19.join(rootAbs, cwdKey);
30035
30104
  const repos = await discoverGitReposUnderRoot(launcherResolved);
30036
30105
  if (repos.length === 0) {
30037
30106
  log2("[worktrees] No git repos under launcher cwd; skipping worktree creation");
@@ -30041,11 +30110,11 @@ async function prepareNewSessionWorktrees(options) {
30041
30110
  const worktreePaths = [];
30042
30111
  fs11.mkdirSync(agentMirrorRoot, { recursive: true });
30043
30112
  for (const repo of repos) {
30044
- let rel = path18.relative(launcherResolved, repo.absolutePath);
30045
- if (rel.startsWith("..") || path18.isAbsolute(rel)) continue;
30113
+ let rel = path19.relative(launcherResolved, repo.absolutePath);
30114
+ if (rel.startsWith("..") || path19.isAbsolute(rel)) continue;
30046
30115
  const relNorm = rel === "" ? "." : rel;
30047
- const wtPath = path18.join(agentMirrorRoot, relNorm, sessionId);
30048
- fs11.mkdirSync(path18.dirname(wtPath), { recursive: true });
30116
+ const wtPath = path19.join(agentMirrorRoot, relNorm, sessionId);
30117
+ fs11.mkdirSync(path19.dirname(wtPath), { recursive: true });
30049
30118
  try {
30050
30119
  await gitWorktreeAddBranch(repo.absolutePath, wtPath, branch);
30051
30120
  log2(`[worktrees] Added worktree ${wtPath} (branch ${branch})`);
@@ -30087,16 +30156,16 @@ import * as fs13 from "node:fs";
30087
30156
 
30088
30157
  // src/git/resolve-main-repo-from-git-file.ts
30089
30158
  import * as fs12 from "node:fs";
30090
- import * as path19 from "node:path";
30159
+ import * as path20 from "node:path";
30091
30160
  function resolveMainRepoFromWorktreeGitFile(wt) {
30092
- const gitDirFile = path19.join(wt, ".git");
30161
+ const gitDirFile = path20.join(wt, ".git");
30093
30162
  if (!fs12.existsSync(gitDirFile) || !fs12.statSync(gitDirFile).isFile()) return "";
30094
30163
  const first2 = fs12.readFileSync(gitDirFile, "utf8").trim();
30095
30164
  const m = first2.match(/^gitdir:\s*(.+)$/im);
30096
30165
  if (!m) return "";
30097
- const gitWorktreePath = path19.resolve(wt, m[1].trim());
30098
- const gitDir = path19.dirname(path19.dirname(gitWorktreePath));
30099
- return path19.dirname(gitDir);
30166
+ const gitWorktreePath = path20.resolve(wt, m[1].trim());
30167
+ const gitDir = path20.dirname(path20.dirname(gitWorktreePath));
30168
+ return path20.dirname(gitDir);
30100
30169
  }
30101
30170
 
30102
30171
  // src/git/worktree-remove.ts
@@ -30179,7 +30248,7 @@ var SessionWorktreeManager = class {
30179
30248
  }
30180
30249
  if (!opts.isNewSession) {
30181
30250
  const agentCwd = this.sessionAgentCwd.get(sessionId);
30182
- if (agentCwd) return path20.resolve(agentCwd);
30251
+ if (agentCwd) return path21.resolve(agentCwd);
30183
30252
  return void 0;
30184
30253
  }
30185
30254
  const prep = await prepareNewSessionWorktrees({
@@ -30192,7 +30261,7 @@ var SessionWorktreeManager = class {
30192
30261
  if (!prep) return void 0;
30193
30262
  this.sessionPaths.set(sessionId, prep.worktreePaths);
30194
30263
  this.sessionAgentCwd.set(sessionId, prep.agentCwd);
30195
- return path20.resolve(prep.agentCwd);
30264
+ return path21.resolve(prep.agentCwd);
30196
30265
  }
30197
30266
  async renameSessionBranch(sessionId, newBranch) {
30198
30267
  const paths = this.sessionPaths.get(sessionId);
@@ -30213,7 +30282,7 @@ var SessionWorktreeManager = class {
30213
30282
  getAgentCwdForSession(sessionId) {
30214
30283
  if (!sessionId) return null;
30215
30284
  const c = this.sessionAgentCwd.get(sessionId);
30216
- return c ? path20.resolve(c) : null;
30285
+ return c ? path21.resolve(c) : null;
30217
30286
  }
30218
30287
  async removeSessionWorktrees(sessionId) {
30219
30288
  const paths = this.sessionPaths.get(sessionId);
@@ -30234,7 +30303,7 @@ var SessionWorktreeManager = class {
30234
30303
  }
30235
30304
  };
30236
30305
  function defaultWorktreesRootAbs() {
30237
- return path20.join(os4.homedir(), ".buildautomaton", "worktrees");
30306
+ return path21.join(os4.homedir(), ".buildautomaton", "worktrees");
30238
30307
  }
30239
30308
 
30240
30309
  // src/auth/refresh-bridge-tokens.ts
@@ -30265,7 +30334,7 @@ async function refreshBridgeTokens(params) {
30265
30334
  }
30266
30335
 
30267
30336
  // src/files/watch-file-index.ts
30268
- import path21 from "node:path";
30337
+ import path22 from "node:path";
30269
30338
 
30270
30339
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
30271
30340
  import { stat as statcb } from "fs";
@@ -30343,7 +30412,7 @@ var ReaddirpStream = class extends Readable2 {
30343
30412
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
30344
30413
  const statMethod = opts.lstat ? lstat : stat;
30345
30414
  if (wantBigintFsStats) {
30346
- this._stat = (path22) => statMethod(path22, { bigint: true });
30415
+ this._stat = (path23) => statMethod(path23, { bigint: true });
30347
30416
  } else {
30348
30417
  this._stat = statMethod;
30349
30418
  }
@@ -30368,8 +30437,8 @@ var ReaddirpStream = class extends Readable2 {
30368
30437
  const par = this.parent;
30369
30438
  const fil = par && par.files;
30370
30439
  if (fil && fil.length > 0) {
30371
- const { path: path22, depth } = par;
30372
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path22));
30440
+ const { path: path23, depth } = par;
30441
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path23));
30373
30442
  const awaited = await Promise.all(slice);
30374
30443
  for (const entry of awaited) {
30375
30444
  if (!entry)
@@ -30409,20 +30478,20 @@ var ReaddirpStream = class extends Readable2 {
30409
30478
  this.reading = false;
30410
30479
  }
30411
30480
  }
30412
- async _exploreDir(path22, depth) {
30481
+ async _exploreDir(path23, depth) {
30413
30482
  let files;
30414
30483
  try {
30415
- files = await readdir(path22, this._rdOptions);
30484
+ files = await readdir(path23, this._rdOptions);
30416
30485
  } catch (error40) {
30417
30486
  this._onError(error40);
30418
30487
  }
30419
- return { files, depth, path: path22 };
30488
+ return { files, depth, path: path23 };
30420
30489
  }
30421
- async _formatEntry(dirent, path22) {
30490
+ async _formatEntry(dirent, path23) {
30422
30491
  let entry;
30423
30492
  const basename6 = this._isDirent ? dirent.name : dirent;
30424
30493
  try {
30425
- const fullPath = presolve(pjoin(path22, basename6));
30494
+ const fullPath = presolve(pjoin(path23, basename6));
30426
30495
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename6 };
30427
30496
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
30428
30497
  } catch (err) {
@@ -30822,16 +30891,16 @@ var delFromSet = (main, prop, item) => {
30822
30891
  };
30823
30892
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
30824
30893
  var FsWatchInstances = /* @__PURE__ */ new Map();
30825
- function createFsWatchInstance(path22, options, listener, errHandler, emitRaw) {
30894
+ function createFsWatchInstance(path23, options, listener, errHandler, emitRaw) {
30826
30895
  const handleEvent = (rawEvent, evPath) => {
30827
- listener(path22);
30828
- emitRaw(rawEvent, evPath, { watchedPath: path22 });
30829
- if (evPath && path22 !== evPath) {
30830
- fsWatchBroadcast(sysPath.resolve(path22, evPath), KEY_LISTENERS, sysPath.join(path22, evPath));
30896
+ listener(path23);
30897
+ emitRaw(rawEvent, evPath, { watchedPath: path23 });
30898
+ if (evPath && path23 !== evPath) {
30899
+ fsWatchBroadcast(sysPath.resolve(path23, evPath), KEY_LISTENERS, sysPath.join(path23, evPath));
30831
30900
  }
30832
30901
  };
30833
30902
  try {
30834
- return fs_watch(path22, {
30903
+ return fs_watch(path23, {
30835
30904
  persistent: options.persistent
30836
30905
  }, handleEvent);
30837
30906
  } catch (error40) {
@@ -30847,12 +30916,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
30847
30916
  listener(val1, val2, val3);
30848
30917
  });
30849
30918
  };
30850
- var setFsWatchListener = (path22, fullPath, options, handlers) => {
30919
+ var setFsWatchListener = (path23, fullPath, options, handlers) => {
30851
30920
  const { listener, errHandler, rawEmitter } = handlers;
30852
30921
  let cont = FsWatchInstances.get(fullPath);
30853
30922
  let watcher;
30854
30923
  if (!options.persistent) {
30855
- watcher = createFsWatchInstance(path22, options, listener, errHandler, rawEmitter);
30924
+ watcher = createFsWatchInstance(path23, options, listener, errHandler, rawEmitter);
30856
30925
  if (!watcher)
30857
30926
  return;
30858
30927
  return watcher.close.bind(watcher);
@@ -30863,7 +30932,7 @@ var setFsWatchListener = (path22, fullPath, options, handlers) => {
30863
30932
  addAndConvert(cont, KEY_RAW, rawEmitter);
30864
30933
  } else {
30865
30934
  watcher = createFsWatchInstance(
30866
- path22,
30935
+ path23,
30867
30936
  options,
30868
30937
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
30869
30938
  errHandler,
@@ -30878,7 +30947,7 @@ var setFsWatchListener = (path22, fullPath, options, handlers) => {
30878
30947
  cont.watcherUnusable = true;
30879
30948
  if (isWindows && error40.code === "EPERM") {
30880
30949
  try {
30881
- const fd = await open(path22, "r");
30950
+ const fd = await open(path23, "r");
30882
30951
  await fd.close();
30883
30952
  broadcastErr(error40);
30884
30953
  } catch (err) {
@@ -30909,7 +30978,7 @@ var setFsWatchListener = (path22, fullPath, options, handlers) => {
30909
30978
  };
30910
30979
  };
30911
30980
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
30912
- var setFsWatchFileListener = (path22, fullPath, options, handlers) => {
30981
+ var setFsWatchFileListener = (path23, fullPath, options, handlers) => {
30913
30982
  const { listener, rawEmitter } = handlers;
30914
30983
  let cont = FsWatchFileInstances.get(fullPath);
30915
30984
  const copts = cont && cont.options;
@@ -30931,7 +31000,7 @@ var setFsWatchFileListener = (path22, fullPath, options, handlers) => {
30931
31000
  });
30932
31001
  const currmtime = curr.mtimeMs;
30933
31002
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
30934
- foreach(cont.listeners, (listener2) => listener2(path22, curr));
31003
+ foreach(cont.listeners, (listener2) => listener2(path23, curr));
30935
31004
  }
30936
31005
  })
30937
31006
  };
@@ -30959,13 +31028,13 @@ var NodeFsHandler = class {
30959
31028
  * @param listener on fs change
30960
31029
  * @returns closer for the watcher instance
30961
31030
  */
30962
- _watchWithNodeFs(path22, listener) {
31031
+ _watchWithNodeFs(path23, listener) {
30963
31032
  const opts = this.fsw.options;
30964
- const directory = sysPath.dirname(path22);
30965
- const basename6 = sysPath.basename(path22);
31033
+ const directory = sysPath.dirname(path23);
31034
+ const basename6 = sysPath.basename(path23);
30966
31035
  const parent = this.fsw._getWatchedDir(directory);
30967
31036
  parent.add(basename6);
30968
- const absolutePath = sysPath.resolve(path22);
31037
+ const absolutePath = sysPath.resolve(path23);
30969
31038
  const options = {
30970
31039
  persistent: opts.persistent
30971
31040
  };
@@ -30975,12 +31044,12 @@ var NodeFsHandler = class {
30975
31044
  if (opts.usePolling) {
30976
31045
  const enableBin = opts.interval !== opts.binaryInterval;
30977
31046
  options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
30978
- closer = setFsWatchFileListener(path22, absolutePath, options, {
31047
+ closer = setFsWatchFileListener(path23, absolutePath, options, {
30979
31048
  listener,
30980
31049
  rawEmitter: this.fsw._emitRaw
30981
31050
  });
30982
31051
  } else {
30983
- closer = setFsWatchListener(path22, absolutePath, options, {
31052
+ closer = setFsWatchListener(path23, absolutePath, options, {
30984
31053
  listener,
30985
31054
  errHandler: this._boundHandleError,
30986
31055
  rawEmitter: this.fsw._emitRaw
@@ -31002,7 +31071,7 @@ var NodeFsHandler = class {
31002
31071
  let prevStats = stats;
31003
31072
  if (parent.has(basename6))
31004
31073
  return;
31005
- const listener = async (path22, newStats) => {
31074
+ const listener = async (path23, newStats) => {
31006
31075
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
31007
31076
  return;
31008
31077
  if (!newStats || newStats.mtimeMs === 0) {
@@ -31016,11 +31085,11 @@ var NodeFsHandler = class {
31016
31085
  this.fsw._emit(EV.CHANGE, file2, newStats2);
31017
31086
  }
31018
31087
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
31019
- this.fsw._closeFile(path22);
31088
+ this.fsw._closeFile(path23);
31020
31089
  prevStats = newStats2;
31021
31090
  const closer2 = this._watchWithNodeFs(file2, listener);
31022
31091
  if (closer2)
31023
- this.fsw._addPathCloser(path22, closer2);
31092
+ this.fsw._addPathCloser(path23, closer2);
31024
31093
  } else {
31025
31094
  prevStats = newStats2;
31026
31095
  }
@@ -31052,7 +31121,7 @@ var NodeFsHandler = class {
31052
31121
  * @param item basename of this item
31053
31122
  * @returns true if no more processing is needed for this entry.
31054
31123
  */
31055
- async _handleSymlink(entry, directory, path22, item) {
31124
+ async _handleSymlink(entry, directory, path23, item) {
31056
31125
  if (this.fsw.closed) {
31057
31126
  return;
31058
31127
  }
@@ -31062,7 +31131,7 @@ var NodeFsHandler = class {
31062
31131
  this.fsw._incrReadyCount();
31063
31132
  let linkPath;
31064
31133
  try {
31065
- linkPath = await fsrealpath(path22);
31134
+ linkPath = await fsrealpath(path23);
31066
31135
  } catch (e) {
31067
31136
  this.fsw._emitReady();
31068
31137
  return true;
@@ -31072,12 +31141,12 @@ var NodeFsHandler = class {
31072
31141
  if (dir.has(item)) {
31073
31142
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
31074
31143
  this.fsw._symlinkPaths.set(full, linkPath);
31075
- this.fsw._emit(EV.CHANGE, path22, entry.stats);
31144
+ this.fsw._emit(EV.CHANGE, path23, entry.stats);
31076
31145
  }
31077
31146
  } else {
31078
31147
  dir.add(item);
31079
31148
  this.fsw._symlinkPaths.set(full, linkPath);
31080
- this.fsw._emit(EV.ADD, path22, entry.stats);
31149
+ this.fsw._emit(EV.ADD, path23, entry.stats);
31081
31150
  }
31082
31151
  this.fsw._emitReady();
31083
31152
  return true;
@@ -31106,9 +31175,9 @@ var NodeFsHandler = class {
31106
31175
  return;
31107
31176
  }
31108
31177
  const item = entry.path;
31109
- let path22 = sysPath.join(directory, item);
31178
+ let path23 = sysPath.join(directory, item);
31110
31179
  current.add(item);
31111
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path22, item)) {
31180
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path23, item)) {
31112
31181
  return;
31113
31182
  }
31114
31183
  if (this.fsw.closed) {
@@ -31117,8 +31186,8 @@ var NodeFsHandler = class {
31117
31186
  }
31118
31187
  if (item === target || !target && !previous.has(item)) {
31119
31188
  this.fsw._incrReadyCount();
31120
- path22 = sysPath.join(dir, sysPath.relative(dir, path22));
31121
- this._addToNodeFs(path22, initialAdd, wh, depth + 1);
31189
+ path23 = sysPath.join(dir, sysPath.relative(dir, path23));
31190
+ this._addToNodeFs(path23, initialAdd, wh, depth + 1);
31122
31191
  }
31123
31192
  }).on(EV.ERROR, this._boundHandleError);
31124
31193
  return new Promise((resolve16, reject) => {
@@ -31187,13 +31256,13 @@ var NodeFsHandler = class {
31187
31256
  * @param depth Child path actually targeted for watch
31188
31257
  * @param target Child path actually targeted for watch
31189
31258
  */
31190
- async _addToNodeFs(path22, initialAdd, priorWh, depth, target) {
31259
+ async _addToNodeFs(path23, initialAdd, priorWh, depth, target) {
31191
31260
  const ready = this.fsw._emitReady;
31192
- if (this.fsw._isIgnored(path22) || this.fsw.closed) {
31261
+ if (this.fsw._isIgnored(path23) || this.fsw.closed) {
31193
31262
  ready();
31194
31263
  return false;
31195
31264
  }
31196
- const wh = this.fsw._getWatchHelpers(path22);
31265
+ const wh = this.fsw._getWatchHelpers(path23);
31197
31266
  if (priorWh) {
31198
31267
  wh.filterPath = (entry) => priorWh.filterPath(entry);
31199
31268
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -31209,8 +31278,8 @@ var NodeFsHandler = class {
31209
31278
  const follow = this.fsw.options.followSymlinks;
31210
31279
  let closer;
31211
31280
  if (stats.isDirectory()) {
31212
- const absPath = sysPath.resolve(path22);
31213
- const targetPath = follow ? await fsrealpath(path22) : path22;
31281
+ const absPath = sysPath.resolve(path23);
31282
+ const targetPath = follow ? await fsrealpath(path23) : path23;
31214
31283
  if (this.fsw.closed)
31215
31284
  return;
31216
31285
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -31220,29 +31289,29 @@ var NodeFsHandler = class {
31220
31289
  this.fsw._symlinkPaths.set(absPath, targetPath);
31221
31290
  }
31222
31291
  } else if (stats.isSymbolicLink()) {
31223
- const targetPath = follow ? await fsrealpath(path22) : path22;
31292
+ const targetPath = follow ? await fsrealpath(path23) : path23;
31224
31293
  if (this.fsw.closed)
31225
31294
  return;
31226
31295
  const parent = sysPath.dirname(wh.watchPath);
31227
31296
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
31228
31297
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
31229
- closer = await this._handleDir(parent, stats, initialAdd, depth, path22, wh, targetPath);
31298
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path23, wh, targetPath);
31230
31299
  if (this.fsw.closed)
31231
31300
  return;
31232
31301
  if (targetPath !== void 0) {
31233
- this.fsw._symlinkPaths.set(sysPath.resolve(path22), targetPath);
31302
+ this.fsw._symlinkPaths.set(sysPath.resolve(path23), targetPath);
31234
31303
  }
31235
31304
  } else {
31236
31305
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
31237
31306
  }
31238
31307
  ready();
31239
31308
  if (closer)
31240
- this.fsw._addPathCloser(path22, closer);
31309
+ this.fsw._addPathCloser(path23, closer);
31241
31310
  return false;
31242
31311
  } catch (error40) {
31243
31312
  if (this.fsw._handleError(error40)) {
31244
31313
  ready();
31245
- return path22;
31314
+ return path23;
31246
31315
  }
31247
31316
  }
31248
31317
  }
@@ -31285,26 +31354,26 @@ function createPattern(matcher) {
31285
31354
  }
31286
31355
  return () => false;
31287
31356
  }
31288
- function normalizePath(path22) {
31289
- if (typeof path22 !== "string")
31357
+ function normalizePath(path23) {
31358
+ if (typeof path23 !== "string")
31290
31359
  throw new Error("string expected");
31291
- path22 = sysPath2.normalize(path22);
31292
- path22 = path22.replace(/\\/g, "/");
31360
+ path23 = sysPath2.normalize(path23);
31361
+ path23 = path23.replace(/\\/g, "/");
31293
31362
  let prepend = false;
31294
- if (path22.startsWith("//"))
31363
+ if (path23.startsWith("//"))
31295
31364
  prepend = true;
31296
31365
  const DOUBLE_SLASH_RE2 = /\/\//;
31297
- while (path22.match(DOUBLE_SLASH_RE2))
31298
- path22 = path22.replace(DOUBLE_SLASH_RE2, "/");
31366
+ while (path23.match(DOUBLE_SLASH_RE2))
31367
+ path23 = path23.replace(DOUBLE_SLASH_RE2, "/");
31299
31368
  if (prepend)
31300
- path22 = "/" + path22;
31301
- return path22;
31369
+ path23 = "/" + path23;
31370
+ return path23;
31302
31371
  }
31303
31372
  function matchPatterns(patterns, testString, stats) {
31304
- const path22 = normalizePath(testString);
31373
+ const path23 = normalizePath(testString);
31305
31374
  for (let index = 0; index < patterns.length; index++) {
31306
31375
  const pattern = patterns[index];
31307
- if (pattern(path22, stats)) {
31376
+ if (pattern(path23, stats)) {
31308
31377
  return true;
31309
31378
  }
31310
31379
  }
@@ -31344,19 +31413,19 @@ var toUnix = (string4) => {
31344
31413
  }
31345
31414
  return str;
31346
31415
  };
31347
- var normalizePathToUnix = (path22) => toUnix(sysPath2.normalize(toUnix(path22)));
31348
- var normalizeIgnored = (cwd3 = "") => (path22) => {
31349
- if (typeof path22 === "string") {
31350
- return normalizePathToUnix(sysPath2.isAbsolute(path22) ? path22 : sysPath2.join(cwd3, path22));
31416
+ var normalizePathToUnix = (path23) => toUnix(sysPath2.normalize(toUnix(path23)));
31417
+ var normalizeIgnored = (cwd3 = "") => (path23) => {
31418
+ if (typeof path23 === "string") {
31419
+ return normalizePathToUnix(sysPath2.isAbsolute(path23) ? path23 : sysPath2.join(cwd3, path23));
31351
31420
  } else {
31352
- return path22;
31421
+ return path23;
31353
31422
  }
31354
31423
  };
31355
- var getAbsolutePath = (path22, cwd3) => {
31356
- if (sysPath2.isAbsolute(path22)) {
31357
- return path22;
31424
+ var getAbsolutePath = (path23, cwd3) => {
31425
+ if (sysPath2.isAbsolute(path23)) {
31426
+ return path23;
31358
31427
  }
31359
- return sysPath2.join(cwd3, path22);
31428
+ return sysPath2.join(cwd3, path23);
31360
31429
  };
31361
31430
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
31362
31431
  var DirEntry = class {
@@ -31411,10 +31480,10 @@ var DirEntry = class {
31411
31480
  var STAT_METHOD_F = "stat";
31412
31481
  var STAT_METHOD_L = "lstat";
31413
31482
  var WatchHelper = class {
31414
- constructor(path22, follow, fsw) {
31483
+ constructor(path23, follow, fsw) {
31415
31484
  this.fsw = fsw;
31416
- const watchPath = path22;
31417
- this.path = path22 = path22.replace(REPLACER_RE, "");
31485
+ const watchPath = path23;
31486
+ this.path = path23 = path23.replace(REPLACER_RE, "");
31418
31487
  this.watchPath = watchPath;
31419
31488
  this.fullWatchPath = sysPath2.resolve(watchPath);
31420
31489
  this.dirParts = [];
@@ -31536,20 +31605,20 @@ var FSWatcher = class extends EventEmitter2 {
31536
31605
  this._closePromise = void 0;
31537
31606
  let paths = unifyPaths(paths_);
31538
31607
  if (cwd3) {
31539
- paths = paths.map((path22) => {
31540
- const absPath = getAbsolutePath(path22, cwd3);
31608
+ paths = paths.map((path23) => {
31609
+ const absPath = getAbsolutePath(path23, cwd3);
31541
31610
  return absPath;
31542
31611
  });
31543
31612
  }
31544
- paths.forEach((path22) => {
31545
- this._removeIgnoredPath(path22);
31613
+ paths.forEach((path23) => {
31614
+ this._removeIgnoredPath(path23);
31546
31615
  });
31547
31616
  this._userIgnored = void 0;
31548
31617
  if (!this._readyCount)
31549
31618
  this._readyCount = 0;
31550
31619
  this._readyCount += paths.length;
31551
- Promise.all(paths.map(async (path22) => {
31552
- const res = await this._nodeFsHandler._addToNodeFs(path22, !_internal, void 0, 0, _origAdd);
31620
+ Promise.all(paths.map(async (path23) => {
31621
+ const res = await this._nodeFsHandler._addToNodeFs(path23, !_internal, void 0, 0, _origAdd);
31553
31622
  if (res)
31554
31623
  this._emitReady();
31555
31624
  return res;
@@ -31571,17 +31640,17 @@ var FSWatcher = class extends EventEmitter2 {
31571
31640
  return this;
31572
31641
  const paths = unifyPaths(paths_);
31573
31642
  const { cwd: cwd3 } = this.options;
31574
- paths.forEach((path22) => {
31575
- if (!sysPath2.isAbsolute(path22) && !this._closers.has(path22)) {
31643
+ paths.forEach((path23) => {
31644
+ if (!sysPath2.isAbsolute(path23) && !this._closers.has(path23)) {
31576
31645
  if (cwd3)
31577
- path22 = sysPath2.join(cwd3, path22);
31578
- path22 = sysPath2.resolve(path22);
31646
+ path23 = sysPath2.join(cwd3, path23);
31647
+ path23 = sysPath2.resolve(path23);
31579
31648
  }
31580
- this._closePath(path22);
31581
- this._addIgnoredPath(path22);
31582
- if (this._watched.has(path22)) {
31649
+ this._closePath(path23);
31650
+ this._addIgnoredPath(path23);
31651
+ if (this._watched.has(path23)) {
31583
31652
  this._addIgnoredPath({
31584
- path: path22,
31653
+ path: path23,
31585
31654
  recursive: true
31586
31655
  });
31587
31656
  }
@@ -31645,38 +31714,38 @@ var FSWatcher = class extends EventEmitter2 {
31645
31714
  * @param stats arguments to be passed with event
31646
31715
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
31647
31716
  */
31648
- async _emit(event, path22, stats) {
31717
+ async _emit(event, path23, stats) {
31649
31718
  if (this.closed)
31650
31719
  return;
31651
31720
  const opts = this.options;
31652
31721
  if (isWindows)
31653
- path22 = sysPath2.normalize(path22);
31722
+ path23 = sysPath2.normalize(path23);
31654
31723
  if (opts.cwd)
31655
- path22 = sysPath2.relative(opts.cwd, path22);
31656
- const args = [path22];
31724
+ path23 = sysPath2.relative(opts.cwd, path23);
31725
+ const args = [path23];
31657
31726
  if (stats != null)
31658
31727
  args.push(stats);
31659
31728
  const awf = opts.awaitWriteFinish;
31660
31729
  let pw;
31661
- if (awf && (pw = this._pendingWrites.get(path22))) {
31730
+ if (awf && (pw = this._pendingWrites.get(path23))) {
31662
31731
  pw.lastChange = /* @__PURE__ */ new Date();
31663
31732
  return this;
31664
31733
  }
31665
31734
  if (opts.atomic) {
31666
31735
  if (event === EVENTS.UNLINK) {
31667
- this._pendingUnlinks.set(path22, [event, ...args]);
31736
+ this._pendingUnlinks.set(path23, [event, ...args]);
31668
31737
  setTimeout(() => {
31669
- this._pendingUnlinks.forEach((entry, path23) => {
31738
+ this._pendingUnlinks.forEach((entry, path24) => {
31670
31739
  this.emit(...entry);
31671
31740
  this.emit(EVENTS.ALL, ...entry);
31672
- this._pendingUnlinks.delete(path23);
31741
+ this._pendingUnlinks.delete(path24);
31673
31742
  });
31674
31743
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
31675
31744
  return this;
31676
31745
  }
31677
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path22)) {
31746
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path23)) {
31678
31747
  event = EVENTS.CHANGE;
31679
- this._pendingUnlinks.delete(path22);
31748
+ this._pendingUnlinks.delete(path23);
31680
31749
  }
31681
31750
  }
31682
31751
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -31694,16 +31763,16 @@ var FSWatcher = class extends EventEmitter2 {
31694
31763
  this.emitWithAll(event, args);
31695
31764
  }
31696
31765
  };
31697
- this._awaitWriteFinish(path22, awf.stabilityThreshold, event, awfEmit);
31766
+ this._awaitWriteFinish(path23, awf.stabilityThreshold, event, awfEmit);
31698
31767
  return this;
31699
31768
  }
31700
31769
  if (event === EVENTS.CHANGE) {
31701
- const isThrottled = !this._throttle(EVENTS.CHANGE, path22, 50);
31770
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path23, 50);
31702
31771
  if (isThrottled)
31703
31772
  return this;
31704
31773
  }
31705
31774
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
31706
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path22) : path22;
31775
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path23) : path23;
31707
31776
  let stats2;
31708
31777
  try {
31709
31778
  stats2 = await stat3(fullPath);
@@ -31734,23 +31803,23 @@ var FSWatcher = class extends EventEmitter2 {
31734
31803
  * @param timeout duration of time to suppress duplicate actions
31735
31804
  * @returns tracking object or false if action should be suppressed
31736
31805
  */
31737
- _throttle(actionType, path22, timeout) {
31806
+ _throttle(actionType, path23, timeout) {
31738
31807
  if (!this._throttled.has(actionType)) {
31739
31808
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
31740
31809
  }
31741
31810
  const action = this._throttled.get(actionType);
31742
31811
  if (!action)
31743
31812
  throw new Error("invalid throttle");
31744
- const actionPath = action.get(path22);
31813
+ const actionPath = action.get(path23);
31745
31814
  if (actionPath) {
31746
31815
  actionPath.count++;
31747
31816
  return false;
31748
31817
  }
31749
31818
  let timeoutObject;
31750
31819
  const clear = () => {
31751
- const item = action.get(path22);
31820
+ const item = action.get(path23);
31752
31821
  const count = item ? item.count : 0;
31753
- action.delete(path22);
31822
+ action.delete(path23);
31754
31823
  clearTimeout(timeoutObject);
31755
31824
  if (item)
31756
31825
  clearTimeout(item.timeoutObject);
@@ -31758,7 +31827,7 @@ var FSWatcher = class extends EventEmitter2 {
31758
31827
  };
31759
31828
  timeoutObject = setTimeout(clear, timeout);
31760
31829
  const thr = { timeoutObject, clear, count: 0 };
31761
- action.set(path22, thr);
31830
+ action.set(path23, thr);
31762
31831
  return thr;
31763
31832
  }
31764
31833
  _incrReadyCount() {
@@ -31772,44 +31841,44 @@ var FSWatcher = class extends EventEmitter2 {
31772
31841
  * @param event
31773
31842
  * @param awfEmit Callback to be called when ready for event to be emitted.
31774
31843
  */
31775
- _awaitWriteFinish(path22, threshold, event, awfEmit) {
31844
+ _awaitWriteFinish(path23, threshold, event, awfEmit) {
31776
31845
  const awf = this.options.awaitWriteFinish;
31777
31846
  if (typeof awf !== "object")
31778
31847
  return;
31779
31848
  const pollInterval = awf.pollInterval;
31780
31849
  let timeoutHandler;
31781
- let fullPath = path22;
31782
- if (this.options.cwd && !sysPath2.isAbsolute(path22)) {
31783
- fullPath = sysPath2.join(this.options.cwd, path22);
31850
+ let fullPath = path23;
31851
+ if (this.options.cwd && !sysPath2.isAbsolute(path23)) {
31852
+ fullPath = sysPath2.join(this.options.cwd, path23);
31784
31853
  }
31785
31854
  const now = /* @__PURE__ */ new Date();
31786
31855
  const writes = this._pendingWrites;
31787
31856
  function awaitWriteFinishFn(prevStat) {
31788
31857
  statcb(fullPath, (err, curStat) => {
31789
- if (err || !writes.has(path22)) {
31858
+ if (err || !writes.has(path23)) {
31790
31859
  if (err && err.code !== "ENOENT")
31791
31860
  awfEmit(err);
31792
31861
  return;
31793
31862
  }
31794
31863
  const now2 = Number(/* @__PURE__ */ new Date());
31795
31864
  if (prevStat && curStat.size !== prevStat.size) {
31796
- writes.get(path22).lastChange = now2;
31865
+ writes.get(path23).lastChange = now2;
31797
31866
  }
31798
- const pw = writes.get(path22);
31867
+ const pw = writes.get(path23);
31799
31868
  const df = now2 - pw.lastChange;
31800
31869
  if (df >= threshold) {
31801
- writes.delete(path22);
31870
+ writes.delete(path23);
31802
31871
  awfEmit(void 0, curStat);
31803
31872
  } else {
31804
31873
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
31805
31874
  }
31806
31875
  });
31807
31876
  }
31808
- if (!writes.has(path22)) {
31809
- writes.set(path22, {
31877
+ if (!writes.has(path23)) {
31878
+ writes.set(path23, {
31810
31879
  lastChange: now,
31811
31880
  cancelWait: () => {
31812
- writes.delete(path22);
31881
+ writes.delete(path23);
31813
31882
  clearTimeout(timeoutHandler);
31814
31883
  return event;
31815
31884
  }
@@ -31820,8 +31889,8 @@ var FSWatcher = class extends EventEmitter2 {
31820
31889
  /**
31821
31890
  * Determines whether user has asked to ignore this path.
31822
31891
  */
31823
- _isIgnored(path22, stats) {
31824
- if (this.options.atomic && DOT_RE.test(path22))
31892
+ _isIgnored(path23, stats) {
31893
+ if (this.options.atomic && DOT_RE.test(path23))
31825
31894
  return true;
31826
31895
  if (!this._userIgnored) {
31827
31896
  const { cwd: cwd3 } = this.options;
@@ -31831,17 +31900,17 @@ var FSWatcher = class extends EventEmitter2 {
31831
31900
  const list = [...ignoredPaths.map(normalizeIgnored(cwd3)), ...ignored];
31832
31901
  this._userIgnored = anymatch(list, void 0);
31833
31902
  }
31834
- return this._userIgnored(path22, stats);
31903
+ return this._userIgnored(path23, stats);
31835
31904
  }
31836
- _isntIgnored(path22, stat4) {
31837
- return !this._isIgnored(path22, stat4);
31905
+ _isntIgnored(path23, stat4) {
31906
+ return !this._isIgnored(path23, stat4);
31838
31907
  }
31839
31908
  /**
31840
31909
  * Provides a set of common helpers and properties relating to symlink handling.
31841
31910
  * @param path file or directory pattern being watched
31842
31911
  */
31843
- _getWatchHelpers(path22) {
31844
- return new WatchHelper(path22, this.options.followSymlinks, this);
31912
+ _getWatchHelpers(path23) {
31913
+ return new WatchHelper(path23, this.options.followSymlinks, this);
31845
31914
  }
31846
31915
  // Directory helpers
31847
31916
  // -----------------
@@ -31873,63 +31942,63 @@ var FSWatcher = class extends EventEmitter2 {
31873
31942
  * @param item base path of item/directory
31874
31943
  */
31875
31944
  _remove(directory, item, isDirectory) {
31876
- const path22 = sysPath2.join(directory, item);
31877
- const fullPath = sysPath2.resolve(path22);
31878
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path22) || this._watched.has(fullPath);
31879
- if (!this._throttle("remove", path22, 100))
31945
+ const path23 = sysPath2.join(directory, item);
31946
+ const fullPath = sysPath2.resolve(path23);
31947
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path23) || this._watched.has(fullPath);
31948
+ if (!this._throttle("remove", path23, 100))
31880
31949
  return;
31881
31950
  if (!isDirectory && this._watched.size === 1) {
31882
31951
  this.add(directory, item, true);
31883
31952
  }
31884
- const wp = this._getWatchedDir(path22);
31953
+ const wp = this._getWatchedDir(path23);
31885
31954
  const nestedDirectoryChildren = wp.getChildren();
31886
- nestedDirectoryChildren.forEach((nested) => this._remove(path22, nested));
31955
+ nestedDirectoryChildren.forEach((nested) => this._remove(path23, nested));
31887
31956
  const parent = this._getWatchedDir(directory);
31888
31957
  const wasTracked = parent.has(item);
31889
31958
  parent.remove(item);
31890
31959
  if (this._symlinkPaths.has(fullPath)) {
31891
31960
  this._symlinkPaths.delete(fullPath);
31892
31961
  }
31893
- let relPath = path22;
31962
+ let relPath = path23;
31894
31963
  if (this.options.cwd)
31895
- relPath = sysPath2.relative(this.options.cwd, path22);
31964
+ relPath = sysPath2.relative(this.options.cwd, path23);
31896
31965
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
31897
31966
  const event = this._pendingWrites.get(relPath).cancelWait();
31898
31967
  if (event === EVENTS.ADD)
31899
31968
  return;
31900
31969
  }
31901
- this._watched.delete(path22);
31970
+ this._watched.delete(path23);
31902
31971
  this._watched.delete(fullPath);
31903
31972
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
31904
- if (wasTracked && !this._isIgnored(path22))
31905
- this._emit(eventName, path22);
31906
- this._closePath(path22);
31973
+ if (wasTracked && !this._isIgnored(path23))
31974
+ this._emit(eventName, path23);
31975
+ this._closePath(path23);
31907
31976
  }
31908
31977
  /**
31909
31978
  * Closes all watchers for a path
31910
31979
  */
31911
- _closePath(path22) {
31912
- this._closeFile(path22);
31913
- const dir = sysPath2.dirname(path22);
31914
- this._getWatchedDir(dir).remove(sysPath2.basename(path22));
31980
+ _closePath(path23) {
31981
+ this._closeFile(path23);
31982
+ const dir = sysPath2.dirname(path23);
31983
+ this._getWatchedDir(dir).remove(sysPath2.basename(path23));
31915
31984
  }
31916
31985
  /**
31917
31986
  * Closes only file-specific watchers
31918
31987
  */
31919
- _closeFile(path22) {
31920
- const closers = this._closers.get(path22);
31988
+ _closeFile(path23) {
31989
+ const closers = this._closers.get(path23);
31921
31990
  if (!closers)
31922
31991
  return;
31923
31992
  closers.forEach((closer) => closer());
31924
- this._closers.delete(path22);
31993
+ this._closers.delete(path23);
31925
31994
  }
31926
- _addPathCloser(path22, closer) {
31995
+ _addPathCloser(path23, closer) {
31927
31996
  if (!closer)
31928
31997
  return;
31929
- let list = this._closers.get(path22);
31998
+ let list = this._closers.get(path23);
31930
31999
  if (!list) {
31931
32000
  list = [];
31932
- this._closers.set(path22, list);
32001
+ this._closers.set(path23, list);
31933
32002
  }
31934
32003
  list.push(closer);
31935
32004
  }
@@ -31968,7 +32037,7 @@ function shouldIgnoreRelative(rel) {
31968
32037
  return false;
31969
32038
  }
31970
32039
  function startFileIndexWatcher(cwd3 = process.cwd()) {
31971
- const resolved = path21.resolve(cwd3);
32040
+ const resolved = path22.resolve(cwd3);
31972
32041
  let timer = null;
31973
32042
  const runRebuild = () => {
31974
32043
  try {
@@ -31989,7 +32058,7 @@ function startFileIndexWatcher(cwd3 = process.cwd()) {
31989
32058
  ignoreInitial: true,
31990
32059
  persistent: true,
31991
32060
  ignored: (p) => {
31992
- const rel = path21.isAbsolute(p) ? path21.relative(resolved, p).replace(/\\/g, "/") : p.replace(/\\/g, "/");
32061
+ const rel = path22.isAbsolute(p) ? path22.relative(resolved, p).replace(/\\/g, "/") : p.replace(/\\/g, "/");
31993
32062
  return shouldIgnoreRelative(rel || ".");
31994
32063
  },
31995
32064
  awaitWriteFinish: { stabilityThreshold: 250, pollInterval: 100 }