@adhdev/daemon-core 0.9.50 → 0.9.51

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
@@ -1340,11 +1340,11 @@ function loadNodePty() {
1340
1340
  }
1341
1341
  return cachedPty;
1342
1342
  }
1343
- var os7, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
1343
+ var os8, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
1344
1344
  var init_pty_transport = __esm({
1345
1345
  "src/cli-adapters/pty-transport.ts"() {
1346
1346
  "use strict";
1347
- os7 = __toESM(require("os"));
1347
+ os8 = __toESM(require("os"));
1348
1348
  init_spawn_env();
1349
1349
  NodePtyRuntimeTransport = class {
1350
1350
  constructor(handle) {
@@ -1381,11 +1381,11 @@ var init_pty_transport = __esm({
1381
1381
  let cwd = options.cwd;
1382
1382
  if (cwd) {
1383
1383
  try {
1384
- const fs15 = require("fs");
1385
- const stat = fs15.statSync(cwd);
1386
- if (!stat.isDirectory()) cwd = os7.homedir();
1384
+ const fs16 = require("fs");
1385
+ const stat = fs16.statSync(cwd);
1386
+ if (!stat.isDirectory()) cwd = os8.homedir();
1387
1387
  } catch {
1388
- cwd = os7.homedir();
1388
+ cwd = os8.homedir();
1389
1389
  }
1390
1390
  }
1391
1391
  const handle = pty.spawn(command, args, {
@@ -1465,11 +1465,11 @@ function buildCliScreenSnapshot(text) {
1465
1465
  function findBinary(name) {
1466
1466
  const trimmed = String(name || "").trim();
1467
1467
  if (!trimmed) return trimmed;
1468
- const expanded = trimmed.startsWith("~") ? path9.join(os8.homedir(), trimmed.slice(1)) : trimmed;
1469
- if (path9.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
1470
- return path9.isAbsolute(expanded) ? expanded : path9.resolve(expanded);
1468
+ const expanded = trimmed.startsWith("~") ? path10.join(os9.homedir(), trimmed.slice(1)) : trimmed;
1469
+ if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
1470
+ return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
1471
1471
  }
1472
- const isWin = os8.platform() === "win32";
1472
+ const isWin = os9.platform() === "win32";
1473
1473
  try {
1474
1474
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
1475
1475
  return (0, import_child_process4.execSync)(cmd, {
@@ -1483,14 +1483,14 @@ function findBinary(name) {
1483
1483
  }
1484
1484
  }
1485
1485
  function isScriptBinary(binaryPath) {
1486
- if (!path9.isAbsolute(binaryPath)) return false;
1486
+ if (!path10.isAbsolute(binaryPath)) return false;
1487
1487
  try {
1488
- const fs15 = require("fs");
1489
- const resolved = fs15.realpathSync(binaryPath);
1488
+ const fs16 = require("fs");
1489
+ const resolved = fs16.realpathSync(binaryPath);
1490
1490
  const head = Buffer.alloc(8);
1491
- const fd = fs15.openSync(resolved, "r");
1492
- fs15.readSync(fd, head, 0, 8, 0);
1493
- fs15.closeSync(fd);
1491
+ const fd = fs16.openSync(resolved, "r");
1492
+ fs16.readSync(fd, head, 0, 8, 0);
1493
+ fs16.closeSync(fd);
1494
1494
  let i = 0;
1495
1495
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
1496
1496
  return head[i] === 35 && head[i + 1] === 33;
@@ -1499,14 +1499,14 @@ function isScriptBinary(binaryPath) {
1499
1499
  }
1500
1500
  }
1501
1501
  function looksLikeMachOOrElf(filePath) {
1502
- if (!path9.isAbsolute(filePath)) return false;
1502
+ if (!path10.isAbsolute(filePath)) return false;
1503
1503
  try {
1504
- const fs15 = require("fs");
1505
- const resolved = fs15.realpathSync(filePath);
1504
+ const fs16 = require("fs");
1505
+ const resolved = fs16.realpathSync(filePath);
1506
1506
  const buf = Buffer.alloc(8);
1507
- const fd = fs15.openSync(resolved, "r");
1508
- fs15.readSync(fd, buf, 0, 8, 0);
1509
- fs15.closeSync(fd);
1507
+ const fd = fs16.openSync(resolved, "r");
1508
+ fs16.readSync(fd, buf, 0, 8, 0);
1509
+ fs16.closeSync(fd);
1510
1510
  let i = 0;
1511
1511
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
1512
1512
  const b = buf.subarray(i);
@@ -1522,7 +1522,7 @@ function looksLikeMachOOrElf(filePath) {
1522
1522
  }
1523
1523
  function shSingleQuote(arg) {
1524
1524
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
1525
- if (os8.platform() === "win32") {
1525
+ if (os9.platform() === "win32") {
1526
1526
  return `"${arg.replace(/"/g, '""')}"`;
1527
1527
  }
1528
1528
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -1649,12 +1649,12 @@ function normalizeCliProviderForRuntime(raw) {
1649
1649
  }
1650
1650
  };
1651
1651
  }
1652
- var os8, path9, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
1652
+ var os9, path10, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
1653
1653
  var init_provider_cli_shared = __esm({
1654
1654
  "src/cli-adapters/provider-cli-shared.ts"() {
1655
1655
  "use strict";
1656
- os8 = __toESM(require("os"));
1657
- path9 = __toESM(require("path"));
1656
+ os9 = __toESM(require("os"));
1657
+ path10 = __toESM(require("path"));
1658
1658
  import_child_process4 = require("child_process");
1659
1659
  init_spawn_env();
1660
1660
  buildCliSpawnEnv = import_session_host_core.sanitizeSpawnEnv;
@@ -1967,13 +1967,13 @@ function resolveCliSpawnPlan(options) {
1967
1967
  const { spawn: spawnConfig } = provider;
1968
1968
  const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
1969
1969
  const binaryPath = findBinary(configuredCommand);
1970
- const isWin = os9.platform() === "win32";
1970
+ const isWin = os10.platform() === "win32";
1971
1971
  const allArgs = [...spawnConfig.args, ...extraArgs];
1972
1972
  let shellCmd;
1973
1973
  let shellArgs;
1974
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
1974
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
1975
1975
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
1976
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
1976
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
1977
1977
  const useShell = isWin ? useShellWin : useShellUnix;
1978
1978
  if (useShell) {
1979
1979
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -2049,12 +2049,12 @@ function respondToCliTerminalQueries(options) {
2049
2049
  }
2050
2050
  return "";
2051
2051
  }
2052
- var os9, path10, import_session_host_core2;
2052
+ var os10, path11, import_session_host_core2;
2053
2053
  var init_provider_cli_runtime = __esm({
2054
2054
  "src/cli-adapters/provider-cli-runtime.ts"() {
2055
2055
  "use strict";
2056
- os9 = __toESM(require("os"));
2057
- path10 = __toESM(require("path"));
2056
+ os10 = __toESM(require("os"));
2057
+ path11 = __toESM(require("path"));
2058
2058
  import_session_host_core2 = require("@adhdev/session-host-core");
2059
2059
  init_provider_cli_shared();
2060
2060
  }
@@ -2176,11 +2176,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt) {
2176
2176
  return;
2177
2177
  }
2178
2178
  }
2179
- var os10, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
2179
+ var os11, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
2180
2180
  var init_provider_cli_adapter = __esm({
2181
2181
  "src/cli-adapters/provider-cli-adapter.ts"() {
2182
2182
  "use strict";
2183
- os10 = __toESM(require("os"));
2183
+ os11 = __toESM(require("os"));
2184
2184
  init_logger();
2185
2185
  init_debug_config();
2186
2186
  init_terminal_screen();
@@ -2200,7 +2200,7 @@ var init_provider_cli_adapter = __esm({
2200
2200
  this.transportFactory = transportFactory;
2201
2201
  this.cliType = provider.type;
2202
2202
  this.cliName = provider.name;
2203
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os10.homedir()) : workingDir;
2203
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os11.homedir()) : workingDir;
2204
2204
  const resolvedConfig = resolveCliAdapterConfig(provider);
2205
2205
  this.timeouts = resolvedConfig.timeouts;
2206
2206
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -5275,17 +5275,17 @@ function checkPathExists(paths) {
5275
5275
  return null;
5276
5276
  }
5277
5277
  async function detectIDEs(providerLoader) {
5278
- const os20 = (0, import_os2.platform)();
5278
+ const os21 = (0, import_os2.platform)();
5279
5279
  const results = [];
5280
5280
  for (const def of getMergedDefinitions()) {
5281
5281
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
5282
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os20] || []) || []);
5282
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os21] || []) || []);
5283
5283
  let resolvedCli = cliPath;
5284
- if (!resolvedCli && appPath && os20 === "darwin") {
5284
+ if (!resolvedCli && appPath && os21 === "darwin") {
5285
5285
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
5286
5286
  if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
5287
5287
  }
5288
- if (!resolvedCli && appPath && os20 === "win32") {
5288
+ if (!resolvedCli && appPath && os21 === "win32") {
5289
5289
  const { dirname: dirname7 } = await import("path");
5290
5290
  const appDir = dirname7(appPath);
5291
5291
  const candidates = [
@@ -5302,7 +5302,7 @@ async function detectIDEs(providerLoader) {
5302
5302
  }
5303
5303
  }
5304
5304
  }
5305
- const installed = os20 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
5305
+ const installed = os21 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
5306
5306
  const version = resolvedCli ? getIdeVersion(resolvedCli) : null;
5307
5307
  results.push({
5308
5308
  id: def.id,
@@ -10466,6 +10466,10 @@ function resolveLegacyProviderScript(fn, scriptName, params) {
10466
10466
  }
10467
10467
 
10468
10468
  // src/commands/chat-commands.ts
10469
+ var fs4 = __toESM(require("fs"));
10470
+ var os6 = __toESM(require("os"));
10471
+ var path8 = __toESM(require("path"));
10472
+ var import_node_crypto = require("crypto");
10469
10473
  init_contracts();
10470
10474
 
10471
10475
  // src/providers/provider-input-support.ts
@@ -11155,6 +11159,50 @@ function buildDebugBundleText(bundle) {
11155
11159
  "```"
11156
11160
  ].join("\n");
11157
11161
  }
11162
+ function getChatDebugBundleDir() {
11163
+ const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
11164
+ return override || path8.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
11165
+ }
11166
+ function safeBundleIdSegment(value, fallback) {
11167
+ const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
11168
+ return normalized || fallback;
11169
+ }
11170
+ function createChatDebugBundleId(targetSessionId) {
11171
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
11172
+ const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
11173
+ return `chat-debug-${timestamp}-${sessionSegment}-${(0, import_node_crypto.randomUUID)().slice(0, 8)}`;
11174
+ }
11175
+ function buildChatDebugBundleSummary(bundle) {
11176
+ const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
11177
+ const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
11178
+ const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
11179
+ const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
11180
+ return {
11181
+ createdAt: bundle.createdAt,
11182
+ targetSessionId: target.targetSessionId,
11183
+ providerType: target.providerType,
11184
+ transport: target.transport,
11185
+ readChatSuccess: readChat.success,
11186
+ readChatStatus: readChat.status,
11187
+ readChatTotalMessages: readChat.totalMessages,
11188
+ cliStatus: cli?.status,
11189
+ cliMessageCount: cli?.messageCount,
11190
+ hasFrontendSnapshot: !!frontend
11191
+ };
11192
+ }
11193
+ function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
11194
+ const bundleId = createChatDebugBundleId(targetSessionId);
11195
+ const dir = getChatDebugBundleDir();
11196
+ fs4.mkdirSync(dir, { recursive: true });
11197
+ const savedPath = path8.join(dir, `${bundleId}.json`);
11198
+ const json = `${JSON.stringify(bundle, null, 2)}
11199
+ `;
11200
+ fs4.writeFileSync(savedPath, json, { encoding: "utf8", mode: 384 });
11201
+ return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json, "utf8") };
11202
+ }
11203
+ function isDaemonFileDebugDelivery(args) {
11204
+ return args?.delivery === "daemon_file" || args?.delivery === "file";
11205
+ }
11158
11206
  async function handleGetChatDebugBundle(h, args) {
11159
11207
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
11160
11208
  if (!targetSessionId && !h.currentSession) {
@@ -11266,6 +11314,20 @@ async function handleGetChatDebugBundle(h, args) {
11266
11314
  recentDebugTrace: getRecentDebugTrace({ limit: 120 })
11267
11315
  };
11268
11316
  const bundle = sanitizeDebugBundleValue(rawBundle);
11317
+ if (isDaemonFileDebugDelivery(args)) {
11318
+ const summary = buildChatDebugBundleSummary(bundle);
11319
+ const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
11320
+ LOG.info("Command", `[get_chat_debug_bundle] saved daemon_file bundle id=${stored.bundleId} path=${stored.savedPath} sizeBytes=${stored.sizeBytes} targetSessionId=${summary.targetSessionId || ""} providerType=${summary.providerType || ""} transport=${summary.transport || ""}`);
11321
+ return {
11322
+ success: true,
11323
+ delivery: "daemon_file",
11324
+ bundleId: stored.bundleId,
11325
+ savedPath: stored.savedPath,
11326
+ sizeBytes: stored.sizeBytes,
11327
+ createdAt: bundle.createdAt,
11328
+ summary
11329
+ };
11330
+ }
11269
11331
  return {
11270
11332
  success: true,
11271
11333
  bundle,
@@ -12247,9 +12309,9 @@ async function handleResolveAction(h, args) {
12247
12309
  }
12248
12310
 
12249
12311
  // src/commands/cdp-commands.ts
12250
- var fs4 = __toESM(require("fs"));
12251
- var path8 = __toESM(require("path"));
12252
- var os6 = __toESM(require("os"));
12312
+ var fs5 = __toESM(require("fs"));
12313
+ var path9 = __toESM(require("path"));
12314
+ var os7 = __toESM(require("os"));
12253
12315
  var KEY_TO_VK = {
12254
12316
  Backspace: 8,
12255
12317
  Tab: 9,
@@ -12503,27 +12565,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
12503
12565
  function resolveSafePath(requestedPath) {
12504
12566
  const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
12505
12567
  const inputPath = rawPath || ".";
12506
- const home = os6.homedir();
12568
+ const home = os7.homedir();
12507
12569
  if (inputPath.startsWith("~")) {
12508
- return path8.resolve(path8.join(home, inputPath.slice(1)));
12570
+ return path9.resolve(path9.join(home, inputPath.slice(1)));
12509
12571
  }
12510
12572
  if (process.platform === "win32") {
12511
12573
  const normalized = normalizeWindowsRequestedPath(inputPath);
12512
- if (path8.win32.isAbsolute(normalized)) {
12513
- return path8.win32.normalize(normalized);
12574
+ if (path9.win32.isAbsolute(normalized)) {
12575
+ return path9.win32.normalize(normalized);
12514
12576
  }
12515
- return path8.win32.resolve(normalized);
12577
+ return path9.win32.resolve(normalized);
12516
12578
  }
12517
- if (path8.isAbsolute(inputPath)) {
12518
- return path8.normalize(inputPath);
12579
+ if (path9.isAbsolute(inputPath)) {
12580
+ return path9.normalize(inputPath);
12519
12581
  }
12520
- return path8.resolve(inputPath);
12582
+ return path9.resolve(inputPath);
12521
12583
  }
12522
12584
  function listDirectoryEntriesSafe(dirPath) {
12523
- const entries = fs4.readdirSync(dirPath, { withFileTypes: true });
12585
+ const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
12524
12586
  const files = [];
12525
12587
  for (const entry of entries) {
12526
- const entryPath = path8.join(dirPath, entry.name);
12588
+ const entryPath = path9.join(dirPath, entry.name);
12527
12589
  try {
12528
12590
  if (entry.isDirectory()) {
12529
12591
  files.push({ name: entry.name, type: "directory" });
@@ -12532,14 +12594,14 @@ function listDirectoryEntriesSafe(dirPath) {
12532
12594
  if (entry.isFile()) {
12533
12595
  let size;
12534
12596
  try {
12535
- size = fs4.statSync(entryPath).size;
12597
+ size = fs5.statSync(entryPath).size;
12536
12598
  } catch {
12537
12599
  size = void 0;
12538
12600
  }
12539
12601
  files.push({ name: entry.name, type: "file", size });
12540
12602
  continue;
12541
12603
  }
12542
- const stat = fs4.statSync(entryPath);
12604
+ const stat = fs5.statSync(entryPath);
12543
12605
  files.push({
12544
12606
  name: entry.name,
12545
12607
  type: stat.isDirectory() ? "directory" : "file",
@@ -12557,7 +12619,7 @@ function listWindowsDriveEntries(excludePath) {
12557
12619
  const letter = String.fromCharCode(code);
12558
12620
  const root = `${letter}:\\`;
12559
12621
  try {
12560
- if (!fs4.existsSync(root)) continue;
12622
+ if (!fs5.existsSync(root)) continue;
12561
12623
  if (excluded && root.toLowerCase() === excluded) continue;
12562
12624
  drives.push({ name: `${letter}:`, type: "directory", path: root });
12563
12625
  } catch {
@@ -12568,7 +12630,7 @@ function listWindowsDriveEntries(excludePath) {
12568
12630
  async function handleFileRead(h, args) {
12569
12631
  try {
12570
12632
  const filePath = resolveSafePath(args?.path);
12571
- const content = fs4.readFileSync(filePath, "utf-8");
12633
+ const content = fs5.readFileSync(filePath, "utf-8");
12572
12634
  return { success: true, content, path: filePath };
12573
12635
  } catch (e) {
12574
12636
  return { success: false, error: e.message };
@@ -12577,8 +12639,8 @@ async function handleFileRead(h, args) {
12577
12639
  async function handleFileWrite(h, args) {
12578
12640
  try {
12579
12641
  const filePath = resolveSafePath(args?.path);
12580
- fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
12581
- fs4.writeFileSync(filePath, args?.content || "", "utf-8");
12642
+ fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
12643
+ fs5.writeFileSync(filePath, args?.content || "", "utf-8");
12582
12644
  return { success: true, path: filePath };
12583
12645
  } catch (e) {
12584
12646
  return { success: false, error: e.message };
@@ -13679,8 +13741,8 @@ var DaemonCommandHandler = class {
13679
13741
  };
13680
13742
 
13681
13743
  // src/commands/cli-manager.ts
13682
- var os12 = __toESM(require("os"));
13683
- var path12 = __toESM(require("path"));
13744
+ var os13 = __toESM(require("os"));
13745
+ var path13 = __toESM(require("path"));
13684
13746
  var crypto4 = __toESM(require("crypto"));
13685
13747
  var import_fs5 = require("fs");
13686
13748
  var import_child_process6 = require("child_process");
@@ -13689,10 +13751,10 @@ init_provider_cli_adapter();
13689
13751
  init_config();
13690
13752
 
13691
13753
  // src/providers/cli-provider-instance.ts
13692
- var os11 = __toESM(require("os"));
13693
- var path11 = __toESM(require("path"));
13754
+ var os12 = __toESM(require("os"));
13755
+ var path12 = __toESM(require("path"));
13694
13756
  var crypto3 = __toESM(require("crypto"));
13695
- var fs5 = __toESM(require("fs"));
13757
+ var fs6 = __toESM(require("fs"));
13696
13758
  var import_node_module = require("module");
13697
13759
  init_contracts();
13698
13760
  init_provider_cli_adapter();
@@ -13751,7 +13813,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
13751
13813
  var CachedDatabaseSync = null;
13752
13814
  function getDatabaseSync() {
13753
13815
  if (CachedDatabaseSync) return CachedDatabaseSync;
13754
- const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path11.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
13816
+ const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
13755
13817
  const sqliteModule = requireFn(`node:${"sqlite"}`);
13756
13818
  CachedDatabaseSync = sqliteModule.DatabaseSync;
13757
13819
  if (!CachedDatabaseSync) {
@@ -13901,10 +13963,10 @@ var CliProviderInstance = class {
13901
13963
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
13902
13964
  */
13903
13965
  probeSessionIdFromConfig(probe) {
13904
- const resolvedDbPath = probe.dbPath.replace(/^~/, os11.homedir());
13966
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os12.homedir());
13905
13967
  const now = Date.now();
13906
13968
  if (this.cachedSqliteDbMissingUntil > now) return null;
13907
- if (!fs5.existsSync(resolvedDbPath)) {
13969
+ if (!fs6.existsSync(resolvedDbPath)) {
13908
13970
  this.cachedSqliteDbMissingUntil = now + 1e4;
13909
13971
  return null;
13910
13972
  }
@@ -14636,7 +14698,7 @@ ${effect.notification.body || ""}`.trim();
14636
14698
  };
14637
14699
  addDir(this.workingDir);
14638
14700
  try {
14639
- addDir(fs5.realpathSync.native(this.workingDir));
14701
+ addDir(fs6.realpathSync.native(this.workingDir));
14640
14702
  } catch {
14641
14703
  }
14642
14704
  return Array.from(dirs);
@@ -15835,11 +15897,11 @@ function shouldRestoreHostedRuntime(record, managerTag) {
15835
15897
  // src/commands/cli-manager.ts
15836
15898
  function isExplicitCommand(command) {
15837
15899
  const trimmed = command.trim();
15838
- return path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
15900
+ return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
15839
15901
  }
15840
15902
  function expandExecutable(command) {
15841
15903
  const trimmed = command.trim();
15842
- return trimmed.startsWith("~") ? path12.join(os12.homedir(), trimmed.slice(1)) : trimmed;
15904
+ return trimmed.startsWith("~") ? path13.join(os13.homedir(), trimmed.slice(1)) : trimmed;
15843
15905
  }
15844
15906
  function commandExists(command) {
15845
15907
  const trimmed = command.trim();
@@ -16120,7 +16182,7 @@ var DaemonCliManager = class {
16120
16182
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
16121
16183
  const trimmed = (workingDir || "").trim();
16122
16184
  if (!trimmed) throw new Error("working directory required");
16123
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os12.homedir()) : path12.resolve(trimmed);
16185
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path13.resolve(trimmed);
16124
16186
  const normalizedType = this.providerLoader.resolveAlias(cliType);
16125
16187
  const rawProvider = this.providerLoader.getByAlias(cliType);
16126
16188
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -16620,13 +16682,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
16620
16682
  // src/launch.ts
16621
16683
  var import_child_process7 = require("child_process");
16622
16684
  var net = __toESM(require("net"));
16623
- var os14 = __toESM(require("os"));
16624
- var path14 = __toESM(require("path"));
16685
+ var os15 = __toESM(require("os"));
16686
+ var path15 = __toESM(require("path"));
16625
16687
 
16626
16688
  // src/providers/provider-loader.ts
16627
- var fs6 = __toESM(require("fs"));
16628
- var path13 = __toESM(require("path"));
16629
- var os13 = __toESM(require("os"));
16689
+ var fs7 = __toESM(require("fs"));
16690
+ var path14 = __toESM(require("path"));
16691
+ var os14 = __toESM(require("os"));
16630
16692
  var chokidar = __toESM(require("chokidar"));
16631
16693
  init_logger();
16632
16694
 
@@ -16888,9 +16950,9 @@ var ProviderLoader = class _ProviderLoader {
16888
16950
  static siblingStderrLogged = /* @__PURE__ */ new Set();
16889
16951
  static looksLikeProviderRoot(candidate) {
16890
16952
  try {
16891
- if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
16953
+ if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
16892
16954
  return ["ide", "extension", "cli", "acp"].some(
16893
- (category) => fs6.existsSync(path13.join(candidate, category))
16955
+ (category) => fs7.existsSync(path14.join(candidate, category))
16894
16956
  );
16895
16957
  } catch {
16896
16958
  return false;
@@ -16898,20 +16960,20 @@ var ProviderLoader = class _ProviderLoader {
16898
16960
  }
16899
16961
  static hasProviderRootMarker(candidate) {
16900
16962
  try {
16901
- return fs6.existsSync(path13.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
16963
+ return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
16902
16964
  } catch {
16903
16965
  return false;
16904
16966
  }
16905
16967
  }
16906
16968
  detectDefaultUserDir() {
16907
- const fallback = path13.join(os13.homedir(), ".adhdev", "providers");
16969
+ const fallback = path14.join(os14.homedir(), ".adhdev", "providers");
16908
16970
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
16909
16971
  const visited = /* @__PURE__ */ new Set();
16910
16972
  for (const start of this.probeStarts) {
16911
- let current = path13.resolve(start);
16973
+ let current = path14.resolve(start);
16912
16974
  while (!visited.has(current)) {
16913
16975
  visited.add(current);
16914
- const siblingCandidate = path13.join(path13.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
16976
+ const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
16915
16977
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
16916
16978
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
16917
16979
  if (envOptIn || hasMarker) {
@@ -16933,7 +16995,7 @@ var ProviderLoader = class _ProviderLoader {
16933
16995
  return { path: siblingCandidate, source };
16934
16996
  }
16935
16997
  }
16936
- const parent = path13.dirname(current);
16998
+ const parent = path14.dirname(current);
16937
16999
  if (parent === current) break;
16938
17000
  current = parent;
16939
17001
  }
@@ -16943,11 +17005,11 @@ var ProviderLoader = class _ProviderLoader {
16943
17005
  constructor(options) {
16944
17006
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
16945
17007
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
16946
- this.defaultProvidersDir = path13.join(os13.homedir(), ".adhdev", "providers");
17008
+ this.defaultProvidersDir = path14.join(os14.homedir(), ".adhdev", "providers");
16947
17009
  const detected = this.detectDefaultUserDir();
16948
17010
  this.userDir = detected.path;
16949
17011
  this.userDirSource = detected.source;
16950
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
17012
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
16951
17013
  this.disableUpstream = false;
16952
17014
  this.applySourceConfig({
16953
17015
  userDir: options?.userDir,
@@ -17006,7 +17068,7 @@ var ProviderLoader = class _ProviderLoader {
17006
17068
  this.userDir = detected.path;
17007
17069
  this.userDirSource = detected.source;
17008
17070
  }
17009
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
17071
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
17010
17072
  this.disableUpstream = this.sourceMode === "no-upstream";
17011
17073
  if (this.explicitProviderDir) {
17012
17074
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -17020,7 +17082,7 @@ var ProviderLoader = class _ProviderLoader {
17020
17082
  * Canonical provider directory shape for a given root.
17021
17083
  */
17022
17084
  getProviderDir(root, category, type) {
17023
- return path13.join(root, category, type);
17085
+ return path14.join(root, category, type);
17024
17086
  }
17025
17087
  /**
17026
17088
  * Canonical user override directory for a provider.
@@ -17047,7 +17109,7 @@ var ProviderLoader = class _ProviderLoader {
17047
17109
  resolveProviderFile(type, ...segments) {
17048
17110
  const dir = this.findProviderDirInternal(type);
17049
17111
  if (!dir) return null;
17050
- return path13.join(dir, ...segments);
17112
+ return path14.join(dir, ...segments);
17051
17113
  }
17052
17114
  /**
17053
17115
  * Load all providers (3-tier priority)
@@ -17060,7 +17122,7 @@ var ProviderLoader = class _ProviderLoader {
17060
17122
  this.providers.clear();
17061
17123
  this.providerAvailability.clear();
17062
17124
  let upstreamCount = 0;
17063
- if (!this.disableUpstream && fs6.existsSync(this.upstreamDir)) {
17125
+ if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
17064
17126
  upstreamCount = this.loadDir(this.upstreamDir);
17065
17127
  if (upstreamCount > 0) {
17066
17128
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -17068,7 +17130,7 @@ var ProviderLoader = class _ProviderLoader {
17068
17130
  } else if (this.disableUpstream) {
17069
17131
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
17070
17132
  }
17071
- if (fs6.existsSync(this.userDir)) {
17133
+ if (fs7.existsSync(this.userDir)) {
17072
17134
  const userCount = this.loadDir(this.userDir, [".upstream"]);
17073
17135
  if (userCount > 0) {
17074
17136
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -17083,10 +17145,10 @@ var ProviderLoader = class _ProviderLoader {
17083
17145
  * Check if upstream directory exists and has providers.
17084
17146
  */
17085
17147
  hasUpstream() {
17086
- if (!fs6.existsSync(this.upstreamDir)) return false;
17148
+ if (!fs7.existsSync(this.upstreamDir)) return false;
17087
17149
  try {
17088
- return fs6.readdirSync(this.upstreamDir).some(
17089
- (d) => fs6.statSync(path13.join(this.upstreamDir, d)).isDirectory()
17150
+ return fs7.readdirSync(this.upstreamDir).some(
17151
+ (d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
17090
17152
  );
17091
17153
  } catch {
17092
17154
  return false;
@@ -17583,8 +17645,8 @@ var ProviderLoader = class _ProviderLoader {
17583
17645
  resolved._resolvedScriptDir = entry.scriptDir;
17584
17646
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
17585
17647
  if (providerDir) {
17586
- const fullDir = path13.join(providerDir, entry.scriptDir);
17587
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17648
+ const fullDir = path14.join(providerDir, entry.scriptDir);
17649
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17588
17650
  }
17589
17651
  matched = true;
17590
17652
  }
@@ -17599,8 +17661,8 @@ var ProviderLoader = class _ProviderLoader {
17599
17661
  resolved._resolvedScriptDir = base.defaultScriptDir;
17600
17662
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
17601
17663
  if (providerDir) {
17602
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
17603
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17664
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
17665
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17604
17666
  }
17605
17667
  }
17606
17668
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -17617,8 +17679,8 @@ var ProviderLoader = class _ProviderLoader {
17617
17679
  resolved._resolvedScriptDir = dirOverride;
17618
17680
  resolved._resolvedScriptsSource = `versions:${range}`;
17619
17681
  if (providerDir) {
17620
- const fullDir = path13.join(providerDir, dirOverride);
17621
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17682
+ const fullDir = path14.join(providerDir, dirOverride);
17683
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17622
17684
  }
17623
17685
  }
17624
17686
  } else if (override.scripts) {
@@ -17634,8 +17696,8 @@ var ProviderLoader = class _ProviderLoader {
17634
17696
  resolved._resolvedScriptDir = base.defaultScriptDir;
17635
17697
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
17636
17698
  if (providerDir) {
17637
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
17638
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17699
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
17700
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17639
17701
  }
17640
17702
  }
17641
17703
  }
@@ -17667,15 +17729,15 @@ var ProviderLoader = class _ProviderLoader {
17667
17729
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
17668
17730
  return null;
17669
17731
  }
17670
- const dir = path13.join(providerDir, scriptDir);
17671
- if (!fs6.existsSync(dir)) {
17732
+ const dir = path14.join(providerDir, scriptDir);
17733
+ if (!fs7.existsSync(dir)) {
17672
17734
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
17673
17735
  return null;
17674
17736
  }
17675
17737
  const cached = this.scriptsCache.get(dir);
17676
17738
  if (cached) return cached;
17677
- const scriptsJs = path13.join(dir, "scripts.js");
17678
- if (fs6.existsSync(scriptsJs)) {
17739
+ const scriptsJs = path14.join(dir, "scripts.js");
17740
+ if (fs7.existsSync(scriptsJs)) {
17679
17741
  try {
17680
17742
  delete require.cache[require.resolve(scriptsJs)];
17681
17743
  const loaded = require(scriptsJs);
@@ -17696,9 +17758,9 @@ var ProviderLoader = class _ProviderLoader {
17696
17758
  watch() {
17697
17759
  this.stopWatch();
17698
17760
  const watchDir = (dir) => {
17699
- if (!fs6.existsSync(dir)) {
17761
+ if (!fs7.existsSync(dir)) {
17700
17762
  try {
17701
- fs6.mkdirSync(dir, { recursive: true });
17763
+ fs7.mkdirSync(dir, { recursive: true });
17702
17764
  } catch {
17703
17765
  return;
17704
17766
  }
@@ -17716,7 +17778,7 @@ var ProviderLoader = class _ProviderLoader {
17716
17778
  return;
17717
17779
  }
17718
17780
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
17719
- this.log(`File changed: ${path13.basename(filePath)}, reloading...`);
17781
+ this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
17720
17782
  this.reload();
17721
17783
  }
17722
17784
  };
@@ -17771,12 +17833,12 @@ var ProviderLoader = class _ProviderLoader {
17771
17833
  }
17772
17834
  const https = require("https");
17773
17835
  const { execSync: execSync7 } = require("child_process");
17774
- const metaPath = path13.join(this.upstreamDir, _ProviderLoader.META_FILE);
17836
+ const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
17775
17837
  let prevEtag = "";
17776
17838
  let prevTimestamp = 0;
17777
17839
  try {
17778
- if (fs6.existsSync(metaPath)) {
17779
- const meta = JSON.parse(fs6.readFileSync(metaPath, "utf-8"));
17840
+ if (fs7.existsSync(metaPath)) {
17841
+ const meta = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
17780
17842
  prevEtag = meta.etag || "";
17781
17843
  prevTimestamp = meta.timestamp || 0;
17782
17844
  }
@@ -17831,39 +17893,39 @@ var ProviderLoader = class _ProviderLoader {
17831
17893
  return { updated: false };
17832
17894
  }
17833
17895
  this.log("Downloading latest providers from GitHub...");
17834
- const tmpTar = path13.join(os13.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
17835
- const tmpExtract = path13.join(os13.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
17896
+ const tmpTar = path14.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
17897
+ const tmpExtract = path14.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
17836
17898
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
17837
- fs6.mkdirSync(tmpExtract, { recursive: true });
17899
+ fs7.mkdirSync(tmpExtract, { recursive: true });
17838
17900
  execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
17839
- const extracted = fs6.readdirSync(tmpExtract);
17901
+ const extracted = fs7.readdirSync(tmpExtract);
17840
17902
  const rootDir = extracted.find(
17841
- (d) => fs6.statSync(path13.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
17903
+ (d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
17842
17904
  );
17843
17905
  if (!rootDir) throw new Error("Unexpected tarball structure");
17844
- const sourceDir = path13.join(tmpExtract, rootDir);
17906
+ const sourceDir = path14.join(tmpExtract, rootDir);
17845
17907
  const backupDir = this.upstreamDir + ".bak";
17846
- if (fs6.existsSync(this.upstreamDir)) {
17847
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
17848
- fs6.renameSync(this.upstreamDir, backupDir);
17908
+ if (fs7.existsSync(this.upstreamDir)) {
17909
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
17910
+ fs7.renameSync(this.upstreamDir, backupDir);
17849
17911
  }
17850
17912
  try {
17851
17913
  this.copyDirRecursive(sourceDir, this.upstreamDir);
17852
17914
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
17853
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
17915
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
17854
17916
  } catch (e) {
17855
- if (fs6.existsSync(backupDir)) {
17856
- if (fs6.existsSync(this.upstreamDir)) fs6.rmSync(this.upstreamDir, { recursive: true, force: true });
17857
- fs6.renameSync(backupDir, this.upstreamDir);
17917
+ if (fs7.existsSync(backupDir)) {
17918
+ if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
17919
+ fs7.renameSync(backupDir, this.upstreamDir);
17858
17920
  }
17859
17921
  throw e;
17860
17922
  }
17861
17923
  try {
17862
- fs6.rmSync(tmpTar, { force: true });
17924
+ fs7.rmSync(tmpTar, { force: true });
17863
17925
  } catch {
17864
17926
  }
17865
17927
  try {
17866
- fs6.rmSync(tmpExtract, { recursive: true, force: true });
17928
+ fs7.rmSync(tmpExtract, { recursive: true, force: true });
17867
17929
  } catch {
17868
17930
  }
17869
17931
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -17895,7 +17957,7 @@ var ProviderLoader = class _ProviderLoader {
17895
17957
  reject(new Error(`HTTP ${res.statusCode}`));
17896
17958
  return;
17897
17959
  }
17898
- const ws = fs6.createWriteStream(destPath);
17960
+ const ws = fs7.createWriteStream(destPath);
17899
17961
  res.pipe(ws);
17900
17962
  ws.on("finish", () => {
17901
17963
  ws.close();
@@ -17914,22 +17976,22 @@ var ProviderLoader = class _ProviderLoader {
17914
17976
  }
17915
17977
  /** Recursive directory copy */
17916
17978
  copyDirRecursive(src, dest) {
17917
- fs6.mkdirSync(dest, { recursive: true });
17918
- for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
17919
- const srcPath = path13.join(src, entry.name);
17920
- const destPath = path13.join(dest, entry.name);
17979
+ fs7.mkdirSync(dest, { recursive: true });
17980
+ for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
17981
+ const srcPath = path14.join(src, entry.name);
17982
+ const destPath = path14.join(dest, entry.name);
17921
17983
  if (entry.isDirectory()) {
17922
17984
  this.copyDirRecursive(srcPath, destPath);
17923
17985
  } else {
17924
- fs6.copyFileSync(srcPath, destPath);
17986
+ fs7.copyFileSync(srcPath, destPath);
17925
17987
  }
17926
17988
  }
17927
17989
  }
17928
17990
  /** .meta.json save */
17929
17991
  writeMeta(metaPath, etag, timestamp) {
17930
17992
  try {
17931
- fs6.mkdirSync(path13.dirname(metaPath), { recursive: true });
17932
- fs6.writeFileSync(metaPath, JSON.stringify({
17993
+ fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
17994
+ fs7.writeFileSync(metaPath, JSON.stringify({
17933
17995
  etag,
17934
17996
  timestamp,
17935
17997
  lastCheck: new Date(timestamp).toISOString(),
@@ -17940,12 +18002,12 @@ var ProviderLoader = class _ProviderLoader {
17940
18002
  }
17941
18003
  /** Count provider files (provider.js or provider.json) */
17942
18004
  countProviders(dir) {
17943
- if (!fs6.existsSync(dir)) return 0;
18005
+ if (!fs7.existsSync(dir)) return 0;
17944
18006
  let count = 0;
17945
18007
  const scan = (d) => {
17946
18008
  try {
17947
- for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
17948
- if (entry.isDirectory()) scan(path13.join(d, entry.name));
18009
+ for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
18010
+ if (entry.isDirectory()) scan(path14.join(d, entry.name));
17949
18011
  else if (entry.name === "provider.json") count++;
17950
18012
  }
17951
18013
  } catch {
@@ -18171,19 +18233,19 @@ var ProviderLoader = class _ProviderLoader {
18171
18233
  const cat = provider.category;
18172
18234
  const searchRoots = this.getProviderRoots();
18173
18235
  for (const root of searchRoots) {
18174
- if (!fs6.existsSync(root)) continue;
18236
+ if (!fs7.existsSync(root)) continue;
18175
18237
  const candidate = this.getProviderDir(root, cat, type);
18176
- if (fs6.existsSync(path13.join(candidate, "provider.json"))) return candidate;
18177
- const catDir = path13.join(root, cat);
18178
- if (fs6.existsSync(catDir)) {
18238
+ if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
18239
+ const catDir = path14.join(root, cat);
18240
+ if (fs7.existsSync(catDir)) {
18179
18241
  try {
18180
- for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
18242
+ for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
18181
18243
  if (!entry.isDirectory()) continue;
18182
- const jsonPath = path13.join(catDir, entry.name, "provider.json");
18183
- if (fs6.existsSync(jsonPath)) {
18244
+ const jsonPath = path14.join(catDir, entry.name, "provider.json");
18245
+ if (fs7.existsSync(jsonPath)) {
18184
18246
  try {
18185
- const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
18186
- if (data.type === type) return path13.join(catDir, entry.name);
18247
+ const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
18248
+ if (data.type === type) return path14.join(catDir, entry.name);
18187
18249
  } catch {
18188
18250
  }
18189
18251
  }
@@ -18200,8 +18262,8 @@ var ProviderLoader = class _ProviderLoader {
18200
18262
  * (template substitution is NOT applied here — scripts.js handles that)
18201
18263
  */
18202
18264
  buildScriptWrappersFromDir(dir) {
18203
- const scriptsJs = path13.join(dir, "scripts.js");
18204
- if (fs6.existsSync(scriptsJs)) {
18265
+ const scriptsJs = path14.join(dir, "scripts.js");
18266
+ if (fs7.existsSync(scriptsJs)) {
18205
18267
  try {
18206
18268
  delete require.cache[require.resolve(scriptsJs)];
18207
18269
  return require(scriptsJs);
@@ -18211,13 +18273,13 @@ var ProviderLoader = class _ProviderLoader {
18211
18273
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
18212
18274
  const result = {};
18213
18275
  try {
18214
- for (const file of fs6.readdirSync(dir)) {
18276
+ for (const file of fs7.readdirSync(dir)) {
18215
18277
  if (!file.endsWith(".js")) continue;
18216
18278
  const scriptName = toCamel(file.replace(".js", ""));
18217
- const filePath = path13.join(dir, file);
18279
+ const filePath = path14.join(dir, file);
18218
18280
  result[scriptName] = (...args) => {
18219
18281
  try {
18220
- let content = fs6.readFileSync(filePath, "utf-8");
18282
+ let content = fs7.readFileSync(filePath, "utf-8");
18221
18283
  if (args[0] && typeof args[0] === "object") {
18222
18284
  for (const [key, val] of Object.entries(args[0])) {
18223
18285
  let v = val;
@@ -18263,20 +18325,20 @@ var ProviderLoader = class _ProviderLoader {
18263
18325
  * Structure: dir/category/agent-name/provider.{json,js}
18264
18326
  */
18265
18327
  loadDir(dir, excludeDirs) {
18266
- if (!fs6.existsSync(dir)) return 0;
18328
+ if (!fs7.existsSync(dir)) return 0;
18267
18329
  let count = 0;
18268
18330
  const scan = (d) => {
18269
18331
  let entries;
18270
18332
  try {
18271
- entries = fs6.readdirSync(d, { withFileTypes: true });
18333
+ entries = fs7.readdirSync(d, { withFileTypes: true });
18272
18334
  } catch {
18273
18335
  return;
18274
18336
  }
18275
18337
  const hasJson = entries.some((e) => e.name === "provider.json");
18276
18338
  if (hasJson) {
18277
- const jsonPath = path13.join(d, "provider.json");
18339
+ const jsonPath = path14.join(d, "provider.json");
18278
18340
  try {
18279
- const raw = fs6.readFileSync(jsonPath, "utf-8");
18341
+ const raw = fs7.readFileSync(jsonPath, "utf-8");
18280
18342
  const mod = JSON.parse(raw);
18281
18343
  if (typeof mod.extensionIdPattern === "string") {
18282
18344
  const flags = mod.extensionIdPattern_flags || "";
@@ -18295,8 +18357,8 @@ var ProviderLoader = class _ProviderLoader {
18295
18357
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
18296
18358
  } else {
18297
18359
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
18298
- const scriptsPath = path13.join(d, "scripts.js");
18299
- if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
18360
+ const scriptsPath = path14.join(d, "scripts.js");
18361
+ if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
18300
18362
  try {
18301
18363
  delete require.cache[require.resolve(scriptsPath)];
18302
18364
  const scripts = require(scriptsPath);
@@ -18321,7 +18383,7 @@ var ProviderLoader = class _ProviderLoader {
18321
18383
  if (!entry.isDirectory()) continue;
18322
18384
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
18323
18385
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
18324
- scan(path13.join(d, entry.name));
18386
+ scan(path14.join(d, entry.name));
18325
18387
  }
18326
18388
  }
18327
18389
  };
@@ -18511,7 +18573,7 @@ async function isCdpActive(port) {
18511
18573
  });
18512
18574
  }
18513
18575
  async function killIdeProcess(ideId) {
18514
- const plat = os14.platform();
18576
+ const plat = os15.platform();
18515
18577
  const appName = getMacAppIdentifiers()[ideId];
18516
18578
  const winProcesses = getWinProcessNames()[ideId];
18517
18579
  try {
@@ -18572,7 +18634,7 @@ async function killIdeProcess(ideId) {
18572
18634
  }
18573
18635
  }
18574
18636
  function isIdeRunning(ideId) {
18575
- const plat = os14.platform();
18637
+ const plat = os15.platform();
18576
18638
  try {
18577
18639
  if (plat === "darwin") {
18578
18640
  const appName = getMacAppIdentifiers()[ideId];
@@ -18627,7 +18689,7 @@ function isIdeRunning(ideId) {
18627
18689
  }
18628
18690
  }
18629
18691
  function detectCurrentWorkspace(ideId) {
18630
- const plat = os14.platform();
18692
+ const plat = os15.platform();
18631
18693
  if (plat === "darwin") {
18632
18694
  try {
18633
18695
  const appName = getMacAppIdentifiers()[ideId];
@@ -18642,17 +18704,17 @@ function detectCurrentWorkspace(ideId) {
18642
18704
  }
18643
18705
  } else if (plat === "win32") {
18644
18706
  try {
18645
- const fs15 = require("fs");
18707
+ const fs16 = require("fs");
18646
18708
  const appNameMap = getMacAppIdentifiers();
18647
18709
  const appName = appNameMap[ideId];
18648
18710
  if (appName) {
18649
- const storagePath = path14.join(
18650
- process.env.APPDATA || path14.join(os14.homedir(), "AppData", "Roaming"),
18711
+ const storagePath = path15.join(
18712
+ process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Roaming"),
18651
18713
  appName,
18652
18714
  "storage.json"
18653
18715
  );
18654
- if (fs15.existsSync(storagePath)) {
18655
- const data = JSON.parse(fs15.readFileSync(storagePath, "utf-8"));
18716
+ if (fs16.existsSync(storagePath)) {
18717
+ const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
18656
18718
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
18657
18719
  if (workspaces.length > 0) {
18658
18720
  const recent = workspaces[0];
@@ -18669,7 +18731,7 @@ function detectCurrentWorkspace(ideId) {
18669
18731
  return void 0;
18670
18732
  }
18671
18733
  async function launchWithCdp(options = {}) {
18672
- const platform10 = os14.platform();
18734
+ const platform10 = os15.platform();
18673
18735
  let targetIde;
18674
18736
  const ides = await detectIDEs(getProviderLoader());
18675
18737
  if (options.ideId) {
@@ -18824,14 +18886,14 @@ init_config();
18824
18886
  init_logger();
18825
18887
 
18826
18888
  // src/logging/command-log.ts
18827
- var fs7 = __toESM(require("fs"));
18828
- var path15 = __toESM(require("path"));
18829
- var os15 = __toESM(require("os"));
18830
- var LOG_DIR2 = process.platform === "win32" ? path15.join(process.env.LOCALAPPDATA || process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path15.join(os15.homedir(), "Library", "Logs", "adhdev") : path15.join(os15.homedir(), ".local", "share", "adhdev", "logs");
18889
+ var fs8 = __toESM(require("fs"));
18890
+ var path16 = __toESM(require("path"));
18891
+ var os16 = __toESM(require("os"));
18892
+ var LOG_DIR2 = process.platform === "win32" ? path16.join(process.env.LOCALAPPDATA || process.env.APPDATA || path16.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path16.join(os16.homedir(), "Library", "Logs", "adhdev") : path16.join(os16.homedir(), ".local", "share", "adhdev", "logs");
18831
18893
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
18832
18894
  var MAX_DAYS = 7;
18833
18895
  try {
18834
- fs7.mkdirSync(LOG_DIR2, { recursive: true });
18896
+ fs8.mkdirSync(LOG_DIR2, { recursive: true });
18835
18897
  } catch {
18836
18898
  }
18837
18899
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -18865,19 +18927,19 @@ function getDateStr2() {
18865
18927
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
18866
18928
  }
18867
18929
  var currentDate2 = getDateStr2();
18868
- var currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18930
+ var currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18869
18931
  var writeCount2 = 0;
18870
18932
  function checkRotation() {
18871
18933
  const today = getDateStr2();
18872
18934
  if (today !== currentDate2) {
18873
18935
  currentDate2 = today;
18874
- currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18936
+ currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18875
18937
  cleanOldFiles();
18876
18938
  }
18877
18939
  }
18878
18940
  function cleanOldFiles() {
18879
18941
  try {
18880
- const files = fs7.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
18942
+ const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
18881
18943
  const cutoff = /* @__PURE__ */ new Date();
18882
18944
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
18883
18945
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -18885,7 +18947,7 @@ function cleanOldFiles() {
18885
18947
  const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
18886
18948
  if (dateMatch && dateMatch[1] < cutoffStr) {
18887
18949
  try {
18888
- fs7.unlinkSync(path15.join(LOG_DIR2, file));
18950
+ fs8.unlinkSync(path16.join(LOG_DIR2, file));
18889
18951
  } catch {
18890
18952
  }
18891
18953
  }
@@ -18895,14 +18957,14 @@ function cleanOldFiles() {
18895
18957
  }
18896
18958
  function checkSize() {
18897
18959
  try {
18898
- const stat = fs7.statSync(currentFile);
18960
+ const stat = fs8.statSync(currentFile);
18899
18961
  if (stat.size > MAX_FILE_SIZE) {
18900
18962
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
18901
18963
  try {
18902
- fs7.unlinkSync(backup);
18964
+ fs8.unlinkSync(backup);
18903
18965
  } catch {
18904
18966
  }
18905
- fs7.renameSync(currentFile, backup);
18967
+ fs8.renameSync(currentFile, backup);
18906
18968
  }
18907
18969
  } catch {
18908
18970
  }
@@ -18935,14 +18997,14 @@ function logCommand(entry) {
18935
18997
  ...entry.error ? { err: entry.error } : {},
18936
18998
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
18937
18999
  });
18938
- fs7.appendFileSync(currentFile, line + "\n");
19000
+ fs8.appendFileSync(currentFile, line + "\n");
18939
19001
  } catch {
18940
19002
  }
18941
19003
  }
18942
19004
  function getRecentCommands(count = 50) {
18943
19005
  try {
18944
- if (!fs7.existsSync(currentFile)) return [];
18945
- const content = fs7.readFileSync(currentFile, "utf-8");
19006
+ if (!fs8.existsSync(currentFile)) return [];
19007
+ const content = fs8.readFileSync(currentFile, "utf-8");
18946
19008
  const lines = content.trim().split("\n").filter(Boolean);
18947
19009
  return lines.slice(-count).map((line) => {
18948
19010
  try {
@@ -18971,7 +19033,7 @@ cleanOldFiles();
18971
19033
  init_logger();
18972
19034
 
18973
19035
  // src/status/snapshot.ts
18974
- var os16 = __toESM(require("os"));
19036
+ var os17 = __toESM(require("os"));
18975
19037
  init_config();
18976
19038
  init_terminal_screen();
18977
19039
  init_logger();
@@ -19026,8 +19088,8 @@ function buildAvailableProviders(providerLoader) {
19026
19088
  }
19027
19089
  function buildMachineInfo(profile = "full") {
19028
19090
  const base = {
19029
- hostname: os16.hostname(),
19030
- platform: os16.platform()
19091
+ hostname: os17.hostname(),
19092
+ platform: os17.platform()
19031
19093
  };
19032
19094
  if (profile === "live") {
19033
19095
  return base;
@@ -19036,23 +19098,23 @@ function buildMachineInfo(profile = "full") {
19036
19098
  const memSnap2 = getHostMemorySnapshot();
19037
19099
  return {
19038
19100
  ...base,
19039
- arch: os16.arch(),
19040
- cpus: os16.cpus().length,
19101
+ arch: os17.arch(),
19102
+ cpus: os17.cpus().length,
19041
19103
  totalMem: memSnap2.totalMem,
19042
- release: os16.release()
19104
+ release: os17.release()
19043
19105
  };
19044
19106
  }
19045
19107
  const memSnap = getHostMemorySnapshot();
19046
19108
  return {
19047
19109
  ...base,
19048
- arch: os16.arch(),
19049
- cpus: os16.cpus().length,
19110
+ arch: os17.arch(),
19111
+ cpus: os17.cpus().length,
19050
19112
  totalMem: memSnap.totalMem,
19051
19113
  freeMem: memSnap.freeMem,
19052
19114
  availableMem: memSnap.availableMem,
19053
- loadavg: os16.loadavg(),
19054
- uptime: os16.uptime(),
19055
- release: os16.release()
19115
+ loadavg: os17.loadavg(),
19116
+ uptime: os17.uptime(),
19117
+ release: os17.release()
19056
19118
  };
19057
19119
  }
19058
19120
  function parseMessageTime(value) {
@@ -19279,42 +19341,42 @@ function buildStatusSnapshot(options) {
19279
19341
  // src/commands/upgrade-helper.ts
19280
19342
  var import_child_process8 = require("child_process");
19281
19343
  var import_child_process9 = require("child_process");
19282
- var fs8 = __toESM(require("fs"));
19283
- var os17 = __toESM(require("os"));
19284
- var path16 = __toESM(require("path"));
19344
+ var fs9 = __toESM(require("fs"));
19345
+ var os18 = __toESM(require("os"));
19346
+ var path17 = __toESM(require("path"));
19285
19347
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
19286
19348
  function getUpgradeLogPath() {
19287
- const home = os17.homedir();
19288
- const dir = path16.join(home, ".adhdev");
19289
- fs8.mkdirSync(dir, { recursive: true });
19290
- return path16.join(dir, "daemon-upgrade.log");
19349
+ const home = os18.homedir();
19350
+ const dir = path17.join(home, ".adhdev");
19351
+ fs9.mkdirSync(dir, { recursive: true });
19352
+ return path17.join(dir, "daemon-upgrade.log");
19291
19353
  }
19292
19354
  function appendUpgradeLog(message) {
19293
19355
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
19294
19356
  `;
19295
19357
  try {
19296
- fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
19358
+ fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
19297
19359
  } catch {
19298
19360
  }
19299
19361
  }
19300
19362
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
19301
- const binDir = path16.dirname(nodeExecutable);
19363
+ const binDir = path17.dirname(nodeExecutable);
19302
19364
  if (platform10 === "win32") {
19303
- const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
19304
- if (fs8.existsSync(npmCliPath)) {
19365
+ const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
19366
+ if (fs9.existsSync(npmCliPath)) {
19305
19367
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
19306
19368
  }
19307
19369
  for (const candidate of ["npm.exe", "npm"]) {
19308
- const candidatePath = path16.join(binDir, candidate);
19309
- if (fs8.existsSync(candidatePath)) {
19370
+ const candidatePath = path17.join(binDir, candidate);
19371
+ if (fs9.existsSync(candidatePath)) {
19310
19372
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
19311
19373
  }
19312
19374
  }
19313
19375
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
19314
19376
  }
19315
19377
  for (const candidate of ["npm"]) {
19316
- const candidatePath = path16.join(binDir, candidate);
19317
- if (fs8.existsSync(candidatePath)) {
19378
+ const candidatePath = path17.join(binDir, candidate);
19379
+ if (fs9.existsSync(candidatePath)) {
19318
19380
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
19319
19381
  }
19320
19382
  }
@@ -19324,22 +19386,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19324
19386
  if (!currentCliPath) return null;
19325
19387
  let resolvedPath = currentCliPath;
19326
19388
  try {
19327
- resolvedPath = fs8.realpathSync.native(currentCliPath);
19389
+ resolvedPath = fs9.realpathSync.native(currentCliPath);
19328
19390
  } catch {
19329
19391
  }
19330
19392
  let currentDir = resolvedPath;
19331
19393
  try {
19332
- if (fs8.statSync(resolvedPath).isFile()) {
19333
- currentDir = path16.dirname(resolvedPath);
19394
+ if (fs9.statSync(resolvedPath).isFile()) {
19395
+ currentDir = path17.dirname(resolvedPath);
19334
19396
  }
19335
19397
  } catch {
19336
- currentDir = path16.dirname(resolvedPath);
19398
+ currentDir = path17.dirname(resolvedPath);
19337
19399
  }
19338
19400
  while (true) {
19339
- const packageJsonPath = path16.join(currentDir, "package.json");
19401
+ const packageJsonPath = path17.join(currentDir, "package.json");
19340
19402
  try {
19341
- if (fs8.existsSync(packageJsonPath)) {
19342
- const parsed = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
19403
+ if (fs9.existsSync(packageJsonPath)) {
19404
+ const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
19343
19405
  if (parsed?.name === packageName) {
19344
19406
  const normalized = currentDir.replace(/\\/g, "/");
19345
19407
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -19347,7 +19409,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19347
19409
  }
19348
19410
  } catch {
19349
19411
  }
19350
- const parentDir = path16.dirname(currentDir);
19412
+ const parentDir = path17.dirname(currentDir);
19351
19413
  if (parentDir === currentDir) {
19352
19414
  return null;
19353
19415
  }
@@ -19355,13 +19417,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19355
19417
  }
19356
19418
  }
19357
19419
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
19358
- const nodeModulesDir = packageName.startsWith("@") ? path16.dirname(path16.dirname(packageRoot)) : path16.dirname(packageRoot);
19359
- if (path16.basename(nodeModulesDir) !== "node_modules") {
19420
+ const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
19421
+ if (path17.basename(nodeModulesDir) !== "node_modules") {
19360
19422
  return null;
19361
19423
  }
19362
- const maybeLibDir = path16.dirname(nodeModulesDir);
19363
- if (path16.basename(maybeLibDir) === "lib") {
19364
- return path16.dirname(maybeLibDir);
19424
+ const maybeLibDir = path17.dirname(nodeModulesDir);
19425
+ if (path17.basename(maybeLibDir) === "lib") {
19426
+ return path17.dirname(maybeLibDir);
19365
19427
  }
19366
19428
  return maybeLibDir;
19367
19429
  }
@@ -19476,10 +19538,10 @@ async function waitForPidExit(pid, timeoutMs) {
19476
19538
  }
19477
19539
  }
19478
19540
  function stopSessionHostProcesses(appName) {
19479
- const pidFile = path16.join(os17.homedir(), ".adhdev", `${appName}-session-host.pid`);
19541
+ const pidFile = path17.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
19480
19542
  try {
19481
- if (fs8.existsSync(pidFile)) {
19482
- const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
19543
+ if (fs9.existsSync(pidFile)) {
19544
+ const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
19483
19545
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
19484
19546
  killPid(pid);
19485
19547
  }
@@ -19487,15 +19549,15 @@ function stopSessionHostProcesses(appName) {
19487
19549
  } catch {
19488
19550
  } finally {
19489
19551
  try {
19490
- fs8.unlinkSync(pidFile);
19552
+ fs9.unlinkSync(pidFile);
19491
19553
  } catch {
19492
19554
  }
19493
19555
  }
19494
19556
  }
19495
19557
  function removeDaemonPidFile() {
19496
- const pidFile = path16.join(os17.homedir(), ".adhdev", "daemon.pid");
19558
+ const pidFile = path17.join(os18.homedir(), ".adhdev", "daemon.pid");
19497
19559
  try {
19498
- fs8.unlinkSync(pidFile);
19560
+ fs9.unlinkSync(pidFile);
19499
19561
  } catch {
19500
19562
  }
19501
19563
  }
@@ -19504,7 +19566,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
19504
19566
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
19505
19567
  if (!npmRoot) return;
19506
19568
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
19507
- const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
19569
+ const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
19508
19570
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
19509
19571
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
19510
19572
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -19512,25 +19574,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
19512
19574
  }
19513
19575
  if (pkgName.startsWith("@")) {
19514
19576
  const [scope, name] = pkgName.split("/");
19515
- const scopeDir = path16.join(npmRoot, scope);
19516
- if (!fs8.existsSync(scopeDir)) return;
19517
- for (const entry of fs8.readdirSync(scopeDir)) {
19577
+ const scopeDir = path17.join(npmRoot, scope);
19578
+ if (!fs9.existsSync(scopeDir)) return;
19579
+ for (const entry of fs9.readdirSync(scopeDir)) {
19518
19580
  if (!entry.startsWith(`.${name}-`)) continue;
19519
- fs8.rmSync(path16.join(scopeDir, entry), { recursive: true, force: true });
19520
- appendUpgradeLog(`Removed stale scoped staging dir: ${path16.join(scopeDir, entry)}`);
19581
+ fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
19582
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
19521
19583
  }
19522
19584
  } else {
19523
- for (const entry of fs8.readdirSync(npmRoot)) {
19585
+ for (const entry of fs9.readdirSync(npmRoot)) {
19524
19586
  if (!entry.startsWith(`.${pkgName}-`)) continue;
19525
- fs8.rmSync(path16.join(npmRoot, entry), { recursive: true, force: true });
19526
- appendUpgradeLog(`Removed stale staging dir: ${path16.join(npmRoot, entry)}`);
19587
+ fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
19588
+ appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
19527
19589
  }
19528
19590
  }
19529
- if (fs8.existsSync(binDir)) {
19530
- for (const entry of fs8.readdirSync(binDir)) {
19591
+ if (fs9.existsSync(binDir)) {
19592
+ for (const entry of fs9.readdirSync(binDir)) {
19531
19593
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
19532
- fs8.rmSync(path16.join(binDir, entry), { recursive: true, force: true });
19533
- appendUpgradeLog(`Removed stale bin staging entry: ${path16.join(binDir, entry)}`);
19594
+ fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
19595
+ appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
19534
19596
  }
19535
19597
  }
19536
19598
  }
@@ -19615,7 +19677,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
19615
19677
  }
19616
19678
 
19617
19679
  // src/commands/router.ts
19618
- var fs9 = __toESM(require("fs"));
19680
+ var fs10 = __toESM(require("fs"));
19619
19681
  var CHAT_COMMANDS = [
19620
19682
  "send_chat",
19621
19683
  "new_chat",
@@ -19851,8 +19913,8 @@ var DaemonCommandRouter = class {
19851
19913
  if (sinceTs > 0) {
19852
19914
  return { success: true, logs: [], totalBuffered: 0 };
19853
19915
  }
19854
- if (fs9.existsSync(LOG_PATH)) {
19855
- const content = fs9.readFileSync(LOG_PATH, "utf-8");
19916
+ if (fs10.existsSync(LOG_PATH)) {
19917
+ const content = fs10.readFileSync(LOG_PATH, "utf-8");
19856
19918
  const allLines = content.split("\n");
19857
19919
  const recent = allLines.slice(-count).join("\n");
19858
19920
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -22007,12 +22069,12 @@ init_io_contracts();
22007
22069
  init_chat_message_normalization();
22008
22070
 
22009
22071
  // src/providers/version-archive.ts
22010
- var fs10 = __toESM(require("fs"));
22011
- var path17 = __toESM(require("path"));
22012
- var os18 = __toESM(require("os"));
22072
+ var fs11 = __toESM(require("fs"));
22073
+ var path18 = __toESM(require("path"));
22074
+ var os19 = __toESM(require("os"));
22013
22075
  var import_child_process10 = require("child_process");
22014
22076
  var import_os3 = require("os");
22015
- var ARCHIVE_PATH = path17.join(os18.homedir(), ".adhdev", "version-history.json");
22077
+ var ARCHIVE_PATH = path18.join(os19.homedir(), ".adhdev", "version-history.json");
22016
22078
  var MAX_ENTRIES_PER_PROVIDER = 20;
22017
22079
  var VersionArchive = class {
22018
22080
  history = {};
@@ -22021,8 +22083,8 @@ var VersionArchive = class {
22021
22083
  }
22022
22084
  load() {
22023
22085
  try {
22024
- if (fs10.existsSync(ARCHIVE_PATH)) {
22025
- this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
22086
+ if (fs11.existsSync(ARCHIVE_PATH)) {
22087
+ this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
22026
22088
  }
22027
22089
  } catch {
22028
22090
  this.history = {};
@@ -22059,8 +22121,8 @@ var VersionArchive = class {
22059
22121
  }
22060
22122
  save() {
22061
22123
  try {
22062
- fs10.mkdirSync(path17.dirname(ARCHIVE_PATH), { recursive: true });
22063
- fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
22124
+ fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
22125
+ fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
22064
22126
  } catch {
22065
22127
  }
22066
22128
  }
@@ -22115,19 +22177,19 @@ function getVersion(binary, versionCommand) {
22115
22177
  function checkPathExists2(paths) {
22116
22178
  for (const p of paths) {
22117
22179
  if (p.includes("*")) {
22118
- const home = os18.homedir();
22119
- const resolved = p.replace(/\*/g, home.split(path17.sep).pop() || "");
22120
- if (fs10.existsSync(resolved)) return resolved;
22180
+ const home = os19.homedir();
22181
+ const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
22182
+ if (fs11.existsSync(resolved)) return resolved;
22121
22183
  } else {
22122
- if (fs10.existsSync(p)) return p;
22184
+ if (fs11.existsSync(p)) return p;
22123
22185
  }
22124
22186
  }
22125
22187
  return null;
22126
22188
  }
22127
22189
  function getMacAppVersion(appPath) {
22128
22190
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
22129
- const plistPath = path17.join(appPath, "Contents", "Info.plist");
22130
- if (!fs10.existsSync(plistPath)) return null;
22191
+ const plistPath = path18.join(appPath, "Contents", "Info.plist");
22192
+ if (!fs11.existsSync(plistPath)) return null;
22131
22193
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
22132
22194
  return raw || null;
22133
22195
  }
@@ -22152,8 +22214,8 @@ async function detectAllVersions(loader, archive) {
22152
22214
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
22153
22215
  let resolvedBin = cliBin;
22154
22216
  if (!resolvedBin && appPath && currentOs === "darwin") {
22155
- const bundled = path17.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
22156
- if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
22217
+ const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
22218
+ if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
22157
22219
  }
22158
22220
  info.installed = !!(appPath || resolvedBin);
22159
22221
  info.path = appPath || null;
@@ -22192,8 +22254,8 @@ async function detectAllVersions(loader, archive) {
22192
22254
 
22193
22255
  // src/daemon/dev-server.ts
22194
22256
  var http2 = __toESM(require("http"));
22195
- var fs14 = __toESM(require("fs"));
22196
- var path21 = __toESM(require("path"));
22257
+ var fs15 = __toESM(require("fs"));
22258
+ var path22 = __toESM(require("path"));
22197
22259
  init_config();
22198
22260
 
22199
22261
  // src/daemon/scaffold-template.ts
@@ -22543,8 +22605,8 @@ async (params) => {
22543
22605
  init_logger();
22544
22606
 
22545
22607
  // src/daemon/dev-cdp-handlers.ts
22546
- var fs11 = __toESM(require("fs"));
22547
- var path18 = __toESM(require("path"));
22608
+ var fs12 = __toESM(require("fs"));
22609
+ var path19 = __toESM(require("path"));
22548
22610
  init_logger();
22549
22611
  async function handleCdpEvaluate(ctx, req, res) {
22550
22612
  const body = await ctx.readBody(req);
@@ -22723,18 +22785,18 @@ async function handleScriptHints(ctx, type, _req, res) {
22723
22785
  return;
22724
22786
  }
22725
22787
  let scriptsPath = "";
22726
- const directScripts = path18.join(dir, "scripts.js");
22727
- if (fs11.existsSync(directScripts)) {
22788
+ const directScripts = path19.join(dir, "scripts.js");
22789
+ if (fs12.existsSync(directScripts)) {
22728
22790
  scriptsPath = directScripts;
22729
22791
  } else {
22730
- const scriptsDir = path18.join(dir, "scripts");
22731
- if (fs11.existsSync(scriptsDir)) {
22732
- const versions = fs11.readdirSync(scriptsDir).filter((d) => {
22733
- return fs11.statSync(path18.join(scriptsDir, d)).isDirectory();
22792
+ const scriptsDir = path19.join(dir, "scripts");
22793
+ if (fs12.existsSync(scriptsDir)) {
22794
+ const versions = fs12.readdirSync(scriptsDir).filter((d) => {
22795
+ return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
22734
22796
  }).sort().reverse();
22735
22797
  for (const ver of versions) {
22736
- const p = path18.join(scriptsDir, ver, "scripts.js");
22737
- if (fs11.existsSync(p)) {
22798
+ const p = path19.join(scriptsDir, ver, "scripts.js");
22799
+ if (fs12.existsSync(p)) {
22738
22800
  scriptsPath = p;
22739
22801
  break;
22740
22802
  }
@@ -22746,7 +22808,7 @@ async function handleScriptHints(ctx, type, _req, res) {
22746
22808
  return;
22747
22809
  }
22748
22810
  try {
22749
- const source = fs11.readFileSync(scriptsPath, "utf-8");
22811
+ const source = fs12.readFileSync(scriptsPath, "utf-8");
22750
22812
  const hints = {};
22751
22813
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
22752
22814
  let match;
@@ -23561,8 +23623,8 @@ async function handleDomContext(ctx, type, req, res) {
23561
23623
  }
23562
23624
 
23563
23625
  // src/daemon/dev-cli-debug.ts
23564
- var fs12 = __toESM(require("fs"));
23565
- var path19 = __toESM(require("path"));
23626
+ var fs13 = __toESM(require("fs"));
23627
+ var path20 = __toESM(require("path"));
23566
23628
  function slugifyFixtureName(value) {
23567
23629
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
23568
23630
  return normalized || `fixture-${Date.now()}`;
@@ -23572,15 +23634,15 @@ function getCliFixtureDir(ctx, type) {
23572
23634
  if (!providerDir) {
23573
23635
  throw new Error(`Provider directory not found for '${type}'`);
23574
23636
  }
23575
- return path19.join(providerDir, "fixtures");
23637
+ return path20.join(providerDir, "fixtures");
23576
23638
  }
23577
23639
  function readCliFixture(ctx, type, name) {
23578
23640
  const fixtureDir = getCliFixtureDir(ctx, type);
23579
- const filePath = path19.join(fixtureDir, `${name}.json`);
23580
- if (!fs12.existsSync(filePath)) {
23641
+ const filePath = path20.join(fixtureDir, `${name}.json`);
23642
+ if (!fs13.existsSync(filePath)) {
23581
23643
  throw new Error(`Fixture not found: ${filePath}`);
23582
23644
  }
23583
- return JSON.parse(fs12.readFileSync(filePath, "utf-8"));
23645
+ return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
23584
23646
  }
23585
23647
  function getExerciseTranscriptText(result) {
23586
23648
  const parts = [];
@@ -24316,7 +24378,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
24316
24378
  return;
24317
24379
  }
24318
24380
  const fixtureDir = getCliFixtureDir(ctx, type);
24319
- fs12.mkdirSync(fixtureDir, { recursive: true });
24381
+ fs13.mkdirSync(fixtureDir, { recursive: true });
24320
24382
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
24321
24383
  const result = await runCliExerciseInternal(ctx, { ...request, type });
24322
24384
  const fixture = {
@@ -24343,8 +24405,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
24343
24405
  },
24344
24406
  notes: typeof body?.notes === "string" ? body.notes : void 0
24345
24407
  };
24346
- const filePath = path19.join(fixtureDir, `${name}.json`);
24347
- fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
24408
+ const filePath = path20.join(fixtureDir, `${name}.json`);
24409
+ fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
24348
24410
  ctx.json(res, 200, {
24349
24411
  saved: true,
24350
24412
  name,
@@ -24362,14 +24424,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
24362
24424
  async function handleCliFixtureList(ctx, type, _req, res) {
24363
24425
  try {
24364
24426
  const fixtureDir = getCliFixtureDir(ctx, type);
24365
- if (!fs12.existsSync(fixtureDir)) {
24427
+ if (!fs13.existsSync(fixtureDir)) {
24366
24428
  ctx.json(res, 200, { fixtures: [], count: 0 });
24367
24429
  return;
24368
24430
  }
24369
- const fixtures = fs12.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
24370
- const fullPath = path19.join(fixtureDir, file);
24431
+ const fixtures = fs13.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
24432
+ const fullPath = path20.join(fixtureDir, file);
24371
24433
  try {
24372
- const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
24434
+ const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
24373
24435
  return {
24374
24436
  name: raw.name || file.replace(/\.json$/i, ""),
24375
24437
  path: fullPath,
@@ -24502,9 +24564,9 @@ async function handleCliRaw(ctx, req, res) {
24502
24564
  }
24503
24565
 
24504
24566
  // src/daemon/dev-auto-implement.ts
24505
- var fs13 = __toESM(require("fs"));
24506
- var path20 = __toESM(require("path"));
24507
- var os19 = __toESM(require("os"));
24567
+ var fs14 = __toESM(require("fs"));
24568
+ var path21 = __toESM(require("path"));
24569
+ var os20 = __toESM(require("os"));
24508
24570
  function getAutoImplPid(ctx) {
24509
24571
  const pid = ctx.autoImplProcess?.pid;
24510
24572
  return typeof pid === "number" && pid > 0 ? pid : null;
@@ -24550,38 +24612,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
24550
24612
  return fallback?.type || null;
24551
24613
  }
24552
24614
  function getLatestScriptVersionDir(scriptsDir) {
24553
- if (!fs13.existsSync(scriptsDir)) return null;
24554
- const versions = fs13.readdirSync(scriptsDir).filter((d) => {
24615
+ if (!fs14.existsSync(scriptsDir)) return null;
24616
+ const versions = fs14.readdirSync(scriptsDir).filter((d) => {
24555
24617
  try {
24556
- return fs13.statSync(path20.join(scriptsDir, d)).isDirectory();
24618
+ return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
24557
24619
  } catch {
24558
24620
  return false;
24559
24621
  }
24560
24622
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
24561
24623
  if (versions.length === 0) return null;
24562
- return path20.join(scriptsDir, versions[0]);
24624
+ return path21.join(scriptsDir, versions[0]);
24563
24625
  }
24564
24626
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
24565
- const canonicalUserDir = path20.resolve(ctx.providerLoader.getUserProviderDir(category, type));
24566
- const desiredDir = requestedDir ? path20.resolve(requestedDir) : canonicalUserDir;
24567
- const upstreamRoot = path20.resolve(ctx.providerLoader.getUpstreamDir());
24568
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path20.sep}`)) {
24627
+ const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
24628
+ const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
24629
+ const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
24630
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
24569
24631
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
24570
24632
  }
24571
- if (path20.basename(desiredDir) !== type) {
24633
+ if (path21.basename(desiredDir) !== type) {
24572
24634
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
24573
24635
  }
24574
24636
  const sourceDir = ctx.findProviderDir(type);
24575
24637
  if (!sourceDir) {
24576
24638
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
24577
24639
  }
24578
- if (!fs13.existsSync(desiredDir)) {
24579
- fs13.mkdirSync(path20.dirname(desiredDir), { recursive: true });
24580
- fs13.cpSync(sourceDir, desiredDir, { recursive: true });
24640
+ if (!fs14.existsSync(desiredDir)) {
24641
+ fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
24642
+ fs14.cpSync(sourceDir, desiredDir, { recursive: true });
24581
24643
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
24582
24644
  }
24583
- const providerJson = path20.join(desiredDir, "provider.json");
24584
- if (!fs13.existsSync(providerJson)) {
24645
+ const providerJson = path21.join(desiredDir, "provider.json");
24646
+ if (!fs14.existsSync(providerJson)) {
24585
24647
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
24586
24648
  }
24587
24649
  return { dir: desiredDir };
@@ -24589,15 +24651,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
24589
24651
  function loadAutoImplReferenceScripts(ctx, referenceType) {
24590
24652
  if (!referenceType) return {};
24591
24653
  const refDir = ctx.findProviderDir(referenceType);
24592
- if (!refDir || !fs13.existsSync(refDir)) return {};
24654
+ if (!refDir || !fs14.existsSync(refDir)) return {};
24593
24655
  const referenceScripts = {};
24594
- const scriptsDir = path20.join(refDir, "scripts");
24656
+ const scriptsDir = path21.join(refDir, "scripts");
24595
24657
  const latestDir = getLatestScriptVersionDir(scriptsDir);
24596
24658
  if (!latestDir) return referenceScripts;
24597
- for (const file of fs13.readdirSync(latestDir)) {
24659
+ for (const file of fs14.readdirSync(latestDir)) {
24598
24660
  if (!file.endsWith(".js")) continue;
24599
24661
  try {
24600
- referenceScripts[file] = fs13.readFileSync(path20.join(latestDir, file), "utf-8");
24662
+ referenceScripts[file] = fs14.readFileSync(path21.join(latestDir, file), "utf-8");
24601
24663
  } catch {
24602
24664
  }
24603
24665
  }
@@ -24705,16 +24767,16 @@ async function handleAutoImplement(ctx, type, req, res) {
24705
24767
  });
24706
24768
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
24707
24769
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
24708
- const tmpDir = path20.join(os19.tmpdir(), "adhdev-autoimpl");
24709
- if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
24710
- const promptFile = path20.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
24711
- fs13.writeFileSync(promptFile, prompt, "utf-8");
24770
+ const tmpDir = path21.join(os20.tmpdir(), "adhdev-autoimpl");
24771
+ if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
24772
+ const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
24773
+ fs14.writeFileSync(promptFile, prompt, "utf-8");
24712
24774
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
24713
24775
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
24714
24776
  const spawn4 = agentProvider?.spawn;
24715
24777
  if (!spawn4?.command) {
24716
24778
  try {
24717
- fs13.unlinkSync(promptFile);
24779
+ fs14.unlinkSync(promptFile);
24718
24780
  } catch {
24719
24781
  }
24720
24782
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -24816,7 +24878,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24816
24878
  } catch {
24817
24879
  }
24818
24880
  try {
24819
- fs13.unlinkSync(promptFile);
24881
+ fs14.unlinkSync(promptFile);
24820
24882
  } catch {
24821
24883
  }
24822
24884
  ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -24860,7 +24922,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24860
24922
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
24861
24923
  const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
24862
24924
  let shellCmd;
24863
- const isWin = os19.platform() === "win32";
24925
+ const isWin = os20.platform() === "win32";
24864
24926
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
24865
24927
  const promptMode = autoImpl?.promptMode ?? "stdin";
24866
24928
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -24899,7 +24961,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24899
24961
  try {
24900
24962
  const pty = require("node-pty");
24901
24963
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
24902
- const isWin2 = os19.platform() === "win32";
24964
+ const isWin2 = os20.platform() === "win32";
24903
24965
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
24904
24966
  name: "xterm-256color",
24905
24967
  cols: 120,
@@ -25042,7 +25104,7 @@ async function handleAutoImplement(ctx, type, req, res) {
25042
25104
  }
25043
25105
  });
25044
25106
  try {
25045
- fs13.unlinkSync(promptFile);
25107
+ fs14.unlinkSync(promptFile);
25046
25108
  } catch {
25047
25109
  }
25048
25110
  ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -25139,7 +25201,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25139
25201
  setMode: "set_mode.js"
25140
25202
  };
25141
25203
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
25142
- const scriptsDir = path20.join(providerDir, "scripts");
25204
+ const scriptsDir = path21.join(providerDir, "scripts");
25143
25205
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
25144
25206
  if (latestScriptsDir) {
25145
25207
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -25147,10 +25209,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25147
25209
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
25148
25210
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
25149
25211
  lines.push("");
25150
- for (const file of fs13.readdirSync(latestScriptsDir)) {
25212
+ for (const file of fs14.readdirSync(latestScriptsDir)) {
25151
25213
  if (file.endsWith(".js") && targetFileNames.has(file)) {
25152
25214
  try {
25153
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25215
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25154
25216
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
25155
25217
  lines.push("```javascript");
25156
25218
  lines.push(content);
@@ -25160,14 +25222,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25160
25222
  }
25161
25223
  }
25162
25224
  }
25163
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25225
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25164
25226
  if (refFiles.length > 0) {
25165
25227
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
25166
25228
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
25167
25229
  lines.push("");
25168
25230
  for (const file of refFiles) {
25169
25231
  try {
25170
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25232
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25171
25233
  lines.push(`### \`${file}\` \u{1F512}`);
25172
25234
  lines.push("```javascript");
25173
25235
  lines.push(content);
@@ -25208,11 +25270,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25208
25270
  lines.push("");
25209
25271
  }
25210
25272
  }
25211
- const docsDir = path20.join(providerDir, "../../docs");
25273
+ const docsDir = path21.join(providerDir, "../../docs");
25212
25274
  const loadGuide = (name) => {
25213
25275
  try {
25214
- const p = path20.join(docsDir, name);
25215
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
25276
+ const p = path21.join(docsDir, name);
25277
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
25216
25278
  } catch {
25217
25279
  }
25218
25280
  return null;
@@ -25448,7 +25510,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25448
25510
  parseApproval: "parse_approval.js"
25449
25511
  };
25450
25512
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
25451
- const scriptsDir = path20.join(providerDir, "scripts");
25513
+ const scriptsDir = path21.join(providerDir, "scripts");
25452
25514
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
25453
25515
  if (latestScriptsDir) {
25454
25516
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -25456,11 +25518,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25456
25518
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
25457
25519
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
25458
25520
  lines.push("");
25459
- for (const file of fs13.readdirSync(latestScriptsDir)) {
25521
+ for (const file of fs14.readdirSync(latestScriptsDir)) {
25460
25522
  if (!file.endsWith(".js")) continue;
25461
25523
  if (!targetFileNames.has(file)) continue;
25462
25524
  try {
25463
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25525
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25464
25526
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
25465
25527
  lines.push("```javascript");
25466
25528
  lines.push(content);
@@ -25469,14 +25531,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25469
25531
  } catch {
25470
25532
  }
25471
25533
  }
25472
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25534
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25473
25535
  if (refFiles.length > 0) {
25474
25536
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
25475
25537
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
25476
25538
  lines.push("");
25477
25539
  for (const file of refFiles) {
25478
25540
  try {
25479
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25541
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25480
25542
  lines.push(`### \`${file}\` \u{1F512}`);
25481
25543
  lines.push("```javascript");
25482
25544
  lines.push(content);
@@ -25509,11 +25571,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25509
25571
  lines.push("");
25510
25572
  }
25511
25573
  }
25512
- const docsDir = path20.join(providerDir, "../../docs");
25574
+ const docsDir = path21.join(providerDir, "../../docs");
25513
25575
  const loadGuide = (name) => {
25514
25576
  try {
25515
- const p = path20.join(docsDir, name);
25516
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
25577
+ const p = path21.join(docsDir, name);
25578
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
25517
25579
  } catch {
25518
25580
  }
25519
25581
  return null;
@@ -25959,8 +26021,8 @@ var DevServer = class _DevServer {
25959
26021
  }
25960
26022
  getEndpointList() {
25961
26023
  return this.routes.map((r) => {
25962
- const path22 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
25963
- return `${r.method.padEnd(5)} ${path22}`;
26024
+ const path23 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
26025
+ return `${r.method.padEnd(5)} ${path23}`;
25964
26026
  });
25965
26027
  }
25966
26028
  async start(port = DEV_SERVER_PORT) {
@@ -26248,12 +26310,12 @@ var DevServer = class _DevServer {
26248
26310
  // ─── DevConsole SPA ───
26249
26311
  getConsoleDistDir() {
26250
26312
  const candidates = [
26251
- path21.resolve(__dirname, "../../web-devconsole/dist"),
26252
- path21.resolve(__dirname, "../../../web-devconsole/dist"),
26253
- path21.join(process.cwd(), "packages/web-devconsole/dist")
26313
+ path22.resolve(__dirname, "../../web-devconsole/dist"),
26314
+ path22.resolve(__dirname, "../../../web-devconsole/dist"),
26315
+ path22.join(process.cwd(), "packages/web-devconsole/dist")
26254
26316
  ];
26255
26317
  for (const dir of candidates) {
26256
- if (fs14.existsSync(path21.join(dir, "index.html"))) return dir;
26318
+ if (fs15.existsSync(path22.join(dir, "index.html"))) return dir;
26257
26319
  }
26258
26320
  return null;
26259
26321
  }
@@ -26263,9 +26325,9 @@ var DevServer = class _DevServer {
26263
26325
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
26264
26326
  return;
26265
26327
  }
26266
- const htmlPath = path21.join(distDir, "index.html");
26328
+ const htmlPath = path22.join(distDir, "index.html");
26267
26329
  try {
26268
- const html = fs14.readFileSync(htmlPath, "utf-8");
26330
+ const html = fs15.readFileSync(htmlPath, "utf-8");
26269
26331
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
26270
26332
  res.end(html);
26271
26333
  } catch (e) {
@@ -26288,15 +26350,15 @@ var DevServer = class _DevServer {
26288
26350
  this.json(res, 404, { error: "Not found" });
26289
26351
  return;
26290
26352
  }
26291
- const safePath = path21.normalize(pathname).replace(/^\.\.\//, "");
26292
- const filePath = path21.join(distDir, safePath);
26353
+ const safePath = path22.normalize(pathname).replace(/^\.\.\//, "");
26354
+ const filePath = path22.join(distDir, safePath);
26293
26355
  if (!filePath.startsWith(distDir)) {
26294
26356
  this.json(res, 403, { error: "Forbidden" });
26295
26357
  return;
26296
26358
  }
26297
26359
  try {
26298
- const content = fs14.readFileSync(filePath);
26299
- const ext = path21.extname(filePath);
26360
+ const content = fs15.readFileSync(filePath);
26361
+ const ext = path22.extname(filePath);
26300
26362
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
26301
26363
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
26302
26364
  res.end(content);
@@ -26404,14 +26466,14 @@ var DevServer = class _DevServer {
26404
26466
  const files = [];
26405
26467
  const scan = (d, prefix) => {
26406
26468
  try {
26407
- for (const entry of fs14.readdirSync(d, { withFileTypes: true })) {
26469
+ for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
26408
26470
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
26409
26471
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
26410
26472
  if (entry.isDirectory()) {
26411
26473
  files.push({ path: rel, size: 0, type: "dir" });
26412
- scan(path21.join(d, entry.name), rel);
26474
+ scan(path22.join(d, entry.name), rel);
26413
26475
  } else {
26414
- const stat = fs14.statSync(path21.join(d, entry.name));
26476
+ const stat = fs15.statSync(path22.join(d, entry.name));
26415
26477
  files.push({ path: rel, size: stat.size, type: "file" });
26416
26478
  }
26417
26479
  }
@@ -26434,16 +26496,16 @@ var DevServer = class _DevServer {
26434
26496
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
26435
26497
  return;
26436
26498
  }
26437
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
26499
+ const fullPath = path22.resolve(dir, path22.normalize(filePath));
26438
26500
  if (!fullPath.startsWith(dir)) {
26439
26501
  this.json(res, 403, { error: "Forbidden" });
26440
26502
  return;
26441
26503
  }
26442
- if (!fs14.existsSync(fullPath) || fs14.statSync(fullPath).isDirectory()) {
26504
+ if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
26443
26505
  this.json(res, 404, { error: `File not found: ${filePath}` });
26444
26506
  return;
26445
26507
  }
26446
- const content = fs14.readFileSync(fullPath, "utf-8");
26508
+ const content = fs15.readFileSync(fullPath, "utf-8");
26447
26509
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
26448
26510
  }
26449
26511
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -26459,15 +26521,15 @@ var DevServer = class _DevServer {
26459
26521
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
26460
26522
  return;
26461
26523
  }
26462
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
26524
+ const fullPath = path22.resolve(dir, path22.normalize(filePath));
26463
26525
  if (!fullPath.startsWith(dir)) {
26464
26526
  this.json(res, 403, { error: "Forbidden" });
26465
26527
  return;
26466
26528
  }
26467
26529
  try {
26468
- if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
26469
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
26470
- fs14.writeFileSync(fullPath, content, "utf-8");
26530
+ if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
26531
+ fs15.mkdirSync(path22.dirname(fullPath), { recursive: true });
26532
+ fs15.writeFileSync(fullPath, content, "utf-8");
26471
26533
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
26472
26534
  this.providerLoader.reload();
26473
26535
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -26483,9 +26545,9 @@ var DevServer = class _DevServer {
26483
26545
  return;
26484
26546
  }
26485
26547
  for (const name of ["scripts.js", "provider.json"]) {
26486
- const p = path21.join(dir, name);
26487
- if (fs14.existsSync(p)) {
26488
- const source = fs14.readFileSync(p, "utf-8");
26548
+ const p = path22.join(dir, name);
26549
+ if (fs15.existsSync(p)) {
26550
+ const source = fs15.readFileSync(p, "utf-8");
26489
26551
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
26490
26552
  return;
26491
26553
  }
@@ -26504,11 +26566,11 @@ var DevServer = class _DevServer {
26504
26566
  this.json(res, 404, { error: `Provider not found: ${type}` });
26505
26567
  return;
26506
26568
  }
26507
- const target = fs14.existsSync(path21.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
26508
- const targetPath = path21.join(dir, target);
26569
+ const target = fs15.existsSync(path22.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
26570
+ const targetPath = path22.join(dir, target);
26509
26571
  try {
26510
- if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
26511
- fs14.writeFileSync(targetPath, source, "utf-8");
26572
+ if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
26573
+ fs15.writeFileSync(targetPath, source, "utf-8");
26512
26574
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
26513
26575
  this.providerLoader.reload();
26514
26576
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -26652,21 +26714,21 @@ var DevServer = class _DevServer {
26652
26714
  }
26653
26715
  let targetDir;
26654
26716
  targetDir = this.providerLoader.getUserProviderDir(category, type);
26655
- const jsonPath = path21.join(targetDir, "provider.json");
26656
- if (fs14.existsSync(jsonPath)) {
26717
+ const jsonPath = path22.join(targetDir, "provider.json");
26718
+ if (fs15.existsSync(jsonPath)) {
26657
26719
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
26658
26720
  return;
26659
26721
  }
26660
26722
  try {
26661
26723
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
26662
- fs14.mkdirSync(targetDir, { recursive: true });
26663
- fs14.writeFileSync(jsonPath, result["provider.json"], "utf-8");
26724
+ fs15.mkdirSync(targetDir, { recursive: true });
26725
+ fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
26664
26726
  const createdFiles = ["provider.json"];
26665
26727
  if (result.files) {
26666
26728
  for (const [relPath, content] of Object.entries(result.files)) {
26667
- const fullPath = path21.join(targetDir, relPath);
26668
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
26669
- fs14.writeFileSync(fullPath, content, "utf-8");
26729
+ const fullPath = path22.join(targetDir, relPath);
26730
+ fs15.mkdirSync(path22.dirname(fullPath), { recursive: true });
26731
+ fs15.writeFileSync(fullPath, content, "utf-8");
26670
26732
  createdFiles.push(relPath);
26671
26733
  }
26672
26734
  }
@@ -26715,38 +26777,38 @@ var DevServer = class _DevServer {
26715
26777
  }
26716
26778
  // ─── Phase 2: Auto-Implement Backend ───
26717
26779
  getLatestScriptVersionDir(scriptsDir) {
26718
- if (!fs14.existsSync(scriptsDir)) return null;
26719
- const versions = fs14.readdirSync(scriptsDir).filter((d) => {
26780
+ if (!fs15.existsSync(scriptsDir)) return null;
26781
+ const versions = fs15.readdirSync(scriptsDir).filter((d) => {
26720
26782
  try {
26721
- return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
26783
+ return fs15.statSync(path22.join(scriptsDir, d)).isDirectory();
26722
26784
  } catch {
26723
26785
  return false;
26724
26786
  }
26725
26787
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
26726
26788
  if (versions.length === 0) return null;
26727
- return path21.join(scriptsDir, versions[0]);
26789
+ return path22.join(scriptsDir, versions[0]);
26728
26790
  }
26729
26791
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
26730
- const canonicalUserDir = path21.resolve(this.providerLoader.getUserProviderDir(category, type));
26731
- const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
26732
- const upstreamRoot = path21.resolve(this.providerLoader.getUpstreamDir());
26733
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
26792
+ const canonicalUserDir = path22.resolve(this.providerLoader.getUserProviderDir(category, type));
26793
+ const desiredDir = requestedDir ? path22.resolve(requestedDir) : canonicalUserDir;
26794
+ const upstreamRoot = path22.resolve(this.providerLoader.getUpstreamDir());
26795
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path22.sep}`)) {
26734
26796
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
26735
26797
  }
26736
- if (path21.basename(desiredDir) !== type) {
26798
+ if (path22.basename(desiredDir) !== type) {
26737
26799
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
26738
26800
  }
26739
26801
  const sourceDir = this.findProviderDir(type);
26740
26802
  if (!sourceDir) {
26741
26803
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
26742
26804
  }
26743
- if (!fs14.existsSync(desiredDir)) {
26744
- fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
26745
- fs14.cpSync(sourceDir, desiredDir, { recursive: true });
26805
+ if (!fs15.existsSync(desiredDir)) {
26806
+ fs15.mkdirSync(path22.dirname(desiredDir), { recursive: true });
26807
+ fs15.cpSync(sourceDir, desiredDir, { recursive: true });
26746
26808
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
26747
26809
  }
26748
- const providerJson = path21.join(desiredDir, "provider.json");
26749
- if (!fs14.existsSync(providerJson)) {
26810
+ const providerJson = path22.join(desiredDir, "provider.json");
26811
+ if (!fs15.existsSync(providerJson)) {
26750
26812
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
26751
26813
  }
26752
26814
  return { dir: desiredDir };
@@ -26781,7 +26843,7 @@ var DevServer = class _DevServer {
26781
26843
  setMode: "set_mode.js"
26782
26844
  };
26783
26845
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
26784
- const scriptsDir = path21.join(providerDir, "scripts");
26846
+ const scriptsDir = path22.join(providerDir, "scripts");
26785
26847
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
26786
26848
  if (latestScriptsDir) {
26787
26849
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -26789,10 +26851,10 @@ var DevServer = class _DevServer {
26789
26851
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
26790
26852
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
26791
26853
  lines.push("");
26792
- for (const file of fs14.readdirSync(latestScriptsDir)) {
26854
+ for (const file of fs15.readdirSync(latestScriptsDir)) {
26793
26855
  if (file.endsWith(".js") && targetFileNames.has(file)) {
26794
26856
  try {
26795
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26857
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26796
26858
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
26797
26859
  lines.push("```javascript");
26798
26860
  lines.push(content);
@@ -26802,14 +26864,14 @@ var DevServer = class _DevServer {
26802
26864
  }
26803
26865
  }
26804
26866
  }
26805
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26867
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26806
26868
  if (refFiles.length > 0) {
26807
26869
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
26808
26870
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
26809
26871
  lines.push("");
26810
26872
  for (const file of refFiles) {
26811
26873
  try {
26812
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26874
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26813
26875
  lines.push(`### \`${file}\` \u{1F512}`);
26814
26876
  lines.push("```javascript");
26815
26877
  lines.push(content);
@@ -26850,11 +26912,11 @@ var DevServer = class _DevServer {
26850
26912
  lines.push("");
26851
26913
  }
26852
26914
  }
26853
- const docsDir = path21.join(providerDir, "../../docs");
26915
+ const docsDir = path22.join(providerDir, "../../docs");
26854
26916
  const loadGuide = (name) => {
26855
26917
  try {
26856
- const p = path21.join(docsDir, name);
26857
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
26918
+ const p = path22.join(docsDir, name);
26919
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
26858
26920
  } catch {
26859
26921
  }
26860
26922
  return null;
@@ -27027,7 +27089,7 @@ var DevServer = class _DevServer {
27027
27089
  parseApproval: "parse_approval.js"
27028
27090
  };
27029
27091
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
27030
- const scriptsDir = path21.join(providerDir, "scripts");
27092
+ const scriptsDir = path22.join(providerDir, "scripts");
27031
27093
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
27032
27094
  if (latestScriptsDir) {
27033
27095
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -27035,11 +27097,11 @@ var DevServer = class _DevServer {
27035
27097
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
27036
27098
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
27037
27099
  lines.push("");
27038
- for (const file of fs14.readdirSync(latestScriptsDir)) {
27100
+ for (const file of fs15.readdirSync(latestScriptsDir)) {
27039
27101
  if (!file.endsWith(".js")) continue;
27040
27102
  if (!targetFileNames.has(file)) continue;
27041
27103
  try {
27042
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
27104
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
27043
27105
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
27044
27106
  lines.push("```javascript");
27045
27107
  lines.push(content);
@@ -27048,14 +27110,14 @@ var DevServer = class _DevServer {
27048
27110
  } catch {
27049
27111
  }
27050
27112
  }
27051
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
27113
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
27052
27114
  if (refFiles.length > 0) {
27053
27115
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
27054
27116
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
27055
27117
  lines.push("");
27056
27118
  for (const file of refFiles) {
27057
27119
  try {
27058
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
27120
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
27059
27121
  lines.push(`### \`${file}\` \u{1F512}`);
27060
27122
  lines.push("```javascript");
27061
27123
  lines.push(content);
@@ -27088,11 +27150,11 @@ var DevServer = class _DevServer {
27088
27150
  lines.push("");
27089
27151
  }
27090
27152
  }
27091
- const docsDir = path21.join(providerDir, "../../docs");
27153
+ const docsDir = path22.join(providerDir, "../../docs");
27092
27154
  const loadGuide = (name) => {
27093
27155
  try {
27094
- const p = path21.join(docsDir, name);
27095
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
27156
+ const p = path22.join(docsDir, name);
27157
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
27096
27158
  } catch {
27097
27159
  }
27098
27160
  return null;
@@ -27967,8 +28029,8 @@ async function installExtension(ide, extension) {
27967
28029
  const res = await fetch(extension.vsixUrl);
27968
28030
  if (res.ok) {
27969
28031
  const buffer = Buffer.from(await res.arrayBuffer());
27970
- const fs15 = await import("fs");
27971
- fs15.writeFileSync(vsixPath, buffer);
28032
+ const fs16 = await import("fs");
28033
+ fs16.writeFileSync(vsixPath, buffer);
27972
28034
  return new Promise((resolve12) => {
27973
28035
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
27974
28036
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {