@buildautomaton/cli 0.1.51 → 0.1.52
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 +649 -269
- package/dist/cli.js.map +4 -4
- package/dist/index.js +634 -254
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4175,8 +4175,8 @@ var init_parseUtil = __esm({
|
|
|
4175
4175
|
init_errors();
|
|
4176
4176
|
init_en();
|
|
4177
4177
|
makeIssue = (params) => {
|
|
4178
|
-
const { data, path:
|
|
4179
|
-
const fullPath = [...
|
|
4178
|
+
const { data, path: path61, errorMaps, issueData } = params;
|
|
4179
|
+
const fullPath = [...path61, ...issueData.path || []];
|
|
4180
4180
|
const fullIssue = {
|
|
4181
4181
|
...issueData,
|
|
4182
4182
|
path: fullPath
|
|
@@ -4484,11 +4484,11 @@ var init_types = __esm({
|
|
|
4484
4484
|
init_parseUtil();
|
|
4485
4485
|
init_util();
|
|
4486
4486
|
ParseInputLazyPath = class {
|
|
4487
|
-
constructor(parent, value,
|
|
4487
|
+
constructor(parent, value, path61, key) {
|
|
4488
4488
|
this._cachedPath = [];
|
|
4489
4489
|
this.parent = parent;
|
|
4490
4490
|
this.data = value;
|
|
4491
|
-
this._path =
|
|
4491
|
+
this._path = path61;
|
|
4492
4492
|
this._key = key;
|
|
4493
4493
|
}
|
|
4494
4494
|
get path() {
|
|
@@ -8103,10 +8103,10 @@ function assignProp(target, prop, value) {
|
|
|
8103
8103
|
configurable: true
|
|
8104
8104
|
});
|
|
8105
8105
|
}
|
|
8106
|
-
function getElementAtPath(obj,
|
|
8107
|
-
if (!
|
|
8106
|
+
function getElementAtPath(obj, path61) {
|
|
8107
|
+
if (!path61)
|
|
8108
8108
|
return obj;
|
|
8109
|
-
return
|
|
8109
|
+
return path61.reduce((acc, key) => acc?.[key], obj);
|
|
8110
8110
|
}
|
|
8111
8111
|
function promiseAllObject(promisesObj) {
|
|
8112
8112
|
const keys = Object.keys(promisesObj);
|
|
@@ -8355,11 +8355,11 @@ function aborted(x, startIndex = 0) {
|
|
|
8355
8355
|
}
|
|
8356
8356
|
return false;
|
|
8357
8357
|
}
|
|
8358
|
-
function prefixIssues(
|
|
8358
|
+
function prefixIssues(path61, issues) {
|
|
8359
8359
|
return issues.map((iss) => {
|
|
8360
8360
|
var _a2;
|
|
8361
8361
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
8362
|
-
iss.path.unshift(
|
|
8362
|
+
iss.path.unshift(path61);
|
|
8363
8363
|
return iss;
|
|
8364
8364
|
});
|
|
8365
8365
|
}
|
|
@@ -8548,7 +8548,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8548
8548
|
return issue2.message;
|
|
8549
8549
|
};
|
|
8550
8550
|
const result = { errors: [] };
|
|
8551
|
-
const processError = (error41,
|
|
8551
|
+
const processError = (error41, path61 = []) => {
|
|
8552
8552
|
var _a2, _b;
|
|
8553
8553
|
for (const issue2 of error41.issues) {
|
|
8554
8554
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -8558,7 +8558,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8558
8558
|
} else if (issue2.code === "invalid_element") {
|
|
8559
8559
|
processError({ issues: issue2.issues }, issue2.path);
|
|
8560
8560
|
} else {
|
|
8561
|
-
const fullpath = [...
|
|
8561
|
+
const fullpath = [...path61, ...issue2.path];
|
|
8562
8562
|
if (fullpath.length === 0) {
|
|
8563
8563
|
result.errors.push(mapper(issue2));
|
|
8564
8564
|
continue;
|
|
@@ -8588,9 +8588,9 @@ function treeifyError(error40, _mapper) {
|
|
|
8588
8588
|
processError(error40);
|
|
8589
8589
|
return result;
|
|
8590
8590
|
}
|
|
8591
|
-
function toDotPath(
|
|
8591
|
+
function toDotPath(path61) {
|
|
8592
8592
|
const segs = [];
|
|
8593
|
-
for (const seg of
|
|
8593
|
+
for (const seg of path61) {
|
|
8594
8594
|
if (typeof seg === "number")
|
|
8595
8595
|
segs.push(`[${seg}]`);
|
|
8596
8596
|
else if (typeof seg === "symbol")
|
|
@@ -21053,8 +21053,8 @@ var init_acp = __esm({
|
|
|
21053
21053
|
this.#requestHandler = requestHandler;
|
|
21054
21054
|
this.#notificationHandler = notificationHandler;
|
|
21055
21055
|
this.#stream = stream;
|
|
21056
|
-
this.#closedPromise = new Promise((
|
|
21057
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
21056
|
+
this.#closedPromise = new Promise((resolve33) => {
|
|
21057
|
+
this.#abortController.signal.addEventListener("abort", () => resolve33());
|
|
21058
21058
|
});
|
|
21059
21059
|
this.#receive();
|
|
21060
21060
|
}
|
|
@@ -21203,8 +21203,8 @@ var init_acp = __esm({
|
|
|
21203
21203
|
}
|
|
21204
21204
|
async sendRequest(method, params) {
|
|
21205
21205
|
const id = this.#nextRequestId++;
|
|
21206
|
-
const responsePromise = new Promise((
|
|
21207
|
-
this.#pendingResponses.set(id, { resolve:
|
|
21206
|
+
const responsePromise = new Promise((resolve33, reject) => {
|
|
21207
|
+
this.#pendingResponses.set(id, { resolve: resolve33, reject });
|
|
21208
21208
|
});
|
|
21209
21209
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
21210
21210
|
return responsePromise;
|
|
@@ -22073,10 +22073,10 @@ var require_src2 = __commonJS({
|
|
|
22073
22073
|
var fs_1 = __require("fs");
|
|
22074
22074
|
var debug_1 = __importDefault(require_src());
|
|
22075
22075
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
22076
|
-
function check2(
|
|
22077
|
-
log2(`checking %s`,
|
|
22076
|
+
function check2(path61, isFile, isDirectory) {
|
|
22077
|
+
log2(`checking %s`, path61);
|
|
22078
22078
|
try {
|
|
22079
|
-
const stat2 = fs_1.statSync(
|
|
22079
|
+
const stat2 = fs_1.statSync(path61);
|
|
22080
22080
|
if (stat2.isFile() && isFile) {
|
|
22081
22081
|
log2(`[OK] path represents a file`);
|
|
22082
22082
|
return true;
|
|
@@ -22096,8 +22096,8 @@ var require_src2 = __commonJS({
|
|
|
22096
22096
|
throw e;
|
|
22097
22097
|
}
|
|
22098
22098
|
}
|
|
22099
|
-
function exists2(
|
|
22100
|
-
return check2(
|
|
22099
|
+
function exists2(path61, type = exports.READABLE) {
|
|
22100
|
+
return check2(path61, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
22101
22101
|
}
|
|
22102
22102
|
exports.exists = exists2;
|
|
22103
22103
|
exports.FILE = 1;
|
|
@@ -22446,10 +22446,10 @@ async function killChildProcessTreeGracefully(child, graceMs = ACP_PROCESS_TREE_
|
|
|
22446
22446
|
}
|
|
22447
22447
|
await killProcessTree(pid, "SIGTERM");
|
|
22448
22448
|
if (graceMs <= 0) return;
|
|
22449
|
-
const exited = new Promise((
|
|
22450
|
-
child.once("exit", () =>
|
|
22449
|
+
const exited = new Promise((resolve33) => {
|
|
22450
|
+
child.once("exit", () => resolve33());
|
|
22451
22451
|
});
|
|
22452
|
-
await Promise.race([exited, new Promise((
|
|
22452
|
+
await Promise.race([exited, new Promise((resolve33) => setTimeout(resolve33, graceMs))]);
|
|
22453
22453
|
if (child.exitCode == null && child.signalCode == null) {
|
|
22454
22454
|
await killProcessTree(pid, "SIGKILL");
|
|
22455
22455
|
}
|
|
@@ -22466,8 +22466,8 @@ async function gracefulAcpSubprocessDisconnect(params) {
|
|
|
22466
22466
|
await transport.closeSession?.(sessionId);
|
|
22467
22467
|
} catch {
|
|
22468
22468
|
}
|
|
22469
|
-
await new Promise((
|
|
22470
|
-
const timer = setTimeout(
|
|
22469
|
+
await new Promise((resolve33) => {
|
|
22470
|
+
const timer = setTimeout(resolve33, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
|
|
22471
22471
|
timer.unref?.();
|
|
22472
22472
|
});
|
|
22473
22473
|
}
|
|
@@ -23172,9 +23172,9 @@ function parseChangeSummaryJson(raw, allowedPaths, options) {
|
|
|
23172
23172
|
const rawPath = typeof o.path === "string" ? o.path.trim() : "";
|
|
23173
23173
|
const summary = typeof o.summary === "string" ? o.summary.trim() : "";
|
|
23174
23174
|
if (!rawPath || !summary) continue;
|
|
23175
|
-
const
|
|
23176
|
-
if (!
|
|
23177
|
-
rows.push({ path:
|
|
23175
|
+
const path61 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
|
|
23176
|
+
if (!path61) continue;
|
|
23177
|
+
rows.push({ path: path61, summary: clampSummaryToAtMostTwoLines(summary) });
|
|
23178
23178
|
}
|
|
23179
23179
|
return rows;
|
|
23180
23180
|
}
|
|
@@ -23628,11 +23628,11 @@ function createSdkStdioExtNotificationHandler(options) {
|
|
|
23628
23628
|
// src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
|
|
23629
23629
|
function awaitSdkStdioPermissionRequestHandshake(params) {
|
|
23630
23630
|
const { requestId, paramsRecord, pending, onRequest } = params;
|
|
23631
|
-
return new Promise((
|
|
23632
|
-
pending.set(requestId, { resolve:
|
|
23631
|
+
return new Promise((resolve33) => {
|
|
23632
|
+
pending.set(requestId, { resolve: resolve33, params: paramsRecord });
|
|
23633
23633
|
if (onRequest == null) {
|
|
23634
23634
|
pending.delete(requestId);
|
|
23635
|
-
|
|
23635
|
+
resolve33({ outcome: { outcome: "denied" } });
|
|
23636
23636
|
return;
|
|
23637
23637
|
}
|
|
23638
23638
|
try {
|
|
@@ -24176,10 +24176,10 @@ function createSdkStdioInitSettle(child) {
|
|
|
24176
24176
|
forceAcpSubprocessDisconnect(child);
|
|
24177
24177
|
reject(err);
|
|
24178
24178
|
},
|
|
24179
|
-
settleResolve(
|
|
24179
|
+
settleResolve(resolve33, handle) {
|
|
24180
24180
|
if (initSettled) return;
|
|
24181
24181
|
initSettled = true;
|
|
24182
|
-
|
|
24182
|
+
resolve33(handle);
|
|
24183
24183
|
}
|
|
24184
24184
|
};
|
|
24185
24185
|
}
|
|
@@ -24248,7 +24248,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
24248
24248
|
onFileChange,
|
|
24249
24249
|
stderrCapture
|
|
24250
24250
|
});
|
|
24251
|
-
return new Promise((
|
|
24251
|
+
return new Promise((resolve33, reject) => {
|
|
24252
24252
|
const init = createSdkStdioInitSettle(child);
|
|
24253
24253
|
child.on("error", (err) => {
|
|
24254
24254
|
init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
|
|
@@ -24273,7 +24273,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
24273
24273
|
protocolVersion: PROTOCOL_VERSION2
|
|
24274
24274
|
});
|
|
24275
24275
|
init.settleResolve(
|
|
24276
|
-
|
|
24276
|
+
resolve33,
|
|
24277
24277
|
createSdkStdioHandle({
|
|
24278
24278
|
child,
|
|
24279
24279
|
sessionId: established.sessionId,
|
|
@@ -24381,7 +24381,7 @@ async function proxyToLocal(request) {
|
|
|
24381
24381
|
};
|
|
24382
24382
|
const maxAttempts = isIdempotentProxyMethod(request.method) ? LOCAL_PREVIEW_FETCH_RETRY_DELAYS_MS.length + 1 : 1;
|
|
24383
24383
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
24384
|
-
const once = await new Promise((
|
|
24384
|
+
const once = await new Promise((resolve33) => {
|
|
24385
24385
|
const req = mod.request(opts, (res) => {
|
|
24386
24386
|
const chunks = [];
|
|
24387
24387
|
res.on("data", (c) => chunks.push(c));
|
|
@@ -24392,7 +24392,7 @@ async function proxyToLocal(request) {
|
|
|
24392
24392
|
if (typeof v === "string") headers[k] = v;
|
|
24393
24393
|
else if (Array.isArray(v) && v[0]) headers[k] = v[0];
|
|
24394
24394
|
}
|
|
24395
|
-
|
|
24395
|
+
resolve33({
|
|
24396
24396
|
id: request.id,
|
|
24397
24397
|
statusCode: res.statusCode ?? 0,
|
|
24398
24398
|
headers,
|
|
@@ -24401,7 +24401,7 @@ async function proxyToLocal(request) {
|
|
|
24401
24401
|
});
|
|
24402
24402
|
});
|
|
24403
24403
|
req.on("error", (err) => {
|
|
24404
|
-
|
|
24404
|
+
resolve33({
|
|
24405
24405
|
id: request.id,
|
|
24406
24406
|
statusCode: 0,
|
|
24407
24407
|
headers: {},
|
|
@@ -24483,8 +24483,8 @@ function randomSecret() {
|
|
|
24483
24483
|
}
|
|
24484
24484
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
24485
24485
|
}
|
|
24486
|
-
async function requestPreviewApi(port, secret, method,
|
|
24487
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
24486
|
+
async function requestPreviewApi(port, secret, method, path61, body) {
|
|
24487
|
+
const url2 = `http://127.0.0.1:${port}${path61}`;
|
|
24488
24488
|
const headers = {
|
|
24489
24489
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
24490
24490
|
"Content-Type": "application/json"
|
|
@@ -24496,7 +24496,7 @@ async function requestPreviewApi(port, secret, method, path60, body) {
|
|
|
24496
24496
|
});
|
|
24497
24497
|
const data = await res.json().catch(() => ({}));
|
|
24498
24498
|
if (!res.ok) {
|
|
24499
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
24499
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path61}: ${res.status}`);
|
|
24500
24500
|
}
|
|
24501
24501
|
return data;
|
|
24502
24502
|
}
|
|
@@ -24711,7 +24711,7 @@ function installBridgeProcessResilience() {
|
|
|
24711
24711
|
}
|
|
24712
24712
|
|
|
24713
24713
|
// src/cli-version.ts
|
|
24714
|
-
var CLI_VERSION = "0.1.
|
|
24714
|
+
var CLI_VERSION = "0.1.52".length > 0 ? "0.1.52" : "0.0.0-dev";
|
|
24715
24715
|
|
|
24716
24716
|
// src/connection/heartbeat/constants.ts
|
|
24717
24717
|
var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
|
|
@@ -25152,14 +25152,14 @@ var baseOpen = async (options) => {
|
|
|
25152
25152
|
}
|
|
25153
25153
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
25154
25154
|
if (options.wait) {
|
|
25155
|
-
return new Promise((
|
|
25155
|
+
return new Promise((resolve33, reject) => {
|
|
25156
25156
|
subprocess.once("error", reject);
|
|
25157
25157
|
subprocess.once("close", (exitCode) => {
|
|
25158
25158
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
25159
25159
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
25160
25160
|
return;
|
|
25161
25161
|
}
|
|
25162
|
-
|
|
25162
|
+
resolve33(subprocess);
|
|
25163
25163
|
});
|
|
25164
25164
|
});
|
|
25165
25165
|
}
|
|
@@ -25703,8 +25703,8 @@ function runPendingAuth(options) {
|
|
|
25703
25703
|
let hasOpenedBrowser = false;
|
|
25704
25704
|
let resolved = false;
|
|
25705
25705
|
let resolveAuth;
|
|
25706
|
-
const authPromise = new Promise((
|
|
25707
|
-
resolveAuth =
|
|
25706
|
+
const authPromise = new Promise((resolve33) => {
|
|
25707
|
+
resolveAuth = resolve33;
|
|
25708
25708
|
});
|
|
25709
25709
|
let reconnectAttempt = 0;
|
|
25710
25710
|
const signInQuiet = createEmptyReconnectQuietSlot();
|
|
@@ -25855,7 +25855,7 @@ import sqliteWasm from "node-sqlite3-wasm";
|
|
|
25855
25855
|
|
|
25856
25856
|
// src/runtime/yield-to-event-loop.ts
|
|
25857
25857
|
function yieldToEventLoop() {
|
|
25858
|
-
return new Promise((
|
|
25858
|
+
return new Promise((resolve33) => setImmediate(resolve33));
|
|
25859
25859
|
}
|
|
25860
25860
|
|
|
25861
25861
|
// src/sqlite/cli-sqlite-paths.ts
|
|
@@ -27019,7 +27019,7 @@ async function createCursorAcpClient(options) {
|
|
|
27019
27019
|
onFileChange,
|
|
27020
27020
|
stderrCapture
|
|
27021
27021
|
});
|
|
27022
|
-
return new Promise((
|
|
27022
|
+
return new Promise((resolve33, reject) => {
|
|
27023
27023
|
child.on("error", (err) => {
|
|
27024
27024
|
killChildProcessTree(child, "SIGKILL");
|
|
27025
27025
|
reject(new Error(formatSpawnError(err, command[0])));
|
|
@@ -27031,7 +27031,7 @@ async function createCursorAcpClient(options) {
|
|
|
27031
27031
|
sessionCtx,
|
|
27032
27032
|
incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
|
|
27033
27033
|
});
|
|
27034
|
-
|
|
27034
|
+
resolve33(
|
|
27035
27035
|
createCursorAcpHandle({
|
|
27036
27036
|
child,
|
|
27037
27037
|
sessionId: established.sessionId,
|
|
@@ -28237,8 +28237,8 @@ function pathspec(...paths) {
|
|
|
28237
28237
|
cache.set(key, paths);
|
|
28238
28238
|
return key;
|
|
28239
28239
|
}
|
|
28240
|
-
function isPathSpec(
|
|
28241
|
-
return
|
|
28240
|
+
function isPathSpec(path61) {
|
|
28241
|
+
return path61 instanceof String && cache.has(path61);
|
|
28242
28242
|
}
|
|
28243
28243
|
function toPaths(pathSpec) {
|
|
28244
28244
|
return cache.get(pathSpec) || [];
|
|
@@ -28327,8 +28327,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
28327
28327
|
function forEachLineWithContent(input, callback) {
|
|
28328
28328
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
28329
28329
|
}
|
|
28330
|
-
function folderExists(
|
|
28331
|
-
return (0, import_file_exists.exists)(
|
|
28330
|
+
function folderExists(path61) {
|
|
28331
|
+
return (0, import_file_exists.exists)(path61, import_file_exists.FOLDER);
|
|
28332
28332
|
}
|
|
28333
28333
|
function append(target, item) {
|
|
28334
28334
|
if (Array.isArray(target)) {
|
|
@@ -28732,8 +28732,8 @@ function checkIsRepoRootTask() {
|
|
|
28732
28732
|
commands,
|
|
28733
28733
|
format: "utf-8",
|
|
28734
28734
|
onError,
|
|
28735
|
-
parser(
|
|
28736
|
-
return /^\.(git)?$/.test(
|
|
28735
|
+
parser(path61) {
|
|
28736
|
+
return /^\.(git)?$/.test(path61.trim());
|
|
28737
28737
|
}
|
|
28738
28738
|
};
|
|
28739
28739
|
}
|
|
@@ -29167,11 +29167,11 @@ function parseGrep(grep) {
|
|
|
29167
29167
|
const paths = /* @__PURE__ */ new Set();
|
|
29168
29168
|
const results = {};
|
|
29169
29169
|
forEachLineWithContent(grep, (input) => {
|
|
29170
|
-
const [
|
|
29171
|
-
paths.add(
|
|
29172
|
-
(results[
|
|
29170
|
+
const [path61, line, preview] = input.split(NULL);
|
|
29171
|
+
paths.add(path61);
|
|
29172
|
+
(results[path61] = results[path61] || []).push({
|
|
29173
29173
|
line: asNumber(line),
|
|
29174
|
-
path:
|
|
29174
|
+
path: path61,
|
|
29175
29175
|
preview
|
|
29176
29176
|
});
|
|
29177
29177
|
});
|
|
@@ -29936,14 +29936,14 @@ var init_hash_object = __esm2({
|
|
|
29936
29936
|
init_task();
|
|
29937
29937
|
}
|
|
29938
29938
|
});
|
|
29939
|
-
function parseInit(bare,
|
|
29939
|
+
function parseInit(bare, path61, text) {
|
|
29940
29940
|
const response = String(text).trim();
|
|
29941
29941
|
let result;
|
|
29942
29942
|
if (result = initResponseRegex.exec(response)) {
|
|
29943
|
-
return new InitSummary(bare,
|
|
29943
|
+
return new InitSummary(bare, path61, false, result[1]);
|
|
29944
29944
|
}
|
|
29945
29945
|
if (result = reInitResponseRegex.exec(response)) {
|
|
29946
|
-
return new InitSummary(bare,
|
|
29946
|
+
return new InitSummary(bare, path61, true, result[1]);
|
|
29947
29947
|
}
|
|
29948
29948
|
let gitDir = "";
|
|
29949
29949
|
const tokens = response.split(" ");
|
|
@@ -29954,7 +29954,7 @@ function parseInit(bare, path60, text) {
|
|
|
29954
29954
|
break;
|
|
29955
29955
|
}
|
|
29956
29956
|
}
|
|
29957
|
-
return new InitSummary(bare,
|
|
29957
|
+
return new InitSummary(bare, path61, /^re/i.test(response), gitDir);
|
|
29958
29958
|
}
|
|
29959
29959
|
var InitSummary;
|
|
29960
29960
|
var initResponseRegex;
|
|
@@ -29963,9 +29963,9 @@ var init_InitSummary = __esm2({
|
|
|
29963
29963
|
"src/lib/responses/InitSummary.ts"() {
|
|
29964
29964
|
"use strict";
|
|
29965
29965
|
InitSummary = class {
|
|
29966
|
-
constructor(bare,
|
|
29966
|
+
constructor(bare, path61, existing, gitDir) {
|
|
29967
29967
|
this.bare = bare;
|
|
29968
|
-
this.path =
|
|
29968
|
+
this.path = path61;
|
|
29969
29969
|
this.existing = existing;
|
|
29970
29970
|
this.gitDir = gitDir;
|
|
29971
29971
|
}
|
|
@@ -29977,7 +29977,7 @@ var init_InitSummary = __esm2({
|
|
|
29977
29977
|
function hasBareCommand(command) {
|
|
29978
29978
|
return command.includes(bareCommand);
|
|
29979
29979
|
}
|
|
29980
|
-
function initTask(bare = false,
|
|
29980
|
+
function initTask(bare = false, path61, customArgs) {
|
|
29981
29981
|
const commands = ["init", ...customArgs];
|
|
29982
29982
|
if (bare && !hasBareCommand(commands)) {
|
|
29983
29983
|
commands.splice(1, 0, bareCommand);
|
|
@@ -29986,7 +29986,7 @@ function initTask(bare = false, path60, customArgs) {
|
|
|
29986
29986
|
commands,
|
|
29987
29987
|
format: "utf-8",
|
|
29988
29988
|
parser(text) {
|
|
29989
|
-
return parseInit(commands.includes("--bare"),
|
|
29989
|
+
return parseInit(commands.includes("--bare"), path61, text);
|
|
29990
29990
|
}
|
|
29991
29991
|
};
|
|
29992
29992
|
}
|
|
@@ -30802,12 +30802,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
30802
30802
|
"use strict";
|
|
30803
30803
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
30804
30804
|
FileStatusSummary = class {
|
|
30805
|
-
constructor(
|
|
30806
|
-
this.path =
|
|
30805
|
+
constructor(path61, index, working_dir) {
|
|
30806
|
+
this.path = path61;
|
|
30807
30807
|
this.index = index;
|
|
30808
30808
|
this.working_dir = working_dir;
|
|
30809
30809
|
if (index === "R" || working_dir === "R") {
|
|
30810
|
-
const detail = fromPathRegex.exec(
|
|
30810
|
+
const detail = fromPathRegex.exec(path61) || [null, path61, path61];
|
|
30811
30811
|
this.from = detail[2] || "";
|
|
30812
30812
|
this.path = detail[1] || "";
|
|
30813
30813
|
}
|
|
@@ -30838,14 +30838,14 @@ function splitLine(result, lineStr) {
|
|
|
30838
30838
|
default:
|
|
30839
30839
|
return;
|
|
30840
30840
|
}
|
|
30841
|
-
function data(index, workingDir,
|
|
30841
|
+
function data(index, workingDir, path61) {
|
|
30842
30842
|
const raw = `${index}${workingDir}`;
|
|
30843
30843
|
const handler = parsers6.get(raw);
|
|
30844
30844
|
if (handler) {
|
|
30845
|
-
handler(result,
|
|
30845
|
+
handler(result, path61);
|
|
30846
30846
|
}
|
|
30847
30847
|
if (raw !== "##" && raw !== "!!") {
|
|
30848
|
-
result.files.push(new FileStatusSummary(
|
|
30848
|
+
result.files.push(new FileStatusSummary(path61, index, workingDir));
|
|
30849
30849
|
}
|
|
30850
30850
|
}
|
|
30851
30851
|
}
|
|
@@ -31154,9 +31154,9 @@ var init_simple_git_api = __esm2({
|
|
|
31154
31154
|
next
|
|
31155
31155
|
);
|
|
31156
31156
|
}
|
|
31157
|
-
hashObject(
|
|
31157
|
+
hashObject(path61, write) {
|
|
31158
31158
|
return this._runTask(
|
|
31159
|
-
hashObjectTask(
|
|
31159
|
+
hashObjectTask(path61, write === true),
|
|
31160
31160
|
trailingFunctionArgument(arguments)
|
|
31161
31161
|
);
|
|
31162
31162
|
}
|
|
@@ -31509,8 +31509,8 @@ var init_branch = __esm2({
|
|
|
31509
31509
|
}
|
|
31510
31510
|
});
|
|
31511
31511
|
function toPath(input) {
|
|
31512
|
-
const
|
|
31513
|
-
return
|
|
31512
|
+
const path61 = input.trim().replace(/^["']|["']$/g, "");
|
|
31513
|
+
return path61 && normalize3(path61);
|
|
31514
31514
|
}
|
|
31515
31515
|
var parseCheckIgnore;
|
|
31516
31516
|
var init_CheckIgnore = __esm2({
|
|
@@ -31824,8 +31824,8 @@ __export2(sub_module_exports, {
|
|
|
31824
31824
|
subModuleTask: () => subModuleTask,
|
|
31825
31825
|
updateSubModuleTask: () => updateSubModuleTask
|
|
31826
31826
|
});
|
|
31827
|
-
function addSubModuleTask(repo,
|
|
31828
|
-
return subModuleTask(["add", repo,
|
|
31827
|
+
function addSubModuleTask(repo, path61) {
|
|
31828
|
+
return subModuleTask(["add", repo, path61]);
|
|
31829
31829
|
}
|
|
31830
31830
|
function initSubModuleTask(customArgs) {
|
|
31831
31831
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -32158,8 +32158,8 @@ var require_git = __commonJS2({
|
|
|
32158
32158
|
}
|
|
32159
32159
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
32160
32160
|
};
|
|
32161
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
32162
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
32161
|
+
Git2.prototype.submoduleAdd = function(repo, path61, then) {
|
|
32162
|
+
return this._runTask(addSubModuleTask2(repo, path61), trailingFunctionArgument2(arguments));
|
|
32163
32163
|
};
|
|
32164
32164
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
32165
32165
|
return this._runTask(
|
|
@@ -32796,8 +32796,8 @@ async function runGitTask(fn) {
|
|
|
32796
32796
|
}
|
|
32797
32797
|
async function yieldToEventLoop2() {
|
|
32798
32798
|
throwIfGitShutdownRequested();
|
|
32799
|
-
await new Promise((
|
|
32800
|
-
setImmediate(
|
|
32799
|
+
await new Promise((resolve33) => {
|
|
32800
|
+
setImmediate(resolve33);
|
|
32801
32801
|
});
|
|
32802
32802
|
throwIfGitShutdownRequested();
|
|
32803
32803
|
}
|
|
@@ -32877,10 +32877,10 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
32877
32877
|
await yieldGitDiscoverWork(i + 1);
|
|
32878
32878
|
const ent = entries[i];
|
|
32879
32879
|
if (!ent.isDirectory()) continue;
|
|
32880
|
-
const
|
|
32881
|
-
if (await isGitRepoDirectory(
|
|
32882
|
-
const remoteUrl = await getRemoteOriginUrl(
|
|
32883
|
-
result.push({ absolutePath:
|
|
32880
|
+
const childPath2 = path16.join(cwdResolved, ent.name);
|
|
32881
|
+
if (await isGitRepoDirectory(childPath2)) {
|
|
32882
|
+
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
32883
|
+
result.push({ absolutePath: childPath2, remoteUrl });
|
|
32884
32884
|
}
|
|
32885
32885
|
}
|
|
32886
32886
|
return result;
|
|
@@ -33132,9 +33132,9 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
33132
33132
|
// src/agents/acp/put-summarize-change-summaries.ts
|
|
33133
33133
|
async function putEncryptedChangeSummaryRows(params) {
|
|
33134
33134
|
const base = params.apiBaseUrl.replace(/\/+$/, "");
|
|
33135
|
-
const entries = params.rows.map(({ path:
|
|
33135
|
+
const entries = params.rows.map(({ path: path61, summary }) => {
|
|
33136
33136
|
const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
|
|
33137
|
-
return { path:
|
|
33137
|
+
return { path: path61, summary: JSON.stringify(enc) };
|
|
33138
33138
|
});
|
|
33139
33139
|
const res = await fetch(
|
|
33140
33140
|
`${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
|
|
@@ -34074,8 +34074,8 @@ async function commitSessionWorktree(cache2, params) {
|
|
|
34074
34074
|
}
|
|
34075
34075
|
|
|
34076
34076
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
34077
|
-
function normalizeGitDiffPath(
|
|
34078
|
-
return
|
|
34077
|
+
function normalizeGitDiffPath(path61) {
|
|
34078
|
+
return path61.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
34079
34079
|
}
|
|
34080
34080
|
|
|
34081
34081
|
// src/git/changes/parse/expand-git-rename-numstat-path.ts
|
|
@@ -34175,8 +34175,8 @@ function parseNumstatEntries(lines) {
|
|
|
34175
34175
|
}
|
|
34176
34176
|
function parseNumstat(lines) {
|
|
34177
34177
|
const m = /* @__PURE__ */ new Map();
|
|
34178
|
-
for (const [
|
|
34179
|
-
m.set(
|
|
34178
|
+
for (const [path61, entry] of parseNumstatEntries(lines)) {
|
|
34179
|
+
m.set(path61, { additions: entry.additions, deletions: entry.deletions });
|
|
34180
34180
|
}
|
|
34181
34181
|
return m;
|
|
34182
34182
|
}
|
|
@@ -36402,7 +36402,7 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
|
36402
36402
|
}
|
|
36403
36403
|
|
|
36404
36404
|
// src/connection/create-bridge-connection.ts
|
|
36405
|
-
import * as
|
|
36405
|
+
import * as path60 from "node:path";
|
|
36406
36406
|
|
|
36407
36407
|
// src/dev-servers/manager/dev-server-manager.ts
|
|
36408
36408
|
import { rm as rm2 } from "node:fs/promises";
|
|
@@ -36424,15 +36424,15 @@ function sendDevServerStatus(getWs, serverId, status, options) {
|
|
|
36424
36424
|
|
|
36425
36425
|
// src/dev-servers/process/terminate-child-process.ts
|
|
36426
36426
|
async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
|
|
36427
|
-
const exited = new Promise((
|
|
36428
|
-
proc.once("exit", () =>
|
|
36427
|
+
const exited = new Promise((resolve33) => {
|
|
36428
|
+
proc.once("exit", () => resolve33());
|
|
36429
36429
|
});
|
|
36430
36430
|
log2(`[dev-server] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
|
|
36431
36431
|
try {
|
|
36432
36432
|
proc.kill("SIGTERM");
|
|
36433
36433
|
} catch {
|
|
36434
36434
|
}
|
|
36435
|
-
await Promise.race([exited, new Promise((
|
|
36435
|
+
await Promise.race([exited, new Promise((resolve33) => setTimeout(resolve33, graceMs))]);
|
|
36436
36436
|
}
|
|
36437
36437
|
function forceKillChild(proc, log2, shortId, graceMs) {
|
|
36438
36438
|
log2(
|
|
@@ -38302,9 +38302,9 @@ function parseChangeSummarySnapshots(raw) {
|
|
|
38302
38302
|
for (const item of raw) {
|
|
38303
38303
|
if (!item || typeof item !== "object") continue;
|
|
38304
38304
|
const o = item;
|
|
38305
|
-
const
|
|
38306
|
-
if (!
|
|
38307
|
-
const row = { path:
|
|
38305
|
+
const path61 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
|
|
38306
|
+
if (!path61) continue;
|
|
38307
|
+
const row = { path: path61 };
|
|
38308
38308
|
if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
|
|
38309
38309
|
if (typeof o.oldText === "string") row.oldText = o.oldText;
|
|
38310
38310
|
if (typeof o.newText === "string") row.newText = o.newText;
|
|
@@ -38517,6 +38517,17 @@ var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
|
|
|
38517
38517
|
);
|
|
38518
38518
|
};
|
|
38519
38519
|
|
|
38520
|
+
// src/files/resolve-file-browser-session-parent.ts
|
|
38521
|
+
async function resolveFileBrowserSessionParent(sessionWorktreeManager, sessionId) {
|
|
38522
|
+
const sid = sessionId?.trim();
|
|
38523
|
+
if (sid) {
|
|
38524
|
+
await sessionWorktreeManager.ensureRepoCheckoutPathsForSessionAsync(sid);
|
|
38525
|
+
const worktreeRoot = sessionWorktreeManager.getSessionWorktreeRootForSession(sid);
|
|
38526
|
+
if (worktreeRoot) return worktreeRoot;
|
|
38527
|
+
}
|
|
38528
|
+
return getBridgeRoot();
|
|
38529
|
+
}
|
|
38530
|
+
|
|
38520
38531
|
// src/files/list-dir/index.ts
|
|
38521
38532
|
import fs39 from "node:fs";
|
|
38522
38533
|
|
|
@@ -38588,10 +38599,447 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
38588
38599
|
}
|
|
38589
38600
|
}
|
|
38590
38601
|
|
|
38602
|
+
// src/files/handle-file-browser-search.ts
|
|
38603
|
+
import path54 from "node:path";
|
|
38604
|
+
var SEARCH_LIMIT = 100;
|
|
38605
|
+
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
38606
|
+
void (async () => {
|
|
38607
|
+
await yieldToEventLoop();
|
|
38608
|
+
const q = typeof msg.q === "string" ? msg.q : "";
|
|
38609
|
+
const sessionParentPath = path54.resolve(
|
|
38610
|
+
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
38611
|
+
);
|
|
38612
|
+
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
38613
|
+
const payload2 = {
|
|
38614
|
+
type: "file_browser_search_response",
|
|
38615
|
+
id: msg.id,
|
|
38616
|
+
paths: [],
|
|
38617
|
+
indexReady: false
|
|
38618
|
+
};
|
|
38619
|
+
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload2, ["paths"]) : payload2);
|
|
38620
|
+
return;
|
|
38621
|
+
}
|
|
38622
|
+
const results = await searchBridgeFilePathsAsync(sessionParentPath, q, SEARCH_LIMIT);
|
|
38623
|
+
const payload = {
|
|
38624
|
+
type: "file_browser_search_response",
|
|
38625
|
+
id: msg.id,
|
|
38626
|
+
paths: results,
|
|
38627
|
+
indexReady: true
|
|
38628
|
+
};
|
|
38629
|
+
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["paths"]) : payload);
|
|
38630
|
+
})();
|
|
38631
|
+
}
|
|
38632
|
+
function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
|
|
38633
|
+
setImmediate(() => {
|
|
38634
|
+
void ensureFileIndexAsync(sessionParentPath).catch((e) => {
|
|
38635
|
+
console.error("[file-index] Background build failed:", e);
|
|
38636
|
+
});
|
|
38637
|
+
});
|
|
38638
|
+
}
|
|
38639
|
+
|
|
38640
|
+
// src/git/tree/resolve-repo-abs-path.ts
|
|
38641
|
+
import * as path55 from "node:path";
|
|
38642
|
+
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
38643
|
+
const bridgeResolved = path55.resolve(bridgeRoot);
|
|
38644
|
+
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
38645
|
+
const repoPath = rel === "" ? bridgeResolved : path55.join(bridgeResolved, rel);
|
|
38646
|
+
const resolved = path55.resolve(repoPath);
|
|
38647
|
+
if (!resolved.startsWith(bridgeResolved + path55.sep) && resolved !== bridgeResolved) {
|
|
38648
|
+
return null;
|
|
38649
|
+
}
|
|
38650
|
+
return resolved;
|
|
38651
|
+
}
|
|
38652
|
+
|
|
38653
|
+
// src/git/tree/resolve-branch-commit.ts
|
|
38654
|
+
async function resolveBranchCommit(repoAbsPath, branch) {
|
|
38655
|
+
const branchRef = branch.trim();
|
|
38656
|
+
if (!branchRef) return null;
|
|
38657
|
+
try {
|
|
38658
|
+
return (await cliSimpleGit(repoAbsPath).revparse([`${branchRef}^{commit}`])).trim();
|
|
38659
|
+
} catch {
|
|
38660
|
+
return null;
|
|
38661
|
+
}
|
|
38662
|
+
}
|
|
38663
|
+
|
|
38664
|
+
// src/git/tree/list-git-tree-dir.ts
|
|
38665
|
+
function parseLsTreeLine(line) {
|
|
38666
|
+
const tab = line.indexOf(" ");
|
|
38667
|
+
if (tab < 0) return null;
|
|
38668
|
+
const meta = line.slice(0, tab).trim().split(/\s+/);
|
|
38669
|
+
if (meta.length < 3) return null;
|
|
38670
|
+
const mode = meta[0];
|
|
38671
|
+
const objectType2 = meta[1];
|
|
38672
|
+
let name = line.slice(tab + 1);
|
|
38673
|
+
if (name.startsWith('"') && name.endsWith('"')) {
|
|
38674
|
+
name = name.slice(1, -1).replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
38675
|
+
}
|
|
38676
|
+
return { mode, objectType: objectType2, name };
|
|
38677
|
+
}
|
|
38678
|
+
function childPath(relativePath, name) {
|
|
38679
|
+
const base = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
38680
|
+
if (!base || base === ".") return name;
|
|
38681
|
+
return `${base}/${name}`.replace(/\\/g, "/");
|
|
38682
|
+
}
|
|
38683
|
+
function lsTreeArgs(commit, relativePath) {
|
|
38684
|
+
const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
38685
|
+
if (!rel || rel === ".") return ["ls-tree", commit];
|
|
38686
|
+
return ["ls-tree", `${commit}:${rel}`];
|
|
38687
|
+
}
|
|
38688
|
+
async function listGitTreeDirAsync(repoAbsPath, branch, relativePath) {
|
|
38689
|
+
await yieldToEventLoop();
|
|
38690
|
+
const commit = await resolveBranchCommit(repoAbsPath, branch);
|
|
38691
|
+
if (!commit) return { error: "Branch not found" };
|
|
38692
|
+
try {
|
|
38693
|
+
const raw = await cliSimpleGit(repoAbsPath).raw(lsTreeArgs(commit, relativePath));
|
|
38694
|
+
await yieldToEventLoop();
|
|
38695
|
+
const lines = String(raw ?? "").split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
38696
|
+
const entries = [];
|
|
38697
|
+
for (let i = 0; i < lines.length; i++) {
|
|
38698
|
+
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
38699
|
+
await yieldToEventLoop();
|
|
38700
|
+
}
|
|
38701
|
+
const parsed = parseLsTreeLine(lines[i]);
|
|
38702
|
+
if (!parsed) continue;
|
|
38703
|
+
const { mode, objectType: objectType2, name } = parsed;
|
|
38704
|
+
if (!name || name === "." || name === "..") continue;
|
|
38705
|
+
const isSymlink = mode === "120000";
|
|
38706
|
+
const isDir = objectType2 === "tree";
|
|
38707
|
+
entries.push({
|
|
38708
|
+
name,
|
|
38709
|
+
path: childPath(relativePath, name),
|
|
38710
|
+
isDir,
|
|
38711
|
+
...isSymlink ? { isSymlink: true } : {}
|
|
38712
|
+
});
|
|
38713
|
+
}
|
|
38714
|
+
if (entries.length >= LIST_DIR_YIELD_EVERY) {
|
|
38715
|
+
await yieldToEventLoop();
|
|
38716
|
+
}
|
|
38717
|
+
return { entries: sortListEntries(entries) };
|
|
38718
|
+
} catch (err) {
|
|
38719
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
38720
|
+
if (/not a tree object|does not exist|bad revision/i.test(message)) {
|
|
38721
|
+
return { error: "Path not found in branch" };
|
|
38722
|
+
}
|
|
38723
|
+
return { error: message };
|
|
38724
|
+
}
|
|
38725
|
+
}
|
|
38726
|
+
|
|
38591
38727
|
// src/files/read-file/types.ts
|
|
38592
38728
|
var LINE_CHUNK_SIZE = 64 * 1024;
|
|
38593
38729
|
var READ_RANGE_YIELD_EVERY_BYTES = 256 * 1024;
|
|
38594
38730
|
|
|
38731
|
+
// src/files/read-file/guess-mime-type.ts
|
|
38732
|
+
var MIME_BY_EXT = {
|
|
38733
|
+
png: "image/png",
|
|
38734
|
+
jpg: "image/jpeg",
|
|
38735
|
+
jpeg: "image/jpeg",
|
|
38736
|
+
gif: "image/gif",
|
|
38737
|
+
bmp: "image/bmp",
|
|
38738
|
+
ico: "image/x-icon",
|
|
38739
|
+
webp: "image/webp",
|
|
38740
|
+
avif: "image/avif",
|
|
38741
|
+
svg: "image/svg+xml",
|
|
38742
|
+
pdf: "application/pdf",
|
|
38743
|
+
json: "application/json",
|
|
38744
|
+
html: "text/html",
|
|
38745
|
+
htm: "text/html",
|
|
38746
|
+
css: "text/css",
|
|
38747
|
+
js: "text/javascript",
|
|
38748
|
+
mjs: "text/javascript",
|
|
38749
|
+
ts: "text/typescript",
|
|
38750
|
+
txt: "text/plain",
|
|
38751
|
+
md: "text/markdown",
|
|
38752
|
+
xml: "application/xml",
|
|
38753
|
+
zip: "application/zip",
|
|
38754
|
+
gz: "application/gzip",
|
|
38755
|
+
wasm: "application/wasm"
|
|
38756
|
+
};
|
|
38757
|
+
function guessMimeType(filePath) {
|
|
38758
|
+
const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
|
|
38759
|
+
return MIME_BY_EXT[ext] ?? "application/octet-stream";
|
|
38760
|
+
}
|
|
38761
|
+
|
|
38762
|
+
// src/git/tree/file/git-blob-ref.ts
|
|
38763
|
+
async function gitBlobRef(repoAbsPath, branch, relativePath) {
|
|
38764
|
+
const commit = await resolveBranchCommit(repoAbsPath, branch);
|
|
38765
|
+
await yieldToEventLoop();
|
|
38766
|
+
if (!commit) return null;
|
|
38767
|
+
const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
38768
|
+
if (!rel || rel === ".") return null;
|
|
38769
|
+
return `${commit}:${rel}`;
|
|
38770
|
+
}
|
|
38771
|
+
|
|
38772
|
+
// src/git/tree/file/is-binary-buffer.ts
|
|
38773
|
+
function isBinaryBuffer(buf) {
|
|
38774
|
+
const sample = buf.subarray(0, Math.min(buf.length, 8192));
|
|
38775
|
+
for (let i = 0; i < sample.length; i++) {
|
|
38776
|
+
if (sample[i] === 0) return true;
|
|
38777
|
+
}
|
|
38778
|
+
return false;
|
|
38779
|
+
}
|
|
38780
|
+
|
|
38781
|
+
// src/git/tree/file/read-git-blob-text-async.ts
|
|
38782
|
+
import { StringDecoder } from "node:string_decoder";
|
|
38783
|
+
async function countGitBlobLinesAsync(buf) {
|
|
38784
|
+
if (buf.length === 0) return 1;
|
|
38785
|
+
let lines = 1;
|
|
38786
|
+
let bytesSinceYield = 0;
|
|
38787
|
+
for (let i = 0; i < buf.length; i++) {
|
|
38788
|
+
const b = buf[i];
|
|
38789
|
+
if (b === 10) {
|
|
38790
|
+
lines++;
|
|
38791
|
+
} else if (b === 13) {
|
|
38792
|
+
if (i + 1 < buf.length && buf[i + 1] === 10) {
|
|
38793
|
+
lines++;
|
|
38794
|
+
i++;
|
|
38795
|
+
} else {
|
|
38796
|
+
lines++;
|
|
38797
|
+
}
|
|
38798
|
+
}
|
|
38799
|
+
bytesSinceYield++;
|
|
38800
|
+
if (bytesSinceYield >= READ_RANGE_YIELD_EVERY_BYTES) {
|
|
38801
|
+
await yieldToEventLoop();
|
|
38802
|
+
bytesSinceYield = 0;
|
|
38803
|
+
}
|
|
38804
|
+
}
|
|
38805
|
+
return lines;
|
|
38806
|
+
}
|
|
38807
|
+
async function readGitBlobLineRangeAsync(buf, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
38808
|
+
const bufSize = 64 * 1024;
|
|
38809
|
+
const decoder = new StringDecoder("utf8");
|
|
38810
|
+
let currentLine = 0;
|
|
38811
|
+
const resultLines = [];
|
|
38812
|
+
let partial2 = "";
|
|
38813
|
+
let done = false;
|
|
38814
|
+
let skipLine0Chars = typeof lineOffsetIn === "number" ? lineOffsetIn : 0;
|
|
38815
|
+
let line0CharsReturned = 0;
|
|
38816
|
+
let line0Accum = "";
|
|
38817
|
+
let bytesSinceYield = 0;
|
|
38818
|
+
let position = 0;
|
|
38819
|
+
const finish = async () => {
|
|
38820
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38821
|
+
return { content: resultLines.join("\n"), totalLines };
|
|
38822
|
+
};
|
|
38823
|
+
while (!done && position < buf.length) {
|
|
38824
|
+
const chunkEnd = Math.min(position + bufSize, buf.length);
|
|
38825
|
+
const bytesRead = chunkEnd - position;
|
|
38826
|
+
position = chunkEnd;
|
|
38827
|
+
bytesSinceYield += bytesRead;
|
|
38828
|
+
if (bytesSinceYield >= READ_RANGE_YIELD_EVERY_BYTES) {
|
|
38829
|
+
await yieldToEventLoop();
|
|
38830
|
+
bytesSinceYield = 0;
|
|
38831
|
+
}
|
|
38832
|
+
const text = partial2 + decoder.write(buf.subarray(position - bytesRead, position));
|
|
38833
|
+
partial2 = "";
|
|
38834
|
+
let lineStart = 0;
|
|
38835
|
+
for (let i = 0; i < text.length; i++) {
|
|
38836
|
+
if (text[i] === "\n") {
|
|
38837
|
+
const lineContent = (() => {
|
|
38838
|
+
let lineEnd = i;
|
|
38839
|
+
if (lineEnd > lineStart && text[lineEnd - 1] === "\r") lineEnd--;
|
|
38840
|
+
return text.slice(lineStart, lineEnd);
|
|
38841
|
+
})();
|
|
38842
|
+
if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0)) {
|
|
38843
|
+
line0Accum += lineContent;
|
|
38844
|
+
const totalLine0 = line0Accum.length;
|
|
38845
|
+
if (skipLine0Chars > 0) {
|
|
38846
|
+
if (totalLine0 <= skipLine0Chars) {
|
|
38847
|
+
skipLine0Chars -= totalLine0;
|
|
38848
|
+
line0Accum = "";
|
|
38849
|
+
currentLine++;
|
|
38850
|
+
lineStart = i + 1;
|
|
38851
|
+
if (currentLine > endLine) {
|
|
38852
|
+
done = true;
|
|
38853
|
+
break;
|
|
38854
|
+
}
|
|
38855
|
+
continue;
|
|
38856
|
+
}
|
|
38857
|
+
const from = skipLine0Chars;
|
|
38858
|
+
const take = Math.min(lineChunkSize, totalLine0 - from);
|
|
38859
|
+
resultLines.push(line0Accum.slice(from, from + take));
|
|
38860
|
+
line0CharsReturned += take;
|
|
38861
|
+
if (from + take < totalLine0) {
|
|
38862
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38863
|
+
return {
|
|
38864
|
+
content: resultLines.join("\n"),
|
|
38865
|
+
totalLines,
|
|
38866
|
+
lineOffset: lineOffsetIn + line0CharsReturned
|
|
38867
|
+
};
|
|
38868
|
+
}
|
|
38869
|
+
line0Accum = "";
|
|
38870
|
+
skipLine0Chars = 0;
|
|
38871
|
+
line0CharsReturned = 0;
|
|
38872
|
+
} else if (totalLine0 > lineChunkSize) {
|
|
38873
|
+
resultLines.push(line0Accum.slice(0, lineChunkSize));
|
|
38874
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38875
|
+
return {
|
|
38876
|
+
content: resultLines.join("\n"),
|
|
38877
|
+
totalLines,
|
|
38878
|
+
lineOffset: lineChunkSize
|
|
38879
|
+
};
|
|
38880
|
+
} else {
|
|
38881
|
+
resultLines.push(line0Accum);
|
|
38882
|
+
line0Accum = "";
|
|
38883
|
+
}
|
|
38884
|
+
} else if (currentLine >= startLine && currentLine <= endLine) {
|
|
38885
|
+
resultLines.push(lineContent);
|
|
38886
|
+
}
|
|
38887
|
+
currentLine++;
|
|
38888
|
+
lineStart = i + 1;
|
|
38889
|
+
if (currentLine > endLine) {
|
|
38890
|
+
done = true;
|
|
38891
|
+
break;
|
|
38892
|
+
}
|
|
38893
|
+
}
|
|
38894
|
+
}
|
|
38895
|
+
if (!done) {
|
|
38896
|
+
const lineContent = text.slice(lineStart);
|
|
38897
|
+
if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0)) {
|
|
38898
|
+
line0Accum += lineContent;
|
|
38899
|
+
const totalLine0 = line0Accum.length;
|
|
38900
|
+
if (skipLine0Chars > 0) {
|
|
38901
|
+
if (totalLine0 <= skipLine0Chars) {
|
|
38902
|
+
skipLine0Chars -= totalLine0;
|
|
38903
|
+
line0Accum = "";
|
|
38904
|
+
} else {
|
|
38905
|
+
const from = skipLine0Chars;
|
|
38906
|
+
const take = Math.min(lineChunkSize, totalLine0 - from);
|
|
38907
|
+
resultLines.push(line0Accum.slice(from, from + take));
|
|
38908
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38909
|
+
return {
|
|
38910
|
+
content: resultLines.join("\n"),
|
|
38911
|
+
totalLines,
|
|
38912
|
+
lineOffset: (lineOffsetIn ?? 0) + take
|
|
38913
|
+
};
|
|
38914
|
+
}
|
|
38915
|
+
} else if (totalLine0 > lineChunkSize) {
|
|
38916
|
+
resultLines.push(line0Accum.slice(0, lineChunkSize));
|
|
38917
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38918
|
+
return {
|
|
38919
|
+
content: resultLines.join("\n"),
|
|
38920
|
+
totalLines,
|
|
38921
|
+
lineOffset: lineChunkSize
|
|
38922
|
+
};
|
|
38923
|
+
}
|
|
38924
|
+
}
|
|
38925
|
+
partial2 = text.slice(lineStart);
|
|
38926
|
+
}
|
|
38927
|
+
}
|
|
38928
|
+
if (!done) {
|
|
38929
|
+
const tail = partial2 + decoder.end();
|
|
38930
|
+
if (currentLine === 0 && (startLine === 0 || lineOffsetIn !== void 0) && tail.length > 0) {
|
|
38931
|
+
line0Accum += tail.endsWith("\r") ? tail.slice(0, -1) : tail;
|
|
38932
|
+
const totalLine0 = line0Accum.length;
|
|
38933
|
+
if (skipLine0Chars > 0) {
|
|
38934
|
+
if (totalLine0 <= skipLine0Chars) {
|
|
38935
|
+
return finish();
|
|
38936
|
+
}
|
|
38937
|
+
const from = skipLine0Chars;
|
|
38938
|
+
const take = Math.min(lineChunkSize, totalLine0 - from);
|
|
38939
|
+
resultLines.push(line0Accum.slice(from, from + take));
|
|
38940
|
+
line0CharsReturned += take;
|
|
38941
|
+
if (from + take < totalLine0) {
|
|
38942
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38943
|
+
return {
|
|
38944
|
+
content: resultLines.join("\n"),
|
|
38945
|
+
totalLines,
|
|
38946
|
+
lineOffset: (lineOffsetIn ?? 0) + line0CharsReturned
|
|
38947
|
+
};
|
|
38948
|
+
}
|
|
38949
|
+
} else if (totalLine0 > lineChunkSize) {
|
|
38950
|
+
resultLines.push(line0Accum.slice(0, lineChunkSize));
|
|
38951
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38952
|
+
return {
|
|
38953
|
+
content: resultLines.join("\n"),
|
|
38954
|
+
totalLines,
|
|
38955
|
+
lineOffset: lineChunkSize
|
|
38956
|
+
};
|
|
38957
|
+
} else {
|
|
38958
|
+
resultLines.push(line0Accum);
|
|
38959
|
+
}
|
|
38960
|
+
} else if (tail.length > 0 && currentLine >= startLine && currentLine <= endLine) {
|
|
38961
|
+
resultLines.push(tail.endsWith("\r") ? tail.slice(0, -1) : tail);
|
|
38962
|
+
}
|
|
38963
|
+
}
|
|
38964
|
+
return finish();
|
|
38965
|
+
}
|
|
38966
|
+
async function decodeGitBlobUtf8Async(buf) {
|
|
38967
|
+
await yieldToEventLoop();
|
|
38968
|
+
const text = buf.toString("utf8");
|
|
38969
|
+
await yieldToEventLoop();
|
|
38970
|
+
return text;
|
|
38971
|
+
}
|
|
38972
|
+
async function readGitBlobUtf8FullAsync(buf) {
|
|
38973
|
+
const text = await decodeGitBlobUtf8Async(buf);
|
|
38974
|
+
const totalLines = await countGitBlobLinesAsync(buf);
|
|
38975
|
+
return { content: text, totalLines };
|
|
38976
|
+
}
|
|
38977
|
+
|
|
38978
|
+
// src/git/tree/file/index.ts
|
|
38979
|
+
async function readGitTreeFileAsync(repoAbsPath, branch, relativePath, startLine, endLine, lineOffset, lineChunkSize = LINE_CHUNK_SIZE, encoding = "utf8") {
|
|
38980
|
+
await yieldToEventLoop();
|
|
38981
|
+
const branchRef = branch.trim();
|
|
38982
|
+
if (!branchRef) return { error: "branch required" };
|
|
38983
|
+
const rel = relativePath.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
38984
|
+
if (!rel || rel === ".") return { error: "file path required" };
|
|
38985
|
+
const blobRef = await gitBlobRef(repoAbsPath, branchRef, rel);
|
|
38986
|
+
if (!blobRef) return { error: "Branch not found" };
|
|
38987
|
+
const hasRange = typeof startLine === "number" && typeof endLine === "number";
|
|
38988
|
+
try {
|
|
38989
|
+
if (encoding === "base64") {
|
|
38990
|
+
if (hasRange) return { error: "base64 encoding requires a full file read (no line range)" };
|
|
38991
|
+
const buf2 = await cliSimpleGit(repoAbsPath).showBuffer([blobRef]);
|
|
38992
|
+
await yieldToEventLoop();
|
|
38993
|
+
return {
|
|
38994
|
+
content: buf2.toString("base64"),
|
|
38995
|
+
size: buf2.length,
|
|
38996
|
+
mimeType: guessMimeType(rel)
|
|
38997
|
+
};
|
|
38998
|
+
}
|
|
38999
|
+
const buf = await cliSimpleGit(repoAbsPath).showBuffer([blobRef]);
|
|
39000
|
+
await yieldToEventLoop();
|
|
39001
|
+
const size = buf.length;
|
|
39002
|
+
if (isBinaryBuffer(buf)) {
|
|
39003
|
+
return { error: "Binary file cannot be displayed as text" };
|
|
39004
|
+
}
|
|
39005
|
+
if (hasRange) {
|
|
39006
|
+
const ranged = await readGitBlobLineRangeAsync(buf, startLine, endLine, lineOffset, lineChunkSize);
|
|
39007
|
+
return {
|
|
39008
|
+
content: ranged.content,
|
|
39009
|
+
totalLines: ranged.totalLines,
|
|
39010
|
+
size,
|
|
39011
|
+
...ranged.lineOffset != null ? { lineOffset: ranged.lineOffset } : {}
|
|
39012
|
+
};
|
|
39013
|
+
}
|
|
39014
|
+
const full = await readGitBlobUtf8FullAsync(buf);
|
|
39015
|
+
return { content: full.content, totalLines: full.totalLines, size, mimeType: guessMimeType(rel) };
|
|
39016
|
+
} catch (err) {
|
|
39017
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
39018
|
+
if (/does not exist|bad revision|exists on disk, but not in/i.test(message)) {
|
|
39019
|
+
return { error: "File not found in branch" };
|
|
39020
|
+
}
|
|
39021
|
+
return { error: message };
|
|
39022
|
+
}
|
|
39023
|
+
}
|
|
39024
|
+
|
|
39025
|
+
// src/files/browser/send-file-browser-message.ts
|
|
39026
|
+
function sendFileBrowserMessage(socket, e2ee, payload) {
|
|
39027
|
+
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
|
|
39028
|
+
}
|
|
39029
|
+
|
|
39030
|
+
// src/files/browser/handle-file-browser-list.ts
|
|
39031
|
+
async function handleFileBrowserList(socket, e2ee, id, reqPath, sessionParentPath, gitScope) {
|
|
39032
|
+
const result = gitScope ? await listGitTreeDirAsync(gitScope.repoAbsPath, gitScope.branch, reqPath) : await listDirAsync(reqPath, sessionParentPath);
|
|
39033
|
+
if ("error" in result) {
|
|
39034
|
+
sendWsMessage(socket, { type: "file_browser_response", id, error: result.error });
|
|
39035
|
+
return;
|
|
39036
|
+
}
|
|
39037
|
+
sendFileBrowserMessage(socket, e2ee, { type: "file_browser_response", id, entries: result.entries });
|
|
39038
|
+
if (!gitScope && (reqPath === "." || reqPath === "")) {
|
|
39039
|
+
triggerFileIndexBuild(sessionParentPath);
|
|
39040
|
+
}
|
|
39041
|
+
}
|
|
39042
|
+
|
|
38595
39043
|
// src/files/read-file/resolve-file-path.ts
|
|
38596
39044
|
import fs40 from "node:fs";
|
|
38597
39045
|
async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
@@ -38614,13 +39062,13 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
38614
39062
|
|
|
38615
39063
|
// src/files/read-file/read-file-range-async.ts
|
|
38616
39064
|
import fs41 from "node:fs";
|
|
38617
|
-
import { StringDecoder } from "node:string_decoder";
|
|
39065
|
+
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
38618
39066
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
38619
39067
|
const fileSize = (await fs41.promises.stat(filePath)).size;
|
|
38620
39068
|
const fd = await fs41.promises.open(filePath, "r");
|
|
38621
39069
|
const bufSize = 64 * 1024;
|
|
38622
39070
|
const buf = Buffer.alloc(bufSize);
|
|
38623
|
-
const decoder = new
|
|
39071
|
+
const decoder = new StringDecoder2("utf8");
|
|
38624
39072
|
let currentLine = 0;
|
|
38625
39073
|
const resultLines = [];
|
|
38626
39074
|
let partial2 = "";
|
|
@@ -38814,37 +39262,6 @@ async function readFileFullAsync(filePath) {
|
|
|
38814
39262
|
return { content: raw, totalLines: lines.length, size };
|
|
38815
39263
|
}
|
|
38816
39264
|
|
|
38817
|
-
// src/files/read-file/guess-mime-type.ts
|
|
38818
|
-
var MIME_BY_EXT = {
|
|
38819
|
-
png: "image/png",
|
|
38820
|
-
jpg: "image/jpeg",
|
|
38821
|
-
jpeg: "image/jpeg",
|
|
38822
|
-
gif: "image/gif",
|
|
38823
|
-
bmp: "image/bmp",
|
|
38824
|
-
ico: "image/x-icon",
|
|
38825
|
-
webp: "image/webp",
|
|
38826
|
-
avif: "image/avif",
|
|
38827
|
-
svg: "image/svg+xml",
|
|
38828
|
-
pdf: "application/pdf",
|
|
38829
|
-
json: "application/json",
|
|
38830
|
-
html: "text/html",
|
|
38831
|
-
htm: "text/html",
|
|
38832
|
-
css: "text/css",
|
|
38833
|
-
js: "text/javascript",
|
|
38834
|
-
mjs: "text/javascript",
|
|
38835
|
-
ts: "text/typescript",
|
|
38836
|
-
txt: "text/plain",
|
|
38837
|
-
md: "text/markdown",
|
|
38838
|
-
xml: "application/xml",
|
|
38839
|
-
zip: "application/zip",
|
|
38840
|
-
gz: "application/gzip",
|
|
38841
|
-
wasm: "application/wasm"
|
|
38842
|
-
};
|
|
38843
|
-
function guessMimeType(filePath) {
|
|
38844
|
-
const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
|
|
38845
|
-
return MIME_BY_EXT[ext] ?? "application/octet-stream";
|
|
38846
|
-
}
|
|
38847
|
-
|
|
38848
39265
|
// src/files/read-file/read-file-binary-full-async.ts
|
|
38849
39266
|
async function readFileBinaryFullAsync(filePath) {
|
|
38850
39267
|
const { buffer, size } = await readFileBufferFullAsync(filePath);
|
|
@@ -38878,104 +39295,72 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
38878
39295
|
}
|
|
38879
39296
|
}
|
|
38880
39297
|
|
|
38881
|
-
// src/files/
|
|
38882
|
-
async function
|
|
38883
|
-
const
|
|
38884
|
-
|
|
38885
|
-
|
|
38886
|
-
|
|
38887
|
-
|
|
39298
|
+
// src/files/browser/handle-file-browser-read.ts
|
|
39299
|
+
async function handleFileBrowserRead(socket, e2ee, msg, reqPath, sessionParentPath, gitScope) {
|
|
39300
|
+
const startLine = typeof msg.startLine === "number" ? msg.startLine : void 0;
|
|
39301
|
+
const endLine = typeof msg.endLine === "number" ? msg.endLine : void 0;
|
|
39302
|
+
const lineOffset = typeof msg.lineOffset === "number" ? msg.lineOffset : void 0;
|
|
39303
|
+
const lineChunkSize = typeof msg.lineChunkSize === "number" ? msg.lineChunkSize : void 0;
|
|
39304
|
+
const encoding = msg.encoding === "base64" ? "base64" : "utf8";
|
|
39305
|
+
const result = gitScope ? await readGitTreeFileAsync(
|
|
39306
|
+
gitScope.repoAbsPath,
|
|
39307
|
+
gitScope.branch,
|
|
39308
|
+
reqPath,
|
|
39309
|
+
startLine,
|
|
39310
|
+
endLine,
|
|
39311
|
+
lineOffset,
|
|
39312
|
+
lineChunkSize,
|
|
39313
|
+
encoding
|
|
39314
|
+
) : await readFileAsync(
|
|
39315
|
+
reqPath,
|
|
39316
|
+
startLine,
|
|
39317
|
+
endLine,
|
|
39318
|
+
lineOffset,
|
|
39319
|
+
lineChunkSize,
|
|
39320
|
+
sessionParentPath,
|
|
39321
|
+
encoding
|
|
39322
|
+
);
|
|
39323
|
+
if ("error" in result) {
|
|
39324
|
+
sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
|
|
39325
|
+
return;
|
|
38888
39326
|
}
|
|
38889
|
-
|
|
39327
|
+
const payload = {
|
|
39328
|
+
type: "file_browser_response",
|
|
39329
|
+
id: msg.id,
|
|
39330
|
+
content: result.content,
|
|
39331
|
+
totalLines: result.totalLines,
|
|
39332
|
+
size: result.size
|
|
39333
|
+
};
|
|
39334
|
+
if (result.lineOffset != null) payload.lineOffset = result.lineOffset;
|
|
39335
|
+
if (result.mimeType != null) payload.mimeType = result.mimeType;
|
|
39336
|
+
if (result.resolvedPath != null) payload.resolvedPath = result.resolvedPath;
|
|
39337
|
+
sendFileBrowserMessage(socket, e2ee, payload);
|
|
38890
39338
|
}
|
|
38891
39339
|
|
|
38892
|
-
// src/files/
|
|
38893
|
-
|
|
38894
|
-
|
|
38895
|
-
|
|
38896
|
-
|
|
38897
|
-
|
|
38898
|
-
|
|
38899
|
-
const sessionParentPath = path54.resolve(
|
|
38900
|
-
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
38901
|
-
);
|
|
38902
|
-
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
38903
|
-
const payload2 = {
|
|
38904
|
-
type: "file_browser_search_response",
|
|
38905
|
-
id: msg.id,
|
|
38906
|
-
paths: [],
|
|
38907
|
-
indexReady: false
|
|
38908
|
-
};
|
|
38909
|
-
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload2, ["paths"]) : payload2);
|
|
38910
|
-
return;
|
|
38911
|
-
}
|
|
38912
|
-
const results = await searchBridgeFilePathsAsync(sessionParentPath, q, SEARCH_LIMIT);
|
|
38913
|
-
const payload = {
|
|
38914
|
-
type: "file_browser_search_response",
|
|
38915
|
-
id: msg.id,
|
|
38916
|
-
paths: results,
|
|
38917
|
-
indexReady: true
|
|
38918
|
-
};
|
|
38919
|
-
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["paths"]) : payload);
|
|
38920
|
-
})();
|
|
38921
|
-
}
|
|
38922
|
-
function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
|
|
38923
|
-
setImmediate(() => {
|
|
38924
|
-
void ensureFileIndexAsync(sessionParentPath).catch((e) => {
|
|
38925
|
-
console.error("[file-index] Background build failed:", e);
|
|
38926
|
-
});
|
|
38927
|
-
});
|
|
39340
|
+
// src/files/browser/resolve-git-branch-scope.ts
|
|
39341
|
+
function resolveGitBranchScope(msg) {
|
|
39342
|
+
const gitBranchScope = msg.source === "git_branch" && typeof msg.repoRelPath === "string" && typeof msg.branch === "string" && msg.branch.trim().length > 0;
|
|
39343
|
+
if (!gitBranchScope) return null;
|
|
39344
|
+
const repoAbsPath = resolveRepoAbsPathFromBridge(msg.repoRelPath);
|
|
39345
|
+
if (!repoAbsPath) return null;
|
|
39346
|
+
return { repoAbsPath, branch: msg.branch.trim() };
|
|
38928
39347
|
}
|
|
38929
39348
|
|
|
38930
|
-
// src/files/
|
|
38931
|
-
function sendFileBrowserMessage(socket, e2ee, payload) {
|
|
38932
|
-
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
|
|
38933
|
-
}
|
|
39349
|
+
// src/files/browser/index.ts
|
|
38934
39350
|
function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
38935
39351
|
void (async () => {
|
|
38936
39352
|
const reqPath = msg.path.replace(/^\/+/, "") || ".";
|
|
38937
39353
|
const op = msg.op === "read" ? "read" : "list";
|
|
38938
39354
|
const sessionParentPath = sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : void 0;
|
|
39355
|
+
const gitScope = resolveGitBranchScope(msg);
|
|
39356
|
+
if (msg.source === "git_branch" && typeof msg.repoRelPath === "string" && typeof msg.branch === "string" && msg.branch.trim().length > 0 && !gitScope) {
|
|
39357
|
+
sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: "Invalid repository path" });
|
|
39358
|
+
return;
|
|
39359
|
+
}
|
|
38939
39360
|
if (op === "list") {
|
|
38940
|
-
|
|
38941
|
-
if ("error" in result) {
|
|
38942
|
-
sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
|
|
38943
|
-
} else {
|
|
38944
|
-
sendFileBrowserMessage(socket, e2ee, { type: "file_browser_response", id: msg.id, entries: result.entries });
|
|
38945
|
-
if (reqPath === "." || reqPath === "") {
|
|
38946
|
-
triggerFileIndexBuild(sessionParentPath);
|
|
38947
|
-
}
|
|
38948
|
-
}
|
|
39361
|
+
await handleFileBrowserList(socket, e2ee, msg.id, reqPath, sessionParentPath, gitScope);
|
|
38949
39362
|
} else {
|
|
38950
|
-
|
|
38951
|
-
const endLine = typeof msg.endLine === "number" ? msg.endLine : void 0;
|
|
38952
|
-
const lineOffset = typeof msg.lineOffset === "number" ? msg.lineOffset : void 0;
|
|
38953
|
-
const lineChunkSize = typeof msg.lineChunkSize === "number" ? msg.lineChunkSize : void 0;
|
|
38954
|
-
const encoding = msg.encoding === "base64" ? "base64" : "utf8";
|
|
38955
|
-
const result = await readFileAsync(
|
|
38956
|
-
reqPath,
|
|
38957
|
-
startLine,
|
|
38958
|
-
endLine,
|
|
38959
|
-
lineOffset,
|
|
38960
|
-
lineChunkSize,
|
|
38961
|
-
sessionParentPath,
|
|
38962
|
-
encoding
|
|
38963
|
-
);
|
|
38964
|
-
if ("error" in result) {
|
|
38965
|
-
sendWsMessage(socket, { type: "file_browser_response", id: msg.id, error: result.error });
|
|
38966
|
-
} else {
|
|
38967
|
-
const payload = {
|
|
38968
|
-
type: "file_browser_response",
|
|
38969
|
-
id: msg.id,
|
|
38970
|
-
content: result.content,
|
|
38971
|
-
totalLines: result.totalLines,
|
|
38972
|
-
size: result.size
|
|
38973
|
-
};
|
|
38974
|
-
if (result.lineOffset != null) payload.lineOffset = result.lineOffset;
|
|
38975
|
-
if (result.mimeType != null) payload.mimeType = result.mimeType;
|
|
38976
|
-
if (result.resolvedPath != null) payload.resolvedPath = result.resolvedPath;
|
|
38977
|
-
sendFileBrowserMessage(socket, e2ee, payload);
|
|
38978
|
-
}
|
|
39363
|
+
await handleFileBrowserRead(socket, e2ee, msg, reqPath, sessionParentPath, gitScope);
|
|
38979
39364
|
}
|
|
38980
39365
|
})();
|
|
38981
39366
|
}
|
|
@@ -38985,12 +39370,7 @@ function handleFileBrowserRequestMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
38985
39370
|
if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
|
|
38986
39371
|
const socket = getWs();
|
|
38987
39372
|
if (!socket) return;
|
|
38988
|
-
handleFileBrowserRequest(
|
|
38989
|
-
msg,
|
|
38990
|
-
socket,
|
|
38991
|
-
e2ee,
|
|
38992
|
-
sessionWorktreeManager
|
|
38993
|
-
);
|
|
39373
|
+
handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager);
|
|
38994
39374
|
}
|
|
38995
39375
|
function handleFileBrowserSearchMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
|
|
38996
39376
|
if (typeof msg.id !== "string") return;
|
|
@@ -39025,7 +39405,7 @@ function isValidRemoteSkillInstallItem(item) {
|
|
|
39025
39405
|
|
|
39026
39406
|
// src/skills/install/install-remote-skills-async.ts
|
|
39027
39407
|
import fs43 from "node:fs";
|
|
39028
|
-
import
|
|
39408
|
+
import path56 from "node:path";
|
|
39029
39409
|
|
|
39030
39410
|
// src/skills/install/constants.ts
|
|
39031
39411
|
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
@@ -39036,8 +39416,8 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
|
39036
39416
|
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
39037
39417
|
await yieldToEventLoop();
|
|
39038
39418
|
}
|
|
39039
|
-
const dest =
|
|
39040
|
-
await fs43.promises.mkdir(
|
|
39419
|
+
const dest = path56.join(skillDir, f.path);
|
|
39420
|
+
await fs43.promises.mkdir(path56.dirname(dest), { recursive: true });
|
|
39041
39421
|
if (f.text !== void 0) {
|
|
39042
39422
|
await fs43.promises.writeFile(dest, f.text, "utf8");
|
|
39043
39423
|
} else if (f.base64) {
|
|
@@ -39053,7 +39433,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
|
39053
39433
|
try {
|
|
39054
39434
|
for (const item of items) {
|
|
39055
39435
|
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
39056
|
-
const skillDir =
|
|
39436
|
+
const skillDir = path56.join(cwd, targetDir, item.skillName);
|
|
39057
39437
|
for (const f of item.files) {
|
|
39058
39438
|
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
39059
39439
|
}
|
|
@@ -39392,7 +39772,7 @@ var handleDevServersConfig = (msg, deps) => {
|
|
|
39392
39772
|
};
|
|
39393
39773
|
|
|
39394
39774
|
// src/git/bridge-git-context.ts
|
|
39395
|
-
import * as
|
|
39775
|
+
import * as path57 from "node:path";
|
|
39396
39776
|
|
|
39397
39777
|
// src/git/branches/get-current-branch.ts
|
|
39398
39778
|
async function getCurrentBranch(repoPath) {
|
|
@@ -39442,12 +39822,12 @@ async function listRepoBranchRefs(repoPath) {
|
|
|
39442
39822
|
// src/git/bridge-git-context.ts
|
|
39443
39823
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
39444
39824
|
if (relPath === "." || relPath === "") {
|
|
39445
|
-
return
|
|
39825
|
+
return path57.basename(path57.resolve(bridgeRoot)) || "repo";
|
|
39446
39826
|
}
|
|
39447
|
-
return
|
|
39827
|
+
return path57.basename(relPath) || relPath;
|
|
39448
39828
|
}
|
|
39449
39829
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
39450
|
-
const root =
|
|
39830
|
+
const root = path57.resolve(bridgeRoot);
|
|
39451
39831
|
if (await isGitRepoDirectory(root)) {
|
|
39452
39832
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
39453
39833
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -39455,19 +39835,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
39455
39835
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
39456
39836
|
const byPath = /* @__PURE__ */ new Map();
|
|
39457
39837
|
for (const repo of [...deep, ...shallow]) {
|
|
39458
|
-
byPath.set(
|
|
39838
|
+
byPath.set(path57.resolve(repo.absolutePath), repo);
|
|
39459
39839
|
}
|
|
39460
39840
|
return [...byPath.values()];
|
|
39461
39841
|
}
|
|
39462
39842
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
39463
|
-
const bridgeResolved =
|
|
39843
|
+
const bridgeResolved = path57.resolve(bridgeRoot);
|
|
39464
39844
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
39465
39845
|
const rows = [];
|
|
39466
39846
|
for (let i = 0; i < repos.length; i++) {
|
|
39467
39847
|
if (i > 0) await yieldToEventLoop();
|
|
39468
39848
|
const repo = repos[i];
|
|
39469
|
-
let rel =
|
|
39470
|
-
if (rel.startsWith("..") ||
|
|
39849
|
+
let rel = path57.relative(bridgeResolved, repo.absolutePath);
|
|
39850
|
+
if (rel.startsWith("..") || path57.isAbsolute(rel)) continue;
|
|
39471
39851
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
39472
39852
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
39473
39853
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -39482,11 +39862,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
39482
39862
|
return rows;
|
|
39483
39863
|
}
|
|
39484
39864
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
39485
|
-
const bridgeResolved =
|
|
39865
|
+
const bridgeResolved = path57.resolve(bridgeRoot);
|
|
39486
39866
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
39487
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
39488
|
-
const resolved =
|
|
39489
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
39867
|
+
const repoPath = rel === "" ? bridgeResolved : path57.join(bridgeResolved, rel);
|
|
39868
|
+
const resolved = path57.resolve(repoPath);
|
|
39869
|
+
if (!resolved.startsWith(bridgeResolved + path57.sep) && resolved !== bridgeResolved) {
|
|
39490
39870
|
return [];
|
|
39491
39871
|
}
|
|
39492
39872
|
return listRepoBranchRefs(resolved);
|
|
@@ -40070,10 +40450,10 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
|
|
|
40070
40450
|
}
|
|
40071
40451
|
|
|
40072
40452
|
// src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
40073
|
-
import * as
|
|
40453
|
+
import * as path59 from "node:path";
|
|
40074
40454
|
|
|
40075
40455
|
// src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
40076
|
-
import * as
|
|
40456
|
+
import * as path58 from "node:path";
|
|
40077
40457
|
async function probeOneAgentTypeForCapabilities(params) {
|
|
40078
40458
|
const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
|
|
40079
40459
|
const canContinue = () => shouldContinue?.() !== false;
|
|
@@ -40111,7 +40491,7 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
40111
40491
|
if (!canContinue()) return false;
|
|
40112
40492
|
handle = await resolved.createClient({
|
|
40113
40493
|
command: resolved.command,
|
|
40114
|
-
cwd:
|
|
40494
|
+
cwd: path58.resolve(cwd),
|
|
40115
40495
|
backendAgentType: agentType,
|
|
40116
40496
|
sessionMode: "agent",
|
|
40117
40497
|
persistedAcpSessionId: null,
|
|
@@ -40189,7 +40569,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
40189
40569
|
const { workspaceId, log: log2, getWs } = params;
|
|
40190
40570
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
40191
40571
|
if (!isCurrent()) return;
|
|
40192
|
-
const cwd =
|
|
40572
|
+
const cwd = path59.resolve(getBridgeRoot());
|
|
40193
40573
|
async function sendBatchFromCache() {
|
|
40194
40574
|
if (!isCurrent()) return;
|
|
40195
40575
|
const socket = getWs();
|
|
@@ -40535,18 +40915,18 @@ import * as http from "node:http";
|
|
|
40535
40915
|
|
|
40536
40916
|
// src/mcp/bridge-access/read-json-body.ts
|
|
40537
40917
|
function readJsonBody(req) {
|
|
40538
|
-
return new Promise((
|
|
40918
|
+
return new Promise((resolve33, reject) => {
|
|
40539
40919
|
const chunks = [];
|
|
40540
40920
|
req.on("data", (chunk) => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
|
|
40541
40921
|
req.on("end", () => {
|
|
40542
40922
|
try {
|
|
40543
40923
|
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
40544
40924
|
if (!raw) {
|
|
40545
|
-
|
|
40925
|
+
resolve33({});
|
|
40546
40926
|
return;
|
|
40547
40927
|
}
|
|
40548
40928
|
const parsed = JSON.parse(raw);
|
|
40549
|
-
|
|
40929
|
+
resolve33(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
|
|
40550
40930
|
} catch (e) {
|
|
40551
40931
|
reject(e);
|
|
40552
40932
|
}
|
|
@@ -40604,7 +40984,7 @@ function createBridgeAccessRequestHandler(registry2) {
|
|
|
40604
40984
|
// src/mcp/bridge-access/start-server.ts
|
|
40605
40985
|
function startBridgeAccessServer(registry2) {
|
|
40606
40986
|
const server = http.createServer(createBridgeAccessRequestHandler(registry2));
|
|
40607
|
-
return new Promise((
|
|
40987
|
+
return new Promise((resolve33, reject) => {
|
|
40608
40988
|
server.once("error", reject);
|
|
40609
40989
|
server.listen(0, "127.0.0.1", () => {
|
|
40610
40990
|
const addr = server.address();
|
|
@@ -40612,7 +40992,7 @@ function startBridgeAccessServer(registry2) {
|
|
|
40612
40992
|
reject(new Error("Bridge access server did not bind"));
|
|
40613
40993
|
return;
|
|
40614
40994
|
}
|
|
40615
|
-
|
|
40995
|
+
resolve33({
|
|
40616
40996
|
port: addr.port,
|
|
40617
40997
|
close: () => new Promise((closeResolve, closeReject) => {
|
|
40618
40998
|
server.close((err) => err ? closeReject(err) : closeResolve());
|
|
@@ -40752,8 +41132,8 @@ async function createBridgeConnection(options) {
|
|
|
40752
41132
|
getCloudAccessToken: () => tokens.accessToken
|
|
40753
41133
|
};
|
|
40754
41134
|
const identifyReportedPaths = {
|
|
40755
|
-
bridgeRootPath:
|
|
40756
|
-
worktreesRootPath:
|
|
41135
|
+
bridgeRootPath: path60.resolve(getBridgeRoot()),
|
|
41136
|
+
worktreesRootPath: path60.resolve(worktreesRootPath)
|
|
40757
41137
|
};
|
|
40758
41138
|
const { connect } = createMainBridgeWebSocketLifecycle({
|
|
40759
41139
|
state,
|