@adhdev/daemon-standalone 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/index.js +507 -462
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30001,10 +30001,10 @@ var require_dist3 = __commonJS({
|
|
|
30001
30001
|
}
|
|
30002
30002
|
function getDaemonBuildInfo() {
|
|
30003
30003
|
if (cached2) return cached2;
|
|
30004
|
-
const commit = readInjected(true ? "
|
|
30005
|
-
const commitShort = readInjected(true ? "
|
|
30006
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30007
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30004
|
+
const commit = readInjected(true ? "850c147fda8183e55c145fcef876d2c25a22c8d2" : void 0) ?? "unknown";
|
|
30005
|
+
const commitShort = readInjected(true ? "850c147f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30006
|
+
const version2 = readInjected(true ? "0.9.82-rc.302" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30007
|
+
const builtAt = readInjected(true ? "2026-06-17T02:29:47.351Z" : void 0);
|
|
30008
30008
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30009
30009
|
return cached2;
|
|
30010
30010
|
}
|
|
@@ -30344,12 +30344,12 @@ var require_dist3 = __commonJS({
|
|
|
30344
30344
|
if (!match) continue;
|
|
30345
30345
|
const prefix = match[1];
|
|
30346
30346
|
const commit = match[2];
|
|
30347
|
-
const
|
|
30348
|
-
if (ignoreSet.has(
|
|
30347
|
+
const path41 = match[3];
|
|
30348
|
+
if (ignoreSet.has(path41)) continue;
|
|
30349
30349
|
submodules.push({
|
|
30350
|
-
path:
|
|
30350
|
+
path: path41,
|
|
30351
30351
|
commit,
|
|
30352
|
-
repoPath: repoRoot + "/" +
|
|
30352
|
+
repoPath: repoRoot + "/" + path41,
|
|
30353
30353
|
dirty: prefix === "U",
|
|
30354
30354
|
outOfSync: prefix === "-" || prefix === "+",
|
|
30355
30355
|
lastCheckedAt: Date.now()
|
|
@@ -31179,10 +31179,10 @@ ${error48.message || ""}`;
|
|
|
31179
31179
|
return (0, import_path22.join)(getConfigDir(), "meshes.json");
|
|
31180
31180
|
}
|
|
31181
31181
|
function loadMeshConfig() {
|
|
31182
|
-
const
|
|
31183
|
-
if (!(0, import_fs2.existsSync)(
|
|
31182
|
+
const path41 = getMeshConfigPath();
|
|
31183
|
+
if (!(0, import_fs2.existsSync)(path41)) return { meshes: [] };
|
|
31184
31184
|
try {
|
|
31185
|
-
const raw = JSON.parse((0, import_fs2.readFileSync)(
|
|
31185
|
+
const raw = JSON.parse((0, import_fs2.readFileSync)(path41, "utf-8"));
|
|
31186
31186
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
31187
31187
|
return raw;
|
|
31188
31188
|
} catch {
|
|
@@ -31200,16 +31200,16 @@ ${error48.message || ""}`;
|
|
|
31200
31200
|
return tags.length ? tags : void 0;
|
|
31201
31201
|
}
|
|
31202
31202
|
function saveMeshConfig(config2) {
|
|
31203
|
-
const
|
|
31204
|
-
(0, import_fs2.writeFileSync)(
|
|
31203
|
+
const path41 = getMeshConfigPath();
|
|
31204
|
+
(0, import_fs2.writeFileSync)(path41, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
31205
31205
|
}
|
|
31206
31206
|
function normalizeRepoIdentity(remoteUrl) {
|
|
31207
31207
|
let identity = remoteUrl.trim();
|
|
31208
31208
|
if (identity.startsWith("http://") || identity.startsWith("https://")) {
|
|
31209
31209
|
try {
|
|
31210
31210
|
const url2 = new URL(identity);
|
|
31211
|
-
const
|
|
31212
|
-
return `${url2.hostname}/${
|
|
31211
|
+
const path41 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
31212
|
+
return `${url2.hostname}/${path41}`;
|
|
31213
31213
|
} catch {
|
|
31214
31214
|
}
|
|
31215
31215
|
}
|
|
@@ -31896,10 +31896,10 @@ Follow these recovery rules:
|
|
|
31896
31896
|
}
|
|
31897
31897
|
}
|
|
31898
31898
|
function readArchivedCounts(meshId) {
|
|
31899
|
-
const
|
|
31900
|
-
if (!(0, import_fs3.existsSync)(
|
|
31899
|
+
const path41 = getArchivedCountsPath(meshId);
|
|
31900
|
+
if (!(0, import_fs3.existsSync)(path41)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
31901
31901
|
try {
|
|
31902
|
-
return JSON.parse((0, import_fs3.readFileSync)(
|
|
31902
|
+
return JSON.parse((0, import_fs3.readFileSync)(path41, "utf-8"));
|
|
31903
31903
|
} catch {
|
|
31904
31904
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
31905
31905
|
}
|
|
@@ -33328,10 +33328,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33328
33328
|
this.migratedMeshIds.add(meshId);
|
|
33329
33329
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
33330
33330
|
if (count.count > 0) return;
|
|
33331
|
-
const
|
|
33332
|
-
if (!(0, import_fs4.existsSync)(
|
|
33331
|
+
const path41 = legacyQueuePath(meshId);
|
|
33332
|
+
if (!(0, import_fs4.existsSync)(path41)) return;
|
|
33333
33333
|
try {
|
|
33334
|
-
const entries = JSON.parse((0, import_fs4.readFileSync)(
|
|
33334
|
+
const entries = JSON.parse((0, import_fs4.readFileSync)(path41, "utf-8"));
|
|
33335
33335
|
if (!Array.isArray(entries)) return;
|
|
33336
33336
|
const insert = this.db.prepare(`
|
|
33337
33337
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -35097,8 +35097,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
35097
35097
|
}
|
|
35098
35098
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
35099
35099
|
if (mcpConfig.mode === "auto_import") {
|
|
35100
|
-
const
|
|
35101
|
-
if (!
|
|
35100
|
+
const path41 = mcpConfig.path?.trim();
|
|
35101
|
+
if (!path41) {
|
|
35102
35102
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
35103
35103
|
}
|
|
35104
35104
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -35118,7 +35118,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
35118
35118
|
return {
|
|
35119
35119
|
kind: "auto_import",
|
|
35120
35120
|
serverName,
|
|
35121
|
-
configPath: resolveMcpConfigPath(
|
|
35121
|
+
configPath: resolveMcpConfigPath(path41, workspace),
|
|
35122
35122
|
configFormat: mcpConfig.format,
|
|
35123
35123
|
mcpServer
|
|
35124
35124
|
};
|
|
@@ -36135,12 +36135,12 @@ ${rendered}`, "utf-8");
|
|
|
36135
36135
|
if (!Array.isArray(value)) return void 0;
|
|
36136
36136
|
const submodules = value.map((entry) => {
|
|
36137
36137
|
const submodule = readRecord3(entry);
|
|
36138
|
-
const
|
|
36138
|
+
const path41 = readString5(submodule.path);
|
|
36139
36139
|
const commit = readString5(submodule.commit);
|
|
36140
|
-
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot,
|
|
36141
|
-
if (!
|
|
36140
|
+
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path41);
|
|
36141
|
+
if (!path41 || !commit) return null;
|
|
36142
36142
|
const result = {
|
|
36143
|
-
path:
|
|
36143
|
+
path: path41,
|
|
36144
36144
|
commit,
|
|
36145
36145
|
dirty: readBoolean(submodule.dirty) ?? false,
|
|
36146
36146
|
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
@@ -36535,10 +36535,10 @@ Next step: ${nextStep}`;
|
|
|
36535
36535
|
const primaryDaemonId = daemonIds[0];
|
|
36536
36536
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
36537
36537
|
const events = [];
|
|
36538
|
-
for (const
|
|
36539
|
-
if (!(0, import_fs8.existsSync)(
|
|
36538
|
+
for (const path41 of paths) {
|
|
36539
|
+
if (!(0, import_fs8.existsSync)(path41)) continue;
|
|
36540
36540
|
try {
|
|
36541
|
-
const raw = (0, import_fs8.readFileSync)(
|
|
36541
|
+
const raw = (0, import_fs8.readFileSync)(path41, "utf-8");
|
|
36542
36542
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
36543
36543
|
try {
|
|
36544
36544
|
return [JSON.parse(line)];
|
|
@@ -36546,7 +36546,7 @@ Next step: ${nextStep}`;
|
|
|
36546
36546
|
return [];
|
|
36547
36547
|
}
|
|
36548
36548
|
});
|
|
36549
|
-
const filtered = primaryDaemonId &&
|
|
36549
|
+
const filtered = primaryDaemonId && path41 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
|
|
36550
36550
|
events.push(...filtered);
|
|
36551
36551
|
} catch {
|
|
36552
36552
|
}
|
|
@@ -36611,13 +36611,13 @@ Next step: ${nextStep}`;
|
|
|
36611
36611
|
const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
|
|
36612
36612
|
return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
|
|
36613
36613
|
}
|
|
36614
|
-
function trimPendingEventsIfNeeded(
|
|
36614
|
+
function trimPendingEventsIfNeeded(path41) {
|
|
36615
36615
|
try {
|
|
36616
|
-
if (!(0, import_fs8.existsSync)(
|
|
36617
|
-
if ((0, import_fs8.statSync)(
|
|
36618
|
-
const lines = (0, import_fs8.readFileSync)(
|
|
36616
|
+
if (!(0, import_fs8.existsSync)(path41)) return;
|
|
36617
|
+
if ((0, import_fs8.statSync)(path41).size <= MAX_PENDING_EVENTS_BYTES) return;
|
|
36618
|
+
const lines = (0, import_fs8.readFileSync)(path41, "utf-8").split("\n").filter(Boolean);
|
|
36619
36619
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
36620
|
-
(0, import_fs8.writeFileSync)(
|
|
36620
|
+
(0, import_fs8.writeFileSync)(path41, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
36621
36621
|
} catch {
|
|
36622
36622
|
}
|
|
36623
36623
|
}
|
|
@@ -36644,19 +36644,19 @@ Next step: ${nextStep}`;
|
|
|
36644
36644
|
});
|
|
36645
36645
|
} catch {
|
|
36646
36646
|
}
|
|
36647
|
-
const
|
|
36648
|
-
trimPendingEventsIfNeeded(
|
|
36649
|
-
(0, import_fs8.appendFileSync)(
|
|
36647
|
+
const path41 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
36648
|
+
trimPendingEventsIfNeeded(path41);
|
|
36649
|
+
(0, import_fs8.appendFileSync)(path41, JSON.stringify(event) + "\n", "utf-8");
|
|
36650
36650
|
return true;
|
|
36651
36651
|
} catch (e) {
|
|
36652
36652
|
LOG2.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
36653
36653
|
return false;
|
|
36654
36654
|
}
|
|
36655
36655
|
}
|
|
36656
|
-
function atomicDrainFile(
|
|
36657
|
-
const tmpPath = `${
|
|
36656
|
+
function atomicDrainFile(path41) {
|
|
36657
|
+
const tmpPath = `${path41}.draining`;
|
|
36658
36658
|
try {
|
|
36659
|
-
(0, import_fs8.renameSync)(
|
|
36659
|
+
(0, import_fs8.renameSync)(path41, tmpPath);
|
|
36660
36660
|
} catch {
|
|
36661
36661
|
return null;
|
|
36662
36662
|
}
|
|
@@ -36675,10 +36675,10 @@ Next step: ${nextStep}`;
|
|
|
36675
36675
|
return null;
|
|
36676
36676
|
}
|
|
36677
36677
|
}
|
|
36678
|
-
function selectiveDrainFile(
|
|
36679
|
-
const tmpPath = `${
|
|
36678
|
+
function selectiveDrainFile(path41, predicate) {
|
|
36679
|
+
const tmpPath = `${path41}.draining`;
|
|
36680
36680
|
try {
|
|
36681
|
-
(0, import_fs8.renameSync)(
|
|
36681
|
+
(0, import_fs8.renameSync)(path41, tmpPath);
|
|
36682
36682
|
} catch {
|
|
36683
36683
|
return [];
|
|
36684
36684
|
}
|
|
@@ -36710,12 +36710,12 @@ Next step: ${nextStep}`;
|
|
|
36710
36710
|
}
|
|
36711
36711
|
try {
|
|
36712
36712
|
if (keptLines.length > 0) {
|
|
36713
|
-
(0, import_fs8.writeFileSync)(
|
|
36713
|
+
(0, import_fs8.writeFileSync)(path41, keptLines.join("\n") + "\n", "utf-8");
|
|
36714
36714
|
}
|
|
36715
36715
|
(0, import_fs8.unlinkSync)(tmpPath);
|
|
36716
36716
|
} catch {
|
|
36717
36717
|
try {
|
|
36718
|
-
if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(
|
|
36718
|
+
if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(path41)) (0, import_fs8.renameSync)(tmpPath, path41);
|
|
36719
36719
|
} catch {
|
|
36720
36720
|
}
|
|
36721
36721
|
return [];
|
|
@@ -36749,16 +36749,16 @@ Next step: ${nextStep}`;
|
|
|
36749
36749
|
} catch {
|
|
36750
36750
|
}
|
|
36751
36751
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
36752
|
-
for (const
|
|
36753
|
-
const isSharedFile = !!primaryDaemonId &&
|
|
36752
|
+
for (const path41 of paths) {
|
|
36753
|
+
const isSharedFile = !!primaryDaemonId && path41 === getPendingEventsPath(meshId);
|
|
36754
36754
|
const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
|
|
36755
36755
|
if (onlyEvents) {
|
|
36756
|
-
for (const event of selectiveDrainFile(
|
|
36756
|
+
for (const event of selectiveDrainFile(path41, (e) => targets(e) && matchesFilter(e.event))) {
|
|
36757
36757
|
pushUnique(event);
|
|
36758
36758
|
}
|
|
36759
36759
|
continue;
|
|
36760
36760
|
}
|
|
36761
|
-
const content = atomicDrainFile(
|
|
36761
|
+
const content = atomicDrainFile(path41);
|
|
36762
36762
|
if (!content) continue;
|
|
36763
36763
|
const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
|
|
36764
36764
|
try {
|
|
@@ -36808,9 +36808,9 @@ Next step: ${nextStep}`;
|
|
|
36808
36808
|
} catch {
|
|
36809
36809
|
}
|
|
36810
36810
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
36811
|
-
for (const
|
|
36812
|
-
if ((0, import_fs8.existsSync)(
|
|
36813
|
-
(0, import_fs8.unlinkSync)(
|
|
36811
|
+
for (const path41 of paths) {
|
|
36812
|
+
if ((0, import_fs8.existsSync)(path41)) try {
|
|
36813
|
+
(0, import_fs8.unlinkSync)(path41);
|
|
36814
36814
|
} catch {
|
|
36815
36815
|
}
|
|
36816
36816
|
}
|
|
@@ -39828,7 +39828,7 @@ Next step: ${nextStep}`;
|
|
|
39828
39828
|
return _cliValidator;
|
|
39829
39829
|
}
|
|
39830
39830
|
function formatIssue(err) {
|
|
39831
|
-
const
|
|
39831
|
+
const path41 = err.instancePath || "";
|
|
39832
39832
|
const params = err.params;
|
|
39833
39833
|
let message = err.message || "validation failed";
|
|
39834
39834
|
let allowed;
|
|
@@ -39846,7 +39846,7 @@ Next step: ${nextStep}`;
|
|
|
39846
39846
|
} else if (err.keyword === "type") {
|
|
39847
39847
|
message = `must be ${params.type}`;
|
|
39848
39848
|
}
|
|
39849
|
-
return { path:
|
|
39849
|
+
return { path: path41, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
39850
39850
|
}
|
|
39851
39851
|
function validateCliProviderManifest(manifest) {
|
|
39852
39852
|
const validator = getCliValidator();
|
|
@@ -40207,6 +40207,38 @@ Next step: ${nextStep}`;
|
|
|
40207
40207
|
import_session_host_core32 = require_dist();
|
|
40208
40208
|
}
|
|
40209
40209
|
});
|
|
40210
|
+
function resolveWin32Executable(command) {
|
|
40211
|
+
if (process.platform !== "win32") return command;
|
|
40212
|
+
const trimmed = (command || "").trim();
|
|
40213
|
+
if (!trimmed) return command;
|
|
40214
|
+
if (path16.isAbsolute(trimmed) && (0, import_fs13.existsSync)(trimmed)) return trimmed;
|
|
40215
|
+
try {
|
|
40216
|
+
const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
|
|
40217
|
+
encoding: "utf8",
|
|
40218
|
+
windowsHide: true
|
|
40219
|
+
}).trim();
|
|
40220
|
+
if (out) {
|
|
40221
|
+
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
40222
|
+
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path16.extname(m).toLowerCase()));
|
|
40223
|
+
return direct || matches[0] || command;
|
|
40224
|
+
}
|
|
40225
|
+
} catch {
|
|
40226
|
+
}
|
|
40227
|
+
return command;
|
|
40228
|
+
}
|
|
40229
|
+
var import_child_process4;
|
|
40230
|
+
var import_fs13;
|
|
40231
|
+
var path16;
|
|
40232
|
+
var DIRECT_EXEC_EXT;
|
|
40233
|
+
var init_resolve_executable = __esm2({
|
|
40234
|
+
"src/cli-adapters/resolve-executable.ts"() {
|
|
40235
|
+
"use strict";
|
|
40236
|
+
import_child_process4 = require("child_process");
|
|
40237
|
+
import_fs13 = require("fs");
|
|
40238
|
+
path16 = __toESM2(require("path"));
|
|
40239
|
+
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
40240
|
+
}
|
|
40241
|
+
});
|
|
40210
40242
|
var pty_transport_exports = {};
|
|
40211
40243
|
__export2(pty_transport_exports, {
|
|
40212
40244
|
NodePtyTransportFactory: () => NodePtyTransportFactory
|
|
@@ -40230,6 +40262,7 @@ Next step: ${nextStep}`;
|
|
|
40230
40262
|
"use strict";
|
|
40231
40263
|
os11 = __toESM2(require("os"));
|
|
40232
40264
|
init_spawn_env();
|
|
40265
|
+
init_resolve_executable();
|
|
40233
40266
|
NodePtyRuntimeTransport = class {
|
|
40234
40267
|
constructor(handle) {
|
|
40235
40268
|
this.handle = handle;
|
|
@@ -40272,7 +40305,7 @@ Next step: ${nextStep}`;
|
|
|
40272
40305
|
cwd = os11.homedir();
|
|
40273
40306
|
}
|
|
40274
40307
|
}
|
|
40275
|
-
const handle = pty.spawn(command, args, {
|
|
40308
|
+
const handle = pty.spawn(resolveWin32Executable(command), args, {
|
|
40276
40309
|
name: "xterm-256color",
|
|
40277
40310
|
cols: options.cols,
|
|
40278
40311
|
rows: options.rows,
|
|
@@ -40359,17 +40392,17 @@ Next step: ${nextStep}`;
|
|
|
40359
40392
|
function findBinary(name) {
|
|
40360
40393
|
const trimmed = String(name || "").trim();
|
|
40361
40394
|
if (!trimmed) return trimmed;
|
|
40362
|
-
const expanded = trimmed.startsWith("~") ?
|
|
40363
|
-
if (
|
|
40364
|
-
return
|
|
40395
|
+
const expanded = trimmed.startsWith("~") ? path17.join(os12.homedir(), trimmed.slice(1)) : trimmed;
|
|
40396
|
+
if (path17.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
40397
|
+
return path17.isAbsolute(expanded) ? expanded : path17.resolve(expanded);
|
|
40365
40398
|
}
|
|
40366
40399
|
const isWin = os12.platform() === "win32";
|
|
40367
|
-
const paths = (process.env.PATH || "").split(
|
|
40400
|
+
const paths = (process.env.PATH || "").split(path17.delimiter);
|
|
40368
40401
|
const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
40369
40402
|
for (const p of paths) {
|
|
40370
40403
|
if (!p) continue;
|
|
40371
40404
|
for (const ext of exes) {
|
|
40372
|
-
const fullPath =
|
|
40405
|
+
const fullPath = path17.join(p, trimmed + ext);
|
|
40373
40406
|
try {
|
|
40374
40407
|
const fs30 = require("fs");
|
|
40375
40408
|
if (fs30.existsSync(fullPath)) {
|
|
@@ -40385,7 +40418,7 @@ Next step: ${nextStep}`;
|
|
|
40385
40418
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
40386
40419
|
}
|
|
40387
40420
|
function isScriptBinary(binaryPath) {
|
|
40388
|
-
if (!
|
|
40421
|
+
if (!path17.isAbsolute(binaryPath)) return false;
|
|
40389
40422
|
try {
|
|
40390
40423
|
const fs30 = require("fs");
|
|
40391
40424
|
const resolved = fs30.realpathSync(binaryPath);
|
|
@@ -40401,7 +40434,7 @@ Next step: ${nextStep}`;
|
|
|
40401
40434
|
}
|
|
40402
40435
|
}
|
|
40403
40436
|
function looksLikeMachOOrElf(filePath) {
|
|
40404
|
-
if (!
|
|
40437
|
+
if (!path17.isAbsolute(filePath)) return false;
|
|
40405
40438
|
try {
|
|
40406
40439
|
const fs30 = require("fs");
|
|
40407
40440
|
const resolved = fs30.realpathSync(filePath);
|
|
@@ -40491,14 +40524,14 @@ Next step: ${nextStep}`;
|
|
|
40491
40524
|
};
|
|
40492
40525
|
}
|
|
40493
40526
|
var os12;
|
|
40494
|
-
var
|
|
40527
|
+
var path17;
|
|
40495
40528
|
var TerminalTranscriptAccumulator;
|
|
40496
40529
|
var buildCliSpawnEnv;
|
|
40497
40530
|
var init_provider_cli_shared = __esm2({
|
|
40498
40531
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
40499
40532
|
"use strict";
|
|
40500
40533
|
os12 = __toESM2(require("os"));
|
|
40501
|
-
|
|
40534
|
+
path17 = __toESM2(require("path"));
|
|
40502
40535
|
init_spawn_env();
|
|
40503
40536
|
TerminalTranscriptAccumulator = class {
|
|
40504
40537
|
lines = [[]];
|
|
@@ -42449,9 +42482,9 @@ ${cont}` : cont;
|
|
|
42449
42482
|
);
|
|
42450
42483
|
let shellCmd;
|
|
42451
42484
|
let shellArgs;
|
|
42452
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
42485
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
42453
42486
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
42454
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
42487
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
42455
42488
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
42456
42489
|
if (useShell) {
|
|
42457
42490
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -42528,13 +42561,13 @@ ${cont}` : cont;
|
|
|
42528
42561
|
return "";
|
|
42529
42562
|
}
|
|
42530
42563
|
var os13;
|
|
42531
|
-
var
|
|
42564
|
+
var path18;
|
|
42532
42565
|
var import_session_host_core42;
|
|
42533
42566
|
var init_provider_cli_runtime = __esm2({
|
|
42534
42567
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
42535
42568
|
"use strict";
|
|
42536
42569
|
os13 = __toESM2(require("os"));
|
|
42537
|
-
|
|
42570
|
+
path18 = __toESM2(require("path"));
|
|
42538
42571
|
import_session_host_core42 = require_dist();
|
|
42539
42572
|
init_provider_cli_shared();
|
|
42540
42573
|
}
|
|
@@ -44711,40 +44744,40 @@ ${lastSnapshot}`;
|
|
|
44711
44744
|
}
|
|
44712
44745
|
return errs;
|
|
44713
44746
|
}
|
|
44714
|
-
function validateCondition(c, sectionIds,
|
|
44747
|
+
function validateCondition(c, sectionIds, path41) {
|
|
44715
44748
|
const errs = [];
|
|
44716
44749
|
const w = c;
|
|
44717
44750
|
if ("all" in w) {
|
|
44718
|
-
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
44751
|
+
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.all[${i}]`)));
|
|
44719
44752
|
return errs;
|
|
44720
44753
|
}
|
|
44721
44754
|
if ("any" in w) {
|
|
44722
|
-
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
44755
|
+
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.any[${i}]`)));
|
|
44723
44756
|
return errs;
|
|
44724
44757
|
}
|
|
44725
44758
|
if ("not" in w) {
|
|
44726
|
-
errs.push(...validateCondition(w.not, sectionIds, `${
|
|
44759
|
+
errs.push(...validateCondition(w.not, sectionIds, `${path41}.not`));
|
|
44727
44760
|
return errs;
|
|
44728
44761
|
}
|
|
44729
44762
|
if ("matches" in w) {
|
|
44730
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
44763
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path41}.section "${w.section}" unknown`);
|
|
44731
44764
|
try {
|
|
44732
44765
|
new RegExp(w.matches, w.flags ?? "i");
|
|
44733
44766
|
} catch (e) {
|
|
44734
|
-
errs.push(`${
|
|
44767
|
+
errs.push(`${path41}.matches invalid regex: ${e.message}`);
|
|
44735
44768
|
}
|
|
44736
44769
|
return errs;
|
|
44737
44770
|
}
|
|
44738
44771
|
if ("cursor_above" in w && "changed" in w) return errs;
|
|
44739
44772
|
if ("elapsed_ms" in w) {
|
|
44740
|
-
if (typeof w.elapsed_ms !== "number") errs.push(`${
|
|
44773
|
+
if (typeof w.elapsed_ms !== "number") errs.push(`${path41}.elapsed_ms must be a number`);
|
|
44741
44774
|
return errs;
|
|
44742
44775
|
}
|
|
44743
44776
|
if ("stable_ms" in w) {
|
|
44744
|
-
if (typeof w.stable_ms !== "number") errs.push(`${
|
|
44777
|
+
if (typeof w.stable_ms !== "number") errs.push(`${path41}.stable_ms must be a number`);
|
|
44745
44778
|
return errs;
|
|
44746
44779
|
}
|
|
44747
|
-
errs.push(`${
|
|
44780
|
+
errs.push(`${path41} is not a recognized condition`);
|
|
44748
44781
|
return errs;
|
|
44749
44782
|
}
|
|
44750
44783
|
var fs9;
|
|
@@ -44902,7 +44935,7 @@ ${lastSnapshot}`;
|
|
|
44902
44935
|
}
|
|
44903
44936
|
function canonicalize(p) {
|
|
44904
44937
|
try {
|
|
44905
|
-
const resolved =
|
|
44938
|
+
const resolved = path31.resolve(p);
|
|
44906
44939
|
try {
|
|
44907
44940
|
return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
|
|
44908
44941
|
} catch {
|
|
@@ -44922,7 +44955,7 @@ ${lastSnapshot}`;
|
|
|
44922
44955
|
}
|
|
44923
44956
|
for (const root of _gatedRoots) {
|
|
44924
44957
|
if (normalized === root.rootPath) return root;
|
|
44925
|
-
if (normalized.startsWith(root.rootPath +
|
|
44958
|
+
if (normalized.startsWith(root.rootPath + path31.sep)) return root;
|
|
44926
44959
|
}
|
|
44927
44960
|
return null;
|
|
44928
44961
|
}
|
|
@@ -44941,16 +44974,16 @@ ${lastSnapshot}`;
|
|
|
44941
44974
|
};
|
|
44942
44975
|
}
|
|
44943
44976
|
function gatedRequire(request, parent, isMain, gated, originalLoad) {
|
|
44944
|
-
if (request.startsWith("./") || request.startsWith("../") ||
|
|
44977
|
+
if (request.startsWith("./") || request.startsWith("../") || path31.isAbsolute(request)) {
|
|
44945
44978
|
let resolved;
|
|
44946
44979
|
try {
|
|
44947
|
-
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(
|
|
44980
|
+
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path31.join(gated.rootPath, "__entry__.js"));
|
|
44948
44981
|
resolved = callerRequire.resolve(request);
|
|
44949
44982
|
} catch {
|
|
44950
44983
|
return originalLoad.call(this, request, parent, isMain);
|
|
44951
44984
|
}
|
|
44952
44985
|
const resolvedCanon = canonicalize(resolved) || resolved;
|
|
44953
|
-
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath +
|
|
44986
|
+
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path31.sep))) {
|
|
44954
44987
|
denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
|
|
44955
44988
|
}
|
|
44956
44989
|
return originalLoad.call(this, request, parent, isMain);
|
|
@@ -44974,7 +45007,7 @@ ${lastSnapshot}`;
|
|
|
44974
45007
|
err.callerFilename = caller;
|
|
44975
45008
|
throw err;
|
|
44976
45009
|
}
|
|
44977
|
-
var
|
|
45010
|
+
var path31;
|
|
44978
45011
|
var import_node_module2;
|
|
44979
45012
|
var nodeFs;
|
|
44980
45013
|
var nodeChildProcess;
|
|
@@ -44995,7 +45028,7 @@ ${lastSnapshot}`;
|
|
|
44995
45028
|
var init_require_whitelist = __esm2({
|
|
44996
45029
|
"src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
|
|
44997
45030
|
"use strict";
|
|
44998
|
-
|
|
45031
|
+
path31 = __toESM2(require("path"));
|
|
44999
45032
|
import_node_module2 = require("module");
|
|
45000
45033
|
nodeFs = __toESM2(require("fs"));
|
|
45001
45034
|
nodeChildProcess = __toESM2(require("child_process"));
|
|
@@ -47140,10 +47173,10 @@ ${lastSnapshot}`;
|
|
|
47140
47173
|
return (0, import_path5.join)(getDaemonDataDir(), "mesh-coordinators.json");
|
|
47141
47174
|
}
|
|
47142
47175
|
function loadMeshCoordinatorRegistry() {
|
|
47143
|
-
const
|
|
47144
|
-
if (!(0, import_fs5.existsSync)(
|
|
47176
|
+
const path41 = getRegistryPath();
|
|
47177
|
+
if (!(0, import_fs5.existsSync)(path41)) return;
|
|
47145
47178
|
try {
|
|
47146
|
-
const raw = JSON.parse((0, import_fs5.readFileSync)(
|
|
47179
|
+
const raw = JSON.parse((0, import_fs5.readFileSync)(path41, "utf-8"));
|
|
47147
47180
|
if (!Array.isArray(raw)) return;
|
|
47148
47181
|
_registry.clear();
|
|
47149
47182
|
for (const entry of raw) {
|
|
@@ -47379,8 +47412,8 @@ ${lastSnapshot}`;
|
|
|
47379
47412
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
47380
47413
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
|
|
47381
47414
|
}
|
|
47382
|
-
function parseConfigText(
|
|
47383
|
-
if (/\.json$/i.test(
|
|
47415
|
+
function parseConfigText(path41, text) {
|
|
47416
|
+
if (/\.json$/i.test(path41)) return JSON.parse(text);
|
|
47384
47417
|
return yaml.load(text);
|
|
47385
47418
|
}
|
|
47386
47419
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -47536,8 +47569,8 @@ ${lastSnapshot}`;
|
|
|
47536
47569
|
var DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
47537
47570
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
47538
47571
|
var OUTPUT_SUMMARY_CHARS = 2e3;
|
|
47539
|
-
function parseConfigText2(
|
|
47540
|
-
if (/\.json$/i.test(
|
|
47572
|
+
function parseConfigText2(path41, text) {
|
|
47573
|
+
if (/\.json$/i.test(path41)) return JSON.parse(text);
|
|
47541
47574
|
return yaml2.load(text);
|
|
47542
47575
|
}
|
|
47543
47576
|
function truncateOutput(value) {
|
|
@@ -59157,8 +59190,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59157
59190
|
*/
|
|
59158
59191
|
getUpstreamInstallRoot() {
|
|
59159
59192
|
const os30 = require("os");
|
|
59160
|
-
const
|
|
59161
|
-
return
|
|
59193
|
+
const path41 = require("path");
|
|
59194
|
+
return path41.join(os30.homedir(), ".adhdev", "providers", ".upstream");
|
|
59162
59195
|
}
|
|
59163
59196
|
/**
|
|
59164
59197
|
* Download a single provider manifest from the registry and write it to
|
|
@@ -59183,7 +59216,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59183
59216
|
}
|
|
59184
59217
|
const https = require("https");
|
|
59185
59218
|
const fs30 = require("fs");
|
|
59186
|
-
const
|
|
59219
|
+
const path41 = require("path");
|
|
59187
59220
|
const crypto6 = require("crypto");
|
|
59188
59221
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
59189
59222
|
function fetchText(url2, timeoutMs) {
|
|
@@ -59221,9 +59254,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59221
59254
|
return { success: false, error: `checksum mismatch: expected ${meta3.checksum}, got ${actualChecksum}` };
|
|
59222
59255
|
}
|
|
59223
59256
|
const installRoot = this.getUpstreamInstallRoot();
|
|
59224
|
-
const installRootResolved =
|
|
59225
|
-
const targetDir =
|
|
59226
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
59257
|
+
const installRootResolved = path41.resolve(installRoot);
|
|
59258
|
+
const targetDir = path41.resolve(path41.join(installRoot, category, type));
|
|
59259
|
+
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
59227
59260
|
return { success: false, error: "install path escaped upstream root" };
|
|
59228
59261
|
}
|
|
59229
59262
|
fs30.mkdirSync(targetDir, { recursive: true });
|
|
@@ -59250,7 +59283,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59250
59283
|
}
|
|
59251
59284
|
}
|
|
59252
59285
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
59253
|
-
const targetPath =
|
|
59286
|
+
const targetPath = path41.join(targetDir, targetFile);
|
|
59254
59287
|
fs30.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
59255
59288
|
const manifestJson = JSON.parse(manifestBody);
|
|
59256
59289
|
const scriptFetch = await this.fetchProviderSources(
|
|
@@ -59322,7 +59355,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59322
59355
|
const ref = source.ref;
|
|
59323
59356
|
const https = require("https");
|
|
59324
59357
|
const fs30 = require("fs");
|
|
59325
|
-
const
|
|
59358
|
+
const path41 = require("path");
|
|
59326
59359
|
function fetchJson(url2, timeoutMs) {
|
|
59327
59360
|
return new Promise((resolve24, reject) => {
|
|
59328
59361
|
const req = https.get(url2, {
|
|
@@ -59378,9 +59411,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59378
59411
|
}
|
|
59379
59412
|
let fetchedCount = 0;
|
|
59380
59413
|
const sharedDirRel = `${category}/_shared`;
|
|
59381
|
-
const sharedTargetDir =
|
|
59382
|
-
const installRootResolved =
|
|
59383
|
-
if (sharedTargetDir.startsWith(installRootResolved +
|
|
59414
|
+
const sharedTargetDir = path41.resolve(path41.join(targetDir, "../_shared"));
|
|
59415
|
+
const installRootResolved = path41.resolve(path41.join(targetDir, "../.."));
|
|
59416
|
+
if (sharedTargetDir.startsWith(installRootResolved + path41.sep)) {
|
|
59384
59417
|
const sharedStack = [sharedDirRel];
|
|
59385
59418
|
while (sharedStack.length) {
|
|
59386
59419
|
const relDir = sharedStack.pop();
|
|
@@ -59403,9 +59436,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59403
59436
|
try {
|
|
59404
59437
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
59405
59438
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
59406
|
-
const outPath =
|
|
59407
|
-
if (!outPath.startsWith(
|
|
59408
|
-
fs30.mkdirSync(
|
|
59439
|
+
const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
|
|
59440
|
+
if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
|
|
59441
|
+
fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
59409
59442
|
fs30.writeFileSync(outPath, body);
|
|
59410
59443
|
fetchedCount++;
|
|
59411
59444
|
} catch (e) {
|
|
@@ -59439,12 +59472,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59439
59472
|
try {
|
|
59440
59473
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
59441
59474
|
const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
|
|
59442
|
-
const outPath =
|
|
59443
|
-
if (!outPath.startsWith(
|
|
59475
|
+
const outPath = path41.resolve(path41.join(targetDir, relInsideProvider));
|
|
59476
|
+
if (!outPath.startsWith(path41.resolve(targetDir) + path41.sep)) {
|
|
59444
59477
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
59445
59478
|
continue;
|
|
59446
59479
|
}
|
|
59447
|
-
fs30.mkdirSync(
|
|
59480
|
+
fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
59448
59481
|
fs30.writeFileSync(outPath, body);
|
|
59449
59482
|
fetchedCount++;
|
|
59450
59483
|
} catch (e) {
|
|
@@ -59474,12 +59507,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59474
59507
|
return { success: false, error: `unknown category: ${category}` };
|
|
59475
59508
|
}
|
|
59476
59509
|
const fs30 = require("fs");
|
|
59477
|
-
const
|
|
59510
|
+
const path41 = require("path");
|
|
59478
59511
|
try {
|
|
59479
59512
|
const installRoot = this.getUpstreamInstallRoot();
|
|
59480
|
-
const installRootResolved =
|
|
59481
|
-
const targetDir =
|
|
59482
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
59513
|
+
const installRootResolved = path41.resolve(installRoot);
|
|
59514
|
+
const targetDir = path41.resolve(path41.join(installRoot, category, type));
|
|
59515
|
+
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
59483
59516
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
59484
59517
|
}
|
|
59485
59518
|
if (!fs30.existsSync(targetDir)) {
|
|
@@ -59502,13 +59535,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59502
59535
|
*/
|
|
59503
59536
|
handleListInstalledProviders(_args) {
|
|
59504
59537
|
const fs30 = require("fs");
|
|
59505
|
-
const
|
|
59538
|
+
const path41 = require("path");
|
|
59506
59539
|
const installRoot = this.getUpstreamInstallRoot();
|
|
59507
59540
|
if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
|
|
59508
59541
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
59509
59542
|
const items = [];
|
|
59510
59543
|
for (const category of CATEGORIES) {
|
|
59511
|
-
const categoryDir =
|
|
59544
|
+
const categoryDir = path41.join(installRoot, category);
|
|
59512
59545
|
if (!fs30.existsSync(categoryDir)) continue;
|
|
59513
59546
|
let entries;
|
|
59514
59547
|
try {
|
|
@@ -59517,8 +59550,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59517
59550
|
continue;
|
|
59518
59551
|
}
|
|
59519
59552
|
for (const type of entries) {
|
|
59520
|
-
const v1Path =
|
|
59521
|
-
const v0Path =
|
|
59553
|
+
const v1Path = path41.join(categoryDir, type, "provider.v1.json");
|
|
59554
|
+
const v0Path = path41.join(categoryDir, type, "provider.json");
|
|
59522
59555
|
const manifestPath = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
|
|
59523
59556
|
if (!manifestPath) continue;
|
|
59524
59557
|
try {
|
|
@@ -59634,7 +59667,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59634
59667
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
59635
59668
|
}
|
|
59636
59669
|
const fs30 = require("fs");
|
|
59637
|
-
const
|
|
59670
|
+
const path41 = require("path");
|
|
59638
59671
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
59639
59672
|
const file2 = ext.loadExternalSources();
|
|
59640
59673
|
if (file2.sources.some((s) => s.name === requestedName)) {
|
|
@@ -59643,7 +59676,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59643
59676
|
if (file2.sources.some((s) => s.url === url2 && s.ref === ref)) {
|
|
59644
59677
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
59645
59678
|
}
|
|
59646
|
-
const sourceDir =
|
|
59679
|
+
const sourceDir = path41.join(ext.externalRoot(), requestedName);
|
|
59647
59680
|
if (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
59648
59681
|
if (fs30.existsSync(sourceDir)) {
|
|
59649
59682
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
@@ -59700,11 +59733,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59700
59733
|
if (!name) return { success: false, error: "name is required" };
|
|
59701
59734
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
59702
59735
|
const fs30 = require("fs");
|
|
59703
|
-
const
|
|
59736
|
+
const path41 = require("path");
|
|
59704
59737
|
const file2 = ext.loadExternalSources();
|
|
59705
59738
|
const match = file2.sources.find((s) => s.name === name);
|
|
59706
59739
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
59707
|
-
const sourceDir =
|
|
59740
|
+
const sourceDir = path41.join(ext.externalRoot(), name);
|
|
59708
59741
|
if (fs30.existsSync(sourceDir)) {
|
|
59709
59742
|
try {
|
|
59710
59743
|
fs30.rmSync(sourceDir, { recursive: true, force: true });
|
|
@@ -59880,25 +59913,25 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59880
59913
|
}
|
|
59881
59914
|
};
|
|
59882
59915
|
var os19 = __toESM2(require("os"));
|
|
59883
|
-
var
|
|
59916
|
+
var path25 = __toESM2(require("path"));
|
|
59884
59917
|
var crypto5 = __toESM2(require("crypto"));
|
|
59885
|
-
var
|
|
59886
|
-
var
|
|
59918
|
+
var import_fs14 = require("fs");
|
|
59919
|
+
var import_child_process6 = require("child_process");
|
|
59887
59920
|
var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
59888
59921
|
init_provider_cli_adapter();
|
|
59889
59922
|
init_cli_detector();
|
|
59890
59923
|
init_config();
|
|
59891
59924
|
var os18 = __toESM2(require("os"));
|
|
59892
|
-
var
|
|
59925
|
+
var path23 = __toESM2(require("path"));
|
|
59893
59926
|
var crypto4 = __toESM2(require("crypto"));
|
|
59894
59927
|
var fs15 = __toESM2(require("fs"));
|
|
59895
59928
|
var import_node_module = require("module");
|
|
59896
59929
|
var fs14 = __toESM2(require("fs"));
|
|
59897
|
-
var
|
|
59930
|
+
var path222 = __toESM2(require("path"));
|
|
59898
59931
|
init_provider_cli_adapter();
|
|
59899
59932
|
var fs11 = __toESM2(require("fs"));
|
|
59900
59933
|
var os16 = __toESM2(require("os"));
|
|
59901
|
-
var
|
|
59934
|
+
var path20 = __toESM2(require("path"));
|
|
59902
59935
|
init_terminal_screen();
|
|
59903
59936
|
var import_session_host_core6 = require_dist();
|
|
59904
59937
|
var TerminalAdapter = class {
|
|
@@ -60018,18 +60051,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60018
60051
|
init_fsm_loader();
|
|
60019
60052
|
var fs10 = __toESM2(require("fs"));
|
|
60020
60053
|
var os15 = __toESM2(require("os"));
|
|
60021
|
-
var
|
|
60054
|
+
var path19 = __toESM2(require("path"));
|
|
60022
60055
|
init_logger();
|
|
60023
60056
|
function expandHome2(p) {
|
|
60024
60057
|
if (p === "~") return os15.homedir();
|
|
60025
|
-
if (p.startsWith("~/")) return
|
|
60058
|
+
if (p.startsWith("~/")) return path19.join(os15.homedir(), p.slice(2));
|
|
60026
60059
|
return p;
|
|
60027
60060
|
}
|
|
60028
60061
|
function realWorkspacePath(workingDir) {
|
|
60029
60062
|
try {
|
|
60030
60063
|
return fs10.realpathSync(workingDir);
|
|
60031
60064
|
} catch {
|
|
60032
|
-
return
|
|
60065
|
+
return path19.resolve(workingDir);
|
|
60033
60066
|
}
|
|
60034
60067
|
}
|
|
60035
60068
|
function applyPreLaunchTrust(trust, workingDir) {
|
|
@@ -60055,7 +60088,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60055
60088
|
}
|
|
60056
60089
|
list.push(real);
|
|
60057
60090
|
parsed[key] = list;
|
|
60058
|
-
fs10.mkdirSync(
|
|
60091
|
+
fs10.mkdirSync(path19.dirname(settingsPath), { recursive: true });
|
|
60059
60092
|
fs10.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
|
|
60060
60093
|
`, "utf8");
|
|
60061
60094
|
LOG2.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
|
|
@@ -60302,8 +60335,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60302
60335
|
}
|
|
60303
60336
|
armSpecWatcher() {
|
|
60304
60337
|
try {
|
|
60305
|
-
const dir =
|
|
60306
|
-
const base =
|
|
60338
|
+
const dir = path20.dirname(this.opts.specPath);
|
|
60339
|
+
const base = path20.basename(this.opts.specPath);
|
|
60307
60340
|
this.specWatcher = fs11.watch(dir, { persistent: false }, (_event, filename) => {
|
|
60308
60341
|
if (filename && filename !== base) return;
|
|
60309
60342
|
const res = loadFsmSpec(this.opts.specPath);
|
|
@@ -60604,7 +60637,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60604
60637
|
const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
|
|
60605
60638
|
if (!ctl || ctl.action.type !== "attach_image") return;
|
|
60606
60639
|
const ext = guessExt(mime);
|
|
60607
|
-
const tmp =
|
|
60640
|
+
const tmp = path20.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
60608
60641
|
try {
|
|
60609
60642
|
fs11.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
60610
60643
|
} catch {
|
|
@@ -60712,7 +60745,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60712
60745
|
}
|
|
60713
60746
|
var fs12 = __toESM2(require("fs"));
|
|
60714
60747
|
var os17 = __toESM2(require("os"));
|
|
60715
|
-
var
|
|
60748
|
+
var path21 = __toESM2(require("path"));
|
|
60716
60749
|
var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
60717
60750
|
function executeNativeHistory(cfg, input) {
|
|
60718
60751
|
if (!cfg?.source) return null;
|
|
@@ -60756,7 +60789,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60756
60789
|
const v = jsonPathGet(lines[0], src.session_id_path);
|
|
60757
60790
|
if (typeof v === "string" && v) providerSessionId = v;
|
|
60758
60791
|
} else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
|
|
60759
|
-
const m =
|
|
60792
|
+
const m = path21.basename(sourcePath).match(UUID_RE);
|
|
60760
60793
|
if (m) providerSessionId = m[1];
|
|
60761
60794
|
}
|
|
60762
60795
|
const requested = requestedSessionId || "";
|
|
@@ -60869,13 +60902,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60869
60902
|
if (!template) return null;
|
|
60870
60903
|
let out = template;
|
|
60871
60904
|
if (out.startsWith("~/") || out === "~") {
|
|
60872
|
-
out =
|
|
60905
|
+
out = path21.join(os17.homedir(), out.slice(2));
|
|
60873
60906
|
}
|
|
60874
60907
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
60875
60908
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
60876
60909
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
60877
60910
|
});
|
|
60878
|
-
if (out.startsWith("~/")) out =
|
|
60911
|
+
if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
|
|
60879
60912
|
const now = /* @__PURE__ */ new Date();
|
|
60880
60913
|
const workspaceRaw = input.workspace ?? "";
|
|
60881
60914
|
let workspaceResolved = workspaceRaw;
|
|
@@ -60932,12 +60965,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60932
60965
|
continue;
|
|
60933
60966
|
}
|
|
60934
60967
|
for (const e of entries) {
|
|
60935
|
-
if (e.isDirectory() && re.test(e.name)) next.push(
|
|
60968
|
+
if (e.isDirectory() && re.test(e.name)) next.push(path21.join(d, e.name));
|
|
60936
60969
|
}
|
|
60937
60970
|
}
|
|
60938
60971
|
} else {
|
|
60939
60972
|
for (const d of dirs) {
|
|
60940
|
-
const candidate =
|
|
60973
|
+
const candidate = path21.join(d, seg);
|
|
60941
60974
|
let stat2 = null;
|
|
60942
60975
|
try {
|
|
60943
60976
|
stat2 = fs12.statSync(candidate);
|
|
@@ -60960,7 +60993,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60960
60993
|
}
|
|
60961
60994
|
out.push(root);
|
|
60962
60995
|
for (const e of entries) {
|
|
60963
|
-
if (e.isDirectory()) walkAllDirs(
|
|
60996
|
+
if (e.isDirectory()) walkAllDirs(path21.join(root, e.name), out);
|
|
60964
60997
|
}
|
|
60965
60998
|
}
|
|
60966
60999
|
function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
|
|
@@ -60976,7 +61009,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60976
61009
|
}
|
|
60977
61010
|
for (const e of entries) {
|
|
60978
61011
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
60979
|
-
const p =
|
|
61012
|
+
const p = path21.join(d, e.name);
|
|
60980
61013
|
const mtime = safeMtimeMs(p);
|
|
60981
61014
|
if (mtime < cutoff) continue;
|
|
60982
61015
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -61003,7 +61036,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61003
61036
|
}
|
|
61004
61037
|
for (const e of entries) {
|
|
61005
61038
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
61006
|
-
const p =
|
|
61039
|
+
const p = path21.join(resolved, e.name);
|
|
61007
61040
|
const mtime = safeMtimeMs(p);
|
|
61008
61041
|
if (mtime < cutoff) continue;
|
|
61009
61042
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -61015,13 +61048,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61015
61048
|
if (!template) return null;
|
|
61016
61049
|
let out = template;
|
|
61017
61050
|
if (out.startsWith("~/") || out === "~") {
|
|
61018
|
-
out =
|
|
61051
|
+
out = path21.join(os17.homedir(), out.slice(2));
|
|
61019
61052
|
}
|
|
61020
61053
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
61021
61054
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
61022
61055
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
61023
61056
|
});
|
|
61024
|
-
if (out.startsWith("~/")) out =
|
|
61057
|
+
if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
|
|
61025
61058
|
const workspaceRaw = input.workspace ?? "";
|
|
61026
61059
|
let workspaceResolved = workspaceRaw;
|
|
61027
61060
|
if (workspaceRaw) {
|
|
@@ -61059,7 +61092,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61059
61092
|
let best = null;
|
|
61060
61093
|
for (const e of entries) {
|
|
61061
61094
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
61062
|
-
const p =
|
|
61095
|
+
const p = path21.join(dir, e.name);
|
|
61063
61096
|
const mtime = safeMtimeMs(p);
|
|
61064
61097
|
if (mtime < cutoff) continue;
|
|
61065
61098
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -61079,7 +61112,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61079
61112
|
return UUID_RE.test(value) ? value : "";
|
|
61080
61113
|
}
|
|
61081
61114
|
function filenameUuid(filePath) {
|
|
61082
|
-
const match =
|
|
61115
|
+
const match = path21.basename(filePath).match(UUID_RE);
|
|
61083
61116
|
return match?.[1] || "";
|
|
61084
61117
|
}
|
|
61085
61118
|
function pickExactSessionFile(dir, pattern, requestedSessionId) {
|
|
@@ -61174,7 +61207,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61174
61207
|
const out = [];
|
|
61175
61208
|
for (const e of entries) {
|
|
61176
61209
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
61177
|
-
out.push(
|
|
61210
|
+
out.push(path21.join(dir, e.name));
|
|
61178
61211
|
}
|
|
61179
61212
|
return out;
|
|
61180
61213
|
}
|
|
@@ -62112,12 +62145,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62112
62145
|
const dir = provider._resolvedProviderDir;
|
|
62113
62146
|
let specPath = resolvedSpecPath && fs14.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
62114
62147
|
if (!specPath && dir) {
|
|
62115
|
-
const legacy =
|
|
62148
|
+
const legacy = path222.join(dir, "spec.json");
|
|
62116
62149
|
if (fs14.existsSync(legacy)) specPath = legacy;
|
|
62117
62150
|
}
|
|
62118
62151
|
if (specPath) {
|
|
62119
62152
|
try {
|
|
62120
|
-
LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${
|
|
62153
|
+
LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path222.relative(dir || "", specPath) || specPath})`);
|
|
62121
62154
|
return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
|
|
62122
62155
|
} catch (err) {
|
|
62123
62156
|
LOG2.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
|
|
@@ -62178,7 +62211,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62178
62211
|
return uri.slice("file://".length);
|
|
62179
62212
|
}
|
|
62180
62213
|
}
|
|
62181
|
-
if (
|
|
62214
|
+
if (path23.isAbsolute(uri)) return uri;
|
|
62182
62215
|
return null;
|
|
62183
62216
|
}
|
|
62184
62217
|
function extensionForImageMime(mimeType) {
|
|
@@ -62194,7 +62227,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62194
62227
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
62195
62228
|
if (!rawData) return null;
|
|
62196
62229
|
fs15.mkdirSync(dir, { recursive: true });
|
|
62197
|
-
const filePath =
|
|
62230
|
+
const filePath = path23.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
62198
62231
|
fs15.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
62199
62232
|
cleanupStaleMaterializedImages(dir);
|
|
62200
62233
|
return filePath;
|
|
@@ -62210,7 +62243,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62210
62243
|
const entries = fs15.readdirSync(dir);
|
|
62211
62244
|
for (const entry of entries) {
|
|
62212
62245
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
62213
|
-
const fullPath =
|
|
62246
|
+
const fullPath = path23.join(dir, entry);
|
|
62214
62247
|
try {
|
|
62215
62248
|
const stat2 = fs15.statSync(fullPath);
|
|
62216
62249
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
@@ -62233,7 +62266,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62233
62266
|
const promptParts = [];
|
|
62234
62267
|
const imageRefs = [];
|
|
62235
62268
|
const resourceRefs = [];
|
|
62236
|
-
const materializeDir = options.materializeDir ||
|
|
62269
|
+
const materializeDir = options.materializeDir || path23.join(os18.tmpdir(), "adhdev-input-media");
|
|
62237
62270
|
input.parts.forEach((part, index) => {
|
|
62238
62271
|
if (part.type === "text" && part.text.trim()) {
|
|
62239
62272
|
promptParts.push(part.text.trim());
|
|
@@ -62300,7 +62333,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62300
62333
|
var CachedDatabaseSync = null;
|
|
62301
62334
|
function getDatabaseSync() {
|
|
62302
62335
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
62303
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
62336
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path23.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
62304
62337
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
62305
62338
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
62306
62339
|
if (!CachedDatabaseSync) {
|
|
@@ -63935,9 +63968,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
63935
63968
|
}
|
|
63936
63969
|
}
|
|
63937
63970
|
};
|
|
63938
|
-
var
|
|
63971
|
+
var path24 = __toESM2(require("path"));
|
|
63939
63972
|
var import_stream = require("stream");
|
|
63940
|
-
var
|
|
63973
|
+
var import_child_process5 = require("child_process");
|
|
63941
63974
|
var import_sdk = (init_acp(), __toCommonJS(acp_exports));
|
|
63942
63975
|
init_logger();
|
|
63943
63976
|
function getPromptCapabilityFlags(agentCapabilities) {
|
|
@@ -64456,7 +64489,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
64456
64489
|
this.errorMessage = null;
|
|
64457
64490
|
this.errorReason = null;
|
|
64458
64491
|
this.stderrBuffer = [];
|
|
64459
|
-
this.process = (0,
|
|
64492
|
+
this.process = (0, import_child_process5.spawn)(command, args, {
|
|
64460
64493
|
cwd: this.workingDir,
|
|
64461
64494
|
env: env2,
|
|
64462
64495
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -64721,7 +64754,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
64721
64754
|
return b.uri ? {
|
|
64722
64755
|
type: "resource_link",
|
|
64723
64756
|
uri: b.uri,
|
|
64724
|
-
name:
|
|
64757
|
+
name: path24.basename(b.uri),
|
|
64725
64758
|
mimeType: b.mimeType,
|
|
64726
64759
|
...b.transcript ? { description: b.transcript } : {}
|
|
64727
64760
|
} : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
|
|
@@ -65175,20 +65208,20 @@ ${rawInput}` : rawInput;
|
|
|
65175
65208
|
}
|
|
65176
65209
|
function isExplicitCommand(command) {
|
|
65177
65210
|
const trimmed = command.trim();
|
|
65178
|
-
return
|
|
65211
|
+
return path25.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
65179
65212
|
}
|
|
65180
65213
|
function expandExecutable(command) {
|
|
65181
65214
|
const trimmed = command.trim();
|
|
65182
|
-
return trimmed.startsWith("~") ?
|
|
65215
|
+
return trimmed.startsWith("~") ? path25.join(os19.homedir(), trimmed.slice(1)) : trimmed;
|
|
65183
65216
|
}
|
|
65184
65217
|
function commandExists(command) {
|
|
65185
65218
|
const trimmed = command.trim();
|
|
65186
65219
|
if (!trimmed) return false;
|
|
65187
65220
|
if (isExplicitCommand(trimmed)) {
|
|
65188
|
-
return (0,
|
|
65221
|
+
return (0, import_fs14.existsSync)(expandExecutable(trimmed));
|
|
65189
65222
|
}
|
|
65190
65223
|
try {
|
|
65191
|
-
(0,
|
|
65224
|
+
(0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
65192
65225
|
stdio: "ignore",
|
|
65193
65226
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
65194
65227
|
});
|
|
@@ -65320,11 +65353,11 @@ ${rawInput}` : rawInput;
|
|
|
65320
65353
|
return false;
|
|
65321
65354
|
}
|
|
65322
65355
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
65323
|
-
const baseDir =
|
|
65324
|
-
(0,
|
|
65325
|
-
const workspaceHash = crypto5.createHash("sha256").update(
|
|
65326
|
-
const filePath =
|
|
65327
|
-
(0,
|
|
65356
|
+
const baseDir = path25.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
65357
|
+
(0, import_fs14.mkdirSync)(baseDir, { recursive: true });
|
|
65358
|
+
const workspaceHash = crypto5.createHash("sha256").update(path25.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
|
|
65359
|
+
const filePath = path25.join(baseDir, `${workspaceHash}.json`);
|
|
65360
|
+
(0, import_fs14.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
65328
65361
|
return filePath;
|
|
65329
65362
|
}
|
|
65330
65363
|
function buildCoordinatorDelegatedCliLaunchOptions(input) {
|
|
@@ -65637,7 +65670,7 @@ ${rawInput}` : rawInput;
|
|
|
65637
65670
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
65638
65671
|
const trimmed = (workingDir || "").trim();
|
|
65639
65672
|
if (!trimmed) throw new Error("working directory required");
|
|
65640
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) :
|
|
65673
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path25.resolve(trimmed);
|
|
65641
65674
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
65642
65675
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
65643
65676
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -66237,12 +66270,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66237
66270
|
return null;
|
|
66238
66271
|
}
|
|
66239
66272
|
};
|
|
66240
|
-
var
|
|
66273
|
+
var import_child_process7 = require("child_process");
|
|
66241
66274
|
var net3 = __toESM2(require("net"));
|
|
66242
66275
|
var os24 = __toESM2(require("os"));
|
|
66243
|
-
var
|
|
66276
|
+
var path33 = __toESM2(require("path"));
|
|
66244
66277
|
var fs21 = __toESM2(require("fs"));
|
|
66245
|
-
var
|
|
66278
|
+
var path322 = __toESM2(require("path"));
|
|
66246
66279
|
var os23 = __toESM2(require("os"));
|
|
66247
66280
|
var chokidar = __toESM2(require_chokidar());
|
|
66248
66281
|
init_logger();
|
|
@@ -66629,9 +66662,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66629
66662
|
init_external_sources();
|
|
66630
66663
|
var fs20 = __toESM2(require("fs"));
|
|
66631
66664
|
var os222 = __toESM2(require("os"));
|
|
66632
|
-
var
|
|
66665
|
+
var path30 = __toESM2(require("path"));
|
|
66633
66666
|
var fs16 = __toESM2(require("fs"));
|
|
66634
|
-
var
|
|
66667
|
+
var path26 = __toESM2(require("path"));
|
|
66635
66668
|
function extractTimestampValue(value) {
|
|
66636
66669
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
66637
66670
|
if (typeof value === "string") {
|
|
@@ -66787,8 +66820,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66787
66820
|
return records;
|
|
66788
66821
|
}
|
|
66789
66822
|
function readSession(sessionPath) {
|
|
66790
|
-
if (!sessionPath || !
|
|
66791
|
-
const basename14 =
|
|
66823
|
+
if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
|
|
66824
|
+
const basename14 = path26.basename(sessionPath, ".jsonl");
|
|
66792
66825
|
if (!isSafeSessionId(basename14)) return null;
|
|
66793
66826
|
if (!fs16.existsSync(sessionPath)) return null;
|
|
66794
66827
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
@@ -66807,7 +66840,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66807
66840
|
};
|
|
66808
66841
|
}
|
|
66809
66842
|
var fs17 = __toESM2(require("fs"));
|
|
66810
|
-
var
|
|
66843
|
+
var path27 = __toESM2(require("path"));
|
|
66811
66844
|
function extractTimestampValue2(value) {
|
|
66812
66845
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
66813
66846
|
if (typeof value === "string") {
|
|
@@ -67044,11 +67077,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67044
67077
|
return records;
|
|
67045
67078
|
}
|
|
67046
67079
|
function readSession2(sessionPath) {
|
|
67047
|
-
if (!sessionPath || !
|
|
67080
|
+
if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
|
|
67048
67081
|
if (!fs17.existsSync(sessionPath)) return null;
|
|
67049
67082
|
const meta3 = readSessionMeta(sessionPath);
|
|
67050
67083
|
const metaId = String(meta3?.id ?? "").trim();
|
|
67051
|
-
const basename14 =
|
|
67084
|
+
const basename14 = path27.basename(sessionPath, ".jsonl");
|
|
67052
67085
|
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);
|
|
67053
67086
|
const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
|
|
67054
67087
|
if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
|
|
@@ -67071,7 +67104,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67071
67104
|
};
|
|
67072
67105
|
}
|
|
67073
67106
|
var fs18 = __toESM2(require("fs"));
|
|
67074
|
-
var
|
|
67107
|
+
var path28 = __toESM2(require("path"));
|
|
67075
67108
|
var os20 = __toESM2(require("os"));
|
|
67076
67109
|
function extractTimestampValue3(value) {
|
|
67077
67110
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -67094,13 +67127,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67094
67127
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
67095
67128
|
}
|
|
67096
67129
|
function antigravityRoot() {
|
|
67097
|
-
return
|
|
67130
|
+
return path28.join(os20.homedir(), ".gemini", "antigravity-cli");
|
|
67098
67131
|
}
|
|
67099
67132
|
function historyJsonlPath() {
|
|
67100
|
-
return
|
|
67133
|
+
return path28.join(antigravityRoot(), "history.jsonl");
|
|
67101
67134
|
}
|
|
67102
67135
|
function brainRoot() {
|
|
67103
|
-
return
|
|
67136
|
+
return path28.join(antigravityRoot(), "brain");
|
|
67104
67137
|
}
|
|
67105
67138
|
function extractUserRequestContent(content) {
|
|
67106
67139
|
const raw = content.trim();
|
|
@@ -67247,13 +67280,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67247
67280
|
];
|
|
67248
67281
|
}
|
|
67249
67282
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
67250
|
-
if (!sessionPath || !
|
|
67283
|
+
if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
|
|
67251
67284
|
if (!fs18.existsSync(sessionPath)) return null;
|
|
67252
67285
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
67253
67286
|
const brainRootPath = brainRoot();
|
|
67254
|
-
if (sessionPath.startsWith(brainRootPath +
|
|
67287
|
+
if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
|
|
67255
67288
|
const relative5 = sessionPath.slice(brainRootPath.length + 1);
|
|
67256
|
-
const uuidFromPath = relative5.split(
|
|
67289
|
+
const uuidFromPath = relative5.split(path28.sep)[0];
|
|
67257
67290
|
const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
|
|
67258
67291
|
if (!resolvedSessionId) return null;
|
|
67259
67292
|
const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
|
|
@@ -67269,7 +67302,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67269
67302
|
};
|
|
67270
67303
|
}
|
|
67271
67304
|
if (sessionPath.endsWith(".pb")) {
|
|
67272
|
-
const pbSessionId = sessionId ||
|
|
67305
|
+
const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
|
|
67273
67306
|
if (!isUuidLike(pbSessionId)) return null;
|
|
67274
67307
|
const messages = parsePbFile(sessionPath, pbSessionId);
|
|
67275
67308
|
if (!messages || messages.length === 0) return null;
|
|
@@ -67283,7 +67316,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67283
67316
|
partialReason: "antigravity_cli_pb_raw_text_extraction"
|
|
67284
67317
|
};
|
|
67285
67318
|
}
|
|
67286
|
-
if (
|
|
67319
|
+
if (path28.basename(sessionPath) === "history.jsonl") {
|
|
67287
67320
|
const resolvedSessionId = sessionId || "";
|
|
67288
67321
|
if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
|
|
67289
67322
|
const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
|
|
@@ -67329,10 +67362,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67329
67362
|
return null;
|
|
67330
67363
|
}
|
|
67331
67364
|
var fs19 = __toESM2(require("fs"));
|
|
67332
|
-
var
|
|
67365
|
+
var path29 = __toESM2(require("path"));
|
|
67333
67366
|
var os21 = __toESM2(require("os"));
|
|
67334
|
-
var HERMES_STATE_DB =
|
|
67335
|
-
var HERMES_LEGACY_SESSIONS_DIR =
|
|
67367
|
+
var HERMES_STATE_DB = path29.join(os21.homedir(), ".hermes", "state.db");
|
|
67368
|
+
var HERMES_LEGACY_SESSIONS_DIR = path29.join(os21.homedir(), ".hermes", "sessions");
|
|
67336
67369
|
function statMtimeMs4(p) {
|
|
67337
67370
|
try {
|
|
67338
67371
|
return Math.floor(fs19.statSync(p).mtimeMs);
|
|
@@ -67398,7 +67431,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67398
67431
|
}
|
|
67399
67432
|
}
|
|
67400
67433
|
}
|
|
67401
|
-
if (!
|
|
67434
|
+
if (!path29.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
|
|
67402
67435
|
let raw;
|
|
67403
67436
|
try {
|
|
67404
67437
|
raw = JSON.parse(fs19.readFileSync(sessionPath, "utf8"));
|
|
@@ -67424,7 +67457,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67424
67457
|
});
|
|
67425
67458
|
}
|
|
67426
67459
|
if (messages.length === 0) return null;
|
|
67427
|
-
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id :
|
|
67460
|
+
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
|
|
67428
67461
|
return {
|
|
67429
67462
|
messages,
|
|
67430
67463
|
providerSessionId: sessionId,
|
|
@@ -67488,10 +67521,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67488
67521
|
}
|
|
67489
67522
|
}
|
|
67490
67523
|
function resolveClaudePath(workspace, sessionId) {
|
|
67491
|
-
const dir =
|
|
67524
|
+
const dir = path30.join(os222.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
67492
67525
|
if (!fs20.existsSync(dir)) return null;
|
|
67493
67526
|
if (sessionId) {
|
|
67494
|
-
const candidate =
|
|
67527
|
+
const candidate = path30.join(dir, `${sessionId}.jsonl`);
|
|
67495
67528
|
if (fs20.existsSync(candidate)) return candidate;
|
|
67496
67529
|
}
|
|
67497
67530
|
return null;
|
|
@@ -67517,7 +67550,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67517
67550
|
continue;
|
|
67518
67551
|
}
|
|
67519
67552
|
for (const entry of entries) {
|
|
67520
|
-
const entryPath =
|
|
67553
|
+
const entryPath = path30.join(current, entry.name);
|
|
67521
67554
|
if (entry.isDirectory()) {
|
|
67522
67555
|
stack.push(entryPath);
|
|
67523
67556
|
continue;
|
|
@@ -67547,7 +67580,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67547
67580
|
continue;
|
|
67548
67581
|
}
|
|
67549
67582
|
for (const entry of entries) {
|
|
67550
|
-
const entryPath =
|
|
67583
|
+
const entryPath = path30.join(current, entry.name);
|
|
67551
67584
|
if (entry.isDirectory()) {
|
|
67552
67585
|
stack.push(entryPath);
|
|
67553
67586
|
continue;
|
|
@@ -67600,12 +67633,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67600
67633
|
}
|
|
67601
67634
|
function resolveAntigravityPath(workspace) {
|
|
67602
67635
|
void workspace;
|
|
67603
|
-
const brainRoot2 =
|
|
67636
|
+
const brainRoot2 = path30.join(os222.homedir(), ".gemini", "antigravity-cli", "brain");
|
|
67604
67637
|
if (!fs20.existsSync(brainRoot2)) return null;
|
|
67605
67638
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
67606
|
-
const entries = fs20.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p:
|
|
67639
|
+
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);
|
|
67607
67640
|
for (const e of entries) {
|
|
67608
|
-
const t =
|
|
67641
|
+
const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
67609
67642
|
if (fs20.existsSync(t)) return t;
|
|
67610
67643
|
}
|
|
67611
67644
|
return null;
|
|
@@ -67613,9 +67646,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67613
67646
|
function resolveHermesPath(workspace, sessionId) {
|
|
67614
67647
|
void workspace;
|
|
67615
67648
|
void sessionId;
|
|
67616
|
-
const dbPath =
|
|
67649
|
+
const dbPath = path30.join(os222.homedir(), ".hermes", "state.db");
|
|
67617
67650
|
if (fs20.existsSync(dbPath)) return dbPath;
|
|
67618
|
-
const dir =
|
|
67651
|
+
const dir = path30.join(os222.homedir(), ".hermes", "sessions");
|
|
67619
67652
|
if (!fs20.existsSync(dir)) return null;
|
|
67620
67653
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
67621
67654
|
}
|
|
@@ -67636,7 +67669,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67636
67669
|
return cwd.replace(/\//g, "-");
|
|
67637
67670
|
}
|
|
67638
67671
|
function codexSessionsRoot() {
|
|
67639
|
-
return
|
|
67672
|
+
return path30.join(os222.homedir(), ".codex", "sessions");
|
|
67640
67673
|
}
|
|
67641
67674
|
function isUuidLikeSessionId2(sessionId) {
|
|
67642
67675
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
|
|
@@ -67648,7 +67681,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67648
67681
|
function newestRecentFile2(dir, pattern) {
|
|
67649
67682
|
try {
|
|
67650
67683
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
67651
|
-
const entries = fs20.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p:
|
|
67684
|
+
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);
|
|
67652
67685
|
return entries[0]?.p ?? null;
|
|
67653
67686
|
} catch {
|
|
67654
67687
|
return null;
|
|
@@ -67709,7 +67742,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67709
67742
|
try {
|
|
67710
67743
|
if (!fs21.existsSync(candidate) || !fs21.statSync(candidate).isDirectory()) return false;
|
|
67711
67744
|
return ["ide", "extension", "cli", "acp"].some(
|
|
67712
|
-
(category) => fs21.existsSync(
|
|
67745
|
+
(category) => fs21.existsSync(path322.join(candidate, category))
|
|
67713
67746
|
);
|
|
67714
67747
|
} catch {
|
|
67715
67748
|
return false;
|
|
@@ -67717,20 +67750,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67717
67750
|
}
|
|
67718
67751
|
static hasProviderRootMarker(candidate) {
|
|
67719
67752
|
try {
|
|
67720
|
-
return fs21.existsSync(
|
|
67753
|
+
return fs21.existsSync(path322.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
67721
67754
|
} catch {
|
|
67722
67755
|
return false;
|
|
67723
67756
|
}
|
|
67724
67757
|
}
|
|
67725
67758
|
detectDefaultUserDir() {
|
|
67726
|
-
const fallback =
|
|
67759
|
+
const fallback = path322.join(os23.homedir(), ".adhdev", "providers");
|
|
67727
67760
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
67728
67761
|
const visited = /* @__PURE__ */ new Set();
|
|
67729
67762
|
for (const start of this.probeStarts) {
|
|
67730
|
-
let current =
|
|
67763
|
+
let current = path322.resolve(start);
|
|
67731
67764
|
while (!visited.has(current)) {
|
|
67732
67765
|
visited.add(current);
|
|
67733
|
-
const siblingCandidate =
|
|
67766
|
+
const siblingCandidate = path322.join(path322.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
67734
67767
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
67735
67768
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
67736
67769
|
if (envOptIn || hasMarker) {
|
|
@@ -67752,7 +67785,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67752
67785
|
return { path: siblingCandidate, source };
|
|
67753
67786
|
}
|
|
67754
67787
|
}
|
|
67755
|
-
const parent =
|
|
67788
|
+
const parent = path322.dirname(current);
|
|
67756
67789
|
if (parent === current) break;
|
|
67757
67790
|
current = parent;
|
|
67758
67791
|
}
|
|
@@ -67762,11 +67795,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67762
67795
|
constructor(options) {
|
|
67763
67796
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
67764
67797
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
67765
|
-
this.defaultProvidersDir =
|
|
67798
|
+
this.defaultProvidersDir = path322.join(os23.homedir(), ".adhdev", "providers");
|
|
67766
67799
|
const detected = this.detectDefaultUserDir();
|
|
67767
67800
|
this.userDir = detected.path;
|
|
67768
67801
|
this.userDirSource = detected.source;
|
|
67769
|
-
this.upstreamDir =
|
|
67802
|
+
this.upstreamDir = path322.join(this.defaultProvidersDir, ".upstream");
|
|
67770
67803
|
this.disableUpstream = false;
|
|
67771
67804
|
this.applySourceConfig({
|
|
67772
67805
|
userDir: options?.userDir,
|
|
@@ -67778,8 +67811,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67778
67811
|
migrateMarketplaceDirToExternal() {
|
|
67779
67812
|
try {
|
|
67780
67813
|
const home = os23.homedir();
|
|
67781
|
-
const oldDir =
|
|
67782
|
-
const newDir =
|
|
67814
|
+
const oldDir = path322.join(home, ".adhdev", "marketplace");
|
|
67815
|
+
const newDir = path322.join(home, ".adhdev", "external");
|
|
67783
67816
|
if (!fs21.existsSync(oldDir)) return;
|
|
67784
67817
|
if (fs21.existsSync(newDir)) {
|
|
67785
67818
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
@@ -67815,7 +67848,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67815
67848
|
* Highest-priority editable overrides come first.
|
|
67816
67849
|
*/
|
|
67817
67850
|
getProviderRoots() {
|
|
67818
|
-
const externalDir =
|
|
67851
|
+
const externalDir = path322.join(os23.homedir(), ".adhdev", "external");
|
|
67819
67852
|
return [this.userDir, externalDir, this.upstreamDir];
|
|
67820
67853
|
}
|
|
67821
67854
|
getSourceConfig() {
|
|
@@ -67843,7 +67876,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67843
67876
|
this.userDir = detected.path;
|
|
67844
67877
|
this.userDirSource = detected.source;
|
|
67845
67878
|
}
|
|
67846
|
-
this.upstreamDir =
|
|
67879
|
+
this.upstreamDir = path322.join(this.defaultProvidersDir, ".upstream");
|
|
67847
67880
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
67848
67881
|
if (this.explicitProviderDir) {
|
|
67849
67882
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -67857,7 +67890,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67857
67890
|
* Canonical provider directory shape for a given root.
|
|
67858
67891
|
*/
|
|
67859
67892
|
getProviderDir(root, category, type) {
|
|
67860
|
-
return
|
|
67893
|
+
return path322.join(root, category, type);
|
|
67861
67894
|
}
|
|
67862
67895
|
/**
|
|
67863
67896
|
* Canonical user override directory for a provider.
|
|
@@ -67884,7 +67917,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67884
67917
|
resolveProviderFile(type, ...segments) {
|
|
67885
67918
|
const dir = this.findProviderDirInternal(type);
|
|
67886
67919
|
if (!dir) return null;
|
|
67887
|
-
return
|
|
67920
|
+
return path322.join(dir, ...segments);
|
|
67888
67921
|
}
|
|
67889
67922
|
/**
|
|
67890
67923
|
* Load all providers (3-tier priority)
|
|
@@ -67908,7 +67941,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67908
67941
|
} else if (this.disableUpstream) {
|
|
67909
67942
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
67910
67943
|
}
|
|
67911
|
-
const externalDir =
|
|
67944
|
+
const externalDir = path322.join(os23.homedir(), ".adhdev", "external");
|
|
67912
67945
|
if (fs21.existsSync(externalDir)) {
|
|
67913
67946
|
const rootEntries = (() => {
|
|
67914
67947
|
try {
|
|
@@ -67930,7 +67963,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67930
67963
|
const ambiguousTypes = [];
|
|
67931
67964
|
for (const sourceEntry of rootEntries) {
|
|
67932
67965
|
if (!sourceEntry.isDirectory()) continue;
|
|
67933
|
-
const sourceDir =
|
|
67966
|
+
const sourceDir = path322.join(externalDir, sourceEntry.name);
|
|
67934
67967
|
const sourceLoaded = this.loadDir(sourceDir);
|
|
67935
67968
|
if (sourceLoaded > 0) {
|
|
67936
67969
|
totalLoaded += sourceLoaded;
|
|
@@ -67946,7 +67979,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67946
67979
|
ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
|
|
67947
67980
|
}
|
|
67948
67981
|
if (resolved.source && resolved.source !== "?") {
|
|
67949
|
-
const sourceDir =
|
|
67982
|
+
const sourceDir = path322.join(externalDir, resolved.source);
|
|
67950
67983
|
const reloadCount = this.loadDir(sourceDir);
|
|
67951
67984
|
if (reloadCount === 0) {
|
|
67952
67985
|
this.log(`Active source "${resolved.source}" no longer provides ${type}`);
|
|
@@ -67979,7 +68012,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67979
68012
|
if (!fs21.existsSync(this.upstreamDir)) return false;
|
|
67980
68013
|
try {
|
|
67981
68014
|
return fs21.readdirSync(this.upstreamDir).some(
|
|
67982
|
-
(d) => fs21.statSync(
|
|
68015
|
+
(d) => fs21.statSync(path322.join(this.upstreamDir, d)).isDirectory()
|
|
67983
68016
|
);
|
|
67984
68017
|
} catch {
|
|
67985
68018
|
return false;
|
|
@@ -68477,8 +68510,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68477
68510
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
68478
68511
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
68479
68512
|
if (providerDir) {
|
|
68480
|
-
const fullDir =
|
|
68481
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
68513
|
+
const fullDir = path322.join(providerDir, entry.scriptDir);
|
|
68514
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path322.join(fullDir, "scripts.js")) ? path322.join(fullDir, "scripts.js") : fullDir;
|
|
68482
68515
|
}
|
|
68483
68516
|
matched = true;
|
|
68484
68517
|
}
|
|
@@ -68496,8 +68529,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68496
68529
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
68497
68530
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
68498
68531
|
if (providerDir) {
|
|
68499
|
-
const fullDir =
|
|
68500
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
68532
|
+
const fullDir = path322.join(providerDir, base.defaultScriptDir);
|
|
68533
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path322.join(fullDir, "scripts.js")) ? path322.join(fullDir, "scripts.js") : fullDir;
|
|
68501
68534
|
}
|
|
68502
68535
|
}
|
|
68503
68536
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -68514,8 +68547,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68514
68547
|
resolved._resolvedScriptDir = dirOverride;
|
|
68515
68548
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
68516
68549
|
if (providerDir) {
|
|
68517
|
-
const fullDir =
|
|
68518
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
68550
|
+
const fullDir = path322.join(providerDir, dirOverride);
|
|
68551
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path322.join(fullDir, "scripts.js")) ? path322.join(fullDir, "scripts.js") : fullDir;
|
|
68519
68552
|
}
|
|
68520
68553
|
}
|
|
68521
68554
|
} else if (override.scripts) {
|
|
@@ -68531,8 +68564,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68531
68564
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
68532
68565
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
68533
68566
|
if (providerDir) {
|
|
68534
|
-
const fullDir =
|
|
68535
|
-
resolved._resolvedScriptsPath = fs21.existsSync(
|
|
68567
|
+
const fullDir = path322.join(providerDir, base.defaultScriptDir);
|
|
68568
|
+
resolved._resolvedScriptsPath = fs21.existsSync(path322.join(fullDir, "scripts.js")) ? path322.join(fullDir, "scripts.js") : fullDir;
|
|
68536
68569
|
}
|
|
68537
68570
|
}
|
|
68538
68571
|
}
|
|
@@ -68549,13 +68582,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68549
68582
|
if (providerDir2) {
|
|
68550
68583
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
68551
68584
|
if (!override || typeof override.path !== "string") continue;
|
|
68552
|
-
const fullPath =
|
|
68585
|
+
const fullPath = path322.join(providerDir2, override.path);
|
|
68553
68586
|
if (!fs21.existsSync(fullPath)) {
|
|
68554
68587
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
68555
68588
|
continue;
|
|
68556
68589
|
}
|
|
68557
68590
|
try {
|
|
68558
|
-
registerProviderScriptRootSafely(
|
|
68591
|
+
registerProviderScriptRootSafely(path322.dirname(path322.dirname(providerDir2)));
|
|
68559
68592
|
delete require.cache[require.resolve(fullPath)];
|
|
68560
68593
|
const fn = require(fullPath);
|
|
68561
68594
|
const target = typeof fn === "function" ? fn : fn && fn[scriptName];
|
|
@@ -68581,17 +68614,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68581
68614
|
if (providerDir) {
|
|
68582
68615
|
try {
|
|
68583
68616
|
const fs30 = require("fs");
|
|
68584
|
-
const
|
|
68617
|
+
const path41 = require("path");
|
|
68585
68618
|
const candidates = [];
|
|
68586
68619
|
if (Array.isArray(base.compatibility)) {
|
|
68587
68620
|
for (const entry of base.compatibility) {
|
|
68588
68621
|
if (typeof entry?.spec !== "string") continue;
|
|
68589
68622
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
68590
|
-
if (matches) candidates.push(
|
|
68623
|
+
if (matches) candidates.push(path41.join(providerDir, entry.spec));
|
|
68591
68624
|
}
|
|
68592
68625
|
}
|
|
68593
|
-
candidates.push(
|
|
68594
|
-
candidates.push(
|
|
68626
|
+
candidates.push(path41.join(providerDir, "specs", "default.json"));
|
|
68627
|
+
candidates.push(path41.join(providerDir, "spec.json"));
|
|
68595
68628
|
const specPath = candidates.find((p) => fs30.existsSync(p));
|
|
68596
68629
|
if (specPath) {
|
|
68597
68630
|
resolved._resolvedSpecPath = specPath;
|
|
@@ -68622,10 +68655,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68622
68655
|
format = `spec-${nh.source.kind}`;
|
|
68623
68656
|
reader = (input) => executeNativeHistory(nh, input);
|
|
68624
68657
|
} else if (nh.override_path) {
|
|
68625
|
-
const overrideFile =
|
|
68658
|
+
const overrideFile = path41.resolve(providerDir, nh.override_path);
|
|
68626
68659
|
if (fs30.existsSync(overrideFile)) {
|
|
68627
68660
|
try {
|
|
68628
|
-
registerProviderScriptRootSafely(
|
|
68661
|
+
registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
|
|
68629
68662
|
delete require.cache[require.resolve(overrideFile)];
|
|
68630
68663
|
const mod = require(overrideFile);
|
|
68631
68664
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -68668,15 +68701,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68668
68701
|
this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
|
|
68669
68702
|
return null;
|
|
68670
68703
|
}
|
|
68671
|
-
const dir =
|
|
68704
|
+
const dir = path322.join(providerDir, scriptDir);
|
|
68672
68705
|
if (!fs21.existsSync(dir)) {
|
|
68673
68706
|
this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
68674
68707
|
return null;
|
|
68675
68708
|
}
|
|
68676
|
-
registerProviderScriptRootSafely(
|
|
68709
|
+
registerProviderScriptRootSafely(path322.dirname(path322.dirname(providerDir)));
|
|
68677
68710
|
const cached22 = this.scriptsCache.get(dir);
|
|
68678
68711
|
if (cached22) return cached22;
|
|
68679
|
-
const scriptsJs =
|
|
68712
|
+
const scriptsJs = path322.join(dir, "scripts.js");
|
|
68680
68713
|
if (fs21.existsSync(scriptsJs)) {
|
|
68681
68714
|
try {
|
|
68682
68715
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -68721,7 +68754,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68721
68754
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
68722
68755
|
if (reloadTimer) clearTimeout(reloadTimer);
|
|
68723
68756
|
reloadTimer = setTimeout(() => {
|
|
68724
|
-
this.log(`File changed: ${
|
|
68757
|
+
this.log(`File changed: ${path322.basename(filePath)}, reloading...`);
|
|
68725
68758
|
this.reload();
|
|
68726
68759
|
}, 300);
|
|
68727
68760
|
}
|
|
@@ -68789,7 +68822,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68789
68822
|
}
|
|
68790
68823
|
this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
|
|
68791
68824
|
const https = require("https");
|
|
68792
|
-
const regMetaPath =
|
|
68825
|
+
const regMetaPath = path322.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
|
|
68793
68826
|
let cachedChecksums = {};
|
|
68794
68827
|
try {
|
|
68795
68828
|
if (fs21.existsSync(regMetaPath)) {
|
|
@@ -68847,9 +68880,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68847
68880
|
this.log(`\u26A0 Registry checksum mismatch for ${type}@${version2} \u2014 skipping`);
|
|
68848
68881
|
continue;
|
|
68849
68882
|
}
|
|
68850
|
-
const providerDir =
|
|
68883
|
+
const providerDir = path322.join(this.upstreamDir, category, type);
|
|
68851
68884
|
fs21.mkdirSync(providerDir, { recursive: true });
|
|
68852
|
-
fs21.writeFileSync(
|
|
68885
|
+
fs21.writeFileSync(path322.join(providerDir, "provider.json"), manifestBody, "utf-8");
|
|
68853
68886
|
cachedChecksums[cacheKey] = checksum;
|
|
68854
68887
|
updatedCount++;
|
|
68855
68888
|
this.log(`\u2713 Registry updated: ${category}/${type}@${version2}`);
|
|
@@ -68876,7 +68909,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68876
68909
|
const { exec: exec7 } = require("child_process");
|
|
68877
68910
|
const { promisify: promisify8 } = require("util");
|
|
68878
68911
|
const execAsync5 = promisify8(exec7);
|
|
68879
|
-
const metaPath =
|
|
68912
|
+
const metaPath = path322.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
68880
68913
|
let prevEtag = "";
|
|
68881
68914
|
let prevTimestamp = 0;
|
|
68882
68915
|
try {
|
|
@@ -68936,17 +68969,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68936
68969
|
return { updated: false };
|
|
68937
68970
|
}
|
|
68938
68971
|
this.log("Downloading latest providers from GitHub...");
|
|
68939
|
-
const tmpTar =
|
|
68940
|
-
const tmpExtract =
|
|
68972
|
+
const tmpTar = path322.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
68973
|
+
const tmpExtract = path322.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
68941
68974
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
68942
68975
|
fs21.mkdirSync(tmpExtract, { recursive: true });
|
|
68943
68976
|
await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
68944
68977
|
const extracted = fs21.readdirSync(tmpExtract);
|
|
68945
68978
|
const rootDir = extracted.find(
|
|
68946
|
-
(d) => fs21.statSync(
|
|
68979
|
+
(d) => fs21.statSync(path322.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
68947
68980
|
);
|
|
68948
68981
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
68949
|
-
const sourceDir =
|
|
68982
|
+
const sourceDir = path322.join(tmpExtract, rootDir);
|
|
68950
68983
|
const backupDir = this.upstreamDir + ".bak";
|
|
68951
68984
|
if (fs21.existsSync(this.upstreamDir)) {
|
|
68952
68985
|
if (fs21.existsSync(backupDir)) fs21.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -69021,8 +69054,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69021
69054
|
copyDirRecursive(src, dest) {
|
|
69022
69055
|
fs21.mkdirSync(dest, { recursive: true });
|
|
69023
69056
|
for (const entry of fs21.readdirSync(src, { withFileTypes: true })) {
|
|
69024
|
-
const srcPath =
|
|
69025
|
-
const destPath =
|
|
69057
|
+
const srcPath = path322.join(src, entry.name);
|
|
69058
|
+
const destPath = path322.join(dest, entry.name);
|
|
69026
69059
|
if (entry.isDirectory()) {
|
|
69027
69060
|
this.copyDirRecursive(srcPath, destPath);
|
|
69028
69061
|
} else {
|
|
@@ -69033,7 +69066,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69033
69066
|
/** .meta.json save */
|
|
69034
69067
|
writeMeta(metaPath, etag, timestamp) {
|
|
69035
69068
|
try {
|
|
69036
|
-
fs21.mkdirSync(
|
|
69069
|
+
fs21.mkdirSync(path322.dirname(metaPath), { recursive: true });
|
|
69037
69070
|
fs21.writeFileSync(metaPath, JSON.stringify({
|
|
69038
69071
|
etag,
|
|
69039
69072
|
timestamp,
|
|
@@ -69053,7 +69086,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69053
69086
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
69054
69087
|
if (hasManifest) count++;
|
|
69055
69088
|
for (const entry of entries) {
|
|
69056
|
-
if (entry.isDirectory()) scan(
|
|
69089
|
+
if (entry.isDirectory()) scan(path322.join(d, entry.name));
|
|
69057
69090
|
}
|
|
69058
69091
|
} catch {
|
|
69059
69092
|
}
|
|
@@ -69279,10 +69312,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69279
69312
|
if (!provider) return null;
|
|
69280
69313
|
const cat = provider.category;
|
|
69281
69314
|
const searchRoots = this.getProviderRoots();
|
|
69282
|
-
const hasManifest = (dir) => fs21.existsSync(
|
|
69315
|
+
const hasManifest = (dir) => fs21.existsSync(path322.join(dir, "provider.v1.json")) || fs21.existsSync(path322.join(dir, "provider.json"));
|
|
69283
69316
|
const readManifestType = (dir) => {
|
|
69284
69317
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
69285
|
-
const p =
|
|
69318
|
+
const p = path322.join(dir, file2);
|
|
69286
69319
|
if (!fs21.existsSync(p)) continue;
|
|
69287
69320
|
try {
|
|
69288
69321
|
const data = JSON.parse(fs21.readFileSync(p, "utf-8"));
|
|
@@ -69296,12 +69329,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69296
69329
|
if (!fs21.existsSync(root)) continue;
|
|
69297
69330
|
const candidate = this.getProviderDir(root, cat, type);
|
|
69298
69331
|
if (hasManifest(candidate)) return candidate;
|
|
69299
|
-
const catDir =
|
|
69332
|
+
const catDir = path322.join(root, cat);
|
|
69300
69333
|
if (fs21.existsSync(catDir)) {
|
|
69301
69334
|
try {
|
|
69302
69335
|
for (const entry of fs21.readdirSync(catDir, { withFileTypes: true })) {
|
|
69303
69336
|
if (!entry.isDirectory()) continue;
|
|
69304
|
-
const entryDir =
|
|
69337
|
+
const entryDir = path322.join(catDir, entry.name);
|
|
69305
69338
|
const manifestType = readManifestType(entryDir);
|
|
69306
69339
|
if (manifestType === type) return entryDir;
|
|
69307
69340
|
}
|
|
@@ -69317,7 +69350,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69317
69350
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
69318
69351
|
*/
|
|
69319
69352
|
buildScriptWrappersFromDir(dir) {
|
|
69320
|
-
const scriptsJs =
|
|
69353
|
+
const scriptsJs = path322.join(dir, "scripts.js");
|
|
69321
69354
|
if (fs21.existsSync(scriptsJs)) {
|
|
69322
69355
|
try {
|
|
69323
69356
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -69331,7 +69364,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69331
69364
|
for (const file2 of fs21.readdirSync(dir)) {
|
|
69332
69365
|
if (!file2.endsWith(".js")) continue;
|
|
69333
69366
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
69334
|
-
const filePath =
|
|
69367
|
+
const filePath = path322.join(dir, file2);
|
|
69335
69368
|
result[scriptName] = (...args) => {
|
|
69336
69369
|
try {
|
|
69337
69370
|
let content = fs21.readFileSync(filePath, "utf-8");
|
|
@@ -69393,7 +69426,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69393
69426
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
69394
69427
|
if (hasV1 || hasJson) {
|
|
69395
69428
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
69396
|
-
const jsonPath =
|
|
69429
|
+
const jsonPath = path322.join(d, manifestFile);
|
|
69397
69430
|
try {
|
|
69398
69431
|
const raw = fs21.readFileSync(jsonPath, "utf-8");
|
|
69399
69432
|
const mod = JSON.parse(raw);
|
|
@@ -69433,10 +69466,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69433
69466
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
69434
69467
|
} else {
|
|
69435
69468
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
69436
|
-
const scriptsPath =
|
|
69469
|
+
const scriptsPath = path322.join(d, "scripts.js");
|
|
69437
69470
|
if (!hasCompatibility && fs21.existsSync(scriptsPath)) {
|
|
69438
69471
|
try {
|
|
69439
|
-
registerProviderScriptRootSafely(
|
|
69472
|
+
registerProviderScriptRootSafely(path322.dirname(path322.dirname(d)));
|
|
69440
69473
|
delete require.cache[require.resolve(scriptsPath)];
|
|
69441
69474
|
const scripts = require(scriptsPath);
|
|
69442
69475
|
normalizedProvider.scripts = scripts;
|
|
@@ -69444,7 +69477,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69444
69477
|
this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
|
|
69445
69478
|
}
|
|
69446
69479
|
}
|
|
69447
|
-
const externalDirAbs =
|
|
69480
|
+
const externalDirAbs = path322.join(os23.homedir(), ".adhdev", "external");
|
|
69448
69481
|
const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
|
|
69449
69482
|
try {
|
|
69450
69483
|
const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
|
|
@@ -69454,8 +69487,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69454
69487
|
normalizedProvider._sourceTrust = trust;
|
|
69455
69488
|
normalizedProvider._manifestShape = shape;
|
|
69456
69489
|
if (layer === "external") {
|
|
69457
|
-
const rel =
|
|
69458
|
-
const firstSeg = rel.split(
|
|
69490
|
+
const rel = path322.relative(externalDirAbs, d);
|
|
69491
|
+
const firstSeg = rel.split(path322.sep)[0];
|
|
69459
69492
|
if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
|
|
69460
69493
|
}
|
|
69461
69494
|
} catch {
|
|
@@ -69479,7 +69512,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69479
69512
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
69480
69513
|
if (d === dir && entry.name === "examples") continue;
|
|
69481
69514
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
69482
|
-
scan(
|
|
69515
|
+
scan(path322.join(d, entry.name));
|
|
69483
69516
|
}
|
|
69484
69517
|
}
|
|
69485
69518
|
};
|
|
@@ -69557,7 +69590,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69557
69590
|
}
|
|
69558
69591
|
async function execQuiet(command, options = {}) {
|
|
69559
69592
|
return new Promise((resolve24) => {
|
|
69560
|
-
(0,
|
|
69593
|
+
(0, import_child_process7.exec)(command, options, (error48, stdout) => {
|
|
69561
69594
|
if (error48) return resolve24("");
|
|
69562
69595
|
resolve24(stdout.toString());
|
|
69563
69596
|
});
|
|
@@ -69808,8 +69841,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69808
69841
|
const appNameMap = getMacAppIdentifiers();
|
|
69809
69842
|
const appName = appNameMap[ideId];
|
|
69810
69843
|
if (appName) {
|
|
69811
|
-
const storagePath =
|
|
69812
|
-
process.env.APPDATA ||
|
|
69844
|
+
const storagePath = path33.join(
|
|
69845
|
+
process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Roaming"),
|
|
69813
69846
|
appName,
|
|
69814
69847
|
"storage.json"
|
|
69815
69848
|
);
|
|
@@ -69957,10 +69990,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69957
69990
|
const canUseAppLauncher = !!appName;
|
|
69958
69991
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
69959
69992
|
if (!useAppLauncher && ide.cliCommand) {
|
|
69960
|
-
(0,
|
|
69993
|
+
(0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
69961
69994
|
} else if (appName) {
|
|
69962
69995
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
69963
|
-
(0,
|
|
69996
|
+
(0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
69964
69997
|
} else {
|
|
69965
69998
|
throw new Error(`No app identifier or CLI for ${ide.displayName}`);
|
|
69966
69999
|
}
|
|
@@ -69986,7 +70019,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69986
70019
|
const args = ["--remote-debugging-port=" + port];
|
|
69987
70020
|
if (newWindow) args.push("--new-window");
|
|
69988
70021
|
if (workspace) args.push(workspace);
|
|
69989
|
-
(0,
|
|
70022
|
+
(0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
69990
70023
|
}
|
|
69991
70024
|
function getAvailableIdeIds() {
|
|
69992
70025
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -69997,9 +70030,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69997
70030
|
init_dist();
|
|
69998
70031
|
init_logger();
|
|
69999
70032
|
var fs222 = __toESM2(require("fs"));
|
|
70000
|
-
var
|
|
70033
|
+
var path34 = __toESM2(require("path"));
|
|
70001
70034
|
var os25 = __toESM2(require("os"));
|
|
70002
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
70035
|
+
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");
|
|
70003
70036
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
70004
70037
|
var MAX_DAYS = 7;
|
|
70005
70038
|
try {
|
|
@@ -70037,13 +70070,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70037
70070
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
70038
70071
|
}
|
|
70039
70072
|
var currentDate2 = getDateStr2();
|
|
70040
|
-
var currentFile =
|
|
70073
|
+
var currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
70041
70074
|
var writeCount2 = 0;
|
|
70042
70075
|
function checkRotation() {
|
|
70043
70076
|
const today = getDateStr2();
|
|
70044
70077
|
if (today !== currentDate2) {
|
|
70045
70078
|
currentDate2 = today;
|
|
70046
|
-
currentFile =
|
|
70079
|
+
currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
70047
70080
|
cleanOldFiles();
|
|
70048
70081
|
}
|
|
70049
70082
|
}
|
|
@@ -70057,7 +70090,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70057
70090
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
70058
70091
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
70059
70092
|
try {
|
|
70060
|
-
fs222.unlinkSync(
|
|
70093
|
+
fs222.unlinkSync(path34.join(LOG_DIR2, file2));
|
|
70061
70094
|
} catch {
|
|
70062
70095
|
}
|
|
70063
70096
|
}
|
|
@@ -70150,9 +70183,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70150
70183
|
var import_node_util4 = require("util");
|
|
70151
70184
|
var execFileAsync3 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
|
|
70152
70185
|
var MAX_CHANGED_FILES2 = 500;
|
|
70153
|
-
function topLevel(
|
|
70154
|
-
const slash =
|
|
70155
|
-
return slash === -1 ?
|
|
70186
|
+
function topLevel(path41) {
|
|
70187
|
+
const slash = path41.indexOf("/");
|
|
70188
|
+
return slash === -1 ? path41 : path41.slice(0, slash);
|
|
70156
70189
|
}
|
|
70157
70190
|
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
70158
70191
|
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
@@ -70248,10 +70281,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70248
70281
|
}
|
|
70249
70282
|
}
|
|
70250
70283
|
function readRecord6(repoRoot) {
|
|
70251
|
-
const
|
|
70252
|
-
if (!(0, import_node_fs4.existsSync)(
|
|
70284
|
+
const path41 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
70285
|
+
if (!(0, import_node_fs4.existsSync)(path41)) return null;
|
|
70253
70286
|
try {
|
|
70254
|
-
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(
|
|
70287
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path41, "utf8"));
|
|
70255
70288
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
70256
70289
|
} catch {
|
|
70257
70290
|
return null;
|
|
@@ -70312,7 +70345,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70312
70345
|
};
|
|
70313
70346
|
}
|
|
70314
70347
|
init_mesh_refine_status();
|
|
70315
|
-
var
|
|
70348
|
+
var import_fs15 = require("fs");
|
|
70316
70349
|
var import_path10 = require("path");
|
|
70317
70350
|
var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
|
|
70318
70351
|
var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
|
|
@@ -70328,21 +70361,21 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70328
70361
|
];
|
|
70329
70362
|
function writeConfigFile(workspace, relativePath, config2) {
|
|
70330
70363
|
const target = (0, import_path10.join)(workspace, relativePath);
|
|
70331
|
-
(0,
|
|
70332
|
-
(0,
|
|
70364
|
+
(0, import_fs15.mkdirSync)((0, import_path10.dirname)(target), { recursive: true });
|
|
70365
|
+
(0, import_fs15.writeFileSync)(target, `${JSON.stringify(config2, null, 2)}
|
|
70333
70366
|
`, "utf-8");
|
|
70334
70367
|
return target;
|
|
70335
70368
|
}
|
|
70336
70369
|
function suggestMeshWorktreeBootstrapConfig(workspace) {
|
|
70337
70370
|
const commands = [];
|
|
70338
|
-
const hasPackageJson = (0,
|
|
70339
|
-
const hasNpmLock = (0,
|
|
70371
|
+
const hasPackageJson = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package.json"));
|
|
70372
|
+
const hasNpmLock = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package-lock.json"));
|
|
70340
70373
|
if (hasPackageJson) {
|
|
70341
70374
|
commands.push(
|
|
70342
70375
|
hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
|
|
70343
70376
|
);
|
|
70344
70377
|
}
|
|
70345
|
-
const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0,
|
|
70378
|
+
const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0, import_fs15.existsSync)((0, import_path10.join)(workspace, relative5)));
|
|
70346
70379
|
if (!commands.length) {
|
|
70347
70380
|
return { commands, staleInputs };
|
|
70348
70381
|
}
|
|
@@ -70768,17 +70801,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70768
70801
|
};
|
|
70769
70802
|
}
|
|
70770
70803
|
init_build_info();
|
|
70771
|
-
var import_child_process7 = require("child_process");
|
|
70772
70804
|
var import_child_process8 = require("child_process");
|
|
70805
|
+
var import_child_process9 = require("child_process");
|
|
70773
70806
|
var fs23 = __toESM2(require("fs"));
|
|
70774
70807
|
var os27 = __toESM2(require("os"));
|
|
70775
|
-
var
|
|
70808
|
+
var path35 = __toESM2(require("path"));
|
|
70776
70809
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
70777
70810
|
function getUpgradeLogPath() {
|
|
70778
70811
|
const home = os27.homedir();
|
|
70779
|
-
const dir =
|
|
70812
|
+
const dir = path35.join(home, ".adhdev");
|
|
70780
70813
|
fs23.mkdirSync(dir, { recursive: true });
|
|
70781
|
-
return
|
|
70814
|
+
return path35.join(dir, "daemon-upgrade.log");
|
|
70782
70815
|
}
|
|
70783
70816
|
function appendUpgradeLog(message) {
|
|
70784
70817
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -70789,14 +70822,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70789
70822
|
}
|
|
70790
70823
|
}
|
|
70791
70824
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
70792
|
-
const binDir =
|
|
70825
|
+
const binDir = path35.dirname(nodeExecutable);
|
|
70793
70826
|
if (platform10 === "win32") {
|
|
70794
|
-
const npmCliPath =
|
|
70827
|
+
const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
70795
70828
|
if (fs23.existsSync(npmCliPath)) {
|
|
70796
70829
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
70797
70830
|
}
|
|
70798
70831
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
70799
|
-
const candidatePath =
|
|
70832
|
+
const candidatePath = path35.join(binDir, candidate);
|
|
70800
70833
|
if (fs23.existsSync(candidatePath)) {
|
|
70801
70834
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
70802
70835
|
}
|
|
@@ -70804,7 +70837,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70804
70837
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
70805
70838
|
}
|
|
70806
70839
|
for (const candidate of ["npm"]) {
|
|
70807
|
-
const candidatePath =
|
|
70840
|
+
const candidatePath = path35.join(binDir, candidate);
|
|
70808
70841
|
if (fs23.existsSync(candidatePath)) {
|
|
70809
70842
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
70810
70843
|
}
|
|
@@ -70821,13 +70854,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70821
70854
|
let currentDir = resolvedPath;
|
|
70822
70855
|
try {
|
|
70823
70856
|
if (fs23.statSync(resolvedPath).isFile()) {
|
|
70824
|
-
currentDir =
|
|
70857
|
+
currentDir = path35.dirname(resolvedPath);
|
|
70825
70858
|
}
|
|
70826
70859
|
} catch {
|
|
70827
|
-
currentDir =
|
|
70860
|
+
currentDir = path35.dirname(resolvedPath);
|
|
70828
70861
|
}
|
|
70829
70862
|
while (true) {
|
|
70830
|
-
const packageJsonPath =
|
|
70863
|
+
const packageJsonPath = path35.join(currentDir, "package.json");
|
|
70831
70864
|
try {
|
|
70832
70865
|
if (fs23.existsSync(packageJsonPath)) {
|
|
70833
70866
|
const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -70838,7 +70871,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70838
70871
|
}
|
|
70839
70872
|
} catch {
|
|
70840
70873
|
}
|
|
70841
|
-
const parentDir =
|
|
70874
|
+
const parentDir = path35.dirname(currentDir);
|
|
70842
70875
|
if (parentDir === currentDir) {
|
|
70843
70876
|
return null;
|
|
70844
70877
|
}
|
|
@@ -70846,13 +70879,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70846
70879
|
}
|
|
70847
70880
|
}
|
|
70848
70881
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
70849
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
70850
|
-
if (
|
|
70882
|
+
const nodeModulesDir = packageName.startsWith("@") ? path35.dirname(path35.dirname(packageRoot)) : path35.dirname(packageRoot);
|
|
70883
|
+
if (path35.basename(nodeModulesDir) !== "node_modules") {
|
|
70851
70884
|
return null;
|
|
70852
70885
|
}
|
|
70853
|
-
const maybeLibDir =
|
|
70854
|
-
if (
|
|
70855
|
-
return
|
|
70886
|
+
const maybeLibDir = path35.dirname(nodeModulesDir);
|
|
70887
|
+
if (path35.basename(maybeLibDir) === "lib") {
|
|
70888
|
+
return path35.dirname(maybeLibDir);
|
|
70856
70889
|
}
|
|
70857
70890
|
return maybeLibDir;
|
|
70858
70891
|
}
|
|
@@ -70880,6 +70913,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70880
70913
|
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
70881
70914
|
};
|
|
70882
70915
|
}
|
|
70916
|
+
function buildInstallEnvWithNodeOnPath(baseEnv = process.env) {
|
|
70917
|
+
if (process.platform !== "win32") return { ...baseEnv };
|
|
70918
|
+
const nodeBinDir = path35.dirname(process.execPath);
|
|
70919
|
+
if (!nodeBinDir) return { ...baseEnv };
|
|
70920
|
+
const env2 = { ...baseEnv };
|
|
70921
|
+
const pathKey = Object.keys(env2).find((k) => k.toLowerCase() === "path") || "PATH";
|
|
70922
|
+
const current = env2[pathKey] || "";
|
|
70923
|
+
env2[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
|
|
70924
|
+
return env2;
|
|
70925
|
+
}
|
|
70883
70926
|
function getNpmExecOptions(platform10 = process.platform) {
|
|
70884
70927
|
if (platform10 === "win32") {
|
|
70885
70928
|
return { shell: false, windowsHide: true };
|
|
@@ -70888,7 +70931,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70888
70931
|
}
|
|
70889
70932
|
function execNpmCommandSync(args, options = {}, surface) {
|
|
70890
70933
|
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
70891
|
-
return (0,
|
|
70934
|
+
return (0, import_child_process8.execFileSync)(
|
|
70892
70935
|
surface?.npmExecutable || "npm",
|
|
70893
70936
|
[...surface?.npmArgsPrefix || [], ...args],
|
|
70894
70937
|
{
|
|
@@ -70901,7 +70944,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70901
70944
|
function killPid2(pid) {
|
|
70902
70945
|
try {
|
|
70903
70946
|
if (process.platform === "win32") {
|
|
70904
|
-
(0,
|
|
70947
|
+
(0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
70905
70948
|
} else {
|
|
70906
70949
|
process.kill(pid, "SIGTERM");
|
|
70907
70950
|
}
|
|
@@ -70913,7 +70956,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70913
70956
|
function getWindowsProcessCommandLine(pid) {
|
|
70914
70957
|
const pidFilter = `ProcessId=${pid}`;
|
|
70915
70958
|
try {
|
|
70916
|
-
const psOut = (0,
|
|
70959
|
+
const psOut = (0, import_child_process8.execFileSync)("powershell.exe", [
|
|
70917
70960
|
"-NoProfile",
|
|
70918
70961
|
"-NonInteractive",
|
|
70919
70962
|
"-ExecutionPolicy",
|
|
@@ -70925,7 +70968,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70925
70968
|
} catch {
|
|
70926
70969
|
}
|
|
70927
70970
|
try {
|
|
70928
|
-
const wmicOut = (0,
|
|
70971
|
+
const wmicOut = (0, import_child_process8.execFileSync)("wmic", [
|
|
70929
70972
|
"process",
|
|
70930
70973
|
"where",
|
|
70931
70974
|
pidFilter,
|
|
@@ -70941,7 +70984,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70941
70984
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
70942
70985
|
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
70943
70986
|
try {
|
|
70944
|
-
const text = (0,
|
|
70987
|
+
const text = (0, import_child_process8.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
|
|
70945
70988
|
encoding: "utf8",
|
|
70946
70989
|
timeout: 3e3,
|
|
70947
70990
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -70967,7 +71010,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70967
71010
|
}
|
|
70968
71011
|
}
|
|
70969
71012
|
function stopSessionHostProcesses(appName) {
|
|
70970
|
-
const pidFile =
|
|
71013
|
+
const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
70971
71014
|
try {
|
|
70972
71015
|
if (fs23.existsSync(pidFile)) {
|
|
70973
71016
|
const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -70984,7 +71027,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70984
71027
|
}
|
|
70985
71028
|
}
|
|
70986
71029
|
function removeDaemonPidFile() {
|
|
70987
|
-
const pidFile =
|
|
71030
|
+
const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
|
|
70988
71031
|
try {
|
|
70989
71032
|
fs23.unlinkSync(pidFile);
|
|
70990
71033
|
} catch {
|
|
@@ -70995,7 +71038,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70995
71038
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
70996
71039
|
if (!npmRoot) return;
|
|
70997
71040
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
70998
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
71041
|
+
const binDir = process.platform === "win32" ? npmPrefix : path35.join(npmPrefix, "bin");
|
|
70999
71042
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
71000
71043
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
71001
71044
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -71003,31 +71046,31 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71003
71046
|
}
|
|
71004
71047
|
if (pkgName.startsWith("@")) {
|
|
71005
71048
|
const [scope, name] = pkgName.split("/");
|
|
71006
|
-
const scopeDir =
|
|
71049
|
+
const scopeDir = path35.join(npmRoot, scope);
|
|
71007
71050
|
if (!fs23.existsSync(scopeDir)) return;
|
|
71008
71051
|
for (const entry of fs23.readdirSync(scopeDir)) {
|
|
71009
71052
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
71010
|
-
fs23.rmSync(
|
|
71011
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
71053
|
+
fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
|
|
71054
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
|
|
71012
71055
|
}
|
|
71013
71056
|
} else {
|
|
71014
71057
|
for (const entry of fs23.readdirSync(npmRoot)) {
|
|
71015
71058
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
71016
|
-
fs23.rmSync(
|
|
71017
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
71059
|
+
fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
|
|
71060
|
+
appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
|
|
71018
71061
|
}
|
|
71019
71062
|
}
|
|
71020
71063
|
if (fs23.existsSync(binDir)) {
|
|
71021
71064
|
for (const entry of fs23.readdirSync(binDir)) {
|
|
71022
71065
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
71023
|
-
fs23.rmSync(
|
|
71024
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
71066
|
+
fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
|
|
71067
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
|
|
71025
71068
|
}
|
|
71026
71069
|
}
|
|
71027
71070
|
}
|
|
71028
71071
|
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
71029
71072
|
const env2 = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
71030
|
-
const child = (0,
|
|
71073
|
+
const child = (0, import_child_process9.spawn)(process.execPath, process.argv.slice(1), {
|
|
71031
71074
|
detached: true,
|
|
71032
71075
|
stdio: "ignore",
|
|
71033
71076
|
windowsHide: true,
|
|
@@ -71057,13 +71100,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71057
71100
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
71058
71101
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
71059
71102
|
appendUpgradeLog(`Installing ${spec}`);
|
|
71060
|
-
const installOutput = (0,
|
|
71103
|
+
const installOutput = (0, import_child_process8.execFileSync)(
|
|
71061
71104
|
installCommand.command,
|
|
71062
71105
|
installCommand.args,
|
|
71063
71106
|
{
|
|
71064
71107
|
encoding: "utf8",
|
|
71065
71108
|
stdio: "pipe",
|
|
71066
71109
|
maxBuffer: 20 * 1024 * 1024,
|
|
71110
|
+
env: buildInstallEnvWithNodeOnPath(),
|
|
71067
71111
|
...installCommand.execOptions
|
|
71068
71112
|
}
|
|
71069
71113
|
);
|
|
@@ -71079,7 +71123,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71079
71123
|
const env2 = { ...process.env };
|
|
71080
71124
|
delete env2[UPGRADE_HELPER_ENV];
|
|
71081
71125
|
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
71082
|
-
const child = (0,
|
|
71126
|
+
const child = (0, import_child_process9.spawn)(process.execPath, restartArgv, {
|
|
71083
71127
|
detached: true,
|
|
71084
71128
|
stdio: "ignore",
|
|
71085
71129
|
windowsHide: true,
|
|
@@ -72086,18 +72130,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72086
72130
|
return { enabled: false };
|
|
72087
72131
|
}
|
|
72088
72132
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
72089
|
-
const { execFileSync:
|
|
72133
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
72090
72134
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
72091
72135
|
if (excludePaths.length > 0) {
|
|
72092
|
-
diffArgs.push("--", ".", ...excludePaths.map((
|
|
72136
|
+
diffArgs.push("--", ".", ...excludePaths.map((path41) => `:(exclude)${path41}`));
|
|
72093
72137
|
}
|
|
72094
|
-
const diff =
|
|
72138
|
+
const diff = execFileSync7("git", diffArgs, {
|
|
72095
72139
|
cwd,
|
|
72096
72140
|
encoding: "utf8",
|
|
72097
72141
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
72098
72142
|
});
|
|
72099
72143
|
if (!diff.trim()) return "";
|
|
72100
|
-
const patchId =
|
|
72144
|
+
const patchId = execFileSync7("git", ["patch-id", "--stable"], {
|
|
72101
72145
|
cwd,
|
|
72102
72146
|
input: diff,
|
|
72103
72147
|
encoding: "utf8",
|
|
@@ -72108,8 +72152,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72108
72152
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
72109
72153
|
const startedAt = Date.now();
|
|
72110
72154
|
try {
|
|
72111
|
-
const { execFileSync:
|
|
72112
|
-
const git = (args) =>
|
|
72155
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
72156
|
+
const git = (args) => execFileSync7("git", args, {
|
|
72113
72157
|
cwd: repoRoot,
|
|
72114
72158
|
encoding: "utf8",
|
|
72115
72159
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -72200,8 +72244,8 @@ ${e?.stderr || ""}`
|
|
|
72200
72244
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
72201
72245
|
const startedAt = Date.now();
|
|
72202
72246
|
try {
|
|
72203
|
-
const { execFileSync:
|
|
72204
|
-
const git = (args, opts) =>
|
|
72247
|
+
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
72248
|
+
const git = (args, opts) => execFileSync7("git", args, {
|
|
72205
72249
|
cwd: opts?.cwd || repoRoot,
|
|
72206
72250
|
encoding: "utf8",
|
|
72207
72251
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -72226,9 +72270,9 @@ ${e?.stderr || ""}`
|
|
|
72226
72270
|
if (!trimmed) continue;
|
|
72227
72271
|
if (trimmed.startsWith("+")) {
|
|
72228
72272
|
const parts = trimmed.slice(1).trim().split(/\s+/);
|
|
72229
|
-
const
|
|
72273
|
+
const path41 = parts[1] || parts[0] || "(unknown)";
|
|
72230
72274
|
submoduleHints.push({
|
|
72231
|
-
path:
|
|
72275
|
+
path: path41,
|
|
72232
72276
|
reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
|
|
72233
72277
|
});
|
|
72234
72278
|
}
|
|
@@ -72258,10 +72302,10 @@ ${e?.stderr || ""}`
|
|
|
72258
72302
|
}
|
|
72259
72303
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
72260
72304
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
72261
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
72262
|
-
path:
|
|
72263
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
72264
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
72305
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => ({
|
|
72306
|
+
path: path41,
|
|
72307
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path41),
|
|
72308
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path41)
|
|
72265
72309
|
}));
|
|
72266
72310
|
if (conflicts.length === 0) return void 0;
|
|
72267
72311
|
return {
|
|
@@ -72287,11 +72331,11 @@ ${e?.stderr || ""}`
|
|
|
72287
72331
|
if (!line.trim()) continue;
|
|
72288
72332
|
const metaAndPath = line.split(" ");
|
|
72289
72333
|
const meta3 = metaAndPath[0] || "";
|
|
72290
|
-
const
|
|
72291
|
-
if (!
|
|
72334
|
+
const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
72335
|
+
if (!path41) continue;
|
|
72292
72336
|
const parts = meta3.split(/\s+/);
|
|
72293
72337
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
72294
|
-
paths.add(
|
|
72338
|
+
paths.add(path41);
|
|
72295
72339
|
}
|
|
72296
72340
|
}
|
|
72297
72341
|
return [...paths].sort();
|
|
@@ -72299,9 +72343,9 @@ ${e?.stderr || ""}`
|
|
|
72299
72343
|
return [];
|
|
72300
72344
|
}
|
|
72301
72345
|
}
|
|
72302
|
-
function readTreeObject(repoRoot, ref,
|
|
72346
|
+
function readTreeObject(repoRoot, ref, path41) {
|
|
72303
72347
|
try {
|
|
72304
|
-
const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--",
|
|
72348
|
+
const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--", path41], {
|
|
72305
72349
|
cwd: repoRoot,
|
|
72306
72350
|
encoding: "utf8",
|
|
72307
72351
|
maxBuffer: 1024 * 1024
|
|
@@ -72346,12 +72390,12 @@ ${e?.stderr || ""}`
|
|
|
72346
72390
|
if (!line.trim()) continue;
|
|
72347
72391
|
const metaAndPath = line.split(" ");
|
|
72348
72392
|
const meta3 = metaAndPath[0] || "";
|
|
72349
|
-
const
|
|
72350
|
-
if (!
|
|
72351
|
-
seen.add(
|
|
72393
|
+
const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
72394
|
+
if (!path41 || seen.has(path41)) continue;
|
|
72395
|
+
seen.add(path41);
|
|
72352
72396
|
const parts = meta3.split(/\s+/);
|
|
72353
72397
|
const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
|
|
72354
|
-
result.push({ path:
|
|
72398
|
+
result.push({ path: path41, isGitlink });
|
|
72355
72399
|
}
|
|
72356
72400
|
return result;
|
|
72357
72401
|
} catch {
|
|
@@ -72359,20 +72403,20 @@ ${e?.stderr || ""}`
|
|
|
72359
72403
|
}
|
|
72360
72404
|
}
|
|
72361
72405
|
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
72362
|
-
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((
|
|
72363
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
72364
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
72406
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path41) => {
|
|
72407
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path41);
|
|
72408
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path41);
|
|
72365
72409
|
if (!baseCommit || !branchCommit) return false;
|
|
72366
|
-
return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot,
|
|
72410
|
+
return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot, path41), baseCommit, branchCommit);
|
|
72367
72411
|
});
|
|
72368
72412
|
}
|
|
72369
72413
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
72370
|
-
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
72371
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
72372
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
72373
|
-
const submoduleRepoPath = (0, import_path11.resolve)(repoRoot,
|
|
72414
|
+
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => {
|
|
72415
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path41);
|
|
72416
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path41);
|
|
72417
|
+
const submoduleRepoPath = (0, import_path11.resolve)(repoRoot, path41);
|
|
72374
72418
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
72375
|
-
return { path:
|
|
72419
|
+
return { path: path41, baseCommit, branchCommit, fastForward };
|
|
72376
72420
|
});
|
|
72377
72421
|
if (changedGitlinks.length === 0) {
|
|
72378
72422
|
return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
|
|
@@ -72423,7 +72467,7 @@ ${e?.stderr || ""}`
|
|
|
72423
72467
|
maxBuffer: 1024 * 1024
|
|
72424
72468
|
}).trim();
|
|
72425
72469
|
if (!tree) return void 0;
|
|
72426
|
-
const updates = paths.map((
|
|
72470
|
+
const updates = paths.map((path41) => `160000 commit ${placeholderCommit} ${path41}`).join("\n");
|
|
72427
72471
|
if (!updates) return tree;
|
|
72428
72472
|
const tmpIndex = (0, import_path11.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
72429
72473
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
@@ -72526,7 +72570,7 @@ ${e?.stderr || ""}`
|
|
|
72526
72570
|
}
|
|
72527
72571
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
72528
72572
|
const startedAt = Date.now();
|
|
72529
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
72573
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path41) => !(options.submoduleIgnorePaths || []).includes(path41));
|
|
72530
72574
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
72531
72575
|
includeSubmodules: true,
|
|
72532
72576
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -72567,7 +72611,7 @@ ${e?.stderr || ""}`
|
|
|
72567
72611
|
changedGitlinkPaths,
|
|
72568
72612
|
outOfSyncPaths,
|
|
72569
72613
|
updatedPaths: updatePaths,
|
|
72570
|
-
verifiedPaths: updatePaths.filter((
|
|
72614
|
+
verifiedPaths: updatePaths.filter((path41) => !remaining.some((submodule) => submodule.path === path41)),
|
|
72571
72615
|
durationMs: Date.now() - startedAt,
|
|
72572
72616
|
command: `git ${commandArgs.join(" ")}`,
|
|
72573
72617
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -75865,9 +75909,9 @@ ${hintLines.join("\n")}` : "",
|
|
|
75865
75909
|
// commands instead of going through fs from the browser.
|
|
75866
75910
|
case "list_coordinator_prompts": {
|
|
75867
75911
|
const fs30 = await import("fs");
|
|
75868
|
-
const
|
|
75912
|
+
const path41 = await import("path");
|
|
75869
75913
|
const os30 = await import("os");
|
|
75870
|
-
const dir =
|
|
75914
|
+
const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
75871
75915
|
const entries = {};
|
|
75872
75916
|
try {
|
|
75873
75917
|
if (fs30.existsSync(dir)) {
|
|
@@ -75878,7 +75922,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
75878
75922
|
if (!m) continue;
|
|
75879
75923
|
const isAppend = !!matchAppend;
|
|
75880
75924
|
const key = m[1];
|
|
75881
|
-
const full =
|
|
75925
|
+
const full = path41.join(dir, name);
|
|
75882
75926
|
let content = "";
|
|
75883
75927
|
try {
|
|
75884
75928
|
content = fs30.readFileSync(full, "utf8");
|
|
@@ -75896,7 +75940,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
75896
75940
|
}
|
|
75897
75941
|
case "write_coordinator_prompt": {
|
|
75898
75942
|
const fs30 = await import("fs");
|
|
75899
|
-
const
|
|
75943
|
+
const path41 = await import("path");
|
|
75900
75944
|
const os30 = await import("os");
|
|
75901
75945
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
75902
75946
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
@@ -75904,9 +75948,9 @@ ${hintLines.join("\n")}` : "",
|
|
|
75904
75948
|
if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
|
|
75905
75949
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
75906
75950
|
}
|
|
75907
|
-
const dir =
|
|
75951
|
+
const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
75908
75952
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
75909
|
-
const full =
|
|
75953
|
+
const full = path41.join(dir, filename);
|
|
75910
75954
|
try {
|
|
75911
75955
|
fs30.mkdirSync(dir, { recursive: true });
|
|
75912
75956
|
if (content.trim()) {
|
|
@@ -77461,7 +77505,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77461
77505
|
workspace
|
|
77462
77506
|
};
|
|
77463
77507
|
}
|
|
77464
|
-
const { existsSync:
|
|
77508
|
+
const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
77465
77509
|
const { dirname: dirname14 } = await import("path");
|
|
77466
77510
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
77467
77511
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -77504,7 +77548,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77504
77548
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
77505
77549
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
77506
77550
|
}
|
|
77507
|
-
const hadExistingMcpConfig =
|
|
77551
|
+
const hadExistingMcpConfig = existsSync43(mcpConfigPath);
|
|
77508
77552
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
77509
77553
|
if (hermesBaseConfig) {
|
|
77510
77554
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
|
|
@@ -78022,7 +78066,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78022
78066
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
78023
78067
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
78024
78068
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
78025
|
-
const { existsSync:
|
|
78069
|
+
const { existsSync: existsSync43 } = await import("fs");
|
|
78026
78070
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
78027
78071
|
const mesh = meshRecord?.mesh;
|
|
78028
78072
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -78041,7 +78085,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78041
78085
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
78042
78086
|
for (const item of derivation.items) {
|
|
78043
78087
|
const workspace = item.workspace;
|
|
78044
|
-
if (!workspace || !
|
|
78088
|
+
if (!workspace || !existsSync43(workspace)) continue;
|
|
78045
78089
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
78046
78090
|
try {
|
|
78047
78091
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -79766,11 +79810,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79766
79810
|
}
|
|
79767
79811
|
};
|
|
79768
79812
|
var fs25 = __toESM2(require("fs"));
|
|
79769
|
-
var
|
|
79813
|
+
var path36 = __toESM2(require("path"));
|
|
79770
79814
|
var os28 = __toESM2(require("os"));
|
|
79771
79815
|
var import_os4 = require("os");
|
|
79772
|
-
var
|
|
79773
|
-
var ARCHIVE_PATH =
|
|
79816
|
+
var import_child_process10 = require("child_process");
|
|
79817
|
+
var ARCHIVE_PATH = path36.join(os28.homedir(), ".adhdev", "version-history.json");
|
|
79774
79818
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
79775
79819
|
var VersionArchive = class {
|
|
79776
79820
|
history = {};
|
|
@@ -79817,7 +79861,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79817
79861
|
}
|
|
79818
79862
|
save() {
|
|
79819
79863
|
try {
|
|
79820
|
-
fs25.mkdirSync(
|
|
79864
|
+
fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
|
|
79821
79865
|
fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
79822
79866
|
} catch {
|
|
79823
79867
|
}
|
|
@@ -79825,7 +79869,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79825
79869
|
};
|
|
79826
79870
|
async function runCommand(cmd, timeout = 1e4) {
|
|
79827
79871
|
return new Promise((resolve24) => {
|
|
79828
|
-
(0,
|
|
79872
|
+
(0, import_child_process10.exec)(cmd, {
|
|
79829
79873
|
encoding: "utf-8",
|
|
79830
79874
|
timeout
|
|
79831
79875
|
}, (error48, stdout) => {
|
|
@@ -79841,7 +79885,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79841
79885
|
for (const p of paths) {
|
|
79842
79886
|
if (!p) continue;
|
|
79843
79887
|
for (const ext of exes) {
|
|
79844
|
-
const fullPath =
|
|
79888
|
+
const fullPath = path36.join(p, name + ext);
|
|
79845
79889
|
try {
|
|
79846
79890
|
if (fs25.existsSync(fullPath)) {
|
|
79847
79891
|
const stat2 = fs25.statSync(fullPath);
|
|
@@ -79890,7 +79934,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79890
79934
|
for (const p of paths) {
|
|
79891
79935
|
if (p.includes("*")) {
|
|
79892
79936
|
const home = os28.homedir();
|
|
79893
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
79937
|
+
const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
|
|
79894
79938
|
if (fs25.existsSync(resolved)) return resolved;
|
|
79895
79939
|
} else {
|
|
79896
79940
|
if (fs25.existsSync(p)) return p;
|
|
@@ -79900,7 +79944,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79900
79944
|
}
|
|
79901
79945
|
async function getMacAppVersion(appPath) {
|
|
79902
79946
|
if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
79903
|
-
const plistPath =
|
|
79947
|
+
const plistPath = path36.join(appPath, "Contents", "Info.plist");
|
|
79904
79948
|
if (!fs25.existsSync(plistPath)) return null;
|
|
79905
79949
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
79906
79950
|
return raw || null;
|
|
@@ -79926,7 +79970,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79926
79970
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
79927
79971
|
let resolvedBin = cliBin;
|
|
79928
79972
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
79929
|
-
const bundled =
|
|
79973
|
+
const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
79930
79974
|
if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
|
|
79931
79975
|
}
|
|
79932
79976
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -79965,7 +80009,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79965
80009
|
}
|
|
79966
80010
|
var http2 = __toESM2(require("http"));
|
|
79967
80011
|
var fs29 = __toESM2(require("fs"));
|
|
79968
|
-
var
|
|
80012
|
+
var path40 = __toESM2(require("path"));
|
|
79969
80013
|
init_config();
|
|
79970
80014
|
function generateFiles(type, name, category, opts = {}) {
|
|
79971
80015
|
const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
|
|
@@ -80310,7 +80354,7 @@ async (params) => {
|
|
|
80310
80354
|
}
|
|
80311
80355
|
init_logger();
|
|
80312
80356
|
var fs26 = __toESM2(require("fs"));
|
|
80313
|
-
var
|
|
80357
|
+
var path37 = __toESM2(require("path"));
|
|
80314
80358
|
init_logger();
|
|
80315
80359
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
80316
80360
|
const body = await ctx.readBody(req);
|
|
@@ -80489,17 +80533,17 @@ async (params) => {
|
|
|
80489
80533
|
return;
|
|
80490
80534
|
}
|
|
80491
80535
|
let scriptsPath = "";
|
|
80492
|
-
const directScripts =
|
|
80536
|
+
const directScripts = path37.join(dir, "scripts.js");
|
|
80493
80537
|
if (fs26.existsSync(directScripts)) {
|
|
80494
80538
|
scriptsPath = directScripts;
|
|
80495
80539
|
} else {
|
|
80496
|
-
const scriptsDir =
|
|
80540
|
+
const scriptsDir = path37.join(dir, "scripts");
|
|
80497
80541
|
if (fs26.existsSync(scriptsDir)) {
|
|
80498
80542
|
const versions = fs26.readdirSync(scriptsDir).filter((d) => {
|
|
80499
|
-
return fs26.statSync(
|
|
80543
|
+
return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
|
|
80500
80544
|
}).sort().reverse();
|
|
80501
80545
|
for (const ver of versions) {
|
|
80502
|
-
const p =
|
|
80546
|
+
const p = path37.join(scriptsDir, ver, "scripts.js");
|
|
80503
80547
|
if (fs26.existsSync(p)) {
|
|
80504
80548
|
scriptsPath = p;
|
|
80505
80549
|
break;
|
|
@@ -81326,7 +81370,7 @@ async (params) => {
|
|
|
81326
81370
|
}
|
|
81327
81371
|
}
|
|
81328
81372
|
var fs27 = __toESM2(require("fs"));
|
|
81329
|
-
var
|
|
81373
|
+
var path38 = __toESM2(require("path"));
|
|
81330
81374
|
function slugifyFixtureName(value) {
|
|
81331
81375
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
81332
81376
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -81336,11 +81380,11 @@ async (params) => {
|
|
|
81336
81380
|
if (!providerDir) {
|
|
81337
81381
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
81338
81382
|
}
|
|
81339
|
-
return
|
|
81383
|
+
return path38.join(providerDir, "fixtures");
|
|
81340
81384
|
}
|
|
81341
81385
|
function readCliFixture(ctx, type, name) {
|
|
81342
81386
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
81343
|
-
const filePath =
|
|
81387
|
+
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
81344
81388
|
if (!fs27.existsSync(filePath)) {
|
|
81345
81389
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
81346
81390
|
}
|
|
@@ -82116,7 +82160,7 @@ async (params) => {
|
|
|
82116
82160
|
},
|
|
82117
82161
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
82118
82162
|
};
|
|
82119
|
-
const filePath =
|
|
82163
|
+
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
82120
82164
|
fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
82121
82165
|
ctx.json(res, 200, {
|
|
82122
82166
|
saved: true,
|
|
@@ -82140,7 +82184,7 @@ async (params) => {
|
|
|
82140
82184
|
return;
|
|
82141
82185
|
}
|
|
82142
82186
|
const fixtures = fs27.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
82143
|
-
const fullPath =
|
|
82187
|
+
const fullPath = path38.join(fixtureDir, file2);
|
|
82144
82188
|
try {
|
|
82145
82189
|
const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
|
|
82146
82190
|
return {
|
|
@@ -82274,7 +82318,7 @@ async (params) => {
|
|
|
82274
82318
|
}
|
|
82275
82319
|
}
|
|
82276
82320
|
var fs28 = __toESM2(require("fs"));
|
|
82277
|
-
var
|
|
82321
|
+
var path39 = __toESM2(require("path"));
|
|
82278
82322
|
var os29 = __toESM2(require("os"));
|
|
82279
82323
|
var import_session_host_core8 = require_dist();
|
|
82280
82324
|
function getAutoImplPid(ctx) {
|
|
@@ -82325,22 +82369,22 @@ async (params) => {
|
|
|
82325
82369
|
if (!fs28.existsSync(scriptsDir)) return null;
|
|
82326
82370
|
const versions = fs28.readdirSync(scriptsDir).filter((d) => {
|
|
82327
82371
|
try {
|
|
82328
|
-
return fs28.statSync(
|
|
82372
|
+
return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
82329
82373
|
} catch {
|
|
82330
82374
|
return false;
|
|
82331
82375
|
}
|
|
82332
82376
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
82333
82377
|
if (versions.length === 0) return null;
|
|
82334
|
-
return
|
|
82378
|
+
return path39.join(scriptsDir, versions[0]);
|
|
82335
82379
|
}
|
|
82336
82380
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
82337
|
-
const canonicalUserDir =
|
|
82338
|
-
const desiredDir = requestedDir ?
|
|
82339
|
-
const upstreamRoot =
|
|
82340
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
82381
|
+
const canonicalUserDir = path39.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
82382
|
+
const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
|
|
82383
|
+
const upstreamRoot = path39.resolve(ctx.providerLoader.getUpstreamDir());
|
|
82384
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
|
|
82341
82385
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
82342
82386
|
}
|
|
82343
|
-
if (
|
|
82387
|
+
if (path39.basename(desiredDir) !== type) {
|
|
82344
82388
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
82345
82389
|
}
|
|
82346
82390
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -82348,11 +82392,11 @@ async (params) => {
|
|
|
82348
82392
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
82349
82393
|
}
|
|
82350
82394
|
if (!fs28.existsSync(desiredDir)) {
|
|
82351
|
-
fs28.mkdirSync(
|
|
82395
|
+
fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
|
|
82352
82396
|
fs28.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
82353
82397
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
82354
82398
|
}
|
|
82355
|
-
const providerJson =
|
|
82399
|
+
const providerJson = path39.join(desiredDir, "provider.json");
|
|
82356
82400
|
if (!fs28.existsSync(providerJson)) {
|
|
82357
82401
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
82358
82402
|
}
|
|
@@ -82363,13 +82407,13 @@ async (params) => {
|
|
|
82363
82407
|
const refDir = ctx.findProviderDir(referenceType);
|
|
82364
82408
|
if (!refDir || !fs28.existsSync(refDir)) return {};
|
|
82365
82409
|
const referenceScripts = {};
|
|
82366
|
-
const scriptsDir =
|
|
82410
|
+
const scriptsDir = path39.join(refDir, "scripts");
|
|
82367
82411
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
82368
82412
|
if (!latestDir) return referenceScripts;
|
|
82369
82413
|
for (const file2 of fs28.readdirSync(latestDir)) {
|
|
82370
82414
|
if (!file2.endsWith(".js")) continue;
|
|
82371
82415
|
try {
|
|
82372
|
-
referenceScripts[file2] = fs28.readFileSync(
|
|
82416
|
+
referenceScripts[file2] = fs28.readFileSync(path39.join(latestDir, file2), "utf-8");
|
|
82373
82417
|
} catch {
|
|
82374
82418
|
}
|
|
82375
82419
|
}
|
|
@@ -82477,9 +82521,9 @@ async (params) => {
|
|
|
82477
82521
|
});
|
|
82478
82522
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
82479
82523
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
82480
|
-
const tmpDir =
|
|
82524
|
+
const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
82481
82525
|
if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
|
|
82482
|
-
const promptFile =
|
|
82526
|
+
const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
82483
82527
|
fs28.writeFileSync(promptFile, prompt, "utf-8");
|
|
82484
82528
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
82485
82529
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -82911,7 +82955,7 @@ async (params) => {
|
|
|
82911
82955
|
setMode: "set_mode.js"
|
|
82912
82956
|
};
|
|
82913
82957
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
82914
|
-
const scriptsDir =
|
|
82958
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
82915
82959
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
82916
82960
|
if (latestScriptsDir) {
|
|
82917
82961
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -82922,7 +82966,7 @@ async (params) => {
|
|
|
82922
82966
|
for (const file2 of fs28.readdirSync(latestScriptsDir)) {
|
|
82923
82967
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
82924
82968
|
try {
|
|
82925
|
-
const content = fs28.readFileSync(
|
|
82969
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
82926
82970
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
82927
82971
|
lines.push("```javascript");
|
|
82928
82972
|
lines.push(content);
|
|
@@ -82939,7 +82983,7 @@ async (params) => {
|
|
|
82939
82983
|
lines.push("");
|
|
82940
82984
|
for (const file2 of refFiles) {
|
|
82941
82985
|
try {
|
|
82942
|
-
const content = fs28.readFileSync(
|
|
82986
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
82943
82987
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
82944
82988
|
lines.push("```javascript");
|
|
82945
82989
|
lines.push(content);
|
|
@@ -82980,10 +83024,10 @@ async (params) => {
|
|
|
82980
83024
|
lines.push("");
|
|
82981
83025
|
}
|
|
82982
83026
|
}
|
|
82983
|
-
const docsDir =
|
|
83027
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
82984
83028
|
const loadGuide = (name) => {
|
|
82985
83029
|
try {
|
|
82986
|
-
const p =
|
|
83030
|
+
const p = path39.join(docsDir, name);
|
|
82987
83031
|
if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
|
|
82988
83032
|
} catch {
|
|
82989
83033
|
}
|
|
@@ -83220,7 +83264,7 @@ async (params) => {
|
|
|
83220
83264
|
parseApproval: "parse_approval.js"
|
|
83221
83265
|
};
|
|
83222
83266
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
83223
|
-
const scriptsDir =
|
|
83267
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
83224
83268
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
83225
83269
|
if (latestScriptsDir) {
|
|
83226
83270
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -83232,7 +83276,7 @@ async (params) => {
|
|
|
83232
83276
|
if (!file2.endsWith(".js")) continue;
|
|
83233
83277
|
if (!targetFileNames.has(file2)) continue;
|
|
83234
83278
|
try {
|
|
83235
|
-
const content = fs28.readFileSync(
|
|
83279
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83236
83280
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
83237
83281
|
lines.push("```javascript");
|
|
83238
83282
|
lines.push(content);
|
|
@@ -83248,7 +83292,7 @@ async (params) => {
|
|
|
83248
83292
|
lines.push("");
|
|
83249
83293
|
for (const file2 of refFiles) {
|
|
83250
83294
|
try {
|
|
83251
|
-
const content = fs28.readFileSync(
|
|
83295
|
+
const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83252
83296
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
83253
83297
|
lines.push("```javascript");
|
|
83254
83298
|
lines.push(content);
|
|
@@ -83281,10 +83325,10 @@ async (params) => {
|
|
|
83281
83325
|
lines.push("");
|
|
83282
83326
|
}
|
|
83283
83327
|
}
|
|
83284
|
-
const docsDir =
|
|
83328
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
83285
83329
|
const loadGuide = (name) => {
|
|
83286
83330
|
try {
|
|
83287
|
-
const p =
|
|
83331
|
+
const p = path39.join(docsDir, name);
|
|
83288
83332
|
if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
|
|
83289
83333
|
} catch {
|
|
83290
83334
|
}
|
|
@@ -83729,8 +83773,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
83729
83773
|
}
|
|
83730
83774
|
getEndpointList() {
|
|
83731
83775
|
return this.routes.map((r) => {
|
|
83732
|
-
const
|
|
83733
|
-
return `${r.method.padEnd(5)} ${
|
|
83776
|
+
const path41 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
83777
|
+
return `${r.method.padEnd(5)} ${path41}`;
|
|
83734
83778
|
});
|
|
83735
83779
|
}
|
|
83736
83780
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -84018,12 +84062,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84018
84062
|
// ─── DevConsole SPA ───
|
|
84019
84063
|
getConsoleDistDir() {
|
|
84020
84064
|
const candidates = [
|
|
84021
|
-
|
|
84022
|
-
|
|
84023
|
-
|
|
84065
|
+
path40.resolve(__dirname, "../../web-devconsole/dist"),
|
|
84066
|
+
path40.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
84067
|
+
path40.join(process.cwd(), "packages/web-devconsole/dist")
|
|
84024
84068
|
];
|
|
84025
84069
|
for (const dir of candidates) {
|
|
84026
|
-
if (fs29.existsSync(
|
|
84070
|
+
if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
|
|
84027
84071
|
}
|
|
84028
84072
|
return null;
|
|
84029
84073
|
}
|
|
@@ -84033,7 +84077,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84033
84077
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
84034
84078
|
return;
|
|
84035
84079
|
}
|
|
84036
|
-
const htmlPath =
|
|
84080
|
+
const htmlPath = path40.join(distDir, "index.html");
|
|
84037
84081
|
try {
|
|
84038
84082
|
const html = fs29.readFileSync(htmlPath, "utf-8");
|
|
84039
84083
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -84058,15 +84102,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84058
84102
|
this.json(res, 404, { error: "Not found" });
|
|
84059
84103
|
return;
|
|
84060
84104
|
}
|
|
84061
|
-
const safePath =
|
|
84062
|
-
const filePath =
|
|
84105
|
+
const safePath = path40.normalize(pathname).replace(/^\.\.\//, "");
|
|
84106
|
+
const filePath = path40.join(distDir, safePath);
|
|
84063
84107
|
if (!filePath.startsWith(distDir)) {
|
|
84064
84108
|
this.json(res, 403, { error: "Forbidden" });
|
|
84065
84109
|
return;
|
|
84066
84110
|
}
|
|
84067
84111
|
try {
|
|
84068
84112
|
const content = fs29.readFileSync(filePath);
|
|
84069
|
-
const ext =
|
|
84113
|
+
const ext = path40.extname(filePath);
|
|
84070
84114
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
84071
84115
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
84072
84116
|
res.end(content);
|
|
@@ -84179,9 +84223,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84179
84223
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
84180
84224
|
if (entry.isDirectory()) {
|
|
84181
84225
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
84182
|
-
scan(
|
|
84226
|
+
scan(path40.join(d, entry.name), rel);
|
|
84183
84227
|
} else {
|
|
84184
|
-
const stat2 = fs29.statSync(
|
|
84228
|
+
const stat2 = fs29.statSync(path40.join(d, entry.name));
|
|
84185
84229
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
84186
84230
|
}
|
|
84187
84231
|
}
|
|
@@ -84204,7 +84248,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84204
84248
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
84205
84249
|
return;
|
|
84206
84250
|
}
|
|
84207
|
-
const fullPath =
|
|
84251
|
+
const fullPath = path40.resolve(dir, path40.normalize(filePath));
|
|
84208
84252
|
if (!fullPath.startsWith(dir)) {
|
|
84209
84253
|
this.json(res, 403, { error: "Forbidden" });
|
|
84210
84254
|
return;
|
|
@@ -84229,14 +84273,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84229
84273
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
84230
84274
|
return;
|
|
84231
84275
|
}
|
|
84232
|
-
const fullPath =
|
|
84276
|
+
const fullPath = path40.resolve(dir, path40.normalize(filePath));
|
|
84233
84277
|
if (!fullPath.startsWith(dir)) {
|
|
84234
84278
|
this.json(res, 403, { error: "Forbidden" });
|
|
84235
84279
|
return;
|
|
84236
84280
|
}
|
|
84237
84281
|
try {
|
|
84238
84282
|
if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
|
|
84239
|
-
fs29.mkdirSync(
|
|
84283
|
+
fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
84240
84284
|
fs29.writeFileSync(fullPath, content, "utf-8");
|
|
84241
84285
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
84242
84286
|
this.providerLoader.reload();
|
|
@@ -84253,7 +84297,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84253
84297
|
return;
|
|
84254
84298
|
}
|
|
84255
84299
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
84256
|
-
const p =
|
|
84300
|
+
const p = path40.join(dir, name);
|
|
84257
84301
|
if (fs29.existsSync(p)) {
|
|
84258
84302
|
const source = fs29.readFileSync(p, "utf-8");
|
|
84259
84303
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -84274,8 +84318,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84274
84318
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
84275
84319
|
return;
|
|
84276
84320
|
}
|
|
84277
|
-
const target = fs29.existsSync(
|
|
84278
|
-
const targetPath =
|
|
84321
|
+
const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
84322
|
+
const targetPath = path40.join(dir, target);
|
|
84279
84323
|
try {
|
|
84280
84324
|
if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
|
|
84281
84325
|
fs29.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -84422,7 +84466,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84422
84466
|
}
|
|
84423
84467
|
let targetDir;
|
|
84424
84468
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
84425
|
-
const jsonPath =
|
|
84469
|
+
const jsonPath = path40.join(targetDir, "provider.json");
|
|
84426
84470
|
if (fs29.existsSync(jsonPath)) {
|
|
84427
84471
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
84428
84472
|
return;
|
|
@@ -84434,8 +84478,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84434
84478
|
const createdFiles = ["provider.json"];
|
|
84435
84479
|
if (result.files) {
|
|
84436
84480
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
84437
|
-
const fullPath =
|
|
84438
|
-
fs29.mkdirSync(
|
|
84481
|
+
const fullPath = path40.join(targetDir, relPath);
|
|
84482
|
+
fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
84439
84483
|
fs29.writeFileSync(fullPath, content, "utf-8");
|
|
84440
84484
|
createdFiles.push(relPath);
|
|
84441
84485
|
}
|
|
@@ -84488,22 +84532,22 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84488
84532
|
if (!fs29.existsSync(scriptsDir)) return null;
|
|
84489
84533
|
const versions = fs29.readdirSync(scriptsDir).filter((d) => {
|
|
84490
84534
|
try {
|
|
84491
|
-
return fs29.statSync(
|
|
84535
|
+
return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
|
|
84492
84536
|
} catch {
|
|
84493
84537
|
return false;
|
|
84494
84538
|
}
|
|
84495
84539
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
84496
84540
|
if (versions.length === 0) return null;
|
|
84497
|
-
return
|
|
84541
|
+
return path40.join(scriptsDir, versions[0]);
|
|
84498
84542
|
}
|
|
84499
84543
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
84500
|
-
const canonicalUserDir =
|
|
84501
|
-
const desiredDir = requestedDir ?
|
|
84502
|
-
const upstreamRoot =
|
|
84503
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
84544
|
+
const canonicalUserDir = path40.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
84545
|
+
const desiredDir = requestedDir ? path40.resolve(requestedDir) : canonicalUserDir;
|
|
84546
|
+
const upstreamRoot = path40.resolve(this.providerLoader.getUpstreamDir());
|
|
84547
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path40.sep}`)) {
|
|
84504
84548
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
84505
84549
|
}
|
|
84506
|
-
if (
|
|
84550
|
+
if (path40.basename(desiredDir) !== type) {
|
|
84507
84551
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
84508
84552
|
}
|
|
84509
84553
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -84511,11 +84555,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84511
84555
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
84512
84556
|
}
|
|
84513
84557
|
if (!fs29.existsSync(desiredDir)) {
|
|
84514
|
-
fs29.mkdirSync(
|
|
84558
|
+
fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
|
|
84515
84559
|
fs29.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
84516
84560
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
84517
84561
|
}
|
|
84518
|
-
const providerJson =
|
|
84562
|
+
const providerJson = path40.join(desiredDir, "provider.json");
|
|
84519
84563
|
if (!fs29.existsSync(providerJson)) {
|
|
84520
84564
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
84521
84565
|
}
|
|
@@ -84551,7 +84595,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84551
84595
|
setMode: "set_mode.js"
|
|
84552
84596
|
};
|
|
84553
84597
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
84554
|
-
const scriptsDir =
|
|
84598
|
+
const scriptsDir = path40.join(providerDir, "scripts");
|
|
84555
84599
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
84556
84600
|
if (latestScriptsDir) {
|
|
84557
84601
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -84562,7 +84606,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84562
84606
|
for (const file2 of fs29.readdirSync(latestScriptsDir)) {
|
|
84563
84607
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
84564
84608
|
try {
|
|
84565
|
-
const content = fs29.readFileSync(
|
|
84609
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
84566
84610
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
84567
84611
|
lines.push("```javascript");
|
|
84568
84612
|
lines.push(content);
|
|
@@ -84579,7 +84623,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84579
84623
|
lines.push("");
|
|
84580
84624
|
for (const file2 of refFiles) {
|
|
84581
84625
|
try {
|
|
84582
|
-
const content = fs29.readFileSync(
|
|
84626
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
84583
84627
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
84584
84628
|
lines.push("```javascript");
|
|
84585
84629
|
lines.push(content);
|
|
@@ -84620,10 +84664,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84620
84664
|
lines.push("");
|
|
84621
84665
|
}
|
|
84622
84666
|
}
|
|
84623
|
-
const docsDir =
|
|
84667
|
+
const docsDir = path40.join(providerDir, "../../docs");
|
|
84624
84668
|
const loadGuide = (name) => {
|
|
84625
84669
|
try {
|
|
84626
|
-
const p =
|
|
84670
|
+
const p = path40.join(docsDir, name);
|
|
84627
84671
|
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
84628
84672
|
} catch {
|
|
84629
84673
|
}
|
|
@@ -84797,7 +84841,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84797
84841
|
parseApproval: "parse_approval.js"
|
|
84798
84842
|
};
|
|
84799
84843
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
84800
|
-
const scriptsDir =
|
|
84844
|
+
const scriptsDir = path40.join(providerDir, "scripts");
|
|
84801
84845
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
84802
84846
|
if (latestScriptsDir) {
|
|
84803
84847
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -84809,7 +84853,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84809
84853
|
if (!file2.endsWith(".js")) continue;
|
|
84810
84854
|
if (!targetFileNames.has(file2)) continue;
|
|
84811
84855
|
try {
|
|
84812
|
-
const content = fs29.readFileSync(
|
|
84856
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
84813
84857
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
84814
84858
|
lines.push("```javascript");
|
|
84815
84859
|
lines.push(content);
|
|
@@ -84825,7 +84869,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84825
84869
|
lines.push("");
|
|
84826
84870
|
for (const file2 of refFiles) {
|
|
84827
84871
|
try {
|
|
84828
|
-
const content = fs29.readFileSync(
|
|
84872
|
+
const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
84829
84873
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
84830
84874
|
lines.push("```javascript");
|
|
84831
84875
|
lines.push(content);
|
|
@@ -84858,10 +84902,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84858
84902
|
lines.push("");
|
|
84859
84903
|
}
|
|
84860
84904
|
}
|
|
84861
|
-
const docsDir =
|
|
84905
|
+
const docsDir = path40.join(providerDir, "../../docs");
|
|
84862
84906
|
const loadGuide = (name) => {
|
|
84863
84907
|
try {
|
|
84864
|
-
const p =
|
|
84908
|
+
const p = path40.join(docsDir, name);
|
|
84865
84909
|
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
84866
84910
|
} catch {
|
|
84867
84911
|
}
|
|
@@ -85122,6 +85166,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85122
85166
|
init_pty_transport();
|
|
85123
85167
|
var import_session_host_core9 = require_dist();
|
|
85124
85168
|
init_logger();
|
|
85169
|
+
init_resolve_executable();
|
|
85125
85170
|
function shouldResumeAttachedSession(record2) {
|
|
85126
85171
|
if (!record2) return false;
|
|
85127
85172
|
if (record2.lifecycle === "interrupted") return true;
|
|
@@ -85501,7 +85546,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85501
85546
|
spawn(command, args, spawnOptions) {
|
|
85502
85547
|
return new SessionHostRuntimeTransport({
|
|
85503
85548
|
...this.options,
|
|
85504
|
-
command,
|
|
85549
|
+
command: resolveWin32Executable(command),
|
|
85505
85550
|
args,
|
|
85506
85551
|
spawnOptions
|
|
85507
85552
|
});
|
|
@@ -85820,7 +85865,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85820
85865
|
if (raw === "0" || raw === "false" || raw === "no") return false;
|
|
85821
85866
|
return raw === "1" || raw === "true" || raw === "yes";
|
|
85822
85867
|
}
|
|
85823
|
-
var
|
|
85868
|
+
var import_child_process11 = require("child_process");
|
|
85824
85869
|
var import_util32 = require("util");
|
|
85825
85870
|
var EXTENSION_CATALOG = [
|
|
85826
85871
|
// AI Agent extensions
|
|
@@ -85908,7 +85953,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85908
85953
|
apiKeyName: "OpenAI/Anthropic API key"
|
|
85909
85954
|
}
|
|
85910
85955
|
];
|
|
85911
|
-
var execAsync4 = (0, import_util32.promisify)(
|
|
85956
|
+
var execAsync4 = (0, import_util32.promisify)(import_child_process11.exec);
|
|
85912
85957
|
async function isExtensionInstalled(ide, marketplaceId) {
|
|
85913
85958
|
if (!ide.cliCommand) return false;
|
|
85914
85959
|
try {
|
|
@@ -85952,7 +85997,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85952
85997
|
fs30.writeFileSync(vsixPath, buffer);
|
|
85953
85998
|
return new Promise((resolve24) => {
|
|
85954
85999
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
85955
|
-
(0,
|
|
86000
|
+
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
85956
86001
|
resolve24({
|
|
85957
86002
|
extensionId: extension.id,
|
|
85958
86003
|
marketplaceId: extension.marketplaceId,
|
|
@@ -85968,7 +86013,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85968
86013
|
}
|
|
85969
86014
|
return new Promise((resolve24) => {
|
|
85970
86015
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
85971
|
-
(0,
|
|
86016
|
+
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
85972
86017
|
if (error48) {
|
|
85973
86018
|
resolve24({
|
|
85974
86019
|
extensionId: extension.id,
|
|
@@ -86005,7 +86050,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
86005
86050
|
if (!ide.cliCommand) return false;
|
|
86006
86051
|
try {
|
|
86007
86052
|
const args = workspacePath ? `"${workspacePath}"` : "";
|
|
86008
|
-
(0,
|
|
86053
|
+
(0, import_child_process11.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
|
|
86009
86054
|
return true;
|
|
86010
86055
|
} catch {
|
|
86011
86056
|
return false;
|