@buildautomaton/cli 0.1.85 → 0.1.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +602 -478
- package/dist/cli.js.map +4 -4
- package/dist/index.js +581 -457
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -973,8 +973,8 @@ var require_command = __commonJS({
|
|
|
973
973
|
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
|
|
974
974
|
var EventEmitter2 = __require("node:events").EventEmitter;
|
|
975
975
|
var childProcess2 = __require("node:child_process");
|
|
976
|
-
var
|
|
977
|
-
var
|
|
976
|
+
var path90 = __require("node:path");
|
|
977
|
+
var fs69 = __require("node:fs");
|
|
978
978
|
var process9 = __require("node:process");
|
|
979
979
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
980
980
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1906,11 +1906,11 @@ 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 =
|
|
1910
|
-
if (
|
|
1911
|
-
if (sourceExt.includes(
|
|
1909
|
+
const localBin = path90.resolve(baseDir, baseName);
|
|
1910
|
+
if (fs69.existsSync(localBin)) return localBin;
|
|
1911
|
+
if (sourceExt.includes(path90.extname(baseName))) return void 0;
|
|
1912
1912
|
const foundExt = sourceExt.find(
|
|
1913
|
-
(ext) =>
|
|
1913
|
+
(ext) => fs69.existsSync(`${localBin}${ext}`)
|
|
1914
1914
|
);
|
|
1915
1915
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1916
1916
|
return void 0;
|
|
@@ -1922,21 +1922,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1922
1922
|
if (this._scriptPath) {
|
|
1923
1923
|
let resolvedScriptPath;
|
|
1924
1924
|
try {
|
|
1925
|
-
resolvedScriptPath =
|
|
1925
|
+
resolvedScriptPath = fs69.realpathSync(this._scriptPath);
|
|
1926
1926
|
} catch (err) {
|
|
1927
1927
|
resolvedScriptPath = this._scriptPath;
|
|
1928
1928
|
}
|
|
1929
|
-
executableDir =
|
|
1930
|
-
|
|
1929
|
+
executableDir = path90.resolve(
|
|
1930
|
+
path90.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 = path90.basename(
|
|
1938
1938
|
this._scriptPath,
|
|
1939
|
-
|
|
1939
|
+
path90.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(path90.extname(executableFile));
|
|
1951
1951
|
let proc;
|
|
1952
1952
|
if (process9.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 = path90.basename(filename, path90.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(path91) {
|
|
2805
|
+
if (path91 === void 0) return this._executableDir;
|
|
2806
|
+
this._executableDir = path91;
|
|
2807
2807
|
return this;
|
|
2808
2808
|
}
|
|
2809
2809
|
/**
|
|
@@ -7729,7 +7729,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
7729
7729
|
join3(moduleDir, "..", sub, filename),
|
|
7730
7730
|
join3(moduleDir, "..", "..", "dist", sub, filename)
|
|
7731
7731
|
]);
|
|
7732
|
-
const resolved = candidates.find((
|
|
7732
|
+
const resolved = candidates.find((path90) => existsSync(path90));
|
|
7733
7733
|
if (!resolved) {
|
|
7734
7734
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
7735
7735
|
}
|
|
@@ -8807,7 +8807,7 @@ var require_ignore = __commonJS({
|
|
|
8807
8807
|
// path matching.
|
|
8808
8808
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
8809
8809
|
// @returns {TestResult} true if a file is ignored
|
|
8810
|
-
test(
|
|
8810
|
+
test(path90, checkUnignored, mode) {
|
|
8811
8811
|
let ignored = false;
|
|
8812
8812
|
let unignored = false;
|
|
8813
8813
|
let matchedRule;
|
|
@@ -8816,7 +8816,7 @@ var require_ignore = __commonJS({
|
|
|
8816
8816
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
8817
8817
|
return;
|
|
8818
8818
|
}
|
|
8819
|
-
const matched = rule[mode].test(
|
|
8819
|
+
const matched = rule[mode].test(path90);
|
|
8820
8820
|
if (!matched) {
|
|
8821
8821
|
return;
|
|
8822
8822
|
}
|
|
@@ -8837,17 +8837,17 @@ var require_ignore = __commonJS({
|
|
|
8837
8837
|
var throwError = (message, Ctor) => {
|
|
8838
8838
|
throw new Ctor(message);
|
|
8839
8839
|
};
|
|
8840
|
-
var checkPath = (
|
|
8841
|
-
if (!isString(
|
|
8840
|
+
var checkPath = (path90, originalPath, doThrow) => {
|
|
8841
|
+
if (!isString(path90)) {
|
|
8842
8842
|
return doThrow(
|
|
8843
8843
|
`path must be a string, but got \`${originalPath}\``,
|
|
8844
8844
|
TypeError
|
|
8845
8845
|
);
|
|
8846
8846
|
}
|
|
8847
|
-
if (!
|
|
8847
|
+
if (!path90) {
|
|
8848
8848
|
return doThrow(`path must not be empty`, TypeError);
|
|
8849
8849
|
}
|
|
8850
|
-
if (checkPath.isNotRelative(
|
|
8850
|
+
if (checkPath.isNotRelative(path90)) {
|
|
8851
8851
|
const r = "`path.relative()`d";
|
|
8852
8852
|
return doThrow(
|
|
8853
8853
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -8856,7 +8856,7 @@ var require_ignore = __commonJS({
|
|
|
8856
8856
|
}
|
|
8857
8857
|
return true;
|
|
8858
8858
|
};
|
|
8859
|
-
var isNotRelative = (
|
|
8859
|
+
var isNotRelative = (path90) => REGEX_TEST_INVALID_PATH.test(path90);
|
|
8860
8860
|
checkPath.isNotRelative = isNotRelative;
|
|
8861
8861
|
checkPath.convert = (p) => p;
|
|
8862
8862
|
var Ignore = class {
|
|
@@ -8886,19 +8886,19 @@ var require_ignore = __commonJS({
|
|
|
8886
8886
|
}
|
|
8887
8887
|
// @returns {TestResult}
|
|
8888
8888
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
8889
|
-
const
|
|
8889
|
+
const path90 = originalPath && checkPath.convert(originalPath);
|
|
8890
8890
|
checkPath(
|
|
8891
|
-
|
|
8891
|
+
path90,
|
|
8892
8892
|
originalPath,
|
|
8893
8893
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
8894
8894
|
);
|
|
8895
|
-
return this._t(
|
|
8895
|
+
return this._t(path90, cache2, checkUnignored, slices);
|
|
8896
8896
|
}
|
|
8897
|
-
checkIgnore(
|
|
8898
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
8899
|
-
return this.test(
|
|
8897
|
+
checkIgnore(path90) {
|
|
8898
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path90)) {
|
|
8899
|
+
return this.test(path90);
|
|
8900
8900
|
}
|
|
8901
|
-
const slices =
|
|
8901
|
+
const slices = path90.split(SLASH).filter(Boolean);
|
|
8902
8902
|
slices.pop();
|
|
8903
8903
|
if (slices.length) {
|
|
8904
8904
|
const parent = this._t(
|
|
@@ -8911,18 +8911,18 @@ var require_ignore = __commonJS({
|
|
|
8911
8911
|
return parent;
|
|
8912
8912
|
}
|
|
8913
8913
|
}
|
|
8914
|
-
return this._rules.test(
|
|
8914
|
+
return this._rules.test(path90, false, MODE_CHECK_IGNORE);
|
|
8915
8915
|
}
|
|
8916
|
-
_t(
|
|
8917
|
-
if (
|
|
8918
|
-
return cache2[
|
|
8916
|
+
_t(path90, cache2, checkUnignored, slices) {
|
|
8917
|
+
if (path90 in cache2) {
|
|
8918
|
+
return cache2[path90];
|
|
8919
8919
|
}
|
|
8920
8920
|
if (!slices) {
|
|
8921
|
-
slices =
|
|
8921
|
+
slices = path90.split(SLASH).filter(Boolean);
|
|
8922
8922
|
}
|
|
8923
8923
|
slices.pop();
|
|
8924
8924
|
if (!slices.length) {
|
|
8925
|
-
return cache2[
|
|
8925
|
+
return cache2[path90] = this._rules.test(path90, checkUnignored, MODE_IGNORE);
|
|
8926
8926
|
}
|
|
8927
8927
|
const parent = this._t(
|
|
8928
8928
|
slices.join(SLASH) + SLASH,
|
|
@@ -8930,29 +8930,29 @@ var require_ignore = __commonJS({
|
|
|
8930
8930
|
checkUnignored,
|
|
8931
8931
|
slices
|
|
8932
8932
|
);
|
|
8933
|
-
return cache2[
|
|
8933
|
+
return cache2[path90] = parent.ignored ? parent : this._rules.test(path90, checkUnignored, MODE_IGNORE);
|
|
8934
8934
|
}
|
|
8935
|
-
ignores(
|
|
8936
|
-
return this._test(
|
|
8935
|
+
ignores(path90) {
|
|
8936
|
+
return this._test(path90, this._ignoreCache, false).ignored;
|
|
8937
8937
|
}
|
|
8938
8938
|
createFilter() {
|
|
8939
|
-
return (
|
|
8939
|
+
return (path90) => !this.ignores(path90);
|
|
8940
8940
|
}
|
|
8941
8941
|
filter(paths) {
|
|
8942
8942
|
return makeArray(paths).filter(this.createFilter());
|
|
8943
8943
|
}
|
|
8944
8944
|
// @returns {TestResult}
|
|
8945
|
-
test(
|
|
8946
|
-
return this._test(
|
|
8945
|
+
test(path90) {
|
|
8946
|
+
return this._test(path90, this._testCache, true);
|
|
8947
8947
|
}
|
|
8948
8948
|
};
|
|
8949
8949
|
var factory = (options) => new Ignore(options);
|
|
8950
|
-
var isPathValid = (
|
|
8950
|
+
var isPathValid = (path90) => checkPath(path90 && checkPath.convert(path90), path90, RETURN_FALSE);
|
|
8951
8951
|
var setupWindows = () => {
|
|
8952
8952
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
8953
8953
|
checkPath.convert = makePosix;
|
|
8954
8954
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
8955
|
-
checkPath.isNotRelative = (
|
|
8955
|
+
checkPath.isNotRelative = (path90) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path90) || isNotRelative(path90);
|
|
8956
8956
|
};
|
|
8957
8957
|
if (
|
|
8958
8958
|
// Detect `process` so that it can run in browsers.
|
|
@@ -12913,10 +12913,10 @@ function mergeDefs(...defs) {
|
|
|
12913
12913
|
function cloneDef(schema) {
|
|
12914
12914
|
return mergeDefs(schema._zod.def);
|
|
12915
12915
|
}
|
|
12916
|
-
function getElementAtPath(obj,
|
|
12917
|
-
if (!
|
|
12916
|
+
function getElementAtPath(obj, path90) {
|
|
12917
|
+
if (!path90)
|
|
12918
12918
|
return obj;
|
|
12919
|
-
return
|
|
12919
|
+
return path90.reduce((acc, key) => acc?.[key], obj);
|
|
12920
12920
|
}
|
|
12921
12921
|
function promiseAllObject(promisesObj) {
|
|
12922
12922
|
const keys = Object.keys(promisesObj);
|
|
@@ -13244,11 +13244,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
13244
13244
|
}
|
|
13245
13245
|
return false;
|
|
13246
13246
|
}
|
|
13247
|
-
function prefixIssues(
|
|
13247
|
+
function prefixIssues(path90, issues) {
|
|
13248
13248
|
return issues.map((iss) => {
|
|
13249
13249
|
var _a4;
|
|
13250
13250
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
13251
|
-
iss.path.unshift(
|
|
13251
|
+
iss.path.unshift(path90);
|
|
13252
13252
|
return iss;
|
|
13253
13253
|
});
|
|
13254
13254
|
}
|
|
@@ -13465,16 +13465,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
13465
13465
|
}
|
|
13466
13466
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
13467
13467
|
const fieldErrors = { _errors: [] };
|
|
13468
|
-
const processError = (error52,
|
|
13468
|
+
const processError = (error52, path90 = []) => {
|
|
13469
13469
|
for (const issue2 of error52.issues) {
|
|
13470
13470
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
13471
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
13471
|
+
issue2.errors.map((issues) => processError({ issues }, [...path90, ...issue2.path]));
|
|
13472
13472
|
} else if (issue2.code === "invalid_key") {
|
|
13473
|
-
processError({ issues: issue2.issues }, [...
|
|
13473
|
+
processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
|
|
13474
13474
|
} else if (issue2.code === "invalid_element") {
|
|
13475
|
-
processError({ issues: issue2.issues }, [...
|
|
13475
|
+
processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
|
|
13476
13476
|
} else {
|
|
13477
|
-
const fullpath = [...
|
|
13477
|
+
const fullpath = [...path90, ...issue2.path];
|
|
13478
13478
|
if (fullpath.length === 0) {
|
|
13479
13479
|
fieldErrors._errors.push(mapper(issue2));
|
|
13480
13480
|
} else {
|
|
@@ -13501,17 +13501,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
13501
13501
|
}
|
|
13502
13502
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
13503
13503
|
const result = { errors: [] };
|
|
13504
|
-
const processError = (error52,
|
|
13504
|
+
const processError = (error52, path90 = []) => {
|
|
13505
13505
|
var _a4, _b;
|
|
13506
13506
|
for (const issue2 of error52.issues) {
|
|
13507
13507
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
13508
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
13508
|
+
issue2.errors.map((issues) => processError({ issues }, [...path90, ...issue2.path]));
|
|
13509
13509
|
} else if (issue2.code === "invalid_key") {
|
|
13510
|
-
processError({ issues: issue2.issues }, [...
|
|
13510
|
+
processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
|
|
13511
13511
|
} else if (issue2.code === "invalid_element") {
|
|
13512
|
-
processError({ issues: issue2.issues }, [...
|
|
13512
|
+
processError({ issues: issue2.issues }, [...path90, ...issue2.path]);
|
|
13513
13513
|
} else {
|
|
13514
|
-
const fullpath = [...
|
|
13514
|
+
const fullpath = [...path90, ...issue2.path];
|
|
13515
13515
|
if (fullpath.length === 0) {
|
|
13516
13516
|
result.errors.push(mapper(issue2));
|
|
13517
13517
|
continue;
|
|
@@ -13543,8 +13543,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
13543
13543
|
}
|
|
13544
13544
|
function toDotPath(_path) {
|
|
13545
13545
|
const segs = [];
|
|
13546
|
-
const
|
|
13547
|
-
for (const seg of
|
|
13546
|
+
const path90 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
13547
|
+
for (const seg of path90) {
|
|
13548
13548
|
if (typeof seg === "number")
|
|
13549
13549
|
segs.push(`[${seg}]`);
|
|
13550
13550
|
else if (typeof seg === "symbol")
|
|
@@ -26974,13 +26974,13 @@ function resolveRef(ref, ctx) {
|
|
|
26974
26974
|
if (!ref.startsWith("#")) {
|
|
26975
26975
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
26976
26976
|
}
|
|
26977
|
-
const
|
|
26978
|
-
if (
|
|
26977
|
+
const path90 = ref.slice(1).split("/").filter(Boolean);
|
|
26978
|
+
if (path90.length === 0) {
|
|
26979
26979
|
return ctx.rootSchema;
|
|
26980
26980
|
}
|
|
26981
26981
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
26982
|
-
if (
|
|
26983
|
-
const key =
|
|
26982
|
+
if (path90[0] === defsKey) {
|
|
26983
|
+
const key = path90[1];
|
|
26984
26984
|
if (!key || !ctx.defs[key]) {
|
|
26985
26985
|
throw new Error(`Reference not found: ${ref}`);
|
|
26986
26986
|
}
|
|
@@ -30063,7 +30063,7 @@ var require_has_flag = __commonJS({
|
|
|
30063
30063
|
var require_supports_color = __commonJS({
|
|
30064
30064
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
30065
30065
|
"use strict";
|
|
30066
|
-
var
|
|
30066
|
+
var os11 = __require("os");
|
|
30067
30067
|
var tty = __require("tty");
|
|
30068
30068
|
var hasFlag = require_has_flag();
|
|
30069
30069
|
var { env } = process;
|
|
@@ -30111,7 +30111,7 @@ var require_supports_color = __commonJS({
|
|
|
30111
30111
|
return min;
|
|
30112
30112
|
}
|
|
30113
30113
|
if (process.platform === "win32") {
|
|
30114
|
-
const osRelease =
|
|
30114
|
+
const osRelease = os11.release().split(".");
|
|
30115
30115
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
30116
30116
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
30117
30117
|
}
|
|
@@ -30357,10 +30357,10 @@ var require_src2 = __commonJS({
|
|
|
30357
30357
|
var fs_1 = __require("fs");
|
|
30358
30358
|
var debug_1 = __importDefault(require_src());
|
|
30359
30359
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
30360
|
-
function check2(
|
|
30361
|
-
log2(`checking %s`,
|
|
30360
|
+
function check2(path90, isFile, isDirectory) {
|
|
30361
|
+
log2(`checking %s`, path90);
|
|
30362
30362
|
try {
|
|
30363
|
-
const stat3 = fs_1.statSync(
|
|
30363
|
+
const stat3 = fs_1.statSync(path90);
|
|
30364
30364
|
if (stat3.isFile() && isFile) {
|
|
30365
30365
|
log2(`[OK] path represents a file`);
|
|
30366
30366
|
return true;
|
|
@@ -30380,8 +30380,8 @@ var require_src2 = __commonJS({
|
|
|
30380
30380
|
throw e;
|
|
30381
30381
|
}
|
|
30382
30382
|
}
|
|
30383
|
-
function exists2(
|
|
30384
|
-
return check2(
|
|
30383
|
+
function exists2(path90, type = exports.READABLE) {
|
|
30384
|
+
return check2(path90, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
30385
30385
|
}
|
|
30386
30386
|
exports.exists = exists2;
|
|
30387
30387
|
exports.FILE = 1;
|
|
@@ -30462,7 +30462,7 @@ var {
|
|
|
30462
30462
|
} = import_index.default;
|
|
30463
30463
|
|
|
30464
30464
|
// src/cli-version.ts
|
|
30465
|
-
var CLI_VERSION = "0.1.
|
|
30465
|
+
var CLI_VERSION = "0.1.86".length > 0 ? "0.1.86" : "0.0.0-dev";
|
|
30466
30466
|
|
|
30467
30467
|
// src/cli/defaults.ts
|
|
30468
30468
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
@@ -30470,8 +30470,8 @@ var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
|
|
|
30470
30470
|
|
|
30471
30471
|
// src/cli/run-cli-action.ts
|
|
30472
30472
|
init_cli_log_level();
|
|
30473
|
-
import * as
|
|
30474
|
-
import * as
|
|
30473
|
+
import * as fs68 from "node:fs";
|
|
30474
|
+
import * as path89 from "node:path";
|
|
30475
30475
|
|
|
30476
30476
|
// src/config.ts
|
|
30477
30477
|
import fs from "node:fs";
|
|
@@ -33552,8 +33552,8 @@ async function cancelRun(ctx, runId) {
|
|
|
33552
33552
|
}
|
|
33553
33553
|
|
|
33554
33554
|
// src/agents/acp/ensure-acp-client.ts
|
|
33555
|
-
import * as
|
|
33556
|
-
import * as
|
|
33555
|
+
import * as fs25 from "node:fs";
|
|
33556
|
+
import * as path32 from "node:path";
|
|
33557
33557
|
|
|
33558
33558
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
33559
33559
|
var external_exports = {};
|
|
@@ -34033,8 +34033,8 @@ function getErrorMap() {
|
|
|
34033
34033
|
|
|
34034
34034
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
34035
34035
|
var makeIssue = (params) => {
|
|
34036
|
-
const { data, path:
|
|
34037
|
-
const fullPath = [...
|
|
34036
|
+
const { data, path: path90, errorMaps, issueData } = params;
|
|
34037
|
+
const fullPath = [...path90, ...issueData.path || []];
|
|
34038
34038
|
const fullIssue = {
|
|
34039
34039
|
...issueData,
|
|
34040
34040
|
path: fullPath
|
|
@@ -34150,11 +34150,11 @@ var errorUtil;
|
|
|
34150
34150
|
|
|
34151
34151
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
34152
34152
|
var ParseInputLazyPath = class {
|
|
34153
|
-
constructor(parent, value,
|
|
34153
|
+
constructor(parent, value, path90, key) {
|
|
34154
34154
|
this._cachedPath = [];
|
|
34155
34155
|
this.parent = parent;
|
|
34156
34156
|
this.data = value;
|
|
34157
|
-
this._path =
|
|
34157
|
+
this._path = path90;
|
|
34158
34158
|
this._key = key;
|
|
34159
34159
|
}
|
|
34160
34160
|
get path() {
|
|
@@ -39738,6 +39738,7 @@ init_log();
|
|
|
39738
39738
|
function createCursorAcpSessionContext(options) {
|
|
39739
39739
|
const suppressLoadReplayRef = { value: false };
|
|
39740
39740
|
return {
|
|
39741
|
+
cloudSessionId: options.cloudSessionId,
|
|
39741
39742
|
cwd: options.cwd,
|
|
39742
39743
|
onFileChange: options.onFileChange,
|
|
39743
39744
|
mcpServers: options.mcpServers ?? [],
|
|
@@ -39830,6 +39831,41 @@ function createCursorAcpHandle(options) {
|
|
|
39830
39831
|
// src/agents/acp/clients/cursor/cursor-acp-init.ts
|
|
39831
39832
|
import * as readline from "node:readline";
|
|
39832
39833
|
|
|
39834
|
+
// src/agents/acp/clients/cursor/cursor-incoming-cursor-create-plan.ts
|
|
39835
|
+
function buildCursorCreatePlanToolCallUpdate(requestId, params) {
|
|
39836
|
+
const toolCallId = params.toolCallId ?? params.tool_call_id;
|
|
39837
|
+
if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
|
|
39838
|
+
const name = typeof params.name === "string" ? params.name.trim() : "";
|
|
39839
|
+
const overview = typeof params.overview === "string" ? params.overview : void 0;
|
|
39840
|
+
const plan = typeof params.plan === "string" ? params.plan : "";
|
|
39841
|
+
const todos = Array.isArray(params.todos) ? params.todos : void 0;
|
|
39842
|
+
const phases = Array.isArray(params.phases) ? params.phases : void 0;
|
|
39843
|
+
const isProject = typeof params.isProject === "boolean" ? params.isProject : void 0;
|
|
39844
|
+
return {
|
|
39845
|
+
sessionUpdate: "tool_call",
|
|
39846
|
+
toolCallId,
|
|
39847
|
+
title: name || "Plan",
|
|
39848
|
+
status: "pending",
|
|
39849
|
+
cursorPlan: {
|
|
39850
|
+
requestId,
|
|
39851
|
+
...name ? { name } : {},
|
|
39852
|
+
...overview != null ? { overview } : {},
|
|
39853
|
+
plan,
|
|
39854
|
+
...todos != null ? { todos } : {},
|
|
39855
|
+
...phases != null ? { phases } : {},
|
|
39856
|
+
...isProject != null ? { isProject } : {}
|
|
39857
|
+
}
|
|
39858
|
+
};
|
|
39859
|
+
}
|
|
39860
|
+
function queueCursorCreatePlanRequest(method, id, msg, deps) {
|
|
39861
|
+
const params = msg.params ?? {};
|
|
39862
|
+
const requestId = String(id);
|
|
39863
|
+
deps.pendingRequests.set(id, { method, params });
|
|
39864
|
+
const update = buildCursorCreatePlanToolCallUpdate(requestId, params);
|
|
39865
|
+
if (update) deps.onSessionUpdate?.(update);
|
|
39866
|
+
deps.onRequest?.({ requestId, method, params });
|
|
39867
|
+
}
|
|
39868
|
+
|
|
39833
39869
|
// src/agents/acp/clients/cursor/cursor-incoming-cursor-task.ts
|
|
39834
39870
|
function buildCursorTaskToolCallUpdate(params) {
|
|
39835
39871
|
const toolCallId = params.toolCallId ?? params.tool_call_id;
|
|
@@ -39862,9 +39898,13 @@ function handleCursorIncomingCursorTask(id, msg, deps) {
|
|
|
39862
39898
|
}
|
|
39863
39899
|
|
|
39864
39900
|
// src/agents/acp/clients/cursor/cursor-incoming-cursor-methods.ts
|
|
39865
|
-
var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/
|
|
39901
|
+
var CURSOR_BRIDGE_METHODS = /* @__PURE__ */ new Set(["cursor/ask_question"]);
|
|
39866
39902
|
var CURSOR_NOOP_METHODS = /* @__PURE__ */ new Set(["cursor/update_todos", "cursor/generate_image"]);
|
|
39867
39903
|
function handleCursorIncomingCursorMethods(method, id, msg, deps) {
|
|
39904
|
+
if (method === "cursor/create_plan") {
|
|
39905
|
+
queueCursorCreatePlanRequest(method, id, msg, deps);
|
|
39906
|
+
return true;
|
|
39907
|
+
}
|
|
39868
39908
|
if (CURSOR_BRIDGE_METHODS.has(method)) {
|
|
39869
39909
|
const params = msg.params ?? {};
|
|
39870
39910
|
deps.pendingRequests.set(id, { method, params });
|
|
@@ -39978,10 +40018,71 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
|
|
|
39978
40018
|
return true;
|
|
39979
40019
|
}
|
|
39980
40020
|
|
|
40021
|
+
// src/agents/acp/clients/cursor/write-create-plan-file.ts
|
|
40022
|
+
import * as fs24 from "node:fs";
|
|
40023
|
+
import * as path29 from "node:path";
|
|
40024
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
40025
|
+
|
|
40026
|
+
// src/paths/session-plans-paths.ts
|
|
40027
|
+
import * as os8 from "node:os";
|
|
40028
|
+
import * as path28 from "node:path";
|
|
40029
|
+
function getSessionPlansRootDir() {
|
|
40030
|
+
return path28.join(os8.homedir(), ".buildautomaton", "plans");
|
|
40031
|
+
}
|
|
40032
|
+
function sanitizeSessionPlansKey(sessionId) {
|
|
40033
|
+
const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
|
|
40034
|
+
return t || "session";
|
|
40035
|
+
}
|
|
40036
|
+
function getSessionPlansDir(sessionId) {
|
|
40037
|
+
return path28.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
|
|
40038
|
+
}
|
|
40039
|
+
|
|
40040
|
+
// src/agents/acp/clients/cursor/write-create-plan-file.ts
|
|
40041
|
+
function sanitizePlanFileBase(toolCallId) {
|
|
40042
|
+
const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
|
|
40043
|
+
return t || "plan";
|
|
40044
|
+
}
|
|
40045
|
+
function writeCreatePlanFile(params) {
|
|
40046
|
+
const dir = getSessionPlansDir(params.cloudSessionId);
|
|
40047
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
40048
|
+
const filePath = path29.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
|
|
40049
|
+
fs24.writeFileSync(filePath, params.planMarkdown, "utf8");
|
|
40050
|
+
return pathToFileURL2(filePath).href;
|
|
40051
|
+
}
|
|
40052
|
+
|
|
40053
|
+
// src/agents/acp/clients/cursor/enrich-create-plan-rpc-result.ts
|
|
40054
|
+
function asRecord2(v) {
|
|
40055
|
+
return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
40056
|
+
}
|
|
40057
|
+
function enrichCreatePlanRpcResult(result, pendingParams, cloudSessionId) {
|
|
40058
|
+
const root = asRecord2(result);
|
|
40059
|
+
const outcome = asRecord2(root?.outcome);
|
|
40060
|
+
if (!outcome) return result;
|
|
40061
|
+
const kind = typeof outcome.outcome === "string" ? outcome.outcome : "";
|
|
40062
|
+
if (kind !== "accepted") {
|
|
40063
|
+
const { plan: _drop, ...rest } = outcome;
|
|
40064
|
+
return { ...root, outcome: rest };
|
|
40065
|
+
}
|
|
40066
|
+
const planMarkdown = typeof outcome.plan === "string" ? outcome.plan : "";
|
|
40067
|
+
const toolCallIdRaw = pendingParams.toolCallId ?? pendingParams.tool_call_id;
|
|
40068
|
+
const toolCallId = typeof toolCallIdRaw === "string" ? toolCallIdRaw.trim() : "";
|
|
40069
|
+
const sessionId = cloudSessionId?.trim() ?? "";
|
|
40070
|
+
if (planMarkdown && toolCallId && sessionId) {
|
|
40071
|
+
const planUri = writeCreatePlanFile({ cloudSessionId: sessionId, toolCallId, planMarkdown });
|
|
40072
|
+
return { outcome: { outcome: "accepted", planUri } };
|
|
40073
|
+
}
|
|
40074
|
+
return { outcome: { outcome: "accepted" } };
|
|
40075
|
+
}
|
|
40076
|
+
|
|
39981
40077
|
// src/agents/acp/clients/cursor/cursor-incoming-resolve-request.ts
|
|
39982
|
-
function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result) {
|
|
40078
|
+
function resolveCursorIncomingRequest(pendingRequests2, respond, requestId, result, cloudSessionId) {
|
|
39983
40079
|
const pending2 = pendingRequests2.get(requestId);
|
|
39984
|
-
|
|
40080
|
+
let payload = result;
|
|
40081
|
+
if (pending2?.method === "session/request_permission") {
|
|
40082
|
+
payload = enrichAcpPermissionRpcResultFromRequestParams(result, pending2.params);
|
|
40083
|
+
} else if (pending2?.method === "cursor/create_plan") {
|
|
40084
|
+
payload = enrichCreatePlanRpcResult(result, pending2.params, cloudSessionId ?? void 0);
|
|
40085
|
+
}
|
|
39985
40086
|
respond(requestId, payload);
|
|
39986
40087
|
pendingRequests2.delete(requestId);
|
|
39987
40088
|
}
|
|
@@ -40042,7 +40143,13 @@ function createCursorAcpIncomingLineHandler(deps) {
|
|
|
40042
40143
|
pendingRequests: deps.pendingRequests
|
|
40043
40144
|
};
|
|
40044
40145
|
return {
|
|
40045
|
-
resolveRequest: (requestId, result) => resolveCursorIncomingRequest(
|
|
40146
|
+
resolveRequest: (requestId, result) => resolveCursorIncomingRequest(
|
|
40147
|
+
deps.pendingRequests,
|
|
40148
|
+
deps.respond,
|
|
40149
|
+
requestId,
|
|
40150
|
+
result,
|
|
40151
|
+
deps.sessionCtx.cloudSessionId
|
|
40152
|
+
),
|
|
40046
40153
|
handleLine(line) {
|
|
40047
40154
|
const msg = safeJsonParse(line);
|
|
40048
40155
|
if (!msg) return;
|
|
@@ -40245,6 +40352,7 @@ async function createCursorAcpClient(options) {
|
|
|
40245
40352
|
const skipBrowserAuthenticate = cursorAgentUsesApiKeyAuth(spawnEnv);
|
|
40246
40353
|
const sessionCtx = createCursorAcpSessionContext({
|
|
40247
40354
|
cwd,
|
|
40355
|
+
cloudSessionId: options.cloudSessionId,
|
|
40248
40356
|
mcpServers: options.mcpServers,
|
|
40249
40357
|
persistedAcpSessionId,
|
|
40250
40358
|
backendAgentType,
|
|
@@ -40394,18 +40502,18 @@ import { existsSync as existsSync4, statSync } from "node:fs";
|
|
|
40394
40502
|
|
|
40395
40503
|
// src/git/get-git-repo-root-sync.ts
|
|
40396
40504
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
40397
|
-
import * as
|
|
40505
|
+
import * as path30 from "node:path";
|
|
40398
40506
|
var GIT_LOOKUP_TIMEOUT_MS = 2e3;
|
|
40399
40507
|
function getGitRepoRootSync(startDir) {
|
|
40400
40508
|
try {
|
|
40401
40509
|
const out = execFileSync3("git", ["rev-parse", "--show-toplevel"], {
|
|
40402
|
-
cwd:
|
|
40510
|
+
cwd: path30.resolve(startDir),
|
|
40403
40511
|
encoding: "utf8",
|
|
40404
40512
|
stdio: ["ignore", "pipe", "ignore"],
|
|
40405
40513
|
maxBuffer: 1024 * 1024,
|
|
40406
40514
|
timeout: GIT_LOOKUP_TIMEOUT_MS
|
|
40407
40515
|
}).trim();
|
|
40408
|
-
return out ?
|
|
40516
|
+
return out ? path30.resolve(out) : null;
|
|
40409
40517
|
} catch {
|
|
40410
40518
|
return null;
|
|
40411
40519
|
}
|
|
@@ -40414,26 +40522,26 @@ function getGitRepoRootSync(startDir) {
|
|
|
40414
40522
|
// src/agents/acp/workspace-files.ts
|
|
40415
40523
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
40416
40524
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
40417
|
-
import * as
|
|
40525
|
+
import * as path31 from "node:path";
|
|
40418
40526
|
var GIT_FILE_READ_TIMEOUT_MS = 2e3;
|
|
40419
40527
|
function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
|
|
40420
40528
|
const trimmed2 = rawPath.trim();
|
|
40421
40529
|
if (!trimmed2) return null;
|
|
40422
|
-
const normalizedSessionParent =
|
|
40530
|
+
const normalizedSessionParent = path31.resolve(sessionParentPath);
|
|
40423
40531
|
let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
|
|
40424
40532
|
if (!resolvedPath) {
|
|
40425
|
-
const candidate =
|
|
40533
|
+
const candidate = path31.isAbsolute(trimmed2) ? path31.normalize(trimmed2) : path31.normalize(path31.resolve(normalizedSessionParent, trimmed2));
|
|
40426
40534
|
const gitRoot2 = getGitRepoRootSync(sessionParentPath);
|
|
40427
40535
|
if (!gitRoot2) return null;
|
|
40428
|
-
const rel =
|
|
40429
|
-
if (rel.startsWith("..") ||
|
|
40536
|
+
const rel = path31.relative(gitRoot2, candidate);
|
|
40537
|
+
if (rel.startsWith("..") || path31.isAbsolute(rel)) return null;
|
|
40430
40538
|
resolvedPath = candidate;
|
|
40431
40539
|
}
|
|
40432
40540
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
40433
40541
|
if (gitRoot) {
|
|
40434
|
-
const relFromRoot =
|
|
40435
|
-
if (!relFromRoot.startsWith("..") && !
|
|
40436
|
-
return { resolvedPath, display: relFromRoot.split(
|
|
40542
|
+
const relFromRoot = path31.relative(gitRoot, resolvedPath);
|
|
40543
|
+
if (!relFromRoot.startsWith("..") && !path31.isAbsolute(relFromRoot)) {
|
|
40544
|
+
return { resolvedPath, display: relFromRoot.split(path31.sep).join("/") };
|
|
40437
40545
|
}
|
|
40438
40546
|
}
|
|
40439
40547
|
return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
|
|
@@ -40442,9 +40550,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
|
|
|
40442
40550
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
40443
40551
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
40444
40552
|
if (gitRoot) {
|
|
40445
|
-
const resolvedPath2 =
|
|
40446
|
-
const rel =
|
|
40447
|
-
if (!rel.startsWith("..") && !
|
|
40553
|
+
const resolvedPath2 = path31.resolve(gitRoot, displayPath);
|
|
40554
|
+
const rel = path31.relative(gitRoot, resolvedPath2);
|
|
40555
|
+
if (!rel.startsWith("..") && !path31.isAbsolute(rel)) {
|
|
40448
40556
|
try {
|
|
40449
40557
|
return readFileSync4(resolvedPath2, "utf8");
|
|
40450
40558
|
} catch {
|
|
@@ -40463,9 +40571,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
|
|
|
40463
40571
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
40464
40572
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
40465
40573
|
if (gitRoot) {
|
|
40466
|
-
const resolvedPath =
|
|
40467
|
-
const rel =
|
|
40468
|
-
if (!rel.startsWith("..") && !
|
|
40574
|
+
const resolvedPath = path31.resolve(gitRoot, displayPath);
|
|
40575
|
+
const rel = path31.relative(gitRoot, resolvedPath);
|
|
40576
|
+
if (!rel.startsWith("..") && !path31.isAbsolute(rel)) return resolvedPath;
|
|
40469
40577
|
}
|
|
40470
40578
|
return resolveSafePathUnderCwd(sessionParentPath, displayPath);
|
|
40471
40579
|
}
|
|
@@ -41352,11 +41460,11 @@ init_cli_process_interrupt();
|
|
|
41352
41460
|
var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
|
|
41353
41461
|
|
|
41354
41462
|
// src/mcp/resolve-bridge-mcp-server-path.ts
|
|
41355
|
-
import { dirname as dirname7, join as
|
|
41463
|
+
import { dirname as dirname7, join as join10 } from "node:path";
|
|
41356
41464
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
41357
41465
|
function resolveBridgeMcpServerScriptPath() {
|
|
41358
41466
|
const cliDir = dirname7(fileURLToPath7(import.meta.url));
|
|
41359
|
-
return
|
|
41467
|
+
return join10(cliDir, "bridge-mcp-server.js");
|
|
41360
41468
|
}
|
|
41361
41469
|
|
|
41362
41470
|
// src/mcp/build-acp-mcp-servers.ts
|
|
@@ -41415,7 +41523,7 @@ async function ensureAcpClient(options) {
|
|
|
41415
41523
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
41416
41524
|
await state.acpStartPromise;
|
|
41417
41525
|
}
|
|
41418
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
41526
|
+
if (state.acpHandle && state.lastAcpCwd != null && path32.resolve(state.lastAcpCwd) !== path32.resolve(targetSessionParentPath)) {
|
|
41419
41527
|
try {
|
|
41420
41528
|
state.acpHandle.disconnect();
|
|
41421
41529
|
} catch {
|
|
@@ -41447,7 +41555,7 @@ async function ensureAcpClient(options) {
|
|
|
41447
41555
|
if (!state.acpStartPromise) {
|
|
41448
41556
|
let statOk = false;
|
|
41449
41557
|
try {
|
|
41450
|
-
const st = await
|
|
41558
|
+
const st = await fs25.promises.stat(targetSessionParentPath);
|
|
41451
41559
|
statOk = st.isDirectory();
|
|
41452
41560
|
if (!statOk) {
|
|
41453
41561
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
|
|
@@ -41526,6 +41634,7 @@ async function ensureAcpClient(options) {
|
|
|
41526
41634
|
},
|
|
41527
41635
|
...hooks,
|
|
41528
41636
|
cwd: targetSessionParentPath,
|
|
41637
|
+
cloudSessionId: cloudSessionId ?? null,
|
|
41529
41638
|
mcpServers
|
|
41530
41639
|
}).then(async (h) => {
|
|
41531
41640
|
if (spawnEpoch !== state.clientEpoch || isCliImmediateShutdownRequested()) {
|
|
@@ -41745,8 +41854,8 @@ async function execGitFile(args, options) {
|
|
|
41745
41854
|
}
|
|
41746
41855
|
|
|
41747
41856
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
41748
|
-
function normalizeGitDiffPath(
|
|
41749
|
-
return
|
|
41857
|
+
function normalizeGitDiffPath(path90) {
|
|
41858
|
+
return path90.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
41750
41859
|
}
|
|
41751
41860
|
|
|
41752
41861
|
// src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -41785,7 +41894,7 @@ function parseNameStatusLines(lines) {
|
|
|
41785
41894
|
}
|
|
41786
41895
|
|
|
41787
41896
|
// src/git/snapshot/diff/messages.ts
|
|
41788
|
-
import * as
|
|
41897
|
+
import * as path33 from "node:path";
|
|
41789
41898
|
|
|
41790
41899
|
// src/git/snapshot/diff/files.ts
|
|
41791
41900
|
import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
@@ -41816,7 +41925,7 @@ async function buildTrackedChangeMessage(options) {
|
|
|
41816
41925
|
const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
|
|
41817
41926
|
const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
|
|
41818
41927
|
if (!patchContent.trim()) return null;
|
|
41819
|
-
const workspaceFilePath =
|
|
41928
|
+
const workspaceFilePath = path33.join(repoPath, rel);
|
|
41820
41929
|
const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
|
|
41821
41930
|
const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
|
|
41822
41931
|
return {
|
|
@@ -41848,9 +41957,9 @@ function buildUntrackedChangeMessage(options) {
|
|
|
41848
41957
|
}
|
|
41849
41958
|
|
|
41850
41959
|
// src/git/snapshot/diff/paths.ts
|
|
41851
|
-
import * as
|
|
41960
|
+
import * as path34 from "node:path";
|
|
41852
41961
|
function repoDisplayPath(repoPath, multiRepo) {
|
|
41853
|
-
const slug =
|
|
41962
|
+
const slug = path34.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
|
|
41854
41963
|
return (rel) => multiRepo ? `${slug}/${rel}` : rel;
|
|
41855
41964
|
}
|
|
41856
41965
|
function safeRelPath(rel) {
|
|
@@ -41862,12 +41971,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
|
|
|
41862
41971
|
}
|
|
41863
41972
|
|
|
41864
41973
|
// src/git/snapshot/diff/move-pairs.ts
|
|
41865
|
-
import * as
|
|
41974
|
+
import * as path35 from "node:path";
|
|
41866
41975
|
async function readUntrackedTexts(repoPath, untracked) {
|
|
41867
41976
|
const out = /* @__PURE__ */ new Map();
|
|
41868
41977
|
await forEachWithGitYield(untracked, async (rel) => {
|
|
41869
41978
|
if (!safeRelPath(rel)) return;
|
|
41870
|
-
const newText = await readWorkspaceFileAsUtf8(
|
|
41979
|
+
const newText = await readWorkspaceFileAsUtf8(path35.join(repoPath, rel));
|
|
41871
41980
|
if (newText !== void 0) out.set(rel, newText);
|
|
41872
41981
|
});
|
|
41873
41982
|
return out;
|
|
@@ -41984,12 +42093,12 @@ async function collectRepoTurnChanges(options) {
|
|
|
41984
42093
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
41985
42094
|
|
|
41986
42095
|
// src/git/snapshot/types.ts
|
|
41987
|
-
import * as
|
|
42096
|
+
import * as path36 from "node:path";
|
|
41988
42097
|
function snapshotsDirForCwd(agentCwd) {
|
|
41989
|
-
return
|
|
42098
|
+
return path36.join(agentCwd, ".buildautomaton", "snapshots");
|
|
41990
42099
|
}
|
|
41991
42100
|
function snapshotFilePath(agentCwd, runId) {
|
|
41992
|
-
return
|
|
42101
|
+
return path36.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
41993
42102
|
}
|
|
41994
42103
|
|
|
41995
42104
|
// src/git/snapshot/diff/load-pre-turn-snapshot.ts
|
|
@@ -42057,6 +42166,18 @@ function reportPostTurnEnrichment(options) {
|
|
|
42057
42166
|
});
|
|
42058
42167
|
}
|
|
42059
42168
|
|
|
42169
|
+
// src/agents/acp/clients/cursor/cleanup-session-plans.ts
|
|
42170
|
+
import * as fs26 from "node:fs";
|
|
42171
|
+
function cleanupSessionPlans(sessionId) {
|
|
42172
|
+
const id = typeof sessionId === "string" ? sessionId.trim() : "";
|
|
42173
|
+
if (!id) return;
|
|
42174
|
+
const dir = getSessionPlansDir(id);
|
|
42175
|
+
try {
|
|
42176
|
+
fs26.rmSync(dir, { recursive: true, force: true });
|
|
42177
|
+
} catch {
|
|
42178
|
+
}
|
|
42179
|
+
}
|
|
42180
|
+
|
|
42060
42181
|
// src/agents/acp/prompts/finalize-and-send-prompt-result.ts
|
|
42061
42182
|
async function finalizeAndSendPromptResult(params) {
|
|
42062
42183
|
const {
|
|
@@ -42074,6 +42195,7 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
42074
42195
|
sendSessionUpdate,
|
|
42075
42196
|
log: log2
|
|
42076
42197
|
} = params;
|
|
42198
|
+
cleanupSessionPlans(sessionId);
|
|
42077
42199
|
const planningTodosSubmit = isPlanningSession ? await maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
42078
42200
|
sessionId,
|
|
42079
42201
|
runId,
|
|
@@ -43197,7 +43319,7 @@ async function createBridgeAccessState(options = {}) {
|
|
|
43197
43319
|
}
|
|
43198
43320
|
|
|
43199
43321
|
// src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
43200
|
-
import * as
|
|
43322
|
+
import * as path38 from "node:path";
|
|
43201
43323
|
|
|
43202
43324
|
// src/agents/detect-local-agent-types.ts
|
|
43203
43325
|
init_yield_to_event_loop();
|
|
@@ -43302,7 +43424,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
|
|
|
43302
43424
|
init_cli_database();
|
|
43303
43425
|
|
|
43304
43426
|
// src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
43305
|
-
import * as
|
|
43427
|
+
import * as path37 from "node:path";
|
|
43306
43428
|
init_cli_database();
|
|
43307
43429
|
init_cli_process_interrupt();
|
|
43308
43430
|
async function probeOneAgentTypeForCapabilities(params) {
|
|
@@ -43342,7 +43464,7 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
43342
43464
|
if (!canContinue()) return false;
|
|
43343
43465
|
handle = await resolved.createClient({
|
|
43344
43466
|
command: resolved.command,
|
|
43345
|
-
cwd:
|
|
43467
|
+
cwd: path37.resolve(cwd),
|
|
43346
43468
|
backendAgentType: agentType,
|
|
43347
43469
|
sessionMode: "agent",
|
|
43348
43470
|
persistedAcpSessionId: null,
|
|
@@ -43435,7 +43557,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
43435
43557
|
const { workspaceId, log: log2, getWs } = params;
|
|
43436
43558
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
43437
43559
|
if (!isCurrent()) return;
|
|
43438
|
-
const cwd =
|
|
43560
|
+
const cwd = path38.resolve(getBridgeRoot());
|
|
43439
43561
|
async function sendBatchFromCache() {
|
|
43440
43562
|
if (!isCurrent()) return;
|
|
43441
43563
|
const socket = getWs();
|
|
@@ -43562,7 +43684,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
43562
43684
|
}
|
|
43563
43685
|
|
|
43564
43686
|
// src/connection/create-bridge-preview-stack.ts
|
|
43565
|
-
import * as
|
|
43687
|
+
import * as path41 from "node:path";
|
|
43566
43688
|
|
|
43567
43689
|
// src/preview-environments/manager/firehose-messages.ts
|
|
43568
43690
|
function buildFirehoseSnapshotMessage(params) {
|
|
@@ -43880,7 +44002,7 @@ function attachChildErrorHandler(d) {
|
|
|
43880
44002
|
}
|
|
43881
44003
|
|
|
43882
44004
|
// src/preview-environments/process/wire/handle-exit.ts
|
|
43883
|
-
import
|
|
44005
|
+
import fs27 from "node:fs";
|
|
43884
44006
|
function logStopLine(d, code, signal) {
|
|
43885
44007
|
const { title } = d;
|
|
43886
44008
|
if (signal) {
|
|
@@ -43919,7 +44041,7 @@ function attachChildExitHandler(d) {
|
|
|
43919
44041
|
const cleanupDir = d.mergedCleanupDir;
|
|
43920
44042
|
const mergedPath = d.mergedLogPath;
|
|
43921
44043
|
if (mergedPath && !stale) {
|
|
43922
|
-
|
|
44044
|
+
fs27.readFile(mergedPath, (err, buf) => {
|
|
43923
44045
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
43924
44046
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
43925
44047
|
if (chunk.length > 0) {
|
|
@@ -43965,7 +44087,7 @@ function wireChildOutputPipes(d) {
|
|
|
43965
44087
|
}
|
|
43966
44088
|
|
|
43967
44089
|
// src/preview-environments/process/wire/poll-merged-log.ts
|
|
43968
|
-
import
|
|
44090
|
+
import fs28 from "node:fs";
|
|
43969
44091
|
function startMergedLogPoll(d) {
|
|
43970
44092
|
if (!d.mergedLogPath || !d.mergedCleanupDir) return;
|
|
43971
44093
|
const { environmentId } = d;
|
|
@@ -43975,7 +44097,7 @@ function startMergedLogPoll(d) {
|
|
|
43975
44097
|
d.setPollInterval(void 0);
|
|
43976
44098
|
return;
|
|
43977
44099
|
}
|
|
43978
|
-
|
|
44100
|
+
fs28.readFile(d.mergedLogPath, (err, buf) => {
|
|
43979
44101
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
43980
44102
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
43981
44103
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -44190,7 +44312,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
|
|
|
44190
44312
|
}
|
|
44191
44313
|
|
|
44192
44314
|
// src/preview-environments/manager/shell-spawn/utils.ts
|
|
44193
|
-
import
|
|
44315
|
+
import fs29 from "node:fs";
|
|
44194
44316
|
function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
|
|
44195
44317
|
return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
|
|
44196
44318
|
}
|
|
@@ -44199,7 +44321,7 @@ function isSpawnEbadf(e) {
|
|
|
44199
44321
|
}
|
|
44200
44322
|
function rmDirQuiet(dir) {
|
|
44201
44323
|
try {
|
|
44202
|
-
|
|
44324
|
+
fs29.rmSync(dir, { recursive: true, force: true });
|
|
44203
44325
|
} catch {
|
|
44204
44326
|
}
|
|
44205
44327
|
}
|
|
@@ -44207,7 +44329,7 @@ var cachedDevNullReadFd;
|
|
|
44207
44329
|
function devNullReadFd() {
|
|
44208
44330
|
if (cachedDevNullReadFd === void 0) {
|
|
44209
44331
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
44210
|
-
cachedDevNullReadFd =
|
|
44332
|
+
cachedDevNullReadFd = fs29.openSync(devPath, "r");
|
|
44211
44333
|
}
|
|
44212
44334
|
return cachedDevNullReadFd;
|
|
44213
44335
|
}
|
|
@@ -44287,15 +44409,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
44287
44409
|
|
|
44288
44410
|
// src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
44289
44411
|
import { spawn as spawn6 } from "node:child_process";
|
|
44290
|
-
import
|
|
44412
|
+
import fs30 from "node:fs";
|
|
44291
44413
|
import { tmpdir } from "node:os";
|
|
44292
|
-
import
|
|
44414
|
+
import path39 from "node:path";
|
|
44293
44415
|
function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
44294
|
-
const tmpRoot =
|
|
44295
|
-
const logPath =
|
|
44416
|
+
const tmpRoot = fs30.mkdtempSync(path39.join(tmpdir(), "ba-devsrv-log-"));
|
|
44417
|
+
const logPath = path39.join(tmpRoot, "combined.log");
|
|
44296
44418
|
let logFd;
|
|
44297
44419
|
try {
|
|
44298
|
-
logFd =
|
|
44420
|
+
logFd = fs30.openSync(logPath, "a");
|
|
44299
44421
|
} catch {
|
|
44300
44422
|
rmDirQuiet(tmpRoot);
|
|
44301
44423
|
return null;
|
|
@@ -44319,7 +44441,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
44319
44441
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
44320
44442
|
);
|
|
44321
44443
|
}
|
|
44322
|
-
|
|
44444
|
+
fs30.closeSync(logFd);
|
|
44323
44445
|
return {
|
|
44324
44446
|
proc,
|
|
44325
44447
|
pipedStdoutStderr: true,
|
|
@@ -44328,7 +44450,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
44328
44450
|
};
|
|
44329
44451
|
} catch (e) {
|
|
44330
44452
|
try {
|
|
44331
|
-
|
|
44453
|
+
fs30.closeSync(logFd);
|
|
44332
44454
|
} catch {
|
|
44333
44455
|
}
|
|
44334
44456
|
rmDirQuiet(tmpRoot);
|
|
@@ -44339,22 +44461,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
44339
44461
|
|
|
44340
44462
|
// src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
44341
44463
|
import { spawn as spawn7 } from "node:child_process";
|
|
44342
|
-
import
|
|
44464
|
+
import fs31 from "node:fs";
|
|
44343
44465
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
44344
|
-
import
|
|
44466
|
+
import path40 from "node:path";
|
|
44345
44467
|
function shSingleQuote(s) {
|
|
44346
44468
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
44347
44469
|
}
|
|
44348
44470
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
|
|
44349
|
-
const tmpRoot =
|
|
44350
|
-
const logPath =
|
|
44351
|
-
const innerPath =
|
|
44352
|
-
const runnerPath =
|
|
44471
|
+
const tmpRoot = fs31.mkdtempSync(path40.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
44472
|
+
const logPath = path40.join(tmpRoot, "combined.log");
|
|
44473
|
+
const innerPath = path40.join(tmpRoot, "_cmd.sh");
|
|
44474
|
+
const runnerPath = path40.join(tmpRoot, "_run.sh");
|
|
44353
44475
|
try {
|
|
44354
|
-
|
|
44476
|
+
fs31.writeFileSync(innerPath, `#!/bin/sh
|
|
44355
44477
|
${command}
|
|
44356
44478
|
`);
|
|
44357
|
-
|
|
44479
|
+
fs31.writeFileSync(
|
|
44358
44480
|
runnerPath,
|
|
44359
44481
|
`#!/bin/sh
|
|
44360
44482
|
cd ${shSingleQuote(cwd)}
|
|
@@ -44382,13 +44504,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
44382
44504
|
}
|
|
44383
44505
|
}
|
|
44384
44506
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
|
|
44385
|
-
const tmpRoot =
|
|
44386
|
-
const logPath =
|
|
44387
|
-
const runnerPath =
|
|
44507
|
+
const tmpRoot = fs31.mkdtempSync(path40.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
44508
|
+
const logPath = path40.join(tmpRoot, "combined.log");
|
|
44509
|
+
const runnerPath = path40.join(tmpRoot, "_run.bat");
|
|
44388
44510
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
44389
44511
|
const com = process.env.ComSpec || "cmd.exe";
|
|
44390
44512
|
try {
|
|
44391
|
-
|
|
44513
|
+
fs31.writeFileSync(
|
|
44392
44514
|
runnerPath,
|
|
44393
44515
|
`@ECHO OFF\r
|
|
44394
44516
|
CD /D ${q(cwd)}\r
|
|
@@ -44706,8 +44828,8 @@ function createBridgePreviewStack(options) {
|
|
|
44706
44828
|
scheduleInitialIndexBuilds(getBridgeRoot());
|
|
44707
44829
|
};
|
|
44708
44830
|
const identifyReportedPaths = {
|
|
44709
|
-
bridgeRootPath:
|
|
44710
|
-
worktreesRootPath:
|
|
44831
|
+
bridgeRootPath: path41.resolve(getBridgeRoot()),
|
|
44832
|
+
worktreesRootPath: path41.resolve(options.worktreesRootPath),
|
|
44711
44833
|
localShortcutPort: 0,
|
|
44712
44834
|
localShortcutToken: ""
|
|
44713
44835
|
};
|
|
@@ -45670,17 +45792,17 @@ async function yieldSkillDiscoveryWork(entryCount) {
|
|
|
45670
45792
|
}
|
|
45671
45793
|
|
|
45672
45794
|
// src/skills/discovery/discover-local-skills.ts
|
|
45673
|
-
import
|
|
45674
|
-
import
|
|
45795
|
+
import fs32 from "node:fs";
|
|
45796
|
+
import path42 from "node:path";
|
|
45675
45797
|
function collectSkillFromDir(rel, base, name, seenKeys, out) {
|
|
45676
|
-
const dir =
|
|
45798
|
+
const dir = path42.join(base, name);
|
|
45677
45799
|
try {
|
|
45678
|
-
if (!
|
|
45800
|
+
if (!fs32.statSync(dir).isDirectory()) return;
|
|
45679
45801
|
} catch {
|
|
45680
45802
|
return;
|
|
45681
45803
|
}
|
|
45682
|
-
const skillMd =
|
|
45683
|
-
if (!
|
|
45804
|
+
const skillMd = path42.join(dir, "SKILL.md");
|
|
45805
|
+
if (!fs32.existsSync(skillMd)) return;
|
|
45684
45806
|
const key = `${rel}/${name}`;
|
|
45685
45807
|
if (seenKeys.has(key)) return;
|
|
45686
45808
|
seenKeys.add(key);
|
|
@@ -45692,11 +45814,11 @@ async function discoverLocalSkillsAsync(cwd) {
|
|
|
45692
45814
|
let work = 0;
|
|
45693
45815
|
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
45694
45816
|
await yieldSkillDiscoveryWork(++work);
|
|
45695
|
-
const base =
|
|
45696
|
-
if (!
|
|
45817
|
+
const base = path42.join(cwd, rel);
|
|
45818
|
+
if (!fs32.existsSync(base) || !fs32.statSync(base).isDirectory()) continue;
|
|
45697
45819
|
let entries = [];
|
|
45698
45820
|
try {
|
|
45699
|
-
entries =
|
|
45821
|
+
entries = fs32.readdirSync(base);
|
|
45700
45822
|
} catch {
|
|
45701
45823
|
continue;
|
|
45702
45824
|
}
|
|
@@ -45709,16 +45831,16 @@ async function discoverLocalSkillsAsync(cwd) {
|
|
|
45709
45831
|
}
|
|
45710
45832
|
|
|
45711
45833
|
// src/skills/discovery/discover-skill-layout-roots.ts
|
|
45712
|
-
import
|
|
45713
|
-
import
|
|
45834
|
+
import fs33 from "node:fs";
|
|
45835
|
+
import path43 from "node:path";
|
|
45714
45836
|
function collectLayoutSkill(rel, base, name, skills2) {
|
|
45715
|
-
const dir =
|
|
45837
|
+
const dir = path43.join(base, name);
|
|
45716
45838
|
try {
|
|
45717
|
-
if (!
|
|
45839
|
+
if (!fs33.statSync(dir).isDirectory()) return;
|
|
45718
45840
|
} catch {
|
|
45719
45841
|
return;
|
|
45720
45842
|
}
|
|
45721
|
-
if (!
|
|
45843
|
+
if (!fs33.existsSync(path43.join(dir, "SKILL.md"))) return;
|
|
45722
45844
|
const relPath = `${rel}/${name}`.replace(/\\/g, "/");
|
|
45723
45845
|
skills2.push({ name, relPath });
|
|
45724
45846
|
}
|
|
@@ -45727,11 +45849,11 @@ async function discoverSkillLayoutRootsAsync(cwd) {
|
|
|
45727
45849
|
let work = 0;
|
|
45728
45850
|
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
45729
45851
|
await yieldSkillDiscoveryWork(++work);
|
|
45730
|
-
const base =
|
|
45731
|
-
if (!
|
|
45852
|
+
const base = path43.join(cwd, rel);
|
|
45853
|
+
if (!fs33.existsSync(base) || !fs33.statSync(base).isDirectory()) continue;
|
|
45732
45854
|
let entries = [];
|
|
45733
45855
|
try {
|
|
45734
|
-
entries =
|
|
45856
|
+
entries = fs33.readdirSync(base);
|
|
45735
45857
|
} catch {
|
|
45736
45858
|
continue;
|
|
45737
45859
|
}
|
|
@@ -45878,12 +46000,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
45878
46000
|
}
|
|
45879
46001
|
|
|
45880
46002
|
// src/worktrees/worktree-layout-file.ts
|
|
45881
|
-
import * as
|
|
45882
|
-
import * as
|
|
45883
|
-
import
|
|
46003
|
+
import * as fs34 from "node:fs";
|
|
46004
|
+
import * as path44 from "node:path";
|
|
46005
|
+
import os9 from "node:os";
|
|
45884
46006
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
45885
46007
|
function defaultWorktreeLayoutPath() {
|
|
45886
|
-
return
|
|
46008
|
+
return path44.join(os9.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
45887
46009
|
}
|
|
45888
46010
|
function normalizeLoadedLayout(raw) {
|
|
45889
46011
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -45895,8 +46017,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
45895
46017
|
function loadWorktreeLayout() {
|
|
45896
46018
|
try {
|
|
45897
46019
|
const p = defaultWorktreeLayoutPath();
|
|
45898
|
-
if (!
|
|
45899
|
-
const raw = JSON.parse(
|
|
46020
|
+
if (!fs34.existsSync(p)) return { launcherCwds: [] };
|
|
46021
|
+
const raw = JSON.parse(fs34.readFileSync(p, "utf8"));
|
|
45900
46022
|
return normalizeLoadedLayout(raw);
|
|
45901
46023
|
} catch {
|
|
45902
46024
|
return { launcherCwds: [] };
|
|
@@ -45904,24 +46026,24 @@ function loadWorktreeLayout() {
|
|
|
45904
46026
|
}
|
|
45905
46027
|
function saveWorktreeLayout(layout) {
|
|
45906
46028
|
try {
|
|
45907
|
-
const dir =
|
|
45908
|
-
|
|
45909
|
-
|
|
46029
|
+
const dir = path44.dirname(defaultWorktreeLayoutPath());
|
|
46030
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
46031
|
+
fs34.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
45910
46032
|
} catch {
|
|
45911
46033
|
}
|
|
45912
46034
|
}
|
|
45913
46035
|
function baseNameSafe(pathString) {
|
|
45914
|
-
return
|
|
46036
|
+
return path44.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
45915
46037
|
}
|
|
45916
46038
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
45917
|
-
const norm =
|
|
45918
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
46039
|
+
const norm = path44.resolve(bridgeRootPath2);
|
|
46040
|
+
const existing = layout.launcherCwds.find((e) => path44.resolve(e.absolutePath) === norm);
|
|
45919
46041
|
return existing?.dirName;
|
|
45920
46042
|
}
|
|
45921
46043
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
45922
46044
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
45923
46045
|
if (existing) return existing;
|
|
45924
|
-
const norm =
|
|
46046
|
+
const norm = path44.resolve(bridgeRootPath2);
|
|
45925
46047
|
const base = baseNameSafe(norm);
|
|
45926
46048
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
45927
46049
|
let name = base;
|
|
@@ -46014,8 +46136,8 @@ function pathspec(...paths) {
|
|
|
46014
46136
|
cache.set(key, paths);
|
|
46015
46137
|
return key;
|
|
46016
46138
|
}
|
|
46017
|
-
function isPathSpec(
|
|
46018
|
-
return
|
|
46139
|
+
function isPathSpec(path90) {
|
|
46140
|
+
return path90 instanceof String && cache.has(path90);
|
|
46019
46141
|
}
|
|
46020
46142
|
function toPaths(pathSpec) {
|
|
46021
46143
|
return cache.get(pathSpec) || [];
|
|
@@ -46104,8 +46226,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
46104
46226
|
function forEachLineWithContent(input, callback) {
|
|
46105
46227
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
46106
46228
|
}
|
|
46107
|
-
function folderExists(
|
|
46108
|
-
return (0, import_file_exists.exists)(
|
|
46229
|
+
function folderExists(path90) {
|
|
46230
|
+
return (0, import_file_exists.exists)(path90, import_file_exists.FOLDER);
|
|
46109
46231
|
}
|
|
46110
46232
|
function append(target, item) {
|
|
46111
46233
|
if (Array.isArray(target)) {
|
|
@@ -46509,8 +46631,8 @@ function checkIsRepoRootTask() {
|
|
|
46509
46631
|
commands,
|
|
46510
46632
|
format: "utf-8",
|
|
46511
46633
|
onError,
|
|
46512
|
-
parser(
|
|
46513
|
-
return /^\.(git)?$/.test(
|
|
46634
|
+
parser(path90) {
|
|
46635
|
+
return /^\.(git)?$/.test(path90.trim());
|
|
46514
46636
|
}
|
|
46515
46637
|
};
|
|
46516
46638
|
}
|
|
@@ -46944,11 +47066,11 @@ function parseGrep(grep) {
|
|
|
46944
47066
|
const paths = /* @__PURE__ */ new Set();
|
|
46945
47067
|
const results = {};
|
|
46946
47068
|
forEachLineWithContent(grep, (input) => {
|
|
46947
|
-
const [
|
|
46948
|
-
paths.add(
|
|
46949
|
-
(results[
|
|
47069
|
+
const [path90, line, preview] = input.split(NULL);
|
|
47070
|
+
paths.add(path90);
|
|
47071
|
+
(results[path90] = results[path90] || []).push({
|
|
46950
47072
|
line: asNumber(line),
|
|
46951
|
-
path:
|
|
47073
|
+
path: path90,
|
|
46952
47074
|
preview
|
|
46953
47075
|
});
|
|
46954
47076
|
});
|
|
@@ -47713,14 +47835,14 @@ var init_hash_object = __esm2({
|
|
|
47713
47835
|
init_task();
|
|
47714
47836
|
}
|
|
47715
47837
|
});
|
|
47716
|
-
function parseInit(bare,
|
|
47838
|
+
function parseInit(bare, path90, text) {
|
|
47717
47839
|
const response = String(text).trim();
|
|
47718
47840
|
let result;
|
|
47719
47841
|
if (result = initResponseRegex.exec(response)) {
|
|
47720
|
-
return new InitSummary(bare,
|
|
47842
|
+
return new InitSummary(bare, path90, false, result[1]);
|
|
47721
47843
|
}
|
|
47722
47844
|
if (result = reInitResponseRegex.exec(response)) {
|
|
47723
|
-
return new InitSummary(bare,
|
|
47845
|
+
return new InitSummary(bare, path90, true, result[1]);
|
|
47724
47846
|
}
|
|
47725
47847
|
let gitDir = "";
|
|
47726
47848
|
const tokens = response.split(" ");
|
|
@@ -47731,7 +47853,7 @@ function parseInit(bare, path88, text) {
|
|
|
47731
47853
|
break;
|
|
47732
47854
|
}
|
|
47733
47855
|
}
|
|
47734
|
-
return new InitSummary(bare,
|
|
47856
|
+
return new InitSummary(bare, path90, /^re/i.test(response), gitDir);
|
|
47735
47857
|
}
|
|
47736
47858
|
var InitSummary;
|
|
47737
47859
|
var initResponseRegex;
|
|
@@ -47740,9 +47862,9 @@ var init_InitSummary = __esm2({
|
|
|
47740
47862
|
"src/lib/responses/InitSummary.ts"() {
|
|
47741
47863
|
"use strict";
|
|
47742
47864
|
InitSummary = class {
|
|
47743
|
-
constructor(bare,
|
|
47865
|
+
constructor(bare, path90, existing, gitDir) {
|
|
47744
47866
|
this.bare = bare;
|
|
47745
|
-
this.path =
|
|
47867
|
+
this.path = path90;
|
|
47746
47868
|
this.existing = existing;
|
|
47747
47869
|
this.gitDir = gitDir;
|
|
47748
47870
|
}
|
|
@@ -47754,7 +47876,7 @@ var init_InitSummary = __esm2({
|
|
|
47754
47876
|
function hasBareCommand(command) {
|
|
47755
47877
|
return command.includes(bareCommand);
|
|
47756
47878
|
}
|
|
47757
|
-
function initTask(bare = false,
|
|
47879
|
+
function initTask(bare = false, path90, customArgs) {
|
|
47758
47880
|
const commands = ["init", ...customArgs];
|
|
47759
47881
|
if (bare && !hasBareCommand(commands)) {
|
|
47760
47882
|
commands.splice(1, 0, bareCommand);
|
|
@@ -47763,7 +47885,7 @@ function initTask(bare = false, path88, customArgs) {
|
|
|
47763
47885
|
commands,
|
|
47764
47886
|
format: "utf-8",
|
|
47765
47887
|
parser(text) {
|
|
47766
|
-
return parseInit(commands.includes("--bare"),
|
|
47888
|
+
return parseInit(commands.includes("--bare"), path90, text);
|
|
47767
47889
|
}
|
|
47768
47890
|
};
|
|
47769
47891
|
}
|
|
@@ -48579,12 +48701,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
48579
48701
|
"use strict";
|
|
48580
48702
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
48581
48703
|
FileStatusSummary = class {
|
|
48582
|
-
constructor(
|
|
48583
|
-
this.path =
|
|
48704
|
+
constructor(path90, index, working_dir) {
|
|
48705
|
+
this.path = path90;
|
|
48584
48706
|
this.index = index;
|
|
48585
48707
|
this.working_dir = working_dir;
|
|
48586
48708
|
if (index === "R" || working_dir === "R") {
|
|
48587
|
-
const detail = fromPathRegex.exec(
|
|
48709
|
+
const detail = fromPathRegex.exec(path90) || [null, path90, path90];
|
|
48588
48710
|
this.from = detail[2] || "";
|
|
48589
48711
|
this.path = detail[1] || "";
|
|
48590
48712
|
}
|
|
@@ -48615,14 +48737,14 @@ function splitLine(result, lineStr) {
|
|
|
48615
48737
|
default:
|
|
48616
48738
|
return;
|
|
48617
48739
|
}
|
|
48618
|
-
function data(index, workingDir,
|
|
48740
|
+
function data(index, workingDir, path90) {
|
|
48619
48741
|
const raw = `${index}${workingDir}`;
|
|
48620
48742
|
const handler = parsers6.get(raw);
|
|
48621
48743
|
if (handler) {
|
|
48622
|
-
handler(result,
|
|
48744
|
+
handler(result, path90);
|
|
48623
48745
|
}
|
|
48624
48746
|
if (raw !== "##" && raw !== "!!") {
|
|
48625
|
-
result.files.push(new FileStatusSummary(
|
|
48747
|
+
result.files.push(new FileStatusSummary(path90, index, workingDir));
|
|
48626
48748
|
}
|
|
48627
48749
|
}
|
|
48628
48750
|
}
|
|
@@ -48931,9 +49053,9 @@ var init_simple_git_api = __esm2({
|
|
|
48931
49053
|
next
|
|
48932
49054
|
);
|
|
48933
49055
|
}
|
|
48934
|
-
hashObject(
|
|
49056
|
+
hashObject(path90, write) {
|
|
48935
49057
|
return this._runTask(
|
|
48936
|
-
hashObjectTask(
|
|
49058
|
+
hashObjectTask(path90, write === true),
|
|
48937
49059
|
trailingFunctionArgument(arguments)
|
|
48938
49060
|
);
|
|
48939
49061
|
}
|
|
@@ -49286,8 +49408,8 @@ var init_branch = __esm2({
|
|
|
49286
49408
|
}
|
|
49287
49409
|
});
|
|
49288
49410
|
function toPath(input) {
|
|
49289
|
-
const
|
|
49290
|
-
return
|
|
49411
|
+
const path90 = input.trim().replace(/^["']|["']$/g, "");
|
|
49412
|
+
return path90 && normalize3(path90);
|
|
49291
49413
|
}
|
|
49292
49414
|
var parseCheckIgnore;
|
|
49293
49415
|
var init_CheckIgnore = __esm2({
|
|
@@ -49601,8 +49723,8 @@ __export2(sub_module_exports, {
|
|
|
49601
49723
|
subModuleTask: () => subModuleTask,
|
|
49602
49724
|
updateSubModuleTask: () => updateSubModuleTask
|
|
49603
49725
|
});
|
|
49604
|
-
function addSubModuleTask(repo,
|
|
49605
|
-
return subModuleTask(["add", repo,
|
|
49726
|
+
function addSubModuleTask(repo, path90) {
|
|
49727
|
+
return subModuleTask(["add", repo, path90]);
|
|
49606
49728
|
}
|
|
49607
49729
|
function initSubModuleTask(customArgs) {
|
|
49608
49730
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -49935,8 +50057,8 @@ var require_git = __commonJS2({
|
|
|
49935
50057
|
}
|
|
49936
50058
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
49937
50059
|
};
|
|
49938
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
49939
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
50060
|
+
Git2.prototype.submoduleAdd = function(repo, path90, then) {
|
|
50061
|
+
return this._runTask(addSubModuleTask2(repo, path90), trailingFunctionArgument2(arguments));
|
|
49940
50062
|
};
|
|
49941
50063
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
49942
50064
|
return this._runTask(
|
|
@@ -50675,8 +50797,8 @@ function parseNumstatEntries(lines) {
|
|
|
50675
50797
|
}
|
|
50676
50798
|
function parseNumstat(lines) {
|
|
50677
50799
|
const m = /* @__PURE__ */ new Map();
|
|
50678
|
-
for (const [
|
|
50679
|
-
m.set(
|
|
50800
|
+
for (const [path90, entry] of parseNumstatEntries(lines)) {
|
|
50801
|
+
m.set(path90, { additions: entry.additions, deletions: entry.deletions });
|
|
50680
50802
|
}
|
|
50681
50803
|
return m;
|
|
50682
50804
|
}
|
|
@@ -50805,7 +50927,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
50805
50927
|
}
|
|
50806
50928
|
|
|
50807
50929
|
// src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
50808
|
-
import * as
|
|
50930
|
+
import * as path45 from "node:path";
|
|
50809
50931
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
50810
50932
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
50811
50933
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -50816,7 +50938,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
50816
50938
|
}
|
|
50817
50939
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
50818
50940
|
if (repoDir) {
|
|
50819
|
-
const key =
|
|
50941
|
+
const key = path45.resolve(repoDir);
|
|
50820
50942
|
const now = Date.now();
|
|
50821
50943
|
const cached2 = baseShaCache.get(key);
|
|
50822
50944
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -50951,17 +51073,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
50951
51073
|
}
|
|
50952
51074
|
|
|
50953
51075
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
50954
|
-
import * as
|
|
51076
|
+
import * as path55 from "node:path";
|
|
50955
51077
|
|
|
50956
51078
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
50957
|
-
import * as
|
|
51079
|
+
import * as path54 from "node:path";
|
|
50958
51080
|
|
|
50959
51081
|
// src/git/is-git-repo.ts
|
|
50960
|
-
import * as
|
|
50961
|
-
import * as
|
|
51082
|
+
import * as fs35 from "node:fs";
|
|
51083
|
+
import * as path46 from "node:path";
|
|
50962
51084
|
async function isGitRepoDirectory(dirPath) {
|
|
50963
51085
|
try {
|
|
50964
|
-
await
|
|
51086
|
+
await fs35.promises.access(path46.join(dirPath, ".git"));
|
|
50965
51087
|
return true;
|
|
50966
51088
|
} catch {
|
|
50967
51089
|
return false;
|
|
@@ -50969,8 +51091,8 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
50969
51091
|
}
|
|
50970
51092
|
|
|
50971
51093
|
// src/git/changes/listing/apply-untracked-file-stats.ts
|
|
50972
|
-
import * as
|
|
50973
|
-
import * as
|
|
51094
|
+
import * as fs36 from "node:fs";
|
|
51095
|
+
import * as path47 from "node:path";
|
|
50974
51096
|
|
|
50975
51097
|
// src/git/changes/lines/count-lines.ts
|
|
50976
51098
|
import { createReadStream } from "node:fs";
|
|
@@ -51002,7 +51124,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
51002
51124
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
51003
51125
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
51004
51126
|
if (row.change === "moved") return;
|
|
51005
|
-
const repoFilePath =
|
|
51127
|
+
const repoFilePath = path47.join(options.repoGitCwd, pathInRepo);
|
|
51006
51128
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
51007
51129
|
if (fromGit) {
|
|
51008
51130
|
row.additions = fromGit.additions;
|
|
@@ -51010,7 +51132,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
51010
51132
|
return;
|
|
51011
51133
|
}
|
|
51012
51134
|
try {
|
|
51013
|
-
const st = await
|
|
51135
|
+
const st = await fs36.promises.stat(repoFilePath);
|
|
51014
51136
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
51015
51137
|
} catch {
|
|
51016
51138
|
row.additions = 0;
|
|
@@ -51087,7 +51209,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
51087
51209
|
}
|
|
51088
51210
|
|
|
51089
51211
|
// src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
51090
|
-
import * as
|
|
51212
|
+
import * as path49 from "node:path";
|
|
51091
51213
|
|
|
51092
51214
|
// src/git/changes/patch/patch-truncate.ts
|
|
51093
51215
|
function truncatePatch(s) {
|
|
@@ -51175,10 +51297,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
51175
51297
|
}
|
|
51176
51298
|
|
|
51177
51299
|
// src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
51178
|
-
import * as
|
|
51300
|
+
import * as fs37 from "node:fs";
|
|
51179
51301
|
async function readWorktreeFileLines(filePath) {
|
|
51180
51302
|
try {
|
|
51181
|
-
const raw = await
|
|
51303
|
+
const raw = await fs37.promises.readFile(filePath, "utf8");
|
|
51182
51304
|
return raw.split(/\r?\n/);
|
|
51183
51305
|
} catch {
|
|
51184
51306
|
return null;
|
|
@@ -51316,8 +51438,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
51316
51438
|
}
|
|
51317
51439
|
|
|
51318
51440
|
// src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
51319
|
-
import * as
|
|
51320
|
-
import * as
|
|
51441
|
+
import * as fs38 from "node:fs";
|
|
51442
|
+
import * as path48 from "node:path";
|
|
51321
51443
|
var MAX_BYTES = 512e3;
|
|
51322
51444
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
51323
51445
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -51337,13 +51459,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
51337
51459
|
}
|
|
51338
51460
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
51339
51461
|
if (options.isBinary) return null;
|
|
51340
|
-
const filePath =
|
|
51462
|
+
const filePath = path48.join(options.repoGitCwd, options.pathInRepo);
|
|
51341
51463
|
if (options.change === "removed") {
|
|
51342
51464
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
51343
51465
|
}
|
|
51344
51466
|
if (options.change === "moved" || options.change === "modified") {
|
|
51345
51467
|
try {
|
|
51346
|
-
const st = await
|
|
51468
|
+
const st = await fs38.promises.stat(filePath);
|
|
51347
51469
|
if (!st.isFile()) return null;
|
|
51348
51470
|
return await countTextFileLines(filePath);
|
|
51349
51471
|
} catch {
|
|
@@ -51386,7 +51508,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
51386
51508
|
row.workspaceRelPath,
|
|
51387
51509
|
options.repoPathRelativeToWorkspaceRoot
|
|
51388
51510
|
);
|
|
51389
|
-
const filePath =
|
|
51511
|
+
const filePath = path49.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
51390
51512
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
51391
51513
|
let patch = await unifiedDiffForFile(
|
|
51392
51514
|
options.repoGitCwd,
|
|
@@ -51544,7 +51666,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
51544
51666
|
}
|
|
51545
51667
|
|
|
51546
51668
|
// src/git/changes/listing/list-changed-files-for-commit.ts
|
|
51547
|
-
import * as
|
|
51669
|
+
import * as path50 from "node:path";
|
|
51548
51670
|
|
|
51549
51671
|
// src/git/changes/listing/enrich-commit-file-rows.ts
|
|
51550
51672
|
async function enrichCommitFileRows(options) {
|
|
@@ -51589,7 +51711,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
51589
51711
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
51590
51712
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
51591
51713
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
51592
|
-
return `${
|
|
51714
|
+
return `${path50.resolve(repoGitCwd)}:${commitSha}`;
|
|
51593
51715
|
}
|
|
51594
51716
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
51595
51717
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -51644,7 +51766,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
51644
51766
|
}
|
|
51645
51767
|
|
|
51646
51768
|
// src/git/commits/list-unpushed-commits.ts
|
|
51647
|
-
import * as
|
|
51769
|
+
import * as path51 from "node:path";
|
|
51648
51770
|
|
|
51649
51771
|
// src/git/commits/lib/parse-log-lines.ts
|
|
51650
51772
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -51679,7 +51801,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
51679
51801
|
}
|
|
51680
51802
|
}
|
|
51681
51803
|
async function listUnpushedCommits(repoDir) {
|
|
51682
|
-
const key =
|
|
51804
|
+
const key = path51.resolve(repoDir);
|
|
51683
51805
|
const now = Date.now();
|
|
51684
51806
|
const cached2 = unpushedCache.get(key);
|
|
51685
51807
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -51740,7 +51862,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
51740
51862
|
}
|
|
51741
51863
|
|
|
51742
51864
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
51743
|
-
import * as
|
|
51865
|
+
import * as path52 from "node:path";
|
|
51744
51866
|
|
|
51745
51867
|
// src/git/remote-origin-url.ts
|
|
51746
51868
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -51755,7 +51877,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
51755
51877
|
|
|
51756
51878
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
51757
51879
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
51758
|
-
const resolvedCheckoutPath =
|
|
51880
|
+
const resolvedCheckoutPath = path52.resolve(checkoutPath);
|
|
51759
51881
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
51760
51882
|
await yieldToEventLoop2();
|
|
51761
51883
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -51770,14 +51892,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
51770
51892
|
}
|
|
51771
51893
|
|
|
51772
51894
|
// src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
51773
|
-
import * as
|
|
51895
|
+
import * as path53 from "node:path";
|
|
51774
51896
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
51775
|
-
const checkoutPath =
|
|
51897
|
+
const checkoutPath = path53.resolve(options.checkoutPath);
|
|
51776
51898
|
const git = cliSimpleGit(checkoutPath);
|
|
51777
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
51899
|
+
const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
|
|
51778
51900
|
let repoPathRelativeToWorkspaceRoot;
|
|
51779
51901
|
if (sessionParentPath) {
|
|
51780
|
-
const checkoutPathRelativeToSessionParent =
|
|
51902
|
+
const checkoutPathRelativeToSessionParent = path53.relative(sessionParentPath, checkoutPath);
|
|
51781
51903
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
51782
51904
|
} else {
|
|
51783
51905
|
let gitTopLevel = checkoutPath;
|
|
@@ -51787,8 +51909,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
51787
51909
|
} catch {
|
|
51788
51910
|
gitTopLevel = checkoutPath;
|
|
51789
51911
|
}
|
|
51790
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
51791
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
51912
|
+
const gitTopLevelRelativeToBridgeRoot = path53.relative(options.bridgeRoot, path53.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
51913
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path53.basename(path53.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
51792
51914
|
}
|
|
51793
51915
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
51794
51916
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -51797,10 +51919,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
51797
51919
|
|
|
51798
51920
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
51799
51921
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
51800
|
-
const checkoutPath =
|
|
51922
|
+
const checkoutPath = path54.resolve(options.targetPath);
|
|
51801
51923
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
51802
51924
|
const isCommitView = options.basis.kind === "commit";
|
|
51803
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
51925
|
+
const sessionParentPath = options.sessionParentPath ? path54.resolve(options.sessionParentPath) : null;
|
|
51804
51926
|
const git = cliSimpleGit(checkoutPath);
|
|
51805
51927
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51806
51928
|
checkoutPath,
|
|
@@ -51848,8 +51970,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
51848
51970
|
|
|
51849
51971
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
51850
51972
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
51851
|
-
const bridgeRoot =
|
|
51852
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
51973
|
+
const bridgeRoot = path55.resolve(getBridgeRoot());
|
|
51974
|
+
const sessionParentPath = options.sessionParentPath ? path55.resolve(options.sessionParentPath) : null;
|
|
51853
51975
|
const out = [];
|
|
51854
51976
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
51855
51977
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -51880,9 +52002,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
51880
52002
|
}
|
|
51881
52003
|
|
|
51882
52004
|
// src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
51883
|
-
import * as
|
|
52005
|
+
import * as path56 from "node:path";
|
|
51884
52006
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
51885
|
-
const repoGitCwd =
|
|
52007
|
+
const repoGitCwd = path56.resolve(options.repoGitCwd);
|
|
51886
52008
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
51887
52009
|
throw new Error("Not a git repository");
|
|
51888
52010
|
}
|
|
@@ -51921,7 +52043,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
51921
52043
|
});
|
|
51922
52044
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
51923
52045
|
}
|
|
51924
|
-
const filePath =
|
|
52046
|
+
const filePath = path56.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
51925
52047
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
51926
52048
|
let patchContent = await unifiedDiffForFile(
|
|
51927
52049
|
repoGitCwd,
|
|
@@ -51967,18 +52089,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
51967
52089
|
}
|
|
51968
52090
|
|
|
51969
52091
|
// src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
51970
|
-
import * as
|
|
52092
|
+
import * as path57 from "node:path";
|
|
51971
52093
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
51972
52094
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
51973
|
-
const bridgeRoot =
|
|
51974
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
52095
|
+
const bridgeRoot = path57.resolve(getBridgeRoot());
|
|
52096
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path57.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
51975
52097
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
51976
52098
|
opts.repoRelPath.trim()
|
|
51977
52099
|
);
|
|
51978
52100
|
let result = null;
|
|
51979
52101
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
51980
52102
|
if (result) return;
|
|
51981
|
-
const checkoutPath =
|
|
52103
|
+
const checkoutPath = path57.resolve(targetPath);
|
|
51982
52104
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
51983
52105
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51984
52106
|
checkoutPath,
|
|
@@ -52011,13 +52133,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
52011
52133
|
}
|
|
52012
52134
|
|
|
52013
52135
|
// src/worktrees/remove-session-worktrees.ts
|
|
52014
|
-
import * as
|
|
52136
|
+
import * as fs41 from "node:fs";
|
|
52015
52137
|
|
|
52016
52138
|
// src/git/worktrees/worktree-remove.ts
|
|
52017
|
-
import * as
|
|
52139
|
+
import * as fs40 from "node:fs";
|
|
52018
52140
|
|
|
52019
52141
|
// src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
52020
|
-
import
|
|
52142
|
+
import path58 from "node:path";
|
|
52021
52143
|
init_normalize_resolved_path();
|
|
52022
52144
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
52023
52145
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -52026,23 +52148,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
52026
52148
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
52027
52149
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
52028
52150
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
52029
|
-
const rel =
|
|
52030
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
52151
|
+
const rel = path58.relative(worktreesRoot, normalized);
|
|
52152
|
+
if (rel === "" || rel.startsWith("..") || path58.isAbsolute(rel)) return false;
|
|
52031
52153
|
return true;
|
|
52032
52154
|
}
|
|
52033
52155
|
|
|
52034
52156
|
// src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
52035
|
-
import * as
|
|
52036
|
-
import * as
|
|
52157
|
+
import * as fs39 from "node:fs";
|
|
52158
|
+
import * as path59 from "node:path";
|
|
52037
52159
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
52038
|
-
const gitDirFile =
|
|
52039
|
-
if (!
|
|
52040
|
-
const first2 =
|
|
52160
|
+
const gitDirFile = path59.join(wt, ".git");
|
|
52161
|
+
if (!fs39.existsSync(gitDirFile) || !fs39.statSync(gitDirFile).isFile()) return "";
|
|
52162
|
+
const first2 = fs39.readFileSync(gitDirFile, "utf8").trim();
|
|
52041
52163
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
52042
52164
|
if (!m) return "";
|
|
52043
|
-
const gitWorktreePath =
|
|
52044
|
-
const gitDir =
|
|
52045
|
-
return
|
|
52165
|
+
const gitWorktreePath = path59.resolve(wt, m[1].trim());
|
|
52166
|
+
const gitDir = path59.dirname(path59.dirname(gitWorktreePath));
|
|
52167
|
+
return path59.dirname(gitDir);
|
|
52046
52168
|
}
|
|
52047
52169
|
|
|
52048
52170
|
// src/git/worktrees/worktree-remove.ts
|
|
@@ -52053,7 +52175,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
52053
52175
|
return true;
|
|
52054
52176
|
}
|
|
52055
52177
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
52056
|
-
|
|
52178
|
+
fs40.rmSync(worktreePath, { recursive: true, force: true });
|
|
52057
52179
|
return true;
|
|
52058
52180
|
}
|
|
52059
52181
|
|
|
@@ -52075,7 +52197,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
52075
52197
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
52076
52198
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
52077
52199
|
try {
|
|
52078
|
-
|
|
52200
|
+
fs41.rmSync(wt, { recursive: true, force: true });
|
|
52079
52201
|
} catch {
|
|
52080
52202
|
}
|
|
52081
52203
|
}
|
|
@@ -52131,12 +52253,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
52131
52253
|
// src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
52132
52254
|
init_cli_process_interrupt();
|
|
52133
52255
|
init_yield_to_event_loop();
|
|
52134
|
-
import * as
|
|
52135
|
-
import * as
|
|
52256
|
+
import * as fs45 from "node:fs";
|
|
52257
|
+
import * as path64 from "node:path";
|
|
52136
52258
|
|
|
52137
52259
|
// src/worktrees/discovery/collect-worktree-paths.ts
|
|
52138
|
-
import * as
|
|
52139
|
-
import * as
|
|
52260
|
+
import * as fs43 from "node:fs";
|
|
52261
|
+
import * as path61 from "node:path";
|
|
52140
52262
|
|
|
52141
52263
|
// src/worktrees/discovery/disk-walk-constants.ts
|
|
52142
52264
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -52166,8 +52288,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
52166
52288
|
// src/worktrees/discovery/disk-walk-utils.ts
|
|
52167
52289
|
init_cli_process_interrupt();
|
|
52168
52290
|
init_yield_to_event_loop();
|
|
52169
|
-
import * as
|
|
52170
|
-
import * as
|
|
52291
|
+
import * as fs42 from "node:fs";
|
|
52292
|
+
import * as path60 from "node:path";
|
|
52171
52293
|
async function yieldDuringDiskWalk(state) {
|
|
52172
52294
|
state.entries++;
|
|
52173
52295
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -52177,7 +52299,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
52177
52299
|
}
|
|
52178
52300
|
async function isGitDir(dirPath) {
|
|
52179
52301
|
try {
|
|
52180
|
-
await
|
|
52302
|
+
await fs42.promises.access(path60.join(dirPath, ".git"));
|
|
52181
52303
|
return true;
|
|
52182
52304
|
} catch {
|
|
52183
52305
|
return false;
|
|
@@ -52191,23 +52313,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
52191
52313
|
const walk = async (dir) => {
|
|
52192
52314
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
52193
52315
|
if (await isGitDir(dir)) {
|
|
52194
|
-
out.push(
|
|
52316
|
+
out.push(path61.resolve(dir));
|
|
52195
52317
|
return;
|
|
52196
52318
|
}
|
|
52197
52319
|
let entries;
|
|
52198
52320
|
try {
|
|
52199
|
-
entries = await
|
|
52321
|
+
entries = await fs43.promises.readdir(dir, { withFileTypes: true });
|
|
52200
52322
|
} catch {
|
|
52201
52323
|
return;
|
|
52202
52324
|
}
|
|
52203
52325
|
for (const e of entries) {
|
|
52204
52326
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
52205
|
-
const full =
|
|
52327
|
+
const full = path61.join(dir, e.name);
|
|
52206
52328
|
if (!e.isDirectory()) continue;
|
|
52207
52329
|
await walk(full);
|
|
52208
52330
|
}
|
|
52209
52331
|
};
|
|
52210
|
-
await walk(
|
|
52332
|
+
await walk(path61.resolve(rootPath));
|
|
52211
52333
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
52212
52334
|
}
|
|
52213
52335
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -52218,16 +52340,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
52218
52340
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
52219
52341
|
let entries;
|
|
52220
52342
|
try {
|
|
52221
|
-
entries = await
|
|
52343
|
+
entries = await fs43.promises.readdir(dir, { withFileTypes: true });
|
|
52222
52344
|
} catch {
|
|
52223
52345
|
return;
|
|
52224
52346
|
}
|
|
52225
52347
|
for (const e of entries) {
|
|
52226
52348
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
52227
|
-
const full =
|
|
52349
|
+
const full = path61.join(dir, e.name);
|
|
52228
52350
|
if (!e.isDirectory()) continue;
|
|
52229
52351
|
if (e.name === sessionId) {
|
|
52230
|
-
if (await isGitDir(full)) out.push(
|
|
52352
|
+
if (await isGitDir(full)) out.push(path61.resolve(full));
|
|
52231
52353
|
continue;
|
|
52232
52354
|
}
|
|
52233
52355
|
if (await isGitDir(full)) continue;
|
|
@@ -52239,14 +52361,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
52239
52361
|
}
|
|
52240
52362
|
|
|
52241
52363
|
// src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
52242
|
-
import * as
|
|
52364
|
+
import * as path62 from "node:path";
|
|
52243
52365
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
52244
|
-
const bridge =
|
|
52366
|
+
const bridge = path62.resolve(bridgeRoot);
|
|
52245
52367
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
52246
52368
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
52247
|
-
const entry =
|
|
52248
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
52249
|
-
}).sort((a, b) =>
|
|
52369
|
+
const entry = path62.resolve(e.absolutePath);
|
|
52370
|
+
return bridge === entry || bridge.startsWith(entry + path62.sep) || entry.startsWith(bridge + path62.sep);
|
|
52371
|
+
}).sort((a, b) => path62.resolve(b.absolutePath).length - path62.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
52250
52372
|
const ordered = [];
|
|
52251
52373
|
const seen = /* @__PURE__ */ new Set();
|
|
52252
52374
|
const add = (k) => {
|
|
@@ -52264,19 +52386,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
52264
52386
|
}
|
|
52265
52387
|
|
|
52266
52388
|
// src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
52267
|
-
import * as
|
|
52268
|
-
import * as
|
|
52389
|
+
import * as fs44 from "node:fs";
|
|
52390
|
+
import * as path63 from "node:path";
|
|
52269
52391
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
52270
52392
|
let st;
|
|
52271
52393
|
try {
|
|
52272
|
-
st = await
|
|
52394
|
+
st = await fs44.promises.stat(scopeDir);
|
|
52273
52395
|
} catch {
|
|
52274
52396
|
return null;
|
|
52275
52397
|
}
|
|
52276
52398
|
if (!st.isDirectory()) return null;
|
|
52277
52399
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
52278
52400
|
if (worktreePaths.length === 0) return null;
|
|
52279
|
-
const abs =
|
|
52401
|
+
const abs = path63.resolve(scopeDir);
|
|
52280
52402
|
return {
|
|
52281
52403
|
parentPath: abs,
|
|
52282
52404
|
repoCheckoutPaths: worktreePaths
|
|
@@ -52299,7 +52421,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
52299
52421
|
const sid = sessionId.trim();
|
|
52300
52422
|
if (!sid) return null;
|
|
52301
52423
|
try {
|
|
52302
|
-
await
|
|
52424
|
+
await fs45.promises.access(worktreesRootPath);
|
|
52303
52425
|
} catch {
|
|
52304
52426
|
return null;
|
|
52305
52427
|
}
|
|
@@ -52308,13 +52430,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
52308
52430
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
52309
52431
|
const scanState = { entries: 0 };
|
|
52310
52432
|
try {
|
|
52311
|
-
for (const name of await
|
|
52433
|
+
for (const name of await fs45.promises.readdir(worktreesRootPath)) {
|
|
52312
52434
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
52313
52435
|
if (name.startsWith(".")) continue;
|
|
52314
|
-
const p =
|
|
52436
|
+
const p = path64.join(worktreesRootPath, name);
|
|
52315
52437
|
let st;
|
|
52316
52438
|
try {
|
|
52317
|
-
st = await
|
|
52439
|
+
st = await fs45.promises.stat(p);
|
|
52318
52440
|
} catch {
|
|
52319
52441
|
continue;
|
|
52320
52442
|
}
|
|
@@ -52328,23 +52450,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
52328
52450
|
for (const key of keys) {
|
|
52329
52451
|
if (isCliImmediateShutdownRequested()) return null;
|
|
52330
52452
|
await yieldToEventLoop();
|
|
52331
|
-
const layoutRoot =
|
|
52453
|
+
const layoutRoot = path64.join(worktreesRootPath, key);
|
|
52332
52454
|
let layoutSt;
|
|
52333
52455
|
try {
|
|
52334
|
-
layoutSt = await
|
|
52456
|
+
layoutSt = await fs45.promises.stat(layoutRoot);
|
|
52335
52457
|
} catch {
|
|
52336
52458
|
continue;
|
|
52337
52459
|
}
|
|
52338
52460
|
if (!layoutSt.isDirectory()) continue;
|
|
52339
|
-
const sessionDir =
|
|
52461
|
+
const sessionDir = path64.join(layoutRoot, sid);
|
|
52340
52462
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
52341
52463
|
if (nested) return nested;
|
|
52342
52464
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
52343
52465
|
if (legacy.paths.length > 0) {
|
|
52344
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
52466
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path64.resolve(legacy.paths[0]);
|
|
52345
52467
|
return {
|
|
52346
|
-
sessionParentPath:
|
|
52347
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
52468
|
+
sessionParentPath: path64.resolve(isolated),
|
|
52469
|
+
repoCheckoutPaths: legacy.paths.map((p) => path64.resolve(p))
|
|
52348
52470
|
};
|
|
52349
52471
|
}
|
|
52350
52472
|
}
|
|
@@ -52352,31 +52474,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
52352
52474
|
}
|
|
52353
52475
|
|
|
52354
52476
|
// src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
52355
|
-
import * as
|
|
52356
|
-
import * as
|
|
52477
|
+
import * as fs46 from "node:fs";
|
|
52478
|
+
import * as path66 from "node:path";
|
|
52357
52479
|
|
|
52358
52480
|
// src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
52359
52481
|
init_cli_process_interrupt();
|
|
52360
52482
|
init_yield_to_event_loop();
|
|
52361
|
-
import * as
|
|
52483
|
+
import * as path65 from "node:path";
|
|
52362
52484
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
52363
52485
|
const sid = sessionId.trim();
|
|
52364
52486
|
if (!sid) return null;
|
|
52365
|
-
const hintR =
|
|
52487
|
+
const hintR = path65.resolve(checkoutPath);
|
|
52366
52488
|
let best = null;
|
|
52367
|
-
let cur =
|
|
52489
|
+
let cur = path65.dirname(hintR);
|
|
52368
52490
|
for (let i = 0; i < 40; i++) {
|
|
52369
52491
|
if (isCliImmediateShutdownRequested()) return best;
|
|
52370
52492
|
await yieldToEventLoop();
|
|
52371
52493
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
52372
|
-
if (paths.paths.some((p) =>
|
|
52373
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
52494
|
+
if (paths.paths.some((p) => path65.resolve(p) === hintR)) {
|
|
52495
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path65.resolve(paths.paths[0]);
|
|
52374
52496
|
best = {
|
|
52375
|
-
sessionParentPath:
|
|
52376
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
52497
|
+
sessionParentPath: path65.resolve(isolated),
|
|
52498
|
+
repoCheckoutPaths: paths.paths.map((p) => path65.resolve(p))
|
|
52377
52499
|
};
|
|
52378
52500
|
}
|
|
52379
|
-
const next =
|
|
52501
|
+
const next = path65.dirname(cur);
|
|
52380
52502
|
if (next === cur) break;
|
|
52381
52503
|
cur = next;
|
|
52382
52504
|
}
|
|
@@ -52387,12 +52509,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
52387
52509
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
52388
52510
|
const sid = sessionId.trim();
|
|
52389
52511
|
if (!sid) return null;
|
|
52390
|
-
const hint =
|
|
52391
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
52512
|
+
const hint = path66.resolve(sessionParentPathOrHint);
|
|
52513
|
+
const underHint = await tryBindingFromSessionDirectory(path66.join(hint, sid));
|
|
52392
52514
|
if (underHint) return underHint;
|
|
52393
52515
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
52394
52516
|
if (direct) {
|
|
52395
|
-
if (
|
|
52517
|
+
if (path66.basename(hint) === sid && await isGitDir(hint)) {
|
|
52396
52518
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
52397
52519
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
52398
52520
|
return legacyFromCheckout;
|
|
@@ -52400,23 +52522,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
52400
52522
|
}
|
|
52401
52523
|
return direct;
|
|
52402
52524
|
}
|
|
52403
|
-
if (
|
|
52525
|
+
if (path66.basename(hint) === sid && await isGitDir(hint)) {
|
|
52404
52526
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
52405
52527
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
52406
52528
|
}
|
|
52407
52529
|
let st;
|
|
52408
52530
|
try {
|
|
52409
|
-
st = await
|
|
52531
|
+
st = await fs46.promises.stat(hint);
|
|
52410
52532
|
} catch {
|
|
52411
52533
|
return null;
|
|
52412
52534
|
}
|
|
52413
52535
|
if (!st.isDirectory()) return null;
|
|
52414
52536
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
52415
52537
|
if (legacyPaths.paths.length === 0) return null;
|
|
52416
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
52538
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path66.resolve(legacyPaths.paths[0]);
|
|
52417
52539
|
return {
|
|
52418
|
-
sessionParentPath:
|
|
52419
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
52540
|
+
sessionParentPath: path66.resolve(isolated),
|
|
52541
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path66.resolve(p))
|
|
52420
52542
|
};
|
|
52421
52543
|
}
|
|
52422
52544
|
|
|
@@ -52477,11 +52599,11 @@ function parseSessionParent(v) {
|
|
|
52477
52599
|
}
|
|
52478
52600
|
|
|
52479
52601
|
// src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
52480
|
-
import * as
|
|
52602
|
+
import * as fs50 from "node:fs";
|
|
52481
52603
|
|
|
52482
52604
|
// src/git/discover-repos.ts
|
|
52483
|
-
import * as
|
|
52484
|
-
import * as
|
|
52605
|
+
import * as fs47 from "node:fs";
|
|
52606
|
+
import * as path67 from "node:path";
|
|
52485
52607
|
init_yield_to_event_loop();
|
|
52486
52608
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
52487
52609
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -52491,14 +52613,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
52491
52613
|
}
|
|
52492
52614
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
52493
52615
|
const result = [];
|
|
52494
|
-
const cwdResolved =
|
|
52616
|
+
const cwdResolved = path67.resolve(cwd);
|
|
52495
52617
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
52496
52618
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
52497
52619
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
52498
52620
|
}
|
|
52499
52621
|
let entries;
|
|
52500
52622
|
try {
|
|
52501
|
-
entries =
|
|
52623
|
+
entries = fs47.readdirSync(cwdResolved, { withFileTypes: true });
|
|
52502
52624
|
} catch {
|
|
52503
52625
|
return result;
|
|
52504
52626
|
}
|
|
@@ -52506,7 +52628,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
52506
52628
|
await yieldGitDiscoverWork(i + 1);
|
|
52507
52629
|
const ent = entries[i];
|
|
52508
52630
|
if (!ent.isDirectory()) continue;
|
|
52509
|
-
const childPath2 =
|
|
52631
|
+
const childPath2 = path67.join(cwdResolved, ent.name);
|
|
52510
52632
|
if (await isGitRepoDirectory(childPath2)) {
|
|
52511
52633
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
52512
52634
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -52515,17 +52637,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
52515
52637
|
return result;
|
|
52516
52638
|
}
|
|
52517
52639
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
52518
|
-
const root =
|
|
52640
|
+
const root = path67.resolve(rootPath);
|
|
52519
52641
|
const roots = [];
|
|
52520
52642
|
let walkEntries = 0;
|
|
52521
52643
|
async function walk(dir) {
|
|
52522
52644
|
if (await isGitRepoDirectory(dir)) {
|
|
52523
|
-
roots.push(
|
|
52645
|
+
roots.push(path67.resolve(dir));
|
|
52524
52646
|
return;
|
|
52525
52647
|
}
|
|
52526
52648
|
let entries;
|
|
52527
52649
|
try {
|
|
52528
|
-
entries =
|
|
52650
|
+
entries = fs47.readdirSync(dir, { withFileTypes: true });
|
|
52529
52651
|
} catch {
|
|
52530
52652
|
return;
|
|
52531
52653
|
}
|
|
@@ -52533,7 +52655,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
52533
52655
|
await yieldGitDiscoverWork(++walkEntries);
|
|
52534
52656
|
const ent = entries[i];
|
|
52535
52657
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
52536
|
-
await walk(
|
|
52658
|
+
await walk(path67.join(dir, ent.name));
|
|
52537
52659
|
}
|
|
52538
52660
|
}
|
|
52539
52661
|
await walk(root);
|
|
@@ -52549,8 +52671,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
52549
52671
|
}
|
|
52550
52672
|
|
|
52551
52673
|
// src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
52552
|
-
import * as
|
|
52553
|
-
import * as
|
|
52674
|
+
import * as fs49 from "node:fs";
|
|
52675
|
+
import * as path69 from "node:path";
|
|
52554
52676
|
|
|
52555
52677
|
// src/git/worktrees/worktree-add.ts
|
|
52556
52678
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -52566,8 +52688,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
52566
52688
|
}
|
|
52567
52689
|
|
|
52568
52690
|
// src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
52569
|
-
import * as
|
|
52570
|
-
import * as
|
|
52691
|
+
import * as fs48 from "node:fs";
|
|
52692
|
+
import * as path68 from "node:path";
|
|
52571
52693
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
52572
52694
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
52573
52695
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -52576,19 +52698,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
52576
52698
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
52577
52699
|
for (let i = 0; i < segments.length; i++) {
|
|
52578
52700
|
const prefix = segments.slice(0, i).join("/");
|
|
52579
|
-
const bridgeDir = prefix ?
|
|
52580
|
-
const destDir = prefix ?
|
|
52701
|
+
const bridgeDir = prefix ? path68.join(bridgeRoot, prefix) : bridgeRoot;
|
|
52702
|
+
const destDir = prefix ? path68.join(scopeDir, prefix) : scopeDir;
|
|
52581
52703
|
for (const fileName of fileNames) {
|
|
52582
52704
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
52583
52705
|
}
|
|
52584
52706
|
}
|
|
52585
52707
|
}
|
|
52586
52708
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
52587
|
-
const src =
|
|
52588
|
-
if (!
|
|
52589
|
-
const dest =
|
|
52709
|
+
const src = path68.join(srcDir, fileName);
|
|
52710
|
+
if (!fs48.existsSync(src)) return;
|
|
52711
|
+
const dest = path68.join(destDir, fileName);
|
|
52590
52712
|
try {
|
|
52591
|
-
|
|
52713
|
+
fs48.copyFileSync(src, dest);
|
|
52592
52714
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
52593
52715
|
} catch (e) {
|
|
52594
52716
|
log2?.(
|
|
@@ -52620,16 +52742,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
52620
52742
|
worktreeBaseBranches,
|
|
52621
52743
|
log: log2
|
|
52622
52744
|
} = options;
|
|
52623
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
52624
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
52745
|
+
const repoPathRelativeToBridgeRootRaw = path69.relative(bridgeResolved, repoAbsolutePath);
|
|
52746
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path69.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
52625
52747
|
return null;
|
|
52626
52748
|
}
|
|
52627
52749
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
52628
52750
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
52629
52751
|
);
|
|
52630
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
52752
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path69.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
52631
52753
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
52632
|
-
|
|
52754
|
+
fs49.mkdirSync(path69.dirname(worktreePath), { recursive: true });
|
|
52633
52755
|
copyBridgeFilesAlongWorktreePath({
|
|
52634
52756
|
bridgeRoot: bridgeResolved,
|
|
52635
52757
|
scopeDir,
|
|
@@ -52657,7 +52779,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
52657
52779
|
}
|
|
52658
52780
|
|
|
52659
52781
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
52660
|
-
import * as
|
|
52782
|
+
import * as path70 from "node:path";
|
|
52661
52783
|
|
|
52662
52784
|
// src/worktrees/worktree-layout-kind.ts
|
|
52663
52785
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -52687,10 +52809,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
52687
52809
|
|
|
52688
52810
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
52689
52811
|
function resolveIsolatedScopeDir(options) {
|
|
52690
|
-
const bridgeResolved =
|
|
52812
|
+
const bridgeResolved = path70.resolve(options.bridgeRoot);
|
|
52691
52813
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
52692
|
-
const bridgeKeyDir =
|
|
52693
|
-
const scopeDir =
|
|
52814
|
+
const bridgeKeyDir = path70.join(options.worktreesRootPath, cwdKey);
|
|
52815
|
+
const scopeDir = path70.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
52694
52816
|
return { bridgeResolved, scopeDir };
|
|
52695
52817
|
}
|
|
52696
52818
|
|
|
@@ -52720,7 +52842,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
52720
52842
|
return null;
|
|
52721
52843
|
}
|
|
52722
52844
|
const worktreePaths = [];
|
|
52723
|
-
|
|
52845
|
+
fs50.mkdirSync(scopeDir, { recursive: true });
|
|
52724
52846
|
await forEachWithGitYield(repos, async (repo) => {
|
|
52725
52847
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
52726
52848
|
kind,
|
|
@@ -52792,10 +52914,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
52792
52914
|
}
|
|
52793
52915
|
|
|
52794
52916
|
// src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
52795
|
-
import * as
|
|
52917
|
+
import * as path71 from "node:path";
|
|
52796
52918
|
init_yield_to_event_loop();
|
|
52797
52919
|
async function resolveExplicitSessionParentPath(params) {
|
|
52798
|
-
const resolved =
|
|
52920
|
+
const resolved = path71.resolve(params.parentPathRaw);
|
|
52799
52921
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
52800
52922
|
return resolved;
|
|
52801
52923
|
}
|
|
@@ -52812,7 +52934,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
52812
52934
|
await yieldToEventLoop();
|
|
52813
52935
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
52814
52936
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
52815
|
-
const next =
|
|
52937
|
+
const next = path71.dirname(cur);
|
|
52816
52938
|
if (next === cur) break;
|
|
52817
52939
|
cur = next;
|
|
52818
52940
|
}
|
|
@@ -52973,15 +53095,15 @@ var SessionWorktreeManager = class {
|
|
|
52973
53095
|
};
|
|
52974
53096
|
|
|
52975
53097
|
// src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
52976
|
-
import * as
|
|
52977
|
-
import * as
|
|
53098
|
+
import * as fs51 from "node:fs";
|
|
53099
|
+
import * as path72 from "node:path";
|
|
52978
53100
|
init_yield_to_event_loop();
|
|
52979
53101
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
52980
53102
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
52981
53103
|
const eid = environmentId.trim();
|
|
52982
53104
|
if (!eid) return null;
|
|
52983
53105
|
try {
|
|
52984
|
-
await
|
|
53106
|
+
await fs51.promises.access(worktreesRootPath);
|
|
52985
53107
|
} catch {
|
|
52986
53108
|
return null;
|
|
52987
53109
|
}
|
|
@@ -52990,13 +53112,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
52990
53112
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
52991
53113
|
const scanState = { entries: 0 };
|
|
52992
53114
|
try {
|
|
52993
|
-
for (const name of await
|
|
53115
|
+
for (const name of await fs51.promises.readdir(worktreesRootPath)) {
|
|
52994
53116
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
52995
53117
|
if (name.startsWith(".")) continue;
|
|
52996
|
-
const p =
|
|
53118
|
+
const p = path72.join(worktreesRootPath, name);
|
|
52997
53119
|
let st;
|
|
52998
53120
|
try {
|
|
52999
|
-
st = await
|
|
53121
|
+
st = await fs51.promises.stat(p);
|
|
53000
53122
|
} catch {
|
|
53001
53123
|
continue;
|
|
53002
53124
|
}
|
|
@@ -53010,7 +53132,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
53010
53132
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
53011
53133
|
for (const key of keys) {
|
|
53012
53134
|
await yieldToEventLoop();
|
|
53013
|
-
const previewDir =
|
|
53135
|
+
const previewDir = path72.join(worktreesRootPath, key, ...previewDirRel);
|
|
53014
53136
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
53015
53137
|
if (binding) return binding;
|
|
53016
53138
|
}
|
|
@@ -53137,7 +53259,7 @@ var PreviewWorktreeManager = class {
|
|
|
53137
53259
|
};
|
|
53138
53260
|
|
|
53139
53261
|
// src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
53140
|
-
import * as
|
|
53262
|
+
import * as path76 from "node:path";
|
|
53141
53263
|
|
|
53142
53264
|
// src/git/worktrees/reset-worktree-to-branch.ts
|
|
53143
53265
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -53148,8 +53270,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
53148
53270
|
}
|
|
53149
53271
|
|
|
53150
53272
|
// src/worktrees/deploy/capture-and-apply-wip.ts
|
|
53151
|
-
import * as
|
|
53152
|
-
import * as
|
|
53273
|
+
import * as fs52 from "node:fs";
|
|
53274
|
+
import * as path73 from "node:path";
|
|
53153
53275
|
|
|
53154
53276
|
// src/git/snapshot/git.ts
|
|
53155
53277
|
var SNAPSHOT_GIT_TIMEOUT_MS = 5e3;
|
|
@@ -53204,12 +53326,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
53204
53326
|
if (!ap.ok) return ap;
|
|
53205
53327
|
}
|
|
53206
53328
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
53207
|
-
const src =
|
|
53208
|
-
const dst =
|
|
53329
|
+
const src = path73.join(sourceRepoPath, rel);
|
|
53330
|
+
const dst = path73.join(targetRepoPath, rel);
|
|
53209
53331
|
try {
|
|
53210
|
-
if (!
|
|
53211
|
-
|
|
53212
|
-
|
|
53332
|
+
if (!fs52.existsSync(src)) return;
|
|
53333
|
+
fs52.mkdirSync(path73.dirname(dst), { recursive: true });
|
|
53334
|
+
fs52.copyFileSync(src, dst);
|
|
53213
53335
|
} catch (e) {
|
|
53214
53336
|
log2(
|
|
53215
53337
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -53220,14 +53342,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
53220
53342
|
}
|
|
53221
53343
|
|
|
53222
53344
|
// src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
53223
|
-
import * as
|
|
53345
|
+
import * as path74 from "node:path";
|
|
53224
53346
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
53225
53347
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
53226
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
53348
|
+
const resolvedSessionParentPath = sessionParentPath ? path74.resolve(sessionParentPath) : null;
|
|
53227
53349
|
let match = null;
|
|
53228
53350
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
53229
53351
|
if (match) return;
|
|
53230
|
-
const resolvedCheckoutPath =
|
|
53352
|
+
const resolvedCheckoutPath = path74.resolve(checkoutPath);
|
|
53231
53353
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
53232
53354
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
53233
53355
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -53281,7 +53403,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
53281
53403
|
}
|
|
53282
53404
|
|
|
53283
53405
|
// src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
53284
|
-
import * as
|
|
53406
|
+
import * as path75 from "node:path";
|
|
53285
53407
|
|
|
53286
53408
|
// src/git/branches/create-or-update-branch.ts
|
|
53287
53409
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -53318,19 +53440,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
53318
53440
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
53319
53441
|
const states = [];
|
|
53320
53442
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
53321
|
-
const checkoutPath =
|
|
53443
|
+
const checkoutPath = path75.resolve(sessionCheckout);
|
|
53322
53444
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
53323
53445
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
53324
53446
|
checkoutPath,
|
|
53325
53447
|
bridgeRoot,
|
|
53326
|
-
sessionParentPath: sessionParentPath ?
|
|
53448
|
+
sessionParentPath: sessionParentPath ? path75.resolve(sessionParentPath) : null
|
|
53327
53449
|
});
|
|
53328
53450
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
53329
53451
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
53330
53452
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
53331
53453
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
53332
53454
|
checkoutPaths: previewCheckoutPaths,
|
|
53333
|
-
sessionParentPath: previewParentPath ?
|
|
53455
|
+
sessionParentPath: previewParentPath ? path75.resolve(previewParentPath) : null,
|
|
53334
53456
|
bridgeRoot,
|
|
53335
53457
|
repoPathRelativeToWorkspaceRoot
|
|
53336
53458
|
}) : null;
|
|
@@ -53350,7 +53472,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
53350
53472
|
const eid = options.environmentId.trim();
|
|
53351
53473
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
53352
53474
|
const deployBranch = previewDeployBranchName(eid);
|
|
53353
|
-
const bridgeRoot =
|
|
53475
|
+
const bridgeRoot = path76.resolve(getBridgeRoot());
|
|
53354
53476
|
await previewWorktreeManager.ensureCached(eid);
|
|
53355
53477
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
53356
53478
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -53390,10 +53512,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
53390
53512
|
}
|
|
53391
53513
|
|
|
53392
53514
|
// src/worktrees/manager/default-worktrees-root-path.ts
|
|
53393
|
-
import * as
|
|
53394
|
-
import
|
|
53515
|
+
import * as path77 from "node:path";
|
|
53516
|
+
import os10 from "node:os";
|
|
53395
53517
|
function defaultWorktreesRootPath() {
|
|
53396
|
-
return
|
|
53518
|
+
return path77.join(os10.homedir(), ".buildautomaton", "worktrees");
|
|
53397
53519
|
}
|
|
53398
53520
|
|
|
53399
53521
|
// src/connection/create-bridge-worktree-managers.ts
|
|
@@ -53523,14 +53645,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
53523
53645
|
}
|
|
53524
53646
|
|
|
53525
53647
|
// src/files/list-dir/index.ts
|
|
53526
|
-
import
|
|
53648
|
+
import fs54 from "node:fs";
|
|
53527
53649
|
|
|
53528
53650
|
// src/files/ensure-under-cwd.ts
|
|
53529
|
-
import
|
|
53651
|
+
import path78 from "node:path";
|
|
53530
53652
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
53531
|
-
const normalized =
|
|
53532
|
-
const resolved =
|
|
53533
|
-
if (!resolved.startsWith(cwd +
|
|
53653
|
+
const normalized = path78.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
53654
|
+
const resolved = path78.resolve(cwd, normalized);
|
|
53655
|
+
if (!resolved.startsWith(cwd + path78.sep) && resolved !== cwd) {
|
|
53534
53656
|
return null;
|
|
53535
53657
|
}
|
|
53536
53658
|
return resolved;
|
|
@@ -53543,15 +53665,15 @@ init_yield_to_event_loop();
|
|
|
53543
53665
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
53544
53666
|
|
|
53545
53667
|
// src/files/list-dir/map-dir-entry.ts
|
|
53546
|
-
import
|
|
53547
|
-
import
|
|
53668
|
+
import path79 from "node:path";
|
|
53669
|
+
import fs53 from "node:fs";
|
|
53548
53670
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
53549
|
-
const entryPath =
|
|
53550
|
-
const fullPath =
|
|
53671
|
+
const entryPath = path79.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
53672
|
+
const fullPath = path79.join(resolved, d.name);
|
|
53551
53673
|
let isDir = d.isDirectory();
|
|
53552
53674
|
if (d.isSymbolicLink()) {
|
|
53553
53675
|
try {
|
|
53554
|
-
const targetStat = await
|
|
53676
|
+
const targetStat = await fs53.promises.stat(fullPath);
|
|
53555
53677
|
isDir = targetStat.isDirectory();
|
|
53556
53678
|
} catch {
|
|
53557
53679
|
isDir = false;
|
|
@@ -53581,7 +53703,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
53581
53703
|
return { error: "Path is outside working directory" };
|
|
53582
53704
|
}
|
|
53583
53705
|
try {
|
|
53584
|
-
const names = await
|
|
53706
|
+
const names = await fs54.promises.readdir(resolved, { withFileTypes: true });
|
|
53585
53707
|
const entries = [];
|
|
53586
53708
|
for (let i = 0; i < names.length; i++) {
|
|
53587
53709
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -53597,13 +53719,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
53597
53719
|
}
|
|
53598
53720
|
|
|
53599
53721
|
// src/git/tree/resolve-repo-abs-path.ts
|
|
53600
|
-
import * as
|
|
53722
|
+
import * as path80 from "node:path";
|
|
53601
53723
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
53602
|
-
const bridgeResolved =
|
|
53724
|
+
const bridgeResolved = path80.resolve(bridgeRoot);
|
|
53603
53725
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
53604
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
53605
|
-
const resolved =
|
|
53606
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
53726
|
+
const repoPath = rel === "" ? bridgeResolved : path80.join(bridgeResolved, rel);
|
|
53727
|
+
const resolved = path80.resolve(repoPath);
|
|
53728
|
+
if (!resolved.startsWith(bridgeResolved + path80.sep) && resolved !== bridgeResolved) {
|
|
53607
53729
|
return null;
|
|
53608
53730
|
}
|
|
53609
53731
|
return resolved;
|
|
@@ -54084,25 +54206,25 @@ async function GET2(ctx) {
|
|
|
54084
54206
|
init_in_flight();
|
|
54085
54207
|
|
|
54086
54208
|
// src/files/read/read-file-async.ts
|
|
54087
|
-
import
|
|
54209
|
+
import fs60 from "node:fs";
|
|
54088
54210
|
init_yield_to_event_loop();
|
|
54089
54211
|
|
|
54090
54212
|
// src/files/read/resolve-file-cache.ts
|
|
54091
|
-
import
|
|
54092
|
-
import
|
|
54213
|
+
import fs55 from "node:fs";
|
|
54214
|
+
import path81 from "node:path";
|
|
54093
54215
|
var RESOLVE_CACHE_MAX = 4096;
|
|
54094
54216
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
54095
54217
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
54096
54218
|
return `${sessionParentPath}\0${relativePath}`;
|
|
54097
54219
|
}
|
|
54098
54220
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
54099
|
-
const parent =
|
|
54100
|
-
const resolved =
|
|
54101
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
54221
|
+
const parent = path81.resolve(sessionParentPath);
|
|
54222
|
+
const resolved = path81.resolve(filePath);
|
|
54223
|
+
return resolved === parent || resolved.startsWith(`${parent}${path81.sep}`);
|
|
54102
54224
|
}
|
|
54103
54225
|
function statMatchesCacheSync(entry) {
|
|
54104
54226
|
try {
|
|
54105
|
-
const stat3 =
|
|
54227
|
+
const stat3 = fs55.statSync(entry.path);
|
|
54106
54228
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
54107
54229
|
} catch {
|
|
54108
54230
|
return false;
|
|
@@ -54135,7 +54257,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
54135
54257
|
}
|
|
54136
54258
|
|
|
54137
54259
|
// src/files/read/resolve-file-for-read-core.ts
|
|
54138
|
-
import
|
|
54260
|
+
import fs56 from "node:fs";
|
|
54139
54261
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
54140
54262
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
54141
54263
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -54145,13 +54267,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
54145
54267
|
let size;
|
|
54146
54268
|
let mtimeMs;
|
|
54147
54269
|
try {
|
|
54148
|
-
const lstat =
|
|
54270
|
+
const lstat = fs56.lstatSync(resolved);
|
|
54149
54271
|
if (lstat.isSymbolicLink()) {
|
|
54150
|
-
real =
|
|
54272
|
+
real = fs56.realpathSync(resolved);
|
|
54151
54273
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
54152
54274
|
return { error: "Path is outside working directory" };
|
|
54153
54275
|
}
|
|
54154
|
-
const stat3 =
|
|
54276
|
+
const stat3 = fs56.statSync(real);
|
|
54155
54277
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
54156
54278
|
size = stat3.size;
|
|
54157
54279
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -54179,13 +54301,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
54179
54301
|
let size;
|
|
54180
54302
|
let mtimeMs;
|
|
54181
54303
|
try {
|
|
54182
|
-
const lstat = await
|
|
54304
|
+
const lstat = await fs56.promises.lstat(resolved);
|
|
54183
54305
|
if (lstat.isSymbolicLink()) {
|
|
54184
|
-
real = await
|
|
54306
|
+
real = await fs56.promises.realpath(resolved);
|
|
54185
54307
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
54186
54308
|
return { error: "Path is outside working directory" };
|
|
54187
54309
|
}
|
|
54188
|
-
const stat3 = await
|
|
54310
|
+
const stat3 = await fs56.promises.stat(real);
|
|
54189
54311
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
54190
54312
|
size = stat3.size;
|
|
54191
54313
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -54234,7 +54356,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
54234
54356
|
|
|
54235
54357
|
// src/files/read/read-file-range-async.ts
|
|
54236
54358
|
init_yield_to_event_loop();
|
|
54237
|
-
import
|
|
54359
|
+
import fs57 from "node:fs";
|
|
54238
54360
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
54239
54361
|
|
|
54240
54362
|
// src/files/read/read-file-range-line-zero.ts
|
|
@@ -54348,8 +54470,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
54348
54470
|
|
|
54349
54471
|
// src/files/read/read-file-range-async.ts
|
|
54350
54472
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
54351
|
-
const fileSize = fileSizeIn ?? (await
|
|
54352
|
-
const fd = await
|
|
54473
|
+
const fileSize = fileSizeIn ?? (await fs57.promises.stat(filePath)).size;
|
|
54474
|
+
const fd = await fs57.promises.open(filePath, "r");
|
|
54353
54475
|
const bufSize = 64 * 1024;
|
|
54354
54476
|
const buf = Buffer.alloc(bufSize);
|
|
54355
54477
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -54450,7 +54572,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
54450
54572
|
}
|
|
54451
54573
|
|
|
54452
54574
|
// src/files/read/read-small-file-range-async.ts
|
|
54453
|
-
import
|
|
54575
|
+
import fs58 from "node:fs";
|
|
54454
54576
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
54455
54577
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
54456
54578
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -54480,7 +54602,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
54480
54602
|
};
|
|
54481
54603
|
}
|
|
54482
54604
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
54483
|
-
const raw =
|
|
54605
|
+
const raw = fs58.readFileSync(filePath, "utf8");
|
|
54484
54606
|
const lines = raw.split(/\r?\n/);
|
|
54485
54607
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
54486
54608
|
}
|
|
@@ -54488,28 +54610,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
54488
54610
|
if (isMainThread5) {
|
|
54489
54611
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
54490
54612
|
}
|
|
54491
|
-
const raw = await
|
|
54613
|
+
const raw = await fs58.promises.readFile(filePath, "utf8");
|
|
54492
54614
|
const lines = raw.split(/\r?\n/);
|
|
54493
54615
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
54494
54616
|
}
|
|
54495
54617
|
|
|
54496
54618
|
// src/files/read/read-file-buffer-full-async.ts
|
|
54497
54619
|
init_yield_to_event_loop();
|
|
54498
|
-
import
|
|
54620
|
+
import fs59 from "node:fs";
|
|
54499
54621
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
54500
54622
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
54501
54623
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
54502
54624
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
54503
54625
|
if (isMainThread6) {
|
|
54504
|
-
const size2 = knownSize ??
|
|
54626
|
+
const size2 = knownSize ?? fs59.statSync(filePath).size;
|
|
54505
54627
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
54506
54628
|
await yieldToEventLoop();
|
|
54507
|
-
const buffer =
|
|
54629
|
+
const buffer = fs59.readFileSync(filePath);
|
|
54508
54630
|
return { buffer, size: buffer.length };
|
|
54509
54631
|
}
|
|
54510
54632
|
}
|
|
54511
|
-
const size = knownSize ?? (await
|
|
54512
|
-
const fd = await
|
|
54633
|
+
const size = knownSize ?? (await fs59.promises.stat(filePath)).size;
|
|
54634
|
+
const fd = await fs59.promises.open(filePath, "r");
|
|
54513
54635
|
const chunks = [];
|
|
54514
54636
|
let position = 0;
|
|
54515
54637
|
let bytesSinceYield = 0;
|
|
@@ -54612,7 +54734,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
54612
54734
|
}
|
|
54613
54735
|
if (hasRange) {
|
|
54614
54736
|
if (fileSize == null) {
|
|
54615
|
-
const stat3 = await
|
|
54737
|
+
const stat3 = await fs60.promises.stat(resolvedPath);
|
|
54616
54738
|
fileSize = stat3.size;
|
|
54617
54739
|
}
|
|
54618
54740
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -54910,12 +55032,12 @@ function parseOptionalInt2(raw) {
|
|
|
54910
55032
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
54911
55033
|
}
|
|
54912
55034
|
function parseCodeNavParams(url2) {
|
|
54913
|
-
const
|
|
55035
|
+
const path90 = url2.searchParams.get("path") ?? "";
|
|
54914
55036
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
54915
55037
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
54916
55038
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
54917
55039
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
54918
|
-
return { path:
|
|
55040
|
+
return { path: path90, op, line, column };
|
|
54919
55041
|
}
|
|
54920
55042
|
function parseCodeNavPath(url2) {
|
|
54921
55043
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -55713,18 +55835,18 @@ function hasRunningTurn(turns) {
|
|
|
55713
55835
|
}
|
|
55714
55836
|
|
|
55715
55837
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
55716
|
-
import
|
|
55838
|
+
import fs63 from "node:fs";
|
|
55717
55839
|
|
|
55718
55840
|
// src/git/snapshot/capture.ts
|
|
55719
|
-
import * as
|
|
55720
|
-
import * as
|
|
55841
|
+
import * as fs62 from "node:fs";
|
|
55842
|
+
import * as path83 from "node:path";
|
|
55721
55843
|
|
|
55722
55844
|
// src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
55723
|
-
import * as
|
|
55845
|
+
import * as fs61 from "node:fs";
|
|
55724
55846
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
55725
55847
|
let data;
|
|
55726
55848
|
try {
|
|
55727
|
-
data = JSON.parse(
|
|
55849
|
+
data = JSON.parse(fs61.readFileSync(filePath, "utf8"));
|
|
55728
55850
|
} catch (error51) {
|
|
55729
55851
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
55730
55852
|
}
|
|
@@ -55753,18 +55875,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
55753
55875
|
}
|
|
55754
55876
|
|
|
55755
55877
|
// src/git/snapshot/resolve-repo-roots.ts
|
|
55756
|
-
import * as
|
|
55878
|
+
import * as path82 from "node:path";
|
|
55757
55879
|
async function resolveSnapshotRepoRoots(options) {
|
|
55758
55880
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
55759
55881
|
if (worktreePaths?.length) {
|
|
55760
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
55882
|
+
const paths = [...new Set(worktreePaths.map((p) => path82.resolve(p)))];
|
|
55761
55883
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
55762
55884
|
}
|
|
55763
55885
|
try {
|
|
55764
55886
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
55765
55887
|
const sid = sessionId?.trim();
|
|
55766
55888
|
if (!sid) return roots;
|
|
55767
|
-
const sessionRoots = roots.filter((root) =>
|
|
55889
|
+
const sessionRoots = roots.filter((root) => path82.basename(root) === sid);
|
|
55768
55890
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
55769
55891
|
} catch (error51) {
|
|
55770
55892
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -55786,7 +55908,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
55786
55908
|
});
|
|
55787
55909
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
55788
55910
|
try {
|
|
55789
|
-
|
|
55911
|
+
fs62.mkdirSync(dir, { recursive: true });
|
|
55790
55912
|
} catch (e) {
|
|
55791
55913
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
55792
55914
|
}
|
|
@@ -55795,9 +55917,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
55795
55917
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
55796
55918
|
repos
|
|
55797
55919
|
};
|
|
55798
|
-
const filePath =
|
|
55920
|
+
const filePath = path83.join(dir, `${runId}.json`);
|
|
55799
55921
|
try {
|
|
55800
|
-
|
|
55922
|
+
fs62.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
55801
55923
|
} catch (e) {
|
|
55802
55924
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
55803
55925
|
}
|
|
@@ -55817,7 +55939,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
55817
55939
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
55818
55940
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
55819
55941
|
try {
|
|
55820
|
-
await
|
|
55942
|
+
await fs63.promises.access(file2, fs63.constants.F_OK);
|
|
55821
55943
|
} catch {
|
|
55822
55944
|
deps.log(
|
|
55823
55945
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -56468,6 +56590,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
|
|
|
56468
56590
|
var handleSessionArchivedMessage = (msg, deps) => {
|
|
56469
56591
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
56470
56592
|
if (!sessionId) return;
|
|
56593
|
+
cleanupSessionPlans(sessionId);
|
|
56471
56594
|
void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
|
|
56472
56595
|
};
|
|
56473
56596
|
|
|
@@ -56475,11 +56598,12 @@ var handleSessionArchivedMessage = (msg, deps) => {
|
|
|
56475
56598
|
var handleSessionDiscardedMessage = (msg, deps) => {
|
|
56476
56599
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
56477
56600
|
if (!sessionId) return;
|
|
56601
|
+
cleanupSessionPlans(sessionId);
|
|
56478
56602
|
void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
|
|
56479
56603
|
};
|
|
56480
56604
|
|
|
56481
56605
|
// src/routing/handlers/revert-turn-snapshot.ts
|
|
56482
|
-
import * as
|
|
56606
|
+
import * as fs64 from "node:fs";
|
|
56483
56607
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
56484
56608
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
56485
56609
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -56492,7 +56616,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
56492
56616
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
56493
56617
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
56494
56618
|
try {
|
|
56495
|
-
await
|
|
56619
|
+
await fs64.promises.access(file2, fs64.constants.F_OK);
|
|
56496
56620
|
} catch {
|
|
56497
56621
|
sendWsMessage(s, {
|
|
56498
56622
|
type: "revert_turn_snapshot_result",
|
|
@@ -56566,8 +56690,8 @@ function randomSecret() {
|
|
|
56566
56690
|
}
|
|
56567
56691
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
56568
56692
|
}
|
|
56569
|
-
async function requestPreviewApi(port, secret, method,
|
|
56570
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
56693
|
+
async function requestPreviewApi(port, secret, method, path90, body) {
|
|
56694
|
+
const url2 = `http://127.0.0.1:${port}${path90}`;
|
|
56571
56695
|
const headers = {
|
|
56572
56696
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
56573
56697
|
"Content-Type": "application/json"
|
|
@@ -56579,7 +56703,7 @@ async function requestPreviewApi(port, secret, method, path88, body) {
|
|
|
56579
56703
|
});
|
|
56580
56704
|
const data = await res.json().catch(() => ({}));
|
|
56581
56705
|
if (!res.ok) {
|
|
56582
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
56706
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path90}: ${res.status}`);
|
|
56583
56707
|
}
|
|
56584
56708
|
return data;
|
|
56585
56709
|
}
|
|
@@ -56764,8 +56888,8 @@ function isValidRemoteSkillInstallItem(item) {
|
|
|
56764
56888
|
|
|
56765
56889
|
// src/skills/install/install-remote-skills-async.ts
|
|
56766
56890
|
init_yield_to_event_loop();
|
|
56767
|
-
import
|
|
56768
|
-
import
|
|
56891
|
+
import fs65 from "node:fs";
|
|
56892
|
+
import path84 from "node:path";
|
|
56769
56893
|
|
|
56770
56894
|
// src/skills/install/constants.ts
|
|
56771
56895
|
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
@@ -56776,12 +56900,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
|
56776
56900
|
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
56777
56901
|
await yieldToEventLoop();
|
|
56778
56902
|
}
|
|
56779
|
-
const dest =
|
|
56780
|
-
await
|
|
56903
|
+
const dest = path84.join(skillDir, f.path);
|
|
56904
|
+
await fs65.promises.mkdir(path84.dirname(dest), { recursive: true });
|
|
56781
56905
|
if (f.text !== void 0) {
|
|
56782
|
-
await
|
|
56906
|
+
await fs65.promises.writeFile(dest, f.text, "utf8");
|
|
56783
56907
|
} else if (f.base64) {
|
|
56784
|
-
await
|
|
56908
|
+
await fs65.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
|
|
56785
56909
|
}
|
|
56786
56910
|
}
|
|
56787
56911
|
async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
@@ -56793,7 +56917,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
|
56793
56917
|
try {
|
|
56794
56918
|
for (const item of items) {
|
|
56795
56919
|
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
56796
|
-
const skillDir =
|
|
56920
|
+
const skillDir = path84.join(cwd, targetDir, item.skillName);
|
|
56797
56921
|
for (const f of item.files) {
|
|
56798
56922
|
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
56799
56923
|
}
|
|
@@ -57156,13 +57280,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
57156
57280
|
|
|
57157
57281
|
// src/files/handle-file-browser-search.ts
|
|
57158
57282
|
init_yield_to_event_loop();
|
|
57159
|
-
import
|
|
57283
|
+
import path85 from "node:path";
|
|
57160
57284
|
var SEARCH_LIMIT = 100;
|
|
57161
57285
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
57162
57286
|
void (async () => {
|
|
57163
57287
|
await yieldToEventLoop();
|
|
57164
57288
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
57165
|
-
const sessionParentPath =
|
|
57289
|
+
const sessionParentPath = path85.resolve(
|
|
57166
57290
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
57167
57291
|
);
|
|
57168
57292
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -57260,7 +57384,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
57260
57384
|
}
|
|
57261
57385
|
|
|
57262
57386
|
// src/git/bridge-git-context.ts
|
|
57263
|
-
import * as
|
|
57387
|
+
import * as path86 from "node:path";
|
|
57264
57388
|
init_yield_to_event_loop();
|
|
57265
57389
|
|
|
57266
57390
|
// src/git/branches/get-current-branch.ts
|
|
@@ -57328,12 +57452,12 @@ function listPendingCheckouts() {
|
|
|
57328
57452
|
// src/git/bridge-git-context.ts
|
|
57329
57453
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
57330
57454
|
if (relPath === "." || relPath === "") {
|
|
57331
|
-
return
|
|
57455
|
+
return path86.basename(path86.resolve(bridgeRoot)) || "repo";
|
|
57332
57456
|
}
|
|
57333
|
-
return
|
|
57457
|
+
return path86.basename(relPath) || relPath;
|
|
57334
57458
|
}
|
|
57335
57459
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
57336
|
-
const root =
|
|
57460
|
+
const root = path86.resolve(bridgeRoot);
|
|
57337
57461
|
if (await isGitRepoDirectory(root)) {
|
|
57338
57462
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
57339
57463
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -57341,19 +57465,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
57341
57465
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
57342
57466
|
const byPath = /* @__PURE__ */ new Map();
|
|
57343
57467
|
for (const repo of [...deep, ...shallow]) {
|
|
57344
|
-
byPath.set(
|
|
57468
|
+
byPath.set(path86.resolve(repo.absolutePath), repo);
|
|
57345
57469
|
}
|
|
57346
57470
|
return [...byPath.values()];
|
|
57347
57471
|
}
|
|
57348
57472
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
57349
|
-
const bridgeResolved =
|
|
57473
|
+
const bridgeResolved = path86.resolve(bridgeRoot);
|
|
57350
57474
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
57351
57475
|
const rows = [];
|
|
57352
57476
|
for (let i = 0; i < repos.length; i++) {
|
|
57353
57477
|
if (i > 0) await yieldToEventLoop();
|
|
57354
57478
|
const repo = repos[i];
|
|
57355
|
-
let rel =
|
|
57356
|
-
if (rel.startsWith("..") ||
|
|
57479
|
+
let rel = path86.relative(bridgeResolved, repo.absolutePath);
|
|
57480
|
+
if (rel.startsWith("..") || path86.isAbsolute(rel)) continue;
|
|
57357
57481
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
57358
57482
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
57359
57483
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -57384,11 +57508,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
57384
57508
|
return rows;
|
|
57385
57509
|
}
|
|
57386
57510
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
57387
|
-
const bridgeResolved =
|
|
57511
|
+
const bridgeResolved = path86.resolve(bridgeRoot);
|
|
57388
57512
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
57389
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
57390
|
-
const resolved =
|
|
57391
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
57513
|
+
const repoPath = rel === "" ? bridgeResolved : path86.join(bridgeResolved, rel);
|
|
57514
|
+
const resolved = path86.resolve(repoPath);
|
|
57515
|
+
if (!resolved.startsWith(bridgeResolved + path86.sep) && resolved !== bridgeResolved) {
|
|
57392
57516
|
return [];
|
|
57393
57517
|
}
|
|
57394
57518
|
return listRepoBranchRefs(resolved);
|
|
@@ -57438,8 +57562,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
57438
57562
|
}
|
|
57439
57563
|
|
|
57440
57564
|
// src/git/checkout/bridge-git-checkout.ts
|
|
57441
|
-
import * as
|
|
57442
|
-
import * as
|
|
57565
|
+
import * as fs67 from "node:fs/promises";
|
|
57566
|
+
import * as path88 from "node:path";
|
|
57443
57567
|
|
|
57444
57568
|
// src/git/checkout/normalize-clone-url.ts
|
|
57445
57569
|
function normalizeCloneUrl(url2) {
|
|
@@ -57459,12 +57583,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
57459
57583
|
}
|
|
57460
57584
|
|
|
57461
57585
|
// src/git/checkout/resolve-checkout-target.ts
|
|
57462
|
-
import * as
|
|
57463
|
-
import * as
|
|
57586
|
+
import * as fs66 from "node:fs/promises";
|
|
57587
|
+
import * as path87 from "node:path";
|
|
57464
57588
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
57465
57589
|
async function pathExists(p) {
|
|
57466
57590
|
try {
|
|
57467
|
-
await
|
|
57591
|
+
await fs66.access(p);
|
|
57468
57592
|
return true;
|
|
57469
57593
|
} catch {
|
|
57470
57594
|
return false;
|
|
@@ -57476,7 +57600,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
57476
57600
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
57477
57601
|
throw new Error("Bridge root is already a git repository");
|
|
57478
57602
|
}
|
|
57479
|
-
const entries = await
|
|
57603
|
+
const entries = await fs66.readdir(bridgeRoot).catch(() => []);
|
|
57480
57604
|
if (entries.length > 0) {
|
|
57481
57605
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
57482
57606
|
}
|
|
@@ -57489,8 +57613,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
57489
57613
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
57490
57614
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
57491
57615
|
}
|
|
57492
|
-
const targetDir =
|
|
57493
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
57616
|
+
const targetDir = path87.resolve(bridgeRoot, folder);
|
|
57617
|
+
if (!targetDir.startsWith(bridgeRoot + path87.sep)) {
|
|
57494
57618
|
throw new Error("Invalid folderName");
|
|
57495
57619
|
}
|
|
57496
57620
|
if (await pathExists(targetDir)) {
|
|
@@ -57509,10 +57633,10 @@ async function bridgeGitCheckout(params) {
|
|
|
57509
57633
|
});
|
|
57510
57634
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
57511
57635
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
57512
|
-
const parent =
|
|
57513
|
-
await
|
|
57636
|
+
const parent = path88.dirname(targetDir);
|
|
57637
|
+
await fs67.mkdir(parent, { recursive: true });
|
|
57514
57638
|
if (relPath !== ".") {
|
|
57515
|
-
await
|
|
57639
|
+
await fs67.mkdir(targetDir, { recursive: true });
|
|
57516
57640
|
}
|
|
57517
57641
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
57518
57642
|
try {
|
|
@@ -57523,7 +57647,7 @@ async function bridgeGitCheckout(params) {
|
|
|
57523
57647
|
return { relPath, folderName };
|
|
57524
57648
|
} catch (e) {
|
|
57525
57649
|
if (relPath !== ".") {
|
|
57526
|
-
await
|
|
57650
|
+
await fs67.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
57527
57651
|
}
|
|
57528
57652
|
const msg = e instanceof Error ? e.message : String(e);
|
|
57529
57653
|
throw new Error(
|
|
@@ -58257,9 +58381,9 @@ async function runCliAction(program2, opts) {
|
|
|
58257
58381
|
const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
|
|
58258
58382
|
const bridgeRootOpt = (opts.bridgeRoot && typeof opts.bridgeRoot === "string" && opts.bridgeRoot.trim() ? opts.bridgeRoot.trim() : null) ?? (opts.cwd && typeof opts.cwd === "string" && opts.cwd.trim() ? opts.cwd.trim() : null);
|
|
58259
58383
|
if (bridgeRootOpt) {
|
|
58260
|
-
const resolvedBridgeRoot =
|
|
58384
|
+
const resolvedBridgeRoot = path89.resolve(process.cwd(), bridgeRootOpt);
|
|
58261
58385
|
try {
|
|
58262
|
-
const st =
|
|
58386
|
+
const st = fs68.statSync(resolvedBridgeRoot);
|
|
58263
58387
|
if (!st.isDirectory()) {
|
|
58264
58388
|
console.error(`Bridge root is not a directory: ${resolvedBridgeRoot}`);
|
|
58265
58389
|
process.exit(1);
|
|
@@ -58279,7 +58403,7 @@ async function runCliAction(program2, opts) {
|
|
|
58279
58403
|
);
|
|
58280
58404
|
let worktreesRootPath;
|
|
58281
58405
|
if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
|
|
58282
|
-
worktreesRootPath =
|
|
58406
|
+
worktreesRootPath = path89.resolve(opts.worktreesRoot.trim());
|
|
58283
58407
|
}
|
|
58284
58408
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
58285
58409
|
if (e2eCertificates) {
|