@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.js CHANGED
@@ -82,6 +82,7 @@ var init_repo_mesh_types = __esm({
82
82
  // src/git/git-executor.ts
83
83
  var git_executor_exports = {};
84
84
  __export(git_executor_exports, {
85
+ GIT_STATUS_TIMEOUT_MS: () => GIT_STATUS_TIMEOUT_MS,
85
86
  GitCommandError: () => GitCommandError,
86
87
  isPathInside: () => isPathInside,
87
88
  normalizeGitOutput: () => normalizeGitOutput,
@@ -246,7 +247,7 @@ function mapExecError(error, cwd, argv, behavior) {
246
247
  cause: error
247
248
  });
248
249
  }
249
- var import_node_child_process, import_node_fs, import_promises, path, import_node_util, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError;
250
+ var import_node_child_process, import_node_fs, import_promises, path, import_node_util, 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";
@@ -258,6 +259,7 @@ var init_git_executor = __esm({
258
259
  execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
259
260
  DEFAULT_TIMEOUT_MS = 5e3;
260
261
  DEFAULT_MAX_BUFFER = 1024 * 1024;
262
+ GIT_STATUS_TIMEOUT_MS = process.platform === "win32" ? 3e4 : 2e4;
261
263
  GitCommandError = class extends Error {
262
264
  reason;
263
265
  stdout;
@@ -293,10 +295,10 @@ function readInjected(value) {
293
295
  }
294
296
  function getDaemonBuildInfo() {
295
297
  if (cached) return cached;
296
- const commit = readInjected(true ? "72f1b6e675346bbc37de202b195675150ebb3d82" : void 0) ?? "unknown";
297
- const commitShort = readInjected(true ? "72f1b6e6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
298
- const version = readInjected(true ? "0.9.82-rc.301" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
299
- const builtAt = readInjected(true ? "2026-06-16T23:37:22.009Z" : void 0);
298
+ const commit = readInjected(true ? "21741b4b2d3c1f2ed8a280045e6158b2730391ed" : void 0) ?? "unknown";
299
+ const commitShort = readInjected(true ? "21741b4b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
300
+ const version = readInjected(true ? "0.9.82-rc.303" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
301
+ const builtAt = readInjected(true ? "2026-06-17T04:16:06.174Z" : void 0);
300
302
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
301
303
  return cached;
302
304
  }
@@ -308,64 +310,79 @@ var init_build_info = __esm({
308
310
  });
309
311
 
310
312
  // src/git/git-status.ts
313
+ function isTransientGitFailure(error) {
314
+ return error.reason === "timeout" || error.reason === "git_command_failed";
315
+ }
311
316
  async function getGitRepoStatus(workspace, options = {}) {
312
317
  const lastCheckedAt = Date.now();
313
318
  const includeSubmodules = options.includeSubmodules !== false;
319
+ const effectiveOptions = options.timeoutMs === void 0 ? { ...options, timeoutMs: GIT_STATUS_TIMEOUT_MS } : options;
314
320
  try {
315
- const repo = await resolveGitRepository(workspace, options);
316
- let parsed = await readPorcelainStatus(repo, options);
317
- let upstreamProbe = getInitialUpstreamProbe(parsed);
318
- if (options.refreshUpstream) {
319
- upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
320
- if (upstreamProbe.upstreamStatus === "fresh") {
321
- parsed = await readPorcelainStatus(repo, options);
322
- }
323
- }
324
- const head = await readHead(repo, options);
325
- const stashCount = await readStashCount(repo, options);
326
- let submodules;
327
- if (includeSubmodules) {
328
- submodules = await getSubmoduleStatuses(repo, options);
329
- }
330
- const submoduleDirty = (submodules || []).some((submodule) => submodule.dirty || submodule.outOfSync || !!submodule.error);
331
- const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0 || stashCount > 0 || submoduleDirty;
332
- const daemonBuildBehind = await detectDaemonBuildBehind(repo, submodules, options);
333
- return {
334
- workspace: repo.workspace,
335
- repoRoot: repo.repoRoot,
336
- isGitRepo: true,
337
- branch: parsed.branch,
338
- headCommit: head.commit,
339
- headMessage: head.message,
340
- upstream: parsed.upstream,
341
- upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
342
- upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
343
- upstreamFetchError: upstreamProbe.upstreamFetchError,
344
- ahead: parsed.ahead,
345
- behind: parsed.behind,
346
- staged: parsed.staged,
347
- modified: parsed.modified,
348
- untracked: parsed.untracked,
349
- deleted: parsed.deleted,
350
- renamed: parsed.renamed,
351
- dirty,
352
- hasConflicts: parsed.conflictFiles.length > 0,
353
- conflictFiles: parsed.conflictFiles,
354
- stashCount,
355
- lastCheckedAt,
356
- submodules,
357
- ...daemonBuildBehind ? { daemonBuildBehind } : {}
358
- };
321
+ const repo = await resolveGitRepository(workspace, effectiveOptions);
322
+ const status = await collectGitRepoStatus(repo, includeSubmodules, lastCheckedAt, effectiveOptions);
323
+ lastKnownGoodStatus.set(workspace, status);
324
+ return status;
359
325
  } catch (error) {
360
- if (error instanceof GitCommandError) {
361
- return emptyStatus(workspace, lastCheckedAt, error);
326
+ const gitError = error instanceof GitCommandError ? error : new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error });
327
+ if (isTransientGitFailure(gitError)) {
328
+ const cached2 = lastKnownGoodStatus.get(workspace);
329
+ if (cached2) {
330
+ return {
331
+ ...cached2,
332
+ lastCheckedAt,
333
+ upstreamStatus: "unavailable",
334
+ error: gitError.stderr || gitError.message,
335
+ reason: gitError.reason
336
+ };
337
+ }
362
338
  }
363
- return emptyStatus(
364
- workspace,
365
- lastCheckedAt,
366
- new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error })
367
- );
339
+ return emptyStatus(workspace, lastCheckedAt, gitError);
340
+ }
341
+ }
342
+ async function collectGitRepoStatus(repo, includeSubmodules, lastCheckedAt, options) {
343
+ let parsed = await readPorcelainStatus(repo, options);
344
+ let upstreamProbe = getInitialUpstreamProbe(parsed);
345
+ if (options.refreshUpstream) {
346
+ upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
347
+ if (upstreamProbe.upstreamStatus === "fresh") {
348
+ parsed = await readPorcelainStatus(repo, options);
349
+ }
350
+ }
351
+ const head = await readHead(repo, options);
352
+ const stashCount = await readStashCount(repo, options);
353
+ let submodules;
354
+ if (includeSubmodules) {
355
+ submodules = await getSubmoduleStatuses(repo, options);
368
356
  }
357
+ const submoduleDirty = (submodules || []).some((submodule) => submodule.dirty || submodule.outOfSync || !!submodule.error);
358
+ const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0 || stashCount > 0 || submoduleDirty;
359
+ const daemonBuildBehind = await detectDaemonBuildBehind(repo, submodules, options);
360
+ return {
361
+ workspace: repo.workspace,
362
+ repoRoot: repo.repoRoot,
363
+ isGitRepo: true,
364
+ branch: parsed.branch,
365
+ headCommit: head.commit,
366
+ headMessage: head.message,
367
+ upstream: parsed.upstream,
368
+ upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
369
+ upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
370
+ upstreamFetchError: upstreamProbe.upstreamFetchError,
371
+ ahead: parsed.ahead,
372
+ behind: parsed.behind,
373
+ staged: parsed.staged,
374
+ modified: parsed.modified,
375
+ untracked: parsed.untracked,
376
+ deleted: parsed.deleted,
377
+ renamed: parsed.renamed,
378
+ dirty,
379
+ hasConflicts: parsed.conflictFiles.length > 0,
380
+ conflictFiles: parsed.conflictFiles,
381
+ stashCount,
382
+ lastCheckedAt,
383
+ submodules,
384
+ ...daemonBuildBehind ? { daemonBuildBehind } : {}
385
+ };
369
386
  }
370
387
  function isNonRuntimeRootFile(file) {
371
388
  const base = file.slice(file.lastIndexOf("/") + 1);
@@ -607,7 +624,7 @@ function emptyStatus(workspace, lastCheckedAt, error) {
607
624
  async function getSubmoduleStatuses(repo, options) {
608
625
  if (!repo.repoRoot) return [];
609
626
  try {
610
- const result = await runGit(repo, ["submodule", "status", "--recursive"], options);
627
+ const result = await runGit(repo, ["submodule", "status"], options);
611
628
  const submodules = parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
612
629
  await Promise.all(submodules.map((submodule) => enrichSubmoduleWorktreeStatus(repo, submodule, options)));
613
630
  return submodules;
@@ -638,12 +655,12 @@ function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
638
655
  if (!match) continue;
639
656
  const prefix = match[1];
640
657
  const commit = match[2];
641
- const path40 = match[3];
642
- if (ignoreSet.has(path40)) continue;
658
+ const path41 = match[3];
659
+ if (ignoreSet.has(path41)) continue;
643
660
  submodules.push({
644
- path: path40,
661
+ path: path41,
645
662
  commit,
646
- repoPath: repoRoot + "/" + path40,
663
+ repoPath: repoRoot + "/" + path41,
647
664
  dirty: prefix === "U",
648
665
  outOfSync: prefix === "-" || prefix === "+",
649
666
  lastCheckedAt: Date.now()
@@ -651,12 +668,13 @@ function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
651
668
  }
652
669
  return submodules;
653
670
  }
654
- var DAEMON_RUNTIME_PACKAGES, WEB_ONLY_PACKAGES;
671
+ var lastKnownGoodStatus, DAEMON_RUNTIME_PACKAGES, WEB_ONLY_PACKAGES;
655
672
  var init_git_status = __esm({
656
673
  "src/git/git-status.ts"() {
657
674
  "use strict";
658
675
  init_git_executor();
659
676
  init_build_info();
677
+ lastKnownGoodStatus = /* @__PURE__ */ new Map();
660
678
  DAEMON_RUNTIME_PACKAGES = /* @__PURE__ */ new Set([
661
679
  "daemon-core",
662
680
  "daemon-standalone",
@@ -1465,10 +1483,10 @@ function getMeshConfigPath() {
1465
1483
  return (0, import_path2.join)(getConfigDir(), "meshes.json");
1466
1484
  }
1467
1485
  function loadMeshConfig() {
1468
- const path40 = getMeshConfigPath();
1469
- if (!(0, import_fs2.existsSync)(path40)) return { meshes: [] };
1486
+ const path41 = getMeshConfigPath();
1487
+ if (!(0, import_fs2.existsSync)(path41)) return { meshes: [] };
1470
1488
  try {
1471
- const raw = JSON.parse((0, import_fs2.readFileSync)(path40, "utf-8"));
1489
+ const raw = JSON.parse((0, import_fs2.readFileSync)(path41, "utf-8"));
1472
1490
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
1473
1491
  return raw;
1474
1492
  } catch {
@@ -1486,16 +1504,16 @@ function normalizeCapabilityTags(value) {
1486
1504
  return tags.length ? tags : void 0;
1487
1505
  }
1488
1506
  function saveMeshConfig(config) {
1489
- const path40 = getMeshConfigPath();
1490
- (0, import_fs2.writeFileSync)(path40, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
1507
+ const path41 = getMeshConfigPath();
1508
+ (0, import_fs2.writeFileSync)(path41, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
1491
1509
  }
1492
1510
  function normalizeRepoIdentity(remoteUrl) {
1493
1511
  let identity = remoteUrl.trim();
1494
1512
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
1495
1513
  try {
1496
1514
  const url = new URL(identity);
1497
- const path40 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
1498
- return `${url.hostname}/${path40}`;
1515
+ const path41 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
1516
+ return `${url.hostname}/${path41}`;
1499
1517
  } catch {
1500
1518
  }
1501
1519
  }
@@ -2177,10 +2195,10 @@ function rotateArchiveFile(meshId, archivePath) {
2177
2195
  }
2178
2196
  }
2179
2197
  function readArchivedCounts(meshId) {
2180
- const path40 = getArchivedCountsPath(meshId);
2181
- if (!(0, import_fs3.existsSync)(path40)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2198
+ const path41 = getArchivedCountsPath(meshId);
2199
+ if (!(0, import_fs3.existsSync)(path41)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2182
2200
  try {
2183
- return JSON.parse((0, import_fs3.readFileSync)(path40, "utf-8"));
2201
+ return JSON.parse((0, import_fs3.readFileSync)(path41, "utf-8"));
2184
2202
  } catch {
2185
2203
  return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
2186
2204
  }
@@ -3585,10 +3603,10 @@ var init_mesh_runtime_store = __esm({
3585
3603
  this.migratedMeshIds.add(meshId);
3586
3604
  const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
3587
3605
  if (count.count > 0) return;
3588
- const path40 = legacyQueuePath(meshId);
3589
- if (!(0, import_fs4.existsSync)(path40)) return;
3606
+ const path41 = legacyQueuePath(meshId);
3607
+ if (!(0, import_fs4.existsSync)(path41)) return;
3590
3608
  try {
3591
- const entries = JSON.parse((0, import_fs4.readFileSync)(path40, "utf-8"));
3609
+ const entries = JSON.parse((0, import_fs4.readFileSync)(path41, "utf-8"));
3592
3610
  if (!Array.isArray(entries)) return;
3593
3611
  const insert = this.db.prepare(`
3594
3612
  INSERT OR REPLACE INTO mesh_queue (
@@ -5341,8 +5359,8 @@ function resolveMeshCoordinatorSetup(options) {
5341
5359
  }
5342
5360
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
5343
5361
  if (mcpConfig.mode === "auto_import") {
5344
- const path40 = mcpConfig.path?.trim();
5345
- if (!path40) {
5362
+ const path41 = mcpConfig.path?.trim();
5363
+ if (!path41) {
5346
5364
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
5347
5365
  }
5348
5366
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -5362,7 +5380,7 @@ function resolveMeshCoordinatorSetup(options) {
5362
5380
  return {
5363
5381
  kind: "auto_import",
5364
5382
  serverName,
5365
- configPath: resolveMcpConfigPath(path40, workspace),
5383
+ configPath: resolveMcpConfigPath(path41, workspace),
5366
5384
  configFormat: mcpConfig.format,
5367
5385
  mcpServer
5368
5386
  };
@@ -6375,12 +6393,12 @@ function readGitSubmodules(value, parentRepoRoot) {
6375
6393
  if (!Array.isArray(value)) return void 0;
6376
6394
  const submodules = value.map((entry) => {
6377
6395
  const submodule = readRecord3(entry);
6378
- const path40 = readString5(submodule.path);
6396
+ const path41 = readString5(submodule.path);
6379
6397
  const commit = readString5(submodule.commit);
6380
- const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
6381
- if (!path40 || !commit) return null;
6398
+ const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path41);
6399
+ if (!path41 || !commit) return null;
6382
6400
  const result = {
6383
- path: path40,
6401
+ path: path41,
6384
6402
  commit,
6385
6403
  dirty: readBoolean(submodule.dirty) ?? false,
6386
6404
  outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
@@ -6779,10 +6797,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
6779
6797
  const primaryDaemonId = daemonIds[0];
6780
6798
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
6781
6799
  const events = [];
6782
- for (const path40 of paths) {
6783
- if (!(0, import_fs8.existsSync)(path40)) continue;
6800
+ for (const path41 of paths) {
6801
+ if (!(0, import_fs8.existsSync)(path41)) continue;
6784
6802
  try {
6785
- const raw = (0, import_fs8.readFileSync)(path40, "utf-8");
6803
+ const raw = (0, import_fs8.readFileSync)(path41, "utf-8");
6786
6804
  const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
6787
6805
  try {
6788
6806
  return [JSON.parse(line)];
@@ -6790,7 +6808,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
6790
6808
  return [];
6791
6809
  }
6792
6810
  });
6793
- const filtered = primaryDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
6811
+ const filtered = primaryDaemonId && path41 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
6794
6812
  events.push(...filtered);
6795
6813
  } catch {
6796
6814
  }
@@ -6855,13 +6873,13 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
6855
6873
  const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
6856
6874
  return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
6857
6875
  }
6858
- function trimPendingEventsIfNeeded(path40) {
6876
+ function trimPendingEventsIfNeeded(path41) {
6859
6877
  try {
6860
- if (!(0, import_fs8.existsSync)(path40)) return;
6861
- if ((0, import_fs8.statSync)(path40).size <= MAX_PENDING_EVENTS_BYTES) return;
6862
- const lines = (0, import_fs8.readFileSync)(path40, "utf-8").split("\n").filter(Boolean);
6878
+ if (!(0, import_fs8.existsSync)(path41)) return;
6879
+ if ((0, import_fs8.statSync)(path41).size <= MAX_PENDING_EVENTS_BYTES) return;
6880
+ const lines = (0, import_fs8.readFileSync)(path41, "utf-8").split("\n").filter(Boolean);
6863
6881
  if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
6864
- (0, import_fs8.writeFileSync)(path40, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
6882
+ (0, import_fs8.writeFileSync)(path41, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
6865
6883
  } catch {
6866
6884
  }
6867
6885
  }
@@ -6888,19 +6906,19 @@ function queuePendingMeshCoordinatorEvent(event) {
6888
6906
  });
6889
6907
  } catch {
6890
6908
  }
6891
- const path40 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
6892
- trimPendingEventsIfNeeded(path40);
6893
- (0, import_fs8.appendFileSync)(path40, JSON.stringify(event) + "\n", "utf-8");
6909
+ const path41 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
6910
+ trimPendingEventsIfNeeded(path41);
6911
+ (0, import_fs8.appendFileSync)(path41, JSON.stringify(event) + "\n", "utf-8");
6894
6912
  return true;
6895
6913
  } catch (e) {
6896
6914
  LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
6897
6915
  return false;
6898
6916
  }
6899
6917
  }
6900
- function atomicDrainFile(path40) {
6901
- const tmpPath = `${path40}.draining`;
6918
+ function atomicDrainFile(path41) {
6919
+ const tmpPath = `${path41}.draining`;
6902
6920
  try {
6903
- (0, import_fs8.renameSync)(path40, tmpPath);
6921
+ (0, import_fs8.renameSync)(path41, tmpPath);
6904
6922
  } catch {
6905
6923
  return null;
6906
6924
  }
@@ -6919,10 +6937,10 @@ function atomicDrainFile(path40) {
6919
6937
  return null;
6920
6938
  }
6921
6939
  }
6922
- function selectiveDrainFile(path40, predicate) {
6923
- const tmpPath = `${path40}.draining`;
6940
+ function selectiveDrainFile(path41, predicate) {
6941
+ const tmpPath = `${path41}.draining`;
6924
6942
  try {
6925
- (0, import_fs8.renameSync)(path40, tmpPath);
6943
+ (0, import_fs8.renameSync)(path41, tmpPath);
6926
6944
  } catch {
6927
6945
  return [];
6928
6946
  }
@@ -6954,12 +6972,12 @@ function selectiveDrainFile(path40, predicate) {
6954
6972
  }
6955
6973
  try {
6956
6974
  if (keptLines.length > 0) {
6957
- (0, import_fs8.writeFileSync)(path40, keptLines.join("\n") + "\n", "utf-8");
6975
+ (0, import_fs8.writeFileSync)(path41, keptLines.join("\n") + "\n", "utf-8");
6958
6976
  }
6959
6977
  (0, import_fs8.unlinkSync)(tmpPath);
6960
6978
  } catch {
6961
6979
  try {
6962
- if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(path40)) (0, import_fs8.renameSync)(tmpPath, path40);
6980
+ if ((0, import_fs8.existsSync)(tmpPath) && !(0, import_fs8.existsSync)(path41)) (0, import_fs8.renameSync)(tmpPath, path41);
6963
6981
  } catch {
6964
6982
  }
6965
6983
  return [];
@@ -6993,16 +7011,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
6993
7011
  } catch {
6994
7012
  }
6995
7013
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
6996
- for (const path40 of paths) {
6997
- const isSharedFile = !!primaryDaemonId && path40 === getPendingEventsPath(meshId);
7014
+ for (const path41 of paths) {
7015
+ const isSharedFile = !!primaryDaemonId && path41 === getPendingEventsPath(meshId);
6998
7016
  const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
6999
7017
  if (onlyEvents) {
7000
- for (const event of selectiveDrainFile(path40, (e) => targets(e) && matchesFilter(e.event))) {
7018
+ for (const event of selectiveDrainFile(path41, (e) => targets(e) && matchesFilter(e.event))) {
7001
7019
  pushUnique(event);
7002
7020
  }
7003
7021
  continue;
7004
7022
  }
7005
- const content = atomicDrainFile(path40);
7023
+ const content = atomicDrainFile(path41);
7006
7024
  if (!content) continue;
7007
7025
  const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
7008
7026
  try {
@@ -7052,9 +7070,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
7052
7070
  } catch {
7053
7071
  }
7054
7072
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
7055
- for (const path40 of paths) {
7056
- if ((0, import_fs8.existsSync)(path40)) try {
7057
- (0, import_fs8.unlinkSync)(path40);
7073
+ for (const path41 of paths) {
7074
+ if ((0, import_fs8.existsSync)(path41)) try {
7075
+ (0, import_fs8.unlinkSync)(path41);
7058
7076
  } catch {
7059
7077
  }
7060
7078
  }
@@ -10065,7 +10083,7 @@ function getCliValidator() {
10065
10083
  return _cliValidator;
10066
10084
  }
10067
10085
  function formatIssue(err) {
10068
- const path40 = err.instancePath || "";
10086
+ const path41 = err.instancePath || "";
10069
10087
  const params = err.params;
10070
10088
  let message = err.message || "validation failed";
10071
10089
  let allowed;
@@ -10083,7 +10101,7 @@ function formatIssue(err) {
10083
10101
  } else if (err.keyword === "type") {
10084
10102
  message = `must be ${params.type}`;
10085
10103
  }
10086
- return { path: path40, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
10104
+ return { path: path41, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
10087
10105
  }
10088
10106
  function validateCliProviderManifest(manifest) {
10089
10107
  const validator = getCliValidator();
@@ -10441,6 +10459,37 @@ var init_spawn_env = __esm({
10441
10459
  }
10442
10460
  });
10443
10461
 
10462
+ // src/cli-adapters/resolve-executable.ts
10463
+ function resolveWin32Executable(command) {
10464
+ if (process.platform !== "win32") return command;
10465
+ const trimmed = (command || "").trim();
10466
+ if (!trimmed) return command;
10467
+ if (path16.isAbsolute(trimmed) && (0, import_fs13.existsSync)(trimmed)) return trimmed;
10468
+ try {
10469
+ const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
10470
+ encoding: "utf8",
10471
+ windowsHide: true
10472
+ }).trim();
10473
+ if (out) {
10474
+ const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
10475
+ const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path16.extname(m).toLowerCase()));
10476
+ return direct || matches[0] || command;
10477
+ }
10478
+ } catch {
10479
+ }
10480
+ return command;
10481
+ }
10482
+ var import_child_process4, import_fs13, path16, DIRECT_EXEC_EXT;
10483
+ var init_resolve_executable = __esm({
10484
+ "src/cli-adapters/resolve-executable.ts"() {
10485
+ "use strict";
10486
+ import_child_process4 = require("child_process");
10487
+ import_fs13 = require("fs");
10488
+ path16 = __toESM(require("path"));
10489
+ DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
10490
+ }
10491
+ });
10492
+
10444
10493
  // src/cli-adapters/pty-transport.ts
10445
10494
  var pty_transport_exports = {};
10446
10495
  __export(pty_transport_exports, {
@@ -10462,6 +10511,7 @@ var init_pty_transport = __esm({
10462
10511
  "use strict";
10463
10512
  os11 = __toESM(require("os"));
10464
10513
  init_spawn_env();
10514
+ init_resolve_executable();
10465
10515
  NodePtyRuntimeTransport = class {
10466
10516
  constructor(handle) {
10467
10517
  this.handle = handle;
@@ -10504,7 +10554,7 @@ var init_pty_transport = __esm({
10504
10554
  cwd = os11.homedir();
10505
10555
  }
10506
10556
  }
10507
- const handle = pty.spawn(command, args, {
10557
+ const handle = pty.spawn(resolveWin32Executable(command), args, {
10508
10558
  name: "xterm-256color",
10509
10559
  cols: options.cols,
10510
10560
  rows: options.rows,
@@ -10593,17 +10643,17 @@ function buildCliScreenSnapshot(text) {
10593
10643
  function findBinary(name) {
10594
10644
  const trimmed = String(name || "").trim();
10595
10645
  if (!trimmed) return trimmed;
10596
- const expanded = trimmed.startsWith("~") ? path16.join(os12.homedir(), trimmed.slice(1)) : trimmed;
10597
- if (path16.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
10598
- return path16.isAbsolute(expanded) ? expanded : path16.resolve(expanded);
10646
+ const expanded = trimmed.startsWith("~") ? path17.join(os12.homedir(), trimmed.slice(1)) : trimmed;
10647
+ if (path17.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
10648
+ return path17.isAbsolute(expanded) ? expanded : path17.resolve(expanded);
10599
10649
  }
10600
10650
  const isWin = os12.platform() === "win32";
10601
- const paths = (process.env.PATH || "").split(path16.delimiter);
10651
+ const paths = (process.env.PATH || "").split(path17.delimiter);
10602
10652
  const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
10603
10653
  for (const p of paths) {
10604
10654
  if (!p) continue;
10605
10655
  for (const ext of exes) {
10606
- const fullPath = path16.join(p, trimmed + ext);
10656
+ const fullPath = path17.join(p, trimmed + ext);
10607
10657
  try {
10608
10658
  const fs30 = require("fs");
10609
10659
  if (fs30.existsSync(fullPath)) {
@@ -10619,7 +10669,7 @@ function findBinary(name) {
10619
10669
  return isWin ? `${trimmed}.cmd` : trimmed;
10620
10670
  }
10621
10671
  function isScriptBinary(binaryPath) {
10622
- if (!path16.isAbsolute(binaryPath)) return false;
10672
+ if (!path17.isAbsolute(binaryPath)) return false;
10623
10673
  try {
10624
10674
  const fs30 = require("fs");
10625
10675
  const resolved = fs30.realpathSync(binaryPath);
@@ -10635,7 +10685,7 @@ function isScriptBinary(binaryPath) {
10635
10685
  }
10636
10686
  }
10637
10687
  function looksLikeMachOOrElf(filePath) {
10638
- if (!path16.isAbsolute(filePath)) return false;
10688
+ if (!path17.isAbsolute(filePath)) return false;
10639
10689
  try {
10640
10690
  const fs30 = require("fs");
10641
10691
  const resolved = fs30.realpathSync(filePath);
@@ -10724,12 +10774,12 @@ function normalizeCliProviderForRuntime(raw) {
10724
10774
  }
10725
10775
  };
10726
10776
  }
10727
- var os12, path16, TerminalTranscriptAccumulator, buildCliSpawnEnv;
10777
+ var os12, path17, TerminalTranscriptAccumulator, buildCliSpawnEnv;
10728
10778
  var init_provider_cli_shared = __esm({
10729
10779
  "src/cli-adapters/provider-cli-shared.ts"() {
10730
10780
  "use strict";
10731
10781
  os12 = __toESM(require("os"));
10732
- path16 = __toESM(require("path"));
10782
+ path17 = __toESM(require("path"));
10733
10783
  init_spawn_env();
10734
10784
  TerminalTranscriptAccumulator = class {
10735
10785
  lines = [[]];
@@ -12687,9 +12737,9 @@ function resolveCliSpawnPlan(options) {
12687
12737
  );
12688
12738
  let shellCmd;
12689
12739
  let shellArgs;
12690
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
12740
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
12691
12741
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
12692
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12742
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path18.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12693
12743
  const useShell = isWin ? useShellWin : useShellUnix;
12694
12744
  if (useShell) {
12695
12745
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -12765,12 +12815,12 @@ function respondToCliTerminalQueries(options) {
12765
12815
  }
12766
12816
  return "";
12767
12817
  }
12768
- var os13, path17, import_session_host_core4;
12818
+ var os13, path18, import_session_host_core4;
12769
12819
  var init_provider_cli_runtime = __esm({
12770
12820
  "src/cli-adapters/provider-cli-runtime.ts"() {
12771
12821
  "use strict";
12772
12822
  os13 = __toESM(require("os"));
12773
- path17 = __toESM(require("path"));
12823
+ path18 = __toESM(require("path"));
12774
12824
  import_session_host_core4 = require("@adhdev/session-host-core");
12775
12825
  init_provider_cli_shared();
12776
12826
  }
@@ -14955,40 +15005,40 @@ function validateFsmSpec(raw) {
14955
15005
  }
14956
15006
  return errs;
14957
15007
  }
14958
- function validateCondition(c, sectionIds, path40) {
15008
+ function validateCondition(c, sectionIds, path41) {
14959
15009
  const errs = [];
14960
15010
  const w = c;
14961
15011
  if ("all" in w) {
14962
- w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path40}.all[${i}]`)));
15012
+ w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.all[${i}]`)));
14963
15013
  return errs;
14964
15014
  }
14965
15015
  if ("any" in w) {
14966
- w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path40}.any[${i}]`)));
15016
+ w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path41}.any[${i}]`)));
14967
15017
  return errs;
14968
15018
  }
14969
15019
  if ("not" in w) {
14970
- errs.push(...validateCondition(w.not, sectionIds, `${path40}.not`));
15020
+ errs.push(...validateCondition(w.not, sectionIds, `${path41}.not`));
14971
15021
  return errs;
14972
15022
  }
14973
15023
  if ("matches" in w) {
14974
- if (w.section && !sectionIds.has(w.section)) errs.push(`${path40}.section "${w.section}" unknown`);
15024
+ if (w.section && !sectionIds.has(w.section)) errs.push(`${path41}.section "${w.section}" unknown`);
14975
15025
  try {
14976
15026
  new RegExp(w.matches, w.flags ?? "i");
14977
15027
  } catch (e) {
14978
- errs.push(`${path40}.matches invalid regex: ${e.message}`);
15028
+ errs.push(`${path41}.matches invalid regex: ${e.message}`);
14979
15029
  }
14980
15030
  return errs;
14981
15031
  }
14982
15032
  if ("cursor_above" in w && "changed" in w) return errs;
14983
15033
  if ("elapsed_ms" in w) {
14984
- if (typeof w.elapsed_ms !== "number") errs.push(`${path40}.elapsed_ms must be a number`);
15034
+ if (typeof w.elapsed_ms !== "number") errs.push(`${path41}.elapsed_ms must be a number`);
14985
15035
  return errs;
14986
15036
  }
14987
15037
  if ("stable_ms" in w) {
14988
- if (typeof w.stable_ms !== "number") errs.push(`${path40}.stable_ms must be a number`);
15038
+ if (typeof w.stable_ms !== "number") errs.push(`${path41}.stable_ms must be a number`);
14989
15039
  return errs;
14990
15040
  }
14991
- errs.push(`${path40} is not a recognized condition`);
15041
+ errs.push(`${path41} is not a recognized condition`);
14992
15042
  return errs;
14993
15043
  }
14994
15044
  var fs9;
@@ -15148,7 +15198,7 @@ function _getRegisteredRoots() {
15148
15198
  }
15149
15199
  function canonicalize(p) {
15150
15200
  try {
15151
- const resolved = path30.resolve(p);
15201
+ const resolved = path31.resolve(p);
15152
15202
  try {
15153
15203
  return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
15154
15204
  } catch {
@@ -15168,7 +15218,7 @@ function isCallerInsideGatedRoot(callerFilename) {
15168
15218
  }
15169
15219
  for (const root of _gatedRoots) {
15170
15220
  if (normalized === root.rootPath) return root;
15171
- if (normalized.startsWith(root.rootPath + path30.sep)) return root;
15221
+ if (normalized.startsWith(root.rootPath + path31.sep)) return root;
15172
15222
  }
15173
15223
  return null;
15174
15224
  }
@@ -15187,16 +15237,16 @@ function ensureInstalled() {
15187
15237
  };
15188
15238
  }
15189
15239
  function gatedRequire(request, parent, isMain, gated, originalLoad) {
15190
- if (request.startsWith("./") || request.startsWith("../") || path30.isAbsolute(request)) {
15240
+ if (request.startsWith("./") || request.startsWith("../") || path31.isAbsolute(request)) {
15191
15241
  let resolved;
15192
15242
  try {
15193
- const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path30.join(gated.rootPath, "__entry__.js"));
15243
+ const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path31.join(gated.rootPath, "__entry__.js"));
15194
15244
  resolved = callerRequire.resolve(request);
15195
15245
  } catch {
15196
15246
  return originalLoad.call(this, request, parent, isMain);
15197
15247
  }
15198
15248
  const resolvedCanon = canonicalize(resolved) || resolved;
15199
- if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path30.sep))) {
15249
+ if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path31.sep))) {
15200
15250
  denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
15201
15251
  }
15202
15252
  return originalLoad.call(this, request, parent, isMain);
@@ -15220,11 +15270,11 @@ function denyRequire(request, parent, reason) {
15220
15270
  err.callerFilename = caller;
15221
15271
  throw err;
15222
15272
  }
15223
- var path30, import_node_module2, nodeFs, nodeChildProcess, SAFE_STDLIB, SHIMMED_STDLIB, ALL_GATED_STDLIB, FS_READ_ONLY_MEMBERS, FS_PROMISES_READ_ONLY_MEMBERS, FS_SHIM, CHILD_PROCESS_SHIM, DANGEROUS_PROCESS_METHODS, _processGloballyHardened, _originalProcessMethods, PROCESS_SHIM, _gatedRoots, _installed, PROVIDER_REQUIRE_POLICY;
15273
+ var path31, import_node_module2, nodeFs, nodeChildProcess, SAFE_STDLIB, SHIMMED_STDLIB, ALL_GATED_STDLIB, FS_READ_ONLY_MEMBERS, FS_PROMISES_READ_ONLY_MEMBERS, FS_SHIM, CHILD_PROCESS_SHIM, DANGEROUS_PROCESS_METHODS, _processGloballyHardened, _originalProcessMethods, PROCESS_SHIM, _gatedRoots, _installed, PROVIDER_REQUIRE_POLICY;
15224
15274
  var init_require_whitelist = __esm({
15225
15275
  "src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
15226
15276
  "use strict";
15227
- path30 = __toESM(require("path"));
15277
+ path31 = __toESM(require("path"));
15228
15278
  import_node_module2 = require("module");
15229
15279
  nodeFs = __toESM(require("fs"));
15230
15280
  nodeChildProcess = __toESM(require("child_process"));
@@ -17409,10 +17459,10 @@ function getRegistryPath() {
17409
17459
  return (0, import_path5.join)(getDaemonDataDir(), "mesh-coordinators.json");
17410
17460
  }
17411
17461
  function loadMeshCoordinatorRegistry() {
17412
- const path40 = getRegistryPath();
17413
- if (!(0, import_fs5.existsSync)(path40)) return;
17462
+ const path41 = getRegistryPath();
17463
+ if (!(0, import_fs5.existsSync)(path41)) return;
17414
17464
  try {
17415
- const raw = JSON.parse((0, import_fs5.readFileSync)(path40, "utf-8"));
17465
+ const raw = JSON.parse((0, import_fs5.readFileSync)(path41, "utf-8"));
17416
17466
  if (!Array.isArray(raw)) return;
17417
17467
  _registry.clear();
17418
17468
  for (const entry of raw) {
@@ -17650,8 +17700,8 @@ function validateMeshRefineConfig(config, source = "inline") {
17650
17700
  if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
17651
17701
  return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
17652
17702
  }
17653
- function parseConfigText(path40, text) {
17654
- if (/\.json$/i.test(path40)) return JSON.parse(text);
17703
+ function parseConfigText(path41, text) {
17704
+ if (/\.json$/i.test(path41)) return JSON.parse(text);
17655
17705
  return yaml.load(text);
17656
17706
  }
17657
17707
  function loadMeshRefineConfig(mesh, workspace) {
@@ -17809,8 +17859,8 @@ var MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA = {
17809
17859
  var DEFAULT_TIMEOUT_MS2 = 12e4;
17810
17860
  var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
17811
17861
  var OUTPUT_SUMMARY_CHARS = 2e3;
17812
- function parseConfigText2(path40, text) {
17813
- if (/\.json$/i.test(path40)) return JSON.parse(text);
17862
+ function parseConfigText2(path41, text) {
17863
+ if (/\.json$/i.test(path41)) return JSON.parse(text);
17814
17864
  return yaml2.load(text);
17815
17865
  }
17816
17866
  function truncateOutput(value) {
@@ -29538,8 +29588,8 @@ var DaemonCommandHandler = class {
29538
29588
  */
29539
29589
  getUpstreamInstallRoot() {
29540
29590
  const os30 = require("os");
29541
- const path40 = require("path");
29542
- return path40.join(os30.homedir(), ".adhdev", "providers", ".upstream");
29591
+ const path41 = require("path");
29592
+ return path41.join(os30.homedir(), ".adhdev", "providers", ".upstream");
29543
29593
  }
29544
29594
  /**
29545
29595
  * Download a single provider manifest from the registry and write it to
@@ -29564,7 +29614,7 @@ var DaemonCommandHandler = class {
29564
29614
  }
29565
29615
  const https = require("https");
29566
29616
  const fs30 = require("fs");
29567
- const path40 = require("path");
29617
+ const path41 = require("path");
29568
29618
  const crypto6 = require("crypto");
29569
29619
  const REGISTRY = "https://api.adhf.dev/api/v1/registry";
29570
29620
  function fetchText(url, timeoutMs) {
@@ -29602,9 +29652,9 @@ var DaemonCommandHandler = class {
29602
29652
  return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
29603
29653
  }
29604
29654
  const installRoot = this.getUpstreamInstallRoot();
29605
- const installRootResolved = path40.resolve(installRoot);
29606
- const targetDir = path40.resolve(path40.join(installRoot, category, type));
29607
- if (!targetDir.startsWith(installRootResolved + path40.sep)) {
29655
+ const installRootResolved = path41.resolve(installRoot);
29656
+ const targetDir = path41.resolve(path41.join(installRoot, category, type));
29657
+ if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29608
29658
  return { success: false, error: "install path escaped upstream root" };
29609
29659
  }
29610
29660
  fs30.mkdirSync(targetDir, { recursive: true });
@@ -29631,7 +29681,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29631
29681
  }
29632
29682
  }
29633
29683
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
29634
- const targetPath = path40.join(targetDir, targetFile);
29684
+ const targetPath = path41.join(targetDir, targetFile);
29635
29685
  fs30.writeFileSync(targetPath, manifestBody, "utf-8");
29636
29686
  const manifestJson = JSON.parse(manifestBody);
29637
29687
  const scriptFetch = await this.fetchProviderSources(
@@ -29703,7 +29753,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29703
29753
  const ref = source.ref;
29704
29754
  const https = require("https");
29705
29755
  const fs30 = require("fs");
29706
- const path40 = require("path");
29756
+ const path41 = require("path");
29707
29757
  function fetchJson(url, timeoutMs) {
29708
29758
  return new Promise((resolve24, reject) => {
29709
29759
  const req = https.get(url, {
@@ -29759,9 +29809,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29759
29809
  }
29760
29810
  let fetchedCount = 0;
29761
29811
  const sharedDirRel = `${category}/_shared`;
29762
- const sharedTargetDir = path40.resolve(path40.join(targetDir, "../_shared"));
29763
- const installRootResolved = path40.resolve(path40.join(targetDir, "../.."));
29764
- if (sharedTargetDir.startsWith(installRootResolved + path40.sep)) {
29812
+ const sharedTargetDir = path41.resolve(path41.join(targetDir, "../_shared"));
29813
+ const installRootResolved = path41.resolve(path41.join(targetDir, "../.."));
29814
+ if (sharedTargetDir.startsWith(installRootResolved + path41.sep)) {
29765
29815
  const sharedStack = [sharedDirRel];
29766
29816
  while (sharedStack.length) {
29767
29817
  const relDir = sharedStack.pop();
@@ -29784,9 +29834,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29784
29834
  try {
29785
29835
  const body = await fetchBinary(entry.download_url, 3e4);
29786
29836
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
29787
- const outPath = path40.resolve(path40.join(sharedTargetDir, relInside));
29788
- if (!outPath.startsWith(path40.resolve(sharedTargetDir) + path40.sep)) continue;
29789
- fs30.mkdirSync(path40.dirname(outPath), { recursive: true });
29837
+ const outPath = path41.resolve(path41.join(sharedTargetDir, relInside));
29838
+ if (!outPath.startsWith(path41.resolve(sharedTargetDir) + path41.sep)) continue;
29839
+ fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29790
29840
  fs30.writeFileSync(outPath, body);
29791
29841
  fetchedCount++;
29792
29842
  } catch (e) {
@@ -29820,12 +29870,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29820
29870
  try {
29821
29871
  const body = await fetchBinary(entry.download_url, 3e4);
29822
29872
  const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
29823
- const outPath = path40.resolve(path40.join(targetDir, relInsideProvider));
29824
- if (!outPath.startsWith(path40.resolve(targetDir) + path40.sep)) {
29873
+ const outPath = path41.resolve(path41.join(targetDir, relInsideProvider));
29874
+ if (!outPath.startsWith(path41.resolve(targetDir) + path41.sep)) {
29825
29875
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
29826
29876
  continue;
29827
29877
  }
29828
- fs30.mkdirSync(path40.dirname(outPath), { recursive: true });
29878
+ fs30.mkdirSync(path41.dirname(outPath), { recursive: true });
29829
29879
  fs30.writeFileSync(outPath, body);
29830
29880
  fetchedCount++;
29831
29881
  } catch (e) {
@@ -29855,12 +29905,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29855
29905
  return { success: false, error: `unknown category: ${category}` };
29856
29906
  }
29857
29907
  const fs30 = require("fs");
29858
- const path40 = require("path");
29908
+ const path41 = require("path");
29859
29909
  try {
29860
29910
  const installRoot = this.getUpstreamInstallRoot();
29861
- const installRootResolved = path40.resolve(installRoot);
29862
- const targetDir = path40.resolve(path40.join(installRoot, category, type));
29863
- if (!targetDir.startsWith(installRootResolved + path40.sep)) {
29911
+ const installRootResolved = path41.resolve(installRoot);
29912
+ const targetDir = path41.resolve(path41.join(installRoot, category, type));
29913
+ if (!targetDir.startsWith(installRootResolved + path41.sep)) {
29864
29914
  return { success: false, error: "refusing to delete outside upstream root" };
29865
29915
  }
29866
29916
  if (!fs30.existsSync(targetDir)) {
@@ -29883,13 +29933,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29883
29933
  */
29884
29934
  handleListInstalledProviders(_args) {
29885
29935
  const fs30 = require("fs");
29886
- const path40 = require("path");
29936
+ const path41 = require("path");
29887
29937
  const installRoot = this.getUpstreamInstallRoot();
29888
29938
  if (!fs30.existsSync(installRoot)) return { success: true, providers: [] };
29889
29939
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
29890
29940
  const items = [];
29891
29941
  for (const category of CATEGORIES) {
29892
- const categoryDir = path40.join(installRoot, category);
29942
+ const categoryDir = path41.join(installRoot, category);
29893
29943
  if (!fs30.existsSync(categoryDir)) continue;
29894
29944
  let entries;
29895
29945
  try {
@@ -29898,8 +29948,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
29898
29948
  continue;
29899
29949
  }
29900
29950
  for (const type of entries) {
29901
- const v1Path = path40.join(categoryDir, type, "provider.v1.json");
29902
- const v0Path = path40.join(categoryDir, type, "provider.json");
29951
+ const v1Path = path41.join(categoryDir, type, "provider.v1.json");
29952
+ const v0Path = path41.join(categoryDir, type, "provider.json");
29903
29953
  const manifestPath = fs30.existsSync(v1Path) ? v1Path : fs30.existsSync(v0Path) ? v0Path : null;
29904
29954
  if (!manifestPath) continue;
29905
29955
  try {
@@ -30015,7 +30065,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
30015
30065
  return { success: false, error: "name must match @[a-z0-9_-]+" };
30016
30066
  }
30017
30067
  const fs30 = require("fs");
30018
- const path40 = require("path");
30068
+ const path41 = require("path");
30019
30069
  const { spawnSync: spawnSync2 } = require("child_process");
30020
30070
  const file = ext.loadExternalSources();
30021
30071
  if (file.sources.some((s) => s.name === requestedName)) {
@@ -30024,7 +30074,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
30024
30074
  if (file.sources.some((s) => s.url === url && s.ref === ref)) {
30025
30075
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
30026
30076
  }
30027
- const sourceDir = path40.join(ext.externalRoot(), requestedName);
30077
+ const sourceDir = path41.join(ext.externalRoot(), requestedName);
30028
30078
  if (!fs30.existsSync(ext.externalRoot())) fs30.mkdirSync(ext.externalRoot(), { recursive: true });
30029
30079
  if (fs30.existsSync(sourceDir)) {
30030
30080
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
@@ -30081,11 +30131,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
30081
30131
  if (!name) return { success: false, error: "name is required" };
30082
30132
  const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
30083
30133
  const fs30 = require("fs");
30084
- const path40 = require("path");
30134
+ const path41 = require("path");
30085
30135
  const file = ext.loadExternalSources();
30086
30136
  const match = file.sources.find((s) => s.name === name);
30087
30137
  if (!match) return { success: false, error: `source "${name}" not registered` };
30088
- const sourceDir = path40.join(ext.externalRoot(), name);
30138
+ const sourceDir = path41.join(ext.externalRoot(), name);
30089
30139
  if (fs30.existsSync(sourceDir)) {
30090
30140
  try {
30091
30141
  fs30.rmSync(sourceDir, { recursive: true, force: true });
@@ -30263,10 +30313,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
30263
30313
 
30264
30314
  // src/commands/cli-manager.ts
30265
30315
  var os19 = __toESM(require("os"));
30266
- var path24 = __toESM(require("path"));
30316
+ var path25 = __toESM(require("path"));
30267
30317
  var crypto5 = __toESM(require("crypto"));
30268
- var import_fs13 = require("fs");
30269
- var import_child_process5 = require("child_process");
30318
+ var import_fs14 = require("fs");
30319
+ var import_child_process6 = require("child_process");
30270
30320
  var import_chalk = __toESM(require("chalk"));
30271
30321
  init_provider_cli_adapter();
30272
30322
  init_cli_detector();
@@ -30274,20 +30324,20 @@ init_config();
30274
30324
 
30275
30325
  // src/providers/cli-provider-instance.ts
30276
30326
  var os18 = __toESM(require("os"));
30277
- var path22 = __toESM(require("path"));
30327
+ var path23 = __toESM(require("path"));
30278
30328
  var crypto4 = __toESM(require("crypto"));
30279
30329
  var fs15 = __toESM(require("fs"));
30280
30330
  var import_node_module = require("module");
30281
30331
 
30282
30332
  // src/providers/spec/route.ts
30283
30333
  var fs14 = __toESM(require("fs"));
30284
- var path21 = __toESM(require("path"));
30334
+ var path22 = __toESM(require("path"));
30285
30335
  init_provider_cli_adapter();
30286
30336
 
30287
30337
  // src/providers/spec/fsm-driver.ts
30288
30338
  var fs11 = __toESM(require("fs"));
30289
30339
  var os16 = __toESM(require("os"));
30290
- var path19 = __toESM(require("path"));
30340
+ var path20 = __toESM(require("path"));
30291
30341
 
30292
30342
  // src/providers/spec/adapter.ts
30293
30343
  init_terminal_screen();
@@ -30413,18 +30463,18 @@ init_fsm_loader();
30413
30463
  // src/providers/spec/pre-launch-trust.ts
30414
30464
  var fs10 = __toESM(require("fs"));
30415
30465
  var os15 = __toESM(require("os"));
30416
- var path18 = __toESM(require("path"));
30466
+ var path19 = __toESM(require("path"));
30417
30467
  init_logger();
30418
30468
  function expandHome2(p) {
30419
30469
  if (p === "~") return os15.homedir();
30420
- if (p.startsWith("~/")) return path18.join(os15.homedir(), p.slice(2));
30470
+ if (p.startsWith("~/")) return path19.join(os15.homedir(), p.slice(2));
30421
30471
  return p;
30422
30472
  }
30423
30473
  function realWorkspacePath(workingDir) {
30424
30474
  try {
30425
30475
  return fs10.realpathSync(workingDir);
30426
30476
  } catch {
30427
- return path18.resolve(workingDir);
30477
+ return path19.resolve(workingDir);
30428
30478
  }
30429
30479
  }
30430
30480
  function applyPreLaunchTrust(trust, workingDir) {
@@ -30450,7 +30500,7 @@ function applyPreLaunchTrust(trust, workingDir) {
30450
30500
  }
30451
30501
  list.push(real);
30452
30502
  parsed[key] = list;
30453
- fs10.mkdirSync(path18.dirname(settingsPath), { recursive: true });
30503
+ fs10.mkdirSync(path19.dirname(settingsPath), { recursive: true });
30454
30504
  fs10.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
30455
30505
  `, "utf8");
30456
30506
  LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
@@ -30699,8 +30749,8 @@ var FsmDriver = class {
30699
30749
  }
30700
30750
  armSpecWatcher() {
30701
30751
  try {
30702
- const dir = path19.dirname(this.opts.specPath);
30703
- const base = path19.basename(this.opts.specPath);
30752
+ const dir = path20.dirname(this.opts.specPath);
30753
+ const base = path20.basename(this.opts.specPath);
30704
30754
  this.specWatcher = fs11.watch(dir, { persistent: false }, (_event, filename) => {
30705
30755
  if (filename && filename !== base) return;
30706
30756
  const res = loadFsmSpec(this.opts.specPath);
@@ -31001,7 +31051,7 @@ var FsmDriver = class {
31001
31051
  const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
31002
31052
  if (!ctl || ctl.action.type !== "attach_image") return;
31003
31053
  const ext = guessExt(mime);
31004
- const tmp = path19.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
31054
+ const tmp = path20.join(os16.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
31005
31055
  try {
31006
31056
  fs11.writeFileSync(tmp, Buffer.from(blob, "base64"));
31007
31057
  } catch {
@@ -31111,7 +31161,7 @@ function collectStableSizes(when, sizes) {
31111
31161
  // src/providers/spec/native-history-executor.ts
31112
31162
  var fs12 = __toESM(require("fs"));
31113
31163
  var os17 = __toESM(require("os"));
31114
- var path20 = __toESM(require("path"));
31164
+ var path21 = __toESM(require("path"));
31115
31165
  var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
31116
31166
  function executeNativeHistory(cfg, input) {
31117
31167
  if (!cfg?.source) return null;
@@ -31155,7 +31205,7 @@ function executeJsonl(src, input) {
31155
31205
  const v = jsonPathGet(lines[0], src.session_id_path);
31156
31206
  if (typeof v === "string" && v) providerSessionId = v;
31157
31207
  } else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
31158
- const m = path20.basename(sourcePath).match(UUID_RE);
31208
+ const m = path21.basename(sourcePath).match(UUID_RE);
31159
31209
  if (m) providerSessionId = m[1];
31160
31210
  }
31161
31211
  const requested = requestedSessionId || "";
@@ -31268,13 +31318,13 @@ function expandPath2(template, input) {
31268
31318
  if (!template) return null;
31269
31319
  let out = template;
31270
31320
  if (out.startsWith("~/") || out === "~") {
31271
- out = path20.join(os17.homedir(), out.slice(2));
31321
+ out = path21.join(os17.homedir(), out.slice(2));
31272
31322
  }
31273
31323
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
31274
31324
  const v = input.envOverrides?.[name] ?? process.env[name];
31275
31325
  return v != null && v !== "" ? v : fallback ?? "";
31276
31326
  });
31277
- if (out.startsWith("~/")) out = path20.join(os17.homedir(), out.slice(2));
31327
+ if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
31278
31328
  const now = /* @__PURE__ */ new Date();
31279
31329
  const workspaceRaw = input.workspace ?? "";
31280
31330
  let workspaceResolved = workspaceRaw;
@@ -31331,12 +31381,12 @@ function expandDirGlob(template) {
31331
31381
  continue;
31332
31382
  }
31333
31383
  for (const e of entries) {
31334
- if (e.isDirectory() && re.test(e.name)) next.push(path20.join(d, e.name));
31384
+ if (e.isDirectory() && re.test(e.name)) next.push(path21.join(d, e.name));
31335
31385
  }
31336
31386
  }
31337
31387
  } else {
31338
31388
  for (const d of dirs) {
31339
- const candidate = path20.join(d, seg);
31389
+ const candidate = path21.join(d, seg);
31340
31390
  let stat2 = null;
31341
31391
  try {
31342
31392
  stat2 = fs12.statSync(candidate);
@@ -31359,7 +31409,7 @@ function walkAllDirs(root, out) {
31359
31409
  }
31360
31410
  out.push(root);
31361
31411
  for (const e of entries) {
31362
- if (e.isDirectory()) walkAllDirs(path20.join(root, e.name), out);
31412
+ if (e.isDirectory()) walkAllDirs(path21.join(root, e.name), out);
31363
31413
  }
31364
31414
  }
31365
31415
  function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
@@ -31375,7 +31425,7 @@ function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs
31375
31425
  }
31376
31426
  for (const e of entries) {
31377
31427
  if (!e.isFile() || !pattern.test(e.name)) continue;
31378
- const p = path20.join(d, e.name);
31428
+ const p = path21.join(d, e.name);
31379
31429
  const mtime = safeMtimeMs(p);
31380
31430
  if (mtime < cutoff) continue;
31381
31431
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31402,7 +31452,7 @@ function newestRecentFileAcrossDateWindow(template, input, pattern, windowMs, se
31402
31452
  }
31403
31453
  for (const e of entries) {
31404
31454
  if (!e.isFile() || !pattern.test(e.name)) continue;
31405
- const p = path20.join(resolved, e.name);
31455
+ const p = path21.join(resolved, e.name);
31406
31456
  const mtime = safeMtimeMs(p);
31407
31457
  if (mtime < cutoff) continue;
31408
31458
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31414,13 +31464,13 @@ function expandPathForDate(template, input, day) {
31414
31464
  if (!template) return null;
31415
31465
  let out = template;
31416
31466
  if (out.startsWith("~/") || out === "~") {
31417
- out = path20.join(os17.homedir(), out.slice(2));
31467
+ out = path21.join(os17.homedir(), out.slice(2));
31418
31468
  }
31419
31469
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
31420
31470
  const v = input.envOverrides?.[name] ?? process.env[name];
31421
31471
  return v != null && v !== "" ? v : fallback ?? "";
31422
31472
  });
31423
- if (out.startsWith("~/")) out = path20.join(os17.homedir(), out.slice(2));
31473
+ if (out.startsWith("~/")) out = path21.join(os17.homedir(), out.slice(2));
31424
31474
  const workspaceRaw = input.workspace ?? "";
31425
31475
  let workspaceResolved = workspaceRaw;
31426
31476
  if (workspaceRaw) {
@@ -31458,7 +31508,7 @@ function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
31458
31508
  let best = null;
31459
31509
  for (const e of entries) {
31460
31510
  if (!e.isFile() || !pattern.test(e.name)) continue;
31461
- const p = path20.join(dir, e.name);
31511
+ const p = path21.join(dir, e.name);
31462
31512
  const mtime = safeMtimeMs(p);
31463
31513
  if (mtime < cutoff) continue;
31464
31514
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -31478,7 +31528,7 @@ function readRequestedSessionId(input) {
31478
31528
  return UUID_RE.test(value) ? value : "";
31479
31529
  }
31480
31530
  function filenameUuid(filePath) {
31481
- const match = path20.basename(filePath).match(UUID_RE);
31531
+ const match = path21.basename(filePath).match(UUID_RE);
31482
31532
  return match?.[1] || "";
31483
31533
  }
31484
31534
  function pickExactSessionFile(dir, pattern, requestedSessionId) {
@@ -31573,7 +31623,7 @@ function listMatchingFiles(dir, pattern) {
31573
31623
  const out = [];
31574
31624
  for (const e of entries) {
31575
31625
  if (!e.isFile() || !pattern.test(e.name)) continue;
31576
- out.push(path20.join(dir, e.name));
31626
+ out.push(path21.join(dir, e.name));
31577
31627
  }
31578
31628
  return out;
31579
31629
  }
@@ -32515,12 +32565,12 @@ function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFact
32515
32565
  const dir = provider._resolvedProviderDir;
32516
32566
  let specPath = resolvedSpecPath && fs14.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
32517
32567
  if (!specPath && dir) {
32518
- const legacy = path21.join(dir, "spec.json");
32568
+ const legacy = path22.join(dir, "spec.json");
32519
32569
  if (fs14.existsSync(legacy)) specPath = legacy;
32520
32570
  }
32521
32571
  if (specPath) {
32522
32572
  try {
32523
- LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path21.relative(dir || "", specPath) || specPath})`);
32573
+ LOG.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path22.relative(dir || "", specPath) || specPath})`);
32524
32574
  return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
32525
32575
  } catch (err) {
32526
32576
  LOG.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
@@ -32587,7 +32637,7 @@ function filePathFromUri(uri) {
32587
32637
  return uri.slice("file://".length);
32588
32638
  }
32589
32639
  }
32590
- if (path22.isAbsolute(uri)) return uri;
32640
+ if (path23.isAbsolute(uri)) return uri;
32591
32641
  return null;
32592
32642
  }
32593
32643
  function extensionForImageMime(mimeType) {
@@ -32603,7 +32653,7 @@ function materializeImageDataPart(part, index, dir) {
32603
32653
  const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
32604
32654
  if (!rawData) return null;
32605
32655
  fs15.mkdirSync(dir, { recursive: true });
32606
- const filePath = path22.join(dir, safeInputImageBasename(index, part.mimeType));
32656
+ const filePath = path23.join(dir, safeInputImageBasename(index, part.mimeType));
32607
32657
  fs15.writeFileSync(filePath, Buffer.from(rawData, "base64"));
32608
32658
  cleanupStaleMaterializedImages(dir);
32609
32659
  return filePath;
@@ -32619,7 +32669,7 @@ function cleanupStaleMaterializedImages(dir) {
32619
32669
  const entries = fs15.readdirSync(dir);
32620
32670
  for (const entry of entries) {
32621
32671
  if (!entry.startsWith("adhdev-input-image-")) continue;
32622
- const fullPath = path22.join(dir, entry);
32672
+ const fullPath = path23.join(dir, entry);
32623
32673
  try {
32624
32674
  const stat2 = fs15.statSync(fullPath);
32625
32675
  if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
@@ -32642,7 +32692,7 @@ function buildCliStructuredInputPrompt(input, options = {}) {
32642
32692
  const promptParts = [];
32643
32693
  const imageRefs = [];
32644
32694
  const resourceRefs = [];
32645
- const materializeDir = options.materializeDir || path22.join(os18.tmpdir(), "adhdev-input-media");
32695
+ const materializeDir = options.materializeDir || path23.join(os18.tmpdir(), "adhdev-input-media");
32646
32696
  input.parts.forEach((part, index) => {
32647
32697
  if (part.type === "text" && part.text.trim()) {
32648
32698
  promptParts.push(part.text.trim());
@@ -32709,7 +32759,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
32709
32759
  var CachedDatabaseSync = null;
32710
32760
  function getDatabaseSync() {
32711
32761
  if (CachedDatabaseSync) return CachedDatabaseSync;
32712
- const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path22.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
32762
+ const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path23.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
32713
32763
  const sqliteModule = requireFn(`node:${"sqlite"}`);
32714
32764
  CachedDatabaseSync = sqliteModule.DatabaseSync;
32715
32765
  if (!CachedDatabaseSync) {
@@ -34346,9 +34396,9 @@ ${effect.notification.body || ""}`.trim();
34346
34396
  };
34347
34397
 
34348
34398
  // src/providers/acp-provider-instance.ts
34349
- var path23 = __toESM(require("path"));
34399
+ var path24 = __toESM(require("path"));
34350
34400
  var import_stream = require("stream");
34351
- var import_child_process4 = require("child_process");
34401
+ var import_child_process5 = require("child_process");
34352
34402
  var import_sdk = require("@agentclientprotocol/sdk");
34353
34403
  init_logger();
34354
34404
  function getPromptCapabilityFlags(agentCapabilities) {
@@ -34867,7 +34917,7 @@ var AcpProviderInstance = class {
34867
34917
  this.errorMessage = null;
34868
34918
  this.errorReason = null;
34869
34919
  this.stderrBuffer = [];
34870
- this.process = (0, import_child_process4.spawn)(command, args, {
34920
+ this.process = (0, import_child_process5.spawn)(command, args, {
34871
34921
  cwd: this.workingDir,
34872
34922
  env,
34873
34923
  stdio: ["pipe", "pipe", "pipe"],
@@ -35132,7 +35182,7 @@ var AcpProviderInstance = class {
35132
35182
  return b.uri ? {
35133
35183
  type: "resource_link",
35134
35184
  uri: b.uri,
35135
- name: path23.basename(b.uri),
35185
+ name: path24.basename(b.uri),
35136
35186
  mimeType: b.mimeType,
35137
35187
  ...b.transcript ? { description: b.transcript } : {}
35138
35188
  } : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
@@ -35592,20 +35642,20 @@ function shouldRestoreHostedRuntime(record, managerTag) {
35592
35642
  // src/commands/cli-manager.ts
35593
35643
  function isExplicitCommand(command) {
35594
35644
  const trimmed = command.trim();
35595
- return path24.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
35645
+ return path25.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
35596
35646
  }
35597
35647
  function expandExecutable(command) {
35598
35648
  const trimmed = command.trim();
35599
- return trimmed.startsWith("~") ? path24.join(os19.homedir(), trimmed.slice(1)) : trimmed;
35649
+ return trimmed.startsWith("~") ? path25.join(os19.homedir(), trimmed.slice(1)) : trimmed;
35600
35650
  }
35601
35651
  function commandExists(command) {
35602
35652
  const trimmed = command.trim();
35603
35653
  if (!trimmed) return false;
35604
35654
  if (isExplicitCommand(trimmed)) {
35605
- return (0, import_fs13.existsSync)(expandExecutable(trimmed));
35655
+ return (0, import_fs14.existsSync)(expandExecutable(trimmed));
35606
35656
  }
35607
35657
  try {
35608
- (0, import_child_process5.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
35658
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
35609
35659
  stdio: "ignore",
35610
35660
  ...process.platform === "win32" ? { windowsHide: true } : {}
35611
35661
  });
@@ -35737,11 +35787,11 @@ function hasConfigOverride(args, key) {
35737
35787
  return false;
35738
35788
  }
35739
35789
  function ensureEmptyDelegatedMcpConfig(workspace) {
35740
- const baseDir = path24.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
35741
- (0, import_fs13.mkdirSync)(baseDir, { recursive: true });
35742
- const workspaceHash = crypto5.createHash("sha256").update(path24.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
35743
- const filePath = path24.join(baseDir, `${workspaceHash}.json`);
35744
- (0, import_fs13.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
35790
+ const baseDir = path25.join(os19.tmpdir(), "adhdev-delegated-agent-empty-mcp");
35791
+ (0, import_fs14.mkdirSync)(baseDir, { recursive: true });
35792
+ const workspaceHash = crypto5.createHash("sha256").update(path25.resolve(workspace || os19.tmpdir())).digest("hex").slice(0, 16);
35793
+ const filePath = path25.join(baseDir, `${workspaceHash}.json`);
35794
+ (0, import_fs14.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
35745
35795
  return filePath;
35746
35796
  }
35747
35797
  function buildCoordinatorDelegatedCliLaunchOptions(input) {
@@ -36054,7 +36104,7 @@ var DaemonCliManager = class {
36054
36104
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
36055
36105
  const trimmed = (workingDir || "").trim();
36056
36106
  if (!trimmed) throw new Error("working directory required");
36057
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path24.resolve(trimmed);
36107
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os19.homedir()) : path25.resolve(trimmed);
36058
36108
  const normalizedType = this.providerLoader.resolveAlias(cliType);
36059
36109
  const rawProvider = this.providerLoader.getByAlias(cliType);
36060
36110
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -36656,14 +36706,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
36656
36706
  };
36657
36707
 
36658
36708
  // src/launch.ts
36659
- var import_child_process6 = require("child_process");
36709
+ var import_child_process7 = require("child_process");
36660
36710
  var net = __toESM(require("net"));
36661
36711
  var os24 = __toESM(require("os"));
36662
- var path32 = __toESM(require("path"));
36712
+ var path33 = __toESM(require("path"));
36663
36713
 
36664
36714
  // src/providers/provider-loader.ts
36665
36715
  var fs21 = __toESM(require("fs"));
36666
- var path31 = __toESM(require("path"));
36716
+ var path32 = __toESM(require("path"));
36667
36717
  var os23 = __toESM(require("os"));
36668
36718
  var chokidar = __toESM(require("chokidar"));
36669
36719
  init_logger();
@@ -37056,11 +37106,11 @@ init_external_sources();
37056
37106
  // src/providers/native-history/dispatcher.ts
37057
37107
  var fs20 = __toESM(require("fs"));
37058
37108
  var os22 = __toESM(require("os"));
37059
- var path29 = __toESM(require("path"));
37109
+ var path30 = __toESM(require("path"));
37060
37110
 
37061
37111
  // src/providers/native-history/claude-cli-transcript.ts
37062
37112
  var fs16 = __toESM(require("fs"));
37063
- var path25 = __toESM(require("path"));
37113
+ var path26 = __toESM(require("path"));
37064
37114
  function extractTimestampValue(value) {
37065
37115
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
37066
37116
  if (typeof value === "string") {
@@ -37216,8 +37266,8 @@ function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
37216
37266
  return records;
37217
37267
  }
37218
37268
  function readSession(sessionPath) {
37219
- if (!sessionPath || !path25.isAbsolute(sessionPath)) return null;
37220
- const basename14 = path25.basename(sessionPath, ".jsonl");
37269
+ if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
37270
+ const basename14 = path26.basename(sessionPath, ".jsonl");
37221
37271
  if (!isSafeSessionId(basename14)) return null;
37222
37272
  if (!fs16.existsSync(sessionPath)) return null;
37223
37273
  const sourceMtimeMs = statMtimeMs(sessionPath);
@@ -37238,7 +37288,7 @@ function readSession(sessionPath) {
37238
37288
 
37239
37289
  // src/providers/native-history/codex-cli-transcript.ts
37240
37290
  var fs17 = __toESM(require("fs"));
37241
- var path26 = __toESM(require("path"));
37291
+ var path27 = __toESM(require("path"));
37242
37292
  function extractTimestampValue2(value) {
37243
37293
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
37244
37294
  if (typeof value === "string") {
@@ -37475,11 +37525,11 @@ function parseSessionFile(filePath, sessionId, workspaceFallback) {
37475
37525
  return records;
37476
37526
  }
37477
37527
  function readSession2(sessionPath) {
37478
- if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
37528
+ if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
37479
37529
  if (!fs17.existsSync(sessionPath)) return null;
37480
37530
  const meta = readSessionMeta(sessionPath);
37481
37531
  const metaId = String(meta?.id ?? "").trim();
37482
- const basename14 = path26.basename(sessionPath, ".jsonl");
37532
+ const basename14 = path27.basename(sessionPath, ".jsonl");
37483
37533
  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);
37484
37534
  const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
37485
37535
  if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
@@ -37504,7 +37554,7 @@ function readSession2(sessionPath) {
37504
37554
 
37505
37555
  // src/providers/native-history/antigravity-cli-transcript.ts
37506
37556
  var fs18 = __toESM(require("fs"));
37507
- var path27 = __toESM(require("path"));
37557
+ var path28 = __toESM(require("path"));
37508
37558
  var os20 = __toESM(require("os"));
37509
37559
  function extractTimestampValue3(value) {
37510
37560
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -37527,13 +37577,13 @@ function isUuidLike(value) {
37527
37577
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
37528
37578
  }
37529
37579
  function antigravityRoot() {
37530
- return path27.join(os20.homedir(), ".gemini", "antigravity-cli");
37580
+ return path28.join(os20.homedir(), ".gemini", "antigravity-cli");
37531
37581
  }
37532
37582
  function historyJsonlPath() {
37533
- return path27.join(antigravityRoot(), "history.jsonl");
37583
+ return path28.join(antigravityRoot(), "history.jsonl");
37534
37584
  }
37535
37585
  function brainRoot() {
37536
- return path27.join(antigravityRoot(), "brain");
37586
+ return path28.join(antigravityRoot(), "brain");
37537
37587
  }
37538
37588
  function extractUserRequestContent(content) {
37539
37589
  const raw = content.trim();
@@ -37680,13 +37730,13 @@ function parsePbFile(filePath, sessionId) {
37680
37730
  ];
37681
37731
  }
37682
37732
  function readSession3(sessionPath, sessionId, workspace) {
37683
- if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
37733
+ if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
37684
37734
  if (!fs18.existsSync(sessionPath)) return null;
37685
37735
  const sourceMtimeMs = statMtimeMs3(sessionPath);
37686
37736
  const brainRootPath = brainRoot();
37687
- if (sessionPath.startsWith(brainRootPath + path27.sep) && sessionPath.endsWith(".jsonl")) {
37737
+ if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
37688
37738
  const relative5 = sessionPath.slice(brainRootPath.length + 1);
37689
- const uuidFromPath = relative5.split(path27.sep)[0];
37739
+ const uuidFromPath = relative5.split(path28.sep)[0];
37690
37740
  const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
37691
37741
  if (!resolvedSessionId) return null;
37692
37742
  const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
@@ -37702,7 +37752,7 @@ function readSession3(sessionPath, sessionId, workspace) {
37702
37752
  };
37703
37753
  }
37704
37754
  if (sessionPath.endsWith(".pb")) {
37705
- const pbSessionId = sessionId || path27.basename(sessionPath, ".pb");
37755
+ const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
37706
37756
  if (!isUuidLike(pbSessionId)) return null;
37707
37757
  const messages = parsePbFile(sessionPath, pbSessionId);
37708
37758
  if (!messages || messages.length === 0) return null;
@@ -37716,7 +37766,7 @@ function readSession3(sessionPath, sessionId, workspace) {
37716
37766
  partialReason: "antigravity_cli_pb_raw_text_extraction"
37717
37767
  };
37718
37768
  }
37719
- if (path27.basename(sessionPath) === "history.jsonl") {
37769
+ if (path28.basename(sessionPath) === "history.jsonl") {
37720
37770
  const resolvedSessionId = sessionId || "";
37721
37771
  if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
37722
37772
  const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
@@ -37764,10 +37814,10 @@ function readSession3(sessionPath, sessionId, workspace) {
37764
37814
 
37765
37815
  // src/providers/native-history/hermes-cli-transcript.ts
37766
37816
  var fs19 = __toESM(require("fs"));
37767
- var path28 = __toESM(require("path"));
37817
+ var path29 = __toESM(require("path"));
37768
37818
  var os21 = __toESM(require("os"));
37769
- var HERMES_STATE_DB = path28.join(os21.homedir(), ".hermes", "state.db");
37770
- var HERMES_LEGACY_SESSIONS_DIR = path28.join(os21.homedir(), ".hermes", "sessions");
37819
+ var HERMES_STATE_DB = path29.join(os21.homedir(), ".hermes", "state.db");
37820
+ var HERMES_LEGACY_SESSIONS_DIR = path29.join(os21.homedir(), ".hermes", "sessions");
37771
37821
  function statMtimeMs4(p) {
37772
37822
  try {
37773
37823
  return Math.floor(fs19.statSync(p).mtimeMs);
@@ -37833,7 +37883,7 @@ function readSession4(sessionPath) {
37833
37883
  }
37834
37884
  }
37835
37885
  }
37836
- if (!path28.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
37886
+ if (!path29.isAbsolute(sessionPath) || !fs19.existsSync(sessionPath)) return null;
37837
37887
  let raw;
37838
37888
  try {
37839
37889
  raw = JSON.parse(fs19.readFileSync(sessionPath, "utf8"));
@@ -37859,7 +37909,7 @@ function readSession4(sessionPath) {
37859
37909
  });
37860
37910
  }
37861
37911
  if (messages.length === 0) return null;
37862
- const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path28.basename(sessionPath, ".json").replace(/^session_/, "");
37912
+ const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
37863
37913
  return {
37864
37914
  messages,
37865
37915
  providerSessionId: sessionId,
@@ -37925,10 +37975,10 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
37925
37975
  }
37926
37976
  }
37927
37977
  function resolveClaudePath(workspace, sessionId) {
37928
- const dir = path29.join(os22.homedir(), ".claude", "projects", cwdAsDashes(workspace));
37978
+ const dir = path30.join(os22.homedir(), ".claude", "projects", cwdAsDashes(workspace));
37929
37979
  if (!fs20.existsSync(dir)) return null;
37930
37980
  if (sessionId) {
37931
- const candidate = path29.join(dir, `${sessionId}.jsonl`);
37981
+ const candidate = path30.join(dir, `${sessionId}.jsonl`);
37932
37982
  if (fs20.existsSync(candidate)) return candidate;
37933
37983
  }
37934
37984
  return null;
@@ -37954,7 +38004,7 @@ function findCodexPathBySessionId(root, sessionId) {
37954
38004
  continue;
37955
38005
  }
37956
38006
  for (const entry of entries) {
37957
- const entryPath = path29.join(current, entry.name);
38007
+ const entryPath = path30.join(current, entry.name);
37958
38008
  if (entry.isDirectory()) {
37959
38009
  stack.push(entryPath);
37960
38010
  continue;
@@ -37984,7 +38034,7 @@ function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
37984
38034
  continue;
37985
38035
  }
37986
38036
  for (const entry of entries) {
37987
- const entryPath = path29.join(current, entry.name);
38037
+ const entryPath = path30.join(current, entry.name);
37988
38038
  if (entry.isDirectory()) {
37989
38039
  stack.push(entryPath);
37990
38040
  continue;
@@ -38037,12 +38087,12 @@ function resolveRealPath(value) {
38037
38087
  }
38038
38088
  function resolveAntigravityPath(workspace) {
38039
38089
  void workspace;
38040
- const brainRoot2 = path29.join(os22.homedir(), ".gemini", "antigravity-cli", "brain");
38090
+ const brainRoot2 = path30.join(os22.homedir(), ".gemini", "antigravity-cli", "brain");
38041
38091
  if (!fs20.existsSync(brainRoot2)) return null;
38042
38092
  const cutoff = Date.now() - RECENT_WINDOW_MS;
38043
- 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);
38093
+ 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);
38044
38094
  for (const e of entries) {
38045
- const t = path29.join(e.p, ".system_generated", "logs", "transcript.jsonl");
38095
+ const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
38046
38096
  if (fs20.existsSync(t)) return t;
38047
38097
  }
38048
38098
  return null;
@@ -38050,9 +38100,9 @@ function resolveAntigravityPath(workspace) {
38050
38100
  function resolveHermesPath(workspace, sessionId) {
38051
38101
  void workspace;
38052
38102
  void sessionId;
38053
- const dbPath = path29.join(os22.homedir(), ".hermes", "state.db");
38103
+ const dbPath = path30.join(os22.homedir(), ".hermes", "state.db");
38054
38104
  if (fs20.existsSync(dbPath)) return dbPath;
38055
- const dir = path29.join(os22.homedir(), ".hermes", "sessions");
38105
+ const dir = path30.join(os22.homedir(), ".hermes", "sessions");
38056
38106
  if (!fs20.existsSync(dir)) return null;
38057
38107
  return newestRecentFile2(dir, /^session_.*\.json$/);
38058
38108
  }
@@ -38073,7 +38123,7 @@ function cwdAsDashes(cwd) {
38073
38123
  return cwd.replace(/\//g, "-");
38074
38124
  }
38075
38125
  function codexSessionsRoot() {
38076
- return path29.join(os22.homedir(), ".codex", "sessions");
38126
+ return path30.join(os22.homedir(), ".codex", "sessions");
38077
38127
  }
38078
38128
  function isUuidLikeSessionId2(sessionId) {
38079
38129
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
@@ -38085,7 +38135,7 @@ var RECENT_WINDOW_MS = 5 * 60 * 1e3;
38085
38135
  function newestRecentFile2(dir, pattern) {
38086
38136
  try {
38087
38137
  const cutoff = Date.now() - RECENT_WINDOW_MS;
38088
- 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);
38138
+ 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);
38089
38139
  return entries[0]?.p ?? null;
38090
38140
  } catch {
38091
38141
  return null;
@@ -38148,7 +38198,7 @@ var ProviderLoader = class _ProviderLoader {
38148
38198
  try {
38149
38199
  if (!fs21.existsSync(candidate) || !fs21.statSync(candidate).isDirectory()) return false;
38150
38200
  return ["ide", "extension", "cli", "acp"].some(
38151
- (category) => fs21.existsSync(path31.join(candidate, category))
38201
+ (category) => fs21.existsSync(path32.join(candidate, category))
38152
38202
  );
38153
38203
  } catch {
38154
38204
  return false;
@@ -38156,20 +38206,20 @@ var ProviderLoader = class _ProviderLoader {
38156
38206
  }
38157
38207
  static hasProviderRootMarker(candidate) {
38158
38208
  try {
38159
- return fs21.existsSync(path31.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
38209
+ return fs21.existsSync(path32.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
38160
38210
  } catch {
38161
38211
  return false;
38162
38212
  }
38163
38213
  }
38164
38214
  detectDefaultUserDir() {
38165
- const fallback = path31.join(os23.homedir(), ".adhdev", "providers");
38215
+ const fallback = path32.join(os23.homedir(), ".adhdev", "providers");
38166
38216
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
38167
38217
  const visited = /* @__PURE__ */ new Set();
38168
38218
  for (const start of this.probeStarts) {
38169
- let current = path31.resolve(start);
38219
+ let current = path32.resolve(start);
38170
38220
  while (!visited.has(current)) {
38171
38221
  visited.add(current);
38172
- const siblingCandidate = path31.join(path31.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
38222
+ const siblingCandidate = path32.join(path32.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
38173
38223
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
38174
38224
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
38175
38225
  if (envOptIn || hasMarker) {
@@ -38191,7 +38241,7 @@ var ProviderLoader = class _ProviderLoader {
38191
38241
  return { path: siblingCandidate, source };
38192
38242
  }
38193
38243
  }
38194
- const parent = path31.dirname(current);
38244
+ const parent = path32.dirname(current);
38195
38245
  if (parent === current) break;
38196
38246
  current = parent;
38197
38247
  }
@@ -38201,11 +38251,11 @@ var ProviderLoader = class _ProviderLoader {
38201
38251
  constructor(options) {
38202
38252
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
38203
38253
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
38204
- this.defaultProvidersDir = path31.join(os23.homedir(), ".adhdev", "providers");
38254
+ this.defaultProvidersDir = path32.join(os23.homedir(), ".adhdev", "providers");
38205
38255
  const detected = this.detectDefaultUserDir();
38206
38256
  this.userDir = detected.path;
38207
38257
  this.userDirSource = detected.source;
38208
- this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
38258
+ this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
38209
38259
  this.disableUpstream = false;
38210
38260
  this.applySourceConfig({
38211
38261
  userDir: options?.userDir,
@@ -38217,8 +38267,8 @@ var ProviderLoader = class _ProviderLoader {
38217
38267
  migrateMarketplaceDirToExternal() {
38218
38268
  try {
38219
38269
  const home = os23.homedir();
38220
- const oldDir = path31.join(home, ".adhdev", "marketplace");
38221
- const newDir = path31.join(home, ".adhdev", "external");
38270
+ const oldDir = path32.join(home, ".adhdev", "marketplace");
38271
+ const newDir = path32.join(home, ".adhdev", "external");
38222
38272
  if (!fs21.existsSync(oldDir)) return;
38223
38273
  if (fs21.existsSync(newDir)) {
38224
38274
  this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
@@ -38254,7 +38304,7 @@ var ProviderLoader = class _ProviderLoader {
38254
38304
  * Highest-priority editable overrides come first.
38255
38305
  */
38256
38306
  getProviderRoots() {
38257
- const externalDir = path31.join(os23.homedir(), ".adhdev", "external");
38307
+ const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
38258
38308
  return [this.userDir, externalDir, this.upstreamDir];
38259
38309
  }
38260
38310
  getSourceConfig() {
@@ -38282,7 +38332,7 @@ var ProviderLoader = class _ProviderLoader {
38282
38332
  this.userDir = detected.path;
38283
38333
  this.userDirSource = detected.source;
38284
38334
  }
38285
- this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
38335
+ this.upstreamDir = path32.join(this.defaultProvidersDir, ".upstream");
38286
38336
  this.disableUpstream = this.sourceMode === "no-upstream";
38287
38337
  if (this.explicitProviderDir) {
38288
38338
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -38296,7 +38346,7 @@ var ProviderLoader = class _ProviderLoader {
38296
38346
  * Canonical provider directory shape for a given root.
38297
38347
  */
38298
38348
  getProviderDir(root, category, type) {
38299
- return path31.join(root, category, type);
38349
+ return path32.join(root, category, type);
38300
38350
  }
38301
38351
  /**
38302
38352
  * Canonical user override directory for a provider.
@@ -38323,7 +38373,7 @@ var ProviderLoader = class _ProviderLoader {
38323
38373
  resolveProviderFile(type, ...segments) {
38324
38374
  const dir = this.findProviderDirInternal(type);
38325
38375
  if (!dir) return null;
38326
- return path31.join(dir, ...segments);
38376
+ return path32.join(dir, ...segments);
38327
38377
  }
38328
38378
  /**
38329
38379
  * Load all providers (3-tier priority)
@@ -38347,7 +38397,7 @@ var ProviderLoader = class _ProviderLoader {
38347
38397
  } else if (this.disableUpstream) {
38348
38398
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
38349
38399
  }
38350
- const externalDir = path31.join(os23.homedir(), ".adhdev", "external");
38400
+ const externalDir = path32.join(os23.homedir(), ".adhdev", "external");
38351
38401
  if (fs21.existsSync(externalDir)) {
38352
38402
  const rootEntries = (() => {
38353
38403
  try {
@@ -38369,7 +38419,7 @@ var ProviderLoader = class _ProviderLoader {
38369
38419
  const ambiguousTypes = [];
38370
38420
  for (const sourceEntry of rootEntries) {
38371
38421
  if (!sourceEntry.isDirectory()) continue;
38372
- const sourceDir = path31.join(externalDir, sourceEntry.name);
38422
+ const sourceDir = path32.join(externalDir, sourceEntry.name);
38373
38423
  const sourceLoaded = this.loadDir(sourceDir);
38374
38424
  if (sourceLoaded > 0) {
38375
38425
  totalLoaded += sourceLoaded;
@@ -38385,7 +38435,7 @@ var ProviderLoader = class _ProviderLoader {
38385
38435
  ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
38386
38436
  }
38387
38437
  if (resolved.source && resolved.source !== "?") {
38388
- const sourceDir = path31.join(externalDir, resolved.source);
38438
+ const sourceDir = path32.join(externalDir, resolved.source);
38389
38439
  const reloadCount = this.loadDir(sourceDir);
38390
38440
  if (reloadCount === 0) {
38391
38441
  this.log(`Active source "${resolved.source}" no longer provides ${type}`);
@@ -38418,7 +38468,7 @@ var ProviderLoader = class _ProviderLoader {
38418
38468
  if (!fs21.existsSync(this.upstreamDir)) return false;
38419
38469
  try {
38420
38470
  return fs21.readdirSync(this.upstreamDir).some(
38421
- (d) => fs21.statSync(path31.join(this.upstreamDir, d)).isDirectory()
38471
+ (d) => fs21.statSync(path32.join(this.upstreamDir, d)).isDirectory()
38422
38472
  );
38423
38473
  } catch {
38424
38474
  return false;
@@ -38916,8 +38966,8 @@ var ProviderLoader = class _ProviderLoader {
38916
38966
  resolved._resolvedScriptDir = entry.scriptDir;
38917
38967
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
38918
38968
  if (providerDir) {
38919
- const fullDir = path31.join(providerDir, entry.scriptDir);
38920
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38969
+ const fullDir = path32.join(providerDir, entry.scriptDir);
38970
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38921
38971
  }
38922
38972
  matched = true;
38923
38973
  }
@@ -38935,8 +38985,8 @@ var ProviderLoader = class _ProviderLoader {
38935
38985
  resolved._resolvedScriptDir = base.defaultScriptDir;
38936
38986
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
38937
38987
  if (providerDir) {
38938
- const fullDir = path31.join(providerDir, base.defaultScriptDir);
38939
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
38988
+ const fullDir = path32.join(providerDir, base.defaultScriptDir);
38989
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38940
38990
  }
38941
38991
  }
38942
38992
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -38953,8 +39003,8 @@ var ProviderLoader = class _ProviderLoader {
38953
39003
  resolved._resolvedScriptDir = dirOverride;
38954
39004
  resolved._resolvedScriptsSource = `versions:${range}`;
38955
39005
  if (providerDir) {
38956
- const fullDir = path31.join(providerDir, dirOverride);
38957
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
39006
+ const fullDir = path32.join(providerDir, dirOverride);
39007
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38958
39008
  }
38959
39009
  }
38960
39010
  } else if (override.scripts) {
@@ -38970,8 +39020,8 @@ var ProviderLoader = class _ProviderLoader {
38970
39020
  resolved._resolvedScriptDir = base.defaultScriptDir;
38971
39021
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
38972
39022
  if (providerDir) {
38973
- const fullDir = path31.join(providerDir, base.defaultScriptDir);
38974
- resolved._resolvedScriptsPath = fs21.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
39023
+ const fullDir = path32.join(providerDir, base.defaultScriptDir);
39024
+ resolved._resolvedScriptsPath = fs21.existsSync(path32.join(fullDir, "scripts.js")) ? path32.join(fullDir, "scripts.js") : fullDir;
38975
39025
  }
38976
39026
  }
38977
39027
  }
@@ -38988,13 +39038,13 @@ var ProviderLoader = class _ProviderLoader {
38988
39038
  if (providerDir2) {
38989
39039
  for (const [scriptName, override] of Object.entries(base.overrides)) {
38990
39040
  if (!override || typeof override.path !== "string") continue;
38991
- const fullPath = path31.join(providerDir2, override.path);
39041
+ const fullPath = path32.join(providerDir2, override.path);
38992
39042
  if (!fs21.existsSync(fullPath)) {
38993
39043
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
38994
39044
  continue;
38995
39045
  }
38996
39046
  try {
38997
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir2)));
39047
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir2)));
38998
39048
  delete require.cache[require.resolve(fullPath)];
38999
39049
  const fn = require(fullPath);
39000
39050
  const target = typeof fn === "function" ? fn : fn && fn[scriptName];
@@ -39020,17 +39070,17 @@ var ProviderLoader = class _ProviderLoader {
39020
39070
  if (providerDir) {
39021
39071
  try {
39022
39072
  const fs30 = require("fs");
39023
- const path40 = require("path");
39073
+ const path41 = require("path");
39024
39074
  const candidates = [];
39025
39075
  if (Array.isArray(base.compatibility)) {
39026
39076
  for (const entry of base.compatibility) {
39027
39077
  if (typeof entry?.spec !== "string") continue;
39028
39078
  const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
39029
- if (matches) candidates.push(path40.join(providerDir, entry.spec));
39079
+ if (matches) candidates.push(path41.join(providerDir, entry.spec));
39030
39080
  }
39031
39081
  }
39032
- candidates.push(path40.join(providerDir, "specs", "default.json"));
39033
- candidates.push(path40.join(providerDir, "spec.json"));
39082
+ candidates.push(path41.join(providerDir, "specs", "default.json"));
39083
+ candidates.push(path41.join(providerDir, "spec.json"));
39034
39084
  const specPath = candidates.find((p) => fs30.existsSync(p));
39035
39085
  if (specPath) {
39036
39086
  resolved._resolvedSpecPath = specPath;
@@ -39061,10 +39111,10 @@ var ProviderLoader = class _ProviderLoader {
39061
39111
  format = `spec-${nh.source.kind}`;
39062
39112
  reader = (input) => executeNativeHistory(nh, input);
39063
39113
  } else if (nh.override_path) {
39064
- const overrideFile = path40.resolve(providerDir, nh.override_path);
39114
+ const overrideFile = path41.resolve(providerDir, nh.override_path);
39065
39115
  if (fs30.existsSync(overrideFile)) {
39066
39116
  try {
39067
- registerProviderScriptRootSafely(path40.dirname(path40.dirname(providerDir)));
39117
+ registerProviderScriptRootSafely(path41.dirname(path41.dirname(providerDir)));
39068
39118
  delete require.cache[require.resolve(overrideFile)];
39069
39119
  const mod = require(overrideFile);
39070
39120
  const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
@@ -39107,15 +39157,15 @@ var ProviderLoader = class _ProviderLoader {
39107
39157
  this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
39108
39158
  return null;
39109
39159
  }
39110
- const dir = path31.join(providerDir, scriptDir);
39160
+ const dir = path32.join(providerDir, scriptDir);
39111
39161
  if (!fs21.existsSync(dir)) {
39112
39162
  this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
39113
39163
  return null;
39114
39164
  }
39115
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir)));
39165
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(providerDir)));
39116
39166
  const cached2 = this.scriptsCache.get(dir);
39117
39167
  if (cached2) return cached2;
39118
- const scriptsJs = path31.join(dir, "scripts.js");
39168
+ const scriptsJs = path32.join(dir, "scripts.js");
39119
39169
  if (fs21.existsSync(scriptsJs)) {
39120
39170
  try {
39121
39171
  delete require.cache[require.resolve(scriptsJs)];
@@ -39160,7 +39210,7 @@ var ProviderLoader = class _ProviderLoader {
39160
39210
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
39161
39211
  if (reloadTimer) clearTimeout(reloadTimer);
39162
39212
  reloadTimer = setTimeout(() => {
39163
- this.log(`File changed: ${path31.basename(filePath)}, reloading...`);
39213
+ this.log(`File changed: ${path32.basename(filePath)}, reloading...`);
39164
39214
  this.reload();
39165
39215
  }, 300);
39166
39216
  }
@@ -39228,7 +39278,7 @@ var ProviderLoader = class _ProviderLoader {
39228
39278
  }
39229
39279
  this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
39230
39280
  const https = require("https");
39231
- const regMetaPath = path31.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
39281
+ const regMetaPath = path32.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
39232
39282
  let cachedChecksums = {};
39233
39283
  try {
39234
39284
  if (fs21.existsSync(regMetaPath)) {
@@ -39286,9 +39336,9 @@ var ProviderLoader = class _ProviderLoader {
39286
39336
  this.log(`\u26A0 Registry checksum mismatch for ${type}@${version} \u2014 skipping`);
39287
39337
  continue;
39288
39338
  }
39289
- const providerDir = path31.join(this.upstreamDir, category, type);
39339
+ const providerDir = path32.join(this.upstreamDir, category, type);
39290
39340
  fs21.mkdirSync(providerDir, { recursive: true });
39291
- fs21.writeFileSync(path31.join(providerDir, "provider.json"), manifestBody, "utf-8");
39341
+ fs21.writeFileSync(path32.join(providerDir, "provider.json"), manifestBody, "utf-8");
39292
39342
  cachedChecksums[cacheKey] = checksum;
39293
39343
  updatedCount++;
39294
39344
  this.log(`\u2713 Registry updated: ${category}/${type}@${version}`);
@@ -39315,7 +39365,7 @@ var ProviderLoader = class _ProviderLoader {
39315
39365
  const { exec: exec7 } = require("child_process");
39316
39366
  const { promisify: promisify8 } = require("util");
39317
39367
  const execAsync5 = promisify8(exec7);
39318
- const metaPath = path31.join(this.upstreamDir, _ProviderLoader.META_FILE);
39368
+ const metaPath = path32.join(this.upstreamDir, _ProviderLoader.META_FILE);
39319
39369
  let prevEtag = "";
39320
39370
  let prevTimestamp = 0;
39321
39371
  try {
@@ -39375,17 +39425,17 @@ var ProviderLoader = class _ProviderLoader {
39375
39425
  return { updated: false };
39376
39426
  }
39377
39427
  this.log("Downloading latest providers from GitHub...");
39378
- const tmpTar = path31.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
39379
- const tmpExtract = path31.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
39428
+ const tmpTar = path32.join(os23.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
39429
+ const tmpExtract = path32.join(os23.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
39380
39430
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
39381
39431
  fs21.mkdirSync(tmpExtract, { recursive: true });
39382
39432
  await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
39383
39433
  const extracted = fs21.readdirSync(tmpExtract);
39384
39434
  const rootDir = extracted.find(
39385
- (d) => fs21.statSync(path31.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
39435
+ (d) => fs21.statSync(path32.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
39386
39436
  );
39387
39437
  if (!rootDir) throw new Error("Unexpected tarball structure");
39388
- const sourceDir = path31.join(tmpExtract, rootDir);
39438
+ const sourceDir = path32.join(tmpExtract, rootDir);
39389
39439
  const backupDir = this.upstreamDir + ".bak";
39390
39440
  if (fs21.existsSync(this.upstreamDir)) {
39391
39441
  if (fs21.existsSync(backupDir)) fs21.rmSync(backupDir, { recursive: true, force: true });
@@ -39460,8 +39510,8 @@ var ProviderLoader = class _ProviderLoader {
39460
39510
  copyDirRecursive(src, dest) {
39461
39511
  fs21.mkdirSync(dest, { recursive: true });
39462
39512
  for (const entry of fs21.readdirSync(src, { withFileTypes: true })) {
39463
- const srcPath = path31.join(src, entry.name);
39464
- const destPath = path31.join(dest, entry.name);
39513
+ const srcPath = path32.join(src, entry.name);
39514
+ const destPath = path32.join(dest, entry.name);
39465
39515
  if (entry.isDirectory()) {
39466
39516
  this.copyDirRecursive(srcPath, destPath);
39467
39517
  } else {
@@ -39472,7 +39522,7 @@ var ProviderLoader = class _ProviderLoader {
39472
39522
  /** .meta.json save */
39473
39523
  writeMeta(metaPath, etag, timestamp) {
39474
39524
  try {
39475
- fs21.mkdirSync(path31.dirname(metaPath), { recursive: true });
39525
+ fs21.mkdirSync(path32.dirname(metaPath), { recursive: true });
39476
39526
  fs21.writeFileSync(metaPath, JSON.stringify({
39477
39527
  etag,
39478
39528
  timestamp,
@@ -39492,7 +39542,7 @@ var ProviderLoader = class _ProviderLoader {
39492
39542
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
39493
39543
  if (hasManifest) count++;
39494
39544
  for (const entry of entries) {
39495
- if (entry.isDirectory()) scan(path31.join(d, entry.name));
39545
+ if (entry.isDirectory()) scan(path32.join(d, entry.name));
39496
39546
  }
39497
39547
  } catch {
39498
39548
  }
@@ -39718,10 +39768,10 @@ var ProviderLoader = class _ProviderLoader {
39718
39768
  if (!provider) return null;
39719
39769
  const cat = provider.category;
39720
39770
  const searchRoots = this.getProviderRoots();
39721
- const hasManifest = (dir) => fs21.existsSync(path31.join(dir, "provider.v1.json")) || fs21.existsSync(path31.join(dir, "provider.json"));
39771
+ const hasManifest = (dir) => fs21.existsSync(path32.join(dir, "provider.v1.json")) || fs21.existsSync(path32.join(dir, "provider.json"));
39722
39772
  const readManifestType = (dir) => {
39723
39773
  for (const file of ["provider.v1.json", "provider.json"]) {
39724
- const p = path31.join(dir, file);
39774
+ const p = path32.join(dir, file);
39725
39775
  if (!fs21.existsSync(p)) continue;
39726
39776
  try {
39727
39777
  const data = JSON.parse(fs21.readFileSync(p, "utf-8"));
@@ -39735,12 +39785,12 @@ var ProviderLoader = class _ProviderLoader {
39735
39785
  if (!fs21.existsSync(root)) continue;
39736
39786
  const candidate = this.getProviderDir(root, cat, type);
39737
39787
  if (hasManifest(candidate)) return candidate;
39738
- const catDir = path31.join(root, cat);
39788
+ const catDir = path32.join(root, cat);
39739
39789
  if (fs21.existsSync(catDir)) {
39740
39790
  try {
39741
39791
  for (const entry of fs21.readdirSync(catDir, { withFileTypes: true })) {
39742
39792
  if (!entry.isDirectory()) continue;
39743
- const entryDir = path31.join(catDir, entry.name);
39793
+ const entryDir = path32.join(catDir, entry.name);
39744
39794
  const manifestType = readManifestType(entryDir);
39745
39795
  if (manifestType === type) return entryDir;
39746
39796
  }
@@ -39756,7 +39806,7 @@ var ProviderLoader = class _ProviderLoader {
39756
39806
  * (template substitution is NOT applied here — scripts.js handles that)
39757
39807
  */
39758
39808
  buildScriptWrappersFromDir(dir) {
39759
- const scriptsJs = path31.join(dir, "scripts.js");
39809
+ const scriptsJs = path32.join(dir, "scripts.js");
39760
39810
  if (fs21.existsSync(scriptsJs)) {
39761
39811
  try {
39762
39812
  delete require.cache[require.resolve(scriptsJs)];
@@ -39770,7 +39820,7 @@ var ProviderLoader = class _ProviderLoader {
39770
39820
  for (const file of fs21.readdirSync(dir)) {
39771
39821
  if (!file.endsWith(".js")) continue;
39772
39822
  const scriptName = toCamel(file.replace(".js", ""));
39773
- const filePath = path31.join(dir, file);
39823
+ const filePath = path32.join(dir, file);
39774
39824
  result[scriptName] = (...args) => {
39775
39825
  try {
39776
39826
  let content = fs21.readFileSync(filePath, "utf-8");
@@ -39832,7 +39882,7 @@ var ProviderLoader = class _ProviderLoader {
39832
39882
  const hasJson = entries.some((e) => e.name === "provider.json");
39833
39883
  if (hasV1 || hasJson) {
39834
39884
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
39835
- const jsonPath = path31.join(d, manifestFile);
39885
+ const jsonPath = path32.join(d, manifestFile);
39836
39886
  try {
39837
39887
  const raw = fs21.readFileSync(jsonPath, "utf-8");
39838
39888
  const mod = JSON.parse(raw);
@@ -39872,10 +39922,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39872
39922
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
39873
39923
  } else {
39874
39924
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
39875
- const scriptsPath = path31.join(d, "scripts.js");
39925
+ const scriptsPath = path32.join(d, "scripts.js");
39876
39926
  if (!hasCompatibility && fs21.existsSync(scriptsPath)) {
39877
39927
  try {
39878
- registerProviderScriptRootSafely(path31.dirname(path31.dirname(d)));
39928
+ registerProviderScriptRootSafely(path32.dirname(path32.dirname(d)));
39879
39929
  delete require.cache[require.resolve(scriptsPath)];
39880
39930
  const scripts = require(scriptsPath);
39881
39931
  normalizedProvider.scripts = scripts;
@@ -39883,7 +39933,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39883
39933
  this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
39884
39934
  }
39885
39935
  }
39886
- const externalDirAbs = path31.join(os23.homedir(), ".adhdev", "external");
39936
+ const externalDirAbs = path32.join(os23.homedir(), ".adhdev", "external");
39887
39937
  const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
39888
39938
  try {
39889
39939
  const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS(provider_trust_exports));
@@ -39893,8 +39943,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39893
39943
  normalizedProvider._sourceTrust = trust;
39894
39944
  normalizedProvider._manifestShape = shape;
39895
39945
  if (layer === "external") {
39896
- const rel = path31.relative(externalDirAbs, d);
39897
- const firstSeg = rel.split(path31.sep)[0];
39946
+ const rel = path32.relative(externalDirAbs, d);
39947
+ const firstSeg = rel.split(path32.sep)[0];
39898
39948
  if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
39899
39949
  }
39900
39950
  } catch {
@@ -39918,7 +39968,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
39918
39968
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
39919
39969
  if (d === dir && entry.name === "examples") continue;
39920
39970
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
39921
- scan(path31.join(d, entry.name));
39971
+ scan(path32.join(d, entry.name));
39922
39972
  }
39923
39973
  }
39924
39974
  };
@@ -40000,7 +40050,7 @@ function findMacAppProcessPids(psOutput, appPaths) {
40000
40050
  // src/launch.ts
40001
40051
  async function execQuiet(command, options = {}) {
40002
40052
  return new Promise((resolve24) => {
40003
- (0, import_child_process6.exec)(command, options, (error, stdout) => {
40053
+ (0, import_child_process7.exec)(command, options, (error, stdout) => {
40004
40054
  if (error) return resolve24("");
40005
40055
  resolve24(stdout.toString());
40006
40056
  });
@@ -40251,8 +40301,8 @@ async function detectCurrentWorkspace(ideId) {
40251
40301
  const appNameMap = getMacAppIdentifiers();
40252
40302
  const appName = appNameMap[ideId];
40253
40303
  if (appName) {
40254
- const storagePath = path32.join(
40255
- process.env.APPDATA || path32.join(os24.homedir(), "AppData", "Roaming"),
40304
+ const storagePath = path33.join(
40305
+ process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Roaming"),
40256
40306
  appName,
40257
40307
  "storage.json"
40258
40308
  );
@@ -40400,10 +40450,10 @@ async function launchMacOS(ide, port, workspace, newWindow) {
40400
40450
  const canUseAppLauncher = !!appName;
40401
40451
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
40402
40452
  if (!useAppLauncher && ide.cliCommand) {
40403
- (0, import_child_process6.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
40453
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
40404
40454
  } else if (appName) {
40405
40455
  const openArgs = ["-a", appName, "--args", ...args];
40406
- (0, import_child_process6.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
40456
+ (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
40407
40457
  } else {
40408
40458
  throw new Error(`No app identifier or CLI for ${ide.displayName}`);
40409
40459
  }
@@ -40429,7 +40479,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
40429
40479
  const args = ["--remote-debugging-port=" + port];
40430
40480
  if (newWindow) args.push("--new-window");
40431
40481
  if (workspace) args.push(workspace);
40432
- (0, import_child_process6.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
40482
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
40433
40483
  }
40434
40484
  function getAvailableIdeIds() {
40435
40485
  return getProviderLoader().getAvailableIdeTypes();
@@ -40444,9 +40494,9 @@ init_logger();
40444
40494
 
40445
40495
  // src/logging/command-log.ts
40446
40496
  var fs22 = __toESM(require("fs"));
40447
- var path33 = __toESM(require("path"));
40497
+ var path34 = __toESM(require("path"));
40448
40498
  var os25 = __toESM(require("os"));
40449
- 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");
40499
+ 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");
40450
40500
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
40451
40501
  var MAX_DAYS = 7;
40452
40502
  try {
@@ -40484,13 +40534,13 @@ function getDateStr2() {
40484
40534
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
40485
40535
  }
40486
40536
  var currentDate2 = getDateStr2();
40487
- var currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40537
+ var currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40488
40538
  var writeCount2 = 0;
40489
40539
  function checkRotation() {
40490
40540
  const today = getDateStr2();
40491
40541
  if (today !== currentDate2) {
40492
40542
  currentDate2 = today;
40493
- currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40543
+ currentFile = path34.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
40494
40544
  cleanOldFiles();
40495
40545
  }
40496
40546
  }
@@ -40504,7 +40554,7 @@ function cleanOldFiles() {
40504
40554
  const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
40505
40555
  if (dateMatch && dateMatch[1] < cutoffStr) {
40506
40556
  try {
40507
- fs22.unlinkSync(path33.join(LOG_DIR2, file));
40557
+ fs22.unlinkSync(path34.join(LOG_DIR2, file));
40508
40558
  } catch {
40509
40559
  }
40510
40560
  }
@@ -40601,9 +40651,9 @@ var import_node_child_process4 = require("child_process");
40601
40651
  var import_node_util4 = require("util");
40602
40652
  var execFileAsync3 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
40603
40653
  var MAX_CHANGED_FILES2 = 500;
40604
- function topLevel(path40) {
40605
- const slash = path40.indexOf("/");
40606
- return slash === -1 ? path40 : path40.slice(0, slash);
40654
+ function topLevel(path41) {
40655
+ const slash = path41.indexOf("/");
40656
+ return slash === -1 ? path41 : path41.slice(0, slash);
40607
40657
  }
40608
40658
  async function analyzeMeshRefineNodeChangeArea(args) {
40609
40659
  const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
@@ -40701,10 +40751,10 @@ function runGit2(repoRoot, args) {
40701
40751
  }
40702
40752
  }
40703
40753
  function readRecord6(repoRoot) {
40704
- const path40 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
40705
- if (!(0, import_node_fs4.existsSync)(path40)) return null;
40754
+ const path41 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
40755
+ if (!(0, import_node_fs4.existsSync)(path41)) return null;
40706
40756
  try {
40707
- const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path40, "utf8"));
40757
+ const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path41, "utf8"));
40708
40758
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
40709
40759
  } catch {
40710
40760
  return null;
@@ -40769,7 +40819,7 @@ function buildPreviewFreshness(repoRoot) {
40769
40819
  init_mesh_refine_status();
40770
40820
 
40771
40821
  // src/mesh/mesh-init.ts
40772
- var import_fs14 = require("fs");
40822
+ var import_fs15 = require("fs");
40773
40823
  var import_path10 = require("path");
40774
40824
  var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
40775
40825
  var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
@@ -40785,21 +40835,21 @@ var CANDIDATE_STALE_INPUTS = [
40785
40835
  ];
40786
40836
  function writeConfigFile(workspace, relativePath, config) {
40787
40837
  const target = (0, import_path10.join)(workspace, relativePath);
40788
- (0, import_fs14.mkdirSync)((0, import_path10.dirname)(target), { recursive: true });
40789
- (0, import_fs14.writeFileSync)(target, `${JSON.stringify(config, null, 2)}
40838
+ (0, import_fs15.mkdirSync)((0, import_path10.dirname)(target), { recursive: true });
40839
+ (0, import_fs15.writeFileSync)(target, `${JSON.stringify(config, null, 2)}
40790
40840
  `, "utf-8");
40791
40841
  return target;
40792
40842
  }
40793
40843
  function suggestMeshWorktreeBootstrapConfig(workspace) {
40794
40844
  const commands = [];
40795
- const hasPackageJson = (0, import_fs14.existsSync)((0, import_path10.join)(workspace, "package.json"));
40796
- const hasNpmLock = (0, import_fs14.existsSync)((0, import_path10.join)(workspace, "package-lock.json"));
40845
+ const hasPackageJson = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package.json"));
40846
+ const hasNpmLock = (0, import_fs15.existsSync)((0, import_path10.join)(workspace, "package-lock.json"));
40797
40847
  if (hasPackageJson) {
40798
40848
  commands.push(
40799
40849
  hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
40800
40850
  );
40801
40851
  }
40802
- const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0, import_fs14.existsSync)((0, import_path10.join)(workspace, relative5)));
40852
+ const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => (0, import_fs15.existsSync)((0, import_path10.join)(workspace, relative5)));
40803
40853
  if (!commands.length) {
40804
40854
  return { commands, staleInputs };
40805
40855
  }
@@ -41231,17 +41281,17 @@ function buildStatusSnapshot(options) {
41231
41281
  init_build_info();
41232
41282
 
41233
41283
  // src/commands/upgrade-helper.ts
41234
- var import_child_process7 = require("child_process");
41235
41284
  var import_child_process8 = require("child_process");
41285
+ var import_child_process9 = require("child_process");
41236
41286
  var fs23 = __toESM(require("fs"));
41237
41287
  var os27 = __toESM(require("os"));
41238
- var path34 = __toESM(require("path"));
41288
+ var path35 = __toESM(require("path"));
41239
41289
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
41240
41290
  function getUpgradeLogPath() {
41241
41291
  const home = os27.homedir();
41242
- const dir = path34.join(home, ".adhdev");
41292
+ const dir = path35.join(home, ".adhdev");
41243
41293
  fs23.mkdirSync(dir, { recursive: true });
41244
- return path34.join(dir, "daemon-upgrade.log");
41294
+ return path35.join(dir, "daemon-upgrade.log");
41245
41295
  }
41246
41296
  function appendUpgradeLog(message) {
41247
41297
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
@@ -41252,14 +41302,14 @@ function appendUpgradeLog(message) {
41252
41302
  }
41253
41303
  }
41254
41304
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
41255
- const binDir = path34.dirname(nodeExecutable);
41305
+ const binDir = path35.dirname(nodeExecutable);
41256
41306
  if (platform10 === "win32") {
41257
- const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
41307
+ const npmCliPath = path35.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
41258
41308
  if (fs23.existsSync(npmCliPath)) {
41259
41309
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
41260
41310
  }
41261
41311
  for (const candidate of ["npm.exe", "npm"]) {
41262
- const candidatePath = path34.join(binDir, candidate);
41312
+ const candidatePath = path35.join(binDir, candidate);
41263
41313
  if (fs23.existsSync(candidatePath)) {
41264
41314
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
41265
41315
  }
@@ -41267,7 +41317,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
41267
41317
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
41268
41318
  }
41269
41319
  for (const candidate of ["npm"]) {
41270
- const candidatePath = path34.join(binDir, candidate);
41320
+ const candidatePath = path35.join(binDir, candidate);
41271
41321
  if (fs23.existsSync(candidatePath)) {
41272
41322
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
41273
41323
  }
@@ -41284,13 +41334,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
41284
41334
  let currentDir = resolvedPath;
41285
41335
  try {
41286
41336
  if (fs23.statSync(resolvedPath).isFile()) {
41287
- currentDir = path34.dirname(resolvedPath);
41337
+ currentDir = path35.dirname(resolvedPath);
41288
41338
  }
41289
41339
  } catch {
41290
- currentDir = path34.dirname(resolvedPath);
41340
+ currentDir = path35.dirname(resolvedPath);
41291
41341
  }
41292
41342
  while (true) {
41293
- const packageJsonPath = path34.join(currentDir, "package.json");
41343
+ const packageJsonPath = path35.join(currentDir, "package.json");
41294
41344
  try {
41295
41345
  if (fs23.existsSync(packageJsonPath)) {
41296
41346
  const parsed = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
@@ -41301,7 +41351,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
41301
41351
  }
41302
41352
  } catch {
41303
41353
  }
41304
- const parentDir = path34.dirname(currentDir);
41354
+ const parentDir = path35.dirname(currentDir);
41305
41355
  if (parentDir === currentDir) {
41306
41356
  return null;
41307
41357
  }
@@ -41309,13 +41359,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
41309
41359
  }
41310
41360
  }
41311
41361
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
41312
- const nodeModulesDir = packageName.startsWith("@") ? path34.dirname(path34.dirname(packageRoot)) : path34.dirname(packageRoot);
41313
- if (path34.basename(nodeModulesDir) !== "node_modules") {
41362
+ const nodeModulesDir = packageName.startsWith("@") ? path35.dirname(path35.dirname(packageRoot)) : path35.dirname(packageRoot);
41363
+ if (path35.basename(nodeModulesDir) !== "node_modules") {
41314
41364
  return null;
41315
41365
  }
41316
- const maybeLibDir = path34.dirname(nodeModulesDir);
41317
- if (path34.basename(maybeLibDir) === "lib") {
41318
- return path34.dirname(maybeLibDir);
41366
+ const maybeLibDir = path35.dirname(nodeModulesDir);
41367
+ if (path35.basename(maybeLibDir) === "lib") {
41368
+ return path35.dirname(maybeLibDir);
41319
41369
  }
41320
41370
  return maybeLibDir;
41321
41371
  }
@@ -41343,6 +41393,16 @@ function buildPinnedGlobalInstallCommand(options) {
41343
41393
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
41344
41394
  };
41345
41395
  }
41396
+ function buildInstallEnvWithNodeOnPath(baseEnv = process.env) {
41397
+ if (process.platform !== "win32") return { ...baseEnv };
41398
+ const nodeBinDir = path35.dirname(process.execPath);
41399
+ if (!nodeBinDir) return { ...baseEnv };
41400
+ const env = { ...baseEnv };
41401
+ const pathKey = Object.keys(env).find((k) => k.toLowerCase() === "path") || "PATH";
41402
+ const current = env[pathKey] || "";
41403
+ env[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
41404
+ return env;
41405
+ }
41346
41406
  function getNpmExecOptions(platform10 = process.platform) {
41347
41407
  if (platform10 === "win32") {
41348
41408
  return { shell: false, windowsHide: true };
@@ -41351,7 +41411,7 @@ function getNpmExecOptions(platform10 = process.platform) {
41351
41411
  }
41352
41412
  function execNpmCommandSync(args, options = {}, surface) {
41353
41413
  const execOptions = surface?.execOptions || getNpmExecOptions();
41354
- return (0, import_child_process7.execFileSync)(
41414
+ return (0, import_child_process8.execFileSync)(
41355
41415
  surface?.npmExecutable || "npm",
41356
41416
  [...surface?.npmArgsPrefix || [], ...args],
41357
41417
  {
@@ -41364,7 +41424,7 @@ function execNpmCommandSync(args, options = {}, surface) {
41364
41424
  function killPid(pid) {
41365
41425
  try {
41366
41426
  if (process.platform === "win32") {
41367
- (0, import_child_process7.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
41427
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
41368
41428
  } else {
41369
41429
  process.kill(pid, "SIGTERM");
41370
41430
  }
@@ -41376,7 +41436,7 @@ function killPid(pid) {
41376
41436
  function getWindowsProcessCommandLine(pid) {
41377
41437
  const pidFilter = `ProcessId=${pid}`;
41378
41438
  try {
41379
- const psOut = (0, import_child_process7.execFileSync)("powershell.exe", [
41439
+ const psOut = (0, import_child_process8.execFileSync)("powershell.exe", [
41380
41440
  "-NoProfile",
41381
41441
  "-NonInteractive",
41382
41442
  "-ExecutionPolicy",
@@ -41388,7 +41448,7 @@ function getWindowsProcessCommandLine(pid) {
41388
41448
  } catch {
41389
41449
  }
41390
41450
  try {
41391
- const wmicOut = (0, import_child_process7.execFileSync)("wmic", [
41451
+ const wmicOut = (0, import_child_process8.execFileSync)("wmic", [
41392
41452
  "process",
41393
41453
  "where",
41394
41454
  pidFilter,
@@ -41404,7 +41464,7 @@ function getProcessCommandLine(pid) {
41404
41464
  if (!Number.isFinite(pid) || pid <= 0) return null;
41405
41465
  if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
41406
41466
  try {
41407
- const text = (0, import_child_process7.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
41467
+ const text = (0, import_child_process8.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
41408
41468
  encoding: "utf8",
41409
41469
  timeout: 3e3,
41410
41470
  stdio: ["ignore", "pipe", "ignore"]
@@ -41430,7 +41490,7 @@ async function waitForPidExit(pid, timeoutMs) {
41430
41490
  }
41431
41491
  }
41432
41492
  function stopSessionHostProcesses(appName) {
41433
- const pidFile = path34.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
41493
+ const pidFile = path35.join(os27.homedir(), ".adhdev", `${appName}-session-host.pid`);
41434
41494
  try {
41435
41495
  if (fs23.existsSync(pidFile)) {
41436
41496
  const pid = Number.parseInt(fs23.readFileSync(pidFile, "utf8").trim(), 10);
@@ -41447,7 +41507,7 @@ function stopSessionHostProcesses(appName) {
41447
41507
  }
41448
41508
  }
41449
41509
  function removeDaemonPidFile() {
41450
- const pidFile = path34.join(os27.homedir(), ".adhdev", "daemon.pid");
41510
+ const pidFile = path35.join(os27.homedir(), ".adhdev", "daemon.pid");
41451
41511
  try {
41452
41512
  fs23.unlinkSync(pidFile);
41453
41513
  } catch {
@@ -41458,7 +41518,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
41458
41518
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
41459
41519
  if (!npmRoot) return;
41460
41520
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
41461
- const binDir = process.platform === "win32" ? npmPrefix : path34.join(npmPrefix, "bin");
41521
+ const binDir = process.platform === "win32" ? npmPrefix : path35.join(npmPrefix, "bin");
41462
41522
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
41463
41523
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
41464
41524
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -41466,31 +41526,31 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
41466
41526
  }
41467
41527
  if (pkgName.startsWith("@")) {
41468
41528
  const [scope, name] = pkgName.split("/");
41469
- const scopeDir = path34.join(npmRoot, scope);
41529
+ const scopeDir = path35.join(npmRoot, scope);
41470
41530
  if (!fs23.existsSync(scopeDir)) return;
41471
41531
  for (const entry of fs23.readdirSync(scopeDir)) {
41472
41532
  if (!entry.startsWith(`.${name}-`)) continue;
41473
- fs23.rmSync(path34.join(scopeDir, entry), { recursive: true, force: true });
41474
- appendUpgradeLog(`Removed stale scoped staging dir: ${path34.join(scopeDir, entry)}`);
41533
+ fs23.rmSync(path35.join(scopeDir, entry), { recursive: true, force: true });
41534
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path35.join(scopeDir, entry)}`);
41475
41535
  }
41476
41536
  } else {
41477
41537
  for (const entry of fs23.readdirSync(npmRoot)) {
41478
41538
  if (!entry.startsWith(`.${pkgName}-`)) continue;
41479
- fs23.rmSync(path34.join(npmRoot, entry), { recursive: true, force: true });
41480
- appendUpgradeLog(`Removed stale staging dir: ${path34.join(npmRoot, entry)}`);
41539
+ fs23.rmSync(path35.join(npmRoot, entry), { recursive: true, force: true });
41540
+ appendUpgradeLog(`Removed stale staging dir: ${path35.join(npmRoot, entry)}`);
41481
41541
  }
41482
41542
  }
41483
41543
  if (fs23.existsSync(binDir)) {
41484
41544
  for (const entry of fs23.readdirSync(binDir)) {
41485
41545
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
41486
- fs23.rmSync(path34.join(binDir, entry), { recursive: true, force: true });
41487
- appendUpgradeLog(`Removed stale bin staging entry: ${path34.join(binDir, entry)}`);
41546
+ fs23.rmSync(path35.join(binDir, entry), { recursive: true, force: true });
41547
+ appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
41488
41548
  }
41489
41549
  }
41490
41550
  }
41491
41551
  function spawnDetachedDaemonUpgradeHelper(payload) {
41492
41552
  const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
41493
- const child = (0, import_child_process8.spawn)(process.execPath, process.argv.slice(1), {
41553
+ const child = (0, import_child_process9.spawn)(process.execPath, process.argv.slice(1), {
41494
41554
  detached: true,
41495
41555
  stdio: "ignore",
41496
41556
  windowsHide: true,
@@ -41520,13 +41580,14 @@ async function runDaemonUpgradeHelper(payload) {
41520
41580
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
41521
41581
  const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
41522
41582
  appendUpgradeLog(`Installing ${spec}`);
41523
- const installOutput = (0, import_child_process7.execFileSync)(
41583
+ const installOutput = (0, import_child_process8.execFileSync)(
41524
41584
  installCommand.command,
41525
41585
  installCommand.args,
41526
41586
  {
41527
41587
  encoding: "utf8",
41528
41588
  stdio: "pipe",
41529
41589
  maxBuffer: 20 * 1024 * 1024,
41590
+ env: buildInstallEnvWithNodeOnPath(),
41530
41591
  ...installCommand.execOptions
41531
41592
  }
41532
41593
  );
@@ -41542,7 +41603,7 @@ async function runDaemonUpgradeHelper(payload) {
41542
41603
  const env = { ...process.env };
41543
41604
  delete env[UPGRADE_HELPER_ENV];
41544
41605
  appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
41545
- const child = (0, import_child_process8.spawn)(process.execPath, restartArgv, {
41606
+ const child = (0, import_child_process9.spawn)(process.execPath, restartArgv, {
41546
41607
  detached: true,
41547
41608
  stdio: "ignore",
41548
41609
  windowsHide: true,
@@ -42551,18 +42612,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
42551
42612
  return { enabled: false };
42552
42613
  }
42553
42614
  async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
42554
- const { execFileSync: execFileSync6 } = await import("child_process");
42615
+ const { execFileSync: execFileSync7 } = await import("child_process");
42555
42616
  const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
42556
42617
  if (excludePaths.length > 0) {
42557
- diffArgs.push("--", ".", ...excludePaths.map((path40) => `:(exclude)${path40}`));
42618
+ diffArgs.push("--", ".", ...excludePaths.map((path41) => `:(exclude)${path41}`));
42558
42619
  }
42559
- const diff = execFileSync6("git", diffArgs, {
42620
+ const diff = execFileSync7("git", diffArgs, {
42560
42621
  cwd,
42561
42622
  encoding: "utf8",
42562
42623
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
42563
42624
  });
42564
42625
  if (!diff.trim()) return "";
42565
- const patchId = execFileSync6("git", ["patch-id", "--stable"], {
42626
+ const patchId = execFileSync7("git", ["patch-id", "--stable"], {
42566
42627
  cwd,
42567
42628
  input: diff,
42568
42629
  encoding: "utf8",
@@ -42573,8 +42634,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
42573
42634
  async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
42574
42635
  const startedAt = Date.now();
42575
42636
  try {
42576
- const { execFileSync: execFileSync6 } = await import("child_process");
42577
- const git = (args) => execFileSync6("git", args, {
42637
+ const { execFileSync: execFileSync7 } = await import("child_process");
42638
+ const git = (args) => execFileSync7("git", args, {
42578
42639
  cwd: repoRoot,
42579
42640
  encoding: "utf8",
42580
42641
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42665,8 +42726,8 @@ ${e?.stderr || ""}`
42665
42726
  async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42666
42727
  const startedAt = Date.now();
42667
42728
  try {
42668
- const { execFileSync: execFileSync6 } = await import("child_process");
42669
- const git = (args, opts) => execFileSync6("git", args, {
42729
+ const { execFileSync: execFileSync7 } = await import("child_process");
42730
+ const git = (args, opts) => execFileSync7("git", args, {
42670
42731
  cwd: opts?.cwd || repoRoot,
42671
42732
  encoding: "utf8",
42672
42733
  maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
@@ -42691,9 +42752,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42691
42752
  if (!trimmed) continue;
42692
42753
  if (trimmed.startsWith("+")) {
42693
42754
  const parts = trimmed.slice(1).trim().split(/\s+/);
42694
- const path40 = parts[1] || parts[0] || "(unknown)";
42755
+ const path41 = parts[1] || parts[0] || "(unknown)";
42695
42756
  submoduleHints.push({
42696
- path: path40,
42757
+ path: path41,
42697
42758
  reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
42698
42759
  });
42699
42760
  }
@@ -42723,10 +42784,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
42723
42784
  }
42724
42785
  function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
42725
42786
  if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
42726
- const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => ({
42727
- path: path40,
42728
- baseCommit: readTreeObject(repoRoot, baseHead, path40),
42729
- branchCommit: readTreeObject(repoRoot, branchHead, path40)
42787
+ const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => ({
42788
+ path: path41,
42789
+ baseCommit: readTreeObject(repoRoot, baseHead, path41),
42790
+ branchCommit: readTreeObject(repoRoot, branchHead, path41)
42730
42791
  }));
42731
42792
  if (conflicts.length === 0) return void 0;
42732
42793
  return {
@@ -42752,11 +42813,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
42752
42813
  if (!line.trim()) continue;
42753
42814
  const metaAndPath = line.split(" ");
42754
42815
  const meta = metaAndPath[0] || "";
42755
- const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
42756
- if (!path40) continue;
42816
+ const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
42817
+ if (!path41) continue;
42757
42818
  const parts = meta.split(/\s+/);
42758
42819
  if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
42759
- paths.add(path40);
42820
+ paths.add(path41);
42760
42821
  }
42761
42822
  }
42762
42823
  return [...paths].sort();
@@ -42764,9 +42825,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
42764
42825
  return [];
42765
42826
  }
42766
42827
  }
42767
- function readTreeObject(repoRoot, ref, path40) {
42828
+ function readTreeObject(repoRoot, ref, path41) {
42768
42829
  try {
42769
- const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--", path40], {
42830
+ const output = (0, import_node_child_process6.execFileSync)("git", ["ls-tree", ref, "--", path41], {
42770
42831
  cwd: repoRoot,
42771
42832
  encoding: "utf8",
42772
42833
  maxBuffer: 1024 * 1024
@@ -42811,12 +42872,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
42811
42872
  if (!line.trim()) continue;
42812
42873
  const metaAndPath = line.split(" ");
42813
42874
  const meta = metaAndPath[0] || "";
42814
- const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
42815
- if (!path40 || seen.has(path40)) continue;
42816
- seen.add(path40);
42875
+ const path41 = metaAndPath[metaAndPath.length - 1]?.trim();
42876
+ if (!path41 || seen.has(path41)) continue;
42877
+ seen.add(path41);
42817
42878
  const parts = meta.split(/\s+/);
42818
42879
  const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
42819
- result.push({ path: path40, isGitlink });
42880
+ result.push({ path: path41, isGitlink });
42820
42881
  }
42821
42882
  return result;
42822
42883
  } catch {
@@ -42824,20 +42885,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
42824
42885
  }
42825
42886
  }
42826
42887
  function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
42827
- return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path40) => {
42828
- const baseCommit = readTreeObject(repoRoot, baseHead, path40);
42829
- const branchCommit = readTreeObject(repoRoot, branchHead, path40);
42888
+ return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path41) => {
42889
+ const baseCommit = readTreeObject(repoRoot, baseHead, path41);
42890
+ const branchCommit = readTreeObject(repoRoot, branchHead, path41);
42830
42891
  if (!baseCommit || !branchCommit) return false;
42831
- return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot, path40), baseCommit, branchCommit);
42892
+ return isSubmoduleFastForward((0, import_path11.resolve)(repoRoot, path41), baseCommit, branchCommit);
42832
42893
  });
42833
42894
  }
42834
42895
  function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
42835
- const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => {
42836
- const baseCommit = readTreeObject(repoRoot, baseHead, path40);
42837
- const branchCommit = readTreeObject(repoRoot, branchHead, path40);
42838
- const submoduleRepoPath = (0, import_path11.resolve)(repoRoot, path40);
42896
+ const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path41) => {
42897
+ const baseCommit = readTreeObject(repoRoot, baseHead, path41);
42898
+ const branchCommit = readTreeObject(repoRoot, branchHead, path41);
42899
+ const submoduleRepoPath = (0, import_path11.resolve)(repoRoot, path41);
42839
42900
  const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
42840
- return { path: path40, baseCommit, branchCommit, fastForward };
42901
+ return { path: path41, baseCommit, branchCommit, fastForward };
42841
42902
  });
42842
42903
  if (changedGitlinks.length === 0) {
42843
42904
  return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
@@ -42888,7 +42949,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
42888
42949
  maxBuffer: 1024 * 1024
42889
42950
  }).trim();
42890
42951
  if (!tree) return void 0;
42891
- const updates = paths.map((path40) => `160000 commit ${placeholderCommit} ${path40}`).join("\n");
42952
+ const updates = paths.map((path41) => `160000 commit ${placeholderCommit} ${path41}`).join("\n");
42892
42953
  if (!updates) return tree;
42893
42954
  const tmpIndex = (0, import_path11.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
42894
42955
  const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
@@ -42991,7 +43052,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
42991
43052
  }
42992
43053
  async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
42993
43054
  const startedAt = Date.now();
42994
- const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path40) => !(options.submoduleIgnorePaths || []).includes(path40));
43055
+ const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path41) => !(options.submoduleIgnorePaths || []).includes(path41));
42995
43056
  const preStatus = await getGitRepoStatus(repoRoot, {
42996
43057
  includeSubmodules: true,
42997
43058
  submoduleIgnorePaths: options.submoduleIgnorePaths,
@@ -43032,7 +43093,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
43032
43093
  changedGitlinkPaths,
43033
43094
  outOfSyncPaths,
43034
43095
  updatedPaths: updatePaths,
43035
- verifiedPaths: updatePaths.filter((path40) => !remaining.some((submodule) => submodule.path === path40)),
43096
+ verifiedPaths: updatePaths.filter((path41) => !remaining.some((submodule) => submodule.path === path41)),
43036
43097
  durationMs: Date.now() - startedAt,
43037
43098
  command: `git ${commandArgs.join(" ")}`,
43038
43099
  stdout: truncateValidationOutput(result.stdout),
@@ -46330,9 +46391,9 @@ ${hintLines.join("\n")}` : "",
46330
46391
  // commands instead of going through fs from the browser.
46331
46392
  case "list_coordinator_prompts": {
46332
46393
  const fs30 = await import("fs");
46333
- const path40 = await import("path");
46394
+ const path41 = await import("path");
46334
46395
  const os30 = await import("os");
46335
- const dir = path40.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46396
+ const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46336
46397
  const entries = {};
46337
46398
  try {
46338
46399
  if (fs30.existsSync(dir)) {
@@ -46343,7 +46404,7 @@ ${hintLines.join("\n")}` : "",
46343
46404
  if (!m) continue;
46344
46405
  const isAppend = !!matchAppend;
46345
46406
  const key = m[1];
46346
- const full = path40.join(dir, name);
46407
+ const full = path41.join(dir, name);
46347
46408
  let content = "";
46348
46409
  try {
46349
46410
  content = fs30.readFileSync(full, "utf8");
@@ -46361,7 +46422,7 @@ ${hintLines.join("\n")}` : "",
46361
46422
  }
46362
46423
  case "write_coordinator_prompt": {
46363
46424
  const fs30 = await import("fs");
46364
- const path40 = await import("path");
46425
+ const path41 = await import("path");
46365
46426
  const os30 = await import("os");
46366
46427
  const key = typeof args?.key === "string" ? args.key.trim() : "";
46367
46428
  const kind = args?.kind === "append" ? "append" : "override";
@@ -46369,9 +46430,9 @@ ${hintLines.join("\n")}` : "",
46369
46430
  if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
46370
46431
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
46371
46432
  }
46372
- const dir = path40.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46433
+ const dir = path41.join(os30.homedir(), ".adhdev", "coordinator-prompts");
46373
46434
  const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
46374
- const full = path40.join(dir, filename);
46435
+ const full = path41.join(dir, filename);
46375
46436
  try {
46376
46437
  fs30.mkdirSync(dir, { recursive: true });
46377
46438
  if (content.trim()) {
@@ -47926,7 +47987,7 @@ ${ptyResult.output.slice(-2e3)}`);
47926
47987
  workspace
47927
47988
  };
47928
47989
  }
47929
- const { existsSync: existsSync42, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47990
+ const { existsSync: existsSync43, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
47930
47991
  const { dirname: dirname14 } = await import("path");
47931
47992
  const mcpConfigPath = coordinatorSetup.configPath;
47932
47993
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -47969,7 +48030,7 @@ ${ptyResult.output.slice(-2e3)}`);
47969
48030
  if (hermesManualFallback) return returnManualFallback(message);
47970
48031
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
47971
48032
  }
47972
- const hadExistingMcpConfig = existsSync42(mcpConfigPath);
48033
+ const hadExistingMcpConfig = existsSync43(mcpConfigPath);
47973
48034
  let existingMcpConfig = hermesBaseConfig?.config || {};
47974
48035
  if (hermesBaseConfig) {
47975
48036
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname14(mcpConfigPath));
@@ -48487,7 +48548,7 @@ ${ptyResult.output.slice(-2e3)}`);
48487
48548
  const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
48488
48549
  const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
48489
48550
  const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
48490
- const { existsSync: existsSync42 } = await import("fs");
48551
+ const { existsSync: existsSync43 } = await import("fs");
48491
48552
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
48492
48553
  const mesh = meshRecord?.mesh;
48493
48554
  if (!mesh) return { success: false, error: "Mesh not found" };
@@ -48506,7 +48567,7 @@ ${ptyResult.output.slice(-2e3)}`);
48506
48567
  const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
48507
48568
  for (const item of derivation.items) {
48508
48569
  const workspace = item.workspace;
48509
- if (!workspace || !existsSync42(workspace)) continue;
48570
+ if (!workspace || !existsSync43(workspace)) continue;
48510
48571
  const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
48511
48572
  try {
48512
48573
  const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
@@ -50253,11 +50314,11 @@ var ProviderInstanceManager = class {
50253
50314
 
50254
50315
  // src/providers/version-archive.ts
50255
50316
  var fs25 = __toESM(require("fs"));
50256
- var path35 = __toESM(require("path"));
50317
+ var path36 = __toESM(require("path"));
50257
50318
  var os28 = __toESM(require("os"));
50258
50319
  var import_os4 = require("os");
50259
- var import_child_process9 = require("child_process");
50260
- var ARCHIVE_PATH = path35.join(os28.homedir(), ".adhdev", "version-history.json");
50320
+ var import_child_process10 = require("child_process");
50321
+ var ARCHIVE_PATH = path36.join(os28.homedir(), ".adhdev", "version-history.json");
50261
50322
  var MAX_ENTRIES_PER_PROVIDER = 20;
50262
50323
  var VersionArchive = class {
50263
50324
  history = {};
@@ -50304,7 +50365,7 @@ var VersionArchive = class {
50304
50365
  }
50305
50366
  save() {
50306
50367
  try {
50307
- fs25.mkdirSync(path35.dirname(ARCHIVE_PATH), { recursive: true });
50368
+ fs25.mkdirSync(path36.dirname(ARCHIVE_PATH), { recursive: true });
50308
50369
  fs25.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
50309
50370
  } catch {
50310
50371
  }
@@ -50312,7 +50373,7 @@ var VersionArchive = class {
50312
50373
  };
50313
50374
  async function runCommand(cmd, timeout = 1e4) {
50314
50375
  return new Promise((resolve24) => {
50315
- (0, import_child_process9.exec)(cmd, {
50376
+ (0, import_child_process10.exec)(cmd, {
50316
50377
  encoding: "utf-8",
50317
50378
  timeout
50318
50379
  }, (error, stdout) => {
@@ -50328,7 +50389,7 @@ function findBinary2(name) {
50328
50389
  for (const p of paths) {
50329
50390
  if (!p) continue;
50330
50391
  for (const ext of exes) {
50331
- const fullPath = path35.join(p, name + ext);
50392
+ const fullPath = path36.join(p, name + ext);
50332
50393
  try {
50333
50394
  if (fs25.existsSync(fullPath)) {
50334
50395
  const stat2 = fs25.statSync(fullPath);
@@ -50377,7 +50438,7 @@ function checkPathExists2(paths) {
50377
50438
  for (const p of paths) {
50378
50439
  if (p.includes("*")) {
50379
50440
  const home = os28.homedir();
50380
- const resolved = p.replace(/\*/g, home.split(path35.sep).pop() || "");
50441
+ const resolved = p.replace(/\*/g, home.split(path36.sep).pop() || "");
50381
50442
  if (fs25.existsSync(resolved)) return resolved;
50382
50443
  } else {
50383
50444
  if (fs25.existsSync(p)) return p;
@@ -50387,7 +50448,7 @@ function checkPathExists2(paths) {
50387
50448
  }
50388
50449
  async function getMacAppVersion(appPath) {
50389
50450
  if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
50390
- const plistPath = path35.join(appPath, "Contents", "Info.plist");
50451
+ const plistPath = path36.join(appPath, "Contents", "Info.plist");
50391
50452
  if (!fs25.existsSync(plistPath)) return null;
50392
50453
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
50393
50454
  return raw || null;
@@ -50413,7 +50474,7 @@ async function detectAllVersions(loader, archive) {
50413
50474
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
50414
50475
  let resolvedBin = cliBin;
50415
50476
  if (!resolvedBin && appPath && currentOs === "darwin") {
50416
- const bundled = path35.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
50477
+ const bundled = path36.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
50417
50478
  if (provider.cli && fs25.existsSync(bundled)) resolvedBin = bundled;
50418
50479
  }
50419
50480
  info.installed = !!(appPath || resolvedBin);
@@ -50454,7 +50515,7 @@ async function detectAllVersions(loader, archive) {
50454
50515
  // src/daemon/dev-server.ts
50455
50516
  var http2 = __toESM(require("http"));
50456
50517
  var fs29 = __toESM(require("fs"));
50457
- var path39 = __toESM(require("path"));
50518
+ var path40 = __toESM(require("path"));
50458
50519
  init_config();
50459
50520
 
50460
50521
  // src/daemon/scaffold-template.ts
@@ -50805,7 +50866,7 @@ init_logger();
50805
50866
 
50806
50867
  // src/daemon/dev-cdp-handlers.ts
50807
50868
  var fs26 = __toESM(require("fs"));
50808
- var path36 = __toESM(require("path"));
50869
+ var path37 = __toESM(require("path"));
50809
50870
  init_logger();
50810
50871
  async function handleCdpEvaluate(ctx, req, res) {
50811
50872
  const body = await ctx.readBody(req);
@@ -50984,17 +51045,17 @@ async function handleScriptHints(ctx, type, _req, res) {
50984
51045
  return;
50985
51046
  }
50986
51047
  let scriptsPath = "";
50987
- const directScripts = path36.join(dir, "scripts.js");
51048
+ const directScripts = path37.join(dir, "scripts.js");
50988
51049
  if (fs26.existsSync(directScripts)) {
50989
51050
  scriptsPath = directScripts;
50990
51051
  } else {
50991
- const scriptsDir = path36.join(dir, "scripts");
51052
+ const scriptsDir = path37.join(dir, "scripts");
50992
51053
  if (fs26.existsSync(scriptsDir)) {
50993
51054
  const versions = fs26.readdirSync(scriptsDir).filter((d) => {
50994
- return fs26.statSync(path36.join(scriptsDir, d)).isDirectory();
51055
+ return fs26.statSync(path37.join(scriptsDir, d)).isDirectory();
50995
51056
  }).sort().reverse();
50996
51057
  for (const ver of versions) {
50997
- const p = path36.join(scriptsDir, ver, "scripts.js");
51058
+ const p = path37.join(scriptsDir, ver, "scripts.js");
50998
51059
  if (fs26.existsSync(p)) {
50999
51060
  scriptsPath = p;
51000
51061
  break;
@@ -51823,7 +51884,7 @@ async function handleDomContext(ctx, type, req, res) {
51823
51884
 
51824
51885
  // src/daemon/dev-cli-debug.ts
51825
51886
  var fs27 = __toESM(require("fs"));
51826
- var path37 = __toESM(require("path"));
51887
+ var path38 = __toESM(require("path"));
51827
51888
  function slugifyFixtureName(value) {
51828
51889
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
51829
51890
  return normalized || `fixture-${Date.now()}`;
@@ -51833,11 +51894,11 @@ function getCliFixtureDir(ctx, type) {
51833
51894
  if (!providerDir) {
51834
51895
  throw new Error(`Provider directory not found for '${type}'`);
51835
51896
  }
51836
- return path37.join(providerDir, "fixtures");
51897
+ return path38.join(providerDir, "fixtures");
51837
51898
  }
51838
51899
  function readCliFixture(ctx, type, name) {
51839
51900
  const fixtureDir = getCliFixtureDir(ctx, type);
51840
- const filePath = path37.join(fixtureDir, `${name}.json`);
51901
+ const filePath = path38.join(fixtureDir, `${name}.json`);
51841
51902
  if (!fs27.existsSync(filePath)) {
51842
51903
  throw new Error(`Fixture not found: ${filePath}`);
51843
51904
  }
@@ -52613,7 +52674,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
52613
52674
  },
52614
52675
  notes: typeof body?.notes === "string" ? body.notes : void 0
52615
52676
  };
52616
- const filePath = path37.join(fixtureDir, `${name}.json`);
52677
+ const filePath = path38.join(fixtureDir, `${name}.json`);
52617
52678
  fs27.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
52618
52679
  ctx.json(res, 200, {
52619
52680
  saved: true,
@@ -52637,7 +52698,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
52637
52698
  return;
52638
52699
  }
52639
52700
  const fixtures = fs27.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
52640
- const fullPath = path37.join(fixtureDir, file);
52701
+ const fullPath = path38.join(fixtureDir, file);
52641
52702
  try {
52642
52703
  const raw = JSON.parse(fs27.readFileSync(fullPath, "utf-8"));
52643
52704
  return {
@@ -52773,7 +52834,7 @@ async function handleCliRaw(ctx, req, res) {
52773
52834
 
52774
52835
  // src/daemon/dev-auto-implement.ts
52775
52836
  var fs28 = __toESM(require("fs"));
52776
- var path38 = __toESM(require("path"));
52837
+ var path39 = __toESM(require("path"));
52777
52838
  var os29 = __toESM(require("os"));
52778
52839
  var import_session_host_core8 = require("@adhdev/session-host-core");
52779
52840
  function getAutoImplPid(ctx) {
@@ -52824,22 +52885,22 @@ function getLatestScriptVersionDir(scriptsDir) {
52824
52885
  if (!fs28.existsSync(scriptsDir)) return null;
52825
52886
  const versions = fs28.readdirSync(scriptsDir).filter((d) => {
52826
52887
  try {
52827
- return fs28.statSync(path38.join(scriptsDir, d)).isDirectory();
52888
+ return fs28.statSync(path39.join(scriptsDir, d)).isDirectory();
52828
52889
  } catch {
52829
52890
  return false;
52830
52891
  }
52831
52892
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
52832
52893
  if (versions.length === 0) return null;
52833
- return path38.join(scriptsDir, versions[0]);
52894
+ return path39.join(scriptsDir, versions[0]);
52834
52895
  }
52835
52896
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
52836
- const canonicalUserDir = path38.resolve(ctx.providerLoader.getUserProviderDir(category, type));
52837
- const desiredDir = requestedDir ? path38.resolve(requestedDir) : canonicalUserDir;
52838
- const upstreamRoot = path38.resolve(ctx.providerLoader.getUpstreamDir());
52839
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path38.sep}`)) {
52897
+ const canonicalUserDir = path39.resolve(ctx.providerLoader.getUserProviderDir(category, type));
52898
+ const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
52899
+ const upstreamRoot = path39.resolve(ctx.providerLoader.getUpstreamDir());
52900
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
52840
52901
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
52841
52902
  }
52842
- if (path38.basename(desiredDir) !== type) {
52903
+ if (path39.basename(desiredDir) !== type) {
52843
52904
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
52844
52905
  }
52845
52906
  const sourceDir = ctx.findProviderDir(type);
@@ -52847,11 +52908,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
52847
52908
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
52848
52909
  }
52849
52910
  if (!fs28.existsSync(desiredDir)) {
52850
- fs28.mkdirSync(path38.dirname(desiredDir), { recursive: true });
52911
+ fs28.mkdirSync(path39.dirname(desiredDir), { recursive: true });
52851
52912
  fs28.cpSync(sourceDir, desiredDir, { recursive: true });
52852
52913
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
52853
52914
  }
52854
- const providerJson = path38.join(desiredDir, "provider.json");
52915
+ const providerJson = path39.join(desiredDir, "provider.json");
52855
52916
  if (!fs28.existsSync(providerJson)) {
52856
52917
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
52857
52918
  }
@@ -52862,13 +52923,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
52862
52923
  const refDir = ctx.findProviderDir(referenceType);
52863
52924
  if (!refDir || !fs28.existsSync(refDir)) return {};
52864
52925
  const referenceScripts = {};
52865
- const scriptsDir = path38.join(refDir, "scripts");
52926
+ const scriptsDir = path39.join(refDir, "scripts");
52866
52927
  const latestDir = getLatestScriptVersionDir(scriptsDir);
52867
52928
  if (!latestDir) return referenceScripts;
52868
52929
  for (const file of fs28.readdirSync(latestDir)) {
52869
52930
  if (!file.endsWith(".js")) continue;
52870
52931
  try {
52871
- referenceScripts[file] = fs28.readFileSync(path38.join(latestDir, file), "utf-8");
52932
+ referenceScripts[file] = fs28.readFileSync(path39.join(latestDir, file), "utf-8");
52872
52933
  } catch {
52873
52934
  }
52874
52935
  }
@@ -52976,9 +53037,9 @@ async function handleAutoImplement(ctx, type, req, res) {
52976
53037
  });
52977
53038
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
52978
53039
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
52979
- const tmpDir = path38.join(os29.tmpdir(), "adhdev-autoimpl");
53040
+ const tmpDir = path39.join(os29.tmpdir(), "adhdev-autoimpl");
52980
53041
  if (!fs28.existsSync(tmpDir)) fs28.mkdirSync(tmpDir, { recursive: true });
52981
- const promptFile = path38.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
53042
+ const promptFile = path39.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
52982
53043
  fs28.writeFileSync(promptFile, prompt, "utf-8");
52983
53044
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
52984
53045
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -53410,7 +53471,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53410
53471
  setMode: "set_mode.js"
53411
53472
  };
53412
53473
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
53413
- const scriptsDir = path38.join(providerDir, "scripts");
53474
+ const scriptsDir = path39.join(providerDir, "scripts");
53414
53475
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
53415
53476
  if (latestScriptsDir) {
53416
53477
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -53421,7 +53482,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53421
53482
  for (const file of fs28.readdirSync(latestScriptsDir)) {
53422
53483
  if (file.endsWith(".js") && targetFileNames.has(file)) {
53423
53484
  try {
53424
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53485
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53425
53486
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53426
53487
  lines.push("```javascript");
53427
53488
  lines.push(content);
@@ -53438,7 +53499,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53438
53499
  lines.push("");
53439
53500
  for (const file of refFiles) {
53440
53501
  try {
53441
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53502
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53442
53503
  lines.push(`### \`${file}\` \u{1F512}`);
53443
53504
  lines.push("```javascript");
53444
53505
  lines.push(content);
@@ -53479,10 +53540,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
53479
53540
  lines.push("");
53480
53541
  }
53481
53542
  }
53482
- const docsDir = path38.join(providerDir, "../../docs");
53543
+ const docsDir = path39.join(providerDir, "../../docs");
53483
53544
  const loadGuide = (name) => {
53484
53545
  try {
53485
- const p = path38.join(docsDir, name);
53546
+ const p = path39.join(docsDir, name);
53486
53547
  if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
53487
53548
  } catch {
53488
53549
  }
@@ -53719,7 +53780,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53719
53780
  parseApproval: "parse_approval.js"
53720
53781
  };
53721
53782
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
53722
- const scriptsDir = path38.join(providerDir, "scripts");
53783
+ const scriptsDir = path39.join(providerDir, "scripts");
53723
53784
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
53724
53785
  if (latestScriptsDir) {
53725
53786
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -53731,7 +53792,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53731
53792
  if (!file.endsWith(".js")) continue;
53732
53793
  if (!targetFileNames.has(file)) continue;
53733
53794
  try {
53734
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53795
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53735
53796
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
53736
53797
  lines.push("```javascript");
53737
53798
  lines.push(content);
@@ -53747,7 +53808,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53747
53808
  lines.push("");
53748
53809
  for (const file of refFiles) {
53749
53810
  try {
53750
- const content = fs28.readFileSync(path38.join(latestScriptsDir, file), "utf-8");
53811
+ const content = fs28.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
53751
53812
  lines.push(`### \`${file}\` \u{1F512}`);
53752
53813
  lines.push("```javascript");
53753
53814
  lines.push(content);
@@ -53780,10 +53841,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
53780
53841
  lines.push("");
53781
53842
  }
53782
53843
  }
53783
- const docsDir = path38.join(providerDir, "../../docs");
53844
+ const docsDir = path39.join(providerDir, "../../docs");
53784
53845
  const loadGuide = (name) => {
53785
53846
  try {
53786
- const p = path38.join(docsDir, name);
53847
+ const p = path39.join(docsDir, name);
53787
53848
  if (fs28.existsSync(p)) return fs28.readFileSync(p, "utf-8");
53788
53849
  } catch {
53789
53850
  }
@@ -54230,8 +54291,8 @@ var DevServer = class _DevServer {
54230
54291
  }
54231
54292
  getEndpointList() {
54232
54293
  return this.routes.map((r) => {
54233
- const path40 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
54234
- return `${r.method.padEnd(5)} ${path40}`;
54294
+ const path41 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
54295
+ return `${r.method.padEnd(5)} ${path41}`;
54235
54296
  });
54236
54297
  }
54237
54298
  async start(port = DEV_SERVER_PORT) {
@@ -54519,12 +54580,12 @@ var DevServer = class _DevServer {
54519
54580
  // ─── DevConsole SPA ───
54520
54581
  getConsoleDistDir() {
54521
54582
  const candidates = [
54522
- path39.resolve(__dirname, "../../web-devconsole/dist"),
54523
- path39.resolve(__dirname, "../../../web-devconsole/dist"),
54524
- path39.join(process.cwd(), "packages/web-devconsole/dist")
54583
+ path40.resolve(__dirname, "../../web-devconsole/dist"),
54584
+ path40.resolve(__dirname, "../../../web-devconsole/dist"),
54585
+ path40.join(process.cwd(), "packages/web-devconsole/dist")
54525
54586
  ];
54526
54587
  for (const dir of candidates) {
54527
- if (fs29.existsSync(path39.join(dir, "index.html"))) return dir;
54588
+ if (fs29.existsSync(path40.join(dir, "index.html"))) return dir;
54528
54589
  }
54529
54590
  return null;
54530
54591
  }
@@ -54534,7 +54595,7 @@ var DevServer = class _DevServer {
54534
54595
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
54535
54596
  return;
54536
54597
  }
54537
- const htmlPath = path39.join(distDir, "index.html");
54598
+ const htmlPath = path40.join(distDir, "index.html");
54538
54599
  try {
54539
54600
  const html = fs29.readFileSync(htmlPath, "utf-8");
54540
54601
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -54559,15 +54620,15 @@ var DevServer = class _DevServer {
54559
54620
  this.json(res, 404, { error: "Not found" });
54560
54621
  return;
54561
54622
  }
54562
- const safePath = path39.normalize(pathname).replace(/^\.\.\//, "");
54563
- const filePath = path39.join(distDir, safePath);
54623
+ const safePath = path40.normalize(pathname).replace(/^\.\.\//, "");
54624
+ const filePath = path40.join(distDir, safePath);
54564
54625
  if (!filePath.startsWith(distDir)) {
54565
54626
  this.json(res, 403, { error: "Forbidden" });
54566
54627
  return;
54567
54628
  }
54568
54629
  try {
54569
54630
  const content = fs29.readFileSync(filePath);
54570
- const ext = path39.extname(filePath);
54631
+ const ext = path40.extname(filePath);
54571
54632
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
54572
54633
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
54573
54634
  res.end(content);
@@ -54680,9 +54741,9 @@ var DevServer = class _DevServer {
54680
54741
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
54681
54742
  if (entry.isDirectory()) {
54682
54743
  files.push({ path: rel, size: 0, type: "dir" });
54683
- scan(path39.join(d, entry.name), rel);
54744
+ scan(path40.join(d, entry.name), rel);
54684
54745
  } else {
54685
- const stat2 = fs29.statSync(path39.join(d, entry.name));
54746
+ const stat2 = fs29.statSync(path40.join(d, entry.name));
54686
54747
  files.push({ path: rel, size: stat2.size, type: "file" });
54687
54748
  }
54688
54749
  }
@@ -54705,7 +54766,7 @@ var DevServer = class _DevServer {
54705
54766
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
54706
54767
  return;
54707
54768
  }
54708
- const fullPath = path39.resolve(dir, path39.normalize(filePath));
54769
+ const fullPath = path40.resolve(dir, path40.normalize(filePath));
54709
54770
  if (!fullPath.startsWith(dir)) {
54710
54771
  this.json(res, 403, { error: "Forbidden" });
54711
54772
  return;
@@ -54730,14 +54791,14 @@ var DevServer = class _DevServer {
54730
54791
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
54731
54792
  return;
54732
54793
  }
54733
- const fullPath = path39.resolve(dir, path39.normalize(filePath));
54794
+ const fullPath = path40.resolve(dir, path40.normalize(filePath));
54734
54795
  if (!fullPath.startsWith(dir)) {
54735
54796
  this.json(res, 403, { error: "Forbidden" });
54736
54797
  return;
54737
54798
  }
54738
54799
  try {
54739
54800
  if (fs29.existsSync(fullPath)) fs29.copyFileSync(fullPath, fullPath + ".bak");
54740
- fs29.mkdirSync(path39.dirname(fullPath), { recursive: true });
54801
+ fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
54741
54802
  fs29.writeFileSync(fullPath, content, "utf-8");
54742
54803
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
54743
54804
  this.providerLoader.reload();
@@ -54754,7 +54815,7 @@ var DevServer = class _DevServer {
54754
54815
  return;
54755
54816
  }
54756
54817
  for (const name of ["scripts.js", "provider.json"]) {
54757
- const p = path39.join(dir, name);
54818
+ const p = path40.join(dir, name);
54758
54819
  if (fs29.existsSync(p)) {
54759
54820
  const source = fs29.readFileSync(p, "utf-8");
54760
54821
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -54775,8 +54836,8 @@ var DevServer = class _DevServer {
54775
54836
  this.json(res, 404, { error: `Provider not found: ${type}` });
54776
54837
  return;
54777
54838
  }
54778
- const target = fs29.existsSync(path39.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
54779
- const targetPath = path39.join(dir, target);
54839
+ const target = fs29.existsSync(path40.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
54840
+ const targetPath = path40.join(dir, target);
54780
54841
  try {
54781
54842
  if (fs29.existsSync(targetPath)) fs29.copyFileSync(targetPath, targetPath + ".bak");
54782
54843
  fs29.writeFileSync(targetPath, source, "utf-8");
@@ -54923,7 +54984,7 @@ var DevServer = class _DevServer {
54923
54984
  }
54924
54985
  let targetDir;
54925
54986
  targetDir = this.providerLoader.getUserProviderDir(category, type);
54926
- const jsonPath = path39.join(targetDir, "provider.json");
54987
+ const jsonPath = path40.join(targetDir, "provider.json");
54927
54988
  if (fs29.existsSync(jsonPath)) {
54928
54989
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
54929
54990
  return;
@@ -54935,8 +54996,8 @@ var DevServer = class _DevServer {
54935
54996
  const createdFiles = ["provider.json"];
54936
54997
  if (result.files) {
54937
54998
  for (const [relPath, content] of Object.entries(result.files)) {
54938
- const fullPath = path39.join(targetDir, relPath);
54939
- fs29.mkdirSync(path39.dirname(fullPath), { recursive: true });
54999
+ const fullPath = path40.join(targetDir, relPath);
55000
+ fs29.mkdirSync(path40.dirname(fullPath), { recursive: true });
54940
55001
  fs29.writeFileSync(fullPath, content, "utf-8");
54941
55002
  createdFiles.push(relPath);
54942
55003
  }
@@ -54989,22 +55050,22 @@ var DevServer = class _DevServer {
54989
55050
  if (!fs29.existsSync(scriptsDir)) return null;
54990
55051
  const versions = fs29.readdirSync(scriptsDir).filter((d) => {
54991
55052
  try {
54992
- return fs29.statSync(path39.join(scriptsDir, d)).isDirectory();
55053
+ return fs29.statSync(path40.join(scriptsDir, d)).isDirectory();
54993
55054
  } catch {
54994
55055
  return false;
54995
55056
  }
54996
55057
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
54997
55058
  if (versions.length === 0) return null;
54998
- return path39.join(scriptsDir, versions[0]);
55059
+ return path40.join(scriptsDir, versions[0]);
54999
55060
  }
55000
55061
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
55001
- const canonicalUserDir = path39.resolve(this.providerLoader.getUserProviderDir(category, type));
55002
- const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
55003
- const upstreamRoot = path39.resolve(this.providerLoader.getUpstreamDir());
55004
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
55062
+ const canonicalUserDir = path40.resolve(this.providerLoader.getUserProviderDir(category, type));
55063
+ const desiredDir = requestedDir ? path40.resolve(requestedDir) : canonicalUserDir;
55064
+ const upstreamRoot = path40.resolve(this.providerLoader.getUpstreamDir());
55065
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path40.sep}`)) {
55005
55066
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
55006
55067
  }
55007
- if (path39.basename(desiredDir) !== type) {
55068
+ if (path40.basename(desiredDir) !== type) {
55008
55069
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
55009
55070
  }
55010
55071
  const sourceDir = this.findProviderDir(type);
@@ -55012,11 +55073,11 @@ var DevServer = class _DevServer {
55012
55073
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
55013
55074
  }
55014
55075
  if (!fs29.existsSync(desiredDir)) {
55015
- fs29.mkdirSync(path39.dirname(desiredDir), { recursive: true });
55076
+ fs29.mkdirSync(path40.dirname(desiredDir), { recursive: true });
55016
55077
  fs29.cpSync(sourceDir, desiredDir, { recursive: true });
55017
55078
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
55018
55079
  }
55019
- const providerJson = path39.join(desiredDir, "provider.json");
55080
+ const providerJson = path40.join(desiredDir, "provider.json");
55020
55081
  if (!fs29.existsSync(providerJson)) {
55021
55082
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
55022
55083
  }
@@ -55052,7 +55113,7 @@ var DevServer = class _DevServer {
55052
55113
  setMode: "set_mode.js"
55053
55114
  };
55054
55115
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
55055
- const scriptsDir = path39.join(providerDir, "scripts");
55116
+ const scriptsDir = path40.join(providerDir, "scripts");
55056
55117
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
55057
55118
  if (latestScriptsDir) {
55058
55119
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -55063,7 +55124,7 @@ var DevServer = class _DevServer {
55063
55124
  for (const file of fs29.readdirSync(latestScriptsDir)) {
55064
55125
  if (file.endsWith(".js") && targetFileNames.has(file)) {
55065
55126
  try {
55066
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55127
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55067
55128
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
55068
55129
  lines.push("```javascript");
55069
55130
  lines.push(content);
@@ -55080,7 +55141,7 @@ var DevServer = class _DevServer {
55080
55141
  lines.push("");
55081
55142
  for (const file of refFiles) {
55082
55143
  try {
55083
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55144
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55084
55145
  lines.push(`### \`${file}\` \u{1F512}`);
55085
55146
  lines.push("```javascript");
55086
55147
  lines.push(content);
@@ -55121,10 +55182,10 @@ var DevServer = class _DevServer {
55121
55182
  lines.push("");
55122
55183
  }
55123
55184
  }
55124
- const docsDir = path39.join(providerDir, "../../docs");
55185
+ const docsDir = path40.join(providerDir, "../../docs");
55125
55186
  const loadGuide = (name) => {
55126
55187
  try {
55127
- const p = path39.join(docsDir, name);
55188
+ const p = path40.join(docsDir, name);
55128
55189
  if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
55129
55190
  } catch {
55130
55191
  }
@@ -55298,7 +55359,7 @@ var DevServer = class _DevServer {
55298
55359
  parseApproval: "parse_approval.js"
55299
55360
  };
55300
55361
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
55301
- const scriptsDir = path39.join(providerDir, "scripts");
55362
+ const scriptsDir = path40.join(providerDir, "scripts");
55302
55363
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
55303
55364
  if (latestScriptsDir) {
55304
55365
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -55310,7 +55371,7 @@ var DevServer = class _DevServer {
55310
55371
  if (!file.endsWith(".js")) continue;
55311
55372
  if (!targetFileNames.has(file)) continue;
55312
55373
  try {
55313
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55374
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55314
55375
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
55315
55376
  lines.push("```javascript");
55316
55377
  lines.push(content);
@@ -55326,7 +55387,7 @@ var DevServer = class _DevServer {
55326
55387
  lines.push("");
55327
55388
  for (const file of refFiles) {
55328
55389
  try {
55329
- const content = fs29.readFileSync(path39.join(latestScriptsDir, file), "utf-8");
55390
+ const content = fs29.readFileSync(path40.join(latestScriptsDir, file), "utf-8");
55330
55391
  lines.push(`### \`${file}\` \u{1F512}`);
55331
55392
  lines.push("```javascript");
55332
55393
  lines.push(content);
@@ -55359,10 +55420,10 @@ var DevServer = class _DevServer {
55359
55420
  lines.push("");
55360
55421
  }
55361
55422
  }
55362
- const docsDir = path39.join(providerDir, "../../docs");
55423
+ const docsDir = path40.join(providerDir, "../../docs");
55363
55424
  const loadGuide = (name) => {
55364
55425
  try {
55365
- const p = path39.join(docsDir, name);
55426
+ const p = path40.join(docsDir, name);
55366
55427
  if (fs29.existsSync(p)) return fs29.readFileSync(p, "utf-8");
55367
55428
  } catch {
55368
55429
  }
@@ -55627,6 +55688,7 @@ init_pty_transport();
55627
55688
  // src/cli-adapters/session-host-transport.ts
55628
55689
  var import_session_host_core9 = require("@adhdev/session-host-core");
55629
55690
  init_logger();
55691
+ init_resolve_executable();
55630
55692
  function shouldResumeAttachedSession(record) {
55631
55693
  if (!record) return false;
55632
55694
  if (record.lifecycle === "interrupted") return true;
@@ -56006,7 +56068,7 @@ var SessionHostPtyTransportFactory = class {
56006
56068
  spawn(command, args, spawnOptions) {
56007
56069
  return new SessionHostRuntimeTransport({
56008
56070
  ...this.options,
56009
- command,
56071
+ command: resolveWin32Executable(command),
56010
56072
  args,
56011
56073
  spawnOptions
56012
56074
  });
@@ -56335,7 +56397,7 @@ function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
56335
56397
  }
56336
56398
 
56337
56399
  // src/installer.ts
56338
- var import_child_process10 = require("child_process");
56400
+ var import_child_process11 = require("child_process");
56339
56401
  var import_util3 = require("util");
56340
56402
  var EXTENSION_CATALOG = [
56341
56403
  // AI Agent extensions
@@ -56423,7 +56485,7 @@ var EXTENSION_CATALOG = [
56423
56485
  apiKeyName: "OpenAI/Anthropic API key"
56424
56486
  }
56425
56487
  ];
56426
- var execAsync4 = (0, import_util3.promisify)(import_child_process10.exec);
56488
+ var execAsync4 = (0, import_util3.promisify)(import_child_process11.exec);
56427
56489
  async function isExtensionInstalled(ide, marketplaceId) {
56428
56490
  if (!ide.cliCommand) return false;
56429
56491
  try {
@@ -56467,7 +56529,7 @@ async function installExtension(ide, extension) {
56467
56529
  fs30.writeFileSync(vsixPath, buffer);
56468
56530
  return new Promise((resolve24) => {
56469
56531
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
56470
- (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
56532
+ (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
56471
56533
  resolve24({
56472
56534
  extensionId: extension.id,
56473
56535
  marketplaceId: extension.marketplaceId,
@@ -56483,7 +56545,7 @@ async function installExtension(ide, extension) {
56483
56545
  }
56484
56546
  return new Promise((resolve24) => {
56485
56547
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
56486
- (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
56548
+ (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
56487
56549
  if (error) {
56488
56550
  resolve24({
56489
56551
  extensionId: extension.id,
@@ -56520,7 +56582,7 @@ function launchIDE(ide, workspacePath) {
56520
56582
  if (!ide.cliCommand) return false;
56521
56583
  try {
56522
56584
  const args = workspacePath ? `"${workspacePath}"` : "";
56523
- (0, import_child_process10.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
56585
+ (0, import_child_process11.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
56524
56586
  return true;
56525
56587
  } catch {
56526
56588
  return false;