@adhdev/daemon-core 0.9.82-rc.301 → 0.9.82-rc.303

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.mjs CHANGED
@@ -77,6 +77,7 @@ var init_repo_mesh_types = __esm({
77
77
  // src/git/git-executor.ts
78
78
  var git_executor_exports = {};
79
79
  __export(git_executor_exports, {
80
+ GIT_STATUS_TIMEOUT_MS: () => GIT_STATUS_TIMEOUT_MS,
80
81
  GitCommandError: () => GitCommandError,
81
82
  isPathInside: () => isPathInside,
82
83
  normalizeGitOutput: () => normalizeGitOutput,
@@ -246,13 +247,14 @@ function mapExecError(error, cwd, argv, behavior) {
246
247
  cause: error
247
248
  });
248
249
  }
249
- var execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError;
250
+ var execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GIT_STATUS_TIMEOUT_MS, GitCommandError;
250
251
  var init_git_executor = __esm({
251
252
  "src/git/git-executor.ts"() {
252
253
  "use strict";
253
254
  execFileAsync = promisify(execFile);
254
255
  DEFAULT_TIMEOUT_MS = 5e3;
255
256
  DEFAULT_MAX_BUFFER = 1024 * 1024;
257
+ GIT_STATUS_TIMEOUT_MS = process.platform === "win32" ? 3e4 : 2e4;
256
258
  GitCommandError = class extends Error {
257
259
  reason;
258
260
  stdout;
@@ -288,10 +290,10 @@ function readInjected(value) {
288
290
  }
289
291
  function getDaemonBuildInfo() {
290
292
  if (cached) return cached;
291
- const commit = readInjected(true ? "72f1b6e675346bbc37de202b195675150ebb3d82" : void 0) ?? "unknown";
292
- const commitShort = readInjected(true ? "72f1b6e6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
293
- const version = readInjected(true ? "0.9.82-rc.301" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
294
- const builtAt = readInjected(true ? "2026-06-16T23:37:22.009Z" : void 0);
293
+ const commit = readInjected(true ? "21741b4b2d3c1f2ed8a280045e6158b2730391ed" : void 0) ?? "unknown";
294
+ const commitShort = readInjected(true ? "21741b4b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
295
+ const version = readInjected(true ? "0.9.82-rc.303" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
296
+ const builtAt = readInjected(true ? "2026-06-17T04:16:06.174Z" : void 0);
295
297
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
296
298
  return cached;
297
299
  }
@@ -303,64 +305,79 @@ var init_build_info = __esm({
303
305
  });
304
306
 
305
307
  // src/git/git-status.ts
308
+ function isTransientGitFailure(error) {
309
+ return error.reason === "timeout" || error.reason === "git_command_failed";
310
+ }
306
311
  async function getGitRepoStatus(workspace, options = {}) {
307
312
  const lastCheckedAt = Date.now();
308
313
  const includeSubmodules = options.includeSubmodules !== false;
314
+ const effectiveOptions = options.timeoutMs === void 0 ? { ...options, timeoutMs: GIT_STATUS_TIMEOUT_MS } : options;
309
315
  try {
310
- const repo = await resolveGitRepository(workspace, options);
311
- let parsed = await readPorcelainStatus(repo, options);
312
- let upstreamProbe = getInitialUpstreamProbe(parsed);
313
- if (options.refreshUpstream) {
314
- upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
315
- if (upstreamProbe.upstreamStatus === "fresh") {
316
- parsed = await readPorcelainStatus(repo, options);
317
- }
318
- }
319
- const head = await readHead(repo, options);
320
- const stashCount = await readStashCount(repo, options);
321
- let submodules;
322
- if (includeSubmodules) {
323
- submodules = await getSubmoduleStatuses(repo, options);
324
- }
325
- const submoduleDirty = (submodules || []).some((submodule) => submodule.dirty || submodule.outOfSync || !!submodule.error);
326
- const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0 || stashCount > 0 || submoduleDirty;
327
- const daemonBuildBehind = await detectDaemonBuildBehind(repo, submodules, options);
328
- return {
329
- workspace: repo.workspace,
330
- repoRoot: repo.repoRoot,
331
- isGitRepo: true,
332
- branch: parsed.branch,
333
- headCommit: head.commit,
334
- headMessage: head.message,
335
- upstream: parsed.upstream,
336
- upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
337
- upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
338
- upstreamFetchError: upstreamProbe.upstreamFetchError,
339
- ahead: parsed.ahead,
340
- behind: parsed.behind,
341
- staged: parsed.staged,
342
- modified: parsed.modified,
343
- untracked: parsed.untracked,
344
- deleted: parsed.deleted,
345
- renamed: parsed.renamed,
346
- dirty,
347
- hasConflicts: parsed.conflictFiles.length > 0,
348
- conflictFiles: parsed.conflictFiles,
349
- stashCount,
350
- lastCheckedAt,
351
- submodules,
352
- ...daemonBuildBehind ? { daemonBuildBehind } : {}
353
- };
316
+ const repo = await resolveGitRepository(workspace, effectiveOptions);
317
+ const status = await collectGitRepoStatus(repo, includeSubmodules, lastCheckedAt, effectiveOptions);
318
+ lastKnownGoodStatus.set(workspace, status);
319
+ return status;
354
320
  } catch (error) {
355
- if (error instanceof GitCommandError) {
356
- return emptyStatus(workspace, lastCheckedAt, error);
321
+ const gitError = error instanceof GitCommandError ? error : new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error });
322
+ if (isTransientGitFailure(gitError)) {
323
+ const cached2 = lastKnownGoodStatus.get(workspace);
324
+ if (cached2) {
325
+ return {
326
+ ...cached2,
327
+ lastCheckedAt,
328
+ upstreamStatus: "unavailable",
329
+ error: gitError.stderr || gitError.message,
330
+ reason: gitError.reason
331
+ };
332
+ }
357
333
  }
358
- return emptyStatus(
359
- workspace,
360
- lastCheckedAt,
361
- new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error })
362
- );
334
+ return emptyStatus(workspace, lastCheckedAt, gitError);
335
+ }
336
+ }
337
+ async function collectGitRepoStatus(repo, includeSubmodules, lastCheckedAt, options) {
338
+ let parsed = await readPorcelainStatus(repo, options);
339
+ let upstreamProbe = getInitialUpstreamProbe(parsed);
340
+ if (options.refreshUpstream) {
341
+ upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
342
+ if (upstreamProbe.upstreamStatus === "fresh") {
343
+ parsed = await readPorcelainStatus(repo, options);
344
+ }
345
+ }
346
+ const head = await readHead(repo, options);
347
+ const stashCount = await readStashCount(repo, options);
348
+ let submodules;
349
+ if (includeSubmodules) {
350
+ submodules = await getSubmoduleStatuses(repo, options);
363
351
  }
352
+ const submoduleDirty = (submodules || []).some((submodule) => submodule.dirty || submodule.outOfSync || !!submodule.error);
353
+ const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0 || stashCount > 0 || submoduleDirty;
354
+ const daemonBuildBehind = await detectDaemonBuildBehind(repo, submodules, options);
355
+ return {
356
+ workspace: repo.workspace,
357
+ repoRoot: repo.repoRoot,
358
+ isGitRepo: true,
359
+ branch: parsed.branch,
360
+ headCommit: head.commit,
361
+ headMessage: head.message,
362
+ upstream: parsed.upstream,
363
+ upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
364
+ upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
365
+ upstreamFetchError: upstreamProbe.upstreamFetchError,
366
+ ahead: parsed.ahead,
367
+ behind: parsed.behind,
368
+ staged: parsed.staged,
369
+ modified: parsed.modified,
370
+ untracked: parsed.untracked,
371
+ deleted: parsed.deleted,
372
+ renamed: parsed.renamed,
373
+ dirty,
374
+ hasConflicts: parsed.conflictFiles.length > 0,
375
+ conflictFiles: parsed.conflictFiles,
376
+ stashCount,
377
+ lastCheckedAt,
378
+ submodules,
379
+ ...daemonBuildBehind ? { daemonBuildBehind } : {}
380
+ };
364
381
  }
365
382
  function isNonRuntimeRootFile(file) {
366
383
  const base = file.slice(file.lastIndexOf("/") + 1);
@@ -602,7 +619,7 @@ function emptyStatus(workspace, lastCheckedAt, error) {
602
619
  async function getSubmoduleStatuses(repo, options) {
603
620
  if (!repo.repoRoot) return [];
604
621
  try {
605
- const result = await runGit(repo, ["submodule", "status", "--recursive"], options);
622
+ const result = await runGit(repo, ["submodule", "status"], options);
606
623
  const submodules = parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
607
624
  await Promise.all(submodules.map((submodule) => enrichSubmoduleWorktreeStatus(repo, submodule, options)));
608
625
  return submodules;
@@ -633,12 +650,12 @@ function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
633
650
  if (!match) continue;
634
651
  const prefix = match[1];
635
652
  const commit = match[2];
636
- const path40 = match[3];
637
- if (ignoreSet.has(path40)) continue;
653
+ const path41 = match[3];
654
+ if (ignoreSet.has(path41)) continue;
638
655
  submodules.push({
639
- path: path40,
656
+ path: path41,
640
657
  commit,
641
- repoPath: repoRoot + "/" + path40,
658
+ repoPath: repoRoot + "/" + path41,
642
659
  dirty: prefix === "U",
643
660
  outOfSync: prefix === "-" || prefix === "+",
644
661
  lastCheckedAt: Date.now()
@@ -646,12 +663,13 @@ function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
646
663
  }
647
664
  return submodules;
648
665
  }
649
- var DAEMON_RUNTIME_PACKAGES, WEB_ONLY_PACKAGES;
666
+ var lastKnownGoodStatus, DAEMON_RUNTIME_PACKAGES, WEB_ONLY_PACKAGES;
650
667
  var init_git_status = __esm({
651
668
  "src/git/git-status.ts"() {
652
669
  "use strict";
653
670
  init_git_executor();
654
671
  init_build_info();
672
+ lastKnownGoodStatus = /* @__PURE__ */ new Map();
655
673
  DAEMON_RUNTIME_PACKAGES = /* @__PURE__ */ new Set([
656
674
  "daemon-core",
657
675
  "daemon-standalone",
@@ -1463,10 +1481,10 @@ function getMeshConfigPath() {
1463
1481
  return join4(getConfigDir(), "meshes.json");
1464
1482
  }
1465
1483
  function loadMeshConfig() {
1466
- const path40 = getMeshConfigPath();
1467
- if (!existsSync4(path40)) return { meshes: [] };
1484
+ const path41 = getMeshConfigPath();
1485
+ if (!existsSync4(path41)) return { meshes: [] };
1468
1486
  try {
1469
- const raw = JSON.parse(readFileSync2(path40, "utf-8"));
1487
+ const raw = JSON.parse(readFileSync2(path41, "utf-8"));
1470
1488
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
1471
1489
  return raw;
1472
1490
  } catch {
@@ -1484,16 +1502,16 @@ function normalizeCapabilityTags(value) {
1484
1502
  return tags.length ? tags : void 0;
1485
1503
  }
1486
1504
  function saveMeshConfig(config) {
1487
- const path40 = getMeshConfigPath();
1488
- writeFileSync2(path40, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
1505
+ const path41 = getMeshConfigPath();
1506
+ writeFileSync2(path41, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
1489
1507
  }
1490
1508
  function normalizeRepoIdentity(remoteUrl) {
1491
1509
  let identity = remoteUrl.trim();
1492
1510
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
1493
1511
  try {
1494
1512
  const url = new URL(identity);
1495
- const path40 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
1496
- return `${url.hostname}/${path40}`;
1513
+ const path41 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
1514
+ return `${url.hostname}/${path41}`;
1497
1515
  } catch {
1498
1516
  }
1499
1517
  }
@@ -2176,10 +2194,10 @@ function rotateArchiveFile(meshId, archivePath) {
2176
2194
  }
2177
2195
  }
2178
2196
  function readArchivedCounts(meshId) {
2179
- const path40 = getArchivedCountsPath(meshId);
2180
- if (!existsSync5(path40)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2197
+ const path41 = getArchivedCountsPath(meshId);
2198
+ if (!existsSync5(path41)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2181
2199
  try {
2182
- return JSON.parse(readFileSync4(path40, "utf-8"));
2200
+ return JSON.parse(readFileSync4(path41, "utf-8"));
2183
2201
  } catch {
2184
2202
  return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2185
2203
  }
@@ -3579,10 +3597,10 @@ var init_mesh_runtime_store = __esm({
3579
3597
  this.migratedMeshIds.add(meshId);
3580
3598
  const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
3581
3599
  if (count.count > 0) return;
3582
- const path40 = legacyQueuePath(meshId);
3583
- if (!existsSync6(path40)) return;
3600
+ const path41 = legacyQueuePath(meshId);
3601
+ if (!existsSync6(path41)) return;
3584
3602
  try {
3585
- const entries = JSON.parse(readFileSync5(path40, "utf-8"));
3603
+ const entries = JSON.parse(readFileSync5(path41, "utf-8"));
3586
3604
  if (!Array.isArray(entries)) return;
3587
3605
  const insert = this.db.prepare(`
3588
3606
  INSERT OR REPLACE INTO mesh_queue (
@@ -5340,8 +5358,8 @@ function resolveMeshCoordinatorSetup(options) {
5340
5358
  }
5341
5359
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
5342
5360
  if (mcpConfig.mode === "auto_import") {
5343
- const path40 = mcpConfig.path?.trim();
5344
- if (!path40) {
5361
+ const path41 = mcpConfig.path?.trim();
5362
+ if (!path41) {
5345
5363
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
5346
5364
  }
5347
5365
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -5361,7 +5379,7 @@ function resolveMeshCoordinatorSetup(options) {
5361
5379
  return {
5362
5380
  kind: "auto_import",
5363
5381
  serverName,
5364
- configPath: resolveMcpConfigPath(path40, workspace),
5382
+ configPath: resolveMcpConfigPath(path41, workspace),
5365
5383
  configFormat: mcpConfig.format,
5366
5384
  mcpServer
5367
5385
  };
@@ -6369,12 +6387,12 @@ function readGitSubmodules(value, parentRepoRoot) {
6369
6387
  if (!Array.isArray(value)) return void 0;
6370
6388
  const submodules = value.map((entry) => {
6371
6389
  const submodule = readRecord3(entry);
6372
- const path40 = readString5(submodule.path);
6390
+ const path41 = readString5(submodule.path);
6373
6391
  const commit = readString5(submodule.commit);
6374
- const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
6375
- if (!path40 || !commit) return null;
6392
+ const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path41);
6393
+ if (!path41 || !commit) return null;
6376
6394
  const result = {
6377
- path: path40,
6395
+ path: path41,
6378
6396
  commit,
6379
6397
  dirty: readBoolean(submodule.dirty) ?? false,
6380
6398
  outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
@@ -6776,10 +6794,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
6776
6794
  const primaryDaemonId = daemonIds[0];
6777
6795
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
6778
6796
  const events = [];
6779
- for (const path40 of paths) {
6780
- if (!existsSync12(path40)) continue;
6797
+ for (const path41 of paths) {
6798
+ if (!existsSync12(path41)) continue;
6781
6799
  try {
6782
- const raw = readFileSync10(path40, "utf-8");
6800
+ const raw = readFileSync10(path41, "utf-8");
6783
6801
  const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
6784
6802
  try {
6785
6803
  return [JSON.parse(line)];
@@ -6787,7 +6805,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
6787
6805
  return [];
6788
6806
  }
6789
6807
  });
6790
- const filtered = primaryDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
6808
+ const filtered = primaryDaemonId && path41 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
6791
6809
  events.push(...filtered);
6792
6810
  } catch {
6793
6811
  }
@@ -6852,13 +6870,13 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
6852
6870
  const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
6853
6871
  return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
6854
6872
  }
6855
- function trimPendingEventsIfNeeded(path40) {
6873
+ function trimPendingEventsIfNeeded(path41) {
6856
6874
  try {
6857
- if (!existsSync12(path40)) return;
6858
- if (statSync5(path40).size <= MAX_PENDING_EVENTS_BYTES) return;
6859
- const lines = readFileSync10(path40, "utf-8").split("\n").filter(Boolean);
6875
+ if (!existsSync12(path41)) return;
6876
+ if (statSync5(path41).size <= MAX_PENDING_EVENTS_BYTES) return;
6877
+ const lines = readFileSync10(path41, "utf-8").split("\n").filter(Boolean);
6860
6878
  if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
6861
- writeFileSync6(path40, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
6879
+ writeFileSync6(path41, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
6862
6880
  } catch {
6863
6881
  }
6864
6882
  }
@@ -6885,19 +6903,19 @@ function queuePendingMeshCoordinatorEvent(event) {
6885
6903
  });
6886
6904
  } catch {
6887
6905
  }
6888
- const path40 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
6889
- trimPendingEventsIfNeeded(path40);
6890
- appendFileSync2(path40, JSON.stringify(event) + "\n", "utf-8");
6906
+ const path41 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
6907
+ trimPendingEventsIfNeeded(path41);
6908
+ appendFileSync2(path41, JSON.stringify(event) + "\n", "utf-8");
6891
6909
  return true;
6892
6910
  } catch (e) {
6893
6911
  LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
6894
6912
  return false;
6895
6913
  }
6896
6914
  }
6897
- function atomicDrainFile(path40) {
6898
- const tmpPath = `${path40}.draining`;
6915
+ function atomicDrainFile(path41) {
6916
+ const tmpPath = `${path41}.draining`;
6899
6917
  try {
6900
- renameSync4(path40, tmpPath);
6918
+ renameSync4(path41, tmpPath);
6901
6919
  } catch {
6902
6920
  return null;
6903
6921
  }
@@ -6916,10 +6934,10 @@ function atomicDrainFile(path40) {
6916
6934
  return null;
6917
6935
  }
6918
6936
  }
6919
- function selectiveDrainFile(path40, predicate) {
6920
- const tmpPath = `${path40}.draining`;
6937
+ function selectiveDrainFile(path41, predicate) {
6938
+ const tmpPath = `${path41}.draining`;
6921
6939
  try {
6922
- renameSync4(path40, tmpPath);
6940
+ renameSync4(path41, tmpPath);
6923
6941
  } catch {
6924
6942
  return [];
6925
6943
  }
@@ -6951,12 +6969,12 @@ function selectiveDrainFile(path40, predicate) {
6951
6969
  }
6952
6970
  try {
6953
6971
  if (keptLines.length > 0) {
6954
- writeFileSync6(path40, keptLines.join("\n") + "\n", "utf-8");
6972
+ writeFileSync6(path41, keptLines.join("\n") + "\n", "utf-8");
6955
6973
  }
6956
6974
  unlinkSync2(tmpPath);
6957
6975
  } catch {
6958
6976
  try {
6959
- if (existsSync12(tmpPath) && !existsSync12(path40)) renameSync4(tmpPath, path40);
6977
+ if (existsSync12(tmpPath) && !existsSync12(path41)) renameSync4(tmpPath, path41);
6960
6978
  } catch {
6961
6979
  }
6962
6980
  return [];
@@ -6990,16 +7008,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
6990
7008
  } catch {
6991
7009
  }
6992
7010
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
6993
- for (const path40 of paths) {
6994
- const isSharedFile = !!primaryDaemonId && path40 === getPendingEventsPath(meshId);
7011
+ for (const path41 of paths) {
7012
+ const isSharedFile = !!primaryDaemonId && path41 === getPendingEventsPath(meshId);
6995
7013
  const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
6996
7014
  if (onlyEvents) {
6997
- for (const event of selectiveDrainFile(path40, (e) => targets(e) && matchesFilter(e.event))) {
7015
+ for (const event of selectiveDrainFile(path41, (e) => targets(e) && matchesFilter(e.event))) {
6998
7016
  pushUnique(event);
6999
7017
  }
7000
7018
  continue;
7001
7019
  }
7002
- const content = atomicDrainFile(path40);
7020
+ const content = atomicDrainFile(path41);
7003
7021
  if (!content) continue;
7004
7022
  const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
7005
7023
  try {
@@ -7049,9 +7067,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
7049
7067
  } catch {
7050
7068
  }
7051
7069
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
7052
- for (const path40 of paths) {
7053
- if (existsSync12(path40)) try {
7054
- unlinkSync2(path40);
7070
+ for (const path41 of paths) {
7071
+ if (existsSync12(path41)) try {
7072
+ unlinkSync2(path41);
7055
7073
  } catch {
7056
7074
  }
7057
7075
  }
@@ -10060,7 +10078,7 @@ function getCliValidator() {
10060
10078
  return _cliValidator;
10061
10079
  }
10062
10080
  function formatIssue(err) {
10063
- const path40 = err.instancePath || "";
10081
+ const path41 = err.instancePath || "";
10064
10082
  const params = err.params;
10065
10083
  let message = err.message || "validation failed";
10066
10084
  let allowed;
@@ -10078,7 +10096,7 @@ function formatIssue(err) {
10078
10096
  } else if (err.keyword === "type") {
10079
10097
  message = `must be ${params.type}`;
10080
10098
  }
10081
- return { path: path40, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
10099
+ return { path: path41, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
10082
10100
  }
10083
10101
  function validateCliProviderManifest(manifest) {
10084
10102
  const validator = getCliValidator();
@@ -10437,6 +10455,37 @@ var init_spawn_env = __esm({
10437
10455
  }
10438
10456
  });
10439
10457
 
10458
+ // src/cli-adapters/resolve-executable.ts
10459
+ import { execFileSync } from "child_process";
10460
+ import { existsSync as existsSync20 } from "fs";
10461
+ import * as path16 from "path";
10462
+ function resolveWin32Executable(command) {
10463
+ if (process.platform !== "win32") return command;
10464
+ const trimmed = (command || "").trim();
10465
+ if (!trimmed) return command;
10466
+ if (path16.isAbsolute(trimmed) && existsSync20(trimmed)) return trimmed;
10467
+ try {
10468
+ const out = execFileSync("where", [trimmed], {
10469
+ encoding: "utf8",
10470
+ windowsHide: true
10471
+ }).trim();
10472
+ if (out) {
10473
+ const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
10474
+ const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path16.extname(m).toLowerCase()));
10475
+ return direct || matches[0] || command;
10476
+ }
10477
+ } catch {
10478
+ }
10479
+ return command;
10480
+ }
10481
+ var DIRECT_EXEC_EXT;
10482
+ var init_resolve_executable = __esm({
10483
+ "src/cli-adapters/resolve-executable.ts"() {
10484
+ "use strict";
10485
+ DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
10486
+ }
10487
+ });
10488
+
10440
10489
  // src/cli-adapters/pty-transport.ts
10441
10490
  var pty_transport_exports = {};
10442
10491
  __export(pty_transport_exports, {
@@ -10458,6 +10507,7 @@ var init_pty_transport = __esm({
10458
10507
  "src/cli-adapters/pty-transport.ts"() {
10459
10508
  "use strict";
10460
10509
  init_spawn_env();
10510
+ init_resolve_executable();
10461
10511
  NodePtyRuntimeTransport = class {
10462
10512
  constructor(handle) {
10463
10513
  this.handle = handle;
@@ -10500,7 +10550,7 @@ var init_pty_transport = __esm({
10500
10550
  cwd = os11.homedir();
10501
10551
  }
10502
10552
  }
10503
- const handle = pty.spawn(command, args, {
10553
+ const handle = pty.spawn(resolveWin32Executable(command), args, {
10504
10554
  name: "xterm-256color",
10505
10555
  cols: options.cols,
10506
10556
  rows: options.rows,
@@ -10515,7 +10565,7 @@ var init_pty_transport = __esm({
10515
10565
 
10516
10566
  // src/cli-adapters/provider-cli-shared.ts
10517
10567
  import * as os12 from "os";
10518
- import * as path16 from "path";
10568
+ import * as path17 from "path";
10519
10569
  function stripAnsi(str) {
10520
10570
  return str.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
10521
10571
  }
@@ -10591,17 +10641,17 @@ function buildCliScreenSnapshot(text) {
10591
10641
  function findBinary(name) {
10592
10642
  const trimmed = String(name || "").trim();
10593
10643
  if (!trimmed) return trimmed;
10594
- const expanded = trimmed.startsWith("~") ? path16.join(os12.homedir(), trimmed.slice(1)) : trimmed;
10595
- if (path16.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
10596
- return path16.isAbsolute(expanded) ? expanded : path16.resolve(expanded);
10644
+ const expanded = trimmed.startsWith("~") ? path17.join(os12.homedir(), trimmed.slice(1)) : trimmed;
10645
+ if (path17.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
10646
+ return path17.isAbsolute(expanded) ? expanded : path17.resolve(expanded);
10597
10647
  }
10598
10648
  const isWin = os12.platform() === "win32";
10599
- const paths = (process.env.PATH || "").split(path16.delimiter);
10649
+ const paths = (process.env.PATH || "").split(path17.delimiter);
10600
10650
  const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
10601
10651
  for (const p of paths) {
10602
10652
  if (!p) continue;
10603
10653
  for (const ext of exes) {
10604
- const fullPath = path16.join(p, trimmed + ext);
10654
+ const fullPath = path17.join(p, trimmed + ext);
10605
10655
  try {
10606
10656
  const fs30 = __require("fs");
10607
10657
  if (fs30.existsSync(fullPath)) {
@@ -10617,7 +10667,7 @@ function findBinary(name) {
10617
10667
  return isWin ? `${trimmed}.cmd` : trimmed;
10618
10668
  }
10619
10669
  function isScriptBinary(binaryPath) {
10620
- if (!path16.isAbsolute(binaryPath)) return false;
10670
+ if (!path17.isAbsolute(binaryPath)) return false;
10621
10671
  try {
10622
10672
  const fs30 = __require("fs");
10623
10673
  const resolved = fs30.realpathSync(binaryPath);
@@ -10633,7 +10683,7 @@ function isScriptBinary(binaryPath) {
10633
10683
  }
10634
10684
  }
10635
10685
  function looksLikeMachOOrElf(filePath) {
10636
- if (!path16.isAbsolute(filePath)) return false;
10686
+ if (!path17.isAbsolute(filePath)) return false;
10637
10687
  try {
10638
10688
  const fs30 = __require("fs");
10639
10689
  const resolved = fs30.realpathSync(filePath);
@@ -12673,7 +12723,7 @@ var init_provider_cli_config = __esm({
12673
12723
 
12674
12724
  // src/cli-adapters/provider-cli-runtime.ts
12675
12725
  import * as os13 from "os";
12676
- import * as path17 from "path";
12726
+ import * as path18 from "path";
12677
12727
  import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS3, DEFAULT_SESSION_HOST_ROWS as DEFAULT_SESSION_HOST_ROWS3 } from "@adhdev/session-host-core";
12678
12728
  function resolveCliSpawnPlan(options) {
12679
12729
  const { provider, runtimeSettings, workingDir, extraArgs, extraEnv } = options;
@@ -12686,9 +12736,9 @@ function resolveCliSpawnPlan(options) {
12686
12736
  );
12687
12737
  let shellCmd;
12688
12738
  let shellArgs;
12689
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
12739
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
12690
12740
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
12691
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12741
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12692
12742
  const useShell = isWin ? useShellWin : useShellUnix;
12693
12743
  if (useShell) {
12694
12744
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -14951,40 +15001,40 @@ function validateFsmSpec(raw) {
14951
15001
  }
14952
15002
  return errs;
14953
15003
  }
14954
- function validateCondition(c, sectionIds, path40) {
15004
+ function validateCondition(c, sectionIds, path41) {
14955
15005
  const errs = [];
14956
15006
  const w = c;
14957
15007
  if ("all" in w) {
14958
- w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path40}.all[${i}]`)));
15008
+ w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.all[${i}]`)));
14959
15009
  return errs;
14960
15010
  }
14961
15011
  if ("any" in w) {
14962
- w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path40}.any[${i}]`)));
15012
+ w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.any[${i}]`)));
14963
15013
  return errs;
14964
15014
  }
14965
15015
  if ("not" in w) {
14966
- errs.push(...validateCondition(w.not, sectionIds, `${path40}.not`));
15016
+ errs.push(...validateCondition(w.not, sectionIds, `${path41}.not`));
14967
15017
  return errs;
14968
15018
  }
14969
15019
  if ("matches" in w) {
14970
- if (w.section && !sectionIds.has(w.section)) errs.push(`${path40}.section "${w.section}" unknown`);
15020
+ if (w.section && !sectionIds.has(w.section)) errs.push(`${path41}.section "${w.section}" unknown`);
14971
15021
  try {
14972
15022
  new RegExp(w.matches, w.flags ?? "i");
14973
15023
  } catch (e) {
14974
- errs.push(`${path40}.matches invalid regex: ${e.message}`);
15024
+ errs.push(`${path41}.matches invalid regex: ${e.message}`);
14975
15025
  }
14976
15026
  return errs;
14977
15027
  }
14978
15028
  if ("cursor_above" in w && "changed" in w) return errs;
14979
15029
  if ("elapsed_ms" in w) {
14980
- if (typeof w.elapsed_ms !== "number") errs.push(`${path40}.elapsed_ms must be a number`);
15030
+ if (typeof w.elapsed_ms !== "number") errs.push(`${path41}.elapsed_ms must be a number`);
14981
15031
  return errs;
14982
15032
  }
14983
15033
  if ("stable_ms" in w) {
14984
- if (typeof w.stable_ms !== "number") errs.push(`${path40}.stable_ms must be a number`);
15034
+ if (typeof w.stable_ms !== "number") errs.push(`${path41}.stable_ms must be a number`);
14985
15035
  return errs;
14986
15036
  }
14987
- errs.push(`${path40} is not a recognized condition`);
15037
+ errs.push(`${path41} is not a recognized condition`);
14988
15038
  return errs;
14989
15039
  }
14990
15040
  var init_fsm_loader = __esm({
@@ -15005,7 +15055,7 @@ __export(require_whitelist_exports, {
15005
15055
  registerProviderScriptRoot: () => registerProviderScriptRoot,
15006
15056
  unregisterProviderScriptRoot: () => unregisterProviderScriptRoot
15007
15057
  });
15008
- import * as path30 from "path";
15058
+ import * as path31 from "path";
15009
15059
  import { createRequire as createRequire3 } from "module";
15010
15060
  import * as nodeFs from "fs";
15011
15061
  import * as nodeChildProcess from "child_process";
@@ -15146,7 +15196,7 @@ function _getRegisteredRoots() {
15146
15196
  }
15147
15197
  function canonicalize(p) {
15148
15198
  try {
15149
- const resolved = path30.resolve(p);
15199
+ const resolved = path31.resolve(p);
15150
15200
  try {
15151
15201
  return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
15152
15202
  } catch {
@@ -15166,7 +15216,7 @@ function isCallerInsideGatedRoot(callerFilename) {
15166
15216
  }
15167
15217
  for (const root of _gatedRoots) {
15168
15218
  if (normalized === root.rootPath) return root;
15169
- if (normalized.startsWith(root.rootPath + path30.sep)) return root;
15219
+ if (normalized.startsWith(root.rootPath + path31.sep)) return root;
15170
15220
  }
15171
15221
  return null;
15172
15222
  }
@@ -15185,16 +15235,16 @@ function ensureInstalled() {
15185
15235
  };
15186
15236
  }
15187
15237
  function gatedRequire(request, parent, isMain, gated, originalLoad) {
15188
- if (request.startsWith("./") || request.startsWith("../") || path30.isAbsolute(request)) {
15238
+ if (request.startsWith("./") || request.startsWith("../") || path31.isAbsolute(request)) {
15189
15239
  let resolved;
15190
15240
  try {
15191
- const callerRequire = parent?.filename ? createRequire3(parent.filename) : createRequire3(path30.join(gated.rootPath, "__entry__.js"));
15241
+ const callerRequire = parent?.filename ? createRequire3(parent.filename) : createRequire3(path31.join(gated.rootPath, "__entry__.js"));
15192
15242
  resolved = callerRequire.resolve(request);
15193
15243
  } catch {
15194
15244
  return originalLoad.call(this, request, parent, isMain);
15195
15245
  }
15196
15246
  const resolvedCanon = canonicalize(resolved) || resolved;
15197
- if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path30.sep))) {
15247
+ if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path31.sep))) {
15198
15248
  denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
15199
15249
  }
15200
15250
  return originalLoad.call(this, request, parent, isMain);
@@ -17065,10 +17115,10 @@ function getRegistryPath() {
17065
17115
  return join10(getDaemonDataDir(), "mesh-coordinators.json");
17066
17116
  }
17067
17117
  function loadMeshCoordinatorRegistry() {
17068
- const path40 = getRegistryPath();
17069
- if (!existsSync9(path40)) return;
17118
+ const path41 = getRegistryPath();
17119
+ if (!existsSync9(path41)) return;
17070
17120
  try {
17071
- const raw = JSON.parse(readFileSync7(path40, "utf-8"));
17121
+ const raw = JSON.parse(readFileSync7(path41, "utf-8"));
17072
17122
  if (!Array.isArray(raw)) return;
17073
17123
  _registry.clear();
17074
17124
  for (const entry of raw) {
@@ -17306,8 +17356,8 @@ function validateMeshRefineConfig(config, source = "inline") {
17306
17356
  if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
17307
17357
  return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
17308
17358
  }
17309
- function parseConfigText(path40, text) {
17310
- if (/\.json$/i.test(path40)) return JSON.parse(text);
17359
+ function parseConfigText(path41, text) {
17360
+ if (/\.json$/i.test(path41)) return JSON.parse(text);
17311
17361
  return yaml.load(text);
17312
17362
  }
17313
17363
  function loadMeshRefineConfig(mesh, workspace) {
@@ -17465,8 +17515,8 @@ var MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA = {
17465
17515
  var DEFAULT_TIMEOUT_MS2 = 12e4;
17466
17516
  var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
17467
17517
  var OUTPUT_SUMMARY_CHARS = 2e3;
17468
- function parseConfigText2(path40, text) {
17469
- if (/\.json$/i.test(path40)) return JSON.parse(text);
17518
+ function parseConfigText2(path41, text) {
17519
+ if (/\.json$/i.test(path41)) return JSON.parse(text);
17470
17520
  return yaml2.load(text);
17471
17521
  }
17472
17522
  function truncateOutput(value) {
@@ -29194,8 +29244,8 @@ var DaemonCommandHandler = class {
29194
29244
  */
29195
29245
  getUpstreamInstallRoot() {
29196
29246
  const os30 = __require("os");
29197
- const path40 = __require("path");
29198
- return path40.join(os30.homedir(), ".adhdev", "providers", ".upstream");
29247
+ const path41 = __require("path");
29248
+ return path41.join(os30.homedir(), ".adhdev", "providers", ".upstream");
29199
29249
  }
29200
29250
  /**
29201
29251
  * Download a single provider manifest from the registry and write it to
@@ -29220,7 +29270,7 @@ var DaemonCommandHandler = class {
29220
29270
  }
29221
29271
  const https = __require("https");
29222
29272
  const fs30 = __require("fs");
29223
- const path40 = __require("path");
29273
+ const path41 = __require("path");
29224
29274
  const crypto6 = __require("crypto");
29225
29275
  const REGISTRY = "https://api.adhf.dev/api/v1/registry";
29226
29276
  function fetchText(url, timeoutMs) {
@@ -29258,9 +29308,9 @@ var DaemonCommandHandler = class {
29258
29308
  return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
29259
29309
  }
29260
29310
  const installRoot = this.getUpstreamInstallRoot();
29261
- const installRootResolved = path40.resolve(installRoot);
29262
- const targetDir = path40.resolve(path40.join(installRoot, category, type));
29263
- if (!targetDir.startsWith(installRootResolved + path40.sep)) {
29311
+ const installRootResolved = path41.resolve(installRoot);
29312
+ const targetDir = path41.resolve(path41.join(installRoot, category, type));
29313
+ if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29264
29314
  return { success: false, error: "install path escaped upstream root" };
29265
29315
  }
29266
29316
  fs30.mkdirSync(targetDir, { recursive: true });
@@ -29287,7 +29337,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29287
29337
  }
29288
29338
  }
29289
29339
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
29290
- const targetPath = path40.join(targetDir, targetFile);
29340
+ const targetPath = path41.join(targetDir, targetFile);
29291
29341
  fs30.writeFileSync(targetPath, manifestBody, "utf-8");
29292
29342
  const manifestJson = JSON.parse(manifestBody);
29293
29343
  const scriptFetch = await this.fetchProviderSources(
@@ -29359,7 +29409,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29359
29409
  const ref = source.ref;
29360
29410
  const https = __require("https");
29361
29411
  const fs30 = __require("fs");
29362
- const path40 = __require("path");
29412
+ const path41 = __require("path");
29363
29413
  function fetchJson(url, timeoutMs) {
29364
29414
  return new Promise((resolve24, reject) => {
29365
29415
  const req = https.get(url, {
@@ -29415,9 +29465,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29415
29465
  }
29416
29466
  let fetchedCount = 0;
29417
29467
  const sharedDirRel = `${category}/_shared`;
29418
- const sharedTargetDir = path40.resolve(path40.join(targetDir, "../_shared"));
29419
- const installRootResolved = path40.resolve(path40.join(targetDir, "../.."));
29420
- if (sharedTargetDir.startsWith(installRootResolved + path40.sep)) {
29468
+ const sharedTargetDir = path41.resolve(path41.join(targetDir, "../_shared"));
29469
+ const installRootResolved = path41.resolve(path41.join(targetDir, "../.."));
29470
+ if (sharedTargetDir.startsWith(installRootResolved + path41.sep)) {
29421
29471
  const sharedStack = [sharedDirRel];
29422
29472
  while (sharedStack.length) {
29423
29473
  const relDir = sharedStack.pop();
@@ -29440,9 +29490,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29440
29490
  try {
29441
29491
  const body = await fetchBinary(entry.download_url, 3e4);
29442
29492
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
29443
- const outPath = path40.resolve(path40.join(sharedTargetDir, relInside));
29444
- if (!outPath.startsWith(path40.resolve(sharedTargetDir) + path40.sep)) continue;
29445
- fs30.mkdirSync(path40.dirname(outPath), { recursive: true });
29493
+ const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
29494
+ if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
29495
+ fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29446
29496
  fs30.writeFileSync(outPath, body);
29447
29497
  fetchedCount++;
29448
29498
  } catch (e) {
@@ -29476,12 +29526,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29476
29526
  try {
29477
29527
  const body = await fetchBinary(entry.download_url, 3e4);
29478
29528
  const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
29479
- const outPath = path40.resolve(path40.join(targetDir, relInsideProvider));
29480
- if (!outPath.startsWith(path40.resolve(targetDir) + path40.sep)) {
29529
+ const outPath = path41.resolve(path41.join(targetDir, relInsideProvider));
29530
+ if (!outPath.startsWith(path41.resolve(targetDir) + path41.sep)) {
29481
29531
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
29482
29532
  continue;
29483
29533
  }
29484
- fs30.mkdirSync(path40.dirname(outPath), { recursive: true });
29534
+ fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29485
29535
  fs30.writeFileSync(outPath, body);
29486
29536
  fetchedCount++;
29487
29537
  } catch (e) {
@@ -29511,12 +29561,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29511
29561
  return { success: false, error: `unknown category: ${category}` };
29512
29562
  }
29513
29563
  const fs30 = __require("fs");
29514
- const path40 = __require("path");
29564
+ const path41 = __require("path");
29515
29565
  try {
29516
29566
  const installRoot = this.getUpstreamInstallRoot();
29517
- const installRootResolved = path40.resolve(installRoot);
29518
- const targetDir = path40.resolve(path40.join(installRoot, category, type));
29519
- if (!targetDir.startsWith(installRootResolved + path40.sep)) {
29567
+ const installRootResolved = path41.resolve(installRoot);
29568
+ const targetDir = path41.resolve(path41.join(installRoot, category, type));
29569
+ if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29520
29570
  return { success: false, error: "refusing to delete outside upstream root" };
29521
29571
  }
29522
29572
  if (!fs30.existsSync(targetDir)) {
@@ -29539,13 +29589,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29539
29589
  */
29540
29590
  handleListInstalledProviders(_args) {
29541
29591
  const fs30 = __require("fs");
29542
- const path40 = __require("path");
29592
+ const path41 = __require("path");
29543
29593
  const installRoot = this.getUpstreamInstallRoot();
29544
29594
  if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
29545
29595
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
29546
29596
  const items = [];
29547
29597
  for (const category of CATEGORIES) {
29548
- const categoryDir = path40.join(installRoot, category);
29598
+ const categoryDir = path41.join(installRoot, category);
29549
29599
  if (!fs30.existsSync(categoryDir)) continue;
29550
29600
  let entries;
29551
29601
  try {
@@ -29554,8 +29604,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29554
29604
  continue;
29555
29605
  }
29556
29606
  for (const type of entries) {
29557
- const v1Path = path40.join(categoryDir, type, "provider.v1.json");
29558
- const v0Path = path40.join(categoryDir, type, "provider.json");
29607
+ const v1Path = path41.join(categoryDir, type, "provider.v1.json");
29608
+ const v0Path = path41.join(categoryDir, type, "provider.json");
29559
29609
  const manifestPath = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
29560
29610
  if (!manifestPath) continue;
29561
29611
  try {
@@ -29671,7 +29721,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29671
29721
  return { success: false, error: "name must match @[a-z0-9_-]+" };
29672
29722
  }
29673
29723
  const fs30 = __require("fs");
29674
- const path40 = __require("path");
29724
+ const path41 = __require("path");
29675
29725
  const { spawnSync: spawnSync2 } = __require("child_process");
29676
29726
  const file = ext.loadExternalSources();
29677
29727
  if (file.sources.some((s) => s.name === requestedName)) {
@@ -29680,7 +29730,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29680
29730
  if (file.sources.some((s) => s.url === url && s.ref === ref)) {
29681
29731
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
29682
29732
  }
29683
- const sourceDir = path40.join(ext.externalRoot(), requestedName);
29733
+ const sourceDir = path41.join(ext.externalRoot(), requestedName);
29684
29734
  if (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
29685
29735
  if (fs30.existsSync(sourceDir)) {
29686
29736
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
@@ -29737,11 +29787,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29737
29787
  if (!name) return { success: false, error: "name is required" };
29738
29788
  const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
29739
29789
  const fs30 = __require("fs");
29740
- const path40 = __require("path");
29790
+ const path41 = __require("path");
29741
29791
  const file = ext.loadExternalSources();
29742
29792
  const match = file.sources.find((s) => s.name === name);
29743
29793
  if (!match) return { success: false, error: `source "${name}" not registered` };
29744
- const sourceDir = path40.join(ext.externalRoot(), name);
29794
+ const sourceDir = path41.join(ext.externalRoot(), name);
29745
29795
  if (fs30.existsSync(sourceDir)) {
29746
29796
  try {
29747
29797
  fs30.rmSync(sourceDir, { recursive: true, force: true });
@@ -29922,15 +29972,15 @@ init_provider_cli_adapter();
29922
29972
  init_cli_detector();
29923
29973
  init_config();
29924
29974
  import * as os19 from "os";
29925
- import * as path24 from "path";
29975
+ import * as path25 from "path";
29926
29976
  import * as crypto5 from "crypto";
29927
- import { existsSync as existsSync24, mkdirSync as mkdirSync12, writeFileSync as writeFileSync15 } from "fs";
29928
- import { execFileSync } from "child_process";
29977
+ import { existsSync as existsSync25, mkdirSync as mkdirSync12, writeFileSync as writeFileSync15 } from "fs";
29978
+ import { execFileSync as execFileSync2 } from "child_process";
29929
29979
  import chalk from "chalk";
29930
29980
 
29931
29981
  // src/providers/cli-provider-instance.ts
29932
29982
  import * as os18 from "os";
29933
- import * as path22 from "path";
29983
+ import * as path23 from "path";
29934
29984
  import * as crypto4 from "crypto";
29935
29985
  import * as fs15 from "fs";
29936
29986
  import { createRequire as createRequire2 } from "module";
@@ -29938,12 +29988,12 @@ import { createRequire as createRequire2 } from "module";
29938
29988
  // src/providers/spec/route.ts
29939
29989
  init_provider_cli_adapter();
29940
29990
  import * as fs14 from "fs";
29941
- import * as path21 from "path";
29991
+ import * as path22 from "path";
29942
29992
 
29943
29993
  // src/providers/spec/fsm-driver.ts
29944
29994
  import * as fs11 from "fs";
29945
29995
  import * as os16 from "os";
29946
- import * as path19 from "path";
29996
+ import * as path20 from "path";
29947
29997
 
29948
29998
  // src/providers/spec/adapter.ts
29949
29999
  init_terminal_screen();
@@ -30070,17 +30120,17 @@ import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS6, DEFAULT_SESSIO
30070
30120
  init_logger();
30071
30121
  import * as fs10 from "fs";
30072
30122
  import * as os15 from "os";
30073
- import * as path18 from "path";
30123
+ import * as path19 from "path";
30074
30124
  function expandHome2(p) {
30075
30125
  if (p === "~") return os15.homedir();
30076
- if (p.startsWith("~/")) return path18.join(os15.homedir(), p.slice(2));
30126
+ if (p.startsWith("~/")) return path19.join(os15.homedir(), p.slice(2));
30077
30127
  return p;
30078
30128
  }
30079
30129
  function realWorkspacePath(workingDir) {
30080
30130
  try {
30081
30131
  return fs10.realpathSync(workingDir);
30082
30132
  } catch {
30083
- return path18.resolve(workingDir);
30133
+ return path19.resolve(workingDir);
30084
30134
  }
30085
30135
  }
30086
30136
  function applyPreLaunchTrust(trust, workingDir) {
@@ -30106,7 +30156,7 @@ function applyPreLaunchTrust(trust, workingDir) {
30106
30156
  }
30107
30157
  list.push(real);
30108
30158
  parsed[key] = list;
30109
- fs10.mkdirSync(path18.dirname(settingsPath), { recursive: true });
30159
+ fs10.mkdirSync(path19.dirname(settingsPath), { recursive: true });
30110
30160
  fs10.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
30111
30161
  `, "utf8");
30112
30162
  LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
@@ -30355,8 +30405,8 @@ var FsmDriver = class {
30355
30405
  }
30356
30406
  armSpecWatcher() {
30357
30407
  try {
30358
- const dir = path19.dirname(this.opts.specPath);
30359
- const base = path19.basename(this.opts.specPath);
30408
+ const dir = path20.dirname(this.opts.specPath);
30409
+ const base = path20.basename(this.opts.specPath);
30360
30410
  this.specWatcher = fs11.watch(dir, { persistent: false }, (_event, filename) => {
30361
30411
  if (filename && filename !== base) return;
30362
30412
  const res = loadFsmSpec(this.opts.specPath);
@@ -30657,7 +30707,7 @@ var FsmDriver = class {
30657
30707
  const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
30658
30708
  if (!ctl || ctl.action.type !== "attach_image") return;
30659
30709
  const ext = guessExt(mime);
30660
- const tmp = path19.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
30710
+ const tmp = path20.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
30661
30711
  try {
30662
30712
  fs11.writeFileSync(tmp, Buffer.from(blob, "base64"));
30663
30713
  } catch {
@@ -30767,7 +30817,7 @@ function collectStableSizes(when, sizes) {
30767
30817
  // src/providers/spec/native-history-executor.ts
30768
30818
  import * as fs12 from "fs";
30769
30819
  import * as os17 from "os";
30770
- import * as path20 from "path";
30820
+ import * as path21 from "path";
30771
30821
  var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
30772
30822
  function executeNativeHistory(cfg, input) {
30773
30823
  if (!cfg?.source) return null;
@@ -30811,7 +30861,7 @@ function executeJsonl(src, input) {
30811
30861
  const v = jsonPathGet(lines[0], src.session_id_path);
30812
30862
  if (typeof v === "string" && v) providerSessionId = v;
30813
30863
  } else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
30814
- const m = path20.basename(sourcePath).match(UUID_RE);
30864
+ const m = path21.basename(sourcePath).match(UUID_RE);
30815
30865
  if (m) providerSessionId = m[1];
30816
30866
  }
30817
30867
  const requested = requestedSessionId || "";
@@ -30924,13 +30974,13 @@ function expandPath2(template, input) {
30924
30974
  if (!template) return null;
30925
30975
  let out = template;
30926
30976
  if (out.startsWith("~/") || out === "~") {
30927
- out = path20.join(os17.homedir(), out.slice(2));
30977
+ out = path21.join(os17.homedir(), out.slice(2));
30928
30978
  }
30929
30979
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
30930
30980
  const v = input.envOverrides?.[name] ?? process.env[name];
30931
30981
  return v != null && v !== "" ? v : fallback ?? "";
30932
30982
  });
30933
- if (out.startsWith("~/")) out = path20.join(os17.homedir(), out.slice(2));
30983
+ if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
30934
30984
  const now = /* @__PURE__ */ new Date();
30935
30985
  const workspaceRaw = input.workspace ?? "";
30936
30986
  let workspaceResolved = workspaceRaw;
@@ -30987,12 +31037,12 @@ function expandDirGlob(template) {
30987
31037
  continue;
30988
31038
  }
30989
31039
  for (const e of entries) {
30990
- if (e.isDirectory() && re.test(e.name)) next.push(path20.join(d, e.name));
31040
+ if (e.isDirectory() && re.test(e.name)) next.push(path21.join(d, e.name));
30991
31041
  }
30992
31042
  }
30993
31043
  } else {
30994
31044
  for (const d of dirs) {
30995
- const candidate = path20.join(d, seg);
31045
+ const candidate = path21.join(d, seg);
30996
31046
  let stat2 = null;
30997
31047
  try {
30998
31048
  stat2 = fs12.statSync(candidate);
@@ -31015,7 +31065,7 @@ function walkAllDirs(root, out) {
31015
31065
  }
31016
31066
  out.push(root);
31017
31067
  for (const e of entries) {
31018
- if (e.isDirectory()) walkAllDirs(path20.join(root, e.name), out);
31068
+ if (e.isDirectory()) walkAllDirs(path21.join(root, e.name), out);
31019
31069
  }
31020
31070
  }
31021
31071
  function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
@@ -31031,7 +31081,7 @@ function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs
31031
31081
  }
31032
31082
  for (const e of entries) {
31033
31083
  if (!e.isFile() || !pattern.test(e.name)) continue;
31034
- const p = path20.join(d, e.name);
31084
+ const p = path21.join(d, e.name);
31035
31085
  const mtime = safeMtimeMs(p);
31036
31086
  if (mtime < cutoff) continue;
31037
31087
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31058,7 +31108,7 @@ function newestRecentFileAcrossDateWindow(template, input, pattern, windowMs, se
31058
31108
  }
31059
31109
  for (const e of entries) {
31060
31110
  if (!e.isFile() || !pattern.test(e.name)) continue;
31061
- const p = path20.join(resolved, e.name);
31111
+ const p = path21.join(resolved, e.name);
31062
31112
  const mtime = safeMtimeMs(p);
31063
31113
  if (mtime < cutoff) continue;
31064
31114
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31070,13 +31120,13 @@ function expandPathForDate(template, input, day) {
31070
31120
  if (!template) return null;
31071
31121
  let out = template;
31072
31122
  if (out.startsWith("~/") || out === "~") {
31073
- out = path20.join(os17.homedir(), out.slice(2));
31123
+ out = path21.join(os17.homedir(), out.slice(2));
31074
31124
  }
31075
31125
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
31076
31126
  const v = input.envOverrides?.[name] ?? process.env[name];
31077
31127
  return v != null && v !== "" ? v : fallback ?? "";
31078
31128
  });
31079
- if (out.startsWith("~/")) out = path20.join(os17.homedir(), out.slice(2));
31129
+ if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
31080
31130
  const workspaceRaw = input.workspace ?? "";
31081
31131
  let workspaceResolved = workspaceRaw;
31082
31132
  if (workspaceRaw) {
@@ -31114,7 +31164,7 @@ function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
31114
31164
  let best = null;
31115
31165
  for (const e of entries) {
31116
31166
  if (!e.isFile() || !pattern.test(e.name)) continue;
31117
- const p = path20.join(dir, e.name);
31167
+ const p = path21.join(dir, e.name);
31118
31168
  const mtime = safeMtimeMs(p);
31119
31169
  if (mtime < cutoff) continue;
31120
31170
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31134,7 +31184,7 @@ function readRequestedSessionId(input) {
31134
31184
  return UUID_RE.test(value) ? value : "";
31135
31185
  }
31136
31186
  function filenameUuid(filePath) {
31137
- const match = path20.basename(filePath).match(UUID_RE);
31187
+ const match = path21.basename(filePath).match(UUID_RE);
31138
31188
  return match?.[1] || "";
31139
31189
  }
31140
31190
  function pickExactSessionFile(dir, pattern, requestedSessionId) {
@@ -31229,7 +31279,7 @@ function listMatchingFiles(dir, pattern) {
31229
31279
  const out = [];
31230
31280
  for (const e of entries) {
31231
31281
  if (!e.isFile() || !pattern.test(e.name)) continue;
31232
- out.push(path20.join(dir, e.name));
31282
+ out.push(path21.join(dir, e.name));
31233
31283
  }
31234
31284
  return out;
31235
31285
  }
@@ -32171,12 +32221,12 @@ function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFact
32171
32221
  const dir = provider._resolvedProviderDir;
32172
32222
  let specPath = resolvedSpecPath && fs14.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
32173
32223
  if (!specPath && dir) {
32174
- const legacy = path21.join(dir, "spec.json");
32224
+ const legacy = path22.join(dir, "spec.json");
32175
32225
  if (fs14.existsSync(legacy)) specPath = legacy;
32176
32226
  }
32177
32227
  if (specPath) {
32178
32228
  try {
32179
- LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path21.relative(dir || "", specPath) || specPath})`);
32229
+ LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path22.relative(dir || "", specPath) || specPath})`);
32180
32230
  return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
32181
32231
  } catch (err) {
32182
32232
  LOG.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
@@ -32243,7 +32293,7 @@ function filePathFromUri(uri) {
32243
32293
  return uri.slice("file://".length);
32244
32294
  }
32245
32295
  }
32246
- if (path22.isAbsolute(uri)) return uri;
32296
+ if (path23.isAbsolute(uri)) return uri;
32247
32297
  return null;
32248
32298
  }
32249
32299
  function extensionForImageMime(mimeType) {
@@ -32259,7 +32309,7 @@ function materializeImageDataPart(part, index, dir) {
32259
32309
  const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
32260
32310
  if (!rawData) return null;
32261
32311
  fs15.mkdirSync(dir, { recursive: true });
32262
- const filePath = path22.join(dir, safeInputImageBasename(index, part.mimeType));
32312
+ const filePath = path23.join(dir, safeInputImageBasename(index, part.mimeType));
32263
32313
  fs15.writeFileSync(filePath, Buffer.from(rawData, "base64"));
32264
32314
  cleanupStaleMaterializedImages(dir);
32265
32315
  return filePath;
@@ -32275,7 +32325,7 @@ function cleanupStaleMaterializedImages(dir) {
32275
32325
  const entries = fs15.readdirSync(dir);
32276
32326
  for (const entry of entries) {
32277
32327
  if (!entry.startsWith("adhdev-input-image-")) continue;
32278
- const fullPath = path22.join(dir, entry);
32328
+ const fullPath = path23.join(dir, entry);
32279
32329
  try {
32280
32330
  const stat2 = fs15.statSync(fullPath);
32281
32331
  if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
@@ -32298,7 +32348,7 @@ function buildCliStructuredInputPrompt(input, options = {}) {
32298
32348
  const promptParts = [];
32299
32349
  const imageRefs = [];
32300
32350
  const resourceRefs = [];
32301
- const materializeDir = options.materializeDir || path22.join(os18.tmpdir(), "adhdev-input-media");
32351
+ const materializeDir = options.materializeDir || path23.join(os18.tmpdir(), "adhdev-input-media");
32302
32352
  input.parts.forEach((part, index) => {
32303
32353
  if (part.type === "text" && part.text.trim()) {
32304
32354
  promptParts.push(part.text.trim());
@@ -32365,7 +32415,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
32365
32415
  var CachedDatabaseSync = null;
32366
32416
  function getDatabaseSync() {
32367
32417
  if (CachedDatabaseSync) return CachedDatabaseSync;
32368
- const requireFn = typeof __require === "function" ? __require : createRequire2(path22.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
32418
+ const requireFn = typeof __require === "function" ? __require : createRequire2(path23.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
32369
32419
  const sqliteModule = requireFn(`node:${"sqlite"}`);
32370
32420
  CachedDatabaseSync = sqliteModule.DatabaseSync;
32371
32421
  if (!CachedDatabaseSync) {
@@ -34002,7 +34052,7 @@ ${effect.notification.body || ""}`.trim();
34002
34052
  };
34003
34053
 
34004
34054
  // src/providers/acp-provider-instance.ts
34005
- import * as path23 from "path";
34055
+ import * as path24 from "path";
34006
34056
  import { Readable, Writable } from "stream";
34007
34057
  import { spawn } from "child_process";
34008
34058
  import {
@@ -34793,7 +34843,7 @@ var AcpProviderInstance = class {
34793
34843
  return b.uri ? {
34794
34844
  type: "resource_link",
34795
34845
  uri: b.uri,
34796
- name: path23.basename(b.uri),
34846
+ name: path24.basename(b.uri),
34797
34847
  mimeType: b.mimeType,
34798
34848
  ...b.transcript ? { description: b.transcript } : {}
34799
34849
  } : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
@@ -35253,20 +35303,20 @@ function shouldRestoreHostedRuntime(record, managerTag) {
35253
35303
  // src/commands/cli-manager.ts
35254
35304
  function isExplicitCommand(command) {
35255
35305
  const trimmed = command.trim();
35256
- return path24.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
35306
+ return path25.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
35257
35307
  }
35258
35308
  function expandExecutable(command) {
35259
35309
  const trimmed = command.trim();
35260
- return trimmed.startsWith("~") ? path24.join(os19.homedir(), trimmed.slice(1)) : trimmed;
35310
+ return trimmed.startsWith("~") ? path25.join(os19.homedir(), trimmed.slice(1)) : trimmed;
35261
35311
  }
35262
35312
  function commandExists(command) {
35263
35313
  const trimmed = command.trim();
35264
35314
  if (!trimmed) return false;
35265
35315
  if (isExplicitCommand(trimmed)) {
35266
- return existsSync24(expandExecutable(trimmed));
35316
+ return existsSync25(expandExecutable(trimmed));
35267
35317
  }
35268
35318
  try {
35269
- execFileSync(process.platform === "win32" ? "where" : "which", [trimmed], {
35319
+ execFileSync2(process.platform === "win32" ? "where" : "which", [trimmed], {
35270
35320
  stdio: "ignore",
35271
35321
  ...process.platform === "win32" ? { windowsHide: true } : {}
35272
35322
  });
@@ -35398,10 +35448,10 @@ function hasConfigOverride(args, key) {
35398
35448
  return false;
35399
35449
  }
35400
35450
  function ensureEmptyDelegatedMcpConfig(workspace) {
35401
- const baseDir = path24.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
35451
+ const baseDir = path25.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
35402
35452
  mkdirSync12(baseDir, { recursive: true });
35403
- const workspaceHash = crypto5.createHash("sha256").update(path24.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
35404
- const filePath = path24.join(baseDir, `${workspaceHash}.json`);
35453
+ const workspaceHash = crypto5.createHash("sha256").update(path25.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
35454
+ const filePath = path25.join(baseDir, `${workspaceHash}.json`);
35405
35455
  writeFileSync15(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
35406
35456
  return filePath;
35407
35457
  }
@@ -35715,7 +35765,7 @@ var DaemonCliManager = class {
35715
35765
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
35716
35766
  const trimmed = (workingDir || "").trim();
35717
35767
  if (!trimmed) throw new Error("working directory required");
35718
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path24.resolve(trimmed);
35768
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path25.resolve(trimmed);
35719
35769
  const normalizedType = this.providerLoader.resolveAlias(cliType);
35720
35770
  const rawProvider = this.providerLoader.getByAlias(cliType);
35721
35771
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -36320,11 +36370,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
36320
36370
  import { exec as exec4, spawn as spawn2 } from "child_process";
36321
36371
  import * as net from "net";
36322
36372
  import * as os24 from "os";
36323
- import * as path32 from "path";
36373
+ import * as path33 from "path";
36324
36374
 
36325
36375
  // src/providers/provider-loader.ts
36326
36376
  import * as fs21 from "fs";
36327
- import * as path31 from "path";
36377
+ import * as path32 from "path";
36328
36378
  import * as os23 from "os";
36329
36379
  import * as chokidar from "chokidar";
36330
36380
  init_logger();
@@ -36717,11 +36767,11 @@ init_external_sources();
36717
36767
  // src/providers/native-history/dispatcher.ts
36718
36768
  import * as fs20 from "fs";
36719
36769
  import * as os22 from "os";
36720
- import * as path29 from "path";
36770
+ import * as path30 from "path";
36721
36771
 
36722
36772
  // src/providers/native-history/claude-cli-transcript.ts
36723
36773
  import * as fs16 from "fs";
36724
- import * as path25 from "path";
36774
+ import * as path26 from "path";
36725
36775
  function extractTimestampValue(value) {
36726
36776
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
36727
36777
  if (typeof value === "string") {
@@ -36877,8 +36927,8 @@ function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
36877
36927
  return records;
36878
36928
  }
36879
36929
  function readSession(sessionPath) {
36880
- if (!sessionPath || !path25.isAbsolute(sessionPath)) return null;
36881
- const basename14 = path25.basename(sessionPath, ".jsonl");
36930
+ if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
36931
+ const basename14 = path26.basename(sessionPath, ".jsonl");
36882
36932
  if (!isSafeSessionId(basename14)) return null;
36883
36933
  if (!fs16.existsSync(sessionPath)) return null;
36884
36934
  const sourceMtimeMs = statMtimeMs(sessionPath);
@@ -36899,7 +36949,7 @@ function readSession(sessionPath) {
36899
36949
 
36900
36950
  // src/providers/native-history/codex-cli-transcript.ts
36901
36951
  import * as fs17 from "fs";
36902
- import * as path26 from "path";
36952
+ import * as path27 from "path";
36903
36953
  function extractTimestampValue2(value) {
36904
36954
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
36905
36955
  if (typeof value === "string") {
@@ -37136,11 +37186,11 @@ function parseSessionFile(filePath, sessionId, workspaceFallback) {
37136
37186
  return records;
37137
37187
  }
37138
37188
  function readSession2(sessionPath) {
37139
- if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
37189
+ if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
37140
37190
  if (!fs17.existsSync(sessionPath)) return null;
37141
37191
  const meta = readSessionMeta(sessionPath);
37142
37192
  const metaId = String(meta?.id ?? "").trim();
37143
- const basename14 = path26.basename(sessionPath, ".jsonl");
37193
+ const basename14 = path27.basename(sessionPath, ".jsonl");
37144
37194
  const uuidMatch = basename14.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
37145
37195
  const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
37146
37196
  if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
@@ -37165,7 +37215,7 @@ function readSession2(sessionPath) {
37165
37215
 
37166
37216
  // src/providers/native-history/antigravity-cli-transcript.ts
37167
37217
  import * as fs18 from "fs";
37168
- import * as path27 from "path";
37218
+ import * as path28 from "path";
37169
37219
  import * as os20 from "os";
37170
37220
  function extractTimestampValue3(value) {
37171
37221
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -37188,13 +37238,13 @@ function isUuidLike(value) {
37188
37238
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
37189
37239
  }
37190
37240
  function antigravityRoot() {
37191
- return path27.join(os20.homedir(), ".gemini", "antigravity-cli");
37241
+ return path28.join(os20.homedir(), ".gemini", "antigravity-cli");
37192
37242
  }
37193
37243
  function historyJsonlPath() {
37194
- return path27.join(antigravityRoot(), "history.jsonl");
37244
+ return path28.join(antigravityRoot(), "history.jsonl");
37195
37245
  }
37196
37246
  function brainRoot() {
37197
- return path27.join(antigravityRoot(), "brain");
37247
+ return path28.join(antigravityRoot(), "brain");
37198
37248
  }
37199
37249
  function extractUserRequestContent(content) {
37200
37250
  const raw = content.trim();
@@ -37341,13 +37391,13 @@ function parsePbFile(filePath, sessionId) {
37341
37391
  ];
37342
37392
  }
37343
37393
  function readSession3(sessionPath, sessionId, workspace) {
37344
- if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
37394
+ if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
37345
37395
  if (!fs18.existsSync(sessionPath)) return null;
37346
37396
  const sourceMtimeMs = statMtimeMs3(sessionPath);
37347
37397
  const brainRootPath = brainRoot();
37348
- if (sessionPath.startsWith(brainRootPath + path27.sep) && sessionPath.endsWith(".jsonl")) {
37398
+ if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
37349
37399
  const relative5 = sessionPath.slice(brainRootPath.length + 1);
37350
- const uuidFromPath = relative5.split(path27.sep)[0];
37400
+ const uuidFromPath = relative5.split(path28.sep)[0];
37351
37401
  const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
37352
37402
  if (!resolvedSessionId) return null;
37353
37403
  const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
@@ -37363,7 +37413,7 @@ function readSession3(sessionPath, sessionId, workspace) {
37363
37413
  };
37364
37414
  }
37365
37415
  if (sessionPath.endsWith(".pb")) {
37366
- const pbSessionId = sessionId || path27.basename(sessionPath, ".pb");
37416
+ const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
37367
37417
  if (!isUuidLike(pbSessionId)) return null;
37368
37418
  const messages = parsePbFile(sessionPath, pbSessionId);
37369
37419
  if (!messages || messages.length === 0) return null;
@@ -37377,7 +37427,7 @@ function readSession3(sessionPath, sessionId, workspace) {
37377
37427
  partialReason: "antigravity_cli_pb_raw_text_extraction"
37378
37428
  };
37379
37429
  }
37380
- if (path27.basename(sessionPath) === "history.jsonl") {
37430
+ if (path28.basename(sessionPath) === "history.jsonl") {
37381
37431
  const resolvedSessionId = sessionId || "";
37382
37432
  if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
37383
37433
  const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
@@ -37425,10 +37475,10 @@ function readSession3(sessionPath, sessionId, workspace) {
37425
37475
 
37426
37476
  // src/providers/native-history/hermes-cli-transcript.ts
37427
37477
  import * as fs19 from "fs";
37428
- import * as path28 from "path";
37478
+ import * as path29 from "path";
37429
37479
  import * as os21 from "os";
37430
- var HERMES_STATE_DB = path28.join(os21.homedir(), ".hermes", "state.db");
37431
- var HERMES_LEGACY_SESSIONS_DIR = path28.join(os21.homedir(), ".hermes", "sessions");
37480
+ var HERMES_STATE_DB = path29.join(os21.homedir(), ".hermes", "state.db");
37481
+ var HERMES_LEGACY_SESSIONS_DIR = path29.join(os21.homedir(), ".hermes", "sessions");
37432
37482
  function statMtimeMs4(p) {
37433
37483
  try {
37434
37484
  return Math.floor(fs19.statSync(p).mtimeMs);
@@ -37494,7 +37544,7 @@ function readSession4(sessionPath) {
37494
37544
  }
37495
37545
  }
37496
37546
  }
37497
- if (!path28.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
37547
+ if (!path29.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
37498
37548
  let raw;
37499
37549
  try {
37500
37550
  raw = JSON.parse(fs19.readFileSync(sessionPath, "utf8"));
@@ -37520,7 +37570,7 @@ function readSession4(sessionPath) {
37520
37570
  });
37521
37571
  }
37522
37572
  if (messages.length === 0) return null;
37523
- const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path28.basename(sessionPath, ".json").replace(/^session_/, "");
37573
+ const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
37524
37574
  return {
37525
37575
  messages,
37526
37576
  providerSessionId: sessionId,
@@ -37586,10 +37636,10 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
37586
37636
  }
37587
37637
  }
37588
37638
  function resolveClaudePath(workspace, sessionId) {
37589
- const dir = path29.join(os22.homedir(), ".claude", "projects", cwdAsDashes(workspace));
37639
+ const dir = path30.join(os22.homedir(), ".claude", "projects", cwdAsDashes(workspace));
37590
37640
  if (!fs20.existsSync(dir)) return null;
37591
37641
  if (sessionId) {
37592
- const candidate = path29.join(dir, `${sessionId}.jsonl`);
37642
+ const candidate = path30.join(dir, `${sessionId}.jsonl`);
37593
37643
  if (fs20.existsSync(candidate)) return candidate;
37594
37644
  }
37595
37645
  return null;
@@ -37615,7 +37665,7 @@ function findCodexPathBySessionId(root, sessionId) {
37615
37665
  continue;
37616
37666
  }
37617
37667
  for (const entry of entries) {
37618
- const entryPath = path29.join(current, entry.name);
37668
+ const entryPath = path30.join(current, entry.name);
37619
37669
  if (entry.isDirectory()) {
37620
37670
  stack.push(entryPath);
37621
37671
  continue;
@@ -37645,7 +37695,7 @@ function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
37645
37695
  continue;
37646
37696
  }
37647
37697
  for (const entry of entries) {
37648
- const entryPath = path29.join(current, entry.name);
37698
+ const entryPath = path30.join(current, entry.name);
37649
37699
  if (entry.isDirectory()) {
37650
37700
  stack.push(entryPath);
37651
37701
  continue;
@@ -37698,12 +37748,12 @@ function resolveRealPath(value) {
37698
37748
  }
37699
37749
  function resolveAntigravityPath(workspace) {
37700
37750
  void workspace;
37701
- const brainRoot2 = path29.join(os22.homedir(), ".gemini", "antigravity-cli", "brain");
37751
+ const brainRoot2 = path30.join(os22.homedir(), ".gemini", "antigravity-cli", "brain");
37702
37752
  if (!fs20.existsSync(brainRoot2)) return null;
37703
37753
  const cutoff = Date.now() - RECENT_WINDOW_MS;
37704
- const entries = fs20.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path29.join(brainRoot2, e.name), mtime: safeMtime(path29.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
37754
+ const entries = fs20.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path30.join(brainRoot2, e.name), mtime: safeMtime(path30.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
37705
37755
  for (const e of entries) {
37706
- const t = path29.join(e.p, ".system_generated", "logs", "transcript.jsonl");
37756
+ const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
37707
37757
  if (fs20.existsSync(t)) return t;
37708
37758
  }
37709
37759
  return null;
@@ -37711,9 +37761,9 @@ function resolveAntigravityPath(workspace) {
37711
37761
  function resolveHermesPath(workspace, sessionId) {
37712
37762
  void workspace;
37713
37763
  void sessionId;
37714
- const dbPath = path29.join(os22.homedir(), ".hermes", "state.db");
37764
+ const dbPath = path30.join(os22.homedir(), ".hermes", "state.db");
37715
37765
  if (fs20.existsSync(dbPath)) return dbPath;
37716
- const dir = path29.join(os22.homedir(), ".hermes", "sessions");
37766
+ const dir = path30.join(os22.homedir(), ".hermes", "sessions");
37717
37767
  if (!fs20.existsSync(dir)) return null;
37718
37768
  return newestRecentFile2(dir, /^session_.*\.json$/);
37719
37769
  }
@@ -37734,7 +37784,7 @@ function cwdAsDashes(cwd) {
37734
37784
  return cwd.replace(/\//g, "-");
37735
37785
  }
37736
37786
  function codexSessionsRoot() {
37737
- return path29.join(os22.homedir(), ".codex", "sessions");
37787
+ return path30.join(os22.homedir(), ".codex", "sessions");
37738
37788
  }
37739
37789
  function isUuidLikeSessionId2(sessionId) {
37740
37790
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
@@ -37746,7 +37796,7 @@ var RECENT_WINDOW_MS = 5 * 60 * 1e3;
37746
37796
  function newestRecentFile2(dir, pattern) {
37747
37797
  try {
37748
37798
  const cutoff = Date.now() - RECENT_WINDOW_MS;
37749
- const entries = fs20.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path29.join(dir, e.name), mtime: safeMtime(path29.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
37799
+ const entries = fs20.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path30.join(dir, e.name), mtime: safeMtime(path30.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
37750
37800
  return entries[0]?.p ?? null;
37751
37801
  } catch {
37752
37802
  return null;
@@ -37809,7 +37859,7 @@ var ProviderLoader = class _ProviderLoader {
37809
37859
  try {
37810
37860
  if (!fs21.existsSync(candidate) || !fs21.statSync(candidate).isDirectory()) return false;
37811
37861
  return ["ide", "extension", "cli", "acp"].some(
37812
- (category) => fs21.existsSync(path31.join(candidate, category))
37862
+ (category) => fs21.existsSync(path32.join(candidate, category))
37813
37863
  );
37814
37864
  } catch {
37815
37865
  return false;
@@ -37817,20 +37867,20 @@ var ProviderLoader = class _ProviderLoader {
37817
37867
  }
37818
37868
  static hasProviderRootMarker(candidate) {
37819
37869
  try {
37820
- return fs21.existsSync(path31.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
37870
+ return fs21.existsSync(path32.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
37821
37871
  } catch {
37822
37872
  return false;
37823
37873
  }
37824
37874
  }
37825
37875
  detectDefaultUserDir() {
37826
- const fallback = path31.join(os23.homedir(), ".adhdev", "providers");
37876
+ const fallback = path32.join(os23.homedir(), ".adhdev", "providers");
37827
37877
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
37828
37878
  const visited = /* @__PURE__ */ new Set();
37829
37879
  for (const start of this.probeStarts) {
37830
- let current = path31.resolve(start);
37880
+ let current = path32.resolve(start);
37831
37881
  while (!visited.has(current)) {
37832
37882
  visited.add(current);
37833
- const siblingCandidate = path31.join(path31.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
37883
+ const siblingCandidate = path32.join(path32.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
37834
37884
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
37835
37885
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
37836
37886
  if (envOptIn || hasMarker) {
@@ -37852,7 +37902,7 @@ var ProviderLoader = class _ProviderLoader {
37852
37902
  return { path: siblingCandidate, source };
37853
37903
  }
37854
37904
  }
37855
- const parent = path31.dirname(current);
37905
+ const parent = path32.dirname(current);
37856
37906
  if (parent === current) break;
37857
37907
  current = parent;
37858
37908
  }
@@ -37862,11 +37912,11 @@ var ProviderLoader = class _ProviderLoader {
37862
37912
  constructor(options) {
37863
37913
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
37864
37914
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
37865
- this.defaultProvidersDir = path31.join(os23.homedir(), ".adhdev", "providers");
37915
+ this.defaultProvidersDir = path32.join(os23.homedir(), ".adhdev", "providers");
37866
37916
  const detected = this.detectDefaultUserDir();
37867
37917
  this.userDir = detected.path;
37868
37918
  this.userDirSource = detected.source;
37869
- this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
37919
+ this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
37870
37920
  this.disableUpstream = false;
37871
37921
  this.applySourceConfig({
37872
37922
  userDir: options?.userDir,
@@ -37878,8 +37928,8 @@ var ProviderLoader = class _ProviderLoader {
37878
37928
  migrateMarketplaceDirToExternal() {
37879
37929
  try {
37880
37930
  const home = os23.homedir();
37881
- const oldDir = path31.join(home, ".adhdev", "marketplace");
37882
- const newDir = path31.join(home, ".adhdev", "external");
37931
+ const oldDir = path32.join(home, ".adhdev", "marketplace");
37932
+ const newDir = path32.join(home, ".adhdev", "external");
37883
37933
  if (!fs21.existsSync(oldDir)) return;
37884
37934
  if (fs21.existsSync(newDir)) {
37885
37935
  this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
@@ -37915,7 +37965,7 @@ var ProviderLoader = class _ProviderLoader {
37915
37965
  * Highest-priority editable overrides come first.
37916
37966
  */
37917
37967
  getProviderRoots() {
37918
- const externalDir = path31.join(os23.homedir(), ".adhdev", "external");
37968
+ const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
37919
37969
  return [this.userDir, externalDir, this.upstreamDir];
37920
37970
  }
37921
37971
  getSourceConfig() {
@@ -37943,7 +37993,7 @@ var ProviderLoader = class _ProviderLoader {
37943
37993
  this.userDir = detected.path;
37944
37994
  this.userDirSource = detected.source;
37945
37995
  }
37946
- this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
37996
+ this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
37947
37997
  this.disableUpstream = this.sourceMode === "no-upstream";
37948
37998
  if (this.explicitProviderDir) {
37949
37999
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -37957,7 +38007,7 @@ var ProviderLoader = class _ProviderLoader {
37957
38007
  * Canonical provider directory shape for a given root.
37958
38008
  */
37959
38009
  getProviderDir(root, category, type) {
37960
- return path31.join(root, category, type);
38010
+ return path32.join(root, category, type);
37961
38011
  }
37962
38012
  /**
37963
38013
  * Canonical user override directory for a provider.
@@ -37984,7 +38034,7 @@ var ProviderLoader = class _ProviderLoader {
37984
38034
  resolveProviderFile(type, ...segments) {
37985
38035
  const dir = this.findProviderDirInternal(type);
37986
38036
  if (!dir) return null;
37987
- return path31.join(dir, ...segments);
38037
+ return path32.join(dir, ...segments);
37988
38038
  }
37989
38039
  /**
37990
38040
  * Load all providers (3-tier priority)
@@ -38008,7 +38058,7 @@ var ProviderLoader = class _ProviderLoader {
38008
38058
  } else if (this.disableUpstream) {
38009
38059
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
38010
38060
  }
38011
- const externalDir = path31.join(os23.homedir(), ".adhdev", "external");
38061
+ const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
38012
38062
  if (fs21.existsSync(externalDir)) {
38013
38063
  const rootEntries = (() => {
38014
38064
  try {
@@ -38030,7 +38080,7 @@ var ProviderLoader = class _ProviderLoader {
38030
38080
  const ambiguousTypes = [];
38031
38081
  for (const sourceEntry of rootEntries) {
38032
38082
  if (!sourceEntry.isDirectory()) continue;
38033
- const sourceDir = path31.join(externalDir, sourceEntry.name);
38083
+ const sourceDir = path32.join(externalDir, sourceEntry.name);
38034
38084
  const sourceLoaded = this.loadDir(sourceDir);
38035
38085
  if (sourceLoaded > 0) {
38036
38086
  totalLoaded += sourceLoaded;
@@ -38046,7 +38096,7 @@ var ProviderLoader = class _ProviderLoader {
38046
38096
  ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
38047
38097
  }
38048
38098
  if (resolved.source && resolved.source !== "?") {
38049
- const sourceDir = path31.join(externalDir, resolved.source);
38099
+ const sourceDir = path32.join(externalDir, resolved.source);
38050
38100
  const reloadCount = this.loadDir(sourceDir);
38051
38101
  if (reloadCount === 0) {
38052
38102
  this.log(`Active source "${resolved.source}" no longer provides ${type}`);
@@ -38079,7 +38129,7 @@ var ProviderLoader = class _ProviderLoader {
38079
38129
  if (!fs21.existsSync(this.upstreamDir)) return false;
38080
38130
  try {
38081
38131
  return fs21.readdirSync(this.upstreamDir).some(
38082
- (d) => fs21.statSync(path31.join(this.upstreamDir, d)).isDirectory()
38132
+ (d) => fs21.statSync(path32.join(this.upstreamDir, d)).isDirectory()
38083
38133
  );
38084
38134
  } catch {
38085
38135
  return false;
@@ -38577,8 +38627,8 @@ var ProviderLoader = class _ProviderLoader {
38577
38627
  resolved._resolvedScriptDir = entry.scriptDir;
38578
38628
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
38579
38629
  if (providerDir) {
38580
- const fullDir = path31.join(providerDir, entry.scriptDir);
38581
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38630
+ const fullDir = path32.join(providerDir, entry.scriptDir);
38631
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38582
38632
  }
38583
38633
  matched = true;
38584
38634
  }
@@ -38596,8 +38646,8 @@ var ProviderLoader = class _ProviderLoader {
38596
38646
  resolved._resolvedScriptDir = base.defaultScriptDir;
38597
38647
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
38598
38648
  if (providerDir) {
38599
- const fullDir = path31.join(providerDir, base.defaultScriptDir);
38600
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38649
+ const fullDir = path32.join(providerDir, base.defaultScriptDir);
38650
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38601
38651
  }
38602
38652
  }
38603
38653
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -38614,8 +38664,8 @@ var ProviderLoader = class _ProviderLoader {
38614
38664
  resolved._resolvedScriptDir = dirOverride;
38615
38665
  resolved._resolvedScriptsSource = `versions:${range}`;
38616
38666
  if (providerDir) {
38617
- const fullDir = path31.join(providerDir, dirOverride);
38618
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38667
+ const fullDir = path32.join(providerDir, dirOverride);
38668
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38619
38669
  }
38620
38670
  }
38621
38671
  } else if (override.scripts) {
@@ -38631,8 +38681,8 @@ var ProviderLoader = class _ProviderLoader {
38631
38681
  resolved._resolvedScriptDir = base.defaultScriptDir;
38632
38682
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
38633
38683
  if (providerDir) {
38634
- const fullDir = path31.join(providerDir, base.defaultScriptDir);
38635
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38684
+ const fullDir = path32.join(providerDir, base.defaultScriptDir);
38685
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38636
38686
  }
38637
38687
  }
38638
38688
  }
@@ -38649,13 +38699,13 @@ var ProviderLoader = class _ProviderLoader {
38649
38699
  if (providerDir2) {
38650
38700
  for (const [scriptName, override] of Object.entries(base.overrides)) {
38651
38701
  if (!override || typeof override.path !== "string") continue;
38652
- const fullPath = path31.join(providerDir2, override.path);
38702
+ const fullPath = path32.join(providerDir2, override.path);
38653
38703
  if (!fs21.existsSync(fullPath)) {
38654
38704
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
38655
38705
  continue;
38656
38706
  }
38657
38707
  try {
38658
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir2)));
38708
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir2)));
38659
38709
  delete __require.cache[__require.resolve(fullPath)];
38660
38710
  const fn = __require(fullPath);
38661
38711
  const target = typeof fn === "function" ? fn : fn && fn[scriptName];
@@ -38681,17 +38731,17 @@ var ProviderLoader = class _ProviderLoader {
38681
38731
  if (providerDir) {
38682
38732
  try {
38683
38733
  const fs30 = __require("fs");
38684
- const path40 = __require("path");
38734
+ const path41 = __require("path");
38685
38735
  const candidates = [];
38686
38736
  if (Array.isArray(base.compatibility)) {
38687
38737
  for (const entry of base.compatibility) {
38688
38738
  if (typeof entry?.spec !== "string") continue;
38689
38739
  const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
38690
- if (matches) candidates.push(path40.join(providerDir, entry.spec));
38740
+ if (matches) candidates.push(path41.join(providerDir, entry.spec));
38691
38741
  }
38692
38742
  }
38693
- candidates.push(path40.join(providerDir, "specs", "default.json"));
38694
- candidates.push(path40.join(providerDir, "spec.json"));
38743
+ candidates.push(path41.join(providerDir, "specs", "default.json"));
38744
+ candidates.push(path41.join(providerDir, "spec.json"));
38695
38745
  const specPath = candidates.find((p) => fs30.existsSync(p));
38696
38746
  if (specPath) {
38697
38747
  resolved._resolvedSpecPath = specPath;
@@ -38722,10 +38772,10 @@ var ProviderLoader = class _ProviderLoader {
38722
38772
  format = `spec-${nh.source.kind}`;
38723
38773
  reader = (input) => executeNativeHistory(nh, input);
38724
38774
  } else if (nh.override_path) {
38725
- const overrideFile = path40.resolve(providerDir, nh.override_path);
38775
+ const overrideFile = path41.resolve(providerDir, nh.override_path);
38726
38776
  if (fs30.existsSync(overrideFile)) {
38727
38777
  try {
38728
- registerProviderScriptRootSafely(path40.dirname(path40.dirname(providerDir)));
38778
+ registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
38729
38779
  delete __require.cache[__require.resolve(overrideFile)];
38730
38780
  const mod = __require(overrideFile);
38731
38781
  const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
@@ -38768,15 +38818,15 @@ var ProviderLoader = class _ProviderLoader {
38768
38818
  this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
38769
38819
  return null;
38770
38820
  }
38771
- const dir = path31.join(providerDir, scriptDir);
38821
+ const dir = path32.join(providerDir, scriptDir);
38772
38822
  if (!fs21.existsSync(dir)) {
38773
38823
  this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
38774
38824
  return null;
38775
38825
  }
38776
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir)));
38826
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir)));
38777
38827
  const cached2 = this.scriptsCache.get(dir);
38778
38828
  if (cached2) return cached2;
38779
- const scriptsJs = path31.join(dir, "scripts.js");
38829
+ const scriptsJs = path32.join(dir, "scripts.js");
38780
38830
  if (fs21.existsSync(scriptsJs)) {
38781
38831
  try {
38782
38832
  delete __require.cache[__require.resolve(scriptsJs)];
@@ -38821,7 +38871,7 @@ var ProviderLoader = class _ProviderLoader {
38821
38871
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
38822
38872
  if (reloadTimer) clearTimeout(reloadTimer);
38823
38873
  reloadTimer = setTimeout(() => {
38824
- this.log(`File changed: ${path31.basename(filePath)}, reloading...`);
38874
+ this.log(`File changed: ${path32.basename(filePath)}, reloading...`);
38825
38875
  this.reload();
38826
38876
  }, 300);
38827
38877
  }
@@ -38889,7 +38939,7 @@ var ProviderLoader = class _ProviderLoader {
38889
38939
  }
38890
38940
  this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
38891
38941
  const https = __require("https");
38892
- const regMetaPath = path31.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
38942
+ const regMetaPath = path32.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
38893
38943
  let cachedChecksums = {};
38894
38944
  try {
38895
38945
  if (fs21.existsSync(regMetaPath)) {
@@ -38947,9 +38997,9 @@ var ProviderLoader = class _ProviderLoader {
38947
38997
  this.log(`\u26A0 Registry checksum mismatch for ${type}@${version} \u2014 skipping`);
38948
38998
  continue;
38949
38999
  }
38950
- const providerDir = path31.join(this.upstreamDir, category, type);
39000
+ const providerDir = path32.join(this.upstreamDir, category, type);
38951
39001
  fs21.mkdirSync(providerDir, { recursive: true });
38952
- fs21.writeFileSync(path31.join(providerDir, "provider.json"), manifestBody, "utf-8");
39002
+ fs21.writeFileSync(path32.join(providerDir, "provider.json"), manifestBody, "utf-8");
38953
39003
  cachedChecksums[cacheKey] = checksum;
38954
39004
  updatedCount++;
38955
39005
  this.log(`\u2713 Registry updated: ${category}/${type}@${version}`);
@@ -38976,7 +39026,7 @@ var ProviderLoader = class _ProviderLoader {
38976
39026
  const { exec: exec7 } = __require("child_process");
38977
39027
  const { promisify: promisify8 } = __require("util");
38978
39028
  const execAsync5 = promisify8(exec7);
38979
- const metaPath = path31.join(this.upstreamDir, _ProviderLoader.META_FILE);
39029
+ const metaPath = path32.join(this.upstreamDir, _ProviderLoader.META_FILE);
38980
39030
  let prevEtag = "";
38981
39031
  let prevTimestamp = 0;
38982
39032
  try {
@@ -39036,17 +39086,17 @@ var ProviderLoader = class _ProviderLoader {
39036
39086
  return { updated: false };
39037
39087
  }
39038
39088
  this.log("Downloading latest providers from GitHub...");
39039
- const tmpTar = path31.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
39040
- const tmpExtract = path31.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
39089
+ const tmpTar = path32.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
39090
+ const tmpExtract = path32.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
39041
39091
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
39042
39092
  fs21.mkdirSync(tmpExtract, { recursive: true });
39043
39093
  await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
39044
39094
  const extracted = fs21.readdirSync(tmpExtract);
39045
39095
  const rootDir = extracted.find(
39046
- (d) => fs21.statSync(path31.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
39096
+ (d) => fs21.statSync(path32.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
39047
39097
  );
39048
39098
  if (!rootDir) throw new Error("Unexpected tarball structure");
39049
- const sourceDir = path31.join(tmpExtract, rootDir);
39099
+ const sourceDir = path32.join(tmpExtract, rootDir);
39050
39100
  const backupDir = this.upstreamDir + ".bak";
39051
39101
  if (fs21.existsSync(this.upstreamDir)) {
39052
39102
  if (fs21.existsSync(backupDir)) fs21.rmSync(backupDir, { recursive: true, force: true });
@@ -39121,8 +39171,8 @@ var ProviderLoader = class _ProviderLoader {
39121
39171
  copyDirRecursive(src, dest) {
39122
39172
  fs21.mkdirSync(dest, { recursive: true });
39123
39173
  for (const entry of fs21.readdirSync(src, { withFileTypes: true })) {
39124
- const srcPath = path31.join(src, entry.name);
39125
- const destPath = path31.join(dest, entry.name);
39174
+ const srcPath = path32.join(src, entry.name);
39175
+ const destPath = path32.join(dest, entry.name);
39126
39176
  if (entry.isDirectory()) {
39127
39177
  this.copyDirRecursive(srcPath, destPath);
39128
39178
  } else {
@@ -39133,7 +39183,7 @@ var ProviderLoader = class _ProviderLoader {
39133
39183
  /** .meta.json save */
39134
39184
  writeMeta(metaPath, etag, timestamp) {
39135
39185
  try {
39136
- fs21.mkdirSync(path31.dirname(metaPath), { recursive: true });
39186
+ fs21.mkdirSync(path32.dirname(metaPath), { recursive: true });
39137
39187
  fs21.writeFileSync(metaPath, JSON.stringify({
39138
39188
  etag,
39139
39189
  timestamp,
@@ -39153,7 +39203,7 @@ var ProviderLoader = class _ProviderLoader {
39153
39203
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
39154
39204
  if (hasManifest) count++;
39155
39205
  for (const entry of entries) {
39156
- if (entry.isDirectory()) scan(path31.join(d, entry.name));
39206
+ if (entry.isDirectory()) scan(path32.join(d, entry.name));
39157
39207
  }
39158
39208
  } catch {
39159
39209
  }
@@ -39379,10 +39429,10 @@ var ProviderLoader = class _ProviderLoader {
39379
39429
  if (!provider) return null;
39380
39430
  const cat = provider.category;
39381
39431
  const searchRoots = this.getProviderRoots();
39382
- const hasManifest = (dir) => fs21.existsSync(path31.join(dir, "provider.v1.json")) || fs21.existsSync(path31.join(dir, "provider.json"));
39432
+ const hasManifest = (dir) => fs21.existsSync(path32.join(dir, "provider.v1.json")) || fs21.existsSync(path32.join(dir, "provider.json"));
39383
39433
  const readManifestType = (dir) => {
39384
39434
  for (const file of ["provider.v1.json", "provider.json"]) {
39385
- const p = path31.join(dir, file);
39435
+ const p = path32.join(dir, file);
39386
39436
  if (!fs21.existsSync(p)) continue;
39387
39437
  try {
39388
39438
  const data = JSON.parse(fs21.readFileSync(p, "utf-8"));
@@ -39396,12 +39446,12 @@ var ProviderLoader = class _ProviderLoader {
39396
39446
  if (!fs21.existsSync(root)) continue;
39397
39447
  const candidate = this.getProviderDir(root, cat, type);
39398
39448
  if (hasManifest(candidate)) return candidate;
39399
- const catDir = path31.join(root, cat);
39449
+ const catDir = path32.join(root, cat);
39400
39450
  if (fs21.existsSync(catDir)) {
39401
39451
  try {
39402
39452
  for (const entry of fs21.readdirSync(catDir, { withFileTypes: true })) {
39403
39453
  if (!entry.isDirectory()) continue;
39404
- const entryDir = path31.join(catDir, entry.name);
39454
+ const entryDir = path32.join(catDir, entry.name);
39405
39455
  const manifestType = readManifestType(entryDir);
39406
39456
  if (manifestType === type) return entryDir;
39407
39457
  }
@@ -39417,7 +39467,7 @@ var ProviderLoader = class _ProviderLoader {
39417
39467
  * (template substitution is NOT applied here — scripts.js handles that)
39418
39468
  */
39419
39469
  buildScriptWrappersFromDir(dir) {
39420
- const scriptsJs = path31.join(dir, "scripts.js");
39470
+ const scriptsJs = path32.join(dir, "scripts.js");
39421
39471
  if (fs21.existsSync(scriptsJs)) {
39422
39472
  try {
39423
39473
  delete __require.cache[__require.resolve(scriptsJs)];
@@ -39431,7 +39481,7 @@ var ProviderLoader = class _ProviderLoader {
39431
39481
  for (const file of fs21.readdirSync(dir)) {
39432
39482
  if (!file.endsWith(".js")) continue;
39433
39483
  const scriptName = toCamel(file.replace(".js", ""));
39434
- const filePath = path31.join(dir, file);
39484
+ const filePath = path32.join(dir, file);
39435
39485
  result[scriptName] = (...args) => {
39436
39486
  try {
39437
39487
  let content = fs21.readFileSync(filePath, "utf-8");
@@ -39493,7 +39543,7 @@ var ProviderLoader = class _ProviderLoader {
39493
39543
  const hasJson = entries.some((e) => e.name === "provider.json");
39494
39544
  if (hasV1 || hasJson) {
39495
39545
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
39496
- const jsonPath = path31.join(d, manifestFile);
39546
+ const jsonPath = path32.join(d, manifestFile);
39497
39547
  try {
39498
39548
  const raw = fs21.readFileSync(jsonPath, "utf-8");
39499
39549
  const mod = JSON.parse(raw);
@@ -39533,10 +39583,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39533
39583
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
39534
39584
  } else {
39535
39585
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
39536
- const scriptsPath = path31.join(d, "scripts.js");
39586
+ const scriptsPath = path32.join(d, "scripts.js");
39537
39587
  if (!hasCompatibility && fs21.existsSync(scriptsPath)) {
39538
39588
  try {
39539
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(d)));
39589
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(d)));
39540
39590
  delete __require.cache[__require.resolve(scriptsPath)];
39541
39591
  const scripts = __require(scriptsPath);
39542
39592
  normalizedProvider.scripts = scripts;
@@ -39544,7 +39594,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39544
39594
  this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
39545
39595
  }
39546
39596
  }
39547
- const externalDirAbs = path31.join(os23.homedir(), ".adhdev", "external");
39597
+ const externalDirAbs = path32.join(os23.homedir(), ".adhdev", "external");
39548
39598
  const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
39549
39599
  try {
39550
39600
  const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS(provider_trust_exports));
@@ -39554,8 +39604,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39554
39604
  normalizedProvider._sourceTrust = trust;
39555
39605
  normalizedProvider._manifestShape = shape;
39556
39606
  if (layer === "external") {
39557
- const rel = path31.relative(externalDirAbs, d);
39558
- const firstSeg = rel.split(path31.sep)[0];
39607
+ const rel = path32.relative(externalDirAbs, d);
39608
+ const firstSeg = rel.split(path32.sep)[0];
39559
39609
  if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
39560
39610
  }
39561
39611
  } catch {
@@ -39579,7 +39629,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39579
39629
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
39580
39630
  if (d === dir && entry.name === "examples") continue;
39581
39631
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
39582
- scan(path31.join(d, entry.name));
39632
+ scan(path32.join(d, entry.name));
39583
39633
  }
39584
39634
  }
39585
39635
  };
@@ -39912,8 +39962,8 @@ async function detectCurrentWorkspace(ideId) {
39912
39962
  const appNameMap = getMacAppIdentifiers();
39913
39963
  const appName = appNameMap[ideId];
39914
39964
  if (appName) {
39915
- const storagePath = path32.join(
39916
- process.env.APPDATA || path32.join(os24.homedir(), "AppData", "Roaming"),
39965
+ const storagePath = path33.join(
39966
+ process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Roaming"),
39917
39967
  appName,
39918
39968
  "storage.json"
39919
39969
  );
@@ -40105,9 +40155,9 @@ init_logger();
40105
40155
 
40106
40156
  // src/logging/command-log.ts
40107
40157
  import * as fs22 from "fs";
40108
- import * as path33 from "path";
40158
+ import * as path34 from "path";
40109
40159
  import * as os25 from "os";
40110
- var LOG_DIR2 = process.platform === "win32" ? path33.join(process.env.LOCALAPPDATA || process.env.APPDATA || path33.join(os25.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path33.join(os25.homedir(), "Library", "Logs", "adhdev") : path33.join(os25.homedir(), ".local", "share", "adhdev", "logs");
40160
+ var LOG_DIR2 = process.platform === "win32" ? path34.join(process.env.LOCALAPPDATA || process.env.APPDATA || path34.join(os25.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path34.join(os25.homedir(), "Library", "Logs", "adhdev") : path34.join(os25.homedir(), ".local", "share", "adhdev", "logs");
40111
40161
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
40112
40162
  var MAX_DAYS = 7;
40113
40163
  try {
@@ -40145,13 +40195,13 @@ function getDateStr2() {
40145
40195
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
40146
40196
  }
40147
40197
  var currentDate2 = getDateStr2();
40148
- var currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40198
+ var currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40149
40199
  var writeCount2 = 0;
40150
40200
  function checkRotation() {
40151
40201
  const today = getDateStr2();
40152
40202
  if (today !== currentDate2) {
40153
40203
  currentDate2 = today;
40154
- currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40204
+ currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40155
40205
  cleanOldFiles();
40156
40206
  }
40157
40207
  }
@@ -40165,7 +40215,7 @@ function cleanOldFiles() {
40165
40215
  const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
40166
40216
  if (dateMatch && dateMatch[1] < cutoffStr) {
40167
40217
  try {
40168
- fs22.unlinkSync(path33.join(LOG_DIR2, file));
40218
+ fs22.unlinkSync(path34.join(LOG_DIR2, file));
40169
40219
  } catch {
40170
40220
  }
40171
40221
  }
@@ -40262,9 +40312,9 @@ import { execFile as execFile4 } from "child_process";
40262
40312
  import { promisify as promisify6 } from "util";
40263
40313
  var execFileAsync3 = promisify6(execFile4);
40264
40314
  var MAX_CHANGED_FILES2 = 500;
40265
- function topLevel(path40) {
40266
- const slash = path40.indexOf("/");
40267
- return slash === -1 ? path40 : path40.slice(0, slash);
40315
+ function topLevel(path41) {
40316
+ const slash = path41.indexOf("/");
40317
+ return slash === -1 ? path41 : path41.slice(0, slash);
40268
40318
  }
40269
40319
  async function analyzeMeshRefineNodeChangeArea(args) {
40270
40320
  const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
@@ -40345,13 +40395,13 @@ function orderMeshRefineBatchNodes(changeAreas) {
40345
40395
  }
40346
40396
 
40347
40397
  // src/mesh/preview-freshness.ts
40348
- import { execFileSync as execFileSync3 } from "child_process";
40349
- import { existsSync as existsSync32, readFileSync as readFileSync25 } from "fs";
40398
+ import { execFileSync as execFileSync4 } from "child_process";
40399
+ import { existsSync as existsSync33, readFileSync as readFileSync25 } from "fs";
40350
40400
  import { resolve as resolve19 } from "path";
40351
40401
  var PREVIEW_DEPLOY_RECORD = ".adhdev/preview-deploy.json";
40352
40402
  function runGit2(repoRoot, args) {
40353
40403
  try {
40354
- return execFileSync3("git", args, {
40404
+ return execFileSync4("git", args, {
40355
40405
  cwd: repoRoot,
40356
40406
  encoding: "utf8",
40357
40407
  stdio: ["ignore", "pipe", "ignore"],
@@ -40362,10 +40412,10 @@ function runGit2(repoRoot, args) {
40362
40412
  }
40363
40413
  }
40364
40414
  function readRecord6(repoRoot) {
40365
- const path40 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
40366
- if (!existsSync32(path40)) return null;
40415
+ const path41 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
40416
+ if (!existsSync33(path41)) return null;
40367
40417
  try {
40368
- const parsed = JSON.parse(readFileSync25(path40, "utf8"));
40418
+ const parsed = JSON.parse(readFileSync25(path41, "utf8"));
40369
40419
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
40370
40420
  } catch {
40371
40421
  return null;
@@ -40430,7 +40480,7 @@ function buildPreviewFreshness(repoRoot) {
40430
40480
  init_mesh_refine_status();
40431
40481
 
40432
40482
  // src/mesh/mesh-init.ts
40433
- import { existsSync as existsSync33, mkdirSync as mkdirSync15, writeFileSync as writeFileSync17 } from "fs";
40483
+ import { existsSync as existsSync34, mkdirSync as mkdirSync15, writeFileSync as writeFileSync17 } from "fs";
40434
40484
  import { dirname as dirname7, join as join37 } from "path";
40435
40485
  var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
40436
40486
  var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
@@ -40453,14 +40503,14 @@ function writeConfigFile(workspace, relativePath, config) {
40453
40503
  }
40454
40504
  function suggestMeshWorktreeBootstrapConfig(workspace) {
40455
40505
  const commands = [];
40456
- const hasPackageJson = existsSync33(join37(workspace, "package.json"));
40457
- const hasNpmLock = existsSync33(join37(workspace, "package-lock.json"));
40506
+ const hasPackageJson = existsSync34(join37(workspace, "package.json"));
40507
+ const hasNpmLock = existsSync34(join37(workspace, "package-lock.json"));
40458
40508
  if (hasPackageJson) {
40459
40509
  commands.push(
40460
40510
  hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
40461
40511
  );
40462
40512
  }
40463
- const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync33(join37(workspace, relative5)));
40513
+ const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync34(join37(workspace, relative5)));
40464
40514
  if (!commands.length) {
40465
40515
  return { commands, staleInputs };
40466
40516
  }
@@ -40892,17 +40942,17 @@ function buildStatusSnapshot(options) {
40892
40942
  init_build_info();
40893
40943
 
40894
40944
  // src/commands/upgrade-helper.ts
40895
- import { execFileSync as execFileSync4 } from "child_process";
40945
+ import { execFileSync as execFileSync5 } from "child_process";
40896
40946
  import { spawn as spawn3 } from "child_process";
40897
40947
  import * as fs23 from "fs";
40898
40948
  import * as os27 from "os";
40899
- import * as path34 from "path";
40949
+ import * as path35 from "path";
40900
40950
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
40901
40951
  function getUpgradeLogPath() {
40902
40952
  const home = os27.homedir();
40903
- const dir = path34.join(home, ".adhdev");
40953
+ const dir = path35.join(home, ".adhdev");
40904
40954
  fs23.mkdirSync(dir, { recursive: true });
40905
- return path34.join(dir, "daemon-upgrade.log");
40955
+ return path35.join(dir, "daemon-upgrade.log");
40906
40956
  }
40907
40957
  function appendUpgradeLog(message) {
40908
40958
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
@@ -40913,14 +40963,14 @@ function appendUpgradeLog(message) {
40913
40963
  }
40914
40964
  }
40915
40965
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
40916
- const binDir = path34.dirname(nodeExecutable);
40966
+ const binDir = path35.dirname(nodeExecutable);
40917
40967
  if (platform10 === "win32") {
40918
- const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
40968
+ const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
40919
40969
  if (fs23.existsSync(npmCliPath)) {
40920
40970
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
40921
40971
  }
40922
40972
  for (const candidate of ["npm.exe", "npm"]) {
40923
- const candidatePath = path34.join(binDir, candidate);
40973
+ const candidatePath = path35.join(binDir, candidate);
40924
40974
  if (fs23.existsSync(candidatePath)) {
40925
40975
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
40926
40976
  }
@@ -40928,7 +40978,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
40928
40978
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
40929
40979
  }
40930
40980
  for (const candidate of ["npm"]) {
40931
- const candidatePath = path34.join(binDir, candidate);
40981
+ const candidatePath = path35.join(binDir, candidate);
40932
40982
  if (fs23.existsSync(candidatePath)) {
40933
40983
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
40934
40984
  }
@@ -40945,13 +40995,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
40945
40995
  let currentDir = resolvedPath;
40946
40996
  try {
40947
40997
  if (fs23.statSync(resolvedPath).isFile()) {
40948
- currentDir = path34.dirname(resolvedPath);
40998
+ currentDir = path35.dirname(resolvedPath);
40949
40999
  }
40950
41000
  } catch {
40951
- currentDir = path34.dirname(resolvedPath);
41001
+ currentDir = path35.dirname(resolvedPath);
40952
41002
  }
40953
41003
  while (true) {
40954
- const packageJsonPath = path34.join(currentDir, "package.json");
41004
+ const packageJsonPath = path35.join(currentDir, "package.json");
40955
41005
  try {
40956
41006
  if (fs23.existsSync(packageJsonPath)) {
40957
41007
  const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
@@ -40962,7 +41012,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
40962
41012
  }
40963
41013
  } catch {
40964
41014
  }
40965
- const parentDir = path34.dirname(currentDir);
41015
+ const parentDir = path35.dirname(currentDir);
40966
41016
  if (parentDir === currentDir) {
40967
41017
  return null;
40968
41018
  }
@@ -40970,13 +41020,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
40970
41020
  }
40971
41021
  }
40972
41022
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
40973
- const nodeModulesDir = packageName.startsWith("@") ? path34.dirname(path34.dirname(packageRoot)) : path34.dirname(packageRoot);
40974
- if (path34.basename(nodeModulesDir) !== "node_modules") {
41023
+ const nodeModulesDir = packageName.startsWith("@") ? path35.dirname(path35.dirname(packageRoot)) : path35.dirname(packageRoot);
41024
+ if (path35.basename(nodeModulesDir) !== "node_modules") {
40975
41025
  return null;
40976
41026
  }
40977
- const maybeLibDir = path34.dirname(nodeModulesDir);
40978
- if (path34.basename(maybeLibDir) === "lib") {
40979
- return path34.dirname(maybeLibDir);
41027
+ const maybeLibDir = path35.dirname(nodeModulesDir);
41028
+ if (path35.basename(maybeLibDir) === "lib") {
41029
+ return path35.dirname(maybeLibDir);
40980
41030
  }
40981
41031
  return maybeLibDir;
40982
41032
  }
@@ -41004,6 +41054,16 @@ function buildPinnedGlobalInstallCommand(options) {
41004
41054
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
41005
41055
  };
41006
41056
  }
41057
+ function buildInstallEnvWithNodeOnPath(baseEnv = process.env) {
41058
+ if (process.platform !== "win32") return { ...baseEnv };
41059
+ const nodeBinDir = path35.dirname(process.execPath);
41060
+ if (!nodeBinDir) return { ...baseEnv };
41061
+ const env = { ...baseEnv };
41062
+ const pathKey = Object.keys(env).find((k) => k.toLowerCase() === "path") || "PATH";
41063
+ const current = env[pathKey] || "";
41064
+ env[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
41065
+ return env;
41066
+ }
41007
41067
  function getNpmExecOptions(platform10 = process.platform) {
41008
41068
  if (platform10 === "win32") {
41009
41069
  return { shell: false, windowsHide: true };
@@ -41012,7 +41072,7 @@ function getNpmExecOptions(platform10 = process.platform) {
41012
41072
  }
41013
41073
  function execNpmCommandSync(args, options = {}, surface) {
41014
41074
  const execOptions = surface?.execOptions || getNpmExecOptions();
41015
- return execFileSync4(
41075
+ return execFileSync5(
41016
41076
  surface?.npmExecutable || "npm",
41017
41077
  [...surface?.npmArgsPrefix || [], ...args],
41018
41078
  {
@@ -41025,7 +41085,7 @@ function execNpmCommandSync(args, options = {}, surface) {
41025
41085
  function killPid(pid) {
41026
41086
  try {
41027
41087
  if (process.platform === "win32") {
41028
- execFileSync4("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
41088
+ execFileSync5("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
41029
41089
  } else {
41030
41090
  process.kill(pid, "SIGTERM");
41031
41091
  }
@@ -41037,7 +41097,7 @@ function killPid(pid) {
41037
41097
  function getWindowsProcessCommandLine(pid) {
41038
41098
  const pidFilter = `ProcessId=${pid}`;
41039
41099
  try {
41040
- const psOut = execFileSync4("powershell.exe", [
41100
+ const psOut = execFileSync5("powershell.exe", [
41041
41101
  "-NoProfile",
41042
41102
  "-NonInteractive",
41043
41103
  "-ExecutionPolicy",
@@ -41049,7 +41109,7 @@ function getWindowsProcessCommandLine(pid) {
41049
41109
  } catch {
41050
41110
  }
41051
41111
  try {
41052
- const wmicOut = execFileSync4("wmic", [
41112
+ const wmicOut = execFileSync5("wmic", [
41053
41113
  "process",
41054
41114
  "where",
41055
41115
  pidFilter,
@@ -41065,7 +41125,7 @@ function getProcessCommandLine(pid) {
41065
41125
  if (!Number.isFinite(pid) || pid <= 0) return null;
41066
41126
  if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
41067
41127
  try {
41068
- const text = execFileSync4("ps", ["-o", "command=", "-p", String(pid)], {
41128
+ const text = execFileSync5("ps", ["-o", "command=", "-p", String(pid)], {
41069
41129
  encoding: "utf8",
41070
41130
  timeout: 3e3,
41071
41131
  stdio: ["ignore", "pipe", "ignore"]
@@ -41091,7 +41151,7 @@ async function waitForPidExit(pid, timeoutMs) {
41091
41151
  }
41092
41152
  }
41093
41153
  function stopSessionHostProcesses(appName) {
41094
- const pidFile = path34.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
41154
+ const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
41095
41155
  try {
41096
41156
  if (fs23.existsSync(pidFile)) {
41097
41157
  const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
@@ -41108,7 +41168,7 @@ function stopSessionHostProcesses(appName) {
41108
41168
  }
41109
41169
  }
41110
41170
  function removeDaemonPidFile() {
41111
- const pidFile = path34.join(os27.homedir(), ".adhdev", "daemon.pid");
41171
+ const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
41112
41172
  try {
41113
41173
  fs23.unlinkSync(pidFile);
41114
41174
  } catch {
@@ -41119,7 +41179,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
41119
41179
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
41120
41180
  if (!npmRoot) return;
41121
41181
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
41122
- const binDir = process.platform === "win32" ? npmPrefix : path34.join(npmPrefix, "bin");
41182
+ const binDir = process.platform === "win32" ? npmPrefix : path35.join(npmPrefix, "bin");
41123
41183
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
41124
41184
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
41125
41185
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -41127,25 +41187,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
41127
41187
  }
41128
41188
  if (pkgName.startsWith("@")) {
41129
41189
  const [scope, name] = pkgName.split("/");
41130
- const scopeDir = path34.join(npmRoot, scope);
41190
+ const scopeDir = path35.join(npmRoot, scope);
41131
41191
  if (!fs23.existsSync(scopeDir)) return;
41132
41192
  for (const entry of fs23.readdirSync(scopeDir)) {
41133
41193
  if (!entry.startsWith(`.${name}-`)) continue;
41134
- fs23.rmSync(path34.join(scopeDir, entry), { recursive: true, force: true });
41135
- appendUpgradeLog(`Removed stale scoped staging dir: ${path34.join(scopeDir, entry)}`);
41194
+ fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
41195
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
41136
41196
  }
41137
41197
  } else {
41138
41198
  for (const entry of fs23.readdirSync(npmRoot)) {
41139
41199
  if (!entry.startsWith(`.${pkgName}-`)) continue;
41140
- fs23.rmSync(path34.join(npmRoot, entry), { recursive: true, force: true });
41141
- appendUpgradeLog(`Removed stale staging dir: ${path34.join(npmRoot, entry)}`);
41200
+ fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
41201
+ appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
41142
41202
  }
41143
41203
  }
41144
41204
  if (fs23.existsSync(binDir)) {
41145
41205
  for (const entry of fs23.readdirSync(binDir)) {
41146
41206
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
41147
- fs23.rmSync(path34.join(binDir, entry), { recursive: true, force: true });
41148
- appendUpgradeLog(`Removed stale bin staging entry: ${path34.join(binDir, entry)}`);
41207
+ fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
41208
+ appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
41149
41209
  }
41150
41210
  }
41151
41211
  }
@@ -41181,13 +41241,14 @@ async function runDaemonUpgradeHelper(payload) {
41181
41241
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
41182
41242
  const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
41183
41243
  appendUpgradeLog(`Installing ${spec}`);
41184
- const installOutput = execFileSync4(
41244
+ const installOutput = execFileSync5(
41185
41245
  installCommand.command,
41186
41246
  installCommand.args,
41187
41247
  {
41188
41248
  encoding: "utf8",
41189
41249
  stdio: "pipe",
41190
41250
  maxBuffer: 20 * 1024 * 1024,
41251
+ env: buildInstallEnvWithNodeOnPath(),
41191
41252
  ...installCommand.execOptions
41192
41253
  }
41193
41254
  );
@@ -41235,7 +41296,7 @@ init_repo_mesh_types();
41235
41296
  import { homedir as homedir26, hostname as osHostname } from "os";
41236
41297
  import { basename as pathBasename, join as pathJoin, resolve as pathResolve2 } from "path";
41237
41298
  import * as fs24 from "fs";
41238
- import { execFileSync as execFileSync5 } from "child_process";
41299
+ import { execFileSync as execFileSync6 } from "child_process";
41239
41300
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
41240
41301
  var CHANNEL_SERVER_URL = {
41241
41302
  stable: "https://api.adhf.dev",
@@ -42212,18 +42273,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
42212
42273
  return { enabled: false };
42213
42274
  }
42214
42275
  async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
42215
- const { execFileSync: execFileSync6 } = await import("child_process");
42276
+ const { execFileSync: execFileSync7 } = await import("child_process");
42216
42277
  const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
42217
42278
  if (excludePaths.length > 0) {
42218
- diffArgs.push("--", ".", ...excludePaths.map((path40) => `:(exclude)${path40}`));
42279
+ diffArgs.push("--", ".", ...excludePaths.map((path41) => `:(exclude)${path41}`));
42219
42280
  }
42220
- const diff = execFileSync6("git", diffArgs, {
42281
+ const diff = execFileSync7("git", diffArgs, {
42221
42282
  cwd,
42222
42283
  encoding: "utf8",
42223
42284
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
42224
42285
  });
42225
42286
  if (!diff.trim()) return "";
42226
- const patchId = execFileSync6("git", ["patch-id", "--stable"], {
42287
+ const patchId = execFileSync7("git", ["patch-id", "--stable"], {
42227
42288
  cwd,
42228
42289
  input: diff,
42229
42290
  encoding: "utf8",
@@ -42234,8 +42295,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
42234
42295
  async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
42235
42296
  const startedAt = Date.now();
42236
42297
  try {
42237
- const { execFileSync: execFileSync6 } = await import("child_process");
42238
- const git = (args) => execFileSync6("git", args, {
42298
+ const { execFileSync: execFileSync7 } = await import("child_process");
42299
+ const git = (args) => execFileSync7("git", args, {
42239
42300
  cwd: repoRoot,
42240
42301
  encoding: "utf8",
42241
42302
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42326,8 +42387,8 @@ ${e?.stderr || ""}`
42326
42387
  async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42327
42388
  const startedAt = Date.now();
42328
42389
  try {
42329
- const { execFileSync: execFileSync6 } = await import("child_process");
42330
- const git = (args, opts) => execFileSync6("git", args, {
42390
+ const { execFileSync: execFileSync7 } = await import("child_process");
42391
+ const git = (args, opts) => execFileSync7("git", args, {
42331
42392
  cwd: opts?.cwd || repoRoot,
42332
42393
  encoding: "utf8",
42333
42394
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42352,9 +42413,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42352
42413
  if (!trimmed) continue;
42353
42414
  if (trimmed.startsWith("+")) {
42354
42415
  const parts = trimmed.slice(1).trim().split(/\s+/);
42355
- const path40 = parts[1] || parts[0] || "(unknown)";
42416
+ const path41 = parts[1] || parts[0] || "(unknown)";
42356
42417
  submoduleHints.push({
42357
- path: path40,
42418
+ path: path41,
42358
42419
  reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
42359
42420
  });
42360
42421
  }
@@ -42384,10 +42445,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42384
42445
  }
42385
42446
  function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
42386
42447
  if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
42387
- const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => ({
42388
- path: path40,
42389
- baseCommit: readTreeObject(repoRoot, baseHead, path40),
42390
- branchCommit: readTreeObject(repoRoot, branchHead, path40)
42448
+ const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => ({
42449
+ path: path41,
42450
+ baseCommit: readTreeObject(repoRoot, baseHead, path41),
42451
+ branchCommit: readTreeObject(repoRoot, branchHead, path41)
42391
42452
  }));
42392
42453
  if (conflicts.length === 0) return void 0;
42393
42454
  return {
@@ -42403,7 +42464,7 @@ function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHe
42403
42464
  }
42404
42465
  function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
42405
42466
  try {
42406
- const output = execFileSync5("git", ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
42467
+ const output = execFileSync6("git", ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
42407
42468
  cwd: repoRoot,
42408
42469
  encoding: "utf8",
42409
42470
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42413,11 +42474,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
42413
42474
  if (!line.trim()) continue;
42414
42475
  const metaAndPath = line.split(" ");
42415
42476
  const meta = metaAndPath[0] || "";
42416
- const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
42417
- if (!path40) continue;
42477
+ const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
42478
+ if (!path41) continue;
42418
42479
  const parts = meta.split(/\s+/);
42419
42480
  if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
42420
- paths.add(path40);
42481
+ paths.add(path41);
42421
42482
  }
42422
42483
  }
42423
42484
  return [...paths].sort();
@@ -42425,9 +42486,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
42425
42486
  return [];
42426
42487
  }
42427
42488
  }
42428
- function readTreeObject(repoRoot, ref, path40) {
42489
+ function readTreeObject(repoRoot, ref, path41) {
42429
42490
  try {
42430
- const output = execFileSync5("git", ["ls-tree", ref, "--", path40], {
42491
+ const output = execFileSync6("git", ["ls-tree", ref, "--", path41], {
42431
42492
  cwd: repoRoot,
42432
42493
  encoding: "utf8",
42433
42494
  maxBuffer: 1024 * 1024
@@ -42439,7 +42500,7 @@ function readTreeObject(repoRoot, ref, path40) {
42439
42500
  }
42440
42501
  }
42441
42502
  function resolveGitDir(repoRoot) {
42442
- const out = execFileSync5("git", ["rev-parse", "--absolute-git-dir"], {
42503
+ const out = execFileSync6("git", ["rev-parse", "--absolute-git-dir"], {
42443
42504
  cwd: repoRoot,
42444
42505
  encoding: "utf8",
42445
42506
  maxBuffer: 1024 * 1024
@@ -42451,9 +42512,9 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
42451
42512
  if (baseCommit === branchCommit) return true;
42452
42513
  try {
42453
42514
  if (!fs24.existsSync(submoduleRepoPath)) return false;
42454
- execFileSync5("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
42455
- execFileSync5("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
42456
- execFileSync5("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
42515
+ execFileSync6("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
42516
+ execFileSync6("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
42517
+ execFileSync6("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
42457
42518
  return true;
42458
42519
  } catch {
42459
42520
  return false;
@@ -42461,7 +42522,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
42461
42522
  }
42462
42523
  function readChangedPathKinds(repoRoot, fromRef, toRef) {
42463
42524
  try {
42464
- const output = execFileSync5("git", ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
42525
+ const output = execFileSync6("git", ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
42465
42526
  cwd: repoRoot,
42466
42527
  encoding: "utf8",
42467
42528
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42472,12 +42533,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
42472
42533
  if (!line.trim()) continue;
42473
42534
  const metaAndPath = line.split(" ");
42474
42535
  const meta = metaAndPath[0] || "";
42475
- const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
42476
- if (!path40 || seen.has(path40)) continue;
42477
- seen.add(path40);
42536
+ const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
42537
+ if (!path41 || seen.has(path41)) continue;
42538
+ seen.add(path41);
42478
42539
  const parts = meta.split(/\s+/);
42479
42540
  const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
42480
- result.push({ path: path40, isGitlink });
42541
+ result.push({ path: path41, isGitlink });
42481
42542
  }
42482
42543
  return result;
42483
42544
  } catch {
@@ -42485,20 +42546,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
42485
42546
  }
42486
42547
  }
42487
42548
  function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
42488
- return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path40) => {
42489
- const baseCommit = readTreeObject(repoRoot, baseHead, path40);
42490
- const branchCommit = readTreeObject(repoRoot, branchHead, path40);
42549
+ return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path41) => {
42550
+ const baseCommit = readTreeObject(repoRoot, baseHead, path41);
42551
+ const branchCommit = readTreeObject(repoRoot, branchHead, path41);
42491
42552
  if (!baseCommit || !branchCommit) return false;
42492
- return isSubmoduleFastForward(pathResolve2(repoRoot, path40), baseCommit, branchCommit);
42553
+ return isSubmoduleFastForward(pathResolve2(repoRoot, path41), baseCommit, branchCommit);
42493
42554
  });
42494
42555
  }
42495
42556
  function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
42496
- const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => {
42497
- const baseCommit = readTreeObject(repoRoot, baseHead, path40);
42498
- const branchCommit = readTreeObject(repoRoot, branchHead, path40);
42499
- const submoduleRepoPath = pathResolve2(repoRoot, path40);
42557
+ const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => {
42558
+ const baseCommit = readTreeObject(repoRoot, baseHead, path41);
42559
+ const branchCommit = readTreeObject(repoRoot, branchHead, path41);
42560
+ const submoduleRepoPath = pathResolve2(repoRoot, path41);
42500
42561
  const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
42501
- return { path: path40, baseCommit, branchCommit, fastForward };
42562
+ return { path: path41, baseCommit, branchCommit, fastForward };
42502
42563
  });
42503
42564
  if (changedGitlinks.length === 0) {
42504
42565
  return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
@@ -42513,7 +42574,7 @@ function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
42513
42574
  }
42514
42575
  let mergeBase = "";
42515
42576
  try {
42516
- mergeBase = execFileSync5("git", ["merge-base", baseHead, branchHead], {
42577
+ mergeBase = execFileSync6("git", ["merge-base", baseHead, branchHead], {
42517
42578
  cwd: repoRoot,
42518
42579
  encoding: "utf8",
42519
42580
  maxBuffer: 1024 * 1024
@@ -42543,19 +42604,19 @@ function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
42543
42604
  }
42544
42605
  function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderCommit) {
42545
42606
  try {
42546
- const tree = execFileSync5("git", ["rev-parse", `${commitish}^{tree}`], {
42607
+ const tree = execFileSync6("git", ["rev-parse", `${commitish}^{tree}`], {
42547
42608
  cwd: repoRoot,
42548
42609
  encoding: "utf8",
42549
42610
  maxBuffer: 1024 * 1024
42550
42611
  }).trim();
42551
42612
  if (!tree) return void 0;
42552
- const updates = paths.map((path40) => `160000 commit ${placeholderCommit} ${path40}`).join("\n");
42613
+ const updates = paths.map((path41) => `160000 commit ${placeholderCommit} ${path41}`).join("\n");
42553
42614
  if (!updates) return tree;
42554
42615
  const tmpIndex = pathJoin(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
42555
42616
  const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
42556
42617
  try {
42557
- execFileSync5("git", ["read-tree", tree], { cwd: repoRoot, env, stdio: "ignore" });
42558
- execFileSync5("git", ["update-index", "--index-info"], {
42618
+ execFileSync6("git", ["read-tree", tree], { cwd: repoRoot, env, stdio: "ignore" });
42619
+ execFileSync6("git", ["update-index", "--index-info"], {
42559
42620
  cwd: repoRoot,
42560
42621
  env,
42561
42622
  input: `${updates}
@@ -42563,7 +42624,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
42563
42624
  encoding: "utf8",
42564
42625
  stdio: ["pipe", "ignore", "ignore"]
42565
42626
  });
42566
- const newTree = execFileSync5("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
42627
+ const newTree = execFileSync6("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
42567
42628
  return newTree || void 0;
42568
42629
  } finally {
42569
42630
  try {
@@ -42579,7 +42640,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42579
42640
  try {
42580
42641
  const branchGitlinks = gitlinks.filter((entry) => entry.branchCommit);
42581
42642
  const gitlinkPaths = branchGitlinks.map((entry) => entry.path);
42582
- const mergeBase = execFileSync5("git", ["merge-base", baseHead, branchHead], {
42643
+ const mergeBase = execFileSync6("git", ["merge-base", baseHead, branchHead], {
42583
42644
  cwd: repoRoot,
42584
42645
  encoding: "utf8",
42585
42646
  maxBuffer: 1024 * 1024
@@ -42592,22 +42653,22 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42592
42653
  const theirsEqTree = buildTreeWithGitlinksEqualized(repoRoot, branchHead, gitlinkPaths, placeholder);
42593
42654
  if (baseEqTree && oursEqTree && theirsEqTree) {
42594
42655
  try {
42595
- const baseEqCommit = execFileSync5("git", ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
42656
+ const baseEqCommit = execFileSync6("git", ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
42596
42657
  cwd: repoRoot,
42597
42658
  encoding: "utf8",
42598
42659
  maxBuffer: 1024 * 1024
42599
42660
  }).trim();
42600
- const oursEqCommit = execFileSync5("git", ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
42661
+ const oursEqCommit = execFileSync6("git", ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
42601
42662
  cwd: repoRoot,
42602
42663
  encoding: "utf8",
42603
42664
  maxBuffer: 1024 * 1024
42604
42665
  }).trim();
42605
- const theirsEqCommit = execFileSync5("git", ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
42666
+ const theirsEqCommit = execFileSync6("git", ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
42606
42667
  cwd: repoRoot,
42607
42668
  encoding: "utf8",
42608
42669
  maxBuffer: 1024 * 1024
42609
42670
  }).trim();
42610
- const mergeOut = execFileSync5("git", ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
42671
+ const mergeOut = execFileSync6("git", ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
42611
42672
  cwd: repoRoot,
42612
42673
  encoding: "utf8",
42613
42674
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42618,7 +42679,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42618
42679
  }
42619
42680
  }
42620
42681
  }
42621
- const contentTree = mergedContentTree || execFileSync5("git", ["rev-parse", `${baseHead}^{tree}`], {
42682
+ const contentTree = mergedContentTree || execFileSync6("git", ["rev-parse", `${baseHead}^{tree}`], {
42622
42683
  cwd: repoRoot,
42623
42684
  encoding: "utf8",
42624
42685
  maxBuffer: 1024 * 1024
@@ -42629,8 +42690,8 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42629
42690
  const tmpIndex = pathJoin(resolveGitDir(repoRoot), `adhdev-refine-ff-${baseHead.slice(0, 12)}-${branchHead.slice(0, 12)}.index`);
42630
42691
  const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
42631
42692
  try {
42632
- execFileSync5("git", ["read-tree", contentTree], { cwd: repoRoot, env, stdio: "ignore" });
42633
- execFileSync5("git", ["update-index", "--index-info"], {
42693
+ execFileSync6("git", ["read-tree", contentTree], { cwd: repoRoot, env, stdio: "ignore" });
42694
+ execFileSync6("git", ["update-index", "--index-info"], {
42634
42695
  cwd: repoRoot,
42635
42696
  env,
42636
42697
  input: `${updates}
@@ -42638,7 +42699,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42638
42699
  encoding: "utf8",
42639
42700
  stdio: ["pipe", "ignore", "ignore"]
42640
42701
  });
42641
- const newTree = execFileSync5("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
42702
+ const newTree = execFileSync6("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
42642
42703
  return newTree || void 0;
42643
42704
  } finally {
42644
42705
  try {
@@ -42652,7 +42713,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42652
42713
  }
42653
42714
  async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
42654
42715
  const startedAt = Date.now();
42655
- const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path40) => !(options.submoduleIgnorePaths || []).includes(path40));
42716
+ const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path41) => !(options.submoduleIgnorePaths || []).includes(path41));
42656
42717
  const preStatus = await getGitRepoStatus(repoRoot, {
42657
42718
  includeSubmodules: true,
42658
42719
  submoduleIgnorePaths: options.submoduleIgnorePaths,
@@ -42693,7 +42754,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
42693
42754
  changedGitlinkPaths,
42694
42755
  outOfSyncPaths,
42695
42756
  updatedPaths: updatePaths,
42696
- verifiedPaths: updatePaths.filter((path40) => !remaining.some((submodule) => submodule.path === path40)),
42757
+ verifiedPaths: updatePaths.filter((path41) => !remaining.some((submodule) => submodule.path === path41)),
42697
42758
  durationMs: Date.now() - startedAt,
42698
42759
  command: `git ${commandArgs.join(" ")}`,
42699
42760
  stdout: truncateValidationOutput(result.stdout),
@@ -44316,7 +44377,7 @@ ${tail}` : ""
44316
44377
  let didAutoRebase = false;
44317
44378
  let isBehindBase = false;
44318
44379
  try {
44319
- execFileSync5("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
44380
+ execFileSync6("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
44320
44381
  cwd: node.workspace,
44321
44382
  stdio: "ignore"
44322
44383
  });
@@ -44326,7 +44387,7 @@ ${tail}` : ""
44326
44387
  if (isBehindBase) {
44327
44388
  const autoRebaseStarted = Date.now();
44328
44389
  try {
44329
- execFileSync5("git", ["rebase", baseHead], {
44390
+ execFileSync6("git", ["rebase", baseHead], {
44330
44391
  cwd: node.workspace,
44331
44392
  stdio: ["ignore", "pipe", "pipe"]
44332
44393
  });
@@ -44367,7 +44428,7 @@ ${tail}` : ""
44367
44428
  }
44368
44429
  } catch (rebaseErr) {
44369
44430
  try {
44370
- execFileSync5("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
44431
+ execFileSync6("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
44371
44432
  } catch {
44372
44433
  }
44373
44434
  recordMeshRefineStage(refineStages, "patch_equivalence_after_auto_rebase", "failed", autoRebaseStarted, {
@@ -45991,9 +46052,9 @@ ${hintLines.join("\n")}` : "",
45991
46052
  // commands instead of going through fs from the browser.
45992
46053
  case "list_coordinator_prompts": {
45993
46054
  const fs30 = await import("fs");
45994
- const path40 = await import("path");
46055
+ const path41 = await import("path");
45995
46056
  const os30 = await import("os");
45996
- const dir = path40.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46057
+ const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
45997
46058
  const entries = {};
45998
46059
  try {
45999
46060
  if (fs30.existsSync(dir)) {
@@ -46004,7 +46065,7 @@ ${hintLines.join("\n")}` : "",
46004
46065
  if (!m) continue;
46005
46066
  const isAppend = !!matchAppend;
46006
46067
  const key = m[1];
46007
- const full = path40.join(dir, name);
46068
+ const full = path41.join(dir, name);
46008
46069
  let content = "";
46009
46070
  try {
46010
46071
  content = fs30.readFileSync(full, "utf8");
@@ -46022,7 +46083,7 @@ ${hintLines.join("\n")}` : "",
46022
46083
  }
46023
46084
  case "write_coordinator_prompt": {
46024
46085
  const fs30 = await import("fs");
46025
- const path40 = await import("path");
46086
+ const path41 = await import("path");
46026
46087
  const os30 = await import("os");
46027
46088
  const key = typeof args?.key === "string" ? args.key.trim() : "";
46028
46089
  const kind = args?.kind === "append" ? "append" : "override";
@@ -46030,9 +46091,9 @@ ${hintLines.join("\n")}` : "",
46030
46091
  if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
46031
46092
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
46032
46093
  }
46033
- const dir = path40.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46094
+ const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46034
46095
  const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
46035
- const full = path40.join(dir, filename);
46096
+ const full = path41.join(dir, filename);
46036
46097
  try {
46037
46098
  fs30.mkdirSync(dir, { recursive: true });
46038
46099
  if (content.trim()) {
@@ -47587,7 +47648,7 @@ ${ptyResult.output.slice(-2e3)}`);
47587
47648
  workspace
47588
47649
  };
47589
47650
  }
47590
- const { existsSync: existsSync42, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47651
+ const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47591
47652
  const { dirname: dirname14 } = await import("path");
47592
47653
  const mcpConfigPath = coordinatorSetup.configPath;
47593
47654
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -47630,7 +47691,7 @@ ${ptyResult.output.slice(-2e3)}`);
47630
47691
  if (hermesManualFallback) return returnManualFallback(message);
47631
47692
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
47632
47693
  }
47633
- const hadExistingMcpConfig = existsSync42(mcpConfigPath);
47694
+ const hadExistingMcpConfig = existsSync43(mcpConfigPath);
47634
47695
  let existingMcpConfig = hermesBaseConfig?.config || {};
47635
47696
  if (hermesBaseConfig) {
47636
47697
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
@@ -48148,7 +48209,7 @@ ${ptyResult.output.slice(-2e3)}`);
48148
48209
  const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
48149
48210
  const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
48150
48211
  const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
48151
- const { existsSync: existsSync42 } = await import("fs");
48212
+ const { existsSync: existsSync43 } = await import("fs");
48152
48213
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
48153
48214
  const mesh = meshRecord?.mesh;
48154
48215
  if (!mesh) return { success: false, error: "Mesh not found" };
@@ -48167,7 +48228,7 @@ ${ptyResult.output.slice(-2e3)}`);
48167
48228
  const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
48168
48229
  for (const item of derivation.items) {
48169
48230
  const workspace = item.workspace;
48170
- if (!workspace || !existsSync42(workspace)) continue;
48231
+ if (!workspace || !existsSync43(workspace)) continue;
48171
48232
  const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
48172
48233
  try {
48173
48234
  const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
@@ -49914,11 +49975,11 @@ var ProviderInstanceManager = class {
49914
49975
 
49915
49976
  // src/providers/version-archive.ts
49916
49977
  import * as fs25 from "fs";
49917
- import * as path35 from "path";
49978
+ import * as path36 from "path";
49918
49979
  import * as os28 from "os";
49919
49980
  import { platform as platform8 } from "os";
49920
49981
  import { exec as exec5 } from "child_process";
49921
- var ARCHIVE_PATH = path35.join(os28.homedir(), ".adhdev", "version-history.json");
49982
+ var ARCHIVE_PATH = path36.join(os28.homedir(), ".adhdev", "version-history.json");
49922
49983
  var MAX_ENTRIES_PER_PROVIDER = 20;
49923
49984
  var VersionArchive = class {
49924
49985
  history = {};
@@ -49965,7 +50026,7 @@ var VersionArchive = class {
49965
50026
  }
49966
50027
  save() {
49967
50028
  try {
49968
- fs25.mkdirSync(path35.dirname(ARCHIVE_PATH), { recursive: true });
50029
+ fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
49969
50030
  fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
49970
50031
  } catch {
49971
50032
  }
@@ -49989,7 +50050,7 @@ function findBinary2(name) {
49989
50050
  for (const p of paths) {
49990
50051
  if (!p) continue;
49991
50052
  for (const ext of exes) {
49992
- const fullPath = path35.join(p, name + ext);
50053
+ const fullPath = path36.join(p, name + ext);
49993
50054
  try {
49994
50055
  if (fs25.existsSync(fullPath)) {
49995
50056
  const stat2 = fs25.statSync(fullPath);
@@ -50038,7 +50099,7 @@ function checkPathExists2(paths) {
50038
50099
  for (const p of paths) {
50039
50100
  if (p.includes("*")) {
50040
50101
  const home = os28.homedir();
50041
- const resolved = p.replace(/\*/g, home.split(path35.sep).pop() || "");
50102
+ const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
50042
50103
  if (fs25.existsSync(resolved)) return resolved;
50043
50104
  } else {
50044
50105
  if (fs25.existsSync(p)) return p;
@@ -50048,7 +50109,7 @@ function checkPathExists2(paths) {
50048
50109
  }
50049
50110
  async function getMacAppVersion(appPath) {
50050
50111
  if (platform8() !== "darwin" || !appPath.endsWith(".app")) return null;
50051
- const plistPath = path35.join(appPath, "Contents", "Info.plist");
50112
+ const plistPath = path36.join(appPath, "Contents", "Info.plist");
50052
50113
  if (!fs25.existsSync(plistPath)) return null;
50053
50114
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
50054
50115
  return raw || null;
@@ -50074,7 +50135,7 @@ async function detectAllVersions(loader, archive) {
50074
50135
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
50075
50136
  let resolvedBin = cliBin;
50076
50137
  if (!resolvedBin && appPath && currentOs === "darwin") {
50077
- const bundled = path35.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
50138
+ const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
50078
50139
  if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
50079
50140
  }
50080
50141
  info.installed = !!(appPath || resolvedBin);
@@ -50115,7 +50176,7 @@ async function detectAllVersions(loader, archive) {
50115
50176
  // src/daemon/dev-server.ts
50116
50177
  import * as http2 from "http";
50117
50178
  import * as fs29 from "fs";
50118
- import * as path39 from "path";
50179
+ import * as path40 from "path";
50119
50180
  init_config();
50120
50181
 
50121
50182
  // src/daemon/scaffold-template.ts
@@ -50467,7 +50528,7 @@ init_logger();
50467
50528
  // src/daemon/dev-cdp-handlers.ts
50468
50529
  init_logger();
50469
50530
  import * as fs26 from "fs";
50470
- import * as path36 from "path";
50531
+ import * as path37 from "path";
50471
50532
  async function handleCdpEvaluate(ctx, req, res) {
50472
50533
  const body = await ctx.readBody(req);
50473
50534
  const { expression, timeout, ideType } = body;
@@ -50645,17 +50706,17 @@ async function handleScriptHints(ctx, type, _req, res) {
50645
50706
  return;
50646
50707
  }
50647
50708
  let scriptsPath = "";
50648
- const directScripts = path36.join(dir, "scripts.js");
50709
+ const directScripts = path37.join(dir, "scripts.js");
50649
50710
  if (fs26.existsSync(directScripts)) {
50650
50711
  scriptsPath = directScripts;
50651
50712
  } else {
50652
- const scriptsDir = path36.join(dir, "scripts");
50713
+ const scriptsDir = path37.join(dir, "scripts");
50653
50714
  if (fs26.existsSync(scriptsDir)) {
50654
50715
  const versions = fs26.readdirSync(scriptsDir).filter((d) => {
50655
- return fs26.statSync(path36.join(scriptsDir, d)).isDirectory();
50716
+ return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
50656
50717
  }).sort().reverse();
50657
50718
  for (const ver of versions) {
50658
- const p = path36.join(scriptsDir, ver, "scripts.js");
50719
+ const p = path37.join(scriptsDir, ver, "scripts.js");
50659
50720
  if (fs26.existsSync(p)) {
50660
50721
  scriptsPath = p;
50661
50722
  break;
@@ -51484,7 +51545,7 @@ async function handleDomContext(ctx, type, req, res) {
51484
51545
 
51485
51546
  // src/daemon/dev-cli-debug.ts
51486
51547
  import * as fs27 from "fs";
51487
- import * as path37 from "path";
51548
+ import * as path38 from "path";
51488
51549
  function slugifyFixtureName(value) {
51489
51550
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
51490
51551
  return normalized || `fixture-${Date.now()}`;
@@ -51494,11 +51555,11 @@ function getCliFixtureDir(ctx, type) {
51494
51555
  if (!providerDir) {
51495
51556
  throw new Error(`Provider directory not found for '${type}'`);
51496
51557
  }
51497
- return path37.join(providerDir, "fixtures");
51558
+ return path38.join(providerDir, "fixtures");
51498
51559
  }
51499
51560
  function readCliFixture(ctx, type, name) {
51500
51561
  const fixtureDir = getCliFixtureDir(ctx, type);
51501
- const filePath = path37.join(fixtureDir, `${name}.json`);
51562
+ const filePath = path38.join(fixtureDir, `${name}.json`);
51502
51563
  if (!fs27.existsSync(filePath)) {
51503
51564
  throw new Error(`Fixture not found: ${filePath}`);
51504
51565
  }
@@ -52274,7 +52335,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
52274
52335
  },
52275
52336
  notes: typeof body?.notes === "string" ? body.notes : void 0
52276
52337
  };
52277
- const filePath = path37.join(fixtureDir, `${name}.json`);
52338
+ const filePath = path38.join(fixtureDir, `${name}.json`);
52278
52339
  fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
52279
52340
  ctx.json(res, 200, {
52280
52341
  saved: true,
@@ -52298,7 +52359,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
52298
52359
  return;
52299
52360
  }
52300
52361
  const fixtures = fs27.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
52301
- const fullPath = path37.join(fixtureDir, file);
52362
+ const fullPath = path38.join(fixtureDir, file);
52302
52363
  try {
52303
52364
  const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
52304
52365
  return {
@@ -52434,7 +52495,7 @@ async function handleCliRaw(ctx, req, res) {
52434
52495
 
52435
52496
  // src/daemon/dev-auto-implement.ts
52436
52497
  import * as fs28 from "fs";
52437
- import * as path38 from "path";
52498
+ import * as path39 from "path";
52438
52499
  import * as os29 from "os";
52439
52500
  import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS7, DEFAULT_SESSION_HOST_ROWS as DEFAULT_SESSION_HOST_ROWS7 } from "@adhdev/session-host-core";
52440
52501
  function getAutoImplPid(ctx) {
@@ -52485,22 +52546,22 @@ function getLatestScriptVersionDir(scriptsDir) {
52485
52546
  if (!fs28.existsSync(scriptsDir)) return null;
52486
52547
  const versions = fs28.readdirSync(scriptsDir).filter((d) => {
52487
52548
  try {
52488
- return fs28.statSync(path38.join(scriptsDir, d)).isDirectory();
52549
+ return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
52489
52550
  } catch {
52490
52551
  return false;
52491
52552
  }
52492
52553
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
52493
52554
  if (versions.length === 0) return null;
52494
- return path38.join(scriptsDir, versions[0]);
52555
+ return path39.join(scriptsDir, versions[0]);
52495
52556
  }
52496
52557
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
52497
- const canonicalUserDir = path38.resolve(ctx.providerLoader.getUserProviderDir(category, type));
52498
- const desiredDir = requestedDir ? path38.resolve(requestedDir) : canonicalUserDir;
52499
- const upstreamRoot = path38.resolve(ctx.providerLoader.getUpstreamDir());
52500
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path38.sep}`)) {
52558
+ const canonicalUserDir = path39.resolve(ctx.providerLoader.getUserProviderDir(category, type));
52559
+ const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
52560
+ const upstreamRoot = path39.resolve(ctx.providerLoader.getUpstreamDir());
52561
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
52501
52562
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
52502
52563
  }
52503
- if (path38.basename(desiredDir) !== type) {
52564
+ if (path39.basename(desiredDir) !== type) {
52504
52565
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
52505
52566
  }
52506
52567
  const sourceDir = ctx.findProviderDir(type);
@@ -52508,11 +52569,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
52508
52569
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
52509
52570
  }
52510
52571
  if (!fs28.existsSync(desiredDir)) {
52511
- fs28.mkdirSync(path38.dirname(desiredDir), { recursive: true });
52572
+ fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
52512
52573
  fs28.cpSync(sourceDir, desiredDir, { recursive: true });
52513
52574
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
52514
52575
  }
52515
- const providerJson = path38.join(desiredDir, "provider.json");
52576
+ const providerJson = path39.join(desiredDir, "provider.json");
52516
52577
  if (!fs28.existsSync(providerJson)) {
52517
52578
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
52518
52579
  }
@@ -52523,13 +52584,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
52523
52584
  const refDir = ctx.findProviderDir(referenceType);
52524
52585
  if (!refDir || !fs28.existsSync(refDir)) return {};
52525
52586
  const referenceScripts = {};
52526
- const scriptsDir = path38.join(refDir, "scripts");
52587
+ const scriptsDir = path39.join(refDir, "scripts");
52527
52588
  const latestDir = getLatestScriptVersionDir(scriptsDir);
52528
52589
  if (!latestDir) return referenceScripts;
52529
52590
  for (const file of fs28.readdirSync(latestDir)) {
52530
52591
  if (!file.endsWith(".js")) continue;
52531
52592
  try {
52532
- referenceScripts[file] = fs28.readFileSync(path38.join(latestDir, file), "utf-8");
52593
+ referenceScripts[file] = fs28.readFileSync(path39.join(latestDir, file), "utf-8");
52533
52594
  } catch {
52534
52595
  }
52535
52596
  }
@@ -52637,9 +52698,9 @@ async function handleAutoImplement(ctx, type, req, res) {
52637
52698
  });
52638
52699
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
52639
52700
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
52640
- const tmpDir = path38.join(os29.tmpdir(), "adhdev-autoimpl");
52701
+ const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
52641
52702
  if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
52642
- const promptFile = path38.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
52703
+ const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
52643
52704
  fs28.writeFileSync(promptFile, prompt, "utf-8");
52644
52705
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
52645
52706
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -53071,7 +53132,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53071
53132
  setMode: "set_mode.js"
53072
53133
  };
53073
53134
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
53074
- const scriptsDir = path38.join(providerDir, "scripts");
53135
+ const scriptsDir = path39.join(providerDir, "scripts");
53075
53136
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
53076
53137
  if (latestScriptsDir) {
53077
53138
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -53082,7 +53143,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53082
53143
  for (const file of fs28.readdirSync(latestScriptsDir)) {
53083
53144
  if (file.endsWith(".js") && targetFileNames.has(file)) {
53084
53145
  try {
53085
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53146
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53086
53147
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53087
53148
  lines.push("```javascript");
53088
53149
  lines.push(content);
@@ -53099,7 +53160,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53099
53160
  lines.push("");
53100
53161
  for (const file of refFiles) {
53101
53162
  try {
53102
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53163
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53103
53164
  lines.push(`### \`${file}\` \u{1F512}`);
53104
53165
  lines.push("```javascript");
53105
53166
  lines.push(content);
@@ -53140,10 +53201,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53140
53201
  lines.push("");
53141
53202
  }
53142
53203
  }
53143
- const docsDir = path38.join(providerDir, "../../docs");
53204
+ const docsDir = path39.join(providerDir, "../../docs");
53144
53205
  const loadGuide = (name) => {
53145
53206
  try {
53146
- const p = path38.join(docsDir, name);
53207
+ const p = path39.join(docsDir, name);
53147
53208
  if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
53148
53209
  } catch {
53149
53210
  }
@@ -53380,7 +53441,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53380
53441
  parseApproval: "parse_approval.js"
53381
53442
  };
53382
53443
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
53383
- const scriptsDir = path38.join(providerDir, "scripts");
53444
+ const scriptsDir = path39.join(providerDir, "scripts");
53384
53445
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
53385
53446
  if (latestScriptsDir) {
53386
53447
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -53392,7 +53453,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53392
53453
  if (!file.endsWith(".js")) continue;
53393
53454
  if (!targetFileNames.has(file)) continue;
53394
53455
  try {
53395
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53456
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53396
53457
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53397
53458
  lines.push("```javascript");
53398
53459
  lines.push(content);
@@ -53408,7 +53469,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53408
53469
  lines.push("");
53409
53470
  for (const file of refFiles) {
53410
53471
  try {
53411
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53472
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53412
53473
  lines.push(`### \`${file}\` \u{1F512}`);
53413
53474
  lines.push("```javascript");
53414
53475
  lines.push(content);
@@ -53441,10 +53502,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53441
53502
  lines.push("");
53442
53503
  }
53443
53504
  }
53444
- const docsDir = path38.join(providerDir, "../../docs");
53505
+ const docsDir = path39.join(providerDir, "../../docs");
53445
53506
  const loadGuide = (name) => {
53446
53507
  try {
53447
- const p = path38.join(docsDir, name);
53508
+ const p = path39.join(docsDir, name);
53448
53509
  if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
53449
53510
  } catch {
53450
53511
  }
@@ -53891,8 +53952,8 @@ var DevServer = class _DevServer {
53891
53952
  }
53892
53953
  getEndpointList() {
53893
53954
  return this.routes.map((r) => {
53894
- const path40 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
53895
- return `${r.method.padEnd(5)} ${path40}`;
53955
+ const path41 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
53956
+ return `${r.method.padEnd(5)} ${path41}`;
53896
53957
  });
53897
53958
  }
53898
53959
  async start(port = DEV_SERVER_PORT) {
@@ -54180,12 +54241,12 @@ var DevServer = class _DevServer {
54180
54241
  // ─── DevConsole SPA ───
54181
54242
  getConsoleDistDir() {
54182
54243
  const candidates = [
54183
- path39.resolve(__dirname, "../../web-devconsole/dist"),
54184
- path39.resolve(__dirname, "../../../web-devconsole/dist"),
54185
- path39.join(process.cwd(), "packages/web-devconsole/dist")
54244
+ path40.resolve(__dirname, "../../web-devconsole/dist"),
54245
+ path40.resolve(__dirname, "../../../web-devconsole/dist"),
54246
+ path40.join(process.cwd(), "packages/web-devconsole/dist")
54186
54247
  ];
54187
54248
  for (const dir of candidates) {
54188
- if (fs29.existsSync(path39.join(dir, "index.html"))) return dir;
54249
+ if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
54189
54250
  }
54190
54251
  return null;
54191
54252
  }
@@ -54195,7 +54256,7 @@ var DevServer = class _DevServer {
54195
54256
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
54196
54257
  return;
54197
54258
  }
54198
- const htmlPath = path39.join(distDir, "index.html");
54259
+ const htmlPath = path40.join(distDir, "index.html");
54199
54260
  try {
54200
54261
  const html = fs29.readFileSync(htmlPath, "utf-8");
54201
54262
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -54220,15 +54281,15 @@ var DevServer = class _DevServer {
54220
54281
  this.json(res, 404, { error: "Not found" });
54221
54282
  return;
54222
54283
  }
54223
- const safePath = path39.normalize(pathname).replace(/^\.\.\//, "");
54224
- const filePath = path39.join(distDir, safePath);
54284
+ const safePath = path40.normalize(pathname).replace(/^\.\.\//, "");
54285
+ const filePath = path40.join(distDir, safePath);
54225
54286
  if (!filePath.startsWith(distDir)) {
54226
54287
  this.json(res, 403, { error: "Forbidden" });
54227
54288
  return;
54228
54289
  }
54229
54290
  try {
54230
54291
  const content = fs29.readFileSync(filePath);
54231
- const ext = path39.extname(filePath);
54292
+ const ext = path40.extname(filePath);
54232
54293
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
54233
54294
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
54234
54295
  res.end(content);
@@ -54341,9 +54402,9 @@ var DevServer = class _DevServer {
54341
54402
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
54342
54403
  if (entry.isDirectory()) {
54343
54404
  files.push({ path: rel, size: 0, type: "dir" });
54344
- scan(path39.join(d, entry.name), rel);
54405
+ scan(path40.join(d, entry.name), rel);
54345
54406
  } else {
54346
- const stat2 = fs29.statSync(path39.join(d, entry.name));
54407
+ const stat2 = fs29.statSync(path40.join(d, entry.name));
54347
54408
  files.push({ path: rel, size: stat2.size, type: "file" });
54348
54409
  }
54349
54410
  }
@@ -54366,7 +54427,7 @@ var DevServer = class _DevServer {
54366
54427
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
54367
54428
  return;
54368
54429
  }
54369
- const fullPath = path39.resolve(dir, path39.normalize(filePath));
54430
+ const fullPath = path40.resolve(dir, path40.normalize(filePath));
54370
54431
  if (!fullPath.startsWith(dir)) {
54371
54432
  this.json(res, 403, { error: "Forbidden" });
54372
54433
  return;
@@ -54391,14 +54452,14 @@ var DevServer = class _DevServer {
54391
54452
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
54392
54453
  return;
54393
54454
  }
54394
- const fullPath = path39.resolve(dir, path39.normalize(filePath));
54455
+ const fullPath = path40.resolve(dir, path40.normalize(filePath));
54395
54456
  if (!fullPath.startsWith(dir)) {
54396
54457
  this.json(res, 403, { error: "Forbidden" });
54397
54458
  return;
54398
54459
  }
54399
54460
  try {
54400
54461
  if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
54401
- fs29.mkdirSync(path39.dirname(fullPath), { recursive: true });
54462
+ fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
54402
54463
  fs29.writeFileSync(fullPath, content, "utf-8");
54403
54464
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
54404
54465
  this.providerLoader.reload();
@@ -54415,7 +54476,7 @@ var DevServer = class _DevServer {
54415
54476
  return;
54416
54477
  }
54417
54478
  for (const name of ["scripts.js", "provider.json"]) {
54418
- const p = path39.join(dir, name);
54479
+ const p = path40.join(dir, name);
54419
54480
  if (fs29.existsSync(p)) {
54420
54481
  const source = fs29.readFileSync(p, "utf-8");
54421
54482
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -54436,8 +54497,8 @@ var DevServer = class _DevServer {
54436
54497
  this.json(res, 404, { error: `Provider not found: ${type}` });
54437
54498
  return;
54438
54499
  }
54439
- const target = fs29.existsSync(path39.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
54440
- const targetPath = path39.join(dir, target);
54500
+ const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
54501
+ const targetPath = path40.join(dir, target);
54441
54502
  try {
54442
54503
  if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
54443
54504
  fs29.writeFileSync(targetPath, source, "utf-8");
@@ -54584,7 +54645,7 @@ var DevServer = class _DevServer {
54584
54645
  }
54585
54646
  let targetDir;
54586
54647
  targetDir = this.providerLoader.getUserProviderDir(category, type);
54587
- const jsonPath = path39.join(targetDir, "provider.json");
54648
+ const jsonPath = path40.join(targetDir, "provider.json");
54588
54649
  if (fs29.existsSync(jsonPath)) {
54589
54650
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
54590
54651
  return;
@@ -54596,8 +54657,8 @@ var DevServer = class _DevServer {
54596
54657
  const createdFiles = ["provider.json"];
54597
54658
  if (result.files) {
54598
54659
  for (const [relPath, content] of Object.entries(result.files)) {
54599
- const fullPath = path39.join(targetDir, relPath);
54600
- fs29.mkdirSync(path39.dirname(fullPath), { recursive: true });
54660
+ const fullPath = path40.join(targetDir, relPath);
54661
+ fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
54601
54662
  fs29.writeFileSync(fullPath, content, "utf-8");
54602
54663
  createdFiles.push(relPath);
54603
54664
  }
@@ -54650,22 +54711,22 @@ var DevServer = class _DevServer {
54650
54711
  if (!fs29.existsSync(scriptsDir)) return null;
54651
54712
  const versions = fs29.readdirSync(scriptsDir).filter((d) => {
54652
54713
  try {
54653
- return fs29.statSync(path39.join(scriptsDir, d)).isDirectory();
54714
+ return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
54654
54715
  } catch {
54655
54716
  return false;
54656
54717
  }
54657
54718
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
54658
54719
  if (versions.length === 0) return null;
54659
- return path39.join(scriptsDir, versions[0]);
54720
+ return path40.join(scriptsDir, versions[0]);
54660
54721
  }
54661
54722
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
54662
- const canonicalUserDir = path39.resolve(this.providerLoader.getUserProviderDir(category, type));
54663
- const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
54664
- const upstreamRoot = path39.resolve(this.providerLoader.getUpstreamDir());
54665
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
54723
+ const canonicalUserDir = path40.resolve(this.providerLoader.getUserProviderDir(category, type));
54724
+ const desiredDir = requestedDir ? path40.resolve(requestedDir) : canonicalUserDir;
54725
+ const upstreamRoot = path40.resolve(this.providerLoader.getUpstreamDir());
54726
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path40.sep}`)) {
54666
54727
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
54667
54728
  }
54668
- if (path39.basename(desiredDir) !== type) {
54729
+ if (path40.basename(desiredDir) !== type) {
54669
54730
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
54670
54731
  }
54671
54732
  const sourceDir = this.findProviderDir(type);
@@ -54673,11 +54734,11 @@ var DevServer = class _DevServer {
54673
54734
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
54674
54735
  }
54675
54736
  if (!fs29.existsSync(desiredDir)) {
54676
- fs29.mkdirSync(path39.dirname(desiredDir), { recursive: true });
54737
+ fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
54677
54738
  fs29.cpSync(sourceDir, desiredDir, { recursive: true });
54678
54739
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
54679
54740
  }
54680
- const providerJson = path39.join(desiredDir, "provider.json");
54741
+ const providerJson = path40.join(desiredDir, "provider.json");
54681
54742
  if (!fs29.existsSync(providerJson)) {
54682
54743
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
54683
54744
  }
@@ -54713,7 +54774,7 @@ var DevServer = class _DevServer {
54713
54774
  setMode: "set_mode.js"
54714
54775
  };
54715
54776
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
54716
- const scriptsDir = path39.join(providerDir, "scripts");
54777
+ const scriptsDir = path40.join(providerDir, "scripts");
54717
54778
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
54718
54779
  if (latestScriptsDir) {
54719
54780
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -54724,7 +54785,7 @@ var DevServer = class _DevServer {
54724
54785
  for (const file of fs29.readdirSync(latestScriptsDir)) {
54725
54786
  if (file.endsWith(".js") && targetFileNames.has(file)) {
54726
54787
  try {
54727
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
54788
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
54728
54789
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
54729
54790
  lines.push("```javascript");
54730
54791
  lines.push(content);
@@ -54741,7 +54802,7 @@ var DevServer = class _DevServer {
54741
54802
  lines.push("");
54742
54803
  for (const file of refFiles) {
54743
54804
  try {
54744
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
54805
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
54745
54806
  lines.push(`### \`${file}\` \u{1F512}`);
54746
54807
  lines.push("```javascript");
54747
54808
  lines.push(content);
@@ -54782,10 +54843,10 @@ var DevServer = class _DevServer {
54782
54843
  lines.push("");
54783
54844
  }
54784
54845
  }
54785
- const docsDir = path39.join(providerDir, "../../docs");
54846
+ const docsDir = path40.join(providerDir, "../../docs");
54786
54847
  const loadGuide = (name) => {
54787
54848
  try {
54788
- const p = path39.join(docsDir, name);
54849
+ const p = path40.join(docsDir, name);
54789
54850
  if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
54790
54851
  } catch {
54791
54852
  }
@@ -54959,7 +55020,7 @@ var DevServer = class _DevServer {
54959
55020
  parseApproval: "parse_approval.js"
54960
55021
  };
54961
55022
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
54962
- const scriptsDir = path39.join(providerDir, "scripts");
55023
+ const scriptsDir = path40.join(providerDir, "scripts");
54963
55024
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
54964
55025
  if (latestScriptsDir) {
54965
55026
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -54971,7 +55032,7 @@ var DevServer = class _DevServer {
54971
55032
  if (!file.endsWith(".js")) continue;
54972
55033
  if (!targetFileNames.has(file)) continue;
54973
55034
  try {
54974
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55035
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
54975
55036
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
54976
55037
  lines.push("```javascript");
54977
55038
  lines.push(content);
@@ -54987,7 +55048,7 @@ var DevServer = class _DevServer {
54987
55048
  lines.push("");
54988
55049
  for (const file of refFiles) {
54989
55050
  try {
54990
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55051
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
54991
55052
  lines.push(`### \`${file}\` \u{1F512}`);
54992
55053
  lines.push("```javascript");
54993
55054
  lines.push(content);
@@ -55020,10 +55081,10 @@ var DevServer = class _DevServer {
55020
55081
  lines.push("");
55021
55082
  }
55022
55083
  }
55023
- const docsDir = path39.join(providerDir, "../../docs");
55084
+ const docsDir = path40.join(providerDir, "../../docs");
55024
55085
  const loadGuide = (name) => {
55025
55086
  try {
55026
- const p = path39.join(docsDir, name);
55087
+ const p = path40.join(docsDir, name);
55027
55088
  if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
55028
55089
  } catch {
55029
55090
  }
@@ -55287,6 +55348,7 @@ init_pty_transport();
55287
55348
 
55288
55349
  // src/cli-adapters/session-host-transport.ts
55289
55350
  init_logger();
55351
+ init_resolve_executable();
55290
55352
  import {
55291
55353
  SessionHostClient
55292
55354
  } from "@adhdev/session-host-core";
@@ -55669,7 +55731,7 @@ var SessionHostPtyTransportFactory = class {
55669
55731
  spawn(command, args, spawnOptions) {
55670
55732
  return new SessionHostRuntimeTransport({
55671
55733
  ...this.options,
55672
- command,
55734
+ command: resolveWin32Executable(command),
55673
55735
  args,
55674
55736
  spawnOptions
55675
55737
  });
@@ -56712,7 +56774,7 @@ import { readFileSync as readFileSync33 } from "fs";
56712
56774
  import { dirname as dirname12, resolve as resolve22 } from "path";
56713
56775
 
56714
56776
  // src/providers/sdk/v1/validators/taint.ts
56715
- import { readFileSync as readFileSync34, existsSync as existsSync41 } from "fs";
56777
+ import { readFileSync as readFileSync34, existsSync as existsSync42 } from "fs";
56716
56778
  import { resolve as resolve23, dirname as dirname13, join as join44 } from "path";
56717
56779
 
56718
56780
  // src/providers/sdk/v1/validators/index.ts