@adhdev/daemon-standalone 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/index.js +204 -194
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +31 -1
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
|
|
|
30036
30036
|
}
|
|
30037
30037
|
function getDaemonBuildInfo() {
|
|
30038
30038
|
if (cached2) return cached2;
|
|
30039
|
-
const commit = readInjected(true ? "
|
|
30040
|
-
const commitShort = readInjected(true ? "
|
|
30041
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30042
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30039
|
+
const commit = readInjected(true ? "3920b23e979544d74c4024a0ff18e5deab7b2932" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "3920b23e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.378" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-25T07:59:40.648Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -37042,8 +37042,8 @@ ${rendered}`, "utf-8");
|
|
|
37042
37042
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
37043
37043
|
if (!remaining.trim()) {
|
|
37044
37044
|
try {
|
|
37045
|
-
const
|
|
37046
|
-
|
|
37045
|
+
const fs38 = require("fs");
|
|
37046
|
+
fs38.unlinkSync(filePath);
|
|
37047
37047
|
} catch {
|
|
37048
37048
|
}
|
|
37049
37049
|
} else {
|
|
@@ -39586,9 +39586,9 @@ Next step: ${nextStep}`;
|
|
|
39586
39586
|
for (const ext of exes) {
|
|
39587
39587
|
const fullPath = path11.join(p, trimmed + ext);
|
|
39588
39588
|
try {
|
|
39589
|
-
const
|
|
39590
|
-
if (
|
|
39591
|
-
const stat2 =
|
|
39589
|
+
const fs38 = require("fs");
|
|
39590
|
+
if (fs38.existsSync(fullPath)) {
|
|
39591
|
+
const stat2 = fs38.statSync(fullPath);
|
|
39592
39592
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
39593
39593
|
return fullPath;
|
|
39594
39594
|
}
|
|
@@ -39602,12 +39602,12 @@ Next step: ${nextStep}`;
|
|
|
39602
39602
|
function isScriptBinary(binaryPath) {
|
|
39603
39603
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
39604
39604
|
try {
|
|
39605
|
-
const
|
|
39606
|
-
const resolved =
|
|
39605
|
+
const fs38 = require("fs");
|
|
39606
|
+
const resolved = fs38.realpathSync(binaryPath);
|
|
39607
39607
|
const head = Buffer.alloc(8);
|
|
39608
|
-
const fd =
|
|
39609
|
-
|
|
39610
|
-
|
|
39608
|
+
const fd = fs38.openSync(resolved, "r");
|
|
39609
|
+
fs38.readSync(fd, head, 0, 8, 0);
|
|
39610
|
+
fs38.closeSync(fd);
|
|
39611
39611
|
let i = 0;
|
|
39612
39612
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
39613
39613
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -39618,12 +39618,12 @@ Next step: ${nextStep}`;
|
|
|
39618
39618
|
function looksLikeMachOOrElf(filePath) {
|
|
39619
39619
|
if (!path11.isAbsolute(filePath)) return false;
|
|
39620
39620
|
try {
|
|
39621
|
-
const
|
|
39622
|
-
const resolved =
|
|
39621
|
+
const fs38 = require("fs");
|
|
39622
|
+
const resolved = fs38.realpathSync(filePath);
|
|
39623
39623
|
const buf = Buffer.alloc(8);
|
|
39624
|
-
const fd =
|
|
39625
|
-
|
|
39626
|
-
|
|
39624
|
+
const fd = fs38.openSync(resolved, "r");
|
|
39625
|
+
fs38.readSync(fd, buf, 0, 8, 0);
|
|
39626
|
+
fs38.closeSync(fd);
|
|
39627
39627
|
let i = 0;
|
|
39628
39628
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
39629
39629
|
const b = buf.subarray(i);
|
|
@@ -46778,8 +46778,8 @@ ${cleanBody}`;
|
|
|
46778
46778
|
let cwd = options.cwd;
|
|
46779
46779
|
if (cwd) {
|
|
46780
46780
|
try {
|
|
46781
|
-
const
|
|
46782
|
-
const stat2 =
|
|
46781
|
+
const fs38 = require("fs");
|
|
46782
|
+
const stat2 = fs38.statSync(cwd);
|
|
46783
46783
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
46784
46784
|
} catch {
|
|
46785
46785
|
cwd = os14.homedir();
|
|
@@ -62602,7 +62602,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
62602
62602
|
return { success: false, error: "invalid type" };
|
|
62603
62603
|
}
|
|
62604
62604
|
const https = require("https");
|
|
62605
|
-
const
|
|
62605
|
+
const fs38 = require("fs");
|
|
62606
62606
|
const path43 = require("path");
|
|
62607
62607
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
62608
62608
|
function fetchText(url2, timeoutMs) {
|
|
@@ -62645,7 +62645,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
62645
62645
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
62646
62646
|
return { success: false, error: "install path escaped upstream root" };
|
|
62647
62647
|
}
|
|
62648
|
-
|
|
62648
|
+
fs38.mkdirSync(targetDir, { recursive: true });
|
|
62649
62649
|
let manifestProbe = {};
|
|
62650
62650
|
try {
|
|
62651
62651
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -62670,7 +62670,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62670
62670
|
}
|
|
62671
62671
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
62672
62672
|
const targetPath = path43.join(targetDir, targetFile);
|
|
62673
|
-
|
|
62673
|
+
fs38.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
62674
62674
|
const manifestJson = JSON.parse(manifestBody);
|
|
62675
62675
|
const scriptFetch = await this.fetchProviderSources(
|
|
62676
62676
|
manifestJson,
|
|
@@ -62740,7 +62740,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62740
62740
|
const repo = source.repo;
|
|
62741
62741
|
const ref = source.ref;
|
|
62742
62742
|
const https = require("https");
|
|
62743
|
-
const
|
|
62743
|
+
const fs38 = require("fs");
|
|
62744
62744
|
const path43 = require("path");
|
|
62745
62745
|
function fetchJson(url2, timeoutMs) {
|
|
62746
62746
|
return new Promise((resolve24, reject) => {
|
|
@@ -62824,8 +62824,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62824
62824
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
62825
62825
|
const outPath = path43.resolve(path43.join(sharedTargetDir, relInside));
|
|
62826
62826
|
if (!outPath.startsWith(path43.resolve(sharedTargetDir) + path43.sep)) continue;
|
|
62827
|
-
|
|
62828
|
-
|
|
62827
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
62828
|
+
fs38.writeFileSync(outPath, body);
|
|
62829
62829
|
fetchedCount++;
|
|
62830
62830
|
} catch (e) {
|
|
62831
62831
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -62863,8 +62863,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62863
62863
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
62864
62864
|
continue;
|
|
62865
62865
|
}
|
|
62866
|
-
|
|
62867
|
-
|
|
62866
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
62867
|
+
fs38.writeFileSync(outPath, body);
|
|
62868
62868
|
fetchedCount++;
|
|
62869
62869
|
} catch (e) {
|
|
62870
62870
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -62892,7 +62892,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62892
62892
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
62893
62893
|
return { success: false, error: `unknown category: ${category}` };
|
|
62894
62894
|
}
|
|
62895
|
-
const
|
|
62895
|
+
const fs38 = require("fs");
|
|
62896
62896
|
const path43 = require("path");
|
|
62897
62897
|
try {
|
|
62898
62898
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -62901,10 +62901,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62901
62901
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
62902
62902
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
62903
62903
|
}
|
|
62904
|
-
if (!
|
|
62904
|
+
if (!fs38.existsSync(targetDir)) {
|
|
62905
62905
|
return { success: false, error: "not installed" };
|
|
62906
62906
|
}
|
|
62907
|
-
|
|
62907
|
+
fs38.rmSync(targetDir, { recursive: true, force: true });
|
|
62908
62908
|
if (this._ctx.providerLoader) {
|
|
62909
62909
|
this._ctx.providerLoader.reload();
|
|
62910
62910
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -62920,28 +62920,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62920
62920
|
* the UI and by the update checker.
|
|
62921
62921
|
*/
|
|
62922
62922
|
handleListInstalledProviders(_args) {
|
|
62923
|
-
const
|
|
62923
|
+
const fs38 = require("fs");
|
|
62924
62924
|
const path43 = require("path");
|
|
62925
62925
|
const installRoot = this.getUpstreamInstallRoot();
|
|
62926
|
-
if (!
|
|
62926
|
+
if (!fs38.existsSync(installRoot)) return { success: true, providers: [] };
|
|
62927
62927
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
62928
62928
|
const items = [];
|
|
62929
62929
|
for (const category of CATEGORIES) {
|
|
62930
62930
|
const categoryDir = path43.join(installRoot, category);
|
|
62931
|
-
if (!
|
|
62931
|
+
if (!fs38.existsSync(categoryDir)) continue;
|
|
62932
62932
|
let entries;
|
|
62933
62933
|
try {
|
|
62934
|
-
entries =
|
|
62934
|
+
entries = fs38.readdirSync(categoryDir);
|
|
62935
62935
|
} catch {
|
|
62936
62936
|
continue;
|
|
62937
62937
|
}
|
|
62938
62938
|
for (const type of entries) {
|
|
62939
62939
|
const v1Path = path43.join(categoryDir, type, "provider.v1.json");
|
|
62940
62940
|
const v0Path = path43.join(categoryDir, type, "provider.json");
|
|
62941
|
-
const manifestPath =
|
|
62941
|
+
const manifestPath = fs38.existsSync(v1Path) ? v1Path : fs38.existsSync(v0Path) ? v0Path : null;
|
|
62942
62942
|
if (!manifestPath) continue;
|
|
62943
62943
|
try {
|
|
62944
|
-
const m = JSON.parse(
|
|
62944
|
+
const m = JSON.parse(fs38.readFileSync(manifestPath, "utf-8"));
|
|
62945
62945
|
items.push({
|
|
62946
62946
|
type,
|
|
62947
62947
|
category,
|
|
@@ -63052,7 +63052,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63052
63052
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
63053
63053
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
63054
63054
|
}
|
|
63055
|
-
const
|
|
63055
|
+
const fs38 = require("fs");
|
|
63056
63056
|
const path43 = require("path");
|
|
63057
63057
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
63058
63058
|
const file2 = ext.loadExternalSources();
|
|
@@ -63063,8 +63063,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63063
63063
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
63064
63064
|
}
|
|
63065
63065
|
const sourceDir = path43.join(ext.externalRoot(), requestedName);
|
|
63066
|
-
if (!
|
|
63067
|
-
if (
|
|
63066
|
+
if (!fs38.existsSync(ext.externalRoot())) fs38.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
63067
|
+
if (fs38.existsSync(sourceDir)) {
|
|
63068
63068
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
63069
63069
|
}
|
|
63070
63070
|
const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -63074,7 +63074,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63074
63074
|
});
|
|
63075
63075
|
if (clone2.status !== 0) {
|
|
63076
63076
|
try {
|
|
63077
|
-
|
|
63077
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
63078
63078
|
} catch {
|
|
63079
63079
|
}
|
|
63080
63080
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -63118,15 +63118,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63118
63118
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
63119
63119
|
if (!name) return { success: false, error: "name is required" };
|
|
63120
63120
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
63121
|
-
const
|
|
63121
|
+
const fs38 = require("fs");
|
|
63122
63122
|
const path43 = require("path");
|
|
63123
63123
|
const file2 = ext.loadExternalSources();
|
|
63124
63124
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
63125
63125
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
63126
63126
|
const sourceDir = path43.join(ext.externalRoot(), name);
|
|
63127
|
-
if (
|
|
63127
|
+
if (fs38.existsSync(sourceDir)) {
|
|
63128
63128
|
try {
|
|
63129
|
-
|
|
63129
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
63130
63130
|
} catch (e) {
|
|
63131
63131
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
63132
63132
|
}
|
|
@@ -63895,14 +63895,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63895
63895
|
};
|
|
63896
63896
|
var coordinatorPromptHandlers = {
|
|
63897
63897
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
63898
|
-
const
|
|
63898
|
+
const fs38 = await import("fs");
|
|
63899
63899
|
const path43 = await import("path");
|
|
63900
63900
|
const os30 = await import("os");
|
|
63901
63901
|
const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
63902
63902
|
const entries = {};
|
|
63903
63903
|
try {
|
|
63904
|
-
if (
|
|
63905
|
-
for (const name of
|
|
63904
|
+
if (fs38.existsSync(dir)) {
|
|
63905
|
+
for (const name of fs38.readdirSync(dir)) {
|
|
63906
63906
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
63907
63907
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
63908
63908
|
const m = matchAppend || matchOverride;
|
|
@@ -63912,7 +63912,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63912
63912
|
const full = path43.join(dir, name);
|
|
63913
63913
|
let content = "";
|
|
63914
63914
|
try {
|
|
63915
|
-
content =
|
|
63915
|
+
content = fs38.readFileSync(full, "utf8");
|
|
63916
63916
|
} catch {
|
|
63917
63917
|
}
|
|
63918
63918
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -63926,7 +63926,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63926
63926
|
return { success: true, dir, entries };
|
|
63927
63927
|
},
|
|
63928
63928
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
63929
|
-
const
|
|
63929
|
+
const fs38 = await import("fs");
|
|
63930
63930
|
const path43 = await import("path");
|
|
63931
63931
|
const os30 = await import("os");
|
|
63932
63932
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -63939,11 +63939,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63939
63939
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
63940
63940
|
const full = path43.join(dir, filename);
|
|
63941
63941
|
try {
|
|
63942
|
-
|
|
63942
|
+
fs38.mkdirSync(dir, { recursive: true });
|
|
63943
63943
|
if (content.trim()) {
|
|
63944
|
-
|
|
63945
|
-
} else if (
|
|
63946
|
-
|
|
63944
|
+
fs38.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
63945
|
+
} else if (fs38.existsSync(full)) {
|
|
63946
|
+
fs38.unlinkSync(full);
|
|
63947
63947
|
}
|
|
63948
63948
|
return { success: true, path: full, kind, key };
|
|
63949
63949
|
} catch (error48) {
|
|
@@ -74935,7 +74935,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
74935
74935
|
}
|
|
74936
74936
|
if (providerDir) {
|
|
74937
74937
|
try {
|
|
74938
|
-
const
|
|
74938
|
+
const fs38 = require("fs");
|
|
74939
74939
|
const path43 = require("path");
|
|
74940
74940
|
const candidates = [];
|
|
74941
74941
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -74947,13 +74947,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
74947
74947
|
}
|
|
74948
74948
|
candidates.push(path43.join(providerDir, "specs", "default.json"));
|
|
74949
74949
|
candidates.push(path43.join(providerDir, "spec.json"));
|
|
74950
|
-
const specPath = candidates.find((p) =>
|
|
74950
|
+
const specPath = candidates.find((p) => fs38.existsSync(p));
|
|
74951
74951
|
if (specPath) {
|
|
74952
74952
|
resolved._resolvedSpecPath = specPath;
|
|
74953
74953
|
let specControls;
|
|
74954
74954
|
let nh;
|
|
74955
74955
|
try {
|
|
74956
|
-
const rawSpec = JSON.parse(
|
|
74956
|
+
const rawSpec = JSON.parse(fs38.readFileSync(specPath, "utf8"));
|
|
74957
74957
|
specControls = rawSpec.control_bar;
|
|
74958
74958
|
nh = rawSpec.native_history;
|
|
74959
74959
|
} catch {
|
|
@@ -74985,7 +74985,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
74985
74985
|
reader = (input) => executeNativeHistory(nh, input);
|
|
74986
74986
|
} else if (nh.override_path) {
|
|
74987
74987
|
const overrideFile = path43.resolve(providerDir, nh.override_path);
|
|
74988
|
-
if (
|
|
74988
|
+
if (fs38.existsSync(overrideFile)) {
|
|
74989
74989
|
try {
|
|
74990
74990
|
registerProviderScriptRootSafely(path43.dirname(path43.dirname(providerDir)));
|
|
74991
74991
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -76163,7 +76163,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
76163
76163
|
}
|
|
76164
76164
|
} else if (plat === "win32") {
|
|
76165
76165
|
try {
|
|
76166
|
-
const
|
|
76166
|
+
const fs38 = require("fs");
|
|
76167
76167
|
const appNameMap = getMacAppIdentifiers();
|
|
76168
76168
|
const appName = appNameMap[ideId];
|
|
76169
76169
|
if (appName) {
|
|
@@ -76172,8 +76172,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
76172
76172
|
appName,
|
|
76173
76173
|
"storage.json"
|
|
76174
76174
|
);
|
|
76175
|
-
if (
|
|
76176
|
-
const data = JSON.parse(
|
|
76175
|
+
if (fs38.existsSync(storagePath)) {
|
|
76176
|
+
const data = JSON.parse(fs38.readFileSync(storagePath, "utf-8"));
|
|
76177
76177
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
76178
76178
|
if (workspaces.length > 0) {
|
|
76179
76179
|
const recent = workspaces[0];
|
|
@@ -78109,7 +78109,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78109
78109
|
workspace
|
|
78110
78110
|
};
|
|
78111
78111
|
}
|
|
78112
|
-
const { existsSync:
|
|
78112
|
+
const { existsSync: existsSync52, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
78113
78113
|
const { dirname: dirname17 } = await import("path");
|
|
78114
78114
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
78115
78115
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -78152,7 +78152,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78152
78152
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
78153
78153
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
78154
78154
|
}
|
|
78155
|
-
const hadExistingMcpConfig =
|
|
78155
|
+
const hadExistingMcpConfig = existsSync52(mcpConfigPath);
|
|
78156
78156
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
78157
78157
|
if (hermesBaseConfig) {
|
|
78158
78158
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
@@ -78751,7 +78751,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78751
78751
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
78752
78752
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
78753
78753
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
78754
|
-
const { existsSync:
|
|
78754
|
+
const { existsSync: existsSync52 } = await import("fs");
|
|
78755
78755
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
78756
78756
|
const mesh = meshRecord?.mesh;
|
|
78757
78757
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -78770,7 +78770,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78770
78770
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
78771
78771
|
for (const item of derivation.items) {
|
|
78772
78772
|
const workspace = item.workspace;
|
|
78773
|
-
if (!workspace || !
|
|
78773
|
+
if (!workspace || !existsSync52(workspace)) continue;
|
|
78774
78774
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
78775
78775
|
try {
|
|
78776
78776
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -78815,8 +78815,6 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78815
78815
|
...meshStatusHandlers
|
|
78816
78816
|
})
|
|
78817
78817
|
);
|
|
78818
|
-
init_cli_detector();
|
|
78819
|
-
init_git_status();
|
|
78820
78818
|
init_dist();
|
|
78821
78819
|
init_logger();
|
|
78822
78820
|
var fs28 = __toESM2(require("fs"));
|
|
@@ -78962,7 +78960,6 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78962
78960
|
}
|
|
78963
78961
|
}
|
|
78964
78962
|
cleanOldFiles();
|
|
78965
|
-
var yaml4 = __toESM2(require_js_yaml());
|
|
78966
78963
|
init_mesh_events();
|
|
78967
78964
|
init_mesh_host_ownership();
|
|
78968
78965
|
var import_node_child_process5 = require("child_process");
|
|
@@ -79051,13 +79048,16 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79051
79048
|
return { order: ranked.map((a) => a.nodeId), changeAreas: areaById, rationale };
|
|
79052
79049
|
}
|
|
79053
79050
|
init_mesh_work_queue();
|
|
79054
|
-
init_mesh_warmup_deadline();
|
|
79055
79051
|
init_repo_mesh_types();
|
|
79056
|
-
var
|
|
79057
|
-
var
|
|
79052
|
+
var import_path15 = require("path");
|
|
79053
|
+
var fs322 = __toESM2(require("fs"));
|
|
79054
|
+
var import_node_child_process7 = require("child_process");
|
|
79055
|
+
init_cli_detector();
|
|
79056
|
+
init_git_status();
|
|
79057
|
+
init_dist();
|
|
79058
|
+
init_logger();
|
|
79059
|
+
init_mesh_warmup_deadline();
|
|
79058
79060
|
var fs29 = __toESM2(require("fs"));
|
|
79059
|
-
var import_node_child_process6 = require("child_process");
|
|
79060
|
-
init_resolve_executable();
|
|
79061
79061
|
init_runtime_defaults();
|
|
79062
79062
|
function readProviderPriorityFromPolicy(policy) {
|
|
79063
79063
|
const record2 = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
@@ -80278,6 +80278,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80278
80278
|
}
|
|
80279
80279
|
return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
|
|
80280
80280
|
}
|
|
80281
|
+
init_git_status();
|
|
80282
|
+
var import_path13 = require("path");
|
|
80283
|
+
var fs30 = __toESM2(require("fs"));
|
|
80284
|
+
var import_node_child_process6 = require("child_process");
|
|
80285
|
+
init_resolve_executable();
|
|
80281
80286
|
var REFINE_VALIDATION_TIMEOUT_MS = 12e4;
|
|
80282
80287
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
80283
80288
|
var REFINE_VALIDATION_SUMMARY_CHARS = 2e3;
|
|
@@ -80331,18 +80336,18 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80331
80336
|
return { enabled: false };
|
|
80332
80337
|
}
|
|
80333
80338
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
80334
|
-
const { execFileSync:
|
|
80339
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
80335
80340
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
80336
80341
|
if (excludePaths.length > 0) {
|
|
80337
80342
|
diffArgs.push("--", ".", ...excludePaths.map((path43) => `:(exclude)${path43}`));
|
|
80338
80343
|
}
|
|
80339
|
-
const diff =
|
|
80344
|
+
const diff = execFileSync8("git", diffArgs, {
|
|
80340
80345
|
cwd,
|
|
80341
80346
|
encoding: "utf8",
|
|
80342
80347
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
80343
80348
|
});
|
|
80344
80349
|
if (!diff.trim()) return "";
|
|
80345
|
-
const patchId =
|
|
80350
|
+
const patchId = execFileSync8("git", ["patch-id", "--stable"], {
|
|
80346
80351
|
cwd,
|
|
80347
80352
|
input: diff,
|
|
80348
80353
|
encoding: "utf8",
|
|
@@ -80353,8 +80358,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80353
80358
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
80354
80359
|
const startedAt = Date.now();
|
|
80355
80360
|
try {
|
|
80356
|
-
const { execFileSync:
|
|
80357
|
-
const git = (args) =>
|
|
80361
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
80362
|
+
const git = (args) => execFileSync8("git", args, {
|
|
80358
80363
|
cwd: repoRoot,
|
|
80359
80364
|
encoding: "utf8",
|
|
80360
80365
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -80445,8 +80450,8 @@ ${e?.stderr || ""}`
|
|
|
80445
80450
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
80446
80451
|
const startedAt = Date.now();
|
|
80447
80452
|
try {
|
|
80448
|
-
const { execFileSync:
|
|
80449
|
-
const git = (gitArgs) =>
|
|
80453
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
80454
|
+
const git = (gitArgs) => execFileSync8("git", gitArgs, {
|
|
80450
80455
|
cwd: repoRoot,
|
|
80451
80456
|
encoding: "utf8",
|
|
80452
80457
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -80509,8 +80514,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80509
80514
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
80510
80515
|
const startedAt = Date.now();
|
|
80511
80516
|
try {
|
|
80512
|
-
const { execFileSync:
|
|
80513
|
-
const git = (args, opts) =>
|
|
80517
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
80518
|
+
const git = (args, opts) => execFileSync8("git", args, {
|
|
80514
80519
|
cwd: opts?.cwd || repoRoot,
|
|
80515
80520
|
encoding: "utf8",
|
|
80516
80521
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -80633,7 +80638,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80633
80638
|
if (!baseCommit || !branchCommit) return false;
|
|
80634
80639
|
if (baseCommit === branchCommit) return true;
|
|
80635
80640
|
try {
|
|
80636
|
-
if (!
|
|
80641
|
+
if (!fs30.existsSync(submoduleRepoPath)) return false;
|
|
80637
80642
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
80638
80643
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
80639
80644
|
(0, import_node_child_process6.execFileSync)("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -80750,7 +80755,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80750
80755
|
return newTree || void 0;
|
|
80751
80756
|
} finally {
|
|
80752
80757
|
try {
|
|
80753
|
-
|
|
80758
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
80754
80759
|
} catch {
|
|
80755
80760
|
}
|
|
80756
80761
|
}
|
|
@@ -80825,7 +80830,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80825
80830
|
return newTree || void 0;
|
|
80826
80831
|
} finally {
|
|
80827
80832
|
try {
|
|
80828
|
-
|
|
80833
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
80829
80834
|
} catch {
|
|
80830
80835
|
}
|
|
80831
80836
|
}
|
|
@@ -80931,7 +80936,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80931
80936
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
80932
80937
|
};
|
|
80933
80938
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
80934
|
-
if (!
|
|
80939
|
+
if (!fs30.existsSync(worktreeSubmodulePath)) return false;
|
|
80935
80940
|
try {
|
|
80936
80941
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
80937
80942
|
} catch {
|
|
@@ -80954,7 +80959,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80954
80959
|
reachable: false
|
|
80955
80960
|
};
|
|
80956
80961
|
try {
|
|
80957
|
-
if (!
|
|
80962
|
+
if (!fs30.existsSync(submodulePath)) {
|
|
80958
80963
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
80959
80964
|
entry.publishRequired = true;
|
|
80960
80965
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -81191,9 +81196,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81191
81196
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
81192
81197
|
};
|
|
81193
81198
|
const dependenciesLikelyMissing = (cwd) => {
|
|
81194
|
-
if (!
|
|
81195
|
-
if (
|
|
81196
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
81199
|
+
if (!fs30.existsSync((0, import_path13.join)(cwd, "package.json"))) return false;
|
|
81200
|
+
if (fs30.existsSync((0, import_path13.join)(cwd, "node_modules"))) return false;
|
|
81201
|
+
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)));
|
|
81197
81202
|
};
|
|
81198
81203
|
if (runLegacyBootstrapCommands) {
|
|
81199
81204
|
summary.bootstrap = { stage: "legacy" };
|
|
@@ -81280,6 +81285,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81280
81285
|
summary.status = "passed";
|
|
81281
81286
|
return summary;
|
|
81282
81287
|
}
|
|
81288
|
+
init_logger();
|
|
81289
|
+
var yaml4 = __toESM2(require_js_yaml());
|
|
81290
|
+
var import_os4 = require("os");
|
|
81291
|
+
var import_path14 = require("path");
|
|
81292
|
+
var fs31 = __toESM2(require("fs"));
|
|
81283
81293
|
function loadYamlModule() {
|
|
81284
81294
|
return yaml4;
|
|
81285
81295
|
}
|
|
@@ -81298,14 +81308,14 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81298
81308
|
}
|
|
81299
81309
|
function resolveHermesUserHome() {
|
|
81300
81310
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
81301
|
-
return explicitHome || (0,
|
|
81311
|
+
return explicitHome || (0, import_path14.join)((0, import_os4.homedir)(), ".hermes");
|
|
81302
81312
|
}
|
|
81303
81313
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
81304
81314
|
const sourceHome = resolveHermesUserHome();
|
|
81305
|
-
const sourceConfigPath = (0,
|
|
81306
|
-
if (!
|
|
81307
|
-
if ((0,
|
|
81308
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
81315
|
+
const sourceConfigPath = (0, import_path14.join)(sourceHome, "config.yaml");
|
|
81316
|
+
if (!fs31.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
81317
|
+
if ((0, import_path14.resolve)(sourceConfigPath) === (0, import_path14.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
81318
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs31.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
81309
81319
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
81310
81320
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
81311
81321
|
}
|
|
@@ -81338,13 +81348,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81338
81348
|
return sanitized;
|
|
81339
81349
|
}
|
|
81340
81350
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
81341
|
-
if ((0,
|
|
81351
|
+
if ((0, import_path14.resolve)(sourceHome) === (0, import_path14.resolve)(targetHome)) return;
|
|
81342
81352
|
for (const fileName of [".env", "auth.json"]) {
|
|
81343
|
-
const sourcePath = (0,
|
|
81344
|
-
const targetPath = (0,
|
|
81345
|
-
if (!
|
|
81353
|
+
const sourcePath = (0, import_path14.join)(sourceHome, fileName);
|
|
81354
|
+
const targetPath = (0, import_path14.join)(targetHome, fileName);
|
|
81355
|
+
if (!fs31.existsSync(sourcePath)) continue;
|
|
81346
81356
|
try {
|
|
81347
|
-
|
|
81357
|
+
fs31.copyFileSync(sourcePath, targetPath);
|
|
81348
81358
|
} catch (error48) {
|
|
81349
81359
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
81350
81360
|
}
|
|
@@ -81816,7 +81826,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81816
81826
|
const nodeId = readInlineMeshNodeId(node);
|
|
81817
81827
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
81818
81828
|
const workspace = readStringValue(node?.workspace);
|
|
81819
|
-
if (workspace &&
|
|
81829
|
+
if (workspace && fs322.existsSync(workspace)) {
|
|
81820
81830
|
tombstones.delete(nodeId);
|
|
81821
81831
|
return true;
|
|
81822
81832
|
}
|
|
@@ -81851,14 +81861,14 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81851
81861
|
* to give handles time to release, and reports whether residue remains.
|
|
81852
81862
|
*/
|
|
81853
81863
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
81854
|
-
if (!dir || !
|
|
81864
|
+
if (!dir || !fs322.existsSync(dir)) return { removed: true, residue: false };
|
|
81855
81865
|
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
81856
81866
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
81857
81867
|
let lastErr;
|
|
81858
81868
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
81859
81869
|
try {
|
|
81860
|
-
|
|
81861
|
-
if (!
|
|
81870
|
+
fs322.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
81871
|
+
if (!fs322.existsSync(dir)) return { removed: true, residue: false };
|
|
81862
81872
|
lastErr = new Error("directory still present after rmSync");
|
|
81863
81873
|
} catch (e) {
|
|
81864
81874
|
lastErr = e;
|
|
@@ -81869,7 +81879,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81869
81879
|
}
|
|
81870
81880
|
await sleep3(150 * (attempt + 1));
|
|
81871
81881
|
}
|
|
81872
|
-
return
|
|
81882
|
+
return fs322.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
81873
81883
|
}
|
|
81874
81884
|
async cleanupLocalWorktreeNode(args) {
|
|
81875
81885
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
@@ -81881,13 +81891,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81881
81891
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
81882
81892
|
};
|
|
81883
81893
|
}
|
|
81884
|
-
const worktreeExists =
|
|
81894
|
+
const worktreeExists = fs322.existsSync(workspace);
|
|
81885
81895
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
81886
81896
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
81887
81897
|
if (!worktreeExists) {
|
|
81888
81898
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
81889
81899
|
}
|
|
81890
|
-
if (!repoRoot || !
|
|
81900
|
+
if (!repoRoot || !fs322.existsSync(repoRoot)) {
|
|
81891
81901
|
return {
|
|
81892
81902
|
success: false,
|
|
81893
81903
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -81905,9 +81915,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81905
81915
|
}
|
|
81906
81916
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
81907
81917
|
const normalizePath = (value) => {
|
|
81908
|
-
const resolved = (0,
|
|
81918
|
+
const resolved = (0, import_path15.resolve)(value);
|
|
81909
81919
|
try {
|
|
81910
|
-
return
|
|
81920
|
+
return fs322.realpathSync(resolved);
|
|
81911
81921
|
} catch {
|
|
81912
81922
|
return resolved;
|
|
81913
81923
|
}
|
|
@@ -82701,7 +82711,7 @@ ${tail}` : ""
|
|
|
82701
82711
|
let didAutoRebase = false;
|
|
82702
82712
|
let isBehindBase = false;
|
|
82703
82713
|
try {
|
|
82704
|
-
(0,
|
|
82714
|
+
(0, import_node_child_process7.execFileSync)("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
|
|
82705
82715
|
cwd: node.workspace,
|
|
82706
82716
|
stdio: "ignore"
|
|
82707
82717
|
});
|
|
@@ -82711,7 +82721,7 @@ ${tail}` : ""
|
|
|
82711
82721
|
if (isBehindBase) {
|
|
82712
82722
|
const autoRebaseStarted = Date.now();
|
|
82713
82723
|
try {
|
|
82714
|
-
(0,
|
|
82724
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", baseHead], {
|
|
82715
82725
|
cwd: node.workspace,
|
|
82716
82726
|
stdio: ["ignore", "pipe", "pipe"]
|
|
82717
82727
|
});
|
|
@@ -82752,7 +82762,7 @@ ${tail}` : ""
|
|
|
82752
82762
|
}
|
|
82753
82763
|
} catch (rebaseErr) {
|
|
82754
82764
|
try {
|
|
82755
|
-
(0,
|
|
82765
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
82756
82766
|
} catch {
|
|
82757
82767
|
}
|
|
82758
82768
|
recordMeshRefineStage(refineStages, "patch_equivalence_after_auto_rebase", "failed", autoRebaseStarted, {
|
|
@@ -85489,7 +85499,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
85489
85499
|
};
|
|
85490
85500
|
init_io_contracts();
|
|
85491
85501
|
init_chat_message_normalization();
|
|
85492
|
-
var
|
|
85502
|
+
var fs33 = __toESM2(require("fs"));
|
|
85493
85503
|
var path38 = __toESM2(require("path"));
|
|
85494
85504
|
var os28 = __toESM2(require("os"));
|
|
85495
85505
|
var import_os5 = require("os");
|
|
@@ -85503,8 +85513,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
85503
85513
|
}
|
|
85504
85514
|
load() {
|
|
85505
85515
|
try {
|
|
85506
|
-
if (
|
|
85507
|
-
this.history = JSON.parse(
|
|
85516
|
+
if (fs33.existsSync(ARCHIVE_PATH)) {
|
|
85517
|
+
this.history = JSON.parse(fs33.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
85508
85518
|
}
|
|
85509
85519
|
} catch {
|
|
85510
85520
|
this.history = {};
|
|
@@ -85541,8 +85551,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
85541
85551
|
}
|
|
85542
85552
|
save() {
|
|
85543
85553
|
try {
|
|
85544
|
-
|
|
85545
|
-
|
|
85554
|
+
fs33.mkdirSync(path38.dirname(ARCHIVE_PATH), { recursive: true });
|
|
85555
|
+
fs33.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
85546
85556
|
} catch {
|
|
85547
85557
|
}
|
|
85548
85558
|
}
|
|
@@ -85567,8 +85577,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
85567
85577
|
for (const ext of exes) {
|
|
85568
85578
|
const fullPath = path38.join(p, name + ext);
|
|
85569
85579
|
try {
|
|
85570
|
-
if (
|
|
85571
|
-
const stat2 =
|
|
85580
|
+
if (fs33.existsSync(fullPath)) {
|
|
85581
|
+
const stat2 = fs33.statSync(fullPath);
|
|
85572
85582
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
85573
85583
|
return fullPath;
|
|
85574
85584
|
}
|
|
@@ -85615,9 +85625,9 @@ ${hintLines.join("\n")}` : "",
|
|
|
85615
85625
|
if (p.includes("*")) {
|
|
85616
85626
|
const home = os28.homedir();
|
|
85617
85627
|
const resolved = p.replace(/\*/g, home.split(path38.sep).pop() || "");
|
|
85618
|
-
if (
|
|
85628
|
+
if (fs33.existsSync(resolved)) return resolved;
|
|
85619
85629
|
} else {
|
|
85620
|
-
if (
|
|
85630
|
+
if (fs33.existsSync(p)) return p;
|
|
85621
85631
|
}
|
|
85622
85632
|
}
|
|
85623
85633
|
return null;
|
|
@@ -85625,7 +85635,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
85625
85635
|
async function getMacAppVersion(appPath) {
|
|
85626
85636
|
if ((0, import_os5.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
85627
85637
|
const plistPath = path38.join(appPath, "Contents", "Info.plist");
|
|
85628
|
-
if (!
|
|
85638
|
+
if (!fs33.existsSync(plistPath)) return null;
|
|
85629
85639
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
85630
85640
|
return raw || null;
|
|
85631
85641
|
}
|
|
@@ -85652,7 +85662,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
85652
85662
|
let resolvedBin = cliBin;
|
|
85653
85663
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
85654
85664
|
const bundled = path38.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
85655
|
-
if (provider.cli &&
|
|
85665
|
+
if (provider.cli && fs33.existsSync(bundled)) resolvedBin = bundled;
|
|
85656
85666
|
}
|
|
85657
85667
|
info.installed = !!(appPath || resolvedBin);
|
|
85658
85668
|
info.path = appPath || null;
|
|
@@ -85698,7 +85708,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
85698
85708
|
return results;
|
|
85699
85709
|
}
|
|
85700
85710
|
var http2 = __toESM2(require("http"));
|
|
85701
|
-
var
|
|
85711
|
+
var fs37 = __toESM2(require("fs"));
|
|
85702
85712
|
var path422 = __toESM2(require("path"));
|
|
85703
85713
|
init_config();
|
|
85704
85714
|
function generateFiles(type, name, category, opts = {}) {
|
|
@@ -86044,7 +86054,7 @@ async (params) => {
|
|
|
86044
86054
|
}
|
|
86045
86055
|
init_logger();
|
|
86046
86056
|
init_builders();
|
|
86047
|
-
var
|
|
86057
|
+
var fs34 = __toESM2(require("fs"));
|
|
86048
86058
|
var path39 = __toESM2(require("path"));
|
|
86049
86059
|
init_logger();
|
|
86050
86060
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -86225,17 +86235,17 @@ async (params) => {
|
|
|
86225
86235
|
}
|
|
86226
86236
|
let scriptsPath = "";
|
|
86227
86237
|
const directScripts = path39.join(dir, "scripts.js");
|
|
86228
|
-
if (
|
|
86238
|
+
if (fs34.existsSync(directScripts)) {
|
|
86229
86239
|
scriptsPath = directScripts;
|
|
86230
86240
|
} else {
|
|
86231
86241
|
const scriptsDir = path39.join(dir, "scripts");
|
|
86232
|
-
if (
|
|
86233
|
-
const versions =
|
|
86234
|
-
return
|
|
86242
|
+
if (fs34.existsSync(scriptsDir)) {
|
|
86243
|
+
const versions = fs34.readdirSync(scriptsDir).filter((d) => {
|
|
86244
|
+
return fs34.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
86235
86245
|
}).sort().reverse();
|
|
86236
86246
|
for (const ver of versions) {
|
|
86237
86247
|
const p = path39.join(scriptsDir, ver, "scripts.js");
|
|
86238
|
-
if (
|
|
86248
|
+
if (fs34.existsSync(p)) {
|
|
86239
86249
|
scriptsPath = p;
|
|
86240
86250
|
break;
|
|
86241
86251
|
}
|
|
@@ -86247,7 +86257,7 @@ async (params) => {
|
|
|
86247
86257
|
return;
|
|
86248
86258
|
}
|
|
86249
86259
|
try {
|
|
86250
|
-
const source =
|
|
86260
|
+
const source = fs34.readFileSync(scriptsPath, "utf-8");
|
|
86251
86261
|
const hints = {};
|
|
86252
86262
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
86253
86263
|
let match;
|
|
@@ -87060,7 +87070,7 @@ async (params) => {
|
|
|
87060
87070
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
87061
87071
|
}
|
|
87062
87072
|
}
|
|
87063
|
-
var
|
|
87073
|
+
var fs35 = __toESM2(require("fs"));
|
|
87064
87074
|
var path40 = __toESM2(require("path"));
|
|
87065
87075
|
function slugifyFixtureName(value) {
|
|
87066
87076
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -87076,10 +87086,10 @@ async (params) => {
|
|
|
87076
87086
|
function readCliFixture(ctx, type, name) {
|
|
87077
87087
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
87078
87088
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
87079
|
-
if (!
|
|
87089
|
+
if (!fs35.existsSync(filePath)) {
|
|
87080
87090
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
87081
87091
|
}
|
|
87082
|
-
return JSON.parse(
|
|
87092
|
+
return JSON.parse(fs35.readFileSync(filePath, "utf-8"));
|
|
87083
87093
|
}
|
|
87084
87094
|
function getExerciseTranscriptText(result) {
|
|
87085
87095
|
const parts = [];
|
|
@@ -87824,7 +87834,7 @@ async (params) => {
|
|
|
87824
87834
|
return;
|
|
87825
87835
|
}
|
|
87826
87836
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
87827
|
-
|
|
87837
|
+
fs35.mkdirSync(fixtureDir, { recursive: true });
|
|
87828
87838
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
87829
87839
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
87830
87840
|
const fixture = {
|
|
@@ -87852,7 +87862,7 @@ async (params) => {
|
|
|
87852
87862
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
87853
87863
|
};
|
|
87854
87864
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
87855
|
-
|
|
87865
|
+
fs35.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
87856
87866
|
ctx.json(res, 200, {
|
|
87857
87867
|
saved: true,
|
|
87858
87868
|
name,
|
|
@@ -87870,14 +87880,14 @@ async (params) => {
|
|
|
87870
87880
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
87871
87881
|
try {
|
|
87872
87882
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
87873
|
-
if (!
|
|
87883
|
+
if (!fs35.existsSync(fixtureDir)) {
|
|
87874
87884
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
87875
87885
|
return;
|
|
87876
87886
|
}
|
|
87877
|
-
const fixtures =
|
|
87887
|
+
const fixtures = fs35.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
87878
87888
|
const fullPath = path40.join(fixtureDir, file2);
|
|
87879
87889
|
try {
|
|
87880
|
-
const raw = JSON.parse(
|
|
87890
|
+
const raw = JSON.parse(fs35.readFileSync(fullPath, "utf-8"));
|
|
87881
87891
|
return {
|
|
87882
87892
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
87883
87893
|
path: fullPath,
|
|
@@ -88008,7 +88018,7 @@ async (params) => {
|
|
|
88008
88018
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
88009
88019
|
}
|
|
88010
88020
|
}
|
|
88011
|
-
var
|
|
88021
|
+
var fs36 = __toESM2(require("fs"));
|
|
88012
88022
|
var path41 = __toESM2(require("path"));
|
|
88013
88023
|
var os29 = __toESM2(require("os"));
|
|
88014
88024
|
var import_session_host_core8 = require_dist();
|
|
@@ -88057,10 +88067,10 @@ async (params) => {
|
|
|
88057
88067
|
return fallback?.type || null;
|
|
88058
88068
|
}
|
|
88059
88069
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
88060
|
-
if (!
|
|
88061
|
-
const versions =
|
|
88070
|
+
if (!fs36.existsSync(scriptsDir)) return null;
|
|
88071
|
+
const versions = fs36.readdirSync(scriptsDir).filter((d) => {
|
|
88062
88072
|
try {
|
|
88063
|
-
return
|
|
88073
|
+
return fs36.statSync(path41.join(scriptsDir, d)).isDirectory();
|
|
88064
88074
|
} catch {
|
|
88065
88075
|
return false;
|
|
88066
88076
|
}
|
|
@@ -88082,13 +88092,13 @@ async (params) => {
|
|
|
88082
88092
|
if (!sourceDir) {
|
|
88083
88093
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
88084
88094
|
}
|
|
88085
|
-
if (!
|
|
88086
|
-
|
|
88087
|
-
|
|
88095
|
+
if (!fs36.existsSync(desiredDir)) {
|
|
88096
|
+
fs36.mkdirSync(path41.dirname(desiredDir), { recursive: true });
|
|
88097
|
+
fs36.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
88088
88098
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
88089
88099
|
}
|
|
88090
88100
|
const providerJson = path41.join(desiredDir, "provider.json");
|
|
88091
|
-
if (!
|
|
88101
|
+
if (!fs36.existsSync(providerJson)) {
|
|
88092
88102
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
88093
88103
|
}
|
|
88094
88104
|
return { dir: desiredDir };
|
|
@@ -88096,15 +88106,15 @@ async (params) => {
|
|
|
88096
88106
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
88097
88107
|
if (!referenceType) return {};
|
|
88098
88108
|
const refDir = ctx.findProviderDir(referenceType);
|
|
88099
|
-
if (!refDir || !
|
|
88109
|
+
if (!refDir || !fs36.existsSync(refDir)) return {};
|
|
88100
88110
|
const referenceScripts = {};
|
|
88101
88111
|
const scriptsDir = path41.join(refDir, "scripts");
|
|
88102
88112
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
88103
88113
|
if (!latestDir) return referenceScripts;
|
|
88104
|
-
for (const file2 of
|
|
88114
|
+
for (const file2 of fs36.readdirSync(latestDir)) {
|
|
88105
88115
|
if (!file2.endsWith(".js")) continue;
|
|
88106
88116
|
try {
|
|
88107
|
-
referenceScripts[file2] =
|
|
88117
|
+
referenceScripts[file2] = fs36.readFileSync(path41.join(latestDir, file2), "utf-8");
|
|
88108
88118
|
} catch {
|
|
88109
88119
|
}
|
|
88110
88120
|
}
|
|
@@ -88213,15 +88223,15 @@ async (params) => {
|
|
|
88213
88223
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
88214
88224
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
88215
88225
|
const tmpDir = path41.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
88216
|
-
if (!
|
|
88226
|
+
if (!fs36.existsSync(tmpDir)) fs36.mkdirSync(tmpDir, { recursive: true });
|
|
88217
88227
|
const promptFile = path41.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
88218
|
-
|
|
88228
|
+
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
88219
88229
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
88220
88230
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
88221
88231
|
const spawn4 = agentProvider?.spawn;
|
|
88222
88232
|
if (!spawn4?.command) {
|
|
88223
88233
|
try {
|
|
88224
|
-
|
|
88234
|
+
fs36.unlinkSync(promptFile);
|
|
88225
88235
|
} catch {
|
|
88226
88236
|
}
|
|
88227
88237
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -88323,7 +88333,7 @@ async (params) => {
|
|
|
88323
88333
|
} catch {
|
|
88324
88334
|
}
|
|
88325
88335
|
try {
|
|
88326
|
-
|
|
88336
|
+
fs36.unlinkSync(promptFile);
|
|
88327
88337
|
} catch {
|
|
88328
88338
|
}
|
|
88329
88339
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -88549,7 +88559,7 @@ async (params) => {
|
|
|
88549
88559
|
}
|
|
88550
88560
|
});
|
|
88551
88561
|
try {
|
|
88552
|
-
|
|
88562
|
+
fs36.unlinkSync(promptFile);
|
|
88553
88563
|
} catch {
|
|
88554
88564
|
}
|
|
88555
88565
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -88654,10 +88664,10 @@ async (params) => {
|
|
|
88654
88664
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
88655
88665
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
88656
88666
|
lines.push("");
|
|
88657
|
-
for (const file2 of
|
|
88667
|
+
for (const file2 of fs36.readdirSync(latestScriptsDir)) {
|
|
88658
88668
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
88659
88669
|
try {
|
|
88660
|
-
const content =
|
|
88670
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file2), "utf-8");
|
|
88661
88671
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
88662
88672
|
lines.push("```javascript");
|
|
88663
88673
|
lines.push(content);
|
|
@@ -88667,14 +88677,14 @@ async (params) => {
|
|
|
88667
88677
|
}
|
|
88668
88678
|
}
|
|
88669
88679
|
}
|
|
88670
|
-
const refFiles =
|
|
88680
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
88671
88681
|
if (refFiles.length > 0) {
|
|
88672
88682
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
88673
88683
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
88674
88684
|
lines.push("");
|
|
88675
88685
|
for (const file2 of refFiles) {
|
|
88676
88686
|
try {
|
|
88677
|
-
const content =
|
|
88687
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file2), "utf-8");
|
|
88678
88688
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
88679
88689
|
lines.push("```javascript");
|
|
88680
88690
|
lines.push(content);
|
|
@@ -88719,7 +88729,7 @@ async (params) => {
|
|
|
88719
88729
|
const loadGuide = (name) => {
|
|
88720
88730
|
try {
|
|
88721
88731
|
const p = path41.join(docsDir, name);
|
|
88722
|
-
if (
|
|
88732
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
88723
88733
|
} catch {
|
|
88724
88734
|
}
|
|
88725
88735
|
return null;
|
|
@@ -88963,11 +88973,11 @@ async (params) => {
|
|
|
88963
88973
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
88964
88974
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
88965
88975
|
lines.push("");
|
|
88966
|
-
for (const file2 of
|
|
88976
|
+
for (const file2 of fs36.readdirSync(latestScriptsDir)) {
|
|
88967
88977
|
if (!file2.endsWith(".js")) continue;
|
|
88968
88978
|
if (!targetFileNames.has(file2)) continue;
|
|
88969
88979
|
try {
|
|
88970
|
-
const content =
|
|
88980
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file2), "utf-8");
|
|
88971
88981
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
88972
88982
|
lines.push("```javascript");
|
|
88973
88983
|
lines.push(content);
|
|
@@ -88976,14 +88986,14 @@ async (params) => {
|
|
|
88976
88986
|
} catch {
|
|
88977
88987
|
}
|
|
88978
88988
|
}
|
|
88979
|
-
const refFiles =
|
|
88989
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
88980
88990
|
if (refFiles.length > 0) {
|
|
88981
88991
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
88982
88992
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
88983
88993
|
lines.push("");
|
|
88984
88994
|
for (const file2 of refFiles) {
|
|
88985
88995
|
try {
|
|
88986
|
-
const content =
|
|
88996
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file2), "utf-8");
|
|
88987
88997
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
88988
88998
|
lines.push("```javascript");
|
|
88989
88999
|
lines.push(content);
|
|
@@ -89020,7 +89030,7 @@ async (params) => {
|
|
|
89020
89030
|
const loadGuide = (name) => {
|
|
89021
89031
|
try {
|
|
89022
89032
|
const p = path41.join(docsDir, name);
|
|
89023
|
-
if (
|
|
89033
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
89024
89034
|
} catch {
|
|
89025
89035
|
}
|
|
89026
89036
|
return null;
|
|
@@ -89758,7 +89768,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89758
89768
|
path422.join(process.cwd(), "packages/web-devconsole/dist")
|
|
89759
89769
|
];
|
|
89760
89770
|
for (const dir of candidates) {
|
|
89761
|
-
if (
|
|
89771
|
+
if (fs37.existsSync(path422.join(dir, "index.html"))) return dir;
|
|
89762
89772
|
}
|
|
89763
89773
|
return null;
|
|
89764
89774
|
}
|
|
@@ -89770,7 +89780,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89770
89780
|
}
|
|
89771
89781
|
const htmlPath = path422.join(distDir, "index.html");
|
|
89772
89782
|
try {
|
|
89773
|
-
const html =
|
|
89783
|
+
const html = fs37.readFileSync(htmlPath, "utf-8");
|
|
89774
89784
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
89775
89785
|
res.end(html);
|
|
89776
89786
|
} catch (e) {
|
|
@@ -89800,7 +89810,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89800
89810
|
return;
|
|
89801
89811
|
}
|
|
89802
89812
|
try {
|
|
89803
|
-
const content =
|
|
89813
|
+
const content = fs37.readFileSync(filePath);
|
|
89804
89814
|
const ext = path422.extname(filePath);
|
|
89805
89815
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
89806
89816
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -89909,14 +89919,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89909
89919
|
const files = [];
|
|
89910
89920
|
const scan = (d, prefix) => {
|
|
89911
89921
|
try {
|
|
89912
|
-
for (const entry of
|
|
89922
|
+
for (const entry of fs37.readdirSync(d, { withFileTypes: true })) {
|
|
89913
89923
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
89914
89924
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
89915
89925
|
if (entry.isDirectory()) {
|
|
89916
89926
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
89917
89927
|
scan(path422.join(d, entry.name), rel);
|
|
89918
89928
|
} else {
|
|
89919
|
-
const stat2 =
|
|
89929
|
+
const stat2 = fs37.statSync(path422.join(d, entry.name));
|
|
89920
89930
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
89921
89931
|
}
|
|
89922
89932
|
}
|
|
@@ -89944,11 +89954,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89944
89954
|
this.json(res, 403, { error: "Forbidden" });
|
|
89945
89955
|
return;
|
|
89946
89956
|
}
|
|
89947
|
-
if (!
|
|
89957
|
+
if (!fs37.existsSync(fullPath) || fs37.statSync(fullPath).isDirectory()) {
|
|
89948
89958
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
89949
89959
|
return;
|
|
89950
89960
|
}
|
|
89951
|
-
const content =
|
|
89961
|
+
const content = fs37.readFileSync(fullPath, "utf-8");
|
|
89952
89962
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
89953
89963
|
}
|
|
89954
89964
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -89970,9 +89980,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89970
89980
|
return;
|
|
89971
89981
|
}
|
|
89972
89982
|
try {
|
|
89973
|
-
if (
|
|
89974
|
-
|
|
89975
|
-
|
|
89983
|
+
if (fs37.existsSync(fullPath)) fs37.copyFileSync(fullPath, fullPath + ".bak");
|
|
89984
|
+
fs37.mkdirSync(path422.dirname(fullPath), { recursive: true });
|
|
89985
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
89976
89986
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
89977
89987
|
this.providerLoader.reload();
|
|
89978
89988
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -89989,8 +89999,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
89989
89999
|
}
|
|
89990
90000
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
89991
90001
|
const p = path422.join(dir, name);
|
|
89992
|
-
if (
|
|
89993
|
-
const source =
|
|
90002
|
+
if (fs37.existsSync(p)) {
|
|
90003
|
+
const source = fs37.readFileSync(p, "utf-8");
|
|
89994
90004
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
89995
90005
|
return;
|
|
89996
90006
|
}
|
|
@@ -90009,11 +90019,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
90009
90019
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
90010
90020
|
return;
|
|
90011
90021
|
}
|
|
90012
|
-
const target =
|
|
90022
|
+
const target = fs37.existsSync(path422.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
90013
90023
|
const targetPath = path422.join(dir, target);
|
|
90014
90024
|
try {
|
|
90015
|
-
if (
|
|
90016
|
-
|
|
90025
|
+
if (fs37.existsSync(targetPath)) fs37.copyFileSync(targetPath, targetPath + ".bak");
|
|
90026
|
+
fs37.writeFileSync(targetPath, source, "utf-8");
|
|
90017
90027
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
90018
90028
|
this.providerLoader.reload();
|
|
90019
90029
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -90158,20 +90168,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
90158
90168
|
let targetDir;
|
|
90159
90169
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
90160
90170
|
const jsonPath = path422.join(targetDir, "provider.json");
|
|
90161
|
-
if (
|
|
90171
|
+
if (fs37.existsSync(jsonPath)) {
|
|
90162
90172
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
90163
90173
|
return;
|
|
90164
90174
|
}
|
|
90165
90175
|
try {
|
|
90166
90176
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
90167
|
-
|
|
90168
|
-
|
|
90177
|
+
fs37.mkdirSync(targetDir, { recursive: true });
|
|
90178
|
+
fs37.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
90169
90179
|
const createdFiles = ["provider.json"];
|
|
90170
90180
|
if (result.files) {
|
|
90171
90181
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
90172
90182
|
const fullPath = path422.join(targetDir, relPath);
|
|
90173
|
-
|
|
90174
|
-
|
|
90183
|
+
fs37.mkdirSync(path422.dirname(fullPath), { recursive: true });
|
|
90184
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
90175
90185
|
createdFiles.push(relPath);
|
|
90176
90186
|
}
|
|
90177
90187
|
}
|
|
@@ -90220,10 +90230,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
90220
90230
|
}
|
|
90221
90231
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
90222
90232
|
getLatestScriptVersionDir(scriptsDir) {
|
|
90223
|
-
if (!
|
|
90224
|
-
const versions =
|
|
90233
|
+
if (!fs37.existsSync(scriptsDir)) return null;
|
|
90234
|
+
const versions = fs37.readdirSync(scriptsDir).filter((d) => {
|
|
90225
90235
|
try {
|
|
90226
|
-
return
|
|
90236
|
+
return fs37.statSync(path422.join(scriptsDir, d)).isDirectory();
|
|
90227
90237
|
} catch {
|
|
90228
90238
|
return false;
|
|
90229
90239
|
}
|
|
@@ -90245,13 +90255,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
90245
90255
|
if (!sourceDir) {
|
|
90246
90256
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
90247
90257
|
}
|
|
90248
|
-
if (!
|
|
90249
|
-
|
|
90250
|
-
|
|
90258
|
+
if (!fs37.existsSync(desiredDir)) {
|
|
90259
|
+
fs37.mkdirSync(path422.dirname(desiredDir), { recursive: true });
|
|
90260
|
+
fs37.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
90251
90261
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
90252
90262
|
}
|
|
90253
90263
|
const providerJson = path422.join(desiredDir, "provider.json");
|
|
90254
|
-
if (!
|
|
90264
|
+
if (!fs37.existsSync(providerJson)) {
|
|
90255
90265
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
90256
90266
|
}
|
|
90257
90267
|
return { dir: desiredDir };
|
|
@@ -91214,8 +91224,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
91214
91224
|
const res = await fetch(extension.vsixUrl);
|
|
91215
91225
|
if (res.ok) {
|
|
91216
91226
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
91217
|
-
const
|
|
91218
|
-
|
|
91227
|
+
const fs38 = await import("fs");
|
|
91228
|
+
fs38.writeFileSync(vsixPath, buffer);
|
|
91219
91229
|
return new Promise((resolve24) => {
|
|
91220
91230
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
91221
91231
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|