adhdev 0.9.47 → 0.9.48

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/cli/index.js CHANGED
@@ -9522,7 +9522,8 @@ function getCliScriptCommand(payload) {
9522
9522
  if (command.type !== "send_message" && command.type !== "pty_write") return null;
9523
9523
  const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
9524
9524
  if (!text) return null;
9525
- return { type: command.type, text };
9525
+ const enterCount = Number.isInteger(command.enterCount) && command.enterCount > 0 && command.enterCount <= 5 ? command.enterCount : void 0;
9526
+ return { type: command.type, text, ...enterCount ? { enterCount } : {} };
9526
9527
  }
9527
9528
  var init_cli_script_results = __esm({
9528
9529
  "../../oss/packages/daemon-core/src/providers/cli-script-results.ts"() {
@@ -9784,7 +9785,12 @@ async function executeProviderScript(h, args, scriptName) {
9784
9785
  if (cliCommand?.type === "send_message" && cliCommand.text) {
9785
9786
  await adapter.sendMessage(cliCommand.text);
9786
9787
  } else if (cliCommand?.type === "pty_write" && cliCommand.text && adapter.writeRaw) {
9788
+ const enterCount = cliCommand.enterCount || 1;
9787
9789
  await adapter.writeRaw(cliCommand.text + "\r");
9790
+ for (let i = 1; i < enterCount; i += 1) {
9791
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
9792
+ await adapter.writeRaw("\r");
9793
+ }
9788
9794
  }
9789
9795
  applyProviderPatch(h, args, parsed.payload);
9790
9796
  return {
@@ -15581,7 +15587,12 @@ var init_cli_provider_instance = __esm({
15581
15587
  if (cliCommand?.type === "send_message" && cliCommand.text) {
15582
15588
  await this.adapter.sendMessage(cliCommand.text);
15583
15589
  } else if (cliCommand?.type === "pty_write" && cliCommand.text) {
15590
+ const enterCount = cliCommand.enterCount || 1;
15584
15591
  await this.adapter.writeRaw(cliCommand.text + "\r");
15592
+ for (let i = 1; i < enterCount; i += 1) {
15593
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
15594
+ await this.adapter.writeRaw("\r");
15595
+ }
15585
15596
  }
15586
15597
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
15587
15598
  }
@@ -38851,16 +38862,28 @@ function appendUpgradeLog(message) {
38851
38862
  } catch {
38852
38863
  }
38853
38864
  }
38854
- function resolveSiblingNpmExecutable(nodeExecutable) {
38865
+ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
38855
38866
  const binDir = path17.dirname(nodeExecutable);
38856
- const candidates = process.platform === "win32" ? ["npm.cmd", "npm.exe", "npm"] : ["npm"];
38857
- for (const candidate of candidates) {
38867
+ if (platform12 === "win32") {
38868
+ const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
38869
+ if (fs8.existsSync(npmCliPath)) {
38870
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38871
+ }
38872
+ for (const candidate of ["npm.exe", "npm"]) {
38873
+ const candidatePath = path17.join(binDir, candidate);
38874
+ if (fs8.existsSync(candidatePath)) {
38875
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38876
+ }
38877
+ }
38878
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38879
+ }
38880
+ for (const candidate of ["npm"]) {
38858
38881
  const candidatePath = path17.join(binDir, candidate);
38859
38882
  if (fs8.existsSync(candidatePath)) {
38860
- return candidatePath;
38883
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38861
38884
  }
38862
38885
  }
38863
- return "npm";
38886
+ return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
38864
38887
  }
38865
38888
  function findCurrentPackageRoot(currentCliPath, packageName) {
38866
38889
  if (!currentCliPath) return null;
@@ -38909,26 +38932,30 @@ function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
38909
38932
  }
38910
38933
  function resolveCurrentGlobalInstallSurface(options) {
38911
38934
  const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
38935
+ const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
38912
38936
  return {
38913
- npmExecutable: resolveSiblingNpmExecutable(options.nodeExecutable || process.execPath),
38937
+ npmExecutable: npmInvocation.executable,
38938
+ npmArgsPrefix: npmInvocation.argsPrefix,
38914
38939
  packageRoot,
38915
- installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null
38940
+ installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null,
38941
+ execOptions: npmInvocation.execOptions
38916
38942
  };
38917
38943
  }
38918
38944
  function buildPinnedGlobalInstallCommand(options) {
38919
38945
  const surface = resolveCurrentGlobalInstallSurface(options);
38920
- const args = ["install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
38946
+ const args = [...surface.npmArgsPrefix || [], "install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
38921
38947
  if (surface.installPrefix) {
38922
38948
  args.push("--prefix", surface.installPrefix);
38923
38949
  }
38924
38950
  return {
38925
38951
  command: surface.npmExecutable,
38926
38952
  args,
38927
- surface
38953
+ surface,
38954
+ execOptions: surface.execOptions || getNpmExecOptions(options.platform)
38928
38955
  };
38929
38956
  }
38930
- function getNpmExecOptions() {
38931
- return { shell: process.platform === "win32" };
38957
+ function getNpmExecOptions(_platform = process.platform) {
38958
+ return { shell: false };
38932
38959
  }
38933
38960
  function killPid(pid) {
38934
38961
  try {
@@ -39023,11 +39050,10 @@ function removeDaemonPidFile() {
39023
39050
  }
39024
39051
  }
39025
39052
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39026
- const npmExecOpts = getNpmExecOptions();
39027
39053
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
39028
- const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, ["root", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
39054
+ const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "root", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
39029
39055
  if (!npmRoot) return;
39030
- const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, ["prefix", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
39056
+ const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "prefix", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
39031
39057
  const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
39032
39058
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
39033
39059
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -39097,7 +39123,7 @@ async function runDaemonUpgradeHelper(payload) {
39097
39123
  encoding: "utf8",
39098
39124
  stdio: "pipe",
39099
39125
  maxBuffer: 20 * 1024 * 1024,
39100
- ...getNpmExecOptions()
39126
+ ...installCommand.execOptions
39101
39127
  }
39102
39128
  );
39103
39129
  if (installOutput.trim()) {
@@ -87844,12 +87870,15 @@ function verifyPublishedMandatoryUpdateTarget(packageName, targetVersion, deps =
87844
87870
  const validation = validateMandatoryUpdateTarget(targetVersion);
87845
87871
  if (!validation.valid) throw new Error(validation.error || "invalid mandatory update target");
87846
87872
  const run = deps.execFileSync || import_child_process14.execFileSync;
87847
- const npmExecutable = deps.npmExecutable || resolveCurrentGlobalInstallSurface({ packageName }).npmExecutable;
87848
- const published = String(run(npmExecutable, ["view", `${packageName}@${targetVersion}`, "version"], {
87873
+ const surface = resolveCurrentGlobalInstallSurface({ packageName });
87874
+ const npmExecutable = deps.npmExecutable || surface.npmExecutable;
87875
+ const npmArgsPrefix = deps.npmArgsPrefix || surface.npmArgsPrefix || [];
87876
+ const execOptions = deps.execOptions || surface.execOptions || {};
87877
+ const published = String(run(npmExecutable, [...npmArgsPrefix, "view", `${packageName}@${targetVersion}`, "version"], {
87849
87878
  encoding: "utf-8",
87850
87879
  timeout: 1e4,
87851
87880
  stdio: ["pipe", "pipe", "pipe"],
87852
- ...process.platform === "win32" ? { shell: true, windowsHide: true } : {}
87881
+ ...execOptions
87853
87882
  })).trim();
87854
87883
  if (published !== targetVersion) {
87855
87884
  throw new Error(`Published version mismatch: expected ${targetVersion}, got ${published || "unknown"}`);
@@ -88056,7 +88085,7 @@ var init_adhdev_daemon = __esm({
88056
88085
  init_version();
88057
88086
  init_src();
88058
88087
  init_runtime_defaults();
88059
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.47" });
88088
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.48" });
88060
88089
  AdhdevDaemon = class _AdhdevDaemon {
88061
88090
  localHttpServer = null;
88062
88091
  localWss = null;
@@ -89191,10 +89220,11 @@ function hasCloudMachineAuth() {
89191
89220
  function readLatestPublishedCliVersion(execFileSyncLocal) {
89192
89221
  const surface = resolveCurrentGlobalInstallSurface({ packageName: "adhdev" });
89193
89222
  try {
89194
- return execFileSyncLocal(surface.npmExecutable, ["view", "adhdev", "version"], {
89223
+ return execFileSyncLocal(surface.npmExecutable, [...surface.npmArgsPrefix || [], "view", "adhdev", "version"], {
89195
89224
  encoding: "utf-8",
89196
89225
  timeout: 5e3,
89197
- stdio: ["pipe", "pipe", "pipe"]
89226
+ stdio: ["pipe", "pipe", "pipe"],
89227
+ ...surface.execOptions
89198
89228
  }).trim();
89199
89229
  } catch {
89200
89230
  return null;
@@ -89202,7 +89232,7 @@ function readLatestPublishedCliVersion(execFileSyncLocal) {
89202
89232
  }
89203
89233
  function readInstalledGlobalCliVersion(execFileSyncLocal) {
89204
89234
  const surface = resolveCurrentGlobalInstallSurface({ packageName: "adhdev" });
89205
- const args = ["list", "-g", "adhdev", "--json"];
89235
+ const args = [...surface.npmArgsPrefix || [], "list", "-g", "adhdev", "--json"];
89206
89236
  if (surface.installPrefix) {
89207
89237
  args.push("--prefix", surface.installPrefix);
89208
89238
  }
@@ -89210,7 +89240,8 @@ function readInstalledGlobalCliVersion(execFileSyncLocal) {
89210
89240
  const result = execFileSyncLocal(surface.npmExecutable, args, {
89211
89241
  encoding: "utf-8",
89212
89242
  timeout: 5e3,
89213
- stdio: ["pipe", "pipe", "pipe"]
89243
+ stdio: ["pipe", "pipe", "pipe"],
89244
+ ...surface.execOptions
89214
89245
  });
89215
89246
  const parsed = JSON.parse(result);
89216
89247
  return parsed.dependencies?.adhdev?.version || null;
@@ -89255,7 +89286,8 @@ async function checkForUpdate() {
89255
89286
  execFileSync6(installCommand.command, installCommand.args, {
89256
89287
  encoding: "utf-8",
89257
89288
  timeout: 6e4,
89258
- stdio: ["pipe", "pipe", "pipe"]
89289
+ stdio: ["pipe", "pipe", "pipe"],
89290
+ ...installCommand.execOptions
89259
89291
  });
89260
89292
  spinner.succeed(`Updated to v${latestVersion}`);
89261
89293
  console.log();
@@ -89541,7 +89573,8 @@ async function installCliOnly() {
89541
89573
  execFileSyncLocal(installCommand.command, installCommand.args, {
89542
89574
  encoding: "utf-8",
89543
89575
  timeout: 6e4,
89544
- stdio: ["pipe", "pipe", "pipe"]
89576
+ stdio: ["pipe", "pipe", "pipe"],
89577
+ ...installCommand.execOptions
89545
89578
  });
89546
89579
  const newVersion = readInstalledGlobalCliVersion(execFileSyncLocal) || "latest";
89547
89580
  installSpinner.succeed(`adhdev CLI ${currentVersion ? "updated" : "installed"} \u2713 (v${newVersion})`);