@buildautomaton/cli 0.1.74 → 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 +396 -390
- package/dist/cli.js.map +4 -4
- package/dist/index.js +375 -369
- 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.
|
|
@@ -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";
|
|
@@ -38065,8 +38065,8 @@ async function execGitFile(args, options) {
|
|
|
38065
38065
|
}
|
|
38066
38066
|
|
|
38067
38067
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
38068
|
-
function normalizeGitDiffPath(
|
|
38069
|
-
return
|
|
38068
|
+
function normalizeGitDiffPath(path86) {
|
|
38069
|
+
return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
38070
38070
|
}
|
|
38071
38071
|
|
|
38072
38072
|
// src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -42360,8 +42360,8 @@ function pathspec(...paths) {
|
|
|
42360
42360
|
cache.set(key, paths);
|
|
42361
42361
|
return key;
|
|
42362
42362
|
}
|
|
42363
|
-
function isPathSpec(
|
|
42364
|
-
return
|
|
42363
|
+
function isPathSpec(path86) {
|
|
42364
|
+
return path86 instanceof String && cache.has(path86);
|
|
42365
42365
|
}
|
|
42366
42366
|
function toPaths(pathSpec) {
|
|
42367
42367
|
return cache.get(pathSpec) || [];
|
|
@@ -42450,8 +42450,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
42450
42450
|
function forEachLineWithContent(input, callback) {
|
|
42451
42451
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
42452
42452
|
}
|
|
42453
|
-
function folderExists(
|
|
42454
|
-
return (0, import_file_exists.exists)(
|
|
42453
|
+
function folderExists(path86) {
|
|
42454
|
+
return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
|
|
42455
42455
|
}
|
|
42456
42456
|
function append(target, item) {
|
|
42457
42457
|
if (Array.isArray(target)) {
|
|
@@ -42855,8 +42855,8 @@ function checkIsRepoRootTask() {
|
|
|
42855
42855
|
commands,
|
|
42856
42856
|
format: "utf-8",
|
|
42857
42857
|
onError,
|
|
42858
|
-
parser(
|
|
42859
|
-
return /^\.(git)?$/.test(
|
|
42858
|
+
parser(path86) {
|
|
42859
|
+
return /^\.(git)?$/.test(path86.trim());
|
|
42860
42860
|
}
|
|
42861
42861
|
};
|
|
42862
42862
|
}
|
|
@@ -43290,11 +43290,11 @@ function parseGrep(grep) {
|
|
|
43290
43290
|
const paths = /* @__PURE__ */ new Set();
|
|
43291
43291
|
const results = {};
|
|
43292
43292
|
forEachLineWithContent(grep, (input) => {
|
|
43293
|
-
const [
|
|
43294
|
-
paths.add(
|
|
43295
|
-
(results[
|
|
43293
|
+
const [path86, line, preview] = input.split(NULL);
|
|
43294
|
+
paths.add(path86);
|
|
43295
|
+
(results[path86] = results[path86] || []).push({
|
|
43296
43296
|
line: asNumber(line),
|
|
43297
|
-
path:
|
|
43297
|
+
path: path86,
|
|
43298
43298
|
preview
|
|
43299
43299
|
});
|
|
43300
43300
|
});
|
|
@@ -44059,14 +44059,14 @@ var init_hash_object = __esm2({
|
|
|
44059
44059
|
init_task();
|
|
44060
44060
|
}
|
|
44061
44061
|
});
|
|
44062
|
-
function parseInit(bare,
|
|
44062
|
+
function parseInit(bare, path86, text) {
|
|
44063
44063
|
const response = String(text).trim();
|
|
44064
44064
|
let result;
|
|
44065
44065
|
if (result = initResponseRegex.exec(response)) {
|
|
44066
|
-
return new InitSummary(bare,
|
|
44066
|
+
return new InitSummary(bare, path86, false, result[1]);
|
|
44067
44067
|
}
|
|
44068
44068
|
if (result = reInitResponseRegex.exec(response)) {
|
|
44069
|
-
return new InitSummary(bare,
|
|
44069
|
+
return new InitSummary(bare, path86, true, result[1]);
|
|
44070
44070
|
}
|
|
44071
44071
|
let gitDir = "";
|
|
44072
44072
|
const tokens = response.split(" ");
|
|
@@ -44077,7 +44077,7 @@ function parseInit(bare, path84, text) {
|
|
|
44077
44077
|
break;
|
|
44078
44078
|
}
|
|
44079
44079
|
}
|
|
44080
|
-
return new InitSummary(bare,
|
|
44080
|
+
return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
|
|
44081
44081
|
}
|
|
44082
44082
|
var InitSummary;
|
|
44083
44083
|
var initResponseRegex;
|
|
@@ -44086,9 +44086,9 @@ var init_InitSummary = __esm2({
|
|
|
44086
44086
|
"src/lib/responses/InitSummary.ts"() {
|
|
44087
44087
|
"use strict";
|
|
44088
44088
|
InitSummary = class {
|
|
44089
|
-
constructor(bare,
|
|
44089
|
+
constructor(bare, path86, existing, gitDir) {
|
|
44090
44090
|
this.bare = bare;
|
|
44091
|
-
this.path =
|
|
44091
|
+
this.path = path86;
|
|
44092
44092
|
this.existing = existing;
|
|
44093
44093
|
this.gitDir = gitDir;
|
|
44094
44094
|
}
|
|
@@ -44100,7 +44100,7 @@ var init_InitSummary = __esm2({
|
|
|
44100
44100
|
function hasBareCommand(command) {
|
|
44101
44101
|
return command.includes(bareCommand);
|
|
44102
44102
|
}
|
|
44103
|
-
function initTask(bare = false,
|
|
44103
|
+
function initTask(bare = false, path86, customArgs) {
|
|
44104
44104
|
const commands = ["init", ...customArgs];
|
|
44105
44105
|
if (bare && !hasBareCommand(commands)) {
|
|
44106
44106
|
commands.splice(1, 0, bareCommand);
|
|
@@ -44109,7 +44109,7 @@ function initTask(bare = false, path84, customArgs) {
|
|
|
44109
44109
|
commands,
|
|
44110
44110
|
format: "utf-8",
|
|
44111
44111
|
parser(text) {
|
|
44112
|
-
return parseInit(commands.includes("--bare"),
|
|
44112
|
+
return parseInit(commands.includes("--bare"), path86, text);
|
|
44113
44113
|
}
|
|
44114
44114
|
};
|
|
44115
44115
|
}
|
|
@@ -44925,12 +44925,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
44925
44925
|
"use strict";
|
|
44926
44926
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
44927
44927
|
FileStatusSummary = class {
|
|
44928
|
-
constructor(
|
|
44929
|
-
this.path =
|
|
44928
|
+
constructor(path86, index, working_dir) {
|
|
44929
|
+
this.path = path86;
|
|
44930
44930
|
this.index = index;
|
|
44931
44931
|
this.working_dir = working_dir;
|
|
44932
44932
|
if (index === "R" || working_dir === "R") {
|
|
44933
|
-
const detail = fromPathRegex.exec(
|
|
44933
|
+
const detail = fromPathRegex.exec(path86) || [null, path86, path86];
|
|
44934
44934
|
this.from = detail[2] || "";
|
|
44935
44935
|
this.path = detail[1] || "";
|
|
44936
44936
|
}
|
|
@@ -44961,14 +44961,14 @@ function splitLine(result, lineStr) {
|
|
|
44961
44961
|
default:
|
|
44962
44962
|
return;
|
|
44963
44963
|
}
|
|
44964
|
-
function data(index, workingDir,
|
|
44964
|
+
function data(index, workingDir, path86) {
|
|
44965
44965
|
const raw = `${index}${workingDir}`;
|
|
44966
44966
|
const handler = parsers6.get(raw);
|
|
44967
44967
|
if (handler) {
|
|
44968
|
-
handler(result,
|
|
44968
|
+
handler(result, path86);
|
|
44969
44969
|
}
|
|
44970
44970
|
if (raw !== "##" && raw !== "!!") {
|
|
44971
|
-
result.files.push(new FileStatusSummary(
|
|
44971
|
+
result.files.push(new FileStatusSummary(path86, index, workingDir));
|
|
44972
44972
|
}
|
|
44973
44973
|
}
|
|
44974
44974
|
}
|
|
@@ -45277,9 +45277,9 @@ var init_simple_git_api = __esm2({
|
|
|
45277
45277
|
next
|
|
45278
45278
|
);
|
|
45279
45279
|
}
|
|
45280
|
-
hashObject(
|
|
45280
|
+
hashObject(path86, write) {
|
|
45281
45281
|
return this._runTask(
|
|
45282
|
-
hashObjectTask(
|
|
45282
|
+
hashObjectTask(path86, write === true),
|
|
45283
45283
|
trailingFunctionArgument(arguments)
|
|
45284
45284
|
);
|
|
45285
45285
|
}
|
|
@@ -45632,8 +45632,8 @@ var init_branch = __esm2({
|
|
|
45632
45632
|
}
|
|
45633
45633
|
});
|
|
45634
45634
|
function toPath(input) {
|
|
45635
|
-
const
|
|
45636
|
-
return
|
|
45635
|
+
const path86 = input.trim().replace(/^["']|["']$/g, "");
|
|
45636
|
+
return path86 && normalize3(path86);
|
|
45637
45637
|
}
|
|
45638
45638
|
var parseCheckIgnore;
|
|
45639
45639
|
var init_CheckIgnore = __esm2({
|
|
@@ -45947,8 +45947,8 @@ __export2(sub_module_exports, {
|
|
|
45947
45947
|
subModuleTask: () => subModuleTask,
|
|
45948
45948
|
updateSubModuleTask: () => updateSubModuleTask
|
|
45949
45949
|
});
|
|
45950
|
-
function addSubModuleTask(repo,
|
|
45951
|
-
return subModuleTask(["add", repo,
|
|
45950
|
+
function addSubModuleTask(repo, path86) {
|
|
45951
|
+
return subModuleTask(["add", repo, path86]);
|
|
45952
45952
|
}
|
|
45953
45953
|
function initSubModuleTask(customArgs) {
|
|
45954
45954
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -46281,8 +46281,8 @@ var require_git = __commonJS2({
|
|
|
46281
46281
|
}
|
|
46282
46282
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
46283
46283
|
};
|
|
46284
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
46285
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
46284
|
+
Git2.prototype.submoduleAdd = function(repo, path86, then) {
|
|
46285
|
+
return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
|
|
46286
46286
|
};
|
|
46287
46287
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
46288
46288
|
return this._runTask(
|
|
@@ -47021,8 +47021,8 @@ function parseNumstatEntries(lines) {
|
|
|
47021
47021
|
}
|
|
47022
47022
|
function parseNumstat(lines) {
|
|
47023
47023
|
const m = /* @__PURE__ */ new Map();
|
|
47024
|
-
for (const [
|
|
47025
|
-
m.set(
|
|
47024
|
+
for (const [path86, entry] of parseNumstatEntries(lines)) {
|
|
47025
|
+
m.set(path86, { additions: entry.additions, deletions: entry.deletions });
|
|
47026
47026
|
}
|
|
47027
47027
|
return m;
|
|
47028
47028
|
}
|
|
@@ -47305,23 +47305,26 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
47305
47305
|
}
|
|
47306
47306
|
|
|
47307
47307
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
47308
|
-
import * as
|
|
47308
|
+
import * as path53 from "node:path";
|
|
47309
47309
|
|
|
47310
47310
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
47311
|
-
import * as
|
|
47311
|
+
import * as path52 from "node:path";
|
|
47312
47312
|
|
|
47313
47313
|
// src/git/is-git-repo.ts
|
|
47314
|
+
import * as fs33 from "node:fs";
|
|
47315
|
+
import * as path44 from "node:path";
|
|
47314
47316
|
async function isGitRepoDirectory(dirPath) {
|
|
47315
47317
|
try {
|
|
47316
|
-
|
|
47318
|
+
await fs33.promises.access(path44.join(dirPath, ".git"));
|
|
47319
|
+
return true;
|
|
47317
47320
|
} catch {
|
|
47318
47321
|
return false;
|
|
47319
47322
|
}
|
|
47320
47323
|
}
|
|
47321
47324
|
|
|
47322
47325
|
// src/git/changes/listing/apply-untracked-file-stats.ts
|
|
47323
|
-
import * as
|
|
47324
|
-
import * as
|
|
47326
|
+
import * as fs34 from "node:fs";
|
|
47327
|
+
import * as path45 from "node:path";
|
|
47325
47328
|
|
|
47326
47329
|
// src/git/changes/lines/count-lines.ts
|
|
47327
47330
|
import { createReadStream } from "node:fs";
|
|
@@ -47353,7 +47356,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
47353
47356
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
47354
47357
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
47355
47358
|
if (row.change === "moved") return;
|
|
47356
|
-
const repoFilePath =
|
|
47359
|
+
const repoFilePath = path45.join(options.repoGitCwd, pathInRepo);
|
|
47357
47360
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
47358
47361
|
if (fromGit) {
|
|
47359
47362
|
row.additions = fromGit.additions;
|
|
@@ -47361,7 +47364,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
47361
47364
|
return;
|
|
47362
47365
|
}
|
|
47363
47366
|
try {
|
|
47364
|
-
const st = await
|
|
47367
|
+
const st = await fs34.promises.stat(repoFilePath);
|
|
47365
47368
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
47366
47369
|
} catch {
|
|
47367
47370
|
row.additions = 0;
|
|
@@ -47438,7 +47441,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
47438
47441
|
}
|
|
47439
47442
|
|
|
47440
47443
|
// src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
47441
|
-
import * as
|
|
47444
|
+
import * as path47 from "node:path";
|
|
47442
47445
|
|
|
47443
47446
|
// src/git/changes/patch/patch-truncate.ts
|
|
47444
47447
|
function truncatePatch(s) {
|
|
@@ -47526,10 +47529,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
47526
47529
|
}
|
|
47527
47530
|
|
|
47528
47531
|
// src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
47529
|
-
import * as
|
|
47532
|
+
import * as fs35 from "node:fs";
|
|
47530
47533
|
async function readWorktreeFileLines(filePath) {
|
|
47531
47534
|
try {
|
|
47532
|
-
const raw = await
|
|
47535
|
+
const raw = await fs35.promises.readFile(filePath, "utf8");
|
|
47533
47536
|
return raw.split(/\r?\n/);
|
|
47534
47537
|
} catch {
|
|
47535
47538
|
return null;
|
|
@@ -47667,8 +47670,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
47667
47670
|
}
|
|
47668
47671
|
|
|
47669
47672
|
// src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
47670
|
-
import * as
|
|
47671
|
-
import * as
|
|
47673
|
+
import * as fs36 from "node:fs";
|
|
47674
|
+
import * as path46 from "node:path";
|
|
47672
47675
|
var MAX_BYTES = 512e3;
|
|
47673
47676
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
47674
47677
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -47688,13 +47691,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
47688
47691
|
}
|
|
47689
47692
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
47690
47693
|
if (options.isBinary) return null;
|
|
47691
|
-
const filePath =
|
|
47694
|
+
const filePath = path46.join(options.repoGitCwd, options.pathInRepo);
|
|
47692
47695
|
if (options.change === "removed") {
|
|
47693
47696
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
47694
47697
|
}
|
|
47695
47698
|
if (options.change === "moved" || options.change === "modified") {
|
|
47696
47699
|
try {
|
|
47697
|
-
const st = await
|
|
47700
|
+
const st = await fs36.promises.stat(filePath);
|
|
47698
47701
|
if (!st.isFile()) return null;
|
|
47699
47702
|
return await countTextFileLines(filePath);
|
|
47700
47703
|
} catch {
|
|
@@ -47737,7 +47740,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
47737
47740
|
row.workspaceRelPath,
|
|
47738
47741
|
options.repoPathRelativeToWorkspaceRoot
|
|
47739
47742
|
);
|
|
47740
|
-
const filePath =
|
|
47743
|
+
const filePath = path47.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
47741
47744
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
47742
47745
|
let patch = await unifiedDiffForFile(
|
|
47743
47746
|
options.repoGitCwd,
|
|
@@ -47895,7 +47898,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
47895
47898
|
}
|
|
47896
47899
|
|
|
47897
47900
|
// src/git/changes/listing/list-changed-files-for-commit.ts
|
|
47898
|
-
import * as
|
|
47901
|
+
import * as path48 from "node:path";
|
|
47899
47902
|
|
|
47900
47903
|
// src/git/changes/listing/enrich-commit-file-rows.ts
|
|
47901
47904
|
async function enrichCommitFileRows(options) {
|
|
@@ -47940,7 +47943,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
47940
47943
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
47941
47944
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
47942
47945
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
47943
|
-
return `${
|
|
47946
|
+
return `${path48.resolve(repoGitCwd)}:${commitSha}`;
|
|
47944
47947
|
}
|
|
47945
47948
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
47946
47949
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -47995,7 +47998,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
47995
47998
|
}
|
|
47996
47999
|
|
|
47997
48000
|
// src/git/commits/list-unpushed-commits.ts
|
|
47998
|
-
import * as
|
|
48001
|
+
import * as path49 from "node:path";
|
|
47999
48002
|
|
|
48000
48003
|
// src/git/commits/lib/parse-log-lines.ts
|
|
48001
48004
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -48030,7 +48033,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
48030
48033
|
}
|
|
48031
48034
|
}
|
|
48032
48035
|
async function listUnpushedCommits(repoDir) {
|
|
48033
|
-
const key =
|
|
48036
|
+
const key = path49.resolve(repoDir);
|
|
48034
48037
|
const now = Date.now();
|
|
48035
48038
|
const cached2 = unpushedCache.get(key);
|
|
48036
48039
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -48091,7 +48094,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
48091
48094
|
}
|
|
48092
48095
|
|
|
48093
48096
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
48094
|
-
import * as
|
|
48097
|
+
import * as path50 from "node:path";
|
|
48095
48098
|
|
|
48096
48099
|
// src/git/remote-origin-url.ts
|
|
48097
48100
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -48106,7 +48109,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
48106
48109
|
|
|
48107
48110
|
// src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
48108
48111
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
48109
|
-
const resolvedCheckoutPath =
|
|
48112
|
+
const resolvedCheckoutPath = path50.resolve(checkoutPath);
|
|
48110
48113
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
48111
48114
|
await yieldToEventLoop2();
|
|
48112
48115
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -48121,14 +48124,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
48121
48124
|
}
|
|
48122
48125
|
|
|
48123
48126
|
// src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
48124
|
-
import * as
|
|
48127
|
+
import * as path51 from "node:path";
|
|
48125
48128
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
48126
|
-
const checkoutPath =
|
|
48129
|
+
const checkoutPath = path51.resolve(options.checkoutPath);
|
|
48127
48130
|
const git = cliSimpleGit(checkoutPath);
|
|
48128
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48131
|
+
const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
|
|
48129
48132
|
let repoPathRelativeToWorkspaceRoot;
|
|
48130
48133
|
if (sessionParentPath) {
|
|
48131
|
-
const checkoutPathRelativeToSessionParent =
|
|
48134
|
+
const checkoutPathRelativeToSessionParent = path51.relative(sessionParentPath, checkoutPath);
|
|
48132
48135
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
48133
48136
|
} else {
|
|
48134
48137
|
let gitTopLevel = checkoutPath;
|
|
@@ -48138,8 +48141,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
48138
48141
|
} catch {
|
|
48139
48142
|
gitTopLevel = checkoutPath;
|
|
48140
48143
|
}
|
|
48141
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
48142
|
-
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;
|
|
48143
48146
|
}
|
|
48144
48147
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48145
48148
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -48148,10 +48151,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
48148
48151
|
|
|
48149
48152
|
// src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
48150
48153
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
48151
|
-
const checkoutPath =
|
|
48154
|
+
const checkoutPath = path52.resolve(options.targetPath);
|
|
48152
48155
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
48153
48156
|
const isCommitView = options.basis.kind === "commit";
|
|
48154
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48157
|
+
const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
|
|
48155
48158
|
const git = cliSimpleGit(checkoutPath);
|
|
48156
48159
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48157
48160
|
checkoutPath,
|
|
@@ -48199,8 +48202,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
48199
48202
|
|
|
48200
48203
|
// src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
48201
48204
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
48202
|
-
const bridgeRoot =
|
|
48203
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
48205
|
+
const bridgeRoot = path53.resolve(getBridgeRoot());
|
|
48206
|
+
const sessionParentPath = options.sessionParentPath ? path53.resolve(options.sessionParentPath) : null;
|
|
48204
48207
|
const out = [];
|
|
48205
48208
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
48206
48209
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -48231,9 +48234,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
48231
48234
|
}
|
|
48232
48235
|
|
|
48233
48236
|
// src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
48234
|
-
import * as
|
|
48237
|
+
import * as path54 from "node:path";
|
|
48235
48238
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
48236
|
-
const repoGitCwd =
|
|
48239
|
+
const repoGitCwd = path54.resolve(options.repoGitCwd);
|
|
48237
48240
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
48238
48241
|
throw new Error("Not a git repository");
|
|
48239
48242
|
}
|
|
@@ -48272,7 +48275,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
48272
48275
|
});
|
|
48273
48276
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
48274
48277
|
}
|
|
48275
|
-
const filePath =
|
|
48278
|
+
const filePath = path54.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
48276
48279
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
48277
48280
|
let patchContent = await unifiedDiffForFile(
|
|
48278
48281
|
repoGitCwd,
|
|
@@ -48318,18 +48321,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
48318
48321
|
}
|
|
48319
48322
|
|
|
48320
48323
|
// src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
48321
|
-
import * as
|
|
48324
|
+
import * as path55 from "node:path";
|
|
48322
48325
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
48323
48326
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
48324
|
-
const bridgeRoot =
|
|
48325
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
48327
|
+
const bridgeRoot = path55.resolve(getBridgeRoot());
|
|
48328
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path55.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
48326
48329
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48327
48330
|
opts.repoRelPath.trim()
|
|
48328
48331
|
);
|
|
48329
48332
|
let result = null;
|
|
48330
48333
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
48331
48334
|
if (result) return;
|
|
48332
|
-
const checkoutPath =
|
|
48335
|
+
const checkoutPath = path55.resolve(targetPath);
|
|
48333
48336
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
48334
48337
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48335
48338
|
checkoutPath,
|
|
@@ -48362,13 +48365,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
48362
48365
|
}
|
|
48363
48366
|
|
|
48364
48367
|
// src/worktrees/remove-session-worktrees.ts
|
|
48365
|
-
import * as
|
|
48368
|
+
import * as fs39 from "node:fs";
|
|
48366
48369
|
|
|
48367
48370
|
// src/git/worktrees/worktree-remove.ts
|
|
48368
|
-
import * as
|
|
48371
|
+
import * as fs38 from "node:fs";
|
|
48369
48372
|
|
|
48370
48373
|
// src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
48371
|
-
import
|
|
48374
|
+
import path56 from "node:path";
|
|
48372
48375
|
init_normalize_resolved_path();
|
|
48373
48376
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
48374
48377
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -48377,23 +48380,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
48377
48380
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
48378
48381
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
48379
48382
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
48380
|
-
const rel =
|
|
48381
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
48383
|
+
const rel = path56.relative(worktreesRoot, normalized);
|
|
48384
|
+
if (rel === "" || rel.startsWith("..") || path56.isAbsolute(rel)) return false;
|
|
48382
48385
|
return true;
|
|
48383
48386
|
}
|
|
48384
48387
|
|
|
48385
48388
|
// src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
48386
|
-
import * as
|
|
48387
|
-
import * as
|
|
48389
|
+
import * as fs37 from "node:fs";
|
|
48390
|
+
import * as path57 from "node:path";
|
|
48388
48391
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
48389
|
-
const gitDirFile =
|
|
48390
|
-
if (!
|
|
48391
|
-
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();
|
|
48392
48395
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
48393
48396
|
if (!m) return "";
|
|
48394
|
-
const gitWorktreePath =
|
|
48395
|
-
const gitDir =
|
|
48396
|
-
return
|
|
48397
|
+
const gitWorktreePath = path57.resolve(wt, m[1].trim());
|
|
48398
|
+
const gitDir = path57.dirname(path57.dirname(gitWorktreePath));
|
|
48399
|
+
return path57.dirname(gitDir);
|
|
48397
48400
|
}
|
|
48398
48401
|
|
|
48399
48402
|
// src/git/worktrees/worktree-remove.ts
|
|
@@ -48404,7 +48407,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
48404
48407
|
return true;
|
|
48405
48408
|
}
|
|
48406
48409
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
48407
|
-
|
|
48410
|
+
fs38.rmSync(worktreePath, { recursive: true, force: true });
|
|
48408
48411
|
return true;
|
|
48409
48412
|
}
|
|
48410
48413
|
|
|
@@ -48426,7 +48429,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
48426
48429
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
48427
48430
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
48428
48431
|
try {
|
|
48429
|
-
|
|
48432
|
+
fs39.rmSync(wt, { recursive: true, force: true });
|
|
48430
48433
|
} catch {
|
|
48431
48434
|
}
|
|
48432
48435
|
}
|
|
@@ -48451,6 +48454,7 @@ async function gitRenameCurrentBranch(repoDir, newName) {
|
|
|
48451
48454
|
async function renameSessionWorktreeBranches(paths, newBranch, log2) {
|
|
48452
48455
|
const safe = newBranch.replace(/[^a-zA-Z0-9/_-]+/g, "-").slice(0, 80) || "session-branch";
|
|
48453
48456
|
await forEachWithGitYield(paths, async (wt) => {
|
|
48457
|
+
if (!await isGitRepoDirectory(wt)) return;
|
|
48454
48458
|
try {
|
|
48455
48459
|
await gitRenameCurrentBranch(wt, safe);
|
|
48456
48460
|
log2(`[worktrees] Renamed branch in ${wt} \u2192 ${safe}`);
|
|
@@ -48472,12 +48476,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
48472
48476
|
// src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
48473
48477
|
init_cli_process_interrupt();
|
|
48474
48478
|
init_yield_to_event_loop();
|
|
48475
|
-
import * as
|
|
48476
|
-
import * as
|
|
48479
|
+
import * as fs43 from "node:fs";
|
|
48480
|
+
import * as path62 from "node:path";
|
|
48477
48481
|
|
|
48478
48482
|
// src/worktrees/discovery/collect-worktree-paths.ts
|
|
48479
|
-
import * as
|
|
48480
|
-
import * as
|
|
48483
|
+
import * as fs41 from "node:fs";
|
|
48484
|
+
import * as path59 from "node:path";
|
|
48481
48485
|
|
|
48482
48486
|
// src/worktrees/discovery/disk-walk-constants.ts
|
|
48483
48487
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -48507,8 +48511,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
48507
48511
|
// src/worktrees/discovery/disk-walk-utils.ts
|
|
48508
48512
|
init_cli_process_interrupt();
|
|
48509
48513
|
init_yield_to_event_loop();
|
|
48510
|
-
import * as
|
|
48511
|
-
import * as
|
|
48514
|
+
import * as fs40 from "node:fs";
|
|
48515
|
+
import * as path58 from "node:path";
|
|
48512
48516
|
async function yieldDuringDiskWalk(state) {
|
|
48513
48517
|
state.entries++;
|
|
48514
48518
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -48518,7 +48522,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
48518
48522
|
}
|
|
48519
48523
|
async function isGitDir(dirPath) {
|
|
48520
48524
|
try {
|
|
48521
|
-
await
|
|
48525
|
+
await fs40.promises.access(path58.join(dirPath, ".git"));
|
|
48522
48526
|
return true;
|
|
48523
48527
|
} catch {
|
|
48524
48528
|
return false;
|
|
@@ -48532,23 +48536,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
48532
48536
|
const walk = async (dir) => {
|
|
48533
48537
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
48534
48538
|
if (await isGitDir(dir)) {
|
|
48535
|
-
out.push(
|
|
48539
|
+
out.push(path59.resolve(dir));
|
|
48536
48540
|
return;
|
|
48537
48541
|
}
|
|
48538
48542
|
let entries;
|
|
48539
48543
|
try {
|
|
48540
|
-
entries = await
|
|
48544
|
+
entries = await fs41.promises.readdir(dir, { withFileTypes: true });
|
|
48541
48545
|
} catch {
|
|
48542
48546
|
return;
|
|
48543
48547
|
}
|
|
48544
48548
|
for (const e of entries) {
|
|
48545
48549
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
48546
|
-
const full =
|
|
48550
|
+
const full = path59.join(dir, e.name);
|
|
48547
48551
|
if (!e.isDirectory()) continue;
|
|
48548
48552
|
await walk(full);
|
|
48549
48553
|
}
|
|
48550
48554
|
};
|
|
48551
|
-
await walk(
|
|
48555
|
+
await walk(path59.resolve(rootPath));
|
|
48552
48556
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
48553
48557
|
}
|
|
48554
48558
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -48559,16 +48563,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
48559
48563
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
48560
48564
|
let entries;
|
|
48561
48565
|
try {
|
|
48562
|
-
entries = await
|
|
48566
|
+
entries = await fs41.promises.readdir(dir, { withFileTypes: true });
|
|
48563
48567
|
} catch {
|
|
48564
48568
|
return;
|
|
48565
48569
|
}
|
|
48566
48570
|
for (const e of entries) {
|
|
48567
48571
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
48568
|
-
const full =
|
|
48572
|
+
const full = path59.join(dir, e.name);
|
|
48569
48573
|
if (!e.isDirectory()) continue;
|
|
48570
48574
|
if (e.name === sessionId) {
|
|
48571
|
-
if (await isGitDir(full)) out.push(
|
|
48575
|
+
if (await isGitDir(full)) out.push(path59.resolve(full));
|
|
48572
48576
|
continue;
|
|
48573
48577
|
}
|
|
48574
48578
|
if (await isGitDir(full)) continue;
|
|
@@ -48580,14 +48584,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
48580
48584
|
}
|
|
48581
48585
|
|
|
48582
48586
|
// src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
48583
|
-
import * as
|
|
48587
|
+
import * as path60 from "node:path";
|
|
48584
48588
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
48585
|
-
const bridge =
|
|
48589
|
+
const bridge = path60.resolve(bridgeRoot);
|
|
48586
48590
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
48587
48591
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
48588
|
-
const entry =
|
|
48589
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
48590
|
-
}).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));
|
|
48591
48595
|
const ordered = [];
|
|
48592
48596
|
const seen = /* @__PURE__ */ new Set();
|
|
48593
48597
|
const add = (k) => {
|
|
@@ -48605,19 +48609,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
48605
48609
|
}
|
|
48606
48610
|
|
|
48607
48611
|
// src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
48608
|
-
import * as
|
|
48609
|
-
import * as
|
|
48612
|
+
import * as fs42 from "node:fs";
|
|
48613
|
+
import * as path61 from "node:path";
|
|
48610
48614
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
48611
48615
|
let st;
|
|
48612
48616
|
try {
|
|
48613
|
-
st = await
|
|
48617
|
+
st = await fs42.promises.stat(scopeDir);
|
|
48614
48618
|
} catch {
|
|
48615
48619
|
return null;
|
|
48616
48620
|
}
|
|
48617
48621
|
if (!st.isDirectory()) return null;
|
|
48618
48622
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
48619
48623
|
if (worktreePaths.length === 0) return null;
|
|
48620
|
-
const abs =
|
|
48624
|
+
const abs = path61.resolve(scopeDir);
|
|
48621
48625
|
return {
|
|
48622
48626
|
parentPath: abs,
|
|
48623
48627
|
repoCheckoutPaths: worktreePaths
|
|
@@ -48640,7 +48644,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48640
48644
|
const sid = sessionId.trim();
|
|
48641
48645
|
if (!sid) return null;
|
|
48642
48646
|
try {
|
|
48643
|
-
await
|
|
48647
|
+
await fs43.promises.access(worktreesRootPath);
|
|
48644
48648
|
} catch {
|
|
48645
48649
|
return null;
|
|
48646
48650
|
}
|
|
@@ -48649,13 +48653,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48649
48653
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
48650
48654
|
const scanState = { entries: 0 };
|
|
48651
48655
|
try {
|
|
48652
|
-
for (const name of await
|
|
48656
|
+
for (const name of await fs43.promises.readdir(worktreesRootPath)) {
|
|
48653
48657
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
48654
48658
|
if (name.startsWith(".")) continue;
|
|
48655
|
-
const p =
|
|
48659
|
+
const p = path62.join(worktreesRootPath, name);
|
|
48656
48660
|
let st;
|
|
48657
48661
|
try {
|
|
48658
|
-
st = await
|
|
48662
|
+
st = await fs43.promises.stat(p);
|
|
48659
48663
|
} catch {
|
|
48660
48664
|
continue;
|
|
48661
48665
|
}
|
|
@@ -48669,23 +48673,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48669
48673
|
for (const key of keys) {
|
|
48670
48674
|
if (isCliImmediateShutdownRequested()) return null;
|
|
48671
48675
|
await yieldToEventLoop();
|
|
48672
|
-
const layoutRoot =
|
|
48676
|
+
const layoutRoot = path62.join(worktreesRootPath, key);
|
|
48673
48677
|
let layoutSt;
|
|
48674
48678
|
try {
|
|
48675
|
-
layoutSt = await
|
|
48679
|
+
layoutSt = await fs43.promises.stat(layoutRoot);
|
|
48676
48680
|
} catch {
|
|
48677
48681
|
continue;
|
|
48678
48682
|
}
|
|
48679
48683
|
if (!layoutSt.isDirectory()) continue;
|
|
48680
|
-
const sessionDir =
|
|
48684
|
+
const sessionDir = path62.join(layoutRoot, sid);
|
|
48681
48685
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
48682
48686
|
if (nested) return nested;
|
|
48683
48687
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
48684
48688
|
if (legacy.paths.length > 0) {
|
|
48685
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
48689
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path62.resolve(legacy.paths[0]);
|
|
48686
48690
|
return {
|
|
48687
|
-
sessionParentPath:
|
|
48688
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
48691
|
+
sessionParentPath: path62.resolve(isolated),
|
|
48692
|
+
repoCheckoutPaths: legacy.paths.map((p) => path62.resolve(p))
|
|
48689
48693
|
};
|
|
48690
48694
|
}
|
|
48691
48695
|
}
|
|
@@ -48693,31 +48697,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
48693
48697
|
}
|
|
48694
48698
|
|
|
48695
48699
|
// src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
48696
|
-
import * as
|
|
48697
|
-
import * as
|
|
48700
|
+
import * as fs44 from "node:fs";
|
|
48701
|
+
import * as path64 from "node:path";
|
|
48698
48702
|
|
|
48699
48703
|
// src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
48700
48704
|
init_cli_process_interrupt();
|
|
48701
48705
|
init_yield_to_event_loop();
|
|
48702
|
-
import * as
|
|
48706
|
+
import * as path63 from "node:path";
|
|
48703
48707
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
48704
48708
|
const sid = sessionId.trim();
|
|
48705
48709
|
if (!sid) return null;
|
|
48706
|
-
const hintR =
|
|
48710
|
+
const hintR = path63.resolve(checkoutPath);
|
|
48707
48711
|
let best = null;
|
|
48708
|
-
let cur =
|
|
48712
|
+
let cur = path63.dirname(hintR);
|
|
48709
48713
|
for (let i = 0; i < 40; i++) {
|
|
48710
48714
|
if (isCliImmediateShutdownRequested()) return best;
|
|
48711
48715
|
await yieldToEventLoop();
|
|
48712
48716
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
48713
|
-
if (paths.paths.some((p) =>
|
|
48714
|
-
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]);
|
|
48715
48719
|
best = {
|
|
48716
|
-
sessionParentPath:
|
|
48717
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
48720
|
+
sessionParentPath: path63.resolve(isolated),
|
|
48721
|
+
repoCheckoutPaths: paths.paths.map((p) => path63.resolve(p))
|
|
48718
48722
|
};
|
|
48719
48723
|
}
|
|
48720
|
-
const next =
|
|
48724
|
+
const next = path63.dirname(cur);
|
|
48721
48725
|
if (next === cur) break;
|
|
48722
48726
|
cur = next;
|
|
48723
48727
|
}
|
|
@@ -48728,12 +48732,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
48728
48732
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
48729
48733
|
const sid = sessionId.trim();
|
|
48730
48734
|
if (!sid) return null;
|
|
48731
|
-
const hint =
|
|
48732
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
48735
|
+
const hint = path64.resolve(sessionParentPathOrHint);
|
|
48736
|
+
const underHint = await tryBindingFromSessionDirectory(path64.join(hint, sid));
|
|
48733
48737
|
if (underHint) return underHint;
|
|
48734
48738
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
48735
48739
|
if (direct) {
|
|
48736
|
-
if (
|
|
48740
|
+
if (path64.basename(hint) === sid && await isGitDir(hint)) {
|
|
48737
48741
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
48738
48742
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
48739
48743
|
return legacyFromCheckout;
|
|
@@ -48741,23 +48745,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
48741
48745
|
}
|
|
48742
48746
|
return direct;
|
|
48743
48747
|
}
|
|
48744
|
-
if (
|
|
48748
|
+
if (path64.basename(hint) === sid && await isGitDir(hint)) {
|
|
48745
48749
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
48746
48750
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
48747
48751
|
}
|
|
48748
48752
|
let st;
|
|
48749
48753
|
try {
|
|
48750
|
-
st = await
|
|
48754
|
+
st = await fs44.promises.stat(hint);
|
|
48751
48755
|
} catch {
|
|
48752
48756
|
return null;
|
|
48753
48757
|
}
|
|
48754
48758
|
if (!st.isDirectory()) return null;
|
|
48755
48759
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
48756
48760
|
if (legacyPaths.paths.length === 0) return null;
|
|
48757
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
48761
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path64.resolve(legacyPaths.paths[0]);
|
|
48758
48762
|
return {
|
|
48759
|
-
sessionParentPath:
|
|
48760
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
48763
|
+
sessionParentPath: path64.resolve(isolated),
|
|
48764
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path64.resolve(p))
|
|
48761
48765
|
};
|
|
48762
48766
|
}
|
|
48763
48767
|
|
|
@@ -48818,11 +48822,11 @@ function parseSessionParent(v) {
|
|
|
48818
48822
|
}
|
|
48819
48823
|
|
|
48820
48824
|
// src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
48821
|
-
import * as
|
|
48825
|
+
import * as fs48 from "node:fs";
|
|
48822
48826
|
|
|
48823
48827
|
// src/git/discover-repos.ts
|
|
48824
|
-
import * as
|
|
48825
|
-
import * as
|
|
48828
|
+
import * as fs45 from "node:fs";
|
|
48829
|
+
import * as path65 from "node:path";
|
|
48826
48830
|
init_yield_to_event_loop();
|
|
48827
48831
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
48828
48832
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -48832,14 +48836,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
48832
48836
|
}
|
|
48833
48837
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
48834
48838
|
const result = [];
|
|
48835
|
-
const cwdResolved =
|
|
48839
|
+
const cwdResolved = path65.resolve(cwd);
|
|
48836
48840
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
48837
48841
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
48838
48842
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
48839
48843
|
}
|
|
48840
48844
|
let entries;
|
|
48841
48845
|
try {
|
|
48842
|
-
entries =
|
|
48846
|
+
entries = fs45.readdirSync(cwdResolved, { withFileTypes: true });
|
|
48843
48847
|
} catch {
|
|
48844
48848
|
return result;
|
|
48845
48849
|
}
|
|
@@ -48847,7 +48851,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
48847
48851
|
await yieldGitDiscoverWork(i + 1);
|
|
48848
48852
|
const ent = entries[i];
|
|
48849
48853
|
if (!ent.isDirectory()) continue;
|
|
48850
|
-
const childPath2 =
|
|
48854
|
+
const childPath2 = path65.join(cwdResolved, ent.name);
|
|
48851
48855
|
if (await isGitRepoDirectory(childPath2)) {
|
|
48852
48856
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
48853
48857
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -48856,17 +48860,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
48856
48860
|
return result;
|
|
48857
48861
|
}
|
|
48858
48862
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
48859
|
-
const root =
|
|
48863
|
+
const root = path65.resolve(rootPath);
|
|
48860
48864
|
const roots = [];
|
|
48861
48865
|
let walkEntries = 0;
|
|
48862
48866
|
async function walk(dir) {
|
|
48863
48867
|
if (await isGitRepoDirectory(dir)) {
|
|
48864
|
-
roots.push(
|
|
48868
|
+
roots.push(path65.resolve(dir));
|
|
48865
48869
|
return;
|
|
48866
48870
|
}
|
|
48867
48871
|
let entries;
|
|
48868
48872
|
try {
|
|
48869
|
-
entries =
|
|
48873
|
+
entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
48870
48874
|
} catch {
|
|
48871
48875
|
return;
|
|
48872
48876
|
}
|
|
@@ -48874,7 +48878,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
48874
48878
|
await yieldGitDiscoverWork(++walkEntries);
|
|
48875
48879
|
const ent = entries[i];
|
|
48876
48880
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
48877
|
-
await walk(
|
|
48881
|
+
await walk(path65.join(dir, ent.name));
|
|
48878
48882
|
}
|
|
48879
48883
|
}
|
|
48880
48884
|
await walk(root);
|
|
@@ -48890,8 +48894,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
48890
48894
|
}
|
|
48891
48895
|
|
|
48892
48896
|
// src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
48893
|
-
import * as
|
|
48894
|
-
import * as
|
|
48897
|
+
import * as fs47 from "node:fs";
|
|
48898
|
+
import * as path67 from "node:path";
|
|
48895
48899
|
|
|
48896
48900
|
// src/git/worktrees/worktree-add.ts
|
|
48897
48901
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -48907,8 +48911,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
48907
48911
|
}
|
|
48908
48912
|
|
|
48909
48913
|
// src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
48910
|
-
import * as
|
|
48911
|
-
import * as
|
|
48914
|
+
import * as fs46 from "node:fs";
|
|
48915
|
+
import * as path66 from "node:path";
|
|
48912
48916
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
48913
48917
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
48914
48918
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -48917,19 +48921,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
48917
48921
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
48918
48922
|
for (let i = 0; i < segments.length; i++) {
|
|
48919
48923
|
const prefix = segments.slice(0, i).join("/");
|
|
48920
|
-
const bridgeDir = prefix ?
|
|
48921
|
-
const destDir = prefix ?
|
|
48924
|
+
const bridgeDir = prefix ? path66.join(bridgeRoot, prefix) : bridgeRoot;
|
|
48925
|
+
const destDir = prefix ? path66.join(scopeDir, prefix) : scopeDir;
|
|
48922
48926
|
for (const fileName of fileNames) {
|
|
48923
48927
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
48924
48928
|
}
|
|
48925
48929
|
}
|
|
48926
48930
|
}
|
|
48927
48931
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
48928
|
-
const src =
|
|
48929
|
-
if (!
|
|
48930
|
-
const dest =
|
|
48932
|
+
const src = path66.join(srcDir, fileName);
|
|
48933
|
+
if (!fs46.existsSync(src)) return;
|
|
48934
|
+
const dest = path66.join(destDir, fileName);
|
|
48931
48935
|
try {
|
|
48932
|
-
|
|
48936
|
+
fs46.copyFileSync(src, dest);
|
|
48933
48937
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
48934
48938
|
} catch (e) {
|
|
48935
48939
|
log2?.(
|
|
@@ -48961,16 +48965,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
48961
48965
|
worktreeBaseBranches,
|
|
48962
48966
|
log: log2
|
|
48963
48967
|
} = options;
|
|
48964
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
48965
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
48968
|
+
const repoPathRelativeToBridgeRootRaw = path67.relative(bridgeResolved, repoAbsolutePath);
|
|
48969
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path67.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
48966
48970
|
return null;
|
|
48967
48971
|
}
|
|
48968
48972
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
48969
48973
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
48970
48974
|
);
|
|
48971
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
48975
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path67.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
48972
48976
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
48973
|
-
|
|
48977
|
+
fs47.mkdirSync(path67.dirname(worktreePath), { recursive: true });
|
|
48974
48978
|
copyBridgeFilesAlongWorktreePath({
|
|
48975
48979
|
bridgeRoot: bridgeResolved,
|
|
48976
48980
|
scopeDir,
|
|
@@ -48998,7 +49002,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
48998
49002
|
}
|
|
48999
49003
|
|
|
49000
49004
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
49001
|
-
import * as
|
|
49005
|
+
import * as path68 from "node:path";
|
|
49002
49006
|
|
|
49003
49007
|
// src/worktrees/worktree-layout-kind.ts
|
|
49004
49008
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -49028,10 +49032,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
49028
49032
|
|
|
49029
49033
|
// src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
49030
49034
|
function resolveIsolatedScopeDir(options) {
|
|
49031
|
-
const bridgeResolved =
|
|
49035
|
+
const bridgeResolved = path68.resolve(options.bridgeRoot);
|
|
49032
49036
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
49033
|
-
const bridgeKeyDir =
|
|
49034
|
-
const scopeDir =
|
|
49037
|
+
const bridgeKeyDir = path68.join(options.worktreesRootPath, cwdKey);
|
|
49038
|
+
const scopeDir = path68.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
49035
49039
|
return { bridgeResolved, scopeDir };
|
|
49036
49040
|
}
|
|
49037
49041
|
|
|
@@ -49061,7 +49065,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
49061
49065
|
return null;
|
|
49062
49066
|
}
|
|
49063
49067
|
const worktreePaths = [];
|
|
49064
|
-
|
|
49068
|
+
fs48.mkdirSync(scopeDir, { recursive: true });
|
|
49065
49069
|
await forEachWithGitYield(repos, async (repo) => {
|
|
49066
49070
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
49067
49071
|
kind,
|
|
@@ -49133,10 +49137,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
49133
49137
|
}
|
|
49134
49138
|
|
|
49135
49139
|
// src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
49136
|
-
import * as
|
|
49140
|
+
import * as path69 from "node:path";
|
|
49137
49141
|
init_yield_to_event_loop();
|
|
49138
49142
|
async function resolveExplicitSessionParentPath(params) {
|
|
49139
|
-
const resolved =
|
|
49143
|
+
const resolved = path69.resolve(params.parentPathRaw);
|
|
49140
49144
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
49141
49145
|
return resolved;
|
|
49142
49146
|
}
|
|
@@ -49153,7 +49157,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
49153
49157
|
await yieldToEventLoop();
|
|
49154
49158
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
49155
49159
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
49156
|
-
const next =
|
|
49160
|
+
const next = path69.dirname(cur);
|
|
49157
49161
|
if (next === cur) break;
|
|
49158
49162
|
cur = next;
|
|
49159
49163
|
}
|
|
@@ -49301,15 +49305,15 @@ var SessionWorktreeManager = class {
|
|
|
49301
49305
|
};
|
|
49302
49306
|
|
|
49303
49307
|
// src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
49304
|
-
import * as
|
|
49305
|
-
import * as
|
|
49308
|
+
import * as fs49 from "node:fs";
|
|
49309
|
+
import * as path70 from "node:path";
|
|
49306
49310
|
init_yield_to_event_loop();
|
|
49307
49311
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
49308
49312
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
49309
49313
|
const eid = environmentId.trim();
|
|
49310
49314
|
if (!eid) return null;
|
|
49311
49315
|
try {
|
|
49312
|
-
await
|
|
49316
|
+
await fs49.promises.access(worktreesRootPath);
|
|
49313
49317
|
} catch {
|
|
49314
49318
|
return null;
|
|
49315
49319
|
}
|
|
@@ -49318,13 +49322,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49318
49322
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
49319
49323
|
const scanState = { entries: 0 };
|
|
49320
49324
|
try {
|
|
49321
|
-
for (const name of await
|
|
49325
|
+
for (const name of await fs49.promises.readdir(worktreesRootPath)) {
|
|
49322
49326
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
49323
49327
|
if (name.startsWith(".")) continue;
|
|
49324
|
-
const p =
|
|
49328
|
+
const p = path70.join(worktreesRootPath, name);
|
|
49325
49329
|
let st;
|
|
49326
49330
|
try {
|
|
49327
|
-
st = await
|
|
49331
|
+
st = await fs49.promises.stat(p);
|
|
49328
49332
|
} catch {
|
|
49329
49333
|
continue;
|
|
49330
49334
|
}
|
|
@@ -49338,7 +49342,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
49338
49342
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
49339
49343
|
for (const key of keys) {
|
|
49340
49344
|
await yieldToEventLoop();
|
|
49341
|
-
const previewDir =
|
|
49345
|
+
const previewDir = path70.join(worktreesRootPath, key, ...previewDirRel);
|
|
49342
49346
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
49343
49347
|
if (binding) return binding;
|
|
49344
49348
|
}
|
|
@@ -49465,7 +49469,7 @@ var PreviewWorktreeManager = class {
|
|
|
49465
49469
|
};
|
|
49466
49470
|
|
|
49467
49471
|
// src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
49468
|
-
import * as
|
|
49472
|
+
import * as path74 from "node:path";
|
|
49469
49473
|
|
|
49470
49474
|
// src/git/worktrees/reset-worktree-to-branch.ts
|
|
49471
49475
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -49476,8 +49480,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
49476
49480
|
}
|
|
49477
49481
|
|
|
49478
49482
|
// src/worktrees/deploy/capture-and-apply-wip.ts
|
|
49479
|
-
import * as
|
|
49480
|
-
import * as
|
|
49483
|
+
import * as fs50 from "node:fs";
|
|
49484
|
+
import * as path71 from "node:path";
|
|
49481
49485
|
|
|
49482
49486
|
// src/git/snapshot/git.ts
|
|
49483
49487
|
async function gitStashCreate(repoRoot, log2) {
|
|
@@ -49525,12 +49529,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49525
49529
|
if (!ap.ok) return ap;
|
|
49526
49530
|
}
|
|
49527
49531
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
49528
|
-
const src =
|
|
49529
|
-
const dst =
|
|
49532
|
+
const src = path71.join(sourceRepoPath, rel);
|
|
49533
|
+
const dst = path71.join(targetRepoPath, rel);
|
|
49530
49534
|
try {
|
|
49531
|
-
if (!
|
|
49532
|
-
|
|
49533
|
-
|
|
49535
|
+
if (!fs50.existsSync(src)) return;
|
|
49536
|
+
fs50.mkdirSync(path71.dirname(dst), { recursive: true });
|
|
49537
|
+
fs50.copyFileSync(src, dst);
|
|
49534
49538
|
} catch (e) {
|
|
49535
49539
|
log2(
|
|
49536
49540
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -49541,14 +49545,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
49541
49545
|
}
|
|
49542
49546
|
|
|
49543
49547
|
// src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
49544
|
-
import * as
|
|
49548
|
+
import * as path72 from "node:path";
|
|
49545
49549
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
49546
49550
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
49547
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
49551
|
+
const resolvedSessionParentPath = sessionParentPath ? path72.resolve(sessionParentPath) : null;
|
|
49548
49552
|
let match = null;
|
|
49549
49553
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
49550
49554
|
if (match) return;
|
|
49551
|
-
const resolvedCheckoutPath =
|
|
49555
|
+
const resolvedCheckoutPath = path72.resolve(checkoutPath);
|
|
49552
49556
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
49553
49557
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49554
49558
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -49602,7 +49606,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
49602
49606
|
}
|
|
49603
49607
|
|
|
49604
49608
|
// src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
49605
|
-
import * as
|
|
49609
|
+
import * as path73 from "node:path";
|
|
49606
49610
|
|
|
49607
49611
|
// src/git/branches/create-or-update-branch.ts
|
|
49608
49612
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -49639,19 +49643,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
49639
49643
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
49640
49644
|
const states = [];
|
|
49641
49645
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
49642
|
-
const checkoutPath =
|
|
49646
|
+
const checkoutPath = path73.resolve(sessionCheckout);
|
|
49643
49647
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
49644
49648
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49645
49649
|
checkoutPath,
|
|
49646
49650
|
bridgeRoot,
|
|
49647
|
-
sessionParentPath: sessionParentPath ?
|
|
49651
|
+
sessionParentPath: sessionParentPath ? path73.resolve(sessionParentPath) : null
|
|
49648
49652
|
});
|
|
49649
49653
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
49650
49654
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
49651
49655
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
49652
49656
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
49653
49657
|
checkoutPaths: previewCheckoutPaths,
|
|
49654
|
-
sessionParentPath: previewParentPath ?
|
|
49658
|
+
sessionParentPath: previewParentPath ? path73.resolve(previewParentPath) : null,
|
|
49655
49659
|
bridgeRoot,
|
|
49656
49660
|
repoPathRelativeToWorkspaceRoot
|
|
49657
49661
|
}) : null;
|
|
@@ -49671,7 +49675,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49671
49675
|
const eid = options.environmentId.trim();
|
|
49672
49676
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
49673
49677
|
const deployBranch = previewDeployBranchName(eid);
|
|
49674
|
-
const bridgeRoot =
|
|
49678
|
+
const bridgeRoot = path74.resolve(getBridgeRoot());
|
|
49675
49679
|
await previewWorktreeManager.ensureCached(eid);
|
|
49676
49680
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
49677
49681
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -49711,10 +49715,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
49711
49715
|
}
|
|
49712
49716
|
|
|
49713
49717
|
// src/worktrees/manager/default-worktrees-root-path.ts
|
|
49714
|
-
import * as
|
|
49718
|
+
import * as path75 from "node:path";
|
|
49715
49719
|
import os9 from "node:os";
|
|
49716
49720
|
function defaultWorktreesRootPath() {
|
|
49717
|
-
return
|
|
49721
|
+
return path75.join(os9.homedir(), ".buildautomaton", "worktrees");
|
|
49718
49722
|
}
|
|
49719
49723
|
|
|
49720
49724
|
// src/connection/create-bridge-worktree-managers.ts
|
|
@@ -49844,14 +49848,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
49844
49848
|
}
|
|
49845
49849
|
|
|
49846
49850
|
// src/files/list-dir/index.ts
|
|
49847
|
-
import
|
|
49851
|
+
import fs52 from "node:fs";
|
|
49848
49852
|
|
|
49849
49853
|
// src/files/ensure-under-cwd.ts
|
|
49850
|
-
import
|
|
49854
|
+
import path76 from "node:path";
|
|
49851
49855
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
49852
|
-
const normalized =
|
|
49853
|
-
const resolved =
|
|
49854
|
-
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) {
|
|
49855
49859
|
return null;
|
|
49856
49860
|
}
|
|
49857
49861
|
return resolved;
|
|
@@ -49864,15 +49868,15 @@ init_yield_to_event_loop();
|
|
|
49864
49868
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
49865
49869
|
|
|
49866
49870
|
// src/files/list-dir/map-dir-entry.ts
|
|
49867
|
-
import
|
|
49868
|
-
import
|
|
49871
|
+
import path77 from "node:path";
|
|
49872
|
+
import fs51 from "node:fs";
|
|
49869
49873
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
49870
|
-
const entryPath =
|
|
49871
|
-
const fullPath =
|
|
49874
|
+
const entryPath = path77.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
49875
|
+
const fullPath = path77.join(resolved, d.name);
|
|
49872
49876
|
let isDir = d.isDirectory();
|
|
49873
49877
|
if (d.isSymbolicLink()) {
|
|
49874
49878
|
try {
|
|
49875
|
-
const targetStat = await
|
|
49879
|
+
const targetStat = await fs51.promises.stat(fullPath);
|
|
49876
49880
|
isDir = targetStat.isDirectory();
|
|
49877
49881
|
} catch {
|
|
49878
49882
|
isDir = false;
|
|
@@ -49902,7 +49906,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49902
49906
|
return { error: "Path is outside working directory" };
|
|
49903
49907
|
}
|
|
49904
49908
|
try {
|
|
49905
|
-
const names = await
|
|
49909
|
+
const names = await fs52.promises.readdir(resolved, { withFileTypes: true });
|
|
49906
49910
|
const entries = [];
|
|
49907
49911
|
for (let i = 0; i < names.length; i++) {
|
|
49908
49912
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -49918,13 +49922,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
49918
49922
|
}
|
|
49919
49923
|
|
|
49920
49924
|
// src/git/tree/resolve-repo-abs-path.ts
|
|
49921
|
-
import * as
|
|
49925
|
+
import * as path78 from "node:path";
|
|
49922
49926
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
49923
|
-
const bridgeResolved =
|
|
49927
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
49924
49928
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
49925
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
49926
|
-
const resolved =
|
|
49927
|
-
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) {
|
|
49928
49932
|
return null;
|
|
49929
49933
|
}
|
|
49930
49934
|
return resolved;
|
|
@@ -50405,25 +50409,25 @@ async function GET2(ctx) {
|
|
|
50405
50409
|
init_in_flight();
|
|
50406
50410
|
|
|
50407
50411
|
// src/files/read/read-file-async.ts
|
|
50408
|
-
import
|
|
50412
|
+
import fs58 from "node:fs";
|
|
50409
50413
|
init_yield_to_event_loop();
|
|
50410
50414
|
|
|
50411
50415
|
// src/files/read/resolve-file-cache.ts
|
|
50412
|
-
import
|
|
50413
|
-
import
|
|
50416
|
+
import fs53 from "node:fs";
|
|
50417
|
+
import path79 from "node:path";
|
|
50414
50418
|
var RESOLVE_CACHE_MAX = 4096;
|
|
50415
50419
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
50416
50420
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
50417
50421
|
return `${sessionParentPath}\0${relativePath}`;
|
|
50418
50422
|
}
|
|
50419
50423
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
50420
|
-
const parent =
|
|
50421
|
-
const resolved =
|
|
50422
|
-
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}`);
|
|
50423
50427
|
}
|
|
50424
50428
|
function statMatchesCacheSync(entry) {
|
|
50425
50429
|
try {
|
|
50426
|
-
const stat3 =
|
|
50430
|
+
const stat3 = fs53.statSync(entry.path);
|
|
50427
50431
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
50428
50432
|
} catch {
|
|
50429
50433
|
return false;
|
|
@@ -50456,7 +50460,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
50456
50460
|
}
|
|
50457
50461
|
|
|
50458
50462
|
// src/files/read/resolve-file-for-read-core.ts
|
|
50459
|
-
import
|
|
50463
|
+
import fs54 from "node:fs";
|
|
50460
50464
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
50461
50465
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
50462
50466
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -50466,13 +50470,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
50466
50470
|
let size;
|
|
50467
50471
|
let mtimeMs;
|
|
50468
50472
|
try {
|
|
50469
|
-
const lstat =
|
|
50473
|
+
const lstat = fs54.lstatSync(resolved);
|
|
50470
50474
|
if (lstat.isSymbolicLink()) {
|
|
50471
|
-
real =
|
|
50475
|
+
real = fs54.realpathSync(resolved);
|
|
50472
50476
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50473
50477
|
return { error: "Path is outside working directory" };
|
|
50474
50478
|
}
|
|
50475
|
-
const stat3 =
|
|
50479
|
+
const stat3 = fs54.statSync(real);
|
|
50476
50480
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50477
50481
|
size = stat3.size;
|
|
50478
50482
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50500,13 +50504,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
50500
50504
|
let size;
|
|
50501
50505
|
let mtimeMs;
|
|
50502
50506
|
try {
|
|
50503
|
-
const lstat = await
|
|
50507
|
+
const lstat = await fs54.promises.lstat(resolved);
|
|
50504
50508
|
if (lstat.isSymbolicLink()) {
|
|
50505
|
-
real = await
|
|
50509
|
+
real = await fs54.promises.realpath(resolved);
|
|
50506
50510
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
50507
50511
|
return { error: "Path is outside working directory" };
|
|
50508
50512
|
}
|
|
50509
|
-
const stat3 = await
|
|
50513
|
+
const stat3 = await fs54.promises.stat(real);
|
|
50510
50514
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
50511
50515
|
size = stat3.size;
|
|
50512
50516
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -50555,7 +50559,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
50555
50559
|
|
|
50556
50560
|
// src/files/read/read-file-range-async.ts
|
|
50557
50561
|
init_yield_to_event_loop();
|
|
50558
|
-
import
|
|
50562
|
+
import fs55 from "node:fs";
|
|
50559
50563
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
50560
50564
|
|
|
50561
50565
|
// src/files/read/read-file-range-line-zero.ts
|
|
@@ -50669,8 +50673,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
50669
50673
|
|
|
50670
50674
|
// src/files/read/read-file-range-async.ts
|
|
50671
50675
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
50672
|
-
const fileSize = fileSizeIn ?? (await
|
|
50673
|
-
const fd = await
|
|
50676
|
+
const fileSize = fileSizeIn ?? (await fs55.promises.stat(filePath)).size;
|
|
50677
|
+
const fd = await fs55.promises.open(filePath, "r");
|
|
50674
50678
|
const bufSize = 64 * 1024;
|
|
50675
50679
|
const buf = Buffer.alloc(bufSize);
|
|
50676
50680
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -50771,7 +50775,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
50771
50775
|
}
|
|
50772
50776
|
|
|
50773
50777
|
// src/files/read/read-small-file-range-async.ts
|
|
50774
|
-
import
|
|
50778
|
+
import fs56 from "node:fs";
|
|
50775
50779
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
50776
50780
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
50777
50781
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -50801,7 +50805,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
50801
50805
|
};
|
|
50802
50806
|
}
|
|
50803
50807
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
50804
|
-
const raw =
|
|
50808
|
+
const raw = fs56.readFileSync(filePath, "utf8");
|
|
50805
50809
|
const lines = raw.split(/\r?\n/);
|
|
50806
50810
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50807
50811
|
}
|
|
@@ -50809,28 +50813,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
50809
50813
|
if (isMainThread5) {
|
|
50810
50814
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
50811
50815
|
}
|
|
50812
|
-
const raw = await
|
|
50816
|
+
const raw = await fs56.promises.readFile(filePath, "utf8");
|
|
50813
50817
|
const lines = raw.split(/\r?\n/);
|
|
50814
50818
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
50815
50819
|
}
|
|
50816
50820
|
|
|
50817
50821
|
// src/files/read/read-file-buffer-full-async.ts
|
|
50818
50822
|
init_yield_to_event_loop();
|
|
50819
|
-
import
|
|
50823
|
+
import fs57 from "node:fs";
|
|
50820
50824
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
50821
50825
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
50822
50826
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
50823
50827
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
50824
50828
|
if (isMainThread6) {
|
|
50825
|
-
const size2 = knownSize ??
|
|
50829
|
+
const size2 = knownSize ?? fs57.statSync(filePath).size;
|
|
50826
50830
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
50827
50831
|
await yieldToEventLoop();
|
|
50828
|
-
const buffer =
|
|
50832
|
+
const buffer = fs57.readFileSync(filePath);
|
|
50829
50833
|
return { buffer, size: buffer.length };
|
|
50830
50834
|
}
|
|
50831
50835
|
}
|
|
50832
|
-
const size = knownSize ?? (await
|
|
50833
|
-
const fd = await
|
|
50836
|
+
const size = knownSize ?? (await fs57.promises.stat(filePath)).size;
|
|
50837
|
+
const fd = await fs57.promises.open(filePath, "r");
|
|
50834
50838
|
const chunks = [];
|
|
50835
50839
|
let position = 0;
|
|
50836
50840
|
let bytesSinceYield = 0;
|
|
@@ -50933,7 +50937,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
50933
50937
|
}
|
|
50934
50938
|
if (hasRange) {
|
|
50935
50939
|
if (fileSize == null) {
|
|
50936
|
-
const stat3 = await
|
|
50940
|
+
const stat3 = await fs58.promises.stat(resolvedPath);
|
|
50937
50941
|
fileSize = stat3.size;
|
|
50938
50942
|
}
|
|
50939
50943
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -51231,12 +51235,12 @@ function parseOptionalInt2(raw) {
|
|
|
51231
51235
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
51232
51236
|
}
|
|
51233
51237
|
function parseCodeNavParams(url2) {
|
|
51234
|
-
const
|
|
51238
|
+
const path86 = url2.searchParams.get("path") ?? "";
|
|
51235
51239
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
51236
51240
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
51237
51241
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
51238
51242
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
51239
|
-
return { path:
|
|
51243
|
+
return { path: path86, op, line, column };
|
|
51240
51244
|
}
|
|
51241
51245
|
function parseCodeNavPath(url2) {
|
|
51242
51246
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -52041,31 +52045,66 @@ function hasRunningTurn(turns) {
|
|
|
52041
52045
|
}
|
|
52042
52046
|
|
|
52043
52047
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
52044
|
-
import
|
|
52048
|
+
import fs61 from "node:fs";
|
|
52045
52049
|
|
|
52046
52050
|
// src/git/snapshot/capture.ts
|
|
52047
|
-
import * as
|
|
52048
|
-
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";
|
|
52049
52089
|
async function resolveSnapshotRepoRoots(options) {
|
|
52050
52090
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
52051
52091
|
if (worktreePaths?.length) {
|
|
52052
|
-
const
|
|
52053
|
-
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);
|
|
52054
52094
|
}
|
|
52055
52095
|
try {
|
|
52056
|
-
const
|
|
52057
|
-
const mapped = repos.map((r) => r.absolutePath);
|
|
52096
|
+
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
52058
52097
|
const sid = sessionId?.trim();
|
|
52059
|
-
if (sid)
|
|
52060
|
-
|
|
52061
|
-
|
|
52062
|
-
|
|
52063
|
-
|
|
52064
|
-
} catch (e) {
|
|
52065
|
-
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)}`);
|
|
52066
52103
|
return [];
|
|
52067
52104
|
}
|
|
52068
52105
|
}
|
|
52106
|
+
|
|
52107
|
+
// src/git/snapshot/capture.ts
|
|
52069
52108
|
async function capturePreTurnSnapshot(options) {
|
|
52070
52109
|
const { runId, repoRoots, agentCwd, log: log2 } = options;
|
|
52071
52110
|
if (!runId || !repoRoots.length) {
|
|
@@ -52079,7 +52118,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
52079
52118
|
});
|
|
52080
52119
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
52081
52120
|
try {
|
|
52082
|
-
|
|
52121
|
+
fs60.mkdirSync(dir, { recursive: true });
|
|
52083
52122
|
} catch (e) {
|
|
52084
52123
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
52085
52124
|
}
|
|
@@ -52088,9 +52127,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
52088
52127
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52089
52128
|
repos
|
|
52090
52129
|
};
|
|
52091
|
-
const filePath =
|
|
52130
|
+
const filePath = path81.join(dir, `${runId}.json`);
|
|
52092
52131
|
try {
|
|
52093
|
-
|
|
52132
|
+
fs60.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
52094
52133
|
} catch (e) {
|
|
52095
52134
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
52096
52135
|
}
|
|
@@ -52100,39 +52139,6 @@ async function capturePreTurnSnapshot(options) {
|
|
|
52100
52139
|
);
|
|
52101
52140
|
return { ok: true, filePath, repos };
|
|
52102
52141
|
}
|
|
52103
|
-
async function applyPreTurnSnapshot(filePath, log2) {
|
|
52104
|
-
let data;
|
|
52105
|
-
try {
|
|
52106
|
-
const raw = fs58.readFileSync(filePath, "utf8");
|
|
52107
|
-
data = JSON.parse(raw);
|
|
52108
|
-
} catch (e) {
|
|
52109
|
-
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
52110
|
-
}
|
|
52111
|
-
if (!Array.isArray(data.repos)) {
|
|
52112
|
-
return { ok: false, error: "Invalid snapshot file" };
|
|
52113
|
-
}
|
|
52114
|
-
let applyError = null;
|
|
52115
|
-
await forEachWithGitYield(data.repos, async (r) => {
|
|
52116
|
-
if (applyError || !r.path) return;
|
|
52117
|
-
const reset = await gitRun(r.path, ["reset", "--hard", "HEAD"], log2, "reset --hard");
|
|
52118
|
-
if (!reset.ok) {
|
|
52119
|
-
applyError = reset;
|
|
52120
|
-
return;
|
|
52121
|
-
}
|
|
52122
|
-
const clean = await gitRun(r.path, ["clean", "-fd"], log2, "clean -fd");
|
|
52123
|
-
if (!clean.ok) {
|
|
52124
|
-
applyError = clean;
|
|
52125
|
-
return;
|
|
52126
|
-
}
|
|
52127
|
-
if (r.stashSha) {
|
|
52128
|
-
const ap = await gitRun(r.path, ["stash", "apply", r.stashSha], log2, "stash apply");
|
|
52129
|
-
if (!ap.ok) applyError = ap;
|
|
52130
|
-
}
|
|
52131
|
-
});
|
|
52132
|
-
if (applyError) return applyError;
|
|
52133
|
-
log2(`[snapshot] Restored pre-turn state for ${data.runId.slice(0, 8)}\u2026`);
|
|
52134
|
-
return { ok: true };
|
|
52135
|
-
}
|
|
52136
52142
|
|
|
52137
52143
|
// src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
52138
52144
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
@@ -52143,7 +52149,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
52143
52149
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
52144
52150
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
52145
52151
|
try {
|
|
52146
|
-
await
|
|
52152
|
+
await fs61.promises.access(file2, fs61.constants.F_OK);
|
|
52147
52153
|
} catch {
|
|
52148
52154
|
deps.log(
|
|
52149
52155
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -52292,8 +52298,8 @@ async function runBridgePromptPreamble(params) {
|
|
|
52292
52298
|
log: log2
|
|
52293
52299
|
});
|
|
52294
52300
|
if (s && sessionId) {
|
|
52295
|
-
const cliGitBranch = await readGitBranch(effectiveCwd);
|
|
52296
52301
|
const usesWt = sessionWorktreeManager.usesWorktreeSession(sessionId);
|
|
52302
|
+
const cliGitBranch = repoRoots.length > 0 ? await readGitBranch(effectiveCwd) : null;
|
|
52297
52303
|
const isolatedSessionParentPath = sessionWorktreeManager.getIsolatedSessionParentPathForSession(sessionId);
|
|
52298
52304
|
sendWsMessage(s, {
|
|
52299
52305
|
type: "session_git_context_report",
|
|
@@ -52735,7 +52741,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
52735
52741
|
};
|
|
52736
52742
|
|
|
52737
52743
|
// src/routing/handlers/revert-turn-snapshot.ts
|
|
52738
|
-
import * as
|
|
52744
|
+
import * as fs62 from "node:fs";
|
|
52739
52745
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
52740
52746
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
52741
52747
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -52748,7 +52754,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
52748
52754
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
52749
52755
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
52750
52756
|
try {
|
|
52751
|
-
await
|
|
52757
|
+
await fs62.promises.access(file2, fs62.constants.F_OK);
|
|
52752
52758
|
} catch {
|
|
52753
52759
|
sendWsMessage(s, {
|
|
52754
52760
|
type: "revert_turn_snapshot_result",
|
|
@@ -52822,8 +52828,8 @@ function randomSecret() {
|
|
|
52822
52828
|
}
|
|
52823
52829
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
52824
52830
|
}
|
|
52825
|
-
async function requestPreviewApi(port, secret, method,
|
|
52826
|
-
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}`;
|
|
52827
52833
|
const headers = {
|
|
52828
52834
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
52829
52835
|
"Content-Type": "application/json"
|
|
@@ -52835,7 +52841,7 @@ async function requestPreviewApi(port, secret, method, path84, body) {
|
|
|
52835
52841
|
});
|
|
52836
52842
|
const data = await res.json().catch(() => ({}));
|
|
52837
52843
|
if (!res.ok) {
|
|
52838
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
52844
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
|
|
52839
52845
|
}
|
|
52840
52846
|
return data;
|
|
52841
52847
|
}
|
|
@@ -53020,8 +53026,8 @@ function isValidRemoteSkillInstallItem(item) {
|
|
|
53020
53026
|
|
|
53021
53027
|
// src/skills/install/install-remote-skills-async.ts
|
|
53022
53028
|
init_yield_to_event_loop();
|
|
53023
|
-
import
|
|
53024
|
-
import
|
|
53029
|
+
import fs63 from "node:fs";
|
|
53030
|
+
import path82 from "node:path";
|
|
53025
53031
|
|
|
53026
53032
|
// src/skills/install/constants.ts
|
|
53027
53033
|
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
@@ -53032,12 +53038,12 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
|
53032
53038
|
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
53033
53039
|
await yieldToEventLoop();
|
|
53034
53040
|
}
|
|
53035
|
-
const dest =
|
|
53036
|
-
await
|
|
53041
|
+
const dest = path82.join(skillDir, f.path);
|
|
53042
|
+
await fs63.promises.mkdir(path82.dirname(dest), { recursive: true });
|
|
53037
53043
|
if (f.text !== void 0) {
|
|
53038
|
-
await
|
|
53044
|
+
await fs63.promises.writeFile(dest, f.text, "utf8");
|
|
53039
53045
|
} else if (f.base64) {
|
|
53040
|
-
await
|
|
53046
|
+
await fs63.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
|
|
53041
53047
|
}
|
|
53042
53048
|
}
|
|
53043
53049
|
async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
@@ -53049,7 +53055,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
|
53049
53055
|
try {
|
|
53050
53056
|
for (const item of items) {
|
|
53051
53057
|
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
53052
|
-
const skillDir =
|
|
53058
|
+
const skillDir = path82.join(cwd, targetDir, item.skillName);
|
|
53053
53059
|
for (const f of item.files) {
|
|
53054
53060
|
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
53055
53061
|
}
|
|
@@ -53356,13 +53362,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
53356
53362
|
|
|
53357
53363
|
// src/files/handle-file-browser-search.ts
|
|
53358
53364
|
init_yield_to_event_loop();
|
|
53359
|
-
import
|
|
53365
|
+
import path83 from "node:path";
|
|
53360
53366
|
var SEARCH_LIMIT = 100;
|
|
53361
53367
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
53362
53368
|
void (async () => {
|
|
53363
53369
|
await yieldToEventLoop();
|
|
53364
53370
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
53365
|
-
const sessionParentPath =
|
|
53371
|
+
const sessionParentPath = path83.resolve(
|
|
53366
53372
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
53367
53373
|
);
|
|
53368
53374
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -53460,7 +53466,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
53460
53466
|
}
|
|
53461
53467
|
|
|
53462
53468
|
// src/git/bridge-git-context.ts
|
|
53463
|
-
import * as
|
|
53469
|
+
import * as path84 from "node:path";
|
|
53464
53470
|
init_yield_to_event_loop();
|
|
53465
53471
|
|
|
53466
53472
|
// src/git/branches/get-current-branch.ts
|
|
@@ -53511,12 +53517,12 @@ async function listRepoBranchRefs(repoPath) {
|
|
|
53511
53517
|
// src/git/bridge-git-context.ts
|
|
53512
53518
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
53513
53519
|
if (relPath === "." || relPath === "") {
|
|
53514
|
-
return
|
|
53520
|
+
return path84.basename(path84.resolve(bridgeRoot)) || "repo";
|
|
53515
53521
|
}
|
|
53516
|
-
return
|
|
53522
|
+
return path84.basename(relPath) || relPath;
|
|
53517
53523
|
}
|
|
53518
53524
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
53519
|
-
const root =
|
|
53525
|
+
const root = path84.resolve(bridgeRoot);
|
|
53520
53526
|
if (await isGitRepoDirectory(root)) {
|
|
53521
53527
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
53522
53528
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -53524,19 +53530,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
53524
53530
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
53525
53531
|
const byPath = /* @__PURE__ */ new Map();
|
|
53526
53532
|
for (const repo of [...deep, ...shallow]) {
|
|
53527
|
-
byPath.set(
|
|
53533
|
+
byPath.set(path84.resolve(repo.absolutePath), repo);
|
|
53528
53534
|
}
|
|
53529
53535
|
return [...byPath.values()];
|
|
53530
53536
|
}
|
|
53531
53537
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
53532
|
-
const bridgeResolved =
|
|
53538
|
+
const bridgeResolved = path84.resolve(bridgeRoot);
|
|
53533
53539
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
53534
53540
|
const rows = [];
|
|
53535
53541
|
for (let i = 0; i < repos.length; i++) {
|
|
53536
53542
|
if (i > 0) await yieldToEventLoop();
|
|
53537
53543
|
const repo = repos[i];
|
|
53538
|
-
let rel =
|
|
53539
|
-
if (rel.startsWith("..") ||
|
|
53544
|
+
let rel = path84.relative(bridgeResolved, repo.absolutePath);
|
|
53545
|
+
if (rel.startsWith("..") || path84.isAbsolute(rel)) continue;
|
|
53540
53546
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
53541
53547
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
53542
53548
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -53551,11 +53557,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
53551
53557
|
return rows;
|
|
53552
53558
|
}
|
|
53553
53559
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
53554
|
-
const bridgeResolved =
|
|
53560
|
+
const bridgeResolved = path84.resolve(bridgeRoot);
|
|
53555
53561
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
53556
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
53557
|
-
const resolved =
|
|
53558
|
-
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) {
|
|
53559
53565
|
return [];
|
|
53560
53566
|
}
|
|
53561
53567
|
return listRepoBranchRefs(resolved);
|
|
@@ -54219,9 +54225,9 @@ async function runCliAction(program2, opts) {
|
|
|
54219
54225
|
const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
|
|
54220
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);
|
|
54221
54227
|
if (bridgeRootOpt) {
|
|
54222
|
-
const resolvedBridgeRoot =
|
|
54228
|
+
const resolvedBridgeRoot = path85.resolve(process.cwd(), bridgeRootOpt);
|
|
54223
54229
|
try {
|
|
54224
|
-
const st =
|
|
54230
|
+
const st = fs64.statSync(resolvedBridgeRoot);
|
|
54225
54231
|
if (!st.isDirectory()) {
|
|
54226
54232
|
console.error(`Bridge root is not a directory: ${resolvedBridgeRoot}`);
|
|
54227
54233
|
process.exit(1);
|
|
@@ -54241,7 +54247,7 @@ async function runCliAction(program2, opts) {
|
|
|
54241
54247
|
);
|
|
54242
54248
|
let worktreesRootPath;
|
|
54243
54249
|
if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
|
|
54244
|
-
worktreesRootPath =
|
|
54250
|
+
worktreesRootPath = path85.resolve(opts.worktreesRoot.trim());
|
|
54245
54251
|
}
|
|
54246
54252
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
54247
54253
|
if (e2eCertificates) {
|