@buildautomaton/cli 0.1.68 → 0.1.69
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 +363 -270
- package/dist/cli.js.map +4 -4
- package/dist/index.js +342 -249
- 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 path84 = __require("node:path");
|
|
977
|
+
var fs63 = __require("node:fs");
|
|
978
978
|
var process8 = __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 = path84.resolve(baseDir, baseName);
|
|
1910
|
+
if (fs63.existsSync(localBin)) return localBin;
|
|
1911
|
+
if (sourceExt.includes(path84.extname(baseName))) return void 0;
|
|
1912
1912
|
const foundExt = sourceExt.find(
|
|
1913
|
-
(ext) =>
|
|
1913
|
+
(ext) => fs63.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 = fs63.realpathSync(this._scriptPath);
|
|
1926
1926
|
} catch (err) {
|
|
1927
1927
|
resolvedScriptPath = this._scriptPath;
|
|
1928
1928
|
}
|
|
1929
|
-
executableDir =
|
|
1930
|
-
|
|
1929
|
+
executableDir = path84.resolve(
|
|
1930
|
+
path84.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 = path84.basename(
|
|
1938
1938
|
this._scriptPath,
|
|
1939
|
-
|
|
1939
|
+
path84.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(path84.extname(executableFile));
|
|
1951
1951
|
let proc;
|
|
1952
1952
|
if (process8.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 = path84.basename(filename, path84.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(path85) {
|
|
2805
|
+
if (path85 === void 0) return this._executableDir;
|
|
2806
|
+
this._executableDir = path85;
|
|
2807
2807
|
return this;
|
|
2808
2808
|
}
|
|
2809
2809
|
/**
|
|
@@ -7729,7 +7729,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
7729
7729
|
join2(moduleDir, "..", sub, filename),
|
|
7730
7730
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
7731
7731
|
]);
|
|
7732
|
-
const resolved = candidates.find((
|
|
7732
|
+
const resolved = candidates.find((path84) => existsSync(path84));
|
|
7733
7733
|
if (!resolved) {
|
|
7734
7734
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
7735
7735
|
}
|
|
@@ -8800,7 +8800,7 @@ var require_ignore = __commonJS({
|
|
|
8800
8800
|
// path matching.
|
|
8801
8801
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
8802
8802
|
// @returns {TestResult} true if a file is ignored
|
|
8803
|
-
test(
|
|
8803
|
+
test(path84, checkUnignored, mode) {
|
|
8804
8804
|
let ignored = false;
|
|
8805
8805
|
let unignored = false;
|
|
8806
8806
|
let matchedRule;
|
|
@@ -8809,7 +8809,7 @@ var require_ignore = __commonJS({
|
|
|
8809
8809
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
8810
8810
|
return;
|
|
8811
8811
|
}
|
|
8812
|
-
const matched = rule[mode].test(
|
|
8812
|
+
const matched = rule[mode].test(path84);
|
|
8813
8813
|
if (!matched) {
|
|
8814
8814
|
return;
|
|
8815
8815
|
}
|
|
@@ -8830,17 +8830,17 @@ var require_ignore = __commonJS({
|
|
|
8830
8830
|
var throwError = (message, Ctor) => {
|
|
8831
8831
|
throw new Ctor(message);
|
|
8832
8832
|
};
|
|
8833
|
-
var checkPath = (
|
|
8834
|
-
if (!isString(
|
|
8833
|
+
var checkPath = (path84, originalPath, doThrow) => {
|
|
8834
|
+
if (!isString(path84)) {
|
|
8835
8835
|
return doThrow(
|
|
8836
8836
|
`path must be a string, but got \`${originalPath}\``,
|
|
8837
8837
|
TypeError
|
|
8838
8838
|
);
|
|
8839
8839
|
}
|
|
8840
|
-
if (!
|
|
8840
|
+
if (!path84) {
|
|
8841
8841
|
return doThrow(`path must not be empty`, TypeError);
|
|
8842
8842
|
}
|
|
8843
|
-
if (checkPath.isNotRelative(
|
|
8843
|
+
if (checkPath.isNotRelative(path84)) {
|
|
8844
8844
|
const r = "`path.relative()`d";
|
|
8845
8845
|
return doThrow(
|
|
8846
8846
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -8849,7 +8849,7 @@ var require_ignore = __commonJS({
|
|
|
8849
8849
|
}
|
|
8850
8850
|
return true;
|
|
8851
8851
|
};
|
|
8852
|
-
var isNotRelative = (
|
|
8852
|
+
var isNotRelative = (path84) => REGEX_TEST_INVALID_PATH.test(path84);
|
|
8853
8853
|
checkPath.isNotRelative = isNotRelative;
|
|
8854
8854
|
checkPath.convert = (p) => p;
|
|
8855
8855
|
var Ignore = class {
|
|
@@ -8879,19 +8879,19 @@ var require_ignore = __commonJS({
|
|
|
8879
8879
|
}
|
|
8880
8880
|
// @returns {TestResult}
|
|
8881
8881
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
8882
|
-
const
|
|
8882
|
+
const path84 = originalPath && checkPath.convert(originalPath);
|
|
8883
8883
|
checkPath(
|
|
8884
|
-
|
|
8884
|
+
path84,
|
|
8885
8885
|
originalPath,
|
|
8886
8886
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
8887
8887
|
);
|
|
8888
|
-
return this._t(
|
|
8888
|
+
return this._t(path84, cache2, checkUnignored, slices);
|
|
8889
8889
|
}
|
|
8890
|
-
checkIgnore(
|
|
8891
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
8892
|
-
return this.test(
|
|
8890
|
+
checkIgnore(path84) {
|
|
8891
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path84)) {
|
|
8892
|
+
return this.test(path84);
|
|
8893
8893
|
}
|
|
8894
|
-
const slices =
|
|
8894
|
+
const slices = path84.split(SLASH).filter(Boolean);
|
|
8895
8895
|
slices.pop();
|
|
8896
8896
|
if (slices.length) {
|
|
8897
8897
|
const parent = this._t(
|
|
@@ -8904,18 +8904,18 @@ var require_ignore = __commonJS({
|
|
|
8904
8904
|
return parent;
|
|
8905
8905
|
}
|
|
8906
8906
|
}
|
|
8907
|
-
return this._rules.test(
|
|
8907
|
+
return this._rules.test(path84, false, MODE_CHECK_IGNORE);
|
|
8908
8908
|
}
|
|
8909
|
-
_t(
|
|
8910
|
-
if (
|
|
8911
|
-
return cache2[
|
|
8909
|
+
_t(path84, cache2, checkUnignored, slices) {
|
|
8910
|
+
if (path84 in cache2) {
|
|
8911
|
+
return cache2[path84];
|
|
8912
8912
|
}
|
|
8913
8913
|
if (!slices) {
|
|
8914
|
-
slices =
|
|
8914
|
+
slices = path84.split(SLASH).filter(Boolean);
|
|
8915
8915
|
}
|
|
8916
8916
|
slices.pop();
|
|
8917
8917
|
if (!slices.length) {
|
|
8918
|
-
return cache2[
|
|
8918
|
+
return cache2[path84] = this._rules.test(path84, checkUnignored, MODE_IGNORE);
|
|
8919
8919
|
}
|
|
8920
8920
|
const parent = this._t(
|
|
8921
8921
|
slices.join(SLASH) + SLASH,
|
|
@@ -8923,29 +8923,29 @@ var require_ignore = __commonJS({
|
|
|
8923
8923
|
checkUnignored,
|
|
8924
8924
|
slices
|
|
8925
8925
|
);
|
|
8926
|
-
return cache2[
|
|
8926
|
+
return cache2[path84] = parent.ignored ? parent : this._rules.test(path84, checkUnignored, MODE_IGNORE);
|
|
8927
8927
|
}
|
|
8928
|
-
ignores(
|
|
8929
|
-
return this._test(
|
|
8928
|
+
ignores(path84) {
|
|
8929
|
+
return this._test(path84, this._ignoreCache, false).ignored;
|
|
8930
8930
|
}
|
|
8931
8931
|
createFilter() {
|
|
8932
|
-
return (
|
|
8932
|
+
return (path84) => !this.ignores(path84);
|
|
8933
8933
|
}
|
|
8934
8934
|
filter(paths) {
|
|
8935
8935
|
return makeArray(paths).filter(this.createFilter());
|
|
8936
8936
|
}
|
|
8937
8937
|
// @returns {TestResult}
|
|
8938
|
-
test(
|
|
8939
|
-
return this._test(
|
|
8938
|
+
test(path84) {
|
|
8939
|
+
return this._test(path84, this._testCache, true);
|
|
8940
8940
|
}
|
|
8941
8941
|
};
|
|
8942
8942
|
var factory = (options) => new Ignore(options);
|
|
8943
|
-
var isPathValid = (
|
|
8943
|
+
var isPathValid = (path84) => checkPath(path84 && checkPath.convert(path84), path84, RETURN_FALSE);
|
|
8944
8944
|
var setupWindows = () => {
|
|
8945
8945
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
8946
8946
|
checkPath.convert = makePosix;
|
|
8947
8947
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
8948
|
-
checkPath.isNotRelative = (
|
|
8948
|
+
checkPath.isNotRelative = (path84) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path84) || isNotRelative(path84);
|
|
8949
8949
|
};
|
|
8950
8950
|
if (
|
|
8951
8951
|
// Detect `process` so that it can run in browsers.
|
|
@@ -12951,8 +12951,8 @@ var init_parseUtil = __esm({
|
|
|
12951
12951
|
init_errors();
|
|
12952
12952
|
init_en();
|
|
12953
12953
|
makeIssue = (params) => {
|
|
12954
|
-
const { data, path:
|
|
12955
|
-
const fullPath = [...
|
|
12954
|
+
const { data, path: path84, errorMaps, issueData } = params;
|
|
12955
|
+
const fullPath = [...path84, ...issueData.path || []];
|
|
12956
12956
|
const fullIssue = {
|
|
12957
12957
|
...issueData,
|
|
12958
12958
|
path: fullPath
|
|
@@ -13260,11 +13260,11 @@ var init_types2 = __esm({
|
|
|
13260
13260
|
init_parseUtil();
|
|
13261
13261
|
init_util();
|
|
13262
13262
|
ParseInputLazyPath = class {
|
|
13263
|
-
constructor(parent, value,
|
|
13263
|
+
constructor(parent, value, path84, key) {
|
|
13264
13264
|
this._cachedPath = [];
|
|
13265
13265
|
this.parent = parent;
|
|
13266
13266
|
this.data = value;
|
|
13267
|
-
this._path =
|
|
13267
|
+
this._path = path84;
|
|
13268
13268
|
this._key = key;
|
|
13269
13269
|
}
|
|
13270
13270
|
get path() {
|
|
@@ -16989,10 +16989,10 @@ function assignProp(target, prop, value) {
|
|
|
16989
16989
|
configurable: true
|
|
16990
16990
|
});
|
|
16991
16991
|
}
|
|
16992
|
-
function getElementAtPath(obj,
|
|
16993
|
-
if (!
|
|
16992
|
+
function getElementAtPath(obj, path84) {
|
|
16993
|
+
if (!path84)
|
|
16994
16994
|
return obj;
|
|
16995
|
-
return
|
|
16995
|
+
return path84.reduce((acc, key) => acc?.[key], obj);
|
|
16996
16996
|
}
|
|
16997
16997
|
function promiseAllObject(promisesObj) {
|
|
16998
16998
|
const keys = Object.keys(promisesObj);
|
|
@@ -17241,11 +17241,11 @@ function aborted(x, startIndex = 0) {
|
|
|
17241
17241
|
}
|
|
17242
17242
|
return false;
|
|
17243
17243
|
}
|
|
17244
|
-
function prefixIssues(
|
|
17244
|
+
function prefixIssues(path84, issues) {
|
|
17245
17245
|
return issues.map((iss) => {
|
|
17246
17246
|
var _a2;
|
|
17247
17247
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
17248
|
-
iss.path.unshift(
|
|
17248
|
+
iss.path.unshift(path84);
|
|
17249
17249
|
return iss;
|
|
17250
17250
|
});
|
|
17251
17251
|
}
|
|
@@ -17434,7 +17434,7 @@ function treeifyError(error40, _mapper) {
|
|
|
17434
17434
|
return issue2.message;
|
|
17435
17435
|
};
|
|
17436
17436
|
const result = { errors: [] };
|
|
17437
|
-
const processError = (error41,
|
|
17437
|
+
const processError = (error41, path84 = []) => {
|
|
17438
17438
|
var _a2, _b;
|
|
17439
17439
|
for (const issue2 of error41.issues) {
|
|
17440
17440
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -17444,7 +17444,7 @@ function treeifyError(error40, _mapper) {
|
|
|
17444
17444
|
} else if (issue2.code === "invalid_element") {
|
|
17445
17445
|
processError({ issues: issue2.issues }, issue2.path);
|
|
17446
17446
|
} else {
|
|
17447
|
-
const fullpath = [...
|
|
17447
|
+
const fullpath = [...path84, ...issue2.path];
|
|
17448
17448
|
if (fullpath.length === 0) {
|
|
17449
17449
|
result.errors.push(mapper(issue2));
|
|
17450
17450
|
continue;
|
|
@@ -17474,9 +17474,9 @@ function treeifyError(error40, _mapper) {
|
|
|
17474
17474
|
processError(error40);
|
|
17475
17475
|
return result;
|
|
17476
17476
|
}
|
|
17477
|
-
function toDotPath(
|
|
17477
|
+
function toDotPath(path84) {
|
|
17478
17478
|
const segs = [];
|
|
17479
|
-
for (const seg of
|
|
17479
|
+
for (const seg of path84) {
|
|
17480
17480
|
if (typeof seg === "number")
|
|
17481
17481
|
segs.push(`[${seg}]`);
|
|
17482
17482
|
else if (typeof seg === "symbol")
|
|
@@ -30959,10 +30959,10 @@ var require_src2 = __commonJS({
|
|
|
30959
30959
|
var fs_1 = __require("fs");
|
|
30960
30960
|
var debug_1 = __importDefault(require_src());
|
|
30961
30961
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
30962
|
-
function check2(
|
|
30963
|
-
log2(`checking %s`,
|
|
30962
|
+
function check2(path84, isFile, isDirectory) {
|
|
30963
|
+
log2(`checking %s`, path84);
|
|
30964
30964
|
try {
|
|
30965
|
-
const stat3 = fs_1.statSync(
|
|
30965
|
+
const stat3 = fs_1.statSync(path84);
|
|
30966
30966
|
if (stat3.isFile() && isFile) {
|
|
30967
30967
|
log2(`[OK] path represents a file`);
|
|
30968
30968
|
return true;
|
|
@@ -30982,8 +30982,8 @@ var require_src2 = __commonJS({
|
|
|
30982
30982
|
throw e;
|
|
30983
30983
|
}
|
|
30984
30984
|
}
|
|
30985
|
-
function exists2(
|
|
30986
|
-
return check2(
|
|
30985
|
+
function exists2(path84, type = exports.READABLE) {
|
|
30986
|
+
return check2(path84, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
30987
30987
|
}
|
|
30988
30988
|
exports.exists = exists2;
|
|
30989
30989
|
exports.FILE = 1;
|
|
@@ -31064,7 +31064,7 @@ var {
|
|
|
31064
31064
|
} = import_index.default;
|
|
31065
31065
|
|
|
31066
31066
|
// src/cli-version.ts
|
|
31067
|
-
var CLI_VERSION = "0.1.
|
|
31067
|
+
var CLI_VERSION = "0.1.69".length > 0 ? "0.1.69" : "0.0.0-dev";
|
|
31068
31068
|
|
|
31069
31069
|
// src/cli/defaults.ts
|
|
31070
31070
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
@@ -31072,8 +31072,8 @@ var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
|
|
|
31072
31072
|
|
|
31073
31073
|
// src/cli/run-cli-action.ts
|
|
31074
31074
|
init_cli_log_level();
|
|
31075
|
-
import * as
|
|
31076
|
-
import * as
|
|
31075
|
+
import * as fs62 from "node:fs";
|
|
31076
|
+
import * as path83 from "node:path";
|
|
31077
31077
|
|
|
31078
31078
|
// src/config.ts
|
|
31079
31079
|
import fs from "node:fs";
|
|
@@ -37952,8 +37952,8 @@ async function execGitFile(args, options) {
|
|
|
37952
37952
|
}
|
|
37953
37953
|
|
|
37954
37954
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
37955
|
-
function normalizeGitDiffPath(
|
|
37956
|
-
return
|
|
37955
|
+
function normalizeGitDiffPath(path84) {
|
|
37956
|
+
return path84.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
37957
37957
|
}
|
|
37958
37958
|
|
|
37959
37959
|
// src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -39291,6 +39291,21 @@ function createBridgeMcpToolRegistry(shared) {
|
|
|
39291
39291
|
// src/mcp/bridge-access/start-server.ts
|
|
39292
39292
|
import * as http from "node:http";
|
|
39293
39293
|
|
|
39294
|
+
// src/http/close-http-server.ts
|
|
39295
|
+
function isServerNotRunningError(err) {
|
|
39296
|
+
return err.code === "ERR_SERVER_NOT_RUNNING";
|
|
39297
|
+
}
|
|
39298
|
+
function closeHttpServer(server) {
|
|
39299
|
+
if (!server) return Promise.resolve();
|
|
39300
|
+
return new Promise((resolve37) => {
|
|
39301
|
+
server.close((err) => {
|
|
39302
|
+
if (err && !isServerNotRunningError(err)) {
|
|
39303
|
+
}
|
|
39304
|
+
resolve37();
|
|
39305
|
+
});
|
|
39306
|
+
});
|
|
39307
|
+
}
|
|
39308
|
+
|
|
39294
39309
|
// src/mcp/bridge-access/read-json-body.ts
|
|
39295
39310
|
function readJsonBody(req) {
|
|
39296
39311
|
return new Promise((resolve37, reject) => {
|
|
@@ -39372,9 +39387,7 @@ function startBridgeAccessServer(registry2) {
|
|
|
39372
39387
|
}
|
|
39373
39388
|
resolve37({
|
|
39374
39389
|
port: addr.port,
|
|
39375
|
-
close: () =>
|
|
39376
|
-
server.close((err) => err ? closeReject(err) : closeResolve());
|
|
39377
|
-
})
|
|
39390
|
+
close: () => closeHttpServer(server)
|
|
39378
39391
|
});
|
|
39379
39392
|
});
|
|
39380
39393
|
});
|
|
@@ -42215,8 +42228,8 @@ function pathspec(...paths) {
|
|
|
42215
42228
|
cache.set(key, paths);
|
|
42216
42229
|
return key;
|
|
42217
42230
|
}
|
|
42218
|
-
function isPathSpec(
|
|
42219
|
-
return
|
|
42231
|
+
function isPathSpec(path84) {
|
|
42232
|
+
return path84 instanceof String && cache.has(path84);
|
|
42220
42233
|
}
|
|
42221
42234
|
function toPaths(pathSpec) {
|
|
42222
42235
|
return cache.get(pathSpec) || [];
|
|
@@ -42305,8 +42318,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
42305
42318
|
function forEachLineWithContent(input, callback) {
|
|
42306
42319
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
42307
42320
|
}
|
|
42308
|
-
function folderExists(
|
|
42309
|
-
return (0, import_file_exists.exists)(
|
|
42321
|
+
function folderExists(path84) {
|
|
42322
|
+
return (0, import_file_exists.exists)(path84, import_file_exists.FOLDER);
|
|
42310
42323
|
}
|
|
42311
42324
|
function append(target, item) {
|
|
42312
42325
|
if (Array.isArray(target)) {
|
|
@@ -42710,8 +42723,8 @@ function checkIsRepoRootTask() {
|
|
|
42710
42723
|
commands,
|
|
42711
42724
|
format: "utf-8",
|
|
42712
42725
|
onError,
|
|
42713
|
-
parser(
|
|
42714
|
-
return /^\.(git)?$/.test(
|
|
42726
|
+
parser(path84) {
|
|
42727
|
+
return /^\.(git)?$/.test(path84.trim());
|
|
42715
42728
|
}
|
|
42716
42729
|
};
|
|
42717
42730
|
}
|
|
@@ -43145,11 +43158,11 @@ function parseGrep(grep) {
|
|
|
43145
43158
|
const paths = /* @__PURE__ */ new Set();
|
|
43146
43159
|
const results = {};
|
|
43147
43160
|
forEachLineWithContent(grep, (input) => {
|
|
43148
|
-
const [
|
|
43149
|
-
paths.add(
|
|
43150
|
-
(results[
|
|
43161
|
+
const [path84, line, preview] = input.split(NULL);
|
|
43162
|
+
paths.add(path84);
|
|
43163
|
+
(results[path84] = results[path84] || []).push({
|
|
43151
43164
|
line: asNumber(line),
|
|
43152
|
-
path:
|
|
43165
|
+
path: path84,
|
|
43153
43166
|
preview
|
|
43154
43167
|
});
|
|
43155
43168
|
});
|
|
@@ -43914,14 +43927,14 @@ var init_hash_object = __esm2({
|
|
|
43914
43927
|
init_task();
|
|
43915
43928
|
}
|
|
43916
43929
|
});
|
|
43917
|
-
function parseInit(bare,
|
|
43930
|
+
function parseInit(bare, path84, text) {
|
|
43918
43931
|
const response = String(text).trim();
|
|
43919
43932
|
let result;
|
|
43920
43933
|
if (result = initResponseRegex.exec(response)) {
|
|
43921
|
-
return new InitSummary(bare,
|
|
43934
|
+
return new InitSummary(bare, path84, false, result[1]);
|
|
43922
43935
|
}
|
|
43923
43936
|
if (result = reInitResponseRegex.exec(response)) {
|
|
43924
|
-
return new InitSummary(bare,
|
|
43937
|
+
return new InitSummary(bare, path84, true, result[1]);
|
|
43925
43938
|
}
|
|
43926
43939
|
let gitDir = "";
|
|
43927
43940
|
const tokens = response.split(" ");
|
|
@@ -43932,7 +43945,7 @@ function parseInit(bare, path82, text) {
|
|
|
43932
43945
|
break;
|
|
43933
43946
|
}
|
|
43934
43947
|
}
|
|
43935
|
-
return new InitSummary(bare,
|
|
43948
|
+
return new InitSummary(bare, path84, /^re/i.test(response), gitDir);
|
|
43936
43949
|
}
|
|
43937
43950
|
var InitSummary;
|
|
43938
43951
|
var initResponseRegex;
|
|
@@ -43941,9 +43954,9 @@ var init_InitSummary = __esm2({
|
|
|
43941
43954
|
"src/lib/responses/InitSummary.ts"() {
|
|
43942
43955
|
"use strict";
|
|
43943
43956
|
InitSummary = class {
|
|
43944
|
-
constructor(bare,
|
|
43957
|
+
constructor(bare, path84, existing, gitDir) {
|
|
43945
43958
|
this.bare = bare;
|
|
43946
|
-
this.path =
|
|
43959
|
+
this.path = path84;
|
|
43947
43960
|
this.existing = existing;
|
|
43948
43961
|
this.gitDir = gitDir;
|
|
43949
43962
|
}
|
|
@@ -43955,7 +43968,7 @@ var init_InitSummary = __esm2({
|
|
|
43955
43968
|
function hasBareCommand(command) {
|
|
43956
43969
|
return command.includes(bareCommand);
|
|
43957
43970
|
}
|
|
43958
|
-
function initTask(bare = false,
|
|
43971
|
+
function initTask(bare = false, path84, customArgs) {
|
|
43959
43972
|
const commands = ["init", ...customArgs];
|
|
43960
43973
|
if (bare && !hasBareCommand(commands)) {
|
|
43961
43974
|
commands.splice(1, 0, bareCommand);
|
|
@@ -43964,7 +43977,7 @@ function initTask(bare = false, path82, customArgs) {
|
|
|
43964
43977
|
commands,
|
|
43965
43978
|
format: "utf-8",
|
|
43966
43979
|
parser(text) {
|
|
43967
|
-
return parseInit(commands.includes("--bare"),
|
|
43980
|
+
return parseInit(commands.includes("--bare"), path84, text);
|
|
43968
43981
|
}
|
|
43969
43982
|
};
|
|
43970
43983
|
}
|
|
@@ -44780,12 +44793,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
44780
44793
|
"use strict";
|
|
44781
44794
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
44782
44795
|
FileStatusSummary = class {
|
|
44783
|
-
constructor(
|
|
44784
|
-
this.path =
|
|
44796
|
+
constructor(path84, index, working_dir) {
|
|
44797
|
+
this.path = path84;
|
|
44785
44798
|
this.index = index;
|
|
44786
44799
|
this.working_dir = working_dir;
|
|
44787
44800
|
if (index === "R" || working_dir === "R") {
|
|
44788
|
-
const detail = fromPathRegex.exec(
|
|
44801
|
+
const detail = fromPathRegex.exec(path84) || [null, path84, path84];
|
|
44789
44802
|
this.from = detail[2] || "";
|
|
44790
44803
|
this.path = detail[1] || "";
|
|
44791
44804
|
}
|
|
@@ -44816,14 +44829,14 @@ function splitLine(result, lineStr) {
|
|
|
44816
44829
|
default:
|
|
44817
44830
|
return;
|
|
44818
44831
|
}
|
|
44819
|
-
function data(index, workingDir,
|
|
44832
|
+
function data(index, workingDir, path84) {
|
|
44820
44833
|
const raw = `${index}${workingDir}`;
|
|
44821
44834
|
const handler = parsers6.get(raw);
|
|
44822
44835
|
if (handler) {
|
|
44823
|
-
handler(result,
|
|
44836
|
+
handler(result, path84);
|
|
44824
44837
|
}
|
|
44825
44838
|
if (raw !== "##" && raw !== "!!") {
|
|
44826
|
-
result.files.push(new FileStatusSummary(
|
|
44839
|
+
result.files.push(new FileStatusSummary(path84, index, workingDir));
|
|
44827
44840
|
}
|
|
44828
44841
|
}
|
|
44829
44842
|
}
|
|
@@ -45132,9 +45145,9 @@ var init_simple_git_api = __esm2({
|
|
|
45132
45145
|
next
|
|
45133
45146
|
);
|
|
45134
45147
|
}
|
|
45135
|
-
hashObject(
|
|
45148
|
+
hashObject(path84, write) {
|
|
45136
45149
|
return this._runTask(
|
|
45137
|
-
hashObjectTask(
|
|
45150
|
+
hashObjectTask(path84, write === true),
|
|
45138
45151
|
trailingFunctionArgument(arguments)
|
|
45139
45152
|
);
|
|
45140
45153
|
}
|
|
@@ -45487,8 +45500,8 @@ var init_branch = __esm2({
|
|
|
45487
45500
|
}
|
|
45488
45501
|
});
|
|
45489
45502
|
function toPath(input) {
|
|
45490
|
-
const
|
|
45491
|
-
return
|
|
45503
|
+
const path84 = input.trim().replace(/^["']|["']$/g, "");
|
|
45504
|
+
return path84 && normalize3(path84);
|
|
45492
45505
|
}
|
|
45493
45506
|
var parseCheckIgnore;
|
|
45494
45507
|
var init_CheckIgnore = __esm2({
|
|
@@ -45802,8 +45815,8 @@ __export2(sub_module_exports, {
|
|
|
45802
45815
|
subModuleTask: () => subModuleTask,
|
|
45803
45816
|
updateSubModuleTask: () => updateSubModuleTask
|
|
45804
45817
|
});
|
|
45805
|
-
function addSubModuleTask(repo,
|
|
45806
|
-
return subModuleTask(["add", repo,
|
|
45818
|
+
function addSubModuleTask(repo, path84) {
|
|
45819
|
+
return subModuleTask(["add", repo, path84]);
|
|
45807
45820
|
}
|
|
45808
45821
|
function initSubModuleTask(customArgs) {
|
|
45809
45822
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -46136,8 +46149,8 @@ var require_git = __commonJS2({
|
|
|
46136
46149
|
}
|
|
46137
46150
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
46138
46151
|
};
|
|
46139
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
46140
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
46152
|
+
Git2.prototype.submoduleAdd = function(repo, path84, then) {
|
|
46153
|
+
return this._runTask(addSubModuleTask2(repo, path84), trailingFunctionArgument2(arguments));
|
|
46141
46154
|
};
|
|
46142
46155
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
46143
46156
|
return this._runTask(
|
|
@@ -46876,8 +46889,8 @@ function parseNumstatEntries(lines) {
|
|
|
46876
46889
|
}
|
|
46877
46890
|
function parseNumstat(lines) {
|
|
46878
46891
|
const m = /* @__PURE__ */ new Map();
|
|
46879
|
-
for (const [
|
|
46880
|
-
m.set(
|
|
46892
|
+
for (const [path84, entry] of parseNumstatEntries(lines)) {
|
|
46893
|
+
m.set(path84, { additions: entry.additions, deletions: entry.deletions });
|
|
46881
46894
|
}
|
|
46882
46895
|
return m;
|
|
46883
46896
|
}
|
|
@@ -48672,9 +48685,8 @@ function parseSessionParent(v) {
|
|
|
48672
48685
|
return null;
|
|
48673
48686
|
}
|
|
48674
48687
|
|
|
48675
|
-
// src/worktrees/prepare-new-isolated-worktrees.ts
|
|
48676
|
-
import * as
|
|
48677
|
-
import * as path65 from "node:path";
|
|
48688
|
+
// src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
48689
|
+
import * as fs47 from "node:fs";
|
|
48678
48690
|
|
|
48679
48691
|
// src/git/discover-repos.ts
|
|
48680
48692
|
import * as fs44 from "node:fs";
|
|
@@ -48745,6 +48757,10 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
48745
48757
|
return out;
|
|
48746
48758
|
}
|
|
48747
48759
|
|
|
48760
|
+
// src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
48761
|
+
import * as fs46 from "node:fs";
|
|
48762
|
+
import * as path66 from "node:path";
|
|
48763
|
+
|
|
48748
48764
|
// src/git/worktrees/worktree-add.ts
|
|
48749
48765
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
48750
48766
|
const mainGit = cliSimpleGit(mainRepoPath);
|
|
@@ -48758,6 +48774,100 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
48758
48774
|
await mainGit.raw(["worktree", "add", worktreePath, branch]);
|
|
48759
48775
|
}
|
|
48760
48776
|
|
|
48777
|
+
// src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
48778
|
+
import * as fs45 from "node:fs";
|
|
48779
|
+
import * as path65 from "node:path";
|
|
48780
|
+
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
48781
|
+
function copyBridgeFilesAlongWorktreePath(options) {
|
|
48782
|
+
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
48783
|
+
const fileNames = options.fileNames ?? BRIDGE_FILES_ALONG_WORKTREE_PATH;
|
|
48784
|
+
if (repoPathRelativeToBridgeRoot === ".") return;
|
|
48785
|
+
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
48786
|
+
for (let i = 0; i < segments.length; i++) {
|
|
48787
|
+
const prefix = segments.slice(0, i).join("/");
|
|
48788
|
+
const bridgeDir = prefix ? path65.join(bridgeRoot, prefix) : bridgeRoot;
|
|
48789
|
+
const destDir = prefix ? path65.join(scopeDir, prefix) : scopeDir;
|
|
48790
|
+
for (const fileName of fileNames) {
|
|
48791
|
+
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
48792
|
+
}
|
|
48793
|
+
}
|
|
48794
|
+
}
|
|
48795
|
+
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
48796
|
+
const src = path65.join(srcDir, fileName);
|
|
48797
|
+
if (!fs45.existsSync(src)) return;
|
|
48798
|
+
const dest = path65.join(destDir, fileName);
|
|
48799
|
+
try {
|
|
48800
|
+
fs45.copyFileSync(src, dest);
|
|
48801
|
+
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
48802
|
+
} catch (e) {
|
|
48803
|
+
log2?.(
|
|
48804
|
+
`[worktrees] Failed to copy ${fileName} to ${dest}: ${e instanceof Error ? e.message : String(e)}`
|
|
48805
|
+
);
|
|
48806
|
+
}
|
|
48807
|
+
}
|
|
48808
|
+
|
|
48809
|
+
// src/worktrees/prepare/resolve-base-ref-for-repo.ts
|
|
48810
|
+
function resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, baseBranches) {
|
|
48811
|
+
if (!baseBranches) return "HEAD";
|
|
48812
|
+
const direct = baseBranches[repoPathRelativeToBridgeRoot]?.trim();
|
|
48813
|
+
if (direct) return direct;
|
|
48814
|
+
if (repoPathRelativeToBridgeRoot !== "." && baseBranches["."]?.trim()) {
|
|
48815
|
+
return baseBranches["."].trim();
|
|
48816
|
+
}
|
|
48817
|
+
return "HEAD";
|
|
48818
|
+
}
|
|
48819
|
+
|
|
48820
|
+
// src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
48821
|
+
async function addIsolatedRepoWorktree(options) {
|
|
48822
|
+
const {
|
|
48823
|
+
kind,
|
|
48824
|
+
bridgeResolved,
|
|
48825
|
+
scopeDir,
|
|
48826
|
+
repoAbsolutePath,
|
|
48827
|
+
branch,
|
|
48828
|
+
existingBranch,
|
|
48829
|
+
worktreeBaseBranches,
|
|
48830
|
+
log: log2
|
|
48831
|
+
} = options;
|
|
48832
|
+
const repoPathRelativeToBridgeRootRaw = path66.relative(bridgeResolved, repoAbsolutePath);
|
|
48833
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path66.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
48834
|
+
return null;
|
|
48835
|
+
}
|
|
48836
|
+
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48837
|
+
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
48838
|
+
);
|
|
48839
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path66.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
48840
|
+
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
48841
|
+
fs46.mkdirSync(path66.dirname(worktreePath), { recursive: true });
|
|
48842
|
+
copyBridgeFilesAlongWorktreePath({
|
|
48843
|
+
bridgeRoot: bridgeResolved,
|
|
48844
|
+
scopeDir,
|
|
48845
|
+
repoPathRelativeToBridgeRoot,
|
|
48846
|
+
log: log2
|
|
48847
|
+
});
|
|
48848
|
+
}
|
|
48849
|
+
const checkoutBranch = existingBranch?.trim() || branch;
|
|
48850
|
+
try {
|
|
48851
|
+
if (existingBranch?.trim()) {
|
|
48852
|
+
await gitWorktreeAddExistingBranch(repoAbsolutePath, worktreePath, checkoutBranch);
|
|
48853
|
+
log2(`[worktrees] Added ${kind} worktree ${worktreePath} (existing branch ${checkoutBranch}).`);
|
|
48854
|
+
} else {
|
|
48855
|
+
const baseRef = resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, worktreeBaseBranches);
|
|
48856
|
+
await gitWorktreeAddBranch(repoAbsolutePath, worktreePath, branch, baseRef);
|
|
48857
|
+
log2(`[worktrees] Added ${kind} worktree ${worktreePath} (branch ${branch}, base ${baseRef}).`);
|
|
48858
|
+
}
|
|
48859
|
+
return worktreePath;
|
|
48860
|
+
} catch (e) {
|
|
48861
|
+
log2(
|
|
48862
|
+
`[worktrees] Worktree add failed for ${repoAbsolutePath}: ${e instanceof Error ? e.message : String(e)}`
|
|
48863
|
+
);
|
|
48864
|
+
return null;
|
|
48865
|
+
}
|
|
48866
|
+
}
|
|
48867
|
+
|
|
48868
|
+
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
48869
|
+
import * as path67 from "node:path";
|
|
48870
|
+
|
|
48761
48871
|
// src/worktrees/worktree-layout-kind.ts
|
|
48762
48872
|
function sanitizeWorktreeBranchSegment(value) {
|
|
48763
48873
|
return value.replace(/[^a-zA-Z0-9/_-]+/g, "-").slice(0, 80) || "worktree";
|
|
@@ -48784,16 +48894,16 @@ function previewDeployBranchName(environmentId) {
|
|
|
48784
48894
|
return `preview-deploy-${sanitizeWorktreeBranchSegment(environmentId.trim())}`;
|
|
48785
48895
|
}
|
|
48786
48896
|
|
|
48787
|
-
// src/worktrees/prepare-
|
|
48788
|
-
function
|
|
48789
|
-
|
|
48790
|
-
const
|
|
48791
|
-
|
|
48792
|
-
|
|
48793
|
-
|
|
48794
|
-
}
|
|
48795
|
-
return "HEAD";
|
|
48897
|
+
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
48898
|
+
function resolveIsolatedScopeDir(options) {
|
|
48899
|
+
const bridgeResolved = path67.resolve(options.bridgeRoot);
|
|
48900
|
+
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
48901
|
+
const bridgeKeyDir = path67.join(options.worktreesRootPath, cwdKey);
|
|
48902
|
+
const scopeDir = path67.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
48903
|
+
return { bridgeResolved, scopeDir };
|
|
48796
48904
|
}
|
|
48905
|
+
|
|
48906
|
+
// src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
48797
48907
|
async function prepareNewIsolatedWorktrees(options) {
|
|
48798
48908
|
const {
|
|
48799
48909
|
kind,
|
|
@@ -48806,45 +48916,32 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
48806
48916
|
worktreeBaseBranches,
|
|
48807
48917
|
existingBranch
|
|
48808
48918
|
} = options;
|
|
48809
|
-
const bridgeResolved =
|
|
48810
|
-
|
|
48811
|
-
|
|
48812
|
-
|
|
48919
|
+
const { bridgeResolved, scopeDir } = resolveIsolatedScopeDir({
|
|
48920
|
+
worktreesRootPath,
|
|
48921
|
+
bridgeRoot,
|
|
48922
|
+
kind,
|
|
48923
|
+
scopeId,
|
|
48924
|
+
layout
|
|
48925
|
+
});
|
|
48813
48926
|
const repos = await discoverGitReposUnderRoot(bridgeResolved);
|
|
48814
48927
|
if (repos.length === 0) {
|
|
48815
48928
|
log2(`[worktrees] No Git repositories under bridge root; skipping ${kind} worktree creation.`);
|
|
48816
48929
|
return null;
|
|
48817
48930
|
}
|
|
48818
48931
|
const worktreePaths = [];
|
|
48819
|
-
|
|
48932
|
+
fs47.mkdirSync(scopeDir, { recursive: true });
|
|
48820
48933
|
await forEachWithGitYield(repos, async (repo) => {
|
|
48821
|
-
const
|
|
48822
|
-
|
|
48823
|
-
|
|
48824
|
-
|
|
48825
|
-
|
|
48826
|
-
|
|
48827
|
-
|
|
48828
|
-
|
|
48829
|
-
|
|
48830
|
-
|
|
48831
|
-
|
|
48832
|
-
const checkoutBranch = existingBranch?.trim() || branch;
|
|
48833
|
-
try {
|
|
48834
|
-
if (existingBranch?.trim()) {
|
|
48835
|
-
await gitWorktreeAddExistingBranch(repo.absolutePath, worktreePath, checkoutBranch);
|
|
48836
|
-
log2(`[worktrees] Added ${kind} worktree ${worktreePath} (existing branch ${checkoutBranch}).`);
|
|
48837
|
-
} else {
|
|
48838
|
-
const baseRef = resolveBaseRefForRepo(repoPathRelativeToBridgeRoot, worktreeBaseBranches);
|
|
48839
|
-
await gitWorktreeAddBranch(repo.absolutePath, worktreePath, branch, baseRef);
|
|
48840
|
-
log2(`[worktrees] Added ${kind} worktree ${worktreePath} (branch ${branch}, base ${baseRef}).`);
|
|
48841
|
-
}
|
|
48842
|
-
worktreePaths.push(worktreePath);
|
|
48843
|
-
} catch (e) {
|
|
48844
|
-
log2(
|
|
48845
|
-
`[worktrees] Worktree add failed for ${repo.absolutePath}: ${e instanceof Error ? e.message : String(e)}`
|
|
48846
|
-
);
|
|
48847
|
-
}
|
|
48934
|
+
const worktreePath = await addIsolatedRepoWorktree({
|
|
48935
|
+
kind,
|
|
48936
|
+
bridgeResolved,
|
|
48937
|
+
scopeDir,
|
|
48938
|
+
repoAbsolutePath: repo.absolutePath,
|
|
48939
|
+
branch,
|
|
48940
|
+
existingBranch,
|
|
48941
|
+
worktreeBaseBranches,
|
|
48942
|
+
log: log2
|
|
48943
|
+
});
|
|
48944
|
+
if (worktreePath) worktreePaths.push(worktreePath);
|
|
48848
48945
|
});
|
|
48849
48946
|
if (worktreePaths.length === 0) return null;
|
|
48850
48947
|
return {
|
|
@@ -48904,10 +49001,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
48904
49001
|
}
|
|
48905
49002
|
|
|
48906
49003
|
// src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
48907
|
-
import * as
|
|
49004
|
+
import * as path68 from "node:path";
|
|
48908
49005
|
init_yield_to_event_loop();
|
|
48909
49006
|
async function resolveExplicitSessionParentPath(params) {
|
|
48910
|
-
const resolved =
|
|
49007
|
+
const resolved = path68.resolve(params.parentPathRaw);
|
|
48911
49008
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
48912
49009
|
return resolved;
|
|
48913
49010
|
}
|
|
@@ -48924,7 +49021,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
48924
49021
|
await yieldToEventLoop();
|
|
48925
49022
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
48926
49023
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
48927
|
-
const next =
|
|
49024
|
+
const next = path68.dirname(cur);
|
|
48928
49025
|
if (next === cur) break;
|
|
48929
49026
|
cur = next;
|
|
48930
49027
|
}
|
|
@@ -49072,15 +49169,15 @@ var SessionWorktreeManager = class {
|
|
|
49072
49169
|
};
|
|
49073
49170
|
|
|
49074
49171
|
// src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
49075
|
-
import * as
|
|
49076
|
-
import * as
|
|
49172
|
+
import * as fs48 from "node:fs";
|
|
49173
|
+
import * as path69 from "node:path";
|
|
49077
49174
|
init_yield_to_event_loop();
|
|
49078
49175
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
49079
49176
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
49080
49177
|
const eid = environmentId.trim();
|
|
49081
49178
|
if (!eid) return null;
|
|
49082
49179
|
try {
|
|
49083
|
-
await
|
|
49180
|
+
await fs48.promises.access(worktreesRootPath);
|
|
49084
49181
|
} catch {
|
|
49085
49182
|
return null;
|
|
49086
49183
|
}
|
|
@@ -49089,13 +49186,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49089
49186
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
49090
49187
|
const scanState = { entries: 0 };
|
|
49091
49188
|
try {
|
|
49092
|
-
for (const name of await
|
|
49189
|
+
for (const name of await fs48.promises.readdir(worktreesRootPath)) {
|
|
49093
49190
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
49094
49191
|
if (name.startsWith(".")) continue;
|
|
49095
|
-
const p =
|
|
49192
|
+
const p = path69.join(worktreesRootPath, name);
|
|
49096
49193
|
let st;
|
|
49097
49194
|
try {
|
|
49098
|
-
st = await
|
|
49195
|
+
st = await fs48.promises.stat(p);
|
|
49099
49196
|
} catch {
|
|
49100
49197
|
continue;
|
|
49101
49198
|
}
|
|
@@ -49109,7 +49206,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49109
49206
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
49110
49207
|
for (const key of keys) {
|
|
49111
49208
|
await yieldToEventLoop();
|
|
49112
|
-
const previewDir =
|
|
49209
|
+
const previewDir = path69.join(worktreesRootPath, key, ...previewDirRel);
|
|
49113
49210
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
49114
49211
|
if (binding) return binding;
|
|
49115
49212
|
}
|
|
@@ -49236,7 +49333,7 @@ var PreviewWorktreeManager = class {
|
|
|
49236
49333
|
};
|
|
49237
49334
|
|
|
49238
49335
|
// src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
49239
|
-
import * as
|
|
49336
|
+
import * as path73 from "node:path";
|
|
49240
49337
|
|
|
49241
49338
|
// src/git/worktrees/reset-worktree-to-branch.ts
|
|
49242
49339
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -49247,8 +49344,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
49247
49344
|
}
|
|
49248
49345
|
|
|
49249
49346
|
// src/worktrees/deploy/capture-and-apply-wip.ts
|
|
49250
|
-
import * as
|
|
49251
|
-
import * as
|
|
49347
|
+
import * as fs49 from "node:fs";
|
|
49348
|
+
import * as path70 from "node:path";
|
|
49252
49349
|
|
|
49253
49350
|
// src/git/snapshot/git.ts
|
|
49254
49351
|
async function gitStashCreate(repoRoot, log2) {
|
|
@@ -49296,12 +49393,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49296
49393
|
if (!ap.ok) return ap;
|
|
49297
49394
|
}
|
|
49298
49395
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
49299
|
-
const src =
|
|
49300
|
-
const dst =
|
|
49396
|
+
const src = path70.join(sourceRepoPath, rel);
|
|
49397
|
+
const dst = path70.join(targetRepoPath, rel);
|
|
49301
49398
|
try {
|
|
49302
|
-
if (!
|
|
49303
|
-
|
|
49304
|
-
|
|
49399
|
+
if (!fs49.existsSync(src)) return;
|
|
49400
|
+
fs49.mkdirSync(path70.dirname(dst), { recursive: true });
|
|
49401
|
+
fs49.copyFileSync(src, dst);
|
|
49305
49402
|
} catch (e) {
|
|
49306
49403
|
log2(
|
|
49307
49404
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -49312,14 +49409,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49312
49409
|
}
|
|
49313
49410
|
|
|
49314
49411
|
// src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
49315
|
-
import * as
|
|
49412
|
+
import * as path71 from "node:path";
|
|
49316
49413
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
49317
49414
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
49318
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
49415
|
+
const resolvedSessionParentPath = sessionParentPath ? path71.resolve(sessionParentPath) : null;
|
|
49319
49416
|
let match = null;
|
|
49320
49417
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
49321
49418
|
if (match) return;
|
|
49322
|
-
const resolvedCheckoutPath =
|
|
49419
|
+
const resolvedCheckoutPath = path71.resolve(checkoutPath);
|
|
49323
49420
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
49324
49421
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49325
49422
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -49373,7 +49470,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
49373
49470
|
}
|
|
49374
49471
|
|
|
49375
49472
|
// src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
49376
|
-
import * as
|
|
49473
|
+
import * as path72 from "node:path";
|
|
49377
49474
|
|
|
49378
49475
|
// src/git/branches/create-or-update-branch.ts
|
|
49379
49476
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -49410,19 +49507,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
49410
49507
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
49411
49508
|
const states = [];
|
|
49412
49509
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
49413
|
-
const checkoutPath =
|
|
49510
|
+
const checkoutPath = path72.resolve(sessionCheckout);
|
|
49414
49511
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
49415
49512
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49416
49513
|
checkoutPath,
|
|
49417
49514
|
bridgeRoot,
|
|
49418
|
-
sessionParentPath: sessionParentPath ?
|
|
49515
|
+
sessionParentPath: sessionParentPath ? path72.resolve(sessionParentPath) : null
|
|
49419
49516
|
});
|
|
49420
49517
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
49421
49518
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
49422
49519
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
49423
49520
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
49424
49521
|
checkoutPaths: previewCheckoutPaths,
|
|
49425
|
-
sessionParentPath: previewParentPath ?
|
|
49522
|
+
sessionParentPath: previewParentPath ? path72.resolve(previewParentPath) : null,
|
|
49426
49523
|
bridgeRoot,
|
|
49427
49524
|
repoPathRelativeToWorkspaceRoot
|
|
49428
49525
|
}) : null;
|
|
@@ -49442,7 +49539,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49442
49539
|
const eid = options.environmentId.trim();
|
|
49443
49540
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
49444
49541
|
const deployBranch = previewDeployBranchName(eid);
|
|
49445
|
-
const bridgeRoot =
|
|
49542
|
+
const bridgeRoot = path73.resolve(getBridgeRoot());
|
|
49446
49543
|
await previewWorktreeManager.ensureCached(eid);
|
|
49447
49544
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
49448
49545
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -49482,10 +49579,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49482
49579
|
}
|
|
49483
49580
|
|
|
49484
49581
|
// src/worktrees/manager/default-worktrees-root-path.ts
|
|
49485
|
-
import * as
|
|
49582
|
+
import * as path74 from "node:path";
|
|
49486
49583
|
import os9 from "node:os";
|
|
49487
49584
|
function defaultWorktreesRootPath() {
|
|
49488
|
-
return
|
|
49585
|
+
return path74.join(os9.homedir(), ".buildautomaton", "worktrees");
|
|
49489
49586
|
}
|
|
49490
49587
|
|
|
49491
49588
|
// src/connection/create-bridge-worktree-managers.ts
|
|
@@ -49615,14 +49712,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
49615
49712
|
}
|
|
49616
49713
|
|
|
49617
49714
|
// src/files/list-dir/index.ts
|
|
49618
|
-
import
|
|
49715
|
+
import fs51 from "node:fs";
|
|
49619
49716
|
|
|
49620
49717
|
// src/files/ensure-under-cwd.ts
|
|
49621
|
-
import
|
|
49718
|
+
import path75 from "node:path";
|
|
49622
49719
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
49623
|
-
const normalized =
|
|
49624
|
-
const resolved =
|
|
49625
|
-
if (!resolved.startsWith(cwd +
|
|
49720
|
+
const normalized = path75.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
49721
|
+
const resolved = path75.resolve(cwd, normalized);
|
|
49722
|
+
if (!resolved.startsWith(cwd + path75.sep) && resolved !== cwd) {
|
|
49626
49723
|
return null;
|
|
49627
49724
|
}
|
|
49628
49725
|
return resolved;
|
|
@@ -49635,15 +49732,15 @@ init_yield_to_event_loop();
|
|
|
49635
49732
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
49636
49733
|
|
|
49637
49734
|
// src/files/list-dir/map-dir-entry.ts
|
|
49638
|
-
import
|
|
49639
|
-
import
|
|
49735
|
+
import path76 from "node:path";
|
|
49736
|
+
import fs50 from "node:fs";
|
|
49640
49737
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
49641
|
-
const entryPath =
|
|
49642
|
-
const fullPath =
|
|
49738
|
+
const entryPath = path76.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
49739
|
+
const fullPath = path76.join(resolved, d.name);
|
|
49643
49740
|
let isDir = d.isDirectory();
|
|
49644
49741
|
if (d.isSymbolicLink()) {
|
|
49645
49742
|
try {
|
|
49646
|
-
const targetStat = await
|
|
49743
|
+
const targetStat = await fs50.promises.stat(fullPath);
|
|
49647
49744
|
isDir = targetStat.isDirectory();
|
|
49648
49745
|
} catch {
|
|
49649
49746
|
isDir = false;
|
|
@@ -49673,7 +49770,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49673
49770
|
return { error: "Path is outside working directory" };
|
|
49674
49771
|
}
|
|
49675
49772
|
try {
|
|
49676
|
-
const names = await
|
|
49773
|
+
const names = await fs51.promises.readdir(resolved, { withFileTypes: true });
|
|
49677
49774
|
const entries = [];
|
|
49678
49775
|
for (let i = 0; i < names.length; i++) {
|
|
49679
49776
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -49689,13 +49786,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49689
49786
|
}
|
|
49690
49787
|
|
|
49691
49788
|
// src/git/tree/resolve-repo-abs-path.ts
|
|
49692
|
-
import * as
|
|
49789
|
+
import * as path77 from "node:path";
|
|
49693
49790
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
49694
|
-
const bridgeResolved =
|
|
49791
|
+
const bridgeResolved = path77.resolve(bridgeRoot);
|
|
49695
49792
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
49696
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
49697
|
-
const resolved =
|
|
49698
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
49793
|
+
const repoPath = rel === "" ? bridgeResolved : path77.join(bridgeResolved, rel);
|
|
49794
|
+
const resolved = path77.resolve(repoPath);
|
|
49795
|
+
if (!resolved.startsWith(bridgeResolved + path77.sep) && resolved !== bridgeResolved) {
|
|
49699
49796
|
return null;
|
|
49700
49797
|
}
|
|
49701
49798
|
return resolved;
|
|
@@ -50176,25 +50273,25 @@ async function GET2(ctx) {
|
|
|
50176
50273
|
init_in_flight();
|
|
50177
50274
|
|
|
50178
50275
|
// src/files/read/read-file-async.ts
|
|
50179
|
-
import
|
|
50276
|
+
import fs57 from "node:fs";
|
|
50180
50277
|
init_yield_to_event_loop();
|
|
50181
50278
|
|
|
50182
50279
|
// src/files/read/resolve-file-cache.ts
|
|
50183
|
-
import
|
|
50184
|
-
import
|
|
50280
|
+
import fs52 from "node:fs";
|
|
50281
|
+
import path78 from "node:path";
|
|
50185
50282
|
var RESOLVE_CACHE_MAX = 4096;
|
|
50186
50283
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
50187
50284
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
50188
50285
|
return `${sessionParentPath}\0${relativePath}`;
|
|
50189
50286
|
}
|
|
50190
50287
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
50191
|
-
const parent =
|
|
50192
|
-
const resolved =
|
|
50193
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
50288
|
+
const parent = path78.resolve(sessionParentPath);
|
|
50289
|
+
const resolved = path78.resolve(filePath);
|
|
50290
|
+
return resolved === parent || resolved.startsWith(`${parent}${path78.sep}`);
|
|
50194
50291
|
}
|
|
50195
50292
|
function statMatchesCacheSync(entry) {
|
|
50196
50293
|
try {
|
|
50197
|
-
const stat3 =
|
|
50294
|
+
const stat3 = fs52.statSync(entry.path);
|
|
50198
50295
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
50199
50296
|
} catch {
|
|
50200
50297
|
return false;
|
|
@@ -50227,7 +50324,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
50227
50324
|
}
|
|
50228
50325
|
|
|
50229
50326
|
// src/files/read/resolve-file-for-read-core.ts
|
|
50230
|
-
import
|
|
50327
|
+
import fs53 from "node:fs";
|
|
50231
50328
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
50232
50329
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
50233
50330
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -50237,13 +50334,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
50237
50334
|
let size;
|
|
50238
50335
|
let mtimeMs;
|
|
50239
50336
|
try {
|
|
50240
|
-
const lstat =
|
|
50337
|
+
const lstat = fs53.lstatSync(resolved);
|
|
50241
50338
|
if (lstat.isSymbolicLink()) {
|
|
50242
|
-
real =
|
|
50339
|
+
real = fs53.realpathSync(resolved);
|
|
50243
50340
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50244
50341
|
return { error: "Path is outside working directory" };
|
|
50245
50342
|
}
|
|
50246
|
-
const stat3 =
|
|
50343
|
+
const stat3 = fs53.statSync(real);
|
|
50247
50344
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50248
50345
|
size = stat3.size;
|
|
50249
50346
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50271,13 +50368,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
50271
50368
|
let size;
|
|
50272
50369
|
let mtimeMs;
|
|
50273
50370
|
try {
|
|
50274
|
-
const lstat = await
|
|
50371
|
+
const lstat = await fs53.promises.lstat(resolved);
|
|
50275
50372
|
if (lstat.isSymbolicLink()) {
|
|
50276
|
-
real = await
|
|
50373
|
+
real = await fs53.promises.realpath(resolved);
|
|
50277
50374
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50278
50375
|
return { error: "Path is outside working directory" };
|
|
50279
50376
|
}
|
|
50280
|
-
const stat3 = await
|
|
50377
|
+
const stat3 = await fs53.promises.stat(real);
|
|
50281
50378
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50282
50379
|
size = stat3.size;
|
|
50283
50380
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50326,7 +50423,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
50326
50423
|
|
|
50327
50424
|
// src/files/read/read-file-range-async.ts
|
|
50328
50425
|
init_yield_to_event_loop();
|
|
50329
|
-
import
|
|
50426
|
+
import fs54 from "node:fs";
|
|
50330
50427
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
50331
50428
|
|
|
50332
50429
|
// src/files/read/read-file-range-line-zero.ts
|
|
@@ -50440,8 +50537,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
50440
50537
|
|
|
50441
50538
|
// src/files/read/read-file-range-async.ts
|
|
50442
50539
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
50443
|
-
const fileSize = fileSizeIn ?? (await
|
|
50444
|
-
const fd = await
|
|
50540
|
+
const fileSize = fileSizeIn ?? (await fs54.promises.stat(filePath)).size;
|
|
50541
|
+
const fd = await fs54.promises.open(filePath, "r");
|
|
50445
50542
|
const bufSize = 64 * 1024;
|
|
50446
50543
|
const buf = Buffer.alloc(bufSize);
|
|
50447
50544
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -50542,7 +50639,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
50542
50639
|
}
|
|
50543
50640
|
|
|
50544
50641
|
// src/files/read/read-small-file-range-async.ts
|
|
50545
|
-
import
|
|
50642
|
+
import fs55 from "node:fs";
|
|
50546
50643
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
50547
50644
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
50548
50645
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -50572,7 +50669,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
50572
50669
|
};
|
|
50573
50670
|
}
|
|
50574
50671
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
50575
|
-
const raw =
|
|
50672
|
+
const raw = fs55.readFileSync(filePath, "utf8");
|
|
50576
50673
|
const lines = raw.split(/\r?\n/);
|
|
50577
50674
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50578
50675
|
}
|
|
@@ -50580,28 +50677,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
50580
50677
|
if (isMainThread5) {
|
|
50581
50678
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
50582
50679
|
}
|
|
50583
|
-
const raw = await
|
|
50680
|
+
const raw = await fs55.promises.readFile(filePath, "utf8");
|
|
50584
50681
|
const lines = raw.split(/\r?\n/);
|
|
50585
50682
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50586
50683
|
}
|
|
50587
50684
|
|
|
50588
50685
|
// src/files/read/read-file-buffer-full-async.ts
|
|
50589
50686
|
init_yield_to_event_loop();
|
|
50590
|
-
import
|
|
50687
|
+
import fs56 from "node:fs";
|
|
50591
50688
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
50592
50689
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
50593
50690
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
50594
50691
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
50595
50692
|
if (isMainThread6) {
|
|
50596
|
-
const size2 = knownSize ??
|
|
50693
|
+
const size2 = knownSize ?? fs56.statSync(filePath).size;
|
|
50597
50694
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
50598
50695
|
await yieldToEventLoop();
|
|
50599
|
-
const buffer =
|
|
50696
|
+
const buffer = fs56.readFileSync(filePath);
|
|
50600
50697
|
return { buffer, size: buffer.length };
|
|
50601
50698
|
}
|
|
50602
50699
|
}
|
|
50603
|
-
const size = knownSize ?? (await
|
|
50604
|
-
const fd = await
|
|
50700
|
+
const size = knownSize ?? (await fs56.promises.stat(filePath)).size;
|
|
50701
|
+
const fd = await fs56.promises.open(filePath, "r");
|
|
50605
50702
|
const chunks = [];
|
|
50606
50703
|
let position = 0;
|
|
50607
50704
|
let bytesSinceYield = 0;
|
|
@@ -50704,7 +50801,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
50704
50801
|
}
|
|
50705
50802
|
if (hasRange) {
|
|
50706
50803
|
if (fileSize == null) {
|
|
50707
|
-
const stat3 = await
|
|
50804
|
+
const stat3 = await fs57.promises.stat(resolvedPath);
|
|
50708
50805
|
fileSize = stat3.size;
|
|
50709
50806
|
}
|
|
50710
50807
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -51002,12 +51099,12 @@ function parseOptionalInt2(raw) {
|
|
|
51002
51099
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
51003
51100
|
}
|
|
51004
51101
|
function parseCodeNavParams(url2) {
|
|
51005
|
-
const
|
|
51102
|
+
const path84 = url2.searchParams.get("path") ?? "";
|
|
51006
51103
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
51007
51104
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
51008
51105
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
51009
51106
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
51010
|
-
return { path:
|
|
51107
|
+
return { path: path84, op, line, column };
|
|
51011
51108
|
}
|
|
51012
51109
|
function parseCodeNavPath(url2) {
|
|
51013
51110
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -51195,12 +51292,6 @@ function listenOnPort(server, port) {
|
|
|
51195
51292
|
});
|
|
51196
51293
|
});
|
|
51197
51294
|
}
|
|
51198
|
-
function closeServer(server) {
|
|
51199
|
-
if (!server) return Promise.resolve();
|
|
51200
|
-
return new Promise((resolve37, reject) => {
|
|
51201
|
-
server.close((err) => err ? reject(err) : resolve37());
|
|
51202
|
-
});
|
|
51203
|
-
}
|
|
51204
51295
|
function delay3(ms) {
|
|
51205
51296
|
return new Promise((resolve37) => setTimeout(resolve37, ms));
|
|
51206
51297
|
}
|
|
@@ -51225,8 +51316,7 @@ function startLocalShortcutServer(ctx) {
|
|
|
51225
51316
|
if (restartAttempts >= MAX_RESTART_ATTEMPTS) return;
|
|
51226
51317
|
restartAttempts += 1;
|
|
51227
51318
|
restarting = (async () => {
|
|
51228
|
-
await
|
|
51229
|
-
});
|
|
51319
|
+
await closeHttpServer(currentServer);
|
|
51230
51320
|
currentServer = null;
|
|
51231
51321
|
if (closed) return;
|
|
51232
51322
|
await delay3(RESTART_DELAY_MS);
|
|
@@ -51246,7 +51336,7 @@ function startLocalShortcutServer(ctx) {
|
|
|
51246
51336
|
token: ctx.token,
|
|
51247
51337
|
close: async () => {
|
|
51248
51338
|
closed = true;
|
|
51249
|
-
await
|
|
51339
|
+
await closeHttpServer(currentServer);
|
|
51250
51340
|
currentServer = null;
|
|
51251
51341
|
}
|
|
51252
51342
|
}));
|
|
@@ -51623,15 +51713,15 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
|
51623
51713
|
}
|
|
51624
51714
|
|
|
51625
51715
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
51626
|
-
import
|
|
51716
|
+
import fs59 from "node:fs";
|
|
51627
51717
|
|
|
51628
51718
|
// src/git/snapshot/capture.ts
|
|
51629
|
-
import * as
|
|
51630
|
-
import * as
|
|
51719
|
+
import * as fs58 from "node:fs";
|
|
51720
|
+
import * as path79 from "node:path";
|
|
51631
51721
|
async function resolveSnapshotRepoRoots(options) {
|
|
51632
51722
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
51633
51723
|
if (worktreePaths?.length) {
|
|
51634
|
-
const uniq = [...new Set(worktreePaths.map((p) =>
|
|
51724
|
+
const uniq = [...new Set(worktreePaths.map((p) => path79.resolve(p)))];
|
|
51635
51725
|
return uniq;
|
|
51636
51726
|
}
|
|
51637
51727
|
try {
|
|
@@ -51639,7 +51729,7 @@ async function resolveSnapshotRepoRoots(options) {
|
|
|
51639
51729
|
const mapped = repos.map((r) => r.absolutePath);
|
|
51640
51730
|
const sid = sessionId?.trim();
|
|
51641
51731
|
if (sid) {
|
|
51642
|
-
const filtered = mapped.filter((root) =>
|
|
51732
|
+
const filtered = mapped.filter((root) => path79.basename(root) === sid);
|
|
51643
51733
|
if (filtered.length > 0) return filtered;
|
|
51644
51734
|
}
|
|
51645
51735
|
return mapped;
|
|
@@ -51661,7 +51751,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51661
51751
|
});
|
|
51662
51752
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
51663
51753
|
try {
|
|
51664
|
-
|
|
51754
|
+
fs58.mkdirSync(dir, { recursive: true });
|
|
51665
51755
|
} catch (e) {
|
|
51666
51756
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51667
51757
|
}
|
|
@@ -51670,9 +51760,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51670
51760
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51671
51761
|
repos
|
|
51672
51762
|
};
|
|
51673
|
-
const filePath =
|
|
51763
|
+
const filePath = path79.join(dir, `${runId}.json`);
|
|
51674
51764
|
try {
|
|
51675
|
-
|
|
51765
|
+
fs58.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
51676
51766
|
} catch (e) {
|
|
51677
51767
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51678
51768
|
}
|
|
@@ -51685,7 +51775,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51685
51775
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
51686
51776
|
let data;
|
|
51687
51777
|
try {
|
|
51688
|
-
const raw =
|
|
51778
|
+
const raw = fs58.readFileSync(filePath, "utf8");
|
|
51689
51779
|
data = JSON.parse(raw);
|
|
51690
51780
|
} catch (e) {
|
|
51691
51781
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
@@ -51725,7 +51815,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51725
51815
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
51726
51816
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
51727
51817
|
try {
|
|
51728
|
-
await
|
|
51818
|
+
await fs59.promises.access(file2, fs59.constants.F_OK);
|
|
51729
51819
|
} catch {
|
|
51730
51820
|
deps.log(
|
|
51731
51821
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -52133,8 +52223,8 @@ function randomSecret() {
|
|
|
52133
52223
|
}
|
|
52134
52224
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
52135
52225
|
}
|
|
52136
|
-
async function requestPreviewApi(port, secret, method,
|
|
52137
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
52226
|
+
async function requestPreviewApi(port, secret, method, path84, body) {
|
|
52227
|
+
const url2 = `http://127.0.0.1:${port}${path84}`;
|
|
52138
52228
|
const headers = {
|
|
52139
52229
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
52140
52230
|
"Content-Type": "application/json"
|
|
@@ -52146,7 +52236,7 @@ async function requestPreviewApi(port, secret, method, path82, body) {
|
|
|
52146
52236
|
});
|
|
52147
52237
|
const data = await res.json().catch(() => ({}));
|
|
52148
52238
|
if (!res.ok) {
|
|
52149
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
52239
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path84}: ${res.status}`);
|
|
52150
52240
|
}
|
|
52151
52241
|
return data;
|
|
52152
52242
|
}
|
|
@@ -52371,13 +52461,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
52371
52461
|
|
|
52372
52462
|
// src/files/handle-file-browser-search.ts
|
|
52373
52463
|
init_yield_to_event_loop();
|
|
52374
|
-
import
|
|
52464
|
+
import path80 from "node:path";
|
|
52375
52465
|
var SEARCH_LIMIT = 100;
|
|
52376
52466
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
52377
52467
|
void (async () => {
|
|
52378
52468
|
await yieldToEventLoop();
|
|
52379
52469
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
52380
|
-
const sessionParentPath =
|
|
52470
|
+
const sessionParentPath = path80.resolve(
|
|
52381
52471
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
52382
52472
|
);
|
|
52383
52473
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -52495,8 +52585,8 @@ function isValidRemoteSkillInstallItem(item) {
|
|
|
52495
52585
|
|
|
52496
52586
|
// src/skills/install/install-remote-skills-async.ts
|
|
52497
52587
|
init_yield_to_event_loop();
|
|
52498
|
-
import
|
|
52499
|
-
import
|
|
52588
|
+
import fs60 from "node:fs";
|
|
52589
|
+
import path81 from "node:path";
|
|
52500
52590
|
|
|
52501
52591
|
// src/skills/install/constants.ts
|
|
52502
52592
|
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
@@ -52507,12 +52597,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
|
52507
52597
|
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
52508
52598
|
await yieldToEventLoop();
|
|
52509
52599
|
}
|
|
52510
|
-
const dest =
|
|
52511
|
-
await
|
|
52600
|
+
const dest = path81.join(skillDir, f.path);
|
|
52601
|
+
await fs60.promises.mkdir(path81.dirname(dest), { recursive: true });
|
|
52512
52602
|
if (f.text !== void 0) {
|
|
52513
|
-
await
|
|
52603
|
+
await fs60.promises.writeFile(dest, f.text, "utf8");
|
|
52514
52604
|
} else if (f.base64) {
|
|
52515
|
-
await
|
|
52605
|
+
await fs60.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
|
|
52516
52606
|
}
|
|
52517
52607
|
}
|
|
52518
52608
|
async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
@@ -52524,7 +52614,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
|
52524
52614
|
try {
|
|
52525
52615
|
for (const item of items) {
|
|
52526
52616
|
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
52527
|
-
const skillDir =
|
|
52617
|
+
const skillDir = path81.join(cwd, targetDir, item.skillName);
|
|
52528
52618
|
for (const f of item.files) {
|
|
52529
52619
|
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
52530
52620
|
}
|
|
@@ -52806,7 +52896,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
52806
52896
|
};
|
|
52807
52897
|
|
|
52808
52898
|
// src/routing/handlers/revert-turn-snapshot.ts
|
|
52809
|
-
import * as
|
|
52899
|
+
import * as fs61 from "node:fs";
|
|
52810
52900
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
52811
52901
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
52812
52902
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -52819,7 +52909,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
52819
52909
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
52820
52910
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
52821
52911
|
try {
|
|
52822
|
-
await
|
|
52912
|
+
await fs61.promises.access(file2, fs61.constants.F_OK);
|
|
52823
52913
|
} catch {
|
|
52824
52914
|
sendWsMessage(s, {
|
|
52825
52915
|
type: "revert_turn_snapshot_result",
|
|
@@ -52904,7 +52994,7 @@ var handleDeploySessionToPreviewMessage = (msg, deps) => {
|
|
|
52904
52994
|
};
|
|
52905
52995
|
|
|
52906
52996
|
// src/git/bridge-git-context.ts
|
|
52907
|
-
import * as
|
|
52997
|
+
import * as path82 from "node:path";
|
|
52908
52998
|
init_yield_to_event_loop();
|
|
52909
52999
|
|
|
52910
53000
|
// src/git/branches/get-current-branch.ts
|
|
@@ -52955,12 +53045,12 @@ async function listRepoBranchRefs(repoPath) {
|
|
|
52955
53045
|
// src/git/bridge-git-context.ts
|
|
52956
53046
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
52957
53047
|
if (relPath === "." || relPath === "") {
|
|
52958
|
-
return
|
|
53048
|
+
return path82.basename(path82.resolve(bridgeRoot)) || "repo";
|
|
52959
53049
|
}
|
|
52960
|
-
return
|
|
53050
|
+
return path82.basename(relPath) || relPath;
|
|
52961
53051
|
}
|
|
52962
53052
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
52963
|
-
const root =
|
|
53053
|
+
const root = path82.resolve(bridgeRoot);
|
|
52964
53054
|
if (await isGitRepoDirectory(root)) {
|
|
52965
53055
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
52966
53056
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -52968,19 +53058,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
52968
53058
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
52969
53059
|
const byPath = /* @__PURE__ */ new Map();
|
|
52970
53060
|
for (const repo of [...deep, ...shallow]) {
|
|
52971
|
-
byPath.set(
|
|
53061
|
+
byPath.set(path82.resolve(repo.absolutePath), repo);
|
|
52972
53062
|
}
|
|
52973
53063
|
return [...byPath.values()];
|
|
52974
53064
|
}
|
|
52975
53065
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
52976
|
-
const bridgeResolved =
|
|
53066
|
+
const bridgeResolved = path82.resolve(bridgeRoot);
|
|
52977
53067
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
52978
53068
|
const rows = [];
|
|
52979
53069
|
for (let i = 0; i < repos.length; i++) {
|
|
52980
53070
|
if (i > 0) await yieldToEventLoop();
|
|
52981
53071
|
const repo = repos[i];
|
|
52982
|
-
let rel =
|
|
52983
|
-
if (rel.startsWith("..") ||
|
|
53072
|
+
let rel = path82.relative(bridgeResolved, repo.absolutePath);
|
|
53073
|
+
if (rel.startsWith("..") || path82.isAbsolute(rel)) continue;
|
|
52984
53074
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
52985
53075
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
52986
53076
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -52995,11 +53085,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
52995
53085
|
return rows;
|
|
52996
53086
|
}
|
|
52997
53087
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
52998
|
-
const bridgeResolved =
|
|
53088
|
+
const bridgeResolved = path82.resolve(bridgeRoot);
|
|
52999
53089
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
53000
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
53001
|
-
const resolved =
|
|
53002
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
53090
|
+
const repoPath = rel === "" ? bridgeResolved : path82.join(bridgeResolved, rel);
|
|
53091
|
+
const resolved = path82.resolve(repoPath);
|
|
53092
|
+
if (!resolved.startsWith(bridgeResolved + path82.sep) && resolved !== bridgeResolved) {
|
|
53003
53093
|
return [];
|
|
53004
53094
|
}
|
|
53005
53095
|
return listRepoBranchRefs(resolved);
|
|
@@ -53515,15 +53605,18 @@ async function runConnectedBridge(options, restartWithoutAuth) {
|
|
|
53515
53605
|
const firehoseServerUrl = options.firehoseServerUrl ?? options.proxyServerUrl;
|
|
53516
53606
|
let cleanupKeyCommand;
|
|
53517
53607
|
let bridgeClose = null;
|
|
53608
|
+
let shutdownStarted = false;
|
|
53518
53609
|
const onSignal = (kind) => {
|
|
53519
53610
|
requestCliImmediateShutdown();
|
|
53520
53611
|
abortActiveGitChildProcesses();
|
|
53521
53612
|
cleanupKeyCommand?.();
|
|
53613
|
+
if (shutdownStarted) return;
|
|
53614
|
+
shutdownStarted = true;
|
|
53522
53615
|
logImmediate(
|
|
53523
53616
|
kind === "interrupt" ? "Keyboard interrupt (Ctrl+C) \u2014 stopping\u2026" : "Stop requested \u2014 shutting down\u2026"
|
|
53524
53617
|
);
|
|
53525
53618
|
if (bridgeClose) {
|
|
53526
|
-
void bridgeClose().
|
|
53619
|
+
void bridgeClose().finally(() => process.exit(0));
|
|
53527
53620
|
return;
|
|
53528
53621
|
}
|
|
53529
53622
|
process.exit(0);
|
|
@@ -53674,9 +53767,9 @@ async function runCliAction(program2, opts) {
|
|
|
53674
53767
|
const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
|
|
53675
53768
|
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);
|
|
53676
53769
|
if (bridgeRootOpt) {
|
|
53677
|
-
const resolvedBridgeRoot =
|
|
53770
|
+
const resolvedBridgeRoot = path83.resolve(process.cwd(), bridgeRootOpt);
|
|
53678
53771
|
try {
|
|
53679
|
-
const st =
|
|
53772
|
+
const st = fs62.statSync(resolvedBridgeRoot);
|
|
53680
53773
|
if (!st.isDirectory()) {
|
|
53681
53774
|
console.error(`Bridge root is not a directory: ${resolvedBridgeRoot}`);
|
|
53682
53775
|
process.exit(1);
|
|
@@ -53696,7 +53789,7 @@ async function runCliAction(program2, opts) {
|
|
|
53696
53789
|
);
|
|
53697
53790
|
let worktreesRootPath;
|
|
53698
53791
|
if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
|
|
53699
|
-
worktreesRootPath =
|
|
53792
|
+
worktreesRootPath = path83.resolve(opts.worktreesRoot.trim());
|
|
53700
53793
|
}
|
|
53701
53794
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
53702
53795
|
if (e2eCertificates) {
|