create-ailk 0.32.0 → 0.34.0

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 (53) hide show
  1. package/README.md +21 -3
  2. package/component-catalog.json +12 -1
  3. package/component-catalog.md +6 -5
  4. package/dist/export-content.d.ts +6 -3
  5. package/dist/export-content.js +82 -11
  6. package/dist/lib/env-catalog.js +4 -0
  7. package/dist/lib/import-mdx.d.ts +111 -0
  8. package/dist/lib/import-mdx.js +648 -46
  9. package/dist/migrate-content.d.ts +3 -1
  10. package/dist/migrate-content.js +52 -1
  11. package/dist/seed-flows.d.ts +1 -1
  12. package/dist/seed-flows.js +9 -4
  13. package/dist/surfaces.js +1 -0
  14. package/package.json +3 -3
  15. package/templates/apps/api/.env.example +11 -0
  16. package/templates/apps/api/CLAUDE.md +7 -5
  17. package/templates/apps/api/src/lib/__mocks__/prisma.ts +13 -0
  18. package/templates/apps/mcp/CLAUDE.md +4 -2
  19. package/templates/apps/web/CLAUDE.md +4 -1
  20. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +28 -0
  21. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +94 -0
  22. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +77 -0
  23. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +79 -14
  24. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +7 -0
  25. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +7 -0
  26. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +7 -0
  27. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +21 -0
  28. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +15 -9
  29. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +38 -105
  30. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +72 -58
  31. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +249 -0
  32. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +164 -20
  33. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +269 -0
  34. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +179 -0
  35. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +108 -40
  36. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +153 -0
  37. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +151 -0
  38. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +1 -1
  39. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +3 -20
  40. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +2 -9
  41. package/templates/apps/web/auth.ts +22 -6
  42. package/templates/apps/web/lib/__tests__/account-config.test.ts +69 -0
  43. package/templates/apps/web/lib/__tests__/auth-email.test.ts +99 -1
  44. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +20 -0
  45. package/templates/apps/web/lib/account-config.ts +52 -14
  46. package/templates/apps/web/lib/auth-email.ts +87 -5
  47. package/templates/apps/web/lib/mcp-oauth.ts +49 -6
  48. package/templates/apps/web/lib/telemetry-scrub.ts +6 -0
  49. package/templates/apps/web/messages/en.json +26 -1
  50. package/templates/database/seed.ts +7 -7
  51. package/versions.json +48 -48
  52. package/templates/apps/web/app/[locale]/thanks/[slug]/AccountInviteLink.tsx +0 -89
  53. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/AccountInviteLink.test.tsx +0 -104
package/README.md CHANGED
@@ -665,9 +665,15 @@ each directory's own `index.mdx` becomes its `BlogList/index` or
665
665
  `parent` comes from its path, never its frontmatter, and a file the walk skips
666
666
  is listed with the rule it failed. Their fumadocs frontmatter is mapped to
667
667
  the stored fields (`date` →
668
- `publishedAt`, `updated` → `updatedAt`); keys the store does not keep from a
669
- caller (`featured`, `sidebar`, `tags`) are not sent, and `--apply` names them
670
- in one line per file. Each outcome carries `root: "content"` or
668
+ `publishedAt`, `updated` → `updatedAt`); every other key — the template's
669
+ `featured` and `sidebar`, or a site's own such as `imageAlt` or `sources` —
670
+ is sent in the page's `siteFields` under its own name, and a blog post's
671
+ `tags` are sent as its categories (#10806). A key the store cannot keep is
672
+ named with its reason under `--apply`, in one line per file:
673
+ `<path>: not imported — <key> (<reason>); …`. A hub that predates site
674
+ fields and drops them is named too: `<path>: not kept by the hub: <keys> (…)`.
675
+ `export-content` writes `siteFields` back as top-level frontmatter keys.
676
+ Each outcome carries `root: "content"` or
671
677
  `root: "editorial"`, and an editorial line is printed prefixed `editorial: `.
672
678
 
673
679
  ```bash
@@ -698,6 +704,18 @@ AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --apply --api-u
698
704
  and then saved with the errors the editor shows, not `failed`.
699
705
  - The site's dependencies must be installed (`pnpm install`): the pages are
700
706
  read through the site's own `@working-theory/content-adapters`.
707
+ - Every page is written with a live-source mark (#10898): its words already
708
+ ship on the live site, so a heading its page type's template asks for and
709
+ the page lacks is listed as advisory, and publish takes the page. Editing
710
+ the page's words in the hub drops the mark, and the page is then gated as
711
+ any other. A dry run prints a line after each page —
712
+ `<path>: publish — publishable`, `publishable · advisory: missing "<heading>", …`
713
+ or `not publishable · <status> · <code>:<where> "<what>"` — and then
714
+ `publish: publishable <N> (<K> with advisory headings) · not publishable <M>`.
715
+ The verdict is the site's installed `@working-theory/validation`'s, not the
716
+ hub's: it sees no library-file finding, and no layout the hub repairs
717
+ differently. A site whose validation package predates the live-source
718
+ report prints one `publish: not checked` line instead.
701
719
  - Exit 0 when no page failed, 1 when any did (in a dry run, when any would), 2
702
720
  on a refusal (a missing key, workspace id or origin, no `content/`, the
703
721
  adapter not installed), which sends nothing.
@@ -17,7 +17,7 @@
17
17
  "importPath": "@working-theory/ui/blocks",
18
18
  "rootBarrel": "@working-theory/ui",
19
19
  "sourceRoot": "packages/ui/src/blocks",
20
- "count": 107
20
+ "count": 108
21
21
  },
22
22
  {
23
23
  "name": "chrome",
@@ -1695,6 +1695,17 @@
1695
1695
  "descriptionGrade": "strong",
1696
1696
  "sectionType": null
1697
1697
  },
1698
+ {
1699
+ "name": "ScoreBar",
1700
+ "tier": "blocks",
1701
+ "sourcePath": "packages/ui/src/blocks/ScoreBar.tsx",
1702
+ "importPath": "@working-theory/ui/blocks",
1703
+ "exported": true,
1704
+ "description": "One labelled score bar on a scored magnet's results page: a label (the overall score's, or a dimension's name), the points out of the most a respondent could score, the Level name that share falls in, and one bar filled to the evaluator's own `pct` (`evaluateWaitlistScoring` returns `{ points, max, pct, level }` for the total and per dimension).",
1705
+ "descriptionSource": "doc-comment",
1706
+ "descriptionGrade": "strong",
1707
+ "sectionType": null
1708
+ },
1698
1709
  {
1699
1710
  "name": "SectionActionRow",
1700
1711
  "tier": "blocks",
@@ -15,13 +15,13 @@ The component inventory of `@working-theory/ui` and the shells of `@working-theo
15
15
  3. Check the Primitives, Panels and Shells tables too — a low-level control, a collapsible layout container, or a route-level frame lives there, not under Sections or Blocks.
16
16
  4. Only then build. If you do build, you are declaring the capability is genuinely absent.
17
17
 
18
- Inventory: **324 component files** across 16 tiers — 60 sections, 107 blocks, 19 chrome, 79 primitives, 6 panels, 8 shells, 5 docs-blog-blocks, 1 docs-blog-chrome, 2 docs-blog-shells, 2 scheduling-sections, 6 scheduling-blocks, 5 signal-collectors-sections, 9 signal-collectors-blocks, 2 commerce-sections, 12 commerce-blocks, 1 commerce-panels. 321 distinct names: `SchedulerEmbed`, `Separator`, `Tabs` exist in more than one tier as genuinely different components, listed once per tier with its own source path.
18
+ Inventory: **325 component files** across 16 tiers — 60 sections, 108 blocks, 19 chrome, 79 primitives, 6 panels, 8 shells, 5 docs-blog-blocks, 1 docs-blog-chrome, 2 docs-blog-shells, 2 scheduling-sections, 6 scheduling-blocks, 5 signal-collectors-sections, 9 signal-collectors-blocks, 2 commerce-sections, 12 commerce-blocks, 1 commerce-panels. 322 distinct names: `SchedulerEmbed`, `Separator`, `Tabs` exist in more than one tier as genuinely different components, listed once per tier with its own source path.
19
19
 
20
- Description coverage: **320/324** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 240 from the component's own doc-comment header, 35 from its tier barrel's roster line. **4** have none; they are listed under [Undescribed components](#undescribed-components) rather than given a sentence invented from their name.
20
+ Description coverage: **321/325** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 241 from the component's own doc-comment header, 35 from its tier barrel's roster line. **4** have none; they are listed under [Undescribed components](#undescribed-components) rather than given a sentence invented from their name.
21
21
 
22
- Of those, **286** are *strong* — a capability sentence you could match a requirement against — and **34** are *weak*: either one short clause, or a long one that spends itself on wiring (client boundaries, class names, which primitives it composes) instead of on what the thing is for. Weak rows are marked `(weak)` and listed in full under [Weak descriptions](#weak-descriptions). Coverage is 99%, but **findable-without-luck coverage is 88%**.
22
+ Of those, **287** are *strong* — a capability sentence you could match a requirement against — and **34** are *weak*: either one short clause, or a long one that spends itself on wiring (client boundaries, class names, which primitives it composes) instead of on what the thing is for. Weak rows are marked `(weak)` and listed in full under [Weak descriptions](#weak-descriptions). Coverage is 99%, but **findable-without-luck coverage is 88%**.
23
23
 
24
- Per tier, strong out of total: **Sections** 59/60 · **Blocks** 99/107 · **Chrome** 10/19 · **Primitives** 64/79 (4 undescribed) · **Panels** 5/6 · **Shells** 7/8 · **Docs + Blog Blocks** 5/5 · **Docs + Blog Chrome** 1/1 · **Docs + Blog Shells** 0/2 · **Scheduling Sections** 2/2 · **Scheduling Blocks** 6/6 · **Signal-Collectors Sections** 5/5 · **Signal-Collectors Blocks** 8/9 · **Commerce Sections** 2/2 · **Commerce Blocks** 12/12 · **Commerce Panels** 1/1. A tier low on this line is a tier where a capability search is most likely to come up empty on something that exists.
24
+ Per tier, strong out of total: **Sections** 59/60 · **Blocks** 100/108 · **Chrome** 10/19 · **Primitives** 64/79 (4 undescribed) · **Panels** 5/6 · **Shells** 7/8 · **Docs + Blog Blocks** 5/5 · **Docs + Blog Chrome** 1/1 · **Docs + Blog Shells** 0/2 · **Scheduling Sections** 2/2 · **Scheduling Blocks** 6/6 · **Signal-Collectors Sections** 5/5 · **Signal-Collectors Blocks** 8/9 · **Commerce Sections** 2/2 · **Commerce Blocks** 12/12 · **Commerce Panels** 1/1. A tier low on this line is a tier where a capability search is most likely to come up empty on something that exists.
25
25
 
26
26
  That grade is **mechanical**. It counts what it can measure — how much a description adds beyond the component's own name, how much of it is spent on wiring, whether the extraction came out damaged — and it cannot tell a fluent paragraph about the wrong subject from a useful one. A person reading these tables will find more rows unusable than the weak count admits. Treat it as a floor on the problem, not a measurement of it, and read the source before concluding a capability is absent.
27
27
 
@@ -124,7 +124,7 @@ Import: `import { X } from "@working-theory/ui/sections";` (or from the `@workin
124
124
 
125
125
  ---
126
126
 
127
- ## Blocks (107)
127
+ ## Blocks (108)
128
128
 
129
129
  Intermediate composition tiles — the pieces sections are built from. Compose primitives and panels; never import a section.
130
130
 
@@ -215,6 +215,7 @@ Import: `import { X } from "@working-theory/ui/blocks";` (or from the `@working-
215
215
  | `ResponsiveSheet` | ONE component, TWO forms, ONE open pair. Renders its `children` as a Radix Dialog at `md` (768px, --breakpoint-md) and up, and as a full-screen Radix Sheet below it — never both at once. | `import { ResponsiveSheet } from "@working-theory/ui/blocks"` |
216
216
  | `RowGroup` | The bordered box that groups ListRows with hairline dividers. The reference is `packages-paid/admin/design/demos/first-steps/demo.html`'s `.box` (`background:var(--bg);border:1px solid var(--border); border-radius:6px;overflow:hidden`) with `.row{border-top:…}` and `.row:first-child{border-top:0}` — i.e. hairlines BETWEEN rows, none above the first. | `import { RowGroup } from "@working-theory/ui/blocks"` |
217
217
  | `SchedulerEmbed` | A declarative third-party booking iframe. Renders a full-width, border-0, lazy-loaded &lt;iframe> at `src` with a graceful loading skeleton (shown until the iframe's own `load` event fires) and a timeout-gated plain-link fallback beneath it — for environments that block third-party frames (ad blockers, a strict CSP `frame-src`) where the iframe may load blank or never load at all. | `import { SchedulerEmbed } from "@working-theory/ui/blocks"` · `packages/ui/src/blocks/SchedulerEmbed.tsx` |
218
+ | `ScoreBar` | One labelled score bar on a scored magnet's results page: a label (the overall score's, or a dimension's name), the points out of the most a respondent could score, the Level name that share falls in, and one bar filled to the evaluator's own `pct` (`evaluateWaitlistScoring` returns `{ points, max, pct, level }` for the total and per dimension). | `import { ScoreBar } from "@working-theory/ui/blocks"` |
218
219
  | `SectionActionRow` | The bottom-anchored, centered action row a section places BENEATH its own content, at the 44×44px target-size floor. It is the block form of the placement established for `stair-steps`: a bounded 1-2 action list rendered after the section body rather than inside the section header. | `import { SectionActionRow } from "@working-theory/ui/blocks"` |
219
220
  | `SectionHeader` | Alignment-parameterized section header (eyebrow/subtitle/description/supportLink). The same component serves two ranks (headingLevel="section" \| "subsection") and three alignments (align="start" \| "center" \| "end"). It knows nothing about columns/splits/carousels — it is width-flexible and fills whatever container the section places it in. | `import { SectionHeader } from "@working-theory/ui/blocks"` |
220
221
  | `ShareBar` | The reader-facing counterpart to DocsActionBar. Both surfaces share the same SplitButton *affordance + slot* (outline variant, right-justified on the post title row) but fill it with different actions: DocsActionBar carries the AI-ingestion set (Copy page + Open in …), ShareBar carries the social-share set (X · LinkedIn · Bluesky · Copy link). One primitive, two configs. | `import { ShareBar } from "@working-theory/ui/blocks"` |
@@ -6,8 +6,11 @@ export declare class ExportContentRefusedError extends Error {
6
6
  constructor(message: string);
7
7
  }
8
8
  export declare const SPOKE_HINT = "the site's read does not serve this workspace's published version \u2014 is the spoke at --store database?";
9
- /** The site-relative file a stored page is written to, and whether it is editorial. */
10
- export declare function fileFor(targetDir: string, type: string, slug: string, locale: string): {
9
+ /**
10
+ * The site-relative file a stored page is written to, and whether it is
11
+ * editorial. A blog post's `parent` is its series' directory (#10811 D1).
12
+ */
13
+ export declare function fileFor(targetDir: string, type: string, slug: string, locale: string, parent?: string): {
11
14
  path: string;
12
15
  editorial: boolean;
13
16
  };
@@ -51,5 +54,5 @@ export interface ExportContentArgs {
51
54
  workspaceId: string | undefined;
52
55
  help: boolean;
53
56
  }
54
- export declare const EXPORT_CONTENT_HELP = "create-ailk export-content \u2014 write every published page back to its content file.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk export-content [<dir>] [--dry-run] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --dry-run Print what would be written, and write nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe rollback for a cutover: every page the workspace list reports published\nin the default locale is written to the file migrate-content reads it from\n\u2014 content/en/<Type>/<slug>.mdx (or the legacy content/<Type>/<slug>.mdx that\nexists), apps/web/content/en/blog/<slug>.mdx for a post and the same under\ndocs for a docs page \u2014 with its words moved back into its sections, so a\nre-run of migrate-content reports every page unchanged. Published edits are\nkept. A page with a draft ahead of its published version fails by name:\npublish or revert it in Admin, then re-run. The site's own API read must\nserve the workspace's published version (on a spoke, the hub's row at\n--store database). Each page prints created, written, unchanged or failed.\nThe agent key needs the content-edit grant; on a spoke, AILK_SPOKE_KEY is\nneeded too. Exit 0 when no page failed, 1 when any did, 2 on a refusal.\n";
57
+ export declare const EXPORT_CONTENT_HELP = "create-ailk export-content \u2014 write every published page back to its content file.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk export-content [<dir>] [--dry-run] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --dry-run Print what would be written, and write nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe rollback for a cutover: every page the workspace list reports published\nin the default locale is written to the file migrate-content reads it from\n\u2014 content/en/<Type>/<slug>.mdx (or the legacy content/<Type>/<slug>.mdx that\nexists), apps/web/content/en/blog/<slug>.mdx for a post,\napps/web/content/en/blog/<series>/<slug>.mdx for a post in a series and the\nsame under docs for a docs page; a post or doc goes to whichever of\n<slug>.mdx or <slug>/index.mdx is on disk, <slug>.mdx when neither is \u2014 with\nits words moved back into its sections, so a re-run of migrate-content\nreports every page unchanged. Published edits are\nkept. A page with a draft ahead of its published version fails by name:\npublish or revert it in Admin, then re-run. The site's own API read must\nserve the workspace's published version (on a spoke, the hub's row at\n--store database). Each page prints created, written, unchanged or failed.\nThe agent key needs the content-edit grant; on a spoke, AILK_SPOKE_KEY is\nneeded too. Exit 0 when no page failed, 1 when any did, 2 on a refusal.\n";
55
58
  export declare function parseExportContentArgs(argv: string[]): ExportContentArgs;
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * Pure module: no `import.meta.url`, so jest imports it directly.
26
26
  */
27
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
27
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
28
28
  import { dirname, join, resolve } from "node:path";
29
29
  import { parseArgs } from "node:util";
30
30
  import { listWorkspacePages, loadSiteWordsCodec, readDraftPage, readPublishedPage, readSiteLocales, resolveWorkspaceAccess, } from "./inventory.js";
@@ -52,21 +52,34 @@ const EDITORIAL_DIRS = {
52
52
  const EDITORIAL_RENAMES = { publishedAt: "date", updatedAt: "updated" };
53
53
  /** Keys an editorial file does not carry: its path decides both. */
54
54
  const EDITORIAL_DROPPED = new Set(["type", "slug"]);
55
+ /** The hub's live-source mark (#10898 D7): evidence about the draft's words, never a file's key. */
56
+ const LIVE_SOURCE_KEY = "liveSource";
57
+ /**
58
+ * Never written from `siteFields` (#10806 D6): a mapped fumadocs key, an
59
+ * address key, the strip marker, the live-source mark, or a prototype name.
60
+ */
61
+ const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, "__proto__"]);
55
62
  const INDEX_SLUG = "index";
56
63
  /** The store's address shapes, restated (create-ailk has no runtime dep): a path built from them stays in the site. */
57
64
  const TYPE_SHAPE = /^[A-Z][A-Za-z]*$/;
58
65
  const SLUG_SHAPE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
59
66
  const LOCALE_SHAPE = /^[a-z]{2}(-[A-Z]{2})?$/;
67
+ /** A blog series' shape (`PARENT` in `lib/import-mdx.ts`), restated: a directory built from it stays in the blog. */
68
+ const SERIES_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
60
69
  /** A pinned item's read times out as the kit's other reads do (`inventory.ts`). */
61
70
  const ITEM_READ_TIMEOUT_MS = 15_000;
62
71
  export const SPOKE_HINT = "the site's read does not serve this workspace's published version — is the spoke at --store database?";
63
72
  // ── File addressing (D6) ────────────────────────────────────────────────────
64
- /** The site-relative file a stored page is written to, and whether it is editorial. */
65
- export function fileFor(targetDir, type, slug, locale) {
73
+ /**
74
+ * The site-relative file a stored page is written to, and whether it is
75
+ * editorial. A blog post's `parent` is its series' directory (#10811 D1).
76
+ */
77
+ export function fileFor(targetDir, type, slug, locale, parent) {
66
78
  const exists = (path) => existsSync(join(targetDir, path));
67
79
  const editorial = EDITORIAL_DIRS[type];
68
80
  if (editorial !== undefined && editorial.index === (slug === INDEX_SLUG)) {
69
- const base = `apps/web/content/${locale}/${editorial.dir}`;
81
+ const series = type === "BlogPosting" && parent !== undefined ? `/${parent}` : "";
82
+ const base = `apps/web/content/${locale}/${editorial.dir}${series}`;
70
83
  if (editorial.index)
71
84
  return { path: `${base}/index.mdx`, editorial: true };
72
85
  // The importer reads `<slug>.mdx` first and `<slug>/index.mdx` (#10701);
@@ -88,11 +101,20 @@ export function recombine(content, sections, codec, editorial, pinned) {
88
101
  const { body: rawBody, ...rest } = content;
89
102
  let body = typeof rawBody === "string" ? rawBody : "";
90
103
  const frontmatter = {};
91
- for (const [key, value] of Object.entries(rest)) {
92
- if (editorial && EDITORIAL_DROPPED.has(key))
104
+ const { siteFields, ...stored } = rest;
105
+ for (const [key, value] of Object.entries(editorial ? stored : rest)) {
106
+ if (key === LIVE_SOURCE_KEY || (editorial && EDITORIAL_DROPPED.has(key)))
93
107
  continue;
94
108
  frontmatter[editorial ? (EDITORIAL_RENAMES[key] ?? key) : key] = value;
95
109
  }
110
+ // #10806 D6 — an editorial page's site fields are its file's own keys, after
111
+ // the mapped ones; a mapped key always wins.
112
+ if (editorial && siteFields !== null && typeof siteFields === "object" && !Array.isArray(siteFields)) {
113
+ for (const [key, value] of Object.entries(siteFields)) {
114
+ if (!Object.hasOwn(frontmatter, key) && !NOT_SITE_FIELDS.has(key))
115
+ frontmatter[key] = value;
116
+ }
117
+ }
96
118
  if (sections !== undefined && sections.length > 0) {
97
119
  const applied = codec.applyWords(body, sections);
98
120
  if (applied.issues.length > 0) {
@@ -170,6 +192,15 @@ export async function exportContent(opts) {
170
192
  if (draft.version !== row.publishedVersionId) {
171
193
  return failed("the draft read is not the published version; re-run");
172
194
  }
195
+ // #10811 D4 — a blog post's series becomes a directory, so it must be one
196
+ // the importer reads back; the API's value is not printed.
197
+ const stored = type === "BlogPosting" ? draft.content["parent"] : undefined;
198
+ const parent = typeof stored === "string" && SERIES_SHAPE.test(stored) && stored !== slug && stored !== "category"
199
+ ? stored
200
+ : undefined;
201
+ if (stored !== undefined && parent === undefined) {
202
+ return failed("its series is not one a file can be written under (lowercase words joined by single hyphens, not its own slug, not category)");
203
+ }
173
204
  const published = await readPublishedPage(access, fetch, type, slug, locale);
174
205
  if (!published.found || published.publishedVersionId !== row.publishedVersionId) {
175
206
  return failed(SPOKE_HINT);
@@ -177,8 +208,18 @@ export async function exportContent(opts) {
177
208
  const pinned = await pinnedItems(published.sections ?? [], locale);
178
209
  if (typeof pinned === "string")
179
210
  return failed(pinned);
180
- const { path, editorial } = fileFor(targetDir, type, slug, locale);
181
- const file = recombine(draft.content, published.sections, codec, editorial, pinned);
211
+ const { path, editorial } = fileFor(targetDir, type, slug, locale, parent);
212
+ let content = draft.content;
213
+ if (parent !== undefined && editorial) {
214
+ const holder = addressHolder(slug, parent);
215
+ if (holder !== undefined) {
216
+ return failed(`${holder} would hold this post's address on import; remove it, then re-run`, path);
217
+ }
218
+ // #10811 D3 — the path carries the series, as it carries type and slug.
219
+ const { parent: _series, ...unparented } = content;
220
+ content = unparented;
221
+ }
222
+ const file = recombine(content, published.sections, codec, editorial, pinned);
182
223
  if ("reason" in file)
183
224
  return failed(file.reason, path);
184
225
  const absolute = join(targetDir, path);
@@ -190,6 +231,33 @@ export async function exportContent(opts) {
190
231
  }
191
232
  return { type, slug, file: path, result };
192
233
  }
234
+ /**
235
+ * The first other file, in path order, that the editorial walk reads as
236
+ * this series post's `BlogPosting/<slug>` (#10811 D5): the top-level forms,
237
+ * or the same post under another series. The walk skips `category`, `_`
238
+ * entries and symbolic links, and refuses a series not in its shape or
239
+ * named after its own post, so none of those holds the address.
240
+ */
241
+ function addressHolder(slug, parent) {
242
+ const blog = `apps/web/content/${locale}/blog`;
243
+ const series = existsSync(join(targetDir, blog))
244
+ ? readdirSync(join(targetDir, blog), { withFileTypes: true })
245
+ .filter((d) => d.isDirectory() && SERIES_SHAPE.test(d.name) && ![parent, slug, "category"].includes(d.name))
246
+ .map((d) => `${blog}/${d.name}`)
247
+ : [];
248
+ // Every directory below `blog` a real directory and the file a real file.
249
+ const walked = (path) => {
250
+ const parts = path.slice(blog.length + 1).split("/");
251
+ return parts.every((_, i) => {
252
+ const stat = lstatSync(join(targetDir, blog, ...parts.slice(0, i + 1)), { throwIfNoEntry: false });
253
+ return i === parts.length - 1 ? stat?.isFile() === true : stat?.isDirectory() === true;
254
+ });
255
+ };
256
+ return [blog, ...series]
257
+ .flatMap((dir) => [`${dir}/${slug}.mdx`, `${dir}/${slug}/index.mdx`])
258
+ .filter(walked)
259
+ .sort()[0];
260
+ }
193
261
  /**
194
262
  * The Live words of every item the page's faq / glossary-index sections pin
195
263
  * (#10735 D9), by kind and slug — `undefined` when none pins — or why the
@@ -261,9 +329,12 @@ Options:
261
329
  The rollback for a cutover: every page the workspace list reports published
262
330
  in the default locale is written to the file migrate-content reads it from
263
331
  — content/en/<Type>/<slug>.mdx (or the legacy content/<Type>/<slug>.mdx that
264
- exists), apps/web/content/en/blog/<slug>.mdx for a post and the same under
265
- docs for a docs page — with its words moved back into its sections, so a
266
- re-run of migrate-content reports every page unchanged. Published edits are
332
+ exists), apps/web/content/en/blog/<slug>.mdx for a post,
333
+ apps/web/content/en/blog/<series>/<slug>.mdx for a post in a series and the
334
+ same under docs for a docs page; a post or doc goes to whichever of
335
+ <slug>.mdx or <slug>/index.mdx is on disk, <slug>.mdx when neither is — with
336
+ its words moved back into its sections, so a re-run of migrate-content
337
+ reports every page unchanged. Published edits are
267
338
  kept. A page with a draft ahead of its published version fails by name:
268
339
  publish or revert it in Admin, then re-run. The site's own API read must
269
340
  serve the workspace's published version (on a spoke, the hub's row at
@@ -163,6 +163,10 @@ export const ENV_CATALOG = {
163
163
  description: 'Set to "true" or "1" for an MCP HTTP transport with no sessions, which any instance can answer; "false" or "0" keeps sessions in one process. Unset means stateless on Vercel (src/app.ts) and stateful on a port (src/index.ts).',
164
164
  secret: false,
165
165
  },
166
+ MCP_OAUTH_ISSUER: {
167
+ description: 'Which MCP authorization server\'s OAuth tokens the API honours: unset for the site\'s own apps/web, "admin" on a hub whose MCP server names the Admin (#10912). A malformed value refuses every OAuth token.',
168
+ secret: false,
169
+ },
166
170
  MCP_PUBLIC_HTTP_URL: {
167
171
  description: "The public URL of the MCP HTTP transport (apps/mcp's `/mcp`), advertised by /.well-known/mcp.json; with BETTER_AUTH_URL it turns on the OAuth metadata. Set by create-ailk provision-env.",
168
172
  secret: false,
@@ -32,6 +32,46 @@ export interface MdxAdapterModule {
32
32
  data: Record<string, unknown>;
33
33
  content: string;
34
34
  };
35
+ /**
36
+ * The site-field rule from the adapter's validation package (#10806 D4);
37
+ * without it the editorial walk sends no `siteFields` and no `tags`, and
38
+ * names the keys it would have sent.
39
+ */
40
+ siteFields?: SiteFieldRules;
41
+ /**
42
+ * The verdict the hub's publish gate will give a live-source page (#10898
43
+ * D6), from the site's own contract; `undefined` for a type with no
44
+ * registry entry. Absent when the site's validation package predates the
45
+ * live-source report.
46
+ */
47
+ publishCheck?: (type: string, content: Record<string, unknown>, layout: Layout | undefined) => PublishVerdict | undefined;
48
+ }
49
+ /** One issue of the hub's content report, typed structurally. */
50
+ export interface ContentIssueLike {
51
+ code: string;
52
+ location: {
53
+ kind: string;
54
+ heading?: string;
55
+ key?: string;
56
+ setting?: string;
57
+ };
58
+ fixer: string;
59
+ }
60
+ /** Whether publish will take a live-source page, and what its report lists (#10898 D6). */
61
+ export type PublishVerdict = {
62
+ publishable: true;
63
+ advisory: ContentIssueLike[];
64
+ } | {
65
+ publishable: false;
66
+ status: string;
67
+ blocking: ContentIssueLike[];
68
+ };
69
+ /** The validation package's site-field rule, typed structurally. */
70
+ export interface SiteFieldRules {
71
+ refusal: (key: string, value: unknown) => string | null;
72
+ publicPageTags: (tags: readonly unknown[]) => string[];
73
+ maxKeys: number;
74
+ maxBytes: number;
35
75
  }
36
76
  export interface ImportMdxOptions {
37
77
  /** The site's content root (`content/`). */
@@ -54,6 +94,8 @@ export interface ImportMdxOptions {
54
94
  onLine?: (line: string) => void;
55
95
  /** Set Live each written page that has no Live version (#10659 D2); off by default. */
56
96
  publish?: boolean;
97
+ /** Send the live-source mark on each page (#10898 D5): migrate-content's import only. */
98
+ liveSource?: boolean;
57
99
  }
58
100
  /** The tree a page came from: `content/` or the site's `apps/web/content`. */
59
101
  export type ImportMdxRoot = "content" | "editorial";
@@ -63,6 +105,8 @@ export type ImportMdxOutcome = {
63
105
  result: "created" | "updated" | "unchanged";
64
106
  type: string;
65
107
  slug: string;
108
+ /** With `liveSource` and `publishCheck`: what the hub's publish gate will answer (#10898 D6). */
109
+ publishVerdict?: PublishVerdict;
66
110
  } | {
67
111
  root: ImportMdxRoot;
68
112
  path: string;
@@ -84,11 +128,78 @@ interface At {
84
128
  root: ImportMdxRoot;
85
129
  path: string;
86
130
  }
131
+ /** The layout a converted page stores in its structure layer (#10643). */
132
+ export interface Layout {
133
+ kind: "sections";
134
+ sections: unknown[];
135
+ }
87
136
  /** An outcome's printed path: an editorial one says so (#10701 D6). */
88
137
  export declare function outcomePath(at: At): string;
89
138
  /** The whole report, one line per page and a final count line. */
90
139
  export declare function formatImportMdxReport(result: ImportMdxResult): string;
140
+ /**
141
+ * A section string's inline HTML as the constrained Markdown the upstream
142
+ * renderers read (#10804 D3): a link with an allowed href becomes
143
+ * `[label](href)`, `<br>` a newline, a block or list item a paragraph break,
144
+ * and every other tag goes, its text kept. A string with no tag comes back
145
+ * byte-identical; the result never holds one. `notCarried` names, sorted,
146
+ * every tag the layout does not keep.
147
+ */
148
+ export declare function inlineHtmlToMarkdown(value: string): {
149
+ text: string;
150
+ notCarried: string[];
151
+ };
152
+ /**
153
+ * Each section with every string in its `data` that holds a tag converted by
154
+ * `inlineHtmlToMarkdown` (#10804 D2); keys and tag-free strings are kept as
155
+ * they are. `notCarried` is the sorted union of the names it did not carry.
156
+ */
157
+ export declare function sectionsWithoutHtml<T>(sections: readonly T[]): {
158
+ sections: T[];
159
+ notCarried: string[];
160
+ };
161
+ /**
162
+ * The first section-string or key rule of the hub's structure write
163
+ * (`checkSectionData`) the layout breaks, as `<message> (sections[i].data<path>)`,
164
+ * or `undefined` (#10804 D5). The depth and size bounds are not restated.
165
+ */
166
+ export declare function layoutRefusal(layout: {
167
+ sections: readonly unknown[];
168
+ }): string | undefined;
91
169
  export declare function importMdx(opts: ImportMdxOptions): Promise<ImportMdxResult>;
170
+ /** A content report, typed structurally. */
171
+ interface ContentReportLike {
172
+ status: string;
173
+ issues: ContentIssueLike[];
174
+ advisory?: ContentIssueLike[];
175
+ }
176
+ /** The four contract members a publish verdict is computed from, typed structurally. */
177
+ export interface PublishCheckMembers {
178
+ checkPage: (words: {
179
+ template: string;
180
+ title: string;
181
+ description: string;
182
+ slug: string;
183
+ body: string;
184
+ }, structure: unknown) => ContentReportLike;
185
+ liveSourceReport: (report: ContentReportLike) => ContentReportLike;
186
+ templates: Readonly<Record<string, {
187
+ kind: string;
188
+ }>>;
189
+ registry: readonly {
190
+ key: string;
191
+ template: string;
192
+ }[];
193
+ }
194
+ /**
195
+ * The hub's publish gate over a live-source page, as the site's contract
196
+ * reads it: the page's words checked against its type's template and the
197
+ * structure publish's repair would build — the layout when the page converts,
198
+ * an editorial template's frontmatter quartet, else none — with the
199
+ * required-heading findings advisory. Publish repairs every `script` finding,
200
+ * so only the rest block.
201
+ */
202
+ export declare function publishCheckOf(members: PublishCheckMembers): NonNullable<MdxAdapterModule["publishCheck"]>;
92
203
  /**
93
204
  * The site's installed adapter package, resolved from its `apps/web` — never
94
205
  * create-ailk's own `node_modules`.