adhdev 0.8.8 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -569,18 +569,18 @@ function checkPathExists(paths) {
569
569
  return null;
570
570
  }
571
571
  async function detectIDEs() {
572
- const os21 = (0, import_os2.platform)();
572
+ const os22 = (0, import_os2.platform)();
573
573
  const results = [];
574
574
  for (const def of getMergedDefinitions()) {
575
575
  const cliPath = findCliCommand(def.cli);
576
- const appPath = checkPathExists(def.paths[os21] || []);
576
+ const appPath = checkPathExists(def.paths[os22] || []);
577
577
  const installed = !!(cliPath || appPath);
578
578
  let resolvedCli = cliPath;
579
- if (!resolvedCli && appPath && os21 === "darwin") {
579
+ if (!resolvedCli && appPath && os22 === "darwin") {
580
580
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
581
581
  if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
582
582
  }
583
- if (!resolvedCli && appPath && os21 === "win32") {
583
+ if (!resolvedCli && appPath && os22 === "win32") {
584
584
  const { dirname: dirname9 } = await import("path");
585
585
  const appDir = dirname9(appPath);
586
586
  const candidates = [
@@ -738,9 +738,22 @@ var init_host_memory = __esm({
738
738
  });
739
739
 
740
740
  // ../../oss/packages/daemon-core/src/logging/logger.ts
741
+ function setLogLevel(level) {
742
+ currentLevel = level;
743
+ daemonLog("Logger", `Log level set to: ${level}`, "info");
744
+ }
745
+ function getLogLevel() {
746
+ return currentLevel;
747
+ }
741
748
  function getDateStr() {
742
749
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
743
750
  }
751
+ function getDaemonLogDir() {
752
+ return LOG_DIR;
753
+ }
754
+ function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
755
+ return path4.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
756
+ }
744
757
  function checkDateRotation() {
745
758
  const today = getDateStr();
746
759
  if (today !== currentDate) {
@@ -3272,6 +3285,17 @@ async function setupIdeInstance(ctx, opts) {
3272
3285
  }
3273
3286
  return ideInstance;
3274
3287
  }
3288
+ async function connectCdpManager(port, ideType, logFn, providerLoader, targetId) {
3289
+ const provider = providerLoader.getMeta(ideType);
3290
+ const manager = new DaemonCdpManager(
3291
+ port,
3292
+ logFn,
3293
+ targetId,
3294
+ provider?.targetFilter
3295
+ );
3296
+ const connected = await manager.connect();
3297
+ return connected ? manager : null;
3298
+ }
3275
3299
  async function probeCdpPort(port, timeoutMs = 1e3) {
3276
3300
  try {
3277
3301
  const probe = await fetch(`http://localhost:${port}/json/version`, {
@@ -3291,12 +3315,154 @@ var init_setup = __esm({
3291
3315
  });
3292
3316
 
3293
3317
  // ../../oss/packages/daemon-core/src/cdp/scanner.ts
3318
+ var DaemonCdpScanner;
3294
3319
  var init_scanner = __esm({
3295
3320
  "../../oss/packages/daemon-core/src/cdp/scanner.ts"() {
3296
3321
  "use strict";
3297
3322
  init_manager();
3298
3323
  init_setup();
3299
3324
  init_logger();
3325
+ DaemonCdpScanner = class {
3326
+ ctx;
3327
+ opts;
3328
+ scanTimer = null;
3329
+ discoveryTimer = null;
3330
+ constructor(opts) {
3331
+ this.ctx = opts.ctx;
3332
+ this.opts = opts;
3333
+ }
3334
+ /**
3335
+ * Initial CDP discovery — connect to all available IDEs.
3336
+ * Supports both single-window and multi-window modes.
3337
+ */
3338
+ async initialScan(enabledIdes) {
3339
+ const portMap = this.ctx.providerLoader.getCdpPortMap();
3340
+ const portsToTry = [];
3341
+ for (const [ide, ports] of Object.entries(portMap)) {
3342
+ portsToTry.push({ port: ports[0], ide });
3343
+ }
3344
+ const filtered = enabledIdes?.length ? portsToTry.filter((p) => enabledIdes.includes(p.ide)) : portsToTry;
3345
+ for (const { port, ide } of filtered) {
3346
+ if (this.opts.multiWindow) {
3347
+ await this.connectMultiWindow(port, ide);
3348
+ } else {
3349
+ await this.connectSingleWindow(port, ide);
3350
+ }
3351
+ }
3352
+ }
3353
+ /**
3354
+ * Start periodic scanning for newly launched IDEs.
3355
+ */
3356
+ startPeriodicScan() {
3357
+ if (this.scanTimer) return;
3358
+ const interval = this.opts.scanIntervalMs || 3e4;
3359
+ this.scanTimer = setInterval(async () => {
3360
+ const portMap = this.ctx.providerLoader.getCdpPortMap();
3361
+ for (const [ide, ports] of Object.entries(portMap)) {
3362
+ const primaryPort = ports[0];
3363
+ const alreadyConnected = [...this.ctx.cdpManagers.entries()].some(
3364
+ ([key, m]) => m.isConnected && (key === ide || key.startsWith(ide + "_"))
3365
+ );
3366
+ if (alreadyConnected) continue;
3367
+ if (this.opts.multiWindow) {
3368
+ await this.connectMultiWindow(primaryPort, ide);
3369
+ } else {
3370
+ await this.connectSingleWindow(primaryPort, ide);
3371
+ }
3372
+ }
3373
+ }, interval);
3374
+ }
3375
+ /**
3376
+ * Start periodic agent webview discovery on all connected CDPs.
3377
+ */
3378
+ startWebviewDiscovery(intervalMs = 3e4) {
3379
+ if (this.discoveryTimer) return;
3380
+ this.discoveryTimer = setInterval(async () => {
3381
+ for (const m of this.ctx.cdpManagers.values()) {
3382
+ if (m.isConnected) {
3383
+ await m.discoverAgentWebviews();
3384
+ }
3385
+ }
3386
+ }, intervalMs);
3387
+ }
3388
+ /**
3389
+ * Stop all timers.
3390
+ */
3391
+ stop() {
3392
+ if (this.scanTimer) {
3393
+ clearInterval(this.scanTimer);
3394
+ this.scanTimer = null;
3395
+ }
3396
+ if (this.discoveryTimer) {
3397
+ clearInterval(this.discoveryTimer);
3398
+ this.discoveryTimer = null;
3399
+ }
3400
+ }
3401
+ // ── Internal ────────────────────────────
3402
+ getLogFn(ideType) {
3403
+ if (this.opts.logFn) return this.opts.logFn(ideType);
3404
+ return (msg) => LOG.info(`CDP:${ideType}`, msg);
3405
+ }
3406
+ /**
3407
+ * Single-window connection (standalone mode).
3408
+ * One CDP manager per IDE, first working port wins.
3409
+ */
3410
+ async connectSingleWindow(port, ide) {
3411
+ if (this.ctx.cdpManagers.has(ide)) return;
3412
+ const available = await probeCdpPort(port);
3413
+ if (!available) return;
3414
+ const manager = await connectCdpManager(
3415
+ port,
3416
+ ide,
3417
+ this.getLogFn(ide),
3418
+ this.ctx.providerLoader
3419
+ );
3420
+ if (!manager) return;
3421
+ registerExtensionProviders(this.ctx.providerLoader, manager, ide);
3422
+ this.ctx.cdpManagers.set(ide, manager);
3423
+ LOG.info("IDE", `Attached: ${ide} (port ${port})`);
3424
+ await setupIdeInstance(this.ctx, { ideType: ide, manager });
3425
+ this.opts.onConnected?.(ide, ide, manager);
3426
+ }
3427
+ /**
3428
+ * Multi-window connection.
3429
+ * Multiple CDP managers per IDE — one per workbench page.
3430
+ */
3431
+ async connectMultiWindow(port, ide) {
3432
+ const allTargets = await DaemonCdpManager.listAllTargets(port);
3433
+ if (allTargets.length === 0) {
3434
+ await this.connectSingleWindow(port, ide);
3435
+ return;
3436
+ }
3437
+ for (let i = 0; i < allTargets.length; i++) {
3438
+ const target = allTargets[i];
3439
+ let managerKey;
3440
+ if (allTargets.length === 1) {
3441
+ managerKey = ide;
3442
+ } else {
3443
+ const workspaceName = (target.title || "").split(" \u2014 ")[0].trim() || `window_${i}`;
3444
+ managerKey = `${ide}_${workspaceName}`;
3445
+ }
3446
+ if (this.ctx.cdpManagers.has(managerKey)) continue;
3447
+ const manager = await connectCdpManager(
3448
+ port,
3449
+ ide,
3450
+ this.getLogFn(managerKey),
3451
+ this.ctx.providerLoader,
3452
+ target.id
3453
+ );
3454
+ if (!manager) continue;
3455
+ this.ctx.cdpManagers.set(managerKey, manager);
3456
+ LOG.info("IDE", `Attached window: ${managerKey} (port ${port}, page "${target.title}")`);
3457
+ await setupIdeInstance(this.ctx, {
3458
+ ideType: ide,
3459
+ manager,
3460
+ managerKey
3461
+ });
3462
+ this.opts.onConnected?.(ide, managerKey, manager);
3463
+ }
3464
+ }
3465
+ };
3300
3466
  }
3301
3467
  });
3302
3468
 
@@ -3540,6 +3706,12 @@ function normalizeManagedStatus(status, opts) {
3540
3706
  if (normalized === "disconnected") return "disconnected";
3541
3707
  return "idle";
3542
3708
  }
3709
+ function isManagedStatusWorking(status) {
3710
+ return normalizeManagedStatus(status) === "generating";
3711
+ }
3712
+ function isManagedStatusWaiting(status, opts) {
3713
+ return normalizeManagedStatus(status, opts) === "waiting_approval";
3714
+ }
3543
3715
  function normalizeActiveChatData(activeChat) {
3544
3716
  if (!activeChat) return activeChat;
3545
3717
  return {
@@ -3587,6 +3759,14 @@ function findCdpManager(cdpManagers, key) {
3587
3759
  }
3588
3760
  return null;
3589
3761
  }
3762
+ function hasCdpManager(cdpManagers, key) {
3763
+ if (cdpManagers.has(key)) return true;
3764
+ const prefix = key + "_";
3765
+ for (const k of cdpManagers.keys()) {
3766
+ if (k.startsWith(prefix)) return true;
3767
+ }
3768
+ return false;
3769
+ }
3590
3770
  function isCdpConnected(cdpManagers, key) {
3591
3771
  const m = findCdpManager(cdpManagers, key);
3592
3772
  return m?.isConnected ?? false;
@@ -6155,12 +6335,12 @@ function findBinary(name) {
6155
6335
  function isScriptBinary(binaryPath) {
6156
6336
  if (!path7.isAbsolute(binaryPath)) return false;
6157
6337
  try {
6158
- const fs17 = require("fs");
6159
- const resolved = fs17.realpathSync(binaryPath);
6338
+ const fs18 = require("fs");
6339
+ const resolved = fs18.realpathSync(binaryPath);
6160
6340
  const head = Buffer.alloc(8);
6161
- const fd = fs17.openSync(resolved, "r");
6162
- fs17.readSync(fd, head, 0, 8, 0);
6163
- fs17.closeSync(fd);
6341
+ const fd = fs18.openSync(resolved, "r");
6342
+ fs18.readSync(fd, head, 0, 8, 0);
6343
+ fs18.closeSync(fd);
6164
6344
  let i = 0;
6165
6345
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
6166
6346
  return head[i] === 35 && head[i + 1] === 33;
@@ -6171,12 +6351,12 @@ function isScriptBinary(binaryPath) {
6171
6351
  function looksLikeMachOOrElf(filePath) {
6172
6352
  if (!path7.isAbsolute(filePath)) return false;
6173
6353
  try {
6174
- const fs17 = require("fs");
6175
- const resolved = fs17.realpathSync(filePath);
6354
+ const fs18 = require("fs");
6355
+ const resolved = fs18.realpathSync(filePath);
6176
6356
  const buf = Buffer.alloc(8);
6177
- const fd = fs17.openSync(resolved, "r");
6178
- fs17.readSync(fd, buf, 0, 8, 0);
6179
- fs17.closeSync(fd);
6357
+ const fd = fs18.openSync(resolved, "r");
6358
+ fs18.readSync(fd, buf, 0, 8, 0);
6359
+ fs18.closeSync(fd);
6180
6360
  let i = 0;
6181
6361
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
6182
6362
  const b = buf.subarray(i);
@@ -6273,14 +6453,14 @@ var init_provider_cli_adapter = __esm({
6273
6453
  pty2 = require("node-pty");
6274
6454
  if (os8.platform() !== "win32") {
6275
6455
  try {
6276
- const fs17 = require("fs");
6456
+ const fs18 = require("fs");
6277
6457
  const ptyDir = path7.resolve(path7.dirname(require.resolve("node-pty")), "..");
6278
6458
  const platformArch = `${os8.platform()}-${os8.arch()}`;
6279
6459
  const helper = path7.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
6280
- if (fs17.existsSync(helper)) {
6281
- const stat4 = fs17.statSync(helper);
6460
+ if (fs18.existsSync(helper)) {
6461
+ const stat4 = fs18.statSync(helper);
6282
6462
  if (!(stat4.mode & 73)) {
6283
- fs17.chmodSync(helper, stat4.mode | 493);
6463
+ fs18.chmodSync(helper, stat4.mode | 493);
6284
6464
  LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
6285
6465
  }
6286
6466
  }
@@ -8399,10 +8579,10 @@ function mergeDefs(...defs) {
8399
8579
  function cloneDef(schema) {
8400
8580
  return mergeDefs(schema._zod.def);
8401
8581
  }
8402
- function getElementAtPath(obj, path21) {
8403
- if (!path21)
8582
+ function getElementAtPath(obj, path23) {
8583
+ if (!path23)
8404
8584
  return obj;
8405
- return path21.reduce((acc, key) => acc?.[key], obj);
8585
+ return path23.reduce((acc, key) => acc?.[key], obj);
8406
8586
  }
8407
8587
  function promiseAllObject(promisesObj) {
8408
8588
  const keys = Object.keys(promisesObj);
@@ -8714,11 +8894,11 @@ function aborted(x, startIndex = 0) {
8714
8894
  }
8715
8895
  return false;
8716
8896
  }
8717
- function prefixIssues(path21, issues) {
8897
+ function prefixIssues(path23, issues) {
8718
8898
  return issues.map((iss) => {
8719
8899
  var _a2;
8720
8900
  (_a2 = iss).path ?? (_a2.path = []);
8721
- iss.path.unshift(path21);
8901
+ iss.path.unshift(path23);
8722
8902
  return iss;
8723
8903
  });
8724
8904
  }
@@ -8961,7 +9141,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
8961
9141
  }
8962
9142
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
8963
9143
  const result = { errors: [] };
8964
- const processError = (error49, path21 = []) => {
9144
+ const processError = (error49, path23 = []) => {
8965
9145
  var _a2, _b;
8966
9146
  for (const issue2 of error49.issues) {
8967
9147
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -8971,7 +9151,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
8971
9151
  } else if (issue2.code === "invalid_element") {
8972
9152
  processError({ issues: issue2.issues }, issue2.path);
8973
9153
  } else {
8974
- const fullpath = [...path21, ...issue2.path];
9154
+ const fullpath = [...path23, ...issue2.path];
8975
9155
  if (fullpath.length === 0) {
8976
9156
  result.errors.push(mapper(issue2));
8977
9157
  continue;
@@ -9003,8 +9183,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
9003
9183
  }
9004
9184
  function toDotPath(_path) {
9005
9185
  const segs = [];
9006
- const path21 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9007
- for (const seg of path21) {
9186
+ const path23 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9187
+ for (const seg of path23) {
9008
9188
  if (typeof seg === "number")
9009
9189
  segs.push(`[${seg}]`);
9010
9190
  else if (typeof seg === "symbol")
@@ -21768,13 +21948,13 @@ function resolveRef(ref, ctx) {
21768
21948
  if (!ref.startsWith("#")) {
21769
21949
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
21770
21950
  }
21771
- const path21 = ref.slice(1).split("/").filter(Boolean);
21772
- if (path21.length === 0) {
21951
+ const path23 = ref.slice(1).split("/").filter(Boolean);
21952
+ if (path23.length === 0) {
21773
21953
  return ctx.rootSchema;
21774
21954
  }
21775
21955
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
21776
- if (path21[0] === defsKey) {
21777
- const key = path21[1];
21956
+ if (path23[0] === defsKey) {
21957
+ const key = path23[1];
21778
21958
  if (!key || !ctx.defs[key]) {
21779
21959
  throw new Error(`Reference not found: ${ref}`);
21780
21960
  }
@@ -25634,8 +25814,8 @@ var init_cli_manager = __esm({
25634
25814
  const spawnCmd = provider.spawn?.command;
25635
25815
  if (spawnCmd) {
25636
25816
  try {
25637
- const { execSync: execSync6 } = require("child_process");
25638
- execSync6(`which ${spawnCmd}`, { stdio: "ignore" });
25817
+ const { execSync: execSync7 } = require("child_process");
25818
+ execSync7(`which ${spawnCmd}`, { stdio: "ignore" });
25639
25819
  } catch {
25640
25820
  const installInfo = provider.install || `Install: check ${provider.displayName || provider.name} documentation`;
25641
25821
  throw new Error(
@@ -26162,7 +26342,7 @@ var init_readdirp = __esm({
26162
26342
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
26163
26343
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
26164
26344
  if (wantBigintFsStats) {
26165
- this._stat = (path21) => statMethod(path21, { bigint: true });
26345
+ this._stat = (path23) => statMethod(path23, { bigint: true });
26166
26346
  } else {
26167
26347
  this._stat = statMethod;
26168
26348
  }
@@ -26187,8 +26367,8 @@ var init_readdirp = __esm({
26187
26367
  const par = this.parent;
26188
26368
  const fil = par && par.files;
26189
26369
  if (fil && fil.length > 0) {
26190
- const { path: path21, depth } = par;
26191
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path21));
26370
+ const { path: path23, depth } = par;
26371
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path23));
26192
26372
  const awaited = await Promise.all(slice);
26193
26373
  for (const entry of awaited) {
26194
26374
  if (!entry)
@@ -26228,20 +26408,20 @@ var init_readdirp = __esm({
26228
26408
  this.reading = false;
26229
26409
  }
26230
26410
  }
26231
- async _exploreDir(path21, depth) {
26411
+ async _exploreDir(path23, depth) {
26232
26412
  let files;
26233
26413
  try {
26234
- files = await (0, import_promises.readdir)(path21, this._rdOptions);
26414
+ files = await (0, import_promises.readdir)(path23, this._rdOptions);
26235
26415
  } catch (error48) {
26236
26416
  this._onError(error48);
26237
26417
  }
26238
- return { files, depth, path: path21 };
26418
+ return { files, depth, path: path23 };
26239
26419
  }
26240
- async _formatEntry(dirent, path21) {
26420
+ async _formatEntry(dirent, path23) {
26241
26421
  let entry;
26242
26422
  const basename7 = this._isDirent ? dirent.name : dirent;
26243
26423
  try {
26244
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path21, basename7));
26424
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path23, basename7));
26245
26425
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
26246
26426
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
26247
26427
  } catch (err) {
@@ -26298,16 +26478,16 @@ var init_readdirp = __esm({
26298
26478
  });
26299
26479
 
26300
26480
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
26301
- function createFsWatchInstance(path21, options, listener, errHandler, emitRaw) {
26481
+ function createFsWatchInstance(path23, options, listener, errHandler, emitRaw) {
26302
26482
  const handleEvent = (rawEvent, evPath) => {
26303
- listener(path21);
26304
- emitRaw(rawEvent, evPath, { watchedPath: path21 });
26305
- if (evPath && path21 !== evPath) {
26306
- fsWatchBroadcast(sp.resolve(path21, evPath), KEY_LISTENERS, sp.join(path21, evPath));
26483
+ listener(path23);
26484
+ emitRaw(rawEvent, evPath, { watchedPath: path23 });
26485
+ if (evPath && path23 !== evPath) {
26486
+ fsWatchBroadcast(sp.resolve(path23, evPath), KEY_LISTENERS, sp.join(path23, evPath));
26307
26487
  }
26308
26488
  };
26309
26489
  try {
26310
- return (0, import_node_fs.watch)(path21, {
26490
+ return (0, import_node_fs.watch)(path23, {
26311
26491
  persistent: options.persistent
26312
26492
  }, handleEvent);
26313
26493
  } catch (error48) {
@@ -26656,12 +26836,12 @@ var init_handler2 = __esm({
26656
26836
  listener(val1, val2, val3);
26657
26837
  });
26658
26838
  };
26659
- setFsWatchListener = (path21, fullPath, options, handlers) => {
26839
+ setFsWatchListener = (path23, fullPath, options, handlers) => {
26660
26840
  const { listener, errHandler, rawEmitter } = handlers;
26661
26841
  let cont = FsWatchInstances.get(fullPath);
26662
26842
  let watcher;
26663
26843
  if (!options.persistent) {
26664
- watcher = createFsWatchInstance(path21, options, listener, errHandler, rawEmitter);
26844
+ watcher = createFsWatchInstance(path23, options, listener, errHandler, rawEmitter);
26665
26845
  if (!watcher)
26666
26846
  return;
26667
26847
  return watcher.close.bind(watcher);
@@ -26672,7 +26852,7 @@ var init_handler2 = __esm({
26672
26852
  addAndConvert(cont, KEY_RAW, rawEmitter);
26673
26853
  } else {
26674
26854
  watcher = createFsWatchInstance(
26675
- path21,
26855
+ path23,
26676
26856
  options,
26677
26857
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
26678
26858
  errHandler,
@@ -26687,7 +26867,7 @@ var init_handler2 = __esm({
26687
26867
  cont.watcherUnusable = true;
26688
26868
  if (isWindows && error48.code === "EPERM") {
26689
26869
  try {
26690
- const fd = await (0, import_promises2.open)(path21, "r");
26870
+ const fd = await (0, import_promises2.open)(path23, "r");
26691
26871
  await fd.close();
26692
26872
  broadcastErr(error48);
26693
26873
  } catch (err) {
@@ -26718,7 +26898,7 @@ var init_handler2 = __esm({
26718
26898
  };
26719
26899
  };
26720
26900
  FsWatchFileInstances = /* @__PURE__ */ new Map();
26721
- setFsWatchFileListener = (path21, fullPath, options, handlers) => {
26901
+ setFsWatchFileListener = (path23, fullPath, options, handlers) => {
26722
26902
  const { listener, rawEmitter } = handlers;
26723
26903
  let cont = FsWatchFileInstances.get(fullPath);
26724
26904
  const copts = cont && cont.options;
@@ -26740,7 +26920,7 @@ var init_handler2 = __esm({
26740
26920
  });
26741
26921
  const currmtime = curr.mtimeMs;
26742
26922
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
26743
- foreach(cont.listeners, (listener2) => listener2(path21, curr));
26923
+ foreach(cont.listeners, (listener2) => listener2(path23, curr));
26744
26924
  }
26745
26925
  })
26746
26926
  };
@@ -26770,13 +26950,13 @@ var init_handler2 = __esm({
26770
26950
  * @param listener on fs change
26771
26951
  * @returns closer for the watcher instance
26772
26952
  */
26773
- _watchWithNodeFs(path21, listener) {
26953
+ _watchWithNodeFs(path23, listener) {
26774
26954
  const opts = this.fsw.options;
26775
- const directory = sp.dirname(path21);
26776
- const basename7 = sp.basename(path21);
26955
+ const directory = sp.dirname(path23);
26956
+ const basename7 = sp.basename(path23);
26777
26957
  const parent = this.fsw._getWatchedDir(directory);
26778
26958
  parent.add(basename7);
26779
- const absolutePath = sp.resolve(path21);
26959
+ const absolutePath = sp.resolve(path23);
26780
26960
  const options = {
26781
26961
  persistent: opts.persistent
26782
26962
  };
@@ -26786,12 +26966,12 @@ var init_handler2 = __esm({
26786
26966
  if (opts.usePolling) {
26787
26967
  const enableBin = opts.interval !== opts.binaryInterval;
26788
26968
  options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
26789
- closer = setFsWatchFileListener(path21, absolutePath, options, {
26969
+ closer = setFsWatchFileListener(path23, absolutePath, options, {
26790
26970
  listener,
26791
26971
  rawEmitter: this.fsw._emitRaw
26792
26972
  });
26793
26973
  } else {
26794
- closer = setFsWatchListener(path21, absolutePath, options, {
26974
+ closer = setFsWatchListener(path23, absolutePath, options, {
26795
26975
  listener,
26796
26976
  errHandler: this._boundHandleError,
26797
26977
  rawEmitter: this.fsw._emitRaw
@@ -26813,7 +26993,7 @@ var init_handler2 = __esm({
26813
26993
  let prevStats = stats;
26814
26994
  if (parent.has(basename7))
26815
26995
  return;
26816
- const listener = async (path21, newStats) => {
26996
+ const listener = async (path23, newStats) => {
26817
26997
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
26818
26998
  return;
26819
26999
  if (!newStats || newStats.mtimeMs === 0) {
@@ -26827,11 +27007,11 @@ var init_handler2 = __esm({
26827
27007
  this.fsw._emit(EV.CHANGE, file2, newStats2);
26828
27008
  }
26829
27009
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
26830
- this.fsw._closeFile(path21);
27010
+ this.fsw._closeFile(path23);
26831
27011
  prevStats = newStats2;
26832
27012
  const closer2 = this._watchWithNodeFs(file2, listener);
26833
27013
  if (closer2)
26834
- this.fsw._addPathCloser(path21, closer2);
27014
+ this.fsw._addPathCloser(path23, closer2);
26835
27015
  } else {
26836
27016
  prevStats = newStats2;
26837
27017
  }
@@ -26863,7 +27043,7 @@ var init_handler2 = __esm({
26863
27043
  * @param item basename of this item
26864
27044
  * @returns true if no more processing is needed for this entry.
26865
27045
  */
26866
- async _handleSymlink(entry, directory, path21, item) {
27046
+ async _handleSymlink(entry, directory, path23, item) {
26867
27047
  if (this.fsw.closed) {
26868
27048
  return;
26869
27049
  }
@@ -26873,7 +27053,7 @@ var init_handler2 = __esm({
26873
27053
  this.fsw._incrReadyCount();
26874
27054
  let linkPath;
26875
27055
  try {
26876
- linkPath = await (0, import_promises2.realpath)(path21);
27056
+ linkPath = await (0, import_promises2.realpath)(path23);
26877
27057
  } catch (e) {
26878
27058
  this.fsw._emitReady();
26879
27059
  return true;
@@ -26883,12 +27063,12 @@ var init_handler2 = __esm({
26883
27063
  if (dir.has(item)) {
26884
27064
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
26885
27065
  this.fsw._symlinkPaths.set(full, linkPath);
26886
- this.fsw._emit(EV.CHANGE, path21, entry.stats);
27066
+ this.fsw._emit(EV.CHANGE, path23, entry.stats);
26887
27067
  }
26888
27068
  } else {
26889
27069
  dir.add(item);
26890
27070
  this.fsw._symlinkPaths.set(full, linkPath);
26891
- this.fsw._emit(EV.ADD, path21, entry.stats);
27071
+ this.fsw._emit(EV.ADD, path23, entry.stats);
26892
27072
  }
26893
27073
  this.fsw._emitReady();
26894
27074
  return true;
@@ -26918,9 +27098,9 @@ var init_handler2 = __esm({
26918
27098
  return;
26919
27099
  }
26920
27100
  const item = entry.path;
26921
- let path21 = sp.join(directory, item);
27101
+ let path23 = sp.join(directory, item);
26922
27102
  current.add(item);
26923
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path21, item)) {
27103
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path23, item)) {
26924
27104
  return;
26925
27105
  }
26926
27106
  if (this.fsw.closed) {
@@ -26929,8 +27109,8 @@ var init_handler2 = __esm({
26929
27109
  }
26930
27110
  if (item === target || !target && !previous.has(item)) {
26931
27111
  this.fsw._incrReadyCount();
26932
- path21 = sp.join(dir, sp.relative(dir, path21));
26933
- this._addToNodeFs(path21, initialAdd, wh, depth + 1);
27112
+ path23 = sp.join(dir, sp.relative(dir, path23));
27113
+ this._addToNodeFs(path23, initialAdd, wh, depth + 1);
26934
27114
  }
26935
27115
  }).on(EV.ERROR, this._boundHandleError);
26936
27116
  return new Promise((resolve13, reject) => {
@@ -26999,13 +27179,13 @@ var init_handler2 = __esm({
26999
27179
  * @param depth Child path actually targeted for watch
27000
27180
  * @param target Child path actually targeted for watch
27001
27181
  */
27002
- async _addToNodeFs(path21, initialAdd, priorWh, depth, target) {
27182
+ async _addToNodeFs(path23, initialAdd, priorWh, depth, target) {
27003
27183
  const ready = this.fsw._emitReady;
27004
- if (this.fsw._isIgnored(path21) || this.fsw.closed) {
27184
+ if (this.fsw._isIgnored(path23) || this.fsw.closed) {
27005
27185
  ready();
27006
27186
  return false;
27007
27187
  }
27008
- const wh = this.fsw._getWatchHelpers(path21);
27188
+ const wh = this.fsw._getWatchHelpers(path23);
27009
27189
  if (priorWh) {
27010
27190
  wh.filterPath = (entry) => priorWh.filterPath(entry);
27011
27191
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -27021,8 +27201,8 @@ var init_handler2 = __esm({
27021
27201
  const follow = this.fsw.options.followSymlinks;
27022
27202
  let closer;
27023
27203
  if (stats.isDirectory()) {
27024
- const absPath = sp.resolve(path21);
27025
- const targetPath = follow ? await (0, import_promises2.realpath)(path21) : path21;
27204
+ const absPath = sp.resolve(path23);
27205
+ const targetPath = follow ? await (0, import_promises2.realpath)(path23) : path23;
27026
27206
  if (this.fsw.closed)
27027
27207
  return;
27028
27208
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -27032,29 +27212,29 @@ var init_handler2 = __esm({
27032
27212
  this.fsw._symlinkPaths.set(absPath, targetPath);
27033
27213
  }
27034
27214
  } else if (stats.isSymbolicLink()) {
27035
- const targetPath = follow ? await (0, import_promises2.realpath)(path21) : path21;
27215
+ const targetPath = follow ? await (0, import_promises2.realpath)(path23) : path23;
27036
27216
  if (this.fsw.closed)
27037
27217
  return;
27038
27218
  const parent = sp.dirname(wh.watchPath);
27039
27219
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
27040
27220
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
27041
- closer = await this._handleDir(parent, stats, initialAdd, depth, path21, wh, targetPath);
27221
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path23, wh, targetPath);
27042
27222
  if (this.fsw.closed)
27043
27223
  return;
27044
27224
  if (targetPath !== void 0) {
27045
- this.fsw._symlinkPaths.set(sp.resolve(path21), targetPath);
27225
+ this.fsw._symlinkPaths.set(sp.resolve(path23), targetPath);
27046
27226
  }
27047
27227
  } else {
27048
27228
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
27049
27229
  }
27050
27230
  ready();
27051
27231
  if (closer)
27052
- this.fsw._addPathCloser(path21, closer);
27232
+ this.fsw._addPathCloser(path23, closer);
27053
27233
  return false;
27054
27234
  } catch (error48) {
27055
27235
  if (this.fsw._handleError(error48)) {
27056
27236
  ready();
27057
- return path21;
27237
+ return path23;
27058
27238
  }
27059
27239
  }
27060
27240
  }
@@ -27089,24 +27269,24 @@ function createPattern(matcher) {
27089
27269
  }
27090
27270
  return () => false;
27091
27271
  }
27092
- function normalizePath(path21) {
27093
- if (typeof path21 !== "string")
27272
+ function normalizePath(path23) {
27273
+ if (typeof path23 !== "string")
27094
27274
  throw new Error("string expected");
27095
- path21 = sp2.normalize(path21);
27096
- path21 = path21.replace(/\\/g, "/");
27275
+ path23 = sp2.normalize(path23);
27276
+ path23 = path23.replace(/\\/g, "/");
27097
27277
  let prepend = false;
27098
- if (path21.startsWith("//"))
27278
+ if (path23.startsWith("//"))
27099
27279
  prepend = true;
27100
- path21 = path21.replace(DOUBLE_SLASH_RE, "/");
27280
+ path23 = path23.replace(DOUBLE_SLASH_RE, "/");
27101
27281
  if (prepend)
27102
- path21 = "/" + path21;
27103
- return path21;
27282
+ path23 = "/" + path23;
27283
+ return path23;
27104
27284
  }
27105
27285
  function matchPatterns(patterns, testString, stats) {
27106
- const path21 = normalizePath(testString);
27286
+ const path23 = normalizePath(testString);
27107
27287
  for (let index = 0; index < patterns.length; index++) {
27108
27288
  const pattern = patterns[index];
27109
- if (pattern(path21, stats)) {
27289
+ if (pattern(path23, stats)) {
27110
27290
  return true;
27111
27291
  }
27112
27292
  }
@@ -27169,19 +27349,19 @@ var init_chokidar = __esm({
27169
27349
  }
27170
27350
  return str;
27171
27351
  };
27172
- normalizePathToUnix = (path21) => toUnix(sp2.normalize(toUnix(path21)));
27173
- normalizeIgnored = (cwd = "") => (path21) => {
27174
- if (typeof path21 === "string") {
27175
- return normalizePathToUnix(sp2.isAbsolute(path21) ? path21 : sp2.join(cwd, path21));
27352
+ normalizePathToUnix = (path23) => toUnix(sp2.normalize(toUnix(path23)));
27353
+ normalizeIgnored = (cwd = "") => (path23) => {
27354
+ if (typeof path23 === "string") {
27355
+ return normalizePathToUnix(sp2.isAbsolute(path23) ? path23 : sp2.join(cwd, path23));
27176
27356
  } else {
27177
- return path21;
27357
+ return path23;
27178
27358
  }
27179
27359
  };
27180
- getAbsolutePath = (path21, cwd) => {
27181
- if (sp2.isAbsolute(path21)) {
27182
- return path21;
27360
+ getAbsolutePath = (path23, cwd) => {
27361
+ if (sp2.isAbsolute(path23)) {
27362
+ return path23;
27183
27363
  }
27184
- return sp2.join(cwd, path21);
27364
+ return sp2.join(cwd, path23);
27185
27365
  };
27186
27366
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
27187
27367
  DirEntry = class {
@@ -27246,10 +27426,10 @@ var init_chokidar = __esm({
27246
27426
  dirParts;
27247
27427
  followSymlinks;
27248
27428
  statMethod;
27249
- constructor(path21, follow, fsw) {
27429
+ constructor(path23, follow, fsw) {
27250
27430
  this.fsw = fsw;
27251
- const watchPath = path21;
27252
- this.path = path21 = path21.replace(REPLACER_RE, "");
27431
+ const watchPath = path23;
27432
+ this.path = path23 = path23.replace(REPLACER_RE, "");
27253
27433
  this.watchPath = watchPath;
27254
27434
  this.fullWatchPath = sp2.resolve(watchPath);
27255
27435
  this.dirParts = [];
@@ -27389,20 +27569,20 @@ var init_chokidar = __esm({
27389
27569
  this._closePromise = void 0;
27390
27570
  let paths = unifyPaths(paths_);
27391
27571
  if (cwd) {
27392
- paths = paths.map((path21) => {
27393
- const absPath = getAbsolutePath(path21, cwd);
27572
+ paths = paths.map((path23) => {
27573
+ const absPath = getAbsolutePath(path23, cwd);
27394
27574
  return absPath;
27395
27575
  });
27396
27576
  }
27397
- paths.forEach((path21) => {
27398
- this._removeIgnoredPath(path21);
27577
+ paths.forEach((path23) => {
27578
+ this._removeIgnoredPath(path23);
27399
27579
  });
27400
27580
  this._userIgnored = void 0;
27401
27581
  if (!this._readyCount)
27402
27582
  this._readyCount = 0;
27403
27583
  this._readyCount += paths.length;
27404
- Promise.all(paths.map(async (path21) => {
27405
- const res = await this._nodeFsHandler._addToNodeFs(path21, !_internal, void 0, 0, _origAdd);
27584
+ Promise.all(paths.map(async (path23) => {
27585
+ const res = await this._nodeFsHandler._addToNodeFs(path23, !_internal, void 0, 0, _origAdd);
27406
27586
  if (res)
27407
27587
  this._emitReady();
27408
27588
  return res;
@@ -27424,17 +27604,17 @@ var init_chokidar = __esm({
27424
27604
  return this;
27425
27605
  const paths = unifyPaths(paths_);
27426
27606
  const { cwd } = this.options;
27427
- paths.forEach((path21) => {
27428
- if (!sp2.isAbsolute(path21) && !this._closers.has(path21)) {
27607
+ paths.forEach((path23) => {
27608
+ if (!sp2.isAbsolute(path23) && !this._closers.has(path23)) {
27429
27609
  if (cwd)
27430
- path21 = sp2.join(cwd, path21);
27431
- path21 = sp2.resolve(path21);
27610
+ path23 = sp2.join(cwd, path23);
27611
+ path23 = sp2.resolve(path23);
27432
27612
  }
27433
- this._closePath(path21);
27434
- this._addIgnoredPath(path21);
27435
- if (this._watched.has(path21)) {
27613
+ this._closePath(path23);
27614
+ this._addIgnoredPath(path23);
27615
+ if (this._watched.has(path23)) {
27436
27616
  this._addIgnoredPath({
27437
- path: path21,
27617
+ path: path23,
27438
27618
  recursive: true
27439
27619
  });
27440
27620
  }
@@ -27498,38 +27678,38 @@ var init_chokidar = __esm({
27498
27678
  * @param stats arguments to be passed with event
27499
27679
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
27500
27680
  */
27501
- async _emit(event, path21, stats) {
27681
+ async _emit(event, path23, stats) {
27502
27682
  if (this.closed)
27503
27683
  return;
27504
27684
  const opts = this.options;
27505
27685
  if (isWindows)
27506
- path21 = sp2.normalize(path21);
27686
+ path23 = sp2.normalize(path23);
27507
27687
  if (opts.cwd)
27508
- path21 = sp2.relative(opts.cwd, path21);
27509
- const args = [path21];
27688
+ path23 = sp2.relative(opts.cwd, path23);
27689
+ const args = [path23];
27510
27690
  if (stats != null)
27511
27691
  args.push(stats);
27512
27692
  const awf = opts.awaitWriteFinish;
27513
27693
  let pw;
27514
- if (awf && (pw = this._pendingWrites.get(path21))) {
27694
+ if (awf && (pw = this._pendingWrites.get(path23))) {
27515
27695
  pw.lastChange = /* @__PURE__ */ new Date();
27516
27696
  return this;
27517
27697
  }
27518
27698
  if (opts.atomic) {
27519
27699
  if (event === EVENTS.UNLINK) {
27520
- this._pendingUnlinks.set(path21, [event, ...args]);
27700
+ this._pendingUnlinks.set(path23, [event, ...args]);
27521
27701
  setTimeout(() => {
27522
- this._pendingUnlinks.forEach((entry, path23) => {
27702
+ this._pendingUnlinks.forEach((entry, path24) => {
27523
27703
  this.emit(...entry);
27524
27704
  this.emit(EVENTS.ALL, ...entry);
27525
- this._pendingUnlinks.delete(path23);
27705
+ this._pendingUnlinks.delete(path24);
27526
27706
  });
27527
27707
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
27528
27708
  return this;
27529
27709
  }
27530
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path21)) {
27710
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path23)) {
27531
27711
  event = EVENTS.CHANGE;
27532
- this._pendingUnlinks.delete(path21);
27712
+ this._pendingUnlinks.delete(path23);
27533
27713
  }
27534
27714
  }
27535
27715
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -27547,16 +27727,16 @@ var init_chokidar = __esm({
27547
27727
  this.emitWithAll(event, args);
27548
27728
  }
27549
27729
  };
27550
- this._awaitWriteFinish(path21, awf.stabilityThreshold, event, awfEmit);
27730
+ this._awaitWriteFinish(path23, awf.stabilityThreshold, event, awfEmit);
27551
27731
  return this;
27552
27732
  }
27553
27733
  if (event === EVENTS.CHANGE) {
27554
- const isThrottled = !this._throttle(EVENTS.CHANGE, path21, 50);
27734
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path23, 50);
27555
27735
  if (isThrottled)
27556
27736
  return this;
27557
27737
  }
27558
27738
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
27559
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path21) : path21;
27739
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path23) : path23;
27560
27740
  let stats2;
27561
27741
  try {
27562
27742
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -27587,23 +27767,23 @@ var init_chokidar = __esm({
27587
27767
  * @param timeout duration of time to suppress duplicate actions
27588
27768
  * @returns tracking object or false if action should be suppressed
27589
27769
  */
27590
- _throttle(actionType, path21, timeout) {
27770
+ _throttle(actionType, path23, timeout) {
27591
27771
  if (!this._throttled.has(actionType)) {
27592
27772
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
27593
27773
  }
27594
27774
  const action = this._throttled.get(actionType);
27595
27775
  if (!action)
27596
27776
  throw new Error("invalid throttle");
27597
- const actionPath = action.get(path21);
27777
+ const actionPath = action.get(path23);
27598
27778
  if (actionPath) {
27599
27779
  actionPath.count++;
27600
27780
  return false;
27601
27781
  }
27602
27782
  let timeoutObject;
27603
27783
  const clear = () => {
27604
- const item = action.get(path21);
27784
+ const item = action.get(path23);
27605
27785
  const count = item ? item.count : 0;
27606
- action.delete(path21);
27786
+ action.delete(path23);
27607
27787
  clearTimeout(timeoutObject);
27608
27788
  if (item)
27609
27789
  clearTimeout(item.timeoutObject);
@@ -27611,7 +27791,7 @@ var init_chokidar = __esm({
27611
27791
  };
27612
27792
  timeoutObject = setTimeout(clear, timeout);
27613
27793
  const thr = { timeoutObject, clear, count: 0 };
27614
- action.set(path21, thr);
27794
+ action.set(path23, thr);
27615
27795
  return thr;
27616
27796
  }
27617
27797
  _incrReadyCount() {
@@ -27625,44 +27805,44 @@ var init_chokidar = __esm({
27625
27805
  * @param event
27626
27806
  * @param awfEmit Callback to be called when ready for event to be emitted.
27627
27807
  */
27628
- _awaitWriteFinish(path21, threshold, event, awfEmit) {
27808
+ _awaitWriteFinish(path23, threshold, event, awfEmit) {
27629
27809
  const awf = this.options.awaitWriteFinish;
27630
27810
  if (typeof awf !== "object")
27631
27811
  return;
27632
27812
  const pollInterval = awf.pollInterval;
27633
27813
  let timeoutHandler;
27634
- let fullPath = path21;
27635
- if (this.options.cwd && !sp2.isAbsolute(path21)) {
27636
- fullPath = sp2.join(this.options.cwd, path21);
27814
+ let fullPath = path23;
27815
+ if (this.options.cwd && !sp2.isAbsolute(path23)) {
27816
+ fullPath = sp2.join(this.options.cwd, path23);
27637
27817
  }
27638
27818
  const now = /* @__PURE__ */ new Date();
27639
27819
  const writes = this._pendingWrites;
27640
27820
  function awaitWriteFinishFn(prevStat) {
27641
27821
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
27642
- if (err || !writes.has(path21)) {
27822
+ if (err || !writes.has(path23)) {
27643
27823
  if (err && err.code !== "ENOENT")
27644
27824
  awfEmit(err);
27645
27825
  return;
27646
27826
  }
27647
27827
  const now2 = Number(/* @__PURE__ */ new Date());
27648
27828
  if (prevStat && curStat.size !== prevStat.size) {
27649
- writes.get(path21).lastChange = now2;
27829
+ writes.get(path23).lastChange = now2;
27650
27830
  }
27651
- const pw = writes.get(path21);
27831
+ const pw = writes.get(path23);
27652
27832
  const df = now2 - pw.lastChange;
27653
27833
  if (df >= threshold) {
27654
- writes.delete(path21);
27834
+ writes.delete(path23);
27655
27835
  awfEmit(void 0, curStat);
27656
27836
  } else {
27657
27837
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
27658
27838
  }
27659
27839
  });
27660
27840
  }
27661
- if (!writes.has(path21)) {
27662
- writes.set(path21, {
27841
+ if (!writes.has(path23)) {
27842
+ writes.set(path23, {
27663
27843
  lastChange: now,
27664
27844
  cancelWait: () => {
27665
- writes.delete(path21);
27845
+ writes.delete(path23);
27666
27846
  clearTimeout(timeoutHandler);
27667
27847
  return event;
27668
27848
  }
@@ -27673,8 +27853,8 @@ var init_chokidar = __esm({
27673
27853
  /**
27674
27854
  * Determines whether user has asked to ignore this path.
27675
27855
  */
27676
- _isIgnored(path21, stats) {
27677
- if (this.options.atomic && DOT_RE.test(path21))
27856
+ _isIgnored(path23, stats) {
27857
+ if (this.options.atomic && DOT_RE.test(path23))
27678
27858
  return true;
27679
27859
  if (!this._userIgnored) {
27680
27860
  const { cwd } = this.options;
@@ -27684,17 +27864,17 @@ var init_chokidar = __esm({
27684
27864
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
27685
27865
  this._userIgnored = anymatch(list, void 0);
27686
27866
  }
27687
- return this._userIgnored(path21, stats);
27867
+ return this._userIgnored(path23, stats);
27688
27868
  }
27689
- _isntIgnored(path21, stat4) {
27690
- return !this._isIgnored(path21, stat4);
27869
+ _isntIgnored(path23, stat4) {
27870
+ return !this._isIgnored(path23, stat4);
27691
27871
  }
27692
27872
  /**
27693
27873
  * Provides a set of common helpers and properties relating to symlink handling.
27694
27874
  * @param path file or directory pattern being watched
27695
27875
  */
27696
- _getWatchHelpers(path21) {
27697
- return new WatchHelper(path21, this.options.followSymlinks, this);
27876
+ _getWatchHelpers(path23) {
27877
+ return new WatchHelper(path23, this.options.followSymlinks, this);
27698
27878
  }
27699
27879
  // Directory helpers
27700
27880
  // -----------------
@@ -27726,63 +27906,63 @@ var init_chokidar = __esm({
27726
27906
  * @param item base path of item/directory
27727
27907
  */
27728
27908
  _remove(directory, item, isDirectory) {
27729
- const path21 = sp2.join(directory, item);
27730
- const fullPath = sp2.resolve(path21);
27731
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path21) || this._watched.has(fullPath);
27732
- if (!this._throttle("remove", path21, 100))
27909
+ const path23 = sp2.join(directory, item);
27910
+ const fullPath = sp2.resolve(path23);
27911
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path23) || this._watched.has(fullPath);
27912
+ if (!this._throttle("remove", path23, 100))
27733
27913
  return;
27734
27914
  if (!isDirectory && this._watched.size === 1) {
27735
27915
  this.add(directory, item, true);
27736
27916
  }
27737
- const wp = this._getWatchedDir(path21);
27917
+ const wp = this._getWatchedDir(path23);
27738
27918
  const nestedDirectoryChildren = wp.getChildren();
27739
- nestedDirectoryChildren.forEach((nested) => this._remove(path21, nested));
27919
+ nestedDirectoryChildren.forEach((nested) => this._remove(path23, nested));
27740
27920
  const parent = this._getWatchedDir(directory);
27741
27921
  const wasTracked = parent.has(item);
27742
27922
  parent.remove(item);
27743
27923
  if (this._symlinkPaths.has(fullPath)) {
27744
27924
  this._symlinkPaths.delete(fullPath);
27745
27925
  }
27746
- let relPath = path21;
27926
+ let relPath = path23;
27747
27927
  if (this.options.cwd)
27748
- relPath = sp2.relative(this.options.cwd, path21);
27928
+ relPath = sp2.relative(this.options.cwd, path23);
27749
27929
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
27750
27930
  const event = this._pendingWrites.get(relPath).cancelWait();
27751
27931
  if (event === EVENTS.ADD)
27752
27932
  return;
27753
27933
  }
27754
- this._watched.delete(path21);
27934
+ this._watched.delete(path23);
27755
27935
  this._watched.delete(fullPath);
27756
27936
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
27757
- if (wasTracked && !this._isIgnored(path21))
27758
- this._emit(eventName, path21);
27759
- this._closePath(path21);
27937
+ if (wasTracked && !this._isIgnored(path23))
27938
+ this._emit(eventName, path23);
27939
+ this._closePath(path23);
27760
27940
  }
27761
27941
  /**
27762
27942
  * Closes all watchers for a path
27763
27943
  */
27764
- _closePath(path21) {
27765
- this._closeFile(path21);
27766
- const dir = sp2.dirname(path21);
27767
- this._getWatchedDir(dir).remove(sp2.basename(path21));
27944
+ _closePath(path23) {
27945
+ this._closeFile(path23);
27946
+ const dir = sp2.dirname(path23);
27947
+ this._getWatchedDir(dir).remove(sp2.basename(path23));
27768
27948
  }
27769
27949
  /**
27770
27950
  * Closes only file-specific watchers
27771
27951
  */
27772
- _closeFile(path21) {
27773
- const closers = this._closers.get(path21);
27952
+ _closeFile(path23) {
27953
+ const closers = this._closers.get(path23);
27774
27954
  if (!closers)
27775
27955
  return;
27776
27956
  closers.forEach((closer) => closer());
27777
- this._closers.delete(path21);
27957
+ this._closers.delete(path23);
27778
27958
  }
27779
- _addPathCloser(path21, closer) {
27959
+ _addPathCloser(path23, closer) {
27780
27960
  if (!closer)
27781
27961
  return;
27782
- let list = this._closers.get(path21);
27962
+ let list = this._closers.get(path23);
27783
27963
  if (!list) {
27784
27964
  list = [];
27785
- this._closers.set(path21, list);
27965
+ this._closers.set(path23, list);
27786
27966
  }
27787
27967
  list.push(closer);
27788
27968
  }
@@ -28374,7 +28554,7 @@ var init_provider_loader = __esm({
28374
28554
  return { updated: false };
28375
28555
  }
28376
28556
  const https = require("https");
28377
- const { execSync: execSync6 } = require("child_process");
28557
+ const { execSync: execSync7 } = require("child_process");
28378
28558
  const metaPath = path10.join(this.upstreamDir, _ProviderLoader.META_FILE);
28379
28559
  let prevEtag = "";
28380
28560
  let prevTimestamp = 0;
@@ -28439,7 +28619,7 @@ var init_provider_loader = __esm({
28439
28619
  const tmpExtract = path10.join(os11.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
28440
28620
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
28441
28621
  fs6.mkdirSync(tmpExtract, { recursive: true });
28442
- execSync6(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
28622
+ execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
28443
28623
  const extracted = fs6.readdirSync(tmpExtract);
28444
28624
  const rootDir = extracted.find(
28445
28625
  (d) => fs6.statSync(path10.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
@@ -29012,7 +29192,7 @@ function detectCurrentWorkspace(ideId) {
29012
29192
  }
29013
29193
  } else if (plat === "win32") {
29014
29194
  try {
29015
- const fs17 = require("fs");
29195
+ const fs18 = require("fs");
29016
29196
  const appNameMap = getMacAppIdentifiers();
29017
29197
  const appName = appNameMap[ideId];
29018
29198
  if (appName) {
@@ -29021,8 +29201,8 @@ function detectCurrentWorkspace(ideId) {
29021
29201
  appName,
29022
29202
  "storage.json"
29023
29203
  );
29024
- if (fs17.existsSync(storagePath)) {
29025
- const data = JSON.parse(fs17.readFileSync(storagePath, "utf-8"));
29204
+ if (fs18.existsSync(storagePath)) {
29205
+ const data = JSON.parse(fs18.readFileSync(storagePath, "utf-8"));
29026
29206
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
29027
29207
  if (workspaces.length > 0) {
29028
29208
  const recent = workspaces[0];
@@ -29180,6 +29360,9 @@ async function launchLinux(ide, port, workspace, newWindow) {
29180
29360
  if (workspace) args.push(workspace);
29181
29361
  (0, import_child_process6.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
29182
29362
  }
29363
+ function getAvailableIdeIds() {
29364
+ return getProviderLoader().getAvailableIdeTypes();
29365
+ }
29183
29366
  var import_child_process6, net, os12, path11, _providerLoader;
29184
29367
  var init_launch = __esm({
29185
29368
  "../../oss/packages/daemon-core/src/launch.ts"() {
@@ -29274,6 +29457,31 @@ function logCommand(entry) {
29274
29457
  } catch {
29275
29458
  }
29276
29459
  }
29460
+ function getRecentCommands(count = 50) {
29461
+ try {
29462
+ if (!fs7.existsSync(currentFile)) return [];
29463
+ const content = fs7.readFileSync(currentFile, "utf-8");
29464
+ const lines = content.trim().split("\n").filter(Boolean);
29465
+ return lines.slice(-count).map((line) => {
29466
+ try {
29467
+ const parsed = JSON.parse(line);
29468
+ return {
29469
+ ts: parsed.ts,
29470
+ cmd: parsed.cmd,
29471
+ source: parsed.src,
29472
+ args: parsed.args,
29473
+ success: parsed.ok,
29474
+ error: parsed.err,
29475
+ durationMs: parsed.ms
29476
+ };
29477
+ } catch {
29478
+ return { ts: "", cmd: "parse_error", source: "unknown" };
29479
+ }
29480
+ });
29481
+ } catch {
29482
+ return [];
29483
+ }
29484
+ }
29277
29485
  var fs7, path12, os13, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
29278
29486
  var init_command_log = __esm({
29279
29487
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
@@ -29463,9 +29671,119 @@ var init_snapshot = __esm({
29463
29671
  });
29464
29672
 
29465
29673
  // ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
29674
+ function getUpgradeLogPath() {
29675
+ const home = os15.homedir();
29676
+ const dir = path13.join(home, ".adhdev");
29677
+ fs8.mkdirSync(dir, { recursive: true });
29678
+ return path13.join(dir, "daemon-upgrade.log");
29679
+ }
29680
+ function appendUpgradeLog(message) {
29681
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
29682
+ `;
29683
+ try {
29684
+ fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
29685
+ } catch {
29686
+ }
29687
+ }
29688
+ function getNpmExecutable() {
29689
+ return process.platform === "win32" ? "npm.cmd" : "npm";
29690
+ }
29691
+ function killPid(pid) {
29692
+ try {
29693
+ if (process.platform === "win32") {
29694
+ (0, import_child_process7.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
29695
+ } else {
29696
+ process.kill(pid, "SIGTERM");
29697
+ }
29698
+ return true;
29699
+ } catch {
29700
+ return false;
29701
+ }
29702
+ }
29703
+ async function waitForPidExit(pid, timeoutMs) {
29704
+ const start = Date.now();
29705
+ while (Date.now() - start < timeoutMs) {
29706
+ try {
29707
+ process.kill(pid, 0);
29708
+ await new Promise((resolve13) => setTimeout(resolve13, 250));
29709
+ } catch {
29710
+ return;
29711
+ }
29712
+ }
29713
+ }
29714
+ function stopSessionHostProcesses(appName) {
29715
+ const pidFile = path13.join(os15.homedir(), ".adhdev", `${appName}-session-host.pid`);
29716
+ try {
29717
+ if (fs8.existsSync(pidFile)) {
29718
+ const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
29719
+ if (Number.isFinite(pid)) {
29720
+ killPid(pid);
29721
+ }
29722
+ }
29723
+ } catch {
29724
+ } finally {
29725
+ try {
29726
+ fs8.unlinkSync(pidFile);
29727
+ } catch {
29728
+ }
29729
+ }
29730
+ if (process.platform !== "win32") {
29731
+ try {
29732
+ const raw = (0, import_child_process7.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
29733
+ for (const line of raw.split("\n")) {
29734
+ const pid = Number.parseInt(line.trim(), 10);
29735
+ if (Number.isFinite(pid)) {
29736
+ killPid(pid);
29737
+ }
29738
+ }
29739
+ } catch {
29740
+ }
29741
+ }
29742
+ }
29743
+ function removeDaemonPidFile() {
29744
+ const pidFile = path13.join(os15.homedir(), ".adhdev", "daemon.pid");
29745
+ try {
29746
+ fs8.unlinkSync(pidFile);
29747
+ } catch {
29748
+ }
29749
+ }
29750
+ function cleanupStaleGlobalInstallDirs(pkgName) {
29751
+ const npmRoot = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8" }).trim();
29752
+ if (!npmRoot) return;
29753
+ const npmPrefix = (0, import_child_process7.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8" }).trim();
29754
+ const binDir = process.platform === "win32" ? npmPrefix : path13.join(npmPrefix, "bin");
29755
+ const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
29756
+ const binNames = /* @__PURE__ */ new Set([packageBaseName]);
29757
+ if (pkgName === "@adhdev/daemon-standalone") {
29758
+ binNames.add("adhdev-standalone");
29759
+ }
29760
+ if (pkgName.startsWith("@")) {
29761
+ const [scope, name] = pkgName.split("/");
29762
+ const scopeDir = path13.join(npmRoot, scope);
29763
+ if (!fs8.existsSync(scopeDir)) return;
29764
+ for (const entry of fs8.readdirSync(scopeDir)) {
29765
+ if (!entry.startsWith(`.${name}-`)) continue;
29766
+ fs8.rmSync(path13.join(scopeDir, entry), { recursive: true, force: true });
29767
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path13.join(scopeDir, entry)}`);
29768
+ }
29769
+ } else {
29770
+ for (const entry of fs8.readdirSync(npmRoot)) {
29771
+ if (!entry.startsWith(`.${pkgName}-`)) continue;
29772
+ fs8.rmSync(path13.join(npmRoot, entry), { recursive: true, force: true });
29773
+ appendUpgradeLog(`Removed stale staging dir: ${path13.join(npmRoot, entry)}`);
29774
+ }
29775
+ }
29776
+ if (fs8.existsSync(binDir)) {
29777
+ for (const entry of fs8.readdirSync(binDir)) {
29778
+ if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
29779
+ fs8.rmSync(path13.join(binDir, entry), { recursive: true, force: true });
29780
+ appendUpgradeLog(`Removed stale bin staging entry: ${path13.join(binDir, entry)}`);
29781
+ }
29782
+ }
29783
+ }
29466
29784
  function spawnDetachedDaemonUpgradeHelper(payload) {
29467
29785
  const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
29468
- const child = (0, import_child_process7.spawn)(process.execPath, process.argv.slice(1), {
29786
+ const child = (0, import_child_process8.spawn)(process.execPath, process.argv.slice(1), {
29469
29787
  detached: true,
29470
29788
  stdio: "ignore",
29471
29789
  windowsHide: true,
@@ -29474,17 +29792,75 @@ function spawnDetachedDaemonUpgradeHelper(payload) {
29474
29792
  });
29475
29793
  child.unref();
29476
29794
  }
29477
- var import_child_process7, UPGRADE_HELPER_ENV;
29795
+ async function runDaemonUpgradeHelper(payload) {
29796
+ const restartArgv = Array.isArray(payload.restartArgv) ? payload.restartArgv : [];
29797
+ const sessionHostAppName = payload.sessionHostAppName || process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
29798
+ appendUpgradeLog(`Upgrade helper started for ${payload.packageName}@${payload.targetVersion}`);
29799
+ if (Number.isFinite(payload.parentPid) && payload.parentPid > 0) {
29800
+ appendUpgradeLog(`Waiting for parent pid ${payload.parentPid} to exit`);
29801
+ await waitForPidExit(payload.parentPid, 15e3);
29802
+ }
29803
+ stopSessionHostProcesses(sessionHostAppName);
29804
+ removeDaemonPidFile();
29805
+ cleanupStaleGlobalInstallDirs(payload.packageName);
29806
+ const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
29807
+ appendUpgradeLog(`Installing ${spec}`);
29808
+ const installOutput = (0, import_child_process7.execFileSync)(
29809
+ getNpmExecutable(),
29810
+ ["install", "-g", spec, "--force"],
29811
+ {
29812
+ encoding: "utf8",
29813
+ stdio: "pipe",
29814
+ maxBuffer: 20 * 1024 * 1024
29815
+ }
29816
+ );
29817
+ if (installOutput.trim()) {
29818
+ appendUpgradeLog(installOutput.trim());
29819
+ }
29820
+ if (restartArgv.length > 0) {
29821
+ const env = { ...process.env };
29822
+ delete env[UPGRADE_HELPER_ENV];
29823
+ appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
29824
+ const child = (0, import_child_process8.spawn)(process.execPath, restartArgv, {
29825
+ detached: true,
29826
+ stdio: "ignore",
29827
+ windowsHide: true,
29828
+ cwd: payload.cwd || process.cwd(),
29829
+ env
29830
+ });
29831
+ child.unref();
29832
+ } else {
29833
+ appendUpgradeLog("No restart argv provided; upgrade completed without restart");
29834
+ }
29835
+ }
29836
+ async function maybeRunDaemonUpgradeHelperFromEnv() {
29837
+ const raw = process.env[UPGRADE_HELPER_ENV];
29838
+ if (!raw) return false;
29839
+ delete process.env[UPGRADE_HELPER_ENV];
29840
+ try {
29841
+ const payload = JSON.parse(raw);
29842
+ await runDaemonUpgradeHelper(payload);
29843
+ process.exit(0);
29844
+ } catch (error48) {
29845
+ appendUpgradeLog(`Upgrade helper failed: ${error48?.stack || error48?.message || String(error48)}`);
29846
+ process.exit(1);
29847
+ }
29848
+ }
29849
+ var import_child_process7, import_child_process8, fs8, os15, path13, UPGRADE_HELPER_ENV;
29478
29850
  var init_upgrade_helper = __esm({
29479
29851
  "../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
29480
29852
  "use strict";
29481
29853
  import_child_process7 = require("child_process");
29854
+ import_child_process8 = require("child_process");
29855
+ fs8 = __toESM(require("fs"));
29856
+ os15 = __toESM(require("os"));
29857
+ path13 = __toESM(require("path"));
29482
29858
  UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
29483
29859
  }
29484
29860
  });
29485
29861
 
29486
29862
  // ../../oss/packages/daemon-core/src/commands/router.ts
29487
- var fs8, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
29863
+ var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
29488
29864
  var init_router = __esm({
29489
29865
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
29490
29866
  "use strict";
@@ -29504,7 +29880,7 @@ var init_router = __esm({
29504
29880
  init_builders();
29505
29881
  init_snapshot();
29506
29882
  init_upgrade_helper();
29507
- fs8 = __toESM(require("fs"));
29883
+ fs9 = __toESM(require("fs"));
29508
29884
  CHAT_COMMANDS = [
29509
29885
  "send_chat",
29510
29886
  "new_chat",
@@ -29575,8 +29951,8 @@ var init_router = __esm({
29575
29951
  if (logs.length > 0) {
29576
29952
  return { success: true, logs, totalBuffered: logs.length };
29577
29953
  }
29578
- if (fs8.existsSync(LOG_PATH)) {
29579
- const content = fs8.readFileSync(LOG_PATH, "utf-8");
29954
+ if (fs9.existsSync(LOG_PATH)) {
29955
+ const content = fs9.readFileSync(LOG_PATH, "utf-8");
29580
29956
  const allLines = content.split("\n");
29581
29957
  const recent = allLines.slice(-count).join("\n");
29582
29958
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -29759,14 +30135,14 @@ var init_router = __esm({
29759
30135
  case "daemon_upgrade": {
29760
30136
  LOG.info("Upgrade", "Remote upgrade requested from dashboard");
29761
30137
  try {
29762
- const { execSync: execSync6 } = await import("child_process");
30138
+ const { execSync: execSync7 } = await import("child_process");
29763
30139
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
29764
30140
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
29765
- const latest = execSync6(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
30141
+ const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
29766
30142
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
29767
30143
  let currentInstalled = null;
29768
30144
  try {
29769
- const currentJson = execSync6(`npm ls -g ${pkgName} --depth=0 --json`, {
30145
+ const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
29770
30146
  encoding: "utf-8",
29771
30147
  timeout: 1e4,
29772
30148
  stdio: ["pipe", "pipe", "pipe"]
@@ -30095,11 +30471,12 @@ var init_reporter = __esm({
30095
30471
  });
30096
30472
 
30097
30473
  // ../../oss/packages/daemon-core/src/ipc-protocol.ts
30098
- var DEFAULT_DAEMON_PORT;
30474
+ var DEFAULT_DAEMON_PORT, DAEMON_WS_PATH;
30099
30475
  var init_ipc_protocol = __esm({
30100
30476
  "../../oss/packages/daemon-core/src/ipc-protocol.ts"() {
30101
30477
  "use strict";
30102
30478
  DEFAULT_DAEMON_PORT = 19222;
30479
+ DAEMON_WS_PATH = "/ipc";
30103
30480
  }
30104
30481
  });
30105
30482
 
@@ -30968,7 +31345,7 @@ var init_provider_instance_manager = __esm({
30968
31345
  // ../../oss/packages/daemon-core/src/providers/version-archive.ts
30969
31346
  function runCommand(cmd, timeout = 1e4) {
30970
31347
  try {
30971
- return (0, import_child_process8.execSync)(cmd, {
31348
+ return (0, import_child_process9.execSync)(cmd, {
30972
31349
  encoding: "utf-8",
30973
31350
  timeout,
30974
31351
  stdio: ["pipe", "pipe", "pipe"]
@@ -31000,19 +31377,19 @@ function getVersion(binary, versionCommand) {
31000
31377
  function checkPathExists2(paths) {
31001
31378
  for (const p of paths) {
31002
31379
  if (p.includes("*")) {
31003
- const home = os15.homedir();
31004
- const resolved = p.replace(/\*/g, home.split(path13.sep).pop() || "");
31005
- if (fs9.existsSync(resolved)) return resolved;
31380
+ const home = os16.homedir();
31381
+ const resolved = p.replace(/\*/g, home.split(path14.sep).pop() || "");
31382
+ if (fs10.existsSync(resolved)) return resolved;
31006
31383
  } else {
31007
- if (fs9.existsSync(p)) return p;
31384
+ if (fs10.existsSync(p)) return p;
31008
31385
  }
31009
31386
  }
31010
31387
  return null;
31011
31388
  }
31012
31389
  function getMacAppVersion(appPath) {
31013
31390
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
31014
- const plistPath = path13.join(appPath, "Contents", "Info.plist");
31015
- if (!fs9.existsSync(plistPath)) return null;
31391
+ const plistPath = path14.join(appPath, "Contents", "Info.plist");
31392
+ if (!fs10.existsSync(plistPath)) return null;
31016
31393
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
31017
31394
  return raw || null;
31018
31395
  }
@@ -31038,8 +31415,8 @@ async function detectAllVersions(loader, archive) {
31038
31415
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
31039
31416
  let resolvedBin = cliBin;
31040
31417
  if (!resolvedBin && appPath && currentOs === "darwin") {
31041
- const bundled = path13.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
31042
- if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
31418
+ const bundled = path14.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
31419
+ if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
31043
31420
  }
31044
31421
  info.installed = !!(appPath || resolvedBin);
31045
31422
  info.path = appPath || null;
@@ -31075,16 +31452,16 @@ async function detectAllVersions(loader, archive) {
31075
31452
  }
31076
31453
  return results;
31077
31454
  }
31078
- var fs9, path13, os15, import_child_process8, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
31455
+ var fs10, path14, os16, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
31079
31456
  var init_version_archive = __esm({
31080
31457
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
31081
31458
  "use strict";
31082
- fs9 = __toESM(require("fs"));
31083
- path13 = __toESM(require("path"));
31084
- os15 = __toESM(require("os"));
31085
- import_child_process8 = require("child_process");
31459
+ fs10 = __toESM(require("fs"));
31460
+ path14 = __toESM(require("path"));
31461
+ os16 = __toESM(require("os"));
31462
+ import_child_process9 = require("child_process");
31086
31463
  import_os3 = require("os");
31087
- ARCHIVE_PATH = path13.join(os15.homedir(), ".adhdev", "version-history.json");
31464
+ ARCHIVE_PATH = path14.join(os16.homedir(), ".adhdev", "version-history.json");
31088
31465
  MAX_ENTRIES_PER_PROVIDER = 20;
31089
31466
  VersionArchive = class {
31090
31467
  history = {};
@@ -31093,8 +31470,8 @@ var init_version_archive = __esm({
31093
31470
  }
31094
31471
  load() {
31095
31472
  try {
31096
- if (fs9.existsSync(ARCHIVE_PATH)) {
31097
- this.history = JSON.parse(fs9.readFileSync(ARCHIVE_PATH, "utf-8"));
31473
+ if (fs10.existsSync(ARCHIVE_PATH)) {
31474
+ this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
31098
31475
  }
31099
31476
  } catch {
31100
31477
  this.history = {};
@@ -31131,8 +31508,8 @@ var init_version_archive = __esm({
31131
31508
  }
31132
31509
  save() {
31133
31510
  try {
31134
- fs9.mkdirSync(path13.dirname(ARCHIVE_PATH), { recursive: true });
31135
- fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
31511
+ fs10.mkdirSync(path14.dirname(ARCHIVE_PATH), { recursive: true });
31512
+ fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
31136
31513
  } catch {
31137
31514
  }
31138
31515
  }
@@ -31652,18 +32029,18 @@ async function handleScriptHints(ctx, type, _req, res) {
31652
32029
  return;
31653
32030
  }
31654
32031
  let scriptsPath = "";
31655
- const directScripts = path14.join(dir, "scripts.js");
31656
- if (fs10.existsSync(directScripts)) {
32032
+ const directScripts = path15.join(dir, "scripts.js");
32033
+ if (fs11.existsSync(directScripts)) {
31657
32034
  scriptsPath = directScripts;
31658
32035
  } else {
31659
- const scriptsDir = path14.join(dir, "scripts");
31660
- if (fs10.existsSync(scriptsDir)) {
31661
- const versions = fs10.readdirSync(scriptsDir).filter((d) => {
31662
- return fs10.statSync(path14.join(scriptsDir, d)).isDirectory();
32036
+ const scriptsDir = path15.join(dir, "scripts");
32037
+ if (fs11.existsSync(scriptsDir)) {
32038
+ const versions = fs11.readdirSync(scriptsDir).filter((d) => {
32039
+ return fs11.statSync(path15.join(scriptsDir, d)).isDirectory();
31663
32040
  }).sort().reverse();
31664
32041
  for (const ver of versions) {
31665
- const p = path14.join(scriptsDir, ver, "scripts.js");
31666
- if (fs10.existsSync(p)) {
32042
+ const p = path15.join(scriptsDir, ver, "scripts.js");
32043
+ if (fs11.existsSync(p)) {
31667
32044
  scriptsPath = p;
31668
32045
  break;
31669
32046
  }
@@ -31675,7 +32052,7 @@ async function handleScriptHints(ctx, type, _req, res) {
31675
32052
  return;
31676
32053
  }
31677
32054
  try {
31678
- const source = fs10.readFileSync(scriptsPath, "utf-8");
32055
+ const source = fs11.readFileSync(scriptsPath, "utf-8");
31679
32056
  const hints = {};
31680
32057
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
31681
32058
  let match;
@@ -32478,12 +32855,12 @@ async function handleDomContext(ctx, type, req, res) {
32478
32855
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
32479
32856
  }
32480
32857
  }
32481
- var fs10, path14;
32858
+ var fs11, path15;
32482
32859
  var init_dev_cdp_handlers = __esm({
32483
32860
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
32484
32861
  "use strict";
32485
- fs10 = __toESM(require("fs"));
32486
- path14 = __toESM(require("path"));
32862
+ fs11 = __toESM(require("fs"));
32863
+ path15 = __toESM(require("path"));
32487
32864
  init_logger();
32488
32865
  }
32489
32866
  });
@@ -32498,15 +32875,15 @@ function getCliFixtureDir(ctx, type) {
32498
32875
  if (!providerDir) {
32499
32876
  throw new Error(`Provider directory not found for '${type}'`);
32500
32877
  }
32501
- return path15.join(providerDir, "fixtures");
32878
+ return path16.join(providerDir, "fixtures");
32502
32879
  }
32503
32880
  function readCliFixture(ctx, type, name) {
32504
32881
  const fixtureDir = getCliFixtureDir(ctx, type);
32505
- const filePath = path15.join(fixtureDir, `${name}.json`);
32506
- if (!fs11.existsSync(filePath)) {
32882
+ const filePath = path16.join(fixtureDir, `${name}.json`);
32883
+ if (!fs12.existsSync(filePath)) {
32507
32884
  throw new Error(`Fixture not found: ${filePath}`);
32508
32885
  }
32509
- return JSON.parse(fs11.readFileSync(filePath, "utf-8"));
32886
+ return JSON.parse(fs12.readFileSync(filePath, "utf-8"));
32510
32887
  }
32511
32888
  function getExerciseTranscriptText(result) {
32512
32889
  const parts = [];
@@ -33205,7 +33582,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
33205
33582
  return;
33206
33583
  }
33207
33584
  const fixtureDir = getCliFixtureDir(ctx, type);
33208
- fs11.mkdirSync(fixtureDir, { recursive: true });
33585
+ fs12.mkdirSync(fixtureDir, { recursive: true });
33209
33586
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
33210
33587
  const result = await runCliExerciseInternal(ctx, { ...request, type });
33211
33588
  const fixture = {
@@ -33232,8 +33609,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
33232
33609
  },
33233
33610
  notes: typeof body?.notes === "string" ? body.notes : void 0
33234
33611
  };
33235
- const filePath = path15.join(fixtureDir, `${name}.json`);
33236
- fs11.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
33612
+ const filePath = path16.join(fixtureDir, `${name}.json`);
33613
+ fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
33237
33614
  ctx.json(res, 200, {
33238
33615
  saved: true,
33239
33616
  name,
@@ -33251,14 +33628,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
33251
33628
  async function handleCliFixtureList(ctx, type, _req, res) {
33252
33629
  try {
33253
33630
  const fixtureDir = getCliFixtureDir(ctx, type);
33254
- if (!fs11.existsSync(fixtureDir)) {
33631
+ if (!fs12.existsSync(fixtureDir)) {
33255
33632
  ctx.json(res, 200, { fixtures: [], count: 0 });
33256
33633
  return;
33257
33634
  }
33258
- const fixtures = fs11.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
33259
- const fullPath = path15.join(fixtureDir, file2);
33635
+ const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
33636
+ const fullPath = path16.join(fixtureDir, file2);
33260
33637
  try {
33261
- const raw = JSON.parse(fs11.readFileSync(fullPath, "utf-8"));
33638
+ const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
33262
33639
  return {
33263
33640
  name: raw.name || file2.replace(/\.json$/i, ""),
33264
33641
  path: fullPath,
@@ -33389,12 +33766,12 @@ async function handleCliRaw(ctx, req, res) {
33389
33766
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
33390
33767
  }
33391
33768
  }
33392
- var fs11, path15;
33769
+ var fs12, path16;
33393
33770
  var init_dev_cli_debug = __esm({
33394
33771
  "../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
33395
33772
  "use strict";
33396
- fs11 = __toESM(require("fs"));
33397
- path15 = __toESM(require("path"));
33773
+ fs12 = __toESM(require("fs"));
33774
+ path16 = __toESM(require("path"));
33398
33775
  }
33399
33776
  });
33400
33777
 
@@ -33434,45 +33811,45 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
33434
33811
  return fallback?.type || null;
33435
33812
  }
33436
33813
  function getLatestScriptVersionDir(scriptsDir) {
33437
- if (!fs12.existsSync(scriptsDir)) return null;
33438
- const versions = fs12.readdirSync(scriptsDir).filter((d) => {
33814
+ if (!fs13.existsSync(scriptsDir)) return null;
33815
+ const versions = fs13.readdirSync(scriptsDir).filter((d) => {
33439
33816
  try {
33440
- return fs12.statSync(path16.join(scriptsDir, d)).isDirectory();
33817
+ return fs13.statSync(path17.join(scriptsDir, d)).isDirectory();
33441
33818
  } catch {
33442
33819
  return false;
33443
33820
  }
33444
33821
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
33445
33822
  if (versions.length === 0) return null;
33446
- return path16.join(scriptsDir, versions[0]);
33823
+ return path17.join(scriptsDir, versions[0]);
33447
33824
  }
33448
33825
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
33449
- const canonicalUserDir = path16.resolve(ctx.providerLoader.getUserProviderDir(category, type));
33450
- const desiredDir = requestedDir ? path16.resolve(requestedDir) : canonicalUserDir;
33451
- const upstreamRoot = path16.resolve(ctx.providerLoader.getUpstreamDir());
33452
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path16.sep}`)) {
33826
+ const canonicalUserDir = path17.resolve(ctx.providerLoader.getUserProviderDir(category, type));
33827
+ const desiredDir = requestedDir ? path17.resolve(requestedDir) : canonicalUserDir;
33828
+ const upstreamRoot = path17.resolve(ctx.providerLoader.getUpstreamDir());
33829
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path17.sep}`)) {
33453
33830
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
33454
33831
  }
33455
- if (path16.basename(desiredDir) !== type) {
33832
+ if (path17.basename(desiredDir) !== type) {
33456
33833
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
33457
33834
  }
33458
33835
  const sourceDir = ctx.findProviderDir(type);
33459
33836
  if (!sourceDir) {
33460
33837
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
33461
33838
  }
33462
- if (!fs12.existsSync(desiredDir)) {
33463
- fs12.mkdirSync(path16.dirname(desiredDir), { recursive: true });
33464
- fs12.cpSync(sourceDir, desiredDir, { recursive: true });
33839
+ if (!fs13.existsSync(desiredDir)) {
33840
+ fs13.mkdirSync(path17.dirname(desiredDir), { recursive: true });
33841
+ fs13.cpSync(sourceDir, desiredDir, { recursive: true });
33465
33842
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
33466
33843
  }
33467
- const providerJson = path16.join(desiredDir, "provider.json");
33468
- if (!fs12.existsSync(providerJson)) {
33844
+ const providerJson = path17.join(desiredDir, "provider.json");
33845
+ if (!fs13.existsSync(providerJson)) {
33469
33846
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
33470
33847
  }
33471
33848
  try {
33472
- const providerData = JSON.parse(fs12.readFileSync(providerJson, "utf-8"));
33849
+ const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
33473
33850
  if (providerData.disableUpstream !== true) {
33474
33851
  providerData.disableUpstream = true;
33475
- fs12.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
33852
+ fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
33476
33853
  }
33477
33854
  } catch (error48) {
33478
33855
  return {
@@ -33485,15 +33862,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
33485
33862
  function loadAutoImplReferenceScripts(ctx, referenceType) {
33486
33863
  if (!referenceType) return {};
33487
33864
  const refDir = ctx.findProviderDir(referenceType);
33488
- if (!refDir || !fs12.existsSync(refDir)) return {};
33865
+ if (!refDir || !fs13.existsSync(refDir)) return {};
33489
33866
  const referenceScripts = {};
33490
- const scriptsDir = path16.join(refDir, "scripts");
33867
+ const scriptsDir = path17.join(refDir, "scripts");
33491
33868
  const latestDir = getLatestScriptVersionDir(scriptsDir);
33492
33869
  if (!latestDir) return referenceScripts;
33493
- for (const file2 of fs12.readdirSync(latestDir)) {
33870
+ for (const file2 of fs13.readdirSync(latestDir)) {
33494
33871
  if (!file2.endsWith(".js")) continue;
33495
33872
  try {
33496
- referenceScripts[file2] = fs12.readFileSync(path16.join(latestDir, file2), "utf-8");
33873
+ referenceScripts[file2] = fs13.readFileSync(path17.join(latestDir, file2), "utf-8");
33497
33874
  } catch {
33498
33875
  }
33499
33876
  }
@@ -33601,16 +33978,16 @@ async function handleAutoImplement(ctx, type, req, res) {
33601
33978
  });
33602
33979
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
33603
33980
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
33604
- const tmpDir = path16.join(os16.tmpdir(), "adhdev-autoimpl");
33605
- if (!fs12.existsSync(tmpDir)) fs12.mkdirSync(tmpDir, { recursive: true });
33606
- const promptFile = path16.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
33607
- fs12.writeFileSync(promptFile, prompt, "utf-8");
33981
+ const tmpDir = path17.join(os17.tmpdir(), "adhdev-autoimpl");
33982
+ if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
33983
+ const promptFile = path17.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
33984
+ fs13.writeFileSync(promptFile, prompt, "utf-8");
33608
33985
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
33609
33986
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
33610
33987
  const spawn5 = agentProvider?.spawn;
33611
33988
  if (!spawn5?.command) {
33612
33989
  try {
33613
- fs12.unlinkSync(promptFile);
33990
+ fs13.unlinkSync(promptFile);
33614
33991
  } catch {
33615
33992
  }
33616
33993
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -33712,7 +34089,7 @@ async function handleAutoImplement(ctx, type, req, res) {
33712
34089
  } catch {
33713
34090
  }
33714
34091
  try {
33715
- fs12.unlinkSync(promptFile);
34092
+ fs13.unlinkSync(promptFile);
33716
34093
  } catch {
33717
34094
  }
33718
34095
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -33755,7 +34132,7 @@ async function handleAutoImplement(ctx, type, req, res) {
33755
34132
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
33756
34133
  const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
33757
34134
  let shellCmd;
33758
- const isWin = os16.platform() === "win32";
34135
+ const isWin = os17.platform() === "win32";
33759
34136
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
33760
34137
  if (command === "claude") {
33761
34138
  const args = [...baseArgs, "--dangerously-skip-permissions"];
@@ -33799,7 +34176,7 @@ async function handleAutoImplement(ctx, type, req, res) {
33799
34176
  try {
33800
34177
  const pty3 = require("node-pty");
33801
34178
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
33802
- const isWin2 = os16.platform() === "win32";
34179
+ const isWin2 = os17.platform() === "win32";
33803
34180
  child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
33804
34181
  name: "xterm-256color",
33805
34182
  cols: 120,
@@ -33947,7 +34324,7 @@ async function handleAutoImplement(ctx, type, req, res) {
33947
34324
  }
33948
34325
  });
33949
34326
  try {
33950
- fs12.unlinkSync(promptFile);
34327
+ fs13.unlinkSync(promptFile);
33951
34328
  } catch {
33952
34329
  }
33953
34330
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -34030,7 +34407,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
34030
34407
  setMode: "set_mode.js"
34031
34408
  };
34032
34409
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
34033
- const scriptsDir = path16.join(providerDir, "scripts");
34410
+ const scriptsDir = path17.join(providerDir, "scripts");
34034
34411
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
34035
34412
  if (latestScriptsDir) {
34036
34413
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -34038,10 +34415,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
34038
34415
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
34039
34416
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
34040
34417
  lines.push("");
34041
- for (const file2 of fs12.readdirSync(latestScriptsDir)) {
34418
+ for (const file2 of fs13.readdirSync(latestScriptsDir)) {
34042
34419
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
34043
34420
  try {
34044
- const content = fs12.readFileSync(path16.join(latestScriptsDir, file2), "utf-8");
34421
+ const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
34045
34422
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
34046
34423
  lines.push("```javascript");
34047
34424
  lines.push(content);
@@ -34051,14 +34428,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
34051
34428
  }
34052
34429
  }
34053
34430
  }
34054
- const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
34431
+ const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
34055
34432
  if (refFiles.length > 0) {
34056
34433
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
34057
34434
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
34058
34435
  lines.push("");
34059
34436
  for (const file2 of refFiles) {
34060
34437
  try {
34061
- const content = fs12.readFileSync(path16.join(latestScriptsDir, file2), "utf-8");
34438
+ const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
34062
34439
  lines.push(`### \`${file2}\` \u{1F512}`);
34063
34440
  lines.push("```javascript");
34064
34441
  lines.push(content);
@@ -34099,11 +34476,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
34099
34476
  lines.push("");
34100
34477
  }
34101
34478
  }
34102
- const docsDir = path16.join(providerDir, "../../docs");
34479
+ const docsDir = path17.join(providerDir, "../../docs");
34103
34480
  const loadGuide = (name) => {
34104
34481
  try {
34105
- const p = path16.join(docsDir, name);
34106
- if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
34482
+ const p = path17.join(docsDir, name);
34483
+ if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
34107
34484
  } catch {
34108
34485
  }
34109
34486
  return null;
@@ -34337,7 +34714,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
34337
34714
  parseApproval: "parse_approval.js"
34338
34715
  };
34339
34716
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
34340
- const scriptsDir = path16.join(providerDir, "scripts");
34717
+ const scriptsDir = path17.join(providerDir, "scripts");
34341
34718
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
34342
34719
  if (latestScriptsDir) {
34343
34720
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -34345,11 +34722,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
34345
34722
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
34346
34723
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
34347
34724
  lines.push("");
34348
- for (const file2 of fs12.readdirSync(latestScriptsDir)) {
34725
+ for (const file2 of fs13.readdirSync(latestScriptsDir)) {
34349
34726
  if (!file2.endsWith(".js")) continue;
34350
34727
  if (!targetFileNames.has(file2)) continue;
34351
34728
  try {
34352
- const content = fs12.readFileSync(path16.join(latestScriptsDir, file2), "utf-8");
34729
+ const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
34353
34730
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
34354
34731
  lines.push("```javascript");
34355
34732
  lines.push(content);
@@ -34358,14 +34735,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
34358
34735
  } catch {
34359
34736
  }
34360
34737
  }
34361
- const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
34738
+ const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
34362
34739
  if (refFiles.length > 0) {
34363
34740
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
34364
34741
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
34365
34742
  lines.push("");
34366
34743
  for (const file2 of refFiles) {
34367
34744
  try {
34368
- const content = fs12.readFileSync(path16.join(latestScriptsDir, file2), "utf-8");
34745
+ const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
34369
34746
  lines.push(`### \`${file2}\` \u{1F512}`);
34370
34747
  lines.push("```javascript");
34371
34748
  lines.push(content);
@@ -34398,11 +34775,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
34398
34775
  lines.push("");
34399
34776
  }
34400
34777
  }
34401
- const docsDir = path16.join(providerDir, "../../docs");
34778
+ const docsDir = path17.join(providerDir, "../../docs");
34402
34779
  const loadGuide = (name) => {
34403
34780
  try {
34404
- const p = path16.join(docsDir, name);
34405
- if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
34781
+ const p = path17.join(docsDir, name);
34782
+ if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
34406
34783
  } catch {
34407
34784
  }
34408
34785
  return null;
@@ -34706,26 +35083,26 @@ data: ${JSON.stringify(msg.data)}
34706
35083
  }
34707
35084
  }
34708
35085
  }
34709
- var fs12, path16, os16;
35086
+ var fs13, path17, os17;
34710
35087
  var init_dev_auto_implement = __esm({
34711
35088
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
34712
35089
  "use strict";
34713
- fs12 = __toESM(require("fs"));
34714
- path16 = __toESM(require("path"));
34715
- os16 = __toESM(require("os"));
35090
+ fs13 = __toESM(require("fs"));
35091
+ path17 = __toESM(require("path"));
35092
+ os17 = __toESM(require("os"));
34716
35093
  init_dev_server();
34717
35094
  init_dev_cli_debug();
34718
35095
  }
34719
35096
  });
34720
35097
 
34721
35098
  // ../../oss/packages/daemon-core/src/daemon/dev-server.ts
34722
- var http2, fs13, path17, DEV_SERVER_PORT, DevServer;
35099
+ var http2, fs14, path18, DEV_SERVER_PORT, DevServer;
34723
35100
  var init_dev_server = __esm({
34724
35101
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
34725
35102
  "use strict";
34726
35103
  http2 = __toESM(require("http"));
34727
- fs13 = __toESM(require("fs"));
34728
- path17 = __toESM(require("path"));
35104
+ fs14 = __toESM(require("fs"));
35105
+ path18 = __toESM(require("path"));
34729
35106
  init_scaffold_template();
34730
35107
  init_version_archive();
34731
35108
  init_logger();
@@ -34829,8 +35206,8 @@ var init_dev_server = __esm({
34829
35206
  }
34830
35207
  getEndpointList() {
34831
35208
  return this.routes.map((r) => {
34832
- const path21 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
34833
- return `${r.method.padEnd(5)} ${path21}`;
35209
+ const path23 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
35210
+ return `${r.method.padEnd(5)} ${path23}`;
34834
35211
  });
34835
35212
  }
34836
35213
  async start(port = DEV_SERVER_PORT) {
@@ -35112,12 +35489,12 @@ var init_dev_server = __esm({
35112
35489
  // ─── DevConsole SPA ───
35113
35490
  getConsoleDistDir() {
35114
35491
  const candidates = [
35115
- path17.resolve(__dirname, "../../web-devconsole/dist"),
35116
- path17.resolve(__dirname, "../../../web-devconsole/dist"),
35117
- path17.join(process.cwd(), "packages/web-devconsole/dist")
35492
+ path18.resolve(__dirname, "../../web-devconsole/dist"),
35493
+ path18.resolve(__dirname, "../../../web-devconsole/dist"),
35494
+ path18.join(process.cwd(), "packages/web-devconsole/dist")
35118
35495
  ];
35119
35496
  for (const dir of candidates) {
35120
- if (fs13.existsSync(path17.join(dir, "index.html"))) return dir;
35497
+ if (fs14.existsSync(path18.join(dir, "index.html"))) return dir;
35121
35498
  }
35122
35499
  return null;
35123
35500
  }
@@ -35127,9 +35504,9 @@ var init_dev_server = __esm({
35127
35504
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
35128
35505
  return;
35129
35506
  }
35130
- const htmlPath = path17.join(distDir, "index.html");
35507
+ const htmlPath = path18.join(distDir, "index.html");
35131
35508
  try {
35132
- const html = fs13.readFileSync(htmlPath, "utf-8");
35509
+ const html = fs14.readFileSync(htmlPath, "utf-8");
35133
35510
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
35134
35511
  res.end(html);
35135
35512
  } catch (e) {
@@ -35152,15 +35529,15 @@ var init_dev_server = __esm({
35152
35529
  this.json(res, 404, { error: "Not found" });
35153
35530
  return;
35154
35531
  }
35155
- const safePath = path17.normalize(pathname).replace(/^\.\.\//, "");
35156
- const filePath = path17.join(distDir, safePath);
35532
+ const safePath = path18.normalize(pathname).replace(/^\.\.\//, "");
35533
+ const filePath = path18.join(distDir, safePath);
35157
35534
  if (!filePath.startsWith(distDir)) {
35158
35535
  this.json(res, 403, { error: "Forbidden" });
35159
35536
  return;
35160
35537
  }
35161
35538
  try {
35162
- const content = fs13.readFileSync(filePath);
35163
- const ext = path17.extname(filePath);
35539
+ const content = fs14.readFileSync(filePath);
35540
+ const ext = path18.extname(filePath);
35164
35541
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
35165
35542
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
35166
35543
  res.end(content);
@@ -35268,14 +35645,14 @@ var init_dev_server = __esm({
35268
35645
  const files = [];
35269
35646
  const scan = (d, prefix) => {
35270
35647
  try {
35271
- for (const entry of fs13.readdirSync(d, { withFileTypes: true })) {
35648
+ for (const entry of fs14.readdirSync(d, { withFileTypes: true })) {
35272
35649
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
35273
35650
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
35274
35651
  if (entry.isDirectory()) {
35275
35652
  files.push({ path: rel, size: 0, type: "dir" });
35276
- scan(path17.join(d, entry.name), rel);
35653
+ scan(path18.join(d, entry.name), rel);
35277
35654
  } else {
35278
- const stat4 = fs13.statSync(path17.join(d, entry.name));
35655
+ const stat4 = fs14.statSync(path18.join(d, entry.name));
35279
35656
  files.push({ path: rel, size: stat4.size, type: "file" });
35280
35657
  }
35281
35658
  }
@@ -35298,16 +35675,16 @@ var init_dev_server = __esm({
35298
35675
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
35299
35676
  return;
35300
35677
  }
35301
- const fullPath = path17.resolve(dir, path17.normalize(filePath));
35678
+ const fullPath = path18.resolve(dir, path18.normalize(filePath));
35302
35679
  if (!fullPath.startsWith(dir)) {
35303
35680
  this.json(res, 403, { error: "Forbidden" });
35304
35681
  return;
35305
35682
  }
35306
- if (!fs13.existsSync(fullPath) || fs13.statSync(fullPath).isDirectory()) {
35683
+ if (!fs14.existsSync(fullPath) || fs14.statSync(fullPath).isDirectory()) {
35307
35684
  this.json(res, 404, { error: `File not found: ${filePath}` });
35308
35685
  return;
35309
35686
  }
35310
- const content = fs13.readFileSync(fullPath, "utf-8");
35687
+ const content = fs14.readFileSync(fullPath, "utf-8");
35311
35688
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
35312
35689
  }
35313
35690
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -35323,15 +35700,15 @@ var init_dev_server = __esm({
35323
35700
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
35324
35701
  return;
35325
35702
  }
35326
- const fullPath = path17.resolve(dir, path17.normalize(filePath));
35703
+ const fullPath = path18.resolve(dir, path18.normalize(filePath));
35327
35704
  if (!fullPath.startsWith(dir)) {
35328
35705
  this.json(res, 403, { error: "Forbidden" });
35329
35706
  return;
35330
35707
  }
35331
35708
  try {
35332
- if (fs13.existsSync(fullPath)) fs13.copyFileSync(fullPath, fullPath + ".bak");
35333
- fs13.mkdirSync(path17.dirname(fullPath), { recursive: true });
35334
- fs13.writeFileSync(fullPath, content, "utf-8");
35709
+ if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
35710
+ fs14.mkdirSync(path18.dirname(fullPath), { recursive: true });
35711
+ fs14.writeFileSync(fullPath, content, "utf-8");
35335
35712
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
35336
35713
  this.providerLoader.reload();
35337
35714
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -35347,9 +35724,9 @@ var init_dev_server = __esm({
35347
35724
  return;
35348
35725
  }
35349
35726
  for (const name of ["scripts.js", "provider.json"]) {
35350
- const p = path17.join(dir, name);
35351
- if (fs13.existsSync(p)) {
35352
- const source = fs13.readFileSync(p, "utf-8");
35727
+ const p = path18.join(dir, name);
35728
+ if (fs14.existsSync(p)) {
35729
+ const source = fs14.readFileSync(p, "utf-8");
35353
35730
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
35354
35731
  return;
35355
35732
  }
@@ -35368,11 +35745,11 @@ var init_dev_server = __esm({
35368
35745
  this.json(res, 404, { error: `Provider not found: ${type}` });
35369
35746
  return;
35370
35747
  }
35371
- const target = fs13.existsSync(path17.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
35372
- const targetPath = path17.join(dir, target);
35748
+ const target = fs14.existsSync(path18.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
35749
+ const targetPath = path18.join(dir, target);
35373
35750
  try {
35374
- if (fs13.existsSync(targetPath)) fs13.copyFileSync(targetPath, targetPath + ".bak");
35375
- fs13.writeFileSync(targetPath, source, "utf-8");
35751
+ if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
35752
+ fs14.writeFileSync(targetPath, source, "utf-8");
35376
35753
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
35377
35754
  this.providerLoader.reload();
35378
35755
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -35529,21 +35906,21 @@ var init_dev_server = __esm({
35529
35906
  }
35530
35907
  let targetDir;
35531
35908
  targetDir = this.providerLoader.getUserProviderDir(category, type);
35532
- const jsonPath = path17.join(targetDir, "provider.json");
35533
- if (fs13.existsSync(jsonPath)) {
35909
+ const jsonPath = path18.join(targetDir, "provider.json");
35910
+ if (fs14.existsSync(jsonPath)) {
35534
35911
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
35535
35912
  return;
35536
35913
  }
35537
35914
  try {
35538
35915
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
35539
- fs13.mkdirSync(targetDir, { recursive: true });
35540
- fs13.writeFileSync(jsonPath, result["provider.json"], "utf-8");
35916
+ fs14.mkdirSync(targetDir, { recursive: true });
35917
+ fs14.writeFileSync(jsonPath, result["provider.json"], "utf-8");
35541
35918
  const createdFiles = ["provider.json"];
35542
35919
  if (result.files) {
35543
35920
  for (const [relPath, content] of Object.entries(result.files)) {
35544
- const fullPath = path17.join(targetDir, relPath);
35545
- fs13.mkdirSync(path17.dirname(fullPath), { recursive: true });
35546
- fs13.writeFileSync(fullPath, content, "utf-8");
35921
+ const fullPath = path18.join(targetDir, relPath);
35922
+ fs14.mkdirSync(path18.dirname(fullPath), { recursive: true });
35923
+ fs14.writeFileSync(fullPath, content, "utf-8");
35547
35924
  createdFiles.push(relPath);
35548
35925
  }
35549
35926
  }
@@ -35592,45 +35969,45 @@ var init_dev_server = __esm({
35592
35969
  }
35593
35970
  // ─── Phase 2: Auto-Implement Backend ───
35594
35971
  getLatestScriptVersionDir(scriptsDir) {
35595
- if (!fs13.existsSync(scriptsDir)) return null;
35596
- const versions = fs13.readdirSync(scriptsDir).filter((d) => {
35972
+ if (!fs14.existsSync(scriptsDir)) return null;
35973
+ const versions = fs14.readdirSync(scriptsDir).filter((d) => {
35597
35974
  try {
35598
- return fs13.statSync(path17.join(scriptsDir, d)).isDirectory();
35975
+ return fs14.statSync(path18.join(scriptsDir, d)).isDirectory();
35599
35976
  } catch {
35600
35977
  return false;
35601
35978
  }
35602
35979
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
35603
35980
  if (versions.length === 0) return null;
35604
- return path17.join(scriptsDir, versions[0]);
35981
+ return path18.join(scriptsDir, versions[0]);
35605
35982
  }
35606
35983
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
35607
- const canonicalUserDir = path17.resolve(this.providerLoader.getUserProviderDir(category, type));
35608
- const desiredDir = requestedDir ? path17.resolve(requestedDir) : canonicalUserDir;
35609
- const upstreamRoot = path17.resolve(this.providerLoader.getUpstreamDir());
35610
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path17.sep}`)) {
35984
+ const canonicalUserDir = path18.resolve(this.providerLoader.getUserProviderDir(category, type));
35985
+ const desiredDir = requestedDir ? path18.resolve(requestedDir) : canonicalUserDir;
35986
+ const upstreamRoot = path18.resolve(this.providerLoader.getUpstreamDir());
35987
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path18.sep}`)) {
35611
35988
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
35612
35989
  }
35613
- if (path17.basename(desiredDir) !== type) {
35990
+ if (path18.basename(desiredDir) !== type) {
35614
35991
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
35615
35992
  }
35616
35993
  const sourceDir = this.findProviderDir(type);
35617
35994
  if (!sourceDir) {
35618
35995
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
35619
35996
  }
35620
- if (!fs13.existsSync(desiredDir)) {
35621
- fs13.mkdirSync(path17.dirname(desiredDir), { recursive: true });
35622
- fs13.cpSync(sourceDir, desiredDir, { recursive: true });
35997
+ if (!fs14.existsSync(desiredDir)) {
35998
+ fs14.mkdirSync(path18.dirname(desiredDir), { recursive: true });
35999
+ fs14.cpSync(sourceDir, desiredDir, { recursive: true });
35623
36000
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
35624
36001
  }
35625
- const providerJson = path17.join(desiredDir, "provider.json");
35626
- if (!fs13.existsSync(providerJson)) {
36002
+ const providerJson = path18.join(desiredDir, "provider.json");
36003
+ if (!fs14.existsSync(providerJson)) {
35627
36004
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
35628
36005
  }
35629
36006
  try {
35630
- const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
36007
+ const providerData = JSON.parse(fs14.readFileSync(providerJson, "utf-8"));
35631
36008
  if (providerData.disableUpstream !== true) {
35632
36009
  providerData.disableUpstream = true;
35633
- fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
36010
+ fs14.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
35634
36011
  }
35635
36012
  } catch (error48) {
35636
36013
  return {
@@ -35670,7 +36047,7 @@ var init_dev_server = __esm({
35670
36047
  setMode: "set_mode.js"
35671
36048
  };
35672
36049
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
35673
- const scriptsDir = path17.join(providerDir, "scripts");
36050
+ const scriptsDir = path18.join(providerDir, "scripts");
35674
36051
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
35675
36052
  if (latestScriptsDir) {
35676
36053
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -35678,10 +36055,10 @@ var init_dev_server = __esm({
35678
36055
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
35679
36056
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
35680
36057
  lines.push("");
35681
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
36058
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
35682
36059
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
35683
36060
  try {
35684
- const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
36061
+ const content = fs14.readFileSync(path18.join(latestScriptsDir, file2), "utf-8");
35685
36062
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
35686
36063
  lines.push("```javascript");
35687
36064
  lines.push(content);
@@ -35691,14 +36068,14 @@ var init_dev_server = __esm({
35691
36068
  }
35692
36069
  }
35693
36070
  }
35694
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
36071
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
35695
36072
  if (refFiles.length > 0) {
35696
36073
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
35697
36074
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
35698
36075
  lines.push("");
35699
36076
  for (const file2 of refFiles) {
35700
36077
  try {
35701
- const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
36078
+ const content = fs14.readFileSync(path18.join(latestScriptsDir, file2), "utf-8");
35702
36079
  lines.push(`### \`${file2}\` \u{1F512}`);
35703
36080
  lines.push("```javascript");
35704
36081
  lines.push(content);
@@ -35739,11 +36116,11 @@ var init_dev_server = __esm({
35739
36116
  lines.push("");
35740
36117
  }
35741
36118
  }
35742
- const docsDir = path17.join(providerDir, "../../docs");
36119
+ const docsDir = path18.join(providerDir, "../../docs");
35743
36120
  const loadGuide = (name) => {
35744
36121
  try {
35745
- const p = path17.join(docsDir, name);
35746
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
36122
+ const p = path18.join(docsDir, name);
36123
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
35747
36124
  } catch {
35748
36125
  }
35749
36126
  return null;
@@ -35916,7 +36293,7 @@ var init_dev_server = __esm({
35916
36293
  parseApproval: "parse_approval.js"
35917
36294
  };
35918
36295
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
35919
- const scriptsDir = path17.join(providerDir, "scripts");
36296
+ const scriptsDir = path18.join(providerDir, "scripts");
35920
36297
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
35921
36298
  if (latestScriptsDir) {
35922
36299
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -35924,11 +36301,11 @@ var init_dev_server = __esm({
35924
36301
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
35925
36302
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
35926
36303
  lines.push("");
35927
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
36304
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
35928
36305
  if (!file2.endsWith(".js")) continue;
35929
36306
  if (!targetFileNames.has(file2)) continue;
35930
36307
  try {
35931
- const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
36308
+ const content = fs14.readFileSync(path18.join(latestScriptsDir, file2), "utf-8");
35932
36309
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
35933
36310
  lines.push("```javascript");
35934
36311
  lines.push(content);
@@ -35937,14 +36314,14 @@ var init_dev_server = __esm({
35937
36314
  } catch {
35938
36315
  }
35939
36316
  }
35940
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
36317
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
35941
36318
  if (refFiles.length > 0) {
35942
36319
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
35943
36320
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
35944
36321
  lines.push("");
35945
36322
  for (const file2 of refFiles) {
35946
36323
  try {
35947
- const content = fs13.readFileSync(path17.join(latestScriptsDir, file2), "utf-8");
36324
+ const content = fs14.readFileSync(path18.join(latestScriptsDir, file2), "utf-8");
35948
36325
  lines.push(`### \`${file2}\` \u{1F512}`);
35949
36326
  lines.push("```javascript");
35950
36327
  lines.push(content);
@@ -35977,11 +36354,11 @@ var init_dev_server = __esm({
35977
36354
  lines.push("");
35978
36355
  }
35979
36356
  }
35980
- const docsDir = path17.join(providerDir, "../../docs");
36357
+ const docsDir = path18.join(providerDir, "../../docs");
35981
36358
  const loadGuide = (name) => {
35982
36359
  try {
35983
- const p = path17.join(docsDir, name);
35984
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
36360
+ const p = path18.join(docsDir, name);
36361
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
35985
36362
  } catch {
35986
36363
  }
35987
36364
  return null;
@@ -36243,7 +36620,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
36243
36620
  }
36244
36621
  return {
36245
36622
  kind: "unix",
36246
- path: path22.join(os17.tmpdir(), `${appName}-session-host.sock`)
36623
+ path: path22.join(os18.tmpdir(), `${appName}-session-host.sock`)
36247
36624
  };
36248
36625
  }
36249
36626
  function serializeEnvelope(envelope) {
@@ -36265,11 +36642,11 @@ function createLineParser(onEnvelope) {
36265
36642
  }
36266
36643
  };
36267
36644
  }
36268
- var os17, path22, net2, import_crypto3, SessionHostClient;
36645
+ var os18, path22, net2, import_crypto3, SessionHostClient;
36269
36646
  var init_dist = __esm({
36270
36647
  "../../oss/packages/session-host-core/dist/index.mjs"() {
36271
36648
  "use strict";
36272
- os17 = __toESM(require("os"), 1);
36649
+ os18 = __toESM(require("os"), 1);
36273
36650
  path22 = __toESM(require("path"), 1);
36274
36651
  net2 = __toESM(require("net"), 1);
36275
36652
  import_crypto3 = require("crypto");
@@ -36812,9 +37189,187 @@ var init_runtime_support = __esm({
36812
37189
  });
36813
37190
 
36814
37191
  // ../../oss/packages/daemon-core/src/installer.ts
37192
+ function isExtensionInstalled(ide, marketplaceId) {
37193
+ if (!ide.cliCommand) return false;
37194
+ try {
37195
+ const result = (0, import_child_process10.execSync)(`"${ide.cliCommand}" --list-extensions`, {
37196
+ encoding: "utf-8",
37197
+ timeout: 15e3,
37198
+ stdio: ["pipe", "pipe", "pipe"]
37199
+ });
37200
+ const installed = result.trim().split("\n").map((e) => e.trim().toLowerCase());
37201
+ return installed.includes(marketplaceId.toLowerCase());
37202
+ } catch {
37203
+ return false;
37204
+ }
37205
+ }
37206
+ async function installExtension(ide, extension) {
37207
+ if (!ide.cliCommand) {
37208
+ return {
37209
+ extensionId: extension.id,
37210
+ marketplaceId: extension.marketplaceId,
37211
+ success: false,
37212
+ alreadyInstalled: false,
37213
+ error: `No CLI command found for ${ide.displayName}. Please install it manually.`
37214
+ };
37215
+ }
37216
+ const alreadyInstalled = isExtensionInstalled(ide, extension.marketplaceId);
37217
+ if (alreadyInstalled) {
37218
+ return {
37219
+ extensionId: extension.id,
37220
+ marketplaceId: extension.marketplaceId,
37221
+ success: true,
37222
+ alreadyInstalled: true
37223
+ };
37224
+ }
37225
+ if (extension.vsixUrl) {
37226
+ try {
37227
+ const tmpDir = (await import("os")).tmpdir();
37228
+ const vsixPath = `${tmpDir}/adhdev-extension-latest.vsix`;
37229
+ const res = await fetch(extension.vsixUrl);
37230
+ if (res.ok) {
37231
+ const buffer = Buffer.from(await res.arrayBuffer());
37232
+ const fs18 = await import("fs");
37233
+ fs18.writeFileSync(vsixPath, buffer);
37234
+ return new Promise((resolve13) => {
37235
+ const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
37236
+ (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
37237
+ resolve13({
37238
+ extensionId: extension.id,
37239
+ marketplaceId: extension.marketplaceId,
37240
+ success: !error48,
37241
+ alreadyInstalled: false,
37242
+ error: error48 ? stderr || error48.message : void 0
37243
+ });
37244
+ });
37245
+ });
37246
+ }
37247
+ } catch (e) {
37248
+ }
37249
+ }
37250
+ return new Promise((resolve13) => {
37251
+ const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
37252
+ (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
37253
+ if (error48) {
37254
+ resolve13({
37255
+ extensionId: extension.id,
37256
+ marketplaceId: extension.marketplaceId,
37257
+ success: false,
37258
+ alreadyInstalled: false,
37259
+ error: stderr || error48.message
37260
+ });
37261
+ } else {
37262
+ resolve13({
37263
+ extensionId: extension.id,
37264
+ marketplaceId: extension.marketplaceId,
37265
+ success: true,
37266
+ alreadyInstalled: false
37267
+ });
37268
+ }
37269
+ });
37270
+ });
37271
+ }
37272
+ async function installExtensions(ide, extensions, onProgress) {
37273
+ const results = [];
37274
+ for (let i = 0; i < extensions.length; i++) {
37275
+ const ext = extensions[i];
37276
+ const result = await installExtension(ide, ext);
37277
+ results.push(result);
37278
+ onProgress?.(i + 1, extensions.length, ext, result);
37279
+ }
37280
+ return results;
37281
+ }
37282
+ function getAIExtensions() {
37283
+ return EXTENSION_CATALOG.filter((e) => e.category === "ai-agent");
37284
+ }
37285
+ function launchIDE(ide, workspacePath) {
37286
+ if (!ide.cliCommand) return false;
37287
+ try {
37288
+ const args = workspacePath ? `"${workspacePath}"` : "";
37289
+ (0, import_child_process10.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
37290
+ return true;
37291
+ } catch {
37292
+ return false;
37293
+ }
37294
+ }
37295
+ var import_child_process10, EXTENSION_CATALOG;
36815
37296
  var init_installer = __esm({
36816
37297
  "../../oss/packages/daemon-core/src/installer.ts"() {
36817
37298
  "use strict";
37299
+ import_child_process10 = require("child_process");
37300
+ EXTENSION_CATALOG = [
37301
+ // AI Agent extensions
37302
+ {
37303
+ id: "roo-code",
37304
+ name: "Roo Code",
37305
+ displayName: "Roo Code (Roo Cline)",
37306
+ marketplaceId: "rooveterinaryinc.roo-cline",
37307
+ description: "Open-source AI coding assistant with multiple modes",
37308
+ category: "ai-agent",
37309
+ icon: "\u{1F998}",
37310
+ recommended: true,
37311
+ website: "https://roocode.com"
37312
+ },
37313
+ {
37314
+ id: "github-copilot",
37315
+ name: "GitHub Copilot",
37316
+ displayName: "GitHub Copilot",
37317
+ marketplaceId: "github.copilot",
37318
+ description: "AI pair programmer by GitHub",
37319
+ category: "ai-agent",
37320
+ icon: "\u{1F916}",
37321
+ recommended: true,
37322
+ requiresApiKey: true,
37323
+ apiKeyName: "GitHub account",
37324
+ website: "https://github.com/features/copilot"
37325
+ },
37326
+ {
37327
+ id: "copilot-chat",
37328
+ name: "GitHub Copilot Chat",
37329
+ displayName: "GitHub Copilot Chat",
37330
+ marketplaceId: "github.copilot-chat",
37331
+ description: "Chat interface for GitHub Copilot",
37332
+ category: "ai-agent",
37333
+ icon: "\u{1F4AC}",
37334
+ recommended: true,
37335
+ requiresApiKey: true,
37336
+ apiKeyName: "GitHub account"
37337
+ },
37338
+ {
37339
+ id: "cline",
37340
+ name: "Cline",
37341
+ displayName: "Cline",
37342
+ marketplaceId: "saoudrizwan.claude-dev",
37343
+ description: "Autonomous AI coding agent in your IDE",
37344
+ category: "ai-agent",
37345
+ icon: "\u{1F9E0}",
37346
+ recommended: false,
37347
+ requiresApiKey: true,
37348
+ apiKeyName: "Anthropic/OpenAI API key"
37349
+ },
37350
+ {
37351
+ id: "continue",
37352
+ name: "Continue",
37353
+ displayName: "Continue",
37354
+ marketplaceId: "continue.continue",
37355
+ description: "Open-source AI code assistant with custom models",
37356
+ category: "ai-agent",
37357
+ icon: "\u25B6\uFE0F",
37358
+ recommended: false
37359
+ },
37360
+ {
37361
+ id: "aider",
37362
+ name: "Aider",
37363
+ displayName: "Aider",
37364
+ marketplaceId: "aider.aider",
37365
+ description: "AI pair programming in your terminal",
37366
+ category: "ai-agent",
37367
+ icon: "\u{1F527}",
37368
+ recommended: false,
37369
+ requiresApiKey: true,
37370
+ apiKeyName: "OpenAI/Anthropic API key"
37371
+ }
37372
+ ];
36818
37373
  }
36819
37374
  });
36820
37375
 
@@ -37019,6 +37574,18 @@ async function initDaemonComponents(config2) {
37019
37574
  detectedIdes: detectedIdesRef
37020
37575
  };
37021
37576
  }
37577
+ async function startDaemonDevSupport(options) {
37578
+ const devServer = new DevServer({
37579
+ providerLoader: options.components.providerLoader,
37580
+ cdpManagers: options.components.cdpManagers,
37581
+ instanceManager: options.components.instanceManager,
37582
+ cliManager: options.components.cliManager,
37583
+ logFn: options.logFn
37584
+ });
37585
+ await devServer.start();
37586
+ options.components.providerLoader.watch();
37587
+ return devServer;
37588
+ }
37022
37589
  async function shutdownDaemonComponents(components) {
37023
37590
  const {
37024
37591
  poller,
@@ -37079,6 +37646,84 @@ var init_daemon_lifecycle = __esm({
37079
37646
  });
37080
37647
 
37081
37648
  // ../../oss/packages/daemon-core/src/index.ts
37649
+ var src_exports = {};
37650
+ __export(src_exports, {
37651
+ AcpProviderInstance: () => AcpProviderInstance,
37652
+ AgentStreamPoller: () => AgentStreamPoller,
37653
+ CdpDomHandlers: () => CdpDomHandlers,
37654
+ CliProviderInstance: () => CliProviderInstance,
37655
+ DAEMON_WS_PATH: () => DAEMON_WS_PATH,
37656
+ DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
37657
+ DaemonAgentStreamManager: () => DaemonAgentStreamManager,
37658
+ DaemonCdpInitializer: () => DaemonCdpInitializer,
37659
+ DaemonCdpManager: () => DaemonCdpManager,
37660
+ DaemonCdpScanner: () => DaemonCdpScanner,
37661
+ DaemonCliManager: () => DaemonCliManager,
37662
+ DaemonCommandHandler: () => DaemonCommandHandler,
37663
+ DaemonCommandRouter: () => DaemonCommandRouter,
37664
+ DaemonStatusReporter: () => DaemonStatusReporter,
37665
+ DevServer: () => DevServer,
37666
+ IdeProviderInstance: () => IdeProviderInstance,
37667
+ LOG: () => LOG,
37668
+ NodePtyTransportFactory: () => NodePtyTransportFactory,
37669
+ ProviderCliAdapter: () => ProviderCliAdapter,
37670
+ ProviderInstanceManager: () => ProviderInstanceManager,
37671
+ ProviderLoader: () => ProviderLoader,
37672
+ SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
37673
+ VersionArchive: () => VersionArchive,
37674
+ appendRecentActivity: () => appendRecentActivity,
37675
+ buildSessionEntries: () => buildSessionEntries,
37676
+ buildStatusSnapshot: () => buildStatusSnapshot,
37677
+ connectCdpManager: () => connectCdpManager,
37678
+ detectAllVersions: () => detectAllVersions,
37679
+ detectCLIs: () => detectCLIs,
37680
+ detectIDEs: () => detectIDEs,
37681
+ ensureSessionHostReady: () => ensureSessionHostReady,
37682
+ findCdpManager: () => findCdpManager,
37683
+ forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
37684
+ getAIExtensions: () => getAIExtensions,
37685
+ getAvailableIdeIds: () => getAvailableIdeIds,
37686
+ getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
37687
+ getDaemonLogDir: () => getDaemonLogDir,
37688
+ getHostMemorySnapshot: () => getHostMemorySnapshot,
37689
+ getLogLevel: () => getLogLevel,
37690
+ getRecentActivity: () => getRecentActivity,
37691
+ getRecentCommands: () => getRecentCommands,
37692
+ getRecentLogs: () => getRecentLogs,
37693
+ getSavedProviderSessions: () => getSavedProviderSessions,
37694
+ getWorkspaceState: () => getWorkspaceState,
37695
+ hasCdpManager: () => hasCdpManager,
37696
+ initDaemonComponents: () => initDaemonComponents,
37697
+ installExtensions: () => installExtensions,
37698
+ installGlobalInterceptor: () => installGlobalInterceptor,
37699
+ isCdpConnected: () => isCdpConnected,
37700
+ isExtensionInstalled: () => isExtensionInstalled,
37701
+ isIdeRunning: () => isIdeRunning,
37702
+ isManagedStatusWaiting: () => isManagedStatusWaiting,
37703
+ isManagedStatusWorking: () => isManagedStatusWorking,
37704
+ isSetupComplete: () => isSetupComplete,
37705
+ killIdeProcess: () => killIdeProcess,
37706
+ launchIDE: () => launchIDE,
37707
+ launchWithCdp: () => launchWithCdp,
37708
+ listHostedCliRuntimes: () => listHostedCliRuntimes,
37709
+ loadConfig: () => loadConfig,
37710
+ logCommand: () => logCommand,
37711
+ markSetupComplete: () => markSetupComplete,
37712
+ maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
37713
+ normalizeActiveChatData: () => normalizeActiveChatData,
37714
+ normalizeManagedStatus: () => normalizeManagedStatus,
37715
+ probeCdpPort: () => probeCdpPort,
37716
+ readChatHistory: () => readChatHistory,
37717
+ registerExtensionProviders: () => registerExtensionProviders,
37718
+ resetConfig: () => resetConfig,
37719
+ saveConfig: () => saveConfig,
37720
+ setLogLevel: () => setLogLevel,
37721
+ setupIdeInstance: () => setupIdeInstance,
37722
+ shutdownDaemonComponents: () => shutdownDaemonComponents,
37723
+ startDaemonDevSupport: () => startDaemonDevSupport,
37724
+ updateConfig: () => updateConfig,
37725
+ upsertSavedProviderSession: () => upsertSavedProviderSession
37726
+ });
37082
37727
  var init_src = __esm({
37083
37728
  "../../oss/packages/daemon-core/src/index.ts"() {
37084
37729
  "use strict";
@@ -37426,17 +38071,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
37426
38071
  return false;
37427
38072
  }
37428
38073
  }
37429
- var fs14, path18, os18, import_node_module2, esmRequire, logFile, log, logDebug, DaemonP2PSender;
38074
+ var fs15, path19, os19, import_node_module2, esmRequire, logFile, log, logDebug, DaemonP2PSender;
37430
38075
  var init_daemon_p2p = __esm({
37431
38076
  "src/daemon-p2p.ts"() {
37432
38077
  "use strict";
37433
- fs14 = __toESM(require("fs"));
38078
+ fs15 = __toESM(require("fs"));
37434
38079
  init_src();
37435
- path18 = __toESM(require("path"));
37436
- os18 = __toESM(require("os"));
38080
+ path19 = __toESM(require("path"));
38081
+ os19 = __toESM(require("os"));
37437
38082
  import_node_module2 = require("module");
37438
38083
  esmRequire = (0, import_node_module2.createRequire)(__filename);
37439
- logFile = path18.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
38084
+ logFile = path19.join(os19.tmpdir(), "adhdev_daemon_p2p.log");
37440
38085
  log = (msg) => {
37441
38086
  LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
37442
38087
  };
@@ -37504,17 +38149,17 @@ ${e?.stack || ""}`);
37504
38149
  const prebuildKey = `${platform11}-${arch3}`;
37505
38150
  try {
37506
38151
  const candidates = [
37507
- path18.join(__dirname, "node_modules", "node-datachannel"),
37508
- path18.join(__dirname, "..", "node_modules", "node-datachannel"),
37509
- path18.join(__dirname, "..", "..", "node_modules", "node-datachannel")
38152
+ path19.join(__dirname, "node_modules", "node-datachannel"),
38153
+ path19.join(__dirname, "..", "node_modules", "node-datachannel"),
38154
+ path19.join(__dirname, "..", "..", "node_modules", "node-datachannel")
37510
38155
  ];
37511
38156
  for (const candidate of candidates) {
37512
- const prebuildPath = path18.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
37513
- if (fs14.existsSync(prebuildPath)) {
37514
- const targetDir = path18.join(candidate, "build", "Release");
37515
- const targetPath = path18.join(targetDir, "node_datachannel.node");
37516
- fs14.mkdirSync(targetDir, { recursive: true });
37517
- fs14.copyFileSync(prebuildPath, targetPath);
38157
+ const prebuildPath = path19.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
38158
+ if (fs15.existsSync(prebuildPath)) {
38159
+ const targetDir = path19.join(candidate, "build", "Release");
38160
+ const targetPath = path19.join(targetDir, "node_datachannel.node");
38161
+ fs15.mkdirSync(targetDir, { recursive: true });
38162
+ fs15.copyFileSync(prebuildPath, targetPath);
37518
38163
  try {
37519
38164
  delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
37520
38165
  } catch {
@@ -38424,23 +39069,23 @@ function buildSessionHostEnv(baseEnv) {
38424
39069
  }
38425
39070
  function resolveSessionHostEntry() {
38426
39071
  const packagedCandidates = [
38427
- path19.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
38428
- path19.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
39072
+ path20.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
39073
+ path20.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
38429
39074
  ];
38430
39075
  for (const candidate of packagedCandidates) {
38431
- if (fs15.existsSync(candidate)) {
39076
+ if (fs16.existsSync(candidate)) {
38432
39077
  return candidate;
38433
39078
  }
38434
39079
  }
38435
39080
  return require.resolve("@adhdev/session-host-daemon");
38436
39081
  }
38437
39082
  function getSessionHostPidFile() {
38438
- return path19.join(os19.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
39083
+ return path20.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
38439
39084
  }
38440
- function killPid(pid) {
39085
+ function killPid2(pid) {
38441
39086
  try {
38442
39087
  if (process.platform === "win32") {
38443
- (0, import_child_process9.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
39088
+ (0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
38444
39089
  } else {
38445
39090
  process.kill(pid, "SIGTERM");
38446
39091
  }
@@ -38453,26 +39098,26 @@ function stopSessionHost() {
38453
39098
  let stopped = false;
38454
39099
  const pidFile = getSessionHostPidFile();
38455
39100
  try {
38456
- if (fs15.existsSync(pidFile)) {
38457
- const pid = Number.parseInt(fs15.readFileSync(pidFile, "utf8").trim(), 10);
39101
+ if (fs16.existsSync(pidFile)) {
39102
+ const pid = Number.parseInt(fs16.readFileSync(pidFile, "utf8").trim(), 10);
38458
39103
  if (Number.isFinite(pid)) {
38459
- stopped = killPid(pid) || stopped;
39104
+ stopped = killPid2(pid) || stopped;
38460
39105
  }
38461
39106
  }
38462
39107
  } catch {
38463
39108
  } finally {
38464
39109
  try {
38465
- fs15.unlinkSync(pidFile);
39110
+ fs16.unlinkSync(pidFile);
38466
39111
  } catch {
38467
39112
  }
38468
39113
  }
38469
39114
  if (process.platform !== "win32") {
38470
39115
  try {
38471
- const raw = (0, import_child_process9.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
39116
+ const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
38472
39117
  for (const line of raw.split("\n")) {
38473
39118
  const pid = Number.parseInt(line.trim(), 10);
38474
39119
  if (Number.isFinite(pid)) {
38475
- stopped = killPid(pid) || stopped;
39120
+ stopped = killPid2(pid) || stopped;
38476
39121
  }
38477
39122
  }
38478
39123
  } catch {
@@ -38483,7 +39128,7 @@ function stopSessionHost() {
38483
39128
  async function ensureSessionHostReady2() {
38484
39129
  const spawnHost = () => {
38485
39130
  const entry = resolveSessionHostEntry();
38486
- const child = (0, import_child_process9.spawn)(process.execPath, [entry], {
39131
+ const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
38487
39132
  detached: true,
38488
39133
  stdio: "ignore",
38489
39134
  windowsHide: true,
@@ -38513,46 +39158,75 @@ async function ensureSessionHostReady2() {
38513
39158
  async function listHostedCliRuntimes2(endpoint) {
38514
39159
  return listHostedCliRuntimes(endpoint);
38515
39160
  }
38516
- var import_child_process9, fs15, os19, path19, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
39161
+ var import_child_process11, fs16, os20, path20, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
38517
39162
  var init_session_host = __esm({
38518
39163
  "src/session-host.ts"() {
38519
39164
  "use strict";
38520
- import_child_process9 = require("child_process");
38521
- fs15 = __toESM(require("fs"));
38522
- os19 = __toESM(require("os"));
38523
- path19 = __toESM(require("path"));
39165
+ import_child_process11 = require("child_process");
39166
+ fs16 = __toESM(require("fs"));
39167
+ os20 = __toESM(require("os"));
39168
+ path20 = __toESM(require("path"));
38524
39169
  init_src();
39170
+ init_dist();
38525
39171
  SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
38526
39172
  SESSION_HOST_START_TIMEOUT_MS = 15e3;
38527
39173
  }
38528
39174
  });
38529
39175
 
39176
+ // src/version.ts
39177
+ function resolvePackageVersion(options) {
39178
+ const injectedVersion = options?.injectedVersion || "unknown";
39179
+ const dir = options?.dirname || __dirname;
39180
+ const possiblePaths = [
39181
+ (0, import_path2.join)(dir, "..", "..", "package.json"),
39182
+ (0, import_path2.join)(dir, "..", "package.json"),
39183
+ (0, import_path2.join)(dir, "package.json")
39184
+ ];
39185
+ for (const p of possiblePaths) {
39186
+ try {
39187
+ const data = JSON.parse((0, import_fs3.readFileSync)(p, "utf-8"));
39188
+ if (data.version) return data.version;
39189
+ } catch {
39190
+ }
39191
+ }
39192
+ return injectedVersion;
39193
+ }
39194
+ var import_fs3, import_path2;
39195
+ var init_version = __esm({
39196
+ "src/version.ts"() {
39197
+ "use strict";
39198
+ import_fs3 = require("fs");
39199
+ import_path2 = require("path");
39200
+ }
39201
+ });
39202
+
38530
39203
  // src/adhdev-daemon.ts
38531
39204
  var adhdev_daemon_exports = {};
38532
39205
  __export(adhdev_daemon_exports, {
38533
39206
  AdhdevDaemon: () => AdhdevDaemon,
39207
+ getDaemonPid: () => getDaemonPid,
38534
39208
  isDaemonRunning: () => isDaemonRunning,
38535
39209
  stopDaemon: () => stopDaemon
38536
39210
  });
38537
39211
  function getDaemonPidFile() {
38538
- const dir = path20.join(os20.homedir(), ".adhdev");
38539
- if (!fs16.existsSync(dir)) fs16.mkdirSync(dir, { recursive: true });
38540
- return path20.join(dir, "daemon.pid");
39212
+ const dir = path21.join(os21.homedir(), ".adhdev");
39213
+ if (!fs17.existsSync(dir)) fs17.mkdirSync(dir, { recursive: true });
39214
+ return path21.join(dir, "daemon.pid");
38541
39215
  }
38542
39216
  function writeDaemonPid(pid) {
38543
- fs16.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
39217
+ fs17.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
38544
39218
  }
38545
39219
  function removeDaemonPid() {
38546
39220
  try {
38547
- fs16.unlinkSync(getDaemonPidFile());
39221
+ fs17.unlinkSync(getDaemonPidFile());
38548
39222
  } catch (e) {
38549
39223
  }
38550
39224
  }
38551
39225
  function isDaemonRunning() {
38552
39226
  const pidFile = getDaemonPidFile();
38553
39227
  try {
38554
- if (!fs16.existsSync(pidFile)) return false;
38555
- const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
39228
+ if (!fs17.existsSync(pidFile)) return false;
39229
+ const pid = parseInt(fs17.readFileSync(pidFile, "utf-8").trim());
38556
39230
  process.kill(pid, 0);
38557
39231
  return true;
38558
39232
  } catch {
@@ -38560,11 +39234,21 @@ function isDaemonRunning() {
38560
39234
  return false;
38561
39235
  }
38562
39236
  }
39237
+ function getDaemonPid() {
39238
+ const pidFile = getDaemonPidFile();
39239
+ try {
39240
+ if (!fs17.existsSync(pidFile)) return null;
39241
+ const pid = parseInt(fs17.readFileSync(pidFile, "utf-8").trim(), 10);
39242
+ return Number.isFinite(pid) ? pid : null;
39243
+ } catch {
39244
+ return null;
39245
+ }
39246
+ }
38563
39247
  function stopDaemon() {
38564
39248
  const pidFile = getDaemonPidFile();
38565
39249
  try {
38566
- if (!fs16.existsSync(pidFile)) return false;
38567
- const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
39250
+ if (!fs17.existsSync(pidFile)) return false;
39251
+ const pid = parseInt(fs17.readFileSync(pidFile, "utf-8").trim());
38568
39252
  process.kill(pid, "SIGTERM");
38569
39253
  removeDaemonPid();
38570
39254
  return true;
@@ -38573,7 +39257,7 @@ function stopDaemon() {
38573
39257
  return false;
38574
39258
  }
38575
39259
  }
38576
- var os20, fs16, path20, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
39260
+ var os21, fs17, path21, import_http, import_ws3, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
38577
39261
  var init_adhdev_daemon = __esm({
38578
39262
  "src/adhdev-daemon.ts"() {
38579
39263
  "use strict";
@@ -38583,30 +39267,14 @@ var init_adhdev_daemon = __esm({
38583
39267
  init_screenshot_controller();
38584
39268
  init_session_host();
38585
39269
  init_dist();
38586
- os20 = __toESM(require("os"));
38587
- fs16 = __toESM(require("fs"));
38588
- path20 = __toESM(require("path"));
39270
+ os21 = __toESM(require("os"));
39271
+ fs17 = __toESM(require("fs"));
39272
+ path21 = __toESM(require("path"));
39273
+ import_http = require("http");
39274
+ import_ws3 = require("ws");
38589
39275
  import_chalk2 = __toESM(require("chalk"));
38590
- pkgVersion = "0.8.8";
38591
- if (pkgVersion === "unknown") {
38592
- try {
38593
- const possiblePaths = [
38594
- path20.join(__dirname, "..", "package.json"),
38595
- path20.join(__dirname, "package.json")
38596
- ];
38597
- for (const p of possiblePaths) {
38598
- try {
38599
- const data = JSON.parse(fs16.readFileSync(p, "utf-8"));
38600
- if (data.version) {
38601
- pkgVersion = data.version;
38602
- break;
38603
- }
38604
- } catch {
38605
- }
38606
- }
38607
- } catch {
38608
- }
38609
- }
39276
+ init_version();
39277
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.10" });
38610
39278
  DANGEROUS_PATTERNS = [
38611
39279
  /\brm\s+(-[a-z]*f|-[a-z]*r|--force|--recursive)/i,
38612
39280
  /\bsudo\b/i,
@@ -38620,6 +39288,9 @@ var init_adhdev_daemon = __esm({
38620
39288
  /\b:\/\)\s*\{/
38621
39289
  ];
38622
39290
  AdhdevDaemon = class {
39291
+ localHttpServer = null;
39292
+ localWss = null;
39293
+ localClients = /* @__PURE__ */ new Set();
38623
39294
  serverConn = null;
38624
39295
  p2p = null;
38625
39296
  screenshotController = null;
@@ -38647,11 +39318,7 @@ var init_adhdev_daemon = __esm({
38647
39318
  return mode === "chat" || mode === "terminal";
38648
39319
  }
38649
39320
  async start(options = {}) {
38650
- try {
38651
- const { installGlobalInterceptor: installGlobalInterceptor2 } = require("./logging/logger");
38652
- installGlobalInterceptor2();
38653
- } catch {
38654
- }
39321
+ installGlobalInterceptor();
38655
39322
  process.on("uncaughtException", (err) => {
38656
39323
  LOG.error("Daemon", `Uncaught exception: ${err?.message}
38657
39324
  ${err?.stack || ""}`);
@@ -38727,6 +39394,7 @@ ${err?.stack || ""}`);
38727
39394
  }
38728
39395
  });
38729
39396
  await this.components.cliManager.restoreHostedSessions();
39397
+ await this.startLocalIpcServer();
38730
39398
  this.components.providerLoader.fetchLatest().then(({ updated }) => {
38731
39399
  if (updated) {
38732
39400
  this.components.providerLoader.reload();
@@ -38743,8 +39411,8 @@ ${err?.stack || ""}`);
38743
39411
  cliInfo: {
38744
39412
  type: "adhdev-daemon",
38745
39413
  version: pkgVersion,
38746
- platform: os20.platform(),
38747
- hostname: os20.hostname(),
39414
+ platform: os21.platform(),
39415
+ hostname: os21.hostname(),
38748
39416
  machineId: config2.machineId,
38749
39417
  instanceId
38750
39418
  }
@@ -38883,6 +39551,7 @@ ${err?.stack || ""}`);
38883
39551
  const cdpManagers = this.components?.cdpManagers;
38884
39552
  const cdpStatus = cdpManagers && cdpManagers.size > 0 ? `\u2705 ${[...cdpManagers.entries()].map(([k, m]) => `${k}:${m.getPort()}`).join(", ")}` : "\u274C not connected";
38885
39553
  console.log(` ${import_chalk2.default.bold("CDP:")} ${cdpStatus}`);
39554
+ console.log(` ${import_chalk2.default.bold("IPC:")} ${import_chalk2.default.cyan(`ws://127.0.0.1:${this.localPort}${DAEMON_WS_PATH}`)}`);
38886
39555
  console.log(` ${import_chalk2.default.bold("P2P:")} ${this.p2p?.isAvailable ? "\u2705 available" : "\u274C unavailable"}`);
38887
39556
  const providerCount = this.components?.providerLoader.getAll().length ?? 0;
38888
39557
  console.log(` ${import_chalk2.default.bold("Providers:")} ${providerCount > 0 ? `\u2705 ${providerCount} loaded` : "\u274C not loaded"}`);
@@ -38927,8 +39596,8 @@ ${err?.stack || ""}`);
38927
39596
  return;
38928
39597
  }
38929
39598
  const cwd = args?.dir || process.cwd();
38930
- const { exec: exec2 } = require("child_process");
38931
- exec2(cmdStr, { cwd, timeout: 6e4 }, (err, stdout, stderr) => {
39599
+ const { exec: exec3 } = require("child_process");
39600
+ exec3(cmdStr, { cwd, timeout: 6e4 }, (err, stdout, stderr) => {
38932
39601
  if (!this.serverConn) return;
38933
39602
  if (err) this.serverConn.sendMessage("log", { message: `\u274C ${err.message}`, level: "error" });
38934
39603
  else {
@@ -38999,6 +39668,135 @@ ${err?.stack || ""}`);
38999
39668
  return { success: false, error: e.message };
39000
39669
  }
39001
39670
  }
39671
+ async startLocalIpcServer() {
39672
+ if (this.localHttpServer || this.localWss) return;
39673
+ this.localHttpServer = (0, import_http.createServer)((req, res) => {
39674
+ const url2 = req.url || "/";
39675
+ if (req.method === "GET" && url2 === "/health") {
39676
+ res.writeHead(200, { "Content-Type": "application/json" });
39677
+ res.end(JSON.stringify({
39678
+ ok: true,
39679
+ pid: process.pid,
39680
+ wsPath: DAEMON_WS_PATH,
39681
+ port: this.localPort
39682
+ }));
39683
+ return;
39684
+ }
39685
+ res.writeHead(404, { "Content-Type": "application/json" });
39686
+ res.end(JSON.stringify({ error: "Not found" }));
39687
+ });
39688
+ this.localWss = new import_ws3.WebSocketServer({ noServer: true });
39689
+ this.localWss.on("connection", (ws) => this.handleLocalIpcConnection(ws));
39690
+ this.localHttpServer.on("upgrade", (req, socket, head) => {
39691
+ const wsUrl = new URL(req.url || "/", `http://${req.headers.host || "127.0.0.1"}`);
39692
+ if (wsUrl.pathname !== DAEMON_WS_PATH) {
39693
+ socket.write("HTTP/1.1 404 Not Found\r\n\r\n");
39694
+ socket.destroy();
39695
+ return;
39696
+ }
39697
+ this.localWss.handleUpgrade(req, socket, head, (ws) => {
39698
+ this.localWss.emit("connection", ws, req);
39699
+ });
39700
+ });
39701
+ await new Promise((resolve13, reject) => {
39702
+ const cleanup = () => {
39703
+ this.localHttpServer?.off("error", onError);
39704
+ this.localHttpServer?.off("listening", onListening);
39705
+ };
39706
+ const onError = (error48) => {
39707
+ cleanup();
39708
+ reject(error48);
39709
+ };
39710
+ const onListening = () => {
39711
+ cleanup();
39712
+ resolve13();
39713
+ };
39714
+ this.localHttpServer.once("error", onError);
39715
+ this.localHttpServer.once("listening", onListening);
39716
+ this.localHttpServer.listen(this.localPort, "127.0.0.1");
39717
+ });
39718
+ LOG.info("IPC", `Local IPC listening on ws://127.0.0.1:${this.localPort}${DAEMON_WS_PATH}`);
39719
+ }
39720
+ handleLocalIpcConnection(ws) {
39721
+ this.localClients.add(ws);
39722
+ this.sendLocalIpcWelcome(ws);
39723
+ ws.on("message", (raw) => {
39724
+ void this.handleLocalIpcMessage(ws, raw.toString());
39725
+ });
39726
+ ws.on("close", () => {
39727
+ this.localClients.delete(ws);
39728
+ });
39729
+ ws.on("error", () => {
39730
+ this.localClients.delete(ws);
39731
+ });
39732
+ }
39733
+ sendLocalIpcWelcome(ws) {
39734
+ try {
39735
+ const cliAgents = this.components ? this.components.instanceManager.collectAllStates().filter((state) => state?.category === "cli").map((state) => String(state?.instanceId || "")).filter(Boolean) : [];
39736
+ ws.send(JSON.stringify({
39737
+ type: "daemon:welcome",
39738
+ payload: {
39739
+ daemonVersion: pkgVersion,
39740
+ serverConnected: this.serverConn?.isConnected() ?? false,
39741
+ cdpConnected: (this.components?.cdpManagers.size || 0) > 0,
39742
+ localPort: this.localPort,
39743
+ cliAgents
39744
+ }
39745
+ }));
39746
+ } catch (error48) {
39747
+ LOG.warn("IPC", `Failed to send welcome: ${error48?.message || error48}`);
39748
+ }
39749
+ }
39750
+ async handleLocalIpcMessage(ws, raw) {
39751
+ let msg;
39752
+ try {
39753
+ msg = JSON.parse(raw);
39754
+ } catch {
39755
+ return;
39756
+ }
39757
+ if (!msg || typeof msg !== "object") return;
39758
+ if (msg.type === "ext:register") {
39759
+ this.sendLocalIpcWelcome(ws);
39760
+ return;
39761
+ }
39762
+ if (msg.type !== "ext:command") return;
39763
+ const payload = msg.payload && typeof msg.payload === "object" ? msg.payload : {};
39764
+ const command = typeof payload.command === "string" ? payload.command : "";
39765
+ const args = payload.args && typeof payload.args === "object" ? payload.args : {};
39766
+ const requestId = typeof payload.requestId === "string" ? payload.requestId : typeof payload.messageId === "string" ? payload.messageId : `ipc-${Date.now()}`;
39767
+ if (!command) {
39768
+ ws.send(JSON.stringify({
39769
+ type: "ext:command_result",
39770
+ payload: {
39771
+ requestId,
39772
+ success: false,
39773
+ error: "command required"
39774
+ }
39775
+ }));
39776
+ return;
39777
+ }
39778
+ try {
39779
+ const result = await this.components.router.execute(command, args, "ipc");
39780
+ ws.send(JSON.stringify({
39781
+ type: "ext:command_result",
39782
+ payload: {
39783
+ requestId,
39784
+ success: !!result?.success,
39785
+ result,
39786
+ error: result?.success ? void 0 : result?.error
39787
+ }
39788
+ }));
39789
+ } catch (error48) {
39790
+ ws.send(JSON.stringify({
39791
+ type: "ext:command_result",
39792
+ payload: {
39793
+ requestId,
39794
+ success: false,
39795
+ error: error48?.message || String(error48)
39796
+ }
39797
+ }));
39798
+ }
39799
+ }
39002
39800
  // ─── executeDaemonCommand / stopIde: Removed — now in DaemonCommandRouter ───
39003
39801
  sendResult(msg, success2, extra) {
39004
39802
  if (!msg.id) return;
@@ -39039,6 +39837,23 @@ ${err?.stack || ""}`);
39039
39837
  this.serverConn?.disconnect();
39040
39838
  } catch {
39041
39839
  }
39840
+ try {
39841
+ for (const client of this.localClients) {
39842
+ client.close();
39843
+ }
39844
+ this.localClients.clear();
39845
+ this.localWss?.close();
39846
+ this.localWss = null;
39847
+ await new Promise((resolve13) => {
39848
+ if (!this.localHttpServer) {
39849
+ resolve13();
39850
+ return;
39851
+ }
39852
+ this.localHttpServer.close(() => resolve13());
39853
+ this.localHttpServer = null;
39854
+ });
39855
+ } catch {
39856
+ }
39042
39857
  removeDaemonPid();
39043
39858
  console.log(import_chalk2.default.green(" \u2713 ADHDev Daemon stopped.\n"));
39044
39859
  if (exitProcess) {
@@ -39112,10 +39927,10 @@ async function runWizard(options = {}) {
39112
39927
  }
39113
39928
  async function checkForUpdate() {
39114
39929
  try {
39115
- const { execSync: execSync6 } = await import("child_process");
39930
+ const { execSync: execSync7 } = await import("child_process");
39116
39931
  let currentVersion = null;
39117
39932
  try {
39118
- currentVersion = execSync6("adhdev --version", {
39933
+ currentVersion = execSync7("adhdev --version", {
39119
39934
  encoding: "utf-8",
39120
39935
  timeout: 3e3,
39121
39936
  stdio: ["pipe", "pipe", "pipe"]
@@ -39125,7 +39940,7 @@ async function checkForUpdate() {
39125
39940
  }
39126
39941
  let latestVersion = null;
39127
39942
  try {
39128
- latestVersion = execSync6("npm show adhdev version", {
39943
+ latestVersion = execSync7("npm show adhdev version", {
39129
39944
  encoding: "utf-8",
39130
39945
  timeout: 5e3,
39131
39946
  stdio: ["pipe", "pipe", "pipe"]
@@ -39147,7 +39962,7 @@ async function checkForUpdate() {
39147
39962
  }
39148
39963
  const spinner = (await import("ora")).default("Updating adhdev CLI...").start();
39149
39964
  try {
39150
- execSync6("npm install -g adhdev@latest", {
39965
+ execSync7("npm install -g adhdev@latest", {
39151
39966
  encoding: "utf-8",
39152
39967
  timeout: 6e4,
39153
39968
  stdio: ["pipe", "pipe", "pipe"]
@@ -39203,11 +40018,12 @@ async function quickSetup() {
39203
40018
  console.log(` ${import_chalk3.default.bold("Status:")} ${loginResult ? import_chalk3.default.green("Ready to connect") : import_chalk3.default.yellow("Login required")}`);
39204
40019
  console.log();
39205
40020
  console.log(import_chalk3.default.gray(" Next steps:"));
39206
- console.log(import_chalk3.default.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (required for all features)" : "adhdev setup \u2014 Sign in to finish setup and enable the daemon"}`));
40021
+ console.log(import_chalk3.default.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (IDE / remote features)" : "adhdev setup \u2014 Sign in to finish setup and enable the daemon"}`));
39207
40022
  console.log(import_chalk3.default.gray(" adhdev launch cursor \u2014 Launch Cursor IDE with remote control"));
39208
40023
  console.log(import_chalk3.default.gray(" adhdev launch windsurf \u2014 Launch Windsurf IDE with remote control"));
39209
- console.log(import_chalk3.default.gray(" adhdev launch gemini \u2014 Start Gemini CLI agent via daemon"));
39210
- console.log(import_chalk3.default.gray(" adhdev launch claude \u2014 Start Claude Code agent via daemon"));
40024
+ console.log(import_chalk3.default.gray(" adhdev daemon \u2014 Keep the daemon running for CLI agent launch"));
40025
+ console.log(import_chalk3.default.gray(" adhdev launch gemini \u2014 Start Gemini CLI agent"));
40026
+ console.log(import_chalk3.default.gray(" adhdev launch claude \u2014 Start Claude Code agent"));
39211
40027
  console.log(import_chalk3.default.gray(" adhdev status \u2014 Check setup status"));
39212
40028
  console.log();
39213
40029
  console.log(import_chalk3.default.cyan(" Dashboard: https://adhf.dev/dashboard"));
@@ -39230,16 +40046,16 @@ async function loginFlow() {
39230
40046
  let verificationUrl;
39231
40047
  try {
39232
40048
  const config2 = loadConfig();
39233
- const os21 = await import("os");
40049
+ const os22 = await import("os");
39234
40050
  const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
39235
40051
  method: "POST",
39236
40052
  headers: { "Content-Type": "application/json" },
39237
40053
  body: JSON.stringify({
39238
40054
  clientMachineId: config2.machineId,
39239
40055
  registeredMachineId: config2.registeredMachineId,
39240
- hostname: os21.hostname(),
39241
- platform: os21.platform(),
39242
- arch: os21.arch()
40056
+ hostname: os22.hostname(),
40057
+ platform: os22.platform(),
40058
+ arch: os22.arch()
39243
40059
  })
39244
40060
  });
39245
40061
  if (!res.ok) {
@@ -39337,20 +40153,20 @@ async function startDaemonFlow() {
39337
40153
  try {
39338
40154
  const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
39339
40155
  const daemon = new AdhdevDaemon2();
39340
- const { execSync: execSync6 } = await import("child_process");
39341
- const os21 = await import("os");
39342
- const path21 = await import("path");
39343
- const logPath = path21.join(os21.homedir(), ".adhdev", "daemon.log");
39344
- const platform11 = os21.platform();
40156
+ const { execSync: execSync7 } = await import("child_process");
40157
+ const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
40158
+ const logPath = getCurrentDaemonLogPath2();
40159
+ const os22 = await import("os");
40160
+ const platform11 = os22.platform();
39345
40161
  try {
39346
40162
  if (platform11 === "win32") {
39347
- execSync6(`start /B adhdev daemon > "${logPath}" 2>&1`, {
40163
+ execSync7("start /B adhdev daemon >NUL 2>&1", {
39348
40164
  timeout: 3e3,
39349
40165
  stdio: "ignore",
39350
40166
  shell: "cmd.exe"
39351
40167
  });
39352
40168
  } else {
39353
- execSync6(`nohup adhdev daemon > "${logPath}" 2>&1 &`, {
40169
+ execSync7("nohup adhdev daemon >/dev/null 2>&1 &", {
39354
40170
  timeout: 3e3,
39355
40171
  stdio: "ignore"
39356
40172
  });
@@ -39398,7 +40214,7 @@ async function installCliOnly() {
39398
40214
  console.log(import_chalk3.default.gray(" The `adhdev` command lets you:"));
39399
40215
  console.log(import_chalk3.default.gray(" \u2022 Start the main daemon (adhdev daemon)"));
39400
40216
  console.log(import_chalk3.default.gray(" \u2022 Launch IDE with CDP (adhdev launch <ide>)"));
39401
- console.log(import_chalk3.default.gray(" \u2022 Start CLI agents (adhdev launch <agent>)"));
40217
+ console.log(import_chalk3.default.gray(" \u2022 Start CLI agents (adhdev daemon && adhdev launch <agent>)"));
39402
40218
  console.log(import_chalk3.default.gray(" \u2022 Check setup status (adhdev status)"));
39403
40219
  console.log();
39404
40220
  if (currentVersion) {