@buildautomaton/cli 0.1.73 → 0.1.75
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 +588 -503
- package/dist/cli.js.map +4 -4
- package/dist/index.js +567 -482
- 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 path86 = __require("node:path");
|
|
977
|
+
var fs65 = __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 = path86.resolve(baseDir, baseName);
|
|
1910
|
+
if (fs65.existsSync(localBin)) return localBin;
|
|
1911
|
+
if (sourceExt.includes(path86.extname(baseName))) return void 0;
|
|
1912
1912
|
const foundExt = sourceExt.find(
|
|
1913
|
-
(ext) =>
|
|
1913
|
+
(ext) => fs65.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 = fs65.realpathSync(this._scriptPath);
|
|
1926
1926
|
} catch (err) {
|
|
1927
1927
|
resolvedScriptPath = this._scriptPath;
|
|
1928
1928
|
}
|
|
1929
|
-
executableDir =
|
|
1930
|
-
|
|
1929
|
+
executableDir = path86.resolve(
|
|
1930
|
+
path86.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 = path86.basename(
|
|
1938
1938
|
this._scriptPath,
|
|
1939
|
-
|
|
1939
|
+
path86.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(path86.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 = path86.basename(filename, path86.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(path87) {
|
|
2805
|
+
if (path87 === void 0) return this._executableDir;
|
|
2806
|
+
this._executableDir = path87;
|
|
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((path86) => existsSync(path86));
|
|
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(path86, 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(path86);
|
|
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 = (path86, originalPath, doThrow) => {
|
|
8834
|
+
if (!isString(path86)) {
|
|
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 (!path86) {
|
|
8841
8841
|
return doThrow(`path must not be empty`, TypeError);
|
|
8842
8842
|
}
|
|
8843
|
-
if (checkPath.isNotRelative(
|
|
8843
|
+
if (checkPath.isNotRelative(path86)) {
|
|
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 = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
|
|
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 path86 = originalPath && checkPath.convert(originalPath);
|
|
8883
8883
|
checkPath(
|
|
8884
|
-
|
|
8884
|
+
path86,
|
|
8885
8885
|
originalPath,
|
|
8886
8886
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
8887
8887
|
);
|
|
8888
|
-
return this._t(
|
|
8888
|
+
return this._t(path86, cache2, checkUnignored, slices);
|
|
8889
8889
|
}
|
|
8890
|
-
checkIgnore(
|
|
8891
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
8892
|
-
return this.test(
|
|
8890
|
+
checkIgnore(path86) {
|
|
8891
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
|
|
8892
|
+
return this.test(path86);
|
|
8893
8893
|
}
|
|
8894
|
-
const slices =
|
|
8894
|
+
const slices = path86.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(path86, false, MODE_CHECK_IGNORE);
|
|
8908
8908
|
}
|
|
8909
|
-
_t(
|
|
8910
|
-
if (
|
|
8911
|
-
return cache2[
|
|
8909
|
+
_t(path86, cache2, checkUnignored, slices) {
|
|
8910
|
+
if (path86 in cache2) {
|
|
8911
|
+
return cache2[path86];
|
|
8912
8912
|
}
|
|
8913
8913
|
if (!slices) {
|
|
8914
|
-
slices =
|
|
8914
|
+
slices = path86.split(SLASH).filter(Boolean);
|
|
8915
8915
|
}
|
|
8916
8916
|
slices.pop();
|
|
8917
8917
|
if (!slices.length) {
|
|
8918
|
-
return cache2[
|
|
8918
|
+
return cache2[path86] = this._rules.test(path86, 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[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
8927
8927
|
}
|
|
8928
|
-
ignores(
|
|
8929
|
-
return this._test(
|
|
8928
|
+
ignores(path86) {
|
|
8929
|
+
return this._test(path86, this._ignoreCache, false).ignored;
|
|
8930
8930
|
}
|
|
8931
8931
|
createFilter() {
|
|
8932
|
-
return (
|
|
8932
|
+
return (path86) => !this.ignores(path86);
|
|
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(path86) {
|
|
8939
|
+
return this._test(path86, this._testCache, true);
|
|
8940
8940
|
}
|
|
8941
8941
|
};
|
|
8942
8942
|
var factory = (options) => new Ignore(options);
|
|
8943
|
-
var isPathValid = (
|
|
8943
|
+
var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, 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 = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
|
|
8949
8949
|
};
|
|
8950
8950
|
if (
|
|
8951
8951
|
// Detect `process` so that it can run in browsers.
|
|
@@ -11850,8 +11850,8 @@ var init_task_queue_types = __esm({
|
|
|
11850
11850
|
});
|
|
11851
11851
|
|
|
11852
11852
|
// src/code-nav/symbol-index/scheduler/task-queue-store.ts
|
|
11853
|
-
function setSymbolIndexWorkerRunning(
|
|
11854
|
-
symbolIndexWorkerRunning =
|
|
11853
|
+
function setSymbolIndexWorkerRunning(running2) {
|
|
11854
|
+
symbolIndexWorkerRunning = running2;
|
|
11855
11855
|
}
|
|
11856
11856
|
function taskMatchesCurrentPending(task) {
|
|
11857
11857
|
const current = pendingSymbolIndexTasks.get(symbolIndexTaskKey(task.parentPath, task.filePath));
|
|
@@ -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: path86, errorMaps, issueData } = params;
|
|
12955
|
+
const fullPath = [...path86, ...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, path86, key) {
|
|
13264
13264
|
this._cachedPath = [];
|
|
13265
13265
|
this.parent = parent;
|
|
13266
13266
|
this.data = value;
|
|
13267
|
-
this._path =
|
|
13267
|
+
this._path = path86;
|
|
13268
13268
|
this._key = key;
|
|
13269
13269
|
}
|
|
13270
13270
|
get path() {
|
|
@@ -16989,15 +16989,15 @@ function assignProp(target, prop, value) {
|
|
|
16989
16989
|
configurable: true
|
|
16990
16990
|
});
|
|
16991
16991
|
}
|
|
16992
|
-
function getElementAtPath(obj,
|
|
16993
|
-
if (!
|
|
16992
|
+
function getElementAtPath(obj, path86) {
|
|
16993
|
+
if (!path86)
|
|
16994
16994
|
return obj;
|
|
16995
|
-
return
|
|
16995
|
+
return path86.reduce((acc, key) => acc?.[key], obj);
|
|
16996
16996
|
}
|
|
16997
16997
|
function promiseAllObject(promisesObj) {
|
|
16998
16998
|
const keys = Object.keys(promisesObj);
|
|
16999
|
-
const
|
|
17000
|
-
return Promise.all(
|
|
16999
|
+
const promises13 = keys.map((key) => promisesObj[key]);
|
|
17000
|
+
return Promise.all(promises13).then((results) => {
|
|
17001
17001
|
const resolvedObj = {};
|
|
17002
17002
|
for (let i = 0; i < keys.length; i++) {
|
|
17003
17003
|
resolvedObj[keys[i]] = results[i];
|
|
@@ -17241,11 +17241,11 @@ function aborted(x, startIndex = 0) {
|
|
|
17241
17241
|
}
|
|
17242
17242
|
return false;
|
|
17243
17243
|
}
|
|
17244
|
-
function prefixIssues(
|
|
17244
|
+
function prefixIssues(path86, 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(path86);
|
|
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, path86 = []) => {
|
|
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 = [...path86, ...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(path86) {
|
|
17478
17478
|
const segs = [];
|
|
17479
|
-
for (const seg of
|
|
17479
|
+
for (const seg of path86) {
|
|
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(path86, isFile, isDirectory) {
|
|
30963
|
+
log2(`checking %s`, path86);
|
|
30964
30964
|
try {
|
|
30965
|
-
const stat3 = fs_1.statSync(
|
|
30965
|
+
const stat3 = fs_1.statSync(path86);
|
|
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(path86, type = exports.READABLE) {
|
|
30986
|
+
return check2(path86, (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.75".length > 0 ? "0.1.75" : "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 fs64 from "node:fs";
|
|
31076
|
+
import * as path85 from "node:path";
|
|
31077
31077
|
|
|
31078
31078
|
// src/config.ts
|
|
31079
31079
|
import fs from "node:fs";
|
|
@@ -37505,6 +37505,7 @@ function extractSessionUpdateMessageText(params) {
|
|
|
37505
37505
|
}
|
|
37506
37506
|
|
|
37507
37507
|
// src/agents/planning/planning-session-turn-buffer.ts
|
|
37508
|
+
var MAX_PLANNING_BUFFER_CHARS = 512 * 1024;
|
|
37508
37509
|
var buffersByRunId = /* @__PURE__ */ new Map();
|
|
37509
37510
|
function registerPlanningSessionTurn(runId) {
|
|
37510
37511
|
buffersByRunId.set(runId, { messageBuffer: "" });
|
|
@@ -37522,7 +37523,10 @@ function capturePlanningSessionUpdate(params) {
|
|
|
37522
37523
|
});
|
|
37523
37524
|
if (bucket !== "message") return false;
|
|
37524
37525
|
const text = extractSessionUpdateMessageText(params.payload);
|
|
37525
|
-
if (text
|
|
37526
|
+
if (text && state.messageBuffer.length < MAX_PLANNING_BUFFER_CHARS) {
|
|
37527
|
+
const room = MAX_PLANNING_BUFFER_CHARS - state.messageBuffer.length;
|
|
37528
|
+
state.messageBuffer += room >= text.length ? text : text.slice(0, room);
|
|
37529
|
+
}
|
|
37526
37530
|
return true;
|
|
37527
37531
|
}
|
|
37528
37532
|
function getPlanningSessionTurnOutput(runId) {
|
|
@@ -38061,8 +38065,8 @@ async function execGitFile(args, options) {
|
|
|
38061
38065
|
}
|
|
38062
38066
|
|
|
38063
38067
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
38064
|
-
function normalizeGitDiffPath(
|
|
38065
|
-
return
|
|
38068
|
+
function normalizeGitDiffPath(path86) {
|
|
38069
|
+
return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
38066
38070
|
}
|
|
38067
38071
|
|
|
38068
38072
|
// src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -39416,11 +39420,30 @@ function closeHttpServer(server) {
|
|
|
39416
39420
|
}
|
|
39417
39421
|
|
|
39418
39422
|
// src/mcp/bridge-access/read-json-body.ts
|
|
39423
|
+
var MAX_JSON_BODY_BYTES = 1024 * 1024;
|
|
39424
|
+
var RequestBodyTooLargeError = class extends Error {
|
|
39425
|
+
constructor() {
|
|
39426
|
+
super(`Request body exceeds ${MAX_JSON_BODY_BYTES} bytes`);
|
|
39427
|
+
}
|
|
39428
|
+
};
|
|
39419
39429
|
function readJsonBody(req) {
|
|
39420
39430
|
return new Promise((resolve37, reject) => {
|
|
39421
39431
|
const chunks = [];
|
|
39422
|
-
|
|
39432
|
+
let total = 0;
|
|
39433
|
+
let tooLarge = false;
|
|
39434
|
+
req.on("data", (chunk) => {
|
|
39435
|
+
if (tooLarge) return;
|
|
39436
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
39437
|
+
total += buf.length;
|
|
39438
|
+
if (total > MAX_JSON_BODY_BYTES) {
|
|
39439
|
+
tooLarge = true;
|
|
39440
|
+
reject(new RequestBodyTooLargeError());
|
|
39441
|
+
return;
|
|
39442
|
+
}
|
|
39443
|
+
chunks.push(buf);
|
|
39444
|
+
});
|
|
39423
39445
|
req.on("end", () => {
|
|
39446
|
+
if (tooLarge) return;
|
|
39424
39447
|
try {
|
|
39425
39448
|
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
39426
39449
|
if (!raw) {
|
|
@@ -39477,7 +39500,7 @@ function createBridgeAccessRequestHandler(registry2) {
|
|
|
39477
39500
|
sendJsonResponse(res, 404, { ok: false, error: "Not found" });
|
|
39478
39501
|
} catch (err) {
|
|
39479
39502
|
const message = err instanceof Error ? err.message : String(err);
|
|
39480
|
-
sendJsonResponse(res, 500, { ok: false, error: message });
|
|
39503
|
+
sendJsonResponse(res, err instanceof RequestBodyTooLargeError ? 413 : 500, { ok: false, error: message });
|
|
39481
39504
|
}
|
|
39482
39505
|
})();
|
|
39483
39506
|
};
|
|
@@ -42337,8 +42360,8 @@ function pathspec(...paths) {
|
|
|
42337
42360
|
cache.set(key, paths);
|
|
42338
42361
|
return key;
|
|
42339
42362
|
}
|
|
42340
|
-
function isPathSpec(
|
|
42341
|
-
return
|
|
42363
|
+
function isPathSpec(path86) {
|
|
42364
|
+
return path86 instanceof String && cache.has(path86);
|
|
42342
42365
|
}
|
|
42343
42366
|
function toPaths(pathSpec) {
|
|
42344
42367
|
return cache.get(pathSpec) || [];
|
|
@@ -42427,8 +42450,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
42427
42450
|
function forEachLineWithContent(input, callback) {
|
|
42428
42451
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
42429
42452
|
}
|
|
42430
|
-
function folderExists(
|
|
42431
|
-
return (0, import_file_exists.exists)(
|
|
42453
|
+
function folderExists(path86) {
|
|
42454
|
+
return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
|
|
42432
42455
|
}
|
|
42433
42456
|
function append(target, item) {
|
|
42434
42457
|
if (Array.isArray(target)) {
|
|
@@ -42832,8 +42855,8 @@ function checkIsRepoRootTask() {
|
|
|
42832
42855
|
commands,
|
|
42833
42856
|
format: "utf-8",
|
|
42834
42857
|
onError,
|
|
42835
|
-
parser(
|
|
42836
|
-
return /^\.(git)?$/.test(
|
|
42858
|
+
parser(path86) {
|
|
42859
|
+
return /^\.(git)?$/.test(path86.trim());
|
|
42837
42860
|
}
|
|
42838
42861
|
};
|
|
42839
42862
|
}
|
|
@@ -43267,11 +43290,11 @@ function parseGrep(grep) {
|
|
|
43267
43290
|
const paths = /* @__PURE__ */ new Set();
|
|
43268
43291
|
const results = {};
|
|
43269
43292
|
forEachLineWithContent(grep, (input) => {
|
|
43270
|
-
const [
|
|
43271
|
-
paths.add(
|
|
43272
|
-
(results[
|
|
43293
|
+
const [path86, line, preview] = input.split(NULL);
|
|
43294
|
+
paths.add(path86);
|
|
43295
|
+
(results[path86] = results[path86] || []).push({
|
|
43273
43296
|
line: asNumber(line),
|
|
43274
|
-
path:
|
|
43297
|
+
path: path86,
|
|
43275
43298
|
preview
|
|
43276
43299
|
});
|
|
43277
43300
|
});
|
|
@@ -44036,14 +44059,14 @@ var init_hash_object = __esm2({
|
|
|
44036
44059
|
init_task();
|
|
44037
44060
|
}
|
|
44038
44061
|
});
|
|
44039
|
-
function parseInit(bare,
|
|
44062
|
+
function parseInit(bare, path86, text) {
|
|
44040
44063
|
const response = String(text).trim();
|
|
44041
44064
|
let result;
|
|
44042
44065
|
if (result = initResponseRegex.exec(response)) {
|
|
44043
|
-
return new InitSummary(bare,
|
|
44066
|
+
return new InitSummary(bare, path86, false, result[1]);
|
|
44044
44067
|
}
|
|
44045
44068
|
if (result = reInitResponseRegex.exec(response)) {
|
|
44046
|
-
return new InitSummary(bare,
|
|
44069
|
+
return new InitSummary(bare, path86, true, result[1]);
|
|
44047
44070
|
}
|
|
44048
44071
|
let gitDir = "";
|
|
44049
44072
|
const tokens = response.split(" ");
|
|
@@ -44054,7 +44077,7 @@ function parseInit(bare, path84, text) {
|
|
|
44054
44077
|
break;
|
|
44055
44078
|
}
|
|
44056
44079
|
}
|
|
44057
|
-
return new InitSummary(bare,
|
|
44080
|
+
return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
|
|
44058
44081
|
}
|
|
44059
44082
|
var InitSummary;
|
|
44060
44083
|
var initResponseRegex;
|
|
@@ -44063,9 +44086,9 @@ var init_InitSummary = __esm2({
|
|
|
44063
44086
|
"src/lib/responses/InitSummary.ts"() {
|
|
44064
44087
|
"use strict";
|
|
44065
44088
|
InitSummary = class {
|
|
44066
|
-
constructor(bare,
|
|
44089
|
+
constructor(bare, path86, existing, gitDir) {
|
|
44067
44090
|
this.bare = bare;
|
|
44068
|
-
this.path =
|
|
44091
|
+
this.path = path86;
|
|
44069
44092
|
this.existing = existing;
|
|
44070
44093
|
this.gitDir = gitDir;
|
|
44071
44094
|
}
|
|
@@ -44077,7 +44100,7 @@ var init_InitSummary = __esm2({
|
|
|
44077
44100
|
function hasBareCommand(command) {
|
|
44078
44101
|
return command.includes(bareCommand);
|
|
44079
44102
|
}
|
|
44080
|
-
function initTask(bare = false,
|
|
44103
|
+
function initTask(bare = false, path86, customArgs) {
|
|
44081
44104
|
const commands = ["init", ...customArgs];
|
|
44082
44105
|
if (bare && !hasBareCommand(commands)) {
|
|
44083
44106
|
commands.splice(1, 0, bareCommand);
|
|
@@ -44086,7 +44109,7 @@ function initTask(bare = false, path84, customArgs) {
|
|
|
44086
44109
|
commands,
|
|
44087
44110
|
format: "utf-8",
|
|
44088
44111
|
parser(text) {
|
|
44089
|
-
return parseInit(commands.includes("--bare"),
|
|
44112
|
+
return parseInit(commands.includes("--bare"), path86, text);
|
|
44090
44113
|
}
|
|
44091
44114
|
};
|
|
44092
44115
|
}
|
|
@@ -44902,12 +44925,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
44902
44925
|
"use strict";
|
|
44903
44926
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
44904
44927
|
FileStatusSummary = class {
|
|
44905
|
-
constructor(
|
|
44906
|
-
this.path =
|
|
44928
|
+
constructor(path86, index, working_dir) {
|
|
44929
|
+
this.path = path86;
|
|
44907
44930
|
this.index = index;
|
|
44908
44931
|
this.working_dir = working_dir;
|
|
44909
44932
|
if (index === "R" || working_dir === "R") {
|
|
44910
|
-
const detail = fromPathRegex.exec(
|
|
44933
|
+
const detail = fromPathRegex.exec(path86) || [null, path86, path86];
|
|
44911
44934
|
this.from = detail[2] || "";
|
|
44912
44935
|
this.path = detail[1] || "";
|
|
44913
44936
|
}
|
|
@@ -44938,14 +44961,14 @@ function splitLine(result, lineStr) {
|
|
|
44938
44961
|
default:
|
|
44939
44962
|
return;
|
|
44940
44963
|
}
|
|
44941
|
-
function data(index, workingDir,
|
|
44964
|
+
function data(index, workingDir, path86) {
|
|
44942
44965
|
const raw = `${index}${workingDir}`;
|
|
44943
44966
|
const handler = parsers6.get(raw);
|
|
44944
44967
|
if (handler) {
|
|
44945
|
-
handler(result,
|
|
44968
|
+
handler(result, path86);
|
|
44946
44969
|
}
|
|
44947
44970
|
if (raw !== "##" && raw !== "!!") {
|
|
44948
|
-
result.files.push(new FileStatusSummary(
|
|
44971
|
+
result.files.push(new FileStatusSummary(path86, index, workingDir));
|
|
44949
44972
|
}
|
|
44950
44973
|
}
|
|
44951
44974
|
}
|
|
@@ -45254,9 +45277,9 @@ var init_simple_git_api = __esm2({
|
|
|
45254
45277
|
next
|
|
45255
45278
|
);
|
|
45256
45279
|
}
|
|
45257
|
-
hashObject(
|
|
45280
|
+
hashObject(path86, write) {
|
|
45258
45281
|
return this._runTask(
|
|
45259
|
-
hashObjectTask(
|
|
45282
|
+
hashObjectTask(path86, write === true),
|
|
45260
45283
|
trailingFunctionArgument(arguments)
|
|
45261
45284
|
);
|
|
45262
45285
|
}
|
|
@@ -45609,8 +45632,8 @@ var init_branch = __esm2({
|
|
|
45609
45632
|
}
|
|
45610
45633
|
});
|
|
45611
45634
|
function toPath(input) {
|
|
45612
|
-
const
|
|
45613
|
-
return
|
|
45635
|
+
const path86 = input.trim().replace(/^["']|["']$/g, "");
|
|
45636
|
+
return path86 && normalize3(path86);
|
|
45614
45637
|
}
|
|
45615
45638
|
var parseCheckIgnore;
|
|
45616
45639
|
var init_CheckIgnore = __esm2({
|
|
@@ -45924,8 +45947,8 @@ __export2(sub_module_exports, {
|
|
|
45924
45947
|
subModuleTask: () => subModuleTask,
|
|
45925
45948
|
updateSubModuleTask: () => updateSubModuleTask
|
|
45926
45949
|
});
|
|
45927
|
-
function addSubModuleTask(repo,
|
|
45928
|
-
return subModuleTask(["add", repo,
|
|
45950
|
+
function addSubModuleTask(repo, path86) {
|
|
45951
|
+
return subModuleTask(["add", repo, path86]);
|
|
45929
45952
|
}
|
|
45930
45953
|
function initSubModuleTask(customArgs) {
|
|
45931
45954
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -46258,8 +46281,8 @@ var require_git = __commonJS2({
|
|
|
46258
46281
|
}
|
|
46259
46282
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
46260
46283
|
};
|
|
46261
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
46262
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
46284
|
+
Git2.prototype.submoduleAdd = function(repo, path86, then) {
|
|
46285
|
+
return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
|
|
46263
46286
|
};
|
|
46264
46287
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
46265
46288
|
return this._runTask(
|
|
@@ -46998,8 +47021,8 @@ function parseNumstatEntries(lines) {
|
|
|
46998
47021
|
}
|
|
46999
47022
|
function parseNumstat(lines) {
|
|
47000
47023
|
const m = /* @__PURE__ */ new Map();
|
|
47001
|
-
for (const [
|
|
47002
|
-
m.set(
|
|
47024
|
+
for (const [path86, entry] of parseNumstatEntries(lines)) {
|
|
47025
|
+
m.set(path86, { additions: entry.additions, deletions: entry.deletions });
|
|
47003
47026
|
}
|
|
47004
47027
|
return m;
|
|
47005
47028
|
}
|
|
@@ -47282,23 +47305,26 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
47282
47305
|
}
|
|
47283
47306
|
|
|
47284
47307
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
47285
|
-
import * as
|
|
47308
|
+
import * as path53 from "node:path";
|
|
47286
47309
|
|
|
47287
47310
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
47288
|
-
import * as
|
|
47311
|
+
import * as path52 from "node:path";
|
|
47289
47312
|
|
|
47290
47313
|
// src/git/is-git-repo.ts
|
|
47314
|
+
import * as fs33 from "node:fs";
|
|
47315
|
+
import * as path44 from "node:path";
|
|
47291
47316
|
async function isGitRepoDirectory(dirPath) {
|
|
47292
47317
|
try {
|
|
47293
|
-
|
|
47318
|
+
await fs33.promises.access(path44.join(dirPath, ".git"));
|
|
47319
|
+
return true;
|
|
47294
47320
|
} catch {
|
|
47295
47321
|
return false;
|
|
47296
47322
|
}
|
|
47297
47323
|
}
|
|
47298
47324
|
|
|
47299
47325
|
// src/git/changes/listing/apply-untracked-file-stats.ts
|
|
47300
|
-
import * as
|
|
47301
|
-
import * as
|
|
47326
|
+
import * as fs34 from "node:fs";
|
|
47327
|
+
import * as path45 from "node:path";
|
|
47302
47328
|
|
|
47303
47329
|
// src/git/changes/lines/count-lines.ts
|
|
47304
47330
|
import { createReadStream } from "node:fs";
|
|
@@ -47330,7 +47356,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
47330
47356
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
47331
47357
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
47332
47358
|
if (row.change === "moved") return;
|
|
47333
|
-
const repoFilePath =
|
|
47359
|
+
const repoFilePath = path45.join(options.repoGitCwd, pathInRepo);
|
|
47334
47360
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
47335
47361
|
if (fromGit) {
|
|
47336
47362
|
row.additions = fromGit.additions;
|
|
@@ -47338,7 +47364,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
47338
47364
|
return;
|
|
47339
47365
|
}
|
|
47340
47366
|
try {
|
|
47341
|
-
const st = await
|
|
47367
|
+
const st = await fs34.promises.stat(repoFilePath);
|
|
47342
47368
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
47343
47369
|
} catch {
|
|
47344
47370
|
row.additions = 0;
|
|
@@ -47415,7 +47441,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
47415
47441
|
}
|
|
47416
47442
|
|
|
47417
47443
|
// src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
47418
|
-
import * as
|
|
47444
|
+
import * as path47 from "node:path";
|
|
47419
47445
|
|
|
47420
47446
|
// src/git/changes/patch/patch-truncate.ts
|
|
47421
47447
|
function truncatePatch(s) {
|
|
@@ -47503,10 +47529,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
47503
47529
|
}
|
|
47504
47530
|
|
|
47505
47531
|
// src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
47506
|
-
import * as
|
|
47532
|
+
import * as fs35 from "node:fs";
|
|
47507
47533
|
async function readWorktreeFileLines(filePath) {
|
|
47508
47534
|
try {
|
|
47509
|
-
const raw = await
|
|
47535
|
+
const raw = await fs35.promises.readFile(filePath, "utf8");
|
|
47510
47536
|
return raw.split(/\r?\n/);
|
|
47511
47537
|
} catch {
|
|
47512
47538
|
return null;
|
|
@@ -47644,8 +47670,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
47644
47670
|
}
|
|
47645
47671
|
|
|
47646
47672
|
// src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
47647
|
-
import * as
|
|
47648
|
-
import * as
|
|
47673
|
+
import * as fs36 from "node:fs";
|
|
47674
|
+
import * as path46 from "node:path";
|
|
47649
47675
|
var MAX_BYTES = 512e3;
|
|
47650
47676
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
47651
47677
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -47665,13 +47691,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
47665
47691
|
}
|
|
47666
47692
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
47667
47693
|
if (options.isBinary) return null;
|
|
47668
|
-
const filePath =
|
|
47694
|
+
const filePath = path46.join(options.repoGitCwd, options.pathInRepo);
|
|
47669
47695
|
if (options.change === "removed") {
|
|
47670
47696
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
47671
47697
|
}
|
|
47672
47698
|
if (options.change === "moved" || options.change === "modified") {
|
|
47673
47699
|
try {
|
|
47674
|
-
const st = await
|
|
47700
|
+
const st = await fs36.promises.stat(filePath);
|
|
47675
47701
|
if (!st.isFile()) return null;
|
|
47676
47702
|
return await countTextFileLines(filePath);
|
|
47677
47703
|
} catch {
|
|
@@ -47714,7 +47740,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
47714
47740
|
row.workspaceRelPath,
|
|
47715
47741
|
options.repoPathRelativeToWorkspaceRoot
|
|
47716
47742
|
);
|
|
47717
|
-
const filePath =
|
|
47743
|
+
const filePath = path47.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
47718
47744
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
47719
47745
|
let patch = await unifiedDiffForFile(
|
|
47720
47746
|
options.repoGitCwd,
|
|
@@ -47872,7 +47898,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
47872
47898
|
}
|
|
47873
47899
|
|
|
47874
47900
|
// src/git/changes/listing/list-changed-files-for-commit.ts
|
|
47875
|
-
import * as
|
|
47901
|
+
import * as path48 from "node:path";
|
|
47876
47902
|
|
|
47877
47903
|
// src/git/changes/listing/enrich-commit-file-rows.ts
|
|
47878
47904
|
async function enrichCommitFileRows(options) {
|
|
@@ -47917,7 +47943,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
47917
47943
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
47918
47944
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
47919
47945
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
47920
|
-
return `${
|
|
47946
|
+
return `${path48.resolve(repoGitCwd)}:${commitSha}`;
|
|
47921
47947
|
}
|
|
47922
47948
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
47923
47949
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -47972,7 +47998,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
47972
47998
|
}
|
|
47973
47999
|
|
|
47974
48000
|
// src/git/commits/list-unpushed-commits.ts
|
|
47975
|
-
import * as
|
|
48001
|
+
import * as path49 from "node:path";
|
|
47976
48002
|
|
|
47977
48003
|
// src/git/commits/lib/parse-log-lines.ts
|
|
47978
48004
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -48007,7 +48033,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
48007
48033
|
}
|
|
48008
48034
|
}
|
|
48009
48035
|
async function listUnpushedCommits(repoDir) {
|
|
48010
|
-
const key =
|
|
48036
|
+
const key = path49.resolve(repoDir);
|
|
48011
48037
|
const now = Date.now();
|
|
48012
48038
|
const cached2 = unpushedCache.get(key);
|
|
48013
48039
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -48068,7 +48094,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
48068
48094
|
}
|
|
48069
48095
|
|
|
48070
48096
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
48071
|
-
import * as
|
|
48097
|
+
import * as path50 from "node:path";
|
|
48072
48098
|
|
|
48073
48099
|
// src/git/remote-origin-url.ts
|
|
48074
48100
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -48083,7 +48109,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
48083
48109
|
|
|
48084
48110
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
48085
48111
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
48086
|
-
const resolvedCheckoutPath =
|
|
48112
|
+
const resolvedCheckoutPath = path50.resolve(checkoutPath);
|
|
48087
48113
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
48088
48114
|
await yieldToEventLoop2();
|
|
48089
48115
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -48098,14 +48124,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
48098
48124
|
}
|
|
48099
48125
|
|
|
48100
48126
|
// src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
48101
|
-
import * as
|
|
48127
|
+
import * as path51 from "node:path";
|
|
48102
48128
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
48103
|
-
const checkoutPath =
|
|
48129
|
+
const checkoutPath = path51.resolve(options.checkoutPath);
|
|
48104
48130
|
const git = cliSimpleGit(checkoutPath);
|
|
48105
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48131
|
+
const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
|
|
48106
48132
|
let repoPathRelativeToWorkspaceRoot;
|
|
48107
48133
|
if (sessionParentPath) {
|
|
48108
|
-
const checkoutPathRelativeToSessionParent =
|
|
48134
|
+
const checkoutPathRelativeToSessionParent = path51.relative(sessionParentPath, checkoutPath);
|
|
48109
48135
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
48110
48136
|
} else {
|
|
48111
48137
|
let gitTopLevel = checkoutPath;
|
|
@@ -48115,8 +48141,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
48115
48141
|
} catch {
|
|
48116
48142
|
gitTopLevel = checkoutPath;
|
|
48117
48143
|
}
|
|
48118
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
48119
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
48144
|
+
const gitTopLevelRelativeToBridgeRoot = path51.relative(options.bridgeRoot, path51.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
48145
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path51.basename(path51.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
48120
48146
|
}
|
|
48121
48147
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48122
48148
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -48125,10 +48151,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
48125
48151
|
|
|
48126
48152
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
48127
48153
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
48128
|
-
const checkoutPath =
|
|
48154
|
+
const checkoutPath = path52.resolve(options.targetPath);
|
|
48129
48155
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
48130
48156
|
const isCommitView = options.basis.kind === "commit";
|
|
48131
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48157
|
+
const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
|
|
48132
48158
|
const git = cliSimpleGit(checkoutPath);
|
|
48133
48159
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48134
48160
|
checkoutPath,
|
|
@@ -48176,8 +48202,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
48176
48202
|
|
|
48177
48203
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
48178
48204
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
48179
|
-
const bridgeRoot =
|
|
48180
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48205
|
+
const bridgeRoot = path53.resolve(getBridgeRoot());
|
|
48206
|
+
const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
|
|
48181
48207
|
const out = [];
|
|
48182
48208
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
48183
48209
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -48208,9 +48234,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
48208
48234
|
}
|
|
48209
48235
|
|
|
48210
48236
|
// src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
48211
|
-
import * as
|
|
48237
|
+
import * as path54 from "node:path";
|
|
48212
48238
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
48213
|
-
const repoGitCwd =
|
|
48239
|
+
const repoGitCwd = path54.resolve(options.repoGitCwd);
|
|
48214
48240
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
48215
48241
|
throw new Error("Not a git repository");
|
|
48216
48242
|
}
|
|
@@ -48249,7 +48275,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
48249
48275
|
});
|
|
48250
48276
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
48251
48277
|
}
|
|
48252
|
-
const filePath =
|
|
48278
|
+
const filePath = path54.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
48253
48279
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
48254
48280
|
let patchContent = await unifiedDiffForFile(
|
|
48255
48281
|
repoGitCwd,
|
|
@@ -48295,18 +48321,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
48295
48321
|
}
|
|
48296
48322
|
|
|
48297
48323
|
// src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
48298
|
-
import * as
|
|
48324
|
+
import * as path55 from "node:path";
|
|
48299
48325
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
48300
48326
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
48301
|
-
const bridgeRoot =
|
|
48302
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
48327
|
+
const bridgeRoot = path55.resolve(getBridgeRoot());
|
|
48328
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path55.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
48303
48329
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48304
48330
|
opts.repoRelPath.trim()
|
|
48305
48331
|
);
|
|
48306
48332
|
let result = null;
|
|
48307
48333
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
48308
48334
|
if (result) return;
|
|
48309
|
-
const checkoutPath =
|
|
48335
|
+
const checkoutPath = path55.resolve(targetPath);
|
|
48310
48336
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
48311
48337
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48312
48338
|
checkoutPath,
|
|
@@ -48339,13 +48365,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
48339
48365
|
}
|
|
48340
48366
|
|
|
48341
48367
|
// src/worktrees/remove-session-worktrees.ts
|
|
48342
|
-
import * as
|
|
48368
|
+
import * as fs39 from "node:fs";
|
|
48343
48369
|
|
|
48344
48370
|
// src/git/worktrees/worktree-remove.ts
|
|
48345
|
-
import * as
|
|
48371
|
+
import * as fs38 from "node:fs";
|
|
48346
48372
|
|
|
48347
48373
|
// src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
48348
|
-
import
|
|
48374
|
+
import path56 from "node:path";
|
|
48349
48375
|
init_normalize_resolved_path();
|
|
48350
48376
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
48351
48377
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -48354,23 +48380,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
48354
48380
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
48355
48381
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
48356
48382
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
48357
|
-
const rel =
|
|
48358
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
48383
|
+
const rel = path56.relative(worktreesRoot, normalized);
|
|
48384
|
+
if (rel === "" || rel.startsWith("..") || path56.isAbsolute(rel)) return false;
|
|
48359
48385
|
return true;
|
|
48360
48386
|
}
|
|
48361
48387
|
|
|
48362
48388
|
// src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
48363
|
-
import * as
|
|
48364
|
-
import * as
|
|
48389
|
+
import * as fs37 from "node:fs";
|
|
48390
|
+
import * as path57 from "node:path";
|
|
48365
48391
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
48366
|
-
const gitDirFile =
|
|
48367
|
-
if (!
|
|
48368
|
-
const first2 =
|
|
48392
|
+
const gitDirFile = path57.join(wt, ".git");
|
|
48393
|
+
if (!fs37.existsSync(gitDirFile) || !fs37.statSync(gitDirFile).isFile()) return "";
|
|
48394
|
+
const first2 = fs37.readFileSync(gitDirFile, "utf8").trim();
|
|
48369
48395
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
48370
48396
|
if (!m) return "";
|
|
48371
|
-
const gitWorktreePath =
|
|
48372
|
-
const gitDir =
|
|
48373
|
-
return
|
|
48397
|
+
const gitWorktreePath = path57.resolve(wt, m[1].trim());
|
|
48398
|
+
const gitDir = path57.dirname(path57.dirname(gitWorktreePath));
|
|
48399
|
+
return path57.dirname(gitDir);
|
|
48374
48400
|
}
|
|
48375
48401
|
|
|
48376
48402
|
// src/git/worktrees/worktree-remove.ts
|
|
@@ -48381,7 +48407,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
48381
48407
|
return true;
|
|
48382
48408
|
}
|
|
48383
48409
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
48384
|
-
|
|
48410
|
+
fs38.rmSync(worktreePath, { recursive: true, force: true });
|
|
48385
48411
|
return true;
|
|
48386
48412
|
}
|
|
48387
48413
|
|
|
@@ -48403,7 +48429,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
48403
48429
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
48404
48430
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
48405
48431
|
try {
|
|
48406
|
-
|
|
48432
|
+
fs39.rmSync(wt, { recursive: true, force: true });
|
|
48407
48433
|
} catch {
|
|
48408
48434
|
}
|
|
48409
48435
|
}
|
|
@@ -48428,6 +48454,7 @@ async function gitRenameCurrentBranch(repoDir, newName) {
|
|
|
48428
48454
|
async function renameSessionWorktreeBranches(paths, newBranch, log2) {
|
|
48429
48455
|
const safe = newBranch.replace(/[^a-zA-Z0-9/_-]+/g, "-").slice(0, 80) || "session-branch";
|
|
48430
48456
|
await forEachWithGitYield(paths, async (wt) => {
|
|
48457
|
+
if (!await isGitRepoDirectory(wt)) return;
|
|
48431
48458
|
try {
|
|
48432
48459
|
await gitRenameCurrentBranch(wt, safe);
|
|
48433
48460
|
log2(`[worktrees] Renamed branch in ${wt} \u2192 ${safe}`);
|
|
@@ -48449,12 +48476,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
48449
48476
|
// src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
48450
48477
|
init_cli_process_interrupt();
|
|
48451
48478
|
init_yield_to_event_loop();
|
|
48452
|
-
import * as
|
|
48453
|
-
import * as
|
|
48479
|
+
import * as fs43 from "node:fs";
|
|
48480
|
+
import * as path62 from "node:path";
|
|
48454
48481
|
|
|
48455
48482
|
// src/worktrees/discovery/collect-worktree-paths.ts
|
|
48456
|
-
import * as
|
|
48457
|
-
import * as
|
|
48483
|
+
import * as fs41 from "node:fs";
|
|
48484
|
+
import * as path59 from "node:path";
|
|
48458
48485
|
|
|
48459
48486
|
// src/worktrees/discovery/disk-walk-constants.ts
|
|
48460
48487
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -48484,8 +48511,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
48484
48511
|
// src/worktrees/discovery/disk-walk-utils.ts
|
|
48485
48512
|
init_cli_process_interrupt();
|
|
48486
48513
|
init_yield_to_event_loop();
|
|
48487
|
-
import * as
|
|
48488
|
-
import * as
|
|
48514
|
+
import * as fs40 from "node:fs";
|
|
48515
|
+
import * as path58 from "node:path";
|
|
48489
48516
|
async function yieldDuringDiskWalk(state) {
|
|
48490
48517
|
state.entries++;
|
|
48491
48518
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -48495,7 +48522,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
48495
48522
|
}
|
|
48496
48523
|
async function isGitDir(dirPath) {
|
|
48497
48524
|
try {
|
|
48498
|
-
await
|
|
48525
|
+
await fs40.promises.access(path58.join(dirPath, ".git"));
|
|
48499
48526
|
return true;
|
|
48500
48527
|
} catch {
|
|
48501
48528
|
return false;
|
|
@@ -48509,23 +48536,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
48509
48536
|
const walk = async (dir) => {
|
|
48510
48537
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
48511
48538
|
if (await isGitDir(dir)) {
|
|
48512
|
-
out.push(
|
|
48539
|
+
out.push(path59.resolve(dir));
|
|
48513
48540
|
return;
|
|
48514
48541
|
}
|
|
48515
48542
|
let entries;
|
|
48516
48543
|
try {
|
|
48517
|
-
entries = await
|
|
48544
|
+
entries = await fs41.promises.readdir(dir, { withFileTypes: true });
|
|
48518
48545
|
} catch {
|
|
48519
48546
|
return;
|
|
48520
48547
|
}
|
|
48521
48548
|
for (const e of entries) {
|
|
48522
48549
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
48523
|
-
const full =
|
|
48550
|
+
const full = path59.join(dir, e.name);
|
|
48524
48551
|
if (!e.isDirectory()) continue;
|
|
48525
48552
|
await walk(full);
|
|
48526
48553
|
}
|
|
48527
48554
|
};
|
|
48528
|
-
await walk(
|
|
48555
|
+
await walk(path59.resolve(rootPath));
|
|
48529
48556
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
48530
48557
|
}
|
|
48531
48558
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -48536,16 +48563,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
48536
48563
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
48537
48564
|
let entries;
|
|
48538
48565
|
try {
|
|
48539
|
-
entries = await
|
|
48566
|
+
entries = await fs41.promises.readdir(dir, { withFileTypes: true });
|
|
48540
48567
|
} catch {
|
|
48541
48568
|
return;
|
|
48542
48569
|
}
|
|
48543
48570
|
for (const e of entries) {
|
|
48544
48571
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
48545
|
-
const full =
|
|
48572
|
+
const full = path59.join(dir, e.name);
|
|
48546
48573
|
if (!e.isDirectory()) continue;
|
|
48547
48574
|
if (e.name === sessionId) {
|
|
48548
|
-
if (await isGitDir(full)) out.push(
|
|
48575
|
+
if (await isGitDir(full)) out.push(path59.resolve(full));
|
|
48549
48576
|
continue;
|
|
48550
48577
|
}
|
|
48551
48578
|
if (await isGitDir(full)) continue;
|
|
@@ -48557,14 +48584,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
48557
48584
|
}
|
|
48558
48585
|
|
|
48559
48586
|
// src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
48560
|
-
import * as
|
|
48587
|
+
import * as path60 from "node:path";
|
|
48561
48588
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
48562
|
-
const bridge =
|
|
48589
|
+
const bridge = path60.resolve(bridgeRoot);
|
|
48563
48590
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
48564
48591
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
48565
|
-
const entry =
|
|
48566
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
48567
|
-
}).sort((a, b) =>
|
|
48592
|
+
const entry = path60.resolve(e.absolutePath);
|
|
48593
|
+
return bridge === entry || bridge.startsWith(entry + path60.sep) || entry.startsWith(bridge + path60.sep);
|
|
48594
|
+
}).sort((a, b) => path60.resolve(b.absolutePath).length - path60.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
48568
48595
|
const ordered = [];
|
|
48569
48596
|
const seen = /* @__PURE__ */ new Set();
|
|
48570
48597
|
const add = (k) => {
|
|
@@ -48582,19 +48609,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
48582
48609
|
}
|
|
48583
48610
|
|
|
48584
48611
|
// src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
48585
|
-
import * as
|
|
48586
|
-
import * as
|
|
48612
|
+
import * as fs42 from "node:fs";
|
|
48613
|
+
import * as path61 from "node:path";
|
|
48587
48614
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
48588
48615
|
let st;
|
|
48589
48616
|
try {
|
|
48590
|
-
st = await
|
|
48617
|
+
st = await fs42.promises.stat(scopeDir);
|
|
48591
48618
|
} catch {
|
|
48592
48619
|
return null;
|
|
48593
48620
|
}
|
|
48594
48621
|
if (!st.isDirectory()) return null;
|
|
48595
48622
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
48596
48623
|
if (worktreePaths.length === 0) return null;
|
|
48597
|
-
const abs =
|
|
48624
|
+
const abs = path61.resolve(scopeDir);
|
|
48598
48625
|
return {
|
|
48599
48626
|
parentPath: abs,
|
|
48600
48627
|
repoCheckoutPaths: worktreePaths
|
|
@@ -48617,7 +48644,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48617
48644
|
const sid = sessionId.trim();
|
|
48618
48645
|
if (!sid) return null;
|
|
48619
48646
|
try {
|
|
48620
|
-
await
|
|
48647
|
+
await fs43.promises.access(worktreesRootPath);
|
|
48621
48648
|
} catch {
|
|
48622
48649
|
return null;
|
|
48623
48650
|
}
|
|
@@ -48626,13 +48653,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48626
48653
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
48627
48654
|
const scanState = { entries: 0 };
|
|
48628
48655
|
try {
|
|
48629
|
-
for (const name of await
|
|
48656
|
+
for (const name of await fs43.promises.readdir(worktreesRootPath)) {
|
|
48630
48657
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
48631
48658
|
if (name.startsWith(".")) continue;
|
|
48632
|
-
const p =
|
|
48659
|
+
const p = path62.join(worktreesRootPath, name);
|
|
48633
48660
|
let st;
|
|
48634
48661
|
try {
|
|
48635
|
-
st = await
|
|
48662
|
+
st = await fs43.promises.stat(p);
|
|
48636
48663
|
} catch {
|
|
48637
48664
|
continue;
|
|
48638
48665
|
}
|
|
@@ -48646,23 +48673,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48646
48673
|
for (const key of keys) {
|
|
48647
48674
|
if (isCliImmediateShutdownRequested()) return null;
|
|
48648
48675
|
await yieldToEventLoop();
|
|
48649
|
-
const layoutRoot =
|
|
48676
|
+
const layoutRoot = path62.join(worktreesRootPath, key);
|
|
48650
48677
|
let layoutSt;
|
|
48651
48678
|
try {
|
|
48652
|
-
layoutSt = await
|
|
48679
|
+
layoutSt = await fs43.promises.stat(layoutRoot);
|
|
48653
48680
|
} catch {
|
|
48654
48681
|
continue;
|
|
48655
48682
|
}
|
|
48656
48683
|
if (!layoutSt.isDirectory()) continue;
|
|
48657
|
-
const sessionDir =
|
|
48684
|
+
const sessionDir = path62.join(layoutRoot, sid);
|
|
48658
48685
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
48659
48686
|
if (nested) return nested;
|
|
48660
48687
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
48661
48688
|
if (legacy.paths.length > 0) {
|
|
48662
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
48689
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path62.resolve(legacy.paths[0]);
|
|
48663
48690
|
return {
|
|
48664
|
-
sessionParentPath:
|
|
48665
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
48691
|
+
sessionParentPath: path62.resolve(isolated),
|
|
48692
|
+
repoCheckoutPaths: legacy.paths.map((p) => path62.resolve(p))
|
|
48666
48693
|
};
|
|
48667
48694
|
}
|
|
48668
48695
|
}
|
|
@@ -48670,31 +48697,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48670
48697
|
}
|
|
48671
48698
|
|
|
48672
48699
|
// src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
48673
|
-
import * as
|
|
48674
|
-
import * as
|
|
48700
|
+
import * as fs44 from "node:fs";
|
|
48701
|
+
import * as path64 from "node:path";
|
|
48675
48702
|
|
|
48676
48703
|
// src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
48677
48704
|
init_cli_process_interrupt();
|
|
48678
48705
|
init_yield_to_event_loop();
|
|
48679
|
-
import * as
|
|
48706
|
+
import * as path63 from "node:path";
|
|
48680
48707
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
48681
48708
|
const sid = sessionId.trim();
|
|
48682
48709
|
if (!sid) return null;
|
|
48683
|
-
const hintR =
|
|
48710
|
+
const hintR = path63.resolve(checkoutPath);
|
|
48684
48711
|
let best = null;
|
|
48685
|
-
let cur =
|
|
48712
|
+
let cur = path63.dirname(hintR);
|
|
48686
48713
|
for (let i = 0; i < 40; i++) {
|
|
48687
48714
|
if (isCliImmediateShutdownRequested()) return best;
|
|
48688
48715
|
await yieldToEventLoop();
|
|
48689
48716
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
48690
|
-
if (paths.paths.some((p) =>
|
|
48691
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
48717
|
+
if (paths.paths.some((p) => path63.resolve(p) === hintR)) {
|
|
48718
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path63.resolve(paths.paths[0]);
|
|
48692
48719
|
best = {
|
|
48693
|
-
sessionParentPath:
|
|
48694
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
48720
|
+
sessionParentPath: path63.resolve(isolated),
|
|
48721
|
+
repoCheckoutPaths: paths.paths.map((p) => path63.resolve(p))
|
|
48695
48722
|
};
|
|
48696
48723
|
}
|
|
48697
|
-
const next =
|
|
48724
|
+
const next = path63.dirname(cur);
|
|
48698
48725
|
if (next === cur) break;
|
|
48699
48726
|
cur = next;
|
|
48700
48727
|
}
|
|
@@ -48705,12 +48732,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
48705
48732
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
48706
48733
|
const sid = sessionId.trim();
|
|
48707
48734
|
if (!sid) return null;
|
|
48708
|
-
const hint =
|
|
48709
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
48735
|
+
const hint = path64.resolve(sessionParentPathOrHint);
|
|
48736
|
+
const underHint = await tryBindingFromSessionDirectory(path64.join(hint, sid));
|
|
48710
48737
|
if (underHint) return underHint;
|
|
48711
48738
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
48712
48739
|
if (direct) {
|
|
48713
|
-
if (
|
|
48740
|
+
if (path64.basename(hint) === sid && await isGitDir(hint)) {
|
|
48714
48741
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
48715
48742
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
48716
48743
|
return legacyFromCheckout;
|
|
@@ -48718,23 +48745,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
48718
48745
|
}
|
|
48719
48746
|
return direct;
|
|
48720
48747
|
}
|
|
48721
|
-
if (
|
|
48748
|
+
if (path64.basename(hint) === sid && await isGitDir(hint)) {
|
|
48722
48749
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
48723
48750
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
48724
48751
|
}
|
|
48725
48752
|
let st;
|
|
48726
48753
|
try {
|
|
48727
|
-
st = await
|
|
48754
|
+
st = await fs44.promises.stat(hint);
|
|
48728
48755
|
} catch {
|
|
48729
48756
|
return null;
|
|
48730
48757
|
}
|
|
48731
48758
|
if (!st.isDirectory()) return null;
|
|
48732
48759
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
48733
48760
|
if (legacyPaths.paths.length === 0) return null;
|
|
48734
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
48761
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path64.resolve(legacyPaths.paths[0]);
|
|
48735
48762
|
return {
|
|
48736
|
-
sessionParentPath:
|
|
48737
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
48763
|
+
sessionParentPath: path64.resolve(isolated),
|
|
48764
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path64.resolve(p))
|
|
48738
48765
|
};
|
|
48739
48766
|
}
|
|
48740
48767
|
|
|
@@ -48795,11 +48822,11 @@ function parseSessionParent(v) {
|
|
|
48795
48822
|
}
|
|
48796
48823
|
|
|
48797
48824
|
// src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
48798
|
-
import * as
|
|
48825
|
+
import * as fs48 from "node:fs";
|
|
48799
48826
|
|
|
48800
48827
|
// src/git/discover-repos.ts
|
|
48801
|
-
import * as
|
|
48802
|
-
import * as
|
|
48828
|
+
import * as fs45 from "node:fs";
|
|
48829
|
+
import * as path65 from "node:path";
|
|
48803
48830
|
init_yield_to_event_loop();
|
|
48804
48831
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
48805
48832
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -48809,14 +48836,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
48809
48836
|
}
|
|
48810
48837
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
48811
48838
|
const result = [];
|
|
48812
|
-
const cwdResolved =
|
|
48839
|
+
const cwdResolved = path65.resolve(cwd);
|
|
48813
48840
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
48814
48841
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
48815
48842
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
48816
48843
|
}
|
|
48817
48844
|
let entries;
|
|
48818
48845
|
try {
|
|
48819
|
-
entries =
|
|
48846
|
+
entries = fs45.readdirSync(cwdResolved, { withFileTypes: true });
|
|
48820
48847
|
} catch {
|
|
48821
48848
|
return result;
|
|
48822
48849
|
}
|
|
@@ -48824,7 +48851,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
48824
48851
|
await yieldGitDiscoverWork(i + 1);
|
|
48825
48852
|
const ent = entries[i];
|
|
48826
48853
|
if (!ent.isDirectory()) continue;
|
|
48827
|
-
const childPath2 =
|
|
48854
|
+
const childPath2 = path65.join(cwdResolved, ent.name);
|
|
48828
48855
|
if (await isGitRepoDirectory(childPath2)) {
|
|
48829
48856
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
48830
48857
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -48833,17 +48860,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
48833
48860
|
return result;
|
|
48834
48861
|
}
|
|
48835
48862
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
48836
|
-
const root =
|
|
48863
|
+
const root = path65.resolve(rootPath);
|
|
48837
48864
|
const roots = [];
|
|
48838
48865
|
let walkEntries = 0;
|
|
48839
48866
|
async function walk(dir) {
|
|
48840
48867
|
if (await isGitRepoDirectory(dir)) {
|
|
48841
|
-
roots.push(
|
|
48868
|
+
roots.push(path65.resolve(dir));
|
|
48842
48869
|
return;
|
|
48843
48870
|
}
|
|
48844
48871
|
let entries;
|
|
48845
48872
|
try {
|
|
48846
|
-
entries =
|
|
48873
|
+
entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
48847
48874
|
} catch {
|
|
48848
48875
|
return;
|
|
48849
48876
|
}
|
|
@@ -48851,7 +48878,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
48851
48878
|
await yieldGitDiscoverWork(++walkEntries);
|
|
48852
48879
|
const ent = entries[i];
|
|
48853
48880
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
48854
|
-
await walk(
|
|
48881
|
+
await walk(path65.join(dir, ent.name));
|
|
48855
48882
|
}
|
|
48856
48883
|
}
|
|
48857
48884
|
await walk(root);
|
|
@@ -48867,8 +48894,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
48867
48894
|
}
|
|
48868
48895
|
|
|
48869
48896
|
// src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
48870
|
-
import * as
|
|
48871
|
-
import * as
|
|
48897
|
+
import * as fs47 from "node:fs";
|
|
48898
|
+
import * as path67 from "node:path";
|
|
48872
48899
|
|
|
48873
48900
|
// src/git/worktrees/worktree-add.ts
|
|
48874
48901
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -48884,8 +48911,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
48884
48911
|
}
|
|
48885
48912
|
|
|
48886
48913
|
// src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
48887
|
-
import * as
|
|
48888
|
-
import * as
|
|
48914
|
+
import * as fs46 from "node:fs";
|
|
48915
|
+
import * as path66 from "node:path";
|
|
48889
48916
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
48890
48917
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
48891
48918
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -48894,19 +48921,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
48894
48921
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
48895
48922
|
for (let i = 0; i < segments.length; i++) {
|
|
48896
48923
|
const prefix = segments.slice(0, i).join("/");
|
|
48897
|
-
const bridgeDir = prefix ?
|
|
48898
|
-
const destDir = prefix ?
|
|
48924
|
+
const bridgeDir = prefix ? path66.join(bridgeRoot, prefix) : bridgeRoot;
|
|
48925
|
+
const destDir = prefix ? path66.join(scopeDir, prefix) : scopeDir;
|
|
48899
48926
|
for (const fileName of fileNames) {
|
|
48900
48927
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
48901
48928
|
}
|
|
48902
48929
|
}
|
|
48903
48930
|
}
|
|
48904
48931
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
48905
|
-
const src =
|
|
48906
|
-
if (!
|
|
48907
|
-
const dest =
|
|
48932
|
+
const src = path66.join(srcDir, fileName);
|
|
48933
|
+
if (!fs46.existsSync(src)) return;
|
|
48934
|
+
const dest = path66.join(destDir, fileName);
|
|
48908
48935
|
try {
|
|
48909
|
-
|
|
48936
|
+
fs46.copyFileSync(src, dest);
|
|
48910
48937
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
48911
48938
|
} catch (e) {
|
|
48912
48939
|
log2?.(
|
|
@@ -48938,16 +48965,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
48938
48965
|
worktreeBaseBranches,
|
|
48939
48966
|
log: log2
|
|
48940
48967
|
} = options;
|
|
48941
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
48942
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
48968
|
+
const repoPathRelativeToBridgeRootRaw = path67.relative(bridgeResolved, repoAbsolutePath);
|
|
48969
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path67.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
48943
48970
|
return null;
|
|
48944
48971
|
}
|
|
48945
48972
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48946
48973
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
48947
48974
|
);
|
|
48948
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
48975
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path67.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
48949
48976
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
48950
|
-
|
|
48977
|
+
fs47.mkdirSync(path67.dirname(worktreePath), { recursive: true });
|
|
48951
48978
|
copyBridgeFilesAlongWorktreePath({
|
|
48952
48979
|
bridgeRoot: bridgeResolved,
|
|
48953
48980
|
scopeDir,
|
|
@@ -48975,7 +49002,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
48975
49002
|
}
|
|
48976
49003
|
|
|
48977
49004
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
48978
|
-
import * as
|
|
49005
|
+
import * as path68 from "node:path";
|
|
48979
49006
|
|
|
48980
49007
|
// src/worktrees/worktree-layout-kind.ts
|
|
48981
49008
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -49005,10 +49032,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
49005
49032
|
|
|
49006
49033
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
49007
49034
|
function resolveIsolatedScopeDir(options) {
|
|
49008
|
-
const bridgeResolved =
|
|
49035
|
+
const bridgeResolved = path68.resolve(options.bridgeRoot);
|
|
49009
49036
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
49010
|
-
const bridgeKeyDir =
|
|
49011
|
-
const scopeDir =
|
|
49037
|
+
const bridgeKeyDir = path68.join(options.worktreesRootPath, cwdKey);
|
|
49038
|
+
const scopeDir = path68.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
49012
49039
|
return { bridgeResolved, scopeDir };
|
|
49013
49040
|
}
|
|
49014
49041
|
|
|
@@ -49038,7 +49065,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
49038
49065
|
return null;
|
|
49039
49066
|
}
|
|
49040
49067
|
const worktreePaths = [];
|
|
49041
|
-
|
|
49068
|
+
fs48.mkdirSync(scopeDir, { recursive: true });
|
|
49042
49069
|
await forEachWithGitYield(repos, async (repo) => {
|
|
49043
49070
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
49044
49071
|
kind,
|
|
@@ -49110,10 +49137,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
49110
49137
|
}
|
|
49111
49138
|
|
|
49112
49139
|
// src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
49113
|
-
import * as
|
|
49140
|
+
import * as path69 from "node:path";
|
|
49114
49141
|
init_yield_to_event_loop();
|
|
49115
49142
|
async function resolveExplicitSessionParentPath(params) {
|
|
49116
|
-
const resolved =
|
|
49143
|
+
const resolved = path69.resolve(params.parentPathRaw);
|
|
49117
49144
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
49118
49145
|
return resolved;
|
|
49119
49146
|
}
|
|
@@ -49130,7 +49157,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
49130
49157
|
await yieldToEventLoop();
|
|
49131
49158
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
49132
49159
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
49133
|
-
const next =
|
|
49160
|
+
const next = path69.dirname(cur);
|
|
49134
49161
|
if (next === cur) break;
|
|
49135
49162
|
cur = next;
|
|
49136
49163
|
}
|
|
@@ -49278,15 +49305,15 @@ var SessionWorktreeManager = class {
|
|
|
49278
49305
|
};
|
|
49279
49306
|
|
|
49280
49307
|
// src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
49281
|
-
import * as
|
|
49282
|
-
import * as
|
|
49308
|
+
import * as fs49 from "node:fs";
|
|
49309
|
+
import * as path70 from "node:path";
|
|
49283
49310
|
init_yield_to_event_loop();
|
|
49284
49311
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
49285
49312
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
49286
49313
|
const eid = environmentId.trim();
|
|
49287
49314
|
if (!eid) return null;
|
|
49288
49315
|
try {
|
|
49289
|
-
await
|
|
49316
|
+
await fs49.promises.access(worktreesRootPath);
|
|
49290
49317
|
} catch {
|
|
49291
49318
|
return null;
|
|
49292
49319
|
}
|
|
@@ -49295,13 +49322,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49295
49322
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
49296
49323
|
const scanState = { entries: 0 };
|
|
49297
49324
|
try {
|
|
49298
|
-
for (const name of await
|
|
49325
|
+
for (const name of await fs49.promises.readdir(worktreesRootPath)) {
|
|
49299
49326
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
49300
49327
|
if (name.startsWith(".")) continue;
|
|
49301
|
-
const p =
|
|
49328
|
+
const p = path70.join(worktreesRootPath, name);
|
|
49302
49329
|
let st;
|
|
49303
49330
|
try {
|
|
49304
|
-
st = await
|
|
49331
|
+
st = await fs49.promises.stat(p);
|
|
49305
49332
|
} catch {
|
|
49306
49333
|
continue;
|
|
49307
49334
|
}
|
|
@@ -49315,7 +49342,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49315
49342
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
49316
49343
|
for (const key of keys) {
|
|
49317
49344
|
await yieldToEventLoop();
|
|
49318
|
-
const previewDir =
|
|
49345
|
+
const previewDir = path70.join(worktreesRootPath, key, ...previewDirRel);
|
|
49319
49346
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
49320
49347
|
if (binding) return binding;
|
|
49321
49348
|
}
|
|
@@ -49442,7 +49469,7 @@ var PreviewWorktreeManager = class {
|
|
|
49442
49469
|
};
|
|
49443
49470
|
|
|
49444
49471
|
// src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
49445
|
-
import * as
|
|
49472
|
+
import * as path74 from "node:path";
|
|
49446
49473
|
|
|
49447
49474
|
// src/git/worktrees/reset-worktree-to-branch.ts
|
|
49448
49475
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -49453,8 +49480,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
49453
49480
|
}
|
|
49454
49481
|
|
|
49455
49482
|
// src/worktrees/deploy/capture-and-apply-wip.ts
|
|
49456
|
-
import * as
|
|
49457
|
-
import * as
|
|
49483
|
+
import * as fs50 from "node:fs";
|
|
49484
|
+
import * as path71 from "node:path";
|
|
49458
49485
|
|
|
49459
49486
|
// src/git/snapshot/git.ts
|
|
49460
49487
|
async function gitStashCreate(repoRoot, log2) {
|
|
@@ -49502,12 +49529,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49502
49529
|
if (!ap.ok) return ap;
|
|
49503
49530
|
}
|
|
49504
49531
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
49505
|
-
const src =
|
|
49506
|
-
const dst =
|
|
49532
|
+
const src = path71.join(sourceRepoPath, rel);
|
|
49533
|
+
const dst = path71.join(targetRepoPath, rel);
|
|
49507
49534
|
try {
|
|
49508
|
-
if (!
|
|
49509
|
-
|
|
49510
|
-
|
|
49535
|
+
if (!fs50.existsSync(src)) return;
|
|
49536
|
+
fs50.mkdirSync(path71.dirname(dst), { recursive: true });
|
|
49537
|
+
fs50.copyFileSync(src, dst);
|
|
49511
49538
|
} catch (e) {
|
|
49512
49539
|
log2(
|
|
49513
49540
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -49518,14 +49545,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49518
49545
|
}
|
|
49519
49546
|
|
|
49520
49547
|
// src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
49521
|
-
import * as
|
|
49548
|
+
import * as path72 from "node:path";
|
|
49522
49549
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
49523
49550
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
49524
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
49551
|
+
const resolvedSessionParentPath = sessionParentPath ? path72.resolve(sessionParentPath) : null;
|
|
49525
49552
|
let match = null;
|
|
49526
49553
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
49527
49554
|
if (match) return;
|
|
49528
|
-
const resolvedCheckoutPath =
|
|
49555
|
+
const resolvedCheckoutPath = path72.resolve(checkoutPath);
|
|
49529
49556
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
49530
49557
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49531
49558
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -49579,7 +49606,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
49579
49606
|
}
|
|
49580
49607
|
|
|
49581
49608
|
// src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
49582
|
-
import * as
|
|
49609
|
+
import * as path73 from "node:path";
|
|
49583
49610
|
|
|
49584
49611
|
// src/git/branches/create-or-update-branch.ts
|
|
49585
49612
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -49616,19 +49643,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
49616
49643
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
49617
49644
|
const states = [];
|
|
49618
49645
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
49619
|
-
const checkoutPath =
|
|
49646
|
+
const checkoutPath = path73.resolve(sessionCheckout);
|
|
49620
49647
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
49621
49648
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49622
49649
|
checkoutPath,
|
|
49623
49650
|
bridgeRoot,
|
|
49624
|
-
sessionParentPath: sessionParentPath ?
|
|
49651
|
+
sessionParentPath: sessionParentPath ? path73.resolve(sessionParentPath) : null
|
|
49625
49652
|
});
|
|
49626
49653
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
49627
49654
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
49628
49655
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
49629
49656
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
49630
49657
|
checkoutPaths: previewCheckoutPaths,
|
|
49631
|
-
sessionParentPath: previewParentPath ?
|
|
49658
|
+
sessionParentPath: previewParentPath ? path73.resolve(previewParentPath) : null,
|
|
49632
49659
|
bridgeRoot,
|
|
49633
49660
|
repoPathRelativeToWorkspaceRoot
|
|
49634
49661
|
}) : null;
|
|
@@ -49648,7 +49675,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49648
49675
|
const eid = options.environmentId.trim();
|
|
49649
49676
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
49650
49677
|
const deployBranch = previewDeployBranchName(eid);
|
|
49651
|
-
const bridgeRoot =
|
|
49678
|
+
const bridgeRoot = path74.resolve(getBridgeRoot());
|
|
49652
49679
|
await previewWorktreeManager.ensureCached(eid);
|
|
49653
49680
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
49654
49681
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -49688,10 +49715,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49688
49715
|
}
|
|
49689
49716
|
|
|
49690
49717
|
// src/worktrees/manager/default-worktrees-root-path.ts
|
|
49691
|
-
import * as
|
|
49718
|
+
import * as path75 from "node:path";
|
|
49692
49719
|
import os9 from "node:os";
|
|
49693
49720
|
function defaultWorktreesRootPath() {
|
|
49694
|
-
return
|
|
49721
|
+
return path75.join(os9.homedir(), ".buildautomaton", "worktrees");
|
|
49695
49722
|
}
|
|
49696
49723
|
|
|
49697
49724
|
// src/connection/create-bridge-worktree-managers.ts
|
|
@@ -49821,14 +49848,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
49821
49848
|
}
|
|
49822
49849
|
|
|
49823
49850
|
// src/files/list-dir/index.ts
|
|
49824
|
-
import
|
|
49851
|
+
import fs52 from "node:fs";
|
|
49825
49852
|
|
|
49826
49853
|
// src/files/ensure-under-cwd.ts
|
|
49827
|
-
import
|
|
49854
|
+
import path76 from "node:path";
|
|
49828
49855
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
49829
|
-
const normalized =
|
|
49830
|
-
const resolved =
|
|
49831
|
-
if (!resolved.startsWith(cwd +
|
|
49856
|
+
const normalized = path76.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
49857
|
+
const resolved = path76.resolve(cwd, normalized);
|
|
49858
|
+
if (!resolved.startsWith(cwd + path76.sep) && resolved !== cwd) {
|
|
49832
49859
|
return null;
|
|
49833
49860
|
}
|
|
49834
49861
|
return resolved;
|
|
@@ -49841,15 +49868,15 @@ init_yield_to_event_loop();
|
|
|
49841
49868
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
49842
49869
|
|
|
49843
49870
|
// src/files/list-dir/map-dir-entry.ts
|
|
49844
|
-
import
|
|
49845
|
-
import
|
|
49871
|
+
import path77 from "node:path";
|
|
49872
|
+
import fs51 from "node:fs";
|
|
49846
49873
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
49847
|
-
const entryPath =
|
|
49848
|
-
const fullPath =
|
|
49874
|
+
const entryPath = path77.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
49875
|
+
const fullPath = path77.join(resolved, d.name);
|
|
49849
49876
|
let isDir = d.isDirectory();
|
|
49850
49877
|
if (d.isSymbolicLink()) {
|
|
49851
49878
|
try {
|
|
49852
|
-
const targetStat = await
|
|
49879
|
+
const targetStat = await fs51.promises.stat(fullPath);
|
|
49853
49880
|
isDir = targetStat.isDirectory();
|
|
49854
49881
|
} catch {
|
|
49855
49882
|
isDir = false;
|
|
@@ -49879,7 +49906,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49879
49906
|
return { error: "Path is outside working directory" };
|
|
49880
49907
|
}
|
|
49881
49908
|
try {
|
|
49882
|
-
const names = await
|
|
49909
|
+
const names = await fs52.promises.readdir(resolved, { withFileTypes: true });
|
|
49883
49910
|
const entries = [];
|
|
49884
49911
|
for (let i = 0; i < names.length; i++) {
|
|
49885
49912
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -49895,13 +49922,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49895
49922
|
}
|
|
49896
49923
|
|
|
49897
49924
|
// src/git/tree/resolve-repo-abs-path.ts
|
|
49898
|
-
import * as
|
|
49925
|
+
import * as path78 from "node:path";
|
|
49899
49926
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
49900
|
-
const bridgeResolved =
|
|
49927
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
49901
49928
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
49902
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
49903
|
-
const resolved =
|
|
49904
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
49929
|
+
const repoPath = rel === "" ? bridgeResolved : path78.join(bridgeResolved, rel);
|
|
49930
|
+
const resolved = path78.resolve(repoPath);
|
|
49931
|
+
if (!resolved.startsWith(bridgeResolved + path78.sep) && resolved !== bridgeResolved) {
|
|
49905
49932
|
return null;
|
|
49906
49933
|
}
|
|
49907
49934
|
return resolved;
|
|
@@ -49987,7 +50014,7 @@ init_yield_to_event_loop();
|
|
|
49987
50014
|
|
|
49988
50015
|
// src/files/read/types.ts
|
|
49989
50016
|
var LINE_CHUNK_SIZE = 64 * 1024;
|
|
49990
|
-
var READ_RANGE_YIELD_EVERY_BYTES =
|
|
50017
|
+
var READ_RANGE_YIELD_EVERY_BYTES = 64 * 1024;
|
|
49991
50018
|
|
|
49992
50019
|
// src/files/read/guess-mime-type.ts
|
|
49993
50020
|
var MIME_BY_EXT = {
|
|
@@ -50382,25 +50409,25 @@ async function GET2(ctx) {
|
|
|
50382
50409
|
init_in_flight();
|
|
50383
50410
|
|
|
50384
50411
|
// src/files/read/read-file-async.ts
|
|
50385
|
-
import
|
|
50412
|
+
import fs58 from "node:fs";
|
|
50386
50413
|
init_yield_to_event_loop();
|
|
50387
50414
|
|
|
50388
50415
|
// src/files/read/resolve-file-cache.ts
|
|
50389
|
-
import
|
|
50390
|
-
import
|
|
50416
|
+
import fs53 from "node:fs";
|
|
50417
|
+
import path79 from "node:path";
|
|
50391
50418
|
var RESOLVE_CACHE_MAX = 4096;
|
|
50392
50419
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
50393
50420
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
50394
50421
|
return `${sessionParentPath}\0${relativePath}`;
|
|
50395
50422
|
}
|
|
50396
50423
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
50397
|
-
const parent =
|
|
50398
|
-
const resolved =
|
|
50399
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
50424
|
+
const parent = path79.resolve(sessionParentPath);
|
|
50425
|
+
const resolved = path79.resolve(filePath);
|
|
50426
|
+
return resolved === parent || resolved.startsWith(`${parent}${path79.sep}`);
|
|
50400
50427
|
}
|
|
50401
50428
|
function statMatchesCacheSync(entry) {
|
|
50402
50429
|
try {
|
|
50403
|
-
const stat3 =
|
|
50430
|
+
const stat3 = fs53.statSync(entry.path);
|
|
50404
50431
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
50405
50432
|
} catch {
|
|
50406
50433
|
return false;
|
|
@@ -50433,7 +50460,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
50433
50460
|
}
|
|
50434
50461
|
|
|
50435
50462
|
// src/files/read/resolve-file-for-read-core.ts
|
|
50436
|
-
import
|
|
50463
|
+
import fs54 from "node:fs";
|
|
50437
50464
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
50438
50465
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
50439
50466
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -50443,13 +50470,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
50443
50470
|
let size;
|
|
50444
50471
|
let mtimeMs;
|
|
50445
50472
|
try {
|
|
50446
|
-
const lstat =
|
|
50473
|
+
const lstat = fs54.lstatSync(resolved);
|
|
50447
50474
|
if (lstat.isSymbolicLink()) {
|
|
50448
|
-
real =
|
|
50475
|
+
real = fs54.realpathSync(resolved);
|
|
50449
50476
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50450
50477
|
return { error: "Path is outside working directory" };
|
|
50451
50478
|
}
|
|
50452
|
-
const stat3 =
|
|
50479
|
+
const stat3 = fs54.statSync(real);
|
|
50453
50480
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50454
50481
|
size = stat3.size;
|
|
50455
50482
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50477,13 +50504,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
50477
50504
|
let size;
|
|
50478
50505
|
let mtimeMs;
|
|
50479
50506
|
try {
|
|
50480
|
-
const lstat = await
|
|
50507
|
+
const lstat = await fs54.promises.lstat(resolved);
|
|
50481
50508
|
if (lstat.isSymbolicLink()) {
|
|
50482
|
-
real = await
|
|
50509
|
+
real = await fs54.promises.realpath(resolved);
|
|
50483
50510
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50484
50511
|
return { error: "Path is outside working directory" };
|
|
50485
50512
|
}
|
|
50486
|
-
const stat3 = await
|
|
50513
|
+
const stat3 = await fs54.promises.stat(real);
|
|
50487
50514
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50488
50515
|
size = stat3.size;
|
|
50489
50516
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50532,7 +50559,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
50532
50559
|
|
|
50533
50560
|
// src/files/read/read-file-range-async.ts
|
|
50534
50561
|
init_yield_to_event_loop();
|
|
50535
|
-
import
|
|
50562
|
+
import fs55 from "node:fs";
|
|
50536
50563
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
50537
50564
|
|
|
50538
50565
|
// src/files/read/read-file-range-line-zero.ts
|
|
@@ -50646,8 +50673,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
50646
50673
|
|
|
50647
50674
|
// src/files/read/read-file-range-async.ts
|
|
50648
50675
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
50649
|
-
const fileSize = fileSizeIn ?? (await
|
|
50650
|
-
const fd = await
|
|
50676
|
+
const fileSize = fileSizeIn ?? (await fs55.promises.stat(filePath)).size;
|
|
50677
|
+
const fd = await fs55.promises.open(filePath, "r");
|
|
50651
50678
|
const bufSize = 64 * 1024;
|
|
50652
50679
|
const buf = Buffer.alloc(bufSize);
|
|
50653
50680
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -50748,7 +50775,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
50748
50775
|
}
|
|
50749
50776
|
|
|
50750
50777
|
// src/files/read/read-small-file-range-async.ts
|
|
50751
|
-
import
|
|
50778
|
+
import fs56 from "node:fs";
|
|
50752
50779
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
50753
50780
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
50754
50781
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -50778,7 +50805,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
50778
50805
|
};
|
|
50779
50806
|
}
|
|
50780
50807
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
50781
|
-
const raw =
|
|
50808
|
+
const raw = fs56.readFileSync(filePath, "utf8");
|
|
50782
50809
|
const lines = raw.split(/\r?\n/);
|
|
50783
50810
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50784
50811
|
}
|
|
@@ -50786,28 +50813,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
50786
50813
|
if (isMainThread5) {
|
|
50787
50814
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
50788
50815
|
}
|
|
50789
|
-
const raw = await
|
|
50816
|
+
const raw = await fs56.promises.readFile(filePath, "utf8");
|
|
50790
50817
|
const lines = raw.split(/\r?\n/);
|
|
50791
50818
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50792
50819
|
}
|
|
50793
50820
|
|
|
50794
50821
|
// src/files/read/read-file-buffer-full-async.ts
|
|
50795
50822
|
init_yield_to_event_loop();
|
|
50796
|
-
import
|
|
50823
|
+
import fs57 from "node:fs";
|
|
50797
50824
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
50798
50825
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
50799
50826
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
50800
50827
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
50801
50828
|
if (isMainThread6) {
|
|
50802
|
-
const size2 = knownSize ??
|
|
50829
|
+
const size2 = knownSize ?? fs57.statSync(filePath).size;
|
|
50803
50830
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
50804
50831
|
await yieldToEventLoop();
|
|
50805
|
-
const buffer =
|
|
50832
|
+
const buffer = fs57.readFileSync(filePath);
|
|
50806
50833
|
return { buffer, size: buffer.length };
|
|
50807
50834
|
}
|
|
50808
50835
|
}
|
|
50809
|
-
const size = knownSize ?? (await
|
|
50810
|
-
const fd = await
|
|
50836
|
+
const size = knownSize ?? (await fs57.promises.stat(filePath)).size;
|
|
50837
|
+
const fd = await fs57.promises.open(filePath, "r");
|
|
50811
50838
|
const chunks = [];
|
|
50812
50839
|
let position = 0;
|
|
50813
50840
|
let bytesSinceYield = 0;
|
|
@@ -50910,7 +50937,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
50910
50937
|
}
|
|
50911
50938
|
if (hasRange) {
|
|
50912
50939
|
if (fileSize == null) {
|
|
50913
|
-
const stat3 = await
|
|
50940
|
+
const stat3 = await fs58.promises.stat(resolvedPath);
|
|
50914
50941
|
fileSize = stat3.size;
|
|
50915
50942
|
}
|
|
50916
50943
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -51208,12 +51235,12 @@ function parseOptionalInt2(raw) {
|
|
|
51208
51235
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
51209
51236
|
}
|
|
51210
51237
|
function parseCodeNavParams(url2) {
|
|
51211
|
-
const
|
|
51238
|
+
const path86 = url2.searchParams.get("path") ?? "";
|
|
51212
51239
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
51213
51240
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
51214
51241
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
51215
51242
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
51216
|
-
return { path:
|
|
51243
|
+
return { path: path86, op, line, column };
|
|
51217
51244
|
}
|
|
51218
51245
|
function parseCodeNavPath(url2) {
|
|
51219
51246
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -51793,16 +51820,8 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
51793
51820
|
handleBridgeAgentConfig(msg, deps);
|
|
51794
51821
|
};
|
|
51795
51822
|
|
|
51796
|
-
// src/prompt-turn-queue/
|
|
51797
|
-
|
|
51798
|
-
if (!ws) return false;
|
|
51799
|
-
const wireQueues = {};
|
|
51800
|
-
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
51801
|
-
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
51802
|
-
}
|
|
51803
|
-
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
51804
|
-
return true;
|
|
51805
|
-
}
|
|
51823
|
+
// src/prompt-turn-queue/runner/dispatch-started-prompt-queue-runs.ts
|
|
51824
|
+
init_yield_to_event_loop();
|
|
51806
51825
|
|
|
51807
51826
|
// src/prompt-turn-queue/disk-store.ts
|
|
51808
51827
|
init_cli_database();
|
|
@@ -51894,23 +51913,6 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
51894
51913
|
handleBridgePrompt(msg, deps);
|
|
51895
51914
|
}
|
|
51896
51915
|
|
|
51897
|
-
// src/prompt-turn-queue/runner/queue-selection.ts
|
|
51898
|
-
function pickNextRunnableTurn(turns) {
|
|
51899
|
-
for (const t of turns) {
|
|
51900
|
-
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
51901
|
-
if (t.bridgeServerState === "cancel_requested") continue;
|
|
51902
|
-
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
51903
|
-
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
51904
|
-
continue;
|
|
51905
|
-
}
|
|
51906
|
-
return t;
|
|
51907
|
-
}
|
|
51908
|
-
return null;
|
|
51909
|
-
}
|
|
51910
|
-
function hasRunningTurn(turns) {
|
|
51911
|
-
return turns.some((t) => t.lastCliState === "running");
|
|
51912
|
-
}
|
|
51913
|
-
|
|
51914
51916
|
// src/prompt-turn-queue/runner/run-id-queue-key-map.ts
|
|
51915
51917
|
var runIdToQueueKey = /* @__PURE__ */ new Map();
|
|
51916
51918
|
function getRunIdQueueKey(runId) {
|
|
@@ -51925,37 +51927,184 @@ function deleteRunIdQueueKey(runId) {
|
|
|
51925
51927
|
return queueKey;
|
|
51926
51928
|
}
|
|
51927
51929
|
function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
51928
|
-
for (const
|
|
51929
|
-
runIdToQueueKey.set(
|
|
51930
|
+
for (const running2 of turns.filter((t) => t.lastCliState === "running")) {
|
|
51931
|
+
runIdToQueueKey.set(running2.turnId, queueKey);
|
|
51930
51932
|
}
|
|
51931
51933
|
}
|
|
51932
51934
|
|
|
51935
|
+
// src/prompt-turn-queue/runner/dispatch-started-prompt-queue-runs.ts
|
|
51936
|
+
async function dispatchStartedPromptQueueRuns(entries, started, deps) {
|
|
51937
|
+
for (const [queueKey] of entries) {
|
|
51938
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
51939
|
+
const running2 = file2?.turns.find((turn) => turn.lastCliState === "running");
|
|
51940
|
+
if (running2 && started.has(running2.turnId) && getRunIdQueueKey(running2.turnId) === queueKey) {
|
|
51941
|
+
dispatchLocalPrompt(running2, deps);
|
|
51942
|
+
}
|
|
51943
|
+
await yieldToEventLoop();
|
|
51944
|
+
}
|
|
51945
|
+
}
|
|
51946
|
+
|
|
51947
|
+
// src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
51948
|
+
init_yield_to_event_loop();
|
|
51949
|
+
|
|
51950
|
+
// src/prompt-turn-queue/client-report.ts
|
|
51951
|
+
function sendPromptQueueClientReport(ws, queues) {
|
|
51952
|
+
if (!ws) return false;
|
|
51953
|
+
const wireQueues = {};
|
|
51954
|
+
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
51955
|
+
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
51956
|
+
}
|
|
51957
|
+
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
51958
|
+
return true;
|
|
51959
|
+
}
|
|
51960
|
+
|
|
51961
|
+
// src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
51962
|
+
async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
51963
|
+
if (!runId) return false;
|
|
51964
|
+
const queueKey = deleteRunIdQueueKey(runId);
|
|
51965
|
+
if (!queueKey) return false;
|
|
51966
|
+
const f = await readPersistedQueue(queueKey);
|
|
51967
|
+
if (!f) return false;
|
|
51968
|
+
const t = f.turns.find((x) => x.turnId === runId);
|
|
51969
|
+
if (!t) return false;
|
|
51970
|
+
t.lastCliState = opts?.terminalCliState ?? (success2 ? "stopped" : "failed");
|
|
51971
|
+
await writePersistedQueue(f);
|
|
51972
|
+
sendPromptQueueClientReport(getWs(), { [queueKey]: [{ turnId: runId, cliState: t.lastCliState }] });
|
|
51973
|
+
return true;
|
|
51974
|
+
}
|
|
51975
|
+
|
|
51976
|
+
// src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
51977
|
+
async function handlePromptQueueCancellations(entries, deps) {
|
|
51978
|
+
for (const [queueKey] of entries) {
|
|
51979
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
51980
|
+
const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
|
|
51981
|
+
if (!turn) {
|
|
51982
|
+
await yieldToEventLoop();
|
|
51983
|
+
continue;
|
|
51984
|
+
}
|
|
51985
|
+
deps.log(`[Queue] Cancellation request received for turn ${turn.turnId.slice(0, 8)}\u2026`);
|
|
51986
|
+
if (await deps.acpManager.cancelRun(turn.turnId)) {
|
|
51987
|
+
await yieldToEventLoop();
|
|
51988
|
+
continue;
|
|
51989
|
+
}
|
|
51990
|
+
deps.log(`[Queue] cancel_requested for ${turn.turnId.slice(0, 8)}\u2026 with no local run; marking cancelled.`);
|
|
51991
|
+
await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
|
|
51992
|
+
const ws = deps.getWs();
|
|
51993
|
+
if (ws && turn.sessionId) {
|
|
51994
|
+
sendWsMessage(ws, {
|
|
51995
|
+
type: "prompt_result",
|
|
51996
|
+
sessionId: turn.sessionId,
|
|
51997
|
+
runId: turn.turnId,
|
|
51998
|
+
success: false,
|
|
51999
|
+
error: "Stopped by user",
|
|
52000
|
+
stopReason: "cancelled"
|
|
52001
|
+
});
|
|
52002
|
+
}
|
|
52003
|
+
await yieldToEventLoop();
|
|
52004
|
+
}
|
|
52005
|
+
}
|
|
52006
|
+
|
|
52007
|
+
// src/prompt-turn-queue/runner/persist-prompt-queue-snapshot.ts
|
|
52008
|
+
init_yield_to_event_loop();
|
|
52009
|
+
async function persistPromptQueueSnapshot(entries) {
|
|
52010
|
+
for (const [queueKey, serverTurns] of entries) {
|
|
52011
|
+
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
52012
|
+
await writePersistedQueue(file2);
|
|
52013
|
+
await yieldToEventLoop();
|
|
52014
|
+
}
|
|
52015
|
+
for (const [queueKey] of entries) {
|
|
52016
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
52017
|
+
if (file2) syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
52018
|
+
await yieldToEventLoop();
|
|
52019
|
+
}
|
|
52020
|
+
}
|
|
52021
|
+
|
|
52022
|
+
// src/prompt-turn-queue/runner/prompt-queue-snapshot-types.ts
|
|
52023
|
+
function promptQueueSnapshotEntries(queues) {
|
|
52024
|
+
return Object.entries(queues).filter((entry) => Array.isArray(entry[1]));
|
|
52025
|
+
}
|
|
52026
|
+
|
|
52027
|
+
// src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
52028
|
+
init_yield_to_event_loop();
|
|
52029
|
+
|
|
52030
|
+
// src/prompt-turn-queue/runner/queue-selection.ts
|
|
52031
|
+
function pickNextRunnableTurn(turns) {
|
|
52032
|
+
for (const t of turns) {
|
|
52033
|
+
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
52034
|
+
if (t.bridgeServerState === "cancel_requested") continue;
|
|
52035
|
+
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
52036
|
+
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
52037
|
+
continue;
|
|
52038
|
+
}
|
|
52039
|
+
return t;
|
|
52040
|
+
}
|
|
52041
|
+
return null;
|
|
52042
|
+
}
|
|
52043
|
+
function hasRunningTurn(turns) {
|
|
52044
|
+
return turns.some((t) => t.lastCliState === "running");
|
|
52045
|
+
}
|
|
52046
|
+
|
|
51933
52047
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
51934
|
-
import
|
|
52048
|
+
import fs61 from "node:fs";
|
|
51935
52049
|
|
|
51936
52050
|
// src/git/snapshot/capture.ts
|
|
51937
|
-
import * as
|
|
51938
|
-
import * as
|
|
52051
|
+
import * as fs60 from "node:fs";
|
|
52052
|
+
import * as path81 from "node:path";
|
|
52053
|
+
|
|
52054
|
+
// src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
52055
|
+
import * as fs59 from "node:fs";
|
|
52056
|
+
async function applyPreTurnSnapshot(filePath, log2) {
|
|
52057
|
+
let data;
|
|
52058
|
+
try {
|
|
52059
|
+
data = JSON.parse(fs59.readFileSync(filePath, "utf8"));
|
|
52060
|
+
} catch (error40) {
|
|
52061
|
+
return { ok: false, error: error40 instanceof Error ? error40.message : String(error40) };
|
|
52062
|
+
}
|
|
52063
|
+
if (!Array.isArray(data.repos)) return { ok: false, error: "Invalid snapshot file" };
|
|
52064
|
+
let applyError = null;
|
|
52065
|
+
await forEachWithGitYield(data.repos, async (repo) => {
|
|
52066
|
+
if (applyError || !repo.path) return;
|
|
52067
|
+
const reset = await gitRun(repo.path, ["reset", "--hard", "HEAD"], log2, "reset --hard");
|
|
52068
|
+
if (!reset.ok) {
|
|
52069
|
+
applyError = reset;
|
|
52070
|
+
return;
|
|
52071
|
+
}
|
|
52072
|
+
const clean = await gitRun(repo.path, ["clean", "-fd"], log2, "clean -fd");
|
|
52073
|
+
if (!clean.ok) {
|
|
52074
|
+
applyError = clean;
|
|
52075
|
+
return;
|
|
52076
|
+
}
|
|
52077
|
+
if (repo.stashSha) {
|
|
52078
|
+
const applied = await gitRun(repo.path, ["stash", "apply", repo.stashSha], log2, "stash apply");
|
|
52079
|
+
if (!applied.ok) applyError = applied;
|
|
52080
|
+
}
|
|
52081
|
+
});
|
|
52082
|
+
if (applyError) return applyError;
|
|
52083
|
+
log2(`[snapshot] Restored pre-turn state for ${data.runId.slice(0, 8)}\u2026`);
|
|
52084
|
+
return { ok: true };
|
|
52085
|
+
}
|
|
52086
|
+
|
|
52087
|
+
// src/git/snapshot/resolve-repo-roots.ts
|
|
52088
|
+
import * as path80 from "node:path";
|
|
51939
52089
|
async function resolveSnapshotRepoRoots(options) {
|
|
51940
52090
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
51941
52091
|
if (worktreePaths?.length) {
|
|
51942
|
-
const
|
|
51943
|
-
return
|
|
52092
|
+
const paths = [...new Set(worktreePaths.map((p) => path80.resolve(p)))];
|
|
52093
|
+
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
51944
52094
|
}
|
|
51945
52095
|
try {
|
|
51946
|
-
const
|
|
51947
|
-
const mapped = repos.map((r) => r.absolutePath);
|
|
52096
|
+
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
51948
52097
|
const sid = sessionId?.trim();
|
|
51949
|
-
if (sid)
|
|
51950
|
-
|
|
51951
|
-
|
|
51952
|
-
|
|
51953
|
-
|
|
51954
|
-
} catch (e) {
|
|
51955
|
-
log2(`[snapshot] Discover repositories failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
52098
|
+
if (!sid) return roots;
|
|
52099
|
+
const sessionRoots = roots.filter((root) => path80.basename(root) === sid);
|
|
52100
|
+
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
52101
|
+
} catch (error40) {
|
|
52102
|
+
log2(`[snapshot] Discover repositories failed: ${error40 instanceof Error ? error40.message : String(error40)}`);
|
|
51956
52103
|
return [];
|
|
51957
52104
|
}
|
|
51958
52105
|
}
|
|
52106
|
+
|
|
52107
|
+
// src/git/snapshot/capture.ts
|
|
51959
52108
|
async function capturePreTurnSnapshot(options) {
|
|
51960
52109
|
const { runId, repoRoots, agentCwd, log: log2 } = options;
|
|
51961
52110
|
if (!runId || !repoRoots.length) {
|
|
@@ -51969,7 +52118,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51969
52118
|
});
|
|
51970
52119
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
51971
52120
|
try {
|
|
51972
|
-
|
|
52121
|
+
fs60.mkdirSync(dir, { recursive: true });
|
|
51973
52122
|
} catch (e) {
|
|
51974
52123
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51975
52124
|
}
|
|
@@ -51978,9 +52127,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51978
52127
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51979
52128
|
repos
|
|
51980
52129
|
};
|
|
51981
|
-
const filePath =
|
|
52130
|
+
const filePath = path81.join(dir, `${runId}.json`);
|
|
51982
52131
|
try {
|
|
51983
|
-
|
|
52132
|
+
fs60.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
51984
52133
|
} catch (e) {
|
|
51985
52134
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51986
52135
|
}
|
|
@@ -51990,39 +52139,6 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51990
52139
|
);
|
|
51991
52140
|
return { ok: true, filePath, repos };
|
|
51992
52141
|
}
|
|
51993
|
-
async function applyPreTurnSnapshot(filePath, log2) {
|
|
51994
|
-
let data;
|
|
51995
|
-
try {
|
|
51996
|
-
const raw = fs58.readFileSync(filePath, "utf8");
|
|
51997
|
-
data = JSON.parse(raw);
|
|
51998
|
-
} catch (e) {
|
|
51999
|
-
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
52000
|
-
}
|
|
52001
|
-
if (!Array.isArray(data.repos)) {
|
|
52002
|
-
return { ok: false, error: "Invalid snapshot file" };
|
|
52003
|
-
}
|
|
52004
|
-
let applyError = null;
|
|
52005
|
-
await forEachWithGitYield(data.repos, async (r) => {
|
|
52006
|
-
if (applyError || !r.path) return;
|
|
52007
|
-
const reset = await gitRun(r.path, ["reset", "--hard", "HEAD"], log2, "reset --hard");
|
|
52008
|
-
if (!reset.ok) {
|
|
52009
|
-
applyError = reset;
|
|
52010
|
-
return;
|
|
52011
|
-
}
|
|
52012
|
-
const clean = await gitRun(r.path, ["clean", "-fd"], log2, "clean -fd");
|
|
52013
|
-
if (!clean.ok) {
|
|
52014
|
-
applyError = clean;
|
|
52015
|
-
return;
|
|
52016
|
-
}
|
|
52017
|
-
if (r.stashSha) {
|
|
52018
|
-
const ap = await gitRun(r.path, ["stash", "apply", r.stashSha], log2, "stash apply");
|
|
52019
|
-
if (!ap.ok) applyError = ap;
|
|
52020
|
-
}
|
|
52021
|
-
});
|
|
52022
|
-
if (applyError) return applyError;
|
|
52023
|
-
log2(`[snapshot] Restored pre-turn state for ${data.runId.slice(0, 8)}\u2026`);
|
|
52024
|
-
return { ok: true };
|
|
52025
|
-
}
|
|
52026
52142
|
|
|
52027
52143
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
52028
52144
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
@@ -52033,7 +52149,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
52033
52149
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
52034
52150
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
52035
52151
|
try {
|
|
52036
|
-
await
|
|
52152
|
+
await fs61.promises.access(file2, fs61.constants.F_OK);
|
|
52037
52153
|
} catch {
|
|
52038
52154
|
deps.log(
|
|
52039
52155
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -52047,96 +52163,41 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
52047
52163
|
return res.ok;
|
|
52048
52164
|
}
|
|
52049
52165
|
|
|
52050
|
-
// src/prompt-turn-queue/runner/
|
|
52051
|
-
async function
|
|
52052
|
-
if (!runId) return false;
|
|
52053
|
-
const queueKey = deleteRunIdQueueKey(runId);
|
|
52054
|
-
if (!queueKey) return false;
|
|
52055
|
-
const f = await readPersistedQueue(queueKey);
|
|
52056
|
-
if (!f) return false;
|
|
52057
|
-
const t = f.turns.find((x) => x.turnId === runId);
|
|
52058
|
-
if (!t) return false;
|
|
52059
|
-
t.lastCliState = opts?.terminalCliState ?? (success2 ? "stopped" : "failed");
|
|
52060
|
-
await writePersistedQueue(f);
|
|
52061
|
-
sendPromptQueueClientReport(getWs(), { [queueKey]: [{ turnId: runId, cliState: t.lastCliState }] });
|
|
52062
|
-
return true;
|
|
52063
|
-
}
|
|
52064
|
-
|
|
52065
|
-
// src/prompt-turn-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
52066
|
-
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
52067
|
-
const raw = msg.queues;
|
|
52068
|
-
if (!raw || typeof raw !== "object") return;
|
|
52069
|
-
const getWs = deps.getWs;
|
|
52070
|
-
for (const [queueKey, serverTurns] of Object.entries(raw)) {
|
|
52071
|
-
if (!Array.isArray(serverTurns)) continue;
|
|
52072
|
-
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
52073
|
-
await writePersistedQueue(file2);
|
|
52074
|
-
}
|
|
52075
|
-
for (const [queueKey, serverTurns] of Object.entries(raw)) {
|
|
52076
|
-
if (!Array.isArray(serverTurns)) continue;
|
|
52077
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
52078
|
-
if (!file2) continue;
|
|
52079
|
-
syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
52080
|
-
}
|
|
52081
|
-
for (const [queueKey, serverTurns] of Object.entries(raw)) {
|
|
52082
|
-
if (!Array.isArray(serverTurns)) continue;
|
|
52083
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
52084
|
-
if (!file2) continue;
|
|
52085
|
-
const cancelRow = file2.turns.find((t) => t.bridgeServerState === "cancel_requested" && t.lastCliState === "running");
|
|
52086
|
-
if (cancelRow) {
|
|
52087
|
-
const localCancelHandled = await deps.acpManager.cancelRun(cancelRow.turnId);
|
|
52088
|
-
if (!localCancelHandled) {
|
|
52089
|
-
deps.log(
|
|
52090
|
-
`[Queue] bridge server cancel_requested for ${cancelRow.turnId.slice(0, 8)}\u2026 but no local agent run is active (e.g. after CLI restart); marking cancelled and notifying bridge.`
|
|
52091
|
-
);
|
|
52092
|
-
await finalizePromptTurnOnBridge(deps.getWs, cancelRow.turnId, false, { terminalCliState: "cancelled" });
|
|
52093
|
-
const ws = deps.getWs();
|
|
52094
|
-
if (ws && cancelRow.sessionId) {
|
|
52095
|
-
sendWsMessage(ws, {
|
|
52096
|
-
type: "prompt_result",
|
|
52097
|
-
sessionId: cancelRow.sessionId,
|
|
52098
|
-
runId: cancelRow.turnId,
|
|
52099
|
-
success: false,
|
|
52100
|
-
error: "Stopped by user",
|
|
52101
|
-
stopReason: "cancelled"
|
|
52102
|
-
});
|
|
52103
|
-
}
|
|
52104
|
-
}
|
|
52105
|
-
}
|
|
52106
|
-
}
|
|
52166
|
+
// src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
52167
|
+
async function startPromptQueueRuns(entries, deps) {
|
|
52107
52168
|
const report = {};
|
|
52108
|
-
const
|
|
52109
|
-
for (const [queueKey
|
|
52110
|
-
if (!Array.isArray(serverTurns)) continue;
|
|
52169
|
+
const started = /* @__PURE__ */ new Set();
|
|
52170
|
+
for (const [queueKey] of entries) {
|
|
52111
52171
|
const file2 = await readPersistedQueue(queueKey);
|
|
52112
|
-
if (!file2) continue;
|
|
52113
|
-
if (hasRunningTurn(file2.turns)) continue;
|
|
52172
|
+
if (!file2 || hasRunningTurn(file2.turns)) continue;
|
|
52114
52173
|
const next = pickNextRunnableTurn(file2.turns);
|
|
52115
52174
|
if (!next) continue;
|
|
52116
52175
|
if (!await runLocalRevertBeforeQueuedPrompt(next, deps)) {
|
|
52117
52176
|
next.lastCliState = "failed";
|
|
52118
52177
|
await writePersistedQueue(file2);
|
|
52119
|
-
sendPromptQueueClientReport(getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
52178
|
+
sendPromptQueueClientReport(deps.getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
52120
52179
|
continue;
|
|
52121
52180
|
}
|
|
52122
52181
|
next.lastCliState = "running";
|
|
52123
52182
|
await writePersistedQueue(file2);
|
|
52124
52183
|
setRunIdQueueKey(next.turnId, queueKey);
|
|
52125
|
-
|
|
52184
|
+
started.add(next.turnId);
|
|
52126
52185
|
report[queueKey] = [{ turnId: next.turnId, cliState: "running" }];
|
|
52186
|
+
await yieldToEventLoop();
|
|
52127
52187
|
}
|
|
52128
|
-
if (Object.keys(report).length
|
|
52129
|
-
|
|
52130
|
-
|
|
52131
|
-
|
|
52132
|
-
|
|
52133
|
-
|
|
52134
|
-
|
|
52135
|
-
|
|
52136
|
-
|
|
52137
|
-
|
|
52138
|
-
|
|
52139
|
-
|
|
52188
|
+
if (Object.keys(report).length) sendPromptQueueClientReport(deps.getWs(), report);
|
|
52189
|
+
return started;
|
|
52190
|
+
}
|
|
52191
|
+
|
|
52192
|
+
// src/prompt-turn-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
52193
|
+
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
52194
|
+
const raw = msg.queues;
|
|
52195
|
+
if (!raw || typeof raw !== "object") return;
|
|
52196
|
+
const entries = promptQueueSnapshotEntries(raw);
|
|
52197
|
+
await persistPromptQueueSnapshot(entries);
|
|
52198
|
+
await handlePromptQueueCancellations(entries, deps);
|
|
52199
|
+
const started = await startPromptQueueRuns(entries, deps);
|
|
52200
|
+
await dispatchStartedPromptQueueRuns(entries, started, deps);
|
|
52140
52201
|
}
|
|
52141
52202
|
|
|
52142
52203
|
// src/agents/acp/from-bridge/bridge-prompt-wiring.ts
|
|
@@ -52237,8 +52298,8 @@ async function runBridgePromptPreamble(params) {
|
|
|
52237
52298
|
log: log2
|
|
52238
52299
|
});
|
|
52239
52300
|
if (s && sessionId) {
|
|
52240
|
-
const cliGitBranch = await readGitBranch(effectiveCwd);
|
|
52241
52301
|
const usesWt = sessionWorktreeManager.usesWorktreeSession(sessionId);
|
|
52302
|
+
const cliGitBranch = repoRoots.length > 0 ? await readGitBranch(effectiveCwd) : null;
|
|
52242
52303
|
const isolatedSessionParentPath = sessionWorktreeManager.getIsolatedSessionParentPathForSession(sessionId);
|
|
52243
52304
|
sendWsMessage(s, {
|
|
52244
52305
|
type: "session_git_context_report",
|
|
@@ -52402,10 +52463,34 @@ var handlePromptMessage = (msg, deps) => {
|
|
|
52402
52463
|
handleBridgePrompt(msg, deps);
|
|
52403
52464
|
};
|
|
52404
52465
|
|
|
52466
|
+
// src/prompt-turn-queue/runner/serial-prompt-queue-work.ts
|
|
52467
|
+
var running = false;
|
|
52468
|
+
var latestWork = null;
|
|
52469
|
+
async function drain() {
|
|
52470
|
+
while (latestWork) {
|
|
52471
|
+
const work = latestWork;
|
|
52472
|
+
latestWork = null;
|
|
52473
|
+
await work();
|
|
52474
|
+
}
|
|
52475
|
+
}
|
|
52476
|
+
function enqueueLatestPromptQueueStateWork(work) {
|
|
52477
|
+
latestWork = work;
|
|
52478
|
+
if (running) return;
|
|
52479
|
+
running = true;
|
|
52480
|
+
void drain().finally(() => {
|
|
52481
|
+
running = false;
|
|
52482
|
+
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
52483
|
+
});
|
|
52484
|
+
}
|
|
52485
|
+
|
|
52405
52486
|
// src/routing/handlers/prompt-queue-state.ts
|
|
52406
52487
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
52407
|
-
|
|
52408
|
-
|
|
52488
|
+
enqueueLatestPromptQueueStateWork(async () => {
|
|
52489
|
+
try {
|
|
52490
|
+
await applyPromptQueueStateFromServer(msg, deps);
|
|
52491
|
+
} catch (err) {
|
|
52492
|
+
deps.log(`[Queue] applyPromptQueueStateFromServer failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
52493
|
+
}
|
|
52409
52494
|
});
|
|
52410
52495
|
};
|
|
52411
52496
|
|
|
@@ -52656,7 +52741,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
52656
52741
|
};
|
|
52657
52742
|
|
|
52658
52743
|
// src/routing/handlers/revert-turn-snapshot.ts
|
|
52659
|
-
import * as
|
|
52744
|
+
import * as fs62 from "node:fs";
|
|
52660
52745
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
52661
52746
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
52662
52747
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -52669,7 +52754,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
52669
52754
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
52670
52755
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
52671
52756
|
try {
|
|
52672
|
-
await
|
|
52757
|
+
await fs62.promises.access(file2, fs62.constants.F_OK);
|
|
52673
52758
|
} catch {
|
|
52674
52759
|
sendWsMessage(s, {
|
|
52675
52760
|
type: "revert_turn_snapshot_result",
|
|
@@ -52743,8 +52828,8 @@ function randomSecret() {
|
|
|
52743
52828
|
}
|
|
52744
52829
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
52745
52830
|
}
|
|
52746
|
-
async function requestPreviewApi(port, secret, method,
|
|
52747
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
52831
|
+
async function requestPreviewApi(port, secret, method, path86, body) {
|
|
52832
|
+
const url2 = `http://127.0.0.1:${port}${path86}`;
|
|
52748
52833
|
const headers = {
|
|
52749
52834
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
52750
52835
|
"Content-Type": "application/json"
|
|
@@ -52756,7 +52841,7 @@ async function requestPreviewApi(port, secret, method, path84, body) {
|
|
|
52756
52841
|
});
|
|
52757
52842
|
const data = await res.json().catch(() => ({}));
|
|
52758
52843
|
if (!res.ok) {
|
|
52759
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
52844
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
|
|
52760
52845
|
}
|
|
52761
52846
|
return data;
|
|
52762
52847
|
}
|
|
@@ -52941,8 +53026,8 @@ function isValidRemoteSkillInstallItem(item) {
|
|
|
52941
53026
|
|
|
52942
53027
|
// src/skills/install/install-remote-skills-async.ts
|
|
52943
53028
|
init_yield_to_event_loop();
|
|
52944
|
-
import
|
|
52945
|
-
import
|
|
53029
|
+
import fs63 from "node:fs";
|
|
53030
|
+
import path82 from "node:path";
|
|
52946
53031
|
|
|
52947
53032
|
// src/skills/install/constants.ts
|
|
52948
53033
|
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
@@ -52953,12 +53038,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
|
52953
53038
|
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
52954
53039
|
await yieldToEventLoop();
|
|
52955
53040
|
}
|
|
52956
|
-
const dest =
|
|
52957
|
-
await
|
|
53041
|
+
const dest = path82.join(skillDir, f.path);
|
|
53042
|
+
await fs63.promises.mkdir(path82.dirname(dest), { recursive: true });
|
|
52958
53043
|
if (f.text !== void 0) {
|
|
52959
|
-
await
|
|
53044
|
+
await fs63.promises.writeFile(dest, f.text, "utf8");
|
|
52960
53045
|
} else if (f.base64) {
|
|
52961
|
-
await
|
|
53046
|
+
await fs63.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
|
|
52962
53047
|
}
|
|
52963
53048
|
}
|
|
52964
53049
|
async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
@@ -52970,7 +53055,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
|
52970
53055
|
try {
|
|
52971
53056
|
for (const item of items) {
|
|
52972
53057
|
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
52973
|
-
const skillDir =
|
|
53058
|
+
const skillDir = path82.join(cwd, targetDir, item.skillName);
|
|
52974
53059
|
for (const f of item.files) {
|
|
52975
53060
|
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
52976
53061
|
}
|
|
@@ -53277,13 +53362,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
53277
53362
|
|
|
53278
53363
|
// src/files/handle-file-browser-search.ts
|
|
53279
53364
|
init_yield_to_event_loop();
|
|
53280
|
-
import
|
|
53365
|
+
import path83 from "node:path";
|
|
53281
53366
|
var SEARCH_LIMIT = 100;
|
|
53282
53367
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
53283
53368
|
void (async () => {
|
|
53284
53369
|
await yieldToEventLoop();
|
|
53285
53370
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
53286
|
-
const sessionParentPath =
|
|
53371
|
+
const sessionParentPath = path83.resolve(
|
|
53287
53372
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
53288
53373
|
);
|
|
53289
53374
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -53381,7 +53466,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
53381
53466
|
}
|
|
53382
53467
|
|
|
53383
53468
|
// src/git/bridge-git-context.ts
|
|
53384
|
-
import * as
|
|
53469
|
+
import * as path84 from "node:path";
|
|
53385
53470
|
init_yield_to_event_loop();
|
|
53386
53471
|
|
|
53387
53472
|
// src/git/branches/get-current-branch.ts
|
|
@@ -53432,12 +53517,12 @@ async function listRepoBranchRefs(repoPath) {
|
|
|
53432
53517
|
// src/git/bridge-git-context.ts
|
|
53433
53518
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
53434
53519
|
if (relPath === "." || relPath === "") {
|
|
53435
|
-
return
|
|
53520
|
+
return path84.basename(path84.resolve(bridgeRoot)) || "repo";
|
|
53436
53521
|
}
|
|
53437
|
-
return
|
|
53522
|
+
return path84.basename(relPath) || relPath;
|
|
53438
53523
|
}
|
|
53439
53524
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
53440
|
-
const root =
|
|
53525
|
+
const root = path84.resolve(bridgeRoot);
|
|
53441
53526
|
if (await isGitRepoDirectory(root)) {
|
|
53442
53527
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
53443
53528
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -53445,19 +53530,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
53445
53530
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
53446
53531
|
const byPath = /* @__PURE__ */ new Map();
|
|
53447
53532
|
for (const repo of [...deep, ...shallow]) {
|
|
53448
|
-
byPath.set(
|
|
53533
|
+
byPath.set(path84.resolve(repo.absolutePath), repo);
|
|
53449
53534
|
}
|
|
53450
53535
|
return [...byPath.values()];
|
|
53451
53536
|
}
|
|
53452
53537
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
53453
|
-
const bridgeResolved =
|
|
53538
|
+
const bridgeResolved = path84.resolve(bridgeRoot);
|
|
53454
53539
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
53455
53540
|
const rows = [];
|
|
53456
53541
|
for (let i = 0; i < repos.length; i++) {
|
|
53457
53542
|
if (i > 0) await yieldToEventLoop();
|
|
53458
53543
|
const repo = repos[i];
|
|
53459
|
-
let rel =
|
|
53460
|
-
if (rel.startsWith("..") ||
|
|
53544
|
+
let rel = path84.relative(bridgeResolved, repo.absolutePath);
|
|
53545
|
+
if (rel.startsWith("..") || path84.isAbsolute(rel)) continue;
|
|
53461
53546
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
53462
53547
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
53463
53548
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -53472,11 +53557,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
53472
53557
|
return rows;
|
|
53473
53558
|
}
|
|
53474
53559
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
53475
|
-
const bridgeResolved =
|
|
53560
|
+
const bridgeResolved = path84.resolve(bridgeRoot);
|
|
53476
53561
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
53477
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
53478
|
-
const resolved =
|
|
53479
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
53562
|
+
const repoPath = rel === "" ? bridgeResolved : path84.join(bridgeResolved, rel);
|
|
53563
|
+
const resolved = path84.resolve(repoPath);
|
|
53564
|
+
if (!resolved.startsWith(bridgeResolved + path84.sep) && resolved !== bridgeResolved) {
|
|
53480
53565
|
return [];
|
|
53481
53566
|
}
|
|
53482
53567
|
return listRepoBranchRefs(resolved);
|
|
@@ -54140,9 +54225,9 @@ async function runCliAction(program2, opts) {
|
|
|
54140
54225
|
const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
|
|
54141
54226
|
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);
|
|
54142
54227
|
if (bridgeRootOpt) {
|
|
54143
|
-
const resolvedBridgeRoot =
|
|
54228
|
+
const resolvedBridgeRoot = path85.resolve(process.cwd(), bridgeRootOpt);
|
|
54144
54229
|
try {
|
|
54145
|
-
const st =
|
|
54230
|
+
const st = fs64.statSync(resolvedBridgeRoot);
|
|
54146
54231
|
if (!st.isDirectory()) {
|
|
54147
54232
|
console.error(`Bridge root is not a directory: ${resolvedBridgeRoot}`);
|
|
54148
54233
|
process.exit(1);
|
|
@@ -54162,7 +54247,7 @@ async function runCliAction(program2, opts) {
|
|
|
54162
54247
|
);
|
|
54163
54248
|
let worktreesRootPath;
|
|
54164
54249
|
if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
|
|
54165
|
-
worktreesRootPath =
|
|
54250
|
+
worktreesRootPath = path85.resolve(opts.worktreesRoot.trim());
|
|
54166
54251
|
}
|
|
54167
54252
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
54168
54253
|
if (e2eCertificates) {
|