@lizard-build/cli 4.0.89 → 4.0.91

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.
@@ -6,8 +6,8 @@ import { api, withQuery, getBaseURL, isNotFound } from "../lib/api.js";
6
6
  import { success, isJSONMode, printJSON, table, isTTY, timeAgo, info, warn } from "../lib/format.js";
7
7
 
8
8
  // `lizard billing` — the account's plan (docs/pro-billing-api.md on the platform
9
- // repo). Pro is $19/month, with $19 of monthly credits; usage above
10
- // that is pay as you go. Unlike most commands this never takes --project/--service:
9
+ // repo). Pro is $19/month with $19 of usage included each month (Pro 5x $99, Pro 20x
10
+ // $499, on the same terms); usage above that is pay as you go. Unlike most commands this never takes --project/--service:
11
11
  // billing belongs to the account, not a workspace. `lizard credits` is the old name.
12
12
 
13
13
  /** Old prepaid credits (`plan: "payg"`) keep working until this date. */
@@ -22,9 +22,15 @@ export interface Subscription {
22
22
  plan: "none" | "pro" | "payg" | "enterprise" | string;
23
23
  status: "none" | "trialing" | "active" | "past_due" | "canceled" | string;
24
24
  isOwner?: boolean;
25
+ /** "pro" | "pro_99" | "pro_499"; null without a live subscription. Older servers omit it. */
26
+ tier?: string | null;
27
+ /** A move to a lower tier that starts with the next period. */
28
+ pendingTier?: string | null;
29
+ /** Of the current tier. */
25
30
  priceCents: number;
26
31
  taxIncluded: boolean;
27
32
  includedCents: number;
33
+ tiers?: TierOption[];
28
34
  trial: {
29
35
  eligible: boolean;
30
36
  days: number | null;
@@ -50,10 +56,46 @@ export interface Subscription {
50
56
  pastDue: boolean;
51
57
  openInvoiceUrl: string | null;
52
58
  paymentMethod: { brand: string; last4: string; expMonth: number; expYear: number } | null;
53
- limits: { tier: string; replicasPerApp: number } | null;
59
+ limits: { tier: string; replicasPerApp: number; sandboxVcpu?: number; maxSandboxCpus?: number } | null;
54
60
  checkoutAvailable: boolean;
55
61
  }
56
62
 
63
+ export interface TierOption {
64
+ tier: string;
65
+ priceCents: number;
66
+ includedCents: number;
67
+ sandboxVcpu: number;
68
+ trial: boolean;
69
+ available: boolean;
70
+ }
71
+
72
+ interface TierChange {
73
+ status: "upgraded" | "scheduled" | "unchanged" | "requires_action" | string;
74
+ tier: string;
75
+ pendingTier: string | null;
76
+ effectiveAt: number | null;
77
+ invoiceUrl: string | null;
78
+ }
79
+
80
+ /** Pro's tiers: what the API calls them, what people call them, and what `lizard billing tier` takes. */
81
+ const TIERS = [
82
+ { tier: "pro", label: "Pro", arg: "pro", aliases: ["pro", "1x", "19"] },
83
+ { tier: "pro_99", label: "Pro 5x", arg: "5x", aliases: ["5x", "pro-5x", "pro5x", "pro_99", "99"] },
84
+ { tier: "pro_499", label: "Pro 20x", arg: "20x", aliases: ["20x", "pro-20x", "pro20x", "pro_499", "499"] },
85
+ ];
86
+
87
+ export function tierLabel(tier: string | null | undefined): string {
88
+ return TIERS.find((t) => t.tier === tier)?.label ?? "Pro";
89
+ }
90
+
91
+ /** `5x`, `pro-5x`, `pro_99` → `pro_99`. */
92
+ export function parseTier(input: string): string {
93
+ const key = input.trim().toLowerCase().replace(/\s+/g, "-");
94
+ const found = TIERS.find((t) => t.aliases.includes(key));
95
+ if (!found) throw new Error(`Unknown tier "${input}". Use pro, 5x or 20x.`);
96
+ return found.tier;
97
+ }
98
+
57
99
  interface BalanceView {
58
100
  plan: string;
59
101
  status: "active" | "grace" | "frozen";
@@ -165,14 +207,14 @@ export function describeSubscription(sub: Subscription, now = Date.now()): strin
165
207
  lines.push("Pro is not open for this account yet.");
166
208
  } else if (sub.trial.eligible && sub.trial.days) {
167
209
  lines.push(
168
- `Start a ${sub.trial.days}-day Pro trial with ${usd(sub.trial.creditCents ?? 0)} in credits: ` +
210
+ `Start a ${sub.trial.days}-day Pro trial with ${usd(sub.trial.creditCents ?? 0)} of usage: ` +
169
211
  chalk.cyan("lizard billing start"),
170
212
  );
171
213
  lines.push(chalk.dim(`No charge today, then ${usd(sub.priceCents)}/month.`));
172
214
  if (sub.trial.promoCode) lines.push(label("Promo code: ") + `${sub.trial.promoCode} (saved for the trial)`);
173
215
  } else {
174
216
  lines.push(
175
- `Start Pro: ${usd(sub.priceCents)}/month, with ${usd(sub.includedCents)} in credits each month: ` +
217
+ `Start Pro: ${usd(sub.priceCents)}/month, with ${usd(sub.includedCents)} of usage included each month: ` +
176
218
  chalk.cyan("lizard billing start"),
177
219
  );
178
220
  }
@@ -180,7 +222,7 @@ export function describeSubscription(sub: Subscription, now = Date.now()): strin
180
222
  }
181
223
 
182
224
  lines.push(
183
- `${chalk.bold("Pro")} ${statusLabel(sub.status)}${owner} ` +
225
+ `${chalk.bold(tierLabel(sub.tier))} ${statusLabel(sub.status)}${owner} ` +
184
226
  chalk.dim(`${usd(sub.priceCents)}/month`),
185
227
  );
186
228
 
@@ -190,7 +232,7 @@ export function describeSubscription(sub: Subscription, now = Date.now()): strin
190
232
  const credit = sub.trial.creditCents ?? period?.includedCents ?? 0;
191
233
  const used = sub.trial.usedCents ?? period?.usedCents ?? 0;
192
234
  const left = sub.trial.remainingCents ?? Math.max(0, credit - used);
193
- lines.push(label("Trial credits: ") + `${usd(used)} of ${usd(credit)} used, ${usd(left)} left`);
235
+ lines.push(label("Trial usage: ") + `${usd(used)} of ${usd(credit)} used, ${usd(left)} left`);
194
236
  } else if (period) {
195
237
  lines.push(
196
238
  label("This month: ") +
@@ -212,6 +254,14 @@ export function describeSubscription(sub: Subscription, now = Date.now()): strin
212
254
  if (sub.nextCharge?.at) {
213
255
  lines.push(label("Next charge: ") + `${usd(sub.nextCharge.amountCents)} on ${fmtDate(sub.nextCharge.at)}`);
214
256
  }
257
+ if (sub.pendingTier && sub.pendingTier !== sub.tier) {
258
+ const when = period ? ` on ${fmtDate(period.end)}` : " with the next period";
259
+ const stay = TIERS.find((t) => t.tier === sub.tier)?.arg ?? "pro";
260
+ lines.push(
261
+ label("Next period: ") + `moves to ${tierLabel(sub.pendingTier)}${when}. Run ` +
262
+ chalk.cyan(`lizard billing tier ${stay}`) + ` to stay on ${tierLabel(sub.tier)}.`,
263
+ );
264
+ }
215
265
  if (sub.cancelAt) {
216
266
  lines.push(chalk.yellow(`Ends on ${fmtDate(sub.cancelAt)}.`) + " Run " + chalk.cyan("lizard billing resume") + " to keep Pro.");
217
267
  }
@@ -222,6 +272,9 @@ export function describeSubscription(sub: Subscription, now = Date.now()): strin
222
272
  if (sub.limits) {
223
273
  const n = sub.limits.replicasPerApp;
224
274
  lines.push(label("Replicas: ") + `up to ${n} per service`);
275
+ if (sub.limits.sandboxVcpu) {
276
+ lines.push(label("Sandboxes: ") + `up to ${sub.limits.sandboxVcpu.toLocaleString("en-US")} vCPU at once`);
277
+ }
225
278
  }
226
279
  if (sub.paymentMethod) {
227
280
  const pm = sub.paymentMethod;
@@ -338,13 +391,13 @@ export function describePromo(out: PromoResult): string {
338
391
  const credits = usd(out.trialCreditCents ?? out.creditCents);
339
392
  if (out.appliesTo === "current_trial") {
340
393
  const until = out.expiresAt ? `, until ${fmtDate(out.expiresAt)}` : "";
341
- return `Your trial now runs ${out.trialDays} days with ${credits} in credits${until}.`;
394
+ return `Your trial now runs ${out.trialDays} days with ${credits} of usage${until}.`;
342
395
  }
343
396
  const code = out.code ? `Code ${out.code} saved: ` : "Code saved: ";
344
- return `${code}a ${out.trialDays}-day Pro trial with ${credits} in credits. Start it with \`lizard billing start\`.`;
397
+ return `${code}a ${out.trialDays}-day Pro trial with ${credits} of usage. Start it with \`lizard billing start\`.`;
345
398
  }
346
399
  if (out.status === "pending_payment_method") {
347
- return `Code saved: ${fmtCents(out.creditCents)} in credits. They unlock when you start your trial in Billing.`;
400
+ return `Code saved: ${fmtCents(out.creditCents)} of trial usage. It unlocks when you start your trial in Billing.`;
348
401
  }
349
402
  return `Redeemed ${fmtCents(out.creditCents)}. New balance: ${fmtCents(out.balanceCents)}.`;
350
403
  }
@@ -353,7 +406,7 @@ export function registerBilling(program: Command) {
353
406
  const cmd = program
354
407
  .command("billing")
355
408
  .alias("credits")
356
- .description("Your plan: Pro trial, this month's credits, next charge, cancel or resume (`credits` is the old name)")
409
+ .description("Your plan: Pro tier, trial, this month's usage, next charge, cancel or resume (`credits` is the old name)")
357
410
  .option("-w, --workspace <id>", "Show the plan of this workspace's owner")
358
411
  .action(async () => {
359
412
  await showStatus(cmd.opts());
@@ -367,7 +420,7 @@ export function registerBilling(program: Command) {
367
420
 
368
421
  cmd
369
422
  .command("status")
370
- .description("Show the plan, trial, this month's credits and the next charge")
423
+ .description("Show the plan, trial, this month's usage and the next charge")
371
424
  .option("-w, --workspace <id>", "Show the plan of this workspace's owner")
372
425
  .action(async (opts) => {
373
426
  // `billing` takes -w too and claims it wherever it appears on the line.
@@ -392,20 +445,24 @@ export function registerBilling(program: Command) {
392
445
  .command("start")
393
446
  .description("Start Pro in Stripe Checkout: the trial if the account can have one, otherwise Pro at once")
394
447
  .option("--return-url <path>", "Dashboard path to come back to after Checkout, e.g. /projects/abc")
448
+ .option("--tier <tier>", "pro (default), 5x ($99/month) or 20x ($499/month); 5x and 20x have no trial")
395
449
  .option("--no-open", "Print the Checkout link instead of opening a browser")
396
450
  .action(async (opts) => {
397
- const out = await api.post<CheckoutResult>("/api/billing/subscription/checkout", { returnUrl: opts.returnUrl });
451
+ const tier = opts.tier ? parseTier(opts.tier) : undefined;
452
+ const out = await api.post<CheckoutResult>("/api/billing/subscription/checkout", { returnUrl: opts.returnUrl, tier });
398
453
  if (isJSONMode()) {
399
454
  printJSON(out);
400
455
  return;
401
456
  }
402
457
  if (out.trialDays) {
403
458
  console.log(
404
- `Your ${out.trialDays}-day trial includes ${usd(out.trialCreditCents ?? 0)} in credits. ` +
459
+ `Your ${out.trialDays}-day trial includes ${usd(out.trialCreditCents ?? 0)} of usage. ` +
405
460
  "No charge today, then $19/month.",
406
461
  );
462
+ } else if (tier && tier !== "pro") {
463
+ console.log(`${tierLabel(tier)} starts today and is charged from day one.`);
407
464
  } else {
408
- console.log("Pro starts today: $19/month, with $19 in credits each month.");
465
+ console.log("Pro starts today: $19/month, with $19 of usage included each month.");
409
466
  }
410
467
  console.log(`Finish in Stripe Checkout:\n${chalk.cyan(out.url)}`);
411
468
  await openInBrowser(out.url, opts.open !== false);
@@ -414,7 +471,7 @@ export function registerBilling(program: Command) {
414
471
 
415
472
  cmd
416
473
  .command("start-now")
417
- .description("End the trial now: charge $19 and start the first paid month with $19 in credits")
474
+ .description("End the trial now: charge $19 and start the first paid month with $19 of usage included")
418
475
  .option("-y, --yes", "Skip confirmation")
419
476
  .option("--no-open", "Print the payment link instead of opening a browser")
420
477
  .action(async (opts) => {
@@ -435,7 +492,45 @@ export function registerBilling(program: Command) {
435
492
  await openInBrowser(out.invoiceUrl, opts.open !== false);
436
493
  return;
437
494
  }
438
- success("Pro is active. We charged $19 and added $19 in credits for this month.");
495
+ success("Pro is active. We charged $19, and this month includes $19 of usage.");
496
+ });
497
+
498
+ cmd
499
+ .command("tier <tier>")
500
+ .description("Move a paid Pro subscription to pro, 5x ($99/month) or 20x ($499/month): up is charged now, prorated; down starts with the next period")
501
+ .option("-y, --yes", "Skip confirmation")
502
+ .option("--no-open", "Print the payment link instead of opening a browser")
503
+ .action(async (input: string, opts) => {
504
+ const tier = parseTier(input);
505
+ const sub = await api.get<Subscription>("/api/billing/subscription");
506
+ const name = tierLabel(tier);
507
+ const price = (t: string | null | undefined) => sub.tiers?.find((o) => o.tier === t)?.priceCents ?? 0;
508
+ if (tier !== sub.tier || sub.pendingTier) {
509
+ const question = tier === sub.tier
510
+ ? `Stay on ${name}? The move to ${tierLabel(sub.pendingTier)} is cancelled.`
511
+ : price(tier) > price(sub.tier)
512
+ ? `Move to ${name} now? We charge the prorated difference today, and your included usage and limits rise at once.`
513
+ : `Move to ${name} from the next period? Nothing is charged today.`;
514
+ await confirmOrExit(question, opts.yes);
515
+ }
516
+ const out = await api.post<TierChange>("/api/billing/subscription/tier", { tier });
517
+ if (isJSONMode()) {
518
+ printJSON(out);
519
+ return;
520
+ }
521
+ if (out.status === "requires_action" && out.invoiceUrl) {
522
+ console.log(`Your bank needs you to confirm the payment. You stay on ${tierLabel(sub.tier)} until you do:\n${chalk.cyan(out.invoiceUrl)}`);
523
+ await openInBrowser(out.invoiceUrl, opts.open !== false);
524
+ } else if (out.status === "upgraded") {
525
+ success(`You are on ${name} now. We charged the prorated difference, and this month's included usage rose by the same amount.`);
526
+ } else if (out.status === "scheduled") {
527
+ const when = out.effectiveAt ? `on ${fmtDate(out.effectiveAt)}` : "with the next period";
528
+ success(`${name} starts ${when}. Until then you keep ${tierLabel(sub.tier)}.`);
529
+ } else if (sub.pendingTier && sub.pendingTier !== tier) {
530
+ success(`You stay on ${name}. The move to ${tierLabel(sub.pendingTier)} is cancelled.`);
531
+ } else {
532
+ info(`You are already on ${name}.`);
533
+ }
439
534
  });
440
535
 
441
536
  cmd
@@ -470,7 +565,7 @@ export function registerBilling(program: Command) {
470
565
 
471
566
  cmd
472
567
  .command("promo <code>")
473
- .description("Redeem a promo code: a longer Pro trial with more trial credits")
568
+ .description("Redeem a promo code: a longer Pro trial with more trial usage")
474
569
  .action(async (code: string) => {
475
570
  const out = await api.post<PromoResult>("/api/billing/promo/redeem", { code });
476
571
  if (isJSONMode()) {
@@ -78,20 +78,20 @@ export function accountInstruction(state: AccountState, sub: Subscription | null
78
78
  case "trialing": {
79
79
  const ends = sub?.trial.endsAt;
80
80
  const left = sub?.trial.remainingCents;
81
- const parts = [ends ? daysLeft(ends, now) : null, left != null ? `${usd(left)} of trial credits left` : null].filter(Boolean);
81
+ const parts = [ends ? daysLeft(ends, now) : null, left != null ? `${usd(left)} of trial usage left` : null].filter(Boolean);
82
82
  return `The Pro trial is on${parts.length ? ` (${parts.join(", ")})` : ""}. Do NOT open billing or start a subscription.`;
83
83
  }
84
84
  case "active":
85
85
  return "Pro is active. Do NOT open billing or start a subscription.";
86
86
  case "trial_available":
87
87
  return (
88
- `No plan yet, and sandboxes and deploys need one. Offer the user the ${sub?.trial.days}-day Pro trial with ${usd(sub?.trial.creditCents ?? 0)} in credits: ` +
88
+ `No plan yet, and sandboxes and deploys need one. Offer the user the ${sub?.trial.days}-day Pro trial with ${usd(sub?.trial.creditCents ?? 0)} of usage: ` +
89
89
  `no charge today, then ${price}/month. ${start}`
90
90
  );
91
91
  case "subscription_required":
92
92
  return (
93
93
  "No plan yet, and sandboxes and deploys need one. This account has had its trial, so do NOT promise one. " +
94
- `Pro is ${price}/month, with ${usd(sub?.includedCents ?? 1900)} in credits each month. ${start}`
94
+ `Pro is ${price}/month, with ${usd(sub?.includedCents ?? 1900)} of usage each month. ${start}`
95
95
  );
96
96
  case "checkout_unavailable":
97
97
  return "No plan, and Pro is not open for this account yet. Do NOT try to start billing.";
@@ -206,8 +206,8 @@ async function offerPlan(canAsk: boolean): Promise<void> {
206
206
 
207
207
  const trial = state === "trial_available";
208
208
  const offer = trial
209
- ? `Pro trial: ${sub.trial.days} days with ${usd(sub.trial.creditCents ?? 0)} in credits. No charge today, then ${usd(sub.priceCents)}/month.`
210
- : `Pro: ${usd(sub.priceCents)}/month, with ${usd(sub.includedCents)} in credits each month.`;
209
+ ? `Pro trial: ${sub.trial.days} days with ${usd(sub.trial.creditCents ?? 0)} of usage. No charge today, then ${usd(sub.priceCents)}/month.`
210
+ : `Pro: ${usd(sub.priceCents)}/month, with ${usd(sub.includedCents)} of usage each month.`;
211
211
  p.log.info(`No plan yet. Sandboxes and deploys need one.\n${offer}`);
212
212
 
213
213
  const go = canAsk ? await p.confirm({ message: trial ? "Start the trial now?" : "Start Pro now?" }) : false;
@@ -570,13 +570,13 @@ async function fetchProCredits(workspaceId: string): Promise<ProCredits | null>
570
570
 
571
571
  const dollars = (cents: number) => (cents % 100 === 0 ? `$${cents / 100}` : `$${(cents / 100).toFixed(2)}`);
572
572
 
573
- /** "$4.10 of $19 in monthly credits used, overage $0" — the account-wide line for Pro. */
573
+ /** "$4.10 used of $19 included, overage $0" — the account-wide line for Pro. */
574
574
  export function proCreditsLine(pro: ProCredits): string {
575
575
  if (pro.kind === "trial") {
576
576
  const left = Math.max(0, pro.includedCents - pro.usedCents);
577
- return `${dollars(pro.usedCents)} of ${dollars(pro.includedCents)} in trial credits used, ${dollars(left)} left`;
577
+ return `${dollars(pro.usedCents)} used of ${dollars(pro.includedCents)} included, ${dollars(left)} left`;
578
578
  }
579
- return `${dollars(pro.usedCents)} of ${dollars(pro.includedCents)} in monthly credits used, overage ${dollars(pro.overageCents)}`;
579
+ return `${dollars(pro.usedCents)} used of ${dollars(pro.includedCents)} included, overage ${dollars(pro.overageCents)}`;
580
580
  }
581
581
 
582
582
  function fmtPeriodDate(ms: number): string {
@@ -5,7 +5,7 @@ import { join, dirname } from "node:path";
5
5
  import os from "node:os";
6
6
  import { spawn } from "node:child_process";
7
7
 
8
- export const CURRENT_VERSION = "4.0.89";
8
+ export const CURRENT_VERSION = "4.0.91";
9
9
  const RELEASES_API = "https://api.github.com/repos/lizard-build/lizard-cli/releases/latest";
10
10
  const RELEASE_BASE = "https://github.com/lizard-build/lizard-cli/releases/latest/download";
11
11
 
@@ -1,6 +1,6 @@
1
1
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2
2
  import { Command } from "commander";
3
- import { registerBilling, describePromo, type Subscription } from "../../src/commands/billing.js";
3
+ import { registerBilling, describePromo, parseTier, type Subscription, type TierOption } from "../../src/commands/billing.js";
4
4
  import { setAccessToken, setBaseURL } from "../../src/lib/api.js";
5
5
  import { setJSONMode } from "../../src/lib/format.js";
6
6
 
@@ -75,6 +75,12 @@ const paid: Subscription = {
75
75
  limits: { tier: "pro", replicasPerApp: 5 },
76
76
  };
77
77
 
78
+ const tiers: TierOption[] = [
79
+ { tier: "pro", priceCents: 1900, includedCents: 1900, sandboxVcpu: 40, trial: true, available: true },
80
+ { tier: "pro_99", priceCents: 9900, includedCents: 9900, sandboxVcpu: 220, trial: false, available: true },
81
+ { tier: "pro_499", priceCents: 49900, includedCents: 49900, sandboxVcpu: 1200, trial: false, available: true },
82
+ ];
83
+
78
84
  const none: Subscription = {
79
85
  ...base,
80
86
  plan: "none",
@@ -112,14 +118,14 @@ afterEach(() => {
112
118
  });
113
119
 
114
120
  describe("lizard billing (status)", () => {
115
- test("a trial shows days left, trial credits, the next charge and the Billing link", async () => {
121
+ test("a trial shows days left, trial usage, the next charge and the Billing link", async () => {
116
122
  routes({ "GET /api/billing/subscription": () => reply(200, base) });
117
123
  await run(["billing"]);
118
124
  const text = out();
119
125
  expect(text).toContain("Pro trial");
120
126
  expect(text).toContain("$19/month");
121
127
  expect(text).toContain("Trial: 5 days left");
122
- expect(text).toContain("Trial credits: $1.20 of $5 used, $3.80 left");
128
+ expect(text).toContain("Trial usage: $1.20 of $5 used, $3.80 left");
123
129
  expect(text).toMatch(/Next charge: \$19 on \w{3} \d+, \d{4}/);
124
130
  expect(text).toContain("Replicas: up to 1 per service");
125
131
  expect(text).toContain("Card: visa •••• 4242");
@@ -153,12 +159,27 @@ describe("lizard billing (status)", () => {
153
159
  expect(text).not.toContain("Next charge");
154
160
  });
155
161
 
162
+ test("a paid tier shows its name, a pending move down and the vCPU limit", async () => {
163
+ routes({
164
+ "GET /api/billing/subscription": () => reply(200, {
165
+ ...paid, tier: "pro_499", pendingTier: "pro_99", priceCents: 49900, includedCents: 49900, tiers,
166
+ limits: { tier: "pro_499", replicasPerApp: 5, sandboxVcpu: 1200, maxSandboxCpus: 8 },
167
+ }),
168
+ });
169
+ await run(["billing"]);
170
+ const text = out();
171
+ expect(text).toContain("Pro 20x active");
172
+ expect(text).toContain("$499/month");
173
+ expect(text).toMatch(/Next period: moves to Pro 5x on \w{3} \d+, \d{4}\. Run lizard billing tier 20x to stay on Pro 20x\./);
174
+ expect(text).toContain("Sandboxes: up to 1,200 vCPU at once");
175
+ });
176
+
156
177
  test("no plan offers the trial", async () => {
157
178
  routes({ "GET /api/billing/subscription": () => reply(200, { ...none, trial: { ...none.trial, promoCode: "ROST", days: 31, creditCents: 10000 } }) });
158
179
  await run(["billing"]);
159
180
  const text = out();
160
181
  expect(text).toContain("No plan");
161
- expect(text).toContain("Start a 31-day Pro trial with $100 in credits: lizard billing start");
182
+ expect(text).toContain("Start a 31-day Pro trial with $100 of usage: lizard billing start");
162
183
  expect(text).toContain("No charge today, then $19/month.");
163
184
  expect(text).toContain("Promo code: ROST");
164
185
  });
@@ -167,7 +188,7 @@ describe("lizard billing (status)", () => {
167
188
  routes({ "GET /api/billing/subscription": () => reply(200, { ...none, status: "canceled", trial: { ...none.trial, eligible: false } }) });
168
189
  await run(["billing"]);
169
190
  expect(out()).toContain("Pro has ended.");
170
- expect(out()).toContain("Start Pro: $19/month, with $19 in credits each month: lizard billing start");
191
+ expect(out()).toContain("Start Pro: $19/month, with $19 of usage included each month: lizard billing start");
171
192
  });
172
193
 
173
194
  test("enterprise is invoiced monthly", async () => {
@@ -249,7 +270,7 @@ describe("lizard billing actions", () => {
249
270
  });
250
271
  await run(["billing", "start", "--return-url", "/projects/abc", "--no-open"]);
251
272
  expect(calls()).toEqual([{ key: "POST /api/billing/subscription/checkout", body: { returnUrl: "/projects/abc" } }]);
252
- expect(out()).toContain("Your 7-day trial includes $5 in credits. No charge today, then $19/month.");
273
+ expect(out()).toContain("Your 7-day trial includes $5 of usage. No charge today, then $19/month.");
253
274
  expect(out()).toContain("https://checkout.stripe.com/c/pay/cs_1");
254
275
  });
255
276
 
@@ -257,13 +278,73 @@ describe("lizard billing actions", () => {
257
278
  const session = { url: "https://checkout.stripe.com/c/pay/cs_2", sessionId: "cs_2", trialDays: null, trialCreditCents: null };
258
279
  routes({ "POST /api/billing/subscription/checkout": () => reply(200, session) });
259
280
  await run(["billing", "start", "--no-open"]);
260
- expect(out()).toContain("Pro starts today: $19/month, with $19 in credits each month.");
281
+ expect(out()).toContain("Pro starts today: $19/month, with $19 of usage included each month.");
261
282
  setJSONMode(true);
262
283
  stdout = [];
263
284
  await run(["billing", "start"]);
264
285
  expect(JSON.parse(stdout.join("\n"))).toEqual(session);
265
286
  });
266
287
 
288
+ test("start --tier opens Checkout for Pro 5x, charged from day one", async () => {
289
+ routes({ "POST /api/billing/subscription/checkout": () => reply(200, { url: "https://checkout.stripe.com/c/pay/cs_5", sessionId: "cs_5", trialDays: null, trialCreditCents: null }) });
290
+ await run(["billing", "start", "--tier", "5x", "--no-open"]);
291
+ expect(calls()).toEqual([{ key: "POST /api/billing/subscription/checkout", body: { tier: "pro_99" } }]);
292
+ expect(out()).toContain("Pro 5x starts today and is charged from day one.");
293
+ await expect(run(["billing", "start", "--tier", "10x"])).rejects.toThrow('Unknown tier "10x". Use pro, 5x or 20x.');
294
+ });
295
+
296
+ test("tier moves up now, down next period, and cancels a pending move", async () => {
297
+ const at = Date.UTC(2026, 10, 20, 12);
298
+ const onPro = { ...paid, tier: "pro", pendingTier: null, tiers };
299
+ routes({
300
+ "GET /api/billing/subscription": () => reply(200, onPro),
301
+ "POST /api/billing/subscription/tier": () => reply(200, { status: "upgraded", tier: "pro_99", pendingTier: null, effectiveAt: now, invoiceUrl: null }),
302
+ });
303
+ await expect(run(["billing", "tier", "5x"])).rejects.toThrow("Use -y to confirm");
304
+ await run(["billing", "tier", "5x", "-y"]);
305
+ expect(calls().at(-1)).toEqual({ key: "POST /api/billing/subscription/tier", body: { tier: "pro_99" } });
306
+ expect(err()).toContain("You are on Pro 5x now.");
307
+
308
+ routes({
309
+ "GET /api/billing/subscription": () => reply(200, { ...onPro, tier: "pro_99" }),
310
+ "POST /api/billing/subscription/tier": () => reply(200, { status: "scheduled", tier: "pro_99", pendingTier: "pro", effectiveAt: at, invoiceUrl: null }),
311
+ });
312
+ await run(["billing", "tier", "pro", "-y"]);
313
+ expect(err()).toContain("Pro starts on Nov 20, 2026. Until then you keep Pro 5x.");
314
+
315
+ routes({
316
+ "GET /api/billing/subscription": () => reply(200, { ...onPro, tier: "pro_99", pendingTier: "pro" }),
317
+ "POST /api/billing/subscription/tier": () => reply(200, { status: "unchanged", tier: "pro_99", pendingTier: null, effectiveAt: null, invoiceUrl: null }),
318
+ });
319
+ await run(["billing", "tier", "pro-5x", "-y"]);
320
+ expect(err()).toContain("You stay on Pro 5x. The move to Pro is cancelled.");
321
+
322
+ routes({
323
+ "GET /api/billing/subscription": () => reply(200, onPro),
324
+ "POST /api/billing/subscription/tier": () => reply(200, { status: "requires_action", tier: "pro", pendingTier: null, effectiveAt: null, invoiceUrl: "https://invoice.stripe.com/i/up" }),
325
+ });
326
+ await run(["billing", "tier", "20x", "-y", "--no-open"]);
327
+ expect(out()).toContain("Your bank needs you to confirm the payment. You stay on Pro until you do:");
328
+ expect(out()).toContain("https://invoice.stripe.com/i/up");
329
+ });
330
+
331
+ test("tier on the current tier asks nothing and says so", async () => {
332
+ routes({
333
+ "GET /api/billing/subscription": () => reply(200, { ...paid, tier: "pro", pendingTier: null, tiers }),
334
+ "POST /api/billing/subscription/tier": () => reply(200, { status: "unchanged", tier: "pro", pendingTier: null, effectiveAt: null, invoiceUrl: null }),
335
+ });
336
+ await run(["billing", "tier", "pro"]);
337
+ expect(err()).toContain("You are already on Pro.");
338
+ });
339
+
340
+ test("tier passes the platform's refusal through", async () => {
341
+ routes({
342
+ "GET /api/billing/subscription": () => reply(200, { ...base, tier: "pro", tiers }),
343
+ "POST /api/billing/subscription/tier": () => reply(409, { error: "TRIAL_ACTIVE", message: "Start Pro now to change tiers." }),
344
+ });
345
+ await expect(run(["billing", "tier", "5x", "-y"])).rejects.toMatchObject({ status: 409, code: "TRIAL_ACTIVE" });
346
+ });
347
+
267
348
  test("start passes the platform's refusal through", async () => {
268
349
  routes({
269
350
  "POST /api/billing/subscription/checkout": () => reply(409, { error: "ALREADY_SUBSCRIBED", message: "This account already has Pro" }),
@@ -279,7 +360,7 @@ describe("lizard billing actions", () => {
279
360
  test("start-now charges and reports each outcome", async () => {
280
361
  routes({ "POST /api/billing/subscription/start-now": () => reply(200, { status: "active" }) });
281
362
  await run(["billing", "start-now", "-y"]);
282
- expect(err()).toContain("Pro is active. We charged $19 and added $19 in credits for this month.");
363
+ expect(err()).toContain("Pro is active. We charged $19, and this month includes $19 of usage.");
283
364
 
284
365
  routes({ "POST /api/billing/subscription/start-now": () => reply(200, { status: "requires_action", invoiceUrl: "https://invoice.stripe.com/i/3ds" }) });
285
366
  await run(["billing", "start-now", "-y", "--no-open"]);
@@ -313,7 +394,7 @@ describe("lizard billing actions", () => {
313
394
  });
314
395
  await run(["billing", "promo", "ROST"]);
315
396
  expect(calls()).toEqual([{ key: "POST /api/billing/promo/redeem", body: { code: "ROST" } }]);
316
- expect(err()).toContain("Code ROST saved: a 31-day Pro trial with $100 in credits. Start it with `lizard billing start`.");
397
+ expect(err()).toContain("Code ROST saved: a 31-day Pro trial with $100 of usage. Start it with `lizard billing start`.");
317
398
  });
318
399
 
319
400
  test("promo errors keep their code", async () => {
@@ -330,18 +411,26 @@ describe("lizard billing actions", () => {
330
411
  });
331
412
  });
332
413
 
414
+ describe("parseTier", () => {
415
+ test("takes the names people type", () => {
416
+ expect(["pro", "1x", "Pro"].map(parseTier)).toEqual(["pro", "pro", "pro"]);
417
+ expect(["5x", "pro-5x", "Pro 5x", "pro_99", "99"].map(parseTier)).toEqual(Array(5).fill("pro_99"));
418
+ expect(["20x", "pro-20x", "pro_499", "499"].map(parseTier)).toEqual(Array(4).fill("pro_499"));
419
+ });
420
+ });
421
+
333
422
  describe("describePromo", () => {
334
423
  test("a code applied to the running trial", () => {
335
424
  expect(describePromo({
336
425
  status: "applied", code: "ROST", creditCents: 10000, expiresAt: Date.UTC(2026, 10, 7, 12), balanceCents: 0,
337
426
  trialDays: 31, trialCreditCents: 10000, appliesTo: "current_trial",
338
- })).toBe("Your trial now runs 31 days with $100 in credits, until Nov 7, 2026.");
427
+ })).toBe("Your trial now runs 31 days with $100 of usage, until Nov 7, 2026.");
339
428
  });
340
429
 
341
430
  test("an older server's answers", () => {
342
431
  expect(describePromo({ status: "applied", creditCents: 2500, expiresAt: null, balanceCents: 3000 }))
343
432
  .toBe("Redeemed $25.00. New balance: $30.00.");
344
433
  expect(describePromo({ status: "pending_payment_method", creditCents: 2500, expiresAt: null, balanceCents: 0 }))
345
- .toBe("Code saved: $25.00 in credits. They unlock when you start your trial in Billing.");
434
+ .toBe("Code saved: $25.00 of trial usage. It unlocks when you start your trial in Billing.");
346
435
  });
347
436
  });
@@ -172,7 +172,7 @@ describe("account state", () => {
172
172
  });
173
173
 
174
174
  test("instructions say when not to touch billing", () => {
175
- expect(accountInstruction("trial_available", none)).toContain("7-day Pro trial with $5 in credits");
175
+ expect(accountInstruction("trial_available", none)).toContain("7-day Pro trial with $5 of usage");
176
176
  expect(accountInstruction("trial_available", none)).toContain("lizard billing start --json");
177
177
  expect(accountInstruction("subscription_required", none)).toContain("do NOT promise one");
178
178
  expect(accountInstruction("active", null)).toContain("Do NOT open billing");
@@ -180,7 +180,7 @@ describe("account state", () => {
180
180
  const now = Date.now();
181
181
  const trialing = { ...none, plan: "pro", status: "trialing", trial: { ...none.trial, endsAt: now + 3 * DAY, remainingCents: 380 } };
182
182
  expect(accountInstruction("trialing", trialing, now)).toBe(
183
- "The Pro trial is on (3 days left, $3.80 of trial credits left). Do NOT open billing or start a subscription.",
183
+ "The Pro trial is on (3 days left, $3.80 of trial usage left). Do NOT open billing or start a subscription.",
184
184
  );
185
185
  });
186
186
 
@@ -331,16 +331,16 @@ describe("metrics --cost", () => {
331
331
  mockCost({ plan: "pro", status: "active", period: { kind: "paid", ...period } });
332
332
  await run(["--cost"]);
333
333
  expect(api.get).toHaveBeenCalledWith("/api/billing/subscription?workspaceId=workspace-test");
334
- expect(lines.join("\n").replace(/\x1b\[[0-9;]*m/g, "")).toContain("Pro $31.40 of $19 in monthly credits used, overage $12.40");
334
+ expect(lines.join("\n").replace(/\x1b\[[0-9;]*m/g, "")).toContain("Pro $31.40 used of $19 included, overage $12.40");
335
335
  });
336
336
 
337
- it("shows trial credits left during the trial", async () => {
337
+ it("shows trial usage left during the trial", async () => {
338
338
  vi.mocked(isJSONMode).mockReturnValue(false);
339
339
  const lines: string[] = [];
340
340
  vi.spyOn(console, "log").mockImplementation((...a: unknown[]) => { lines.push(a.join(" ")); });
341
341
  mockCost({ plan: "pro", status: "trialing", period: { ...period, kind: "trial", includedCents: 500, usedCents: 120, overageCents: 0 } });
342
342
  await run(["--cost"]);
343
- expect(lines.join("\n").replace(/\x1b\[[0-9;]*m/g, "")).toContain("Pro trial $1.20 of $5 in trial credits used, $3.80 left");
343
+ expect(lines.join("\n").replace(/\x1b\[[0-9;]*m/g, "")).toContain("Pro trial $1.20 used of $5 included, $3.80 left");
344
344
  });
345
345
 
346
346
  it("adds proCredits to JSON for Pro, and nothing for prepaid credits or older servers", async () => {