@keystrokehq/cli 0.0.103 → 0.0.105

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/README.md CHANGED
@@ -35,7 +35,7 @@ keystroke auth logout
35
35
  | `platformUrl` | `https://api.keystroke.ai` | Platform API (direct; used by CLI platform commands) |
36
36
  | `serverUrl` | `http://localhost:3001` | Local keystroke server API (`keystroke dev` / `keystroke start`) |
37
37
 
38
- `auth login` persists both `webUrl` and `platformUrl`. Local dev: `--web-url http://localhost:3000` (platform URL resolves to `http://localhost:3002`). Cloud auth does not change `serverUrl` — local project commands still hit your dev server.
38
+ `auth login` persists both `webUrl` and `platformUrl`. Omit `--web-url` to always reset to production defaults (`https://app.keystroke.ai` / `https://api.keystroke.ai`), even if a previous login pointed at localhost. Local dev: `--web-url http://localhost:3000` (platform URL resolves to `http://localhost:3002`). Cloud auth does not change `serverUrl` — local project commands still hit your dev server.
39
39
 
40
40
  Existing commands do not require auth yet. Use `resolveCliAuth()` when adding protected commands.
41
41
 
package/dist/index.mjs CHANGED
@@ -11278,8 +11278,6 @@ async function syncActiveOrganizationAfterLogin(config, options = {}) {
11278
11278
  process.stdout.write(`Using organization ${membership.organization.name}\n`);
11279
11279
  return membership;
11280
11280
  }
11281
- const webUrl = getWebUrl(config).replace(/\/+$/, "");
11282
- options.openUrl?.(`${webUrl}/organization/selection?from=cli`);
11283
11281
  const membership = await pickOrganization(config, organizations);
11284
11282
  process.stdout.write(`Using organization ${membership.organization.name}\n`);
11285
11283
  return membership;
@@ -13430,15 +13428,23 @@ async function getSessionWithBearer(baseURL, accessToken) {
13430
13428
  };
13431
13429
  }
13432
13430
  //#endregion
13431
+ //#region src/auth/resolve-login-targets.ts
13432
+ function resolveAuthLoginTargets(options, config) {
13433
+ const webUrl = options.webUrl ?? "https://app.keystroke.ai";
13434
+ return {
13435
+ webUrl,
13436
+ platformUrl: resolvePlatformUrlForWebUrl(webUrl, {
13437
+ platformUrl: options.platformUrl,
13438
+ fallback: options.webUrl ? getPlatformUrl(config) : DEFAULT_PLATFORM_URL
13439
+ })
13440
+ };
13441
+ }
13442
+ //#endregion
13433
13443
  //#region src/commands/auth/login.ts
13434
13444
  function registerAuthLoginCommand(auth) {
13435
- auth.command("login").description("Authenticate via browser device flow").option("--web-url <url>", "Web dashboard origin (default from config)").option("--platform-url <url>", "Platform API origin (derived from web URL when omitted)").option("--org <id>", "Active organization id (skips prompt when you belong to several)").action(async (options) => {
13445
+ auth.command("login").description("Authenticate via browser device flow").option("--web-url <url>", "Web dashboard origin (omit to use production defaults; local dev: http://localhost:3000)").option("--platform-url <url>", "Platform API origin (derived from web URL when omitted)").option("--org <id>", "Active organization id (skips prompt when you belong to several)").action(async (options) => {
13436
13446
  const config = createCliConfig();
13437
- const webUrl = options.webUrl ?? getWebUrl(config);
13438
- const platformUrl = resolvePlatformUrlForWebUrl(webUrl, {
13439
- platformUrl: options.platformUrl,
13440
- fallback: getPlatformUrl(config)
13441
- });
13447
+ const { webUrl, platformUrl } = resolveAuthLoginTargets(options, config);
13442
13448
  config.set("webUrl", webUrl);
13443
13449
  config.set("platformUrl", platformUrl);
13444
13450
  try {
@@ -13451,10 +13457,7 @@ function registerAuthLoginCommand(auth) {
13451
13457
  const user = await getSessionWithBearer(webUrl, result.accessToken);
13452
13458
  if (user) process.stdout.write(`Logged in as ${user.name} (${user.email})\n`);
13453
13459
  else process.stdout.write(`Logged in to ${webUrl}\n`);
13454
- await syncActiveOrganizationAfterLogin(config, {
13455
- organizationId: options.org,
13456
- openUrl
13457
- });
13460
+ await syncActiveOrganizationAfterLogin(config, { organizationId: options.org });
13458
13461
  } catch (error) {
13459
13462
  process.stderr.write(`${formatCliError(error, "Login failed", { webUrl })}\n`);
13460
13463
  process.exitCode = 1;