@buildautomaton/cli 0.1.94 → 0.1.96
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 +802 -1100
- package/dist/cli.js.map +4 -4
- package/dist/index.js +768 -1064
- package/dist/index.js.map +4 -4
- package/dist/worker.js +83 -161
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -973,8 +973,8 @@ var require_command = __commonJS({
|
|
|
973
973
|
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
|
|
974
974
|
var EventEmitter2 = __require("node:events").EventEmitter;
|
|
975
975
|
var childProcess2 = __require("node:child_process");
|
|
976
|
-
var
|
|
977
|
-
var
|
|
976
|
+
var path86 = __require("node:path");
|
|
977
|
+
var fs65 = __require("node:fs");
|
|
978
978
|
var process9 = __require("node:process");
|
|
979
979
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
980
980
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1906,11 +1906,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1906
1906
|
let launchWithNode = false;
|
|
1907
1907
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1908
1908
|
function findFile(baseDir, baseName) {
|
|
1909
|
-
const localBin =
|
|
1910
|
-
if (
|
|
1911
|
-
if (sourceExt.includes(
|
|
1909
|
+
const localBin = path86.resolve(baseDir, baseName);
|
|
1910
|
+
if (fs65.existsSync(localBin)) return localBin;
|
|
1911
|
+
if (sourceExt.includes(path86.extname(baseName))) return void 0;
|
|
1912
1912
|
const foundExt = sourceExt.find(
|
|
1913
|
-
(ext) =>
|
|
1913
|
+
(ext) => fs65.existsSync(`${localBin}${ext}`)
|
|
1914
1914
|
);
|
|
1915
1915
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1916
1916
|
return void 0;
|
|
@@ -1922,21 +1922,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1922
1922
|
if (this._scriptPath) {
|
|
1923
1923
|
let resolvedScriptPath;
|
|
1924
1924
|
try {
|
|
1925
|
-
resolvedScriptPath =
|
|
1925
|
+
resolvedScriptPath = fs65.realpathSync(this._scriptPath);
|
|
1926
1926
|
} catch (err) {
|
|
1927
1927
|
resolvedScriptPath = this._scriptPath;
|
|
1928
1928
|
}
|
|
1929
|
-
executableDir =
|
|
1930
|
-
|
|
1929
|
+
executableDir = path86.resolve(
|
|
1930
|
+
path86.dirname(resolvedScriptPath),
|
|
1931
1931
|
executableDir
|
|
1932
1932
|
);
|
|
1933
1933
|
}
|
|
1934
1934
|
if (executableDir) {
|
|
1935
1935
|
let localFile = findFile(executableDir, executableFile);
|
|
1936
1936
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1937
|
-
const legacyName =
|
|
1937
|
+
const legacyName = path86.basename(
|
|
1938
1938
|
this._scriptPath,
|
|
1939
|
-
|
|
1939
|
+
path86.extname(this._scriptPath)
|
|
1940
1940
|
);
|
|
1941
1941
|
if (legacyName !== this._name) {
|
|
1942
1942
|
localFile = findFile(
|
|
@@ -1947,7 +1947,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1947
1947
|
}
|
|
1948
1948
|
executableFile = localFile || executableFile;
|
|
1949
1949
|
}
|
|
1950
|
-
launchWithNode = sourceExt.includes(
|
|
1950
|
+
launchWithNode = sourceExt.includes(path86.extname(executableFile));
|
|
1951
1951
|
let proc;
|
|
1952
1952
|
if (process9.platform !== "win32") {
|
|
1953
1953
|
if (launchWithNode) {
|
|
@@ -2787,7 +2787,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2787
2787
|
* @return {Command}
|
|
2788
2788
|
*/
|
|
2789
2789
|
nameFromFilename(filename) {
|
|
2790
|
-
this._name =
|
|
2790
|
+
this._name = path86.basename(filename, path86.extname(filename));
|
|
2791
2791
|
return this;
|
|
2792
2792
|
}
|
|
2793
2793
|
/**
|
|
@@ -2801,9 +2801,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2801
2801
|
* @param {string} [path]
|
|
2802
2802
|
* @return {(string|null|Command)}
|
|
2803
2803
|
*/
|
|
2804
|
-
executableDir(
|
|
2805
|
-
if (
|
|
2806
|
-
this._executableDir =
|
|
2804
|
+
executableDir(path87) {
|
|
2805
|
+
if (path87 === void 0) return this._executableDir;
|
|
2806
|
+
this._executableDir = path87;
|
|
2807
2807
|
return this;
|
|
2808
2808
|
}
|
|
2809
2809
|
/**
|
|
@@ -7085,10 +7085,10 @@ function mergeDefs(...defs) {
|
|
|
7085
7085
|
function cloneDef(schema) {
|
|
7086
7086
|
return mergeDefs(schema._zod.def);
|
|
7087
7087
|
}
|
|
7088
|
-
function getElementAtPath(obj,
|
|
7089
|
-
if (!
|
|
7088
|
+
function getElementAtPath(obj, path86) {
|
|
7089
|
+
if (!path86)
|
|
7090
7090
|
return obj;
|
|
7091
|
-
return
|
|
7091
|
+
return path86.reduce((acc, key) => acc?.[key], obj);
|
|
7092
7092
|
}
|
|
7093
7093
|
function promiseAllObject(promisesObj) {
|
|
7094
7094
|
const keys = Object.keys(promisesObj);
|
|
@@ -7416,11 +7416,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
7416
7416
|
}
|
|
7417
7417
|
return false;
|
|
7418
7418
|
}
|
|
7419
|
-
function prefixIssues(
|
|
7419
|
+
function prefixIssues(path86, issues) {
|
|
7420
7420
|
return issues.map((iss) => {
|
|
7421
7421
|
var _a4;
|
|
7422
7422
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
7423
|
-
iss.path.unshift(
|
|
7423
|
+
iss.path.unshift(path86);
|
|
7424
7424
|
return iss;
|
|
7425
7425
|
});
|
|
7426
7426
|
}
|
|
@@ -7637,16 +7637,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7637
7637
|
}
|
|
7638
7638
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
7639
7639
|
const fieldErrors = { _errors: [] };
|
|
7640
|
-
const processError = (error52,
|
|
7640
|
+
const processError = (error52, path86 = []) => {
|
|
7641
7641
|
for (const issue2 of error52.issues) {
|
|
7642
7642
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
7643
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
7643
|
+
issue2.errors.map((issues) => processError({ issues }, [...path86, ...issue2.path]));
|
|
7644
7644
|
} else if (issue2.code === "invalid_key") {
|
|
7645
|
-
processError({ issues: issue2.issues }, [...
|
|
7645
|
+
processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
|
|
7646
7646
|
} else if (issue2.code === "invalid_element") {
|
|
7647
|
-
processError({ issues: issue2.issues }, [...
|
|
7647
|
+
processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
|
|
7648
7648
|
} else {
|
|
7649
|
-
const fullpath = [...
|
|
7649
|
+
const fullpath = [...path86, ...issue2.path];
|
|
7650
7650
|
if (fullpath.length === 0) {
|
|
7651
7651
|
fieldErrors._errors.push(mapper(issue2));
|
|
7652
7652
|
} else {
|
|
@@ -7673,17 +7673,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7673
7673
|
}
|
|
7674
7674
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
7675
7675
|
const result = { errors: [] };
|
|
7676
|
-
const processError = (error52,
|
|
7676
|
+
const processError = (error52, path86 = []) => {
|
|
7677
7677
|
var _a4, _b;
|
|
7678
7678
|
for (const issue2 of error52.issues) {
|
|
7679
7679
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
7680
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
7680
|
+
issue2.errors.map((issues) => processError({ issues }, [...path86, ...issue2.path]));
|
|
7681
7681
|
} else if (issue2.code === "invalid_key") {
|
|
7682
|
-
processError({ issues: issue2.issues }, [...
|
|
7682
|
+
processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
|
|
7683
7683
|
} else if (issue2.code === "invalid_element") {
|
|
7684
|
-
processError({ issues: issue2.issues }, [...
|
|
7684
|
+
processError({ issues: issue2.issues }, [...path86, ...issue2.path]);
|
|
7685
7685
|
} else {
|
|
7686
|
-
const fullpath = [...
|
|
7686
|
+
const fullpath = [...path86, ...issue2.path];
|
|
7687
7687
|
if (fullpath.length === 0) {
|
|
7688
7688
|
result.errors.push(mapper(issue2));
|
|
7689
7689
|
continue;
|
|
@@ -7715,8 +7715,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
7715
7715
|
}
|
|
7716
7716
|
function toDotPath(_path) {
|
|
7717
7717
|
const segs = [];
|
|
7718
|
-
const
|
|
7719
|
-
for (const seg of
|
|
7718
|
+
const path86 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
7719
|
+
for (const seg of path86) {
|
|
7720
7720
|
if (typeof seg === "number")
|
|
7721
7721
|
segs.push(`[${seg}]`);
|
|
7722
7722
|
else if (typeof seg === "symbol")
|
|
@@ -21146,13 +21146,13 @@ function resolveRef(ref, ctx) {
|
|
|
21146
21146
|
if (!ref.startsWith("#")) {
|
|
21147
21147
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
21148
21148
|
}
|
|
21149
|
-
const
|
|
21150
|
-
if (
|
|
21149
|
+
const path86 = ref.slice(1).split("/").filter(Boolean);
|
|
21150
|
+
if (path86.length === 0) {
|
|
21151
21151
|
return ctx.rootSchema;
|
|
21152
21152
|
}
|
|
21153
21153
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
21154
|
-
if (
|
|
21155
|
-
const key =
|
|
21154
|
+
if (path86[0] === defsKey) {
|
|
21155
|
+
const key = path86[1];
|
|
21156
21156
|
if (!key || !ctx.defs[key]) {
|
|
21157
21157
|
throw new Error(`Reference not found: ${ref}`);
|
|
21158
21158
|
}
|
|
@@ -23770,7 +23770,6 @@ import os from "node:os";
|
|
|
23770
23770
|
var INDEX_WORK_YIELD_EVERY, INDEX_DIR, INDEX_HASH_LEN;
|
|
23771
23771
|
var init_constants = __esm({
|
|
23772
23772
|
"../bridge/src/files/index/constants.ts"() {
|
|
23773
|
-
"use strict";
|
|
23774
23773
|
INDEX_WORK_YIELD_EVERY = 128;
|
|
23775
23774
|
INDEX_DIR = path3.join(os.homedir(), ".buildautomaton");
|
|
23776
23775
|
INDEX_HASH_LEN = 16;
|
|
@@ -24125,6 +24124,7 @@ function isCliSqliteLockError(e) {
|
|
|
24125
24124
|
var CliSqliteInterrupted;
|
|
24126
24125
|
var init_sqlite_errors = __esm({
|
|
24127
24126
|
"../bridge/src/sqlite/sqlite-errors.ts"() {
|
|
24127
|
+
"use strict";
|
|
24128
24128
|
CliSqliteInterrupted = class extends Error {
|
|
24129
24129
|
name = "CliSqliteInterrupted";
|
|
24130
24130
|
constructor() {
|
|
@@ -24371,7 +24371,6 @@ function resetCodeNavCacheAvailabilityForTests() {
|
|
|
24371
24371
|
var initState, initPromise, CodeNavCacheUnavailableError;
|
|
24372
24372
|
var init_code_nav_cache_availability = __esm({
|
|
24373
24373
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-availability.ts"() {
|
|
24374
|
-
"use strict";
|
|
24375
24374
|
init_log();
|
|
24376
24375
|
init_in_flight();
|
|
24377
24376
|
init_sqlite_errors();
|
|
@@ -24748,7 +24747,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
24748
24747
|
join2(moduleDir, "..", sub, filename),
|
|
24749
24748
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
24750
24749
|
]);
|
|
24751
|
-
const resolved = candidates.find((
|
|
24750
|
+
const resolved = candidates.find((path86) => existsSync(path86));
|
|
24752
24751
|
if (!resolved) {
|
|
24753
24752
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
24754
24753
|
}
|
|
@@ -25137,31 +25136,18 @@ var init_cli_sqlite_paths = __esm({
|
|
|
25137
25136
|
}
|
|
25138
25137
|
});
|
|
25139
25138
|
|
|
25140
|
-
// ../bridge/src/prompt-turn-queue/paths.ts
|
|
25141
|
-
import path7 from "node:path";
|
|
25142
|
-
import os4 from "node:os";
|
|
25143
|
-
function getPromptQueuesDirectory() {
|
|
25144
|
-
const override = process.env.BUILDAMATON_PROMPT_QUEUES_DIR?.trim();
|
|
25145
|
-
if (override) return path7.resolve(override);
|
|
25146
|
-
return path7.join(os4.homedir(), ".buildautomaton", "queues");
|
|
25147
|
-
}
|
|
25148
|
-
var init_paths2 = __esm({
|
|
25149
|
-
"../bridge/src/prompt-turn-queue/paths.ts"() {
|
|
25150
|
-
}
|
|
25151
|
-
});
|
|
25152
|
-
|
|
25153
25139
|
// ../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts
|
|
25154
25140
|
import fs7 from "node:fs";
|
|
25155
|
-
import
|
|
25141
|
+
import path7 from "node:path";
|
|
25156
25142
|
function moveLegacyFileToOldVersionBackup(category, sourcePath) {
|
|
25157
|
-
const destDir =
|
|
25143
|
+
const destDir = path7.join(OLD_VERSION_DIR, category);
|
|
25158
25144
|
fs7.mkdirSync(destDir, { recursive: true });
|
|
25159
|
-
const base =
|
|
25160
|
-
let dest =
|
|
25145
|
+
const base = path7.basename(sourcePath);
|
|
25146
|
+
let dest = path7.join(destDir, base);
|
|
25161
25147
|
if (fs7.existsSync(dest)) {
|
|
25162
|
-
const ext =
|
|
25148
|
+
const ext = path7.extname(base);
|
|
25163
25149
|
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
25164
|
-
dest =
|
|
25150
|
+
dest = path7.join(destDir, `${stem}-${Date.now()}${ext}`);
|
|
25165
25151
|
}
|
|
25166
25152
|
fs7.renameSync(sourcePath, dest);
|
|
25167
25153
|
}
|
|
@@ -25170,19 +25156,19 @@ var init_archive_to_old_version = __esm({
|
|
|
25170
25156
|
"../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts"() {
|
|
25171
25157
|
"use strict";
|
|
25172
25158
|
init_constants();
|
|
25173
|
-
OLD_VERSION_DIR =
|
|
25159
|
+
OLD_VERSION_DIR = path7.join(INDEX_DIR, "old-version");
|
|
25174
25160
|
}
|
|
25175
25161
|
});
|
|
25176
25162
|
|
|
25177
25163
|
// ../bridge/src/sqlite/legacy_migration/archive-file-index-json.ts
|
|
25178
25164
|
import fs8 from "node:fs";
|
|
25179
|
-
import
|
|
25165
|
+
import path8 from "node:path";
|
|
25180
25166
|
function archiveLegacyFileIndexJsonFiles() {
|
|
25181
25167
|
try {
|
|
25182
25168
|
if (!fs8.existsSync(INDEX_DIR)) return;
|
|
25183
25169
|
for (const name of fs8.readdirSync(INDEX_DIR)) {
|
|
25184
25170
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) {
|
|
25185
|
-
const full =
|
|
25171
|
+
const full = path8.join(INDEX_DIR, name);
|
|
25186
25172
|
try {
|
|
25187
25173
|
moveLegacyFileToOldVersionBackup("file-index", full);
|
|
25188
25174
|
} catch (err) {
|
|
@@ -25204,15 +25190,15 @@ var init_archive_file_index_json = __esm({
|
|
|
25204
25190
|
|
|
25205
25191
|
// ../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts
|
|
25206
25192
|
import fs9 from "node:fs";
|
|
25207
|
-
import
|
|
25208
|
-
import
|
|
25193
|
+
import path9 from "node:path";
|
|
25194
|
+
import os4 from "node:os";
|
|
25209
25195
|
function importLegacyAgentSessionsFromDisk(db) {
|
|
25210
25196
|
try {
|
|
25211
25197
|
if (!fs9.existsSync(LEGACY_AGENT_SESSION_DIR)) return;
|
|
25212
25198
|
const names = fs9.readdirSync(LEGACY_AGENT_SESSION_DIR).filter((n) => n.endsWith(".json"));
|
|
25213
25199
|
for (const name of names) {
|
|
25214
25200
|
const sessionKey = name.slice(0, -".json".length);
|
|
25215
|
-
const full =
|
|
25201
|
+
const full = path9.join(LEGACY_AGENT_SESSION_DIR, name);
|
|
25216
25202
|
let raw;
|
|
25217
25203
|
try {
|
|
25218
25204
|
raw = fs9.readFileSync(full, "utf8");
|
|
@@ -25249,89 +25235,27 @@ var init_import_agent_sessions_from_disk = __esm({
|
|
|
25249
25235
|
"../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts"() {
|
|
25250
25236
|
"use strict";
|
|
25251
25237
|
init_archive_to_old_version();
|
|
25252
|
-
LEGACY_AGENT_SESSION_DIR =
|
|
25253
|
-
}
|
|
25254
|
-
});
|
|
25255
|
-
|
|
25256
|
-
// ../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts
|
|
25257
|
-
function parsePersistedQueueFromJson(raw) {
|
|
25258
|
-
try {
|
|
25259
|
-
const o = JSON.parse(raw);
|
|
25260
|
-
const queueKey = typeof o.queueKey === "string" ? o.queueKey : typeof o.queueKeyHash === "string" ? o.queueKeyHash : null;
|
|
25261
|
-
if (!queueKey || typeof o.updatedAt !== "string" || !Array.isArray(o.turns)) return null;
|
|
25262
|
-
return { queueKey, updatedAt: o.updatedAt, turns: o.turns };
|
|
25263
|
-
} catch {
|
|
25264
|
-
return null;
|
|
25265
|
-
}
|
|
25266
|
-
}
|
|
25267
|
-
var init_parse_persisted_queue_json = __esm({
|
|
25268
|
-
"../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts"() {
|
|
25269
|
-
"use strict";
|
|
25270
|
-
}
|
|
25271
|
-
});
|
|
25272
|
-
|
|
25273
|
-
// ../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts
|
|
25274
|
-
import fs10 from "node:fs";
|
|
25275
|
-
import path11 from "node:path";
|
|
25276
|
-
function importLegacyPromptQueuesFromDisk(db) {
|
|
25277
|
-
try {
|
|
25278
|
-
const dir = getPromptQueuesDirectory();
|
|
25279
|
-
if (!fs10.existsSync(dir)) return;
|
|
25280
|
-
for (const name of fs10.readdirSync(dir)) {
|
|
25281
|
-
if (!name.endsWith(".json")) continue;
|
|
25282
|
-
const full = path11.join(dir, name);
|
|
25283
|
-
let raw;
|
|
25284
|
-
try {
|
|
25285
|
-
raw = fs10.readFileSync(full, "utf8");
|
|
25286
|
-
} catch {
|
|
25287
|
-
continue;
|
|
25288
|
-
}
|
|
25289
|
-
const file2 = parsePersistedQueueFromJson(raw);
|
|
25290
|
-
if (!file2) continue;
|
|
25291
|
-
db.run(
|
|
25292
|
-
`INSERT OR REPLACE INTO prompt_queue (queue_key, updated_at, turns_json) VALUES (?, ?, ?)`,
|
|
25293
|
-
[file2.queueKey, file2.updatedAt, JSON.stringify(file2.turns)]
|
|
25294
|
-
);
|
|
25295
|
-
try {
|
|
25296
|
-
moveLegacyFileToOldVersionBackup("queues", full);
|
|
25297
|
-
} catch {
|
|
25298
|
-
}
|
|
25299
|
-
}
|
|
25300
|
-
} catch (e) {
|
|
25301
|
-
console.error("[cli-sqlite] legacy import: prompt queues from disk failed", e);
|
|
25302
|
-
}
|
|
25303
|
-
}
|
|
25304
|
-
var init_import_prompt_queues_from_disk = __esm({
|
|
25305
|
-
"../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts"() {
|
|
25306
|
-
"use strict";
|
|
25307
|
-
init_paths2();
|
|
25308
|
-
init_archive_to_old_version();
|
|
25309
|
-
init_parse_persisted_queue_json();
|
|
25238
|
+
LEGACY_AGENT_SESSION_DIR = path9.join(os4.homedir(), ".buildautomaton", "agent-sessions");
|
|
25310
25239
|
}
|
|
25311
25240
|
});
|
|
25312
25241
|
|
|
25313
25242
|
// ../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts
|
|
25314
|
-
import
|
|
25243
|
+
import fs10 from "node:fs";
|
|
25315
25244
|
function legacyCliDiskMigrationIsPending() {
|
|
25316
25245
|
try {
|
|
25317
|
-
if (
|
|
25318
|
-
for (const name of
|
|
25246
|
+
if (fs10.existsSync(INDEX_DIR)) {
|
|
25247
|
+
for (const name of fs10.readdirSync(INDEX_DIR)) {
|
|
25319
25248
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) return true;
|
|
25320
25249
|
}
|
|
25321
25250
|
}
|
|
25322
25251
|
} catch {
|
|
25323
25252
|
}
|
|
25324
25253
|
try {
|
|
25325
|
-
if (
|
|
25326
|
-
if (
|
|
25254
|
+
if (fs10.existsSync(LEGACY_AGENT_SESSION_DIR)) {
|
|
25255
|
+
if (fs10.readdirSync(LEGACY_AGENT_SESSION_DIR).some((n) => n.endsWith(".json"))) return true;
|
|
25327
25256
|
}
|
|
25328
25257
|
} catch {
|
|
25329
25258
|
}
|
|
25330
|
-
try {
|
|
25331
|
-
const dir = getPromptQueuesDirectory();
|
|
25332
|
-
if (fs11.existsSync(dir) && fs11.readdirSync(dir).some((n) => n.endsWith(".json"))) return true;
|
|
25333
|
-
} catch {
|
|
25334
|
-
}
|
|
25335
25259
|
return false;
|
|
25336
25260
|
}
|
|
25337
25261
|
function importCliSqliteLegacyDiskData(db, log2) {
|
|
@@ -25341,7 +25265,6 @@ function importCliSqliteLegacyDiskData(db, log2) {
|
|
|
25341
25265
|
}
|
|
25342
25266
|
archiveLegacyFileIndexJsonFiles();
|
|
25343
25267
|
importLegacyAgentSessionsFromDisk(db);
|
|
25344
|
-
importLegacyPromptQueuesFromDisk(db);
|
|
25345
25268
|
if (pending2 && log2) {
|
|
25346
25269
|
log2("Legacy on-disk CLI data migration finished.");
|
|
25347
25270
|
}
|
|
@@ -25350,10 +25273,8 @@ var init_import_cli_legacy_disk_data = __esm({
|
|
|
25350
25273
|
"../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts"() {
|
|
25351
25274
|
"use strict";
|
|
25352
25275
|
init_constants();
|
|
25353
|
-
init_paths2();
|
|
25354
25276
|
init_archive_file_index_json();
|
|
25355
25277
|
init_import_agent_sessions_from_disk();
|
|
25356
|
-
init_import_prompt_queues_from_disk();
|
|
25357
25278
|
}
|
|
25358
25279
|
});
|
|
25359
25280
|
|
|
@@ -25463,15 +25384,15 @@ var init_cli_database = __esm({
|
|
|
25463
25384
|
});
|
|
25464
25385
|
|
|
25465
25386
|
// ../bridge/src/files/index/walk-workspace-tree.ts
|
|
25466
|
-
import
|
|
25467
|
-
import
|
|
25387
|
+
import fs11 from "node:fs";
|
|
25388
|
+
import path10 from "node:path";
|
|
25468
25389
|
function shouldSkipWorkspaceWalkEntry(name) {
|
|
25469
25390
|
return DEPENDENCY_INSTALL_DIR_NAMES.has(name);
|
|
25470
25391
|
}
|
|
25471
25392
|
async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
25472
25393
|
let names;
|
|
25473
25394
|
try {
|
|
25474
|
-
names = await
|
|
25395
|
+
names = await fs11.promises.readdir(dir);
|
|
25475
25396
|
} catch {
|
|
25476
25397
|
return;
|
|
25477
25398
|
}
|
|
@@ -25486,14 +25407,14 @@ async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
|
25486
25407
|
await yieldUntilFileBrowserReadsIdle();
|
|
25487
25408
|
}
|
|
25488
25409
|
state.n++;
|
|
25489
|
-
const full =
|
|
25410
|
+
const full = path10.join(dir, name);
|
|
25490
25411
|
let stat3;
|
|
25491
25412
|
try {
|
|
25492
|
-
stat3 = await
|
|
25413
|
+
stat3 = await fs11.promises.stat(full);
|
|
25493
25414
|
} catch {
|
|
25494
25415
|
continue;
|
|
25495
25416
|
}
|
|
25496
|
-
const relative6 =
|
|
25417
|
+
const relative6 = path10.relative(baseDir, full).replace(/\\/g, "/");
|
|
25497
25418
|
if (stat3.isDirectory()) {
|
|
25498
25419
|
await walkWorkspaceTreeAsync(full, baseDir, onFile, state);
|
|
25499
25420
|
} else if (stat3.isFile()) {
|
|
@@ -25822,7 +25743,7 @@ var require_ignore = __commonJS({
|
|
|
25822
25743
|
// path matching.
|
|
25823
25744
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
25824
25745
|
// @returns {TestResult} true if a file is ignored
|
|
25825
|
-
test(
|
|
25746
|
+
test(path86, checkUnignored, mode) {
|
|
25826
25747
|
let ignored = false;
|
|
25827
25748
|
let unignored = false;
|
|
25828
25749
|
let matchedRule;
|
|
@@ -25831,7 +25752,7 @@ var require_ignore = __commonJS({
|
|
|
25831
25752
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
25832
25753
|
return;
|
|
25833
25754
|
}
|
|
25834
|
-
const matched = rule[mode].test(
|
|
25755
|
+
const matched = rule[mode].test(path86);
|
|
25835
25756
|
if (!matched) {
|
|
25836
25757
|
return;
|
|
25837
25758
|
}
|
|
@@ -25852,17 +25773,17 @@ var require_ignore = __commonJS({
|
|
|
25852
25773
|
var throwError = (message, Ctor) => {
|
|
25853
25774
|
throw new Ctor(message);
|
|
25854
25775
|
};
|
|
25855
|
-
var checkPath = (
|
|
25856
|
-
if (!isString(
|
|
25776
|
+
var checkPath = (path86, originalPath, doThrow) => {
|
|
25777
|
+
if (!isString(path86)) {
|
|
25857
25778
|
return doThrow(
|
|
25858
25779
|
`path must be a string, but got \`${originalPath}\``,
|
|
25859
25780
|
TypeError
|
|
25860
25781
|
);
|
|
25861
25782
|
}
|
|
25862
|
-
if (!
|
|
25783
|
+
if (!path86) {
|
|
25863
25784
|
return doThrow(`path must not be empty`, TypeError);
|
|
25864
25785
|
}
|
|
25865
|
-
if (checkPath.isNotRelative(
|
|
25786
|
+
if (checkPath.isNotRelative(path86)) {
|
|
25866
25787
|
const r = "`path.relative()`d";
|
|
25867
25788
|
return doThrow(
|
|
25868
25789
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -25871,7 +25792,7 @@ var require_ignore = __commonJS({
|
|
|
25871
25792
|
}
|
|
25872
25793
|
return true;
|
|
25873
25794
|
};
|
|
25874
|
-
var isNotRelative = (
|
|
25795
|
+
var isNotRelative = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
|
|
25875
25796
|
checkPath.isNotRelative = isNotRelative;
|
|
25876
25797
|
checkPath.convert = (p) => p;
|
|
25877
25798
|
var Ignore = class {
|
|
@@ -25901,19 +25822,19 @@ var require_ignore = __commonJS({
|
|
|
25901
25822
|
}
|
|
25902
25823
|
// @returns {TestResult}
|
|
25903
25824
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
25904
|
-
const
|
|
25825
|
+
const path86 = originalPath && checkPath.convert(originalPath);
|
|
25905
25826
|
checkPath(
|
|
25906
|
-
|
|
25827
|
+
path86,
|
|
25907
25828
|
originalPath,
|
|
25908
25829
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
25909
25830
|
);
|
|
25910
|
-
return this._t(
|
|
25831
|
+
return this._t(path86, cache2, checkUnignored, slices);
|
|
25911
25832
|
}
|
|
25912
|
-
checkIgnore(
|
|
25913
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
25914
|
-
return this.test(
|
|
25833
|
+
checkIgnore(path86) {
|
|
25834
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
|
|
25835
|
+
return this.test(path86);
|
|
25915
25836
|
}
|
|
25916
|
-
const slices =
|
|
25837
|
+
const slices = path86.split(SLASH).filter(Boolean);
|
|
25917
25838
|
slices.pop();
|
|
25918
25839
|
if (slices.length) {
|
|
25919
25840
|
const parent = this._t(
|
|
@@ -25926,18 +25847,18 @@ var require_ignore = __commonJS({
|
|
|
25926
25847
|
return parent;
|
|
25927
25848
|
}
|
|
25928
25849
|
}
|
|
25929
|
-
return this._rules.test(
|
|
25850
|
+
return this._rules.test(path86, false, MODE_CHECK_IGNORE);
|
|
25930
25851
|
}
|
|
25931
|
-
_t(
|
|
25932
|
-
if (
|
|
25933
|
-
return cache2[
|
|
25852
|
+
_t(path86, cache2, checkUnignored, slices) {
|
|
25853
|
+
if (path86 in cache2) {
|
|
25854
|
+
return cache2[path86];
|
|
25934
25855
|
}
|
|
25935
25856
|
if (!slices) {
|
|
25936
|
-
slices =
|
|
25857
|
+
slices = path86.split(SLASH).filter(Boolean);
|
|
25937
25858
|
}
|
|
25938
25859
|
slices.pop();
|
|
25939
25860
|
if (!slices.length) {
|
|
25940
|
-
return cache2[
|
|
25861
|
+
return cache2[path86] = this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
25941
25862
|
}
|
|
25942
25863
|
const parent = this._t(
|
|
25943
25864
|
slices.join(SLASH) + SLASH,
|
|
@@ -25945,29 +25866,29 @@ var require_ignore = __commonJS({
|
|
|
25945
25866
|
checkUnignored,
|
|
25946
25867
|
slices
|
|
25947
25868
|
);
|
|
25948
|
-
return cache2[
|
|
25869
|
+
return cache2[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
25949
25870
|
}
|
|
25950
|
-
ignores(
|
|
25951
|
-
return this._test(
|
|
25871
|
+
ignores(path86) {
|
|
25872
|
+
return this._test(path86, this._ignoreCache, false).ignored;
|
|
25952
25873
|
}
|
|
25953
25874
|
createFilter() {
|
|
25954
|
-
return (
|
|
25875
|
+
return (path86) => !this.ignores(path86);
|
|
25955
25876
|
}
|
|
25956
25877
|
filter(paths) {
|
|
25957
25878
|
return makeArray(paths).filter(this.createFilter());
|
|
25958
25879
|
}
|
|
25959
25880
|
// @returns {TestResult}
|
|
25960
|
-
test(
|
|
25961
|
-
return this._test(
|
|
25881
|
+
test(path86) {
|
|
25882
|
+
return this._test(path86, this._testCache, true);
|
|
25962
25883
|
}
|
|
25963
25884
|
};
|
|
25964
25885
|
var factory = (options) => new Ignore(options);
|
|
25965
|
-
var isPathValid = (
|
|
25886
|
+
var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, RETURN_FALSE);
|
|
25966
25887
|
var setupWindows = () => {
|
|
25967
25888
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
25968
25889
|
checkPath.convert = makePosix;
|
|
25969
25890
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
25970
|
-
checkPath.isNotRelative = (
|
|
25891
|
+
checkPath.isNotRelative = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
|
|
25971
25892
|
};
|
|
25972
25893
|
if (
|
|
25973
25894
|
// Detect `process` so that it can run in browsers.
|
|
@@ -25983,8 +25904,8 @@ var require_ignore = __commonJS({
|
|
|
25983
25904
|
});
|
|
25984
25905
|
|
|
25985
25906
|
// ../bridge/src/code-nav/gitignore-filter.ts
|
|
25986
|
-
import
|
|
25987
|
-
import
|
|
25907
|
+
import fs12 from "node:fs";
|
|
25908
|
+
import path11 from "node:path";
|
|
25988
25909
|
function normalizeRelPath(relPath) {
|
|
25989
25910
|
return relPath.replace(/\\/g, "/");
|
|
25990
25911
|
}
|
|
@@ -25994,12 +25915,12 @@ function isUnderDir(relPath, dirRel) {
|
|
|
25994
25915
|
async function createGitignoreFilterForRelativePath(root, relPath) {
|
|
25995
25916
|
const filter = new GitignoreFilter();
|
|
25996
25917
|
await filter.enterDirectory(root, "");
|
|
25997
|
-
const dirRel = normalizeRelPath(
|
|
25918
|
+
const dirRel = normalizeRelPath(path11.dirname(relPath));
|
|
25998
25919
|
if (dirRel === "." || dirRel === "") return filter;
|
|
25999
25920
|
let abs = root;
|
|
26000
25921
|
let rel = "";
|
|
26001
25922
|
for (const segment of dirRel.split("/")) {
|
|
26002
|
-
abs =
|
|
25923
|
+
abs = path11.join(abs, segment);
|
|
26003
25924
|
rel = rel ? `${rel}/${segment}` : segment;
|
|
26004
25925
|
await filter.enterDirectory(abs, rel);
|
|
26005
25926
|
}
|
|
@@ -26021,7 +25942,7 @@ var init_gitignore_filter = __esm({
|
|
|
26021
25942
|
/** Load `.gitignore` in `absDir` and push a layer when the file exists. */
|
|
26022
25943
|
async enterDirectory(absDir, dirRel) {
|
|
26023
25944
|
try {
|
|
26024
|
-
const content = await
|
|
25945
|
+
const content = await fs12.promises.readFile(path11.join(absDir, ".gitignore"), "utf8");
|
|
26025
25946
|
this.layers.push({ dirRel, ig: (0, import_ignore.default)().add(content) });
|
|
26026
25947
|
} catch {
|
|
26027
25948
|
}
|
|
@@ -26048,7 +25969,7 @@ var init_gitignore_filter = __esm({
|
|
|
26048
25969
|
});
|
|
26049
25970
|
|
|
26050
25971
|
// ../bridge/src/code-nav/language-registry.ts
|
|
26051
|
-
import
|
|
25972
|
+
import path12 from "node:path";
|
|
26052
25973
|
function languageAssetPaths(key, wasmFile) {
|
|
26053
25974
|
return {
|
|
26054
25975
|
wasmFile,
|
|
@@ -26056,7 +25977,7 @@ function languageAssetPaths(key, wasmFile) {
|
|
|
26056
25977
|
};
|
|
26057
25978
|
}
|
|
26058
25979
|
function getLanguageKeyForFilePath(filePath) {
|
|
26059
|
-
const ext =
|
|
25980
|
+
const ext = path12.extname(filePath).replace(/^\./, "").toLowerCase();
|
|
26060
25981
|
if (!ext) return null;
|
|
26061
25982
|
return EXT_TO_LANGUAGE_KEY[ext] ?? null;
|
|
26062
25983
|
}
|
|
@@ -26106,13 +26027,13 @@ var init_language_registry = __esm({
|
|
|
26106
26027
|
});
|
|
26107
26028
|
|
|
26108
26029
|
// ../bridge/src/code-nav/walk-code-nav-files.ts
|
|
26109
|
-
import
|
|
26110
|
-
import
|
|
26030
|
+
import fs13 from "node:fs";
|
|
26031
|
+
import path13 from "node:path";
|
|
26111
26032
|
async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile, state) {
|
|
26112
26033
|
await filter.enterDirectory(dir, relDir);
|
|
26113
26034
|
let names;
|
|
26114
26035
|
try {
|
|
26115
|
-
names = await
|
|
26036
|
+
names = await fs13.promises.readdir(dir);
|
|
26116
26037
|
} catch {
|
|
26117
26038
|
filter.leaveDirectory(relDir);
|
|
26118
26039
|
return;
|
|
@@ -26129,10 +26050,10 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
26129
26050
|
}
|
|
26130
26051
|
state.n++;
|
|
26131
26052
|
const relPath = relDir ? `${relDir}/${name}` : name;
|
|
26132
|
-
const full =
|
|
26053
|
+
const full = path13.join(dir, name);
|
|
26133
26054
|
let stat3;
|
|
26134
26055
|
try {
|
|
26135
|
-
stat3 = await
|
|
26056
|
+
stat3 = await fs13.promises.stat(full);
|
|
26136
26057
|
} catch {
|
|
26137
26058
|
continue;
|
|
26138
26059
|
}
|
|
@@ -26149,7 +26070,7 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
26149
26070
|
filter.leaveDirectory(relDir);
|
|
26150
26071
|
}
|
|
26151
26072
|
async function walkCodeNavFilesAsync(rootDir, onFile, state = createWalkYieldState()) {
|
|
26152
|
-
const resolved =
|
|
26073
|
+
const resolved = path13.resolve(rootDir);
|
|
26153
26074
|
const filter = new GitignoreFilter();
|
|
26154
26075
|
await walkCodeNavFilesInDirectory(resolved, resolved, "", filter, onFile, state);
|
|
26155
26076
|
}
|
|
@@ -26912,7 +26833,7 @@ var init_persist_single_file = __esm({
|
|
|
26912
26833
|
});
|
|
26913
26834
|
|
|
26914
26835
|
// ../bridge/src/code-nav/resolve-module-import-path.ts
|
|
26915
|
-
import
|
|
26836
|
+
import path14 from "node:path";
|
|
26916
26837
|
function normalizeWorkspacePath(filePath) {
|
|
26917
26838
|
return filePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
26918
26839
|
}
|
|
@@ -26952,28 +26873,28 @@ function tsJsImportCandidates(joined) {
|
|
|
26952
26873
|
function resolveModuleImportPath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
26953
26874
|
const spec = moduleSpecifier.trim();
|
|
26954
26875
|
if (!spec || !isRelativeModuleSpecifier(spec)) return null;
|
|
26955
|
-
const importerDir =
|
|
26956
|
-
const joined = normalizeWorkspacePath(
|
|
26876
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26877
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
26957
26878
|
return firstExistingPath(tsJsImportCandidates(joined), workspaceFiles);
|
|
26958
26879
|
}
|
|
26959
26880
|
function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
26960
26881
|
const moduleName = moduleSpecifier.trim().replace(/\s+/g, "");
|
|
26961
26882
|
if (!moduleName) return null;
|
|
26962
|
-
const importerDir =
|
|
26883
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26963
26884
|
if (moduleName.startsWith(".")) {
|
|
26964
26885
|
const dotMatch = /^(\.+)(.*)$/.exec(moduleName);
|
|
26965
26886
|
const dotCount = dotMatch?.[1]?.length ?? 1;
|
|
26966
26887
|
const rest = (dotMatch?.[2] ?? "").replace(/^\./, "");
|
|
26967
26888
|
let baseDir = importerDir;
|
|
26968
26889
|
for (let i = 1; i < dotCount; i++) {
|
|
26969
|
-
baseDir =
|
|
26890
|
+
baseDir = path14.posix.dirname(baseDir);
|
|
26970
26891
|
}
|
|
26971
26892
|
const dottedPath2 = rest ? rest.split(".").join("/") : "";
|
|
26972
|
-
const relativeBase = dottedPath2 ?
|
|
26893
|
+
const relativeBase = dottedPath2 ? path14.posix.join(baseDir, dottedPath2) : baseDir;
|
|
26973
26894
|
return firstExistingPath(
|
|
26974
26895
|
[
|
|
26975
26896
|
...withSuffixes(relativeBase, PYTHON_EXTENSIONS),
|
|
26976
|
-
...withSuffixes(
|
|
26897
|
+
...withSuffixes(path14.posix.join(relativeBase, "__init__"), [".py"])
|
|
26977
26898
|
],
|
|
26978
26899
|
workspaceFiles
|
|
26979
26900
|
);
|
|
@@ -26982,7 +26903,7 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
26982
26903
|
return firstExistingPath(
|
|
26983
26904
|
[
|
|
26984
26905
|
...withSuffixes(dottedPath, PYTHON_EXTENSIONS),
|
|
26985
|
-
...withSuffixes(
|
|
26906
|
+
...withSuffixes(path14.posix.join(importerDir, dottedPath), PYTHON_EXTENSIONS)
|
|
26986
26907
|
],
|
|
26987
26908
|
workspaceFiles
|
|
26988
26909
|
);
|
|
@@ -26990,9 +26911,9 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
26990
26911
|
function resolveIncludePath(importerFilePath, includePath, workspaceFiles) {
|
|
26991
26912
|
const spec = includePath.trim().replace(/^["']|["']$/g, "");
|
|
26992
26913
|
if (!spec) return null;
|
|
26993
|
-
const importerDir =
|
|
26914
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26994
26915
|
const joined = normalizeWorkspacePath(
|
|
26995
|
-
|
|
26916
|
+
path14.posix.normalize(path14.posix.join(importerDir, spec.replace(/\\/g, "/")))
|
|
26996
26917
|
);
|
|
26997
26918
|
if (workspaceFiles.has(joined)) return joined;
|
|
26998
26919
|
return firstExistingPath(withSuffixes(joined, C_CPP_EXTENSIONS), workspaceFiles);
|
|
@@ -27011,8 +26932,8 @@ function resolveGoImportPath(importerFilePath, moduleSpecifier, workspaceFiles)
|
|
|
27011
26932
|
const spec = moduleSpecifier.trim();
|
|
27012
26933
|
if (!spec) return null;
|
|
27013
26934
|
if (isRelativeModuleSpecifier(spec)) {
|
|
27014
|
-
const importerDir =
|
|
27015
|
-
const joined = normalizeWorkspacePath(
|
|
26935
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26936
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
27016
26937
|
if (workspaceFiles.has(joined)) return joined;
|
|
27017
26938
|
return firstExistingPath(withSuffixes(joined, [".go"]), workspaceFiles);
|
|
27018
26939
|
}
|
|
@@ -28440,12 +28361,12 @@ var init_workspace_files = __esm({
|
|
|
28440
28361
|
});
|
|
28441
28362
|
|
|
28442
28363
|
// ../bridge/src/code-nav/symbol-index/build/extract-file-symbol-data.ts
|
|
28443
|
-
import
|
|
28444
|
-
import
|
|
28364
|
+
import fs14 from "node:fs";
|
|
28365
|
+
import path15 from "node:path";
|
|
28445
28366
|
import { isMainThread as isMainThread3 } from "node:worker_threads";
|
|
28446
28367
|
async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride) {
|
|
28447
28368
|
await yieldForBridgeInteractivePriority();
|
|
28448
|
-
const absPath =
|
|
28369
|
+
const absPath = path15.join(resolved, relPath);
|
|
28449
28370
|
let tags = [];
|
|
28450
28371
|
let source = null;
|
|
28451
28372
|
if (isCodeNavSupportedPath(relPath) && !await isPathGitIgnored(resolved, relPath)) {
|
|
@@ -28453,16 +28374,16 @@ async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride)
|
|
|
28453
28374
|
assertBackgroundIndexingAllowed();
|
|
28454
28375
|
let fileSource = null;
|
|
28455
28376
|
if (isMainThread3) {
|
|
28456
|
-
const stat3 = await
|
|
28377
|
+
const stat3 = await fs14.promises.stat(absPath);
|
|
28457
28378
|
if (stat3.isFile() && stat3.size <= MAX_INDEX_FILE_BYTES) {
|
|
28458
28379
|
assertBackgroundIndexingAllowed();
|
|
28459
|
-
fileSource = await
|
|
28380
|
+
fileSource = await fs14.promises.readFile(absPath, "utf8");
|
|
28460
28381
|
}
|
|
28461
28382
|
} else {
|
|
28462
|
-
const stat3 =
|
|
28383
|
+
const stat3 = fs14.statSync(absPath);
|
|
28463
28384
|
if (stat3.isFile() && stat3.size <= MAX_INDEX_FILE_BYTES) {
|
|
28464
28385
|
assertBackgroundIndexingAllowed();
|
|
28465
|
-
fileSource =
|
|
28386
|
+
fileSource = fs14.readFileSync(absPath, "utf8");
|
|
28466
28387
|
}
|
|
28467
28388
|
}
|
|
28468
28389
|
source = fileSource;
|
|
@@ -28664,12 +28585,12 @@ var init_ensure_symbol_index_file_host = __esm({
|
|
|
28664
28585
|
});
|
|
28665
28586
|
|
|
28666
28587
|
// ../bridge/src/code-nav/symbol-index/lifecycle/normalize-symbol-index-path.ts
|
|
28667
|
-
import
|
|
28588
|
+
import path16 from "node:path";
|
|
28668
28589
|
function normalizeSymbolIndexRelPath2(parentPath, changedPath) {
|
|
28669
|
-
const resolvedParent =
|
|
28670
|
-
const abs =
|
|
28671
|
-
const rel =
|
|
28672
|
-
if (rel.startsWith("..") ||
|
|
28590
|
+
const resolvedParent = path16.resolve(parentPath);
|
|
28591
|
+
const abs = path16.isAbsolute(changedPath) ? path16.resolve(changedPath) : path16.resolve(resolvedParent, changedPath);
|
|
28592
|
+
const rel = path16.relative(resolvedParent, abs).replace(/\\/g, "/");
|
|
28593
|
+
if (rel.startsWith("..") || path16.isAbsolute(rel)) return null;
|
|
28673
28594
|
return rel;
|
|
28674
28595
|
}
|
|
28675
28596
|
var init_normalize_symbol_index_path = __esm({
|
|
@@ -30050,7 +29971,7 @@ var require_has_flag = __commonJS({
|
|
|
30050
29971
|
var require_supports_color = __commonJS({
|
|
30051
29972
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
30052
29973
|
"use strict";
|
|
30053
|
-
var
|
|
29974
|
+
var os10 = __require("os");
|
|
30054
29975
|
var tty = __require("tty");
|
|
30055
29976
|
var hasFlag = require_has_flag();
|
|
30056
29977
|
var { env } = process;
|
|
@@ -30098,7 +30019,7 @@ var require_supports_color = __commonJS({
|
|
|
30098
30019
|
return min;
|
|
30099
30020
|
}
|
|
30100
30021
|
if (process.platform === "win32") {
|
|
30101
|
-
const osRelease =
|
|
30022
|
+
const osRelease = os10.release().split(".");
|
|
30102
30023
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
30103
30024
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
30104
30025
|
}
|
|
@@ -30344,10 +30265,10 @@ var require_src2 = __commonJS({
|
|
|
30344
30265
|
var fs_1 = __require("fs");
|
|
30345
30266
|
var debug_1 = __importDefault(require_src());
|
|
30346
30267
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
30347
|
-
function check2(
|
|
30348
|
-
log2(`checking %s`,
|
|
30268
|
+
function check2(path86, isFile, isDirectory) {
|
|
30269
|
+
log2(`checking %s`, path86);
|
|
30349
30270
|
try {
|
|
30350
|
-
const stat3 = fs_1.statSync(
|
|
30271
|
+
const stat3 = fs_1.statSync(path86);
|
|
30351
30272
|
if (stat3.isFile() && isFile) {
|
|
30352
30273
|
log2(`[OK] path represents a file`);
|
|
30353
30274
|
return true;
|
|
@@ -30367,8 +30288,8 @@ var require_src2 = __commonJS({
|
|
|
30367
30288
|
throw e;
|
|
30368
30289
|
}
|
|
30369
30290
|
}
|
|
30370
|
-
function exists2(
|
|
30371
|
-
return check2(
|
|
30291
|
+
function exists2(path86, type = exports.READABLE) {
|
|
30292
|
+
return check2(path86, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
30372
30293
|
}
|
|
30373
30294
|
exports.exists = exists2;
|
|
30374
30295
|
exports.FILE = 1;
|
|
@@ -30449,14 +30370,14 @@ var {
|
|
|
30449
30370
|
} = import_index.default;
|
|
30450
30371
|
|
|
30451
30372
|
// src/cli-version.ts
|
|
30452
|
-
var CLI_VERSION = "0.1.
|
|
30373
|
+
var CLI_VERSION = "0.1.96".length > 0 ? "0.1.96" : "0.0.0-dev";
|
|
30453
30374
|
|
|
30454
30375
|
// src/cli/defaults.ts
|
|
30455
30376
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
30456
30377
|
var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
|
|
30457
30378
|
|
|
30458
30379
|
// src/cli/run-cli-action.ts
|
|
30459
|
-
import * as
|
|
30380
|
+
import * as path85 from "node:path";
|
|
30460
30381
|
|
|
30461
30382
|
// ../../node_modules/.pnpm/ws@8.19.0/node_modules/ws/wrapper.mjs
|
|
30462
30383
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -31479,8 +31400,8 @@ function getErrorMap() {
|
|
|
31479
31400
|
|
|
31480
31401
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
31481
31402
|
var makeIssue = (params) => {
|
|
31482
|
-
const { data, path:
|
|
31483
|
-
const fullPath = [...
|
|
31403
|
+
const { data, path: path86, errorMaps, issueData } = params;
|
|
31404
|
+
const fullPath = [...path86, ...issueData.path || []];
|
|
31484
31405
|
const fullIssue = {
|
|
31485
31406
|
...issueData,
|
|
31486
31407
|
path: fullPath
|
|
@@ -31596,11 +31517,11 @@ var errorUtil;
|
|
|
31596
31517
|
|
|
31597
31518
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
31598
31519
|
var ParseInputLazyPath = class {
|
|
31599
|
-
constructor(parent, value,
|
|
31520
|
+
constructor(parent, value, path86, key) {
|
|
31600
31521
|
this._cachedPath = [];
|
|
31601
31522
|
this.parent = parent;
|
|
31602
31523
|
this.data = value;
|
|
31603
|
-
this._path =
|
|
31524
|
+
this._path = path86;
|
|
31604
31525
|
this._key = key;
|
|
31605
31526
|
}
|
|
31606
31527
|
get path() {
|
|
@@ -35510,83 +35431,8 @@ function isUserEndedSessionTurnErrorText(errorText) {
|
|
|
35510
35431
|
}
|
|
35511
35432
|
|
|
35512
35433
|
// ../types/src/session-kind.ts
|
|
35513
|
-
var SESSION_KINDS = ["regular", "
|
|
35434
|
+
var SESSION_KINDS = ["regular", "planned"];
|
|
35514
35435
|
var SESSION_KIND_SET = new Set(SESSION_KINDS);
|
|
35515
|
-
function parseSessionKind(raw) {
|
|
35516
|
-
if (raw === "todo") return "planned";
|
|
35517
|
-
if (typeof raw === "string" && SESSION_KIND_SET.has(raw)) return raw;
|
|
35518
|
-
return "regular";
|
|
35519
|
-
}
|
|
35520
|
-
|
|
35521
|
-
// ../types/src/planning-todo.ts
|
|
35522
|
-
function planningTodoTitle(item) {
|
|
35523
|
-
return item.content.title;
|
|
35524
|
-
}
|
|
35525
|
-
|
|
35526
|
-
// ../types/src/parse-planning-todo-agent-json.ts
|
|
35527
|
-
function parsePlanningTodoAgentJson(raw) {
|
|
35528
|
-
if (raw == null || raw.trim() === "") return [];
|
|
35529
|
-
let text = raw.trim();
|
|
35530
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
35531
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
35532
|
-
let parsed;
|
|
35533
|
-
try {
|
|
35534
|
-
parsed = JSON.parse(text);
|
|
35535
|
-
} catch {
|
|
35536
|
-
const start = text.indexOf("[");
|
|
35537
|
-
const end = text.lastIndexOf("]");
|
|
35538
|
-
if (start < 0 || end <= start) return [];
|
|
35539
|
-
try {
|
|
35540
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
35541
|
-
} catch {
|
|
35542
|
-
return [];
|
|
35543
|
-
}
|
|
35544
|
-
}
|
|
35545
|
-
if (!Array.isArray(parsed)) return [];
|
|
35546
|
-
const rows = [];
|
|
35547
|
-
for (const item of parsed) {
|
|
35548
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
35549
|
-
const o = item;
|
|
35550
|
-
const title = typeof o.title === "string" ? o.title.trim() : "";
|
|
35551
|
-
const prompt = typeof o.prompt === "string" ? o.prompt.trim() : typeof o.promptText === "string" ? o.promptText.trim() : "";
|
|
35552
|
-
if (!title || !prompt) continue;
|
|
35553
|
-
rows.push({ title, prompt });
|
|
35554
|
-
}
|
|
35555
|
-
return rows;
|
|
35556
|
-
}
|
|
35557
|
-
|
|
35558
|
-
// ../types/src/build-planning-session-agent-prompt.ts
|
|
35559
|
-
var PLANNING_INSTRUCTIONS = [
|
|
35560
|
-
"PLANNING MODE: You must NOT make any changes to the codebase, filesystem, or environment.",
|
|
35561
|
-
"Do not run tools that modify files or execute commands that change state.",
|
|
35562
|
-
"Your only task is to analyze and produce a plan.",
|
|
35563
|
-
"",
|
|
35564
|
-
"Respond with ONLY a single JSON array \u2014 no markdown fences, no other text before or after.",
|
|
35565
|
-
"Each array element must be an object with exactly:",
|
|
35566
|
-
'- "title": a one-line summary of the task',
|
|
35567
|
-
'- "prompt": the full prompt to use when creating a new draft session from this todo',
|
|
35568
|
-
"",
|
|
35569
|
-
"Example:",
|
|
35570
|
-
'[{"title":"Add user login","prompt":"Implement a login form with email and password..."}]'
|
|
35571
|
-
].join("\n");
|
|
35572
|
-
function buildPlanningSessionAgentPrompt(userPrompt) {
|
|
35573
|
-
return [PLANNING_INSTRUCTIONS, "", "User request:", userPrompt.trim()].join("\n");
|
|
35574
|
-
}
|
|
35575
|
-
function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
35576
|
-
const todoLines = existingTodos.length > 0 ? existingTodos.map((t) => {
|
|
35577
|
-
const status = t.plannedSessionId ? "DONE (draft session already created)" : "OPEN";
|
|
35578
|
-
return `- [${status}] ${planningTodoTitle(t)}`;
|
|
35579
|
-
}).join("\n") : "(none yet)";
|
|
35580
|
-
return [
|
|
35581
|
-
PLANNING_INSTRUCTIONS,
|
|
35582
|
-
"",
|
|
35583
|
-
"Existing todo items from this planning session (consider these when responding; do not duplicate completed items):",
|
|
35584
|
-
todoLines,
|
|
35585
|
-
"",
|
|
35586
|
-
"User follow-up:",
|
|
35587
|
-
userPrompt.trim()
|
|
35588
|
-
].join("\n");
|
|
35589
|
-
}
|
|
35590
35436
|
|
|
35591
35437
|
// ../types/src/diff/line-diff.ts
|
|
35592
35438
|
function normalizeDiffLineText(line) {
|
|
@@ -35827,19 +35673,6 @@ function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
|
35827
35673
|
};
|
|
35828
35674
|
}
|
|
35829
35675
|
|
|
35830
|
-
// ../types/src/acp-agent-text-stream-bucket.ts
|
|
35831
|
-
function resolveAgentTextStreamBucket(params) {
|
|
35832
|
-
const k = params.transcriptRowKind;
|
|
35833
|
-
const su = params.sessionUpdate;
|
|
35834
|
-
if (k === "agent_thought_chunk" || su === "agent_thought_chunk" || k === "thinking" || su === "thinking") {
|
|
35835
|
-
return "thought";
|
|
35836
|
-
}
|
|
35837
|
-
if (k === "agent_message_chunk" || su === "agent_message_chunk" || k === "update" || su === "update") {
|
|
35838
|
-
return "message";
|
|
35839
|
-
}
|
|
35840
|
-
return null;
|
|
35841
|
-
}
|
|
35842
|
-
|
|
35843
35676
|
// ../types/src/agent-config.ts
|
|
35844
35677
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
35845
35678
|
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
@@ -36950,7 +36783,7 @@ function bridgeAgentPathEnv(base = process.env) {
|
|
|
36950
36783
|
}
|
|
36951
36784
|
|
|
36952
36785
|
// ../bridge/src/files/watch-file-index.ts
|
|
36953
|
-
import
|
|
36786
|
+
import path21 from "node:path";
|
|
36954
36787
|
|
|
36955
36788
|
// ../bridge/src/files/index/index.ts
|
|
36956
36789
|
init_paths();
|
|
@@ -36959,7 +36792,7 @@ init_paths();
|
|
|
36959
36792
|
init_in_flight();
|
|
36960
36793
|
init_cli_process_interrupt();
|
|
36961
36794
|
init_database();
|
|
36962
|
-
import
|
|
36795
|
+
import path17 from "node:path";
|
|
36963
36796
|
|
|
36964
36797
|
// ../bridge/src/files/index/file-index-sqlite-lock.ts
|
|
36965
36798
|
var fileIndexChain = Promise.resolve();
|
|
@@ -37066,7 +36899,7 @@ function assertNotShutdown2() {
|
|
|
37066
36899
|
if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
|
|
37067
36900
|
}
|
|
37068
36901
|
async function buildFileIndexAsync(cwd) {
|
|
37069
|
-
const resolved =
|
|
36902
|
+
const resolved = path17.resolve(cwd);
|
|
37070
36903
|
await yieldForBridgeInteractivePriority();
|
|
37071
36904
|
assertNotShutdown2();
|
|
37072
36905
|
const paths = await collectWorkspacePathsAsync(resolved);
|
|
@@ -37079,7 +36912,7 @@ async function buildFileIndexAsync(cwd) {
|
|
|
37079
36912
|
}
|
|
37080
36913
|
|
|
37081
36914
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
37082
|
-
import
|
|
36915
|
+
import path18 from "node:path";
|
|
37083
36916
|
|
|
37084
36917
|
// ../bridge/src/files/index/search-file-index.ts
|
|
37085
36918
|
init_yield_to_event_loop();
|
|
@@ -37134,7 +36967,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
|
|
|
37134
36967
|
|
|
37135
36968
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
37136
36969
|
async function ensureFileIndexAsync(cwd) {
|
|
37137
|
-
const resolved =
|
|
36970
|
+
const resolved = path18.resolve(cwd);
|
|
37138
36971
|
if (await bridgeFileIndexIsPopulated(resolved)) {
|
|
37139
36972
|
return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
|
|
37140
36973
|
}
|
|
@@ -37886,16 +37719,16 @@ init_database();
|
|
|
37886
37719
|
init_cli_process_interrupt();
|
|
37887
37720
|
|
|
37888
37721
|
// ../bridge/src/files/index/file-index-incremental-symbol-updates.ts
|
|
37889
|
-
import
|
|
37890
|
-
import
|
|
37722
|
+
import fs15 from "node:fs";
|
|
37723
|
+
import path19 from "node:path";
|
|
37891
37724
|
init_cli_process_interrupt();
|
|
37892
37725
|
init_yield_to_event_loop();
|
|
37893
37726
|
init_database();
|
|
37894
37727
|
async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
|
|
37895
37728
|
for (const rel of relPaths) {
|
|
37896
|
-
const absPath =
|
|
37729
|
+
const absPath = path19.join(resolved, rel);
|
|
37897
37730
|
try {
|
|
37898
|
-
const stat3 = await
|
|
37731
|
+
const stat3 = await fs15.promises.stat(absPath);
|
|
37899
37732
|
if (stat3.isFile()) {
|
|
37900
37733
|
await updateSymbolIndexForFile(resolved, absPath);
|
|
37901
37734
|
} else {
|
|
@@ -38009,11 +37842,11 @@ function createFileIndexFsWatcher(resolved, schedule) {
|
|
|
38009
37842
|
}
|
|
38010
37843
|
|
|
38011
37844
|
// ../bridge/src/files/index/file-index-initial-builds.ts
|
|
38012
|
-
import
|
|
37845
|
+
import path20 from "node:path";
|
|
38013
37846
|
init_database();
|
|
38014
37847
|
init_code_nav_cache_availability();
|
|
38015
37848
|
async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
38016
|
-
const resolved =
|
|
37849
|
+
const resolved = path20.resolve(cwd);
|
|
38017
37850
|
try {
|
|
38018
37851
|
if (!await startCodeNavCacheInitialization()) return;
|
|
38019
37852
|
await buildFileIndexAsync(resolved);
|
|
@@ -38032,7 +37865,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
|
38032
37865
|
|
|
38033
37866
|
// ../bridge/src/files/watch-file-index.ts
|
|
38034
37867
|
function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
38035
|
-
const resolved =
|
|
37868
|
+
const resolved = path21.resolve(cwd);
|
|
38036
37869
|
const rebuildState = createFileIndexWatchRebuildState();
|
|
38037
37870
|
let timer = null;
|
|
38038
37871
|
const schedule = (relPath) => {
|
|
@@ -38292,20 +38125,20 @@ async function cancelRun(ctx, runId) {
|
|
|
38292
38125
|
}
|
|
38293
38126
|
|
|
38294
38127
|
// ../bridge/src/agents/acp/ensure-acp-client.ts
|
|
38295
|
-
import * as
|
|
38296
|
-
import * as
|
|
38128
|
+
import * as fs18 from "node:fs";
|
|
38129
|
+
import * as path27 from "node:path";
|
|
38297
38130
|
|
|
38298
38131
|
// ../bridge/src/paths/session-layout-paths.ts
|
|
38299
|
-
import * as
|
|
38132
|
+
import * as path22 from "node:path";
|
|
38300
38133
|
function resolveIsolatedSessionParentPathFromCheckouts(worktreePaths) {
|
|
38301
|
-
const resolved = worktreePaths.map((p) =>
|
|
38134
|
+
const resolved = worktreePaths.map((p) => path22.resolve(p)).filter(Boolean);
|
|
38302
38135
|
if (resolved.length === 0) return null;
|
|
38303
38136
|
resolved.sort();
|
|
38304
38137
|
return resolved[0];
|
|
38305
38138
|
}
|
|
38306
38139
|
function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
|
|
38307
38140
|
if (resolvedSessionParentPath != null && String(resolvedSessionParentPath).trim() !== "") {
|
|
38308
|
-
return
|
|
38141
|
+
return path22.resolve(String(resolvedSessionParentPath).trim());
|
|
38309
38142
|
}
|
|
38310
38143
|
return getBridgeRoot();
|
|
38311
38144
|
}
|
|
@@ -38686,20 +38519,20 @@ var codexProvider = {
|
|
|
38686
38519
|
};
|
|
38687
38520
|
|
|
38688
38521
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
38689
|
-
import * as
|
|
38522
|
+
import * as fs16 from "node:fs";
|
|
38690
38523
|
|
|
38691
38524
|
// ../bridge/src/paths/session-plans-paths.ts
|
|
38692
|
-
import * as
|
|
38693
|
-
import * as
|
|
38525
|
+
import * as os5 from "node:os";
|
|
38526
|
+
import * as path23 from "node:path";
|
|
38694
38527
|
function getSessionPlansRootDir() {
|
|
38695
|
-
return
|
|
38528
|
+
return path23.join(os5.homedir(), ".buildautomaton", "plans");
|
|
38696
38529
|
}
|
|
38697
38530
|
function sanitizeSessionPlansKey(sessionId) {
|
|
38698
38531
|
const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
|
|
38699
38532
|
return t || "session";
|
|
38700
38533
|
}
|
|
38701
38534
|
function getSessionPlansDir(sessionId) {
|
|
38702
|
-
return
|
|
38535
|
+
return path23.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
|
|
38703
38536
|
}
|
|
38704
38537
|
|
|
38705
38538
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
@@ -38708,7 +38541,7 @@ function cleanupSessionPlans(sessionId) {
|
|
|
38708
38541
|
if (!id) return;
|
|
38709
38542
|
const dir = getSessionPlansDir(id);
|
|
38710
38543
|
try {
|
|
38711
|
-
|
|
38544
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
38712
38545
|
} catch {
|
|
38713
38546
|
}
|
|
38714
38547
|
}
|
|
@@ -39076,8 +38909,8 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
|
|
|
39076
38909
|
}
|
|
39077
38910
|
|
|
39078
38911
|
// ../bridge/src/agents/providers/cursor/write-create-plan-file.ts
|
|
39079
|
-
import * as
|
|
39080
|
-
import * as
|
|
38912
|
+
import * as fs17 from "node:fs";
|
|
38913
|
+
import * as path24 from "node:path";
|
|
39081
38914
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
39082
38915
|
function sanitizePlanFileBase(toolCallId) {
|
|
39083
38916
|
const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
|
|
@@ -39085,9 +38918,9 @@ function sanitizePlanFileBase(toolCallId) {
|
|
|
39085
38918
|
}
|
|
39086
38919
|
function writeCreatePlanFile(params) {
|
|
39087
38920
|
const dir = getSessionPlansDir(params.cloudSessionId);
|
|
39088
|
-
|
|
39089
|
-
const filePath =
|
|
39090
|
-
|
|
38921
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
38922
|
+
const filePath = path24.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
|
|
38923
|
+
fs17.writeFileSync(filePath, params.planMarkdown, "utf8");
|
|
39091
38924
|
return pathToFileURL2(filePath).href;
|
|
39092
38925
|
}
|
|
39093
38926
|
|
|
@@ -39701,16 +39534,16 @@ async function execGitFile(args, options) {
|
|
|
39701
39534
|
}
|
|
39702
39535
|
|
|
39703
39536
|
// ../bridge/src/git/get-git-repo-root-sync.ts
|
|
39704
|
-
import * as
|
|
39537
|
+
import * as path25 from "node:path";
|
|
39705
39538
|
var GIT_LOOKUP_TIMEOUT_MS = 2e3;
|
|
39706
39539
|
function getGitRepoRootSync(startDir) {
|
|
39707
39540
|
try {
|
|
39708
39541
|
const out = execGitFileSync(["rev-parse", "--show-toplevel"], {
|
|
39709
|
-
cwd:
|
|
39542
|
+
cwd: path25.resolve(startDir),
|
|
39710
39543
|
maxBuffer: 1024 * 1024,
|
|
39711
39544
|
timeout: GIT_LOOKUP_TIMEOUT_MS
|
|
39712
39545
|
}).trim();
|
|
39713
|
-
return out ?
|
|
39546
|
+
return out ? path25.resolve(out) : null;
|
|
39714
39547
|
} catch {
|
|
39715
39548
|
return null;
|
|
39716
39549
|
}
|
|
@@ -39718,26 +39551,26 @@ function getGitRepoRootSync(startDir) {
|
|
|
39718
39551
|
|
|
39719
39552
|
// ../bridge/src/agents/acp/workspace-files.ts
|
|
39720
39553
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
39721
|
-
import * as
|
|
39554
|
+
import * as path26 from "node:path";
|
|
39722
39555
|
var GIT_FILE_READ_TIMEOUT_MS = 2e3;
|
|
39723
39556
|
function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
|
|
39724
39557
|
const trimmed2 = rawPath.trim();
|
|
39725
39558
|
if (!trimmed2) return null;
|
|
39726
|
-
const normalizedSessionParent =
|
|
39559
|
+
const normalizedSessionParent = path26.resolve(sessionParentPath);
|
|
39727
39560
|
let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
|
|
39728
39561
|
if (!resolvedPath) {
|
|
39729
|
-
const candidate =
|
|
39562
|
+
const candidate = path26.isAbsolute(trimmed2) ? path26.normalize(trimmed2) : path26.normalize(path26.resolve(normalizedSessionParent, trimmed2));
|
|
39730
39563
|
const gitRoot2 = getGitRepoRootSync(sessionParentPath);
|
|
39731
39564
|
if (!gitRoot2) return null;
|
|
39732
|
-
const rel =
|
|
39733
|
-
if (rel.startsWith("..") ||
|
|
39565
|
+
const rel = path26.relative(gitRoot2, candidate);
|
|
39566
|
+
if (rel.startsWith("..") || path26.isAbsolute(rel)) return null;
|
|
39734
39567
|
resolvedPath = candidate;
|
|
39735
39568
|
}
|
|
39736
39569
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39737
39570
|
if (gitRoot) {
|
|
39738
|
-
const relFromRoot =
|
|
39739
|
-
if (!relFromRoot.startsWith("..") && !
|
|
39740
|
-
return { resolvedPath, display: relFromRoot.split(
|
|
39571
|
+
const relFromRoot = path26.relative(gitRoot, resolvedPath);
|
|
39572
|
+
if (!relFromRoot.startsWith("..") && !path26.isAbsolute(relFromRoot)) {
|
|
39573
|
+
return { resolvedPath, display: relFromRoot.split(path26.sep).join("/") };
|
|
39741
39574
|
}
|
|
39742
39575
|
}
|
|
39743
39576
|
return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
|
|
@@ -39746,9 +39579,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
|
|
|
39746
39579
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
39747
39580
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39748
39581
|
if (gitRoot) {
|
|
39749
|
-
const resolvedPath2 =
|
|
39750
|
-
const rel =
|
|
39751
|
-
if (!rel.startsWith("..") && !
|
|
39582
|
+
const resolvedPath2 = path26.resolve(gitRoot, displayPath);
|
|
39583
|
+
const rel = path26.relative(gitRoot, resolvedPath2);
|
|
39584
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) {
|
|
39752
39585
|
try {
|
|
39753
39586
|
return readFileSync4(resolvedPath2, "utf8");
|
|
39754
39587
|
} catch {
|
|
@@ -39767,9 +39600,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
|
|
|
39767
39600
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
39768
39601
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39769
39602
|
if (gitRoot) {
|
|
39770
|
-
const resolvedPath =
|
|
39771
|
-
const rel =
|
|
39772
|
-
if (!rel.startsWith("..") && !
|
|
39603
|
+
const resolvedPath = path26.resolve(gitRoot, displayPath);
|
|
39604
|
+
const rel = path26.relative(gitRoot, resolvedPath);
|
|
39605
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) return resolvedPath;
|
|
39773
39606
|
}
|
|
39774
39607
|
return resolveSafePathUnderCwd(sessionParentPath, displayPath);
|
|
39775
39608
|
}
|
|
@@ -40069,11 +39902,13 @@ var PathSnapshotTracker = class {
|
|
|
40069
39902
|
};
|
|
40070
39903
|
|
|
40071
39904
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/send-session-info-title-update.ts
|
|
39905
|
+
var PLACEHOLDER_TITLES = /* @__PURE__ */ new Set(["session", "new session", "untitled"]);
|
|
40072
39906
|
function extractSessionInfoTitle(params) {
|
|
40073
39907
|
if (!params || typeof params !== "object") return null;
|
|
40074
39908
|
const p = params;
|
|
40075
39909
|
const title = typeof p.title === "string" ? p.title.trim() : "";
|
|
40076
|
-
|
|
39910
|
+
if (!title || PLACEHOLDER_TITLES.has(title.toLowerCase())) return null;
|
|
39911
|
+
return title;
|
|
40077
39912
|
}
|
|
40078
39913
|
function sendSessionInfoTitleUpdate(params) {
|
|
40079
39914
|
const title = extractSessionInfoTitle(params.payload);
|
|
@@ -40394,74 +40229,12 @@ function resolveBridgeToolPaths(params, isToolUpdate, sessionParentPath) {
|
|
|
40394
40229
|
return isToolUpdate ? extractToolTargetDisplayPaths(params, sessionParentPath) : [];
|
|
40395
40230
|
}
|
|
40396
40231
|
|
|
40397
|
-
// ../bridge/src/agents/planning/extract-session-update-message-text.ts
|
|
40398
|
-
function extractSessionUpdateMessageText(params) {
|
|
40399
|
-
if (params == null || typeof params !== "object" || Array.isArray(params)) return null;
|
|
40400
|
-
const o = params;
|
|
40401
|
-
if (typeof o.text === "string" && o.text.length > 0) return o.text;
|
|
40402
|
-
const content = o.content;
|
|
40403
|
-
if (typeof content === "string" && content.length > 0) return content;
|
|
40404
|
-
if (content != null && typeof content === "object" && !Array.isArray(content)) {
|
|
40405
|
-
const c = content;
|
|
40406
|
-
if (typeof c.text === "string" && c.text.length > 0) return c.text;
|
|
40407
|
-
}
|
|
40408
|
-
const update = o.update;
|
|
40409
|
-
if (typeof update === "string" && update.length > 0) return update;
|
|
40410
|
-
if (update != null && typeof update === "object" && !Array.isArray(update)) {
|
|
40411
|
-
const u = update;
|
|
40412
|
-
const innerContent = u.content;
|
|
40413
|
-
if (typeof innerContent === "string" && innerContent.length > 0) return innerContent;
|
|
40414
|
-
if (innerContent != null && typeof innerContent === "object" && !Array.isArray(innerContent)) {
|
|
40415
|
-
const ic = innerContent;
|
|
40416
|
-
if (typeof ic.text === "string" && ic.text.length > 0) return ic.text;
|
|
40417
|
-
}
|
|
40418
|
-
}
|
|
40419
|
-
return null;
|
|
40420
|
-
}
|
|
40421
|
-
|
|
40422
|
-
// ../bridge/src/agents/planning/planning-session-turn-buffer.ts
|
|
40423
|
-
var MAX_PLANNING_BUFFER_CHARS = 512 * 1024;
|
|
40424
|
-
var buffersByRunId = /* @__PURE__ */ new Map();
|
|
40425
|
-
function registerPlanningSessionTurn(runId) {
|
|
40426
|
-
buffersByRunId.set(runId, { messageBuffer: "" });
|
|
40427
|
-
}
|
|
40428
|
-
function clearPlanningSessionTurn(runId) {
|
|
40429
|
-
buffersByRunId.delete(runId);
|
|
40430
|
-
}
|
|
40431
|
-
function capturePlanningSessionUpdate(params) {
|
|
40432
|
-
const state = buffersByRunId.get(params.runId);
|
|
40433
|
-
if (!state) return false;
|
|
40434
|
-
const sessionUpdate = params.payload != null && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload.sessionUpdate ?? params.payload.session_update : void 0;
|
|
40435
|
-
const bucket = resolveAgentTextStreamBucket({
|
|
40436
|
-
transcriptRowKind: params.updateKind,
|
|
40437
|
-
sessionUpdate: typeof sessionUpdate === "string" ? sessionUpdate : void 0
|
|
40438
|
-
});
|
|
40439
|
-
if (bucket !== "message") return false;
|
|
40440
|
-
const text = extractSessionUpdateMessageText(params.payload);
|
|
40441
|
-
if (text && state.messageBuffer.length < MAX_PLANNING_BUFFER_CHARS) {
|
|
40442
|
-
const room = MAX_PLANNING_BUFFER_CHARS - state.messageBuffer.length;
|
|
40443
|
-
state.messageBuffer += room >= text.length ? text : text.slice(0, room);
|
|
40444
|
-
}
|
|
40445
|
-
return true;
|
|
40446
|
-
}
|
|
40447
|
-
function getPlanningSessionTurnOutput(runId) {
|
|
40448
|
-
return buffersByRunId.get(runId)?.messageBuffer ?? "";
|
|
40449
|
-
}
|
|
40450
|
-
function consumePlanningSessionTurnOutput(runId) {
|
|
40451
|
-
const state = buffersByRunId.get(runId);
|
|
40452
|
-
buffersByRunId.delete(runId);
|
|
40453
|
-
return state?.messageBuffer ?? "";
|
|
40454
|
-
}
|
|
40455
|
-
|
|
40456
40232
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/forward-bridge-session-update.ts
|
|
40457
40233
|
function forwardBridgeSessionUpdate(params) {
|
|
40458
40234
|
const { runId, sessionId, updateKind, payload, send, nextTranscriptStreamSeq, log: log2 } = params;
|
|
40459
40235
|
if (updateKind === "permission") {
|
|
40460
40236
|
return;
|
|
40461
40237
|
}
|
|
40462
|
-
if (capturePlanningSessionUpdate({ runId, updateKind, payload })) {
|
|
40463
|
-
return;
|
|
40464
|
-
}
|
|
40465
40238
|
try {
|
|
40466
40239
|
const transcriptStreamSeq = nextTranscriptStreamSeq?.(runId);
|
|
40467
40240
|
send({
|
|
@@ -40717,7 +40490,7 @@ async function ensureAcpClient(options) {
|
|
|
40717
40490
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
40718
40491
|
await state.acpStartPromise;
|
|
40719
40492
|
}
|
|
40720
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
40493
|
+
if (state.acpHandle && state.lastAcpCwd != null && path27.resolve(state.lastAcpCwd) !== path27.resolve(targetSessionParentPath)) {
|
|
40721
40494
|
try {
|
|
40722
40495
|
state.acpHandle.disconnect();
|
|
40723
40496
|
} catch {
|
|
@@ -40749,7 +40522,7 @@ async function ensureAcpClient(options) {
|
|
|
40749
40522
|
if (!state.acpStartPromise) {
|
|
40750
40523
|
let statOk = false;
|
|
40751
40524
|
try {
|
|
40752
|
-
const st = await
|
|
40525
|
+
const st = await fs18.promises.stat(targetSessionParentPath);
|
|
40753
40526
|
statOk = st.isDirectory();
|
|
40754
40527
|
if (!statOk) {
|
|
40755
40528
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
|
|
@@ -40909,8 +40682,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
|
|
|
40909
40682
|
init_yield_to_event_loop();
|
|
40910
40683
|
|
|
40911
40684
|
// ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
|
|
40912
|
-
function normalizeGitDiffPath(
|
|
40913
|
-
return
|
|
40685
|
+
function normalizeGitDiffPath(path86) {
|
|
40686
|
+
return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
40914
40687
|
}
|
|
40915
40688
|
|
|
40916
40689
|
// ../bridge/src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -40949,7 +40722,7 @@ function parseNameStatusLines(lines) {
|
|
|
40949
40722
|
}
|
|
40950
40723
|
|
|
40951
40724
|
// ../bridge/src/git/snapshot/diff/messages.ts
|
|
40952
|
-
import * as
|
|
40725
|
+
import * as path28 from "node:path";
|
|
40953
40726
|
|
|
40954
40727
|
// ../bridge/src/git/snapshot/diff/files.ts
|
|
40955
40728
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -40980,7 +40753,7 @@ async function buildTrackedChangeMessage(options) {
|
|
|
40980
40753
|
const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
|
|
40981
40754
|
const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
|
|
40982
40755
|
if (!patchContent.trim()) return null;
|
|
40983
|
-
const workspaceFilePath =
|
|
40756
|
+
const workspaceFilePath = path28.join(repoPath, rel);
|
|
40984
40757
|
const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
|
|
40985
40758
|
const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
|
|
40986
40759
|
return {
|
|
@@ -41012,9 +40785,9 @@ function buildUntrackedChangeMessage(options) {
|
|
|
41012
40785
|
}
|
|
41013
40786
|
|
|
41014
40787
|
// ../bridge/src/git/snapshot/diff/paths.ts
|
|
41015
|
-
import * as
|
|
40788
|
+
import * as path29 from "node:path";
|
|
41016
40789
|
function repoDisplayPath(repoPath, multiRepo) {
|
|
41017
|
-
const slug =
|
|
40790
|
+
const slug = path29.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
|
|
41018
40791
|
return (rel) => multiRepo ? `${slug}/${rel}` : rel;
|
|
41019
40792
|
}
|
|
41020
40793
|
function safeRelPath(rel) {
|
|
@@ -41026,12 +40799,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
|
|
|
41026
40799
|
}
|
|
41027
40800
|
|
|
41028
40801
|
// ../bridge/src/git/snapshot/diff/move-pairs.ts
|
|
41029
|
-
import * as
|
|
40802
|
+
import * as path30 from "node:path";
|
|
41030
40803
|
async function readUntrackedTexts(repoPath, untracked) {
|
|
41031
40804
|
const out = /* @__PURE__ */ new Map();
|
|
41032
40805
|
await forEachWithGitYield(untracked, async (rel) => {
|
|
41033
40806
|
if (!safeRelPath(rel)) return;
|
|
41034
|
-
const newText = await readWorkspaceFileAsUtf8(
|
|
40807
|
+
const newText = await readWorkspaceFileAsUtf8(path30.join(repoPath, rel));
|
|
41035
40808
|
if (newText !== void 0) out.set(rel, newText);
|
|
41036
40809
|
});
|
|
41037
40810
|
return out;
|
|
@@ -41148,12 +40921,12 @@ async function collectRepoTurnChanges(options) {
|
|
|
41148
40921
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
41149
40922
|
|
|
41150
40923
|
// ../bridge/src/git/snapshot/types.ts
|
|
41151
|
-
import * as
|
|
40924
|
+
import * as path31 from "node:path";
|
|
41152
40925
|
function snapshotsDirForCwd(agentCwd) {
|
|
41153
|
-
return
|
|
40926
|
+
return path31.join(agentCwd, ".buildautomaton", "snapshots");
|
|
41154
40927
|
}
|
|
41155
40928
|
function snapshotFilePath(agentCwd, runId) {
|
|
41156
|
-
return
|
|
40929
|
+
return path31.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
41157
40930
|
}
|
|
41158
40931
|
|
|
41159
40932
|
// ../bridge/src/git/snapshot/diff/load-pre-turn-snapshot.ts
|
|
@@ -41230,22 +41003,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41230
41003
|
promptId,
|
|
41231
41004
|
agentType,
|
|
41232
41005
|
agentCwd,
|
|
41233
|
-
isPlanningSession,
|
|
41234
41006
|
followUpCatalogPromptId,
|
|
41235
|
-
plugin,
|
|
41236
41007
|
sendResult,
|
|
41237
41008
|
sendSessionUpdate,
|
|
41238
41009
|
log: log2
|
|
41239
41010
|
} = params;
|
|
41240
41011
|
notifyAgentProvidersPromptTurnFinished(sessionId);
|
|
41241
|
-
const planningTodosSubmit = isPlanningSession && plugin?.cloud?.maybeSubmitPlanningTodos ? await plugin.cloud.maybeSubmitPlanningTodos({
|
|
41242
|
-
sessionId,
|
|
41243
|
-
runId,
|
|
41244
|
-
resultSuccess: result.success === true,
|
|
41245
|
-
output: result.output,
|
|
41246
|
-
log: log2
|
|
41247
|
-
}) : { suppressOutput: false };
|
|
41248
|
-
const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
|
|
41249
41012
|
const errStr = typeof result.error === "string" ? result.error : void 0;
|
|
41250
41013
|
const resultStop = typeof result.stopReason === "string" ? result.stopReason.trim() : "";
|
|
41251
41014
|
const cancelledByAgent = resultStop.toLowerCase() === "cancelled" || errStr != null && isUserEndedSessionTurnErrorText(errStr);
|
|
@@ -41255,7 +41018,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41255
41018
|
...sessionId ? { sessionId } : {},
|
|
41256
41019
|
...runId ? { runId } : {},
|
|
41257
41020
|
...result,
|
|
41258
|
-
...planningTodosSubmit.suppressOutput ? { output: void 0 } : planningFallbackOutput.trim() !== "" ? { output: planningFallbackOutput } : {},
|
|
41259
41021
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
41260
41022
|
...augmentPromptResultAuthFields(agentType, errStr),
|
|
41261
41023
|
...!result.success && cancelledByAgent ? { stopReason: "cancelled" } : {}
|
|
@@ -41283,14 +41045,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41283
41045
|
async function prepareAgentPromptText(params) {
|
|
41284
41046
|
const { promptText, sessionId, runId, isNewSession, plugin } = params;
|
|
41285
41047
|
if (plugin?.cloud?.prepareAgentPromptText) {
|
|
41286
|
-
|
|
41048
|
+
return plugin.cloud.prepareAgentPromptText({
|
|
41287
41049
|
promptText,
|
|
41288
41050
|
sessionId,
|
|
41289
41051
|
runId,
|
|
41290
41052
|
isNewSession
|
|
41291
41053
|
});
|
|
41292
|
-
if (prepared.isPlanningSession && runId) registerPlanningSessionTurn(runId);
|
|
41293
|
-
return prepared;
|
|
41294
41054
|
}
|
|
41295
41055
|
return { agentPromptText: promptText, isPlanningSession: false };
|
|
41296
41056
|
}
|
|
@@ -41366,7 +41126,6 @@ async function sendPromptToAgent(options) {
|
|
|
41366
41126
|
attachments,
|
|
41367
41127
|
isNewSession = false
|
|
41368
41128
|
} = options;
|
|
41369
|
-
let isPlanningSession = false;
|
|
41370
41129
|
try {
|
|
41371
41130
|
const prepared = await prepareAgentPromptText({
|
|
41372
41131
|
promptText,
|
|
@@ -41375,7 +41134,6 @@ async function sendPromptToAgent(options) {
|
|
|
41375
41134
|
isNewSession,
|
|
41376
41135
|
plugin
|
|
41377
41136
|
});
|
|
41378
|
-
isPlanningSession = prepared.isPlanningSession;
|
|
41379
41137
|
const imagesResolved = await resolveSendPromptImages({
|
|
41380
41138
|
attachments,
|
|
41381
41139
|
sessionId,
|
|
@@ -41404,7 +41162,6 @@ async function sendPromptToAgent(options) {
|
|
|
41404
41162
|
promptId,
|
|
41405
41163
|
agentType,
|
|
41406
41164
|
agentCwd,
|
|
41407
|
-
isPlanningSession,
|
|
41408
41165
|
followUpCatalogPromptId,
|
|
41409
41166
|
plugin,
|
|
41410
41167
|
sendResult,
|
|
@@ -41424,8 +41181,6 @@ async function sendPromptToAgent(options) {
|
|
|
41424
41181
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
41425
41182
|
...augmentPromptResultAuthFields(agentType, errMsg)
|
|
41426
41183
|
});
|
|
41427
|
-
} finally {
|
|
41428
|
-
if (runId && isPlanningSession) clearPlanningSessionTurn(runId);
|
|
41429
41184
|
}
|
|
41430
41185
|
}
|
|
41431
41186
|
|
|
@@ -41600,6 +41355,7 @@ async function createAcpManager(options) {
|
|
|
41600
41355
|
logPromptReceivedFromBridge: (opts) => logPromptReceivedFromBridge(ctx, opts),
|
|
41601
41356
|
handlePrompt: (opts) => handlePrompt(ctx, opts),
|
|
41602
41357
|
cancelRun: (runId) => cancelRun(ctx, runId),
|
|
41358
|
+
isRegisteredRun: (runId) => ctx.promptRouting.isRegisteredRun(runId),
|
|
41603
41359
|
resolveRequest(requestId, result) {
|
|
41604
41360
|
for (const state of ctx.acpAgents.values()) {
|
|
41605
41361
|
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
@@ -41875,8 +41631,8 @@ function decryptCliE2eeMessageField(payload, field, e2ee) {
|
|
|
41875
41631
|
}
|
|
41876
41632
|
|
|
41877
41633
|
// ../bridge/src/e2ee/certificates.ts
|
|
41878
|
-
import * as
|
|
41879
|
-
import * as
|
|
41634
|
+
import * as fs19 from "node:fs/promises";
|
|
41635
|
+
import * as path32 from "node:path";
|
|
41880
41636
|
var E2E_CERTIFICATE_ALGORITHM = "A1";
|
|
41881
41637
|
var CERTIFICATE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".pem", ".key", ".crt"]);
|
|
41882
41638
|
function certificateFromKey({
|
|
@@ -41897,12 +41653,12 @@ function certificateFromKey({
|
|
|
41897
41653
|
}
|
|
41898
41654
|
}
|
|
41899
41655
|
function baseNameForCertificate(fileName) {
|
|
41900
|
-
return
|
|
41656
|
+
return path32.basename(fileName, path32.extname(fileName)) || "BuildAutomaton E2EE certificate";
|
|
41901
41657
|
}
|
|
41902
41658
|
async function readCertificateFiles(directory) {
|
|
41903
41659
|
let entries;
|
|
41904
41660
|
try {
|
|
41905
|
-
entries = await
|
|
41661
|
+
entries = await fs19.readdir(directory, { withFileTypes: true });
|
|
41906
41662
|
} catch (err) {
|
|
41907
41663
|
const nodeErr = err;
|
|
41908
41664
|
if (nodeErr.code === "ENOENT") return [];
|
|
@@ -41910,11 +41666,11 @@ async function readCertificateFiles(directory) {
|
|
|
41910
41666
|
}
|
|
41911
41667
|
const certificates = [];
|
|
41912
41668
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
41913
|
-
if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(
|
|
41914
|
-
const filePath =
|
|
41915
|
-
const raw = await
|
|
41669
|
+
if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(path32.extname(entry.name).toLowerCase())) continue;
|
|
41670
|
+
const filePath = path32.join(directory, entry.name);
|
|
41671
|
+
const raw = await fs19.readFile(filePath, "utf8").catch(() => void 0);
|
|
41916
41672
|
if (!raw) continue;
|
|
41917
|
-
const stat3 = await
|
|
41673
|
+
const stat3 = await fs19.stat(filePath).catch(() => void 0);
|
|
41918
41674
|
const certificate = certificateFromKey({
|
|
41919
41675
|
raw,
|
|
41920
41676
|
name: baseNameForCertificate(entry.name),
|
|
@@ -41927,7 +41683,7 @@ async function readCertificateFiles(directory) {
|
|
|
41927
41683
|
return certificates;
|
|
41928
41684
|
}
|
|
41929
41685
|
function createCertificate(directory) {
|
|
41930
|
-
const baseName =
|
|
41686
|
+
const baseName = path32.basename(directory) || "BuildAutomaton E2EE certificate";
|
|
41931
41687
|
const key = createE2eeKeyRecord(baseName);
|
|
41932
41688
|
return {
|
|
41933
41689
|
...key,
|
|
@@ -41936,8 +41692,8 @@ function createCertificate(directory) {
|
|
|
41936
41692
|
};
|
|
41937
41693
|
}
|
|
41938
41694
|
async function loadOrCreateE2eCertificates(directory) {
|
|
41939
|
-
const resolved =
|
|
41940
|
-
await
|
|
41695
|
+
const resolved = path32.resolve(directory);
|
|
41696
|
+
await fs19.mkdir(resolved, { recursive: true, mode: 448 });
|
|
41941
41697
|
const existing = await readCertificateFiles(resolved);
|
|
41942
41698
|
if (existing.length > 0) {
|
|
41943
41699
|
return {
|
|
@@ -41949,7 +41705,7 @@ async function loadOrCreateE2eCertificates(directory) {
|
|
|
41949
41705
|
}
|
|
41950
41706
|
const certificate = createCertificate(resolved);
|
|
41951
41707
|
const fileName = `buildautomaton-e2ee-key-${certificate.id.slice(0, 12)}.pem`;
|
|
41952
|
-
await
|
|
41708
|
+
await fs19.writeFile(path32.join(resolved, fileName), certificate.pemBundle, {
|
|
41953
41709
|
mode: 384
|
|
41954
41710
|
});
|
|
41955
41711
|
return {
|
|
@@ -42142,7 +41898,7 @@ async function createBridgeAccessState(options) {
|
|
|
42142
41898
|
}
|
|
42143
41899
|
|
|
42144
41900
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
42145
|
-
import * as
|
|
41901
|
+
import * as path34 from "node:path";
|
|
42146
41902
|
|
|
42147
41903
|
// ../bridge/src/agents/detect-local-agent-types.ts
|
|
42148
41904
|
init_yield_to_event_loop();
|
|
@@ -42264,7 +42020,7 @@ function shouldSkipCapabilityProbeThisProcess(agentType) {
|
|
|
42264
42020
|
}
|
|
42265
42021
|
|
|
42266
42022
|
// ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
42267
|
-
import * as
|
|
42023
|
+
import * as path33 from "node:path";
|
|
42268
42024
|
init_cli_database();
|
|
42269
42025
|
init_yield_to_event_loop();
|
|
42270
42026
|
init_cli_process_interrupt();
|
|
@@ -42290,7 +42046,7 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
42290
42046
|
try {
|
|
42291
42047
|
handle = await resolved.createClient({
|
|
42292
42048
|
command: resolved.command,
|
|
42293
|
-
cwd:
|
|
42049
|
+
cwd: path33.resolve(cwd),
|
|
42294
42050
|
backendAgentType: agentType,
|
|
42295
42051
|
sessionMode: "agent",
|
|
42296
42052
|
persistedAcpSessionId: null,
|
|
@@ -42380,7 +42136,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
42380
42136
|
const { workspaceId, log: log2, getWs } = params;
|
|
42381
42137
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
42382
42138
|
if (!isCurrent()) return;
|
|
42383
|
-
const cwd =
|
|
42139
|
+
const cwd = path34.resolve(getBridgeRoot());
|
|
42384
42140
|
async function sendBatchFromCache() {
|
|
42385
42141
|
if (!isCurrent()) return;
|
|
42386
42142
|
const socket = getWs();
|
|
@@ -42489,7 +42245,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
42489
42245
|
}
|
|
42490
42246
|
|
|
42491
42247
|
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
42492
|
-
import * as
|
|
42248
|
+
import * as path37 from "node:path";
|
|
42493
42249
|
|
|
42494
42250
|
// ../bridge/src/preview-environments/manager/firehose-messages.ts
|
|
42495
42251
|
function buildFirehoseSnapshotMessage(params) {
|
|
@@ -42807,7 +42563,7 @@ function attachChildErrorHandler(d) {
|
|
|
42807
42563
|
}
|
|
42808
42564
|
|
|
42809
42565
|
// ../bridge/src/preview-environments/process/wire/handle-exit.ts
|
|
42810
|
-
import
|
|
42566
|
+
import fs20 from "node:fs";
|
|
42811
42567
|
function logStopLine(d, code, signal) {
|
|
42812
42568
|
const { title } = d;
|
|
42813
42569
|
if (signal) {
|
|
@@ -42846,7 +42602,7 @@ function attachChildExitHandler(d) {
|
|
|
42846
42602
|
const cleanupDir = d.mergedCleanupDir;
|
|
42847
42603
|
const mergedPath = d.mergedLogPath;
|
|
42848
42604
|
if (mergedPath && !stale) {
|
|
42849
|
-
|
|
42605
|
+
fs20.readFile(mergedPath, (err, buf) => {
|
|
42850
42606
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
42851
42607
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
42852
42608
|
if (chunk.length > 0) {
|
|
@@ -42892,7 +42648,7 @@ function wireChildOutputPipes(d) {
|
|
|
42892
42648
|
}
|
|
42893
42649
|
|
|
42894
42650
|
// ../bridge/src/preview-environments/process/wire/poll-merged-log.ts
|
|
42895
|
-
import
|
|
42651
|
+
import fs21 from "node:fs";
|
|
42896
42652
|
function startMergedLogPoll(d) {
|
|
42897
42653
|
if (!d.mergedLogPath || !d.mergedCleanupDir) return;
|
|
42898
42654
|
const { environmentId } = d;
|
|
@@ -42902,7 +42658,7 @@ function startMergedLogPoll(d) {
|
|
|
42902
42658
|
d.setPollInterval(void 0);
|
|
42903
42659
|
return;
|
|
42904
42660
|
}
|
|
42905
|
-
|
|
42661
|
+
fs21.readFile(d.mergedLogPath, (err, buf) => {
|
|
42906
42662
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
42907
42663
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
42908
42664
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -43117,7 +42873,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
|
|
|
43117
42873
|
}
|
|
43118
42874
|
|
|
43119
42875
|
// ../bridge/src/preview-environments/manager/shell-spawn/utils.ts
|
|
43120
|
-
import
|
|
42876
|
+
import fs22 from "node:fs";
|
|
43121
42877
|
function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
|
|
43122
42878
|
return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
|
|
43123
42879
|
}
|
|
@@ -43126,7 +42882,7 @@ function isSpawnEbadf(e) {
|
|
|
43126
42882
|
}
|
|
43127
42883
|
function rmDirQuiet(dir) {
|
|
43128
42884
|
try {
|
|
43129
|
-
|
|
42885
|
+
fs22.rmSync(dir, { recursive: true, force: true });
|
|
43130
42886
|
} catch {
|
|
43131
42887
|
}
|
|
43132
42888
|
}
|
|
@@ -43134,7 +42890,7 @@ var cachedDevNullReadFd;
|
|
|
43134
42890
|
function devNullReadFd() {
|
|
43135
42891
|
if (cachedDevNullReadFd === void 0) {
|
|
43136
42892
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
43137
|
-
cachedDevNullReadFd =
|
|
42893
|
+
cachedDevNullReadFd = fs22.openSync(devPath, "r");
|
|
43138
42894
|
}
|
|
43139
42895
|
return cachedDevNullReadFd;
|
|
43140
42896
|
}
|
|
@@ -43214,15 +42970,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
43214
42970
|
|
|
43215
42971
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
43216
42972
|
import { spawn as spawn7 } from "node:child_process";
|
|
43217
|
-
import
|
|
42973
|
+
import fs23 from "node:fs";
|
|
43218
42974
|
import { tmpdir } from "node:os";
|
|
43219
|
-
import
|
|
42975
|
+
import path35 from "node:path";
|
|
43220
42976
|
function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
43221
|
-
const tmpRoot =
|
|
43222
|
-
const logPath =
|
|
42977
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir(), "ba-devsrv-log-"));
|
|
42978
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
43223
42979
|
let logFd;
|
|
43224
42980
|
try {
|
|
43225
|
-
logFd =
|
|
42981
|
+
logFd = fs23.openSync(logPath, "a");
|
|
43226
42982
|
} catch {
|
|
43227
42983
|
rmDirQuiet(tmpRoot);
|
|
43228
42984
|
return null;
|
|
@@ -43246,7 +43002,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43246
43002
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
43247
43003
|
);
|
|
43248
43004
|
}
|
|
43249
|
-
|
|
43005
|
+
fs23.closeSync(logFd);
|
|
43250
43006
|
return {
|
|
43251
43007
|
proc,
|
|
43252
43008
|
pipedStdoutStderr: true,
|
|
@@ -43255,7 +43011,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43255
43011
|
};
|
|
43256
43012
|
} catch (e) {
|
|
43257
43013
|
try {
|
|
43258
|
-
|
|
43014
|
+
fs23.closeSync(logFd);
|
|
43259
43015
|
} catch {
|
|
43260
43016
|
}
|
|
43261
43017
|
rmDirQuiet(tmpRoot);
|
|
@@ -43266,22 +43022,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43266
43022
|
|
|
43267
43023
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
43268
43024
|
import { spawn as spawn8 } from "node:child_process";
|
|
43269
|
-
import
|
|
43025
|
+
import fs24 from "node:fs";
|
|
43270
43026
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
43271
|
-
import
|
|
43027
|
+
import path36 from "node:path";
|
|
43272
43028
|
function shSingleQuote(s) {
|
|
43273
43029
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
43274
43030
|
}
|
|
43275
43031
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
|
|
43276
|
-
const tmpRoot =
|
|
43277
|
-
const logPath =
|
|
43278
|
-
const innerPath =
|
|
43279
|
-
const runnerPath =
|
|
43032
|
+
const tmpRoot = fs24.mkdtempSync(path36.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
43033
|
+
const logPath = path36.join(tmpRoot, "combined.log");
|
|
43034
|
+
const innerPath = path36.join(tmpRoot, "_cmd.sh");
|
|
43035
|
+
const runnerPath = path36.join(tmpRoot, "_run.sh");
|
|
43280
43036
|
try {
|
|
43281
|
-
|
|
43037
|
+
fs24.writeFileSync(innerPath, `#!/bin/sh
|
|
43282
43038
|
${command}
|
|
43283
43039
|
`);
|
|
43284
|
-
|
|
43040
|
+
fs24.writeFileSync(
|
|
43285
43041
|
runnerPath,
|
|
43286
43042
|
`#!/bin/sh
|
|
43287
43043
|
cd ${shSingleQuote(cwd)}
|
|
@@ -43309,13 +43065,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
43309
43065
|
}
|
|
43310
43066
|
}
|
|
43311
43067
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
|
|
43312
|
-
const tmpRoot =
|
|
43313
|
-
const logPath =
|
|
43314
|
-
const runnerPath =
|
|
43068
|
+
const tmpRoot = fs24.mkdtempSync(path36.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
43069
|
+
const logPath = path36.join(tmpRoot, "combined.log");
|
|
43070
|
+
const runnerPath = path36.join(tmpRoot, "_run.bat");
|
|
43315
43071
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
43316
43072
|
const com = process.env.ComSpec || "cmd.exe";
|
|
43317
43073
|
try {
|
|
43318
|
-
|
|
43074
|
+
fs24.writeFileSync(
|
|
43319
43075
|
runnerPath,
|
|
43320
43076
|
`@ECHO OFF\r
|
|
43321
43077
|
CD /D ${q(cwd)}\r
|
|
@@ -43633,8 +43389,8 @@ function createBridgePreviewStack(options) {
|
|
|
43633
43389
|
scheduleInitialIndexBuilds(getBridgeRoot());
|
|
43634
43390
|
};
|
|
43635
43391
|
const identifyReportedPaths = {
|
|
43636
|
-
bridgeRootPath:
|
|
43637
|
-
worktreesRootPath:
|
|
43392
|
+
bridgeRootPath: path37.resolve(getBridgeRoot()),
|
|
43393
|
+
worktreesRootPath: path37.resolve(options.worktreesRootPath),
|
|
43638
43394
|
localShortcutPort: 0,
|
|
43639
43395
|
localShortcutToken: ""
|
|
43640
43396
|
};
|
|
@@ -43836,7 +43592,7 @@ function createBridgeHeartbeatController(params) {
|
|
|
43836
43592
|
}
|
|
43837
43593
|
|
|
43838
43594
|
// ../bridge/src/cli/cli-version.ts
|
|
43839
|
-
var CLI_VERSION2 = "0.1.
|
|
43595
|
+
var CLI_VERSION2 = "0.1.96".length > 0 ? "0.1.96" : "0.0.0-dev";
|
|
43840
43596
|
|
|
43841
43597
|
// ../bridge/src/connection/identify/send-bridge-identify.ts
|
|
43842
43598
|
function sendBridgeIdentify(ws, params) {
|
|
@@ -44007,12 +43763,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
44007
43763
|
}
|
|
44008
43764
|
|
|
44009
43765
|
// ../bridge/src/worktrees/worktree-layout-file.ts
|
|
44010
|
-
import * as
|
|
44011
|
-
import * as
|
|
44012
|
-
import
|
|
43766
|
+
import * as fs25 from "node:fs";
|
|
43767
|
+
import * as path38 from "node:path";
|
|
43768
|
+
import os6 from "node:os";
|
|
44013
43769
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
44014
43770
|
function defaultWorktreeLayoutPath() {
|
|
44015
|
-
return
|
|
43771
|
+
return path38.join(os6.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
44016
43772
|
}
|
|
44017
43773
|
function normalizeLoadedLayout(raw) {
|
|
44018
43774
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -44024,8 +43780,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
44024
43780
|
function loadWorktreeLayout() {
|
|
44025
43781
|
try {
|
|
44026
43782
|
const p = defaultWorktreeLayoutPath();
|
|
44027
|
-
if (!
|
|
44028
|
-
const raw = JSON.parse(
|
|
43783
|
+
if (!fs25.existsSync(p)) return { launcherCwds: [] };
|
|
43784
|
+
const raw = JSON.parse(fs25.readFileSync(p, "utf8"));
|
|
44029
43785
|
return normalizeLoadedLayout(raw);
|
|
44030
43786
|
} catch {
|
|
44031
43787
|
return { launcherCwds: [] };
|
|
@@ -44033,24 +43789,24 @@ function loadWorktreeLayout() {
|
|
|
44033
43789
|
}
|
|
44034
43790
|
function saveWorktreeLayout(layout) {
|
|
44035
43791
|
try {
|
|
44036
|
-
const dir =
|
|
44037
|
-
|
|
44038
|
-
|
|
43792
|
+
const dir = path38.dirname(defaultWorktreeLayoutPath());
|
|
43793
|
+
fs25.mkdirSync(dir, { recursive: true });
|
|
43794
|
+
fs25.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
44039
43795
|
} catch {
|
|
44040
43796
|
}
|
|
44041
43797
|
}
|
|
44042
43798
|
function baseNameSafe(pathString) {
|
|
44043
|
-
return
|
|
43799
|
+
return path38.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
44044
43800
|
}
|
|
44045
43801
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
44046
|
-
const norm =
|
|
44047
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
43802
|
+
const norm = path38.resolve(bridgeRootPath2);
|
|
43803
|
+
const existing = layout.launcherCwds.find((e) => path38.resolve(e.absolutePath) === norm);
|
|
44048
43804
|
return existing?.dirName;
|
|
44049
43805
|
}
|
|
44050
43806
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
44051
43807
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
44052
43808
|
if (existing) return existing;
|
|
44053
|
-
const norm =
|
|
43809
|
+
const norm = path38.resolve(bridgeRootPath2);
|
|
44054
43810
|
const base = baseNameSafe(norm);
|
|
44055
43811
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
44056
43812
|
let name = base;
|
|
@@ -44143,8 +43899,8 @@ function pathspec(...paths) {
|
|
|
44143
43899
|
cache.set(key, paths);
|
|
44144
43900
|
return key;
|
|
44145
43901
|
}
|
|
44146
|
-
function isPathSpec(
|
|
44147
|
-
return
|
|
43902
|
+
function isPathSpec(path86) {
|
|
43903
|
+
return path86 instanceof String && cache.has(path86);
|
|
44148
43904
|
}
|
|
44149
43905
|
function toPaths(pathSpec) {
|
|
44150
43906
|
return cache.get(pathSpec) || [];
|
|
@@ -44233,8 +43989,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
44233
43989
|
function forEachLineWithContent(input, callback) {
|
|
44234
43990
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
44235
43991
|
}
|
|
44236
|
-
function folderExists(
|
|
44237
|
-
return (0, import_file_exists.exists)(
|
|
43992
|
+
function folderExists(path86) {
|
|
43993
|
+
return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
|
|
44238
43994
|
}
|
|
44239
43995
|
function append(target, item) {
|
|
44240
43996
|
if (Array.isArray(target)) {
|
|
@@ -44638,8 +44394,8 @@ function checkIsRepoRootTask() {
|
|
|
44638
44394
|
commands,
|
|
44639
44395
|
format: "utf-8",
|
|
44640
44396
|
onError,
|
|
44641
|
-
parser(
|
|
44642
|
-
return /^\.(git)?$/.test(
|
|
44397
|
+
parser(path86) {
|
|
44398
|
+
return /^\.(git)?$/.test(path86.trim());
|
|
44643
44399
|
}
|
|
44644
44400
|
};
|
|
44645
44401
|
}
|
|
@@ -45073,11 +44829,11 @@ function parseGrep(grep) {
|
|
|
45073
44829
|
const paths = /* @__PURE__ */ new Set();
|
|
45074
44830
|
const results = {};
|
|
45075
44831
|
forEachLineWithContent(grep, (input) => {
|
|
45076
|
-
const [
|
|
45077
|
-
paths.add(
|
|
45078
|
-
(results[
|
|
44832
|
+
const [path86, line, preview] = input.split(NULL);
|
|
44833
|
+
paths.add(path86);
|
|
44834
|
+
(results[path86] = results[path86] || []).push({
|
|
45079
44835
|
line: asNumber(line),
|
|
45080
|
-
path:
|
|
44836
|
+
path: path86,
|
|
45081
44837
|
preview
|
|
45082
44838
|
});
|
|
45083
44839
|
});
|
|
@@ -45842,14 +45598,14 @@ var init_hash_object = __esm2({
|
|
|
45842
45598
|
init_task();
|
|
45843
45599
|
}
|
|
45844
45600
|
});
|
|
45845
|
-
function parseInit(bare,
|
|
45601
|
+
function parseInit(bare, path86, text) {
|
|
45846
45602
|
const response = String(text).trim();
|
|
45847
45603
|
let result;
|
|
45848
45604
|
if (result = initResponseRegex.exec(response)) {
|
|
45849
|
-
return new InitSummary(bare,
|
|
45605
|
+
return new InitSummary(bare, path86, false, result[1]);
|
|
45850
45606
|
}
|
|
45851
45607
|
if (result = reInitResponseRegex.exec(response)) {
|
|
45852
|
-
return new InitSummary(bare,
|
|
45608
|
+
return new InitSummary(bare, path86, true, result[1]);
|
|
45853
45609
|
}
|
|
45854
45610
|
let gitDir = "";
|
|
45855
45611
|
const tokens = response.split(" ");
|
|
@@ -45860,7 +45616,7 @@ function parseInit(bare, path88, text) {
|
|
|
45860
45616
|
break;
|
|
45861
45617
|
}
|
|
45862
45618
|
}
|
|
45863
|
-
return new InitSummary(bare,
|
|
45619
|
+
return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
|
|
45864
45620
|
}
|
|
45865
45621
|
var InitSummary;
|
|
45866
45622
|
var initResponseRegex;
|
|
@@ -45869,9 +45625,9 @@ var init_InitSummary = __esm2({
|
|
|
45869
45625
|
"src/lib/responses/InitSummary.ts"() {
|
|
45870
45626
|
"use strict";
|
|
45871
45627
|
InitSummary = class {
|
|
45872
|
-
constructor(bare,
|
|
45628
|
+
constructor(bare, path86, existing, gitDir) {
|
|
45873
45629
|
this.bare = bare;
|
|
45874
|
-
this.path =
|
|
45630
|
+
this.path = path86;
|
|
45875
45631
|
this.existing = existing;
|
|
45876
45632
|
this.gitDir = gitDir;
|
|
45877
45633
|
}
|
|
@@ -45883,7 +45639,7 @@ var init_InitSummary = __esm2({
|
|
|
45883
45639
|
function hasBareCommand(command) {
|
|
45884
45640
|
return command.includes(bareCommand);
|
|
45885
45641
|
}
|
|
45886
|
-
function initTask(bare = false,
|
|
45642
|
+
function initTask(bare = false, path86, customArgs) {
|
|
45887
45643
|
const commands = ["init", ...customArgs];
|
|
45888
45644
|
if (bare && !hasBareCommand(commands)) {
|
|
45889
45645
|
commands.splice(1, 0, bareCommand);
|
|
@@ -45892,7 +45648,7 @@ function initTask(bare = false, path88, customArgs) {
|
|
|
45892
45648
|
commands,
|
|
45893
45649
|
format: "utf-8",
|
|
45894
45650
|
parser(text) {
|
|
45895
|
-
return parseInit(commands.includes("--bare"),
|
|
45651
|
+
return parseInit(commands.includes("--bare"), path86, text);
|
|
45896
45652
|
}
|
|
45897
45653
|
};
|
|
45898
45654
|
}
|
|
@@ -46708,12 +46464,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
46708
46464
|
"use strict";
|
|
46709
46465
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
46710
46466
|
FileStatusSummary = class {
|
|
46711
|
-
constructor(
|
|
46712
|
-
this.path =
|
|
46467
|
+
constructor(path86, index, working_dir) {
|
|
46468
|
+
this.path = path86;
|
|
46713
46469
|
this.index = index;
|
|
46714
46470
|
this.working_dir = working_dir;
|
|
46715
46471
|
if (index === "R" || working_dir === "R") {
|
|
46716
|
-
const detail = fromPathRegex.exec(
|
|
46472
|
+
const detail = fromPathRegex.exec(path86) || [null, path86, path86];
|
|
46717
46473
|
this.from = detail[2] || "";
|
|
46718
46474
|
this.path = detail[1] || "";
|
|
46719
46475
|
}
|
|
@@ -46744,14 +46500,14 @@ function splitLine(result, lineStr) {
|
|
|
46744
46500
|
default:
|
|
46745
46501
|
return;
|
|
46746
46502
|
}
|
|
46747
|
-
function data(index, workingDir,
|
|
46503
|
+
function data(index, workingDir, path86) {
|
|
46748
46504
|
const raw = `${index}${workingDir}`;
|
|
46749
46505
|
const handler = parsers6.get(raw);
|
|
46750
46506
|
if (handler) {
|
|
46751
|
-
handler(result,
|
|
46507
|
+
handler(result, path86);
|
|
46752
46508
|
}
|
|
46753
46509
|
if (raw !== "##" && raw !== "!!") {
|
|
46754
|
-
result.files.push(new FileStatusSummary(
|
|
46510
|
+
result.files.push(new FileStatusSummary(path86, index, workingDir));
|
|
46755
46511
|
}
|
|
46756
46512
|
}
|
|
46757
46513
|
}
|
|
@@ -47060,9 +46816,9 @@ var init_simple_git_api = __esm2({
|
|
|
47060
46816
|
next
|
|
47061
46817
|
);
|
|
47062
46818
|
}
|
|
47063
|
-
hashObject(
|
|
46819
|
+
hashObject(path86, write) {
|
|
47064
46820
|
return this._runTask(
|
|
47065
|
-
hashObjectTask(
|
|
46821
|
+
hashObjectTask(path86, write === true),
|
|
47066
46822
|
trailingFunctionArgument(arguments)
|
|
47067
46823
|
);
|
|
47068
46824
|
}
|
|
@@ -47415,8 +47171,8 @@ var init_branch = __esm2({
|
|
|
47415
47171
|
}
|
|
47416
47172
|
});
|
|
47417
47173
|
function toPath(input) {
|
|
47418
|
-
const
|
|
47419
|
-
return
|
|
47174
|
+
const path86 = input.trim().replace(/^["']|["']$/g, "");
|
|
47175
|
+
return path86 && normalize3(path86);
|
|
47420
47176
|
}
|
|
47421
47177
|
var parseCheckIgnore;
|
|
47422
47178
|
var init_CheckIgnore = __esm2({
|
|
@@ -47730,8 +47486,8 @@ __export2(sub_module_exports, {
|
|
|
47730
47486
|
subModuleTask: () => subModuleTask,
|
|
47731
47487
|
updateSubModuleTask: () => updateSubModuleTask
|
|
47732
47488
|
});
|
|
47733
|
-
function addSubModuleTask(repo,
|
|
47734
|
-
return subModuleTask(["add", repo,
|
|
47489
|
+
function addSubModuleTask(repo, path86) {
|
|
47490
|
+
return subModuleTask(["add", repo, path86]);
|
|
47735
47491
|
}
|
|
47736
47492
|
function initSubModuleTask(customArgs) {
|
|
47737
47493
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -48064,8 +47820,8 @@ var require_git = __commonJS2({
|
|
|
48064
47820
|
}
|
|
48065
47821
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
48066
47822
|
};
|
|
48067
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
48068
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
47823
|
+
Git2.prototype.submoduleAdd = function(repo, path86, then) {
|
|
47824
|
+
return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
|
|
48069
47825
|
};
|
|
48070
47826
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
48071
47827
|
return this._runTask(
|
|
@@ -48804,8 +48560,8 @@ function parseNumstatEntries(lines) {
|
|
|
48804
48560
|
}
|
|
48805
48561
|
function parseNumstat(lines) {
|
|
48806
48562
|
const m = /* @__PURE__ */ new Map();
|
|
48807
|
-
for (const [
|
|
48808
|
-
m.set(
|
|
48563
|
+
for (const [path86, entry] of parseNumstatEntries(lines)) {
|
|
48564
|
+
m.set(path86, { additions: entry.additions, deletions: entry.deletions });
|
|
48809
48565
|
}
|
|
48810
48566
|
return m;
|
|
48811
48567
|
}
|
|
@@ -48934,7 +48690,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
48934
48690
|
}
|
|
48935
48691
|
|
|
48936
48692
|
// ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
48937
|
-
import * as
|
|
48693
|
+
import * as path39 from "node:path";
|
|
48938
48694
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
48939
48695
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
48940
48696
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -48945,7 +48701,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
48945
48701
|
}
|
|
48946
48702
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
48947
48703
|
if (repoDir) {
|
|
48948
|
-
const key =
|
|
48704
|
+
const key = path39.resolve(repoDir);
|
|
48949
48705
|
const now = Date.now();
|
|
48950
48706
|
const cached2 = baseShaCache.get(key);
|
|
48951
48707
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -49080,17 +48836,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
49080
48836
|
}
|
|
49081
48837
|
|
|
49082
48838
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
49083
|
-
import * as
|
|
48839
|
+
import * as path49 from "node:path";
|
|
49084
48840
|
|
|
49085
48841
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
49086
|
-
import * as
|
|
48842
|
+
import * as path48 from "node:path";
|
|
49087
48843
|
|
|
49088
48844
|
// ../bridge/src/git/is-git-repo.ts
|
|
49089
|
-
import * as
|
|
49090
|
-
import * as
|
|
48845
|
+
import * as fs26 from "node:fs";
|
|
48846
|
+
import * as path40 from "node:path";
|
|
49091
48847
|
async function isGitRepoDirectory(dirPath) {
|
|
49092
48848
|
try {
|
|
49093
|
-
await
|
|
48849
|
+
await fs26.promises.access(path40.join(dirPath, ".git"));
|
|
49094
48850
|
return true;
|
|
49095
48851
|
} catch {
|
|
49096
48852
|
return false;
|
|
@@ -49098,8 +48854,8 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
49098
48854
|
}
|
|
49099
48855
|
|
|
49100
48856
|
// ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
|
|
49101
|
-
import * as
|
|
49102
|
-
import * as
|
|
48857
|
+
import * as fs27 from "node:fs";
|
|
48858
|
+
import * as path41 from "node:path";
|
|
49103
48859
|
|
|
49104
48860
|
// ../bridge/src/git/changes/lines/count-lines.ts
|
|
49105
48861
|
import { createReadStream } from "node:fs";
|
|
@@ -49131,7 +48887,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
49131
48887
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
49132
48888
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
49133
48889
|
if (row.change === "moved") return;
|
|
49134
|
-
const repoFilePath =
|
|
48890
|
+
const repoFilePath = path41.join(options.repoGitCwd, pathInRepo);
|
|
49135
48891
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
49136
48892
|
if (fromGit) {
|
|
49137
48893
|
row.additions = fromGit.additions;
|
|
@@ -49139,7 +48895,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
49139
48895
|
return;
|
|
49140
48896
|
}
|
|
49141
48897
|
try {
|
|
49142
|
-
const st = await
|
|
48898
|
+
const st = await fs27.promises.stat(repoFilePath);
|
|
49143
48899
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
49144
48900
|
} catch {
|
|
49145
48901
|
row.additions = 0;
|
|
@@ -49216,7 +48972,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
49216
48972
|
}
|
|
49217
48973
|
|
|
49218
48974
|
// ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
49219
|
-
import * as
|
|
48975
|
+
import * as path43 from "node:path";
|
|
49220
48976
|
|
|
49221
48977
|
// ../bridge/src/git/changes/patch/patch-truncate.ts
|
|
49222
48978
|
function truncatePatch(s) {
|
|
@@ -49304,10 +49060,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
49304
49060
|
}
|
|
49305
49061
|
|
|
49306
49062
|
// ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
49307
|
-
import * as
|
|
49063
|
+
import * as fs28 from "node:fs";
|
|
49308
49064
|
async function readWorktreeFileLines(filePath) {
|
|
49309
49065
|
try {
|
|
49310
|
-
const raw = await
|
|
49066
|
+
const raw = await fs28.promises.readFile(filePath, "utf8");
|
|
49311
49067
|
return raw.split(/\r?\n/);
|
|
49312
49068
|
} catch {
|
|
49313
49069
|
return null;
|
|
@@ -49445,8 +49201,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
49445
49201
|
}
|
|
49446
49202
|
|
|
49447
49203
|
// ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
49448
|
-
import * as
|
|
49449
|
-
import * as
|
|
49204
|
+
import * as fs29 from "node:fs";
|
|
49205
|
+
import * as path42 from "node:path";
|
|
49450
49206
|
var MAX_BYTES = 512e3;
|
|
49451
49207
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
49452
49208
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -49466,13 +49222,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
49466
49222
|
}
|
|
49467
49223
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
49468
49224
|
if (options.isBinary) return null;
|
|
49469
|
-
const filePath =
|
|
49225
|
+
const filePath = path42.join(options.repoGitCwd, options.pathInRepo);
|
|
49470
49226
|
if (options.change === "removed") {
|
|
49471
49227
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
49472
49228
|
}
|
|
49473
49229
|
if (options.change === "moved" || options.change === "modified") {
|
|
49474
49230
|
try {
|
|
49475
|
-
const st = await
|
|
49231
|
+
const st = await fs29.promises.stat(filePath);
|
|
49476
49232
|
if (!st.isFile()) return null;
|
|
49477
49233
|
return await countTextFileLines(filePath);
|
|
49478
49234
|
} catch {
|
|
@@ -49515,7 +49271,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
49515
49271
|
row.workspaceRelPath,
|
|
49516
49272
|
options.repoPathRelativeToWorkspaceRoot
|
|
49517
49273
|
);
|
|
49518
|
-
const filePath =
|
|
49274
|
+
const filePath = path43.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
49519
49275
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
49520
49276
|
let patch = await unifiedDiffForFile(
|
|
49521
49277
|
options.repoGitCwd,
|
|
@@ -49673,7 +49429,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
49673
49429
|
}
|
|
49674
49430
|
|
|
49675
49431
|
// ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
|
|
49676
|
-
import * as
|
|
49432
|
+
import * as path44 from "node:path";
|
|
49677
49433
|
|
|
49678
49434
|
// ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
|
|
49679
49435
|
async function enrichCommitFileRows(options) {
|
|
@@ -49718,7 +49474,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
49718
49474
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
49719
49475
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
49720
49476
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
49721
|
-
return `${
|
|
49477
|
+
return `${path44.resolve(repoGitCwd)}:${commitSha}`;
|
|
49722
49478
|
}
|
|
49723
49479
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
49724
49480
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -49773,7 +49529,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
49773
49529
|
}
|
|
49774
49530
|
|
|
49775
49531
|
// ../bridge/src/git/commits/list-unpushed-commits.ts
|
|
49776
|
-
import * as
|
|
49532
|
+
import * as path45 from "node:path";
|
|
49777
49533
|
|
|
49778
49534
|
// ../bridge/src/git/commits/lib/parse-log-lines.ts
|
|
49779
49535
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -49808,7 +49564,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
49808
49564
|
}
|
|
49809
49565
|
}
|
|
49810
49566
|
async function listUnpushedCommits(repoDir) {
|
|
49811
|
-
const key =
|
|
49567
|
+
const key = path45.resolve(repoDir);
|
|
49812
49568
|
const now = Date.now();
|
|
49813
49569
|
const cached2 = unpushedCache.get(key);
|
|
49814
49570
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -49869,7 +49625,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
49869
49625
|
}
|
|
49870
49626
|
|
|
49871
49627
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
49872
|
-
import * as
|
|
49628
|
+
import * as path46 from "node:path";
|
|
49873
49629
|
|
|
49874
49630
|
// ../bridge/src/git/remote-origin-url.ts
|
|
49875
49631
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -49884,7 +49640,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
49884
49640
|
|
|
49885
49641
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
49886
49642
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
49887
|
-
const resolvedCheckoutPath =
|
|
49643
|
+
const resolvedCheckoutPath = path46.resolve(checkoutPath);
|
|
49888
49644
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
49889
49645
|
await yieldToEventLoop2();
|
|
49890
49646
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -49899,14 +49655,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
49899
49655
|
}
|
|
49900
49656
|
|
|
49901
49657
|
// ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
49902
|
-
import * as
|
|
49658
|
+
import * as path47 from "node:path";
|
|
49903
49659
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
49904
|
-
const checkoutPath =
|
|
49660
|
+
const checkoutPath = path47.resolve(options.checkoutPath);
|
|
49905
49661
|
const git = cliSimpleGit(checkoutPath);
|
|
49906
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49662
|
+
const sessionParentPath = options.sessionParentPath ? path47.resolve(options.sessionParentPath) : null;
|
|
49907
49663
|
let repoPathRelativeToWorkspaceRoot;
|
|
49908
49664
|
if (sessionParentPath) {
|
|
49909
|
-
const checkoutPathRelativeToSessionParent =
|
|
49665
|
+
const checkoutPathRelativeToSessionParent = path47.relative(sessionParentPath, checkoutPath);
|
|
49910
49666
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
49911
49667
|
} else {
|
|
49912
49668
|
let gitTopLevel = checkoutPath;
|
|
@@ -49916,8 +49672,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
49916
49672
|
} catch {
|
|
49917
49673
|
gitTopLevel = checkoutPath;
|
|
49918
49674
|
}
|
|
49919
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
49920
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
49675
|
+
const gitTopLevelRelativeToBridgeRoot = path47.relative(options.bridgeRoot, path47.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
49676
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path47.basename(path47.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
49921
49677
|
}
|
|
49922
49678
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
49923
49679
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -49926,10 +49682,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
49926
49682
|
|
|
49927
49683
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
49928
49684
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
49929
|
-
const checkoutPath =
|
|
49685
|
+
const checkoutPath = path48.resolve(options.targetPath);
|
|
49930
49686
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
49931
49687
|
const isCommitView = options.basis.kind === "commit";
|
|
49932
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49688
|
+
const sessionParentPath = options.sessionParentPath ? path48.resolve(options.sessionParentPath) : null;
|
|
49933
49689
|
const git = cliSimpleGit(checkoutPath);
|
|
49934
49690
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49935
49691
|
checkoutPath,
|
|
@@ -49977,8 +49733,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
49977
49733
|
|
|
49978
49734
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
49979
49735
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
49980
|
-
const bridgeRoot =
|
|
49981
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49736
|
+
const bridgeRoot = path49.resolve(getBridgeRoot());
|
|
49737
|
+
const sessionParentPath = options.sessionParentPath ? path49.resolve(options.sessionParentPath) : null;
|
|
49982
49738
|
const out = [];
|
|
49983
49739
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
49984
49740
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -50009,9 +49765,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
50009
49765
|
}
|
|
50010
49766
|
|
|
50011
49767
|
// ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
50012
|
-
import * as
|
|
49768
|
+
import * as path50 from "node:path";
|
|
50013
49769
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
50014
|
-
const repoGitCwd =
|
|
49770
|
+
const repoGitCwd = path50.resolve(options.repoGitCwd);
|
|
50015
49771
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
50016
49772
|
throw new Error("Not a git repository");
|
|
50017
49773
|
}
|
|
@@ -50050,7 +49806,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
50050
49806
|
});
|
|
50051
49807
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
50052
49808
|
}
|
|
50053
|
-
const filePath =
|
|
49809
|
+
const filePath = path50.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
50054
49810
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
50055
49811
|
let patchContent = await unifiedDiffForFile(
|
|
50056
49812
|
repoGitCwd,
|
|
@@ -50096,18 +49852,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
50096
49852
|
}
|
|
50097
49853
|
|
|
50098
49854
|
// ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
50099
|
-
import * as
|
|
49855
|
+
import * as path51 from "node:path";
|
|
50100
49856
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
50101
49857
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
50102
|
-
const bridgeRoot =
|
|
50103
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
49858
|
+
const bridgeRoot = path51.resolve(getBridgeRoot());
|
|
49859
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path51.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
50104
49860
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
50105
49861
|
opts.repoRelPath.trim()
|
|
50106
49862
|
);
|
|
50107
49863
|
let result = null;
|
|
50108
49864
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
50109
49865
|
if (result) return;
|
|
50110
|
-
const checkoutPath =
|
|
49866
|
+
const checkoutPath = path51.resolve(targetPath);
|
|
50111
49867
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
50112
49868
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
50113
49869
|
checkoutPath,
|
|
@@ -50140,13 +49896,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
50140
49896
|
}
|
|
50141
49897
|
|
|
50142
49898
|
// ../bridge/src/worktrees/remove-session-worktrees.ts
|
|
50143
|
-
import * as
|
|
49899
|
+
import * as fs32 from "node:fs";
|
|
50144
49900
|
|
|
50145
49901
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
50146
|
-
import * as
|
|
49902
|
+
import * as fs31 from "node:fs";
|
|
50147
49903
|
|
|
50148
49904
|
// ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
50149
|
-
import
|
|
49905
|
+
import path52 from "node:path";
|
|
50150
49906
|
init_normalize_resolved_path();
|
|
50151
49907
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
50152
49908
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -50155,23 +49911,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
50155
49911
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
50156
49912
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
50157
49913
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
50158
|
-
const rel =
|
|
50159
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
49914
|
+
const rel = path52.relative(worktreesRoot, normalized);
|
|
49915
|
+
if (rel === "" || rel.startsWith("..") || path52.isAbsolute(rel)) return false;
|
|
50160
49916
|
return true;
|
|
50161
49917
|
}
|
|
50162
49918
|
|
|
50163
49919
|
// ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
50164
|
-
import * as
|
|
50165
|
-
import * as
|
|
49920
|
+
import * as fs30 from "node:fs";
|
|
49921
|
+
import * as path53 from "node:path";
|
|
50166
49922
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
50167
|
-
const gitDirFile =
|
|
50168
|
-
if (!
|
|
50169
|
-
const first2 =
|
|
49923
|
+
const gitDirFile = path53.join(wt, ".git");
|
|
49924
|
+
if (!fs30.existsSync(gitDirFile) || !fs30.statSync(gitDirFile).isFile()) return "";
|
|
49925
|
+
const first2 = fs30.readFileSync(gitDirFile, "utf8").trim();
|
|
50170
49926
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
50171
49927
|
if (!m) return "";
|
|
50172
|
-
const gitWorktreePath =
|
|
50173
|
-
const gitDir =
|
|
50174
|
-
return
|
|
49928
|
+
const gitWorktreePath = path53.resolve(wt, m[1].trim());
|
|
49929
|
+
const gitDir = path53.dirname(path53.dirname(gitWorktreePath));
|
|
49930
|
+
return path53.dirname(gitDir);
|
|
50175
49931
|
}
|
|
50176
49932
|
|
|
50177
49933
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
@@ -50182,7 +49938,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
50182
49938
|
return true;
|
|
50183
49939
|
}
|
|
50184
49940
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
50185
|
-
|
|
49941
|
+
fs31.rmSync(worktreePath, { recursive: true, force: true });
|
|
50186
49942
|
return true;
|
|
50187
49943
|
}
|
|
50188
49944
|
|
|
@@ -50204,7 +49960,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
50204
49960
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
50205
49961
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
50206
49962
|
try {
|
|
50207
|
-
|
|
49963
|
+
fs32.rmSync(wt, { recursive: true, force: true });
|
|
50208
49964
|
} catch {
|
|
50209
49965
|
}
|
|
50210
49966
|
}
|
|
@@ -50260,12 +50016,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
50260
50016
|
// ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
50261
50017
|
init_cli_process_interrupt();
|
|
50262
50018
|
init_yield_to_event_loop();
|
|
50263
|
-
import * as
|
|
50264
|
-
import * as
|
|
50019
|
+
import * as fs36 from "node:fs";
|
|
50020
|
+
import * as path58 from "node:path";
|
|
50265
50021
|
|
|
50266
50022
|
// ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
|
|
50267
|
-
import * as
|
|
50268
|
-
import * as
|
|
50023
|
+
import * as fs34 from "node:fs";
|
|
50024
|
+
import * as path55 from "node:path";
|
|
50269
50025
|
|
|
50270
50026
|
// ../bridge/src/worktrees/discovery/disk-walk-constants.ts
|
|
50271
50027
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -50295,8 +50051,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
50295
50051
|
// ../bridge/src/worktrees/discovery/disk-walk-utils.ts
|
|
50296
50052
|
init_cli_process_interrupt();
|
|
50297
50053
|
init_yield_to_event_loop();
|
|
50298
|
-
import * as
|
|
50299
|
-
import * as
|
|
50054
|
+
import * as fs33 from "node:fs";
|
|
50055
|
+
import * as path54 from "node:path";
|
|
50300
50056
|
async function yieldDuringDiskWalk(state) {
|
|
50301
50057
|
state.entries++;
|
|
50302
50058
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -50306,7 +50062,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
50306
50062
|
}
|
|
50307
50063
|
async function isGitDir(dirPath) {
|
|
50308
50064
|
try {
|
|
50309
|
-
await
|
|
50065
|
+
await fs33.promises.access(path54.join(dirPath, ".git"));
|
|
50310
50066
|
return true;
|
|
50311
50067
|
} catch {
|
|
50312
50068
|
return false;
|
|
@@ -50320,23 +50076,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
50320
50076
|
const walk = async (dir) => {
|
|
50321
50077
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
50322
50078
|
if (await isGitDir(dir)) {
|
|
50323
|
-
out.push(
|
|
50079
|
+
out.push(path55.resolve(dir));
|
|
50324
50080
|
return;
|
|
50325
50081
|
}
|
|
50326
50082
|
let entries;
|
|
50327
50083
|
try {
|
|
50328
|
-
entries = await
|
|
50084
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
50329
50085
|
} catch {
|
|
50330
50086
|
return;
|
|
50331
50087
|
}
|
|
50332
50088
|
for (const e of entries) {
|
|
50333
50089
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
50334
|
-
const full =
|
|
50090
|
+
const full = path55.join(dir, e.name);
|
|
50335
50091
|
if (!e.isDirectory()) continue;
|
|
50336
50092
|
await walk(full);
|
|
50337
50093
|
}
|
|
50338
50094
|
};
|
|
50339
|
-
await walk(
|
|
50095
|
+
await walk(path55.resolve(rootPath));
|
|
50340
50096
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
50341
50097
|
}
|
|
50342
50098
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -50347,16 +50103,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
50347
50103
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
50348
50104
|
let entries;
|
|
50349
50105
|
try {
|
|
50350
|
-
entries = await
|
|
50106
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
50351
50107
|
} catch {
|
|
50352
50108
|
return;
|
|
50353
50109
|
}
|
|
50354
50110
|
for (const e of entries) {
|
|
50355
50111
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
50356
|
-
const full =
|
|
50112
|
+
const full = path55.join(dir, e.name);
|
|
50357
50113
|
if (!e.isDirectory()) continue;
|
|
50358
50114
|
if (e.name === sessionId) {
|
|
50359
|
-
if (await isGitDir(full)) out.push(
|
|
50115
|
+
if (await isGitDir(full)) out.push(path55.resolve(full));
|
|
50360
50116
|
continue;
|
|
50361
50117
|
}
|
|
50362
50118
|
if (await isGitDir(full)) continue;
|
|
@@ -50368,14 +50124,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
50368
50124
|
}
|
|
50369
50125
|
|
|
50370
50126
|
// ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
50371
|
-
import * as
|
|
50127
|
+
import * as path56 from "node:path";
|
|
50372
50128
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
50373
|
-
const bridge =
|
|
50129
|
+
const bridge = path56.resolve(bridgeRoot);
|
|
50374
50130
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
50375
50131
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
50376
|
-
const entry =
|
|
50377
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
50378
|
-
}).sort((a, b) =>
|
|
50132
|
+
const entry = path56.resolve(e.absolutePath);
|
|
50133
|
+
return bridge === entry || bridge.startsWith(entry + path56.sep) || entry.startsWith(bridge + path56.sep);
|
|
50134
|
+
}).sort((a, b) => path56.resolve(b.absolutePath).length - path56.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
50379
50135
|
const ordered = [];
|
|
50380
50136
|
const seen = /* @__PURE__ */ new Set();
|
|
50381
50137
|
const add = (k) => {
|
|
@@ -50393,19 +50149,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
50393
50149
|
}
|
|
50394
50150
|
|
|
50395
50151
|
// ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
50396
|
-
import * as
|
|
50397
|
-
import * as
|
|
50152
|
+
import * as fs35 from "node:fs";
|
|
50153
|
+
import * as path57 from "node:path";
|
|
50398
50154
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
50399
50155
|
let st;
|
|
50400
50156
|
try {
|
|
50401
|
-
st = await
|
|
50157
|
+
st = await fs35.promises.stat(scopeDir);
|
|
50402
50158
|
} catch {
|
|
50403
50159
|
return null;
|
|
50404
50160
|
}
|
|
50405
50161
|
if (!st.isDirectory()) return null;
|
|
50406
50162
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
50407
50163
|
if (worktreePaths.length === 0) return null;
|
|
50408
|
-
const abs =
|
|
50164
|
+
const abs = path57.resolve(scopeDir);
|
|
50409
50165
|
return {
|
|
50410
50166
|
parentPath: abs,
|
|
50411
50167
|
repoCheckoutPaths: worktreePaths
|
|
@@ -50428,7 +50184,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50428
50184
|
const sid = sessionId.trim();
|
|
50429
50185
|
if (!sid) return null;
|
|
50430
50186
|
try {
|
|
50431
|
-
await
|
|
50187
|
+
await fs36.promises.access(worktreesRootPath);
|
|
50432
50188
|
} catch {
|
|
50433
50189
|
return null;
|
|
50434
50190
|
}
|
|
@@ -50437,13 +50193,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50437
50193
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
50438
50194
|
const scanState = { entries: 0 };
|
|
50439
50195
|
try {
|
|
50440
|
-
for (const name of await
|
|
50196
|
+
for (const name of await fs36.promises.readdir(worktreesRootPath)) {
|
|
50441
50197
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
50442
50198
|
if (name.startsWith(".")) continue;
|
|
50443
|
-
const p =
|
|
50199
|
+
const p = path58.join(worktreesRootPath, name);
|
|
50444
50200
|
let st;
|
|
50445
50201
|
try {
|
|
50446
|
-
st = await
|
|
50202
|
+
st = await fs36.promises.stat(p);
|
|
50447
50203
|
} catch {
|
|
50448
50204
|
continue;
|
|
50449
50205
|
}
|
|
@@ -50457,23 +50213,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50457
50213
|
for (const key of keys) {
|
|
50458
50214
|
if (isCliImmediateShutdownRequested()) return null;
|
|
50459
50215
|
await yieldToEventLoop();
|
|
50460
|
-
const layoutRoot =
|
|
50216
|
+
const layoutRoot = path58.join(worktreesRootPath, key);
|
|
50461
50217
|
let layoutSt;
|
|
50462
50218
|
try {
|
|
50463
|
-
layoutSt = await
|
|
50219
|
+
layoutSt = await fs36.promises.stat(layoutRoot);
|
|
50464
50220
|
} catch {
|
|
50465
50221
|
continue;
|
|
50466
50222
|
}
|
|
50467
50223
|
if (!layoutSt.isDirectory()) continue;
|
|
50468
|
-
const sessionDir =
|
|
50224
|
+
const sessionDir = path58.join(layoutRoot, sid);
|
|
50469
50225
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
50470
50226
|
if (nested) return nested;
|
|
50471
50227
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
50472
50228
|
if (legacy.paths.length > 0) {
|
|
50473
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
50229
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path58.resolve(legacy.paths[0]);
|
|
50474
50230
|
return {
|
|
50475
|
-
sessionParentPath:
|
|
50476
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
50231
|
+
sessionParentPath: path58.resolve(isolated),
|
|
50232
|
+
repoCheckoutPaths: legacy.paths.map((p) => path58.resolve(p))
|
|
50477
50233
|
};
|
|
50478
50234
|
}
|
|
50479
50235
|
}
|
|
@@ -50481,31 +50237,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50481
50237
|
}
|
|
50482
50238
|
|
|
50483
50239
|
// ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
50484
|
-
import * as
|
|
50485
|
-
import * as
|
|
50240
|
+
import * as fs37 from "node:fs";
|
|
50241
|
+
import * as path60 from "node:path";
|
|
50486
50242
|
|
|
50487
50243
|
// ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
50488
50244
|
init_cli_process_interrupt();
|
|
50489
50245
|
init_yield_to_event_loop();
|
|
50490
|
-
import * as
|
|
50246
|
+
import * as path59 from "node:path";
|
|
50491
50247
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
50492
50248
|
const sid = sessionId.trim();
|
|
50493
50249
|
if (!sid) return null;
|
|
50494
|
-
const hintR =
|
|
50250
|
+
const hintR = path59.resolve(checkoutPath);
|
|
50495
50251
|
let best = null;
|
|
50496
|
-
let cur =
|
|
50252
|
+
let cur = path59.dirname(hintR);
|
|
50497
50253
|
for (let i = 0; i < 40; i++) {
|
|
50498
50254
|
if (isCliImmediateShutdownRequested()) return best;
|
|
50499
50255
|
await yieldToEventLoop();
|
|
50500
50256
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
50501
|
-
if (paths.paths.some((p) =>
|
|
50502
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
50257
|
+
if (paths.paths.some((p) => path59.resolve(p) === hintR)) {
|
|
50258
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path59.resolve(paths.paths[0]);
|
|
50503
50259
|
best = {
|
|
50504
|
-
sessionParentPath:
|
|
50505
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
50260
|
+
sessionParentPath: path59.resolve(isolated),
|
|
50261
|
+
repoCheckoutPaths: paths.paths.map((p) => path59.resolve(p))
|
|
50506
50262
|
};
|
|
50507
50263
|
}
|
|
50508
|
-
const next =
|
|
50264
|
+
const next = path59.dirname(cur);
|
|
50509
50265
|
if (next === cur) break;
|
|
50510
50266
|
cur = next;
|
|
50511
50267
|
}
|
|
@@ -50516,12 +50272,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
50516
50272
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
50517
50273
|
const sid = sessionId.trim();
|
|
50518
50274
|
if (!sid) return null;
|
|
50519
|
-
const hint =
|
|
50520
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
50275
|
+
const hint = path60.resolve(sessionParentPathOrHint);
|
|
50276
|
+
const underHint = await tryBindingFromSessionDirectory(path60.join(hint, sid));
|
|
50521
50277
|
if (underHint) return underHint;
|
|
50522
50278
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
50523
50279
|
if (direct) {
|
|
50524
|
-
if (
|
|
50280
|
+
if (path60.basename(hint) === sid && await isGitDir(hint)) {
|
|
50525
50281
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
50526
50282
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
50527
50283
|
return legacyFromCheckout;
|
|
@@ -50529,23 +50285,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
50529
50285
|
}
|
|
50530
50286
|
return direct;
|
|
50531
50287
|
}
|
|
50532
|
-
if (
|
|
50288
|
+
if (path60.basename(hint) === sid && await isGitDir(hint)) {
|
|
50533
50289
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
50534
50290
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
50535
50291
|
}
|
|
50536
50292
|
let st;
|
|
50537
50293
|
try {
|
|
50538
|
-
st = await
|
|
50294
|
+
st = await fs37.promises.stat(hint);
|
|
50539
50295
|
} catch {
|
|
50540
50296
|
return null;
|
|
50541
50297
|
}
|
|
50542
50298
|
if (!st.isDirectory()) return null;
|
|
50543
50299
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
50544
50300
|
if (legacyPaths.paths.length === 0) return null;
|
|
50545
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
50301
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path60.resolve(legacyPaths.paths[0]);
|
|
50546
50302
|
return {
|
|
50547
|
-
sessionParentPath:
|
|
50548
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
50303
|
+
sessionParentPath: path60.resolve(isolated),
|
|
50304
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path60.resolve(p))
|
|
50549
50305
|
};
|
|
50550
50306
|
}
|
|
50551
50307
|
|
|
@@ -50606,11 +50362,11 @@ function parseSessionParent(v) {
|
|
|
50606
50362
|
}
|
|
50607
50363
|
|
|
50608
50364
|
// ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
50609
|
-
import * as
|
|
50365
|
+
import * as fs41 from "node:fs";
|
|
50610
50366
|
|
|
50611
50367
|
// ../bridge/src/git/discover-repos.ts
|
|
50612
|
-
import * as
|
|
50613
|
-
import * as
|
|
50368
|
+
import * as fs38 from "node:fs";
|
|
50369
|
+
import * as path61 from "node:path";
|
|
50614
50370
|
init_yield_to_event_loop();
|
|
50615
50371
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
50616
50372
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -50620,14 +50376,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
50620
50376
|
}
|
|
50621
50377
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
50622
50378
|
const result = [];
|
|
50623
|
-
const cwdResolved =
|
|
50379
|
+
const cwdResolved = path61.resolve(cwd);
|
|
50624
50380
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
50625
50381
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
50626
50382
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
50627
50383
|
}
|
|
50628
50384
|
let entries;
|
|
50629
50385
|
try {
|
|
50630
|
-
entries =
|
|
50386
|
+
entries = fs38.readdirSync(cwdResolved, { withFileTypes: true });
|
|
50631
50387
|
} catch {
|
|
50632
50388
|
return result;
|
|
50633
50389
|
}
|
|
@@ -50635,7 +50391,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
50635
50391
|
await yieldGitDiscoverWork(i + 1);
|
|
50636
50392
|
const ent = entries[i];
|
|
50637
50393
|
if (!ent.isDirectory()) continue;
|
|
50638
|
-
const childPath2 =
|
|
50394
|
+
const childPath2 = path61.join(cwdResolved, ent.name);
|
|
50639
50395
|
if (await isGitRepoDirectory(childPath2)) {
|
|
50640
50396
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
50641
50397
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -50644,17 +50400,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
50644
50400
|
return result;
|
|
50645
50401
|
}
|
|
50646
50402
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
50647
|
-
const root =
|
|
50403
|
+
const root = path61.resolve(rootPath);
|
|
50648
50404
|
const roots = [];
|
|
50649
50405
|
let walkEntries = 0;
|
|
50650
50406
|
async function walk(dir) {
|
|
50651
50407
|
if (await isGitRepoDirectory(dir)) {
|
|
50652
|
-
roots.push(
|
|
50408
|
+
roots.push(path61.resolve(dir));
|
|
50653
50409
|
return;
|
|
50654
50410
|
}
|
|
50655
50411
|
let entries;
|
|
50656
50412
|
try {
|
|
50657
|
-
entries =
|
|
50413
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
50658
50414
|
} catch {
|
|
50659
50415
|
return;
|
|
50660
50416
|
}
|
|
@@ -50662,7 +50418,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
50662
50418
|
await yieldGitDiscoverWork(++walkEntries);
|
|
50663
50419
|
const ent = entries[i];
|
|
50664
50420
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
50665
|
-
await walk(
|
|
50421
|
+
await walk(path61.join(dir, ent.name));
|
|
50666
50422
|
}
|
|
50667
50423
|
}
|
|
50668
50424
|
await walk(root);
|
|
@@ -50678,8 +50434,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
50678
50434
|
}
|
|
50679
50435
|
|
|
50680
50436
|
// ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
50681
|
-
import * as
|
|
50682
|
-
import * as
|
|
50437
|
+
import * as fs40 from "node:fs";
|
|
50438
|
+
import * as path63 from "node:path";
|
|
50683
50439
|
|
|
50684
50440
|
// ../bridge/src/git/worktrees/worktree-add.ts
|
|
50685
50441
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -50695,8 +50451,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
50695
50451
|
}
|
|
50696
50452
|
|
|
50697
50453
|
// ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
50698
|
-
import * as
|
|
50699
|
-
import * as
|
|
50454
|
+
import * as fs39 from "node:fs";
|
|
50455
|
+
import * as path62 from "node:path";
|
|
50700
50456
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
50701
50457
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
50702
50458
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -50705,19 +50461,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
50705
50461
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
50706
50462
|
for (let i = 0; i < segments.length; i++) {
|
|
50707
50463
|
const prefix = segments.slice(0, i).join("/");
|
|
50708
|
-
const bridgeDir = prefix ?
|
|
50709
|
-
const destDir = prefix ?
|
|
50464
|
+
const bridgeDir = prefix ? path62.join(bridgeRoot, prefix) : bridgeRoot;
|
|
50465
|
+
const destDir = prefix ? path62.join(scopeDir, prefix) : scopeDir;
|
|
50710
50466
|
for (const fileName of fileNames) {
|
|
50711
50467
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
50712
50468
|
}
|
|
50713
50469
|
}
|
|
50714
50470
|
}
|
|
50715
50471
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
50716
|
-
const src =
|
|
50717
|
-
if (!
|
|
50718
|
-
const dest =
|
|
50472
|
+
const src = path62.join(srcDir, fileName);
|
|
50473
|
+
if (!fs39.existsSync(src)) return;
|
|
50474
|
+
const dest = path62.join(destDir, fileName);
|
|
50719
50475
|
try {
|
|
50720
|
-
|
|
50476
|
+
fs39.copyFileSync(src, dest);
|
|
50721
50477
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
50722
50478
|
} catch (e) {
|
|
50723
50479
|
log2?.(
|
|
@@ -50749,16 +50505,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
50749
50505
|
worktreeBaseBranches,
|
|
50750
50506
|
log: log2
|
|
50751
50507
|
} = options;
|
|
50752
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
50753
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
50508
|
+
const repoPathRelativeToBridgeRootRaw = path63.relative(bridgeResolved, repoAbsolutePath);
|
|
50509
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path63.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
50754
50510
|
return null;
|
|
50755
50511
|
}
|
|
50756
50512
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
50757
50513
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
50758
50514
|
);
|
|
50759
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
50515
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path63.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
50760
50516
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
50761
|
-
|
|
50517
|
+
fs40.mkdirSync(path63.dirname(worktreePath), { recursive: true });
|
|
50762
50518
|
copyBridgeFilesAlongWorktreePath({
|
|
50763
50519
|
bridgeRoot: bridgeResolved,
|
|
50764
50520
|
scopeDir,
|
|
@@ -50786,7 +50542,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
50786
50542
|
}
|
|
50787
50543
|
|
|
50788
50544
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
50789
|
-
import * as
|
|
50545
|
+
import * as path64 from "node:path";
|
|
50790
50546
|
|
|
50791
50547
|
// ../bridge/src/worktrees/worktree-layout-kind.ts
|
|
50792
50548
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -50816,10 +50572,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
50816
50572
|
|
|
50817
50573
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
50818
50574
|
function resolveIsolatedScopeDir(options) {
|
|
50819
|
-
const bridgeResolved =
|
|
50575
|
+
const bridgeResolved = path64.resolve(options.bridgeRoot);
|
|
50820
50576
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
50821
|
-
const bridgeKeyDir =
|
|
50822
|
-
const scopeDir =
|
|
50577
|
+
const bridgeKeyDir = path64.join(options.worktreesRootPath, cwdKey);
|
|
50578
|
+
const scopeDir = path64.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
50823
50579
|
return { bridgeResolved, scopeDir };
|
|
50824
50580
|
}
|
|
50825
50581
|
|
|
@@ -50849,7 +50605,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
50849
50605
|
return null;
|
|
50850
50606
|
}
|
|
50851
50607
|
const worktreePaths = [];
|
|
50852
|
-
|
|
50608
|
+
fs41.mkdirSync(scopeDir, { recursive: true });
|
|
50853
50609
|
await forEachWithGitYield(repos, async (repo) => {
|
|
50854
50610
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
50855
50611
|
kind,
|
|
@@ -50921,10 +50677,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
50921
50677
|
}
|
|
50922
50678
|
|
|
50923
50679
|
// ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
50924
|
-
import * as
|
|
50680
|
+
import * as path65 from "node:path";
|
|
50925
50681
|
init_yield_to_event_loop();
|
|
50926
50682
|
async function resolveExplicitSessionParentPath(params) {
|
|
50927
|
-
const resolved =
|
|
50683
|
+
const resolved = path65.resolve(params.parentPathRaw);
|
|
50928
50684
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
50929
50685
|
return resolved;
|
|
50930
50686
|
}
|
|
@@ -50941,7 +50697,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
50941
50697
|
await yieldToEventLoop();
|
|
50942
50698
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
50943
50699
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
50944
|
-
const next =
|
|
50700
|
+
const next = path65.dirname(cur);
|
|
50945
50701
|
if (next === cur) break;
|
|
50946
50702
|
cur = next;
|
|
50947
50703
|
}
|
|
@@ -51102,15 +50858,15 @@ var SessionWorktreeManager = class {
|
|
|
51102
50858
|
};
|
|
51103
50859
|
|
|
51104
50860
|
// ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
51105
|
-
import * as
|
|
51106
|
-
import * as
|
|
50861
|
+
import * as fs42 from "node:fs";
|
|
50862
|
+
import * as path66 from "node:path";
|
|
51107
50863
|
init_yield_to_event_loop();
|
|
51108
50864
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
51109
50865
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
51110
50866
|
const eid = environmentId.trim();
|
|
51111
50867
|
if (!eid) return null;
|
|
51112
50868
|
try {
|
|
51113
|
-
await
|
|
50869
|
+
await fs42.promises.access(worktreesRootPath);
|
|
51114
50870
|
} catch {
|
|
51115
50871
|
return null;
|
|
51116
50872
|
}
|
|
@@ -51119,13 +50875,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
51119
50875
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
51120
50876
|
const scanState = { entries: 0 };
|
|
51121
50877
|
try {
|
|
51122
|
-
for (const name of await
|
|
50878
|
+
for (const name of await fs42.promises.readdir(worktreesRootPath)) {
|
|
51123
50879
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
51124
50880
|
if (name.startsWith(".")) continue;
|
|
51125
|
-
const p =
|
|
50881
|
+
const p = path66.join(worktreesRootPath, name);
|
|
51126
50882
|
let st;
|
|
51127
50883
|
try {
|
|
51128
|
-
st = await
|
|
50884
|
+
st = await fs42.promises.stat(p);
|
|
51129
50885
|
} catch {
|
|
51130
50886
|
continue;
|
|
51131
50887
|
}
|
|
@@ -51139,7 +50895,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
51139
50895
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
51140
50896
|
for (const key of keys) {
|
|
51141
50897
|
await yieldToEventLoop();
|
|
51142
|
-
const previewDir =
|
|
50898
|
+
const previewDir = path66.join(worktreesRootPath, key, ...previewDirRel);
|
|
51143
50899
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
51144
50900
|
if (binding) return binding;
|
|
51145
50901
|
}
|
|
@@ -51266,7 +51022,7 @@ var PreviewWorktreeManager = class {
|
|
|
51266
51022
|
};
|
|
51267
51023
|
|
|
51268
51024
|
// ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
51269
|
-
import * as
|
|
51025
|
+
import * as path70 from "node:path";
|
|
51270
51026
|
|
|
51271
51027
|
// ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
|
|
51272
51028
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -51277,8 +51033,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
51277
51033
|
}
|
|
51278
51034
|
|
|
51279
51035
|
// ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
|
|
51280
|
-
import * as
|
|
51281
|
-
import * as
|
|
51036
|
+
import * as fs43 from "node:fs";
|
|
51037
|
+
import * as path67 from "node:path";
|
|
51282
51038
|
|
|
51283
51039
|
// ../bridge/src/git/is-not-a-git-repository-error.ts
|
|
51284
51040
|
function isNotAGitRepositoryError(e) {
|
|
@@ -51340,12 +51096,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
51340
51096
|
if (!ap.ok) return ap;
|
|
51341
51097
|
}
|
|
51342
51098
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
51343
|
-
const src =
|
|
51344
|
-
const dst =
|
|
51099
|
+
const src = path67.join(sourceRepoPath, rel);
|
|
51100
|
+
const dst = path67.join(targetRepoPath, rel);
|
|
51345
51101
|
try {
|
|
51346
|
-
if (!
|
|
51347
|
-
|
|
51348
|
-
|
|
51102
|
+
if (!fs43.existsSync(src)) return;
|
|
51103
|
+
fs43.mkdirSync(path67.dirname(dst), { recursive: true });
|
|
51104
|
+
fs43.copyFileSync(src, dst);
|
|
51349
51105
|
} catch (e) {
|
|
51350
51106
|
log2(
|
|
51351
51107
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -51356,14 +51112,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
51356
51112
|
}
|
|
51357
51113
|
|
|
51358
51114
|
// ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
51359
|
-
import * as
|
|
51115
|
+
import * as path68 from "node:path";
|
|
51360
51116
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
51361
51117
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
51362
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
51118
|
+
const resolvedSessionParentPath = sessionParentPath ? path68.resolve(sessionParentPath) : null;
|
|
51363
51119
|
let match = null;
|
|
51364
51120
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
51365
51121
|
if (match) return;
|
|
51366
|
-
const resolvedCheckoutPath =
|
|
51122
|
+
const resolvedCheckoutPath = path68.resolve(checkoutPath);
|
|
51367
51123
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
51368
51124
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51369
51125
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -51417,7 +51173,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
51417
51173
|
}
|
|
51418
51174
|
|
|
51419
51175
|
// ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
51420
|
-
import * as
|
|
51176
|
+
import * as path69 from "node:path";
|
|
51421
51177
|
|
|
51422
51178
|
// ../bridge/src/git/branches/create-or-update-branch.ts
|
|
51423
51179
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -51454,19 +51210,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
51454
51210
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
51455
51211
|
const states = [];
|
|
51456
51212
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
51457
|
-
const checkoutPath =
|
|
51213
|
+
const checkoutPath = path69.resolve(sessionCheckout);
|
|
51458
51214
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
51459
51215
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51460
51216
|
checkoutPath,
|
|
51461
51217
|
bridgeRoot,
|
|
51462
|
-
sessionParentPath: sessionParentPath ?
|
|
51218
|
+
sessionParentPath: sessionParentPath ? path69.resolve(sessionParentPath) : null
|
|
51463
51219
|
});
|
|
51464
51220
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
51465
51221
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
51466
51222
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
51467
51223
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
51468
51224
|
checkoutPaths: previewCheckoutPaths,
|
|
51469
|
-
sessionParentPath: previewParentPath ?
|
|
51225
|
+
sessionParentPath: previewParentPath ? path69.resolve(previewParentPath) : null,
|
|
51470
51226
|
bridgeRoot,
|
|
51471
51227
|
repoPathRelativeToWorkspaceRoot
|
|
51472
51228
|
}) : null;
|
|
@@ -51486,7 +51242,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
51486
51242
|
const eid = options.environmentId.trim();
|
|
51487
51243
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
51488
51244
|
const deployBranch = previewDeployBranchName(eid);
|
|
51489
|
-
const bridgeRoot =
|
|
51245
|
+
const bridgeRoot = path70.resolve(getBridgeRoot());
|
|
51490
51246
|
await previewWorktreeManager.ensureCached(eid);
|
|
51491
51247
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
51492
51248
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -51526,10 +51282,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
51526
51282
|
}
|
|
51527
51283
|
|
|
51528
51284
|
// ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
|
|
51529
|
-
import * as
|
|
51530
|
-
import
|
|
51285
|
+
import * as path71 from "node:path";
|
|
51286
|
+
import os7 from "node:os";
|
|
51531
51287
|
function defaultWorktreesRootPath() {
|
|
51532
|
-
return
|
|
51288
|
+
return path71.join(os7.homedir(), ".buildautomaton", "worktrees");
|
|
51533
51289
|
}
|
|
51534
51290
|
|
|
51535
51291
|
// ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
|
|
@@ -51654,14 +51410,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
51654
51410
|
}
|
|
51655
51411
|
|
|
51656
51412
|
// ../bridge/src/files/list-dir/index.ts
|
|
51657
|
-
import
|
|
51413
|
+
import fs45 from "node:fs";
|
|
51658
51414
|
|
|
51659
51415
|
// ../bridge/src/files/ensure-under-cwd.ts
|
|
51660
|
-
import
|
|
51416
|
+
import path72 from "node:path";
|
|
51661
51417
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
51662
|
-
const normalized =
|
|
51663
|
-
const resolved =
|
|
51664
|
-
if (!resolved.startsWith(cwd +
|
|
51418
|
+
const normalized = path72.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
51419
|
+
const resolved = path72.resolve(cwd, normalized);
|
|
51420
|
+
if (!resolved.startsWith(cwd + path72.sep) && resolved !== cwd) {
|
|
51665
51421
|
return null;
|
|
51666
51422
|
}
|
|
51667
51423
|
return resolved;
|
|
@@ -51674,15 +51430,15 @@ init_yield_to_event_loop();
|
|
|
51674
51430
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
51675
51431
|
|
|
51676
51432
|
// ../bridge/src/files/list-dir/map-dir-entry.ts
|
|
51677
|
-
import
|
|
51678
|
-
import
|
|
51433
|
+
import path73 from "node:path";
|
|
51434
|
+
import fs44 from "node:fs";
|
|
51679
51435
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
51680
|
-
const entryPath =
|
|
51681
|
-
const fullPath =
|
|
51436
|
+
const entryPath = path73.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
51437
|
+
const fullPath = path73.join(resolved, d.name);
|
|
51682
51438
|
let isDir = d.isDirectory();
|
|
51683
51439
|
if (d.isSymbolicLink()) {
|
|
51684
51440
|
try {
|
|
51685
|
-
const targetStat = await
|
|
51441
|
+
const targetStat = await fs44.promises.stat(fullPath);
|
|
51686
51442
|
isDir = targetStat.isDirectory();
|
|
51687
51443
|
} catch {
|
|
51688
51444
|
isDir = false;
|
|
@@ -51712,7 +51468,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
51712
51468
|
return { error: "Path is outside working directory" };
|
|
51713
51469
|
}
|
|
51714
51470
|
try {
|
|
51715
|
-
const names = await
|
|
51471
|
+
const names = await fs45.promises.readdir(resolved, { withFileTypes: true });
|
|
51716
51472
|
const entries = [];
|
|
51717
51473
|
for (let i = 0; i < names.length; i++) {
|
|
51718
51474
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -51728,13 +51484,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
51728
51484
|
}
|
|
51729
51485
|
|
|
51730
51486
|
// ../bridge/src/git/tree/resolve-repo-abs-path.ts
|
|
51731
|
-
import * as
|
|
51487
|
+
import * as path74 from "node:path";
|
|
51732
51488
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
51733
|
-
const bridgeResolved =
|
|
51489
|
+
const bridgeResolved = path74.resolve(bridgeRoot);
|
|
51734
51490
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
51735
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
51736
|
-
const resolved =
|
|
51737
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
51491
|
+
const repoPath = rel === "" ? bridgeResolved : path74.join(bridgeResolved, rel);
|
|
51492
|
+
const resolved = path74.resolve(repoPath);
|
|
51493
|
+
if (!resolved.startsWith(bridgeResolved + path74.sep) && resolved !== bridgeResolved) {
|
|
51738
51494
|
return null;
|
|
51739
51495
|
}
|
|
51740
51496
|
return resolved;
|
|
@@ -52215,25 +51971,25 @@ async function GET2(ctx) {
|
|
|
52215
51971
|
init_in_flight();
|
|
52216
51972
|
|
|
52217
51973
|
// ../bridge/src/files/read/read-file-async.ts
|
|
52218
|
-
import
|
|
51974
|
+
import fs51 from "node:fs";
|
|
52219
51975
|
init_yield_to_event_loop();
|
|
52220
51976
|
|
|
52221
51977
|
// ../bridge/src/files/read/resolve-file-cache.ts
|
|
52222
|
-
import
|
|
52223
|
-
import
|
|
51978
|
+
import fs46 from "node:fs";
|
|
51979
|
+
import path75 from "node:path";
|
|
52224
51980
|
var RESOLVE_CACHE_MAX = 4096;
|
|
52225
51981
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
52226
51982
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
52227
51983
|
return `${sessionParentPath}\0${relativePath}`;
|
|
52228
51984
|
}
|
|
52229
51985
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
52230
|
-
const parent =
|
|
52231
|
-
const resolved =
|
|
52232
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
51986
|
+
const parent = path75.resolve(sessionParentPath);
|
|
51987
|
+
const resolved = path75.resolve(filePath);
|
|
51988
|
+
return resolved === parent || resolved.startsWith(`${parent}${path75.sep}`);
|
|
52233
51989
|
}
|
|
52234
51990
|
function statMatchesCacheSync(entry) {
|
|
52235
51991
|
try {
|
|
52236
|
-
const stat3 =
|
|
51992
|
+
const stat3 = fs46.statSync(entry.path);
|
|
52237
51993
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
52238
51994
|
} catch {
|
|
52239
51995
|
return false;
|
|
@@ -52266,7 +52022,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
52266
52022
|
}
|
|
52267
52023
|
|
|
52268
52024
|
// ../bridge/src/files/read/resolve-file-for-read-core.ts
|
|
52269
|
-
import
|
|
52025
|
+
import fs47 from "node:fs";
|
|
52270
52026
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
52271
52027
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
52272
52028
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -52276,13 +52032,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
52276
52032
|
let size;
|
|
52277
52033
|
let mtimeMs;
|
|
52278
52034
|
try {
|
|
52279
|
-
const lstat =
|
|
52035
|
+
const lstat = fs47.lstatSync(resolved);
|
|
52280
52036
|
if (lstat.isSymbolicLink()) {
|
|
52281
|
-
real =
|
|
52037
|
+
real = fs47.realpathSync(resolved);
|
|
52282
52038
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
52283
52039
|
return { error: "Path is outside working directory" };
|
|
52284
52040
|
}
|
|
52285
|
-
const stat3 =
|
|
52041
|
+
const stat3 = fs47.statSync(real);
|
|
52286
52042
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
52287
52043
|
size = stat3.size;
|
|
52288
52044
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -52310,13 +52066,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
52310
52066
|
let size;
|
|
52311
52067
|
let mtimeMs;
|
|
52312
52068
|
try {
|
|
52313
|
-
const lstat = await
|
|
52069
|
+
const lstat = await fs47.promises.lstat(resolved);
|
|
52314
52070
|
if (lstat.isSymbolicLink()) {
|
|
52315
|
-
real = await
|
|
52071
|
+
real = await fs47.promises.realpath(resolved);
|
|
52316
52072
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
52317
52073
|
return { error: "Path is outside working directory" };
|
|
52318
52074
|
}
|
|
52319
|
-
const stat3 = await
|
|
52075
|
+
const stat3 = await fs47.promises.stat(real);
|
|
52320
52076
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
52321
52077
|
size = stat3.size;
|
|
52322
52078
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -52365,7 +52121,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
52365
52121
|
|
|
52366
52122
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
52367
52123
|
init_yield_to_event_loop();
|
|
52368
|
-
import
|
|
52124
|
+
import fs48 from "node:fs";
|
|
52369
52125
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
52370
52126
|
|
|
52371
52127
|
// ../bridge/src/files/read/read-file-range-line-zero.ts
|
|
@@ -52479,8 +52235,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
52479
52235
|
|
|
52480
52236
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
52481
52237
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
52482
|
-
const fileSize = fileSizeIn ?? (await
|
|
52483
|
-
const fd = await
|
|
52238
|
+
const fileSize = fileSizeIn ?? (await fs48.promises.stat(filePath)).size;
|
|
52239
|
+
const fd = await fs48.promises.open(filePath, "r");
|
|
52484
52240
|
const bufSize = 64 * 1024;
|
|
52485
52241
|
const buf = Buffer.alloc(bufSize);
|
|
52486
52242
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -52581,7 +52337,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
52581
52337
|
}
|
|
52582
52338
|
|
|
52583
52339
|
// ../bridge/src/files/read/read-small-file-range-async.ts
|
|
52584
|
-
import
|
|
52340
|
+
import fs49 from "node:fs";
|
|
52585
52341
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
52586
52342
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
52587
52343
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -52611,7 +52367,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
52611
52367
|
};
|
|
52612
52368
|
}
|
|
52613
52369
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
52614
|
-
const raw =
|
|
52370
|
+
const raw = fs49.readFileSync(filePath, "utf8");
|
|
52615
52371
|
const lines = raw.split(/\r?\n/);
|
|
52616
52372
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
52617
52373
|
}
|
|
@@ -52619,28 +52375,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
52619
52375
|
if (isMainThread5) {
|
|
52620
52376
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
52621
52377
|
}
|
|
52622
|
-
const raw = await
|
|
52378
|
+
const raw = await fs49.promises.readFile(filePath, "utf8");
|
|
52623
52379
|
const lines = raw.split(/\r?\n/);
|
|
52624
52380
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
52625
52381
|
}
|
|
52626
52382
|
|
|
52627
52383
|
// ../bridge/src/files/read/read-file-buffer-full-async.ts
|
|
52628
52384
|
init_yield_to_event_loop();
|
|
52629
|
-
import
|
|
52385
|
+
import fs50 from "node:fs";
|
|
52630
52386
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
52631
52387
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
52632
52388
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
52633
52389
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
52634
52390
|
if (isMainThread6) {
|
|
52635
|
-
const size2 = knownSize ??
|
|
52391
|
+
const size2 = knownSize ?? fs50.statSync(filePath).size;
|
|
52636
52392
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
52637
52393
|
await yieldToEventLoop();
|
|
52638
|
-
const buffer =
|
|
52394
|
+
const buffer = fs50.readFileSync(filePath);
|
|
52639
52395
|
return { buffer, size: buffer.length };
|
|
52640
52396
|
}
|
|
52641
52397
|
}
|
|
52642
|
-
const size = knownSize ?? (await
|
|
52643
|
-
const fd = await
|
|
52398
|
+
const size = knownSize ?? (await fs50.promises.stat(filePath)).size;
|
|
52399
|
+
const fd = await fs50.promises.open(filePath, "r");
|
|
52644
52400
|
const chunks = [];
|
|
52645
52401
|
let position = 0;
|
|
52646
52402
|
let bytesSinceYield = 0;
|
|
@@ -52743,7 +52499,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
52743
52499
|
}
|
|
52744
52500
|
if (hasRange) {
|
|
52745
52501
|
if (fileSize == null) {
|
|
52746
|
-
const stat3 = await
|
|
52502
|
+
const stat3 = await fs51.promises.stat(resolvedPath);
|
|
52747
52503
|
fileSize = stat3.size;
|
|
52748
52504
|
}
|
|
52749
52505
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -53041,12 +52797,12 @@ function parseOptionalInt2(raw) {
|
|
|
53041
52797
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
53042
52798
|
}
|
|
53043
52799
|
function parseCodeNavParams(url2) {
|
|
53044
|
-
const
|
|
52800
|
+
const path86 = url2.searchParams.get("path") ?? "";
|
|
53045
52801
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
53046
52802
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
53047
52803
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
53048
52804
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
53049
|
-
return { path:
|
|
52805
|
+
return { path: path86, op, line, column };
|
|
53050
52806
|
}
|
|
53051
52807
|
function parseCodeNavPath(url2) {
|
|
53052
52808
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -53979,19 +53735,34 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
53979
53735
|
handleBridgeAgentConfig(msg, deps);
|
|
53980
53736
|
};
|
|
53981
53737
|
|
|
53982
|
-
// ../bridge/src/prompt-
|
|
53738
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
53983
53739
|
init_yield_to_event_loop();
|
|
53984
53740
|
|
|
53985
|
-
// ../bridge/src/prompt-
|
|
53741
|
+
// ../bridge/src/prompt-queue/snapshots/types.ts
|
|
53742
|
+
function parseServerTurnSnapshot(raw) {
|
|
53743
|
+
if (!raw || typeof raw !== "object") return null;
|
|
53744
|
+
const o = raw;
|
|
53745
|
+
const turnId = typeof o.turnId === "string" ? o.turnId : "";
|
|
53746
|
+
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
53747
|
+
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
53748
|
+
const serverState = o.serverState ?? o.bridgeServerState;
|
|
53749
|
+
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
53750
|
+
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
53751
|
+
if (!turnId || !sessionId) return null;
|
|
53752
|
+
return { turnId, sessionId, turnOrd, serverState, lastCliState, payload };
|
|
53753
|
+
}
|
|
53754
|
+
function promptQueueSnapshotEntries(queues) {
|
|
53755
|
+
const entries = [];
|
|
53756
|
+
for (const [queueKey, rawTurns] of Object.entries(queues)) {
|
|
53757
|
+
if (!Array.isArray(rawTurns)) continue;
|
|
53758
|
+
const turns = rawTurns.map(parseServerTurnSnapshot).filter((t) => t !== null);
|
|
53759
|
+
entries.push([queueKey, turns]);
|
|
53760
|
+
}
|
|
53761
|
+
return entries;
|
|
53762
|
+
}
|
|
53763
|
+
|
|
53764
|
+
// ../bridge/src/prompt-queue/persistence/read-persisted-queue.ts
|
|
53986
53765
|
init_cli_database();
|
|
53987
|
-
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
53988
|
-
"queued",
|
|
53989
|
-
"requeued",
|
|
53990
|
-
"requeued_with_revert",
|
|
53991
|
-
"cancel_requested",
|
|
53992
|
-
"stopping",
|
|
53993
|
-
"discarded"
|
|
53994
|
-
]);
|
|
53995
53766
|
async function readPersistedQueue(queueKey) {
|
|
53996
53767
|
return withCliSqlite((db) => {
|
|
53997
53768
|
const row = db.get("SELECT queue_key, updated_at, turns_json FROM prompt_queue WHERE queue_key = ?", [
|
|
@@ -54007,6 +53778,9 @@ async function readPersistedQueue(queueKey) {
|
|
|
54007
53778
|
}
|
|
54008
53779
|
});
|
|
54009
53780
|
}
|
|
53781
|
+
|
|
53782
|
+
// ../bridge/src/prompt-queue/persistence/write-persisted-queue.ts
|
|
53783
|
+
init_cli_database();
|
|
54010
53784
|
async function writePersistedQueue(file2) {
|
|
54011
53785
|
await withCliSqlite((db) => {
|
|
54012
53786
|
db.run(
|
|
@@ -54016,36 +53790,103 @@ async function writePersistedQueue(file2) {
|
|
|
54016
53790
|
);
|
|
54017
53791
|
});
|
|
54018
53792
|
}
|
|
54019
|
-
|
|
54020
|
-
|
|
53793
|
+
|
|
53794
|
+
// ../bridge/src/prompt-queue/reconciliation/merge-turns.ts
|
|
53795
|
+
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
53796
|
+
"queued",
|
|
53797
|
+
"requeued",
|
|
53798
|
+
"requeued_with_revert",
|
|
53799
|
+
"cancel_requested",
|
|
53800
|
+
"stopping",
|
|
53801
|
+
"discarded"
|
|
53802
|
+
]);
|
|
53803
|
+
function mergeServerSnapshotWithLocal(queueKey, serverTurns, prev) {
|
|
54021
53804
|
const turns = [];
|
|
54022
|
-
for (const
|
|
54023
|
-
if (!
|
|
54024
|
-
const
|
|
54025
|
-
const
|
|
54026
|
-
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
54027
|
-
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
54028
|
-
const bridgeServerState = o.serverState ?? o.bridgeServerState;
|
|
54029
|
-
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
54030
|
-
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
54031
|
-
if (!turnId || !sessionId) continue;
|
|
54032
|
-
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(bridgeServerState))) continue;
|
|
54033
|
-
const old = prev?.turns.find((t) => t.turnId === turnId);
|
|
54034
|
-
const mergedCli = old?.lastCliState === "running" && lastCliState == null ? "running" : lastCliState;
|
|
53805
|
+
for (const s of serverTurns) {
|
|
53806
|
+
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(s.serverState))) continue;
|
|
53807
|
+
const old = prev?.turns.find((t) => t.turnId === s.turnId);
|
|
53808
|
+
const mergedCli = old?.lastCliState === "running" && s.lastCliState == null ? "running" : s.lastCliState;
|
|
54035
53809
|
turns.push({
|
|
54036
|
-
turnId,
|
|
54037
|
-
sessionId,
|
|
54038
|
-
turnOrd,
|
|
54039
|
-
bridgeServerState,
|
|
53810
|
+
turnId: s.turnId,
|
|
53811
|
+
sessionId: s.sessionId,
|
|
53812
|
+
turnOrd: s.turnOrd,
|
|
53813
|
+
bridgeServerState: s.serverState,
|
|
54040
53814
|
lastCliState: mergedCli,
|
|
54041
|
-
payload
|
|
53815
|
+
payload: s.payload
|
|
54042
53816
|
});
|
|
54043
53817
|
}
|
|
54044
53818
|
turns.sort((a, b) => a.turnOrd - b.turnOrd);
|
|
54045
53819
|
return { queueKey, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
54046
53820
|
}
|
|
53821
|
+
function hasLiveRunningTurn(turns, isLiveRun) {
|
|
53822
|
+
return turns.some((t) => t.lastCliState === "running" && isLiveRun(t.turnId));
|
|
53823
|
+
}
|
|
53824
|
+
function isTerminalCliState(state) {
|
|
53825
|
+
return state === "stopped" || state === "failed" || state === "cancelled";
|
|
53826
|
+
}
|
|
53827
|
+
function isSkippedServerState(state) {
|
|
53828
|
+
return state === "discarded" || state === "stopping" || state === "cancel_requested";
|
|
53829
|
+
}
|
|
53830
|
+
|
|
53831
|
+
// ../bridge/src/prompt-queue/reconciliation/pick-actions.ts
|
|
53832
|
+
function pickNextRunnableTurn(turns) {
|
|
53833
|
+
for (const t of turns) {
|
|
53834
|
+
if (isSkippedServerState(t.bridgeServerState)) continue;
|
|
53835
|
+
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
53836
|
+
if (isTerminalCliState(t.lastCliState) || t.lastCliState === "running") continue;
|
|
53837
|
+
return t;
|
|
53838
|
+
}
|
|
53839
|
+
return null;
|
|
53840
|
+
}
|
|
53841
|
+
function normalizeStaleRunning(turns, isLiveRun) {
|
|
53842
|
+
return turns.map((t) => {
|
|
53843
|
+
if (t.lastCliState !== "running") return t;
|
|
53844
|
+
if (isLiveRun(t.turnId)) return t;
|
|
53845
|
+
if (t.bridgeServerState === "cancel_requested") return t;
|
|
53846
|
+
return { ...t, lastCliState: null };
|
|
53847
|
+
});
|
|
53848
|
+
}
|
|
53849
|
+
function reconcileQueueActions(queueKey, turns, isLiveRun) {
|
|
53850
|
+
const actions = [];
|
|
53851
|
+
for (const t of turns) {
|
|
53852
|
+
if (t.bridgeServerState === "cancel_requested" && t.lastCliState === "running" && isLiveRun(t.turnId)) {
|
|
53853
|
+
actions.push({ type: "cancel_run", queueKey, turnId: t.turnId });
|
|
53854
|
+
}
|
|
53855
|
+
}
|
|
53856
|
+
for (const t of turns) {
|
|
53857
|
+
if (t.bridgeServerState !== "cancel_requested") continue;
|
|
53858
|
+
if (t.lastCliState !== "running") continue;
|
|
53859
|
+
if (isLiveRun(t.turnId)) continue;
|
|
53860
|
+
actions.push({ type: "finalize_stale", queueKey, turnId: t.turnId, cliState: "cancelled" });
|
|
53861
|
+
}
|
|
53862
|
+
const normalized = normalizeStaleRunning(turns, isLiveRun);
|
|
53863
|
+
if (hasLiveRunningTurn(normalized, isLiveRun)) return actions;
|
|
53864
|
+
const next = pickNextRunnableTurn(normalized);
|
|
53865
|
+
if (next) {
|
|
53866
|
+
actions.push({ type: "start_run", queueKey, turn: next });
|
|
53867
|
+
actions.push({ type: "report_cli_state", queueKey, turnId: next.turnId, cliState: "running" });
|
|
53868
|
+
}
|
|
53869
|
+
return actions;
|
|
53870
|
+
}
|
|
53871
|
+
function applyStaleRunningNormalization(turns, isLiveRun) {
|
|
53872
|
+
return normalizeStaleRunning(turns, isLiveRun);
|
|
53873
|
+
}
|
|
54047
53874
|
|
|
54048
|
-
// ../bridge/src/prompt-
|
|
53875
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
53876
|
+
init_yield_to_event_loop();
|
|
53877
|
+
|
|
53878
|
+
// ../bridge/src/prompt-queue/runner/client-report.ts
|
|
53879
|
+
function sendPromptQueueClientReport(ws, queues) {
|
|
53880
|
+
if (!ws) return false;
|
|
53881
|
+
const wireQueues = {};
|
|
53882
|
+
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
53883
|
+
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
53884
|
+
}
|
|
53885
|
+
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
53886
|
+
return true;
|
|
53887
|
+
}
|
|
53888
|
+
|
|
53889
|
+
// ../bridge/src/prompt-queue/runner/dispatch-local-prompt.ts
|
|
54049
53890
|
function dispatchLocalPrompt(next, deps) {
|
|
54050
53891
|
const pl = next.payload;
|
|
54051
53892
|
const rawParent = pl["sessionParent"];
|
|
@@ -54072,20 +53913,17 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
54072
53913
|
handleBridgePrompt(msg, deps);
|
|
54073
53914
|
}
|
|
54074
53915
|
|
|
54075
|
-
// ../bridge/src/prompt-
|
|
53916
|
+
// ../bridge/src/prompt-queue/runner/run-id-queue-key-map.ts
|
|
54076
53917
|
var runIdToQueueKey = /* @__PURE__ */ new Map();
|
|
54077
|
-
var locallyDispatchedRunIds = /* @__PURE__ */ new Set();
|
|
54078
53918
|
function getRunIdQueueKey(runId) {
|
|
54079
53919
|
return runIdToQueueKey.get(runId);
|
|
54080
53920
|
}
|
|
54081
53921
|
function setRunIdQueueKey(runId, queueKey) {
|
|
54082
53922
|
runIdToQueueKey.set(runId, queueKey);
|
|
54083
|
-
locallyDispatchedRunIds.add(runId);
|
|
54084
53923
|
}
|
|
54085
53924
|
function deleteRunIdQueueKey(runId) {
|
|
54086
53925
|
const queueKey = runIdToQueueKey.get(runId);
|
|
54087
53926
|
runIdToQueueKey.delete(runId);
|
|
54088
|
-
locallyDispatchedRunIds.delete(runId);
|
|
54089
53927
|
return queueKey;
|
|
54090
53928
|
}
|
|
54091
53929
|
function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
@@ -54094,33 +53932,7 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
|
54094
53932
|
}
|
|
54095
53933
|
}
|
|
54096
53934
|
|
|
54097
|
-
// ../bridge/src/prompt-
|
|
54098
|
-
async function dispatchStartedPromptQueueRuns(entries, started, deps) {
|
|
54099
|
-
for (const [queueKey] of entries) {
|
|
54100
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54101
|
-
const running2 = file2?.turns.find((turn) => turn.lastCliState === "running");
|
|
54102
|
-
if (running2 && started.has(running2.turnId) && getRunIdQueueKey(running2.turnId) === queueKey) {
|
|
54103
|
-
dispatchLocalPrompt(running2, deps);
|
|
54104
|
-
}
|
|
54105
|
-
await yieldToEventLoop();
|
|
54106
|
-
}
|
|
54107
|
-
}
|
|
54108
|
-
|
|
54109
|
-
// ../bridge/src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
54110
|
-
init_yield_to_event_loop();
|
|
54111
|
-
|
|
54112
|
-
// ../bridge/src/prompt-turn-queue/client-report.ts
|
|
54113
|
-
function sendPromptQueueClientReport(ws, queues) {
|
|
54114
|
-
if (!ws) return false;
|
|
54115
|
-
const wireQueues = {};
|
|
54116
|
-
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
54117
|
-
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
54118
|
-
}
|
|
54119
|
-
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
54120
|
-
return true;
|
|
54121
|
-
}
|
|
54122
|
-
|
|
54123
|
-
// ../bridge/src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
53935
|
+
// ../bridge/src/prompt-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
54124
53936
|
async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
54125
53937
|
if (!runId) return false;
|
|
54126
53938
|
const queueKey = deleteRunIdQueueKey(runId);
|
|
@@ -54135,79 +53947,19 @@ async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
|
54135
53947
|
return true;
|
|
54136
53948
|
}
|
|
54137
53949
|
|
|
54138
|
-
// ../bridge/src/prompt-
|
|
54139
|
-
|
|
54140
|
-
for (const [queueKey] of entries) {
|
|
54141
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54142
|
-
const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
|
|
54143
|
-
if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey) {
|
|
54144
|
-
await yieldToEventLoop();
|
|
54145
|
-
continue;
|
|
54146
|
-
}
|
|
54147
|
-
deps.log(`[Queue] Cancellation request received for turn ${turn.turnId.slice(0, 8)}\u2026`);
|
|
54148
|
-
if (await deps.acpManager.cancelRun(turn.turnId)) {
|
|
54149
|
-
await yieldToEventLoop();
|
|
54150
|
-
continue;
|
|
54151
|
-
}
|
|
54152
|
-
deps.log(`[Queue] No local ACP run remains for ${turn.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
54153
|
-
await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
|
|
54154
|
-
await yieldToEventLoop();
|
|
54155
|
-
}
|
|
54156
|
-
}
|
|
54157
|
-
|
|
54158
|
-
// ../bridge/src/prompt-turn-queue/runner/persist-prompt-queue-snapshot.ts
|
|
54159
|
-
init_yield_to_event_loop();
|
|
54160
|
-
async function persistPromptQueueSnapshot(entries) {
|
|
54161
|
-
for (const [queueKey, serverTurns] of entries) {
|
|
54162
|
-
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
54163
|
-
await writePersistedQueue(file2);
|
|
54164
|
-
await yieldToEventLoop();
|
|
54165
|
-
}
|
|
54166
|
-
for (const [queueKey] of entries) {
|
|
54167
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54168
|
-
if (file2) syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
54169
|
-
await yieldToEventLoop();
|
|
54170
|
-
}
|
|
54171
|
-
}
|
|
54172
|
-
|
|
54173
|
-
// ../bridge/src/prompt-turn-queue/runner/prompt-queue-snapshot-types.ts
|
|
54174
|
-
function promptQueueSnapshotEntries(queues) {
|
|
54175
|
-
return Object.entries(queues).filter((entry) => Array.isArray(entry[1]));
|
|
54176
|
-
}
|
|
54177
|
-
|
|
54178
|
-
// ../bridge/src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
54179
|
-
init_yield_to_event_loop();
|
|
54180
|
-
|
|
54181
|
-
// ../bridge/src/prompt-turn-queue/runner/queue-selection.ts
|
|
54182
|
-
function pickNextRunnableTurn(turns) {
|
|
54183
|
-
for (const t of turns) {
|
|
54184
|
-
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
54185
|
-
if (t.bridgeServerState === "cancel_requested") continue;
|
|
54186
|
-
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
54187
|
-
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
54188
|
-
continue;
|
|
54189
|
-
}
|
|
54190
|
-
return t;
|
|
54191
|
-
}
|
|
54192
|
-
return null;
|
|
54193
|
-
}
|
|
54194
|
-
function hasRunningTurn(turns) {
|
|
54195
|
-
return turns.some((t) => t.lastCliState === "running");
|
|
54196
|
-
}
|
|
54197
|
-
|
|
54198
|
-
// ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
54199
|
-
import fs55 from "node:fs";
|
|
53950
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
53951
|
+
import fs54 from "node:fs";
|
|
54200
53952
|
|
|
54201
53953
|
// ../bridge/src/git/snapshot/capture.ts
|
|
54202
|
-
import * as
|
|
54203
|
-
import * as
|
|
53954
|
+
import * as fs53 from "node:fs";
|
|
53955
|
+
import * as path77 from "node:path";
|
|
54204
53956
|
|
|
54205
53957
|
// ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
54206
|
-
import * as
|
|
53958
|
+
import * as fs52 from "node:fs";
|
|
54207
53959
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
54208
53960
|
let data;
|
|
54209
53961
|
try {
|
|
54210
|
-
data = JSON.parse(
|
|
53962
|
+
data = JSON.parse(fs52.readFileSync(filePath, "utf8"));
|
|
54211
53963
|
} catch (error51) {
|
|
54212
53964
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
54213
53965
|
}
|
|
@@ -54236,18 +53988,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
54236
53988
|
}
|
|
54237
53989
|
|
|
54238
53990
|
// ../bridge/src/git/snapshot/resolve-repo-roots.ts
|
|
54239
|
-
import * as
|
|
53991
|
+
import * as path76 from "node:path";
|
|
54240
53992
|
async function resolveSnapshotRepoRoots(options) {
|
|
54241
53993
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
54242
53994
|
if (worktreePaths?.length) {
|
|
54243
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
53995
|
+
const paths = [...new Set(worktreePaths.map((p) => path76.resolve(p)))];
|
|
54244
53996
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
54245
53997
|
}
|
|
54246
53998
|
try {
|
|
54247
53999
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
54248
54000
|
const sid = sessionId?.trim();
|
|
54249
54001
|
if (!sid) return roots;
|
|
54250
|
-
const sessionRoots = roots.filter((root) =>
|
|
54002
|
+
const sessionRoots = roots.filter((root) => path76.basename(root) === sid);
|
|
54251
54003
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
54252
54004
|
} catch (error51) {
|
|
54253
54005
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -54269,7 +54021,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54269
54021
|
});
|
|
54270
54022
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
54271
54023
|
try {
|
|
54272
|
-
|
|
54024
|
+
fs53.mkdirSync(dir, { recursive: true });
|
|
54273
54025
|
} catch (e) {
|
|
54274
54026
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
54275
54027
|
}
|
|
@@ -54278,9 +54030,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54278
54030
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
54279
54031
|
repos
|
|
54280
54032
|
};
|
|
54281
|
-
const filePath =
|
|
54033
|
+
const filePath = path77.join(dir, `${runId}.json`);
|
|
54282
54034
|
try {
|
|
54283
|
-
|
|
54035
|
+
fs53.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
54284
54036
|
} catch (e) {
|
|
54285
54037
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
54286
54038
|
}
|
|
@@ -54291,7 +54043,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54291
54043
|
return { ok: true, filePath, repos };
|
|
54292
54044
|
}
|
|
54293
54045
|
|
|
54294
|
-
// ../bridge/src/prompt-
|
|
54046
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
54295
54047
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
54296
54048
|
if (next.bridgeServerState !== "requeued_with_revert") return true;
|
|
54297
54049
|
const sid = next.sessionId;
|
|
@@ -54300,7 +54052,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
54300
54052
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
54301
54053
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
54302
54054
|
try {
|
|
54303
|
-
await
|
|
54055
|
+
await fs54.promises.access(file2, fs54.constants.F_OK);
|
|
54304
54056
|
} catch {
|
|
54305
54057
|
deps.log(
|
|
54306
54058
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -54314,49 +54066,121 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
54314
54066
|
return res.ok;
|
|
54315
54067
|
}
|
|
54316
54068
|
|
|
54317
|
-
// ../bridge/src/prompt-
|
|
54318
|
-
async function
|
|
54319
|
-
const report = {};
|
|
54069
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
54070
|
+
async function executePromptQueueActions(actions, deps) {
|
|
54320
54071
|
const started = /* @__PURE__ */ new Set();
|
|
54321
|
-
|
|
54322
|
-
|
|
54323
|
-
if (
|
|
54324
|
-
|
|
54325
|
-
|
|
54326
|
-
|
|
54327
|
-
|
|
54328
|
-
await
|
|
54329
|
-
sendPromptQueueClientReport(deps.getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
54072
|
+
const report = {};
|
|
54073
|
+
for (const action of actions) {
|
|
54074
|
+
if (action.type === "cancel_run") {
|
|
54075
|
+
if (getRunIdQueueKey(action.turnId) !== action.queueKey) continue;
|
|
54076
|
+
deps.log(`[Queue] Cancellation request received for turn ${action.turnId.slice(0, 8)}\u2026`);
|
|
54077
|
+
if (await deps.acpManager.cancelRun(action.turnId)) continue;
|
|
54078
|
+
deps.log(`[Queue] No local ACP run remains for ${action.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
54079
|
+
await finalizePromptTurnOnBridge(deps.getWs, action.turnId, false, { terminalCliState: "cancelled" });
|
|
54330
54080
|
continue;
|
|
54331
54081
|
}
|
|
54332
|
-
|
|
54333
|
-
|
|
54334
|
-
|
|
54335
|
-
|
|
54336
|
-
|
|
54082
|
+
if (action.type === "finalize_stale") {
|
|
54083
|
+
await applyCliState(action.queueKey, action.turnId, action.cliState);
|
|
54084
|
+
deleteRunIdQueueKey(action.turnId);
|
|
54085
|
+
report[action.queueKey] = [{ turnId: action.turnId, cliState: action.cliState }];
|
|
54086
|
+
continue;
|
|
54087
|
+
}
|
|
54088
|
+
if (action.type === "start_run") {
|
|
54089
|
+
if (getRunIdQueueKey(action.turn.turnId)) continue;
|
|
54090
|
+
const ok = await markTurnRunning(action.queueKey, action.turn, deps);
|
|
54091
|
+
if (!ok) {
|
|
54092
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "failed" }];
|
|
54093
|
+
continue;
|
|
54094
|
+
}
|
|
54095
|
+
started.add(action.turn.turnId);
|
|
54096
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "running" }];
|
|
54097
|
+
}
|
|
54337
54098
|
await yieldToEventLoop();
|
|
54338
54099
|
}
|
|
54339
54100
|
if (Object.keys(report).length) sendPromptQueueClientReport(deps.getWs(), report);
|
|
54101
|
+
for (const runId of started) {
|
|
54102
|
+
const queueKey = getRunIdQueueKey(runId);
|
|
54103
|
+
if (!queueKey) continue;
|
|
54104
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54105
|
+
const turn = file2?.turns.find((t) => t.turnId === runId);
|
|
54106
|
+
if (turn) dispatchLocalPrompt(turn, deps);
|
|
54107
|
+
await yieldToEventLoop();
|
|
54108
|
+
}
|
|
54340
54109
|
return started;
|
|
54341
54110
|
}
|
|
54111
|
+
async function markTurnRunning(queueKey, turn, deps) {
|
|
54112
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54113
|
+
if (!file2) return false;
|
|
54114
|
+
const row = file2.turns.find((t) => t.turnId === turn.turnId);
|
|
54115
|
+
if (!row) return false;
|
|
54116
|
+
if (!await runLocalRevertBeforeQueuedPrompt(row, deps)) {
|
|
54117
|
+
row.lastCliState = "failed";
|
|
54118
|
+
await writePersistedQueue(file2);
|
|
54119
|
+
return false;
|
|
54120
|
+
}
|
|
54121
|
+
row.lastCliState = "running";
|
|
54122
|
+
await writePersistedQueue(file2);
|
|
54123
|
+
setRunIdQueueKey(row.turnId, queueKey);
|
|
54124
|
+
return true;
|
|
54125
|
+
}
|
|
54126
|
+
async function applyCliState(queueKey, turnId, cliState) {
|
|
54127
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54128
|
+
if (!file2) return;
|
|
54129
|
+
const turn = file2.turns.find((t) => t.turnId === turnId);
|
|
54130
|
+
if (!turn) return;
|
|
54131
|
+
turn.lastCliState = cliState;
|
|
54132
|
+
await writePersistedQueue(file2);
|
|
54133
|
+
}
|
|
54342
54134
|
|
|
54343
|
-
// ../bridge/src/prompt-
|
|
54135
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
54344
54136
|
var SLOW_QUEUE_SYNC_MS = 2e3;
|
|
54137
|
+
async function persistAndReconcileQueue(queueKey, serverTurns, deps) {
|
|
54138
|
+
const prev = await readPersistedQueue(queueKey);
|
|
54139
|
+
const merged = mergeServerSnapshotWithLocal(queueKey, serverTurns, prev);
|
|
54140
|
+
const liveCheck = (runId) => deps.acpManager.isRegisteredRun(runId) || getRunIdQueueKey(runId) != null;
|
|
54141
|
+
const actions = reconcileQueueActions(queueKey, merged.turns, liveCheck);
|
|
54142
|
+
merged.turns = applyStaleRunningNormalization(merged.turns, liveCheck);
|
|
54143
|
+
await writePersistedQueue(merged);
|
|
54144
|
+
syncRunningTurnQueueKeys(merged.turns, queueKey);
|
|
54145
|
+
return actions;
|
|
54146
|
+
}
|
|
54345
54147
|
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
54346
54148
|
const raw = msg.queues;
|
|
54347
54149
|
if (!raw || typeof raw !== "object") return;
|
|
54348
54150
|
const startedAt = Date.now();
|
|
54349
54151
|
const entries = promptQueueSnapshotEntries(raw);
|
|
54350
|
-
|
|
54351
|
-
|
|
54352
|
-
|
|
54353
|
-
|
|
54152
|
+
const allActions = [];
|
|
54153
|
+
for (const [queueKey, serverTurns] of entries) {
|
|
54154
|
+
allActions.push(...await persistAndReconcileQueue(queueKey, serverTurns, deps));
|
|
54155
|
+
await yieldToEventLoop();
|
|
54156
|
+
}
|
|
54157
|
+
await executePromptQueueActions(allActions, deps);
|
|
54354
54158
|
const durationMs = Date.now() - startedAt;
|
|
54355
54159
|
if (durationMs >= SLOW_QUEUE_SYNC_MS) {
|
|
54356
54160
|
deps.log(`[Queue] Queue state sync and dispatch took ${durationMs}ms.`);
|
|
54357
54161
|
}
|
|
54358
54162
|
}
|
|
54359
54163
|
|
|
54164
|
+
// ../bridge/src/prompt-queue/runner/serial-prompt-queue-work.ts
|
|
54165
|
+
var running = false;
|
|
54166
|
+
var latestWork = null;
|
|
54167
|
+
async function drain() {
|
|
54168
|
+
while (latestWork) {
|
|
54169
|
+
const work = latestWork;
|
|
54170
|
+
latestWork = null;
|
|
54171
|
+
await work();
|
|
54172
|
+
}
|
|
54173
|
+
}
|
|
54174
|
+
function enqueueLatestPromptQueueStateWork(work) {
|
|
54175
|
+
latestWork = work;
|
|
54176
|
+
if (running) return;
|
|
54177
|
+
running = true;
|
|
54178
|
+
void drain().finally(() => {
|
|
54179
|
+
running = false;
|
|
54180
|
+
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
54181
|
+
});
|
|
54182
|
+
}
|
|
54183
|
+
|
|
54360
54184
|
// ../bridge/src/agents/acp/from-bridge/pending-prompt-results.ts
|
|
54361
54185
|
var pending = [];
|
|
54362
54186
|
function enqueuePendingPromptResult(message) {
|
|
@@ -54676,26 +54500,6 @@ var handlePromptMessage = (msg, deps) => {
|
|
|
54676
54500
|
handleBridgePrompt(msg, deps);
|
|
54677
54501
|
};
|
|
54678
54502
|
|
|
54679
|
-
// ../bridge/src/prompt-turn-queue/runner/serial-prompt-queue-work.ts
|
|
54680
|
-
var running = false;
|
|
54681
|
-
var latestWork = null;
|
|
54682
|
-
async function drain() {
|
|
54683
|
-
while (latestWork) {
|
|
54684
|
-
const work = latestWork;
|
|
54685
|
-
latestWork = null;
|
|
54686
|
-
await work();
|
|
54687
|
-
}
|
|
54688
|
-
}
|
|
54689
|
-
function enqueueLatestPromptQueueStateWork(work) {
|
|
54690
|
-
latestWork = work;
|
|
54691
|
-
if (running) return;
|
|
54692
|
-
running = true;
|
|
54693
|
-
void drain().finally(() => {
|
|
54694
|
-
running = false;
|
|
54695
|
-
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
54696
|
-
});
|
|
54697
|
-
}
|
|
54698
|
-
|
|
54699
54503
|
// ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
|
|
54700
54504
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
54701
54505
|
enqueueLatestPromptQueueStateWork(async () => {
|
|
@@ -54958,7 +54762,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
54958
54762
|
};
|
|
54959
54763
|
|
|
54960
54764
|
// ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
|
|
54961
|
-
import * as
|
|
54765
|
+
import * as fs55 from "node:fs";
|
|
54962
54766
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
54963
54767
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
54964
54768
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -54971,7 +54775,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
54971
54775
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
54972
54776
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
54973
54777
|
try {
|
|
54974
|
-
await
|
|
54778
|
+
await fs55.promises.access(file2, fs55.constants.F_OK);
|
|
54975
54779
|
} catch {
|
|
54976
54780
|
sendWsMessage(s, {
|
|
54977
54781
|
type: "revert_turn_snapshot_result",
|
|
@@ -55085,13 +54889,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
55085
54889
|
|
|
55086
54890
|
// ../bridge/src/files/handle-file-browser-search.ts
|
|
55087
54891
|
init_yield_to_event_loop();
|
|
55088
|
-
import
|
|
54892
|
+
import path78 from "node:path";
|
|
55089
54893
|
var SEARCH_LIMIT = 100;
|
|
55090
54894
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
55091
54895
|
void (async () => {
|
|
55092
54896
|
await yieldToEventLoop();
|
|
55093
54897
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
55094
|
-
const sessionParentPath =
|
|
54898
|
+
const sessionParentPath = path78.resolve(
|
|
55095
54899
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
55096
54900
|
);
|
|
55097
54901
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -55189,7 +54993,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
55189
54993
|
}
|
|
55190
54994
|
|
|
55191
54995
|
// ../bridge/src/git/bridge-git-context.ts
|
|
55192
|
-
import * as
|
|
54996
|
+
import * as path79 from "node:path";
|
|
55193
54997
|
init_yield_to_event_loop();
|
|
55194
54998
|
|
|
55195
54999
|
// ../bridge/src/git/branches/get-current-branch.ts
|
|
@@ -55257,12 +55061,12 @@ function listPendingCheckouts() {
|
|
|
55257
55061
|
// ../bridge/src/git/bridge-git-context.ts
|
|
55258
55062
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
55259
55063
|
if (relPath === "." || relPath === "") {
|
|
55260
|
-
return
|
|
55064
|
+
return path79.basename(path79.resolve(bridgeRoot)) || "repo";
|
|
55261
55065
|
}
|
|
55262
|
-
return
|
|
55066
|
+
return path79.basename(relPath) || relPath;
|
|
55263
55067
|
}
|
|
55264
55068
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
55265
|
-
const root =
|
|
55069
|
+
const root = path79.resolve(bridgeRoot);
|
|
55266
55070
|
if (await isGitRepoDirectory(root)) {
|
|
55267
55071
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
55268
55072
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -55270,19 +55074,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
55270
55074
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
55271
55075
|
const byPath = /* @__PURE__ */ new Map();
|
|
55272
55076
|
for (const repo of [...deep, ...shallow]) {
|
|
55273
|
-
byPath.set(
|
|
55077
|
+
byPath.set(path79.resolve(repo.absolutePath), repo);
|
|
55274
55078
|
}
|
|
55275
55079
|
return [...byPath.values()];
|
|
55276
55080
|
}
|
|
55277
55081
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
55278
|
-
const bridgeResolved =
|
|
55082
|
+
const bridgeResolved = path79.resolve(bridgeRoot);
|
|
55279
55083
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
55280
55084
|
const rows = [];
|
|
55281
55085
|
for (let i = 0; i < repos.length; i++) {
|
|
55282
55086
|
if (i > 0) await yieldToEventLoop();
|
|
55283
55087
|
const repo = repos[i];
|
|
55284
|
-
let rel =
|
|
55285
|
-
if (rel.startsWith("..") ||
|
|
55088
|
+
let rel = path79.relative(bridgeResolved, repo.absolutePath);
|
|
55089
|
+
if (rel.startsWith("..") || path79.isAbsolute(rel)) continue;
|
|
55286
55090
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
55287
55091
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
55288
55092
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -55313,11 +55117,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
55313
55117
|
return rows;
|
|
55314
55118
|
}
|
|
55315
55119
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
55316
|
-
const bridgeResolved =
|
|
55120
|
+
const bridgeResolved = path79.resolve(bridgeRoot);
|
|
55317
55121
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
55318
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
55319
|
-
const resolved =
|
|
55320
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
55122
|
+
const repoPath = rel === "" ? bridgeResolved : path79.join(bridgeResolved, rel);
|
|
55123
|
+
const resolved = path79.resolve(repoPath);
|
|
55124
|
+
if (!resolved.startsWith(bridgeResolved + path79.sep) && resolved !== bridgeResolved) {
|
|
55321
55125
|
return [];
|
|
55322
55126
|
}
|
|
55323
55127
|
return listRepoBranchRefs(resolved);
|
|
@@ -55367,8 +55171,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
55367
55171
|
}
|
|
55368
55172
|
|
|
55369
55173
|
// ../bridge/src/git/checkout/bridge-git-checkout.ts
|
|
55370
|
-
import * as
|
|
55371
|
-
import * as
|
|
55174
|
+
import * as fs57 from "node:fs/promises";
|
|
55175
|
+
import * as path81 from "node:path";
|
|
55372
55176
|
|
|
55373
55177
|
// ../bridge/src/git/checkout/normalize-clone-url.ts
|
|
55374
55178
|
function normalizeCloneUrl(url2) {
|
|
@@ -55388,12 +55192,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
55388
55192
|
}
|
|
55389
55193
|
|
|
55390
55194
|
// ../bridge/src/git/checkout/resolve-checkout-target.ts
|
|
55391
|
-
import * as
|
|
55392
|
-
import * as
|
|
55195
|
+
import * as fs56 from "node:fs/promises";
|
|
55196
|
+
import * as path80 from "node:path";
|
|
55393
55197
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
55394
55198
|
async function pathExists(p) {
|
|
55395
55199
|
try {
|
|
55396
|
-
await
|
|
55200
|
+
await fs56.access(p);
|
|
55397
55201
|
return true;
|
|
55398
55202
|
} catch {
|
|
55399
55203
|
return false;
|
|
@@ -55405,7 +55209,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
55405
55209
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
55406
55210
|
throw new Error("Bridge root is already a git repository");
|
|
55407
55211
|
}
|
|
55408
|
-
const entries = await
|
|
55212
|
+
const entries = await fs56.readdir(bridgeRoot).catch(() => []);
|
|
55409
55213
|
if (entries.length > 0) {
|
|
55410
55214
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
55411
55215
|
}
|
|
@@ -55418,8 +55222,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
55418
55222
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
55419
55223
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
55420
55224
|
}
|
|
55421
|
-
const targetDir =
|
|
55422
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
55225
|
+
const targetDir = path80.resolve(bridgeRoot, folder);
|
|
55226
|
+
if (!targetDir.startsWith(bridgeRoot + path80.sep)) {
|
|
55423
55227
|
throw new Error("Invalid folderName");
|
|
55424
55228
|
}
|
|
55425
55229
|
if (await pathExists(targetDir)) {
|
|
@@ -55438,10 +55242,10 @@ async function bridgeGitCheckout(params) {
|
|
|
55438
55242
|
});
|
|
55439
55243
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
55440
55244
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
55441
|
-
const parent =
|
|
55442
|
-
await
|
|
55245
|
+
const parent = path81.dirname(targetDir);
|
|
55246
|
+
await fs57.mkdir(parent, { recursive: true });
|
|
55443
55247
|
if (relPath !== ".") {
|
|
55444
|
-
await
|
|
55248
|
+
await fs57.mkdir(targetDir, { recursive: true });
|
|
55445
55249
|
}
|
|
55446
55250
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
55447
55251
|
try {
|
|
@@ -55452,7 +55256,7 @@ async function bridgeGitCheckout(params) {
|
|
|
55452
55256
|
return { relPath, folderName };
|
|
55453
55257
|
} catch (e) {
|
|
55454
55258
|
if (relPath !== ".") {
|
|
55455
|
-
await
|
|
55259
|
+
await fs57.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
55456
55260
|
}
|
|
55457
55261
|
const msg = e instanceof Error ? e.message : String(e);
|
|
55458
55262
|
throw new Error(
|
|
@@ -56078,12 +55882,12 @@ function startStreamingProxy(ws, log2, pr) {
|
|
|
56078
55882
|
}
|
|
56079
55883
|
|
|
56080
55884
|
// src/config.ts
|
|
56081
|
-
import
|
|
56082
|
-
import
|
|
56083
|
-
import
|
|
55885
|
+
import fs58 from "node:fs";
|
|
55886
|
+
import path82 from "node:path";
|
|
55887
|
+
import os8 from "node:os";
|
|
56084
55888
|
function getConfigPath() {
|
|
56085
|
-
const dir =
|
|
56086
|
-
return
|
|
55889
|
+
const dir = path82.join(os8.homedir(), ".buildautomaton");
|
|
55890
|
+
return path82.join(dir, "config.json");
|
|
56087
55891
|
}
|
|
56088
55892
|
function normalizeApiUrl(url2) {
|
|
56089
55893
|
return url2.replace(/\/$/, "");
|
|
@@ -56091,7 +55895,7 @@ function normalizeApiUrl(url2) {
|
|
|
56091
55895
|
function readRawConfig() {
|
|
56092
55896
|
try {
|
|
56093
55897
|
const p = getConfigPath();
|
|
56094
|
-
const raw =
|
|
55898
|
+
const raw = fs58.readFileSync(p, "utf8");
|
|
56095
55899
|
return JSON.parse(raw);
|
|
56096
55900
|
} catch {
|
|
56097
55901
|
return null;
|
|
@@ -56119,14 +55923,14 @@ function readConfigForApi(apiUrl) {
|
|
|
56119
55923
|
}
|
|
56120
55924
|
function writeConfigForApi(apiUrl, auth) {
|
|
56121
55925
|
const p = getConfigPath();
|
|
56122
|
-
const dir =
|
|
55926
|
+
const dir = path82.dirname(p);
|
|
56123
55927
|
const key = normalizeApiUrl(apiUrl);
|
|
56124
55928
|
const prev = readRawConfig() ?? {};
|
|
56125
55929
|
const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
|
|
56126
55930
|
const next = { ...prev, servers };
|
|
56127
55931
|
try {
|
|
56128
|
-
if (!
|
|
56129
|
-
|
|
55932
|
+
if (!fs58.existsSync(dir)) fs58.mkdirSync(dir, { recursive: true });
|
|
55933
|
+
fs58.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
56130
55934
|
} catch (e) {
|
|
56131
55935
|
console.error("Could not save authentication config:", e);
|
|
56132
55936
|
}
|
|
@@ -56135,22 +55939,22 @@ function clearConfigForApi(apiUrl) {
|
|
|
56135
55939
|
const key = normalizeApiUrl(apiUrl);
|
|
56136
55940
|
try {
|
|
56137
55941
|
const p = getConfigPath();
|
|
56138
|
-
if (!
|
|
55942
|
+
if (!fs58.existsSync(p)) return;
|
|
56139
55943
|
const prev = readRawConfig();
|
|
56140
55944
|
if (!prev) return;
|
|
56141
55945
|
const servers = { ...prev.servers ?? {} };
|
|
56142
55946
|
delete servers[key];
|
|
56143
55947
|
const next = { ...prev, servers };
|
|
56144
55948
|
if (Object.keys(servers).length === 0 && !prev.workspaceId) {
|
|
56145
|
-
|
|
55949
|
+
fs58.unlinkSync(p);
|
|
56146
55950
|
return;
|
|
56147
55951
|
}
|
|
56148
55952
|
if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
|
|
56149
55953
|
const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
|
|
56150
|
-
|
|
55954
|
+
fs58.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
|
|
56151
55955
|
return;
|
|
56152
55956
|
}
|
|
56153
|
-
|
|
55957
|
+
fs58.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
56154
55958
|
} catch {
|
|
56155
55959
|
}
|
|
56156
55960
|
}
|
|
@@ -56158,30 +55962,30 @@ function clearConfigForApi(apiUrl) {
|
|
|
56158
55962
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
56159
55963
|
import process8 from "node:process";
|
|
56160
55964
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
56161
|
-
import
|
|
55965
|
+
import path83 from "node:path";
|
|
56162
55966
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
56163
55967
|
import { promisify as promisify8 } from "node:util";
|
|
56164
55968
|
import childProcess from "node:child_process";
|
|
56165
|
-
import
|
|
55969
|
+
import fs63, { constants as fsConstants2 } from "node:fs/promises";
|
|
56166
55970
|
|
|
56167
55971
|
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
56168
55972
|
import process4 from "node:process";
|
|
56169
|
-
import
|
|
55973
|
+
import fs62, { constants as fsConstants } from "node:fs/promises";
|
|
56170
55974
|
|
|
56171
55975
|
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
56172
55976
|
import process3 from "node:process";
|
|
56173
|
-
import
|
|
56174
|
-
import
|
|
55977
|
+
import os9 from "node:os";
|
|
55978
|
+
import fs61 from "node:fs";
|
|
56175
55979
|
|
|
56176
55980
|
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
56177
|
-
import
|
|
55981
|
+
import fs60 from "node:fs";
|
|
56178
55982
|
|
|
56179
55983
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
56180
|
-
import
|
|
55984
|
+
import fs59 from "node:fs";
|
|
56181
55985
|
var isDockerCached;
|
|
56182
55986
|
function hasDockerEnv() {
|
|
56183
55987
|
try {
|
|
56184
|
-
|
|
55988
|
+
fs59.statSync("/.dockerenv");
|
|
56185
55989
|
return true;
|
|
56186
55990
|
} catch {
|
|
56187
55991
|
return false;
|
|
@@ -56189,7 +55993,7 @@ function hasDockerEnv() {
|
|
|
56189
55993
|
}
|
|
56190
55994
|
function hasDockerCGroup() {
|
|
56191
55995
|
try {
|
|
56192
|
-
return
|
|
55996
|
+
return fs59.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
56193
55997
|
} catch {
|
|
56194
55998
|
return false;
|
|
56195
55999
|
}
|
|
@@ -56205,7 +56009,7 @@ function isDocker() {
|
|
|
56205
56009
|
var cachedResult;
|
|
56206
56010
|
var hasContainerEnv = () => {
|
|
56207
56011
|
try {
|
|
56208
|
-
|
|
56012
|
+
fs60.statSync("/run/.containerenv");
|
|
56209
56013
|
return true;
|
|
56210
56014
|
} catch {
|
|
56211
56015
|
return false;
|
|
@@ -56223,19 +56027,19 @@ var isWsl = () => {
|
|
|
56223
56027
|
if (process3.platform !== "linux") {
|
|
56224
56028
|
return false;
|
|
56225
56029
|
}
|
|
56226
|
-
if (
|
|
56030
|
+
if (os9.release().toLowerCase().includes("microsoft")) {
|
|
56227
56031
|
if (isInsideContainer()) {
|
|
56228
56032
|
return false;
|
|
56229
56033
|
}
|
|
56230
56034
|
return true;
|
|
56231
56035
|
}
|
|
56232
56036
|
try {
|
|
56233
|
-
if (
|
|
56037
|
+
if (fs61.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
56234
56038
|
return !isInsideContainer();
|
|
56235
56039
|
}
|
|
56236
56040
|
} catch {
|
|
56237
56041
|
}
|
|
56238
|
-
if (
|
|
56042
|
+
if (fs61.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs61.existsSync("/run/WSL")) {
|
|
56239
56043
|
return !isInsideContainer();
|
|
56240
56044
|
}
|
|
56241
56045
|
return false;
|
|
@@ -56253,14 +56057,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
56253
56057
|
const configFilePath2 = "/etc/wsl.conf";
|
|
56254
56058
|
let isConfigFileExists = false;
|
|
56255
56059
|
try {
|
|
56256
|
-
await
|
|
56060
|
+
await fs62.access(configFilePath2, fsConstants.F_OK);
|
|
56257
56061
|
isConfigFileExists = true;
|
|
56258
56062
|
} catch {
|
|
56259
56063
|
}
|
|
56260
56064
|
if (!isConfigFileExists) {
|
|
56261
56065
|
return defaultMountPoint;
|
|
56262
56066
|
}
|
|
56263
|
-
const configContent = await
|
|
56067
|
+
const configContent = await fs62.readFile(configFilePath2, { encoding: "utf8" });
|
|
56264
56068
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
56265
56069
|
if (!configMountPoint) {
|
|
56266
56070
|
return defaultMountPoint;
|
|
@@ -56414,8 +56218,8 @@ async function defaultBrowser2() {
|
|
|
56414
56218
|
|
|
56415
56219
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
56416
56220
|
var execFile7 = promisify8(childProcess.execFile);
|
|
56417
|
-
var __dirname =
|
|
56418
|
-
var localXdgOpenPath =
|
|
56221
|
+
var __dirname = path83.dirname(fileURLToPath7(import.meta.url));
|
|
56222
|
+
var localXdgOpenPath = path83.join(__dirname, "xdg-open");
|
|
56419
56223
|
var { platform, arch } = process8;
|
|
56420
56224
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
56421
56225
|
const powershellPath = await powerShellPath();
|
|
@@ -56565,7 +56369,7 @@ var baseOpen = async (options) => {
|
|
|
56565
56369
|
const isBundled = !__dirname || __dirname === "/";
|
|
56566
56370
|
let exeLocalXdgOpen = false;
|
|
56567
56371
|
try {
|
|
56568
|
-
await
|
|
56372
|
+
await fs63.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
56569
56373
|
exeLocalXdgOpen = true;
|
|
56570
56374
|
} catch {
|
|
56571
56375
|
}
|
|
@@ -57487,34 +57291,10 @@ function enrichIntegrationContentPromptForAgent(params) {
|
|
|
57487
57291
|
return injectIntegrationContentAgentPromptNote(params.agentPromptText, params.sessionId);
|
|
57488
57292
|
}
|
|
57489
57293
|
|
|
57490
|
-
// src/agents/planning/enrich-planning-session-prompt-for-agent.ts
|
|
57491
|
-
async function enrichPlanningSessionPromptForAgent(params) {
|
|
57492
|
-
const meta3 = await fetchCloudSessionMeta({
|
|
57493
|
-
sessionId: params.sessionId,
|
|
57494
|
-
cloudApiBaseUrl: params.cloudApiBaseUrl,
|
|
57495
|
-
getCloudAccessToken: params.getCloudAccessToken
|
|
57496
|
-
});
|
|
57497
|
-
if (!meta3.ok) return { promptText: params.promptText, isPlanningSession: false };
|
|
57498
|
-
const sessionKind = parseSessionKind(meta3.data.sessionKind);
|
|
57499
|
-
if (sessionKind !== "planning") return { promptText: params.promptText, isPlanningSession: false };
|
|
57500
|
-
const todos = Array.isArray(meta3.data.planningTodos) ? meta3.data.planningTodos : [];
|
|
57501
|
-
if (params.isNewSession || todos.length === 0) {
|
|
57502
|
-
return {
|
|
57503
|
-
promptText: buildPlanningSessionAgentPrompt(params.promptText),
|
|
57504
|
-
isPlanningSession: true
|
|
57505
|
-
};
|
|
57506
|
-
}
|
|
57507
|
-
return {
|
|
57508
|
-
promptText: buildPlanningSessionFollowUpAgentPrompt(params.promptText, todos),
|
|
57509
|
-
isPlanningSession: true
|
|
57510
|
-
};
|
|
57511
|
-
}
|
|
57512
|
-
|
|
57513
57294
|
// src/plugin/prepare-ba-agent-prompt.ts
|
|
57514
57295
|
async function prepareBuildAutomatonAgentPrompt(params) {
|
|
57515
|
-
const { promptText, sessionId,
|
|
57296
|
+
const { promptText, sessionId, cloudApiBaseUrl, getCloudAccessToken } = params;
|
|
57516
57297
|
let agentPromptText = promptText;
|
|
57517
|
-
let isPlanningSession = false;
|
|
57518
57298
|
if (sessionId) {
|
|
57519
57299
|
agentPromptText = await enrichForkedSessionPromptForAgent({
|
|
57520
57300
|
sessionId,
|
|
@@ -57522,88 +57302,15 @@ async function prepareBuildAutomatonAgentPrompt(params) {
|
|
|
57522
57302
|
cloudApiBaseUrl,
|
|
57523
57303
|
getCloudAccessToken
|
|
57524
57304
|
});
|
|
57525
|
-
const planningEnriched = await enrichPlanningSessionPromptForAgent({
|
|
57526
|
-
sessionId,
|
|
57527
|
-
promptText: agentPromptText,
|
|
57528
|
-
isNewSession,
|
|
57529
|
-
cloudApiBaseUrl,
|
|
57530
|
-
getCloudAccessToken
|
|
57531
|
-
});
|
|
57532
|
-
agentPromptText = planningEnriched.promptText;
|
|
57533
|
-
isPlanningSession = planningEnriched.isPlanningSession;
|
|
57534
|
-
}
|
|
57535
|
-
if (sessionId) {
|
|
57536
57305
|
agentPromptText = enrichIntegrationContentPromptForAgent({
|
|
57537
57306
|
sessionId,
|
|
57538
57307
|
originalPromptText: promptText,
|
|
57539
57308
|
agentPromptText
|
|
57540
57309
|
});
|
|
57541
57310
|
}
|
|
57542
|
-
|
|
57543
|
-
|
|
57544
|
-
|
|
57545
|
-
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
57546
|
-
var PLANNING_TODO_SUBMIT_TIMEOUT_MS = 3e3;
|
|
57547
|
-
async function submitPlanningTodosForTurn(params) {
|
|
57548
|
-
const token = params.getCloudAccessToken();
|
|
57549
|
-
if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
|
|
57550
|
-
const base = params.cloudApiBaseUrl.replace(/\/$/, "");
|
|
57551
|
-
const url2 = `${base}/internal/sessions/todos/submit`;
|
|
57552
|
-
let res;
|
|
57553
|
-
try {
|
|
57554
|
-
res = await fetch(url2, {
|
|
57555
|
-
method: "POST",
|
|
57556
|
-
signal: AbortSignal.timeout(PLANNING_TODO_SUBMIT_TIMEOUT_MS),
|
|
57557
|
-
headers: {
|
|
57558
|
-
Authorization: `Bearer ${token}`,
|
|
57559
|
-
"Content-Type": "application/json"
|
|
57560
|
-
},
|
|
57561
|
-
body: JSON.stringify({
|
|
57562
|
-
sessionId: params.sessionId,
|
|
57563
|
-
turnId: params.turnId,
|
|
57564
|
-
items: params.items
|
|
57565
|
-
})
|
|
57566
|
-
});
|
|
57567
|
-
} catch (error51) {
|
|
57568
|
-
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
57569
|
-
}
|
|
57570
|
-
if (!res.ok) {
|
|
57571
|
-
const body = await res.json().catch(() => null);
|
|
57572
|
-
return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
|
|
57573
|
-
}
|
|
57574
|
-
return { ok: true };
|
|
57575
|
-
}
|
|
57576
|
-
|
|
57577
|
-
// src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
|
|
57578
|
-
async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
|
|
57579
|
-
const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
|
|
57580
|
-
const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
|
|
57581
|
-
const outputFromResult = typeof output === "string" ? output : "";
|
|
57582
|
-
const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
|
|
57583
|
-
if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
|
|
57584
|
-
return { submitted: false, suppressOutput: false };
|
|
57585
|
-
}
|
|
57586
|
-
if (!cloudApiBaseUrl || !getCloudAccessToken) {
|
|
57587
|
-
return { submitted: false, suppressOutput: false };
|
|
57588
|
-
}
|
|
57589
|
-
const items = parsePlanningTodoAgentJson(outputStr);
|
|
57590
|
-
if (items.length === 0) {
|
|
57591
|
-
return { submitted: false, suppressOutput: false };
|
|
57592
|
-
}
|
|
57593
|
-
const result = await submitPlanningTodosForTurn({
|
|
57594
|
-
sessionId,
|
|
57595
|
-
turnId: runId,
|
|
57596
|
-
items,
|
|
57597
|
-
cloudApiBaseUrl,
|
|
57598
|
-
getCloudAccessToken
|
|
57599
|
-
});
|
|
57600
|
-
if (!result.ok) {
|
|
57601
|
-
log2(`[Agent] Planning todo submit failed: ${result.error}`);
|
|
57602
|
-
return { submitted: false, suppressOutput: false };
|
|
57603
|
-
}
|
|
57604
|
-
if (runId) consumePlanningSessionTurnOutput(runId);
|
|
57605
|
-
log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
|
|
57606
|
-
return { submitted: true, suppressOutput: true };
|
|
57311
|
+
void params.runId;
|
|
57312
|
+
void params.isNewSession;
|
|
57313
|
+
return { agentPromptText, isPlanningSession: false };
|
|
57607
57314
|
}
|
|
57608
57315
|
|
|
57609
57316
|
// src/e2e-certificates/open-import-url.ts
|
|
@@ -57962,11 +57669,6 @@ function createBuildAutomatonPlugin(options) {
|
|
|
57962
57669
|
cloudApiBaseUrl: apiUrl,
|
|
57963
57670
|
getCloudAccessToken: getAccessToken
|
|
57964
57671
|
}),
|
|
57965
|
-
maybeSubmitPlanningTodos: (params) => maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
57966
|
-
...params,
|
|
57967
|
-
cloudApiBaseUrl: apiUrl,
|
|
57968
|
-
getCloudAccessToken: getAccessToken
|
|
57969
|
-
}),
|
|
57970
57672
|
persistTokens: (tokens) => writeConfigForApi(apiUrl, {
|
|
57971
57673
|
workspaceId: tokens.workspaceId,
|
|
57972
57674
|
token: tokens.token,
|
|
@@ -57985,13 +57687,13 @@ function toTokens(auth) {
|
|
|
57985
57687
|
}
|
|
57986
57688
|
|
|
57987
57689
|
// src/cli/chdir-to-bridge-root.ts
|
|
57988
|
-
import * as
|
|
57989
|
-
import * as
|
|
57690
|
+
import * as fs64 from "node:fs";
|
|
57691
|
+
import * as path84 from "node:path";
|
|
57990
57692
|
function chdirToBridgeRoot(bridgeRootOpt) {
|
|
57991
57693
|
if (!bridgeRootOpt) return;
|
|
57992
|
-
const resolved =
|
|
57694
|
+
const resolved = path84.resolve(process.cwd(), bridgeRootOpt);
|
|
57993
57695
|
try {
|
|
57994
|
-
if (!
|
|
57696
|
+
if (!fs64.statSync(resolved).isDirectory()) {
|
|
57995
57697
|
console.error(`Bridge root is not a directory: ${resolved}`);
|
|
57996
57698
|
process.exit(1);
|
|
57997
57699
|
}
|
|
@@ -58025,7 +57727,7 @@ async function runCliAction(program2, opts) {
|
|
|
58025
57727
|
initBridgeRoot();
|
|
58026
57728
|
console.log(colorize(GOLDEN_YELLOW, `[Bridge] Using ${getBridgeRoot()} as the bridge root.`));
|
|
58027
57729
|
let worktreesRootPath;
|
|
58028
|
-
if (opts.worktreesRoot?.trim()) worktreesRootPath =
|
|
57730
|
+
if (opts.worktreesRoot?.trim()) worktreesRootPath = path85.resolve(opts.worktreesRoot.trim());
|
|
58029
57731
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
58030
57732
|
if (e2eCertificates) {
|
|
58031
57733
|
const action = e2eCertificates.generated ? "Generated" : "Loaded";
|