adhdev 0.7.43 → 0.7.44

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
@@ -18257,6 +18257,27 @@ var init_snapshot = __esm({
18257
18257
  }
18258
18258
  });
18259
18259
 
18260
+ // ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
18261
+ function spawnDetachedDaemonUpgradeHelper(payload) {
18262
+ const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
18263
+ const child = (0, import_child_process5.spawn)(process.execPath, process.argv.slice(1), {
18264
+ detached: true,
18265
+ stdio: "ignore",
18266
+ windowsHide: true,
18267
+ cwd: payload.cwd || process.cwd(),
18268
+ env
18269
+ });
18270
+ child.unref();
18271
+ }
18272
+ var import_child_process5, UPGRADE_HELPER_ENV;
18273
+ var init_upgrade_helper = __esm({
18274
+ "../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
18275
+ "use strict";
18276
+ import_child_process5 = require("child_process");
18277
+ UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
18278
+ }
18279
+ });
18280
+
18260
18281
  // ../../oss/packages/daemon-core/src/commands/router.ts
18261
18282
  var fs8, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
18262
18283
  var init_router = __esm({
@@ -18274,6 +18295,7 @@ var init_router = __esm({
18274
18295
  init_logger();
18275
18296
  init_builders();
18276
18297
  init_snapshot();
18298
+ init_upgrade_helper();
18277
18299
  fs8 = __toESM(require("fs"));
18278
18300
  CHAT_COMMANDS = [
18279
18301
  "send_chat",
@@ -18494,31 +18516,35 @@ var init_router = __esm({
18494
18516
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
18495
18517
  const latest = execSync6(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
18496
18518
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
18497
- execSync6(`npm install -g ${pkgName}@latest --force`, {
18498
- encoding: "utf-8",
18499
- timeout: 12e4,
18500
- stdio: ["pipe", "pipe", "pipe"]
18519
+ let currentInstalled = null;
18520
+ try {
18521
+ const currentJson = execSync6(`npm ls -g ${pkgName} --depth=0 --json`, {
18522
+ encoding: "utf-8",
18523
+ timeout: 1e4,
18524
+ stdio: ["pipe", "pipe", "pipe"]
18525
+ }).trim();
18526
+ const parsed = JSON.parse(currentJson);
18527
+ currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
18528
+ } catch {
18529
+ }
18530
+ if (currentInstalled === latest) {
18531
+ LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
18532
+ return { success: true, upgraded: false, alreadyLatest: true, version: latest };
18533
+ }
18534
+ spawnDetachedDaemonUpgradeHelper({
18535
+ packageName: pkgName,
18536
+ targetVersion: latest,
18537
+ parentPid: process.pid,
18538
+ restartArgv: process.argv.slice(1),
18539
+ cwd: process.cwd(),
18540
+ sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
18501
18541
  });
18502
- LOG.info("Upgrade", `\u2705 Upgraded to v${latest}`);
18542
+ LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
18503
18543
  setTimeout(() => {
18504
- LOG.info("Upgrade", "Restarting daemon with new version...");
18505
- try {
18506
- const path18 = require("path");
18507
- const fs16 = require("fs");
18508
- const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
18509
- if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
18510
- } catch {
18511
- }
18512
- const { spawn: spawn4 } = require("child_process");
18513
- const child = spawn4(process.execPath, process.argv.slice(1), {
18514
- detached: true,
18515
- stdio: "ignore",
18516
- env: { ...process.env }
18517
- });
18518
- child.unref();
18544
+ LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
18519
18545
  process.exit(0);
18520
18546
  }, 3e3);
18521
- return { success: true, upgraded: true, version: latest };
18547
+ return { success: true, upgraded: true, version: latest, restarting: true };
18522
18548
  } catch (e) {
18523
18549
  LOG.error("Upgrade", `Failed: ${e.message}`);
18524
18550
  return { success: false, error: e.message };
@@ -18920,7 +18946,7 @@ function findBinary(name) {
18920
18946
  const isWin = os13.platform() === "win32";
18921
18947
  try {
18922
18948
  const cmd = isWin ? `where ${name}` : `which ${name}`;
18923
- return (0, import_child_process5.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
18949
+ return (0, import_child_process6.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
18924
18950
  } catch {
18925
18951
  return isWin ? `${name}.cmd` : name;
18926
18952
  }
@@ -19026,13 +19052,13 @@ function normalizeCliProviderForRuntime(raw) {
19026
19052
  }
19027
19053
  };
19028
19054
  }
19029
- var os13, path9, import_child_process5, pty2, ProviderCliAdapter;
19055
+ var os13, path9, import_child_process6, pty2, ProviderCliAdapter;
19030
19056
  var init_provider_cli_adapter = __esm({
19031
19057
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
19032
19058
  "use strict";
19033
19059
  os13 = __toESM(require("os"));
19034
19060
  path9 = __toESM(require("path"));
19035
- import_child_process5 = require("child_process");
19061
+ import_child_process6 = require("child_process");
19036
19062
  init_logger();
19037
19063
  init_terminal_screen();
19038
19064
  init_pty_transport();
@@ -36620,12 +36646,12 @@ var init_contracts = __esm({
36620
36646
  });
36621
36647
 
36622
36648
  // ../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts
36623
- var import_stream, import_child_process6, AcpProviderInstance;
36649
+ var import_stream, import_child_process7, AcpProviderInstance;
36624
36650
  var init_acp_provider_instance = __esm({
36625
36651
  "../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
36626
36652
  "use strict";
36627
36653
  import_stream = require("stream");
36628
- import_child_process6 = require("child_process");
36654
+ import_child_process7 = require("child_process");
36629
36655
  init_acp();
36630
36656
  init_contracts();
36631
36657
  init_status_monitor();
@@ -36949,7 +36975,7 @@ var init_acp_provider_instance = __esm({
36949
36975
  this.errorMessage = null;
36950
36976
  this.errorReason = null;
36951
36977
  this.stderrBuffer = [];
36952
- this.process = (0, import_child_process6.spawn)(command, args, {
36978
+ this.process = (0, import_child_process7.spawn)(command, args, {
36953
36979
  cwd: this.workingDir,
36954
36980
  env,
36955
36981
  stdio: ["pipe", "pipe", "pipe"],
@@ -38904,7 +38930,7 @@ var init_provider_instance_manager = __esm({
38904
38930
  // ../../oss/packages/daemon-core/src/providers/version-archive.ts
38905
38931
  function runCommand(cmd, timeout = 1e4) {
38906
38932
  try {
38907
- return (0, import_child_process7.execSync)(cmd, {
38933
+ return (0, import_child_process8.execSync)(cmd, {
38908
38934
  encoding: "utf-8",
38909
38935
  timeout,
38910
38936
  stdio: ["pipe", "pipe", "pipe"]
@@ -39011,14 +39037,14 @@ async function detectAllVersions(loader, archive) {
39011
39037
  }
39012
39038
  return results;
39013
39039
  }
39014
- var fs9, path11, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
39040
+ var fs9, path11, os15, import_child_process8, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
39015
39041
  var init_version_archive = __esm({
39016
39042
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
39017
39043
  "use strict";
39018
39044
  fs9 = __toESM(require("fs"));
39019
39045
  path11 = __toESM(require("path"));
39020
39046
  os15 = __toESM(require("os"));
39021
- import_child_process7 = require("child_process");
39047
+ import_child_process8 = require("child_process");
39022
39048
  import_os3 = require("os");
39023
39049
  ARCHIVE_PATH = path11.join(os15.homedir(), ".adhdev", "version-history.json");
39024
39050
  MAX_ENTRIES_PER_PROVIDER = 20;
@@ -40797,8 +40823,8 @@ async function handleAutoImplement(ctx, type, req, res) {
40797
40823
  fs11.writeFileSync(promptFile, prompt, "utf-8");
40798
40824
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
40799
40825
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
40800
- const spawn4 = agentProvider?.spawn;
40801
- if (!spawn4?.command) {
40826
+ const spawn5 = agentProvider?.spawn;
40827
+ if (!spawn5?.command) {
40802
40828
  try {
40803
40829
  fs11.unlinkSync(promptFile);
40804
40830
  } catch {
@@ -40808,21 +40834,21 @@ async function handleAutoImplement(ctx, type, req, res) {
40808
40834
  }
40809
40835
  const agentCategory = agentProvider?.category;
40810
40836
  if (agentCategory === "acp") {
40811
- sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn4.command} ${(spawn4.args || []).join(" ")}` } });
40837
+ sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn5.command} ${(spawn5.args || []).join(" ")}` } });
40812
40838
  ctx.autoImplStatus = { running: true, type, progress: [] };
40813
40839
  const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
40814
40840
  const { Readable: Readable3, Writable: Writable2 } = await import("stream");
40815
40841
  const { spawn: spawnFn2 } = await import("child_process");
40816
- const acpArgs = [...spawn4.args || []];
40842
+ const acpArgs = [...spawn5.args || []];
40817
40843
  if (model) {
40818
40844
  acpArgs.push("--model", model);
40819
40845
  ctx.log(`Auto-implement ACP using model: ${model}`);
40820
40846
  }
40821
- const child2 = spawnFn2(spawn4.command, acpArgs, {
40847
+ const child2 = spawnFn2(spawn5.command, acpArgs, {
40822
40848
  cwd: providerDir,
40823
40849
  stdio: ["pipe", "pipe", "pipe"],
40824
- shell: spawn4.shell ?? false,
40825
- env: { ...process.env, ...spawn4.env || {} }
40850
+ shell: spawn5.shell ?? false,
40851
+ env: { ...process.env, ...spawn5.env || {} }
40826
40852
  });
40827
40853
  ctx.autoImplProcess = child2;
40828
40854
  child2.stderr?.on("data", (d) => {
@@ -40932,7 +40958,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40932
40958
  ctx.json(res, 202, {
40933
40959
  started: true,
40934
40960
  type,
40935
- agent: spawn4.command,
40961
+ agent: spawn5.command,
40936
40962
  functions,
40937
40963
  providerDir,
40938
40964
  message: "ACP Auto-implement started. Connect to SSE for progress.",
@@ -40940,9 +40966,9 @@ async function handleAutoImplement(ctx, type, req, res) {
40940
40966
  });
40941
40967
  return;
40942
40968
  }
40943
- const command = spawn4.command;
40969
+ const command = spawn5.command;
40944
40970
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
40945
- const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
40971
+ const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
40946
40972
  let shellCmd;
40947
40973
  const isWin = os16.platform() === "win32";
40948
40974
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
@@ -40993,7 +41019,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40993
41019
  cols: 120,
40994
41020
  rows: 40,
40995
41021
  cwd: providerDir,
40996
- env: { ...process.env, ...spawn4.env || {} }
41022
+ env: { ...process.env, ...spawn5.env || {} }
40997
41023
  });
40998
41024
  isPty = true;
40999
41025
  } catch (err) {
@@ -41005,7 +41031,7 @@ async function handleAutoImplement(ctx, type, req, res) {
41005
41031
  stdio: ["pipe", "pipe", "pipe"],
41006
41032
  env: {
41007
41033
  ...process.env,
41008
- ...spawn4.env || {},
41034
+ ...spawn5.env || {},
41009
41035
  ...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
41010
41036
  }
41011
41037
  });
@@ -41857,16 +41883,16 @@ var init_dev_server = __esm({
41857
41883
  this.json(res, 404, { error: `Provider not found: ${type}` });
41858
41884
  return;
41859
41885
  }
41860
- const spawn4 = provider.spawn;
41861
- if (!spawn4) {
41886
+ const spawn5 = provider.spawn;
41887
+ if (!spawn5) {
41862
41888
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
41863
41889
  return;
41864
41890
  }
41865
41891
  const { spawn: spawnFn } = await import("child_process");
41866
41892
  const start = Date.now();
41867
41893
  try {
41868
- const child = spawnFn(spawn4.command, [...spawn4.args || []], {
41869
- shell: spawn4.shell ?? false,
41894
+ const child = spawnFn(spawn5.command, [...spawn5.args || []], {
41895
+ shell: spawn5.shell ?? false,
41870
41896
  timeout: 5e3,
41871
41897
  stdio: ["pipe", "pipe", "pipe"]
41872
41898
  });
@@ -41898,7 +41924,7 @@ var init_dev_server = __esm({
41898
41924
  const elapsed = Date.now() - start;
41899
41925
  this.json(res, 200, {
41900
41926
  success: true,
41901
- command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41927
+ command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
41902
41928
  elapsed,
41903
41929
  stdout: stdout.trim(),
41904
41930
  stderr: stderr.trim(),
@@ -41908,7 +41934,7 @@ var init_dev_server = __esm({
41908
41934
  const elapsed = Date.now() - start;
41909
41935
  this.json(res, 200, {
41910
41936
  success: false,
41911
- command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41937
+ command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
41912
41938
  elapsed,
41913
41939
  error: e.message
41914
41940
  });
@@ -42377,20 +42403,20 @@ var init_dev_server = __esm({
42377
42403
  this.json(res, 404, { error: `Provider not found: ${type}` });
42378
42404
  return;
42379
42405
  }
42380
- const spawn4 = provider.spawn;
42381
- if (!spawn4) {
42406
+ const spawn5 = provider.spawn;
42407
+ if (!spawn5) {
42382
42408
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
42383
42409
  return;
42384
42410
  }
42385
42411
  const { spawn: spawnFn } = await import("child_process");
42386
42412
  const start = Date.now();
42387
42413
  try {
42388
- const args = [...spawn4.args || [], message];
42389
- const child = spawnFn(spawn4.command, args, {
42390
- shell: spawn4.shell ?? false,
42414
+ const args = [...spawn5.args || [], message];
42415
+ const child = spawnFn(spawn5.command, args, {
42416
+ shell: spawn5.shell ?? false,
42391
42417
  timeout,
42392
42418
  stdio: ["pipe", "pipe", "pipe"],
42393
- env: { ...process.env, ...spawn4.env || {} }
42419
+ env: { ...process.env, ...spawn5.env || {} }
42394
42420
  });
42395
42421
  let stdout = "";
42396
42422
  let stderr = "";
@@ -43953,6 +43979,7 @@ var init_src = __esm({
43953
43979
  init_initializer();
43954
43980
  init_handler();
43955
43981
  init_router();
43982
+ init_upgrade_helper();
43956
43983
  init_reporter();
43957
43984
  init_builders();
43958
43985
  init_snapshot();
@@ -45281,7 +45308,7 @@ async function ensureSessionHostReady2() {
45281
45308
  appName: SESSION_HOST_APP_NAME,
45282
45309
  spawnHost: () => {
45283
45310
  const entry = resolveSessionHostEntry();
45284
- const child = (0, import_child_process8.spawn)(process.execPath, [entry], {
45311
+ const child = (0, import_child_process9.spawn)(process.execPath, [entry], {
45285
45312
  detached: true,
45286
45313
  stdio: "ignore",
45287
45314
  windowsHide: true,
@@ -45297,11 +45324,11 @@ async function ensureSessionHostReady2() {
45297
45324
  async function listHostedCliRuntimes2(endpoint) {
45298
45325
  return listHostedCliRuntimes(endpoint);
45299
45326
  }
45300
- var import_child_process8, fs14, path16, SESSION_HOST_APP_NAME;
45327
+ var import_child_process9, fs14, path16, SESSION_HOST_APP_NAME;
45301
45328
  var init_session_host = __esm({
45302
45329
  "src/session-host.ts"() {
45303
45330
  "use strict";
45304
- import_child_process8 = require("child_process");
45331
+ import_child_process9 = require("child_process");
45305
45332
  fs14 = __toESM(require("fs"));
45306
45333
  path16 = __toESM(require("path"));
45307
45334
  init_src();
@@ -45369,7 +45396,7 @@ var init_adhdev_daemon = __esm({
45369
45396
  fs15 = __toESM(require("fs"));
45370
45397
  path17 = __toESM(require("path"));
45371
45398
  import_chalk2 = __toESM(require("chalk"));
45372
- pkgVersion = "0.7.43";
45399
+ pkgVersion = "0.7.44";
45373
45400
  if (pkgVersion === "unknown") {
45374
45401
  try {
45375
45402
  const possiblePaths = [