@buildautomaton/cli 0.1.94 → 0.1.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +801 -1101
- package/dist/cli.js.map +4 -4
- package/dist/index.js +767 -1064
- package/dist/index.js.map +4 -4
- package/dist/worker.js +84 -161
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4086,10 +4086,10 @@ function mergeDefs(...defs) {
|
|
|
4086
4086
|
function cloneDef(schema) {
|
|
4087
4087
|
return mergeDefs(schema._zod.def);
|
|
4088
4088
|
}
|
|
4089
|
-
function getElementAtPath(obj,
|
|
4090
|
-
if (!
|
|
4089
|
+
function getElementAtPath(obj, path83) {
|
|
4090
|
+
if (!path83)
|
|
4091
4091
|
return obj;
|
|
4092
|
-
return
|
|
4092
|
+
return path83.reduce((acc, key) => acc?.[key], obj);
|
|
4093
4093
|
}
|
|
4094
4094
|
function promiseAllObject(promisesObj) {
|
|
4095
4095
|
const keys = Object.keys(promisesObj);
|
|
@@ -4417,11 +4417,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
4417
4417
|
}
|
|
4418
4418
|
return false;
|
|
4419
4419
|
}
|
|
4420
|
-
function prefixIssues(
|
|
4420
|
+
function prefixIssues(path83, issues) {
|
|
4421
4421
|
return issues.map((iss) => {
|
|
4422
4422
|
var _a4;
|
|
4423
4423
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
4424
|
-
iss.path.unshift(
|
|
4424
|
+
iss.path.unshift(path83);
|
|
4425
4425
|
return iss;
|
|
4426
4426
|
});
|
|
4427
4427
|
}
|
|
@@ -4638,16 +4638,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4638
4638
|
}
|
|
4639
4639
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
4640
4640
|
const fieldErrors = { _errors: [] };
|
|
4641
|
-
const processError = (error52,
|
|
4641
|
+
const processError = (error52, path83 = []) => {
|
|
4642
4642
|
for (const issue2 of error52.issues) {
|
|
4643
4643
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4644
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4644
|
+
issue2.errors.map((issues) => processError({ issues }, [...path83, ...issue2.path]));
|
|
4645
4645
|
} else if (issue2.code === "invalid_key") {
|
|
4646
|
-
processError({ issues: issue2.issues }, [...
|
|
4646
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4647
4647
|
} else if (issue2.code === "invalid_element") {
|
|
4648
|
-
processError({ issues: issue2.issues }, [...
|
|
4648
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4649
4649
|
} else {
|
|
4650
|
-
const fullpath = [...
|
|
4650
|
+
const fullpath = [...path83, ...issue2.path];
|
|
4651
4651
|
if (fullpath.length === 0) {
|
|
4652
4652
|
fieldErrors._errors.push(mapper(issue2));
|
|
4653
4653
|
} else {
|
|
@@ -4674,17 +4674,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4674
4674
|
}
|
|
4675
4675
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
4676
4676
|
const result = { errors: [] };
|
|
4677
|
-
const processError = (error52,
|
|
4677
|
+
const processError = (error52, path83 = []) => {
|
|
4678
4678
|
var _a4, _b;
|
|
4679
4679
|
for (const issue2 of error52.issues) {
|
|
4680
4680
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4681
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4681
|
+
issue2.errors.map((issues) => processError({ issues }, [...path83, ...issue2.path]));
|
|
4682
4682
|
} else if (issue2.code === "invalid_key") {
|
|
4683
|
-
processError({ issues: issue2.issues }, [...
|
|
4683
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4684
4684
|
} else if (issue2.code === "invalid_element") {
|
|
4685
|
-
processError({ issues: issue2.issues }, [...
|
|
4685
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4686
4686
|
} else {
|
|
4687
|
-
const fullpath = [...
|
|
4687
|
+
const fullpath = [...path83, ...issue2.path];
|
|
4688
4688
|
if (fullpath.length === 0) {
|
|
4689
4689
|
result.errors.push(mapper(issue2));
|
|
4690
4690
|
continue;
|
|
@@ -4716,8 +4716,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4716
4716
|
}
|
|
4717
4717
|
function toDotPath(_path) {
|
|
4718
4718
|
const segs = [];
|
|
4719
|
-
const
|
|
4720
|
-
for (const seg of
|
|
4719
|
+
const path83 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
4720
|
+
for (const seg of path83) {
|
|
4721
4721
|
if (typeof seg === "number")
|
|
4722
4722
|
segs.push(`[${seg}]`);
|
|
4723
4723
|
else if (typeof seg === "symbol")
|
|
@@ -18147,13 +18147,13 @@ function resolveRef(ref, ctx) {
|
|
|
18147
18147
|
if (!ref.startsWith("#")) {
|
|
18148
18148
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18149
18149
|
}
|
|
18150
|
-
const
|
|
18151
|
-
if (
|
|
18150
|
+
const path83 = ref.slice(1).split("/").filter(Boolean);
|
|
18151
|
+
if (path83.length === 0) {
|
|
18152
18152
|
return ctx.rootSchema;
|
|
18153
18153
|
}
|
|
18154
18154
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18155
|
-
if (
|
|
18156
|
-
const key =
|
|
18155
|
+
if (path83[0] === defsKey) {
|
|
18156
|
+
const key = path83[1];
|
|
18157
18157
|
if (!key || !ctx.defs[key]) {
|
|
18158
18158
|
throw new Error(`Reference not found: ${ref}`);
|
|
18159
18159
|
}
|
|
@@ -21748,7 +21748,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
21748
21748
|
join2(moduleDir, "..", sub, filename),
|
|
21749
21749
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
21750
21750
|
]);
|
|
21751
|
-
const resolved = candidates.find((
|
|
21751
|
+
const resolved = candidates.find((path83) => existsSync(path83));
|
|
21752
21752
|
if (!resolved) {
|
|
21753
21753
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
21754
21754
|
}
|
|
@@ -21923,6 +21923,7 @@ function withCodeNavCacheSqliteWorkLock(fn) {
|
|
|
21923
21923
|
var chain, workLockDepth;
|
|
21924
21924
|
var init_code_nav_cache_sqlite_work_lock = __esm({
|
|
21925
21925
|
"../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-work-lock.ts"() {
|
|
21926
|
+
"use strict";
|
|
21926
21927
|
init_code_nav_cache_paths();
|
|
21927
21928
|
chain = Promise.resolve();
|
|
21928
21929
|
workLockDepth = 0;
|
|
@@ -22136,31 +22137,18 @@ var init_cli_sqlite_paths = __esm({
|
|
|
22136
22137
|
}
|
|
22137
22138
|
});
|
|
22138
22139
|
|
|
22139
|
-
// ../bridge/src/prompt-turn-queue/paths.ts
|
|
22140
|
-
import path7 from "node:path";
|
|
22141
|
-
import os4 from "node:os";
|
|
22142
|
-
function getPromptQueuesDirectory() {
|
|
22143
|
-
const override = process.env.BUILDAMATON_PROMPT_QUEUES_DIR?.trim();
|
|
22144
|
-
if (override) return path7.resolve(override);
|
|
22145
|
-
return path7.join(os4.homedir(), ".buildautomaton", "queues");
|
|
22146
|
-
}
|
|
22147
|
-
var init_paths2 = __esm({
|
|
22148
|
-
"../bridge/src/prompt-turn-queue/paths.ts"() {
|
|
22149
|
-
}
|
|
22150
|
-
});
|
|
22151
|
-
|
|
22152
22140
|
// ../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts
|
|
22153
22141
|
import fs7 from "node:fs";
|
|
22154
|
-
import
|
|
22142
|
+
import path7 from "node:path";
|
|
22155
22143
|
function moveLegacyFileToOldVersionBackup(category, sourcePath) {
|
|
22156
|
-
const destDir =
|
|
22144
|
+
const destDir = path7.join(OLD_VERSION_DIR, category);
|
|
22157
22145
|
fs7.mkdirSync(destDir, { recursive: true });
|
|
22158
|
-
const base =
|
|
22159
|
-
let dest =
|
|
22146
|
+
const base = path7.basename(sourcePath);
|
|
22147
|
+
let dest = path7.join(destDir, base);
|
|
22160
22148
|
if (fs7.existsSync(dest)) {
|
|
22161
|
-
const ext =
|
|
22149
|
+
const ext = path7.extname(base);
|
|
22162
22150
|
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
22163
|
-
dest =
|
|
22151
|
+
dest = path7.join(destDir, `${stem}-${Date.now()}${ext}`);
|
|
22164
22152
|
}
|
|
22165
22153
|
fs7.renameSync(sourcePath, dest);
|
|
22166
22154
|
}
|
|
@@ -22169,19 +22157,19 @@ var init_archive_to_old_version = __esm({
|
|
|
22169
22157
|
"../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts"() {
|
|
22170
22158
|
"use strict";
|
|
22171
22159
|
init_constants();
|
|
22172
|
-
OLD_VERSION_DIR =
|
|
22160
|
+
OLD_VERSION_DIR = path7.join(INDEX_DIR, "old-version");
|
|
22173
22161
|
}
|
|
22174
22162
|
});
|
|
22175
22163
|
|
|
22176
22164
|
// ../bridge/src/sqlite/legacy_migration/archive-file-index-json.ts
|
|
22177
22165
|
import fs8 from "node:fs";
|
|
22178
|
-
import
|
|
22166
|
+
import path8 from "node:path";
|
|
22179
22167
|
function archiveLegacyFileIndexJsonFiles() {
|
|
22180
22168
|
try {
|
|
22181
22169
|
if (!fs8.existsSync(INDEX_DIR)) return;
|
|
22182
22170
|
for (const name of fs8.readdirSync(INDEX_DIR)) {
|
|
22183
22171
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) {
|
|
22184
|
-
const full =
|
|
22172
|
+
const full = path8.join(INDEX_DIR, name);
|
|
22185
22173
|
try {
|
|
22186
22174
|
moveLegacyFileToOldVersionBackup("file-index", full);
|
|
22187
22175
|
} catch (err) {
|
|
@@ -22203,15 +22191,15 @@ var init_archive_file_index_json = __esm({
|
|
|
22203
22191
|
|
|
22204
22192
|
// ../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts
|
|
22205
22193
|
import fs9 from "node:fs";
|
|
22206
|
-
import
|
|
22207
|
-
import
|
|
22194
|
+
import path9 from "node:path";
|
|
22195
|
+
import os4 from "node:os";
|
|
22208
22196
|
function importLegacyAgentSessionsFromDisk(db) {
|
|
22209
22197
|
try {
|
|
22210
22198
|
if (!fs9.existsSync(LEGACY_AGENT_SESSION_DIR)) return;
|
|
22211
22199
|
const names = fs9.readdirSync(LEGACY_AGENT_SESSION_DIR).filter((n) => n.endsWith(".json"));
|
|
22212
22200
|
for (const name of names) {
|
|
22213
22201
|
const sessionKey = name.slice(0, -".json".length);
|
|
22214
|
-
const full =
|
|
22202
|
+
const full = path9.join(LEGACY_AGENT_SESSION_DIR, name);
|
|
22215
22203
|
let raw;
|
|
22216
22204
|
try {
|
|
22217
22205
|
raw = fs9.readFileSync(full, "utf8");
|
|
@@ -22248,89 +22236,27 @@ var init_import_agent_sessions_from_disk = __esm({
|
|
|
22248
22236
|
"../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts"() {
|
|
22249
22237
|
"use strict";
|
|
22250
22238
|
init_archive_to_old_version();
|
|
22251
|
-
LEGACY_AGENT_SESSION_DIR =
|
|
22252
|
-
}
|
|
22253
|
-
});
|
|
22254
|
-
|
|
22255
|
-
// ../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts
|
|
22256
|
-
function parsePersistedQueueFromJson(raw) {
|
|
22257
|
-
try {
|
|
22258
|
-
const o = JSON.parse(raw);
|
|
22259
|
-
const queueKey = typeof o.queueKey === "string" ? o.queueKey : typeof o.queueKeyHash === "string" ? o.queueKeyHash : null;
|
|
22260
|
-
if (!queueKey || typeof o.updatedAt !== "string" || !Array.isArray(o.turns)) return null;
|
|
22261
|
-
return { queueKey, updatedAt: o.updatedAt, turns: o.turns };
|
|
22262
|
-
} catch {
|
|
22263
|
-
return null;
|
|
22264
|
-
}
|
|
22265
|
-
}
|
|
22266
|
-
var init_parse_persisted_queue_json = __esm({
|
|
22267
|
-
"../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts"() {
|
|
22268
|
-
"use strict";
|
|
22269
|
-
}
|
|
22270
|
-
});
|
|
22271
|
-
|
|
22272
|
-
// ../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts
|
|
22273
|
-
import fs10 from "node:fs";
|
|
22274
|
-
import path11 from "node:path";
|
|
22275
|
-
function importLegacyPromptQueuesFromDisk(db) {
|
|
22276
|
-
try {
|
|
22277
|
-
const dir = getPromptQueuesDirectory();
|
|
22278
|
-
if (!fs10.existsSync(dir)) return;
|
|
22279
|
-
for (const name of fs10.readdirSync(dir)) {
|
|
22280
|
-
if (!name.endsWith(".json")) continue;
|
|
22281
|
-
const full = path11.join(dir, name);
|
|
22282
|
-
let raw;
|
|
22283
|
-
try {
|
|
22284
|
-
raw = fs10.readFileSync(full, "utf8");
|
|
22285
|
-
} catch {
|
|
22286
|
-
continue;
|
|
22287
|
-
}
|
|
22288
|
-
const file2 = parsePersistedQueueFromJson(raw);
|
|
22289
|
-
if (!file2) continue;
|
|
22290
|
-
db.run(
|
|
22291
|
-
`INSERT OR REPLACE INTO prompt_queue (queue_key, updated_at, turns_json) VALUES (?, ?, ?)`,
|
|
22292
|
-
[file2.queueKey, file2.updatedAt, JSON.stringify(file2.turns)]
|
|
22293
|
-
);
|
|
22294
|
-
try {
|
|
22295
|
-
moveLegacyFileToOldVersionBackup("queues", full);
|
|
22296
|
-
} catch {
|
|
22297
|
-
}
|
|
22298
|
-
}
|
|
22299
|
-
} catch (e) {
|
|
22300
|
-
console.error("[cli-sqlite] legacy import: prompt queues from disk failed", e);
|
|
22301
|
-
}
|
|
22302
|
-
}
|
|
22303
|
-
var init_import_prompt_queues_from_disk = __esm({
|
|
22304
|
-
"../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts"() {
|
|
22305
|
-
"use strict";
|
|
22306
|
-
init_paths2();
|
|
22307
|
-
init_archive_to_old_version();
|
|
22308
|
-
init_parse_persisted_queue_json();
|
|
22239
|
+
LEGACY_AGENT_SESSION_DIR = path9.join(os4.homedir(), ".buildautomaton", "agent-sessions");
|
|
22309
22240
|
}
|
|
22310
22241
|
});
|
|
22311
22242
|
|
|
22312
22243
|
// ../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts
|
|
22313
|
-
import
|
|
22244
|
+
import fs10 from "node:fs";
|
|
22314
22245
|
function legacyCliDiskMigrationIsPending() {
|
|
22315
22246
|
try {
|
|
22316
|
-
if (
|
|
22317
|
-
for (const name of
|
|
22247
|
+
if (fs10.existsSync(INDEX_DIR)) {
|
|
22248
|
+
for (const name of fs10.readdirSync(INDEX_DIR)) {
|
|
22318
22249
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) return true;
|
|
22319
22250
|
}
|
|
22320
22251
|
}
|
|
22321
22252
|
} catch {
|
|
22322
22253
|
}
|
|
22323
22254
|
try {
|
|
22324
|
-
if (
|
|
22325
|
-
if (
|
|
22255
|
+
if (fs10.existsSync(LEGACY_AGENT_SESSION_DIR)) {
|
|
22256
|
+
if (fs10.readdirSync(LEGACY_AGENT_SESSION_DIR).some((n) => n.endsWith(".json"))) return true;
|
|
22326
22257
|
}
|
|
22327
22258
|
} catch {
|
|
22328
22259
|
}
|
|
22329
|
-
try {
|
|
22330
|
-
const dir = getPromptQueuesDirectory();
|
|
22331
|
-
if (fs11.existsSync(dir) && fs11.readdirSync(dir).some((n) => n.endsWith(".json"))) return true;
|
|
22332
|
-
} catch {
|
|
22333
|
-
}
|
|
22334
22260
|
return false;
|
|
22335
22261
|
}
|
|
22336
22262
|
function importCliSqliteLegacyDiskData(db, log2) {
|
|
@@ -22340,7 +22266,6 @@ function importCliSqliteLegacyDiskData(db, log2) {
|
|
|
22340
22266
|
}
|
|
22341
22267
|
archiveLegacyFileIndexJsonFiles();
|
|
22342
22268
|
importLegacyAgentSessionsFromDisk(db);
|
|
22343
|
-
importLegacyPromptQueuesFromDisk(db);
|
|
22344
22269
|
if (pending2 && log2) {
|
|
22345
22270
|
log2("Legacy on-disk CLI data migration finished.");
|
|
22346
22271
|
}
|
|
@@ -22349,10 +22274,8 @@ var init_import_cli_legacy_disk_data = __esm({
|
|
|
22349
22274
|
"../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts"() {
|
|
22350
22275
|
"use strict";
|
|
22351
22276
|
init_constants();
|
|
22352
|
-
init_paths2();
|
|
22353
22277
|
init_archive_file_index_json();
|
|
22354
22278
|
init_import_agent_sessions_from_disk();
|
|
22355
|
-
init_import_prompt_queues_from_disk();
|
|
22356
22279
|
}
|
|
22357
22280
|
});
|
|
22358
22281
|
|
|
@@ -22462,15 +22385,15 @@ var init_cli_database = __esm({
|
|
|
22462
22385
|
});
|
|
22463
22386
|
|
|
22464
22387
|
// ../bridge/src/files/index/walk-workspace-tree.ts
|
|
22465
|
-
import
|
|
22466
|
-
import
|
|
22388
|
+
import fs11 from "node:fs";
|
|
22389
|
+
import path10 from "node:path";
|
|
22467
22390
|
function shouldSkipWorkspaceWalkEntry(name) {
|
|
22468
22391
|
return DEPENDENCY_INSTALL_DIR_NAMES.has(name);
|
|
22469
22392
|
}
|
|
22470
22393
|
async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
22471
22394
|
let names;
|
|
22472
22395
|
try {
|
|
22473
|
-
names = await
|
|
22396
|
+
names = await fs11.promises.readdir(dir);
|
|
22474
22397
|
} catch {
|
|
22475
22398
|
return;
|
|
22476
22399
|
}
|
|
@@ -22485,14 +22408,14 @@ async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
|
22485
22408
|
await yieldUntilFileBrowserReadsIdle();
|
|
22486
22409
|
}
|
|
22487
22410
|
state.n++;
|
|
22488
|
-
const full =
|
|
22411
|
+
const full = path10.join(dir, name);
|
|
22489
22412
|
let stat2;
|
|
22490
22413
|
try {
|
|
22491
|
-
stat2 = await
|
|
22414
|
+
stat2 = await fs11.promises.stat(full);
|
|
22492
22415
|
} catch {
|
|
22493
22416
|
continue;
|
|
22494
22417
|
}
|
|
22495
|
-
const relative6 =
|
|
22418
|
+
const relative6 = path10.relative(baseDir, full).replace(/\\/g, "/");
|
|
22496
22419
|
if (stat2.isDirectory()) {
|
|
22497
22420
|
await walkWorkspaceTreeAsync(full, baseDir, onFile, state);
|
|
22498
22421
|
} else if (stat2.isFile()) {
|
|
@@ -22821,7 +22744,7 @@ var require_ignore = __commonJS({
|
|
|
22821
22744
|
// path matching.
|
|
22822
22745
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
22823
22746
|
// @returns {TestResult} true if a file is ignored
|
|
22824
|
-
test(
|
|
22747
|
+
test(path83, checkUnignored, mode) {
|
|
22825
22748
|
let ignored = false;
|
|
22826
22749
|
let unignored = false;
|
|
22827
22750
|
let matchedRule;
|
|
@@ -22830,7 +22753,7 @@ var require_ignore = __commonJS({
|
|
|
22830
22753
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
22831
22754
|
return;
|
|
22832
22755
|
}
|
|
22833
|
-
const matched = rule[mode].test(
|
|
22756
|
+
const matched = rule[mode].test(path83);
|
|
22834
22757
|
if (!matched) {
|
|
22835
22758
|
return;
|
|
22836
22759
|
}
|
|
@@ -22851,17 +22774,17 @@ var require_ignore = __commonJS({
|
|
|
22851
22774
|
var throwError = (message, Ctor) => {
|
|
22852
22775
|
throw new Ctor(message);
|
|
22853
22776
|
};
|
|
22854
|
-
var checkPath = (
|
|
22855
|
-
if (!isString(
|
|
22777
|
+
var checkPath = (path83, originalPath, doThrow) => {
|
|
22778
|
+
if (!isString(path83)) {
|
|
22856
22779
|
return doThrow(
|
|
22857
22780
|
`path must be a string, but got \`${originalPath}\``,
|
|
22858
22781
|
TypeError
|
|
22859
22782
|
);
|
|
22860
22783
|
}
|
|
22861
|
-
if (!
|
|
22784
|
+
if (!path83) {
|
|
22862
22785
|
return doThrow(`path must not be empty`, TypeError);
|
|
22863
22786
|
}
|
|
22864
|
-
if (checkPath.isNotRelative(
|
|
22787
|
+
if (checkPath.isNotRelative(path83)) {
|
|
22865
22788
|
const r = "`path.relative()`d";
|
|
22866
22789
|
return doThrow(
|
|
22867
22790
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -22870,7 +22793,7 @@ var require_ignore = __commonJS({
|
|
|
22870
22793
|
}
|
|
22871
22794
|
return true;
|
|
22872
22795
|
};
|
|
22873
|
-
var isNotRelative = (
|
|
22796
|
+
var isNotRelative = (path83) => REGEX_TEST_INVALID_PATH.test(path83);
|
|
22874
22797
|
checkPath.isNotRelative = isNotRelative;
|
|
22875
22798
|
checkPath.convert = (p) => p;
|
|
22876
22799
|
var Ignore = class {
|
|
@@ -22900,19 +22823,19 @@ var require_ignore = __commonJS({
|
|
|
22900
22823
|
}
|
|
22901
22824
|
// @returns {TestResult}
|
|
22902
22825
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
22903
|
-
const
|
|
22826
|
+
const path83 = originalPath && checkPath.convert(originalPath);
|
|
22904
22827
|
checkPath(
|
|
22905
|
-
|
|
22828
|
+
path83,
|
|
22906
22829
|
originalPath,
|
|
22907
22830
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
22908
22831
|
);
|
|
22909
|
-
return this._t(
|
|
22832
|
+
return this._t(path83, cache2, checkUnignored, slices);
|
|
22910
22833
|
}
|
|
22911
|
-
checkIgnore(
|
|
22912
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
22913
|
-
return this.test(
|
|
22834
|
+
checkIgnore(path83) {
|
|
22835
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path83)) {
|
|
22836
|
+
return this.test(path83);
|
|
22914
22837
|
}
|
|
22915
|
-
const slices =
|
|
22838
|
+
const slices = path83.split(SLASH).filter(Boolean);
|
|
22916
22839
|
slices.pop();
|
|
22917
22840
|
if (slices.length) {
|
|
22918
22841
|
const parent = this._t(
|
|
@@ -22925,18 +22848,18 @@ var require_ignore = __commonJS({
|
|
|
22925
22848
|
return parent;
|
|
22926
22849
|
}
|
|
22927
22850
|
}
|
|
22928
|
-
return this._rules.test(
|
|
22851
|
+
return this._rules.test(path83, false, MODE_CHECK_IGNORE);
|
|
22929
22852
|
}
|
|
22930
|
-
_t(
|
|
22931
|
-
if (
|
|
22932
|
-
return cache2[
|
|
22853
|
+
_t(path83, cache2, checkUnignored, slices) {
|
|
22854
|
+
if (path83 in cache2) {
|
|
22855
|
+
return cache2[path83];
|
|
22933
22856
|
}
|
|
22934
22857
|
if (!slices) {
|
|
22935
|
-
slices =
|
|
22858
|
+
slices = path83.split(SLASH).filter(Boolean);
|
|
22936
22859
|
}
|
|
22937
22860
|
slices.pop();
|
|
22938
22861
|
if (!slices.length) {
|
|
22939
|
-
return cache2[
|
|
22862
|
+
return cache2[path83] = this._rules.test(path83, checkUnignored, MODE_IGNORE);
|
|
22940
22863
|
}
|
|
22941
22864
|
const parent = this._t(
|
|
22942
22865
|
slices.join(SLASH) + SLASH,
|
|
@@ -22944,29 +22867,29 @@ var require_ignore = __commonJS({
|
|
|
22944
22867
|
checkUnignored,
|
|
22945
22868
|
slices
|
|
22946
22869
|
);
|
|
22947
|
-
return cache2[
|
|
22870
|
+
return cache2[path83] = parent.ignored ? parent : this._rules.test(path83, checkUnignored, MODE_IGNORE);
|
|
22948
22871
|
}
|
|
22949
|
-
ignores(
|
|
22950
|
-
return this._test(
|
|
22872
|
+
ignores(path83) {
|
|
22873
|
+
return this._test(path83, this._ignoreCache, false).ignored;
|
|
22951
22874
|
}
|
|
22952
22875
|
createFilter() {
|
|
22953
|
-
return (
|
|
22876
|
+
return (path83) => !this.ignores(path83);
|
|
22954
22877
|
}
|
|
22955
22878
|
filter(paths) {
|
|
22956
22879
|
return makeArray(paths).filter(this.createFilter());
|
|
22957
22880
|
}
|
|
22958
22881
|
// @returns {TestResult}
|
|
22959
|
-
test(
|
|
22960
|
-
return this._test(
|
|
22882
|
+
test(path83) {
|
|
22883
|
+
return this._test(path83, this._testCache, true);
|
|
22961
22884
|
}
|
|
22962
22885
|
};
|
|
22963
22886
|
var factory = (options) => new Ignore(options);
|
|
22964
|
-
var isPathValid = (
|
|
22887
|
+
var isPathValid = (path83) => checkPath(path83 && checkPath.convert(path83), path83, RETURN_FALSE);
|
|
22965
22888
|
var setupWindows = () => {
|
|
22966
22889
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
22967
22890
|
checkPath.convert = makePosix;
|
|
22968
22891
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
22969
|
-
checkPath.isNotRelative = (
|
|
22892
|
+
checkPath.isNotRelative = (path83) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path83) || isNotRelative(path83);
|
|
22970
22893
|
};
|
|
22971
22894
|
if (
|
|
22972
22895
|
// Detect `process` so that it can run in browsers.
|
|
@@ -22982,8 +22905,8 @@ var require_ignore = __commonJS({
|
|
|
22982
22905
|
});
|
|
22983
22906
|
|
|
22984
22907
|
// ../bridge/src/code-nav/gitignore-filter.ts
|
|
22985
|
-
import
|
|
22986
|
-
import
|
|
22908
|
+
import fs12 from "node:fs";
|
|
22909
|
+
import path11 from "node:path";
|
|
22987
22910
|
function normalizeRelPath(relPath) {
|
|
22988
22911
|
return relPath.replace(/\\/g, "/");
|
|
22989
22912
|
}
|
|
@@ -22993,12 +22916,12 @@ function isUnderDir(relPath, dirRel) {
|
|
|
22993
22916
|
async function createGitignoreFilterForRelativePath(root, relPath) {
|
|
22994
22917
|
const filter = new GitignoreFilter();
|
|
22995
22918
|
await filter.enterDirectory(root, "");
|
|
22996
|
-
const dirRel = normalizeRelPath(
|
|
22919
|
+
const dirRel = normalizeRelPath(path11.dirname(relPath));
|
|
22997
22920
|
if (dirRel === "." || dirRel === "") return filter;
|
|
22998
22921
|
let abs = root;
|
|
22999
22922
|
let rel = "";
|
|
23000
22923
|
for (const segment of dirRel.split("/")) {
|
|
23001
|
-
abs =
|
|
22924
|
+
abs = path11.join(abs, segment);
|
|
23002
22925
|
rel = rel ? `${rel}/${segment}` : segment;
|
|
23003
22926
|
await filter.enterDirectory(abs, rel);
|
|
23004
22927
|
}
|
|
@@ -23020,7 +22943,7 @@ var init_gitignore_filter = __esm({
|
|
|
23020
22943
|
/** Load `.gitignore` in `absDir` and push a layer when the file exists. */
|
|
23021
22944
|
async enterDirectory(absDir, dirRel) {
|
|
23022
22945
|
try {
|
|
23023
|
-
const content = await
|
|
22946
|
+
const content = await fs12.promises.readFile(path11.join(absDir, ".gitignore"), "utf8");
|
|
23024
22947
|
this.layers.push({ dirRel, ig: (0, import_ignore.default)().add(content) });
|
|
23025
22948
|
} catch {
|
|
23026
22949
|
}
|
|
@@ -23047,7 +22970,7 @@ var init_gitignore_filter = __esm({
|
|
|
23047
22970
|
});
|
|
23048
22971
|
|
|
23049
22972
|
// ../bridge/src/code-nav/language-registry.ts
|
|
23050
|
-
import
|
|
22973
|
+
import path12 from "node:path";
|
|
23051
22974
|
function languageAssetPaths(key, wasmFile) {
|
|
23052
22975
|
return {
|
|
23053
22976
|
wasmFile,
|
|
@@ -23055,7 +22978,7 @@ function languageAssetPaths(key, wasmFile) {
|
|
|
23055
22978
|
};
|
|
23056
22979
|
}
|
|
23057
22980
|
function getLanguageKeyForFilePath(filePath) {
|
|
23058
|
-
const ext =
|
|
22981
|
+
const ext = path12.extname(filePath).replace(/^\./, "").toLowerCase();
|
|
23059
22982
|
if (!ext) return null;
|
|
23060
22983
|
return EXT_TO_LANGUAGE_KEY[ext] ?? null;
|
|
23061
22984
|
}
|
|
@@ -23105,13 +23028,13 @@ var init_language_registry = __esm({
|
|
|
23105
23028
|
});
|
|
23106
23029
|
|
|
23107
23030
|
// ../bridge/src/code-nav/walk-code-nav-files.ts
|
|
23108
|
-
import
|
|
23109
|
-
import
|
|
23031
|
+
import fs13 from "node:fs";
|
|
23032
|
+
import path13 from "node:path";
|
|
23110
23033
|
async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile, state) {
|
|
23111
23034
|
await filter.enterDirectory(dir, relDir);
|
|
23112
23035
|
let names;
|
|
23113
23036
|
try {
|
|
23114
|
-
names = await
|
|
23037
|
+
names = await fs13.promises.readdir(dir);
|
|
23115
23038
|
} catch {
|
|
23116
23039
|
filter.leaveDirectory(relDir);
|
|
23117
23040
|
return;
|
|
@@ -23128,10 +23051,10 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
23128
23051
|
}
|
|
23129
23052
|
state.n++;
|
|
23130
23053
|
const relPath = relDir ? `${relDir}/${name}` : name;
|
|
23131
|
-
const full =
|
|
23054
|
+
const full = path13.join(dir, name);
|
|
23132
23055
|
let stat2;
|
|
23133
23056
|
try {
|
|
23134
|
-
stat2 = await
|
|
23057
|
+
stat2 = await fs13.promises.stat(full);
|
|
23135
23058
|
} catch {
|
|
23136
23059
|
continue;
|
|
23137
23060
|
}
|
|
@@ -23148,7 +23071,7 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
23148
23071
|
filter.leaveDirectory(relDir);
|
|
23149
23072
|
}
|
|
23150
23073
|
async function walkCodeNavFilesAsync(rootDir, onFile, state = createWalkYieldState()) {
|
|
23151
|
-
const resolved =
|
|
23074
|
+
const resolved = path13.resolve(rootDir);
|
|
23152
23075
|
const filter = new GitignoreFilter();
|
|
23153
23076
|
await walkCodeNavFilesInDirectory(resolved, resolved, "", filter, onFile, state);
|
|
23154
23077
|
}
|
|
@@ -23911,7 +23834,7 @@ var init_persist_single_file = __esm({
|
|
|
23911
23834
|
});
|
|
23912
23835
|
|
|
23913
23836
|
// ../bridge/src/code-nav/resolve-module-import-path.ts
|
|
23914
|
-
import
|
|
23837
|
+
import path14 from "node:path";
|
|
23915
23838
|
function normalizeWorkspacePath(filePath) {
|
|
23916
23839
|
return filePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
23917
23840
|
}
|
|
@@ -23951,28 +23874,28 @@ function tsJsImportCandidates(joined) {
|
|
|
23951
23874
|
function resolveModuleImportPath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
23952
23875
|
const spec = moduleSpecifier.trim();
|
|
23953
23876
|
if (!spec || !isRelativeModuleSpecifier(spec)) return null;
|
|
23954
|
-
const importerDir =
|
|
23955
|
-
const joined = normalizeWorkspacePath(
|
|
23877
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23878
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
23956
23879
|
return firstExistingPath(tsJsImportCandidates(joined), workspaceFiles);
|
|
23957
23880
|
}
|
|
23958
23881
|
function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
23959
23882
|
const moduleName = moduleSpecifier.trim().replace(/\s+/g, "");
|
|
23960
23883
|
if (!moduleName) return null;
|
|
23961
|
-
const importerDir =
|
|
23884
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23962
23885
|
if (moduleName.startsWith(".")) {
|
|
23963
23886
|
const dotMatch = /^(\.+)(.*)$/.exec(moduleName);
|
|
23964
23887
|
const dotCount = dotMatch?.[1]?.length ?? 1;
|
|
23965
23888
|
const rest = (dotMatch?.[2] ?? "").replace(/^\./, "");
|
|
23966
23889
|
let baseDir = importerDir;
|
|
23967
23890
|
for (let i = 1; i < dotCount; i++) {
|
|
23968
|
-
baseDir =
|
|
23891
|
+
baseDir = path14.posix.dirname(baseDir);
|
|
23969
23892
|
}
|
|
23970
23893
|
const dottedPath2 = rest ? rest.split(".").join("/") : "";
|
|
23971
|
-
const relativeBase = dottedPath2 ?
|
|
23894
|
+
const relativeBase = dottedPath2 ? path14.posix.join(baseDir, dottedPath2) : baseDir;
|
|
23972
23895
|
return firstExistingPath(
|
|
23973
23896
|
[
|
|
23974
23897
|
...withSuffixes(relativeBase, PYTHON_EXTENSIONS),
|
|
23975
|
-
...withSuffixes(
|
|
23898
|
+
...withSuffixes(path14.posix.join(relativeBase, "__init__"), [".py"])
|
|
23976
23899
|
],
|
|
23977
23900
|
workspaceFiles
|
|
23978
23901
|
);
|
|
@@ -23981,7 +23904,7 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
23981
23904
|
return firstExistingPath(
|
|
23982
23905
|
[
|
|
23983
23906
|
...withSuffixes(dottedPath, PYTHON_EXTENSIONS),
|
|
23984
|
-
...withSuffixes(
|
|
23907
|
+
...withSuffixes(path14.posix.join(importerDir, dottedPath), PYTHON_EXTENSIONS)
|
|
23985
23908
|
],
|
|
23986
23909
|
workspaceFiles
|
|
23987
23910
|
);
|
|
@@ -23989,9 +23912,9 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
23989
23912
|
function resolveIncludePath(importerFilePath, includePath, workspaceFiles) {
|
|
23990
23913
|
const spec = includePath.trim().replace(/^["']|["']$/g, "");
|
|
23991
23914
|
if (!spec) return null;
|
|
23992
|
-
const importerDir =
|
|
23915
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23993
23916
|
const joined = normalizeWorkspacePath(
|
|
23994
|
-
|
|
23917
|
+
path14.posix.normalize(path14.posix.join(importerDir, spec.replace(/\\/g, "/")))
|
|
23995
23918
|
);
|
|
23996
23919
|
if (workspaceFiles.has(joined)) return joined;
|
|
23997
23920
|
return firstExistingPath(withSuffixes(joined, C_CPP_EXTENSIONS), workspaceFiles);
|
|
@@ -24010,8 +23933,8 @@ function resolveGoImportPath(importerFilePath, moduleSpecifier, workspaceFiles)
|
|
|
24010
23933
|
const spec = moduleSpecifier.trim();
|
|
24011
23934
|
if (!spec) return null;
|
|
24012
23935
|
if (isRelativeModuleSpecifier(spec)) {
|
|
24013
|
-
const importerDir =
|
|
24014
|
-
const joined = normalizeWorkspacePath(
|
|
23936
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23937
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
24015
23938
|
if (workspaceFiles.has(joined)) return joined;
|
|
24016
23939
|
return firstExistingPath(withSuffixes(joined, [".go"]), workspaceFiles);
|
|
24017
23940
|
}
|
|
@@ -25439,12 +25362,12 @@ var init_workspace_files = __esm({
|
|
|
25439
25362
|
});
|
|
25440
25363
|
|
|
25441
25364
|
// ../bridge/src/code-nav/symbol-index/build/extract-file-symbol-data.ts
|
|
25442
|
-
import
|
|
25443
|
-
import
|
|
25365
|
+
import fs14 from "node:fs";
|
|
25366
|
+
import path15 from "node:path";
|
|
25444
25367
|
import { isMainThread as isMainThread3 } from "node:worker_threads";
|
|
25445
25368
|
async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride) {
|
|
25446
25369
|
await yieldForBridgeInteractivePriority();
|
|
25447
|
-
const absPath =
|
|
25370
|
+
const absPath = path15.join(resolved, relPath);
|
|
25448
25371
|
let tags = [];
|
|
25449
25372
|
let source = null;
|
|
25450
25373
|
if (isCodeNavSupportedPath(relPath) && !await isPathGitIgnored(resolved, relPath)) {
|
|
@@ -25452,16 +25375,16 @@ async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride)
|
|
|
25452
25375
|
assertBackgroundIndexingAllowed();
|
|
25453
25376
|
let fileSource = null;
|
|
25454
25377
|
if (isMainThread3) {
|
|
25455
|
-
const stat2 = await
|
|
25378
|
+
const stat2 = await fs14.promises.stat(absPath);
|
|
25456
25379
|
if (stat2.isFile() && stat2.size <= MAX_INDEX_FILE_BYTES) {
|
|
25457
25380
|
assertBackgroundIndexingAllowed();
|
|
25458
|
-
fileSource = await
|
|
25381
|
+
fileSource = await fs14.promises.readFile(absPath, "utf8");
|
|
25459
25382
|
}
|
|
25460
25383
|
} else {
|
|
25461
|
-
const stat2 =
|
|
25384
|
+
const stat2 = fs14.statSync(absPath);
|
|
25462
25385
|
if (stat2.isFile() && stat2.size <= MAX_INDEX_FILE_BYTES) {
|
|
25463
25386
|
assertBackgroundIndexingAllowed();
|
|
25464
|
-
fileSource =
|
|
25387
|
+
fileSource = fs14.readFileSync(absPath, "utf8");
|
|
25465
25388
|
}
|
|
25466
25389
|
}
|
|
25467
25390
|
source = fileSource;
|
|
@@ -25663,12 +25586,12 @@ var init_ensure_symbol_index_file_host = __esm({
|
|
|
25663
25586
|
});
|
|
25664
25587
|
|
|
25665
25588
|
// ../bridge/src/code-nav/symbol-index/lifecycle/normalize-symbol-index-path.ts
|
|
25666
|
-
import
|
|
25589
|
+
import path16 from "node:path";
|
|
25667
25590
|
function normalizeSymbolIndexRelPath2(parentPath, changedPath) {
|
|
25668
|
-
const resolvedParent =
|
|
25669
|
-
const abs =
|
|
25670
|
-
const rel =
|
|
25671
|
-
if (rel.startsWith("..") ||
|
|
25591
|
+
const resolvedParent = path16.resolve(parentPath);
|
|
25592
|
+
const abs = path16.isAbsolute(changedPath) ? path16.resolve(changedPath) : path16.resolve(resolvedParent, changedPath);
|
|
25593
|
+
const rel = path16.relative(resolvedParent, abs).replace(/\\/g, "/");
|
|
25594
|
+
if (rel.startsWith("..") || path16.isAbsolute(rel)) return null;
|
|
25672
25595
|
return rel;
|
|
25673
25596
|
}
|
|
25674
25597
|
var init_normalize_symbol_index_path = __esm({
|
|
@@ -27049,7 +26972,7 @@ var require_has_flag = __commonJS({
|
|
|
27049
26972
|
var require_supports_color = __commonJS({
|
|
27050
26973
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
27051
26974
|
"use strict";
|
|
27052
|
-
var
|
|
26975
|
+
var os10 = __require("os");
|
|
27053
26976
|
var tty = __require("tty");
|
|
27054
26977
|
var hasFlag = require_has_flag();
|
|
27055
26978
|
var { env } = process;
|
|
@@ -27097,7 +27020,7 @@ var require_supports_color = __commonJS({
|
|
|
27097
27020
|
return min;
|
|
27098
27021
|
}
|
|
27099
27022
|
if (process.platform === "win32") {
|
|
27100
|
-
const osRelease =
|
|
27023
|
+
const osRelease = os10.release().split(".");
|
|
27101
27024
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
27102
27025
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
27103
27026
|
}
|
|
@@ -27343,10 +27266,10 @@ var require_src2 = __commonJS({
|
|
|
27343
27266
|
var fs_1 = __require("fs");
|
|
27344
27267
|
var debug_1 = __importDefault(require_src());
|
|
27345
27268
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
27346
|
-
function check2(
|
|
27347
|
-
log2(`checking %s`,
|
|
27269
|
+
function check2(path83, isFile, isDirectory) {
|
|
27270
|
+
log2(`checking %s`, path83);
|
|
27348
27271
|
try {
|
|
27349
|
-
const stat2 = fs_1.statSync(
|
|
27272
|
+
const stat2 = fs_1.statSync(path83);
|
|
27350
27273
|
if (stat2.isFile() && isFile) {
|
|
27351
27274
|
log2(`[OK] path represents a file`);
|
|
27352
27275
|
return true;
|
|
@@ -27366,8 +27289,8 @@ var require_src2 = __commonJS({
|
|
|
27366
27289
|
throw e;
|
|
27367
27290
|
}
|
|
27368
27291
|
}
|
|
27369
|
-
function exists2(
|
|
27370
|
-
return check2(
|
|
27292
|
+
function exists2(path83, type = exports.READABLE) {
|
|
27293
|
+
return check2(path83, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
27371
27294
|
}
|
|
27372
27295
|
exports.exists = exists2;
|
|
27373
27296
|
exports.FILE = 1;
|
|
@@ -28451,8 +28374,8 @@ function getErrorMap() {
|
|
|
28451
28374
|
|
|
28452
28375
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
28453
28376
|
var makeIssue = (params) => {
|
|
28454
|
-
const { data, path:
|
|
28455
|
-
const fullPath = [...
|
|
28377
|
+
const { data, path: path83, errorMaps, issueData } = params;
|
|
28378
|
+
const fullPath = [...path83, ...issueData.path || []];
|
|
28456
28379
|
const fullIssue = {
|
|
28457
28380
|
...issueData,
|
|
28458
28381
|
path: fullPath
|
|
@@ -28568,11 +28491,11 @@ var errorUtil;
|
|
|
28568
28491
|
|
|
28569
28492
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
28570
28493
|
var ParseInputLazyPath = class {
|
|
28571
|
-
constructor(parent, value,
|
|
28494
|
+
constructor(parent, value, path83, key) {
|
|
28572
28495
|
this._cachedPath = [];
|
|
28573
28496
|
this.parent = parent;
|
|
28574
28497
|
this.data = value;
|
|
28575
|
-
this._path =
|
|
28498
|
+
this._path = path83;
|
|
28576
28499
|
this._key = key;
|
|
28577
28500
|
}
|
|
28578
28501
|
get path() {
|
|
@@ -32482,83 +32405,8 @@ function isUserEndedSessionTurnErrorText(errorText) {
|
|
|
32482
32405
|
}
|
|
32483
32406
|
|
|
32484
32407
|
// ../types/src/session-kind.ts
|
|
32485
|
-
var SESSION_KINDS = ["regular", "
|
|
32408
|
+
var SESSION_KINDS = ["regular", "planned"];
|
|
32486
32409
|
var SESSION_KIND_SET = new Set(SESSION_KINDS);
|
|
32487
|
-
function parseSessionKind(raw) {
|
|
32488
|
-
if (raw === "todo") return "planned";
|
|
32489
|
-
if (typeof raw === "string" && SESSION_KIND_SET.has(raw)) return raw;
|
|
32490
|
-
return "regular";
|
|
32491
|
-
}
|
|
32492
|
-
|
|
32493
|
-
// ../types/src/planning-todo.ts
|
|
32494
|
-
function planningTodoTitle(item) {
|
|
32495
|
-
return item.content.title;
|
|
32496
|
-
}
|
|
32497
|
-
|
|
32498
|
-
// ../types/src/parse-planning-todo-agent-json.ts
|
|
32499
|
-
function parsePlanningTodoAgentJson(raw) {
|
|
32500
|
-
if (raw == null || raw.trim() === "") return [];
|
|
32501
|
-
let text = raw.trim();
|
|
32502
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
32503
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
32504
|
-
let parsed;
|
|
32505
|
-
try {
|
|
32506
|
-
parsed = JSON.parse(text);
|
|
32507
|
-
} catch {
|
|
32508
|
-
const start = text.indexOf("[");
|
|
32509
|
-
const end = text.lastIndexOf("]");
|
|
32510
|
-
if (start < 0 || end <= start) return [];
|
|
32511
|
-
try {
|
|
32512
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
32513
|
-
} catch {
|
|
32514
|
-
return [];
|
|
32515
|
-
}
|
|
32516
|
-
}
|
|
32517
|
-
if (!Array.isArray(parsed)) return [];
|
|
32518
|
-
const rows = [];
|
|
32519
|
-
for (const item of parsed) {
|
|
32520
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
32521
|
-
const o = item;
|
|
32522
|
-
const title = typeof o.title === "string" ? o.title.trim() : "";
|
|
32523
|
-
const prompt = typeof o.prompt === "string" ? o.prompt.trim() : typeof o.promptText === "string" ? o.promptText.trim() : "";
|
|
32524
|
-
if (!title || !prompt) continue;
|
|
32525
|
-
rows.push({ title, prompt });
|
|
32526
|
-
}
|
|
32527
|
-
return rows;
|
|
32528
|
-
}
|
|
32529
|
-
|
|
32530
|
-
// ../types/src/build-planning-session-agent-prompt.ts
|
|
32531
|
-
var PLANNING_INSTRUCTIONS = [
|
|
32532
|
-
"PLANNING MODE: You must NOT make any changes to the codebase, filesystem, or environment.",
|
|
32533
|
-
"Do not run tools that modify files or execute commands that change state.",
|
|
32534
|
-
"Your only task is to analyze and produce a plan.",
|
|
32535
|
-
"",
|
|
32536
|
-
"Respond with ONLY a single JSON array \u2014 no markdown fences, no other text before or after.",
|
|
32537
|
-
"Each array element must be an object with exactly:",
|
|
32538
|
-
'- "title": a one-line summary of the task',
|
|
32539
|
-
'- "prompt": the full prompt to use when creating a new draft session from this todo',
|
|
32540
|
-
"",
|
|
32541
|
-
"Example:",
|
|
32542
|
-
'[{"title":"Add user login","prompt":"Implement a login form with email and password..."}]'
|
|
32543
|
-
].join("\n");
|
|
32544
|
-
function buildPlanningSessionAgentPrompt(userPrompt) {
|
|
32545
|
-
return [PLANNING_INSTRUCTIONS, "", "User request:", userPrompt.trim()].join("\n");
|
|
32546
|
-
}
|
|
32547
|
-
function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
32548
|
-
const todoLines = existingTodos.length > 0 ? existingTodos.map((t) => {
|
|
32549
|
-
const status = t.plannedSessionId ? "DONE (draft session already created)" : "OPEN";
|
|
32550
|
-
return `- [${status}] ${planningTodoTitle(t)}`;
|
|
32551
|
-
}).join("\n") : "(none yet)";
|
|
32552
|
-
return [
|
|
32553
|
-
PLANNING_INSTRUCTIONS,
|
|
32554
|
-
"",
|
|
32555
|
-
"Existing todo items from this planning session (consider these when responding; do not duplicate completed items):",
|
|
32556
|
-
todoLines,
|
|
32557
|
-
"",
|
|
32558
|
-
"User follow-up:",
|
|
32559
|
-
userPrompt.trim()
|
|
32560
|
-
].join("\n");
|
|
32561
|
-
}
|
|
32562
32410
|
|
|
32563
32411
|
// ../types/src/diff/line-diff.ts
|
|
32564
32412
|
function normalizeDiffLineText(line) {
|
|
@@ -32799,19 +32647,6 @@ function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
|
32799
32647
|
};
|
|
32800
32648
|
}
|
|
32801
32649
|
|
|
32802
|
-
// ../types/src/acp-agent-text-stream-bucket.ts
|
|
32803
|
-
function resolveAgentTextStreamBucket(params) {
|
|
32804
|
-
const k = params.transcriptRowKind;
|
|
32805
|
-
const su = params.sessionUpdate;
|
|
32806
|
-
if (k === "agent_thought_chunk" || su === "agent_thought_chunk" || k === "thinking" || su === "thinking") {
|
|
32807
|
-
return "thought";
|
|
32808
|
-
}
|
|
32809
|
-
if (k === "agent_message_chunk" || su === "agent_message_chunk" || k === "update" || su === "update") {
|
|
32810
|
-
return "message";
|
|
32811
|
-
}
|
|
32812
|
-
return null;
|
|
32813
|
-
}
|
|
32814
|
-
|
|
32815
32650
|
// ../types/src/agent-config.ts
|
|
32816
32651
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
32817
32652
|
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
@@ -33922,7 +33757,7 @@ function bridgeAgentPathEnv(base = process.env) {
|
|
|
33922
33757
|
}
|
|
33923
33758
|
|
|
33924
33759
|
// ../bridge/src/files/watch-file-index.ts
|
|
33925
|
-
import
|
|
33760
|
+
import path21 from "node:path";
|
|
33926
33761
|
|
|
33927
33762
|
// ../bridge/src/files/index/index.ts
|
|
33928
33763
|
init_paths();
|
|
@@ -33931,7 +33766,7 @@ init_paths();
|
|
|
33931
33766
|
init_in_flight();
|
|
33932
33767
|
init_cli_process_interrupt();
|
|
33933
33768
|
init_database();
|
|
33934
|
-
import
|
|
33769
|
+
import path17 from "node:path";
|
|
33935
33770
|
|
|
33936
33771
|
// ../bridge/src/files/index/file-index-sqlite-lock.ts
|
|
33937
33772
|
var fileIndexChain = Promise.resolve();
|
|
@@ -34038,7 +33873,7 @@ function assertNotShutdown2() {
|
|
|
34038
33873
|
if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
|
|
34039
33874
|
}
|
|
34040
33875
|
async function buildFileIndexAsync(cwd) {
|
|
34041
|
-
const resolved =
|
|
33876
|
+
const resolved = path17.resolve(cwd);
|
|
34042
33877
|
await yieldForBridgeInteractivePriority();
|
|
34043
33878
|
assertNotShutdown2();
|
|
34044
33879
|
const paths = await collectWorkspacePathsAsync(resolved);
|
|
@@ -34051,7 +33886,7 @@ async function buildFileIndexAsync(cwd) {
|
|
|
34051
33886
|
}
|
|
34052
33887
|
|
|
34053
33888
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
34054
|
-
import
|
|
33889
|
+
import path18 from "node:path";
|
|
34055
33890
|
|
|
34056
33891
|
// ../bridge/src/files/index/search-file-index.ts
|
|
34057
33892
|
init_yield_to_event_loop();
|
|
@@ -34106,7 +33941,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
|
|
|
34106
33941
|
|
|
34107
33942
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
34108
33943
|
async function ensureFileIndexAsync(cwd) {
|
|
34109
|
-
const resolved =
|
|
33944
|
+
const resolved = path18.resolve(cwd);
|
|
34110
33945
|
if (await bridgeFileIndexIsPopulated(resolved)) {
|
|
34111
33946
|
return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
|
|
34112
33947
|
}
|
|
@@ -34858,16 +34693,16 @@ init_database();
|
|
|
34858
34693
|
init_cli_process_interrupt();
|
|
34859
34694
|
|
|
34860
34695
|
// ../bridge/src/files/index/file-index-incremental-symbol-updates.ts
|
|
34861
|
-
import
|
|
34862
|
-
import
|
|
34696
|
+
import fs15 from "node:fs";
|
|
34697
|
+
import path19 from "node:path";
|
|
34863
34698
|
init_cli_process_interrupt();
|
|
34864
34699
|
init_yield_to_event_loop();
|
|
34865
34700
|
init_database();
|
|
34866
34701
|
async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
|
|
34867
34702
|
for (const rel of relPaths) {
|
|
34868
|
-
const absPath =
|
|
34703
|
+
const absPath = path19.join(resolved, rel);
|
|
34869
34704
|
try {
|
|
34870
|
-
const stat2 = await
|
|
34705
|
+
const stat2 = await fs15.promises.stat(absPath);
|
|
34871
34706
|
if (stat2.isFile()) {
|
|
34872
34707
|
await updateSymbolIndexForFile(resolved, absPath);
|
|
34873
34708
|
} else {
|
|
@@ -34981,11 +34816,11 @@ function createFileIndexFsWatcher(resolved, schedule) {
|
|
|
34981
34816
|
}
|
|
34982
34817
|
|
|
34983
34818
|
// ../bridge/src/files/index/file-index-initial-builds.ts
|
|
34984
|
-
import
|
|
34819
|
+
import path20 from "node:path";
|
|
34985
34820
|
init_database();
|
|
34986
34821
|
init_code_nav_cache_availability();
|
|
34987
34822
|
async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
34988
|
-
const resolved =
|
|
34823
|
+
const resolved = path20.resolve(cwd);
|
|
34989
34824
|
try {
|
|
34990
34825
|
if (!await startCodeNavCacheInitialization()) return;
|
|
34991
34826
|
await buildFileIndexAsync(resolved);
|
|
@@ -35004,7 +34839,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
|
35004
34839
|
|
|
35005
34840
|
// ../bridge/src/files/watch-file-index.ts
|
|
35006
34841
|
function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
35007
|
-
const resolved =
|
|
34842
|
+
const resolved = path21.resolve(cwd);
|
|
35008
34843
|
const rebuildState = createFileIndexWatchRebuildState();
|
|
35009
34844
|
let timer = null;
|
|
35010
34845
|
const schedule = (relPath) => {
|
|
@@ -35264,20 +35099,20 @@ async function cancelRun(ctx, runId) {
|
|
|
35264
35099
|
}
|
|
35265
35100
|
|
|
35266
35101
|
// ../bridge/src/agents/acp/ensure-acp-client.ts
|
|
35267
|
-
import * as
|
|
35268
|
-
import * as
|
|
35102
|
+
import * as fs18 from "node:fs";
|
|
35103
|
+
import * as path27 from "node:path";
|
|
35269
35104
|
|
|
35270
35105
|
// ../bridge/src/paths/session-layout-paths.ts
|
|
35271
|
-
import * as
|
|
35106
|
+
import * as path22 from "node:path";
|
|
35272
35107
|
function resolveIsolatedSessionParentPathFromCheckouts(worktreePaths) {
|
|
35273
|
-
const resolved = worktreePaths.map((p) =>
|
|
35108
|
+
const resolved = worktreePaths.map((p) => path22.resolve(p)).filter(Boolean);
|
|
35274
35109
|
if (resolved.length === 0) return null;
|
|
35275
35110
|
resolved.sort();
|
|
35276
35111
|
return resolved[0];
|
|
35277
35112
|
}
|
|
35278
35113
|
function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
|
|
35279
35114
|
if (resolvedSessionParentPath != null && String(resolvedSessionParentPath).trim() !== "") {
|
|
35280
|
-
return
|
|
35115
|
+
return path22.resolve(String(resolvedSessionParentPath).trim());
|
|
35281
35116
|
}
|
|
35282
35117
|
return getBridgeRoot();
|
|
35283
35118
|
}
|
|
@@ -35658,20 +35493,20 @@ var codexProvider = {
|
|
|
35658
35493
|
};
|
|
35659
35494
|
|
|
35660
35495
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
35661
|
-
import * as
|
|
35496
|
+
import * as fs16 from "node:fs";
|
|
35662
35497
|
|
|
35663
35498
|
// ../bridge/src/paths/session-plans-paths.ts
|
|
35664
|
-
import * as
|
|
35665
|
-
import * as
|
|
35499
|
+
import * as os5 from "node:os";
|
|
35500
|
+
import * as path23 from "node:path";
|
|
35666
35501
|
function getSessionPlansRootDir() {
|
|
35667
|
-
return
|
|
35502
|
+
return path23.join(os5.homedir(), ".buildautomaton", "plans");
|
|
35668
35503
|
}
|
|
35669
35504
|
function sanitizeSessionPlansKey(sessionId) {
|
|
35670
35505
|
const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
|
|
35671
35506
|
return t || "session";
|
|
35672
35507
|
}
|
|
35673
35508
|
function getSessionPlansDir(sessionId) {
|
|
35674
|
-
return
|
|
35509
|
+
return path23.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
|
|
35675
35510
|
}
|
|
35676
35511
|
|
|
35677
35512
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
@@ -35680,7 +35515,7 @@ function cleanupSessionPlans(sessionId) {
|
|
|
35680
35515
|
if (!id) return;
|
|
35681
35516
|
const dir = getSessionPlansDir(id);
|
|
35682
35517
|
try {
|
|
35683
|
-
|
|
35518
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
35684
35519
|
} catch {
|
|
35685
35520
|
}
|
|
35686
35521
|
}
|
|
@@ -36048,8 +35883,8 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
|
|
|
36048
35883
|
}
|
|
36049
35884
|
|
|
36050
35885
|
// ../bridge/src/agents/providers/cursor/write-create-plan-file.ts
|
|
36051
|
-
import * as
|
|
36052
|
-
import * as
|
|
35886
|
+
import * as fs17 from "node:fs";
|
|
35887
|
+
import * as path24 from "node:path";
|
|
36053
35888
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
36054
35889
|
function sanitizePlanFileBase(toolCallId) {
|
|
36055
35890
|
const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
|
|
@@ -36057,9 +35892,9 @@ function sanitizePlanFileBase(toolCallId) {
|
|
|
36057
35892
|
}
|
|
36058
35893
|
function writeCreatePlanFile(params) {
|
|
36059
35894
|
const dir = getSessionPlansDir(params.cloudSessionId);
|
|
36060
|
-
|
|
36061
|
-
const filePath =
|
|
36062
|
-
|
|
35895
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
35896
|
+
const filePath = path24.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
|
|
35897
|
+
fs17.writeFileSync(filePath, params.planMarkdown, "utf8");
|
|
36063
35898
|
return pathToFileURL2(filePath).href;
|
|
36064
35899
|
}
|
|
36065
35900
|
|
|
@@ -36673,16 +36508,16 @@ async function execGitFile(args, options) {
|
|
|
36673
36508
|
}
|
|
36674
36509
|
|
|
36675
36510
|
// ../bridge/src/git/get-git-repo-root-sync.ts
|
|
36676
|
-
import * as
|
|
36511
|
+
import * as path25 from "node:path";
|
|
36677
36512
|
var GIT_LOOKUP_TIMEOUT_MS = 2e3;
|
|
36678
36513
|
function getGitRepoRootSync(startDir) {
|
|
36679
36514
|
try {
|
|
36680
36515
|
const out = execGitFileSync(["rev-parse", "--show-toplevel"], {
|
|
36681
|
-
cwd:
|
|
36516
|
+
cwd: path25.resolve(startDir),
|
|
36682
36517
|
maxBuffer: 1024 * 1024,
|
|
36683
36518
|
timeout: GIT_LOOKUP_TIMEOUT_MS
|
|
36684
36519
|
}).trim();
|
|
36685
|
-
return out ?
|
|
36520
|
+
return out ? path25.resolve(out) : null;
|
|
36686
36521
|
} catch {
|
|
36687
36522
|
return null;
|
|
36688
36523
|
}
|
|
@@ -36690,26 +36525,26 @@ function getGitRepoRootSync(startDir) {
|
|
|
36690
36525
|
|
|
36691
36526
|
// ../bridge/src/agents/acp/workspace-files.ts
|
|
36692
36527
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
36693
|
-
import * as
|
|
36528
|
+
import * as path26 from "node:path";
|
|
36694
36529
|
var GIT_FILE_READ_TIMEOUT_MS = 2e3;
|
|
36695
36530
|
function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
|
|
36696
36531
|
const trimmed2 = rawPath.trim();
|
|
36697
36532
|
if (!trimmed2) return null;
|
|
36698
|
-
const normalizedSessionParent =
|
|
36533
|
+
const normalizedSessionParent = path26.resolve(sessionParentPath);
|
|
36699
36534
|
let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
|
|
36700
36535
|
if (!resolvedPath) {
|
|
36701
|
-
const candidate =
|
|
36536
|
+
const candidate = path26.isAbsolute(trimmed2) ? path26.normalize(trimmed2) : path26.normalize(path26.resolve(normalizedSessionParent, trimmed2));
|
|
36702
36537
|
const gitRoot2 = getGitRepoRootSync(sessionParentPath);
|
|
36703
36538
|
if (!gitRoot2) return null;
|
|
36704
|
-
const rel =
|
|
36705
|
-
if (rel.startsWith("..") ||
|
|
36539
|
+
const rel = path26.relative(gitRoot2, candidate);
|
|
36540
|
+
if (rel.startsWith("..") || path26.isAbsolute(rel)) return null;
|
|
36706
36541
|
resolvedPath = candidate;
|
|
36707
36542
|
}
|
|
36708
36543
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36709
36544
|
if (gitRoot) {
|
|
36710
|
-
const relFromRoot =
|
|
36711
|
-
if (!relFromRoot.startsWith("..") && !
|
|
36712
|
-
return { resolvedPath, display: relFromRoot.split(
|
|
36545
|
+
const relFromRoot = path26.relative(gitRoot, resolvedPath);
|
|
36546
|
+
if (!relFromRoot.startsWith("..") && !path26.isAbsolute(relFromRoot)) {
|
|
36547
|
+
return { resolvedPath, display: relFromRoot.split(path26.sep).join("/") };
|
|
36713
36548
|
}
|
|
36714
36549
|
}
|
|
36715
36550
|
return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
|
|
@@ -36718,9 +36553,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
|
|
|
36718
36553
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
36719
36554
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36720
36555
|
if (gitRoot) {
|
|
36721
|
-
const resolvedPath2 =
|
|
36722
|
-
const rel =
|
|
36723
|
-
if (!rel.startsWith("..") && !
|
|
36556
|
+
const resolvedPath2 = path26.resolve(gitRoot, displayPath);
|
|
36557
|
+
const rel = path26.relative(gitRoot, resolvedPath2);
|
|
36558
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) {
|
|
36724
36559
|
try {
|
|
36725
36560
|
return readFileSync4(resolvedPath2, "utf8");
|
|
36726
36561
|
} catch {
|
|
@@ -36739,9 +36574,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
|
|
|
36739
36574
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
36740
36575
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36741
36576
|
if (gitRoot) {
|
|
36742
|
-
const resolvedPath =
|
|
36743
|
-
const rel =
|
|
36744
|
-
if (!rel.startsWith("..") && !
|
|
36577
|
+
const resolvedPath = path26.resolve(gitRoot, displayPath);
|
|
36578
|
+
const rel = path26.relative(gitRoot, resolvedPath);
|
|
36579
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) return resolvedPath;
|
|
36745
36580
|
}
|
|
36746
36581
|
return resolveSafePathUnderCwd(sessionParentPath, displayPath);
|
|
36747
36582
|
}
|
|
@@ -37041,11 +36876,13 @@ var PathSnapshotTracker = class {
|
|
|
37041
36876
|
};
|
|
37042
36877
|
|
|
37043
36878
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/send-session-info-title-update.ts
|
|
36879
|
+
var PLACEHOLDER_TITLES = /* @__PURE__ */ new Set(["session", "new session", "untitled"]);
|
|
37044
36880
|
function extractSessionInfoTitle(params) {
|
|
37045
36881
|
if (!params || typeof params !== "object") return null;
|
|
37046
36882
|
const p = params;
|
|
37047
36883
|
const title = typeof p.title === "string" ? p.title.trim() : "";
|
|
37048
|
-
|
|
36884
|
+
if (!title || PLACEHOLDER_TITLES.has(title.toLowerCase())) return null;
|
|
36885
|
+
return title;
|
|
37049
36886
|
}
|
|
37050
36887
|
function sendSessionInfoTitleUpdate(params) {
|
|
37051
36888
|
const title = extractSessionInfoTitle(params.payload);
|
|
@@ -37366,74 +37203,12 @@ function resolveBridgeToolPaths(params, isToolUpdate, sessionParentPath) {
|
|
|
37366
37203
|
return isToolUpdate ? extractToolTargetDisplayPaths(params, sessionParentPath) : [];
|
|
37367
37204
|
}
|
|
37368
37205
|
|
|
37369
|
-
// ../bridge/src/agents/planning/extract-session-update-message-text.ts
|
|
37370
|
-
function extractSessionUpdateMessageText(params) {
|
|
37371
|
-
if (params == null || typeof params !== "object" || Array.isArray(params)) return null;
|
|
37372
|
-
const o = params;
|
|
37373
|
-
if (typeof o.text === "string" && o.text.length > 0) return o.text;
|
|
37374
|
-
const content = o.content;
|
|
37375
|
-
if (typeof content === "string" && content.length > 0) return content;
|
|
37376
|
-
if (content != null && typeof content === "object" && !Array.isArray(content)) {
|
|
37377
|
-
const c = content;
|
|
37378
|
-
if (typeof c.text === "string" && c.text.length > 0) return c.text;
|
|
37379
|
-
}
|
|
37380
|
-
const update = o.update;
|
|
37381
|
-
if (typeof update === "string" && update.length > 0) return update;
|
|
37382
|
-
if (update != null && typeof update === "object" && !Array.isArray(update)) {
|
|
37383
|
-
const u = update;
|
|
37384
|
-
const innerContent = u.content;
|
|
37385
|
-
if (typeof innerContent === "string" && innerContent.length > 0) return innerContent;
|
|
37386
|
-
if (innerContent != null && typeof innerContent === "object" && !Array.isArray(innerContent)) {
|
|
37387
|
-
const ic = innerContent;
|
|
37388
|
-
if (typeof ic.text === "string" && ic.text.length > 0) return ic.text;
|
|
37389
|
-
}
|
|
37390
|
-
}
|
|
37391
|
-
return null;
|
|
37392
|
-
}
|
|
37393
|
-
|
|
37394
|
-
// ../bridge/src/agents/planning/planning-session-turn-buffer.ts
|
|
37395
|
-
var MAX_PLANNING_BUFFER_CHARS = 512 * 1024;
|
|
37396
|
-
var buffersByRunId = /* @__PURE__ */ new Map();
|
|
37397
|
-
function registerPlanningSessionTurn(runId) {
|
|
37398
|
-
buffersByRunId.set(runId, { messageBuffer: "" });
|
|
37399
|
-
}
|
|
37400
|
-
function clearPlanningSessionTurn(runId) {
|
|
37401
|
-
buffersByRunId.delete(runId);
|
|
37402
|
-
}
|
|
37403
|
-
function capturePlanningSessionUpdate(params) {
|
|
37404
|
-
const state = buffersByRunId.get(params.runId);
|
|
37405
|
-
if (!state) return false;
|
|
37406
|
-
const sessionUpdate = params.payload != null && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload.sessionUpdate ?? params.payload.session_update : void 0;
|
|
37407
|
-
const bucket = resolveAgentTextStreamBucket({
|
|
37408
|
-
transcriptRowKind: params.updateKind,
|
|
37409
|
-
sessionUpdate: typeof sessionUpdate === "string" ? sessionUpdate : void 0
|
|
37410
|
-
});
|
|
37411
|
-
if (bucket !== "message") return false;
|
|
37412
|
-
const text = extractSessionUpdateMessageText(params.payload);
|
|
37413
|
-
if (text && state.messageBuffer.length < MAX_PLANNING_BUFFER_CHARS) {
|
|
37414
|
-
const room = MAX_PLANNING_BUFFER_CHARS - state.messageBuffer.length;
|
|
37415
|
-
state.messageBuffer += room >= text.length ? text : text.slice(0, room);
|
|
37416
|
-
}
|
|
37417
|
-
return true;
|
|
37418
|
-
}
|
|
37419
|
-
function getPlanningSessionTurnOutput(runId) {
|
|
37420
|
-
return buffersByRunId.get(runId)?.messageBuffer ?? "";
|
|
37421
|
-
}
|
|
37422
|
-
function consumePlanningSessionTurnOutput(runId) {
|
|
37423
|
-
const state = buffersByRunId.get(runId);
|
|
37424
|
-
buffersByRunId.delete(runId);
|
|
37425
|
-
return state?.messageBuffer ?? "";
|
|
37426
|
-
}
|
|
37427
|
-
|
|
37428
37206
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/forward-bridge-session-update.ts
|
|
37429
37207
|
function forwardBridgeSessionUpdate(params) {
|
|
37430
37208
|
const { runId, sessionId, updateKind, payload, send, nextTranscriptStreamSeq, log: log2 } = params;
|
|
37431
37209
|
if (updateKind === "permission") {
|
|
37432
37210
|
return;
|
|
37433
37211
|
}
|
|
37434
|
-
if (capturePlanningSessionUpdate({ runId, updateKind, payload })) {
|
|
37435
|
-
return;
|
|
37436
|
-
}
|
|
37437
37212
|
try {
|
|
37438
37213
|
const transcriptStreamSeq = nextTranscriptStreamSeq?.(runId);
|
|
37439
37214
|
send({
|
|
@@ -37689,7 +37464,7 @@ async function ensureAcpClient(options) {
|
|
|
37689
37464
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
37690
37465
|
await state.acpStartPromise;
|
|
37691
37466
|
}
|
|
37692
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
37467
|
+
if (state.acpHandle && state.lastAcpCwd != null && path27.resolve(state.lastAcpCwd) !== path27.resolve(targetSessionParentPath)) {
|
|
37693
37468
|
try {
|
|
37694
37469
|
state.acpHandle.disconnect();
|
|
37695
37470
|
} catch {
|
|
@@ -37721,7 +37496,7 @@ async function ensureAcpClient(options) {
|
|
|
37721
37496
|
if (!state.acpStartPromise) {
|
|
37722
37497
|
let statOk = false;
|
|
37723
37498
|
try {
|
|
37724
|
-
const st = await
|
|
37499
|
+
const st = await fs18.promises.stat(targetSessionParentPath);
|
|
37725
37500
|
statOk = st.isDirectory();
|
|
37726
37501
|
if (!statOk) {
|
|
37727
37502
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
|
|
@@ -37881,8 +37656,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
|
|
|
37881
37656
|
init_yield_to_event_loop();
|
|
37882
37657
|
|
|
37883
37658
|
// ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
|
|
37884
|
-
function normalizeGitDiffPath(
|
|
37885
|
-
return
|
|
37659
|
+
function normalizeGitDiffPath(path83) {
|
|
37660
|
+
return path83.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
37886
37661
|
}
|
|
37887
37662
|
|
|
37888
37663
|
// ../bridge/src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -37921,7 +37696,7 @@ function parseNameStatusLines(lines) {
|
|
|
37921
37696
|
}
|
|
37922
37697
|
|
|
37923
37698
|
// ../bridge/src/git/snapshot/diff/messages.ts
|
|
37924
|
-
import * as
|
|
37699
|
+
import * as path28 from "node:path";
|
|
37925
37700
|
|
|
37926
37701
|
// ../bridge/src/git/snapshot/diff/files.ts
|
|
37927
37702
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -37952,7 +37727,7 @@ async function buildTrackedChangeMessage(options) {
|
|
|
37952
37727
|
const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
|
|
37953
37728
|
const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
|
|
37954
37729
|
if (!patchContent.trim()) return null;
|
|
37955
|
-
const workspaceFilePath =
|
|
37730
|
+
const workspaceFilePath = path28.join(repoPath, rel);
|
|
37956
37731
|
const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
|
|
37957
37732
|
const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
|
|
37958
37733
|
return {
|
|
@@ -37984,9 +37759,9 @@ function buildUntrackedChangeMessage(options) {
|
|
|
37984
37759
|
}
|
|
37985
37760
|
|
|
37986
37761
|
// ../bridge/src/git/snapshot/diff/paths.ts
|
|
37987
|
-
import * as
|
|
37762
|
+
import * as path29 from "node:path";
|
|
37988
37763
|
function repoDisplayPath(repoPath, multiRepo) {
|
|
37989
|
-
const slug =
|
|
37764
|
+
const slug = path29.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
|
|
37990
37765
|
return (rel) => multiRepo ? `${slug}/${rel}` : rel;
|
|
37991
37766
|
}
|
|
37992
37767
|
function safeRelPath(rel) {
|
|
@@ -37998,12 +37773,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
|
|
|
37998
37773
|
}
|
|
37999
37774
|
|
|
38000
37775
|
// ../bridge/src/git/snapshot/diff/move-pairs.ts
|
|
38001
|
-
import * as
|
|
37776
|
+
import * as path30 from "node:path";
|
|
38002
37777
|
async function readUntrackedTexts(repoPath, untracked) {
|
|
38003
37778
|
const out = /* @__PURE__ */ new Map();
|
|
38004
37779
|
await forEachWithGitYield(untracked, async (rel) => {
|
|
38005
37780
|
if (!safeRelPath(rel)) return;
|
|
38006
|
-
const newText = await readWorkspaceFileAsUtf8(
|
|
37781
|
+
const newText = await readWorkspaceFileAsUtf8(path30.join(repoPath, rel));
|
|
38007
37782
|
if (newText !== void 0) out.set(rel, newText);
|
|
38008
37783
|
});
|
|
38009
37784
|
return out;
|
|
@@ -38120,12 +37895,12 @@ async function collectRepoTurnChanges(options) {
|
|
|
38120
37895
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
38121
37896
|
|
|
38122
37897
|
// ../bridge/src/git/snapshot/types.ts
|
|
38123
|
-
import * as
|
|
37898
|
+
import * as path31 from "node:path";
|
|
38124
37899
|
function snapshotsDirForCwd(agentCwd) {
|
|
38125
|
-
return
|
|
37900
|
+
return path31.join(agentCwd, ".buildautomaton", "snapshots");
|
|
38126
37901
|
}
|
|
38127
37902
|
function snapshotFilePath(agentCwd, runId) {
|
|
38128
|
-
return
|
|
37903
|
+
return path31.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
38129
37904
|
}
|
|
38130
37905
|
|
|
38131
37906
|
// ../bridge/src/git/snapshot/diff/load-pre-turn-snapshot.ts
|
|
@@ -38202,22 +37977,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38202
37977
|
promptId,
|
|
38203
37978
|
agentType,
|
|
38204
37979
|
agentCwd,
|
|
38205
|
-
isPlanningSession,
|
|
38206
37980
|
followUpCatalogPromptId,
|
|
38207
|
-
plugin,
|
|
38208
37981
|
sendResult,
|
|
38209
37982
|
sendSessionUpdate,
|
|
38210
37983
|
log: log2
|
|
38211
37984
|
} = params;
|
|
38212
37985
|
notifyAgentProvidersPromptTurnFinished(sessionId);
|
|
38213
|
-
const planningTodosSubmit = isPlanningSession && plugin?.cloud?.maybeSubmitPlanningTodos ? await plugin.cloud.maybeSubmitPlanningTodos({
|
|
38214
|
-
sessionId,
|
|
38215
|
-
runId,
|
|
38216
|
-
resultSuccess: result.success === true,
|
|
38217
|
-
output: result.output,
|
|
38218
|
-
log: log2
|
|
38219
|
-
}) : { suppressOutput: false };
|
|
38220
|
-
const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
|
|
38221
37986
|
const errStr = typeof result.error === "string" ? result.error : void 0;
|
|
38222
37987
|
const resultStop = typeof result.stopReason === "string" ? result.stopReason.trim() : "";
|
|
38223
37988
|
const cancelledByAgent = resultStop.toLowerCase() === "cancelled" || errStr != null && isUserEndedSessionTurnErrorText(errStr);
|
|
@@ -38227,7 +37992,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38227
37992
|
...sessionId ? { sessionId } : {},
|
|
38228
37993
|
...runId ? { runId } : {},
|
|
38229
37994
|
...result,
|
|
38230
|
-
...planningTodosSubmit.suppressOutput ? { output: void 0 } : planningFallbackOutput.trim() !== "" ? { output: planningFallbackOutput } : {},
|
|
38231
37995
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
38232
37996
|
...augmentPromptResultAuthFields(agentType, errStr),
|
|
38233
37997
|
...!result.success && cancelledByAgent ? { stopReason: "cancelled" } : {}
|
|
@@ -38255,14 +38019,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38255
38019
|
async function prepareAgentPromptText(params) {
|
|
38256
38020
|
const { promptText, sessionId, runId, isNewSession, plugin } = params;
|
|
38257
38021
|
if (plugin?.cloud?.prepareAgentPromptText) {
|
|
38258
|
-
|
|
38022
|
+
return plugin.cloud.prepareAgentPromptText({
|
|
38259
38023
|
promptText,
|
|
38260
38024
|
sessionId,
|
|
38261
38025
|
runId,
|
|
38262
38026
|
isNewSession
|
|
38263
38027
|
});
|
|
38264
|
-
if (prepared.isPlanningSession && runId) registerPlanningSessionTurn(runId);
|
|
38265
|
-
return prepared;
|
|
38266
38028
|
}
|
|
38267
38029
|
return { agentPromptText: promptText, isPlanningSession: false };
|
|
38268
38030
|
}
|
|
@@ -38338,7 +38100,6 @@ async function sendPromptToAgent(options) {
|
|
|
38338
38100
|
attachments,
|
|
38339
38101
|
isNewSession = false
|
|
38340
38102
|
} = options;
|
|
38341
|
-
let isPlanningSession = false;
|
|
38342
38103
|
try {
|
|
38343
38104
|
const prepared = await prepareAgentPromptText({
|
|
38344
38105
|
promptText,
|
|
@@ -38347,7 +38108,6 @@ async function sendPromptToAgent(options) {
|
|
|
38347
38108
|
isNewSession,
|
|
38348
38109
|
plugin
|
|
38349
38110
|
});
|
|
38350
|
-
isPlanningSession = prepared.isPlanningSession;
|
|
38351
38111
|
const imagesResolved = await resolveSendPromptImages({
|
|
38352
38112
|
attachments,
|
|
38353
38113
|
sessionId,
|
|
@@ -38376,7 +38136,6 @@ async function sendPromptToAgent(options) {
|
|
|
38376
38136
|
promptId,
|
|
38377
38137
|
agentType,
|
|
38378
38138
|
agentCwd,
|
|
38379
|
-
isPlanningSession,
|
|
38380
38139
|
followUpCatalogPromptId,
|
|
38381
38140
|
plugin,
|
|
38382
38141
|
sendResult,
|
|
@@ -38396,8 +38155,6 @@ async function sendPromptToAgent(options) {
|
|
|
38396
38155
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
38397
38156
|
...augmentPromptResultAuthFields(agentType, errMsg)
|
|
38398
38157
|
});
|
|
38399
|
-
} finally {
|
|
38400
|
-
if (runId && isPlanningSession) clearPlanningSessionTurn(runId);
|
|
38401
38158
|
}
|
|
38402
38159
|
}
|
|
38403
38160
|
|
|
@@ -38572,6 +38329,7 @@ async function createAcpManager(options) {
|
|
|
38572
38329
|
logPromptReceivedFromBridge: (opts) => logPromptReceivedFromBridge(ctx, opts),
|
|
38573
38330
|
handlePrompt: (opts) => handlePrompt(ctx, opts),
|
|
38574
38331
|
cancelRun: (runId) => cancelRun(ctx, runId),
|
|
38332
|
+
isRegisteredRun: (runId) => ctx.promptRouting.isRegisteredRun(runId),
|
|
38575
38333
|
resolveRequest(requestId, result) {
|
|
38576
38334
|
for (const state of ctx.acpAgents.values()) {
|
|
38577
38335
|
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
@@ -38934,7 +38692,7 @@ async function createBridgeAccessState(options) {
|
|
|
38934
38692
|
}
|
|
38935
38693
|
|
|
38936
38694
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
38937
|
-
import * as
|
|
38695
|
+
import * as path33 from "node:path";
|
|
38938
38696
|
|
|
38939
38697
|
// ../bridge/src/agents/detect-local-agent-types.ts
|
|
38940
38698
|
init_yield_to_event_loop();
|
|
@@ -39056,7 +38814,7 @@ function shouldSkipCapabilityProbeThisProcess(agentType) {
|
|
|
39056
38814
|
}
|
|
39057
38815
|
|
|
39058
38816
|
// ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
39059
|
-
import * as
|
|
38817
|
+
import * as path32 from "node:path";
|
|
39060
38818
|
init_cli_database();
|
|
39061
38819
|
init_yield_to_event_loop();
|
|
39062
38820
|
init_cli_process_interrupt();
|
|
@@ -39082,7 +38840,7 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
39082
38840
|
try {
|
|
39083
38841
|
handle = await resolved.createClient({
|
|
39084
38842
|
command: resolved.command,
|
|
39085
|
-
cwd:
|
|
38843
|
+
cwd: path32.resolve(cwd),
|
|
39086
38844
|
backendAgentType: agentType,
|
|
39087
38845
|
sessionMode: "agent",
|
|
39088
38846
|
persistedAcpSessionId: null,
|
|
@@ -39172,7 +38930,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
39172
38930
|
const { workspaceId, log: log2, getWs } = params;
|
|
39173
38931
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
39174
38932
|
if (!isCurrent()) return;
|
|
39175
|
-
const cwd =
|
|
38933
|
+
const cwd = path33.resolve(getBridgeRoot());
|
|
39176
38934
|
async function sendBatchFromCache() {
|
|
39177
38935
|
if (!isCurrent()) return;
|
|
39178
38936
|
const socket = getWs();
|
|
@@ -39281,7 +39039,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
39281
39039
|
}
|
|
39282
39040
|
|
|
39283
39041
|
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
39284
|
-
import * as
|
|
39042
|
+
import * as path36 from "node:path";
|
|
39285
39043
|
|
|
39286
39044
|
// ../bridge/src/preview-environments/manager/firehose-messages.ts
|
|
39287
39045
|
function buildFirehoseSnapshotMessage(params) {
|
|
@@ -39599,7 +39357,7 @@ function attachChildErrorHandler(d) {
|
|
|
39599
39357
|
}
|
|
39600
39358
|
|
|
39601
39359
|
// ../bridge/src/preview-environments/process/wire/handle-exit.ts
|
|
39602
|
-
import
|
|
39360
|
+
import fs19 from "node:fs";
|
|
39603
39361
|
function logStopLine(d, code, signal) {
|
|
39604
39362
|
const { title } = d;
|
|
39605
39363
|
if (signal) {
|
|
@@ -39638,7 +39396,7 @@ function attachChildExitHandler(d) {
|
|
|
39638
39396
|
const cleanupDir = d.mergedCleanupDir;
|
|
39639
39397
|
const mergedPath = d.mergedLogPath;
|
|
39640
39398
|
if (mergedPath && !stale) {
|
|
39641
|
-
|
|
39399
|
+
fs19.readFile(mergedPath, (err, buf) => {
|
|
39642
39400
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
39643
39401
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
39644
39402
|
if (chunk.length > 0) {
|
|
@@ -39684,7 +39442,7 @@ function wireChildOutputPipes(d) {
|
|
|
39684
39442
|
}
|
|
39685
39443
|
|
|
39686
39444
|
// ../bridge/src/preview-environments/process/wire/poll-merged-log.ts
|
|
39687
|
-
import
|
|
39445
|
+
import fs20 from "node:fs";
|
|
39688
39446
|
function startMergedLogPoll(d) {
|
|
39689
39447
|
if (!d.mergedLogPath || !d.mergedCleanupDir) return;
|
|
39690
39448
|
const { environmentId } = d;
|
|
@@ -39694,7 +39452,7 @@ function startMergedLogPoll(d) {
|
|
|
39694
39452
|
d.setPollInterval(void 0);
|
|
39695
39453
|
return;
|
|
39696
39454
|
}
|
|
39697
|
-
|
|
39455
|
+
fs20.readFile(d.mergedLogPath, (err, buf) => {
|
|
39698
39456
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
39699
39457
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
39700
39458
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -39909,7 +39667,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
|
|
|
39909
39667
|
}
|
|
39910
39668
|
|
|
39911
39669
|
// ../bridge/src/preview-environments/manager/shell-spawn/utils.ts
|
|
39912
|
-
import
|
|
39670
|
+
import fs21 from "node:fs";
|
|
39913
39671
|
function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
|
|
39914
39672
|
return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
|
|
39915
39673
|
}
|
|
@@ -39918,7 +39676,7 @@ function isSpawnEbadf(e) {
|
|
|
39918
39676
|
}
|
|
39919
39677
|
function rmDirQuiet(dir) {
|
|
39920
39678
|
try {
|
|
39921
|
-
|
|
39679
|
+
fs21.rmSync(dir, { recursive: true, force: true });
|
|
39922
39680
|
} catch {
|
|
39923
39681
|
}
|
|
39924
39682
|
}
|
|
@@ -39926,7 +39684,7 @@ var cachedDevNullReadFd;
|
|
|
39926
39684
|
function devNullReadFd() {
|
|
39927
39685
|
if (cachedDevNullReadFd === void 0) {
|
|
39928
39686
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
39929
|
-
cachedDevNullReadFd =
|
|
39687
|
+
cachedDevNullReadFd = fs21.openSync(devPath, "r");
|
|
39930
39688
|
}
|
|
39931
39689
|
return cachedDevNullReadFd;
|
|
39932
39690
|
}
|
|
@@ -40006,15 +39764,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
40006
39764
|
|
|
40007
39765
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
40008
39766
|
import { spawn as spawn7 } from "node:child_process";
|
|
40009
|
-
import
|
|
39767
|
+
import fs22 from "node:fs";
|
|
40010
39768
|
import { tmpdir } from "node:os";
|
|
40011
|
-
import
|
|
39769
|
+
import path34 from "node:path";
|
|
40012
39770
|
function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
40013
|
-
const tmpRoot =
|
|
40014
|
-
const logPath =
|
|
39771
|
+
const tmpRoot = fs22.mkdtempSync(path34.join(tmpdir(), "ba-devsrv-log-"));
|
|
39772
|
+
const logPath = path34.join(tmpRoot, "combined.log");
|
|
40015
39773
|
let logFd;
|
|
40016
39774
|
try {
|
|
40017
|
-
logFd =
|
|
39775
|
+
logFd = fs22.openSync(logPath, "a");
|
|
40018
39776
|
} catch {
|
|
40019
39777
|
rmDirQuiet(tmpRoot);
|
|
40020
39778
|
return null;
|
|
@@ -40038,7 +39796,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40038
39796
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
40039
39797
|
);
|
|
40040
39798
|
}
|
|
40041
|
-
|
|
39799
|
+
fs22.closeSync(logFd);
|
|
40042
39800
|
return {
|
|
40043
39801
|
proc,
|
|
40044
39802
|
pipedStdoutStderr: true,
|
|
@@ -40047,7 +39805,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40047
39805
|
};
|
|
40048
39806
|
} catch (e) {
|
|
40049
39807
|
try {
|
|
40050
|
-
|
|
39808
|
+
fs22.closeSync(logFd);
|
|
40051
39809
|
} catch {
|
|
40052
39810
|
}
|
|
40053
39811
|
rmDirQuiet(tmpRoot);
|
|
@@ -40058,22 +39816,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40058
39816
|
|
|
40059
39817
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
40060
39818
|
import { spawn as spawn8 } from "node:child_process";
|
|
40061
|
-
import
|
|
39819
|
+
import fs23 from "node:fs";
|
|
40062
39820
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
40063
|
-
import
|
|
39821
|
+
import path35 from "node:path";
|
|
40064
39822
|
function shSingleQuote(s) {
|
|
40065
39823
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
40066
39824
|
}
|
|
40067
39825
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
|
|
40068
|
-
const tmpRoot =
|
|
40069
|
-
const logPath =
|
|
40070
|
-
const innerPath =
|
|
40071
|
-
const runnerPath =
|
|
39826
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
39827
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
39828
|
+
const innerPath = path35.join(tmpRoot, "_cmd.sh");
|
|
39829
|
+
const runnerPath = path35.join(tmpRoot, "_run.sh");
|
|
40072
39830
|
try {
|
|
40073
|
-
|
|
39831
|
+
fs23.writeFileSync(innerPath, `#!/bin/sh
|
|
40074
39832
|
${command}
|
|
40075
39833
|
`);
|
|
40076
|
-
|
|
39834
|
+
fs23.writeFileSync(
|
|
40077
39835
|
runnerPath,
|
|
40078
39836
|
`#!/bin/sh
|
|
40079
39837
|
cd ${shSingleQuote(cwd)}
|
|
@@ -40101,13 +39859,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
40101
39859
|
}
|
|
40102
39860
|
}
|
|
40103
39861
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
|
|
40104
|
-
const tmpRoot =
|
|
40105
|
-
const logPath =
|
|
40106
|
-
const runnerPath =
|
|
39862
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
39863
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
39864
|
+
const runnerPath = path35.join(tmpRoot, "_run.bat");
|
|
40107
39865
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
40108
39866
|
const com = process.env.ComSpec || "cmd.exe";
|
|
40109
39867
|
try {
|
|
40110
|
-
|
|
39868
|
+
fs23.writeFileSync(
|
|
40111
39869
|
runnerPath,
|
|
40112
39870
|
`@ECHO OFF\r
|
|
40113
39871
|
CD /D ${q(cwd)}\r
|
|
@@ -40425,8 +40183,8 @@ function createBridgePreviewStack(options) {
|
|
|
40425
40183
|
scheduleInitialIndexBuilds(getBridgeRoot());
|
|
40426
40184
|
};
|
|
40427
40185
|
const identifyReportedPaths = {
|
|
40428
|
-
bridgeRootPath:
|
|
40429
|
-
worktreesRootPath:
|
|
40186
|
+
bridgeRootPath: path36.resolve(getBridgeRoot()),
|
|
40187
|
+
worktreesRootPath: path36.resolve(options.worktreesRootPath),
|
|
40430
40188
|
localShortcutPort: 0,
|
|
40431
40189
|
localShortcutToken: ""
|
|
40432
40190
|
};
|
|
@@ -40628,7 +40386,7 @@ function createBridgeHeartbeatController(params) {
|
|
|
40628
40386
|
}
|
|
40629
40387
|
|
|
40630
40388
|
// ../bridge/src/cli/cli-version.ts
|
|
40631
|
-
var CLI_VERSION = "0.1.
|
|
40389
|
+
var CLI_VERSION = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
40632
40390
|
|
|
40633
40391
|
// ../bridge/src/connection/identify/send-bridge-identify.ts
|
|
40634
40392
|
function sendBridgeIdentify(ws, params) {
|
|
@@ -40799,12 +40557,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
40799
40557
|
}
|
|
40800
40558
|
|
|
40801
40559
|
// ../bridge/src/worktrees/worktree-layout-file.ts
|
|
40802
|
-
import * as
|
|
40803
|
-
import * as
|
|
40804
|
-
import
|
|
40560
|
+
import * as fs24 from "node:fs";
|
|
40561
|
+
import * as path37 from "node:path";
|
|
40562
|
+
import os6 from "node:os";
|
|
40805
40563
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
40806
40564
|
function defaultWorktreeLayoutPath() {
|
|
40807
|
-
return
|
|
40565
|
+
return path37.join(os6.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
40808
40566
|
}
|
|
40809
40567
|
function normalizeLoadedLayout(raw) {
|
|
40810
40568
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -40816,8 +40574,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
40816
40574
|
function loadWorktreeLayout() {
|
|
40817
40575
|
try {
|
|
40818
40576
|
const p = defaultWorktreeLayoutPath();
|
|
40819
|
-
if (!
|
|
40820
|
-
const raw = JSON.parse(
|
|
40577
|
+
if (!fs24.existsSync(p)) return { launcherCwds: [] };
|
|
40578
|
+
const raw = JSON.parse(fs24.readFileSync(p, "utf8"));
|
|
40821
40579
|
return normalizeLoadedLayout(raw);
|
|
40822
40580
|
} catch {
|
|
40823
40581
|
return { launcherCwds: [] };
|
|
@@ -40825,24 +40583,24 @@ function loadWorktreeLayout() {
|
|
|
40825
40583
|
}
|
|
40826
40584
|
function saveWorktreeLayout(layout) {
|
|
40827
40585
|
try {
|
|
40828
|
-
const dir =
|
|
40829
|
-
|
|
40830
|
-
|
|
40586
|
+
const dir = path37.dirname(defaultWorktreeLayoutPath());
|
|
40587
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
40588
|
+
fs24.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
40831
40589
|
} catch {
|
|
40832
40590
|
}
|
|
40833
40591
|
}
|
|
40834
40592
|
function baseNameSafe(pathString) {
|
|
40835
|
-
return
|
|
40593
|
+
return path37.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
40836
40594
|
}
|
|
40837
40595
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
40838
|
-
const norm =
|
|
40839
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
40596
|
+
const norm = path37.resolve(bridgeRootPath2);
|
|
40597
|
+
const existing = layout.launcherCwds.find((e) => path37.resolve(e.absolutePath) === norm);
|
|
40840
40598
|
return existing?.dirName;
|
|
40841
40599
|
}
|
|
40842
40600
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
40843
40601
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
40844
40602
|
if (existing) return existing;
|
|
40845
|
-
const norm =
|
|
40603
|
+
const norm = path37.resolve(bridgeRootPath2);
|
|
40846
40604
|
const base = baseNameSafe(norm);
|
|
40847
40605
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
40848
40606
|
let name = base;
|
|
@@ -40935,8 +40693,8 @@ function pathspec(...paths) {
|
|
|
40935
40693
|
cache.set(key, paths);
|
|
40936
40694
|
return key;
|
|
40937
40695
|
}
|
|
40938
|
-
function isPathSpec(
|
|
40939
|
-
return
|
|
40696
|
+
function isPathSpec(path83) {
|
|
40697
|
+
return path83 instanceof String && cache.has(path83);
|
|
40940
40698
|
}
|
|
40941
40699
|
function toPaths(pathSpec) {
|
|
40942
40700
|
return cache.get(pathSpec) || [];
|
|
@@ -41025,8 +40783,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
41025
40783
|
function forEachLineWithContent(input, callback) {
|
|
41026
40784
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
41027
40785
|
}
|
|
41028
|
-
function folderExists(
|
|
41029
|
-
return (0, import_file_exists.exists)(
|
|
40786
|
+
function folderExists(path83) {
|
|
40787
|
+
return (0, import_file_exists.exists)(path83, import_file_exists.FOLDER);
|
|
41030
40788
|
}
|
|
41031
40789
|
function append(target, item) {
|
|
41032
40790
|
if (Array.isArray(target)) {
|
|
@@ -41430,8 +41188,8 @@ function checkIsRepoRootTask() {
|
|
|
41430
41188
|
commands,
|
|
41431
41189
|
format: "utf-8",
|
|
41432
41190
|
onError,
|
|
41433
|
-
parser(
|
|
41434
|
-
return /^\.(git)?$/.test(
|
|
41191
|
+
parser(path83) {
|
|
41192
|
+
return /^\.(git)?$/.test(path83.trim());
|
|
41435
41193
|
}
|
|
41436
41194
|
};
|
|
41437
41195
|
}
|
|
@@ -41865,11 +41623,11 @@ function parseGrep(grep) {
|
|
|
41865
41623
|
const paths = /* @__PURE__ */ new Set();
|
|
41866
41624
|
const results = {};
|
|
41867
41625
|
forEachLineWithContent(grep, (input) => {
|
|
41868
|
-
const [
|
|
41869
|
-
paths.add(
|
|
41870
|
-
(results[
|
|
41626
|
+
const [path83, line, preview] = input.split(NULL);
|
|
41627
|
+
paths.add(path83);
|
|
41628
|
+
(results[path83] = results[path83] || []).push({
|
|
41871
41629
|
line: asNumber(line),
|
|
41872
|
-
path:
|
|
41630
|
+
path: path83,
|
|
41873
41631
|
preview
|
|
41874
41632
|
});
|
|
41875
41633
|
});
|
|
@@ -42634,14 +42392,14 @@ var init_hash_object = __esm2({
|
|
|
42634
42392
|
init_task();
|
|
42635
42393
|
}
|
|
42636
42394
|
});
|
|
42637
|
-
function parseInit(bare,
|
|
42395
|
+
function parseInit(bare, path83, text) {
|
|
42638
42396
|
const response = String(text).trim();
|
|
42639
42397
|
let result;
|
|
42640
42398
|
if (result = initResponseRegex.exec(response)) {
|
|
42641
|
-
return new InitSummary(bare,
|
|
42399
|
+
return new InitSummary(bare, path83, false, result[1]);
|
|
42642
42400
|
}
|
|
42643
42401
|
if (result = reInitResponseRegex.exec(response)) {
|
|
42644
|
-
return new InitSummary(bare,
|
|
42402
|
+
return new InitSummary(bare, path83, true, result[1]);
|
|
42645
42403
|
}
|
|
42646
42404
|
let gitDir = "";
|
|
42647
42405
|
const tokens = response.split(" ");
|
|
@@ -42652,7 +42410,7 @@ function parseInit(bare, path85, text) {
|
|
|
42652
42410
|
break;
|
|
42653
42411
|
}
|
|
42654
42412
|
}
|
|
42655
|
-
return new InitSummary(bare,
|
|
42413
|
+
return new InitSummary(bare, path83, /^re/i.test(response), gitDir);
|
|
42656
42414
|
}
|
|
42657
42415
|
var InitSummary;
|
|
42658
42416
|
var initResponseRegex;
|
|
@@ -42661,9 +42419,9 @@ var init_InitSummary = __esm2({
|
|
|
42661
42419
|
"src/lib/responses/InitSummary.ts"() {
|
|
42662
42420
|
"use strict";
|
|
42663
42421
|
InitSummary = class {
|
|
42664
|
-
constructor(bare,
|
|
42422
|
+
constructor(bare, path83, existing, gitDir) {
|
|
42665
42423
|
this.bare = bare;
|
|
42666
|
-
this.path =
|
|
42424
|
+
this.path = path83;
|
|
42667
42425
|
this.existing = existing;
|
|
42668
42426
|
this.gitDir = gitDir;
|
|
42669
42427
|
}
|
|
@@ -42675,7 +42433,7 @@ var init_InitSummary = __esm2({
|
|
|
42675
42433
|
function hasBareCommand(command) {
|
|
42676
42434
|
return command.includes(bareCommand);
|
|
42677
42435
|
}
|
|
42678
|
-
function initTask(bare = false,
|
|
42436
|
+
function initTask(bare = false, path83, customArgs) {
|
|
42679
42437
|
const commands = ["init", ...customArgs];
|
|
42680
42438
|
if (bare && !hasBareCommand(commands)) {
|
|
42681
42439
|
commands.splice(1, 0, bareCommand);
|
|
@@ -42684,7 +42442,7 @@ function initTask(bare = false, path85, customArgs) {
|
|
|
42684
42442
|
commands,
|
|
42685
42443
|
format: "utf-8",
|
|
42686
42444
|
parser(text) {
|
|
42687
|
-
return parseInit(commands.includes("--bare"),
|
|
42445
|
+
return parseInit(commands.includes("--bare"), path83, text);
|
|
42688
42446
|
}
|
|
42689
42447
|
};
|
|
42690
42448
|
}
|
|
@@ -43500,12 +43258,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
43500
43258
|
"use strict";
|
|
43501
43259
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
43502
43260
|
FileStatusSummary = class {
|
|
43503
|
-
constructor(
|
|
43504
|
-
this.path =
|
|
43261
|
+
constructor(path83, index, working_dir) {
|
|
43262
|
+
this.path = path83;
|
|
43505
43263
|
this.index = index;
|
|
43506
43264
|
this.working_dir = working_dir;
|
|
43507
43265
|
if (index === "R" || working_dir === "R") {
|
|
43508
|
-
const detail = fromPathRegex.exec(
|
|
43266
|
+
const detail = fromPathRegex.exec(path83) || [null, path83, path83];
|
|
43509
43267
|
this.from = detail[2] || "";
|
|
43510
43268
|
this.path = detail[1] || "";
|
|
43511
43269
|
}
|
|
@@ -43536,14 +43294,14 @@ function splitLine(result, lineStr) {
|
|
|
43536
43294
|
default:
|
|
43537
43295
|
return;
|
|
43538
43296
|
}
|
|
43539
|
-
function data(index, workingDir,
|
|
43297
|
+
function data(index, workingDir, path83) {
|
|
43540
43298
|
const raw = `${index}${workingDir}`;
|
|
43541
43299
|
const handler = parsers6.get(raw);
|
|
43542
43300
|
if (handler) {
|
|
43543
|
-
handler(result,
|
|
43301
|
+
handler(result, path83);
|
|
43544
43302
|
}
|
|
43545
43303
|
if (raw !== "##" && raw !== "!!") {
|
|
43546
|
-
result.files.push(new FileStatusSummary(
|
|
43304
|
+
result.files.push(new FileStatusSummary(path83, index, workingDir));
|
|
43547
43305
|
}
|
|
43548
43306
|
}
|
|
43549
43307
|
}
|
|
@@ -43852,9 +43610,9 @@ var init_simple_git_api = __esm2({
|
|
|
43852
43610
|
next
|
|
43853
43611
|
);
|
|
43854
43612
|
}
|
|
43855
|
-
hashObject(
|
|
43613
|
+
hashObject(path83, write) {
|
|
43856
43614
|
return this._runTask(
|
|
43857
|
-
hashObjectTask(
|
|
43615
|
+
hashObjectTask(path83, write === true),
|
|
43858
43616
|
trailingFunctionArgument(arguments)
|
|
43859
43617
|
);
|
|
43860
43618
|
}
|
|
@@ -44207,8 +43965,8 @@ var init_branch = __esm2({
|
|
|
44207
43965
|
}
|
|
44208
43966
|
});
|
|
44209
43967
|
function toPath(input) {
|
|
44210
|
-
const
|
|
44211
|
-
return
|
|
43968
|
+
const path83 = input.trim().replace(/^["']|["']$/g, "");
|
|
43969
|
+
return path83 && normalize3(path83);
|
|
44212
43970
|
}
|
|
44213
43971
|
var parseCheckIgnore;
|
|
44214
43972
|
var init_CheckIgnore = __esm2({
|
|
@@ -44522,8 +44280,8 @@ __export2(sub_module_exports, {
|
|
|
44522
44280
|
subModuleTask: () => subModuleTask,
|
|
44523
44281
|
updateSubModuleTask: () => updateSubModuleTask
|
|
44524
44282
|
});
|
|
44525
|
-
function addSubModuleTask(repo,
|
|
44526
|
-
return subModuleTask(["add", repo,
|
|
44283
|
+
function addSubModuleTask(repo, path83) {
|
|
44284
|
+
return subModuleTask(["add", repo, path83]);
|
|
44527
44285
|
}
|
|
44528
44286
|
function initSubModuleTask(customArgs) {
|
|
44529
44287
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -44856,8 +44614,8 @@ var require_git = __commonJS2({
|
|
|
44856
44614
|
}
|
|
44857
44615
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
44858
44616
|
};
|
|
44859
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
44860
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
44617
|
+
Git2.prototype.submoduleAdd = function(repo, path83, then) {
|
|
44618
|
+
return this._runTask(addSubModuleTask2(repo, path83), trailingFunctionArgument2(arguments));
|
|
44861
44619
|
};
|
|
44862
44620
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
44863
44621
|
return this._runTask(
|
|
@@ -45596,8 +45354,8 @@ function parseNumstatEntries(lines) {
|
|
|
45596
45354
|
}
|
|
45597
45355
|
function parseNumstat(lines) {
|
|
45598
45356
|
const m = /* @__PURE__ */ new Map();
|
|
45599
|
-
for (const [
|
|
45600
|
-
m.set(
|
|
45357
|
+
for (const [path83, entry] of parseNumstatEntries(lines)) {
|
|
45358
|
+
m.set(path83, { additions: entry.additions, deletions: entry.deletions });
|
|
45601
45359
|
}
|
|
45602
45360
|
return m;
|
|
45603
45361
|
}
|
|
@@ -45726,7 +45484,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
45726
45484
|
}
|
|
45727
45485
|
|
|
45728
45486
|
// ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
45729
|
-
import * as
|
|
45487
|
+
import * as path38 from "node:path";
|
|
45730
45488
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
45731
45489
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
45732
45490
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -45737,7 +45495,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
45737
45495
|
}
|
|
45738
45496
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
45739
45497
|
if (repoDir) {
|
|
45740
|
-
const key =
|
|
45498
|
+
const key = path38.resolve(repoDir);
|
|
45741
45499
|
const now = Date.now();
|
|
45742
45500
|
const cached2 = baseShaCache.get(key);
|
|
45743
45501
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -45872,17 +45630,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
45872
45630
|
}
|
|
45873
45631
|
|
|
45874
45632
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
45875
|
-
import * as
|
|
45633
|
+
import * as path48 from "node:path";
|
|
45876
45634
|
|
|
45877
45635
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
45878
|
-
import * as
|
|
45636
|
+
import * as path47 from "node:path";
|
|
45879
45637
|
|
|
45880
45638
|
// ../bridge/src/git/is-git-repo.ts
|
|
45881
|
-
import * as
|
|
45882
|
-
import * as
|
|
45639
|
+
import * as fs25 from "node:fs";
|
|
45640
|
+
import * as path39 from "node:path";
|
|
45883
45641
|
async function isGitRepoDirectory(dirPath) {
|
|
45884
45642
|
try {
|
|
45885
|
-
await
|
|
45643
|
+
await fs25.promises.access(path39.join(dirPath, ".git"));
|
|
45886
45644
|
return true;
|
|
45887
45645
|
} catch {
|
|
45888
45646
|
return false;
|
|
@@ -45890,8 +45648,8 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
45890
45648
|
}
|
|
45891
45649
|
|
|
45892
45650
|
// ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
|
|
45893
|
-
import * as
|
|
45894
|
-
import * as
|
|
45651
|
+
import * as fs26 from "node:fs";
|
|
45652
|
+
import * as path40 from "node:path";
|
|
45895
45653
|
|
|
45896
45654
|
// ../bridge/src/git/changes/lines/count-lines.ts
|
|
45897
45655
|
import { createReadStream } from "node:fs";
|
|
@@ -45923,7 +45681,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45923
45681
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
45924
45682
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
45925
45683
|
if (row.change === "moved") return;
|
|
45926
|
-
const repoFilePath =
|
|
45684
|
+
const repoFilePath = path40.join(options.repoGitCwd, pathInRepo);
|
|
45927
45685
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
45928
45686
|
if (fromGit) {
|
|
45929
45687
|
row.additions = fromGit.additions;
|
|
@@ -45931,7 +45689,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45931
45689
|
return;
|
|
45932
45690
|
}
|
|
45933
45691
|
try {
|
|
45934
|
-
const st = await
|
|
45692
|
+
const st = await fs26.promises.stat(repoFilePath);
|
|
45935
45693
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
45936
45694
|
} catch {
|
|
45937
45695
|
row.additions = 0;
|
|
@@ -46008,7 +45766,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
46008
45766
|
}
|
|
46009
45767
|
|
|
46010
45768
|
// ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
46011
|
-
import * as
|
|
45769
|
+
import * as path42 from "node:path";
|
|
46012
45770
|
|
|
46013
45771
|
// ../bridge/src/git/changes/patch/patch-truncate.ts
|
|
46014
45772
|
function truncatePatch(s) {
|
|
@@ -46096,10 +45854,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
46096
45854
|
}
|
|
46097
45855
|
|
|
46098
45856
|
// ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
46099
|
-
import * as
|
|
45857
|
+
import * as fs27 from "node:fs";
|
|
46100
45858
|
async function readWorktreeFileLines(filePath) {
|
|
46101
45859
|
try {
|
|
46102
|
-
const raw = await
|
|
45860
|
+
const raw = await fs27.promises.readFile(filePath, "utf8");
|
|
46103
45861
|
return raw.split(/\r?\n/);
|
|
46104
45862
|
} catch {
|
|
46105
45863
|
return null;
|
|
@@ -46237,8 +45995,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
46237
45995
|
}
|
|
46238
45996
|
|
|
46239
45997
|
// ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
46240
|
-
import * as
|
|
46241
|
-
import * as
|
|
45998
|
+
import * as fs28 from "node:fs";
|
|
45999
|
+
import * as path41 from "node:path";
|
|
46242
46000
|
var MAX_BYTES = 512e3;
|
|
46243
46001
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
46244
46002
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -46258,13 +46016,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
46258
46016
|
}
|
|
46259
46017
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
46260
46018
|
if (options.isBinary) return null;
|
|
46261
|
-
const filePath =
|
|
46019
|
+
const filePath = path41.join(options.repoGitCwd, options.pathInRepo);
|
|
46262
46020
|
if (options.change === "removed") {
|
|
46263
46021
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
46264
46022
|
}
|
|
46265
46023
|
if (options.change === "moved" || options.change === "modified") {
|
|
46266
46024
|
try {
|
|
46267
|
-
const st = await
|
|
46025
|
+
const st = await fs28.promises.stat(filePath);
|
|
46268
46026
|
if (!st.isFile()) return null;
|
|
46269
46027
|
return await countTextFileLines(filePath);
|
|
46270
46028
|
} catch {
|
|
@@ -46307,7 +46065,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
46307
46065
|
row.workspaceRelPath,
|
|
46308
46066
|
options.repoPathRelativeToWorkspaceRoot
|
|
46309
46067
|
);
|
|
46310
|
-
const filePath =
|
|
46068
|
+
const filePath = path42.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
46311
46069
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
46312
46070
|
let patch = await unifiedDiffForFile(
|
|
46313
46071
|
options.repoGitCwd,
|
|
@@ -46465,7 +46223,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
46465
46223
|
}
|
|
46466
46224
|
|
|
46467
46225
|
// ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
|
|
46468
|
-
import * as
|
|
46226
|
+
import * as path43 from "node:path";
|
|
46469
46227
|
|
|
46470
46228
|
// ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
|
|
46471
46229
|
async function enrichCommitFileRows(options) {
|
|
@@ -46510,7 +46268,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
46510
46268
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
46511
46269
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
46512
46270
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
46513
|
-
return `${
|
|
46271
|
+
return `${path43.resolve(repoGitCwd)}:${commitSha}`;
|
|
46514
46272
|
}
|
|
46515
46273
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
46516
46274
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -46565,7 +46323,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
46565
46323
|
}
|
|
46566
46324
|
|
|
46567
46325
|
// ../bridge/src/git/commits/list-unpushed-commits.ts
|
|
46568
|
-
import * as
|
|
46326
|
+
import * as path44 from "node:path";
|
|
46569
46327
|
|
|
46570
46328
|
// ../bridge/src/git/commits/lib/parse-log-lines.ts
|
|
46571
46329
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -46600,7 +46358,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
46600
46358
|
}
|
|
46601
46359
|
}
|
|
46602
46360
|
async function listUnpushedCommits(repoDir) {
|
|
46603
|
-
const key =
|
|
46361
|
+
const key = path44.resolve(repoDir);
|
|
46604
46362
|
const now = Date.now();
|
|
46605
46363
|
const cached2 = unpushedCache.get(key);
|
|
46606
46364
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -46661,7 +46419,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
46661
46419
|
}
|
|
46662
46420
|
|
|
46663
46421
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46664
|
-
import * as
|
|
46422
|
+
import * as path45 from "node:path";
|
|
46665
46423
|
|
|
46666
46424
|
// ../bridge/src/git/remote-origin-url.ts
|
|
46667
46425
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -46676,7 +46434,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
46676
46434
|
|
|
46677
46435
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46678
46436
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
46679
|
-
const resolvedCheckoutPath =
|
|
46437
|
+
const resolvedCheckoutPath = path45.resolve(checkoutPath);
|
|
46680
46438
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
46681
46439
|
await yieldToEventLoop2();
|
|
46682
46440
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -46691,14 +46449,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
46691
46449
|
}
|
|
46692
46450
|
|
|
46693
46451
|
// ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
46694
|
-
import * as
|
|
46452
|
+
import * as path46 from "node:path";
|
|
46695
46453
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
46696
|
-
const checkoutPath =
|
|
46454
|
+
const checkoutPath = path46.resolve(options.checkoutPath);
|
|
46697
46455
|
const git = cliSimpleGit(checkoutPath);
|
|
46698
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46456
|
+
const sessionParentPath = options.sessionParentPath ? path46.resolve(options.sessionParentPath) : null;
|
|
46699
46457
|
let repoPathRelativeToWorkspaceRoot;
|
|
46700
46458
|
if (sessionParentPath) {
|
|
46701
|
-
const checkoutPathRelativeToSessionParent =
|
|
46459
|
+
const checkoutPathRelativeToSessionParent = path46.relative(sessionParentPath, checkoutPath);
|
|
46702
46460
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
46703
46461
|
} else {
|
|
46704
46462
|
let gitTopLevel = checkoutPath;
|
|
@@ -46708,8 +46466,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46708
46466
|
} catch {
|
|
46709
46467
|
gitTopLevel = checkoutPath;
|
|
46710
46468
|
}
|
|
46711
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
46712
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
46469
|
+
const gitTopLevelRelativeToBridgeRoot = path46.relative(options.bridgeRoot, path46.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
46470
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path46.basename(path46.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
46713
46471
|
}
|
|
46714
46472
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46715
46473
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -46718,10 +46476,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46718
46476
|
|
|
46719
46477
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
46720
46478
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
46721
|
-
const checkoutPath =
|
|
46479
|
+
const checkoutPath = path47.resolve(options.targetPath);
|
|
46722
46480
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
46723
46481
|
const isCommitView = options.basis.kind === "commit";
|
|
46724
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46482
|
+
const sessionParentPath = options.sessionParentPath ? path47.resolve(options.sessionParentPath) : null;
|
|
46725
46483
|
const git = cliSimpleGit(checkoutPath);
|
|
46726
46484
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46727
46485
|
checkoutPath,
|
|
@@ -46769,8 +46527,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
46769
46527
|
|
|
46770
46528
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
46771
46529
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
46772
|
-
const bridgeRoot =
|
|
46773
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46530
|
+
const bridgeRoot = path48.resolve(getBridgeRoot());
|
|
46531
|
+
const sessionParentPath = options.sessionParentPath ? path48.resolve(options.sessionParentPath) : null;
|
|
46774
46532
|
const out = [];
|
|
46775
46533
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
46776
46534
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -46801,9 +46559,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
46801
46559
|
}
|
|
46802
46560
|
|
|
46803
46561
|
// ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
46804
|
-
import * as
|
|
46562
|
+
import * as path49 from "node:path";
|
|
46805
46563
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
46806
|
-
const repoGitCwd =
|
|
46564
|
+
const repoGitCwd = path49.resolve(options.repoGitCwd);
|
|
46807
46565
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
46808
46566
|
throw new Error("Not a git repository");
|
|
46809
46567
|
}
|
|
@@ -46842,7 +46600,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
46842
46600
|
});
|
|
46843
46601
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
46844
46602
|
}
|
|
46845
|
-
const filePath =
|
|
46603
|
+
const filePath = path49.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
46846
46604
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
46847
46605
|
let patchContent = await unifiedDiffForFile(
|
|
46848
46606
|
repoGitCwd,
|
|
@@ -46888,18 +46646,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
46888
46646
|
}
|
|
46889
46647
|
|
|
46890
46648
|
// ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
46891
|
-
import * as
|
|
46649
|
+
import * as path50 from "node:path";
|
|
46892
46650
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
46893
46651
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
46894
|
-
const bridgeRoot =
|
|
46895
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
46652
|
+
const bridgeRoot = path50.resolve(getBridgeRoot());
|
|
46653
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path50.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
46896
46654
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46897
46655
|
opts.repoRelPath.trim()
|
|
46898
46656
|
);
|
|
46899
46657
|
let result = null;
|
|
46900
46658
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
46901
46659
|
if (result) return;
|
|
46902
|
-
const checkoutPath =
|
|
46660
|
+
const checkoutPath = path50.resolve(targetPath);
|
|
46903
46661
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
46904
46662
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46905
46663
|
checkoutPath,
|
|
@@ -46932,13 +46690,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
46932
46690
|
}
|
|
46933
46691
|
|
|
46934
46692
|
// ../bridge/src/worktrees/remove-session-worktrees.ts
|
|
46935
|
-
import * as
|
|
46693
|
+
import * as fs31 from "node:fs";
|
|
46936
46694
|
|
|
46937
46695
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
46938
|
-
import * as
|
|
46696
|
+
import * as fs30 from "node:fs";
|
|
46939
46697
|
|
|
46940
46698
|
// ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
46941
|
-
import
|
|
46699
|
+
import path51 from "node:path";
|
|
46942
46700
|
init_normalize_resolved_path();
|
|
46943
46701
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
46944
46702
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -46947,23 +46705,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
46947
46705
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
46948
46706
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
46949
46707
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
46950
|
-
const rel =
|
|
46951
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
46708
|
+
const rel = path51.relative(worktreesRoot, normalized);
|
|
46709
|
+
if (rel === "" || rel.startsWith("..") || path51.isAbsolute(rel)) return false;
|
|
46952
46710
|
return true;
|
|
46953
46711
|
}
|
|
46954
46712
|
|
|
46955
46713
|
// ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
46956
|
-
import * as
|
|
46957
|
-
import * as
|
|
46714
|
+
import * as fs29 from "node:fs";
|
|
46715
|
+
import * as path52 from "node:path";
|
|
46958
46716
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
46959
|
-
const gitDirFile =
|
|
46960
|
-
if (!
|
|
46961
|
-
const first2 =
|
|
46717
|
+
const gitDirFile = path52.join(wt, ".git");
|
|
46718
|
+
if (!fs29.existsSync(gitDirFile) || !fs29.statSync(gitDirFile).isFile()) return "";
|
|
46719
|
+
const first2 = fs29.readFileSync(gitDirFile, "utf8").trim();
|
|
46962
46720
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
46963
46721
|
if (!m) return "";
|
|
46964
|
-
const gitWorktreePath =
|
|
46965
|
-
const gitDir =
|
|
46966
|
-
return
|
|
46722
|
+
const gitWorktreePath = path52.resolve(wt, m[1].trim());
|
|
46723
|
+
const gitDir = path52.dirname(path52.dirname(gitWorktreePath));
|
|
46724
|
+
return path52.dirname(gitDir);
|
|
46967
46725
|
}
|
|
46968
46726
|
|
|
46969
46727
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
@@ -46974,7 +46732,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
46974
46732
|
return true;
|
|
46975
46733
|
}
|
|
46976
46734
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
46977
|
-
|
|
46735
|
+
fs30.rmSync(worktreePath, { recursive: true, force: true });
|
|
46978
46736
|
return true;
|
|
46979
46737
|
}
|
|
46980
46738
|
|
|
@@ -46996,7 +46754,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
46996
46754
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
46997
46755
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
46998
46756
|
try {
|
|
46999
|
-
|
|
46757
|
+
fs31.rmSync(wt, { recursive: true, force: true });
|
|
47000
46758
|
} catch {
|
|
47001
46759
|
}
|
|
47002
46760
|
}
|
|
@@ -47052,12 +46810,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
47052
46810
|
// ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
47053
46811
|
init_cli_process_interrupt();
|
|
47054
46812
|
init_yield_to_event_loop();
|
|
47055
|
-
import * as
|
|
47056
|
-
import * as
|
|
46813
|
+
import * as fs35 from "node:fs";
|
|
46814
|
+
import * as path57 from "node:path";
|
|
47057
46815
|
|
|
47058
46816
|
// ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
|
|
47059
|
-
import * as
|
|
47060
|
-
import * as
|
|
46817
|
+
import * as fs33 from "node:fs";
|
|
46818
|
+
import * as path54 from "node:path";
|
|
47061
46819
|
|
|
47062
46820
|
// ../bridge/src/worktrees/discovery/disk-walk-constants.ts
|
|
47063
46821
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -47087,8 +46845,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
47087
46845
|
// ../bridge/src/worktrees/discovery/disk-walk-utils.ts
|
|
47088
46846
|
init_cli_process_interrupt();
|
|
47089
46847
|
init_yield_to_event_loop();
|
|
47090
|
-
import * as
|
|
47091
|
-
import * as
|
|
46848
|
+
import * as fs32 from "node:fs";
|
|
46849
|
+
import * as path53 from "node:path";
|
|
47092
46850
|
async function yieldDuringDiskWalk(state) {
|
|
47093
46851
|
state.entries++;
|
|
47094
46852
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -47098,7 +46856,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
47098
46856
|
}
|
|
47099
46857
|
async function isGitDir(dirPath) {
|
|
47100
46858
|
try {
|
|
47101
|
-
await
|
|
46859
|
+
await fs32.promises.access(path53.join(dirPath, ".git"));
|
|
47102
46860
|
return true;
|
|
47103
46861
|
} catch {
|
|
47104
46862
|
return false;
|
|
@@ -47112,23 +46870,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
47112
46870
|
const walk = async (dir) => {
|
|
47113
46871
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47114
46872
|
if (await isGitDir(dir)) {
|
|
47115
|
-
out.push(
|
|
46873
|
+
out.push(path54.resolve(dir));
|
|
47116
46874
|
return;
|
|
47117
46875
|
}
|
|
47118
46876
|
let entries;
|
|
47119
46877
|
try {
|
|
47120
|
-
entries = await
|
|
46878
|
+
entries = await fs33.promises.readdir(dir, { withFileTypes: true });
|
|
47121
46879
|
} catch {
|
|
47122
46880
|
return;
|
|
47123
46881
|
}
|
|
47124
46882
|
for (const e of entries) {
|
|
47125
46883
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47126
|
-
const full =
|
|
46884
|
+
const full = path54.join(dir, e.name);
|
|
47127
46885
|
if (!e.isDirectory()) continue;
|
|
47128
46886
|
await walk(full);
|
|
47129
46887
|
}
|
|
47130
46888
|
};
|
|
47131
|
-
await walk(
|
|
46889
|
+
await walk(path54.resolve(rootPath));
|
|
47132
46890
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
47133
46891
|
}
|
|
47134
46892
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -47139,16 +46897,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47139
46897
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47140
46898
|
let entries;
|
|
47141
46899
|
try {
|
|
47142
|
-
entries = await
|
|
46900
|
+
entries = await fs33.promises.readdir(dir, { withFileTypes: true });
|
|
47143
46901
|
} catch {
|
|
47144
46902
|
return;
|
|
47145
46903
|
}
|
|
47146
46904
|
for (const e of entries) {
|
|
47147
46905
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47148
|
-
const full =
|
|
46906
|
+
const full = path54.join(dir, e.name);
|
|
47149
46907
|
if (!e.isDirectory()) continue;
|
|
47150
46908
|
if (e.name === sessionId) {
|
|
47151
|
-
if (await isGitDir(full)) out.push(
|
|
46909
|
+
if (await isGitDir(full)) out.push(path54.resolve(full));
|
|
47152
46910
|
continue;
|
|
47153
46911
|
}
|
|
47154
46912
|
if (await isGitDir(full)) continue;
|
|
@@ -47160,14 +46918,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47160
46918
|
}
|
|
47161
46919
|
|
|
47162
46920
|
// ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
47163
|
-
import * as
|
|
46921
|
+
import * as path55 from "node:path";
|
|
47164
46922
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
47165
|
-
const bridge =
|
|
46923
|
+
const bridge = path55.resolve(bridgeRoot);
|
|
47166
46924
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
47167
46925
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
47168
|
-
const entry =
|
|
47169
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
47170
|
-
}).sort((a, b) =>
|
|
46926
|
+
const entry = path55.resolve(e.absolutePath);
|
|
46927
|
+
return bridge === entry || bridge.startsWith(entry + path55.sep) || entry.startsWith(bridge + path55.sep);
|
|
46928
|
+
}).sort((a, b) => path55.resolve(b.absolutePath).length - path55.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
47171
46929
|
const ordered = [];
|
|
47172
46930
|
const seen = /* @__PURE__ */ new Set();
|
|
47173
46931
|
const add = (k) => {
|
|
@@ -47185,19 +46943,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
47185
46943
|
}
|
|
47186
46944
|
|
|
47187
46945
|
// ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
47188
|
-
import * as
|
|
47189
|
-
import * as
|
|
46946
|
+
import * as fs34 from "node:fs";
|
|
46947
|
+
import * as path56 from "node:path";
|
|
47190
46948
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
47191
46949
|
let st;
|
|
47192
46950
|
try {
|
|
47193
|
-
st = await
|
|
46951
|
+
st = await fs34.promises.stat(scopeDir);
|
|
47194
46952
|
} catch {
|
|
47195
46953
|
return null;
|
|
47196
46954
|
}
|
|
47197
46955
|
if (!st.isDirectory()) return null;
|
|
47198
46956
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
47199
46957
|
if (worktreePaths.length === 0) return null;
|
|
47200
|
-
const abs =
|
|
46958
|
+
const abs = path56.resolve(scopeDir);
|
|
47201
46959
|
return {
|
|
47202
46960
|
parentPath: abs,
|
|
47203
46961
|
repoCheckoutPaths: worktreePaths
|
|
@@ -47220,7 +46978,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47220
46978
|
const sid = sessionId.trim();
|
|
47221
46979
|
if (!sid) return null;
|
|
47222
46980
|
try {
|
|
47223
|
-
await
|
|
46981
|
+
await fs35.promises.access(worktreesRootPath);
|
|
47224
46982
|
} catch {
|
|
47225
46983
|
return null;
|
|
47226
46984
|
}
|
|
@@ -47229,13 +46987,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47229
46987
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47230
46988
|
const scanState = { entries: 0 };
|
|
47231
46989
|
try {
|
|
47232
|
-
for (const name of await
|
|
46990
|
+
for (const name of await fs35.promises.readdir(worktreesRootPath)) {
|
|
47233
46991
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47234
46992
|
if (name.startsWith(".")) continue;
|
|
47235
|
-
const p =
|
|
46993
|
+
const p = path57.join(worktreesRootPath, name);
|
|
47236
46994
|
let st;
|
|
47237
46995
|
try {
|
|
47238
|
-
st = await
|
|
46996
|
+
st = await fs35.promises.stat(p);
|
|
47239
46997
|
} catch {
|
|
47240
46998
|
continue;
|
|
47241
46999
|
}
|
|
@@ -47249,23 +47007,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47249
47007
|
for (const key of keys) {
|
|
47250
47008
|
if (isCliImmediateShutdownRequested()) return null;
|
|
47251
47009
|
await yieldToEventLoop();
|
|
47252
|
-
const layoutRoot =
|
|
47010
|
+
const layoutRoot = path57.join(worktreesRootPath, key);
|
|
47253
47011
|
let layoutSt;
|
|
47254
47012
|
try {
|
|
47255
|
-
layoutSt = await
|
|
47013
|
+
layoutSt = await fs35.promises.stat(layoutRoot);
|
|
47256
47014
|
} catch {
|
|
47257
47015
|
continue;
|
|
47258
47016
|
}
|
|
47259
47017
|
if (!layoutSt.isDirectory()) continue;
|
|
47260
|
-
const sessionDir =
|
|
47018
|
+
const sessionDir = path57.join(layoutRoot, sid);
|
|
47261
47019
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
47262
47020
|
if (nested) return nested;
|
|
47263
47021
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
47264
47022
|
if (legacy.paths.length > 0) {
|
|
47265
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
47023
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path57.resolve(legacy.paths[0]);
|
|
47266
47024
|
return {
|
|
47267
|
-
sessionParentPath:
|
|
47268
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
47025
|
+
sessionParentPath: path57.resolve(isolated),
|
|
47026
|
+
repoCheckoutPaths: legacy.paths.map((p) => path57.resolve(p))
|
|
47269
47027
|
};
|
|
47270
47028
|
}
|
|
47271
47029
|
}
|
|
@@ -47273,31 +47031,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47273
47031
|
}
|
|
47274
47032
|
|
|
47275
47033
|
// ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
47276
|
-
import * as
|
|
47277
|
-
import * as
|
|
47034
|
+
import * as fs36 from "node:fs";
|
|
47035
|
+
import * as path59 from "node:path";
|
|
47278
47036
|
|
|
47279
47037
|
// ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
47280
47038
|
init_cli_process_interrupt();
|
|
47281
47039
|
init_yield_to_event_loop();
|
|
47282
|
-
import * as
|
|
47040
|
+
import * as path58 from "node:path";
|
|
47283
47041
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
47284
47042
|
const sid = sessionId.trim();
|
|
47285
47043
|
if (!sid) return null;
|
|
47286
|
-
const hintR =
|
|
47044
|
+
const hintR = path58.resolve(checkoutPath);
|
|
47287
47045
|
let best = null;
|
|
47288
|
-
let cur =
|
|
47046
|
+
let cur = path58.dirname(hintR);
|
|
47289
47047
|
for (let i = 0; i < 40; i++) {
|
|
47290
47048
|
if (isCliImmediateShutdownRequested()) return best;
|
|
47291
47049
|
await yieldToEventLoop();
|
|
47292
47050
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
47293
|
-
if (paths.paths.some((p) =>
|
|
47294
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
47051
|
+
if (paths.paths.some((p) => path58.resolve(p) === hintR)) {
|
|
47052
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path58.resolve(paths.paths[0]);
|
|
47295
47053
|
best = {
|
|
47296
|
-
sessionParentPath:
|
|
47297
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
47054
|
+
sessionParentPath: path58.resolve(isolated),
|
|
47055
|
+
repoCheckoutPaths: paths.paths.map((p) => path58.resolve(p))
|
|
47298
47056
|
};
|
|
47299
47057
|
}
|
|
47300
|
-
const next =
|
|
47058
|
+
const next = path58.dirname(cur);
|
|
47301
47059
|
if (next === cur) break;
|
|
47302
47060
|
cur = next;
|
|
47303
47061
|
}
|
|
@@ -47308,12 +47066,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
47308
47066
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
47309
47067
|
const sid = sessionId.trim();
|
|
47310
47068
|
if (!sid) return null;
|
|
47311
|
-
const hint =
|
|
47312
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
47069
|
+
const hint = path59.resolve(sessionParentPathOrHint);
|
|
47070
|
+
const underHint = await tryBindingFromSessionDirectory(path59.join(hint, sid));
|
|
47313
47071
|
if (underHint) return underHint;
|
|
47314
47072
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
47315
47073
|
if (direct) {
|
|
47316
|
-
if (
|
|
47074
|
+
if (path59.basename(hint) === sid && await isGitDir(hint)) {
|
|
47317
47075
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47318
47076
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
47319
47077
|
return legacyFromCheckout;
|
|
@@ -47321,23 +47079,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
47321
47079
|
}
|
|
47322
47080
|
return direct;
|
|
47323
47081
|
}
|
|
47324
|
-
if (
|
|
47082
|
+
if (path59.basename(hint) === sid && await isGitDir(hint)) {
|
|
47325
47083
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47326
47084
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
47327
47085
|
}
|
|
47328
47086
|
let st;
|
|
47329
47087
|
try {
|
|
47330
|
-
st = await
|
|
47088
|
+
st = await fs36.promises.stat(hint);
|
|
47331
47089
|
} catch {
|
|
47332
47090
|
return null;
|
|
47333
47091
|
}
|
|
47334
47092
|
if (!st.isDirectory()) return null;
|
|
47335
47093
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
47336
47094
|
if (legacyPaths.paths.length === 0) return null;
|
|
47337
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
47095
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path59.resolve(legacyPaths.paths[0]);
|
|
47338
47096
|
return {
|
|
47339
|
-
sessionParentPath:
|
|
47340
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
47097
|
+
sessionParentPath: path59.resolve(isolated),
|
|
47098
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path59.resolve(p))
|
|
47341
47099
|
};
|
|
47342
47100
|
}
|
|
47343
47101
|
|
|
@@ -47398,11 +47156,11 @@ function parseSessionParent(v) {
|
|
|
47398
47156
|
}
|
|
47399
47157
|
|
|
47400
47158
|
// ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
47401
|
-
import * as
|
|
47159
|
+
import * as fs40 from "node:fs";
|
|
47402
47160
|
|
|
47403
47161
|
// ../bridge/src/git/discover-repos.ts
|
|
47404
|
-
import * as
|
|
47405
|
-
import * as
|
|
47162
|
+
import * as fs37 from "node:fs";
|
|
47163
|
+
import * as path60 from "node:path";
|
|
47406
47164
|
init_yield_to_event_loop();
|
|
47407
47165
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
47408
47166
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -47412,14 +47170,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
47412
47170
|
}
|
|
47413
47171
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
47414
47172
|
const result = [];
|
|
47415
|
-
const cwdResolved =
|
|
47173
|
+
const cwdResolved = path60.resolve(cwd);
|
|
47416
47174
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
47417
47175
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
47418
47176
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
47419
47177
|
}
|
|
47420
47178
|
let entries;
|
|
47421
47179
|
try {
|
|
47422
|
-
entries =
|
|
47180
|
+
entries = fs37.readdirSync(cwdResolved, { withFileTypes: true });
|
|
47423
47181
|
} catch {
|
|
47424
47182
|
return result;
|
|
47425
47183
|
}
|
|
@@ -47427,7 +47185,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47427
47185
|
await yieldGitDiscoverWork(i + 1);
|
|
47428
47186
|
const ent = entries[i];
|
|
47429
47187
|
if (!ent.isDirectory()) continue;
|
|
47430
|
-
const childPath2 =
|
|
47188
|
+
const childPath2 = path60.join(cwdResolved, ent.name);
|
|
47431
47189
|
if (await isGitRepoDirectory(childPath2)) {
|
|
47432
47190
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
47433
47191
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -47436,17 +47194,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47436
47194
|
return result;
|
|
47437
47195
|
}
|
|
47438
47196
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
47439
|
-
const root =
|
|
47197
|
+
const root = path60.resolve(rootPath);
|
|
47440
47198
|
const roots = [];
|
|
47441
47199
|
let walkEntries = 0;
|
|
47442
47200
|
async function walk(dir) {
|
|
47443
47201
|
if (await isGitRepoDirectory(dir)) {
|
|
47444
|
-
roots.push(
|
|
47202
|
+
roots.push(path60.resolve(dir));
|
|
47445
47203
|
return;
|
|
47446
47204
|
}
|
|
47447
47205
|
let entries;
|
|
47448
47206
|
try {
|
|
47449
|
-
entries =
|
|
47207
|
+
entries = fs37.readdirSync(dir, { withFileTypes: true });
|
|
47450
47208
|
} catch {
|
|
47451
47209
|
return;
|
|
47452
47210
|
}
|
|
@@ -47454,7 +47212,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47454
47212
|
await yieldGitDiscoverWork(++walkEntries);
|
|
47455
47213
|
const ent = entries[i];
|
|
47456
47214
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
47457
|
-
await walk(
|
|
47215
|
+
await walk(path60.join(dir, ent.name));
|
|
47458
47216
|
}
|
|
47459
47217
|
}
|
|
47460
47218
|
await walk(root);
|
|
@@ -47470,8 +47228,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47470
47228
|
}
|
|
47471
47229
|
|
|
47472
47230
|
// ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
47473
|
-
import * as
|
|
47474
|
-
import * as
|
|
47231
|
+
import * as fs39 from "node:fs";
|
|
47232
|
+
import * as path62 from "node:path";
|
|
47475
47233
|
|
|
47476
47234
|
// ../bridge/src/git/worktrees/worktree-add.ts
|
|
47477
47235
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -47487,8 +47245,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
47487
47245
|
}
|
|
47488
47246
|
|
|
47489
47247
|
// ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
47490
|
-
import * as
|
|
47491
|
-
import * as
|
|
47248
|
+
import * as fs38 from "node:fs";
|
|
47249
|
+
import * as path61 from "node:path";
|
|
47492
47250
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
47493
47251
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
47494
47252
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -47497,19 +47255,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
47497
47255
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
47498
47256
|
for (let i = 0; i < segments.length; i++) {
|
|
47499
47257
|
const prefix = segments.slice(0, i).join("/");
|
|
47500
|
-
const bridgeDir = prefix ?
|
|
47501
|
-
const destDir = prefix ?
|
|
47258
|
+
const bridgeDir = prefix ? path61.join(bridgeRoot, prefix) : bridgeRoot;
|
|
47259
|
+
const destDir = prefix ? path61.join(scopeDir, prefix) : scopeDir;
|
|
47502
47260
|
for (const fileName of fileNames) {
|
|
47503
47261
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
47504
47262
|
}
|
|
47505
47263
|
}
|
|
47506
47264
|
}
|
|
47507
47265
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
47508
|
-
const src =
|
|
47509
|
-
if (!
|
|
47510
|
-
const dest =
|
|
47266
|
+
const src = path61.join(srcDir, fileName);
|
|
47267
|
+
if (!fs38.existsSync(src)) return;
|
|
47268
|
+
const dest = path61.join(destDir, fileName);
|
|
47511
47269
|
try {
|
|
47512
|
-
|
|
47270
|
+
fs38.copyFileSync(src, dest);
|
|
47513
47271
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
47514
47272
|
} catch (e) {
|
|
47515
47273
|
log2?.(
|
|
@@ -47541,16 +47299,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47541
47299
|
worktreeBaseBranches,
|
|
47542
47300
|
log: log2
|
|
47543
47301
|
} = options;
|
|
47544
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
47545
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
47302
|
+
const repoPathRelativeToBridgeRootRaw = path62.relative(bridgeResolved, repoAbsolutePath);
|
|
47303
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path62.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
47546
47304
|
return null;
|
|
47547
47305
|
}
|
|
47548
47306
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
47549
47307
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
47550
47308
|
);
|
|
47551
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
47309
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path62.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
47552
47310
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
47553
|
-
|
|
47311
|
+
fs39.mkdirSync(path62.dirname(worktreePath), { recursive: true });
|
|
47554
47312
|
copyBridgeFilesAlongWorktreePath({
|
|
47555
47313
|
bridgeRoot: bridgeResolved,
|
|
47556
47314
|
scopeDir,
|
|
@@ -47578,7 +47336,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47578
47336
|
}
|
|
47579
47337
|
|
|
47580
47338
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47581
|
-
import * as
|
|
47339
|
+
import * as path63 from "node:path";
|
|
47582
47340
|
|
|
47583
47341
|
// ../bridge/src/worktrees/worktree-layout-kind.ts
|
|
47584
47342
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -47608,10 +47366,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
47608
47366
|
|
|
47609
47367
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47610
47368
|
function resolveIsolatedScopeDir(options) {
|
|
47611
|
-
const bridgeResolved =
|
|
47369
|
+
const bridgeResolved = path63.resolve(options.bridgeRoot);
|
|
47612
47370
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
47613
|
-
const bridgeKeyDir =
|
|
47614
|
-
const scopeDir =
|
|
47371
|
+
const bridgeKeyDir = path63.join(options.worktreesRootPath, cwdKey);
|
|
47372
|
+
const scopeDir = path63.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
47615
47373
|
return { bridgeResolved, scopeDir };
|
|
47616
47374
|
}
|
|
47617
47375
|
|
|
@@ -47641,7 +47399,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
47641
47399
|
return null;
|
|
47642
47400
|
}
|
|
47643
47401
|
const worktreePaths = [];
|
|
47644
|
-
|
|
47402
|
+
fs40.mkdirSync(scopeDir, { recursive: true });
|
|
47645
47403
|
await forEachWithGitYield(repos, async (repo) => {
|
|
47646
47404
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
47647
47405
|
kind,
|
|
@@ -47713,10 +47471,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
47713
47471
|
}
|
|
47714
47472
|
|
|
47715
47473
|
// ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
47716
|
-
import * as
|
|
47474
|
+
import * as path64 from "node:path";
|
|
47717
47475
|
init_yield_to_event_loop();
|
|
47718
47476
|
async function resolveExplicitSessionParentPath(params) {
|
|
47719
|
-
const resolved =
|
|
47477
|
+
const resolved = path64.resolve(params.parentPathRaw);
|
|
47720
47478
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
47721
47479
|
return resolved;
|
|
47722
47480
|
}
|
|
@@ -47733,7 +47491,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
47733
47491
|
await yieldToEventLoop();
|
|
47734
47492
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
47735
47493
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
47736
|
-
const next =
|
|
47494
|
+
const next = path64.dirname(cur);
|
|
47737
47495
|
if (next === cur) break;
|
|
47738
47496
|
cur = next;
|
|
47739
47497
|
}
|
|
@@ -47894,15 +47652,15 @@ var SessionWorktreeManager = class {
|
|
|
47894
47652
|
};
|
|
47895
47653
|
|
|
47896
47654
|
// ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
47897
|
-
import * as
|
|
47898
|
-
import * as
|
|
47655
|
+
import * as fs41 from "node:fs";
|
|
47656
|
+
import * as path65 from "node:path";
|
|
47899
47657
|
init_yield_to_event_loop();
|
|
47900
47658
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
47901
47659
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
47902
47660
|
const eid = environmentId.trim();
|
|
47903
47661
|
if (!eid) return null;
|
|
47904
47662
|
try {
|
|
47905
|
-
await
|
|
47663
|
+
await fs41.promises.access(worktreesRootPath);
|
|
47906
47664
|
} catch {
|
|
47907
47665
|
return null;
|
|
47908
47666
|
}
|
|
@@ -47911,13 +47669,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47911
47669
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47912
47670
|
const scanState = { entries: 0 };
|
|
47913
47671
|
try {
|
|
47914
|
-
for (const name of await
|
|
47672
|
+
for (const name of await fs41.promises.readdir(worktreesRootPath)) {
|
|
47915
47673
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47916
47674
|
if (name.startsWith(".")) continue;
|
|
47917
|
-
const p =
|
|
47675
|
+
const p = path65.join(worktreesRootPath, name);
|
|
47918
47676
|
let st;
|
|
47919
47677
|
try {
|
|
47920
|
-
st = await
|
|
47678
|
+
st = await fs41.promises.stat(p);
|
|
47921
47679
|
} catch {
|
|
47922
47680
|
continue;
|
|
47923
47681
|
}
|
|
@@ -47931,7 +47689,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47931
47689
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
47932
47690
|
for (const key of keys) {
|
|
47933
47691
|
await yieldToEventLoop();
|
|
47934
|
-
const previewDir =
|
|
47692
|
+
const previewDir = path65.join(worktreesRootPath, key, ...previewDirRel);
|
|
47935
47693
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
47936
47694
|
if (binding) return binding;
|
|
47937
47695
|
}
|
|
@@ -48058,7 +47816,7 @@ var PreviewWorktreeManager = class {
|
|
|
48058
47816
|
};
|
|
48059
47817
|
|
|
48060
47818
|
// ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
48061
|
-
import * as
|
|
47819
|
+
import * as path69 from "node:path";
|
|
48062
47820
|
|
|
48063
47821
|
// ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
|
|
48064
47822
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -48069,8 +47827,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
48069
47827
|
}
|
|
48070
47828
|
|
|
48071
47829
|
// ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
|
|
48072
|
-
import * as
|
|
48073
|
-
import * as
|
|
47830
|
+
import * as fs42 from "node:fs";
|
|
47831
|
+
import * as path66 from "node:path";
|
|
48074
47832
|
|
|
48075
47833
|
// ../bridge/src/git/is-not-a-git-repository-error.ts
|
|
48076
47834
|
function isNotAGitRepositoryError(e) {
|
|
@@ -48132,12 +47890,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48132
47890
|
if (!ap.ok) return ap;
|
|
48133
47891
|
}
|
|
48134
47892
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
48135
|
-
const src =
|
|
48136
|
-
const dst =
|
|
47893
|
+
const src = path66.join(sourceRepoPath, rel);
|
|
47894
|
+
const dst = path66.join(targetRepoPath, rel);
|
|
48137
47895
|
try {
|
|
48138
|
-
if (!
|
|
48139
|
-
|
|
48140
|
-
|
|
47896
|
+
if (!fs42.existsSync(src)) return;
|
|
47897
|
+
fs42.mkdirSync(path66.dirname(dst), { recursive: true });
|
|
47898
|
+
fs42.copyFileSync(src, dst);
|
|
48141
47899
|
} catch (e) {
|
|
48142
47900
|
log2(
|
|
48143
47901
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -48148,14 +47906,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48148
47906
|
}
|
|
48149
47907
|
|
|
48150
47908
|
// ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
48151
|
-
import * as
|
|
47909
|
+
import * as path67 from "node:path";
|
|
48152
47910
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
48153
47911
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
48154
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
47912
|
+
const resolvedSessionParentPath = sessionParentPath ? path67.resolve(sessionParentPath) : null;
|
|
48155
47913
|
let match = null;
|
|
48156
47914
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
48157
47915
|
if (match) return;
|
|
48158
|
-
const resolvedCheckoutPath =
|
|
47916
|
+
const resolvedCheckoutPath = path67.resolve(checkoutPath);
|
|
48159
47917
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
48160
47918
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48161
47919
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -48209,7 +47967,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
48209
47967
|
}
|
|
48210
47968
|
|
|
48211
47969
|
// ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
48212
|
-
import * as
|
|
47970
|
+
import * as path68 from "node:path";
|
|
48213
47971
|
|
|
48214
47972
|
// ../bridge/src/git/branches/create-or-update-branch.ts
|
|
48215
47973
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -48246,19 +48004,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
48246
48004
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
48247
48005
|
const states = [];
|
|
48248
48006
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
48249
|
-
const checkoutPath =
|
|
48007
|
+
const checkoutPath = path68.resolve(sessionCheckout);
|
|
48250
48008
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
48251
48009
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48252
48010
|
checkoutPath,
|
|
48253
48011
|
bridgeRoot,
|
|
48254
|
-
sessionParentPath: sessionParentPath ?
|
|
48012
|
+
sessionParentPath: sessionParentPath ? path68.resolve(sessionParentPath) : null
|
|
48255
48013
|
});
|
|
48256
48014
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
48257
48015
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
48258
48016
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
48259
48017
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
48260
48018
|
checkoutPaths: previewCheckoutPaths,
|
|
48261
|
-
sessionParentPath: previewParentPath ?
|
|
48019
|
+
sessionParentPath: previewParentPath ? path68.resolve(previewParentPath) : null,
|
|
48262
48020
|
bridgeRoot,
|
|
48263
48021
|
repoPathRelativeToWorkspaceRoot
|
|
48264
48022
|
}) : null;
|
|
@@ -48278,7 +48036,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48278
48036
|
const eid = options.environmentId.trim();
|
|
48279
48037
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
48280
48038
|
const deployBranch = previewDeployBranchName(eid);
|
|
48281
|
-
const bridgeRoot =
|
|
48039
|
+
const bridgeRoot = path69.resolve(getBridgeRoot());
|
|
48282
48040
|
await previewWorktreeManager.ensureCached(eid);
|
|
48283
48041
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
48284
48042
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -48318,10 +48076,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48318
48076
|
}
|
|
48319
48077
|
|
|
48320
48078
|
// ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
|
|
48321
|
-
import * as
|
|
48322
|
-
import
|
|
48079
|
+
import * as path70 from "node:path";
|
|
48080
|
+
import os7 from "node:os";
|
|
48323
48081
|
function defaultWorktreesRootPath() {
|
|
48324
|
-
return
|
|
48082
|
+
return path70.join(os7.homedir(), ".buildautomaton", "worktrees");
|
|
48325
48083
|
}
|
|
48326
48084
|
|
|
48327
48085
|
// ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
|
|
@@ -48446,14 +48204,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
48446
48204
|
}
|
|
48447
48205
|
|
|
48448
48206
|
// ../bridge/src/files/list-dir/index.ts
|
|
48449
|
-
import
|
|
48207
|
+
import fs44 from "node:fs";
|
|
48450
48208
|
|
|
48451
48209
|
// ../bridge/src/files/ensure-under-cwd.ts
|
|
48452
|
-
import
|
|
48210
|
+
import path71 from "node:path";
|
|
48453
48211
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
48454
|
-
const normalized =
|
|
48455
|
-
const resolved =
|
|
48456
|
-
if (!resolved.startsWith(cwd +
|
|
48212
|
+
const normalized = path71.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
48213
|
+
const resolved = path71.resolve(cwd, normalized);
|
|
48214
|
+
if (!resolved.startsWith(cwd + path71.sep) && resolved !== cwd) {
|
|
48457
48215
|
return null;
|
|
48458
48216
|
}
|
|
48459
48217
|
return resolved;
|
|
@@ -48466,15 +48224,15 @@ init_yield_to_event_loop();
|
|
|
48466
48224
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
48467
48225
|
|
|
48468
48226
|
// ../bridge/src/files/list-dir/map-dir-entry.ts
|
|
48469
|
-
import
|
|
48470
|
-
import
|
|
48227
|
+
import path72 from "node:path";
|
|
48228
|
+
import fs43 from "node:fs";
|
|
48471
48229
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
48472
|
-
const entryPath =
|
|
48473
|
-
const fullPath =
|
|
48230
|
+
const entryPath = path72.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
48231
|
+
const fullPath = path72.join(resolved, d.name);
|
|
48474
48232
|
let isDir = d.isDirectory();
|
|
48475
48233
|
if (d.isSymbolicLink()) {
|
|
48476
48234
|
try {
|
|
48477
|
-
const targetStat = await
|
|
48235
|
+
const targetStat = await fs43.promises.stat(fullPath);
|
|
48478
48236
|
isDir = targetStat.isDirectory();
|
|
48479
48237
|
} catch {
|
|
48480
48238
|
isDir = false;
|
|
@@ -48504,7 +48262,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48504
48262
|
return { error: "Path is outside working directory" };
|
|
48505
48263
|
}
|
|
48506
48264
|
try {
|
|
48507
|
-
const names = await
|
|
48265
|
+
const names = await fs44.promises.readdir(resolved, { withFileTypes: true });
|
|
48508
48266
|
const entries = [];
|
|
48509
48267
|
for (let i = 0; i < names.length; i++) {
|
|
48510
48268
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -48520,13 +48278,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48520
48278
|
}
|
|
48521
48279
|
|
|
48522
48280
|
// ../bridge/src/git/tree/resolve-repo-abs-path.ts
|
|
48523
|
-
import * as
|
|
48281
|
+
import * as path73 from "node:path";
|
|
48524
48282
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
48525
|
-
const bridgeResolved =
|
|
48283
|
+
const bridgeResolved = path73.resolve(bridgeRoot);
|
|
48526
48284
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
48527
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
48528
|
-
const resolved =
|
|
48529
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
48285
|
+
const repoPath = rel === "" ? bridgeResolved : path73.join(bridgeResolved, rel);
|
|
48286
|
+
const resolved = path73.resolve(repoPath);
|
|
48287
|
+
if (!resolved.startsWith(bridgeResolved + path73.sep) && resolved !== bridgeResolved) {
|
|
48530
48288
|
return null;
|
|
48531
48289
|
}
|
|
48532
48290
|
return resolved;
|
|
@@ -49007,25 +48765,25 @@ async function GET2(ctx) {
|
|
|
49007
48765
|
init_in_flight();
|
|
49008
48766
|
|
|
49009
48767
|
// ../bridge/src/files/read/read-file-async.ts
|
|
49010
|
-
import
|
|
48768
|
+
import fs50 from "node:fs";
|
|
49011
48769
|
init_yield_to_event_loop();
|
|
49012
48770
|
|
|
49013
48771
|
// ../bridge/src/files/read/resolve-file-cache.ts
|
|
49014
|
-
import
|
|
49015
|
-
import
|
|
48772
|
+
import fs45 from "node:fs";
|
|
48773
|
+
import path74 from "node:path";
|
|
49016
48774
|
var RESOLVE_CACHE_MAX = 4096;
|
|
49017
48775
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
49018
48776
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
49019
48777
|
return `${sessionParentPath}\0${relativePath}`;
|
|
49020
48778
|
}
|
|
49021
48779
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
49022
|
-
const parent =
|
|
49023
|
-
const resolved =
|
|
49024
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
48780
|
+
const parent = path74.resolve(sessionParentPath);
|
|
48781
|
+
const resolved = path74.resolve(filePath);
|
|
48782
|
+
return resolved === parent || resolved.startsWith(`${parent}${path74.sep}`);
|
|
49025
48783
|
}
|
|
49026
48784
|
function statMatchesCacheSync(entry) {
|
|
49027
48785
|
try {
|
|
49028
|
-
const stat2 =
|
|
48786
|
+
const stat2 = fs45.statSync(entry.path);
|
|
49029
48787
|
return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
|
|
49030
48788
|
} catch {
|
|
49031
48789
|
return false;
|
|
@@ -49058,7 +48816,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
49058
48816
|
}
|
|
49059
48817
|
|
|
49060
48818
|
// ../bridge/src/files/read/resolve-file-for-read-core.ts
|
|
49061
|
-
import
|
|
48819
|
+
import fs46 from "node:fs";
|
|
49062
48820
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
49063
48821
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
49064
48822
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -49068,13 +48826,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
49068
48826
|
let size;
|
|
49069
48827
|
let mtimeMs;
|
|
49070
48828
|
try {
|
|
49071
|
-
const lstat =
|
|
48829
|
+
const lstat = fs46.lstatSync(resolved);
|
|
49072
48830
|
if (lstat.isSymbolicLink()) {
|
|
49073
|
-
real =
|
|
48831
|
+
real = fs46.realpathSync(resolved);
|
|
49074
48832
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49075
48833
|
return { error: "Path is outside working directory" };
|
|
49076
48834
|
}
|
|
49077
|
-
const stat2 =
|
|
48835
|
+
const stat2 = fs46.statSync(real);
|
|
49078
48836
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49079
48837
|
size = stat2.size;
|
|
49080
48838
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49102,13 +48860,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
49102
48860
|
let size;
|
|
49103
48861
|
let mtimeMs;
|
|
49104
48862
|
try {
|
|
49105
|
-
const lstat = await
|
|
48863
|
+
const lstat = await fs46.promises.lstat(resolved);
|
|
49106
48864
|
if (lstat.isSymbolicLink()) {
|
|
49107
|
-
real = await
|
|
48865
|
+
real = await fs46.promises.realpath(resolved);
|
|
49108
48866
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49109
48867
|
return { error: "Path is outside working directory" };
|
|
49110
48868
|
}
|
|
49111
|
-
const stat2 = await
|
|
48869
|
+
const stat2 = await fs46.promises.stat(real);
|
|
49112
48870
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49113
48871
|
size = stat2.size;
|
|
49114
48872
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49157,7 +48915,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
49157
48915
|
|
|
49158
48916
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49159
48917
|
init_yield_to_event_loop();
|
|
49160
|
-
import
|
|
48918
|
+
import fs47 from "node:fs";
|
|
49161
48919
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
49162
48920
|
|
|
49163
48921
|
// ../bridge/src/files/read/read-file-range-line-zero.ts
|
|
@@ -49271,8 +49029,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
49271
49029
|
|
|
49272
49030
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49273
49031
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
49274
|
-
const fileSize = fileSizeIn ?? (await
|
|
49275
|
-
const fd = await
|
|
49032
|
+
const fileSize = fileSizeIn ?? (await fs47.promises.stat(filePath)).size;
|
|
49033
|
+
const fd = await fs47.promises.open(filePath, "r");
|
|
49276
49034
|
const bufSize = 64 * 1024;
|
|
49277
49035
|
const buf = Buffer.alloc(bufSize);
|
|
49278
49036
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -49373,7 +49131,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
49373
49131
|
}
|
|
49374
49132
|
|
|
49375
49133
|
// ../bridge/src/files/read/read-small-file-range-async.ts
|
|
49376
|
-
import
|
|
49134
|
+
import fs48 from "node:fs";
|
|
49377
49135
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
49378
49136
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
49379
49137
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -49403,7 +49161,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
49403
49161
|
};
|
|
49404
49162
|
}
|
|
49405
49163
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
49406
|
-
const raw =
|
|
49164
|
+
const raw = fs48.readFileSync(filePath, "utf8");
|
|
49407
49165
|
const lines = raw.split(/\r?\n/);
|
|
49408
49166
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49409
49167
|
}
|
|
@@ -49411,28 +49169,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
49411
49169
|
if (isMainThread5) {
|
|
49412
49170
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
49413
49171
|
}
|
|
49414
|
-
const raw = await
|
|
49172
|
+
const raw = await fs48.promises.readFile(filePath, "utf8");
|
|
49415
49173
|
const lines = raw.split(/\r?\n/);
|
|
49416
49174
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49417
49175
|
}
|
|
49418
49176
|
|
|
49419
49177
|
// ../bridge/src/files/read/read-file-buffer-full-async.ts
|
|
49420
49178
|
init_yield_to_event_loop();
|
|
49421
|
-
import
|
|
49179
|
+
import fs49 from "node:fs";
|
|
49422
49180
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
49423
49181
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
49424
49182
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
49425
49183
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
49426
49184
|
if (isMainThread6) {
|
|
49427
|
-
const size2 = knownSize ??
|
|
49185
|
+
const size2 = knownSize ?? fs49.statSync(filePath).size;
|
|
49428
49186
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
49429
49187
|
await yieldToEventLoop();
|
|
49430
|
-
const buffer =
|
|
49188
|
+
const buffer = fs49.readFileSync(filePath);
|
|
49431
49189
|
return { buffer, size: buffer.length };
|
|
49432
49190
|
}
|
|
49433
49191
|
}
|
|
49434
|
-
const size = knownSize ?? (await
|
|
49435
|
-
const fd = await
|
|
49192
|
+
const size = knownSize ?? (await fs49.promises.stat(filePath)).size;
|
|
49193
|
+
const fd = await fs49.promises.open(filePath, "r");
|
|
49436
49194
|
const chunks = [];
|
|
49437
49195
|
let position = 0;
|
|
49438
49196
|
let bytesSinceYield = 0;
|
|
@@ -49535,7 +49293,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
49535
49293
|
}
|
|
49536
49294
|
if (hasRange) {
|
|
49537
49295
|
if (fileSize == null) {
|
|
49538
|
-
const stat2 = await
|
|
49296
|
+
const stat2 = await fs50.promises.stat(resolvedPath);
|
|
49539
49297
|
fileSize = stat2.size;
|
|
49540
49298
|
}
|
|
49541
49299
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -49833,12 +49591,12 @@ function parseOptionalInt2(raw) {
|
|
|
49833
49591
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
49834
49592
|
}
|
|
49835
49593
|
function parseCodeNavParams(url2) {
|
|
49836
|
-
const
|
|
49594
|
+
const path83 = url2.searchParams.get("path") ?? "";
|
|
49837
49595
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
49838
49596
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
49839
49597
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
49840
49598
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
49841
|
-
return { path:
|
|
49599
|
+
return { path: path83, op, line, column };
|
|
49842
49600
|
}
|
|
49843
49601
|
function parseCodeNavPath(url2) {
|
|
49844
49602
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -50771,19 +50529,34 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
50771
50529
|
handleBridgeAgentConfig(msg, deps);
|
|
50772
50530
|
};
|
|
50773
50531
|
|
|
50774
|
-
// ../bridge/src/prompt-
|
|
50532
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
50775
50533
|
init_yield_to_event_loop();
|
|
50776
50534
|
|
|
50777
|
-
// ../bridge/src/prompt-
|
|
50535
|
+
// ../bridge/src/prompt-queue/snapshots/types.ts
|
|
50536
|
+
function parseServerTurnSnapshot(raw) {
|
|
50537
|
+
if (!raw || typeof raw !== "object") return null;
|
|
50538
|
+
const o = raw;
|
|
50539
|
+
const turnId = typeof o.turnId === "string" ? o.turnId : "";
|
|
50540
|
+
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
50541
|
+
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
50542
|
+
const serverState = o.serverState ?? o.bridgeServerState;
|
|
50543
|
+
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
50544
|
+
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
50545
|
+
if (!turnId || !sessionId) return null;
|
|
50546
|
+
return { turnId, sessionId, turnOrd, serverState, lastCliState, payload };
|
|
50547
|
+
}
|
|
50548
|
+
function promptQueueSnapshotEntries(queues) {
|
|
50549
|
+
const entries = [];
|
|
50550
|
+
for (const [queueKey, rawTurns] of Object.entries(queues)) {
|
|
50551
|
+
if (!Array.isArray(rawTurns)) continue;
|
|
50552
|
+
const turns = rawTurns.map(parseServerTurnSnapshot).filter((t) => t !== null);
|
|
50553
|
+
entries.push([queueKey, turns]);
|
|
50554
|
+
}
|
|
50555
|
+
return entries;
|
|
50556
|
+
}
|
|
50557
|
+
|
|
50558
|
+
// ../bridge/src/prompt-queue/persistence/read-persisted-queue.ts
|
|
50778
50559
|
init_cli_database();
|
|
50779
|
-
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
50780
|
-
"queued",
|
|
50781
|
-
"requeued",
|
|
50782
|
-
"requeued_with_revert",
|
|
50783
|
-
"cancel_requested",
|
|
50784
|
-
"stopping",
|
|
50785
|
-
"discarded"
|
|
50786
|
-
]);
|
|
50787
50560
|
async function readPersistedQueue(queueKey) {
|
|
50788
50561
|
return withCliSqlite((db) => {
|
|
50789
50562
|
const row = db.get("SELECT queue_key, updated_at, turns_json FROM prompt_queue WHERE queue_key = ?", [
|
|
@@ -50799,6 +50572,9 @@ async function readPersistedQueue(queueKey) {
|
|
|
50799
50572
|
}
|
|
50800
50573
|
});
|
|
50801
50574
|
}
|
|
50575
|
+
|
|
50576
|
+
// ../bridge/src/prompt-queue/persistence/write-persisted-queue.ts
|
|
50577
|
+
init_cli_database();
|
|
50802
50578
|
async function writePersistedQueue(file2) {
|
|
50803
50579
|
await withCliSqlite((db) => {
|
|
50804
50580
|
db.run(
|
|
@@ -50808,36 +50584,103 @@ async function writePersistedQueue(file2) {
|
|
|
50808
50584
|
);
|
|
50809
50585
|
});
|
|
50810
50586
|
}
|
|
50811
|
-
|
|
50812
|
-
|
|
50587
|
+
|
|
50588
|
+
// ../bridge/src/prompt-queue/reconciliation/merge-turns.ts
|
|
50589
|
+
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
50590
|
+
"queued",
|
|
50591
|
+
"requeued",
|
|
50592
|
+
"requeued_with_revert",
|
|
50593
|
+
"cancel_requested",
|
|
50594
|
+
"stopping",
|
|
50595
|
+
"discarded"
|
|
50596
|
+
]);
|
|
50597
|
+
function mergeServerSnapshotWithLocal(queueKey, serverTurns, prev) {
|
|
50813
50598
|
const turns = [];
|
|
50814
|
-
for (const
|
|
50815
|
-
if (!
|
|
50816
|
-
const
|
|
50817
|
-
const
|
|
50818
|
-
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
50819
|
-
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
50820
|
-
const bridgeServerState = o.serverState ?? o.bridgeServerState;
|
|
50821
|
-
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
50822
|
-
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
50823
|
-
if (!turnId || !sessionId) continue;
|
|
50824
|
-
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(bridgeServerState))) continue;
|
|
50825
|
-
const old = prev?.turns.find((t) => t.turnId === turnId);
|
|
50826
|
-
const mergedCli = old?.lastCliState === "running" && lastCliState == null ? "running" : lastCliState;
|
|
50599
|
+
for (const s of serverTurns) {
|
|
50600
|
+
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(s.serverState))) continue;
|
|
50601
|
+
const old = prev?.turns.find((t) => t.turnId === s.turnId);
|
|
50602
|
+
const mergedCli = old?.lastCliState === "running" && s.lastCliState == null ? "running" : s.lastCliState;
|
|
50827
50603
|
turns.push({
|
|
50828
|
-
turnId,
|
|
50829
|
-
sessionId,
|
|
50830
|
-
turnOrd,
|
|
50831
|
-
bridgeServerState,
|
|
50604
|
+
turnId: s.turnId,
|
|
50605
|
+
sessionId: s.sessionId,
|
|
50606
|
+
turnOrd: s.turnOrd,
|
|
50607
|
+
bridgeServerState: s.serverState,
|
|
50832
50608
|
lastCliState: mergedCli,
|
|
50833
|
-
payload
|
|
50609
|
+
payload: s.payload
|
|
50834
50610
|
});
|
|
50835
50611
|
}
|
|
50836
50612
|
turns.sort((a, b) => a.turnOrd - b.turnOrd);
|
|
50837
50613
|
return { queueKey, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
50838
50614
|
}
|
|
50615
|
+
function hasLiveRunningTurn(turns, isLiveRun) {
|
|
50616
|
+
return turns.some((t) => t.lastCliState === "running" && isLiveRun(t.turnId));
|
|
50617
|
+
}
|
|
50618
|
+
function isTerminalCliState(state) {
|
|
50619
|
+
return state === "stopped" || state === "failed" || state === "cancelled";
|
|
50620
|
+
}
|
|
50621
|
+
function isSkippedServerState(state) {
|
|
50622
|
+
return state === "discarded" || state === "stopping" || state === "cancel_requested";
|
|
50623
|
+
}
|
|
50839
50624
|
|
|
50840
|
-
// ../bridge/src/prompt-
|
|
50625
|
+
// ../bridge/src/prompt-queue/reconciliation/pick-actions.ts
|
|
50626
|
+
function pickNextRunnableTurn(turns) {
|
|
50627
|
+
for (const t of turns) {
|
|
50628
|
+
if (isSkippedServerState(t.bridgeServerState)) continue;
|
|
50629
|
+
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
50630
|
+
if (isTerminalCliState(t.lastCliState) || t.lastCliState === "running") continue;
|
|
50631
|
+
return t;
|
|
50632
|
+
}
|
|
50633
|
+
return null;
|
|
50634
|
+
}
|
|
50635
|
+
function normalizeStaleRunning(turns, isLiveRun) {
|
|
50636
|
+
return turns.map((t) => {
|
|
50637
|
+
if (t.lastCliState !== "running") return t;
|
|
50638
|
+
if (isLiveRun(t.turnId)) return t;
|
|
50639
|
+
if (t.bridgeServerState === "cancel_requested") return t;
|
|
50640
|
+
return { ...t, lastCliState: null };
|
|
50641
|
+
});
|
|
50642
|
+
}
|
|
50643
|
+
function reconcileQueueActions(queueKey, turns, isLiveRun) {
|
|
50644
|
+
const actions = [];
|
|
50645
|
+
for (const t of turns) {
|
|
50646
|
+
if (t.bridgeServerState === "cancel_requested" && t.lastCliState === "running" && isLiveRun(t.turnId)) {
|
|
50647
|
+
actions.push({ type: "cancel_run", queueKey, turnId: t.turnId });
|
|
50648
|
+
}
|
|
50649
|
+
}
|
|
50650
|
+
for (const t of turns) {
|
|
50651
|
+
if (t.bridgeServerState !== "cancel_requested") continue;
|
|
50652
|
+
if (t.lastCliState !== "running") continue;
|
|
50653
|
+
if (isLiveRun(t.turnId)) continue;
|
|
50654
|
+
actions.push({ type: "finalize_stale", queueKey, turnId: t.turnId, cliState: "cancelled" });
|
|
50655
|
+
}
|
|
50656
|
+
const normalized = normalizeStaleRunning(turns, isLiveRun);
|
|
50657
|
+
if (hasLiveRunningTurn(normalized, isLiveRun)) return actions;
|
|
50658
|
+
const next = pickNextRunnableTurn(normalized);
|
|
50659
|
+
if (next) {
|
|
50660
|
+
actions.push({ type: "start_run", queueKey, turn: next });
|
|
50661
|
+
actions.push({ type: "report_cli_state", queueKey, turnId: next.turnId, cliState: "running" });
|
|
50662
|
+
}
|
|
50663
|
+
return actions;
|
|
50664
|
+
}
|
|
50665
|
+
function applyStaleRunningNormalization(turns, isLiveRun) {
|
|
50666
|
+
return normalizeStaleRunning(turns, isLiveRun);
|
|
50667
|
+
}
|
|
50668
|
+
|
|
50669
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
50670
|
+
init_yield_to_event_loop();
|
|
50671
|
+
|
|
50672
|
+
// ../bridge/src/prompt-queue/runner/client-report.ts
|
|
50673
|
+
function sendPromptQueueClientReport(ws, queues) {
|
|
50674
|
+
if (!ws) return false;
|
|
50675
|
+
const wireQueues = {};
|
|
50676
|
+
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
50677
|
+
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
50678
|
+
}
|
|
50679
|
+
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
50680
|
+
return true;
|
|
50681
|
+
}
|
|
50682
|
+
|
|
50683
|
+
// ../bridge/src/prompt-queue/runner/dispatch-local-prompt.ts
|
|
50841
50684
|
function dispatchLocalPrompt(next, deps) {
|
|
50842
50685
|
const pl = next.payload;
|
|
50843
50686
|
const rawParent = pl["sessionParent"];
|
|
@@ -50864,20 +50707,17 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
50864
50707
|
handleBridgePrompt(msg, deps);
|
|
50865
50708
|
}
|
|
50866
50709
|
|
|
50867
|
-
// ../bridge/src/prompt-
|
|
50710
|
+
// ../bridge/src/prompt-queue/runner/run-id-queue-key-map.ts
|
|
50868
50711
|
var runIdToQueueKey = /* @__PURE__ */ new Map();
|
|
50869
|
-
var locallyDispatchedRunIds = /* @__PURE__ */ new Set();
|
|
50870
50712
|
function getRunIdQueueKey(runId) {
|
|
50871
50713
|
return runIdToQueueKey.get(runId);
|
|
50872
50714
|
}
|
|
50873
50715
|
function setRunIdQueueKey(runId, queueKey) {
|
|
50874
50716
|
runIdToQueueKey.set(runId, queueKey);
|
|
50875
|
-
locallyDispatchedRunIds.add(runId);
|
|
50876
50717
|
}
|
|
50877
50718
|
function deleteRunIdQueueKey(runId) {
|
|
50878
50719
|
const queueKey = runIdToQueueKey.get(runId);
|
|
50879
50720
|
runIdToQueueKey.delete(runId);
|
|
50880
|
-
locallyDispatchedRunIds.delete(runId);
|
|
50881
50721
|
return queueKey;
|
|
50882
50722
|
}
|
|
50883
50723
|
function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
@@ -50886,33 +50726,7 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
|
50886
50726
|
}
|
|
50887
50727
|
}
|
|
50888
50728
|
|
|
50889
|
-
// ../bridge/src/prompt-
|
|
50890
|
-
async function dispatchStartedPromptQueueRuns(entries, started, deps) {
|
|
50891
|
-
for (const [queueKey] of entries) {
|
|
50892
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50893
|
-
const running2 = file2?.turns.find((turn) => turn.lastCliState === "running");
|
|
50894
|
-
if (running2 && started.has(running2.turnId) && getRunIdQueueKey(running2.turnId) === queueKey) {
|
|
50895
|
-
dispatchLocalPrompt(running2, deps);
|
|
50896
|
-
}
|
|
50897
|
-
await yieldToEventLoop();
|
|
50898
|
-
}
|
|
50899
|
-
}
|
|
50900
|
-
|
|
50901
|
-
// ../bridge/src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
50902
|
-
init_yield_to_event_loop();
|
|
50903
|
-
|
|
50904
|
-
// ../bridge/src/prompt-turn-queue/client-report.ts
|
|
50905
|
-
function sendPromptQueueClientReport(ws, queues) {
|
|
50906
|
-
if (!ws) return false;
|
|
50907
|
-
const wireQueues = {};
|
|
50908
|
-
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
50909
|
-
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
50910
|
-
}
|
|
50911
|
-
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
50912
|
-
return true;
|
|
50913
|
-
}
|
|
50914
|
-
|
|
50915
|
-
// ../bridge/src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
50729
|
+
// ../bridge/src/prompt-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
50916
50730
|
async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
50917
50731
|
if (!runId) return false;
|
|
50918
50732
|
const queueKey = deleteRunIdQueueKey(runId);
|
|
@@ -50927,79 +50741,19 @@ async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
|
50927
50741
|
return true;
|
|
50928
50742
|
}
|
|
50929
50743
|
|
|
50930
|
-
// ../bridge/src/prompt-
|
|
50931
|
-
|
|
50932
|
-
for (const [queueKey] of entries) {
|
|
50933
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50934
|
-
const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
|
|
50935
|
-
if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey) {
|
|
50936
|
-
await yieldToEventLoop();
|
|
50937
|
-
continue;
|
|
50938
|
-
}
|
|
50939
|
-
deps.log(`[Queue] Cancellation request received for turn ${turn.turnId.slice(0, 8)}\u2026`);
|
|
50940
|
-
if (await deps.acpManager.cancelRun(turn.turnId)) {
|
|
50941
|
-
await yieldToEventLoop();
|
|
50942
|
-
continue;
|
|
50943
|
-
}
|
|
50944
|
-
deps.log(`[Queue] No local ACP run remains for ${turn.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
50945
|
-
await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
|
|
50946
|
-
await yieldToEventLoop();
|
|
50947
|
-
}
|
|
50948
|
-
}
|
|
50949
|
-
|
|
50950
|
-
// ../bridge/src/prompt-turn-queue/runner/persist-prompt-queue-snapshot.ts
|
|
50951
|
-
init_yield_to_event_loop();
|
|
50952
|
-
async function persistPromptQueueSnapshot(entries) {
|
|
50953
|
-
for (const [queueKey, serverTurns] of entries) {
|
|
50954
|
-
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
50955
|
-
await writePersistedQueue(file2);
|
|
50956
|
-
await yieldToEventLoop();
|
|
50957
|
-
}
|
|
50958
|
-
for (const [queueKey] of entries) {
|
|
50959
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50960
|
-
if (file2) syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
50961
|
-
await yieldToEventLoop();
|
|
50962
|
-
}
|
|
50963
|
-
}
|
|
50964
|
-
|
|
50965
|
-
// ../bridge/src/prompt-turn-queue/runner/prompt-queue-snapshot-types.ts
|
|
50966
|
-
function promptQueueSnapshotEntries(queues) {
|
|
50967
|
-
return Object.entries(queues).filter((entry) => Array.isArray(entry[1]));
|
|
50968
|
-
}
|
|
50969
|
-
|
|
50970
|
-
// ../bridge/src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
50971
|
-
init_yield_to_event_loop();
|
|
50972
|
-
|
|
50973
|
-
// ../bridge/src/prompt-turn-queue/runner/queue-selection.ts
|
|
50974
|
-
function pickNextRunnableTurn(turns) {
|
|
50975
|
-
for (const t of turns) {
|
|
50976
|
-
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
50977
|
-
if (t.bridgeServerState === "cancel_requested") continue;
|
|
50978
|
-
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
50979
|
-
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
50980
|
-
continue;
|
|
50981
|
-
}
|
|
50982
|
-
return t;
|
|
50983
|
-
}
|
|
50984
|
-
return null;
|
|
50985
|
-
}
|
|
50986
|
-
function hasRunningTurn(turns) {
|
|
50987
|
-
return turns.some((t) => t.lastCliState === "running");
|
|
50988
|
-
}
|
|
50989
|
-
|
|
50990
|
-
// ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
50991
|
-
import fs54 from "node:fs";
|
|
50744
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
50745
|
+
import fs53 from "node:fs";
|
|
50992
50746
|
|
|
50993
50747
|
// ../bridge/src/git/snapshot/capture.ts
|
|
50994
|
-
import * as
|
|
50995
|
-
import * as
|
|
50748
|
+
import * as fs52 from "node:fs";
|
|
50749
|
+
import * as path76 from "node:path";
|
|
50996
50750
|
|
|
50997
50751
|
// ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
50998
|
-
import * as
|
|
50752
|
+
import * as fs51 from "node:fs";
|
|
50999
50753
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
51000
50754
|
let data;
|
|
51001
50755
|
try {
|
|
51002
|
-
data = JSON.parse(
|
|
50756
|
+
data = JSON.parse(fs51.readFileSync(filePath, "utf8"));
|
|
51003
50757
|
} catch (error51) {
|
|
51004
50758
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
51005
50759
|
}
|
|
@@ -51028,18 +50782,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
51028
50782
|
}
|
|
51029
50783
|
|
|
51030
50784
|
// ../bridge/src/git/snapshot/resolve-repo-roots.ts
|
|
51031
|
-
import * as
|
|
50785
|
+
import * as path75 from "node:path";
|
|
51032
50786
|
async function resolveSnapshotRepoRoots(options) {
|
|
51033
50787
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
51034
50788
|
if (worktreePaths?.length) {
|
|
51035
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
50789
|
+
const paths = [...new Set(worktreePaths.map((p) => path75.resolve(p)))];
|
|
51036
50790
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
51037
50791
|
}
|
|
51038
50792
|
try {
|
|
51039
50793
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
51040
50794
|
const sid = sessionId?.trim();
|
|
51041
50795
|
if (!sid) return roots;
|
|
51042
|
-
const sessionRoots = roots.filter((root) =>
|
|
50796
|
+
const sessionRoots = roots.filter((root) => path75.basename(root) === sid);
|
|
51043
50797
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
51044
50798
|
} catch (error51) {
|
|
51045
50799
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -51061,7 +50815,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51061
50815
|
});
|
|
51062
50816
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
51063
50817
|
try {
|
|
51064
|
-
|
|
50818
|
+
fs52.mkdirSync(dir, { recursive: true });
|
|
51065
50819
|
} catch (e) {
|
|
51066
50820
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51067
50821
|
}
|
|
@@ -51070,9 +50824,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51070
50824
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51071
50825
|
repos
|
|
51072
50826
|
};
|
|
51073
|
-
const filePath =
|
|
50827
|
+
const filePath = path76.join(dir, `${runId}.json`);
|
|
51074
50828
|
try {
|
|
51075
|
-
|
|
50829
|
+
fs52.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
51076
50830
|
} catch (e) {
|
|
51077
50831
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51078
50832
|
}
|
|
@@ -51083,7 +50837,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51083
50837
|
return { ok: true, filePath, repos };
|
|
51084
50838
|
}
|
|
51085
50839
|
|
|
51086
|
-
// ../bridge/src/prompt-
|
|
50840
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
51087
50841
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
51088
50842
|
if (next.bridgeServerState !== "requeued_with_revert") return true;
|
|
51089
50843
|
const sid = next.sessionId;
|
|
@@ -51092,7 +50846,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51092
50846
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
51093
50847
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
51094
50848
|
try {
|
|
51095
|
-
await
|
|
50849
|
+
await fs53.promises.access(file2, fs53.constants.F_OK);
|
|
51096
50850
|
} catch {
|
|
51097
50851
|
deps.log(
|
|
51098
50852
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -51106,49 +50860,120 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51106
50860
|
return res.ok;
|
|
51107
50861
|
}
|
|
51108
50862
|
|
|
51109
|
-
// ../bridge/src/prompt-
|
|
51110
|
-
async function
|
|
51111
|
-
const report = {};
|
|
50863
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
50864
|
+
async function executePromptQueueActions(actions, deps) {
|
|
51112
50865
|
const started = /* @__PURE__ */ new Set();
|
|
51113
|
-
|
|
51114
|
-
|
|
51115
|
-
if (
|
|
51116
|
-
|
|
51117
|
-
|
|
51118
|
-
|
|
51119
|
-
|
|
51120
|
-
await
|
|
51121
|
-
sendPromptQueueClientReport(deps.getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
50866
|
+
const report = {};
|
|
50867
|
+
for (const action of actions) {
|
|
50868
|
+
if (action.type === "cancel_run") {
|
|
50869
|
+
if (getRunIdQueueKey(action.turnId) !== action.queueKey) continue;
|
|
50870
|
+
deps.log(`[Queue] Cancellation request received for turn ${action.turnId.slice(0, 8)}\u2026`);
|
|
50871
|
+
if (await deps.acpManager.cancelRun(action.turnId)) continue;
|
|
50872
|
+
deps.log(`[Queue] No local ACP run remains for ${action.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
50873
|
+
await finalizePromptTurnOnBridge(deps.getWs, action.turnId, false, { terminalCliState: "cancelled" });
|
|
51122
50874
|
continue;
|
|
51123
50875
|
}
|
|
51124
|
-
|
|
51125
|
-
|
|
51126
|
-
|
|
51127
|
-
|
|
51128
|
-
|
|
50876
|
+
if (action.type === "finalize_stale") {
|
|
50877
|
+
await applyCliState(action.queueKey, action.turnId, action.cliState);
|
|
50878
|
+
deleteRunIdQueueKey(action.turnId);
|
|
50879
|
+
report[action.queueKey] = [{ turnId: action.turnId, cliState: action.cliState }];
|
|
50880
|
+
continue;
|
|
50881
|
+
}
|
|
50882
|
+
if (action.type === "start_run") {
|
|
50883
|
+
const ok = await markTurnRunning(action.queueKey, action.turn, deps);
|
|
50884
|
+
if (!ok) {
|
|
50885
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "failed" }];
|
|
50886
|
+
continue;
|
|
50887
|
+
}
|
|
50888
|
+
started.add(action.turn.turnId);
|
|
50889
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "running" }];
|
|
50890
|
+
}
|
|
51129
50891
|
await yieldToEventLoop();
|
|
51130
50892
|
}
|
|
51131
50893
|
if (Object.keys(report).length) sendPromptQueueClientReport(deps.getWs(), report);
|
|
50894
|
+
for (const runId of started) {
|
|
50895
|
+
const queueKey = getRunIdQueueKey(runId);
|
|
50896
|
+
if (!queueKey) continue;
|
|
50897
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50898
|
+
const turn = file2?.turns.find((t) => t.turnId === runId);
|
|
50899
|
+
if (turn) dispatchLocalPrompt(turn, deps);
|
|
50900
|
+
await yieldToEventLoop();
|
|
50901
|
+
}
|
|
51132
50902
|
return started;
|
|
51133
50903
|
}
|
|
50904
|
+
async function markTurnRunning(queueKey, turn, deps) {
|
|
50905
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50906
|
+
if (!file2) return false;
|
|
50907
|
+
const row = file2.turns.find((t) => t.turnId === turn.turnId);
|
|
50908
|
+
if (!row) return false;
|
|
50909
|
+
if (!await runLocalRevertBeforeQueuedPrompt(row, deps)) {
|
|
50910
|
+
row.lastCliState = "failed";
|
|
50911
|
+
await writePersistedQueue(file2);
|
|
50912
|
+
return false;
|
|
50913
|
+
}
|
|
50914
|
+
row.lastCliState = "running";
|
|
50915
|
+
await writePersistedQueue(file2);
|
|
50916
|
+
setRunIdQueueKey(row.turnId, queueKey);
|
|
50917
|
+
return true;
|
|
50918
|
+
}
|
|
50919
|
+
async function applyCliState(queueKey, turnId, cliState) {
|
|
50920
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50921
|
+
if (!file2) return;
|
|
50922
|
+
const turn = file2.turns.find((t) => t.turnId === turnId);
|
|
50923
|
+
if (!turn) return;
|
|
50924
|
+
turn.lastCliState = cliState;
|
|
50925
|
+
await writePersistedQueue(file2);
|
|
50926
|
+
}
|
|
51134
50927
|
|
|
51135
|
-
// ../bridge/src/prompt-
|
|
50928
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
51136
50929
|
var SLOW_QUEUE_SYNC_MS = 2e3;
|
|
50930
|
+
async function persistAndReconcileQueue(queueKey, serverTurns, deps) {
|
|
50931
|
+
const prev = await readPersistedQueue(queueKey);
|
|
50932
|
+
const merged = mergeServerSnapshotWithLocal(queueKey, serverTurns, prev);
|
|
50933
|
+
const liveCheck = (runId) => deps.acpManager.isRegisteredRun(runId);
|
|
50934
|
+
const actions = reconcileQueueActions(queueKey, merged.turns, liveCheck);
|
|
50935
|
+
merged.turns = applyStaleRunningNormalization(merged.turns, liveCheck);
|
|
50936
|
+
await writePersistedQueue(merged);
|
|
50937
|
+
syncRunningTurnQueueKeys(merged.turns, queueKey);
|
|
50938
|
+
return actions;
|
|
50939
|
+
}
|
|
51137
50940
|
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
51138
50941
|
const raw = msg.queues;
|
|
51139
50942
|
if (!raw || typeof raw !== "object") return;
|
|
51140
50943
|
const startedAt = Date.now();
|
|
51141
50944
|
const entries = promptQueueSnapshotEntries(raw);
|
|
51142
|
-
|
|
51143
|
-
|
|
51144
|
-
|
|
51145
|
-
|
|
50945
|
+
const allActions = [];
|
|
50946
|
+
for (const [queueKey, serverTurns] of entries) {
|
|
50947
|
+
allActions.push(...await persistAndReconcileQueue(queueKey, serverTurns, deps));
|
|
50948
|
+
await yieldToEventLoop();
|
|
50949
|
+
}
|
|
50950
|
+
await executePromptQueueActions(allActions, deps);
|
|
51146
50951
|
const durationMs = Date.now() - startedAt;
|
|
51147
50952
|
if (durationMs >= SLOW_QUEUE_SYNC_MS) {
|
|
51148
50953
|
deps.log(`[Queue] Queue state sync and dispatch took ${durationMs}ms.`);
|
|
51149
50954
|
}
|
|
51150
50955
|
}
|
|
51151
50956
|
|
|
50957
|
+
// ../bridge/src/prompt-queue/runner/serial-prompt-queue-work.ts
|
|
50958
|
+
var running = false;
|
|
50959
|
+
var latestWork = null;
|
|
50960
|
+
async function drain() {
|
|
50961
|
+
while (latestWork) {
|
|
50962
|
+
const work = latestWork;
|
|
50963
|
+
latestWork = null;
|
|
50964
|
+
await work();
|
|
50965
|
+
}
|
|
50966
|
+
}
|
|
50967
|
+
function enqueueLatestPromptQueueStateWork(work) {
|
|
50968
|
+
latestWork = work;
|
|
50969
|
+
if (running) return;
|
|
50970
|
+
running = true;
|
|
50971
|
+
void drain().finally(() => {
|
|
50972
|
+
running = false;
|
|
50973
|
+
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
50974
|
+
});
|
|
50975
|
+
}
|
|
50976
|
+
|
|
51152
50977
|
// ../bridge/src/agents/acp/from-bridge/pending-prompt-results.ts
|
|
51153
50978
|
var pending = [];
|
|
51154
50979
|
function enqueuePendingPromptResult(message) {
|
|
@@ -51468,26 +51293,6 @@ var handlePromptMessage = (msg, deps) => {
|
|
|
51468
51293
|
handleBridgePrompt(msg, deps);
|
|
51469
51294
|
};
|
|
51470
51295
|
|
|
51471
|
-
// ../bridge/src/prompt-turn-queue/runner/serial-prompt-queue-work.ts
|
|
51472
|
-
var running = false;
|
|
51473
|
-
var latestWork = null;
|
|
51474
|
-
async function drain() {
|
|
51475
|
-
while (latestWork) {
|
|
51476
|
-
const work = latestWork;
|
|
51477
|
-
latestWork = null;
|
|
51478
|
-
await work();
|
|
51479
|
-
}
|
|
51480
|
-
}
|
|
51481
|
-
function enqueueLatestPromptQueueStateWork(work) {
|
|
51482
|
-
latestWork = work;
|
|
51483
|
-
if (running) return;
|
|
51484
|
-
running = true;
|
|
51485
|
-
void drain().finally(() => {
|
|
51486
|
-
running = false;
|
|
51487
|
-
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
51488
|
-
});
|
|
51489
|
-
}
|
|
51490
|
-
|
|
51491
51296
|
// ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
|
|
51492
51297
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
51493
51298
|
enqueueLatestPromptQueueStateWork(async () => {
|
|
@@ -51750,7 +51555,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
51750
51555
|
};
|
|
51751
51556
|
|
|
51752
51557
|
// ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
|
|
51753
|
-
import * as
|
|
51558
|
+
import * as fs54 from "node:fs";
|
|
51754
51559
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
51755
51560
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
51756
51561
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -51763,7 +51568,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
51763
51568
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
51764
51569
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
51765
51570
|
try {
|
|
51766
|
-
await
|
|
51571
|
+
await fs54.promises.access(file2, fs54.constants.F_OK);
|
|
51767
51572
|
} catch {
|
|
51768
51573
|
sendWsMessage(s, {
|
|
51769
51574
|
type: "revert_turn_snapshot_result",
|
|
@@ -51877,13 +51682,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
51877
51682
|
|
|
51878
51683
|
// ../bridge/src/files/handle-file-browser-search.ts
|
|
51879
51684
|
init_yield_to_event_loop();
|
|
51880
|
-
import
|
|
51685
|
+
import path77 from "node:path";
|
|
51881
51686
|
var SEARCH_LIMIT = 100;
|
|
51882
51687
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
51883
51688
|
void (async () => {
|
|
51884
51689
|
await yieldToEventLoop();
|
|
51885
51690
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
51886
|
-
const sessionParentPath =
|
|
51691
|
+
const sessionParentPath = path77.resolve(
|
|
51887
51692
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
51888
51693
|
);
|
|
51889
51694
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -51981,7 +51786,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
51981
51786
|
}
|
|
51982
51787
|
|
|
51983
51788
|
// ../bridge/src/git/bridge-git-context.ts
|
|
51984
|
-
import * as
|
|
51789
|
+
import * as path78 from "node:path";
|
|
51985
51790
|
init_yield_to_event_loop();
|
|
51986
51791
|
|
|
51987
51792
|
// ../bridge/src/git/branches/get-current-branch.ts
|
|
@@ -52049,12 +51854,12 @@ function listPendingCheckouts() {
|
|
|
52049
51854
|
// ../bridge/src/git/bridge-git-context.ts
|
|
52050
51855
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
52051
51856
|
if (relPath === "." || relPath === "") {
|
|
52052
|
-
return
|
|
51857
|
+
return path78.basename(path78.resolve(bridgeRoot)) || "repo";
|
|
52053
51858
|
}
|
|
52054
|
-
return
|
|
51859
|
+
return path78.basename(relPath) || relPath;
|
|
52055
51860
|
}
|
|
52056
51861
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
52057
|
-
const root =
|
|
51862
|
+
const root = path78.resolve(bridgeRoot);
|
|
52058
51863
|
if (await isGitRepoDirectory(root)) {
|
|
52059
51864
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
52060
51865
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -52062,19 +51867,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
52062
51867
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
52063
51868
|
const byPath = /* @__PURE__ */ new Map();
|
|
52064
51869
|
for (const repo of [...deep, ...shallow]) {
|
|
52065
|
-
byPath.set(
|
|
51870
|
+
byPath.set(path78.resolve(repo.absolutePath), repo);
|
|
52066
51871
|
}
|
|
52067
51872
|
return [...byPath.values()];
|
|
52068
51873
|
}
|
|
52069
51874
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
52070
|
-
const bridgeResolved =
|
|
51875
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
52071
51876
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
52072
51877
|
const rows = [];
|
|
52073
51878
|
for (let i = 0; i < repos.length; i++) {
|
|
52074
51879
|
if (i > 0) await yieldToEventLoop();
|
|
52075
51880
|
const repo = repos[i];
|
|
52076
|
-
let rel =
|
|
52077
|
-
if (rel.startsWith("..") ||
|
|
51881
|
+
let rel = path78.relative(bridgeResolved, repo.absolutePath);
|
|
51882
|
+
if (rel.startsWith("..") || path78.isAbsolute(rel)) continue;
|
|
52078
51883
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
52079
51884
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
52080
51885
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -52105,11 +51910,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
52105
51910
|
return rows;
|
|
52106
51911
|
}
|
|
52107
51912
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
52108
|
-
const bridgeResolved =
|
|
51913
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
52109
51914
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
52110
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
52111
|
-
const resolved =
|
|
52112
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
51915
|
+
const repoPath = rel === "" ? bridgeResolved : path78.join(bridgeResolved, rel);
|
|
51916
|
+
const resolved = path78.resolve(repoPath);
|
|
51917
|
+
if (!resolved.startsWith(bridgeResolved + path78.sep) && resolved !== bridgeResolved) {
|
|
52113
51918
|
return [];
|
|
52114
51919
|
}
|
|
52115
51920
|
return listRepoBranchRefs(resolved);
|
|
@@ -52159,8 +51964,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
52159
51964
|
}
|
|
52160
51965
|
|
|
52161
51966
|
// ../bridge/src/git/checkout/bridge-git-checkout.ts
|
|
52162
|
-
import * as
|
|
52163
|
-
import * as
|
|
51967
|
+
import * as fs56 from "node:fs/promises";
|
|
51968
|
+
import * as path80 from "node:path";
|
|
52164
51969
|
|
|
52165
51970
|
// ../bridge/src/git/checkout/normalize-clone-url.ts
|
|
52166
51971
|
function normalizeCloneUrl(url2) {
|
|
@@ -52180,12 +51985,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
52180
51985
|
}
|
|
52181
51986
|
|
|
52182
51987
|
// ../bridge/src/git/checkout/resolve-checkout-target.ts
|
|
52183
|
-
import * as
|
|
52184
|
-
import * as
|
|
51988
|
+
import * as fs55 from "node:fs/promises";
|
|
51989
|
+
import * as path79 from "node:path";
|
|
52185
51990
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
52186
51991
|
async function pathExists(p) {
|
|
52187
51992
|
try {
|
|
52188
|
-
await
|
|
51993
|
+
await fs55.access(p);
|
|
52189
51994
|
return true;
|
|
52190
51995
|
} catch {
|
|
52191
51996
|
return false;
|
|
@@ -52197,7 +52002,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52197
52002
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52198
52003
|
throw new Error("Bridge root is already a git repository");
|
|
52199
52004
|
}
|
|
52200
|
-
const entries = await
|
|
52005
|
+
const entries = await fs55.readdir(bridgeRoot).catch(() => []);
|
|
52201
52006
|
if (entries.length > 0) {
|
|
52202
52007
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
52203
52008
|
}
|
|
@@ -52210,8 +52015,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52210
52015
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52211
52016
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
52212
52017
|
}
|
|
52213
|
-
const targetDir =
|
|
52214
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
52018
|
+
const targetDir = path79.resolve(bridgeRoot, folder);
|
|
52019
|
+
if (!targetDir.startsWith(bridgeRoot + path79.sep)) {
|
|
52215
52020
|
throw new Error("Invalid folderName");
|
|
52216
52021
|
}
|
|
52217
52022
|
if (await pathExists(targetDir)) {
|
|
@@ -52230,10 +52035,10 @@ async function bridgeGitCheckout(params) {
|
|
|
52230
52035
|
});
|
|
52231
52036
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
52232
52037
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
52233
|
-
const parent =
|
|
52234
|
-
await
|
|
52038
|
+
const parent = path80.dirname(targetDir);
|
|
52039
|
+
await fs56.mkdir(parent, { recursive: true });
|
|
52235
52040
|
if (relPath !== ".") {
|
|
52236
|
-
await
|
|
52041
|
+
await fs56.mkdir(targetDir, { recursive: true });
|
|
52237
52042
|
}
|
|
52238
52043
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
52239
52044
|
try {
|
|
@@ -52244,7 +52049,7 @@ async function bridgeGitCheckout(params) {
|
|
|
52244
52049
|
return { relPath, folderName };
|
|
52245
52050
|
} catch (e) {
|
|
52246
52051
|
if (relPath !== ".") {
|
|
52247
|
-
await
|
|
52052
|
+
await fs56.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
52248
52053
|
}
|
|
52249
52054
|
const msg = e instanceof Error ? e.message : String(e);
|
|
52250
52055
|
throw new Error(
|
|
@@ -52885,30 +52690,30 @@ function startStreamingProxy(ws, log2, pr) {
|
|
|
52885
52690
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
52886
52691
|
import process8 from "node:process";
|
|
52887
52692
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
52888
|
-
import
|
|
52693
|
+
import path81 from "node:path";
|
|
52889
52694
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
52890
52695
|
import { promisify as promisify8 } from "node:util";
|
|
52891
52696
|
import childProcess from "node:child_process";
|
|
52892
|
-
import
|
|
52697
|
+
import fs61, { constants as fsConstants2 } from "node:fs/promises";
|
|
52893
52698
|
|
|
52894
52699
|
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
52895
52700
|
import process4 from "node:process";
|
|
52896
|
-
import
|
|
52701
|
+
import fs60, { constants as fsConstants } from "node:fs/promises";
|
|
52897
52702
|
|
|
52898
52703
|
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
52899
52704
|
import process3 from "node:process";
|
|
52900
|
-
import
|
|
52901
|
-
import
|
|
52705
|
+
import os8 from "node:os";
|
|
52706
|
+
import fs59 from "node:fs";
|
|
52902
52707
|
|
|
52903
52708
|
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
52904
|
-
import
|
|
52709
|
+
import fs58 from "node:fs";
|
|
52905
52710
|
|
|
52906
52711
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
52907
|
-
import
|
|
52712
|
+
import fs57 from "node:fs";
|
|
52908
52713
|
var isDockerCached;
|
|
52909
52714
|
function hasDockerEnv() {
|
|
52910
52715
|
try {
|
|
52911
|
-
|
|
52716
|
+
fs57.statSync("/.dockerenv");
|
|
52912
52717
|
return true;
|
|
52913
52718
|
} catch {
|
|
52914
52719
|
return false;
|
|
@@ -52916,7 +52721,7 @@ function hasDockerEnv() {
|
|
|
52916
52721
|
}
|
|
52917
52722
|
function hasDockerCGroup() {
|
|
52918
52723
|
try {
|
|
52919
|
-
return
|
|
52724
|
+
return fs57.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
52920
52725
|
} catch {
|
|
52921
52726
|
return false;
|
|
52922
52727
|
}
|
|
@@ -52932,7 +52737,7 @@ function isDocker() {
|
|
|
52932
52737
|
var cachedResult;
|
|
52933
52738
|
var hasContainerEnv = () => {
|
|
52934
52739
|
try {
|
|
52935
|
-
|
|
52740
|
+
fs58.statSync("/run/.containerenv");
|
|
52936
52741
|
return true;
|
|
52937
52742
|
} catch {
|
|
52938
52743
|
return false;
|
|
@@ -52950,19 +52755,19 @@ var isWsl = () => {
|
|
|
52950
52755
|
if (process3.platform !== "linux") {
|
|
52951
52756
|
return false;
|
|
52952
52757
|
}
|
|
52953
|
-
if (
|
|
52758
|
+
if (os8.release().toLowerCase().includes("microsoft")) {
|
|
52954
52759
|
if (isInsideContainer()) {
|
|
52955
52760
|
return false;
|
|
52956
52761
|
}
|
|
52957
52762
|
return true;
|
|
52958
52763
|
}
|
|
52959
52764
|
try {
|
|
52960
|
-
if (
|
|
52765
|
+
if (fs59.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
52961
52766
|
return !isInsideContainer();
|
|
52962
52767
|
}
|
|
52963
52768
|
} catch {
|
|
52964
52769
|
}
|
|
52965
|
-
if (
|
|
52770
|
+
if (fs59.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs59.existsSync("/run/WSL")) {
|
|
52966
52771
|
return !isInsideContainer();
|
|
52967
52772
|
}
|
|
52968
52773
|
return false;
|
|
@@ -52980,14 +52785,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
52980
52785
|
const configFilePath2 = "/etc/wsl.conf";
|
|
52981
52786
|
let isConfigFileExists = false;
|
|
52982
52787
|
try {
|
|
52983
|
-
await
|
|
52788
|
+
await fs60.access(configFilePath2, fsConstants.F_OK);
|
|
52984
52789
|
isConfigFileExists = true;
|
|
52985
52790
|
} catch {
|
|
52986
52791
|
}
|
|
52987
52792
|
if (!isConfigFileExists) {
|
|
52988
52793
|
return defaultMountPoint;
|
|
52989
52794
|
}
|
|
52990
|
-
const configContent = await
|
|
52795
|
+
const configContent = await fs60.readFile(configFilePath2, { encoding: "utf8" });
|
|
52991
52796
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
52992
52797
|
if (!configMountPoint) {
|
|
52993
52798
|
return defaultMountPoint;
|
|
@@ -53141,8 +52946,8 @@ async function defaultBrowser2() {
|
|
|
53141
52946
|
|
|
53142
52947
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
53143
52948
|
var execFile7 = promisify8(childProcess.execFile);
|
|
53144
|
-
var __dirname =
|
|
53145
|
-
var localXdgOpenPath =
|
|
52949
|
+
var __dirname = path81.dirname(fileURLToPath7(import.meta.url));
|
|
52950
|
+
var localXdgOpenPath = path81.join(__dirname, "xdg-open");
|
|
53146
52951
|
var { platform, arch } = process8;
|
|
53147
52952
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
53148
52953
|
const powershellPath = await powerShellPath();
|
|
@@ -53292,7 +53097,7 @@ var baseOpen = async (options) => {
|
|
|
53292
53097
|
const isBundled = !__dirname || __dirname === "/";
|
|
53293
53098
|
let exeLocalXdgOpen = false;
|
|
53294
53099
|
try {
|
|
53295
|
-
await
|
|
53100
|
+
await fs61.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
53296
53101
|
exeLocalXdgOpen = true;
|
|
53297
53102
|
} catch {
|
|
53298
53103
|
}
|
|
@@ -53539,7 +53344,7 @@ function createPendingAuthOnMessage(params) {
|
|
|
53539
53344
|
}
|
|
53540
53345
|
|
|
53541
53346
|
// src/cli-version.ts
|
|
53542
|
-
var CLI_VERSION2 = "0.1.
|
|
53347
|
+
var CLI_VERSION2 = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
53543
53348
|
|
|
53544
53349
|
// src/auth/pending/pending-auth-on-open.ts
|
|
53545
53350
|
function createPendingAuthOnOpen(params) {
|
|
@@ -53650,12 +53455,12 @@ async function refreshBridgeTokens(params) {
|
|
|
53650
53455
|
}
|
|
53651
53456
|
|
|
53652
53457
|
// src/config.ts
|
|
53653
|
-
import
|
|
53654
|
-
import
|
|
53655
|
-
import
|
|
53458
|
+
import fs62 from "node:fs";
|
|
53459
|
+
import path82 from "node:path";
|
|
53460
|
+
import os9 from "node:os";
|
|
53656
53461
|
function getConfigPath() {
|
|
53657
|
-
const dir =
|
|
53658
|
-
return
|
|
53462
|
+
const dir = path82.join(os9.homedir(), ".buildautomaton");
|
|
53463
|
+
return path82.join(dir, "config.json");
|
|
53659
53464
|
}
|
|
53660
53465
|
function normalizeApiUrl(url2) {
|
|
53661
53466
|
return url2.replace(/\/$/, "");
|
|
@@ -53663,7 +53468,7 @@ function normalizeApiUrl(url2) {
|
|
|
53663
53468
|
function readRawConfig() {
|
|
53664
53469
|
try {
|
|
53665
53470
|
const p = getConfigPath();
|
|
53666
|
-
const raw =
|
|
53471
|
+
const raw = fs62.readFileSync(p, "utf8");
|
|
53667
53472
|
return JSON.parse(raw);
|
|
53668
53473
|
} catch {
|
|
53669
53474
|
return null;
|
|
@@ -53671,14 +53476,14 @@ function readRawConfig() {
|
|
|
53671
53476
|
}
|
|
53672
53477
|
function writeConfigForApi(apiUrl, auth) {
|
|
53673
53478
|
const p = getConfigPath();
|
|
53674
|
-
const dir =
|
|
53479
|
+
const dir = path82.dirname(p);
|
|
53675
53480
|
const key = normalizeApiUrl(apiUrl);
|
|
53676
53481
|
const prev = readRawConfig() ?? {};
|
|
53677
53482
|
const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
|
|
53678
53483
|
const next = { ...prev, servers };
|
|
53679
53484
|
try {
|
|
53680
|
-
if (!
|
|
53681
|
-
|
|
53485
|
+
if (!fs62.existsSync(dir)) fs62.mkdirSync(dir, { recursive: true });
|
|
53486
|
+
fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
53682
53487
|
} catch (e) {
|
|
53683
53488
|
console.error("Could not save authentication config:", e);
|
|
53684
53489
|
}
|
|
@@ -53687,22 +53492,22 @@ function clearConfigForApi(apiUrl) {
|
|
|
53687
53492
|
const key = normalizeApiUrl(apiUrl);
|
|
53688
53493
|
try {
|
|
53689
53494
|
const p = getConfigPath();
|
|
53690
|
-
if (!
|
|
53495
|
+
if (!fs62.existsSync(p)) return;
|
|
53691
53496
|
const prev = readRawConfig();
|
|
53692
53497
|
if (!prev) return;
|
|
53693
53498
|
const servers = { ...prev.servers ?? {} };
|
|
53694
53499
|
delete servers[key];
|
|
53695
53500
|
const next = { ...prev, servers };
|
|
53696
53501
|
if (Object.keys(servers).length === 0 && !prev.workspaceId) {
|
|
53697
|
-
|
|
53502
|
+
fs62.unlinkSync(p);
|
|
53698
53503
|
return;
|
|
53699
53504
|
}
|
|
53700
53505
|
if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
|
|
53701
53506
|
const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
|
|
53702
|
-
|
|
53507
|
+
fs62.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
|
|
53703
53508
|
return;
|
|
53704
53509
|
}
|
|
53705
|
-
|
|
53510
|
+
fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
53706
53511
|
} catch {
|
|
53707
53512
|
}
|
|
53708
53513
|
}
|
|
@@ -54275,34 +54080,10 @@ function enrichIntegrationContentPromptForAgent(params) {
|
|
|
54275
54080
|
return injectIntegrationContentAgentPromptNote(params.agentPromptText, params.sessionId);
|
|
54276
54081
|
}
|
|
54277
54082
|
|
|
54278
|
-
// src/agents/planning/enrich-planning-session-prompt-for-agent.ts
|
|
54279
|
-
async function enrichPlanningSessionPromptForAgent(params) {
|
|
54280
|
-
const meta3 = await fetchCloudSessionMeta({
|
|
54281
|
-
sessionId: params.sessionId,
|
|
54282
|
-
cloudApiBaseUrl: params.cloudApiBaseUrl,
|
|
54283
|
-
getCloudAccessToken: params.getCloudAccessToken
|
|
54284
|
-
});
|
|
54285
|
-
if (!meta3.ok) return { promptText: params.promptText, isPlanningSession: false };
|
|
54286
|
-
const sessionKind = parseSessionKind(meta3.data.sessionKind);
|
|
54287
|
-
if (sessionKind !== "planning") return { promptText: params.promptText, isPlanningSession: false };
|
|
54288
|
-
const todos = Array.isArray(meta3.data.planningTodos) ? meta3.data.planningTodos : [];
|
|
54289
|
-
if (params.isNewSession || todos.length === 0) {
|
|
54290
|
-
return {
|
|
54291
|
-
promptText: buildPlanningSessionAgentPrompt(params.promptText),
|
|
54292
|
-
isPlanningSession: true
|
|
54293
|
-
};
|
|
54294
|
-
}
|
|
54295
|
-
return {
|
|
54296
|
-
promptText: buildPlanningSessionFollowUpAgentPrompt(params.promptText, todos),
|
|
54297
|
-
isPlanningSession: true
|
|
54298
|
-
};
|
|
54299
|
-
}
|
|
54300
|
-
|
|
54301
54083
|
// src/plugin/prepare-ba-agent-prompt.ts
|
|
54302
54084
|
async function prepareBuildAutomatonAgentPrompt(params) {
|
|
54303
|
-
const { promptText, sessionId,
|
|
54085
|
+
const { promptText, sessionId, cloudApiBaseUrl, getCloudAccessToken } = params;
|
|
54304
54086
|
let agentPromptText = promptText;
|
|
54305
|
-
let isPlanningSession = false;
|
|
54306
54087
|
if (sessionId) {
|
|
54307
54088
|
agentPromptText = await enrichForkedSessionPromptForAgent({
|
|
54308
54089
|
sessionId,
|
|
@@ -54310,88 +54091,15 @@ async function prepareBuildAutomatonAgentPrompt(params) {
|
|
|
54310
54091
|
cloudApiBaseUrl,
|
|
54311
54092
|
getCloudAccessToken
|
|
54312
54093
|
});
|
|
54313
|
-
const planningEnriched = await enrichPlanningSessionPromptForAgent({
|
|
54314
|
-
sessionId,
|
|
54315
|
-
promptText: agentPromptText,
|
|
54316
|
-
isNewSession,
|
|
54317
|
-
cloudApiBaseUrl,
|
|
54318
|
-
getCloudAccessToken
|
|
54319
|
-
});
|
|
54320
|
-
agentPromptText = planningEnriched.promptText;
|
|
54321
|
-
isPlanningSession = planningEnriched.isPlanningSession;
|
|
54322
|
-
}
|
|
54323
|
-
if (sessionId) {
|
|
54324
54094
|
agentPromptText = enrichIntegrationContentPromptForAgent({
|
|
54325
54095
|
sessionId,
|
|
54326
54096
|
originalPromptText: promptText,
|
|
54327
54097
|
agentPromptText
|
|
54328
54098
|
});
|
|
54329
54099
|
}
|
|
54330
|
-
|
|
54331
|
-
|
|
54332
|
-
|
|
54333
|
-
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
54334
|
-
var PLANNING_TODO_SUBMIT_TIMEOUT_MS = 3e3;
|
|
54335
|
-
async function submitPlanningTodosForTurn(params) {
|
|
54336
|
-
const token = params.getCloudAccessToken();
|
|
54337
|
-
if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
|
|
54338
|
-
const base = params.cloudApiBaseUrl.replace(/\/$/, "");
|
|
54339
|
-
const url2 = `${base}/internal/sessions/todos/submit`;
|
|
54340
|
-
let res;
|
|
54341
|
-
try {
|
|
54342
|
-
res = await fetch(url2, {
|
|
54343
|
-
method: "POST",
|
|
54344
|
-
signal: AbortSignal.timeout(PLANNING_TODO_SUBMIT_TIMEOUT_MS),
|
|
54345
|
-
headers: {
|
|
54346
|
-
Authorization: `Bearer ${token}`,
|
|
54347
|
-
"Content-Type": "application/json"
|
|
54348
|
-
},
|
|
54349
|
-
body: JSON.stringify({
|
|
54350
|
-
sessionId: params.sessionId,
|
|
54351
|
-
turnId: params.turnId,
|
|
54352
|
-
items: params.items
|
|
54353
|
-
})
|
|
54354
|
-
});
|
|
54355
|
-
} catch (error51) {
|
|
54356
|
-
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
54357
|
-
}
|
|
54358
|
-
if (!res.ok) {
|
|
54359
|
-
const body = await res.json().catch(() => null);
|
|
54360
|
-
return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
|
|
54361
|
-
}
|
|
54362
|
-
return { ok: true };
|
|
54363
|
-
}
|
|
54364
|
-
|
|
54365
|
-
// src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
|
|
54366
|
-
async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
|
|
54367
|
-
const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
|
|
54368
|
-
const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
|
|
54369
|
-
const outputFromResult = typeof output === "string" ? output : "";
|
|
54370
|
-
const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
|
|
54371
|
-
if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
|
|
54372
|
-
return { submitted: false, suppressOutput: false };
|
|
54373
|
-
}
|
|
54374
|
-
if (!cloudApiBaseUrl || !getCloudAccessToken) {
|
|
54375
|
-
return { submitted: false, suppressOutput: false };
|
|
54376
|
-
}
|
|
54377
|
-
const items = parsePlanningTodoAgentJson(outputStr);
|
|
54378
|
-
if (items.length === 0) {
|
|
54379
|
-
return { submitted: false, suppressOutput: false };
|
|
54380
|
-
}
|
|
54381
|
-
const result = await submitPlanningTodosForTurn({
|
|
54382
|
-
sessionId,
|
|
54383
|
-
turnId: runId,
|
|
54384
|
-
items,
|
|
54385
|
-
cloudApiBaseUrl,
|
|
54386
|
-
getCloudAccessToken
|
|
54387
|
-
});
|
|
54388
|
-
if (!result.ok) {
|
|
54389
|
-
log2(`[Agent] Planning todo submit failed: ${result.error}`);
|
|
54390
|
-
return { submitted: false, suppressOutput: false };
|
|
54391
|
-
}
|
|
54392
|
-
if (runId) consumePlanningSessionTurnOutput(runId);
|
|
54393
|
-
log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
|
|
54394
|
-
return { submitted: true, suppressOutput: true };
|
|
54100
|
+
void params.runId;
|
|
54101
|
+
void params.isNewSession;
|
|
54102
|
+
return { agentPromptText, isPlanningSession: false };
|
|
54395
54103
|
}
|
|
54396
54104
|
|
|
54397
54105
|
// src/e2e-certificates/open-import-url.ts
|
|
@@ -54750,11 +54458,6 @@ function createBuildAutomatonPlugin(options) {
|
|
|
54750
54458
|
cloudApiBaseUrl: apiUrl,
|
|
54751
54459
|
getCloudAccessToken: getAccessToken
|
|
54752
54460
|
}),
|
|
54753
|
-
maybeSubmitPlanningTodos: (params) => maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
54754
|
-
...params,
|
|
54755
|
-
cloudApiBaseUrl: apiUrl,
|
|
54756
|
-
getCloudAccessToken: getAccessToken
|
|
54757
|
-
}),
|
|
54758
54461
|
persistTokens: (tokens) => writeConfigForApi(apiUrl, {
|
|
54759
54462
|
workspaceId: tokens.workspaceId,
|
|
54760
54463
|
token: tokens.token,
|