@adhdev/daemon-standalone 0.9.82-rc.164 → 0.9.82-rc.166
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 +1352 -781
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-BA2Cx8ay.js +99 -0
- package/public/assets/index-CftkZOqj.css +1 -0
- package/public/assets/index-D8yS9J4o.js +99 -0
- package/public/index.html +2 -2
package/dist/index.js
CHANGED
|
@@ -34851,8 +34851,8 @@ var require_dist3 = __commonJS({
|
|
|
34851
34851
|
return String(value).replace(/\r\n/g, "\n");
|
|
34852
34852
|
}
|
|
34853
34853
|
function isPathInside(parent, child) {
|
|
34854
|
-
const
|
|
34855
|
-
return
|
|
34854
|
+
const relative5 = path5.relative(path5.resolve(parent), path5.resolve(child));
|
|
34855
|
+
return relative5 === "" || !relative5.startsWith("..") && !path5.isAbsolute(relative5);
|
|
34856
34856
|
}
|
|
34857
34857
|
async function validateWorkspace(workspace) {
|
|
34858
34858
|
if (typeof workspace !== "string" || workspace.length === 0 || workspace.includes("\0")) {
|
|
@@ -35529,10 +35529,10 @@ ${error48.message || ""}`;
|
|
|
35529
35529
|
return (0, import_path22.join)(getConfigDir(), "meshes.json");
|
|
35530
35530
|
}
|
|
35531
35531
|
function loadMeshConfig() {
|
|
35532
|
-
const
|
|
35533
|
-
if (!(0, import_fs2.existsSync)(
|
|
35532
|
+
const path40 = getMeshConfigPath();
|
|
35533
|
+
if (!(0, import_fs2.existsSync)(path40)) return { meshes: [] };
|
|
35534
35534
|
try {
|
|
35535
|
-
const raw = JSON.parse((0, import_fs2.readFileSync)(
|
|
35535
|
+
const raw = JSON.parse((0, import_fs2.readFileSync)(path40, "utf-8"));
|
|
35536
35536
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
35537
35537
|
return raw;
|
|
35538
35538
|
} catch {
|
|
@@ -35540,16 +35540,16 @@ ${error48.message || ""}`;
|
|
|
35540
35540
|
}
|
|
35541
35541
|
}
|
|
35542
35542
|
function saveMeshConfig(config2) {
|
|
35543
|
-
const
|
|
35544
|
-
(0, import_fs2.writeFileSync)(
|
|
35543
|
+
const path40 = getMeshConfigPath();
|
|
35544
|
+
(0, import_fs2.writeFileSync)(path40, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
35545
35545
|
}
|
|
35546
35546
|
function normalizeRepoIdentity(remoteUrl) {
|
|
35547
35547
|
let identity = remoteUrl.trim();
|
|
35548
35548
|
if (identity.startsWith("http://") || identity.startsWith("https://")) {
|
|
35549
35549
|
try {
|
|
35550
35550
|
const url2 = new URL(identity);
|
|
35551
|
-
const
|
|
35552
|
-
return `${url2.hostname}/${
|
|
35551
|
+
const path40 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
35552
|
+
return `${url2.hostname}/${path40}`;
|
|
35553
35553
|
} catch {
|
|
35554
35554
|
}
|
|
35555
35555
|
}
|
|
@@ -36498,8 +36498,8 @@ Follow these recovery rules:
|
|
|
36498
36498
|
}
|
|
36499
36499
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
36500
36500
|
if (mcpConfig.mode === "auto_import") {
|
|
36501
|
-
const
|
|
36502
|
-
if (!
|
|
36501
|
+
const path40 = mcpConfig.path?.trim();
|
|
36502
|
+
if (!path40) {
|
|
36503
36503
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
36504
36504
|
}
|
|
36505
36505
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -36517,7 +36517,7 @@ Follow these recovery rules:
|
|
|
36517
36517
|
return {
|
|
36518
36518
|
kind: "auto_import",
|
|
36519
36519
|
serverName,
|
|
36520
|
-
configPath: resolveMcpConfigPath(
|
|
36520
|
+
configPath: resolveMcpConfigPath(path40, workspace),
|
|
36521
36521
|
configFormat: mcpConfig.format,
|
|
36522
36522
|
mcpServer
|
|
36523
36523
|
};
|
|
@@ -36674,8 +36674,8 @@ ${rendered}`, "utf-8");
|
|
|
36674
36674
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
36675
36675
|
if (!remaining.trim()) {
|
|
36676
36676
|
try {
|
|
36677
|
-
const
|
|
36678
|
-
|
|
36677
|
+
const fs28 = require("fs");
|
|
36678
|
+
fs28.unlinkSync(filePath);
|
|
36679
36679
|
} catch {
|
|
36680
36680
|
}
|
|
36681
36681
|
} else {
|
|
@@ -36818,10 +36818,10 @@ ${rendered}`, "utf-8");
|
|
|
36818
36818
|
}
|
|
36819
36819
|
}
|
|
36820
36820
|
function readArchivedCounts(meshId) {
|
|
36821
|
-
const
|
|
36822
|
-
if (!(0, import_fs6.existsSync)(
|
|
36821
|
+
const path40 = getArchivedCountsPath(meshId);
|
|
36822
|
+
if (!(0, import_fs6.existsSync)(path40)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
36823
36823
|
try {
|
|
36824
|
-
return JSON.parse((0, import_fs6.readFileSync)(
|
|
36824
|
+
return JSON.parse((0, import_fs6.readFileSync)(path40, "utf-8"));
|
|
36825
36825
|
} catch {
|
|
36826
36826
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
36827
36827
|
}
|
|
@@ -37493,10 +37493,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
37493
37493
|
this.migratedMeshIds.add(meshId);
|
|
37494
37494
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
37495
37495
|
if (count.count > 0) return;
|
|
37496
|
-
const
|
|
37497
|
-
if (!(0, import_fs7.existsSync)(
|
|
37496
|
+
const path40 = legacyQueuePath(meshId);
|
|
37497
|
+
if (!(0, import_fs7.existsSync)(path40)) return;
|
|
37498
37498
|
try {
|
|
37499
|
-
const entries = JSON.parse((0, import_fs7.readFileSync)(
|
|
37499
|
+
const entries = JSON.parse((0, import_fs7.readFileSync)(path40, "utf-8"));
|
|
37500
37500
|
if (!Array.isArray(entries)) return;
|
|
37501
37501
|
const insert = this.db.prepare(`
|
|
37502
37502
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -38207,10 +38207,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38207
38207
|
if (!meshId) return [];
|
|
38208
38208
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
38209
38209
|
const events = [];
|
|
38210
|
-
for (const
|
|
38211
|
-
if (!(0, import_fs9.existsSync)(
|
|
38210
|
+
for (const path40 of paths) {
|
|
38211
|
+
if (!(0, import_fs9.existsSync)(path40)) continue;
|
|
38212
38212
|
try {
|
|
38213
|
-
const raw = (0, import_fs9.readFileSync)(
|
|
38213
|
+
const raw = (0, import_fs9.readFileSync)(path40, "utf-8");
|
|
38214
38214
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
38215
38215
|
try {
|
|
38216
38216
|
return [JSON.parse(line)];
|
|
@@ -38218,7 +38218,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38218
38218
|
return [];
|
|
38219
38219
|
}
|
|
38220
38220
|
});
|
|
38221
|
-
const filtered = coordinatorDaemonId &&
|
|
38221
|
+
const filtered = coordinatorDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
|
|
38222
38222
|
events.push(...filtered);
|
|
38223
38223
|
} catch {
|
|
38224
38224
|
}
|
|
@@ -38287,13 +38287,13 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38287
38287
|
...backfilled
|
|
38288
38288
|
];
|
|
38289
38289
|
}
|
|
38290
|
-
function trimPendingEventsIfNeeded(
|
|
38290
|
+
function trimPendingEventsIfNeeded(path40) {
|
|
38291
38291
|
try {
|
|
38292
|
-
if (!(0, import_fs9.existsSync)(
|
|
38293
|
-
if ((0, import_fs9.statSync)(
|
|
38294
|
-
const lines = (0, import_fs9.readFileSync)(
|
|
38292
|
+
if (!(0, import_fs9.existsSync)(path40)) return;
|
|
38293
|
+
if ((0, import_fs9.statSync)(path40).size <= MAX_PENDING_EVENTS_BYTES) return;
|
|
38294
|
+
const lines = (0, import_fs9.readFileSync)(path40, "utf-8").split("\n").filter(Boolean);
|
|
38295
38295
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
38296
|
-
(0, import_fs9.writeFileSync)(
|
|
38296
|
+
(0, import_fs9.writeFileSync)(path40, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
38297
38297
|
} catch {
|
|
38298
38298
|
}
|
|
38299
38299
|
}
|
|
@@ -38307,19 +38307,19 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38307
38307
|
LOG2.info("MeshEvents", `Suppressed duplicate pending ${event.event} for mesh ${event.meshId}`);
|
|
38308
38308
|
return true;
|
|
38309
38309
|
}
|
|
38310
|
-
const
|
|
38311
|
-
trimPendingEventsIfNeeded(
|
|
38312
|
-
(0, import_fs9.appendFileSync)(
|
|
38310
|
+
const path40 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
38311
|
+
trimPendingEventsIfNeeded(path40);
|
|
38312
|
+
(0, import_fs9.appendFileSync)(path40, JSON.stringify(event) + "\n", "utf-8");
|
|
38313
38313
|
return true;
|
|
38314
38314
|
} catch (e) {
|
|
38315
38315
|
LOG2.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
38316
38316
|
return false;
|
|
38317
38317
|
}
|
|
38318
38318
|
}
|
|
38319
|
-
function atomicDrainFile(
|
|
38320
|
-
const tmpPath = `${
|
|
38319
|
+
function atomicDrainFile(path40) {
|
|
38320
|
+
const tmpPath = `${path40}.draining`;
|
|
38321
38321
|
try {
|
|
38322
|
-
(0, import_fs9.renameSync)(
|
|
38322
|
+
(0, import_fs9.renameSync)(path40, tmpPath);
|
|
38323
38323
|
} catch {
|
|
38324
38324
|
return null;
|
|
38325
38325
|
}
|
|
@@ -38342,8 +38342,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38342
38342
|
if (!meshId) return [];
|
|
38343
38343
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
38344
38344
|
const all = [];
|
|
38345
|
-
for (const
|
|
38346
|
-
const content = atomicDrainFile(
|
|
38345
|
+
for (const path40 of paths) {
|
|
38346
|
+
const content = atomicDrainFile(path40);
|
|
38347
38347
|
if (!content) continue;
|
|
38348
38348
|
const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
|
|
38349
38349
|
try {
|
|
@@ -38352,7 +38352,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38352
38352
|
return [];
|
|
38353
38353
|
}
|
|
38354
38354
|
});
|
|
38355
|
-
const filtered = coordinatorDaemonId &&
|
|
38355
|
+
const filtered = coordinatorDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
|
|
38356
38356
|
all.push(...filtered);
|
|
38357
38357
|
}
|
|
38358
38358
|
if (all.length === 0) return [];
|
|
@@ -38365,9 +38365,9 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
38365
38365
|
function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
38366
38366
|
if (!meshId) return;
|
|
38367
38367
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
38368
|
-
for (const
|
|
38369
|
-
if ((0, import_fs9.existsSync)(
|
|
38370
|
-
(0, import_fs9.unlinkSync)(
|
|
38368
|
+
for (const path40 of paths) {
|
|
38369
|
+
if ((0, import_fs9.existsSync)(path40)) try {
|
|
38370
|
+
(0, import_fs9.unlinkSync)(path40);
|
|
38371
38371
|
} catch {
|
|
38372
38372
|
}
|
|
38373
38373
|
}
|
|
@@ -39508,6 +39508,54 @@ Next step: ${nextStep}`;
|
|
|
39508
39508
|
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
39509
39509
|
}
|
|
39510
39510
|
});
|
|
39511
|
+
var provider_trust_exports = {};
|
|
39512
|
+
__export2(provider_trust_exports, {
|
|
39513
|
+
classifyTrust: () => classifyTrust,
|
|
39514
|
+
describeTrust: () => describeTrust,
|
|
39515
|
+
inspectManifestShape: () => inspectManifestShape,
|
|
39516
|
+
requiresConfirmation: () => requiresConfirmation
|
|
39517
|
+
});
|
|
39518
|
+
function inspectManifestShape(manifest) {
|
|
39519
|
+
const hasTui = !!manifest.tui && typeof manifest.tui === "object" && Object.keys(manifest.tui).length > 0;
|
|
39520
|
+
const hasOverrides = !!manifest.overrides && typeof manifest.overrides === "object" && !Array.isArray(manifest.overrides) && Object.keys(manifest.overrides).length > 0;
|
|
39521
|
+
const compat = Array.isArray(manifest.compatibility) ? manifest.compatibility : [];
|
|
39522
|
+
const compatHasScriptDir = compat.some((entry) => typeof entry?.scriptDir === "string");
|
|
39523
|
+
const hasScriptDir = compatHasScriptDir || typeof manifest.defaultScriptDir === "string";
|
|
39524
|
+
return { hasTui, hasOverrides, hasScriptDir };
|
|
39525
|
+
}
|
|
39526
|
+
function classifyTrust(layer, shape) {
|
|
39527
|
+
const isSpecOnly = !shape.hasTui && !shape.hasOverrides && !shape.hasScriptDir;
|
|
39528
|
+
switch (layer) {
|
|
39529
|
+
case "user":
|
|
39530
|
+
return "user-custom";
|
|
39531
|
+
case "upstream":
|
|
39532
|
+
return isSpecOnly ? "trusted" : "trusted-with-scripts";
|
|
39533
|
+
case "external":
|
|
39534
|
+
return isSpecOnly ? "external-safe" : "external-untrusted";
|
|
39535
|
+
}
|
|
39536
|
+
}
|
|
39537
|
+
function requiresConfirmation(trust) {
|
|
39538
|
+
return trust === "external-untrusted";
|
|
39539
|
+
}
|
|
39540
|
+
function describeTrust(trust) {
|
|
39541
|
+
switch (trust) {
|
|
39542
|
+
case "user-custom":
|
|
39543
|
+
return "Hand-authored in ~/.adhdev/providers/. Runs your own code.";
|
|
39544
|
+
case "trusted":
|
|
39545
|
+
return "Official, declarative-only manifest from the ADHDev registry.";
|
|
39546
|
+
case "trusted-with-scripts":
|
|
39547
|
+
return "Official manifest from the ADHDev registry. Ships JavaScript hooks executed by the daemon.";
|
|
39548
|
+
case "external-safe":
|
|
39549
|
+
return "Manifest from a 3rd-party git source you added. Declarative-only \u2014 the daemon never runs JS from this source.";
|
|
39550
|
+
case "external-untrusted":
|
|
39551
|
+
return "Manifest from a 3rd-party git source you added. Ships JavaScript that the daemon will execute. Treat as untrusted code \u2014 review the source before enabling.";
|
|
39552
|
+
}
|
|
39553
|
+
}
|
|
39554
|
+
var init_provider_trust = __esm2({
|
|
39555
|
+
"src/providers/provider-trust.ts"() {
|
|
39556
|
+
"use strict";
|
|
39557
|
+
}
|
|
39558
|
+
});
|
|
39511
39559
|
var provider_schema_default;
|
|
39512
39560
|
var init_provider_schema = __esm2({
|
|
39513
39561
|
"src/providers/sdk/v1/schemas/cli/provider.schema.json"() {
|
|
@@ -39750,14 +39798,15 @@ Next step: ${nextStep}`;
|
|
|
39750
39798
|
minItems: 1,
|
|
39751
39799
|
items: {
|
|
39752
39800
|
type: "object",
|
|
39753
|
-
required: ["
|
|
39801
|
+
required: ["ideVersion"],
|
|
39754
39802
|
additionalProperties: false,
|
|
39755
39803
|
properties: {
|
|
39756
39804
|
ideVersion: { type: "string", description: "SemVer range." },
|
|
39757
|
-
scriptDir: { type: "string", pattern: "^scripts/[^/]+$" }
|
|
39805
|
+
scriptDir: { type: "string", pattern: "^scripts/[^/]+$" },
|
|
39806
|
+
spec: { type: "string", pattern: "^specs/[^/]+\\.json$", description: "Path to declarative spec.json driving SpecCliAdapter for this version range." }
|
|
39758
39807
|
}
|
|
39759
39808
|
},
|
|
39760
|
-
description: "Maps installed agent versions to script subdirectories."
|
|
39809
|
+
description: "Maps installed agent versions to script subdirectories and/or declarative specs."
|
|
39761
39810
|
},
|
|
39762
39811
|
defaultScriptDir: {
|
|
39763
39812
|
type: "string",
|
|
@@ -40007,7 +40056,7 @@ Next step: ${nextStep}`;
|
|
|
40007
40056
|
return _cliValidator;
|
|
40008
40057
|
}
|
|
40009
40058
|
function formatIssue(err) {
|
|
40010
|
-
const
|
|
40059
|
+
const path40 = err.instancePath || "";
|
|
40011
40060
|
const params = err.params;
|
|
40012
40061
|
let message = err.message || "validation failed";
|
|
40013
40062
|
let allowed;
|
|
@@ -40025,7 +40074,7 @@ Next step: ${nextStep}`;
|
|
|
40025
40074
|
} else if (err.keyword === "type") {
|
|
40026
40075
|
message = `must be ${params.type}`;
|
|
40027
40076
|
}
|
|
40028
|
-
return { path:
|
|
40077
|
+
return { path: path40, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
40029
40078
|
}
|
|
40030
40079
|
function validateCliProviderManifest(manifest) {
|
|
40031
40080
|
const validator = getCliValidator();
|
|
@@ -40054,6 +40103,158 @@ Next step: ${nextStep}`;
|
|
|
40054
40103
|
_cliValidator = null;
|
|
40055
40104
|
}
|
|
40056
40105
|
});
|
|
40106
|
+
var external_sources_exports = {};
|
|
40107
|
+
__export2(external_sources_exports, {
|
|
40108
|
+
activeFilePath: () => activeFilePath,
|
|
40109
|
+
deriveSourceName: () => deriveSourceName,
|
|
40110
|
+
externalRoot: () => externalRoot,
|
|
40111
|
+
inventoryExternalSources: () => inventoryExternalSources,
|
|
40112
|
+
loadExternalSources: () => loadExternalSources,
|
|
40113
|
+
loadProvidersActive: () => loadProvidersActive,
|
|
40114
|
+
resolveActiveSource: () => resolveActiveSource,
|
|
40115
|
+
saveExternalSources: () => saveExternalSources,
|
|
40116
|
+
saveProvidersActive: () => saveProvidersActive,
|
|
40117
|
+
sourcesFilePath: () => sourcesFilePath,
|
|
40118
|
+
sourcesProviding: () => sourcesProviding
|
|
40119
|
+
});
|
|
40120
|
+
function adhdevDir() {
|
|
40121
|
+
return path15.join(os10.homedir(), ".adhdev");
|
|
40122
|
+
}
|
|
40123
|
+
function externalRoot() {
|
|
40124
|
+
return path15.join(adhdevDir(), "external");
|
|
40125
|
+
}
|
|
40126
|
+
function sourcesFilePath() {
|
|
40127
|
+
return path15.join(adhdevDir(), SOURCES_FILENAME);
|
|
40128
|
+
}
|
|
40129
|
+
function activeFilePath() {
|
|
40130
|
+
return path15.join(adhdevDir(), ACTIVE_FILENAME);
|
|
40131
|
+
}
|
|
40132
|
+
function ensureAdhdevDir() {
|
|
40133
|
+
const d = adhdevDir();
|
|
40134
|
+
if (!fs8.existsSync(d)) fs8.mkdirSync(d, { recursive: true });
|
|
40135
|
+
}
|
|
40136
|
+
function loadExternalSources() {
|
|
40137
|
+
const p = sourcesFilePath();
|
|
40138
|
+
if (!fs8.existsSync(p)) return { schema: 1, sources: [] };
|
|
40139
|
+
try {
|
|
40140
|
+
const raw = JSON.parse(fs8.readFileSync(p, "utf-8"));
|
|
40141
|
+
if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
|
|
40142
|
+
const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
|
|
40143
|
+
return { schema: 1, sources };
|
|
40144
|
+
} catch {
|
|
40145
|
+
return { schema: 1, sources: [] };
|
|
40146
|
+
}
|
|
40147
|
+
}
|
|
40148
|
+
function saveExternalSources(file2) {
|
|
40149
|
+
ensureAdhdevDir();
|
|
40150
|
+
const tmp = sourcesFilePath() + ".tmp";
|
|
40151
|
+
fs8.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
40152
|
+
fs8.renameSync(tmp, sourcesFilePath());
|
|
40153
|
+
}
|
|
40154
|
+
function loadProvidersActive() {
|
|
40155
|
+
const p = activeFilePath();
|
|
40156
|
+
if (!fs8.existsSync(p)) return { schema: 1, active: {} };
|
|
40157
|
+
try {
|
|
40158
|
+
const raw = JSON.parse(fs8.readFileSync(p, "utf-8"));
|
|
40159
|
+
if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
|
|
40160
|
+
const active = raw.active && typeof raw.active === "object" ? raw.active : {};
|
|
40161
|
+
return { schema: 1, active };
|
|
40162
|
+
} catch {
|
|
40163
|
+
return { schema: 1, active: {} };
|
|
40164
|
+
}
|
|
40165
|
+
}
|
|
40166
|
+
function saveProvidersActive(file2) {
|
|
40167
|
+
ensureAdhdevDir();
|
|
40168
|
+
const tmp = activeFilePath() + ".tmp";
|
|
40169
|
+
fs8.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
40170
|
+
fs8.renameSync(tmp, activeFilePath());
|
|
40171
|
+
}
|
|
40172
|
+
function isValidSource(x) {
|
|
40173
|
+
if (!x || typeof x !== "object") return false;
|
|
40174
|
+
const s = x;
|
|
40175
|
+
return typeof s.name === "string" && s.name.length > 0 && typeof s.url === "string" && s.url.length > 0 && typeof s.ref === "string" && s.ref.length > 0 && typeof s.addedAt === "string";
|
|
40176
|
+
}
|
|
40177
|
+
function deriveSourceName(url2) {
|
|
40178
|
+
const m = url2.match(/[/:]([^/:]+)\/([^/]+?)(?:\.git)?$/);
|
|
40179
|
+
if (!m) return "@source";
|
|
40180
|
+
const owner = m[1].toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
40181
|
+
const repo = m[2].toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
40182
|
+
return `@${owner}-${repo}`;
|
|
40183
|
+
}
|
|
40184
|
+
function inventoryExternalSources() {
|
|
40185
|
+
const root = externalRoot();
|
|
40186
|
+
if (!fs8.existsSync(root)) return [];
|
|
40187
|
+
const out = [];
|
|
40188
|
+
let entries;
|
|
40189
|
+
try {
|
|
40190
|
+
entries = fs8.readdirSync(root, { withFileTypes: true });
|
|
40191
|
+
} catch {
|
|
40192
|
+
return [];
|
|
40193
|
+
}
|
|
40194
|
+
for (const sourceEntry of entries) {
|
|
40195
|
+
if (!sourceEntry.isDirectory()) continue;
|
|
40196
|
+
const sourceName = sourceEntry.name;
|
|
40197
|
+
const sourceDir = path15.join(root, sourceName);
|
|
40198
|
+
const providers = {};
|
|
40199
|
+
let categoryEntries;
|
|
40200
|
+
try {
|
|
40201
|
+
categoryEntries = fs8.readdirSync(sourceDir, { withFileTypes: true });
|
|
40202
|
+
} catch {
|
|
40203
|
+
continue;
|
|
40204
|
+
}
|
|
40205
|
+
for (const categoryEntry of categoryEntries) {
|
|
40206
|
+
if (!categoryEntry.isDirectory()) continue;
|
|
40207
|
+
const category = categoryEntry.name;
|
|
40208
|
+
const categoryDir = path15.join(sourceDir, category);
|
|
40209
|
+
let typeEntries;
|
|
40210
|
+
try {
|
|
40211
|
+
typeEntries = fs8.readdirSync(categoryDir, { withFileTypes: true });
|
|
40212
|
+
} catch {
|
|
40213
|
+
continue;
|
|
40214
|
+
}
|
|
40215
|
+
const types = [];
|
|
40216
|
+
for (const typeEntry of typeEntries) {
|
|
40217
|
+
if (!typeEntry.isDirectory()) continue;
|
|
40218
|
+
const typeDir = path15.join(categoryDir, typeEntry.name);
|
|
40219
|
+
const hasV1 = fs8.existsSync(path15.join(typeDir, "provider.v1.json"));
|
|
40220
|
+
const hasV0 = fs8.existsSync(path15.join(typeDir, "provider.json"));
|
|
40221
|
+
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
40222
|
+
}
|
|
40223
|
+
if (types.length > 0) providers[category] = types;
|
|
40224
|
+
}
|
|
40225
|
+
out.push({ sourceName, providers });
|
|
40226
|
+
}
|
|
40227
|
+
return out;
|
|
40228
|
+
}
|
|
40229
|
+
function sourcesProviding(category, type) {
|
|
40230
|
+
const inventory = inventoryExternalSources();
|
|
40231
|
+
return inventory.filter((s) => (s.providers[category] || []).includes(type)).map((s) => s.sourceName);
|
|
40232
|
+
}
|
|
40233
|
+
function resolveActiveSource(category, type, activeFile) {
|
|
40234
|
+
const candidates = sourcesProviding(category, type);
|
|
40235
|
+
if (candidates.length === 0) return { source: null, ambiguous: false, candidates };
|
|
40236
|
+
if (candidates.length === 1) return { source: candidates[0], ambiguous: false, candidates };
|
|
40237
|
+
const explicit = (activeFile ?? loadProvidersActive()).active[type];
|
|
40238
|
+
if (explicit && candidates.includes(explicit)) {
|
|
40239
|
+
return { source: explicit, ambiguous: false, candidates };
|
|
40240
|
+
}
|
|
40241
|
+
return { source: candidates[0], ambiguous: true, candidates };
|
|
40242
|
+
}
|
|
40243
|
+
var fs8;
|
|
40244
|
+
var os10;
|
|
40245
|
+
var path15;
|
|
40246
|
+
var SOURCES_FILENAME;
|
|
40247
|
+
var ACTIVE_FILENAME;
|
|
40248
|
+
var init_external_sources = __esm2({
|
|
40249
|
+
"src/providers/external-sources.ts"() {
|
|
40250
|
+
"use strict";
|
|
40251
|
+
fs8 = __toESM2(require("fs"));
|
|
40252
|
+
os10 = __toESM2(require("os"));
|
|
40253
|
+
path15 = __toESM2(require("path"));
|
|
40254
|
+
SOURCES_FILENAME = "providers-sources.json";
|
|
40255
|
+
ACTIVE_FILENAME = "providers-active.json";
|
|
40256
|
+
}
|
|
40257
|
+
});
|
|
40057
40258
|
function isModuleNotFoundError(error48, ref) {
|
|
40058
40259
|
if (!(error48 instanceof Error)) return false;
|
|
40059
40260
|
const message = error48.message || "";
|
|
@@ -40346,14 +40547,14 @@ Next step: ${nextStep}`;
|
|
|
40346
40547
|
}
|
|
40347
40548
|
return cachedPty;
|
|
40348
40549
|
}
|
|
40349
|
-
var
|
|
40550
|
+
var os11;
|
|
40350
40551
|
var cachedPty;
|
|
40351
40552
|
var NodePtyRuntimeTransport;
|
|
40352
40553
|
var NodePtyTransportFactory;
|
|
40353
40554
|
var init_pty_transport = __esm2({
|
|
40354
40555
|
"src/cli-adapters/pty-transport.ts"() {
|
|
40355
40556
|
"use strict";
|
|
40356
|
-
|
|
40557
|
+
os11 = __toESM2(require("os"));
|
|
40357
40558
|
init_spawn_env();
|
|
40358
40559
|
NodePtyRuntimeTransport = class {
|
|
40359
40560
|
constructor(handle) {
|
|
@@ -40390,11 +40591,11 @@ Next step: ${nextStep}`;
|
|
|
40390
40591
|
let cwd = options.cwd;
|
|
40391
40592
|
if (cwd) {
|
|
40392
40593
|
try {
|
|
40393
|
-
const
|
|
40394
|
-
const stat2 =
|
|
40395
|
-
if (!stat2.isDirectory()) cwd =
|
|
40594
|
+
const fs28 = require("fs");
|
|
40595
|
+
const stat2 = fs28.statSync(cwd);
|
|
40596
|
+
if (!stat2.isDirectory()) cwd = os11.homedir();
|
|
40396
40597
|
} catch {
|
|
40397
|
-
cwd =
|
|
40598
|
+
cwd = os11.homedir();
|
|
40398
40599
|
}
|
|
40399
40600
|
}
|
|
40400
40601
|
const handle = pty.spawn(command, args, {
|
|
@@ -40484,21 +40685,21 @@ Next step: ${nextStep}`;
|
|
|
40484
40685
|
function findBinary(name) {
|
|
40485
40686
|
const trimmed = String(name || "").trim();
|
|
40486
40687
|
if (!trimmed) return trimmed;
|
|
40487
|
-
const expanded = trimmed.startsWith("~") ?
|
|
40488
|
-
if (
|
|
40489
|
-
return
|
|
40688
|
+
const expanded = trimmed.startsWith("~") ? path16.join(os12.homedir(), trimmed.slice(1)) : trimmed;
|
|
40689
|
+
if (path16.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
40690
|
+
return path16.isAbsolute(expanded) ? expanded : path16.resolve(expanded);
|
|
40490
40691
|
}
|
|
40491
|
-
const isWin =
|
|
40492
|
-
const paths = (process.env.PATH || "").split(
|
|
40692
|
+
const isWin = os12.platform() === "win32";
|
|
40693
|
+
const paths = (process.env.PATH || "").split(path16.delimiter);
|
|
40493
40694
|
const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
40494
40695
|
for (const p of paths) {
|
|
40495
40696
|
if (!p) continue;
|
|
40496
40697
|
for (const ext of exes) {
|
|
40497
|
-
const fullPath =
|
|
40698
|
+
const fullPath = path16.join(p, trimmed + ext);
|
|
40498
40699
|
try {
|
|
40499
|
-
const
|
|
40500
|
-
if (
|
|
40501
|
-
const stat2 =
|
|
40700
|
+
const fs28 = require("fs");
|
|
40701
|
+
if (fs28.existsSync(fullPath)) {
|
|
40702
|
+
const stat2 = fs28.statSync(fullPath);
|
|
40502
40703
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
40503
40704
|
return fullPath;
|
|
40504
40705
|
}
|
|
@@ -40510,14 +40711,14 @@ Next step: ${nextStep}`;
|
|
|
40510
40711
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
40511
40712
|
}
|
|
40512
40713
|
function isScriptBinary(binaryPath) {
|
|
40513
|
-
if (!
|
|
40714
|
+
if (!path16.isAbsolute(binaryPath)) return false;
|
|
40514
40715
|
try {
|
|
40515
|
-
const
|
|
40516
|
-
const resolved =
|
|
40716
|
+
const fs28 = require("fs");
|
|
40717
|
+
const resolved = fs28.realpathSync(binaryPath);
|
|
40517
40718
|
const head = Buffer.alloc(8);
|
|
40518
|
-
const fd =
|
|
40519
|
-
|
|
40520
|
-
|
|
40719
|
+
const fd = fs28.openSync(resolved, "r");
|
|
40720
|
+
fs28.readSync(fd, head, 0, 8, 0);
|
|
40721
|
+
fs28.closeSync(fd);
|
|
40521
40722
|
let i = 0;
|
|
40522
40723
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
40523
40724
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -40526,14 +40727,14 @@ Next step: ${nextStep}`;
|
|
|
40526
40727
|
}
|
|
40527
40728
|
}
|
|
40528
40729
|
function looksLikeMachOOrElf(filePath) {
|
|
40529
|
-
if (!
|
|
40730
|
+
if (!path16.isAbsolute(filePath)) return false;
|
|
40530
40731
|
try {
|
|
40531
|
-
const
|
|
40532
|
-
const resolved =
|
|
40732
|
+
const fs28 = require("fs");
|
|
40733
|
+
const resolved = fs28.realpathSync(filePath);
|
|
40533
40734
|
const buf = Buffer.alloc(8);
|
|
40534
|
-
const fd =
|
|
40535
|
-
|
|
40536
|
-
|
|
40735
|
+
const fd = fs28.openSync(resolved, "r");
|
|
40736
|
+
fs28.readSync(fd, buf, 0, 8, 0);
|
|
40737
|
+
fs28.closeSync(fd);
|
|
40537
40738
|
let i = 0;
|
|
40538
40739
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
40539
40740
|
const b = buf.subarray(i);
|
|
@@ -40549,7 +40750,7 @@ Next step: ${nextStep}`;
|
|
|
40549
40750
|
}
|
|
40550
40751
|
function shSingleQuote(arg) {
|
|
40551
40752
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
40552
|
-
if (
|
|
40753
|
+
if (os12.platform() === "win32") {
|
|
40553
40754
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
40554
40755
|
}
|
|
40555
40756
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -40615,15 +40816,15 @@ Next step: ${nextStep}`;
|
|
|
40615
40816
|
}
|
|
40616
40817
|
};
|
|
40617
40818
|
}
|
|
40618
|
-
var
|
|
40619
|
-
var
|
|
40819
|
+
var os12;
|
|
40820
|
+
var path16;
|
|
40620
40821
|
var TerminalTranscriptAccumulator;
|
|
40621
40822
|
var buildCliSpawnEnv;
|
|
40622
40823
|
var init_provider_cli_shared = __esm2({
|
|
40623
40824
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
40624
40825
|
"use strict";
|
|
40625
|
-
|
|
40626
|
-
|
|
40826
|
+
os12 = __toESM2(require("os"));
|
|
40827
|
+
path16 = __toESM2(require("path"));
|
|
40627
40828
|
init_spawn_env();
|
|
40628
40829
|
TerminalTranscriptAccumulator = class {
|
|
40629
40830
|
lines = [[]];
|
|
@@ -42505,15 +42706,15 @@ ${cont}` : cont;
|
|
|
42505
42706
|
const { spawn: spawnConfig } = provider;
|
|
42506
42707
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
42507
42708
|
const binaryPath = findBinary(configuredCommand);
|
|
42508
|
-
const isWin =
|
|
42709
|
+
const isWin = os13.platform() === "win32";
|
|
42509
42710
|
const allArgs = [...spawnConfig.args, ...extraArgs].map(
|
|
42510
42711
|
(arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
|
|
42511
42712
|
);
|
|
42512
42713
|
let shellCmd;
|
|
42513
42714
|
let shellArgs;
|
|
42514
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
42715
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
42515
42716
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
42516
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
42717
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
42517
42718
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
42518
42719
|
if (useShell) {
|
|
42519
42720
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -42589,14 +42790,14 @@ ${cont}` : cont;
|
|
|
42589
42790
|
}
|
|
42590
42791
|
return "";
|
|
42591
42792
|
}
|
|
42592
|
-
var
|
|
42593
|
-
var
|
|
42793
|
+
var os13;
|
|
42794
|
+
var path17;
|
|
42594
42795
|
var import_session_host_core22;
|
|
42595
42796
|
var init_provider_cli_runtime = __esm2({
|
|
42596
42797
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
42597
42798
|
"use strict";
|
|
42598
|
-
|
|
42599
|
-
|
|
42799
|
+
os13 = __toESM2(require("os"));
|
|
42800
|
+
path17 = __toESM2(require("path"));
|
|
42600
42801
|
import_session_host_core22 = require_dist2();
|
|
42601
42802
|
init_provider_cli_shared();
|
|
42602
42803
|
}
|
|
@@ -42615,12 +42816,12 @@ ${cont}` : cont;
|
|
|
42615
42816
|
if (current.length <= keepFromCurrent) return current + chunk;
|
|
42616
42817
|
return current.slice(-keepFromCurrent) + chunk;
|
|
42617
42818
|
}
|
|
42618
|
-
var
|
|
42819
|
+
var os14;
|
|
42619
42820
|
var ProviderCliAdapter;
|
|
42620
42821
|
var init_provider_cli_adapter = __esm2({
|
|
42621
42822
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
42622
42823
|
"use strict";
|
|
42623
|
-
|
|
42824
|
+
os14 = __toESM2(require("os"));
|
|
42624
42825
|
init_logger();
|
|
42625
42826
|
init_debug_config();
|
|
42626
42827
|
init_terminal_screen();
|
|
@@ -42641,7 +42842,7 @@ ${cont}` : cont;
|
|
|
42641
42842
|
this.transportFactory = transportFactory;
|
|
42642
42843
|
this.cliType = provider.type;
|
|
42643
42844
|
this.cliName = provider.name;
|
|
42644
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
42845
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
|
|
42645
42846
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
42646
42847
|
this.timeouts = resolvedConfig.timeouts;
|
|
42647
42848
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -44784,7 +44985,7 @@ ${lastSnapshot}`;
|
|
|
44784
44985
|
function loadSpec(sourcePath) {
|
|
44785
44986
|
let raw;
|
|
44786
44987
|
try {
|
|
44787
|
-
const text =
|
|
44988
|
+
const text = fs9.readFileSync(sourcePath, "utf8");
|
|
44788
44989
|
raw = JSON.parse(text);
|
|
44789
44990
|
} catch (err) {
|
|
44790
44991
|
return { ok: false, errors: [`Failed to read spec: ${err.message}`], sourcePath };
|
|
@@ -44860,18 +45061,18 @@ ${lastSnapshot}`;
|
|
|
44860
45061
|
}
|
|
44861
45062
|
}
|
|
44862
45063
|
function resolveSpecPath(providerDir) {
|
|
44863
|
-
return
|
|
45064
|
+
return path18.join(providerDir, "spec.json");
|
|
44864
45065
|
}
|
|
44865
|
-
var
|
|
44866
|
-
var
|
|
45066
|
+
var fs9;
|
|
45067
|
+
var path18;
|
|
44867
45068
|
var import_ajv;
|
|
44868
45069
|
var ajv;
|
|
44869
45070
|
var validate;
|
|
44870
45071
|
var init_loader = __esm2({
|
|
44871
45072
|
"src/providers/spec/loader.ts"() {
|
|
44872
45073
|
"use strict";
|
|
44873
|
-
|
|
44874
|
-
|
|
45074
|
+
fs9 = __toESM2(require("fs"));
|
|
45075
|
+
path18 = __toESM2(require("path"));
|
|
44875
45076
|
import_ajv = __toESM2(require_ajv());
|
|
44876
45077
|
init_schema_gen();
|
|
44877
45078
|
ajv = new import_ajv.default({ allErrors: true, strict: false });
|
|
@@ -45025,7 +45226,7 @@ ${lastSnapshot}`;
|
|
|
45025
45226
|
}
|
|
45026
45227
|
function canonicalize(p) {
|
|
45027
45228
|
try {
|
|
45028
|
-
const resolved =
|
|
45229
|
+
const resolved = path24.resolve(p);
|
|
45029
45230
|
try {
|
|
45030
45231
|
return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
|
|
45031
45232
|
} catch {
|
|
@@ -45045,7 +45246,7 @@ ${lastSnapshot}`;
|
|
|
45045
45246
|
}
|
|
45046
45247
|
for (const root of _gatedRoots) {
|
|
45047
45248
|
if (normalized === root.rootPath) return root;
|
|
45048
|
-
if (normalized.startsWith(root.rootPath +
|
|
45249
|
+
if (normalized.startsWith(root.rootPath + path24.sep)) return root;
|
|
45049
45250
|
}
|
|
45050
45251
|
return null;
|
|
45051
45252
|
}
|
|
@@ -45064,16 +45265,16 @@ ${lastSnapshot}`;
|
|
|
45064
45265
|
};
|
|
45065
45266
|
}
|
|
45066
45267
|
function gatedRequire(request, parent, isMain, gated, originalLoad) {
|
|
45067
|
-
if (request.startsWith("./") || request.startsWith("../") ||
|
|
45268
|
+
if (request.startsWith("./") || request.startsWith("../") || path24.isAbsolute(request)) {
|
|
45068
45269
|
let resolved;
|
|
45069
45270
|
try {
|
|
45070
|
-
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(
|
|
45271
|
+
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path24.join(gated.rootPath, "__entry__.js"));
|
|
45071
45272
|
resolved = callerRequire.resolve(request);
|
|
45072
45273
|
} catch {
|
|
45073
45274
|
return originalLoad.call(this, request, parent, isMain);
|
|
45074
45275
|
}
|
|
45075
45276
|
const resolvedCanon = canonicalize(resolved) || resolved;
|
|
45076
|
-
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath +
|
|
45277
|
+
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path24.sep))) {
|
|
45077
45278
|
denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
|
|
45078
45279
|
}
|
|
45079
45280
|
return originalLoad.call(this, request, parent, isMain);
|
|
@@ -45097,7 +45298,7 @@ ${lastSnapshot}`;
|
|
|
45097
45298
|
err.callerFilename = caller;
|
|
45098
45299
|
throw err;
|
|
45099
45300
|
}
|
|
45100
|
-
var
|
|
45301
|
+
var path24;
|
|
45101
45302
|
var import_node_module2;
|
|
45102
45303
|
var nodeFs;
|
|
45103
45304
|
var nodeChildProcess;
|
|
@@ -45118,7 +45319,7 @@ ${lastSnapshot}`;
|
|
|
45118
45319
|
var init_require_whitelist = __esm2({
|
|
45119
45320
|
"src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
|
|
45120
45321
|
"use strict";
|
|
45121
|
-
|
|
45322
|
+
path24 = __toESM2(require("path"));
|
|
45122
45323
|
import_node_module2 = require("module");
|
|
45123
45324
|
nodeFs = __toESM2(require("fs"));
|
|
45124
45325
|
nodeChildProcess = __toESM2(require("child_process"));
|
|
@@ -45226,7 +45427,7 @@ ${lastSnapshot}`;
|
|
|
45226
45427
|
} else {
|
|
45227
45428
|
let stat2 = null;
|
|
45228
45429
|
try {
|
|
45229
|
-
stat2 =
|
|
45430
|
+
stat2 = fs13.statSync(resolved);
|
|
45230
45431
|
} catch {
|
|
45231
45432
|
return null;
|
|
45232
45433
|
}
|
|
@@ -45245,7 +45446,7 @@ ${lastSnapshot}`;
|
|
|
45245
45446
|
const v = jsonPathGet(lines[0], src.session_id_path);
|
|
45246
45447
|
if (typeof v === "string" && v) providerSessionId = v;
|
|
45247
45448
|
} else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
|
|
45248
|
-
const m =
|
|
45449
|
+
const m = path25.basename(sourcePath).match(UUID_RE);
|
|
45249
45450
|
if (m) providerSessionId = m[1];
|
|
45250
45451
|
}
|
|
45251
45452
|
const requested = input.providerSessionId || "";
|
|
@@ -45270,7 +45471,7 @@ ${lastSnapshot}`;
|
|
|
45270
45471
|
function readJsonlLines(p) {
|
|
45271
45472
|
let text;
|
|
45272
45473
|
try {
|
|
45273
|
-
text =
|
|
45474
|
+
text = fs13.readFileSync(p, "utf8");
|
|
45274
45475
|
} catch {
|
|
45275
45476
|
return [];
|
|
45276
45477
|
}
|
|
@@ -45287,7 +45488,7 @@ ${lastSnapshot}`;
|
|
|
45287
45488
|
}
|
|
45288
45489
|
function executeSqlite(src, input) {
|
|
45289
45490
|
const resolved = expandPath2(src.path, input);
|
|
45290
|
-
if (!resolved || !
|
|
45491
|
+
if (!resolved || !fs13.existsSync(resolved)) return null;
|
|
45291
45492
|
let Database;
|
|
45292
45493
|
try {
|
|
45293
45494
|
Database = require("better-sqlite3");
|
|
@@ -45346,17 +45547,25 @@ ${lastSnapshot}`;
|
|
|
45346
45547
|
if (!template) return null;
|
|
45347
45548
|
let out = template;
|
|
45348
45549
|
if (out.startsWith("~/") || out === "~") {
|
|
45349
|
-
out =
|
|
45550
|
+
out = path25.join(os18.homedir(), out.slice(2));
|
|
45350
45551
|
}
|
|
45351
45552
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
45352
45553
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
45353
45554
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
45354
45555
|
});
|
|
45355
|
-
if (out.startsWith("~/")) out =
|
|
45556
|
+
if (out.startsWith("~/")) out = path25.join(os18.homedir(), out.slice(2));
|
|
45356
45557
|
const now = /* @__PURE__ */ new Date();
|
|
45558
|
+
const workspaceRaw = input.workspace ?? "";
|
|
45559
|
+
let workspaceResolved = workspaceRaw;
|
|
45560
|
+
if (workspaceRaw) {
|
|
45561
|
+
try {
|
|
45562
|
+
workspaceResolved = fs13.realpathSync(workspaceRaw);
|
|
45563
|
+
} catch {
|
|
45564
|
+
}
|
|
45565
|
+
}
|
|
45357
45566
|
const vars = {
|
|
45358
|
-
cwd:
|
|
45359
|
-
cwd_dashed:
|
|
45567
|
+
cwd: workspaceResolved,
|
|
45568
|
+
cwd_dashed: workspaceResolved.replace(/\//g, "-"),
|
|
45360
45569
|
session_id: input.providerSessionId || input.sessionId || input.historySessionId || "",
|
|
45361
45570
|
yyyy: String(now.getUTCFullYear()),
|
|
45362
45571
|
mm: String(now.getUTCMonth() + 1).padStart(2, "0"),
|
|
@@ -45392,20 +45601,20 @@ ${lastSnapshot}`;
|
|
|
45392
45601
|
for (const d of dirs) {
|
|
45393
45602
|
let entries;
|
|
45394
45603
|
try {
|
|
45395
|
-
entries =
|
|
45604
|
+
entries = fs13.readdirSync(d, { withFileTypes: true });
|
|
45396
45605
|
} catch {
|
|
45397
45606
|
continue;
|
|
45398
45607
|
}
|
|
45399
45608
|
for (const e of entries) {
|
|
45400
|
-
if (e.isDirectory() && re.test(e.name)) next.push(
|
|
45609
|
+
if (e.isDirectory() && re.test(e.name)) next.push(path25.join(d, e.name));
|
|
45401
45610
|
}
|
|
45402
45611
|
}
|
|
45403
45612
|
} else {
|
|
45404
45613
|
for (const d of dirs) {
|
|
45405
|
-
const candidate =
|
|
45614
|
+
const candidate = path25.join(d, seg);
|
|
45406
45615
|
let stat2 = null;
|
|
45407
45616
|
try {
|
|
45408
|
-
stat2 =
|
|
45617
|
+
stat2 = fs13.statSync(candidate);
|
|
45409
45618
|
} catch {
|
|
45410
45619
|
continue;
|
|
45411
45620
|
}
|
|
@@ -45419,13 +45628,13 @@ ${lastSnapshot}`;
|
|
|
45419
45628
|
function walkAllDirs(root, out) {
|
|
45420
45629
|
let entries;
|
|
45421
45630
|
try {
|
|
45422
|
-
entries =
|
|
45631
|
+
entries = fs13.readdirSync(root, { withFileTypes: true });
|
|
45423
45632
|
} catch {
|
|
45424
45633
|
return;
|
|
45425
45634
|
}
|
|
45426
45635
|
out.push(root);
|
|
45427
45636
|
for (const e of entries) {
|
|
45428
|
-
if (e.isDirectory()) walkAllDirs(
|
|
45637
|
+
if (e.isDirectory()) walkAllDirs(path25.join(root, e.name), out);
|
|
45429
45638
|
}
|
|
45430
45639
|
}
|
|
45431
45640
|
function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
|
|
@@ -45435,13 +45644,13 @@ ${lastSnapshot}`;
|
|
|
45435
45644
|
for (const d of dirs) {
|
|
45436
45645
|
let entries;
|
|
45437
45646
|
try {
|
|
45438
|
-
entries =
|
|
45647
|
+
entries = fs13.readdirSync(d, { withFileTypes: true });
|
|
45439
45648
|
} catch {
|
|
45440
45649
|
continue;
|
|
45441
45650
|
}
|
|
45442
45651
|
for (const e of entries) {
|
|
45443
45652
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
45444
|
-
const p =
|
|
45653
|
+
const p = path25.join(d, e.name);
|
|
45445
45654
|
const mtime = safeMtimeMs(p);
|
|
45446
45655
|
if (mtime < cutoff) continue;
|
|
45447
45656
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -45452,7 +45661,7 @@ ${lastSnapshot}`;
|
|
|
45452
45661
|
function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
45453
45662
|
let entries;
|
|
45454
45663
|
try {
|
|
45455
|
-
entries =
|
|
45664
|
+
entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
45456
45665
|
} catch {
|
|
45457
45666
|
return null;
|
|
45458
45667
|
}
|
|
@@ -45460,7 +45669,7 @@ ${lastSnapshot}`;
|
|
|
45460
45669
|
let best = null;
|
|
45461
45670
|
for (const e of entries) {
|
|
45462
45671
|
if (!e.isFile() || !pattern.test(e.name)) continue;
|
|
45463
|
-
const p =
|
|
45672
|
+
const p = path25.join(dir, e.name);
|
|
45464
45673
|
const mtime = safeMtimeMs(p);
|
|
45465
45674
|
if (mtime < cutoff) continue;
|
|
45466
45675
|
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
@@ -45469,7 +45678,7 @@ ${lastSnapshot}`;
|
|
|
45469
45678
|
}
|
|
45470
45679
|
function safeMtimeMs(p) {
|
|
45471
45680
|
try {
|
|
45472
|
-
return Math.floor(
|
|
45681
|
+
return Math.floor(fs13.statSync(p).mtimeMs);
|
|
45473
45682
|
} catch {
|
|
45474
45683
|
return 0;
|
|
45475
45684
|
}
|
|
@@ -45673,16 +45882,16 @@ ${lastSnapshot}`;
|
|
|
45673
45882
|
}
|
|
45674
45883
|
return t.negate ? !result : result;
|
|
45675
45884
|
}
|
|
45676
|
-
var
|
|
45677
|
-
var
|
|
45678
|
-
var
|
|
45885
|
+
var fs13;
|
|
45886
|
+
var os18;
|
|
45887
|
+
var path25;
|
|
45679
45888
|
var UUID_RE;
|
|
45680
45889
|
var init_native_history_executor = __esm2({
|
|
45681
45890
|
"src/providers/spec/native-history-executor.ts"() {
|
|
45682
45891
|
"use strict";
|
|
45683
|
-
|
|
45684
|
-
|
|
45685
|
-
|
|
45892
|
+
fs13 = __toESM2(require("fs"));
|
|
45893
|
+
os18 = __toESM2(require("os"));
|
|
45894
|
+
path25 = __toESM2(require("path"));
|
|
45686
45895
|
UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
45687
45896
|
}
|
|
45688
45897
|
});
|
|
@@ -45698,7 +45907,7 @@ ${lastSnapshot}`;
|
|
|
45698
45907
|
}
|
|
45699
45908
|
function statMtimeMs(filePath) {
|
|
45700
45909
|
try {
|
|
45701
|
-
return
|
|
45910
|
+
return fs14.statSync(filePath).mtimeMs;
|
|
45702
45911
|
} catch {
|
|
45703
45912
|
return 0;
|
|
45704
45913
|
}
|
|
@@ -45768,7 +45977,7 @@ ${lastSnapshot}`;
|
|
|
45768
45977
|
function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
45769
45978
|
let raw;
|
|
45770
45979
|
try {
|
|
45771
|
-
raw =
|
|
45980
|
+
raw = fs14.readFileSync(filePath, "utf-8");
|
|
45772
45981
|
} catch {
|
|
45773
45982
|
return [];
|
|
45774
45983
|
}
|
|
@@ -45841,10 +46050,10 @@ ${lastSnapshot}`;
|
|
|
45841
46050
|
return records;
|
|
45842
46051
|
}
|
|
45843
46052
|
function readSession(sessionPath) {
|
|
45844
|
-
if (!sessionPath || !
|
|
45845
|
-
const basename12 =
|
|
46053
|
+
if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
|
|
46054
|
+
const basename12 = path26.basename(sessionPath, ".jsonl");
|
|
45846
46055
|
if (!isSafeSessionId(basename12)) return null;
|
|
45847
|
-
if (!
|
|
46056
|
+
if (!fs14.existsSync(sessionPath)) return null;
|
|
45848
46057
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
45849
46058
|
const messages = parseTranscriptFile(sessionPath, basename12);
|
|
45850
46059
|
if (messages.length === 0) return null;
|
|
@@ -45860,13 +46069,13 @@ ${lastSnapshot}`;
|
|
|
45860
46069
|
workspace
|
|
45861
46070
|
};
|
|
45862
46071
|
}
|
|
45863
|
-
var
|
|
45864
|
-
var
|
|
46072
|
+
var fs14;
|
|
46073
|
+
var path26;
|
|
45865
46074
|
var init_claude_cli_transcript = __esm2({
|
|
45866
46075
|
"src/providers/native-history/claude-cli-transcript.ts"() {
|
|
45867
46076
|
"use strict";
|
|
45868
|
-
|
|
45869
|
-
|
|
46077
|
+
fs14 = __toESM2(require("fs"));
|
|
46078
|
+
path26 = __toESM2(require("path"));
|
|
45870
46079
|
}
|
|
45871
46080
|
});
|
|
45872
46081
|
function extractTimestampValue2(value) {
|
|
@@ -45881,7 +46090,7 @@ ${lastSnapshot}`;
|
|
|
45881
46090
|
}
|
|
45882
46091
|
function statMtimeMs2(filePath) {
|
|
45883
46092
|
try {
|
|
45884
|
-
return
|
|
46093
|
+
return fs15.statSync(filePath).mtimeMs;
|
|
45885
46094
|
} catch {
|
|
45886
46095
|
return 0;
|
|
45887
46096
|
}
|
|
@@ -45949,7 +46158,7 @@ ${lastSnapshot}`;
|
|
|
45949
46158
|
}
|
|
45950
46159
|
function readSessionMeta(filePath) {
|
|
45951
46160
|
try {
|
|
45952
|
-
const firstLine =
|
|
46161
|
+
const firstLine = fs15.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
45953
46162
|
if (!firstLine) return null;
|
|
45954
46163
|
const parsed = JSON.parse(firstLine);
|
|
45955
46164
|
if (String(parsed.type ?? "") !== "session_meta") return null;
|
|
@@ -45961,7 +46170,7 @@ ${lastSnapshot}`;
|
|
|
45961
46170
|
function parseSessionFile(filePath, sessionId, workspaceFallback) {
|
|
45962
46171
|
let raw;
|
|
45963
46172
|
try {
|
|
45964
|
-
raw =
|
|
46173
|
+
raw = fs15.readFileSync(filePath, "utf-8");
|
|
45965
46174
|
} catch {
|
|
45966
46175
|
return [];
|
|
45967
46176
|
}
|
|
@@ -46055,11 +46264,11 @@ ${lastSnapshot}`;
|
|
|
46055
46264
|
return records;
|
|
46056
46265
|
}
|
|
46057
46266
|
function readSession2(sessionPath) {
|
|
46058
|
-
if (!sessionPath || !
|
|
46059
|
-
if (!
|
|
46267
|
+
if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
|
|
46268
|
+
if (!fs15.existsSync(sessionPath)) return null;
|
|
46060
46269
|
const meta3 = readSessionMeta(sessionPath);
|
|
46061
46270
|
const metaId = String(meta3?.id ?? "").trim();
|
|
46062
|
-
const basename12 =
|
|
46271
|
+
const basename12 = path27.basename(sessionPath, ".jsonl");
|
|
46063
46272
|
const uuidMatch = basename12.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
46064
46273
|
const filenameUuid = uuidMatch ? uuidMatch[1] : "";
|
|
46065
46274
|
if (metaId && filenameUuid && metaId !== filenameUuid) return null;
|
|
@@ -46081,13 +46290,13 @@ ${lastSnapshot}`;
|
|
|
46081
46290
|
workspace
|
|
46082
46291
|
};
|
|
46083
46292
|
}
|
|
46084
|
-
var
|
|
46085
|
-
var
|
|
46293
|
+
var fs15;
|
|
46294
|
+
var path27;
|
|
46086
46295
|
var init_codex_cli_transcript = __esm2({
|
|
46087
46296
|
"src/providers/native-history/codex-cli-transcript.ts"() {
|
|
46088
46297
|
"use strict";
|
|
46089
|
-
|
|
46090
|
-
|
|
46298
|
+
fs15 = __toESM2(require("fs"));
|
|
46299
|
+
path27 = __toESM2(require("path"));
|
|
46091
46300
|
}
|
|
46092
46301
|
});
|
|
46093
46302
|
function extractTimestampValue3(value) {
|
|
@@ -46102,7 +46311,7 @@ ${lastSnapshot}`;
|
|
|
46102
46311
|
}
|
|
46103
46312
|
function statMtimeMs3(filePath) {
|
|
46104
46313
|
try {
|
|
46105
|
-
return
|
|
46314
|
+
return fs16.statSync(filePath).mtimeMs;
|
|
46106
46315
|
} catch {
|
|
46107
46316
|
return 0;
|
|
46108
46317
|
}
|
|
@@ -46111,13 +46320,13 @@ ${lastSnapshot}`;
|
|
|
46111
46320
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
46112
46321
|
}
|
|
46113
46322
|
function antigravityRoot() {
|
|
46114
|
-
return
|
|
46323
|
+
return path28.join(os19.homedir(), ".gemini", "antigravity-cli");
|
|
46115
46324
|
}
|
|
46116
46325
|
function historyJsonlPath() {
|
|
46117
|
-
return
|
|
46326
|
+
return path28.join(antigravityRoot(), "history.jsonl");
|
|
46118
46327
|
}
|
|
46119
46328
|
function brainRoot() {
|
|
46120
|
-
return
|
|
46329
|
+
return path28.join(antigravityRoot(), "brain");
|
|
46121
46330
|
}
|
|
46122
46331
|
function extractUserRequestContent(content) {
|
|
46123
46332
|
const raw = content.trim();
|
|
@@ -46133,7 +46342,7 @@ ${lastSnapshot}`;
|
|
|
46133
46342
|
function parseBrainTranscript(filePath, sessionId, workspace) {
|
|
46134
46343
|
let raw;
|
|
46135
46344
|
try {
|
|
46136
|
-
raw =
|
|
46345
|
+
raw = fs16.readFileSync(filePath, "utf-8");
|
|
46137
46346
|
} catch {
|
|
46138
46347
|
return null;
|
|
46139
46348
|
}
|
|
@@ -46193,7 +46402,7 @@ ${lastSnapshot}`;
|
|
|
46193
46402
|
const sourcePath = historyJsonlPath();
|
|
46194
46403
|
let lines = [];
|
|
46195
46404
|
try {
|
|
46196
|
-
lines =
|
|
46405
|
+
lines = fs16.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
46197
46406
|
} catch {
|
|
46198
46407
|
return [];
|
|
46199
46408
|
}
|
|
@@ -46240,7 +46449,7 @@ ${lastSnapshot}`;
|
|
|
46240
46449
|
function parsePbFile(filePath, sessionId) {
|
|
46241
46450
|
let buf;
|
|
46242
46451
|
try {
|
|
46243
|
-
buf =
|
|
46452
|
+
buf = fs16.readFileSync(filePath);
|
|
46244
46453
|
} catch {
|
|
46245
46454
|
return null;
|
|
46246
46455
|
}
|
|
@@ -46263,13 +46472,13 @@ ${lastSnapshot}`;
|
|
|
46263
46472
|
];
|
|
46264
46473
|
}
|
|
46265
46474
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
46266
|
-
if (!sessionPath || !
|
|
46267
|
-
if (!
|
|
46475
|
+
if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
|
|
46476
|
+
if (!fs16.existsSync(sessionPath)) return null;
|
|
46268
46477
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
46269
46478
|
const brainRootPath = brainRoot();
|
|
46270
|
-
if (sessionPath.startsWith(brainRootPath +
|
|
46271
|
-
const
|
|
46272
|
-
const uuidFromPath =
|
|
46479
|
+
if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
|
|
46480
|
+
const relative5 = sessionPath.slice(brainRootPath.length + 1);
|
|
46481
|
+
const uuidFromPath = relative5.split(path28.sep)[0];
|
|
46273
46482
|
const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
|
|
46274
46483
|
if (!resolvedSessionId) return null;
|
|
46275
46484
|
const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
|
|
@@ -46285,7 +46494,7 @@ ${lastSnapshot}`;
|
|
|
46285
46494
|
};
|
|
46286
46495
|
}
|
|
46287
46496
|
if (sessionPath.endsWith(".pb")) {
|
|
46288
|
-
const pbSessionId = sessionId ||
|
|
46497
|
+
const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
|
|
46289
46498
|
if (!isUuidLike(pbSessionId)) return null;
|
|
46290
46499
|
const messages = parsePbFile(sessionPath, pbSessionId);
|
|
46291
46500
|
if (!messages || messages.length === 0) return null;
|
|
@@ -46299,7 +46508,7 @@ ${lastSnapshot}`;
|
|
|
46299
46508
|
partialReason: "antigravity_cli_pb_raw_text_extraction"
|
|
46300
46509
|
};
|
|
46301
46510
|
}
|
|
46302
|
-
if (
|
|
46511
|
+
if (path28.basename(sessionPath) === "history.jsonl") {
|
|
46303
46512
|
const resolvedSessionId = sessionId || "";
|
|
46304
46513
|
if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
|
|
46305
46514
|
const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
|
|
@@ -46344,28 +46553,28 @@ ${lastSnapshot}`;
|
|
|
46344
46553
|
}
|
|
46345
46554
|
return null;
|
|
46346
46555
|
}
|
|
46347
|
-
var
|
|
46348
|
-
var
|
|
46349
|
-
var
|
|
46556
|
+
var fs16;
|
|
46557
|
+
var path28;
|
|
46558
|
+
var os19;
|
|
46350
46559
|
var MIN_PRINTABLE_RUN;
|
|
46351
46560
|
var init_antigravity_cli_transcript = __esm2({
|
|
46352
46561
|
"src/providers/native-history/antigravity-cli-transcript.ts"() {
|
|
46353
46562
|
"use strict";
|
|
46354
|
-
|
|
46355
|
-
|
|
46356
|
-
|
|
46563
|
+
fs16 = __toESM2(require("fs"));
|
|
46564
|
+
path28 = __toESM2(require("path"));
|
|
46565
|
+
os19 = __toESM2(require("os"));
|
|
46357
46566
|
MIN_PRINTABLE_RUN = 8;
|
|
46358
46567
|
}
|
|
46359
46568
|
});
|
|
46360
46569
|
function statMtimeMs4(p) {
|
|
46361
46570
|
try {
|
|
46362
|
-
return Math.floor(
|
|
46571
|
+
return Math.floor(fs17.statSync(p).mtimeMs);
|
|
46363
46572
|
} catch {
|
|
46364
46573
|
return 0;
|
|
46365
46574
|
}
|
|
46366
46575
|
}
|
|
46367
46576
|
function openDb() {
|
|
46368
|
-
if (!
|
|
46577
|
+
if (!fs17.existsSync(HERMES_STATE_DB)) return null;
|
|
46369
46578
|
try {
|
|
46370
46579
|
const Database = require("better-sqlite3");
|
|
46371
46580
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
@@ -46422,10 +46631,10 @@ ${lastSnapshot}`;
|
|
|
46422
46631
|
}
|
|
46423
46632
|
}
|
|
46424
46633
|
}
|
|
46425
|
-
if (!
|
|
46634
|
+
if (!path29.isAbsolute(sessionPath) || !fs17.existsSync(sessionPath)) return null;
|
|
46426
46635
|
let raw;
|
|
46427
46636
|
try {
|
|
46428
|
-
raw = JSON.parse(
|
|
46637
|
+
raw = JSON.parse(fs17.readFileSync(sessionPath, "utf8"));
|
|
46429
46638
|
} catch {
|
|
46430
46639
|
return null;
|
|
46431
46640
|
}
|
|
@@ -46448,7 +46657,7 @@ ${lastSnapshot}`;
|
|
|
46448
46657
|
});
|
|
46449
46658
|
}
|
|
46450
46659
|
if (messages.length === 0) return null;
|
|
46451
|
-
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id :
|
|
46660
|
+
const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
|
|
46452
46661
|
return {
|
|
46453
46662
|
messages,
|
|
46454
46663
|
providerSessionId: sessionId,
|
|
@@ -46465,19 +46674,19 @@ ${lastSnapshot}`;
|
|
|
46465
46674
|
if (s === "tool" || s === "tool_result" || s === "function") return "assistant";
|
|
46466
46675
|
return "system";
|
|
46467
46676
|
}
|
|
46468
|
-
var
|
|
46469
|
-
var
|
|
46470
|
-
var
|
|
46677
|
+
var fs17;
|
|
46678
|
+
var path29;
|
|
46679
|
+
var os20;
|
|
46471
46680
|
var HERMES_STATE_DB;
|
|
46472
46681
|
var HERMES_LEGACY_SESSIONS_DIR;
|
|
46473
46682
|
var init_hermes_cli_transcript = __esm2({
|
|
46474
46683
|
"src/providers/native-history/hermes-cli-transcript.ts"() {
|
|
46475
46684
|
"use strict";
|
|
46476
|
-
|
|
46477
|
-
|
|
46478
|
-
|
|
46479
|
-
HERMES_STATE_DB =
|
|
46480
|
-
HERMES_LEGACY_SESSIONS_DIR =
|
|
46685
|
+
fs17 = __toESM2(require("fs"));
|
|
46686
|
+
path29 = __toESM2(require("path"));
|
|
46687
|
+
os20 = __toESM2(require("os"));
|
|
46688
|
+
HERMES_STATE_DB = path29.join(os20.homedir(), ".hermes", "state.db");
|
|
46689
|
+
HERMES_LEGACY_SESSIONS_DIR = path29.join(os20.homedir(), ".hermes", "sessions");
|
|
46481
46690
|
}
|
|
46482
46691
|
});
|
|
46483
46692
|
var dispatcher_exports = {};
|
|
@@ -46523,26 +46732,26 @@ ${lastSnapshot}`;
|
|
|
46523
46732
|
}
|
|
46524
46733
|
}
|
|
46525
46734
|
function resolveClaudePath(workspace, sessionId) {
|
|
46526
|
-
const dir =
|
|
46527
|
-
if (!
|
|
46735
|
+
const dir = path30.join(os21.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
46736
|
+
if (!fs18.existsSync(dir)) return null;
|
|
46528
46737
|
if (sessionId) {
|
|
46529
|
-
const candidate =
|
|
46530
|
-
if (
|
|
46738
|
+
const candidate = path30.join(dir, `${sessionId}.jsonl`);
|
|
46739
|
+
if (fs18.existsSync(candidate)) return candidate;
|
|
46531
46740
|
}
|
|
46532
46741
|
return null;
|
|
46533
46742
|
}
|
|
46534
46743
|
function resolveCodexPath(workspace) {
|
|
46535
46744
|
void workspace;
|
|
46536
46745
|
const now = /* @__PURE__ */ new Date();
|
|
46537
|
-
const dir =
|
|
46538
|
-
|
|
46746
|
+
const dir = path30.join(
|
|
46747
|
+
os21.homedir(),
|
|
46539
46748
|
".codex",
|
|
46540
46749
|
"sessions",
|
|
46541
46750
|
String(now.getUTCFullYear()),
|
|
46542
46751
|
String(now.getUTCMonth() + 1).padStart(2, "0"),
|
|
46543
46752
|
String(now.getUTCDate()).padStart(2, "0")
|
|
46544
46753
|
);
|
|
46545
|
-
if (
|
|
46754
|
+
if (fs18.existsSync(dir)) {
|
|
46546
46755
|
const f = newestRecentFile2(dir, /\.jsonl$/);
|
|
46547
46756
|
if (f) return f;
|
|
46548
46757
|
}
|
|
@@ -46550,23 +46759,23 @@ ${lastSnapshot}`;
|
|
|
46550
46759
|
}
|
|
46551
46760
|
function resolveAntigravityPath(workspace) {
|
|
46552
46761
|
void workspace;
|
|
46553
|
-
const brainRoot2 =
|
|
46554
|
-
if (!
|
|
46762
|
+
const brainRoot2 = path30.join(os21.homedir(), ".gemini", "antigravity-cli", "brain");
|
|
46763
|
+
if (!fs18.existsSync(brainRoot2)) return null;
|
|
46555
46764
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
46556
|
-
const entries =
|
|
46765
|
+
const entries = fs18.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);
|
|
46557
46766
|
for (const e of entries) {
|
|
46558
|
-
const t =
|
|
46559
|
-
if (
|
|
46767
|
+
const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
46768
|
+
if (fs18.existsSync(t)) return t;
|
|
46560
46769
|
}
|
|
46561
46770
|
return null;
|
|
46562
46771
|
}
|
|
46563
46772
|
function resolveHermesPath(workspace, sessionId) {
|
|
46564
46773
|
void workspace;
|
|
46565
46774
|
void sessionId;
|
|
46566
|
-
const dbPath =
|
|
46567
|
-
if (
|
|
46568
|
-
const dir =
|
|
46569
|
-
if (!
|
|
46775
|
+
const dbPath = path30.join(os21.homedir(), ".hermes", "state.db");
|
|
46776
|
+
if (fs18.existsSync(dbPath)) return dbPath;
|
|
46777
|
+
const dir = path30.join(os21.homedir(), ".hermes", "sessions");
|
|
46778
|
+
if (!fs18.existsSync(dir)) return null;
|
|
46570
46779
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
46571
46780
|
}
|
|
46572
46781
|
function readByReader(reader, sourcePath, sessionId, workspace) {
|
|
@@ -46588,7 +46797,7 @@ ${lastSnapshot}`;
|
|
|
46588
46797
|
function newestRecentFile2(dir, pattern) {
|
|
46589
46798
|
try {
|
|
46590
46799
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
46591
|
-
const entries =
|
|
46800
|
+
const entries = fs18.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);
|
|
46592
46801
|
return entries[0]?.p ?? null;
|
|
46593
46802
|
} catch {
|
|
46594
46803
|
return null;
|
|
@@ -46596,7 +46805,7 @@ ${lastSnapshot}`;
|
|
|
46596
46805
|
}
|
|
46597
46806
|
function safeMtime(p) {
|
|
46598
46807
|
try {
|
|
46599
|
-
return Math.floor(
|
|
46808
|
+
return Math.floor(fs18.statSync(p).mtimeMs);
|
|
46600
46809
|
} catch {
|
|
46601
46810
|
return 0;
|
|
46602
46811
|
}
|
|
@@ -46608,16 +46817,16 @@ ${lastSnapshot}`;
|
|
|
46608
46817
|
if (s === "tool" || s === "tool_result" || s === "function") return "assistant";
|
|
46609
46818
|
return "system";
|
|
46610
46819
|
}
|
|
46611
|
-
var
|
|
46612
|
-
var
|
|
46613
|
-
var
|
|
46820
|
+
var fs18;
|
|
46821
|
+
var os21;
|
|
46822
|
+
var path30;
|
|
46614
46823
|
var RECENT_WINDOW_MS;
|
|
46615
46824
|
var init_dispatcher = __esm2({
|
|
46616
46825
|
"src/providers/native-history/dispatcher.ts"() {
|
|
46617
46826
|
"use strict";
|
|
46618
|
-
|
|
46619
|
-
|
|
46620
|
-
|
|
46827
|
+
fs18 = __toESM2(require("fs"));
|
|
46828
|
+
os21 = __toESM2(require("os"));
|
|
46829
|
+
path30 = __toESM2(require("path"));
|
|
46621
46830
|
init_claude_cli_transcript();
|
|
46622
46831
|
init_codex_cli_transcript();
|
|
46623
46832
|
init_antigravity_cli_transcript();
|
|
@@ -47154,12 +47363,12 @@ ${lastSnapshot}`;
|
|
|
47154
47363
|
if (!match) continue;
|
|
47155
47364
|
const prefix = match[1];
|
|
47156
47365
|
const commit = match[2];
|
|
47157
|
-
const
|
|
47158
|
-
if (ignoreSet.has(
|
|
47366
|
+
const path40 = match[3];
|
|
47367
|
+
if (ignoreSet.has(path40)) continue;
|
|
47159
47368
|
submodules.push({
|
|
47160
|
-
path:
|
|
47369
|
+
path: path40,
|
|
47161
47370
|
commit,
|
|
47162
|
-
repoPath: repoRoot + "/" +
|
|
47371
|
+
repoPath: repoRoot + "/" + path40,
|
|
47163
47372
|
dirty: prefix === "+",
|
|
47164
47373
|
outOfSync: prefix === "-",
|
|
47165
47374
|
lastCheckedAt: Date.now()
|
|
@@ -47168,7 +47377,7 @@ ${lastSnapshot}`;
|
|
|
47168
47377
|
return submodules;
|
|
47169
47378
|
}
|
|
47170
47379
|
var import_promises2 = require("fs/promises");
|
|
47171
|
-
var
|
|
47380
|
+
var path23 = __toESM2(require("path"));
|
|
47172
47381
|
init_git_executor();
|
|
47173
47382
|
var DEFAULT_MAX_FILES = 200;
|
|
47174
47383
|
var DEFAULT_MAX_BYTES = 2e5;
|
|
@@ -47340,17 +47549,17 @@ ${lastSnapshot}`;
|
|
|
47340
47549
|
if (typeof filePath !== "string" || filePath.length === 0 || filePath.includes("\0")) {
|
|
47341
47550
|
throw new GitCommandError("invalid_args", "File path must be a non-empty path");
|
|
47342
47551
|
}
|
|
47343
|
-
const canonicalRepoRoot = await (0, import_promises2.realpath)(repoRoot).catch(() =>
|
|
47344
|
-
const absolutePath =
|
|
47552
|
+
const canonicalRepoRoot = await (0, import_promises2.realpath)(repoRoot).catch(() => path23.resolve(repoRoot));
|
|
47553
|
+
const absolutePath = path23.isAbsolute(filePath) ? path23.resolve(filePath) : path23.resolve(repoRoot, filePath);
|
|
47345
47554
|
const checkPath = await (0, import_promises2.realpath)(absolutePath).catch(() => absolutePath);
|
|
47346
|
-
const relativeBase = isPathInside(canonicalRepoRoot, checkPath) ? canonicalRepoRoot :
|
|
47555
|
+
const relativeBase = isPathInside(canonicalRepoRoot, checkPath) ? canonicalRepoRoot : path23.resolve(repoRoot);
|
|
47347
47556
|
if (!isPathInside(canonicalRepoRoot, checkPath) && !isPathInside(repoRoot, absolutePath)) {
|
|
47348
47557
|
throw new GitCommandError("path_outside_repo", "Selected file path is outside the repository root", {
|
|
47349
47558
|
cwd: repoRoot
|
|
47350
47559
|
});
|
|
47351
47560
|
}
|
|
47352
|
-
const relativePath =
|
|
47353
|
-
if (!relativePath || relativePath.startsWith("..") ||
|
|
47561
|
+
const relativePath = path23.relative(relativeBase, checkPath).split(path23.sep).join("/");
|
|
47562
|
+
if (!relativePath || relativePath.startsWith("..") || path23.isAbsolute(relativePath)) {
|
|
47354
47563
|
throw new GitCommandError("path_outside_repo", "Selected file path is outside the repository root", {
|
|
47355
47564
|
cwd: repoRoot
|
|
47356
47565
|
});
|
|
@@ -48633,10 +48842,10 @@ ${lastSnapshot}`;
|
|
|
48633
48842
|
return (0, import_path3.join)(getDaemonDataDir(), "mesh-coordinators.json");
|
|
48634
48843
|
}
|
|
48635
48844
|
function loadMeshCoordinatorRegistry() {
|
|
48636
|
-
const
|
|
48637
|
-
if (!(0, import_fs3.existsSync)(
|
|
48845
|
+
const path40 = getRegistryPath();
|
|
48846
|
+
if (!(0, import_fs3.existsSync)(path40)) return;
|
|
48638
48847
|
try {
|
|
48639
|
-
const raw = JSON.parse((0, import_fs3.readFileSync)(
|
|
48848
|
+
const raw = JSON.parse((0, import_fs3.readFileSync)(path40, "utf-8"));
|
|
48640
48849
|
if (!Array.isArray(raw)) return;
|
|
48641
48850
|
_registry.clear();
|
|
48642
48851
|
for (const entry of raw) {
|
|
@@ -48853,8 +49062,8 @@ ${lastSnapshot}`;
|
|
|
48853
49062
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
48854
49063
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands };
|
|
48855
49064
|
}
|
|
48856
|
-
function parseConfigText(
|
|
48857
|
-
if (/\.json$/i.test(
|
|
49065
|
+
function parseConfigText(path40, text) {
|
|
49066
|
+
if (/\.json$/i.test(path40)) return JSON.parse(text);
|
|
48858
49067
|
return yaml.load(text);
|
|
48859
49068
|
}
|
|
48860
49069
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -48865,16 +49074,16 @@ ${lastSnapshot}`;
|
|
|
48865
49074
|
if (!validation.valid) return { source: "mesh.policy.refineConfig", sourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
48866
49075
|
return { config: inline, source: "mesh.policy.refineConfig", sourceType: "mesh_policy" };
|
|
48867
49076
|
}
|
|
48868
|
-
for (const
|
|
48869
|
-
const configPath = (0, import_path4.join)(workspace,
|
|
49077
|
+
for (const relative5 of MESH_REFINE_CONFIG_LOCATIONS) {
|
|
49078
|
+
const configPath = (0, import_path4.join)(workspace, relative5);
|
|
48870
49079
|
if (!(0, import_fs4.existsSync)(configPath)) continue;
|
|
48871
49080
|
try {
|
|
48872
49081
|
const parsed = parseConfigText(configPath, (0, import_fs4.readFileSync)(configPath, "utf-8"));
|
|
48873
|
-
const validation = validateMeshRefineConfig(parsed,
|
|
48874
|
-
if (!validation.valid) return { source:
|
|
48875
|
-
return { config: parsed, source:
|
|
49082
|
+
const validation = validateMeshRefineConfig(parsed, relative5);
|
|
49083
|
+
if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
49084
|
+
return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
|
|
48876
49085
|
} catch (error48) {
|
|
48877
|
-
return { source:
|
|
49086
|
+
return { source: relative5, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
|
|
48878
49087
|
}
|
|
48879
49088
|
}
|
|
48880
49089
|
return {
|
|
@@ -49005,8 +49214,8 @@ ${lastSnapshot}`;
|
|
|
49005
49214
|
var DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
49006
49215
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
49007
49216
|
var OUTPUT_SUMMARY_CHARS = 2e3;
|
|
49008
|
-
function parseConfigText2(
|
|
49009
|
-
if (/\.json$/i.test(
|
|
49217
|
+
function parseConfigText2(path40, text) {
|
|
49218
|
+
if (/\.json$/i.test(path40)) return JSON.parse(text);
|
|
49010
49219
|
return yaml2.load(text);
|
|
49011
49220
|
}
|
|
49012
49221
|
function truncateOutput(value) {
|
|
@@ -49046,16 +49255,16 @@ ${lastSnapshot}`;
|
|
|
49046
49255
|
if (!validation.valid) return { source: "mesh.policy.worktreeBootstrapConfig", sourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
49047
49256
|
return { config: inline, source: "mesh.policy.worktreeBootstrapConfig", sourceType: "mesh_policy" };
|
|
49048
49257
|
}
|
|
49049
|
-
for (const
|
|
49050
|
-
const configPath = (0, import_path5.join)(workspace,
|
|
49258
|
+
for (const relative5 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
|
|
49259
|
+
const configPath = (0, import_path5.join)(workspace, relative5);
|
|
49051
49260
|
if (!(0, import_fs5.existsSync)(configPath)) continue;
|
|
49052
49261
|
try {
|
|
49053
49262
|
const parsed = parseConfigText2(configPath, (0, import_fs5.readFileSync)(configPath, "utf-8"));
|
|
49054
|
-
const validation = validateMeshWorktreeBootstrapConfig(parsed,
|
|
49055
|
-
if (!validation.valid) return { source:
|
|
49056
|
-
return { config: parsed, source:
|
|
49263
|
+
const validation = validateMeshWorktreeBootstrapConfig(parsed, relative5);
|
|
49264
|
+
if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
49265
|
+
return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
|
|
49057
49266
|
} catch (error48) {
|
|
49058
|
-
return { source:
|
|
49267
|
+
return { source: relative5, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
|
|
49059
49268
|
}
|
|
49060
49269
|
}
|
|
49061
49270
|
return { source: "unavailable", sourceType: "unavailable", error: `No worktree bootstrap config found. Checked: ${MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS.join(", ")}` };
|
|
@@ -50274,17 +50483,17 @@ ${lastSnapshot}`;
|
|
|
50274
50483
|
return null;
|
|
50275
50484
|
}
|
|
50276
50485
|
async function detectIDEs(providerLoader) {
|
|
50277
|
-
const
|
|
50486
|
+
const os29 = (0, import_os22.platform)();
|
|
50278
50487
|
const results = [];
|
|
50279
50488
|
for (const def of getMergedDefinitions()) {
|
|
50280
50489
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
50281
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
50490
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
|
|
50282
50491
|
let resolvedCli = cliPath;
|
|
50283
|
-
if (!resolvedCli && appPath &&
|
|
50492
|
+
if (!resolvedCli && appPath && os29 === "darwin") {
|
|
50284
50493
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
50285
50494
|
if ((0, import_fs11.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
50286
50495
|
}
|
|
50287
|
-
if (!resolvedCli && appPath &&
|
|
50496
|
+
if (!resolvedCli && appPath && os29 === "win32") {
|
|
50288
50497
|
const { dirname: dirname11 } = await import("path");
|
|
50289
50498
|
const appDir = dirname11(appPath);
|
|
50290
50499
|
const candidates = [
|
|
@@ -50301,7 +50510,7 @@ ${lastSnapshot}`;
|
|
|
50301
50510
|
}
|
|
50302
50511
|
}
|
|
50303
50512
|
}
|
|
50304
|
-
const installed =
|
|
50513
|
+
const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
50305
50514
|
const version2 = resolvedCli ? await getIdeVersion(resolvedCli) : null;
|
|
50306
50515
|
results.push({
|
|
50307
50516
|
id: def.id,
|
|
@@ -60591,6 +60800,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
60591
60800
|
return this.handleCheckProviderUpdates(args);
|
|
60592
60801
|
case "list_installed_providers":
|
|
60593
60802
|
return this.handleListInstalledProviders(args);
|
|
60803
|
+
case "add_provider_source":
|
|
60804
|
+
return this.handleAddProviderSource(args);
|
|
60805
|
+
case "remove_provider_source":
|
|
60806
|
+
return this.handleRemoveProviderSource(args);
|
|
60807
|
+
case "list_provider_sources":
|
|
60808
|
+
return this.handleListProviderSources(args);
|
|
60809
|
+
case "set_active_provider_source":
|
|
60810
|
+
return this.handleSetActiveProviderSource(args);
|
|
60594
60811
|
// ─── Stream commands (stream-commands.ts) ───────────
|
|
60595
60812
|
case "select_session":
|
|
60596
60813
|
return handleSelectSession(this, args);
|
|
@@ -60654,49 +60871,62 @@ ${effect.notification.body || ""}`.trim();
|
|
|
60654
60871
|
return { success: false, error: "ProviderLoader not initialized" };
|
|
60655
60872
|
}
|
|
60656
60873
|
/**
|
|
60657
|
-
* Return per-provider availability so
|
|
60658
|
-
* "Installed" badges. Reuses the existing detection state from
|
|
60874
|
+
* Return per-provider availability so the dashboard's provider catalog
|
|
60875
|
+
* can show "Installed" badges. Reuses the existing detection state from
|
|
60659
60876
|
* ProviderLoader.getMachineProviderStatus() — no probing is triggered.
|
|
60660
60877
|
*/
|
|
60661
60878
|
handleListProviderAvailability(_args) {
|
|
60662
60879
|
if (!this._ctx.providerLoader) {
|
|
60663
60880
|
return { success: false, error: "ProviderLoader not initialized" };
|
|
60664
60881
|
}
|
|
60882
|
+
const { describeTrust: describeTrust2, requiresConfirmation: requiresConfirmation2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
|
|
60665
60883
|
const loader = this._ctx.providerLoader;
|
|
60666
60884
|
const items = loader.getAll().map((provider) => {
|
|
60667
60885
|
const machineConfig = loader.getMachineProviderConfig(provider.type);
|
|
60668
60886
|
const lastDetection = machineConfig.lastDetection;
|
|
60887
|
+
const trust = provider._sourceTrust ?? "trusted";
|
|
60888
|
+
const layer = provider._sourceLayer ?? "upstream";
|
|
60889
|
+
const sourceName = provider._sourceName ?? null;
|
|
60669
60890
|
return {
|
|
60670
60891
|
type: provider.type,
|
|
60671
60892
|
category: provider.category,
|
|
60672
60893
|
status: loader.getMachineProviderStatus(provider.type),
|
|
60673
60894
|
installed: lastDetection?.ok === true,
|
|
60674
60895
|
detectedPath: lastDetection?.path ?? null,
|
|
60675
|
-
checkedAt: lastDetection?.checkedAt ?? null
|
|
60896
|
+
checkedAt: lastDetection?.checkedAt ?? null,
|
|
60897
|
+
trust,
|
|
60898
|
+
trustDescription: describeTrust2(trust),
|
|
60899
|
+
requiresConfirmation: requiresConfirmation2(trust),
|
|
60900
|
+
sourceLayer: layer,
|
|
60901
|
+
sourceName
|
|
60676
60902
|
};
|
|
60677
60903
|
});
|
|
60678
60904
|
return { success: true, providers: items };
|
|
60679
60905
|
}
|
|
60680
60906
|
/**
|
|
60681
|
-
* Compute the *
|
|
60682
|
-
*
|
|
60683
|
-
*
|
|
60684
|
-
*
|
|
60685
|
-
*
|
|
60686
|
-
*
|
|
60907
|
+
* Compute the *upstream cache root*. install_provider_manifest writes
|
|
60908
|
+
* official-registry manifests here so the daemon's standard upstream
|
|
60909
|
+
* layer picks them up — no special handling needed at load time, and
|
|
60910
|
+
* the manifests inherit the official-trust badge instead of the
|
|
60911
|
+
* untrusted-external one.
|
|
60912
|
+
*
|
|
60913
|
+
* Path matches ProviderLoader.upstreamDir but we recompute it from
|
|
60914
|
+
* homedir() so this method stays usable in dev where userDir can
|
|
60915
|
+
* point at a sibling git checkout.
|
|
60687
60916
|
*/
|
|
60688
|
-
|
|
60689
|
-
const
|
|
60690
|
-
const
|
|
60691
|
-
return
|
|
60917
|
+
getUpstreamInstallRoot() {
|
|
60918
|
+
const os29 = require("os");
|
|
60919
|
+
const path40 = require("path");
|
|
60920
|
+
return path40.join(os29.homedir(), ".adhdev", "providers", ".upstream");
|
|
60692
60921
|
}
|
|
60693
60922
|
/**
|
|
60694
60923
|
* Download a single provider manifest from the registry and write it to
|
|
60695
|
-
* ~/.adhdev/
|
|
60924
|
+
* ~/.adhdev/providers/.upstream/{category}/{type}/provider.json.
|
|
60696
60925
|
*
|
|
60697
|
-
* Used by
|
|
60698
|
-
*
|
|
60699
|
-
* the
|
|
60926
|
+
* Used by standalone onboarding to seed the upstream cache with the
|
|
60927
|
+
* default provider set on first launch. Verifies SHA-256 checksum
|
|
60928
|
+
* against the registry meta before persisting. Refuses to write
|
|
60929
|
+
* outside the upstream root.
|
|
60700
60930
|
*
|
|
60701
60931
|
* Args: { type: string, category?: string, version?: string }
|
|
60702
60932
|
* If category/version are omitted, looks up the latest from the registry.
|
|
@@ -60711,8 +60941,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
60711
60941
|
return { success: false, error: "invalid type" };
|
|
60712
60942
|
}
|
|
60713
60943
|
const https = require("https");
|
|
60714
|
-
const
|
|
60715
|
-
const
|
|
60944
|
+
const fs28 = require("fs");
|
|
60945
|
+
const path40 = require("path");
|
|
60716
60946
|
const crypto6 = require("crypto");
|
|
60717
60947
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
60718
60948
|
function fetchText(url2, timeoutMs) {
|
|
@@ -60749,13 +60979,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
60749
60979
|
if (actualChecksum !== meta3.checksum) {
|
|
60750
60980
|
return { success: false, error: `checksum mismatch: expected ${meta3.checksum}, got ${actualChecksum}` };
|
|
60751
60981
|
}
|
|
60752
|
-
const installRoot = this.
|
|
60753
|
-
const installRootResolved =
|
|
60754
|
-
const targetDir =
|
|
60755
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
60756
|
-
return { success: false, error: "install path escaped
|
|
60982
|
+
const installRoot = this.getUpstreamInstallRoot();
|
|
60983
|
+
const installRootResolved = path40.resolve(installRoot);
|
|
60984
|
+
const targetDir = path40.resolve(path40.join(installRoot, category, type));
|
|
60985
|
+
if (!targetDir.startsWith(installRootResolved + path40.sep)) {
|
|
60986
|
+
return { success: false, error: "install path escaped upstream root" };
|
|
60757
60987
|
}
|
|
60758
|
-
|
|
60988
|
+
fs28.mkdirSync(targetDir, { recursive: true });
|
|
60759
60989
|
let manifestProbe = {};
|
|
60760
60990
|
try {
|
|
60761
60991
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -60779,8 +61009,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60779
61009
|
}
|
|
60780
61010
|
}
|
|
60781
61011
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
60782
|
-
const targetPath =
|
|
60783
|
-
|
|
61012
|
+
const targetPath = path40.join(targetDir, targetFile);
|
|
61013
|
+
fs28.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
60784
61014
|
const manifestJson = JSON.parse(manifestBody);
|
|
60785
61015
|
const scriptFetch = await this.fetchProviderSources(
|
|
60786
61016
|
manifestJson,
|
|
@@ -60828,6 +61058,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60828
61058
|
if (Array.isArray(manifest.compatibility)) {
|
|
60829
61059
|
for (const c of manifest.compatibility) {
|
|
60830
61060
|
if (typeof c?.scriptDir === "string") scriptDirs.add(c.scriptDir);
|
|
61061
|
+
if (typeof c?.spec === "string" && c.spec.includes("/")) {
|
|
61062
|
+
const dir = c.spec.substring(0, c.spec.lastIndexOf("/"));
|
|
61063
|
+
if (dir) scriptDirs.add(dir);
|
|
61064
|
+
}
|
|
60831
61065
|
}
|
|
60832
61066
|
}
|
|
60833
61067
|
if (manifest.overrides && typeof manifest.overrides === "object" && !Array.isArray(manifest.overrides)) {
|
|
@@ -60846,8 +61080,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60846
61080
|
const repo = source.repo;
|
|
60847
61081
|
const ref = source.ref;
|
|
60848
61082
|
const https = require("https");
|
|
60849
|
-
const
|
|
60850
|
-
const
|
|
61083
|
+
const fs28 = require("fs");
|
|
61084
|
+
const path40 = require("path");
|
|
60851
61085
|
function fetchJson(url2, timeoutMs) {
|
|
60852
61086
|
return new Promise((resolve23, reject) => {
|
|
60853
61087
|
const req = https.get(url2, {
|
|
@@ -60903,9 +61137,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60903
61137
|
}
|
|
60904
61138
|
let fetchedCount = 0;
|
|
60905
61139
|
const sharedDirRel = `${category}/_shared`;
|
|
60906
|
-
const sharedTargetDir =
|
|
60907
|
-
const installRootResolved =
|
|
60908
|
-
if (sharedTargetDir.startsWith(installRootResolved +
|
|
61140
|
+
const sharedTargetDir = path40.resolve(path40.join(targetDir, "../_shared"));
|
|
61141
|
+
const installRootResolved = path40.resolve(path40.join(targetDir, "../.."));
|
|
61142
|
+
if (sharedTargetDir.startsWith(installRootResolved + path40.sep)) {
|
|
60909
61143
|
const sharedStack = [sharedDirRel];
|
|
60910
61144
|
while (sharedStack.length) {
|
|
60911
61145
|
const relDir = sharedStack.pop();
|
|
@@ -60928,10 +61162,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60928
61162
|
try {
|
|
60929
61163
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
60930
61164
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
60931
|
-
const outPath =
|
|
60932
|
-
if (!outPath.startsWith(
|
|
60933
|
-
|
|
60934
|
-
|
|
61165
|
+
const outPath = path40.resolve(path40.join(sharedTargetDir, relInside));
|
|
61166
|
+
if (!outPath.startsWith(path40.resolve(sharedTargetDir) + path40.sep)) continue;
|
|
61167
|
+
fs28.mkdirSync(path40.dirname(outPath), { recursive: true });
|
|
61168
|
+
fs28.writeFileSync(outPath, body);
|
|
60935
61169
|
fetchedCount++;
|
|
60936
61170
|
} catch (e) {
|
|
60937
61171
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -60964,13 +61198,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60964
61198
|
try {
|
|
60965
61199
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
60966
61200
|
const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
|
|
60967
|
-
const outPath =
|
|
60968
|
-
if (!outPath.startsWith(
|
|
61201
|
+
const outPath = path40.resolve(path40.join(targetDir, relInsideProvider));
|
|
61202
|
+
if (!outPath.startsWith(path40.resolve(targetDir) + path40.sep)) {
|
|
60969
61203
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
60970
61204
|
continue;
|
|
60971
61205
|
}
|
|
60972
|
-
|
|
60973
|
-
|
|
61206
|
+
fs28.mkdirSync(path40.dirname(outPath), { recursive: true });
|
|
61207
|
+
fs28.writeFileSync(outPath, body);
|
|
60974
61208
|
fetchedCount++;
|
|
60975
61209
|
} catch (e) {
|
|
60976
61210
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -60981,9 +61215,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60981
61215
|
return { fetchedCount, source: `${repo}@${ref}`, errors };
|
|
60982
61216
|
}
|
|
60983
61217
|
/**
|
|
60984
|
-
* Remove a provider manifest from the
|
|
60985
|
-
* (~/.adhdev/
|
|
60986
|
-
* outside that root.
|
|
61218
|
+
* Remove a provider manifest from the upstream cache root
|
|
61219
|
+
* (~/.adhdev/providers/.upstream/{category}/{type}/). Refuses to touch
|
|
61220
|
+
* anything outside that root. Used by onboarding to opt out of a
|
|
61221
|
+
* provider the user doesn't want; the dashboard no longer exposes a
|
|
61222
|
+
* per-provider uninstall button (external sources are removed as a
|
|
61223
|
+
* whole via remove_provider_source).
|
|
60987
61224
|
*/
|
|
60988
61225
|
async handleUninstallProviderManifest(args) {
|
|
60989
61226
|
const type = typeof args?.type === "string" ? args.type : "";
|
|
@@ -60995,19 +61232,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
60995
61232
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
60996
61233
|
return { success: false, error: `unknown category: ${category}` };
|
|
60997
61234
|
}
|
|
60998
|
-
const
|
|
60999
|
-
const
|
|
61235
|
+
const fs28 = require("fs");
|
|
61236
|
+
const path40 = require("path");
|
|
61000
61237
|
try {
|
|
61001
|
-
const installRoot = this.
|
|
61002
|
-
const installRootResolved =
|
|
61003
|
-
const targetDir =
|
|
61004
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
61005
|
-
return { success: false, error: "refusing to delete outside
|
|
61238
|
+
const installRoot = this.getUpstreamInstallRoot();
|
|
61239
|
+
const installRootResolved = path40.resolve(installRoot);
|
|
61240
|
+
const targetDir = path40.resolve(path40.join(installRoot, category, type));
|
|
61241
|
+
if (!targetDir.startsWith(installRootResolved + path40.sep)) {
|
|
61242
|
+
return { success: false, error: "refusing to delete outside upstream root" };
|
|
61006
61243
|
}
|
|
61007
|
-
if (!
|
|
61244
|
+
if (!fs28.existsSync(targetDir)) {
|
|
61008
61245
|
return { success: false, error: "not installed" };
|
|
61009
61246
|
}
|
|
61010
|
-
|
|
61247
|
+
fs28.rmSync(targetDir, { recursive: true, force: true });
|
|
61011
61248
|
if (this._ctx.providerLoader) {
|
|
61012
61249
|
this._ctx.providerLoader.reload();
|
|
61013
61250
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -61018,33 +61255,33 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61018
61255
|
}
|
|
61019
61256
|
}
|
|
61020
61257
|
/**
|
|
61021
|
-
* Return everything currently installed in
|
|
61258
|
+
* Return everything currently installed in the upstream cache with its
|
|
61022
61259
|
* version. This is the "what does this daemon have" answer used both by
|
|
61023
61260
|
* the UI and by the update checker.
|
|
61024
61261
|
*/
|
|
61025
61262
|
handleListInstalledProviders(_args) {
|
|
61026
|
-
const
|
|
61027
|
-
const
|
|
61028
|
-
const installRoot = this.
|
|
61029
|
-
if (!
|
|
61263
|
+
const fs28 = require("fs");
|
|
61264
|
+
const path40 = require("path");
|
|
61265
|
+
const installRoot = this.getUpstreamInstallRoot();
|
|
61266
|
+
if (!fs28.existsSync(installRoot)) return { success: true, providers: [] };
|
|
61030
61267
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
61031
61268
|
const items = [];
|
|
61032
61269
|
for (const category of CATEGORIES) {
|
|
61033
|
-
const categoryDir =
|
|
61034
|
-
if (!
|
|
61270
|
+
const categoryDir = path40.join(installRoot, category);
|
|
61271
|
+
if (!fs28.existsSync(categoryDir)) continue;
|
|
61035
61272
|
let entries;
|
|
61036
61273
|
try {
|
|
61037
|
-
entries =
|
|
61274
|
+
entries = fs28.readdirSync(categoryDir);
|
|
61038
61275
|
} catch {
|
|
61039
61276
|
continue;
|
|
61040
61277
|
}
|
|
61041
61278
|
for (const type of entries) {
|
|
61042
|
-
const v1Path =
|
|
61043
|
-
const v0Path =
|
|
61044
|
-
const manifestPath =
|
|
61279
|
+
const v1Path = path40.join(categoryDir, type, "provider.v1.json");
|
|
61280
|
+
const v0Path = path40.join(categoryDir, type, "provider.json");
|
|
61281
|
+
const manifestPath = fs28.existsSync(v1Path) ? v1Path : fs28.existsSync(v0Path) ? v0Path : null;
|
|
61045
61282
|
if (!manifestPath) continue;
|
|
61046
61283
|
try {
|
|
61047
|
-
const m = JSON.parse(
|
|
61284
|
+
const m = JSON.parse(fs28.readFileSync(manifestPath, "utf-8"));
|
|
61048
61285
|
items.push({
|
|
61049
61286
|
type,
|
|
61050
61287
|
category,
|
|
@@ -61121,6 +61358,196 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61121
61358
|
);
|
|
61122
61359
|
return { success: true, providers: checks };
|
|
61123
61360
|
}
|
|
61361
|
+
// ─── External provider sources (3rd-party git URLs) ──────────────
|
|
61362
|
+
/**
|
|
61363
|
+
* Register a new external provider source. The daemon clones the repo
|
|
61364
|
+
* to ~/.adhdev/external/<name>/, walks it once to detect provided
|
|
61365
|
+
* types, and surfaces any conflicts with already-installed types so
|
|
61366
|
+
* the dashboard can ask the user how to resolve them.
|
|
61367
|
+
*
|
|
61368
|
+
* Args: { url: string, ref?: string, name?: string }
|
|
61369
|
+
* - url: https://, git@, or any git-cloneable URL
|
|
61370
|
+
* - ref: branch/tag/commit (default "main")
|
|
61371
|
+
* - name: short identifier (default derived from URL)
|
|
61372
|
+
*
|
|
61373
|
+
* Returns: { source, providers, conflicts }
|
|
61374
|
+
* - conflicts: list of types this new source provides that another
|
|
61375
|
+
* source already exposes. UI uses this to prompt for active-source
|
|
61376
|
+
* selection before the load takes effect.
|
|
61377
|
+
*/
|
|
61378
|
+
async handleAddProviderSource(args) {
|
|
61379
|
+
const url2 = typeof args?.url === "string" ? args.url.trim() : "";
|
|
61380
|
+
if (!url2) return { success: false, error: "url is required" };
|
|
61381
|
+
const ref = typeof args?.ref === "string" && args.ref.trim() ? args.ref.trim() : "main";
|
|
61382
|
+
if (url2.startsWith("-")) return { success: false, error: 'url must not start with "-"' };
|
|
61383
|
+
if (ref.startsWith("-")) return { success: false, error: 'ref must not start with "-"' };
|
|
61384
|
+
if (!/^(https?:\/\/|git@[a-z0-9._-]+:)[a-z0-9._@:/~\-]+$/i.test(url2)) {
|
|
61385
|
+
return { success: false, error: "url must be https://\u2026 or git@host:\u2026 and contain only URL-safe characters" };
|
|
61386
|
+
}
|
|
61387
|
+
if (!/^[A-Za-z0-9._/-]+$/.test(ref)) {
|
|
61388
|
+
return { success: false, error: "ref must contain only [A-Za-z0-9._/-]" };
|
|
61389
|
+
}
|
|
61390
|
+
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
61391
|
+
const requestedName = typeof args?.name === "string" && args.name.trim() ? args.name.trim() : ext.deriveSourceName(url2);
|
|
61392
|
+
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
61393
|
+
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
61394
|
+
}
|
|
61395
|
+
const fs28 = require("fs");
|
|
61396
|
+
const path40 = require("path");
|
|
61397
|
+
const { spawnSync: spawnSync2 } = require("child_process");
|
|
61398
|
+
const file2 = ext.loadExternalSources();
|
|
61399
|
+
if (file2.sources.some((s) => s.name === requestedName)) {
|
|
61400
|
+
return { success: false, error: `source name "${requestedName}" is already registered` };
|
|
61401
|
+
}
|
|
61402
|
+
if (file2.sources.some((s) => s.url === url2 && s.ref === ref)) {
|
|
61403
|
+
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
61404
|
+
}
|
|
61405
|
+
const sourceDir = path40.join(ext.externalRoot(), requestedName);
|
|
61406
|
+
if (!fs28.existsSync(ext.externalRoot())) fs28.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
61407
|
+
if (fs28.existsSync(sourceDir)) {
|
|
61408
|
+
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
61409
|
+
}
|
|
61410
|
+
const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
61411
|
+
encoding: "utf-8",
|
|
61412
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
61413
|
+
timeout: 6e4
|
|
61414
|
+
});
|
|
61415
|
+
if (clone2.status !== 0) {
|
|
61416
|
+
try {
|
|
61417
|
+
fs28.rmSync(sourceDir, { recursive: true, force: true });
|
|
61418
|
+
} catch {
|
|
61419
|
+
}
|
|
61420
|
+
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
61421
|
+
}
|
|
61422
|
+
const source = {
|
|
61423
|
+
name: requestedName,
|
|
61424
|
+
url: url2,
|
|
61425
|
+
ref,
|
|
61426
|
+
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
61427
|
+
};
|
|
61428
|
+
ext.saveExternalSources({ schema: 1, sources: [...file2.sources, source] });
|
|
61429
|
+
const inventory = ext.inventoryExternalSources();
|
|
61430
|
+
const conflicts = [];
|
|
61431
|
+
const newEntry = inventory.find((e) => e.sourceName === requestedName);
|
|
61432
|
+
if (newEntry) {
|
|
61433
|
+
for (const [category, types] of Object.entries(newEntry.providers)) {
|
|
61434
|
+
for (const type of types) {
|
|
61435
|
+
const sources = ext.sourcesProviding(category, type);
|
|
61436
|
+
if (sources.length > 1) conflicts.push({ category, type, sources });
|
|
61437
|
+
}
|
|
61438
|
+
}
|
|
61439
|
+
}
|
|
61440
|
+
if (this._ctx.providerLoader) {
|
|
61441
|
+
this._ctx.providerLoader.reload();
|
|
61442
|
+
this._ctx.providerLoader.registerToDetector();
|
|
61443
|
+
}
|
|
61444
|
+
return {
|
|
61445
|
+
success: true,
|
|
61446
|
+
source,
|
|
61447
|
+
providers: newEntry?.providers ?? {},
|
|
61448
|
+
conflicts
|
|
61449
|
+
};
|
|
61450
|
+
}
|
|
61451
|
+
/**
|
|
61452
|
+
* Remove a registered external source. Deletes the clone directory and
|
|
61453
|
+
* any active-source entry pointing to it.
|
|
61454
|
+
*
|
|
61455
|
+
* Args: { name: string }
|
|
61456
|
+
*/
|
|
61457
|
+
async handleRemoveProviderSource(args) {
|
|
61458
|
+
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
61459
|
+
if (!name) return { success: false, error: "name is required" };
|
|
61460
|
+
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
61461
|
+
const fs28 = require("fs");
|
|
61462
|
+
const path40 = require("path");
|
|
61463
|
+
const file2 = ext.loadExternalSources();
|
|
61464
|
+
const match = file2.sources.find((s) => s.name === name);
|
|
61465
|
+
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
61466
|
+
const sourceDir = path40.join(ext.externalRoot(), name);
|
|
61467
|
+
if (fs28.existsSync(sourceDir)) {
|
|
61468
|
+
try {
|
|
61469
|
+
fs28.rmSync(sourceDir, { recursive: true, force: true });
|
|
61470
|
+
} catch (e) {
|
|
61471
|
+
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
61472
|
+
}
|
|
61473
|
+
}
|
|
61474
|
+
ext.saveExternalSources({
|
|
61475
|
+
schema: 1,
|
|
61476
|
+
sources: file2.sources.filter((s) => s.name !== name)
|
|
61477
|
+
});
|
|
61478
|
+
const active = ext.loadProvidersActive();
|
|
61479
|
+
const filteredActive = {};
|
|
61480
|
+
for (const [type, src] of Object.entries(active.active)) {
|
|
61481
|
+
if (src !== name) filteredActive[type] = src;
|
|
61482
|
+
}
|
|
61483
|
+
ext.saveProvidersActive({ schema: 1, active: filteredActive });
|
|
61484
|
+
if (this._ctx.providerLoader) {
|
|
61485
|
+
this._ctx.providerLoader.reload();
|
|
61486
|
+
this._ctx.providerLoader.registerToDetector();
|
|
61487
|
+
}
|
|
61488
|
+
return { success: true, removed: { name } };
|
|
61489
|
+
}
|
|
61490
|
+
/**
|
|
61491
|
+
* List registered external sources + each source's currently installed
|
|
61492
|
+
* providers + the active selection for any conflicting types. Used by
|
|
61493
|
+
* the dashboard's "Sources" tab.
|
|
61494
|
+
*/
|
|
61495
|
+
handleListProviderSources(_args) {
|
|
61496
|
+
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
61497
|
+
const file2 = ext.loadExternalSources();
|
|
61498
|
+
const inventory = ext.inventoryExternalSources();
|
|
61499
|
+
const active = ext.loadProvidersActive();
|
|
61500
|
+
const sources = file2.sources.map((s) => {
|
|
61501
|
+
const inv = inventory.find((e) => e.sourceName === s.name);
|
|
61502
|
+
return {
|
|
61503
|
+
...s,
|
|
61504
|
+
providers: inv?.providers ?? {}
|
|
61505
|
+
};
|
|
61506
|
+
});
|
|
61507
|
+
const conflictMap = /* @__PURE__ */ new Map();
|
|
61508
|
+
for (const inv of inventory) {
|
|
61509
|
+
for (const [category, types] of Object.entries(inv.providers)) {
|
|
61510
|
+
for (const type of types) {
|
|
61511
|
+
const candidates = ext.sourcesProviding(category, type);
|
|
61512
|
+
if (candidates.length > 1 && !conflictMap.has(type)) {
|
|
61513
|
+
conflictMap.set(type, { category, sources: candidates });
|
|
61514
|
+
}
|
|
61515
|
+
}
|
|
61516
|
+
}
|
|
61517
|
+
}
|
|
61518
|
+
const conflicts = [...conflictMap.entries()].map(([type, info]) => ({
|
|
61519
|
+
type,
|
|
61520
|
+
category: info.category,
|
|
61521
|
+
candidates: info.sources,
|
|
61522
|
+
active: active.active[type] ?? null
|
|
61523
|
+
}));
|
|
61524
|
+
return { success: true, sources, conflicts };
|
|
61525
|
+
}
|
|
61526
|
+
/**
|
|
61527
|
+
* Pick which source's copy of a conflicting provider type is active.
|
|
61528
|
+
* Other sources' copies stay on disk but the loader ignores them.
|
|
61529
|
+
*
|
|
61530
|
+
* Args: { type: string, sourceName: string }
|
|
61531
|
+
*/
|
|
61532
|
+
handleSetActiveProviderSource(args) {
|
|
61533
|
+
const type = typeof args?.type === "string" ? args.type.trim() : "";
|
|
61534
|
+
const sourceName = typeof args?.sourceName === "string" ? args.sourceName.trim() : "";
|
|
61535
|
+
if (!type || !sourceName) return { success: false, error: "type and sourceName are required" };
|
|
61536
|
+
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
61537
|
+
const inventory = ext.inventoryExternalSources();
|
|
61538
|
+
const entry = inventory.find((e) => e.sourceName === sourceName);
|
|
61539
|
+
if (!entry) return { success: false, error: `source "${sourceName}" not found` };
|
|
61540
|
+
const provided = Object.values(entry.providers).some((types) => types.includes(type));
|
|
61541
|
+
if (!provided) return { success: false, error: `source "${sourceName}" does not provide type "${type}"` };
|
|
61542
|
+
const active = ext.loadProvidersActive();
|
|
61543
|
+
active.active[type] = sourceName;
|
|
61544
|
+
ext.saveProvidersActive(active);
|
|
61545
|
+
if (this._ctx.providerLoader) {
|
|
61546
|
+
this._ctx.providerLoader.reload();
|
|
61547
|
+
this._ctx.providerLoader.registerToDetector();
|
|
61548
|
+
}
|
|
61549
|
+
return { success: true, type, sourceName };
|
|
61550
|
+
}
|
|
61124
61551
|
// ─── DevServer HTTP proxy helpers ─────────────────
|
|
61125
61552
|
// These bridge WS commands to the DevServer REST API (localhost:19280)
|
|
61126
61553
|
async proxyDevServerPost(args, endpoint) {
|
|
@@ -61211,8 +61638,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61211
61638
|
}
|
|
61212
61639
|
}
|
|
61213
61640
|
};
|
|
61214
|
-
var
|
|
61215
|
-
var
|
|
61641
|
+
var os17 = __toESM2(require("os"));
|
|
61642
|
+
var path232 = __toESM2(require("path"));
|
|
61216
61643
|
var crypto5 = __toESM2(require("crypto"));
|
|
61217
61644
|
var import_fs12 = require("fs");
|
|
61218
61645
|
var import_child_process5 = require("child_process");
|
|
@@ -61220,17 +61647,17 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61220
61647
|
init_provider_cli_adapter();
|
|
61221
61648
|
init_cli_detector();
|
|
61222
61649
|
init_config();
|
|
61223
|
-
var
|
|
61224
|
-
var
|
|
61650
|
+
var os16 = __toESM2(require("os"));
|
|
61651
|
+
var path21 = __toESM2(require("path"));
|
|
61225
61652
|
var crypto4 = __toESM2(require("crypto"));
|
|
61226
|
-
var
|
|
61653
|
+
var fs12 = __toESM2(require("fs"));
|
|
61227
61654
|
var import_node_module = require("module");
|
|
61655
|
+
var fs11 = __toESM2(require("fs"));
|
|
61656
|
+
var path20 = __toESM2(require("path"));
|
|
61657
|
+
init_provider_cli_adapter();
|
|
61228
61658
|
var fs10 = __toESM2(require("fs"));
|
|
61659
|
+
var os15 = __toESM2(require("os"));
|
|
61229
61660
|
var path19 = __toESM2(require("path"));
|
|
61230
|
-
init_provider_cli_adapter();
|
|
61231
|
-
var fs9 = __toESM2(require("fs"));
|
|
61232
|
-
var os14 = __toESM2(require("os"));
|
|
61233
|
-
var path18 = __toESM2(require("path"));
|
|
61234
61661
|
var xtermHeadlessNs = __toESM2(require_xterm_headless());
|
|
61235
61662
|
init_pty_transport();
|
|
61236
61663
|
var TerminalCtor2 = xtermHeadlessNs.Terminal ?? xtermHeadlessNs.default?.Terminal;
|
|
@@ -61601,7 +62028,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61601
62028
|
}
|
|
61602
62029
|
armSpecWatcher() {
|
|
61603
62030
|
try {
|
|
61604
|
-
this.specWatcher =
|
|
62031
|
+
this.specWatcher = fs10.watch(this.opts.specPath, { persistent: false }, () => {
|
|
61605
62032
|
const res = loadSpec(this.opts.specPath);
|
|
61606
62033
|
if (!res.ok) {
|
|
61607
62034
|
this.emit({ kind: "spec_error", errors: res.errors });
|
|
@@ -61694,7 +62121,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61694
62121
|
}
|
|
61695
62122
|
fireDelegate(d) {
|
|
61696
62123
|
const ev = this.currentEval;
|
|
61697
|
-
const task = d.task_template.replace(/\{node\}/g,
|
|
62124
|
+
const task = d.task_template.replace(/\{node\}/g, os15.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
|
|
61698
62125
|
this.emit({ kind: "delegate", id: d.id, task });
|
|
61699
62126
|
}
|
|
61700
62127
|
// ────────────────────────────────────────────────────────────────────
|
|
@@ -61763,9 +62190,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61763
62190
|
const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
|
|
61764
62191
|
if (!ctl || ctl.action.type !== "attach_image") return;
|
|
61765
62192
|
const ext = guessExt(mime);
|
|
61766
|
-
const tmp =
|
|
62193
|
+
const tmp = path19.join(os15.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
61767
62194
|
try {
|
|
61768
|
-
|
|
62195
|
+
fs10.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
61769
62196
|
} catch {
|
|
61770
62197
|
return;
|
|
61771
62198
|
}
|
|
@@ -61832,6 +62259,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
61832
62259
|
cliType;
|
|
61833
62260
|
cliName;
|
|
61834
62261
|
workingDir;
|
|
62262
|
+
/**
|
|
62263
|
+
* Marker the daemon's finalization gate checks: `getStatus()` returns
|
|
62264
|
+
* `messages: []` by design here (chat history lives in the daemon's
|
|
62265
|
+
* native-history pipeline, not the adapter). Without this flag,
|
|
62266
|
+
* cli-provider-instance's `missing_final_assistant` gate would stall
|
|
62267
|
+
* every turn until the 30s safety timeout because it expects the
|
|
62268
|
+
* adapter to surface the final assistant message.
|
|
62269
|
+
*/
|
|
62270
|
+
chatMessagesOwnedExternally = true;
|
|
61835
62271
|
driver;
|
|
61836
62272
|
spec;
|
|
61837
62273
|
lastEvent = null;
|
|
@@ -62080,14 +62516,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62080
62516
|
function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory) {
|
|
62081
62517
|
const resolvedSpecPath = provider._resolvedSpecPath;
|
|
62082
62518
|
const dir = provider._resolvedProviderDir;
|
|
62083
|
-
let specPath = resolvedSpecPath &&
|
|
62519
|
+
let specPath = resolvedSpecPath && fs11.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
62084
62520
|
if (!specPath && dir) {
|
|
62085
|
-
const legacy =
|
|
62086
|
-
if (
|
|
62521
|
+
const legacy = path20.join(dir, "spec.json");
|
|
62522
|
+
if (fs11.existsSync(legacy)) specPath = legacy;
|
|
62087
62523
|
}
|
|
62088
62524
|
if (specPath) {
|
|
62089
62525
|
try {
|
|
62090
|
-
LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${
|
|
62526
|
+
LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path20.relative(dir || "", specPath) || specPath})`);
|
|
62091
62527
|
return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
|
|
62092
62528
|
} catch (err) {
|
|
62093
62529
|
LOG2.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
|
|
@@ -62142,7 +62578,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62142
62578
|
return uri.slice("file://".length);
|
|
62143
62579
|
}
|
|
62144
62580
|
}
|
|
62145
|
-
if (
|
|
62581
|
+
if (path21.isAbsolute(uri)) return uri;
|
|
62146
62582
|
return null;
|
|
62147
62583
|
}
|
|
62148
62584
|
function extensionForImageMime(mimeType) {
|
|
@@ -62157,9 +62593,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62157
62593
|
if (!part.data) return null;
|
|
62158
62594
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
62159
62595
|
if (!rawData) return null;
|
|
62160
|
-
|
|
62161
|
-
const filePath =
|
|
62162
|
-
|
|
62596
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
62597
|
+
const filePath = path21.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
62598
|
+
fs12.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
62163
62599
|
cleanupStaleMaterializedImages(dir);
|
|
62164
62600
|
return filePath;
|
|
62165
62601
|
}
|
|
@@ -62171,14 +62607,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62171
62607
|
if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
|
|
62172
62608
|
lastMaterializedImageCleanupAt = now;
|
|
62173
62609
|
try {
|
|
62174
|
-
const entries =
|
|
62610
|
+
const entries = fs12.readdirSync(dir);
|
|
62175
62611
|
for (const entry of entries) {
|
|
62176
62612
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
62177
|
-
const fullPath =
|
|
62613
|
+
const fullPath = path21.join(dir, entry);
|
|
62178
62614
|
try {
|
|
62179
|
-
const stat2 =
|
|
62615
|
+
const stat2 = fs12.statSync(fullPath);
|
|
62180
62616
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
62181
|
-
|
|
62617
|
+
fs12.unlinkSync(fullPath);
|
|
62182
62618
|
}
|
|
62183
62619
|
} catch {
|
|
62184
62620
|
}
|
|
@@ -62197,7 +62633,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62197
62633
|
const promptParts = [];
|
|
62198
62634
|
const imageRefs = [];
|
|
62199
62635
|
const resourceRefs = [];
|
|
62200
|
-
const materializeDir = options.materializeDir ||
|
|
62636
|
+
const materializeDir = options.materializeDir || path21.join(os16.tmpdir(), "adhdev-input-media");
|
|
62201
62637
|
input.parts.forEach((part, index) => {
|
|
62202
62638
|
if (part.type === "text" && part.text.trim()) {
|
|
62203
62639
|
promptParts.push(part.text.trim());
|
|
@@ -62264,7 +62700,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62264
62700
|
var CachedDatabaseSync = null;
|
|
62265
62701
|
function getDatabaseSync() {
|
|
62266
62702
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
62267
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
62703
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path21.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
62268
62704
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
62269
62705
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
62270
62706
|
if (!CachedDatabaseSync) {
|
|
@@ -62418,10 +62854,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62418
62854
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
62419
62855
|
*/
|
|
62420
62856
|
probeSessionIdFromConfig(probe) {
|
|
62421
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
62857
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os16.homedir());
|
|
62422
62858
|
const now = Date.now();
|
|
62423
62859
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
62424
|
-
if (!
|
|
62860
|
+
if (!fs12.existsSync(resolvedDbPath)) {
|
|
62425
62861
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
62426
62862
|
return null;
|
|
62427
62863
|
}
|
|
@@ -62807,7 +63243,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62807
63243
|
return { reason: `parsed_status:${parsedStatus}`, terminal: isCliGeneratingLikeStatus(parsedStatus) };
|
|
62808
63244
|
}
|
|
62809
63245
|
if (parsed?.activeModal || parsed?.modal) return { reason: "parsed_modal_active", terminal: true };
|
|
62810
|
-
|
|
63246
|
+
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
63247
|
+
if (!adapterOwnsMessagesElsewhere && !this.completionHasFinalAssistantMessage(parsed?.messages)) {
|
|
63248
|
+
return { reason: "missing_final_assistant" };
|
|
63249
|
+
}
|
|
62811
63250
|
try {
|
|
62812
63251
|
const screenText = typeof this.adapter.getScreenText === "function" ? String(this.adapter.getScreenText() || "") : "";
|
|
62813
63252
|
if (screenText) {
|
|
@@ -63520,7 +63959,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
63520
63959
|
};
|
|
63521
63960
|
addDir(this.workingDir);
|
|
63522
63961
|
try {
|
|
63523
|
-
addDir(
|
|
63962
|
+
addDir(fs12.realpathSync.native(this.workingDir));
|
|
63524
63963
|
} catch {
|
|
63525
63964
|
}
|
|
63526
63965
|
return Array.from(dirs);
|
|
@@ -63555,7 +63994,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
63555
63994
|
}
|
|
63556
63995
|
}
|
|
63557
63996
|
};
|
|
63558
|
-
var
|
|
63997
|
+
var path222 = __toESM2(require("path"));
|
|
63559
63998
|
var import_stream = require("stream");
|
|
63560
63999
|
var import_child_process4 = require("child_process");
|
|
63561
64000
|
var import_sdk = (init_acp(), __toCommonJS(acp_exports));
|
|
@@ -64330,7 +64769,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
64330
64769
|
return b.uri ? {
|
|
64331
64770
|
type: "resource_link",
|
|
64332
64771
|
uri: b.uri,
|
|
64333
|
-
name:
|
|
64772
|
+
name: path222.basename(b.uri),
|
|
64334
64773
|
mimeType: b.mimeType,
|
|
64335
64774
|
...b.transcript ? { description: b.transcript } : {}
|
|
64336
64775
|
} : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
|
|
@@ -64782,11 +65221,11 @@ ${rawInput}` : rawInput;
|
|
|
64782
65221
|
}
|
|
64783
65222
|
function isExplicitCommand(command) {
|
|
64784
65223
|
const trimmed = command.trim();
|
|
64785
|
-
return
|
|
65224
|
+
return path232.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
64786
65225
|
}
|
|
64787
65226
|
function expandExecutable(command) {
|
|
64788
65227
|
const trimmed = command.trim();
|
|
64789
|
-
return trimmed.startsWith("~") ?
|
|
65228
|
+
return trimmed.startsWith("~") ? path232.join(os17.homedir(), trimmed.slice(1)) : trimmed;
|
|
64790
65229
|
}
|
|
64791
65230
|
function commandExists(command) {
|
|
64792
65231
|
const trimmed = command.trim();
|
|
@@ -64913,10 +65352,10 @@ ${rawInput}` : rawInput;
|
|
|
64913
65352
|
return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
64914
65353
|
}
|
|
64915
65354
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
64916
|
-
const baseDir =
|
|
65355
|
+
const baseDir = path232.join(os17.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
64917
65356
|
(0, import_fs12.mkdirSync)(baseDir, { recursive: true });
|
|
64918
|
-
const workspaceHash = crypto5.createHash("sha256").update(
|
|
64919
|
-
const filePath =
|
|
65357
|
+
const workspaceHash = crypto5.createHash("sha256").update(path232.resolve(workspace || os17.tmpdir())).digest("hex").slice(0, 16);
|
|
65358
|
+
const filePath = path232.join(baseDir, `${workspaceHash}.json`);
|
|
64920
65359
|
(0, import_fs12.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
64921
65360
|
return filePath;
|
|
64922
65361
|
}
|
|
@@ -65210,7 +65649,7 @@ ${rawInput}` : rawInput;
|
|
|
65210
65649
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
65211
65650
|
const trimmed = (workingDir || "").trim();
|
|
65212
65651
|
if (!trimmed) throw new Error("working directory required");
|
|
65213
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
65652
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os17.homedir()) : path232.resolve(trimmed);
|
|
65214
65653
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
65215
65654
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
65216
65655
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -65595,6 +66034,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
65595
66034
|
cliArgs: args?.cliArgs,
|
|
65596
66035
|
env: args?.env
|
|
65597
66036
|
}) : null;
|
|
66037
|
+
const provLookup = this.providerLoader.getMeta(this.providerLoader.resolveAlias(cliType));
|
|
66038
|
+
const provTrust = provLookup?._sourceTrust;
|
|
66039
|
+
if (provTrust === "external-untrusted" && args?.confirmExternalUntrusted !== true) {
|
|
66040
|
+
return {
|
|
66041
|
+
success: false,
|
|
66042
|
+
error: "untrusted_external_provider",
|
|
66043
|
+
provider: {
|
|
66044
|
+
type: provLookup?.type ?? cliType,
|
|
66045
|
+
sourceName: provLookup?._sourceName ?? null,
|
|
66046
|
+
trust: provTrust
|
|
66047
|
+
},
|
|
66048
|
+
hint: "Resend launch_cli with confirmExternalUntrusted=true after the user explicitly approves running JavaScript from this 3rd-party source."
|
|
66049
|
+
};
|
|
66050
|
+
}
|
|
65598
66051
|
const started = await this.startSession(
|
|
65599
66052
|
cliType,
|
|
65600
66053
|
dir,
|
|
@@ -65779,11 +66232,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
65779
66232
|
};
|
|
65780
66233
|
var import_child_process6 = require("child_process");
|
|
65781
66234
|
var net3 = __toESM2(require("net"));
|
|
65782
|
-
var
|
|
66235
|
+
var os23 = __toESM2(require("os"));
|
|
66236
|
+
var path322 = __toESM2(require("path"));
|
|
66237
|
+
var fs19 = __toESM2(require("fs"));
|
|
65783
66238
|
var path31 = __toESM2(require("path"));
|
|
65784
|
-
var
|
|
65785
|
-
var path30 = __toESM2(require("path"));
|
|
65786
|
-
var os21 = __toESM2(require("os"));
|
|
66239
|
+
var os222 = __toESM2(require("os"));
|
|
65787
66240
|
var chokidar = __toESM2(require_chokidar());
|
|
65788
66241
|
init_logger();
|
|
65789
66242
|
var VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
@@ -66152,9 +66605,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66152
66605
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
66153
66606
|
static looksLikeProviderRoot(candidate) {
|
|
66154
66607
|
try {
|
|
66155
|
-
if (!
|
|
66608
|
+
if (!fs19.existsSync(candidate) || !fs19.statSync(candidate).isDirectory()) return false;
|
|
66156
66609
|
return ["ide", "extension", "cli", "acp"].some(
|
|
66157
|
-
(category) =>
|
|
66610
|
+
(category) => fs19.existsSync(path31.join(candidate, category))
|
|
66158
66611
|
);
|
|
66159
66612
|
} catch {
|
|
66160
66613
|
return false;
|
|
@@ -66162,20 +66615,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66162
66615
|
}
|
|
66163
66616
|
static hasProviderRootMarker(candidate) {
|
|
66164
66617
|
try {
|
|
66165
|
-
return
|
|
66618
|
+
return fs19.existsSync(path31.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
66166
66619
|
} catch {
|
|
66167
66620
|
return false;
|
|
66168
66621
|
}
|
|
66169
66622
|
}
|
|
66170
66623
|
detectDefaultUserDir() {
|
|
66171
|
-
const fallback =
|
|
66624
|
+
const fallback = path31.join(os222.homedir(), ".adhdev", "providers");
|
|
66172
66625
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
66173
66626
|
const visited = /* @__PURE__ */ new Set();
|
|
66174
66627
|
for (const start of this.probeStarts) {
|
|
66175
|
-
let current =
|
|
66628
|
+
let current = path31.resolve(start);
|
|
66176
66629
|
while (!visited.has(current)) {
|
|
66177
66630
|
visited.add(current);
|
|
66178
|
-
const siblingCandidate =
|
|
66631
|
+
const siblingCandidate = path31.join(path31.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
66179
66632
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
66180
66633
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
66181
66634
|
if (envOptIn || hasMarker) {
|
|
@@ -66197,7 +66650,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66197
66650
|
return { path: siblingCandidate, source };
|
|
66198
66651
|
}
|
|
66199
66652
|
}
|
|
66200
|
-
const parent =
|
|
66653
|
+
const parent = path31.dirname(current);
|
|
66201
66654
|
if (parent === current) break;
|
|
66202
66655
|
current = parent;
|
|
66203
66656
|
}
|
|
@@ -66207,17 +66660,34 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66207
66660
|
constructor(options) {
|
|
66208
66661
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
66209
66662
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
66210
|
-
this.defaultProvidersDir =
|
|
66663
|
+
this.defaultProvidersDir = path31.join(os222.homedir(), ".adhdev", "providers");
|
|
66211
66664
|
const detected = this.detectDefaultUserDir();
|
|
66212
66665
|
this.userDir = detected.path;
|
|
66213
66666
|
this.userDirSource = detected.source;
|
|
66214
|
-
this.upstreamDir =
|
|
66667
|
+
this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
|
|
66215
66668
|
this.disableUpstream = false;
|
|
66216
66669
|
this.applySourceConfig({
|
|
66217
66670
|
userDir: options?.userDir,
|
|
66218
66671
|
sourceMode: options?.sourceMode,
|
|
66219
66672
|
disableUpstream: options?.disableUpstream
|
|
66220
66673
|
});
|
|
66674
|
+
this.migrateMarketplaceDirToExternal();
|
|
66675
|
+
}
|
|
66676
|
+
migrateMarketplaceDirToExternal() {
|
|
66677
|
+
try {
|
|
66678
|
+
const home = os222.homedir();
|
|
66679
|
+
const oldDir = path31.join(home, ".adhdev", "marketplace");
|
|
66680
|
+
const newDir = path31.join(home, ".adhdev", "external");
|
|
66681
|
+
if (!fs19.existsSync(oldDir)) return;
|
|
66682
|
+
if (fs19.existsSync(newDir)) {
|
|
66683
|
+
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
66684
|
+
return;
|
|
66685
|
+
}
|
|
66686
|
+
fs19.renameSync(oldDir, newDir);
|
|
66687
|
+
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
66688
|
+
} catch (e) {
|
|
66689
|
+
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
66690
|
+
}
|
|
66221
66691
|
}
|
|
66222
66692
|
log(msg) {
|
|
66223
66693
|
this.logFn(`[ProviderLoader] ${msg}`);
|
|
@@ -66243,8 +66713,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66243
66713
|
* Highest-priority editable overrides come first.
|
|
66244
66714
|
*/
|
|
66245
66715
|
getProviderRoots() {
|
|
66246
|
-
const
|
|
66247
|
-
return [this.userDir,
|
|
66716
|
+
const externalDir = path31.join(os222.homedir(), ".adhdev", "external");
|
|
66717
|
+
return [this.userDir, externalDir, this.upstreamDir];
|
|
66248
66718
|
}
|
|
66249
66719
|
getSourceConfig() {
|
|
66250
66720
|
return {
|
|
@@ -66271,7 +66741,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66271
66741
|
this.userDir = detected.path;
|
|
66272
66742
|
this.userDirSource = detected.source;
|
|
66273
66743
|
}
|
|
66274
|
-
this.upstreamDir =
|
|
66744
|
+
this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
|
|
66275
66745
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
66276
66746
|
if (this.explicitProviderDir) {
|
|
66277
66747
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -66285,7 +66755,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66285
66755
|
* Canonical provider directory shape for a given root.
|
|
66286
66756
|
*/
|
|
66287
66757
|
getProviderDir(root, category, type) {
|
|
66288
|
-
return
|
|
66758
|
+
return path31.join(root, category, type);
|
|
66289
66759
|
}
|
|
66290
66760
|
/**
|
|
66291
66761
|
* Canonical user override directory for a provider.
|
|
@@ -66312,20 +66782,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66312
66782
|
resolveProviderFile(type, ...segments) {
|
|
66313
66783
|
const dir = this.findProviderDirInternal(type);
|
|
66314
66784
|
if (!dir) return null;
|
|
66315
|
-
return
|
|
66785
|
+
return path31.join(dir, ...segments);
|
|
66316
66786
|
}
|
|
66317
66787
|
/**
|
|
66318
66788
|
* Load all providers (3-tier priority)
|
|
66319
|
-
* 1.
|
|
66320
|
-
* 2.
|
|
66321
|
-
*
|
|
66789
|
+
* 1. ~/.adhdev/providers/.upstream/ — official git, auto-synced
|
|
66790
|
+
* 2. ~/.adhdev/external/ — 3rd-party git sources, user-added,
|
|
66791
|
+
* bundled providers may include arbitrary JS (untrusted by default)
|
|
66792
|
+
* 3. ~/.adhdev/providers/ (excluding .upstream) — user-authored customs,
|
|
66793
|
+
* always wins
|
|
66794
|
+
* Highest priority listed last (overwrites earlier loads).
|
|
66322
66795
|
* If .upstream/ is empty, call fetchLatest() before loadAll().
|
|
66323
66796
|
*/
|
|
66324
66797
|
loadAll() {
|
|
66325
66798
|
this.providers.clear();
|
|
66326
66799
|
this.providerAvailability.clear();
|
|
66327
66800
|
let upstreamCount = 0;
|
|
66328
|
-
if (!this.disableUpstream &&
|
|
66801
|
+
if (!this.disableUpstream && fs19.existsSync(this.upstreamDir)) {
|
|
66329
66802
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
66330
66803
|
if (upstreamCount > 0) {
|
|
66331
66804
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -66333,14 +66806,64 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66333
66806
|
} else if (this.disableUpstream) {
|
|
66334
66807
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
66335
66808
|
}
|
|
66336
|
-
const
|
|
66337
|
-
if (
|
|
66338
|
-
const
|
|
66339
|
-
|
|
66340
|
-
|
|
66809
|
+
const externalDir = path31.join(os222.homedir(), ".adhdev", "external");
|
|
66810
|
+
if (fs19.existsSync(externalDir)) {
|
|
66811
|
+
const rootEntries = (() => {
|
|
66812
|
+
try {
|
|
66813
|
+
return fs19.readdirSync(externalDir, { withFileTypes: true });
|
|
66814
|
+
} catch {
|
|
66815
|
+
return [];
|
|
66816
|
+
}
|
|
66817
|
+
})();
|
|
66818
|
+
const KNOWN_CATEGORIES = /* @__PURE__ */ new Set(["cli", "ide", "extension", "acp"]);
|
|
66819
|
+
const looksLegacy = rootEntries.some((e) => e.isDirectory() && KNOWN_CATEGORIES.has(e.name));
|
|
66820
|
+
if (looksLegacy) {
|
|
66821
|
+
const externalCount = this.loadDir(externalDir);
|
|
66822
|
+
if (externalCount > 0) {
|
|
66823
|
+
this.log(`Loaded ${externalCount} external providers (legacy unnamed source)`);
|
|
66824
|
+
}
|
|
66825
|
+
} else {
|
|
66826
|
+
const {
|
|
66827
|
+
loadProvidersActive: loadProvidersActive2,
|
|
66828
|
+
resolveActiveSource: resolveActiveSource2
|
|
66829
|
+
} = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
66830
|
+
const activeFile = loadProvidersActive2();
|
|
66831
|
+
let totalLoaded = 0;
|
|
66832
|
+
const ambiguousTypes = [];
|
|
66833
|
+
for (const sourceEntry of rootEntries) {
|
|
66834
|
+
if (!sourceEntry.isDirectory()) continue;
|
|
66835
|
+
const sourceDir = path31.join(externalDir, sourceEntry.name);
|
|
66836
|
+
const sourceLoaded = this.loadDir(sourceDir);
|
|
66837
|
+
if (sourceLoaded > 0) {
|
|
66838
|
+
totalLoaded += sourceLoaded;
|
|
66839
|
+
this.log(`Loaded ${sourceLoaded} providers from external source "${sourceEntry.name}"`);
|
|
66840
|
+
}
|
|
66841
|
+
}
|
|
66842
|
+
for (const [type] of this.providers) {
|
|
66843
|
+
const prov = this.providers.get(type);
|
|
66844
|
+
if (!prov) continue;
|
|
66845
|
+
const resolved = resolveActiveSource2(prov.category, type, activeFile);
|
|
66846
|
+
if (resolved.candidates.length <= 1) continue;
|
|
66847
|
+
if (resolved.ambiguous) {
|
|
66848
|
+
ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
|
|
66849
|
+
}
|
|
66850
|
+
if (resolved.source && resolved.source !== "?") {
|
|
66851
|
+
const sourceDir = path31.join(externalDir, resolved.source);
|
|
66852
|
+
const reloadCount = this.loadDir(sourceDir);
|
|
66853
|
+
if (reloadCount === 0) {
|
|
66854
|
+
this.log(`Active source "${resolved.source}" no longer provides ${type}`);
|
|
66855
|
+
}
|
|
66856
|
+
}
|
|
66857
|
+
}
|
|
66858
|
+
if (totalLoaded > 0) {
|
|
66859
|
+
this.log(`Loaded ${totalLoaded} external providers (3rd-party sources)`);
|
|
66860
|
+
}
|
|
66861
|
+
for (const a of ambiguousTypes) {
|
|
66862
|
+
this.log(`Ambiguous provider "${a.type}" \u2014 provided by [${a.candidates.join(", ")}], defaulted to "${a.chosen}". Set the active source from the dashboard to silence this warning.`);
|
|
66863
|
+
}
|
|
66341
66864
|
}
|
|
66342
66865
|
}
|
|
66343
|
-
if (
|
|
66866
|
+
if (fs19.existsSync(this.userDir)) {
|
|
66344
66867
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
66345
66868
|
if (userCount > 0) {
|
|
66346
66869
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -66355,10 +66878,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66355
66878
|
* Check if upstream directory exists and has providers.
|
|
66356
66879
|
*/
|
|
66357
66880
|
hasUpstream() {
|
|
66358
|
-
if (!
|
|
66881
|
+
if (!fs19.existsSync(this.upstreamDir)) return false;
|
|
66359
66882
|
try {
|
|
66360
|
-
return
|
|
66361
|
-
(d) =>
|
|
66883
|
+
return fs19.readdirSync(this.upstreamDir).some(
|
|
66884
|
+
(d) => fs19.statSync(path31.join(this.upstreamDir, d)).isDirectory()
|
|
66362
66885
|
);
|
|
66363
66886
|
} catch {
|
|
66364
66887
|
return false;
|
|
@@ -66848,16 +67371,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66848
67371
|
let matched = false;
|
|
66849
67372
|
for (const entry of compat) {
|
|
66850
67373
|
if (this.matchesVersion(currentVersion, entry.ideVersion)) {
|
|
66851
|
-
|
|
66852
|
-
|
|
66853
|
-
|
|
66854
|
-
|
|
66855
|
-
|
|
66856
|
-
|
|
66857
|
-
|
|
66858
|
-
|
|
66859
|
-
|
|
67374
|
+
if (entry.scriptDir) {
|
|
67375
|
+
const loaded = this.loadScriptsFromDir(type, entry.scriptDir);
|
|
67376
|
+
if (loaded) {
|
|
67377
|
+
resolved.scripts = loaded;
|
|
67378
|
+
this.debugLog(` [compatibility] ${type} v${currentVersion} \u2192 ${entry.scriptDir}`);
|
|
67379
|
+
resolved._resolvedScriptDir = entry.scriptDir;
|
|
67380
|
+
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
67381
|
+
if (providerDir) {
|
|
67382
|
+
const fullDir = path31.join(providerDir, entry.scriptDir);
|
|
67383
|
+
resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
|
|
67384
|
+
}
|
|
67385
|
+
matched = true;
|
|
66860
67386
|
}
|
|
67387
|
+
} else {
|
|
66861
67388
|
matched = true;
|
|
66862
67389
|
}
|
|
66863
67390
|
break;
|
|
@@ -66871,8 +67398,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66871
67398
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
66872
67399
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
66873
67400
|
if (providerDir) {
|
|
66874
|
-
const fullDir =
|
|
66875
|
-
resolved._resolvedScriptsPath =
|
|
67401
|
+
const fullDir = path31.join(providerDir, base.defaultScriptDir);
|
|
67402
|
+
resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
|
|
66876
67403
|
}
|
|
66877
67404
|
}
|
|
66878
67405
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -66889,8 +67416,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66889
67416
|
resolved._resolvedScriptDir = dirOverride;
|
|
66890
67417
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
66891
67418
|
if (providerDir) {
|
|
66892
|
-
const fullDir =
|
|
66893
|
-
resolved._resolvedScriptsPath =
|
|
67419
|
+
const fullDir = path31.join(providerDir, dirOverride);
|
|
67420
|
+
resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
|
|
66894
67421
|
}
|
|
66895
67422
|
}
|
|
66896
67423
|
} else if (override.scripts) {
|
|
@@ -66906,8 +67433,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66906
67433
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
66907
67434
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
66908
67435
|
if (providerDir) {
|
|
66909
|
-
const fullDir =
|
|
66910
|
-
resolved._resolvedScriptsPath =
|
|
67436
|
+
const fullDir = path31.join(providerDir, base.defaultScriptDir);
|
|
67437
|
+
resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
|
|
66911
67438
|
}
|
|
66912
67439
|
}
|
|
66913
67440
|
}
|
|
@@ -66924,13 +67451,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66924
67451
|
if (providerDir2) {
|
|
66925
67452
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
66926
67453
|
if (!override || typeof override.path !== "string") continue;
|
|
66927
|
-
const fullPath =
|
|
66928
|
-
if (!
|
|
67454
|
+
const fullPath = path31.join(providerDir2, override.path);
|
|
67455
|
+
if (!fs19.existsSync(fullPath)) {
|
|
66929
67456
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
66930
67457
|
continue;
|
|
66931
67458
|
}
|
|
66932
67459
|
try {
|
|
66933
|
-
registerProviderScriptRootSafely(
|
|
67460
|
+
registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir2)));
|
|
66934
67461
|
delete require.cache[require.resolve(fullPath)];
|
|
66935
67462
|
const fn = require(fullPath);
|
|
66936
67463
|
const target = typeof fn === "function" ? fn : fn && fn[scriptName];
|
|
@@ -66955,19 +67482,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66955
67482
|
}
|
|
66956
67483
|
if (providerDir) {
|
|
66957
67484
|
try {
|
|
66958
|
-
const
|
|
66959
|
-
const
|
|
67485
|
+
const fs28 = require("fs");
|
|
67486
|
+
const path40 = require("path");
|
|
66960
67487
|
const candidates = [];
|
|
66961
67488
|
if (Array.isArray(base.compatibility)) {
|
|
66962
67489
|
for (const entry of base.compatibility) {
|
|
66963
67490
|
if (typeof entry?.spec !== "string") continue;
|
|
66964
67491
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
66965
|
-
if (matches) candidates.push(
|
|
67492
|
+
if (matches) candidates.push(path40.join(providerDir, entry.spec));
|
|
66966
67493
|
}
|
|
66967
67494
|
}
|
|
66968
|
-
candidates.push(
|
|
66969
|
-
candidates.push(
|
|
66970
|
-
const specPath = candidates.find((p) =>
|
|
67495
|
+
candidates.push(path40.join(providerDir, "specs", "default.json"));
|
|
67496
|
+
candidates.push(path40.join(providerDir, "spec.json"));
|
|
67497
|
+
const specPath = candidates.find((p) => fs28.existsSync(p));
|
|
66971
67498
|
if (specPath) {
|
|
66972
67499
|
resolved._resolvedSpecPath = specPath;
|
|
66973
67500
|
const { loadSpec: loadSpec2 } = (init_loader(), __toCommonJS2(loader_exports));
|
|
@@ -66996,10 +67523,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
66996
67523
|
format = `spec-${nh.source.kind}`;
|
|
66997
67524
|
reader = (input) => executeNativeHistory2(nh, input);
|
|
66998
67525
|
} else if (nh.override_path) {
|
|
66999
|
-
const overrideFile =
|
|
67000
|
-
if (
|
|
67526
|
+
const overrideFile = path40.resolve(providerDir, nh.override_path);
|
|
67527
|
+
if (fs28.existsSync(overrideFile)) {
|
|
67001
67528
|
try {
|
|
67002
|
-
registerProviderScriptRootSafely(
|
|
67529
|
+
registerProviderScriptRootSafely(path40.dirname(path40.dirname(providerDir)));
|
|
67003
67530
|
delete require.cache[require.resolve(overrideFile)];
|
|
67004
67531
|
const mod = require(overrideFile);
|
|
67005
67532
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -67043,16 +67570,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67043
67570
|
this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
|
|
67044
67571
|
return null;
|
|
67045
67572
|
}
|
|
67046
|
-
const dir =
|
|
67047
|
-
if (!
|
|
67573
|
+
const dir = path31.join(providerDir, scriptDir);
|
|
67574
|
+
if (!fs19.existsSync(dir)) {
|
|
67048
67575
|
this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
67049
67576
|
return null;
|
|
67050
67577
|
}
|
|
67051
|
-
registerProviderScriptRootSafely(
|
|
67578
|
+
registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir)));
|
|
67052
67579
|
const cached2 = this.scriptsCache.get(dir);
|
|
67053
67580
|
if (cached2) return cached2;
|
|
67054
|
-
const scriptsJs =
|
|
67055
|
-
if (
|
|
67581
|
+
const scriptsJs = path31.join(dir, "scripts.js");
|
|
67582
|
+
if (fs19.existsSync(scriptsJs)) {
|
|
67056
67583
|
try {
|
|
67057
67584
|
delete require.cache[require.resolve(scriptsJs)];
|
|
67058
67585
|
const loaded = require(scriptsJs);
|
|
@@ -67073,9 +67600,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67073
67600
|
watch() {
|
|
67074
67601
|
this.stopWatch();
|
|
67075
67602
|
const watchDir = (dir) => {
|
|
67076
|
-
if (!
|
|
67603
|
+
if (!fs19.existsSync(dir)) {
|
|
67077
67604
|
try {
|
|
67078
|
-
|
|
67605
|
+
fs19.mkdirSync(dir, { recursive: true });
|
|
67079
67606
|
} catch {
|
|
67080
67607
|
return;
|
|
67081
67608
|
}
|
|
@@ -67096,7 +67623,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67096
67623
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
67097
67624
|
if (reloadTimer) clearTimeout(reloadTimer);
|
|
67098
67625
|
reloadTimer = setTimeout(() => {
|
|
67099
|
-
this.log(`File changed: ${
|
|
67626
|
+
this.log(`File changed: ${path31.basename(filePath)}, reloading...`);
|
|
67100
67627
|
this.reload();
|
|
67101
67628
|
}, 300);
|
|
67102
67629
|
}
|
|
@@ -67164,11 +67691,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67164
67691
|
}
|
|
67165
67692
|
this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
|
|
67166
67693
|
const https = require("https");
|
|
67167
|
-
const regMetaPath =
|
|
67694
|
+
const regMetaPath = path31.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
|
|
67168
67695
|
let cachedChecksums = {};
|
|
67169
67696
|
try {
|
|
67170
|
-
if (
|
|
67171
|
-
cachedChecksums = JSON.parse(
|
|
67697
|
+
if (fs19.existsSync(regMetaPath)) {
|
|
67698
|
+
cachedChecksums = JSON.parse(fs19.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
|
|
67172
67699
|
}
|
|
67173
67700
|
} catch {
|
|
67174
67701
|
}
|
|
@@ -67222,15 +67749,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67222
67749
|
this.log(`\u26A0 Registry checksum mismatch for ${type}@${version2} \u2014 skipping`);
|
|
67223
67750
|
continue;
|
|
67224
67751
|
}
|
|
67225
|
-
const providerDir =
|
|
67226
|
-
|
|
67227
|
-
|
|
67752
|
+
const providerDir = path31.join(this.upstreamDir, category, type);
|
|
67753
|
+
fs19.mkdirSync(providerDir, { recursive: true });
|
|
67754
|
+
fs19.writeFileSync(path31.join(providerDir, "provider.json"), manifestBody, "utf-8");
|
|
67228
67755
|
cachedChecksums[cacheKey] = checksum;
|
|
67229
67756
|
updatedCount++;
|
|
67230
67757
|
this.log(`\u2713 Registry updated: ${category}/${type}@${version2}`);
|
|
67231
67758
|
}
|
|
67232
|
-
|
|
67233
|
-
|
|
67759
|
+
fs19.mkdirSync(this.upstreamDir, { recursive: true });
|
|
67760
|
+
fs19.writeFileSync(regMetaPath, JSON.stringify({
|
|
67234
67761
|
checksums: cachedChecksums,
|
|
67235
67762
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
67236
67763
|
providerCount: list.providers.length
|
|
@@ -67251,12 +67778,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67251
67778
|
const { exec: exec7 } = require("child_process");
|
|
67252
67779
|
const { promisify: promisify7 } = require("util");
|
|
67253
67780
|
const execAsync5 = promisify7(exec7);
|
|
67254
|
-
const metaPath =
|
|
67781
|
+
const metaPath = path31.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
67255
67782
|
let prevEtag = "";
|
|
67256
67783
|
let prevTimestamp = 0;
|
|
67257
67784
|
try {
|
|
67258
|
-
if (
|
|
67259
|
-
const meta3 = JSON.parse(
|
|
67785
|
+
if (fs19.existsSync(metaPath)) {
|
|
67786
|
+
const meta3 = JSON.parse(fs19.readFileSync(metaPath, "utf-8"));
|
|
67260
67787
|
prevEtag = meta3.etag || "";
|
|
67261
67788
|
prevTimestamp = meta3.timestamp || 0;
|
|
67262
67789
|
}
|
|
@@ -67311,39 +67838,39 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67311
67838
|
return { updated: false };
|
|
67312
67839
|
}
|
|
67313
67840
|
this.log("Downloading latest providers from GitHub...");
|
|
67314
|
-
const tmpTar =
|
|
67315
|
-
const tmpExtract =
|
|
67841
|
+
const tmpTar = path31.join(os222.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
67842
|
+
const tmpExtract = path31.join(os222.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
67316
67843
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
67317
|
-
|
|
67844
|
+
fs19.mkdirSync(tmpExtract, { recursive: true });
|
|
67318
67845
|
await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
67319
|
-
const extracted =
|
|
67846
|
+
const extracted = fs19.readdirSync(tmpExtract);
|
|
67320
67847
|
const rootDir = extracted.find(
|
|
67321
|
-
(d) =>
|
|
67848
|
+
(d) => fs19.statSync(path31.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
67322
67849
|
);
|
|
67323
67850
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
67324
|
-
const sourceDir =
|
|
67851
|
+
const sourceDir = path31.join(tmpExtract, rootDir);
|
|
67325
67852
|
const backupDir = this.upstreamDir + ".bak";
|
|
67326
|
-
if (
|
|
67327
|
-
if (
|
|
67328
|
-
|
|
67853
|
+
if (fs19.existsSync(this.upstreamDir)) {
|
|
67854
|
+
if (fs19.existsSync(backupDir)) fs19.rmSync(backupDir, { recursive: true, force: true });
|
|
67855
|
+
fs19.renameSync(this.upstreamDir, backupDir);
|
|
67329
67856
|
}
|
|
67330
67857
|
try {
|
|
67331
67858
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
67332
67859
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
67333
|
-
if (
|
|
67860
|
+
if (fs19.existsSync(backupDir)) fs19.rmSync(backupDir, { recursive: true, force: true });
|
|
67334
67861
|
} catch (e) {
|
|
67335
|
-
if (
|
|
67336
|
-
if (
|
|
67337
|
-
|
|
67862
|
+
if (fs19.existsSync(backupDir)) {
|
|
67863
|
+
if (fs19.existsSync(this.upstreamDir)) fs19.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
67864
|
+
fs19.renameSync(backupDir, this.upstreamDir);
|
|
67338
67865
|
}
|
|
67339
67866
|
throw e;
|
|
67340
67867
|
}
|
|
67341
67868
|
try {
|
|
67342
|
-
|
|
67869
|
+
fs19.rmSync(tmpTar, { force: true });
|
|
67343
67870
|
} catch {
|
|
67344
67871
|
}
|
|
67345
67872
|
try {
|
|
67346
|
-
|
|
67873
|
+
fs19.rmSync(tmpExtract, { recursive: true, force: true });
|
|
67347
67874
|
} catch {
|
|
67348
67875
|
}
|
|
67349
67876
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -67375,7 +67902,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67375
67902
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
67376
67903
|
return;
|
|
67377
67904
|
}
|
|
67378
|
-
const ws =
|
|
67905
|
+
const ws = fs19.createWriteStream(destPath);
|
|
67379
67906
|
res.pipe(ws);
|
|
67380
67907
|
ws.on("finish", () => {
|
|
67381
67908
|
ws.close();
|
|
@@ -67394,22 +67921,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67394
67921
|
}
|
|
67395
67922
|
/** Recursive directory copy */
|
|
67396
67923
|
copyDirRecursive(src, dest) {
|
|
67397
|
-
|
|
67398
|
-
for (const entry of
|
|
67399
|
-
const srcPath =
|
|
67400
|
-
const destPath =
|
|
67924
|
+
fs19.mkdirSync(dest, { recursive: true });
|
|
67925
|
+
for (const entry of fs19.readdirSync(src, { withFileTypes: true })) {
|
|
67926
|
+
const srcPath = path31.join(src, entry.name);
|
|
67927
|
+
const destPath = path31.join(dest, entry.name);
|
|
67401
67928
|
if (entry.isDirectory()) {
|
|
67402
67929
|
this.copyDirRecursive(srcPath, destPath);
|
|
67403
67930
|
} else {
|
|
67404
|
-
|
|
67931
|
+
fs19.copyFileSync(srcPath, destPath);
|
|
67405
67932
|
}
|
|
67406
67933
|
}
|
|
67407
67934
|
}
|
|
67408
67935
|
/** .meta.json save */
|
|
67409
67936
|
writeMeta(metaPath, etag, timestamp) {
|
|
67410
67937
|
try {
|
|
67411
|
-
|
|
67412
|
-
|
|
67938
|
+
fs19.mkdirSync(path31.dirname(metaPath), { recursive: true });
|
|
67939
|
+
fs19.writeFileSync(metaPath, JSON.stringify({
|
|
67413
67940
|
etag,
|
|
67414
67941
|
timestamp,
|
|
67415
67942
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -67420,15 +67947,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67420
67947
|
}
|
|
67421
67948
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
67422
67949
|
countProviders(dir) {
|
|
67423
|
-
if (!
|
|
67950
|
+
if (!fs19.existsSync(dir)) return 0;
|
|
67424
67951
|
let count = 0;
|
|
67425
67952
|
const scan = (d) => {
|
|
67426
67953
|
try {
|
|
67427
|
-
const entries =
|
|
67954
|
+
const entries = fs19.readdirSync(d, { withFileTypes: true });
|
|
67428
67955
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
67429
67956
|
if (hasManifest) count++;
|
|
67430
67957
|
for (const entry of entries) {
|
|
67431
|
-
if (entry.isDirectory()) scan(
|
|
67958
|
+
if (entry.isDirectory()) scan(path31.join(d, entry.name));
|
|
67432
67959
|
}
|
|
67433
67960
|
} catch {
|
|
67434
67961
|
}
|
|
@@ -67654,13 +68181,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67654
68181
|
if (!provider) return null;
|
|
67655
68182
|
const cat = provider.category;
|
|
67656
68183
|
const searchRoots = this.getProviderRoots();
|
|
67657
|
-
const hasManifest = (dir) =>
|
|
68184
|
+
const hasManifest = (dir) => fs19.existsSync(path31.join(dir, "provider.v1.json")) || fs19.existsSync(path31.join(dir, "provider.json"));
|
|
67658
68185
|
const readManifestType = (dir) => {
|
|
67659
68186
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
67660
|
-
const p =
|
|
67661
|
-
if (!
|
|
68187
|
+
const p = path31.join(dir, file2);
|
|
68188
|
+
if (!fs19.existsSync(p)) continue;
|
|
67662
68189
|
try {
|
|
67663
|
-
const data = JSON.parse(
|
|
68190
|
+
const data = JSON.parse(fs19.readFileSync(p, "utf-8"));
|
|
67664
68191
|
if (typeof data?.type === "string") return data.type;
|
|
67665
68192
|
} catch {
|
|
67666
68193
|
}
|
|
@@ -67668,15 +68195,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67668
68195
|
return null;
|
|
67669
68196
|
};
|
|
67670
68197
|
for (const root of searchRoots) {
|
|
67671
|
-
if (!
|
|
68198
|
+
if (!fs19.existsSync(root)) continue;
|
|
67672
68199
|
const candidate = this.getProviderDir(root, cat, type);
|
|
67673
68200
|
if (hasManifest(candidate)) return candidate;
|
|
67674
|
-
const catDir =
|
|
67675
|
-
if (
|
|
68201
|
+
const catDir = path31.join(root, cat);
|
|
68202
|
+
if (fs19.existsSync(catDir)) {
|
|
67676
68203
|
try {
|
|
67677
|
-
for (const entry of
|
|
68204
|
+
for (const entry of fs19.readdirSync(catDir, { withFileTypes: true })) {
|
|
67678
68205
|
if (!entry.isDirectory()) continue;
|
|
67679
|
-
const entryDir =
|
|
68206
|
+
const entryDir = path31.join(catDir, entry.name);
|
|
67680
68207
|
const manifestType = readManifestType(entryDir);
|
|
67681
68208
|
if (manifestType === type) return entryDir;
|
|
67682
68209
|
}
|
|
@@ -67692,8 +68219,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67692
68219
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
67693
68220
|
*/
|
|
67694
68221
|
buildScriptWrappersFromDir(dir) {
|
|
67695
|
-
const scriptsJs =
|
|
67696
|
-
if (
|
|
68222
|
+
const scriptsJs = path31.join(dir, "scripts.js");
|
|
68223
|
+
if (fs19.existsSync(scriptsJs)) {
|
|
67697
68224
|
try {
|
|
67698
68225
|
delete require.cache[require.resolve(scriptsJs)];
|
|
67699
68226
|
return require(scriptsJs);
|
|
@@ -67703,13 +68230,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67703
68230
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
67704
68231
|
const result = {};
|
|
67705
68232
|
try {
|
|
67706
|
-
for (const file2 of
|
|
68233
|
+
for (const file2 of fs19.readdirSync(dir)) {
|
|
67707
68234
|
if (!file2.endsWith(".js")) continue;
|
|
67708
68235
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
67709
|
-
const filePath =
|
|
68236
|
+
const filePath = path31.join(dir, file2);
|
|
67710
68237
|
result[scriptName] = (...args) => {
|
|
67711
68238
|
try {
|
|
67712
|
-
let content =
|
|
68239
|
+
let content = fs19.readFileSync(filePath, "utf-8");
|
|
67713
68240
|
if (args[0] && typeof args[0] === "object") {
|
|
67714
68241
|
for (const [key, val] of Object.entries(args[0])) {
|
|
67715
68242
|
let v = val;
|
|
@@ -67755,12 +68282,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67755
68282
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
67756
68283
|
*/
|
|
67757
68284
|
loadDir(dir, excludeDirs) {
|
|
67758
|
-
if (!
|
|
68285
|
+
if (!fs19.existsSync(dir)) return 0;
|
|
67759
68286
|
let count = 0;
|
|
67760
68287
|
const scan = (d) => {
|
|
67761
68288
|
let entries;
|
|
67762
68289
|
try {
|
|
67763
|
-
entries =
|
|
68290
|
+
entries = fs19.readdirSync(d, { withFileTypes: true });
|
|
67764
68291
|
} catch {
|
|
67765
68292
|
return;
|
|
67766
68293
|
}
|
|
@@ -67768,9 +68295,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
67768
68295
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
67769
68296
|
if (hasV1 || hasJson) {
|
|
67770
68297
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
67771
|
-
const jsonPath =
|
|
68298
|
+
const jsonPath = path31.join(d, manifestFile);
|
|
67772
68299
|
try {
|
|
67773
|
-
const raw =
|
|
68300
|
+
const raw = fs19.readFileSync(jsonPath, "utf-8");
|
|
67774
68301
|
const mod = JSON.parse(raw);
|
|
67775
68302
|
if (hasV1 && mod?.category === "cli") {
|
|
67776
68303
|
try {
|
|
@@ -67808,10 +68335,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
67808
68335
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
67809
68336
|
} else {
|
|
67810
68337
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
67811
|
-
const scriptsPath =
|
|
67812
|
-
if (!hasCompatibility &&
|
|
68338
|
+
const scriptsPath = path31.join(d, "scripts.js");
|
|
68339
|
+
if (!hasCompatibility && fs19.existsSync(scriptsPath)) {
|
|
67813
68340
|
try {
|
|
67814
|
-
registerProviderScriptRootSafely(
|
|
68341
|
+
registerProviderScriptRootSafely(path31.dirname(path31.dirname(d)));
|
|
67815
68342
|
delete require.cache[require.resolve(scriptsPath)];
|
|
67816
68343
|
const scripts = require(scriptsPath);
|
|
67817
68344
|
normalizedProvider.scripts = scripts;
|
|
@@ -67819,12 +68346,30 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
67819
68346
|
this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
|
|
67820
68347
|
}
|
|
67821
68348
|
}
|
|
68349
|
+
const externalDirAbs = path31.join(os222.homedir(), ".adhdev", "external");
|
|
68350
|
+
const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
|
|
68351
|
+
try {
|
|
68352
|
+
const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
|
|
68353
|
+
const shape = inspectManifestShape2(mod);
|
|
68354
|
+
const trust = classifyTrust2(layer, shape);
|
|
68355
|
+
normalizedProvider._sourceLayer = layer;
|
|
68356
|
+
normalizedProvider._sourceTrust = trust;
|
|
68357
|
+
normalizedProvider._manifestShape = shape;
|
|
68358
|
+
if (layer === "external") {
|
|
68359
|
+
const rel = path31.relative(externalDirAbs, d);
|
|
68360
|
+
const firstSeg = rel.split(path31.sep)[0];
|
|
68361
|
+
if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
|
|
68362
|
+
}
|
|
68363
|
+
} catch {
|
|
68364
|
+
}
|
|
67822
68365
|
const existed = this.providers.has(normalizedProvider.type);
|
|
67823
68366
|
this.providers.set(normalizedProvider.type, normalizedProvider);
|
|
67824
68367
|
count++;
|
|
67825
|
-
const source =
|
|
68368
|
+
const source = normalizedProvider._sourceLayer ?? "upstream";
|
|
67826
68369
|
const overrideWarning = existed && source === "user" ? " \u26A0 OVERRIDES upstream" : "";
|
|
67827
|
-
|
|
68370
|
+
const sourceName = normalizedProvider._sourceName;
|
|
68371
|
+
const sourceLabel = sourceName ? `${source}/${sourceName}` : source;
|
|
68372
|
+
this.log(` ${existed ? "\u{1F504}" : "\u2705"} ${normalizedProvider.type} (${normalizedProvider.category}) \u2014 ${normalizedProvider.name} [${sourceLabel}]${overrideWarning}`);
|
|
67828
68373
|
}
|
|
67829
68374
|
} catch (e) {
|
|
67830
68375
|
this.log(`\u26A0 Failed to load ${jsonPath}: ${e.message}`);
|
|
@@ -67834,8 +68379,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
67834
68379
|
for (const entry of entries) {
|
|
67835
68380
|
if (!entry.isDirectory()) continue;
|
|
67836
68381
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
68382
|
+
if (d === dir && entry.name === "examples") continue;
|
|
67837
68383
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
67838
|
-
scan(
|
|
68384
|
+
scan(path31.join(d, entry.name));
|
|
67839
68385
|
}
|
|
67840
68386
|
}
|
|
67841
68387
|
};
|
|
@@ -68029,7 +68575,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68029
68575
|
});
|
|
68030
68576
|
}
|
|
68031
68577
|
async function killIdeProcess(ideId) {
|
|
68032
|
-
const plat =
|
|
68578
|
+
const plat = os23.platform();
|
|
68033
68579
|
const appName = getMacAppIdentifiers()[ideId];
|
|
68034
68580
|
const winProcesses = getWinProcessNames()[ideId];
|
|
68035
68581
|
try {
|
|
@@ -68090,7 +68636,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68090
68636
|
}
|
|
68091
68637
|
}
|
|
68092
68638
|
async function isIdeRunning(ideId) {
|
|
68093
|
-
const plat =
|
|
68639
|
+
const plat = os23.platform();
|
|
68094
68640
|
try {
|
|
68095
68641
|
if (plat === "darwin") {
|
|
68096
68642
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -68145,7 +68691,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68145
68691
|
}
|
|
68146
68692
|
}
|
|
68147
68693
|
async function detectCurrentWorkspace(ideId) {
|
|
68148
|
-
const plat =
|
|
68694
|
+
const plat = os23.platform();
|
|
68149
68695
|
if (plat === "darwin") {
|
|
68150
68696
|
try {
|
|
68151
68697
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -68160,17 +68706,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68160
68706
|
}
|
|
68161
68707
|
} else if (plat === "win32") {
|
|
68162
68708
|
try {
|
|
68163
|
-
const
|
|
68709
|
+
const fs28 = require("fs");
|
|
68164
68710
|
const appNameMap = getMacAppIdentifiers();
|
|
68165
68711
|
const appName = appNameMap[ideId];
|
|
68166
68712
|
if (appName) {
|
|
68167
|
-
const storagePath =
|
|
68168
|
-
process.env.APPDATA ||
|
|
68713
|
+
const storagePath = path322.join(
|
|
68714
|
+
process.env.APPDATA || path322.join(os23.homedir(), "AppData", "Roaming"),
|
|
68169
68715
|
appName,
|
|
68170
68716
|
"storage.json"
|
|
68171
68717
|
);
|
|
68172
|
-
if (
|
|
68173
|
-
const data = JSON.parse(
|
|
68718
|
+
if (fs28.existsSync(storagePath)) {
|
|
68719
|
+
const data = JSON.parse(fs28.readFileSync(storagePath, "utf-8"));
|
|
68174
68720
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
68175
68721
|
if (workspaces.length > 0) {
|
|
68176
68722
|
const recent = workspaces[0];
|
|
@@ -68187,7 +68733,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68187
68733
|
return void 0;
|
|
68188
68734
|
}
|
|
68189
68735
|
async function launchWithCdp(options = {}) {
|
|
68190
|
-
const platform10 =
|
|
68736
|
+
const platform10 = os23.platform();
|
|
68191
68737
|
let targetIde;
|
|
68192
68738
|
const ides = await detectIDEs(getProviderLoader());
|
|
68193
68739
|
if (options.ideId) {
|
|
@@ -68350,14 +68896,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68350
68896
|
init_config();
|
|
68351
68897
|
init_cli_detector();
|
|
68352
68898
|
init_logger();
|
|
68353
|
-
var
|
|
68354
|
-
var
|
|
68355
|
-
var
|
|
68356
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
68899
|
+
var fs20 = __toESM2(require("fs"));
|
|
68900
|
+
var path33 = __toESM2(require("path"));
|
|
68901
|
+
var os24 = __toESM2(require("os"));
|
|
68902
|
+
var LOG_DIR2 = process.platform === "win32" ? path33.join(process.env.LOCALAPPDATA || process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path33.join(os24.homedir(), "Library", "Logs", "adhdev") : path33.join(os24.homedir(), ".local", "share", "adhdev", "logs");
|
|
68357
68903
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
68358
68904
|
var MAX_DAYS = 7;
|
|
68359
68905
|
try {
|
|
68360
|
-
|
|
68906
|
+
fs20.mkdirSync(LOG_DIR2, { recursive: true });
|
|
68361
68907
|
} catch {
|
|
68362
68908
|
}
|
|
68363
68909
|
var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -68391,19 +68937,19 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68391
68937
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
68392
68938
|
}
|
|
68393
68939
|
var currentDate2 = getDateStr2();
|
|
68394
|
-
var currentFile =
|
|
68940
|
+
var currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
68395
68941
|
var writeCount2 = 0;
|
|
68396
68942
|
function checkRotation() {
|
|
68397
68943
|
const today = getDateStr2();
|
|
68398
68944
|
if (today !== currentDate2) {
|
|
68399
68945
|
currentDate2 = today;
|
|
68400
|
-
currentFile =
|
|
68946
|
+
currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
68401
68947
|
cleanOldFiles();
|
|
68402
68948
|
}
|
|
68403
68949
|
}
|
|
68404
68950
|
function cleanOldFiles() {
|
|
68405
68951
|
try {
|
|
68406
|
-
const files =
|
|
68952
|
+
const files = fs20.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
68407
68953
|
const cutoff = /* @__PURE__ */ new Date();
|
|
68408
68954
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
68409
68955
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -68411,7 +68957,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68411
68957
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
68412
68958
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
68413
68959
|
try {
|
|
68414
|
-
|
|
68960
|
+
fs20.unlinkSync(path33.join(LOG_DIR2, file2));
|
|
68415
68961
|
} catch {
|
|
68416
68962
|
}
|
|
68417
68963
|
}
|
|
@@ -68421,14 +68967,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68421
68967
|
}
|
|
68422
68968
|
function checkSize() {
|
|
68423
68969
|
try {
|
|
68424
|
-
const stat2 =
|
|
68970
|
+
const stat2 = fs20.statSync(currentFile);
|
|
68425
68971
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
68426
68972
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
68427
68973
|
try {
|
|
68428
|
-
|
|
68974
|
+
fs20.unlinkSync(backup);
|
|
68429
68975
|
} catch {
|
|
68430
68976
|
}
|
|
68431
|
-
|
|
68977
|
+
fs20.renameSync(currentFile, backup);
|
|
68432
68978
|
}
|
|
68433
68979
|
} catch {
|
|
68434
68980
|
}
|
|
@@ -68461,14 +69007,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68461
69007
|
...entry.error ? { err: entry.error } : {},
|
|
68462
69008
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
68463
69009
|
});
|
|
68464
|
-
|
|
69010
|
+
fs20.appendFileSync(currentFile, line + "\n");
|
|
68465
69011
|
} catch {
|
|
68466
69012
|
}
|
|
68467
69013
|
}
|
|
68468
69014
|
function getRecentCommands(count = 50) {
|
|
68469
69015
|
try {
|
|
68470
|
-
if (!
|
|
68471
|
-
const content =
|
|
69016
|
+
if (!fs20.existsSync(currentFile)) return [];
|
|
69017
|
+
const content = fs20.readFileSync(currentFile, "utf-8");
|
|
68472
69018
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
68473
69019
|
return lines.slice(-count).map((line) => {
|
|
68474
69020
|
try {
|
|
@@ -68514,10 +69060,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68514
69060
|
}
|
|
68515
69061
|
}
|
|
68516
69062
|
function readRecord3(repoRoot) {
|
|
68517
|
-
const
|
|
68518
|
-
if (!(0, import_node_fs4.existsSync)(
|
|
69063
|
+
const path40 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
69064
|
+
if (!(0, import_node_fs4.existsSync)(path40)) return null;
|
|
68519
69065
|
try {
|
|
68520
|
-
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(
|
|
69066
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path40, "utf8"));
|
|
68521
69067
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
68522
69068
|
} catch {
|
|
68523
69069
|
return null;
|
|
@@ -68577,7 +69123,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68577
69123
|
nextAction
|
|
68578
69124
|
};
|
|
68579
69125
|
}
|
|
68580
|
-
var
|
|
69126
|
+
var os25 = __toESM2(require("os"));
|
|
68581
69127
|
init_config();
|
|
68582
69128
|
init_terminal_screen();
|
|
68583
69129
|
init_logger();
|
|
@@ -68616,25 +69162,50 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68616
69162
|
}
|
|
68617
69163
|
function buildAvailableProviders(providerLoader) {
|
|
68618
69164
|
const providers = providerLoader.getAvailableProviderInfos?.() || providerLoader.getAll();
|
|
68619
|
-
|
|
68620
|
-
|
|
68621
|
-
|
|
68622
|
-
|
|
68623
|
-
|
|
68624
|
-
|
|
68625
|
-
|
|
68626
|
-
|
|
68627
|
-
|
|
68628
|
-
|
|
68629
|
-
|
|
68630
|
-
|
|
68631
|
-
|
|
68632
|
-
|
|
69165
|
+
let describeTrust2 = () => "";
|
|
69166
|
+
let requiresConfirmation2 = () => false;
|
|
69167
|
+
try {
|
|
69168
|
+
const mod = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
|
|
69169
|
+
describeTrust2 = mod.describeTrust;
|
|
69170
|
+
requiresConfirmation2 = mod.requiresConfirmation;
|
|
69171
|
+
} catch {
|
|
69172
|
+
}
|
|
69173
|
+
return providers.map((provider) => {
|
|
69174
|
+
const trust = provider._sourceTrust;
|
|
69175
|
+
const sourceLayer = provider._sourceLayer;
|
|
69176
|
+
const sourceName = provider._sourceName;
|
|
69177
|
+
return {
|
|
69178
|
+
type: provider.type,
|
|
69179
|
+
name: provider.displayName || provider.type,
|
|
69180
|
+
displayName: provider.displayName || provider.type,
|
|
69181
|
+
icon: provider.icon || "\u{1F4BB}",
|
|
69182
|
+
category: provider.category,
|
|
69183
|
+
...provider.installed !== void 0 ? { installed: provider.installed } : {},
|
|
69184
|
+
...provider.detectedPath !== void 0 ? { detectedPath: provider.detectedPath } : {},
|
|
69185
|
+
...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
|
|
69186
|
+
...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
|
|
69187
|
+
...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
|
|
69188
|
+
...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
|
|
69189
|
+
...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {},
|
|
69190
|
+
...trust ? {
|
|
69191
|
+
trust,
|
|
69192
|
+
trustDescription: describeTrust2(trust),
|
|
69193
|
+
requiresConfirmation: requiresConfirmation2(trust)
|
|
69194
|
+
} : {},
|
|
69195
|
+
...sourceLayer ? { sourceLayer } : {},
|
|
69196
|
+
...sourceName ? { sourceName } : {},
|
|
69197
|
+
...provider.providerVersion ? { providerVersion: provider.providerVersion } : {},
|
|
69198
|
+
...provider.binary ? { binary: provider.binary } : {},
|
|
69199
|
+
...provider.status ? { status: provider.status } : {},
|
|
69200
|
+
...provider.details ? { details: provider.details } : {},
|
|
69201
|
+
...provider.links ? { links: provider.links } : {}
|
|
69202
|
+
};
|
|
69203
|
+
});
|
|
68633
69204
|
}
|
|
68634
69205
|
function buildMachineInfo2(profile = "full") {
|
|
68635
69206
|
const base = {
|
|
68636
|
-
hostname:
|
|
68637
|
-
platform:
|
|
69207
|
+
hostname: os25.hostname(),
|
|
69208
|
+
platform: os25.platform()
|
|
68638
69209
|
};
|
|
68639
69210
|
if (profile === "live") {
|
|
68640
69211
|
return base;
|
|
@@ -68643,23 +69214,23 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68643
69214
|
const memSnap2 = getHostMemorySnapshot();
|
|
68644
69215
|
return {
|
|
68645
69216
|
...base,
|
|
68646
|
-
arch:
|
|
68647
|
-
cpus:
|
|
69217
|
+
arch: os25.arch(),
|
|
69218
|
+
cpus: os25.cpus().length,
|
|
68648
69219
|
totalMem: memSnap2.totalMem,
|
|
68649
|
-
release:
|
|
69220
|
+
release: os25.release()
|
|
68650
69221
|
};
|
|
68651
69222
|
}
|
|
68652
69223
|
const memSnap = getHostMemorySnapshot();
|
|
68653
69224
|
return {
|
|
68654
69225
|
...base,
|
|
68655
|
-
arch:
|
|
68656
|
-
cpus:
|
|
69226
|
+
arch: os25.arch(),
|
|
69227
|
+
cpus: os25.cpus().length,
|
|
68657
69228
|
totalMem: memSnap.totalMem,
|
|
68658
69229
|
freeMem: memSnap.freeMem,
|
|
68659
69230
|
availableMem: memSnap.availableMem,
|
|
68660
|
-
loadavg:
|
|
68661
|
-
uptime:
|
|
68662
|
-
release:
|
|
69231
|
+
loadavg: os25.loadavg(),
|
|
69232
|
+
uptime: os25.uptime(),
|
|
69233
|
+
release: os25.release()
|
|
68663
69234
|
};
|
|
68664
69235
|
}
|
|
68665
69236
|
function parseMessageTime(value) {
|
|
@@ -68898,42 +69469,42 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68898
69469
|
}
|
|
68899
69470
|
var import_child_process7 = require("child_process");
|
|
68900
69471
|
var import_child_process8 = require("child_process");
|
|
68901
|
-
var
|
|
68902
|
-
var
|
|
68903
|
-
var
|
|
69472
|
+
var fs21 = __toESM2(require("fs"));
|
|
69473
|
+
var os26 = __toESM2(require("os"));
|
|
69474
|
+
var path34 = __toESM2(require("path"));
|
|
68904
69475
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
68905
69476
|
function getUpgradeLogPath() {
|
|
68906
|
-
const home =
|
|
68907
|
-
const dir =
|
|
68908
|
-
|
|
68909
|
-
return
|
|
69477
|
+
const home = os26.homedir();
|
|
69478
|
+
const dir = path34.join(home, ".adhdev");
|
|
69479
|
+
fs21.mkdirSync(dir, { recursive: true });
|
|
69480
|
+
return path34.join(dir, "daemon-upgrade.log");
|
|
68910
69481
|
}
|
|
68911
69482
|
function appendUpgradeLog(message) {
|
|
68912
69483
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
68913
69484
|
`;
|
|
68914
69485
|
try {
|
|
68915
|
-
|
|
69486
|
+
fs21.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
68916
69487
|
} catch {
|
|
68917
69488
|
}
|
|
68918
69489
|
}
|
|
68919
69490
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
68920
|
-
const binDir =
|
|
69491
|
+
const binDir = path34.dirname(nodeExecutable);
|
|
68921
69492
|
if (platform10 === "win32") {
|
|
68922
|
-
const npmCliPath =
|
|
68923
|
-
if (
|
|
69493
|
+
const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
69494
|
+
if (fs21.existsSync(npmCliPath)) {
|
|
68924
69495
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
68925
69496
|
}
|
|
68926
69497
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
68927
|
-
const candidatePath =
|
|
68928
|
-
if (
|
|
69498
|
+
const candidatePath = path34.join(binDir, candidate);
|
|
69499
|
+
if (fs21.existsSync(candidatePath)) {
|
|
68929
69500
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
68930
69501
|
}
|
|
68931
69502
|
}
|
|
68932
69503
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
68933
69504
|
}
|
|
68934
69505
|
for (const candidate of ["npm"]) {
|
|
68935
|
-
const candidatePath =
|
|
68936
|
-
if (
|
|
69506
|
+
const candidatePath = path34.join(binDir, candidate);
|
|
69507
|
+
if (fs21.existsSync(candidatePath)) {
|
|
68937
69508
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
68938
69509
|
}
|
|
68939
69510
|
}
|
|
@@ -68943,22 +69514,22 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68943
69514
|
if (!currentCliPath) return null;
|
|
68944
69515
|
let resolvedPath = currentCliPath;
|
|
68945
69516
|
try {
|
|
68946
|
-
resolvedPath =
|
|
69517
|
+
resolvedPath = fs21.realpathSync.native(currentCliPath);
|
|
68947
69518
|
} catch {
|
|
68948
69519
|
}
|
|
68949
69520
|
let currentDir = resolvedPath;
|
|
68950
69521
|
try {
|
|
68951
|
-
if (
|
|
68952
|
-
currentDir =
|
|
69522
|
+
if (fs21.statSync(resolvedPath).isFile()) {
|
|
69523
|
+
currentDir = path34.dirname(resolvedPath);
|
|
68953
69524
|
}
|
|
68954
69525
|
} catch {
|
|
68955
|
-
currentDir =
|
|
69526
|
+
currentDir = path34.dirname(resolvedPath);
|
|
68956
69527
|
}
|
|
68957
69528
|
while (true) {
|
|
68958
|
-
const packageJsonPath =
|
|
69529
|
+
const packageJsonPath = path34.join(currentDir, "package.json");
|
|
68959
69530
|
try {
|
|
68960
|
-
if (
|
|
68961
|
-
const parsed = JSON.parse(
|
|
69531
|
+
if (fs21.existsSync(packageJsonPath)) {
|
|
69532
|
+
const parsed = JSON.parse(fs21.readFileSync(packageJsonPath, "utf8"));
|
|
68962
69533
|
if (parsed?.name === packageName) {
|
|
68963
69534
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
68964
69535
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -68966,7 +69537,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68966
69537
|
}
|
|
68967
69538
|
} catch {
|
|
68968
69539
|
}
|
|
68969
|
-
const parentDir =
|
|
69540
|
+
const parentDir = path34.dirname(currentDir);
|
|
68970
69541
|
if (parentDir === currentDir) {
|
|
68971
69542
|
return null;
|
|
68972
69543
|
}
|
|
@@ -68974,13 +69545,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
68974
69545
|
}
|
|
68975
69546
|
}
|
|
68976
69547
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
68977
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
68978
|
-
if (
|
|
69548
|
+
const nodeModulesDir = packageName.startsWith("@") ? path34.dirname(path34.dirname(packageRoot)) : path34.dirname(packageRoot);
|
|
69549
|
+
if (path34.basename(nodeModulesDir) !== "node_modules") {
|
|
68979
69550
|
return null;
|
|
68980
69551
|
}
|
|
68981
|
-
const maybeLibDir =
|
|
68982
|
-
if (
|
|
68983
|
-
return
|
|
69552
|
+
const maybeLibDir = path34.dirname(nodeModulesDir);
|
|
69553
|
+
if (path34.basename(maybeLibDir) === "lib") {
|
|
69554
|
+
return path34.dirname(maybeLibDir);
|
|
68984
69555
|
}
|
|
68985
69556
|
return maybeLibDir;
|
|
68986
69557
|
}
|
|
@@ -69095,10 +69666,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69095
69666
|
}
|
|
69096
69667
|
}
|
|
69097
69668
|
function stopSessionHostProcesses(appName) {
|
|
69098
|
-
const pidFile =
|
|
69669
|
+
const pidFile = path34.join(os26.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
69099
69670
|
try {
|
|
69100
|
-
if (
|
|
69101
|
-
const pid = Number.parseInt(
|
|
69671
|
+
if (fs21.existsSync(pidFile)) {
|
|
69672
|
+
const pid = Number.parseInt(fs21.readFileSync(pidFile, "utf8").trim(), 10);
|
|
69102
69673
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
69103
69674
|
killPid2(pid);
|
|
69104
69675
|
}
|
|
@@ -69106,15 +69677,15 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69106
69677
|
} catch {
|
|
69107
69678
|
} finally {
|
|
69108
69679
|
try {
|
|
69109
|
-
|
|
69680
|
+
fs21.unlinkSync(pidFile);
|
|
69110
69681
|
} catch {
|
|
69111
69682
|
}
|
|
69112
69683
|
}
|
|
69113
69684
|
}
|
|
69114
69685
|
function removeDaemonPidFile() {
|
|
69115
|
-
const pidFile =
|
|
69686
|
+
const pidFile = path34.join(os26.homedir(), ".adhdev", "daemon.pid");
|
|
69116
69687
|
try {
|
|
69117
|
-
|
|
69688
|
+
fs21.unlinkSync(pidFile);
|
|
69118
69689
|
} catch {
|
|
69119
69690
|
}
|
|
69120
69691
|
}
|
|
@@ -69123,7 +69694,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69123
69694
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
69124
69695
|
if (!npmRoot) return;
|
|
69125
69696
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
69126
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
69697
|
+
const binDir = process.platform === "win32" ? npmPrefix : path34.join(npmPrefix, "bin");
|
|
69127
69698
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
69128
69699
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
69129
69700
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -69131,25 +69702,25 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69131
69702
|
}
|
|
69132
69703
|
if (pkgName.startsWith("@")) {
|
|
69133
69704
|
const [scope, name] = pkgName.split("/");
|
|
69134
|
-
const scopeDir =
|
|
69135
|
-
if (!
|
|
69136
|
-
for (const entry of
|
|
69705
|
+
const scopeDir = path34.join(npmRoot, scope);
|
|
69706
|
+
if (!fs21.existsSync(scopeDir)) return;
|
|
69707
|
+
for (const entry of fs21.readdirSync(scopeDir)) {
|
|
69137
69708
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
69138
|
-
|
|
69139
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
69709
|
+
fs21.rmSync(path34.join(scopeDir, entry), { recursive: true, force: true });
|
|
69710
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path34.join(scopeDir, entry)}`);
|
|
69140
69711
|
}
|
|
69141
69712
|
} else {
|
|
69142
|
-
for (const entry of
|
|
69713
|
+
for (const entry of fs21.readdirSync(npmRoot)) {
|
|
69143
69714
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
69144
|
-
|
|
69145
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
69715
|
+
fs21.rmSync(path34.join(npmRoot, entry), { recursive: true, force: true });
|
|
69716
|
+
appendUpgradeLog(`Removed stale staging dir: ${path34.join(npmRoot, entry)}`);
|
|
69146
69717
|
}
|
|
69147
69718
|
}
|
|
69148
|
-
if (
|
|
69149
|
-
for (const entry of
|
|
69719
|
+
if (fs21.existsSync(binDir)) {
|
|
69720
|
+
for (const entry of fs21.readdirSync(binDir)) {
|
|
69150
69721
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
69151
|
-
|
|
69152
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
69722
|
+
fs21.rmSync(path34.join(binDir, entry), { recursive: true, force: true });
|
|
69723
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path34.join(binDir, entry)}`);
|
|
69153
69724
|
}
|
|
69154
69725
|
}
|
|
69155
69726
|
}
|
|
@@ -69235,7 +69806,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69235
69806
|
init_mesh_work_queue();
|
|
69236
69807
|
var import_os3 = require("os");
|
|
69237
69808
|
var import_path10 = require("path");
|
|
69238
|
-
var
|
|
69809
|
+
var fs222 = __toESM2(require("fs"));
|
|
69239
69810
|
var import_node_child_process5 = require("child_process");
|
|
69240
69811
|
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
69241
69812
|
var CHANNEL_SERVER_URL = {
|
|
@@ -69362,12 +69933,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
69362
69933
|
if (!Array.isArray(value)) return void 0;
|
|
69363
69934
|
const submodules = value.map((entry) => {
|
|
69364
69935
|
const submodule = readObjectRecord(entry);
|
|
69365
|
-
const
|
|
69936
|
+
const path40 = readStringValue(submodule.path);
|
|
69366
69937
|
const commit = readStringValue(submodule.commit);
|
|
69367
|
-
const repoPath = readStringValue(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot,
|
|
69368
|
-
if (!
|
|
69938
|
+
const repoPath = readStringValue(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
|
|
69939
|
+
if (!path40 || !commit || !repoPath) return null;
|
|
69369
69940
|
return {
|
|
69370
|
-
path:
|
|
69941
|
+
path: path40,
|
|
69371
69942
|
commit,
|
|
69372
69943
|
repoPath,
|
|
69373
69944
|
dirty: readBooleanValue(submodule.dirty) ?? false,
|
|
@@ -70009,7 +70580,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70009
70580
|
if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
|
|
70010
70581
|
continue;
|
|
70011
70582
|
}
|
|
70012
|
-
if (
|
|
70583
|
+
if (fs222.existsSync(workspace)) {
|
|
70013
70584
|
try {
|
|
70014
70585
|
const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
70015
70586
|
if (localGit?.isGitRepo) {
|
|
@@ -70094,7 +70665,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70094
70665
|
}
|
|
70095
70666
|
function collectLiveMeshSessionRecords(args) {
|
|
70096
70667
|
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
70097
|
-
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !
|
|
70668
|
+
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs222.existsSync(nodeWorkspace);
|
|
70098
70669
|
const matches = args.liveSessionRecords.filter((record2) => {
|
|
70099
70670
|
const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
|
|
70100
70671
|
if (recordNodeId && recordNodeId !== args.nodeId) return false;
|
|
@@ -70121,7 +70692,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70121
70692
|
const workspace = readStringValue(node?.workspace);
|
|
70122
70693
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
70123
70694
|
if (workspace) liveWorkspaces.add(workspace);
|
|
70124
|
-
if (nodeId && node?.isLocalWorktree === true && workspace && !
|
|
70695
|
+
if (nodeId && node?.isLocalWorktree === true && workspace && !fs222.existsSync(workspace)) {
|
|
70125
70696
|
missingLocalWorktreeNodeIds.add(nodeId);
|
|
70126
70697
|
}
|
|
70127
70698
|
}
|
|
@@ -70320,10 +70891,10 @@ ${e?.stderr || ""}`
|
|
|
70320
70891
|
}
|
|
70321
70892
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
70322
70893
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
70323
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
70324
|
-
path:
|
|
70325
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
70326
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
70894
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => ({
|
|
70895
|
+
path: path40,
|
|
70896
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path40),
|
|
70897
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path40)
|
|
70327
70898
|
}));
|
|
70328
70899
|
if (conflicts.length === 0) return void 0;
|
|
70329
70900
|
return {
|
|
@@ -70349,11 +70920,11 @@ ${e?.stderr || ""}`
|
|
|
70349
70920
|
if (!line.trim()) continue;
|
|
70350
70921
|
const metaAndPath = line.split(" ");
|
|
70351
70922
|
const meta3 = metaAndPath[0] || "";
|
|
70352
|
-
const
|
|
70353
|
-
if (!
|
|
70923
|
+
const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
70924
|
+
if (!path40) continue;
|
|
70354
70925
|
const parts = meta3.split(/\s+/);
|
|
70355
70926
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
70356
|
-
paths.add(
|
|
70927
|
+
paths.add(path40);
|
|
70357
70928
|
}
|
|
70358
70929
|
}
|
|
70359
70930
|
return [...paths].sort();
|
|
@@ -70361,9 +70932,9 @@ ${e?.stderr || ""}`
|
|
|
70361
70932
|
return [];
|
|
70362
70933
|
}
|
|
70363
70934
|
}
|
|
70364
|
-
function readTreeObject(repoRoot, ref,
|
|
70935
|
+
function readTreeObject(repoRoot, ref, path40) {
|
|
70365
70936
|
try {
|
|
70366
|
-
const output = (0, import_node_child_process5.execFileSync)("git", ["ls-tree", ref, "--",
|
|
70937
|
+
const output = (0, import_node_child_process5.execFileSync)("git", ["ls-tree", ref, "--", path40], {
|
|
70367
70938
|
cwd: repoRoot,
|
|
70368
70939
|
encoding: "utf8",
|
|
70369
70940
|
maxBuffer: 1024 * 1024
|
|
@@ -70376,7 +70947,7 @@ ${e?.stderr || ""}`
|
|
|
70376
70947
|
}
|
|
70377
70948
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
70378
70949
|
const startedAt = Date.now();
|
|
70379
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
70950
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path40) => !(options.submoduleIgnorePaths || []).includes(path40));
|
|
70380
70951
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
70381
70952
|
includeSubmodules: true,
|
|
70382
70953
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -70417,7 +70988,7 @@ ${e?.stderr || ""}`
|
|
|
70417
70988
|
changedGitlinkPaths,
|
|
70418
70989
|
outOfSyncPaths,
|
|
70419
70990
|
updatedPaths: updatePaths,
|
|
70420
|
-
verifiedPaths: updatePaths.filter((
|
|
70991
|
+
verifiedPaths: updatePaths.filter((path40) => !remaining.some((submodule) => submodule.path === path40)),
|
|
70421
70992
|
durationMs: Date.now() - startedAt,
|
|
70422
70993
|
command: `git ${commandArgs.join(" ")}`,
|
|
70423
70994
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -70472,7 +71043,7 @@ ${e?.stderr || ""}`
|
|
|
70472
71043
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
70473
71044
|
};
|
|
70474
71045
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
70475
|
-
if (!
|
|
71046
|
+
if (!fs222.existsSync(worktreeSubmodulePath)) return false;
|
|
70476
71047
|
try {
|
|
70477
71048
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
70478
71049
|
} catch {
|
|
@@ -70495,7 +71066,7 @@ ${e?.stderr || ""}`
|
|
|
70495
71066
|
reachable: false
|
|
70496
71067
|
};
|
|
70497
71068
|
try {
|
|
70498
|
-
if (!
|
|
71069
|
+
if (!fs222.existsSync(submodulePath)) {
|
|
70499
71070
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
70500
71071
|
entry.publishRequired = true;
|
|
70501
71072
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -70687,9 +71258,9 @@ ${e?.stderr || ""}`
|
|
|
70687
71258
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
70688
71259
|
};
|
|
70689
71260
|
const dependenciesLikelyMissing = (cwd) => {
|
|
70690
|
-
if (!
|
|
70691
|
-
if (
|
|
70692
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
71261
|
+
if (!fs222.existsSync((0, import_path10.join)(cwd, "package.json"))) return false;
|
|
71262
|
+
if (fs222.existsSync((0, import_path10.join)(cwd, "node_modules"))) return false;
|
|
71263
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs222.existsSync((0, import_path10.join)(cwd, lock)));
|
|
70693
71264
|
};
|
|
70694
71265
|
for (const candidate of selection.bootstrapCommands) {
|
|
70695
71266
|
const startedAt = Date.now();
|
|
@@ -70786,9 +71357,9 @@ ${e?.stderr || ""}`
|
|
|
70786
71357
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
70787
71358
|
const sourceHome = resolveHermesUserHome();
|
|
70788
71359
|
const sourceConfigPath = (0, import_path10.join)(sourceHome, "config.yaml");
|
|
70789
|
-
if (!
|
|
71360
|
+
if (!fs222.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
70790
71361
|
if ((0, import_path10.resolve)(sourceConfigPath) === (0, import_path10.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
70791
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
71362
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs222.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
70792
71363
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
70793
71364
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
70794
71365
|
}
|
|
@@ -70825,9 +71396,9 @@ ${e?.stderr || ""}`
|
|
|
70825
71396
|
for (const fileName of [".env", "auth.json"]) {
|
|
70826
71397
|
const sourcePath = (0, import_path10.join)(sourceHome, fileName);
|
|
70827
71398
|
const targetPath = (0, import_path10.join)(targetHome, fileName);
|
|
70828
|
-
if (!
|
|
71399
|
+
if (!fs222.existsSync(sourcePath)) continue;
|
|
70829
71400
|
try {
|
|
70830
|
-
|
|
71401
|
+
fs222.copyFileSync(sourcePath, targetPath);
|
|
70831
71402
|
} catch (error48) {
|
|
70832
71403
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
70833
71404
|
}
|
|
@@ -71182,13 +71753,13 @@ ${e?.stderr || ""}`
|
|
|
71182
71753
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
71183
71754
|
};
|
|
71184
71755
|
}
|
|
71185
|
-
const worktreeExists =
|
|
71756
|
+
const worktreeExists = fs222.existsSync(workspace);
|
|
71186
71757
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => n.id === args.node.clonedFromNodeId || n.nodeId === args.node.clonedFromNodeId) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
71187
71758
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
71188
71759
|
if (!worktreeExists) {
|
|
71189
71760
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
71190
71761
|
}
|
|
71191
|
-
if (!repoRoot || !
|
|
71762
|
+
if (!repoRoot || !fs222.existsSync(repoRoot)) {
|
|
71192
71763
|
return {
|
|
71193
71764
|
success: false,
|
|
71194
71765
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -71208,7 +71779,7 @@ ${e?.stderr || ""}`
|
|
|
71208
71779
|
const normalizePath = (value) => {
|
|
71209
71780
|
const resolved = (0, import_path10.resolve)(value);
|
|
71210
71781
|
try {
|
|
71211
|
-
return
|
|
71782
|
+
return fs222.realpathSync(resolved);
|
|
71212
71783
|
} catch {
|
|
71213
71784
|
return resolved;
|
|
71214
71785
|
}
|
|
@@ -72147,8 +72718,8 @@ ${e?.stderr || ""}`
|
|
|
72147
72718
|
if (sinceTs > 0) {
|
|
72148
72719
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
72149
72720
|
}
|
|
72150
|
-
if (
|
|
72151
|
-
const content =
|
|
72721
|
+
if (fs222.existsSync(LOG_PATH)) {
|
|
72722
|
+
const content = fs222.readFileSync(LOG_PATH, "utf-8");
|
|
72152
72723
|
const allLines = content.split("\n");
|
|
72153
72724
|
const recent = allLines.slice(-count).join("\n");
|
|
72154
72725
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -72538,24 +73109,24 @@ ${e?.stderr || ""}`
|
|
|
72538
73109
|
// Settings page in the dashboard reads/writes via these two
|
|
72539
73110
|
// commands instead of going through fs from the browser.
|
|
72540
73111
|
case "list_coordinator_prompts": {
|
|
72541
|
-
const
|
|
72542
|
-
const
|
|
72543
|
-
const
|
|
72544
|
-
const dir =
|
|
73112
|
+
const fs28 = await import("fs");
|
|
73113
|
+
const path40 = await import("path");
|
|
73114
|
+
const os29 = await import("os");
|
|
73115
|
+
const dir = path40.join(os29.homedir(), ".adhdev", "coordinator-prompts");
|
|
72545
73116
|
const entries = {};
|
|
72546
73117
|
try {
|
|
72547
|
-
if (
|
|
72548
|
-
for (const name of
|
|
73118
|
+
if (fs28.existsSync(dir)) {
|
|
73119
|
+
for (const name of fs28.readdirSync(dir)) {
|
|
72549
73120
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
72550
73121
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
72551
73122
|
const m = matchAppend || matchOverride;
|
|
72552
73123
|
if (!m) continue;
|
|
72553
73124
|
const isAppend = !!matchAppend;
|
|
72554
73125
|
const key = m[1];
|
|
72555
|
-
const full =
|
|
73126
|
+
const full = path40.join(dir, name);
|
|
72556
73127
|
let content = "";
|
|
72557
73128
|
try {
|
|
72558
|
-
content =
|
|
73129
|
+
content = fs28.readFileSync(full, "utf8");
|
|
72559
73130
|
} catch {
|
|
72560
73131
|
}
|
|
72561
73132
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -72569,24 +73140,24 @@ ${e?.stderr || ""}`
|
|
|
72569
73140
|
return { success: true, dir, entries };
|
|
72570
73141
|
}
|
|
72571
73142
|
case "write_coordinator_prompt": {
|
|
72572
|
-
const
|
|
72573
|
-
const
|
|
72574
|
-
const
|
|
73143
|
+
const fs28 = await import("fs");
|
|
73144
|
+
const path40 = await import("path");
|
|
73145
|
+
const os29 = await import("os");
|
|
72575
73146
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
72576
73147
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
72577
73148
|
const content = typeof args?.content === "string" ? args.content : "";
|
|
72578
73149
|
if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
|
|
72579
73150
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
72580
73151
|
}
|
|
72581
|
-
const dir =
|
|
73152
|
+
const dir = path40.join(os29.homedir(), ".adhdev", "coordinator-prompts");
|
|
72582
73153
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
72583
|
-
const full =
|
|
73154
|
+
const full = path40.join(dir, filename);
|
|
72584
73155
|
try {
|
|
72585
|
-
|
|
73156
|
+
fs28.mkdirSync(dir, { recursive: true });
|
|
72586
73157
|
if (content.trim()) {
|
|
72587
|
-
|
|
72588
|
-
} else if (
|
|
72589
|
-
|
|
73158
|
+
fs28.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
73159
|
+
} else if (fs28.existsSync(full)) {
|
|
73160
|
+
fs28.unlinkSync(full);
|
|
72590
73161
|
}
|
|
72591
73162
|
return { success: true, path: full, kind, key };
|
|
72592
73163
|
} catch (error48) {
|
|
@@ -73795,7 +74366,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
73795
74366
|
workspace
|
|
73796
74367
|
};
|
|
73797
74368
|
}
|
|
73798
|
-
const { existsSync:
|
|
74369
|
+
const { existsSync: existsSync39, readFileSync: readFileSync33, writeFileSync: writeFileSync20, copyFileSync: copyFileSync4, mkdirSync: mkdirSync19 } = await import("fs");
|
|
73799
74370
|
const { dirname: dirname11 } = await import("path");
|
|
73800
74371
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
73801
74372
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -73831,21 +74402,21 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
73831
74402
|
};
|
|
73832
74403
|
}
|
|
73833
74404
|
try {
|
|
73834
|
-
|
|
74405
|
+
mkdirSync19(dirname11(mcpConfigPath), { recursive: true });
|
|
73835
74406
|
} catch (error48) {
|
|
73836
74407
|
const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
|
|
73837
74408
|
LOG2.error("MeshCoordinator", message);
|
|
73838
74409
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
73839
74410
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
73840
74411
|
}
|
|
73841
|
-
const hadExistingMcpConfig =
|
|
74412
|
+
const hadExistingMcpConfig = existsSync39(mcpConfigPath);
|
|
73842
74413
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
73843
74414
|
if (hermesBaseConfig) {
|
|
73844
74415
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname11(mcpConfigPath));
|
|
73845
74416
|
}
|
|
73846
74417
|
if (hadExistingMcpConfig) {
|
|
73847
74418
|
try {
|
|
73848
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
74419
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync33(mcpConfigPath, "utf-8"), configFormat);
|
|
73849
74420
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
73850
74421
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
73851
74422
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -73868,7 +74439,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
73868
74439
|
}
|
|
73869
74440
|
};
|
|
73870
74441
|
try {
|
|
73871
|
-
|
|
74442
|
+
writeFileSync20(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
|
|
73872
74443
|
} catch (error48) {
|
|
73873
74444
|
const message = `Could not write MCP config for automatic setup: ${error48?.message || error48}`;
|
|
73874
74445
|
LOG2.error("MeshCoordinator", message);
|
|
@@ -74147,7 +74718,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
74147
74718
|
}
|
|
74148
74719
|
}
|
|
74149
74720
|
if (workspace) {
|
|
74150
|
-
if (!
|
|
74721
|
+
if (!fs222.existsSync(workspace)) {
|
|
74151
74722
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
74152
74723
|
let remoteProbeApplied = false;
|
|
74153
74724
|
if (inlineTransitGit) {
|
|
@@ -74260,7 +74831,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
74260
74831
|
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
|
|
74261
74832
|
const pendingCoordinatorEvents = drainPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
|
|
74262
74833
|
const previewFreshness = (() => {
|
|
74263
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
74834
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs222.existsSync(candidate));
|
|
74264
74835
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
74265
74836
|
})();
|
|
74266
74837
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -75985,12 +76556,12 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
75985
76556
|
this.eventListeners = [];
|
|
75986
76557
|
}
|
|
75987
76558
|
};
|
|
75988
|
-
var
|
|
75989
|
-
var
|
|
75990
|
-
var
|
|
76559
|
+
var fs23 = __toESM2(require("fs"));
|
|
76560
|
+
var path35 = __toESM2(require("path"));
|
|
76561
|
+
var os27 = __toESM2(require("os"));
|
|
75991
76562
|
var import_os4 = require("os");
|
|
75992
76563
|
var import_child_process9 = require("child_process");
|
|
75993
|
-
var ARCHIVE_PATH =
|
|
76564
|
+
var ARCHIVE_PATH = path35.join(os27.homedir(), ".adhdev", "version-history.json");
|
|
75994
76565
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
75995
76566
|
var VersionArchive = class {
|
|
75996
76567
|
history = {};
|
|
@@ -75999,8 +76570,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
75999
76570
|
}
|
|
76000
76571
|
load() {
|
|
76001
76572
|
try {
|
|
76002
|
-
if (
|
|
76003
|
-
this.history = JSON.parse(
|
|
76573
|
+
if (fs23.existsSync(ARCHIVE_PATH)) {
|
|
76574
|
+
this.history = JSON.parse(fs23.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
76004
76575
|
}
|
|
76005
76576
|
} catch {
|
|
76006
76577
|
this.history = {};
|
|
@@ -76037,8 +76608,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76037
76608
|
}
|
|
76038
76609
|
save() {
|
|
76039
76610
|
try {
|
|
76040
|
-
|
|
76041
|
-
|
|
76611
|
+
fs23.mkdirSync(path35.dirname(ARCHIVE_PATH), { recursive: true });
|
|
76612
|
+
fs23.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
76042
76613
|
} catch {
|
|
76043
76614
|
}
|
|
76044
76615
|
}
|
|
@@ -76061,10 +76632,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76061
76632
|
for (const p of paths) {
|
|
76062
76633
|
if (!p) continue;
|
|
76063
76634
|
for (const ext of exes) {
|
|
76064
|
-
const fullPath =
|
|
76635
|
+
const fullPath = path35.join(p, name + ext);
|
|
76065
76636
|
try {
|
|
76066
|
-
if (
|
|
76067
|
-
const stat2 =
|
|
76637
|
+
if (fs23.existsSync(fullPath)) {
|
|
76638
|
+
const stat2 = fs23.statSync(fullPath);
|
|
76068
76639
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
76069
76640
|
return fullPath;
|
|
76070
76641
|
}
|
|
@@ -76109,19 +76680,19 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76109
76680
|
function checkPathExists2(paths) {
|
|
76110
76681
|
for (const p of paths) {
|
|
76111
76682
|
if (p.includes("*")) {
|
|
76112
|
-
const home =
|
|
76113
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
76114
|
-
if (
|
|
76683
|
+
const home = os27.homedir();
|
|
76684
|
+
const resolved = p.replace(/\*/g, home.split(path35.sep).pop() || "");
|
|
76685
|
+
if (fs23.existsSync(resolved)) return resolved;
|
|
76115
76686
|
} else {
|
|
76116
|
-
if (
|
|
76687
|
+
if (fs23.existsSync(p)) return p;
|
|
76117
76688
|
}
|
|
76118
76689
|
}
|
|
76119
76690
|
return null;
|
|
76120
76691
|
}
|
|
76121
76692
|
async function getMacAppVersion(appPath) {
|
|
76122
76693
|
if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
76123
|
-
const plistPath =
|
|
76124
|
-
if (!
|
|
76694
|
+
const plistPath = path35.join(appPath, "Contents", "Info.plist");
|
|
76695
|
+
if (!fs23.existsSync(plistPath)) return null;
|
|
76125
76696
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
76126
76697
|
return raw || null;
|
|
76127
76698
|
}
|
|
@@ -76146,8 +76717,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76146
76717
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
76147
76718
|
let resolvedBin = cliBin;
|
|
76148
76719
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
76149
|
-
const bundled =
|
|
76150
|
-
if (provider.cli &&
|
|
76720
|
+
const bundled = path35.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
76721
|
+
if (provider.cli && fs23.existsSync(bundled)) resolvedBin = bundled;
|
|
76151
76722
|
}
|
|
76152
76723
|
info.installed = !!(appPath || resolvedBin);
|
|
76153
76724
|
info.path = appPath || null;
|
|
@@ -76184,8 +76755,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76184
76755
|
return results;
|
|
76185
76756
|
}
|
|
76186
76757
|
var http2 = __toESM2(require("http"));
|
|
76187
|
-
var
|
|
76188
|
-
var
|
|
76758
|
+
var fs27 = __toESM2(require("fs"));
|
|
76759
|
+
var path39 = __toESM2(require("path"));
|
|
76189
76760
|
init_config();
|
|
76190
76761
|
function generateFiles(type, name, category, opts = {}) {
|
|
76191
76762
|
const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
|
|
@@ -76529,8 +77100,8 @@ async (params) => {
|
|
|
76529
77100
|
};
|
|
76530
77101
|
}
|
|
76531
77102
|
init_logger();
|
|
76532
|
-
var
|
|
76533
|
-
var
|
|
77103
|
+
var fs24 = __toESM2(require("fs"));
|
|
77104
|
+
var path36 = __toESM2(require("path"));
|
|
76534
77105
|
init_logger();
|
|
76535
77106
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
76536
77107
|
const body = await ctx.readBody(req);
|
|
@@ -76709,18 +77280,18 @@ async (params) => {
|
|
|
76709
77280
|
return;
|
|
76710
77281
|
}
|
|
76711
77282
|
let scriptsPath = "";
|
|
76712
|
-
const directScripts =
|
|
76713
|
-
if (
|
|
77283
|
+
const directScripts = path36.join(dir, "scripts.js");
|
|
77284
|
+
if (fs24.existsSync(directScripts)) {
|
|
76714
77285
|
scriptsPath = directScripts;
|
|
76715
77286
|
} else {
|
|
76716
|
-
const scriptsDir =
|
|
76717
|
-
if (
|
|
76718
|
-
const versions =
|
|
76719
|
-
return
|
|
77287
|
+
const scriptsDir = path36.join(dir, "scripts");
|
|
77288
|
+
if (fs24.existsSync(scriptsDir)) {
|
|
77289
|
+
const versions = fs24.readdirSync(scriptsDir).filter((d) => {
|
|
77290
|
+
return fs24.statSync(path36.join(scriptsDir, d)).isDirectory();
|
|
76720
77291
|
}).sort().reverse();
|
|
76721
77292
|
for (const ver of versions) {
|
|
76722
|
-
const p =
|
|
76723
|
-
if (
|
|
77293
|
+
const p = path36.join(scriptsDir, ver, "scripts.js");
|
|
77294
|
+
if (fs24.existsSync(p)) {
|
|
76724
77295
|
scriptsPath = p;
|
|
76725
77296
|
break;
|
|
76726
77297
|
}
|
|
@@ -76732,7 +77303,7 @@ async (params) => {
|
|
|
76732
77303
|
return;
|
|
76733
77304
|
}
|
|
76734
77305
|
try {
|
|
76735
|
-
const source =
|
|
77306
|
+
const source = fs24.readFileSync(scriptsPath, "utf-8");
|
|
76736
77307
|
const hints = {};
|
|
76737
77308
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
76738
77309
|
let match;
|
|
@@ -77545,8 +78116,8 @@ async (params) => {
|
|
|
77545
78116
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
77546
78117
|
}
|
|
77547
78118
|
}
|
|
77548
|
-
var
|
|
77549
|
-
var
|
|
78119
|
+
var fs25 = __toESM2(require("fs"));
|
|
78120
|
+
var path37 = __toESM2(require("path"));
|
|
77550
78121
|
function slugifyFixtureName(value) {
|
|
77551
78122
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
77552
78123
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -77556,15 +78127,15 @@ async (params) => {
|
|
|
77556
78127
|
if (!providerDir) {
|
|
77557
78128
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
77558
78129
|
}
|
|
77559
|
-
return
|
|
78130
|
+
return path37.join(providerDir, "fixtures");
|
|
77560
78131
|
}
|
|
77561
78132
|
function readCliFixture(ctx, type, name) {
|
|
77562
78133
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
77563
|
-
const filePath =
|
|
77564
|
-
if (!
|
|
78134
|
+
const filePath = path37.join(fixtureDir, `${name}.json`);
|
|
78135
|
+
if (!fs25.existsSync(filePath)) {
|
|
77565
78136
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
77566
78137
|
}
|
|
77567
|
-
return JSON.parse(
|
|
78138
|
+
return JSON.parse(fs25.readFileSync(filePath, "utf-8"));
|
|
77568
78139
|
}
|
|
77569
78140
|
function getExerciseTranscriptText(result) {
|
|
77570
78141
|
const parts = [];
|
|
@@ -78309,7 +78880,7 @@ async (params) => {
|
|
|
78309
78880
|
return;
|
|
78310
78881
|
}
|
|
78311
78882
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
78312
|
-
|
|
78883
|
+
fs25.mkdirSync(fixtureDir, { recursive: true });
|
|
78313
78884
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
78314
78885
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
78315
78886
|
const fixture = {
|
|
@@ -78336,8 +78907,8 @@ async (params) => {
|
|
|
78336
78907
|
},
|
|
78337
78908
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
78338
78909
|
};
|
|
78339
|
-
const filePath =
|
|
78340
|
-
|
|
78910
|
+
const filePath = path37.join(fixtureDir, `${name}.json`);
|
|
78911
|
+
fs25.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
78341
78912
|
ctx.json(res, 200, {
|
|
78342
78913
|
saved: true,
|
|
78343
78914
|
name,
|
|
@@ -78355,14 +78926,14 @@ async (params) => {
|
|
|
78355
78926
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
78356
78927
|
try {
|
|
78357
78928
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
78358
|
-
if (!
|
|
78929
|
+
if (!fs25.existsSync(fixtureDir)) {
|
|
78359
78930
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
78360
78931
|
return;
|
|
78361
78932
|
}
|
|
78362
|
-
const fixtures =
|
|
78363
|
-
const fullPath =
|
|
78933
|
+
const fixtures = fs25.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
78934
|
+
const fullPath = path37.join(fixtureDir, file2);
|
|
78364
78935
|
try {
|
|
78365
|
-
const raw = JSON.parse(
|
|
78936
|
+
const raw = JSON.parse(fs25.readFileSync(fullPath, "utf-8"));
|
|
78366
78937
|
return {
|
|
78367
78938
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
78368
78939
|
path: fullPath,
|
|
@@ -78493,9 +79064,9 @@ async (params) => {
|
|
|
78493
79064
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
78494
79065
|
}
|
|
78495
79066
|
}
|
|
78496
|
-
var
|
|
78497
|
-
var
|
|
78498
|
-
var
|
|
79067
|
+
var fs26 = __toESM2(require("fs"));
|
|
79068
|
+
var path38 = __toESM2(require("path"));
|
|
79069
|
+
var os28 = __toESM2(require("os"));
|
|
78499
79070
|
function getAutoImplPid(ctx) {
|
|
78500
79071
|
const pid = ctx.autoImplProcess?.pid;
|
|
78501
79072
|
return typeof pid === "number" && pid > 0 ? pid : null;
|
|
@@ -78541,38 +79112,38 @@ async (params) => {
|
|
|
78541
79112
|
return fallback?.type || null;
|
|
78542
79113
|
}
|
|
78543
79114
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
78544
|
-
if (!
|
|
78545
|
-
const versions =
|
|
79115
|
+
if (!fs26.existsSync(scriptsDir)) return null;
|
|
79116
|
+
const versions = fs26.readdirSync(scriptsDir).filter((d) => {
|
|
78546
79117
|
try {
|
|
78547
|
-
return
|
|
79118
|
+
return fs26.statSync(path38.join(scriptsDir, d)).isDirectory();
|
|
78548
79119
|
} catch {
|
|
78549
79120
|
return false;
|
|
78550
79121
|
}
|
|
78551
79122
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
78552
79123
|
if (versions.length === 0) return null;
|
|
78553
|
-
return
|
|
79124
|
+
return path38.join(scriptsDir, versions[0]);
|
|
78554
79125
|
}
|
|
78555
79126
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
78556
|
-
const canonicalUserDir =
|
|
78557
|
-
const desiredDir = requestedDir ?
|
|
78558
|
-
const upstreamRoot =
|
|
78559
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
79127
|
+
const canonicalUserDir = path38.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
79128
|
+
const desiredDir = requestedDir ? path38.resolve(requestedDir) : canonicalUserDir;
|
|
79129
|
+
const upstreamRoot = path38.resolve(ctx.providerLoader.getUpstreamDir());
|
|
79130
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path38.sep}`)) {
|
|
78560
79131
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
78561
79132
|
}
|
|
78562
|
-
if (
|
|
79133
|
+
if (path38.basename(desiredDir) !== type) {
|
|
78563
79134
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
78564
79135
|
}
|
|
78565
79136
|
const sourceDir = ctx.findProviderDir(type);
|
|
78566
79137
|
if (!sourceDir) {
|
|
78567
79138
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
78568
79139
|
}
|
|
78569
|
-
if (!
|
|
78570
|
-
|
|
78571
|
-
|
|
79140
|
+
if (!fs26.existsSync(desiredDir)) {
|
|
79141
|
+
fs26.mkdirSync(path38.dirname(desiredDir), { recursive: true });
|
|
79142
|
+
fs26.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
78572
79143
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
78573
79144
|
}
|
|
78574
|
-
const providerJson =
|
|
78575
|
-
if (!
|
|
79145
|
+
const providerJson = path38.join(desiredDir, "provider.json");
|
|
79146
|
+
if (!fs26.existsSync(providerJson)) {
|
|
78576
79147
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
78577
79148
|
}
|
|
78578
79149
|
return { dir: desiredDir };
|
|
@@ -78580,15 +79151,15 @@ async (params) => {
|
|
|
78580
79151
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
78581
79152
|
if (!referenceType) return {};
|
|
78582
79153
|
const refDir = ctx.findProviderDir(referenceType);
|
|
78583
|
-
if (!refDir || !
|
|
79154
|
+
if (!refDir || !fs26.existsSync(refDir)) return {};
|
|
78584
79155
|
const referenceScripts = {};
|
|
78585
|
-
const scriptsDir =
|
|
79156
|
+
const scriptsDir = path38.join(refDir, "scripts");
|
|
78586
79157
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
78587
79158
|
if (!latestDir) return referenceScripts;
|
|
78588
|
-
for (const file2 of
|
|
79159
|
+
for (const file2 of fs26.readdirSync(latestDir)) {
|
|
78589
79160
|
if (!file2.endsWith(".js")) continue;
|
|
78590
79161
|
try {
|
|
78591
|
-
referenceScripts[file2] =
|
|
79162
|
+
referenceScripts[file2] = fs26.readFileSync(path38.join(latestDir, file2), "utf-8");
|
|
78592
79163
|
} catch {
|
|
78593
79164
|
}
|
|
78594
79165
|
}
|
|
@@ -78696,16 +79267,16 @@ async (params) => {
|
|
|
78696
79267
|
});
|
|
78697
79268
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
78698
79269
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
78699
|
-
const tmpDir =
|
|
78700
|
-
if (!
|
|
78701
|
-
const promptFile =
|
|
78702
|
-
|
|
79270
|
+
const tmpDir = path38.join(os28.tmpdir(), "adhdev-autoimpl");
|
|
79271
|
+
if (!fs26.existsSync(tmpDir)) fs26.mkdirSync(tmpDir, { recursive: true });
|
|
79272
|
+
const promptFile = path38.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
79273
|
+
fs26.writeFileSync(promptFile, prompt, "utf-8");
|
|
78703
79274
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
78704
79275
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
78705
79276
|
const spawn4 = agentProvider?.spawn;
|
|
78706
79277
|
if (!spawn4?.command) {
|
|
78707
79278
|
try {
|
|
78708
|
-
|
|
79279
|
+
fs26.unlinkSync(promptFile);
|
|
78709
79280
|
} catch {
|
|
78710
79281
|
}
|
|
78711
79282
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -78807,7 +79378,7 @@ async (params) => {
|
|
|
78807
79378
|
} catch {
|
|
78808
79379
|
}
|
|
78809
79380
|
try {
|
|
78810
|
-
|
|
79381
|
+
fs26.unlinkSync(promptFile);
|
|
78811
79382
|
} catch {
|
|
78812
79383
|
}
|
|
78813
79384
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -78851,7 +79422,7 @@ async (params) => {
|
|
|
78851
79422
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
78852
79423
|
const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
78853
79424
|
let shellCmd;
|
|
78854
|
-
const isWin =
|
|
79425
|
+
const isWin = os28.platform() === "win32";
|
|
78855
79426
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
78856
79427
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
78857
79428
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -78890,7 +79461,7 @@ async (params) => {
|
|
|
78890
79461
|
try {
|
|
78891
79462
|
const pty = require("node-pty");
|
|
78892
79463
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
78893
|
-
const isWin2 =
|
|
79464
|
+
const isWin2 = os28.platform() === "win32";
|
|
78894
79465
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
78895
79466
|
name: "xterm-256color",
|
|
78896
79467
|
cols: 120,
|
|
@@ -79033,7 +79604,7 @@ async (params) => {
|
|
|
79033
79604
|
}
|
|
79034
79605
|
});
|
|
79035
79606
|
try {
|
|
79036
|
-
|
|
79607
|
+
fs26.unlinkSync(promptFile);
|
|
79037
79608
|
} catch {
|
|
79038
79609
|
}
|
|
79039
79610
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -79130,7 +79701,7 @@ async (params) => {
|
|
|
79130
79701
|
setMode: "set_mode.js"
|
|
79131
79702
|
};
|
|
79132
79703
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
79133
|
-
const scriptsDir =
|
|
79704
|
+
const scriptsDir = path38.join(providerDir, "scripts");
|
|
79134
79705
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
79135
79706
|
if (latestScriptsDir) {
|
|
79136
79707
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -79138,10 +79709,10 @@ async (params) => {
|
|
|
79138
79709
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
79139
79710
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
79140
79711
|
lines.push("");
|
|
79141
|
-
for (const file2 of
|
|
79712
|
+
for (const file2 of fs26.readdirSync(latestScriptsDir)) {
|
|
79142
79713
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
79143
79714
|
try {
|
|
79144
|
-
const content =
|
|
79715
|
+
const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
|
|
79145
79716
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
79146
79717
|
lines.push("```javascript");
|
|
79147
79718
|
lines.push(content);
|
|
@@ -79151,14 +79722,14 @@ async (params) => {
|
|
|
79151
79722
|
}
|
|
79152
79723
|
}
|
|
79153
79724
|
}
|
|
79154
|
-
const refFiles =
|
|
79725
|
+
const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
79155
79726
|
if (refFiles.length > 0) {
|
|
79156
79727
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
79157
79728
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
79158
79729
|
lines.push("");
|
|
79159
79730
|
for (const file2 of refFiles) {
|
|
79160
79731
|
try {
|
|
79161
|
-
const content =
|
|
79732
|
+
const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
|
|
79162
79733
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
79163
79734
|
lines.push("```javascript");
|
|
79164
79735
|
lines.push(content);
|
|
@@ -79199,11 +79770,11 @@ async (params) => {
|
|
|
79199
79770
|
lines.push("");
|
|
79200
79771
|
}
|
|
79201
79772
|
}
|
|
79202
|
-
const docsDir =
|
|
79773
|
+
const docsDir = path38.join(providerDir, "../../docs");
|
|
79203
79774
|
const loadGuide = (name) => {
|
|
79204
79775
|
try {
|
|
79205
|
-
const p =
|
|
79206
|
-
if (
|
|
79776
|
+
const p = path38.join(docsDir, name);
|
|
79777
|
+
if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
|
|
79207
79778
|
} catch {
|
|
79208
79779
|
}
|
|
79209
79780
|
return null;
|
|
@@ -79439,7 +80010,7 @@ async (params) => {
|
|
|
79439
80010
|
parseApproval: "parse_approval.js"
|
|
79440
80011
|
};
|
|
79441
80012
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
79442
|
-
const scriptsDir =
|
|
80013
|
+
const scriptsDir = path38.join(providerDir, "scripts");
|
|
79443
80014
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
79444
80015
|
if (latestScriptsDir) {
|
|
79445
80016
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -79447,11 +80018,11 @@ async (params) => {
|
|
|
79447
80018
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
79448
80019
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
79449
80020
|
lines.push("");
|
|
79450
|
-
for (const file2 of
|
|
80021
|
+
for (const file2 of fs26.readdirSync(latestScriptsDir)) {
|
|
79451
80022
|
if (!file2.endsWith(".js")) continue;
|
|
79452
80023
|
if (!targetFileNames.has(file2)) continue;
|
|
79453
80024
|
try {
|
|
79454
|
-
const content =
|
|
80025
|
+
const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
|
|
79455
80026
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
79456
80027
|
lines.push("```javascript");
|
|
79457
80028
|
lines.push(content);
|
|
@@ -79460,14 +80031,14 @@ async (params) => {
|
|
|
79460
80031
|
} catch {
|
|
79461
80032
|
}
|
|
79462
80033
|
}
|
|
79463
|
-
const refFiles =
|
|
80034
|
+
const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
79464
80035
|
if (refFiles.length > 0) {
|
|
79465
80036
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
79466
80037
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
79467
80038
|
lines.push("");
|
|
79468
80039
|
for (const file2 of refFiles) {
|
|
79469
80040
|
try {
|
|
79470
|
-
const content =
|
|
80041
|
+
const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
|
|
79471
80042
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
79472
80043
|
lines.push("```javascript");
|
|
79473
80044
|
lines.push(content);
|
|
@@ -79500,11 +80071,11 @@ async (params) => {
|
|
|
79500
80071
|
lines.push("");
|
|
79501
80072
|
}
|
|
79502
80073
|
}
|
|
79503
|
-
const docsDir =
|
|
80074
|
+
const docsDir = path38.join(providerDir, "../../docs");
|
|
79504
80075
|
const loadGuide = (name) => {
|
|
79505
80076
|
try {
|
|
79506
|
-
const p =
|
|
79507
|
-
if (
|
|
80077
|
+
const p = path38.join(docsDir, name);
|
|
80078
|
+
if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
|
|
79508
80079
|
} catch {
|
|
79509
80080
|
}
|
|
79510
80081
|
return null;
|
|
@@ -79948,8 +80519,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
79948
80519
|
}
|
|
79949
80520
|
getEndpointList() {
|
|
79950
80521
|
return this.routes.map((r) => {
|
|
79951
|
-
const
|
|
79952
|
-
return `${r.method.padEnd(5)} ${
|
|
80522
|
+
const path40 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
80523
|
+
return `${r.method.padEnd(5)} ${path40}`;
|
|
79953
80524
|
});
|
|
79954
80525
|
}
|
|
79955
80526
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -80237,12 +80808,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80237
80808
|
// ─── DevConsole SPA ───
|
|
80238
80809
|
getConsoleDistDir() {
|
|
80239
80810
|
const candidates = [
|
|
80240
|
-
|
|
80241
|
-
|
|
80242
|
-
|
|
80811
|
+
path39.resolve(__dirname, "../../web-devconsole/dist"),
|
|
80812
|
+
path39.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
80813
|
+
path39.join(process.cwd(), "packages/web-devconsole/dist")
|
|
80243
80814
|
];
|
|
80244
80815
|
for (const dir of candidates) {
|
|
80245
|
-
if (
|
|
80816
|
+
if (fs27.existsSync(path39.join(dir, "index.html"))) return dir;
|
|
80246
80817
|
}
|
|
80247
80818
|
return null;
|
|
80248
80819
|
}
|
|
@@ -80252,9 +80823,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80252
80823
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
80253
80824
|
return;
|
|
80254
80825
|
}
|
|
80255
|
-
const htmlPath =
|
|
80826
|
+
const htmlPath = path39.join(distDir, "index.html");
|
|
80256
80827
|
try {
|
|
80257
|
-
const html =
|
|
80828
|
+
const html = fs27.readFileSync(htmlPath, "utf-8");
|
|
80258
80829
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
80259
80830
|
res.end(html);
|
|
80260
80831
|
} catch (e) {
|
|
@@ -80277,15 +80848,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80277
80848
|
this.json(res, 404, { error: "Not found" });
|
|
80278
80849
|
return;
|
|
80279
80850
|
}
|
|
80280
|
-
const safePath =
|
|
80281
|
-
const filePath =
|
|
80851
|
+
const safePath = path39.normalize(pathname).replace(/^\.\.\//, "");
|
|
80852
|
+
const filePath = path39.join(distDir, safePath);
|
|
80282
80853
|
if (!filePath.startsWith(distDir)) {
|
|
80283
80854
|
this.json(res, 403, { error: "Forbidden" });
|
|
80284
80855
|
return;
|
|
80285
80856
|
}
|
|
80286
80857
|
try {
|
|
80287
|
-
const content =
|
|
80288
|
-
const ext =
|
|
80858
|
+
const content = fs27.readFileSync(filePath);
|
|
80859
|
+
const ext = path39.extname(filePath);
|
|
80289
80860
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
80290
80861
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
80291
80862
|
res.end(content);
|
|
@@ -80393,14 +80964,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80393
80964
|
const files = [];
|
|
80394
80965
|
const scan = (d, prefix) => {
|
|
80395
80966
|
try {
|
|
80396
|
-
for (const entry of
|
|
80967
|
+
for (const entry of fs27.readdirSync(d, { withFileTypes: true })) {
|
|
80397
80968
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
80398
80969
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
80399
80970
|
if (entry.isDirectory()) {
|
|
80400
80971
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
80401
|
-
scan(
|
|
80972
|
+
scan(path39.join(d, entry.name), rel);
|
|
80402
80973
|
} else {
|
|
80403
|
-
const stat2 =
|
|
80974
|
+
const stat2 = fs27.statSync(path39.join(d, entry.name));
|
|
80404
80975
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
80405
80976
|
}
|
|
80406
80977
|
}
|
|
@@ -80423,16 +80994,16 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80423
80994
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
80424
80995
|
return;
|
|
80425
80996
|
}
|
|
80426
|
-
const fullPath =
|
|
80997
|
+
const fullPath = path39.resolve(dir, path39.normalize(filePath));
|
|
80427
80998
|
if (!fullPath.startsWith(dir)) {
|
|
80428
80999
|
this.json(res, 403, { error: "Forbidden" });
|
|
80429
81000
|
return;
|
|
80430
81001
|
}
|
|
80431
|
-
if (!
|
|
81002
|
+
if (!fs27.existsSync(fullPath) || fs27.statSync(fullPath).isDirectory()) {
|
|
80432
81003
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
80433
81004
|
return;
|
|
80434
81005
|
}
|
|
80435
|
-
const content =
|
|
81006
|
+
const content = fs27.readFileSync(fullPath, "utf-8");
|
|
80436
81007
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
80437
81008
|
}
|
|
80438
81009
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -80448,15 +81019,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80448
81019
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
80449
81020
|
return;
|
|
80450
81021
|
}
|
|
80451
|
-
const fullPath =
|
|
81022
|
+
const fullPath = path39.resolve(dir, path39.normalize(filePath));
|
|
80452
81023
|
if (!fullPath.startsWith(dir)) {
|
|
80453
81024
|
this.json(res, 403, { error: "Forbidden" });
|
|
80454
81025
|
return;
|
|
80455
81026
|
}
|
|
80456
81027
|
try {
|
|
80457
|
-
if (
|
|
80458
|
-
|
|
80459
|
-
|
|
81028
|
+
if (fs27.existsSync(fullPath)) fs27.copyFileSync(fullPath, fullPath + ".bak");
|
|
81029
|
+
fs27.mkdirSync(path39.dirname(fullPath), { recursive: true });
|
|
81030
|
+
fs27.writeFileSync(fullPath, content, "utf-8");
|
|
80460
81031
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
80461
81032
|
this.providerLoader.reload();
|
|
80462
81033
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -80472,9 +81043,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80472
81043
|
return;
|
|
80473
81044
|
}
|
|
80474
81045
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
80475
|
-
const p =
|
|
80476
|
-
if (
|
|
80477
|
-
const source =
|
|
81046
|
+
const p = path39.join(dir, name);
|
|
81047
|
+
if (fs27.existsSync(p)) {
|
|
81048
|
+
const source = fs27.readFileSync(p, "utf-8");
|
|
80478
81049
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
80479
81050
|
return;
|
|
80480
81051
|
}
|
|
@@ -80493,11 +81064,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80493
81064
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
80494
81065
|
return;
|
|
80495
81066
|
}
|
|
80496
|
-
const target =
|
|
80497
|
-
const targetPath =
|
|
81067
|
+
const target = fs27.existsSync(path39.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
81068
|
+
const targetPath = path39.join(dir, target);
|
|
80498
81069
|
try {
|
|
80499
|
-
if (
|
|
80500
|
-
|
|
81070
|
+
if (fs27.existsSync(targetPath)) fs27.copyFileSync(targetPath, targetPath + ".bak");
|
|
81071
|
+
fs27.writeFileSync(targetPath, source, "utf-8");
|
|
80501
81072
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
80502
81073
|
this.providerLoader.reload();
|
|
80503
81074
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -80641,21 +81212,21 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80641
81212
|
}
|
|
80642
81213
|
let targetDir;
|
|
80643
81214
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
80644
|
-
const jsonPath =
|
|
80645
|
-
if (
|
|
81215
|
+
const jsonPath = path39.join(targetDir, "provider.json");
|
|
81216
|
+
if (fs27.existsSync(jsonPath)) {
|
|
80646
81217
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
80647
81218
|
return;
|
|
80648
81219
|
}
|
|
80649
81220
|
try {
|
|
80650
81221
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
80651
|
-
|
|
80652
|
-
|
|
81222
|
+
fs27.mkdirSync(targetDir, { recursive: true });
|
|
81223
|
+
fs27.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
80653
81224
|
const createdFiles = ["provider.json"];
|
|
80654
81225
|
if (result.files) {
|
|
80655
81226
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
80656
|
-
const fullPath =
|
|
80657
|
-
|
|
80658
|
-
|
|
81227
|
+
const fullPath = path39.join(targetDir, relPath);
|
|
81228
|
+
fs27.mkdirSync(path39.dirname(fullPath), { recursive: true });
|
|
81229
|
+
fs27.writeFileSync(fullPath, content, "utf-8");
|
|
80659
81230
|
createdFiles.push(relPath);
|
|
80660
81231
|
}
|
|
80661
81232
|
}
|
|
@@ -80704,38 +81275,38 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80704
81275
|
}
|
|
80705
81276
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
80706
81277
|
getLatestScriptVersionDir(scriptsDir) {
|
|
80707
|
-
if (!
|
|
80708
|
-
const versions =
|
|
81278
|
+
if (!fs27.existsSync(scriptsDir)) return null;
|
|
81279
|
+
const versions = fs27.readdirSync(scriptsDir).filter((d) => {
|
|
80709
81280
|
try {
|
|
80710
|
-
return
|
|
81281
|
+
return fs27.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
80711
81282
|
} catch {
|
|
80712
81283
|
return false;
|
|
80713
81284
|
}
|
|
80714
81285
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
80715
81286
|
if (versions.length === 0) return null;
|
|
80716
|
-
return
|
|
81287
|
+
return path39.join(scriptsDir, versions[0]);
|
|
80717
81288
|
}
|
|
80718
81289
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
80719
|
-
const canonicalUserDir =
|
|
80720
|
-
const desiredDir = requestedDir ?
|
|
80721
|
-
const upstreamRoot =
|
|
80722
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
81290
|
+
const canonicalUserDir = path39.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
81291
|
+
const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
|
|
81292
|
+
const upstreamRoot = path39.resolve(this.providerLoader.getUpstreamDir());
|
|
81293
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
|
|
80723
81294
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
80724
81295
|
}
|
|
80725
|
-
if (
|
|
81296
|
+
if (path39.basename(desiredDir) !== type) {
|
|
80726
81297
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
80727
81298
|
}
|
|
80728
81299
|
const sourceDir = this.findProviderDir(type);
|
|
80729
81300
|
if (!sourceDir) {
|
|
80730
81301
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
80731
81302
|
}
|
|
80732
|
-
if (!
|
|
80733
|
-
|
|
80734
|
-
|
|
81303
|
+
if (!fs27.existsSync(desiredDir)) {
|
|
81304
|
+
fs27.mkdirSync(path39.dirname(desiredDir), { recursive: true });
|
|
81305
|
+
fs27.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
80735
81306
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
80736
81307
|
}
|
|
80737
|
-
const providerJson =
|
|
80738
|
-
if (!
|
|
81308
|
+
const providerJson = path39.join(desiredDir, "provider.json");
|
|
81309
|
+
if (!fs27.existsSync(providerJson)) {
|
|
80739
81310
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
80740
81311
|
}
|
|
80741
81312
|
return { dir: desiredDir };
|
|
@@ -80770,7 +81341,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80770
81341
|
setMode: "set_mode.js"
|
|
80771
81342
|
};
|
|
80772
81343
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
80773
|
-
const scriptsDir =
|
|
81344
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
80774
81345
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
80775
81346
|
if (latestScriptsDir) {
|
|
80776
81347
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -80778,10 +81349,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80778
81349
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
80779
81350
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
80780
81351
|
lines.push("");
|
|
80781
|
-
for (const file2 of
|
|
81352
|
+
for (const file2 of fs27.readdirSync(latestScriptsDir)) {
|
|
80782
81353
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
80783
81354
|
try {
|
|
80784
|
-
const content =
|
|
81355
|
+
const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
80785
81356
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
80786
81357
|
lines.push("```javascript");
|
|
80787
81358
|
lines.push(content);
|
|
@@ -80791,14 +81362,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80791
81362
|
}
|
|
80792
81363
|
}
|
|
80793
81364
|
}
|
|
80794
|
-
const refFiles =
|
|
81365
|
+
const refFiles = fs27.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
80795
81366
|
if (refFiles.length > 0) {
|
|
80796
81367
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
80797
81368
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
80798
81369
|
lines.push("");
|
|
80799
81370
|
for (const file2 of refFiles) {
|
|
80800
81371
|
try {
|
|
80801
|
-
const content =
|
|
81372
|
+
const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
80802
81373
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
80803
81374
|
lines.push("```javascript");
|
|
80804
81375
|
lines.push(content);
|
|
@@ -80839,11 +81410,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
80839
81410
|
lines.push("");
|
|
80840
81411
|
}
|
|
80841
81412
|
}
|
|
80842
|
-
const docsDir =
|
|
81413
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
80843
81414
|
const loadGuide = (name) => {
|
|
80844
81415
|
try {
|
|
80845
|
-
const p =
|
|
80846
|
-
if (
|
|
81416
|
+
const p = path39.join(docsDir, name);
|
|
81417
|
+
if (fs27.existsSync(p)) return fs27.readFileSync(p, "utf-8");
|
|
80847
81418
|
} catch {
|
|
80848
81419
|
}
|
|
80849
81420
|
return null;
|
|
@@ -81016,7 +81587,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
81016
81587
|
parseApproval: "parse_approval.js"
|
|
81017
81588
|
};
|
|
81018
81589
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
81019
|
-
const scriptsDir =
|
|
81590
|
+
const scriptsDir = path39.join(providerDir, "scripts");
|
|
81020
81591
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
81021
81592
|
if (latestScriptsDir) {
|
|
81022
81593
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -81024,11 +81595,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
81024
81595
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
81025
81596
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
81026
81597
|
lines.push("");
|
|
81027
|
-
for (const file2 of
|
|
81598
|
+
for (const file2 of fs27.readdirSync(latestScriptsDir)) {
|
|
81028
81599
|
if (!file2.endsWith(".js")) continue;
|
|
81029
81600
|
if (!targetFileNames.has(file2)) continue;
|
|
81030
81601
|
try {
|
|
81031
|
-
const content =
|
|
81602
|
+
const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
81032
81603
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
81033
81604
|
lines.push("```javascript");
|
|
81034
81605
|
lines.push(content);
|
|
@@ -81037,14 +81608,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
81037
81608
|
} catch {
|
|
81038
81609
|
}
|
|
81039
81610
|
}
|
|
81040
|
-
const refFiles =
|
|
81611
|
+
const refFiles = fs27.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
81041
81612
|
if (refFiles.length > 0) {
|
|
81042
81613
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
81043
81614
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
81044
81615
|
lines.push("");
|
|
81045
81616
|
for (const file2 of refFiles) {
|
|
81046
81617
|
try {
|
|
81047
|
-
const content =
|
|
81618
|
+
const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
81048
81619
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
81049
81620
|
lines.push("```javascript");
|
|
81050
81621
|
lines.push(content);
|
|
@@ -81077,11 +81648,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
81077
81648
|
lines.push("");
|
|
81078
81649
|
}
|
|
81079
81650
|
}
|
|
81080
|
-
const docsDir =
|
|
81651
|
+
const docsDir = path39.join(providerDir, "../../docs");
|
|
81081
81652
|
const loadGuide = (name) => {
|
|
81082
81653
|
try {
|
|
81083
|
-
const p =
|
|
81084
|
-
if (
|
|
81654
|
+
const p = path39.join(docsDir, name);
|
|
81655
|
+
if (fs27.existsSync(p)) return fs27.readFileSync(p, "utf-8");
|
|
81085
81656
|
} catch {
|
|
81086
81657
|
}
|
|
81087
81658
|
return null;
|
|
@@ -81974,8 +82545,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
81974
82545
|
const res = await fetch(extension.vsixUrl);
|
|
81975
82546
|
if (res.ok) {
|
|
81976
82547
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
81977
|
-
const
|
|
81978
|
-
|
|
82548
|
+
const fs28 = await import("fs");
|
|
82549
|
+
fs28.writeFileSync(vsixPath, buffer);
|
|
81979
82550
|
return new Promise((resolve23) => {
|
|
81980
82551
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
81981
82552
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|