@buildautomaton/cli 0.1.93 → 0.1.95
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 +955 -1228
- package/dist/cli.js.map +4 -4
- package/dist/index.js +921 -1195
- package/dist/index.js.map +4 -4
- package/dist/worker.js +84 -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
|
}
|
|
@@ -23755,13 +23755,21 @@ var init_acp = __esm({
|
|
|
23755
23755
|
}
|
|
23756
23756
|
});
|
|
23757
23757
|
|
|
23758
|
+
// ../bridge/src/runtime/yield-to-event-loop.ts
|
|
23759
|
+
function yieldToEventLoop() {
|
|
23760
|
+
return new Promise((resolve39) => setImmediate(resolve39));
|
|
23761
|
+
}
|
|
23762
|
+
var init_yield_to_event_loop = __esm({
|
|
23763
|
+
"../bridge/src/runtime/yield-to-event-loop.ts"() {
|
|
23764
|
+
}
|
|
23765
|
+
});
|
|
23766
|
+
|
|
23758
23767
|
// ../bridge/src/files/index/constants.ts
|
|
23759
23768
|
import path3 from "node:path";
|
|
23760
23769
|
import os from "node:os";
|
|
23761
23770
|
var INDEX_WORK_YIELD_EVERY, INDEX_DIR, INDEX_HASH_LEN;
|
|
23762
23771
|
var init_constants = __esm({
|
|
23763
23772
|
"../bridge/src/files/index/constants.ts"() {
|
|
23764
|
-
"use strict";
|
|
23765
23773
|
INDEX_WORK_YIELD_EVERY = 128;
|
|
23766
23774
|
INDEX_DIR = path3.join(os.homedir(), ".buildautomaton");
|
|
23767
23775
|
INDEX_HASH_LEN = 16;
|
|
@@ -24026,15 +24034,6 @@ var init_activity_tracker = __esm({
|
|
|
24026
24034
|
}
|
|
24027
24035
|
});
|
|
24028
24036
|
|
|
24029
|
-
// ../bridge/src/runtime/yield-to-event-loop.ts
|
|
24030
|
-
function yieldToEventLoop() {
|
|
24031
|
-
return new Promise((resolve39) => setImmediate(resolve39));
|
|
24032
|
-
}
|
|
24033
|
-
var init_yield_to_event_loop = __esm({
|
|
24034
|
-
"../bridge/src/runtime/yield-to-event-loop.ts"() {
|
|
24035
|
-
}
|
|
24036
|
-
});
|
|
24037
|
-
|
|
24038
24037
|
// ../bridge/src/code-nav/symbol-index/deferred-indexing.ts
|
|
24039
24038
|
function isSymbolIndexDeferredError(err) {
|
|
24040
24039
|
return err instanceof SymbolIndexDeferredError;
|
|
@@ -24747,7 +24746,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
24747
24746
|
join2(moduleDir, "..", sub, filename),
|
|
24748
24747
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
24749
24748
|
]);
|
|
24750
|
-
const resolved = candidates.find((
|
|
24749
|
+
const resolved = candidates.find((path86) => existsSync(path86));
|
|
24751
24750
|
if (!resolved) {
|
|
24752
24751
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
24753
24752
|
}
|
|
@@ -24922,6 +24921,7 @@ function withCodeNavCacheSqliteWorkLock(fn) {
|
|
|
24922
24921
|
var chain, workLockDepth;
|
|
24923
24922
|
var init_code_nav_cache_sqlite_work_lock = __esm({
|
|
24924
24923
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-work-lock.ts"() {
|
|
24924
|
+
"use strict";
|
|
24925
24925
|
init_code_nav_cache_paths();
|
|
24926
24926
|
chain = Promise.resolve();
|
|
24927
24927
|
workLockDepth = 0;
|
|
@@ -25135,31 +25135,18 @@ var init_cli_sqlite_paths = __esm({
|
|
|
25135
25135
|
}
|
|
25136
25136
|
});
|
|
25137
25137
|
|
|
25138
|
-
// ../bridge/src/prompt-turn-queue/paths.ts
|
|
25139
|
-
import path7 from "node:path";
|
|
25140
|
-
import os4 from "node:os";
|
|
25141
|
-
function getPromptQueuesDirectory() {
|
|
25142
|
-
const override = process.env.BUILDAMATON_PROMPT_QUEUES_DIR?.trim();
|
|
25143
|
-
if (override) return path7.resolve(override);
|
|
25144
|
-
return path7.join(os4.homedir(), ".buildautomaton", "queues");
|
|
25145
|
-
}
|
|
25146
|
-
var init_paths2 = __esm({
|
|
25147
|
-
"../bridge/src/prompt-turn-queue/paths.ts"() {
|
|
25148
|
-
}
|
|
25149
|
-
});
|
|
25150
|
-
|
|
25151
25138
|
// ../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts
|
|
25152
25139
|
import fs7 from "node:fs";
|
|
25153
|
-
import
|
|
25140
|
+
import path7 from "node:path";
|
|
25154
25141
|
function moveLegacyFileToOldVersionBackup(category, sourcePath) {
|
|
25155
|
-
const destDir =
|
|
25142
|
+
const destDir = path7.join(OLD_VERSION_DIR, category);
|
|
25156
25143
|
fs7.mkdirSync(destDir, { recursive: true });
|
|
25157
|
-
const base =
|
|
25158
|
-
let dest =
|
|
25144
|
+
const base = path7.basename(sourcePath);
|
|
25145
|
+
let dest = path7.join(destDir, base);
|
|
25159
25146
|
if (fs7.existsSync(dest)) {
|
|
25160
|
-
const ext =
|
|
25147
|
+
const ext = path7.extname(base);
|
|
25161
25148
|
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
25162
|
-
dest =
|
|
25149
|
+
dest = path7.join(destDir, `${stem}-${Date.now()}${ext}`);
|
|
25163
25150
|
}
|
|
25164
25151
|
fs7.renameSync(sourcePath, dest);
|
|
25165
25152
|
}
|
|
@@ -25168,19 +25155,19 @@ var init_archive_to_old_version = __esm({
|
|
|
25168
25155
|
"../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts"() {
|
|
25169
25156
|
"use strict";
|
|
25170
25157
|
init_constants();
|
|
25171
|
-
OLD_VERSION_DIR =
|
|
25158
|
+
OLD_VERSION_DIR = path7.join(INDEX_DIR, "old-version");
|
|
25172
25159
|
}
|
|
25173
25160
|
});
|
|
25174
25161
|
|
|
25175
25162
|
// ../bridge/src/sqlite/legacy_migration/archive-file-index-json.ts
|
|
25176
25163
|
import fs8 from "node:fs";
|
|
25177
|
-
import
|
|
25164
|
+
import path8 from "node:path";
|
|
25178
25165
|
function archiveLegacyFileIndexJsonFiles() {
|
|
25179
25166
|
try {
|
|
25180
25167
|
if (!fs8.existsSync(INDEX_DIR)) return;
|
|
25181
25168
|
for (const name of fs8.readdirSync(INDEX_DIR)) {
|
|
25182
25169
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) {
|
|
25183
|
-
const full =
|
|
25170
|
+
const full = path8.join(INDEX_DIR, name);
|
|
25184
25171
|
try {
|
|
25185
25172
|
moveLegacyFileToOldVersionBackup("file-index", full);
|
|
25186
25173
|
} catch (err) {
|
|
@@ -25202,15 +25189,15 @@ var init_archive_file_index_json = __esm({
|
|
|
25202
25189
|
|
|
25203
25190
|
// ../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts
|
|
25204
25191
|
import fs9 from "node:fs";
|
|
25205
|
-
import
|
|
25206
|
-
import
|
|
25192
|
+
import path9 from "node:path";
|
|
25193
|
+
import os4 from "node:os";
|
|
25207
25194
|
function importLegacyAgentSessionsFromDisk(db) {
|
|
25208
25195
|
try {
|
|
25209
25196
|
if (!fs9.existsSync(LEGACY_AGENT_SESSION_DIR)) return;
|
|
25210
25197
|
const names = fs9.readdirSync(LEGACY_AGENT_SESSION_DIR).filter((n) => n.endsWith(".json"));
|
|
25211
25198
|
for (const name of names) {
|
|
25212
25199
|
const sessionKey = name.slice(0, -".json".length);
|
|
25213
|
-
const full =
|
|
25200
|
+
const full = path9.join(LEGACY_AGENT_SESSION_DIR, name);
|
|
25214
25201
|
let raw;
|
|
25215
25202
|
try {
|
|
25216
25203
|
raw = fs9.readFileSync(full, "utf8");
|
|
@@ -25247,89 +25234,27 @@ var init_import_agent_sessions_from_disk = __esm({
|
|
|
25247
25234
|
"../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts"() {
|
|
25248
25235
|
"use strict";
|
|
25249
25236
|
init_archive_to_old_version();
|
|
25250
|
-
LEGACY_AGENT_SESSION_DIR =
|
|
25251
|
-
}
|
|
25252
|
-
});
|
|
25253
|
-
|
|
25254
|
-
// ../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts
|
|
25255
|
-
function parsePersistedQueueFromJson(raw) {
|
|
25256
|
-
try {
|
|
25257
|
-
const o = JSON.parse(raw);
|
|
25258
|
-
const queueKey = typeof o.queueKey === "string" ? o.queueKey : typeof o.queueKeyHash === "string" ? o.queueKeyHash : null;
|
|
25259
|
-
if (!queueKey || typeof o.updatedAt !== "string" || !Array.isArray(o.turns)) return null;
|
|
25260
|
-
return { queueKey, updatedAt: o.updatedAt, turns: o.turns };
|
|
25261
|
-
} catch {
|
|
25262
|
-
return null;
|
|
25263
|
-
}
|
|
25264
|
-
}
|
|
25265
|
-
var init_parse_persisted_queue_json = __esm({
|
|
25266
|
-
"../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts"() {
|
|
25267
|
-
"use strict";
|
|
25268
|
-
}
|
|
25269
|
-
});
|
|
25270
|
-
|
|
25271
|
-
// ../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts
|
|
25272
|
-
import fs10 from "node:fs";
|
|
25273
|
-
import path11 from "node:path";
|
|
25274
|
-
function importLegacyPromptQueuesFromDisk(db) {
|
|
25275
|
-
try {
|
|
25276
|
-
const dir = getPromptQueuesDirectory();
|
|
25277
|
-
if (!fs10.existsSync(dir)) return;
|
|
25278
|
-
for (const name of fs10.readdirSync(dir)) {
|
|
25279
|
-
if (!name.endsWith(".json")) continue;
|
|
25280
|
-
const full = path11.join(dir, name);
|
|
25281
|
-
let raw;
|
|
25282
|
-
try {
|
|
25283
|
-
raw = fs10.readFileSync(full, "utf8");
|
|
25284
|
-
} catch {
|
|
25285
|
-
continue;
|
|
25286
|
-
}
|
|
25287
|
-
const file2 = parsePersistedQueueFromJson(raw);
|
|
25288
|
-
if (!file2) continue;
|
|
25289
|
-
db.run(
|
|
25290
|
-
`INSERT OR REPLACE INTO prompt_queue (queue_key, updated_at, turns_json) VALUES (?, ?, ?)`,
|
|
25291
|
-
[file2.queueKey, file2.updatedAt, JSON.stringify(file2.turns)]
|
|
25292
|
-
);
|
|
25293
|
-
try {
|
|
25294
|
-
moveLegacyFileToOldVersionBackup("queues", full);
|
|
25295
|
-
} catch {
|
|
25296
|
-
}
|
|
25297
|
-
}
|
|
25298
|
-
} catch (e) {
|
|
25299
|
-
console.error("[cli-sqlite] legacy import: prompt queues from disk failed", e);
|
|
25300
|
-
}
|
|
25301
|
-
}
|
|
25302
|
-
var init_import_prompt_queues_from_disk = __esm({
|
|
25303
|
-
"../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts"() {
|
|
25304
|
-
"use strict";
|
|
25305
|
-
init_paths2();
|
|
25306
|
-
init_archive_to_old_version();
|
|
25307
|
-
init_parse_persisted_queue_json();
|
|
25237
|
+
LEGACY_AGENT_SESSION_DIR = path9.join(os4.homedir(), ".buildautomaton", "agent-sessions");
|
|
25308
25238
|
}
|
|
25309
25239
|
});
|
|
25310
25240
|
|
|
25311
25241
|
// ../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts
|
|
25312
|
-
import
|
|
25242
|
+
import fs10 from "node:fs";
|
|
25313
25243
|
function legacyCliDiskMigrationIsPending() {
|
|
25314
25244
|
try {
|
|
25315
|
-
if (
|
|
25316
|
-
for (const name of
|
|
25245
|
+
if (fs10.existsSync(INDEX_DIR)) {
|
|
25246
|
+
for (const name of fs10.readdirSync(INDEX_DIR)) {
|
|
25317
25247
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) return true;
|
|
25318
25248
|
}
|
|
25319
25249
|
}
|
|
25320
25250
|
} catch {
|
|
25321
25251
|
}
|
|
25322
25252
|
try {
|
|
25323
|
-
if (
|
|
25324
|
-
if (
|
|
25253
|
+
if (fs10.existsSync(LEGACY_AGENT_SESSION_DIR)) {
|
|
25254
|
+
if (fs10.readdirSync(LEGACY_AGENT_SESSION_DIR).some((n) => n.endsWith(".json"))) return true;
|
|
25325
25255
|
}
|
|
25326
25256
|
} catch {
|
|
25327
25257
|
}
|
|
25328
|
-
try {
|
|
25329
|
-
const dir = getPromptQueuesDirectory();
|
|
25330
|
-
if (fs11.existsSync(dir) && fs11.readdirSync(dir).some((n) => n.endsWith(".json"))) return true;
|
|
25331
|
-
} catch {
|
|
25332
|
-
}
|
|
25333
25258
|
return false;
|
|
25334
25259
|
}
|
|
25335
25260
|
function importCliSqliteLegacyDiskData(db, log2) {
|
|
@@ -25339,7 +25264,6 @@ function importCliSqliteLegacyDiskData(db, log2) {
|
|
|
25339
25264
|
}
|
|
25340
25265
|
archiveLegacyFileIndexJsonFiles();
|
|
25341
25266
|
importLegacyAgentSessionsFromDisk(db);
|
|
25342
|
-
importLegacyPromptQueuesFromDisk(db);
|
|
25343
25267
|
if (pending2 && log2) {
|
|
25344
25268
|
log2("Legacy on-disk CLI data migration finished.");
|
|
25345
25269
|
}
|
|
@@ -25348,10 +25272,8 @@ var init_import_cli_legacy_disk_data = __esm({
|
|
|
25348
25272
|
"../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts"() {
|
|
25349
25273
|
"use strict";
|
|
25350
25274
|
init_constants();
|
|
25351
|
-
init_paths2();
|
|
25352
25275
|
init_archive_file_index_json();
|
|
25353
25276
|
init_import_agent_sessions_from_disk();
|
|
25354
|
-
init_import_prompt_queues_from_disk();
|
|
25355
25277
|
}
|
|
25356
25278
|
});
|
|
25357
25279
|
|
|
@@ -25461,15 +25383,15 @@ var init_cli_database = __esm({
|
|
|
25461
25383
|
});
|
|
25462
25384
|
|
|
25463
25385
|
// ../bridge/src/files/index/walk-workspace-tree.ts
|
|
25464
|
-
import
|
|
25465
|
-
import
|
|
25386
|
+
import fs11 from "node:fs";
|
|
25387
|
+
import path10 from "node:path";
|
|
25466
25388
|
function shouldSkipWorkspaceWalkEntry(name) {
|
|
25467
25389
|
return DEPENDENCY_INSTALL_DIR_NAMES.has(name);
|
|
25468
25390
|
}
|
|
25469
25391
|
async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
25470
25392
|
let names;
|
|
25471
25393
|
try {
|
|
25472
|
-
names = await
|
|
25394
|
+
names = await fs11.promises.readdir(dir);
|
|
25473
25395
|
} catch {
|
|
25474
25396
|
return;
|
|
25475
25397
|
}
|
|
@@ -25484,14 +25406,14 @@ async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
|
25484
25406
|
await yieldUntilFileBrowserReadsIdle();
|
|
25485
25407
|
}
|
|
25486
25408
|
state.n++;
|
|
25487
|
-
const full =
|
|
25409
|
+
const full = path10.join(dir, name);
|
|
25488
25410
|
let stat3;
|
|
25489
25411
|
try {
|
|
25490
|
-
stat3 = await
|
|
25412
|
+
stat3 = await fs11.promises.stat(full);
|
|
25491
25413
|
} catch {
|
|
25492
25414
|
continue;
|
|
25493
25415
|
}
|
|
25494
|
-
const relative6 =
|
|
25416
|
+
const relative6 = path10.relative(baseDir, full).replace(/\\/g, "/");
|
|
25495
25417
|
if (stat3.isDirectory()) {
|
|
25496
25418
|
await walkWorkspaceTreeAsync(full, baseDir, onFile, state);
|
|
25497
25419
|
} else if (stat3.isFile()) {
|
|
@@ -25820,7 +25742,7 @@ var require_ignore = __commonJS({
|
|
|
25820
25742
|
// path matching.
|
|
25821
25743
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
25822
25744
|
// @returns {TestResult} true if a file is ignored
|
|
25823
|
-
test(
|
|
25745
|
+
test(path86, checkUnignored, mode) {
|
|
25824
25746
|
let ignored = false;
|
|
25825
25747
|
let unignored = false;
|
|
25826
25748
|
let matchedRule;
|
|
@@ -25829,7 +25751,7 @@ var require_ignore = __commonJS({
|
|
|
25829
25751
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
25830
25752
|
return;
|
|
25831
25753
|
}
|
|
25832
|
-
const matched = rule[mode].test(
|
|
25754
|
+
const matched = rule[mode].test(path86);
|
|
25833
25755
|
if (!matched) {
|
|
25834
25756
|
return;
|
|
25835
25757
|
}
|
|
@@ -25850,17 +25772,17 @@ var require_ignore = __commonJS({
|
|
|
25850
25772
|
var throwError = (message, Ctor) => {
|
|
25851
25773
|
throw new Ctor(message);
|
|
25852
25774
|
};
|
|
25853
|
-
var checkPath = (
|
|
25854
|
-
if (!isString(
|
|
25775
|
+
var checkPath = (path86, originalPath, doThrow) => {
|
|
25776
|
+
if (!isString(path86)) {
|
|
25855
25777
|
return doThrow(
|
|
25856
25778
|
`path must be a string, but got \`${originalPath}\``,
|
|
25857
25779
|
TypeError
|
|
25858
25780
|
);
|
|
25859
25781
|
}
|
|
25860
|
-
if (!
|
|
25782
|
+
if (!path86) {
|
|
25861
25783
|
return doThrow(`path must not be empty`, TypeError);
|
|
25862
25784
|
}
|
|
25863
|
-
if (checkPath.isNotRelative(
|
|
25785
|
+
if (checkPath.isNotRelative(path86)) {
|
|
25864
25786
|
const r = "`path.relative()`d";
|
|
25865
25787
|
return doThrow(
|
|
25866
25788
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -25869,7 +25791,7 @@ var require_ignore = __commonJS({
|
|
|
25869
25791
|
}
|
|
25870
25792
|
return true;
|
|
25871
25793
|
};
|
|
25872
|
-
var isNotRelative = (
|
|
25794
|
+
var isNotRelative = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
|
|
25873
25795
|
checkPath.isNotRelative = isNotRelative;
|
|
25874
25796
|
checkPath.convert = (p) => p;
|
|
25875
25797
|
var Ignore = class {
|
|
@@ -25899,19 +25821,19 @@ var require_ignore = __commonJS({
|
|
|
25899
25821
|
}
|
|
25900
25822
|
// @returns {TestResult}
|
|
25901
25823
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
25902
|
-
const
|
|
25824
|
+
const path86 = originalPath && checkPath.convert(originalPath);
|
|
25903
25825
|
checkPath(
|
|
25904
|
-
|
|
25826
|
+
path86,
|
|
25905
25827
|
originalPath,
|
|
25906
25828
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
25907
25829
|
);
|
|
25908
|
-
return this._t(
|
|
25830
|
+
return this._t(path86, cache2, checkUnignored, slices);
|
|
25909
25831
|
}
|
|
25910
|
-
checkIgnore(
|
|
25911
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
25912
|
-
return this.test(
|
|
25832
|
+
checkIgnore(path86) {
|
|
25833
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
|
|
25834
|
+
return this.test(path86);
|
|
25913
25835
|
}
|
|
25914
|
-
const slices =
|
|
25836
|
+
const slices = path86.split(SLASH).filter(Boolean);
|
|
25915
25837
|
slices.pop();
|
|
25916
25838
|
if (slices.length) {
|
|
25917
25839
|
const parent = this._t(
|
|
@@ -25924,18 +25846,18 @@ var require_ignore = __commonJS({
|
|
|
25924
25846
|
return parent;
|
|
25925
25847
|
}
|
|
25926
25848
|
}
|
|
25927
|
-
return this._rules.test(
|
|
25849
|
+
return this._rules.test(path86, false, MODE_CHECK_IGNORE);
|
|
25928
25850
|
}
|
|
25929
|
-
_t(
|
|
25930
|
-
if (
|
|
25931
|
-
return cache2[
|
|
25851
|
+
_t(path86, cache2, checkUnignored, slices) {
|
|
25852
|
+
if (path86 in cache2) {
|
|
25853
|
+
return cache2[path86];
|
|
25932
25854
|
}
|
|
25933
25855
|
if (!slices) {
|
|
25934
|
-
slices =
|
|
25856
|
+
slices = path86.split(SLASH).filter(Boolean);
|
|
25935
25857
|
}
|
|
25936
25858
|
slices.pop();
|
|
25937
25859
|
if (!slices.length) {
|
|
25938
|
-
return cache2[
|
|
25860
|
+
return cache2[path86] = this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
25939
25861
|
}
|
|
25940
25862
|
const parent = this._t(
|
|
25941
25863
|
slices.join(SLASH) + SLASH,
|
|
@@ -25943,29 +25865,29 @@ var require_ignore = __commonJS({
|
|
|
25943
25865
|
checkUnignored,
|
|
25944
25866
|
slices
|
|
25945
25867
|
);
|
|
25946
|
-
return cache2[
|
|
25868
|
+
return cache2[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
25947
25869
|
}
|
|
25948
|
-
ignores(
|
|
25949
|
-
return this._test(
|
|
25870
|
+
ignores(path86) {
|
|
25871
|
+
return this._test(path86, this._ignoreCache, false).ignored;
|
|
25950
25872
|
}
|
|
25951
25873
|
createFilter() {
|
|
25952
|
-
return (
|
|
25874
|
+
return (path86) => !this.ignores(path86);
|
|
25953
25875
|
}
|
|
25954
25876
|
filter(paths) {
|
|
25955
25877
|
return makeArray(paths).filter(this.createFilter());
|
|
25956
25878
|
}
|
|
25957
25879
|
// @returns {TestResult}
|
|
25958
|
-
test(
|
|
25959
|
-
return this._test(
|
|
25880
|
+
test(path86) {
|
|
25881
|
+
return this._test(path86, this._testCache, true);
|
|
25960
25882
|
}
|
|
25961
25883
|
};
|
|
25962
25884
|
var factory = (options) => new Ignore(options);
|
|
25963
|
-
var isPathValid = (
|
|
25885
|
+
var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, RETURN_FALSE);
|
|
25964
25886
|
var setupWindows = () => {
|
|
25965
25887
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
25966
25888
|
checkPath.convert = makePosix;
|
|
25967
25889
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
25968
|
-
checkPath.isNotRelative = (
|
|
25890
|
+
checkPath.isNotRelative = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
|
|
25969
25891
|
};
|
|
25970
25892
|
if (
|
|
25971
25893
|
// Detect `process` so that it can run in browsers.
|
|
@@ -25981,8 +25903,8 @@ var require_ignore = __commonJS({
|
|
|
25981
25903
|
});
|
|
25982
25904
|
|
|
25983
25905
|
// ../bridge/src/code-nav/gitignore-filter.ts
|
|
25984
|
-
import
|
|
25985
|
-
import
|
|
25906
|
+
import fs12 from "node:fs";
|
|
25907
|
+
import path11 from "node:path";
|
|
25986
25908
|
function normalizeRelPath(relPath) {
|
|
25987
25909
|
return relPath.replace(/\\/g, "/");
|
|
25988
25910
|
}
|
|
@@ -25992,12 +25914,12 @@ function isUnderDir(relPath, dirRel) {
|
|
|
25992
25914
|
async function createGitignoreFilterForRelativePath(root, relPath) {
|
|
25993
25915
|
const filter = new GitignoreFilter();
|
|
25994
25916
|
await filter.enterDirectory(root, "");
|
|
25995
|
-
const dirRel = normalizeRelPath(
|
|
25917
|
+
const dirRel = normalizeRelPath(path11.dirname(relPath));
|
|
25996
25918
|
if (dirRel === "." || dirRel === "") return filter;
|
|
25997
25919
|
let abs = root;
|
|
25998
25920
|
let rel = "";
|
|
25999
25921
|
for (const segment of dirRel.split("/")) {
|
|
26000
|
-
abs =
|
|
25922
|
+
abs = path11.join(abs, segment);
|
|
26001
25923
|
rel = rel ? `${rel}/${segment}` : segment;
|
|
26002
25924
|
await filter.enterDirectory(abs, rel);
|
|
26003
25925
|
}
|
|
@@ -26019,7 +25941,7 @@ var init_gitignore_filter = __esm({
|
|
|
26019
25941
|
/** Load `.gitignore` in `absDir` and push a layer when the file exists. */
|
|
26020
25942
|
async enterDirectory(absDir, dirRel) {
|
|
26021
25943
|
try {
|
|
26022
|
-
const content = await
|
|
25944
|
+
const content = await fs12.promises.readFile(path11.join(absDir, ".gitignore"), "utf8");
|
|
26023
25945
|
this.layers.push({ dirRel, ig: (0, import_ignore.default)().add(content) });
|
|
26024
25946
|
} catch {
|
|
26025
25947
|
}
|
|
@@ -26046,7 +25968,7 @@ var init_gitignore_filter = __esm({
|
|
|
26046
25968
|
});
|
|
26047
25969
|
|
|
26048
25970
|
// ../bridge/src/code-nav/language-registry.ts
|
|
26049
|
-
import
|
|
25971
|
+
import path12 from "node:path";
|
|
26050
25972
|
function languageAssetPaths(key, wasmFile) {
|
|
26051
25973
|
return {
|
|
26052
25974
|
wasmFile,
|
|
@@ -26054,7 +25976,7 @@ function languageAssetPaths(key, wasmFile) {
|
|
|
26054
25976
|
};
|
|
26055
25977
|
}
|
|
26056
25978
|
function getLanguageKeyForFilePath(filePath) {
|
|
26057
|
-
const ext =
|
|
25979
|
+
const ext = path12.extname(filePath).replace(/^\./, "").toLowerCase();
|
|
26058
25980
|
if (!ext) return null;
|
|
26059
25981
|
return EXT_TO_LANGUAGE_KEY[ext] ?? null;
|
|
26060
25982
|
}
|
|
@@ -26104,13 +26026,13 @@ var init_language_registry = __esm({
|
|
|
26104
26026
|
});
|
|
26105
26027
|
|
|
26106
26028
|
// ../bridge/src/code-nav/walk-code-nav-files.ts
|
|
26107
|
-
import
|
|
26108
|
-
import
|
|
26029
|
+
import fs13 from "node:fs";
|
|
26030
|
+
import path13 from "node:path";
|
|
26109
26031
|
async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile, state) {
|
|
26110
26032
|
await filter.enterDirectory(dir, relDir);
|
|
26111
26033
|
let names;
|
|
26112
26034
|
try {
|
|
26113
|
-
names = await
|
|
26035
|
+
names = await fs13.promises.readdir(dir);
|
|
26114
26036
|
} catch {
|
|
26115
26037
|
filter.leaveDirectory(relDir);
|
|
26116
26038
|
return;
|
|
@@ -26127,10 +26049,10 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
26127
26049
|
}
|
|
26128
26050
|
state.n++;
|
|
26129
26051
|
const relPath = relDir ? `${relDir}/${name}` : name;
|
|
26130
|
-
const full =
|
|
26052
|
+
const full = path13.join(dir, name);
|
|
26131
26053
|
let stat3;
|
|
26132
26054
|
try {
|
|
26133
|
-
stat3 = await
|
|
26055
|
+
stat3 = await fs13.promises.stat(full);
|
|
26134
26056
|
} catch {
|
|
26135
26057
|
continue;
|
|
26136
26058
|
}
|
|
@@ -26147,7 +26069,7 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
26147
26069
|
filter.leaveDirectory(relDir);
|
|
26148
26070
|
}
|
|
26149
26071
|
async function walkCodeNavFilesAsync(rootDir, onFile, state = createWalkYieldState()) {
|
|
26150
|
-
const resolved =
|
|
26072
|
+
const resolved = path13.resolve(rootDir);
|
|
26151
26073
|
const filter = new GitignoreFilter();
|
|
26152
26074
|
await walkCodeNavFilesInDirectory(resolved, resolved, "", filter, onFile, state);
|
|
26153
26075
|
}
|
|
@@ -26910,7 +26832,7 @@ var init_persist_single_file = __esm({
|
|
|
26910
26832
|
});
|
|
26911
26833
|
|
|
26912
26834
|
// ../bridge/src/code-nav/resolve-module-import-path.ts
|
|
26913
|
-
import
|
|
26835
|
+
import path14 from "node:path";
|
|
26914
26836
|
function normalizeWorkspacePath(filePath) {
|
|
26915
26837
|
return filePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
26916
26838
|
}
|
|
@@ -26950,28 +26872,28 @@ function tsJsImportCandidates(joined) {
|
|
|
26950
26872
|
function resolveModuleImportPath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
26951
26873
|
const spec = moduleSpecifier.trim();
|
|
26952
26874
|
if (!spec || !isRelativeModuleSpecifier(spec)) return null;
|
|
26953
|
-
const importerDir =
|
|
26954
|
-
const joined = normalizeWorkspacePath(
|
|
26875
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26876
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
26955
26877
|
return firstExistingPath(tsJsImportCandidates(joined), workspaceFiles);
|
|
26956
26878
|
}
|
|
26957
26879
|
function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
26958
26880
|
const moduleName = moduleSpecifier.trim().replace(/\s+/g, "");
|
|
26959
26881
|
if (!moduleName) return null;
|
|
26960
|
-
const importerDir =
|
|
26882
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26961
26883
|
if (moduleName.startsWith(".")) {
|
|
26962
26884
|
const dotMatch = /^(\.+)(.*)$/.exec(moduleName);
|
|
26963
26885
|
const dotCount = dotMatch?.[1]?.length ?? 1;
|
|
26964
26886
|
const rest = (dotMatch?.[2] ?? "").replace(/^\./, "");
|
|
26965
26887
|
let baseDir = importerDir;
|
|
26966
26888
|
for (let i = 1; i < dotCount; i++) {
|
|
26967
|
-
baseDir =
|
|
26889
|
+
baseDir = path14.posix.dirname(baseDir);
|
|
26968
26890
|
}
|
|
26969
26891
|
const dottedPath2 = rest ? rest.split(".").join("/") : "";
|
|
26970
|
-
const relativeBase = dottedPath2 ?
|
|
26892
|
+
const relativeBase = dottedPath2 ? path14.posix.join(baseDir, dottedPath2) : baseDir;
|
|
26971
26893
|
return firstExistingPath(
|
|
26972
26894
|
[
|
|
26973
26895
|
...withSuffixes(relativeBase, PYTHON_EXTENSIONS),
|
|
26974
|
-
...withSuffixes(
|
|
26896
|
+
...withSuffixes(path14.posix.join(relativeBase, "__init__"), [".py"])
|
|
26975
26897
|
],
|
|
26976
26898
|
workspaceFiles
|
|
26977
26899
|
);
|
|
@@ -26980,7 +26902,7 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
26980
26902
|
return firstExistingPath(
|
|
26981
26903
|
[
|
|
26982
26904
|
...withSuffixes(dottedPath, PYTHON_EXTENSIONS),
|
|
26983
|
-
...withSuffixes(
|
|
26905
|
+
...withSuffixes(path14.posix.join(importerDir, dottedPath), PYTHON_EXTENSIONS)
|
|
26984
26906
|
],
|
|
26985
26907
|
workspaceFiles
|
|
26986
26908
|
);
|
|
@@ -26988,9 +26910,9 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
26988
26910
|
function resolveIncludePath(importerFilePath, includePath, workspaceFiles) {
|
|
26989
26911
|
const spec = includePath.trim().replace(/^["']|["']$/g, "");
|
|
26990
26912
|
if (!spec) return null;
|
|
26991
|
-
const importerDir =
|
|
26913
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26992
26914
|
const joined = normalizeWorkspacePath(
|
|
26993
|
-
|
|
26915
|
+
path14.posix.normalize(path14.posix.join(importerDir, spec.replace(/\\/g, "/")))
|
|
26994
26916
|
);
|
|
26995
26917
|
if (workspaceFiles.has(joined)) return joined;
|
|
26996
26918
|
return firstExistingPath(withSuffixes(joined, C_CPP_EXTENSIONS), workspaceFiles);
|
|
@@ -27009,8 +26931,8 @@ function resolveGoImportPath(importerFilePath, moduleSpecifier, workspaceFiles)
|
|
|
27009
26931
|
const spec = moduleSpecifier.trim();
|
|
27010
26932
|
if (!spec) return null;
|
|
27011
26933
|
if (isRelativeModuleSpecifier(spec)) {
|
|
27012
|
-
const importerDir =
|
|
27013
|
-
const joined = normalizeWorkspacePath(
|
|
26934
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
26935
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
27014
26936
|
if (workspaceFiles.has(joined)) return joined;
|
|
27015
26937
|
return firstExistingPath(withSuffixes(joined, [".go"]), workspaceFiles);
|
|
27016
26938
|
}
|
|
@@ -28438,12 +28360,12 @@ var init_workspace_files = __esm({
|
|
|
28438
28360
|
});
|
|
28439
28361
|
|
|
28440
28362
|
// ../bridge/src/code-nav/symbol-index/build/extract-file-symbol-data.ts
|
|
28441
|
-
import
|
|
28442
|
-
import
|
|
28363
|
+
import fs14 from "node:fs";
|
|
28364
|
+
import path15 from "node:path";
|
|
28443
28365
|
import { isMainThread as isMainThread3 } from "node:worker_threads";
|
|
28444
28366
|
async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride) {
|
|
28445
28367
|
await yieldForBridgeInteractivePriority();
|
|
28446
|
-
const absPath =
|
|
28368
|
+
const absPath = path15.join(resolved, relPath);
|
|
28447
28369
|
let tags = [];
|
|
28448
28370
|
let source = null;
|
|
28449
28371
|
if (isCodeNavSupportedPath(relPath) && !await isPathGitIgnored(resolved, relPath)) {
|
|
@@ -28451,16 +28373,16 @@ async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride)
|
|
|
28451
28373
|
assertBackgroundIndexingAllowed();
|
|
28452
28374
|
let fileSource = null;
|
|
28453
28375
|
if (isMainThread3) {
|
|
28454
|
-
const stat3 = await
|
|
28376
|
+
const stat3 = await fs14.promises.stat(absPath);
|
|
28455
28377
|
if (stat3.isFile() && stat3.size <= MAX_INDEX_FILE_BYTES) {
|
|
28456
28378
|
assertBackgroundIndexingAllowed();
|
|
28457
|
-
fileSource = await
|
|
28379
|
+
fileSource = await fs14.promises.readFile(absPath, "utf8");
|
|
28458
28380
|
}
|
|
28459
28381
|
} else {
|
|
28460
|
-
const stat3 =
|
|
28382
|
+
const stat3 = fs14.statSync(absPath);
|
|
28461
28383
|
if (stat3.isFile() && stat3.size <= MAX_INDEX_FILE_BYTES) {
|
|
28462
28384
|
assertBackgroundIndexingAllowed();
|
|
28463
|
-
fileSource =
|
|
28385
|
+
fileSource = fs14.readFileSync(absPath, "utf8");
|
|
28464
28386
|
}
|
|
28465
28387
|
}
|
|
28466
28388
|
source = fileSource;
|
|
@@ -28662,12 +28584,12 @@ var init_ensure_symbol_index_file_host = __esm({
|
|
|
28662
28584
|
});
|
|
28663
28585
|
|
|
28664
28586
|
// ../bridge/src/code-nav/symbol-index/lifecycle/normalize-symbol-index-path.ts
|
|
28665
|
-
import
|
|
28587
|
+
import path16 from "node:path";
|
|
28666
28588
|
function normalizeSymbolIndexRelPath2(parentPath, changedPath) {
|
|
28667
|
-
const resolvedParent =
|
|
28668
|
-
const abs =
|
|
28669
|
-
const rel =
|
|
28670
|
-
if (rel.startsWith("..") ||
|
|
28589
|
+
const resolvedParent = path16.resolve(parentPath);
|
|
28590
|
+
const abs = path16.isAbsolute(changedPath) ? path16.resolve(changedPath) : path16.resolve(resolvedParent, changedPath);
|
|
28591
|
+
const rel = path16.relative(resolvedParent, abs).replace(/\\/g, "/");
|
|
28592
|
+
if (rel.startsWith("..") || path16.isAbsolute(rel)) return null;
|
|
28671
28593
|
return rel;
|
|
28672
28594
|
}
|
|
28673
28595
|
var init_normalize_symbol_index_path = __esm({
|
|
@@ -30048,7 +29970,7 @@ var require_has_flag = __commonJS({
|
|
|
30048
29970
|
var require_supports_color = __commonJS({
|
|
30049
29971
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
30050
29972
|
"use strict";
|
|
30051
|
-
var
|
|
29973
|
+
var os10 = __require("os");
|
|
30052
29974
|
var tty = __require("tty");
|
|
30053
29975
|
var hasFlag = require_has_flag();
|
|
30054
29976
|
var { env } = process;
|
|
@@ -30096,7 +30018,7 @@ var require_supports_color = __commonJS({
|
|
|
30096
30018
|
return min;
|
|
30097
30019
|
}
|
|
30098
30020
|
if (process.platform === "win32") {
|
|
30099
|
-
const osRelease =
|
|
30021
|
+
const osRelease = os10.release().split(".");
|
|
30100
30022
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
30101
30023
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
30102
30024
|
}
|
|
@@ -30342,10 +30264,10 @@ var require_src2 = __commonJS({
|
|
|
30342
30264
|
var fs_1 = __require("fs");
|
|
30343
30265
|
var debug_1 = __importDefault(require_src());
|
|
30344
30266
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
30345
|
-
function check2(
|
|
30346
|
-
log2(`checking %s`,
|
|
30267
|
+
function check2(path86, isFile, isDirectory) {
|
|
30268
|
+
log2(`checking %s`, path86);
|
|
30347
30269
|
try {
|
|
30348
|
-
const stat3 = fs_1.statSync(
|
|
30270
|
+
const stat3 = fs_1.statSync(path86);
|
|
30349
30271
|
if (stat3.isFile() && isFile) {
|
|
30350
30272
|
log2(`[OK] path represents a file`);
|
|
30351
30273
|
return true;
|
|
@@ -30365,8 +30287,8 @@ var require_src2 = __commonJS({
|
|
|
30365
30287
|
throw e;
|
|
30366
30288
|
}
|
|
30367
30289
|
}
|
|
30368
|
-
function exists2(
|
|
30369
|
-
return check2(
|
|
30290
|
+
function exists2(path86, type = exports.READABLE) {
|
|
30291
|
+
return check2(path86, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
30370
30292
|
}
|
|
30371
30293
|
exports.exists = exists2;
|
|
30372
30294
|
exports.FILE = 1;
|
|
@@ -30447,14 +30369,14 @@ var {
|
|
|
30447
30369
|
} = import_index.default;
|
|
30448
30370
|
|
|
30449
30371
|
// src/cli-version.ts
|
|
30450
|
-
var CLI_VERSION = "0.1.
|
|
30372
|
+
var CLI_VERSION = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
30451
30373
|
|
|
30452
30374
|
// src/cli/defaults.ts
|
|
30453
30375
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
30454
30376
|
var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
|
|
30455
30377
|
|
|
30456
30378
|
// src/cli/run-cli-action.ts
|
|
30457
|
-
import * as
|
|
30379
|
+
import * as path85 from "node:path";
|
|
30458
30380
|
|
|
30459
30381
|
// ../../node_modules/.pnpm/ws@8.19.0/node_modules/ws/wrapper.mjs
|
|
30460
30382
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -30467,6 +30389,12 @@ var wrapper_default = import_websocket.default;
|
|
|
30467
30389
|
// ../bridge/src/connection/ws/cli-ws-client.ts
|
|
30468
30390
|
import https from "node:https";
|
|
30469
30391
|
var CLI_WEBSOCKET_CLIENT_PING_MS = 25e3;
|
|
30392
|
+
var CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
30393
|
+
var sharedWssAgent = null;
|
|
30394
|
+
function cliWssAgent() {
|
|
30395
|
+
sharedWssAgent ??= new https.Agent({ rejectUnauthorized: false, keepAlive: true });
|
|
30396
|
+
return sharedWssAgent;
|
|
30397
|
+
}
|
|
30470
30398
|
function attachWebSocketClientPing(ws, intervalMs) {
|
|
30471
30399
|
let timer = null;
|
|
30472
30400
|
function clear() {
|
|
@@ -30487,9 +30415,12 @@ function attachWebSocketClientPing(ws, intervalMs) {
|
|
|
30487
30415
|
return clear;
|
|
30488
30416
|
}
|
|
30489
30417
|
function buildCliWebSocketClientOptions(wsUrl) {
|
|
30490
|
-
const wsOptions = {
|
|
30418
|
+
const wsOptions = {
|
|
30419
|
+
perMessageDeflate: false,
|
|
30420
|
+
handshakeTimeout: CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS
|
|
30421
|
+
};
|
|
30491
30422
|
if (wsUrl.startsWith("wss://")) {
|
|
30492
|
-
wsOptions.agent =
|
|
30423
|
+
wsOptions.agent = cliWssAgent();
|
|
30493
30424
|
}
|
|
30494
30425
|
return wsOptions;
|
|
30495
30426
|
}
|
|
@@ -30503,6 +30434,15 @@ function safeCloseWebSocket(ws) {
|
|
|
30503
30434
|
ws.removeAllListeners();
|
|
30504
30435
|
return;
|
|
30505
30436
|
}
|
|
30437
|
+
if (ws.readyState === wrapper_default.CONNECTING) {
|
|
30438
|
+
ws.once("error", () => {
|
|
30439
|
+
});
|
|
30440
|
+
ws.once("close", () => {
|
|
30441
|
+
ws.removeAllListeners();
|
|
30442
|
+
});
|
|
30443
|
+
ws.terminate();
|
|
30444
|
+
return;
|
|
30445
|
+
}
|
|
30506
30446
|
ws.once("close", () => {
|
|
30507
30447
|
ws.removeAllListeners();
|
|
30508
30448
|
});
|
|
@@ -31459,8 +31399,8 @@ function getErrorMap() {
|
|
|
31459
31399
|
|
|
31460
31400
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
31461
31401
|
var makeIssue = (params) => {
|
|
31462
|
-
const { data, path:
|
|
31463
|
-
const fullPath = [...
|
|
31402
|
+
const { data, path: path86, errorMaps, issueData } = params;
|
|
31403
|
+
const fullPath = [...path86, ...issueData.path || []];
|
|
31464
31404
|
const fullIssue = {
|
|
31465
31405
|
...issueData,
|
|
31466
31406
|
path: fullPath
|
|
@@ -31576,11 +31516,11 @@ var errorUtil;
|
|
|
31576
31516
|
|
|
31577
31517
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
31578
31518
|
var ParseInputLazyPath = class {
|
|
31579
|
-
constructor(parent, value,
|
|
31519
|
+
constructor(parent, value, path86, key) {
|
|
31580
31520
|
this._cachedPath = [];
|
|
31581
31521
|
this.parent = parent;
|
|
31582
31522
|
this.data = value;
|
|
31583
|
-
this._path =
|
|
31523
|
+
this._path = path86;
|
|
31584
31524
|
this._key = key;
|
|
31585
31525
|
}
|
|
31586
31526
|
get path() {
|
|
@@ -35490,83 +35430,8 @@ function isUserEndedSessionTurnErrorText(errorText) {
|
|
|
35490
35430
|
}
|
|
35491
35431
|
|
|
35492
35432
|
// ../types/src/session-kind.ts
|
|
35493
|
-
var SESSION_KINDS = ["regular", "
|
|
35433
|
+
var SESSION_KINDS = ["regular", "planned"];
|
|
35494
35434
|
var SESSION_KIND_SET = new Set(SESSION_KINDS);
|
|
35495
|
-
function parseSessionKind(raw) {
|
|
35496
|
-
if (raw === "todo") return "planned";
|
|
35497
|
-
if (typeof raw === "string" && SESSION_KIND_SET.has(raw)) return raw;
|
|
35498
|
-
return "regular";
|
|
35499
|
-
}
|
|
35500
|
-
|
|
35501
|
-
// ../types/src/planning-todo.ts
|
|
35502
|
-
function planningTodoTitle(item) {
|
|
35503
|
-
return item.content.title;
|
|
35504
|
-
}
|
|
35505
|
-
|
|
35506
|
-
// ../types/src/parse-planning-todo-agent-json.ts
|
|
35507
|
-
function parsePlanningTodoAgentJson(raw) {
|
|
35508
|
-
if (raw == null || raw.trim() === "") return [];
|
|
35509
|
-
let text = raw.trim();
|
|
35510
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
35511
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
35512
|
-
let parsed;
|
|
35513
|
-
try {
|
|
35514
|
-
parsed = JSON.parse(text);
|
|
35515
|
-
} catch {
|
|
35516
|
-
const start = text.indexOf("[");
|
|
35517
|
-
const end = text.lastIndexOf("]");
|
|
35518
|
-
if (start < 0 || end <= start) return [];
|
|
35519
|
-
try {
|
|
35520
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
35521
|
-
} catch {
|
|
35522
|
-
return [];
|
|
35523
|
-
}
|
|
35524
|
-
}
|
|
35525
|
-
if (!Array.isArray(parsed)) return [];
|
|
35526
|
-
const rows = [];
|
|
35527
|
-
for (const item of parsed) {
|
|
35528
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
35529
|
-
const o = item;
|
|
35530
|
-
const title = typeof o.title === "string" ? o.title.trim() : "";
|
|
35531
|
-
const prompt = typeof o.prompt === "string" ? o.prompt.trim() : typeof o.promptText === "string" ? o.promptText.trim() : "";
|
|
35532
|
-
if (!title || !prompt) continue;
|
|
35533
|
-
rows.push({ title, prompt });
|
|
35534
|
-
}
|
|
35535
|
-
return rows;
|
|
35536
|
-
}
|
|
35537
|
-
|
|
35538
|
-
// ../types/src/build-planning-session-agent-prompt.ts
|
|
35539
|
-
var PLANNING_INSTRUCTIONS = [
|
|
35540
|
-
"PLANNING MODE: You must NOT make any changes to the codebase, filesystem, or environment.",
|
|
35541
|
-
"Do not run tools that modify files or execute commands that change state.",
|
|
35542
|
-
"Your only task is to analyze and produce a plan.",
|
|
35543
|
-
"",
|
|
35544
|
-
"Respond with ONLY a single JSON array \u2014 no markdown fences, no other text before or after.",
|
|
35545
|
-
"Each array element must be an object with exactly:",
|
|
35546
|
-
'- "title": a one-line summary of the task',
|
|
35547
|
-
'- "prompt": the full prompt to use when creating a new draft session from this todo',
|
|
35548
|
-
"",
|
|
35549
|
-
"Example:",
|
|
35550
|
-
'[{"title":"Add user login","prompt":"Implement a login form with email and password..."}]'
|
|
35551
|
-
].join("\n");
|
|
35552
|
-
function buildPlanningSessionAgentPrompt(userPrompt) {
|
|
35553
|
-
return [PLANNING_INSTRUCTIONS, "", "User request:", userPrompt.trim()].join("\n");
|
|
35554
|
-
}
|
|
35555
|
-
function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
35556
|
-
const todoLines = existingTodos.length > 0 ? existingTodos.map((t) => {
|
|
35557
|
-
const status = t.plannedSessionId ? "DONE (draft session already created)" : "OPEN";
|
|
35558
|
-
return `- [${status}] ${planningTodoTitle(t)}`;
|
|
35559
|
-
}).join("\n") : "(none yet)";
|
|
35560
|
-
return [
|
|
35561
|
-
PLANNING_INSTRUCTIONS,
|
|
35562
|
-
"",
|
|
35563
|
-
"Existing todo items from this planning session (consider these when responding; do not duplicate completed items):",
|
|
35564
|
-
todoLines,
|
|
35565
|
-
"",
|
|
35566
|
-
"User follow-up:",
|
|
35567
|
-
userPrompt.trim()
|
|
35568
|
-
].join("\n");
|
|
35569
|
-
}
|
|
35570
35435
|
|
|
35571
35436
|
// ../types/src/diff/line-diff.ts
|
|
35572
35437
|
function normalizeDiffLineText(line) {
|
|
@@ -35807,19 +35672,6 @@ function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
|
35807
35672
|
};
|
|
35808
35673
|
}
|
|
35809
35674
|
|
|
35810
|
-
// ../types/src/acp-agent-text-stream-bucket.ts
|
|
35811
|
-
function resolveAgentTextStreamBucket(params) {
|
|
35812
|
-
const k = params.transcriptRowKind;
|
|
35813
|
-
const su = params.sessionUpdate;
|
|
35814
|
-
if (k === "agent_thought_chunk" || su === "agent_thought_chunk" || k === "thinking" || su === "thinking") {
|
|
35815
|
-
return "thought";
|
|
35816
|
-
}
|
|
35817
|
-
if (k === "agent_message_chunk" || su === "agent_message_chunk" || k === "update" || su === "update") {
|
|
35818
|
-
return "message";
|
|
35819
|
-
}
|
|
35820
|
-
return null;
|
|
35821
|
-
}
|
|
35822
|
-
|
|
35823
35675
|
// ../types/src/agent-config.ts
|
|
35824
35676
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
35825
35677
|
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
@@ -36525,7 +36377,25 @@ function spawnSdkStdioProcess(options) {
|
|
|
36525
36377
|
return { child, stderrCapture };
|
|
36526
36378
|
}
|
|
36527
36379
|
|
|
36380
|
+
// ../bridge/src/agents/acp/clients/listen-for-acp-client-abort.ts
|
|
36381
|
+
function listenForAcpClientAbort(child, signal, onAbort) {
|
|
36382
|
+
if (!signal) return () => {
|
|
36383
|
+
};
|
|
36384
|
+
const fire = () => {
|
|
36385
|
+
killChildProcessTree(child, "SIGKILL");
|
|
36386
|
+
onAbort();
|
|
36387
|
+
};
|
|
36388
|
+
if (signal.aborted) {
|
|
36389
|
+
fire();
|
|
36390
|
+
return () => {
|
|
36391
|
+
};
|
|
36392
|
+
}
|
|
36393
|
+
signal.addEventListener("abort", fire, { once: true });
|
|
36394
|
+
return () => signal.removeEventListener("abort", fire);
|
|
36395
|
+
}
|
|
36396
|
+
|
|
36528
36397
|
// ../bridge/src/agents/acp/clients/sdk/sdk-stdio-acp-client.ts
|
|
36398
|
+
init_yield_to_event_loop();
|
|
36529
36399
|
async function createSdkStdioAcpClient(options) {
|
|
36530
36400
|
const { PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
36531
36401
|
const {
|
|
@@ -36543,13 +36413,18 @@ async function createSdkStdioAcpClient(options) {
|
|
|
36543
36413
|
onAcpConfigOptionsUpdated,
|
|
36544
36414
|
getActiveConfigOptions,
|
|
36545
36415
|
afterSessionEstablished,
|
|
36546
|
-
createExtNotificationHandler
|
|
36416
|
+
createExtNotificationHandler,
|
|
36417
|
+
signal
|
|
36547
36418
|
} = options;
|
|
36419
|
+
if (signal?.aborted) {
|
|
36420
|
+
throw new Error("ACP client aborted");
|
|
36421
|
+
}
|
|
36548
36422
|
const { child, stderrCapture } = spawnSdkStdioProcess({
|
|
36549
36423
|
command,
|
|
36550
36424
|
cwd,
|
|
36551
36425
|
onAgentSubprocessExit
|
|
36552
36426
|
});
|
|
36427
|
+
await yieldToEventLoop();
|
|
36553
36428
|
const sessionCtx = createSdkStdioSessionContext({
|
|
36554
36429
|
cwd,
|
|
36555
36430
|
mcpServers: options.mcpServers,
|
|
@@ -36565,7 +36440,11 @@ async function createSdkStdioAcpClient(options) {
|
|
|
36565
36440
|
});
|
|
36566
36441
|
return new Promise((resolve39, reject) => {
|
|
36567
36442
|
const init = createSdkStdioInitSettle(child);
|
|
36443
|
+
const stopAbort = listenForAcpClientAbort(child, signal, () => {
|
|
36444
|
+
init.settleReject(reject, new Error("ACP client aborted"));
|
|
36445
|
+
});
|
|
36568
36446
|
child.on("error", (err) => {
|
|
36447
|
+
stopAbort();
|
|
36569
36448
|
init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
|
|
36570
36449
|
});
|
|
36571
36450
|
attachSdkStdioStderrAuthWatch({
|
|
@@ -36599,7 +36478,9 @@ async function createSdkStdioAcpClient(options) {
|
|
|
36599
36478
|
killSubprocessAfterCancelMs
|
|
36600
36479
|
})
|
|
36601
36480
|
);
|
|
36481
|
+
stopAbort();
|
|
36602
36482
|
} catch (err) {
|
|
36483
|
+
stopAbort();
|
|
36603
36484
|
if (init.settled) return;
|
|
36604
36485
|
init.settleReject(
|
|
36605
36486
|
reject,
|
|
@@ -36871,22 +36752,12 @@ function installBridgeProcessResilience() {
|
|
|
36871
36752
|
init_log();
|
|
36872
36753
|
|
|
36873
36754
|
// ../bridge/src/agents/acp/clients/bridge-agent-path.ts
|
|
36874
|
-
import { execFileSync } from "node:child_process";
|
|
36875
36755
|
import { homedir } from "node:os";
|
|
36876
36756
|
import { join } from "node:path";
|
|
36877
36757
|
function getBridgeAgentPathEntries(home = process.env.HOME ?? homedir()) {
|
|
36878
|
-
const entries = [
|
|
36879
|
-
join(home, ".local", "bin"),
|
|
36880
|
-
join(home, ".npm-global", "bin"),
|
|
36881
|
-
"/usr/local/bin"
|
|
36882
|
-
];
|
|
36758
|
+
const entries = [join(home, ".local", "bin"), join(home, ".npm-global", "bin"), "/usr/local/bin"];
|
|
36883
36759
|
const prefix = process.env.NPM_CONFIG_PREFIX;
|
|
36884
36760
|
if (prefix) entries.push(join(prefix, "bin"));
|
|
36885
|
-
try {
|
|
36886
|
-
const npmBin = execFileSync("npm", ["bin", "-g"], { encoding: "utf8", timeout: 2e3 }).trim();
|
|
36887
|
-
if (npmBin) entries.push(npmBin);
|
|
36888
|
-
} catch {
|
|
36889
|
-
}
|
|
36890
36761
|
return entries;
|
|
36891
36762
|
}
|
|
36892
36763
|
function augmentPath(pathValue, extra) {
|
|
@@ -36911,7 +36782,7 @@ function bridgeAgentPathEnv(base = process.env) {
|
|
|
36911
36782
|
}
|
|
36912
36783
|
|
|
36913
36784
|
// ../bridge/src/files/watch-file-index.ts
|
|
36914
|
-
import
|
|
36785
|
+
import path21 from "node:path";
|
|
36915
36786
|
|
|
36916
36787
|
// ../bridge/src/files/index/index.ts
|
|
36917
36788
|
init_paths();
|
|
@@ -36920,7 +36791,7 @@ init_paths();
|
|
|
36920
36791
|
init_in_flight();
|
|
36921
36792
|
init_cli_process_interrupt();
|
|
36922
36793
|
init_database();
|
|
36923
|
-
import
|
|
36794
|
+
import path17 from "node:path";
|
|
36924
36795
|
|
|
36925
36796
|
// ../bridge/src/files/index/file-index-sqlite-lock.ts
|
|
36926
36797
|
var fileIndexChain = Promise.resolve();
|
|
@@ -37027,7 +36898,7 @@ function assertNotShutdown2() {
|
|
|
37027
36898
|
if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
|
|
37028
36899
|
}
|
|
37029
36900
|
async function buildFileIndexAsync(cwd) {
|
|
37030
|
-
const resolved =
|
|
36901
|
+
const resolved = path17.resolve(cwd);
|
|
37031
36902
|
await yieldForBridgeInteractivePriority();
|
|
37032
36903
|
assertNotShutdown2();
|
|
37033
36904
|
const paths = await collectWorkspacePathsAsync(resolved);
|
|
@@ -37040,7 +36911,7 @@ async function buildFileIndexAsync(cwd) {
|
|
|
37040
36911
|
}
|
|
37041
36912
|
|
|
37042
36913
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
37043
|
-
import
|
|
36914
|
+
import path18 from "node:path";
|
|
37044
36915
|
|
|
37045
36916
|
// ../bridge/src/files/index/search-file-index.ts
|
|
37046
36917
|
init_yield_to_event_loop();
|
|
@@ -37095,7 +36966,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
|
|
|
37095
36966
|
|
|
37096
36967
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
37097
36968
|
async function ensureFileIndexAsync(cwd) {
|
|
37098
|
-
const resolved =
|
|
36969
|
+
const resolved = path18.resolve(cwd);
|
|
37099
36970
|
if (await bridgeFileIndexIsPopulated(resolved)) {
|
|
37100
36971
|
return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
|
|
37101
36972
|
}
|
|
@@ -37847,16 +37718,16 @@ init_database();
|
|
|
37847
37718
|
init_cli_process_interrupt();
|
|
37848
37719
|
|
|
37849
37720
|
// ../bridge/src/files/index/file-index-incremental-symbol-updates.ts
|
|
37850
|
-
import
|
|
37851
|
-
import
|
|
37721
|
+
import fs15 from "node:fs";
|
|
37722
|
+
import path19 from "node:path";
|
|
37852
37723
|
init_cli_process_interrupt();
|
|
37853
37724
|
init_yield_to_event_loop();
|
|
37854
37725
|
init_database();
|
|
37855
37726
|
async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
|
|
37856
37727
|
for (const rel of relPaths) {
|
|
37857
|
-
const absPath =
|
|
37728
|
+
const absPath = path19.join(resolved, rel);
|
|
37858
37729
|
try {
|
|
37859
|
-
const stat3 = await
|
|
37730
|
+
const stat3 = await fs15.promises.stat(absPath);
|
|
37860
37731
|
if (stat3.isFile()) {
|
|
37861
37732
|
await updateSymbolIndexForFile(resolved, absPath);
|
|
37862
37733
|
} else {
|
|
@@ -37970,11 +37841,11 @@ function createFileIndexFsWatcher(resolved, schedule) {
|
|
|
37970
37841
|
}
|
|
37971
37842
|
|
|
37972
37843
|
// ../bridge/src/files/index/file-index-initial-builds.ts
|
|
37973
|
-
import
|
|
37844
|
+
import path20 from "node:path";
|
|
37974
37845
|
init_database();
|
|
37975
37846
|
init_code_nav_cache_availability();
|
|
37976
37847
|
async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
37977
|
-
const resolved =
|
|
37848
|
+
const resolved = path20.resolve(cwd);
|
|
37978
37849
|
try {
|
|
37979
37850
|
if (!await startCodeNavCacheInitialization()) return;
|
|
37980
37851
|
await buildFileIndexAsync(resolved);
|
|
@@ -37993,7 +37864,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
|
37993
37864
|
|
|
37994
37865
|
// ../bridge/src/files/watch-file-index.ts
|
|
37995
37866
|
function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
37996
|
-
const resolved =
|
|
37867
|
+
const resolved = path21.resolve(cwd);
|
|
37997
37868
|
const rebuildState = createFileIndexWatchRebuildState();
|
|
37998
37869
|
let timer = null;
|
|
37999
37870
|
const schedule = (relPath) => {
|
|
@@ -38128,6 +37999,22 @@ function beginDeferredDisconnectForReconnect(options) {
|
|
|
38128
37999
|
}
|
|
38129
38000
|
}
|
|
38130
38001
|
|
|
38002
|
+
// ../bridge/src/connection/ws/dispose-previous-bridge-socket.ts
|
|
38003
|
+
function disposePreviousBridgeSocket(ws) {
|
|
38004
|
+
if (!ws) return;
|
|
38005
|
+
ws.removeAllListeners();
|
|
38006
|
+
ws.once("error", () => {
|
|
38007
|
+
});
|
|
38008
|
+
ws.once("close", () => {
|
|
38009
|
+
ws.removeAllListeners();
|
|
38010
|
+
});
|
|
38011
|
+
try {
|
|
38012
|
+
if (ws.readyState === wrapper_default.CONNECTING) ws.terminate();
|
|
38013
|
+
else ws.close();
|
|
38014
|
+
} catch {
|
|
38015
|
+
}
|
|
38016
|
+
}
|
|
38017
|
+
|
|
38131
38018
|
// ../bridge/src/connection/runtime/close-bridge-connection.ts
|
|
38132
38019
|
async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
|
|
38133
38020
|
requestCliImmediateShutdown();
|
|
@@ -38144,16 +38031,7 @@ async function closeBridgeConnection(state, acpManager, previewEnvironmentManage
|
|
|
38144
38031
|
await acpManager.disconnect();
|
|
38145
38032
|
if (state.currentWs) {
|
|
38146
38033
|
say("Closing bridge connection to the cloud\u2026");
|
|
38147
|
-
state.currentWs
|
|
38148
|
-
const wsState = state.currentWs.readyState;
|
|
38149
|
-
if (wsState === 1 || wsState === 2) {
|
|
38150
|
-
state.currentWs.close();
|
|
38151
|
-
} else {
|
|
38152
|
-
state.currentWs.on("error", () => {
|
|
38153
|
-
});
|
|
38154
|
-
state.currentWs.on("close", () => {
|
|
38155
|
-
});
|
|
38156
|
-
}
|
|
38034
|
+
disposePreviousBridgeSocket(state.currentWs);
|
|
38157
38035
|
state.currentWs = null;
|
|
38158
38036
|
}
|
|
38159
38037
|
if (previewEnvironmentManager) {
|
|
@@ -38246,20 +38124,20 @@ async function cancelRun(ctx, runId) {
|
|
|
38246
38124
|
}
|
|
38247
38125
|
|
|
38248
38126
|
// ../bridge/src/agents/acp/ensure-acp-client.ts
|
|
38249
|
-
import * as
|
|
38250
|
-
import * as
|
|
38127
|
+
import * as fs18 from "node:fs";
|
|
38128
|
+
import * as path27 from "node:path";
|
|
38251
38129
|
|
|
38252
38130
|
// ../bridge/src/paths/session-layout-paths.ts
|
|
38253
|
-
import * as
|
|
38131
|
+
import * as path22 from "node:path";
|
|
38254
38132
|
function resolveIsolatedSessionParentPathFromCheckouts(worktreePaths) {
|
|
38255
|
-
const resolved = worktreePaths.map((p) =>
|
|
38133
|
+
const resolved = worktreePaths.map((p) => path22.resolve(p)).filter(Boolean);
|
|
38256
38134
|
if (resolved.length === 0) return null;
|
|
38257
38135
|
resolved.sort();
|
|
38258
38136
|
return resolved[0];
|
|
38259
38137
|
}
|
|
38260
38138
|
function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
|
|
38261
38139
|
if (resolvedSessionParentPath != null && String(resolvedSessionParentPath).trim() !== "") {
|
|
38262
|
-
return
|
|
38140
|
+
return path22.resolve(String(resolvedSessionParentPath).trim());
|
|
38263
38141
|
}
|
|
38264
38142
|
return getBridgeRoot();
|
|
38265
38143
|
}
|
|
@@ -38640,20 +38518,20 @@ var codexProvider = {
|
|
|
38640
38518
|
};
|
|
38641
38519
|
|
|
38642
38520
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
38643
|
-
import * as
|
|
38521
|
+
import * as fs16 from "node:fs";
|
|
38644
38522
|
|
|
38645
38523
|
// ../bridge/src/paths/session-plans-paths.ts
|
|
38646
|
-
import * as
|
|
38647
|
-
import * as
|
|
38524
|
+
import * as os5 from "node:os";
|
|
38525
|
+
import * as path23 from "node:path";
|
|
38648
38526
|
function getSessionPlansRootDir() {
|
|
38649
|
-
return
|
|
38527
|
+
return path23.join(os5.homedir(), ".buildautomaton", "plans");
|
|
38650
38528
|
}
|
|
38651
38529
|
function sanitizeSessionPlansKey(sessionId) {
|
|
38652
38530
|
const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
|
|
38653
38531
|
return t || "session";
|
|
38654
38532
|
}
|
|
38655
38533
|
function getSessionPlansDir(sessionId) {
|
|
38656
|
-
return
|
|
38534
|
+
return path23.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
|
|
38657
38535
|
}
|
|
38658
38536
|
|
|
38659
38537
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
@@ -38662,7 +38540,7 @@ function cleanupSessionPlans(sessionId) {
|
|
|
38662
38540
|
if (!id) return;
|
|
38663
38541
|
const dir = getSessionPlansDir(id);
|
|
38664
38542
|
try {
|
|
38665
|
-
|
|
38543
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
38666
38544
|
} catch {
|
|
38667
38545
|
}
|
|
38668
38546
|
}
|
|
@@ -39030,8 +38908,8 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
|
|
|
39030
38908
|
}
|
|
39031
38909
|
|
|
39032
38910
|
// ../bridge/src/agents/providers/cursor/write-create-plan-file.ts
|
|
39033
|
-
import * as
|
|
39034
|
-
import * as
|
|
38911
|
+
import * as fs17 from "node:fs";
|
|
38912
|
+
import * as path24 from "node:path";
|
|
39035
38913
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
39036
38914
|
function sanitizePlanFileBase(toolCallId) {
|
|
39037
38915
|
const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
|
|
@@ -39039,9 +38917,9 @@ function sanitizePlanFileBase(toolCallId) {
|
|
|
39039
38917
|
}
|
|
39040
38918
|
function writeCreatePlanFile(params) {
|
|
39041
38919
|
const dir = getSessionPlansDir(params.cloudSessionId);
|
|
39042
|
-
|
|
39043
|
-
const filePath =
|
|
39044
|
-
|
|
38920
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
38921
|
+
const filePath = path24.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
|
|
38922
|
+
fs17.writeFileSync(filePath, params.planMarkdown, "utf8");
|
|
39045
38923
|
return pathToFileURL2(filePath).href;
|
|
39046
38924
|
}
|
|
39047
38925
|
|
|
@@ -39347,7 +39225,8 @@ async function createCursorAcpClient(options) {
|
|
|
39347
39225
|
onAcpSessionEstablished,
|
|
39348
39226
|
onAcpConfigOptionsUpdated,
|
|
39349
39227
|
onAgentSubprocessExit,
|
|
39350
|
-
afterSessionEstablished
|
|
39228
|
+
afterSessionEstablished,
|
|
39229
|
+
signal
|
|
39351
39230
|
} = options;
|
|
39352
39231
|
const dbgFs = process.env.BUILDAUTOMATON_DEBUG_ACP_FS === "1";
|
|
39353
39232
|
const spawnEnv = bridgeInstalledAgentAuthProcessEnv(process.env);
|
|
@@ -39372,7 +39251,11 @@ async function createCursorAcpClient(options) {
|
|
|
39372
39251
|
stderrCapture
|
|
39373
39252
|
});
|
|
39374
39253
|
return new Promise((resolve39, reject) => {
|
|
39254
|
+
const stopAbort = listenForAcpClientAbort(child, signal, () => {
|
|
39255
|
+
reject(new Error("ACP client aborted"));
|
|
39256
|
+
});
|
|
39375
39257
|
child.on("error", (err) => {
|
|
39258
|
+
stopAbort();
|
|
39376
39259
|
killChildProcessTree(child, "SIGKILL");
|
|
39377
39260
|
reject(new Error(formatSpawnError(err, command[0])));
|
|
39378
39261
|
});
|
|
@@ -39384,6 +39267,7 @@ async function createCursorAcpClient(options) {
|
|
|
39384
39267
|
skipBrowserAuthenticate,
|
|
39385
39268
|
incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
|
|
39386
39269
|
});
|
|
39270
|
+
stopAbort();
|
|
39387
39271
|
resolve39(
|
|
39388
39272
|
createCursorAcpHandle({
|
|
39389
39273
|
child,
|
|
@@ -39396,6 +39280,7 @@ async function createCursorAcpClient(options) {
|
|
|
39396
39280
|
})
|
|
39397
39281
|
);
|
|
39398
39282
|
} catch (err) {
|
|
39283
|
+
stopAbort();
|
|
39399
39284
|
killChildProcessTree(child, "SIGKILL");
|
|
39400
39285
|
const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrCapture.getText());
|
|
39401
39286
|
reject(merged ? new Error(merged) : err instanceof Error ? err : new Error(String(err)));
|
|
@@ -39562,7 +39447,7 @@ function getAgentTypeDisplayName(agentType) {
|
|
|
39562
39447
|
import { existsSync as existsSync4, statSync } from "node:fs";
|
|
39563
39448
|
|
|
39564
39449
|
// ../bridge/src/git/git-exec.ts
|
|
39565
|
-
import { execFile as execFile2, execFileSync
|
|
39450
|
+
import { execFile as execFile2, execFileSync, spawn as spawn4 } from "node:child_process";
|
|
39566
39451
|
import { promisify as promisify3 } from "node:util";
|
|
39567
39452
|
|
|
39568
39453
|
// ../bridge/src/git/git-runtime.ts
|
|
@@ -39620,7 +39505,7 @@ init_cli_process_interrupt();
|
|
|
39620
39505
|
var execFileAsync2 = promisify3(execFile2);
|
|
39621
39506
|
var GIT_SYNC_STDIO = ["ignore", "pipe", "pipe"];
|
|
39622
39507
|
function execGitFileSync(args, options) {
|
|
39623
|
-
return
|
|
39508
|
+
return execFileSync("git", args, {
|
|
39624
39509
|
encoding: "utf8",
|
|
39625
39510
|
maxBuffer: 10 * 1024 * 1024,
|
|
39626
39511
|
...options,
|
|
@@ -39648,16 +39533,16 @@ async function execGitFile(args, options) {
|
|
|
39648
39533
|
}
|
|
39649
39534
|
|
|
39650
39535
|
// ../bridge/src/git/get-git-repo-root-sync.ts
|
|
39651
|
-
import * as
|
|
39536
|
+
import * as path25 from "node:path";
|
|
39652
39537
|
var GIT_LOOKUP_TIMEOUT_MS = 2e3;
|
|
39653
39538
|
function getGitRepoRootSync(startDir) {
|
|
39654
39539
|
try {
|
|
39655
39540
|
const out = execGitFileSync(["rev-parse", "--show-toplevel"], {
|
|
39656
|
-
cwd:
|
|
39541
|
+
cwd: path25.resolve(startDir),
|
|
39657
39542
|
maxBuffer: 1024 * 1024,
|
|
39658
39543
|
timeout: GIT_LOOKUP_TIMEOUT_MS
|
|
39659
39544
|
}).trim();
|
|
39660
|
-
return out ?
|
|
39545
|
+
return out ? path25.resolve(out) : null;
|
|
39661
39546
|
} catch {
|
|
39662
39547
|
return null;
|
|
39663
39548
|
}
|
|
@@ -39665,26 +39550,26 @@ function getGitRepoRootSync(startDir) {
|
|
|
39665
39550
|
|
|
39666
39551
|
// ../bridge/src/agents/acp/workspace-files.ts
|
|
39667
39552
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
39668
|
-
import * as
|
|
39553
|
+
import * as path26 from "node:path";
|
|
39669
39554
|
var GIT_FILE_READ_TIMEOUT_MS = 2e3;
|
|
39670
39555
|
function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
|
|
39671
39556
|
const trimmed2 = rawPath.trim();
|
|
39672
39557
|
if (!trimmed2) return null;
|
|
39673
|
-
const normalizedSessionParent =
|
|
39558
|
+
const normalizedSessionParent = path26.resolve(sessionParentPath);
|
|
39674
39559
|
let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
|
|
39675
39560
|
if (!resolvedPath) {
|
|
39676
|
-
const candidate =
|
|
39561
|
+
const candidate = path26.isAbsolute(trimmed2) ? path26.normalize(trimmed2) : path26.normalize(path26.resolve(normalizedSessionParent, trimmed2));
|
|
39677
39562
|
const gitRoot2 = getGitRepoRootSync(sessionParentPath);
|
|
39678
39563
|
if (!gitRoot2) return null;
|
|
39679
|
-
const rel =
|
|
39680
|
-
if (rel.startsWith("..") ||
|
|
39564
|
+
const rel = path26.relative(gitRoot2, candidate);
|
|
39565
|
+
if (rel.startsWith("..") || path26.isAbsolute(rel)) return null;
|
|
39681
39566
|
resolvedPath = candidate;
|
|
39682
39567
|
}
|
|
39683
39568
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39684
39569
|
if (gitRoot) {
|
|
39685
|
-
const relFromRoot =
|
|
39686
|
-
if (!relFromRoot.startsWith("..") && !
|
|
39687
|
-
return { resolvedPath, display: relFromRoot.split(
|
|
39570
|
+
const relFromRoot = path26.relative(gitRoot, resolvedPath);
|
|
39571
|
+
if (!relFromRoot.startsWith("..") && !path26.isAbsolute(relFromRoot)) {
|
|
39572
|
+
return { resolvedPath, display: relFromRoot.split(path26.sep).join("/") };
|
|
39688
39573
|
}
|
|
39689
39574
|
}
|
|
39690
39575
|
return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
|
|
@@ -39693,9 +39578,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
|
|
|
39693
39578
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
39694
39579
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39695
39580
|
if (gitRoot) {
|
|
39696
|
-
const resolvedPath2 =
|
|
39697
|
-
const rel =
|
|
39698
|
-
if (!rel.startsWith("..") && !
|
|
39581
|
+
const resolvedPath2 = path26.resolve(gitRoot, displayPath);
|
|
39582
|
+
const rel = path26.relative(gitRoot, resolvedPath2);
|
|
39583
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) {
|
|
39699
39584
|
try {
|
|
39700
39585
|
return readFileSync4(resolvedPath2, "utf8");
|
|
39701
39586
|
} catch {
|
|
@@ -39714,9 +39599,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
|
|
|
39714
39599
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
39715
39600
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
39716
39601
|
if (gitRoot) {
|
|
39717
|
-
const resolvedPath =
|
|
39718
|
-
const rel =
|
|
39719
|
-
if (!rel.startsWith("..") && !
|
|
39602
|
+
const resolvedPath = path26.resolve(gitRoot, displayPath);
|
|
39603
|
+
const rel = path26.relative(gitRoot, resolvedPath);
|
|
39604
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) return resolvedPath;
|
|
39720
39605
|
}
|
|
39721
39606
|
return resolveSafePathUnderCwd(sessionParentPath, displayPath);
|
|
39722
39607
|
}
|
|
@@ -40016,11 +39901,13 @@ var PathSnapshotTracker = class {
|
|
|
40016
39901
|
};
|
|
40017
39902
|
|
|
40018
39903
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/send-session-info-title-update.ts
|
|
39904
|
+
var PLACEHOLDER_TITLES = /* @__PURE__ */ new Set(["session", "new session", "untitled"]);
|
|
40019
39905
|
function extractSessionInfoTitle(params) {
|
|
40020
39906
|
if (!params || typeof params !== "object") return null;
|
|
40021
39907
|
const p = params;
|
|
40022
39908
|
const title = typeof p.title === "string" ? p.title.trim() : "";
|
|
40023
|
-
|
|
39909
|
+
if (!title || PLACEHOLDER_TITLES.has(title.toLowerCase())) return null;
|
|
39910
|
+
return title;
|
|
40024
39911
|
}
|
|
40025
39912
|
function sendSessionInfoTitleUpdate(params) {
|
|
40026
39913
|
const title = extractSessionInfoTitle(params.payload);
|
|
@@ -40341,74 +40228,12 @@ function resolveBridgeToolPaths(params, isToolUpdate, sessionParentPath) {
|
|
|
40341
40228
|
return isToolUpdate ? extractToolTargetDisplayPaths(params, sessionParentPath) : [];
|
|
40342
40229
|
}
|
|
40343
40230
|
|
|
40344
|
-
// ../bridge/src/agents/planning/extract-session-update-message-text.ts
|
|
40345
|
-
function extractSessionUpdateMessageText(params) {
|
|
40346
|
-
if (params == null || typeof params !== "object" || Array.isArray(params)) return null;
|
|
40347
|
-
const o = params;
|
|
40348
|
-
if (typeof o.text === "string" && o.text.length > 0) return o.text;
|
|
40349
|
-
const content = o.content;
|
|
40350
|
-
if (typeof content === "string" && content.length > 0) return content;
|
|
40351
|
-
if (content != null && typeof content === "object" && !Array.isArray(content)) {
|
|
40352
|
-
const c = content;
|
|
40353
|
-
if (typeof c.text === "string" && c.text.length > 0) return c.text;
|
|
40354
|
-
}
|
|
40355
|
-
const update = o.update;
|
|
40356
|
-
if (typeof update === "string" && update.length > 0) return update;
|
|
40357
|
-
if (update != null && typeof update === "object" && !Array.isArray(update)) {
|
|
40358
|
-
const u = update;
|
|
40359
|
-
const innerContent = u.content;
|
|
40360
|
-
if (typeof innerContent === "string" && innerContent.length > 0) return innerContent;
|
|
40361
|
-
if (innerContent != null && typeof innerContent === "object" && !Array.isArray(innerContent)) {
|
|
40362
|
-
const ic = innerContent;
|
|
40363
|
-
if (typeof ic.text === "string" && ic.text.length > 0) return ic.text;
|
|
40364
|
-
}
|
|
40365
|
-
}
|
|
40366
|
-
return null;
|
|
40367
|
-
}
|
|
40368
|
-
|
|
40369
|
-
// ../bridge/src/agents/planning/planning-session-turn-buffer.ts
|
|
40370
|
-
var MAX_PLANNING_BUFFER_CHARS = 512 * 1024;
|
|
40371
|
-
var buffersByRunId = /* @__PURE__ */ new Map();
|
|
40372
|
-
function registerPlanningSessionTurn(runId) {
|
|
40373
|
-
buffersByRunId.set(runId, { messageBuffer: "" });
|
|
40374
|
-
}
|
|
40375
|
-
function clearPlanningSessionTurn(runId) {
|
|
40376
|
-
buffersByRunId.delete(runId);
|
|
40377
|
-
}
|
|
40378
|
-
function capturePlanningSessionUpdate(params) {
|
|
40379
|
-
const state = buffersByRunId.get(params.runId);
|
|
40380
|
-
if (!state) return false;
|
|
40381
|
-
const sessionUpdate = params.payload != null && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload.sessionUpdate ?? params.payload.session_update : void 0;
|
|
40382
|
-
const bucket = resolveAgentTextStreamBucket({
|
|
40383
|
-
transcriptRowKind: params.updateKind,
|
|
40384
|
-
sessionUpdate: typeof sessionUpdate === "string" ? sessionUpdate : void 0
|
|
40385
|
-
});
|
|
40386
|
-
if (bucket !== "message") return false;
|
|
40387
|
-
const text = extractSessionUpdateMessageText(params.payload);
|
|
40388
|
-
if (text && state.messageBuffer.length < MAX_PLANNING_BUFFER_CHARS) {
|
|
40389
|
-
const room = MAX_PLANNING_BUFFER_CHARS - state.messageBuffer.length;
|
|
40390
|
-
state.messageBuffer += room >= text.length ? text : text.slice(0, room);
|
|
40391
|
-
}
|
|
40392
|
-
return true;
|
|
40393
|
-
}
|
|
40394
|
-
function getPlanningSessionTurnOutput(runId) {
|
|
40395
|
-
return buffersByRunId.get(runId)?.messageBuffer ?? "";
|
|
40396
|
-
}
|
|
40397
|
-
function consumePlanningSessionTurnOutput(runId) {
|
|
40398
|
-
const state = buffersByRunId.get(runId);
|
|
40399
|
-
buffersByRunId.delete(runId);
|
|
40400
|
-
return state?.messageBuffer ?? "";
|
|
40401
|
-
}
|
|
40402
|
-
|
|
40403
40231
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/forward-bridge-session-update.ts
|
|
40404
40232
|
function forwardBridgeSessionUpdate(params) {
|
|
40405
40233
|
const { runId, sessionId, updateKind, payload, send, nextTranscriptStreamSeq, log: log2 } = params;
|
|
40406
40234
|
if (updateKind === "permission") {
|
|
40407
40235
|
return;
|
|
40408
40236
|
}
|
|
40409
|
-
if (capturePlanningSessionUpdate({ runId, updateKind, payload })) {
|
|
40410
|
-
return;
|
|
40411
|
-
}
|
|
40412
40237
|
try {
|
|
40413
40238
|
const transcriptStreamSeq = nextTranscriptStreamSeq?.(runId);
|
|
40414
40239
|
send({
|
|
@@ -40664,7 +40489,7 @@ async function ensureAcpClient(options) {
|
|
|
40664
40489
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
40665
40490
|
await state.acpStartPromise;
|
|
40666
40491
|
}
|
|
40667
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
40492
|
+
if (state.acpHandle && state.lastAcpCwd != null && path27.resolve(state.lastAcpCwd) !== path27.resolve(targetSessionParentPath)) {
|
|
40668
40493
|
try {
|
|
40669
40494
|
state.acpHandle.disconnect();
|
|
40670
40495
|
} catch {
|
|
@@ -40696,7 +40521,7 @@ async function ensureAcpClient(options) {
|
|
|
40696
40521
|
if (!state.acpStartPromise) {
|
|
40697
40522
|
let statOk = false;
|
|
40698
40523
|
try {
|
|
40699
|
-
const st = await
|
|
40524
|
+
const st = await fs18.promises.stat(targetSessionParentPath);
|
|
40700
40525
|
statOk = st.isDirectory();
|
|
40701
40526
|
if (!statOk) {
|
|
40702
40527
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
|
|
@@ -40856,8 +40681,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
|
|
|
40856
40681
|
init_yield_to_event_loop();
|
|
40857
40682
|
|
|
40858
40683
|
// ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
|
|
40859
|
-
function normalizeGitDiffPath(
|
|
40860
|
-
return
|
|
40684
|
+
function normalizeGitDiffPath(path86) {
|
|
40685
|
+
return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
40861
40686
|
}
|
|
40862
40687
|
|
|
40863
40688
|
// ../bridge/src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -40896,7 +40721,7 @@ function parseNameStatusLines(lines) {
|
|
|
40896
40721
|
}
|
|
40897
40722
|
|
|
40898
40723
|
// ../bridge/src/git/snapshot/diff/messages.ts
|
|
40899
|
-
import * as
|
|
40724
|
+
import * as path28 from "node:path";
|
|
40900
40725
|
|
|
40901
40726
|
// ../bridge/src/git/snapshot/diff/files.ts
|
|
40902
40727
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -40927,7 +40752,7 @@ async function buildTrackedChangeMessage(options) {
|
|
|
40927
40752
|
const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
|
|
40928
40753
|
const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
|
|
40929
40754
|
if (!patchContent.trim()) return null;
|
|
40930
|
-
const workspaceFilePath =
|
|
40755
|
+
const workspaceFilePath = path28.join(repoPath, rel);
|
|
40931
40756
|
const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
|
|
40932
40757
|
const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
|
|
40933
40758
|
return {
|
|
@@ -40959,9 +40784,9 @@ function buildUntrackedChangeMessage(options) {
|
|
|
40959
40784
|
}
|
|
40960
40785
|
|
|
40961
40786
|
// ../bridge/src/git/snapshot/diff/paths.ts
|
|
40962
|
-
import * as
|
|
40787
|
+
import * as path29 from "node:path";
|
|
40963
40788
|
function repoDisplayPath(repoPath, multiRepo) {
|
|
40964
|
-
const slug =
|
|
40789
|
+
const slug = path29.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
|
|
40965
40790
|
return (rel) => multiRepo ? `${slug}/${rel}` : rel;
|
|
40966
40791
|
}
|
|
40967
40792
|
function safeRelPath(rel) {
|
|
@@ -40973,12 +40798,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
|
|
|
40973
40798
|
}
|
|
40974
40799
|
|
|
40975
40800
|
// ../bridge/src/git/snapshot/diff/move-pairs.ts
|
|
40976
|
-
import * as
|
|
40801
|
+
import * as path30 from "node:path";
|
|
40977
40802
|
async function readUntrackedTexts(repoPath, untracked) {
|
|
40978
40803
|
const out = /* @__PURE__ */ new Map();
|
|
40979
40804
|
await forEachWithGitYield(untracked, async (rel) => {
|
|
40980
40805
|
if (!safeRelPath(rel)) return;
|
|
40981
|
-
const newText = await readWorkspaceFileAsUtf8(
|
|
40806
|
+
const newText = await readWorkspaceFileAsUtf8(path30.join(repoPath, rel));
|
|
40982
40807
|
if (newText !== void 0) out.set(rel, newText);
|
|
40983
40808
|
});
|
|
40984
40809
|
return out;
|
|
@@ -41095,12 +40920,12 @@ async function collectRepoTurnChanges(options) {
|
|
|
41095
40920
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
41096
40921
|
|
|
41097
40922
|
// ../bridge/src/git/snapshot/types.ts
|
|
41098
|
-
import * as
|
|
40923
|
+
import * as path31 from "node:path";
|
|
41099
40924
|
function snapshotsDirForCwd(agentCwd) {
|
|
41100
|
-
return
|
|
40925
|
+
return path31.join(agentCwd, ".buildautomaton", "snapshots");
|
|
41101
40926
|
}
|
|
41102
40927
|
function snapshotFilePath(agentCwd, runId) {
|
|
41103
|
-
return
|
|
40928
|
+
return path31.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
41104
40929
|
}
|
|
41105
40930
|
|
|
41106
40931
|
// ../bridge/src/git/snapshot/diff/load-pre-turn-snapshot.ts
|
|
@@ -41177,22 +41002,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41177
41002
|
promptId,
|
|
41178
41003
|
agentType,
|
|
41179
41004
|
agentCwd,
|
|
41180
|
-
isPlanningSession,
|
|
41181
41005
|
followUpCatalogPromptId,
|
|
41182
|
-
plugin,
|
|
41183
41006
|
sendResult,
|
|
41184
41007
|
sendSessionUpdate,
|
|
41185
41008
|
log: log2
|
|
41186
41009
|
} = params;
|
|
41187
41010
|
notifyAgentProvidersPromptTurnFinished(sessionId);
|
|
41188
|
-
const planningTodosSubmit = isPlanningSession && plugin?.cloud?.maybeSubmitPlanningTodos ? await plugin.cloud.maybeSubmitPlanningTodos({
|
|
41189
|
-
sessionId,
|
|
41190
|
-
runId,
|
|
41191
|
-
resultSuccess: result.success === true,
|
|
41192
|
-
output: result.output,
|
|
41193
|
-
log: log2
|
|
41194
|
-
}) : { suppressOutput: false };
|
|
41195
|
-
const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
|
|
41196
41011
|
const errStr = typeof result.error === "string" ? result.error : void 0;
|
|
41197
41012
|
const resultStop = typeof result.stopReason === "string" ? result.stopReason.trim() : "";
|
|
41198
41013
|
const cancelledByAgent = resultStop.toLowerCase() === "cancelled" || errStr != null && isUserEndedSessionTurnErrorText(errStr);
|
|
@@ -41202,7 +41017,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41202
41017
|
...sessionId ? { sessionId } : {},
|
|
41203
41018
|
...runId ? { runId } : {},
|
|
41204
41019
|
...result,
|
|
41205
|
-
...planningTodosSubmit.suppressOutput ? { output: void 0 } : planningFallbackOutput.trim() !== "" ? { output: planningFallbackOutput } : {},
|
|
41206
41020
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
41207
41021
|
...augmentPromptResultAuthFields(agentType, errStr),
|
|
41208
41022
|
...!result.success && cancelledByAgent ? { stopReason: "cancelled" } : {}
|
|
@@ -41230,14 +41044,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
41230
41044
|
async function prepareAgentPromptText(params) {
|
|
41231
41045
|
const { promptText, sessionId, runId, isNewSession, plugin } = params;
|
|
41232
41046
|
if (plugin?.cloud?.prepareAgentPromptText) {
|
|
41233
|
-
|
|
41047
|
+
return plugin.cloud.prepareAgentPromptText({
|
|
41234
41048
|
promptText,
|
|
41235
41049
|
sessionId,
|
|
41236
41050
|
runId,
|
|
41237
41051
|
isNewSession
|
|
41238
41052
|
});
|
|
41239
|
-
if (prepared.isPlanningSession && runId) registerPlanningSessionTurn(runId);
|
|
41240
|
-
return prepared;
|
|
41241
41053
|
}
|
|
41242
41054
|
return { agentPromptText: promptText, isPlanningSession: false };
|
|
41243
41055
|
}
|
|
@@ -41313,7 +41125,6 @@ async function sendPromptToAgent(options) {
|
|
|
41313
41125
|
attachments,
|
|
41314
41126
|
isNewSession = false
|
|
41315
41127
|
} = options;
|
|
41316
|
-
let isPlanningSession = false;
|
|
41317
41128
|
try {
|
|
41318
41129
|
const prepared = await prepareAgentPromptText({
|
|
41319
41130
|
promptText,
|
|
@@ -41322,7 +41133,6 @@ async function sendPromptToAgent(options) {
|
|
|
41322
41133
|
isNewSession,
|
|
41323
41134
|
plugin
|
|
41324
41135
|
});
|
|
41325
|
-
isPlanningSession = prepared.isPlanningSession;
|
|
41326
41136
|
const imagesResolved = await resolveSendPromptImages({
|
|
41327
41137
|
attachments,
|
|
41328
41138
|
sessionId,
|
|
@@ -41351,7 +41161,6 @@ async function sendPromptToAgent(options) {
|
|
|
41351
41161
|
promptId,
|
|
41352
41162
|
agentType,
|
|
41353
41163
|
agentCwd,
|
|
41354
|
-
isPlanningSession,
|
|
41355
41164
|
followUpCatalogPromptId,
|
|
41356
41165
|
plugin,
|
|
41357
41166
|
sendResult,
|
|
@@ -41371,8 +41180,6 @@ async function sendPromptToAgent(options) {
|
|
|
41371
41180
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
41372
41181
|
...augmentPromptResultAuthFields(agentType, errMsg)
|
|
41373
41182
|
});
|
|
41374
|
-
} finally {
|
|
41375
|
-
if (runId && isPlanningSession) clearPlanningSessionTurn(runId);
|
|
41376
41183
|
}
|
|
41377
41184
|
}
|
|
41378
41185
|
|
|
@@ -41547,6 +41354,7 @@ async function createAcpManager(options) {
|
|
|
41547
41354
|
logPromptReceivedFromBridge: (opts) => logPromptReceivedFromBridge(ctx, opts),
|
|
41548
41355
|
handlePrompt: (opts) => handlePrompt(ctx, opts),
|
|
41549
41356
|
cancelRun: (runId) => cancelRun(ctx, runId),
|
|
41357
|
+
isRegisteredRun: (runId) => ctx.promptRouting.isRegisteredRun(runId),
|
|
41550
41358
|
resolveRequest(requestId, result) {
|
|
41551
41359
|
for (const state of ctx.acpAgents.values()) {
|
|
41552
41360
|
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
@@ -41822,8 +41630,8 @@ function decryptCliE2eeMessageField(payload, field, e2ee) {
|
|
|
41822
41630
|
}
|
|
41823
41631
|
|
|
41824
41632
|
// ../bridge/src/e2ee/certificates.ts
|
|
41825
|
-
import * as
|
|
41826
|
-
import * as
|
|
41633
|
+
import * as fs19 from "node:fs/promises";
|
|
41634
|
+
import * as path32 from "node:path";
|
|
41827
41635
|
var E2E_CERTIFICATE_ALGORITHM = "A1";
|
|
41828
41636
|
var CERTIFICATE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".pem", ".key", ".crt"]);
|
|
41829
41637
|
function certificateFromKey({
|
|
@@ -41844,12 +41652,12 @@ function certificateFromKey({
|
|
|
41844
41652
|
}
|
|
41845
41653
|
}
|
|
41846
41654
|
function baseNameForCertificate(fileName) {
|
|
41847
|
-
return
|
|
41655
|
+
return path32.basename(fileName, path32.extname(fileName)) || "BuildAutomaton E2EE certificate";
|
|
41848
41656
|
}
|
|
41849
41657
|
async function readCertificateFiles(directory) {
|
|
41850
41658
|
let entries;
|
|
41851
41659
|
try {
|
|
41852
|
-
entries = await
|
|
41660
|
+
entries = await fs19.readdir(directory, { withFileTypes: true });
|
|
41853
41661
|
} catch (err) {
|
|
41854
41662
|
const nodeErr = err;
|
|
41855
41663
|
if (nodeErr.code === "ENOENT") return [];
|
|
@@ -41857,11 +41665,11 @@ async function readCertificateFiles(directory) {
|
|
|
41857
41665
|
}
|
|
41858
41666
|
const certificates = [];
|
|
41859
41667
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
41860
|
-
if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(
|
|
41861
|
-
const filePath =
|
|
41862
|
-
const raw = await
|
|
41668
|
+
if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(path32.extname(entry.name).toLowerCase())) continue;
|
|
41669
|
+
const filePath = path32.join(directory, entry.name);
|
|
41670
|
+
const raw = await fs19.readFile(filePath, "utf8").catch(() => void 0);
|
|
41863
41671
|
if (!raw) continue;
|
|
41864
|
-
const stat3 = await
|
|
41672
|
+
const stat3 = await fs19.stat(filePath).catch(() => void 0);
|
|
41865
41673
|
const certificate = certificateFromKey({
|
|
41866
41674
|
raw,
|
|
41867
41675
|
name: baseNameForCertificate(entry.name),
|
|
@@ -41874,7 +41682,7 @@ async function readCertificateFiles(directory) {
|
|
|
41874
41682
|
return certificates;
|
|
41875
41683
|
}
|
|
41876
41684
|
function createCertificate(directory) {
|
|
41877
|
-
const baseName =
|
|
41685
|
+
const baseName = path32.basename(directory) || "BuildAutomaton E2EE certificate";
|
|
41878
41686
|
const key = createE2eeKeyRecord(baseName);
|
|
41879
41687
|
return {
|
|
41880
41688
|
...key,
|
|
@@ -41883,8 +41691,8 @@ function createCertificate(directory) {
|
|
|
41883
41691
|
};
|
|
41884
41692
|
}
|
|
41885
41693
|
async function loadOrCreateE2eCertificates(directory) {
|
|
41886
|
-
const resolved =
|
|
41887
|
-
await
|
|
41694
|
+
const resolved = path32.resolve(directory);
|
|
41695
|
+
await fs19.mkdir(resolved, { recursive: true, mode: 448 });
|
|
41888
41696
|
const existing = await readCertificateFiles(resolved);
|
|
41889
41697
|
if (existing.length > 0) {
|
|
41890
41698
|
return {
|
|
@@ -41896,7 +41704,7 @@ async function loadOrCreateE2eCertificates(directory) {
|
|
|
41896
41704
|
}
|
|
41897
41705
|
const certificate = createCertificate(resolved);
|
|
41898
41706
|
const fileName = `buildautomaton-e2ee-key-${certificate.id.slice(0, 12)}.pem`;
|
|
41899
|
-
await
|
|
41707
|
+
await fs19.writeFile(path32.join(resolved, fileName), certificate.pemBundle, {
|
|
41900
41708
|
mode: 384
|
|
41901
41709
|
});
|
|
41902
41710
|
return {
|
|
@@ -42089,7 +41897,7 @@ async function createBridgeAccessState(options) {
|
|
|
42089
41897
|
}
|
|
42090
41898
|
|
|
42091
41899
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
42092
|
-
import * as
|
|
41900
|
+
import * as path34 from "node:path";
|
|
42093
41901
|
|
|
42094
41902
|
// ../bridge/src/agents/detect-local-agent-types.ts
|
|
42095
41903
|
init_yield_to_event_loop();
|
|
@@ -42188,58 +41996,67 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
|
|
|
42188
41996
|
// ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
|
|
42189
41997
|
init_cli_database();
|
|
42190
41998
|
|
|
41999
|
+
// ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
|
|
42000
|
+
init_cli_process_interrupt();
|
|
42001
|
+
var warmupEpoch = 0;
|
|
42002
|
+
var probedTypesThisProcess = /* @__PURE__ */ new Set();
|
|
42003
|
+
function cancelInFlightAgentCapabilityWarmup() {
|
|
42004
|
+
warmupEpoch += 1;
|
|
42005
|
+
}
|
|
42006
|
+
function beginAgentCapabilityWarmupRun() {
|
|
42007
|
+
const epoch = warmupEpoch += 1;
|
|
42008
|
+
return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
|
|
42009
|
+
}
|
|
42010
|
+
function wasAgentCapabilityTypeProbedThisProcess(agentType) {
|
|
42011
|
+
return probedTypesThisProcess.has(agentType);
|
|
42012
|
+
}
|
|
42013
|
+
function markAgentCapabilityTypeProbedThisProcess(agentType) {
|
|
42014
|
+
probedTypesThisProcess.add(agentType);
|
|
42015
|
+
}
|
|
42016
|
+
function shouldSkipCapabilityProbeThisProcess(agentType) {
|
|
42017
|
+
if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES === "1") return false;
|
|
42018
|
+
return wasAgentCapabilityTypeProbedThisProcess(agentType);
|
|
42019
|
+
}
|
|
42020
|
+
|
|
42191
42021
|
// ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
42192
|
-
import * as
|
|
42022
|
+
import * as path33 from "node:path";
|
|
42193
42023
|
init_cli_database();
|
|
42024
|
+
init_yield_to_event_loop();
|
|
42194
42025
|
init_cli_process_interrupt();
|
|
42026
|
+
var ACP_CAPABILITY_PROBE_TIMEOUT_MS = 12e3;
|
|
42195
42027
|
async function probeOneAgentTypeForCapabilities(params) {
|
|
42196
42028
|
const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
|
|
42197
|
-
const canContinue = () => shouldContinue?.() !== false;
|
|
42029
|
+
const canContinue = () => shouldContinue?.() !== false && !isCliImmediateShutdownRequested();
|
|
42198
42030
|
if (!canContinue()) return false;
|
|
42199
42031
|
const resolved = resolveAgentCommand(agentType);
|
|
42200
42032
|
if (!resolved) return false;
|
|
42201
|
-
|
|
42202
|
-
|
|
42203
|
-
|
|
42204
|
-
|
|
42205
|
-
|
|
42206
|
-
|
|
42207
|
-
|
|
42208
|
-
|
|
42209
|
-
|
|
42210
|
-
|
|
42211
|
-
|
|
42212
|
-
agentType,
|
|
42213
|
-
configOptions: co
|
|
42214
|
-
})
|
|
42215
|
-
);
|
|
42216
|
-
} catch {
|
|
42217
|
-
}
|
|
42218
|
-
sqliteChanged ||= changed;
|
|
42219
|
-
if (bridgeReport && changed) {
|
|
42220
|
-
reportAgentCapabilities?.({ agentType, configOptions: co });
|
|
42221
|
-
}
|
|
42222
|
-
};
|
|
42033
|
+
await yieldToEventLoop();
|
|
42034
|
+
if (!canContinue()) return false;
|
|
42035
|
+
markAgentCapabilityTypeProbedThisProcess(agentType);
|
|
42036
|
+
let pendingCo = null;
|
|
42037
|
+
const ac = new AbortController();
|
|
42038
|
+
const abortTimer = setTimeout(() => ac.abort(), ACP_CAPABILITY_PROBE_TIMEOUT_MS);
|
|
42039
|
+
abortTimer.unref?.();
|
|
42040
|
+
const abortIfStale = setInterval(() => {
|
|
42041
|
+
if (!canContinue()) ac.abort();
|
|
42042
|
+
}, 50);
|
|
42043
|
+
abortIfStale.unref?.();
|
|
42223
42044
|
let handle = null;
|
|
42224
|
-
const killTimer = setTimeout(() => {
|
|
42225
|
-
void handle?.disconnectGracefully();
|
|
42226
|
-
}, 28e3);
|
|
42227
|
-
killTimer.unref?.();
|
|
42228
42045
|
try {
|
|
42229
|
-
if (!canContinue()) return false;
|
|
42230
42046
|
handle = await resolved.createClient({
|
|
42231
42047
|
command: resolved.command,
|
|
42232
|
-
cwd:
|
|
42048
|
+
cwd: path33.resolve(cwd),
|
|
42233
42049
|
backendAgentType: agentType,
|
|
42234
42050
|
sessionMode: "agent",
|
|
42235
42051
|
persistedAcpSessionId: null,
|
|
42236
42052
|
agentConfig: null,
|
|
42053
|
+
signal: ac.signal,
|
|
42237
42054
|
getActiveConfigOptions: () => null,
|
|
42238
42055
|
onAcpSessionEstablished: (info) => {
|
|
42239
|
-
|
|
42056
|
+
if (Array.isArray(info.configOptions) && info.configOptions.length > 0) pendingCo = info.configOptions;
|
|
42240
42057
|
},
|
|
42241
42058
|
onAcpConfigOptionsUpdated: (co) => {
|
|
42242
|
-
|
|
42059
|
+
if (Array.isArray(co) && co.length > 0) pendingCo = co;
|
|
42243
42060
|
},
|
|
42244
42061
|
onAgentSubprocessExit: () => {
|
|
42245
42062
|
},
|
|
@@ -42252,13 +42069,21 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
42252
42069
|
`[Bridge service] Agent capability probe (${agentType}): ${e instanceof Error ? e.message : String(e)}`
|
|
42253
42070
|
);
|
|
42254
42071
|
} finally {
|
|
42255
|
-
clearTimeout(
|
|
42072
|
+
clearTimeout(abortTimer);
|
|
42073
|
+
clearInterval(abortIfStale);
|
|
42256
42074
|
try {
|
|
42257
42075
|
await handle?.disconnectGracefully();
|
|
42258
42076
|
} catch {
|
|
42259
42077
|
}
|
|
42260
42078
|
}
|
|
42261
|
-
return
|
|
42079
|
+
if (!pendingCo || !canContinue()) return false;
|
|
42080
|
+
const configOptions = pendingCo;
|
|
42081
|
+
await yieldToEventLoop();
|
|
42082
|
+
const changed = await withCliSqlite(
|
|
42083
|
+
(db) => upsertCliAgentCapabilityCache(db, { workspaceId, agentType, configOptions })
|
|
42084
|
+
);
|
|
42085
|
+
if (bridgeReport && changed) reportAgentCapabilities?.({ agentType, configOptions });
|
|
42086
|
+
return changed;
|
|
42262
42087
|
}
|
|
42263
42088
|
|
|
42264
42089
|
// ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
|
|
@@ -42277,9 +42102,10 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
|
|
|
42277
42102
|
let changedCount = 0;
|
|
42278
42103
|
for (let i = 0; i < agentTypes.length; i++) {
|
|
42279
42104
|
if (!canContinue()) return changedCount;
|
|
42280
|
-
|
|
42105
|
+
await yieldToEventLoop();
|
|
42281
42106
|
const agentType = agentTypes[i];
|
|
42282
42107
|
if (!agentType.trim()) continue;
|
|
42108
|
+
if (shouldSkipCapabilityProbeThisProcess(agentType)) continue;
|
|
42283
42109
|
if (!forceAllTypes) {
|
|
42284
42110
|
try {
|
|
42285
42111
|
if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES !== "1" && await withCliSqlite((db) => hasNonEmptyAgentCapabilityCache(db, workspaceId, agentType))) {
|
|
@@ -42305,32 +42131,18 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
|
|
|
42305
42131
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
42306
42132
|
init_yield_to_event_loop();
|
|
42307
42133
|
init_cli_database();
|
|
42308
|
-
|
|
42309
|
-
// ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
|
|
42310
|
-
init_cli_process_interrupt();
|
|
42311
|
-
var warmupEpoch = 0;
|
|
42312
|
-
function cancelInFlightAgentCapabilityWarmup() {
|
|
42313
|
-
warmupEpoch += 1;
|
|
42314
|
-
}
|
|
42315
|
-
function beginAgentCapabilityWarmupRun() {
|
|
42316
|
-
const epoch = warmupEpoch += 1;
|
|
42317
|
-
return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
|
|
42318
|
-
}
|
|
42319
|
-
|
|
42320
|
-
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
42321
42134
|
async function warmupAgentCapabilitiesOnConnect(params) {
|
|
42322
42135
|
const { workspaceId, log: log2, getWs } = params;
|
|
42323
42136
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
42324
42137
|
if (!isCurrent()) return;
|
|
42325
|
-
const cwd =
|
|
42138
|
+
const cwd = path34.resolve(getBridgeRoot());
|
|
42326
42139
|
async function sendBatchFromCache() {
|
|
42327
42140
|
if (!isCurrent()) return;
|
|
42328
42141
|
const socket = getWs();
|
|
42329
42142
|
if (!socket || socket.readyState !== wrapper_default.OPEN) return;
|
|
42330
42143
|
try {
|
|
42331
42144
|
const rows = await withCliSqlite((db) => listCliAgentCapabilityCacheForWorkspace(db, workspaceId));
|
|
42332
|
-
if (!isCurrent()) return;
|
|
42333
|
-
if (rows.length === 0) return;
|
|
42145
|
+
if (!isCurrent() || rows.length === 0) return;
|
|
42334
42146
|
sendWsMessage(socket, {
|
|
42335
42147
|
type: "agent_capabilities_batch",
|
|
42336
42148
|
items: rows.map((r) => ({ agentType: r.agentType, configOptions: r.configOptions }))
|
|
@@ -42344,46 +42156,30 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
42344
42156
|
}
|
|
42345
42157
|
await sendBatchFromCache();
|
|
42346
42158
|
if (!isCurrent()) return;
|
|
42347
|
-
let types = [];
|
|
42348
|
-
try {
|
|
42349
|
-
types = [...await detectLocalAgentTypes()];
|
|
42350
|
-
} catch (e) {
|
|
42351
|
-
log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
42352
|
-
}
|
|
42353
|
-
if (!isCurrent()) return;
|
|
42354
|
-
try {
|
|
42355
|
-
const n = await probeAgentCapabilitiesForDetectedTypes({
|
|
42356
|
-
agentTypes: types,
|
|
42357
|
-
cwd,
|
|
42358
|
-
workspaceId,
|
|
42359
|
-
log: log2,
|
|
42360
|
-
bridgeReport: false,
|
|
42361
|
-
forceAllTypes: false,
|
|
42362
|
-
shouldContinue: isCurrent
|
|
42363
|
-
});
|
|
42364
|
-
if (n > 0) await sendBatchFromCache();
|
|
42365
|
-
} catch (e) {
|
|
42366
|
-
if (e instanceof CliSqliteInterrupted) return;
|
|
42367
|
-
log2(`[Bridge service] Agent capability probe (missing cache) failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
42368
|
-
}
|
|
42369
|
-
if (!isCurrent()) return;
|
|
42370
42159
|
void (async () => {
|
|
42371
42160
|
try {
|
|
42372
42161
|
await yieldToEventLoop();
|
|
42373
42162
|
if (!isCurrent()) return;
|
|
42163
|
+
let types = [];
|
|
42164
|
+
try {
|
|
42165
|
+
types = [...await detectLocalAgentTypes()];
|
|
42166
|
+
} catch (e) {
|
|
42167
|
+
log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
42168
|
+
}
|
|
42169
|
+
if (!isCurrent()) return;
|
|
42374
42170
|
const n = await probeAgentCapabilitiesForDetectedTypes({
|
|
42375
42171
|
agentTypes: types,
|
|
42376
42172
|
cwd,
|
|
42377
42173
|
workspaceId,
|
|
42378
42174
|
log: log2,
|
|
42379
42175
|
bridgeReport: false,
|
|
42380
|
-
forceAllTypes:
|
|
42176
|
+
forceAllTypes: false,
|
|
42381
42177
|
shouldContinue: isCurrent
|
|
42382
42178
|
});
|
|
42383
42179
|
if (n > 0) await sendBatchFromCache();
|
|
42384
42180
|
} catch (e) {
|
|
42385
42181
|
if (e instanceof CliSqliteInterrupted) return;
|
|
42386
|
-
log2(`[Bridge service] Agent capability
|
|
42182
|
+
log2(`[Bridge service] Agent capability probe failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
42387
42183
|
}
|
|
42388
42184
|
})();
|
|
42389
42185
|
}
|
|
@@ -42448,7 +42244,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
42448
42244
|
}
|
|
42449
42245
|
|
|
42450
42246
|
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
42451
|
-
import * as
|
|
42247
|
+
import * as path37 from "node:path";
|
|
42452
42248
|
|
|
42453
42249
|
// ../bridge/src/preview-environments/manager/firehose-messages.ts
|
|
42454
42250
|
function buildFirehoseSnapshotMessage(params) {
|
|
@@ -42766,7 +42562,7 @@ function attachChildErrorHandler(d) {
|
|
|
42766
42562
|
}
|
|
42767
42563
|
|
|
42768
42564
|
// ../bridge/src/preview-environments/process/wire/handle-exit.ts
|
|
42769
|
-
import
|
|
42565
|
+
import fs20 from "node:fs";
|
|
42770
42566
|
function logStopLine(d, code, signal) {
|
|
42771
42567
|
const { title } = d;
|
|
42772
42568
|
if (signal) {
|
|
@@ -42805,7 +42601,7 @@ function attachChildExitHandler(d) {
|
|
|
42805
42601
|
const cleanupDir = d.mergedCleanupDir;
|
|
42806
42602
|
const mergedPath = d.mergedLogPath;
|
|
42807
42603
|
if (mergedPath && !stale) {
|
|
42808
|
-
|
|
42604
|
+
fs20.readFile(mergedPath, (err, buf) => {
|
|
42809
42605
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
42810
42606
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
42811
42607
|
if (chunk.length > 0) {
|
|
@@ -42851,7 +42647,7 @@ function wireChildOutputPipes(d) {
|
|
|
42851
42647
|
}
|
|
42852
42648
|
|
|
42853
42649
|
// ../bridge/src/preview-environments/process/wire/poll-merged-log.ts
|
|
42854
|
-
import
|
|
42650
|
+
import fs21 from "node:fs";
|
|
42855
42651
|
function startMergedLogPoll(d) {
|
|
42856
42652
|
if (!d.mergedLogPath || !d.mergedCleanupDir) return;
|
|
42857
42653
|
const { environmentId } = d;
|
|
@@ -42861,7 +42657,7 @@ function startMergedLogPoll(d) {
|
|
|
42861
42657
|
d.setPollInterval(void 0);
|
|
42862
42658
|
return;
|
|
42863
42659
|
}
|
|
42864
|
-
|
|
42660
|
+
fs21.readFile(d.mergedLogPath, (err, buf) => {
|
|
42865
42661
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
42866
42662
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
42867
42663
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -43076,7 +42872,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
|
|
|
43076
42872
|
}
|
|
43077
42873
|
|
|
43078
42874
|
// ../bridge/src/preview-environments/manager/shell-spawn/utils.ts
|
|
43079
|
-
import
|
|
42875
|
+
import fs22 from "node:fs";
|
|
43080
42876
|
function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
|
|
43081
42877
|
return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
|
|
43082
42878
|
}
|
|
@@ -43085,7 +42881,7 @@ function isSpawnEbadf(e) {
|
|
|
43085
42881
|
}
|
|
43086
42882
|
function rmDirQuiet(dir) {
|
|
43087
42883
|
try {
|
|
43088
|
-
|
|
42884
|
+
fs22.rmSync(dir, { recursive: true, force: true });
|
|
43089
42885
|
} catch {
|
|
43090
42886
|
}
|
|
43091
42887
|
}
|
|
@@ -43093,7 +42889,7 @@ var cachedDevNullReadFd;
|
|
|
43093
42889
|
function devNullReadFd() {
|
|
43094
42890
|
if (cachedDevNullReadFd === void 0) {
|
|
43095
42891
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
43096
|
-
cachedDevNullReadFd =
|
|
42892
|
+
cachedDevNullReadFd = fs22.openSync(devPath, "r");
|
|
43097
42893
|
}
|
|
43098
42894
|
return cachedDevNullReadFd;
|
|
43099
42895
|
}
|
|
@@ -43173,15 +42969,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
43173
42969
|
|
|
43174
42970
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
43175
42971
|
import { spawn as spawn7 } from "node:child_process";
|
|
43176
|
-
import
|
|
42972
|
+
import fs23 from "node:fs";
|
|
43177
42973
|
import { tmpdir } from "node:os";
|
|
43178
|
-
import
|
|
42974
|
+
import path35 from "node:path";
|
|
43179
42975
|
function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
43180
|
-
const tmpRoot =
|
|
43181
|
-
const logPath =
|
|
42976
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir(), "ba-devsrv-log-"));
|
|
42977
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
43182
42978
|
let logFd;
|
|
43183
42979
|
try {
|
|
43184
|
-
logFd =
|
|
42980
|
+
logFd = fs23.openSync(logPath, "a");
|
|
43185
42981
|
} catch {
|
|
43186
42982
|
rmDirQuiet(tmpRoot);
|
|
43187
42983
|
return null;
|
|
@@ -43205,7 +43001,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43205
43001
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
43206
43002
|
);
|
|
43207
43003
|
}
|
|
43208
|
-
|
|
43004
|
+
fs23.closeSync(logFd);
|
|
43209
43005
|
return {
|
|
43210
43006
|
proc,
|
|
43211
43007
|
pipedStdoutStderr: true,
|
|
@@ -43214,7 +43010,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43214
43010
|
};
|
|
43215
43011
|
} catch (e) {
|
|
43216
43012
|
try {
|
|
43217
|
-
|
|
43013
|
+
fs23.closeSync(logFd);
|
|
43218
43014
|
} catch {
|
|
43219
43015
|
}
|
|
43220
43016
|
rmDirQuiet(tmpRoot);
|
|
@@ -43225,22 +43021,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
43225
43021
|
|
|
43226
43022
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
43227
43023
|
import { spawn as spawn8 } from "node:child_process";
|
|
43228
|
-
import
|
|
43024
|
+
import fs24 from "node:fs";
|
|
43229
43025
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
43230
|
-
import
|
|
43026
|
+
import path36 from "node:path";
|
|
43231
43027
|
function shSingleQuote(s) {
|
|
43232
43028
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
43233
43029
|
}
|
|
43234
43030
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
|
|
43235
|
-
const tmpRoot =
|
|
43236
|
-
const logPath =
|
|
43237
|
-
const innerPath =
|
|
43238
|
-
const runnerPath =
|
|
43031
|
+
const tmpRoot = fs24.mkdtempSync(path36.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
43032
|
+
const logPath = path36.join(tmpRoot, "combined.log");
|
|
43033
|
+
const innerPath = path36.join(tmpRoot, "_cmd.sh");
|
|
43034
|
+
const runnerPath = path36.join(tmpRoot, "_run.sh");
|
|
43239
43035
|
try {
|
|
43240
|
-
|
|
43036
|
+
fs24.writeFileSync(innerPath, `#!/bin/sh
|
|
43241
43037
|
${command}
|
|
43242
43038
|
`);
|
|
43243
|
-
|
|
43039
|
+
fs24.writeFileSync(
|
|
43244
43040
|
runnerPath,
|
|
43245
43041
|
`#!/bin/sh
|
|
43246
43042
|
cd ${shSingleQuote(cwd)}
|
|
@@ -43268,13 +43064,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
43268
43064
|
}
|
|
43269
43065
|
}
|
|
43270
43066
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
|
|
43271
|
-
const tmpRoot =
|
|
43272
|
-
const logPath =
|
|
43273
|
-
const runnerPath =
|
|
43067
|
+
const tmpRoot = fs24.mkdtempSync(path36.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
43068
|
+
const logPath = path36.join(tmpRoot, "combined.log");
|
|
43069
|
+
const runnerPath = path36.join(tmpRoot, "_run.bat");
|
|
43274
43070
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
43275
43071
|
const com = process.env.ComSpec || "cmd.exe";
|
|
43276
43072
|
try {
|
|
43277
|
-
|
|
43073
|
+
fs24.writeFileSync(
|
|
43278
43074
|
runnerPath,
|
|
43279
43075
|
`@ECHO OFF\r
|
|
43280
43076
|
CD /D ${q(cwd)}\r
|
|
@@ -43592,8 +43388,8 @@ function createBridgePreviewStack(options) {
|
|
|
43592
43388
|
scheduleInitialIndexBuilds(getBridgeRoot());
|
|
43593
43389
|
};
|
|
43594
43390
|
const identifyReportedPaths = {
|
|
43595
|
-
bridgeRootPath:
|
|
43596
|
-
worktreesRootPath:
|
|
43391
|
+
bridgeRootPath: path37.resolve(getBridgeRoot()),
|
|
43392
|
+
worktreesRootPath: path37.resolve(options.worktreesRootPath),
|
|
43597
43393
|
localShortcutPort: 0,
|
|
43598
43394
|
localShortcutToken: ""
|
|
43599
43395
|
};
|
|
@@ -43795,7 +43591,7 @@ function createBridgeHeartbeatController(params) {
|
|
|
43795
43591
|
}
|
|
43796
43592
|
|
|
43797
43593
|
// ../bridge/src/cli/cli-version.ts
|
|
43798
|
-
var CLI_VERSION2 = "0.1.
|
|
43594
|
+
var CLI_VERSION2 = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
43799
43595
|
|
|
43800
43596
|
// ../bridge/src/connection/identify/send-bridge-identify.ts
|
|
43801
43597
|
function sendBridgeIdentify(ws, params) {
|
|
@@ -43966,12 +43762,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
43966
43762
|
}
|
|
43967
43763
|
|
|
43968
43764
|
// ../bridge/src/worktrees/worktree-layout-file.ts
|
|
43969
|
-
import * as
|
|
43970
|
-
import * as
|
|
43971
|
-
import
|
|
43765
|
+
import * as fs25 from "node:fs";
|
|
43766
|
+
import * as path38 from "node:path";
|
|
43767
|
+
import os6 from "node:os";
|
|
43972
43768
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
43973
43769
|
function defaultWorktreeLayoutPath() {
|
|
43974
|
-
return
|
|
43770
|
+
return path38.join(os6.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
43975
43771
|
}
|
|
43976
43772
|
function normalizeLoadedLayout(raw) {
|
|
43977
43773
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -43983,8 +43779,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
43983
43779
|
function loadWorktreeLayout() {
|
|
43984
43780
|
try {
|
|
43985
43781
|
const p = defaultWorktreeLayoutPath();
|
|
43986
|
-
if (!
|
|
43987
|
-
const raw = JSON.parse(
|
|
43782
|
+
if (!fs25.existsSync(p)) return { launcherCwds: [] };
|
|
43783
|
+
const raw = JSON.parse(fs25.readFileSync(p, "utf8"));
|
|
43988
43784
|
return normalizeLoadedLayout(raw);
|
|
43989
43785
|
} catch {
|
|
43990
43786
|
return { launcherCwds: [] };
|
|
@@ -43992,24 +43788,24 @@ function loadWorktreeLayout() {
|
|
|
43992
43788
|
}
|
|
43993
43789
|
function saveWorktreeLayout(layout) {
|
|
43994
43790
|
try {
|
|
43995
|
-
const dir =
|
|
43996
|
-
|
|
43997
|
-
|
|
43791
|
+
const dir = path38.dirname(defaultWorktreeLayoutPath());
|
|
43792
|
+
fs25.mkdirSync(dir, { recursive: true });
|
|
43793
|
+
fs25.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
43998
43794
|
} catch {
|
|
43999
43795
|
}
|
|
44000
43796
|
}
|
|
44001
43797
|
function baseNameSafe(pathString) {
|
|
44002
|
-
return
|
|
43798
|
+
return path38.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
44003
43799
|
}
|
|
44004
43800
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
44005
|
-
const norm =
|
|
44006
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
43801
|
+
const norm = path38.resolve(bridgeRootPath2);
|
|
43802
|
+
const existing = layout.launcherCwds.find((e) => path38.resolve(e.absolutePath) === norm);
|
|
44007
43803
|
return existing?.dirName;
|
|
44008
43804
|
}
|
|
44009
43805
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
44010
43806
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
44011
43807
|
if (existing) return existing;
|
|
44012
|
-
const norm =
|
|
43808
|
+
const norm = path38.resolve(bridgeRootPath2);
|
|
44013
43809
|
const base = baseNameSafe(norm);
|
|
44014
43810
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
44015
43811
|
let name = base;
|
|
@@ -44102,8 +43898,8 @@ function pathspec(...paths) {
|
|
|
44102
43898
|
cache.set(key, paths);
|
|
44103
43899
|
return key;
|
|
44104
43900
|
}
|
|
44105
|
-
function isPathSpec(
|
|
44106
|
-
return
|
|
43901
|
+
function isPathSpec(path86) {
|
|
43902
|
+
return path86 instanceof String && cache.has(path86);
|
|
44107
43903
|
}
|
|
44108
43904
|
function toPaths(pathSpec) {
|
|
44109
43905
|
return cache.get(pathSpec) || [];
|
|
@@ -44192,8 +43988,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
44192
43988
|
function forEachLineWithContent(input, callback) {
|
|
44193
43989
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
44194
43990
|
}
|
|
44195
|
-
function folderExists(
|
|
44196
|
-
return (0, import_file_exists.exists)(
|
|
43991
|
+
function folderExists(path86) {
|
|
43992
|
+
return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
|
|
44197
43993
|
}
|
|
44198
43994
|
function append(target, item) {
|
|
44199
43995
|
if (Array.isArray(target)) {
|
|
@@ -44597,8 +44393,8 @@ function checkIsRepoRootTask() {
|
|
|
44597
44393
|
commands,
|
|
44598
44394
|
format: "utf-8",
|
|
44599
44395
|
onError,
|
|
44600
|
-
parser(
|
|
44601
|
-
return /^\.(git)?$/.test(
|
|
44396
|
+
parser(path86) {
|
|
44397
|
+
return /^\.(git)?$/.test(path86.trim());
|
|
44602
44398
|
}
|
|
44603
44399
|
};
|
|
44604
44400
|
}
|
|
@@ -45032,11 +44828,11 @@ function parseGrep(grep) {
|
|
|
45032
44828
|
const paths = /* @__PURE__ */ new Set();
|
|
45033
44829
|
const results = {};
|
|
45034
44830
|
forEachLineWithContent(grep, (input) => {
|
|
45035
|
-
const [
|
|
45036
|
-
paths.add(
|
|
45037
|
-
(results[
|
|
44831
|
+
const [path86, line, preview] = input.split(NULL);
|
|
44832
|
+
paths.add(path86);
|
|
44833
|
+
(results[path86] = results[path86] || []).push({
|
|
45038
44834
|
line: asNumber(line),
|
|
45039
|
-
path:
|
|
44835
|
+
path: path86,
|
|
45040
44836
|
preview
|
|
45041
44837
|
});
|
|
45042
44838
|
});
|
|
@@ -45801,14 +45597,14 @@ var init_hash_object = __esm2({
|
|
|
45801
45597
|
init_task();
|
|
45802
45598
|
}
|
|
45803
45599
|
});
|
|
45804
|
-
function parseInit(bare,
|
|
45600
|
+
function parseInit(bare, path86, text) {
|
|
45805
45601
|
const response = String(text).trim();
|
|
45806
45602
|
let result;
|
|
45807
45603
|
if (result = initResponseRegex.exec(response)) {
|
|
45808
|
-
return new InitSummary(bare,
|
|
45604
|
+
return new InitSummary(bare, path86, false, result[1]);
|
|
45809
45605
|
}
|
|
45810
45606
|
if (result = reInitResponseRegex.exec(response)) {
|
|
45811
|
-
return new InitSummary(bare,
|
|
45607
|
+
return new InitSummary(bare, path86, true, result[1]);
|
|
45812
45608
|
}
|
|
45813
45609
|
let gitDir = "";
|
|
45814
45610
|
const tokens = response.split(" ");
|
|
@@ -45819,7 +45615,7 @@ function parseInit(bare, path88, text) {
|
|
|
45819
45615
|
break;
|
|
45820
45616
|
}
|
|
45821
45617
|
}
|
|
45822
|
-
return new InitSummary(bare,
|
|
45618
|
+
return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
|
|
45823
45619
|
}
|
|
45824
45620
|
var InitSummary;
|
|
45825
45621
|
var initResponseRegex;
|
|
@@ -45828,9 +45624,9 @@ var init_InitSummary = __esm2({
|
|
|
45828
45624
|
"src/lib/responses/InitSummary.ts"() {
|
|
45829
45625
|
"use strict";
|
|
45830
45626
|
InitSummary = class {
|
|
45831
|
-
constructor(bare,
|
|
45627
|
+
constructor(bare, path86, existing, gitDir) {
|
|
45832
45628
|
this.bare = bare;
|
|
45833
|
-
this.path =
|
|
45629
|
+
this.path = path86;
|
|
45834
45630
|
this.existing = existing;
|
|
45835
45631
|
this.gitDir = gitDir;
|
|
45836
45632
|
}
|
|
@@ -45842,7 +45638,7 @@ var init_InitSummary = __esm2({
|
|
|
45842
45638
|
function hasBareCommand(command) {
|
|
45843
45639
|
return command.includes(bareCommand);
|
|
45844
45640
|
}
|
|
45845
|
-
function initTask(bare = false,
|
|
45641
|
+
function initTask(bare = false, path86, customArgs) {
|
|
45846
45642
|
const commands = ["init", ...customArgs];
|
|
45847
45643
|
if (bare && !hasBareCommand(commands)) {
|
|
45848
45644
|
commands.splice(1, 0, bareCommand);
|
|
@@ -45851,7 +45647,7 @@ function initTask(bare = false, path88, customArgs) {
|
|
|
45851
45647
|
commands,
|
|
45852
45648
|
format: "utf-8",
|
|
45853
45649
|
parser(text) {
|
|
45854
|
-
return parseInit(commands.includes("--bare"),
|
|
45650
|
+
return parseInit(commands.includes("--bare"), path86, text);
|
|
45855
45651
|
}
|
|
45856
45652
|
};
|
|
45857
45653
|
}
|
|
@@ -46667,12 +46463,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
46667
46463
|
"use strict";
|
|
46668
46464
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
46669
46465
|
FileStatusSummary = class {
|
|
46670
|
-
constructor(
|
|
46671
|
-
this.path =
|
|
46466
|
+
constructor(path86, index, working_dir) {
|
|
46467
|
+
this.path = path86;
|
|
46672
46468
|
this.index = index;
|
|
46673
46469
|
this.working_dir = working_dir;
|
|
46674
46470
|
if (index === "R" || working_dir === "R") {
|
|
46675
|
-
const detail = fromPathRegex.exec(
|
|
46471
|
+
const detail = fromPathRegex.exec(path86) || [null, path86, path86];
|
|
46676
46472
|
this.from = detail[2] || "";
|
|
46677
46473
|
this.path = detail[1] || "";
|
|
46678
46474
|
}
|
|
@@ -46703,14 +46499,14 @@ function splitLine(result, lineStr) {
|
|
|
46703
46499
|
default:
|
|
46704
46500
|
return;
|
|
46705
46501
|
}
|
|
46706
|
-
function data(index, workingDir,
|
|
46502
|
+
function data(index, workingDir, path86) {
|
|
46707
46503
|
const raw = `${index}${workingDir}`;
|
|
46708
46504
|
const handler = parsers6.get(raw);
|
|
46709
46505
|
if (handler) {
|
|
46710
|
-
handler(result,
|
|
46506
|
+
handler(result, path86);
|
|
46711
46507
|
}
|
|
46712
46508
|
if (raw !== "##" && raw !== "!!") {
|
|
46713
|
-
result.files.push(new FileStatusSummary(
|
|
46509
|
+
result.files.push(new FileStatusSummary(path86, index, workingDir));
|
|
46714
46510
|
}
|
|
46715
46511
|
}
|
|
46716
46512
|
}
|
|
@@ -47019,9 +46815,9 @@ var init_simple_git_api = __esm2({
|
|
|
47019
46815
|
next
|
|
47020
46816
|
);
|
|
47021
46817
|
}
|
|
47022
|
-
hashObject(
|
|
46818
|
+
hashObject(path86, write) {
|
|
47023
46819
|
return this._runTask(
|
|
47024
|
-
hashObjectTask(
|
|
46820
|
+
hashObjectTask(path86, write === true),
|
|
47025
46821
|
trailingFunctionArgument(arguments)
|
|
47026
46822
|
);
|
|
47027
46823
|
}
|
|
@@ -47374,8 +47170,8 @@ var init_branch = __esm2({
|
|
|
47374
47170
|
}
|
|
47375
47171
|
});
|
|
47376
47172
|
function toPath(input) {
|
|
47377
|
-
const
|
|
47378
|
-
return
|
|
47173
|
+
const path86 = input.trim().replace(/^["']|["']$/g, "");
|
|
47174
|
+
return path86 && normalize3(path86);
|
|
47379
47175
|
}
|
|
47380
47176
|
var parseCheckIgnore;
|
|
47381
47177
|
var init_CheckIgnore = __esm2({
|
|
@@ -47689,8 +47485,8 @@ __export2(sub_module_exports, {
|
|
|
47689
47485
|
subModuleTask: () => subModuleTask,
|
|
47690
47486
|
updateSubModuleTask: () => updateSubModuleTask
|
|
47691
47487
|
});
|
|
47692
|
-
function addSubModuleTask(repo,
|
|
47693
|
-
return subModuleTask(["add", repo,
|
|
47488
|
+
function addSubModuleTask(repo, path86) {
|
|
47489
|
+
return subModuleTask(["add", repo, path86]);
|
|
47694
47490
|
}
|
|
47695
47491
|
function initSubModuleTask(customArgs) {
|
|
47696
47492
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -48023,8 +47819,8 @@ var require_git = __commonJS2({
|
|
|
48023
47819
|
}
|
|
48024
47820
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
48025
47821
|
};
|
|
48026
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
48027
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
47822
|
+
Git2.prototype.submoduleAdd = function(repo, path86, then) {
|
|
47823
|
+
return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
|
|
48028
47824
|
};
|
|
48029
47825
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
48030
47826
|
return this._runTask(
|
|
@@ -48763,8 +48559,8 @@ function parseNumstatEntries(lines) {
|
|
|
48763
48559
|
}
|
|
48764
48560
|
function parseNumstat(lines) {
|
|
48765
48561
|
const m = /* @__PURE__ */ new Map();
|
|
48766
|
-
for (const [
|
|
48767
|
-
m.set(
|
|
48562
|
+
for (const [path86, entry] of parseNumstatEntries(lines)) {
|
|
48563
|
+
m.set(path86, { additions: entry.additions, deletions: entry.deletions });
|
|
48768
48564
|
}
|
|
48769
48565
|
return m;
|
|
48770
48566
|
}
|
|
@@ -48893,7 +48689,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
48893
48689
|
}
|
|
48894
48690
|
|
|
48895
48691
|
// ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
48896
|
-
import * as
|
|
48692
|
+
import * as path39 from "node:path";
|
|
48897
48693
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
48898
48694
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
48899
48695
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -48904,7 +48700,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
48904
48700
|
}
|
|
48905
48701
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
48906
48702
|
if (repoDir) {
|
|
48907
|
-
const key =
|
|
48703
|
+
const key = path39.resolve(repoDir);
|
|
48908
48704
|
const now = Date.now();
|
|
48909
48705
|
const cached2 = baseShaCache.get(key);
|
|
48910
48706
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -49039,17 +48835,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
49039
48835
|
}
|
|
49040
48836
|
|
|
49041
48837
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
49042
|
-
import * as
|
|
48838
|
+
import * as path49 from "node:path";
|
|
49043
48839
|
|
|
49044
48840
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
49045
|
-
import * as
|
|
48841
|
+
import * as path48 from "node:path";
|
|
49046
48842
|
|
|
49047
48843
|
// ../bridge/src/git/is-git-repo.ts
|
|
49048
|
-
import * as
|
|
49049
|
-
import * as
|
|
48844
|
+
import * as fs26 from "node:fs";
|
|
48845
|
+
import * as path40 from "node:path";
|
|
49050
48846
|
async function isGitRepoDirectory(dirPath) {
|
|
49051
48847
|
try {
|
|
49052
|
-
await
|
|
48848
|
+
await fs26.promises.access(path40.join(dirPath, ".git"));
|
|
49053
48849
|
return true;
|
|
49054
48850
|
} catch {
|
|
49055
48851
|
return false;
|
|
@@ -49057,8 +48853,8 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
49057
48853
|
}
|
|
49058
48854
|
|
|
49059
48855
|
// ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
|
|
49060
|
-
import * as
|
|
49061
|
-
import * as
|
|
48856
|
+
import * as fs27 from "node:fs";
|
|
48857
|
+
import * as path41 from "node:path";
|
|
49062
48858
|
|
|
49063
48859
|
// ../bridge/src/git/changes/lines/count-lines.ts
|
|
49064
48860
|
import { createReadStream } from "node:fs";
|
|
@@ -49090,7 +48886,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
49090
48886
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
49091
48887
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
49092
48888
|
if (row.change === "moved") return;
|
|
49093
|
-
const repoFilePath =
|
|
48889
|
+
const repoFilePath = path41.join(options.repoGitCwd, pathInRepo);
|
|
49094
48890
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
49095
48891
|
if (fromGit) {
|
|
49096
48892
|
row.additions = fromGit.additions;
|
|
@@ -49098,7 +48894,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
49098
48894
|
return;
|
|
49099
48895
|
}
|
|
49100
48896
|
try {
|
|
49101
|
-
const st = await
|
|
48897
|
+
const st = await fs27.promises.stat(repoFilePath);
|
|
49102
48898
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
49103
48899
|
} catch {
|
|
49104
48900
|
row.additions = 0;
|
|
@@ -49175,7 +48971,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
49175
48971
|
}
|
|
49176
48972
|
|
|
49177
48973
|
// ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
49178
|
-
import * as
|
|
48974
|
+
import * as path43 from "node:path";
|
|
49179
48975
|
|
|
49180
48976
|
// ../bridge/src/git/changes/patch/patch-truncate.ts
|
|
49181
48977
|
function truncatePatch(s) {
|
|
@@ -49263,10 +49059,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
49263
49059
|
}
|
|
49264
49060
|
|
|
49265
49061
|
// ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
49266
|
-
import * as
|
|
49062
|
+
import * as fs28 from "node:fs";
|
|
49267
49063
|
async function readWorktreeFileLines(filePath) {
|
|
49268
49064
|
try {
|
|
49269
|
-
const raw = await
|
|
49065
|
+
const raw = await fs28.promises.readFile(filePath, "utf8");
|
|
49270
49066
|
return raw.split(/\r?\n/);
|
|
49271
49067
|
} catch {
|
|
49272
49068
|
return null;
|
|
@@ -49404,8 +49200,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
49404
49200
|
}
|
|
49405
49201
|
|
|
49406
49202
|
// ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
49407
|
-
import * as
|
|
49408
|
-
import * as
|
|
49203
|
+
import * as fs29 from "node:fs";
|
|
49204
|
+
import * as path42 from "node:path";
|
|
49409
49205
|
var MAX_BYTES = 512e3;
|
|
49410
49206
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
49411
49207
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -49425,13 +49221,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
49425
49221
|
}
|
|
49426
49222
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
49427
49223
|
if (options.isBinary) return null;
|
|
49428
|
-
const filePath =
|
|
49224
|
+
const filePath = path42.join(options.repoGitCwd, options.pathInRepo);
|
|
49429
49225
|
if (options.change === "removed") {
|
|
49430
49226
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
49431
49227
|
}
|
|
49432
49228
|
if (options.change === "moved" || options.change === "modified") {
|
|
49433
49229
|
try {
|
|
49434
|
-
const st = await
|
|
49230
|
+
const st = await fs29.promises.stat(filePath);
|
|
49435
49231
|
if (!st.isFile()) return null;
|
|
49436
49232
|
return await countTextFileLines(filePath);
|
|
49437
49233
|
} catch {
|
|
@@ -49474,7 +49270,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
49474
49270
|
row.workspaceRelPath,
|
|
49475
49271
|
options.repoPathRelativeToWorkspaceRoot
|
|
49476
49272
|
);
|
|
49477
|
-
const filePath =
|
|
49273
|
+
const filePath = path43.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
49478
49274
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
49479
49275
|
let patch = await unifiedDiffForFile(
|
|
49480
49276
|
options.repoGitCwd,
|
|
@@ -49632,7 +49428,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
49632
49428
|
}
|
|
49633
49429
|
|
|
49634
49430
|
// ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
|
|
49635
|
-
import * as
|
|
49431
|
+
import * as path44 from "node:path";
|
|
49636
49432
|
|
|
49637
49433
|
// ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
|
|
49638
49434
|
async function enrichCommitFileRows(options) {
|
|
@@ -49677,7 +49473,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
49677
49473
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
49678
49474
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
49679
49475
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
49680
|
-
return `${
|
|
49476
|
+
return `${path44.resolve(repoGitCwd)}:${commitSha}`;
|
|
49681
49477
|
}
|
|
49682
49478
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
49683
49479
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -49732,7 +49528,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
49732
49528
|
}
|
|
49733
49529
|
|
|
49734
49530
|
// ../bridge/src/git/commits/list-unpushed-commits.ts
|
|
49735
|
-
import * as
|
|
49531
|
+
import * as path45 from "node:path";
|
|
49736
49532
|
|
|
49737
49533
|
// ../bridge/src/git/commits/lib/parse-log-lines.ts
|
|
49738
49534
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -49767,7 +49563,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
49767
49563
|
}
|
|
49768
49564
|
}
|
|
49769
49565
|
async function listUnpushedCommits(repoDir) {
|
|
49770
|
-
const key =
|
|
49566
|
+
const key = path45.resolve(repoDir);
|
|
49771
49567
|
const now = Date.now();
|
|
49772
49568
|
const cached2 = unpushedCache.get(key);
|
|
49773
49569
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -49828,7 +49624,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
49828
49624
|
}
|
|
49829
49625
|
|
|
49830
49626
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
49831
|
-
import * as
|
|
49627
|
+
import * as path46 from "node:path";
|
|
49832
49628
|
|
|
49833
49629
|
// ../bridge/src/git/remote-origin-url.ts
|
|
49834
49630
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -49843,7 +49639,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
49843
49639
|
|
|
49844
49640
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
49845
49641
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
49846
|
-
const resolvedCheckoutPath =
|
|
49642
|
+
const resolvedCheckoutPath = path46.resolve(checkoutPath);
|
|
49847
49643
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
49848
49644
|
await yieldToEventLoop2();
|
|
49849
49645
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -49858,14 +49654,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
49858
49654
|
}
|
|
49859
49655
|
|
|
49860
49656
|
// ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
49861
|
-
import * as
|
|
49657
|
+
import * as path47 from "node:path";
|
|
49862
49658
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
49863
|
-
const checkoutPath =
|
|
49659
|
+
const checkoutPath = path47.resolve(options.checkoutPath);
|
|
49864
49660
|
const git = cliSimpleGit(checkoutPath);
|
|
49865
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49661
|
+
const sessionParentPath = options.sessionParentPath ? path47.resolve(options.sessionParentPath) : null;
|
|
49866
49662
|
let repoPathRelativeToWorkspaceRoot;
|
|
49867
49663
|
if (sessionParentPath) {
|
|
49868
|
-
const checkoutPathRelativeToSessionParent =
|
|
49664
|
+
const checkoutPathRelativeToSessionParent = path47.relative(sessionParentPath, checkoutPath);
|
|
49869
49665
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
49870
49666
|
} else {
|
|
49871
49667
|
let gitTopLevel = checkoutPath;
|
|
@@ -49875,8 +49671,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
49875
49671
|
} catch {
|
|
49876
49672
|
gitTopLevel = checkoutPath;
|
|
49877
49673
|
}
|
|
49878
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
49879
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
49674
|
+
const gitTopLevelRelativeToBridgeRoot = path47.relative(options.bridgeRoot, path47.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
49675
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path47.basename(path47.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
49880
49676
|
}
|
|
49881
49677
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
49882
49678
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -49885,10 +49681,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
49885
49681
|
|
|
49886
49682
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
49887
49683
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
49888
|
-
const checkoutPath =
|
|
49684
|
+
const checkoutPath = path48.resolve(options.targetPath);
|
|
49889
49685
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
49890
49686
|
const isCommitView = options.basis.kind === "commit";
|
|
49891
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49687
|
+
const sessionParentPath = options.sessionParentPath ? path48.resolve(options.sessionParentPath) : null;
|
|
49892
49688
|
const git = cliSimpleGit(checkoutPath);
|
|
49893
49689
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
49894
49690
|
checkoutPath,
|
|
@@ -49936,8 +49732,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
49936
49732
|
|
|
49937
49733
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
49938
49734
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
49939
|
-
const bridgeRoot =
|
|
49940
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
49735
|
+
const bridgeRoot = path49.resolve(getBridgeRoot());
|
|
49736
|
+
const sessionParentPath = options.sessionParentPath ? path49.resolve(options.sessionParentPath) : null;
|
|
49941
49737
|
const out = [];
|
|
49942
49738
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
49943
49739
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -49968,9 +49764,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
49968
49764
|
}
|
|
49969
49765
|
|
|
49970
49766
|
// ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
49971
|
-
import * as
|
|
49767
|
+
import * as path50 from "node:path";
|
|
49972
49768
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
49973
|
-
const repoGitCwd =
|
|
49769
|
+
const repoGitCwd = path50.resolve(options.repoGitCwd);
|
|
49974
49770
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
49975
49771
|
throw new Error("Not a git repository");
|
|
49976
49772
|
}
|
|
@@ -50009,7 +49805,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
50009
49805
|
});
|
|
50010
49806
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
50011
49807
|
}
|
|
50012
|
-
const filePath =
|
|
49808
|
+
const filePath = path50.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
50013
49809
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
50014
49810
|
let patchContent = await unifiedDiffForFile(
|
|
50015
49811
|
repoGitCwd,
|
|
@@ -50055,18 +49851,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
50055
49851
|
}
|
|
50056
49852
|
|
|
50057
49853
|
// ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
50058
|
-
import * as
|
|
49854
|
+
import * as path51 from "node:path";
|
|
50059
49855
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
50060
49856
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
50061
|
-
const bridgeRoot =
|
|
50062
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
49857
|
+
const bridgeRoot = path51.resolve(getBridgeRoot());
|
|
49858
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path51.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
50063
49859
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
50064
49860
|
opts.repoRelPath.trim()
|
|
50065
49861
|
);
|
|
50066
49862
|
let result = null;
|
|
50067
49863
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
50068
49864
|
if (result) return;
|
|
50069
|
-
const checkoutPath =
|
|
49865
|
+
const checkoutPath = path51.resolve(targetPath);
|
|
50070
49866
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
50071
49867
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
50072
49868
|
checkoutPath,
|
|
@@ -50099,13 +49895,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
50099
49895
|
}
|
|
50100
49896
|
|
|
50101
49897
|
// ../bridge/src/worktrees/remove-session-worktrees.ts
|
|
50102
|
-
import * as
|
|
49898
|
+
import * as fs32 from "node:fs";
|
|
50103
49899
|
|
|
50104
49900
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
50105
|
-
import * as
|
|
49901
|
+
import * as fs31 from "node:fs";
|
|
50106
49902
|
|
|
50107
49903
|
// ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
50108
|
-
import
|
|
49904
|
+
import path52 from "node:path";
|
|
50109
49905
|
init_normalize_resolved_path();
|
|
50110
49906
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
50111
49907
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -50114,23 +49910,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
50114
49910
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
50115
49911
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
50116
49912
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
50117
|
-
const rel =
|
|
50118
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
49913
|
+
const rel = path52.relative(worktreesRoot, normalized);
|
|
49914
|
+
if (rel === "" || rel.startsWith("..") || path52.isAbsolute(rel)) return false;
|
|
50119
49915
|
return true;
|
|
50120
49916
|
}
|
|
50121
49917
|
|
|
50122
49918
|
// ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
50123
|
-
import * as
|
|
50124
|
-
import * as
|
|
49919
|
+
import * as fs30 from "node:fs";
|
|
49920
|
+
import * as path53 from "node:path";
|
|
50125
49921
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
50126
|
-
const gitDirFile =
|
|
50127
|
-
if (!
|
|
50128
|
-
const first2 =
|
|
49922
|
+
const gitDirFile = path53.join(wt, ".git");
|
|
49923
|
+
if (!fs30.existsSync(gitDirFile) || !fs30.statSync(gitDirFile).isFile()) return "";
|
|
49924
|
+
const first2 = fs30.readFileSync(gitDirFile, "utf8").trim();
|
|
50129
49925
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
50130
49926
|
if (!m) return "";
|
|
50131
|
-
const gitWorktreePath =
|
|
50132
|
-
const gitDir =
|
|
50133
|
-
return
|
|
49927
|
+
const gitWorktreePath = path53.resolve(wt, m[1].trim());
|
|
49928
|
+
const gitDir = path53.dirname(path53.dirname(gitWorktreePath));
|
|
49929
|
+
return path53.dirname(gitDir);
|
|
50134
49930
|
}
|
|
50135
49931
|
|
|
50136
49932
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
@@ -50141,7 +49937,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
50141
49937
|
return true;
|
|
50142
49938
|
}
|
|
50143
49939
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
50144
|
-
|
|
49940
|
+
fs31.rmSync(worktreePath, { recursive: true, force: true });
|
|
50145
49941
|
return true;
|
|
50146
49942
|
}
|
|
50147
49943
|
|
|
@@ -50163,7 +49959,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
50163
49959
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
50164
49960
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
50165
49961
|
try {
|
|
50166
|
-
|
|
49962
|
+
fs32.rmSync(wt, { recursive: true, force: true });
|
|
50167
49963
|
} catch {
|
|
50168
49964
|
}
|
|
50169
49965
|
}
|
|
@@ -50219,12 +50015,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
50219
50015
|
// ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
50220
50016
|
init_cli_process_interrupt();
|
|
50221
50017
|
init_yield_to_event_loop();
|
|
50222
|
-
import * as
|
|
50223
|
-
import * as
|
|
50018
|
+
import * as fs36 from "node:fs";
|
|
50019
|
+
import * as path58 from "node:path";
|
|
50224
50020
|
|
|
50225
50021
|
// ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
|
|
50226
|
-
import * as
|
|
50227
|
-
import * as
|
|
50022
|
+
import * as fs34 from "node:fs";
|
|
50023
|
+
import * as path55 from "node:path";
|
|
50228
50024
|
|
|
50229
50025
|
// ../bridge/src/worktrees/discovery/disk-walk-constants.ts
|
|
50230
50026
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -50254,8 +50050,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
50254
50050
|
// ../bridge/src/worktrees/discovery/disk-walk-utils.ts
|
|
50255
50051
|
init_cli_process_interrupt();
|
|
50256
50052
|
init_yield_to_event_loop();
|
|
50257
|
-
import * as
|
|
50258
|
-
import * as
|
|
50053
|
+
import * as fs33 from "node:fs";
|
|
50054
|
+
import * as path54 from "node:path";
|
|
50259
50055
|
async function yieldDuringDiskWalk(state) {
|
|
50260
50056
|
state.entries++;
|
|
50261
50057
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -50265,7 +50061,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
50265
50061
|
}
|
|
50266
50062
|
async function isGitDir(dirPath) {
|
|
50267
50063
|
try {
|
|
50268
|
-
await
|
|
50064
|
+
await fs33.promises.access(path54.join(dirPath, ".git"));
|
|
50269
50065
|
return true;
|
|
50270
50066
|
} catch {
|
|
50271
50067
|
return false;
|
|
@@ -50279,23 +50075,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
50279
50075
|
const walk = async (dir) => {
|
|
50280
50076
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
50281
50077
|
if (await isGitDir(dir)) {
|
|
50282
|
-
out.push(
|
|
50078
|
+
out.push(path55.resolve(dir));
|
|
50283
50079
|
return;
|
|
50284
50080
|
}
|
|
50285
50081
|
let entries;
|
|
50286
50082
|
try {
|
|
50287
|
-
entries = await
|
|
50083
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
50288
50084
|
} catch {
|
|
50289
50085
|
return;
|
|
50290
50086
|
}
|
|
50291
50087
|
for (const e of entries) {
|
|
50292
50088
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
50293
|
-
const full =
|
|
50089
|
+
const full = path55.join(dir, e.name);
|
|
50294
50090
|
if (!e.isDirectory()) continue;
|
|
50295
50091
|
await walk(full);
|
|
50296
50092
|
}
|
|
50297
50093
|
};
|
|
50298
|
-
await walk(
|
|
50094
|
+
await walk(path55.resolve(rootPath));
|
|
50299
50095
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
50300
50096
|
}
|
|
50301
50097
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -50306,16 +50102,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
50306
50102
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
50307
50103
|
let entries;
|
|
50308
50104
|
try {
|
|
50309
|
-
entries = await
|
|
50105
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
50310
50106
|
} catch {
|
|
50311
50107
|
return;
|
|
50312
50108
|
}
|
|
50313
50109
|
for (const e of entries) {
|
|
50314
50110
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
50315
|
-
const full =
|
|
50111
|
+
const full = path55.join(dir, e.name);
|
|
50316
50112
|
if (!e.isDirectory()) continue;
|
|
50317
50113
|
if (e.name === sessionId) {
|
|
50318
|
-
if (await isGitDir(full)) out.push(
|
|
50114
|
+
if (await isGitDir(full)) out.push(path55.resolve(full));
|
|
50319
50115
|
continue;
|
|
50320
50116
|
}
|
|
50321
50117
|
if (await isGitDir(full)) continue;
|
|
@@ -50327,14 +50123,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
50327
50123
|
}
|
|
50328
50124
|
|
|
50329
50125
|
// ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
50330
|
-
import * as
|
|
50126
|
+
import * as path56 from "node:path";
|
|
50331
50127
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
50332
|
-
const bridge =
|
|
50128
|
+
const bridge = path56.resolve(bridgeRoot);
|
|
50333
50129
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
50334
50130
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
50335
|
-
const entry =
|
|
50336
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
50337
|
-
}).sort((a, b) =>
|
|
50131
|
+
const entry = path56.resolve(e.absolutePath);
|
|
50132
|
+
return bridge === entry || bridge.startsWith(entry + path56.sep) || entry.startsWith(bridge + path56.sep);
|
|
50133
|
+
}).sort((a, b) => path56.resolve(b.absolutePath).length - path56.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
50338
50134
|
const ordered = [];
|
|
50339
50135
|
const seen = /* @__PURE__ */ new Set();
|
|
50340
50136
|
const add = (k) => {
|
|
@@ -50352,19 +50148,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
50352
50148
|
}
|
|
50353
50149
|
|
|
50354
50150
|
// ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
50355
|
-
import * as
|
|
50356
|
-
import * as
|
|
50151
|
+
import * as fs35 from "node:fs";
|
|
50152
|
+
import * as path57 from "node:path";
|
|
50357
50153
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
50358
50154
|
let st;
|
|
50359
50155
|
try {
|
|
50360
|
-
st = await
|
|
50156
|
+
st = await fs35.promises.stat(scopeDir);
|
|
50361
50157
|
} catch {
|
|
50362
50158
|
return null;
|
|
50363
50159
|
}
|
|
50364
50160
|
if (!st.isDirectory()) return null;
|
|
50365
50161
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
50366
50162
|
if (worktreePaths.length === 0) return null;
|
|
50367
|
-
const abs =
|
|
50163
|
+
const abs = path57.resolve(scopeDir);
|
|
50368
50164
|
return {
|
|
50369
50165
|
parentPath: abs,
|
|
50370
50166
|
repoCheckoutPaths: worktreePaths
|
|
@@ -50387,7 +50183,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50387
50183
|
const sid = sessionId.trim();
|
|
50388
50184
|
if (!sid) return null;
|
|
50389
50185
|
try {
|
|
50390
|
-
await
|
|
50186
|
+
await fs36.promises.access(worktreesRootPath);
|
|
50391
50187
|
} catch {
|
|
50392
50188
|
return null;
|
|
50393
50189
|
}
|
|
@@ -50396,13 +50192,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50396
50192
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
50397
50193
|
const scanState = { entries: 0 };
|
|
50398
50194
|
try {
|
|
50399
|
-
for (const name of await
|
|
50195
|
+
for (const name of await fs36.promises.readdir(worktreesRootPath)) {
|
|
50400
50196
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
50401
50197
|
if (name.startsWith(".")) continue;
|
|
50402
|
-
const p =
|
|
50198
|
+
const p = path58.join(worktreesRootPath, name);
|
|
50403
50199
|
let st;
|
|
50404
50200
|
try {
|
|
50405
|
-
st = await
|
|
50201
|
+
st = await fs36.promises.stat(p);
|
|
50406
50202
|
} catch {
|
|
50407
50203
|
continue;
|
|
50408
50204
|
}
|
|
@@ -50416,23 +50212,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50416
50212
|
for (const key of keys) {
|
|
50417
50213
|
if (isCliImmediateShutdownRequested()) return null;
|
|
50418
50214
|
await yieldToEventLoop();
|
|
50419
|
-
const layoutRoot =
|
|
50215
|
+
const layoutRoot = path58.join(worktreesRootPath, key);
|
|
50420
50216
|
let layoutSt;
|
|
50421
50217
|
try {
|
|
50422
|
-
layoutSt = await
|
|
50218
|
+
layoutSt = await fs36.promises.stat(layoutRoot);
|
|
50423
50219
|
} catch {
|
|
50424
50220
|
continue;
|
|
50425
50221
|
}
|
|
50426
50222
|
if (!layoutSt.isDirectory()) continue;
|
|
50427
|
-
const sessionDir =
|
|
50223
|
+
const sessionDir = path58.join(layoutRoot, sid);
|
|
50428
50224
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
50429
50225
|
if (nested) return nested;
|
|
50430
50226
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
50431
50227
|
if (legacy.paths.length > 0) {
|
|
50432
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
50228
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path58.resolve(legacy.paths[0]);
|
|
50433
50229
|
return {
|
|
50434
|
-
sessionParentPath:
|
|
50435
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
50230
|
+
sessionParentPath: path58.resolve(isolated),
|
|
50231
|
+
repoCheckoutPaths: legacy.paths.map((p) => path58.resolve(p))
|
|
50436
50232
|
};
|
|
50437
50233
|
}
|
|
50438
50234
|
}
|
|
@@ -50440,31 +50236,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
50440
50236
|
}
|
|
50441
50237
|
|
|
50442
50238
|
// ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
50443
|
-
import * as
|
|
50444
|
-
import * as
|
|
50239
|
+
import * as fs37 from "node:fs";
|
|
50240
|
+
import * as path60 from "node:path";
|
|
50445
50241
|
|
|
50446
50242
|
// ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
50447
50243
|
init_cli_process_interrupt();
|
|
50448
50244
|
init_yield_to_event_loop();
|
|
50449
|
-
import * as
|
|
50245
|
+
import * as path59 from "node:path";
|
|
50450
50246
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
50451
50247
|
const sid = sessionId.trim();
|
|
50452
50248
|
if (!sid) return null;
|
|
50453
|
-
const hintR =
|
|
50249
|
+
const hintR = path59.resolve(checkoutPath);
|
|
50454
50250
|
let best = null;
|
|
50455
|
-
let cur =
|
|
50251
|
+
let cur = path59.dirname(hintR);
|
|
50456
50252
|
for (let i = 0; i < 40; i++) {
|
|
50457
50253
|
if (isCliImmediateShutdownRequested()) return best;
|
|
50458
50254
|
await yieldToEventLoop();
|
|
50459
50255
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
50460
|
-
if (paths.paths.some((p) =>
|
|
50461
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
50256
|
+
if (paths.paths.some((p) => path59.resolve(p) === hintR)) {
|
|
50257
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path59.resolve(paths.paths[0]);
|
|
50462
50258
|
best = {
|
|
50463
|
-
sessionParentPath:
|
|
50464
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
50259
|
+
sessionParentPath: path59.resolve(isolated),
|
|
50260
|
+
repoCheckoutPaths: paths.paths.map((p) => path59.resolve(p))
|
|
50465
50261
|
};
|
|
50466
50262
|
}
|
|
50467
|
-
const next =
|
|
50263
|
+
const next = path59.dirname(cur);
|
|
50468
50264
|
if (next === cur) break;
|
|
50469
50265
|
cur = next;
|
|
50470
50266
|
}
|
|
@@ -50475,12 +50271,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
50475
50271
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
50476
50272
|
const sid = sessionId.trim();
|
|
50477
50273
|
if (!sid) return null;
|
|
50478
|
-
const hint =
|
|
50479
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
50274
|
+
const hint = path60.resolve(sessionParentPathOrHint);
|
|
50275
|
+
const underHint = await tryBindingFromSessionDirectory(path60.join(hint, sid));
|
|
50480
50276
|
if (underHint) return underHint;
|
|
50481
50277
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
50482
50278
|
if (direct) {
|
|
50483
|
-
if (
|
|
50279
|
+
if (path60.basename(hint) === sid && await isGitDir(hint)) {
|
|
50484
50280
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
50485
50281
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
50486
50282
|
return legacyFromCheckout;
|
|
@@ -50488,23 +50284,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
50488
50284
|
}
|
|
50489
50285
|
return direct;
|
|
50490
50286
|
}
|
|
50491
|
-
if (
|
|
50287
|
+
if (path60.basename(hint) === sid && await isGitDir(hint)) {
|
|
50492
50288
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
50493
50289
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
50494
50290
|
}
|
|
50495
50291
|
let st;
|
|
50496
50292
|
try {
|
|
50497
|
-
st = await
|
|
50293
|
+
st = await fs37.promises.stat(hint);
|
|
50498
50294
|
} catch {
|
|
50499
50295
|
return null;
|
|
50500
50296
|
}
|
|
50501
50297
|
if (!st.isDirectory()) return null;
|
|
50502
50298
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
50503
50299
|
if (legacyPaths.paths.length === 0) return null;
|
|
50504
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
50300
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path60.resolve(legacyPaths.paths[0]);
|
|
50505
50301
|
return {
|
|
50506
|
-
sessionParentPath:
|
|
50507
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
50302
|
+
sessionParentPath: path60.resolve(isolated),
|
|
50303
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path60.resolve(p))
|
|
50508
50304
|
};
|
|
50509
50305
|
}
|
|
50510
50306
|
|
|
@@ -50565,11 +50361,11 @@ function parseSessionParent(v) {
|
|
|
50565
50361
|
}
|
|
50566
50362
|
|
|
50567
50363
|
// ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
50568
|
-
import * as
|
|
50364
|
+
import * as fs41 from "node:fs";
|
|
50569
50365
|
|
|
50570
50366
|
// ../bridge/src/git/discover-repos.ts
|
|
50571
|
-
import * as
|
|
50572
|
-
import * as
|
|
50367
|
+
import * as fs38 from "node:fs";
|
|
50368
|
+
import * as path61 from "node:path";
|
|
50573
50369
|
init_yield_to_event_loop();
|
|
50574
50370
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
50575
50371
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -50579,14 +50375,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
50579
50375
|
}
|
|
50580
50376
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
50581
50377
|
const result = [];
|
|
50582
|
-
const cwdResolved =
|
|
50378
|
+
const cwdResolved = path61.resolve(cwd);
|
|
50583
50379
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
50584
50380
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
50585
50381
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
50586
50382
|
}
|
|
50587
50383
|
let entries;
|
|
50588
50384
|
try {
|
|
50589
|
-
entries =
|
|
50385
|
+
entries = fs38.readdirSync(cwdResolved, { withFileTypes: true });
|
|
50590
50386
|
} catch {
|
|
50591
50387
|
return result;
|
|
50592
50388
|
}
|
|
@@ -50594,7 +50390,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
50594
50390
|
await yieldGitDiscoverWork(i + 1);
|
|
50595
50391
|
const ent = entries[i];
|
|
50596
50392
|
if (!ent.isDirectory()) continue;
|
|
50597
|
-
const childPath2 =
|
|
50393
|
+
const childPath2 = path61.join(cwdResolved, ent.name);
|
|
50598
50394
|
if (await isGitRepoDirectory(childPath2)) {
|
|
50599
50395
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
50600
50396
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -50603,17 +50399,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
50603
50399
|
return result;
|
|
50604
50400
|
}
|
|
50605
50401
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
50606
|
-
const root =
|
|
50402
|
+
const root = path61.resolve(rootPath);
|
|
50607
50403
|
const roots = [];
|
|
50608
50404
|
let walkEntries = 0;
|
|
50609
50405
|
async function walk(dir) {
|
|
50610
50406
|
if (await isGitRepoDirectory(dir)) {
|
|
50611
|
-
roots.push(
|
|
50407
|
+
roots.push(path61.resolve(dir));
|
|
50612
50408
|
return;
|
|
50613
50409
|
}
|
|
50614
50410
|
let entries;
|
|
50615
50411
|
try {
|
|
50616
|
-
entries =
|
|
50412
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
50617
50413
|
} catch {
|
|
50618
50414
|
return;
|
|
50619
50415
|
}
|
|
@@ -50621,7 +50417,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
50621
50417
|
await yieldGitDiscoverWork(++walkEntries);
|
|
50622
50418
|
const ent = entries[i];
|
|
50623
50419
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
50624
|
-
await walk(
|
|
50420
|
+
await walk(path61.join(dir, ent.name));
|
|
50625
50421
|
}
|
|
50626
50422
|
}
|
|
50627
50423
|
await walk(root);
|
|
@@ -50637,8 +50433,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
50637
50433
|
}
|
|
50638
50434
|
|
|
50639
50435
|
// ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
50640
|
-
import * as
|
|
50641
|
-
import * as
|
|
50436
|
+
import * as fs40 from "node:fs";
|
|
50437
|
+
import * as path63 from "node:path";
|
|
50642
50438
|
|
|
50643
50439
|
// ../bridge/src/git/worktrees/worktree-add.ts
|
|
50644
50440
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -50654,8 +50450,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
50654
50450
|
}
|
|
50655
50451
|
|
|
50656
50452
|
// ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
50657
|
-
import * as
|
|
50658
|
-
import * as
|
|
50453
|
+
import * as fs39 from "node:fs";
|
|
50454
|
+
import * as path62 from "node:path";
|
|
50659
50455
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
50660
50456
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
50661
50457
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -50664,19 +50460,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
50664
50460
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
50665
50461
|
for (let i = 0; i < segments.length; i++) {
|
|
50666
50462
|
const prefix = segments.slice(0, i).join("/");
|
|
50667
|
-
const bridgeDir = prefix ?
|
|
50668
|
-
const destDir = prefix ?
|
|
50463
|
+
const bridgeDir = prefix ? path62.join(bridgeRoot, prefix) : bridgeRoot;
|
|
50464
|
+
const destDir = prefix ? path62.join(scopeDir, prefix) : scopeDir;
|
|
50669
50465
|
for (const fileName of fileNames) {
|
|
50670
50466
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
50671
50467
|
}
|
|
50672
50468
|
}
|
|
50673
50469
|
}
|
|
50674
50470
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
50675
|
-
const src =
|
|
50676
|
-
if (!
|
|
50677
|
-
const dest =
|
|
50471
|
+
const src = path62.join(srcDir, fileName);
|
|
50472
|
+
if (!fs39.existsSync(src)) return;
|
|
50473
|
+
const dest = path62.join(destDir, fileName);
|
|
50678
50474
|
try {
|
|
50679
|
-
|
|
50475
|
+
fs39.copyFileSync(src, dest);
|
|
50680
50476
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
50681
50477
|
} catch (e) {
|
|
50682
50478
|
log2?.(
|
|
@@ -50708,16 +50504,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
50708
50504
|
worktreeBaseBranches,
|
|
50709
50505
|
log: log2
|
|
50710
50506
|
} = options;
|
|
50711
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
50712
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
50507
|
+
const repoPathRelativeToBridgeRootRaw = path63.relative(bridgeResolved, repoAbsolutePath);
|
|
50508
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path63.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
50713
50509
|
return null;
|
|
50714
50510
|
}
|
|
50715
50511
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
50716
50512
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
50717
50513
|
);
|
|
50718
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
50514
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path63.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
50719
50515
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
50720
|
-
|
|
50516
|
+
fs40.mkdirSync(path63.dirname(worktreePath), { recursive: true });
|
|
50721
50517
|
copyBridgeFilesAlongWorktreePath({
|
|
50722
50518
|
bridgeRoot: bridgeResolved,
|
|
50723
50519
|
scopeDir,
|
|
@@ -50745,7 +50541,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
50745
50541
|
}
|
|
50746
50542
|
|
|
50747
50543
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
50748
|
-
import * as
|
|
50544
|
+
import * as path64 from "node:path";
|
|
50749
50545
|
|
|
50750
50546
|
// ../bridge/src/worktrees/worktree-layout-kind.ts
|
|
50751
50547
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -50775,10 +50571,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
50775
50571
|
|
|
50776
50572
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
50777
50573
|
function resolveIsolatedScopeDir(options) {
|
|
50778
|
-
const bridgeResolved =
|
|
50574
|
+
const bridgeResolved = path64.resolve(options.bridgeRoot);
|
|
50779
50575
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
50780
|
-
const bridgeKeyDir =
|
|
50781
|
-
const scopeDir =
|
|
50576
|
+
const bridgeKeyDir = path64.join(options.worktreesRootPath, cwdKey);
|
|
50577
|
+
const scopeDir = path64.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
50782
50578
|
return { bridgeResolved, scopeDir };
|
|
50783
50579
|
}
|
|
50784
50580
|
|
|
@@ -50808,7 +50604,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
50808
50604
|
return null;
|
|
50809
50605
|
}
|
|
50810
50606
|
const worktreePaths = [];
|
|
50811
|
-
|
|
50607
|
+
fs41.mkdirSync(scopeDir, { recursive: true });
|
|
50812
50608
|
await forEachWithGitYield(repos, async (repo) => {
|
|
50813
50609
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
50814
50610
|
kind,
|
|
@@ -50880,10 +50676,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
50880
50676
|
}
|
|
50881
50677
|
|
|
50882
50678
|
// ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
50883
|
-
import * as
|
|
50679
|
+
import * as path65 from "node:path";
|
|
50884
50680
|
init_yield_to_event_loop();
|
|
50885
50681
|
async function resolveExplicitSessionParentPath(params) {
|
|
50886
|
-
const resolved =
|
|
50682
|
+
const resolved = path65.resolve(params.parentPathRaw);
|
|
50887
50683
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
50888
50684
|
return resolved;
|
|
50889
50685
|
}
|
|
@@ -50900,7 +50696,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
50900
50696
|
await yieldToEventLoop();
|
|
50901
50697
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
50902
50698
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
50903
|
-
const next =
|
|
50699
|
+
const next = path65.dirname(cur);
|
|
50904
50700
|
if (next === cur) break;
|
|
50905
50701
|
cur = next;
|
|
50906
50702
|
}
|
|
@@ -51061,15 +50857,15 @@ var SessionWorktreeManager = class {
|
|
|
51061
50857
|
};
|
|
51062
50858
|
|
|
51063
50859
|
// ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
51064
|
-
import * as
|
|
51065
|
-
import * as
|
|
50860
|
+
import * as fs42 from "node:fs";
|
|
50861
|
+
import * as path66 from "node:path";
|
|
51066
50862
|
init_yield_to_event_loop();
|
|
51067
50863
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
51068
50864
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
51069
50865
|
const eid = environmentId.trim();
|
|
51070
50866
|
if (!eid) return null;
|
|
51071
50867
|
try {
|
|
51072
|
-
await
|
|
50868
|
+
await fs42.promises.access(worktreesRootPath);
|
|
51073
50869
|
} catch {
|
|
51074
50870
|
return null;
|
|
51075
50871
|
}
|
|
@@ -51078,13 +50874,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
51078
50874
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
51079
50875
|
const scanState = { entries: 0 };
|
|
51080
50876
|
try {
|
|
51081
|
-
for (const name of await
|
|
50877
|
+
for (const name of await fs42.promises.readdir(worktreesRootPath)) {
|
|
51082
50878
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
51083
50879
|
if (name.startsWith(".")) continue;
|
|
51084
|
-
const p =
|
|
50880
|
+
const p = path66.join(worktreesRootPath, name);
|
|
51085
50881
|
let st;
|
|
51086
50882
|
try {
|
|
51087
|
-
st = await
|
|
50883
|
+
st = await fs42.promises.stat(p);
|
|
51088
50884
|
} catch {
|
|
51089
50885
|
continue;
|
|
51090
50886
|
}
|
|
@@ -51098,7 +50894,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
51098
50894
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
51099
50895
|
for (const key of keys) {
|
|
51100
50896
|
await yieldToEventLoop();
|
|
51101
|
-
const previewDir =
|
|
50897
|
+
const previewDir = path66.join(worktreesRootPath, key, ...previewDirRel);
|
|
51102
50898
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
51103
50899
|
if (binding) return binding;
|
|
51104
50900
|
}
|
|
@@ -51225,7 +51021,7 @@ var PreviewWorktreeManager = class {
|
|
|
51225
51021
|
};
|
|
51226
51022
|
|
|
51227
51023
|
// ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
51228
|
-
import * as
|
|
51024
|
+
import * as path70 from "node:path";
|
|
51229
51025
|
|
|
51230
51026
|
// ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
|
|
51231
51027
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -51236,8 +51032,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
51236
51032
|
}
|
|
51237
51033
|
|
|
51238
51034
|
// ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
|
|
51239
|
-
import * as
|
|
51240
|
-
import * as
|
|
51035
|
+
import * as fs43 from "node:fs";
|
|
51036
|
+
import * as path67 from "node:path";
|
|
51241
51037
|
|
|
51242
51038
|
// ../bridge/src/git/is-not-a-git-repository-error.ts
|
|
51243
51039
|
function isNotAGitRepositoryError(e) {
|
|
@@ -51299,12 +51095,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
51299
51095
|
if (!ap.ok) return ap;
|
|
51300
51096
|
}
|
|
51301
51097
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
51302
|
-
const src =
|
|
51303
|
-
const dst =
|
|
51098
|
+
const src = path67.join(sourceRepoPath, rel);
|
|
51099
|
+
const dst = path67.join(targetRepoPath, rel);
|
|
51304
51100
|
try {
|
|
51305
|
-
if (!
|
|
51306
|
-
|
|
51307
|
-
|
|
51101
|
+
if (!fs43.existsSync(src)) return;
|
|
51102
|
+
fs43.mkdirSync(path67.dirname(dst), { recursive: true });
|
|
51103
|
+
fs43.copyFileSync(src, dst);
|
|
51308
51104
|
} catch (e) {
|
|
51309
51105
|
log2(
|
|
51310
51106
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -51315,14 +51111,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
51315
51111
|
}
|
|
51316
51112
|
|
|
51317
51113
|
// ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
51318
|
-
import * as
|
|
51114
|
+
import * as path68 from "node:path";
|
|
51319
51115
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
51320
51116
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
51321
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
51117
|
+
const resolvedSessionParentPath = sessionParentPath ? path68.resolve(sessionParentPath) : null;
|
|
51322
51118
|
let match = null;
|
|
51323
51119
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
51324
51120
|
if (match) return;
|
|
51325
|
-
const resolvedCheckoutPath =
|
|
51121
|
+
const resolvedCheckoutPath = path68.resolve(checkoutPath);
|
|
51326
51122
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
51327
51123
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51328
51124
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -51376,7 +51172,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
51376
51172
|
}
|
|
51377
51173
|
|
|
51378
51174
|
// ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
51379
|
-
import * as
|
|
51175
|
+
import * as path69 from "node:path";
|
|
51380
51176
|
|
|
51381
51177
|
// ../bridge/src/git/branches/create-or-update-branch.ts
|
|
51382
51178
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -51413,19 +51209,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
51413
51209
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
51414
51210
|
const states = [];
|
|
51415
51211
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
51416
|
-
const checkoutPath =
|
|
51212
|
+
const checkoutPath = path69.resolve(sessionCheckout);
|
|
51417
51213
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
51418
51214
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
51419
51215
|
checkoutPath,
|
|
51420
51216
|
bridgeRoot,
|
|
51421
|
-
sessionParentPath: sessionParentPath ?
|
|
51217
|
+
sessionParentPath: sessionParentPath ? path69.resolve(sessionParentPath) : null
|
|
51422
51218
|
});
|
|
51423
51219
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
51424
51220
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
51425
51221
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
51426
51222
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
51427
51223
|
checkoutPaths: previewCheckoutPaths,
|
|
51428
|
-
sessionParentPath: previewParentPath ?
|
|
51224
|
+
sessionParentPath: previewParentPath ? path69.resolve(previewParentPath) : null,
|
|
51429
51225
|
bridgeRoot,
|
|
51430
51226
|
repoPathRelativeToWorkspaceRoot
|
|
51431
51227
|
}) : null;
|
|
@@ -51445,7 +51241,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
51445
51241
|
const eid = options.environmentId.trim();
|
|
51446
51242
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
51447
51243
|
const deployBranch = previewDeployBranchName(eid);
|
|
51448
|
-
const bridgeRoot =
|
|
51244
|
+
const bridgeRoot = path70.resolve(getBridgeRoot());
|
|
51449
51245
|
await previewWorktreeManager.ensureCached(eid);
|
|
51450
51246
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
51451
51247
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -51485,10 +51281,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
51485
51281
|
}
|
|
51486
51282
|
|
|
51487
51283
|
// ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
|
|
51488
|
-
import * as
|
|
51489
|
-
import
|
|
51284
|
+
import * as path71 from "node:path";
|
|
51285
|
+
import os7 from "node:os";
|
|
51490
51286
|
function defaultWorktreesRootPath() {
|
|
51491
|
-
return
|
|
51287
|
+
return path71.join(os7.homedir(), ".buildautomaton", "worktrees");
|
|
51492
51288
|
}
|
|
51493
51289
|
|
|
51494
51290
|
// ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
|
|
@@ -51613,14 +51409,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
51613
51409
|
}
|
|
51614
51410
|
|
|
51615
51411
|
// ../bridge/src/files/list-dir/index.ts
|
|
51616
|
-
import
|
|
51412
|
+
import fs45 from "node:fs";
|
|
51617
51413
|
|
|
51618
51414
|
// ../bridge/src/files/ensure-under-cwd.ts
|
|
51619
|
-
import
|
|
51415
|
+
import path72 from "node:path";
|
|
51620
51416
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
51621
|
-
const normalized =
|
|
51622
|
-
const resolved =
|
|
51623
|
-
if (!resolved.startsWith(cwd +
|
|
51417
|
+
const normalized = path72.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
51418
|
+
const resolved = path72.resolve(cwd, normalized);
|
|
51419
|
+
if (!resolved.startsWith(cwd + path72.sep) && resolved !== cwd) {
|
|
51624
51420
|
return null;
|
|
51625
51421
|
}
|
|
51626
51422
|
return resolved;
|
|
@@ -51633,15 +51429,15 @@ init_yield_to_event_loop();
|
|
|
51633
51429
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
51634
51430
|
|
|
51635
51431
|
// ../bridge/src/files/list-dir/map-dir-entry.ts
|
|
51636
|
-
import
|
|
51637
|
-
import
|
|
51432
|
+
import path73 from "node:path";
|
|
51433
|
+
import fs44 from "node:fs";
|
|
51638
51434
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
51639
|
-
const entryPath =
|
|
51640
|
-
const fullPath =
|
|
51435
|
+
const entryPath = path73.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
51436
|
+
const fullPath = path73.join(resolved, d.name);
|
|
51641
51437
|
let isDir = d.isDirectory();
|
|
51642
51438
|
if (d.isSymbolicLink()) {
|
|
51643
51439
|
try {
|
|
51644
|
-
const targetStat = await
|
|
51440
|
+
const targetStat = await fs44.promises.stat(fullPath);
|
|
51645
51441
|
isDir = targetStat.isDirectory();
|
|
51646
51442
|
} catch {
|
|
51647
51443
|
isDir = false;
|
|
@@ -51671,7 +51467,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
51671
51467
|
return { error: "Path is outside working directory" };
|
|
51672
51468
|
}
|
|
51673
51469
|
try {
|
|
51674
|
-
const names = await
|
|
51470
|
+
const names = await fs45.promises.readdir(resolved, { withFileTypes: true });
|
|
51675
51471
|
const entries = [];
|
|
51676
51472
|
for (let i = 0; i < names.length; i++) {
|
|
51677
51473
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -51687,13 +51483,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
51687
51483
|
}
|
|
51688
51484
|
|
|
51689
51485
|
// ../bridge/src/git/tree/resolve-repo-abs-path.ts
|
|
51690
|
-
import * as
|
|
51486
|
+
import * as path74 from "node:path";
|
|
51691
51487
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
51692
|
-
const bridgeResolved =
|
|
51488
|
+
const bridgeResolved = path74.resolve(bridgeRoot);
|
|
51693
51489
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
51694
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
51695
|
-
const resolved =
|
|
51696
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
51490
|
+
const repoPath = rel === "" ? bridgeResolved : path74.join(bridgeResolved, rel);
|
|
51491
|
+
const resolved = path74.resolve(repoPath);
|
|
51492
|
+
if (!resolved.startsWith(bridgeResolved + path74.sep) && resolved !== bridgeResolved) {
|
|
51697
51493
|
return null;
|
|
51698
51494
|
}
|
|
51699
51495
|
return resolved;
|
|
@@ -52174,25 +51970,25 @@ async function GET2(ctx) {
|
|
|
52174
51970
|
init_in_flight();
|
|
52175
51971
|
|
|
52176
51972
|
// ../bridge/src/files/read/read-file-async.ts
|
|
52177
|
-
import
|
|
51973
|
+
import fs51 from "node:fs";
|
|
52178
51974
|
init_yield_to_event_loop();
|
|
52179
51975
|
|
|
52180
51976
|
// ../bridge/src/files/read/resolve-file-cache.ts
|
|
52181
|
-
import
|
|
52182
|
-
import
|
|
51977
|
+
import fs46 from "node:fs";
|
|
51978
|
+
import path75 from "node:path";
|
|
52183
51979
|
var RESOLVE_CACHE_MAX = 4096;
|
|
52184
51980
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
52185
51981
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
52186
51982
|
return `${sessionParentPath}\0${relativePath}`;
|
|
52187
51983
|
}
|
|
52188
51984
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
52189
|
-
const parent =
|
|
52190
|
-
const resolved =
|
|
52191
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
51985
|
+
const parent = path75.resolve(sessionParentPath);
|
|
51986
|
+
const resolved = path75.resolve(filePath);
|
|
51987
|
+
return resolved === parent || resolved.startsWith(`${parent}${path75.sep}`);
|
|
52192
51988
|
}
|
|
52193
51989
|
function statMatchesCacheSync(entry) {
|
|
52194
51990
|
try {
|
|
52195
|
-
const stat3 =
|
|
51991
|
+
const stat3 = fs46.statSync(entry.path);
|
|
52196
51992
|
return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
|
|
52197
51993
|
} catch {
|
|
52198
51994
|
return false;
|
|
@@ -52225,7 +52021,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
52225
52021
|
}
|
|
52226
52022
|
|
|
52227
52023
|
// ../bridge/src/files/read/resolve-file-for-read-core.ts
|
|
52228
|
-
import
|
|
52024
|
+
import fs47 from "node:fs";
|
|
52229
52025
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
52230
52026
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
52231
52027
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -52235,13 +52031,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
52235
52031
|
let size;
|
|
52236
52032
|
let mtimeMs;
|
|
52237
52033
|
try {
|
|
52238
|
-
const lstat =
|
|
52034
|
+
const lstat = fs47.lstatSync(resolved);
|
|
52239
52035
|
if (lstat.isSymbolicLink()) {
|
|
52240
|
-
real =
|
|
52036
|
+
real = fs47.realpathSync(resolved);
|
|
52241
52037
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
52242
52038
|
return { error: "Path is outside working directory" };
|
|
52243
52039
|
}
|
|
52244
|
-
const stat3 =
|
|
52040
|
+
const stat3 = fs47.statSync(real);
|
|
52245
52041
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
52246
52042
|
size = stat3.size;
|
|
52247
52043
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -52269,13 +52065,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
52269
52065
|
let size;
|
|
52270
52066
|
let mtimeMs;
|
|
52271
52067
|
try {
|
|
52272
|
-
const lstat = await
|
|
52068
|
+
const lstat = await fs47.promises.lstat(resolved);
|
|
52273
52069
|
if (lstat.isSymbolicLink()) {
|
|
52274
|
-
real = await
|
|
52070
|
+
real = await fs47.promises.realpath(resolved);
|
|
52275
52071
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
52276
52072
|
return { error: "Path is outside working directory" };
|
|
52277
52073
|
}
|
|
52278
|
-
const stat3 = await
|
|
52074
|
+
const stat3 = await fs47.promises.stat(real);
|
|
52279
52075
|
if (!stat3.isFile()) return { error: "Not a file" };
|
|
52280
52076
|
size = stat3.size;
|
|
52281
52077
|
mtimeMs = stat3.mtimeMs;
|
|
@@ -52324,7 +52120,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
52324
52120
|
|
|
52325
52121
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
52326
52122
|
init_yield_to_event_loop();
|
|
52327
|
-
import
|
|
52123
|
+
import fs48 from "node:fs";
|
|
52328
52124
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
52329
52125
|
|
|
52330
52126
|
// ../bridge/src/files/read/read-file-range-line-zero.ts
|
|
@@ -52438,8 +52234,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
52438
52234
|
|
|
52439
52235
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
52440
52236
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
52441
|
-
const fileSize = fileSizeIn ?? (await
|
|
52442
|
-
const fd = await
|
|
52237
|
+
const fileSize = fileSizeIn ?? (await fs48.promises.stat(filePath)).size;
|
|
52238
|
+
const fd = await fs48.promises.open(filePath, "r");
|
|
52443
52239
|
const bufSize = 64 * 1024;
|
|
52444
52240
|
const buf = Buffer.alloc(bufSize);
|
|
52445
52241
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -52540,7 +52336,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
52540
52336
|
}
|
|
52541
52337
|
|
|
52542
52338
|
// ../bridge/src/files/read/read-small-file-range-async.ts
|
|
52543
|
-
import
|
|
52339
|
+
import fs49 from "node:fs";
|
|
52544
52340
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
52545
52341
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
52546
52342
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -52570,7 +52366,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
52570
52366
|
};
|
|
52571
52367
|
}
|
|
52572
52368
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
52573
|
-
const raw =
|
|
52369
|
+
const raw = fs49.readFileSync(filePath, "utf8");
|
|
52574
52370
|
const lines = raw.split(/\r?\n/);
|
|
52575
52371
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
52576
52372
|
}
|
|
@@ -52578,28 +52374,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
52578
52374
|
if (isMainThread5) {
|
|
52579
52375
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
52580
52376
|
}
|
|
52581
|
-
const raw = await
|
|
52377
|
+
const raw = await fs49.promises.readFile(filePath, "utf8");
|
|
52582
52378
|
const lines = raw.split(/\r?\n/);
|
|
52583
52379
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
52584
52380
|
}
|
|
52585
52381
|
|
|
52586
52382
|
// ../bridge/src/files/read/read-file-buffer-full-async.ts
|
|
52587
52383
|
init_yield_to_event_loop();
|
|
52588
|
-
import
|
|
52384
|
+
import fs50 from "node:fs";
|
|
52589
52385
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
52590
52386
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
52591
52387
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
52592
52388
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
52593
52389
|
if (isMainThread6) {
|
|
52594
|
-
const size2 = knownSize ??
|
|
52390
|
+
const size2 = knownSize ?? fs50.statSync(filePath).size;
|
|
52595
52391
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
52596
52392
|
await yieldToEventLoop();
|
|
52597
|
-
const buffer =
|
|
52393
|
+
const buffer = fs50.readFileSync(filePath);
|
|
52598
52394
|
return { buffer, size: buffer.length };
|
|
52599
52395
|
}
|
|
52600
52396
|
}
|
|
52601
|
-
const size = knownSize ?? (await
|
|
52602
|
-
const fd = await
|
|
52397
|
+
const size = knownSize ?? (await fs50.promises.stat(filePath)).size;
|
|
52398
|
+
const fd = await fs50.promises.open(filePath, "r");
|
|
52603
52399
|
const chunks = [];
|
|
52604
52400
|
let position = 0;
|
|
52605
52401
|
let bytesSinceYield = 0;
|
|
@@ -52702,7 +52498,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
52702
52498
|
}
|
|
52703
52499
|
if (hasRange) {
|
|
52704
52500
|
if (fileSize == null) {
|
|
52705
|
-
const stat3 = await
|
|
52501
|
+
const stat3 = await fs51.promises.stat(resolvedPath);
|
|
52706
52502
|
fileSize = stat3.size;
|
|
52707
52503
|
}
|
|
52708
52504
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -53000,12 +52796,12 @@ function parseOptionalInt2(raw) {
|
|
|
53000
52796
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
53001
52797
|
}
|
|
53002
52798
|
function parseCodeNavParams(url2) {
|
|
53003
|
-
const
|
|
52799
|
+
const path86 = url2.searchParams.get("path") ?? "";
|
|
53004
52800
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
53005
52801
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
53006
52802
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
53007
52803
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
53008
|
-
return { path:
|
|
52804
|
+
return { path: path86, op, line, column };
|
|
53009
52805
|
}
|
|
53010
52806
|
function parseCodeNavPath(url2) {
|
|
53011
52807
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -53694,7 +53490,6 @@ var handleBridgeIdentified = (msg, deps) => {
|
|
|
53694
53490
|
});
|
|
53695
53491
|
setImmediate(() => {
|
|
53696
53492
|
void (async () => {
|
|
53697
|
-
cancelInFlightAgentCapabilityWarmup();
|
|
53698
53493
|
try {
|
|
53699
53494
|
await deps.reportAutoDetectedAgents?.();
|
|
53700
53495
|
} catch (e) {
|
|
@@ -53702,13 +53497,11 @@ var handleBridgeIdentified = (msg, deps) => {
|
|
|
53702
53497
|
`[Bridge service] Auto-detect agents failed: ${e instanceof Error ? e.message : String(e)}`
|
|
53703
53498
|
);
|
|
53704
53499
|
}
|
|
53705
|
-
|
|
53706
|
-
await deps.warmupAgentCapabilitiesOnConnect?.();
|
|
53707
|
-
} catch (e) {
|
|
53500
|
+
void deps.warmupAgentCapabilitiesOnConnect?.()?.catch((e) => {
|
|
53708
53501
|
deps.log(
|
|
53709
53502
|
`[Bridge service] Agent capability warmup failed: ${e instanceof Error ? e.message : String(e)}`
|
|
53710
53503
|
);
|
|
53711
|
-
}
|
|
53504
|
+
});
|
|
53712
53505
|
})();
|
|
53713
53506
|
});
|
|
53714
53507
|
};
|
|
@@ -53941,19 +53734,34 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
53941
53734
|
handleBridgeAgentConfig(msg, deps);
|
|
53942
53735
|
};
|
|
53943
53736
|
|
|
53944
|
-
// ../bridge/src/prompt-
|
|
53737
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
53945
53738
|
init_yield_to_event_loop();
|
|
53946
53739
|
|
|
53947
|
-
// ../bridge/src/prompt-
|
|
53740
|
+
// ../bridge/src/prompt-queue/snapshots/types.ts
|
|
53741
|
+
function parseServerTurnSnapshot(raw) {
|
|
53742
|
+
if (!raw || typeof raw !== "object") return null;
|
|
53743
|
+
const o = raw;
|
|
53744
|
+
const turnId = typeof o.turnId === "string" ? o.turnId : "";
|
|
53745
|
+
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
53746
|
+
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
53747
|
+
const serverState = o.serverState ?? o.bridgeServerState;
|
|
53748
|
+
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
53749
|
+
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
53750
|
+
if (!turnId || !sessionId) return null;
|
|
53751
|
+
return { turnId, sessionId, turnOrd, serverState, lastCliState, payload };
|
|
53752
|
+
}
|
|
53753
|
+
function promptQueueSnapshotEntries(queues) {
|
|
53754
|
+
const entries = [];
|
|
53755
|
+
for (const [queueKey, rawTurns] of Object.entries(queues)) {
|
|
53756
|
+
if (!Array.isArray(rawTurns)) continue;
|
|
53757
|
+
const turns = rawTurns.map(parseServerTurnSnapshot).filter((t) => t !== null);
|
|
53758
|
+
entries.push([queueKey, turns]);
|
|
53759
|
+
}
|
|
53760
|
+
return entries;
|
|
53761
|
+
}
|
|
53762
|
+
|
|
53763
|
+
// ../bridge/src/prompt-queue/persistence/read-persisted-queue.ts
|
|
53948
53764
|
init_cli_database();
|
|
53949
|
-
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
53950
|
-
"queued",
|
|
53951
|
-
"requeued",
|
|
53952
|
-
"requeued_with_revert",
|
|
53953
|
-
"cancel_requested",
|
|
53954
|
-
"stopping",
|
|
53955
|
-
"discarded"
|
|
53956
|
-
]);
|
|
53957
53765
|
async function readPersistedQueue(queueKey) {
|
|
53958
53766
|
return withCliSqlite((db) => {
|
|
53959
53767
|
const row = db.get("SELECT queue_key, updated_at, turns_json FROM prompt_queue WHERE queue_key = ?", [
|
|
@@ -53969,6 +53777,9 @@ async function readPersistedQueue(queueKey) {
|
|
|
53969
53777
|
}
|
|
53970
53778
|
});
|
|
53971
53779
|
}
|
|
53780
|
+
|
|
53781
|
+
// ../bridge/src/prompt-queue/persistence/write-persisted-queue.ts
|
|
53782
|
+
init_cli_database();
|
|
53972
53783
|
async function writePersistedQueue(file2) {
|
|
53973
53784
|
await withCliSqlite((db) => {
|
|
53974
53785
|
db.run(
|
|
@@ -53978,36 +53789,103 @@ async function writePersistedQueue(file2) {
|
|
|
53978
53789
|
);
|
|
53979
53790
|
});
|
|
53980
53791
|
}
|
|
53981
|
-
|
|
53982
|
-
|
|
53792
|
+
|
|
53793
|
+
// ../bridge/src/prompt-queue/reconciliation/merge-turns.ts
|
|
53794
|
+
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
53795
|
+
"queued",
|
|
53796
|
+
"requeued",
|
|
53797
|
+
"requeued_with_revert",
|
|
53798
|
+
"cancel_requested",
|
|
53799
|
+
"stopping",
|
|
53800
|
+
"discarded"
|
|
53801
|
+
]);
|
|
53802
|
+
function mergeServerSnapshotWithLocal(queueKey, serverTurns, prev) {
|
|
53983
53803
|
const turns = [];
|
|
53984
|
-
for (const
|
|
53985
|
-
if (!
|
|
53986
|
-
const
|
|
53987
|
-
const
|
|
53988
|
-
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
53989
|
-
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
53990
|
-
const bridgeServerState = o.serverState ?? o.bridgeServerState;
|
|
53991
|
-
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
53992
|
-
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
53993
|
-
if (!turnId || !sessionId) continue;
|
|
53994
|
-
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(bridgeServerState))) continue;
|
|
53995
|
-
const old = prev?.turns.find((t) => t.turnId === turnId);
|
|
53996
|
-
const mergedCli = old?.lastCliState === "running" && lastCliState == null ? "running" : lastCliState;
|
|
53804
|
+
for (const s of serverTurns) {
|
|
53805
|
+
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(s.serverState))) continue;
|
|
53806
|
+
const old = prev?.turns.find((t) => t.turnId === s.turnId);
|
|
53807
|
+
const mergedCli = old?.lastCliState === "running" && s.lastCliState == null ? "running" : s.lastCliState;
|
|
53997
53808
|
turns.push({
|
|
53998
|
-
turnId,
|
|
53999
|
-
sessionId,
|
|
54000
|
-
turnOrd,
|
|
54001
|
-
bridgeServerState,
|
|
53809
|
+
turnId: s.turnId,
|
|
53810
|
+
sessionId: s.sessionId,
|
|
53811
|
+
turnOrd: s.turnOrd,
|
|
53812
|
+
bridgeServerState: s.serverState,
|
|
54002
53813
|
lastCliState: mergedCli,
|
|
54003
|
-
payload
|
|
53814
|
+
payload: s.payload
|
|
54004
53815
|
});
|
|
54005
53816
|
}
|
|
54006
53817
|
turns.sort((a, b) => a.turnOrd - b.turnOrd);
|
|
54007
53818
|
return { queueKey, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
54008
53819
|
}
|
|
53820
|
+
function hasLiveRunningTurn(turns, isLiveRun) {
|
|
53821
|
+
return turns.some((t) => t.lastCliState === "running" && isLiveRun(t.turnId));
|
|
53822
|
+
}
|
|
53823
|
+
function isTerminalCliState(state) {
|
|
53824
|
+
return state === "stopped" || state === "failed" || state === "cancelled";
|
|
53825
|
+
}
|
|
53826
|
+
function isSkippedServerState(state) {
|
|
53827
|
+
return state === "discarded" || state === "stopping" || state === "cancel_requested";
|
|
53828
|
+
}
|
|
53829
|
+
|
|
53830
|
+
// ../bridge/src/prompt-queue/reconciliation/pick-actions.ts
|
|
53831
|
+
function pickNextRunnableTurn(turns) {
|
|
53832
|
+
for (const t of turns) {
|
|
53833
|
+
if (isSkippedServerState(t.bridgeServerState)) continue;
|
|
53834
|
+
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
53835
|
+
if (isTerminalCliState(t.lastCliState) || t.lastCliState === "running") continue;
|
|
53836
|
+
return t;
|
|
53837
|
+
}
|
|
53838
|
+
return null;
|
|
53839
|
+
}
|
|
53840
|
+
function normalizeStaleRunning(turns, isLiveRun) {
|
|
53841
|
+
return turns.map((t) => {
|
|
53842
|
+
if (t.lastCliState !== "running") return t;
|
|
53843
|
+
if (isLiveRun(t.turnId)) return t;
|
|
53844
|
+
if (t.bridgeServerState === "cancel_requested") return t;
|
|
53845
|
+
return { ...t, lastCliState: null };
|
|
53846
|
+
});
|
|
53847
|
+
}
|
|
53848
|
+
function reconcileQueueActions(queueKey, turns, isLiveRun) {
|
|
53849
|
+
const actions = [];
|
|
53850
|
+
for (const t of turns) {
|
|
53851
|
+
if (t.bridgeServerState === "cancel_requested" && t.lastCliState === "running" && isLiveRun(t.turnId)) {
|
|
53852
|
+
actions.push({ type: "cancel_run", queueKey, turnId: t.turnId });
|
|
53853
|
+
}
|
|
53854
|
+
}
|
|
53855
|
+
for (const t of turns) {
|
|
53856
|
+
if (t.bridgeServerState !== "cancel_requested") continue;
|
|
53857
|
+
if (t.lastCliState !== "running") continue;
|
|
53858
|
+
if (isLiveRun(t.turnId)) continue;
|
|
53859
|
+
actions.push({ type: "finalize_stale", queueKey, turnId: t.turnId, cliState: "cancelled" });
|
|
53860
|
+
}
|
|
53861
|
+
const normalized = normalizeStaleRunning(turns, isLiveRun);
|
|
53862
|
+
if (hasLiveRunningTurn(normalized, isLiveRun)) return actions;
|
|
53863
|
+
const next = pickNextRunnableTurn(normalized);
|
|
53864
|
+
if (next) {
|
|
53865
|
+
actions.push({ type: "start_run", queueKey, turn: next });
|
|
53866
|
+
actions.push({ type: "report_cli_state", queueKey, turnId: next.turnId, cliState: "running" });
|
|
53867
|
+
}
|
|
53868
|
+
return actions;
|
|
53869
|
+
}
|
|
53870
|
+
function applyStaleRunningNormalization(turns, isLiveRun) {
|
|
53871
|
+
return normalizeStaleRunning(turns, isLiveRun);
|
|
53872
|
+
}
|
|
53873
|
+
|
|
53874
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
53875
|
+
init_yield_to_event_loop();
|
|
54009
53876
|
|
|
54010
|
-
// ../bridge/src/prompt-
|
|
53877
|
+
// ../bridge/src/prompt-queue/runner/client-report.ts
|
|
53878
|
+
function sendPromptQueueClientReport(ws, queues) {
|
|
53879
|
+
if (!ws) return false;
|
|
53880
|
+
const wireQueues = {};
|
|
53881
|
+
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
53882
|
+
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
53883
|
+
}
|
|
53884
|
+
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
53885
|
+
return true;
|
|
53886
|
+
}
|
|
53887
|
+
|
|
53888
|
+
// ../bridge/src/prompt-queue/runner/dispatch-local-prompt.ts
|
|
54011
53889
|
function dispatchLocalPrompt(next, deps) {
|
|
54012
53890
|
const pl = next.payload;
|
|
54013
53891
|
const rawParent = pl["sessionParent"];
|
|
@@ -54034,20 +53912,17 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
54034
53912
|
handleBridgePrompt(msg, deps);
|
|
54035
53913
|
}
|
|
54036
53914
|
|
|
54037
|
-
// ../bridge/src/prompt-
|
|
53915
|
+
// ../bridge/src/prompt-queue/runner/run-id-queue-key-map.ts
|
|
54038
53916
|
var runIdToQueueKey = /* @__PURE__ */ new Map();
|
|
54039
|
-
var locallyDispatchedRunIds = /* @__PURE__ */ new Set();
|
|
54040
53917
|
function getRunIdQueueKey(runId) {
|
|
54041
53918
|
return runIdToQueueKey.get(runId);
|
|
54042
53919
|
}
|
|
54043
53920
|
function setRunIdQueueKey(runId, queueKey) {
|
|
54044
53921
|
runIdToQueueKey.set(runId, queueKey);
|
|
54045
|
-
locallyDispatchedRunIds.add(runId);
|
|
54046
53922
|
}
|
|
54047
53923
|
function deleteRunIdQueueKey(runId) {
|
|
54048
53924
|
const queueKey = runIdToQueueKey.get(runId);
|
|
54049
53925
|
runIdToQueueKey.delete(runId);
|
|
54050
|
-
locallyDispatchedRunIds.delete(runId);
|
|
54051
53926
|
return queueKey;
|
|
54052
53927
|
}
|
|
54053
53928
|
function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
@@ -54056,33 +53931,7 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
|
54056
53931
|
}
|
|
54057
53932
|
}
|
|
54058
53933
|
|
|
54059
|
-
// ../bridge/src/prompt-
|
|
54060
|
-
async function dispatchStartedPromptQueueRuns(entries, started, deps) {
|
|
54061
|
-
for (const [queueKey] of entries) {
|
|
54062
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54063
|
-
const running2 = file2?.turns.find((turn) => turn.lastCliState === "running");
|
|
54064
|
-
if (running2 && started.has(running2.turnId) && getRunIdQueueKey(running2.turnId) === queueKey) {
|
|
54065
|
-
dispatchLocalPrompt(running2, deps);
|
|
54066
|
-
}
|
|
54067
|
-
await yieldToEventLoop();
|
|
54068
|
-
}
|
|
54069
|
-
}
|
|
54070
|
-
|
|
54071
|
-
// ../bridge/src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
54072
|
-
init_yield_to_event_loop();
|
|
54073
|
-
|
|
54074
|
-
// ../bridge/src/prompt-turn-queue/client-report.ts
|
|
54075
|
-
function sendPromptQueueClientReport(ws, queues) {
|
|
54076
|
-
if (!ws) return false;
|
|
54077
|
-
const wireQueues = {};
|
|
54078
|
-
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
54079
|
-
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
54080
|
-
}
|
|
54081
|
-
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
54082
|
-
return true;
|
|
54083
|
-
}
|
|
54084
|
-
|
|
54085
|
-
// ../bridge/src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
53934
|
+
// ../bridge/src/prompt-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
54086
53935
|
async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
54087
53936
|
if (!runId) return false;
|
|
54088
53937
|
const queueKey = deleteRunIdQueueKey(runId);
|
|
@@ -54097,79 +53946,19 @@ async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
|
54097
53946
|
return true;
|
|
54098
53947
|
}
|
|
54099
53948
|
|
|
54100
|
-
// ../bridge/src/prompt-
|
|
54101
|
-
|
|
54102
|
-
for (const [queueKey] of entries) {
|
|
54103
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54104
|
-
const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
|
|
54105
|
-
if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey) {
|
|
54106
|
-
await yieldToEventLoop();
|
|
54107
|
-
continue;
|
|
54108
|
-
}
|
|
54109
|
-
deps.log(`[Queue] Cancellation request received for turn ${turn.turnId.slice(0, 8)}\u2026`);
|
|
54110
|
-
if (await deps.acpManager.cancelRun(turn.turnId)) {
|
|
54111
|
-
await yieldToEventLoop();
|
|
54112
|
-
continue;
|
|
54113
|
-
}
|
|
54114
|
-
deps.log(`[Queue] No local ACP run remains for ${turn.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
54115
|
-
await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
|
|
54116
|
-
await yieldToEventLoop();
|
|
54117
|
-
}
|
|
54118
|
-
}
|
|
54119
|
-
|
|
54120
|
-
// ../bridge/src/prompt-turn-queue/runner/persist-prompt-queue-snapshot.ts
|
|
54121
|
-
init_yield_to_event_loop();
|
|
54122
|
-
async function persistPromptQueueSnapshot(entries) {
|
|
54123
|
-
for (const [queueKey, serverTurns] of entries) {
|
|
54124
|
-
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
54125
|
-
await writePersistedQueue(file2);
|
|
54126
|
-
await yieldToEventLoop();
|
|
54127
|
-
}
|
|
54128
|
-
for (const [queueKey] of entries) {
|
|
54129
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
54130
|
-
if (file2) syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
54131
|
-
await yieldToEventLoop();
|
|
54132
|
-
}
|
|
54133
|
-
}
|
|
54134
|
-
|
|
54135
|
-
// ../bridge/src/prompt-turn-queue/runner/prompt-queue-snapshot-types.ts
|
|
54136
|
-
function promptQueueSnapshotEntries(queues) {
|
|
54137
|
-
return Object.entries(queues).filter((entry) => Array.isArray(entry[1]));
|
|
54138
|
-
}
|
|
54139
|
-
|
|
54140
|
-
// ../bridge/src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
54141
|
-
init_yield_to_event_loop();
|
|
54142
|
-
|
|
54143
|
-
// ../bridge/src/prompt-turn-queue/runner/queue-selection.ts
|
|
54144
|
-
function pickNextRunnableTurn(turns) {
|
|
54145
|
-
for (const t of turns) {
|
|
54146
|
-
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
54147
|
-
if (t.bridgeServerState === "cancel_requested") continue;
|
|
54148
|
-
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
54149
|
-
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
54150
|
-
continue;
|
|
54151
|
-
}
|
|
54152
|
-
return t;
|
|
54153
|
-
}
|
|
54154
|
-
return null;
|
|
54155
|
-
}
|
|
54156
|
-
function hasRunningTurn(turns) {
|
|
54157
|
-
return turns.some((t) => t.lastCliState === "running");
|
|
54158
|
-
}
|
|
54159
|
-
|
|
54160
|
-
// ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
54161
|
-
import fs55 from "node:fs";
|
|
53949
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
53950
|
+
import fs54 from "node:fs";
|
|
54162
53951
|
|
|
54163
53952
|
// ../bridge/src/git/snapshot/capture.ts
|
|
54164
|
-
import * as
|
|
54165
|
-
import * as
|
|
53953
|
+
import * as fs53 from "node:fs";
|
|
53954
|
+
import * as path77 from "node:path";
|
|
54166
53955
|
|
|
54167
53956
|
// ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
54168
|
-
import * as
|
|
53957
|
+
import * as fs52 from "node:fs";
|
|
54169
53958
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
54170
53959
|
let data;
|
|
54171
53960
|
try {
|
|
54172
|
-
data = JSON.parse(
|
|
53961
|
+
data = JSON.parse(fs52.readFileSync(filePath, "utf8"));
|
|
54173
53962
|
} catch (error51) {
|
|
54174
53963
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
54175
53964
|
}
|
|
@@ -54198,18 +53987,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
54198
53987
|
}
|
|
54199
53988
|
|
|
54200
53989
|
// ../bridge/src/git/snapshot/resolve-repo-roots.ts
|
|
54201
|
-
import * as
|
|
53990
|
+
import * as path76 from "node:path";
|
|
54202
53991
|
async function resolveSnapshotRepoRoots(options) {
|
|
54203
53992
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
54204
53993
|
if (worktreePaths?.length) {
|
|
54205
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
53994
|
+
const paths = [...new Set(worktreePaths.map((p) => path76.resolve(p)))];
|
|
54206
53995
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
54207
53996
|
}
|
|
54208
53997
|
try {
|
|
54209
53998
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
54210
53999
|
const sid = sessionId?.trim();
|
|
54211
54000
|
if (!sid) return roots;
|
|
54212
|
-
const sessionRoots = roots.filter((root) =>
|
|
54001
|
+
const sessionRoots = roots.filter((root) => path76.basename(root) === sid);
|
|
54213
54002
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
54214
54003
|
} catch (error51) {
|
|
54215
54004
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -54231,7 +54020,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54231
54020
|
});
|
|
54232
54021
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
54233
54022
|
try {
|
|
54234
|
-
|
|
54023
|
+
fs53.mkdirSync(dir, { recursive: true });
|
|
54235
54024
|
} catch (e) {
|
|
54236
54025
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
54237
54026
|
}
|
|
@@ -54240,9 +54029,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54240
54029
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
54241
54030
|
repos
|
|
54242
54031
|
};
|
|
54243
|
-
const filePath =
|
|
54032
|
+
const filePath = path77.join(dir, `${runId}.json`);
|
|
54244
54033
|
try {
|
|
54245
|
-
|
|
54034
|
+
fs53.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
54246
54035
|
} catch (e) {
|
|
54247
54036
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
54248
54037
|
}
|
|
@@ -54253,7 +54042,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
54253
54042
|
return { ok: true, filePath, repos };
|
|
54254
54043
|
}
|
|
54255
54044
|
|
|
54256
|
-
// ../bridge/src/prompt-
|
|
54045
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
54257
54046
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
54258
54047
|
if (next.bridgeServerState !== "requeued_with_revert") return true;
|
|
54259
54048
|
const sid = next.sessionId;
|
|
@@ -54262,7 +54051,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
54262
54051
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
54263
54052
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
54264
54053
|
try {
|
|
54265
|
-
await
|
|
54054
|
+
await fs54.promises.access(file2, fs54.constants.F_OK);
|
|
54266
54055
|
} catch {
|
|
54267
54056
|
deps.log(
|
|
54268
54057
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -54276,49 +54065,120 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
54276
54065
|
return res.ok;
|
|
54277
54066
|
}
|
|
54278
54067
|
|
|
54279
|
-
// ../bridge/src/prompt-
|
|
54280
|
-
async function
|
|
54281
|
-
const report = {};
|
|
54068
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
54069
|
+
async function executePromptQueueActions(actions, deps) {
|
|
54282
54070
|
const started = /* @__PURE__ */ new Set();
|
|
54283
|
-
|
|
54284
|
-
|
|
54285
|
-
if (
|
|
54286
|
-
|
|
54287
|
-
|
|
54288
|
-
|
|
54289
|
-
|
|
54290
|
-
await
|
|
54291
|
-
sendPromptQueueClientReport(deps.getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
54071
|
+
const report = {};
|
|
54072
|
+
for (const action of actions) {
|
|
54073
|
+
if (action.type === "cancel_run") {
|
|
54074
|
+
if (getRunIdQueueKey(action.turnId) !== action.queueKey) continue;
|
|
54075
|
+
deps.log(`[Queue] Cancellation request received for turn ${action.turnId.slice(0, 8)}\u2026`);
|
|
54076
|
+
if (await deps.acpManager.cancelRun(action.turnId)) continue;
|
|
54077
|
+
deps.log(`[Queue] No local ACP run remains for ${action.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
54078
|
+
await finalizePromptTurnOnBridge(deps.getWs, action.turnId, false, { terminalCliState: "cancelled" });
|
|
54292
54079
|
continue;
|
|
54293
54080
|
}
|
|
54294
|
-
|
|
54295
|
-
|
|
54296
|
-
|
|
54297
|
-
|
|
54298
|
-
|
|
54081
|
+
if (action.type === "finalize_stale") {
|
|
54082
|
+
await applyCliState(action.queueKey, action.turnId, action.cliState);
|
|
54083
|
+
deleteRunIdQueueKey(action.turnId);
|
|
54084
|
+
report[action.queueKey] = [{ turnId: action.turnId, cliState: action.cliState }];
|
|
54085
|
+
continue;
|
|
54086
|
+
}
|
|
54087
|
+
if (action.type === "start_run") {
|
|
54088
|
+
const ok = await markTurnRunning(action.queueKey, action.turn, deps);
|
|
54089
|
+
if (!ok) {
|
|
54090
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "failed" }];
|
|
54091
|
+
continue;
|
|
54092
|
+
}
|
|
54093
|
+
started.add(action.turn.turnId);
|
|
54094
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "running" }];
|
|
54095
|
+
}
|
|
54299
54096
|
await yieldToEventLoop();
|
|
54300
54097
|
}
|
|
54301
54098
|
if (Object.keys(report).length) sendPromptQueueClientReport(deps.getWs(), report);
|
|
54099
|
+
for (const runId of started) {
|
|
54100
|
+
const queueKey = getRunIdQueueKey(runId);
|
|
54101
|
+
if (!queueKey) continue;
|
|
54102
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54103
|
+
const turn = file2?.turns.find((t) => t.turnId === runId);
|
|
54104
|
+
if (turn) dispatchLocalPrompt(turn, deps);
|
|
54105
|
+
await yieldToEventLoop();
|
|
54106
|
+
}
|
|
54302
54107
|
return started;
|
|
54303
54108
|
}
|
|
54109
|
+
async function markTurnRunning(queueKey, turn, deps) {
|
|
54110
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54111
|
+
if (!file2) return false;
|
|
54112
|
+
const row = file2.turns.find((t) => t.turnId === turn.turnId);
|
|
54113
|
+
if (!row) return false;
|
|
54114
|
+
if (!await runLocalRevertBeforeQueuedPrompt(row, deps)) {
|
|
54115
|
+
row.lastCliState = "failed";
|
|
54116
|
+
await writePersistedQueue(file2);
|
|
54117
|
+
return false;
|
|
54118
|
+
}
|
|
54119
|
+
row.lastCliState = "running";
|
|
54120
|
+
await writePersistedQueue(file2);
|
|
54121
|
+
setRunIdQueueKey(row.turnId, queueKey);
|
|
54122
|
+
return true;
|
|
54123
|
+
}
|
|
54124
|
+
async function applyCliState(queueKey, turnId, cliState) {
|
|
54125
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
54126
|
+
if (!file2) return;
|
|
54127
|
+
const turn = file2.turns.find((t) => t.turnId === turnId);
|
|
54128
|
+
if (!turn) return;
|
|
54129
|
+
turn.lastCliState = cliState;
|
|
54130
|
+
await writePersistedQueue(file2);
|
|
54131
|
+
}
|
|
54304
54132
|
|
|
54305
|
-
// ../bridge/src/prompt-
|
|
54133
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
54306
54134
|
var SLOW_QUEUE_SYNC_MS = 2e3;
|
|
54135
|
+
async function persistAndReconcileQueue(queueKey, serverTurns, deps) {
|
|
54136
|
+
const prev = await readPersistedQueue(queueKey);
|
|
54137
|
+
const merged = mergeServerSnapshotWithLocal(queueKey, serverTurns, prev);
|
|
54138
|
+
const liveCheck = (runId) => deps.acpManager.isRegisteredRun(runId);
|
|
54139
|
+
const actions = reconcileQueueActions(queueKey, merged.turns, liveCheck);
|
|
54140
|
+
merged.turns = applyStaleRunningNormalization(merged.turns, liveCheck);
|
|
54141
|
+
await writePersistedQueue(merged);
|
|
54142
|
+
syncRunningTurnQueueKeys(merged.turns, queueKey);
|
|
54143
|
+
return actions;
|
|
54144
|
+
}
|
|
54307
54145
|
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
54308
54146
|
const raw = msg.queues;
|
|
54309
54147
|
if (!raw || typeof raw !== "object") return;
|
|
54310
54148
|
const startedAt = Date.now();
|
|
54311
54149
|
const entries = promptQueueSnapshotEntries(raw);
|
|
54312
|
-
|
|
54313
|
-
|
|
54314
|
-
|
|
54315
|
-
|
|
54150
|
+
const allActions = [];
|
|
54151
|
+
for (const [queueKey, serverTurns] of entries) {
|
|
54152
|
+
allActions.push(...await persistAndReconcileQueue(queueKey, serverTurns, deps));
|
|
54153
|
+
await yieldToEventLoop();
|
|
54154
|
+
}
|
|
54155
|
+
await executePromptQueueActions(allActions, deps);
|
|
54316
54156
|
const durationMs = Date.now() - startedAt;
|
|
54317
54157
|
if (durationMs >= SLOW_QUEUE_SYNC_MS) {
|
|
54318
54158
|
deps.log(`[Queue] Queue state sync and dispatch took ${durationMs}ms.`);
|
|
54319
54159
|
}
|
|
54320
54160
|
}
|
|
54321
54161
|
|
|
54162
|
+
// ../bridge/src/prompt-queue/runner/serial-prompt-queue-work.ts
|
|
54163
|
+
var running = false;
|
|
54164
|
+
var latestWork = null;
|
|
54165
|
+
async function drain() {
|
|
54166
|
+
while (latestWork) {
|
|
54167
|
+
const work = latestWork;
|
|
54168
|
+
latestWork = null;
|
|
54169
|
+
await work();
|
|
54170
|
+
}
|
|
54171
|
+
}
|
|
54172
|
+
function enqueueLatestPromptQueueStateWork(work) {
|
|
54173
|
+
latestWork = work;
|
|
54174
|
+
if (running) return;
|
|
54175
|
+
running = true;
|
|
54176
|
+
void drain().finally(() => {
|
|
54177
|
+
running = false;
|
|
54178
|
+
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
54179
|
+
});
|
|
54180
|
+
}
|
|
54181
|
+
|
|
54322
54182
|
// ../bridge/src/agents/acp/from-bridge/pending-prompt-results.ts
|
|
54323
54183
|
var pending = [];
|
|
54324
54184
|
function enqueuePendingPromptResult(message) {
|
|
@@ -54638,26 +54498,6 @@ var handlePromptMessage = (msg, deps) => {
|
|
|
54638
54498
|
handleBridgePrompt(msg, deps);
|
|
54639
54499
|
};
|
|
54640
54500
|
|
|
54641
|
-
// ../bridge/src/prompt-turn-queue/runner/serial-prompt-queue-work.ts
|
|
54642
|
-
var running = false;
|
|
54643
|
-
var latestWork = null;
|
|
54644
|
-
async function drain() {
|
|
54645
|
-
while (latestWork) {
|
|
54646
|
-
const work = latestWork;
|
|
54647
|
-
latestWork = null;
|
|
54648
|
-
await work();
|
|
54649
|
-
}
|
|
54650
|
-
}
|
|
54651
|
-
function enqueueLatestPromptQueueStateWork(work) {
|
|
54652
|
-
latestWork = work;
|
|
54653
|
-
if (running) return;
|
|
54654
|
-
running = true;
|
|
54655
|
-
void drain().finally(() => {
|
|
54656
|
-
running = false;
|
|
54657
|
-
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
54658
|
-
});
|
|
54659
|
-
}
|
|
54660
|
-
|
|
54661
54501
|
// ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
|
|
54662
54502
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
54663
54503
|
enqueueLatestPromptQueueStateWork(async () => {
|
|
@@ -54920,7 +54760,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
54920
54760
|
};
|
|
54921
54761
|
|
|
54922
54762
|
// ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
|
|
54923
|
-
import * as
|
|
54763
|
+
import * as fs55 from "node:fs";
|
|
54924
54764
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
54925
54765
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
54926
54766
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -54933,7 +54773,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
54933
54773
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
54934
54774
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
54935
54775
|
try {
|
|
54936
|
-
await
|
|
54776
|
+
await fs55.promises.access(file2, fs55.constants.F_OK);
|
|
54937
54777
|
} catch {
|
|
54938
54778
|
sendWsMessage(s, {
|
|
54939
54779
|
type: "revert_turn_snapshot_result",
|
|
@@ -55047,13 +54887,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
55047
54887
|
|
|
55048
54888
|
// ../bridge/src/files/handle-file-browser-search.ts
|
|
55049
54889
|
init_yield_to_event_loop();
|
|
55050
|
-
import
|
|
54890
|
+
import path78 from "node:path";
|
|
55051
54891
|
var SEARCH_LIMIT = 100;
|
|
55052
54892
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
55053
54893
|
void (async () => {
|
|
55054
54894
|
await yieldToEventLoop();
|
|
55055
54895
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
55056
|
-
const sessionParentPath =
|
|
54896
|
+
const sessionParentPath = path78.resolve(
|
|
55057
54897
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
55058
54898
|
);
|
|
55059
54899
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -55151,7 +54991,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
55151
54991
|
}
|
|
55152
54992
|
|
|
55153
54993
|
// ../bridge/src/git/bridge-git-context.ts
|
|
55154
|
-
import * as
|
|
54994
|
+
import * as path79 from "node:path";
|
|
55155
54995
|
init_yield_to_event_loop();
|
|
55156
54996
|
|
|
55157
54997
|
// ../bridge/src/git/branches/get-current-branch.ts
|
|
@@ -55219,12 +55059,12 @@ function listPendingCheckouts() {
|
|
|
55219
55059
|
// ../bridge/src/git/bridge-git-context.ts
|
|
55220
55060
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
55221
55061
|
if (relPath === "." || relPath === "") {
|
|
55222
|
-
return
|
|
55062
|
+
return path79.basename(path79.resolve(bridgeRoot)) || "repo";
|
|
55223
55063
|
}
|
|
55224
|
-
return
|
|
55064
|
+
return path79.basename(relPath) || relPath;
|
|
55225
55065
|
}
|
|
55226
55066
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
55227
|
-
const root =
|
|
55067
|
+
const root = path79.resolve(bridgeRoot);
|
|
55228
55068
|
if (await isGitRepoDirectory(root)) {
|
|
55229
55069
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
55230
55070
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -55232,19 +55072,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
55232
55072
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
55233
55073
|
const byPath = /* @__PURE__ */ new Map();
|
|
55234
55074
|
for (const repo of [...deep, ...shallow]) {
|
|
55235
|
-
byPath.set(
|
|
55075
|
+
byPath.set(path79.resolve(repo.absolutePath), repo);
|
|
55236
55076
|
}
|
|
55237
55077
|
return [...byPath.values()];
|
|
55238
55078
|
}
|
|
55239
55079
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
55240
|
-
const bridgeResolved =
|
|
55080
|
+
const bridgeResolved = path79.resolve(bridgeRoot);
|
|
55241
55081
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
55242
55082
|
const rows = [];
|
|
55243
55083
|
for (let i = 0; i < repos.length; i++) {
|
|
55244
55084
|
if (i > 0) await yieldToEventLoop();
|
|
55245
55085
|
const repo = repos[i];
|
|
55246
|
-
let rel =
|
|
55247
|
-
if (rel.startsWith("..") ||
|
|
55086
|
+
let rel = path79.relative(bridgeResolved, repo.absolutePath);
|
|
55087
|
+
if (rel.startsWith("..") || path79.isAbsolute(rel)) continue;
|
|
55248
55088
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
55249
55089
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
55250
55090
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -55275,11 +55115,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
55275
55115
|
return rows;
|
|
55276
55116
|
}
|
|
55277
55117
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
55278
|
-
const bridgeResolved =
|
|
55118
|
+
const bridgeResolved = path79.resolve(bridgeRoot);
|
|
55279
55119
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
55280
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
55281
|
-
const resolved =
|
|
55282
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
55120
|
+
const repoPath = rel === "" ? bridgeResolved : path79.join(bridgeResolved, rel);
|
|
55121
|
+
const resolved = path79.resolve(repoPath);
|
|
55122
|
+
if (!resolved.startsWith(bridgeResolved + path79.sep) && resolved !== bridgeResolved) {
|
|
55283
55123
|
return [];
|
|
55284
55124
|
}
|
|
55285
55125
|
return listRepoBranchRefs(resolved);
|
|
@@ -55329,8 +55169,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
55329
55169
|
}
|
|
55330
55170
|
|
|
55331
55171
|
// ../bridge/src/git/checkout/bridge-git-checkout.ts
|
|
55332
|
-
import * as
|
|
55333
|
-
import * as
|
|
55172
|
+
import * as fs57 from "node:fs/promises";
|
|
55173
|
+
import * as path81 from "node:path";
|
|
55334
55174
|
|
|
55335
55175
|
// ../bridge/src/git/checkout/normalize-clone-url.ts
|
|
55336
55176
|
function normalizeCloneUrl(url2) {
|
|
@@ -55350,12 +55190,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
55350
55190
|
}
|
|
55351
55191
|
|
|
55352
55192
|
// ../bridge/src/git/checkout/resolve-checkout-target.ts
|
|
55353
|
-
import * as
|
|
55354
|
-
import * as
|
|
55193
|
+
import * as fs56 from "node:fs/promises";
|
|
55194
|
+
import * as path80 from "node:path";
|
|
55355
55195
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
55356
55196
|
async function pathExists(p) {
|
|
55357
55197
|
try {
|
|
55358
|
-
await
|
|
55198
|
+
await fs56.access(p);
|
|
55359
55199
|
return true;
|
|
55360
55200
|
} catch {
|
|
55361
55201
|
return false;
|
|
@@ -55367,7 +55207,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
55367
55207
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
55368
55208
|
throw new Error("Bridge root is already a git repository");
|
|
55369
55209
|
}
|
|
55370
|
-
const entries = await
|
|
55210
|
+
const entries = await fs56.readdir(bridgeRoot).catch(() => []);
|
|
55371
55211
|
if (entries.length > 0) {
|
|
55372
55212
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
55373
55213
|
}
|
|
@@ -55380,8 +55220,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
55380
55220
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
55381
55221
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
55382
55222
|
}
|
|
55383
|
-
const targetDir =
|
|
55384
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
55223
|
+
const targetDir = path80.resolve(bridgeRoot, folder);
|
|
55224
|
+
if (!targetDir.startsWith(bridgeRoot + path80.sep)) {
|
|
55385
55225
|
throw new Error("Invalid folderName");
|
|
55386
55226
|
}
|
|
55387
55227
|
if (await pathExists(targetDir)) {
|
|
@@ -55400,10 +55240,10 @@ async function bridgeGitCheckout(params) {
|
|
|
55400
55240
|
});
|
|
55401
55241
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
55402
55242
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
55403
|
-
const parent =
|
|
55404
|
-
await
|
|
55243
|
+
const parent = path81.dirname(targetDir);
|
|
55244
|
+
await fs57.mkdir(parent, { recursive: true });
|
|
55405
55245
|
if (relPath !== ".") {
|
|
55406
|
-
await
|
|
55246
|
+
await fs57.mkdir(targetDir, { recursive: true });
|
|
55407
55247
|
}
|
|
55408
55248
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
55409
55249
|
try {
|
|
@@ -55414,7 +55254,7 @@ async function bridgeGitCheckout(params) {
|
|
|
55414
55254
|
return { relPath, folderName };
|
|
55415
55255
|
} catch (e) {
|
|
55416
55256
|
if (relPath !== ".") {
|
|
55417
|
-
await
|
|
55257
|
+
await fs57.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
55418
55258
|
}
|
|
55419
55259
|
const msg = e instanceof Error ? e.message : String(e);
|
|
55420
55260
|
throw new Error(
|
|
@@ -55596,6 +55436,7 @@ function createMainBridgeCloseHandler(params, connect) {
|
|
|
55596
55436
|
const { state, logFn, bridgeHeartbeat } = params;
|
|
55597
55437
|
return (code, reason, closedWs) => {
|
|
55598
55438
|
if (state.currentWs !== closedWs) return;
|
|
55439
|
+
cancelInFlightAgentCapabilityWarmup();
|
|
55599
55440
|
bridgeHeartbeat?.stop();
|
|
55600
55441
|
try {
|
|
55601
55442
|
state.currentWs = null;
|
|
@@ -55723,20 +55564,8 @@ function createMainBridgeWebSocketLifecycle(params) {
|
|
|
55723
55564
|
}
|
|
55724
55565
|
}
|
|
55725
55566
|
bridgeHeartbeat?.stop();
|
|
55726
|
-
|
|
55727
|
-
|
|
55728
|
-
prev.removeAllListeners();
|
|
55729
|
-
prev.once("error", () => {
|
|
55730
|
-
});
|
|
55731
|
-
prev.once("close", () => {
|
|
55732
|
-
prev.removeAllListeners();
|
|
55733
|
-
});
|
|
55734
|
-
try {
|
|
55735
|
-
prev.close();
|
|
55736
|
-
} catch {
|
|
55737
|
-
}
|
|
55738
|
-
state.currentWs = null;
|
|
55739
|
-
}
|
|
55567
|
+
disposePreviousBridgeSocket(state.currentWs);
|
|
55568
|
+
state.currentWs = null;
|
|
55740
55569
|
try {
|
|
55741
55570
|
const url2 = plugin.transport.resolveControlPlaneUrl({
|
|
55742
55571
|
workspaceId,
|
|
@@ -56051,12 +55880,12 @@ function startStreamingProxy(ws, log2, pr) {
|
|
|
56051
55880
|
}
|
|
56052
55881
|
|
|
56053
55882
|
// src/config.ts
|
|
56054
|
-
import
|
|
56055
|
-
import
|
|
56056
|
-
import
|
|
55883
|
+
import fs58 from "node:fs";
|
|
55884
|
+
import path82 from "node:path";
|
|
55885
|
+
import os8 from "node:os";
|
|
56057
55886
|
function getConfigPath() {
|
|
56058
|
-
const dir =
|
|
56059
|
-
return
|
|
55887
|
+
const dir = path82.join(os8.homedir(), ".buildautomaton");
|
|
55888
|
+
return path82.join(dir, "config.json");
|
|
56060
55889
|
}
|
|
56061
55890
|
function normalizeApiUrl(url2) {
|
|
56062
55891
|
return url2.replace(/\/$/, "");
|
|
@@ -56064,7 +55893,7 @@ function normalizeApiUrl(url2) {
|
|
|
56064
55893
|
function readRawConfig() {
|
|
56065
55894
|
try {
|
|
56066
55895
|
const p = getConfigPath();
|
|
56067
|
-
const raw =
|
|
55896
|
+
const raw = fs58.readFileSync(p, "utf8");
|
|
56068
55897
|
return JSON.parse(raw);
|
|
56069
55898
|
} catch {
|
|
56070
55899
|
return null;
|
|
@@ -56092,14 +55921,14 @@ function readConfigForApi(apiUrl) {
|
|
|
56092
55921
|
}
|
|
56093
55922
|
function writeConfigForApi(apiUrl, auth) {
|
|
56094
55923
|
const p = getConfigPath();
|
|
56095
|
-
const dir =
|
|
55924
|
+
const dir = path82.dirname(p);
|
|
56096
55925
|
const key = normalizeApiUrl(apiUrl);
|
|
56097
55926
|
const prev = readRawConfig() ?? {};
|
|
56098
55927
|
const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
|
|
56099
55928
|
const next = { ...prev, servers };
|
|
56100
55929
|
try {
|
|
56101
|
-
if (!
|
|
56102
|
-
|
|
55930
|
+
if (!fs58.existsSync(dir)) fs58.mkdirSync(dir, { recursive: true });
|
|
55931
|
+
fs58.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
56103
55932
|
} catch (e) {
|
|
56104
55933
|
console.error("Could not save authentication config:", e);
|
|
56105
55934
|
}
|
|
@@ -56108,22 +55937,22 @@ function clearConfigForApi(apiUrl) {
|
|
|
56108
55937
|
const key = normalizeApiUrl(apiUrl);
|
|
56109
55938
|
try {
|
|
56110
55939
|
const p = getConfigPath();
|
|
56111
|
-
if (!
|
|
55940
|
+
if (!fs58.existsSync(p)) return;
|
|
56112
55941
|
const prev = readRawConfig();
|
|
56113
55942
|
if (!prev) return;
|
|
56114
55943
|
const servers = { ...prev.servers ?? {} };
|
|
56115
55944
|
delete servers[key];
|
|
56116
55945
|
const next = { ...prev, servers };
|
|
56117
55946
|
if (Object.keys(servers).length === 0 && !prev.workspaceId) {
|
|
56118
|
-
|
|
55947
|
+
fs58.unlinkSync(p);
|
|
56119
55948
|
return;
|
|
56120
55949
|
}
|
|
56121
55950
|
if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
|
|
56122
55951
|
const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
|
|
56123
|
-
|
|
55952
|
+
fs58.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
|
|
56124
55953
|
return;
|
|
56125
55954
|
}
|
|
56126
|
-
|
|
55955
|
+
fs58.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
56127
55956
|
} catch {
|
|
56128
55957
|
}
|
|
56129
55958
|
}
|
|
@@ -56131,30 +55960,30 @@ function clearConfigForApi(apiUrl) {
|
|
|
56131
55960
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
56132
55961
|
import process8 from "node:process";
|
|
56133
55962
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
56134
|
-
import
|
|
55963
|
+
import path83 from "node:path";
|
|
56135
55964
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
56136
55965
|
import { promisify as promisify8 } from "node:util";
|
|
56137
55966
|
import childProcess from "node:child_process";
|
|
56138
|
-
import
|
|
55967
|
+
import fs63, { constants as fsConstants2 } from "node:fs/promises";
|
|
56139
55968
|
|
|
56140
55969
|
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
56141
55970
|
import process4 from "node:process";
|
|
56142
|
-
import
|
|
55971
|
+
import fs62, { constants as fsConstants } from "node:fs/promises";
|
|
56143
55972
|
|
|
56144
55973
|
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
56145
55974
|
import process3 from "node:process";
|
|
56146
|
-
import
|
|
56147
|
-
import
|
|
55975
|
+
import os9 from "node:os";
|
|
55976
|
+
import fs61 from "node:fs";
|
|
56148
55977
|
|
|
56149
55978
|
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
56150
|
-
import
|
|
55979
|
+
import fs60 from "node:fs";
|
|
56151
55980
|
|
|
56152
55981
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
56153
|
-
import
|
|
55982
|
+
import fs59 from "node:fs";
|
|
56154
55983
|
var isDockerCached;
|
|
56155
55984
|
function hasDockerEnv() {
|
|
56156
55985
|
try {
|
|
56157
|
-
|
|
55986
|
+
fs59.statSync("/.dockerenv");
|
|
56158
55987
|
return true;
|
|
56159
55988
|
} catch {
|
|
56160
55989
|
return false;
|
|
@@ -56162,7 +55991,7 @@ function hasDockerEnv() {
|
|
|
56162
55991
|
}
|
|
56163
55992
|
function hasDockerCGroup() {
|
|
56164
55993
|
try {
|
|
56165
|
-
return
|
|
55994
|
+
return fs59.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
56166
55995
|
} catch {
|
|
56167
55996
|
return false;
|
|
56168
55997
|
}
|
|
@@ -56178,7 +56007,7 @@ function isDocker() {
|
|
|
56178
56007
|
var cachedResult;
|
|
56179
56008
|
var hasContainerEnv = () => {
|
|
56180
56009
|
try {
|
|
56181
|
-
|
|
56010
|
+
fs60.statSync("/run/.containerenv");
|
|
56182
56011
|
return true;
|
|
56183
56012
|
} catch {
|
|
56184
56013
|
return false;
|
|
@@ -56196,19 +56025,19 @@ var isWsl = () => {
|
|
|
56196
56025
|
if (process3.platform !== "linux") {
|
|
56197
56026
|
return false;
|
|
56198
56027
|
}
|
|
56199
|
-
if (
|
|
56028
|
+
if (os9.release().toLowerCase().includes("microsoft")) {
|
|
56200
56029
|
if (isInsideContainer()) {
|
|
56201
56030
|
return false;
|
|
56202
56031
|
}
|
|
56203
56032
|
return true;
|
|
56204
56033
|
}
|
|
56205
56034
|
try {
|
|
56206
|
-
if (
|
|
56035
|
+
if (fs61.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
56207
56036
|
return !isInsideContainer();
|
|
56208
56037
|
}
|
|
56209
56038
|
} catch {
|
|
56210
56039
|
}
|
|
56211
|
-
if (
|
|
56040
|
+
if (fs61.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs61.existsSync("/run/WSL")) {
|
|
56212
56041
|
return !isInsideContainer();
|
|
56213
56042
|
}
|
|
56214
56043
|
return false;
|
|
@@ -56226,14 +56055,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
56226
56055
|
const configFilePath2 = "/etc/wsl.conf";
|
|
56227
56056
|
let isConfigFileExists = false;
|
|
56228
56057
|
try {
|
|
56229
|
-
await
|
|
56058
|
+
await fs62.access(configFilePath2, fsConstants.F_OK);
|
|
56230
56059
|
isConfigFileExists = true;
|
|
56231
56060
|
} catch {
|
|
56232
56061
|
}
|
|
56233
56062
|
if (!isConfigFileExists) {
|
|
56234
56063
|
return defaultMountPoint;
|
|
56235
56064
|
}
|
|
56236
|
-
const configContent = await
|
|
56065
|
+
const configContent = await fs62.readFile(configFilePath2, { encoding: "utf8" });
|
|
56237
56066
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
56238
56067
|
if (!configMountPoint) {
|
|
56239
56068
|
return defaultMountPoint;
|
|
@@ -56298,7 +56127,7 @@ async function defaultBrowserId() {
|
|
|
56298
56127
|
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
56299
56128
|
import process6 from "node:process";
|
|
56300
56129
|
import { promisify as promisify5 } from "node:util";
|
|
56301
|
-
import { execFile as execFile4, execFileSync as
|
|
56130
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
56302
56131
|
var execFileAsync4 = promisify5(execFile4);
|
|
56303
56132
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
56304
56133
|
if (process6.platform !== "darwin") {
|
|
@@ -56387,8 +56216,8 @@ async function defaultBrowser2() {
|
|
|
56387
56216
|
|
|
56388
56217
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
56389
56218
|
var execFile7 = promisify8(childProcess.execFile);
|
|
56390
|
-
var __dirname =
|
|
56391
|
-
var localXdgOpenPath =
|
|
56219
|
+
var __dirname = path83.dirname(fileURLToPath7(import.meta.url));
|
|
56220
|
+
var localXdgOpenPath = path83.join(__dirname, "xdg-open");
|
|
56392
56221
|
var { platform, arch } = process8;
|
|
56393
56222
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
56394
56223
|
const powershellPath = await powerShellPath();
|
|
@@ -56538,7 +56367,7 @@ var baseOpen = async (options) => {
|
|
|
56538
56367
|
const isBundled = !__dirname || __dirname === "/";
|
|
56539
56368
|
let exeLocalXdgOpen = false;
|
|
56540
56369
|
try {
|
|
56541
|
-
await
|
|
56370
|
+
await fs63.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
56542
56371
|
exeLocalXdgOpen = true;
|
|
56543
56372
|
} catch {
|
|
56544
56373
|
}
|
|
@@ -57460,34 +57289,10 @@ function enrichIntegrationContentPromptForAgent(params) {
|
|
|
57460
57289
|
return injectIntegrationContentAgentPromptNote(params.agentPromptText, params.sessionId);
|
|
57461
57290
|
}
|
|
57462
57291
|
|
|
57463
|
-
// src/agents/planning/enrich-planning-session-prompt-for-agent.ts
|
|
57464
|
-
async function enrichPlanningSessionPromptForAgent(params) {
|
|
57465
|
-
const meta3 = await fetchCloudSessionMeta({
|
|
57466
|
-
sessionId: params.sessionId,
|
|
57467
|
-
cloudApiBaseUrl: params.cloudApiBaseUrl,
|
|
57468
|
-
getCloudAccessToken: params.getCloudAccessToken
|
|
57469
|
-
});
|
|
57470
|
-
if (!meta3.ok) return { promptText: params.promptText, isPlanningSession: false };
|
|
57471
|
-
const sessionKind = parseSessionKind(meta3.data.sessionKind);
|
|
57472
|
-
if (sessionKind !== "planning") return { promptText: params.promptText, isPlanningSession: false };
|
|
57473
|
-
const todos = Array.isArray(meta3.data.planningTodos) ? meta3.data.planningTodos : [];
|
|
57474
|
-
if (params.isNewSession || todos.length === 0) {
|
|
57475
|
-
return {
|
|
57476
|
-
promptText: buildPlanningSessionAgentPrompt(params.promptText),
|
|
57477
|
-
isPlanningSession: true
|
|
57478
|
-
};
|
|
57479
|
-
}
|
|
57480
|
-
return {
|
|
57481
|
-
promptText: buildPlanningSessionFollowUpAgentPrompt(params.promptText, todos),
|
|
57482
|
-
isPlanningSession: true
|
|
57483
|
-
};
|
|
57484
|
-
}
|
|
57485
|
-
|
|
57486
57292
|
// src/plugin/prepare-ba-agent-prompt.ts
|
|
57487
57293
|
async function prepareBuildAutomatonAgentPrompt(params) {
|
|
57488
|
-
const { promptText, sessionId,
|
|
57294
|
+
const { promptText, sessionId, cloudApiBaseUrl, getCloudAccessToken } = params;
|
|
57489
57295
|
let agentPromptText = promptText;
|
|
57490
|
-
let isPlanningSession = false;
|
|
57491
57296
|
if (sessionId) {
|
|
57492
57297
|
agentPromptText = await enrichForkedSessionPromptForAgent({
|
|
57493
57298
|
sessionId,
|
|
@@ -57495,88 +57300,15 @@ async function prepareBuildAutomatonAgentPrompt(params) {
|
|
|
57495
57300
|
cloudApiBaseUrl,
|
|
57496
57301
|
getCloudAccessToken
|
|
57497
57302
|
});
|
|
57498
|
-
const planningEnriched = await enrichPlanningSessionPromptForAgent({
|
|
57499
|
-
sessionId,
|
|
57500
|
-
promptText: agentPromptText,
|
|
57501
|
-
isNewSession,
|
|
57502
|
-
cloudApiBaseUrl,
|
|
57503
|
-
getCloudAccessToken
|
|
57504
|
-
});
|
|
57505
|
-
agentPromptText = planningEnriched.promptText;
|
|
57506
|
-
isPlanningSession = planningEnriched.isPlanningSession;
|
|
57507
|
-
}
|
|
57508
|
-
if (sessionId) {
|
|
57509
57303
|
agentPromptText = enrichIntegrationContentPromptForAgent({
|
|
57510
57304
|
sessionId,
|
|
57511
57305
|
originalPromptText: promptText,
|
|
57512
57306
|
agentPromptText
|
|
57513
57307
|
});
|
|
57514
57308
|
}
|
|
57515
|
-
|
|
57516
|
-
|
|
57517
|
-
|
|
57518
|
-
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
57519
|
-
var PLANNING_TODO_SUBMIT_TIMEOUT_MS = 3e3;
|
|
57520
|
-
async function submitPlanningTodosForTurn(params) {
|
|
57521
|
-
const token = params.getCloudAccessToken();
|
|
57522
|
-
if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
|
|
57523
|
-
const base = params.cloudApiBaseUrl.replace(/\/$/, "");
|
|
57524
|
-
const url2 = `${base}/internal/sessions/todos/submit`;
|
|
57525
|
-
let res;
|
|
57526
|
-
try {
|
|
57527
|
-
res = await fetch(url2, {
|
|
57528
|
-
method: "POST",
|
|
57529
|
-
signal: AbortSignal.timeout(PLANNING_TODO_SUBMIT_TIMEOUT_MS),
|
|
57530
|
-
headers: {
|
|
57531
|
-
Authorization: `Bearer ${token}`,
|
|
57532
|
-
"Content-Type": "application/json"
|
|
57533
|
-
},
|
|
57534
|
-
body: JSON.stringify({
|
|
57535
|
-
sessionId: params.sessionId,
|
|
57536
|
-
turnId: params.turnId,
|
|
57537
|
-
items: params.items
|
|
57538
|
-
})
|
|
57539
|
-
});
|
|
57540
|
-
} catch (error51) {
|
|
57541
|
-
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
57542
|
-
}
|
|
57543
|
-
if (!res.ok) {
|
|
57544
|
-
const body = await res.json().catch(() => null);
|
|
57545
|
-
return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
|
|
57546
|
-
}
|
|
57547
|
-
return { ok: true };
|
|
57548
|
-
}
|
|
57549
|
-
|
|
57550
|
-
// src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
|
|
57551
|
-
async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
|
|
57552
|
-
const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
|
|
57553
|
-
const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
|
|
57554
|
-
const outputFromResult = typeof output === "string" ? output : "";
|
|
57555
|
-
const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
|
|
57556
|
-
if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
|
|
57557
|
-
return { submitted: false, suppressOutput: false };
|
|
57558
|
-
}
|
|
57559
|
-
if (!cloudApiBaseUrl || !getCloudAccessToken) {
|
|
57560
|
-
return { submitted: false, suppressOutput: false };
|
|
57561
|
-
}
|
|
57562
|
-
const items = parsePlanningTodoAgentJson(outputStr);
|
|
57563
|
-
if (items.length === 0) {
|
|
57564
|
-
return { submitted: false, suppressOutput: false };
|
|
57565
|
-
}
|
|
57566
|
-
const result = await submitPlanningTodosForTurn({
|
|
57567
|
-
sessionId,
|
|
57568
|
-
turnId: runId,
|
|
57569
|
-
items,
|
|
57570
|
-
cloudApiBaseUrl,
|
|
57571
|
-
getCloudAccessToken
|
|
57572
|
-
});
|
|
57573
|
-
if (!result.ok) {
|
|
57574
|
-
log2(`[Agent] Planning todo submit failed: ${result.error}`);
|
|
57575
|
-
return { submitted: false, suppressOutput: false };
|
|
57576
|
-
}
|
|
57577
|
-
if (runId) consumePlanningSessionTurnOutput(runId);
|
|
57578
|
-
log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
|
|
57579
|
-
return { submitted: true, suppressOutput: true };
|
|
57309
|
+
void params.runId;
|
|
57310
|
+
void params.isNewSession;
|
|
57311
|
+
return { agentPromptText, isPlanningSession: false };
|
|
57580
57312
|
}
|
|
57581
57313
|
|
|
57582
57314
|
// src/e2e-certificates/open-import-url.ts
|
|
@@ -57935,11 +57667,6 @@ function createBuildAutomatonPlugin(options) {
|
|
|
57935
57667
|
cloudApiBaseUrl: apiUrl,
|
|
57936
57668
|
getCloudAccessToken: getAccessToken
|
|
57937
57669
|
}),
|
|
57938
|
-
maybeSubmitPlanningTodos: (params) => maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
57939
|
-
...params,
|
|
57940
|
-
cloudApiBaseUrl: apiUrl,
|
|
57941
|
-
getCloudAccessToken: getAccessToken
|
|
57942
|
-
}),
|
|
57943
57670
|
persistTokens: (tokens) => writeConfigForApi(apiUrl, {
|
|
57944
57671
|
workspaceId: tokens.workspaceId,
|
|
57945
57672
|
token: tokens.token,
|
|
@@ -57958,13 +57685,13 @@ function toTokens(auth) {
|
|
|
57958
57685
|
}
|
|
57959
57686
|
|
|
57960
57687
|
// src/cli/chdir-to-bridge-root.ts
|
|
57961
|
-
import * as
|
|
57962
|
-
import * as
|
|
57688
|
+
import * as fs64 from "node:fs";
|
|
57689
|
+
import * as path84 from "node:path";
|
|
57963
57690
|
function chdirToBridgeRoot(bridgeRootOpt) {
|
|
57964
57691
|
if (!bridgeRootOpt) return;
|
|
57965
|
-
const resolved =
|
|
57692
|
+
const resolved = path84.resolve(process.cwd(), bridgeRootOpt);
|
|
57966
57693
|
try {
|
|
57967
|
-
if (!
|
|
57694
|
+
if (!fs64.statSync(resolved).isDirectory()) {
|
|
57968
57695
|
console.error(`Bridge root is not a directory: ${resolved}`);
|
|
57969
57696
|
process.exit(1);
|
|
57970
57697
|
}
|
|
@@ -57998,7 +57725,7 @@ async function runCliAction(program2, opts) {
|
|
|
57998
57725
|
initBridgeRoot();
|
|
57999
57726
|
console.log(colorize(GOLDEN_YELLOW, `[Bridge] Using ${getBridgeRoot()} as the bridge root.`));
|
|
58000
57727
|
let worktreesRootPath;
|
|
58001
|
-
if (opts.worktreesRoot?.trim()) worktreesRootPath =
|
|
57728
|
+
if (opts.worktreesRoot?.trim()) worktreesRootPath = path85.resolve(opts.worktreesRoot.trim());
|
|
58002
57729
|
const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
|
|
58003
57730
|
if (e2eCertificates) {
|
|
58004
57731
|
const action = e2eCertificates.generated ? "Generated" : "Loaded";
|