genclass 0.3.8 → 0.3.9

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/genclass.mjs CHANGED
@@ -12,7 +12,7 @@ var __export = (target, all) => {
12
12
  var define_GENCLASS_BUILD_default;
13
13
  var init_define_GENCLASS_BUILD = __esm({
14
14
  "<define:__GENCLASS_BUILD__>"() {
15
- define_GENCLASS_BUILD_default = { version: "0.3.8", runtimeVersion: "0.3.0-beta.6", mcpVersion: "0.2.2", workflow: `# GenClass on your existing Playwright suite: no change to your tests or your playwright.config.
15
+ define_GENCLASS_BUILD_default = { version: "0.3.9", runtimeVersion: "0.3.0-beta.6", mcpVersion: "0.2.2", workflow: `# GenClass on your existing Playwright suite: no change to your tests or your playwright.config.
16
16
  # Copy to .github/workflows/genclass.yml.
17
17
  #
18
18
  # Assumes "npx playwright test" works on a fresh checkout with dependencies installed, which usually
@@ -473,18 +473,23 @@ var init_account = __esm({
473
473
  // src/name.mjs
474
474
  var name_exports = {};
475
475
  __export(name_exports, {
476
+ forgetShortName: () => forgetShortName,
476
477
  installGlobally: () => installGlobally,
478
+ installedVersion: () => installedVersion,
477
479
  isShort: () => isShort,
480
+ latestOnNpm: () => latestOnNpm,
481
+ newer: () => newer,
478
482
  readPrefs: () => readPrefs,
479
483
  savePrefs: () => savePrefs,
480
484
  shortNameWorks: () => shortNameWorks,
481
485
  shorten: () => shorten,
482
- useShortName: () => useShortName
486
+ useShortName: () => useShortName,
487
+ viaNpx: () => viaNpx
483
488
  });
484
489
  import { spawn } from "node:child_process";
485
- import { accessSync, constants, mkdirSync as mkdirSync2, readFileSync as readFileSync4, statSync, writeFileSync as writeFileSync3 } from "node:fs";
490
+ import { accessSync, constants, mkdirSync as mkdirSync2, readFileSync as readFileSync4, realpathSync, statSync, writeFileSync as writeFileSync3 } from "node:fs";
486
491
  import { delimiter, dirname as dirname2, join as join3 } from "node:path";
487
- function shortNameWorks(env2 = process.env, platform = process.platform) {
492
+ function shortNameFile(env2 = process.env, platform = process.platform) {
488
493
  const names = platform === "win32" ? ["genclass.cmd", "genclass.exe", "genclass.ps1"] : ["genclass"];
489
494
  for (const dir of String(env2.PATH ?? env2.Path ?? "").split(platform === "win32" ? ";" : delimiter)) {
490
495
  if (!dir || /[\\/]_npx[\\/]/.test(dir) || /node_modules[\\/]\.bin[\\/]?$/.test(dir)) continue;
@@ -493,12 +498,53 @@ function shortNameWorks(env2 = process.env, platform = process.platform) {
493
498
  const file = join3(dir, n2);
494
499
  if (!statSync(file).isFile()) continue;
495
500
  if (platform !== "win32") accessSync(file, constants.X_OK);
496
- return true;
501
+ return file;
497
502
  } catch {
498
503
  }
499
504
  }
500
505
  }
501
- return false;
506
+ return null;
507
+ }
508
+ function installedVersion(env2 = process.env, platform = process.platform) {
509
+ const file = shortNameFile(env2, platform);
510
+ if (!file || platform === "win32") return null;
511
+ try {
512
+ const pkg = join3(dirname2(dirname2(realpathSync(file))), "package.json");
513
+ const j = JSON.parse(readFileSync4(pkg, "utf8"));
514
+ return j?.name === "genclass" && typeof j.version === "string" ? j.version : null;
515
+ } catch {
516
+ return null;
517
+ }
518
+ }
519
+ function newer(a, b) {
520
+ const parse2 = (v) => {
521
+ const m = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/.exec(String(v ?? ""));
522
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3]), m[4] ?? null] : null;
523
+ };
524
+ const x = parse2(a);
525
+ const y = parse2(b);
526
+ if (!x || !y) return false;
527
+ for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] > y[i];
528
+ if (x[3] === y[3]) return false;
529
+ return x[3] === null ? true : y[3] === null ? false : x[3] > y[3];
530
+ }
531
+ async function latestOnNpm(fetchFn = globalThis.fetch, timeoutMs = 2e3) {
532
+ if (typeof fetchFn !== "function") return null;
533
+ const ctl = new AbortController();
534
+ const t = setTimeout(() => ctl.abort(), timeoutMs);
535
+ try {
536
+ const r = await fetchFn("https://registry.npmjs.org/genclass/latest", { headers: { accept: "application/json" }, signal: ctl.signal });
537
+ if (!r.ok) return null;
538
+ const j = await r.json();
539
+ return typeof j?.version === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(j.version) ? j.version : null;
540
+ } catch {
541
+ return null;
542
+ } finally {
543
+ clearTimeout(t);
544
+ }
545
+ }
546
+ function shortNameWorks(env2 = process.env, platform = process.platform) {
547
+ return shortNameFile(env2, platform) !== null;
502
548
  }
503
549
  function useShortName() {
504
550
  short = true;
@@ -545,15 +591,19 @@ function installGlobally(version2, run5 = spawn) {
545
591
  child.on("close", (code) => resolve12({ ok: code === 0, text: text.trim().split("\n").slice(-4).join("\n") }));
546
592
  });
547
593
  }
548
- var shorten, short, wrapped, isShort, prefsFile;
594
+ var viaNpx, shorten, short, wrapped, isShort, forgetShortName, prefsFile;
549
595
  var init_name = __esm({
550
596
  "src/name.mjs"() {
551
597
  init_define_GENCLASS_BUILD();
552
598
  init_account();
599
+ viaNpx = (argv1 = process.argv[1] ?? "") => /[\\/]_npx[\\/]/.test(String(argv1));
553
600
  shorten = (text) => String(text).replace(/(^|[^\w-]|\u001b\[[0-9;]*m)npx genclass\b/g, "$1genclass");
554
601
  short = false;
555
602
  wrapped = false;
556
603
  isShort = () => short;
604
+ forgetShortName = () => {
605
+ short = false;
606
+ };
557
607
  prefsFile = () => join3(dirname2(credentialsPath()), "prefs.json");
558
608
  }
559
609
  });
@@ -764,8 +814,8 @@ async function ask(question, opts = {}) {
764
814
  });
765
815
  }
766
816
  async function confirm(question, def = true) {
767
- const hint = def ? "Y/n" : "y/N";
768
- const answer = await ask(` ${c.bold(question)} ${c.gray(`(${hint})`)} `);
817
+ const hint2 = def ? "Y/n" : "y/N";
818
+ const answer = await ask(` ${c.bold(question)} ${c.gray(`(${hint2})`)} `);
769
819
  if (answer === null) return null;
770
820
  const a = answer.toLowerCase();
771
821
  if (!a) return def;
@@ -892,6 +942,42 @@ var init_art = __esm({
892
942
  });
893
943
 
894
944
  // src/tui.mjs
945
+ var tui_exports = {};
946
+ __export(tui_exports, {
947
+ PROMPT: () => PROMPT,
948
+ STOP_HINT: () => STOP_HINT,
949
+ ago: () => ago,
950
+ agree: () => agree,
951
+ bad: () => bad,
952
+ barPara: () => barPara,
953
+ card: () => card,
954
+ checklist: () => checklist,
955
+ clean: () => clean,
956
+ firstName: () => firstName,
957
+ fitLine: () => fitLine,
958
+ folderName: () => folderName,
959
+ good: () => good,
960
+ header: () => header,
961
+ hint: () => hint,
962
+ homeOpen: () => homeOpen,
963
+ inHome: () => inHome,
964
+ linkLine: () => linkLine,
965
+ nextBlock: () => nextBlock,
966
+ note: () => note,
967
+ para: () => para,
968
+ pick: () => pick,
969
+ planCard: () => planCard,
970
+ proBox: () => proBox,
971
+ rule: () => rule,
972
+ secret: () => secret,
973
+ spinner: () => spinner,
974
+ summary: () => summary,
975
+ typed: () => typed,
976
+ visible: () => visible2,
977
+ warn: () => warn,
978
+ width: () => width,
979
+ wrap: () => wrap2
980
+ });
895
981
  import { homedir as homedir2 } from "node:os";
896
982
  function clean(text, max = 400) {
897
983
  const s = String(text ?? "").replace(ANSI, "").replace(CONTROL, " ").replace(/\s+/g, " ").trim();
@@ -942,6 +1028,13 @@ function wrap2(text, cols2 = width() - 4) {
942
1028
  function para(text, indent = " ", paint = (s) => s) {
943
1029
  for (const l of wrap2(text, width() - 2 - indent.length)) out(`${indent}${paint(l)}`);
944
1030
  }
1031
+ function linkLine(label, url) {
1032
+ if (2 + visible2(label) + 2 + visible2(url) <= width() - 2) out(` ${c.gray(label)} ${c.cyan(url)}`);
1033
+ else {
1034
+ out(` ${c.gray(label)}`);
1035
+ out(` ${c.cyan(url)}`);
1036
+ }
1037
+ }
945
1038
  function header(h = {}) {
946
1039
  if (homeApp !== null) {
947
1040
  out();
@@ -1029,9 +1122,9 @@ function planCard(offer, app, heading = null) {
1029
1122
  row3(price);
1030
1123
  }
1031
1124
  if (offer.summary) for (const l of wrap2(clean(offer.summary, 200), room3)) row3(c.gray(l));
1032
- if (offer.trialDays) for (const l of wrap2(`${offer.trialDays} days free, then ${clean(offer.price, 40)}. Cancel any time.`, room3)) row3(c.green(l));
1125
+ if (offer.trialDays) for (const l of wrap2(`The first ${offer.trialDays} days are free. Cancel any time.`, room3)) row3(c.green(l));
1033
1126
  row3();
1034
- for (const f of offer.features) {
1127
+ for (const f of offer.trialDays ? offer.features.filter((x) => !/days? free/i.test(x)) : offer.features) {
1035
1128
  const [first = "", ...rest] = wrap2(clean(f, 120), room3 - 2);
1036
1129
  row3(`${c.green(sym.ok)} ${first}`);
1037
1130
  for (const l of rest) row3(` ${l}`);
@@ -1054,16 +1147,16 @@ function checklist(steps) {
1054
1147
  function summary(steps) {
1055
1148
  const room3 = width() - 4 - 3 - 9;
1056
1149
  const names = (list2) => {
1057
- const lines = [];
1150
+ const lines2 = [];
1058
1151
  let line2 = "";
1059
1152
  for (const t of list2.map((s) => s.title)) {
1060
1153
  if (line2 && visible2(line2) + 3 + t.length > room3) {
1061
- lines.push(`${line2} ${sym.dot}`);
1154
+ lines2.push(`${line2} ${sym.dot}`);
1062
1155
  line2 = t;
1063
1156
  } else line2 = line2 ? `${line2} ${sym.dot} ${t}` : t;
1064
1157
  }
1065
- if (line2) lines.push(line2);
1066
- return lines;
1158
+ if (line2) lines2.push(line2);
1159
+ return lines2;
1067
1160
  };
1068
1161
  const line = (mark2, label, text) => {
1069
1162
  const [first = "", ...rest] = Array.isArray(text) ? text : [text];
@@ -1075,9 +1168,10 @@ function summary(steps) {
1075
1168
  const next = steps.find((s) => s.state === "next");
1076
1169
  const later = steps.filter((s) => s.state === "todo");
1077
1170
  if (done.length) line(MARK2.done(), pad("Done"), names(done));
1078
- for (const b of steps.filter((s) => s.state === "blocked")) line(MARK2.blocked(), pad(b.title), c.gray(clean(b.detail ?? "", room3)));
1171
+ const lines = (text) => wrap2(text, room3);
1172
+ for (const b of steps.filter((s) => s.state === "blocked")) line(MARK2.blocked(), pad(b.title), lines(clean(b.detail ?? "", 200)));
1079
1173
  if (next) line(MARK2.next(), c.bold(pad("Next")), c.bold(clean(next.doing ?? next.title, room3)));
1080
- for (const w of steps.filter((s) => s.state === "waiting")) line(MARK2.waiting(), pad("Waiting"), c.gray(clean(`${w.title}: ${w.detail ?? ""}`, room3)));
1174
+ for (const w of steps.filter((s) => s.state === "waiting")) line(MARK2.waiting(), pad("Waiting"), lines(clean(`${w.title}: ${w.detail ?? ""}`, 200)));
1081
1175
  if (later.length) line(MARK2.todo(), c.gray(pad("Later")), names(later));
1082
1176
  }
1083
1177
  function nextBlock(title, text) {
@@ -1154,7 +1248,7 @@ function ago(iso, now = Date.now()) {
1154
1248
  }
1155
1249
  return "just now";
1156
1250
  }
1157
- var tty2, unicode2, ESC2, CSI, ANSI, CONTROL, COLOUR, width, visible2, SUBCOMMANDS, VALUED, plainWord, closes, rule, homeApp, inHome, homeOpen, centre, badge, BAR, PROMPT, MARK2, note, marked, good, warn, bad, FRAMES, STOP_HINT;
1251
+ var tty2, unicode2, ESC2, CSI, ANSI, CONTROL, COLOUR, width, visible2, SUBCOMMANDS, VALUED, plainWord, closes, rule, homeApp, inHome, homeOpen, hint, centre, badge, BAR, PROMPT, MARK2, note, marked, good, warn, bad, FRAMES, STOP_HINT;
1158
1252
  var init_tui = __esm({
1159
1253
  "src/tui.mjs"() {
1160
1254
  init_define_GENCLASS_BUILD();
@@ -1181,6 +1275,7 @@ var init_tui = __esm({
1181
1275
  homeApp = app === null ? null : clean(app ?? "", 40);
1182
1276
  };
1183
1277
  homeOpen = () => homeApp !== null;
1278
+ hint = (cmd) => homeOpen() ? `type ${cmd}` : `run npx genclass ${cmd}`;
1184
1279
  centre = (text, cols2) => {
1185
1280
  const pad = Math.max(0, cols2 - visible2(text));
1186
1281
  const left = Math.floor(pad / 2);
@@ -2051,7 +2146,7 @@ function versionInSpec(spec) {
2051
2146
  const m = /^\s*(?:[\^~]|>=?|=)?\s*v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/.exec(String(spec ?? ""));
2052
2147
  return m ? m[1] : null;
2053
2148
  }
2054
- function installedVersion(dir) {
2149
+ function installedVersion2(dir) {
2055
2150
  for (let d = resolve2(dir); ; d = dirname4(d)) {
2056
2151
  try {
2057
2152
  const v = JSON.parse(readFileSync6(join5(d, "node_modules", "@genclass", "runtime", "package.json"), "utf8")).version;
@@ -2108,12 +2203,12 @@ function versionStatus(version2, tags) {
2108
2203
  if (!tags) return { tag: null, newer: null };
2109
2204
  const entries = Object.entries(tags);
2110
2205
  const tag = entries.find(([k, v]) => v === version2 && k === "latest")?.[0] ?? entries.find(([, v]) => v === version2)?.[0] ?? null;
2111
- let newer = null;
2206
+ let newer2 = null;
2112
2207
  for (const [k, v] of entries) {
2113
2208
  if (compareVersions(v, version2) !== 1) continue;
2114
- if (!newer || compareVersions(v, newer.version) === 1) newer = { version: v, tag: k };
2209
+ if (!newer2 || compareVersions(v, newer2.version) === 1) newer2 = { version: v, tag: k };
2115
2210
  }
2116
- return { tag, newer };
2211
+ return { tag, newer: newer2 };
2117
2212
  }
2118
2213
  var PKG, PKG_DIR, HOST_CLI, VERSION2, SEMVER, cmdFor, CMD;
2119
2214
  var init_version = __esm({
@@ -2699,7 +2794,7 @@ function briefTelemetry(cfg) {
2699
2794
  out(` ${c.gray(TELEMETRY_URL)}`);
2700
2795
  }
2701
2796
  function commandLine(label, cmd) {
2702
- const cols2 = Math.max(40, Math.min(100, Number(process.stdout.columns) || 100));
2797
+ const cols2 = Math.max(40, Math.min(100, Number(process.stdout.columns) || Number(process.env.COLUMNS) || 100));
2703
2798
  if (2 + label.length + 2 + cmd.length <= cols2) {
2704
2799
  out(` ${c.bold(label)} ${c.cyan(cmd)}`);
2705
2800
  return;
@@ -2715,7 +2810,7 @@ function commandLine(label, cmd) {
2715
2810
  if (line) out(` ${c.cyan(line)}`);
2716
2811
  }
2717
2812
  function briefLines(text, paint = c.gray) {
2718
- const cols2 = Math.max(40, Math.min(100, Number(process.stdout.columns) || 100)) - 4;
2813
+ const cols2 = Math.max(40, Math.min(100, Number(process.stdout.columns) || Number(process.env.COLUMNS) || 100)) - 4;
2719
2814
  let line = "";
2720
2815
  for (const word of String(text).split(/\s+/).filter(Boolean)) {
2721
2816
  if (line && line.length + 1 + word.length > cols2) {
@@ -2973,7 +3068,7 @@ async function versionNotice(o) {
2973
3068
  }
2974
3069
  function olderRuntime(project, cwd) {
2975
3070
  if (!project.pkg || !project.has(PKG)) return null;
2976
- const have = installedVersion(cwd) ?? versionInSpec(project.deps[PKG]);
3071
+ const have = installedVersion2(cwd) ?? versionInSpec(project.deps[PKG]);
2977
3072
  return have && compareVersions(have, VERSION2) === -1 ? have : null;
2978
3073
  }
2979
3074
  function inspectProject(o) {
@@ -3465,6 +3560,23 @@ remove takes out exactly what init added (the lines and blocks marked "${MARK3
3465
3560
  });
3466
3561
 
3467
3562
  // src/api.mjs
3563
+ var api_exports = {};
3564
+ __export(api_exports, {
3565
+ askModel: () => askModel,
3566
+ changeConnection: () => changeConnection,
3567
+ cliOf: () => cliOf,
3568
+ createInvite: () => createInvite,
3569
+ fetchAccount: () => fetchAccount,
3570
+ fetchApp: () => fetchApp,
3571
+ fetchConnections: () => fetchConnections,
3572
+ fetchEvents: () => fetchEvents,
3573
+ fetchOverview: () => fetchOverview,
3574
+ fetchRepoStatus: () => fetchRepoStatus,
3575
+ makeAgentLink: () => makeAgentLink,
3576
+ requestPlan: () => requestPlan,
3577
+ saveFunnels: () => saveFunnels,
3578
+ signInIsOld: () => signInIsOld
3579
+ });
3468
3580
  async function fetchOverview(creds, opts = {}) {
3469
3581
  const base2 = { token: creds.access_token, host: creds.host, fetchFn: opts.fetchFn };
3470
3582
  let r = await request("/api/cli/overview", base2);
@@ -4072,7 +4184,7 @@ async function afterLogin(o, creds, me) {
4072
4184
  }
4073
4185
  const where = relative4(process.cwd(), st.cwd) || ".";
4074
4186
  const name = st.project.pkg?.name || st.project.name;
4075
- const ok = o.yes ? true : await confirm(`Connect ${name} (${where}, ${st.project.label}) to ${HOST_CLI?.into ?? "your account"}?`);
4187
+ const ok = o.yes ? true : await confirm(`Connect ${name} (${where === "." ? "" : `${where}, `}${st.project.label}) to ${HOST_CLI?.into ?? "your account"}?`);
4076
4188
  if (ok === null) {
4077
4189
  out(` Not a terminal: run ${c.cyan(`${CMD} connect --yes`)} here to connect this app.`);
4078
4190
  out();
@@ -4134,7 +4246,7 @@ async function login(o) {
4134
4246
  out();
4135
4247
  return 1;
4136
4248
  }
4137
- out(` Open this link, sign in (Google, email and password, GitHub or a passkey) and approve the code:`);
4249
+ more("Open this link, sign in (Google, email and password, GitHub or a passkey) and approve the code:", 2);
4138
4250
  out(` ${c.bold(c.cyan(dev.verification_uri_complete))}`);
4139
4251
  out();
4140
4252
  row("Code", `${c.bold(dev.user_code)} ${c.gray("(check that the page shows the same code)")}`);
@@ -4142,7 +4254,7 @@ async function login(o) {
4142
4254
  if (openBrowser(dev.verification_uri_complete, o)) out(` ${c.gray("Opening it in your browser.")}`);
4143
4255
  else out(` ${c.gray("Open the link in a browser on any device.")}`);
4144
4256
  const minutes = Math.max(1, Math.round(dev.expires_in / 60));
4145
- out(` Waiting for approval ${c.gray(`(the code expires in ${minutes} minute${minutes === 1 ? "" : "s"}; Ctrl-C to cancel)`)}`);
4257
+ more(`Waiting for approval ${c.gray(`(the code expires in ${minutes} minute${minutes === 1 ? "" : "s"}; Ctrl-C to cancel)`)}`, 2);
4146
4258
  const ctl = new AbortController();
4147
4259
  const onSigint = () => ctl.abort();
4148
4260
  process.on("SIGINT", onSigint);
@@ -4177,7 +4289,7 @@ async function login(o) {
4177
4289
  }
4178
4290
  out();
4179
4291
  row("Signed in", `${c.bold(accountLabel(creds.account))}${creds.account.github_login && creds.account.email ? c.gray(` (GitHub ${creds.account.github_login})`) : ""}`);
4180
- out(` ${c.gray(`Session saved in ${tilde(path)} (only you can read it).`)}`);
4292
+ more(c.gray(`Session saved in ${tilde(path)} (only you can read it).`), 2);
4181
4293
  out(` ${c.gray(`Sign out: ${CMD} logout`)}`);
4182
4294
  out();
4183
4295
  return afterLogin(o, creds, null);
@@ -4294,7 +4406,7 @@ async function logout() {
4294
4406
  return 1;
4295
4407
  }
4296
4408
  row("Signed out", accountLabel(creds.account));
4297
- out(` ${c.gray(`The CLI session is ended at genclass.dev, and ${tilde(path)} is deleted.`)}`);
4409
+ more(c.gray(`The CLI session is ended at genclass.dev, and ${tilde(path)} is deleted.`), 2);
4298
4410
  out();
4299
4411
  return 0;
4300
4412
  }
@@ -4310,7 +4422,8 @@ async function run2(cmd, argv) {
4310
4422
  if (o.app !== void 0 && o.name !== void 0) throw new UsageError("--app and --name contradict each other (use an app, or create one)");
4311
4423
  } catch (e) {
4312
4424
  if (e instanceof UsageError) {
4313
- err(HOST_CLI ? `${SELF2} ${cmd}: ${e.message}. Every command and option: ${CMD} help` : `${SELF2} ${cmd}: ${e.message}
4425
+ if (HOST_CLI) for (const l of wrapTo(`${SELF2} ${cmd}: ${e.message}. Every command and option: ${CMD} help`, columns() - 2)) err(l);
4426
+ else err(`${SELF2} ${cmd}: ${e.message}
4314
4427
 
4315
4428
  ${usage2()}`);
4316
4429
  return 2;
@@ -4318,7 +4431,7 @@ ${usage2()}`);
4318
4431
  throw e;
4319
4432
  }
4320
4433
  if (o.help) {
4321
- if (HOST_CLI) more(`${CMD} ${cmd}: ${HOST_HELP[cmd] ?? ""} Every command and option: ${CMD} help`, 2);
4434
+ if (HOST_CLI) more(`${CMD} ${cmd}: ${HOST_HELP[cmd] ?? ""} All commands: ${CMD} help`, 2);
4322
4435
  else out(usage2());
4323
4436
  return 0;
4324
4437
  }
@@ -4674,7 +4787,10 @@ async function readState(o = {}, deps = {}) {
4674
4787
  state: me ? "done" : creds && offline && offline !== "expired" ? "done" : "todo",
4675
4788
  detail: me ? `${accountLabel(me.account)}${me.plan ? ` \xB7 ${me.plan.name} plan` : ""}` : creds && offline === "expired" ? "the saved session expired: sign in again" : creds && offline ? `${accountLabel(creds.account)} (not checked: ${offline})` : otherHost ? `the saved session is for ${otherHost}` : "",
4676
4789
  // said before anyone signs up: the command is Pro's, with its trial and price (the owner's call, 2026-11-13)
4677
- why: "Opens genclass.dev. Then Pro: 3 days free, then $15 / developer / month, with a card on Stripe.",
4790
+ // the host the sign-in opens (genclass.dev, or GENCLASS_HOST in a test)
4791
+ // someone signing in again (a saved session, or an app set up in this folder) already has an account and maybe
4792
+ // Pro: the price is said only to someone new (the 0.3.9 user stories: it was quoted to a payer after logout)
4793
+ why: creds || st.token ? `Opens ${host.overridden && !host.error ? new URL(host.host).host : "genclass.dev"} to sign you in again.` : `Opens ${host.overridden && !host.error ? new URL(host.host).host : "genclass.dev"}. Then Pro: 3 days free, then $15 / developer / month, with a card on Stripe.`,
4678
4794
  more: `Your account is where your apps, their dashboards and your plan live. New here? It is made on that page. Nothing is typed in the terminal. ${PRO_TERMS} Free stays on the website: one app and its totals.`,
4679
4795
  run: "npx genclass login",
4680
4796
  human: "approve the sign-in in your browser"
@@ -4685,7 +4801,7 @@ async function readState(o = {}, deps = {}) {
4685
4801
  title: "Pro",
4686
4802
  doing: cli && !cli.paid ? cli.trialDays ? `Start your ${cli.trialDays}-day free trial` : `Start ${cli.plan}` : "Pro",
4687
4803
  state: !me ? creds && offline !== "expired" ? "optional" : "todo" : !cli ? "optional" : cli.paid ? "done" : "todo",
4688
- detail: !me ? creds ? "" : "3 days free, then $15 / developer / month" : cli && !cli.paid ? `${cli.price ?? cli.plan}${cli.trialDays ? `, ${cli.trialDays} days free` : ""}` : cli?.paid && cli.via === "team" ? "through your team's plan" : cli?.paid && cli.via === "open" ? "open on this genclass.dev" : me.plan && me.plan.id !== "free" ? me.plan.name : "",
4804
+ detail: !me ? creds || st.token ? "" : "3 days free, then $15 / developer / month" : cli && !cli.paid ? `${cli.price ?? cli.plan}${cli.trialDays ? `, ${cli.trialDays} days free` : ""}` : cli?.paid && cli.via === "team" ? "through your team's plan" : cli?.paid && cli.via === "open" ? "open on this genclass.dev" : me.plan && me.plan.id !== "free" && me.plan.name !== "Pro" ? me.plan.name : "",
4689
4805
  why: cli && !cli.paid ? `Every genclass command comes with ${cli.plan}${cli.trialDays ? `, ${cli.trialDays} days free to start` : ""}.` : me ? "Every genclass command comes with Pro." : PRO_TERMS,
4690
4806
  more: `${cli && !cli.paid && cli.trialDays ? `The trial opens in your browser and the card is asked for there, on Stripe: nothing is charged if you cancel before the ${cli.trialDays} days end. ` : "Pro opens in your browser and is paid there, on Stripe. "}Free stays on the website: one app and its totals. Plans and prices: genclass.dev/pricing.`,
4691
4807
  run: "npx genclass upgrade",
@@ -4717,11 +4833,12 @@ async function readState(o = {}, deps = {}) {
4717
4833
  id: "app-plan",
4718
4834
  title: "App plan",
4719
4835
  doing: appOffer?.current ? `Continue with ${appOffer.current} for this app` : "Choose this app's plan",
4720
- state: appOffer ? "todo" : "optional",
4721
- // an app the account's plan already covers (paid, or GenClass's grant) waits on nothing: its page's Continue is
4722
- // offered once, never required, so a setup with --yes or a coding agent still ends complete
4836
+ // an app the account's plan already covers (paid, in its trial, GenClass's grant) has its plan: the step is done,
4837
+ // so no page opens and nothing waits (the 0.3.9 user stories: a third browser page right after paying, and a
4838
+ // setup that stopped there). Its plan page stays one link away, in the detail
4839
+ state: appOffer ? appOffer.current && !appOffer.needs ? "done" : "todo" : app?.plan?.source && !app.needsPlan && !app.shared ? "done" : "optional",
4723
4840
  blocking: !(appOffer?.current && !appOffer.needs),
4724
- detail: !me || !app?.plan ? app?.shared ? "the team's owner chooses it" : "" : appOffer ? appOffer.needs ? appOffer.paying ? `${appOffer.current ?? "Your plan"} covers no more apps` : `Free covers ${appOffer.free.apps === 1 ? "one app" : `${appOffer.free.apps ?? 1} apps`}: this one needs ${appOffer.plan.name}` : appOffer.current ? `covered by ${appOffer.current}: continue on its plan page` : `${appOffer.plan.name}, ${appOffer.price}` : `${app.plan.name}${app.plan.source === "comp" ? " (set up by GenClass)" : ""}`,
4841
+ detail: !me || !app?.plan ? app?.shared ? "the team's owner chooses it" : "" : appOffer ? appOffer.needs ? appOffer.paying ? `${appOffer.current ?? "Your plan"} covers no more apps` : `Free covers ${appOffer.free.apps === 1 ? "one app" : `${appOffer.free.apps ?? 1} apps`}: this one needs ${appOffer.plan.name}` : appOffer.current ? `covered by ${appOffer.current}` : `${appOffer.plan.name}, ${appOffer.price}` : `${app.plan.name}${app.plan.source === "comp" ? " (set up by GenClass)" : ""}`,
4725
4842
  why: appOffer?.needs && appOffer.paying ? "Your plan covers no more apps. More apps come with Enterprise, by email." : appOffer?.current ? `Every new app has its plan page once. ${appOffer.current} covers this one: continue with it there.` : "This app's plan, on its page in your browser.",
4726
4843
  more: "Every app has its plan page: genclass.dev/account/billing. Plans and prices: genclass.dev/pricing.",
4727
4844
  run: "npx genclass setup",
@@ -4847,13 +4964,15 @@ function appPlanOffer(app, accountOffer, paying) {
4847
4964
  return { ...base2, checkoutUrl: `${app.planUrl}&from=cli`, project: { id: app.id, name: app.name, token: app.token }, needs: app.needsPlan === true, current: covered ? app.plan.name : null, paying: !!paying, chosen: app.planChosen === true };
4848
4965
  }
4849
4966
  function stateJson(s) {
4967
+ const agentNext = s.next && s.next.blocking === false ? s.steps.find((x) => x !== s.next && x.state === "todo" && x.blocking !== false) ?? null : s.next;
4850
4968
  return {
4851
4969
  app: s.app,
4852
4970
  signed_in: s.signedIn,
4853
4971
  account: s.account ? { label: s.account.label, plan: s.account.plan } : null,
4854
4972
  github: s.git.github,
4855
- steps: s.steps.map((x) => ({ id: x.id, title: x.title, state: x.state, detail: x.detail, run: x.state === "done" ? null : forAgent(x.run), human: x.state === "done" ? null : x.human })),
4856
- next: s.next ? { id: s.next.id, title: s.next.doing, run: forAgent(s.next.run), human: s.next.human, why: s.next.why } : null,
4973
+ // a step that does not apply here (optional: no git repository, no tests) has nothing for an agent to run
4974
+ steps: s.steps.map((x) => ({ id: x.id, title: x.title, state: x.blocking === false && x.state !== "done" ? "optional" : x.state, detail: x.detail, run: x.state === "done" || x.state === "optional" || x.blocking === false ? null : forAgent(x.run), human: x.state === "done" || x.state === "optional" ? null : x.human })),
4975
+ next: agentNext ? { id: agentNext.id, title: agentNext.doing, run: forAgent(agentNext.run), human: agentNext.human, why: agentNext.why } : null,
4857
4976
  complete: s.complete
4858
4977
  };
4859
4978
  }
@@ -4882,7 +5001,7 @@ var init_state = __esm({
4882
5001
  NOT_APPS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "coverage", "vendor", "tmp", "target"]);
4883
5002
  accountPaid = (me) => !!me && (me.cli ? me.cli.paid : !!me.plan && me.plan.id !== "free");
4884
5003
  planName = (state, token = state?.app?.token) => (state?.projects ?? []).find((p) => p.token === token && p.plan)?.plan?.name ?? state?.account?.plan?.name ?? null;
4885
- forAgent = (run5) => run5 === "npx genclass setup" ? "npx genclass setup --yes" : run5;
5004
+ forAgent = (run5) => ["npx genclass setup", "npx genclass init", "npx genclass connect"].includes(run5) ? "npx genclass setup --yes" : run5;
4886
5005
  }
4887
5006
  });
4888
5007
 
@@ -4965,7 +5084,7 @@ async function signIn(o = {}) {
4965
5084
  async function choosePlan(state, o = {}, deps = {}) {
4966
5085
  const cli = state.steps.find((s) => s.id === "plan")?.cli;
4967
5086
  if (!cli || cli.paid) return "skipped";
4968
- return await (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).startPro(cli, state.account?.offer ?? null, o, deps) ? "done" : "quit";
5087
+ return await (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).startPro(cli, state.account?.offer ?? null, { ...o, again: "Setup goes on with Pro." }, deps) ? "done" : "quit";
4969
5088
  }
4970
5089
  async function chooseAppPlan(state, o = {}, deps = {}) {
4971
5090
  const offer = state.steps.find((s) => s.id === "app-plan")?.offer;
@@ -4998,6 +5117,13 @@ async function planNow(o = {}, deps = {}, id = null) {
4998
5117
  return "locked";
4999
5118
  }
5000
5119
  if (o.json) return offer.current ? "covered" : "open";
5120
+ if (offer.current && !offer.needs) {
5121
+ if (o.announce) {
5122
+ out();
5123
+ note(`${clean(app.name, 40)} is on your ${clean(offer.current, 20)} plan.`);
5124
+ }
5125
+ return "covered";
5126
+ }
5001
5127
  if (o.yes || !interactive()) {
5002
5128
  out();
5003
5129
  note(offer.current ? `${clean(app.name, 40)} is covered by your ${clean(offer.current, 20)} plan. Continue with it once on its plan page: ${offer.checkoutUrl}` : `${clean(app.name, 40)} has no plan yet. Choose it in the browser: ${offer.checkoutUrl}`);
@@ -5061,7 +5187,7 @@ async function waitForPlan(offer, o = {}, deps = {}) {
5061
5187
  if (got === "kept") sp.stop("ok", `${app} goes on with ${clean(offer.current, 20)}.`);
5062
5188
  else if (got === "paid") sp.stop("ok", `${offer.plan.name} is active${app ? ` for ${app}` : ""}. Thank you.`);
5063
5189
  else if (got === "free") sp.stop("ok", `${app} is on ${offer.free.name} for now (limited).`);
5064
- else sp.stop("warn", app && !offer.needs ? "No choice yet." : `No payment yet. ${offer.plan.name} starts once it is started on Stripe.`);
5190
+ else sp.stop("warn", app && !offer.needs ? "No choice yet." : `No payment yet: ${clean(offer.plan.name, 20)} is not started.`);
5065
5191
  return got;
5066
5192
  }
5067
5193
  function runtimeArgs(state, o = {}) {
@@ -5127,7 +5253,7 @@ async function addViteSettings(state, o = {}) {
5127
5253
  note('Without them "vite build" fails.');
5128
5254
  out();
5129
5255
  printChange(plan2.change);
5130
- if (!o.yes) {
5256
+ if (!o.yes && !o.confirmed) {
5131
5257
  if (!interactive()) {
5132
5258
  note(`Not a terminal: run ${c.cyan("npx genclass setup --yes")} to write them.`);
5133
5259
  return "skipped";
@@ -5213,7 +5339,9 @@ async function addWorkflow(state, o = {}) {
5213
5339
  }
5214
5340
  good(`Wrote ${c.bold(WORKFLOW_PATH)} ${c.gray(`(new file, ${text.split("\n").length - 1} lines)`)}`);
5215
5341
  note("It is not committed. When you are ready:");
5216
- out(` ${c.cyan(`git add ${WORKFLOW_PATH} && git commit -m "Add GenClass to pull requests" && git push`)}`);
5342
+ out(` ${c.cyan(`git add ${WORKFLOW_PATH}`)}`);
5343
+ out(` ${c.cyan('git commit -m "Add GenClass to pull requests"')}`);
5344
+ out(` ${c.cyan("git push")}`);
5217
5345
  return "done";
5218
5346
  }
5219
5347
  async function waitForGithub(creds, repo, text, until, seconds) {
@@ -5335,8 +5463,10 @@ async function connectAgent(state, o = {}) {
5335
5463
  if (!o.yes) {
5336
5464
  out();
5337
5465
  printChange(plan2.change);
5338
- out(` ${c.gray(`And ${SKILL_PATH}: how the agent uses GenClass's tools (a file you changed is left alone).`)}`);
5466
+ note(`And ${SKILL_PATH}: how the agent uses GenClass's tools (a file you changed is left alone).`);
5339
5467
  out();
5468
+ }
5469
+ if (!o.yes && !o.confirmed) {
5340
5470
  if (!interactive()) {
5341
5471
  note(`Not a terminal: run ${c.cyan("npx genclass setup --yes")} to write it.`);
5342
5472
  return "skipped";
@@ -5400,7 +5530,9 @@ __export(paywall_exports, {
5400
5530
  proOffer: () => proOffer,
5401
5531
  proSeen: () => proSeen,
5402
5532
  requirePro: () => requirePro,
5403
- startPro: () => startPro
5533
+ resetRefused: () => resetRefused,
5534
+ startPro: () => startPro,
5535
+ wasRefused: () => wasRefused
5404
5536
  });
5405
5537
  function noteAccount(who) {
5406
5538
  const host = globalThis.__GENCLASS_CLI__;
@@ -5450,20 +5582,29 @@ async function startPro(cli, offer, o = {}, deps = {}) {
5450
5582
  }
5451
5583
  return false;
5452
5584
  }
5585
+ const start = cli.trialDays ? `start your ${cli.trialDays}-day free trial` : `start ${clean(cli.plan, 20)}`;
5586
+ if (cardShown && (o.short || o.again)) {
5587
+ out();
5588
+ note(`${o.again ?? `That comes with ${clean(cli.plan, 20)}.`} ${homeOpen() ? "Type upgrade" : "Run npx genclass upgrade"} to ${start}.`);
5589
+ refused2 = true;
5590
+ return false;
5591
+ }
5592
+ cardShown = true;
5453
5593
  if (o.account) {
5454
5594
  out();
5455
5595
  note(`For ${clean(o.account, 60)}`);
5456
5596
  }
5457
5597
  planCard(card2, null, heading);
5458
5598
  note(
5459
- cli.trialDays ? `Every genclass command comes with ${clean(cli.plan, 20)}. ${cli.trialDays} days free, then ${clean(card2.price, 40)}: your card is asked for on Stripe, and nothing is charged if you cancel before the trial ends.` : `Every genclass command comes with ${clean(cli.plan, 20)}, ${clean(card2.price, 40)}, paid on Stripe.`
5599
+ cli.trialDays ? `Every genclass command comes with ${clean(cli.plan, 20)}. Your card is asked for on Stripe, and nothing is charged if you cancel before the trial ends.` : `Every genclass command comes with ${clean(cli.plan, 20)}, paid on Stripe.`
5460
5600
  );
5461
5601
  out();
5462
5602
  const dot = c.gray("\xB7");
5463
5603
  const a = await typed(` ${PROMPT()} ${c.bold("Enter")} ${c.gray(cli.trialDays ? "to start the free trial" : `to start ${clean(cli.plan, 20)}`)} ${dot} ${c.bold("q")} ${c.gray("stop")} `);
5464
5604
  if (a === null || !/^(y|yes)?$/i.test(a.trim())) {
5465
5605
  out();
5466
- note(proLine(cli));
5606
+ note(`Not started. ${homeOpen() ? "Type upgrade" : "Run npx genclass upgrade"} any time to ${start}.`);
5607
+ refused2 = true;
5467
5608
  return false;
5468
5609
  }
5469
5610
  const { checkout: checkout2 } = await Promise.resolve().then(() => (init_actions(), actions_exports));
@@ -5474,6 +5615,7 @@ async function startPro(cli, offer, o = {}, deps = {}) {
5474
5615
  return false;
5475
5616
  }
5476
5617
  async function requirePro(o = {}, deps = {}) {
5618
+ refused2 = false;
5477
5619
  if (seen) return 0;
5478
5620
  let creds = readCredentials();
5479
5621
  if (!creds) {
@@ -5498,11 +5640,12 @@ async function requirePro(o = {}, deps = {}) {
5498
5640
  if (me.ok && me.cli?.paid) seen = true;
5499
5641
  return 0;
5500
5642
  }
5501
- if (await startPro(me.cli, me.offer ?? null, { ...o, account: accountLabel(me.account) }, deps)) {
5643
+ if (await startPro(me.cli, me.offer ?? null, { ...o, account: accountLabel(me.account), short: true }, deps)) {
5502
5644
  seen = true;
5503
5645
  out();
5504
5646
  return 0;
5505
5647
  }
5648
+ refused2 = true;
5506
5649
  return 1;
5507
5650
  }
5508
5651
  async function afterLogin2(o = {}, deps = {}) {
@@ -5522,7 +5665,7 @@ async function afterLogin2(o = {}, deps = {}) {
5522
5665
  }
5523
5666
  return false;
5524
5667
  }
5525
- var seen, forgetPro, proSeen;
5668
+ var seen, cardShown, refused2, forgetPro, wasRefused, resetRefused, proSeen;
5526
5669
  var init_paywall = __esm({
5527
5670
  "src/paywall.mjs"() {
5528
5671
  init_define_GENCLASS_BUILD();
@@ -5532,8 +5675,16 @@ var init_paywall = __esm({
5532
5675
  init_api();
5533
5676
  init_tui();
5534
5677
  seen = false;
5678
+ cardShown = false;
5679
+ refused2 = false;
5535
5680
  forgetPro = () => {
5536
5681
  seen = false;
5682
+ cardShown = false;
5683
+ refused2 = false;
5684
+ };
5685
+ wasRefused = () => refused2;
5686
+ resetRefused = () => {
5687
+ refused2 = false;
5537
5688
  };
5538
5689
  proSeen = () => seen;
5539
5690
  }
@@ -5543,7 +5694,7 @@ var init_paywall = __esm({
5543
5694
  var session_exports = {};
5544
5695
  __export(session_exports, {
5545
5696
  asking: () => asking,
5546
- refused: () => refused2
5697
+ refused: () => refused3
5547
5698
  });
5548
5699
  async function asking(o, creds, call, deps = {}) {
5549
5700
  let r = await call(creds);
@@ -5558,7 +5709,7 @@ async function asking(o, creds, call, deps = {}) {
5558
5709
  }
5559
5710
  return r;
5560
5711
  }
5561
- function refused2(r, ctx) {
5712
+ function refused3(r, ctx) {
5562
5713
  if (r.needsPro) {
5563
5714
  if (ctx.json) out(JSON.stringify(needsProJson(r.needsPro)));
5564
5715
  else {
@@ -5580,7 +5731,7 @@ function refused2(r, ctx) {
5580
5731
  proBox(`${ctx.what} comes with ${clean(lock.plan ?? ctx.plan ?? "Pro", 20)}.`, { ...lock, upgradeUrl: lock.upgradeUrl ?? r.upgradeUrl });
5581
5732
  } else if (r.missing) note("This genclass.dev cannot do this from the terminal yet.");
5582
5733
  else bad(`${ctx.what}: ${clean(r.reason ?? "it did not work", 240)}`);
5583
- if (ctx.browserUrl && !r.upgradeUrl) out(` ${c.gray("In the browser")} ${c.cyan(ctx.browserUrl)}`);
5734
+ if (ctx.browserUrl && !r.upgradeUrl) linkLine("In the browser", ctx.browserUrl);
5584
5735
  out();
5585
5736
  return 1;
5586
5737
  }
@@ -5699,7 +5850,7 @@ function render(app, state, o = {}) {
5699
5850
  const sg = state?.steps?.find((s) => s.id === "suggestions");
5700
5851
  if (sg) part2("Suggestions", sg.detail ? sg.state === "done" ? clean(sg.detail, 60) : `${clean(sg.detail, 60)}${c.gray(" \xB7 npx genclass suggest")}` : c.gray("not run yet: npx genclass suggest"));
5701
5852
  out();
5702
- if (app.dashboardUrl) out(` ${c.gray("In the browser")} ${c.cyan(app.dashboardUrl)}`);
5853
+ if (app.dashboardUrl) linkLine("In the browser", app.dashboardUrl);
5703
5854
  if (!all) out(` ${c.gray("Every row:")} ${c.cyan("npx genclass dashboard --all")}`);
5704
5855
  out();
5705
5856
  }
@@ -5734,11 +5885,12 @@ async function pickApp(o = {}, deps = {}, name = "dashboard") {
5734
5885
  const { creds } = readCredentialsFor();
5735
5886
  const projects = state.projects;
5736
5887
  const byId = o.app ? projects.filter((p) => p.id === o.app) : [];
5737
- const wanted = byId.length ? byId : o.app ? projects.filter((p) => p.name.toLowerCase() === String(o.app).toLowerCase()) : state.app.token ? projects.filter((p) => p.token === state.app.token) : projects.length === 1 ? projects : [];
5888
+ const unsetHere = !state.app.token && state.app.isApp && !o.json && !o.yes && interactive();
5889
+ const wanted = byId.length ? byId : o.app ? projects.filter((p) => p.name.toLowerCase() === String(o.app).toLowerCase()) : state.app.token ? projects.filter((p) => p.token === state.app.token) : projects.length === 1 && !unsetHere ? projects : [];
5738
5890
  if (wanted.length !== 1 && projects.length && !o.json && !o.yes && interactive()) {
5739
5891
  const list2 = (wanted.length > 1 ? wanted : projects).slice(0, 30);
5740
5892
  header({ app: state.app.name, framework: state.app.framework, account: state.account?.label, plan: planName(state), host: state.host });
5741
- note(wanted.length > 1 ? `More than one app is named "${clean(o.app, 40)}". Which one?` : o.app ? `No app named "${clean(o.app, 40)}". Which one?` : state.app.token ? "This folder's app is not in your account yet. Which app?" : "Which app?");
5893
+ note(wanted.length > 1 ? `More than one app is named "${clean(o.app, 40)}". Which one?` : o.app ? `No app named "${clean(o.app, 40)}". Which one?` : state.app.token ? "This folder's app is not in your account yet. Which app?" : unsetHere ? `GenClass is not in this folder's app yet: ${hint("setup")} to add it. Which app do you want to see?` : "Which app?");
5742
5894
  list2.forEach((p, i2) => out(` ${c.gray(String(i2 + 1).padStart(2))} ${c.bold(clean(appLabel(p, projects), 34))}${p.last_event ? c.gray(` last page ${ago(p.last_event, deps.now)}`) : ""}`));
5743
5895
  out();
5744
5896
  const a = await typed(` ${PROMPT()} ${c.gray("a number \xB7")} ${c.bold("q")} ${c.gray("stop")} `);
@@ -5805,7 +5957,7 @@ async function appView(o = {}, deps = {}, view) {
5805
5957
  if (app.reauth) warn(`This sign-in is from before the command could show dashboards. Run ${c.cyan("npx genclass login")} once, then ${c.cyan(`npx genclass ${view.name}`)}.`);
5806
5958
  else if (app.missing) note("This genclass.dev cannot show a dashboard in the terminal yet.");
5807
5959
  else bad(`Could not read the dashboard: ${clean(app.reason, 200)}`);
5808
- if (target.dashboard_url) out(` ${c.gray("In the browser")} ${c.cyan(target.dashboard_url)}`);
5960
+ if (target.dashboard_url) linkLine("In the browser", target.dashboard_url);
5809
5961
  else out(` ${c.gray("Your apps")} ${c.cyan(hostUrl("/account"))}`);
5810
5962
  out();
5811
5963
  }
@@ -7153,7 +7305,7 @@ function renderAnalytics(app, o = {}) {
7153
7305
  out(` ${c.gray("One part:")} ${c.cyan("npx genclass analytics pages")}`);
7154
7306
  out(` ${c.gray(`also ${ANALYTICS_SECTIONS.slice(1).join(", ")}`)}`);
7155
7307
  }
7156
- if (app.dashboardUrl) out(` ${c.gray("In the browser")} ${c.cyan(app.dashboardUrl)}`);
7308
+ if (app.dashboardUrl) linkLine("In the browser", app.dashboardUrl);
7157
7309
  out();
7158
7310
  }
7159
7311
  function analytics(o = {}, deps = {}) {
@@ -7256,13 +7408,14 @@ function renderEvents(app, o = {}) {
7256
7408
  }
7257
7409
  const short2 = (iso) => ago(iso, o.now).replace(/ minutes? ago/, " min ago").replace(/ hours? ago/, " h ago");
7258
7410
  const wWhen = Math.max(...rows2.map((r) => short2(r.at).length));
7259
- const wKind = Math.max(4, Math.min(14, Math.max(...rows2.map((r) => plain(r.kind ?? r.trigger ?? "").length))));
7411
+ const kindName = (r) => r.kind && TYPES[r.kind]?.name || plain(r.kind ?? r.trigger ?? "");
7412
+ const wKind = Math.max(4, Math.min(18, Math.max(...rows2.map((r) => kindName(r).length))));
7260
7413
  const wPage = Math.max(8, room() - 14 - wWhen - wKind);
7261
7414
  head(`The latest ${rows2.length} event${rows2.length === 1 ? "" : "s"}`, "Newest first. sure: how confident the model was.");
7262
7415
  out(` ${c.gray("when".padEnd(wWhen))} ${c.gray("kind".padEnd(wKind))} ${c.gray("sure")} ${c.gray("page")}`);
7263
7416
  for (const r of rows2) {
7264
7417
  const sure = r.confidence === null ? "" : `${Math.round(r.confidence * 100)}%`;
7265
- out(` ${c.gray(short2(r.at).padEnd(wWhen))} ${clean(plain(r.kind ?? r.trigger ?? ""), wKind).padEnd(wKind)} ${sure.padStart(4)} ${c.cyan(clean(r.route ?? "", wPage))}`.trimEnd());
7418
+ out(` ${c.gray(short2(r.at).padEnd(wWhen))} ${clean(kindName(r), wKind).padEnd(wKind)} ${sure.padStart(4)} ${c.cyan(clean(r.route ?? "", wPage))}`.trimEnd());
7266
7419
  const did = didAct(r) ? actionWords(r.ran) : null;
7267
7420
  if (did) out(` ${" ".repeat(wWhen)} ${c.green(`${sym.arrow} ${clean(did, 60)}`)}`);
7268
7421
  if (all) {
@@ -7466,10 +7619,10 @@ var init_views = __esm({
7466
7619
  return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, "0")}s`;
7467
7620
  };
7468
7621
  cell = (label, value) => `${c.gray(label.padEnd(15))}${c.bold(String(value).padEnd(9))}`;
7469
- head = (title, hint = "") => {
7622
+ head = (title, hint2 = "") => {
7470
7623
  out();
7471
7624
  out(` ${c.bold(title)}`);
7472
- if (hint) for (const l of wrap2(hint, room() - 4)) out(` ${c.gray(l)}`);
7625
+ if (hint2) for (const l of wrap2(hint2, room() - 4)) out(` ${c.gray(l)}`);
7473
7626
  };
7474
7627
  part = (label, text, w = 18) => {
7475
7628
  const [first = "", ...rest] = wrap2(text, room() - 2 - w);
@@ -7595,7 +7748,9 @@ function listProblems(list2, shown) {
7595
7748
  const info = infoOf(x);
7596
7749
  out(` ${c.cyan(String(i + 1).padStart(wNum))} ${c.bold(clean(info.name, 40))} ${c.gray(`${n(x.count)} time${x.count === 1 ? "" : "s"}${x.check ? ", visual check" : ""}`)}`);
7597
7750
  const pages = x.where.slice(0, 3).map((w) => clean(w.route, 40)).join(", ");
7598
- if (pages) for (const l of wrap2(`on ${pages}`, width() - 2 - 6 - wNum)) out(` ${" ".repeat(wNum + 2)}${c.gray(l)}`);
7751
+ const plain2 = KINDS[x.key];
7752
+ const under = [plain2, pages && `on ${pages}`].filter(Boolean).join(", ");
7753
+ if (under) for (const l of wrap2(under, width() - 2 - 6 - wNum)) out(` ${" ".repeat(wNum + 2)}${c.gray(l)}`);
7599
7754
  });
7600
7755
  if (list2.length > shown) out(` ${c.gray(`and ${n(list2.length - shown)} more: add --all`)}`);
7601
7756
  }
@@ -9950,8 +10105,9 @@ ${prompt}
9950
10105
  choices.forEach(([label], i) => out(` ${c.gray(String(i + 1).padStart(2))} ${label}`));
9951
10106
  if (!agents.length) note("No coding agent's command found here (claude, codex, cursor-agent, gemini).");
9952
10107
  out();
9953
- const a = await typed(` ${PROMPT()} ${c.gray("a number \xB7")} ${c.bold("q")} ${c.gray("stop")} `);
9954
- const pick2 = a !== null && /^\d+$/.test(a.trim()) ? choices[Number(a.trim()) - 1] : null;
10108
+ const a = await typed(` ${PROMPT()} ${c.bold("Enter")} ${c.gray("for 1 \xB7 a number \xB7")} ${c.bold("q")} ${c.gray("stop")} `);
10109
+ const t = a === null ? null : a.trim();
10110
+ const pick2 = t === "" ? choices[0] : t !== null && /^\d+$/.test(t) ? choices[Number(t) - 1] : null;
9955
10111
  if (pick2) await pick2[1]();
9956
10112
  }
9957
10113
  async function suggest(o = {}, deps = {}) {
@@ -10044,11 +10200,11 @@ async function suggest(o = {}, deps = {}) {
10044
10200
  out(` ${c.bold(`${passed.length} of ${total} checks pass.`)} ${failed.length ? `${failed.length} to do${failed.some((r) => r.weight >= 5) ? `, ${failed.filter((r) => r.weight >= 5).length} of them urgent` : ""}.` : c.green("Nothing to do.")}`);
10045
10201
  if (planNote) note(planNote);
10046
10202
  if (!site?.reachable) note(url ? "The site could not be read, so only the repository was checked." : `Only the repository was checked. With the site's address there is more: ${c.cyan("npx genclass suggest https://your-site.com")}`);
10047
- const fullCount = o.all ? items.length : 5;
10203
+ const fullCount = o.all ? items.length : o.fromSetup ? 1 : 5;
10048
10204
  for (const i of items.filter((x) => x.open)) printItem(i, i.n <= fullCount);
10049
10205
  if (items.some((i) => i.open && i.n > fullCount)) {
10050
10206
  out();
10051
- note(`Items ${fullCount + 1} and after are listed by title. ${c.cyan("npx genclass suggest --all")} prints each one's reason, first step and prompt.`);
10207
+ note(o.fromSetup ? `The others in full, with a prompt for each: ${hint("suggest")}.` : `Items ${fullCount + 1} and after are listed by title. ${c.cyan("npx genclass suggest --all")} prints each one's reason, first step and prompt.`);
10052
10208
  }
10053
10209
  if (plan2?.ideas?.length) printIdeas(plan2.ideas, o.all);
10054
10210
  if (plan2?.designs?.length) printDesigns(plan2.designs);
@@ -10122,9 +10278,19 @@ __export(manage_exports, {
10122
10278
  import { writeFileSync as writeFileSync9 } from "node:fs";
10123
10279
  import { resolve as resolve10 } from "node:path";
10124
10280
  async function signedIn(o, deps, name) {
10125
- const state = await readState({ cwd: o.cwd }, deps);
10126
- const { creds } = readCredentialsFor();
10281
+ let state = await readState({ cwd: o.cwd }, deps);
10282
+ let { creds } = readCredentialsFor();
10127
10283
  if (state.signedIn && creds) return { state, creds };
10284
+ if (!o.json && !o.yes && interactive() && !(state.sessionProblem && state.sessionProblem !== "expired")) {
10285
+ out();
10286
+ note("Sign in to genclass.dev first.");
10287
+ if (await (deps.signIn ?? signIn)(o) === "done") {
10288
+ state = await readState({ cwd: o.cwd }, deps);
10289
+ creds = readCredentialsFor().creds;
10290
+ if (state.signedIn && creds) return { state, creds };
10291
+ }
10292
+ return { code: 1 };
10293
+ }
10128
10294
  if (o.json) out(JSON.stringify({ ok: false, error: "not signed in", run: "npx genclass login" }));
10129
10295
  else {
10130
10296
  header({ app: state.app.name, framework: state.app.framework, host: state.host });
@@ -10170,7 +10336,7 @@ async function apps(o = {}, deps = {}) {
10170
10336
  out(` ${c.gray("On Free (limited). Its plan:")}`);
10171
10337
  out(` ${c.cyan(made.planUrl)}`);
10172
10338
  }
10173
- if (made?.id && !full) await planNow({ cwd: o.cwd, noBrowser: o.noBrowser }, deps, made.id);
10339
+ if (made?.id && !full) await planNow({ cwd: o.cwd, noBrowser: o.noBrowser, announce: true }, deps, made.id);
10174
10340
  note("To put GenClass into that app's code, run npx genclass in its folder and pick this app.");
10175
10341
  }
10176
10342
  out();
@@ -10218,7 +10384,9 @@ async function plan(o = {}, deps = {}) {
10218
10384
  const apps2 = mine.map((p) => ({ id: p.id, name: p.name, plan: p.plan, needs_plan: p.needsPlan, plan_url: p.planUrl, this_folder: p.token === state.app?.token }));
10219
10385
  const command = cli ? { paid: cli.paid, ...cli.paid && cli.via ? { via: cli.via } : {}, ...pro ? { checkout_url: pro.checkoutUrl, trial_days: pro.trialDays, price: pro.price } : {} } : null;
10220
10386
  const limits = a.ok && pro ? { ...a.limits, suggestionsPerDay: 0 } : a.ok ? a.limits : null;
10221
- out(JSON.stringify(a.ok ? { ok: true, plan: a.plan, access: a.access, team_plan: a.teamPlan ?? null, limits, used: a.used, includes: a.includes, subscription: a.subscription, billing_url: a.billingUrl, offer: offer ?? (pro ? a.offer : null), cli: command, apps: apps2 } : { ok: true, plan: state.account?.plan ?? null, billing_url: state.account?.billingUrl ?? null, offer, cli: command, partial: a.reauth ? "sign in again for the limits: npx genclass login" : "this genclass.dev says no more" }, null, 2));
10387
+ const member = a.ok && a.teamPlan && a.teamPlan.id !== a.plan.id ? a.teamPlan : null;
10388
+ const shown = member ? { plan: { id: member.id, name: member.name, via: "team", source: member.source, owner: member.owner }, limits: { ...limits, apps: member.apps, historyDays: member.historyDays, seats: null }, includes: member.includes ?? a.includes } : a.ok ? { plan: a.plan, limits, includes: a.includes } : {};
10389
+ out(JSON.stringify(a.ok ? { ok: true, plan: shown.plan, ...member ? { own_plan: a.plan } : {}, access: a.access, team_plan: a.teamPlan ?? null, limits: shown.limits, used: a.used, includes: shown.includes, subscription: a.subscription, billing_url: a.billingUrl, offer: offer ?? (pro ? a.offer : null), cli: command, apps: apps2 } : { ok: true, plan: state.account?.plan ?? null, billing_url: state.account?.billingUrl ?? null, offer, cli: command, partial: a.reauth ? "sign in again for the limits: npx genclass login" : "this genclass.dev says no more" }, null, 2));
10222
10390
  return 0;
10223
10391
  }
10224
10392
  top(state);
@@ -10263,13 +10431,13 @@ async function plan(o = {}, deps = {}) {
10263
10431
  }
10264
10432
  }
10265
10433
  if (pro) {
10266
- await (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).startPro(pro, state.account?.offer ?? (a.ok ? a.offer : null), { ...o, card: true }, deps);
10434
+ await (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).startPro(pro, state.account?.offer ?? (a.ok ? a.offer : null), { ...o, card: true, again: `${clean(pro.plan, 20)} has every genclass command.` }, deps);
10267
10435
  out();
10268
10436
  return 0;
10269
10437
  }
10270
10438
  if (!offer) {
10271
10439
  out();
10272
- out(` ${c.gray("Billing, in the browser")} ${c.cyan(billingUrl)}`);
10440
+ linkLine("Billing, in the browser", billingUrl);
10273
10441
  out();
10274
10442
  return 0;
10275
10443
  }
@@ -10310,7 +10478,7 @@ async function freeLine(o = {}, deps = {}) {
10310
10478
  const price = clean((cli && !cli.paid ? cli.price : null) ?? offer?.price ?? "", 40);
10311
10479
  const days = cli && !cli.paid ? cli.trialDays : offer?.trialDays;
10312
10480
  const [first = "", ...rest] = wrap2(
10313
- cli && !cli.paid ? `You are on Free${lim ? ` (${lim})` : ""}, on the website. Every genclass command comes with ${name}, ${days ? `${days} days free, then ${price}` : price}. Start it: npx genclass upgrade` : `You are on Free, which has limits${lim ? ` (${lim})` : ""}. ${name} has everything, ${days ? `${days} days free, then ${price}` : `for ${price}`}. Upgrade now: npx genclass upgrade`,
10481
+ cli && !cli.paid ? `You are on Free${lim ? ` (${lim})` : ""}, on the website. Every genclass command comes with ${name}${days ? `, ${days} days free` : ""}: ${homeOpen() ? "type upgrade" : "npx genclass upgrade"}` : `You are on Free, which has limits${lim ? ` (${lim})` : ""}. ${name} has everything, ${days ? `${days} days free, then ${price}` : `for ${price}`}. Upgrade now: ${homeOpen() ? "type upgrade" : "npx genclass upgrade"}`,
10314
10482
  width() - 6
10315
10483
  );
10316
10484
  out();
@@ -10394,7 +10562,7 @@ async function profile(o = {}, deps = {}) {
10394
10562
  top(state);
10395
10563
  out(` ${c.bold("Profile")}`);
10396
10564
  row2("Signed in as", clean(state.account?.label ?? "", 60));
10397
- row2("Plan", onFree ? `Free ${c.gray(pro ? "(website only: the genclass command comes with Pro)" : "(limited)")}` : `${c.bold(clean(state.account?.plan?.name ?? "", 20))}${viaTeam ? c.gray(" on your team: a seat its owner pays for") : state.account?.plan?.source === "comp" ? c.gray(" set up by GenClass") : ""}`);
10565
+ row2("Plan", onFree ? `Free ${c.gray(pro ? "(website only: the genclass command comes with Pro)" : "(limited)")}` : `${c.bold(clean(state.account?.plan?.name ?? "", 20))}${viaTeam ? c.gray(state.account?.plan?.source === "comp" ? " on your team: set up by GenClass" : " on your team: a seat its owner pays for") : state.account?.plan?.source === "comp" ? c.gray(" set up by GenClass") : ""}`);
10398
10566
  if (mine.length) {
10399
10567
  out();
10400
10568
  out(` ${c.bold("Apps and their plans")}`);
@@ -10440,7 +10608,7 @@ async function team(o = {}, deps = {}) {
10440
10608
  else {
10441
10609
  top(state);
10442
10610
  warn("Invites come from the team's owner: ask them for a link.");
10443
- note("Your seat is on their team, and they add seats in Manage billing.");
10611
+ note(state.account?.plan?.source === "comp" ? "Your seat is on their team's plan, set up by GenClass." : "Your seat is on their team, and they add seats in Manage billing.");
10444
10612
  out();
10445
10613
  }
10446
10614
  return 1;
@@ -10456,7 +10624,7 @@ async function team(o = {}, deps = {}) {
10456
10624
  }
10457
10625
  if (!r.ok) {
10458
10626
  if (!o.json) top(state);
10459
- return refused2(r, { what: "A team", command: "team invite", browserUrl: billing, json: o.json });
10627
+ return refused3(r, { what: "A team", command: "team invite", browserUrl: billing, json: o.json });
10460
10628
  }
10461
10629
  if (o.json) out(JSON.stringify({ ok: true, url: r.url, expires: r.expires }));
10462
10630
  else {
@@ -10471,7 +10639,7 @@ async function team(o = {}, deps = {}) {
10471
10639
  const a = await asking(o, creds, (cr) => fetchAccount(cr, deps), deps);
10472
10640
  if (!a.ok) {
10473
10641
  if (!o.json) top(state);
10474
- return refused2(a, { what: "The team", command: "team", browserUrl: billing, json: o.json });
10642
+ return refused3(a, { what: "The team", command: "team", browserUrl: billing, json: o.json });
10475
10643
  }
10476
10644
  if (o.json) {
10477
10645
  out(JSON.stringify({ ok: true, plan: a.plan, ...a.team }, null, 2));
@@ -10483,9 +10651,10 @@ async function team(o = {}, deps = {}) {
10483
10651
  const tp = a.teamPlan;
10484
10652
  out(` ${c.bold("Team")} ${c.gray(`${clean(tp.name, 20)}, on ${clean(tp.owner ?? "your team's owner", 50)}'s team`)}`);
10485
10653
  for (const m of t.memberships) out(` ${clean(m.label, 50)} ${c.gray(`owner${m.active ? "" : ` ${sym.dot} your seat is not active`}`)}`);
10486
- out(` ${clean(state.account?.label ?? "you", 50)} ${c.gray("you, a seat the owner pays for")}`);
10654
+ const granted = tp.source === "comp";
10655
+ out(` ${clean(state.account?.label ?? "you", 50)} ${c.gray(granted ? "you, on a plan GenClass set up" : "you, a seat the owner pays for")}`);
10487
10656
  out();
10488
- note("The owner invites people and adds seats in Manage billing. Apps you add go into the team's account.");
10657
+ note(granted ? "The owner invites people. Apps you add go into the team's account." : "The owner invites people and adds seats in Manage billing. Apps you add go into the team's account.");
10489
10658
  out();
10490
10659
  return 0;
10491
10660
  }
@@ -10556,8 +10725,8 @@ async function connections(o = {}, deps = {}) {
10556
10725
  }
10557
10726
  top(state, target);
10558
10727
  const can = await asking(o, creds, (cr) => fetchConnections(cr, target.id, deps), deps);
10559
- if (!can.ok) return refused2(can, ctx("Sending alerts"));
10560
- if (!can.forwarding) return refused2({ ok: false, upgradeUrl: can.upgradeUrl ?? hostUrl("/account/billing") }, { ...ctx("Sending alerts"), plan: can.plan });
10728
+ if (!can.ok) return refused3(can, ctx("Sending alerts"));
10729
+ if (!can.forwarding) return refused3({ ok: false, upgradeUrl: can.upgradeUrl ?? hostUrl("/account/billing") }, { ...ctx("Sending alerts"), plan: can.plan });
10561
10730
  out(` ${c.bold(`Send ${clean(target.name, 40)}'s new problems to ${destName(kind)}`)}`);
10562
10731
  note("Each new likely problem is sent once per kind and page an hour. What you type next is not shown, goes to genclass.dev over HTTPS, is stored encrypted there, and is not kept on this machine.");
10563
10732
  for (const [field, label, hidden] of DESTINATIONS[kind][1]) {
@@ -10578,7 +10747,7 @@ async function connections(o = {}, deps = {}) {
10578
10747
  const sp = o.json ? null : spinner(how === "test" ? `Sending a test record to ${destName(kind)}` : "Saving");
10579
10748
  const r2 = await asking(o, creds, (cr) => changeConnection(cr, target.id, kind, how, fields, deps), deps);
10580
10749
  sp?.stop(null);
10581
- if (!r2.ok) return refused2(r2, { ...ctx(how === "test" ? `The test to ${destName(kind)}` : "Sending alerts"), plan: null });
10750
+ if (!r2.ok) return refused3(r2, { ...ctx(how === "test" ? `The test to ${destName(kind)}` : "Sending alerts"), plan: null });
10582
10751
  if (o.json) {
10583
10752
  out(JSON.stringify({ ok: true, kind, done: how, ...r2.summary ? { summary: r2.summary } : {}, ...r2.secret ? { secret: r2.secret } : {} }));
10584
10753
  return 0;
@@ -10604,7 +10773,7 @@ async function connections(o = {}, deps = {}) {
10604
10773
  const gh = here ? state.steps.find((x) => x.id === "github-app") : null;
10605
10774
  if (!r.ok && r.needsPro) {
10606
10775
  if (!o.json) top(state, target);
10607
- return refused2(r, { what: "Alerts", command: "connections", json: o.json });
10776
+ return refused3(r, { what: "Alerts", command: "connections", json: o.json });
10608
10777
  }
10609
10778
  if (o.json) {
10610
10779
  out(JSON.stringify({ ok: true, app: target.name, alerts: r.ok ? { in_plan: r.forwarding, destinations: r.list } : { error: r.reauth ? "sign in again" : r.reason }, private_link: r.ok ? r.privateLink : null, github_app: gh ? { state: gh.state, detail: gh.detail ?? null } : null, coding_agent: agentHere }, null, 2));
@@ -10682,7 +10851,7 @@ async function exportEvents(o = {}, deps = {}) {
10682
10851
  `);
10683
10852
  return 1;
10684
10853
  }
10685
- return refused2(r, { what: "The stored events as a file", command: ["export", o.from ? `--from ${o.from}` : "", o.to ? `--to ${o.to}` : "", o.format ? `--format ${o.format}` : "", o.out ? `--out ${o.out}` : ""].filter(Boolean).join(" "), browserUrl: target.dashboard_url, json: o.json });
10854
+ return refused3(r, { what: "The stored events as a file", command: ["export", o.from ? `--from ${o.from}` : "", o.to ? `--to ${o.to}` : "", o.format ? `--format ${o.format}` : "", o.out ? `--out ${o.out}` : ""].filter(Boolean).join(" "), browserUrl: target.dashboard_url, json: o.json });
10686
10855
  }
10687
10856
  parts.push(r.text);
10688
10857
  pages++;
@@ -10734,8 +10903,8 @@ async function funnels(o = {}, deps = {}) {
10734
10903
  const [sub, name, ...steps] = o.args ?? [];
10735
10904
  const app = await fetchApp(creds, target.id, "7d", deps);
10736
10905
  if (!o.json) top(state, target);
10737
- if (!app.ok) return refused2(app, { what: "The funnels", command: "funnels", browserUrl: target.dashboard_url, json: o.json });
10738
- if (app.visitorsPlan) return refused2({ ok: false, upgradeUrl: app.visitorsPlan.upgradeUrl ?? hostUrl("/account/billing") }, { what: "Funnels (part of visitor analytics)", command: "funnels", plan: app.visitorsPlan.plan, json: o.json });
10906
+ if (!app.ok) return refused3(app, { what: "The funnels", command: "funnels", browserUrl: target.dashboard_url, json: o.json });
10907
+ if (app.visitorsPlan) return refused3({ ok: false, upgradeUrl: app.visitorsPlan.upgradeUrl ?? hostUrl("/account/billing") }, { what: "Funnels (part of visitor analytics)", command: "funnels", plan: app.visitorsPlan.plan, json: o.json });
10739
10908
  const current = app.more.funnels.map((f) => ({ name: f.name, steps: f.steps }));
10740
10909
  if (!sub) {
10741
10910
  if (o.json) out(JSON.stringify({ ok: true, app: target.name, funnels: app.more.funnels }, null, 2));
@@ -10766,7 +10935,7 @@ async function funnels(o = {}, deps = {}) {
10766
10935
  return 2;
10767
10936
  }
10768
10937
  const r = await asking(o, creds, (cr) => saveFunnels(cr, target.id, next, deps), deps);
10769
- if (!r.ok) return refused2(r, { what: "Funnels (part of visitor analytics)", command: ["funnels", sub, name ? `"${name}"` : "", ...steps].filter(Boolean).join(" "), browserUrl: target.dashboard_url, json: o.json });
10938
+ if (!r.ok) return refused3(r, { what: "Funnels (part of visitor analytics)", command: ["funnels", sub, name ? `"${name}"` : "", ...steps].filter(Boolean).join(" "), browserUrl: target.dashboard_url, json: o.json });
10770
10939
  if (o.json) out(JSON.stringify({ ok: true, funnels: r.funnels }));
10771
10940
  else {
10772
10941
  good(sub === "add" ? `Saved the funnel ${c.bold(clean(name, 60))}: ${steps.map((x) => clean(x, 30)).join(` ${sym.arrow} `)}` : `Removed the funnel ${c.bold(clean(name, 60))}.`);
@@ -10807,7 +10976,7 @@ async function agentLink(o = {}, deps = {}) {
10807
10976
  return 1;
10808
10977
  }
10809
10978
  const r = await asking(o, creds, (cr) => makeAgentLink(cr, target.id, deps), deps);
10810
- if (!r.ok) return refused2(r, { what: "The agent link", command: "agent link", browserUrl: target.dashboard_url, json: o.json });
10979
+ if (!r.ok) return refused3(r, { what: "The agent link", command: "agent link", browserUrl: target.dashboard_url, json: o.json });
10811
10980
  const args = claudeAdd(r.url);
10812
10981
  const line = `claude ${args.join(" ")}`;
10813
10982
  if (o.json) {
@@ -10936,7 +11105,7 @@ async function ask2(o = {}, deps = {}) {
10936
11105
  const range = ["24h", "7d", "30d", "90d", "1y"].includes(o.range) ? o.range : "7d";
10937
11106
  if (!o.json) header({ app: target.name, framework: state.app.token === target.token ? state.app.framework : null, account: state.account?.label, plan: planName(state, target.token), host: state.host });
10938
11107
  const cli = state.account?.cli ?? null;
10939
- if (cli && !cli.paid) return refused2({ ok: false, needsPro: cli }, { what: "A question to the model", command: "ask", json: o.json });
11108
+ if (cli && !cli.paid) return refused3({ ok: false, needsPro: cli }, { what: "A question to the model", command: "ask", json: o.json });
10940
11109
  const prefs = (deps.readPrefs ?? readPrefs)();
10941
11110
  if (!prefs.askTold) {
10942
11111
  const told = "Your question goes to GenClass's model on genclass.dev, with this app's dashboard numbers: pages, kinds of problem and counts, and with visitor analytics the sources and the names of what people click. The model is OpenAI's. No code leaves your machine, and neither the question nor the answer is stored.";
@@ -10956,7 +11125,7 @@ async function ask2(o = {}, deps = {}) {
10956
11125
  const sp = o.json ? null : spinner("Reading your app's numbers");
10957
11126
  const r = await asking({ ...o, json: o.json }, creds, (cr) => askModel(cr, { id: target.id, range, question, history }, deps), deps);
10958
11127
  sp?.stop(null);
10959
- if (!r.ok) return refused2(r, { what: "A question to the model", command: `ask "${clean(question, 40)}"`, browserUrl: target.dashboard_url, json: o.json });
11128
+ if (!r.ok) return refused3(r, { what: "A question to the model", command: `ask "${clean(question, 40)}"`, browserUrl: target.dashboard_url, json: o.json });
10960
11129
  if (o.json) {
10961
11130
  out(JSON.stringify({ ok: r.answer !== null, app: target.name, range: r.range ?? range, question, answer: r.answer, why: r.why, remaining_today: r.remainingToday }, null, 2));
10962
11131
  return r.answer === null ? 1 : 0;
@@ -11057,6 +11226,9 @@ function closing(state) {
11057
11226
  const waiting = state.steps.filter((s) => s.state === "waiting");
11058
11227
  const blocked = state.steps.find((s) => s.state === "blocked");
11059
11228
  if (blocked) {
11229
+ } else if (!state.signedIn) {
11230
+ out(` ${c.bold("Not signed in yet.")}`);
11231
+ note("Run npx genclass again for a new code: setup goes on from the sign-in.");
11060
11232
  } else if (state.complete) out(` ${c.green("Everything is set up.")}`);
11061
11233
  else if (waiting.length) {
11062
11234
  out(` ${c.bold("Nothing more to do here right now.")}`);
@@ -11064,7 +11236,7 @@ function closing(state) {
11064
11236
  }
11065
11237
  out();
11066
11238
  out(` ${c.gray("Day to day")}`);
11067
- out(` ${c.cyan("npx genclass".padEnd(25))}${c.gray("where things stand")}`);
11239
+ out(` ${c.cyan("npx genclass".padEnd(25))}${c.gray("the prompt: commands, questions")}`);
11068
11240
  out(` ${c.cyan("npx genclass suggest".padEnd(25))}${c.gray("what your app is missing")}`);
11069
11241
  if (state.app.token) out(` ${c.cyan("npx genclass dashboard".padEnd(25))}${c.gray("what it found on your site")}`);
11070
11242
  out();
@@ -11079,7 +11251,9 @@ async function status(o = {}) {
11079
11251
  const step = state.next;
11080
11252
  if (step) {
11081
11253
  showNext(step, !!o.all);
11082
- barPara(`${c.gray("Run")} ${c.cyan(step.run ?? "npx genclass setup")}${step.human ? c.gray(` (then: ${step.human})`) : ""}`, (l) => l);
11254
+ const cmd = step.run ?? "npx genclass setup";
11255
+ const typedHere = homeOpen() && cmd.startsWith("npx genclass ");
11256
+ barPara(`${c.gray(typedHere ? "Type" : "Run")} ${c.cyan(typedHere ? cmd.slice("npx genclass ".length) : cmd)}${step.human ? c.gray(` (then: ${step.human})`) : ""}`, (l) => l);
11083
11257
  out();
11084
11258
  if (!o.all) out(` ${c.gray("Every part:")} ${c.cyan("npx genclass status --all")}`);
11085
11259
  out();
@@ -11138,7 +11312,7 @@ async function walk(o, deps, auto) {
11138
11312
  return deps.home({ ...o, cwd: state.cwd, app: state.app.name ?? "" });
11139
11313
  }
11140
11314
  out();
11141
- note("Stopped. Run npx genclass again any time: it continues from here.");
11315
+ note(o.home === false ? "Setup stopped here. Type setup to go on with it." : "Stopped. Run npx genclass again any time: it continues from here.");
11142
11316
  out();
11143
11317
  return 0;
11144
11318
  }
@@ -11167,8 +11341,10 @@ async function walk(o, deps, auto) {
11167
11341
  else if (step.id === "plan" || step.id === "app-plan") {
11168
11342
  result = step.id === "plan" ? await choosePlan(state, so) : await chooseAppPlan(state, so);
11169
11343
  if (result === "quit") {
11170
- out();
11171
- if (!auto) note("Stopped. Run npx genclass again any time: it continues from here.");
11344
+ if (!auto && step.id !== "plan") {
11345
+ out();
11346
+ note(o.home === false ? "Setup stopped here. Type setup to go on with it." : "Stopped. Run npx genclass again any time: it continues from here.");
11347
+ }
11172
11348
  out();
11173
11349
  return auto ? 1 : 0;
11174
11350
  }
@@ -11185,13 +11361,16 @@ async function walk(o, deps, auto) {
11185
11361
  }
11186
11362
  if (result === "failed") {
11187
11363
  failed = true;
11188
- if (!auto) {
11364
+ if (!auto && step.id !== "account") {
11189
11365
  out();
11190
11366
  warn(`${step.doing} did not finish. The steps that do not need it go on, and npx genclass offers it again next time.`);
11191
11367
  }
11192
11368
  }
11193
11369
  if (step.id === "account" && result === "failed" && !auto && signInTries++ < 1) note("Enter tries the sign-in again with a new code.");
11194
- else skip2.push(step.id);
11370
+ else {
11371
+ if (step.id === "account" && result === "failed" && !auto) note(`Sign in any time: ${deps.home && o.home !== false ? "type login" : "npx genclass login"}.`);
11372
+ skip2.push(step.id);
11373
+ }
11195
11374
  out();
11196
11375
  rule();
11197
11376
  }
@@ -11216,9 +11395,11 @@ var init_setup = __esm({
11216
11395
  var home_exports = {};
11217
11396
  __export(home_exports, {
11218
11397
  COMMANDS: () => COMMANDS,
11398
+ FREE_MENU: () => FREE_MENU,
11219
11399
  home: () => home,
11220
11400
  installShortName: () => installShortName,
11221
11401
  menu: () => menu,
11402
+ opening: () => opening,
11222
11403
  read: () => read6,
11223
11404
  words: () => words
11224
11405
  });
@@ -11229,7 +11410,7 @@ function words(line) {
11229
11410
  while (m = re.exec(String(line))) out2.push(m[1] ?? m[2] ?? m[3]);
11230
11411
  return out2;
11231
11412
  }
11232
- function read6(line, known = NAMES) {
11413
+ function read6(line, known = NAMES, numbered = COMMANDS) {
11233
11414
  const text = String(line ?? "").trim();
11234
11415
  if (!text) return { help: true };
11235
11416
  let argv = words(text);
@@ -11238,17 +11419,32 @@ function read6(line, known = NAMES) {
11238
11419
  if (!argv.length) return { help: true };
11239
11420
  const head2 = argv[0].toLowerCase();
11240
11421
  if (["q", "quit", "exit", "bye"].includes(head2)) return { quit: true };
11241
- if (/^\d{1,2}$/.test(head2) && argv.length === 1) {
11242
- const cmd = COMMANDS[Number(head2) - 1];
11243
- return cmd ? { command: [cmd[0].split(" ")[0]] } : { unknown: head2 };
11422
+ if (/^\d+$/.test(head2) && argv.length === 1) {
11423
+ const cmd = numbered[Number(head2) - 1];
11424
+ return cmd ? { command: [cmd[0].split(" ")[0]] } : { unknown: head2, number: true };
11244
11425
  }
11245
11426
  if (head2 === "help" || head2 === "?" || head2 === "commands") return { help: true, all: true };
11246
11427
  if (known.includes(head2)) return { command: [head2, ...argv.slice(1)] };
11428
+ if (VERBS.has(head2) && argv[1] && known.includes(argv[1].toLowerCase())) return { command: [argv[1].toLowerCase(), ...argv.slice(2)] };
11247
11429
  if (argv.length >= 3 || /\?\s*$/.test(text)) return { question: text };
11248
11430
  return { unknown: argv[0] };
11249
11431
  }
11250
- function menu(all = false) {
11432
+ function menu(all = false, free = false) {
11251
11433
  out();
11434
+ if (free) {
11435
+ out(` ${c.bold("What next?")} ${c.gray(all ? "Every command:" : "A number or a command.")}`);
11436
+ if (all) {
11437
+ const names = COMMANDS.map(([n2]) => n2);
11438
+ for (let i = 0; i < names.length; i += 4) out(` ${c.cyan(names.slice(i, i + 4).map((n2) => n2.padEnd(13)).join(""))}`);
11439
+ note("All but upgrade, profile, plan, status, login and remove come with Pro.");
11440
+ return;
11441
+ }
11442
+ const pad2 = Math.max(...FREE_MENU.map(([n2]) => n2.length)) + 2;
11443
+ FREE_MENU.forEach(([name, what], i) => out(` ${c.gray(String(i + 1).padStart(2))} ${c.cyan(name.padEnd(pad2))}${c.gray(what)}`));
11444
+ out(` ${c.cyan("help".padEnd(pad2))}${c.gray("every command")} ${c.cyan("q")} ${c.gray("leave")}`);
11445
+ note("You are on Free: the other commands come with Pro.");
11446
+ return;
11447
+ }
11252
11448
  out(` ${c.bold("What next?")} ${c.gray("A number, a command, or a question.")}`);
11253
11449
  const list2 = COMMANDS.map((x, i) => [...x, i + 1]).filter(([, , short2]) => all || short2);
11254
11450
  const pad = Math.max(...list2.map(([n2]) => n2.length)) + 2;
@@ -11257,16 +11453,42 @@ function menu(all = false) {
11257
11453
  }
11258
11454
  async function installShortName(deps = {}) {
11259
11455
  if (isShort() || process.env.CI || process.env.GENCLASS_NO_INSTALL || !(deps.interactive ?? interactive)()) return "skipped";
11456
+ const p = readPrefs();
11457
+ const now = deps.now ?? Date.now();
11458
+ const install = deps.install ?? installGlobally;
11260
11459
  if ((deps.works ?? shortNameWorks)()) {
11460
+ const have = (deps.installedVersion ?? installedVersion)();
11461
+ const npx = (deps.viaNpx ?? viaNpx)();
11462
+ let want = null;
11463
+ if (have && npx) want = newer(BUILD.version, have) ? BUILD.version : null;
11464
+ else if (have && !(p.updateCheckedAt && now - Date.parse(p.updateCheckedAt) < DAY2)) {
11465
+ savePrefs({ updateCheckedAt: new Date(now).toISOString() });
11466
+ const latest = await (deps.latest ?? latestOnNpm)();
11467
+ want = latest && newer(latest, have) ? latest : null;
11468
+ }
11469
+ if (want && p.updateFailedAt && now - Date.parse(p.updateFailedAt) < DAY2) want = null;
11470
+ let updated = false;
11471
+ if (want) {
11472
+ out();
11473
+ const sp2 = spinner(`Updating the genclass command, ${have} to ${want}`);
11474
+ const r2 = await install(want);
11475
+ if (r2.ok) {
11476
+ savePrefs({ updateFailedAt: null });
11477
+ sp2.stop("ok", npx ? `Updated to ${want}.` : `Updated to ${want}: the next genclass you type runs it.`);
11478
+ updated = true;
11479
+ } else {
11480
+ savePrefs({ updateFailedAt: new Date(now).toISOString() });
11481
+ sp2.stop("warn", `Could not update the genclass command: it stays ${have}.`);
11482
+ note("By hand: npm install -g genclass@latest");
11483
+ }
11484
+ }
11261
11485
  useShortName();
11262
- return "skipped";
11486
+ return updated ? "updated" : "skipped";
11263
11487
  }
11264
- const p = readPrefs();
11265
- const now = deps.now ?? Date.now();
11266
11488
  if (p.installFailedAt && now - Date.parse(p.installFailedAt) < DAY2) return "skipped";
11267
11489
  out();
11268
11490
  const sp = spinner("Adding the genclass command to your terminal");
11269
- const r = await (deps.install ?? installGlobally)(BUILD.version);
11491
+ const r = await install(BUILD.version);
11270
11492
  if (!r.ok) {
11271
11493
  savePrefs({ installFailedAt: new Date(now).toISOString() });
11272
11494
  sp.stop("warn", "Could not add the genclass command. npx genclass keeps working.");
@@ -11278,28 +11500,50 @@ async function installShortName(deps = {}) {
11278
11500
  if ((deps.works ?? shortNameWorks)()) {
11279
11501
  useShortName();
11280
11502
  sp.stop("ok", "Added: type genclass from now on.");
11503
+ if (/zsh$/.test(process.env.SHELL ?? "")) note("If this window says command not found, run rehash once, or open a new window.");
11281
11504
  } else sp.stop("ok", "Added. Open a new terminal window and type genclass.");
11282
11505
  note("npm install -g genclass ran. npm uninstall -g genclass takes it out.");
11283
11506
  return "installed";
11284
11507
  }
11508
+ function opening(state) {
11509
+ header({ app: state.app?.name, framework: state.app?.framework, account: state.account?.label, plan: planName(state), host: state.host });
11510
+ const left = state.steps.filter((x) => x.state !== "done" && x.state !== "optional" && x.blocking !== false && x.state !== "waiting");
11511
+ if (state.signedIn && state.account?.cli && !state.account.cli.paid) note(`You are on Free. Type upgrade to start ${state.account.cli.trialDays ? `your ${state.account.cli.trialDays}-day free trial of ` : ""}Pro: setup and the other commands come with it.`);
11512
+ else if (!state.signedIn && state.app?.token) note(state.sessionProblem === "expired" ? "Your sign-in expired. Type login to sign in again." : "Not signed in. Type login to sign in again.");
11513
+ else if (!state.signedIn) note("Not signed in, and GenClass is not in this app yet. Type setup: it starts with the sign-in.");
11514
+ else if (!state.app?.token) note("GenClass is not set up in this folder yet. Type setup to do it, one step at a time.");
11515
+ else if (left.length) note(`Set up. ${left.length} more step${left.length === 1 ? "" : "s"} you can add (${left.map((x) => x.title).join(", ")}): type setup.`);
11516
+ else note("Everything is set up. Type setup any time to change something.");
11517
+ }
11285
11518
  async function home(o = {}, deps = {}) {
11286
11519
  if (!interactive()) return 0;
11287
11520
  await installShortName(deps);
11288
- menu();
11521
+ let free = !!o.free;
11522
+ const pro = async () => (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).proSeen();
11523
+ menu(false, free);
11289
11524
  inHome(o.app ?? "");
11525
+ let meant = null;
11290
11526
  for (; ; ) {
11291
11527
  out();
11292
11528
  const line = await typed(` ${PROMPT()} `);
11293
11529
  if (line === null) break;
11294
- const got = read6(line);
11530
+ const yes = meant && /^\s*(y|yes)\s*$/i.test(line);
11531
+ const got = yes ? { command: [meant] } : read6(line, NAMES, free ? FREE_MENU : COMMANDS);
11532
+ meant = null;
11295
11533
  if (got.quit) break;
11296
11534
  if (got.help) {
11297
- menu(!!got.all);
11535
+ menu(!!got.all, free);
11298
11536
  continue;
11299
11537
  }
11300
11538
  if (got.unknown) {
11539
+ if (got.number) {
11540
+ warn(`No command has the number ${got.unknown}.`);
11541
+ note(`The numbers are the ones in the list: ${free ? "1 to " + FREE_MENU.length : "help shows them all"}.`);
11542
+ continue;
11543
+ }
11301
11544
  const near = deps.nearest?.(got.unknown);
11302
- warn(`There is no command "${got.unknown}".${near ? ` Did you mean ${c.cyan(near)}?` : ""}`);
11545
+ meant = near;
11546
+ warn(`There is no command "${got.unknown}".${near ? ` Did you mean ${c.cyan(near)}? (y runs it)` : ""}`);
11303
11547
  note("help lists them all.");
11304
11548
  continue;
11305
11549
  }
@@ -11310,12 +11554,23 @@ async function home(o = {}, deps = {}) {
11310
11554
  } catch (e) {
11311
11555
  warn(`That did not work: ${e?.message ?? e}`);
11312
11556
  }
11313
- if (!["upgrade", "profile", "plan", "login", "logout", "remove"].includes(argv[0])) {
11557
+ let stopped = false;
11558
+ try {
11559
+ const paywall = await Promise.resolve().then(() => (init_paywall(), paywall_exports));
11560
+ stopped = paywall.wasRefused();
11561
+ paywall.resetRefused();
11562
+ } catch {
11563
+ }
11564
+ if (!stopped && !["upgrade", "profile", "plan", "login", "logout", "remove", "status", "setup"].includes(argv[0])) {
11314
11565
  try {
11315
11566
  await deps.afterCommand?.();
11316
11567
  } catch {
11317
11568
  }
11318
11569
  }
11570
+ if (free && await pro().catch(() => false)) {
11571
+ free = false;
11572
+ menu(false, false);
11573
+ }
11319
11574
  rule();
11320
11575
  }
11321
11576
  inHome(null);
@@ -11324,13 +11579,14 @@ async function home(o = {}, deps = {}) {
11324
11579
  out();
11325
11580
  return 0;
11326
11581
  }
11327
- var COMMANDS, NAMES, DAY2;
11582
+ var COMMANDS, NAMES, FREE_MENU, VERBS, DAY2;
11328
11583
  var init_home = __esm({
11329
11584
  "src/home.mjs"() {
11330
11585
  init_define_GENCLASS_BUILD();
11331
11586
  init_ui();
11332
11587
  init_assets();
11333
11588
  init_name();
11589
+ init_state();
11334
11590
  init_tui();
11335
11591
  COMMANDS = [
11336
11592
  ["dashboard", "what GenClass found on your live site", true],
@@ -11358,6 +11614,13 @@ var init_home = __esm({
11358
11614
  ["remove", "take GenClass out of this app", false]
11359
11615
  ];
11360
11616
  NAMES = [...COMMANDS.map(([n2]) => n2.split(" ")[0]), "logout", "whoami", "version", "connect", "init", "audit"];
11617
+ FREE_MENU = [
11618
+ ["upgrade", "start Pro: its free trial first"],
11619
+ ["profile", "your account and plan"],
11620
+ ["plan", "your plan and its limits"],
11621
+ ["status", "where the setup stands"]
11622
+ ];
11623
+ VERBS = /* @__PURE__ */ new Set(["show", "open", "see", "run", "view", "go", "list"]);
11361
11624
  DAY2 = 24 * 60 * 6e4;
11362
11625
  }
11363
11626
  });
@@ -11442,17 +11705,18 @@ async function run4(argv, ctx = {}) {
11442
11705
  const po = { cwd: i >= 0 ? args[i + 1] : void 0, yes: args.includes("--yes") || args.includes("-y"), json: args.includes("--json"), noBrowser: args.includes("--no-browser") };
11443
11706
  const thenPlan = async (code) => {
11444
11707
  if (code !== 0) return code;
11445
- await (await Promise.resolve().then(() => (init_actions(), actions_exports))).planNow(po).catch(() => "none");
11708
+ await (await Promise.resolve().then(() => (init_actions(), actions_exports))).planNow({ ...po, announce: true }).catch(() => "none");
11446
11709
  return code;
11447
11710
  };
11448
11711
  if (["logout", "whoami"].includes(cmd)) return (await Promise.resolve().then(() => (init_login(), login_exports))).run(cmd, args);
11449
11712
  if (cmd === "login") {
11450
11713
  const login2 = await Promise.resolve().then(() => (init_login(), login_exports));
11451
11714
  const noConnect = args.includes("--no-connect");
11452
- const code = await login2.run(cmd, noConnect || asksHelp ? args : [...args, "--no-connect"]);
11715
+ const plain2 = args.every((a, i2) => ["--cwd", "--no-connect", "--no-browser"].includes(a) || args[i2 - 1] === "--cwd");
11716
+ const code = !asksHelp && plain2 && interactive() ? await ownLogin(po) : await login2.run(cmd, noConnect || asksHelp ? args : [...args, "--no-connect"]);
11453
11717
  if (code !== 0 || asksHelp) return code;
11454
11718
  if (!await (await Promise.resolve().then(() => (init_paywall(), paywall_exports))).afterLogin(po).catch(() => true)) return code;
11455
- return thenPlan(noConnect ? code : await login2.offerConnect(args).catch(() => 1));
11719
+ return thenPlan(noConnect ? code : await afterSignIn(po, args, login2).catch(() => 1));
11456
11720
  }
11457
11721
  if (cmd === "remove") return (await Promise.resolve().then(() => (init_remove(), remove_exports))).remove(args);
11458
11722
  if (["connect", "init", "scan", "audit"].includes(cmd)) {
@@ -11488,7 +11752,8 @@ ${usage3()}`);
11488
11752
  return 2;
11489
11753
  }
11490
11754
  if (o.version || cmd === "version") {
11491
- out(`genclass ${BUILD.version} (installs @genclass/runtime ${BUILD.runtimeVersion}, @genclass/mcp ${BUILD.mcpVersion})`);
11755
+ out(`genclass ${BUILD.version}`);
11756
+ out(`installs @genclass/runtime ${BUILD.runtimeVersion}, @genclass/mcp ${BUILD.mcpVersion}`);
11492
11757
  return 0;
11493
11758
  }
11494
11759
  if (o.help || cmd === "help") {
@@ -11572,10 +11837,64 @@ ${usage3()}`);
11572
11837
  if (cmd === "setup" || cmd === null) {
11573
11838
  const home2 = async (ho) => (await Promise.resolve().then(() => (init_home(), home_exports))).home(ho, { runCommand: (a) => run4(a, { nested: true }), nearest, afterCommand: async () => (await Promise.resolve().then(() => (init_manage(), manage_exports))).freeLine({ cwd: ho.cwd }) });
11574
11839
  if (!ctx.nested && !o.yes && !o.json) await (await Promise.resolve().then(() => (init_home(), home_exports))).installShortName();
11840
+ if (cmd === null && !ctx.nested && !o.yes && !o.json && interactive()) {
11841
+ const { readState: readState2 } = await Promise.resolve().then(() => (init_state(), state_exports));
11842
+ const state = await readState2({ cwd: o.cwd }).catch(() => null);
11843
+ const ready = !!state?.signedIn && !!state?.app?.token;
11844
+ if (ready || !(await Promise.resolve().then(() => (init_name(), name_exports))).viaNpx()) {
11845
+ if (state) (await Promise.resolve().then(() => (init_home(), home_exports))).opening(state);
11846
+ const free = !!state?.account?.cli && !state.account.cli.paid;
11847
+ return home2({ ...o, cwd: state?.cwd ?? o.cwd, app: state?.app?.name ?? "", free });
11848
+ }
11849
+ }
11575
11850
  return setup2({ ...o, ...ctx.nested ? { home: false } : {} }, { runSuggest, home: home2 });
11576
11851
  }
11577
11852
  return 2;
11578
11853
  }
11854
+ async function afterSignIn(po, args, login2) {
11855
+ if (po.yes || !interactive()) return login2.offerConnect(args);
11856
+ let state = null;
11857
+ try {
11858
+ state = await (await Promise.resolve().then(() => (init_state(), state_exports))).readState({ cwd: po.cwd });
11859
+ } catch {
11860
+ state = null;
11861
+ }
11862
+ if (!state?.signedIn) return login2.offerConnect(args);
11863
+ const rt = state.steps.find((x) => x.id === "runtime");
11864
+ if (!state.app.isApp || !rt || rt.state === "done") return 0;
11865
+ if (rt.run === "npx genclass connect") return login2.offerConnect(args);
11866
+ const { hint: hint2, note: note2 } = await Promise.resolve().then(() => (init_tui(), tui_exports));
11867
+ out();
11868
+ note2(`Next: ${hint2("setup")} to ${rt.vite ? "add the two Vite settings this app needs" : "add GenClass to this app"}. It shows the change first.`);
11869
+ return 0;
11870
+ }
11871
+ async function ownLogin(po) {
11872
+ const { readCredentialsFor: readCredentialsFor2 } = await Promise.resolve().then(() => (init_account(), account_exports));
11873
+ const { accountLabel: accountLabel2, inspectProject: inspectProject2 } = await Promise.resolve().then(() => (init_init(), init_exports));
11874
+ const { fetchOverview: fetchOverview2 } = await Promise.resolve().then(() => (init_api(), api_exports));
11875
+ const { bad: bad2, header: header2, note: note2 } = await Promise.resolve().then(() => (init_tui(), tui_exports));
11876
+ const h = hostConfig();
11877
+ let project = null;
11878
+ try {
11879
+ project = inspectProject2({ cwd: po.cwd }).project;
11880
+ } catch {
11881
+ project = null;
11882
+ }
11883
+ const saved = readCredentialsFor2().creds;
11884
+ const me = saved ? await fetchOverview2(saved) : null;
11885
+ header2({ app: project?.name ?? null, framework: project?.label ?? null, account: me?.ok ? accountLabel2(me.account) : null, host: h.overridden && !h.error ? h.host : null });
11886
+ if (me?.ok) {
11887
+ note2(`Already signed in as ${accountLabel2(me.account)}. To switch accounts: logout, then login.`);
11888
+ return 0;
11889
+ }
11890
+ if (me && me.status !== 401) {
11891
+ bad2(`Could not reach genclass.dev (${me.reason}).`);
11892
+ return 1;
11893
+ }
11894
+ if (me) note2("The saved sign-in no longer works: signing in again.");
11895
+ const r = await (await Promise.resolve().then(() => (init_actions(), actions_exports))).signIn(po);
11896
+ return r === "done" ? 0 : 1;
11897
+ }
11579
11898
  function telemetryOnly(args) {
11580
11899
  let toggle = false;
11581
11900
  for (let i = 0; i < args.length; i++) {
@@ -11656,8 +11975,8 @@ var init_cli = __esm({
11656
11975
  init_tui();
11657
11976
  HELP = [
11658
11977
  [null, [
11659
- ["npx genclass", "where this project stands; on a terminal it walks you through the next step, then stays open for commands and questions"],
11660
- ["npx genclass setup", "the guided setup (--yes: no questions, for a coding agent)"],
11978
+ ["npx genclass", "the command's prompt, for commands and questions (the first time in a folder, the setup first)"],
11979
+ ["npx genclass setup", "the guided setup, any time, to add or change a part (--yes: no questions, for a coding agent)"],
11661
11980
  ["npx genclass status", "what is done, what is next (--all: every part; --json)"]
11662
11981
  ]],
11663
11982
  ["See", [