@buildautomaton/cli 0.1.14 → 0.1.15
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 +880 -352
- package/dist/cli.js.map +4 -4
- package/dist/index.js +827 -299
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3179,7 +3179,7 @@ var require_stream = __commonJS({
|
|
|
3179
3179
|
};
|
|
3180
3180
|
duplex._final = function(callback) {
|
|
3181
3181
|
if (ws.readyState === ws.CONNECTING) {
|
|
3182
|
-
ws.once("open", function
|
|
3182
|
+
ws.once("open", function open2() {
|
|
3183
3183
|
duplex._final(callback);
|
|
3184
3184
|
});
|
|
3185
3185
|
return;
|
|
@@ -3200,7 +3200,7 @@ var require_stream = __commonJS({
|
|
|
3200
3200
|
};
|
|
3201
3201
|
duplex._write = function(chunk, encoding, callback) {
|
|
3202
3202
|
if (ws.readyState === ws.CONNECTING) {
|
|
3203
|
-
ws.once("open", function
|
|
3203
|
+
ws.once("open", function open2() {
|
|
3204
3204
|
duplex._write(chunk, encoding, callback);
|
|
3205
3205
|
});
|
|
3206
3206
|
return;
|
|
@@ -4065,8 +4065,8 @@ var init_parseUtil = __esm({
|
|
|
4065
4065
|
init_errors();
|
|
4066
4066
|
init_en();
|
|
4067
4067
|
makeIssue = (params) => {
|
|
4068
|
-
const { data, path:
|
|
4069
|
-
const fullPath = [...
|
|
4068
|
+
const { data, path: path32, errorMaps, issueData } = params;
|
|
4069
|
+
const fullPath = [...path32, ...issueData.path || []];
|
|
4070
4070
|
const fullIssue = {
|
|
4071
4071
|
...issueData,
|
|
4072
4072
|
path: fullPath
|
|
@@ -4374,11 +4374,11 @@ var init_types = __esm({
|
|
|
4374
4374
|
init_parseUtil();
|
|
4375
4375
|
init_util();
|
|
4376
4376
|
ParseInputLazyPath = class {
|
|
4377
|
-
constructor(parent, value,
|
|
4377
|
+
constructor(parent, value, path32, key) {
|
|
4378
4378
|
this._cachedPath = [];
|
|
4379
4379
|
this.parent = parent;
|
|
4380
4380
|
this.data = value;
|
|
4381
|
-
this._path =
|
|
4381
|
+
this._path = path32;
|
|
4382
4382
|
this._key = key;
|
|
4383
4383
|
}
|
|
4384
4384
|
get path() {
|
|
@@ -7993,10 +7993,10 @@ function assignProp(target, prop, value) {
|
|
|
7993
7993
|
configurable: true
|
|
7994
7994
|
});
|
|
7995
7995
|
}
|
|
7996
|
-
function getElementAtPath(obj,
|
|
7997
|
-
if (!
|
|
7996
|
+
function getElementAtPath(obj, path32) {
|
|
7997
|
+
if (!path32)
|
|
7998
7998
|
return obj;
|
|
7999
|
-
return
|
|
7999
|
+
return path32.reduce((acc, key) => acc?.[key], obj);
|
|
8000
8000
|
}
|
|
8001
8001
|
function promiseAllObject(promisesObj) {
|
|
8002
8002
|
const keys = Object.keys(promisesObj);
|
|
@@ -8245,11 +8245,11 @@ function aborted(x, startIndex = 0) {
|
|
|
8245
8245
|
}
|
|
8246
8246
|
return false;
|
|
8247
8247
|
}
|
|
8248
|
-
function prefixIssues(
|
|
8248
|
+
function prefixIssues(path32, issues) {
|
|
8249
8249
|
return issues.map((iss) => {
|
|
8250
8250
|
var _a2;
|
|
8251
8251
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
8252
|
-
iss.path.unshift(
|
|
8252
|
+
iss.path.unshift(path32);
|
|
8253
8253
|
return iss;
|
|
8254
8254
|
});
|
|
8255
8255
|
}
|
|
@@ -8438,7 +8438,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8438
8438
|
return issue2.message;
|
|
8439
8439
|
};
|
|
8440
8440
|
const result = { errors: [] };
|
|
8441
|
-
const processError = (error41,
|
|
8441
|
+
const processError = (error41, path32 = []) => {
|
|
8442
8442
|
var _a2, _b;
|
|
8443
8443
|
for (const issue2 of error41.issues) {
|
|
8444
8444
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -8448,7 +8448,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8448
8448
|
} else if (issue2.code === "invalid_element") {
|
|
8449
8449
|
processError({ issues: issue2.issues }, issue2.path);
|
|
8450
8450
|
} else {
|
|
8451
|
-
const fullpath = [...
|
|
8451
|
+
const fullpath = [...path32, ...issue2.path];
|
|
8452
8452
|
if (fullpath.length === 0) {
|
|
8453
8453
|
result.errors.push(mapper(issue2));
|
|
8454
8454
|
continue;
|
|
@@ -8478,9 +8478,9 @@ function treeifyError(error40, _mapper) {
|
|
|
8478
8478
|
processError(error40);
|
|
8479
8479
|
return result;
|
|
8480
8480
|
}
|
|
8481
|
-
function toDotPath(
|
|
8481
|
+
function toDotPath(path32) {
|
|
8482
8482
|
const segs = [];
|
|
8483
|
-
for (const seg of
|
|
8483
|
+
for (const seg of path32) {
|
|
8484
8484
|
if (typeof seg === "number")
|
|
8485
8485
|
segs.push(`[${seg}]`);
|
|
8486
8486
|
else if (typeof seg === "symbol")
|
|
@@ -21669,7 +21669,7 @@ var require_has_flag = __commonJS({
|
|
|
21669
21669
|
var require_supports_color = __commonJS({
|
|
21670
21670
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
21671
21671
|
"use strict";
|
|
21672
|
-
var
|
|
21672
|
+
var os6 = __require("os");
|
|
21673
21673
|
var tty = __require("tty");
|
|
21674
21674
|
var hasFlag = require_has_flag();
|
|
21675
21675
|
var { env } = process;
|
|
@@ -21717,7 +21717,7 @@ var require_supports_color = __commonJS({
|
|
|
21717
21717
|
return min;
|
|
21718
21718
|
}
|
|
21719
21719
|
if (process.platform === "win32") {
|
|
21720
|
-
const osRelease =
|
|
21720
|
+
const osRelease = os6.release().split(".");
|
|
21721
21721
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
21722
21722
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
21723
21723
|
}
|
|
@@ -21963,10 +21963,10 @@ var require_src2 = __commonJS({
|
|
|
21963
21963
|
var fs_1 = __require("fs");
|
|
21964
21964
|
var debug_1 = __importDefault(require_src());
|
|
21965
21965
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
21966
|
-
function check2(
|
|
21967
|
-
log2(`checking %s`,
|
|
21966
|
+
function check2(path32, isFile, isDirectory) {
|
|
21967
|
+
log2(`checking %s`, path32);
|
|
21968
21968
|
try {
|
|
21969
|
-
const stat2 = fs_1.statSync(
|
|
21969
|
+
const stat2 = fs_1.statSync(path32);
|
|
21970
21970
|
if (stat2.isFile() && isFile) {
|
|
21971
21971
|
log2(`[OK] path represents a file`);
|
|
21972
21972
|
return true;
|
|
@@ -21986,8 +21986,8 @@ var require_src2 = __commonJS({
|
|
|
21986
21986
|
throw e;
|
|
21987
21987
|
}
|
|
21988
21988
|
}
|
|
21989
|
-
function exists2(
|
|
21990
|
-
return check2(
|
|
21989
|
+
function exists2(path32, type = exports.READABLE) {
|
|
21990
|
+
return check2(path32, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
21991
21991
|
}
|
|
21992
21992
|
exports.exists = exists2;
|
|
21993
21993
|
exports.FILE = 1;
|
|
@@ -22802,8 +22802,8 @@ function randomSecret() {
|
|
|
22802
22802
|
}
|
|
22803
22803
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
22804
22804
|
}
|
|
22805
|
-
async function requestPreviewApi(port, secret, method,
|
|
22806
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
22805
|
+
async function requestPreviewApi(port, secret, method, path32, body) {
|
|
22806
|
+
const url2 = `http://127.0.0.1:${port}${path32}`;
|
|
22807
22807
|
const headers = {
|
|
22808
22808
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
22809
22809
|
"Content-Type": "application/json"
|
|
@@ -22815,7 +22815,7 @@ async function requestPreviewApi(port, secret, method, path31, body) {
|
|
|
22815
22815
|
});
|
|
22816
22816
|
const data = await res.json().catch(() => ({}));
|
|
22817
22817
|
if (!res.ok) {
|
|
22818
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
22818
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path32}: ${res.status}`);
|
|
22819
22819
|
}
|
|
22820
22820
|
return data;
|
|
22821
22821
|
}
|
|
@@ -23040,8 +23040,521 @@ function installBridgeProcessResilience() {
|
|
|
23040
23040
|
});
|
|
23041
23041
|
}
|
|
23042
23042
|
|
|
23043
|
+
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
23044
|
+
import process7 from "node:process";
|
|
23045
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
23046
|
+
import path4 from "node:path";
|
|
23047
|
+
import { fileURLToPath } from "node:url";
|
|
23048
|
+
import { promisify as promisify5 } from "node:util";
|
|
23049
|
+
import childProcess from "node:child_process";
|
|
23050
|
+
import fs6, { constants as fsConstants2 } from "node:fs/promises";
|
|
23051
|
+
|
|
23052
|
+
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
23053
|
+
import process3 from "node:process";
|
|
23054
|
+
import fs5, { constants as fsConstants } from "node:fs/promises";
|
|
23055
|
+
|
|
23056
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
23057
|
+
import process2 from "node:process";
|
|
23058
|
+
import os2 from "node:os";
|
|
23059
|
+
import fs4 from "node:fs";
|
|
23060
|
+
|
|
23061
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
23062
|
+
import fs3 from "node:fs";
|
|
23063
|
+
|
|
23064
|
+
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
23065
|
+
import fs2 from "node:fs";
|
|
23066
|
+
var isDockerCached;
|
|
23067
|
+
function hasDockerEnv() {
|
|
23068
|
+
try {
|
|
23069
|
+
fs2.statSync("/.dockerenv");
|
|
23070
|
+
return true;
|
|
23071
|
+
} catch {
|
|
23072
|
+
return false;
|
|
23073
|
+
}
|
|
23074
|
+
}
|
|
23075
|
+
function hasDockerCGroup() {
|
|
23076
|
+
try {
|
|
23077
|
+
return fs2.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
23078
|
+
} catch {
|
|
23079
|
+
return false;
|
|
23080
|
+
}
|
|
23081
|
+
}
|
|
23082
|
+
function isDocker() {
|
|
23083
|
+
if (isDockerCached === void 0) {
|
|
23084
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
23085
|
+
}
|
|
23086
|
+
return isDockerCached;
|
|
23087
|
+
}
|
|
23088
|
+
|
|
23089
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
23090
|
+
var cachedResult;
|
|
23091
|
+
var hasContainerEnv = () => {
|
|
23092
|
+
try {
|
|
23093
|
+
fs3.statSync("/run/.containerenv");
|
|
23094
|
+
return true;
|
|
23095
|
+
} catch {
|
|
23096
|
+
return false;
|
|
23097
|
+
}
|
|
23098
|
+
};
|
|
23099
|
+
function isInsideContainer() {
|
|
23100
|
+
if (cachedResult === void 0) {
|
|
23101
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
23102
|
+
}
|
|
23103
|
+
return cachedResult;
|
|
23104
|
+
}
|
|
23105
|
+
|
|
23106
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
23107
|
+
var isWsl = () => {
|
|
23108
|
+
if (process2.platform !== "linux") {
|
|
23109
|
+
return false;
|
|
23110
|
+
}
|
|
23111
|
+
if (os2.release().toLowerCase().includes("microsoft")) {
|
|
23112
|
+
if (isInsideContainer()) {
|
|
23113
|
+
return false;
|
|
23114
|
+
}
|
|
23115
|
+
return true;
|
|
23116
|
+
}
|
|
23117
|
+
try {
|
|
23118
|
+
if (fs4.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
23119
|
+
return !isInsideContainer();
|
|
23120
|
+
}
|
|
23121
|
+
} catch {
|
|
23122
|
+
}
|
|
23123
|
+
if (fs4.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs4.existsSync("/run/WSL")) {
|
|
23124
|
+
return !isInsideContainer();
|
|
23125
|
+
}
|
|
23126
|
+
return false;
|
|
23127
|
+
};
|
|
23128
|
+
var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
23129
|
+
|
|
23130
|
+
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
23131
|
+
var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
23132
|
+
const defaultMountPoint = "/mnt/";
|
|
23133
|
+
let mountPoint;
|
|
23134
|
+
return async function() {
|
|
23135
|
+
if (mountPoint) {
|
|
23136
|
+
return mountPoint;
|
|
23137
|
+
}
|
|
23138
|
+
const configFilePath2 = "/etc/wsl.conf";
|
|
23139
|
+
let isConfigFileExists = false;
|
|
23140
|
+
try {
|
|
23141
|
+
await fs5.access(configFilePath2, fsConstants.F_OK);
|
|
23142
|
+
isConfigFileExists = true;
|
|
23143
|
+
} catch {
|
|
23144
|
+
}
|
|
23145
|
+
if (!isConfigFileExists) {
|
|
23146
|
+
return defaultMountPoint;
|
|
23147
|
+
}
|
|
23148
|
+
const configContent = await fs5.readFile(configFilePath2, { encoding: "utf8" });
|
|
23149
|
+
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
23150
|
+
if (!configMountPoint) {
|
|
23151
|
+
return defaultMountPoint;
|
|
23152
|
+
}
|
|
23153
|
+
mountPoint = configMountPoint.groups.mountPoint.trim();
|
|
23154
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
23155
|
+
return mountPoint;
|
|
23156
|
+
};
|
|
23157
|
+
})();
|
|
23158
|
+
var powerShellPathFromWsl = async () => {
|
|
23159
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
23160
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
23161
|
+
};
|
|
23162
|
+
var powerShellPath = async () => {
|
|
23163
|
+
if (is_wsl_default) {
|
|
23164
|
+
return powerShellPathFromWsl();
|
|
23165
|
+
}
|
|
23166
|
+
return `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
23167
|
+
};
|
|
23168
|
+
|
|
23169
|
+
// ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
23170
|
+
function defineLazyProperty(object2, propertyName, valueGetter) {
|
|
23171
|
+
const define = (value) => Object.defineProperty(object2, propertyName, { value, enumerable: true, writable: true });
|
|
23172
|
+
Object.defineProperty(object2, propertyName, {
|
|
23173
|
+
configurable: true,
|
|
23174
|
+
enumerable: true,
|
|
23175
|
+
get() {
|
|
23176
|
+
const result = valueGetter();
|
|
23177
|
+
define(result);
|
|
23178
|
+
return result;
|
|
23179
|
+
},
|
|
23180
|
+
set(value) {
|
|
23181
|
+
define(value);
|
|
23182
|
+
}
|
|
23183
|
+
});
|
|
23184
|
+
return object2;
|
|
23185
|
+
}
|
|
23186
|
+
|
|
23187
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
23188
|
+
import { promisify as promisify4 } from "node:util";
|
|
23189
|
+
import process6 from "node:process";
|
|
23190
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
23191
|
+
|
|
23192
|
+
// ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
23193
|
+
import { promisify } from "node:util";
|
|
23194
|
+
import process4 from "node:process";
|
|
23195
|
+
import { execFile } from "node:child_process";
|
|
23196
|
+
var execFileAsync = promisify(execFile);
|
|
23197
|
+
async function defaultBrowserId() {
|
|
23198
|
+
if (process4.platform !== "darwin") {
|
|
23199
|
+
throw new Error("macOS only");
|
|
23200
|
+
}
|
|
23201
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
23202
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
23203
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
23204
|
+
if (browserId === "com.apple.safari") {
|
|
23205
|
+
return "com.apple.Safari";
|
|
23206
|
+
}
|
|
23207
|
+
return browserId;
|
|
23208
|
+
}
|
|
23209
|
+
|
|
23210
|
+
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
23211
|
+
import process5 from "node:process";
|
|
23212
|
+
import { promisify as promisify2 } from "node:util";
|
|
23213
|
+
import { execFile as execFile2, execFileSync } from "node:child_process";
|
|
23214
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
23215
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
23216
|
+
if (process5.platform !== "darwin") {
|
|
23217
|
+
throw new Error("macOS only");
|
|
23218
|
+
}
|
|
23219
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
23220
|
+
const execOptions = {};
|
|
23221
|
+
if (signal) {
|
|
23222
|
+
execOptions.signal = signal;
|
|
23223
|
+
}
|
|
23224
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
23225
|
+
return stdout.trim();
|
|
23226
|
+
}
|
|
23227
|
+
|
|
23228
|
+
// ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
23229
|
+
async function bundleName(bundleId) {
|
|
23230
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
23231
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
23232
|
+
}
|
|
23233
|
+
|
|
23234
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
23235
|
+
import { promisify as promisify3 } from "node:util";
|
|
23236
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
23237
|
+
var execFileAsync3 = promisify3(execFile3);
|
|
23238
|
+
var windowsBrowserProgIds = {
|
|
23239
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
23240
|
+
// The missing `L` is correct.
|
|
23241
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
23242
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
23243
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
23244
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
23245
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
23246
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
23247
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
23248
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
23249
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
23250
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
23251
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
23252
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
23253
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
23254
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
23255
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
23256
|
+
};
|
|
23257
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
23258
|
+
var UnknownBrowserError = class extends Error {
|
|
23259
|
+
};
|
|
23260
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
23261
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
23262
|
+
"QUERY",
|
|
23263
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
23264
|
+
"/v",
|
|
23265
|
+
"ProgId"
|
|
23266
|
+
]);
|
|
23267
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
23268
|
+
if (!match) {
|
|
23269
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
23270
|
+
}
|
|
23271
|
+
const { id } = match.groups;
|
|
23272
|
+
const dotIndex = id.lastIndexOf(".");
|
|
23273
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
23274
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
23275
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
23276
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
23277
|
+
}
|
|
23278
|
+
|
|
23279
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
23280
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
23281
|
+
var titleize = (string4) => string4.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
23282
|
+
async function defaultBrowser2() {
|
|
23283
|
+
if (process6.platform === "darwin") {
|
|
23284
|
+
const id = await defaultBrowserId();
|
|
23285
|
+
const name = await bundleName(id);
|
|
23286
|
+
return { name, id };
|
|
23287
|
+
}
|
|
23288
|
+
if (process6.platform === "linux") {
|
|
23289
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
23290
|
+
const id = stdout.trim();
|
|
23291
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
23292
|
+
return { name, id };
|
|
23293
|
+
}
|
|
23294
|
+
if (process6.platform === "win32") {
|
|
23295
|
+
return defaultBrowser();
|
|
23296
|
+
}
|
|
23297
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
23298
|
+
}
|
|
23299
|
+
|
|
23300
|
+
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
23301
|
+
var execFile5 = promisify5(childProcess.execFile);
|
|
23302
|
+
var __dirname = path4.dirname(fileURLToPath(import.meta.url));
|
|
23303
|
+
var localXdgOpenPath = path4.join(__dirname, "xdg-open");
|
|
23304
|
+
var { platform, arch } = process7;
|
|
23305
|
+
async function getWindowsDefaultBrowserFromWsl() {
|
|
23306
|
+
const powershellPath = await powerShellPath();
|
|
23307
|
+
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
23308
|
+
const encodedCommand = Buffer2.from(rawCommand, "utf16le").toString("base64");
|
|
23309
|
+
const { stdout } = await execFile5(
|
|
23310
|
+
powershellPath,
|
|
23311
|
+
[
|
|
23312
|
+
"-NoProfile",
|
|
23313
|
+
"-NonInteractive",
|
|
23314
|
+
"-ExecutionPolicy",
|
|
23315
|
+
"Bypass",
|
|
23316
|
+
"-EncodedCommand",
|
|
23317
|
+
encodedCommand
|
|
23318
|
+
],
|
|
23319
|
+
{ encoding: "utf8" }
|
|
23320
|
+
);
|
|
23321
|
+
const progId = stdout.trim();
|
|
23322
|
+
const browserMap = {
|
|
23323
|
+
ChromeHTML: "com.google.chrome",
|
|
23324
|
+
BraveHTML: "com.brave.Browser",
|
|
23325
|
+
MSEdgeHTM: "com.microsoft.edge",
|
|
23326
|
+
FirefoxURL: "org.mozilla.firefox"
|
|
23327
|
+
};
|
|
23328
|
+
return browserMap[progId] ? { id: browserMap[progId] } : {};
|
|
23329
|
+
}
|
|
23330
|
+
var pTryEach = async (array2, mapper) => {
|
|
23331
|
+
let latestError;
|
|
23332
|
+
for (const item of array2) {
|
|
23333
|
+
try {
|
|
23334
|
+
return await mapper(item);
|
|
23335
|
+
} catch (error40) {
|
|
23336
|
+
latestError = error40;
|
|
23337
|
+
}
|
|
23338
|
+
}
|
|
23339
|
+
throw latestError;
|
|
23340
|
+
};
|
|
23341
|
+
var baseOpen = async (options) => {
|
|
23342
|
+
options = {
|
|
23343
|
+
wait: false,
|
|
23344
|
+
background: false,
|
|
23345
|
+
newInstance: false,
|
|
23346
|
+
allowNonzeroExitCode: false,
|
|
23347
|
+
...options
|
|
23348
|
+
};
|
|
23349
|
+
if (Array.isArray(options.app)) {
|
|
23350
|
+
return pTryEach(options.app, (singleApp) => baseOpen({
|
|
23351
|
+
...options,
|
|
23352
|
+
app: singleApp
|
|
23353
|
+
}));
|
|
23354
|
+
}
|
|
23355
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
23356
|
+
appArguments = [...appArguments];
|
|
23357
|
+
if (Array.isArray(app)) {
|
|
23358
|
+
return pTryEach(app, (appName) => baseOpen({
|
|
23359
|
+
...options,
|
|
23360
|
+
app: {
|
|
23361
|
+
name: appName,
|
|
23362
|
+
arguments: appArguments
|
|
23363
|
+
}
|
|
23364
|
+
}));
|
|
23365
|
+
}
|
|
23366
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
23367
|
+
const ids = {
|
|
23368
|
+
"com.google.chrome": "chrome",
|
|
23369
|
+
"google-chrome.desktop": "chrome",
|
|
23370
|
+
"com.brave.Browser": "brave",
|
|
23371
|
+
"org.mozilla.firefox": "firefox",
|
|
23372
|
+
"firefox.desktop": "firefox",
|
|
23373
|
+
"com.microsoft.msedge": "edge",
|
|
23374
|
+
"com.microsoft.edge": "edge",
|
|
23375
|
+
"com.microsoft.edgemac": "edge",
|
|
23376
|
+
"microsoft-edge.desktop": "edge"
|
|
23377
|
+
};
|
|
23378
|
+
const flags = {
|
|
23379
|
+
chrome: "--incognito",
|
|
23380
|
+
brave: "--incognito",
|
|
23381
|
+
firefox: "--private-window",
|
|
23382
|
+
edge: "--inPrivate"
|
|
23383
|
+
};
|
|
23384
|
+
const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
|
|
23385
|
+
if (browser.id in ids) {
|
|
23386
|
+
const browserName = ids[browser.id];
|
|
23387
|
+
if (app === "browserPrivate") {
|
|
23388
|
+
appArguments.push(flags[browserName]);
|
|
23389
|
+
}
|
|
23390
|
+
return baseOpen({
|
|
23391
|
+
...options,
|
|
23392
|
+
app: {
|
|
23393
|
+
name: apps[browserName],
|
|
23394
|
+
arguments: appArguments
|
|
23395
|
+
}
|
|
23396
|
+
});
|
|
23397
|
+
}
|
|
23398
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
23399
|
+
}
|
|
23400
|
+
let command;
|
|
23401
|
+
const cliArguments = [];
|
|
23402
|
+
const childProcessOptions = {};
|
|
23403
|
+
if (platform === "darwin") {
|
|
23404
|
+
command = "open";
|
|
23405
|
+
if (options.wait) {
|
|
23406
|
+
cliArguments.push("--wait-apps");
|
|
23407
|
+
}
|
|
23408
|
+
if (options.background) {
|
|
23409
|
+
cliArguments.push("--background");
|
|
23410
|
+
}
|
|
23411
|
+
if (options.newInstance) {
|
|
23412
|
+
cliArguments.push("--new");
|
|
23413
|
+
}
|
|
23414
|
+
if (app) {
|
|
23415
|
+
cliArguments.push("-a", app);
|
|
23416
|
+
}
|
|
23417
|
+
} else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
|
|
23418
|
+
command = await powerShellPath();
|
|
23419
|
+
cliArguments.push(
|
|
23420
|
+
"-NoProfile",
|
|
23421
|
+
"-NonInteractive",
|
|
23422
|
+
"-ExecutionPolicy",
|
|
23423
|
+
"Bypass",
|
|
23424
|
+
"-EncodedCommand"
|
|
23425
|
+
);
|
|
23426
|
+
if (!is_wsl_default) {
|
|
23427
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
23428
|
+
}
|
|
23429
|
+
const encodedArguments = ["Start"];
|
|
23430
|
+
if (options.wait) {
|
|
23431
|
+
encodedArguments.push("-Wait");
|
|
23432
|
+
}
|
|
23433
|
+
if (app) {
|
|
23434
|
+
encodedArguments.push(`"\`"${app}\`""`);
|
|
23435
|
+
if (options.target) {
|
|
23436
|
+
appArguments.push(options.target);
|
|
23437
|
+
}
|
|
23438
|
+
} else if (options.target) {
|
|
23439
|
+
encodedArguments.push(`"${options.target}"`);
|
|
23440
|
+
}
|
|
23441
|
+
if (appArguments.length > 0) {
|
|
23442
|
+
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
|
|
23443
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
23444
|
+
}
|
|
23445
|
+
options.target = Buffer2.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
23446
|
+
} else {
|
|
23447
|
+
if (app) {
|
|
23448
|
+
command = app;
|
|
23449
|
+
} else {
|
|
23450
|
+
const isBundled = !__dirname || __dirname === "/";
|
|
23451
|
+
let exeLocalXdgOpen = false;
|
|
23452
|
+
try {
|
|
23453
|
+
await fs6.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
23454
|
+
exeLocalXdgOpen = true;
|
|
23455
|
+
} catch {
|
|
23456
|
+
}
|
|
23457
|
+
const useSystemXdgOpen = process7.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
23458
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
23459
|
+
}
|
|
23460
|
+
if (appArguments.length > 0) {
|
|
23461
|
+
cliArguments.push(...appArguments);
|
|
23462
|
+
}
|
|
23463
|
+
if (!options.wait) {
|
|
23464
|
+
childProcessOptions.stdio = "ignore";
|
|
23465
|
+
childProcessOptions.detached = true;
|
|
23466
|
+
}
|
|
23467
|
+
}
|
|
23468
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
23469
|
+
cliArguments.push("--args", ...appArguments);
|
|
23470
|
+
}
|
|
23471
|
+
if (options.target) {
|
|
23472
|
+
cliArguments.push(options.target);
|
|
23473
|
+
}
|
|
23474
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
23475
|
+
if (options.wait) {
|
|
23476
|
+
return new Promise((resolve15, reject) => {
|
|
23477
|
+
subprocess.once("error", reject);
|
|
23478
|
+
subprocess.once("close", (exitCode) => {
|
|
23479
|
+
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
23480
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
23481
|
+
return;
|
|
23482
|
+
}
|
|
23483
|
+
resolve15(subprocess);
|
|
23484
|
+
});
|
|
23485
|
+
});
|
|
23486
|
+
}
|
|
23487
|
+
subprocess.unref();
|
|
23488
|
+
return subprocess;
|
|
23489
|
+
};
|
|
23490
|
+
var open = (target, options) => {
|
|
23491
|
+
if (typeof target !== "string") {
|
|
23492
|
+
throw new TypeError("Expected a `target`");
|
|
23493
|
+
}
|
|
23494
|
+
return baseOpen({
|
|
23495
|
+
...options,
|
|
23496
|
+
target
|
|
23497
|
+
});
|
|
23498
|
+
};
|
|
23499
|
+
function detectArchBinary(binary) {
|
|
23500
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
23501
|
+
return binary;
|
|
23502
|
+
}
|
|
23503
|
+
const { [arch]: archBinary } = binary;
|
|
23504
|
+
if (!archBinary) {
|
|
23505
|
+
throw new Error(`${arch} is not supported`);
|
|
23506
|
+
}
|
|
23507
|
+
return archBinary;
|
|
23508
|
+
}
|
|
23509
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
23510
|
+
if (wsl && is_wsl_default) {
|
|
23511
|
+
return detectArchBinary(wsl);
|
|
23512
|
+
}
|
|
23513
|
+
if (!platformBinary) {
|
|
23514
|
+
throw new Error(`${platform} is not supported`);
|
|
23515
|
+
}
|
|
23516
|
+
return detectArchBinary(platformBinary);
|
|
23517
|
+
}
|
|
23518
|
+
var apps = {};
|
|
23519
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
23520
|
+
darwin: "google chrome",
|
|
23521
|
+
win32: "chrome",
|
|
23522
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium"]
|
|
23523
|
+
}, {
|
|
23524
|
+
wsl: {
|
|
23525
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
23526
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
23527
|
+
}
|
|
23528
|
+
}));
|
|
23529
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
23530
|
+
darwin: "brave browser",
|
|
23531
|
+
win32: "brave",
|
|
23532
|
+
linux: ["brave-browser", "brave"]
|
|
23533
|
+
}, {
|
|
23534
|
+
wsl: {
|
|
23535
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
23536
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
23537
|
+
}
|
|
23538
|
+
}));
|
|
23539
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
23540
|
+
darwin: "firefox",
|
|
23541
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
23542
|
+
linux: "firefox"
|
|
23543
|
+
}, {
|
|
23544
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
23545
|
+
}));
|
|
23546
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
23547
|
+
darwin: "microsoft edge",
|
|
23548
|
+
win32: "msedge",
|
|
23549
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
23550
|
+
}, {
|
|
23551
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
23552
|
+
}));
|
|
23553
|
+
defineLazyProperty(apps, "browser", () => "browser");
|
|
23554
|
+
defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
|
|
23555
|
+
var open_default = open;
|
|
23556
|
+
|
|
23043
23557
|
// src/auth/open-browser.ts
|
|
23044
|
-
import { execSync } from "node:child_process";
|
|
23045
23558
|
function isLocalApiUrl(apiUrl) {
|
|
23046
23559
|
try {
|
|
23047
23560
|
const u = new URL(apiUrl);
|
|
@@ -23051,7 +23564,7 @@ function isLocalApiUrl(apiUrl) {
|
|
|
23051
23564
|
return false;
|
|
23052
23565
|
}
|
|
23053
23566
|
}
|
|
23054
|
-
function openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn = log) {
|
|
23567
|
+
async function openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn = log) {
|
|
23055
23568
|
const appUrl = apiUrl && isLocalApiUrl(apiUrl) ? process.env.BUILDAUTOMATON_APP_URL ?? "http://localhost:3000" : process.env.BUILDAUTOMATON_APP_URL ?? "https://app.buildautomaton.com";
|
|
23056
23569
|
let connectCliUrl = `${appUrl.replace(/\/$/, "")}/bridges/connect?connectionId=${connectionId}`;
|
|
23057
23570
|
if (initialWorkspaceId) {
|
|
@@ -23065,10 +23578,11 @@ function openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiU
|
|
|
23065
23578
|
connectCliUrl += `&bridgeName=${encodeURIComponent(preferredBridgeName.trim())}`;
|
|
23066
23579
|
}
|
|
23067
23580
|
logFn("Opening browser to link this CLI\u2026");
|
|
23068
|
-
logFn(
|
|
23581
|
+
logFn(
|
|
23582
|
+
"If you\u2019re already signed in with one workspace, the CLI will connect automatically. Otherwise sign in and link to a workspace."
|
|
23583
|
+
);
|
|
23069
23584
|
try {
|
|
23070
|
-
|
|
23071
|
-
execSync(`${cmd} "${connectCliUrl}"`, { stdio: "ignore" });
|
|
23585
|
+
await open_default(connectCliUrl, { wait: false });
|
|
23072
23586
|
} catch {
|
|
23073
23587
|
logFn("Could not open browser. Open this URL manually:");
|
|
23074
23588
|
logFn(connectCliUrl);
|
|
@@ -23323,7 +23837,7 @@ function runPendingAuth(options) {
|
|
|
23323
23837
|
}
|
|
23324
23838
|
if (!hasOpenedBrowser) {
|
|
23325
23839
|
hasOpenedBrowser = true;
|
|
23326
|
-
openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
23840
|
+
void openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
23327
23841
|
}
|
|
23328
23842
|
},
|
|
23329
23843
|
onClose: (code, reason) => {
|
|
@@ -23365,7 +23879,7 @@ function runPendingAuth(options) {
|
|
|
23365
23879
|
browserFallback = null;
|
|
23366
23880
|
if (!hasOpenedBrowser) {
|
|
23367
23881
|
hasOpenedBrowser = true;
|
|
23368
|
-
openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
23882
|
+
void openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
23369
23883
|
}
|
|
23370
23884
|
}, BROWSER_OPEN_FALLBACK_MS);
|
|
23371
23885
|
connect();
|
|
@@ -23425,27 +23939,27 @@ async function closeBridgeConnection(state, acpManager, devServerManager, log2)
|
|
|
23425
23939
|
}
|
|
23426
23940
|
|
|
23427
23941
|
// src/git/session-git-queue.ts
|
|
23428
|
-
import { execFile as
|
|
23942
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
23429
23943
|
import { readFile, stat } from "node:fs/promises";
|
|
23430
|
-
import { promisify as
|
|
23431
|
-
import * as
|
|
23944
|
+
import { promisify as promisify7 } from "node:util";
|
|
23945
|
+
import * as path7 from "node:path";
|
|
23432
23946
|
|
|
23433
23947
|
// src/git/pre-turn-snapshot.ts
|
|
23434
|
-
import * as
|
|
23435
|
-
import * as
|
|
23436
|
-
import { execFile } from "node:child_process";
|
|
23437
|
-
import { promisify } from "node:util";
|
|
23948
|
+
import * as fs8 from "node:fs";
|
|
23949
|
+
import * as path6 from "node:path";
|
|
23950
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
23951
|
+
import { promisify as promisify6 } from "node:util";
|
|
23438
23952
|
|
|
23439
23953
|
// src/git/discover-repos.ts
|
|
23440
|
-
import * as
|
|
23441
|
-
import * as
|
|
23954
|
+
import * as fs7 from "node:fs";
|
|
23955
|
+
import * as path5 from "node:path";
|
|
23442
23956
|
|
|
23443
23957
|
// ../../node_modules/.pnpm/simple-git@3.32.3/node_modules/simple-git/dist/esm/index.js
|
|
23444
23958
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
23445
23959
|
var import_debug = __toESM(require_src(), 1);
|
|
23446
23960
|
var import_promise_deferred = __toESM(require_dist2(), 1);
|
|
23447
23961
|
var import_promise_deferred2 = __toESM(require_dist2(), 1);
|
|
23448
|
-
import { Buffer as
|
|
23962
|
+
import { Buffer as Buffer22 } from "node:buffer";
|
|
23449
23963
|
import { spawn as spawn3 } from "child_process";
|
|
23450
23964
|
import { normalize as normalize2 } from "node:path";
|
|
23451
23965
|
import { EventEmitter } from "node:events";
|
|
@@ -23477,8 +23991,8 @@ function pathspec(...paths) {
|
|
|
23477
23991
|
cache.set(key, paths);
|
|
23478
23992
|
return key;
|
|
23479
23993
|
}
|
|
23480
|
-
function isPathSpec(
|
|
23481
|
-
return
|
|
23994
|
+
function isPathSpec(path32) {
|
|
23995
|
+
return path32 instanceof String && cache.has(path32);
|
|
23482
23996
|
}
|
|
23483
23997
|
function toPaths(pathSpec) {
|
|
23484
23998
|
return cache.get(pathSpec) || [];
|
|
@@ -23567,8 +24081,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
23567
24081
|
function forEachLineWithContent(input, callback) {
|
|
23568
24082
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
23569
24083
|
}
|
|
23570
|
-
function folderExists(
|
|
23571
|
-
return (0, import_file_exists.exists)(
|
|
24084
|
+
function folderExists(path32) {
|
|
24085
|
+
return (0, import_file_exists.exists)(path32, import_file_exists.FOLDER);
|
|
23572
24086
|
}
|
|
23573
24087
|
function append(target, item) {
|
|
23574
24088
|
if (Array.isArray(target)) {
|
|
@@ -23625,7 +24139,7 @@ function prefixedArray(input, prefix) {
|
|
|
23625
24139
|
return output;
|
|
23626
24140
|
}
|
|
23627
24141
|
function bufferToString(input) {
|
|
23628
|
-
return (Array.isArray(input) ?
|
|
24142
|
+
return (Array.isArray(input) ? Buffer22.concat(input) : input).toString("utf-8");
|
|
23629
24143
|
}
|
|
23630
24144
|
function pick2(source, properties) {
|
|
23631
24145
|
const out = {};
|
|
@@ -23972,8 +24486,8 @@ function checkIsRepoRootTask() {
|
|
|
23972
24486
|
commands,
|
|
23973
24487
|
format: "utf-8",
|
|
23974
24488
|
onError,
|
|
23975
|
-
parser(
|
|
23976
|
-
return /^\.(git)?$/.test(
|
|
24489
|
+
parser(path32) {
|
|
24490
|
+
return /^\.(git)?$/.test(path32.trim());
|
|
23977
24491
|
}
|
|
23978
24492
|
};
|
|
23979
24493
|
}
|
|
@@ -24407,11 +24921,11 @@ function parseGrep(grep) {
|
|
|
24407
24921
|
const paths = /* @__PURE__ */ new Set();
|
|
24408
24922
|
const results = {};
|
|
24409
24923
|
forEachLineWithContent(grep, (input) => {
|
|
24410
|
-
const [
|
|
24411
|
-
paths.add(
|
|
24412
|
-
(results[
|
|
24924
|
+
const [path32, line, preview] = input.split(NULL);
|
|
24925
|
+
paths.add(path32);
|
|
24926
|
+
(results[path32] = results[path32] || []).push({
|
|
24413
24927
|
line: asNumber(line),
|
|
24414
|
-
path:
|
|
24928
|
+
path: path32,
|
|
24415
24929
|
preview
|
|
24416
24930
|
});
|
|
24417
24931
|
});
|
|
@@ -25176,14 +25690,14 @@ var init_hash_object = __esm2({
|
|
|
25176
25690
|
init_task();
|
|
25177
25691
|
}
|
|
25178
25692
|
});
|
|
25179
|
-
function parseInit(bare,
|
|
25693
|
+
function parseInit(bare, path32, text) {
|
|
25180
25694
|
const response = String(text).trim();
|
|
25181
25695
|
let result;
|
|
25182
25696
|
if (result = initResponseRegex.exec(response)) {
|
|
25183
|
-
return new InitSummary(bare,
|
|
25697
|
+
return new InitSummary(bare, path32, false, result[1]);
|
|
25184
25698
|
}
|
|
25185
25699
|
if (result = reInitResponseRegex.exec(response)) {
|
|
25186
|
-
return new InitSummary(bare,
|
|
25700
|
+
return new InitSummary(bare, path32, true, result[1]);
|
|
25187
25701
|
}
|
|
25188
25702
|
let gitDir = "";
|
|
25189
25703
|
const tokens = response.split(" ");
|
|
@@ -25194,7 +25708,7 @@ function parseInit(bare, path31, text) {
|
|
|
25194
25708
|
break;
|
|
25195
25709
|
}
|
|
25196
25710
|
}
|
|
25197
|
-
return new InitSummary(bare,
|
|
25711
|
+
return new InitSummary(bare, path32, /^re/i.test(response), gitDir);
|
|
25198
25712
|
}
|
|
25199
25713
|
var InitSummary;
|
|
25200
25714
|
var initResponseRegex;
|
|
@@ -25203,9 +25717,9 @@ var init_InitSummary = __esm2({
|
|
|
25203
25717
|
"src/lib/responses/InitSummary.ts"() {
|
|
25204
25718
|
"use strict";
|
|
25205
25719
|
InitSummary = class {
|
|
25206
|
-
constructor(bare,
|
|
25720
|
+
constructor(bare, path32, existing, gitDir) {
|
|
25207
25721
|
this.bare = bare;
|
|
25208
|
-
this.path =
|
|
25722
|
+
this.path = path32;
|
|
25209
25723
|
this.existing = existing;
|
|
25210
25724
|
this.gitDir = gitDir;
|
|
25211
25725
|
}
|
|
@@ -25217,7 +25731,7 @@ var init_InitSummary = __esm2({
|
|
|
25217
25731
|
function hasBareCommand(command) {
|
|
25218
25732
|
return command.includes(bareCommand);
|
|
25219
25733
|
}
|
|
25220
|
-
function initTask(bare = false,
|
|
25734
|
+
function initTask(bare = false, path32, customArgs) {
|
|
25221
25735
|
const commands = ["init", ...customArgs];
|
|
25222
25736
|
if (bare && !hasBareCommand(commands)) {
|
|
25223
25737
|
commands.splice(1, 0, bareCommand);
|
|
@@ -25226,7 +25740,7 @@ function initTask(bare = false, path31, customArgs) {
|
|
|
25226
25740
|
commands,
|
|
25227
25741
|
format: "utf-8",
|
|
25228
25742
|
parser(text) {
|
|
25229
|
-
return parseInit(commands.includes("--bare"),
|
|
25743
|
+
return parseInit(commands.includes("--bare"), path32, text);
|
|
25230
25744
|
}
|
|
25231
25745
|
};
|
|
25232
25746
|
}
|
|
@@ -26042,12 +26556,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
26042
26556
|
"use strict";
|
|
26043
26557
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
26044
26558
|
FileStatusSummary = class {
|
|
26045
|
-
constructor(
|
|
26046
|
-
this.path =
|
|
26559
|
+
constructor(path32, index, working_dir) {
|
|
26560
|
+
this.path = path32;
|
|
26047
26561
|
this.index = index;
|
|
26048
26562
|
this.working_dir = working_dir;
|
|
26049
26563
|
if (index === "R" || working_dir === "R") {
|
|
26050
|
-
const detail = fromPathRegex.exec(
|
|
26564
|
+
const detail = fromPathRegex.exec(path32) || [null, path32, path32];
|
|
26051
26565
|
this.from = detail[2] || "";
|
|
26052
26566
|
this.path = detail[1] || "";
|
|
26053
26567
|
}
|
|
@@ -26078,14 +26592,14 @@ function splitLine(result, lineStr) {
|
|
|
26078
26592
|
default:
|
|
26079
26593
|
return;
|
|
26080
26594
|
}
|
|
26081
|
-
function data(index, workingDir,
|
|
26595
|
+
function data(index, workingDir, path32) {
|
|
26082
26596
|
const raw = `${index}${workingDir}`;
|
|
26083
26597
|
const handler = parsers6.get(raw);
|
|
26084
26598
|
if (handler) {
|
|
26085
|
-
handler(result,
|
|
26599
|
+
handler(result, path32);
|
|
26086
26600
|
}
|
|
26087
26601
|
if (raw !== "##" && raw !== "!!") {
|
|
26088
|
-
result.files.push(new FileStatusSummary(
|
|
26602
|
+
result.files.push(new FileStatusSummary(path32, index, workingDir));
|
|
26089
26603
|
}
|
|
26090
26604
|
}
|
|
26091
26605
|
}
|
|
@@ -26394,9 +26908,9 @@ var init_simple_git_api = __esm2({
|
|
|
26394
26908
|
next
|
|
26395
26909
|
);
|
|
26396
26910
|
}
|
|
26397
|
-
hashObject(
|
|
26911
|
+
hashObject(path32, write) {
|
|
26398
26912
|
return this._runTask(
|
|
26399
|
-
hashObjectTask(
|
|
26913
|
+
hashObjectTask(path32, write === true),
|
|
26400
26914
|
trailingFunctionArgument(arguments)
|
|
26401
26915
|
);
|
|
26402
26916
|
}
|
|
@@ -26749,8 +27263,8 @@ var init_branch = __esm2({
|
|
|
26749
27263
|
}
|
|
26750
27264
|
});
|
|
26751
27265
|
function toPath(input) {
|
|
26752
|
-
const
|
|
26753
|
-
return
|
|
27266
|
+
const path32 = input.trim().replace(/^["']|["']$/g, "");
|
|
27267
|
+
return path32 && normalize2(path32);
|
|
26754
27268
|
}
|
|
26755
27269
|
var parseCheckIgnore;
|
|
26756
27270
|
var init_CheckIgnore = __esm2({
|
|
@@ -27064,8 +27578,8 @@ __export2(sub_module_exports, {
|
|
|
27064
27578
|
subModuleTask: () => subModuleTask,
|
|
27065
27579
|
updateSubModuleTask: () => updateSubModuleTask
|
|
27066
27580
|
});
|
|
27067
|
-
function addSubModuleTask(repo,
|
|
27068
|
-
return subModuleTask(["add", repo,
|
|
27581
|
+
function addSubModuleTask(repo, path32) {
|
|
27582
|
+
return subModuleTask(["add", repo, path32]);
|
|
27069
27583
|
}
|
|
27070
27584
|
function initSubModuleTask(customArgs) {
|
|
27071
27585
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -27398,8 +27912,8 @@ var require_git = __commonJS2({
|
|
|
27398
27912
|
}
|
|
27399
27913
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
27400
27914
|
};
|
|
27401
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
27402
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
27915
|
+
Git2.prototype.submoduleAdd = function(repo, path32, then) {
|
|
27916
|
+
return this._runTask(addSubModuleTask2(repo, path32), trailingFunctionArgument2(arguments));
|
|
27403
27917
|
};
|
|
27404
27918
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
27405
27919
|
return this._runTask(
|
|
@@ -28025,20 +28539,20 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
28025
28539
|
// src/git/discover-repos.ts
|
|
28026
28540
|
async function discoverGitRepos(cwd = getBridgeWorkspaceDirectory()) {
|
|
28027
28541
|
const result = [];
|
|
28028
|
-
const cwdResolved =
|
|
28542
|
+
const cwdResolved = path5.resolve(cwd);
|
|
28029
28543
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
28030
28544
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
28031
28545
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
28032
28546
|
}
|
|
28033
28547
|
let entries;
|
|
28034
28548
|
try {
|
|
28035
|
-
entries =
|
|
28549
|
+
entries = fs7.readdirSync(cwdResolved, { withFileTypes: true });
|
|
28036
28550
|
} catch {
|
|
28037
28551
|
return result;
|
|
28038
28552
|
}
|
|
28039
28553
|
for (const ent of entries) {
|
|
28040
28554
|
if (!ent.isDirectory()) continue;
|
|
28041
|
-
const childPath =
|
|
28555
|
+
const childPath = path5.join(cwdResolved, ent.name);
|
|
28042
28556
|
if (await isGitRepoDirectory(childPath)) {
|
|
28043
28557
|
const remoteUrl = await getRemoteOriginUrl(childPath);
|
|
28044
28558
|
result.push({ absolutePath: childPath, remoteUrl });
|
|
@@ -28047,22 +28561,22 @@ async function discoverGitRepos(cwd = getBridgeWorkspaceDirectory()) {
|
|
|
28047
28561
|
return result;
|
|
28048
28562
|
}
|
|
28049
28563
|
async function discoverGitReposUnderRoot(rootAbs) {
|
|
28050
|
-
const root =
|
|
28564
|
+
const root = path5.resolve(rootAbs);
|
|
28051
28565
|
const roots = [];
|
|
28052
28566
|
async function walk(dir) {
|
|
28053
28567
|
if (await isGitRepoDirectory(dir)) {
|
|
28054
|
-
roots.push(
|
|
28568
|
+
roots.push(path5.resolve(dir));
|
|
28055
28569
|
return;
|
|
28056
28570
|
}
|
|
28057
28571
|
let entries;
|
|
28058
28572
|
try {
|
|
28059
|
-
entries =
|
|
28573
|
+
entries = fs7.readdirSync(dir, { withFileTypes: true });
|
|
28060
28574
|
} catch {
|
|
28061
28575
|
return;
|
|
28062
28576
|
}
|
|
28063
28577
|
for (const ent of entries) {
|
|
28064
28578
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
28065
|
-
await walk(
|
|
28579
|
+
await walk(path5.join(dir, ent.name));
|
|
28066
28580
|
}
|
|
28067
28581
|
}
|
|
28068
28582
|
await walk(root);
|
|
@@ -28076,13 +28590,13 @@ async function discoverGitReposUnderRoot(rootAbs) {
|
|
|
28076
28590
|
}
|
|
28077
28591
|
|
|
28078
28592
|
// src/git/pre-turn-snapshot.ts
|
|
28079
|
-
var
|
|
28593
|
+
var execFileAsync5 = promisify6(execFile6);
|
|
28080
28594
|
function snapshotsDirForCwd(agentCwd) {
|
|
28081
|
-
return
|
|
28595
|
+
return path6.join(agentCwd, ".buildautomaton", "snapshots");
|
|
28082
28596
|
}
|
|
28083
28597
|
async function gitStashCreate(repoRoot, log2) {
|
|
28084
28598
|
try {
|
|
28085
|
-
const { stdout } = await
|
|
28599
|
+
const { stdout } = await execFileAsync5("git", ["stash", "create"], {
|
|
28086
28600
|
cwd: repoRoot,
|
|
28087
28601
|
maxBuffer: 10 * 1024 * 1024
|
|
28088
28602
|
});
|
|
@@ -28096,7 +28610,7 @@ async function gitStashCreate(repoRoot, log2) {
|
|
|
28096
28610
|
}
|
|
28097
28611
|
async function gitRun(repoRoot, args, log2, label) {
|
|
28098
28612
|
try {
|
|
28099
|
-
await
|
|
28613
|
+
await execFileAsync5("git", args, { cwd: repoRoot, maxBuffer: 10 * 1024 * 1024 });
|
|
28100
28614
|
return { ok: true };
|
|
28101
28615
|
} catch (e) {
|
|
28102
28616
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -28107,7 +28621,7 @@ async function gitRun(repoRoot, args, log2, label) {
|
|
|
28107
28621
|
async function resolveSnapshotRepoRoots(options) {
|
|
28108
28622
|
const { worktreePaths, fallbackCwd, log: log2 } = options;
|
|
28109
28623
|
if (worktreePaths?.length) {
|
|
28110
|
-
const uniq = [...new Set(worktreePaths.map((p) =>
|
|
28624
|
+
const uniq = [...new Set(worktreePaths.map((p) => path6.resolve(p)))];
|
|
28111
28625
|
return uniq;
|
|
28112
28626
|
}
|
|
28113
28627
|
try {
|
|
@@ -28130,7 +28644,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
28130
28644
|
}
|
|
28131
28645
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
28132
28646
|
try {
|
|
28133
|
-
|
|
28647
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
28134
28648
|
} catch (e) {
|
|
28135
28649
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
28136
28650
|
}
|
|
@@ -28139,9 +28653,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
28139
28653
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
28140
28654
|
repos
|
|
28141
28655
|
};
|
|
28142
|
-
const filePath =
|
|
28656
|
+
const filePath = path6.join(dir, `${runId}.json`);
|
|
28143
28657
|
try {
|
|
28144
|
-
|
|
28658
|
+
fs8.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
28145
28659
|
} catch (e) {
|
|
28146
28660
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
28147
28661
|
}
|
|
@@ -28154,7 +28668,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
28154
28668
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
28155
28669
|
let data;
|
|
28156
28670
|
try {
|
|
28157
|
-
const raw =
|
|
28671
|
+
const raw = fs8.readFileSync(filePath, "utf8");
|
|
28158
28672
|
data = JSON.parse(raw);
|
|
28159
28673
|
} catch (e) {
|
|
28160
28674
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
@@ -28177,11 +28691,11 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
28177
28691
|
return { ok: true };
|
|
28178
28692
|
}
|
|
28179
28693
|
function snapshotFilePath(agentCwd, runId) {
|
|
28180
|
-
return
|
|
28694
|
+
return path6.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
28181
28695
|
}
|
|
28182
28696
|
|
|
28183
28697
|
// src/git/session-git-queue.ts
|
|
28184
|
-
var
|
|
28698
|
+
var execFileAsync6 = promisify7(execFile7);
|
|
28185
28699
|
var MAX_FULL_FILE_TEXT_BYTES = 512 * 1024;
|
|
28186
28700
|
async function readWorkspaceFileAsUtf8(absPath) {
|
|
28187
28701
|
try {
|
|
@@ -28214,7 +28728,7 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
28214
28728
|
if (!repo.stashSha) continue;
|
|
28215
28729
|
let namesRaw;
|
|
28216
28730
|
try {
|
|
28217
|
-
const { stdout } = await
|
|
28731
|
+
const { stdout } = await execFileAsync6("git", ["diff", "--name-only", repo.stashSha], {
|
|
28218
28732
|
cwd: repo.path,
|
|
28219
28733
|
maxBuffer: 10 * 1024 * 1024
|
|
28220
28734
|
});
|
|
@@ -28226,11 +28740,11 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
28226
28740
|
continue;
|
|
28227
28741
|
}
|
|
28228
28742
|
const lines = namesRaw.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
28229
|
-
const slug =
|
|
28743
|
+
const slug = path7.basename(repo.path).replace(/[^\w.-]+/g, "_") || "repo";
|
|
28230
28744
|
for (const rel of lines) {
|
|
28231
28745
|
if (rel.includes("..")) continue;
|
|
28232
28746
|
try {
|
|
28233
|
-
const { stdout: patchContent } = await
|
|
28747
|
+
const { stdout: patchContent } = await execFileAsync6(
|
|
28234
28748
|
"git",
|
|
28235
28749
|
["diff", "--no-color", repo.stashSha, "--", rel],
|
|
28236
28750
|
{
|
|
@@ -28240,7 +28754,7 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
28240
28754
|
);
|
|
28241
28755
|
if (!patchContent.trim()) continue;
|
|
28242
28756
|
const displayPath = multiRepo ? `${slug}/${rel}` : rel;
|
|
28243
|
-
const absFile =
|
|
28757
|
+
const absFile = path7.join(repo.path, rel);
|
|
28244
28758
|
const newText = await readWorkspaceFileAsUtf8(absFile);
|
|
28245
28759
|
sendSessionUpdate({
|
|
28246
28760
|
type: "session_file_change",
|
|
@@ -28302,7 +28816,9 @@ async function sendPromptToAgent(options) {
|
|
|
28302
28816
|
...augmentAuthFields(errStr)
|
|
28303
28817
|
});
|
|
28304
28818
|
if (!result.success) {
|
|
28305
|
-
log2(
|
|
28819
|
+
log2(
|
|
28820
|
+
`[Agent] Prompt did not run successfully on the agent (no successful start/completion): ${result.error ?? "Unknown error"}`
|
|
28821
|
+
);
|
|
28306
28822
|
}
|
|
28307
28823
|
} catch (err) {
|
|
28308
28824
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
@@ -28320,8 +28836,8 @@ async function sendPromptToAgent(options) {
|
|
|
28320
28836
|
}
|
|
28321
28837
|
|
|
28322
28838
|
// src/agents/acp/ensure-acp-client.ts
|
|
28323
|
-
import * as
|
|
28324
|
-
import * as
|
|
28839
|
+
import * as fs9 from "node:fs";
|
|
28840
|
+
import * as path10 from "node:path";
|
|
28325
28841
|
|
|
28326
28842
|
// src/error-message.ts
|
|
28327
28843
|
function errorMessage(err) {
|
|
@@ -28341,16 +28857,16 @@ __export(claude_code_acp_client_exports, {
|
|
|
28341
28857
|
createClaudeCodeAcpClient: () => createClaudeCodeAcpClient,
|
|
28342
28858
|
detectLocalAgentPresence: () => detectLocalAgentPresence
|
|
28343
28859
|
});
|
|
28344
|
-
import { execFile as
|
|
28345
|
-
import { promisify as
|
|
28860
|
+
import { execFile as execFile9 } from "node:child_process";
|
|
28861
|
+
import { promisify as promisify9 } from "node:util";
|
|
28346
28862
|
|
|
28347
28863
|
// src/agents/acp/clients/detect-command-on-path.ts
|
|
28348
|
-
import { execFile as
|
|
28349
|
-
import { promisify as
|
|
28350
|
-
var
|
|
28864
|
+
import { execFile as execFile8 } from "node:child_process";
|
|
28865
|
+
import { promisify as promisify8 } from "node:util";
|
|
28866
|
+
var execFileAsync7 = promisify8(execFile8);
|
|
28351
28867
|
async function isCommandOnPath(command, timeoutMs = 4e3) {
|
|
28352
28868
|
try {
|
|
28353
|
-
await
|
|
28869
|
+
await execFileAsync7("which", [command], { timeout: timeoutMs });
|
|
28354
28870
|
return true;
|
|
28355
28871
|
} catch {
|
|
28356
28872
|
return false;
|
|
@@ -28358,12 +28874,12 @@ async function isCommandOnPath(command, timeoutMs = 4e3) {
|
|
|
28358
28874
|
}
|
|
28359
28875
|
|
|
28360
28876
|
// src/agents/acp/clients/claude-code-acp-client.ts
|
|
28361
|
-
var
|
|
28877
|
+
var execFileAsync8 = promisify9(execFile9);
|
|
28362
28878
|
var BACKEND_LOCAL_AGENT_TYPE = "claude-code";
|
|
28363
28879
|
async function detectLocalAgentPresence() {
|
|
28364
28880
|
if (await isCommandOnPath("claude")) return true;
|
|
28365
28881
|
try {
|
|
28366
|
-
await
|
|
28882
|
+
await execFileAsync8("npx", ["--yes", "@anthropic-ai/claude-code", "--version"], { timeout: 25e3 });
|
|
28367
28883
|
return true;
|
|
28368
28884
|
} catch {
|
|
28369
28885
|
return false;
|
|
@@ -28861,48 +29377,48 @@ function resolveAgentCommand(preferredAgentType) {
|
|
|
28861
29377
|
}
|
|
28862
29378
|
|
|
28863
29379
|
// src/agents/acp/session-file-change-path-kind.ts
|
|
28864
|
-
import { execFileSync as
|
|
29380
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
28865
29381
|
import { existsSync, statSync } from "node:fs";
|
|
28866
29382
|
|
|
28867
29383
|
// src/git/get-git-repo-root-sync.ts
|
|
28868
|
-
import { execFileSync } from "node:child_process";
|
|
28869
|
-
import * as
|
|
29384
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
29385
|
+
import * as path8 from "node:path";
|
|
28870
29386
|
function getGitRepoRootSync(startDir) {
|
|
28871
29387
|
try {
|
|
28872
|
-
const out =
|
|
28873
|
-
cwd:
|
|
29388
|
+
const out = execFileSync2("git", ["rev-parse", "--show-toplevel"], {
|
|
29389
|
+
cwd: path8.resolve(startDir),
|
|
28874
29390
|
encoding: "utf8",
|
|
28875
29391
|
stdio: ["ignore", "pipe", "ignore"],
|
|
28876
29392
|
maxBuffer: 1024 * 1024
|
|
28877
29393
|
}).trim();
|
|
28878
|
-
return out ?
|
|
29394
|
+
return out ? path8.resolve(out) : null;
|
|
28879
29395
|
} catch {
|
|
28880
29396
|
return null;
|
|
28881
29397
|
}
|
|
28882
29398
|
}
|
|
28883
29399
|
|
|
28884
29400
|
// src/agents/acp/workspace-files.ts
|
|
28885
|
-
import { execFileSync as
|
|
29401
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
28886
29402
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
28887
|
-
import * as
|
|
29403
|
+
import * as path9 from "node:path";
|
|
28888
29404
|
function resolveWorkspaceFilePath(cwd, rawPath) {
|
|
28889
29405
|
const trimmed2 = rawPath.trim();
|
|
28890
29406
|
if (!trimmed2) return null;
|
|
28891
|
-
const normalizedCwd =
|
|
29407
|
+
const normalizedCwd = path9.resolve(cwd);
|
|
28892
29408
|
let abs = resolveSafePathUnderCwd(cwd, trimmed2);
|
|
28893
29409
|
if (!abs) {
|
|
28894
|
-
const candidate =
|
|
29410
|
+
const candidate = path9.isAbsolute(trimmed2) ? path9.normalize(trimmed2) : path9.normalize(path9.resolve(normalizedCwd, trimmed2));
|
|
28895
29411
|
const gitRoot2 = getGitRepoRootSync(cwd);
|
|
28896
29412
|
if (!gitRoot2) return null;
|
|
28897
|
-
const rel =
|
|
28898
|
-
if (rel.startsWith("..") ||
|
|
29413
|
+
const rel = path9.relative(gitRoot2, candidate);
|
|
29414
|
+
if (rel.startsWith("..") || path9.isAbsolute(rel)) return null;
|
|
28899
29415
|
abs = candidate;
|
|
28900
29416
|
}
|
|
28901
29417
|
const gitRoot = getGitRepoRootSync(cwd);
|
|
28902
29418
|
if (gitRoot) {
|
|
28903
|
-
const relFromRoot =
|
|
28904
|
-
if (!relFromRoot.startsWith("..") && !
|
|
28905
|
-
return { abs, display: relFromRoot.split(
|
|
29419
|
+
const relFromRoot = path9.relative(gitRoot, abs);
|
|
29420
|
+
if (!relFromRoot.startsWith("..") && !path9.isAbsolute(relFromRoot)) {
|
|
29421
|
+
return { abs, display: relFromRoot.split(path9.sep).join("/") };
|
|
28906
29422
|
}
|
|
28907
29423
|
}
|
|
28908
29424
|
return { abs, display: toDisplayPathRelativeToCwd(cwd, abs) };
|
|
@@ -28911,9 +29427,9 @@ function readUtf8WorkspaceFile(cwd, displayPath) {
|
|
|
28911
29427
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
28912
29428
|
const gitRoot = getGitRepoRootSync(cwd);
|
|
28913
29429
|
if (gitRoot) {
|
|
28914
|
-
const abs2 =
|
|
28915
|
-
const rel =
|
|
28916
|
-
if (!rel.startsWith("..") && !
|
|
29430
|
+
const abs2 = path9.resolve(gitRoot, displayPath);
|
|
29431
|
+
const rel = path9.relative(gitRoot, abs2);
|
|
29432
|
+
if (!rel.startsWith("..") && !path9.isAbsolute(rel)) {
|
|
28917
29433
|
try {
|
|
28918
29434
|
return readFileSync4(abs2, "utf8");
|
|
28919
29435
|
} catch {
|
|
@@ -28932,9 +29448,9 @@ function tryWorkspaceDisplayToAbs(cwd, displayPath) {
|
|
|
28932
29448
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
28933
29449
|
const gitRoot = getGitRepoRootSync(cwd);
|
|
28934
29450
|
if (gitRoot) {
|
|
28935
|
-
const abs =
|
|
28936
|
-
const rel =
|
|
28937
|
-
if (!rel.startsWith("..") && !
|
|
29451
|
+
const abs = path9.resolve(gitRoot, displayPath);
|
|
29452
|
+
const rel = path9.relative(gitRoot, abs);
|
|
29453
|
+
if (!rel.startsWith("..") && !path9.isAbsolute(rel)) return abs;
|
|
28938
29454
|
}
|
|
28939
29455
|
return resolveSafePathUnderCwd(cwd, displayPath);
|
|
28940
29456
|
}
|
|
@@ -28943,7 +29459,7 @@ function readGitHeadBlob(cwd, displayPath) {
|
|
|
28943
29459
|
const gitRoot = getGitRepoRootSync(cwd);
|
|
28944
29460
|
const execCwd = gitRoot ?? cwd;
|
|
28945
29461
|
try {
|
|
28946
|
-
return
|
|
29462
|
+
return execFileSync3("git", ["show", `HEAD:${displayPath}`], {
|
|
28947
29463
|
cwd: execCwd,
|
|
28948
29464
|
encoding: "utf8",
|
|
28949
29465
|
maxBuffer: 50 * 1024 * 1024
|
|
@@ -28959,7 +29475,7 @@ function gitHeadPathObjectType(cwd, displayPath) {
|
|
|
28959
29475
|
const gitRoot = getGitRepoRootSync(cwd);
|
|
28960
29476
|
if (!gitRoot) return null;
|
|
28961
29477
|
try {
|
|
28962
|
-
return
|
|
29478
|
+
return execFileSync4("git", ["cat-file", "-t", `HEAD:${displayPath}`], {
|
|
28963
29479
|
cwd: gitRoot,
|
|
28964
29480
|
encoding: "utf8"
|
|
28965
29481
|
}).trim();
|
|
@@ -29050,7 +29566,7 @@ function createBridgeOnRequest(opts) {
|
|
|
29050
29566
|
}
|
|
29051
29567
|
|
|
29052
29568
|
// src/agents/acp/hooks/extract-acp-file-diffs-from-update/paths-and-text.ts
|
|
29053
|
-
import { fileURLToPath } from "node:url";
|
|
29569
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
29054
29570
|
function readOptionalTextField(v) {
|
|
29055
29571
|
if (v === null || v === void 0) return "";
|
|
29056
29572
|
if (typeof v === "string") return v;
|
|
@@ -29060,7 +29576,7 @@ function normalizePathField(raw) {
|
|
|
29060
29576
|
const t = raw.trim();
|
|
29061
29577
|
if (t.startsWith("file://")) {
|
|
29062
29578
|
try {
|
|
29063
|
-
return
|
|
29579
|
+
return fileURLToPath2(t);
|
|
29064
29580
|
} catch {
|
|
29065
29581
|
return t;
|
|
29066
29582
|
}
|
|
@@ -29502,10 +30018,10 @@ function buildAcpSessionBridgeHooks(opts) {
|
|
|
29502
30018
|
// src/agents/acp/ensure-acp-client.ts
|
|
29503
30019
|
async function ensureAcpClient(options) {
|
|
29504
30020
|
const { state, preferredAgentType, mode, cwd, routing, sendSessionUpdate, sendRequest, log: log2 } = options;
|
|
29505
|
-
const targetCwd =
|
|
30021
|
+
const targetCwd = path10.resolve(
|
|
29506
30022
|
cwd != null && String(cwd).trim() !== "" ? String(cwd).trim() : getBridgeWorkspaceDirectory()
|
|
29507
30023
|
);
|
|
29508
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
30024
|
+
if (state.acpHandle && state.lastAcpCwd != null && path10.resolve(state.lastAcpCwd) !== path10.resolve(targetCwd)) {
|
|
29509
30025
|
try {
|
|
29510
30026
|
state.acpHandle.disconnect();
|
|
29511
30027
|
} catch {
|
|
@@ -29537,7 +30053,7 @@ async function ensureAcpClient(options) {
|
|
|
29537
30053
|
if (!state.acpStartPromise) {
|
|
29538
30054
|
let statOk = false;
|
|
29539
30055
|
try {
|
|
29540
|
-
const st =
|
|
30056
|
+
const st = fs9.statSync(targetCwd);
|
|
29541
30057
|
statOk = st.isDirectory();
|
|
29542
30058
|
if (!statOk) {
|
|
29543
30059
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetCwd}`;
|
|
@@ -29733,12 +30249,12 @@ async function createAcpManager(options) {
|
|
|
29733
30249
|
}
|
|
29734
30250
|
|
|
29735
30251
|
// src/worktrees/session-worktree-manager.ts
|
|
29736
|
-
import * as
|
|
29737
|
-
import
|
|
30252
|
+
import * as path16 from "node:path";
|
|
30253
|
+
import os4 from "node:os";
|
|
29738
30254
|
|
|
29739
30255
|
// src/worktrees/prepare-new-session-worktrees.ts
|
|
29740
|
-
import * as
|
|
29741
|
-
import * as
|
|
30256
|
+
import * as fs11 from "node:fs";
|
|
30257
|
+
import * as path12 from "node:path";
|
|
29742
30258
|
|
|
29743
30259
|
// src/git/worktree-add.ts
|
|
29744
30260
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
|
|
@@ -29747,12 +30263,12 @@ async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch) {
|
|
|
29747
30263
|
}
|
|
29748
30264
|
|
|
29749
30265
|
// src/worktrees/worktree-layout-file.ts
|
|
29750
|
-
import * as
|
|
29751
|
-
import * as
|
|
29752
|
-
import
|
|
30266
|
+
import * as fs10 from "node:fs";
|
|
30267
|
+
import * as path11 from "node:path";
|
|
30268
|
+
import os3 from "node:os";
|
|
29753
30269
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
29754
30270
|
function defaultWorktreeLayoutPath() {
|
|
29755
|
-
return
|
|
30271
|
+
return path11.join(os3.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
29756
30272
|
}
|
|
29757
30273
|
function normalizeLoadedLayout(raw) {
|
|
29758
30274
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -29764,8 +30280,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
29764
30280
|
function loadWorktreeLayout() {
|
|
29765
30281
|
try {
|
|
29766
30282
|
const p = defaultWorktreeLayoutPath();
|
|
29767
|
-
if (!
|
|
29768
|
-
const raw = JSON.parse(
|
|
30283
|
+
if (!fs10.existsSync(p)) return { launcherCwds: [] };
|
|
30284
|
+
const raw = JSON.parse(fs10.readFileSync(p, "utf8"));
|
|
29769
30285
|
return normalizeLoadedLayout(raw);
|
|
29770
30286
|
} catch {
|
|
29771
30287
|
return { launcherCwds: [] };
|
|
@@ -29773,18 +30289,18 @@ function loadWorktreeLayout() {
|
|
|
29773
30289
|
}
|
|
29774
30290
|
function saveWorktreeLayout(layout) {
|
|
29775
30291
|
try {
|
|
29776
|
-
const dir =
|
|
29777
|
-
|
|
29778
|
-
|
|
30292
|
+
const dir = path11.dirname(defaultWorktreeLayoutPath());
|
|
30293
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
30294
|
+
fs10.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
29779
30295
|
} catch {
|
|
29780
30296
|
}
|
|
29781
30297
|
}
|
|
29782
30298
|
function baseNameSafe(abs) {
|
|
29783
|
-
return
|
|
30299
|
+
return path11.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
29784
30300
|
}
|
|
29785
30301
|
function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
|
|
29786
|
-
const norm =
|
|
29787
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
30302
|
+
const norm = path11.resolve(launcherCwdAbs);
|
|
30303
|
+
const existing = layout.launcherCwds.find((e) => path11.resolve(e.absolutePath) === norm);
|
|
29788
30304
|
if (existing) return existing.dirName;
|
|
29789
30305
|
const base = baseNameSafe(norm);
|
|
29790
30306
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
@@ -29802,9 +30318,9 @@ function allocateDirNameForLauncherCwd(layout, launcherCwdAbs) {
|
|
|
29802
30318
|
// src/worktrees/prepare-new-session-worktrees.ts
|
|
29803
30319
|
async function prepareNewSessionWorktrees(options) {
|
|
29804
30320
|
const { rootAbs, launcherCwd, sessionId, layout, log: log2 } = options;
|
|
29805
|
-
const launcherResolved =
|
|
30321
|
+
const launcherResolved = path12.resolve(launcherCwd);
|
|
29806
30322
|
const cwdKey = allocateDirNameForLauncherCwd(layout, launcherResolved);
|
|
29807
|
-
const agentMirrorRoot =
|
|
30323
|
+
const agentMirrorRoot = path12.join(rootAbs, cwdKey);
|
|
29808
30324
|
const repos = await discoverGitReposUnderRoot(launcherResolved);
|
|
29809
30325
|
if (repos.length === 0) {
|
|
29810
30326
|
log2("[worktrees] No Git repositories under launcher working directory; skipping worktree creation.");
|
|
@@ -29812,13 +30328,13 @@ async function prepareNewSessionWorktrees(options) {
|
|
|
29812
30328
|
}
|
|
29813
30329
|
const branch = `session-${sessionId}`;
|
|
29814
30330
|
const worktreePaths = [];
|
|
29815
|
-
|
|
30331
|
+
fs11.mkdirSync(agentMirrorRoot, { recursive: true });
|
|
29816
30332
|
for (const repo of repos) {
|
|
29817
|
-
let rel =
|
|
29818
|
-
if (rel.startsWith("..") ||
|
|
30333
|
+
let rel = path12.relative(launcherResolved, repo.absolutePath);
|
|
30334
|
+
if (rel.startsWith("..") || path12.isAbsolute(rel)) continue;
|
|
29819
30335
|
const relNorm = rel === "" ? "." : rel;
|
|
29820
|
-
const wtPath =
|
|
29821
|
-
|
|
30336
|
+
const wtPath = path12.join(agentMirrorRoot, relNorm, sessionId);
|
|
30337
|
+
fs11.mkdirSync(path12.dirname(wtPath), { recursive: true });
|
|
29822
30338
|
try {
|
|
29823
30339
|
await gitWorktreeAddBranch(repo.absolutePath, wtPath, branch);
|
|
29824
30340
|
log2(`[worktrees] Added worktree ${wtPath} (branch ${branch}).`);
|
|
@@ -29855,23 +30371,23 @@ async function renameSessionWorktreeBranches(paths, newBranch, log2) {
|
|
|
29855
30371
|
}
|
|
29856
30372
|
|
|
29857
30373
|
// src/worktrees/remove-session-worktrees.ts
|
|
29858
|
-
import * as
|
|
30374
|
+
import * as fs14 from "node:fs";
|
|
29859
30375
|
|
|
29860
30376
|
// src/git/worktree-remove.ts
|
|
29861
|
-
import * as
|
|
30377
|
+
import * as fs13 from "node:fs";
|
|
29862
30378
|
|
|
29863
30379
|
// src/git/resolve-main-repo-from-git-file.ts
|
|
29864
|
-
import * as
|
|
29865
|
-
import * as
|
|
30380
|
+
import * as fs12 from "node:fs";
|
|
30381
|
+
import * as path13 from "node:path";
|
|
29866
30382
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
29867
|
-
const gitDirFile =
|
|
29868
|
-
if (!
|
|
29869
|
-
const first2 =
|
|
30383
|
+
const gitDirFile = path13.join(wt, ".git");
|
|
30384
|
+
if (!fs12.existsSync(gitDirFile) || !fs12.statSync(gitDirFile).isFile()) return "";
|
|
30385
|
+
const first2 = fs12.readFileSync(gitDirFile, "utf8").trim();
|
|
29870
30386
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
29871
30387
|
if (!m) return "";
|
|
29872
|
-
const gitWorktreePath =
|
|
29873
|
-
const gitDir =
|
|
29874
|
-
return
|
|
30388
|
+
const gitWorktreePath = path13.resolve(wt, m[1].trim());
|
|
30389
|
+
const gitDir = path13.dirname(path13.dirname(gitWorktreePath));
|
|
30390
|
+
return path13.dirname(gitDir);
|
|
29875
30391
|
}
|
|
29876
30392
|
|
|
29877
30393
|
// src/git/worktree-remove.ts
|
|
@@ -29880,7 +30396,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
29880
30396
|
if (mainRepo) {
|
|
29881
30397
|
await simpleGit(mainRepo).raw(["worktree", "remove", "--force", worktreePath]);
|
|
29882
30398
|
} else {
|
|
29883
|
-
|
|
30399
|
+
fs13.rmSync(worktreePath, { recursive: true, force: true });
|
|
29884
30400
|
}
|
|
29885
30401
|
}
|
|
29886
30402
|
|
|
@@ -29893,7 +30409,7 @@ async function removeSessionWorktrees(paths, log2) {
|
|
|
29893
30409
|
} catch (e) {
|
|
29894
30410
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
29895
30411
|
try {
|
|
29896
|
-
|
|
30412
|
+
fs14.rmSync(wt, { recursive: true, force: true });
|
|
29897
30413
|
} catch {
|
|
29898
30414
|
}
|
|
29899
30415
|
}
|
|
@@ -30113,7 +30629,7 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
30113
30629
|
}
|
|
30114
30630
|
|
|
30115
30631
|
// src/git/working-directory/changes/get-working-tree-change-repo-details.ts
|
|
30116
|
-
import * as
|
|
30632
|
+
import * as path15 from "node:path";
|
|
30117
30633
|
|
|
30118
30634
|
// src/git/working-directory/changes/parse-git-status.ts
|
|
30119
30635
|
function parseNameStatusLines(lines) {
|
|
@@ -30233,8 +30749,8 @@ async function listChangedFilesForCommit(repoGitCwd, repoRelPath, commitSha) {
|
|
|
30233
30749
|
}
|
|
30234
30750
|
|
|
30235
30751
|
// src/git/working-directory/changes/list-changed-files-for-repo.ts
|
|
30236
|
-
import * as
|
|
30237
|
-
import * as
|
|
30752
|
+
import * as fs16 from "node:fs";
|
|
30753
|
+
import * as path14 from "node:path";
|
|
30238
30754
|
|
|
30239
30755
|
// src/git/working-directory/changes/count-lines.ts
|
|
30240
30756
|
import { createReadStream } from "node:fs";
|
|
@@ -30258,7 +30774,7 @@ async function countTextFileLines(absFile) {
|
|
|
30258
30774
|
}
|
|
30259
30775
|
|
|
30260
30776
|
// src/git/working-directory/changes/hydrate-patch.ts
|
|
30261
|
-
import * as
|
|
30777
|
+
import * as fs15 from "node:fs";
|
|
30262
30778
|
var UNIFIED_HUNK_HEADER_RE = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
30263
30779
|
var MAX_HYDRATE_LINES_PER_GAP = 8e3;
|
|
30264
30780
|
var MAX_HYDRATE_LINES_PER_FILE = 8e4;
|
|
@@ -30273,7 +30789,7 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
30273
30789
|
}
|
|
30274
30790
|
async function readWorktreeFileLines(abs) {
|
|
30275
30791
|
try {
|
|
30276
|
-
const raw = await
|
|
30792
|
+
const raw = await fs15.promises.readFile(abs, "utf8");
|
|
30277
30793
|
return raw.split(/\r?\n/);
|
|
30278
30794
|
} catch {
|
|
30279
30795
|
return null;
|
|
@@ -30408,7 +30924,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoRelPath) {
|
|
|
30408
30924
|
const rows = [];
|
|
30409
30925
|
for (const pathInRepo of paths) {
|
|
30410
30926
|
const relLauncher = posixJoinDirFile(repoRelPath, pathInRepo.replace(/\\/g, "/"));
|
|
30411
|
-
const abs =
|
|
30927
|
+
const abs = path14.join(repoGitCwd, pathInRepo);
|
|
30412
30928
|
const nums = numByPath.get(pathInRepo);
|
|
30413
30929
|
let additions = nums?.additions ?? 0;
|
|
30414
30930
|
let deletions = nums?.deletions ?? 0;
|
|
@@ -30421,7 +30937,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoRelPath) {
|
|
|
30421
30937
|
deletions = fromGit.deletions;
|
|
30422
30938
|
} else {
|
|
30423
30939
|
try {
|
|
30424
|
-
const st = await
|
|
30940
|
+
const st = await fs16.promises.stat(abs);
|
|
30425
30941
|
if (st.isFile()) additions = await countTextFileLines(abs);
|
|
30426
30942
|
else additions = 0;
|
|
30427
30943
|
} catch {
|
|
@@ -30447,7 +30963,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoRelPath) {
|
|
|
30447
30963
|
} else {
|
|
30448
30964
|
pathInRepo = row.pathRelLauncher;
|
|
30449
30965
|
}
|
|
30450
|
-
const absFile =
|
|
30966
|
+
const absFile = path14.join(repoGitCwd, pathInRepo);
|
|
30451
30967
|
let patch = await unifiedDiffForFile(repoGitCwd, pathInRepo, row.change);
|
|
30452
30968
|
if (patch) {
|
|
30453
30969
|
patch = await hydrateUnifiedPatchWithFileContext(patch, absFile, repoGitCwd, pathInRepo, row.change);
|
|
@@ -30463,8 +30979,8 @@ function normRepoRel(p) {
|
|
|
30463
30979
|
return x === "" ? "." : x;
|
|
30464
30980
|
}
|
|
30465
30981
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
30466
|
-
const launcher =
|
|
30467
|
-
const mirror = options.agentMirrorRootAbs ?
|
|
30982
|
+
const launcher = path15.resolve(getBridgeWorkspaceDirectory());
|
|
30983
|
+
const mirror = options.agentMirrorRootAbs ? path15.resolve(options.agentMirrorRootAbs) : null;
|
|
30468
30984
|
const out = [];
|
|
30469
30985
|
const filter = options.repoFilterRelPath != null ? normRepoRel(options.repoFilterRelPath) : null;
|
|
30470
30986
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -30476,7 +30992,7 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
30476
30992
|
}
|
|
30477
30993
|
const basis = filter == null && basisInput.kind === "commit" ? { kind: "working" } : basisInput;
|
|
30478
30994
|
for (const target of options.commitTargetAbsDirs) {
|
|
30479
|
-
const t =
|
|
30995
|
+
const t = path15.resolve(target);
|
|
30480
30996
|
if (!await isGitRepoDirectory(t)) continue;
|
|
30481
30997
|
const g = simpleGit(t);
|
|
30482
30998
|
let branch = "HEAD";
|
|
@@ -30489,7 +31005,7 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
30489
31005
|
const remoteDisplay = formatRemoteDisplayLabel(remoteUrl);
|
|
30490
31006
|
let repoRelPath;
|
|
30491
31007
|
if (mirror) {
|
|
30492
|
-
const relNorm =
|
|
31008
|
+
const relNorm = path15.relative(mirror, path15.dirname(t));
|
|
30493
31009
|
repoRelPath = relNorm === "" ? "." : relNorm.replace(/\\/g, "/");
|
|
30494
31010
|
} else {
|
|
30495
31011
|
let top = t;
|
|
@@ -30498,8 +31014,8 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
30498
31014
|
} catch {
|
|
30499
31015
|
top = t;
|
|
30500
31016
|
}
|
|
30501
|
-
const rel =
|
|
30502
|
-
repoRelPath = rel.startsWith("..") ?
|
|
31017
|
+
const rel = path15.relative(launcher, path15.resolve(top)).replace(/\\/g, "/") || ".";
|
|
31018
|
+
repoRelPath = rel.startsWith("..") ? path15.basename(path15.resolve(top)) : rel;
|
|
30503
31019
|
}
|
|
30504
31020
|
const norm = normRepoRel(repoRelPath === "" ? "." : repoRelPath);
|
|
30505
31021
|
if (filter && norm !== filter) continue;
|
|
@@ -30591,7 +31107,7 @@ var SessionWorktreeManager = class {
|
|
|
30591
31107
|
}
|
|
30592
31108
|
if (!opts.isNewSession) {
|
|
30593
31109
|
const agentCwd = this.sessionAgentCwd.get(sessionId);
|
|
30594
|
-
if (agentCwd) return
|
|
31110
|
+
if (agentCwd) return path16.resolve(agentCwd);
|
|
30595
31111
|
return void 0;
|
|
30596
31112
|
}
|
|
30597
31113
|
const prep = await prepareNewSessionWorktrees({
|
|
@@ -30604,7 +31120,7 @@ var SessionWorktreeManager = class {
|
|
|
30604
31120
|
if (!prep) return void 0;
|
|
30605
31121
|
this.sessionPaths.set(sessionId, prep.worktreePaths);
|
|
30606
31122
|
this.sessionAgentCwd.set(sessionId, prep.agentCwd);
|
|
30607
|
-
return
|
|
31123
|
+
return path16.resolve(prep.agentCwd);
|
|
30608
31124
|
}
|
|
30609
31125
|
async renameSessionBranch(sessionId, newBranch) {
|
|
30610
31126
|
const paths = this.sessionPaths.get(sessionId);
|
|
@@ -30625,7 +31141,7 @@ var SessionWorktreeManager = class {
|
|
|
30625
31141
|
getAgentCwdForSession(sessionId) {
|
|
30626
31142
|
if (!sessionId) return null;
|
|
30627
31143
|
const c = this.sessionAgentCwd.get(sessionId);
|
|
30628
|
-
return c ?
|
|
31144
|
+
return c ? path16.resolve(c) : null;
|
|
30629
31145
|
}
|
|
30630
31146
|
async removeSessionWorktrees(sessionId) {
|
|
30631
31147
|
const paths = this.sessionPaths.get(sessionId);
|
|
@@ -30673,15 +31189,15 @@ var SessionWorktreeManager = class {
|
|
|
30673
31189
|
}
|
|
30674
31190
|
};
|
|
30675
31191
|
function defaultWorktreesRootAbs() {
|
|
30676
|
-
return
|
|
31192
|
+
return path16.join(os4.homedir(), ".buildautomaton", "worktrees");
|
|
30677
31193
|
}
|
|
30678
31194
|
|
|
30679
31195
|
// src/files/watch-file-index.ts
|
|
30680
31196
|
import { watch } from "node:fs";
|
|
30681
|
-
import
|
|
31197
|
+
import path23 from "node:path";
|
|
30682
31198
|
|
|
30683
31199
|
// src/files/index/build-file-index.ts
|
|
30684
|
-
import
|
|
31200
|
+
import path20 from "node:path";
|
|
30685
31201
|
|
|
30686
31202
|
// src/runtime/yield-to-event-loop.ts
|
|
30687
31203
|
function yieldToEventLoop() {
|
|
@@ -30689,14 +31205,14 @@ function yieldToEventLoop() {
|
|
|
30689
31205
|
}
|
|
30690
31206
|
|
|
30691
31207
|
// src/files/index/walk-workspace-tree.ts
|
|
30692
|
-
import
|
|
30693
|
-
import
|
|
31208
|
+
import fs17 from "node:fs";
|
|
31209
|
+
import path18 from "node:path";
|
|
30694
31210
|
|
|
30695
31211
|
// src/files/index/constants.ts
|
|
30696
|
-
import
|
|
30697
|
-
import
|
|
31212
|
+
import path17 from "node:path";
|
|
31213
|
+
import os5 from "node:os";
|
|
30698
31214
|
var INDEX_WORK_YIELD_EVERY = 256;
|
|
30699
|
-
var INDEX_DIR =
|
|
31215
|
+
var INDEX_DIR = path17.join(os5.homedir(), ".buildautomaton");
|
|
30700
31216
|
var INDEX_HASH_LEN = 16;
|
|
30701
31217
|
var INDEX_VERSION = 2;
|
|
30702
31218
|
var INDEX_LOG_PREFIX = "[file-index]";
|
|
@@ -30705,20 +31221,20 @@ var INDEX_LOG_PREFIX = "[file-index]";
|
|
|
30705
31221
|
function walkWorkspaceTreeSync(dir, baseDir, out) {
|
|
30706
31222
|
let names;
|
|
30707
31223
|
try {
|
|
30708
|
-
names =
|
|
31224
|
+
names = fs17.readdirSync(dir);
|
|
30709
31225
|
} catch {
|
|
30710
31226
|
return;
|
|
30711
31227
|
}
|
|
30712
31228
|
for (const name of names) {
|
|
30713
31229
|
if (name.startsWith(".")) continue;
|
|
30714
|
-
const full =
|
|
31230
|
+
const full = path18.join(dir, name);
|
|
30715
31231
|
let stat2;
|
|
30716
31232
|
try {
|
|
30717
|
-
stat2 =
|
|
31233
|
+
stat2 = fs17.statSync(full);
|
|
30718
31234
|
} catch {
|
|
30719
31235
|
continue;
|
|
30720
31236
|
}
|
|
30721
|
-
const relative5 =
|
|
31237
|
+
const relative5 = path18.relative(baseDir, full).replace(/\\/g, "/");
|
|
30722
31238
|
if (stat2.isDirectory()) {
|
|
30723
31239
|
walkWorkspaceTreeSync(full, baseDir, out);
|
|
30724
31240
|
} else if (stat2.isFile()) {
|
|
@@ -30729,7 +31245,7 @@ function walkWorkspaceTreeSync(dir, baseDir, out) {
|
|
|
30729
31245
|
async function walkWorkspaceTreeAsync(dir, baseDir, out, state) {
|
|
30730
31246
|
let names;
|
|
30731
31247
|
try {
|
|
30732
|
-
names = await
|
|
31248
|
+
names = await fs17.promises.readdir(dir);
|
|
30733
31249
|
} catch {
|
|
30734
31250
|
return;
|
|
30735
31251
|
}
|
|
@@ -30739,14 +31255,14 @@ async function walkWorkspaceTreeAsync(dir, baseDir, out, state) {
|
|
|
30739
31255
|
await yieldToEventLoop();
|
|
30740
31256
|
}
|
|
30741
31257
|
state.n++;
|
|
30742
|
-
const full =
|
|
31258
|
+
const full = path18.join(dir, name);
|
|
30743
31259
|
let stat2;
|
|
30744
31260
|
try {
|
|
30745
|
-
stat2 = await
|
|
31261
|
+
stat2 = await fs17.promises.stat(full);
|
|
30746
31262
|
} catch {
|
|
30747
31263
|
continue;
|
|
30748
31264
|
}
|
|
30749
|
-
const relative5 =
|
|
31265
|
+
const relative5 = path18.relative(baseDir, full).replace(/\\/g, "/");
|
|
30750
31266
|
if (stat2.isDirectory()) {
|
|
30751
31267
|
await walkWorkspaceTreeAsync(full, baseDir, out, state);
|
|
30752
31268
|
} else if (stat2.isFile()) {
|
|
@@ -30827,22 +31343,22 @@ async function buildTrigramMapForPathsAsync(paths) {
|
|
|
30827
31343
|
}
|
|
30828
31344
|
|
|
30829
31345
|
// src/files/index/write-index-file.ts
|
|
30830
|
-
import
|
|
31346
|
+
import fs18 from "node:fs";
|
|
30831
31347
|
|
|
30832
31348
|
// src/files/index/paths.ts
|
|
30833
|
-
import
|
|
31349
|
+
import path19 from "node:path";
|
|
30834
31350
|
import crypto2 from "node:crypto";
|
|
30835
31351
|
function getIndexPathForCwd(resolvedCwd) {
|
|
30836
31352
|
const hash = crypto2.createHash("sha256").update(resolvedCwd).digest("hex").slice(0, INDEX_HASH_LEN);
|
|
30837
|
-
return
|
|
31353
|
+
return path19.join(INDEX_DIR, `.file-index-${hash}.json`);
|
|
30838
31354
|
}
|
|
30839
31355
|
|
|
30840
31356
|
// src/files/index/write-index-file.ts
|
|
30841
31357
|
function writeIndexFileSync(resolvedCwd, data) {
|
|
30842
31358
|
const indexPath = getIndexPathForCwd(resolvedCwd);
|
|
30843
31359
|
try {
|
|
30844
|
-
if (!
|
|
30845
|
-
|
|
31360
|
+
if (!fs18.existsSync(INDEX_DIR)) fs18.mkdirSync(INDEX_DIR, { recursive: true });
|
|
31361
|
+
fs18.writeFileSync(indexPath, JSON.stringify(data), "utf8");
|
|
30846
31362
|
} catch (e) {
|
|
30847
31363
|
console.error(`${INDEX_LOG_PREFIX} Failed to write index:`, e);
|
|
30848
31364
|
}
|
|
@@ -30850,8 +31366,8 @@ function writeIndexFileSync(resolvedCwd, data) {
|
|
|
30850
31366
|
async function writeIndexFileAsync(resolvedCwd, data) {
|
|
30851
31367
|
const indexPath = getIndexPathForCwd(resolvedCwd);
|
|
30852
31368
|
try {
|
|
30853
|
-
await
|
|
30854
|
-
await
|
|
31369
|
+
await fs18.promises.mkdir(INDEX_DIR, { recursive: true });
|
|
31370
|
+
await fs18.promises.writeFile(indexPath, JSON.stringify(data), "utf8");
|
|
30855
31371
|
} catch (e) {
|
|
30856
31372
|
console.error(`${INDEX_LOG_PREFIX} Failed to write index:`, e);
|
|
30857
31373
|
}
|
|
@@ -30865,7 +31381,7 @@ function sortPaths(paths) {
|
|
|
30865
31381
|
paths.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" }));
|
|
30866
31382
|
}
|
|
30867
31383
|
function buildFileIndex(cwd) {
|
|
30868
|
-
const resolved =
|
|
31384
|
+
const resolved = path20.resolve(cwd);
|
|
30869
31385
|
const paths = [];
|
|
30870
31386
|
walkWorkspaceTreeSync(resolved, resolved, paths);
|
|
30871
31387
|
sortPaths(paths);
|
|
@@ -30875,7 +31391,7 @@ function buildFileIndex(cwd) {
|
|
|
30875
31391
|
return data;
|
|
30876
31392
|
}
|
|
30877
31393
|
async function buildFileIndexAsync(cwd) {
|
|
30878
|
-
const resolved =
|
|
31394
|
+
const resolved = path20.resolve(cwd);
|
|
30879
31395
|
const paths = [];
|
|
30880
31396
|
await walkWorkspaceTreeAsync(resolved, resolved, paths, createWalkYieldState());
|
|
30881
31397
|
await yieldToEventLoop();
|
|
@@ -30887,13 +31403,13 @@ async function buildFileIndexAsync(cwd) {
|
|
|
30887
31403
|
}
|
|
30888
31404
|
|
|
30889
31405
|
// src/files/index/load-file-index.ts
|
|
30890
|
-
import
|
|
30891
|
-
import
|
|
31406
|
+
import fs19 from "node:fs";
|
|
31407
|
+
import path21 from "node:path";
|
|
30892
31408
|
function loadFileIndex(cwd) {
|
|
30893
|
-
const resolved =
|
|
31409
|
+
const resolved = path21.resolve(cwd);
|
|
30894
31410
|
const indexPath = getIndexPathForCwd(resolved);
|
|
30895
31411
|
try {
|
|
30896
|
-
const raw =
|
|
31412
|
+
const raw = fs19.readFileSync(indexPath, "utf8");
|
|
30897
31413
|
const parsed = JSON.parse(raw);
|
|
30898
31414
|
if (parsed !== null && typeof parsed === "object" && Array.isArray(parsed.paths)) {
|
|
30899
31415
|
const obj = parsed;
|
|
@@ -30912,9 +31428,9 @@ function loadFileIndex(cwd) {
|
|
|
30912
31428
|
}
|
|
30913
31429
|
|
|
30914
31430
|
// src/files/index/ensure-file-index.ts
|
|
30915
|
-
import
|
|
31431
|
+
import path22 from "node:path";
|
|
30916
31432
|
async function ensureFileIndexAsync(cwd) {
|
|
30917
|
-
const resolved =
|
|
31433
|
+
const resolved = path22.resolve(cwd);
|
|
30918
31434
|
const cached2 = loadFileIndex(resolved);
|
|
30919
31435
|
if (cached2 !== null) return { data: cached2, fromCache: true };
|
|
30920
31436
|
const data = await buildFileIndexAsync(resolved);
|
|
@@ -30997,7 +31513,7 @@ function createFsWatcher(resolved, schedule) {
|
|
|
30997
31513
|
}
|
|
30998
31514
|
}
|
|
30999
31515
|
function startFileIndexWatcher(cwd = getBridgeWorkspaceDirectory()) {
|
|
31000
|
-
const resolved =
|
|
31516
|
+
const resolved = path23.resolve(cwd);
|
|
31001
31517
|
void buildFileIndexAsync(resolved).catch((e) => {
|
|
31002
31518
|
console.error("[file-index] Initial index build failed:", e);
|
|
31003
31519
|
});
|
|
@@ -31066,7 +31582,7 @@ function forceKillChild(proc, log2, shortId, graceMs) {
|
|
|
31066
31582
|
}
|
|
31067
31583
|
|
|
31068
31584
|
// src/dev-servers/process/wire-dev-server-child-process.ts
|
|
31069
|
-
import
|
|
31585
|
+
import fs20 from "node:fs";
|
|
31070
31586
|
|
|
31071
31587
|
// src/dev-servers/manager/forward-pipe.ts
|
|
31072
31588
|
function forwardChildPipe(childReadable, terminal, onData) {
|
|
@@ -31102,7 +31618,7 @@ function wireDevServerChildProcess(d) {
|
|
|
31102
31618
|
d.setPollInterval(void 0);
|
|
31103
31619
|
return;
|
|
31104
31620
|
}
|
|
31105
|
-
|
|
31621
|
+
fs20.readFile(d.mergedLogPath, (err, buf) => {
|
|
31106
31622
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
31107
31623
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
31108
31624
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -31140,7 +31656,7 @@ ${errTail}` : ""}`);
|
|
|
31140
31656
|
d.sendStatus(code === 0 || code == null ? "stopped" : "error", detail, tails);
|
|
31141
31657
|
};
|
|
31142
31658
|
if (mergedPath) {
|
|
31143
|
-
|
|
31659
|
+
fs20.readFile(mergedPath, (err, buf) => {
|
|
31144
31660
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
31145
31661
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
31146
31662
|
if (chunk.length > 0) {
|
|
@@ -31242,13 +31758,13 @@ function parseDevServerDefs(servers) {
|
|
|
31242
31758
|
}
|
|
31243
31759
|
|
|
31244
31760
|
// src/dev-servers/manager/shell-spawn/utils.ts
|
|
31245
|
-
import
|
|
31761
|
+
import fs21 from "node:fs";
|
|
31246
31762
|
function isSpawnEbadf(e) {
|
|
31247
31763
|
return typeof e === "object" && e !== null && "code" in e && e.code === "EBADF";
|
|
31248
31764
|
}
|
|
31249
31765
|
function rmDirQuiet(dir) {
|
|
31250
31766
|
try {
|
|
31251
|
-
|
|
31767
|
+
fs21.rmSync(dir, { recursive: true, force: true });
|
|
31252
31768
|
} catch {
|
|
31253
31769
|
}
|
|
31254
31770
|
}
|
|
@@ -31256,7 +31772,7 @@ var cachedDevNullReadFd;
|
|
|
31256
31772
|
function devNullReadFd() {
|
|
31257
31773
|
if (cachedDevNullReadFd === void 0) {
|
|
31258
31774
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
31259
|
-
cachedDevNullReadFd =
|
|
31775
|
+
cachedDevNullReadFd = fs21.openSync(devPath, "r");
|
|
31260
31776
|
}
|
|
31261
31777
|
return cachedDevNullReadFd;
|
|
31262
31778
|
}
|
|
@@ -31330,15 +31846,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal) {
|
|
|
31330
31846
|
|
|
31331
31847
|
// src/dev-servers/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
31332
31848
|
import { spawn as spawn7 } from "node:child_process";
|
|
31333
|
-
import
|
|
31849
|
+
import fs22 from "node:fs";
|
|
31334
31850
|
import { tmpdir } from "node:os";
|
|
31335
|
-
import
|
|
31851
|
+
import path24 from "node:path";
|
|
31336
31852
|
function trySpawnMergedLogFile(command, env, cwd, signal) {
|
|
31337
|
-
const tmpRoot =
|
|
31338
|
-
const logPath =
|
|
31853
|
+
const tmpRoot = fs22.mkdtempSync(path24.join(tmpdir(), "ba-devsrv-log-"));
|
|
31854
|
+
const logPath = path24.join(tmpRoot, "combined.log");
|
|
31339
31855
|
let logFd;
|
|
31340
31856
|
try {
|
|
31341
|
-
logFd =
|
|
31857
|
+
logFd = fs22.openSync(logPath, "a");
|
|
31342
31858
|
} catch {
|
|
31343
31859
|
rmDirQuiet(tmpRoot);
|
|
31344
31860
|
return null;
|
|
@@ -31357,7 +31873,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal) {
|
|
|
31357
31873
|
} else {
|
|
31358
31874
|
proc = spawn7("/bin/sh", ["-c", command], { env, cwd, stdio, ...signal ? { signal } : {} });
|
|
31359
31875
|
}
|
|
31360
|
-
|
|
31876
|
+
fs22.closeSync(logFd);
|
|
31361
31877
|
return {
|
|
31362
31878
|
proc,
|
|
31363
31879
|
pipedStdoutStderr: true,
|
|
@@ -31366,7 +31882,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal) {
|
|
|
31366
31882
|
};
|
|
31367
31883
|
} catch (e) {
|
|
31368
31884
|
try {
|
|
31369
|
-
|
|
31885
|
+
fs22.closeSync(logFd);
|
|
31370
31886
|
} catch {
|
|
31371
31887
|
}
|
|
31372
31888
|
rmDirQuiet(tmpRoot);
|
|
@@ -31377,22 +31893,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal) {
|
|
|
31377
31893
|
|
|
31378
31894
|
// src/dev-servers/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
31379
31895
|
import { spawn as spawn8 } from "node:child_process";
|
|
31380
|
-
import
|
|
31896
|
+
import fs23 from "node:fs";
|
|
31381
31897
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
31382
|
-
import
|
|
31898
|
+
import path25 from "node:path";
|
|
31383
31899
|
function shSingleQuote(s) {
|
|
31384
31900
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
31385
31901
|
}
|
|
31386
31902
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal) {
|
|
31387
|
-
const tmpRoot =
|
|
31388
|
-
const logPath =
|
|
31389
|
-
const innerPath =
|
|
31390
|
-
const runnerPath =
|
|
31903
|
+
const tmpRoot = fs23.mkdtempSync(path25.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
31904
|
+
const logPath = path25.join(tmpRoot, "combined.log");
|
|
31905
|
+
const innerPath = path25.join(tmpRoot, "_cmd.sh");
|
|
31906
|
+
const runnerPath = path25.join(tmpRoot, "_run.sh");
|
|
31391
31907
|
try {
|
|
31392
|
-
|
|
31908
|
+
fs23.writeFileSync(innerPath, `#!/bin/sh
|
|
31393
31909
|
${command}
|
|
31394
31910
|
`);
|
|
31395
|
-
|
|
31911
|
+
fs23.writeFileSync(
|
|
31396
31912
|
runnerPath,
|
|
31397
31913
|
`#!/bin/sh
|
|
31398
31914
|
cd ${shSingleQuote(cwd)}
|
|
@@ -31418,13 +31934,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
31418
31934
|
}
|
|
31419
31935
|
}
|
|
31420
31936
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal) {
|
|
31421
|
-
const tmpRoot =
|
|
31422
|
-
const logPath =
|
|
31423
|
-
const runnerPath =
|
|
31937
|
+
const tmpRoot = fs23.mkdtempSync(path25.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
31938
|
+
const logPath = path25.join(tmpRoot, "combined.log");
|
|
31939
|
+
const runnerPath = path25.join(tmpRoot, "_run.bat");
|
|
31424
31940
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
31425
31941
|
const com = process.env.ComSpec || "cmd.exe";
|
|
31426
31942
|
try {
|
|
31427
|
-
|
|
31943
|
+
fs23.writeFileSync(
|
|
31428
31944
|
runnerPath,
|
|
31429
31945
|
`@ECHO OFF\r
|
|
31430
31946
|
CD /D ${q(cwd)}\r
|
|
@@ -32106,30 +32622,30 @@ function createOnBridgeIdentified(opts) {
|
|
|
32106
32622
|
}
|
|
32107
32623
|
|
|
32108
32624
|
// src/skills/discover-local-agent-skills.ts
|
|
32109
|
-
import
|
|
32110
|
-
import
|
|
32625
|
+
import fs24 from "node:fs";
|
|
32626
|
+
import path26 from "node:path";
|
|
32111
32627
|
var SKILL_DISCOVERY_ROOTS = [".agents/skills", ".claude/skills", ".cursor/skills", "skills"];
|
|
32112
32628
|
function discoverLocalSkills(cwd) {
|
|
32113
32629
|
const out = [];
|
|
32114
32630
|
const seenKeys = /* @__PURE__ */ new Set();
|
|
32115
32631
|
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
32116
|
-
const base =
|
|
32117
|
-
if (!
|
|
32632
|
+
const base = path26.join(cwd, rel);
|
|
32633
|
+
if (!fs24.existsSync(base) || !fs24.statSync(base).isDirectory()) continue;
|
|
32118
32634
|
let entries = [];
|
|
32119
32635
|
try {
|
|
32120
|
-
entries =
|
|
32636
|
+
entries = fs24.readdirSync(base);
|
|
32121
32637
|
} catch {
|
|
32122
32638
|
continue;
|
|
32123
32639
|
}
|
|
32124
32640
|
for (const name of entries) {
|
|
32125
|
-
const dir =
|
|
32641
|
+
const dir = path26.join(base, name);
|
|
32126
32642
|
try {
|
|
32127
|
-
if (!
|
|
32643
|
+
if (!fs24.statSync(dir).isDirectory()) continue;
|
|
32128
32644
|
} catch {
|
|
32129
32645
|
continue;
|
|
32130
32646
|
}
|
|
32131
|
-
const skillMd =
|
|
32132
|
-
if (!
|
|
32647
|
+
const skillMd = path26.join(dir, "SKILL.md");
|
|
32648
|
+
if (!fs24.existsSync(skillMd)) continue;
|
|
32133
32649
|
const key = `${rel}/${name}`;
|
|
32134
32650
|
if (seenKeys.has(key)) continue;
|
|
32135
32651
|
seenKeys.add(key);
|
|
@@ -32141,23 +32657,23 @@ function discoverLocalSkills(cwd) {
|
|
|
32141
32657
|
function discoverSkillLayoutRoots(cwd) {
|
|
32142
32658
|
const roots = [];
|
|
32143
32659
|
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
32144
|
-
const base =
|
|
32145
|
-
if (!
|
|
32660
|
+
const base = path26.join(cwd, rel);
|
|
32661
|
+
if (!fs24.existsSync(base) || !fs24.statSync(base).isDirectory()) continue;
|
|
32146
32662
|
let entries = [];
|
|
32147
32663
|
try {
|
|
32148
|
-
entries =
|
|
32664
|
+
entries = fs24.readdirSync(base);
|
|
32149
32665
|
} catch {
|
|
32150
32666
|
continue;
|
|
32151
32667
|
}
|
|
32152
32668
|
const skills2 = [];
|
|
32153
32669
|
for (const name of entries) {
|
|
32154
|
-
const dir =
|
|
32670
|
+
const dir = path26.join(base, name);
|
|
32155
32671
|
try {
|
|
32156
|
-
if (!
|
|
32672
|
+
if (!fs24.statSync(dir).isDirectory()) continue;
|
|
32157
32673
|
} catch {
|
|
32158
32674
|
continue;
|
|
32159
32675
|
}
|
|
32160
|
-
if (!
|
|
32676
|
+
if (!fs24.existsSync(path26.join(dir, "SKILL.md"))) continue;
|
|
32161
32677
|
const relPath = `${rel}/${name}`.replace(/\\/g, "/");
|
|
32162
32678
|
skills2.push({ name, relPath });
|
|
32163
32679
|
}
|
|
@@ -32302,12 +32818,12 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
32302
32818
|
};
|
|
32303
32819
|
|
|
32304
32820
|
// src/agents/acp/from-bridge/handle-bridge-prompt.ts
|
|
32305
|
-
import * as
|
|
32306
|
-
import { execFile as
|
|
32307
|
-
import { promisify as
|
|
32821
|
+
import * as path28 from "node:path";
|
|
32822
|
+
import { execFile as execFile10 } from "node:child_process";
|
|
32823
|
+
import { promisify as promisify10 } from "node:util";
|
|
32308
32824
|
|
|
32309
32825
|
// src/git/bridge-queue-key.ts
|
|
32310
|
-
import * as
|
|
32826
|
+
import * as path27 from "node:path";
|
|
32311
32827
|
import { createHash } from "node:crypto";
|
|
32312
32828
|
function normalizeCanonicalGitUrl(url2) {
|
|
32313
32829
|
let s = url2.trim();
|
|
@@ -32335,11 +32851,11 @@ function canonicalUrlToRepoIdSync(url2) {
|
|
|
32335
32851
|
return createHash("sha256").update(normalized).digest("hex").slice(0, 32);
|
|
32336
32852
|
}
|
|
32337
32853
|
function fallbackRepoIdFromPath(absPath) {
|
|
32338
|
-
return createHash("sha256").update(
|
|
32854
|
+
return createHash("sha256").update(path27.resolve(absPath)).digest("hex").slice(0, 32);
|
|
32339
32855
|
}
|
|
32340
32856
|
async function resolveBridgeQueueBindFields(options) {
|
|
32341
32857
|
const { effectiveCwd, worktreePaths, primaryRepoRoots, log: log2 } = options;
|
|
32342
|
-
const cwdAbs = worktreePaths.length > 0 ?
|
|
32858
|
+
const cwdAbs = worktreePaths.length > 0 ? path27.resolve(worktreePaths[0]) : path27.resolve(effectiveCwd);
|
|
32343
32859
|
if (!primaryRepoRoots.length) {
|
|
32344
32860
|
log2("[Bridge service] Prompt queue bind skipped: no Git repository roots under the working directory.");
|
|
32345
32861
|
return null;
|
|
@@ -32362,10 +32878,10 @@ async function resolveBridgeQueueBindFields(options) {
|
|
|
32362
32878
|
}
|
|
32363
32879
|
|
|
32364
32880
|
// src/agents/acp/from-bridge/handle-bridge-prompt.ts
|
|
32365
|
-
var
|
|
32881
|
+
var execFileAsync9 = promisify10(execFile10);
|
|
32366
32882
|
async function readGitBranch(cwd) {
|
|
32367
32883
|
try {
|
|
32368
|
-
const { stdout } = await
|
|
32884
|
+
const { stdout } = await execFileAsync9("git", ["branch", "--show-current"], { cwd, maxBuffer: 64 * 1024 });
|
|
32369
32885
|
const b = stdout.trim();
|
|
32370
32886
|
return b || null;
|
|
32371
32887
|
} catch {
|
|
@@ -32376,17 +32892,29 @@ function handleBridgePrompt(msg, deps) {
|
|
|
32376
32892
|
const { getWs, log: log2, acpManager, sessionWorktreeManager } = deps;
|
|
32377
32893
|
const rawPrompt = msg.prompt;
|
|
32378
32894
|
const promptText = typeof rawPrompt === "string" ? rawPrompt : rawPrompt != null ? String(rawPrompt) : "";
|
|
32895
|
+
const sessionId = msg.sessionId;
|
|
32896
|
+
const runId = typeof msg.runId === "string" ? msg.runId : void 0;
|
|
32897
|
+
const promptId = typeof msg.id === "string" ? msg.id : void 0;
|
|
32379
32898
|
if (!promptText.trim()) {
|
|
32380
32899
|
log2(
|
|
32381
32900
|
`[Bridge service] Prompt ignored: empty or missing prompt text (session ${typeof msg.sessionId === "string" ? msg.sessionId.slice(0, 8) : "\u2014"}\u2026, run ${typeof msg.runId === "string" ? msg.runId.slice(0, 8) : "\u2014"}\u2026).`
|
|
32382
32901
|
);
|
|
32902
|
+
const s = getWs();
|
|
32903
|
+
if (s) {
|
|
32904
|
+
sendWsMessage(s, {
|
|
32905
|
+
type: "prompt_result",
|
|
32906
|
+
...promptId ? { id: promptId } : {},
|
|
32907
|
+
...sessionId ? { sessionId } : {},
|
|
32908
|
+
...runId ? { runId } : {},
|
|
32909
|
+
success: false,
|
|
32910
|
+
error: "Empty or missing prompt text from the bridge; this turn was not sent to the agent."
|
|
32911
|
+
});
|
|
32912
|
+
}
|
|
32383
32913
|
return;
|
|
32384
32914
|
}
|
|
32385
|
-
const sessionId = msg.sessionId;
|
|
32386
32915
|
const isNewSession = msg.isNewSession === true;
|
|
32387
32916
|
const sessionWorktreesEnabled = msg.sessionWorktreesEnabled === true;
|
|
32388
32917
|
const agentType = typeof msg.agentType === "string" && msg.agentType.trim() ? msg.agentType.trim() : void 0;
|
|
32389
|
-
const runId = typeof msg.runId === "string" ? msg.runId : void 0;
|
|
32390
32918
|
const mode = typeof msg.mode === "string" && msg.mode.trim() ? msg.mode.trim() : void 0;
|
|
32391
32919
|
acpManager.logPromptReceivedFromBridge({ agentType, mode });
|
|
32392
32920
|
const sendResult2 = (result) => {
|
|
@@ -32404,7 +32932,7 @@ function handleBridgePrompt(msg, deps) {
|
|
|
32404
32932
|
};
|
|
32405
32933
|
async function preambleAndPrompt(resolvedCwd) {
|
|
32406
32934
|
const s = getWs();
|
|
32407
|
-
const effectiveCwd =
|
|
32935
|
+
const effectiveCwd = path28.resolve(resolvedCwd ?? getBridgeWorkspaceDirectory());
|
|
32408
32936
|
const worktreePaths = sessionWorktreeManager.getWorktreePathsForSession(sessionId) ?? [];
|
|
32409
32937
|
const repoRoots = await resolveSnapshotRepoRoots({
|
|
32410
32938
|
worktreePaths,
|
|
@@ -32529,15 +33057,15 @@ var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
|
|
|
32529
33057
|
};
|
|
32530
33058
|
|
|
32531
33059
|
// src/files/list-dir.ts
|
|
32532
|
-
import
|
|
32533
|
-
import
|
|
33060
|
+
import fs25 from "node:fs";
|
|
33061
|
+
import path30 from "node:path";
|
|
32534
33062
|
|
|
32535
33063
|
// src/files/ensure-under-cwd.ts
|
|
32536
|
-
import
|
|
33064
|
+
import path29 from "node:path";
|
|
32537
33065
|
function ensureUnderCwd(relativePath, cwd = getBridgeWorkspaceDirectory()) {
|
|
32538
|
-
const normalized =
|
|
32539
|
-
const resolved =
|
|
32540
|
-
if (!resolved.startsWith(cwd +
|
|
33066
|
+
const normalized = path29.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
33067
|
+
const resolved = path29.resolve(cwd, normalized);
|
|
33068
|
+
if (!resolved.startsWith(cwd + path29.sep) && resolved !== cwd) {
|
|
32541
33069
|
return null;
|
|
32542
33070
|
}
|
|
32543
33071
|
return resolved;
|
|
@@ -32551,7 +33079,7 @@ async function listDirAsync(relativePath) {
|
|
|
32551
33079
|
return { error: "Path is outside working directory" };
|
|
32552
33080
|
}
|
|
32553
33081
|
try {
|
|
32554
|
-
const names = await
|
|
33082
|
+
const names = await fs25.promises.readdir(resolved, { withFileTypes: true });
|
|
32555
33083
|
const visible = names.filter((d) => !d.name.startsWith("."));
|
|
32556
33084
|
const entries = [];
|
|
32557
33085
|
for (let i = 0; i < visible.length; i++) {
|
|
@@ -32559,12 +33087,12 @@ async function listDirAsync(relativePath) {
|
|
|
32559
33087
|
await yieldToEventLoop();
|
|
32560
33088
|
}
|
|
32561
33089
|
const d = visible[i];
|
|
32562
|
-
const entryPath =
|
|
32563
|
-
const fullPath =
|
|
33090
|
+
const entryPath = path30.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
33091
|
+
const fullPath = path30.join(resolved, d.name);
|
|
32564
33092
|
let isDir = d.isDirectory();
|
|
32565
33093
|
if (d.isSymbolicLink()) {
|
|
32566
33094
|
try {
|
|
32567
|
-
const targetStat = await
|
|
33095
|
+
const targetStat = await fs25.promises.stat(fullPath);
|
|
32568
33096
|
isDir = targetStat.isDirectory();
|
|
32569
33097
|
} catch {
|
|
32570
33098
|
isDir = false;
|
|
@@ -32589,25 +33117,25 @@ async function listDirAsync(relativePath) {
|
|
|
32589
33117
|
}
|
|
32590
33118
|
|
|
32591
33119
|
// src/files/read-file.ts
|
|
32592
|
-
import
|
|
33120
|
+
import fs26 from "node:fs";
|
|
32593
33121
|
import { StringDecoder } from "node:string_decoder";
|
|
32594
33122
|
function resolveFilePath(relativePath) {
|
|
32595
33123
|
const resolved = ensureUnderCwd(relativePath, getBridgeWorkspaceDirectory());
|
|
32596
33124
|
if (!resolved) return { error: "Path is outside working directory" };
|
|
32597
33125
|
let real;
|
|
32598
33126
|
try {
|
|
32599
|
-
real =
|
|
33127
|
+
real = fs26.realpathSync(resolved);
|
|
32600
33128
|
} catch {
|
|
32601
33129
|
real = resolved;
|
|
32602
33130
|
}
|
|
32603
|
-
const stat2 =
|
|
33131
|
+
const stat2 = fs26.statSync(real);
|
|
32604
33132
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
32605
33133
|
return real;
|
|
32606
33134
|
}
|
|
32607
33135
|
var LINE_CHUNK_SIZE = 64 * 1024;
|
|
32608
33136
|
function readFileRange(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
32609
|
-
const fileSize =
|
|
32610
|
-
const fd =
|
|
33137
|
+
const fileSize = fs26.statSync(filePath).size;
|
|
33138
|
+
const fd = fs26.openSync(filePath, "r");
|
|
32611
33139
|
const bufSize = 64 * 1024;
|
|
32612
33140
|
const buf = Buffer.alloc(bufSize);
|
|
32613
33141
|
const decoder = new StringDecoder("utf8");
|
|
@@ -32620,7 +33148,7 @@ function readFileRange(filePath, startLine, endLine, lineOffsetIn, lineChunkSize
|
|
|
32620
33148
|
let line0Accum = "";
|
|
32621
33149
|
try {
|
|
32622
33150
|
let bytesRead;
|
|
32623
|
-
while (!done && (bytesRead =
|
|
33151
|
+
while (!done && (bytesRead = fs26.readSync(fd, buf, 0, bufSize, null)) > 0) {
|
|
32624
33152
|
const text = partial2 + decoder.write(buf.subarray(0, bytesRead));
|
|
32625
33153
|
partial2 = "";
|
|
32626
33154
|
let lineStart = 0;
|
|
@@ -32755,7 +33283,7 @@ function readFileRange(filePath, startLine, endLine, lineOffsetIn, lineChunkSize
|
|
|
32755
33283
|
}
|
|
32756
33284
|
return { content: resultLines.join("\n"), size: fileSize };
|
|
32757
33285
|
} finally {
|
|
32758
|
-
|
|
33286
|
+
fs26.closeSync(fd);
|
|
32759
33287
|
}
|
|
32760
33288
|
}
|
|
32761
33289
|
function readFile2(relativePath, startLine, endLine, lineOffset, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
@@ -32766,8 +33294,8 @@ function readFile2(relativePath, startLine, endLine, lineOffset, lineChunkSize =
|
|
|
32766
33294
|
if (hasRange) {
|
|
32767
33295
|
return readFileRange(result, startLine, endLine, lineOffset, lineChunkSize);
|
|
32768
33296
|
}
|
|
32769
|
-
const stat2 =
|
|
32770
|
-
const raw =
|
|
33297
|
+
const stat2 = fs26.statSync(result);
|
|
33298
|
+
const raw = fs26.readFileSync(result, "utf8");
|
|
32771
33299
|
const lines = raw.split(/\r?\n/);
|
|
32772
33300
|
return { content: raw, totalLines: lines.length, size: stat2.size };
|
|
32773
33301
|
} catch (err) {
|
|
@@ -32877,8 +33405,8 @@ function handleSkillLayoutRequest(msg, deps) {
|
|
|
32877
33405
|
}
|
|
32878
33406
|
|
|
32879
33407
|
// src/skills/install-remote-skills.ts
|
|
32880
|
-
import
|
|
32881
|
-
import
|
|
33408
|
+
import fs27 from "node:fs";
|
|
33409
|
+
import path31 from "node:path";
|
|
32882
33410
|
function installRemoteSkills(cwd, targetDir, items) {
|
|
32883
33411
|
const installed2 = [];
|
|
32884
33412
|
if (!Array.isArray(items)) {
|
|
@@ -32889,15 +33417,15 @@ function installRemoteSkills(cwd, targetDir, items) {
|
|
|
32889
33417
|
if (typeof item.sourceId !== "string" || typeof item.skillName !== "string" || typeof item.versionHash !== "string" || !Array.isArray(item.files)) {
|
|
32890
33418
|
continue;
|
|
32891
33419
|
}
|
|
32892
|
-
const skillDir =
|
|
33420
|
+
const skillDir = path31.join(cwd, targetDir, item.skillName);
|
|
32893
33421
|
for (const f of item.files) {
|
|
32894
33422
|
if (typeof f.path !== "string" || !f.text && !f.base64) continue;
|
|
32895
|
-
const dest =
|
|
32896
|
-
|
|
33423
|
+
const dest = path31.join(skillDir, f.path);
|
|
33424
|
+
fs27.mkdirSync(path31.dirname(dest), { recursive: true });
|
|
32897
33425
|
if (f.text !== void 0) {
|
|
32898
|
-
|
|
33426
|
+
fs27.writeFileSync(dest, f.text, "utf8");
|
|
32899
33427
|
} else if (f.base64) {
|
|
32900
|
-
|
|
33428
|
+
fs27.writeFileSync(dest, Buffer.from(f.base64, "base64"));
|
|
32901
33429
|
}
|
|
32902
33430
|
}
|
|
32903
33431
|
installed2.push({
|
|
@@ -33042,7 +33570,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
33042
33570
|
};
|
|
33043
33571
|
|
|
33044
33572
|
// src/bridge/routing/handlers/revert-turn-snapshot.ts
|
|
33045
|
-
import * as
|
|
33573
|
+
import * as fs28 from "node:fs";
|
|
33046
33574
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
33047
33575
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
33048
33576
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -33054,7 +33582,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
33054
33582
|
if (!s) return;
|
|
33055
33583
|
const agentBase = sessionWorktreeManager.getAgentCwdForSession(sessionId) ?? getBridgeWorkspaceDirectory();
|
|
33056
33584
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
33057
|
-
if (!
|
|
33585
|
+
if (!fs28.existsSync(file2)) {
|
|
33058
33586
|
sendWsMessage(s, {
|
|
33059
33587
|
type: "revert_turn_snapshot_result",
|
|
33060
33588
|
id,
|