@buildautomaton/cli 0.1.89 → 0.1.90
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 +925 -1374
- package/dist/cli.js.map +4 -4
- package/dist/index.js +781 -1236
- package/dist/index.js.map +4 -4
- package/dist/worker.js +6 -21
- package/dist/worker.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3666,7 +3666,6 @@ function normalizeResolvedPath(resolved) {
|
|
|
3666
3666
|
}
|
|
3667
3667
|
var init_normalize_resolved_path = __esm({
|
|
3668
3668
|
"../bridge/src/paths/normalize-resolved-path.ts"() {
|
|
3669
|
-
"use strict";
|
|
3670
3669
|
}
|
|
3671
3670
|
});
|
|
3672
3671
|
|
|
@@ -3691,7 +3690,7 @@ var require_tree_kill = __commonJS({
|
|
|
3691
3690
|
"../../node_modules/.pnpm/tree-kill@1.2.2/node_modules/tree-kill/index.js"(exports, module) {
|
|
3692
3691
|
"use strict";
|
|
3693
3692
|
var childProcess2 = __require("child_process");
|
|
3694
|
-
var
|
|
3693
|
+
var spawn11 = childProcess2.spawn;
|
|
3695
3694
|
var exec = childProcess2.exec;
|
|
3696
3695
|
module.exports = function(pid, signal, callback) {
|
|
3697
3696
|
if (typeof signal === "function" && callback === void 0) {
|
|
@@ -3716,7 +3715,7 @@ var require_tree_kill = __commonJS({
|
|
|
3716
3715
|
break;
|
|
3717
3716
|
case "darwin":
|
|
3718
3717
|
buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
|
|
3719
|
-
return
|
|
3718
|
+
return spawn11("pgrep", ["-P", parentPid]);
|
|
3720
3719
|
}, function() {
|
|
3721
3720
|
killAll(tree, signal, callback);
|
|
3722
3721
|
});
|
|
@@ -3728,7 +3727,7 @@ var require_tree_kill = __commonJS({
|
|
|
3728
3727
|
// break;
|
|
3729
3728
|
default:
|
|
3730
3729
|
buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
|
|
3731
|
-
return
|
|
3730
|
+
return spawn11("ps", ["-o", "pid", "--no-headers", "--ppid", parentPid]);
|
|
3732
3731
|
}, function() {
|
|
3733
3732
|
killAll(tree, signal, callback);
|
|
3734
3733
|
});
|
|
@@ -3796,7 +3795,7 @@ var require_tree_kill = __commonJS({
|
|
|
3796
3795
|
}
|
|
3797
3796
|
});
|
|
3798
3797
|
|
|
3799
|
-
// ../bridge/src/cli-log-level.ts
|
|
3798
|
+
// ../bridge/src/cli/cli-log-level.ts
|
|
3800
3799
|
function setCliLogVerbosity(level) {
|
|
3801
3800
|
verbosity = level;
|
|
3802
3801
|
}
|
|
@@ -3808,13 +3807,12 @@ function isCliTrace() {
|
|
|
3808
3807
|
}
|
|
3809
3808
|
var verbosity;
|
|
3810
3809
|
var init_cli_log_level = __esm({
|
|
3811
|
-
"../bridge/src/cli-log-level.ts"() {
|
|
3812
|
-
"use strict";
|
|
3810
|
+
"../bridge/src/cli/cli-log-level.ts"() {
|
|
3813
3811
|
verbosity = "info";
|
|
3814
3812
|
}
|
|
3815
3813
|
});
|
|
3816
3814
|
|
|
3817
|
-
// ../bridge/src/log.ts
|
|
3815
|
+
// ../bridge/src/cli/log.ts
|
|
3818
3816
|
function timestampPrefix() {
|
|
3819
3817
|
const time3 = (/* @__PURE__ */ new Date()).toISOString().slice(11, 19);
|
|
3820
3818
|
return `[${time3}]`;
|
|
@@ -3836,8 +3834,7 @@ function logTrace(line) {
|
|
|
3836
3834
|
console.log(`${timestampPrefix()} [trace] ${line}`);
|
|
3837
3835
|
}
|
|
3838
3836
|
var init_log = __esm({
|
|
3839
|
-
"../bridge/src/log.ts"() {
|
|
3840
|
-
"use strict";
|
|
3837
|
+
"../bridge/src/cli/log.ts"() {
|
|
3841
3838
|
init_cli_log_level();
|
|
3842
3839
|
}
|
|
3843
3840
|
});
|
|
@@ -4089,10 +4086,10 @@ function mergeDefs(...defs) {
|
|
|
4089
4086
|
function cloneDef(schema) {
|
|
4090
4087
|
return mergeDefs(schema._zod.def);
|
|
4091
4088
|
}
|
|
4092
|
-
function getElementAtPath(obj,
|
|
4093
|
-
if (!
|
|
4089
|
+
function getElementAtPath(obj, path85) {
|
|
4090
|
+
if (!path85)
|
|
4094
4091
|
return obj;
|
|
4095
|
-
return
|
|
4092
|
+
return path85.reduce((acc, key) => acc?.[key], obj);
|
|
4096
4093
|
}
|
|
4097
4094
|
function promiseAllObject(promisesObj) {
|
|
4098
4095
|
const keys = Object.keys(promisesObj);
|
|
@@ -4420,11 +4417,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
4420
4417
|
}
|
|
4421
4418
|
return false;
|
|
4422
4419
|
}
|
|
4423
|
-
function prefixIssues(
|
|
4420
|
+
function prefixIssues(path85, issues) {
|
|
4424
4421
|
return issues.map((iss) => {
|
|
4425
4422
|
var _a4;
|
|
4426
4423
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
4427
|
-
iss.path.unshift(
|
|
4424
|
+
iss.path.unshift(path85);
|
|
4428
4425
|
return iss;
|
|
4429
4426
|
});
|
|
4430
4427
|
}
|
|
@@ -4641,16 +4638,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4641
4638
|
}
|
|
4642
4639
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
4643
4640
|
const fieldErrors = { _errors: [] };
|
|
4644
|
-
const processError = (error52,
|
|
4641
|
+
const processError = (error52, path85 = []) => {
|
|
4645
4642
|
for (const issue2 of error52.issues) {
|
|
4646
4643
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4647
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4644
|
+
issue2.errors.map((issues) => processError({ issues }, [...path85, ...issue2.path]));
|
|
4648
4645
|
} else if (issue2.code === "invalid_key") {
|
|
4649
|
-
processError({ issues: issue2.issues }, [...
|
|
4646
|
+
processError({ issues: issue2.issues }, [...path85, ...issue2.path]);
|
|
4650
4647
|
} else if (issue2.code === "invalid_element") {
|
|
4651
|
-
processError({ issues: issue2.issues }, [...
|
|
4648
|
+
processError({ issues: issue2.issues }, [...path85, ...issue2.path]);
|
|
4652
4649
|
} else {
|
|
4653
|
-
const fullpath = [...
|
|
4650
|
+
const fullpath = [...path85, ...issue2.path];
|
|
4654
4651
|
if (fullpath.length === 0) {
|
|
4655
4652
|
fieldErrors._errors.push(mapper(issue2));
|
|
4656
4653
|
} else {
|
|
@@ -4677,17 +4674,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4677
4674
|
}
|
|
4678
4675
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
4679
4676
|
const result = { errors: [] };
|
|
4680
|
-
const processError = (error52,
|
|
4677
|
+
const processError = (error52, path85 = []) => {
|
|
4681
4678
|
var _a4, _b;
|
|
4682
4679
|
for (const issue2 of error52.issues) {
|
|
4683
4680
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4684
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4681
|
+
issue2.errors.map((issues) => processError({ issues }, [...path85, ...issue2.path]));
|
|
4685
4682
|
} else if (issue2.code === "invalid_key") {
|
|
4686
|
-
processError({ issues: issue2.issues }, [...
|
|
4683
|
+
processError({ issues: issue2.issues }, [...path85, ...issue2.path]);
|
|
4687
4684
|
} else if (issue2.code === "invalid_element") {
|
|
4688
|
-
processError({ issues: issue2.issues }, [...
|
|
4685
|
+
processError({ issues: issue2.issues }, [...path85, ...issue2.path]);
|
|
4689
4686
|
} else {
|
|
4690
|
-
const fullpath = [...
|
|
4687
|
+
const fullpath = [...path85, ...issue2.path];
|
|
4691
4688
|
if (fullpath.length === 0) {
|
|
4692
4689
|
result.errors.push(mapper(issue2));
|
|
4693
4690
|
continue;
|
|
@@ -4719,8 +4716,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4719
4716
|
}
|
|
4720
4717
|
function toDotPath(_path) {
|
|
4721
4718
|
const segs = [];
|
|
4722
|
-
const
|
|
4723
|
-
for (const seg of
|
|
4719
|
+
const path85 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
4720
|
+
for (const seg of path85) {
|
|
4724
4721
|
if (typeof seg === "number")
|
|
4725
4722
|
segs.push(`[${seg}]`);
|
|
4726
4723
|
else if (typeof seg === "symbol")
|
|
@@ -18150,13 +18147,13 @@ function resolveRef(ref, ctx) {
|
|
|
18150
18147
|
if (!ref.startsWith("#")) {
|
|
18151
18148
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18152
18149
|
}
|
|
18153
|
-
const
|
|
18154
|
-
if (
|
|
18150
|
+
const path85 = ref.slice(1).split("/").filter(Boolean);
|
|
18151
|
+
if (path85.length === 0) {
|
|
18155
18152
|
return ctx.rootSchema;
|
|
18156
18153
|
}
|
|
18157
18154
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18158
|
-
if (
|
|
18159
|
-
const key =
|
|
18155
|
+
if (path85[0] === defsKey) {
|
|
18156
|
+
const key = path85[1];
|
|
18160
18157
|
if (!key || !ctx.defs[key]) {
|
|
18161
18158
|
throw new Error(`Reference not found: ${ref}`);
|
|
18162
18159
|
}
|
|
@@ -20765,7 +20762,6 @@ import os from "node:os";
|
|
|
20765
20762
|
var INDEX_WORK_YIELD_EVERY, INDEX_DIR, INDEX_HASH_LEN;
|
|
20766
20763
|
var init_constants = __esm({
|
|
20767
20764
|
"../bridge/src/files/index/constants.ts"() {
|
|
20768
|
-
"use strict";
|
|
20769
20765
|
INDEX_WORK_YIELD_EVERY = 128;
|
|
20770
20766
|
INDEX_DIR = path3.join(os.homedir(), ".buildautomaton");
|
|
20771
20767
|
INDEX_HASH_LEN = 16;
|
|
@@ -21036,7 +21032,6 @@ function yieldToEventLoop() {
|
|
|
21036
21032
|
}
|
|
21037
21033
|
var init_yield_to_event_loop = __esm({
|
|
21038
21034
|
"../bridge/src/runtime/yield-to-event-loop.ts"() {
|
|
21039
|
-
"use strict";
|
|
21040
21035
|
}
|
|
21041
21036
|
});
|
|
21042
21037
|
|
|
@@ -21047,7 +21042,6 @@ function isSymbolIndexDeferredError(err) {
|
|
|
21047
21042
|
var SymbolIndexDeferredError;
|
|
21048
21043
|
var init_deferred_indexing = __esm({
|
|
21049
21044
|
"../bridge/src/code-nav/symbol-index/deferred-indexing.ts"() {
|
|
21050
|
-
"use strict";
|
|
21051
21045
|
SymbolIndexDeferredError = class extends Error {
|
|
21052
21046
|
constructor() {
|
|
21053
21047
|
super("Symbol indexing deferred for file browser");
|
|
@@ -21114,7 +21108,6 @@ var init_idle_yield = __esm({
|
|
|
21114
21108
|
// ../bridge/src/files/browser/in-flight.ts
|
|
21115
21109
|
var init_in_flight = __esm({
|
|
21116
21110
|
"../bridge/src/files/browser/in-flight.ts"() {
|
|
21117
|
-
"use strict";
|
|
21118
21111
|
init_activity_shared();
|
|
21119
21112
|
init_activity_types();
|
|
21120
21113
|
init_activity_tracker();
|
|
@@ -21132,7 +21125,6 @@ function isCliSqliteLockError(e) {
|
|
|
21132
21125
|
var CliSqliteInterrupted;
|
|
21133
21126
|
var init_sqlite_errors = __esm({
|
|
21134
21127
|
"../bridge/src/sqlite/sqlite-errors.ts"() {
|
|
21135
|
-
"use strict";
|
|
21136
21128
|
CliSqliteInterrupted = class extends Error {
|
|
21137
21129
|
name = "CliSqliteInterrupted";
|
|
21138
21130
|
constructor() {
|
|
@@ -21243,7 +21235,6 @@ function maybeLogCodeNavCacheWorkerError(message) {
|
|
|
21243
21235
|
var diagnosticSink, lastDiagnosticKey;
|
|
21244
21236
|
var init_code_nav_cache_log = __esm({
|
|
21245
21237
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-log.ts"() {
|
|
21246
|
-
"use strict";
|
|
21247
21238
|
init_log();
|
|
21248
21239
|
init_sqlite_errors();
|
|
21249
21240
|
init_sqlite_lock_path();
|
|
@@ -21380,7 +21371,6 @@ function resetCodeNavCacheAvailabilityForTests() {
|
|
|
21380
21371
|
var initState, initPromise, CodeNavCacheUnavailableError;
|
|
21381
21372
|
var init_code_nav_cache_availability = __esm({
|
|
21382
21373
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-availability.ts"() {
|
|
21383
|
-
"use strict";
|
|
21384
21374
|
init_log();
|
|
21385
21375
|
init_in_flight();
|
|
21386
21376
|
init_sqlite_errors();
|
|
@@ -21757,7 +21747,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
21757
21747
|
join2(moduleDir, "..", sub, filename),
|
|
21758
21748
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
21759
21749
|
]);
|
|
21760
|
-
const resolved = candidates.find((
|
|
21750
|
+
const resolved = candidates.find((path85) => existsSync(path85));
|
|
21761
21751
|
if (!resolved) {
|
|
21762
21752
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
21763
21753
|
}
|
|
@@ -22074,7 +22064,6 @@ async function ensureCodeNavCacheSqliteInitialized() {
|
|
|
22074
22064
|
var safeCloseCodeNavCacheSqliteDatabase, openCodeNavCacheSqliteConnection;
|
|
22075
22065
|
var init_database = __esm({
|
|
22076
22066
|
"../bridge/src/sqlite/code-nav-cache/database.ts"() {
|
|
22077
|
-
"use strict";
|
|
22078
22067
|
init_code_nav_cache_availability();
|
|
22079
22068
|
init_instance();
|
|
22080
22069
|
init_sqlite_errors();
|
|
@@ -22103,7 +22092,6 @@ function runCodeNavCacheWriteTransaction(db, fn) {
|
|
|
22103
22092
|
}
|
|
22104
22093
|
var init_code_nav_cache_sqlite_transaction = __esm({
|
|
22105
22094
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-transaction.ts"() {
|
|
22106
|
-
"use strict";
|
|
22107
22095
|
}
|
|
22108
22096
|
});
|
|
22109
22097
|
|
|
@@ -22158,7 +22146,6 @@ function getPromptQueuesDirectory() {
|
|
|
22158
22146
|
}
|
|
22159
22147
|
var init_paths2 = __esm({
|
|
22160
22148
|
"../bridge/src/prompt-turn-queue/paths.ts"() {
|
|
22161
|
-
"use strict";
|
|
22162
22149
|
}
|
|
22163
22150
|
});
|
|
22164
22151
|
|
|
@@ -22448,7 +22435,6 @@ function closeAllCliSqliteConnections() {
|
|
|
22448
22435
|
var legacyImportDoneForPath, cliSqlite, safeCloseCliSqliteDatabase, openCliSqliteConnection, withCliSqliteSync, withCliSqlite, ensureCliSqliteInitialized;
|
|
22449
22436
|
var init_cli_database = __esm({
|
|
22450
22437
|
"../bridge/src/sqlite/cli-database.ts"() {
|
|
22451
|
-
"use strict";
|
|
22452
22438
|
init_cli_process_interrupt();
|
|
22453
22439
|
init_cli_sqlite_paths();
|
|
22454
22440
|
init_access();
|
|
@@ -22835,7 +22821,7 @@ var require_ignore = __commonJS({
|
|
|
22835
22821
|
// path matching.
|
|
22836
22822
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
22837
22823
|
// @returns {TestResult} true if a file is ignored
|
|
22838
|
-
test(
|
|
22824
|
+
test(path85, checkUnignored, mode) {
|
|
22839
22825
|
let ignored = false;
|
|
22840
22826
|
let unignored = false;
|
|
22841
22827
|
let matchedRule;
|
|
@@ -22844,7 +22830,7 @@ var require_ignore = __commonJS({
|
|
|
22844
22830
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
22845
22831
|
return;
|
|
22846
22832
|
}
|
|
22847
|
-
const matched = rule[mode].test(
|
|
22833
|
+
const matched = rule[mode].test(path85);
|
|
22848
22834
|
if (!matched) {
|
|
22849
22835
|
return;
|
|
22850
22836
|
}
|
|
@@ -22865,17 +22851,17 @@ var require_ignore = __commonJS({
|
|
|
22865
22851
|
var throwError = (message, Ctor) => {
|
|
22866
22852
|
throw new Ctor(message);
|
|
22867
22853
|
};
|
|
22868
|
-
var checkPath = (
|
|
22869
|
-
if (!isString(
|
|
22854
|
+
var checkPath = (path85, originalPath, doThrow) => {
|
|
22855
|
+
if (!isString(path85)) {
|
|
22870
22856
|
return doThrow(
|
|
22871
22857
|
`path must be a string, but got \`${originalPath}\``,
|
|
22872
22858
|
TypeError
|
|
22873
22859
|
);
|
|
22874
22860
|
}
|
|
22875
|
-
if (!
|
|
22861
|
+
if (!path85) {
|
|
22876
22862
|
return doThrow(`path must not be empty`, TypeError);
|
|
22877
22863
|
}
|
|
22878
|
-
if (checkPath.isNotRelative(
|
|
22864
|
+
if (checkPath.isNotRelative(path85)) {
|
|
22879
22865
|
const r = "`path.relative()`d";
|
|
22880
22866
|
return doThrow(
|
|
22881
22867
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -22884,7 +22870,7 @@ var require_ignore = __commonJS({
|
|
|
22884
22870
|
}
|
|
22885
22871
|
return true;
|
|
22886
22872
|
};
|
|
22887
|
-
var isNotRelative = (
|
|
22873
|
+
var isNotRelative = (path85) => REGEX_TEST_INVALID_PATH.test(path85);
|
|
22888
22874
|
checkPath.isNotRelative = isNotRelative;
|
|
22889
22875
|
checkPath.convert = (p) => p;
|
|
22890
22876
|
var Ignore = class {
|
|
@@ -22914,19 +22900,19 @@ var require_ignore = __commonJS({
|
|
|
22914
22900
|
}
|
|
22915
22901
|
// @returns {TestResult}
|
|
22916
22902
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
22917
|
-
const
|
|
22903
|
+
const path85 = originalPath && checkPath.convert(originalPath);
|
|
22918
22904
|
checkPath(
|
|
22919
|
-
|
|
22905
|
+
path85,
|
|
22920
22906
|
originalPath,
|
|
22921
22907
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
22922
22908
|
);
|
|
22923
|
-
return this._t(
|
|
22909
|
+
return this._t(path85, cache2, checkUnignored, slices);
|
|
22924
22910
|
}
|
|
22925
|
-
checkIgnore(
|
|
22926
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
22927
|
-
return this.test(
|
|
22911
|
+
checkIgnore(path85) {
|
|
22912
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path85)) {
|
|
22913
|
+
return this.test(path85);
|
|
22928
22914
|
}
|
|
22929
|
-
const slices =
|
|
22915
|
+
const slices = path85.split(SLASH).filter(Boolean);
|
|
22930
22916
|
slices.pop();
|
|
22931
22917
|
if (slices.length) {
|
|
22932
22918
|
const parent = this._t(
|
|
@@ -22939,18 +22925,18 @@ var require_ignore = __commonJS({
|
|
|
22939
22925
|
return parent;
|
|
22940
22926
|
}
|
|
22941
22927
|
}
|
|
22942
|
-
return this._rules.test(
|
|
22928
|
+
return this._rules.test(path85, false, MODE_CHECK_IGNORE);
|
|
22943
22929
|
}
|
|
22944
|
-
_t(
|
|
22945
|
-
if (
|
|
22946
|
-
return cache2[
|
|
22930
|
+
_t(path85, cache2, checkUnignored, slices) {
|
|
22931
|
+
if (path85 in cache2) {
|
|
22932
|
+
return cache2[path85];
|
|
22947
22933
|
}
|
|
22948
22934
|
if (!slices) {
|
|
22949
|
-
slices =
|
|
22935
|
+
slices = path85.split(SLASH).filter(Boolean);
|
|
22950
22936
|
}
|
|
22951
22937
|
slices.pop();
|
|
22952
22938
|
if (!slices.length) {
|
|
22953
|
-
return cache2[
|
|
22939
|
+
return cache2[path85] = this._rules.test(path85, checkUnignored, MODE_IGNORE);
|
|
22954
22940
|
}
|
|
22955
22941
|
const parent = this._t(
|
|
22956
22942
|
slices.join(SLASH) + SLASH,
|
|
@@ -22958,29 +22944,29 @@ var require_ignore = __commonJS({
|
|
|
22958
22944
|
checkUnignored,
|
|
22959
22945
|
slices
|
|
22960
22946
|
);
|
|
22961
|
-
return cache2[
|
|
22947
|
+
return cache2[path85] = parent.ignored ? parent : this._rules.test(path85, checkUnignored, MODE_IGNORE);
|
|
22962
22948
|
}
|
|
22963
|
-
ignores(
|
|
22964
|
-
return this._test(
|
|
22949
|
+
ignores(path85) {
|
|
22950
|
+
return this._test(path85, this._ignoreCache, false).ignored;
|
|
22965
22951
|
}
|
|
22966
22952
|
createFilter() {
|
|
22967
|
-
return (
|
|
22953
|
+
return (path85) => !this.ignores(path85);
|
|
22968
22954
|
}
|
|
22969
22955
|
filter(paths) {
|
|
22970
22956
|
return makeArray(paths).filter(this.createFilter());
|
|
22971
22957
|
}
|
|
22972
22958
|
// @returns {TestResult}
|
|
22973
|
-
test(
|
|
22974
|
-
return this._test(
|
|
22959
|
+
test(path85) {
|
|
22960
|
+
return this._test(path85, this._testCache, true);
|
|
22975
22961
|
}
|
|
22976
22962
|
};
|
|
22977
22963
|
var factory = (options) => new Ignore(options);
|
|
22978
|
-
var isPathValid = (
|
|
22964
|
+
var isPathValid = (path85) => checkPath(path85 && checkPath.convert(path85), path85, RETURN_FALSE);
|
|
22979
22965
|
var setupWindows = () => {
|
|
22980
22966
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
22981
22967
|
checkPath.convert = makePosix;
|
|
22982
22968
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
22983
|
-
checkPath.isNotRelative = (
|
|
22969
|
+
checkPath.isNotRelative = (path85) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path85) || isNotRelative(path85);
|
|
22984
22970
|
};
|
|
22985
22971
|
if (
|
|
22986
22972
|
// Detect `process` so that it can run in browsers.
|
|
@@ -26525,12 +26511,11 @@ __export(lifecycle_exports, {
|
|
|
26525
26511
|
});
|
|
26526
26512
|
var init_lifecycle2 = __esm({
|
|
26527
26513
|
"../bridge/src/code-nav/symbol-index/worker/lifecycle.ts"() {
|
|
26528
|
-
"use strict";
|
|
26529
26514
|
init_lifecycle();
|
|
26530
26515
|
}
|
|
26531
26516
|
});
|
|
26532
26517
|
|
|
26533
|
-
// ../bridge/src/
|
|
26518
|
+
// ../bridge/src/cli/teardown/cli-process-interrupt.ts
|
|
26534
26519
|
function requestCliImmediateShutdown() {
|
|
26535
26520
|
if (cliImmediateShutdownRequested) return;
|
|
26536
26521
|
cliImmediateShutdownRequested = true;
|
|
@@ -26577,7 +26562,7 @@ async function delayMsUnlessShutdownRequested(ms) {
|
|
|
26577
26562
|
}
|
|
26578
26563
|
var cliImmediateShutdownRequested, symbolIndexShutdownPromise;
|
|
26579
26564
|
var init_cli_process_interrupt = __esm({
|
|
26580
|
-
"../bridge/src/
|
|
26565
|
+
"../bridge/src/cli/teardown/cli-process-interrupt.ts"() {
|
|
26581
26566
|
"use strict";
|
|
26582
26567
|
cliImmediateShutdownRequested = false;
|
|
26583
26568
|
symbolIndexShutdownPromise = null;
|
|
@@ -27358,10 +27343,10 @@ var require_src2 = __commonJS({
|
|
|
27358
27343
|
var fs_1 = __require("fs");
|
|
27359
27344
|
var debug_1 = __importDefault(require_src());
|
|
27360
27345
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
27361
|
-
function check2(
|
|
27362
|
-
log2(`checking %s`,
|
|
27346
|
+
function check2(path85, isFile, isDirectory) {
|
|
27347
|
+
log2(`checking %s`, path85);
|
|
27363
27348
|
try {
|
|
27364
|
-
const stat2 = fs_1.statSync(
|
|
27349
|
+
const stat2 = fs_1.statSync(path85);
|
|
27365
27350
|
if (stat2.isFile() && isFile) {
|
|
27366
27351
|
log2(`[OK] path represents a file`);
|
|
27367
27352
|
return true;
|
|
@@ -27381,8 +27366,8 @@ var require_src2 = __commonJS({
|
|
|
27381
27366
|
throw e;
|
|
27382
27367
|
}
|
|
27383
27368
|
}
|
|
27384
|
-
function exists2(
|
|
27385
|
-
return check2(
|
|
27369
|
+
function exists2(path85, type = exports.READABLE) {
|
|
27370
|
+
return check2(path85, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
27386
27371
|
}
|
|
27387
27372
|
exports.exists = exists2;
|
|
27388
27373
|
exports.FILE = 1;
|
|
@@ -27453,7 +27438,7 @@ var import_websocket = __toESM(require_websocket(), 1);
|
|
|
27453
27438
|
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
27454
27439
|
var wrapper_default = import_websocket.default;
|
|
27455
27440
|
|
|
27456
|
-
// ../bridge/src/connection/cli-ws-client.ts
|
|
27441
|
+
// ../bridge/src/connection/ws/cli-ws-client.ts
|
|
27457
27442
|
import https from "node:https";
|
|
27458
27443
|
var CLI_WEBSOCKET_CLIENT_PING_MS = 25e3;
|
|
27459
27444
|
function attachWebSocketClientPing(ws, intervalMs) {
|
|
@@ -27513,11 +27498,11 @@ function safeSendWebSocketBinary(ws, data) {
|
|
|
27513
27498
|
}
|
|
27514
27499
|
}
|
|
27515
27500
|
|
|
27516
|
-
// ../bridge/src/connection/create-ws-bridge-options.ts
|
|
27501
|
+
// ../bridge/src/connection/ws/create-ws-bridge-options.ts
|
|
27517
27502
|
var BRIDGE_AUTH_ERROR_HEADER = "x-bridge-auth-error";
|
|
27518
27503
|
var BRIDGE_AUTH_ERROR_TOKEN_INVALID = "token_invalid";
|
|
27519
27504
|
|
|
27520
|
-
// ../bridge/src/connection/dispatch-ws-inbound-message.ts
|
|
27505
|
+
// ../bridge/src/connection/ws/dispatch-ws-inbound-message.ts
|
|
27521
27506
|
function dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket) {
|
|
27522
27507
|
if (isActiveSocket && !isActiveSocket(ws)) return;
|
|
27523
27508
|
try {
|
|
@@ -27536,7 +27521,7 @@ function dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket) {
|
|
|
27536
27521
|
}
|
|
27537
27522
|
}
|
|
27538
27523
|
|
|
27539
|
-
// ../bridge/src/connection/parse-compact-heartbeat-ack.ts
|
|
27524
|
+
// ../bridge/src/connection/heartbeat/parse-compact-heartbeat-ack.ts
|
|
27540
27525
|
function tryParseCompactHeartbeatAck(raw) {
|
|
27541
27526
|
let str = null;
|
|
27542
27527
|
if (typeof raw === "string") {
|
|
@@ -27562,7 +27547,7 @@ function tryParseCompactHeartbeatAck(raw) {
|
|
|
27562
27547
|
}
|
|
27563
27548
|
}
|
|
27564
27549
|
|
|
27565
|
-
// ../bridge/src/connection/create-ws-bridge.ts
|
|
27550
|
+
// ../bridge/src/connection/ws/create-ws-bridge.ts
|
|
27566
27551
|
function createWsBridge(options) {
|
|
27567
27552
|
const {
|
|
27568
27553
|
url: url2,
|
|
@@ -27719,7 +27704,7 @@ function formatSpawnError(err, command) {
|
|
|
27719
27704
|
}
|
|
27720
27705
|
|
|
27721
27706
|
// ../bridge/src/agents/acp/clients/kill-process-tree.ts
|
|
27722
|
-
var import_tree_kill = __toESM(require_tree_kill()
|
|
27707
|
+
var import_tree_kill = __toESM(require_tree_kill());
|
|
27723
27708
|
import { promisify } from "node:util";
|
|
27724
27709
|
var treeKillAsync = promisify(import_tree_kill.default);
|
|
27725
27710
|
var ACP_PROCESS_TREE_KILL_GRACE_MS = 2500;
|
|
@@ -27788,7 +27773,7 @@ function forceAcpSubprocessDisconnect(child) {
|
|
|
27788
27773
|
killChildProcessTree(child, "SIGKILL");
|
|
27789
27774
|
}
|
|
27790
27775
|
|
|
27791
|
-
// ../bridge/src/
|
|
27776
|
+
// ../bridge/src/agents/local-agent-auth.ts
|
|
27792
27777
|
var LOCAL_AGENT_AUTH_ERROR_HINTS = {
|
|
27793
27778
|
"kiro-acp": [/not logged in/i, /kiro-cli\s+login/i, /log in with kiro-cli/i],
|
|
27794
27779
|
"cursor-cli": [/cursor_login/i, /authenticate.*cursor/i, /not logged in.*cursor/i, /run:\s*agent\s+login/i],
|
|
@@ -28424,8 +28409,8 @@ function getErrorMap() {
|
|
|
28424
28409
|
|
|
28425
28410
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
28426
28411
|
var makeIssue = (params) => {
|
|
28427
|
-
const { data, path:
|
|
28428
|
-
const fullPath = [...
|
|
28412
|
+
const { data, path: path85, errorMaps, issueData } = params;
|
|
28413
|
+
const fullPath = [...path85, ...issueData.path || []];
|
|
28429
28414
|
const fullIssue = {
|
|
28430
28415
|
...issueData,
|
|
28431
28416
|
path: fullPath
|
|
@@ -28541,11 +28526,11 @@ var errorUtil;
|
|
|
28541
28526
|
|
|
28542
28527
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
28543
28528
|
var ParseInputLazyPath = class {
|
|
28544
|
-
constructor(parent, value,
|
|
28529
|
+
constructor(parent, value, path85, key) {
|
|
28545
28530
|
this._cachedPath = [];
|
|
28546
28531
|
this.parent = parent;
|
|
28547
28532
|
this.data = value;
|
|
28548
|
-
this._path =
|
|
28533
|
+
this._path = path85;
|
|
28549
28534
|
this._key = key;
|
|
28550
28535
|
}
|
|
28551
28536
|
get path() {
|
|
@@ -33926,191 +33911,14 @@ async function proxyToLocalStreaming(request, callbacks) {
|
|
|
33926
33911
|
});
|
|
33927
33912
|
}
|
|
33928
33913
|
|
|
33929
|
-
// ../bridge/src/skills/preview.ts
|
|
33930
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
33931
|
-
var PREVIEW_API_BASE_PATH = "/__preview";
|
|
33932
|
-
var PREVIEW_SECRET_HEADER = "X-Preview-Secret";
|
|
33933
|
-
var DEFAULT_PORT = 3e3;
|
|
33934
|
-
var DEFAULT_COMMAND = "npm run preview";
|
|
33935
|
-
var PREVIEW_COMMAND_ENV = "BUILDAUTOMATON_PREVIEW_COMMAND";
|
|
33936
|
-
var PREVIEW_PORT_ENV = "BUILDAUTOMATON_PREVIEW_PORT";
|
|
33937
|
-
var previewProcess = null;
|
|
33938
|
-
var previewPort = DEFAULT_PORT;
|
|
33939
|
-
var previewSecret = "";
|
|
33940
|
-
function getPreviewCommand() {
|
|
33941
|
-
return process.env[PREVIEW_COMMAND_ENV]?.trim() || DEFAULT_COMMAND;
|
|
33942
|
-
}
|
|
33943
|
-
function randomSecret() {
|
|
33944
|
-
const bytes = new Uint8Array(32);
|
|
33945
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
33946
|
-
crypto.getRandomValues(bytes);
|
|
33947
|
-
}
|
|
33948
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
33949
|
-
}
|
|
33950
|
-
async function requestPreviewApi(port, secret, method, path88, body) {
|
|
33951
|
-
const url2 = `http://127.0.0.1:${port}${path88}`;
|
|
33952
|
-
const headers = {
|
|
33953
|
-
[PREVIEW_SECRET_HEADER]: secret,
|
|
33954
|
-
"Content-Type": "application/json"
|
|
33955
|
-
};
|
|
33956
|
-
const res = await fetch(url2, {
|
|
33957
|
-
method,
|
|
33958
|
-
headers,
|
|
33959
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
33960
|
-
});
|
|
33961
|
-
const data = await res.json().catch(() => ({}));
|
|
33962
|
-
if (!res.ok) {
|
|
33963
|
-
throw new Error(data?.error ?? `Preview API ${method} ${path88}: ${res.status}`);
|
|
33964
|
-
}
|
|
33965
|
-
return data;
|
|
33966
|
-
}
|
|
33967
|
-
var OPERATIONS = [
|
|
33968
|
-
{
|
|
33969
|
-
id: "start",
|
|
33970
|
-
description: "Start the preview server process (runs the configured command with PORT and PREVIEW_SECRET).",
|
|
33971
|
-
params: [
|
|
33972
|
-
{ name: "port", description: "Port for the preview server", type: "number", required: false }
|
|
33973
|
-
]
|
|
33974
|
-
},
|
|
33975
|
-
{
|
|
33976
|
-
id: "stop",
|
|
33977
|
-
description: "Stop the preview server via POST /__preview/stop (graceful shutdown).",
|
|
33978
|
-
params: []
|
|
33979
|
-
},
|
|
33980
|
-
{
|
|
33981
|
-
id: "status",
|
|
33982
|
-
description: "Return status from GET /__preview/status (running, url).",
|
|
33983
|
-
params: []
|
|
33984
|
-
}
|
|
33985
|
-
];
|
|
33986
|
-
var previewSkill = {
|
|
33987
|
-
id: "preview",
|
|
33988
|
-
name: "Preview",
|
|
33989
|
-
description: "Start and manage a local preview server that implements the BuildAutomaton Preview Server API. Configure the command with BUILDAUTOMATON_PREVIEW_COMMAND (default: npm run preview). The server receives PORT and PREVIEW_SECRET and must expose /__preview/status and /__preview/stop.",
|
|
33990
|
-
operations: OPERATIONS,
|
|
33991
|
-
async execute(operationId, params) {
|
|
33992
|
-
const command = getPreviewCommand();
|
|
33993
|
-
switch (operationId) {
|
|
33994
|
-
case "start": {
|
|
33995
|
-
if (previewProcess) {
|
|
33996
|
-
return {
|
|
33997
|
-
ok: false,
|
|
33998
|
-
message: "Preview server already running",
|
|
33999
|
-
url: `http://localhost:${previewPort}`
|
|
34000
|
-
};
|
|
34001
|
-
}
|
|
34002
|
-
const port = params.port ?? (Number(process.env[PREVIEW_PORT_ENV]) || DEFAULT_PORT);
|
|
34003
|
-
previewPort = port;
|
|
34004
|
-
previewSecret = randomSecret();
|
|
34005
|
-
const isWindows = process.platform === "win32";
|
|
34006
|
-
const parts = command.split(/\s+/);
|
|
34007
|
-
const exe = parts[0];
|
|
34008
|
-
const args = parts.slice(1);
|
|
34009
|
-
previewProcess = spawn2(isWindows && exe === "npm" ? "npm.cmd" : exe, args, {
|
|
34010
|
-
cwd: getBridgeRoot(),
|
|
34011
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
34012
|
-
env: {
|
|
34013
|
-
...process.env,
|
|
34014
|
-
PORT: String(port),
|
|
34015
|
-
PREVIEW_SECRET: previewSecret
|
|
34016
|
-
}
|
|
34017
|
-
});
|
|
34018
|
-
previewProcess.stdout?.on("data", (d) => process.stdout.write(d));
|
|
34019
|
-
previewProcess.stderr?.on("data", (d) => process.stderr.write(d));
|
|
34020
|
-
previewProcess.on("exit", (code) => {
|
|
34021
|
-
previewProcess = null;
|
|
34022
|
-
if (code !== null && code !== 0) {
|
|
34023
|
-
process.stderr.write(`Preview server exited with code ${code}
|
|
34024
|
-
`);
|
|
34025
|
-
}
|
|
34026
|
-
});
|
|
34027
|
-
return {
|
|
34028
|
-
ok: true,
|
|
34029
|
-
message: `Preview server starting (${command}, port=${port})`,
|
|
34030
|
-
url: `http://localhost:${port}`,
|
|
34031
|
-
port
|
|
34032
|
-
};
|
|
34033
|
-
}
|
|
34034
|
-
case "stop": {
|
|
34035
|
-
if (!previewProcess) {
|
|
34036
|
-
return { ok: true, message: "No preview server was running" };
|
|
34037
|
-
}
|
|
34038
|
-
if (!previewSecret) {
|
|
34039
|
-
previewProcess.kill("SIGTERM");
|
|
34040
|
-
previewProcess = null;
|
|
34041
|
-
return { ok: true, message: "Preview process stopped (no secret)" };
|
|
34042
|
-
}
|
|
34043
|
-
try {
|
|
34044
|
-
await requestPreviewApi(
|
|
34045
|
-
previewPort,
|
|
34046
|
-
previewSecret,
|
|
34047
|
-
"POST",
|
|
34048
|
-
`${PREVIEW_API_BASE_PATH}/stop`
|
|
34049
|
-
);
|
|
34050
|
-
} catch (e) {
|
|
34051
|
-
previewProcess.kill("SIGTERM");
|
|
34052
|
-
}
|
|
34053
|
-
previewProcess = null;
|
|
34054
|
-
previewSecret = "";
|
|
34055
|
-
return { ok: true, message: "Preview server stop requested" };
|
|
34056
|
-
}
|
|
34057
|
-
case "status": {
|
|
34058
|
-
if (!previewProcess || !previewSecret) {
|
|
34059
|
-
return {
|
|
34060
|
-
running: previewProcess != null,
|
|
34061
|
-
url: previewProcess ? `http://localhost:${previewPort}` : void 0,
|
|
34062
|
-
message: previewProcess ? `Process running at http://localhost:${previewPort}` : "No preview server running"
|
|
34063
|
-
};
|
|
34064
|
-
}
|
|
34065
|
-
try {
|
|
34066
|
-
const status = await requestPreviewApi(
|
|
34067
|
-
previewPort,
|
|
34068
|
-
previewSecret,
|
|
34069
|
-
"GET",
|
|
34070
|
-
`${PREVIEW_API_BASE_PATH}/status`
|
|
34071
|
-
);
|
|
34072
|
-
return {
|
|
34073
|
-
running: status.status === "running",
|
|
34074
|
-
status: status.status,
|
|
34075
|
-
url: status.url ?? `http://localhost:${previewPort}`,
|
|
34076
|
-
message: status.message ?? (status.status === "running" ? "Preview server running" : "Stopping")
|
|
34077
|
-
};
|
|
34078
|
-
} catch {
|
|
34079
|
-
return {
|
|
34080
|
-
running: previewProcess != null,
|
|
34081
|
-
url: `http://localhost:${previewPort}`,
|
|
34082
|
-
message: "Process running but status endpoint unreachable (server may not implement Preview Server API yet)"
|
|
34083
|
-
};
|
|
34084
|
-
}
|
|
34085
|
-
}
|
|
34086
|
-
default:
|
|
34087
|
-
throw new Error(`Unknown operation: ${operationId}`);
|
|
34088
|
-
}
|
|
34089
|
-
}
|
|
34090
|
-
};
|
|
34091
|
-
|
|
34092
|
-
// ../bridge/src/skills/index.ts
|
|
34093
|
-
var skills = [previewSkill];
|
|
34094
|
-
function getSkills() {
|
|
34095
|
-
return skills;
|
|
34096
|
-
}
|
|
34097
|
-
function getSkill(id) {
|
|
34098
|
-
return skills.find((s) => s.id === id);
|
|
34099
|
-
}
|
|
34100
|
-
async function callSkill(skillId, operationId, params) {
|
|
34101
|
-
const skill = getSkill(skillId);
|
|
34102
|
-
if (!skill) throw new Error(`Skill not found: ${skillId}`);
|
|
34103
|
-
return skill.execute(operationId, params);
|
|
34104
|
-
}
|
|
34105
|
-
|
|
34106
33914
|
// ../bridge/src/index.ts
|
|
34107
33915
|
init_log();
|
|
34108
33916
|
init_cli_log_level();
|
|
34109
33917
|
|
|
34110
|
-
// ../bridge/src/run-bridge.ts
|
|
33918
|
+
// ../bridge/src/cli/run-bridge.ts
|
|
34111
33919
|
init_log();
|
|
34112
33920
|
|
|
34113
|
-
// ../bridge/src/process-bridge-resilience.ts
|
|
33921
|
+
// ../bridge/src/cli/teardown/process-bridge-resilience.ts
|
|
34114
33922
|
init_log();
|
|
34115
33923
|
var installed = false;
|
|
34116
33924
|
function installBridgeProcessResilience() {
|
|
@@ -34124,7 +33932,7 @@ function installBridgeProcessResilience() {
|
|
|
34124
33932
|
});
|
|
34125
33933
|
}
|
|
34126
33934
|
|
|
34127
|
-
// ../bridge/src/run-bridge-connected.ts
|
|
33935
|
+
// ../bridge/src/cli/run-bridge-connected.ts
|
|
34128
33936
|
init_log();
|
|
34129
33937
|
|
|
34130
33938
|
// ../bridge/src/agents/acp/clients/bridge-agent-path.ts
|
|
@@ -35271,7 +35079,7 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
|
35271
35079
|
};
|
|
35272
35080
|
}
|
|
35273
35081
|
|
|
35274
|
-
// ../bridge/src/connection/create-bridge-connection.ts
|
|
35082
|
+
// ../bridge/src/connection/runtime/create-bridge-connection.ts
|
|
35275
35083
|
init_cli_process_interrupt();
|
|
35276
35084
|
|
|
35277
35085
|
// ../bridge/src/preview-environments/manager/constants.ts
|
|
@@ -35279,13 +35087,13 @@ var BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS = 0;
|
|
|
35279
35087
|
var BRIDGE_SHUTDOWN_GRACE_MS = 8e3;
|
|
35280
35088
|
var PREVIEW_ENVIRONMENT_STOP_GRACE_MS = 2500;
|
|
35281
35089
|
|
|
35282
|
-
// ../bridge/src/connection/close-bridge-connection.ts
|
|
35090
|
+
// ../bridge/src/connection/runtime/close-bridge-connection.ts
|
|
35283
35091
|
init_log();
|
|
35284
35092
|
init_cli_process_interrupt();
|
|
35285
35093
|
init_cli_database();
|
|
35286
35094
|
init_database();
|
|
35287
35095
|
|
|
35288
|
-
// ../bridge/src/connection/ws-close-diagnostics.ts
|
|
35096
|
+
// ../bridge/src/connection/ws/ws-close-diagnostics.ts
|
|
35289
35097
|
function describeWebSocketCloseCode(code) {
|
|
35290
35098
|
const known = {
|
|
35291
35099
|
1e3: "normal closure",
|
|
@@ -35385,7 +35193,7 @@ function beginDeferredDisconnectForReconnect(options) {
|
|
|
35385
35193
|
}
|
|
35386
35194
|
}
|
|
35387
35195
|
|
|
35388
|
-
// ../bridge/src/connection/close-bridge-connection.ts
|
|
35196
|
+
// ../bridge/src/connection/runtime/close-bridge-connection.ts
|
|
35389
35197
|
async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
|
|
35390
35198
|
requestCliImmediateShutdown();
|
|
35391
35199
|
const say = log2 ?? logImmediate;
|
|
@@ -35521,7 +35329,7 @@ function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
|
|
|
35521
35329
|
return getBridgeRoot();
|
|
35522
35330
|
}
|
|
35523
35331
|
|
|
35524
|
-
// ../bridge/src/error-message.ts
|
|
35332
|
+
// ../bridge/src/cli/error-message.ts
|
|
35525
35333
|
function errorMessage(err) {
|
|
35526
35334
|
if (err instanceof Error) return err.message;
|
|
35527
35335
|
if (err != null && typeof err === "object" && "message" in err)
|
|
@@ -36325,10 +36133,10 @@ async function initCursorAcpWire(options) {
|
|
|
36325
36133
|
}
|
|
36326
36134
|
|
|
36327
36135
|
// ../bridge/src/agents/acp/clients/cursor/spawn-cursor-acp-process.ts
|
|
36328
|
-
import { spawn as
|
|
36136
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
36329
36137
|
function spawnCursorAcpProcess(options) {
|
|
36330
36138
|
const isWindows = process.platform === "win32";
|
|
36331
|
-
const child =
|
|
36139
|
+
const child = spawn2(options.command[0], options.command.slice(1), {
|
|
36332
36140
|
cwd: options.cwd,
|
|
36333
36141
|
stdio: ["pipe", "pipe", "pipe"],
|
|
36334
36142
|
env: bridgeInstalledAgentAuthProcessEnv(process.env),
|
|
@@ -36520,7 +36328,7 @@ function resolveAgentCommand(preferredAgentType) {
|
|
|
36520
36328
|
import { existsSync as existsSync4, statSync } from "node:fs";
|
|
36521
36329
|
|
|
36522
36330
|
// ../bridge/src/git/git-exec.ts
|
|
36523
|
-
import { execFile as execFile2, execFileSync as execFileSync2, spawn as
|
|
36331
|
+
import { execFile as execFile2, execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
|
|
36524
36332
|
import { promisify as promisify3 } from "node:util";
|
|
36525
36333
|
|
|
36526
36334
|
// ../bridge/src/git/git-runtime.ts
|
|
@@ -37814,8 +37622,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
|
|
|
37814
37622
|
init_yield_to_event_loop();
|
|
37815
37623
|
|
|
37816
37624
|
// ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
|
|
37817
|
-
function normalizeGitDiffPath(
|
|
37818
|
-
return
|
|
37625
|
+
function normalizeGitDiffPath(path85) {
|
|
37626
|
+
return path85.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
37819
37627
|
}
|
|
37820
37628
|
|
|
37821
37629
|
// ../bridge/src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -38526,17 +38334,17 @@ async function createAcpManager(options) {
|
|
|
38526
38334
|
};
|
|
38527
38335
|
}
|
|
38528
38336
|
|
|
38529
|
-
// ../
|
|
38337
|
+
// ../bridge/src/e2ee/constants.ts
|
|
38530
38338
|
var E2EE_NONCE_BYTES = 12;
|
|
38531
38339
|
|
|
38532
|
-
// ../
|
|
38340
|
+
// ../bridge/src/e2ee/types.ts
|
|
38533
38341
|
function isE2eeEnvelope(value) {
|
|
38534
38342
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
38535
38343
|
const o = value;
|
|
38536
38344
|
return typeof o.k === "string" && typeof o.n === "string" && typeof o.c === "string";
|
|
38537
38345
|
}
|
|
38538
38346
|
|
|
38539
|
-
// ../
|
|
38347
|
+
// ../bridge/src/e2ee/encoding.ts
|
|
38540
38348
|
function base64UrlEncode(bytes) {
|
|
38541
38349
|
let binary = "";
|
|
38542
38350
|
for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
|
|
@@ -38552,7 +38360,7 @@ function base64UrlDecode(value) {
|
|
|
38552
38360
|
return out;
|
|
38553
38361
|
}
|
|
38554
38362
|
|
|
38555
|
-
// ../bridge/src/
|
|
38363
|
+
// ../bridge/src/e2ee/cli-e2ee-runtime.ts
|
|
38556
38364
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
38557
38365
|
function nonceFromCounter(prefix, counter) {
|
|
38558
38366
|
const nonce = Buffer.alloc(E2EE_NONCE_BYTES);
|
|
@@ -38631,7 +38439,7 @@ function createCliE2eeRuntime(key) {
|
|
|
38631
38439
|
};
|
|
38632
38440
|
}
|
|
38633
38441
|
|
|
38634
|
-
// ../bridge/src/
|
|
38442
|
+
// ../bridge/src/e2ee/decrypt-stored-e2ee-content.ts
|
|
38635
38443
|
function parseJsonObject(raw) {
|
|
38636
38444
|
try {
|
|
38637
38445
|
const parsed = JSON.parse(raw);
|
|
@@ -38697,6 +38505,40 @@ function decryptCliE2eeMessageField(payload, field, e2ee) {
|
|
|
38697
38505
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
38698
38506
|
}
|
|
38699
38507
|
|
|
38508
|
+
// ../bridge/src/e2ee/key-command.ts
|
|
38509
|
+
import * as readline2 from "node:readline";
|
|
38510
|
+
function installE2eCertificateKeyCommand({
|
|
38511
|
+
log: log2,
|
|
38512
|
+
onOpenCertificate,
|
|
38513
|
+
onInterrupt
|
|
38514
|
+
}) {
|
|
38515
|
+
if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== "function") {
|
|
38516
|
+
log2("[E2EE] Press c to import the E2EE key in a browser when running in an interactive terminal.");
|
|
38517
|
+
return () => {
|
|
38518
|
+
};
|
|
38519
|
+
}
|
|
38520
|
+
readline2.emitKeypressEvents(process.stdin);
|
|
38521
|
+
process.stdin.setRawMode(true);
|
|
38522
|
+
process.stdin.resume();
|
|
38523
|
+
const onKeypress = (str, key) => {
|
|
38524
|
+
if (key?.ctrl && key.name === "c") {
|
|
38525
|
+
onInterrupt();
|
|
38526
|
+
return;
|
|
38527
|
+
}
|
|
38528
|
+
if (!key?.ctrl && !key?.meta && (key?.name === "c" || str === "c")) {
|
|
38529
|
+
onOpenCertificate();
|
|
38530
|
+
}
|
|
38531
|
+
};
|
|
38532
|
+
process.stdin.on("keypress", onKeypress);
|
|
38533
|
+
log2("[E2EE] Press c to import the active E2EE key into the browser.");
|
|
38534
|
+
return () => {
|
|
38535
|
+
process.stdin.off("keypress", onKeypress);
|
|
38536
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
38537
|
+
process.stdin.setRawMode(false);
|
|
38538
|
+
}
|
|
38539
|
+
};
|
|
38540
|
+
}
|
|
38541
|
+
|
|
38700
38542
|
// ../bridge/src/mcp/create-empty-mcp-tool-registry.ts
|
|
38701
38543
|
function createEmptyMcpToolRegistry() {
|
|
38702
38544
|
return {
|
|
@@ -39149,7 +38991,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
39149
38991
|
})();
|
|
39150
38992
|
}
|
|
39151
38993
|
|
|
39152
|
-
// ../bridge/src/connection/create-bridge-agent-capabilities-reporter.ts
|
|
38994
|
+
// ../bridge/src/connection/reports/create-bridge-agent-capabilities-reporter.ts
|
|
39153
38995
|
init_cli_database();
|
|
39154
38996
|
function createAgentCapabilitiesReporter(params) {
|
|
39155
38997
|
const { workspaceId, getWs } = params;
|
|
@@ -39185,7 +39027,7 @@ function createWarmupAgentCapabilitiesOnConnect(params) {
|
|
|
39185
39027
|
};
|
|
39186
39028
|
}
|
|
39187
39029
|
|
|
39188
|
-
// ../bridge/src/connection/create-bridge-access-and-acp.ts
|
|
39030
|
+
// ../bridge/src/connection/setup/create-bridge-access-and-acp.ts
|
|
39189
39031
|
async function createBridgeAccessAndAcp(options) {
|
|
39190
39032
|
const { plugin, workspaceId, getWs, log: log2 } = options;
|
|
39191
39033
|
const e2ee = options.e2eCertificate ? createCliE2eeRuntime(options.e2eCertificate) : void 0;
|
|
@@ -39208,7 +39050,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
39208
39050
|
return { e2ee, acpManager, bridgeAccessPromise };
|
|
39209
39051
|
}
|
|
39210
39052
|
|
|
39211
|
-
// ../bridge/src/connection/create-bridge-preview-stack.ts
|
|
39053
|
+
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
39212
39054
|
import * as path38 from "node:path";
|
|
39213
39055
|
|
|
39214
39056
|
// ../bridge/src/preview-environments/manager/firehose-messages.ts
|
|
@@ -39863,7 +39705,7 @@ function pipedStdoutStderrFor(attemptStdio) {
|
|
|
39863
39705
|
}
|
|
39864
39706
|
|
|
39865
39707
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-piped-via-sh.ts
|
|
39866
|
-
import { spawn as
|
|
39708
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
39867
39709
|
function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
|
|
39868
39710
|
const attempts = [
|
|
39869
39711
|
{ stdio: [devNullReadFd(), "pipe", "pipe"], endStdin: false },
|
|
@@ -39887,9 +39729,9 @@ function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
|
|
|
39887
39729
|
if (process.platform === "win32") {
|
|
39888
39730
|
opts.windowsHide = true;
|
|
39889
39731
|
const com = process.env.ComSpec || "cmd.exe";
|
|
39890
|
-
proc =
|
|
39732
|
+
proc = spawn4(com, ["/d", "/s", "/c", command], opts);
|
|
39891
39733
|
} else {
|
|
39892
|
-
proc =
|
|
39734
|
+
proc = spawn4("/bin/sh", ["-c", command], opts);
|
|
39893
39735
|
}
|
|
39894
39736
|
if (attempt.endStdin) {
|
|
39895
39737
|
proc.stdin?.end();
|
|
@@ -39909,7 +39751,7 @@ function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
|
|
|
39909
39751
|
}
|
|
39910
39752
|
|
|
39911
39753
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-true-piped.ts
|
|
39912
|
-
import { spawn as
|
|
39754
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
39913
39755
|
function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle) {
|
|
39914
39756
|
try {
|
|
39915
39757
|
const opts = mergePreviewEnvironmentSpawnOptions(
|
|
@@ -39925,7 +39767,7 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
39925
39767
|
if (process.platform === "win32") {
|
|
39926
39768
|
opts.windowsHide = true;
|
|
39927
39769
|
}
|
|
39928
|
-
return
|
|
39770
|
+
return spawn5(command, opts);
|
|
39929
39771
|
} catch (e) {
|
|
39930
39772
|
if (isSpawnEbadf(e)) return null;
|
|
39931
39773
|
throw e;
|
|
@@ -39933,7 +39775,7 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
39933
39775
|
}
|
|
39934
39776
|
|
|
39935
39777
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
39936
|
-
import { spawn as
|
|
39778
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
39937
39779
|
import fs23 from "node:fs";
|
|
39938
39780
|
import { tmpdir } from "node:os";
|
|
39939
39781
|
import path36 from "node:path";
|
|
@@ -39951,7 +39793,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
39951
39793
|
try {
|
|
39952
39794
|
let proc;
|
|
39953
39795
|
if (process.platform === "win32") {
|
|
39954
|
-
proc =
|
|
39796
|
+
proc = spawn6(
|
|
39955
39797
|
process.env.ComSpec || "cmd.exe",
|
|
39956
39798
|
["/d", "/s", "/c", command],
|
|
39957
39799
|
mergePreviewEnvironmentSpawnOptions(
|
|
@@ -39960,7 +39802,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
39960
39802
|
)
|
|
39961
39803
|
);
|
|
39962
39804
|
} else {
|
|
39963
|
-
proc =
|
|
39805
|
+
proc = spawn6(
|
|
39964
39806
|
"/bin/sh",
|
|
39965
39807
|
["-c", command],
|
|
39966
39808
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
@@ -39985,7 +39827,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
39985
39827
|
}
|
|
39986
39828
|
|
|
39987
39829
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
39988
|
-
import { spawn as
|
|
39830
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
39989
39831
|
import fs24 from "node:fs";
|
|
39990
39832
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
39991
39833
|
import path37 from "node:path";
|
|
@@ -40008,7 +39850,7 @@ cd ${shSingleQuote(cwd)}
|
|
|
40008
39850
|
/bin/sh ${shSingleQuote(innerPath)} >>${shSingleQuote(logPath)} 2>&1
|
|
40009
39851
|
`
|
|
40010
39852
|
);
|
|
40011
|
-
const proc =
|
|
39853
|
+
const proc = spawn7(
|
|
40012
39854
|
"/bin/sh",
|
|
40013
39855
|
[runnerPath],
|
|
40014
39856
|
mergePreviewEnvironmentSpawnOptions(
|
|
@@ -40042,7 +39884,7 @@ CD /D ${q(cwd)}\r
|
|
|
40042
39884
|
${command} >> ${q(logPath)} 2>&1\r
|
|
40043
39885
|
`
|
|
40044
39886
|
);
|
|
40045
|
-
const proc =
|
|
39887
|
+
const proc = spawn7(
|
|
40046
39888
|
com,
|
|
40047
39889
|
["/d", "/s", "/c", q(runnerPath)],
|
|
40048
39890
|
mergePreviewEnvironmentSpawnOptions(
|
|
@@ -40064,7 +39906,7 @@ ${command} >> ${q(logPath)} 2>&1\r
|
|
|
40064
39906
|
}
|
|
40065
39907
|
|
|
40066
39908
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-inherit.ts
|
|
40067
|
-
import { spawn as
|
|
39909
|
+
import { spawn as spawn8 } from "node:child_process";
|
|
40068
39910
|
function trySpawnInheritStdio(command, env, cwd, signal, lifecycle) {
|
|
40069
39911
|
const opts = mergePreviewEnvironmentSpawnOptions(
|
|
40070
39912
|
{
|
|
@@ -40079,9 +39921,9 @@ function trySpawnInheritStdio(command, env, cwd, signal, lifecycle) {
|
|
|
40079
39921
|
if (process.platform === "win32") {
|
|
40080
39922
|
opts.windowsHide = true;
|
|
40081
39923
|
const com = process.env.ComSpec || "cmd.exe";
|
|
40082
|
-
proc =
|
|
39924
|
+
proc = spawn8(com, ["/d", "/s", "/c", command], opts);
|
|
40083
39925
|
} else {
|
|
40084
|
-
proc =
|
|
39926
|
+
proc = spawn8("/bin/sh", ["-c", command], opts);
|
|
40085
39927
|
}
|
|
40086
39928
|
return { proc, pipedStdoutStderr: false };
|
|
40087
39929
|
}
|
|
@@ -40337,7 +40179,7 @@ var PreviewEnvironmentManager = class {
|
|
|
40337
40179
|
}
|
|
40338
40180
|
};
|
|
40339
40181
|
|
|
40340
|
-
// ../bridge/src/connection/create-bridge-preview-stack.ts
|
|
40182
|
+
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
40341
40183
|
function createBridgePreviewStack(options) {
|
|
40342
40184
|
const previewEnvironmentManager = new PreviewEnvironmentManager({
|
|
40343
40185
|
getWs: options.getWs,
|
|
@@ -40361,7 +40203,7 @@ function createBridgePreviewStack(options) {
|
|
|
40361
40203
|
return { previewEnvironmentManager, scheduleInitialIndexBuildsOnce, identifyReportedPaths };
|
|
40362
40204
|
}
|
|
40363
40205
|
|
|
40364
|
-
// ../bridge/src/connection/create-bridge-identified-handler.ts
|
|
40206
|
+
// ../bridge/src/connection/identify/create-bridge-identified-handler.ts
|
|
40365
40207
|
function createOnBridgeIdentified(opts) {
|
|
40366
40208
|
const { plugin, previewEnvironmentManager, workspaceId, logFn } = opts;
|
|
40367
40209
|
return (msg) => {
|
|
@@ -40377,7 +40219,7 @@ function createOnBridgeIdentified(opts) {
|
|
|
40377
40219
|
};
|
|
40378
40220
|
}
|
|
40379
40221
|
|
|
40380
|
-
// ../bridge/src/connection/create-bridge-identified-with-heartbeat.ts
|
|
40222
|
+
// ../bridge/src/connection/identify/create-bridge-identified-with-heartbeat.ts
|
|
40381
40223
|
function createBridgeIdentifiedWithHeartbeat(params) {
|
|
40382
40224
|
const { bridgeHeartbeat, log: log2, ...identifiedOpts } = params;
|
|
40383
40225
|
const onBridgeIdentified = createOnBridgeIdentified({ ...identifiedOpts, logFn: log2 });
|
|
@@ -40555,10 +40397,10 @@ function createBridgeHeartbeatController(params) {
|
|
|
40555
40397
|
};
|
|
40556
40398
|
}
|
|
40557
40399
|
|
|
40558
|
-
// ../bridge/src/cli-version.ts
|
|
40559
|
-
var CLI_VERSION = "0.1.
|
|
40400
|
+
// ../bridge/src/cli/cli-version.ts
|
|
40401
|
+
var CLI_VERSION = "0.1.90".length > 0 ? "0.1.90" : "0.0.0-dev";
|
|
40560
40402
|
|
|
40561
|
-
// ../bridge/src/connection/send-bridge-identify.ts
|
|
40403
|
+
// ../bridge/src/connection/identify/send-bridge-identify.ts
|
|
40562
40404
|
function sendBridgeIdentify(ws, params) {
|
|
40563
40405
|
if (!ws) return;
|
|
40564
40406
|
const { identifyReportedPaths, e2ee } = params;
|
|
@@ -40575,7 +40417,7 @@ function sendBridgeIdentify(ws, params) {
|
|
|
40575
40417
|
}
|
|
40576
40418
|
var BRIDGE_IDENTIFY_REFRESH_EVERY_TICKS = 6;
|
|
40577
40419
|
|
|
40578
|
-
// ../bridge/src/connection/create-bridge-identify-heartbeat.ts
|
|
40420
|
+
// ../bridge/src/connection/identify/create-bridge-identify-heartbeat.ts
|
|
40579
40421
|
function createBridgeIdentifyHeartbeat(params) {
|
|
40580
40422
|
const { getWs, log: log2, identifyReportedPaths, e2ee } = params;
|
|
40581
40423
|
return createBridgeHeartbeatController({
|
|
@@ -40588,7 +40430,7 @@ function createBridgeIdentifyHeartbeat(params) {
|
|
|
40588
40430
|
});
|
|
40589
40431
|
}
|
|
40590
40432
|
|
|
40591
|
-
// ../bridge/src/connection/create-bridge-message-deps.ts
|
|
40433
|
+
// ../bridge/src/connection/runtime/create-bridge-message-deps.ts
|
|
40592
40434
|
function createBridgeMessageDeps(params) {
|
|
40593
40435
|
const {
|
|
40594
40436
|
getWs,
|
|
@@ -40598,7 +40440,6 @@ function createBridgeMessageDeps(params) {
|
|
|
40598
40440
|
previewWorktreeManager,
|
|
40599
40441
|
onBridgeIdentified,
|
|
40600
40442
|
bridgeHeartbeat,
|
|
40601
|
-
sendLocalSkillsReport,
|
|
40602
40443
|
reportAutoDetectedAgents,
|
|
40603
40444
|
warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
|
|
40604
40445
|
previewEnvironmentManager,
|
|
@@ -40616,7 +40457,6 @@ function createBridgeMessageDeps(params) {
|
|
|
40616
40457
|
onBridgeHeartbeatAck: (seq) => {
|
|
40617
40458
|
bridgeHeartbeat.onAck(seq);
|
|
40618
40459
|
},
|
|
40619
|
-
sendLocalSkillsReport,
|
|
40620
40460
|
reportAutoDetectedAgents,
|
|
40621
40461
|
warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
|
|
40622
40462
|
previewEnvironmentManager,
|
|
@@ -40626,114 +40466,8 @@ function createBridgeMessageDeps(params) {
|
|
|
40626
40466
|
};
|
|
40627
40467
|
}
|
|
40628
40468
|
|
|
40629
|
-
// ../bridge/src/
|
|
40630
|
-
init_constants();
|
|
40631
|
-
init_yield_to_event_loop();
|
|
40632
|
-
var SKILL_DISCOVERY_ROOTS = [".agents/skills", ".claude/skills", ".cursor/skills", "skills"];
|
|
40633
|
-
async function yieldSkillDiscoveryWork(entryCount) {
|
|
40634
|
-
if (entryCount > 0 && entryCount % INDEX_WORK_YIELD_EVERY === 0) {
|
|
40635
|
-
await yieldToEventLoop();
|
|
40636
|
-
}
|
|
40637
|
-
}
|
|
40638
|
-
|
|
40639
|
-
// ../bridge/src/skills/discovery/discover-local-skills.ts
|
|
40640
|
-
import fs25 from "node:fs";
|
|
40641
|
-
import path39 from "node:path";
|
|
40642
|
-
function collectSkillFromDir(rel, base, name, seenKeys, out) {
|
|
40643
|
-
const dir = path39.join(base, name);
|
|
40644
|
-
try {
|
|
40645
|
-
if (!fs25.statSync(dir).isDirectory()) return;
|
|
40646
|
-
} catch {
|
|
40647
|
-
return;
|
|
40648
|
-
}
|
|
40649
|
-
const skillMd = path39.join(dir, "SKILL.md");
|
|
40650
|
-
if (!fs25.existsSync(skillMd)) return;
|
|
40651
|
-
const key = `${rel}/${name}`;
|
|
40652
|
-
if (seenKeys.has(key)) return;
|
|
40653
|
-
seenKeys.add(key);
|
|
40654
|
-
out.push({ skillKey: name, path: `${rel}/${name}`.replace(/\\/g, "/") });
|
|
40655
|
-
}
|
|
40656
|
-
async function discoverLocalSkillsAsync(cwd) {
|
|
40657
|
-
const out = [];
|
|
40658
|
-
const seenKeys = /* @__PURE__ */ new Set();
|
|
40659
|
-
let work = 0;
|
|
40660
|
-
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
40661
|
-
await yieldSkillDiscoveryWork(++work);
|
|
40662
|
-
const base = path39.join(cwd, rel);
|
|
40663
|
-
if (!fs25.existsSync(base) || !fs25.statSync(base).isDirectory()) continue;
|
|
40664
|
-
let entries = [];
|
|
40665
|
-
try {
|
|
40666
|
-
entries = fs25.readdirSync(base);
|
|
40667
|
-
} catch {
|
|
40668
|
-
continue;
|
|
40669
|
-
}
|
|
40670
|
-
for (let i = 0; i < entries.length; i++) {
|
|
40671
|
-
await yieldSkillDiscoveryWork(++work);
|
|
40672
|
-
collectSkillFromDir(rel, base, entries[i], seenKeys, out);
|
|
40673
|
-
}
|
|
40674
|
-
}
|
|
40675
|
-
return out;
|
|
40676
|
-
}
|
|
40677
|
-
|
|
40678
|
-
// ../bridge/src/skills/discovery/discover-skill-layout-roots.ts
|
|
40679
|
-
import fs26 from "node:fs";
|
|
40680
|
-
import path40 from "node:path";
|
|
40681
|
-
function collectLayoutSkill(rel, base, name, skills2) {
|
|
40682
|
-
const dir = path40.join(base, name);
|
|
40683
|
-
try {
|
|
40684
|
-
if (!fs26.statSync(dir).isDirectory()) return;
|
|
40685
|
-
} catch {
|
|
40686
|
-
return;
|
|
40687
|
-
}
|
|
40688
|
-
if (!fs26.existsSync(path40.join(dir, "SKILL.md"))) return;
|
|
40689
|
-
const relPath = `${rel}/${name}`.replace(/\\/g, "/");
|
|
40690
|
-
skills2.push({ name, relPath });
|
|
40691
|
-
}
|
|
40692
|
-
async function discoverSkillLayoutRootsAsync(cwd) {
|
|
40693
|
-
const roots = [];
|
|
40694
|
-
let work = 0;
|
|
40695
|
-
for (const rel of SKILL_DISCOVERY_ROOTS) {
|
|
40696
|
-
await yieldSkillDiscoveryWork(++work);
|
|
40697
|
-
const base = path40.join(cwd, rel);
|
|
40698
|
-
if (!fs26.existsSync(base) || !fs26.statSync(base).isDirectory()) continue;
|
|
40699
|
-
let entries = [];
|
|
40700
|
-
try {
|
|
40701
|
-
entries = fs26.readdirSync(base);
|
|
40702
|
-
} catch {
|
|
40703
|
-
continue;
|
|
40704
|
-
}
|
|
40705
|
-
const skills2 = [];
|
|
40706
|
-
for (let i = 0; i < entries.length; i++) {
|
|
40707
|
-
await yieldSkillDiscoveryWork(++work);
|
|
40708
|
-
collectLayoutSkill(rel, base, entries[i], skills2);
|
|
40709
|
-
}
|
|
40710
|
-
if (skills2.length > 0) {
|
|
40711
|
-
roots.push({ path: rel.replace(/\\/g, "/"), skills: skills2 });
|
|
40712
|
-
}
|
|
40713
|
-
}
|
|
40714
|
-
return roots;
|
|
40715
|
-
}
|
|
40716
|
-
|
|
40717
|
-
// ../bridge/src/connection/create-bridge-local-reports.ts
|
|
40469
|
+
// ../bridge/src/connection/reports/create-bridge-local-reports.ts
|
|
40718
40470
|
init_cli_process_interrupt();
|
|
40719
|
-
function createSendLocalSkillsReport(getWs, logFn) {
|
|
40720
|
-
return () => {
|
|
40721
|
-
setImmediate(() => {
|
|
40722
|
-
void (async () => {
|
|
40723
|
-
try {
|
|
40724
|
-
const socket = getWs();
|
|
40725
|
-
if (!socket || socket.readyState !== wrapper_default.OPEN) return;
|
|
40726
|
-
const skills2 = await discoverLocalSkillsAsync(getBridgeRoot());
|
|
40727
|
-
sendWsMessage(socket, { type: "local_skills", skills: skills2 });
|
|
40728
|
-
} catch (e) {
|
|
40729
|
-
logFn(
|
|
40730
|
-
`[Bridge service] Local skills report failed: ${e instanceof Error ? e.message : String(e)}`
|
|
40731
|
-
);
|
|
40732
|
-
}
|
|
40733
|
-
})();
|
|
40734
|
-
});
|
|
40735
|
-
};
|
|
40736
|
-
}
|
|
40737
40471
|
function createReportAutoDetectedAgents(getWs, logFn) {
|
|
40738
40472
|
return async () => {
|
|
40739
40473
|
if (isCliImmediateShutdownRequested()) return;
|
|
@@ -40751,7 +40485,7 @@ function createReportAutoDetectedAgents(getWs, logFn) {
|
|
|
40751
40485
|
};
|
|
40752
40486
|
}
|
|
40753
40487
|
|
|
40754
|
-
// ../bridge/src/connection/create-bridge-runtime-message-deps.ts
|
|
40488
|
+
// ../bridge/src/connection/runtime/create-bridge-runtime-message-deps.ts
|
|
40755
40489
|
function createBridgeRuntimeMessageDeps(params) {
|
|
40756
40490
|
const {
|
|
40757
40491
|
plugin,
|
|
@@ -40774,7 +40508,6 @@ function createBridgeRuntimeMessageDeps(params) {
|
|
|
40774
40508
|
previewWorktreeManager,
|
|
40775
40509
|
onBridgeIdentified,
|
|
40776
40510
|
bridgeHeartbeat,
|
|
40777
|
-
sendLocalSkillsReport: createSendLocalSkillsReport(getWs, log2),
|
|
40778
40511
|
reportAutoDetectedAgents: createReportAutoDetectedAgents(getWs, log2),
|
|
40779
40512
|
warmupAgentCapabilitiesOnConnect: createWarmupAgentCapabilitiesOnConnect({
|
|
40780
40513
|
workspaceId,
|
|
@@ -40790,7 +40523,7 @@ function createBridgeRuntimeMessageDeps(params) {
|
|
|
40790
40523
|
});
|
|
40791
40524
|
}
|
|
40792
40525
|
|
|
40793
|
-
// ../bridge/src/connection/create-bridge-runtime-message-setup.ts
|
|
40526
|
+
// ../bridge/src/connection/runtime/create-bridge-runtime-message-setup.ts
|
|
40794
40527
|
function createBridgeRuntimeMessageSetup(options) {
|
|
40795
40528
|
const {
|
|
40796
40529
|
plugin,
|
|
@@ -40836,12 +40569,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
40836
40569
|
}
|
|
40837
40570
|
|
|
40838
40571
|
// ../bridge/src/worktrees/worktree-layout-file.ts
|
|
40839
|
-
import * as
|
|
40840
|
-
import * as
|
|
40572
|
+
import * as fs25 from "node:fs";
|
|
40573
|
+
import * as path39 from "node:path";
|
|
40841
40574
|
import os7 from "node:os";
|
|
40842
40575
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
40843
40576
|
function defaultWorktreeLayoutPath() {
|
|
40844
|
-
return
|
|
40577
|
+
return path39.join(os7.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
40845
40578
|
}
|
|
40846
40579
|
function normalizeLoadedLayout(raw) {
|
|
40847
40580
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -40853,8 +40586,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
40853
40586
|
function loadWorktreeLayout() {
|
|
40854
40587
|
try {
|
|
40855
40588
|
const p = defaultWorktreeLayoutPath();
|
|
40856
|
-
if (!
|
|
40857
|
-
const raw = JSON.parse(
|
|
40589
|
+
if (!fs25.existsSync(p)) return { launcherCwds: [] };
|
|
40590
|
+
const raw = JSON.parse(fs25.readFileSync(p, "utf8"));
|
|
40858
40591
|
return normalizeLoadedLayout(raw);
|
|
40859
40592
|
} catch {
|
|
40860
40593
|
return { launcherCwds: [] };
|
|
@@ -40862,24 +40595,24 @@ function loadWorktreeLayout() {
|
|
|
40862
40595
|
}
|
|
40863
40596
|
function saveWorktreeLayout(layout) {
|
|
40864
40597
|
try {
|
|
40865
|
-
const dir =
|
|
40866
|
-
|
|
40867
|
-
|
|
40598
|
+
const dir = path39.dirname(defaultWorktreeLayoutPath());
|
|
40599
|
+
fs25.mkdirSync(dir, { recursive: true });
|
|
40600
|
+
fs25.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
40868
40601
|
} catch {
|
|
40869
40602
|
}
|
|
40870
40603
|
}
|
|
40871
40604
|
function baseNameSafe(pathString) {
|
|
40872
|
-
return
|
|
40605
|
+
return path39.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
40873
40606
|
}
|
|
40874
40607
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
40875
|
-
const norm =
|
|
40876
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
40608
|
+
const norm = path39.resolve(bridgeRootPath2);
|
|
40609
|
+
const existing = layout.launcherCwds.find((e) => path39.resolve(e.absolutePath) === norm);
|
|
40877
40610
|
return existing?.dirName;
|
|
40878
40611
|
}
|
|
40879
40612
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
40880
40613
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
40881
40614
|
if (existing) return existing;
|
|
40882
|
-
const norm =
|
|
40615
|
+
const norm = path39.resolve(bridgeRootPath2);
|
|
40883
40616
|
const base = baseNameSafe(norm);
|
|
40884
40617
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
40885
40618
|
let name = base;
|
|
@@ -40941,7 +40674,7 @@ var import_debug = __toESM(require_src(), 1);
|
|
|
40941
40674
|
var import_promise_deferred = __toESM(require_dist2(), 1);
|
|
40942
40675
|
var import_promise_deferred2 = __toESM(require_dist2(), 1);
|
|
40943
40676
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
40944
|
-
import { spawn as
|
|
40677
|
+
import { spawn as spawn9 } from "child_process";
|
|
40945
40678
|
import { normalize as normalize3 } from "node:path";
|
|
40946
40679
|
import { EventEmitter } from "node:events";
|
|
40947
40680
|
var __defProp2 = Object.defineProperty;
|
|
@@ -40972,8 +40705,8 @@ function pathspec(...paths) {
|
|
|
40972
40705
|
cache.set(key, paths);
|
|
40973
40706
|
return key;
|
|
40974
40707
|
}
|
|
40975
|
-
function isPathSpec(
|
|
40976
|
-
return
|
|
40708
|
+
function isPathSpec(path85) {
|
|
40709
|
+
return path85 instanceof String && cache.has(path85);
|
|
40977
40710
|
}
|
|
40978
40711
|
function toPaths(pathSpec) {
|
|
40979
40712
|
return cache.get(pathSpec) || [];
|
|
@@ -41062,8 +40795,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
41062
40795
|
function forEachLineWithContent(input, callback) {
|
|
41063
40796
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
41064
40797
|
}
|
|
41065
|
-
function folderExists(
|
|
41066
|
-
return (0, import_file_exists.exists)(
|
|
40798
|
+
function folderExists(path85) {
|
|
40799
|
+
return (0, import_file_exists.exists)(path85, import_file_exists.FOLDER);
|
|
41067
40800
|
}
|
|
41068
40801
|
function append(target, item) {
|
|
41069
40802
|
if (Array.isArray(target)) {
|
|
@@ -41467,8 +41200,8 @@ function checkIsRepoRootTask() {
|
|
|
41467
41200
|
commands,
|
|
41468
41201
|
format: "utf-8",
|
|
41469
41202
|
onError,
|
|
41470
|
-
parser(
|
|
41471
|
-
return /^\.(git)?$/.test(
|
|
41203
|
+
parser(path85) {
|
|
41204
|
+
return /^\.(git)?$/.test(path85.trim());
|
|
41472
41205
|
}
|
|
41473
41206
|
};
|
|
41474
41207
|
}
|
|
@@ -41902,11 +41635,11 @@ function parseGrep(grep) {
|
|
|
41902
41635
|
const paths = /* @__PURE__ */ new Set();
|
|
41903
41636
|
const results = {};
|
|
41904
41637
|
forEachLineWithContent(grep, (input) => {
|
|
41905
|
-
const [
|
|
41906
|
-
paths.add(
|
|
41907
|
-
(results[
|
|
41638
|
+
const [path85, line, preview] = input.split(NULL);
|
|
41639
|
+
paths.add(path85);
|
|
41640
|
+
(results[path85] = results[path85] || []).push({
|
|
41908
41641
|
line: asNumber(line),
|
|
41909
|
-
path:
|
|
41642
|
+
path: path85,
|
|
41910
41643
|
preview
|
|
41911
41644
|
});
|
|
41912
41645
|
});
|
|
@@ -42329,7 +42062,7 @@ var init_git_executor_chain = __esm2({
|
|
|
42329
42062
|
rejection = reason || rejection;
|
|
42330
42063
|
}
|
|
42331
42064
|
});
|
|
42332
|
-
const spawned =
|
|
42065
|
+
const spawned = spawn9(command, args, spawnOptions);
|
|
42333
42066
|
spawned.stdout.on(
|
|
42334
42067
|
"data",
|
|
42335
42068
|
onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
|
|
@@ -42671,14 +42404,14 @@ var init_hash_object = __esm2({
|
|
|
42671
42404
|
init_task();
|
|
42672
42405
|
}
|
|
42673
42406
|
});
|
|
42674
|
-
function parseInit(bare,
|
|
42407
|
+
function parseInit(bare, path85, text) {
|
|
42675
42408
|
const response = String(text).trim();
|
|
42676
42409
|
let result;
|
|
42677
42410
|
if (result = initResponseRegex.exec(response)) {
|
|
42678
|
-
return new InitSummary(bare,
|
|
42411
|
+
return new InitSummary(bare, path85, false, result[1]);
|
|
42679
42412
|
}
|
|
42680
42413
|
if (result = reInitResponseRegex.exec(response)) {
|
|
42681
|
-
return new InitSummary(bare,
|
|
42414
|
+
return new InitSummary(bare, path85, true, result[1]);
|
|
42682
42415
|
}
|
|
42683
42416
|
let gitDir = "";
|
|
42684
42417
|
const tokens = response.split(" ");
|
|
@@ -42689,7 +42422,7 @@ function parseInit(bare, path88, text) {
|
|
|
42689
42422
|
break;
|
|
42690
42423
|
}
|
|
42691
42424
|
}
|
|
42692
|
-
return new InitSummary(bare,
|
|
42425
|
+
return new InitSummary(bare, path85, /^re/i.test(response), gitDir);
|
|
42693
42426
|
}
|
|
42694
42427
|
var InitSummary;
|
|
42695
42428
|
var initResponseRegex;
|
|
@@ -42698,9 +42431,9 @@ var init_InitSummary = __esm2({
|
|
|
42698
42431
|
"src/lib/responses/InitSummary.ts"() {
|
|
42699
42432
|
"use strict";
|
|
42700
42433
|
InitSummary = class {
|
|
42701
|
-
constructor(bare,
|
|
42434
|
+
constructor(bare, path85, existing, gitDir) {
|
|
42702
42435
|
this.bare = bare;
|
|
42703
|
-
this.path =
|
|
42436
|
+
this.path = path85;
|
|
42704
42437
|
this.existing = existing;
|
|
42705
42438
|
this.gitDir = gitDir;
|
|
42706
42439
|
}
|
|
@@ -42712,7 +42445,7 @@ var init_InitSummary = __esm2({
|
|
|
42712
42445
|
function hasBareCommand(command) {
|
|
42713
42446
|
return command.includes(bareCommand);
|
|
42714
42447
|
}
|
|
42715
|
-
function initTask(bare = false,
|
|
42448
|
+
function initTask(bare = false, path85, customArgs) {
|
|
42716
42449
|
const commands = ["init", ...customArgs];
|
|
42717
42450
|
if (bare && !hasBareCommand(commands)) {
|
|
42718
42451
|
commands.splice(1, 0, bareCommand);
|
|
@@ -42721,7 +42454,7 @@ function initTask(bare = false, path88, customArgs) {
|
|
|
42721
42454
|
commands,
|
|
42722
42455
|
format: "utf-8",
|
|
42723
42456
|
parser(text) {
|
|
42724
|
-
return parseInit(commands.includes("--bare"),
|
|
42457
|
+
return parseInit(commands.includes("--bare"), path85, text);
|
|
42725
42458
|
}
|
|
42726
42459
|
};
|
|
42727
42460
|
}
|
|
@@ -43537,12 +43270,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
43537
43270
|
"use strict";
|
|
43538
43271
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
43539
43272
|
FileStatusSummary = class {
|
|
43540
|
-
constructor(
|
|
43541
|
-
this.path =
|
|
43273
|
+
constructor(path85, index, working_dir) {
|
|
43274
|
+
this.path = path85;
|
|
43542
43275
|
this.index = index;
|
|
43543
43276
|
this.working_dir = working_dir;
|
|
43544
43277
|
if (index === "R" || working_dir === "R") {
|
|
43545
|
-
const detail = fromPathRegex.exec(
|
|
43278
|
+
const detail = fromPathRegex.exec(path85) || [null, path85, path85];
|
|
43546
43279
|
this.from = detail[2] || "";
|
|
43547
43280
|
this.path = detail[1] || "";
|
|
43548
43281
|
}
|
|
@@ -43573,14 +43306,14 @@ function splitLine(result, lineStr) {
|
|
|
43573
43306
|
default:
|
|
43574
43307
|
return;
|
|
43575
43308
|
}
|
|
43576
|
-
function data(index, workingDir,
|
|
43309
|
+
function data(index, workingDir, path85) {
|
|
43577
43310
|
const raw = `${index}${workingDir}`;
|
|
43578
43311
|
const handler = parsers6.get(raw);
|
|
43579
43312
|
if (handler) {
|
|
43580
|
-
handler(result,
|
|
43313
|
+
handler(result, path85);
|
|
43581
43314
|
}
|
|
43582
43315
|
if (raw !== "##" && raw !== "!!") {
|
|
43583
|
-
result.files.push(new FileStatusSummary(
|
|
43316
|
+
result.files.push(new FileStatusSummary(path85, index, workingDir));
|
|
43584
43317
|
}
|
|
43585
43318
|
}
|
|
43586
43319
|
}
|
|
@@ -43889,9 +43622,9 @@ var init_simple_git_api = __esm2({
|
|
|
43889
43622
|
next
|
|
43890
43623
|
);
|
|
43891
43624
|
}
|
|
43892
|
-
hashObject(
|
|
43625
|
+
hashObject(path85, write) {
|
|
43893
43626
|
return this._runTask(
|
|
43894
|
-
hashObjectTask(
|
|
43627
|
+
hashObjectTask(path85, write === true),
|
|
43895
43628
|
trailingFunctionArgument(arguments)
|
|
43896
43629
|
);
|
|
43897
43630
|
}
|
|
@@ -44244,8 +43977,8 @@ var init_branch = __esm2({
|
|
|
44244
43977
|
}
|
|
44245
43978
|
});
|
|
44246
43979
|
function toPath(input) {
|
|
44247
|
-
const
|
|
44248
|
-
return
|
|
43980
|
+
const path85 = input.trim().replace(/^["']|["']$/g, "");
|
|
43981
|
+
return path85 && normalize3(path85);
|
|
44249
43982
|
}
|
|
44250
43983
|
var parseCheckIgnore;
|
|
44251
43984
|
var init_CheckIgnore = __esm2({
|
|
@@ -44559,8 +44292,8 @@ __export2(sub_module_exports, {
|
|
|
44559
44292
|
subModuleTask: () => subModuleTask,
|
|
44560
44293
|
updateSubModuleTask: () => updateSubModuleTask
|
|
44561
44294
|
});
|
|
44562
|
-
function addSubModuleTask(repo,
|
|
44563
|
-
return subModuleTask(["add", repo,
|
|
44295
|
+
function addSubModuleTask(repo, path85) {
|
|
44296
|
+
return subModuleTask(["add", repo, path85]);
|
|
44564
44297
|
}
|
|
44565
44298
|
function initSubModuleTask(customArgs) {
|
|
44566
44299
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -44893,8 +44626,8 @@ var require_git = __commonJS2({
|
|
|
44893
44626
|
}
|
|
44894
44627
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
44895
44628
|
};
|
|
44896
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
44897
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
44629
|
+
Git2.prototype.submoduleAdd = function(repo, path85, then) {
|
|
44630
|
+
return this._runTask(addSubModuleTask2(repo, path85), trailingFunctionArgument2(arguments));
|
|
44898
44631
|
};
|
|
44899
44632
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
44900
44633
|
return this._runTask(
|
|
@@ -45633,8 +45366,8 @@ function parseNumstatEntries(lines) {
|
|
|
45633
45366
|
}
|
|
45634
45367
|
function parseNumstat(lines) {
|
|
45635
45368
|
const m = /* @__PURE__ */ new Map();
|
|
45636
|
-
for (const [
|
|
45637
|
-
m.set(
|
|
45369
|
+
for (const [path85, entry] of parseNumstatEntries(lines)) {
|
|
45370
|
+
m.set(path85, { additions: entry.additions, deletions: entry.deletions });
|
|
45638
45371
|
}
|
|
45639
45372
|
return m;
|
|
45640
45373
|
}
|
|
@@ -45763,7 +45496,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
45763
45496
|
}
|
|
45764
45497
|
|
|
45765
45498
|
// ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
45766
|
-
import * as
|
|
45499
|
+
import * as path40 from "node:path";
|
|
45767
45500
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
45768
45501
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
45769
45502
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -45774,7 +45507,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
45774
45507
|
}
|
|
45775
45508
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
45776
45509
|
if (repoDir) {
|
|
45777
|
-
const key =
|
|
45510
|
+
const key = path40.resolve(repoDir);
|
|
45778
45511
|
const now = Date.now();
|
|
45779
45512
|
const cached2 = baseShaCache.get(key);
|
|
45780
45513
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -45909,17 +45642,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
45909
45642
|
}
|
|
45910
45643
|
|
|
45911
45644
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
45912
|
-
import * as
|
|
45645
|
+
import * as path50 from "node:path";
|
|
45913
45646
|
|
|
45914
45647
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
45915
|
-
import * as
|
|
45648
|
+
import * as path49 from "node:path";
|
|
45916
45649
|
|
|
45917
45650
|
// ../bridge/src/git/is-git-repo.ts
|
|
45918
|
-
import * as
|
|
45919
|
-
import * as
|
|
45651
|
+
import * as fs26 from "node:fs";
|
|
45652
|
+
import * as path41 from "node:path";
|
|
45920
45653
|
async function isGitRepoDirectory(dirPath) {
|
|
45921
45654
|
try {
|
|
45922
|
-
await
|
|
45655
|
+
await fs26.promises.access(path41.join(dirPath, ".git"));
|
|
45923
45656
|
return true;
|
|
45924
45657
|
} catch {
|
|
45925
45658
|
return false;
|
|
@@ -45927,12 +45660,12 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
45927
45660
|
}
|
|
45928
45661
|
|
|
45929
45662
|
// ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
|
|
45930
|
-
import * as
|
|
45931
|
-
import * as
|
|
45663
|
+
import * as fs27 from "node:fs";
|
|
45664
|
+
import * as path42 from "node:path";
|
|
45932
45665
|
|
|
45933
45666
|
// ../bridge/src/git/changes/lines/count-lines.ts
|
|
45934
45667
|
import { createReadStream } from "node:fs";
|
|
45935
|
-
import * as
|
|
45668
|
+
import * as readline3 from "node:readline";
|
|
45936
45669
|
function countLinesInText(text) {
|
|
45937
45670
|
return splitTextIntoDiffLines(text).length;
|
|
45938
45671
|
}
|
|
@@ -45941,7 +45674,7 @@ async function countTextFileLines(filePath) {
|
|
|
45941
45674
|
const maxBytes = 512e3;
|
|
45942
45675
|
let lines = 0;
|
|
45943
45676
|
const stream = createReadStream(filePath, { encoding: "utf8" });
|
|
45944
|
-
const rl =
|
|
45677
|
+
const rl = readline3.createInterface({ input: stream, crlfDelay: Infinity });
|
|
45945
45678
|
for await (const _line of rl) {
|
|
45946
45679
|
lines += 1;
|
|
45947
45680
|
bytes += Buffer.byteLength(String(_line), "utf8") + 1;
|
|
@@ -45960,7 +45693,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45960
45693
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
45961
45694
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
45962
45695
|
if (row.change === "moved") return;
|
|
45963
|
-
const repoFilePath =
|
|
45696
|
+
const repoFilePath = path42.join(options.repoGitCwd, pathInRepo);
|
|
45964
45697
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
45965
45698
|
if (fromGit) {
|
|
45966
45699
|
row.additions = fromGit.additions;
|
|
@@ -45968,7 +45701,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45968
45701
|
return;
|
|
45969
45702
|
}
|
|
45970
45703
|
try {
|
|
45971
|
-
const st = await
|
|
45704
|
+
const st = await fs27.promises.stat(repoFilePath);
|
|
45972
45705
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
45973
45706
|
} catch {
|
|
45974
45707
|
row.additions = 0;
|
|
@@ -46045,7 +45778,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
46045
45778
|
}
|
|
46046
45779
|
|
|
46047
45780
|
// ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
46048
|
-
import * as
|
|
45781
|
+
import * as path44 from "node:path";
|
|
46049
45782
|
|
|
46050
45783
|
// ../bridge/src/git/changes/patch/patch-truncate.ts
|
|
46051
45784
|
function truncatePatch(s) {
|
|
@@ -46133,10 +45866,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
46133
45866
|
}
|
|
46134
45867
|
|
|
46135
45868
|
// ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
46136
|
-
import * as
|
|
45869
|
+
import * as fs28 from "node:fs";
|
|
46137
45870
|
async function readWorktreeFileLines(filePath) {
|
|
46138
45871
|
try {
|
|
46139
|
-
const raw = await
|
|
45872
|
+
const raw = await fs28.promises.readFile(filePath, "utf8");
|
|
46140
45873
|
return raw.split(/\r?\n/);
|
|
46141
45874
|
} catch {
|
|
46142
45875
|
return null;
|
|
@@ -46274,8 +46007,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
46274
46007
|
}
|
|
46275
46008
|
|
|
46276
46009
|
// ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
46277
|
-
import * as
|
|
46278
|
-
import * as
|
|
46010
|
+
import * as fs29 from "node:fs";
|
|
46011
|
+
import * as path43 from "node:path";
|
|
46279
46012
|
var MAX_BYTES = 512e3;
|
|
46280
46013
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
46281
46014
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -46295,13 +46028,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
46295
46028
|
}
|
|
46296
46029
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
46297
46030
|
if (options.isBinary) return null;
|
|
46298
|
-
const filePath =
|
|
46031
|
+
const filePath = path43.join(options.repoGitCwd, options.pathInRepo);
|
|
46299
46032
|
if (options.change === "removed") {
|
|
46300
46033
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
46301
46034
|
}
|
|
46302
46035
|
if (options.change === "moved" || options.change === "modified") {
|
|
46303
46036
|
try {
|
|
46304
|
-
const st = await
|
|
46037
|
+
const st = await fs29.promises.stat(filePath);
|
|
46305
46038
|
if (!st.isFile()) return null;
|
|
46306
46039
|
return await countTextFileLines(filePath);
|
|
46307
46040
|
} catch {
|
|
@@ -46344,7 +46077,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
46344
46077
|
row.workspaceRelPath,
|
|
46345
46078
|
options.repoPathRelativeToWorkspaceRoot
|
|
46346
46079
|
);
|
|
46347
|
-
const filePath =
|
|
46080
|
+
const filePath = path44.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
46348
46081
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
46349
46082
|
let patch = await unifiedDiffForFile(
|
|
46350
46083
|
options.repoGitCwd,
|
|
@@ -46502,7 +46235,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
46502
46235
|
}
|
|
46503
46236
|
|
|
46504
46237
|
// ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
|
|
46505
|
-
import * as
|
|
46238
|
+
import * as path45 from "node:path";
|
|
46506
46239
|
|
|
46507
46240
|
// ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
|
|
46508
46241
|
async function enrichCommitFileRows(options) {
|
|
@@ -46547,7 +46280,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
46547
46280
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
46548
46281
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
46549
46282
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
46550
|
-
return `${
|
|
46283
|
+
return `${path45.resolve(repoGitCwd)}:${commitSha}`;
|
|
46551
46284
|
}
|
|
46552
46285
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
46553
46286
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -46602,7 +46335,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
46602
46335
|
}
|
|
46603
46336
|
|
|
46604
46337
|
// ../bridge/src/git/commits/list-unpushed-commits.ts
|
|
46605
|
-
import * as
|
|
46338
|
+
import * as path46 from "node:path";
|
|
46606
46339
|
|
|
46607
46340
|
// ../bridge/src/git/commits/lib/parse-log-lines.ts
|
|
46608
46341
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -46637,7 +46370,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
46637
46370
|
}
|
|
46638
46371
|
}
|
|
46639
46372
|
async function listUnpushedCommits(repoDir) {
|
|
46640
|
-
const key =
|
|
46373
|
+
const key = path46.resolve(repoDir);
|
|
46641
46374
|
const now = Date.now();
|
|
46642
46375
|
const cached2 = unpushedCache.get(key);
|
|
46643
46376
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -46698,7 +46431,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
46698
46431
|
}
|
|
46699
46432
|
|
|
46700
46433
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46701
|
-
import * as
|
|
46434
|
+
import * as path47 from "node:path";
|
|
46702
46435
|
|
|
46703
46436
|
// ../bridge/src/git/remote-origin-url.ts
|
|
46704
46437
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -46713,7 +46446,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
46713
46446
|
|
|
46714
46447
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46715
46448
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
46716
|
-
const resolvedCheckoutPath =
|
|
46449
|
+
const resolvedCheckoutPath = path47.resolve(checkoutPath);
|
|
46717
46450
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
46718
46451
|
await yieldToEventLoop2();
|
|
46719
46452
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -46728,14 +46461,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
46728
46461
|
}
|
|
46729
46462
|
|
|
46730
46463
|
// ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
46731
|
-
import * as
|
|
46464
|
+
import * as path48 from "node:path";
|
|
46732
46465
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
46733
|
-
const checkoutPath =
|
|
46466
|
+
const checkoutPath = path48.resolve(options.checkoutPath);
|
|
46734
46467
|
const git = cliSimpleGit(checkoutPath);
|
|
46735
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46468
|
+
const sessionParentPath = options.sessionParentPath ? path48.resolve(options.sessionParentPath) : null;
|
|
46736
46469
|
let repoPathRelativeToWorkspaceRoot;
|
|
46737
46470
|
if (sessionParentPath) {
|
|
46738
|
-
const checkoutPathRelativeToSessionParent =
|
|
46471
|
+
const checkoutPathRelativeToSessionParent = path48.relative(sessionParentPath, checkoutPath);
|
|
46739
46472
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
46740
46473
|
} else {
|
|
46741
46474
|
let gitTopLevel = checkoutPath;
|
|
@@ -46745,8 +46478,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46745
46478
|
} catch {
|
|
46746
46479
|
gitTopLevel = checkoutPath;
|
|
46747
46480
|
}
|
|
46748
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
46749
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
46481
|
+
const gitTopLevelRelativeToBridgeRoot = path48.relative(options.bridgeRoot, path48.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
46482
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path48.basename(path48.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
46750
46483
|
}
|
|
46751
46484
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46752
46485
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -46755,10 +46488,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46755
46488
|
|
|
46756
46489
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
46757
46490
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
46758
|
-
const checkoutPath =
|
|
46491
|
+
const checkoutPath = path49.resolve(options.targetPath);
|
|
46759
46492
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
46760
46493
|
const isCommitView = options.basis.kind === "commit";
|
|
46761
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46494
|
+
const sessionParentPath = options.sessionParentPath ? path49.resolve(options.sessionParentPath) : null;
|
|
46762
46495
|
const git = cliSimpleGit(checkoutPath);
|
|
46763
46496
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46764
46497
|
checkoutPath,
|
|
@@ -46806,8 +46539,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
46806
46539
|
|
|
46807
46540
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
46808
46541
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
46809
|
-
const bridgeRoot =
|
|
46810
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46542
|
+
const bridgeRoot = path50.resolve(getBridgeRoot());
|
|
46543
|
+
const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
|
|
46811
46544
|
const out = [];
|
|
46812
46545
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
46813
46546
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -46838,9 +46571,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
46838
46571
|
}
|
|
46839
46572
|
|
|
46840
46573
|
// ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
46841
|
-
import * as
|
|
46574
|
+
import * as path51 from "node:path";
|
|
46842
46575
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
46843
|
-
const repoGitCwd =
|
|
46576
|
+
const repoGitCwd = path51.resolve(options.repoGitCwd);
|
|
46844
46577
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
46845
46578
|
throw new Error("Not a git repository");
|
|
46846
46579
|
}
|
|
@@ -46879,7 +46612,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
46879
46612
|
});
|
|
46880
46613
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
46881
46614
|
}
|
|
46882
|
-
const filePath =
|
|
46615
|
+
const filePath = path51.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
46883
46616
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
46884
46617
|
let patchContent = await unifiedDiffForFile(
|
|
46885
46618
|
repoGitCwd,
|
|
@@ -46925,18 +46658,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
46925
46658
|
}
|
|
46926
46659
|
|
|
46927
46660
|
// ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
46928
|
-
import * as
|
|
46661
|
+
import * as path52 from "node:path";
|
|
46929
46662
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
46930
46663
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
46931
|
-
const bridgeRoot =
|
|
46932
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
46664
|
+
const bridgeRoot = path52.resolve(getBridgeRoot());
|
|
46665
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path52.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
46933
46666
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46934
46667
|
opts.repoRelPath.trim()
|
|
46935
46668
|
);
|
|
46936
46669
|
let result = null;
|
|
46937
46670
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
46938
46671
|
if (result) return;
|
|
46939
|
-
const checkoutPath =
|
|
46672
|
+
const checkoutPath = path52.resolve(targetPath);
|
|
46940
46673
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
46941
46674
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46942
46675
|
checkoutPath,
|
|
@@ -46969,13 +46702,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
46969
46702
|
}
|
|
46970
46703
|
|
|
46971
46704
|
// ../bridge/src/worktrees/remove-session-worktrees.ts
|
|
46972
|
-
import * as
|
|
46705
|
+
import * as fs32 from "node:fs";
|
|
46973
46706
|
|
|
46974
46707
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
46975
|
-
import * as
|
|
46708
|
+
import * as fs31 from "node:fs";
|
|
46976
46709
|
|
|
46977
46710
|
// ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
46978
|
-
import
|
|
46711
|
+
import path53 from "node:path";
|
|
46979
46712
|
init_normalize_resolved_path();
|
|
46980
46713
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
46981
46714
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -46984,23 +46717,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
46984
46717
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
46985
46718
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
46986
46719
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
46987
|
-
const rel =
|
|
46988
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
46720
|
+
const rel = path53.relative(worktreesRoot, normalized);
|
|
46721
|
+
if (rel === "" || rel.startsWith("..") || path53.isAbsolute(rel)) return false;
|
|
46989
46722
|
return true;
|
|
46990
46723
|
}
|
|
46991
46724
|
|
|
46992
46725
|
// ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
46993
|
-
import * as
|
|
46994
|
-
import * as
|
|
46726
|
+
import * as fs30 from "node:fs";
|
|
46727
|
+
import * as path54 from "node:path";
|
|
46995
46728
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
46996
|
-
const gitDirFile =
|
|
46997
|
-
if (!
|
|
46998
|
-
const first2 =
|
|
46729
|
+
const gitDirFile = path54.join(wt, ".git");
|
|
46730
|
+
if (!fs30.existsSync(gitDirFile) || !fs30.statSync(gitDirFile).isFile()) return "";
|
|
46731
|
+
const first2 = fs30.readFileSync(gitDirFile, "utf8").trim();
|
|
46999
46732
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
47000
46733
|
if (!m) return "";
|
|
47001
|
-
const gitWorktreePath =
|
|
47002
|
-
const gitDir =
|
|
47003
|
-
return
|
|
46734
|
+
const gitWorktreePath = path54.resolve(wt, m[1].trim());
|
|
46735
|
+
const gitDir = path54.dirname(path54.dirname(gitWorktreePath));
|
|
46736
|
+
return path54.dirname(gitDir);
|
|
47004
46737
|
}
|
|
47005
46738
|
|
|
47006
46739
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
@@ -47011,7 +46744,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
47011
46744
|
return true;
|
|
47012
46745
|
}
|
|
47013
46746
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
47014
|
-
|
|
46747
|
+
fs31.rmSync(worktreePath, { recursive: true, force: true });
|
|
47015
46748
|
return true;
|
|
47016
46749
|
}
|
|
47017
46750
|
|
|
@@ -47033,7 +46766,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
47033
46766
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
47034
46767
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
47035
46768
|
try {
|
|
47036
|
-
|
|
46769
|
+
fs32.rmSync(wt, { recursive: true, force: true });
|
|
47037
46770
|
} catch {
|
|
47038
46771
|
}
|
|
47039
46772
|
}
|
|
@@ -47089,12 +46822,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
47089
46822
|
// ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
47090
46823
|
init_cli_process_interrupt();
|
|
47091
46824
|
init_yield_to_event_loop();
|
|
47092
|
-
import * as
|
|
47093
|
-
import * as
|
|
46825
|
+
import * as fs36 from "node:fs";
|
|
46826
|
+
import * as path59 from "node:path";
|
|
47094
46827
|
|
|
47095
46828
|
// ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
|
|
47096
|
-
import * as
|
|
47097
|
-
import * as
|
|
46829
|
+
import * as fs34 from "node:fs";
|
|
46830
|
+
import * as path56 from "node:path";
|
|
47098
46831
|
|
|
47099
46832
|
// ../bridge/src/worktrees/discovery/disk-walk-constants.ts
|
|
47100
46833
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -47124,8 +46857,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
47124
46857
|
// ../bridge/src/worktrees/discovery/disk-walk-utils.ts
|
|
47125
46858
|
init_cli_process_interrupt();
|
|
47126
46859
|
init_yield_to_event_loop();
|
|
47127
|
-
import * as
|
|
47128
|
-
import * as
|
|
46860
|
+
import * as fs33 from "node:fs";
|
|
46861
|
+
import * as path55 from "node:path";
|
|
47129
46862
|
async function yieldDuringDiskWalk(state) {
|
|
47130
46863
|
state.entries++;
|
|
47131
46864
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -47135,7 +46868,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
47135
46868
|
}
|
|
47136
46869
|
async function isGitDir(dirPath) {
|
|
47137
46870
|
try {
|
|
47138
|
-
await
|
|
46871
|
+
await fs33.promises.access(path55.join(dirPath, ".git"));
|
|
47139
46872
|
return true;
|
|
47140
46873
|
} catch {
|
|
47141
46874
|
return false;
|
|
@@ -47149,23 +46882,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
47149
46882
|
const walk = async (dir) => {
|
|
47150
46883
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47151
46884
|
if (await isGitDir(dir)) {
|
|
47152
|
-
out.push(
|
|
46885
|
+
out.push(path56.resolve(dir));
|
|
47153
46886
|
return;
|
|
47154
46887
|
}
|
|
47155
46888
|
let entries;
|
|
47156
46889
|
try {
|
|
47157
|
-
entries = await
|
|
46890
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
47158
46891
|
} catch {
|
|
47159
46892
|
return;
|
|
47160
46893
|
}
|
|
47161
46894
|
for (const e of entries) {
|
|
47162
46895
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47163
|
-
const full =
|
|
46896
|
+
const full = path56.join(dir, e.name);
|
|
47164
46897
|
if (!e.isDirectory()) continue;
|
|
47165
46898
|
await walk(full);
|
|
47166
46899
|
}
|
|
47167
46900
|
};
|
|
47168
|
-
await walk(
|
|
46901
|
+
await walk(path56.resolve(rootPath));
|
|
47169
46902
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
47170
46903
|
}
|
|
47171
46904
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -47176,16 +46909,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47176
46909
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47177
46910
|
let entries;
|
|
47178
46911
|
try {
|
|
47179
|
-
entries = await
|
|
46912
|
+
entries = await fs34.promises.readdir(dir, { withFileTypes: true });
|
|
47180
46913
|
} catch {
|
|
47181
46914
|
return;
|
|
47182
46915
|
}
|
|
47183
46916
|
for (const e of entries) {
|
|
47184
46917
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47185
|
-
const full =
|
|
46918
|
+
const full = path56.join(dir, e.name);
|
|
47186
46919
|
if (!e.isDirectory()) continue;
|
|
47187
46920
|
if (e.name === sessionId) {
|
|
47188
|
-
if (await isGitDir(full)) out.push(
|
|
46921
|
+
if (await isGitDir(full)) out.push(path56.resolve(full));
|
|
47189
46922
|
continue;
|
|
47190
46923
|
}
|
|
47191
46924
|
if (await isGitDir(full)) continue;
|
|
@@ -47197,14 +46930,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47197
46930
|
}
|
|
47198
46931
|
|
|
47199
46932
|
// ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
47200
|
-
import * as
|
|
46933
|
+
import * as path57 from "node:path";
|
|
47201
46934
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
47202
|
-
const bridge =
|
|
46935
|
+
const bridge = path57.resolve(bridgeRoot);
|
|
47203
46936
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
47204
46937
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
47205
|
-
const entry =
|
|
47206
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
47207
|
-
}).sort((a, b) =>
|
|
46938
|
+
const entry = path57.resolve(e.absolutePath);
|
|
46939
|
+
return bridge === entry || bridge.startsWith(entry + path57.sep) || entry.startsWith(bridge + path57.sep);
|
|
46940
|
+
}).sort((a, b) => path57.resolve(b.absolutePath).length - path57.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
47208
46941
|
const ordered = [];
|
|
47209
46942
|
const seen = /* @__PURE__ */ new Set();
|
|
47210
46943
|
const add = (k) => {
|
|
@@ -47222,19 +46955,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
47222
46955
|
}
|
|
47223
46956
|
|
|
47224
46957
|
// ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
47225
|
-
import * as
|
|
47226
|
-
import * as
|
|
46958
|
+
import * as fs35 from "node:fs";
|
|
46959
|
+
import * as path58 from "node:path";
|
|
47227
46960
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
47228
46961
|
let st;
|
|
47229
46962
|
try {
|
|
47230
|
-
st = await
|
|
46963
|
+
st = await fs35.promises.stat(scopeDir);
|
|
47231
46964
|
} catch {
|
|
47232
46965
|
return null;
|
|
47233
46966
|
}
|
|
47234
46967
|
if (!st.isDirectory()) return null;
|
|
47235
46968
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
47236
46969
|
if (worktreePaths.length === 0) return null;
|
|
47237
|
-
const abs =
|
|
46970
|
+
const abs = path58.resolve(scopeDir);
|
|
47238
46971
|
return {
|
|
47239
46972
|
parentPath: abs,
|
|
47240
46973
|
repoCheckoutPaths: worktreePaths
|
|
@@ -47257,7 +46990,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47257
46990
|
const sid = sessionId.trim();
|
|
47258
46991
|
if (!sid) return null;
|
|
47259
46992
|
try {
|
|
47260
|
-
await
|
|
46993
|
+
await fs36.promises.access(worktreesRootPath);
|
|
47261
46994
|
} catch {
|
|
47262
46995
|
return null;
|
|
47263
46996
|
}
|
|
@@ -47266,13 +46999,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47266
46999
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47267
47000
|
const scanState = { entries: 0 };
|
|
47268
47001
|
try {
|
|
47269
|
-
for (const name of await
|
|
47002
|
+
for (const name of await fs36.promises.readdir(worktreesRootPath)) {
|
|
47270
47003
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47271
47004
|
if (name.startsWith(".")) continue;
|
|
47272
|
-
const p =
|
|
47005
|
+
const p = path59.join(worktreesRootPath, name);
|
|
47273
47006
|
let st;
|
|
47274
47007
|
try {
|
|
47275
|
-
st = await
|
|
47008
|
+
st = await fs36.promises.stat(p);
|
|
47276
47009
|
} catch {
|
|
47277
47010
|
continue;
|
|
47278
47011
|
}
|
|
@@ -47286,23 +47019,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47286
47019
|
for (const key of keys) {
|
|
47287
47020
|
if (isCliImmediateShutdownRequested()) return null;
|
|
47288
47021
|
await yieldToEventLoop();
|
|
47289
|
-
const layoutRoot =
|
|
47022
|
+
const layoutRoot = path59.join(worktreesRootPath, key);
|
|
47290
47023
|
let layoutSt;
|
|
47291
47024
|
try {
|
|
47292
|
-
layoutSt = await
|
|
47025
|
+
layoutSt = await fs36.promises.stat(layoutRoot);
|
|
47293
47026
|
} catch {
|
|
47294
47027
|
continue;
|
|
47295
47028
|
}
|
|
47296
47029
|
if (!layoutSt.isDirectory()) continue;
|
|
47297
|
-
const sessionDir =
|
|
47030
|
+
const sessionDir = path59.join(layoutRoot, sid);
|
|
47298
47031
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
47299
47032
|
if (nested) return nested;
|
|
47300
47033
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
47301
47034
|
if (legacy.paths.length > 0) {
|
|
47302
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
47035
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path59.resolve(legacy.paths[0]);
|
|
47303
47036
|
return {
|
|
47304
|
-
sessionParentPath:
|
|
47305
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
47037
|
+
sessionParentPath: path59.resolve(isolated),
|
|
47038
|
+
repoCheckoutPaths: legacy.paths.map((p) => path59.resolve(p))
|
|
47306
47039
|
};
|
|
47307
47040
|
}
|
|
47308
47041
|
}
|
|
@@ -47310,31 +47043,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47310
47043
|
}
|
|
47311
47044
|
|
|
47312
47045
|
// ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
47313
|
-
import * as
|
|
47314
|
-
import * as
|
|
47046
|
+
import * as fs37 from "node:fs";
|
|
47047
|
+
import * as path61 from "node:path";
|
|
47315
47048
|
|
|
47316
47049
|
// ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
47317
47050
|
init_cli_process_interrupt();
|
|
47318
47051
|
init_yield_to_event_loop();
|
|
47319
|
-
import * as
|
|
47052
|
+
import * as path60 from "node:path";
|
|
47320
47053
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
47321
47054
|
const sid = sessionId.trim();
|
|
47322
47055
|
if (!sid) return null;
|
|
47323
|
-
const hintR =
|
|
47056
|
+
const hintR = path60.resolve(checkoutPath);
|
|
47324
47057
|
let best = null;
|
|
47325
|
-
let cur =
|
|
47058
|
+
let cur = path60.dirname(hintR);
|
|
47326
47059
|
for (let i = 0; i < 40; i++) {
|
|
47327
47060
|
if (isCliImmediateShutdownRequested()) return best;
|
|
47328
47061
|
await yieldToEventLoop();
|
|
47329
47062
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
47330
|
-
if (paths.paths.some((p) =>
|
|
47331
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
47063
|
+
if (paths.paths.some((p) => path60.resolve(p) === hintR)) {
|
|
47064
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path60.resolve(paths.paths[0]);
|
|
47332
47065
|
best = {
|
|
47333
|
-
sessionParentPath:
|
|
47334
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
47066
|
+
sessionParentPath: path60.resolve(isolated),
|
|
47067
|
+
repoCheckoutPaths: paths.paths.map((p) => path60.resolve(p))
|
|
47335
47068
|
};
|
|
47336
47069
|
}
|
|
47337
|
-
const next =
|
|
47070
|
+
const next = path60.dirname(cur);
|
|
47338
47071
|
if (next === cur) break;
|
|
47339
47072
|
cur = next;
|
|
47340
47073
|
}
|
|
@@ -47345,12 +47078,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
47345
47078
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
47346
47079
|
const sid = sessionId.trim();
|
|
47347
47080
|
if (!sid) return null;
|
|
47348
|
-
const hint =
|
|
47349
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
47081
|
+
const hint = path61.resolve(sessionParentPathOrHint);
|
|
47082
|
+
const underHint = await tryBindingFromSessionDirectory(path61.join(hint, sid));
|
|
47350
47083
|
if (underHint) return underHint;
|
|
47351
47084
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
47352
47085
|
if (direct) {
|
|
47353
|
-
if (
|
|
47086
|
+
if (path61.basename(hint) === sid && await isGitDir(hint)) {
|
|
47354
47087
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47355
47088
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
47356
47089
|
return legacyFromCheckout;
|
|
@@ -47358,23 +47091,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
47358
47091
|
}
|
|
47359
47092
|
return direct;
|
|
47360
47093
|
}
|
|
47361
|
-
if (
|
|
47094
|
+
if (path61.basename(hint) === sid && await isGitDir(hint)) {
|
|
47362
47095
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47363
47096
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
47364
47097
|
}
|
|
47365
47098
|
let st;
|
|
47366
47099
|
try {
|
|
47367
|
-
st = await
|
|
47100
|
+
st = await fs37.promises.stat(hint);
|
|
47368
47101
|
} catch {
|
|
47369
47102
|
return null;
|
|
47370
47103
|
}
|
|
47371
47104
|
if (!st.isDirectory()) return null;
|
|
47372
47105
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
47373
47106
|
if (legacyPaths.paths.length === 0) return null;
|
|
47374
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
47107
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path61.resolve(legacyPaths.paths[0]);
|
|
47375
47108
|
return {
|
|
47376
|
-
sessionParentPath:
|
|
47377
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
47109
|
+
sessionParentPath: path61.resolve(isolated),
|
|
47110
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path61.resolve(p))
|
|
47378
47111
|
};
|
|
47379
47112
|
}
|
|
47380
47113
|
|
|
@@ -47435,11 +47168,11 @@ function parseSessionParent(v) {
|
|
|
47435
47168
|
}
|
|
47436
47169
|
|
|
47437
47170
|
// ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
47438
|
-
import * as
|
|
47171
|
+
import * as fs41 from "node:fs";
|
|
47439
47172
|
|
|
47440
47173
|
// ../bridge/src/git/discover-repos.ts
|
|
47441
|
-
import * as
|
|
47442
|
-
import * as
|
|
47174
|
+
import * as fs38 from "node:fs";
|
|
47175
|
+
import * as path62 from "node:path";
|
|
47443
47176
|
init_yield_to_event_loop();
|
|
47444
47177
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
47445
47178
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -47449,14 +47182,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
47449
47182
|
}
|
|
47450
47183
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
47451
47184
|
const result = [];
|
|
47452
|
-
const cwdResolved =
|
|
47185
|
+
const cwdResolved = path62.resolve(cwd);
|
|
47453
47186
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
47454
47187
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
47455
47188
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
47456
47189
|
}
|
|
47457
47190
|
let entries;
|
|
47458
47191
|
try {
|
|
47459
|
-
entries =
|
|
47192
|
+
entries = fs38.readdirSync(cwdResolved, { withFileTypes: true });
|
|
47460
47193
|
} catch {
|
|
47461
47194
|
return result;
|
|
47462
47195
|
}
|
|
@@ -47464,7 +47197,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47464
47197
|
await yieldGitDiscoverWork(i + 1);
|
|
47465
47198
|
const ent = entries[i];
|
|
47466
47199
|
if (!ent.isDirectory()) continue;
|
|
47467
|
-
const childPath2 =
|
|
47200
|
+
const childPath2 = path62.join(cwdResolved, ent.name);
|
|
47468
47201
|
if (await isGitRepoDirectory(childPath2)) {
|
|
47469
47202
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
47470
47203
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -47473,17 +47206,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47473
47206
|
return result;
|
|
47474
47207
|
}
|
|
47475
47208
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
47476
|
-
const root =
|
|
47209
|
+
const root = path62.resolve(rootPath);
|
|
47477
47210
|
const roots = [];
|
|
47478
47211
|
let walkEntries = 0;
|
|
47479
47212
|
async function walk(dir) {
|
|
47480
47213
|
if (await isGitRepoDirectory(dir)) {
|
|
47481
|
-
roots.push(
|
|
47214
|
+
roots.push(path62.resolve(dir));
|
|
47482
47215
|
return;
|
|
47483
47216
|
}
|
|
47484
47217
|
let entries;
|
|
47485
47218
|
try {
|
|
47486
|
-
entries =
|
|
47219
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
47487
47220
|
} catch {
|
|
47488
47221
|
return;
|
|
47489
47222
|
}
|
|
@@ -47491,7 +47224,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47491
47224
|
await yieldGitDiscoverWork(++walkEntries);
|
|
47492
47225
|
const ent = entries[i];
|
|
47493
47226
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
47494
|
-
await walk(
|
|
47227
|
+
await walk(path62.join(dir, ent.name));
|
|
47495
47228
|
}
|
|
47496
47229
|
}
|
|
47497
47230
|
await walk(root);
|
|
@@ -47507,8 +47240,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47507
47240
|
}
|
|
47508
47241
|
|
|
47509
47242
|
// ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
47510
|
-
import * as
|
|
47511
|
-
import * as
|
|
47243
|
+
import * as fs40 from "node:fs";
|
|
47244
|
+
import * as path64 from "node:path";
|
|
47512
47245
|
|
|
47513
47246
|
// ../bridge/src/git/worktrees/worktree-add.ts
|
|
47514
47247
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -47524,8 +47257,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
47524
47257
|
}
|
|
47525
47258
|
|
|
47526
47259
|
// ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
47527
|
-
import * as
|
|
47528
|
-
import * as
|
|
47260
|
+
import * as fs39 from "node:fs";
|
|
47261
|
+
import * as path63 from "node:path";
|
|
47529
47262
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
47530
47263
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
47531
47264
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -47534,19 +47267,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
47534
47267
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
47535
47268
|
for (let i = 0; i < segments.length; i++) {
|
|
47536
47269
|
const prefix = segments.slice(0, i).join("/");
|
|
47537
|
-
const bridgeDir = prefix ?
|
|
47538
|
-
const destDir = prefix ?
|
|
47270
|
+
const bridgeDir = prefix ? path63.join(bridgeRoot, prefix) : bridgeRoot;
|
|
47271
|
+
const destDir = prefix ? path63.join(scopeDir, prefix) : scopeDir;
|
|
47539
47272
|
for (const fileName of fileNames) {
|
|
47540
47273
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
47541
47274
|
}
|
|
47542
47275
|
}
|
|
47543
47276
|
}
|
|
47544
47277
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
47545
|
-
const src =
|
|
47546
|
-
if (!
|
|
47547
|
-
const dest =
|
|
47278
|
+
const src = path63.join(srcDir, fileName);
|
|
47279
|
+
if (!fs39.existsSync(src)) return;
|
|
47280
|
+
const dest = path63.join(destDir, fileName);
|
|
47548
47281
|
try {
|
|
47549
|
-
|
|
47282
|
+
fs39.copyFileSync(src, dest);
|
|
47550
47283
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
47551
47284
|
} catch (e) {
|
|
47552
47285
|
log2?.(
|
|
@@ -47578,16 +47311,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47578
47311
|
worktreeBaseBranches,
|
|
47579
47312
|
log: log2
|
|
47580
47313
|
} = options;
|
|
47581
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
47582
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
47314
|
+
const repoPathRelativeToBridgeRootRaw = path64.relative(bridgeResolved, repoAbsolutePath);
|
|
47315
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path64.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
47583
47316
|
return null;
|
|
47584
47317
|
}
|
|
47585
47318
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
47586
47319
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
47587
47320
|
);
|
|
47588
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
47321
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path64.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
47589
47322
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
47590
|
-
|
|
47323
|
+
fs40.mkdirSync(path64.dirname(worktreePath), { recursive: true });
|
|
47591
47324
|
copyBridgeFilesAlongWorktreePath({
|
|
47592
47325
|
bridgeRoot: bridgeResolved,
|
|
47593
47326
|
scopeDir,
|
|
@@ -47615,7 +47348,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47615
47348
|
}
|
|
47616
47349
|
|
|
47617
47350
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47618
|
-
import * as
|
|
47351
|
+
import * as path65 from "node:path";
|
|
47619
47352
|
|
|
47620
47353
|
// ../bridge/src/worktrees/worktree-layout-kind.ts
|
|
47621
47354
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -47645,10 +47378,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
47645
47378
|
|
|
47646
47379
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47647
47380
|
function resolveIsolatedScopeDir(options) {
|
|
47648
|
-
const bridgeResolved =
|
|
47381
|
+
const bridgeResolved = path65.resolve(options.bridgeRoot);
|
|
47649
47382
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
47650
|
-
const bridgeKeyDir =
|
|
47651
|
-
const scopeDir =
|
|
47383
|
+
const bridgeKeyDir = path65.join(options.worktreesRootPath, cwdKey);
|
|
47384
|
+
const scopeDir = path65.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
47652
47385
|
return { bridgeResolved, scopeDir };
|
|
47653
47386
|
}
|
|
47654
47387
|
|
|
@@ -47678,7 +47411,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
47678
47411
|
return null;
|
|
47679
47412
|
}
|
|
47680
47413
|
const worktreePaths = [];
|
|
47681
|
-
|
|
47414
|
+
fs41.mkdirSync(scopeDir, { recursive: true });
|
|
47682
47415
|
await forEachWithGitYield(repos, async (repo) => {
|
|
47683
47416
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
47684
47417
|
kind,
|
|
@@ -47750,10 +47483,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
47750
47483
|
}
|
|
47751
47484
|
|
|
47752
47485
|
// ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
47753
|
-
import * as
|
|
47486
|
+
import * as path66 from "node:path";
|
|
47754
47487
|
init_yield_to_event_loop();
|
|
47755
47488
|
async function resolveExplicitSessionParentPath(params) {
|
|
47756
|
-
const resolved =
|
|
47489
|
+
const resolved = path66.resolve(params.parentPathRaw);
|
|
47757
47490
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
47758
47491
|
return resolved;
|
|
47759
47492
|
}
|
|
@@ -47770,7 +47503,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
47770
47503
|
await yieldToEventLoop();
|
|
47771
47504
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
47772
47505
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
47773
|
-
const next =
|
|
47506
|
+
const next = path66.dirname(cur);
|
|
47774
47507
|
if (next === cur) break;
|
|
47775
47508
|
cur = next;
|
|
47776
47509
|
}
|
|
@@ -47931,15 +47664,15 @@ var SessionWorktreeManager = class {
|
|
|
47931
47664
|
};
|
|
47932
47665
|
|
|
47933
47666
|
// ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
47934
|
-
import * as
|
|
47935
|
-
import * as
|
|
47667
|
+
import * as fs42 from "node:fs";
|
|
47668
|
+
import * as path67 from "node:path";
|
|
47936
47669
|
init_yield_to_event_loop();
|
|
47937
47670
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
47938
47671
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
47939
47672
|
const eid = environmentId.trim();
|
|
47940
47673
|
if (!eid) return null;
|
|
47941
47674
|
try {
|
|
47942
|
-
await
|
|
47675
|
+
await fs42.promises.access(worktreesRootPath);
|
|
47943
47676
|
} catch {
|
|
47944
47677
|
return null;
|
|
47945
47678
|
}
|
|
@@ -47948,13 +47681,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47948
47681
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47949
47682
|
const scanState = { entries: 0 };
|
|
47950
47683
|
try {
|
|
47951
|
-
for (const name of await
|
|
47684
|
+
for (const name of await fs42.promises.readdir(worktreesRootPath)) {
|
|
47952
47685
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47953
47686
|
if (name.startsWith(".")) continue;
|
|
47954
|
-
const p =
|
|
47687
|
+
const p = path67.join(worktreesRootPath, name);
|
|
47955
47688
|
let st;
|
|
47956
47689
|
try {
|
|
47957
|
-
st = await
|
|
47690
|
+
st = await fs42.promises.stat(p);
|
|
47958
47691
|
} catch {
|
|
47959
47692
|
continue;
|
|
47960
47693
|
}
|
|
@@ -47968,7 +47701,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47968
47701
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
47969
47702
|
for (const key of keys) {
|
|
47970
47703
|
await yieldToEventLoop();
|
|
47971
|
-
const previewDir =
|
|
47704
|
+
const previewDir = path67.join(worktreesRootPath, key, ...previewDirRel);
|
|
47972
47705
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
47973
47706
|
if (binding) return binding;
|
|
47974
47707
|
}
|
|
@@ -48095,7 +47828,7 @@ var PreviewWorktreeManager = class {
|
|
|
48095
47828
|
};
|
|
48096
47829
|
|
|
48097
47830
|
// ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
48098
|
-
import * as
|
|
47831
|
+
import * as path71 from "node:path";
|
|
48099
47832
|
|
|
48100
47833
|
// ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
|
|
48101
47834
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -48106,8 +47839,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
48106
47839
|
}
|
|
48107
47840
|
|
|
48108
47841
|
// ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
|
|
48109
|
-
import * as
|
|
48110
|
-
import * as
|
|
47842
|
+
import * as fs43 from "node:fs";
|
|
47843
|
+
import * as path68 from "node:path";
|
|
48111
47844
|
|
|
48112
47845
|
// ../bridge/src/git/is-not-a-git-repository-error.ts
|
|
48113
47846
|
function isNotAGitRepositoryError(e) {
|
|
@@ -48169,12 +47902,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48169
47902
|
if (!ap.ok) return ap;
|
|
48170
47903
|
}
|
|
48171
47904
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
48172
|
-
const src =
|
|
48173
|
-
const dst =
|
|
47905
|
+
const src = path68.join(sourceRepoPath, rel);
|
|
47906
|
+
const dst = path68.join(targetRepoPath, rel);
|
|
48174
47907
|
try {
|
|
48175
|
-
if (!
|
|
48176
|
-
|
|
48177
|
-
|
|
47908
|
+
if (!fs43.existsSync(src)) return;
|
|
47909
|
+
fs43.mkdirSync(path68.dirname(dst), { recursive: true });
|
|
47910
|
+
fs43.copyFileSync(src, dst);
|
|
48178
47911
|
} catch (e) {
|
|
48179
47912
|
log2(
|
|
48180
47913
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -48185,14 +47918,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48185
47918
|
}
|
|
48186
47919
|
|
|
48187
47920
|
// ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
48188
|
-
import * as
|
|
47921
|
+
import * as path69 from "node:path";
|
|
48189
47922
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
48190
47923
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
48191
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
47924
|
+
const resolvedSessionParentPath = sessionParentPath ? path69.resolve(sessionParentPath) : null;
|
|
48192
47925
|
let match = null;
|
|
48193
47926
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
48194
47927
|
if (match) return;
|
|
48195
|
-
const resolvedCheckoutPath =
|
|
47928
|
+
const resolvedCheckoutPath = path69.resolve(checkoutPath);
|
|
48196
47929
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
48197
47930
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48198
47931
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -48246,7 +47979,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
48246
47979
|
}
|
|
48247
47980
|
|
|
48248
47981
|
// ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
48249
|
-
import * as
|
|
47982
|
+
import * as path70 from "node:path";
|
|
48250
47983
|
|
|
48251
47984
|
// ../bridge/src/git/branches/create-or-update-branch.ts
|
|
48252
47985
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -48283,19 +48016,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
48283
48016
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
48284
48017
|
const states = [];
|
|
48285
48018
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
48286
|
-
const checkoutPath =
|
|
48019
|
+
const checkoutPath = path70.resolve(sessionCheckout);
|
|
48287
48020
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
48288
48021
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48289
48022
|
checkoutPath,
|
|
48290
48023
|
bridgeRoot,
|
|
48291
|
-
sessionParentPath: sessionParentPath ?
|
|
48024
|
+
sessionParentPath: sessionParentPath ? path70.resolve(sessionParentPath) : null
|
|
48292
48025
|
});
|
|
48293
48026
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
48294
48027
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
48295
48028
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
48296
48029
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
48297
48030
|
checkoutPaths: previewCheckoutPaths,
|
|
48298
|
-
sessionParentPath: previewParentPath ?
|
|
48031
|
+
sessionParentPath: previewParentPath ? path70.resolve(previewParentPath) : null,
|
|
48299
48032
|
bridgeRoot,
|
|
48300
48033
|
repoPathRelativeToWorkspaceRoot
|
|
48301
48034
|
}) : null;
|
|
@@ -48315,7 +48048,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48315
48048
|
const eid = options.environmentId.trim();
|
|
48316
48049
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
48317
48050
|
const deployBranch = previewDeployBranchName(eid);
|
|
48318
|
-
const bridgeRoot =
|
|
48051
|
+
const bridgeRoot = path71.resolve(getBridgeRoot());
|
|
48319
48052
|
await previewWorktreeManager.ensureCached(eid);
|
|
48320
48053
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
48321
48054
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -48355,13 +48088,13 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48355
48088
|
}
|
|
48356
48089
|
|
|
48357
48090
|
// ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
|
|
48358
|
-
import * as
|
|
48091
|
+
import * as path72 from "node:path";
|
|
48359
48092
|
import os8 from "node:os";
|
|
48360
48093
|
function defaultWorktreesRootPath() {
|
|
48361
|
-
return
|
|
48094
|
+
return path72.join(os8.homedir(), ".buildautomaton", "worktrees");
|
|
48362
48095
|
}
|
|
48363
48096
|
|
|
48364
|
-
// ../bridge/src/connection/create-bridge-worktree-managers.ts
|
|
48097
|
+
// ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
|
|
48365
48098
|
function createBridgeWorktreeManagers(options) {
|
|
48366
48099
|
const worktreesRootPath = options.worktreesRootPath ?? defaultWorktreesRootPath();
|
|
48367
48100
|
return {
|
|
@@ -48483,14 +48216,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
48483
48216
|
}
|
|
48484
48217
|
|
|
48485
48218
|
// ../bridge/src/files/list-dir/index.ts
|
|
48486
|
-
import
|
|
48219
|
+
import fs45 from "node:fs";
|
|
48487
48220
|
|
|
48488
48221
|
// ../bridge/src/files/ensure-under-cwd.ts
|
|
48489
|
-
import
|
|
48222
|
+
import path73 from "node:path";
|
|
48490
48223
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
48491
|
-
const normalized =
|
|
48492
|
-
const resolved =
|
|
48493
|
-
if (!resolved.startsWith(cwd +
|
|
48224
|
+
const normalized = path73.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
48225
|
+
const resolved = path73.resolve(cwd, normalized);
|
|
48226
|
+
if (!resolved.startsWith(cwd + path73.sep) && resolved !== cwd) {
|
|
48494
48227
|
return null;
|
|
48495
48228
|
}
|
|
48496
48229
|
return resolved;
|
|
@@ -48503,15 +48236,15 @@ init_yield_to_event_loop();
|
|
|
48503
48236
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
48504
48237
|
|
|
48505
48238
|
// ../bridge/src/files/list-dir/map-dir-entry.ts
|
|
48506
|
-
import
|
|
48507
|
-
import
|
|
48239
|
+
import path74 from "node:path";
|
|
48240
|
+
import fs44 from "node:fs";
|
|
48508
48241
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
48509
|
-
const entryPath =
|
|
48510
|
-
const fullPath =
|
|
48242
|
+
const entryPath = path74.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
48243
|
+
const fullPath = path74.join(resolved, d.name);
|
|
48511
48244
|
let isDir = d.isDirectory();
|
|
48512
48245
|
if (d.isSymbolicLink()) {
|
|
48513
48246
|
try {
|
|
48514
|
-
const targetStat = await
|
|
48247
|
+
const targetStat = await fs44.promises.stat(fullPath);
|
|
48515
48248
|
isDir = targetStat.isDirectory();
|
|
48516
48249
|
} catch {
|
|
48517
48250
|
isDir = false;
|
|
@@ -48541,7 +48274,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48541
48274
|
return { error: "Path is outside working directory" };
|
|
48542
48275
|
}
|
|
48543
48276
|
try {
|
|
48544
|
-
const names = await
|
|
48277
|
+
const names = await fs45.promises.readdir(resolved, { withFileTypes: true });
|
|
48545
48278
|
const entries = [];
|
|
48546
48279
|
for (let i = 0; i < names.length; i++) {
|
|
48547
48280
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -48557,13 +48290,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48557
48290
|
}
|
|
48558
48291
|
|
|
48559
48292
|
// ../bridge/src/git/tree/resolve-repo-abs-path.ts
|
|
48560
|
-
import * as
|
|
48293
|
+
import * as path75 from "node:path";
|
|
48561
48294
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
48562
|
-
const bridgeResolved =
|
|
48295
|
+
const bridgeResolved = path75.resolve(bridgeRoot);
|
|
48563
48296
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
48564
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
48565
|
-
const resolved =
|
|
48566
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
48297
|
+
const repoPath = rel === "" ? bridgeResolved : path75.join(bridgeResolved, rel);
|
|
48298
|
+
const resolved = path75.resolve(repoPath);
|
|
48299
|
+
if (!resolved.startsWith(bridgeResolved + path75.sep) && resolved !== bridgeResolved) {
|
|
48567
48300
|
return null;
|
|
48568
48301
|
}
|
|
48569
48302
|
return resolved;
|
|
@@ -49044,25 +48777,25 @@ async function GET2(ctx) {
|
|
|
49044
48777
|
init_in_flight();
|
|
49045
48778
|
|
|
49046
48779
|
// ../bridge/src/files/read/read-file-async.ts
|
|
49047
|
-
import
|
|
48780
|
+
import fs51 from "node:fs";
|
|
49048
48781
|
init_yield_to_event_loop();
|
|
49049
48782
|
|
|
49050
48783
|
// ../bridge/src/files/read/resolve-file-cache.ts
|
|
49051
|
-
import
|
|
49052
|
-
import
|
|
48784
|
+
import fs46 from "node:fs";
|
|
48785
|
+
import path76 from "node:path";
|
|
49053
48786
|
var RESOLVE_CACHE_MAX = 4096;
|
|
49054
48787
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
49055
48788
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
49056
48789
|
return `${sessionParentPath}\0${relativePath}`;
|
|
49057
48790
|
}
|
|
49058
48791
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
49059
|
-
const parent =
|
|
49060
|
-
const resolved =
|
|
49061
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
48792
|
+
const parent = path76.resolve(sessionParentPath);
|
|
48793
|
+
const resolved = path76.resolve(filePath);
|
|
48794
|
+
return resolved === parent || resolved.startsWith(`${parent}${path76.sep}`);
|
|
49062
48795
|
}
|
|
49063
48796
|
function statMatchesCacheSync(entry) {
|
|
49064
48797
|
try {
|
|
49065
|
-
const stat2 =
|
|
48798
|
+
const stat2 = fs46.statSync(entry.path);
|
|
49066
48799
|
return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
|
|
49067
48800
|
} catch {
|
|
49068
48801
|
return false;
|
|
@@ -49095,7 +48828,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
49095
48828
|
}
|
|
49096
48829
|
|
|
49097
48830
|
// ../bridge/src/files/read/resolve-file-for-read-core.ts
|
|
49098
|
-
import
|
|
48831
|
+
import fs47 from "node:fs";
|
|
49099
48832
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
49100
48833
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
49101
48834
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -49105,13 +48838,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
49105
48838
|
let size;
|
|
49106
48839
|
let mtimeMs;
|
|
49107
48840
|
try {
|
|
49108
|
-
const lstat =
|
|
48841
|
+
const lstat = fs47.lstatSync(resolved);
|
|
49109
48842
|
if (lstat.isSymbolicLink()) {
|
|
49110
|
-
real =
|
|
48843
|
+
real = fs47.realpathSync(resolved);
|
|
49111
48844
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49112
48845
|
return { error: "Path is outside working directory" };
|
|
49113
48846
|
}
|
|
49114
|
-
const stat2 =
|
|
48847
|
+
const stat2 = fs47.statSync(real);
|
|
49115
48848
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49116
48849
|
size = stat2.size;
|
|
49117
48850
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49139,13 +48872,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
49139
48872
|
let size;
|
|
49140
48873
|
let mtimeMs;
|
|
49141
48874
|
try {
|
|
49142
|
-
const lstat = await
|
|
48875
|
+
const lstat = await fs47.promises.lstat(resolved);
|
|
49143
48876
|
if (lstat.isSymbolicLink()) {
|
|
49144
|
-
real = await
|
|
48877
|
+
real = await fs47.promises.realpath(resolved);
|
|
49145
48878
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49146
48879
|
return { error: "Path is outside working directory" };
|
|
49147
48880
|
}
|
|
49148
|
-
const stat2 = await
|
|
48881
|
+
const stat2 = await fs47.promises.stat(real);
|
|
49149
48882
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49150
48883
|
size = stat2.size;
|
|
49151
48884
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49194,7 +48927,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
49194
48927
|
|
|
49195
48928
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49196
48929
|
init_yield_to_event_loop();
|
|
49197
|
-
import
|
|
48930
|
+
import fs48 from "node:fs";
|
|
49198
48931
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
49199
48932
|
|
|
49200
48933
|
// ../bridge/src/files/read/read-file-range-line-zero.ts
|
|
@@ -49308,8 +49041,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
49308
49041
|
|
|
49309
49042
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49310
49043
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
49311
|
-
const fileSize = fileSizeIn ?? (await
|
|
49312
|
-
const fd = await
|
|
49044
|
+
const fileSize = fileSizeIn ?? (await fs48.promises.stat(filePath)).size;
|
|
49045
|
+
const fd = await fs48.promises.open(filePath, "r");
|
|
49313
49046
|
const bufSize = 64 * 1024;
|
|
49314
49047
|
const buf = Buffer.alloc(bufSize);
|
|
49315
49048
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -49410,7 +49143,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
49410
49143
|
}
|
|
49411
49144
|
|
|
49412
49145
|
// ../bridge/src/files/read/read-small-file-range-async.ts
|
|
49413
|
-
import
|
|
49146
|
+
import fs49 from "node:fs";
|
|
49414
49147
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
49415
49148
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
49416
49149
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -49440,7 +49173,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
49440
49173
|
};
|
|
49441
49174
|
}
|
|
49442
49175
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
49443
|
-
const raw =
|
|
49176
|
+
const raw = fs49.readFileSync(filePath, "utf8");
|
|
49444
49177
|
const lines = raw.split(/\r?\n/);
|
|
49445
49178
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49446
49179
|
}
|
|
@@ -49448,28 +49181,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
49448
49181
|
if (isMainThread5) {
|
|
49449
49182
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
49450
49183
|
}
|
|
49451
|
-
const raw = await
|
|
49184
|
+
const raw = await fs49.promises.readFile(filePath, "utf8");
|
|
49452
49185
|
const lines = raw.split(/\r?\n/);
|
|
49453
49186
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49454
49187
|
}
|
|
49455
49188
|
|
|
49456
49189
|
// ../bridge/src/files/read/read-file-buffer-full-async.ts
|
|
49457
49190
|
init_yield_to_event_loop();
|
|
49458
|
-
import
|
|
49191
|
+
import fs50 from "node:fs";
|
|
49459
49192
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
49460
49193
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
49461
49194
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
49462
49195
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
49463
49196
|
if (isMainThread6) {
|
|
49464
|
-
const size2 = knownSize ??
|
|
49197
|
+
const size2 = knownSize ?? fs50.statSync(filePath).size;
|
|
49465
49198
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
49466
49199
|
await yieldToEventLoop();
|
|
49467
|
-
const buffer =
|
|
49200
|
+
const buffer = fs50.readFileSync(filePath);
|
|
49468
49201
|
return { buffer, size: buffer.length };
|
|
49469
49202
|
}
|
|
49470
49203
|
}
|
|
49471
|
-
const size = knownSize ?? (await
|
|
49472
|
-
const fd = await
|
|
49204
|
+
const size = knownSize ?? (await fs50.promises.stat(filePath)).size;
|
|
49205
|
+
const fd = await fs50.promises.open(filePath, "r");
|
|
49473
49206
|
const chunks = [];
|
|
49474
49207
|
let position = 0;
|
|
49475
49208
|
let bytesSinceYield = 0;
|
|
@@ -49572,7 +49305,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
49572
49305
|
}
|
|
49573
49306
|
if (hasRange) {
|
|
49574
49307
|
if (fileSize == null) {
|
|
49575
|
-
const stat2 = await
|
|
49308
|
+
const stat2 = await fs51.promises.stat(resolvedPath);
|
|
49576
49309
|
fileSize = stat2.size;
|
|
49577
49310
|
}
|
|
49578
49311
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -49870,12 +49603,12 @@ function parseOptionalInt2(raw) {
|
|
|
49870
49603
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
49871
49604
|
}
|
|
49872
49605
|
function parseCodeNavParams(url2) {
|
|
49873
|
-
const
|
|
49606
|
+
const path85 = url2.searchParams.get("path") ?? "";
|
|
49874
49607
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
49875
49608
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
49876
49609
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
49877
49610
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
49878
|
-
return { path:
|
|
49611
|
+
return { path: path85, op, line, column };
|
|
49879
49612
|
}
|
|
49880
49613
|
function parseCodeNavPath(url2) {
|
|
49881
49614
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -50132,7 +49865,7 @@ async function createLocalShortcut(params) {
|
|
|
50132
49865
|
};
|
|
50133
49866
|
}
|
|
50134
49867
|
|
|
50135
|
-
// ../bridge/src/connection/create-bridge-connection-runtime.ts
|
|
49868
|
+
// ../bridge/src/connection/runtime/create-bridge-connection-runtime.ts
|
|
50136
49869
|
async function createBridgeConnectionRuntime(options, params) {
|
|
50137
49870
|
const { plugin, workspaceId } = options;
|
|
50138
49871
|
const { state, getWs, logFn } = params;
|
|
@@ -50477,7 +50210,7 @@ function logDuplicateBridgeWarning(log2, result) {
|
|
|
50477
50210
|
}
|
|
50478
50211
|
}
|
|
50479
50212
|
|
|
50480
|
-
// ../bridge/src/connection/create-main-bridge-reconnect-state.ts
|
|
50213
|
+
// ../bridge/src/connection/reconnect/create-main-bridge-reconnect-state.ts
|
|
50481
50214
|
function createMainBridgeReconnectState() {
|
|
50482
50215
|
const state = {
|
|
50483
50216
|
closedByUser: false,
|
|
@@ -50496,7 +50229,7 @@ function createMainBridgeReconnectState() {
|
|
|
50496
50229
|
};
|
|
50497
50230
|
}
|
|
50498
50231
|
|
|
50499
|
-
// ../bridge/src/connection/ensure-bridge-connection-databases.ts
|
|
50232
|
+
// ../bridge/src/connection/runtime/ensure-bridge-connection-databases.ts
|
|
50500
50233
|
init_cli_database();
|
|
50501
50234
|
init_code_nav_cache_availability();
|
|
50502
50235
|
async function ensureBridgeConnectionDatabases(log2) {
|
|
@@ -50504,7 +50237,7 @@ async function ensureBridgeConnectionDatabases(log2) {
|
|
|
50504
50237
|
void startCodeNavCacheInitialization(log2);
|
|
50505
50238
|
}
|
|
50506
50239
|
|
|
50507
|
-
// ../bridge/src/
|
|
50240
|
+
// ../bridge/src/connection/protocol/api-to-bridge-messages.ts
|
|
50508
50241
|
var API_TO_BRIDGE_MESSAGE_TYPES = [
|
|
50509
50242
|
"auth_token",
|
|
50510
50243
|
"bridge_identified",
|
|
@@ -50522,14 +50255,10 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
|
|
|
50522
50255
|
"session_discarded",
|
|
50523
50256
|
"revert_turn_snapshot",
|
|
50524
50257
|
"cursor_request_response",
|
|
50525
|
-
"skill_call",
|
|
50526
50258
|
"file_browser_request",
|
|
50527
50259
|
"file_browser_search",
|
|
50528
50260
|
"code_nav",
|
|
50529
|
-
"skill_layout_request",
|
|
50530
|
-
"install_skills",
|
|
50531
50261
|
"install_agent",
|
|
50532
|
-
"refresh_local_skills",
|
|
50533
50262
|
"bridge_git_context_request",
|
|
50534
50263
|
"list_repo_branches_request",
|
|
50535
50264
|
"bridge_git_checkout_request"
|
|
@@ -50551,15 +50280,14 @@ function parseApiToBridgeMessage(data, log2) {
|
|
|
50551
50280
|
return data;
|
|
50552
50281
|
}
|
|
50553
50282
|
|
|
50554
|
-
// ../bridge/src/routing/handlers/auth-token.ts
|
|
50283
|
+
// ../bridge/src/connection/routing/handlers/auth-token.ts
|
|
50555
50284
|
var handleAuthToken = (msg, { log: log2 }) => {
|
|
50556
50285
|
if (typeof msg.token !== "string") return;
|
|
50557
50286
|
log2("Received auth token. Save it for future runs:");
|
|
50558
50287
|
log2(` export BUILDAUTOMATON_AUTH_TOKEN="${msg.token}"`);
|
|
50559
50288
|
};
|
|
50560
50289
|
|
|
50561
|
-
// ../bridge/src/routing/handlers/bridge-identified.ts
|
|
50562
|
-
init_cli_process_interrupt();
|
|
50290
|
+
// ../bridge/src/connection/routing/handlers/bridge-identified.ts
|
|
50563
50291
|
var handleBridgeIdentified = (msg, deps) => {
|
|
50564
50292
|
if (typeof msg.bridgeName !== "string") return;
|
|
50565
50293
|
deps.onBridgeIdentified({
|
|
@@ -50586,19 +50314,9 @@ var handleBridgeIdentified = (msg, deps) => {
|
|
|
50586
50314
|
}
|
|
50587
50315
|
})();
|
|
50588
50316
|
});
|
|
50589
|
-
setImmediate(() => {
|
|
50590
|
-
if (isCliImmediateShutdownRequested()) return;
|
|
50591
|
-
try {
|
|
50592
|
-
deps.sendLocalSkillsReport?.();
|
|
50593
|
-
} catch (e) {
|
|
50594
|
-
deps.log(
|
|
50595
|
-
`[Bridge service] Local skills report failed: ${e instanceof Error ? e.message : String(e)}`
|
|
50596
|
-
);
|
|
50597
|
-
}
|
|
50598
|
-
});
|
|
50599
50317
|
};
|
|
50600
50318
|
|
|
50601
|
-
// ../bridge/src/routing/handlers/installed-agent-auth-sync.ts
|
|
50319
|
+
// ../bridge/src/connection/routing/handlers/installed-agent-auth-sync.ts
|
|
50602
50320
|
var handleInstalledAgentAuthSync = (msg) => {
|
|
50603
50321
|
const entries = Array.isArray(msg.entries) ? msg.entries : [];
|
|
50604
50322
|
setBridgeInstalledAgentAuthEnv(
|
|
@@ -50608,6 +50326,241 @@ var handleInstalledAgentAuthSync = (msg) => {
|
|
|
50608
50326
|
);
|
|
50609
50327
|
};
|
|
50610
50328
|
|
|
50329
|
+
// ../bridge/src/agents/install/run-streaming-command.ts
|
|
50330
|
+
import { spawn as spawn10 } from "node:child_process";
|
|
50331
|
+
import * as readline4 from "node:readline";
|
|
50332
|
+
function runStreamingCommand(command, args, options) {
|
|
50333
|
+
return new Promise((resolve36, reject) => {
|
|
50334
|
+
const child = spawn10(command, args, {
|
|
50335
|
+
env: options.env,
|
|
50336
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
50337
|
+
});
|
|
50338
|
+
let settled = false;
|
|
50339
|
+
const timer = options.timeoutMs != null ? setTimeout(() => {
|
|
50340
|
+
child.kill("SIGKILL");
|
|
50341
|
+
if (!settled) {
|
|
50342
|
+
settled = true;
|
|
50343
|
+
reject(new Error(`Command timed out after ${options.timeoutMs}ms`));
|
|
50344
|
+
}
|
|
50345
|
+
}, options.timeoutMs) : null;
|
|
50346
|
+
const onLine = (line) => {
|
|
50347
|
+
if (line.length > 0) options.onLine?.(line);
|
|
50348
|
+
};
|
|
50349
|
+
if (child.stdout) {
|
|
50350
|
+
readline4.createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", onLine);
|
|
50351
|
+
}
|
|
50352
|
+
if (child.stderr) {
|
|
50353
|
+
readline4.createInterface({ input: child.stderr, crlfDelay: Infinity }).on("line", onLine);
|
|
50354
|
+
}
|
|
50355
|
+
child.on("error", (err) => {
|
|
50356
|
+
if (timer) clearTimeout(timer);
|
|
50357
|
+
if (!settled) {
|
|
50358
|
+
settled = true;
|
|
50359
|
+
reject(err);
|
|
50360
|
+
}
|
|
50361
|
+
});
|
|
50362
|
+
child.on("close", (code, signal) => {
|
|
50363
|
+
if (timer) clearTimeout(timer);
|
|
50364
|
+
if (!settled) {
|
|
50365
|
+
settled = true;
|
|
50366
|
+
resolve36({ code, signal });
|
|
50367
|
+
}
|
|
50368
|
+
});
|
|
50369
|
+
});
|
|
50370
|
+
}
|
|
50371
|
+
|
|
50372
|
+
// ../bridge/src/agents/install/commands/run-npm-global-install.ts
|
|
50373
|
+
async function runNpmGlobalInstall(packageName, env, options) {
|
|
50374
|
+
const result = await runStreamingCommand("npm", ["install", "-g", packageName], {
|
|
50375
|
+
env: bridgeAgentPathEnv(env),
|
|
50376
|
+
timeoutMs: options?.timeoutMs ?? 3e5,
|
|
50377
|
+
onLine: options?.onLine
|
|
50378
|
+
});
|
|
50379
|
+
if (result.code !== 0) {
|
|
50380
|
+
throw new Error(`npm install -g ${packageName} failed (exit ${result.code ?? "signal"})`);
|
|
50381
|
+
}
|
|
50382
|
+
}
|
|
50383
|
+
|
|
50384
|
+
// ../bridge/src/agents/install/commands/claude-code.ts
|
|
50385
|
+
var claudeCodeInstallCommand = {
|
|
50386
|
+
agentType: "claude-code",
|
|
50387
|
+
detectCommand: "claude",
|
|
50388
|
+
async install(ctx) {
|
|
50389
|
+
ctx.onProgress?.("Installing Anthropic Claude Code");
|
|
50390
|
+
await runNpmGlobalInstall(
|
|
50391
|
+
"@anthropic-ai/claude-code",
|
|
50392
|
+
{ ...ctx.env, ANTHROPIC_API_KEY: ctx.authToken },
|
|
50393
|
+
{ onLine: (line) => ctx.onProgress?.("Installing Anthropic Claude Code", line) }
|
|
50394
|
+
);
|
|
50395
|
+
}
|
|
50396
|
+
};
|
|
50397
|
+
|
|
50398
|
+
// ../bridge/src/agents/install/commands/codex-acp.ts
|
|
50399
|
+
var codexAcpInstallCommand = {
|
|
50400
|
+
agentType: "codex-acp",
|
|
50401
|
+
detectCommand: "codex",
|
|
50402
|
+
async install(ctx) {
|
|
50403
|
+
ctx.onProgress?.("Installing Codex");
|
|
50404
|
+
await runNpmGlobalInstall(
|
|
50405
|
+
"@openai/codex",
|
|
50406
|
+
{ ...ctx.env, OPENAI_API_KEY: ctx.authToken },
|
|
50407
|
+
{ onLine: (line) => ctx.onProgress?.("Installing Codex", line) }
|
|
50408
|
+
);
|
|
50409
|
+
}
|
|
50410
|
+
};
|
|
50411
|
+
|
|
50412
|
+
// ../bridge/src/agents/install/commands/cursor-cli.ts
|
|
50413
|
+
var cursorCliInstallCommand = {
|
|
50414
|
+
agentType: "cursor-cli",
|
|
50415
|
+
detectCommand: "agent",
|
|
50416
|
+
alternateDetectCommands: ["cursor-agent"],
|
|
50417
|
+
async install(ctx) {
|
|
50418
|
+
ctx.onProgress?.("Installing Cursor CLI");
|
|
50419
|
+
const result = await runStreamingCommand(
|
|
50420
|
+
"bash",
|
|
50421
|
+
["-lc", "curl -fsSL https://cursor.com/install | bash"],
|
|
50422
|
+
{
|
|
50423
|
+
timeoutMs: 3e5,
|
|
50424
|
+
env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken },
|
|
50425
|
+
onLine: (line) => ctx.onProgress?.("Installing Cursor CLI", line)
|
|
50426
|
+
}
|
|
50427
|
+
);
|
|
50428
|
+
if (result.code !== 0) {
|
|
50429
|
+
throw new Error(`Cursor CLI install failed (exit ${result.code ?? "signal"})`);
|
|
50430
|
+
}
|
|
50431
|
+
}
|
|
50432
|
+
};
|
|
50433
|
+
|
|
50434
|
+
// ../bridge/src/agents/install/commands/opencode.ts
|
|
50435
|
+
var opencodeInstallCommand = {
|
|
50436
|
+
agentType: "opencode",
|
|
50437
|
+
detectCommand: "opencode",
|
|
50438
|
+
async install(ctx) {
|
|
50439
|
+
ctx.onProgress?.("Installing OpenCode");
|
|
50440
|
+
await runNpmGlobalInstall(
|
|
50441
|
+
"opencode-ai",
|
|
50442
|
+
{ ...ctx.env, OPENCODE_API_KEY: ctx.authToken },
|
|
50443
|
+
{ onLine: (line) => ctx.onProgress?.("Installing OpenCode", line) }
|
|
50444
|
+
);
|
|
50445
|
+
}
|
|
50446
|
+
};
|
|
50447
|
+
|
|
50448
|
+
// ../bridge/src/agents/install/commands/index.ts
|
|
50449
|
+
var COMMANDS = [
|
|
50450
|
+
claudeCodeInstallCommand,
|
|
50451
|
+
codexAcpInstallCommand,
|
|
50452
|
+
cursorCliInstallCommand,
|
|
50453
|
+
opencodeInstallCommand
|
|
50454
|
+
];
|
|
50455
|
+
var byType = new Map(COMMANDS.map((c) => [c.agentType, c]));
|
|
50456
|
+
function getAgentInstallCommand(agentType) {
|
|
50457
|
+
return byType.get(agentType);
|
|
50458
|
+
}
|
|
50459
|
+
|
|
50460
|
+
// ../bridge/src/agents/install/install-local-agent.ts
|
|
50461
|
+
async function installLocalAgentOnBridge(params) {
|
|
50462
|
+
const spec = INSTALLABLE_BRIDGE_AGENTS.find((a) => a.value === params.agentType);
|
|
50463
|
+
if (!spec) return { success: false, error: `Unsupported agent type: ${params.agentType}` };
|
|
50464
|
+
const command = getAgentInstallCommand(params.agentType);
|
|
50465
|
+
if (!command) return { success: false, error: `No install command for ${params.agentType}` };
|
|
50466
|
+
params.onProgress?.(`Configuring ${spec.label} credentials`);
|
|
50467
|
+
try {
|
|
50468
|
+
await command.install({
|
|
50469
|
+
authToken: params.authToken,
|
|
50470
|
+
onProgress: params.onProgress,
|
|
50471
|
+
env: { ...process.env, [spec.tokenEnvVar]: params.authToken }
|
|
50472
|
+
});
|
|
50473
|
+
} catch (e) {
|
|
50474
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
50475
|
+
return { success: false, error: msg };
|
|
50476
|
+
}
|
|
50477
|
+
ensureBridgeAgentPathInProcessEnv();
|
|
50478
|
+
const detectNames = [
|
|
50479
|
+
command.detectCommand,
|
|
50480
|
+
...command.alternateDetectCommands ?? []
|
|
50481
|
+
];
|
|
50482
|
+
let found = false;
|
|
50483
|
+
for (const name of detectNames) {
|
|
50484
|
+
if (await waitForCommandOnPath(name)) {
|
|
50485
|
+
found = true;
|
|
50486
|
+
break;
|
|
50487
|
+
}
|
|
50488
|
+
}
|
|
50489
|
+
if (!found) {
|
|
50490
|
+
return { success: false, error: `${command.detectCommand} not found on PATH after install` };
|
|
50491
|
+
}
|
|
50492
|
+
return { success: true };
|
|
50493
|
+
}
|
|
50494
|
+
|
|
50495
|
+
// ../bridge/src/connection/routing/handlers/install-agent.ts
|
|
50496
|
+
var handleInstallAgentMessage = (msg, deps) => {
|
|
50497
|
+
const processId = typeof msg.processId === "string" ? msg.processId : "";
|
|
50498
|
+
const agentId = typeof msg.agentId === "string" ? msg.agentId : "";
|
|
50499
|
+
const tokenId = typeof msg.tokenId === "string" ? msg.tokenId : "";
|
|
50500
|
+
const agentType = typeof msg.agentType === "string" ? msg.agentType : "";
|
|
50501
|
+
const authToken = typeof msg.authToken === "string" ? msg.authToken : "";
|
|
50502
|
+
if (!processId || !agentId || !tokenId || !agentType || !authToken) return;
|
|
50503
|
+
void (async () => {
|
|
50504
|
+
const socket = deps.getWs();
|
|
50505
|
+
let pendingLines = [];
|
|
50506
|
+
let flushTimer = null;
|
|
50507
|
+
const sendProgress = (message, logOutput) => {
|
|
50508
|
+
if (!socket) return;
|
|
50509
|
+
sendWsMessage(socket, {
|
|
50510
|
+
type: "install_agent_progress",
|
|
50511
|
+
processId,
|
|
50512
|
+
agentId,
|
|
50513
|
+
tokenId,
|
|
50514
|
+
agentType,
|
|
50515
|
+
step: "agent_install_package",
|
|
50516
|
+
message,
|
|
50517
|
+
...logOutput ? { logOutput } : {}
|
|
50518
|
+
});
|
|
50519
|
+
};
|
|
50520
|
+
const flushLines = (message) => {
|
|
50521
|
+
if (flushTimer) {
|
|
50522
|
+
clearTimeout(flushTimer);
|
|
50523
|
+
flushTimer = null;
|
|
50524
|
+
}
|
|
50525
|
+
if (pendingLines.length === 0) return;
|
|
50526
|
+
const logOutput = pendingLines.join("\n");
|
|
50527
|
+
pendingLines = [];
|
|
50528
|
+
sendProgress(message, logOutput);
|
|
50529
|
+
};
|
|
50530
|
+
const result = await installLocalAgentOnBridge({
|
|
50531
|
+
agentType,
|
|
50532
|
+
authToken,
|
|
50533
|
+
onProgress: (message, logOutput) => {
|
|
50534
|
+
if (logOutput == null) {
|
|
50535
|
+
flushLines(message);
|
|
50536
|
+
sendProgress(message);
|
|
50537
|
+
return;
|
|
50538
|
+
}
|
|
50539
|
+
pendingLines.push(logOutput);
|
|
50540
|
+
if (!flushTimer) {
|
|
50541
|
+
flushTimer = setTimeout(() => flushLines(message), 100);
|
|
50542
|
+
}
|
|
50543
|
+
}
|
|
50544
|
+
});
|
|
50545
|
+
flushLines("Installing agent packages on the bridge machine.");
|
|
50546
|
+
if (socket) {
|
|
50547
|
+
sendWsMessage(socket, {
|
|
50548
|
+
type: "install_agent_result",
|
|
50549
|
+
processId,
|
|
50550
|
+
agentId,
|
|
50551
|
+
tokenId,
|
|
50552
|
+
agentType,
|
|
50553
|
+
success: result.success,
|
|
50554
|
+
error: result.error
|
|
50555
|
+
});
|
|
50556
|
+
}
|
|
50557
|
+
if (result.success) await deps.reportAutoDetectedAgents?.();
|
|
50558
|
+
if (!result.success) {
|
|
50559
|
+
deps.log(`[Bridge service] Install agent failed: ${result.error ?? "unknown"}`);
|
|
50560
|
+
}
|
|
50561
|
+
})();
|
|
50562
|
+
};
|
|
50563
|
+
|
|
50611
50564
|
// ../bridge/src/connection/heartbeat/ack.ts
|
|
50612
50565
|
var handleBridgeHeartbeatAck = (msg, deps) => {
|
|
50613
50566
|
const raw = msg.s;
|
|
@@ -50615,7 +50568,7 @@ var handleBridgeHeartbeatAck = (msg, deps) => {
|
|
|
50615
50568
|
deps.onBridgeHeartbeatAck?.(Math.trunc(raw));
|
|
50616
50569
|
};
|
|
50617
50570
|
|
|
50618
|
-
// ../bridge/src/routing/dispatch/connection.ts
|
|
50571
|
+
// ../bridge/src/connection/routing/dispatch/connection.ts
|
|
50619
50572
|
function dispatchBridgeConnectionMessage(msg, deps) {
|
|
50620
50573
|
switch (msg.type) {
|
|
50621
50574
|
case "auth_token":
|
|
@@ -50627,13 +50580,16 @@ function dispatchBridgeConnectionMessage(msg, deps) {
|
|
|
50627
50580
|
case "installed_agent_auth_sync":
|
|
50628
50581
|
handleInstalledAgentAuthSync(msg, deps);
|
|
50629
50582
|
break;
|
|
50583
|
+
case "install_agent":
|
|
50584
|
+
handleInstallAgentMessage(msg, deps);
|
|
50585
|
+
break;
|
|
50630
50586
|
case "ha":
|
|
50631
50587
|
handleBridgeHeartbeatAck(msg, deps);
|
|
50632
50588
|
break;
|
|
50633
50589
|
}
|
|
50634
50590
|
}
|
|
50635
50591
|
|
|
50636
|
-
// ../bridge/src/routing/handlers/preview-environment-control.ts
|
|
50592
|
+
// ../bridge/src/connection/routing/handlers/preview-environment-control.ts
|
|
50637
50593
|
var handlePreviewEnvironmentControl = (msg, deps) => {
|
|
50638
50594
|
let wire;
|
|
50639
50595
|
try {
|
|
@@ -50648,7 +50604,7 @@ var handlePreviewEnvironmentControl = (msg, deps) => {
|
|
|
50648
50604
|
deps.previewEnvironmentManager?.handleControl(environmentId, action);
|
|
50649
50605
|
};
|
|
50650
50606
|
|
|
50651
|
-
// ../bridge/src/routing/handlers/preview-environments-config.ts
|
|
50607
|
+
// ../bridge/src/connection/routing/handlers/preview-environments-config.ts
|
|
50652
50608
|
var VALID_PORT = (p) => typeof p === "number" && Number.isInteger(p) && p > 0 && p < 65536;
|
|
50653
50609
|
var handlePreviewEnvironmentsConfig = (msg, deps) => {
|
|
50654
50610
|
const previewEnvironments = msg.previewEnvironments;
|
|
@@ -50663,13 +50619,13 @@ var handlePreviewEnvironmentsConfig = (msg, deps) => {
|
|
|
50663
50619
|
});
|
|
50664
50620
|
};
|
|
50665
50621
|
|
|
50666
|
-
// ../bridge/src/routing/handlers/send-deploy-session-to-preview-result.ts
|
|
50622
|
+
// ../bridge/src/connection/routing/handlers/send-deploy-session-to-preview-result.ts
|
|
50667
50623
|
function sendDeploySessionToPreviewResult(ws, id, payload) {
|
|
50668
50624
|
if (!ws) return;
|
|
50669
50625
|
sendWsMessage(ws, { type: "deploy_session_to_preview_result", id, ...payload });
|
|
50670
50626
|
}
|
|
50671
50627
|
|
|
50672
|
-
// ../bridge/src/routing/handlers/deploy-session-to-preview.ts
|
|
50628
|
+
// ../bridge/src/connection/routing/handlers/deploy-session-to-preview.ts
|
|
50673
50629
|
var handleDeploySessionToPreviewMessage = (msg, deps) => {
|
|
50674
50630
|
if (typeof msg.id !== "string") return;
|
|
50675
50631
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -50697,7 +50653,7 @@ var handleDeploySessionToPreviewMessage = (msg, deps) => {
|
|
|
50697
50653
|
})();
|
|
50698
50654
|
};
|
|
50699
50655
|
|
|
50700
|
-
// ../bridge/src/routing/dispatch/preview.ts
|
|
50656
|
+
// ../bridge/src/connection/routing/dispatch/preview.ts
|
|
50701
50657
|
function dispatchBridgePreviewMessage(msg, deps) {
|
|
50702
50658
|
switch (msg.type) {
|
|
50703
50659
|
case "preview_environments_config":
|
|
@@ -50718,7 +50674,7 @@ function handleBridgeAgentConfig(msg, { acpManager }) {
|
|
|
50718
50674
|
acpManager.setPreferredAgentType(msg.agents[0].type);
|
|
50719
50675
|
}
|
|
50720
50676
|
|
|
50721
|
-
// ../bridge/src/routing/handlers/agent-config.ts
|
|
50677
|
+
// ../bridge/src/connection/routing/handlers/agent-config.ts
|
|
50722
50678
|
var handleAgentConfigMessage = (msg, deps) => {
|
|
50723
50679
|
handleBridgeAgentConfig(msg, deps);
|
|
50724
50680
|
};
|
|
@@ -50940,18 +50896,18 @@ function hasRunningTurn(turns) {
|
|
|
50940
50896
|
}
|
|
50941
50897
|
|
|
50942
50898
|
// ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
50943
|
-
import
|
|
50899
|
+
import fs54 from "node:fs";
|
|
50944
50900
|
|
|
50945
50901
|
// ../bridge/src/git/snapshot/capture.ts
|
|
50946
|
-
import * as
|
|
50947
|
-
import * as
|
|
50902
|
+
import * as fs53 from "node:fs";
|
|
50903
|
+
import * as path78 from "node:path";
|
|
50948
50904
|
|
|
50949
50905
|
// ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
50950
|
-
import * as
|
|
50906
|
+
import * as fs52 from "node:fs";
|
|
50951
50907
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
50952
50908
|
let data;
|
|
50953
50909
|
try {
|
|
50954
|
-
data = JSON.parse(
|
|
50910
|
+
data = JSON.parse(fs52.readFileSync(filePath, "utf8"));
|
|
50955
50911
|
} catch (error51) {
|
|
50956
50912
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
50957
50913
|
}
|
|
@@ -50980,18 +50936,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
50980
50936
|
}
|
|
50981
50937
|
|
|
50982
50938
|
// ../bridge/src/git/snapshot/resolve-repo-roots.ts
|
|
50983
|
-
import * as
|
|
50939
|
+
import * as path77 from "node:path";
|
|
50984
50940
|
async function resolveSnapshotRepoRoots(options) {
|
|
50985
50941
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
50986
50942
|
if (worktreePaths?.length) {
|
|
50987
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
50943
|
+
const paths = [...new Set(worktreePaths.map((p) => path77.resolve(p)))];
|
|
50988
50944
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
50989
50945
|
}
|
|
50990
50946
|
try {
|
|
50991
50947
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
50992
50948
|
const sid = sessionId?.trim();
|
|
50993
50949
|
if (!sid) return roots;
|
|
50994
|
-
const sessionRoots = roots.filter((root) =>
|
|
50950
|
+
const sessionRoots = roots.filter((root) => path77.basename(root) === sid);
|
|
50995
50951
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
50996
50952
|
} catch (error51) {
|
|
50997
50953
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -51013,7 +50969,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51013
50969
|
});
|
|
51014
50970
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
51015
50971
|
try {
|
|
51016
|
-
|
|
50972
|
+
fs53.mkdirSync(dir, { recursive: true });
|
|
51017
50973
|
} catch (e) {
|
|
51018
50974
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51019
50975
|
}
|
|
@@ -51022,9 +50978,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51022
50978
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51023
50979
|
repos
|
|
51024
50980
|
};
|
|
51025
|
-
const filePath =
|
|
50981
|
+
const filePath = path78.join(dir, `${runId}.json`);
|
|
51026
50982
|
try {
|
|
51027
|
-
|
|
50983
|
+
fs53.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
51028
50984
|
} catch (e) {
|
|
51029
50985
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51030
50986
|
}
|
|
@@ -51044,7 +51000,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51044
51000
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
51045
51001
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
51046
51002
|
try {
|
|
51047
|
-
await
|
|
51003
|
+
await fs54.promises.access(file2, fs54.constants.F_OK);
|
|
51048
51004
|
} catch {
|
|
51049
51005
|
deps.log(
|
|
51050
51006
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -51415,7 +51371,7 @@ function handleBridgePrompt(msg, deps) {
|
|
|
51415
51371
|
});
|
|
51416
51372
|
}
|
|
51417
51373
|
|
|
51418
|
-
// ../bridge/src/routing/handlers/prompt.ts
|
|
51374
|
+
// ../bridge/src/connection/routing/handlers/prompt.ts
|
|
51419
51375
|
var handlePromptMessage = (msg, deps) => {
|
|
51420
51376
|
handleBridgePrompt(msg, deps);
|
|
51421
51377
|
};
|
|
@@ -51440,7 +51396,7 @@ function enqueueLatestPromptQueueStateWork(work) {
|
|
|
51440
51396
|
});
|
|
51441
51397
|
}
|
|
51442
51398
|
|
|
51443
|
-
// ../bridge/src/routing/handlers/prompt-queue-state.ts
|
|
51399
|
+
// ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
|
|
51444
51400
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
51445
51401
|
enqueueLatestPromptQueueStateWork(async () => {
|
|
51446
51402
|
try {
|
|
@@ -51457,12 +51413,12 @@ function handleBridgeSessionRequestResponse(msg, { acpManager }) {
|
|
|
51457
51413
|
acpManager.resolveRequest(msg.requestId, msg.result ?? {});
|
|
51458
51414
|
}
|
|
51459
51415
|
|
|
51460
|
-
// ../bridge/src/routing/handlers/session-request-response.ts
|
|
51416
|
+
// ../bridge/src/connection/routing/handlers/session-request-response.ts
|
|
51461
51417
|
var handleSessionRequestResponseMessage = (msg, deps) => {
|
|
51462
51418
|
handleBridgeSessionRequestResponse(msg, deps);
|
|
51463
51419
|
};
|
|
51464
51420
|
|
|
51465
|
-
// ../bridge/src/routing/handlers/git/handle-session-git-commit.ts
|
|
51421
|
+
// ../bridge/src/connection/routing/handlers/git/handle-session-git-commit.ts
|
|
51466
51422
|
async function handleSessionGitCommitAction(deps, sessionId, msg, reply) {
|
|
51467
51423
|
const branch = typeof msg.branch === "string" ? msg.branch : "";
|
|
51468
51424
|
const message = typeof msg.message === "string" ? msg.message : "";
|
|
@@ -51492,7 +51448,7 @@ async function handleSessionGitCommitAction(deps, sessionId, msg, reply) {
|
|
|
51492
51448
|
});
|
|
51493
51449
|
}
|
|
51494
51450
|
|
|
51495
|
-
// ../bridge/src/routing/handlers/git/session-git-changes-params.ts
|
|
51451
|
+
// ../bridge/src/connection/routing/handlers/git/session-git-changes-params.ts
|
|
51496
51452
|
function readString(value) {
|
|
51497
51453
|
return typeof value === "string" ? value.trim() : "";
|
|
51498
51454
|
}
|
|
@@ -51520,7 +51476,7 @@ function parseSessionGitChangesParams(msg) {
|
|
|
51520
51476
|
};
|
|
51521
51477
|
}
|
|
51522
51478
|
|
|
51523
|
-
// ../bridge/src/routing/handlers/git/handle-session-git-get-change-file-patch.ts
|
|
51479
|
+
// ../bridge/src/connection/routing/handlers/git/handle-session-git-get-change-file-patch.ts
|
|
51524
51480
|
async function handleSessionGitGetChangeFilePatchAction(deps, msg, reply) {
|
|
51525
51481
|
const changes = parseSessionGitChangesParams(msg);
|
|
51526
51482
|
const { repoRelPath: repoRel, view, commitSha, fileWorkspaceRelPath, fileChange, fileMovedFromWorkspaceRelPath } = changes;
|
|
@@ -51553,7 +51509,7 @@ async function handleSessionGitGetChangeFilePatchAction(deps, msg, reply) {
|
|
|
51553
51509
|
);
|
|
51554
51510
|
}
|
|
51555
51511
|
|
|
51556
|
-
// ../bridge/src/routing/handlers/git/coalesce-list-changes.ts
|
|
51512
|
+
// ../bridge/src/connection/routing/handlers/git/coalesce-list-changes.ts
|
|
51557
51513
|
var listChangesInflight = /* @__PURE__ */ new Map();
|
|
51558
51514
|
function normalizeListChangesRepoPathRelativeToWorkspaceRoot(repoRelPath) {
|
|
51559
51515
|
if (!repoRelPath?.trim()) return "";
|
|
@@ -51579,7 +51535,7 @@ function getSessionWorkingTreeChangeDetailsCoalesced(sessionWorktreeManager, ses
|
|
|
51579
51535
|
return promise2;
|
|
51580
51536
|
}
|
|
51581
51537
|
|
|
51582
|
-
// ../bridge/src/routing/handlers/git/handle-session-git-list-changes.ts
|
|
51538
|
+
// ../bridge/src/connection/routing/handlers/git/handle-session-git-list-changes.ts
|
|
51583
51539
|
async function handleSessionGitListChangesAction(deps, msg, reply) {
|
|
51584
51540
|
const changes = parseSessionGitChangesParams(msg);
|
|
51585
51541
|
const { repoRelPath: repoRel, view, commitSha, recentCommitsLimit } = changes;
|
|
@@ -51605,7 +51561,7 @@ async function handleSessionGitListChangesAction(deps, msg, reply) {
|
|
|
51605
51561
|
reply({ ok: true, repos }, ["repos"]);
|
|
51606
51562
|
}
|
|
51607
51563
|
|
|
51608
|
-
// ../bridge/src/routing/handlers/git/handle-session-git-push.ts
|
|
51564
|
+
// ../bridge/src/connection/routing/handlers/git/handle-session-git-push.ts
|
|
51609
51565
|
async function handleSessionGitPushAction(deps, sessionId, reply) {
|
|
51610
51566
|
const pushRes = await deps.sessionWorktreeManager.pushSessionUpstream(sessionId);
|
|
51611
51567
|
if (!pushRes.ok) {
|
|
@@ -51621,7 +51577,7 @@ async function handleSessionGitPushAction(deps, sessionId, reply) {
|
|
|
51621
51577
|
});
|
|
51622
51578
|
}
|
|
51623
51579
|
|
|
51624
|
-
// ../bridge/src/routing/handlers/git/handle-session-git-status.ts
|
|
51580
|
+
// ../bridge/src/connection/routing/handlers/git/handle-session-git-status.ts
|
|
51625
51581
|
async function handleSessionGitStatusAction(deps, sessionId, reply) {
|
|
51626
51582
|
const r = await deps.sessionWorktreeManager.getSessionWorkingTreeStatus(sessionId);
|
|
51627
51583
|
reply({
|
|
@@ -51632,7 +51588,7 @@ async function handleSessionGitStatusAction(deps, sessionId, reply) {
|
|
|
51632
51588
|
});
|
|
51633
51589
|
}
|
|
51634
51590
|
|
|
51635
|
-
// ../bridge/src/routing/handlers/git/send-session-git-result.ts
|
|
51591
|
+
// ../bridge/src/connection/routing/handlers/git/send-session-git-result.ts
|
|
51636
51592
|
function sendSessionGitResult(ws, id, payload, e2ee, encryptedFields = []) {
|
|
51637
51593
|
if (!ws) return;
|
|
51638
51594
|
const message = { type: "session_git_result", id, ...payload };
|
|
@@ -51643,7 +51599,7 @@ function sendSessionGitResult(ws, id, payload, e2ee, encryptedFields = []) {
|
|
|
51643
51599
|
sendWsMessage(ws, wire);
|
|
51644
51600
|
}
|
|
51645
51601
|
|
|
51646
|
-
// ../bridge/src/routing/handlers/git/session-git-request.ts
|
|
51602
|
+
// ../bridge/src/connection/routing/handlers/git/session-git-request.ts
|
|
51647
51603
|
var handleSessionGitRequestMessage = (msg, deps) => {
|
|
51648
51604
|
if (typeof msg.id !== "string") return;
|
|
51649
51605
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -51677,7 +51633,7 @@ var handleSessionGitRequestMessage = (msg, deps) => {
|
|
|
51677
51633
|
})();
|
|
51678
51634
|
};
|
|
51679
51635
|
|
|
51680
|
-
// ../bridge/src/routing/handlers/rename-session-branch.ts
|
|
51636
|
+
// ../bridge/src/connection/routing/handlers/rename-session-branch.ts
|
|
51681
51637
|
var handleRenameSessionBranchMessage = (msg, deps) => {
|
|
51682
51638
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
51683
51639
|
const newBranch = typeof msg.newBranch === "string" ? msg.newBranch : "";
|
|
@@ -51685,7 +51641,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
|
|
|
51685
51641
|
void deps.sessionWorktreeManager.renameSessionBranch(sessionId, newBranch);
|
|
51686
51642
|
};
|
|
51687
51643
|
|
|
51688
|
-
// ../bridge/src/routing/handlers/session-archived.ts
|
|
51644
|
+
// ../bridge/src/connection/routing/handlers/session-archived.ts
|
|
51689
51645
|
var handleSessionArchivedMessage = (msg, deps) => {
|
|
51690
51646
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
51691
51647
|
if (!sessionId) return;
|
|
@@ -51693,7 +51649,7 @@ var handleSessionArchivedMessage = (msg, deps) => {
|
|
|
51693
51649
|
void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
|
|
51694
51650
|
};
|
|
51695
51651
|
|
|
51696
|
-
// ../bridge/src/routing/handlers/session-discarded.ts
|
|
51652
|
+
// ../bridge/src/connection/routing/handlers/session-discarded.ts
|
|
51697
51653
|
var handleSessionDiscardedMessage = (msg, deps) => {
|
|
51698
51654
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
51699
51655
|
if (!sessionId) return;
|
|
@@ -51701,8 +51657,8 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
51701
51657
|
void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
|
|
51702
51658
|
};
|
|
51703
51659
|
|
|
51704
|
-
// ../bridge/src/routing/handlers/revert-turn-snapshot.ts
|
|
51705
|
-
import * as
|
|
51660
|
+
// ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
|
|
51661
|
+
import * as fs55 from "node:fs";
|
|
51706
51662
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
51707
51663
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
51708
51664
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -51715,7 +51671,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
51715
51671
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
51716
51672
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
51717
51673
|
try {
|
|
51718
|
-
await
|
|
51674
|
+
await fs55.promises.access(file2, fs55.constants.F_OK);
|
|
51719
51675
|
} catch {
|
|
51720
51676
|
sendWsMessage(s, {
|
|
51721
51677
|
type: "revert_turn_snapshot_result",
|
|
@@ -51735,7 +51691,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
51735
51691
|
})();
|
|
51736
51692
|
};
|
|
51737
51693
|
|
|
51738
|
-
// ../bridge/src/routing/dispatch/session.ts
|
|
51694
|
+
// ../bridge/src/connection/routing/dispatch/session.ts
|
|
51739
51695
|
function dispatchBridgeSessionMessage(msg, deps) {
|
|
51740
51696
|
switch (msg.type) {
|
|
51741
51697
|
case "agent_config":
|
|
@@ -51768,382 +51724,6 @@ function dispatchBridgeSessionMessage(msg, deps) {
|
|
|
51768
51724
|
}
|
|
51769
51725
|
}
|
|
51770
51726
|
|
|
51771
|
-
// ../bridge/src/skills/handle-skill-call.ts
|
|
51772
|
-
function handleSkillCall(msg, socket, log2) {
|
|
51773
|
-
callSkill(msg.skillId, msg.operationId, msg.params ?? {}).then((result) => {
|
|
51774
|
-
sendWsMessage(socket, { type: "skill_result", id: msg.id, result });
|
|
51775
|
-
}).catch((err) => {
|
|
51776
|
-
sendWsMessage(socket, { type: "skill_result", id: msg.id, error: String(err) });
|
|
51777
|
-
log2(`[Bridge service] Skill invocation failed (${msg.skillId}/${msg.operationId}): ${err}`);
|
|
51778
|
-
});
|
|
51779
|
-
}
|
|
51780
|
-
|
|
51781
|
-
// ../bridge/src/routing/handlers/skill-call.ts
|
|
51782
|
-
var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
|
|
51783
|
-
const skillId = typeof msg.skillId === "string" ? msg.skillId : "";
|
|
51784
|
-
const operationId = typeof msg.operationId === "string" ? msg.operationId : "";
|
|
51785
|
-
if (!skillId || !operationId) return;
|
|
51786
|
-
const socket = getWs();
|
|
51787
|
-
if (!socket) return;
|
|
51788
|
-
handleSkillCall(
|
|
51789
|
-
{ id: msg.id, skillId, operationId, params: msg.params },
|
|
51790
|
-
socket,
|
|
51791
|
-
log2
|
|
51792
|
-
);
|
|
51793
|
-
};
|
|
51794
|
-
|
|
51795
|
-
// ../bridge/src/routing/handlers/skill-layout-request.ts
|
|
51796
|
-
function handleSkillLayoutRequest(msg, deps) {
|
|
51797
|
-
const id = typeof msg.id === "string" ? msg.id : "";
|
|
51798
|
-
void (async () => {
|
|
51799
|
-
const socket = deps.getWs();
|
|
51800
|
-
const roots = await discoverSkillLayoutRootsAsync(getBridgeRoot());
|
|
51801
|
-
if (socket) {
|
|
51802
|
-
sendWsMessage(socket, { type: "skill_layout_response", id, roots });
|
|
51803
|
-
}
|
|
51804
|
-
})();
|
|
51805
|
-
}
|
|
51806
|
-
|
|
51807
|
-
// ../bridge/src/skills/install/is-valid-install-item.ts
|
|
51808
|
-
function isValidRemoteSkillInstallItem(item) {
|
|
51809
|
-
if (item === null || typeof item !== "object") return false;
|
|
51810
|
-
const o = item;
|
|
51811
|
-
return typeof o.sourceId === "string" && typeof o.skillName === "string" && typeof o.versionHash === "string" && Array.isArray(o.files);
|
|
51812
|
-
}
|
|
51813
|
-
|
|
51814
|
-
// ../bridge/src/skills/install/install-remote-skills-async.ts
|
|
51815
|
-
init_yield_to_event_loop();
|
|
51816
|
-
import fs58 from "node:fs";
|
|
51817
|
-
import path81 from "node:path";
|
|
51818
|
-
|
|
51819
|
-
// ../bridge/src/skills/install/constants.ts
|
|
51820
|
-
var INSTALL_SKILLS_YIELD_EVERY = 16;
|
|
51821
|
-
|
|
51822
|
-
// ../bridge/src/skills/install/install-remote-skills-async.ts
|
|
51823
|
-
async function writeInstallFileAsync(skillDir, f, filesWritten) {
|
|
51824
|
-
if (typeof f.path !== "string" || !f.text && !f.base64) return;
|
|
51825
|
-
if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
|
|
51826
|
-
await yieldToEventLoop();
|
|
51827
|
-
}
|
|
51828
|
-
const dest = path81.join(skillDir, f.path);
|
|
51829
|
-
await fs58.promises.mkdir(path81.dirname(dest), { recursive: true });
|
|
51830
|
-
if (f.text !== void 0) {
|
|
51831
|
-
await fs58.promises.writeFile(dest, f.text, "utf8");
|
|
51832
|
-
} else if (f.base64) {
|
|
51833
|
-
await fs58.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
|
|
51834
|
-
}
|
|
51835
|
-
}
|
|
51836
|
-
async function installRemoteSkillsAsync(cwd, targetDir, items) {
|
|
51837
|
-
const installed2 = [];
|
|
51838
|
-
if (!Array.isArray(items)) {
|
|
51839
|
-
return { success: false, error: "Invalid items" };
|
|
51840
|
-
}
|
|
51841
|
-
const filesWritten = { count: 0 };
|
|
51842
|
-
try {
|
|
51843
|
-
for (const item of items) {
|
|
51844
|
-
if (!isValidRemoteSkillInstallItem(item)) continue;
|
|
51845
|
-
const skillDir = path81.join(cwd, targetDir, item.skillName);
|
|
51846
|
-
for (const f of item.files) {
|
|
51847
|
-
await writeInstallFileAsync(skillDir, f, filesWritten);
|
|
51848
|
-
}
|
|
51849
|
-
installed2.push({
|
|
51850
|
-
sourceId: item.sourceId,
|
|
51851
|
-
skillName: item.skillName,
|
|
51852
|
-
versionHash: item.versionHash
|
|
51853
|
-
});
|
|
51854
|
-
}
|
|
51855
|
-
return { success: true, installed: installed2 };
|
|
51856
|
-
} catch (e) {
|
|
51857
|
-
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
|
51858
|
-
}
|
|
51859
|
-
}
|
|
51860
|
-
|
|
51861
|
-
// ../bridge/src/routing/handlers/install-skills.ts
|
|
51862
|
-
var handleInstallSkillsMessage = (msg, deps) => {
|
|
51863
|
-
const id = typeof msg.id === "string" ? msg.id : "";
|
|
51864
|
-
const targetDir = typeof msg.targetDir === "string" && msg.targetDir.trim() ? msg.targetDir.trim() : ".agents/skills";
|
|
51865
|
-
const rawItems = msg.items;
|
|
51866
|
-
const cwd = getBridgeRoot();
|
|
51867
|
-
void (async () => {
|
|
51868
|
-
const socket = deps.getWs();
|
|
51869
|
-
const result = await installRemoteSkillsAsync(cwd, targetDir, rawItems);
|
|
51870
|
-
if (!result.success) {
|
|
51871
|
-
const err = result.error ?? "Invalid items";
|
|
51872
|
-
deps.log(`[Bridge service] Install skills failed: ${err}`);
|
|
51873
|
-
if (socket) {
|
|
51874
|
-
sendWsMessage(socket, { type: "install_skills_result", id, success: false, error: err });
|
|
51875
|
-
}
|
|
51876
|
-
return;
|
|
51877
|
-
}
|
|
51878
|
-
if (socket) {
|
|
51879
|
-
sendWsMessage(socket, { type: "install_skills_result", id, success: true, installed: result.installed });
|
|
51880
|
-
}
|
|
51881
|
-
})();
|
|
51882
|
-
};
|
|
51883
|
-
|
|
51884
|
-
// ../bridge/src/agents/install/run-streaming-command.ts
|
|
51885
|
-
import { spawn as spawn11 } from "node:child_process";
|
|
51886
|
-
import * as readline3 from "node:readline";
|
|
51887
|
-
function runStreamingCommand(command, args, options) {
|
|
51888
|
-
return new Promise((resolve36, reject) => {
|
|
51889
|
-
const child = spawn11(command, args, {
|
|
51890
|
-
env: options.env,
|
|
51891
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
51892
|
-
});
|
|
51893
|
-
let settled = false;
|
|
51894
|
-
const timer = options.timeoutMs != null ? setTimeout(() => {
|
|
51895
|
-
child.kill("SIGKILL");
|
|
51896
|
-
if (!settled) {
|
|
51897
|
-
settled = true;
|
|
51898
|
-
reject(new Error(`Command timed out after ${options.timeoutMs}ms`));
|
|
51899
|
-
}
|
|
51900
|
-
}, options.timeoutMs) : null;
|
|
51901
|
-
const onLine = (line) => {
|
|
51902
|
-
if (line.length > 0) options.onLine?.(line);
|
|
51903
|
-
};
|
|
51904
|
-
if (child.stdout) {
|
|
51905
|
-
readline3.createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", onLine);
|
|
51906
|
-
}
|
|
51907
|
-
if (child.stderr) {
|
|
51908
|
-
readline3.createInterface({ input: child.stderr, crlfDelay: Infinity }).on("line", onLine);
|
|
51909
|
-
}
|
|
51910
|
-
child.on("error", (err) => {
|
|
51911
|
-
if (timer) clearTimeout(timer);
|
|
51912
|
-
if (!settled) {
|
|
51913
|
-
settled = true;
|
|
51914
|
-
reject(err);
|
|
51915
|
-
}
|
|
51916
|
-
});
|
|
51917
|
-
child.on("close", (code, signal) => {
|
|
51918
|
-
if (timer) clearTimeout(timer);
|
|
51919
|
-
if (!settled) {
|
|
51920
|
-
settled = true;
|
|
51921
|
-
resolve36({ code, signal });
|
|
51922
|
-
}
|
|
51923
|
-
});
|
|
51924
|
-
});
|
|
51925
|
-
}
|
|
51926
|
-
|
|
51927
|
-
// ../bridge/src/agents/install/commands/run-npm-global-install.ts
|
|
51928
|
-
async function runNpmGlobalInstall(packageName, env, options) {
|
|
51929
|
-
const result = await runStreamingCommand("npm", ["install", "-g", packageName], {
|
|
51930
|
-
env: bridgeAgentPathEnv(env),
|
|
51931
|
-
timeoutMs: options?.timeoutMs ?? 3e5,
|
|
51932
|
-
onLine: options?.onLine
|
|
51933
|
-
});
|
|
51934
|
-
if (result.code !== 0) {
|
|
51935
|
-
throw new Error(`npm install -g ${packageName} failed (exit ${result.code ?? "signal"})`);
|
|
51936
|
-
}
|
|
51937
|
-
}
|
|
51938
|
-
|
|
51939
|
-
// ../bridge/src/agents/install/commands/claude-code.ts
|
|
51940
|
-
var claudeCodeInstallCommand = {
|
|
51941
|
-
agentType: "claude-code",
|
|
51942
|
-
detectCommand: "claude",
|
|
51943
|
-
async install(ctx) {
|
|
51944
|
-
ctx.onProgress?.("Installing Anthropic Claude Code");
|
|
51945
|
-
await runNpmGlobalInstall(
|
|
51946
|
-
"@anthropic-ai/claude-code",
|
|
51947
|
-
{ ...ctx.env, ANTHROPIC_API_KEY: ctx.authToken },
|
|
51948
|
-
{ onLine: (line) => ctx.onProgress?.("Installing Anthropic Claude Code", line) }
|
|
51949
|
-
);
|
|
51950
|
-
}
|
|
51951
|
-
};
|
|
51952
|
-
|
|
51953
|
-
// ../bridge/src/agents/install/commands/codex-acp.ts
|
|
51954
|
-
var codexAcpInstallCommand = {
|
|
51955
|
-
agentType: "codex-acp",
|
|
51956
|
-
detectCommand: "codex",
|
|
51957
|
-
async install(ctx) {
|
|
51958
|
-
ctx.onProgress?.("Installing Codex");
|
|
51959
|
-
await runNpmGlobalInstall(
|
|
51960
|
-
"@openai/codex",
|
|
51961
|
-
{ ...ctx.env, OPENAI_API_KEY: ctx.authToken },
|
|
51962
|
-
{ onLine: (line) => ctx.onProgress?.("Installing Codex", line) }
|
|
51963
|
-
);
|
|
51964
|
-
}
|
|
51965
|
-
};
|
|
51966
|
-
|
|
51967
|
-
// ../bridge/src/agents/install/commands/cursor-cli.ts
|
|
51968
|
-
var cursorCliInstallCommand = {
|
|
51969
|
-
agentType: "cursor-cli",
|
|
51970
|
-
detectCommand: "agent",
|
|
51971
|
-
alternateDetectCommands: ["cursor-agent"],
|
|
51972
|
-
async install(ctx) {
|
|
51973
|
-
ctx.onProgress?.("Installing Cursor CLI");
|
|
51974
|
-
const result = await runStreamingCommand(
|
|
51975
|
-
"bash",
|
|
51976
|
-
["-lc", "curl -fsSL https://cursor.com/install | bash"],
|
|
51977
|
-
{
|
|
51978
|
-
timeoutMs: 3e5,
|
|
51979
|
-
env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken },
|
|
51980
|
-
onLine: (line) => ctx.onProgress?.("Installing Cursor CLI", line)
|
|
51981
|
-
}
|
|
51982
|
-
);
|
|
51983
|
-
if (result.code !== 0) {
|
|
51984
|
-
throw new Error(`Cursor CLI install failed (exit ${result.code ?? "signal"})`);
|
|
51985
|
-
}
|
|
51986
|
-
}
|
|
51987
|
-
};
|
|
51988
|
-
|
|
51989
|
-
// ../bridge/src/agents/install/commands/opencode.ts
|
|
51990
|
-
var opencodeInstallCommand = {
|
|
51991
|
-
agentType: "opencode",
|
|
51992
|
-
detectCommand: "opencode",
|
|
51993
|
-
async install(ctx) {
|
|
51994
|
-
ctx.onProgress?.("Installing OpenCode");
|
|
51995
|
-
await runNpmGlobalInstall(
|
|
51996
|
-
"opencode-ai",
|
|
51997
|
-
{ ...ctx.env, OPENCODE_API_KEY: ctx.authToken },
|
|
51998
|
-
{ onLine: (line) => ctx.onProgress?.("Installing OpenCode", line) }
|
|
51999
|
-
);
|
|
52000
|
-
}
|
|
52001
|
-
};
|
|
52002
|
-
|
|
52003
|
-
// ../bridge/src/agents/install/commands/index.ts
|
|
52004
|
-
var COMMANDS = [
|
|
52005
|
-
claudeCodeInstallCommand,
|
|
52006
|
-
codexAcpInstallCommand,
|
|
52007
|
-
cursorCliInstallCommand,
|
|
52008
|
-
opencodeInstallCommand
|
|
52009
|
-
];
|
|
52010
|
-
var byType = new Map(COMMANDS.map((c) => [c.agentType, c]));
|
|
52011
|
-
function getAgentInstallCommand(agentType) {
|
|
52012
|
-
return byType.get(agentType);
|
|
52013
|
-
}
|
|
52014
|
-
|
|
52015
|
-
// ../bridge/src/agents/install/install-local-agent.ts
|
|
52016
|
-
async function installLocalAgentOnBridge(params) {
|
|
52017
|
-
const spec = INSTALLABLE_BRIDGE_AGENTS.find((a) => a.value === params.agentType);
|
|
52018
|
-
if (!spec) return { success: false, error: `Unsupported agent type: ${params.agentType}` };
|
|
52019
|
-
const command = getAgentInstallCommand(params.agentType);
|
|
52020
|
-
if (!command) return { success: false, error: `No install command for ${params.agentType}` };
|
|
52021
|
-
params.onProgress?.(`Configuring ${spec.label} credentials`);
|
|
52022
|
-
try {
|
|
52023
|
-
await command.install({
|
|
52024
|
-
authToken: params.authToken,
|
|
52025
|
-
onProgress: params.onProgress,
|
|
52026
|
-
env: { ...process.env, [spec.tokenEnvVar]: params.authToken }
|
|
52027
|
-
});
|
|
52028
|
-
} catch (e) {
|
|
52029
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
52030
|
-
return { success: false, error: msg };
|
|
52031
|
-
}
|
|
52032
|
-
ensureBridgeAgentPathInProcessEnv();
|
|
52033
|
-
const detectNames = [
|
|
52034
|
-
command.detectCommand,
|
|
52035
|
-
...command.alternateDetectCommands ?? []
|
|
52036
|
-
];
|
|
52037
|
-
let found = false;
|
|
52038
|
-
for (const name of detectNames) {
|
|
52039
|
-
if (await waitForCommandOnPath(name)) {
|
|
52040
|
-
found = true;
|
|
52041
|
-
break;
|
|
52042
|
-
}
|
|
52043
|
-
}
|
|
52044
|
-
if (!found) {
|
|
52045
|
-
return { success: false, error: `${command.detectCommand} not found on PATH after install` };
|
|
52046
|
-
}
|
|
52047
|
-
return { success: true };
|
|
52048
|
-
}
|
|
52049
|
-
|
|
52050
|
-
// ../bridge/src/routing/handlers/install-agent.ts
|
|
52051
|
-
var handleInstallAgentMessage = (msg, deps) => {
|
|
52052
|
-
const processId = typeof msg.processId === "string" ? msg.processId : "";
|
|
52053
|
-
const agentId = typeof msg.agentId === "string" ? msg.agentId : "";
|
|
52054
|
-
const tokenId = typeof msg.tokenId === "string" ? msg.tokenId : "";
|
|
52055
|
-
const agentType = typeof msg.agentType === "string" ? msg.agentType : "";
|
|
52056
|
-
const authToken = typeof msg.authToken === "string" ? msg.authToken : "";
|
|
52057
|
-
if (!processId || !agentId || !tokenId || !agentType || !authToken) return;
|
|
52058
|
-
void (async () => {
|
|
52059
|
-
const socket = deps.getWs();
|
|
52060
|
-
let pendingLines = [];
|
|
52061
|
-
let flushTimer = null;
|
|
52062
|
-
const sendProgress = (message, logOutput) => {
|
|
52063
|
-
if (!socket) return;
|
|
52064
|
-
sendWsMessage(socket, {
|
|
52065
|
-
type: "install_agent_progress",
|
|
52066
|
-
processId,
|
|
52067
|
-
agentId,
|
|
52068
|
-
tokenId,
|
|
52069
|
-
agentType,
|
|
52070
|
-
step: "agent_install_package",
|
|
52071
|
-
message,
|
|
52072
|
-
...logOutput ? { logOutput } : {}
|
|
52073
|
-
});
|
|
52074
|
-
};
|
|
52075
|
-
const flushLines = (message) => {
|
|
52076
|
-
if (flushTimer) {
|
|
52077
|
-
clearTimeout(flushTimer);
|
|
52078
|
-
flushTimer = null;
|
|
52079
|
-
}
|
|
52080
|
-
if (pendingLines.length === 0) return;
|
|
52081
|
-
const logOutput = pendingLines.join("\n");
|
|
52082
|
-
pendingLines = [];
|
|
52083
|
-
sendProgress(message, logOutput);
|
|
52084
|
-
};
|
|
52085
|
-
const result = await installLocalAgentOnBridge({
|
|
52086
|
-
agentType,
|
|
52087
|
-
authToken,
|
|
52088
|
-
onProgress: (message, logOutput) => {
|
|
52089
|
-
if (logOutput == null) {
|
|
52090
|
-
flushLines(message);
|
|
52091
|
-
sendProgress(message);
|
|
52092
|
-
return;
|
|
52093
|
-
}
|
|
52094
|
-
pendingLines.push(logOutput);
|
|
52095
|
-
if (!flushTimer) {
|
|
52096
|
-
flushTimer = setTimeout(() => flushLines(message), 100);
|
|
52097
|
-
}
|
|
52098
|
-
}
|
|
52099
|
-
});
|
|
52100
|
-
flushLines("Installing agent packages on the bridge machine.");
|
|
52101
|
-
if (socket) {
|
|
52102
|
-
sendWsMessage(socket, {
|
|
52103
|
-
type: "install_agent_result",
|
|
52104
|
-
processId,
|
|
52105
|
-
agentId,
|
|
52106
|
-
tokenId,
|
|
52107
|
-
agentType,
|
|
52108
|
-
success: result.success,
|
|
52109
|
-
error: result.error
|
|
52110
|
-
});
|
|
52111
|
-
}
|
|
52112
|
-
if (result.success) await deps.reportAutoDetectedAgents?.();
|
|
52113
|
-
if (!result.success) {
|
|
52114
|
-
deps.log(`[Bridge service] Install agent failed: ${result.error ?? "unknown"}`);
|
|
52115
|
-
}
|
|
52116
|
-
})();
|
|
52117
|
-
};
|
|
52118
|
-
|
|
52119
|
-
// ../bridge/src/routing/handlers/refresh-local-skills.ts
|
|
52120
|
-
var handleRefreshLocalSkills = (_msg, deps) => {
|
|
52121
|
-
setImmediate(() => {
|
|
52122
|
-
deps.sendLocalSkillsReport?.();
|
|
52123
|
-
});
|
|
52124
|
-
};
|
|
52125
|
-
|
|
52126
|
-
// ../bridge/src/routing/dispatch/skills.ts
|
|
52127
|
-
function dispatchBridgeSkillsMessage(msg, deps) {
|
|
52128
|
-
switch (msg.type) {
|
|
52129
|
-
case "skill_call":
|
|
52130
|
-
handleSkillCallMessage(msg, deps);
|
|
52131
|
-
break;
|
|
52132
|
-
case "skill_layout_request":
|
|
52133
|
-
handleSkillLayoutRequest(msg, deps);
|
|
52134
|
-
break;
|
|
52135
|
-
case "install_skills":
|
|
52136
|
-
handleInstallSkillsMessage(msg, deps);
|
|
52137
|
-
break;
|
|
52138
|
-
case "install_agent":
|
|
52139
|
-
handleInstallAgentMessage(msg, deps);
|
|
52140
|
-
break;
|
|
52141
|
-
case "refresh_local_skills":
|
|
52142
|
-
handleRefreshLocalSkills(msg, deps);
|
|
52143
|
-
break;
|
|
52144
|
-
}
|
|
52145
|
-
}
|
|
52146
|
-
|
|
52147
51727
|
// ../bridge/src/files/browser/send-file-browser-message.ts
|
|
52148
51728
|
function sendFileBrowserMessage(socket, e2ee, payload) {
|
|
52149
51729
|
sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
|
|
@@ -52205,13 +51785,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
52205
51785
|
|
|
52206
51786
|
// ../bridge/src/files/handle-file-browser-search.ts
|
|
52207
51787
|
init_yield_to_event_loop();
|
|
52208
|
-
import
|
|
51788
|
+
import path79 from "node:path";
|
|
52209
51789
|
var SEARCH_LIMIT = 100;
|
|
52210
51790
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
52211
51791
|
void (async () => {
|
|
52212
51792
|
await yieldToEventLoop();
|
|
52213
51793
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
52214
|
-
const sessionParentPath =
|
|
51794
|
+
const sessionParentPath = path79.resolve(
|
|
52215
51795
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
52216
51796
|
);
|
|
52217
51797
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -52243,7 +51823,7 @@ function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
|
|
|
52243
51823
|
});
|
|
52244
51824
|
}
|
|
52245
51825
|
|
|
52246
|
-
// ../bridge/src/routing/handlers/file-browser-messages.ts
|
|
51826
|
+
// ../bridge/src/connection/routing/handlers/file-browser-messages.ts
|
|
52247
51827
|
function handleFileBrowserRequestMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
|
|
52248
51828
|
if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
|
|
52249
51829
|
const socket = getWs();
|
|
@@ -52287,7 +51867,7 @@ function handleCodeNavRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
52287
51867
|
// ../bridge/src/code-nav/handlers/trigger-symbol-index-build.ts
|
|
52288
51868
|
init_normalize_resolved_path();
|
|
52289
51869
|
|
|
52290
|
-
// ../bridge/src/routing/handlers/code-nav-messages.ts
|
|
51870
|
+
// ../bridge/src/connection/routing/handlers/code-nav-messages.ts
|
|
52291
51871
|
function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
|
|
52292
51872
|
if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
|
|
52293
51873
|
const socket = getWs();
|
|
@@ -52309,7 +51889,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
52309
51889
|
}
|
|
52310
51890
|
|
|
52311
51891
|
// ../bridge/src/git/bridge-git-context.ts
|
|
52312
|
-
import * as
|
|
51892
|
+
import * as path80 from "node:path";
|
|
52313
51893
|
init_yield_to_event_loop();
|
|
52314
51894
|
|
|
52315
51895
|
// ../bridge/src/git/branches/get-current-branch.ts
|
|
@@ -52377,12 +51957,12 @@ function listPendingCheckouts() {
|
|
|
52377
51957
|
// ../bridge/src/git/bridge-git-context.ts
|
|
52378
51958
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
52379
51959
|
if (relPath === "." || relPath === "") {
|
|
52380
|
-
return
|
|
51960
|
+
return path80.basename(path80.resolve(bridgeRoot)) || "repo";
|
|
52381
51961
|
}
|
|
52382
|
-
return
|
|
51962
|
+
return path80.basename(relPath) || relPath;
|
|
52383
51963
|
}
|
|
52384
51964
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
52385
|
-
const root =
|
|
51965
|
+
const root = path80.resolve(bridgeRoot);
|
|
52386
51966
|
if (await isGitRepoDirectory(root)) {
|
|
52387
51967
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
52388
51968
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -52390,19 +51970,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
52390
51970
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
52391
51971
|
const byPath = /* @__PURE__ */ new Map();
|
|
52392
51972
|
for (const repo of [...deep, ...shallow]) {
|
|
52393
|
-
byPath.set(
|
|
51973
|
+
byPath.set(path80.resolve(repo.absolutePath), repo);
|
|
52394
51974
|
}
|
|
52395
51975
|
return [...byPath.values()];
|
|
52396
51976
|
}
|
|
52397
51977
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
52398
|
-
const bridgeResolved =
|
|
51978
|
+
const bridgeResolved = path80.resolve(bridgeRoot);
|
|
52399
51979
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
52400
51980
|
const rows = [];
|
|
52401
51981
|
for (let i = 0; i < repos.length; i++) {
|
|
52402
51982
|
if (i > 0) await yieldToEventLoop();
|
|
52403
51983
|
const repo = repos[i];
|
|
52404
|
-
let rel =
|
|
52405
|
-
if (rel.startsWith("..") ||
|
|
51984
|
+
let rel = path80.relative(bridgeResolved, repo.absolutePath);
|
|
51985
|
+
if (rel.startsWith("..") || path80.isAbsolute(rel)) continue;
|
|
52406
51986
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
52407
51987
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
52408
51988
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -52433,17 +52013,17 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
52433
52013
|
return rows;
|
|
52434
52014
|
}
|
|
52435
52015
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
52436
|
-
const bridgeResolved =
|
|
52016
|
+
const bridgeResolved = path80.resolve(bridgeRoot);
|
|
52437
52017
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
52438
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
52439
|
-
const resolved =
|
|
52440
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
52018
|
+
const repoPath = rel === "" ? bridgeResolved : path80.join(bridgeResolved, rel);
|
|
52019
|
+
const resolved = path80.resolve(repoPath);
|
|
52020
|
+
if (!resolved.startsWith(bridgeResolved + path80.sep) && resolved !== bridgeResolved) {
|
|
52441
52021
|
return [];
|
|
52442
52022
|
}
|
|
52443
52023
|
return listRepoBranchRefs(resolved);
|
|
52444
52024
|
}
|
|
52445
52025
|
|
|
52446
|
-
// ../bridge/src/routing/handlers/bridge-git-context-messages.ts
|
|
52026
|
+
// ../bridge/src/connection/routing/handlers/bridge-git-context-messages.ts
|
|
52447
52027
|
function handleBridgeGitContextRequestMessage(msg, getWs) {
|
|
52448
52028
|
void (async () => {
|
|
52449
52029
|
const socket = getWs();
|
|
@@ -52487,8 +52067,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
52487
52067
|
}
|
|
52488
52068
|
|
|
52489
52069
|
// ../bridge/src/git/checkout/bridge-git-checkout.ts
|
|
52490
|
-
import * as
|
|
52491
|
-
import * as
|
|
52070
|
+
import * as fs57 from "node:fs/promises";
|
|
52071
|
+
import * as path82 from "node:path";
|
|
52492
52072
|
|
|
52493
52073
|
// ../bridge/src/git/checkout/normalize-clone-url.ts
|
|
52494
52074
|
function normalizeCloneUrl(url2) {
|
|
@@ -52508,12 +52088,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
52508
52088
|
}
|
|
52509
52089
|
|
|
52510
52090
|
// ../bridge/src/git/checkout/resolve-checkout-target.ts
|
|
52511
|
-
import * as
|
|
52512
|
-
import * as
|
|
52091
|
+
import * as fs56 from "node:fs/promises";
|
|
52092
|
+
import * as path81 from "node:path";
|
|
52513
52093
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
52514
52094
|
async function pathExists(p) {
|
|
52515
52095
|
try {
|
|
52516
|
-
await
|
|
52096
|
+
await fs56.access(p);
|
|
52517
52097
|
return true;
|
|
52518
52098
|
} catch {
|
|
52519
52099
|
return false;
|
|
@@ -52525,7 +52105,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52525
52105
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52526
52106
|
throw new Error("Bridge root is already a git repository");
|
|
52527
52107
|
}
|
|
52528
|
-
const entries = await
|
|
52108
|
+
const entries = await fs56.readdir(bridgeRoot).catch(() => []);
|
|
52529
52109
|
if (entries.length > 0) {
|
|
52530
52110
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
52531
52111
|
}
|
|
@@ -52538,8 +52118,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52538
52118
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52539
52119
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
52540
52120
|
}
|
|
52541
|
-
const targetDir =
|
|
52542
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
52121
|
+
const targetDir = path81.resolve(bridgeRoot, folder);
|
|
52122
|
+
if (!targetDir.startsWith(bridgeRoot + path81.sep)) {
|
|
52543
52123
|
throw new Error("Invalid folderName");
|
|
52544
52124
|
}
|
|
52545
52125
|
if (await pathExists(targetDir)) {
|
|
@@ -52558,10 +52138,10 @@ async function bridgeGitCheckout(params) {
|
|
|
52558
52138
|
});
|
|
52559
52139
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
52560
52140
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
52561
|
-
const parent =
|
|
52562
|
-
await
|
|
52141
|
+
const parent = path82.dirname(targetDir);
|
|
52142
|
+
await fs57.mkdir(parent, { recursive: true });
|
|
52563
52143
|
if (relPath !== ".") {
|
|
52564
|
-
await
|
|
52144
|
+
await fs57.mkdir(targetDir, { recursive: true });
|
|
52565
52145
|
}
|
|
52566
52146
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
52567
52147
|
try {
|
|
@@ -52572,7 +52152,7 @@ async function bridgeGitCheckout(params) {
|
|
|
52572
52152
|
return { relPath, folderName };
|
|
52573
52153
|
} catch (e) {
|
|
52574
52154
|
if (relPath !== ".") {
|
|
52575
|
-
await
|
|
52155
|
+
await fs57.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
52576
52156
|
}
|
|
52577
52157
|
const msg = e instanceof Error ? e.message : String(e);
|
|
52578
52158
|
throw new Error(
|
|
@@ -52583,7 +52163,7 @@ async function bridgeGitCheckout(params) {
|
|
|
52583
52163
|
}
|
|
52584
52164
|
}
|
|
52585
52165
|
|
|
52586
|
-
// ../bridge/src/routing/handlers/bridge-git-checkout-messages.ts
|
|
52166
|
+
// ../bridge/src/connection/routing/handlers/bridge-git-checkout-messages.ts
|
|
52587
52167
|
function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
|
|
52588
52168
|
void (async () => {
|
|
52589
52169
|
const socket = getWs();
|
|
@@ -52623,7 +52203,7 @@ function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
|
|
|
52623
52203
|
})();
|
|
52624
52204
|
}
|
|
52625
52205
|
|
|
52626
|
-
// ../bridge/src/routing/dispatch/file-browser.ts
|
|
52206
|
+
// ../bridge/src/connection/routing/dispatch/file-browser.ts
|
|
52627
52207
|
function dispatchBridgeFileBrowserMessage(msg, deps) {
|
|
52628
52208
|
switch (msg.type) {
|
|
52629
52209
|
case "file_browser_request":
|
|
@@ -52647,12 +52227,13 @@ function dispatchBridgeFileBrowserMessage(msg, deps) {
|
|
|
52647
52227
|
}
|
|
52648
52228
|
}
|
|
52649
52229
|
|
|
52650
|
-
// ../bridge/src/routing/dispatch/index.ts
|
|
52230
|
+
// ../bridge/src/connection/routing/dispatch/index.ts
|
|
52651
52231
|
function dispatchBridgeMessage(msg, deps) {
|
|
52652
52232
|
switch (msg.type) {
|
|
52653
52233
|
case "auth_token":
|
|
52654
52234
|
case "bridge_identified":
|
|
52655
52235
|
case "installed_agent_auth_sync":
|
|
52236
|
+
case "install_agent":
|
|
52656
52237
|
case "ha":
|
|
52657
52238
|
dispatchBridgeConnectionMessage(msg, deps);
|
|
52658
52239
|
break;
|
|
@@ -52672,13 +52253,6 @@ function dispatchBridgeMessage(msg, deps) {
|
|
|
52672
52253
|
case "cursor_request_response":
|
|
52673
52254
|
dispatchBridgeSessionMessage(msg, deps);
|
|
52674
52255
|
break;
|
|
52675
|
-
case "skill_call":
|
|
52676
|
-
case "skill_layout_request":
|
|
52677
|
-
case "install_skills":
|
|
52678
|
-
case "install_agent":
|
|
52679
|
-
case "refresh_local_skills":
|
|
52680
|
-
dispatchBridgeSkillsMessage(msg, deps);
|
|
52681
|
-
break;
|
|
52682
52256
|
case "file_browser_request":
|
|
52683
52257
|
case "file_browser_search":
|
|
52684
52258
|
case "code_nav":
|
|
@@ -52690,7 +52264,7 @@ function dispatchBridgeMessage(msg, deps) {
|
|
|
52690
52264
|
}
|
|
52691
52265
|
}
|
|
52692
52266
|
|
|
52693
|
-
// ../bridge/src/routing/handle-bridge-message.ts
|
|
52267
|
+
// ../bridge/src/connection/routing/handle-bridge-message.ts
|
|
52694
52268
|
function normalizeInboundBridgeWebSocketJson(data) {
|
|
52695
52269
|
if (data === null || typeof data !== "object" || Array.isArray(data)) return data;
|
|
52696
52270
|
const o = data;
|
|
@@ -52708,7 +52282,7 @@ function handleBridgeMessage(data, deps, sourceWs) {
|
|
|
52708
52282
|
dispatchBridgeMessage(msg, deps);
|
|
52709
52283
|
}
|
|
52710
52284
|
|
|
52711
|
-
// ../bridge/src/connection/main-bridge-auth-refresh-handler.ts
|
|
52285
|
+
// ../bridge/src/connection/ws/main-bridge-auth-refresh-handler.ts
|
|
52712
52286
|
function resetAfterAuthInvalid(params) {
|
|
52713
52287
|
const { state } = params;
|
|
52714
52288
|
state.reconnectAttempt = 0;
|
|
@@ -52755,7 +52329,7 @@ function createMainBridgeAuthRefreshHandler(params, connect) {
|
|
|
52755
52329
|
};
|
|
52756
52330
|
}
|
|
52757
52331
|
|
|
52758
|
-
// ../bridge/src/connection/main-bridge-ws-close-handler.ts
|
|
52332
|
+
// ../bridge/src/connection/ws/main-bridge-ws-close-handler.ts
|
|
52759
52333
|
function createMainBridgeCloseHandler(params, connect) {
|
|
52760
52334
|
const { state, logFn, bridgeHeartbeat } = params;
|
|
52761
52335
|
return (code, reason) => {
|
|
@@ -52793,7 +52367,7 @@ function createMainBridgeCloseHandler(params, connect) {
|
|
|
52793
52367
|
};
|
|
52794
52368
|
}
|
|
52795
52369
|
|
|
52796
|
-
// ../bridge/src/connection/report-git-repos.ts
|
|
52370
|
+
// ../bridge/src/connection/reports/report-git-repos.ts
|
|
52797
52371
|
function reportGitRepos(getWs, log2) {
|
|
52798
52372
|
setImmediate(() => {
|
|
52799
52373
|
discoverGitRepos().then((repos) => {
|
|
@@ -52814,7 +52388,7 @@ function reportGitRepos(getWs, log2) {
|
|
|
52814
52388
|
});
|
|
52815
52389
|
}
|
|
52816
52390
|
|
|
52817
|
-
// ../bridge/src/connection/main-bridge-ws-open-handler.ts
|
|
52391
|
+
// ../bridge/src/connection/ws/main-bridge-ws-open-handler.ts
|
|
52818
52392
|
function createMainBridgeOpenHandler(params) {
|
|
52819
52393
|
const {
|
|
52820
52394
|
state,
|
|
@@ -52859,7 +52433,7 @@ function createMainBridgeOpenHandler(params) {
|
|
|
52859
52433
|
};
|
|
52860
52434
|
}
|
|
52861
52435
|
|
|
52862
|
-
// ../bridge/src/connection/main-bridge-ws-lifecycle.ts
|
|
52436
|
+
// ../bridge/src/connection/ws/main-bridge-ws-lifecycle.ts
|
|
52863
52437
|
function createMainBridgeWebSocketLifecycle(params) {
|
|
52864
52438
|
const {
|
|
52865
52439
|
state,
|
|
@@ -52944,7 +52518,7 @@ function createMainBridgeWebSocketLifecycle(params) {
|
|
|
52944
52518
|
return { connect };
|
|
52945
52519
|
}
|
|
52946
52520
|
|
|
52947
|
-
// ../bridge/src/connection/create-bridge-connection.ts
|
|
52521
|
+
// ../bridge/src/connection/runtime/create-bridge-connection.ts
|
|
52948
52522
|
init_log();
|
|
52949
52523
|
async function createBridgeConnection(options) {
|
|
52950
52524
|
const { plugin, workspaceId, justAuthenticated, onAuthInvalid, persistTokens } = options;
|
|
@@ -52994,41 +52568,7 @@ async function createBridgeConnection(options) {
|
|
|
52994
52568
|
};
|
|
52995
52569
|
}
|
|
52996
52570
|
|
|
52997
|
-
// ../bridge/src/
|
|
52998
|
-
import * as readline4 from "node:readline";
|
|
52999
|
-
function installE2eCertificateKeyCommand({
|
|
53000
|
-
log: log2,
|
|
53001
|
-
onOpenCertificate,
|
|
53002
|
-
onInterrupt
|
|
53003
|
-
}) {
|
|
53004
|
-
if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== "function") {
|
|
53005
|
-
log2("[E2EE] Press c to import the E2EE key in a browser when running in an interactive terminal.");
|
|
53006
|
-
return () => {
|
|
53007
|
-
};
|
|
53008
|
-
}
|
|
53009
|
-
readline4.emitKeypressEvents(process.stdin);
|
|
53010
|
-
process.stdin.setRawMode(true);
|
|
53011
|
-
process.stdin.resume();
|
|
53012
|
-
const onKeypress = (str, key) => {
|
|
53013
|
-
if (key?.ctrl && key.name === "c") {
|
|
53014
|
-
onInterrupt();
|
|
53015
|
-
return;
|
|
53016
|
-
}
|
|
53017
|
-
if (!key?.ctrl && !key?.meta && (key?.name === "c" || str === "c")) {
|
|
53018
|
-
onOpenCertificate();
|
|
53019
|
-
}
|
|
53020
|
-
};
|
|
53021
|
-
process.stdin.on("keypress", onKeypress);
|
|
53022
|
-
log2("[E2EE] Press c to import the active E2EE key into the browser.");
|
|
53023
|
-
return () => {
|
|
53024
|
-
process.stdin.off("keypress", onKeypress);
|
|
53025
|
-
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
53026
|
-
process.stdin.setRawMode(false);
|
|
53027
|
-
}
|
|
53028
|
-
};
|
|
53029
|
-
}
|
|
53030
|
-
|
|
53031
|
-
// ../bridge/src/run-bridge-e2ee-key-command.ts
|
|
52571
|
+
// ../bridge/src/cli/run-bridge-e2ee-key-command.ts
|
|
53032
52572
|
function installConnectedBridgeE2eeKeyCommand(params) {
|
|
53033
52573
|
const openImport = params.plugin.cloud?.openCertificateImportUrl;
|
|
53034
52574
|
if (!openImport) return () => {
|
|
@@ -53051,7 +52591,7 @@ function installConnectedBridgeE2eeKeyCommand(params) {
|
|
|
53051
52591
|
});
|
|
53052
52592
|
}
|
|
53053
52593
|
|
|
53054
|
-
// ../bridge/src/run-bridge-connected-signals.ts
|
|
52594
|
+
// ../bridge/src/cli/teardown/run-bridge-connected-signals.ts
|
|
53055
52595
|
init_log();
|
|
53056
52596
|
init_cli_process_interrupt();
|
|
53057
52597
|
function installConnectedBridgeSignals(params) {
|
|
@@ -53085,7 +52625,7 @@ function installConnectedBridgeSignals(params) {
|
|
|
53085
52625
|
};
|
|
53086
52626
|
}
|
|
53087
52627
|
|
|
53088
|
-
// ../bridge/src/run-bridge-on-auth-invalid.ts
|
|
52628
|
+
// ../bridge/src/cli/teardown/run-bridge-on-auth-invalid.ts
|
|
53089
52629
|
init_cli_process_interrupt();
|
|
53090
52630
|
async function closeBridgeForReauth(params) {
|
|
53091
52631
|
params.log("[Bridge service] Access token invalid or revoked; re-authenticating\u2026");
|
|
@@ -53096,7 +52636,7 @@ async function closeBridgeForReauth(params) {
|
|
|
53096
52636
|
params.endConnectedSession();
|
|
53097
52637
|
}
|
|
53098
52638
|
|
|
53099
|
-
// ../bridge/src/run-bridge-connected.ts
|
|
52639
|
+
// ../bridge/src/cli/run-bridge-connected.ts
|
|
53100
52640
|
init_cli_database();
|
|
53101
52641
|
async function runConnectedBridge(options, restartWithoutAuth) {
|
|
53102
52642
|
const { plugin, workspaceId, authToken, refreshToken, justAuthenticated, worktreesRootPath, e2eCertificate } = options;
|
|
@@ -53171,7 +52711,7 @@ async function runConnectedBridge(options, restartWithoutAuth) {
|
|
|
53171
52711
|
await restartWithoutAuth({ plugin, worktreesRootPath, e2eCertificate });
|
|
53172
52712
|
}
|
|
53173
52713
|
|
|
53174
|
-
// ../bridge/src/run-bridge.ts
|
|
52714
|
+
// ../bridge/src/cli/run-bridge.ts
|
|
53175
52715
|
init_cli_process_interrupt();
|
|
53176
52716
|
async function runBridge(options) {
|
|
53177
52717
|
installBridgeProcessResilience();
|
|
@@ -53264,30 +52804,30 @@ function startStreamingProxy(ws, log2, pr) {
|
|
|
53264
52804
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
53265
52805
|
import process8 from "node:process";
|
|
53266
52806
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
53267
|
-
import
|
|
52807
|
+
import path83 from "node:path";
|
|
53268
52808
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
53269
52809
|
import { promisify as promisify8 } from "node:util";
|
|
53270
52810
|
import childProcess from "node:child_process";
|
|
53271
|
-
import
|
|
52811
|
+
import fs62, { constants as fsConstants2 } from "node:fs/promises";
|
|
53272
52812
|
|
|
53273
52813
|
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
53274
52814
|
import process4 from "node:process";
|
|
53275
|
-
import
|
|
52815
|
+
import fs61, { constants as fsConstants } from "node:fs/promises";
|
|
53276
52816
|
|
|
53277
52817
|
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
53278
52818
|
import process3 from "node:process";
|
|
53279
52819
|
import os9 from "node:os";
|
|
53280
|
-
import
|
|
52820
|
+
import fs60 from "node:fs";
|
|
53281
52821
|
|
|
53282
52822
|
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
53283
|
-
import
|
|
52823
|
+
import fs59 from "node:fs";
|
|
53284
52824
|
|
|
53285
52825
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
53286
|
-
import
|
|
52826
|
+
import fs58 from "node:fs";
|
|
53287
52827
|
var isDockerCached;
|
|
53288
52828
|
function hasDockerEnv() {
|
|
53289
52829
|
try {
|
|
53290
|
-
|
|
52830
|
+
fs58.statSync("/.dockerenv");
|
|
53291
52831
|
return true;
|
|
53292
52832
|
} catch {
|
|
53293
52833
|
return false;
|
|
@@ -53295,7 +52835,7 @@ function hasDockerEnv() {
|
|
|
53295
52835
|
}
|
|
53296
52836
|
function hasDockerCGroup() {
|
|
53297
52837
|
try {
|
|
53298
|
-
return
|
|
52838
|
+
return fs58.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
53299
52839
|
} catch {
|
|
53300
52840
|
return false;
|
|
53301
52841
|
}
|
|
@@ -53311,7 +52851,7 @@ function isDocker() {
|
|
|
53311
52851
|
var cachedResult;
|
|
53312
52852
|
var hasContainerEnv = () => {
|
|
53313
52853
|
try {
|
|
53314
|
-
|
|
52854
|
+
fs59.statSync("/run/.containerenv");
|
|
53315
52855
|
return true;
|
|
53316
52856
|
} catch {
|
|
53317
52857
|
return false;
|
|
@@ -53336,12 +52876,12 @@ var isWsl = () => {
|
|
|
53336
52876
|
return true;
|
|
53337
52877
|
}
|
|
53338
52878
|
try {
|
|
53339
|
-
if (
|
|
52879
|
+
if (fs60.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
53340
52880
|
return !isInsideContainer();
|
|
53341
52881
|
}
|
|
53342
52882
|
} catch {
|
|
53343
52883
|
}
|
|
53344
|
-
if (
|
|
52884
|
+
if (fs60.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs60.existsSync("/run/WSL")) {
|
|
53345
52885
|
return !isInsideContainer();
|
|
53346
52886
|
}
|
|
53347
52887
|
return false;
|
|
@@ -53359,14 +52899,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
53359
52899
|
const configFilePath2 = "/etc/wsl.conf";
|
|
53360
52900
|
let isConfigFileExists = false;
|
|
53361
52901
|
try {
|
|
53362
|
-
await
|
|
52902
|
+
await fs61.access(configFilePath2, fsConstants.F_OK);
|
|
53363
52903
|
isConfigFileExists = true;
|
|
53364
52904
|
} catch {
|
|
53365
52905
|
}
|
|
53366
52906
|
if (!isConfigFileExists) {
|
|
53367
52907
|
return defaultMountPoint;
|
|
53368
52908
|
}
|
|
53369
|
-
const configContent = await
|
|
52909
|
+
const configContent = await fs61.readFile(configFilePath2, { encoding: "utf8" });
|
|
53370
52910
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
53371
52911
|
if (!configMountPoint) {
|
|
53372
52912
|
return defaultMountPoint;
|
|
@@ -53520,8 +53060,8 @@ async function defaultBrowser2() {
|
|
|
53520
53060
|
|
|
53521
53061
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
53522
53062
|
var execFile7 = promisify8(childProcess.execFile);
|
|
53523
|
-
var __dirname =
|
|
53524
|
-
var localXdgOpenPath =
|
|
53063
|
+
var __dirname = path83.dirname(fileURLToPath7(import.meta.url));
|
|
53064
|
+
var localXdgOpenPath = path83.join(__dirname, "xdg-open");
|
|
53525
53065
|
var { platform, arch } = process8;
|
|
53526
53066
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
53527
53067
|
const powershellPath = await powerShellPath();
|
|
@@ -53671,7 +53211,7 @@ var baseOpen = async (options) => {
|
|
|
53671
53211
|
const isBundled = !__dirname || __dirname === "/";
|
|
53672
53212
|
let exeLocalXdgOpen = false;
|
|
53673
53213
|
try {
|
|
53674
|
-
await
|
|
53214
|
+
await fs62.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
53675
53215
|
exeLocalXdgOpen = true;
|
|
53676
53216
|
} catch {
|
|
53677
53217
|
}
|
|
@@ -53918,7 +53458,7 @@ function createPendingAuthOnMessage(params) {
|
|
|
53918
53458
|
}
|
|
53919
53459
|
|
|
53920
53460
|
// src/cli-version.ts
|
|
53921
|
-
var CLI_VERSION2 = "0.1.
|
|
53461
|
+
var CLI_VERSION2 = "0.1.90".length > 0 ? "0.1.90" : "0.0.0-dev";
|
|
53922
53462
|
|
|
53923
53463
|
// src/auth/pending/pending-auth-on-open.ts
|
|
53924
53464
|
function createPendingAuthOnOpen(params) {
|
|
@@ -54029,12 +53569,12 @@ async function refreshBridgeTokens(params) {
|
|
|
54029
53569
|
}
|
|
54030
53570
|
|
|
54031
53571
|
// src/config.ts
|
|
54032
|
-
import
|
|
54033
|
-
import
|
|
53572
|
+
import fs63 from "node:fs";
|
|
53573
|
+
import path84 from "node:path";
|
|
54034
53574
|
import os10 from "node:os";
|
|
54035
53575
|
function getConfigPath() {
|
|
54036
|
-
const dir =
|
|
54037
|
-
return
|
|
53576
|
+
const dir = path84.join(os10.homedir(), ".buildautomaton");
|
|
53577
|
+
return path84.join(dir, "config.json");
|
|
54038
53578
|
}
|
|
54039
53579
|
function normalizeApiUrl(url2) {
|
|
54040
53580
|
return url2.replace(/\/$/, "");
|
|
@@ -54042,7 +53582,7 @@ function normalizeApiUrl(url2) {
|
|
|
54042
53582
|
function readRawConfig() {
|
|
54043
53583
|
try {
|
|
54044
53584
|
const p = getConfigPath();
|
|
54045
|
-
const raw =
|
|
53585
|
+
const raw = fs63.readFileSync(p, "utf8");
|
|
54046
53586
|
return JSON.parse(raw);
|
|
54047
53587
|
} catch {
|
|
54048
53588
|
return null;
|
|
@@ -54050,14 +53590,14 @@ function readRawConfig() {
|
|
|
54050
53590
|
}
|
|
54051
53591
|
function writeConfigForApi(apiUrl, auth) {
|
|
54052
53592
|
const p = getConfigPath();
|
|
54053
|
-
const dir =
|
|
53593
|
+
const dir = path84.dirname(p);
|
|
54054
53594
|
const key = normalizeApiUrl(apiUrl);
|
|
54055
53595
|
const prev = readRawConfig() ?? {};
|
|
54056
53596
|
const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
|
|
54057
53597
|
const next = { ...prev, servers };
|
|
54058
53598
|
try {
|
|
54059
|
-
if (!
|
|
54060
|
-
|
|
53599
|
+
if (!fs63.existsSync(dir)) fs63.mkdirSync(dir, { recursive: true });
|
|
53600
|
+
fs63.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
54061
53601
|
} catch (e) {
|
|
54062
53602
|
console.error("Could not save authentication config:", e);
|
|
54063
53603
|
}
|
|
@@ -54066,22 +53606,22 @@ function clearConfigForApi(apiUrl) {
|
|
|
54066
53606
|
const key = normalizeApiUrl(apiUrl);
|
|
54067
53607
|
try {
|
|
54068
53608
|
const p = getConfigPath();
|
|
54069
|
-
if (!
|
|
53609
|
+
if (!fs63.existsSync(p)) return;
|
|
54070
53610
|
const prev = readRawConfig();
|
|
54071
53611
|
if (!prev) return;
|
|
54072
53612
|
const servers = { ...prev.servers ?? {} };
|
|
54073
53613
|
delete servers[key];
|
|
54074
53614
|
const next = { ...prev, servers };
|
|
54075
53615
|
if (Object.keys(servers).length === 0 && !prev.workspaceId) {
|
|
54076
|
-
|
|
53616
|
+
fs63.unlinkSync(p);
|
|
54077
53617
|
return;
|
|
54078
53618
|
}
|
|
54079
53619
|
if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
|
|
54080
53620
|
const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
|
|
54081
|
-
|
|
53621
|
+
fs63.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
|
|
54082
53622
|
return;
|
|
54083
53623
|
}
|
|
54084
|
-
|
|
53624
|
+
fs63.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
54085
53625
|
} catch {
|
|
54086
53626
|
}
|
|
54087
53627
|
}
|
|
@@ -54488,6 +54028,14 @@ function createBridgeMcpToolRegistry(shared) {
|
|
|
54488
54028
|
};
|
|
54489
54029
|
}
|
|
54490
54030
|
|
|
54031
|
+
// ../e2ee/src/encoding.ts
|
|
54032
|
+
function base64UrlEncode2(bytes) {
|
|
54033
|
+
let binary = "";
|
|
54034
|
+
for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
|
|
54035
|
+
const b64 = btoa(binary);
|
|
54036
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
54037
|
+
}
|
|
54038
|
+
|
|
54491
54039
|
// src/agents/acp/fetch-session-attachments.ts
|
|
54492
54040
|
function metaSaysEncrypted(meta3) {
|
|
54493
54041
|
if (!meta3) return false;
|
|
@@ -54557,7 +54105,7 @@ async function fetchSessionAttachmentPayloadsForAgent(params) {
|
|
|
54557
54105
|
if (!k || !n) {
|
|
54558
54106
|
return { ok: false, error: "Invalid encrypted attachment metadata (missing key id or nonce)." };
|
|
54559
54107
|
}
|
|
54560
|
-
const c =
|
|
54108
|
+
const c = base64UrlEncode2(buf);
|
|
54561
54109
|
imageBytes = e2ee.decryptEnvelopeToBuffer({ k, n, c });
|
|
54562
54110
|
} else {
|
|
54563
54111
|
imageBytes = buf;
|
|
@@ -55143,15 +54691,12 @@ function toTokens(auth) {
|
|
|
55143
54691
|
return { workspaceId: auth.workspaceId, accessToken: auth.token, refreshToken: auth.refreshToken };
|
|
55144
54692
|
}
|
|
55145
54693
|
export {
|
|
55146
|
-
callSkill,
|
|
55147
54694
|
createSdkStdioAcpClient as createAcpClient,
|
|
55148
54695
|
createBridgeConnection,
|
|
55149
54696
|
createBuildAutomatonPlugin,
|
|
55150
54697
|
createGenericWebSocketPlugin,
|
|
55151
54698
|
createWsBridge,
|
|
55152
54699
|
getCliLogVerbosity,
|
|
55153
|
-
getSkill,
|
|
55154
|
-
getSkills,
|
|
55155
54700
|
log,
|
|
55156
54701
|
logDebug,
|
|
55157
54702
|
logTrace,
|