adhdev 0.8.13 → 0.8.15

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
@@ -5459,8 +5459,24 @@ var init_stream_commands = __esm({
5459
5459
  });
5460
5460
 
5461
5461
  // ../../oss/packages/daemon-core/src/commands/workspace-commands.ts
5462
+ function loadWorkspaceConfig() {
5463
+ try {
5464
+ return loadConfig();
5465
+ } catch (e) {
5466
+ return { error: `Could not load config: ${e?.message || "unknown error"}` };
5467
+ }
5468
+ }
5469
+ function persistWorkspaceConfig(config2) {
5470
+ try {
5471
+ saveConfig(config2);
5472
+ return { ok: true };
5473
+ } catch (e) {
5474
+ return { error: `Could not save config: ${e?.message || "unknown error"}` };
5475
+ }
5476
+ }
5462
5477
  function handleWorkspaceList() {
5463
- const config2 = loadConfig();
5478
+ const config2 = loadWorkspaceConfig();
5479
+ if ("error" in config2) return { success: false, error: config2.error };
5464
5480
  const state = getWorkspaceState(config2);
5465
5481
  return {
5466
5482
  success: true,
@@ -5474,31 +5490,37 @@ function handleWorkspaceAdd(args) {
5474
5490
  const label = (args?.label || "").trim() || void 0;
5475
5491
  const createIfMissing = args?.createIfMissing === true;
5476
5492
  if (!rawPath) return { success: false, error: "path required" };
5477
- const config2 = loadConfig();
5493
+ const config2 = loadWorkspaceConfig();
5494
+ if ("error" in config2) return { success: false, error: config2.error };
5478
5495
  const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
5479
5496
  if ("error" in result) return { success: false, error: result.error };
5480
- saveConfig(result.config);
5497
+ const saveResult = persistWorkspaceConfig(result.config);
5498
+ if ("error" in saveResult) return { success: false, error: saveResult.error };
5481
5499
  const state = getWorkspaceState(result.config);
5482
5500
  return { success: true, entry: result.entry, ...state };
5483
5501
  }
5484
5502
  function handleWorkspaceRemove(args) {
5485
5503
  const id = (args?.id || "").trim();
5486
5504
  if (!id) return { success: false, error: "id required" };
5487
- const config2 = loadConfig();
5505
+ const config2 = loadWorkspaceConfig();
5506
+ if ("error" in config2) return { success: false, error: config2.error };
5488
5507
  const removed = (config2.workspaces || []).find((w) => w.id === id);
5489
5508
  const result = removeWorkspaceEntry(config2, id);
5490
5509
  if ("error" in result) return { success: false, error: result.error };
5491
- saveConfig(result.config);
5510
+ const saveResult = persistWorkspaceConfig(result.config);
5511
+ if ("error" in saveResult) return { success: false, error: saveResult.error };
5492
5512
  const state = getWorkspaceState(result.config);
5493
5513
  return { success: true, removedId: id, ...state };
5494
5514
  }
5495
5515
  function handleWorkspaceSetDefault(args) {
5496
5516
  const clear = args?.clear === true || args?.id === null || args?.id === "";
5497
5517
  if (clear) {
5498
- const config3 = loadConfig();
5518
+ const config3 = loadWorkspaceConfig();
5519
+ if ("error" in config3) return { success: false, error: config3.error };
5499
5520
  const result2 = setDefaultWorkspaceId(config3, null);
5500
5521
  if ("error" in result2) return { success: false, error: result2.error };
5501
- saveConfig(result2.config);
5522
+ const saveResult2 = persistWorkspaceConfig(result2.config);
5523
+ if ("error" in saveResult2) return { success: false, error: saveResult2.error };
5502
5524
  const state2 = getWorkspaceState(result2.config);
5503
5525
  return {
5504
5526
  success: true,
@@ -5510,7 +5532,9 @@ function handleWorkspaceSetDefault(args) {
5510
5532
  if (!pathArg && !idArg) {
5511
5533
  return { success: false, error: "id or path required (or clear: true)" };
5512
5534
  }
5513
- let config2 = loadConfig();
5535
+ const configResult = loadWorkspaceConfig();
5536
+ if ("error" in configResult) return { success: false, error: configResult.error };
5537
+ let config2 = configResult;
5514
5538
  let nextId;
5515
5539
  if (pathArg) {
5516
5540
  let w = findWorkspaceByPath(config2, pathArg);
@@ -5526,7 +5550,8 @@ function handleWorkspaceSetDefault(args) {
5526
5550
  }
5527
5551
  const result = setDefaultWorkspaceId(config2, nextId);
5528
5552
  if ("error" in result) return { success: false, error: result.error };
5529
- saveConfig(result.config);
5553
+ const saveResult = persistWorkspaceConfig(result.config);
5554
+ if ("error" in saveResult) return { success: false, error: saveResult.error };
5530
5555
  const state = getWorkspaceState(result.config);
5531
5556
  return { success: true, ...state };
5532
5557
  }
@@ -6297,71 +6322,6 @@ var init_terminal_screen = __esm({
6297
6322
  }
6298
6323
  });
6299
6324
 
6300
- // ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
6301
- var os7, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
6302
- var init_pty_transport = __esm({
6303
- "../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
6304
- "use strict";
6305
- os7 = __toESM(require("os"));
6306
- try {
6307
- pty = require("node-pty");
6308
- } catch {
6309
- pty = null;
6310
- }
6311
- NodePtyRuntimeTransport = class {
6312
- constructor(handle) {
6313
- this.handle = handle;
6314
- }
6315
- ready = Promise.resolve();
6316
- terminalQueriesHandled = false;
6317
- get pid() {
6318
- return this.handle.pid;
6319
- }
6320
- write(data) {
6321
- this.handle.write(data);
6322
- }
6323
- resize(cols, rows) {
6324
- this.handle.resize(cols, rows);
6325
- }
6326
- kill() {
6327
- this.handle.kill();
6328
- }
6329
- getMetadata() {
6330
- return null;
6331
- }
6332
- onData(callback) {
6333
- this.handle.onData(callback);
6334
- }
6335
- onExit(callback) {
6336
- this.handle.onExit(callback);
6337
- }
6338
- };
6339
- NodePtyTransportFactory = class {
6340
- spawn(command, args, options) {
6341
- if (!pty) throw new Error("node-pty is not installed");
6342
- let cwd = options.cwd;
6343
- if (cwd) {
6344
- try {
6345
- const fs18 = require("fs");
6346
- const stat4 = fs18.statSync(cwd);
6347
- if (!stat4.isDirectory()) cwd = os7.homedir();
6348
- } catch {
6349
- cwd = os7.homedir();
6350
- }
6351
- }
6352
- const handle = pty.spawn(command, args, {
6353
- name: "xterm-256color",
6354
- cols: options.cols,
6355
- rows: options.rows,
6356
- cwd,
6357
- env: options.env
6358
- });
6359
- return new NodePtyRuntimeTransport(handle);
6360
- }
6361
- };
6362
- }
6363
- });
6364
-
6365
6325
  // ../../oss/packages/session-host-core/dist/index.mjs
6366
6326
  function getDefaultSessionHostEndpoint(appName = "adhdev") {
6367
6327
  if (process.platform === "win32") {
@@ -6372,7 +6332,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
6372
6332
  }
6373
6333
  return {
6374
6334
  kind: "unix",
6375
- path: path22.join(os8.tmpdir(), `${appName}-session-host.sock`)
6335
+ path: path22.join(os7.tmpdir(), `${appName}-session-host.sock`)
6376
6336
  };
6377
6337
  }
6378
6338
  function serializeEnvelope(envelope) {
@@ -6437,11 +6397,11 @@ function ensureNodePtySpawnHelperPermissions(logFn) {
6437
6397
  } catch {
6438
6398
  }
6439
6399
  }
6440
- var os8, path22, net, import_crypto3, os22, path32, __require, SessionHostClient;
6400
+ var os7, path22, net, import_crypto3, os22, path32, __require, SessionHostClient;
6441
6401
  var init_dist = __esm({
6442
6402
  "../../oss/packages/session-host-core/dist/index.mjs"() {
6443
6403
  "use strict";
6444
- os8 = __toESM(require("os"), 1);
6404
+ os7 = __toESM(require("os"), 1);
6445
6405
  path22 = __toESM(require("path"), 1);
6446
6406
  net = __toESM(require("net"), 1);
6447
6407
  import_crypto3 = require("crypto");
@@ -6570,6 +6530,78 @@ var init_spawn_env = __esm({
6570
6530
  }
6571
6531
  });
6572
6532
 
6533
+ // ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
6534
+ function loadNodePty() {
6535
+ if (cachedPty !== void 0) return cachedPty;
6536
+ try {
6537
+ cachedPty = require("node-pty");
6538
+ ensureNodePtySpawnHelperPermissions();
6539
+ } catch {
6540
+ cachedPty = null;
6541
+ }
6542
+ return cachedPty;
6543
+ }
6544
+ var os8, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
6545
+ var init_pty_transport = __esm({
6546
+ "../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
6547
+ "use strict";
6548
+ os8 = __toESM(require("os"));
6549
+ init_spawn_env();
6550
+ NodePtyRuntimeTransport = class {
6551
+ constructor(handle) {
6552
+ this.handle = handle;
6553
+ }
6554
+ ready = Promise.resolve();
6555
+ terminalQueriesHandled = false;
6556
+ get pid() {
6557
+ return this.handle.pid;
6558
+ }
6559
+ write(data) {
6560
+ this.handle.write(data);
6561
+ }
6562
+ resize(cols, rows) {
6563
+ this.handle.resize(cols, rows);
6564
+ }
6565
+ kill() {
6566
+ this.handle.kill();
6567
+ }
6568
+ getMetadata() {
6569
+ return null;
6570
+ }
6571
+ onData(callback) {
6572
+ this.handle.onData(callback);
6573
+ }
6574
+ onExit(callback) {
6575
+ this.handle.onExit(callback);
6576
+ }
6577
+ };
6578
+ NodePtyTransportFactory = class {
6579
+ spawn(command, args, options) {
6580
+ const pty = loadNodePty();
6581
+ if (!pty) throw new Error("node-pty is not installed");
6582
+ let cwd = options.cwd;
6583
+ if (cwd) {
6584
+ try {
6585
+ const fs18 = require("fs");
6586
+ const stat4 = fs18.statSync(cwd);
6587
+ if (!stat4.isDirectory()) cwd = os8.homedir();
6588
+ } catch {
6589
+ cwd = os8.homedir();
6590
+ }
6591
+ }
6592
+ const handle = pty.spawn(command, args, {
6593
+ name: "xterm-256color",
6594
+ cols: options.cols,
6595
+ rows: options.rows,
6596
+ cwd,
6597
+ env: options.env
6598
+ });
6599
+ return new NodePtyRuntimeTransport(handle);
6600
+ }
6601
+ };
6602
+ }
6603
+ });
6604
+
6573
6605
  // ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts
6574
6606
  var provider_cli_adapter_exports = {};
6575
6607
  __export(provider_cli_adapter_exports, {
@@ -6713,7 +6745,7 @@ function normalizeCliProviderForRuntime(raw) {
6713
6745
  }
6714
6746
  };
6715
6747
  }
6716
- var os9, path7, import_child_process4, pty2, buildCliSpawnEnv, ProviderCliAdapter;
6748
+ var os9, path7, import_child_process4, buildCliSpawnEnv, ProviderCliAdapter;
6717
6749
  var init_provider_cli_adapter = __esm({
6718
6750
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
6719
6751
  "use strict";
@@ -6724,12 +6756,6 @@ var init_provider_cli_adapter = __esm({
6724
6756
  init_terminal_screen();
6725
6757
  init_pty_transport();
6726
6758
  init_spawn_env();
6727
- try {
6728
- pty2 = require("node-pty");
6729
- ensureNodePtySpawnHelperPermissions((msg) => LOG.info("CLI", msg));
6730
- } catch {
6731
- LOG.error("CLI", "[ProviderCliAdapter] node-pty not found. Terminal features disabled.");
6732
- }
6733
6759
  buildCliSpawnEnv = sanitizeSpawnEnv;
6734
6760
  ProviderCliAdapter = class _ProviderCliAdapter {
6735
6761
  constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
@@ -7053,13 +7079,16 @@ var init_provider_cli_adapter = __esm({
7053
7079
  let shellArgs;
7054
7080
  const useShellUnix = !isWin && (!!spawnConfig.shell || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
7055
7081
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
7056
- const useShell = isWin ? !!spawnConfig.shell || isCmdShim : useShellUnix;
7082
+ const useShellWin = isCmdShim || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
7083
+ const useShell = isWin ? useShellWin : useShellUnix;
7057
7084
  if (useShell) {
7058
7085
  if (!spawnConfig.shell && !isWin) {
7059
7086
  LOG.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
7060
7087
  }
7061
7088
  if (isCmdShim) {
7062
7089
  LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
7090
+ } else if (isWin) {
7091
+ LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell on Windows: ${binaryPath}`);
7063
7092
  }
7064
7093
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
7065
7094
  if (isWin) {
@@ -7069,6 +7098,9 @@ var init_provider_cli_adapter = __esm({
7069
7098
  shellArgs = ["-l", "-c", fullCmd];
7070
7099
  }
7071
7100
  } else {
7101
+ if (isWin && spawnConfig.shell) {
7102
+ LOG.info("CLI", `[${this.cliType}] Spawning Windows binary directly without cmd.exe: ${binaryPath}`);
7103
+ }
7072
7104
  shellCmd = binaryPath;
7073
7105
  shellArgs = allArgs;
7074
7106
  }
@@ -34494,10 +34526,10 @@ async function handleAutoImplement(ctx, type, req, res) {
34494
34526
  let isPty = false;
34495
34527
  const { spawn: spawnFn } = await import("child_process");
34496
34528
  try {
34497
- const pty3 = require("node-pty");
34529
+ const pty = require("node-pty");
34498
34530
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
34499
34531
  const isWin2 = os18.platform() === "win32";
34500
- child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
34532
+ child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
34501
34533
  name: "xterm-256color",
34502
34534
  cols: 120,
34503
34535
  rows: 40,
@@ -45833,7 +45865,7 @@ function getSessionHostPidFile() {
45833
45865
  function killPid2(pid) {
45834
45866
  try {
45835
45867
  if (process.platform === "win32") {
45836
- (0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
45868
+ (0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
45837
45869
  } else {
45838
45870
  process.kill(pid, "SIGTERM");
45839
45871
  }
@@ -45851,7 +45883,7 @@ function getWindowsProcessCommandLine(pid) {
45851
45883
  pidFilter,
45852
45884
  "get",
45853
45885
  "CommandLine"
45854
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] });
45886
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
45855
45887
  const text = wmicOut.trim();
45856
45888
  if (text) return text;
45857
45889
  } catch {
@@ -45864,7 +45896,7 @@ function getWindowsProcessCommandLine(pid) {
45864
45896
  "Bypass",
45865
45897
  "-Command",
45866
45898
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
45867
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
45899
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
45868
45900
  const text = psOut.trim();
45869
45901
  if (text) return text;
45870
45902
  } catch {
@@ -45893,7 +45925,8 @@ function stopSessionHost() {
45893
45925
  const raw = (0, import_child_process11.execFileSync)("tasklist", ["/FO", "CSV", "/NH", "/FI", "IMAGENAME eq node.exe"], {
45894
45926
  encoding: "utf8",
45895
45927
  timeout: 5e3,
45896
- stdio: ["ignore", "pipe", "ignore"]
45928
+ stdio: ["ignore", "pipe", "ignore"],
45929
+ windowsHide: true
45897
45930
  }).trim();
45898
45931
  for (const line of raw.split(/\r?\n/)) {
45899
45932
  const match = line.match(/^"node\.exe","(\d+)"/i);
@@ -46077,7 +46110,7 @@ var init_adhdev_daemon = __esm({
46077
46110
  import_ws3 = require("ws");
46078
46111
  import_chalk2 = __toESM(require("chalk"));
46079
46112
  init_version();
46080
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.13" });
46113
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.15" });
46081
46114
  DANGEROUS_PATTERNS = [
46082
46115
  /\brm\s+(-[a-z]*f|-[a-z]*r|--force|--recursive)/i,
46083
46116
  /\bsudo\b/i,