adhdev 0.9.76-rc.4 → 0.9.76-rc.5

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
@@ -59161,7 +59161,7 @@ var init_adhdev_daemon = __esm({
59161
59161
  init_version();
59162
59162
  init_src();
59163
59163
  init_runtime_defaults();
59164
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.4" });
59164
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.5" });
59165
59165
  AdhdevDaemon = class _AdhdevDaemon {
59166
59166
  localHttpServer = null;
59167
59167
  localWss = null;
@@ -90912,7 +90912,58 @@ init_lib();
90912
90912
  init_ora();
90913
90913
  init_src();
90914
90914
  init_version();
90915
- var SERVER_URL = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
90915
+ var CHANNEL_NPM_TAG2 = {
90916
+ stable: "latest",
90917
+ preview: "next"
90918
+ };
90919
+ var CHANNEL_SERVER_URL2 = {
90920
+ stable: "https://api.adhf.dev",
90921
+ preview: "https://api-preview.adhf.dev"
90922
+ };
90923
+ function normalizeSetupReleaseChannel(value) {
90924
+ if (typeof value !== "string") return null;
90925
+ const normalized = value.trim().toLowerCase();
90926
+ if (normalized === "stable" || normalized === "latest") return "stable";
90927
+ if (normalized === "preview" || normalized === "next") return "preview";
90928
+ return null;
90929
+ }
90930
+ function inferReleaseChannelFromServerUrl(serverUrl) {
90931
+ if (typeof serverUrl !== "string") return null;
90932
+ const normalized = serverUrl.trim().toLowerCase();
90933
+ if (!normalized) return null;
90934
+ if (normalized.includes("api-preview.adhf.dev") || normalized.includes("dev.adhf.dev")) return "preview";
90935
+ if (normalized.includes("api.adhf.dev") || normalized.includes("adhf.dev")) return "stable";
90936
+ return null;
90937
+ }
90938
+ function buildDashboardUrl(serverUrl, channel) {
90939
+ try {
90940
+ const url2 = new URL(serverUrl);
90941
+ if (url2.hostname === "api-preview.adhf.dev") return "https://dev.adhf.dev/dashboard";
90942
+ if (url2.hostname === "api.adhf.dev") return "https://adhf.dev/dashboard";
90943
+ if (url2.hostname === "127.0.0.1" || url2.hostname === "localhost") {
90944
+ url2.port = url2.port === "3100" ? "3000" : url2.port;
90945
+ url2.pathname = "/dashboard";
90946
+ url2.search = "";
90947
+ url2.hash = "";
90948
+ return url2.toString();
90949
+ }
90950
+ } catch {
90951
+ }
90952
+ return channel === "preview" ? "https://dev.adhf.dev/dashboard" : "https://adhf.dev/dashboard";
90953
+ }
90954
+ function buildSetupReleaseContext(options = {}) {
90955
+ const env3 = options.env || process.env;
90956
+ const envServerUrl = typeof env3.ADHDEV_SERVER_URL === "string" && env3.ADHDEV_SERVER_URL.trim() ? env3.ADHDEV_SERVER_URL.trim() : null;
90957
+ const config2 = options.config || {};
90958
+ const channel = normalizeSetupReleaseChannel(config2.updateChannel) || inferReleaseChannelFromServerUrl(envServerUrl) || inferReleaseChannelFromServerUrl(config2.serverUrl) || "stable";
90959
+ const serverUrl = envServerUrl || CHANNEL_SERVER_URL2[channel];
90960
+ return {
90961
+ channel,
90962
+ npmTag: CHANNEL_NPM_TAG2[channel],
90963
+ serverUrl,
90964
+ dashboardUrl: buildDashboardUrl(serverUrl, channel)
90965
+ };
90966
+ }
90916
90967
  var LOGO = `
90917
90968
  ${source_default2.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")}
90918
90969
  ${source_default2.cyan("\u2551")} ${source_default2.bold.white("\u{1F9A6} ADHDev Setup Wizard")} ${source_default2.cyan("\u2551")}
@@ -90928,10 +90979,10 @@ function hasCloudMachineAuth() {
90928
90979
  const config2 = loadConfig();
90929
90980
  return Boolean(config2.machineSecret && config2.machineSecret.trim());
90930
90981
  }
90931
- function readLatestPublishedCliVersion(execFileSyncLocal) {
90982
+ function readLatestPublishedCliVersion(execFileSyncLocal, npmTag = "latest") {
90932
90983
  const surface = resolveCurrentGlobalInstallSurface({ packageName: "adhdev" });
90933
90984
  try {
90934
- return execFileSyncLocal(surface.npmExecutable, [...surface.npmArgsPrefix || [], "view", "adhdev", "version"], {
90985
+ return execFileSyncLocal(surface.npmExecutable, [...surface.npmArgsPrefix || [], "view", `adhdev@${npmTag}`, "version"], {
90935
90986
  encoding: "utf-8",
90936
90987
  timeout: 5e3,
90937
90988
  stdio: ["pipe", "pipe", "pipe"],
@@ -90962,38 +91013,41 @@ function readInstalledGlobalCliVersion(execFileSyncLocal) {
90962
91013
  }
90963
91014
  async function runWizard(options = {}) {
90964
91015
  console.log(LOGO);
91016
+ const config2 = loadConfig();
91017
+ const releaseContext = buildSetupReleaseContext({ config: config2 });
90965
91018
  if (isSetupComplete() && hasCloudMachineAuth() && !options.force) {
90966
- const config2 = loadConfig();
90967
91019
  console.log(source_default2.green("\u2713") + " ADHDev is already configured.");
90968
91020
  console.log(source_default2.gray(` Account: ${config2.userEmail || "not logged in"}`));
91021
+ console.log(source_default2.gray(` Server: ${releaseContext.serverUrl}`));
90969
91022
  console.log();
90970
- await checkForUpdate();
90971
- await startDaemonFlow();
91023
+ await checkForUpdate(releaseContext);
91024
+ await startDaemonFlow(releaseContext);
90972
91025
  return;
90973
91026
  }
90974
- await quickSetup();
91027
+ await quickSetup(releaseContext);
90975
91028
  }
90976
- async function checkForUpdate() {
91029
+ async function checkForUpdate(releaseContext) {
90977
91030
  try {
90978
91031
  const { execFileSync: execFileSync5 } = await import("child_process");
90979
91032
  const currentVersion = resolvePackageVersion();
90980
- const latestVersion = readLatestPublishedCliVersion(execFileSync5);
91033
+ const latestVersion = readLatestPublishedCliVersion(execFileSync5, releaseContext.npmTag);
90981
91034
  if (!latestVersion) return;
90982
91035
  if (!currentVersion || !latestVersion || currentVersion === latestVersion) return;
90983
- console.log(source_default2.yellow(` Update available: ${currentVersion} \u2192 ${latestVersion}`));
91036
+ console.log(source_default2.yellow(` Update available (${releaseContext.channel}/${releaseContext.npmTag}): ${currentVersion} \u2192 ${latestVersion}`));
90984
91037
  const { doUpdate } = await (await Promise.resolve().then(() => (init_lib(), lib_exports))).default.prompt([{
90985
91038
  type: "confirm",
90986
91039
  name: "doUpdate",
90987
- message: `Update adhdev CLI to v${latestVersion}?`,
91040
+ message: `Update adhdev CLI to v${latestVersion} from ${releaseContext.npmTag}?`,
90988
91041
  default: true
90989
91042
  }]);
90990
91043
  if (!doUpdate) {
90991
- console.log(source_default2.gray(" Skipping update. Run: npm install -g adhdev@latest\n"));
91044
+ console.log(source_default2.gray(` Skipping update. Run: npm install -g adhdev@${releaseContext.npmTag}
91045
+ `));
90992
91046
  return;
90993
91047
  }
90994
91048
  const spinner = (await Promise.resolve().then(() => (init_ora(), ora_exports))).default("Updating adhdev CLI...").start();
90995
91049
  try {
90996
- const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
91050
+ const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: releaseContext.npmTag });
90997
91051
  execFileSync5(installCommand.command, installCommand.args, {
90998
91052
  encoding: "utf-8",
90999
91053
  timeout: 6e4,
@@ -91004,14 +91058,17 @@ async function checkForUpdate() {
91004
91058
  console.log();
91005
91059
  } catch (e) {
91006
91060
  spinner.fail("Update failed");
91007
- console.log(source_default2.gray(" Manual: npm install -g adhdev@latest\n"));
91061
+ console.log(source_default2.gray(` Manual: npm install -g adhdev@${releaseContext.npmTag}
91062
+ `));
91008
91063
  }
91009
91064
  } catch {
91010
91065
  }
91011
91066
  }
91012
- async function quickSetup() {
91067
+ async function quickSetup(releaseContext) {
91013
91068
  console.log(source_default2.bold("\n\u{1F680} Quick Setup\n"));
91014
- const loginResult = await loginFlow();
91069
+ console.log(source_default2.gray(` Channel: ${releaseContext.channel} (${releaseContext.npmTag})`));
91070
+ console.log(source_default2.gray(` Server: ${releaseContext.serverUrl}`));
91071
+ const loginResult = await loginFlow(releaseContext);
91015
91072
  const setupDate = (/* @__PURE__ */ new Date()).toISOString();
91016
91073
  if (!loginResult) {
91017
91074
  updateConfig({
@@ -91022,7 +91079,9 @@ async function quickSetup() {
91022
91079
  setupDate,
91023
91080
  userEmail: null,
91024
91081
  userName: null,
91025
- machineSecret: null
91082
+ machineSecret: null,
91083
+ updateChannel: releaseContext.channel,
91084
+ serverUrl: releaseContext.serverUrl
91026
91085
  });
91027
91086
  console.log(source_default2.yellow("\u26A0 Setup is not complete without login. Run `adhdev setup` after signing in."));
91028
91087
  }
@@ -91033,14 +91092,16 @@ async function quickSetup() {
91033
91092
  userEmail: loginResult.email,
91034
91093
  userName: loginResult.name,
91035
91094
  setupDate,
91095
+ updateChannel: releaseContext.channel,
91096
+ serverUrl: releaseContext.serverUrl,
91036
91097
  ...loginResult.registeredMachineId ? { registeredMachineId: loginResult.registeredMachineId } : {}
91037
91098
  };
91038
91099
  updateConfig(configUpdate);
91039
91100
  console.log(source_default2.green(` \u2713 Machine registered`));
91040
91101
  }
91041
- await installCliOnly();
91102
+ await installCliOnly(releaseContext);
91042
91103
  if (loginResult) {
91043
- await startDaemonFlow();
91104
+ await startDaemonFlow(releaseContext);
91044
91105
  } else {
91045
91106
  console.log(source_default2.gray(" Start daemon after login: adhdev setup"));
91046
91107
  console.log();
@@ -91049,6 +91110,7 @@ async function quickSetup() {
91049
91110
  console.log(source_default2.bold("\n\u{1F389} Setup Complete!\n"));
91050
91111
  console.log(` ${source_default2.bold("User:")} ${loginResult?.email || "not logged in"}`);
91051
91112
  console.log(` ${source_default2.bold("Status:")} ${loginResult ? source_default2.green("Ready to connect") : source_default2.yellow("Login required")}`);
91113
+ console.log(` ${source_default2.bold("Server:")} ${releaseContext.serverUrl}`);
91052
91114
  console.log();
91053
91115
  console.log(source_default2.gray(" Next steps:"));
91054
91116
  console.log(source_default2.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (IDE / remote features)" : "adhdev setup \u2014 Sign in to finish setup and enable the daemon"}`));
@@ -91059,11 +91121,12 @@ async function quickSetup() {
91059
91121
  console.log(source_default2.gray(" adhdev launch claude \u2014 Start Claude Code agent"));
91060
91122
  console.log(source_default2.gray(" adhdev status \u2014 Check setup status"));
91061
91123
  console.log();
91062
- console.log(source_default2.cyan(" Dashboard: https://adhf.dev/dashboard"));
91124
+ console.log(source_default2.cyan(` Dashboard: ${releaseContext.dashboardUrl}`));
91063
91125
  console.log();
91064
91126
  }
91065
- async function loginFlow() {
91127
+ async function loginFlow(releaseContext) {
91066
91128
  console.log(source_default2.bold("\n\u{1F510} Login to ADHDev\n"));
91129
+ console.log(source_default2.gray(` Auth server: ${releaseContext.serverUrl}`));
91067
91130
  const { wantLogin } = await lib_default.prompt([
91068
91131
  {
91069
91132
  type: "confirm",
@@ -91080,7 +91143,7 @@ async function loginFlow() {
91080
91143
  try {
91081
91144
  const config2 = loadConfig();
91082
91145
  const os29 = await import("os");
91083
- const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
91146
+ const res = await fetch(`${releaseContext.serverUrl}/auth/cli/init`, {
91084
91147
  method: "POST",
91085
91148
  headers: { "Content-Type": "application/json" },
91086
91149
  body: JSON.stringify({
@@ -91122,7 +91185,7 @@ async function loginFlow() {
91122
91185
  while (Date.now() - startTime < timeout) {
91123
91186
  await new Promise((r) => setTimeout(r, 3e3));
91124
91187
  try {
91125
- const res = await fetch(`${SERVER_URL}/auth/cli/poll`, {
91188
+ const res = await fetch(`${releaseContext.serverUrl}/auth/cli/poll`, {
91126
91189
  method: "POST",
91127
91190
  headers: { "Content-Type": "application/json" },
91128
91191
  body: JSON.stringify({ deviceCode })
@@ -91152,9 +91215,9 @@ async function loginFlow() {
91152
91215
  console.log();
91153
91216
  console.log(source_default2.yellow(" To fix this, do one of the following:"));
91154
91217
  console.log(source_default2.gray(" 1. Remove an unused machine from the dashboard:"));
91155
- console.log(source_default2.gray(" https://adhf.dev/account \u2192 Registered Machines \u2192 \u2715 Remove"));
91218
+ console.log(source_default2.gray(` ${releaseContext.dashboardUrl.replace(/\/dashboard$/, "/account")} \u2192 Registered Machines \u2192 \u2715 Remove`));
91156
91219
  console.log(source_default2.gray(" 2. Upgrade your plan:"));
91157
- console.log(source_default2.gray(" https://adhf.dev/account?tab=billing"));
91220
+ console.log(source_default2.gray(` ${releaseContext.dashboardUrl.replace(/\/dashboard$/, "/account?tab=billing")}`));
91158
91221
  console.log();
91159
91222
  console.log(source_default2.gray(" Then run `adhdev setup` again."));
91160
91223
  console.log();
@@ -91166,11 +91229,12 @@ async function loginFlow() {
91166
91229
  pollSpinner.fail("Authentication timed out");
91167
91230
  return null;
91168
91231
  }
91169
- async function startDaemonFlow() {
91232
+ async function startDaemonFlow(releaseContext) {
91170
91233
  const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
91171
91234
  if (isDaemonRunning2()) {
91172
91235
  console.log(source_default2.green(" \u2713 Daemon is already running"));
91173
- console.log(source_default2.gray(" Dashboard: https://adhf.dev/dashboard\n"));
91236
+ console.log(source_default2.gray(` Dashboard: ${releaseContext.dashboardUrl}
91237
+ `));
91174
91238
  return;
91175
91239
  }
91176
91240
  const { startDaemon } = await lib_default.prompt([
@@ -91224,7 +91288,7 @@ async function startDaemonFlow() {
91224
91288
  } else {
91225
91289
  daemonSpinner.warn("Daemon starting in background (may take a few seconds)");
91226
91290
  }
91227
- console.log(source_default2.gray(" Dashboard: https://adhf.dev/dashboard"));
91291
+ console.log(source_default2.gray(` Dashboard: ${releaseContext.dashboardUrl}`));
91228
91292
  console.log(source_default2.gray(` Logs: ${logPath}`));
91229
91293
  console.log();
91230
91294
  } catch (e) {
@@ -91232,7 +91296,7 @@ async function startDaemonFlow() {
91232
91296
  console.log(source_default2.gray(" Manual: adhdev daemon\n"));
91233
91297
  }
91234
91298
  }
91235
- async function installCliOnly() {
91299
+ async function installCliOnly(releaseContext) {
91236
91300
  const { execFileSync: execFileSyncLocal } = await import("child_process");
91237
91301
  const currentVersion = readInstalledGlobalCliVersion(execFileSyncLocal);
91238
91302
  const isNpx = process.env.npm_execpath?.includes("npx") || process.argv[1]?.includes("npx") || process.argv[1]?.includes("_npx");
@@ -91245,7 +91309,7 @@ async function installCliOnly() {
91245
91309
  console.log();
91246
91310
  if (currentVersion) {
91247
91311
  console.log(source_default2.green(` \u2713 Currently installed: v${currentVersion}`));
91248
- const latestVersion = readLatestPublishedCliVersion(execFileSyncLocal);
91312
+ const latestVersion = readLatestPublishedCliVersion(execFileSyncLocal, releaseContext.npmTag);
91249
91313
  if (latestVersion && currentVersion === latestVersion) {
91250
91314
  console.log(source_default2.gray(" (Already up to date)"));
91251
91315
  return;
@@ -91254,12 +91318,12 @@ async function installCliOnly() {
91254
91318
  const { doUpdate } = await lib_default.prompt([{
91255
91319
  type: "confirm",
91256
91320
  name: "doUpdate",
91257
- message: `Update to latest version${latestVersion ? ` (v${latestVersion})` : ""}?`,
91321
+ message: `Update to ${releaseContext.npmTag} version${latestVersion ? ` (v${latestVersion})` : ""}?`,
91258
91322
  default: true
91259
91323
  }]);
91260
91324
  if (!doUpdate) return;
91261
91325
  } else {
91262
- console.log(source_default2.gray(" Updating to latest..."));
91326
+ console.log(source_default2.gray(` Updating to ${releaseContext.npmTag}...`));
91263
91327
  }
91264
91328
  } else {
91265
91329
  console.log(source_default2.yellow(" \u2717 Not installed globally"));
@@ -91267,7 +91331,7 @@ async function installCliOnly() {
91267
91331
  const { doInstall } = await lib_default.prompt([{
91268
91332
  type: "confirm",
91269
91333
  name: "doInstall",
91270
- message: "Install adhdev CLI globally? (npm install -g adhdev)",
91334
+ message: `Install adhdev CLI globally? (npm install -g adhdev@${releaseContext.npmTag})`,
91271
91335
  default: true
91272
91336
  }]);
91273
91337
  if (!doInstall) {
@@ -91280,14 +91344,14 @@ async function installCliOnly() {
91280
91344
  }
91281
91345
  const installSpinner = ora2("Installing adhdev CLI...").start();
91282
91346
  try {
91283
- const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
91347
+ const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: releaseContext.npmTag });
91284
91348
  execFileSyncLocal(installCommand.command, installCommand.args, {
91285
91349
  encoding: "utf-8",
91286
91350
  timeout: 6e4,
91287
91351
  stdio: ["pipe", "pipe", "pipe"],
91288
91352
  ...installCommand.execOptions
91289
91353
  });
91290
- const newVersion = readInstalledGlobalCliVersion(execFileSyncLocal) || "latest";
91354
+ const newVersion = readInstalledGlobalCliVersion(execFileSyncLocal) || releaseContext.npmTag;
91291
91355
  installSpinner.succeed(`adhdev CLI ${currentVersion ? "updated" : "installed"} \u2713 (v${newVersion})`);
91292
91356
  console.log(source_default2.gray(" Try: adhdev daemon"));
91293
91357
  console.log();
@@ -91298,7 +91362,7 @@ async function installCliOnly() {
91298
91362
  if (osModule.platform() === "win32") {
91299
91363
  console.log(source_default2.gray(" On Windows, run PowerShell as Administrator"));
91300
91364
  }
91301
- console.log(source_default2.gray(" Manual: npm install -g adhdev@latest"));
91365
+ console.log(source_default2.gray(` Manual: npm install -g adhdev@${releaseContext.npmTag}`));
91302
91366
  console.log();
91303
91367
  }
91304
91368
  }