@adhdev/daemon-core 0.9.82-rc.301 → 0.9.82-rc.302
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-adapters/resolve-executable.d.ts +14 -0
- package/dist/index.js +506 -462
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +511 -467
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/resolve-executable.ts +45 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/commands/upgrade-helper.ts +29 -0
package/dist/index.js
CHANGED
|
@@ -293,10 +293,10 @@ function readInjected(value) {
|
|
|
293
293
|
}
|
|
294
294
|
function getDaemonBuildInfo() {
|
|
295
295
|
if (cached) return cached;
|
|
296
|
-
const commit = readInjected(true ? "
|
|
297
|
-
const commitShort = readInjected(true ? "
|
|
298
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
299
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
296
|
+
const commit = readInjected(true ? "850c147fda8183e55c145fcef876d2c25a22c8d2" : void 0) ?? "unknown";
|
|
297
|
+
const commitShort = readInjected(true ? "850c147f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
298
|
+
const version = readInjected(true ? "0.9.82-rc.302" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
299
|
+
const builtAt = readInjected(true ? "2026-06-17T02:29:22.806Z" : void 0);
|
|
300
300
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
301
301
|
return cached;
|
|
302
302
|
}
|
|
@@ -638,12 +638,12 @@ function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
|
|
|
638
638
|
if (!match) continue;
|
|
639
639
|
const prefix = match[1];
|
|
640
640
|
const commit = match[2];
|
|
641
|
-
const
|
|
642
|
-
if (ignoreSet.has(
|
|
641
|
+
const path41 = match[3];
|
|
642
|
+
if (ignoreSet.has(path41)) continue;
|
|
643
643
|
submodules.push({
|
|
644
|
-
path:
|
|
644
|
+
path: path41,
|
|
645
645
|
commit,
|
|
646
|
-
repoPath: repoRoot + "/" +
|
|
646
|
+
repoPath: repoRoot + "/" + path41,
|
|
647
647
|
dirty: prefix === "U",
|
|
648
648
|
outOfSync: prefix === "-" || prefix === "+",
|
|
649
649
|
lastCheckedAt: Date.now()
|
|
@@ -1465,10 +1465,10 @@ function getMeshConfigPath() {
|
|
|
1465
1465
|
return (0, import_path2.join)(getConfigDir(), "meshes.json");
|
|
1466
1466
|
}
|
|
1467
1467
|
function loadMeshConfig() {
|
|
1468
|
-
const
|
|
1469
|
-
if (!(0, import_fs2.existsSync)(
|
|
1468
|
+
const path41 = getMeshConfigPath();
|
|
1469
|
+
if (!(0, import_fs2.existsSync)(path41)) return { meshes: [] };
|
|
1470
1470
|
try {
|
|
1471
|
-
const raw = JSON.parse((0, import_fs2.readFileSync)(
|
|
1471
|
+
const raw = JSON.parse((0, import_fs2.readFileSync)(path41, "utf-8"));
|
|
1472
1472
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
1473
1473
|
return raw;
|
|
1474
1474
|
} catch {
|
|
@@ -1486,16 +1486,16 @@ function normalizeCapabilityTags(value) {
|
|
|
1486
1486
|
return tags.length ? tags : void 0;
|
|
1487
1487
|
}
|
|
1488
1488
|
function saveMeshConfig(config) {
|
|
1489
|
-
const
|
|
1490
|
-
(0, import_fs2.writeFileSync)(
|
|
1489
|
+
const path41 = getMeshConfigPath();
|
|
1490
|
+
(0, import_fs2.writeFileSync)(path41, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
|
|
1491
1491
|
}
|
|
1492
1492
|
function normalizeRepoIdentity(remoteUrl) {
|
|
1493
1493
|
let identity = remoteUrl.trim();
|
|
1494
1494
|
if (identity.startsWith("http://") || identity.startsWith("https://")) {
|
|
1495
1495
|
try {
|
|
1496
1496
|
const url = new URL(identity);
|
|
1497
|
-
const
|
|
1498
|
-
return `${url.hostname}/${
|
|
1497
|
+
const path41 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
1498
|
+
return `${url.hostname}/${path41}`;
|
|
1499
1499
|
} catch {
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
@@ -2177,10 +2177,10 @@ function rotateArchiveFile(meshId, archivePath) {
|
|
|
2177
2177
|
}
|
|
2178
2178
|
}
|
|
2179
2179
|
function readArchivedCounts(meshId) {
|
|
2180
|
-
const
|
|
2181
|
-
if (!(0, import_fs3.existsSync)(
|
|
2180
|
+
const path41 = getArchivedCountsPath(meshId);
|
|
2181
|
+
if (!(0, import_fs3.existsSync)(path41)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
2182
2182
|
try {
|
|
2183
|
-
return JSON.parse((0, import_fs3.readFileSync)(
|
|
2183
|
+
return JSON.parse((0, import_fs3.readFileSync)(path41, "utf-8"));
|
|
2184
2184
|
} catch {
|
|
2185
2185
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
2186
2186
|
}
|
|
@@ -3585,10 +3585,10 @@ var init_mesh_runtime_store = __esm({
|
|
|
3585
3585
|
this.migratedMeshIds.add(meshId);
|
|
3586
3586
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
3587
3587
|
if (count.count > 0) return;
|
|
3588
|
-
const
|
|
3589
|
-
if (!(0, import_fs4.existsSync)(
|
|
3588
|
+
const path41 = legacyQueuePath(meshId);
|
|
3589
|
+
if (!(0, import_fs4.existsSync)(path41)) return;
|
|
3590
3590
|
try {
|
|
3591
|
-
const entries = JSON.parse((0, import_fs4.readFileSync)(
|
|
3591
|
+
const entries = JSON.parse((0, import_fs4.readFileSync)(path41, "utf-8"));
|
|
3592
3592
|
if (!Array.isArray(entries)) return;
|
|
3593
3593
|
const insert = this.db.prepare(`
|
|
3594
3594
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -5341,8 +5341,8 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
5341
5341
|
}
|
|
5342
5342
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
5343
5343
|
if (mcpConfig.mode === "auto_import") {
|
|
5344
|
-
const
|
|
5345
|
-
if (!
|
|
5344
|
+
const path41 = mcpConfig.path?.trim();
|
|
5345
|
+
if (!path41) {
|
|
5346
5346
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
5347
5347
|
}
|
|
5348
5348
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -5362,7 +5362,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
5362
5362
|
return {
|
|
5363
5363
|
kind: "auto_import",
|
|
5364
5364
|
serverName,
|
|
5365
|
-
configPath: resolveMcpConfigPath(
|
|
5365
|
+
configPath: resolveMcpConfigPath(path41, workspace),
|
|
5366
5366
|
configFormat: mcpConfig.format,
|
|
5367
5367
|
mcpServer
|
|
5368
5368
|
};
|
|
@@ -6375,12 +6375,12 @@ function readGitSubmodules(value, parentRepoRoot) {
|
|
|
6375
6375
|
if (!Array.isArray(value)) return void 0;
|
|
6376
6376
|
const submodules = value.map((entry) => {
|
|
6377
6377
|
const submodule = readRecord3(entry);
|
|
6378
|
-
const
|
|
6378
|
+
const path41 = readString5(submodule.path);
|
|
6379
6379
|
const commit = readString5(submodule.commit);
|
|
6380
|
-
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot,
|
|
6381
|
-
if (!
|
|
6380
|
+
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path41);
|
|
6381
|
+
if (!path41 || !commit) return null;
|
|
6382
6382
|
const result = {
|
|
6383
|
-
path:
|
|
6383
|
+
path: path41,
|
|
6384
6384
|
commit,
|
|
6385
6385
|
dirty: readBoolean(submodule.dirty) ?? false,
|
|
6386
6386
|
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
@@ -6779,10 +6779,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
6779
6779
|
const primaryDaemonId = daemonIds[0];
|
|
6780
6780
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
6781
6781
|
const events = [];
|
|
6782
|
-
for (const
|
|
6783
|
-
if (!(0, import_fs8.existsSync)(
|
|
6782
|
+
for (const path41 of paths) {
|
|
6783
|
+
if (!(0, import_fs8.existsSync)(path41)) continue;
|
|
6784
6784
|
try {
|
|
6785
|
-
const raw = (0, import_fs8.readFileSync)(
|
|
6785
|
+
const raw = (0, import_fs8.readFileSync)(path41, "utf-8");
|
|
6786
6786
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
6787
6787
|
try {
|
|
6788
6788
|
return [JSON.parse(line)];
|
|
@@ -6790,7 +6790,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
6790
6790
|
return [];
|
|
6791
6791
|
}
|
|
6792
6792
|
});
|
|
6793
|
-
const filtered = primaryDaemonId &&
|
|
6793
|
+
const filtered = primaryDaemonId && path41 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
|
|
6794
6794
|
events.push(...filtered);
|
|
6795
6795
|
} catch {
|
|
6796
6796
|
}
|
|
@@ -6855,13 +6855,13 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
|
|
|
6855
6855
|
const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
|
|
6856
6856
|
return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
|
|
6857
6857
|
}
|
|
6858
|
-
function trimPendingEventsIfNeeded(
|
|
6858
|
+
function trimPendingEventsIfNeeded(path41) {
|
|
6859
6859
|
try {
|
|
6860
|
-
if (!(0, import_fs8.existsSync)(
|
|
6861
|
-
if ((0, import_fs8.statSync)(
|
|
6862
|
-
const lines = (0, import_fs8.readFileSync)(
|
|
6860
|
+
if (!(0, import_fs8.existsSync)(path41)) return;
|
|
6861
|
+
if ((0, import_fs8.statSync)(path41).size <= MAX_PENDING_EVENTS_BYTES) return;
|
|
6862
|
+
const lines = (0, import_fs8.readFileSync)(path41, "utf-8").split("\n").filter(Boolean);
|
|
6863
6863
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
6864
|
-
(0, import_fs8.writeFileSync)(
|
|
6864
|
+
(0, import_fs8.writeFileSync)(path41, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
6865
6865
|
} catch {
|
|
6866
6866
|
}
|
|
6867
6867
|
}
|
|
@@ -6888,19 +6888,19 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
6888
6888
|
});
|
|
6889
6889
|
} catch {
|
|
6890
6890
|
}
|
|
6891
|
-
const
|
|
6892
|
-
trimPendingEventsIfNeeded(
|
|
6893
|
-
(0, import_fs8.appendFileSync)(
|
|
6891
|
+
const path41 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
6892
|
+
trimPendingEventsIfNeeded(path41);
|
|
6893
|
+
(0, import_fs8.appendFileSync)(path41, JSON.stringify(event) + "\n", "utf-8");
|
|
6894
6894
|
return true;
|
|
6895
6895
|
} catch (e) {
|
|
6896
6896
|
LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
6897
6897
|
return false;
|
|
6898
6898
|
}
|
|
6899
6899
|
}
|
|
6900
|
-
function atomicDrainFile(
|
|
6901
|
-
const tmpPath = `${
|
|
6900
|
+
function atomicDrainFile(path41) {
|
|
6901
|
+
const tmpPath = `${path41}.draining`;
|
|
6902
6902
|
try {
|
|
6903
|
-
(0, import_fs8.renameSync)(
|
|
6903
|
+
(0, import_fs8.renameSync)(path41, tmpPath);
|
|
6904
6904
|
} catch {
|
|
6905
6905
|
return null;
|
|
6906
6906
|
}
|
|
@@ -6919,10 +6919,10 @@ function atomicDrainFile(path40) {
|
|
|
6919
6919
|
return null;
|
|
6920
6920
|
}
|
|
6921
6921
|
}
|
|
6922
|
-
function selectiveDrainFile(
|
|
6923
|
-
const tmpPath = `${
|
|
6922
|
+
function selectiveDrainFile(path41, predicate) {
|
|
6923
|
+
const tmpPath = `${path41}.draining`;
|
|
6924
6924
|
try {
|
|
6925
|
-
(0, import_fs8.renameSync)(
|
|
6925
|
+
(0, import_fs8.renameSync)(path41, tmpPath);
|
|
6926
6926
|
} catch {
|
|
6927
6927
|
return [];
|
|
6928
6928
|
}
|
|
@@ -6954,12 +6954,12 @@ function selectiveDrainFile(path40, predicate) {
|
|
|
6954
6954
|
}
|
|
6955
6955
|
try {
|
|
6956
6956
|
if (keptLines.length > 0) {
|
|
6957
|
-
(0, import_fs8.writeFileSync)(
|
|
6957
|
+
(0, import_fs8.writeFileSync)(path41, keptLines.join("\n") + "\n", "utf-8");
|
|
6958
6958
|
}
|
|
6959
6959
|
(0, import_fs8.unlinkSync)(tmpPath);
|
|
6960
6960
|
} catch {
|
|
6961
6961
|
try {
|
|
6962
|
-
if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(
|
|
6962
|
+
if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(path41)) (0, import_fs8.renameSync)(tmpPath, path41);
|
|
6963
6963
|
} catch {
|
|
6964
6964
|
}
|
|
6965
6965
|
return [];
|
|
@@ -6993,16 +6993,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
|
|
|
6993
6993
|
} catch {
|
|
6994
6994
|
}
|
|
6995
6995
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
6996
|
-
for (const
|
|
6997
|
-
const isSharedFile = !!primaryDaemonId &&
|
|
6996
|
+
for (const path41 of paths) {
|
|
6997
|
+
const isSharedFile = !!primaryDaemonId && path41 === getPendingEventsPath(meshId);
|
|
6998
6998
|
const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
|
|
6999
6999
|
if (onlyEvents) {
|
|
7000
|
-
for (const event of selectiveDrainFile(
|
|
7000
|
+
for (const event of selectiveDrainFile(path41, (e) => targets(e) && matchesFilter(e.event))) {
|
|
7001
7001
|
pushUnique(event);
|
|
7002
7002
|
}
|
|
7003
7003
|
continue;
|
|
7004
7004
|
}
|
|
7005
|
-
const content = atomicDrainFile(
|
|
7005
|
+
const content = atomicDrainFile(path41);
|
|
7006
7006
|
if (!content) continue;
|
|
7007
7007
|
const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
|
|
7008
7008
|
try {
|
|
@@ -7052,9 +7052,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
|
7052
7052
|
} catch {
|
|
7053
7053
|
}
|
|
7054
7054
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
7055
|
-
for (const
|
|
7056
|
-
if ((0, import_fs8.existsSync)(
|
|
7057
|
-
(0, import_fs8.unlinkSync)(
|
|
7055
|
+
for (const path41 of paths) {
|
|
7056
|
+
if ((0, import_fs8.existsSync)(path41)) try {
|
|
7057
|
+
(0, import_fs8.unlinkSync)(path41);
|
|
7058
7058
|
} catch {
|
|
7059
7059
|
}
|
|
7060
7060
|
}
|
|
@@ -10065,7 +10065,7 @@ function getCliValidator() {
|
|
|
10065
10065
|
return _cliValidator;
|
|
10066
10066
|
}
|
|
10067
10067
|
function formatIssue(err) {
|
|
10068
|
-
const
|
|
10068
|
+
const path41 = err.instancePath || "";
|
|
10069
10069
|
const params = err.params;
|
|
10070
10070
|
let message = err.message || "validation failed";
|
|
10071
10071
|
let allowed;
|
|
@@ -10083,7 +10083,7 @@ function formatIssue(err) {
|
|
|
10083
10083
|
} else if (err.keyword === "type") {
|
|
10084
10084
|
message = `must be ${params.type}`;
|
|
10085
10085
|
}
|
|
10086
|
-
return { path:
|
|
10086
|
+
return { path: path41, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
10087
10087
|
}
|
|
10088
10088
|
function validateCliProviderManifest(manifest) {
|
|
10089
10089
|
const validator = getCliValidator();
|
|
@@ -10441,6 +10441,37 @@ var init_spawn_env = __esm({
|
|
|
10441
10441
|
}
|
|
10442
10442
|
});
|
|
10443
10443
|
|
|
10444
|
+
// src/cli-adapters/resolve-executable.ts
|
|
10445
|
+
function resolveWin32Executable(command) {
|
|
10446
|
+
if (process.platform !== "win32") return command;
|
|
10447
|
+
const trimmed = (command || "").trim();
|
|
10448
|
+
if (!trimmed) return command;
|
|
10449
|
+
if (path16.isAbsolute(trimmed) && (0, import_fs13.existsSync)(trimmed)) return trimmed;
|
|
10450
|
+
try {
|
|
10451
|
+
const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
|
|
10452
|
+
encoding: "utf8",
|
|
10453
|
+
windowsHide: true
|
|
10454
|
+
}).trim();
|
|
10455
|
+
if (out) {
|
|
10456
|
+
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
10457
|
+
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path16.extname(m).toLowerCase()));
|
|
10458
|
+
return direct || matches[0] || command;
|
|
10459
|
+
}
|
|
10460
|
+
} catch {
|
|
10461
|
+
}
|
|
10462
|
+
return command;
|
|
10463
|
+
}
|
|
10464
|
+
var import_child_process4, import_fs13, path16, DIRECT_EXEC_EXT;
|
|
10465
|
+
var init_resolve_executable = __esm({
|
|
10466
|
+
"src/cli-adapters/resolve-executable.ts"() {
|
|
10467
|
+
"use strict";
|
|
10468
|
+
import_child_process4 = require("child_process");
|
|
10469
|
+
import_fs13 = require("fs");
|
|
10470
|
+
path16 = __toESM(require("path"));
|
|
10471
|
+
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
10472
|
+
}
|
|
10473
|
+
});
|
|
10474
|
+
|
|
10444
10475
|
// src/cli-adapters/pty-transport.ts
|
|
10445
10476
|
var pty_transport_exports = {};
|
|
10446
10477
|
__export(pty_transport_exports, {
|
|
@@ -10462,6 +10493,7 @@ var init_pty_transport = __esm({
|
|
|
10462
10493
|
"use strict";
|
|
10463
10494
|
os11 = __toESM(require("os"));
|
|
10464
10495
|
init_spawn_env();
|
|
10496
|
+
init_resolve_executable();
|
|
10465
10497
|
NodePtyRuntimeTransport = class {
|
|
10466
10498
|
constructor(handle) {
|
|
10467
10499
|
this.handle = handle;
|
|
@@ -10504,7 +10536,7 @@ var init_pty_transport = __esm({
|
|
|
10504
10536
|
cwd = os11.homedir();
|
|
10505
10537
|
}
|
|
10506
10538
|
}
|
|
10507
|
-
const handle = pty.spawn(command, args, {
|
|
10539
|
+
const handle = pty.spawn(resolveWin32Executable(command), args, {
|
|
10508
10540
|
name: "xterm-256color",
|
|
10509
10541
|
cols: options.cols,
|
|
10510
10542
|
rows: options.rows,
|
|
@@ -10593,17 +10625,17 @@ function buildCliScreenSnapshot(text) {
|
|
|
10593
10625
|
function findBinary(name) {
|
|
10594
10626
|
const trimmed = String(name || "").trim();
|
|
10595
10627
|
if (!trimmed) return trimmed;
|
|
10596
|
-
const expanded = trimmed.startsWith("~") ?
|
|
10597
|
-
if (
|
|
10598
|
-
return
|
|
10628
|
+
const expanded = trimmed.startsWith("~") ? path17.join(os12.homedir(), trimmed.slice(1)) : trimmed;
|
|
10629
|
+
if (path17.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
10630
|
+
return path17.isAbsolute(expanded) ? expanded : path17.resolve(expanded);
|
|
10599
10631
|
}
|
|
10600
10632
|
const isWin = os12.platform() === "win32";
|
|
10601
|
-
const paths = (process.env.PATH || "").split(
|
|
10633
|
+
const paths = (process.env.PATH || "").split(path17.delimiter);
|
|
10602
10634
|
const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
10603
10635
|
for (const p of paths) {
|
|
10604
10636
|
if (!p) continue;
|
|
10605
10637
|
for (const ext of exes) {
|
|
10606
|
-
const fullPath =
|
|
10638
|
+
const fullPath = path17.join(p, trimmed + ext);
|
|
10607
10639
|
try {
|
|
10608
10640
|
const fs30 = require("fs");
|
|
10609
10641
|
if (fs30.existsSync(fullPath)) {
|
|
@@ -10619,7 +10651,7 @@ function findBinary(name) {
|
|
|
10619
10651
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
10620
10652
|
}
|
|
10621
10653
|
function isScriptBinary(binaryPath) {
|
|
10622
|
-
if (!
|
|
10654
|
+
if (!path17.isAbsolute(binaryPath)) return false;
|
|
10623
10655
|
try {
|
|
10624
10656
|
const fs30 = require("fs");
|
|
10625
10657
|
const resolved = fs30.realpathSync(binaryPath);
|
|
@@ -10635,7 +10667,7 @@ function isScriptBinary(binaryPath) {
|
|
|
10635
10667
|
}
|
|
10636
10668
|
}
|
|
10637
10669
|
function looksLikeMachOOrElf(filePath) {
|
|
10638
|
-
if (!
|
|
10670
|
+
if (!path17.isAbsolute(filePath)) return false;
|
|
10639
10671
|
try {
|
|
10640
10672
|
const fs30 = require("fs");
|
|
10641
10673
|
const resolved = fs30.realpathSync(filePath);
|
|
@@ -10724,12 +10756,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
10724
10756
|
}
|
|
10725
10757
|
};
|
|
10726
10758
|
}
|
|
10727
|
-
var os12,
|
|
10759
|
+
var os12, path17, TerminalTranscriptAccumulator, buildCliSpawnEnv;
|
|
10728
10760
|
var init_provider_cli_shared = __esm({
|
|
10729
10761
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
10730
10762
|
"use strict";
|
|
10731
10763
|
os12 = __toESM(require("os"));
|
|
10732
|
-
|
|
10764
|
+
path17 = __toESM(require("path"));
|
|
10733
10765
|
init_spawn_env();
|
|
10734
10766
|
TerminalTranscriptAccumulator = class {
|
|
10735
10767
|
lines = [[]];
|
|
@@ -12687,9 +12719,9 @@ function resolveCliSpawnPlan(options) {
|
|
|
12687
12719
|
);
|
|
12688
12720
|
let shellCmd;
|
|
12689
12721
|
let shellArgs;
|
|
12690
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
12722
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
12691
12723
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
12692
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
12724
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
12693
12725
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
12694
12726
|
if (useShell) {
|
|
12695
12727
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -12765,12 +12797,12 @@ function respondToCliTerminalQueries(options) {
|
|
|
12765
12797
|
}
|
|
12766
12798
|
return "";
|
|
12767
12799
|
}
|
|
12768
|
-
var os13,
|
|
12800
|
+
var os13, path18, import_session_host_core4;
|
|
12769
12801
|
var init_provider_cli_runtime = __esm({
|
|
12770
12802
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
12771
12803
|
"use strict";
|
|
12772
12804
|
os13 = __toESM(require("os"));
|
|
12773
|
-
|
|
12805
|
+
path18 = __toESM(require("path"));
|
|
12774
12806
|
import_session_host_core4 = require("@adhdev/session-host-core");
|
|
12775
12807
|
init_provider_cli_shared();
|
|
12776
12808
|
}
|
|
@@ -14955,40 +14987,40 @@ function validateFsmSpec(raw) {
|
|
|
14955
14987
|
}
|
|
14956
14988
|
return errs;
|
|
14957
14989
|
}
|
|
14958
|
-
function validateCondition(c, sectionIds,
|
|
14990
|
+
function validateCondition(c, sectionIds, path41) {
|
|
14959
14991
|
const errs = [];
|
|
14960
14992
|
const w = c;
|
|
14961
14993
|
if ("all" in w) {
|
|
14962
|
-
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
14994
|
+
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.all[${i}]`)));
|
|
14963
14995
|
return errs;
|
|
14964
14996
|
}
|
|
14965
14997
|
if ("any" in w) {
|
|
14966
|
-
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
14998
|
+
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.any[${i}]`)));
|
|
14967
14999
|
return errs;
|
|
14968
15000
|
}
|
|
14969
15001
|
if ("not" in w) {
|
|
14970
|
-
errs.push(...validateCondition(w.not, sectionIds, `${
|
|
15002
|
+
errs.push(...validateCondition(w.not, sectionIds, `${path41}.not`));
|
|
14971
15003
|
return errs;
|
|
14972
15004
|
}
|
|
14973
15005
|
if ("matches" in w) {
|
|
14974
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
15006
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path41}.section "${w.section}" unknown`);
|
|
14975
15007
|
try {
|
|
14976
15008
|
new RegExp(w.matches, w.flags ?? "i");
|
|
14977
15009
|
} catch (e) {
|
|
14978
|
-
errs.push(`${
|
|
15010
|
+
errs.push(`${path41}.matches invalid regex: ${e.message}`);
|
|
14979
15011
|
}
|
|
14980
15012
|
return errs;
|
|
14981
15013
|
}
|
|
14982
15014
|
if ("cursor_above" in w && "changed" in w) return errs;
|
|
14983
15015
|
if ("elapsed_ms" in w) {
|
|
14984
|
-
if (typeof w.elapsed_ms !== "number") errs.push(`${
|
|
15016
|
+
if (typeof w.elapsed_ms !== "number") errs.push(`${path41}.elapsed_ms must be a number`);
|
|
14985
15017
|
return errs;
|
|
14986
15018
|
}
|
|
14987
15019
|
if ("stable_ms" in w) {
|
|
14988
|
-
if (typeof w.stable_ms !== "number") errs.push(`${
|
|
15020
|
+
if (typeof w.stable_ms !== "number") errs.push(`${path41}.stable_ms must be a number`);
|
|
14989
15021
|
return errs;
|
|
14990
15022
|
}
|
|
14991
|
-
errs.push(`${
|
|
15023
|
+
errs.push(`${path41} is not a recognized condition`);
|
|
14992
15024
|
return errs;
|
|
14993
15025
|
}
|
|
14994
15026
|
var fs9;
|
|
@@ -15148,7 +15180,7 @@ function _getRegisteredRoots() {
|
|
|
15148
15180
|
}
|
|
15149
15181
|
function canonicalize(p) {
|
|
15150
15182
|
try {
|
|
15151
|
-
const resolved =
|
|
15183
|
+
const resolved = path31.resolve(p);
|
|
15152
15184
|
try {
|
|
15153
15185
|
return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
|
|
15154
15186
|
} catch {
|
|
@@ -15168,7 +15200,7 @@ function isCallerInsideGatedRoot(callerFilename) {
|
|
|
15168
15200
|
}
|
|
15169
15201
|
for (const root of _gatedRoots) {
|
|
15170
15202
|
if (normalized === root.rootPath) return root;
|
|
15171
|
-
if (normalized.startsWith(root.rootPath +
|
|
15203
|
+
if (normalized.startsWith(root.rootPath + path31.sep)) return root;
|
|
15172
15204
|
}
|
|
15173
15205
|
return null;
|
|
15174
15206
|
}
|
|
@@ -15187,16 +15219,16 @@ function ensureInstalled() {
|
|
|
15187
15219
|
};
|
|
15188
15220
|
}
|
|
15189
15221
|
function gatedRequire(request, parent, isMain, gated, originalLoad) {
|
|
15190
|
-
if (request.startsWith("./") || request.startsWith("../") ||
|
|
15222
|
+
if (request.startsWith("./") || request.startsWith("../") || path31.isAbsolute(request)) {
|
|
15191
15223
|
let resolved;
|
|
15192
15224
|
try {
|
|
15193
|
-
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(
|
|
15225
|
+
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path31.join(gated.rootPath, "__entry__.js"));
|
|
15194
15226
|
resolved = callerRequire.resolve(request);
|
|
15195
15227
|
} catch {
|
|
15196
15228
|
return originalLoad.call(this, request, parent, isMain);
|
|
15197
15229
|
}
|
|
15198
15230
|
const resolvedCanon = canonicalize(resolved) || resolved;
|
|
15199
|
-
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath +
|
|
15231
|
+
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path31.sep))) {
|
|
15200
15232
|
denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
|
|
15201
15233
|
}
|
|
15202
15234
|
return originalLoad.call(this, request, parent, isMain);
|
|
@@ -15220,11 +15252,11 @@ function denyRequire(request, parent, reason) {
|
|
|
15220
15252
|
err.callerFilename = caller;
|
|
15221
15253
|
throw err;
|
|
15222
15254
|
}
|
|
15223
|
-
var
|
|
15255
|
+
var path31, import_node_module2, nodeFs, nodeChildProcess, SAFE_STDLIB, SHIMMED_STDLIB, ALL_GATED_STDLIB, FS_READ_ONLY_MEMBERS, FS_PROMISES_READ_ONLY_MEMBERS, FS_SHIM, CHILD_PROCESS_SHIM, DANGEROUS_PROCESS_METHODS, _processGloballyHardened, _originalProcessMethods, PROCESS_SHIM, _gatedRoots, _installed, PROVIDER_REQUIRE_POLICY;
|
|
15224
15256
|
var init_require_whitelist = __esm({
|
|
15225
15257
|
"src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
|
|
15226
15258
|
"use strict";
|
|
15227
|
-
|
|
15259
|
+
path31 = __toESM(require("path"));
|
|
15228
15260
|
import_node_module2 = require("module");
|
|
15229
15261
|
nodeFs = __toESM(require("fs"));
|
|
15230
15262
|
nodeChildProcess = __toESM(require("child_process"));
|
|
@@ -17409,10 +17441,10 @@ function getRegistryPath() {
|
|
|
17409
17441
|
return (0, import_path5.join)(getDaemonDataDir(), "mesh-coordinators.json");
|
|
17410
17442
|
}
|
|
17411
17443
|
function loadMeshCoordinatorRegistry() {
|
|
17412
|
-
const
|
|
17413
|
-
if (!(0, import_fs5.existsSync)(
|
|
17444
|
+
const path41 = getRegistryPath();
|
|
17445
|
+
if (!(0, import_fs5.existsSync)(path41)) return;
|
|
17414
17446
|
try {
|
|
17415
|
-
const raw = JSON.parse((0, import_fs5.readFileSync)(
|
|
17447
|
+
const raw = JSON.parse((0, import_fs5.readFileSync)(path41, "utf-8"));
|
|
17416
17448
|
if (!Array.isArray(raw)) return;
|
|
17417
17449
|
_registry.clear();
|
|
17418
17450
|
for (const entry of raw) {
|
|
@@ -17650,8 +17682,8 @@ function validateMeshRefineConfig(config, source = "inline") {
|
|
|
17650
17682
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
17651
17683
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
|
|
17652
17684
|
}
|
|
17653
|
-
function parseConfigText(
|
|
17654
|
-
if (/\.json$/i.test(
|
|
17685
|
+
function parseConfigText(path41, text) {
|
|
17686
|
+
if (/\.json$/i.test(path41)) return JSON.parse(text);
|
|
17655
17687
|
return yaml.load(text);
|
|
17656
17688
|
}
|
|
17657
17689
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -17809,8 +17841,8 @@ var MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA = {
|
|
|
17809
17841
|
var DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
17810
17842
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
17811
17843
|
var OUTPUT_SUMMARY_CHARS = 2e3;
|
|
17812
|
-
function parseConfigText2(
|
|
17813
|
-
if (/\.json$/i.test(
|
|
17844
|
+
function parseConfigText2(path41, text) {
|
|
17845
|
+
if (/\.json$/i.test(path41)) return JSON.parse(text);
|
|
17814
17846
|
return yaml2.load(text);
|
|
17815
17847
|
}
|
|
17816
17848
|
function truncateOutput(value) {
|
|
@@ -29538,8 +29570,8 @@ var DaemonCommandHandler = class {
|
|
|
29538
29570
|
*/
|
|
29539
29571
|
getUpstreamInstallRoot() {
|
|
29540
29572
|
const os30 = require("os");
|
|
29541
|
-
const
|
|
29542
|
-
return
|
|
29573
|
+
const path41 = require("path");
|
|
29574
|
+
return path41.join(os30.homedir(), ".adhdev", "providers", ".upstream");
|
|
29543
29575
|
}
|
|
29544
29576
|
/**
|
|
29545
29577
|
* Download a single provider manifest from the registry and write it to
|
|
@@ -29564,7 +29596,7 @@ var DaemonCommandHandler = class {
|
|
|
29564
29596
|
}
|
|
29565
29597
|
const https = require("https");
|
|
29566
29598
|
const fs30 = require("fs");
|
|
29567
|
-
const
|
|
29599
|
+
const path41 = require("path");
|
|
29568
29600
|
const crypto6 = require("crypto");
|
|
29569
29601
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
29570
29602
|
function fetchText(url, timeoutMs) {
|
|
@@ -29602,9 +29634,9 @@ var DaemonCommandHandler = class {
|
|
|
29602
29634
|
return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
|
|
29603
29635
|
}
|
|
29604
29636
|
const installRoot = this.getUpstreamInstallRoot();
|
|
29605
|
-
const installRootResolved =
|
|
29606
|
-
const targetDir =
|
|
29607
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
29637
|
+
const installRootResolved = path41.resolve(installRoot);
|
|
29638
|
+
const targetDir = path41.resolve(path41.join(installRoot, category, type));
|
|
29639
|
+
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
29608
29640
|
return { success: false, error: "install path escaped upstream root" };
|
|
29609
29641
|
}
|
|
29610
29642
|
fs30.mkdirSync(targetDir, { recursive: true });
|
|
@@ -29631,7 +29663,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29631
29663
|
}
|
|
29632
29664
|
}
|
|
29633
29665
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
29634
|
-
const targetPath =
|
|
29666
|
+
const targetPath = path41.join(targetDir, targetFile);
|
|
29635
29667
|
fs30.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
29636
29668
|
const manifestJson = JSON.parse(manifestBody);
|
|
29637
29669
|
const scriptFetch = await this.fetchProviderSources(
|
|
@@ -29703,7 +29735,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29703
29735
|
const ref = source.ref;
|
|
29704
29736
|
const https = require("https");
|
|
29705
29737
|
const fs30 = require("fs");
|
|
29706
|
-
const
|
|
29738
|
+
const path41 = require("path");
|
|
29707
29739
|
function fetchJson(url, timeoutMs) {
|
|
29708
29740
|
return new Promise((resolve24, reject) => {
|
|
29709
29741
|
const req = https.get(url, {
|
|
@@ -29759,9 +29791,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29759
29791
|
}
|
|
29760
29792
|
let fetchedCount = 0;
|
|
29761
29793
|
const sharedDirRel = `${category}/_shared`;
|
|
29762
|
-
const sharedTargetDir =
|
|
29763
|
-
const installRootResolved =
|
|
29764
|
-
if (sharedTargetDir.startsWith(installRootResolved +
|
|
29794
|
+
const sharedTargetDir = path41.resolve(path41.join(targetDir, "../_shared"));
|
|
29795
|
+
const installRootResolved = path41.resolve(path41.join(targetDir, "../.."));
|
|
29796
|
+
if (sharedTargetDir.startsWith(installRootResolved + path41.sep)) {
|
|
29765
29797
|
const sharedStack = [sharedDirRel];
|
|
29766
29798
|
while (sharedStack.length) {
|
|
29767
29799
|
const relDir = sharedStack.pop();
|
|
@@ -29784,9 +29816,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29784
29816
|
try {
|
|
29785
29817
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
29786
29818
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
29787
|
-
const outPath =
|
|
29788
|
-
if (!outPath.startsWith(
|
|
29789
|
-
fs30.mkdirSync(
|
|
29819
|
+
const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
|
|
29820
|
+
if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
|
|
29821
|
+
fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
29790
29822
|
fs30.writeFileSync(outPath, body);
|
|
29791
29823
|
fetchedCount++;
|
|
29792
29824
|
} catch (e) {
|
|
@@ -29820,12 +29852,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29820
29852
|
try {
|
|
29821
29853
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
29822
29854
|
const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
|
|
29823
|
-
const outPath =
|
|
29824
|
-
if (!outPath.startsWith(
|
|
29855
|
+
const outPath = path41.resolve(path41.join(targetDir, relInsideProvider));
|
|
29856
|
+
if (!outPath.startsWith(path41.resolve(targetDir) + path41.sep)) {
|
|
29825
29857
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
29826
29858
|
continue;
|
|
29827
29859
|
}
|
|
29828
|
-
fs30.mkdirSync(
|
|
29860
|
+
fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
29829
29861
|
fs30.writeFileSync(outPath, body);
|
|
29830
29862
|
fetchedCount++;
|
|
29831
29863
|
} catch (e) {
|
|
@@ -29855,12 +29887,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29855
29887
|
return { success: false, error: `unknown category: ${category}` };
|
|
29856
29888
|
}
|
|
29857
29889
|
const fs30 = require("fs");
|
|
29858
|
-
const
|
|
29890
|
+
const path41 = require("path");
|
|
29859
29891
|
try {
|
|
29860
29892
|
const installRoot = this.getUpstreamInstallRoot();
|
|
29861
|
-
const installRootResolved =
|
|
29862
|
-
const targetDir =
|
|
29863
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
29893
|
+
const installRootResolved = path41.resolve(installRoot);
|
|
29894
|
+
const targetDir = path41.resolve(path41.join(installRoot, category, type));
|
|
29895
|
+
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
29864
29896
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
29865
29897
|
}
|
|
29866
29898
|
if (!fs30.existsSync(targetDir)) {
|
|
@@ -29883,13 +29915,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29883
29915
|
*/
|
|
29884
29916
|
handleListInstalledProviders(_args) {
|
|
29885
29917
|
const fs30 = require("fs");
|
|
29886
|
-
const
|
|
29918
|
+
const path41 = require("path");
|
|
29887
29919
|
const installRoot = this.getUpstreamInstallRoot();
|
|
29888
29920
|
if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
|
|
29889
29921
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
29890
29922
|
const items = [];
|
|
29891
29923
|
for (const category of CATEGORIES) {
|
|
29892
|
-
const categoryDir =
|
|
29924
|
+
const categoryDir = path41.join(installRoot, category);
|
|
29893
29925
|
if (!fs30.existsSync(categoryDir)) continue;
|
|
29894
29926
|
let entries;
|
|
29895
29927
|
try {
|
|
@@ -29898,8 +29930,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
29898
29930
|
continue;
|
|
29899
29931
|
}
|
|
29900
29932
|
for (const type of entries) {
|
|
29901
|
-
const v1Path =
|
|
29902
|
-
const v0Path =
|
|
29933
|
+
const v1Path = path41.join(categoryDir, type, "provider.v1.json");
|
|
29934
|
+
const v0Path = path41.join(categoryDir, type, "provider.json");
|
|
29903
29935
|
const manifestPath = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
|
|
29904
29936
|
if (!manifestPath) continue;
|
|
29905
29937
|
try {
|
|
@@ -30015,7 +30047,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
30015
30047
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
30016
30048
|
}
|
|
30017
30049
|
const fs30 = require("fs");
|
|
30018
|
-
const
|
|
30050
|
+
const path41 = require("path");
|
|
30019
30051
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
30020
30052
|
const file = ext.loadExternalSources();
|
|
30021
30053
|
if (file.sources.some((s) => s.name === requestedName)) {
|
|
@@ -30024,7 +30056,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
30024
30056
|
if (file.sources.some((s) => s.url === url && s.ref === ref)) {
|
|
30025
30057
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
30026
30058
|
}
|
|
30027
|
-
const sourceDir =
|
|
30059
|
+
const sourceDir = path41.join(ext.externalRoot(), requestedName);
|
|
30028
30060
|
if (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
30029
30061
|
if (fs30.existsSync(sourceDir)) {
|
|
30030
30062
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
@@ -30081,11 +30113,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
30081
30113
|
if (!name) return { success: false, error: "name is required" };
|
|
30082
30114
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
30083
30115
|
const fs30 = require("fs");
|
|
30084
|
-
const
|
|
30116
|
+
const path41 = require("path");
|
|
30085
30117
|
const file = ext.loadExternalSources();
|
|
30086
30118
|
const match = file.sources.find((s) => s.name === name);
|
|
30087
30119
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
30088
|
-
const sourceDir =
|
|
30120
|
+
const sourceDir = path41.join(ext.externalRoot(), name);
|
|
30089
30121
|
if (fs30.existsSync(sourceDir)) {
|
|
30090
30122
|
try {
|
|
30091
30123
|
fs30.rmSync(sourceDir, { recursive: true, force: true });
|
|
@@ -30263,10 +30295,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
30263
30295
|
|
|
30264
30296
|
// src/commands/cli-manager.ts
|
|
30265
30297
|
var os19 = __toESM(require("os"));
|
|
30266
|
-
var
|
|
30298
|
+
var path25 = __toESM(require("path"));
|
|
30267
30299
|
var crypto5 = __toESM(require("crypto"));
|
|
30268
|
-
var
|
|
30269
|
-
var
|
|
30300
|
+
var import_fs14 = require("fs");
|
|
30301
|
+
var import_child_process6 = require("child_process");
|
|
30270
30302
|
var import_chalk = __toESM(require("chalk"));
|
|
30271
30303
|
init_provider_cli_adapter();
|
|
30272
30304
|
init_cli_detector();
|
|
@@ -30274,20 +30306,20 @@ init_config();
|
|
|
30274
30306
|
|
|
30275
30307
|
// src/providers/cli-provider-instance.ts
|
|
30276
30308
|
var os18 = __toESM(require("os"));
|
|
30277
|
-
var
|
|
30309
|
+
var path23 = __toESM(require("path"));
|
|
30278
30310
|
var crypto4 = __toESM(require("crypto"));
|
|
30279
30311
|
var fs15 = __toESM(require("fs"));
|
|
30280
30312
|
var import_node_module = require("module");
|
|
30281
30313
|
|
|
30282
30314
|
// src/providers/spec/route.ts
|
|
30283
30315
|
var fs14 = __toESM(require("fs"));
|
|
30284
|
-
var
|
|
30316
|
+
var path22 = __toESM(require("path"));
|
|
30285
30317
|
init_provider_cli_adapter();
|
|
30286
30318
|
|
|
30287
30319
|
// src/providers/spec/fsm-driver.ts
|
|
30288
30320
|
var fs11 = __toESM(require("fs"));
|
|
30289
30321
|
var os16 = __toESM(require("os"));
|
|
30290
|
-
var
|
|
30322
|
+
var path20 = __toESM(require("path"));
|
|
30291
30323
|
|
|
30292
30324
|
// src/providers/spec/adapter.ts
|
|
30293
30325
|
init_terminal_screen();
|
|
@@ -30413,18 +30445,18 @@ init_fsm_loader();
|
|
|
30413
30445
|
// src/providers/spec/pre-launch-trust.ts
|
|
30414
30446
|
var fs10 = __toESM(require("fs"));
|
|
30415
30447
|
var os15 = __toESM(require("os"));
|
|
30416
|
-
var
|
|
30448
|
+
var path19 = __toESM(require("path"));
|
|
30417
30449
|
init_logger();
|
|
30418
30450
|
function expandHome2(p) {
|
|
30419
30451
|
if (p === "~") return os15.homedir();
|
|
30420
|
-
if (p.startsWith("~/")) return
|
|
30452
|
+
if (p.startsWith("~/")) return path19.join(os15.homedir(), p.slice(2));
|
|
30421
30453
|
return p;
|
|
30422
30454
|
}
|
|
30423
30455
|
function realWorkspacePath(workingDir) {
|
|
30424
30456
|
try {
|
|
30425
30457
|
return fs10.realpathSync(workingDir);
|
|
30426
30458
|
} catch {
|
|
30427
|
-
return
|
|
30459
|
+
return path19.resolve(workingDir);
|
|
30428
30460
|
}
|
|
30429
30461
|
}
|
|
30430
30462
|
function applyPreLaunchTrust(trust, workingDir) {
|
|
@@ -30450,7 +30482,7 @@ function applyPreLaunchTrust(trust, workingDir) {
|
|
|
30450
30482
|
}
|
|
30451
30483
|
list.push(real);
|
|
30452
30484
|
parsed[key] = list;
|
|
30453
|
-
fs10.mkdirSync(
|
|
30485
|
+
fs10.mkdirSync(path19.dirname(settingsPath), { recursive: true });
|
|
30454
30486
|
fs10.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
|
|
30455
30487
|
`, "utf8");
|
|
30456
30488
|
LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
|
|
@@ -30699,8 +30731,8 @@ var FsmDriver = class {
|
|
|
30699
30731
|
}
|
|
30700
30732
|
armSpecWatcher() {
|
|
30701
30733
|
try {
|
|
30702
|
-
const dir =
|
|
30703
|
-
const base =
|
|
30734
|
+
const dir = path20.dirname(this.opts.specPath);
|
|
30735
|
+
const base = path20.basename(this.opts.specPath);
|
|
30704
30736
|
this.specWatcher = fs11.watch(dir, { persistent: false }, (_event, filename) => {
|
|
30705
30737
|
if (filename && filename !== base) return;
|
|
30706
30738
|
const res = loadFsmSpec(this.opts.specPath);
|
|
@@ -31001,7 +31033,7 @@ var FsmDriver = class {
|
|
|
31001
31033
|
const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
|
|
31002
31034
|
if (!ctl || ctl.action.type !== "attach_image") return;
|
|
31003
31035
|
const ext = guessExt(mime);
|
|
31004
|
-
const tmp =
|
|
31036
|
+
const tmp = path20.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
31005
31037
|
try {
|
|
31006
31038
|
fs11.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
31007
31039
|
} catch {
|
|
@@ -31111,7 +31143,7 @@ function collectStableSizes(when, sizes) {
|
|
|
31111
31143
|
// src/providers/spec/native-history-executor.ts
|
|
31112
31144
|
var fs12 = __toESM(require("fs"));
|
|
31113
31145
|
var os17 = __toESM(require("os"));
|
|
31114
|
-
var
|
|
31146
|
+
var path21 = __toESM(require("path"));
|
|
31115
31147
|
var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
31116
31148
|
function executeNativeHistory(cfg, input) {
|
|
31117
31149
|
if (!cfg?.source) return null;
|
|
@@ -31155,7 +31187,7 @@ function executeJsonl(src, input) {
|
|
|
31155
31187
|
const v = jsonPathGet(lines[0], src.session_id_path);
|
|
31156
31188
|
if (typeof v === "string" && v) providerSessionId = v;
|
|
31157
31189
|
} else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
|
|
31158
|
-
const m =
|
|
31190
|
+
const m = path21.basename(sourcePath).match(UUID_RE);
|
|
31159
31191
|
if (m) providerSessionId = m[1];
|
|
31160
31192
|
}
|
|
31161
31193
|
const requested = requestedSessionId || "";
|
|
@@ -31268,13 +31300,13 @@ function expandPath2(template, input) {
|
|
|
31268
31300
|
if (!template) return null;
|
|
31269
31301
|
let out = template;
|
|
31270
31302
|
if (out.startsWith("~/") || out === "~") {
|
|
31271
|
-
out =
|
|
31303
|
+
out = path21.join(os17.homedir(), out.slice(2));
|
|
31272
31304
|
}
|
|
31273
31305
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
31274
31306
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
31275
31307
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
31276
31308
|
});
|
|
31277
|
-
if (out.startsWith("~/")) out =
|
|
31309
|
+
if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
|
|
31278
31310
|
const now = /* @__PURE__ */ new Date();
|
|
31279
31311
|
const workspaceRaw = input.workspace ?? "";
|
|
31280
31312
|
let workspaceResolved = workspaceRaw;
|
|
@@ -31331,12 +31363,12 @@ function expandDirGlob(template) {
|
|
|
31331
31363
|
continue;
|
|
31332
31364
|
}
|
|
31333
31365
|
for (const e of entries) {
|
|
31334
|
-
if (e.isDirectory() && re.test(e.name)) next.push(
|
|
31366
|
+
if (e.isDirectory() && re.test(e.name)) next.push(path21.join(d, e.name));
|
|
31335
31367
|
}
|
|
31336
31368
|
}
|
|
31337
31369
|
} else {
|
|
31338
31370
|
for (const d of dirs) {
|
|
31339
|
-
const candidate =
|
|
31371
|
+
const candidate = path21.join(d, seg);
|
|
31340
31372
|
let stat2 = null;
|
|
31341
31373
|
try {
|
|
31342
31374
|
stat2 = fs12.statSync(candidate);
|
|
@@ -31359,7 +31391,7 @@ function walkAllDirs(root, out) {
|
|
|
31359
31391
|
}
|
|
31360
31392
|
out.push(root);
|
|
31361
31393
|
for (const e of entries) {
|
|
31362
|
-
if (e.isDirectory()) walkAllDirs(
|
|
31394
|
+
if (e.isDirectory()) walkAllDirs(path21.join(root, e.name), out);
|
|
31363
31395
|
}
|
|
31364
31396
|
}
|
|
31365
31397
|
function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
|
|
@@ -31375,7 +31407,7 @@ function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs
|
|
|
31375
31407
|
}
|
|
31376
31408
|
for (const e of entries) {
|
|
31377
31409
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
31378
|
-
const p =
|
|
31410
|
+
const p = path21.join(d, e.name);
|
|
31379
31411
|
const mtime = safeMtimeMs(p);
|
|
31380
31412
|
if (mtime < cutoff) continue;
|
|
31381
31413
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -31402,7 +31434,7 @@ function newestRecentFileAcrossDateWindow(template, input, pattern, windowMs, se
|
|
|
31402
31434
|
}
|
|
31403
31435
|
for (const e of entries) {
|
|
31404
31436
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
31405
|
-
const p =
|
|
31437
|
+
const p = path21.join(resolved, e.name);
|
|
31406
31438
|
const mtime = safeMtimeMs(p);
|
|
31407
31439
|
if (mtime < cutoff) continue;
|
|
31408
31440
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -31414,13 +31446,13 @@ function expandPathForDate(template, input, day) {
|
|
|
31414
31446
|
if (!template) return null;
|
|
31415
31447
|
let out = template;
|
|
31416
31448
|
if (out.startsWith("~/") || out === "~") {
|
|
31417
|
-
out =
|
|
31449
|
+
out = path21.join(os17.homedir(), out.slice(2));
|
|
31418
31450
|
}
|
|
31419
31451
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
31420
31452
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
31421
31453
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
31422
31454
|
});
|
|
31423
|
-
if (out.startsWith("~/")) out =
|
|
31455
|
+
if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
|
|
31424
31456
|
const workspaceRaw = input.workspace ?? "";
|
|
31425
31457
|
let workspaceResolved = workspaceRaw;
|
|
31426
31458
|
if (workspaceRaw) {
|
|
@@ -31458,7 +31490,7 @@ function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
|
31458
31490
|
let best = null;
|
|
31459
31491
|
for (const e of entries) {
|
|
31460
31492
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
31461
|
-
const p =
|
|
31493
|
+
const p = path21.join(dir, e.name);
|
|
31462
31494
|
const mtime = safeMtimeMs(p);
|
|
31463
31495
|
if (mtime < cutoff) continue;
|
|
31464
31496
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -31478,7 +31510,7 @@ function readRequestedSessionId(input) {
|
|
|
31478
31510
|
return UUID_RE.test(value) ? value : "";
|
|
31479
31511
|
}
|
|
31480
31512
|
function filenameUuid(filePath) {
|
|
31481
|
-
const match =
|
|
31513
|
+
const match = path21.basename(filePath).match(UUID_RE);
|
|
31482
31514
|
return match?.[1] || "";
|
|
31483
31515
|
}
|
|
31484
31516
|
function pickExactSessionFile(dir, pattern, requestedSessionId) {
|
|
@@ -31573,7 +31605,7 @@ function listMatchingFiles(dir, pattern) {
|
|
|
31573
31605
|
const out = [];
|
|
31574
31606
|
for (const e of entries) {
|
|
31575
31607
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
31576
|
-
out.push(
|
|
31608
|
+
out.push(path21.join(dir, e.name));
|
|
31577
31609
|
}
|
|
31578
31610
|
return out;
|
|
31579
31611
|
}
|
|
@@ -32515,12 +32547,12 @@ function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFact
|
|
|
32515
32547
|
const dir = provider._resolvedProviderDir;
|
|
32516
32548
|
let specPath = resolvedSpecPath && fs14.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
32517
32549
|
if (!specPath && dir) {
|
|
32518
|
-
const legacy =
|
|
32550
|
+
const legacy = path22.join(dir, "spec.json");
|
|
32519
32551
|
if (fs14.existsSync(legacy)) specPath = legacy;
|
|
32520
32552
|
}
|
|
32521
32553
|
if (specPath) {
|
|
32522
32554
|
try {
|
|
32523
|
-
LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${
|
|
32555
|
+
LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path22.relative(dir || "", specPath) || specPath})`);
|
|
32524
32556
|
return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
|
|
32525
32557
|
} catch (err) {
|
|
32526
32558
|
LOG.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
|
|
@@ -32587,7 +32619,7 @@ function filePathFromUri(uri) {
|
|
|
32587
32619
|
return uri.slice("file://".length);
|
|
32588
32620
|
}
|
|
32589
32621
|
}
|
|
32590
|
-
if (
|
|
32622
|
+
if (path23.isAbsolute(uri)) return uri;
|
|
32591
32623
|
return null;
|
|
32592
32624
|
}
|
|
32593
32625
|
function extensionForImageMime(mimeType) {
|
|
@@ -32603,7 +32635,7 @@ function materializeImageDataPart(part, index, dir) {
|
|
|
32603
32635
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
32604
32636
|
if (!rawData) return null;
|
|
32605
32637
|
fs15.mkdirSync(dir, { recursive: true });
|
|
32606
|
-
const filePath =
|
|
32638
|
+
const filePath = path23.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
32607
32639
|
fs15.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
32608
32640
|
cleanupStaleMaterializedImages(dir);
|
|
32609
32641
|
return filePath;
|
|
@@ -32619,7 +32651,7 @@ function cleanupStaleMaterializedImages(dir) {
|
|
|
32619
32651
|
const entries = fs15.readdirSync(dir);
|
|
32620
32652
|
for (const entry of entries) {
|
|
32621
32653
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
32622
|
-
const fullPath =
|
|
32654
|
+
const fullPath = path23.join(dir, entry);
|
|
32623
32655
|
try {
|
|
32624
32656
|
const stat2 = fs15.statSync(fullPath);
|
|
32625
32657
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
@@ -32642,7 +32674,7 @@ function buildCliStructuredInputPrompt(input, options = {}) {
|
|
|
32642
32674
|
const promptParts = [];
|
|
32643
32675
|
const imageRefs = [];
|
|
32644
32676
|
const resourceRefs = [];
|
|
32645
|
-
const materializeDir = options.materializeDir ||
|
|
32677
|
+
const materializeDir = options.materializeDir || path23.join(os18.tmpdir(), "adhdev-input-media");
|
|
32646
32678
|
input.parts.forEach((part, index) => {
|
|
32647
32679
|
if (part.type === "text" && part.text.trim()) {
|
|
32648
32680
|
promptParts.push(part.text.trim());
|
|
@@ -32709,7 +32741,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
|
|
|
32709
32741
|
var CachedDatabaseSync = null;
|
|
32710
32742
|
function getDatabaseSync() {
|
|
32711
32743
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
32712
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
32744
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path23.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
32713
32745
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
32714
32746
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
32715
32747
|
if (!CachedDatabaseSync) {
|
|
@@ -34346,9 +34378,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
34346
34378
|
};
|
|
34347
34379
|
|
|
34348
34380
|
// src/providers/acp-provider-instance.ts
|
|
34349
|
-
var
|
|
34381
|
+
var path24 = __toESM(require("path"));
|
|
34350
34382
|
var import_stream = require("stream");
|
|
34351
|
-
var
|
|
34383
|
+
var import_child_process5 = require("child_process");
|
|
34352
34384
|
var import_sdk = require("@agentclientprotocol/sdk");
|
|
34353
34385
|
init_logger();
|
|
34354
34386
|
function getPromptCapabilityFlags(agentCapabilities) {
|
|
@@ -34867,7 +34899,7 @@ var AcpProviderInstance = class {
|
|
|
34867
34899
|
this.errorMessage = null;
|
|
34868
34900
|
this.errorReason = null;
|
|
34869
34901
|
this.stderrBuffer = [];
|
|
34870
|
-
this.process = (0,
|
|
34902
|
+
this.process = (0, import_child_process5.spawn)(command, args, {
|
|
34871
34903
|
cwd: this.workingDir,
|
|
34872
34904
|
env,
|
|
34873
34905
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -35132,7 +35164,7 @@ var AcpProviderInstance = class {
|
|
|
35132
35164
|
return b.uri ? {
|
|
35133
35165
|
type: "resource_link",
|
|
35134
35166
|
uri: b.uri,
|
|
35135
|
-
name:
|
|
35167
|
+
name: path24.basename(b.uri),
|
|
35136
35168
|
mimeType: b.mimeType,
|
|
35137
35169
|
...b.transcript ? { description: b.transcript } : {}
|
|
35138
35170
|
} : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
|
|
@@ -35592,20 +35624,20 @@ function shouldRestoreHostedRuntime(record, managerTag) {
|
|
|
35592
35624
|
// src/commands/cli-manager.ts
|
|
35593
35625
|
function isExplicitCommand(command) {
|
|
35594
35626
|
const trimmed = command.trim();
|
|
35595
|
-
return
|
|
35627
|
+
return path25.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
35596
35628
|
}
|
|
35597
35629
|
function expandExecutable(command) {
|
|
35598
35630
|
const trimmed = command.trim();
|
|
35599
|
-
return trimmed.startsWith("~") ?
|
|
35631
|
+
return trimmed.startsWith("~") ? path25.join(os19.homedir(), trimmed.slice(1)) : trimmed;
|
|
35600
35632
|
}
|
|
35601
35633
|
function commandExists(command) {
|
|
35602
35634
|
const trimmed = command.trim();
|
|
35603
35635
|
if (!trimmed) return false;
|
|
35604
35636
|
if (isExplicitCommand(trimmed)) {
|
|
35605
|
-
return (0,
|
|
35637
|
+
return (0, import_fs14.existsSync)(expandExecutable(trimmed));
|
|
35606
35638
|
}
|
|
35607
35639
|
try {
|
|
35608
|
-
(0,
|
|
35640
|
+
(0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
35609
35641
|
stdio: "ignore",
|
|
35610
35642
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
35611
35643
|
});
|
|
@@ -35737,11 +35769,11 @@ function hasConfigOverride(args, key) {
|
|
|
35737
35769
|
return false;
|
|
35738
35770
|
}
|
|
35739
35771
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
35740
|
-
const baseDir =
|
|
35741
|
-
(0,
|
|
35742
|
-
const workspaceHash = crypto5.createHash("sha256").update(
|
|
35743
|
-
const filePath =
|
|
35744
|
-
(0,
|
|
35772
|
+
const baseDir = path25.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
35773
|
+
(0, import_fs14.mkdirSync)(baseDir, { recursive: true });
|
|
35774
|
+
const workspaceHash = crypto5.createHash("sha256").update(path25.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
|
|
35775
|
+
const filePath = path25.join(baseDir, `${workspaceHash}.json`);
|
|
35776
|
+
(0, import_fs14.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
35745
35777
|
return filePath;
|
|
35746
35778
|
}
|
|
35747
35779
|
function buildCoordinatorDelegatedCliLaunchOptions(input) {
|
|
@@ -36054,7 +36086,7 @@ var DaemonCliManager = class {
|
|
|
36054
36086
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
36055
36087
|
const trimmed = (workingDir || "").trim();
|
|
36056
36088
|
if (!trimmed) throw new Error("working directory required");
|
|
36057
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) :
|
|
36089
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path25.resolve(trimmed);
|
|
36058
36090
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
36059
36091
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
36060
36092
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -36656,14 +36688,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
36656
36688
|
};
|
|
36657
36689
|
|
|
36658
36690
|
// src/launch.ts
|
|
36659
|
-
var
|
|
36691
|
+
var import_child_process7 = require("child_process");
|
|
36660
36692
|
var net = __toESM(require("net"));
|
|
36661
36693
|
var os24 = __toESM(require("os"));
|
|
36662
|
-
var
|
|
36694
|
+
var path33 = __toESM(require("path"));
|
|
36663
36695
|
|
|
36664
36696
|
// src/providers/provider-loader.ts
|
|
36665
36697
|
var fs21 = __toESM(require("fs"));
|
|
36666
|
-
var
|
|
36698
|
+
var path32 = __toESM(require("path"));
|
|
36667
36699
|
var os23 = __toESM(require("os"));
|
|
36668
36700
|
var chokidar = __toESM(require("chokidar"));
|
|
36669
36701
|
init_logger();
|
|
@@ -37056,11 +37088,11 @@ init_external_sources();
|
|
|
37056
37088
|
// src/providers/native-history/dispatcher.ts
|
|
37057
37089
|
var fs20 = __toESM(require("fs"));
|
|
37058
37090
|
var os22 = __toESM(require("os"));
|
|
37059
|
-
var
|
|
37091
|
+
var path30 = __toESM(require("path"));
|
|
37060
37092
|
|
|
37061
37093
|
// src/providers/native-history/claude-cli-transcript.ts
|
|
37062
37094
|
var fs16 = __toESM(require("fs"));
|
|
37063
|
-
var
|
|
37095
|
+
var path26 = __toESM(require("path"));
|
|
37064
37096
|
function extractTimestampValue(value) {
|
|
37065
37097
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
37066
37098
|
if (typeof value === "string") {
|
|
@@ -37216,8 +37248,8 @@ function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
|
37216
37248
|
return records;
|
|
37217
37249
|
}
|
|
37218
37250
|
function readSession(sessionPath) {
|
|
37219
|
-
if (!sessionPath || !
|
|
37220
|
-
const basename14 =
|
|
37251
|
+
if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
|
|
37252
|
+
const basename14 = path26.basename(sessionPath, ".jsonl");
|
|
37221
37253
|
if (!isSafeSessionId(basename14)) return null;
|
|
37222
37254
|
if (!fs16.existsSync(sessionPath)) return null;
|
|
37223
37255
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
@@ -37238,7 +37270,7 @@ function readSession(sessionPath) {
|
|
|
37238
37270
|
|
|
37239
37271
|
// src/providers/native-history/codex-cli-transcript.ts
|
|
37240
37272
|
var fs17 = __toESM(require("fs"));
|
|
37241
|
-
var
|
|
37273
|
+
var path27 = __toESM(require("path"));
|
|
37242
37274
|
function extractTimestampValue2(value) {
|
|
37243
37275
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
37244
37276
|
if (typeof value === "string") {
|
|
@@ -37475,11 +37507,11 @@ function parseSessionFile(filePath, sessionId, workspaceFallback) {
|
|
|
37475
37507
|
return records;
|
|
37476
37508
|
}
|
|
37477
37509
|
function readSession2(sessionPath) {
|
|
37478
|
-
if (!sessionPath || !
|
|
37510
|
+
if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
|
|
37479
37511
|
if (!fs17.existsSync(sessionPath)) return null;
|
|
37480
37512
|
const meta = readSessionMeta(sessionPath);
|
|
37481
37513
|
const metaId = String(meta?.id ?? "").trim();
|
|
37482
|
-
const basename14 =
|
|
37514
|
+
const basename14 = path27.basename(sessionPath, ".jsonl");
|
|
37483
37515
|
const uuidMatch = basename14.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
37484
37516
|
const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
|
|
37485
37517
|
if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
|
|
@@ -37504,7 +37536,7 @@ function readSession2(sessionPath) {
|
|
|
37504
37536
|
|
|
37505
37537
|
// src/providers/native-history/antigravity-cli-transcript.ts
|
|
37506
37538
|
var fs18 = __toESM(require("fs"));
|
|
37507
|
-
var
|
|
37539
|
+
var path28 = __toESM(require("path"));
|
|
37508
37540
|
var os20 = __toESM(require("os"));
|
|
37509
37541
|
function extractTimestampValue3(value) {
|
|
37510
37542
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -37527,13 +37559,13 @@ function isUuidLike(value) {
|
|
|
37527
37559
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
37528
37560
|
}
|
|
37529
37561
|
function antigravityRoot() {
|
|
37530
|
-
return
|
|
37562
|
+
return path28.join(os20.homedir(), ".gemini", "antigravity-cli");
|
|
37531
37563
|
}
|
|
37532
37564
|
function historyJsonlPath() {
|
|
37533
|
-
return
|
|
37565
|
+
return path28.join(antigravityRoot(), "history.jsonl");
|
|
37534
37566
|
}
|
|
37535
37567
|
function brainRoot() {
|
|
37536
|
-
return
|
|
37568
|
+
return path28.join(antigravityRoot(), "brain");
|
|
37537
37569
|
}
|
|
37538
37570
|
function extractUserRequestContent(content) {
|
|
37539
37571
|
const raw = content.trim();
|
|
@@ -37680,13 +37712,13 @@ function parsePbFile(filePath, sessionId) {
|
|
|
37680
37712
|
];
|
|
37681
37713
|
}
|
|
37682
37714
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
37683
|
-
if (!sessionPath || !
|
|
37715
|
+
if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
|
|
37684
37716
|
if (!fs18.existsSync(sessionPath)) return null;
|
|
37685
37717
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
37686
37718
|
const brainRootPath = brainRoot();
|
|
37687
|
-
if (sessionPath.startsWith(brainRootPath +
|
|
37719
|
+
if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
|
|
37688
37720
|
const relative5 = sessionPath.slice(brainRootPath.length + 1);
|
|
37689
|
-
const uuidFromPath = relative5.split(
|
|
37721
|
+
const uuidFromPath = relative5.split(path28.sep)[0];
|
|
37690
37722
|
const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
|
|
37691
37723
|
if (!resolvedSessionId) return null;
|
|
37692
37724
|
const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
|
|
@@ -37702,7 +37734,7 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
37702
37734
|
};
|
|
37703
37735
|
}
|
|
37704
37736
|
if (sessionPath.endsWith(".pb")) {
|
|
37705
|
-
const pbSessionId = sessionId ||
|
|
37737
|
+
const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
|
|
37706
37738
|
if (!isUuidLike(pbSessionId)) return null;
|
|
37707
37739
|
const messages = parsePbFile(sessionPath, pbSessionId);
|
|
37708
37740
|
if (!messages || messages.length === 0) return null;
|
|
@@ -37716,7 +37748,7 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
37716
37748
|
partialReason: "antigravity_cli_pb_raw_text_extraction"
|
|
37717
37749
|
};
|
|
37718
37750
|
}
|
|
37719
|
-
if (
|
|
37751
|
+
if (path28.basename(sessionPath) === "history.jsonl") {
|
|
37720
37752
|
const resolvedSessionId = sessionId || "";
|
|
37721
37753
|
if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
|
|
37722
37754
|
const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
|
|
@@ -37764,10 +37796,10 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
37764
37796
|
|
|
37765
37797
|
// src/providers/native-history/hermes-cli-transcript.ts
|
|
37766
37798
|
var fs19 = __toESM(require("fs"));
|
|
37767
|
-
var
|
|
37799
|
+
var path29 = __toESM(require("path"));
|
|
37768
37800
|
var os21 = __toESM(require("os"));
|
|
37769
|
-
var HERMES_STATE_DB =
|
|
37770
|
-
var HERMES_LEGACY_SESSIONS_DIR =
|
|
37801
|
+
var HERMES_STATE_DB = path29.join(os21.homedir(), ".hermes", "state.db");
|
|
37802
|
+
var HERMES_LEGACY_SESSIONS_DIR = path29.join(os21.homedir(), ".hermes", "sessions");
|
|
37771
37803
|
function statMtimeMs4(p) {
|
|
37772
37804
|
try {
|
|
37773
37805
|
return Math.floor(fs19.statSync(p).mtimeMs);
|
|
@@ -37833,7 +37865,7 @@ function readSession4(sessionPath) {
|
|
|
37833
37865
|
}
|
|
37834
37866
|
}
|
|
37835
37867
|
}
|
|
37836
|
-
if (!
|
|
37868
|
+
if (!path29.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
|
|
37837
37869
|
let raw;
|
|
37838
37870
|
try {
|
|
37839
37871
|
raw = JSON.parse(fs19.readFileSync(sessionPath, "utf8"));
|
|
@@ -37859,7 +37891,7 @@ function readSession4(sessionPath) {
|
|
|
37859
37891
|
});
|
|
37860
37892
|
}
|
|
37861
37893
|
if (messages.length === 0) return null;
|
|
37862
|
-
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id :
|
|
37894
|
+
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
|
|
37863
37895
|
return {
|
|
37864
37896
|
messages,
|
|
37865
37897
|
providerSessionId: sessionId,
|
|
@@ -37925,10 +37957,10 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
|
|
|
37925
37957
|
}
|
|
37926
37958
|
}
|
|
37927
37959
|
function resolveClaudePath(workspace, sessionId) {
|
|
37928
|
-
const dir =
|
|
37960
|
+
const dir = path30.join(os22.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
37929
37961
|
if (!fs20.existsSync(dir)) return null;
|
|
37930
37962
|
if (sessionId) {
|
|
37931
|
-
const candidate =
|
|
37963
|
+
const candidate = path30.join(dir, `${sessionId}.jsonl`);
|
|
37932
37964
|
if (fs20.existsSync(candidate)) return candidate;
|
|
37933
37965
|
}
|
|
37934
37966
|
return null;
|
|
@@ -37954,7 +37986,7 @@ function findCodexPathBySessionId(root, sessionId) {
|
|
|
37954
37986
|
continue;
|
|
37955
37987
|
}
|
|
37956
37988
|
for (const entry of entries) {
|
|
37957
|
-
const entryPath =
|
|
37989
|
+
const entryPath = path30.join(current, entry.name);
|
|
37958
37990
|
if (entry.isDirectory()) {
|
|
37959
37991
|
stack.push(entryPath);
|
|
37960
37992
|
continue;
|
|
@@ -37984,7 +38016,7 @@ function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
|
37984
38016
|
continue;
|
|
37985
38017
|
}
|
|
37986
38018
|
for (const entry of entries) {
|
|
37987
|
-
const entryPath =
|
|
38019
|
+
const entryPath = path30.join(current, entry.name);
|
|
37988
38020
|
if (entry.isDirectory()) {
|
|
37989
38021
|
stack.push(entryPath);
|
|
37990
38022
|
continue;
|
|
@@ -38037,12 +38069,12 @@ function resolveRealPath(value) {
|
|
|
38037
38069
|
}
|
|
38038
38070
|
function resolveAntigravityPath(workspace) {
|
|
38039
38071
|
void workspace;
|
|
38040
|
-
const brainRoot2 =
|
|
38072
|
+
const brainRoot2 = path30.join(os22.homedir(), ".gemini", "antigravity-cli", "brain");
|
|
38041
38073
|
if (!fs20.existsSync(brainRoot2)) return null;
|
|
38042
38074
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
38043
|
-
const entries = fs20.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p:
|
|
38075
|
+
const entries = fs20.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path30.join(brainRoot2, e.name), mtime: safeMtime(path30.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
38044
38076
|
for (const e of entries) {
|
|
38045
|
-
const t =
|
|
38077
|
+
const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
38046
38078
|
if (fs20.existsSync(t)) return t;
|
|
38047
38079
|
}
|
|
38048
38080
|
return null;
|
|
@@ -38050,9 +38082,9 @@ function resolveAntigravityPath(workspace) {
|
|
|
38050
38082
|
function resolveHermesPath(workspace, sessionId) {
|
|
38051
38083
|
void workspace;
|
|
38052
38084
|
void sessionId;
|
|
38053
|
-
const dbPath =
|
|
38085
|
+
const dbPath = path30.join(os22.homedir(), ".hermes", "state.db");
|
|
38054
38086
|
if (fs20.existsSync(dbPath)) return dbPath;
|
|
38055
|
-
const dir =
|
|
38087
|
+
const dir = path30.join(os22.homedir(), ".hermes", "sessions");
|
|
38056
38088
|
if (!fs20.existsSync(dir)) return null;
|
|
38057
38089
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
38058
38090
|
}
|
|
@@ -38073,7 +38105,7 @@ function cwdAsDashes(cwd) {
|
|
|
38073
38105
|
return cwd.replace(/\//g, "-");
|
|
38074
38106
|
}
|
|
38075
38107
|
function codexSessionsRoot() {
|
|
38076
|
-
return
|
|
38108
|
+
return path30.join(os22.homedir(), ".codex", "sessions");
|
|
38077
38109
|
}
|
|
38078
38110
|
function isUuidLikeSessionId2(sessionId) {
|
|
38079
38111
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
|
|
@@ -38085,7 +38117,7 @@ var RECENT_WINDOW_MS = 5 * 60 * 1e3;
|
|
|
38085
38117
|
function newestRecentFile2(dir, pattern) {
|
|
38086
38118
|
try {
|
|
38087
38119
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
38088
|
-
const entries = fs20.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p:
|
|
38120
|
+
const entries = fs20.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path30.join(dir, e.name), mtime: safeMtime(path30.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
38089
38121
|
return entries[0]?.p ?? null;
|
|
38090
38122
|
} catch {
|
|
38091
38123
|
return null;
|
|
@@ -38148,7 +38180,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38148
38180
|
try {
|
|
38149
38181
|
if (!fs21.existsSync(candidate) || !fs21.statSync(candidate).isDirectory()) return false;
|
|
38150
38182
|
return ["ide", "extension", "cli", "acp"].some(
|
|
38151
|
-
(category) => fs21.existsSync(
|
|
38183
|
+
(category) => fs21.existsSync(path32.join(candidate, category))
|
|
38152
38184
|
);
|
|
38153
38185
|
} catch {
|
|
38154
38186
|
return false;
|
|
@@ -38156,20 +38188,20 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38156
38188
|
}
|
|
38157
38189
|
static hasProviderRootMarker(candidate) {
|
|
38158
38190
|
try {
|
|
38159
|
-
return fs21.existsSync(
|
|
38191
|
+
return fs21.existsSync(path32.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
38160
38192
|
} catch {
|
|
38161
38193
|
return false;
|
|
38162
38194
|
}
|
|
38163
38195
|
}
|
|
38164
38196
|
detectDefaultUserDir() {
|
|
38165
|
-
const fallback =
|
|
38197
|
+
const fallback = path32.join(os23.homedir(), ".adhdev", "providers");
|
|
38166
38198
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
38167
38199
|
const visited = /* @__PURE__ */ new Set();
|
|
38168
38200
|
for (const start of this.probeStarts) {
|
|
38169
|
-
let current =
|
|
38201
|
+
let current = path32.resolve(start);
|
|
38170
38202
|
while (!visited.has(current)) {
|
|
38171
38203
|
visited.add(current);
|
|
38172
|
-
const siblingCandidate =
|
|
38204
|
+
const siblingCandidate = path32.join(path32.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
38173
38205
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
38174
38206
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
38175
38207
|
if (envOptIn || hasMarker) {
|
|
@@ -38191,7 +38223,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38191
38223
|
return { path: siblingCandidate, source };
|
|
38192
38224
|
}
|
|
38193
38225
|
}
|
|
38194
|
-
const parent =
|
|
38226
|
+
const parent = path32.dirname(current);
|
|
38195
38227
|
if (parent === current) break;
|
|
38196
38228
|
current = parent;
|
|
38197
38229
|
}
|
|
@@ -38201,11 +38233,11 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38201
38233
|
constructor(options) {
|
|
38202
38234
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
38203
38235
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
38204
|
-
this.defaultProvidersDir =
|
|
38236
|
+
this.defaultProvidersDir = path32.join(os23.homedir(), ".adhdev", "providers");
|
|
38205
38237
|
const detected = this.detectDefaultUserDir();
|
|
38206
38238
|
this.userDir = detected.path;
|
|
38207
38239
|
this.userDirSource = detected.source;
|
|
38208
|
-
this.upstreamDir =
|
|
38240
|
+
this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
|
|
38209
38241
|
this.disableUpstream = false;
|
|
38210
38242
|
this.applySourceConfig({
|
|
38211
38243
|
userDir: options?.userDir,
|
|
@@ -38217,8 +38249,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38217
38249
|
migrateMarketplaceDirToExternal() {
|
|
38218
38250
|
try {
|
|
38219
38251
|
const home = os23.homedir();
|
|
38220
|
-
const oldDir =
|
|
38221
|
-
const newDir =
|
|
38252
|
+
const oldDir = path32.join(home, ".adhdev", "marketplace");
|
|
38253
|
+
const newDir = path32.join(home, ".adhdev", "external");
|
|
38222
38254
|
if (!fs21.existsSync(oldDir)) return;
|
|
38223
38255
|
if (fs21.existsSync(newDir)) {
|
|
38224
38256
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
@@ -38254,7 +38286,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38254
38286
|
* Highest-priority editable overrides come first.
|
|
38255
38287
|
*/
|
|
38256
38288
|
getProviderRoots() {
|
|
38257
|
-
const externalDir =
|
|
38289
|
+
const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
|
|
38258
38290
|
return [this.userDir, externalDir, this.upstreamDir];
|
|
38259
38291
|
}
|
|
38260
38292
|
getSourceConfig() {
|
|
@@ -38282,7 +38314,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38282
38314
|
this.userDir = detected.path;
|
|
38283
38315
|
this.userDirSource = detected.source;
|
|
38284
38316
|
}
|
|
38285
|
-
this.upstreamDir =
|
|
38317
|
+
this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
|
|
38286
38318
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
38287
38319
|
if (this.explicitProviderDir) {
|
|
38288
38320
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -38296,7 +38328,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38296
38328
|
* Canonical provider directory shape for a given root.
|
|
38297
38329
|
*/
|
|
38298
38330
|
getProviderDir(root, category, type) {
|
|
38299
|
-
return
|
|
38331
|
+
return path32.join(root, category, type);
|
|
38300
38332
|
}
|
|
38301
38333
|
/**
|
|
38302
38334
|
* Canonical user override directory for a provider.
|
|
@@ -38323,7 +38355,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38323
38355
|
resolveProviderFile(type, ...segments) {
|
|
38324
38356
|
const dir = this.findProviderDirInternal(type);
|
|
38325
38357
|
if (!dir) return null;
|
|
38326
|
-
return
|
|
38358
|
+
return path32.join(dir, ...segments);
|
|
38327
38359
|
}
|
|
38328
38360
|
/**
|
|
38329
38361
|
* Load all providers (3-tier priority)
|
|
@@ -38347,7 +38379,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38347
38379
|
} else if (this.disableUpstream) {
|
|
38348
38380
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
38349
38381
|
}
|
|
38350
|
-
const externalDir =
|
|
38382
|
+
const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
|
|
38351
38383
|
if (fs21.existsSync(externalDir)) {
|
|
38352
38384
|
const rootEntries = (() => {
|
|
38353
38385
|
try {
|
|
@@ -38369,7 +38401,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38369
38401
|
const ambiguousTypes = [];
|
|
38370
38402
|
for (const sourceEntry of rootEntries) {
|
|
38371
38403
|
if (!sourceEntry.isDirectory()) continue;
|
|
38372
|
-
const sourceDir =
|
|
38404
|
+
const sourceDir = path32.join(externalDir, sourceEntry.name);
|
|
38373
38405
|
const sourceLoaded = this.loadDir(sourceDir);
|
|
38374
38406
|
if (sourceLoaded > 0) {
|
|
38375
38407
|
totalLoaded += sourceLoaded;
|
|
@@ -38385,7 +38417,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38385
38417
|
ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
|
|
38386
38418
|
}
|
|
38387
38419
|
if (resolved.source && resolved.source !== "?") {
|
|
38388
|
-
const sourceDir =
|
|
38420
|
+
const sourceDir = path32.join(externalDir, resolved.source);
|
|
38389
38421
|
const reloadCount = this.loadDir(sourceDir);
|
|
38390
38422
|
if (reloadCount === 0) {
|
|
38391
38423
|
this.log(`Active source "${resolved.source}" no longer provides ${type}`);
|
|
@@ -38418,7 +38450,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38418
38450
|
if (!fs21.existsSync(this.upstreamDir)) return false;
|
|
38419
38451
|
try {
|
|
38420
38452
|
return fs21.readdirSync(this.upstreamDir).some(
|
|
38421
|
-
(d) => fs21.statSync(
|
|
38453
|
+
(d) => fs21.statSync(path32.join(this.upstreamDir, d)).isDirectory()
|
|
38422
38454
|
);
|
|
38423
38455
|
} catch {
|
|
38424
38456
|
return false;
|
|
@@ -38916,8 +38948,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38916
38948
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
38917
38949
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
38918
38950
|
if (providerDir) {
|
|
38919
|
-
const fullDir =
|
|
38920
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
38951
|
+
const fullDir = path32.join(providerDir, entry.scriptDir);
|
|
38952
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
|
|
38921
38953
|
}
|
|
38922
38954
|
matched = true;
|
|
38923
38955
|
}
|
|
@@ -38935,8 +38967,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38935
38967
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
38936
38968
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
38937
38969
|
if (providerDir) {
|
|
38938
|
-
const fullDir =
|
|
38939
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
38970
|
+
const fullDir = path32.join(providerDir, base.defaultScriptDir);
|
|
38971
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
|
|
38940
38972
|
}
|
|
38941
38973
|
}
|
|
38942
38974
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -38953,8 +38985,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38953
38985
|
resolved._resolvedScriptDir = dirOverride;
|
|
38954
38986
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
38955
38987
|
if (providerDir) {
|
|
38956
|
-
const fullDir =
|
|
38957
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
38988
|
+
const fullDir = path32.join(providerDir, dirOverride);
|
|
38989
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
|
|
38958
38990
|
}
|
|
38959
38991
|
}
|
|
38960
38992
|
} else if (override.scripts) {
|
|
@@ -38970,8 +39002,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38970
39002
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
38971
39003
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
38972
39004
|
if (providerDir) {
|
|
38973
|
-
const fullDir =
|
|
38974
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
39005
|
+
const fullDir = path32.join(providerDir, base.defaultScriptDir);
|
|
39006
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
|
|
38975
39007
|
}
|
|
38976
39008
|
}
|
|
38977
39009
|
}
|
|
@@ -38988,13 +39020,13 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
38988
39020
|
if (providerDir2) {
|
|
38989
39021
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
38990
39022
|
if (!override || typeof override.path !== "string") continue;
|
|
38991
|
-
const fullPath =
|
|
39023
|
+
const fullPath = path32.join(providerDir2, override.path);
|
|
38992
39024
|
if (!fs21.existsSync(fullPath)) {
|
|
38993
39025
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
38994
39026
|
continue;
|
|
38995
39027
|
}
|
|
38996
39028
|
try {
|
|
38997
|
-
registerProviderScriptRootSafely(
|
|
39029
|
+
registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir2)));
|
|
38998
39030
|
delete require.cache[require.resolve(fullPath)];
|
|
38999
39031
|
const fn = require(fullPath);
|
|
39000
39032
|
const target = typeof fn === "function" ? fn : fn && fn[scriptName];
|
|
@@ -39020,17 +39052,17 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39020
39052
|
if (providerDir) {
|
|
39021
39053
|
try {
|
|
39022
39054
|
const fs30 = require("fs");
|
|
39023
|
-
const
|
|
39055
|
+
const path41 = require("path");
|
|
39024
39056
|
const candidates = [];
|
|
39025
39057
|
if (Array.isArray(base.compatibility)) {
|
|
39026
39058
|
for (const entry of base.compatibility) {
|
|
39027
39059
|
if (typeof entry?.spec !== "string") continue;
|
|
39028
39060
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
39029
|
-
if (matches) candidates.push(
|
|
39061
|
+
if (matches) candidates.push(path41.join(providerDir, entry.spec));
|
|
39030
39062
|
}
|
|
39031
39063
|
}
|
|
39032
|
-
candidates.push(
|
|
39033
|
-
candidates.push(
|
|
39064
|
+
candidates.push(path41.join(providerDir, "specs", "default.json"));
|
|
39065
|
+
candidates.push(path41.join(providerDir, "spec.json"));
|
|
39034
39066
|
const specPath = candidates.find((p) => fs30.existsSync(p));
|
|
39035
39067
|
if (specPath) {
|
|
39036
39068
|
resolved._resolvedSpecPath = specPath;
|
|
@@ -39061,10 +39093,10 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39061
39093
|
format = `spec-${nh.source.kind}`;
|
|
39062
39094
|
reader = (input) => executeNativeHistory(nh, input);
|
|
39063
39095
|
} else if (nh.override_path) {
|
|
39064
|
-
const overrideFile =
|
|
39096
|
+
const overrideFile = path41.resolve(providerDir, nh.override_path);
|
|
39065
39097
|
if (fs30.existsSync(overrideFile)) {
|
|
39066
39098
|
try {
|
|
39067
|
-
registerProviderScriptRootSafely(
|
|
39099
|
+
registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
|
|
39068
39100
|
delete require.cache[require.resolve(overrideFile)];
|
|
39069
39101
|
const mod = require(overrideFile);
|
|
39070
39102
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -39107,15 +39139,15 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39107
39139
|
this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
|
|
39108
39140
|
return null;
|
|
39109
39141
|
}
|
|
39110
|
-
const dir =
|
|
39142
|
+
const dir = path32.join(providerDir, scriptDir);
|
|
39111
39143
|
if (!fs21.existsSync(dir)) {
|
|
39112
39144
|
this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
39113
39145
|
return null;
|
|
39114
39146
|
}
|
|
39115
|
-
registerProviderScriptRootSafely(
|
|
39147
|
+
registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir)));
|
|
39116
39148
|
const cached2 = this.scriptsCache.get(dir);
|
|
39117
39149
|
if (cached2) return cached2;
|
|
39118
|
-
const scriptsJs =
|
|
39150
|
+
const scriptsJs = path32.join(dir, "scripts.js");
|
|
39119
39151
|
if (fs21.existsSync(scriptsJs)) {
|
|
39120
39152
|
try {
|
|
39121
39153
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -39160,7 +39192,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39160
39192
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
39161
39193
|
if (reloadTimer) clearTimeout(reloadTimer);
|
|
39162
39194
|
reloadTimer = setTimeout(() => {
|
|
39163
|
-
this.log(`File changed: ${
|
|
39195
|
+
this.log(`File changed: ${path32.basename(filePath)}, reloading...`);
|
|
39164
39196
|
this.reload();
|
|
39165
39197
|
}, 300);
|
|
39166
39198
|
}
|
|
@@ -39228,7 +39260,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39228
39260
|
}
|
|
39229
39261
|
this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
|
|
39230
39262
|
const https = require("https");
|
|
39231
|
-
const regMetaPath =
|
|
39263
|
+
const regMetaPath = path32.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
|
|
39232
39264
|
let cachedChecksums = {};
|
|
39233
39265
|
try {
|
|
39234
39266
|
if (fs21.existsSync(regMetaPath)) {
|
|
@@ -39286,9 +39318,9 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39286
39318
|
this.log(`\u26A0 Registry checksum mismatch for ${type}@${version} \u2014 skipping`);
|
|
39287
39319
|
continue;
|
|
39288
39320
|
}
|
|
39289
|
-
const providerDir =
|
|
39321
|
+
const providerDir = path32.join(this.upstreamDir, category, type);
|
|
39290
39322
|
fs21.mkdirSync(providerDir, { recursive: true });
|
|
39291
|
-
fs21.writeFileSync(
|
|
39323
|
+
fs21.writeFileSync(path32.join(providerDir, "provider.json"), manifestBody, "utf-8");
|
|
39292
39324
|
cachedChecksums[cacheKey] = checksum;
|
|
39293
39325
|
updatedCount++;
|
|
39294
39326
|
this.log(`\u2713 Registry updated: ${category}/${type}@${version}`);
|
|
@@ -39315,7 +39347,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39315
39347
|
const { exec: exec7 } = require("child_process");
|
|
39316
39348
|
const { promisify: promisify8 } = require("util");
|
|
39317
39349
|
const execAsync5 = promisify8(exec7);
|
|
39318
|
-
const metaPath =
|
|
39350
|
+
const metaPath = path32.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
39319
39351
|
let prevEtag = "";
|
|
39320
39352
|
let prevTimestamp = 0;
|
|
39321
39353
|
try {
|
|
@@ -39375,17 +39407,17 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39375
39407
|
return { updated: false };
|
|
39376
39408
|
}
|
|
39377
39409
|
this.log("Downloading latest providers from GitHub...");
|
|
39378
|
-
const tmpTar =
|
|
39379
|
-
const tmpExtract =
|
|
39410
|
+
const tmpTar = path32.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
39411
|
+
const tmpExtract = path32.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
39380
39412
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
39381
39413
|
fs21.mkdirSync(tmpExtract, { recursive: true });
|
|
39382
39414
|
await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
39383
39415
|
const extracted = fs21.readdirSync(tmpExtract);
|
|
39384
39416
|
const rootDir = extracted.find(
|
|
39385
|
-
(d) => fs21.statSync(
|
|
39417
|
+
(d) => fs21.statSync(path32.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
39386
39418
|
);
|
|
39387
39419
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
39388
|
-
const sourceDir =
|
|
39420
|
+
const sourceDir = path32.join(tmpExtract, rootDir);
|
|
39389
39421
|
const backupDir = this.upstreamDir + ".bak";
|
|
39390
39422
|
if (fs21.existsSync(this.upstreamDir)) {
|
|
39391
39423
|
if (fs21.existsSync(backupDir)) fs21.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -39460,8 +39492,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39460
39492
|
copyDirRecursive(src, dest) {
|
|
39461
39493
|
fs21.mkdirSync(dest, { recursive: true });
|
|
39462
39494
|
for (const entry of fs21.readdirSync(src, { withFileTypes: true })) {
|
|
39463
|
-
const srcPath =
|
|
39464
|
-
const destPath =
|
|
39495
|
+
const srcPath = path32.join(src, entry.name);
|
|
39496
|
+
const destPath = path32.join(dest, entry.name);
|
|
39465
39497
|
if (entry.isDirectory()) {
|
|
39466
39498
|
this.copyDirRecursive(srcPath, destPath);
|
|
39467
39499
|
} else {
|
|
@@ -39472,7 +39504,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39472
39504
|
/** .meta.json save */
|
|
39473
39505
|
writeMeta(metaPath, etag, timestamp) {
|
|
39474
39506
|
try {
|
|
39475
|
-
fs21.mkdirSync(
|
|
39507
|
+
fs21.mkdirSync(path32.dirname(metaPath), { recursive: true });
|
|
39476
39508
|
fs21.writeFileSync(metaPath, JSON.stringify({
|
|
39477
39509
|
etag,
|
|
39478
39510
|
timestamp,
|
|
@@ -39492,7 +39524,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39492
39524
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
39493
39525
|
if (hasManifest) count++;
|
|
39494
39526
|
for (const entry of entries) {
|
|
39495
|
-
if (entry.isDirectory()) scan(
|
|
39527
|
+
if (entry.isDirectory()) scan(path32.join(d, entry.name));
|
|
39496
39528
|
}
|
|
39497
39529
|
} catch {
|
|
39498
39530
|
}
|
|
@@ -39718,10 +39750,10 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39718
39750
|
if (!provider) return null;
|
|
39719
39751
|
const cat = provider.category;
|
|
39720
39752
|
const searchRoots = this.getProviderRoots();
|
|
39721
|
-
const hasManifest = (dir) => fs21.existsSync(
|
|
39753
|
+
const hasManifest = (dir) => fs21.existsSync(path32.join(dir, "provider.v1.json")) || fs21.existsSync(path32.join(dir, "provider.json"));
|
|
39722
39754
|
const readManifestType = (dir) => {
|
|
39723
39755
|
for (const file of ["provider.v1.json", "provider.json"]) {
|
|
39724
|
-
const p =
|
|
39756
|
+
const p = path32.join(dir, file);
|
|
39725
39757
|
if (!fs21.existsSync(p)) continue;
|
|
39726
39758
|
try {
|
|
39727
39759
|
const data = JSON.parse(fs21.readFileSync(p, "utf-8"));
|
|
@@ -39735,12 +39767,12 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39735
39767
|
if (!fs21.existsSync(root)) continue;
|
|
39736
39768
|
const candidate = this.getProviderDir(root, cat, type);
|
|
39737
39769
|
if (hasManifest(candidate)) return candidate;
|
|
39738
|
-
const catDir =
|
|
39770
|
+
const catDir = path32.join(root, cat);
|
|
39739
39771
|
if (fs21.existsSync(catDir)) {
|
|
39740
39772
|
try {
|
|
39741
39773
|
for (const entry of fs21.readdirSync(catDir, { withFileTypes: true })) {
|
|
39742
39774
|
if (!entry.isDirectory()) continue;
|
|
39743
|
-
const entryDir =
|
|
39775
|
+
const entryDir = path32.join(catDir, entry.name);
|
|
39744
39776
|
const manifestType = readManifestType(entryDir);
|
|
39745
39777
|
if (manifestType === type) return entryDir;
|
|
39746
39778
|
}
|
|
@@ -39756,7 +39788,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39756
39788
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
39757
39789
|
*/
|
|
39758
39790
|
buildScriptWrappersFromDir(dir) {
|
|
39759
|
-
const scriptsJs =
|
|
39791
|
+
const scriptsJs = path32.join(dir, "scripts.js");
|
|
39760
39792
|
if (fs21.existsSync(scriptsJs)) {
|
|
39761
39793
|
try {
|
|
39762
39794
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -39770,7 +39802,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39770
39802
|
for (const file of fs21.readdirSync(dir)) {
|
|
39771
39803
|
if (!file.endsWith(".js")) continue;
|
|
39772
39804
|
const scriptName = toCamel(file.replace(".js", ""));
|
|
39773
|
-
const filePath =
|
|
39805
|
+
const filePath = path32.join(dir, file);
|
|
39774
39806
|
result[scriptName] = (...args) => {
|
|
39775
39807
|
try {
|
|
39776
39808
|
let content = fs21.readFileSync(filePath, "utf-8");
|
|
@@ -39832,7 +39864,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
39832
39864
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
39833
39865
|
if (hasV1 || hasJson) {
|
|
39834
39866
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
39835
|
-
const jsonPath =
|
|
39867
|
+
const jsonPath = path32.join(d, manifestFile);
|
|
39836
39868
|
try {
|
|
39837
39869
|
const raw = fs21.readFileSync(jsonPath, "utf-8");
|
|
39838
39870
|
const mod = JSON.parse(raw);
|
|
@@ -39872,10 +39904,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
39872
39904
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
39873
39905
|
} else {
|
|
39874
39906
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
39875
|
-
const scriptsPath =
|
|
39907
|
+
const scriptsPath = path32.join(d, "scripts.js");
|
|
39876
39908
|
if (!hasCompatibility && fs21.existsSync(scriptsPath)) {
|
|
39877
39909
|
try {
|
|
39878
|
-
registerProviderScriptRootSafely(
|
|
39910
|
+
registerProviderScriptRootSafely(path32.dirname(path32.dirname(d)));
|
|
39879
39911
|
delete require.cache[require.resolve(scriptsPath)];
|
|
39880
39912
|
const scripts = require(scriptsPath);
|
|
39881
39913
|
normalizedProvider.scripts = scripts;
|
|
@@ -39883,7 +39915,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
39883
39915
|
this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
|
|
39884
39916
|
}
|
|
39885
39917
|
}
|
|
39886
|
-
const externalDirAbs =
|
|
39918
|
+
const externalDirAbs = path32.join(os23.homedir(), ".adhdev", "external");
|
|
39887
39919
|
const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
|
|
39888
39920
|
try {
|
|
39889
39921
|
const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS(provider_trust_exports));
|
|
@@ -39893,8 +39925,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
39893
39925
|
normalizedProvider._sourceTrust = trust;
|
|
39894
39926
|
normalizedProvider._manifestShape = shape;
|
|
39895
39927
|
if (layer === "external") {
|
|
39896
|
-
const rel =
|
|
39897
|
-
const firstSeg = rel.split(
|
|
39928
|
+
const rel = path32.relative(externalDirAbs, d);
|
|
39929
|
+
const firstSeg = rel.split(path32.sep)[0];
|
|
39898
39930
|
if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
|
|
39899
39931
|
}
|
|
39900
39932
|
} catch {
|
|
@@ -39918,7 +39950,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
39918
39950
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
39919
39951
|
if (d === dir && entry.name === "examples") continue;
|
|
39920
39952
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
39921
|
-
scan(
|
|
39953
|
+
scan(path32.join(d, entry.name));
|
|
39922
39954
|
}
|
|
39923
39955
|
}
|
|
39924
39956
|
};
|
|
@@ -40000,7 +40032,7 @@ function findMacAppProcessPids(psOutput, appPaths) {
|
|
|
40000
40032
|
// src/launch.ts
|
|
40001
40033
|
async function execQuiet(command, options = {}) {
|
|
40002
40034
|
return new Promise((resolve24) => {
|
|
40003
|
-
(0,
|
|
40035
|
+
(0, import_child_process7.exec)(command, options, (error, stdout) => {
|
|
40004
40036
|
if (error) return resolve24("");
|
|
40005
40037
|
resolve24(stdout.toString());
|
|
40006
40038
|
});
|
|
@@ -40251,8 +40283,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
40251
40283
|
const appNameMap = getMacAppIdentifiers();
|
|
40252
40284
|
const appName = appNameMap[ideId];
|
|
40253
40285
|
if (appName) {
|
|
40254
|
-
const storagePath =
|
|
40255
|
-
process.env.APPDATA ||
|
|
40286
|
+
const storagePath = path33.join(
|
|
40287
|
+
process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Roaming"),
|
|
40256
40288
|
appName,
|
|
40257
40289
|
"storage.json"
|
|
40258
40290
|
);
|
|
@@ -40400,10 +40432,10 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
40400
40432
|
const canUseAppLauncher = !!appName;
|
|
40401
40433
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
40402
40434
|
if (!useAppLauncher && ide.cliCommand) {
|
|
40403
|
-
(0,
|
|
40435
|
+
(0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
40404
40436
|
} else if (appName) {
|
|
40405
40437
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
40406
|
-
(0,
|
|
40438
|
+
(0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
40407
40439
|
} else {
|
|
40408
40440
|
throw new Error(`No app identifier or CLI for ${ide.displayName}`);
|
|
40409
40441
|
}
|
|
@@ -40429,7 +40461,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
40429
40461
|
const args = ["--remote-debugging-port=" + port];
|
|
40430
40462
|
if (newWindow) args.push("--new-window");
|
|
40431
40463
|
if (workspace) args.push(workspace);
|
|
40432
|
-
(0,
|
|
40464
|
+
(0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
40433
40465
|
}
|
|
40434
40466
|
function getAvailableIdeIds() {
|
|
40435
40467
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -40444,9 +40476,9 @@ init_logger();
|
|
|
40444
40476
|
|
|
40445
40477
|
// src/logging/command-log.ts
|
|
40446
40478
|
var fs22 = __toESM(require("fs"));
|
|
40447
|
-
var
|
|
40479
|
+
var path34 = __toESM(require("path"));
|
|
40448
40480
|
var os25 = __toESM(require("os"));
|
|
40449
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
40481
|
+
var LOG_DIR2 = process.platform === "win32" ? path34.join(process.env.LOCALAPPDATA || process.env.APPDATA || path34.join(os25.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path34.join(os25.homedir(), "Library", "Logs", "adhdev") : path34.join(os25.homedir(), ".local", "share", "adhdev", "logs");
|
|
40450
40482
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
40451
40483
|
var MAX_DAYS = 7;
|
|
40452
40484
|
try {
|
|
@@ -40484,13 +40516,13 @@ function getDateStr2() {
|
|
|
40484
40516
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
40485
40517
|
}
|
|
40486
40518
|
var currentDate2 = getDateStr2();
|
|
40487
|
-
var currentFile =
|
|
40519
|
+
var currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
40488
40520
|
var writeCount2 = 0;
|
|
40489
40521
|
function checkRotation() {
|
|
40490
40522
|
const today = getDateStr2();
|
|
40491
40523
|
if (today !== currentDate2) {
|
|
40492
40524
|
currentDate2 = today;
|
|
40493
|
-
currentFile =
|
|
40525
|
+
currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
40494
40526
|
cleanOldFiles();
|
|
40495
40527
|
}
|
|
40496
40528
|
}
|
|
@@ -40504,7 +40536,7 @@ function cleanOldFiles() {
|
|
|
40504
40536
|
const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
40505
40537
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
40506
40538
|
try {
|
|
40507
|
-
fs22.unlinkSync(
|
|
40539
|
+
fs22.unlinkSync(path34.join(LOG_DIR2, file));
|
|
40508
40540
|
} catch {
|
|
40509
40541
|
}
|
|
40510
40542
|
}
|
|
@@ -40601,9 +40633,9 @@ var import_node_child_process4 = require("child_process");
|
|
|
40601
40633
|
var import_node_util4 = require("util");
|
|
40602
40634
|
var execFileAsync3 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
|
|
40603
40635
|
var MAX_CHANGED_FILES2 = 500;
|
|
40604
|
-
function topLevel(
|
|
40605
|
-
const slash =
|
|
40606
|
-
return slash === -1 ?
|
|
40636
|
+
function topLevel(path41) {
|
|
40637
|
+
const slash = path41.indexOf("/");
|
|
40638
|
+
return slash === -1 ? path41 : path41.slice(0, slash);
|
|
40607
40639
|
}
|
|
40608
40640
|
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
40609
40641
|
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
@@ -40701,10 +40733,10 @@ function runGit2(repoRoot, args) {
|
|
|
40701
40733
|
}
|
|
40702
40734
|
}
|
|
40703
40735
|
function readRecord6(repoRoot) {
|
|
40704
|
-
const
|
|
40705
|
-
if (!(0, import_node_fs4.existsSync)(
|
|
40736
|
+
const path41 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
40737
|
+
if (!(0, import_node_fs4.existsSync)(path41)) return null;
|
|
40706
40738
|
try {
|
|
40707
|
-
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(
|
|
40739
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path41, "utf8"));
|
|
40708
40740
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
40709
40741
|
} catch {
|
|
40710
40742
|
return null;
|
|
@@ -40769,7 +40801,7 @@ function buildPreviewFreshness(repoRoot) {
|
|
|
40769
40801
|
init_mesh_refine_status();
|
|
40770
40802
|
|
|
40771
40803
|
// src/mesh/mesh-init.ts
|
|
40772
|
-
var
|
|
40804
|
+
var import_fs15 = require("fs");
|
|
40773
40805
|
var import_path10 = require("path");
|
|
40774
40806
|
var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
|
|
40775
40807
|
var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
|
|
@@ -40785,21 +40817,21 @@ var CANDIDATE_STALE_INPUTS = [
|
|
|
40785
40817
|
];
|
|
40786
40818
|
function writeConfigFile(workspace, relativePath, config) {
|
|
40787
40819
|
const target = (0, import_path10.join)(workspace, relativePath);
|
|
40788
|
-
(0,
|
|
40789
|
-
(0,
|
|
40820
|
+
(0, import_fs15.mkdirSync)((0, import_path10.dirname)(target), { recursive: true });
|
|
40821
|
+
(0, import_fs15.writeFileSync)(target, `${JSON.stringify(config, null, 2)}
|
|
40790
40822
|
`, "utf-8");
|
|
40791
40823
|
return target;
|
|
40792
40824
|
}
|
|
40793
40825
|
function suggestMeshWorktreeBootstrapConfig(workspace) {
|
|
40794
40826
|
const commands = [];
|
|
40795
|
-
const hasPackageJson = (0,
|
|
40796
|
-
const hasNpmLock = (0,
|
|
40827
|
+
const hasPackageJson = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package.json"));
|
|
40828
|
+
const hasNpmLock = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package-lock.json"));
|
|
40797
40829
|
if (hasPackageJson) {
|
|
40798
40830
|
commands.push(
|
|
40799
40831
|
hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
|
|
40800
40832
|
);
|
|
40801
40833
|
}
|
|
40802
|
-
const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0,
|
|
40834
|
+
const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0, import_fs15.existsSync)((0, import_path10.join)(workspace, relative5)));
|
|
40803
40835
|
if (!commands.length) {
|
|
40804
40836
|
return { commands, staleInputs };
|
|
40805
40837
|
}
|
|
@@ -41231,17 +41263,17 @@ function buildStatusSnapshot(options) {
|
|
|
41231
41263
|
init_build_info();
|
|
41232
41264
|
|
|
41233
41265
|
// src/commands/upgrade-helper.ts
|
|
41234
|
-
var import_child_process7 = require("child_process");
|
|
41235
41266
|
var import_child_process8 = require("child_process");
|
|
41267
|
+
var import_child_process9 = require("child_process");
|
|
41236
41268
|
var fs23 = __toESM(require("fs"));
|
|
41237
41269
|
var os27 = __toESM(require("os"));
|
|
41238
|
-
var
|
|
41270
|
+
var path35 = __toESM(require("path"));
|
|
41239
41271
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
41240
41272
|
function getUpgradeLogPath() {
|
|
41241
41273
|
const home = os27.homedir();
|
|
41242
|
-
const dir =
|
|
41274
|
+
const dir = path35.join(home, ".adhdev");
|
|
41243
41275
|
fs23.mkdirSync(dir, { recursive: true });
|
|
41244
|
-
return
|
|
41276
|
+
return path35.join(dir, "daemon-upgrade.log");
|
|
41245
41277
|
}
|
|
41246
41278
|
function appendUpgradeLog(message) {
|
|
41247
41279
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -41252,14 +41284,14 @@ function appendUpgradeLog(message) {
|
|
|
41252
41284
|
}
|
|
41253
41285
|
}
|
|
41254
41286
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
41255
|
-
const binDir =
|
|
41287
|
+
const binDir = path35.dirname(nodeExecutable);
|
|
41256
41288
|
if (platform10 === "win32") {
|
|
41257
|
-
const npmCliPath =
|
|
41289
|
+
const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
41258
41290
|
if (fs23.existsSync(npmCliPath)) {
|
|
41259
41291
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
41260
41292
|
}
|
|
41261
41293
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
41262
|
-
const candidatePath =
|
|
41294
|
+
const candidatePath = path35.join(binDir, candidate);
|
|
41263
41295
|
if (fs23.existsSync(candidatePath)) {
|
|
41264
41296
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
41265
41297
|
}
|
|
@@ -41267,7 +41299,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
|
|
|
41267
41299
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
41268
41300
|
}
|
|
41269
41301
|
for (const candidate of ["npm"]) {
|
|
41270
|
-
const candidatePath =
|
|
41302
|
+
const candidatePath = path35.join(binDir, candidate);
|
|
41271
41303
|
if (fs23.existsSync(candidatePath)) {
|
|
41272
41304
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
41273
41305
|
}
|
|
@@ -41284,13 +41316,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
41284
41316
|
let currentDir = resolvedPath;
|
|
41285
41317
|
try {
|
|
41286
41318
|
if (fs23.statSync(resolvedPath).isFile()) {
|
|
41287
|
-
currentDir =
|
|
41319
|
+
currentDir = path35.dirname(resolvedPath);
|
|
41288
41320
|
}
|
|
41289
41321
|
} catch {
|
|
41290
|
-
currentDir =
|
|
41322
|
+
currentDir = path35.dirname(resolvedPath);
|
|
41291
41323
|
}
|
|
41292
41324
|
while (true) {
|
|
41293
|
-
const packageJsonPath =
|
|
41325
|
+
const packageJsonPath = path35.join(currentDir, "package.json");
|
|
41294
41326
|
try {
|
|
41295
41327
|
if (fs23.existsSync(packageJsonPath)) {
|
|
41296
41328
|
const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -41301,7 +41333,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
41301
41333
|
}
|
|
41302
41334
|
} catch {
|
|
41303
41335
|
}
|
|
41304
|
-
const parentDir =
|
|
41336
|
+
const parentDir = path35.dirname(currentDir);
|
|
41305
41337
|
if (parentDir === currentDir) {
|
|
41306
41338
|
return null;
|
|
41307
41339
|
}
|
|
@@ -41309,13 +41341,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
41309
41341
|
}
|
|
41310
41342
|
}
|
|
41311
41343
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
41312
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
41313
|
-
if (
|
|
41344
|
+
const nodeModulesDir = packageName.startsWith("@") ? path35.dirname(path35.dirname(packageRoot)) : path35.dirname(packageRoot);
|
|
41345
|
+
if (path35.basename(nodeModulesDir) !== "node_modules") {
|
|
41314
41346
|
return null;
|
|
41315
41347
|
}
|
|
41316
|
-
const maybeLibDir =
|
|
41317
|
-
if (
|
|
41318
|
-
return
|
|
41348
|
+
const maybeLibDir = path35.dirname(nodeModulesDir);
|
|
41349
|
+
if (path35.basename(maybeLibDir) === "lib") {
|
|
41350
|
+
return path35.dirname(maybeLibDir);
|
|
41319
41351
|
}
|
|
41320
41352
|
return maybeLibDir;
|
|
41321
41353
|
}
|
|
@@ -41343,6 +41375,16 @@ function buildPinnedGlobalInstallCommand(options) {
|
|
|
41343
41375
|
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
41344
41376
|
};
|
|
41345
41377
|
}
|
|
41378
|
+
function buildInstallEnvWithNodeOnPath(baseEnv = process.env) {
|
|
41379
|
+
if (process.platform !== "win32") return { ...baseEnv };
|
|
41380
|
+
const nodeBinDir = path35.dirname(process.execPath);
|
|
41381
|
+
if (!nodeBinDir) return { ...baseEnv };
|
|
41382
|
+
const env = { ...baseEnv };
|
|
41383
|
+
const pathKey = Object.keys(env).find((k) => k.toLowerCase() === "path") || "PATH";
|
|
41384
|
+
const current = env[pathKey] || "";
|
|
41385
|
+
env[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
|
|
41386
|
+
return env;
|
|
41387
|
+
}
|
|
41346
41388
|
function getNpmExecOptions(platform10 = process.platform) {
|
|
41347
41389
|
if (platform10 === "win32") {
|
|
41348
41390
|
return { shell: false, windowsHide: true };
|
|
@@ -41351,7 +41393,7 @@ function getNpmExecOptions(platform10 = process.platform) {
|
|
|
41351
41393
|
}
|
|
41352
41394
|
function execNpmCommandSync(args, options = {}, surface) {
|
|
41353
41395
|
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
41354
|
-
return (0,
|
|
41396
|
+
return (0, import_child_process8.execFileSync)(
|
|
41355
41397
|
surface?.npmExecutable || "npm",
|
|
41356
41398
|
[...surface?.npmArgsPrefix || [], ...args],
|
|
41357
41399
|
{
|
|
@@ -41364,7 +41406,7 @@ function execNpmCommandSync(args, options = {}, surface) {
|
|
|
41364
41406
|
function killPid(pid) {
|
|
41365
41407
|
try {
|
|
41366
41408
|
if (process.platform === "win32") {
|
|
41367
|
-
(0,
|
|
41409
|
+
(0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
41368
41410
|
} else {
|
|
41369
41411
|
process.kill(pid, "SIGTERM");
|
|
41370
41412
|
}
|
|
@@ -41376,7 +41418,7 @@ function killPid(pid) {
|
|
|
41376
41418
|
function getWindowsProcessCommandLine(pid) {
|
|
41377
41419
|
const pidFilter = `ProcessId=${pid}`;
|
|
41378
41420
|
try {
|
|
41379
|
-
const psOut = (0,
|
|
41421
|
+
const psOut = (0, import_child_process8.execFileSync)("powershell.exe", [
|
|
41380
41422
|
"-NoProfile",
|
|
41381
41423
|
"-NonInteractive",
|
|
41382
41424
|
"-ExecutionPolicy",
|
|
@@ -41388,7 +41430,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
41388
41430
|
} catch {
|
|
41389
41431
|
}
|
|
41390
41432
|
try {
|
|
41391
|
-
const wmicOut = (0,
|
|
41433
|
+
const wmicOut = (0, import_child_process8.execFileSync)("wmic", [
|
|
41392
41434
|
"process",
|
|
41393
41435
|
"where",
|
|
41394
41436
|
pidFilter,
|
|
@@ -41404,7 +41446,7 @@ function getProcessCommandLine(pid) {
|
|
|
41404
41446
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
41405
41447
|
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
41406
41448
|
try {
|
|
41407
|
-
const text = (0,
|
|
41449
|
+
const text = (0, import_child_process8.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
|
|
41408
41450
|
encoding: "utf8",
|
|
41409
41451
|
timeout: 3e3,
|
|
41410
41452
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -41430,7 +41472,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
41430
41472
|
}
|
|
41431
41473
|
}
|
|
41432
41474
|
function stopSessionHostProcesses(appName) {
|
|
41433
|
-
const pidFile =
|
|
41475
|
+
const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
41434
41476
|
try {
|
|
41435
41477
|
if (fs23.existsSync(pidFile)) {
|
|
41436
41478
|
const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -41447,7 +41489,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
41447
41489
|
}
|
|
41448
41490
|
}
|
|
41449
41491
|
function removeDaemonPidFile() {
|
|
41450
|
-
const pidFile =
|
|
41492
|
+
const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
|
|
41451
41493
|
try {
|
|
41452
41494
|
fs23.unlinkSync(pidFile);
|
|
41453
41495
|
} catch {
|
|
@@ -41458,7 +41500,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
41458
41500
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
41459
41501
|
if (!npmRoot) return;
|
|
41460
41502
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
41461
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
41503
|
+
const binDir = process.platform === "win32" ? npmPrefix : path35.join(npmPrefix, "bin");
|
|
41462
41504
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
41463
41505
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
41464
41506
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -41466,31 +41508,31 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
41466
41508
|
}
|
|
41467
41509
|
if (pkgName.startsWith("@")) {
|
|
41468
41510
|
const [scope, name] = pkgName.split("/");
|
|
41469
|
-
const scopeDir =
|
|
41511
|
+
const scopeDir = path35.join(npmRoot, scope);
|
|
41470
41512
|
if (!fs23.existsSync(scopeDir)) return;
|
|
41471
41513
|
for (const entry of fs23.readdirSync(scopeDir)) {
|
|
41472
41514
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
41473
|
-
fs23.rmSync(
|
|
41474
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
41515
|
+
fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
|
|
41516
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
|
|
41475
41517
|
}
|
|
41476
41518
|
} else {
|
|
41477
41519
|
for (const entry of fs23.readdirSync(npmRoot)) {
|
|
41478
41520
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
41479
|
-
fs23.rmSync(
|
|
41480
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
41521
|
+
fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
|
|
41522
|
+
appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
|
|
41481
41523
|
}
|
|
41482
41524
|
}
|
|
41483
41525
|
if (fs23.existsSync(binDir)) {
|
|
41484
41526
|
for (const entry of fs23.readdirSync(binDir)) {
|
|
41485
41527
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
41486
|
-
fs23.rmSync(
|
|
41487
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
41528
|
+
fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
|
|
41529
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
|
|
41488
41530
|
}
|
|
41489
41531
|
}
|
|
41490
41532
|
}
|
|
41491
41533
|
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
41492
41534
|
const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
41493
|
-
const child = (0,
|
|
41535
|
+
const child = (0, import_child_process9.spawn)(process.execPath, process.argv.slice(1), {
|
|
41494
41536
|
detached: true,
|
|
41495
41537
|
stdio: "ignore",
|
|
41496
41538
|
windowsHide: true,
|
|
@@ -41520,13 +41562,14 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
41520
41562
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
41521
41563
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
41522
41564
|
appendUpgradeLog(`Installing ${spec}`);
|
|
41523
|
-
const installOutput = (0,
|
|
41565
|
+
const installOutput = (0, import_child_process8.execFileSync)(
|
|
41524
41566
|
installCommand.command,
|
|
41525
41567
|
installCommand.args,
|
|
41526
41568
|
{
|
|
41527
41569
|
encoding: "utf8",
|
|
41528
41570
|
stdio: "pipe",
|
|
41529
41571
|
maxBuffer: 20 * 1024 * 1024,
|
|
41572
|
+
env: buildInstallEnvWithNodeOnPath(),
|
|
41530
41573
|
...installCommand.execOptions
|
|
41531
41574
|
}
|
|
41532
41575
|
);
|
|
@@ -41542,7 +41585,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
41542
41585
|
const env = { ...process.env };
|
|
41543
41586
|
delete env[UPGRADE_HELPER_ENV];
|
|
41544
41587
|
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
41545
|
-
const child = (0,
|
|
41588
|
+
const child = (0, import_child_process9.spawn)(process.execPath, restartArgv, {
|
|
41546
41589
|
detached: true,
|
|
41547
41590
|
stdio: "ignore",
|
|
41548
41591
|
windowsHide: true,
|
|
@@ -42551,18 +42594,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
42551
42594
|
return { enabled: false };
|
|
42552
42595
|
}
|
|
42553
42596
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
42554
|
-
const { execFileSync:
|
|
42597
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
42555
42598
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
42556
42599
|
if (excludePaths.length > 0) {
|
|
42557
|
-
diffArgs.push("--", ".", ...excludePaths.map((
|
|
42600
|
+
diffArgs.push("--", ".", ...excludePaths.map((path41) => `:(exclude)${path41}`));
|
|
42558
42601
|
}
|
|
42559
|
-
const diff =
|
|
42602
|
+
const diff = execFileSync7("git", diffArgs, {
|
|
42560
42603
|
cwd,
|
|
42561
42604
|
encoding: "utf8",
|
|
42562
42605
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
42563
42606
|
});
|
|
42564
42607
|
if (!diff.trim()) return "";
|
|
42565
|
-
const patchId =
|
|
42608
|
+
const patchId = execFileSync7("git", ["patch-id", "--stable"], {
|
|
42566
42609
|
cwd,
|
|
42567
42610
|
input: diff,
|
|
42568
42611
|
encoding: "utf8",
|
|
@@ -42573,8 +42616,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
42573
42616
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
42574
42617
|
const startedAt = Date.now();
|
|
42575
42618
|
try {
|
|
42576
|
-
const { execFileSync:
|
|
42577
|
-
const git = (args) =>
|
|
42619
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
42620
|
+
const git = (args) => execFileSync7("git", args, {
|
|
42578
42621
|
cwd: repoRoot,
|
|
42579
42622
|
encoding: "utf8",
|
|
42580
42623
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -42665,8 +42708,8 @@ ${e?.stderr || ""}`
|
|
|
42665
42708
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
42666
42709
|
const startedAt = Date.now();
|
|
42667
42710
|
try {
|
|
42668
|
-
const { execFileSync:
|
|
42669
|
-
const git = (args, opts) =>
|
|
42711
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
42712
|
+
const git = (args, opts) => execFileSync7("git", args, {
|
|
42670
42713
|
cwd: opts?.cwd || repoRoot,
|
|
42671
42714
|
encoding: "utf8",
|
|
42672
42715
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -42691,9 +42734,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
42691
42734
|
if (!trimmed) continue;
|
|
42692
42735
|
if (trimmed.startsWith("+")) {
|
|
42693
42736
|
const parts = trimmed.slice(1).trim().split(/\s+/);
|
|
42694
|
-
const
|
|
42737
|
+
const path41 = parts[1] || parts[0] || "(unknown)";
|
|
42695
42738
|
submoduleHints.push({
|
|
42696
|
-
path:
|
|
42739
|
+
path: path41,
|
|
42697
42740
|
reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
|
|
42698
42741
|
});
|
|
42699
42742
|
}
|
|
@@ -42723,10 +42766,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
42723
42766
|
}
|
|
42724
42767
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
42725
42768
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
42726
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
42727
|
-
path:
|
|
42728
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
42729
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
42769
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => ({
|
|
42770
|
+
path: path41,
|
|
42771
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path41),
|
|
42772
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path41)
|
|
42730
42773
|
}));
|
|
42731
42774
|
if (conflicts.length === 0) return void 0;
|
|
42732
42775
|
return {
|
|
@@ -42752,11 +42795,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
42752
42795
|
if (!line.trim()) continue;
|
|
42753
42796
|
const metaAndPath = line.split(" ");
|
|
42754
42797
|
const meta = metaAndPath[0] || "";
|
|
42755
|
-
const
|
|
42756
|
-
if (!
|
|
42798
|
+
const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
42799
|
+
if (!path41) continue;
|
|
42757
42800
|
const parts = meta.split(/\s+/);
|
|
42758
42801
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
42759
|
-
paths.add(
|
|
42802
|
+
paths.add(path41);
|
|
42760
42803
|
}
|
|
42761
42804
|
}
|
|
42762
42805
|
return [...paths].sort();
|
|
@@ -42764,9 +42807,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
42764
42807
|
return [];
|
|
42765
42808
|
}
|
|
42766
42809
|
}
|
|
42767
|
-
function readTreeObject(repoRoot, ref,
|
|
42810
|
+
function readTreeObject(repoRoot, ref, path41) {
|
|
42768
42811
|
try {
|
|
42769
|
-
const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--",
|
|
42812
|
+
const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--", path41], {
|
|
42770
42813
|
cwd: repoRoot,
|
|
42771
42814
|
encoding: "utf8",
|
|
42772
42815
|
maxBuffer: 1024 * 1024
|
|
@@ -42811,12 +42854,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
42811
42854
|
if (!line.trim()) continue;
|
|
42812
42855
|
const metaAndPath = line.split(" ");
|
|
42813
42856
|
const meta = metaAndPath[0] || "";
|
|
42814
|
-
const
|
|
42815
|
-
if (!
|
|
42816
|
-
seen.add(
|
|
42857
|
+
const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
42858
|
+
if (!path41 || seen.has(path41)) continue;
|
|
42859
|
+
seen.add(path41);
|
|
42817
42860
|
const parts = meta.split(/\s+/);
|
|
42818
42861
|
const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
|
|
42819
|
-
result.push({ path:
|
|
42862
|
+
result.push({ path: path41, isGitlink });
|
|
42820
42863
|
}
|
|
42821
42864
|
return result;
|
|
42822
42865
|
} catch {
|
|
@@ -42824,20 +42867,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
42824
42867
|
}
|
|
42825
42868
|
}
|
|
42826
42869
|
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
42827
|
-
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((
|
|
42828
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
42829
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
42870
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path41) => {
|
|
42871
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path41);
|
|
42872
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path41);
|
|
42830
42873
|
if (!baseCommit || !branchCommit) return false;
|
|
42831
|
-
return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot,
|
|
42874
|
+
return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot, path41), baseCommit, branchCommit);
|
|
42832
42875
|
});
|
|
42833
42876
|
}
|
|
42834
42877
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
42835
|
-
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
42836
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
42837
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
42838
|
-
const submoduleRepoPath = (0, import_path11.resolve)(repoRoot,
|
|
42878
|
+
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => {
|
|
42879
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path41);
|
|
42880
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path41);
|
|
42881
|
+
const submoduleRepoPath = (0, import_path11.resolve)(repoRoot, path41);
|
|
42839
42882
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
42840
|
-
return { path:
|
|
42883
|
+
return { path: path41, baseCommit, branchCommit, fastForward };
|
|
42841
42884
|
});
|
|
42842
42885
|
if (changedGitlinks.length === 0) {
|
|
42843
42886
|
return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
|
|
@@ -42888,7 +42931,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
42888
42931
|
maxBuffer: 1024 * 1024
|
|
42889
42932
|
}).trim();
|
|
42890
42933
|
if (!tree) return void 0;
|
|
42891
|
-
const updates = paths.map((
|
|
42934
|
+
const updates = paths.map((path41) => `160000 commit ${placeholderCommit} ${path41}`).join("\n");
|
|
42892
42935
|
if (!updates) return tree;
|
|
42893
42936
|
const tmpIndex = (0, import_path11.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
42894
42937
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
@@ -42991,7 +43034,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
42991
43034
|
}
|
|
42992
43035
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
42993
43036
|
const startedAt = Date.now();
|
|
42994
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
43037
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path41) => !(options.submoduleIgnorePaths || []).includes(path41));
|
|
42995
43038
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
42996
43039
|
includeSubmodules: true,
|
|
42997
43040
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -43032,7 +43075,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
|
|
|
43032
43075
|
changedGitlinkPaths,
|
|
43033
43076
|
outOfSyncPaths,
|
|
43034
43077
|
updatedPaths: updatePaths,
|
|
43035
|
-
verifiedPaths: updatePaths.filter((
|
|
43078
|
+
verifiedPaths: updatePaths.filter((path41) => !remaining.some((submodule) => submodule.path === path41)),
|
|
43036
43079
|
durationMs: Date.now() - startedAt,
|
|
43037
43080
|
command: `git ${commandArgs.join(" ")}`,
|
|
43038
43081
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -46330,9 +46373,9 @@ ${hintLines.join("\n")}` : "",
|
|
|
46330
46373
|
// commands instead of going through fs from the browser.
|
|
46331
46374
|
case "list_coordinator_prompts": {
|
|
46332
46375
|
const fs30 = await import("fs");
|
|
46333
|
-
const
|
|
46376
|
+
const path41 = await import("path");
|
|
46334
46377
|
const os30 = await import("os");
|
|
46335
|
-
const dir =
|
|
46378
|
+
const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
46336
46379
|
const entries = {};
|
|
46337
46380
|
try {
|
|
46338
46381
|
if (fs30.existsSync(dir)) {
|
|
@@ -46343,7 +46386,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46343
46386
|
if (!m) continue;
|
|
46344
46387
|
const isAppend = !!matchAppend;
|
|
46345
46388
|
const key = m[1];
|
|
46346
|
-
const full =
|
|
46389
|
+
const full = path41.join(dir, name);
|
|
46347
46390
|
let content = "";
|
|
46348
46391
|
try {
|
|
46349
46392
|
content = fs30.readFileSync(full, "utf8");
|
|
@@ -46361,7 +46404,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46361
46404
|
}
|
|
46362
46405
|
case "write_coordinator_prompt": {
|
|
46363
46406
|
const fs30 = await import("fs");
|
|
46364
|
-
const
|
|
46407
|
+
const path41 = await import("path");
|
|
46365
46408
|
const os30 = await import("os");
|
|
46366
46409
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
46367
46410
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
@@ -46369,9 +46412,9 @@ ${hintLines.join("\n")}` : "",
|
|
|
46369
46412
|
if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
|
|
46370
46413
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
46371
46414
|
}
|
|
46372
|
-
const dir =
|
|
46415
|
+
const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
46373
46416
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
46374
|
-
const full =
|
|
46417
|
+
const full = path41.join(dir, filename);
|
|
46375
46418
|
try {
|
|
46376
46419
|
fs30.mkdirSync(dir, { recursive: true });
|
|
46377
46420
|
if (content.trim()) {
|
|
@@ -47926,7 +47969,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47926
47969
|
workspace
|
|
47927
47970
|
};
|
|
47928
47971
|
}
|
|
47929
|
-
const { existsSync:
|
|
47972
|
+
const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
47930
47973
|
const { dirname: dirname14 } = await import("path");
|
|
47931
47974
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
47932
47975
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -47969,7 +48012,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47969
48012
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
47970
48013
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
47971
48014
|
}
|
|
47972
|
-
const hadExistingMcpConfig =
|
|
48015
|
+
const hadExistingMcpConfig = existsSync43(mcpConfigPath);
|
|
47973
48016
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
47974
48017
|
if (hermesBaseConfig) {
|
|
47975
48018
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
|
|
@@ -48487,7 +48530,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48487
48530
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
48488
48531
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
48489
48532
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
48490
|
-
const { existsSync:
|
|
48533
|
+
const { existsSync: existsSync43 } = await import("fs");
|
|
48491
48534
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
48492
48535
|
const mesh = meshRecord?.mesh;
|
|
48493
48536
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -48506,7 +48549,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48506
48549
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
48507
48550
|
for (const item of derivation.items) {
|
|
48508
48551
|
const workspace = item.workspace;
|
|
48509
|
-
if (!workspace || !
|
|
48552
|
+
if (!workspace || !existsSync43(workspace)) continue;
|
|
48510
48553
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
48511
48554
|
try {
|
|
48512
48555
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -50253,11 +50296,11 @@ var ProviderInstanceManager = class {
|
|
|
50253
50296
|
|
|
50254
50297
|
// src/providers/version-archive.ts
|
|
50255
50298
|
var fs25 = __toESM(require("fs"));
|
|
50256
|
-
var
|
|
50299
|
+
var path36 = __toESM(require("path"));
|
|
50257
50300
|
var os28 = __toESM(require("os"));
|
|
50258
50301
|
var import_os4 = require("os");
|
|
50259
|
-
var
|
|
50260
|
-
var ARCHIVE_PATH =
|
|
50302
|
+
var import_child_process10 = require("child_process");
|
|
50303
|
+
var ARCHIVE_PATH = path36.join(os28.homedir(), ".adhdev", "version-history.json");
|
|
50261
50304
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
50262
50305
|
var VersionArchive = class {
|
|
50263
50306
|
history = {};
|
|
@@ -50304,7 +50347,7 @@ var VersionArchive = class {
|
|
|
50304
50347
|
}
|
|
50305
50348
|
save() {
|
|
50306
50349
|
try {
|
|
50307
|
-
fs25.mkdirSync(
|
|
50350
|
+
fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
|
|
50308
50351
|
fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
50309
50352
|
} catch {
|
|
50310
50353
|
}
|
|
@@ -50312,7 +50355,7 @@ var VersionArchive = class {
|
|
|
50312
50355
|
};
|
|
50313
50356
|
async function runCommand(cmd, timeout = 1e4) {
|
|
50314
50357
|
return new Promise((resolve24) => {
|
|
50315
|
-
(0,
|
|
50358
|
+
(0, import_child_process10.exec)(cmd, {
|
|
50316
50359
|
encoding: "utf-8",
|
|
50317
50360
|
timeout
|
|
50318
50361
|
}, (error, stdout) => {
|
|
@@ -50328,7 +50371,7 @@ function findBinary2(name) {
|
|
|
50328
50371
|
for (const p of paths) {
|
|
50329
50372
|
if (!p) continue;
|
|
50330
50373
|
for (const ext of exes) {
|
|
50331
|
-
const fullPath =
|
|
50374
|
+
const fullPath = path36.join(p, name + ext);
|
|
50332
50375
|
try {
|
|
50333
50376
|
if (fs25.existsSync(fullPath)) {
|
|
50334
50377
|
const stat2 = fs25.statSync(fullPath);
|
|
@@ -50377,7 +50420,7 @@ function checkPathExists2(paths) {
|
|
|
50377
50420
|
for (const p of paths) {
|
|
50378
50421
|
if (p.includes("*")) {
|
|
50379
50422
|
const home = os28.homedir();
|
|
50380
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
50423
|
+
const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
|
|
50381
50424
|
if (fs25.existsSync(resolved)) return resolved;
|
|
50382
50425
|
} else {
|
|
50383
50426
|
if (fs25.existsSync(p)) return p;
|
|
@@ -50387,7 +50430,7 @@ function checkPathExists2(paths) {
|
|
|
50387
50430
|
}
|
|
50388
50431
|
async function getMacAppVersion(appPath) {
|
|
50389
50432
|
if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
50390
|
-
const plistPath =
|
|
50433
|
+
const plistPath = path36.join(appPath, "Contents", "Info.plist");
|
|
50391
50434
|
if (!fs25.existsSync(plistPath)) return null;
|
|
50392
50435
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
50393
50436
|
return raw || null;
|
|
@@ -50413,7 +50456,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
50413
50456
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
50414
50457
|
let resolvedBin = cliBin;
|
|
50415
50458
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
50416
|
-
const bundled =
|
|
50459
|
+
const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
50417
50460
|
if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
|
|
50418
50461
|
}
|
|
50419
50462
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -50454,7 +50497,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
50454
50497
|
// src/daemon/dev-server.ts
|
|
50455
50498
|
var http2 = __toESM(require("http"));
|
|
50456
50499
|
var fs29 = __toESM(require("fs"));
|
|
50457
|
-
var
|
|
50500
|
+
var path40 = __toESM(require("path"));
|
|
50458
50501
|
init_config();
|
|
50459
50502
|
|
|
50460
50503
|
// src/daemon/scaffold-template.ts
|
|
@@ -50805,7 +50848,7 @@ init_logger();
|
|
|
50805
50848
|
|
|
50806
50849
|
// src/daemon/dev-cdp-handlers.ts
|
|
50807
50850
|
var fs26 = __toESM(require("fs"));
|
|
50808
|
-
var
|
|
50851
|
+
var path37 = __toESM(require("path"));
|
|
50809
50852
|
init_logger();
|
|
50810
50853
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
50811
50854
|
const body = await ctx.readBody(req);
|
|
@@ -50984,17 +51027,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
50984
51027
|
return;
|
|
50985
51028
|
}
|
|
50986
51029
|
let scriptsPath = "";
|
|
50987
|
-
const directScripts =
|
|
51030
|
+
const directScripts = path37.join(dir, "scripts.js");
|
|
50988
51031
|
if (fs26.existsSync(directScripts)) {
|
|
50989
51032
|
scriptsPath = directScripts;
|
|
50990
51033
|
} else {
|
|
50991
|
-
const scriptsDir =
|
|
51034
|
+
const scriptsDir = path37.join(dir, "scripts");
|
|
50992
51035
|
if (fs26.existsSync(scriptsDir)) {
|
|
50993
51036
|
const versions = fs26.readdirSync(scriptsDir).filter((d) => {
|
|
50994
|
-
return fs26.statSync(
|
|
51037
|
+
return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
|
|
50995
51038
|
}).sort().reverse();
|
|
50996
51039
|
for (const ver of versions) {
|
|
50997
|
-
const p =
|
|
51040
|
+
const p = path37.join(scriptsDir, ver, "scripts.js");
|
|
50998
51041
|
if (fs26.existsSync(p)) {
|
|
50999
51042
|
scriptsPath = p;
|
|
51000
51043
|
break;
|
|
@@ -51823,7 +51866,7 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
51823
51866
|
|
|
51824
51867
|
// src/daemon/dev-cli-debug.ts
|
|
51825
51868
|
var fs27 = __toESM(require("fs"));
|
|
51826
|
-
var
|
|
51869
|
+
var path38 = __toESM(require("path"));
|
|
51827
51870
|
function slugifyFixtureName(value) {
|
|
51828
51871
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
51829
51872
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -51833,11 +51876,11 @@ function getCliFixtureDir(ctx, type) {
|
|
|
51833
51876
|
if (!providerDir) {
|
|
51834
51877
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
51835
51878
|
}
|
|
51836
|
-
return
|
|
51879
|
+
return path38.join(providerDir, "fixtures");
|
|
51837
51880
|
}
|
|
51838
51881
|
function readCliFixture(ctx, type, name) {
|
|
51839
51882
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
51840
|
-
const filePath =
|
|
51883
|
+
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
51841
51884
|
if (!fs27.existsSync(filePath)) {
|
|
51842
51885
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
51843
51886
|
}
|
|
@@ -52613,7 +52656,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
52613
52656
|
},
|
|
52614
52657
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
52615
52658
|
};
|
|
52616
|
-
const filePath =
|
|
52659
|
+
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
52617
52660
|
fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
52618
52661
|
ctx.json(res, 200, {
|
|
52619
52662
|
saved: true,
|
|
@@ -52637,7 +52680,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
|
|
|
52637
52680
|
return;
|
|
52638
52681
|
}
|
|
52639
52682
|
const fixtures = fs27.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
|
|
52640
|
-
const fullPath =
|
|
52683
|
+
const fullPath = path38.join(fixtureDir, file);
|
|
52641
52684
|
try {
|
|
52642
52685
|
const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
|
|
52643
52686
|
return {
|
|
@@ -52773,7 +52816,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
52773
52816
|
|
|
52774
52817
|
// src/daemon/dev-auto-implement.ts
|
|
52775
52818
|
var fs28 = __toESM(require("fs"));
|
|
52776
|
-
var
|
|
52819
|
+
var path39 = __toESM(require("path"));
|
|
52777
52820
|
var os29 = __toESM(require("os"));
|
|
52778
52821
|
var import_session_host_core8 = require("@adhdev/session-host-core");
|
|
52779
52822
|
function getAutoImplPid(ctx) {
|
|
@@ -52824,22 +52867,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
52824
52867
|
if (!fs28.existsSync(scriptsDir)) return null;
|
|
52825
52868
|
const versions = fs28.readdirSync(scriptsDir).filter((d) => {
|
|
52826
52869
|
try {
|
|
52827
|
-
return fs28.statSync(
|
|
52870
|
+
return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
52828
52871
|
} catch {
|
|
52829
52872
|
return false;
|
|
52830
52873
|
}
|
|
52831
52874
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
52832
52875
|
if (versions.length === 0) return null;
|
|
52833
|
-
return
|
|
52876
|
+
return path39.join(scriptsDir, versions[0]);
|
|
52834
52877
|
}
|
|
52835
52878
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
52836
|
-
const canonicalUserDir =
|
|
52837
|
-
const desiredDir = requestedDir ?
|
|
52838
|
-
const upstreamRoot =
|
|
52839
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
52879
|
+
const canonicalUserDir = path39.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
52880
|
+
const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
|
|
52881
|
+
const upstreamRoot = path39.resolve(ctx.providerLoader.getUpstreamDir());
|
|
52882
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
|
|
52840
52883
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
52841
52884
|
}
|
|
52842
|
-
if (
|
|
52885
|
+
if (path39.basename(desiredDir) !== type) {
|
|
52843
52886
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
52844
52887
|
}
|
|
52845
52888
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -52847,11 +52890,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
52847
52890
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
52848
52891
|
}
|
|
52849
52892
|
if (!fs28.existsSync(desiredDir)) {
|
|
52850
|
-
fs28.mkdirSync(
|
|
52893
|
+
fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
|
|
52851
52894
|
fs28.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
52852
52895
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
52853
52896
|
}
|
|
52854
|
-
const providerJson =
|
|
52897
|
+
const providerJson = path39.join(desiredDir, "provider.json");
|
|
52855
52898
|
if (!fs28.existsSync(providerJson)) {
|
|
52856
52899
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
52857
52900
|
}
|
|
@@ -52862,13 +52905,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
52862
52905
|
const refDir = ctx.findProviderDir(referenceType);
|
|
52863
52906
|
if (!refDir || !fs28.existsSync(refDir)) return {};
|
|
52864
52907
|
const referenceScripts = {};
|
|
52865
|
-
const scriptsDir =
|
|
52908
|
+
const scriptsDir = path39.join(refDir, "scripts");
|
|
52866
52909
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
52867
52910
|
if (!latestDir) return referenceScripts;
|
|
52868
52911
|
for (const file of fs28.readdirSync(latestDir)) {
|
|
52869
52912
|
if (!file.endsWith(".js")) continue;
|
|
52870
52913
|
try {
|
|
52871
|
-
referenceScripts[file] = fs28.readFileSync(
|
|
52914
|
+
referenceScripts[file] = fs28.readFileSync(path39.join(latestDir, file), "utf-8");
|
|
52872
52915
|
} catch {
|
|
52873
52916
|
}
|
|
52874
52917
|
}
|
|
@@ -52976,9 +53019,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
52976
53019
|
});
|
|
52977
53020
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
52978
53021
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
52979
|
-
const tmpDir =
|
|
53022
|
+
const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
52980
53023
|
if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
|
|
52981
|
-
const promptFile =
|
|
53024
|
+
const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
52982
53025
|
fs28.writeFileSync(promptFile, prompt, "utf-8");
|
|
52983
53026
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
52984
53027
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -53410,7 +53453,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
53410
53453
|
setMode: "set_mode.js"
|
|
53411
53454
|
};
|
|
53412
53455
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
53413
|
-
const scriptsDir =
|
|
53456
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
53414
53457
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
53415
53458
|
if (latestScriptsDir) {
|
|
53416
53459
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -53421,7 +53464,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
53421
53464
|
for (const file of fs28.readdirSync(latestScriptsDir)) {
|
|
53422
53465
|
if (file.endsWith(".js") && targetFileNames.has(file)) {
|
|
53423
53466
|
try {
|
|
53424
|
-
const content = fs28.readFileSync(
|
|
53467
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
|
|
53425
53468
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
53426
53469
|
lines.push("```javascript");
|
|
53427
53470
|
lines.push(content);
|
|
@@ -53438,7 +53481,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
53438
53481
|
lines.push("");
|
|
53439
53482
|
for (const file of refFiles) {
|
|
53440
53483
|
try {
|
|
53441
|
-
const content = fs28.readFileSync(
|
|
53484
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
|
|
53442
53485
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
53443
53486
|
lines.push("```javascript");
|
|
53444
53487
|
lines.push(content);
|
|
@@ -53479,10 +53522,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
53479
53522
|
lines.push("");
|
|
53480
53523
|
}
|
|
53481
53524
|
}
|
|
53482
|
-
const docsDir =
|
|
53525
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
53483
53526
|
const loadGuide = (name) => {
|
|
53484
53527
|
try {
|
|
53485
|
-
const p =
|
|
53528
|
+
const p = path39.join(docsDir, name);
|
|
53486
53529
|
if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
|
|
53487
53530
|
} catch {
|
|
53488
53531
|
}
|
|
@@ -53719,7 +53762,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
53719
53762
|
parseApproval: "parse_approval.js"
|
|
53720
53763
|
};
|
|
53721
53764
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
53722
|
-
const scriptsDir =
|
|
53765
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
53723
53766
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
53724
53767
|
if (latestScriptsDir) {
|
|
53725
53768
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -53731,7 +53774,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
53731
53774
|
if (!file.endsWith(".js")) continue;
|
|
53732
53775
|
if (!targetFileNames.has(file)) continue;
|
|
53733
53776
|
try {
|
|
53734
|
-
const content = fs28.readFileSync(
|
|
53777
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
|
|
53735
53778
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
53736
53779
|
lines.push("```javascript");
|
|
53737
53780
|
lines.push(content);
|
|
@@ -53747,7 +53790,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
53747
53790
|
lines.push("");
|
|
53748
53791
|
for (const file of refFiles) {
|
|
53749
53792
|
try {
|
|
53750
|
-
const content = fs28.readFileSync(
|
|
53793
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
|
|
53751
53794
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
53752
53795
|
lines.push("```javascript");
|
|
53753
53796
|
lines.push(content);
|
|
@@ -53780,10 +53823,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
53780
53823
|
lines.push("");
|
|
53781
53824
|
}
|
|
53782
53825
|
}
|
|
53783
|
-
const docsDir =
|
|
53826
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
53784
53827
|
const loadGuide = (name) => {
|
|
53785
53828
|
try {
|
|
53786
|
-
const p =
|
|
53829
|
+
const p = path39.join(docsDir, name);
|
|
53787
53830
|
if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
|
|
53788
53831
|
} catch {
|
|
53789
53832
|
}
|
|
@@ -54230,8 +54273,8 @@ var DevServer = class _DevServer {
|
|
|
54230
54273
|
}
|
|
54231
54274
|
getEndpointList() {
|
|
54232
54275
|
return this.routes.map((r) => {
|
|
54233
|
-
const
|
|
54234
|
-
return `${r.method.padEnd(5)} ${
|
|
54276
|
+
const path41 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
54277
|
+
return `${r.method.padEnd(5)} ${path41}`;
|
|
54235
54278
|
});
|
|
54236
54279
|
}
|
|
54237
54280
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -54519,12 +54562,12 @@ var DevServer = class _DevServer {
|
|
|
54519
54562
|
// ─── DevConsole SPA ───
|
|
54520
54563
|
getConsoleDistDir() {
|
|
54521
54564
|
const candidates = [
|
|
54522
|
-
|
|
54523
|
-
|
|
54524
|
-
|
|
54565
|
+
path40.resolve(__dirname, "../../web-devconsole/dist"),
|
|
54566
|
+
path40.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
54567
|
+
path40.join(process.cwd(), "packages/web-devconsole/dist")
|
|
54525
54568
|
];
|
|
54526
54569
|
for (const dir of candidates) {
|
|
54527
|
-
if (fs29.existsSync(
|
|
54570
|
+
if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
|
|
54528
54571
|
}
|
|
54529
54572
|
return null;
|
|
54530
54573
|
}
|
|
@@ -54534,7 +54577,7 @@ var DevServer = class _DevServer {
|
|
|
54534
54577
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
54535
54578
|
return;
|
|
54536
54579
|
}
|
|
54537
|
-
const htmlPath =
|
|
54580
|
+
const htmlPath = path40.join(distDir, "index.html");
|
|
54538
54581
|
try {
|
|
54539
54582
|
const html = fs29.readFileSync(htmlPath, "utf-8");
|
|
54540
54583
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -54559,15 +54602,15 @@ var DevServer = class _DevServer {
|
|
|
54559
54602
|
this.json(res, 404, { error: "Not found" });
|
|
54560
54603
|
return;
|
|
54561
54604
|
}
|
|
54562
|
-
const safePath =
|
|
54563
|
-
const filePath =
|
|
54605
|
+
const safePath = path40.normalize(pathname).replace(/^\.\.\//, "");
|
|
54606
|
+
const filePath = path40.join(distDir, safePath);
|
|
54564
54607
|
if (!filePath.startsWith(distDir)) {
|
|
54565
54608
|
this.json(res, 403, { error: "Forbidden" });
|
|
54566
54609
|
return;
|
|
54567
54610
|
}
|
|
54568
54611
|
try {
|
|
54569
54612
|
const content = fs29.readFileSync(filePath);
|
|
54570
|
-
const ext =
|
|
54613
|
+
const ext = path40.extname(filePath);
|
|
54571
54614
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
54572
54615
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
54573
54616
|
res.end(content);
|
|
@@ -54680,9 +54723,9 @@ var DevServer = class _DevServer {
|
|
|
54680
54723
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
54681
54724
|
if (entry.isDirectory()) {
|
|
54682
54725
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
54683
|
-
scan(
|
|
54726
|
+
scan(path40.join(d, entry.name), rel);
|
|
54684
54727
|
} else {
|
|
54685
|
-
const stat2 = fs29.statSync(
|
|
54728
|
+
const stat2 = fs29.statSync(path40.join(d, entry.name));
|
|
54686
54729
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
54687
54730
|
}
|
|
54688
54731
|
}
|
|
@@ -54705,7 +54748,7 @@ var DevServer = class _DevServer {
|
|
|
54705
54748
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54706
54749
|
return;
|
|
54707
54750
|
}
|
|
54708
|
-
const fullPath =
|
|
54751
|
+
const fullPath = path40.resolve(dir, path40.normalize(filePath));
|
|
54709
54752
|
if (!fullPath.startsWith(dir)) {
|
|
54710
54753
|
this.json(res, 403, { error: "Forbidden" });
|
|
54711
54754
|
return;
|
|
@@ -54730,14 +54773,14 @@ var DevServer = class _DevServer {
|
|
|
54730
54773
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54731
54774
|
return;
|
|
54732
54775
|
}
|
|
54733
|
-
const fullPath =
|
|
54776
|
+
const fullPath = path40.resolve(dir, path40.normalize(filePath));
|
|
54734
54777
|
if (!fullPath.startsWith(dir)) {
|
|
54735
54778
|
this.json(res, 403, { error: "Forbidden" });
|
|
54736
54779
|
return;
|
|
54737
54780
|
}
|
|
54738
54781
|
try {
|
|
54739
54782
|
if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
|
|
54740
|
-
fs29.mkdirSync(
|
|
54783
|
+
fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
54741
54784
|
fs29.writeFileSync(fullPath, content, "utf-8");
|
|
54742
54785
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
54743
54786
|
this.providerLoader.reload();
|
|
@@ -54754,7 +54797,7 @@ var DevServer = class _DevServer {
|
|
|
54754
54797
|
return;
|
|
54755
54798
|
}
|
|
54756
54799
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
54757
|
-
const p =
|
|
54800
|
+
const p = path40.join(dir, name);
|
|
54758
54801
|
if (fs29.existsSync(p)) {
|
|
54759
54802
|
const source = fs29.readFileSync(p, "utf-8");
|
|
54760
54803
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -54775,8 +54818,8 @@ var DevServer = class _DevServer {
|
|
|
54775
54818
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
54776
54819
|
return;
|
|
54777
54820
|
}
|
|
54778
|
-
const target = fs29.existsSync(
|
|
54779
|
-
const targetPath =
|
|
54821
|
+
const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
54822
|
+
const targetPath = path40.join(dir, target);
|
|
54780
54823
|
try {
|
|
54781
54824
|
if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
|
|
54782
54825
|
fs29.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -54923,7 +54966,7 @@ var DevServer = class _DevServer {
|
|
|
54923
54966
|
}
|
|
54924
54967
|
let targetDir;
|
|
54925
54968
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
54926
|
-
const jsonPath =
|
|
54969
|
+
const jsonPath = path40.join(targetDir, "provider.json");
|
|
54927
54970
|
if (fs29.existsSync(jsonPath)) {
|
|
54928
54971
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
54929
54972
|
return;
|
|
@@ -54935,8 +54978,8 @@ var DevServer = class _DevServer {
|
|
|
54935
54978
|
const createdFiles = ["provider.json"];
|
|
54936
54979
|
if (result.files) {
|
|
54937
54980
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
54938
|
-
const fullPath =
|
|
54939
|
-
fs29.mkdirSync(
|
|
54981
|
+
const fullPath = path40.join(targetDir, relPath);
|
|
54982
|
+
fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
54940
54983
|
fs29.writeFileSync(fullPath, content, "utf-8");
|
|
54941
54984
|
createdFiles.push(relPath);
|
|
54942
54985
|
}
|
|
@@ -54989,22 +55032,22 @@ var DevServer = class _DevServer {
|
|
|
54989
55032
|
if (!fs29.existsSync(scriptsDir)) return null;
|
|
54990
55033
|
const versions = fs29.readdirSync(scriptsDir).filter((d) => {
|
|
54991
55034
|
try {
|
|
54992
|
-
return fs29.statSync(
|
|
55035
|
+
return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
|
|
54993
55036
|
} catch {
|
|
54994
55037
|
return false;
|
|
54995
55038
|
}
|
|
54996
55039
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
54997
55040
|
if (versions.length === 0) return null;
|
|
54998
|
-
return
|
|
55041
|
+
return path40.join(scriptsDir, versions[0]);
|
|
54999
55042
|
}
|
|
55000
55043
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
55001
|
-
const canonicalUserDir =
|
|
55002
|
-
const desiredDir = requestedDir ?
|
|
55003
|
-
const upstreamRoot =
|
|
55004
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
55044
|
+
const canonicalUserDir = path40.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
55045
|
+
const desiredDir = requestedDir ? path40.resolve(requestedDir) : canonicalUserDir;
|
|
55046
|
+
const upstreamRoot = path40.resolve(this.providerLoader.getUpstreamDir());
|
|
55047
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path40.sep}`)) {
|
|
55005
55048
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
55006
55049
|
}
|
|
55007
|
-
if (
|
|
55050
|
+
if (path40.basename(desiredDir) !== type) {
|
|
55008
55051
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
55009
55052
|
}
|
|
55010
55053
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -55012,11 +55055,11 @@ var DevServer = class _DevServer {
|
|
|
55012
55055
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
55013
55056
|
}
|
|
55014
55057
|
if (!fs29.existsSync(desiredDir)) {
|
|
55015
|
-
fs29.mkdirSync(
|
|
55058
|
+
fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
|
|
55016
55059
|
fs29.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
55017
55060
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
55018
55061
|
}
|
|
55019
|
-
const providerJson =
|
|
55062
|
+
const providerJson = path40.join(desiredDir, "provider.json");
|
|
55020
55063
|
if (!fs29.existsSync(providerJson)) {
|
|
55021
55064
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
55022
55065
|
}
|
|
@@ -55052,7 +55095,7 @@ var DevServer = class _DevServer {
|
|
|
55052
55095
|
setMode: "set_mode.js"
|
|
55053
55096
|
};
|
|
55054
55097
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
55055
|
-
const scriptsDir =
|
|
55098
|
+
const scriptsDir = path40.join(providerDir, "scripts");
|
|
55056
55099
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
55057
55100
|
if (latestScriptsDir) {
|
|
55058
55101
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -55063,7 +55106,7 @@ var DevServer = class _DevServer {
|
|
|
55063
55106
|
for (const file of fs29.readdirSync(latestScriptsDir)) {
|
|
55064
55107
|
if (file.endsWith(".js") && targetFileNames.has(file)) {
|
|
55065
55108
|
try {
|
|
55066
|
-
const content = fs29.readFileSync(
|
|
55109
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
|
|
55067
55110
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
55068
55111
|
lines.push("```javascript");
|
|
55069
55112
|
lines.push(content);
|
|
@@ -55080,7 +55123,7 @@ var DevServer = class _DevServer {
|
|
|
55080
55123
|
lines.push("");
|
|
55081
55124
|
for (const file of refFiles) {
|
|
55082
55125
|
try {
|
|
55083
|
-
const content = fs29.readFileSync(
|
|
55126
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
|
|
55084
55127
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
55085
55128
|
lines.push("```javascript");
|
|
55086
55129
|
lines.push(content);
|
|
@@ -55121,10 +55164,10 @@ var DevServer = class _DevServer {
|
|
|
55121
55164
|
lines.push("");
|
|
55122
55165
|
}
|
|
55123
55166
|
}
|
|
55124
|
-
const docsDir =
|
|
55167
|
+
const docsDir = path40.join(providerDir, "../../docs");
|
|
55125
55168
|
const loadGuide = (name) => {
|
|
55126
55169
|
try {
|
|
55127
|
-
const p =
|
|
55170
|
+
const p = path40.join(docsDir, name);
|
|
55128
55171
|
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
55129
55172
|
} catch {
|
|
55130
55173
|
}
|
|
@@ -55298,7 +55341,7 @@ var DevServer = class _DevServer {
|
|
|
55298
55341
|
parseApproval: "parse_approval.js"
|
|
55299
55342
|
};
|
|
55300
55343
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
55301
|
-
const scriptsDir =
|
|
55344
|
+
const scriptsDir = path40.join(providerDir, "scripts");
|
|
55302
55345
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
55303
55346
|
if (latestScriptsDir) {
|
|
55304
55347
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -55310,7 +55353,7 @@ var DevServer = class _DevServer {
|
|
|
55310
55353
|
if (!file.endsWith(".js")) continue;
|
|
55311
55354
|
if (!targetFileNames.has(file)) continue;
|
|
55312
55355
|
try {
|
|
55313
|
-
const content = fs29.readFileSync(
|
|
55356
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
|
|
55314
55357
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
55315
55358
|
lines.push("```javascript");
|
|
55316
55359
|
lines.push(content);
|
|
@@ -55326,7 +55369,7 @@ var DevServer = class _DevServer {
|
|
|
55326
55369
|
lines.push("");
|
|
55327
55370
|
for (const file of refFiles) {
|
|
55328
55371
|
try {
|
|
55329
|
-
const content = fs29.readFileSync(
|
|
55372
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
|
|
55330
55373
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
55331
55374
|
lines.push("```javascript");
|
|
55332
55375
|
lines.push(content);
|
|
@@ -55359,10 +55402,10 @@ var DevServer = class _DevServer {
|
|
|
55359
55402
|
lines.push("");
|
|
55360
55403
|
}
|
|
55361
55404
|
}
|
|
55362
|
-
const docsDir =
|
|
55405
|
+
const docsDir = path40.join(providerDir, "../../docs");
|
|
55363
55406
|
const loadGuide = (name) => {
|
|
55364
55407
|
try {
|
|
55365
|
-
const p =
|
|
55408
|
+
const p = path40.join(docsDir, name);
|
|
55366
55409
|
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
55367
55410
|
} catch {
|
|
55368
55411
|
}
|
|
@@ -55627,6 +55670,7 @@ init_pty_transport();
|
|
|
55627
55670
|
// src/cli-adapters/session-host-transport.ts
|
|
55628
55671
|
var import_session_host_core9 = require("@adhdev/session-host-core");
|
|
55629
55672
|
init_logger();
|
|
55673
|
+
init_resolve_executable();
|
|
55630
55674
|
function shouldResumeAttachedSession(record) {
|
|
55631
55675
|
if (!record) return false;
|
|
55632
55676
|
if (record.lifecycle === "interrupted") return true;
|
|
@@ -56006,7 +56050,7 @@ var SessionHostPtyTransportFactory = class {
|
|
|
56006
56050
|
spawn(command, args, spawnOptions) {
|
|
56007
56051
|
return new SessionHostRuntimeTransport({
|
|
56008
56052
|
...this.options,
|
|
56009
|
-
command,
|
|
56053
|
+
command: resolveWin32Executable(command),
|
|
56010
56054
|
args,
|
|
56011
56055
|
spawnOptions
|
|
56012
56056
|
});
|
|
@@ -56335,7 +56379,7 @@ function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
|
|
|
56335
56379
|
}
|
|
56336
56380
|
|
|
56337
56381
|
// src/installer.ts
|
|
56338
|
-
var
|
|
56382
|
+
var import_child_process11 = require("child_process");
|
|
56339
56383
|
var import_util3 = require("util");
|
|
56340
56384
|
var EXTENSION_CATALOG = [
|
|
56341
56385
|
// AI Agent extensions
|
|
@@ -56423,7 +56467,7 @@ var EXTENSION_CATALOG = [
|
|
|
56423
56467
|
apiKeyName: "OpenAI/Anthropic API key"
|
|
56424
56468
|
}
|
|
56425
56469
|
];
|
|
56426
|
-
var execAsync4 = (0, import_util3.promisify)(
|
|
56470
|
+
var execAsync4 = (0, import_util3.promisify)(import_child_process11.exec);
|
|
56427
56471
|
async function isExtensionInstalled(ide, marketplaceId) {
|
|
56428
56472
|
if (!ide.cliCommand) return false;
|
|
56429
56473
|
try {
|
|
@@ -56467,7 +56511,7 @@ async function installExtension(ide, extension) {
|
|
|
56467
56511
|
fs30.writeFileSync(vsixPath, buffer);
|
|
56468
56512
|
return new Promise((resolve24) => {
|
|
56469
56513
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
56470
|
-
(0,
|
|
56514
|
+
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
56471
56515
|
resolve24({
|
|
56472
56516
|
extensionId: extension.id,
|
|
56473
56517
|
marketplaceId: extension.marketplaceId,
|
|
@@ -56483,7 +56527,7 @@ async function installExtension(ide, extension) {
|
|
|
56483
56527
|
}
|
|
56484
56528
|
return new Promise((resolve24) => {
|
|
56485
56529
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
56486
|
-
(0,
|
|
56530
|
+
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
|
|
56487
56531
|
if (error) {
|
|
56488
56532
|
resolve24({
|
|
56489
56533
|
extensionId: extension.id,
|
|
@@ -56520,7 +56564,7 @@ function launchIDE(ide, workspacePath) {
|
|
|
56520
56564
|
if (!ide.cliCommand) return false;
|
|
56521
56565
|
try {
|
|
56522
56566
|
const args = workspacePath ? `"${workspacePath}"` : "";
|
|
56523
|
-
(0,
|
|
56567
|
+
(0, import_child_process11.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
|
|
56524
56568
|
return true;
|
|
56525
56569
|
} catch {
|
|
56526
56570
|
return false;
|