@adhdev/daemon-standalone 0.9.82-rc.311 → 0.9.82-rc.313
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 +584 -214
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-jzEwV60L.js +114 -0
- package/public/index.html +1 -1
- package/vendor/mcp-server/index.js +41 -0
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -30029,10 +30029,10 @@ var require_dist3 = __commonJS({
|
|
|
30029
30029
|
}
|
|
30030
30030
|
function getDaemonBuildInfo() {
|
|
30031
30031
|
if (cached2) return cached2;
|
|
30032
|
-
const commit = readInjected(true ? "
|
|
30033
|
-
const commitShort = readInjected(true ? "
|
|
30034
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30035
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30032
|
+
const commit = readInjected(true ? "ed3b7279be8ea9fa191f854f7e9b6ce969159e67" : void 0) ?? "unknown";
|
|
30033
|
+
const commitShort = readInjected(true ? "ed3b7279" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30034
|
+
const version2 = readInjected(true ? "0.9.82-rc.313" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30035
|
+
const builtAt = readInjected(true ? "2026-06-18T00:15:22.605Z" : void 0);
|
|
30036
30036
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30037
30037
|
return cached2;
|
|
30038
30038
|
}
|
|
@@ -31845,6 +31845,7 @@ ${rules.join("\n")}`;
|
|
|
31845
31845
|
| \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
|
|
31846
31846
|
| \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
|
|
31847
31847
|
| \`mesh_git_status\` | Check git status on a specific node |
|
|
31848
|
+
| \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) \u2014 no session/PowerShell needed to debug a node's daemon |
|
|
31848
31849
|
| \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
|
|
31849
31850
|
| \`mesh_checkpoint\` | Create a git checkpoint on a node |
|
|
31850
31851
|
| \`mesh_approve\` | Approve/reject a pending agent action |
|
|
@@ -35585,8 +35586,8 @@ ${rendered}`, "utf-8");
|
|
|
35585
35586
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
35586
35587
|
if (!remaining.trim()) {
|
|
35587
35588
|
try {
|
|
35588
|
-
const
|
|
35589
|
-
|
|
35589
|
+
const fs31 = require("fs");
|
|
35590
|
+
fs31.unlinkSync(filePath);
|
|
35590
35591
|
} catch {
|
|
35591
35592
|
}
|
|
35592
35593
|
} else {
|
|
@@ -40631,8 +40632,8 @@ Next step: ${nextStep}`;
|
|
|
40631
40632
|
let cwd = options.cwd;
|
|
40632
40633
|
if (cwd) {
|
|
40633
40634
|
try {
|
|
40634
|
-
const
|
|
40635
|
-
const stat2 =
|
|
40635
|
+
const fs31 = require("fs");
|
|
40636
|
+
const stat2 = fs31.statSync(cwd);
|
|
40636
40637
|
if (!stat2.isDirectory()) cwd = os11.homedir();
|
|
40637
40638
|
} catch {
|
|
40638
40639
|
cwd = os11.homedir();
|
|
@@ -40737,9 +40738,9 @@ Next step: ${nextStep}`;
|
|
|
40737
40738
|
for (const ext of exes) {
|
|
40738
40739
|
const fullPath = path17.join(p, trimmed + ext);
|
|
40739
40740
|
try {
|
|
40740
|
-
const
|
|
40741
|
-
if (
|
|
40742
|
-
const stat2 =
|
|
40741
|
+
const fs31 = require("fs");
|
|
40742
|
+
if (fs31.existsSync(fullPath)) {
|
|
40743
|
+
const stat2 = fs31.statSync(fullPath);
|
|
40743
40744
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
40744
40745
|
return fullPath;
|
|
40745
40746
|
}
|
|
@@ -40753,12 +40754,12 @@ Next step: ${nextStep}`;
|
|
|
40753
40754
|
function isScriptBinary(binaryPath) {
|
|
40754
40755
|
if (!path17.isAbsolute(binaryPath)) return false;
|
|
40755
40756
|
try {
|
|
40756
|
-
const
|
|
40757
|
-
const resolved =
|
|
40757
|
+
const fs31 = require("fs");
|
|
40758
|
+
const resolved = fs31.realpathSync(binaryPath);
|
|
40758
40759
|
const head = Buffer.alloc(8);
|
|
40759
|
-
const fd =
|
|
40760
|
-
|
|
40761
|
-
|
|
40760
|
+
const fd = fs31.openSync(resolved, "r");
|
|
40761
|
+
fs31.readSync(fd, head, 0, 8, 0);
|
|
40762
|
+
fs31.closeSync(fd);
|
|
40762
40763
|
let i = 0;
|
|
40763
40764
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
40764
40765
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -40769,12 +40770,12 @@ Next step: ${nextStep}`;
|
|
|
40769
40770
|
function looksLikeMachOOrElf(filePath) {
|
|
40770
40771
|
if (!path17.isAbsolute(filePath)) return false;
|
|
40771
40772
|
try {
|
|
40772
|
-
const
|
|
40773
|
-
const resolved =
|
|
40773
|
+
const fs31 = require("fs");
|
|
40774
|
+
const resolved = fs31.realpathSync(filePath);
|
|
40774
40775
|
const buf = Buffer.alloc(8);
|
|
40775
|
-
const fd =
|
|
40776
|
-
|
|
40777
|
-
|
|
40776
|
+
const fd = fs31.openSync(resolved, "r");
|
|
40777
|
+
fs31.readSync(fd, buf, 0, 8, 0);
|
|
40778
|
+
fs31.closeSync(fd);
|
|
40778
40779
|
let i = 0;
|
|
40779
40780
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
40780
40781
|
const b = buf.subarray(i);
|
|
@@ -59469,7 +59470,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59469
59470
|
return { success: false, error: "invalid type" };
|
|
59470
59471
|
}
|
|
59471
59472
|
const https = require("https");
|
|
59472
|
-
const
|
|
59473
|
+
const fs31 = require("fs");
|
|
59473
59474
|
const path41 = require("path");
|
|
59474
59475
|
const crypto6 = require("crypto");
|
|
59475
59476
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
@@ -59513,7 +59514,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59513
59514
|
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
59514
59515
|
return { success: false, error: "install path escaped upstream root" };
|
|
59515
59516
|
}
|
|
59516
|
-
|
|
59517
|
+
fs31.mkdirSync(targetDir, { recursive: true });
|
|
59517
59518
|
let manifestProbe = {};
|
|
59518
59519
|
try {
|
|
59519
59520
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -59538,7 +59539,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59538
59539
|
}
|
|
59539
59540
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
59540
59541
|
const targetPath = path41.join(targetDir, targetFile);
|
|
59541
|
-
|
|
59542
|
+
fs31.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
59542
59543
|
const manifestJson = JSON.parse(manifestBody);
|
|
59543
59544
|
const scriptFetch = await this.fetchProviderSources(
|
|
59544
59545
|
manifestJson,
|
|
@@ -59608,7 +59609,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59608
59609
|
const repo = source.repo;
|
|
59609
59610
|
const ref = source.ref;
|
|
59610
59611
|
const https = require("https");
|
|
59611
|
-
const
|
|
59612
|
+
const fs31 = require("fs");
|
|
59612
59613
|
const path41 = require("path");
|
|
59613
59614
|
function fetchJson(url2, timeoutMs) {
|
|
59614
59615
|
return new Promise((resolve24, reject) => {
|
|
@@ -59692,8 +59693,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59692
59693
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
59693
59694
|
const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
|
|
59694
59695
|
if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
|
|
59695
|
-
|
|
59696
|
-
|
|
59696
|
+
fs31.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
59697
|
+
fs31.writeFileSync(outPath, body);
|
|
59697
59698
|
fetchedCount++;
|
|
59698
59699
|
} catch (e) {
|
|
59699
59700
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -59731,8 +59732,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59731
59732
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
59732
59733
|
continue;
|
|
59733
59734
|
}
|
|
59734
|
-
|
|
59735
|
-
|
|
59735
|
+
fs31.mkdirSync(path41.dirname(outPath), { recursive: true });
|
|
59736
|
+
fs31.writeFileSync(outPath, body);
|
|
59736
59737
|
fetchedCount++;
|
|
59737
59738
|
} catch (e) {
|
|
59738
59739
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -59760,7 +59761,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59760
59761
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
59761
59762
|
return { success: false, error: `unknown category: ${category}` };
|
|
59762
59763
|
}
|
|
59763
|
-
const
|
|
59764
|
+
const fs31 = require("fs");
|
|
59764
59765
|
const path41 = require("path");
|
|
59765
59766
|
try {
|
|
59766
59767
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -59769,10 +59770,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59769
59770
|
if (!targetDir.startsWith(installRootResolved + path41.sep)) {
|
|
59770
59771
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
59771
59772
|
}
|
|
59772
|
-
if (!
|
|
59773
|
+
if (!fs31.existsSync(targetDir)) {
|
|
59773
59774
|
return { success: false, error: "not installed" };
|
|
59774
59775
|
}
|
|
59775
|
-
|
|
59776
|
+
fs31.rmSync(targetDir, { recursive: true, force: true });
|
|
59776
59777
|
if (this._ctx.providerLoader) {
|
|
59777
59778
|
this._ctx.providerLoader.reload();
|
|
59778
59779
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -59788,28 +59789,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59788
59789
|
* the UI and by the update checker.
|
|
59789
59790
|
*/
|
|
59790
59791
|
handleListInstalledProviders(_args) {
|
|
59791
|
-
const
|
|
59792
|
+
const fs31 = require("fs");
|
|
59792
59793
|
const path41 = require("path");
|
|
59793
59794
|
const installRoot = this.getUpstreamInstallRoot();
|
|
59794
|
-
if (!
|
|
59795
|
+
if (!fs31.existsSync(installRoot)) return { success: true, providers: [] };
|
|
59795
59796
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
59796
59797
|
const items = [];
|
|
59797
59798
|
for (const category of CATEGORIES) {
|
|
59798
59799
|
const categoryDir = path41.join(installRoot, category);
|
|
59799
|
-
if (!
|
|
59800
|
+
if (!fs31.existsSync(categoryDir)) continue;
|
|
59800
59801
|
let entries;
|
|
59801
59802
|
try {
|
|
59802
|
-
entries =
|
|
59803
|
+
entries = fs31.readdirSync(categoryDir);
|
|
59803
59804
|
} catch {
|
|
59804
59805
|
continue;
|
|
59805
59806
|
}
|
|
59806
59807
|
for (const type of entries) {
|
|
59807
59808
|
const v1Path = path41.join(categoryDir, type, "provider.v1.json");
|
|
59808
59809
|
const v0Path = path41.join(categoryDir, type, "provider.json");
|
|
59809
|
-
const manifestPath =
|
|
59810
|
+
const manifestPath = fs31.existsSync(v1Path) ? v1Path : fs31.existsSync(v0Path) ? v0Path : null;
|
|
59810
59811
|
if (!manifestPath) continue;
|
|
59811
59812
|
try {
|
|
59812
|
-
const m = JSON.parse(
|
|
59813
|
+
const m = JSON.parse(fs31.readFileSync(manifestPath, "utf-8"));
|
|
59813
59814
|
items.push({
|
|
59814
59815
|
type,
|
|
59815
59816
|
category,
|
|
@@ -59920,7 +59921,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59920
59921
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
59921
59922
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
59922
59923
|
}
|
|
59923
|
-
const
|
|
59924
|
+
const fs31 = require("fs");
|
|
59924
59925
|
const path41 = require("path");
|
|
59925
59926
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
59926
59927
|
const file2 = ext.loadExternalSources();
|
|
@@ -59931,8 +59932,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59931
59932
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
59932
59933
|
}
|
|
59933
59934
|
const sourceDir = path41.join(ext.externalRoot(), requestedName);
|
|
59934
|
-
if (!
|
|
59935
|
-
if (
|
|
59935
|
+
if (!fs31.existsSync(ext.externalRoot())) fs31.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
59936
|
+
if (fs31.existsSync(sourceDir)) {
|
|
59936
59937
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
59937
59938
|
}
|
|
59938
59939
|
const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -59942,7 +59943,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59942
59943
|
});
|
|
59943
59944
|
if (clone2.status !== 0) {
|
|
59944
59945
|
try {
|
|
59945
|
-
|
|
59946
|
+
fs31.rmSync(sourceDir, { recursive: true, force: true });
|
|
59946
59947
|
} catch {
|
|
59947
59948
|
}
|
|
59948
59949
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -59986,15 +59987,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
59986
59987
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
59987
59988
|
if (!name) return { success: false, error: "name is required" };
|
|
59988
59989
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
59989
|
-
const
|
|
59990
|
+
const fs31 = require("fs");
|
|
59990
59991
|
const path41 = require("path");
|
|
59991
59992
|
const file2 = ext.loadExternalSources();
|
|
59992
59993
|
const match = file2.sources.find((s) => s.name === name);
|
|
59993
59994
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
59994
59995
|
const sourceDir = path41.join(ext.externalRoot(), name);
|
|
59995
|
-
if (
|
|
59996
|
+
if (fs31.existsSync(sourceDir)) {
|
|
59996
59997
|
try {
|
|
59997
|
-
|
|
59998
|
+
fs31.rmSync(sourceDir, { recursive: true, force: true });
|
|
59998
59999
|
} catch (e) {
|
|
59999
60000
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
60000
60001
|
}
|
|
@@ -62016,7 +62017,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62016
62017
|
}
|
|
62017
62018
|
if (action.type === "open_picker") {
|
|
62018
62019
|
const choiceIndex = typeof flat.choiceIndex === "number" ? flat.choiceIndex : typeof flat.choiceIndex === "string" && flat.choiceIndex.trim() ? Number(flat.choiceIndex) : void 0;
|
|
62019
|
-
const choiceLabel = typeof flat.choiceLabel === "string" ? flat.choiceLabel : typeof flat.choice === "string" ? flat.choice : void 0;
|
|
62020
|
+
const choiceLabel = typeof flat.choiceLabel === "string" ? flat.choiceLabel : typeof flat.choice === "string" ? flat.choice : typeof flat.value === "string" ? flat.value : void 0;
|
|
62020
62021
|
if (typeof choiceIndex === "number" && Number.isFinite(choiceIndex) || choiceLabel && choiceLabel.trim()) {
|
|
62021
62022
|
return this.selectPickerChoice(ctl, action, choiceIndex, choiceLabel);
|
|
62022
62023
|
}
|
|
@@ -68144,6 +68145,39 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
68144
68145
|
} catch {
|
|
68145
68146
|
}
|
|
68146
68147
|
}
|
|
68148
|
+
function synthesizeControlsFromControlBar(specControls) {
|
|
68149
|
+
const out = [];
|
|
68150
|
+
specControls.forEach((ctl, index) => {
|
|
68151
|
+
const id = typeof ctl?.id === "string" ? ctl.id.trim() : "";
|
|
68152
|
+
const actionType = ctl?.action?.type;
|
|
68153
|
+
if (!id || !actionType) return;
|
|
68154
|
+
const label = typeof ctl?.label === "string" && ctl.label.trim() ? ctl.label : id;
|
|
68155
|
+
if (actionType === "open_picker") {
|
|
68156
|
+
out.push({
|
|
68157
|
+
id,
|
|
68158
|
+
type: "select",
|
|
68159
|
+
label,
|
|
68160
|
+
placement: "bar",
|
|
68161
|
+
dynamic: true,
|
|
68162
|
+
listScript: id,
|
|
68163
|
+
setScript: id,
|
|
68164
|
+
readFrom: id,
|
|
68165
|
+
order: index
|
|
68166
|
+
});
|
|
68167
|
+
} else if (actionType === "send_keys") {
|
|
68168
|
+
out.push({
|
|
68169
|
+
id,
|
|
68170
|
+
type: "action",
|
|
68171
|
+
label,
|
|
68172
|
+
placement: "bar",
|
|
68173
|
+
invokeScript: id,
|
|
68174
|
+
resultDisplay: "none",
|
|
68175
|
+
order: index
|
|
68176
|
+
});
|
|
68177
|
+
}
|
|
68178
|
+
});
|
|
68179
|
+
return out;
|
|
68180
|
+
}
|
|
68147
68181
|
var ProviderLoader = class _ProviderLoader {
|
|
68148
68182
|
providers = /* @__PURE__ */ new Map();
|
|
68149
68183
|
providerAvailability = /* @__PURE__ */ new Map();
|
|
@@ -69048,7 +69082,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69048
69082
|
}
|
|
69049
69083
|
if (providerDir) {
|
|
69050
69084
|
try {
|
|
69051
|
-
const
|
|
69085
|
+
const fs31 = require("fs");
|
|
69052
69086
|
const path41 = require("path");
|
|
69053
69087
|
const candidates = [];
|
|
69054
69088
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -69060,13 +69094,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69060
69094
|
}
|
|
69061
69095
|
candidates.push(path41.join(providerDir, "specs", "default.json"));
|
|
69062
69096
|
candidates.push(path41.join(providerDir, "spec.json"));
|
|
69063
|
-
const specPath = candidates.find((p) =>
|
|
69097
|
+
const specPath = candidates.find((p) => fs31.existsSync(p));
|
|
69064
69098
|
if (specPath) {
|
|
69065
69099
|
resolved._resolvedSpecPath = specPath;
|
|
69066
69100
|
let specControls;
|
|
69067
69101
|
let nh;
|
|
69068
69102
|
try {
|
|
69069
|
-
const rawSpec = JSON.parse(
|
|
69103
|
+
const rawSpec = JSON.parse(fs31.readFileSync(specPath, "utf8"));
|
|
69070
69104
|
specControls = rawSpec.control_bar;
|
|
69071
69105
|
nh = rawSpec.native_history;
|
|
69072
69106
|
} catch {
|
|
@@ -69082,6 +69116,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69082
69116
|
});
|
|
69083
69117
|
}
|
|
69084
69118
|
}
|
|
69119
|
+
const hasDeclaredControls = Array.isArray(resolved.controls) && resolved.controls.length > 0;
|
|
69120
|
+
if (!hasDeclaredControls) {
|
|
69121
|
+
const synthesized = synthesizeControlsFromControlBar(specControls);
|
|
69122
|
+
if (synthesized.length > 0) {
|
|
69123
|
+
resolved.controls = synthesized;
|
|
69124
|
+
}
|
|
69125
|
+
}
|
|
69085
69126
|
}
|
|
69086
69127
|
if (nh) {
|
|
69087
69128
|
let reader = null;
|
|
@@ -69091,7 +69132,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69091
69132
|
reader = (input) => executeNativeHistory(nh, input);
|
|
69092
69133
|
} else if (nh.override_path) {
|
|
69093
69134
|
const overrideFile = path41.resolve(providerDir, nh.override_path);
|
|
69094
|
-
if (
|
|
69135
|
+
if (fs31.existsSync(overrideFile)) {
|
|
69095
69136
|
try {
|
|
69096
69137
|
registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
|
|
69097
69138
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -70272,7 +70313,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70272
70313
|
}
|
|
70273
70314
|
} else if (plat === "win32") {
|
|
70274
70315
|
try {
|
|
70275
|
-
const
|
|
70316
|
+
const fs31 = require("fs");
|
|
70276
70317
|
const appNameMap = getMacAppIdentifiers();
|
|
70277
70318
|
const appName = appNameMap[ideId];
|
|
70278
70319
|
if (appName) {
|
|
@@ -70281,8 +70322,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70281
70322
|
appName,
|
|
70282
70323
|
"storage.json"
|
|
70283
70324
|
);
|
|
70284
|
-
if (
|
|
70285
|
-
const data = JSON.parse(
|
|
70325
|
+
if (fs31.existsSync(storagePath)) {
|
|
70326
|
+
const data = JSON.parse(fs31.readFileSync(storagePath, "utf-8"));
|
|
70286
70327
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
70287
70328
|
if (workspaces.length > 0) {
|
|
70288
70329
|
const recent = workspaces[0];
|
|
@@ -70608,6 +70649,204 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
70608
70649
|
cleanOldFiles();
|
|
70609
70650
|
var yaml3 = __toESM2(require_js_yaml());
|
|
70610
70651
|
init_logger();
|
|
70652
|
+
var fs23 = __toESM2(require("fs"));
|
|
70653
|
+
init_logger();
|
|
70654
|
+
var DEFAULT_TAIL_BYTES = 64 * 1024;
|
|
70655
|
+
var MAX_TAIL_BYTES = 128 * 1024;
|
|
70656
|
+
var READ_CHUNK_BYTES = 64 * 1024;
|
|
70657
|
+
function resolveLogPath(date5) {
|
|
70658
|
+
if (date5 instanceof Date) return getCurrentDaemonLogPath(date5);
|
|
70659
|
+
if (typeof date5 === "string" && date5.trim()) {
|
|
70660
|
+
const parsed = /* @__PURE__ */ new Date(`${date5.trim()}T00:00:00.000Z`);
|
|
70661
|
+
if (!Number.isNaN(parsed.getTime())) return getCurrentDaemonLogPath(parsed);
|
|
70662
|
+
}
|
|
70663
|
+
return getCurrentDaemonLogPath();
|
|
70664
|
+
}
|
|
70665
|
+
function clampTailBytes(tailBytes) {
|
|
70666
|
+
if (!Number.isFinite(tailBytes) || tailBytes <= 0) return DEFAULT_TAIL_BYTES;
|
|
70667
|
+
return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
|
|
70668
|
+
}
|
|
70669
|
+
function readByteBoundedTail(filePath, limitBytes) {
|
|
70670
|
+
const fd = fs23.openSync(filePath, "r");
|
|
70671
|
+
try {
|
|
70672
|
+
const stat2 = fs23.fstatSync(fd);
|
|
70673
|
+
const size = stat2.size;
|
|
70674
|
+
if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
|
|
70675
|
+
const want = Math.min(limitBytes, size);
|
|
70676
|
+
let start = size - want;
|
|
70677
|
+
const truncated = start > 0;
|
|
70678
|
+
const buffers = [];
|
|
70679
|
+
let position = start;
|
|
70680
|
+
while (position < size) {
|
|
70681
|
+
const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
|
|
70682
|
+
const chunk = Buffer.alloc(chunkSize);
|
|
70683
|
+
fs23.readSync(fd, chunk, 0, chunkSize, position);
|
|
70684
|
+
buffers.push(chunk);
|
|
70685
|
+
position += chunkSize;
|
|
70686
|
+
}
|
|
70687
|
+
let buf = Buffer.concat(buffers);
|
|
70688
|
+
if (truncated) {
|
|
70689
|
+
const firstNewline = buf.indexOf(10);
|
|
70690
|
+
if (firstNewline >= 0) {
|
|
70691
|
+
buf = buf.subarray(firstNewline + 1);
|
|
70692
|
+
}
|
|
70693
|
+
}
|
|
70694
|
+
return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
|
|
70695
|
+
} finally {
|
|
70696
|
+
fs23.closeSync(fd);
|
|
70697
|
+
}
|
|
70698
|
+
}
|
|
70699
|
+
function parseLineEpochMs(line, fileDate) {
|
|
70700
|
+
const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
|
|
70701
|
+
if (!m) {
|
|
70702
|
+
const iso = line.match(/\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?/);
|
|
70703
|
+
if (iso) {
|
|
70704
|
+
const t = Date.parse(iso[0].replace(" ", "T"));
|
|
70705
|
+
return Number.isNaN(t) ? null : t;
|
|
70706
|
+
}
|
|
70707
|
+
return null;
|
|
70708
|
+
}
|
|
70709
|
+
const d = new Date(fileDate);
|
|
70710
|
+
d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
|
|
70711
|
+
return d.getTime();
|
|
70712
|
+
}
|
|
70713
|
+
function readDaemonLogTail(args = {}) {
|
|
70714
|
+
const platform10 = process.platform;
|
|
70715
|
+
const limitBytes = clampTailBytes(args.tailBytes);
|
|
70716
|
+
let logPath = resolveLogPath(args.date);
|
|
70717
|
+
if (!fs23.existsSync(logPath)) {
|
|
70718
|
+
const backup = logPath.replace(/\.log$/, ".1.log");
|
|
70719
|
+
if (fs23.existsSync(backup)) {
|
|
70720
|
+
logPath = backup;
|
|
70721
|
+
} else {
|
|
70722
|
+
return {
|
|
70723
|
+
success: false,
|
|
70724
|
+
error: `No daemon log file at ${logPath} (dir: ${getDaemonLogDir()})`,
|
|
70725
|
+
lines: [],
|
|
70726
|
+
truncated: false,
|
|
70727
|
+
logPath,
|
|
70728
|
+
platform: platform10,
|
|
70729
|
+
bytesReturned: 0,
|
|
70730
|
+
filtered: false
|
|
70731
|
+
};
|
|
70732
|
+
}
|
|
70733
|
+
}
|
|
70734
|
+
let raw;
|
|
70735
|
+
try {
|
|
70736
|
+
raw = readByteBoundedTail(logPath, limitBytes);
|
|
70737
|
+
} catch (e) {
|
|
70738
|
+
return {
|
|
70739
|
+
success: false,
|
|
70740
|
+
error: `Failed to read ${logPath}: ${e?.message ?? String(e)}`,
|
|
70741
|
+
lines: [],
|
|
70742
|
+
truncated: false,
|
|
70743
|
+
logPath,
|
|
70744
|
+
platform: platform10,
|
|
70745
|
+
bytesReturned: 0,
|
|
70746
|
+
filtered: false
|
|
70747
|
+
};
|
|
70748
|
+
}
|
|
70749
|
+
let lines = raw.text.split("\n");
|
|
70750
|
+
if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
70751
|
+
const rawCount = lines.length;
|
|
70752
|
+
if (Number.isFinite(args.sinceMs)) {
|
|
70753
|
+
const fileDate = args.date instanceof Date ? args.date : typeof args.date === "string" && args.date.trim() ? /* @__PURE__ */ new Date(`${args.date.trim()}T00:00:00.000Z`) : /* @__PURE__ */ new Date();
|
|
70754
|
+
const floor = args.sinceMs;
|
|
70755
|
+
lines = lines.filter((line) => {
|
|
70756
|
+
const ts2 = parseLineEpochMs(line, fileDate);
|
|
70757
|
+
return ts2 === null || ts2 >= floor;
|
|
70758
|
+
});
|
|
70759
|
+
}
|
|
70760
|
+
let appliedGrep;
|
|
70761
|
+
if (typeof args.grep === "string" && args.grep.trim()) {
|
|
70762
|
+
appliedGrep = args.grep.trim();
|
|
70763
|
+
let re = null;
|
|
70764
|
+
try {
|
|
70765
|
+
re = new RegExp(appliedGrep, "i");
|
|
70766
|
+
} catch {
|
|
70767
|
+
re = null;
|
|
70768
|
+
}
|
|
70769
|
+
if (re) {
|
|
70770
|
+
const compiled = re;
|
|
70771
|
+
lines = lines.filter((line) => compiled.test(line));
|
|
70772
|
+
} else {
|
|
70773
|
+
const needle = appliedGrep.toLowerCase();
|
|
70774
|
+
lines = lines.filter((line) => line.toLowerCase().includes(needle));
|
|
70775
|
+
}
|
|
70776
|
+
}
|
|
70777
|
+
return {
|
|
70778
|
+
success: true,
|
|
70779
|
+
lines,
|
|
70780
|
+
truncated: raw.truncated,
|
|
70781
|
+
logPath,
|
|
70782
|
+
platform: platform10,
|
|
70783
|
+
bytesReturned: raw.bytesReturned,
|
|
70784
|
+
filtered: lines.length !== rawCount,
|
|
70785
|
+
...appliedGrep ? { grep: appliedGrep } : {}
|
|
70786
|
+
};
|
|
70787
|
+
}
|
|
70788
|
+
var MASK = "\u2022\u2022\u2022\u2022redacted";
|
|
70789
|
+
function maskKeepTail(token) {
|
|
70790
|
+
if (token.length <= 8) return MASK;
|
|
70791
|
+
return `${MASK}${token.slice(-4)}`;
|
|
70792
|
+
}
|
|
70793
|
+
var RULES = [
|
|
70794
|
+
// `JWT_SECRET=...`, `TOKEN=...`, `API_KEY=...`, `password: ...` env/config dumps.
|
|
70795
|
+
// Captures the key + delimiter and masks only the value.
|
|
70796
|
+
{
|
|
70797
|
+
name: "key_value_secret",
|
|
70798
|
+
pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
|
|
70799
|
+
replace: (_m, key, delim, quote) => `${key}${delim}${quote}${MASK}${quote}`
|
|
70800
|
+
},
|
|
70801
|
+
// Authorization: Bearer <token>
|
|
70802
|
+
{
|
|
70803
|
+
name: "bearer_token",
|
|
70804
|
+
pattern: /\b(Bearer\s+)([A-Za-z0-9._\-+/=]{8,})/g,
|
|
70805
|
+
replace: (_m, prefix, token) => `${prefix}${maskKeepTail(token)}`
|
|
70806
|
+
},
|
|
70807
|
+
// ADHDev credential prefixes: API key (adk_), machine secret (adm_), provider key (adp_).
|
|
70808
|
+
{
|
|
70809
|
+
name: "adhdev_prefixed_secret",
|
|
70810
|
+
pattern: /\b(ad[kmp]_)([A-Za-z0-9]{6,})/g,
|
|
70811
|
+
replace: (_m, prefix, token) => `${prefix}${maskKeepTail(prefix + token)}`
|
|
70812
|
+
},
|
|
70813
|
+
// JWT: three base64url segments separated by dots, header starts with eyJ.
|
|
70814
|
+
{
|
|
70815
|
+
name: "jwt",
|
|
70816
|
+
pattern: /\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}/g,
|
|
70817
|
+
replace: () => MASK
|
|
70818
|
+
},
|
|
70819
|
+
// TURN credential: a long credential value following a `credential` key in
|
|
70820
|
+
// any common shape — `credential: x`, `credential=x`, or `credential "x"`.
|
|
70821
|
+
// Mask the credential value only, preserving the key + delimiter/quote.
|
|
70822
|
+
{
|
|
70823
|
+
name: "turn_credential",
|
|
70824
|
+
pattern: /\b(credential["']?\s*(?:[:=]\s*)?["']?)([^\s"',;]{6,})/gi,
|
|
70825
|
+
replace: (_m, prefix) => `${prefix}${MASK}`
|
|
70826
|
+
},
|
|
70827
|
+
// TURN REST username:credential of the form `<expiry-ts>:<base64hmac>`,
|
|
70828
|
+
// where the hmac part is long base64. Mask the hmac.
|
|
70829
|
+
{
|
|
70830
|
+
name: "turn_rest_pair",
|
|
70831
|
+
pattern: /\b(\d{10,}:)([A-Za-z0-9+/]{20,}={0,2})\b/g,
|
|
70832
|
+
replace: (_m, prefix) => `${prefix}${MASK}`
|
|
70833
|
+
}
|
|
70834
|
+
];
|
|
70835
|
+
function redactLogLine(line) {
|
|
70836
|
+
if (!line) return line;
|
|
70837
|
+
let out = line;
|
|
70838
|
+
for (const rule of RULES) {
|
|
70839
|
+
try {
|
|
70840
|
+
out = out.replace(rule.pattern, rule.replace);
|
|
70841
|
+
} catch {
|
|
70842
|
+
}
|
|
70843
|
+
}
|
|
70844
|
+
return out;
|
|
70845
|
+
}
|
|
70846
|
+
function redactLogLines(lines) {
|
|
70847
|
+
return lines.map((line) => redactLogLine(line));
|
|
70848
|
+
}
|
|
70849
|
+
var LOG_REDACTION_RULE_NAMES = RULES.map((r) => r.name);
|
|
70611
70850
|
init_mesh_coordinator();
|
|
70612
70851
|
init_mesh_events();
|
|
70613
70852
|
init_mesh_routing();
|
|
@@ -71238,21 +71477,21 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71238
71477
|
init_build_info();
|
|
71239
71478
|
var import_child_process8 = require("child_process");
|
|
71240
71479
|
var import_child_process9 = require("child_process");
|
|
71241
|
-
var
|
|
71480
|
+
var fs24 = __toESM2(require("fs"));
|
|
71242
71481
|
var os27 = __toESM2(require("os"));
|
|
71243
71482
|
var path35 = __toESM2(require("path"));
|
|
71244
71483
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
71245
71484
|
function getUpgradeLogPath() {
|
|
71246
71485
|
const home = os27.homedir();
|
|
71247
71486
|
const dir = path35.join(home, ".adhdev");
|
|
71248
|
-
|
|
71487
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
71249
71488
|
return path35.join(dir, "daemon-upgrade.log");
|
|
71250
71489
|
}
|
|
71251
71490
|
function appendUpgradeLog(message) {
|
|
71252
71491
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
71253
71492
|
`;
|
|
71254
71493
|
try {
|
|
71255
|
-
|
|
71494
|
+
fs24.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
71256
71495
|
} catch {
|
|
71257
71496
|
}
|
|
71258
71497
|
}
|
|
@@ -71260,12 +71499,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71260
71499
|
const binDir = path35.dirname(nodeExecutable);
|
|
71261
71500
|
if (platform10 === "win32") {
|
|
71262
71501
|
const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
71263
|
-
if (
|
|
71502
|
+
if (fs24.existsSync(npmCliPath)) {
|
|
71264
71503
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
71265
71504
|
}
|
|
71266
71505
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
71267
71506
|
const candidatePath = path35.join(binDir, candidate);
|
|
71268
|
-
if (
|
|
71507
|
+
if (fs24.existsSync(candidatePath)) {
|
|
71269
71508
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
71270
71509
|
}
|
|
71271
71510
|
}
|
|
@@ -71273,7 +71512,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71273
71512
|
}
|
|
71274
71513
|
for (const candidate of ["npm"]) {
|
|
71275
71514
|
const candidatePath = path35.join(binDir, candidate);
|
|
71276
|
-
if (
|
|
71515
|
+
if (fs24.existsSync(candidatePath)) {
|
|
71277
71516
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
71278
71517
|
}
|
|
71279
71518
|
}
|
|
@@ -71283,12 +71522,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71283
71522
|
if (!currentCliPath) return null;
|
|
71284
71523
|
let resolvedPath = currentCliPath;
|
|
71285
71524
|
try {
|
|
71286
|
-
resolvedPath =
|
|
71525
|
+
resolvedPath = fs24.realpathSync.native(currentCliPath);
|
|
71287
71526
|
} catch {
|
|
71288
71527
|
}
|
|
71289
71528
|
let currentDir = resolvedPath;
|
|
71290
71529
|
try {
|
|
71291
|
-
if (
|
|
71530
|
+
if (fs24.statSync(resolvedPath).isFile()) {
|
|
71292
71531
|
currentDir = path35.dirname(resolvedPath);
|
|
71293
71532
|
}
|
|
71294
71533
|
} catch {
|
|
@@ -71297,8 +71536,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71297
71536
|
while (true) {
|
|
71298
71537
|
const packageJsonPath = path35.join(currentDir, "package.json");
|
|
71299
71538
|
try {
|
|
71300
|
-
if (
|
|
71301
|
-
const parsed = JSON.parse(
|
|
71539
|
+
if (fs24.existsSync(packageJsonPath)) {
|
|
71540
|
+
const parsed = JSON.parse(fs24.readFileSync(packageJsonPath, "utf8"));
|
|
71302
71541
|
if (parsed?.name === packageName) {
|
|
71303
71542
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
71304
71543
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -71447,8 +71686,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71447
71686
|
function stopSessionHostProcesses(appName) {
|
|
71448
71687
|
const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
71449
71688
|
try {
|
|
71450
|
-
if (
|
|
71451
|
-
const pid = Number.parseInt(
|
|
71689
|
+
if (fs24.existsSync(pidFile)) {
|
|
71690
|
+
const pid = Number.parseInt(fs24.readFileSync(pidFile, "utf8").trim(), 10);
|
|
71452
71691
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
71453
71692
|
killPid2(pid);
|
|
71454
71693
|
}
|
|
@@ -71456,7 +71695,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71456
71695
|
} catch {
|
|
71457
71696
|
} finally {
|
|
71458
71697
|
try {
|
|
71459
|
-
|
|
71698
|
+
fs24.unlinkSync(pidFile);
|
|
71460
71699
|
} catch {
|
|
71461
71700
|
}
|
|
71462
71701
|
}
|
|
@@ -71464,7 +71703,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71464
71703
|
function removeDaemonPidFile() {
|
|
71465
71704
|
const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
|
|
71466
71705
|
try {
|
|
71467
|
-
|
|
71706
|
+
fs24.unlinkSync(pidFile);
|
|
71468
71707
|
} catch {
|
|
71469
71708
|
}
|
|
71470
71709
|
}
|
|
@@ -71482,23 +71721,23 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71482
71721
|
if (pkgName.startsWith("@")) {
|
|
71483
71722
|
const [scope, name] = pkgName.split("/");
|
|
71484
71723
|
const scopeDir = path35.join(npmRoot, scope);
|
|
71485
|
-
if (!
|
|
71486
|
-
for (const entry of
|
|
71724
|
+
if (!fs24.existsSync(scopeDir)) return;
|
|
71725
|
+
for (const entry of fs24.readdirSync(scopeDir)) {
|
|
71487
71726
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
71488
|
-
|
|
71727
|
+
fs24.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
|
|
71489
71728
|
appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
|
|
71490
71729
|
}
|
|
71491
71730
|
} else {
|
|
71492
|
-
for (const entry of
|
|
71731
|
+
for (const entry of fs24.readdirSync(npmRoot)) {
|
|
71493
71732
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
71494
|
-
|
|
71733
|
+
fs24.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
|
|
71495
71734
|
appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
|
|
71496
71735
|
}
|
|
71497
71736
|
}
|
|
71498
|
-
if (
|
|
71499
|
-
for (const entry of
|
|
71737
|
+
if (fs24.existsSync(binDir)) {
|
|
71738
|
+
for (const entry of fs24.readdirSync(binDir)) {
|
|
71500
71739
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
71501
|
-
|
|
71740
|
+
fs24.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
|
|
71502
71741
|
appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
|
|
71503
71742
|
}
|
|
71504
71743
|
}
|
|
@@ -71587,7 +71826,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71587
71826
|
init_repo_mesh_types();
|
|
71588
71827
|
var import_os3 = require("os");
|
|
71589
71828
|
var import_path11 = require("path");
|
|
71590
|
-
var
|
|
71829
|
+
var fs25 = __toESM2(require("fs"));
|
|
71591
71830
|
var import_node_child_process6 = require("child_process");
|
|
71592
71831
|
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
71593
71832
|
var CHANNEL_SERVER_URL = {
|
|
@@ -71913,6 +72152,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
71913
72152
|
function readInlineMeshNodeId(node) {
|
|
71914
72153
|
return normalizeMeshNodeId(node) ?? "";
|
|
71915
72154
|
}
|
|
72155
|
+
function isDeadLocalWorktreeNode(node) {
|
|
72156
|
+
if (node?.isLocalWorktree !== true) return false;
|
|
72157
|
+
const workspace = readStringValue(node?.workspace);
|
|
72158
|
+
if (!workspace) return false;
|
|
72159
|
+
return !fs25.existsSync(workspace);
|
|
72160
|
+
}
|
|
71916
72161
|
function foldMeshNodeIdentityToCanonical(node) {
|
|
71917
72162
|
if (!node || typeof node !== "object" || Array.isArray(node)) return node;
|
|
71918
72163
|
const canonical = normalizeMeshNodeId(node);
|
|
@@ -72159,7 +72404,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72159
72404
|
const followUps = nodes.filter((node) => {
|
|
72160
72405
|
if (readObjectRecord(node.branchConvergence).needsConvergence !== true) return false;
|
|
72161
72406
|
const workspace = typeof node.workspace === "string" ? node.workspace : "";
|
|
72162
|
-
if (workspace && !
|
|
72407
|
+
if (workspace && !fs25.existsSync(workspace)) return false;
|
|
72163
72408
|
return true;
|
|
72164
72409
|
}).map((node) => {
|
|
72165
72410
|
const convergence = readObjectRecord(node.branchConvergence);
|
|
@@ -72367,7 +72612,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72367
72612
|
peerAttemptedCount: 0,
|
|
72368
72613
|
peerConfirmedCount: 0,
|
|
72369
72614
|
standingEvidenceCount: 0,
|
|
72370
|
-
unavailableNodeIds: []
|
|
72615
|
+
unavailableNodeIds: [],
|
|
72616
|
+
deadNodeIds: []
|
|
72371
72617
|
};
|
|
72372
72618
|
}
|
|
72373
72619
|
const selectedCoordinatorNodeId = readStringValue(
|
|
@@ -72380,6 +72626,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72380
72626
|
let peerConfirmedCount = 0;
|
|
72381
72627
|
let standingEvidenceCount = 0;
|
|
72382
72628
|
const unavailableNodeIds = [];
|
|
72629
|
+
const deadNodeIds = [];
|
|
72383
72630
|
for (const [nodeIndex, node] of nodes.entries()) {
|
|
72384
72631
|
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
72385
72632
|
const workspace = readStringValue(node?.workspace);
|
|
@@ -72389,11 +72636,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72389
72636
|
) || Boolean(
|
|
72390
72637
|
daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
|
|
72391
72638
|
) || Boolean(args.meshSource !== "local_config" && nodeIndex === 0);
|
|
72639
|
+
const isSelfDaemonNode = Boolean(
|
|
72640
|
+
daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
|
|
72641
|
+
);
|
|
72642
|
+
if ((isSelfNode || isSelfDaemonNode) && isDeadLocalWorktreeNode(node)) {
|
|
72643
|
+
deadNodeIds.push(nodeId);
|
|
72644
|
+
continue;
|
|
72645
|
+
}
|
|
72392
72646
|
if (!workspace) {
|
|
72393
72647
|
if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
|
|
72394
72648
|
continue;
|
|
72395
72649
|
}
|
|
72396
|
-
if (
|
|
72650
|
+
if (fs25.existsSync(workspace)) {
|
|
72397
72651
|
try {
|
|
72398
72652
|
const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
72399
72653
|
if (localGit?.isGitRepo) {
|
|
@@ -72439,7 +72693,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72439
72693
|
peerAttemptedCount,
|
|
72440
72694
|
peerConfirmedCount,
|
|
72441
72695
|
standingEvidenceCount,
|
|
72442
|
-
unavailableNodeIds
|
|
72696
|
+
unavailableNodeIds,
|
|
72697
|
+
deadNodeIds
|
|
72443
72698
|
};
|
|
72444
72699
|
}
|
|
72445
72700
|
function summarizeMeshSessionRecord(record2) {
|
|
@@ -72498,7 +72753,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72498
72753
|
}
|
|
72499
72754
|
function collectLiveMeshSessionRecords(args) {
|
|
72500
72755
|
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
72501
|
-
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !
|
|
72756
|
+
const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs25.existsSync(nodeWorkspace);
|
|
72502
72757
|
const matches = args.liveSessionRecords.filter((record2) => {
|
|
72503
72758
|
const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
|
|
72504
72759
|
if (recordNodeId && recordNodeId !== args.nodeId) return false;
|
|
@@ -72525,7 +72780,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
72525
72780
|
const workspace = readStringValue(node?.workspace);
|
|
72526
72781
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
72527
72782
|
if (workspace) liveWorkspaces.add(workspace);
|
|
72528
|
-
if (nodeId && node?.isLocalWorktree === true && workspace && !
|
|
72783
|
+
if (nodeId && node?.isLocalWorktree === true && workspace && !fs25.existsSync(workspace)) {
|
|
72529
72784
|
missingLocalWorktreeNodeIds.add(nodeId);
|
|
72530
72785
|
}
|
|
72531
72786
|
}
|
|
@@ -72885,7 +73140,7 @@ ${e?.stderr || ""}`
|
|
|
72885
73140
|
if (!baseCommit || !branchCommit) return false;
|
|
72886
73141
|
if (baseCommit === branchCommit) return true;
|
|
72887
73142
|
try {
|
|
72888
|
-
if (!
|
|
73143
|
+
if (!fs25.existsSync(submoduleRepoPath)) return false;
|
|
72889
73144
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
72890
73145
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
72891
73146
|
(0, import_node_child_process6.execFileSync)("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -73002,7 +73257,7 @@ ${e?.stderr || ""}`
|
|
|
73002
73257
|
return newTree || void 0;
|
|
73003
73258
|
} finally {
|
|
73004
73259
|
try {
|
|
73005
|
-
|
|
73260
|
+
fs25.rmSync(tmpIndex, { force: true });
|
|
73006
73261
|
} catch {
|
|
73007
73262
|
}
|
|
73008
73263
|
}
|
|
@@ -73077,7 +73332,7 @@ ${e?.stderr || ""}`
|
|
|
73077
73332
|
return newTree || void 0;
|
|
73078
73333
|
} finally {
|
|
73079
73334
|
try {
|
|
73080
|
-
|
|
73335
|
+
fs25.rmSync(tmpIndex, { force: true });
|
|
73081
73336
|
} catch {
|
|
73082
73337
|
}
|
|
73083
73338
|
}
|
|
@@ -73183,7 +73438,7 @@ ${e?.stderr || ""}`
|
|
|
73183
73438
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
73184
73439
|
};
|
|
73185
73440
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
73186
|
-
if (!
|
|
73441
|
+
if (!fs25.existsSync(worktreeSubmodulePath)) return false;
|
|
73187
73442
|
try {
|
|
73188
73443
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
73189
73444
|
} catch {
|
|
@@ -73206,7 +73461,7 @@ ${e?.stderr || ""}`
|
|
|
73206
73461
|
reachable: false
|
|
73207
73462
|
};
|
|
73208
73463
|
try {
|
|
73209
|
-
if (!
|
|
73464
|
+
if (!fs25.existsSync(submodulePath)) {
|
|
73210
73465
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
73211
73466
|
entry.publishRequired = true;
|
|
73212
73467
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -73443,9 +73698,9 @@ ${e?.stderr || ""}`
|
|
|
73443
73698
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
73444
73699
|
};
|
|
73445
73700
|
const dependenciesLikelyMissing = (cwd) => {
|
|
73446
|
-
if (!
|
|
73447
|
-
if (
|
|
73448
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
73701
|
+
if (!fs25.existsSync((0, import_path11.join)(cwd, "package.json"))) return false;
|
|
73702
|
+
if (fs25.existsSync((0, import_path11.join)(cwd, "node_modules"))) return false;
|
|
73703
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs25.existsSync((0, import_path11.join)(cwd, lock)));
|
|
73449
73704
|
};
|
|
73450
73705
|
if (runLegacyBootstrapCommands) {
|
|
73451
73706
|
summary.bootstrap = { stage: "legacy" };
|
|
@@ -73547,9 +73802,9 @@ ${e?.stderr || ""}`
|
|
|
73547
73802
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
73548
73803
|
const sourceHome = resolveHermesUserHome();
|
|
73549
73804
|
const sourceConfigPath = (0, import_path11.join)(sourceHome, "config.yaml");
|
|
73550
|
-
if (!
|
|
73805
|
+
if (!fs25.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
73551
73806
|
if ((0, import_path11.resolve)(sourceConfigPath) === (0, import_path11.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
73552
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
73807
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs25.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
73553
73808
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
73554
73809
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
73555
73810
|
}
|
|
@@ -73586,9 +73841,9 @@ ${e?.stderr || ""}`
|
|
|
73586
73841
|
for (const fileName of [".env", "auth.json"]) {
|
|
73587
73842
|
const sourcePath = (0, import_path11.join)(sourceHome, fileName);
|
|
73588
73843
|
const targetPath = (0, import_path11.join)(targetHome, fileName);
|
|
73589
|
-
if (!
|
|
73844
|
+
if (!fs25.existsSync(sourcePath)) continue;
|
|
73590
73845
|
try {
|
|
73591
|
-
|
|
73846
|
+
fs25.copyFileSync(sourcePath, targetPath);
|
|
73592
73847
|
} catch (error48) {
|
|
73593
73848
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
73594
73849
|
}
|
|
@@ -73746,6 +74001,15 @@ ${e?.stderr || ""}`
|
|
|
73746
74001
|
* Allows the MCP server to query mesh data via get_mesh even when
|
|
73747
74002
|
* the mesh doesn't exist in the local meshes.json file. */
|
|
73748
74003
|
inlineMeshCache = /* @__PURE__ */ new Map();
|
|
74004
|
+
/** Tombstones for inline mesh nodes removed via remove_mesh_node, keyed by
|
|
74005
|
+
* meshId → set of removed nodeIds. The dashboard keeps echoing the removed
|
|
74006
|
+
* node in the inlineMesh it attaches to every command; without a tombstone,
|
|
74007
|
+
* reconcileInlineMeshCache MERGEs it straight back (resurrection). A
|
|
74008
|
+
* tombstoned node is skipped during reconcile only while its workspace is
|
|
74009
|
+
* absent from disk — a genuine re-registration (same nodeId, workspace back
|
|
74010
|
+
* on disk) clears the tombstone and merges normally, preserving clone
|
|
74011
|
+
* worktree visibility and legitimate node re-creation. */
|
|
74012
|
+
removedInlineMeshNodeIds = /* @__PURE__ */ new Map();
|
|
73749
74013
|
/** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
|
|
73750
74014
|
aggregateMeshStatusCache = /* @__PURE__ */ new Map();
|
|
73751
74015
|
/** Shared per-peer git_status probe dedup + recently-probed reuse gate.
|
|
@@ -73779,10 +74043,23 @@ ${e?.stderr || ""}`
|
|
|
73779
74043
|
const unavailableNodeIds = /* @__PURE__ */ new Set();
|
|
73780
74044
|
const sourceOfTruth = readObjectRecord(snapshot.sourceOfTruth);
|
|
73781
74045
|
const directPeerTruth = readObjectRecord(sourceOfTruth.directPeerTruth);
|
|
74046
|
+
const deadNodeIds = /* @__PURE__ */ new Set();
|
|
74047
|
+
for (const node of mesh.nodes) {
|
|
74048
|
+
if (!isDeadLocalWorktreeNode(node)) continue;
|
|
74049
|
+
const deadId = readInlineMeshNodeId(node);
|
|
74050
|
+
if (deadId) deadNodeIds.add(deadId);
|
|
74051
|
+
}
|
|
74052
|
+
let droppedDeadUnavailable = false;
|
|
73782
74053
|
for (const entry of Array.isArray(directPeerTruth.unavailableNodeIds) ? directPeerTruth.unavailableNodeIds : []) {
|
|
73783
74054
|
const nodeId = readStringValue(entry);
|
|
73784
|
-
if (nodeId)
|
|
74055
|
+
if (!nodeId) continue;
|
|
74056
|
+
if (deadNodeIds.has(nodeId)) {
|
|
74057
|
+
droppedDeadUnavailable = true;
|
|
74058
|
+
continue;
|
|
74059
|
+
}
|
|
74060
|
+
unavailableNodeIds.add(nodeId);
|
|
73785
74061
|
}
|
|
74062
|
+
if (droppedDeadUnavailable) changed = true;
|
|
73786
74063
|
const nodes = snapshot.nodes.map((statusNode) => {
|
|
73787
74064
|
const nodeId = normalizeMeshNodeId(statusNode);
|
|
73788
74065
|
const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
|
|
@@ -73897,7 +74174,10 @@ ${e?.stderr || ""}`
|
|
|
73897
74174
|
}
|
|
73898
74175
|
warmInlineMeshCache(meshId, inlineMesh) {
|
|
73899
74176
|
if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
|
|
73900
|
-
const sanitizedInlineMesh =
|
|
74177
|
+
const sanitizedInlineMesh = this.applyInlineMeshNodeTombstones(
|
|
74178
|
+
meshId,
|
|
74179
|
+
sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
|
|
74180
|
+
);
|
|
73901
74181
|
const cached22 = this.inlineMeshCache.get(meshId);
|
|
73902
74182
|
if (cached22) {
|
|
73903
74183
|
const merged = reconcileInlineMeshCache(cached22, sanitizedInlineMesh);
|
|
@@ -73913,7 +74193,10 @@ ${e?.stderr || ""}`
|
|
|
73913
74193
|
const cached3 = this.getCachedInlineMesh(meshId);
|
|
73914
74194
|
if (cached3) {
|
|
73915
74195
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
73916
|
-
const merged = reconcileInlineMeshCache(
|
|
74196
|
+
const merged = reconcileInlineMeshCache(
|
|
74197
|
+
cached3,
|
|
74198
|
+
this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
|
|
74199
|
+
);
|
|
73917
74200
|
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
73918
74201
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
73919
74202
|
}
|
|
@@ -73964,12 +74247,49 @@ ${e?.stderr || ""}`
|
|
|
73964
74247
|
if (!mesh || !Array.isArray(mesh.nodes)) return false;
|
|
73965
74248
|
const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, nodeId));
|
|
73966
74249
|
if (idx === -1) return false;
|
|
74250
|
+
const canonicalNodeId = readInlineMeshNodeId(mesh.nodes[idx]) || nodeId;
|
|
73967
74251
|
mesh.nodes.splice(idx, 1);
|
|
73968
74252
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
73969
74253
|
this.inlineMeshCache.set(meshId, mesh);
|
|
74254
|
+
this.tombstoneRemovedInlineMeshNode(meshId, canonicalNodeId);
|
|
74255
|
+
if (canonicalNodeId !== nodeId) this.tombstoneRemovedInlineMeshNode(meshId, nodeId);
|
|
73970
74256
|
this.invalidateAggregateMeshStatus(meshId);
|
|
73971
74257
|
return true;
|
|
73972
74258
|
}
|
|
74259
|
+
tombstoneRemovedInlineMeshNode(meshId, nodeId) {
|
|
74260
|
+
if (!nodeId) return;
|
|
74261
|
+
let set2 = this.removedInlineMeshNodeIds.get(meshId);
|
|
74262
|
+
if (!set2) {
|
|
74263
|
+
set2 = /* @__PURE__ */ new Set();
|
|
74264
|
+
this.removedInlineMeshNodeIds.set(meshId, set2);
|
|
74265
|
+
}
|
|
74266
|
+
set2.add(nodeId);
|
|
74267
|
+
}
|
|
74268
|
+
/** Filter an incoming inline mesh against this mesh's tombstones before it is
|
|
74269
|
+
* reconciled into the cache. A tombstoned node is dropped only while its
|
|
74270
|
+
* workspace is still absent from disk; if the workspace is back (genuine
|
|
74271
|
+
* re-registration), the tombstone is cleared and the node merges normally. */
|
|
74272
|
+
applyInlineMeshNodeTombstones(meshId, incoming) {
|
|
74273
|
+
const tombstones = this.removedInlineMeshNodeIds.get(meshId);
|
|
74274
|
+
if (!tombstones?.size || !incoming || typeof incoming !== "object" || !Array.isArray(incoming.nodes)) {
|
|
74275
|
+
return incoming;
|
|
74276
|
+
}
|
|
74277
|
+
let dropped = false;
|
|
74278
|
+
const nodes = incoming.nodes.filter((node) => {
|
|
74279
|
+
const nodeId = readInlineMeshNodeId(node);
|
|
74280
|
+
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
74281
|
+
const workspace = readStringValue(node?.workspace);
|
|
74282
|
+
if (workspace && fs25.existsSync(workspace)) {
|
|
74283
|
+
tombstones.delete(nodeId);
|
|
74284
|
+
return true;
|
|
74285
|
+
}
|
|
74286
|
+
dropped = true;
|
|
74287
|
+
return false;
|
|
74288
|
+
});
|
|
74289
|
+
if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
|
|
74290
|
+
if (!dropped) return incoming;
|
|
74291
|
+
return { ...incoming, nodes };
|
|
74292
|
+
}
|
|
73973
74293
|
normalizeMeshSessionCleanupMode(value) {
|
|
73974
74294
|
return value === "stop" || value === "delete_stopped" || value === "stop_and_delete" || value === "preserve" ? value : "preserve";
|
|
73975
74295
|
}
|
|
@@ -73992,13 +74312,13 @@ ${e?.stderr || ""}`
|
|
|
73992
74312
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
73993
74313
|
};
|
|
73994
74314
|
}
|
|
73995
|
-
const worktreeExists =
|
|
74315
|
+
const worktreeExists = fs25.existsSync(workspace);
|
|
73996
74316
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
73997
74317
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
73998
74318
|
if (!worktreeExists) {
|
|
73999
74319
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
74000
74320
|
}
|
|
74001
|
-
if (!repoRoot || !
|
|
74321
|
+
if (!repoRoot || !fs25.existsSync(repoRoot)) {
|
|
74002
74322
|
return {
|
|
74003
74323
|
success: false,
|
|
74004
74324
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -74018,7 +74338,7 @@ ${e?.stderr || ""}`
|
|
|
74018
74338
|
const normalizePath = (value) => {
|
|
74019
74339
|
const resolved = (0, import_path11.resolve)(value);
|
|
74020
74340
|
try {
|
|
74021
|
-
return
|
|
74341
|
+
return fs25.realpathSync(resolved);
|
|
74022
74342
|
} catch {
|
|
74023
74343
|
return resolved;
|
|
74024
74344
|
}
|
|
@@ -74104,7 +74424,7 @@ ${e?.stderr || ""}`
|
|
|
74104
74424
|
};
|
|
74105
74425
|
} catch (deinitError) {
|
|
74106
74426
|
try {
|
|
74107
|
-
|
|
74427
|
+
fs25.rmSync(workspace, { recursive: true, force: true });
|
|
74108
74428
|
await execFileAsync4("git", ["worktree", "prune"], {
|
|
74109
74429
|
cwd: repoRoot,
|
|
74110
74430
|
encoding: "utf8",
|
|
@@ -75883,8 +76203,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
75883
76203
|
if (sinceTs > 0) {
|
|
75884
76204
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
75885
76205
|
}
|
|
75886
|
-
if (
|
|
75887
|
-
const content =
|
|
76206
|
+
if (fs25.existsSync(LOG_PATH)) {
|
|
76207
|
+
const content = fs25.readFileSync(LOG_PATH, "utf-8");
|
|
75888
76208
|
const allLines = content.split("\n");
|
|
75889
76209
|
const recent = allLines.slice(-count).join("\n");
|
|
75890
76210
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -76429,14 +76749,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
76429
76749
|
// Settings page in the dashboard reads/writes via these two
|
|
76430
76750
|
// commands instead of going through fs from the browser.
|
|
76431
76751
|
case "list_coordinator_prompts": {
|
|
76432
|
-
const
|
|
76752
|
+
const fs31 = await import("fs");
|
|
76433
76753
|
const path41 = await import("path");
|
|
76434
76754
|
const os30 = await import("os");
|
|
76435
76755
|
const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
76436
76756
|
const entries = {};
|
|
76437
76757
|
try {
|
|
76438
|
-
if (
|
|
76439
|
-
for (const name of
|
|
76758
|
+
if (fs31.existsSync(dir)) {
|
|
76759
|
+
for (const name of fs31.readdirSync(dir)) {
|
|
76440
76760
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
76441
76761
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
76442
76762
|
const m = matchAppend || matchOverride;
|
|
@@ -76446,7 +76766,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
76446
76766
|
const full = path41.join(dir, name);
|
|
76447
76767
|
let content = "";
|
|
76448
76768
|
try {
|
|
76449
|
-
content =
|
|
76769
|
+
content = fs31.readFileSync(full, "utf8");
|
|
76450
76770
|
} catch {
|
|
76451
76771
|
}
|
|
76452
76772
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -76460,7 +76780,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
76460
76780
|
return { success: true, dir, entries };
|
|
76461
76781
|
}
|
|
76462
76782
|
case "write_coordinator_prompt": {
|
|
76463
|
-
const
|
|
76783
|
+
const fs31 = await import("fs");
|
|
76464
76784
|
const path41 = await import("path");
|
|
76465
76785
|
const os30 = await import("os");
|
|
76466
76786
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -76473,11 +76793,11 @@ ${hintLines.join("\n")}` : "",
|
|
|
76473
76793
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
76474
76794
|
const full = path41.join(dir, filename);
|
|
76475
76795
|
try {
|
|
76476
|
-
|
|
76796
|
+
fs31.mkdirSync(dir, { recursive: true });
|
|
76477
76797
|
if (content.trim()) {
|
|
76478
|
-
|
|
76479
|
-
} else if (
|
|
76480
|
-
|
|
76798
|
+
fs31.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
76799
|
+
} else if (fs31.existsSync(full)) {
|
|
76800
|
+
fs31.unlinkSync(full);
|
|
76481
76801
|
}
|
|
76482
76802
|
return { success: true, path: full, kind, key };
|
|
76483
76803
|
} catch (error48) {
|
|
@@ -77255,6 +77575,55 @@ ${hintLines.join("\n")}` : "",
|
|
|
77255
77575
|
});
|
|
77256
77576
|
return result;
|
|
77257
77577
|
}
|
|
77578
|
+
case "get_mesh_node_logs": {
|
|
77579
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
77580
|
+
const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
|
|
77581
|
+
let nodeDaemonId;
|
|
77582
|
+
if (meshId && nodeId) {
|
|
77583
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
77584
|
+
const node = meshRecord?.mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
77585
|
+
nodeDaemonId = typeof node?.daemonId === "string" ? node.daemonId.trim() : void 0;
|
|
77586
|
+
}
|
|
77587
|
+
const selfDaemonId = this.deps.statusInstanceId;
|
|
77588
|
+
const isRemote = nodeDaemonId && selfDaemonId && nodeDaemonId !== selfDaemonId;
|
|
77589
|
+
if (isRemote && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
77590
|
+
const forwarded = await this.deps.dispatchMeshCommand(nodeDaemonId, "get_mesh_node_logs", {
|
|
77591
|
+
...typeof args === "object" && args !== null ? args : {},
|
|
77592
|
+
_meshDirectDispatch: true
|
|
77593
|
+
});
|
|
77594
|
+
return forwarded ?? { success: false, error: "no response from remote node" };
|
|
77595
|
+
}
|
|
77596
|
+
const rawTailBytes = Number(args?.tailBytes);
|
|
77597
|
+
const tail = readDaemonLogTail({
|
|
77598
|
+
date: typeof args?.date === "string" ? args.date : void 0,
|
|
77599
|
+
tailBytes: Number.isFinite(rawTailBytes) ? Math.min(rawTailBytes, MAX_TAIL_BYTES) : void 0,
|
|
77600
|
+
grep: typeof args?.grep === "string" ? args.grep : void 0,
|
|
77601
|
+
sinceMs: Number.isFinite(Number(args?.sinceMs)) ? Number(args?.sinceMs) : void 0
|
|
77602
|
+
});
|
|
77603
|
+
if (!tail.success) {
|
|
77604
|
+
return {
|
|
77605
|
+
success: false,
|
|
77606
|
+
error: tail.error || "failed to read daemon log tail",
|
|
77607
|
+
nodeId,
|
|
77608
|
+
logPath: tail.logPath,
|
|
77609
|
+
platform: tail.platform
|
|
77610
|
+
};
|
|
77611
|
+
}
|
|
77612
|
+
const redactedLines = redactLogLines(tail.lines);
|
|
77613
|
+
return {
|
|
77614
|
+
success: true,
|
|
77615
|
+
nodeId,
|
|
77616
|
+
daemonId: selfDaemonId,
|
|
77617
|
+
logPath: tail.logPath,
|
|
77618
|
+
platform: tail.platform,
|
|
77619
|
+
lines: redactedLines,
|
|
77620
|
+
lineCount: redactedLines.length,
|
|
77621
|
+
truncated: tail.truncated,
|
|
77622
|
+
filtered: tail.filtered,
|
|
77623
|
+
bytesReturned: tail.bytesReturned,
|
|
77624
|
+
...tail.grep ? { grep: tail.grep } : {}
|
|
77625
|
+
};
|
|
77626
|
+
}
|
|
77258
77627
|
case "refine_mesh_node": {
|
|
77259
77628
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
77260
77629
|
const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
|
|
@@ -77922,15 +78291,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77922
78291
|
}
|
|
77923
78292
|
if (cliType === "codex-cli") {
|
|
77924
78293
|
const repoMcpConfigPath = (0, import_path11.join)(workspace, ".mcp.json");
|
|
77925
|
-
if (
|
|
78294
|
+
if (fs25.existsSync(repoMcpConfigPath)) {
|
|
77926
78295
|
try {
|
|
77927
78296
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
77928
|
-
|
|
78297
|
+
fs25.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
77929
78298
|
"claude_mcp_json"
|
|
77930
78299
|
);
|
|
77931
78300
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
77932
78301
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
77933
|
-
|
|
78302
|
+
fs25.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
77934
78303
|
...repoMcpConfig,
|
|
77935
78304
|
mcpServers: {
|
|
77936
78305
|
...existingServers2,
|
|
@@ -78046,7 +78415,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78046
78415
|
workspace
|
|
78047
78416
|
};
|
|
78048
78417
|
}
|
|
78049
|
-
const { existsSync:
|
|
78418
|
+
const { existsSync: existsSync44, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
78050
78419
|
const { dirname: dirname14 } = await import("path");
|
|
78051
78420
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
78052
78421
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -78089,7 +78458,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78089
78458
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
78090
78459
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
78091
78460
|
}
|
|
78092
|
-
const hadExistingMcpConfig =
|
|
78461
|
+
const hadExistingMcpConfig = existsSync44(mcpConfigPath);
|
|
78093
78462
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
78094
78463
|
if (hermesBaseConfig) {
|
|
78095
78464
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
|
|
@@ -78266,7 +78635,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78266
78635
|
peerAttemptedCount: 0,
|
|
78267
78636
|
peerConfirmedCount: 0,
|
|
78268
78637
|
standingEvidenceCount: 0,
|
|
78269
|
-
unavailableNodeIds: []
|
|
78638
|
+
unavailableNodeIds: [],
|
|
78639
|
+
deadNodeIds: []
|
|
78270
78640
|
};
|
|
78271
78641
|
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
78272
78642
|
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
@@ -78406,7 +78776,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78406
78776
|
}
|
|
78407
78777
|
}
|
|
78408
78778
|
if (workspace) {
|
|
78409
|
-
if (!
|
|
78779
|
+
if (!fs25.existsSync(workspace)) {
|
|
78410
78780
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
78411
78781
|
let remoteProbeApplied = false;
|
|
78412
78782
|
if (inlineTransitGit) {
|
|
@@ -78497,7 +78867,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78497
78867
|
const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
|
|
78498
78868
|
const unroutableDeliveries = getRecentUnroutableDeliveries();
|
|
78499
78869
|
const previewFreshness = (() => {
|
|
78500
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
78870
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs25.existsSync(candidate));
|
|
78501
78871
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
78502
78872
|
})();
|
|
78503
78873
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -78592,7 +78962,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78592
78962
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
78593
78963
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
78594
78964
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
78595
|
-
const { existsSync:
|
|
78965
|
+
const { existsSync: existsSync44 } = await import("fs");
|
|
78596
78966
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
78597
78967
|
const mesh = meshRecord?.mesh;
|
|
78598
78968
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -78611,7 +78981,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78611
78981
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
78612
78982
|
for (const item of derivation.items) {
|
|
78613
78983
|
const workspace = item.workspace;
|
|
78614
|
-
if (!workspace || !
|
|
78984
|
+
if (!workspace || !existsSync44(workspace)) continue;
|
|
78615
78985
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
78616
78986
|
try {
|
|
78617
78987
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -80335,7 +80705,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80335
80705
|
this.eventListeners = [];
|
|
80336
80706
|
}
|
|
80337
80707
|
};
|
|
80338
|
-
var
|
|
80708
|
+
var fs26 = __toESM2(require("fs"));
|
|
80339
80709
|
var path36 = __toESM2(require("path"));
|
|
80340
80710
|
var os28 = __toESM2(require("os"));
|
|
80341
80711
|
var import_os4 = require("os");
|
|
@@ -80349,8 +80719,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80349
80719
|
}
|
|
80350
80720
|
load() {
|
|
80351
80721
|
try {
|
|
80352
|
-
if (
|
|
80353
|
-
this.history = JSON.parse(
|
|
80722
|
+
if (fs26.existsSync(ARCHIVE_PATH)) {
|
|
80723
|
+
this.history = JSON.parse(fs26.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
80354
80724
|
}
|
|
80355
80725
|
} catch {
|
|
80356
80726
|
this.history = {};
|
|
@@ -80387,8 +80757,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80387
80757
|
}
|
|
80388
80758
|
save() {
|
|
80389
80759
|
try {
|
|
80390
|
-
|
|
80391
|
-
|
|
80760
|
+
fs26.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
|
|
80761
|
+
fs26.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
80392
80762
|
} catch {
|
|
80393
80763
|
}
|
|
80394
80764
|
}
|
|
@@ -80413,8 +80783,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80413
80783
|
for (const ext of exes) {
|
|
80414
80784
|
const fullPath = path36.join(p, name + ext);
|
|
80415
80785
|
try {
|
|
80416
|
-
if (
|
|
80417
|
-
const stat2 =
|
|
80786
|
+
if (fs26.existsSync(fullPath)) {
|
|
80787
|
+
const stat2 = fs26.statSync(fullPath);
|
|
80418
80788
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
80419
80789
|
return fullPath;
|
|
80420
80790
|
}
|
|
@@ -80461,9 +80831,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80461
80831
|
if (p.includes("*")) {
|
|
80462
80832
|
const home = os28.homedir();
|
|
80463
80833
|
const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
|
|
80464
|
-
if (
|
|
80834
|
+
if (fs26.existsSync(resolved)) return resolved;
|
|
80465
80835
|
} else {
|
|
80466
|
-
if (
|
|
80836
|
+
if (fs26.existsSync(p)) return p;
|
|
80467
80837
|
}
|
|
80468
80838
|
}
|
|
80469
80839
|
return null;
|
|
@@ -80471,7 +80841,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80471
80841
|
async function getMacAppVersion(appPath) {
|
|
80472
80842
|
if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
80473
80843
|
const plistPath = path36.join(appPath, "Contents", "Info.plist");
|
|
80474
|
-
if (!
|
|
80844
|
+
if (!fs26.existsSync(plistPath)) return null;
|
|
80475
80845
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
80476
80846
|
return raw || null;
|
|
80477
80847
|
}
|
|
@@ -80497,7 +80867,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80497
80867
|
let resolvedBin = cliBin;
|
|
80498
80868
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
80499
80869
|
const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
80500
|
-
if (provider.cli &&
|
|
80870
|
+
if (provider.cli && fs26.existsSync(bundled)) resolvedBin = bundled;
|
|
80501
80871
|
}
|
|
80502
80872
|
info.installed = !!(appPath || resolvedBin);
|
|
80503
80873
|
info.path = appPath || null;
|
|
@@ -80534,7 +80904,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
80534
80904
|
return results;
|
|
80535
80905
|
}
|
|
80536
80906
|
var http2 = __toESM2(require("http"));
|
|
80537
|
-
var
|
|
80907
|
+
var fs30 = __toESM2(require("fs"));
|
|
80538
80908
|
var path40 = __toESM2(require("path"));
|
|
80539
80909
|
init_config();
|
|
80540
80910
|
function generateFiles(type, name, category, opts = {}) {
|
|
@@ -80879,7 +81249,7 @@ async (params) => {
|
|
|
80879
81249
|
};
|
|
80880
81250
|
}
|
|
80881
81251
|
init_logger();
|
|
80882
|
-
var
|
|
81252
|
+
var fs27 = __toESM2(require("fs"));
|
|
80883
81253
|
var path37 = __toESM2(require("path"));
|
|
80884
81254
|
init_logger();
|
|
80885
81255
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -81060,17 +81430,17 @@ async (params) => {
|
|
|
81060
81430
|
}
|
|
81061
81431
|
let scriptsPath = "";
|
|
81062
81432
|
const directScripts = path37.join(dir, "scripts.js");
|
|
81063
|
-
if (
|
|
81433
|
+
if (fs27.existsSync(directScripts)) {
|
|
81064
81434
|
scriptsPath = directScripts;
|
|
81065
81435
|
} else {
|
|
81066
81436
|
const scriptsDir = path37.join(dir, "scripts");
|
|
81067
|
-
if (
|
|
81068
|
-
const versions =
|
|
81069
|
-
return
|
|
81437
|
+
if (fs27.existsSync(scriptsDir)) {
|
|
81438
|
+
const versions = fs27.readdirSync(scriptsDir).filter((d) => {
|
|
81439
|
+
return fs27.statSync(path37.join(scriptsDir, d)).isDirectory();
|
|
81070
81440
|
}).sort().reverse();
|
|
81071
81441
|
for (const ver of versions) {
|
|
81072
81442
|
const p = path37.join(scriptsDir, ver, "scripts.js");
|
|
81073
|
-
if (
|
|
81443
|
+
if (fs27.existsSync(p)) {
|
|
81074
81444
|
scriptsPath = p;
|
|
81075
81445
|
break;
|
|
81076
81446
|
}
|
|
@@ -81082,7 +81452,7 @@ async (params) => {
|
|
|
81082
81452
|
return;
|
|
81083
81453
|
}
|
|
81084
81454
|
try {
|
|
81085
|
-
const source =
|
|
81455
|
+
const source = fs27.readFileSync(scriptsPath, "utf-8");
|
|
81086
81456
|
const hints = {};
|
|
81087
81457
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
81088
81458
|
let match;
|
|
@@ -81895,7 +82265,7 @@ async (params) => {
|
|
|
81895
82265
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
81896
82266
|
}
|
|
81897
82267
|
}
|
|
81898
|
-
var
|
|
82268
|
+
var fs28 = __toESM2(require("fs"));
|
|
81899
82269
|
var path38 = __toESM2(require("path"));
|
|
81900
82270
|
function slugifyFixtureName(value) {
|
|
81901
82271
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -81911,10 +82281,10 @@ async (params) => {
|
|
|
81911
82281
|
function readCliFixture(ctx, type, name) {
|
|
81912
82282
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
81913
82283
|
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
81914
|
-
if (!
|
|
82284
|
+
if (!fs28.existsSync(filePath)) {
|
|
81915
82285
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
81916
82286
|
}
|
|
81917
|
-
return JSON.parse(
|
|
82287
|
+
return JSON.parse(fs28.readFileSync(filePath, "utf-8"));
|
|
81918
82288
|
}
|
|
81919
82289
|
function getExerciseTranscriptText(result) {
|
|
81920
82290
|
const parts = [];
|
|
@@ -82659,7 +83029,7 @@ async (params) => {
|
|
|
82659
83029
|
return;
|
|
82660
83030
|
}
|
|
82661
83031
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
82662
|
-
|
|
83032
|
+
fs28.mkdirSync(fixtureDir, { recursive: true });
|
|
82663
83033
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
82664
83034
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
82665
83035
|
const fixture = {
|
|
@@ -82687,7 +83057,7 @@ async (params) => {
|
|
|
82687
83057
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
82688
83058
|
};
|
|
82689
83059
|
const filePath = path38.join(fixtureDir, `${name}.json`);
|
|
82690
|
-
|
|
83060
|
+
fs28.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
82691
83061
|
ctx.json(res, 200, {
|
|
82692
83062
|
saved: true,
|
|
82693
83063
|
name,
|
|
@@ -82705,14 +83075,14 @@ async (params) => {
|
|
|
82705
83075
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
82706
83076
|
try {
|
|
82707
83077
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
82708
|
-
if (!
|
|
83078
|
+
if (!fs28.existsSync(fixtureDir)) {
|
|
82709
83079
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
82710
83080
|
return;
|
|
82711
83081
|
}
|
|
82712
|
-
const fixtures =
|
|
83082
|
+
const fixtures = fs28.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
82713
83083
|
const fullPath = path38.join(fixtureDir, file2);
|
|
82714
83084
|
try {
|
|
82715
|
-
const raw = JSON.parse(
|
|
83085
|
+
const raw = JSON.parse(fs28.readFileSync(fullPath, "utf-8"));
|
|
82716
83086
|
return {
|
|
82717
83087
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
82718
83088
|
path: fullPath,
|
|
@@ -82843,7 +83213,7 @@ async (params) => {
|
|
|
82843
83213
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
82844
83214
|
}
|
|
82845
83215
|
}
|
|
82846
|
-
var
|
|
83216
|
+
var fs29 = __toESM2(require("fs"));
|
|
82847
83217
|
var path39 = __toESM2(require("path"));
|
|
82848
83218
|
var os29 = __toESM2(require("os"));
|
|
82849
83219
|
var import_session_host_core8 = require_dist();
|
|
@@ -82892,10 +83262,10 @@ async (params) => {
|
|
|
82892
83262
|
return fallback?.type || null;
|
|
82893
83263
|
}
|
|
82894
83264
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
82895
|
-
if (!
|
|
82896
|
-
const versions =
|
|
83265
|
+
if (!fs29.existsSync(scriptsDir)) return null;
|
|
83266
|
+
const versions = fs29.readdirSync(scriptsDir).filter((d) => {
|
|
82897
83267
|
try {
|
|
82898
|
-
return
|
|
83268
|
+
return fs29.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
82899
83269
|
} catch {
|
|
82900
83270
|
return false;
|
|
82901
83271
|
}
|
|
@@ -82917,13 +83287,13 @@ async (params) => {
|
|
|
82917
83287
|
if (!sourceDir) {
|
|
82918
83288
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
82919
83289
|
}
|
|
82920
|
-
if (!
|
|
82921
|
-
|
|
82922
|
-
|
|
83290
|
+
if (!fs29.existsSync(desiredDir)) {
|
|
83291
|
+
fs29.mkdirSync(path39.dirname(desiredDir), { recursive: true });
|
|
83292
|
+
fs29.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
82923
83293
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
82924
83294
|
}
|
|
82925
83295
|
const providerJson = path39.join(desiredDir, "provider.json");
|
|
82926
|
-
if (!
|
|
83296
|
+
if (!fs29.existsSync(providerJson)) {
|
|
82927
83297
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
82928
83298
|
}
|
|
82929
83299
|
return { dir: desiredDir };
|
|
@@ -82931,15 +83301,15 @@ async (params) => {
|
|
|
82931
83301
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
82932
83302
|
if (!referenceType) return {};
|
|
82933
83303
|
const refDir = ctx.findProviderDir(referenceType);
|
|
82934
|
-
if (!refDir || !
|
|
83304
|
+
if (!refDir || !fs29.existsSync(refDir)) return {};
|
|
82935
83305
|
const referenceScripts = {};
|
|
82936
83306
|
const scriptsDir = path39.join(refDir, "scripts");
|
|
82937
83307
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
82938
83308
|
if (!latestDir) return referenceScripts;
|
|
82939
|
-
for (const file2 of
|
|
83309
|
+
for (const file2 of fs29.readdirSync(latestDir)) {
|
|
82940
83310
|
if (!file2.endsWith(".js")) continue;
|
|
82941
83311
|
try {
|
|
82942
|
-
referenceScripts[file2] =
|
|
83312
|
+
referenceScripts[file2] = fs29.readFileSync(path39.join(latestDir, file2), "utf-8");
|
|
82943
83313
|
} catch {
|
|
82944
83314
|
}
|
|
82945
83315
|
}
|
|
@@ -83048,15 +83418,15 @@ async (params) => {
|
|
|
83048
83418
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
83049
83419
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
83050
83420
|
const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
83051
|
-
if (!
|
|
83421
|
+
if (!fs29.existsSync(tmpDir)) fs29.mkdirSync(tmpDir, { recursive: true });
|
|
83052
83422
|
const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
83053
|
-
|
|
83423
|
+
fs29.writeFileSync(promptFile, prompt, "utf-8");
|
|
83054
83424
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
83055
83425
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
83056
83426
|
const spawn4 = agentProvider?.spawn;
|
|
83057
83427
|
if (!spawn4?.command) {
|
|
83058
83428
|
try {
|
|
83059
|
-
|
|
83429
|
+
fs29.unlinkSync(promptFile);
|
|
83060
83430
|
} catch {
|
|
83061
83431
|
}
|
|
83062
83432
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -83158,7 +83528,7 @@ async (params) => {
|
|
|
83158
83528
|
} catch {
|
|
83159
83529
|
}
|
|
83160
83530
|
try {
|
|
83161
|
-
|
|
83531
|
+
fs29.unlinkSync(promptFile);
|
|
83162
83532
|
} catch {
|
|
83163
83533
|
}
|
|
83164
83534
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -83384,7 +83754,7 @@ async (params) => {
|
|
|
83384
83754
|
}
|
|
83385
83755
|
});
|
|
83386
83756
|
try {
|
|
83387
|
-
|
|
83757
|
+
fs29.unlinkSync(promptFile);
|
|
83388
83758
|
} catch {
|
|
83389
83759
|
}
|
|
83390
83760
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -83489,10 +83859,10 @@ async (params) => {
|
|
|
83489
83859
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
83490
83860
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
83491
83861
|
lines.push("");
|
|
83492
|
-
for (const file2 of
|
|
83862
|
+
for (const file2 of fs29.readdirSync(latestScriptsDir)) {
|
|
83493
83863
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
83494
83864
|
try {
|
|
83495
|
-
const content =
|
|
83865
|
+
const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83496
83866
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
83497
83867
|
lines.push("```javascript");
|
|
83498
83868
|
lines.push(content);
|
|
@@ -83502,14 +83872,14 @@ async (params) => {
|
|
|
83502
83872
|
}
|
|
83503
83873
|
}
|
|
83504
83874
|
}
|
|
83505
|
-
const refFiles =
|
|
83875
|
+
const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
83506
83876
|
if (refFiles.length > 0) {
|
|
83507
83877
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
83508
83878
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
83509
83879
|
lines.push("");
|
|
83510
83880
|
for (const file2 of refFiles) {
|
|
83511
83881
|
try {
|
|
83512
|
-
const content =
|
|
83882
|
+
const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83513
83883
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
83514
83884
|
lines.push("```javascript");
|
|
83515
83885
|
lines.push(content);
|
|
@@ -83554,7 +83924,7 @@ async (params) => {
|
|
|
83554
83924
|
const loadGuide = (name) => {
|
|
83555
83925
|
try {
|
|
83556
83926
|
const p = path39.join(docsDir, name);
|
|
83557
|
-
if (
|
|
83927
|
+
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
83558
83928
|
} catch {
|
|
83559
83929
|
}
|
|
83560
83930
|
return null;
|
|
@@ -83798,11 +84168,11 @@ async (params) => {
|
|
|
83798
84168
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
83799
84169
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
83800
84170
|
lines.push("");
|
|
83801
|
-
for (const file2 of
|
|
84171
|
+
for (const file2 of fs29.readdirSync(latestScriptsDir)) {
|
|
83802
84172
|
if (!file2.endsWith(".js")) continue;
|
|
83803
84173
|
if (!targetFileNames.has(file2)) continue;
|
|
83804
84174
|
try {
|
|
83805
|
-
const content =
|
|
84175
|
+
const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83806
84176
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
83807
84177
|
lines.push("```javascript");
|
|
83808
84178
|
lines.push(content);
|
|
@@ -83811,14 +84181,14 @@ async (params) => {
|
|
|
83811
84181
|
} catch {
|
|
83812
84182
|
}
|
|
83813
84183
|
}
|
|
83814
|
-
const refFiles =
|
|
84184
|
+
const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
83815
84185
|
if (refFiles.length > 0) {
|
|
83816
84186
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
83817
84187
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
83818
84188
|
lines.push("");
|
|
83819
84189
|
for (const file2 of refFiles) {
|
|
83820
84190
|
try {
|
|
83821
|
-
const content =
|
|
84191
|
+
const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
|
|
83822
84192
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
83823
84193
|
lines.push("```javascript");
|
|
83824
84194
|
lines.push(content);
|
|
@@ -83855,7 +84225,7 @@ async (params) => {
|
|
|
83855
84225
|
const loadGuide = (name) => {
|
|
83856
84226
|
try {
|
|
83857
84227
|
const p = path39.join(docsDir, name);
|
|
83858
|
-
if (
|
|
84228
|
+
if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
|
|
83859
84229
|
} catch {
|
|
83860
84230
|
}
|
|
83861
84231
|
return null;
|
|
@@ -84593,7 +84963,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84593
84963
|
path40.join(process.cwd(), "packages/web-devconsole/dist")
|
|
84594
84964
|
];
|
|
84595
84965
|
for (const dir of candidates) {
|
|
84596
|
-
if (
|
|
84966
|
+
if (fs30.existsSync(path40.join(dir, "index.html"))) return dir;
|
|
84597
84967
|
}
|
|
84598
84968
|
return null;
|
|
84599
84969
|
}
|
|
@@ -84605,7 +84975,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84605
84975
|
}
|
|
84606
84976
|
const htmlPath = path40.join(distDir, "index.html");
|
|
84607
84977
|
try {
|
|
84608
|
-
const html =
|
|
84978
|
+
const html = fs30.readFileSync(htmlPath, "utf-8");
|
|
84609
84979
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
84610
84980
|
res.end(html);
|
|
84611
84981
|
} catch (e) {
|
|
@@ -84635,7 +85005,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84635
85005
|
return;
|
|
84636
85006
|
}
|
|
84637
85007
|
try {
|
|
84638
|
-
const content =
|
|
85008
|
+
const content = fs30.readFileSync(filePath);
|
|
84639
85009
|
const ext = path40.extname(filePath);
|
|
84640
85010
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
84641
85011
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -84744,14 +85114,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84744
85114
|
const files = [];
|
|
84745
85115
|
const scan = (d, prefix) => {
|
|
84746
85116
|
try {
|
|
84747
|
-
for (const entry of
|
|
85117
|
+
for (const entry of fs30.readdirSync(d, { withFileTypes: true })) {
|
|
84748
85118
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
84749
85119
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
84750
85120
|
if (entry.isDirectory()) {
|
|
84751
85121
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
84752
85122
|
scan(path40.join(d, entry.name), rel);
|
|
84753
85123
|
} else {
|
|
84754
|
-
const stat2 =
|
|
85124
|
+
const stat2 = fs30.statSync(path40.join(d, entry.name));
|
|
84755
85125
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
84756
85126
|
}
|
|
84757
85127
|
}
|
|
@@ -84779,11 +85149,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84779
85149
|
this.json(res, 403, { error: "Forbidden" });
|
|
84780
85150
|
return;
|
|
84781
85151
|
}
|
|
84782
|
-
if (!
|
|
85152
|
+
if (!fs30.existsSync(fullPath) || fs30.statSync(fullPath).isDirectory()) {
|
|
84783
85153
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
84784
85154
|
return;
|
|
84785
85155
|
}
|
|
84786
|
-
const content =
|
|
85156
|
+
const content = fs30.readFileSync(fullPath, "utf-8");
|
|
84787
85157
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
84788
85158
|
}
|
|
84789
85159
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -84805,9 +85175,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84805
85175
|
return;
|
|
84806
85176
|
}
|
|
84807
85177
|
try {
|
|
84808
|
-
if (
|
|
84809
|
-
|
|
84810
|
-
|
|
85178
|
+
if (fs30.existsSync(fullPath)) fs30.copyFileSync(fullPath, fullPath + ".bak");
|
|
85179
|
+
fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
85180
|
+
fs30.writeFileSync(fullPath, content, "utf-8");
|
|
84811
85181
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
84812
85182
|
this.providerLoader.reload();
|
|
84813
85183
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -84824,8 +85194,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84824
85194
|
}
|
|
84825
85195
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
84826
85196
|
const p = path40.join(dir, name);
|
|
84827
|
-
if (
|
|
84828
|
-
const source =
|
|
85197
|
+
if (fs30.existsSync(p)) {
|
|
85198
|
+
const source = fs30.readFileSync(p, "utf-8");
|
|
84829
85199
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
84830
85200
|
return;
|
|
84831
85201
|
}
|
|
@@ -84844,11 +85214,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84844
85214
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
84845
85215
|
return;
|
|
84846
85216
|
}
|
|
84847
|
-
const target =
|
|
85217
|
+
const target = fs30.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
84848
85218
|
const targetPath = path40.join(dir, target);
|
|
84849
85219
|
try {
|
|
84850
|
-
if (
|
|
84851
|
-
|
|
85220
|
+
if (fs30.existsSync(targetPath)) fs30.copyFileSync(targetPath, targetPath + ".bak");
|
|
85221
|
+
fs30.writeFileSync(targetPath, source, "utf-8");
|
|
84852
85222
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
84853
85223
|
this.providerLoader.reload();
|
|
84854
85224
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -84993,20 +85363,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84993
85363
|
let targetDir;
|
|
84994
85364
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
84995
85365
|
const jsonPath = path40.join(targetDir, "provider.json");
|
|
84996
|
-
if (
|
|
85366
|
+
if (fs30.existsSync(jsonPath)) {
|
|
84997
85367
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
84998
85368
|
return;
|
|
84999
85369
|
}
|
|
85000
85370
|
try {
|
|
85001
85371
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
85002
|
-
|
|
85003
|
-
|
|
85372
|
+
fs30.mkdirSync(targetDir, { recursive: true });
|
|
85373
|
+
fs30.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
85004
85374
|
const createdFiles = ["provider.json"];
|
|
85005
85375
|
if (result.files) {
|
|
85006
85376
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
85007
85377
|
const fullPath = path40.join(targetDir, relPath);
|
|
85008
|
-
|
|
85009
|
-
|
|
85378
|
+
fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
|
|
85379
|
+
fs30.writeFileSync(fullPath, content, "utf-8");
|
|
85010
85380
|
createdFiles.push(relPath);
|
|
85011
85381
|
}
|
|
85012
85382
|
}
|
|
@@ -85055,10 +85425,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85055
85425
|
}
|
|
85056
85426
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
85057
85427
|
getLatestScriptVersionDir(scriptsDir) {
|
|
85058
|
-
if (!
|
|
85059
|
-
const versions =
|
|
85428
|
+
if (!fs30.existsSync(scriptsDir)) return null;
|
|
85429
|
+
const versions = fs30.readdirSync(scriptsDir).filter((d) => {
|
|
85060
85430
|
try {
|
|
85061
|
-
return
|
|
85431
|
+
return fs30.statSync(path40.join(scriptsDir, d)).isDirectory();
|
|
85062
85432
|
} catch {
|
|
85063
85433
|
return false;
|
|
85064
85434
|
}
|
|
@@ -85080,13 +85450,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85080
85450
|
if (!sourceDir) {
|
|
85081
85451
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
85082
85452
|
}
|
|
85083
|
-
if (!
|
|
85084
|
-
|
|
85085
|
-
|
|
85453
|
+
if (!fs30.existsSync(desiredDir)) {
|
|
85454
|
+
fs30.mkdirSync(path40.dirname(desiredDir), { recursive: true });
|
|
85455
|
+
fs30.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
85086
85456
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
85087
85457
|
}
|
|
85088
85458
|
const providerJson = path40.join(desiredDir, "provider.json");
|
|
85089
|
-
if (!
|
|
85459
|
+
if (!fs30.existsSync(providerJson)) {
|
|
85090
85460
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
85091
85461
|
}
|
|
85092
85462
|
return { dir: desiredDir };
|
|
@@ -85129,10 +85499,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85129
85499
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
85130
85500
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
85131
85501
|
lines.push("");
|
|
85132
|
-
for (const file2 of
|
|
85502
|
+
for (const file2 of fs30.readdirSync(latestScriptsDir)) {
|
|
85133
85503
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
85134
85504
|
try {
|
|
85135
|
-
const content =
|
|
85505
|
+
const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
85136
85506
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
85137
85507
|
lines.push("```javascript");
|
|
85138
85508
|
lines.push(content);
|
|
@@ -85142,14 +85512,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85142
85512
|
}
|
|
85143
85513
|
}
|
|
85144
85514
|
}
|
|
85145
|
-
const refFiles =
|
|
85515
|
+
const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
85146
85516
|
if (refFiles.length > 0) {
|
|
85147
85517
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
85148
85518
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
85149
85519
|
lines.push("");
|
|
85150
85520
|
for (const file2 of refFiles) {
|
|
85151
85521
|
try {
|
|
85152
|
-
const content =
|
|
85522
|
+
const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
85153
85523
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
85154
85524
|
lines.push("```javascript");
|
|
85155
85525
|
lines.push(content);
|
|
@@ -85194,7 +85564,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85194
85564
|
const loadGuide = (name) => {
|
|
85195
85565
|
try {
|
|
85196
85566
|
const p = path40.join(docsDir, name);
|
|
85197
|
-
if (
|
|
85567
|
+
if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
|
|
85198
85568
|
} catch {
|
|
85199
85569
|
}
|
|
85200
85570
|
return null;
|
|
@@ -85375,11 +85745,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85375
85745
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
85376
85746
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
85377
85747
|
lines.push("");
|
|
85378
|
-
for (const file2 of
|
|
85748
|
+
for (const file2 of fs30.readdirSync(latestScriptsDir)) {
|
|
85379
85749
|
if (!file2.endsWith(".js")) continue;
|
|
85380
85750
|
if (!targetFileNames.has(file2)) continue;
|
|
85381
85751
|
try {
|
|
85382
|
-
const content =
|
|
85752
|
+
const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
85383
85753
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
85384
85754
|
lines.push("```javascript");
|
|
85385
85755
|
lines.push(content);
|
|
@@ -85388,14 +85758,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85388
85758
|
} catch {
|
|
85389
85759
|
}
|
|
85390
85760
|
}
|
|
85391
|
-
const refFiles =
|
|
85761
|
+
const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
85392
85762
|
if (refFiles.length > 0) {
|
|
85393
85763
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
85394
85764
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
85395
85765
|
lines.push("");
|
|
85396
85766
|
for (const file2 of refFiles) {
|
|
85397
85767
|
try {
|
|
85398
|
-
const content =
|
|
85768
|
+
const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
|
|
85399
85769
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
85400
85770
|
lines.push("```javascript");
|
|
85401
85771
|
lines.push(content);
|
|
@@ -85432,7 +85802,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85432
85802
|
const loadGuide = (name) => {
|
|
85433
85803
|
try {
|
|
85434
85804
|
const p = path40.join(docsDir, name);
|
|
85435
|
-
if (
|
|
85805
|
+
if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
|
|
85436
85806
|
} catch {
|
|
85437
85807
|
}
|
|
85438
85808
|
return null;
|
|
@@ -86519,8 +86889,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
86519
86889
|
const res = await fetch(extension.vsixUrl);
|
|
86520
86890
|
if (res.ok) {
|
|
86521
86891
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
86522
|
-
const
|
|
86523
|
-
|
|
86892
|
+
const fs31 = await import("fs");
|
|
86893
|
+
fs31.writeFileSync(vsixPath, buffer);
|
|
86524
86894
|
return new Promise((resolve24) => {
|
|
86525
86895
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
86526
86896
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|