@adhdev/daemon-core 0.9.82-rc.377 → 0.9.82-rc.378
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/commands/router.d.ts +3 -470
- package/dist/index.js +212 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +213 -195
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/package.json +2 -2
- package/src/commands/router.ts +59 -3624
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-refine-gates.ts +1652 -0
package/dist/index.js
CHANGED
|
@@ -316,10 +316,10 @@ function readInjected(value) {
|
|
|
316
316
|
}
|
|
317
317
|
function getDaemonBuildInfo() {
|
|
318
318
|
if (cached) return cached;
|
|
319
|
-
const commit = readInjected(true ? "
|
|
320
|
-
const commitShort = readInjected(true ? "
|
|
321
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
322
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
319
|
+
const commit = readInjected(true ? "3920b23e979544d74c4024a0ff18e5deab7b2932" : void 0) ?? "unknown";
|
|
320
|
+
const commitShort = readInjected(true ? "3920b23e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
321
|
+
const version = readInjected(true ? "0.9.82-rc.378" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
322
|
+
const builtAt = readInjected(true ? "2026-06-25T07:59:13.420Z" : void 0);
|
|
323
323
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
324
|
return cached;
|
|
325
325
|
}
|
|
@@ -7271,8 +7271,8 @@ function stripCoordinatorWrapperFile(filePath) {
|
|
|
7271
7271
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
7272
7272
|
if (!remaining.trim()) {
|
|
7273
7273
|
try {
|
|
7274
|
-
const
|
|
7275
|
-
|
|
7274
|
+
const fs38 = require("fs");
|
|
7275
|
+
fs38.unlinkSync(filePath);
|
|
7276
7276
|
} catch {
|
|
7277
7277
|
}
|
|
7278
7278
|
} else {
|
|
@@ -9800,9 +9800,9 @@ function findBinary(name) {
|
|
|
9800
9800
|
for (const ext of exes) {
|
|
9801
9801
|
const fullPath = path11.join(p, trimmed + ext);
|
|
9802
9802
|
try {
|
|
9803
|
-
const
|
|
9804
|
-
if (
|
|
9805
|
-
const stat2 =
|
|
9803
|
+
const fs38 = require("fs");
|
|
9804
|
+
if (fs38.existsSync(fullPath)) {
|
|
9805
|
+
const stat2 = fs38.statSync(fullPath);
|
|
9806
9806
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
9807
9807
|
return fullPath;
|
|
9808
9808
|
}
|
|
@@ -9816,12 +9816,12 @@ function findBinary(name) {
|
|
|
9816
9816
|
function isScriptBinary(binaryPath) {
|
|
9817
9817
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
9818
9818
|
try {
|
|
9819
|
-
const
|
|
9820
|
-
const resolved =
|
|
9819
|
+
const fs38 = require("fs");
|
|
9820
|
+
const resolved = fs38.realpathSync(binaryPath);
|
|
9821
9821
|
const head = Buffer.alloc(8);
|
|
9822
|
-
const fd =
|
|
9823
|
-
|
|
9824
|
-
|
|
9822
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9823
|
+
fs38.readSync(fd, head, 0, 8, 0);
|
|
9824
|
+
fs38.closeSync(fd);
|
|
9825
9825
|
let i = 0;
|
|
9826
9826
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
9827
9827
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -9832,12 +9832,12 @@ function isScriptBinary(binaryPath) {
|
|
|
9832
9832
|
function looksLikeMachOOrElf(filePath) {
|
|
9833
9833
|
if (!path11.isAbsolute(filePath)) return false;
|
|
9834
9834
|
try {
|
|
9835
|
-
const
|
|
9836
|
-
const resolved =
|
|
9835
|
+
const fs38 = require("fs");
|
|
9836
|
+
const resolved = fs38.realpathSync(filePath);
|
|
9837
9837
|
const buf = Buffer.alloc(8);
|
|
9838
|
-
const fd =
|
|
9839
|
-
|
|
9840
|
-
|
|
9838
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9839
|
+
fs38.readSync(fd, buf, 0, 8, 0);
|
|
9840
|
+
fs38.closeSync(fd);
|
|
9841
9841
|
let i = 0;
|
|
9842
9842
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
9843
9843
|
const b = buf.subarray(i);
|
|
@@ -16977,8 +16977,8 @@ var init_pty_transport = __esm({
|
|
|
16977
16977
|
let cwd = options.cwd;
|
|
16978
16978
|
if (cwd) {
|
|
16979
16979
|
try {
|
|
16980
|
-
const
|
|
16981
|
-
const stat2 =
|
|
16980
|
+
const fs38 = require("fs");
|
|
16981
|
+
const stat2 = fs38.statSync(cwd);
|
|
16982
16982
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
16983
16983
|
} catch {
|
|
16984
16984
|
cwd = os14.homedir();
|
|
@@ -32922,7 +32922,7 @@ var DaemonCommandHandler = class {
|
|
|
32922
32922
|
return { success: false, error: "invalid type" };
|
|
32923
32923
|
}
|
|
32924
32924
|
const https = require("https");
|
|
32925
|
-
const
|
|
32925
|
+
const fs38 = require("fs");
|
|
32926
32926
|
const path43 = require("path");
|
|
32927
32927
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
32928
32928
|
function fetchText(url, timeoutMs) {
|
|
@@ -32965,7 +32965,7 @@ var DaemonCommandHandler = class {
|
|
|
32965
32965
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
32966
32966
|
return { success: false, error: "install path escaped upstream root" };
|
|
32967
32967
|
}
|
|
32968
|
-
|
|
32968
|
+
fs38.mkdirSync(targetDir, { recursive: true });
|
|
32969
32969
|
let manifestProbe = {};
|
|
32970
32970
|
try {
|
|
32971
32971
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -32990,7 +32990,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32990
32990
|
}
|
|
32991
32991
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
32992
32992
|
const targetPath = path43.join(targetDir, targetFile);
|
|
32993
|
-
|
|
32993
|
+
fs38.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
32994
32994
|
const manifestJson = JSON.parse(manifestBody);
|
|
32995
32995
|
const scriptFetch = await this.fetchProviderSources(
|
|
32996
32996
|
manifestJson,
|
|
@@ -33060,7 +33060,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33060
33060
|
const repo = source.repo;
|
|
33061
33061
|
const ref = source.ref;
|
|
33062
33062
|
const https = require("https");
|
|
33063
|
-
const
|
|
33063
|
+
const fs38 = require("fs");
|
|
33064
33064
|
const path43 = require("path");
|
|
33065
33065
|
function fetchJson(url, timeoutMs) {
|
|
33066
33066
|
return new Promise((resolve24, reject) => {
|
|
@@ -33144,8 +33144,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33144
33144
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
33145
33145
|
const outPath = path43.resolve(path43.join(sharedTargetDir, relInside));
|
|
33146
33146
|
if (!outPath.startsWith(path43.resolve(sharedTargetDir) + path43.sep)) continue;
|
|
33147
|
-
|
|
33148
|
-
|
|
33147
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
33148
|
+
fs38.writeFileSync(outPath, body);
|
|
33149
33149
|
fetchedCount++;
|
|
33150
33150
|
} catch (e) {
|
|
33151
33151
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -33183,8 +33183,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33183
33183
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
33184
33184
|
continue;
|
|
33185
33185
|
}
|
|
33186
|
-
|
|
33187
|
-
|
|
33186
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
33187
|
+
fs38.writeFileSync(outPath, body);
|
|
33188
33188
|
fetchedCount++;
|
|
33189
33189
|
} catch (e) {
|
|
33190
33190
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -33212,7 +33212,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33212
33212
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
33213
33213
|
return { success: false, error: `unknown category: ${category}` };
|
|
33214
33214
|
}
|
|
33215
|
-
const
|
|
33215
|
+
const fs38 = require("fs");
|
|
33216
33216
|
const path43 = require("path");
|
|
33217
33217
|
try {
|
|
33218
33218
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -33221,10 +33221,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33221
33221
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
33222
33222
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
33223
33223
|
}
|
|
33224
|
-
if (!
|
|
33224
|
+
if (!fs38.existsSync(targetDir)) {
|
|
33225
33225
|
return { success: false, error: "not installed" };
|
|
33226
33226
|
}
|
|
33227
|
-
|
|
33227
|
+
fs38.rmSync(targetDir, { recursive: true, force: true });
|
|
33228
33228
|
if (this._ctx.providerLoader) {
|
|
33229
33229
|
this._ctx.providerLoader.reload();
|
|
33230
33230
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -33240,28 +33240,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33240
33240
|
* the UI and by the update checker.
|
|
33241
33241
|
*/
|
|
33242
33242
|
handleListInstalledProviders(_args) {
|
|
33243
|
-
const
|
|
33243
|
+
const fs38 = require("fs");
|
|
33244
33244
|
const path43 = require("path");
|
|
33245
33245
|
const installRoot = this.getUpstreamInstallRoot();
|
|
33246
|
-
if (!
|
|
33246
|
+
if (!fs38.existsSync(installRoot)) return { success: true, providers: [] };
|
|
33247
33247
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
33248
33248
|
const items = [];
|
|
33249
33249
|
for (const category of CATEGORIES) {
|
|
33250
33250
|
const categoryDir = path43.join(installRoot, category);
|
|
33251
|
-
if (!
|
|
33251
|
+
if (!fs38.existsSync(categoryDir)) continue;
|
|
33252
33252
|
let entries;
|
|
33253
33253
|
try {
|
|
33254
|
-
entries =
|
|
33254
|
+
entries = fs38.readdirSync(categoryDir);
|
|
33255
33255
|
} catch {
|
|
33256
33256
|
continue;
|
|
33257
33257
|
}
|
|
33258
33258
|
for (const type of entries) {
|
|
33259
33259
|
const v1Path = path43.join(categoryDir, type, "provider.v1.json");
|
|
33260
33260
|
const v0Path = path43.join(categoryDir, type, "provider.json");
|
|
33261
|
-
const manifestPath =
|
|
33261
|
+
const manifestPath = fs38.existsSync(v1Path) ? v1Path : fs38.existsSync(v0Path) ? v0Path : null;
|
|
33262
33262
|
if (!manifestPath) continue;
|
|
33263
33263
|
try {
|
|
33264
|
-
const m = JSON.parse(
|
|
33264
|
+
const m = JSON.parse(fs38.readFileSync(manifestPath, "utf-8"));
|
|
33265
33265
|
items.push({
|
|
33266
33266
|
type,
|
|
33267
33267
|
category,
|
|
@@ -33372,7 +33372,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33372
33372
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
33373
33373
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
33374
33374
|
}
|
|
33375
|
-
const
|
|
33375
|
+
const fs38 = require("fs");
|
|
33376
33376
|
const path43 = require("path");
|
|
33377
33377
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
33378
33378
|
const file = ext.loadExternalSources();
|
|
@@ -33383,8 +33383,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33383
33383
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
33384
33384
|
}
|
|
33385
33385
|
const sourceDir = path43.join(ext.externalRoot(), requestedName);
|
|
33386
|
-
if (!
|
|
33387
|
-
if (
|
|
33386
|
+
if (!fs38.existsSync(ext.externalRoot())) fs38.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
33387
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33388
33388
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
33389
33389
|
}
|
|
33390
33390
|
const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
|
|
@@ -33394,7 +33394,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33394
33394
|
});
|
|
33395
33395
|
if (clone.status !== 0) {
|
|
33396
33396
|
try {
|
|
33397
|
-
|
|
33397
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33398
33398
|
} catch {
|
|
33399
33399
|
}
|
|
33400
33400
|
return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
|
|
@@ -33438,15 +33438,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33438
33438
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
33439
33439
|
if (!name) return { success: false, error: "name is required" };
|
|
33440
33440
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
33441
|
-
const
|
|
33441
|
+
const fs38 = require("fs");
|
|
33442
33442
|
const path43 = require("path");
|
|
33443
33443
|
const file = ext.loadExternalSources();
|
|
33444
33444
|
const match = file.sources.find((s2) => s2.name === name);
|
|
33445
33445
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
33446
33446
|
const sourceDir = path43.join(ext.externalRoot(), name);
|
|
33447
|
-
if (
|
|
33447
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33448
33448
|
try {
|
|
33449
|
-
|
|
33449
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33450
33450
|
} catch (e) {
|
|
33451
33451
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
33452
33452
|
}
|
|
@@ -34227,14 +34227,14 @@ var statusMetaHandlers = {
|
|
|
34227
34227
|
// src/commands/low-family/coordinator-prompt.ts
|
|
34228
34228
|
var coordinatorPromptHandlers = {
|
|
34229
34229
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
34230
|
-
const
|
|
34230
|
+
const fs38 = await import("fs");
|
|
34231
34231
|
const path43 = await import("path");
|
|
34232
34232
|
const os30 = await import("os");
|
|
34233
34233
|
const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
34234
34234
|
const entries = {};
|
|
34235
34235
|
try {
|
|
34236
|
-
if (
|
|
34237
|
-
for (const name of
|
|
34236
|
+
if (fs38.existsSync(dir)) {
|
|
34237
|
+
for (const name of fs38.readdirSync(dir)) {
|
|
34238
34238
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
34239
34239
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
34240
34240
|
const m = matchAppend || matchOverride;
|
|
@@ -34244,7 +34244,7 @@ var coordinatorPromptHandlers = {
|
|
|
34244
34244
|
const full = path43.join(dir, name);
|
|
34245
34245
|
let content = "";
|
|
34246
34246
|
try {
|
|
34247
|
-
content =
|
|
34247
|
+
content = fs38.readFileSync(full, "utf8");
|
|
34248
34248
|
} catch {
|
|
34249
34249
|
}
|
|
34250
34250
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -34258,7 +34258,7 @@ var coordinatorPromptHandlers = {
|
|
|
34258
34258
|
return { success: true, dir, entries };
|
|
34259
34259
|
},
|
|
34260
34260
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
34261
|
-
const
|
|
34261
|
+
const fs38 = await import("fs");
|
|
34262
34262
|
const path43 = await import("path");
|
|
34263
34263
|
const os30 = await import("os");
|
|
34264
34264
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -34271,11 +34271,11 @@ var coordinatorPromptHandlers = {
|
|
|
34271
34271
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
34272
34272
|
const full = path43.join(dir, filename);
|
|
34273
34273
|
try {
|
|
34274
|
-
|
|
34274
|
+
fs38.mkdirSync(dir, { recursive: true });
|
|
34275
34275
|
if (content.trim()) {
|
|
34276
|
-
|
|
34277
|
-
} else if (
|
|
34278
|
-
|
|
34276
|
+
fs38.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
34277
|
+
} else if (fs38.existsSync(full)) {
|
|
34278
|
+
fs38.unlinkSync(full);
|
|
34279
34279
|
}
|
|
34280
34280
|
return { success: true, path: full, kind, key };
|
|
34281
34281
|
} catch (error) {
|
|
@@ -45359,7 +45359,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45359
45359
|
}
|
|
45360
45360
|
if (providerDir) {
|
|
45361
45361
|
try {
|
|
45362
|
-
const
|
|
45362
|
+
const fs38 = require("fs");
|
|
45363
45363
|
const path43 = require("path");
|
|
45364
45364
|
const candidates = [];
|
|
45365
45365
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -45371,13 +45371,13 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45371
45371
|
}
|
|
45372
45372
|
candidates.push(path43.join(providerDir, "specs", "default.json"));
|
|
45373
45373
|
candidates.push(path43.join(providerDir, "spec.json"));
|
|
45374
|
-
const specPath = candidates.find((p) =>
|
|
45374
|
+
const specPath = candidates.find((p) => fs38.existsSync(p));
|
|
45375
45375
|
if (specPath) {
|
|
45376
45376
|
resolved._resolvedSpecPath = specPath;
|
|
45377
45377
|
let specControls;
|
|
45378
45378
|
let nh;
|
|
45379
45379
|
try {
|
|
45380
|
-
const rawSpec = JSON.parse(
|
|
45380
|
+
const rawSpec = JSON.parse(fs38.readFileSync(specPath, "utf8"));
|
|
45381
45381
|
specControls = rawSpec.control_bar;
|
|
45382
45382
|
nh = rawSpec.native_history;
|
|
45383
45383
|
} catch {
|
|
@@ -45409,7 +45409,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45409
45409
|
reader = (input) => executeNativeHistory(nh, input);
|
|
45410
45410
|
} else if (nh.override_path) {
|
|
45411
45411
|
const overrideFile = path43.resolve(providerDir, nh.override_path);
|
|
45412
|
-
if (
|
|
45412
|
+
if (fs38.existsSync(overrideFile)) {
|
|
45413
45413
|
try {
|
|
45414
45414
|
registerProviderScriptRootSafely(path43.dirname(path43.dirname(providerDir)));
|
|
45415
45415
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -46591,7 +46591,7 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46591
46591
|
}
|
|
46592
46592
|
} else if (plat === "win32") {
|
|
46593
46593
|
try {
|
|
46594
|
-
const
|
|
46594
|
+
const fs38 = require("fs");
|
|
46595
46595
|
const appNameMap = getMacAppIdentifiers();
|
|
46596
46596
|
const appName = appNameMap[ideId];
|
|
46597
46597
|
if (appName) {
|
|
@@ -46600,8 +46600,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46600
46600
|
appName,
|
|
46601
46601
|
"storage.json"
|
|
46602
46602
|
);
|
|
46603
|
-
if (
|
|
46604
|
-
const data = JSON.parse(
|
|
46603
|
+
if (fs38.existsSync(storagePath)) {
|
|
46604
|
+
const data = JSON.parse(fs38.readFileSync(storagePath, "utf-8"));
|
|
46605
46605
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
46606
46606
|
if (workspaces.length > 0) {
|
|
46607
46607
|
const recent = workspaces[0];
|
|
@@ -48559,7 +48559,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48559
48559
|
workspace
|
|
48560
48560
|
};
|
|
48561
48561
|
}
|
|
48562
|
-
const { existsSync:
|
|
48562
|
+
const { existsSync: existsSync52, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
48563
48563
|
const { dirname: dirname17 } = await import("path");
|
|
48564
48564
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48565
48565
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -48602,7 +48602,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48602
48602
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
48603
48603
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
48604
48604
|
}
|
|
48605
|
-
const hadExistingMcpConfig =
|
|
48605
|
+
const hadExistingMcpConfig = existsSync52(mcpConfigPath);
|
|
48606
48606
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
48607
48607
|
if (hermesBaseConfig) {
|
|
48608
48608
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
@@ -49207,7 +49207,7 @@ var meshStatusHandlers = {
|
|
|
49207
49207
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
49208
49208
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
49209
49209
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
49210
|
-
const { existsSync:
|
|
49210
|
+
const { existsSync: existsSync52 } = await import("fs");
|
|
49211
49211
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
49212
49212
|
const mesh = meshRecord?.mesh;
|
|
49213
49213
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -49226,7 +49226,7 @@ var meshStatusHandlers = {
|
|
|
49226
49226
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
49227
49227
|
for (const item of derivation.items) {
|
|
49228
49228
|
const workspace = item.workspace;
|
|
49229
|
-
if (!workspace || !
|
|
49229
|
+
if (!workspace || !existsSync52(workspace)) continue;
|
|
49230
49230
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
49231
49231
|
try {
|
|
49232
49232
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -49275,8 +49275,6 @@ var highFamilyRegistry = new Map(
|
|
|
49275
49275
|
);
|
|
49276
49276
|
|
|
49277
49277
|
// src/commands/router.ts
|
|
49278
|
-
init_cli_detector();
|
|
49279
|
-
init_git_status();
|
|
49280
49278
|
init_dist();
|
|
49281
49279
|
init_logger();
|
|
49282
49280
|
|
|
@@ -49426,7 +49424,6 @@ function getRecentCommands(count = 50) {
|
|
|
49426
49424
|
cleanOldFiles();
|
|
49427
49425
|
|
|
49428
49426
|
// src/commands/router.ts
|
|
49429
|
-
var yaml4 = __toESM(require("js-yaml"));
|
|
49430
49427
|
init_mesh_events();
|
|
49431
49428
|
init_mesh_host_ownership();
|
|
49432
49429
|
|
|
@@ -49519,13 +49516,18 @@ function orderMeshRefineBatchNodes(changeAreas) {
|
|
|
49519
49516
|
|
|
49520
49517
|
// src/commands/router.ts
|
|
49521
49518
|
init_mesh_work_queue();
|
|
49522
|
-
init_mesh_warmup_deadline();
|
|
49523
49519
|
init_repo_mesh_types();
|
|
49524
|
-
var
|
|
49525
|
-
var
|
|
49520
|
+
var import_path15 = require("path");
|
|
49521
|
+
var fs32 = __toESM(require("fs"));
|
|
49522
|
+
var import_node_child_process7 = require("child_process");
|
|
49523
|
+
|
|
49524
|
+
// src/mesh/mesh-node-identity.ts
|
|
49525
|
+
init_cli_detector();
|
|
49526
|
+
init_git_status();
|
|
49527
|
+
init_dist();
|
|
49528
|
+
init_logger();
|
|
49529
|
+
init_mesh_warmup_deadline();
|
|
49526
49530
|
var fs29 = __toESM(require("fs"));
|
|
49527
|
-
var import_node_child_process6 = require("child_process");
|
|
49528
|
-
init_resolve_executable();
|
|
49529
49531
|
init_runtime_defaults();
|
|
49530
49532
|
function readProviderPriorityFromPolicy(policy) {
|
|
49531
49533
|
const record = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
@@ -50746,6 +50748,13 @@ async function resolveProviderTypeFromPriority(args) {
|
|
|
50746
50748
|
}
|
|
50747
50749
|
return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
|
|
50748
50750
|
}
|
|
50751
|
+
|
|
50752
|
+
// src/mesh/mesh-refine-gates.ts
|
|
50753
|
+
init_git_status();
|
|
50754
|
+
var import_path13 = require("path");
|
|
50755
|
+
var fs30 = __toESM(require("fs"));
|
|
50756
|
+
var import_node_child_process6 = require("child_process");
|
|
50757
|
+
init_resolve_executable();
|
|
50749
50758
|
var REFINE_VALIDATION_TIMEOUT_MS = 12e4;
|
|
50750
50759
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
50751
50760
|
var REFINE_VALIDATION_SUMMARY_CHARS = 2e3;
|
|
@@ -50799,18 +50808,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
50799
50808
|
return { enabled: false };
|
|
50800
50809
|
}
|
|
50801
50810
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
50802
|
-
const { execFileSync:
|
|
50811
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50803
50812
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
50804
50813
|
if (excludePaths.length > 0) {
|
|
50805
50814
|
diffArgs.push("--", ".", ...excludePaths.map((path43) => `:(exclude)${path43}`));
|
|
50806
50815
|
}
|
|
50807
|
-
const diff =
|
|
50816
|
+
const diff = execFileSync8("git", diffArgs, {
|
|
50808
50817
|
cwd,
|
|
50809
50818
|
encoding: "utf8",
|
|
50810
50819
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
50811
50820
|
});
|
|
50812
50821
|
if (!diff.trim()) return "";
|
|
50813
|
-
const patchId =
|
|
50822
|
+
const patchId = execFileSync8("git", ["patch-id", "--stable"], {
|
|
50814
50823
|
cwd,
|
|
50815
50824
|
input: diff,
|
|
50816
50825
|
encoding: "utf8",
|
|
@@ -50821,8 +50830,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
50821
50830
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
50822
50831
|
const startedAt = Date.now();
|
|
50823
50832
|
try {
|
|
50824
|
-
const { execFileSync:
|
|
50825
|
-
const git = (args) =>
|
|
50833
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50834
|
+
const git = (args) => execFileSync8("git", args, {
|
|
50826
50835
|
cwd: repoRoot,
|
|
50827
50836
|
encoding: "utf8",
|
|
50828
50837
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50913,8 +50922,8 @@ ${e?.stderr || ""}`
|
|
|
50913
50922
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
50914
50923
|
const startedAt = Date.now();
|
|
50915
50924
|
try {
|
|
50916
|
-
const { execFileSync:
|
|
50917
|
-
const git = (gitArgs) =>
|
|
50925
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50926
|
+
const git = (gitArgs) => execFileSync8("git", gitArgs, {
|
|
50918
50927
|
cwd: repoRoot,
|
|
50919
50928
|
encoding: "utf8",
|
|
50920
50929
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50977,8 +50986,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
50977
50986
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
50978
50987
|
const startedAt = Date.now();
|
|
50979
50988
|
try {
|
|
50980
|
-
const { execFileSync:
|
|
50981
|
-
const git = (args, opts) =>
|
|
50989
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50990
|
+
const git = (args, opts) => execFileSync8("git", args, {
|
|
50982
50991
|
cwd: opts?.cwd || repoRoot,
|
|
50983
50992
|
encoding: "utf8",
|
|
50984
50993
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -51101,7 +51110,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
|
|
|
51101
51110
|
if (!baseCommit || !branchCommit) return false;
|
|
51102
51111
|
if (baseCommit === branchCommit) return true;
|
|
51103
51112
|
try {
|
|
51104
|
-
if (!
|
|
51113
|
+
if (!fs30.existsSync(submoduleRepoPath)) return false;
|
|
51105
51114
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
51106
51115
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
51107
51116
|
(0, import_node_child_process6.execFileSync)("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -51218,7 +51227,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
51218
51227
|
return newTree || void 0;
|
|
51219
51228
|
} finally {
|
|
51220
51229
|
try {
|
|
51221
|
-
|
|
51230
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
51222
51231
|
} catch {
|
|
51223
51232
|
}
|
|
51224
51233
|
}
|
|
@@ -51293,7 +51302,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
51293
51302
|
return newTree || void 0;
|
|
51294
51303
|
} finally {
|
|
51295
51304
|
try {
|
|
51296
|
-
|
|
51305
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
51297
51306
|
} catch {
|
|
51298
51307
|
}
|
|
51299
51308
|
}
|
|
@@ -51399,7 +51408,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51399
51408
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
51400
51409
|
};
|
|
51401
51410
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
51402
|
-
if (!
|
|
51411
|
+
if (!fs30.existsSync(worktreeSubmodulePath)) return false;
|
|
51403
51412
|
try {
|
|
51404
51413
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
51405
51414
|
} catch {
|
|
@@ -51422,7 +51431,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51422
51431
|
reachable: false
|
|
51423
51432
|
};
|
|
51424
51433
|
try {
|
|
51425
|
-
if (!
|
|
51434
|
+
if (!fs30.existsSync(submodulePath)) {
|
|
51426
51435
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
51427
51436
|
entry.publishRequired = true;
|
|
51428
51437
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -51659,9 +51668,9 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51659
51668
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
51660
51669
|
};
|
|
51661
51670
|
const dependenciesLikelyMissing = (cwd) => {
|
|
51662
|
-
if (!
|
|
51663
|
-
if (
|
|
51664
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
51671
|
+
if (!fs30.existsSync((0, import_path13.join)(cwd, "package.json"))) return false;
|
|
51672
|
+
if (fs30.existsSync((0, import_path13.join)(cwd, "node_modules"))) return false;
|
|
51673
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs30.existsSync((0, import_path13.join)(cwd, lock)));
|
|
51665
51674
|
};
|
|
51666
51675
|
if (runLegacyBootstrapCommands) {
|
|
51667
51676
|
summary.bootstrap = { stage: "legacy" };
|
|
@@ -51748,6 +51757,13 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51748
51757
|
summary.status = "passed";
|
|
51749
51758
|
return summary;
|
|
51750
51759
|
}
|
|
51760
|
+
|
|
51761
|
+
// src/mesh/mesh-coordinator-config.ts
|
|
51762
|
+
init_logger();
|
|
51763
|
+
var yaml4 = __toESM(require("js-yaml"));
|
|
51764
|
+
var import_os4 = require("os");
|
|
51765
|
+
var import_path14 = require("path");
|
|
51766
|
+
var fs31 = __toESM(require("fs"));
|
|
51751
51767
|
function loadYamlModule() {
|
|
51752
51768
|
return yaml4;
|
|
51753
51769
|
}
|
|
@@ -51766,14 +51782,14 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
|
|
|
51766
51782
|
}
|
|
51767
51783
|
function resolveHermesUserHome() {
|
|
51768
51784
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
51769
|
-
return explicitHome || (0,
|
|
51785
|
+
return explicitHome || (0, import_path14.join)((0, import_os4.homedir)(), ".hermes");
|
|
51770
51786
|
}
|
|
51771
51787
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
51772
51788
|
const sourceHome = resolveHermesUserHome();
|
|
51773
|
-
const sourceConfigPath = (0,
|
|
51774
|
-
if (!
|
|
51775
|
-
if ((0,
|
|
51776
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
51789
|
+
const sourceConfigPath = (0, import_path14.join)(sourceHome, "config.yaml");
|
|
51790
|
+
if (!fs31.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51791
|
+
if ((0, import_path14.resolve)(sourceConfigPath) === (0, import_path14.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51792
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs31.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
51777
51793
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
51778
51794
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
51779
51795
|
}
|
|
@@ -51806,18 +51822,20 @@ function stripHermesCoordinatorTempModelProviderOverrides(config) {
|
|
|
51806
51822
|
return sanitized;
|
|
51807
51823
|
}
|
|
51808
51824
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
51809
|
-
if ((0,
|
|
51825
|
+
if ((0, import_path14.resolve)(sourceHome) === (0, import_path14.resolve)(targetHome)) return;
|
|
51810
51826
|
for (const fileName of [".env", "auth.json"]) {
|
|
51811
|
-
const sourcePath = (0,
|
|
51812
|
-
const targetPath = (0,
|
|
51813
|
-
if (!
|
|
51827
|
+
const sourcePath = (0, import_path14.join)(sourceHome, fileName);
|
|
51828
|
+
const targetPath = (0, import_path14.join)(targetHome, fileName);
|
|
51829
|
+
if (!fs31.existsSync(sourcePath)) continue;
|
|
51814
51830
|
try {
|
|
51815
|
-
|
|
51831
|
+
fs31.copyFileSync(sourcePath, targetPath);
|
|
51816
51832
|
} catch (error) {
|
|
51817
51833
|
LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
|
|
51818
51834
|
}
|
|
51819
51835
|
}
|
|
51820
51836
|
}
|
|
51837
|
+
|
|
51838
|
+
// src/commands/router.ts
|
|
51821
51839
|
var CHAT_COMMANDS = [
|
|
51822
51840
|
"send_chat",
|
|
51823
51841
|
"new_chat",
|
|
@@ -52284,7 +52302,7 @@ var DaemonCommandRouter = class {
|
|
|
52284
52302
|
const nodeId = readInlineMeshNodeId(node);
|
|
52285
52303
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
52286
52304
|
const workspace = readStringValue(node?.workspace);
|
|
52287
|
-
if (workspace &&
|
|
52305
|
+
if (workspace && fs32.existsSync(workspace)) {
|
|
52288
52306
|
tombstones.delete(nodeId);
|
|
52289
52307
|
return true;
|
|
52290
52308
|
}
|
|
@@ -52319,14 +52337,14 @@ var DaemonCommandRouter = class {
|
|
|
52319
52337
|
* to give handles time to release, and reports whether residue remains.
|
|
52320
52338
|
*/
|
|
52321
52339
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
52322
|
-
if (!dir || !
|
|
52340
|
+
if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
52323
52341
|
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
52324
52342
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
52325
52343
|
let lastErr;
|
|
52326
52344
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
52327
52345
|
try {
|
|
52328
|
-
|
|
52329
|
-
if (!
|
|
52346
|
+
fs32.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
52347
|
+
if (!fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
52330
52348
|
lastErr = new Error("directory still present after rmSync");
|
|
52331
52349
|
} catch (e) {
|
|
52332
52350
|
lastErr = e;
|
|
@@ -52337,7 +52355,7 @@ var DaemonCommandRouter = class {
|
|
|
52337
52355
|
}
|
|
52338
52356
|
await sleep3(150 * (attempt + 1));
|
|
52339
52357
|
}
|
|
52340
|
-
return
|
|
52358
|
+
return fs32.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
52341
52359
|
}
|
|
52342
52360
|
async cleanupLocalWorktreeNode(args) {
|
|
52343
52361
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
@@ -52349,13 +52367,13 @@ var DaemonCommandRouter = class {
|
|
|
52349
52367
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
52350
52368
|
};
|
|
52351
52369
|
}
|
|
52352
|
-
const worktreeExists =
|
|
52370
|
+
const worktreeExists = fs32.existsSync(workspace);
|
|
52353
52371
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
52354
52372
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
52355
52373
|
if (!worktreeExists) {
|
|
52356
52374
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
52357
52375
|
}
|
|
52358
|
-
if (!repoRoot || !
|
|
52376
|
+
if (!repoRoot || !fs32.existsSync(repoRoot)) {
|
|
52359
52377
|
return {
|
|
52360
52378
|
success: false,
|
|
52361
52379
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -52373,9 +52391,9 @@ var DaemonCommandRouter = class {
|
|
|
52373
52391
|
}
|
|
52374
52392
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
52375
52393
|
const normalizePath = (value) => {
|
|
52376
|
-
const resolved = (0,
|
|
52394
|
+
const resolved = (0, import_path15.resolve)(value);
|
|
52377
52395
|
try {
|
|
52378
|
-
return
|
|
52396
|
+
return fs32.realpathSync(resolved);
|
|
52379
52397
|
} catch {
|
|
52380
52398
|
return resolved;
|
|
52381
52399
|
}
|
|
@@ -53169,7 +53187,7 @@ ${tail}` : ""
|
|
|
53169
53187
|
let didAutoRebase = false;
|
|
53170
53188
|
let isBehindBase = false;
|
|
53171
53189
|
try {
|
|
53172
|
-
(0,
|
|
53190
|
+
(0, import_node_child_process7.execFileSync)("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
|
|
53173
53191
|
cwd: node.workspace,
|
|
53174
53192
|
stdio: "ignore"
|
|
53175
53193
|
});
|
|
@@ -53179,7 +53197,7 @@ ${tail}` : ""
|
|
|
53179
53197
|
if (isBehindBase) {
|
|
53180
53198
|
const autoRebaseStarted = Date.now();
|
|
53181
53199
|
try {
|
|
53182
|
-
(0,
|
|
53200
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", baseHead], {
|
|
53183
53201
|
cwd: node.workspace,
|
|
53184
53202
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53185
53203
|
});
|
|
@@ -53220,7 +53238,7 @@ ${tail}` : ""
|
|
|
53220
53238
|
}
|
|
53221
53239
|
} catch (rebaseErr) {
|
|
53222
53240
|
try {
|
|
53223
|
-
(0,
|
|
53241
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
53224
53242
|
} catch {
|
|
53225
53243
|
}
|
|
53226
53244
|
recordMeshRefineStage(refineStages, "patch_equivalence_after_auto_rebase", "failed", autoRebaseStarted, {
|
|
@@ -55983,7 +56001,7 @@ init_io_contracts();
|
|
|
55983
56001
|
init_chat_message_normalization();
|
|
55984
56002
|
|
|
55985
56003
|
// src/providers/version-archive.ts
|
|
55986
|
-
var
|
|
56004
|
+
var fs33 = __toESM(require("fs"));
|
|
55987
56005
|
var path38 = __toESM(require("path"));
|
|
55988
56006
|
var os28 = __toESM(require("os"));
|
|
55989
56007
|
var import_os5 = require("os");
|
|
@@ -55997,8 +56015,8 @@ var VersionArchive = class {
|
|
|
55997
56015
|
}
|
|
55998
56016
|
load() {
|
|
55999
56017
|
try {
|
|
56000
|
-
if (
|
|
56001
|
-
this.history = JSON.parse(
|
|
56018
|
+
if (fs33.existsSync(ARCHIVE_PATH)) {
|
|
56019
|
+
this.history = JSON.parse(fs33.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
56002
56020
|
}
|
|
56003
56021
|
} catch {
|
|
56004
56022
|
this.history = {};
|
|
@@ -56035,8 +56053,8 @@ var VersionArchive = class {
|
|
|
56035
56053
|
}
|
|
56036
56054
|
save() {
|
|
56037
56055
|
try {
|
|
56038
|
-
|
|
56039
|
-
|
|
56056
|
+
fs33.mkdirSync(path38.dirname(ARCHIVE_PATH), { recursive: true });
|
|
56057
|
+
fs33.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
56040
56058
|
} catch {
|
|
56041
56059
|
}
|
|
56042
56060
|
}
|
|
@@ -56061,8 +56079,8 @@ function findBinary2(name) {
|
|
|
56061
56079
|
for (const ext of exes) {
|
|
56062
56080
|
const fullPath = path38.join(p, name + ext);
|
|
56063
56081
|
try {
|
|
56064
|
-
if (
|
|
56065
|
-
const stat2 =
|
|
56082
|
+
if (fs33.existsSync(fullPath)) {
|
|
56083
|
+
const stat2 = fs33.statSync(fullPath);
|
|
56066
56084
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
56067
56085
|
return fullPath;
|
|
56068
56086
|
}
|
|
@@ -56109,9 +56127,9 @@ function checkPathExists2(paths) {
|
|
|
56109
56127
|
if (p.includes("*")) {
|
|
56110
56128
|
const home = os28.homedir();
|
|
56111
56129
|
const resolved = p.replace(/\*/g, home.split(path38.sep).pop() || "");
|
|
56112
|
-
if (
|
|
56130
|
+
if (fs33.existsSync(resolved)) return resolved;
|
|
56113
56131
|
} else {
|
|
56114
|
-
if (
|
|
56132
|
+
if (fs33.existsSync(p)) return p;
|
|
56115
56133
|
}
|
|
56116
56134
|
}
|
|
56117
56135
|
return null;
|
|
@@ -56119,7 +56137,7 @@ function checkPathExists2(paths) {
|
|
|
56119
56137
|
async function getMacAppVersion(appPath) {
|
|
56120
56138
|
if ((0, import_os5.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
56121
56139
|
const plistPath = path38.join(appPath, "Contents", "Info.plist");
|
|
56122
|
-
if (!
|
|
56140
|
+
if (!fs33.existsSync(plistPath)) return null;
|
|
56123
56141
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
56124
56142
|
return raw || null;
|
|
56125
56143
|
}
|
|
@@ -56146,7 +56164,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
56146
56164
|
let resolvedBin = cliBin;
|
|
56147
56165
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
56148
56166
|
const bundled = path38.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
56149
|
-
if (provider.cli &&
|
|
56167
|
+
if (provider.cli && fs33.existsSync(bundled)) resolvedBin = bundled;
|
|
56150
56168
|
}
|
|
56151
56169
|
info.installed = !!(appPath || resolvedBin);
|
|
56152
56170
|
info.path = appPath || null;
|
|
@@ -56194,7 +56212,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
56194
56212
|
|
|
56195
56213
|
// src/daemon/dev-server.ts
|
|
56196
56214
|
var http2 = __toESM(require("http"));
|
|
56197
|
-
var
|
|
56215
|
+
var fs37 = __toESM(require("fs"));
|
|
56198
56216
|
var path42 = __toESM(require("path"));
|
|
56199
56217
|
init_config();
|
|
56200
56218
|
|
|
@@ -56546,7 +56564,7 @@ init_logger();
|
|
|
56546
56564
|
init_builders();
|
|
56547
56565
|
|
|
56548
56566
|
// src/daemon/dev-cdp-handlers.ts
|
|
56549
|
-
var
|
|
56567
|
+
var fs34 = __toESM(require("fs"));
|
|
56550
56568
|
var path39 = __toESM(require("path"));
|
|
56551
56569
|
init_logger();
|
|
56552
56570
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -56727,17 +56745,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56727
56745
|
}
|
|
56728
56746
|
let scriptsPath = "";
|
|
56729
56747
|
const directScripts = path39.join(dir, "scripts.js");
|
|
56730
|
-
if (
|
|
56748
|
+
if (fs34.existsSync(directScripts)) {
|
|
56731
56749
|
scriptsPath = directScripts;
|
|
56732
56750
|
} else {
|
|
56733
56751
|
const scriptsDir = path39.join(dir, "scripts");
|
|
56734
|
-
if (
|
|
56735
|
-
const versions =
|
|
56736
|
-
return
|
|
56752
|
+
if (fs34.existsSync(scriptsDir)) {
|
|
56753
|
+
const versions = fs34.readdirSync(scriptsDir).filter((d) => {
|
|
56754
|
+
return fs34.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
56737
56755
|
}).sort().reverse();
|
|
56738
56756
|
for (const ver of versions) {
|
|
56739
56757
|
const p = path39.join(scriptsDir, ver, "scripts.js");
|
|
56740
|
-
if (
|
|
56758
|
+
if (fs34.existsSync(p)) {
|
|
56741
56759
|
scriptsPath = p;
|
|
56742
56760
|
break;
|
|
56743
56761
|
}
|
|
@@ -56749,7 +56767,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56749
56767
|
return;
|
|
56750
56768
|
}
|
|
56751
56769
|
try {
|
|
56752
|
-
const source =
|
|
56770
|
+
const source = fs34.readFileSync(scriptsPath, "utf-8");
|
|
56753
56771
|
const hints = {};
|
|
56754
56772
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
56755
56773
|
let match;
|
|
@@ -57564,7 +57582,7 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
57564
57582
|
}
|
|
57565
57583
|
|
|
57566
57584
|
// src/daemon/dev-cli-debug.ts
|
|
57567
|
-
var
|
|
57585
|
+
var fs35 = __toESM(require("fs"));
|
|
57568
57586
|
var path40 = __toESM(require("path"));
|
|
57569
57587
|
function slugifyFixtureName(value) {
|
|
57570
57588
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -57580,10 +57598,10 @@ function getCliFixtureDir(ctx, type) {
|
|
|
57580
57598
|
function readCliFixture(ctx, type, name) {
|
|
57581
57599
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
57582
57600
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
57583
|
-
if (!
|
|
57601
|
+
if (!fs35.existsSync(filePath)) {
|
|
57584
57602
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
57585
57603
|
}
|
|
57586
|
-
return JSON.parse(
|
|
57604
|
+
return JSON.parse(fs35.readFileSync(filePath, "utf-8"));
|
|
57587
57605
|
}
|
|
57588
57606
|
function getExerciseTranscriptText(result) {
|
|
57589
57607
|
const parts = [];
|
|
@@ -58328,7 +58346,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58328
58346
|
return;
|
|
58329
58347
|
}
|
|
58330
58348
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
58331
|
-
|
|
58349
|
+
fs35.mkdirSync(fixtureDir, { recursive: true });
|
|
58332
58350
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
58333
58351
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
58334
58352
|
const fixture = {
|
|
@@ -58356,7 +58374,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58356
58374
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
58357
58375
|
};
|
|
58358
58376
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
58359
|
-
|
|
58377
|
+
fs35.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
58360
58378
|
ctx.json(res, 200, {
|
|
58361
58379
|
saved: true,
|
|
58362
58380
|
name,
|
|
@@ -58374,14 +58392,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58374
58392
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
58375
58393
|
try {
|
|
58376
58394
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
58377
|
-
if (!
|
|
58395
|
+
if (!fs35.existsSync(fixtureDir)) {
|
|
58378
58396
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
58379
58397
|
return;
|
|
58380
58398
|
}
|
|
58381
|
-
const fixtures =
|
|
58399
|
+
const fixtures = fs35.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
|
|
58382
58400
|
const fullPath = path40.join(fixtureDir, file);
|
|
58383
58401
|
try {
|
|
58384
|
-
const raw = JSON.parse(
|
|
58402
|
+
const raw = JSON.parse(fs35.readFileSync(fullPath, "utf-8"));
|
|
58385
58403
|
return {
|
|
58386
58404
|
name: raw.name || file.replace(/\.json$/i, ""),
|
|
58387
58405
|
path: fullPath,
|
|
@@ -58514,7 +58532,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
58514
58532
|
}
|
|
58515
58533
|
|
|
58516
58534
|
// src/daemon/dev-auto-implement.ts
|
|
58517
|
-
var
|
|
58535
|
+
var fs36 = __toESM(require("fs"));
|
|
58518
58536
|
var path41 = __toESM(require("path"));
|
|
58519
58537
|
var os29 = __toESM(require("os"));
|
|
58520
58538
|
var import_session_host_core8 = require("@adhdev/session-host-core");
|
|
@@ -58563,10 +58581,10 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
58563
58581
|
return fallback?.type || null;
|
|
58564
58582
|
}
|
|
58565
58583
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
58566
|
-
if (!
|
|
58567
|
-
const versions =
|
|
58584
|
+
if (!fs36.existsSync(scriptsDir)) return null;
|
|
58585
|
+
const versions = fs36.readdirSync(scriptsDir).filter((d) => {
|
|
58568
58586
|
try {
|
|
58569
|
-
return
|
|
58587
|
+
return fs36.statSync(path41.join(scriptsDir, d)).isDirectory();
|
|
58570
58588
|
} catch {
|
|
58571
58589
|
return false;
|
|
58572
58590
|
}
|
|
@@ -58588,13 +58606,13 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58588
58606
|
if (!sourceDir) {
|
|
58589
58607
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
58590
58608
|
}
|
|
58591
|
-
if (!
|
|
58592
|
-
|
|
58593
|
-
|
|
58609
|
+
if (!fs36.existsSync(desiredDir)) {
|
|
58610
|
+
fs36.mkdirSync(path41.dirname(desiredDir), { recursive: true });
|
|
58611
|
+
fs36.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
58594
58612
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
58595
58613
|
}
|
|
58596
58614
|
const providerJson = path41.join(desiredDir, "provider.json");
|
|
58597
|
-
if (!
|
|
58615
|
+
if (!fs36.existsSync(providerJson)) {
|
|
58598
58616
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
58599
58617
|
}
|
|
58600
58618
|
return { dir: desiredDir };
|
|
@@ -58602,15 +58620,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58602
58620
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
58603
58621
|
if (!referenceType) return {};
|
|
58604
58622
|
const refDir = ctx.findProviderDir(referenceType);
|
|
58605
|
-
if (!refDir || !
|
|
58623
|
+
if (!refDir || !fs36.existsSync(refDir)) return {};
|
|
58606
58624
|
const referenceScripts = {};
|
|
58607
58625
|
const scriptsDir = path41.join(refDir, "scripts");
|
|
58608
58626
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
58609
58627
|
if (!latestDir) return referenceScripts;
|
|
58610
|
-
for (const file of
|
|
58628
|
+
for (const file of fs36.readdirSync(latestDir)) {
|
|
58611
58629
|
if (!file.endsWith(".js")) continue;
|
|
58612
58630
|
try {
|
|
58613
|
-
referenceScripts[file] =
|
|
58631
|
+
referenceScripts[file] = fs36.readFileSync(path41.join(latestDir, file), "utf-8");
|
|
58614
58632
|
} catch {
|
|
58615
58633
|
}
|
|
58616
58634
|
}
|
|
@@ -58719,15 +58737,15 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58719
58737
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
58720
58738
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
58721
58739
|
const tmpDir = path41.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
58722
|
-
if (!
|
|
58740
|
+
if (!fs36.existsSync(tmpDir)) fs36.mkdirSync(tmpDir, { recursive: true });
|
|
58723
58741
|
const promptFile = path41.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
58724
|
-
|
|
58742
|
+
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
58725
58743
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
58726
58744
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
58727
58745
|
const spawn4 = agentProvider?.spawn;
|
|
58728
58746
|
if (!spawn4?.command) {
|
|
58729
58747
|
try {
|
|
58730
|
-
|
|
58748
|
+
fs36.unlinkSync(promptFile);
|
|
58731
58749
|
} catch {
|
|
58732
58750
|
}
|
|
58733
58751
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -58829,7 +58847,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58829
58847
|
} catch {
|
|
58830
58848
|
}
|
|
58831
58849
|
try {
|
|
58832
|
-
|
|
58850
|
+
fs36.unlinkSync(promptFile);
|
|
58833
58851
|
} catch {
|
|
58834
58852
|
}
|
|
58835
58853
|
ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -59055,7 +59073,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
59055
59073
|
}
|
|
59056
59074
|
});
|
|
59057
59075
|
try {
|
|
59058
|
-
|
|
59076
|
+
fs36.unlinkSync(promptFile);
|
|
59059
59077
|
} catch {
|
|
59060
59078
|
}
|
|
59061
59079
|
ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -59160,10 +59178,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59160
59178
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
59161
59179
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
59162
59180
|
lines.push("");
|
|
59163
|
-
for (const file of
|
|
59181
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
59164
59182
|
if (file.endsWith(".js") && targetFileNames.has(file)) {
|
|
59165
59183
|
try {
|
|
59166
|
-
const content =
|
|
59184
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59167
59185
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
59168
59186
|
lines.push("```javascript");
|
|
59169
59187
|
lines.push(content);
|
|
@@ -59173,14 +59191,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59173
59191
|
}
|
|
59174
59192
|
}
|
|
59175
59193
|
}
|
|
59176
|
-
const refFiles =
|
|
59194
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
59177
59195
|
if (refFiles.length > 0) {
|
|
59178
59196
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
59179
59197
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
59180
59198
|
lines.push("");
|
|
59181
59199
|
for (const file of refFiles) {
|
|
59182
59200
|
try {
|
|
59183
|
-
const content =
|
|
59201
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59184
59202
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
59185
59203
|
lines.push("```javascript");
|
|
59186
59204
|
lines.push(content);
|
|
@@ -59225,7 +59243,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59225
59243
|
const loadGuide = (name) => {
|
|
59226
59244
|
try {
|
|
59227
59245
|
const p = path41.join(docsDir, name);
|
|
59228
|
-
if (
|
|
59246
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
59229
59247
|
} catch {
|
|
59230
59248
|
}
|
|
59231
59249
|
return null;
|
|
@@ -59469,11 +59487,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59469
59487
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
59470
59488
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
59471
59489
|
lines.push("");
|
|
59472
|
-
for (const file of
|
|
59490
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
59473
59491
|
if (!file.endsWith(".js")) continue;
|
|
59474
59492
|
if (!targetFileNames.has(file)) continue;
|
|
59475
59493
|
try {
|
|
59476
|
-
const content =
|
|
59494
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59477
59495
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
59478
59496
|
lines.push("```javascript");
|
|
59479
59497
|
lines.push(content);
|
|
@@ -59482,14 +59500,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59482
59500
|
} catch {
|
|
59483
59501
|
}
|
|
59484
59502
|
}
|
|
59485
|
-
const refFiles =
|
|
59503
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
59486
59504
|
if (refFiles.length > 0) {
|
|
59487
59505
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
59488
59506
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
59489
59507
|
lines.push("");
|
|
59490
59508
|
for (const file of refFiles) {
|
|
59491
59509
|
try {
|
|
59492
|
-
const content =
|
|
59510
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59493
59511
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
59494
59512
|
lines.push("```javascript");
|
|
59495
59513
|
lines.push(content);
|
|
@@ -59526,7 +59544,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59526
59544
|
const loadGuide = (name) => {
|
|
59527
59545
|
try {
|
|
59528
59546
|
const p = path41.join(docsDir, name);
|
|
59529
|
-
if (
|
|
59547
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
59530
59548
|
} catch {
|
|
59531
59549
|
}
|
|
59532
59550
|
return null;
|
|
@@ -60266,7 +60284,7 @@ var DevServer = class _DevServer {
|
|
|
60266
60284
|
path42.join(process.cwd(), "packages/web-devconsole/dist")
|
|
60267
60285
|
];
|
|
60268
60286
|
for (const dir of candidates) {
|
|
60269
|
-
if (
|
|
60287
|
+
if (fs37.existsSync(path42.join(dir, "index.html"))) return dir;
|
|
60270
60288
|
}
|
|
60271
60289
|
return null;
|
|
60272
60290
|
}
|
|
@@ -60278,7 +60296,7 @@ var DevServer = class _DevServer {
|
|
|
60278
60296
|
}
|
|
60279
60297
|
const htmlPath = path42.join(distDir, "index.html");
|
|
60280
60298
|
try {
|
|
60281
|
-
const html =
|
|
60299
|
+
const html = fs37.readFileSync(htmlPath, "utf-8");
|
|
60282
60300
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
60283
60301
|
res.end(html);
|
|
60284
60302
|
} catch (e) {
|
|
@@ -60308,7 +60326,7 @@ var DevServer = class _DevServer {
|
|
|
60308
60326
|
return;
|
|
60309
60327
|
}
|
|
60310
60328
|
try {
|
|
60311
|
-
const content =
|
|
60329
|
+
const content = fs37.readFileSync(filePath);
|
|
60312
60330
|
const ext = path42.extname(filePath);
|
|
60313
60331
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
60314
60332
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -60417,14 +60435,14 @@ var DevServer = class _DevServer {
|
|
|
60417
60435
|
const files = [];
|
|
60418
60436
|
const scan = (d, prefix) => {
|
|
60419
60437
|
try {
|
|
60420
|
-
for (const entry of
|
|
60438
|
+
for (const entry of fs37.readdirSync(d, { withFileTypes: true })) {
|
|
60421
60439
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
60422
60440
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
60423
60441
|
if (entry.isDirectory()) {
|
|
60424
60442
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
60425
60443
|
scan(path42.join(d, entry.name), rel);
|
|
60426
60444
|
} else {
|
|
60427
|
-
const stat2 =
|
|
60445
|
+
const stat2 = fs37.statSync(path42.join(d, entry.name));
|
|
60428
60446
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
60429
60447
|
}
|
|
60430
60448
|
}
|
|
@@ -60452,11 +60470,11 @@ var DevServer = class _DevServer {
|
|
|
60452
60470
|
this.json(res, 403, { error: "Forbidden" });
|
|
60453
60471
|
return;
|
|
60454
60472
|
}
|
|
60455
|
-
if (!
|
|
60473
|
+
if (!fs37.existsSync(fullPath) || fs37.statSync(fullPath).isDirectory()) {
|
|
60456
60474
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
60457
60475
|
return;
|
|
60458
60476
|
}
|
|
60459
|
-
const content =
|
|
60477
|
+
const content = fs37.readFileSync(fullPath, "utf-8");
|
|
60460
60478
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
60461
60479
|
}
|
|
60462
60480
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -60478,9 +60496,9 @@ var DevServer = class _DevServer {
|
|
|
60478
60496
|
return;
|
|
60479
60497
|
}
|
|
60480
60498
|
try {
|
|
60481
|
-
if (
|
|
60482
|
-
|
|
60483
|
-
|
|
60499
|
+
if (fs37.existsSync(fullPath)) fs37.copyFileSync(fullPath, fullPath + ".bak");
|
|
60500
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60501
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60484
60502
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
60485
60503
|
this.providerLoader.reload();
|
|
60486
60504
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -60497,8 +60515,8 @@ var DevServer = class _DevServer {
|
|
|
60497
60515
|
}
|
|
60498
60516
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
60499
60517
|
const p = path42.join(dir, name);
|
|
60500
|
-
if (
|
|
60501
|
-
const source =
|
|
60518
|
+
if (fs37.existsSync(p)) {
|
|
60519
|
+
const source = fs37.readFileSync(p, "utf-8");
|
|
60502
60520
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
60503
60521
|
return;
|
|
60504
60522
|
}
|
|
@@ -60517,11 +60535,11 @@ var DevServer = class _DevServer {
|
|
|
60517
60535
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
60518
60536
|
return;
|
|
60519
60537
|
}
|
|
60520
|
-
const target =
|
|
60538
|
+
const target = fs37.existsSync(path42.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
60521
60539
|
const targetPath = path42.join(dir, target);
|
|
60522
60540
|
try {
|
|
60523
|
-
if (
|
|
60524
|
-
|
|
60541
|
+
if (fs37.existsSync(targetPath)) fs37.copyFileSync(targetPath, targetPath + ".bak");
|
|
60542
|
+
fs37.writeFileSync(targetPath, source, "utf-8");
|
|
60525
60543
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
60526
60544
|
this.providerLoader.reload();
|
|
60527
60545
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -60666,20 +60684,20 @@ var DevServer = class _DevServer {
|
|
|
60666
60684
|
let targetDir;
|
|
60667
60685
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
60668
60686
|
const jsonPath = path42.join(targetDir, "provider.json");
|
|
60669
|
-
if (
|
|
60687
|
+
if (fs37.existsSync(jsonPath)) {
|
|
60670
60688
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
60671
60689
|
return;
|
|
60672
60690
|
}
|
|
60673
60691
|
try {
|
|
60674
60692
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
|
|
60675
|
-
|
|
60676
|
-
|
|
60693
|
+
fs37.mkdirSync(targetDir, { recursive: true });
|
|
60694
|
+
fs37.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
60677
60695
|
const createdFiles = ["provider.json"];
|
|
60678
60696
|
if (result.files) {
|
|
60679
60697
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
60680
60698
|
const fullPath = path42.join(targetDir, relPath);
|
|
60681
|
-
|
|
60682
|
-
|
|
60699
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60700
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60683
60701
|
createdFiles.push(relPath);
|
|
60684
60702
|
}
|
|
60685
60703
|
}
|
|
@@ -60728,10 +60746,10 @@ var DevServer = class _DevServer {
|
|
|
60728
60746
|
}
|
|
60729
60747
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
60730
60748
|
getLatestScriptVersionDir(scriptsDir) {
|
|
60731
|
-
if (!
|
|
60732
|
-
const versions =
|
|
60749
|
+
if (!fs37.existsSync(scriptsDir)) return null;
|
|
60750
|
+
const versions = fs37.readdirSync(scriptsDir).filter((d) => {
|
|
60733
60751
|
try {
|
|
60734
|
-
return
|
|
60752
|
+
return fs37.statSync(path42.join(scriptsDir, d)).isDirectory();
|
|
60735
60753
|
} catch {
|
|
60736
60754
|
return false;
|
|
60737
60755
|
}
|
|
@@ -60753,13 +60771,13 @@ var DevServer = class _DevServer {
|
|
|
60753
60771
|
if (!sourceDir) {
|
|
60754
60772
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
60755
60773
|
}
|
|
60756
|
-
if (!
|
|
60757
|
-
|
|
60758
|
-
|
|
60774
|
+
if (!fs37.existsSync(desiredDir)) {
|
|
60775
|
+
fs37.mkdirSync(path42.dirname(desiredDir), { recursive: true });
|
|
60776
|
+
fs37.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
60759
60777
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
60760
60778
|
}
|
|
60761
60779
|
const providerJson = path42.join(desiredDir, "provider.json");
|
|
60762
|
-
if (!
|
|
60780
|
+
if (!fs37.existsSync(providerJson)) {
|
|
60763
60781
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
60764
60782
|
}
|
|
60765
60783
|
return { dir: desiredDir };
|
|
@@ -61736,8 +61754,8 @@ async function installExtension(ide, extension) {
|
|
|
61736
61754
|
const res = await fetch(extension.vsixUrl);
|
|
61737
61755
|
if (res.ok) {
|
|
61738
61756
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
61739
|
-
const
|
|
61740
|
-
|
|
61757
|
+
const fs38 = await import("fs");
|
|
61758
|
+
fs38.writeFileSync(vsixPath, buffer);
|
|
61741
61759
|
return new Promise((resolve24) => {
|
|
61742
61760
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
61743
61761
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|