@adhdev/daemon-standalone 0.9.82-rc.311 → 0.9.82-rc.312

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 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 ? "3902f3d63eabe7b9e34d0e849dc0fed2fd66c026" : void 0) ?? "unknown";
30033
- const commitShort = readInjected(true ? "3902f3d6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30034
- const version2 = readInjected(true ? "0.9.82-rc.311" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30035
- const builtAt = readInjected(true ? "2026-06-17T12:22:27.984Z" : void 0);
30032
+ const commit = readInjected(true ? "35facf0367dbbe37f25a3b5589287dc757ee6213" : void 0) ?? "unknown";
30033
+ const commitShort = readInjected(true ? "35facf03" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30034
+ const version2 = readInjected(true ? "0.9.82-rc.312" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30035
+ const builtAt = readInjected(true ? "2026-06-17T22:49:21.710Z" : 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 fs30 = require("fs");
35589
- fs30.unlinkSync(filePath);
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 fs30 = require("fs");
40635
- const stat2 = fs30.statSync(cwd);
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 fs30 = require("fs");
40741
- if (fs30.existsSync(fullPath)) {
40742
- const stat2 = fs30.statSync(fullPath);
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 fs30 = require("fs");
40757
- const resolved = fs30.realpathSync(binaryPath);
40757
+ const fs31 = require("fs");
40758
+ const resolved = fs31.realpathSync(binaryPath);
40758
40759
  const head = Buffer.alloc(8);
40759
- const fd = fs30.openSync(resolved, "r");
40760
- fs30.readSync(fd, head, 0, 8, 0);
40761
- fs30.closeSync(fd);
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 fs30 = require("fs");
40773
- const resolved = fs30.realpathSync(filePath);
40773
+ const fs31 = require("fs");
40774
+ const resolved = fs31.realpathSync(filePath);
40774
40775
  const buf = Buffer.alloc(8);
40775
- const fd = fs30.openSync(resolved, "r");
40776
- fs30.readSync(fd, buf, 0, 8, 0);
40777
- fs30.closeSync(fd);
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 fs30 = require("fs");
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
- fs30.mkdirSync(targetDir, { recursive: true });
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
- fs30.writeFileSync(targetPath, manifestBody, "utf-8");
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 fs30 = require("fs");
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
- fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
59696
- fs30.writeFileSync(outPath, body);
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
- fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
59735
- fs30.writeFileSync(outPath, body);
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 fs30 = require("fs");
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 (!fs30.existsSync(targetDir)) {
59773
+ if (!fs31.existsSync(targetDir)) {
59773
59774
  return { success: false, error: "not installed" };
59774
59775
  }
59775
- fs30.rmSync(targetDir, { recursive: true, force: true });
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 fs30 = require("fs");
59792
+ const fs31 = require("fs");
59792
59793
  const path41 = require("path");
59793
59794
  const installRoot = this.getUpstreamInstallRoot();
59794
- if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
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 (!fs30.existsSync(categoryDir)) continue;
59800
+ if (!fs31.existsSync(categoryDir)) continue;
59800
59801
  let entries;
59801
59802
  try {
59802
- entries = fs30.readdirSync(categoryDir);
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 = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
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(fs30.readFileSync(manifestPath, "utf-8"));
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 fs30 = require("fs");
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 (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
59935
- if (fs30.existsSync(sourceDir)) {
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
- fs30.rmSync(sourceDir, { recursive: true, force: true });
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 fs30 = require("fs");
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 (fs30.existsSync(sourceDir)) {
59996
+ if (fs31.existsSync(sourceDir)) {
59996
59997
  try {
59997
- fs30.rmSync(sourceDir, { recursive: true, force: true });
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
  }
@@ -69048,7 +69049,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
69048
69049
  }
69049
69050
  if (providerDir) {
69050
69051
  try {
69051
- const fs30 = require("fs");
69052
+ const fs31 = require("fs");
69052
69053
  const path41 = require("path");
69053
69054
  const candidates = [];
69054
69055
  if (Array.isArray(base.compatibility)) {
@@ -69060,13 +69061,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
69060
69061
  }
69061
69062
  candidates.push(path41.join(providerDir, "specs", "default.json"));
69062
69063
  candidates.push(path41.join(providerDir, "spec.json"));
69063
- const specPath = candidates.find((p) => fs30.existsSync(p));
69064
+ const specPath = candidates.find((p) => fs31.existsSync(p));
69064
69065
  if (specPath) {
69065
69066
  resolved._resolvedSpecPath = specPath;
69066
69067
  let specControls;
69067
69068
  let nh;
69068
69069
  try {
69069
- const rawSpec = JSON.parse(fs30.readFileSync(specPath, "utf8"));
69070
+ const rawSpec = JSON.parse(fs31.readFileSync(specPath, "utf8"));
69070
69071
  specControls = rawSpec.control_bar;
69071
69072
  nh = rawSpec.native_history;
69072
69073
  } catch {
@@ -69091,7 +69092,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
69091
69092
  reader = (input) => executeNativeHistory(nh, input);
69092
69093
  } else if (nh.override_path) {
69093
69094
  const overrideFile = path41.resolve(providerDir, nh.override_path);
69094
- if (fs30.existsSync(overrideFile)) {
69095
+ if (fs31.existsSync(overrideFile)) {
69095
69096
  try {
69096
69097
  registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
69097
69098
  delete require.cache[require.resolve(overrideFile)];
@@ -70272,7 +70273,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70272
70273
  }
70273
70274
  } else if (plat === "win32") {
70274
70275
  try {
70275
- const fs30 = require("fs");
70276
+ const fs31 = require("fs");
70276
70277
  const appNameMap = getMacAppIdentifiers();
70277
70278
  const appName = appNameMap[ideId];
70278
70279
  if (appName) {
@@ -70281,8 +70282,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70281
70282
  appName,
70282
70283
  "storage.json"
70283
70284
  );
70284
- if (fs30.existsSync(storagePath)) {
70285
- const data = JSON.parse(fs30.readFileSync(storagePath, "utf-8"));
70285
+ if (fs31.existsSync(storagePath)) {
70286
+ const data = JSON.parse(fs31.readFileSync(storagePath, "utf-8"));
70286
70287
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
70287
70288
  if (workspaces.length > 0) {
70288
70289
  const recent = workspaces[0];
@@ -70608,6 +70609,204 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70608
70609
  cleanOldFiles();
70609
70610
  var yaml3 = __toESM2(require_js_yaml());
70610
70611
  init_logger();
70612
+ var fs23 = __toESM2(require("fs"));
70613
+ init_logger();
70614
+ var DEFAULT_TAIL_BYTES = 64 * 1024;
70615
+ var MAX_TAIL_BYTES = 128 * 1024;
70616
+ var READ_CHUNK_BYTES = 64 * 1024;
70617
+ function resolveLogPath(date5) {
70618
+ if (date5 instanceof Date) return getCurrentDaemonLogPath(date5);
70619
+ if (typeof date5 === "string" && date5.trim()) {
70620
+ const parsed = /* @__PURE__ */ new Date(`${date5.trim()}T00:00:00.000Z`);
70621
+ if (!Number.isNaN(parsed.getTime())) return getCurrentDaemonLogPath(parsed);
70622
+ }
70623
+ return getCurrentDaemonLogPath();
70624
+ }
70625
+ function clampTailBytes(tailBytes) {
70626
+ if (!Number.isFinite(tailBytes) || tailBytes <= 0) return DEFAULT_TAIL_BYTES;
70627
+ return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
70628
+ }
70629
+ function readByteBoundedTail(filePath, limitBytes) {
70630
+ const fd = fs23.openSync(filePath, "r");
70631
+ try {
70632
+ const stat2 = fs23.fstatSync(fd);
70633
+ const size = stat2.size;
70634
+ if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
70635
+ const want = Math.min(limitBytes, size);
70636
+ let start = size - want;
70637
+ const truncated = start > 0;
70638
+ const buffers = [];
70639
+ let position = start;
70640
+ while (position < size) {
70641
+ const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
70642
+ const chunk = Buffer.alloc(chunkSize);
70643
+ fs23.readSync(fd, chunk, 0, chunkSize, position);
70644
+ buffers.push(chunk);
70645
+ position += chunkSize;
70646
+ }
70647
+ let buf = Buffer.concat(buffers);
70648
+ if (truncated) {
70649
+ const firstNewline = buf.indexOf(10);
70650
+ if (firstNewline >= 0) {
70651
+ buf = buf.subarray(firstNewline + 1);
70652
+ }
70653
+ }
70654
+ return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
70655
+ } finally {
70656
+ fs23.closeSync(fd);
70657
+ }
70658
+ }
70659
+ function parseLineEpochMs(line, fileDate) {
70660
+ const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
70661
+ if (!m) {
70662
+ const iso = line.match(/\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?/);
70663
+ if (iso) {
70664
+ const t = Date.parse(iso[0].replace(" ", "T"));
70665
+ return Number.isNaN(t) ? null : t;
70666
+ }
70667
+ return null;
70668
+ }
70669
+ const d = new Date(fileDate);
70670
+ d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
70671
+ return d.getTime();
70672
+ }
70673
+ function readDaemonLogTail(args = {}) {
70674
+ const platform10 = process.platform;
70675
+ const limitBytes = clampTailBytes(args.tailBytes);
70676
+ let logPath = resolveLogPath(args.date);
70677
+ if (!fs23.existsSync(logPath)) {
70678
+ const backup = logPath.replace(/\.log$/, ".1.log");
70679
+ if (fs23.existsSync(backup)) {
70680
+ logPath = backup;
70681
+ } else {
70682
+ return {
70683
+ success: false,
70684
+ error: `No daemon log file at ${logPath} (dir: ${getDaemonLogDir()})`,
70685
+ lines: [],
70686
+ truncated: false,
70687
+ logPath,
70688
+ platform: platform10,
70689
+ bytesReturned: 0,
70690
+ filtered: false
70691
+ };
70692
+ }
70693
+ }
70694
+ let raw;
70695
+ try {
70696
+ raw = readByteBoundedTail(logPath, limitBytes);
70697
+ } catch (e) {
70698
+ return {
70699
+ success: false,
70700
+ error: `Failed to read ${logPath}: ${e?.message ?? String(e)}`,
70701
+ lines: [],
70702
+ truncated: false,
70703
+ logPath,
70704
+ platform: platform10,
70705
+ bytesReturned: 0,
70706
+ filtered: false
70707
+ };
70708
+ }
70709
+ let lines = raw.text.split("\n");
70710
+ if (lines.length && lines[lines.length - 1] === "") lines.pop();
70711
+ const rawCount = lines.length;
70712
+ if (Number.isFinite(args.sinceMs)) {
70713
+ 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();
70714
+ const floor = args.sinceMs;
70715
+ lines = lines.filter((line) => {
70716
+ const ts2 = parseLineEpochMs(line, fileDate);
70717
+ return ts2 === null || ts2 >= floor;
70718
+ });
70719
+ }
70720
+ let appliedGrep;
70721
+ if (typeof args.grep === "string" && args.grep.trim()) {
70722
+ appliedGrep = args.grep.trim();
70723
+ let re = null;
70724
+ try {
70725
+ re = new RegExp(appliedGrep, "i");
70726
+ } catch {
70727
+ re = null;
70728
+ }
70729
+ if (re) {
70730
+ const compiled = re;
70731
+ lines = lines.filter((line) => compiled.test(line));
70732
+ } else {
70733
+ const needle = appliedGrep.toLowerCase();
70734
+ lines = lines.filter((line) => line.toLowerCase().includes(needle));
70735
+ }
70736
+ }
70737
+ return {
70738
+ success: true,
70739
+ lines,
70740
+ truncated: raw.truncated,
70741
+ logPath,
70742
+ platform: platform10,
70743
+ bytesReturned: raw.bytesReturned,
70744
+ filtered: lines.length !== rawCount,
70745
+ ...appliedGrep ? { grep: appliedGrep } : {}
70746
+ };
70747
+ }
70748
+ var MASK = "\u2022\u2022\u2022\u2022redacted";
70749
+ function maskKeepTail(token) {
70750
+ if (token.length <= 8) return MASK;
70751
+ return `${MASK}${token.slice(-4)}`;
70752
+ }
70753
+ var RULES = [
70754
+ // `JWT_SECRET=...`, `TOKEN=...`, `API_KEY=...`, `password: ...` env/config dumps.
70755
+ // Captures the key + delimiter and masks only the value.
70756
+ {
70757
+ name: "key_value_secret",
70758
+ pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
70759
+ replace: (_m, key, delim, quote) => `${key}${delim}${quote}${MASK}${quote}`
70760
+ },
70761
+ // Authorization: Bearer <token>
70762
+ {
70763
+ name: "bearer_token",
70764
+ pattern: /\b(Bearer\s+)([A-Za-z0-9._\-+/=]{8,})/g,
70765
+ replace: (_m, prefix, token) => `${prefix}${maskKeepTail(token)}`
70766
+ },
70767
+ // ADHDev credential prefixes: API key (adk_), machine secret (adm_), provider key (adp_).
70768
+ {
70769
+ name: "adhdev_prefixed_secret",
70770
+ pattern: /\b(ad[kmp]_)([A-Za-z0-9]{6,})/g,
70771
+ replace: (_m, prefix, token) => `${prefix}${maskKeepTail(prefix + token)}`
70772
+ },
70773
+ // JWT: three base64url segments separated by dots, header starts with eyJ.
70774
+ {
70775
+ name: "jwt",
70776
+ pattern: /\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}/g,
70777
+ replace: () => MASK
70778
+ },
70779
+ // TURN credential: a long credential value following a `credential` key in
70780
+ // any common shape — `credential: x`, `credential=x`, or `credential "x"`.
70781
+ // Mask the credential value only, preserving the key + delimiter/quote.
70782
+ {
70783
+ name: "turn_credential",
70784
+ pattern: /\b(credential["']?\s*(?:[:=]\s*)?["']?)([^\s"',;]{6,})/gi,
70785
+ replace: (_m, prefix) => `${prefix}${MASK}`
70786
+ },
70787
+ // TURN REST username:credential of the form `<expiry-ts>:<base64hmac>`,
70788
+ // where the hmac part is long base64. Mask the hmac.
70789
+ {
70790
+ name: "turn_rest_pair",
70791
+ pattern: /\b(\d{10,}:)([A-Za-z0-9+/]{20,}={0,2})\b/g,
70792
+ replace: (_m, prefix) => `${prefix}${MASK}`
70793
+ }
70794
+ ];
70795
+ function redactLogLine(line) {
70796
+ if (!line) return line;
70797
+ let out = line;
70798
+ for (const rule of RULES) {
70799
+ try {
70800
+ out = out.replace(rule.pattern, rule.replace);
70801
+ } catch {
70802
+ }
70803
+ }
70804
+ return out;
70805
+ }
70806
+ function redactLogLines(lines) {
70807
+ return lines.map((line) => redactLogLine(line));
70808
+ }
70809
+ var LOG_REDACTION_RULE_NAMES = RULES.map((r) => r.name);
70611
70810
  init_mesh_coordinator();
70612
70811
  init_mesh_events();
70613
70812
  init_mesh_routing();
@@ -71238,21 +71437,21 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71238
71437
  init_build_info();
71239
71438
  var import_child_process8 = require("child_process");
71240
71439
  var import_child_process9 = require("child_process");
71241
- var fs23 = __toESM2(require("fs"));
71440
+ var fs24 = __toESM2(require("fs"));
71242
71441
  var os27 = __toESM2(require("os"));
71243
71442
  var path35 = __toESM2(require("path"));
71244
71443
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
71245
71444
  function getUpgradeLogPath() {
71246
71445
  const home = os27.homedir();
71247
71446
  const dir = path35.join(home, ".adhdev");
71248
- fs23.mkdirSync(dir, { recursive: true });
71447
+ fs24.mkdirSync(dir, { recursive: true });
71249
71448
  return path35.join(dir, "daemon-upgrade.log");
71250
71449
  }
71251
71450
  function appendUpgradeLog(message) {
71252
71451
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
71253
71452
  `;
71254
71453
  try {
71255
- fs23.appendFileSync(getUpgradeLogPath(), line, "utf8");
71454
+ fs24.appendFileSync(getUpgradeLogPath(), line, "utf8");
71256
71455
  } catch {
71257
71456
  }
71258
71457
  }
@@ -71260,12 +71459,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71260
71459
  const binDir = path35.dirname(nodeExecutable);
71261
71460
  if (platform10 === "win32") {
71262
71461
  const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
71263
- if (fs23.existsSync(npmCliPath)) {
71462
+ if (fs24.existsSync(npmCliPath)) {
71264
71463
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
71265
71464
  }
71266
71465
  for (const candidate of ["npm.exe", "npm"]) {
71267
71466
  const candidatePath = path35.join(binDir, candidate);
71268
- if (fs23.existsSync(candidatePath)) {
71467
+ if (fs24.existsSync(candidatePath)) {
71269
71468
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
71270
71469
  }
71271
71470
  }
@@ -71273,7 +71472,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71273
71472
  }
71274
71473
  for (const candidate of ["npm"]) {
71275
71474
  const candidatePath = path35.join(binDir, candidate);
71276
- if (fs23.existsSync(candidatePath)) {
71475
+ if (fs24.existsSync(candidatePath)) {
71277
71476
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
71278
71477
  }
71279
71478
  }
@@ -71283,12 +71482,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71283
71482
  if (!currentCliPath) return null;
71284
71483
  let resolvedPath = currentCliPath;
71285
71484
  try {
71286
- resolvedPath = fs23.realpathSync.native(currentCliPath);
71485
+ resolvedPath = fs24.realpathSync.native(currentCliPath);
71287
71486
  } catch {
71288
71487
  }
71289
71488
  let currentDir = resolvedPath;
71290
71489
  try {
71291
- if (fs23.statSync(resolvedPath).isFile()) {
71490
+ if (fs24.statSync(resolvedPath).isFile()) {
71292
71491
  currentDir = path35.dirname(resolvedPath);
71293
71492
  }
71294
71493
  } catch {
@@ -71297,8 +71496,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71297
71496
  while (true) {
71298
71497
  const packageJsonPath = path35.join(currentDir, "package.json");
71299
71498
  try {
71300
- if (fs23.existsSync(packageJsonPath)) {
71301
- const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
71499
+ if (fs24.existsSync(packageJsonPath)) {
71500
+ const parsed = JSON.parse(fs24.readFileSync(packageJsonPath, "utf8"));
71302
71501
  if (parsed?.name === packageName) {
71303
71502
  const normalized = currentDir.replace(/\\/g, "/");
71304
71503
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -71447,8 +71646,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71447
71646
  function stopSessionHostProcesses(appName) {
71448
71647
  const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
71449
71648
  try {
71450
- if (fs23.existsSync(pidFile)) {
71451
- const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
71649
+ if (fs24.existsSync(pidFile)) {
71650
+ const pid = Number.parseInt(fs24.readFileSync(pidFile, "utf8").trim(), 10);
71452
71651
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
71453
71652
  killPid2(pid);
71454
71653
  }
@@ -71456,7 +71655,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71456
71655
  } catch {
71457
71656
  } finally {
71458
71657
  try {
71459
- fs23.unlinkSync(pidFile);
71658
+ fs24.unlinkSync(pidFile);
71460
71659
  } catch {
71461
71660
  }
71462
71661
  }
@@ -71464,7 +71663,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71464
71663
  function removeDaemonPidFile() {
71465
71664
  const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
71466
71665
  try {
71467
- fs23.unlinkSync(pidFile);
71666
+ fs24.unlinkSync(pidFile);
71468
71667
  } catch {
71469
71668
  }
71470
71669
  }
@@ -71482,23 +71681,23 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71482
71681
  if (pkgName.startsWith("@")) {
71483
71682
  const [scope, name] = pkgName.split("/");
71484
71683
  const scopeDir = path35.join(npmRoot, scope);
71485
- if (!fs23.existsSync(scopeDir)) return;
71486
- for (const entry of fs23.readdirSync(scopeDir)) {
71684
+ if (!fs24.existsSync(scopeDir)) return;
71685
+ for (const entry of fs24.readdirSync(scopeDir)) {
71487
71686
  if (!entry.startsWith(`.${name}-`)) continue;
71488
- fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
71687
+ fs24.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
71489
71688
  appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
71490
71689
  }
71491
71690
  } else {
71492
- for (const entry of fs23.readdirSync(npmRoot)) {
71691
+ for (const entry of fs24.readdirSync(npmRoot)) {
71493
71692
  if (!entry.startsWith(`.${pkgName}-`)) continue;
71494
- fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
71693
+ fs24.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
71495
71694
  appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
71496
71695
  }
71497
71696
  }
71498
- if (fs23.existsSync(binDir)) {
71499
- for (const entry of fs23.readdirSync(binDir)) {
71697
+ if (fs24.existsSync(binDir)) {
71698
+ for (const entry of fs24.readdirSync(binDir)) {
71500
71699
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
71501
- fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
71700
+ fs24.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
71502
71701
  appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
71503
71702
  }
71504
71703
  }
@@ -71587,7 +71786,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71587
71786
  init_repo_mesh_types();
71588
71787
  var import_os3 = require("os");
71589
71788
  var import_path11 = require("path");
71590
- var fs24 = __toESM2(require("fs"));
71789
+ var fs25 = __toESM2(require("fs"));
71591
71790
  var import_node_child_process6 = require("child_process");
71592
71791
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
71593
71792
  var CHANNEL_SERVER_URL = {
@@ -71913,6 +72112,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
71913
72112
  function readInlineMeshNodeId(node) {
71914
72113
  return normalizeMeshNodeId(node) ?? "";
71915
72114
  }
72115
+ function isDeadLocalWorktreeNode(node) {
72116
+ if (node?.isLocalWorktree !== true) return false;
72117
+ const workspace = readStringValue(node?.workspace);
72118
+ if (!workspace) return false;
72119
+ return !fs25.existsSync(workspace);
72120
+ }
71916
72121
  function foldMeshNodeIdentityToCanonical(node) {
71917
72122
  if (!node || typeof node !== "object" || Array.isArray(node)) return node;
71918
72123
  const canonical = normalizeMeshNodeId(node);
@@ -72159,7 +72364,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72159
72364
  const followUps = nodes.filter((node) => {
72160
72365
  if (readObjectRecord(node.branchConvergence).needsConvergence !== true) return false;
72161
72366
  const workspace = typeof node.workspace === "string" ? node.workspace : "";
72162
- if (workspace && !fs24.existsSync(workspace)) return false;
72367
+ if (workspace && !fs25.existsSync(workspace)) return false;
72163
72368
  return true;
72164
72369
  }).map((node) => {
72165
72370
  const convergence = readObjectRecord(node.branchConvergence);
@@ -72367,7 +72572,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72367
72572
  peerAttemptedCount: 0,
72368
72573
  peerConfirmedCount: 0,
72369
72574
  standingEvidenceCount: 0,
72370
- unavailableNodeIds: []
72575
+ unavailableNodeIds: [],
72576
+ deadNodeIds: []
72371
72577
  };
72372
72578
  }
72373
72579
  const selectedCoordinatorNodeId = readStringValue(
@@ -72380,6 +72586,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72380
72586
  let peerConfirmedCount = 0;
72381
72587
  let standingEvidenceCount = 0;
72382
72588
  const unavailableNodeIds = [];
72589
+ const deadNodeIds = [];
72383
72590
  for (const [nodeIndex, node] of nodes.entries()) {
72384
72591
  const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
72385
72592
  const workspace = readStringValue(node?.workspace);
@@ -72389,11 +72596,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72389
72596
  ) || Boolean(
72390
72597
  daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
72391
72598
  ) || Boolean(args.meshSource !== "local_config" && nodeIndex === 0);
72599
+ const isSelfDaemonNode = Boolean(
72600
+ daemonId && (daemonId === args.localMachineId || daemonId === args.statusInstanceId)
72601
+ );
72602
+ if ((isSelfNode || isSelfDaemonNode) && isDeadLocalWorktreeNode(node)) {
72603
+ deadNodeIds.push(nodeId);
72604
+ continue;
72605
+ }
72392
72606
  if (!workspace) {
72393
72607
  if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
72394
72608
  continue;
72395
72609
  }
72396
- if (fs24.existsSync(workspace)) {
72610
+ if (fs25.existsSync(workspace)) {
72397
72611
  try {
72398
72612
  const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
72399
72613
  if (localGit?.isGitRepo) {
@@ -72439,7 +72653,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72439
72653
  peerAttemptedCount,
72440
72654
  peerConfirmedCount,
72441
72655
  standingEvidenceCount,
72442
- unavailableNodeIds
72656
+ unavailableNodeIds,
72657
+ deadNodeIds
72443
72658
  };
72444
72659
  }
72445
72660
  function summarizeMeshSessionRecord(record2) {
@@ -72498,7 +72713,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72498
72713
  }
72499
72714
  function collectLiveMeshSessionRecords(args) {
72500
72715
  const nodeWorkspace = readStringValue(args.node?.workspace);
72501
- const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs24.existsSync(nodeWorkspace);
72716
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs25.existsSync(nodeWorkspace);
72502
72717
  const matches = args.liveSessionRecords.filter((record2) => {
72503
72718
  const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
72504
72719
  if (recordNodeId && recordNodeId !== args.nodeId) return false;
@@ -72525,7 +72740,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72525
72740
  const workspace = readStringValue(node?.workspace);
72526
72741
  if (nodeId) liveNodeIds.add(nodeId);
72527
72742
  if (workspace) liveWorkspaces.add(workspace);
72528
- if (nodeId && node?.isLocalWorktree === true && workspace && !fs24.existsSync(workspace)) {
72743
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs25.existsSync(workspace)) {
72529
72744
  missingLocalWorktreeNodeIds.add(nodeId);
72530
72745
  }
72531
72746
  }
@@ -72885,7 +73100,7 @@ ${e?.stderr || ""}`
72885
73100
  if (!baseCommit || !branchCommit) return false;
72886
73101
  if (baseCommit === branchCommit) return true;
72887
73102
  try {
72888
- if (!fs24.existsSync(submoduleRepoPath)) return false;
73103
+ if (!fs25.existsSync(submoduleRepoPath)) return false;
72889
73104
  (0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
72890
73105
  (0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
72891
73106
  (0, import_node_child_process6.execFileSync)("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
@@ -73002,7 +73217,7 @@ ${e?.stderr || ""}`
73002
73217
  return newTree || void 0;
73003
73218
  } finally {
73004
73219
  try {
73005
- fs24.rmSync(tmpIndex, { force: true });
73220
+ fs25.rmSync(tmpIndex, { force: true });
73006
73221
  } catch {
73007
73222
  }
73008
73223
  }
@@ -73077,7 +73292,7 @@ ${e?.stderr || ""}`
73077
73292
  return newTree || void 0;
73078
73293
  } finally {
73079
73294
  try {
73080
- fs24.rmSync(tmpIndex, { force: true });
73295
+ fs25.rmSync(tmpIndex, { force: true });
73081
73296
  } catch {
73082
73297
  }
73083
73298
  }
@@ -73183,7 +73398,7 @@ ${e?.stderr || ""}`
73183
73398
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
73184
73399
  };
73185
73400
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
73186
- if (!fs24.existsSync(worktreeSubmodulePath)) return false;
73401
+ if (!fs25.existsSync(worktreeSubmodulePath)) return false;
73187
73402
  try {
73188
73403
  await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
73189
73404
  } catch {
@@ -73206,7 +73421,7 @@ ${e?.stderr || ""}`
73206
73421
  reachable: false
73207
73422
  };
73208
73423
  try {
73209
- if (!fs24.existsSync(submodulePath)) {
73424
+ if (!fs25.existsSync(submodulePath)) {
73210
73425
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
73211
73426
  entry.publishRequired = true;
73212
73427
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -73443,9 +73658,9 @@ ${e?.stderr || ""}`
73443
73658
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
73444
73659
  };
73445
73660
  const dependenciesLikelyMissing = (cwd) => {
73446
- if (!fs24.existsSync((0, import_path11.join)(cwd, "package.json"))) return false;
73447
- if (fs24.existsSync((0, import_path11.join)(cwd, "node_modules"))) return false;
73448
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs24.existsSync((0, import_path11.join)(cwd, lock)));
73661
+ if (!fs25.existsSync((0, import_path11.join)(cwd, "package.json"))) return false;
73662
+ if (fs25.existsSync((0, import_path11.join)(cwd, "node_modules"))) return false;
73663
+ 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
73664
  };
73450
73665
  if (runLegacyBootstrapCommands) {
73451
73666
  summary.bootstrap = { stage: "legacy" };
@@ -73547,9 +73762,9 @@ ${e?.stderr || ""}`
73547
73762
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
73548
73763
  const sourceHome = resolveHermesUserHome();
73549
73764
  const sourceConfigPath = (0, import_path11.join)(sourceHome, "config.yaml");
73550
- if (!fs24.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
73765
+ if (!fs25.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
73551
73766
  if ((0, import_path11.resolve)(sourceConfigPath) === (0, import_path11.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
73552
- const parsed = parseMeshCoordinatorMcpConfig(fs24.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
73767
+ const parsed = parseMeshCoordinatorMcpConfig(fs25.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
73553
73768
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
73554
73769
  return { config: baseConfig, sourceHome, sourceConfigPath };
73555
73770
  }
@@ -73586,9 +73801,9 @@ ${e?.stderr || ""}`
73586
73801
  for (const fileName of [".env", "auth.json"]) {
73587
73802
  const sourcePath = (0, import_path11.join)(sourceHome, fileName);
73588
73803
  const targetPath = (0, import_path11.join)(targetHome, fileName);
73589
- if (!fs24.existsSync(sourcePath)) continue;
73804
+ if (!fs25.existsSync(sourcePath)) continue;
73590
73805
  try {
73591
- fs24.copyFileSync(sourcePath, targetPath);
73806
+ fs25.copyFileSync(sourcePath, targetPath);
73592
73807
  } catch (error48) {
73593
73808
  LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
73594
73809
  }
@@ -73746,6 +73961,15 @@ ${e?.stderr || ""}`
73746
73961
  * Allows the MCP server to query mesh data via get_mesh even when
73747
73962
  * the mesh doesn't exist in the local meshes.json file. */
73748
73963
  inlineMeshCache = /* @__PURE__ */ new Map();
73964
+ /** Tombstones for inline mesh nodes removed via remove_mesh_node, keyed by
73965
+ * meshId → set of removed nodeIds. The dashboard keeps echoing the removed
73966
+ * node in the inlineMesh it attaches to every command; without a tombstone,
73967
+ * reconcileInlineMeshCache MERGEs it straight back (resurrection). A
73968
+ * tombstoned node is skipped during reconcile only while its workspace is
73969
+ * absent from disk — a genuine re-registration (same nodeId, workspace back
73970
+ * on disk) clears the tombstone and merges normally, preserving clone
73971
+ * worktree visibility and legitimate node re-creation. */
73972
+ removedInlineMeshNodeIds = /* @__PURE__ */ new Map();
73749
73973
  /** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
73750
73974
  aggregateMeshStatusCache = /* @__PURE__ */ new Map();
73751
73975
  /** Shared per-peer git_status probe dedup + recently-probed reuse gate.
@@ -73779,10 +74003,23 @@ ${e?.stderr || ""}`
73779
74003
  const unavailableNodeIds = /* @__PURE__ */ new Set();
73780
74004
  const sourceOfTruth = readObjectRecord(snapshot.sourceOfTruth);
73781
74005
  const directPeerTruth = readObjectRecord(sourceOfTruth.directPeerTruth);
74006
+ const deadNodeIds = /* @__PURE__ */ new Set();
74007
+ for (const node of mesh.nodes) {
74008
+ if (!isDeadLocalWorktreeNode(node)) continue;
74009
+ const deadId = readInlineMeshNodeId(node);
74010
+ if (deadId) deadNodeIds.add(deadId);
74011
+ }
74012
+ let droppedDeadUnavailable = false;
73782
74013
  for (const entry of Array.isArray(directPeerTruth.unavailableNodeIds) ? directPeerTruth.unavailableNodeIds : []) {
73783
74014
  const nodeId = readStringValue(entry);
73784
- if (nodeId) unavailableNodeIds.add(nodeId);
74015
+ if (!nodeId) continue;
74016
+ if (deadNodeIds.has(nodeId)) {
74017
+ droppedDeadUnavailable = true;
74018
+ continue;
74019
+ }
74020
+ unavailableNodeIds.add(nodeId);
73785
74021
  }
74022
+ if (droppedDeadUnavailable) changed = true;
73786
74023
  const nodes = snapshot.nodes.map((statusNode) => {
73787
74024
  const nodeId = normalizeMeshNodeId(statusNode);
73788
74025
  const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
@@ -73897,7 +74134,10 @@ ${e?.stderr || ""}`
73897
74134
  }
73898
74135
  warmInlineMeshCache(meshId, inlineMesh) {
73899
74136
  if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
73900
- const sanitizedInlineMesh = sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh));
74137
+ const sanitizedInlineMesh = this.applyInlineMeshNodeTombstones(
74138
+ meshId,
74139
+ sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
74140
+ );
73901
74141
  const cached22 = this.inlineMeshCache.get(meshId);
73902
74142
  if (cached22) {
73903
74143
  const merged = reconcileInlineMeshCache(cached22, sanitizedInlineMesh);
@@ -73913,7 +74153,10 @@ ${e?.stderr || ""}`
73913
74153
  const cached3 = this.getCachedInlineMesh(meshId);
73914
74154
  if (cached3) {
73915
74155
  if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
73916
- const merged = reconcileInlineMeshCache(cached3, inlineMesh);
74156
+ const merged = reconcileInlineMeshCache(
74157
+ cached3,
74158
+ this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
74159
+ );
73917
74160
  this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
73918
74161
  return { mesh: merged, inline: true, source: "inline_cache" };
73919
74162
  }
@@ -73964,12 +74207,49 @@ ${e?.stderr || ""}`
73964
74207
  if (!mesh || !Array.isArray(mesh.nodes)) return false;
73965
74208
  const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, nodeId));
73966
74209
  if (idx === -1) return false;
74210
+ const canonicalNodeId = readInlineMeshNodeId(mesh.nodes[idx]) || nodeId;
73967
74211
  mesh.nodes.splice(idx, 1);
73968
74212
  mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
73969
74213
  this.inlineMeshCache.set(meshId, mesh);
74214
+ this.tombstoneRemovedInlineMeshNode(meshId, canonicalNodeId);
74215
+ if (canonicalNodeId !== nodeId) this.tombstoneRemovedInlineMeshNode(meshId, nodeId);
73970
74216
  this.invalidateAggregateMeshStatus(meshId);
73971
74217
  return true;
73972
74218
  }
74219
+ tombstoneRemovedInlineMeshNode(meshId, nodeId) {
74220
+ if (!nodeId) return;
74221
+ let set2 = this.removedInlineMeshNodeIds.get(meshId);
74222
+ if (!set2) {
74223
+ set2 = /* @__PURE__ */ new Set();
74224
+ this.removedInlineMeshNodeIds.set(meshId, set2);
74225
+ }
74226
+ set2.add(nodeId);
74227
+ }
74228
+ /** Filter an incoming inline mesh against this mesh's tombstones before it is
74229
+ * reconciled into the cache. A tombstoned node is dropped only while its
74230
+ * workspace is still absent from disk; if the workspace is back (genuine
74231
+ * re-registration), the tombstone is cleared and the node merges normally. */
74232
+ applyInlineMeshNodeTombstones(meshId, incoming) {
74233
+ const tombstones = this.removedInlineMeshNodeIds.get(meshId);
74234
+ if (!tombstones?.size || !incoming || typeof incoming !== "object" || !Array.isArray(incoming.nodes)) {
74235
+ return incoming;
74236
+ }
74237
+ let dropped = false;
74238
+ const nodes = incoming.nodes.filter((node) => {
74239
+ const nodeId = readInlineMeshNodeId(node);
74240
+ if (!nodeId || !tombstones.has(nodeId)) return true;
74241
+ const workspace = readStringValue(node?.workspace);
74242
+ if (workspace && fs25.existsSync(workspace)) {
74243
+ tombstones.delete(nodeId);
74244
+ return true;
74245
+ }
74246
+ dropped = true;
74247
+ return false;
74248
+ });
74249
+ if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
74250
+ if (!dropped) return incoming;
74251
+ return { ...incoming, nodes };
74252
+ }
73973
74253
  normalizeMeshSessionCleanupMode(value) {
73974
74254
  return value === "stop" || value === "delete_stopped" || value === "stop_and_delete" || value === "preserve" ? value : "preserve";
73975
74255
  }
@@ -73992,13 +74272,13 @@ ${e?.stderr || ""}`
73992
74272
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
73993
74273
  };
73994
74274
  }
73995
- const worktreeExists = fs24.existsSync(workspace);
74275
+ const worktreeExists = fs25.existsSync(workspace);
73996
74276
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
73997
74277
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
73998
74278
  if (!worktreeExists) {
73999
74279
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
74000
74280
  }
74001
- if (!repoRoot || !fs24.existsSync(repoRoot)) {
74281
+ if (!repoRoot || !fs25.existsSync(repoRoot)) {
74002
74282
  return {
74003
74283
  success: false,
74004
74284
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -74018,7 +74298,7 @@ ${e?.stderr || ""}`
74018
74298
  const normalizePath = (value) => {
74019
74299
  const resolved = (0, import_path11.resolve)(value);
74020
74300
  try {
74021
- return fs24.realpathSync(resolved);
74301
+ return fs25.realpathSync(resolved);
74022
74302
  } catch {
74023
74303
  return resolved;
74024
74304
  }
@@ -74104,7 +74384,7 @@ ${e?.stderr || ""}`
74104
74384
  };
74105
74385
  } catch (deinitError) {
74106
74386
  try {
74107
- fs24.rmSync(workspace, { recursive: true, force: true });
74387
+ fs25.rmSync(workspace, { recursive: true, force: true });
74108
74388
  await execFileAsync4("git", ["worktree", "prune"], {
74109
74389
  cwd: repoRoot,
74110
74390
  encoding: "utf8",
@@ -75883,8 +76163,8 @@ ${hintLines.join("\n")}` : "",
75883
76163
  if (sinceTs > 0) {
75884
76164
  return { success: true, logs: [], totalBuffered: 0 };
75885
76165
  }
75886
- if (fs24.existsSync(LOG_PATH)) {
75887
- const content = fs24.readFileSync(LOG_PATH, "utf-8");
76166
+ if (fs25.existsSync(LOG_PATH)) {
76167
+ const content = fs25.readFileSync(LOG_PATH, "utf-8");
75888
76168
  const allLines = content.split("\n");
75889
76169
  const recent = allLines.slice(-count).join("\n");
75890
76170
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -76429,14 +76709,14 @@ ${hintLines.join("\n")}` : "",
76429
76709
  // Settings page in the dashboard reads/writes via these two
76430
76710
  // commands instead of going through fs from the browser.
76431
76711
  case "list_coordinator_prompts": {
76432
- const fs30 = await import("fs");
76712
+ const fs31 = await import("fs");
76433
76713
  const path41 = await import("path");
76434
76714
  const os30 = await import("os");
76435
76715
  const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
76436
76716
  const entries = {};
76437
76717
  try {
76438
- if (fs30.existsSync(dir)) {
76439
- for (const name of fs30.readdirSync(dir)) {
76718
+ if (fs31.existsSync(dir)) {
76719
+ for (const name of fs31.readdirSync(dir)) {
76440
76720
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
76441
76721
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
76442
76722
  const m = matchAppend || matchOverride;
@@ -76446,7 +76726,7 @@ ${hintLines.join("\n")}` : "",
76446
76726
  const full = path41.join(dir, name);
76447
76727
  let content = "";
76448
76728
  try {
76449
- content = fs30.readFileSync(full, "utf8");
76729
+ content = fs31.readFileSync(full, "utf8");
76450
76730
  } catch {
76451
76731
  }
76452
76732
  if (!entries[key]) entries[key] = { override: "", append: "" };
@@ -76460,7 +76740,7 @@ ${hintLines.join("\n")}` : "",
76460
76740
  return { success: true, dir, entries };
76461
76741
  }
76462
76742
  case "write_coordinator_prompt": {
76463
- const fs30 = await import("fs");
76743
+ const fs31 = await import("fs");
76464
76744
  const path41 = await import("path");
76465
76745
  const os30 = await import("os");
76466
76746
  const key = typeof args?.key === "string" ? args.key.trim() : "";
@@ -76473,11 +76753,11 @@ ${hintLines.join("\n")}` : "",
76473
76753
  const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
76474
76754
  const full = path41.join(dir, filename);
76475
76755
  try {
76476
- fs30.mkdirSync(dir, { recursive: true });
76756
+ fs31.mkdirSync(dir, { recursive: true });
76477
76757
  if (content.trim()) {
76478
- fs30.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
76479
- } else if (fs30.existsSync(full)) {
76480
- fs30.unlinkSync(full);
76758
+ fs31.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
76759
+ } else if (fs31.existsSync(full)) {
76760
+ fs31.unlinkSync(full);
76481
76761
  }
76482
76762
  return { success: true, path: full, kind, key };
76483
76763
  } catch (error48) {
@@ -77255,6 +77535,55 @@ ${hintLines.join("\n")}` : "",
77255
77535
  });
77256
77536
  return result;
77257
77537
  }
77538
+ case "get_mesh_node_logs": {
77539
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
77540
+ const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
77541
+ let nodeDaemonId;
77542
+ if (meshId && nodeId) {
77543
+ const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
77544
+ const node = meshRecord?.mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
77545
+ nodeDaemonId = typeof node?.daemonId === "string" ? node.daemonId.trim() : void 0;
77546
+ }
77547
+ const selfDaemonId = this.deps.statusInstanceId;
77548
+ const isRemote = nodeDaemonId && selfDaemonId && nodeDaemonId !== selfDaemonId;
77549
+ if (isRemote && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
77550
+ const forwarded = await this.deps.dispatchMeshCommand(nodeDaemonId, "get_mesh_node_logs", {
77551
+ ...typeof args === "object" && args !== null ? args : {},
77552
+ _meshDirectDispatch: true
77553
+ });
77554
+ return forwarded ?? { success: false, error: "no response from remote node" };
77555
+ }
77556
+ const rawTailBytes = Number(args?.tailBytes);
77557
+ const tail = readDaemonLogTail({
77558
+ date: typeof args?.date === "string" ? args.date : void 0,
77559
+ tailBytes: Number.isFinite(rawTailBytes) ? Math.min(rawTailBytes, MAX_TAIL_BYTES) : void 0,
77560
+ grep: typeof args?.grep === "string" ? args.grep : void 0,
77561
+ sinceMs: Number.isFinite(Number(args?.sinceMs)) ? Number(args?.sinceMs) : void 0
77562
+ });
77563
+ if (!tail.success) {
77564
+ return {
77565
+ success: false,
77566
+ error: tail.error || "failed to read daemon log tail",
77567
+ nodeId,
77568
+ logPath: tail.logPath,
77569
+ platform: tail.platform
77570
+ };
77571
+ }
77572
+ const redactedLines = redactLogLines(tail.lines);
77573
+ return {
77574
+ success: true,
77575
+ nodeId,
77576
+ daemonId: selfDaemonId,
77577
+ logPath: tail.logPath,
77578
+ platform: tail.platform,
77579
+ lines: redactedLines,
77580
+ lineCount: redactedLines.length,
77581
+ truncated: tail.truncated,
77582
+ filtered: tail.filtered,
77583
+ bytesReturned: tail.bytesReturned,
77584
+ ...tail.grep ? { grep: tail.grep } : {}
77585
+ };
77586
+ }
77258
77587
  case "refine_mesh_node": {
77259
77588
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
77260
77589
  const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
@@ -77922,15 +78251,15 @@ ${ptyResult.output.slice(-2e3)}`);
77922
78251
  }
77923
78252
  if (cliType === "codex-cli") {
77924
78253
  const repoMcpConfigPath = (0, import_path11.join)(workspace, ".mcp.json");
77925
- if (fs24.existsSync(repoMcpConfigPath)) {
78254
+ if (fs25.existsSync(repoMcpConfigPath)) {
77926
78255
  try {
77927
78256
  const repoMcpConfig = parseMeshCoordinatorMcpConfig(
77928
- fs24.readFileSync(repoMcpConfigPath, "utf-8"),
78257
+ fs25.readFileSync(repoMcpConfigPath, "utf-8"),
77929
78258
  "claude_mcp_json"
77930
78259
  );
77931
78260
  const existingServers2 = repoMcpConfig.mcpServers;
77932
78261
  if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
77933
- fs24.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
78262
+ fs25.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
77934
78263
  ...repoMcpConfig,
77935
78264
  mcpServers: {
77936
78265
  ...existingServers2,
@@ -78046,7 +78375,7 @@ ${ptyResult.output.slice(-2e3)}`);
78046
78375
  workspace
78047
78376
  };
78048
78377
  }
78049
- const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
78378
+ const { existsSync: existsSync44, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
78050
78379
  const { dirname: dirname14 } = await import("path");
78051
78380
  const mcpConfigPath = coordinatorSetup.configPath;
78052
78381
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -78089,7 +78418,7 @@ ${ptyResult.output.slice(-2e3)}`);
78089
78418
  if (hermesManualFallback) return returnManualFallback(message);
78090
78419
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
78091
78420
  }
78092
- const hadExistingMcpConfig = existsSync43(mcpConfigPath);
78421
+ const hadExistingMcpConfig = existsSync44(mcpConfigPath);
78093
78422
  let existingMcpConfig = hermesBaseConfig?.config || {};
78094
78423
  if (hermesBaseConfig) {
78095
78424
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
@@ -78266,7 +78595,8 @@ ${ptyResult.output.slice(-2e3)}`);
78266
78595
  peerAttemptedCount: 0,
78267
78596
  peerConfirmedCount: 0,
78268
78597
  standingEvidenceCount: 0,
78269
- unavailableNodeIds: []
78598
+ unavailableNodeIds: [],
78599
+ deadNodeIds: []
78270
78600
  };
78271
78601
  const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
78272
78602
  const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
@@ -78406,7 +78736,7 @@ ${ptyResult.output.slice(-2e3)}`);
78406
78736
  }
78407
78737
  }
78408
78738
  if (workspace) {
78409
- if (!fs24.existsSync(workspace)) {
78739
+ if (!fs25.existsSync(workspace)) {
78410
78740
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
78411
78741
  let remoteProbeApplied = false;
78412
78742
  if (inlineTransitGit) {
@@ -78497,7 +78827,7 @@ ${ptyResult.output.slice(-2e3)}`);
78497
78827
  const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
78498
78828
  const unroutableDeliveries = getRecentUnroutableDeliveries();
78499
78829
  const previewFreshness = (() => {
78500
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs24.existsSync(candidate));
78830
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs25.existsSync(candidate));
78501
78831
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
78502
78832
  })();
78503
78833
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -78592,7 +78922,7 @@ ${ptyResult.output.slice(-2e3)}`);
78592
78922
  const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
78593
78923
  const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
78594
78924
  const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
78595
- const { existsSync: existsSync43 } = await import("fs");
78925
+ const { existsSync: existsSync44 } = await import("fs");
78596
78926
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
78597
78927
  const mesh = meshRecord?.mesh;
78598
78928
  if (!mesh) return { success: false, error: "Mesh not found" };
@@ -78611,7 +78941,7 @@ ${ptyResult.output.slice(-2e3)}`);
78611
78941
  const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
78612
78942
  for (const item of derivation.items) {
78613
78943
  const workspace = item.workspace;
78614
- if (!workspace || !existsSync43(workspace)) continue;
78944
+ if (!workspace || !existsSync44(workspace)) continue;
78615
78945
  const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
78616
78946
  try {
78617
78947
  const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
@@ -80335,7 +80665,7 @@ ${ptyResult.output.slice(-2e3)}`);
80335
80665
  this.eventListeners = [];
80336
80666
  }
80337
80667
  };
80338
- var fs25 = __toESM2(require("fs"));
80668
+ var fs26 = __toESM2(require("fs"));
80339
80669
  var path36 = __toESM2(require("path"));
80340
80670
  var os28 = __toESM2(require("os"));
80341
80671
  var import_os4 = require("os");
@@ -80349,8 +80679,8 @@ ${ptyResult.output.slice(-2e3)}`);
80349
80679
  }
80350
80680
  load() {
80351
80681
  try {
80352
- if (fs25.existsSync(ARCHIVE_PATH)) {
80353
- this.history = JSON.parse(fs25.readFileSync(ARCHIVE_PATH, "utf-8"));
80682
+ if (fs26.existsSync(ARCHIVE_PATH)) {
80683
+ this.history = JSON.parse(fs26.readFileSync(ARCHIVE_PATH, "utf-8"));
80354
80684
  }
80355
80685
  } catch {
80356
80686
  this.history = {};
@@ -80387,8 +80717,8 @@ ${ptyResult.output.slice(-2e3)}`);
80387
80717
  }
80388
80718
  save() {
80389
80719
  try {
80390
- fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
80391
- fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
80720
+ fs26.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
80721
+ fs26.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
80392
80722
  } catch {
80393
80723
  }
80394
80724
  }
@@ -80413,8 +80743,8 @@ ${ptyResult.output.slice(-2e3)}`);
80413
80743
  for (const ext of exes) {
80414
80744
  const fullPath = path36.join(p, name + ext);
80415
80745
  try {
80416
- if (fs25.existsSync(fullPath)) {
80417
- const stat2 = fs25.statSync(fullPath);
80746
+ if (fs26.existsSync(fullPath)) {
80747
+ const stat2 = fs26.statSync(fullPath);
80418
80748
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
80419
80749
  return fullPath;
80420
80750
  }
@@ -80461,9 +80791,9 @@ ${ptyResult.output.slice(-2e3)}`);
80461
80791
  if (p.includes("*")) {
80462
80792
  const home = os28.homedir();
80463
80793
  const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
80464
- if (fs25.existsSync(resolved)) return resolved;
80794
+ if (fs26.existsSync(resolved)) return resolved;
80465
80795
  } else {
80466
- if (fs25.existsSync(p)) return p;
80796
+ if (fs26.existsSync(p)) return p;
80467
80797
  }
80468
80798
  }
80469
80799
  return null;
@@ -80471,7 +80801,7 @@ ${ptyResult.output.slice(-2e3)}`);
80471
80801
  async function getMacAppVersion(appPath) {
80472
80802
  if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
80473
80803
  const plistPath = path36.join(appPath, "Contents", "Info.plist");
80474
- if (!fs25.existsSync(plistPath)) return null;
80804
+ if (!fs26.existsSync(plistPath)) return null;
80475
80805
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
80476
80806
  return raw || null;
80477
80807
  }
@@ -80497,7 +80827,7 @@ ${ptyResult.output.slice(-2e3)}`);
80497
80827
  let resolvedBin = cliBin;
80498
80828
  if (!resolvedBin && appPath && currentOs === "darwin") {
80499
80829
  const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
80500
- if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
80830
+ if (provider.cli && fs26.existsSync(bundled)) resolvedBin = bundled;
80501
80831
  }
80502
80832
  info.installed = !!(appPath || resolvedBin);
80503
80833
  info.path = appPath || null;
@@ -80534,7 +80864,7 @@ ${ptyResult.output.slice(-2e3)}`);
80534
80864
  return results;
80535
80865
  }
80536
80866
  var http2 = __toESM2(require("http"));
80537
- var fs29 = __toESM2(require("fs"));
80867
+ var fs30 = __toESM2(require("fs"));
80538
80868
  var path40 = __toESM2(require("path"));
80539
80869
  init_config();
80540
80870
  function generateFiles(type, name, category, opts = {}) {
@@ -80879,7 +81209,7 @@ async (params) => {
80879
81209
  };
80880
81210
  }
80881
81211
  init_logger();
80882
- var fs26 = __toESM2(require("fs"));
81212
+ var fs27 = __toESM2(require("fs"));
80883
81213
  var path37 = __toESM2(require("path"));
80884
81214
  init_logger();
80885
81215
  async function handleCdpEvaluate(ctx, req, res) {
@@ -81060,17 +81390,17 @@ async (params) => {
81060
81390
  }
81061
81391
  let scriptsPath = "";
81062
81392
  const directScripts = path37.join(dir, "scripts.js");
81063
- if (fs26.existsSync(directScripts)) {
81393
+ if (fs27.existsSync(directScripts)) {
81064
81394
  scriptsPath = directScripts;
81065
81395
  } else {
81066
81396
  const scriptsDir = path37.join(dir, "scripts");
81067
- if (fs26.existsSync(scriptsDir)) {
81068
- const versions = fs26.readdirSync(scriptsDir).filter((d) => {
81069
- return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
81397
+ if (fs27.existsSync(scriptsDir)) {
81398
+ const versions = fs27.readdirSync(scriptsDir).filter((d) => {
81399
+ return fs27.statSync(path37.join(scriptsDir, d)).isDirectory();
81070
81400
  }).sort().reverse();
81071
81401
  for (const ver of versions) {
81072
81402
  const p = path37.join(scriptsDir, ver, "scripts.js");
81073
- if (fs26.existsSync(p)) {
81403
+ if (fs27.existsSync(p)) {
81074
81404
  scriptsPath = p;
81075
81405
  break;
81076
81406
  }
@@ -81082,7 +81412,7 @@ async (params) => {
81082
81412
  return;
81083
81413
  }
81084
81414
  try {
81085
- const source = fs26.readFileSync(scriptsPath, "utf-8");
81415
+ const source = fs27.readFileSync(scriptsPath, "utf-8");
81086
81416
  const hints = {};
81087
81417
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
81088
81418
  let match;
@@ -81895,7 +82225,7 @@ async (params) => {
81895
82225
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
81896
82226
  }
81897
82227
  }
81898
- var fs27 = __toESM2(require("fs"));
82228
+ var fs28 = __toESM2(require("fs"));
81899
82229
  var path38 = __toESM2(require("path"));
81900
82230
  function slugifyFixtureName(value) {
81901
82231
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -81911,10 +82241,10 @@ async (params) => {
81911
82241
  function readCliFixture(ctx, type, name) {
81912
82242
  const fixtureDir = getCliFixtureDir(ctx, type);
81913
82243
  const filePath = path38.join(fixtureDir, `${name}.json`);
81914
- if (!fs27.existsSync(filePath)) {
82244
+ if (!fs28.existsSync(filePath)) {
81915
82245
  throw new Error(`Fixture not found: ${filePath}`);
81916
82246
  }
81917
- return JSON.parse(fs27.readFileSync(filePath, "utf-8"));
82247
+ return JSON.parse(fs28.readFileSync(filePath, "utf-8"));
81918
82248
  }
81919
82249
  function getExerciseTranscriptText(result) {
81920
82250
  const parts = [];
@@ -82659,7 +82989,7 @@ async (params) => {
82659
82989
  return;
82660
82990
  }
82661
82991
  const fixtureDir = getCliFixtureDir(ctx, type);
82662
- fs27.mkdirSync(fixtureDir, { recursive: true });
82992
+ fs28.mkdirSync(fixtureDir, { recursive: true });
82663
82993
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
82664
82994
  const result = await runCliExerciseInternal(ctx, { ...request, type });
82665
82995
  const fixture = {
@@ -82687,7 +83017,7 @@ async (params) => {
82687
83017
  notes: typeof body?.notes === "string" ? body.notes : void 0
82688
83018
  };
82689
83019
  const filePath = path38.join(fixtureDir, `${name}.json`);
82690
- fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
83020
+ fs28.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
82691
83021
  ctx.json(res, 200, {
82692
83022
  saved: true,
82693
83023
  name,
@@ -82705,14 +83035,14 @@ async (params) => {
82705
83035
  async function handleCliFixtureList(ctx, type, _req, res) {
82706
83036
  try {
82707
83037
  const fixtureDir = getCliFixtureDir(ctx, type);
82708
- if (!fs27.existsSync(fixtureDir)) {
83038
+ if (!fs28.existsSync(fixtureDir)) {
82709
83039
  ctx.json(res, 200, { fixtures: [], count: 0 });
82710
83040
  return;
82711
83041
  }
82712
- const fixtures = fs27.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
83042
+ 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
83043
  const fullPath = path38.join(fixtureDir, file2);
82714
83044
  try {
82715
- const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
83045
+ const raw = JSON.parse(fs28.readFileSync(fullPath, "utf-8"));
82716
83046
  return {
82717
83047
  name: raw.name || file2.replace(/\.json$/i, ""),
82718
83048
  path: fullPath,
@@ -82843,7 +83173,7 @@ async (params) => {
82843
83173
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
82844
83174
  }
82845
83175
  }
82846
- var fs28 = __toESM2(require("fs"));
83176
+ var fs29 = __toESM2(require("fs"));
82847
83177
  var path39 = __toESM2(require("path"));
82848
83178
  var os29 = __toESM2(require("os"));
82849
83179
  var import_session_host_core8 = require_dist();
@@ -82892,10 +83222,10 @@ async (params) => {
82892
83222
  return fallback?.type || null;
82893
83223
  }
82894
83224
  function getLatestScriptVersionDir(scriptsDir) {
82895
- if (!fs28.existsSync(scriptsDir)) return null;
82896
- const versions = fs28.readdirSync(scriptsDir).filter((d) => {
83225
+ if (!fs29.existsSync(scriptsDir)) return null;
83226
+ const versions = fs29.readdirSync(scriptsDir).filter((d) => {
82897
83227
  try {
82898
- return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
83228
+ return fs29.statSync(path39.join(scriptsDir, d)).isDirectory();
82899
83229
  } catch {
82900
83230
  return false;
82901
83231
  }
@@ -82917,13 +83247,13 @@ async (params) => {
82917
83247
  if (!sourceDir) {
82918
83248
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
82919
83249
  }
82920
- if (!fs28.existsSync(desiredDir)) {
82921
- fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
82922
- fs28.cpSync(sourceDir, desiredDir, { recursive: true });
83250
+ if (!fs29.existsSync(desiredDir)) {
83251
+ fs29.mkdirSync(path39.dirname(desiredDir), { recursive: true });
83252
+ fs29.cpSync(sourceDir, desiredDir, { recursive: true });
82923
83253
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
82924
83254
  }
82925
83255
  const providerJson = path39.join(desiredDir, "provider.json");
82926
- if (!fs28.existsSync(providerJson)) {
83256
+ if (!fs29.existsSync(providerJson)) {
82927
83257
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
82928
83258
  }
82929
83259
  return { dir: desiredDir };
@@ -82931,15 +83261,15 @@ async (params) => {
82931
83261
  function loadAutoImplReferenceScripts(ctx, referenceType) {
82932
83262
  if (!referenceType) return {};
82933
83263
  const refDir = ctx.findProviderDir(referenceType);
82934
- if (!refDir || !fs28.existsSync(refDir)) return {};
83264
+ if (!refDir || !fs29.existsSync(refDir)) return {};
82935
83265
  const referenceScripts = {};
82936
83266
  const scriptsDir = path39.join(refDir, "scripts");
82937
83267
  const latestDir = getLatestScriptVersionDir(scriptsDir);
82938
83268
  if (!latestDir) return referenceScripts;
82939
- for (const file2 of fs28.readdirSync(latestDir)) {
83269
+ for (const file2 of fs29.readdirSync(latestDir)) {
82940
83270
  if (!file2.endsWith(".js")) continue;
82941
83271
  try {
82942
- referenceScripts[file2] = fs28.readFileSync(path39.join(latestDir, file2), "utf-8");
83272
+ referenceScripts[file2] = fs29.readFileSync(path39.join(latestDir, file2), "utf-8");
82943
83273
  } catch {
82944
83274
  }
82945
83275
  }
@@ -83048,15 +83378,15 @@ async (params) => {
83048
83378
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
83049
83379
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
83050
83380
  const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
83051
- if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
83381
+ if (!fs29.existsSync(tmpDir)) fs29.mkdirSync(tmpDir, { recursive: true });
83052
83382
  const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
83053
- fs28.writeFileSync(promptFile, prompt, "utf-8");
83383
+ fs29.writeFileSync(promptFile, prompt, "utf-8");
83054
83384
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
83055
83385
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
83056
83386
  const spawn4 = agentProvider?.spawn;
83057
83387
  if (!spawn4?.command) {
83058
83388
  try {
83059
- fs28.unlinkSync(promptFile);
83389
+ fs29.unlinkSync(promptFile);
83060
83390
  } catch {
83061
83391
  }
83062
83392
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -83158,7 +83488,7 @@ async (params) => {
83158
83488
  } catch {
83159
83489
  }
83160
83490
  try {
83161
- fs28.unlinkSync(promptFile);
83491
+ fs29.unlinkSync(promptFile);
83162
83492
  } catch {
83163
83493
  }
83164
83494
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -83384,7 +83714,7 @@ async (params) => {
83384
83714
  }
83385
83715
  });
83386
83716
  try {
83387
- fs28.unlinkSync(promptFile);
83717
+ fs29.unlinkSync(promptFile);
83388
83718
  } catch {
83389
83719
  }
83390
83720
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -83489,10 +83819,10 @@ async (params) => {
83489
83819
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
83490
83820
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
83491
83821
  lines.push("");
83492
- for (const file2 of fs28.readdirSync(latestScriptsDir)) {
83822
+ for (const file2 of fs29.readdirSync(latestScriptsDir)) {
83493
83823
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
83494
83824
  try {
83495
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83825
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83496
83826
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
83497
83827
  lines.push("```javascript");
83498
83828
  lines.push(content);
@@ -83502,14 +83832,14 @@ async (params) => {
83502
83832
  }
83503
83833
  }
83504
83834
  }
83505
- const refFiles = fs28.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
83835
+ const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
83506
83836
  if (refFiles.length > 0) {
83507
83837
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
83508
83838
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
83509
83839
  lines.push("");
83510
83840
  for (const file2 of refFiles) {
83511
83841
  try {
83512
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83842
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83513
83843
  lines.push(`### \`${file2}\` \u{1F512}`);
83514
83844
  lines.push("```javascript");
83515
83845
  lines.push(content);
@@ -83554,7 +83884,7 @@ async (params) => {
83554
83884
  const loadGuide = (name) => {
83555
83885
  try {
83556
83886
  const p = path39.join(docsDir, name);
83557
- if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
83887
+ if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
83558
83888
  } catch {
83559
83889
  }
83560
83890
  return null;
@@ -83798,11 +84128,11 @@ async (params) => {
83798
84128
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
83799
84129
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
83800
84130
  lines.push("");
83801
- for (const file2 of fs28.readdirSync(latestScriptsDir)) {
84131
+ for (const file2 of fs29.readdirSync(latestScriptsDir)) {
83802
84132
  if (!file2.endsWith(".js")) continue;
83803
84133
  if (!targetFileNames.has(file2)) continue;
83804
84134
  try {
83805
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
84135
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83806
84136
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
83807
84137
  lines.push("```javascript");
83808
84138
  lines.push(content);
@@ -83811,14 +84141,14 @@ async (params) => {
83811
84141
  } catch {
83812
84142
  }
83813
84143
  }
83814
- const refFiles = fs28.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
84144
+ const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
83815
84145
  if (refFiles.length > 0) {
83816
84146
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
83817
84147
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
83818
84148
  lines.push("");
83819
84149
  for (const file2 of refFiles) {
83820
84150
  try {
83821
- const content = fs28.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
84151
+ const content = fs29.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
83822
84152
  lines.push(`### \`${file2}\` \u{1F512}`);
83823
84153
  lines.push("```javascript");
83824
84154
  lines.push(content);
@@ -83855,7 +84185,7 @@ async (params) => {
83855
84185
  const loadGuide = (name) => {
83856
84186
  try {
83857
84187
  const p = path39.join(docsDir, name);
83858
- if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
84188
+ if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
83859
84189
  } catch {
83860
84190
  }
83861
84191
  return null;
@@ -84593,7 +84923,7 @@ data: ${JSON.stringify(msg.data)}
84593
84923
  path40.join(process.cwd(), "packages/web-devconsole/dist")
84594
84924
  ];
84595
84925
  for (const dir of candidates) {
84596
- if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
84926
+ if (fs30.existsSync(path40.join(dir, "index.html"))) return dir;
84597
84927
  }
84598
84928
  return null;
84599
84929
  }
@@ -84605,7 +84935,7 @@ data: ${JSON.stringify(msg.data)}
84605
84935
  }
84606
84936
  const htmlPath = path40.join(distDir, "index.html");
84607
84937
  try {
84608
- const html = fs29.readFileSync(htmlPath, "utf-8");
84938
+ const html = fs30.readFileSync(htmlPath, "utf-8");
84609
84939
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
84610
84940
  res.end(html);
84611
84941
  } catch (e) {
@@ -84635,7 +84965,7 @@ data: ${JSON.stringify(msg.data)}
84635
84965
  return;
84636
84966
  }
84637
84967
  try {
84638
- const content = fs29.readFileSync(filePath);
84968
+ const content = fs30.readFileSync(filePath);
84639
84969
  const ext = path40.extname(filePath);
84640
84970
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
84641
84971
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
@@ -84744,14 +85074,14 @@ data: ${JSON.stringify(msg.data)}
84744
85074
  const files = [];
84745
85075
  const scan = (d, prefix) => {
84746
85076
  try {
84747
- for (const entry of fs29.readdirSync(d, { withFileTypes: true })) {
85077
+ for (const entry of fs30.readdirSync(d, { withFileTypes: true })) {
84748
85078
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
84749
85079
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
84750
85080
  if (entry.isDirectory()) {
84751
85081
  files.push({ path: rel, size: 0, type: "dir" });
84752
85082
  scan(path40.join(d, entry.name), rel);
84753
85083
  } else {
84754
- const stat2 = fs29.statSync(path40.join(d, entry.name));
85084
+ const stat2 = fs30.statSync(path40.join(d, entry.name));
84755
85085
  files.push({ path: rel, size: stat2.size, type: "file" });
84756
85086
  }
84757
85087
  }
@@ -84779,11 +85109,11 @@ data: ${JSON.stringify(msg.data)}
84779
85109
  this.json(res, 403, { error: "Forbidden" });
84780
85110
  return;
84781
85111
  }
84782
- if (!fs29.existsSync(fullPath) || fs29.statSync(fullPath).isDirectory()) {
85112
+ if (!fs30.existsSync(fullPath) || fs30.statSync(fullPath).isDirectory()) {
84783
85113
  this.json(res, 404, { error: `File not found: ${filePath}` });
84784
85114
  return;
84785
85115
  }
84786
- const content = fs29.readFileSync(fullPath, "utf-8");
85116
+ const content = fs30.readFileSync(fullPath, "utf-8");
84787
85117
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
84788
85118
  }
84789
85119
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -84805,9 +85135,9 @@ data: ${JSON.stringify(msg.data)}
84805
85135
  return;
84806
85136
  }
84807
85137
  try {
84808
- if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
84809
- fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
84810
- fs29.writeFileSync(fullPath, content, "utf-8");
85138
+ if (fs30.existsSync(fullPath)) fs30.copyFileSync(fullPath, fullPath + ".bak");
85139
+ fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
85140
+ fs30.writeFileSync(fullPath, content, "utf-8");
84811
85141
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
84812
85142
  this.providerLoader.reload();
84813
85143
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -84824,8 +85154,8 @@ data: ${JSON.stringify(msg.data)}
84824
85154
  }
84825
85155
  for (const name of ["scripts.js", "provider.json"]) {
84826
85156
  const p = path40.join(dir, name);
84827
- if (fs29.existsSync(p)) {
84828
- const source = fs29.readFileSync(p, "utf-8");
85157
+ if (fs30.existsSync(p)) {
85158
+ const source = fs30.readFileSync(p, "utf-8");
84829
85159
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
84830
85160
  return;
84831
85161
  }
@@ -84844,11 +85174,11 @@ data: ${JSON.stringify(msg.data)}
84844
85174
  this.json(res, 404, { error: `Provider not found: ${type}` });
84845
85175
  return;
84846
85176
  }
84847
- const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
85177
+ const target = fs30.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
84848
85178
  const targetPath = path40.join(dir, target);
84849
85179
  try {
84850
- if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
84851
- fs29.writeFileSync(targetPath, source, "utf-8");
85180
+ if (fs30.existsSync(targetPath)) fs30.copyFileSync(targetPath, targetPath + ".bak");
85181
+ fs30.writeFileSync(targetPath, source, "utf-8");
84852
85182
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
84853
85183
  this.providerLoader.reload();
84854
85184
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -84993,20 +85323,20 @@ data: ${JSON.stringify(msg.data)}
84993
85323
  let targetDir;
84994
85324
  targetDir = this.providerLoader.getUserProviderDir(category, type);
84995
85325
  const jsonPath = path40.join(targetDir, "provider.json");
84996
- if (fs29.existsSync(jsonPath)) {
85326
+ if (fs30.existsSync(jsonPath)) {
84997
85327
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
84998
85328
  return;
84999
85329
  }
85000
85330
  try {
85001
85331
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
85002
- fs29.mkdirSync(targetDir, { recursive: true });
85003
- fs29.writeFileSync(jsonPath, result["provider.json"], "utf-8");
85332
+ fs30.mkdirSync(targetDir, { recursive: true });
85333
+ fs30.writeFileSync(jsonPath, result["provider.json"], "utf-8");
85004
85334
  const createdFiles = ["provider.json"];
85005
85335
  if (result.files) {
85006
85336
  for (const [relPath, content] of Object.entries(result.files)) {
85007
85337
  const fullPath = path40.join(targetDir, relPath);
85008
- fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
85009
- fs29.writeFileSync(fullPath, content, "utf-8");
85338
+ fs30.mkdirSync(path40.dirname(fullPath), { recursive: true });
85339
+ fs30.writeFileSync(fullPath, content, "utf-8");
85010
85340
  createdFiles.push(relPath);
85011
85341
  }
85012
85342
  }
@@ -85055,10 +85385,10 @@ data: ${JSON.stringify(msg.data)}
85055
85385
  }
85056
85386
  // ─── Phase 2: Auto-Implement Backend ───
85057
85387
  getLatestScriptVersionDir(scriptsDir) {
85058
- if (!fs29.existsSync(scriptsDir)) return null;
85059
- const versions = fs29.readdirSync(scriptsDir).filter((d) => {
85388
+ if (!fs30.existsSync(scriptsDir)) return null;
85389
+ const versions = fs30.readdirSync(scriptsDir).filter((d) => {
85060
85390
  try {
85061
- return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
85391
+ return fs30.statSync(path40.join(scriptsDir, d)).isDirectory();
85062
85392
  } catch {
85063
85393
  return false;
85064
85394
  }
@@ -85080,13 +85410,13 @@ data: ${JSON.stringify(msg.data)}
85080
85410
  if (!sourceDir) {
85081
85411
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
85082
85412
  }
85083
- if (!fs29.existsSync(desiredDir)) {
85084
- fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
85085
- fs29.cpSync(sourceDir, desiredDir, { recursive: true });
85413
+ if (!fs30.existsSync(desiredDir)) {
85414
+ fs30.mkdirSync(path40.dirname(desiredDir), { recursive: true });
85415
+ fs30.cpSync(sourceDir, desiredDir, { recursive: true });
85086
85416
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
85087
85417
  }
85088
85418
  const providerJson = path40.join(desiredDir, "provider.json");
85089
- if (!fs29.existsSync(providerJson)) {
85419
+ if (!fs30.existsSync(providerJson)) {
85090
85420
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
85091
85421
  }
85092
85422
  return { dir: desiredDir };
@@ -85129,10 +85459,10 @@ data: ${JSON.stringify(msg.data)}
85129
85459
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
85130
85460
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
85131
85461
  lines.push("");
85132
- for (const file2 of fs29.readdirSync(latestScriptsDir)) {
85462
+ for (const file2 of fs30.readdirSync(latestScriptsDir)) {
85133
85463
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
85134
85464
  try {
85135
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85465
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85136
85466
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
85137
85467
  lines.push("```javascript");
85138
85468
  lines.push(content);
@@ -85142,14 +85472,14 @@ data: ${JSON.stringify(msg.data)}
85142
85472
  }
85143
85473
  }
85144
85474
  }
85145
- const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
85475
+ const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
85146
85476
  if (refFiles.length > 0) {
85147
85477
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
85148
85478
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
85149
85479
  lines.push("");
85150
85480
  for (const file2 of refFiles) {
85151
85481
  try {
85152
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85482
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85153
85483
  lines.push(`### \`${file2}\` \u{1F512}`);
85154
85484
  lines.push("```javascript");
85155
85485
  lines.push(content);
@@ -85194,7 +85524,7 @@ data: ${JSON.stringify(msg.data)}
85194
85524
  const loadGuide = (name) => {
85195
85525
  try {
85196
85526
  const p = path40.join(docsDir, name);
85197
- if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
85527
+ if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
85198
85528
  } catch {
85199
85529
  }
85200
85530
  return null;
@@ -85375,11 +85705,11 @@ data: ${JSON.stringify(msg.data)}
85375
85705
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
85376
85706
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
85377
85707
  lines.push("");
85378
- for (const file2 of fs29.readdirSync(latestScriptsDir)) {
85708
+ for (const file2 of fs30.readdirSync(latestScriptsDir)) {
85379
85709
  if (!file2.endsWith(".js")) continue;
85380
85710
  if (!targetFileNames.has(file2)) continue;
85381
85711
  try {
85382
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85712
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85383
85713
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
85384
85714
  lines.push("```javascript");
85385
85715
  lines.push(content);
@@ -85388,14 +85718,14 @@ data: ${JSON.stringify(msg.data)}
85388
85718
  } catch {
85389
85719
  }
85390
85720
  }
85391
- const refFiles = fs29.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
85721
+ const refFiles = fs30.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
85392
85722
  if (refFiles.length > 0) {
85393
85723
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
85394
85724
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
85395
85725
  lines.push("");
85396
85726
  for (const file2 of refFiles) {
85397
85727
  try {
85398
- const content = fs29.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85728
+ const content = fs30.readFileSync(path40.join(latestScriptsDir, file2), "utf-8");
85399
85729
  lines.push(`### \`${file2}\` \u{1F512}`);
85400
85730
  lines.push("```javascript");
85401
85731
  lines.push(content);
@@ -85432,7 +85762,7 @@ data: ${JSON.stringify(msg.data)}
85432
85762
  const loadGuide = (name) => {
85433
85763
  try {
85434
85764
  const p = path40.join(docsDir, name);
85435
- if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
85765
+ if (fs30.existsSync(p)) return fs30.readFileSync(p, "utf-8");
85436
85766
  } catch {
85437
85767
  }
85438
85768
  return null;
@@ -86519,8 +86849,8 @@ data: ${JSON.stringify(msg.data)}
86519
86849
  const res = await fetch(extension.vsixUrl);
86520
86850
  if (res.ok) {
86521
86851
  const buffer = Buffer.from(await res.arrayBuffer());
86522
- const fs30 = await import("fs");
86523
- fs30.writeFileSync(vsixPath, buffer);
86852
+ const fs31 = await import("fs");
86853
+ fs31.writeFileSync(vsixPath, buffer);
86524
86854
  return new Promise((resolve24) => {
86525
86855
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
86526
86856
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {