@adhdev/daemon-core 0.9.50 → 0.9.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1328,7 +1328,7 @@ var init_spawn_env = __esm({
1328
1328
  });
1329
1329
 
1330
1330
  // src/cli-adapters/pty-transport.ts
1331
- import * as os7 from "os";
1331
+ import * as os8 from "os";
1332
1332
  function loadNodePty() {
1333
1333
  if (cachedPty !== void 0) return cachedPty;
1334
1334
  try {
@@ -1379,11 +1379,11 @@ var init_pty_transport = __esm({
1379
1379
  let cwd = options.cwd;
1380
1380
  if (cwd) {
1381
1381
  try {
1382
- const fs15 = __require("fs");
1383
- const stat = fs15.statSync(cwd);
1384
- if (!stat.isDirectory()) cwd = os7.homedir();
1382
+ const fs16 = __require("fs");
1383
+ const stat = fs16.statSync(cwd);
1384
+ if (!stat.isDirectory()) cwd = os8.homedir();
1385
1385
  } catch {
1386
- cwd = os7.homedir();
1386
+ cwd = os8.homedir();
1387
1387
  }
1388
1388
  }
1389
1389
  const handle = pty.spawn(command, args, {
@@ -1400,8 +1400,8 @@ var init_pty_transport = __esm({
1400
1400
  });
1401
1401
 
1402
1402
  // src/cli-adapters/provider-cli-shared.ts
1403
- import * as os8 from "os";
1404
- import * as path9 from "path";
1403
+ import * as os9 from "os";
1404
+ import * as path10 from "path";
1405
1405
  import { execSync as execSync3 } from "child_process";
1406
1406
  function stripAnsi(str) {
1407
1407
  return str.replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][\s\S]*?\x1B\\/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/ +/g, " ");
@@ -1466,11 +1466,11 @@ function buildCliScreenSnapshot(text) {
1466
1466
  function findBinary(name) {
1467
1467
  const trimmed = String(name || "").trim();
1468
1468
  if (!trimmed) return trimmed;
1469
- const expanded = trimmed.startsWith("~") ? path9.join(os8.homedir(), trimmed.slice(1)) : trimmed;
1470
- if (path9.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
1471
- return path9.isAbsolute(expanded) ? expanded : path9.resolve(expanded);
1469
+ const expanded = trimmed.startsWith("~") ? path10.join(os9.homedir(), trimmed.slice(1)) : trimmed;
1470
+ if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
1471
+ return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
1472
1472
  }
1473
- const isWin = os8.platform() === "win32";
1473
+ const isWin = os9.platform() === "win32";
1474
1474
  try {
1475
1475
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
1476
1476
  return execSync3(cmd, {
@@ -1484,14 +1484,14 @@ function findBinary(name) {
1484
1484
  }
1485
1485
  }
1486
1486
  function isScriptBinary(binaryPath) {
1487
- if (!path9.isAbsolute(binaryPath)) return false;
1487
+ if (!path10.isAbsolute(binaryPath)) return false;
1488
1488
  try {
1489
- const fs15 = __require("fs");
1490
- const resolved = fs15.realpathSync(binaryPath);
1489
+ const fs16 = __require("fs");
1490
+ const resolved = fs16.realpathSync(binaryPath);
1491
1491
  const head = Buffer.alloc(8);
1492
- const fd = fs15.openSync(resolved, "r");
1493
- fs15.readSync(fd, head, 0, 8, 0);
1494
- fs15.closeSync(fd);
1492
+ const fd = fs16.openSync(resolved, "r");
1493
+ fs16.readSync(fd, head, 0, 8, 0);
1494
+ fs16.closeSync(fd);
1495
1495
  let i = 0;
1496
1496
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
1497
1497
  return head[i] === 35 && head[i + 1] === 33;
@@ -1500,14 +1500,14 @@ function isScriptBinary(binaryPath) {
1500
1500
  }
1501
1501
  }
1502
1502
  function looksLikeMachOOrElf(filePath) {
1503
- if (!path9.isAbsolute(filePath)) return false;
1503
+ if (!path10.isAbsolute(filePath)) return false;
1504
1504
  try {
1505
- const fs15 = __require("fs");
1506
- const resolved = fs15.realpathSync(filePath);
1505
+ const fs16 = __require("fs");
1506
+ const resolved = fs16.realpathSync(filePath);
1507
1507
  const buf = Buffer.alloc(8);
1508
- const fd = fs15.openSync(resolved, "r");
1509
- fs15.readSync(fd, buf, 0, 8, 0);
1510
- fs15.closeSync(fd);
1508
+ const fd = fs16.openSync(resolved, "r");
1509
+ fs16.readSync(fd, buf, 0, 8, 0);
1510
+ fs16.closeSync(fd);
1511
1511
  let i = 0;
1512
1512
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
1513
1513
  const b = buf.subarray(i);
@@ -1523,7 +1523,7 @@ function looksLikeMachOOrElf(filePath) {
1523
1523
  }
1524
1524
  function shSingleQuote(arg) {
1525
1525
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
1526
- if (os8.platform() === "win32") {
1526
+ if (os9.platform() === "win32") {
1527
1527
  return `"${arg.replace(/"/g, '""')}"`;
1528
1528
  }
1529
1529
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -1960,21 +1960,21 @@ var init_provider_cli_config = __esm({
1960
1960
  });
1961
1961
 
1962
1962
  // src/cli-adapters/provider-cli-runtime.ts
1963
- import * as os9 from "os";
1964
- import * as path10 from "path";
1963
+ import * as os10 from "os";
1964
+ import * as path11 from "path";
1965
1965
  import { DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS } from "@adhdev/session-host-core";
1966
1966
  function resolveCliSpawnPlan(options) {
1967
1967
  const { provider, runtimeSettings, workingDir, extraArgs } = options;
1968
1968
  const { spawn: spawnConfig } = provider;
1969
1969
  const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
1970
1970
  const binaryPath = findBinary(configuredCommand);
1971
- const isWin = os9.platform() === "win32";
1971
+ const isWin = os10.platform() === "win32";
1972
1972
  const allArgs = [...spawnConfig.args, ...extraArgs];
1973
1973
  let shellCmd;
1974
1974
  let shellArgs;
1975
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
1975
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
1976
1976
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
1977
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
1977
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
1978
1978
  const useShell = isWin ? useShellWin : useShellUnix;
1979
1979
  if (useShell) {
1980
1980
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -2066,7 +2066,7 @@ __export(provider_cli_adapter_exports, {
2066
2066
  sanitizeCliStandardMessageContent: () => sanitizeCliStandardMessageContent,
2067
2067
  trimLastAssistantEchoForCliMessages: () => trimLastAssistantEchoForCliMessages
2068
2068
  });
2069
- import * as os10 from "os";
2069
+ import * as os11 from "os";
2070
2070
  function normalizeComparableTranscriptText(value) {
2071
2071
  return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
2072
2072
  }
@@ -2197,7 +2197,7 @@ var init_provider_cli_adapter = __esm({
2197
2197
  this.transportFactory = transportFactory;
2198
2198
  this.cliType = provider.type;
2199
2199
  this.cliName = provider.name;
2200
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os10.homedir()) : workingDir;
2200
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os11.homedir()) : workingDir;
2201
2201
  const resolvedConfig = resolveCliAdapterConfig(provider);
2202
2202
  this.timeouts = resolvedConfig.timeouts;
2203
2203
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -5120,17 +5120,17 @@ function checkPathExists(paths) {
5120
5120
  return null;
5121
5121
  }
5122
5122
  async function detectIDEs(providerLoader) {
5123
- const os20 = platform();
5123
+ const os21 = platform();
5124
5124
  const results = [];
5125
5125
  for (const def of getMergedDefinitions()) {
5126
5126
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
5127
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os20] || []) || []);
5127
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os21] || []) || []);
5128
5128
  let resolvedCli = cliPath;
5129
- if (!resolvedCli && appPath && os20 === "darwin") {
5129
+ if (!resolvedCli && appPath && os21 === "darwin") {
5130
5130
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
5131
5131
  if (existsSync4(bundledCli)) resolvedCli = bundledCli;
5132
5132
  }
5133
- if (!resolvedCli && appPath && os20 === "win32") {
5133
+ if (!resolvedCli && appPath && os21 === "win32") {
5134
5134
  const { dirname: dirname7 } = await import("path");
5135
5135
  const appDir = dirname7(appPath);
5136
5136
  const candidates = [
@@ -5147,7 +5147,7 @@ async function detectIDEs(providerLoader) {
5147
5147
  }
5148
5148
  }
5149
5149
  }
5150
- const installed = os20 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
5150
+ const installed = os21 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
5151
5151
  const version = resolvedCli ? getIdeVersion(resolvedCli) : null;
5152
5152
  results.push({
5153
5153
  id: def.id,
@@ -10312,6 +10312,10 @@ function resolveLegacyProviderScript(fn, scriptName, params) {
10312
10312
 
10313
10313
  // src/commands/chat-commands.ts
10314
10314
  init_contracts();
10315
+ import * as fs4 from "fs";
10316
+ import * as os6 from "os";
10317
+ import * as path8 from "path";
10318
+ import { randomUUID as randomUUID4 } from "crypto";
10315
10319
 
10316
10320
  // src/providers/provider-input-support.ts
10317
10321
  var VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
@@ -11000,6 +11004,50 @@ function buildDebugBundleText(bundle) {
11000
11004
  "```"
11001
11005
  ].join("\n");
11002
11006
  }
11007
+ function getChatDebugBundleDir() {
11008
+ const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
11009
+ return override || path8.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
11010
+ }
11011
+ function safeBundleIdSegment(value, fallback) {
11012
+ const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
11013
+ return normalized || fallback;
11014
+ }
11015
+ function createChatDebugBundleId(targetSessionId) {
11016
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
11017
+ const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
11018
+ return `chat-debug-${timestamp}-${sessionSegment}-${randomUUID4().slice(0, 8)}`;
11019
+ }
11020
+ function buildChatDebugBundleSummary(bundle) {
11021
+ const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
11022
+ const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
11023
+ const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
11024
+ const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
11025
+ return {
11026
+ createdAt: bundle.createdAt,
11027
+ targetSessionId: target.targetSessionId,
11028
+ providerType: target.providerType,
11029
+ transport: target.transport,
11030
+ readChatSuccess: readChat.success,
11031
+ readChatStatus: readChat.status,
11032
+ readChatTotalMessages: readChat.totalMessages,
11033
+ cliStatus: cli?.status,
11034
+ cliMessageCount: cli?.messageCount,
11035
+ hasFrontendSnapshot: !!frontend
11036
+ };
11037
+ }
11038
+ function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
11039
+ const bundleId = createChatDebugBundleId(targetSessionId);
11040
+ const dir = getChatDebugBundleDir();
11041
+ fs4.mkdirSync(dir, { recursive: true });
11042
+ const savedPath = path8.join(dir, `${bundleId}.json`);
11043
+ const json = `${JSON.stringify(bundle, null, 2)}
11044
+ `;
11045
+ fs4.writeFileSync(savedPath, json, { encoding: "utf8", mode: 384 });
11046
+ return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json, "utf8") };
11047
+ }
11048
+ function isDaemonFileDebugDelivery(args) {
11049
+ return args?.delivery === "daemon_file" || args?.delivery === "file";
11050
+ }
11003
11051
  async function handleGetChatDebugBundle(h, args) {
11004
11052
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
11005
11053
  if (!targetSessionId && !h.currentSession) {
@@ -11111,6 +11159,20 @@ async function handleGetChatDebugBundle(h, args) {
11111
11159
  recentDebugTrace: getRecentDebugTrace({ limit: 120 })
11112
11160
  };
11113
11161
  const bundle = sanitizeDebugBundleValue(rawBundle);
11162
+ if (isDaemonFileDebugDelivery(args)) {
11163
+ const summary = buildChatDebugBundleSummary(bundle);
11164
+ const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
11165
+ 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 || ""}`);
11166
+ return {
11167
+ success: true,
11168
+ delivery: "daemon_file",
11169
+ bundleId: stored.bundleId,
11170
+ savedPath: stored.savedPath,
11171
+ sizeBytes: stored.sizeBytes,
11172
+ createdAt: bundle.createdAt,
11173
+ summary
11174
+ };
11175
+ }
11114
11176
  return {
11115
11177
  success: true,
11116
11178
  bundle,
@@ -12092,9 +12154,9 @@ async function handleResolveAction(h, args) {
12092
12154
  }
12093
12155
 
12094
12156
  // src/commands/cdp-commands.ts
12095
- import * as fs4 from "fs";
12096
- import * as path8 from "path";
12097
- import * as os6 from "os";
12157
+ import * as fs5 from "fs";
12158
+ import * as path9 from "path";
12159
+ import * as os7 from "os";
12098
12160
  var KEY_TO_VK = {
12099
12161
  Backspace: 8,
12100
12162
  Tab: 9,
@@ -12348,27 +12410,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
12348
12410
  function resolveSafePath(requestedPath) {
12349
12411
  const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
12350
12412
  const inputPath = rawPath || ".";
12351
- const home = os6.homedir();
12413
+ const home = os7.homedir();
12352
12414
  if (inputPath.startsWith("~")) {
12353
- return path8.resolve(path8.join(home, inputPath.slice(1)));
12415
+ return path9.resolve(path9.join(home, inputPath.slice(1)));
12354
12416
  }
12355
12417
  if (process.platform === "win32") {
12356
12418
  const normalized = normalizeWindowsRequestedPath(inputPath);
12357
- if (path8.win32.isAbsolute(normalized)) {
12358
- return path8.win32.normalize(normalized);
12419
+ if (path9.win32.isAbsolute(normalized)) {
12420
+ return path9.win32.normalize(normalized);
12359
12421
  }
12360
- return path8.win32.resolve(normalized);
12422
+ return path9.win32.resolve(normalized);
12361
12423
  }
12362
- if (path8.isAbsolute(inputPath)) {
12363
- return path8.normalize(inputPath);
12424
+ if (path9.isAbsolute(inputPath)) {
12425
+ return path9.normalize(inputPath);
12364
12426
  }
12365
- return path8.resolve(inputPath);
12427
+ return path9.resolve(inputPath);
12366
12428
  }
12367
12429
  function listDirectoryEntriesSafe(dirPath) {
12368
- const entries = fs4.readdirSync(dirPath, { withFileTypes: true });
12430
+ const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
12369
12431
  const files = [];
12370
12432
  for (const entry of entries) {
12371
- const entryPath = path8.join(dirPath, entry.name);
12433
+ const entryPath = path9.join(dirPath, entry.name);
12372
12434
  try {
12373
12435
  if (entry.isDirectory()) {
12374
12436
  files.push({ name: entry.name, type: "directory" });
@@ -12377,14 +12439,14 @@ function listDirectoryEntriesSafe(dirPath) {
12377
12439
  if (entry.isFile()) {
12378
12440
  let size;
12379
12441
  try {
12380
- size = fs4.statSync(entryPath).size;
12442
+ size = fs5.statSync(entryPath).size;
12381
12443
  } catch {
12382
12444
  size = void 0;
12383
12445
  }
12384
12446
  files.push({ name: entry.name, type: "file", size });
12385
12447
  continue;
12386
12448
  }
12387
- const stat = fs4.statSync(entryPath);
12449
+ const stat = fs5.statSync(entryPath);
12388
12450
  files.push({
12389
12451
  name: entry.name,
12390
12452
  type: stat.isDirectory() ? "directory" : "file",
@@ -12402,7 +12464,7 @@ function listWindowsDriveEntries(excludePath) {
12402
12464
  const letter = String.fromCharCode(code);
12403
12465
  const root = `${letter}:\\`;
12404
12466
  try {
12405
- if (!fs4.existsSync(root)) continue;
12467
+ if (!fs5.existsSync(root)) continue;
12406
12468
  if (excluded && root.toLowerCase() === excluded) continue;
12407
12469
  drives.push({ name: `${letter}:`, type: "directory", path: root });
12408
12470
  } catch {
@@ -12413,7 +12475,7 @@ function listWindowsDriveEntries(excludePath) {
12413
12475
  async function handleFileRead(h, args) {
12414
12476
  try {
12415
12477
  const filePath = resolveSafePath(args?.path);
12416
- const content = fs4.readFileSync(filePath, "utf-8");
12478
+ const content = fs5.readFileSync(filePath, "utf-8");
12417
12479
  return { success: true, content, path: filePath };
12418
12480
  } catch (e) {
12419
12481
  return { success: false, error: e.message };
@@ -12422,8 +12484,8 @@ async function handleFileRead(h, args) {
12422
12484
  async function handleFileWrite(h, args) {
12423
12485
  try {
12424
12486
  const filePath = resolveSafePath(args?.path);
12425
- fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
12426
- fs4.writeFileSync(filePath, args?.content || "", "utf-8");
12487
+ fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
12488
+ fs5.writeFileSync(filePath, args?.content || "", "utf-8");
12427
12489
  return { success: true, path: filePath };
12428
12490
  } catch (e) {
12429
12491
  return { success: false, error: e.message };
@@ -12656,12 +12718,13 @@ async function handleSetProviderSourceConfig(h, args) {
12656
12718
  });
12657
12719
  loader.reload();
12658
12720
  loader.registerToDetector();
12721
+ const refreshedInstances = h.ctx.instanceManager ? h.ctx.instanceManager.refreshProviderDefinitions((providerType) => loader.resolve(providerType)) : 0;
12659
12722
  await h.ctx.onProviderSourceConfigChanged?.();
12660
12723
  LOG.info(
12661
12724
  "Command",
12662
12725
  `[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
12663
12726
  );
12664
- return { success: true, reloaded: true, ...sourceConfig };
12727
+ return { success: true, reloaded: true, refreshedInstances, ...sourceConfig };
12665
12728
  }
12666
12729
  function normalizeProviderScriptArgs(args, scriptName) {
12667
12730
  const normalizedArgs = { ...args || {} };
@@ -13525,8 +13588,8 @@ var DaemonCommandHandler = class {
13525
13588
 
13526
13589
  // src/commands/cli-manager.ts
13527
13590
  init_provider_cli_adapter();
13528
- import * as os12 from "os";
13529
- import * as path12 from "path";
13591
+ import * as os13 from "os";
13592
+ import * as path13 from "path";
13530
13593
  import * as crypto4 from "crypto";
13531
13594
  import { existsSync as existsSync10 } from "fs";
13532
13595
  import { execFileSync } from "child_process";
@@ -13535,10 +13598,10 @@ init_config();
13535
13598
 
13536
13599
  // src/providers/cli-provider-instance.ts
13537
13600
  init_contracts();
13538
- import * as os11 from "os";
13539
- import * as path11 from "path";
13601
+ import * as os12 from "os";
13602
+ import * as path12 from "path";
13540
13603
  import * as crypto3 from "crypto";
13541
- import * as fs5 from "fs";
13604
+ import * as fs6 from "fs";
13542
13605
  import { createRequire } from "module";
13543
13606
  init_provider_cli_adapter();
13544
13607
  init_logger();
@@ -13596,7 +13659,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
13596
13659
  var CachedDatabaseSync = null;
13597
13660
  function getDatabaseSync() {
13598
13661
  if (CachedDatabaseSync) return CachedDatabaseSync;
13599
- const requireFn = typeof __require === "function" ? __require : createRequire(path11.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
13662
+ const requireFn = typeof __require === "function" ? __require : createRequire(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
13600
13663
  const sqliteModule = requireFn(`node:${"sqlite"}`);
13601
13664
  CachedDatabaseSync = sqliteModule.DatabaseSync;
13602
13665
  if (!CachedDatabaseSync) {
@@ -13746,10 +13809,10 @@ var CliProviderInstance = class {
13746
13809
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
13747
13810
  */
13748
13811
  probeSessionIdFromConfig(probe) {
13749
- const resolvedDbPath = probe.dbPath.replace(/^~/, os11.homedir());
13812
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os12.homedir());
13750
13813
  const now = Date.now();
13751
13814
  if (this.cachedSqliteDbMissingUntil > now) return null;
13752
- if (!fs5.existsSync(resolvedDbPath)) {
13815
+ if (!fs6.existsSync(resolvedDbPath)) {
13753
13816
  this.cachedSqliteDbMissingUntil = now + 1e4;
13754
13817
  return null;
13755
13818
  }
@@ -14481,7 +14544,7 @@ ${effect.notification.body || ""}`.trim();
14481
14544
  };
14482
14545
  addDir(this.workingDir);
14483
14546
  try {
14484
- addDir(fs5.realpathSync.native(this.workingDir));
14547
+ addDir(fs6.realpathSync.native(this.workingDir));
14485
14548
  } catch {
14486
14549
  }
14487
14550
  return Array.from(dirs);
@@ -15685,11 +15748,11 @@ function shouldRestoreHostedRuntime(record, managerTag) {
15685
15748
  // src/commands/cli-manager.ts
15686
15749
  function isExplicitCommand(command) {
15687
15750
  const trimmed = command.trim();
15688
- return path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
15751
+ return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
15689
15752
  }
15690
15753
  function expandExecutable(command) {
15691
15754
  const trimmed = command.trim();
15692
- return trimmed.startsWith("~") ? path12.join(os12.homedir(), trimmed.slice(1)) : trimmed;
15755
+ return trimmed.startsWith("~") ? path13.join(os13.homedir(), trimmed.slice(1)) : trimmed;
15693
15756
  }
15694
15757
  function commandExists(command) {
15695
15758
  const trimmed = command.trim();
@@ -15970,7 +16033,7 @@ var DaemonCliManager = class {
15970
16033
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
15971
16034
  const trimmed = (workingDir || "").trim();
15972
16035
  if (!trimmed) throw new Error("working directory required");
15973
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os12.homedir()) : path12.resolve(trimmed);
16036
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path13.resolve(trimmed);
15974
16037
  const normalizedType = this.providerLoader.resolveAlias(cliType);
15975
16038
  const rawProvider = this.providerLoader.getByAlias(cliType);
15976
16039
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -16470,13 +16533,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
16470
16533
  // src/launch.ts
16471
16534
  import { execSync as execSync4, spawn as spawn2 } from "child_process";
16472
16535
  import * as net from "net";
16473
- import * as os14 from "os";
16474
- import * as path14 from "path";
16536
+ import * as os15 from "os";
16537
+ import * as path15 from "path";
16475
16538
 
16476
16539
  // src/providers/provider-loader.ts
16477
- import * as fs6 from "fs";
16478
- import * as path13 from "path";
16479
- import * as os13 from "os";
16540
+ import * as fs7 from "fs";
16541
+ import * as path14 from "path";
16542
+ import * as os14 from "os";
16480
16543
  import * as chokidar from "chokidar";
16481
16544
  init_logger();
16482
16545
 
@@ -16738,9 +16801,9 @@ var ProviderLoader = class _ProviderLoader {
16738
16801
  static siblingStderrLogged = /* @__PURE__ */ new Set();
16739
16802
  static looksLikeProviderRoot(candidate) {
16740
16803
  try {
16741
- if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
16804
+ if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
16742
16805
  return ["ide", "extension", "cli", "acp"].some(
16743
- (category) => fs6.existsSync(path13.join(candidate, category))
16806
+ (category) => fs7.existsSync(path14.join(candidate, category))
16744
16807
  );
16745
16808
  } catch {
16746
16809
  return false;
@@ -16748,20 +16811,20 @@ var ProviderLoader = class _ProviderLoader {
16748
16811
  }
16749
16812
  static hasProviderRootMarker(candidate) {
16750
16813
  try {
16751
- return fs6.existsSync(path13.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
16814
+ return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
16752
16815
  } catch {
16753
16816
  return false;
16754
16817
  }
16755
16818
  }
16756
16819
  detectDefaultUserDir() {
16757
- const fallback = path13.join(os13.homedir(), ".adhdev", "providers");
16820
+ const fallback = path14.join(os14.homedir(), ".adhdev", "providers");
16758
16821
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
16759
16822
  const visited = /* @__PURE__ */ new Set();
16760
16823
  for (const start of this.probeStarts) {
16761
- let current = path13.resolve(start);
16824
+ let current = path14.resolve(start);
16762
16825
  while (!visited.has(current)) {
16763
16826
  visited.add(current);
16764
- const siblingCandidate = path13.join(path13.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
16827
+ const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
16765
16828
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
16766
16829
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
16767
16830
  if (envOptIn || hasMarker) {
@@ -16783,7 +16846,7 @@ var ProviderLoader = class _ProviderLoader {
16783
16846
  return { path: siblingCandidate, source };
16784
16847
  }
16785
16848
  }
16786
- const parent = path13.dirname(current);
16849
+ const parent = path14.dirname(current);
16787
16850
  if (parent === current) break;
16788
16851
  current = parent;
16789
16852
  }
@@ -16793,11 +16856,11 @@ var ProviderLoader = class _ProviderLoader {
16793
16856
  constructor(options) {
16794
16857
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
16795
16858
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
16796
- this.defaultProvidersDir = path13.join(os13.homedir(), ".adhdev", "providers");
16859
+ this.defaultProvidersDir = path14.join(os14.homedir(), ".adhdev", "providers");
16797
16860
  const detected = this.detectDefaultUserDir();
16798
16861
  this.userDir = detected.path;
16799
16862
  this.userDirSource = detected.source;
16800
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
16863
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
16801
16864
  this.disableUpstream = false;
16802
16865
  this.applySourceConfig({
16803
16866
  userDir: options?.userDir,
@@ -16856,7 +16919,7 @@ var ProviderLoader = class _ProviderLoader {
16856
16919
  this.userDir = detected.path;
16857
16920
  this.userDirSource = detected.source;
16858
16921
  }
16859
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
16922
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
16860
16923
  this.disableUpstream = this.sourceMode === "no-upstream";
16861
16924
  if (this.explicitProviderDir) {
16862
16925
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -16870,7 +16933,7 @@ var ProviderLoader = class _ProviderLoader {
16870
16933
  * Canonical provider directory shape for a given root.
16871
16934
  */
16872
16935
  getProviderDir(root, category, type) {
16873
- return path13.join(root, category, type);
16936
+ return path14.join(root, category, type);
16874
16937
  }
16875
16938
  /**
16876
16939
  * Canonical user override directory for a provider.
@@ -16897,7 +16960,7 @@ var ProviderLoader = class _ProviderLoader {
16897
16960
  resolveProviderFile(type, ...segments) {
16898
16961
  const dir = this.findProviderDirInternal(type);
16899
16962
  if (!dir) return null;
16900
- return path13.join(dir, ...segments);
16963
+ return path14.join(dir, ...segments);
16901
16964
  }
16902
16965
  /**
16903
16966
  * Load all providers (3-tier priority)
@@ -16910,7 +16973,7 @@ var ProviderLoader = class _ProviderLoader {
16910
16973
  this.providers.clear();
16911
16974
  this.providerAvailability.clear();
16912
16975
  let upstreamCount = 0;
16913
- if (!this.disableUpstream && fs6.existsSync(this.upstreamDir)) {
16976
+ if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
16914
16977
  upstreamCount = this.loadDir(this.upstreamDir);
16915
16978
  if (upstreamCount > 0) {
16916
16979
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -16918,7 +16981,7 @@ var ProviderLoader = class _ProviderLoader {
16918
16981
  } else if (this.disableUpstream) {
16919
16982
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
16920
16983
  }
16921
- if (fs6.existsSync(this.userDir)) {
16984
+ if (fs7.existsSync(this.userDir)) {
16922
16985
  const userCount = this.loadDir(this.userDir, [".upstream"]);
16923
16986
  if (userCount > 0) {
16924
16987
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -16933,10 +16996,10 @@ var ProviderLoader = class _ProviderLoader {
16933
16996
  * Check if upstream directory exists and has providers.
16934
16997
  */
16935
16998
  hasUpstream() {
16936
- if (!fs6.existsSync(this.upstreamDir)) return false;
16999
+ if (!fs7.existsSync(this.upstreamDir)) return false;
16937
17000
  try {
16938
- return fs6.readdirSync(this.upstreamDir).some(
16939
- (d) => fs6.statSync(path13.join(this.upstreamDir, d)).isDirectory()
17001
+ return fs7.readdirSync(this.upstreamDir).some(
17002
+ (d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
16940
17003
  );
16941
17004
  } catch {
16942
17005
  return false;
@@ -17433,8 +17496,8 @@ var ProviderLoader = class _ProviderLoader {
17433
17496
  resolved._resolvedScriptDir = entry.scriptDir;
17434
17497
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
17435
17498
  if (providerDir) {
17436
- const fullDir = path13.join(providerDir, entry.scriptDir);
17437
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17499
+ const fullDir = path14.join(providerDir, entry.scriptDir);
17500
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17438
17501
  }
17439
17502
  matched = true;
17440
17503
  }
@@ -17449,8 +17512,8 @@ var ProviderLoader = class _ProviderLoader {
17449
17512
  resolved._resolvedScriptDir = base.defaultScriptDir;
17450
17513
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
17451
17514
  if (providerDir) {
17452
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
17453
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17515
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
17516
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17454
17517
  }
17455
17518
  }
17456
17519
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -17467,8 +17530,8 @@ var ProviderLoader = class _ProviderLoader {
17467
17530
  resolved._resolvedScriptDir = dirOverride;
17468
17531
  resolved._resolvedScriptsSource = `versions:${range}`;
17469
17532
  if (providerDir) {
17470
- const fullDir = path13.join(providerDir, dirOverride);
17471
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17533
+ const fullDir = path14.join(providerDir, dirOverride);
17534
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17472
17535
  }
17473
17536
  }
17474
17537
  } else if (override.scripts) {
@@ -17484,8 +17547,8 @@ var ProviderLoader = class _ProviderLoader {
17484
17547
  resolved._resolvedScriptDir = base.defaultScriptDir;
17485
17548
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
17486
17549
  if (providerDir) {
17487
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
17488
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
17550
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
17551
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
17489
17552
  }
17490
17553
  }
17491
17554
  }
@@ -17517,15 +17580,15 @@ var ProviderLoader = class _ProviderLoader {
17517
17580
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
17518
17581
  return null;
17519
17582
  }
17520
- const dir = path13.join(providerDir, scriptDir);
17521
- if (!fs6.existsSync(dir)) {
17583
+ const dir = path14.join(providerDir, scriptDir);
17584
+ if (!fs7.existsSync(dir)) {
17522
17585
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
17523
17586
  return null;
17524
17587
  }
17525
17588
  const cached = this.scriptsCache.get(dir);
17526
17589
  if (cached) return cached;
17527
- const scriptsJs = path13.join(dir, "scripts.js");
17528
- if (fs6.existsSync(scriptsJs)) {
17590
+ const scriptsJs = path14.join(dir, "scripts.js");
17591
+ if (fs7.existsSync(scriptsJs)) {
17529
17592
  try {
17530
17593
  delete __require.cache[__require.resolve(scriptsJs)];
17531
17594
  const loaded = __require(scriptsJs);
@@ -17546,9 +17609,9 @@ var ProviderLoader = class _ProviderLoader {
17546
17609
  watch() {
17547
17610
  this.stopWatch();
17548
17611
  const watchDir = (dir) => {
17549
- if (!fs6.existsSync(dir)) {
17612
+ if (!fs7.existsSync(dir)) {
17550
17613
  try {
17551
- fs6.mkdirSync(dir, { recursive: true });
17614
+ fs7.mkdirSync(dir, { recursive: true });
17552
17615
  } catch {
17553
17616
  return;
17554
17617
  }
@@ -17566,7 +17629,7 @@ var ProviderLoader = class _ProviderLoader {
17566
17629
  return;
17567
17630
  }
17568
17631
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
17569
- this.log(`File changed: ${path13.basename(filePath)}, reloading...`);
17632
+ this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
17570
17633
  this.reload();
17571
17634
  }
17572
17635
  };
@@ -17621,12 +17684,12 @@ var ProviderLoader = class _ProviderLoader {
17621
17684
  }
17622
17685
  const https = __require("https");
17623
17686
  const { execSync: execSync7 } = __require("child_process");
17624
- const metaPath = path13.join(this.upstreamDir, _ProviderLoader.META_FILE);
17687
+ const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
17625
17688
  let prevEtag = "";
17626
17689
  let prevTimestamp = 0;
17627
17690
  try {
17628
- if (fs6.existsSync(metaPath)) {
17629
- const meta = JSON.parse(fs6.readFileSync(metaPath, "utf-8"));
17691
+ if (fs7.existsSync(metaPath)) {
17692
+ const meta = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
17630
17693
  prevEtag = meta.etag || "";
17631
17694
  prevTimestamp = meta.timestamp || 0;
17632
17695
  }
@@ -17681,39 +17744,39 @@ var ProviderLoader = class _ProviderLoader {
17681
17744
  return { updated: false };
17682
17745
  }
17683
17746
  this.log("Downloading latest providers from GitHub...");
17684
- const tmpTar = path13.join(os13.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
17685
- const tmpExtract = path13.join(os13.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
17747
+ const tmpTar = path14.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
17748
+ const tmpExtract = path14.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
17686
17749
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
17687
- fs6.mkdirSync(tmpExtract, { recursive: true });
17750
+ fs7.mkdirSync(tmpExtract, { recursive: true });
17688
17751
  execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
17689
- const extracted = fs6.readdirSync(tmpExtract);
17752
+ const extracted = fs7.readdirSync(tmpExtract);
17690
17753
  const rootDir = extracted.find(
17691
- (d) => fs6.statSync(path13.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
17754
+ (d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
17692
17755
  );
17693
17756
  if (!rootDir) throw new Error("Unexpected tarball structure");
17694
- const sourceDir = path13.join(tmpExtract, rootDir);
17757
+ const sourceDir = path14.join(tmpExtract, rootDir);
17695
17758
  const backupDir = this.upstreamDir + ".bak";
17696
- if (fs6.existsSync(this.upstreamDir)) {
17697
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
17698
- fs6.renameSync(this.upstreamDir, backupDir);
17759
+ if (fs7.existsSync(this.upstreamDir)) {
17760
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
17761
+ fs7.renameSync(this.upstreamDir, backupDir);
17699
17762
  }
17700
17763
  try {
17701
17764
  this.copyDirRecursive(sourceDir, this.upstreamDir);
17702
17765
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
17703
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
17766
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
17704
17767
  } catch (e) {
17705
- if (fs6.existsSync(backupDir)) {
17706
- if (fs6.existsSync(this.upstreamDir)) fs6.rmSync(this.upstreamDir, { recursive: true, force: true });
17707
- fs6.renameSync(backupDir, this.upstreamDir);
17768
+ if (fs7.existsSync(backupDir)) {
17769
+ if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
17770
+ fs7.renameSync(backupDir, this.upstreamDir);
17708
17771
  }
17709
17772
  throw e;
17710
17773
  }
17711
17774
  try {
17712
- fs6.rmSync(tmpTar, { force: true });
17775
+ fs7.rmSync(tmpTar, { force: true });
17713
17776
  } catch {
17714
17777
  }
17715
17778
  try {
17716
- fs6.rmSync(tmpExtract, { recursive: true, force: true });
17779
+ fs7.rmSync(tmpExtract, { recursive: true, force: true });
17717
17780
  } catch {
17718
17781
  }
17719
17782
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -17745,7 +17808,7 @@ var ProviderLoader = class _ProviderLoader {
17745
17808
  reject(new Error(`HTTP ${res.statusCode}`));
17746
17809
  return;
17747
17810
  }
17748
- const ws = fs6.createWriteStream(destPath);
17811
+ const ws = fs7.createWriteStream(destPath);
17749
17812
  res.pipe(ws);
17750
17813
  ws.on("finish", () => {
17751
17814
  ws.close();
@@ -17764,22 +17827,22 @@ var ProviderLoader = class _ProviderLoader {
17764
17827
  }
17765
17828
  /** Recursive directory copy */
17766
17829
  copyDirRecursive(src, dest) {
17767
- fs6.mkdirSync(dest, { recursive: true });
17768
- for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
17769
- const srcPath = path13.join(src, entry.name);
17770
- const destPath = path13.join(dest, entry.name);
17830
+ fs7.mkdirSync(dest, { recursive: true });
17831
+ for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
17832
+ const srcPath = path14.join(src, entry.name);
17833
+ const destPath = path14.join(dest, entry.name);
17771
17834
  if (entry.isDirectory()) {
17772
17835
  this.copyDirRecursive(srcPath, destPath);
17773
17836
  } else {
17774
- fs6.copyFileSync(srcPath, destPath);
17837
+ fs7.copyFileSync(srcPath, destPath);
17775
17838
  }
17776
17839
  }
17777
17840
  }
17778
17841
  /** .meta.json save */
17779
17842
  writeMeta(metaPath, etag, timestamp) {
17780
17843
  try {
17781
- fs6.mkdirSync(path13.dirname(metaPath), { recursive: true });
17782
- fs6.writeFileSync(metaPath, JSON.stringify({
17844
+ fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
17845
+ fs7.writeFileSync(metaPath, JSON.stringify({
17783
17846
  etag,
17784
17847
  timestamp,
17785
17848
  lastCheck: new Date(timestamp).toISOString(),
@@ -17790,12 +17853,12 @@ var ProviderLoader = class _ProviderLoader {
17790
17853
  }
17791
17854
  /** Count provider files (provider.js or provider.json) */
17792
17855
  countProviders(dir) {
17793
- if (!fs6.existsSync(dir)) return 0;
17856
+ if (!fs7.existsSync(dir)) return 0;
17794
17857
  let count = 0;
17795
17858
  const scan = (d) => {
17796
17859
  try {
17797
- for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
17798
- if (entry.isDirectory()) scan(path13.join(d, entry.name));
17860
+ for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
17861
+ if (entry.isDirectory()) scan(path14.join(d, entry.name));
17799
17862
  else if (entry.name === "provider.json") count++;
17800
17863
  }
17801
17864
  } catch {
@@ -18021,19 +18084,19 @@ var ProviderLoader = class _ProviderLoader {
18021
18084
  const cat = provider.category;
18022
18085
  const searchRoots = this.getProviderRoots();
18023
18086
  for (const root of searchRoots) {
18024
- if (!fs6.existsSync(root)) continue;
18087
+ if (!fs7.existsSync(root)) continue;
18025
18088
  const candidate = this.getProviderDir(root, cat, type);
18026
- if (fs6.existsSync(path13.join(candidate, "provider.json"))) return candidate;
18027
- const catDir = path13.join(root, cat);
18028
- if (fs6.existsSync(catDir)) {
18089
+ if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
18090
+ const catDir = path14.join(root, cat);
18091
+ if (fs7.existsSync(catDir)) {
18029
18092
  try {
18030
- for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
18093
+ for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
18031
18094
  if (!entry.isDirectory()) continue;
18032
- const jsonPath = path13.join(catDir, entry.name, "provider.json");
18033
- if (fs6.existsSync(jsonPath)) {
18095
+ const jsonPath = path14.join(catDir, entry.name, "provider.json");
18096
+ if (fs7.existsSync(jsonPath)) {
18034
18097
  try {
18035
- const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
18036
- if (data.type === type) return path13.join(catDir, entry.name);
18098
+ const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
18099
+ if (data.type === type) return path14.join(catDir, entry.name);
18037
18100
  } catch {
18038
18101
  }
18039
18102
  }
@@ -18050,8 +18113,8 @@ var ProviderLoader = class _ProviderLoader {
18050
18113
  * (template substitution is NOT applied here — scripts.js handles that)
18051
18114
  */
18052
18115
  buildScriptWrappersFromDir(dir) {
18053
- const scriptsJs = path13.join(dir, "scripts.js");
18054
- if (fs6.existsSync(scriptsJs)) {
18116
+ const scriptsJs = path14.join(dir, "scripts.js");
18117
+ if (fs7.existsSync(scriptsJs)) {
18055
18118
  try {
18056
18119
  delete __require.cache[__require.resolve(scriptsJs)];
18057
18120
  return __require(scriptsJs);
@@ -18061,13 +18124,13 @@ var ProviderLoader = class _ProviderLoader {
18061
18124
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
18062
18125
  const result = {};
18063
18126
  try {
18064
- for (const file of fs6.readdirSync(dir)) {
18127
+ for (const file of fs7.readdirSync(dir)) {
18065
18128
  if (!file.endsWith(".js")) continue;
18066
18129
  const scriptName = toCamel(file.replace(".js", ""));
18067
- const filePath = path13.join(dir, file);
18130
+ const filePath = path14.join(dir, file);
18068
18131
  result[scriptName] = (...args) => {
18069
18132
  try {
18070
- let content = fs6.readFileSync(filePath, "utf-8");
18133
+ let content = fs7.readFileSync(filePath, "utf-8");
18071
18134
  if (args[0] && typeof args[0] === "object") {
18072
18135
  for (const [key, val] of Object.entries(args[0])) {
18073
18136
  let v = val;
@@ -18113,20 +18176,20 @@ var ProviderLoader = class _ProviderLoader {
18113
18176
  * Structure: dir/category/agent-name/provider.{json,js}
18114
18177
  */
18115
18178
  loadDir(dir, excludeDirs) {
18116
- if (!fs6.existsSync(dir)) return 0;
18179
+ if (!fs7.existsSync(dir)) return 0;
18117
18180
  let count = 0;
18118
18181
  const scan = (d) => {
18119
18182
  let entries;
18120
18183
  try {
18121
- entries = fs6.readdirSync(d, { withFileTypes: true });
18184
+ entries = fs7.readdirSync(d, { withFileTypes: true });
18122
18185
  } catch {
18123
18186
  return;
18124
18187
  }
18125
18188
  const hasJson = entries.some((e) => e.name === "provider.json");
18126
18189
  if (hasJson) {
18127
- const jsonPath = path13.join(d, "provider.json");
18190
+ const jsonPath = path14.join(d, "provider.json");
18128
18191
  try {
18129
- const raw = fs6.readFileSync(jsonPath, "utf-8");
18192
+ const raw = fs7.readFileSync(jsonPath, "utf-8");
18130
18193
  const mod = JSON.parse(raw);
18131
18194
  if (typeof mod.extensionIdPattern === "string") {
18132
18195
  const flags = mod.extensionIdPattern_flags || "";
@@ -18145,8 +18208,8 @@ var ProviderLoader = class _ProviderLoader {
18145
18208
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
18146
18209
  } else {
18147
18210
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
18148
- const scriptsPath = path13.join(d, "scripts.js");
18149
- if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
18211
+ const scriptsPath = path14.join(d, "scripts.js");
18212
+ if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
18150
18213
  try {
18151
18214
  delete __require.cache[__require.resolve(scriptsPath)];
18152
18215
  const scripts = __require(scriptsPath);
@@ -18171,7 +18234,7 @@ var ProviderLoader = class _ProviderLoader {
18171
18234
  if (!entry.isDirectory()) continue;
18172
18235
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
18173
18236
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
18174
- scan(path13.join(d, entry.name));
18237
+ scan(path14.join(d, entry.name));
18175
18238
  }
18176
18239
  }
18177
18240
  };
@@ -18361,7 +18424,7 @@ async function isCdpActive(port) {
18361
18424
  });
18362
18425
  }
18363
18426
  async function killIdeProcess(ideId) {
18364
- const plat = os14.platform();
18427
+ const plat = os15.platform();
18365
18428
  const appName = getMacAppIdentifiers()[ideId];
18366
18429
  const winProcesses = getWinProcessNames()[ideId];
18367
18430
  try {
@@ -18422,7 +18485,7 @@ async function killIdeProcess(ideId) {
18422
18485
  }
18423
18486
  }
18424
18487
  function isIdeRunning(ideId) {
18425
- const plat = os14.platform();
18488
+ const plat = os15.platform();
18426
18489
  try {
18427
18490
  if (plat === "darwin") {
18428
18491
  const appName = getMacAppIdentifiers()[ideId];
@@ -18477,7 +18540,7 @@ function isIdeRunning(ideId) {
18477
18540
  }
18478
18541
  }
18479
18542
  function detectCurrentWorkspace(ideId) {
18480
- const plat = os14.platform();
18543
+ const plat = os15.platform();
18481
18544
  if (plat === "darwin") {
18482
18545
  try {
18483
18546
  const appName = getMacAppIdentifiers()[ideId];
@@ -18492,17 +18555,17 @@ function detectCurrentWorkspace(ideId) {
18492
18555
  }
18493
18556
  } else if (plat === "win32") {
18494
18557
  try {
18495
- const fs15 = __require("fs");
18558
+ const fs16 = __require("fs");
18496
18559
  const appNameMap = getMacAppIdentifiers();
18497
18560
  const appName = appNameMap[ideId];
18498
18561
  if (appName) {
18499
- const storagePath = path14.join(
18500
- process.env.APPDATA || path14.join(os14.homedir(), "AppData", "Roaming"),
18562
+ const storagePath = path15.join(
18563
+ process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Roaming"),
18501
18564
  appName,
18502
18565
  "storage.json"
18503
18566
  );
18504
- if (fs15.existsSync(storagePath)) {
18505
- const data = JSON.parse(fs15.readFileSync(storagePath, "utf-8"));
18567
+ if (fs16.existsSync(storagePath)) {
18568
+ const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
18506
18569
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
18507
18570
  if (workspaces.length > 0) {
18508
18571
  const recent = workspaces[0];
@@ -18519,7 +18582,7 @@ function detectCurrentWorkspace(ideId) {
18519
18582
  return void 0;
18520
18583
  }
18521
18584
  async function launchWithCdp(options = {}) {
18522
- const platform10 = os14.platform();
18585
+ const platform10 = os15.platform();
18523
18586
  let targetIde;
18524
18587
  const ides = await detectIDEs(getProviderLoader());
18525
18588
  if (options.ideId) {
@@ -18674,14 +18737,14 @@ init_config();
18674
18737
  init_logger();
18675
18738
 
18676
18739
  // src/logging/command-log.ts
18677
- import * as fs7 from "fs";
18678
- import * as path15 from "path";
18679
- import * as os15 from "os";
18680
- 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");
18740
+ import * as fs8 from "fs";
18741
+ import * as path16 from "path";
18742
+ import * as os16 from "os";
18743
+ 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");
18681
18744
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
18682
18745
  var MAX_DAYS = 7;
18683
18746
  try {
18684
- fs7.mkdirSync(LOG_DIR2, { recursive: true });
18747
+ fs8.mkdirSync(LOG_DIR2, { recursive: true });
18685
18748
  } catch {
18686
18749
  }
18687
18750
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -18715,19 +18778,19 @@ function getDateStr2() {
18715
18778
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
18716
18779
  }
18717
18780
  var currentDate2 = getDateStr2();
18718
- var currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18781
+ var currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18719
18782
  var writeCount2 = 0;
18720
18783
  function checkRotation() {
18721
18784
  const today = getDateStr2();
18722
18785
  if (today !== currentDate2) {
18723
18786
  currentDate2 = today;
18724
- currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18787
+ currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
18725
18788
  cleanOldFiles();
18726
18789
  }
18727
18790
  }
18728
18791
  function cleanOldFiles() {
18729
18792
  try {
18730
- const files = fs7.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
18793
+ const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
18731
18794
  const cutoff = /* @__PURE__ */ new Date();
18732
18795
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
18733
18796
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -18735,7 +18798,7 @@ function cleanOldFiles() {
18735
18798
  const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
18736
18799
  if (dateMatch && dateMatch[1] < cutoffStr) {
18737
18800
  try {
18738
- fs7.unlinkSync(path15.join(LOG_DIR2, file));
18801
+ fs8.unlinkSync(path16.join(LOG_DIR2, file));
18739
18802
  } catch {
18740
18803
  }
18741
18804
  }
@@ -18745,14 +18808,14 @@ function cleanOldFiles() {
18745
18808
  }
18746
18809
  function checkSize() {
18747
18810
  try {
18748
- const stat = fs7.statSync(currentFile);
18811
+ const stat = fs8.statSync(currentFile);
18749
18812
  if (stat.size > MAX_FILE_SIZE) {
18750
18813
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
18751
18814
  try {
18752
- fs7.unlinkSync(backup);
18815
+ fs8.unlinkSync(backup);
18753
18816
  } catch {
18754
18817
  }
18755
- fs7.renameSync(currentFile, backup);
18818
+ fs8.renameSync(currentFile, backup);
18756
18819
  }
18757
18820
  } catch {
18758
18821
  }
@@ -18785,14 +18848,14 @@ function logCommand(entry) {
18785
18848
  ...entry.error ? { err: entry.error } : {},
18786
18849
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
18787
18850
  });
18788
- fs7.appendFileSync(currentFile, line + "\n");
18851
+ fs8.appendFileSync(currentFile, line + "\n");
18789
18852
  } catch {
18790
18853
  }
18791
18854
  }
18792
18855
  function getRecentCommands(count = 50) {
18793
18856
  try {
18794
- if (!fs7.existsSync(currentFile)) return [];
18795
- const content = fs7.readFileSync(currentFile, "utf-8");
18857
+ if (!fs8.existsSync(currentFile)) return [];
18858
+ const content = fs8.readFileSync(currentFile, "utf-8");
18796
18859
  const lines = content.trim().split("\n").filter(Boolean);
18797
18860
  return lines.slice(-count).map((line) => {
18798
18861
  try {
@@ -18822,7 +18885,7 @@ init_logger();
18822
18885
 
18823
18886
  // src/status/snapshot.ts
18824
18887
  init_config();
18825
- import * as os16 from "os";
18888
+ import * as os17 from "os";
18826
18889
  init_terminal_screen();
18827
18890
  init_logger();
18828
18891
  var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
@@ -18876,8 +18939,8 @@ function buildAvailableProviders(providerLoader) {
18876
18939
  }
18877
18940
  function buildMachineInfo(profile = "full") {
18878
18941
  const base = {
18879
- hostname: os16.hostname(),
18880
- platform: os16.platform()
18942
+ hostname: os17.hostname(),
18943
+ platform: os17.platform()
18881
18944
  };
18882
18945
  if (profile === "live") {
18883
18946
  return base;
@@ -18886,23 +18949,23 @@ function buildMachineInfo(profile = "full") {
18886
18949
  const memSnap2 = getHostMemorySnapshot();
18887
18950
  return {
18888
18951
  ...base,
18889
- arch: os16.arch(),
18890
- cpus: os16.cpus().length,
18952
+ arch: os17.arch(),
18953
+ cpus: os17.cpus().length,
18891
18954
  totalMem: memSnap2.totalMem,
18892
- release: os16.release()
18955
+ release: os17.release()
18893
18956
  };
18894
18957
  }
18895
18958
  const memSnap = getHostMemorySnapshot();
18896
18959
  return {
18897
18960
  ...base,
18898
- arch: os16.arch(),
18899
- cpus: os16.cpus().length,
18961
+ arch: os17.arch(),
18962
+ cpus: os17.cpus().length,
18900
18963
  totalMem: memSnap.totalMem,
18901
18964
  freeMem: memSnap.freeMem,
18902
18965
  availableMem: memSnap.availableMem,
18903
- loadavg: os16.loadavg(),
18904
- uptime: os16.uptime(),
18905
- release: os16.release()
18966
+ loadavg: os17.loadavg(),
18967
+ uptime: os17.uptime(),
18968
+ release: os17.release()
18906
18969
  };
18907
18970
  }
18908
18971
  function parseMessageTime(value) {
@@ -19129,42 +19192,42 @@ function buildStatusSnapshot(options) {
19129
19192
  // src/commands/upgrade-helper.ts
19130
19193
  import { execFileSync as execFileSync2 } from "child_process";
19131
19194
  import { spawn as spawn3 } from "child_process";
19132
- import * as fs8 from "fs";
19133
- import * as os17 from "os";
19134
- import * as path16 from "path";
19195
+ import * as fs9 from "fs";
19196
+ import * as os18 from "os";
19197
+ import * as path17 from "path";
19135
19198
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
19136
19199
  function getUpgradeLogPath() {
19137
- const home = os17.homedir();
19138
- const dir = path16.join(home, ".adhdev");
19139
- fs8.mkdirSync(dir, { recursive: true });
19140
- return path16.join(dir, "daemon-upgrade.log");
19200
+ const home = os18.homedir();
19201
+ const dir = path17.join(home, ".adhdev");
19202
+ fs9.mkdirSync(dir, { recursive: true });
19203
+ return path17.join(dir, "daemon-upgrade.log");
19141
19204
  }
19142
19205
  function appendUpgradeLog(message) {
19143
19206
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
19144
19207
  `;
19145
19208
  try {
19146
- fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
19209
+ fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
19147
19210
  } catch {
19148
19211
  }
19149
19212
  }
19150
19213
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
19151
- const binDir = path16.dirname(nodeExecutable);
19214
+ const binDir = path17.dirname(nodeExecutable);
19152
19215
  if (platform10 === "win32") {
19153
- const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
19154
- if (fs8.existsSync(npmCliPath)) {
19216
+ const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
19217
+ if (fs9.existsSync(npmCliPath)) {
19155
19218
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
19156
19219
  }
19157
19220
  for (const candidate of ["npm.exe", "npm"]) {
19158
- const candidatePath = path16.join(binDir, candidate);
19159
- if (fs8.existsSync(candidatePath)) {
19221
+ const candidatePath = path17.join(binDir, candidate);
19222
+ if (fs9.existsSync(candidatePath)) {
19160
19223
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
19161
19224
  }
19162
19225
  }
19163
19226
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
19164
19227
  }
19165
19228
  for (const candidate of ["npm"]) {
19166
- const candidatePath = path16.join(binDir, candidate);
19167
- if (fs8.existsSync(candidatePath)) {
19229
+ const candidatePath = path17.join(binDir, candidate);
19230
+ if (fs9.existsSync(candidatePath)) {
19168
19231
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
19169
19232
  }
19170
19233
  }
@@ -19174,22 +19237,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19174
19237
  if (!currentCliPath) return null;
19175
19238
  let resolvedPath = currentCliPath;
19176
19239
  try {
19177
- resolvedPath = fs8.realpathSync.native(currentCliPath);
19240
+ resolvedPath = fs9.realpathSync.native(currentCliPath);
19178
19241
  } catch {
19179
19242
  }
19180
19243
  let currentDir = resolvedPath;
19181
19244
  try {
19182
- if (fs8.statSync(resolvedPath).isFile()) {
19183
- currentDir = path16.dirname(resolvedPath);
19245
+ if (fs9.statSync(resolvedPath).isFile()) {
19246
+ currentDir = path17.dirname(resolvedPath);
19184
19247
  }
19185
19248
  } catch {
19186
- currentDir = path16.dirname(resolvedPath);
19249
+ currentDir = path17.dirname(resolvedPath);
19187
19250
  }
19188
19251
  while (true) {
19189
- const packageJsonPath = path16.join(currentDir, "package.json");
19252
+ const packageJsonPath = path17.join(currentDir, "package.json");
19190
19253
  try {
19191
- if (fs8.existsSync(packageJsonPath)) {
19192
- const parsed = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
19254
+ if (fs9.existsSync(packageJsonPath)) {
19255
+ const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
19193
19256
  if (parsed?.name === packageName) {
19194
19257
  const normalized = currentDir.replace(/\\/g, "/");
19195
19258
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -19197,7 +19260,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19197
19260
  }
19198
19261
  } catch {
19199
19262
  }
19200
- const parentDir = path16.dirname(currentDir);
19263
+ const parentDir = path17.dirname(currentDir);
19201
19264
  if (parentDir === currentDir) {
19202
19265
  return null;
19203
19266
  }
@@ -19205,13 +19268,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
19205
19268
  }
19206
19269
  }
19207
19270
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
19208
- const nodeModulesDir = packageName.startsWith("@") ? path16.dirname(path16.dirname(packageRoot)) : path16.dirname(packageRoot);
19209
- if (path16.basename(nodeModulesDir) !== "node_modules") {
19271
+ const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
19272
+ if (path17.basename(nodeModulesDir) !== "node_modules") {
19210
19273
  return null;
19211
19274
  }
19212
- const maybeLibDir = path16.dirname(nodeModulesDir);
19213
- if (path16.basename(maybeLibDir) === "lib") {
19214
- return path16.dirname(maybeLibDir);
19275
+ const maybeLibDir = path17.dirname(nodeModulesDir);
19276
+ if (path17.basename(maybeLibDir) === "lib") {
19277
+ return path17.dirname(maybeLibDir);
19215
19278
  }
19216
19279
  return maybeLibDir;
19217
19280
  }
@@ -19326,10 +19389,10 @@ async function waitForPidExit(pid, timeoutMs) {
19326
19389
  }
19327
19390
  }
19328
19391
  function stopSessionHostProcesses(appName) {
19329
- const pidFile = path16.join(os17.homedir(), ".adhdev", `${appName}-session-host.pid`);
19392
+ const pidFile = path17.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
19330
19393
  try {
19331
- if (fs8.existsSync(pidFile)) {
19332
- const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
19394
+ if (fs9.existsSync(pidFile)) {
19395
+ const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
19333
19396
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
19334
19397
  killPid(pid);
19335
19398
  }
@@ -19337,15 +19400,15 @@ function stopSessionHostProcesses(appName) {
19337
19400
  } catch {
19338
19401
  } finally {
19339
19402
  try {
19340
- fs8.unlinkSync(pidFile);
19403
+ fs9.unlinkSync(pidFile);
19341
19404
  } catch {
19342
19405
  }
19343
19406
  }
19344
19407
  }
19345
19408
  function removeDaemonPidFile() {
19346
- const pidFile = path16.join(os17.homedir(), ".adhdev", "daemon.pid");
19409
+ const pidFile = path17.join(os18.homedir(), ".adhdev", "daemon.pid");
19347
19410
  try {
19348
- fs8.unlinkSync(pidFile);
19411
+ fs9.unlinkSync(pidFile);
19349
19412
  } catch {
19350
19413
  }
19351
19414
  }
@@ -19354,7 +19417,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
19354
19417
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
19355
19418
  if (!npmRoot) return;
19356
19419
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
19357
- const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
19420
+ const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
19358
19421
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
19359
19422
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
19360
19423
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -19362,25 +19425,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
19362
19425
  }
19363
19426
  if (pkgName.startsWith("@")) {
19364
19427
  const [scope, name] = pkgName.split("/");
19365
- const scopeDir = path16.join(npmRoot, scope);
19366
- if (!fs8.existsSync(scopeDir)) return;
19367
- for (const entry of fs8.readdirSync(scopeDir)) {
19428
+ const scopeDir = path17.join(npmRoot, scope);
19429
+ if (!fs9.existsSync(scopeDir)) return;
19430
+ for (const entry of fs9.readdirSync(scopeDir)) {
19368
19431
  if (!entry.startsWith(`.${name}-`)) continue;
19369
- fs8.rmSync(path16.join(scopeDir, entry), { recursive: true, force: true });
19370
- appendUpgradeLog(`Removed stale scoped staging dir: ${path16.join(scopeDir, entry)}`);
19432
+ fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
19433
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
19371
19434
  }
19372
19435
  } else {
19373
- for (const entry of fs8.readdirSync(npmRoot)) {
19436
+ for (const entry of fs9.readdirSync(npmRoot)) {
19374
19437
  if (!entry.startsWith(`.${pkgName}-`)) continue;
19375
- fs8.rmSync(path16.join(npmRoot, entry), { recursive: true, force: true });
19376
- appendUpgradeLog(`Removed stale staging dir: ${path16.join(npmRoot, entry)}`);
19438
+ fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
19439
+ appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
19377
19440
  }
19378
19441
  }
19379
- if (fs8.existsSync(binDir)) {
19380
- for (const entry of fs8.readdirSync(binDir)) {
19442
+ if (fs9.existsSync(binDir)) {
19443
+ for (const entry of fs9.readdirSync(binDir)) {
19381
19444
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
19382
- fs8.rmSync(path16.join(binDir, entry), { recursive: true, force: true });
19383
- appendUpgradeLog(`Removed stale bin staging entry: ${path16.join(binDir, entry)}`);
19445
+ fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
19446
+ appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
19384
19447
  }
19385
19448
  }
19386
19449
  }
@@ -19465,7 +19528,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
19465
19528
  }
19466
19529
 
19467
19530
  // src/commands/router.ts
19468
- import * as fs9 from "fs";
19531
+ import * as fs10 from "fs";
19469
19532
  var CHAT_COMMANDS = [
19470
19533
  "send_chat",
19471
19534
  "new_chat",
@@ -19701,8 +19764,8 @@ var DaemonCommandRouter = class {
19701
19764
  if (sinceTs > 0) {
19702
19765
  return { success: true, logs: [], totalBuffered: 0 };
19703
19766
  }
19704
- if (fs9.existsSync(LOG_PATH)) {
19705
- const content = fs9.readFileSync(LOG_PATH, "utf-8");
19767
+ if (fs10.existsSync(LOG_PATH)) {
19768
+ const content = fs10.readFileSync(LOG_PATH, "utf-8");
19706
19769
  const allLines = content.split("\n");
19707
19770
  const recent = allLines.slice(-count).join("\n");
19708
19771
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -21857,12 +21920,12 @@ init_io_contracts();
21857
21920
  init_chat_message_normalization();
21858
21921
 
21859
21922
  // src/providers/version-archive.ts
21860
- import * as fs10 from "fs";
21861
- import * as path17 from "path";
21862
- import * as os18 from "os";
21923
+ import * as fs11 from "fs";
21924
+ import * as path18 from "path";
21925
+ import * as os19 from "os";
21863
21926
  import { execSync as execSync5 } from "child_process";
21864
21927
  import { platform as platform8 } from "os";
21865
- var ARCHIVE_PATH = path17.join(os18.homedir(), ".adhdev", "version-history.json");
21928
+ var ARCHIVE_PATH = path18.join(os19.homedir(), ".adhdev", "version-history.json");
21866
21929
  var MAX_ENTRIES_PER_PROVIDER = 20;
21867
21930
  var VersionArchive = class {
21868
21931
  history = {};
@@ -21871,8 +21934,8 @@ var VersionArchive = class {
21871
21934
  }
21872
21935
  load() {
21873
21936
  try {
21874
- if (fs10.existsSync(ARCHIVE_PATH)) {
21875
- this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
21937
+ if (fs11.existsSync(ARCHIVE_PATH)) {
21938
+ this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
21876
21939
  }
21877
21940
  } catch {
21878
21941
  this.history = {};
@@ -21909,8 +21972,8 @@ var VersionArchive = class {
21909
21972
  }
21910
21973
  save() {
21911
21974
  try {
21912
- fs10.mkdirSync(path17.dirname(ARCHIVE_PATH), { recursive: true });
21913
- fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
21975
+ fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
21976
+ fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
21914
21977
  } catch {
21915
21978
  }
21916
21979
  }
@@ -21965,19 +22028,19 @@ function getVersion(binary, versionCommand) {
21965
22028
  function checkPathExists2(paths) {
21966
22029
  for (const p of paths) {
21967
22030
  if (p.includes("*")) {
21968
- const home = os18.homedir();
21969
- const resolved = p.replace(/\*/g, home.split(path17.sep).pop() || "");
21970
- if (fs10.existsSync(resolved)) return resolved;
22031
+ const home = os19.homedir();
22032
+ const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
22033
+ if (fs11.existsSync(resolved)) return resolved;
21971
22034
  } else {
21972
- if (fs10.existsSync(p)) return p;
22035
+ if (fs11.existsSync(p)) return p;
21973
22036
  }
21974
22037
  }
21975
22038
  return null;
21976
22039
  }
21977
22040
  function getMacAppVersion(appPath) {
21978
22041
  if (platform8() !== "darwin" || !appPath.endsWith(".app")) return null;
21979
- const plistPath = path17.join(appPath, "Contents", "Info.plist");
21980
- if (!fs10.existsSync(plistPath)) return null;
22042
+ const plistPath = path18.join(appPath, "Contents", "Info.plist");
22043
+ if (!fs11.existsSync(plistPath)) return null;
21981
22044
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
21982
22045
  return raw || null;
21983
22046
  }
@@ -22002,8 +22065,8 @@ async function detectAllVersions(loader, archive) {
22002
22065
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
22003
22066
  let resolvedBin = cliBin;
22004
22067
  if (!resolvedBin && appPath && currentOs === "darwin") {
22005
- const bundled = path17.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
22006
- if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
22068
+ const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
22069
+ if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
22007
22070
  }
22008
22071
  info.installed = !!(appPath || resolvedBin);
22009
22072
  info.path = appPath || null;
@@ -22042,8 +22105,8 @@ async function detectAllVersions(loader, archive) {
22042
22105
 
22043
22106
  // src/daemon/dev-server.ts
22044
22107
  import * as http2 from "http";
22045
- import * as fs14 from "fs";
22046
- import * as path21 from "path";
22108
+ import * as fs15 from "fs";
22109
+ import * as path22 from "path";
22047
22110
  init_config();
22048
22111
 
22049
22112
  // src/daemon/scaffold-template.ts
@@ -22394,8 +22457,8 @@ init_logger();
22394
22457
 
22395
22458
  // src/daemon/dev-cdp-handlers.ts
22396
22459
  init_logger();
22397
- import * as fs11 from "fs";
22398
- import * as path18 from "path";
22460
+ import * as fs12 from "fs";
22461
+ import * as path19 from "path";
22399
22462
  async function handleCdpEvaluate(ctx, req, res) {
22400
22463
  const body = await ctx.readBody(req);
22401
22464
  const { expression, timeout, ideType } = body;
@@ -22573,18 +22636,18 @@ async function handleScriptHints(ctx, type, _req, res) {
22573
22636
  return;
22574
22637
  }
22575
22638
  let scriptsPath = "";
22576
- const directScripts = path18.join(dir, "scripts.js");
22577
- if (fs11.existsSync(directScripts)) {
22639
+ const directScripts = path19.join(dir, "scripts.js");
22640
+ if (fs12.existsSync(directScripts)) {
22578
22641
  scriptsPath = directScripts;
22579
22642
  } else {
22580
- const scriptsDir = path18.join(dir, "scripts");
22581
- if (fs11.existsSync(scriptsDir)) {
22582
- const versions = fs11.readdirSync(scriptsDir).filter((d) => {
22583
- return fs11.statSync(path18.join(scriptsDir, d)).isDirectory();
22643
+ const scriptsDir = path19.join(dir, "scripts");
22644
+ if (fs12.existsSync(scriptsDir)) {
22645
+ const versions = fs12.readdirSync(scriptsDir).filter((d) => {
22646
+ return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
22584
22647
  }).sort().reverse();
22585
22648
  for (const ver of versions) {
22586
- const p = path18.join(scriptsDir, ver, "scripts.js");
22587
- if (fs11.existsSync(p)) {
22649
+ const p = path19.join(scriptsDir, ver, "scripts.js");
22650
+ if (fs12.existsSync(p)) {
22588
22651
  scriptsPath = p;
22589
22652
  break;
22590
22653
  }
@@ -22596,7 +22659,7 @@ async function handleScriptHints(ctx, type, _req, res) {
22596
22659
  return;
22597
22660
  }
22598
22661
  try {
22599
- const source = fs11.readFileSync(scriptsPath, "utf-8");
22662
+ const source = fs12.readFileSync(scriptsPath, "utf-8");
22600
22663
  const hints = {};
22601
22664
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
22602
22665
  let match;
@@ -23411,8 +23474,8 @@ async function handleDomContext(ctx, type, req, res) {
23411
23474
  }
23412
23475
 
23413
23476
  // src/daemon/dev-cli-debug.ts
23414
- import * as fs12 from "fs";
23415
- import * as path19 from "path";
23477
+ import * as fs13 from "fs";
23478
+ import * as path20 from "path";
23416
23479
  function slugifyFixtureName(value) {
23417
23480
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
23418
23481
  return normalized || `fixture-${Date.now()}`;
@@ -23422,15 +23485,15 @@ function getCliFixtureDir(ctx, type) {
23422
23485
  if (!providerDir) {
23423
23486
  throw new Error(`Provider directory not found for '${type}'`);
23424
23487
  }
23425
- return path19.join(providerDir, "fixtures");
23488
+ return path20.join(providerDir, "fixtures");
23426
23489
  }
23427
23490
  function readCliFixture(ctx, type, name) {
23428
23491
  const fixtureDir = getCliFixtureDir(ctx, type);
23429
- const filePath = path19.join(fixtureDir, `${name}.json`);
23430
- if (!fs12.existsSync(filePath)) {
23492
+ const filePath = path20.join(fixtureDir, `${name}.json`);
23493
+ if (!fs13.existsSync(filePath)) {
23431
23494
  throw new Error(`Fixture not found: ${filePath}`);
23432
23495
  }
23433
- return JSON.parse(fs12.readFileSync(filePath, "utf-8"));
23496
+ return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
23434
23497
  }
23435
23498
  function getExerciseTranscriptText(result) {
23436
23499
  const parts = [];
@@ -24166,7 +24229,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
24166
24229
  return;
24167
24230
  }
24168
24231
  const fixtureDir = getCliFixtureDir(ctx, type);
24169
- fs12.mkdirSync(fixtureDir, { recursive: true });
24232
+ fs13.mkdirSync(fixtureDir, { recursive: true });
24170
24233
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
24171
24234
  const result = await runCliExerciseInternal(ctx, { ...request, type });
24172
24235
  const fixture = {
@@ -24193,8 +24256,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
24193
24256
  },
24194
24257
  notes: typeof body?.notes === "string" ? body.notes : void 0
24195
24258
  };
24196
- const filePath = path19.join(fixtureDir, `${name}.json`);
24197
- fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
24259
+ const filePath = path20.join(fixtureDir, `${name}.json`);
24260
+ fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
24198
24261
  ctx.json(res, 200, {
24199
24262
  saved: true,
24200
24263
  name,
@@ -24212,14 +24275,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
24212
24275
  async function handleCliFixtureList(ctx, type, _req, res) {
24213
24276
  try {
24214
24277
  const fixtureDir = getCliFixtureDir(ctx, type);
24215
- if (!fs12.existsSync(fixtureDir)) {
24278
+ if (!fs13.existsSync(fixtureDir)) {
24216
24279
  ctx.json(res, 200, { fixtures: [], count: 0 });
24217
24280
  return;
24218
24281
  }
24219
- const fixtures = fs12.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
24220
- const fullPath = path19.join(fixtureDir, file);
24282
+ const fixtures = fs13.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
24283
+ const fullPath = path20.join(fixtureDir, file);
24221
24284
  try {
24222
- const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
24285
+ const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
24223
24286
  return {
24224
24287
  name: raw.name || file.replace(/\.json$/i, ""),
24225
24288
  path: fullPath,
@@ -24352,9 +24415,9 @@ async function handleCliRaw(ctx, req, res) {
24352
24415
  }
24353
24416
 
24354
24417
  // src/daemon/dev-auto-implement.ts
24355
- import * as fs13 from "fs";
24356
- import * as path20 from "path";
24357
- import * as os19 from "os";
24418
+ import * as fs14 from "fs";
24419
+ import * as path21 from "path";
24420
+ import * as os20 from "os";
24358
24421
  function getAutoImplPid(ctx) {
24359
24422
  const pid = ctx.autoImplProcess?.pid;
24360
24423
  return typeof pid === "number" && pid > 0 ? pid : null;
@@ -24400,38 +24463,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
24400
24463
  return fallback?.type || null;
24401
24464
  }
24402
24465
  function getLatestScriptVersionDir(scriptsDir) {
24403
- if (!fs13.existsSync(scriptsDir)) return null;
24404
- const versions = fs13.readdirSync(scriptsDir).filter((d) => {
24466
+ if (!fs14.existsSync(scriptsDir)) return null;
24467
+ const versions = fs14.readdirSync(scriptsDir).filter((d) => {
24405
24468
  try {
24406
- return fs13.statSync(path20.join(scriptsDir, d)).isDirectory();
24469
+ return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
24407
24470
  } catch {
24408
24471
  return false;
24409
24472
  }
24410
24473
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
24411
24474
  if (versions.length === 0) return null;
24412
- return path20.join(scriptsDir, versions[0]);
24475
+ return path21.join(scriptsDir, versions[0]);
24413
24476
  }
24414
24477
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
24415
- const canonicalUserDir = path20.resolve(ctx.providerLoader.getUserProviderDir(category, type));
24416
- const desiredDir = requestedDir ? path20.resolve(requestedDir) : canonicalUserDir;
24417
- const upstreamRoot = path20.resolve(ctx.providerLoader.getUpstreamDir());
24418
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path20.sep}`)) {
24478
+ const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
24479
+ const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
24480
+ const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
24481
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
24419
24482
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
24420
24483
  }
24421
- if (path20.basename(desiredDir) !== type) {
24484
+ if (path21.basename(desiredDir) !== type) {
24422
24485
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
24423
24486
  }
24424
24487
  const sourceDir = ctx.findProviderDir(type);
24425
24488
  if (!sourceDir) {
24426
24489
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
24427
24490
  }
24428
- if (!fs13.existsSync(desiredDir)) {
24429
- fs13.mkdirSync(path20.dirname(desiredDir), { recursive: true });
24430
- fs13.cpSync(sourceDir, desiredDir, { recursive: true });
24491
+ if (!fs14.existsSync(desiredDir)) {
24492
+ fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
24493
+ fs14.cpSync(sourceDir, desiredDir, { recursive: true });
24431
24494
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
24432
24495
  }
24433
- const providerJson = path20.join(desiredDir, "provider.json");
24434
- if (!fs13.existsSync(providerJson)) {
24496
+ const providerJson = path21.join(desiredDir, "provider.json");
24497
+ if (!fs14.existsSync(providerJson)) {
24435
24498
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
24436
24499
  }
24437
24500
  return { dir: desiredDir };
@@ -24439,15 +24502,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
24439
24502
  function loadAutoImplReferenceScripts(ctx, referenceType) {
24440
24503
  if (!referenceType) return {};
24441
24504
  const refDir = ctx.findProviderDir(referenceType);
24442
- if (!refDir || !fs13.existsSync(refDir)) return {};
24505
+ if (!refDir || !fs14.existsSync(refDir)) return {};
24443
24506
  const referenceScripts = {};
24444
- const scriptsDir = path20.join(refDir, "scripts");
24507
+ const scriptsDir = path21.join(refDir, "scripts");
24445
24508
  const latestDir = getLatestScriptVersionDir(scriptsDir);
24446
24509
  if (!latestDir) return referenceScripts;
24447
- for (const file of fs13.readdirSync(latestDir)) {
24510
+ for (const file of fs14.readdirSync(latestDir)) {
24448
24511
  if (!file.endsWith(".js")) continue;
24449
24512
  try {
24450
- referenceScripts[file] = fs13.readFileSync(path20.join(latestDir, file), "utf-8");
24513
+ referenceScripts[file] = fs14.readFileSync(path21.join(latestDir, file), "utf-8");
24451
24514
  } catch {
24452
24515
  }
24453
24516
  }
@@ -24555,16 +24618,16 @@ async function handleAutoImplement(ctx, type, req, res) {
24555
24618
  });
24556
24619
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
24557
24620
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
24558
- const tmpDir = path20.join(os19.tmpdir(), "adhdev-autoimpl");
24559
- if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
24560
- const promptFile = path20.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
24561
- fs13.writeFileSync(promptFile, prompt, "utf-8");
24621
+ const tmpDir = path21.join(os20.tmpdir(), "adhdev-autoimpl");
24622
+ if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
24623
+ const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
24624
+ fs14.writeFileSync(promptFile, prompt, "utf-8");
24562
24625
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
24563
24626
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
24564
24627
  const spawn4 = agentProvider?.spawn;
24565
24628
  if (!spawn4?.command) {
24566
24629
  try {
24567
- fs13.unlinkSync(promptFile);
24630
+ fs14.unlinkSync(promptFile);
24568
24631
  } catch {
24569
24632
  }
24570
24633
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -24666,7 +24729,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24666
24729
  } catch {
24667
24730
  }
24668
24731
  try {
24669
- fs13.unlinkSync(promptFile);
24732
+ fs14.unlinkSync(promptFile);
24670
24733
  } catch {
24671
24734
  }
24672
24735
  ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -24710,7 +24773,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24710
24773
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
24711
24774
  const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
24712
24775
  let shellCmd;
24713
- const isWin = os19.platform() === "win32";
24776
+ const isWin = os20.platform() === "win32";
24714
24777
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
24715
24778
  const promptMode = autoImpl?.promptMode ?? "stdin";
24716
24779
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -24749,7 +24812,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24749
24812
  try {
24750
24813
  const pty = __require("node-pty");
24751
24814
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
24752
- const isWin2 = os19.platform() === "win32";
24815
+ const isWin2 = os20.platform() === "win32";
24753
24816
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
24754
24817
  name: "xterm-256color",
24755
24818
  cols: 120,
@@ -24892,7 +24955,7 @@ async function handleAutoImplement(ctx, type, req, res) {
24892
24955
  }
24893
24956
  });
24894
24957
  try {
24895
- fs13.unlinkSync(promptFile);
24958
+ fs14.unlinkSync(promptFile);
24896
24959
  } catch {
24897
24960
  }
24898
24961
  ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -24989,7 +25052,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
24989
25052
  setMode: "set_mode.js"
24990
25053
  };
24991
25054
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
24992
- const scriptsDir = path20.join(providerDir, "scripts");
25055
+ const scriptsDir = path21.join(providerDir, "scripts");
24993
25056
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
24994
25057
  if (latestScriptsDir) {
24995
25058
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -24997,10 +25060,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
24997
25060
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
24998
25061
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
24999
25062
  lines.push("");
25000
- for (const file of fs13.readdirSync(latestScriptsDir)) {
25063
+ for (const file of fs14.readdirSync(latestScriptsDir)) {
25001
25064
  if (file.endsWith(".js") && targetFileNames.has(file)) {
25002
25065
  try {
25003
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25066
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25004
25067
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
25005
25068
  lines.push("```javascript");
25006
25069
  lines.push(content);
@@ -25010,14 +25073,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25010
25073
  }
25011
25074
  }
25012
25075
  }
25013
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25076
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25014
25077
  if (refFiles.length > 0) {
25015
25078
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
25016
25079
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
25017
25080
  lines.push("");
25018
25081
  for (const file of refFiles) {
25019
25082
  try {
25020
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25083
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25021
25084
  lines.push(`### \`${file}\` \u{1F512}`);
25022
25085
  lines.push("```javascript");
25023
25086
  lines.push(content);
@@ -25058,11 +25121,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
25058
25121
  lines.push("");
25059
25122
  }
25060
25123
  }
25061
- const docsDir = path20.join(providerDir, "../../docs");
25124
+ const docsDir = path21.join(providerDir, "../../docs");
25062
25125
  const loadGuide = (name) => {
25063
25126
  try {
25064
- const p = path20.join(docsDir, name);
25065
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
25127
+ const p = path21.join(docsDir, name);
25128
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
25066
25129
  } catch {
25067
25130
  }
25068
25131
  return null;
@@ -25298,7 +25361,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25298
25361
  parseApproval: "parse_approval.js"
25299
25362
  };
25300
25363
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
25301
- const scriptsDir = path20.join(providerDir, "scripts");
25364
+ const scriptsDir = path21.join(providerDir, "scripts");
25302
25365
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
25303
25366
  if (latestScriptsDir) {
25304
25367
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -25306,11 +25369,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25306
25369
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
25307
25370
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
25308
25371
  lines.push("");
25309
- for (const file of fs13.readdirSync(latestScriptsDir)) {
25372
+ for (const file of fs14.readdirSync(latestScriptsDir)) {
25310
25373
  if (!file.endsWith(".js")) continue;
25311
25374
  if (!targetFileNames.has(file)) continue;
25312
25375
  try {
25313
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25376
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25314
25377
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
25315
25378
  lines.push("```javascript");
25316
25379
  lines.push(content);
@@ -25319,14 +25382,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25319
25382
  } catch {
25320
25383
  }
25321
25384
  }
25322
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25385
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
25323
25386
  if (refFiles.length > 0) {
25324
25387
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
25325
25388
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
25326
25389
  lines.push("");
25327
25390
  for (const file of refFiles) {
25328
25391
  try {
25329
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file), "utf-8");
25392
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
25330
25393
  lines.push(`### \`${file}\` \u{1F512}`);
25331
25394
  lines.push("```javascript");
25332
25395
  lines.push(content);
@@ -25359,11 +25422,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
25359
25422
  lines.push("");
25360
25423
  }
25361
25424
  }
25362
- const docsDir = path20.join(providerDir, "../../docs");
25425
+ const docsDir = path21.join(providerDir, "../../docs");
25363
25426
  const loadGuide = (name) => {
25364
25427
  try {
25365
- const p = path20.join(docsDir, name);
25366
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
25428
+ const p = path21.join(docsDir, name);
25429
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
25367
25430
  } catch {
25368
25431
  }
25369
25432
  return null;
@@ -25809,8 +25872,8 @@ var DevServer = class _DevServer {
25809
25872
  }
25810
25873
  getEndpointList() {
25811
25874
  return this.routes.map((r) => {
25812
- const path22 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
25813
- return `${r.method.padEnd(5)} ${path22}`;
25875
+ const path23 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
25876
+ return `${r.method.padEnd(5)} ${path23}`;
25814
25877
  });
25815
25878
  }
25816
25879
  async start(port = DEV_SERVER_PORT) {
@@ -26098,12 +26161,12 @@ var DevServer = class _DevServer {
26098
26161
  // ─── DevConsole SPA ───
26099
26162
  getConsoleDistDir() {
26100
26163
  const candidates = [
26101
- path21.resolve(__dirname, "../../web-devconsole/dist"),
26102
- path21.resolve(__dirname, "../../../web-devconsole/dist"),
26103
- path21.join(process.cwd(), "packages/web-devconsole/dist")
26164
+ path22.resolve(__dirname, "../../web-devconsole/dist"),
26165
+ path22.resolve(__dirname, "../../../web-devconsole/dist"),
26166
+ path22.join(process.cwd(), "packages/web-devconsole/dist")
26104
26167
  ];
26105
26168
  for (const dir of candidates) {
26106
- if (fs14.existsSync(path21.join(dir, "index.html"))) return dir;
26169
+ if (fs15.existsSync(path22.join(dir, "index.html"))) return dir;
26107
26170
  }
26108
26171
  return null;
26109
26172
  }
@@ -26113,9 +26176,9 @@ var DevServer = class _DevServer {
26113
26176
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
26114
26177
  return;
26115
26178
  }
26116
- const htmlPath = path21.join(distDir, "index.html");
26179
+ const htmlPath = path22.join(distDir, "index.html");
26117
26180
  try {
26118
- const html = fs14.readFileSync(htmlPath, "utf-8");
26181
+ const html = fs15.readFileSync(htmlPath, "utf-8");
26119
26182
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
26120
26183
  res.end(html);
26121
26184
  } catch (e) {
@@ -26138,15 +26201,15 @@ var DevServer = class _DevServer {
26138
26201
  this.json(res, 404, { error: "Not found" });
26139
26202
  return;
26140
26203
  }
26141
- const safePath = path21.normalize(pathname).replace(/^\.\.\//, "");
26142
- const filePath = path21.join(distDir, safePath);
26204
+ const safePath = path22.normalize(pathname).replace(/^\.\.\//, "");
26205
+ const filePath = path22.join(distDir, safePath);
26143
26206
  if (!filePath.startsWith(distDir)) {
26144
26207
  this.json(res, 403, { error: "Forbidden" });
26145
26208
  return;
26146
26209
  }
26147
26210
  try {
26148
- const content = fs14.readFileSync(filePath);
26149
- const ext = path21.extname(filePath);
26211
+ const content = fs15.readFileSync(filePath);
26212
+ const ext = path22.extname(filePath);
26150
26213
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
26151
26214
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
26152
26215
  res.end(content);
@@ -26254,14 +26317,14 @@ var DevServer = class _DevServer {
26254
26317
  const files = [];
26255
26318
  const scan = (d, prefix) => {
26256
26319
  try {
26257
- for (const entry of fs14.readdirSync(d, { withFileTypes: true })) {
26320
+ for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
26258
26321
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
26259
26322
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
26260
26323
  if (entry.isDirectory()) {
26261
26324
  files.push({ path: rel, size: 0, type: "dir" });
26262
- scan(path21.join(d, entry.name), rel);
26325
+ scan(path22.join(d, entry.name), rel);
26263
26326
  } else {
26264
- const stat = fs14.statSync(path21.join(d, entry.name));
26327
+ const stat = fs15.statSync(path22.join(d, entry.name));
26265
26328
  files.push({ path: rel, size: stat.size, type: "file" });
26266
26329
  }
26267
26330
  }
@@ -26284,16 +26347,16 @@ var DevServer = class _DevServer {
26284
26347
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
26285
26348
  return;
26286
26349
  }
26287
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
26350
+ const fullPath = path22.resolve(dir, path22.normalize(filePath));
26288
26351
  if (!fullPath.startsWith(dir)) {
26289
26352
  this.json(res, 403, { error: "Forbidden" });
26290
26353
  return;
26291
26354
  }
26292
- if (!fs14.existsSync(fullPath) || fs14.statSync(fullPath).isDirectory()) {
26355
+ if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
26293
26356
  this.json(res, 404, { error: `File not found: ${filePath}` });
26294
26357
  return;
26295
26358
  }
26296
- const content = fs14.readFileSync(fullPath, "utf-8");
26359
+ const content = fs15.readFileSync(fullPath, "utf-8");
26297
26360
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
26298
26361
  }
26299
26362
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -26309,15 +26372,15 @@ var DevServer = class _DevServer {
26309
26372
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
26310
26373
  return;
26311
26374
  }
26312
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
26375
+ const fullPath = path22.resolve(dir, path22.normalize(filePath));
26313
26376
  if (!fullPath.startsWith(dir)) {
26314
26377
  this.json(res, 403, { error: "Forbidden" });
26315
26378
  return;
26316
26379
  }
26317
26380
  try {
26318
- if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
26319
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
26320
- fs14.writeFileSync(fullPath, content, "utf-8");
26381
+ if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
26382
+ fs15.mkdirSync(path22.dirname(fullPath), { recursive: true });
26383
+ fs15.writeFileSync(fullPath, content, "utf-8");
26321
26384
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
26322
26385
  this.providerLoader.reload();
26323
26386
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -26333,9 +26396,9 @@ var DevServer = class _DevServer {
26333
26396
  return;
26334
26397
  }
26335
26398
  for (const name of ["scripts.js", "provider.json"]) {
26336
- const p = path21.join(dir, name);
26337
- if (fs14.existsSync(p)) {
26338
- const source = fs14.readFileSync(p, "utf-8");
26399
+ const p = path22.join(dir, name);
26400
+ if (fs15.existsSync(p)) {
26401
+ const source = fs15.readFileSync(p, "utf-8");
26339
26402
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
26340
26403
  return;
26341
26404
  }
@@ -26354,11 +26417,11 @@ var DevServer = class _DevServer {
26354
26417
  this.json(res, 404, { error: `Provider not found: ${type}` });
26355
26418
  return;
26356
26419
  }
26357
- const target = fs14.existsSync(path21.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
26358
- const targetPath = path21.join(dir, target);
26420
+ const target = fs15.existsSync(path22.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
26421
+ const targetPath = path22.join(dir, target);
26359
26422
  try {
26360
- if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
26361
- fs14.writeFileSync(targetPath, source, "utf-8");
26423
+ if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
26424
+ fs15.writeFileSync(targetPath, source, "utf-8");
26362
26425
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
26363
26426
  this.providerLoader.reload();
26364
26427
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -26502,21 +26565,21 @@ var DevServer = class _DevServer {
26502
26565
  }
26503
26566
  let targetDir;
26504
26567
  targetDir = this.providerLoader.getUserProviderDir(category, type);
26505
- const jsonPath = path21.join(targetDir, "provider.json");
26506
- if (fs14.existsSync(jsonPath)) {
26568
+ const jsonPath = path22.join(targetDir, "provider.json");
26569
+ if (fs15.existsSync(jsonPath)) {
26507
26570
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
26508
26571
  return;
26509
26572
  }
26510
26573
  try {
26511
26574
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
26512
- fs14.mkdirSync(targetDir, { recursive: true });
26513
- fs14.writeFileSync(jsonPath, result["provider.json"], "utf-8");
26575
+ fs15.mkdirSync(targetDir, { recursive: true });
26576
+ fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
26514
26577
  const createdFiles = ["provider.json"];
26515
26578
  if (result.files) {
26516
26579
  for (const [relPath, content] of Object.entries(result.files)) {
26517
- const fullPath = path21.join(targetDir, relPath);
26518
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
26519
- fs14.writeFileSync(fullPath, content, "utf-8");
26580
+ const fullPath = path22.join(targetDir, relPath);
26581
+ fs15.mkdirSync(path22.dirname(fullPath), { recursive: true });
26582
+ fs15.writeFileSync(fullPath, content, "utf-8");
26520
26583
  createdFiles.push(relPath);
26521
26584
  }
26522
26585
  }
@@ -26565,38 +26628,38 @@ var DevServer = class _DevServer {
26565
26628
  }
26566
26629
  // ─── Phase 2: Auto-Implement Backend ───
26567
26630
  getLatestScriptVersionDir(scriptsDir) {
26568
- if (!fs14.existsSync(scriptsDir)) return null;
26569
- const versions = fs14.readdirSync(scriptsDir).filter((d) => {
26631
+ if (!fs15.existsSync(scriptsDir)) return null;
26632
+ const versions = fs15.readdirSync(scriptsDir).filter((d) => {
26570
26633
  try {
26571
- return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
26634
+ return fs15.statSync(path22.join(scriptsDir, d)).isDirectory();
26572
26635
  } catch {
26573
26636
  return false;
26574
26637
  }
26575
26638
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
26576
26639
  if (versions.length === 0) return null;
26577
- return path21.join(scriptsDir, versions[0]);
26640
+ return path22.join(scriptsDir, versions[0]);
26578
26641
  }
26579
26642
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
26580
- const canonicalUserDir = path21.resolve(this.providerLoader.getUserProviderDir(category, type));
26581
- const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
26582
- const upstreamRoot = path21.resolve(this.providerLoader.getUpstreamDir());
26583
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
26643
+ const canonicalUserDir = path22.resolve(this.providerLoader.getUserProviderDir(category, type));
26644
+ const desiredDir = requestedDir ? path22.resolve(requestedDir) : canonicalUserDir;
26645
+ const upstreamRoot = path22.resolve(this.providerLoader.getUpstreamDir());
26646
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path22.sep}`)) {
26584
26647
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
26585
26648
  }
26586
- if (path21.basename(desiredDir) !== type) {
26649
+ if (path22.basename(desiredDir) !== type) {
26587
26650
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
26588
26651
  }
26589
26652
  const sourceDir = this.findProviderDir(type);
26590
26653
  if (!sourceDir) {
26591
26654
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
26592
26655
  }
26593
- if (!fs14.existsSync(desiredDir)) {
26594
- fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
26595
- fs14.cpSync(sourceDir, desiredDir, { recursive: true });
26656
+ if (!fs15.existsSync(desiredDir)) {
26657
+ fs15.mkdirSync(path22.dirname(desiredDir), { recursive: true });
26658
+ fs15.cpSync(sourceDir, desiredDir, { recursive: true });
26596
26659
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
26597
26660
  }
26598
- const providerJson = path21.join(desiredDir, "provider.json");
26599
- if (!fs14.existsSync(providerJson)) {
26661
+ const providerJson = path22.join(desiredDir, "provider.json");
26662
+ if (!fs15.existsSync(providerJson)) {
26600
26663
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
26601
26664
  }
26602
26665
  return { dir: desiredDir };
@@ -26631,7 +26694,7 @@ var DevServer = class _DevServer {
26631
26694
  setMode: "set_mode.js"
26632
26695
  };
26633
26696
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
26634
- const scriptsDir = path21.join(providerDir, "scripts");
26697
+ const scriptsDir = path22.join(providerDir, "scripts");
26635
26698
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
26636
26699
  if (latestScriptsDir) {
26637
26700
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -26639,10 +26702,10 @@ var DevServer = class _DevServer {
26639
26702
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
26640
26703
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
26641
26704
  lines.push("");
26642
- for (const file of fs14.readdirSync(latestScriptsDir)) {
26705
+ for (const file of fs15.readdirSync(latestScriptsDir)) {
26643
26706
  if (file.endsWith(".js") && targetFileNames.has(file)) {
26644
26707
  try {
26645
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26708
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26646
26709
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
26647
26710
  lines.push("```javascript");
26648
26711
  lines.push(content);
@@ -26652,14 +26715,14 @@ var DevServer = class _DevServer {
26652
26715
  }
26653
26716
  }
26654
26717
  }
26655
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26718
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26656
26719
  if (refFiles.length > 0) {
26657
26720
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
26658
26721
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
26659
26722
  lines.push("");
26660
26723
  for (const file of refFiles) {
26661
26724
  try {
26662
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26725
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26663
26726
  lines.push(`### \`${file}\` \u{1F512}`);
26664
26727
  lines.push("```javascript");
26665
26728
  lines.push(content);
@@ -26700,11 +26763,11 @@ var DevServer = class _DevServer {
26700
26763
  lines.push("");
26701
26764
  }
26702
26765
  }
26703
- const docsDir = path21.join(providerDir, "../../docs");
26766
+ const docsDir = path22.join(providerDir, "../../docs");
26704
26767
  const loadGuide = (name) => {
26705
26768
  try {
26706
- const p = path21.join(docsDir, name);
26707
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
26769
+ const p = path22.join(docsDir, name);
26770
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
26708
26771
  } catch {
26709
26772
  }
26710
26773
  return null;
@@ -26877,7 +26940,7 @@ var DevServer = class _DevServer {
26877
26940
  parseApproval: "parse_approval.js"
26878
26941
  };
26879
26942
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
26880
- const scriptsDir = path21.join(providerDir, "scripts");
26943
+ const scriptsDir = path22.join(providerDir, "scripts");
26881
26944
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
26882
26945
  if (latestScriptsDir) {
26883
26946
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -26885,11 +26948,11 @@ var DevServer = class _DevServer {
26885
26948
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
26886
26949
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
26887
26950
  lines.push("");
26888
- for (const file of fs14.readdirSync(latestScriptsDir)) {
26951
+ for (const file of fs15.readdirSync(latestScriptsDir)) {
26889
26952
  if (!file.endsWith(".js")) continue;
26890
26953
  if (!targetFileNames.has(file)) continue;
26891
26954
  try {
26892
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26955
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26893
26956
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
26894
26957
  lines.push("```javascript");
26895
26958
  lines.push(content);
@@ -26898,14 +26961,14 @@ var DevServer = class _DevServer {
26898
26961
  } catch {
26899
26962
  }
26900
26963
  }
26901
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26964
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
26902
26965
  if (refFiles.length > 0) {
26903
26966
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
26904
26967
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
26905
26968
  lines.push("");
26906
26969
  for (const file of refFiles) {
26907
26970
  try {
26908
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file), "utf-8");
26971
+ const content = fs15.readFileSync(path22.join(latestScriptsDir, file), "utf-8");
26909
26972
  lines.push(`### \`${file}\` \u{1F512}`);
26910
26973
  lines.push("```javascript");
26911
26974
  lines.push(content);
@@ -26938,11 +27001,11 @@ var DevServer = class _DevServer {
26938
27001
  lines.push("");
26939
27002
  }
26940
27003
  }
26941
- const docsDir = path21.join(providerDir, "../../docs");
27004
+ const docsDir = path22.join(providerDir, "../../docs");
26942
27005
  const loadGuide = (name) => {
26943
27006
  try {
26944
- const p = path21.join(docsDir, name);
26945
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
27007
+ const p = path22.join(docsDir, name);
27008
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
26946
27009
  } catch {
26947
27010
  }
26948
27011
  return null;
@@ -27822,8 +27885,8 @@ async function installExtension(ide, extension) {
27822
27885
  const res = await fetch(extension.vsixUrl);
27823
27886
  if (res.ok) {
27824
27887
  const buffer = Buffer.from(await res.arrayBuffer());
27825
- const fs15 = await import("fs");
27826
- fs15.writeFileSync(vsixPath, buffer);
27888
+ const fs16 = await import("fs");
27889
+ fs16.writeFileSync(vsixPath, buffer);
27827
27890
  return new Promise((resolve12) => {
27828
27891
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
27829
27892
  exec2(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {