create-ailk 0.45.0 → 0.46.1

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.
Files changed (42) hide show
  1. package/README.md +6 -3
  2. package/component-catalog.json +217 -4
  3. package/component-catalog.md +10 -7
  4. package/dist/lib/env-catalog.js +1 -1
  5. package/dist/lib/import-mdx.js +10 -2
  6. package/dist/seed-workspace.d.ts +1 -1
  7. package/dist/seed-workspace.js +10 -3
  8. package/dist/surfaces.js +1 -1
  9. package/package.json +3 -3
  10. package/templates/apps/api/.env.example +23 -0
  11. package/templates/apps/api/CLAUDE.md +13 -6
  12. package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
  13. package/templates/apps/mcp/.env.example +8 -0
  14. package/templates/apps/mcp/CLAUDE.md +22 -6
  15. package/templates/apps/web/.env.example +1 -1
  16. package/templates/apps/web/CLAUDE.md +80 -16
  17. package/templates/apps/web/app/.well-known/mcp.json/route.ts +6 -7
  18. package/templates/apps/web/app/[locale]/layout.tsx +10 -7
  19. package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
  20. package/templates/apps/web/app/api/site-status/route.ts +62 -0
  21. package/templates/apps/web/app/llms.txt/route.ts +3 -3
  22. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
  23. package/templates/apps/web/app/openapi.json/route.ts +10 -9
  24. package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
  25. package/templates/apps/web/auth.ts +25 -1
  26. package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +10 -3
  27. package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +61 -0
  28. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +384 -1
  29. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +675 -0
  30. package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
  31. package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
  32. package/templates/apps/web/lib/mcp-oauth.ts +64 -0
  33. package/templates/apps/web/lib/mcp-served-tools.ts +51 -9
  34. package/templates/apps/web/lib/offerings-pricing.ts +173 -20
  35. package/templates/apps/web/lib/pricing-page.ts +382 -43
  36. package/templates/apps/web/lib/site-brand.tsx +1 -7
  37. package/templates/apps/web/lib/site-visibility.ts +45 -0
  38. package/templates/apps/web/messages/en.json +9 -0
  39. package/templates/apps/web/middleware.ts +16 -1
  40. package/templates/apps/web/src/lib/routes.ts +3 -3
  41. package/versions.json +51 -51
  42. package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
@@ -13,7 +13,15 @@
13
13
  * - anything else (expired, empty, a failed read) — the site's contact
14
14
  * email in place of those sections, never an error (D5).
15
15
  * `pricingSections` runs that choice per page, narrowed to the page's own
16
- * `plans` (#10044 D4); `plans: []` reads no Stripe data at all.
16
+ * `plans` (#10044 D4); `plans: []` reads no Stripe data at all. A `pricing`
17
+ * section that lists its own `offeringPlans` is a plan group (#12103 D2): it
18
+ * shows exactly those plans' Stripe cards, and none is removed.
19
+ *
20
+ * A section's `source` (#12140, spec
21
+ * docs/specs/12140-pricing-sections-bind-to-offerings-spec.md D2) says where
22
+ * its plans come from: `offerings` binds it to the shown set in the layout its
23
+ * own `variant` names; `written` keeps it as authored, never linking the
24
+ * Offerings checkout. A page with no `source` anywhere renders as before.
17
25
  *
18
26
  * Stripe text reaches markup only as React text through `offeringsPricing`,
19
27
  * and JSON-LD only through renderPage's serializer (T4).
@@ -21,6 +29,8 @@
21
29
  * Base tree: no paid import, no `oss: false`.
22
30
  */
23
31
  import { offerings } from "@working-theory/api-client";
32
+ import type { DetailPage } from "@working-theory/site-pages/lib/route-family";
33
+ import { contactFormText } from "@working-theory/site-pages/pages/contact/contact-form-text";
24
34
  import { ContactFallback } from "@working-theory/ui";
25
35
  import {
26
36
  LOOKUP_KEY_PLAN_PATTERN,
@@ -29,16 +39,15 @@ import {
29
39
  import { getTranslations } from "next-intl/server";
30
40
  import { createElement, type ReactNode } from "react";
31
41
 
32
- import { contactFormText } from "@working-theory/site-pages/pages/contact/contact-form-text";
33
- import { readSiteContactEmail } from "./site-contact-email";
34
-
35
42
  import { browserApiOrigin } from "./api-origin.generated";
36
43
  import {
44
+ OFFERINGS_CHECKOUT_PATH,
37
45
  offeringsPricing,
38
46
  type OfferingsPricing,
39
47
  type OfferingsPricingLabels,
40
48
  } from "./offerings-pricing";
41
- import type { DetailPage } from "@working-theory/site-pages/lib/route-family";
49
+ import { readSiteContactEmail } from "./site-contact-email";
50
+
42
51
 
43
52
  type PricingSection = Extract<PageSection, { type: "pricing" }>;
44
53
  type PricingData = PricingSection["data"];
@@ -161,7 +170,9 @@ export async function offeringsCopy(locale: string): Promise<{
161
170
  addonsHeadline: string;
162
171
  }> {
163
172
  const t = await getTranslations({ locale, namespace: "pricingOfferings" });
164
- const period = (key: "monthly" | "annual" | "oneTime") => {
173
+ const period = (
174
+ key: "monthly" | "annual" | "oneTime" | "billedYearly",
175
+ ) => {
165
176
  const phrase = t(key, KEEP_AMOUNT_PLACEHOLDER);
166
177
  return (amount: string) => phrase.replace("{amount}", () => amount);
167
178
  };
@@ -172,6 +183,7 @@ export async function offeringsCopy(locale: string): Promise<{
172
183
  monthly: period("monthly"),
173
184
  annual: period("annual"),
174
185
  oneTime: period("oneTime"),
186
+ billedYearly: period("billedYearly"),
175
187
  withRequired: (plan, required) =>
176
188
  t("withRequired", KEEP_BUNDLE_PLACEHOLDERS)
177
189
  .replace("{plan}", () => plan)
@@ -187,8 +199,13 @@ export async function offeringsCopy(locale: string): Promise<{
187
199
  };
188
200
  }
189
201
 
190
- /** The authored section copy a Stripe section keeps — never a plan or price fact. */
202
+ /**
203
+ * The authored section copy a Stripe section keeps — never a plan or price
204
+ * fact. `cardLayout` (#12103 D6) is also re-applied over the mapper's own
205
+ * layout by `stripePlansSection`, so an authored one wins.
206
+ */
191
207
  const AUTHORED_COPY_FIELDS = [
208
+ "cardLayout",
192
209
  "eyebrow",
193
210
  "headline",
194
211
  "description",
@@ -202,6 +219,9 @@ const AUTHORED_COPY_FIELDS = [
202
219
  "surface",
203
220
  "note",
204
221
  "collapseFeaturesOnMobile",
222
+ // #12141 D9 — the plan bar's options, so a connected section keeps them.
223
+ "planBar",
224
+ "comparisonPlanBar",
205
225
  ] as const satisfies readonly (keyof PricingData)[];
206
226
 
207
227
  function authoredCopy(
@@ -220,50 +240,262 @@ function isPricing(section: PageSection): section is PricingSection {
220
240
  return section.type === "pricing";
221
241
  }
222
242
 
243
+ /** A section bound to the workspace's Offerings (#12140 D1). */
244
+ function isBound(section: PageSection): section is PricingSection {
245
+ return isPricing(section) && section.data.source === "offerings";
246
+ }
247
+
248
+ /** A section whose plans stay as written on a connected page (#12140 D1). */
249
+ function isWritten(section: PageSection): section is PricingSection {
250
+ return isPricing(section) && section.data.source === "written";
251
+ }
252
+
253
+ /** A section with no `source` — every pricing section before #12140. */
254
+ function isUnbound(section: PageSection): section is PricingSection {
255
+ return isPricing(section) && section.data.source === undefined;
256
+ }
257
+
258
+ /**
259
+ * Whether `href` reaches the Offerings checkout route, read as a browser
260
+ * resolves it — a relative, absolute or dot-segment form alike, on any host,
261
+ * whatever the case (#12140 D2 rule 7). The path is read percent-decoded too,
262
+ * as the router decodes it, so `/api/%6Ffferings/checkout` is caught. An href
263
+ * no URL parser accepts is one a browser cannot follow either.
264
+ */
265
+ function linksOfferingsCheckout(href: string | undefined): boolean {
266
+ if (href === undefined) return false;
267
+ const base = "https://site.invalid";
268
+ const reaches = (path: string) =>
269
+ path.toLowerCase().startsWith(OFFERINGS_CHECKOUT_PATH);
270
+ let path: string;
271
+ try {
272
+ path = new URL(href, base).pathname;
273
+ } catch {
274
+ return false;
275
+ }
276
+ if (reaches(path)) return true;
277
+ try {
278
+ return reaches(new URL(decodeURIComponent(path), base).pathname);
279
+ } catch {
280
+ return false;
281
+ }
282
+ }
283
+
284
+ type PricingPlan = PricingData["plans"][number];
285
+
286
+ function sellsOfferings(plan: PricingPlan): boolean {
287
+ return (
288
+ linksOfferingsCheckout(plan.cta.href) ||
289
+ linksOfferingsCheckout(plan.annualCtaHref)
290
+ );
291
+ }
292
+
293
+ type ComparisonGroups = NonNullable<PricingData["comparisonGroups"]>;
294
+
295
+ /** Whether any comparison cell's `link` reaches the Offerings checkout. */
296
+ function cellsSellOfferings(groups: ComparisonGroups | undefined): boolean {
297
+ return (groups ?? []).some((group) =>
298
+ group.rows.some((row) =>
299
+ Object.values(row.values).some(
300
+ (value) =>
301
+ typeof value === "object" && linksOfferingsCheckout(value.link?.href),
302
+ ),
303
+ ),
304
+ );
305
+ }
306
+
307
+ /**
308
+ * A written section with every card, extra tier and add-on tile that links the
309
+ * Offerings checkout dropped, and every comparison cell's link that does
310
+ * (#12140 D2 rule 7), so a written price can never sell an Offerings Price;
311
+ * the section itself when nothing is dropped.
312
+ */
313
+ function withoutCheckoutLinks(section: PricingSection): PricingSection {
314
+ const { extraTier, ...data } = section.data;
315
+ const plans = data.plans.filter((plan) => !sellsOfferings(plan));
316
+ const addons = data.addons?.filter(
317
+ (addon) => !linksOfferingsCheckout(addon.cta?.href),
318
+ );
319
+ const dropTier = extraTier !== undefined && sellsOfferings(extraTier);
320
+ const dropCells = cellsSellOfferings(data.comparisonGroups);
321
+ if (
322
+ plans.length === data.plans.length &&
323
+ addons?.length === data.addons?.length &&
324
+ !dropTier &&
325
+ !dropCells
326
+ )
327
+ return section;
328
+ return {
329
+ ...section,
330
+ data: {
331
+ ...data,
332
+ plans,
333
+ ...(addons !== undefined ? { addons } : {}),
334
+ ...(dropCells && data.comparisonGroups
335
+ ? { comparisonGroups: withoutCellLinks(data.comparisonGroups, true) }
336
+ : {}),
337
+ ...(extraTier !== undefined && !dropTier ? { extraTier } : {}),
338
+ },
339
+ };
340
+ }
341
+
342
+ /**
343
+ * The page's comparison grid with each object cell's `link` dropped (#12140
344
+ * D6): its cells are hand-written, so a bound section carries no authored href.
345
+ * With `checkoutOnly` (a written section, D2 rule 7), only a link that reaches
346
+ * the Offerings checkout is dropped.
347
+ */
348
+ function withoutCellLinks(
349
+ groups: ComparisonGroups,
350
+ checkoutOnly = false,
351
+ ): ComparisonGroups {
352
+ return groups.map((group) => ({
353
+ ...group,
354
+ rows: group.rows.map((row) => ({
355
+ ...row,
356
+ values: Object.fromEntries(
357
+ Object.entries(row.values).map(([key, value]) => {
358
+ if (typeof value !== "object") return [key, value];
359
+ if (checkoutOnly && !linksOfferingsCheckout(value.link?.href))
360
+ return [key, value];
361
+ const { link: _, ...cell } = value;
362
+ return [key, cell];
363
+ }),
364
+ ),
365
+ })),
366
+ }));
367
+ }
368
+
223
369
  /** Where a section with no slot goes: after a leading hero, else first. */
224
370
  function insertionIndex(sections: PageSection[]): number {
225
371
  return sections[0]?.type === "hero" ? 1 : 0;
226
372
  }
227
373
 
374
+ /** A non-`addons` pricing section — a plans section. */
375
+ function isPlansSection(section: PageSection): section is PricingSection {
376
+ return isPricing(section) && section.data.variant !== "addons";
377
+ }
378
+
228
379
  /**
229
- * The page's sections with the Stripe fragments in place of its authored
230
- * `pricing` sections (D4). The first non-`addons` pricing section is the
231
- * plans slot and the first `addons` one the add-ons slot; every other pricing
232
- * section, and a slot whose fragment is `null`, is removed. A fragment with no
233
- * slot is inserted after a leading hero (the add-ons directly after the
234
- * plans). No other section moves.
380
+ * Each plan group's Stripe plans fragment (#12103 D2), keyed by its section:
381
+ * `null` when none of the group's plans is shown.
235
382
  */
236
- export function withOfferings(
237
- sections: PageSection[],
238
- pricing: OfferingsPricing,
239
- plan: string | undefined,
240
- recommendedLabel: string,
241
- addonsHeadline: string,
242
- ): PageSection[] {
243
- const plansSlot = sections.find(
244
- (s): s is PricingSection => isPricing(s) && s.data.variant !== "addons",
383
+ export type OfferingsGroups = ReadonlyMap<PricingSection, PricingData | null>;
384
+
385
+ /**
386
+ * The page's Stripe fragments from one shown-set read (#12103 D2). Each plans
387
+ * section that lists `offeringPlans` is mapped alone, for exactly those plans
388
+ * (its add-ons discarded), into `groups`. `pricing` is the page-level mapping
389
+ * — the page's `plans`, less every plan a group lists — for the unlisted plans
390
+ * slot and the add-ons slot. A page with no group maps exactly as before, with
391
+ * `groups` empty.
392
+ *
393
+ * Each bound section (#12140 D3, D7) is mapped alone into `groups` too, for
394
+ * its own `offeringPlans` else the page's `plans`: a plans section in the
395
+ * layout its `variant` names, an `addons` section to its add-on tiles. The
396
+ * plans a bound section lists are excluded from the page-level mapping.
397
+ */
398
+ export function offeringsFragments(
399
+ declared: PageSection[],
400
+ shownSet: unknown,
401
+ options: {
402
+ locale: string;
403
+ labels: OfferingsPricingLabels;
404
+ plans: readonly string[] | undefined;
405
+ },
406
+ ): { pricing: OfferingsPricing | null; groups: OfferingsGroups } {
407
+ const { locale, labels, plans } = options;
408
+ const listed = declared.filter(
409
+ (s): s is PricingSection =>
410
+ isUnbound(s) && isPlansSection(s) && s.data.offeringPlans !== undefined,
245
411
  );
246
- const addonsSlot = sections.find(
247
- (s): s is PricingSection => isPricing(s) && s.data.variant === "addons",
412
+ const bound = declared.filter(isBound);
413
+ const exclude = [...listed, ...bound].flatMap(
414
+ (s) => s.data.offeringPlans ?? [],
248
415
  );
249
- const recommend =
250
- plan !== undefined && LOOKUP_KEY_PLAN_PATTERN.test(plan) ? plan : undefined;
251
- const plansSection: PricingSection | null = pricing.plans && {
252
- id: plansSlot?.id ?? "offerings-plans",
416
+ const groups = new Map<PricingSection, PricingData | null>(
417
+ listed.map((section) => [
418
+ section,
419
+ offeringsPricing(shownSet, {
420
+ locale,
421
+ labels,
422
+ plans: section.data.offeringPlans,
423
+ })?.plans ?? null,
424
+ ]),
425
+ );
426
+ for (const section of bound) {
427
+ const { variant, offeringPlans } = section.data;
428
+ const addons = variant === "addons";
429
+ const mapped = offeringsPricing(shownSet, {
430
+ locale,
431
+ labels,
432
+ plans: offeringPlans ?? plans,
433
+ ...(variant === "addons"
434
+ ? {}
435
+ : { layout: variant ?? "three-tiers-with-toggle" }),
436
+ });
437
+ groups.set(section, (addons ? mapped?.addons : mapped?.plans) ?? null);
438
+ }
439
+ const pricing = offeringsPricing(shownSet, {
440
+ locale,
441
+ labels,
442
+ plans,
443
+ ...(exclude.length > 0 ? { exclude } : {}),
444
+ });
445
+ return { pricing, groups };
446
+ }
447
+
448
+ /** What a bound section keeps from the page beside its copy (#12140 D6). */
449
+ const BOUND_KEPT_FIELDS = [
450
+ "source",
451
+ "keyPointsPanel",
452
+ "narrative",
453
+ "bandSurface",
454
+ ] as const satisfies readonly (keyof PricingData)[];
455
+
456
+ /**
457
+ * One Stripe plans section in `slot`'s place: the slot's authored copy, the
458
+ * mapper's fragment, the slot's own `cardLayout` over the mapper's (#12103
459
+ * D6; `billingToggle` stays the mapper's computed one), and a `?plan=`
460
+ * recommendation (#8842) — applied by each section to its own cards.
461
+ *
462
+ * A bound slot (#12140 D6) also keeps its `source`, its band parts, its
463
+ * comparison grid (cell links dropped) and its own `features` over the
464
+ * mapper's; never an authored plan, extra tier or comparison-cell link.
465
+ */
466
+ function stripePlansSection(
467
+ slot: PricingSection | undefined,
468
+ fragment: PricingData,
469
+ recommend: string | undefined,
470
+ recommendedLabel: string,
471
+ ): PricingSection {
472
+ const bound = slot !== undefined && isBound(slot);
473
+ const cardLayout = slot?.data.cardLayout ?? fragment.cardLayout;
474
+ const features = bound
475
+ ? (slot.data.features ?? fragment.features)
476
+ : undefined;
477
+ const comparisonGroups = bound ? slot.data.comparisonGroups : undefined;
478
+ return {
479
+ id: slot?.id ?? "offerings-plans",
253
480
  type: "pricing",
254
481
  data: {
255
- ...authoredCopy(plansSlot),
256
- ...pricing.plans,
482
+ ...authoredCopy(slot, bound ? BOUND_KEPT_FIELDS : []),
483
+ ...(comparisonGroups
484
+ ? { comparisonGroups: withoutCellLinks(comparisonGroups) }
485
+ : {}),
486
+ ...fragment,
487
+ ...(cardLayout !== undefined ? { cardLayout } : {}),
488
+ ...(features !== undefined ? { features } : {}),
257
489
  // A `?plan=` recommendation moves the mapper's highlight onto the named
258
490
  // plan and wears `recommendedLabel` (#8842); the mapper's own
259
491
  // "Recommended" pill label would ride along as a second label, so it is
260
492
  // dropped from every card when a recommendation is in play.
261
493
  ...(recommend !== undefined &&
262
- pricing.plans.plans.some(
494
+ fragment.plans.some(
263
495
  (card) => card.key?.toLowerCase() === recommend.toLowerCase(),
264
496
  )
265
497
  ? {
266
- plans: pricing.plans.plans.map(
498
+ plans: fragment.plans.map(
267
499
  ({ highlightLabel: _, ...card }) => card,
268
500
  ),
269
501
  }
@@ -273,6 +505,49 @@ export function withOfferings(
273
505
  ...(recommend !== undefined ? { recommended: recommend } : {}),
274
506
  } as PricingData,
275
507
  };
508
+ }
509
+
510
+ /**
511
+ * The page's sections with the Stripe fragments in place of its authored
512
+ * `pricing` sections (D4). Each plan group in `groups` (#12103 D2) becomes
513
+ * its own Stripe section where it was, or is removed when its fragment is
514
+ * `null`. Of the other sections, the first non-`addons` pricing section is the
515
+ * plans slot and the first `addons` one the add-ons slot; every other pricing
516
+ * section, and a slot whose fragment is `null`, is removed. A fragment with no
517
+ * slot is inserted after a leading hero (the add-ons directly after the last
518
+ * plans section) — except the plans fragment on a page with plan groups, which
519
+ * has said what it shows and gets no inserted section. No other section moves.
520
+ *
521
+ * With `source` (#12140 D2): each bound section in `groups` is placed the same
522
+ * way, an `addons` one as add-on tiles; each written section stays where it
523
+ * is, without Offerings checkout links, taking a `{plan}`-grammar `?plan=`;
524
+ * the two slots are chosen among unbound sections only; and a page that
525
+ * declares a `source` gets no inserted section.
526
+ */
527
+ export function withOfferings(
528
+ sections: PageSection[],
529
+ pricing: OfferingsPricing,
530
+ plan: string | undefined,
531
+ recommendedLabel: string,
532
+ addonsHeadline: string,
533
+ groups?: OfferingsGroups,
534
+ ): PageSection[] {
535
+ const grouped = groups !== undefined && groups.size > 0;
536
+ const declaresSource = sections.some(
537
+ (s) => isPricing(s) && s.data.source !== undefined,
538
+ );
539
+ const plansSlot = sections.find(
540
+ (s): s is PricingSection =>
541
+ isUnbound(s) && isPlansSection(s) && !groups?.has(s),
542
+ );
543
+ const addonsSlot = sections.find(
544
+ (s): s is PricingSection => isUnbound(s) && s.data.variant === "addons",
545
+ );
546
+ const recommend =
547
+ plan !== undefined && LOOKUP_KEY_PLAN_PATTERN.test(plan) ? plan : undefined;
548
+ const plansSection: PricingSection | null =
549
+ pricing.plans &&
550
+ stripePlansSection(plansSlot, pricing.plans, recommend, recommendedLabel);
276
551
  const addonsSection: PricingSection | null = pricing.addons && {
277
552
  id: addonsSlot?.id ?? "offerings-addons",
278
553
  type: "pricing",
@@ -287,17 +562,62 @@ export function withOfferings(
287
562
  };
288
563
 
289
564
  const placed: PageSection[] = [];
565
+ const stripePlans: PageSection[] = [];
290
566
  for (const section of sections) {
291
567
  if (!isPricing(section)) placed.push(section);
292
- else if (section === plansSlot && plansSection) placed.push(plansSection);
293
- else if (section === addonsSlot && addonsSection)
568
+ else if (section.data.source === "written") {
569
+ const written = withoutCheckoutLinks(section);
570
+ placed.push(
571
+ recommend === undefined
572
+ ? written
573
+ : {
574
+ ...written,
575
+ // Render-time fields the section reads (#8842), not authored ones.
576
+ data: {
577
+ ...written.data,
578
+ recommended: recommend,
579
+ recommendedLabel,
580
+ } as PricingData,
581
+ },
582
+ );
583
+ } else if (
584
+ section.data.source === "offerings" &&
585
+ section.data.variant === "addons"
586
+ ) {
587
+ const fragment = groups?.get(section);
588
+ if (fragment)
589
+ placed.push({
590
+ id: section.id,
591
+ type: "pricing",
592
+ data: {
593
+ ...authoredCopy(section, ["addonLayout", "source"]),
594
+ ...fragment,
595
+ } as PricingData,
596
+ });
597
+ } else if (groups?.has(section)) {
598
+ const fragment = groups.get(section);
599
+ if (fragment) {
600
+ const group = stripePlansSection(
601
+ section,
602
+ fragment,
603
+ recommend,
604
+ recommendedLabel,
605
+ );
606
+ placed.push(group);
607
+ stripePlans.push(group);
608
+ }
609
+ } else if (section === plansSlot && plansSection) {
610
+ placed.push(plansSection);
611
+ stripePlans.push(plansSection);
612
+ } else if (section === addonsSlot && addonsSection)
294
613
  placed.push(addonsSection);
295
614
  }
296
- if (plansSection && !plansSlot) {
615
+ if (plansSection && !plansSlot && !grouped && !declaresSource) {
297
616
  placed.splice(insertionIndex(placed), 0, plansSection);
617
+ stripePlans.push(plansSection);
298
618
  }
299
- if (addonsSection && !addonsSlot) {
300
- const plansAt = plansSection ? placed.indexOf(plansSection) : -1;
619
+ if (addonsSection && !addonsSlot && !declaresSource) {
620
+ const plansAt = Math.max(-1, ...stripePlans.map((s) => placed.indexOf(s)));
301
621
  placed.splice(
302
622
  plansAt >= 0 ? plansAt + 1 : insertionIndex(placed),
303
623
  0,
@@ -365,10 +685,16 @@ export function pagePlans(frontmatter: unknown): string[] | undefined {
365
685
  * One Pricing page's sections in its Offerings state (#10044 D5): `/pricing`'s
366
686
  * three-state choice with the page's own `plans` passed through.
367
687
  * - `plans: []` → the written sections, no Stripe read;
688
+ * - every pricing section `source: written` (#12140 D2 rule 1) → the same,
689
+ * no read;
368
690
  * - unconnected → the written sections (`?plan=` moving the recommendation);
369
691
  * - shown → the page's Stripe cards in place of its `pricing` sections,
370
- * when any of its plans is shown;
692
+ * when any of its plans is shown — each plan group's own plans in its
693
+ * place (#12103 D2), each bound and written section in its place (#12140);
694
+ * a page whose only pricing left is written takes the contact email;
371
695
  * - anything else → the contact email in their place.
696
+ * On the written states a `source: written` section never links the
697
+ * Offerings checkout (#12140 D2 rule 7).
372
698
  */
373
699
  export async function pricingSections(
374
700
  declared: PageSection[],
@@ -379,24 +705,37 @@ export async function pricingSections(
379
705
  },
380
706
  ): Promise<PageSection[]> {
381
707
  const { plans, plan, locale } = options;
382
- const asWritten = () =>
383
- plan ? withRecommendedPlan(declared, plan) : declared;
708
+ const written = declared.some(isWritten)
709
+ ? declared.map((s) => (isWritten(s) ? withoutCheckoutLinks(s) : s))
710
+ : declared;
711
+ const asWritten = () => (plan ? withRecommendedPlan(written, plan) : written);
384
712
  if (plans !== undefined && plans.length === 0) return asWritten();
713
+ const priced = declared.filter(isPricing);
714
+ if (priced.length > 0 && priced.every(isWritten)) return asWritten();
385
715
 
386
716
  const read = await readShownOfferings();
387
717
  if (read.kind === "unconnected") return asWritten();
388
718
  if (read.kind === "shown") {
389
719
  const { labels, recommendedLabel, addonsHeadline } =
390
720
  await offeringsCopy(locale);
391
- const pricing = offeringsPricing(read.shownSet, { locale, labels, plans });
392
- if (pricing && (pricing.plans || pricing.addons)) {
393
- return withOfferings(
721
+ const { pricing, groups } = offeringsFragments(declared, read.shownSet, {
722
+ locale,
723
+ labels,
724
+ plans,
725
+ });
726
+ if (pricing) {
727
+ const placed = withOfferings(
394
728
  declared,
395
729
  pricing,
396
730
  plan,
397
731
  recommendedLabel,
398
732
  addonsHeadline,
733
+ groups,
399
734
  );
735
+ // Every pricing section left but a written one is a Stripe one; none
736
+ // means nothing shown, and written prices never stand in for the
737
+ // catalogue (#12140 D2 rule 5).
738
+ if (placed.some((s) => isPricing(s) && !isWritten(s))) return placed;
400
739
  }
401
740
  }
402
741
  return withContactFallback(declared);
@@ -169,8 +169,6 @@ export interface SiteBrand {
169
169
  siteName: string;
170
170
  description: string;
171
171
  copyrightHolder: string;
172
- /** False when the hub's seo row turns search indexing off (`robots.index: false`). */
173
- indexable: boolean;
174
172
  }
175
173
 
176
174
  /**
@@ -190,8 +188,7 @@ function oneLine(value: string): string {
190
188
  * refilled from `_site.mdx` — `siteName` is `NEXT_PUBLIC_SITE_NAME`, else the
191
189
  * hub `name`; `description` the hub's, else the seo row's, else the neutral
192
190
  * fallback; `copyrightHolder` the hub `legalName`, else the hub `siteName`.
193
- * Otherwise the module's constants, exactly. `indexable` reads the seo row
194
- * whether or not an identity row exists, and fails open. Never rejects.
191
+ * Otherwise the module's constants, exactly. Never rejects.
195
192
  */
196
193
  export async function resolveSiteBrand(): Promise<SiteBrand> {
197
194
  return brandFrom(await readHubSite());
@@ -199,14 +196,12 @@ export async function resolveSiteBrand(): Promise<SiteBrand> {
199
196
 
200
197
  /** `resolveSiteBrand`'s rule over one hub read, so a caller holding the read derives the same brand. */
201
198
  export function brandFrom(hub: HubSite | undefined): SiteBrand {
202
- const indexable = hub?.seo?.robots?.index !== false;
203
199
  const identity = hub?.identity;
204
200
  if (!identity) {
205
201
  return {
206
202
  siteName: SITE_NAME,
207
203
  description: SITE_DESCRIPTION,
208
204
  copyrightHolder: COPYRIGHT_HOLDER,
209
- indexable,
210
205
  };
211
206
  }
212
207
  const siteName =
@@ -217,6 +212,5 @@ export function brandFrom(hub: HubSite | undefined): SiteBrand {
217
212
  oneLine(identity.description ?? hub.seo?.description ?? "") ||
218
213
  FALLBACK_SITE_DESCRIPTION,
219
214
  copyrightHolder: oneLine(identity.legalName ?? "") || siteName,
220
- indexable,
221
215
  };
222
216
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * #11978 D2 — the site's one rule for Hidden (spec
3
+ * docs/specs/11978-one-site-visibility-control-with-spec.md).
4
+ *
5
+ * The site is Hidden when STEALTH is set on its hosting project (the hosting
6
+ * lock) or when the owner's Site visibility switch — the `site.discovery`
7
+ * row, read through `siteDiscoverable()` — is off. The middleware, the locale
8
+ * layout, mcp.json, openapi.json and `/api/site-status` all read it here, so
9
+ * the surfaces act on, and the status route reports, one answer.
10
+ *
11
+ * Edge-safe: it imports no `node:` module, so the middleware can load it.
12
+ */
13
+
14
+ import { siteDiscoverable } from "@working-theory/api-client";
15
+ import { parseStealth } from "@working-theory/web-i18n/stealth";
16
+
17
+ /** STEALTH's own header value, so Hidden is byte-for-byte what STEALTH sends. */
18
+ export const HIDDEN_ROBOTS_HEADER = "noindex, nofollow, noarchive";
19
+
20
+ /**
21
+ * `"hosting"` when STEALTH is set on the hosting project, else `null`. Read
22
+ * through the one shared parse, so an unknown value throws `StealthValueError`.
23
+ */
24
+ export function siteLock(): "hosting" | null {
25
+ return parseStealth(process.env["STEALTH"]) ? "hosting" : null;
26
+ }
27
+
28
+ /**
29
+ * Whether the site is Hidden: the hosting lock, or the owner's switch off.
30
+ * Makes no hub read under the lock. The hub read never rejects
31
+ * (`siteDiscoverable`); an unknown STEALTH value rejects with
32
+ * `StealthValueError`, as it fails the build.
33
+ */
34
+ export async function siteHidden(): Promise<boolean> {
35
+ return siteLock() !== null || !(await siteDiscoverable());
36
+ }
37
+
38
+ /**
39
+ * The discovery files' default `discoverable` dep: Live unless Hidden, so
40
+ * sitemap.xml and both llms.txt copies hide under STEALTH as well as the
41
+ * switch.
42
+ */
43
+ export async function siteLive(): Promise<boolean> {
44
+ return !(await siteHidden());
45
+ }
@@ -140,6 +140,7 @@
140
140
  "monthly": "{amount}/mo",
141
141
  "annual": "{amount}/yr",
142
142
  "oneTime": "{amount} one-time",
143
+ "billedYearly": "billed {amount} yearly",
143
144
  "withRequired": "{plan} + {required}",
144
145
  "depositNote": "{deposit} deposit due today; the balance is invoiced."
145
146
  },
@@ -712,6 +713,13 @@
712
713
  "toolBulletList": "Bulleted list",
713
714
  "toolNumberedList": "Numbered list",
714
715
  "toolLink": "Link",
716
+ "toolTable": "Table",
717
+ "tableInsert": "Insert table",
718
+ "tableAddRow": "Add row below",
719
+ "tableDeleteRow": "Delete row",
720
+ "tableAddColumn": "Add column to the right",
721
+ "tableDeleteColumn": "Delete column",
722
+ "tableDelete": "Delete table",
715
723
  "toolImage": "Insert image",
716
724
  "toolView": "View",
717
725
  "toolRendered": "Rendered — your words, formatted",
@@ -732,6 +740,7 @@
732
740
  "bulletList": "Types - before each line → a bulleted list.",
733
741
  "numberedList": "Types 1. before each line → a numbered list.",
734
742
  "link": "Types [words](address) → a link.",
743
+ "table": "Makes a table; in Markdown, | between cells and | - | under the header. Click a cell, then use this menu to add or remove rows and columns.",
735
744
  "insert": "A meeting, magnet, offer, FAQ or image from your library. AI uses these when it lays out the page.",
736
745
  "changes": "Compare your unsaved edits with the last save."
737
746
  },