@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/README.md +1 -1
- package/dist/cli.js +386 -319
- package/dist/cli.js.map +4 -4
- package/dist/index.js +393 -324
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -973,7 +973,7 @@ var require_command = __commonJS({
|
|
|
973
973
|
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
|
|
974
974
|
var EventEmitter3 = __require("node:events").EventEmitter;
|
|
975
975
|
var childProcess = __require("node:child_process");
|
|
976
|
-
var
|
|
976
|
+
var path24 = __require("node:path");
|
|
977
977
|
var fs15 = __require("node:fs");
|
|
978
978
|
var process2 = __require("node:process");
|
|
979
979
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1906,9 +1906,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1906
1906
|
let launchWithNode = false;
|
|
1907
1907
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1908
1908
|
function findFile(baseDir, baseName) {
|
|
1909
|
-
const localBin =
|
|
1909
|
+
const localBin = path24.resolve(baseDir, baseName);
|
|
1910
1910
|
if (fs15.existsSync(localBin)) return localBin;
|
|
1911
|
-
if (sourceExt.includes(
|
|
1911
|
+
if (sourceExt.includes(path24.extname(baseName))) return void 0;
|
|
1912
1912
|
const foundExt = sourceExt.find(
|
|
1913
1913
|
(ext) => fs15.existsSync(`${localBin}${ext}`)
|
|
1914
1914
|
);
|
|
@@ -1926,17 +1926,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1926
1926
|
} catch (err) {
|
|
1927
1927
|
resolvedScriptPath = this._scriptPath;
|
|
1928
1928
|
}
|
|
1929
|
-
executableDir =
|
|
1930
|
-
|
|
1929
|
+
executableDir = path24.resolve(
|
|
1930
|
+
path24.dirname(resolvedScriptPath),
|
|
1931
1931
|
executableDir
|
|
1932
1932
|
);
|
|
1933
1933
|
}
|
|
1934
1934
|
if (executableDir) {
|
|
1935
1935
|
let localFile = findFile(executableDir, executableFile);
|
|
1936
1936
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1937
|
-
const legacyName =
|
|
1937
|
+
const legacyName = path24.basename(
|
|
1938
1938
|
this._scriptPath,
|
|
1939
|
-
|
|
1939
|
+
path24.extname(this._scriptPath)
|
|
1940
1940
|
);
|
|
1941
1941
|
if (legacyName !== this._name) {
|
|
1942
1942
|
localFile = findFile(
|
|
@@ -1947,7 +1947,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1947
1947
|
}
|
|
1948
1948
|
executableFile = localFile || executableFile;
|
|
1949
1949
|
}
|
|
1950
|
-
launchWithNode = sourceExt.includes(
|
|
1950
|
+
launchWithNode = sourceExt.includes(path24.extname(executableFile));
|
|
1951
1951
|
let proc;
|
|
1952
1952
|
if (process2.platform !== "win32") {
|
|
1953
1953
|
if (launchWithNode) {
|
|
@@ -2787,7 +2787,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2787
2787
|
* @return {Command}
|
|
2788
2788
|
*/
|
|
2789
2789
|
nameFromFilename(filename) {
|
|
2790
|
-
this._name =
|
|
2790
|
+
this._name = path24.basename(filename, path24.extname(filename));
|
|
2791
2791
|
return this;
|
|
2792
2792
|
}
|
|
2793
2793
|
/**
|
|
@@ -2801,9 +2801,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2801
2801
|
* @param {string} [path]
|
|
2802
2802
|
* @return {(string|null|Command)}
|
|
2803
2803
|
*/
|
|
2804
|
-
executableDir(
|
|
2805
|
-
if (
|
|
2806
|
-
this._executableDir =
|
|
2804
|
+
executableDir(path25) {
|
|
2805
|
+
if (path25 === void 0) return this._executableDir;
|
|
2806
|
+
this._executableDir = path25;
|
|
2807
2807
|
return this;
|
|
2808
2808
|
}
|
|
2809
2809
|
/**
|
|
@@ -7423,10 +7423,10 @@ var require_src2 = __commonJS({
|
|
|
7423
7423
|
var fs_1 = __require("fs");
|
|
7424
7424
|
var debug_1 = __importDefault(require_src());
|
|
7425
7425
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
7426
|
-
function check2(
|
|
7427
|
-
log2(`checking %s`,
|
|
7426
|
+
function check2(path24, isFile, isDirectory) {
|
|
7427
|
+
log2(`checking %s`, path24);
|
|
7428
7428
|
try {
|
|
7429
|
-
const stat4 = fs_1.statSync(
|
|
7429
|
+
const stat4 = fs_1.statSync(path24);
|
|
7430
7430
|
if (stat4.isFile() && isFile) {
|
|
7431
7431
|
log2(`[OK] path represents a file`);
|
|
7432
7432
|
return true;
|
|
@@ -7446,8 +7446,8 @@ var require_src2 = __commonJS({
|
|
|
7446
7446
|
throw e;
|
|
7447
7447
|
}
|
|
7448
7448
|
}
|
|
7449
|
-
function exists2(
|
|
7450
|
-
return check2(
|
|
7449
|
+
function exists2(path24, type = exports.READABLE) {
|
|
7450
|
+
return check2(path24, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
7451
7451
|
}
|
|
7452
7452
|
exports.exists = exists2;
|
|
7453
7453
|
exports.FILE = 1;
|
|
@@ -7922,8 +7922,8 @@ var init_parseUtil = __esm({
|
|
|
7922
7922
|
init_errors();
|
|
7923
7923
|
init_en();
|
|
7924
7924
|
makeIssue = (params) => {
|
|
7925
|
-
const { data, path:
|
|
7926
|
-
const fullPath = [...
|
|
7925
|
+
const { data, path: path24, errorMaps, issueData } = params;
|
|
7926
|
+
const fullPath = [...path24, ...issueData.path || []];
|
|
7927
7927
|
const fullIssue = {
|
|
7928
7928
|
...issueData,
|
|
7929
7929
|
path: fullPath
|
|
@@ -8231,11 +8231,11 @@ var init_types = __esm({
|
|
|
8231
8231
|
init_parseUtil();
|
|
8232
8232
|
init_util2();
|
|
8233
8233
|
ParseInputLazyPath = class {
|
|
8234
|
-
constructor(parent, value,
|
|
8234
|
+
constructor(parent, value, path24, key) {
|
|
8235
8235
|
this._cachedPath = [];
|
|
8236
8236
|
this.parent = parent;
|
|
8237
8237
|
this.data = value;
|
|
8238
|
-
this._path =
|
|
8238
|
+
this._path = path24;
|
|
8239
8239
|
this._key = key;
|
|
8240
8240
|
}
|
|
8241
8241
|
get path() {
|
|
@@ -11850,10 +11850,10 @@ function assignProp(target, prop, value) {
|
|
|
11850
11850
|
configurable: true
|
|
11851
11851
|
});
|
|
11852
11852
|
}
|
|
11853
|
-
function getElementAtPath(obj,
|
|
11854
|
-
if (!
|
|
11853
|
+
function getElementAtPath(obj, path24) {
|
|
11854
|
+
if (!path24)
|
|
11855
11855
|
return obj;
|
|
11856
|
-
return
|
|
11856
|
+
return path24.reduce((acc, key) => acc?.[key], obj);
|
|
11857
11857
|
}
|
|
11858
11858
|
function promiseAllObject(promisesObj) {
|
|
11859
11859
|
const keys = Object.keys(promisesObj);
|
|
@@ -12102,11 +12102,11 @@ function aborted(x, startIndex = 0) {
|
|
|
12102
12102
|
}
|
|
12103
12103
|
return false;
|
|
12104
12104
|
}
|
|
12105
|
-
function prefixIssues(
|
|
12105
|
+
function prefixIssues(path24, issues) {
|
|
12106
12106
|
return issues.map((iss) => {
|
|
12107
12107
|
var _a2;
|
|
12108
12108
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
12109
|
-
iss.path.unshift(
|
|
12109
|
+
iss.path.unshift(path24);
|
|
12110
12110
|
return iss;
|
|
12111
12111
|
});
|
|
12112
12112
|
}
|
|
@@ -12295,7 +12295,7 @@ function treeifyError(error40, _mapper) {
|
|
|
12295
12295
|
return issue2.message;
|
|
12296
12296
|
};
|
|
12297
12297
|
const result = { errors: [] };
|
|
12298
|
-
const processError = (error41,
|
|
12298
|
+
const processError = (error41, path24 = []) => {
|
|
12299
12299
|
var _a2, _b;
|
|
12300
12300
|
for (const issue2 of error41.issues) {
|
|
12301
12301
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -12305,7 +12305,7 @@ function treeifyError(error40, _mapper) {
|
|
|
12305
12305
|
} else if (issue2.code === "invalid_element") {
|
|
12306
12306
|
processError({ issues: issue2.issues }, issue2.path);
|
|
12307
12307
|
} else {
|
|
12308
|
-
const fullpath = [...
|
|
12308
|
+
const fullpath = [...path24, ...issue2.path];
|
|
12309
12309
|
if (fullpath.length === 0) {
|
|
12310
12310
|
result.errors.push(mapper(issue2));
|
|
12311
12311
|
continue;
|
|
@@ -12335,9 +12335,9 @@ function treeifyError(error40, _mapper) {
|
|
|
12335
12335
|
processError(error40);
|
|
12336
12336
|
return result;
|
|
12337
12337
|
}
|
|
12338
|
-
function toDotPath(
|
|
12338
|
+
function toDotPath(path24) {
|
|
12339
12339
|
const segs = [];
|
|
12340
|
-
for (const seg of
|
|
12340
|
+
for (const seg of path24) {
|
|
12341
12341
|
if (typeof seg === "number")
|
|
12342
12342
|
segs.push(`[${seg}]`);
|
|
12343
12343
|
else if (typeof seg === "symbol")
|
|
@@ -25047,7 +25047,7 @@ var init_acp = __esm({
|
|
|
25047
25047
|
});
|
|
25048
25048
|
|
|
25049
25049
|
// src/cli.ts
|
|
25050
|
-
import * as
|
|
25050
|
+
import * as path23 from "node:path";
|
|
25051
25051
|
|
|
25052
25052
|
// ../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
|
|
25053
25053
|
var import_index = __toESM(require_commander(), 1);
|
|
@@ -25387,8 +25387,8 @@ function randomSecret() {
|
|
|
25387
25387
|
}
|
|
25388
25388
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
25389
25389
|
}
|
|
25390
|
-
async function requestPreviewApi(port, secret, method,
|
|
25391
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
25390
|
+
async function requestPreviewApi(port, secret, method, path24, body) {
|
|
25391
|
+
const url2 = `http://127.0.0.1:${port}${path24}`;
|
|
25392
25392
|
const headers = {
|
|
25393
25393
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
25394
25394
|
"Content-Type": "application/json"
|
|
@@ -25400,7 +25400,7 @@ async function requestPreviewApi(port, secret, method, path23, body) {
|
|
|
25400
25400
|
});
|
|
25401
25401
|
const data = await res.json().catch(() => ({}));
|
|
25402
25402
|
if (!res.ok) {
|
|
25403
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
25403
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path24}: ${res.status}`);
|
|
25404
25404
|
}
|
|
25405
25405
|
return data;
|
|
25406
25406
|
}
|
|
@@ -25654,8 +25654,8 @@ function pathspec(...paths) {
|
|
|
25654
25654
|
cache.set(key, paths);
|
|
25655
25655
|
return key;
|
|
25656
25656
|
}
|
|
25657
|
-
function isPathSpec(
|
|
25658
|
-
return
|
|
25657
|
+
function isPathSpec(path24) {
|
|
25658
|
+
return path24 instanceof String && cache.has(path24);
|
|
25659
25659
|
}
|
|
25660
25660
|
function toPaths(pathSpec) {
|
|
25661
25661
|
return cache.get(pathSpec) || [];
|
|
@@ -25744,8 +25744,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
25744
25744
|
function forEachLineWithContent(input, callback) {
|
|
25745
25745
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
25746
25746
|
}
|
|
25747
|
-
function folderExists(
|
|
25748
|
-
return (0, import_file_exists.exists)(
|
|
25747
|
+
function folderExists(path24) {
|
|
25748
|
+
return (0, import_file_exists.exists)(path24, import_file_exists.FOLDER);
|
|
25749
25749
|
}
|
|
25750
25750
|
function append(target, item) {
|
|
25751
25751
|
if (Array.isArray(target)) {
|
|
@@ -26149,8 +26149,8 @@ function checkIsRepoRootTask() {
|
|
|
26149
26149
|
commands,
|
|
26150
26150
|
format: "utf-8",
|
|
26151
26151
|
onError,
|
|
26152
|
-
parser(
|
|
26153
|
-
return /^\.(git)?$/.test(
|
|
26152
|
+
parser(path24) {
|
|
26153
|
+
return /^\.(git)?$/.test(path24.trim());
|
|
26154
26154
|
}
|
|
26155
26155
|
};
|
|
26156
26156
|
}
|
|
@@ -26584,11 +26584,11 @@ function parseGrep(grep) {
|
|
|
26584
26584
|
const paths = /* @__PURE__ */ new Set();
|
|
26585
26585
|
const results = {};
|
|
26586
26586
|
forEachLineWithContent(grep, (input) => {
|
|
26587
|
-
const [
|
|
26588
|
-
paths.add(
|
|
26589
|
-
(results[
|
|
26587
|
+
const [path24, line, preview] = input.split(NULL);
|
|
26588
|
+
paths.add(path24);
|
|
26589
|
+
(results[path24] = results[path24] || []).push({
|
|
26590
26590
|
line: asNumber(line),
|
|
26591
|
-
path:
|
|
26591
|
+
path: path24,
|
|
26592
26592
|
preview
|
|
26593
26593
|
});
|
|
26594
26594
|
});
|
|
@@ -27353,14 +27353,14 @@ var init_hash_object = __esm2({
|
|
|
27353
27353
|
init_task();
|
|
27354
27354
|
}
|
|
27355
27355
|
});
|
|
27356
|
-
function parseInit(bare,
|
|
27356
|
+
function parseInit(bare, path24, text) {
|
|
27357
27357
|
const response = String(text).trim();
|
|
27358
27358
|
let result;
|
|
27359
27359
|
if (result = initResponseRegex.exec(response)) {
|
|
27360
|
-
return new InitSummary(bare,
|
|
27360
|
+
return new InitSummary(bare, path24, false, result[1]);
|
|
27361
27361
|
}
|
|
27362
27362
|
if (result = reInitResponseRegex.exec(response)) {
|
|
27363
|
-
return new InitSummary(bare,
|
|
27363
|
+
return new InitSummary(bare, path24, true, result[1]);
|
|
27364
27364
|
}
|
|
27365
27365
|
let gitDir = "";
|
|
27366
27366
|
const tokens = response.split(" ");
|
|
@@ -27371,7 +27371,7 @@ function parseInit(bare, path23, text) {
|
|
|
27371
27371
|
break;
|
|
27372
27372
|
}
|
|
27373
27373
|
}
|
|
27374
|
-
return new InitSummary(bare,
|
|
27374
|
+
return new InitSummary(bare, path24, /^re/i.test(response), gitDir);
|
|
27375
27375
|
}
|
|
27376
27376
|
var InitSummary;
|
|
27377
27377
|
var initResponseRegex;
|
|
@@ -27380,9 +27380,9 @@ var init_InitSummary = __esm2({
|
|
|
27380
27380
|
"src/lib/responses/InitSummary.ts"() {
|
|
27381
27381
|
"use strict";
|
|
27382
27382
|
InitSummary = class {
|
|
27383
|
-
constructor(bare,
|
|
27383
|
+
constructor(bare, path24, existing, gitDir) {
|
|
27384
27384
|
this.bare = bare;
|
|
27385
|
-
this.path =
|
|
27385
|
+
this.path = path24;
|
|
27386
27386
|
this.existing = existing;
|
|
27387
27387
|
this.gitDir = gitDir;
|
|
27388
27388
|
}
|
|
@@ -27394,7 +27394,7 @@ var init_InitSummary = __esm2({
|
|
|
27394
27394
|
function hasBareCommand(command) {
|
|
27395
27395
|
return command.includes(bareCommand);
|
|
27396
27396
|
}
|
|
27397
|
-
function initTask(bare = false,
|
|
27397
|
+
function initTask(bare = false, path24, customArgs) {
|
|
27398
27398
|
const commands = ["init", ...customArgs];
|
|
27399
27399
|
if (bare && !hasBareCommand(commands)) {
|
|
27400
27400
|
commands.splice(1, 0, bareCommand);
|
|
@@ -27403,7 +27403,7 @@ function initTask(bare = false, path23, customArgs) {
|
|
|
27403
27403
|
commands,
|
|
27404
27404
|
format: "utf-8",
|
|
27405
27405
|
parser(text) {
|
|
27406
|
-
return parseInit(commands.includes("--bare"),
|
|
27406
|
+
return parseInit(commands.includes("--bare"), path24, text);
|
|
27407
27407
|
}
|
|
27408
27408
|
};
|
|
27409
27409
|
}
|
|
@@ -28219,12 +28219,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
28219
28219
|
"use strict";
|
|
28220
28220
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
28221
28221
|
FileStatusSummary = class {
|
|
28222
|
-
constructor(
|
|
28223
|
-
this.path =
|
|
28222
|
+
constructor(path24, index, working_dir) {
|
|
28223
|
+
this.path = path24;
|
|
28224
28224
|
this.index = index;
|
|
28225
28225
|
this.working_dir = working_dir;
|
|
28226
28226
|
if (index === "R" || working_dir === "R") {
|
|
28227
|
-
const detail = fromPathRegex.exec(
|
|
28227
|
+
const detail = fromPathRegex.exec(path24) || [null, path24, path24];
|
|
28228
28228
|
this.from = detail[2] || "";
|
|
28229
28229
|
this.path = detail[1] || "";
|
|
28230
28230
|
}
|
|
@@ -28255,14 +28255,14 @@ function splitLine(result, lineStr) {
|
|
|
28255
28255
|
default:
|
|
28256
28256
|
return;
|
|
28257
28257
|
}
|
|
28258
|
-
function data(index, workingDir,
|
|
28258
|
+
function data(index, workingDir, path24) {
|
|
28259
28259
|
const raw = `${index}${workingDir}`;
|
|
28260
28260
|
const handler = parsers6.get(raw);
|
|
28261
28261
|
if (handler) {
|
|
28262
|
-
handler(result,
|
|
28262
|
+
handler(result, path24);
|
|
28263
28263
|
}
|
|
28264
28264
|
if (raw !== "##" && raw !== "!!") {
|
|
28265
|
-
result.files.push(new FileStatusSummary(
|
|
28265
|
+
result.files.push(new FileStatusSummary(path24, index, workingDir));
|
|
28266
28266
|
}
|
|
28267
28267
|
}
|
|
28268
28268
|
}
|
|
@@ -28571,9 +28571,9 @@ var init_simple_git_api = __esm2({
|
|
|
28571
28571
|
next
|
|
28572
28572
|
);
|
|
28573
28573
|
}
|
|
28574
|
-
hashObject(
|
|
28574
|
+
hashObject(path24, write) {
|
|
28575
28575
|
return this._runTask(
|
|
28576
|
-
hashObjectTask(
|
|
28576
|
+
hashObjectTask(path24, write === true),
|
|
28577
28577
|
trailingFunctionArgument(arguments)
|
|
28578
28578
|
);
|
|
28579
28579
|
}
|
|
@@ -28926,8 +28926,8 @@ var init_branch = __esm2({
|
|
|
28926
28926
|
}
|
|
28927
28927
|
});
|
|
28928
28928
|
function toPath(input) {
|
|
28929
|
-
const
|
|
28930
|
-
return
|
|
28929
|
+
const path24 = input.trim().replace(/^["']|["']$/g, "");
|
|
28930
|
+
return path24 && normalize(path24);
|
|
28931
28931
|
}
|
|
28932
28932
|
var parseCheckIgnore;
|
|
28933
28933
|
var init_CheckIgnore = __esm2({
|
|
@@ -29241,8 +29241,8 @@ __export2(sub_module_exports, {
|
|
|
29241
29241
|
subModuleTask: () => subModuleTask,
|
|
29242
29242
|
updateSubModuleTask: () => updateSubModuleTask
|
|
29243
29243
|
});
|
|
29244
|
-
function addSubModuleTask(repo,
|
|
29245
|
-
return subModuleTask(["add", repo,
|
|
29244
|
+
function addSubModuleTask(repo, path24) {
|
|
29245
|
+
return subModuleTask(["add", repo, path24]);
|
|
29246
29246
|
}
|
|
29247
29247
|
function initSubModuleTask(customArgs) {
|
|
29248
29248
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -29575,8 +29575,8 @@ var require_git = __commonJS2({
|
|
|
29575
29575
|
}
|
|
29576
29576
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
29577
29577
|
};
|
|
29578
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
29579
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
29578
|
+
Git2.prototype.submoduleAdd = function(repo, path24, then) {
|
|
29579
|
+
return this._runTask(addSubModuleTask2(repo, path24), trailingFunctionArgument2(arguments));
|
|
29580
29580
|
};
|
|
29581
29581
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
29582
29582
|
return this._runTask(
|
|
@@ -30614,6 +30614,34 @@ async function collectSessionDiffAndNotify(options) {
|
|
|
30614
30614
|
}
|
|
30615
30615
|
}
|
|
30616
30616
|
|
|
30617
|
+
// src/acp/format-acp-rpc-error.ts
|
|
30618
|
+
function formatAcpRpcError(err) {
|
|
30619
|
+
if (err instanceof Error) return err.message;
|
|
30620
|
+
if (err != null && typeof err === "object") {
|
|
30621
|
+
const o = err;
|
|
30622
|
+
if (typeof o.message === "string") {
|
|
30623
|
+
const code = typeof o.code === "number" ? ` (code ${o.code})` : "";
|
|
30624
|
+
return `${o.message}${code}`;
|
|
30625
|
+
}
|
|
30626
|
+
}
|
|
30627
|
+
if (typeof err === "string") return err;
|
|
30628
|
+
try {
|
|
30629
|
+
return JSON.stringify(err);
|
|
30630
|
+
} catch {
|
|
30631
|
+
return String(err);
|
|
30632
|
+
}
|
|
30633
|
+
}
|
|
30634
|
+
function isAcpAuthenticationRequiredError(err) {
|
|
30635
|
+
if (err == null || typeof err !== "object") return false;
|
|
30636
|
+
const o = err;
|
|
30637
|
+
if (o.code === -32e3 && typeof o.message === "string") {
|
|
30638
|
+
const m2 = o.message.toLowerCase();
|
|
30639
|
+
if (m2.includes("authentication") || m2.includes("auth")) return true;
|
|
30640
|
+
}
|
|
30641
|
+
const m = typeof o.message === "string" ? o.message.toLowerCase() : "";
|
|
30642
|
+
return m.includes("authentication required") || m.includes("auth_required");
|
|
30643
|
+
}
|
|
30644
|
+
|
|
30617
30645
|
// src/acp/send-prompt-to-agent.ts
|
|
30618
30646
|
async function sendPromptToAgent(options) {
|
|
30619
30647
|
const {
|
|
@@ -30625,6 +30653,7 @@ async function sendPromptToAgent(options) {
|
|
|
30625
30653
|
sendResult,
|
|
30626
30654
|
sendSessionUpdate,
|
|
30627
30655
|
collectSessionDiffAfterTurn,
|
|
30656
|
+
agentType,
|
|
30628
30657
|
log: log2
|
|
30629
30658
|
} = options;
|
|
30630
30659
|
log2("[prompt] Sending to agent\u2026");
|
|
@@ -30638,7 +30667,12 @@ async function sendPromptToAgent(options) {
|
|
|
30638
30667
|
id: promptId,
|
|
30639
30668
|
...sessionId ? { sessionId } : {},
|
|
30640
30669
|
...runId ? { runId } : {},
|
|
30641
|
-
|
|
30670
|
+
success: result.success,
|
|
30671
|
+
...typeof result.stopReason === "string" ? { stopReason: result.stopReason } : {},
|
|
30672
|
+
...typeof result.output === "string" ? { output: result.output } : {},
|
|
30673
|
+
...typeof result.error === "string" ? { error: result.error } : {},
|
|
30674
|
+
...result.authRequired ? { authRequired: true } : {},
|
|
30675
|
+
...agentType ? { agentType } : {}
|
|
30642
30676
|
});
|
|
30643
30677
|
if (result.success) {
|
|
30644
30678
|
const out = result.output ?? "";
|
|
@@ -30646,10 +30680,11 @@ async function sendPromptToAgent(options) {
|
|
|
30646
30680
|
log2(`[prompt] Done; sent response (${out.length} chars)`);
|
|
30647
30681
|
if (preview) log2(`[prompt] Response: ${preview}`);
|
|
30648
30682
|
} else {
|
|
30649
|
-
log2(`[prompt] Agent error: ${result.error}`);
|
|
30683
|
+
log2(`[prompt] Agent error: ${result.error ?? "(unknown)"}`);
|
|
30650
30684
|
}
|
|
30651
30685
|
} catch (err) {
|
|
30652
|
-
const errMsg =
|
|
30686
|
+
const errMsg = formatAcpRpcError(err);
|
|
30687
|
+
const authRequired = isAcpAuthenticationRequiredError(err);
|
|
30653
30688
|
log2(`[prompt] Send failed: ${errMsg}`);
|
|
30654
30689
|
if (err instanceof Error && err.stack) log2(`[prompt] ${err.stack}`);
|
|
30655
30690
|
sendResult({
|
|
@@ -30658,13 +30693,15 @@ async function sendPromptToAgent(options) {
|
|
|
30658
30693
|
...sessionId ? { sessionId } : {},
|
|
30659
30694
|
...runId ? { runId } : {},
|
|
30660
30695
|
success: false,
|
|
30661
|
-
error: errMsg
|
|
30696
|
+
error: errMsg,
|
|
30697
|
+
...authRequired ? { authRequired: true } : {},
|
|
30698
|
+
...agentType ? { agentType } : {}
|
|
30662
30699
|
});
|
|
30663
30700
|
}
|
|
30664
30701
|
}
|
|
30665
30702
|
|
|
30666
30703
|
// src/acp/ensure-acp-client.ts
|
|
30667
|
-
import * as
|
|
30704
|
+
import * as path9 from "node:path";
|
|
30668
30705
|
|
|
30669
30706
|
// src/error-message.ts
|
|
30670
30707
|
function errorMessage(err) {
|
|
@@ -30678,6 +30715,7 @@ function errorMessage(err) {
|
|
|
30678
30715
|
|
|
30679
30716
|
// src/acp/clients/acp-client.ts
|
|
30680
30717
|
import { spawn as spawn3 } from "node:child_process";
|
|
30718
|
+
import path5 from "node:path";
|
|
30681
30719
|
import { Readable, Writable } from "node:stream";
|
|
30682
30720
|
function formatSpawnError(err, command) {
|
|
30683
30721
|
if (err.code === "ENOENT") {
|
|
@@ -30685,17 +30723,10 @@ function formatSpawnError(err, command) {
|
|
|
30685
30723
|
}
|
|
30686
30724
|
return err.message || String(err);
|
|
30687
30725
|
}
|
|
30688
|
-
function toErrorMessage(err) {
|
|
30689
|
-
if (err instanceof Error) return err.message;
|
|
30690
|
-
if (err != null && typeof err === "object" && "message" in err)
|
|
30691
|
-
return String(err.message);
|
|
30692
|
-
if (typeof err === "string") return err;
|
|
30693
|
-
if (err != null && typeof err === "object") return JSON.stringify(err);
|
|
30694
|
-
return String(err);
|
|
30695
|
-
}
|
|
30696
30726
|
async function createAcpClient(options) {
|
|
30697
|
-
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
30727
|
+
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
30698
30728
|
const { command, cwd: cwd3 = process.cwd(), onSessionUpdate } = options;
|
|
30729
|
+
const sessionCwd = path5.resolve(cwd3);
|
|
30699
30730
|
const isWindows2 = process.platform === "win32";
|
|
30700
30731
|
const child = spawn3(command[0], command.slice(1), {
|
|
30701
30732
|
cwd: cwd3,
|
|
@@ -30726,11 +30757,13 @@ async function createAcpClient(options) {
|
|
|
30726
30757
|
child.kill();
|
|
30727
30758
|
});
|
|
30728
30759
|
await connection.initialize({
|
|
30729
|
-
protocolVersion:
|
|
30730
|
-
capabilities: {},
|
|
30760
|
+
protocolVersion: PROTOCOL_VERSION2,
|
|
30731
30761
|
clientInfo: { name: "buildautomaton-cli", version: "0.1.0" }
|
|
30732
30762
|
});
|
|
30733
|
-
const newSessionRes = await connection.newSession({
|
|
30763
|
+
const newSessionRes = await connection.newSession({
|
|
30764
|
+
cwd: sessionCwd,
|
|
30765
|
+
mcpServers: []
|
|
30766
|
+
});
|
|
30734
30767
|
const sessionId = newSessionRes.sessionId;
|
|
30735
30768
|
resolve17({
|
|
30736
30769
|
sessionId,
|
|
@@ -30738,7 +30771,7 @@ async function createAcpClient(options) {
|
|
|
30738
30771
|
try {
|
|
30739
30772
|
const response = await connection.prompt({
|
|
30740
30773
|
sessionId,
|
|
30741
|
-
prompt: { type: "text", text: prompt }
|
|
30774
|
+
prompt: [{ type: "text", text: prompt }]
|
|
30742
30775
|
});
|
|
30743
30776
|
const r = response;
|
|
30744
30777
|
const cancelled = (r?.stopReason ?? "").toLowerCase() === "cancelled";
|
|
@@ -30751,7 +30784,8 @@ async function createAcpClient(options) {
|
|
|
30751
30784
|
} catch (err) {
|
|
30752
30785
|
return {
|
|
30753
30786
|
success: false,
|
|
30754
|
-
error:
|
|
30787
|
+
error: formatAcpRpcError(err),
|
|
30788
|
+
...isAcpAuthenticationRequiredError(err) ? { authRequired: true } : {}
|
|
30755
30789
|
};
|
|
30756
30790
|
}
|
|
30757
30791
|
},
|
|
@@ -30769,12 +30803,23 @@ async function createAcpClient(options) {
|
|
|
30769
30803
|
});
|
|
30770
30804
|
} catch (err) {
|
|
30771
30805
|
child.kill();
|
|
30772
|
-
reject(new Error(
|
|
30806
|
+
reject(new Error(formatAcpRpcError(err)));
|
|
30773
30807
|
}
|
|
30774
30808
|
})();
|
|
30775
30809
|
});
|
|
30776
30810
|
}
|
|
30777
30811
|
|
|
30812
|
+
// src/acp/clients/claude-agent-acp-client.ts
|
|
30813
|
+
var DEFAULT_CLAUDE_AGENT_ACP_COMMAND = ["npx", "--yes", "@agentclientprotocol/claude-agent-acp"];
|
|
30814
|
+
function isClaudeAgentAcpCommand(command) {
|
|
30815
|
+
const i = command.indexOf("@agentclientprotocol/claude-agent-acp");
|
|
30816
|
+
return i >= 0 && (i === 0 || command[i - 1] === "npx" || command[i - 1] === "bunx");
|
|
30817
|
+
}
|
|
30818
|
+
async function createClaudeAgentAcpClient(options) {
|
|
30819
|
+
const command = options.command?.length && options.command.some((a) => a.includes("claude-agent-acp")) ? options.command : [...DEFAULT_CLAUDE_AGENT_ACP_COMMAND];
|
|
30820
|
+
return createAcpClient({ ...options, command });
|
|
30821
|
+
}
|
|
30822
|
+
|
|
30778
30823
|
// src/acp/clients/codex-acp-client.ts
|
|
30779
30824
|
var DEFAULT_CODEX_ACP_COMMAND = ["npx", "--yes", "@zed-industries/codex-acp"];
|
|
30780
30825
|
function isCodexAcpCommand(command) {
|
|
@@ -30793,21 +30838,21 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
30793
30838
|
import * as readline from "node:readline";
|
|
30794
30839
|
|
|
30795
30840
|
// src/acp/safe-fs-path.ts
|
|
30796
|
-
import * as
|
|
30841
|
+
import * as path6 from "node:path";
|
|
30797
30842
|
function resolveSafePathUnderCwd(cwd3, filePath) {
|
|
30798
30843
|
const trimmed2 = filePath.trim();
|
|
30799
30844
|
if (!trimmed2) return null;
|
|
30800
|
-
const normalizedCwd =
|
|
30801
|
-
const resolved =
|
|
30802
|
-
const rel =
|
|
30803
|
-
if (rel.startsWith("..") ||
|
|
30845
|
+
const normalizedCwd = path6.resolve(cwd3);
|
|
30846
|
+
const resolved = path6.isAbsolute(trimmed2) ? path6.normalize(trimmed2) : path6.resolve(normalizedCwd, trimmed2);
|
|
30847
|
+
const rel = path6.relative(normalizedCwd, resolved);
|
|
30848
|
+
if (rel.startsWith("..") || path6.isAbsolute(rel)) return null;
|
|
30804
30849
|
return resolved;
|
|
30805
30850
|
}
|
|
30806
30851
|
function toDisplayPathRelativeToCwd(cwd3, absolutePath) {
|
|
30807
|
-
const normalizedCwd =
|
|
30808
|
-
const rel =
|
|
30809
|
-
if (!rel || rel === "") return
|
|
30810
|
-
return rel.split(
|
|
30852
|
+
const normalizedCwd = path6.resolve(cwd3);
|
|
30853
|
+
const rel = path6.relative(normalizedCwd, path6.resolve(absolutePath));
|
|
30854
|
+
if (!rel || rel === "") return path6.basename(absolutePath);
|
|
30855
|
+
return rel.split(path6.sep).join("/");
|
|
30811
30856
|
}
|
|
30812
30857
|
|
|
30813
30858
|
// src/files/diff/unified-diff.ts
|
|
@@ -31109,7 +31154,7 @@ async function createCursorAcpClient(options) {
|
|
|
31109
31154
|
var AGENT_TYPE_DEFAULT_COMMANDS = {
|
|
31110
31155
|
"cursor-cli": ["agent", "acp"],
|
|
31111
31156
|
"codex-acp": [...DEFAULT_CODEX_ACP_COMMAND],
|
|
31112
|
-
"claude-code": [
|
|
31157
|
+
"claude-code": [...DEFAULT_CLAUDE_AGENT_ACP_COMMAND]
|
|
31113
31158
|
};
|
|
31114
31159
|
function useCursorAcp(agentType, command) {
|
|
31115
31160
|
if (agentType === "cursor-cli") return true;
|
|
@@ -31119,12 +31164,16 @@ function useCodexAcp(agentType, command) {
|
|
|
31119
31164
|
if (agentType === "codex-acp") return true;
|
|
31120
31165
|
return isCodexAcpCommand(command);
|
|
31121
31166
|
}
|
|
31167
|
+
function useClaudeAgentAcp(agentType, command) {
|
|
31168
|
+
if (agentType === "claude-code") return true;
|
|
31169
|
+
return isClaudeAgentAcpCommand(command);
|
|
31170
|
+
}
|
|
31122
31171
|
function resolveAgentCommand(agentCommand, preferredAgentType) {
|
|
31123
31172
|
const explicitCmd = agentCommand?.length ? agentCommand : void 0;
|
|
31124
31173
|
const typeCmd = preferredAgentType ? AGENT_TYPE_DEFAULT_COMMANDS[preferredAgentType] : void 0;
|
|
31125
31174
|
const command = explicitCmd ?? typeCmd;
|
|
31126
31175
|
if (!command?.length) return null;
|
|
31127
|
-
const createClient = useCursorAcp(preferredAgentType, command) ? createCursorAcpClient : useCodexAcp(preferredAgentType, command) ? createCodexAcpClient : createAcpClient;
|
|
31176
|
+
const createClient = useCursorAcp(preferredAgentType, command) ? createCursorAcpClient : useCodexAcp(preferredAgentType, command) ? createCodexAcpClient : useClaudeAgentAcp(preferredAgentType, command) ? createClaudeAgentAcpClient : createAcpClient;
|
|
31128
31177
|
const label = preferredAgentType ?? "--agent";
|
|
31129
31178
|
return { command, label, createClient };
|
|
31130
31179
|
}
|
|
@@ -31135,16 +31184,16 @@ import { existsSync, statSync } from "node:fs";
|
|
|
31135
31184
|
|
|
31136
31185
|
// src/git/get-git-repo-root-sync.ts
|
|
31137
31186
|
import { execFileSync } from "node:child_process";
|
|
31138
|
-
import * as
|
|
31187
|
+
import * as path7 from "node:path";
|
|
31139
31188
|
function getGitRepoRootSync(startDir) {
|
|
31140
31189
|
try {
|
|
31141
31190
|
const out = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
31142
|
-
cwd:
|
|
31191
|
+
cwd: path7.resolve(startDir),
|
|
31143
31192
|
encoding: "utf8",
|
|
31144
31193
|
stdio: ["ignore", "pipe", "ignore"],
|
|
31145
31194
|
maxBuffer: 1024 * 1024
|
|
31146
31195
|
}).trim();
|
|
31147
|
-
return out ?
|
|
31196
|
+
return out ? path7.resolve(out) : null;
|
|
31148
31197
|
} catch {
|
|
31149
31198
|
return null;
|
|
31150
31199
|
}
|
|
@@ -31153,25 +31202,25 @@ function getGitRepoRootSync(startDir) {
|
|
|
31153
31202
|
// src/acp/workspace-files.ts
|
|
31154
31203
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
31155
31204
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
31156
|
-
import * as
|
|
31205
|
+
import * as path8 from "node:path";
|
|
31157
31206
|
function resolveWorkspaceFilePath(cwd3, rawPath) {
|
|
31158
31207
|
const trimmed2 = rawPath.trim();
|
|
31159
31208
|
if (!trimmed2) return null;
|
|
31160
|
-
const normalizedCwd =
|
|
31209
|
+
const normalizedCwd = path8.resolve(cwd3);
|
|
31161
31210
|
let abs = resolveSafePathUnderCwd(cwd3, trimmed2);
|
|
31162
31211
|
if (!abs) {
|
|
31163
|
-
const candidate =
|
|
31212
|
+
const candidate = path8.isAbsolute(trimmed2) ? path8.normalize(trimmed2) : path8.normalize(path8.resolve(normalizedCwd, trimmed2));
|
|
31164
31213
|
const gitRoot2 = getGitRepoRootSync(cwd3);
|
|
31165
31214
|
if (!gitRoot2) return null;
|
|
31166
|
-
const rel =
|
|
31167
|
-
if (rel.startsWith("..") ||
|
|
31215
|
+
const rel = path8.relative(gitRoot2, candidate);
|
|
31216
|
+
if (rel.startsWith("..") || path8.isAbsolute(rel)) return null;
|
|
31168
31217
|
abs = candidate;
|
|
31169
31218
|
}
|
|
31170
31219
|
const gitRoot = getGitRepoRootSync(cwd3);
|
|
31171
31220
|
if (gitRoot) {
|
|
31172
|
-
const relFromRoot =
|
|
31173
|
-
if (!relFromRoot.startsWith("..") && !
|
|
31174
|
-
return { abs, display: relFromRoot.split(
|
|
31221
|
+
const relFromRoot = path8.relative(gitRoot, abs);
|
|
31222
|
+
if (!relFromRoot.startsWith("..") && !path8.isAbsolute(relFromRoot)) {
|
|
31223
|
+
return { abs, display: relFromRoot.split(path8.sep).join("/") };
|
|
31175
31224
|
}
|
|
31176
31225
|
}
|
|
31177
31226
|
return { abs, display: toDisplayPathRelativeToCwd(cwd3, abs) };
|
|
@@ -31180,9 +31229,9 @@ function readUtf8WorkspaceFile(cwd3, displayPath) {
|
|
|
31180
31229
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
31181
31230
|
const gitRoot = getGitRepoRootSync(cwd3);
|
|
31182
31231
|
if (gitRoot) {
|
|
31183
|
-
const abs2 =
|
|
31184
|
-
const rel =
|
|
31185
|
-
if (!rel.startsWith("..") && !
|
|
31232
|
+
const abs2 = path8.resolve(gitRoot, displayPath);
|
|
31233
|
+
const rel = path8.relative(gitRoot, abs2);
|
|
31234
|
+
if (!rel.startsWith("..") && !path8.isAbsolute(rel)) {
|
|
31186
31235
|
try {
|
|
31187
31236
|
return readFileSync2(abs2, "utf8");
|
|
31188
31237
|
} catch {
|
|
@@ -31201,9 +31250,9 @@ function tryWorkspaceDisplayToAbs(cwd3, displayPath) {
|
|
|
31201
31250
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
31202
31251
|
const gitRoot = getGitRepoRootSync(cwd3);
|
|
31203
31252
|
if (gitRoot) {
|
|
31204
|
-
const abs =
|
|
31205
|
-
const rel =
|
|
31206
|
-
if (!rel.startsWith("..") && !
|
|
31253
|
+
const abs = path8.resolve(gitRoot, displayPath);
|
|
31254
|
+
const rel = path8.relative(gitRoot, abs);
|
|
31255
|
+
if (!rel.startsWith("..") && !path8.isAbsolute(rel)) return abs;
|
|
31207
31256
|
}
|
|
31208
31257
|
return resolveSafePathUnderCwd(cwd3, displayPath);
|
|
31209
31258
|
}
|
|
@@ -31497,6 +31546,11 @@ function isCompletedToolStatus(status) {
|
|
|
31497
31546
|
const s = status.toLowerCase();
|
|
31498
31547
|
return s === "completed" || s === "complete" || s === "succeeded" || s === "success";
|
|
31499
31548
|
}
|
|
31549
|
+
function isTerminalToolStatus(status) {
|
|
31550
|
+
if (typeof status !== "string") return false;
|
|
31551
|
+
const s = status.toLowerCase();
|
|
31552
|
+
return isCompletedToolStatus(status) || s === "failed" || s === "cancelled" || s === "canceled";
|
|
31553
|
+
}
|
|
31500
31554
|
function accumulateToolPaths(toolKey, paths, acc) {
|
|
31501
31555
|
if (!toolKey || paths.length === 0) return;
|
|
31502
31556
|
let s = acc.get(toolKey);
|
|
@@ -31759,7 +31813,7 @@ function buildAcpSessionBridgeHooks(opts) {
|
|
|
31759
31813
|
async function ensureAcpClient(options) {
|
|
31760
31814
|
const { state, agentCommand, preferredAgentType, mode, cwd: cwd3, routing, sendSessionUpdate, sendRequest, log: log2 } = options;
|
|
31761
31815
|
const targetCwd = cwd3 ?? process.cwd();
|
|
31762
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
31816
|
+
if (state.acpHandle && state.lastAcpCwd != null && path9.resolve(state.lastAcpCwd) !== path9.resolve(targetCwd)) {
|
|
31763
31817
|
try {
|
|
31764
31818
|
state.acpHandle.disconnect();
|
|
31765
31819
|
} catch {
|
|
@@ -31901,6 +31955,7 @@ async function createAcpManager(options) {
|
|
|
31901
31955
|
promptId,
|
|
31902
31956
|
sessionId,
|
|
31903
31957
|
runId,
|
|
31958
|
+
agentType: preferredForPrompt,
|
|
31904
31959
|
sendResult,
|
|
31905
31960
|
sendSessionUpdate,
|
|
31906
31961
|
collectSessionDiffAfterTurn,
|
|
@@ -31988,12 +32043,12 @@ function handleBridgeAgentConfig(msg, { acpManager }) {
|
|
|
31988
32043
|
var handleAgentConfigMessage = (msg, deps) => handleBridgeAgentConfig(msg, deps);
|
|
31989
32044
|
|
|
31990
32045
|
// src/acp/from-bridge/handle-bridge-prompt.ts
|
|
31991
|
-
import * as
|
|
32046
|
+
import * as path12 from "node:path";
|
|
31992
32047
|
import { execFile as execFile3 } from "node:child_process";
|
|
31993
32048
|
import { promisify as promisify3 } from "node:util";
|
|
31994
32049
|
|
|
31995
32050
|
// src/git/bridge-queue-key.ts
|
|
31996
|
-
import * as
|
|
32051
|
+
import * as path10 from "node:path";
|
|
31997
32052
|
import { createHash } from "node:crypto";
|
|
31998
32053
|
function normalizeCanonicalGitUrl(url2) {
|
|
31999
32054
|
let s = url2.trim();
|
|
@@ -32021,11 +32076,11 @@ function canonicalUrlToRepoIdSync(url2) {
|
|
|
32021
32076
|
return createHash("sha256").update(normalized).digest("hex").slice(0, 32);
|
|
32022
32077
|
}
|
|
32023
32078
|
function fallbackRepoIdFromPath(absPath) {
|
|
32024
|
-
return createHash("sha256").update(
|
|
32079
|
+
return createHash("sha256").update(path10.resolve(absPath)).digest("hex").slice(0, 32);
|
|
32025
32080
|
}
|
|
32026
32081
|
async function resolveBridgeQueueBindFields(options) {
|
|
32027
32082
|
const { effectiveCwd, worktreePaths, primaryRepoRoots, log: log2 } = options;
|
|
32028
|
-
const cwdAbs = worktreePaths.length > 0 ?
|
|
32083
|
+
const cwdAbs = worktreePaths.length > 0 ? path10.resolve(worktreePaths[0]) : path10.resolve(effectiveCwd);
|
|
32029
32084
|
if (!primaryRepoRoots.length) {
|
|
32030
32085
|
log2("[bridge-queue] bind skipped: no git repo roots");
|
|
32031
32086
|
return null;
|
|
@@ -32049,12 +32104,12 @@ async function resolveBridgeQueueBindFields(options) {
|
|
|
32049
32104
|
|
|
32050
32105
|
// src/git/pre-turn-snapshot.ts
|
|
32051
32106
|
import * as fs4 from "node:fs";
|
|
32052
|
-
import * as
|
|
32107
|
+
import * as path11 from "node:path";
|
|
32053
32108
|
import { execFile as execFile2 } from "node:child_process";
|
|
32054
32109
|
import { promisify as promisify2 } from "node:util";
|
|
32055
32110
|
var execFileAsync2 = promisify2(execFile2);
|
|
32056
32111
|
function snapshotsDirForCwd(agentCwd) {
|
|
32057
|
-
return
|
|
32112
|
+
return path11.join(agentCwd, ".buildautomaton", "snapshots");
|
|
32058
32113
|
}
|
|
32059
32114
|
async function gitStashCreate2(repoRoot, log2) {
|
|
32060
32115
|
try {
|
|
@@ -32081,7 +32136,7 @@ async function gitRun(repoRoot, args, log2, label) {
|
|
|
32081
32136
|
async function resolveSnapshotRepoRoots(options) {
|
|
32082
32137
|
const { worktreePaths, fallbackCwd, log: log2 } = options;
|
|
32083
32138
|
if (worktreePaths?.length) {
|
|
32084
|
-
const uniq = [...new Set(worktreePaths.map((p) =>
|
|
32139
|
+
const uniq = [...new Set(worktreePaths.map((p) => path11.resolve(p)))];
|
|
32085
32140
|
return uniq;
|
|
32086
32141
|
}
|
|
32087
32142
|
try {
|
|
@@ -32113,7 +32168,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
32113
32168
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
32114
32169
|
repos
|
|
32115
32170
|
};
|
|
32116
|
-
const filePath =
|
|
32171
|
+
const filePath = path11.join(dir, `${runId}.json`);
|
|
32117
32172
|
try {
|
|
32118
32173
|
fs4.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
32119
32174
|
} catch (e) {
|
|
@@ -32148,7 +32203,7 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
32148
32203
|
return { ok: true };
|
|
32149
32204
|
}
|
|
32150
32205
|
function snapshotFilePath(agentCwd, runId) {
|
|
32151
|
-
return
|
|
32206
|
+
return path11.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
32152
32207
|
}
|
|
32153
32208
|
|
|
32154
32209
|
// src/acp/from-bridge/handle-bridge-prompt.ts
|
|
@@ -32188,15 +32243,27 @@ function handleBridgePrompt(msg, deps) {
|
|
|
32188
32243
|
return;
|
|
32189
32244
|
}
|
|
32190
32245
|
const p = payload;
|
|
32191
|
-
|
|
32192
|
-
|
|
32193
|
-
|
|
32194
|
-
|
|
32246
|
+
if (p.type === "session_file_change" && typeof p.path === "string") {
|
|
32247
|
+
log2(
|
|
32248
|
+
`[bridge\u2192ws] session_file_change runId=${p.runId?.slice(0, 8) ?? "?"}\u2026 path=${p.path}`
|
|
32249
|
+
);
|
|
32250
|
+
} else if (p.type === "session_update" && (p.kind === "tool_call_update" || p.kind === "tool_call")) {
|
|
32251
|
+
const inner = p.payload && typeof p.payload === "object" ? p.payload : null;
|
|
32252
|
+
const status = inner?.status;
|
|
32253
|
+
if (isTerminalToolStatus(status)) {
|
|
32254
|
+
const tc = inner?.toolCall ?? inner?.tool_call;
|
|
32255
|
+
const toolName = typeof tc?.name === "string" ? tc.name : "";
|
|
32256
|
+
const st = typeof status === "string" ? status : String(status);
|
|
32257
|
+
log2(
|
|
32258
|
+
`[bridge\u2192ws] tool finished runId=${p.runId?.slice(0, 8) ?? "?"}\u2026 tool=${toolName || "?"} status=${st}`
|
|
32259
|
+
);
|
|
32260
|
+
}
|
|
32261
|
+
}
|
|
32195
32262
|
sendWsMessage(s, payload);
|
|
32196
32263
|
};
|
|
32197
32264
|
async function preambleAndPrompt(resolvedCwd) {
|
|
32198
32265
|
const s = getWs();
|
|
32199
|
-
const effectiveCwd =
|
|
32266
|
+
const effectiveCwd = path12.resolve(resolvedCwd ?? process.cwd());
|
|
32200
32267
|
const worktreePaths = sessionWorktreeManager.getWorktreePathsForSession(sessionId) ?? [];
|
|
32201
32268
|
const repoRoots = await resolveSnapshotRepoRoots({
|
|
32202
32269
|
worktreePaths,
|
|
@@ -32318,14 +32385,14 @@ var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
|
|
|
32318
32385
|
|
|
32319
32386
|
// src/files/list-dir.ts
|
|
32320
32387
|
import fs5 from "node:fs";
|
|
32321
|
-
import
|
|
32388
|
+
import path14 from "node:path";
|
|
32322
32389
|
|
|
32323
32390
|
// src/files/ensure-under-cwd.ts
|
|
32324
|
-
import
|
|
32391
|
+
import path13 from "node:path";
|
|
32325
32392
|
function ensureUnderCwd(relativePath, cwd3 = process.cwd()) {
|
|
32326
|
-
const normalized =
|
|
32327
|
-
const resolved =
|
|
32328
|
-
if (!resolved.startsWith(cwd3 +
|
|
32393
|
+
const normalized = path13.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
32394
|
+
const resolved = path13.resolve(cwd3, normalized);
|
|
32395
|
+
if (!resolved.startsWith(cwd3 + path13.sep) && resolved !== cwd3) {
|
|
32329
32396
|
return null;
|
|
32330
32397
|
}
|
|
32331
32398
|
return resolved;
|
|
@@ -32341,8 +32408,8 @@ function listDir(relativePath) {
|
|
|
32341
32408
|
try {
|
|
32342
32409
|
const names = fs5.readdirSync(resolved, { withFileTypes: true });
|
|
32343
32410
|
const entries = names.filter((d) => !d.name.startsWith(".")).map((d) => {
|
|
32344
|
-
const entryPath =
|
|
32345
|
-
const fullPath =
|
|
32411
|
+
const entryPath = path14.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
32412
|
+
const fullPath = path14.join(resolved, d.name);
|
|
32346
32413
|
let isDir = d.isDirectory();
|
|
32347
32414
|
if (d.isSymbolicLink()) {
|
|
32348
32415
|
try {
|
|
@@ -32559,15 +32626,15 @@ function readFile(relativePath, startLine, endLine, lineOffset, lineChunkSize =
|
|
|
32559
32626
|
|
|
32560
32627
|
// src/files/file-index.ts
|
|
32561
32628
|
import fs7 from "node:fs";
|
|
32562
|
-
import
|
|
32629
|
+
import path15 from "node:path";
|
|
32563
32630
|
import os2 from "node:os";
|
|
32564
32631
|
import crypto2 from "node:crypto";
|
|
32565
|
-
var INDEX_DIR =
|
|
32632
|
+
var INDEX_DIR = path15.join(os2.homedir(), ".buildautomaton");
|
|
32566
32633
|
var HASH_LEN = 16;
|
|
32567
32634
|
var INDEX_VERSION = 2;
|
|
32568
32635
|
function getIndexPath(cwd3) {
|
|
32569
32636
|
const hash = crypto2.createHash("sha256").update(cwd3).digest("hex").slice(0, HASH_LEN);
|
|
32570
|
-
return
|
|
32637
|
+
return path15.join(INDEX_DIR, `.file-index-${hash}.json`);
|
|
32571
32638
|
}
|
|
32572
32639
|
function getTrigrams(s) {
|
|
32573
32640
|
const lower = s.toLowerCase();
|
|
@@ -32611,14 +32678,14 @@ function walkDir(dir, baseDir, out) {
|
|
|
32611
32678
|
}
|
|
32612
32679
|
for (const name of names) {
|
|
32613
32680
|
if (name.startsWith(".")) continue;
|
|
32614
|
-
const full =
|
|
32681
|
+
const full = path15.join(dir, name);
|
|
32615
32682
|
let stat4;
|
|
32616
32683
|
try {
|
|
32617
32684
|
stat4 = fs7.statSync(full);
|
|
32618
32685
|
} catch {
|
|
32619
32686
|
continue;
|
|
32620
32687
|
}
|
|
32621
|
-
const relative6 =
|
|
32688
|
+
const relative6 = path15.relative(baseDir, full).replace(/\\/g, "/");
|
|
32622
32689
|
if (stat4.isDirectory()) {
|
|
32623
32690
|
walkDir(full, baseDir, out);
|
|
32624
32691
|
} else if (stat4.isFile()) {
|
|
@@ -32627,7 +32694,7 @@ function walkDir(dir, baseDir, out) {
|
|
|
32627
32694
|
}
|
|
32628
32695
|
}
|
|
32629
32696
|
function buildFileIndex(cwd3) {
|
|
32630
|
-
const resolved =
|
|
32697
|
+
const resolved = path15.resolve(cwd3);
|
|
32631
32698
|
const paths = [];
|
|
32632
32699
|
walkDir(resolved, resolved, paths);
|
|
32633
32700
|
paths.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" }));
|
|
@@ -32653,7 +32720,7 @@ function buildFileIndex(cwd3) {
|
|
|
32653
32720
|
return data;
|
|
32654
32721
|
}
|
|
32655
32722
|
function loadFileIndex(cwd3) {
|
|
32656
|
-
const resolved =
|
|
32723
|
+
const resolved = path15.resolve(cwd3);
|
|
32657
32724
|
const indexPath = getIndexPath(resolved);
|
|
32658
32725
|
try {
|
|
32659
32726
|
const raw = fs7.readFileSync(indexPath, "utf8");
|
|
@@ -32674,7 +32741,7 @@ function loadFileIndex(cwd3) {
|
|
|
32674
32741
|
}
|
|
32675
32742
|
}
|
|
32676
32743
|
function ensureFileIndex(cwd3) {
|
|
32677
|
-
const resolved =
|
|
32744
|
+
const resolved = path15.resolve(cwd3);
|
|
32678
32745
|
const cached2 = loadFileIndex(resolved);
|
|
32679
32746
|
if (cached2 !== null) return { data: cached2, fromCache: true };
|
|
32680
32747
|
const data = buildFileIndex(resolved);
|
|
@@ -32813,7 +32880,7 @@ function registerFileBrowserHandlers(router2) {
|
|
|
32813
32880
|
|
|
32814
32881
|
// src/skills/install-remote-skills.ts
|
|
32815
32882
|
import fs8 from "node:fs";
|
|
32816
|
-
import
|
|
32883
|
+
import path16 from "node:path";
|
|
32817
32884
|
function installRemoteSkills(cwd3, targetDir, items) {
|
|
32818
32885
|
const installed = [];
|
|
32819
32886
|
if (!Array.isArray(items)) {
|
|
@@ -32824,11 +32891,11 @@ function installRemoteSkills(cwd3, targetDir, items) {
|
|
|
32824
32891
|
if (typeof item.sourceId !== "string" || typeof item.skillName !== "string" || typeof item.versionHash !== "string" || !Array.isArray(item.files)) {
|
|
32825
32892
|
continue;
|
|
32826
32893
|
}
|
|
32827
|
-
const skillDir =
|
|
32894
|
+
const skillDir = path16.join(cwd3, targetDir, item.skillName);
|
|
32828
32895
|
for (const f of item.files) {
|
|
32829
32896
|
if (typeof f.path !== "string" || !f.text && !f.base64) continue;
|
|
32830
|
-
const dest =
|
|
32831
|
-
fs8.mkdirSync(
|
|
32897
|
+
const dest = path16.join(skillDir, f.path);
|
|
32898
|
+
fs8.mkdirSync(path16.dirname(dest), { recursive: true });
|
|
32832
32899
|
if (f.text !== void 0) {
|
|
32833
32900
|
fs8.writeFileSync(dest, f.text, "utf8");
|
|
32834
32901
|
} else if (f.base64) {
|
|
@@ -32938,7 +33005,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
32938
33005
|
|
|
32939
33006
|
// src/bridge/routing/handlers/revert-turn-snapshot.ts
|
|
32940
33007
|
import * as fs9 from "node:fs";
|
|
32941
|
-
import * as
|
|
33008
|
+
import * as path17 from "node:path";
|
|
32942
33009
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
32943
33010
|
if (msg.type !== "revert_turn_snapshot") return false;
|
|
32944
33011
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
@@ -32949,7 +33016,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
32949
33016
|
void (async () => {
|
|
32950
33017
|
const s = getWs();
|
|
32951
33018
|
if (!s) return;
|
|
32952
|
-
const agentBase = sessionWorktreeManager.getAgentCwdForSession(sessionId) ??
|
|
33019
|
+
const agentBase = sessionWorktreeManager.getAgentCwdForSession(sessionId) ?? path17.resolve(process.cwd());
|
|
32953
33020
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
32954
33021
|
if (!fs9.existsSync(file2)) {
|
|
32955
33022
|
sendWsMessage(s, {
|
|
@@ -32996,12 +33063,12 @@ function handleBridgeMessage(data, deps) {
|
|
|
32996
33063
|
}
|
|
32997
33064
|
|
|
32998
33065
|
// src/worktrees/session-worktree-manager.ts
|
|
32999
|
-
import * as
|
|
33066
|
+
import * as path21 from "node:path";
|
|
33000
33067
|
import os4 from "node:os";
|
|
33001
33068
|
|
|
33002
33069
|
// src/worktrees/prepare-new-session-worktrees.ts
|
|
33003
33070
|
import * as fs11 from "node:fs";
|
|
33004
|
-
import * as
|
|
33071
|
+
import * as path19 from "node:path";
|
|
33005
33072
|
|
|
33006
33073
|
// src/git/worktree-add.ts
|
|
33007
33074
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
|
|
@@ -33011,11 +33078,11 @@ async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
|
|
|
33011
33078
|
|
|
33012
33079
|
// src/worktrees/worktree-layout-file.ts
|
|
33013
33080
|
import * as fs10 from "node:fs";
|
|
33014
|
-
import * as
|
|
33081
|
+
import * as path18 from "node:path";
|
|
33015
33082
|
import os3 from "node:os";
|
|
33016
33083
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
33017
33084
|
function defaultWorktreeLayoutPath() {
|
|
33018
|
-
return
|
|
33085
|
+
return path18.join(os3.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
33019
33086
|
}
|
|
33020
33087
|
function normalizeLoadedLayout(raw) {
|
|
33021
33088
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -33036,18 +33103,18 @@ function loadWorktreeLayout() {
|
|
|
33036
33103
|
}
|
|
33037
33104
|
function saveWorktreeLayout(layout) {
|
|
33038
33105
|
try {
|
|
33039
|
-
const dir =
|
|
33106
|
+
const dir = path18.dirname(defaultWorktreeLayoutPath());
|
|
33040
33107
|
fs10.mkdirSync(dir, { recursive: true });
|
|
33041
33108
|
fs10.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
33042
33109
|
} catch {
|
|
33043
33110
|
}
|
|
33044
33111
|
}
|
|
33045
33112
|
function baseNameSafe(abs) {
|
|
33046
|
-
return
|
|
33113
|
+
return path18.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
33047
33114
|
}
|
|
33048
33115
|
function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
|
|
33049
|
-
const norm =
|
|
33050
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
33116
|
+
const norm = path18.resolve(launcherCwdAbs);
|
|
33117
|
+
const existing = layout.launcherCwds.find((e) => path18.resolve(e.absolutePath) === norm);
|
|
33051
33118
|
if (existing) return existing.dirName;
|
|
33052
33119
|
const base = baseNameSafe(norm);
|
|
33053
33120
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
@@ -33065,9 +33132,9 @@ function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
|
|
|
33065
33132
|
// src/worktrees/prepare-new-session-worktrees.ts
|
|
33066
33133
|
async function prepareNewSessionWorktrees(options) {
|
|
33067
33134
|
const { rootAbs, launcherCwd, sessionId, layout, log: log2 } = options;
|
|
33068
|
-
const launcherResolved =
|
|
33135
|
+
const launcherResolved = path19.resolve(launcherCwd);
|
|
33069
33136
|
const cwdKey = allocateDirNameForLauncherCwd(layout, launcherResolved);
|
|
33070
|
-
const agentMirrorRoot =
|
|
33137
|
+
const agentMirrorRoot = path19.join(rootAbs, cwdKey);
|
|
33071
33138
|
const repos = await discoverGitReposUnderRoot(launcherResolved);
|
|
33072
33139
|
if (repos.length === 0) {
|
|
33073
33140
|
log2("[worktrees] No git repos under launcher cwd; skipping worktree creation");
|
|
@@ -33077,11 +33144,11 @@ async function prepareNewSessionWorktrees(options) {
|
|
|
33077
33144
|
const worktreePaths = [];
|
|
33078
33145
|
fs11.mkdirSync(agentMirrorRoot, { recursive: true });
|
|
33079
33146
|
for (const repo of repos) {
|
|
33080
|
-
let rel =
|
|
33081
|
-
if (rel.startsWith("..") ||
|
|
33147
|
+
let rel = path19.relative(launcherResolved, repo.absolutePath);
|
|
33148
|
+
if (rel.startsWith("..") || path19.isAbsolute(rel)) continue;
|
|
33082
33149
|
const relNorm = rel === "" ? "." : rel;
|
|
33083
|
-
const wtPath =
|
|
33084
|
-
fs11.mkdirSync(
|
|
33150
|
+
const wtPath = path19.join(agentMirrorRoot, relNorm, sessionId);
|
|
33151
|
+
fs11.mkdirSync(path19.dirname(wtPath), { recursive: true });
|
|
33085
33152
|
try {
|
|
33086
33153
|
await gitWorktreeAddBranch(repo.absolutePath, wtPath, branch);
|
|
33087
33154
|
log2(`[worktrees] Added worktree ${wtPath} (branch ${branch})`);
|
|
@@ -33123,16 +33190,16 @@ import * as fs13 from "node:fs";
|
|
|
33123
33190
|
|
|
33124
33191
|
// src/git/resolve-main-repo-from-git-file.ts
|
|
33125
33192
|
import * as fs12 from "node:fs";
|
|
33126
|
-
import * as
|
|
33193
|
+
import * as path20 from "node:path";
|
|
33127
33194
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
33128
|
-
const gitDirFile =
|
|
33195
|
+
const gitDirFile = path20.join(wt, ".git");
|
|
33129
33196
|
if (!fs12.existsSync(gitDirFile) || !fs12.statSync(gitDirFile).isFile()) return "";
|
|
33130
33197
|
const first2 = fs12.readFileSync(gitDirFile, "utf8").trim();
|
|
33131
33198
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
33132
33199
|
if (!m) return "";
|
|
33133
|
-
const gitWorktreePath =
|
|
33134
|
-
const gitDir =
|
|
33135
|
-
return
|
|
33200
|
+
const gitWorktreePath = path20.resolve(wt, m[1].trim());
|
|
33201
|
+
const gitDir = path20.dirname(path20.dirname(gitWorktreePath));
|
|
33202
|
+
return path20.dirname(gitDir);
|
|
33136
33203
|
}
|
|
33137
33204
|
|
|
33138
33205
|
// src/git/worktree-remove.ts
|
|
@@ -33215,7 +33282,7 @@ var SessionWorktreeManager = class {
|
|
|
33215
33282
|
}
|
|
33216
33283
|
if (!opts.isNewSession) {
|
|
33217
33284
|
const agentCwd = this.sessionAgentCwd.get(sessionId);
|
|
33218
|
-
if (agentCwd) return
|
|
33285
|
+
if (agentCwd) return path21.resolve(agentCwd);
|
|
33219
33286
|
return void 0;
|
|
33220
33287
|
}
|
|
33221
33288
|
const prep = await prepareNewSessionWorktrees({
|
|
@@ -33228,7 +33295,7 @@ var SessionWorktreeManager = class {
|
|
|
33228
33295
|
if (!prep) return void 0;
|
|
33229
33296
|
this.sessionPaths.set(sessionId, prep.worktreePaths);
|
|
33230
33297
|
this.sessionAgentCwd.set(sessionId, prep.agentCwd);
|
|
33231
|
-
return
|
|
33298
|
+
return path21.resolve(prep.agentCwd);
|
|
33232
33299
|
}
|
|
33233
33300
|
async renameSessionBranch(sessionId, newBranch) {
|
|
33234
33301
|
const paths = this.sessionPaths.get(sessionId);
|
|
@@ -33249,7 +33316,7 @@ var SessionWorktreeManager = class {
|
|
|
33249
33316
|
getAgentCwdForSession(sessionId) {
|
|
33250
33317
|
if (!sessionId) return null;
|
|
33251
33318
|
const c = this.sessionAgentCwd.get(sessionId);
|
|
33252
|
-
return c ?
|
|
33319
|
+
return c ? path21.resolve(c) : null;
|
|
33253
33320
|
}
|
|
33254
33321
|
async removeSessionWorktrees(sessionId) {
|
|
33255
33322
|
const paths = this.sessionPaths.get(sessionId);
|
|
@@ -33270,7 +33337,7 @@ var SessionWorktreeManager = class {
|
|
|
33270
33337
|
}
|
|
33271
33338
|
};
|
|
33272
33339
|
function defaultWorktreesRootAbs() {
|
|
33273
|
-
return
|
|
33340
|
+
return path21.join(os4.homedir(), ".buildautomaton", "worktrees");
|
|
33274
33341
|
}
|
|
33275
33342
|
|
|
33276
33343
|
// src/auth/refresh-bridge-tokens.ts
|
|
@@ -33301,7 +33368,7 @@ async function refreshBridgeTokens(params) {
|
|
|
33301
33368
|
}
|
|
33302
33369
|
|
|
33303
33370
|
// src/files/watch-file-index.ts
|
|
33304
|
-
import
|
|
33371
|
+
import path22 from "node:path";
|
|
33305
33372
|
|
|
33306
33373
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
33307
33374
|
import { stat as statcb } from "fs";
|
|
@@ -33379,7 +33446,7 @@ var ReaddirpStream = class extends Readable2 {
|
|
|
33379
33446
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
33380
33447
|
const statMethod = opts.lstat ? lstat : stat;
|
|
33381
33448
|
if (wantBigintFsStats) {
|
|
33382
|
-
this._stat = (
|
|
33449
|
+
this._stat = (path24) => statMethod(path24, { bigint: true });
|
|
33383
33450
|
} else {
|
|
33384
33451
|
this._stat = statMethod;
|
|
33385
33452
|
}
|
|
@@ -33404,8 +33471,8 @@ var ReaddirpStream = class extends Readable2 {
|
|
|
33404
33471
|
const par = this.parent;
|
|
33405
33472
|
const fil = par && par.files;
|
|
33406
33473
|
if (fil && fil.length > 0) {
|
|
33407
|
-
const { path:
|
|
33408
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
33474
|
+
const { path: path24, depth } = par;
|
|
33475
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path24));
|
|
33409
33476
|
const awaited = await Promise.all(slice);
|
|
33410
33477
|
for (const entry of awaited) {
|
|
33411
33478
|
if (!entry)
|
|
@@ -33445,20 +33512,20 @@ var ReaddirpStream = class extends Readable2 {
|
|
|
33445
33512
|
this.reading = false;
|
|
33446
33513
|
}
|
|
33447
33514
|
}
|
|
33448
|
-
async _exploreDir(
|
|
33515
|
+
async _exploreDir(path24, depth) {
|
|
33449
33516
|
let files;
|
|
33450
33517
|
try {
|
|
33451
|
-
files = await readdir(
|
|
33518
|
+
files = await readdir(path24, this._rdOptions);
|
|
33452
33519
|
} catch (error40) {
|
|
33453
33520
|
this._onError(error40);
|
|
33454
33521
|
}
|
|
33455
|
-
return { files, depth, path:
|
|
33522
|
+
return { files, depth, path: path24 };
|
|
33456
33523
|
}
|
|
33457
|
-
async _formatEntry(dirent,
|
|
33524
|
+
async _formatEntry(dirent, path24) {
|
|
33458
33525
|
let entry;
|
|
33459
33526
|
const basename6 = this._isDirent ? dirent.name : dirent;
|
|
33460
33527
|
try {
|
|
33461
|
-
const fullPath = presolve(pjoin(
|
|
33528
|
+
const fullPath = presolve(pjoin(path24, basename6));
|
|
33462
33529
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename6 };
|
|
33463
33530
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
33464
33531
|
} catch (err) {
|
|
@@ -33858,16 +33925,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
33858
33925
|
};
|
|
33859
33926
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
33860
33927
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
33861
|
-
function createFsWatchInstance(
|
|
33928
|
+
function createFsWatchInstance(path24, options, listener, errHandler, emitRaw) {
|
|
33862
33929
|
const handleEvent = (rawEvent, evPath) => {
|
|
33863
|
-
listener(
|
|
33864
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
33865
|
-
if (evPath &&
|
|
33866
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
33930
|
+
listener(path24);
|
|
33931
|
+
emitRaw(rawEvent, evPath, { watchedPath: path24 });
|
|
33932
|
+
if (evPath && path24 !== evPath) {
|
|
33933
|
+
fsWatchBroadcast(sysPath.resolve(path24, evPath), KEY_LISTENERS, sysPath.join(path24, evPath));
|
|
33867
33934
|
}
|
|
33868
33935
|
};
|
|
33869
33936
|
try {
|
|
33870
|
-
return fs_watch(
|
|
33937
|
+
return fs_watch(path24, {
|
|
33871
33938
|
persistent: options.persistent
|
|
33872
33939
|
}, handleEvent);
|
|
33873
33940
|
} catch (error40) {
|
|
@@ -33883,12 +33950,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
33883
33950
|
listener(val1, val2, val3);
|
|
33884
33951
|
});
|
|
33885
33952
|
};
|
|
33886
|
-
var setFsWatchListener = (
|
|
33953
|
+
var setFsWatchListener = (path24, fullPath, options, handlers) => {
|
|
33887
33954
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
33888
33955
|
let cont = FsWatchInstances.get(fullPath);
|
|
33889
33956
|
let watcher;
|
|
33890
33957
|
if (!options.persistent) {
|
|
33891
|
-
watcher = createFsWatchInstance(
|
|
33958
|
+
watcher = createFsWatchInstance(path24, options, listener, errHandler, rawEmitter);
|
|
33892
33959
|
if (!watcher)
|
|
33893
33960
|
return;
|
|
33894
33961
|
return watcher.close.bind(watcher);
|
|
@@ -33899,7 +33966,7 @@ var setFsWatchListener = (path23, fullPath, options, handlers) => {
|
|
|
33899
33966
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
33900
33967
|
} else {
|
|
33901
33968
|
watcher = createFsWatchInstance(
|
|
33902
|
-
|
|
33969
|
+
path24,
|
|
33903
33970
|
options,
|
|
33904
33971
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
33905
33972
|
errHandler,
|
|
@@ -33914,7 +33981,7 @@ var setFsWatchListener = (path23, fullPath, options, handlers) => {
|
|
|
33914
33981
|
cont.watcherUnusable = true;
|
|
33915
33982
|
if (isWindows && error40.code === "EPERM") {
|
|
33916
33983
|
try {
|
|
33917
|
-
const fd = await open(
|
|
33984
|
+
const fd = await open(path24, "r");
|
|
33918
33985
|
await fd.close();
|
|
33919
33986
|
broadcastErr(error40);
|
|
33920
33987
|
} catch (err) {
|
|
@@ -33945,7 +34012,7 @@ var setFsWatchListener = (path23, fullPath, options, handlers) => {
|
|
|
33945
34012
|
};
|
|
33946
34013
|
};
|
|
33947
34014
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
33948
|
-
var setFsWatchFileListener = (
|
|
34015
|
+
var setFsWatchFileListener = (path24, fullPath, options, handlers) => {
|
|
33949
34016
|
const { listener, rawEmitter } = handlers;
|
|
33950
34017
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
33951
34018
|
const copts = cont && cont.options;
|
|
@@ -33967,7 +34034,7 @@ var setFsWatchFileListener = (path23, fullPath, options, handlers) => {
|
|
|
33967
34034
|
});
|
|
33968
34035
|
const currmtime = curr.mtimeMs;
|
|
33969
34036
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
33970
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
34037
|
+
foreach(cont.listeners, (listener2) => listener2(path24, curr));
|
|
33971
34038
|
}
|
|
33972
34039
|
})
|
|
33973
34040
|
};
|
|
@@ -33995,13 +34062,13 @@ var NodeFsHandler = class {
|
|
|
33995
34062
|
* @param listener on fs change
|
|
33996
34063
|
* @returns closer for the watcher instance
|
|
33997
34064
|
*/
|
|
33998
|
-
_watchWithNodeFs(
|
|
34065
|
+
_watchWithNodeFs(path24, listener) {
|
|
33999
34066
|
const opts = this.fsw.options;
|
|
34000
|
-
const directory = sysPath.dirname(
|
|
34001
|
-
const basename6 = sysPath.basename(
|
|
34067
|
+
const directory = sysPath.dirname(path24);
|
|
34068
|
+
const basename6 = sysPath.basename(path24);
|
|
34002
34069
|
const parent = this.fsw._getWatchedDir(directory);
|
|
34003
34070
|
parent.add(basename6);
|
|
34004
|
-
const absolutePath = sysPath.resolve(
|
|
34071
|
+
const absolutePath = sysPath.resolve(path24);
|
|
34005
34072
|
const options = {
|
|
34006
34073
|
persistent: opts.persistent
|
|
34007
34074
|
};
|
|
@@ -34011,12 +34078,12 @@ var NodeFsHandler = class {
|
|
|
34011
34078
|
if (opts.usePolling) {
|
|
34012
34079
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
34013
34080
|
options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
|
|
34014
|
-
closer = setFsWatchFileListener(
|
|
34081
|
+
closer = setFsWatchFileListener(path24, absolutePath, options, {
|
|
34015
34082
|
listener,
|
|
34016
34083
|
rawEmitter: this.fsw._emitRaw
|
|
34017
34084
|
});
|
|
34018
34085
|
} else {
|
|
34019
|
-
closer = setFsWatchListener(
|
|
34086
|
+
closer = setFsWatchListener(path24, absolutePath, options, {
|
|
34020
34087
|
listener,
|
|
34021
34088
|
errHandler: this._boundHandleError,
|
|
34022
34089
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -34038,7 +34105,7 @@ var NodeFsHandler = class {
|
|
|
34038
34105
|
let prevStats = stats;
|
|
34039
34106
|
if (parent.has(basename6))
|
|
34040
34107
|
return;
|
|
34041
|
-
const listener = async (
|
|
34108
|
+
const listener = async (path24, newStats) => {
|
|
34042
34109
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
34043
34110
|
return;
|
|
34044
34111
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -34052,11 +34119,11 @@ var NodeFsHandler = class {
|
|
|
34052
34119
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
34053
34120
|
}
|
|
34054
34121
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
34055
|
-
this.fsw._closeFile(
|
|
34122
|
+
this.fsw._closeFile(path24);
|
|
34056
34123
|
prevStats = newStats2;
|
|
34057
34124
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
34058
34125
|
if (closer2)
|
|
34059
|
-
this.fsw._addPathCloser(
|
|
34126
|
+
this.fsw._addPathCloser(path24, closer2);
|
|
34060
34127
|
} else {
|
|
34061
34128
|
prevStats = newStats2;
|
|
34062
34129
|
}
|
|
@@ -34088,7 +34155,7 @@ var NodeFsHandler = class {
|
|
|
34088
34155
|
* @param item basename of this item
|
|
34089
34156
|
* @returns true if no more processing is needed for this entry.
|
|
34090
34157
|
*/
|
|
34091
|
-
async _handleSymlink(entry, directory,
|
|
34158
|
+
async _handleSymlink(entry, directory, path24, item) {
|
|
34092
34159
|
if (this.fsw.closed) {
|
|
34093
34160
|
return;
|
|
34094
34161
|
}
|
|
@@ -34098,7 +34165,7 @@ var NodeFsHandler = class {
|
|
|
34098
34165
|
this.fsw._incrReadyCount();
|
|
34099
34166
|
let linkPath;
|
|
34100
34167
|
try {
|
|
34101
|
-
linkPath = await fsrealpath(
|
|
34168
|
+
linkPath = await fsrealpath(path24);
|
|
34102
34169
|
} catch (e) {
|
|
34103
34170
|
this.fsw._emitReady();
|
|
34104
34171
|
return true;
|
|
@@ -34108,12 +34175,12 @@ var NodeFsHandler = class {
|
|
|
34108
34175
|
if (dir.has(item)) {
|
|
34109
34176
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
34110
34177
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34111
|
-
this.fsw._emit(EV.CHANGE,
|
|
34178
|
+
this.fsw._emit(EV.CHANGE, path24, entry.stats);
|
|
34112
34179
|
}
|
|
34113
34180
|
} else {
|
|
34114
34181
|
dir.add(item);
|
|
34115
34182
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34116
|
-
this.fsw._emit(EV.ADD,
|
|
34183
|
+
this.fsw._emit(EV.ADD, path24, entry.stats);
|
|
34117
34184
|
}
|
|
34118
34185
|
this.fsw._emitReady();
|
|
34119
34186
|
return true;
|
|
@@ -34142,9 +34209,9 @@ var NodeFsHandler = class {
|
|
|
34142
34209
|
return;
|
|
34143
34210
|
}
|
|
34144
34211
|
const item = entry.path;
|
|
34145
|
-
let
|
|
34212
|
+
let path24 = sysPath.join(directory, item);
|
|
34146
34213
|
current.add(item);
|
|
34147
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
34214
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path24, item)) {
|
|
34148
34215
|
return;
|
|
34149
34216
|
}
|
|
34150
34217
|
if (this.fsw.closed) {
|
|
@@ -34153,8 +34220,8 @@ var NodeFsHandler = class {
|
|
|
34153
34220
|
}
|
|
34154
34221
|
if (item === target || !target && !previous.has(item)) {
|
|
34155
34222
|
this.fsw._incrReadyCount();
|
|
34156
|
-
|
|
34157
|
-
this._addToNodeFs(
|
|
34223
|
+
path24 = sysPath.join(dir, sysPath.relative(dir, path24));
|
|
34224
|
+
this._addToNodeFs(path24, initialAdd, wh, depth + 1);
|
|
34158
34225
|
}
|
|
34159
34226
|
}).on(EV.ERROR, this._boundHandleError);
|
|
34160
34227
|
return new Promise((resolve17, reject) => {
|
|
@@ -34223,13 +34290,13 @@ var NodeFsHandler = class {
|
|
|
34223
34290
|
* @param depth Child path actually targeted for watch
|
|
34224
34291
|
* @param target Child path actually targeted for watch
|
|
34225
34292
|
*/
|
|
34226
|
-
async _addToNodeFs(
|
|
34293
|
+
async _addToNodeFs(path24, initialAdd, priorWh, depth, target) {
|
|
34227
34294
|
const ready = this.fsw._emitReady;
|
|
34228
|
-
if (this.fsw._isIgnored(
|
|
34295
|
+
if (this.fsw._isIgnored(path24) || this.fsw.closed) {
|
|
34229
34296
|
ready();
|
|
34230
34297
|
return false;
|
|
34231
34298
|
}
|
|
34232
|
-
const wh = this.fsw._getWatchHelpers(
|
|
34299
|
+
const wh = this.fsw._getWatchHelpers(path24);
|
|
34233
34300
|
if (priorWh) {
|
|
34234
34301
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
34235
34302
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -34245,8 +34312,8 @@ var NodeFsHandler = class {
|
|
|
34245
34312
|
const follow = this.fsw.options.followSymlinks;
|
|
34246
34313
|
let closer;
|
|
34247
34314
|
if (stats.isDirectory()) {
|
|
34248
|
-
const absPath = sysPath.resolve(
|
|
34249
|
-
const targetPath = follow ? await fsrealpath(
|
|
34315
|
+
const absPath = sysPath.resolve(path24);
|
|
34316
|
+
const targetPath = follow ? await fsrealpath(path24) : path24;
|
|
34250
34317
|
if (this.fsw.closed)
|
|
34251
34318
|
return;
|
|
34252
34319
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -34256,29 +34323,29 @@ var NodeFsHandler = class {
|
|
|
34256
34323
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
34257
34324
|
}
|
|
34258
34325
|
} else if (stats.isSymbolicLink()) {
|
|
34259
|
-
const targetPath = follow ? await fsrealpath(
|
|
34326
|
+
const targetPath = follow ? await fsrealpath(path24) : path24;
|
|
34260
34327
|
if (this.fsw.closed)
|
|
34261
34328
|
return;
|
|
34262
34329
|
const parent = sysPath.dirname(wh.watchPath);
|
|
34263
34330
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
34264
34331
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
34265
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
34332
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path24, wh, targetPath);
|
|
34266
34333
|
if (this.fsw.closed)
|
|
34267
34334
|
return;
|
|
34268
34335
|
if (targetPath !== void 0) {
|
|
34269
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
34336
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path24), targetPath);
|
|
34270
34337
|
}
|
|
34271
34338
|
} else {
|
|
34272
34339
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
34273
34340
|
}
|
|
34274
34341
|
ready();
|
|
34275
34342
|
if (closer)
|
|
34276
|
-
this.fsw._addPathCloser(
|
|
34343
|
+
this.fsw._addPathCloser(path24, closer);
|
|
34277
34344
|
return false;
|
|
34278
34345
|
} catch (error40) {
|
|
34279
34346
|
if (this.fsw._handleError(error40)) {
|
|
34280
34347
|
ready();
|
|
34281
|
-
return
|
|
34348
|
+
return path24;
|
|
34282
34349
|
}
|
|
34283
34350
|
}
|
|
34284
34351
|
}
|
|
@@ -34321,26 +34388,26 @@ function createPattern(matcher) {
|
|
|
34321
34388
|
}
|
|
34322
34389
|
return () => false;
|
|
34323
34390
|
}
|
|
34324
|
-
function normalizePath(
|
|
34325
|
-
if (typeof
|
|
34391
|
+
function normalizePath(path24) {
|
|
34392
|
+
if (typeof path24 !== "string")
|
|
34326
34393
|
throw new Error("string expected");
|
|
34327
|
-
|
|
34328
|
-
|
|
34394
|
+
path24 = sysPath2.normalize(path24);
|
|
34395
|
+
path24 = path24.replace(/\\/g, "/");
|
|
34329
34396
|
let prepend = false;
|
|
34330
|
-
if (
|
|
34397
|
+
if (path24.startsWith("//"))
|
|
34331
34398
|
prepend = true;
|
|
34332
34399
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
34333
|
-
while (
|
|
34334
|
-
|
|
34400
|
+
while (path24.match(DOUBLE_SLASH_RE2))
|
|
34401
|
+
path24 = path24.replace(DOUBLE_SLASH_RE2, "/");
|
|
34335
34402
|
if (prepend)
|
|
34336
|
-
|
|
34337
|
-
return
|
|
34403
|
+
path24 = "/" + path24;
|
|
34404
|
+
return path24;
|
|
34338
34405
|
}
|
|
34339
34406
|
function matchPatterns(patterns, testString, stats) {
|
|
34340
|
-
const
|
|
34407
|
+
const path24 = normalizePath(testString);
|
|
34341
34408
|
for (let index = 0; index < patterns.length; index++) {
|
|
34342
34409
|
const pattern = patterns[index];
|
|
34343
|
-
if (pattern(
|
|
34410
|
+
if (pattern(path24, stats)) {
|
|
34344
34411
|
return true;
|
|
34345
34412
|
}
|
|
34346
34413
|
}
|
|
@@ -34380,19 +34447,19 @@ var toUnix = (string4) => {
|
|
|
34380
34447
|
}
|
|
34381
34448
|
return str;
|
|
34382
34449
|
};
|
|
34383
|
-
var normalizePathToUnix = (
|
|
34384
|
-
var normalizeIgnored = (cwd3 = "") => (
|
|
34385
|
-
if (typeof
|
|
34386
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
34450
|
+
var normalizePathToUnix = (path24) => toUnix(sysPath2.normalize(toUnix(path24)));
|
|
34451
|
+
var normalizeIgnored = (cwd3 = "") => (path24) => {
|
|
34452
|
+
if (typeof path24 === "string") {
|
|
34453
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path24) ? path24 : sysPath2.join(cwd3, path24));
|
|
34387
34454
|
} else {
|
|
34388
|
-
return
|
|
34455
|
+
return path24;
|
|
34389
34456
|
}
|
|
34390
34457
|
};
|
|
34391
|
-
var getAbsolutePath = (
|
|
34392
|
-
if (sysPath2.isAbsolute(
|
|
34393
|
-
return
|
|
34458
|
+
var getAbsolutePath = (path24, cwd3) => {
|
|
34459
|
+
if (sysPath2.isAbsolute(path24)) {
|
|
34460
|
+
return path24;
|
|
34394
34461
|
}
|
|
34395
|
-
return sysPath2.join(cwd3,
|
|
34462
|
+
return sysPath2.join(cwd3, path24);
|
|
34396
34463
|
};
|
|
34397
34464
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
34398
34465
|
var DirEntry = class {
|
|
@@ -34447,10 +34514,10 @@ var DirEntry = class {
|
|
|
34447
34514
|
var STAT_METHOD_F = "stat";
|
|
34448
34515
|
var STAT_METHOD_L = "lstat";
|
|
34449
34516
|
var WatchHelper = class {
|
|
34450
|
-
constructor(
|
|
34517
|
+
constructor(path24, follow, fsw) {
|
|
34451
34518
|
this.fsw = fsw;
|
|
34452
|
-
const watchPath =
|
|
34453
|
-
this.path =
|
|
34519
|
+
const watchPath = path24;
|
|
34520
|
+
this.path = path24 = path24.replace(REPLACER_RE, "");
|
|
34454
34521
|
this.watchPath = watchPath;
|
|
34455
34522
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
34456
34523
|
this.dirParts = [];
|
|
@@ -34572,20 +34639,20 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34572
34639
|
this._closePromise = void 0;
|
|
34573
34640
|
let paths = unifyPaths(paths_);
|
|
34574
34641
|
if (cwd3) {
|
|
34575
|
-
paths = paths.map((
|
|
34576
|
-
const absPath = getAbsolutePath(
|
|
34642
|
+
paths = paths.map((path24) => {
|
|
34643
|
+
const absPath = getAbsolutePath(path24, cwd3);
|
|
34577
34644
|
return absPath;
|
|
34578
34645
|
});
|
|
34579
34646
|
}
|
|
34580
|
-
paths.forEach((
|
|
34581
|
-
this._removeIgnoredPath(
|
|
34647
|
+
paths.forEach((path24) => {
|
|
34648
|
+
this._removeIgnoredPath(path24);
|
|
34582
34649
|
});
|
|
34583
34650
|
this._userIgnored = void 0;
|
|
34584
34651
|
if (!this._readyCount)
|
|
34585
34652
|
this._readyCount = 0;
|
|
34586
34653
|
this._readyCount += paths.length;
|
|
34587
|
-
Promise.all(paths.map(async (
|
|
34588
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
34654
|
+
Promise.all(paths.map(async (path24) => {
|
|
34655
|
+
const res = await this._nodeFsHandler._addToNodeFs(path24, !_internal, void 0, 0, _origAdd);
|
|
34589
34656
|
if (res)
|
|
34590
34657
|
this._emitReady();
|
|
34591
34658
|
return res;
|
|
@@ -34607,17 +34674,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34607
34674
|
return this;
|
|
34608
34675
|
const paths = unifyPaths(paths_);
|
|
34609
34676
|
const { cwd: cwd3 } = this.options;
|
|
34610
|
-
paths.forEach((
|
|
34611
|
-
if (!sysPath2.isAbsolute(
|
|
34677
|
+
paths.forEach((path24) => {
|
|
34678
|
+
if (!sysPath2.isAbsolute(path24) && !this._closers.has(path24)) {
|
|
34612
34679
|
if (cwd3)
|
|
34613
|
-
|
|
34614
|
-
|
|
34680
|
+
path24 = sysPath2.join(cwd3, path24);
|
|
34681
|
+
path24 = sysPath2.resolve(path24);
|
|
34615
34682
|
}
|
|
34616
|
-
this._closePath(
|
|
34617
|
-
this._addIgnoredPath(
|
|
34618
|
-
if (this._watched.has(
|
|
34683
|
+
this._closePath(path24);
|
|
34684
|
+
this._addIgnoredPath(path24);
|
|
34685
|
+
if (this._watched.has(path24)) {
|
|
34619
34686
|
this._addIgnoredPath({
|
|
34620
|
-
path:
|
|
34687
|
+
path: path24,
|
|
34621
34688
|
recursive: true
|
|
34622
34689
|
});
|
|
34623
34690
|
}
|
|
@@ -34681,38 +34748,38 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34681
34748
|
* @param stats arguments to be passed with event
|
|
34682
34749
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
34683
34750
|
*/
|
|
34684
|
-
async _emit(event,
|
|
34751
|
+
async _emit(event, path24, stats) {
|
|
34685
34752
|
if (this.closed)
|
|
34686
34753
|
return;
|
|
34687
34754
|
const opts = this.options;
|
|
34688
34755
|
if (isWindows)
|
|
34689
|
-
|
|
34756
|
+
path24 = sysPath2.normalize(path24);
|
|
34690
34757
|
if (opts.cwd)
|
|
34691
|
-
|
|
34692
|
-
const args = [
|
|
34758
|
+
path24 = sysPath2.relative(opts.cwd, path24);
|
|
34759
|
+
const args = [path24];
|
|
34693
34760
|
if (stats != null)
|
|
34694
34761
|
args.push(stats);
|
|
34695
34762
|
const awf = opts.awaitWriteFinish;
|
|
34696
34763
|
let pw;
|
|
34697
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
34764
|
+
if (awf && (pw = this._pendingWrites.get(path24))) {
|
|
34698
34765
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
34699
34766
|
return this;
|
|
34700
34767
|
}
|
|
34701
34768
|
if (opts.atomic) {
|
|
34702
34769
|
if (event === EVENTS.UNLINK) {
|
|
34703
|
-
this._pendingUnlinks.set(
|
|
34770
|
+
this._pendingUnlinks.set(path24, [event, ...args]);
|
|
34704
34771
|
setTimeout(() => {
|
|
34705
|
-
this._pendingUnlinks.forEach((entry,
|
|
34772
|
+
this._pendingUnlinks.forEach((entry, path25) => {
|
|
34706
34773
|
this.emit(...entry);
|
|
34707
34774
|
this.emit(EVENTS.ALL, ...entry);
|
|
34708
|
-
this._pendingUnlinks.delete(
|
|
34775
|
+
this._pendingUnlinks.delete(path25);
|
|
34709
34776
|
});
|
|
34710
34777
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
34711
34778
|
return this;
|
|
34712
34779
|
}
|
|
34713
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
34780
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path24)) {
|
|
34714
34781
|
event = EVENTS.CHANGE;
|
|
34715
|
-
this._pendingUnlinks.delete(
|
|
34782
|
+
this._pendingUnlinks.delete(path24);
|
|
34716
34783
|
}
|
|
34717
34784
|
}
|
|
34718
34785
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -34730,16 +34797,16 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34730
34797
|
this.emitWithAll(event, args);
|
|
34731
34798
|
}
|
|
34732
34799
|
};
|
|
34733
|
-
this._awaitWriteFinish(
|
|
34800
|
+
this._awaitWriteFinish(path24, awf.stabilityThreshold, event, awfEmit);
|
|
34734
34801
|
return this;
|
|
34735
34802
|
}
|
|
34736
34803
|
if (event === EVENTS.CHANGE) {
|
|
34737
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
34804
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path24, 50);
|
|
34738
34805
|
if (isThrottled)
|
|
34739
34806
|
return this;
|
|
34740
34807
|
}
|
|
34741
34808
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
34742
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
34809
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path24) : path24;
|
|
34743
34810
|
let stats2;
|
|
34744
34811
|
try {
|
|
34745
34812
|
stats2 = await stat3(fullPath);
|
|
@@ -34770,23 +34837,23 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34770
34837
|
* @param timeout duration of time to suppress duplicate actions
|
|
34771
34838
|
* @returns tracking object or false if action should be suppressed
|
|
34772
34839
|
*/
|
|
34773
|
-
_throttle(actionType,
|
|
34840
|
+
_throttle(actionType, path24, timeout) {
|
|
34774
34841
|
if (!this._throttled.has(actionType)) {
|
|
34775
34842
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
34776
34843
|
}
|
|
34777
34844
|
const action = this._throttled.get(actionType);
|
|
34778
34845
|
if (!action)
|
|
34779
34846
|
throw new Error("invalid throttle");
|
|
34780
|
-
const actionPath = action.get(
|
|
34847
|
+
const actionPath = action.get(path24);
|
|
34781
34848
|
if (actionPath) {
|
|
34782
34849
|
actionPath.count++;
|
|
34783
34850
|
return false;
|
|
34784
34851
|
}
|
|
34785
34852
|
let timeoutObject;
|
|
34786
34853
|
const clear = () => {
|
|
34787
|
-
const item = action.get(
|
|
34854
|
+
const item = action.get(path24);
|
|
34788
34855
|
const count = item ? item.count : 0;
|
|
34789
|
-
action.delete(
|
|
34856
|
+
action.delete(path24);
|
|
34790
34857
|
clearTimeout(timeoutObject);
|
|
34791
34858
|
if (item)
|
|
34792
34859
|
clearTimeout(item.timeoutObject);
|
|
@@ -34794,7 +34861,7 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34794
34861
|
};
|
|
34795
34862
|
timeoutObject = setTimeout(clear, timeout);
|
|
34796
34863
|
const thr = { timeoutObject, clear, count: 0 };
|
|
34797
|
-
action.set(
|
|
34864
|
+
action.set(path24, thr);
|
|
34798
34865
|
return thr;
|
|
34799
34866
|
}
|
|
34800
34867
|
_incrReadyCount() {
|
|
@@ -34808,44 +34875,44 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34808
34875
|
* @param event
|
|
34809
34876
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
34810
34877
|
*/
|
|
34811
|
-
_awaitWriteFinish(
|
|
34878
|
+
_awaitWriteFinish(path24, threshold, event, awfEmit) {
|
|
34812
34879
|
const awf = this.options.awaitWriteFinish;
|
|
34813
34880
|
if (typeof awf !== "object")
|
|
34814
34881
|
return;
|
|
34815
34882
|
const pollInterval = awf.pollInterval;
|
|
34816
34883
|
let timeoutHandler;
|
|
34817
|
-
let fullPath =
|
|
34818
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
34819
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
34884
|
+
let fullPath = path24;
|
|
34885
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path24)) {
|
|
34886
|
+
fullPath = sysPath2.join(this.options.cwd, path24);
|
|
34820
34887
|
}
|
|
34821
34888
|
const now = /* @__PURE__ */ new Date();
|
|
34822
34889
|
const writes = this._pendingWrites;
|
|
34823
34890
|
function awaitWriteFinishFn(prevStat) {
|
|
34824
34891
|
statcb(fullPath, (err, curStat) => {
|
|
34825
|
-
if (err || !writes.has(
|
|
34892
|
+
if (err || !writes.has(path24)) {
|
|
34826
34893
|
if (err && err.code !== "ENOENT")
|
|
34827
34894
|
awfEmit(err);
|
|
34828
34895
|
return;
|
|
34829
34896
|
}
|
|
34830
34897
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
34831
34898
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
34832
|
-
writes.get(
|
|
34899
|
+
writes.get(path24).lastChange = now2;
|
|
34833
34900
|
}
|
|
34834
|
-
const pw = writes.get(
|
|
34901
|
+
const pw = writes.get(path24);
|
|
34835
34902
|
const df = now2 - pw.lastChange;
|
|
34836
34903
|
if (df >= threshold) {
|
|
34837
|
-
writes.delete(
|
|
34904
|
+
writes.delete(path24);
|
|
34838
34905
|
awfEmit(void 0, curStat);
|
|
34839
34906
|
} else {
|
|
34840
34907
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
34841
34908
|
}
|
|
34842
34909
|
});
|
|
34843
34910
|
}
|
|
34844
|
-
if (!writes.has(
|
|
34845
|
-
writes.set(
|
|
34911
|
+
if (!writes.has(path24)) {
|
|
34912
|
+
writes.set(path24, {
|
|
34846
34913
|
lastChange: now,
|
|
34847
34914
|
cancelWait: () => {
|
|
34848
|
-
writes.delete(
|
|
34915
|
+
writes.delete(path24);
|
|
34849
34916
|
clearTimeout(timeoutHandler);
|
|
34850
34917
|
return event;
|
|
34851
34918
|
}
|
|
@@ -34856,8 +34923,8 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34856
34923
|
/**
|
|
34857
34924
|
* Determines whether user has asked to ignore this path.
|
|
34858
34925
|
*/
|
|
34859
|
-
_isIgnored(
|
|
34860
|
-
if (this.options.atomic && DOT_RE.test(
|
|
34926
|
+
_isIgnored(path24, stats) {
|
|
34927
|
+
if (this.options.atomic && DOT_RE.test(path24))
|
|
34861
34928
|
return true;
|
|
34862
34929
|
if (!this._userIgnored) {
|
|
34863
34930
|
const { cwd: cwd3 } = this.options;
|
|
@@ -34867,17 +34934,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34867
34934
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd3)), ...ignored];
|
|
34868
34935
|
this._userIgnored = anymatch(list, void 0);
|
|
34869
34936
|
}
|
|
34870
|
-
return this._userIgnored(
|
|
34937
|
+
return this._userIgnored(path24, stats);
|
|
34871
34938
|
}
|
|
34872
|
-
_isntIgnored(
|
|
34873
|
-
return !this._isIgnored(
|
|
34939
|
+
_isntIgnored(path24, stat4) {
|
|
34940
|
+
return !this._isIgnored(path24, stat4);
|
|
34874
34941
|
}
|
|
34875
34942
|
/**
|
|
34876
34943
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
34877
34944
|
* @param path file or directory pattern being watched
|
|
34878
34945
|
*/
|
|
34879
|
-
_getWatchHelpers(
|
|
34880
|
-
return new WatchHelper(
|
|
34946
|
+
_getWatchHelpers(path24) {
|
|
34947
|
+
return new WatchHelper(path24, this.options.followSymlinks, this);
|
|
34881
34948
|
}
|
|
34882
34949
|
// Directory helpers
|
|
34883
34950
|
// -----------------
|
|
@@ -34909,63 +34976,63 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
34909
34976
|
* @param item base path of item/directory
|
|
34910
34977
|
*/
|
|
34911
34978
|
_remove(directory, item, isDirectory) {
|
|
34912
|
-
const
|
|
34913
|
-
const fullPath = sysPath2.resolve(
|
|
34914
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
34915
|
-
if (!this._throttle("remove",
|
|
34979
|
+
const path24 = sysPath2.join(directory, item);
|
|
34980
|
+
const fullPath = sysPath2.resolve(path24);
|
|
34981
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path24) || this._watched.has(fullPath);
|
|
34982
|
+
if (!this._throttle("remove", path24, 100))
|
|
34916
34983
|
return;
|
|
34917
34984
|
if (!isDirectory && this._watched.size === 1) {
|
|
34918
34985
|
this.add(directory, item, true);
|
|
34919
34986
|
}
|
|
34920
|
-
const wp = this._getWatchedDir(
|
|
34987
|
+
const wp = this._getWatchedDir(path24);
|
|
34921
34988
|
const nestedDirectoryChildren = wp.getChildren();
|
|
34922
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
34989
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path24, nested));
|
|
34923
34990
|
const parent = this._getWatchedDir(directory);
|
|
34924
34991
|
const wasTracked = parent.has(item);
|
|
34925
34992
|
parent.remove(item);
|
|
34926
34993
|
if (this._symlinkPaths.has(fullPath)) {
|
|
34927
34994
|
this._symlinkPaths.delete(fullPath);
|
|
34928
34995
|
}
|
|
34929
|
-
let relPath =
|
|
34996
|
+
let relPath = path24;
|
|
34930
34997
|
if (this.options.cwd)
|
|
34931
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
34998
|
+
relPath = sysPath2.relative(this.options.cwd, path24);
|
|
34932
34999
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
34933
35000
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
34934
35001
|
if (event === EVENTS.ADD)
|
|
34935
35002
|
return;
|
|
34936
35003
|
}
|
|
34937
|
-
this._watched.delete(
|
|
35004
|
+
this._watched.delete(path24);
|
|
34938
35005
|
this._watched.delete(fullPath);
|
|
34939
35006
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
34940
|
-
if (wasTracked && !this._isIgnored(
|
|
34941
|
-
this._emit(eventName,
|
|
34942
|
-
this._closePath(
|
|
35007
|
+
if (wasTracked && !this._isIgnored(path24))
|
|
35008
|
+
this._emit(eventName, path24);
|
|
35009
|
+
this._closePath(path24);
|
|
34943
35010
|
}
|
|
34944
35011
|
/**
|
|
34945
35012
|
* Closes all watchers for a path
|
|
34946
35013
|
*/
|
|
34947
|
-
_closePath(
|
|
34948
|
-
this._closeFile(
|
|
34949
|
-
const dir = sysPath2.dirname(
|
|
34950
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
35014
|
+
_closePath(path24) {
|
|
35015
|
+
this._closeFile(path24);
|
|
35016
|
+
const dir = sysPath2.dirname(path24);
|
|
35017
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path24));
|
|
34951
35018
|
}
|
|
34952
35019
|
/**
|
|
34953
35020
|
* Closes only file-specific watchers
|
|
34954
35021
|
*/
|
|
34955
|
-
_closeFile(
|
|
34956
|
-
const closers = this._closers.get(
|
|
35022
|
+
_closeFile(path24) {
|
|
35023
|
+
const closers = this._closers.get(path24);
|
|
34957
35024
|
if (!closers)
|
|
34958
35025
|
return;
|
|
34959
35026
|
closers.forEach((closer) => closer());
|
|
34960
|
-
this._closers.delete(
|
|
35027
|
+
this._closers.delete(path24);
|
|
34961
35028
|
}
|
|
34962
|
-
_addPathCloser(
|
|
35029
|
+
_addPathCloser(path24, closer) {
|
|
34963
35030
|
if (!closer)
|
|
34964
35031
|
return;
|
|
34965
|
-
let list = this._closers.get(
|
|
35032
|
+
let list = this._closers.get(path24);
|
|
34966
35033
|
if (!list) {
|
|
34967
35034
|
list = [];
|
|
34968
|
-
this._closers.set(
|
|
35035
|
+
this._closers.set(path24, list);
|
|
34969
35036
|
}
|
|
34970
35037
|
list.push(closer);
|
|
34971
35038
|
}
|
|
@@ -35004,7 +35071,7 @@ function shouldIgnoreRelative(rel) {
|
|
|
35004
35071
|
return false;
|
|
35005
35072
|
}
|
|
35006
35073
|
function startFileIndexWatcher(cwd3 = process.cwd()) {
|
|
35007
|
-
const resolved =
|
|
35074
|
+
const resolved = path22.resolve(cwd3);
|
|
35008
35075
|
let timer = null;
|
|
35009
35076
|
const runRebuild = () => {
|
|
35010
35077
|
try {
|
|
@@ -35025,7 +35092,7 @@ function startFileIndexWatcher(cwd3 = process.cwd()) {
|
|
|
35025
35092
|
ignoreInitial: true,
|
|
35026
35093
|
persistent: true,
|
|
35027
35094
|
ignored: (p) => {
|
|
35028
|
-
const rel =
|
|
35095
|
+
const rel = path22.isAbsolute(p) ? path22.relative(resolved, p).replace(/\\/g, "/") : p.replace(/\\/g, "/");
|
|
35029
35096
|
return shouldIgnoreRelative(rel || ".");
|
|
35030
35097
|
},
|
|
35031
35098
|
awaitWriteFinish: { stabilityThreshold: 250, pollInterval: 100 }
|
|
@@ -35287,7 +35354,7 @@ async function main() {
|
|
|
35287
35354
|
}
|
|
35288
35355
|
let worktreesRootAbs;
|
|
35289
35356
|
if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
|
|
35290
|
-
worktreesRootAbs =
|
|
35357
|
+
worktreesRootAbs = path23.resolve(opts.worktreesRoot.trim());
|
|
35291
35358
|
}
|
|
35292
35359
|
let refreshToken;
|
|
35293
35360
|
if ((!workspaceId || !authToken) && opts.config !== false) {
|