create-ailk 0.44.0 → 0.46.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 (57) hide show
  1. package/README.md +6 -3
  2. package/component-catalog.json +24 -1
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.d.ts +7 -0
  5. package/dist/add-module.js +17 -2
  6. package/dist/apply-design.js +1 -12
  7. package/dist/lib/env-catalog.js +2 -2
  8. package/dist/lib/import-mdx.js +10 -2
  9. package/dist/lib/license-key-files.d.ts +2 -0
  10. package/dist/lib/license-key-files.js +11 -0
  11. package/dist/paid-sections.d.ts +19 -0
  12. package/dist/paid-sections.js +41 -0
  13. package/dist/programmatic.js +56 -6
  14. package/dist/seed-workspace.d.ts +1 -1
  15. package/dist/seed-workspace.js +10 -3
  16. package/dist/surfaces.js +1 -1
  17. package/dist/update.d.ts +21 -2
  18. package/dist/update.js +188 -10
  19. package/package.json +3 -3
  20. package/templates/apps/api/.env.example +23 -0
  21. package/templates/apps/api/CLAUDE.md +17 -7
  22. package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
  23. package/templates/apps/mcp/.env.example +14 -3
  24. package/templates/apps/mcp/CLAUDE.md +47 -24
  25. package/templates/apps/mcp/src/index.ts +1 -1
  26. package/templates/apps/web/.env.example +1 -1
  27. package/templates/apps/web/CLAUDE.md +47 -16
  28. package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +44 -41
  29. package/templates/apps/web/app/.well-known/mcp.json/route.ts +24 -33
  30. package/templates/apps/web/app/[locale]/layout.tsx +10 -7
  31. package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
  32. package/templates/apps/web/app/api/site-status/route.ts +62 -0
  33. package/templates/apps/web/app/llms.txt/route.ts +3 -3
  34. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
  35. package/templates/apps/web/app/openapi.json/route.ts +10 -9
  36. package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
  37. package/templates/apps/web/auth.ts +25 -1
  38. package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +245 -0
  39. package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +395 -0
  40. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +112 -0
  41. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +280 -0
  42. package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
  43. package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
  44. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +108 -11
  45. package/templates/apps/web/lib/license-key-store.ts +1 -1
  46. package/templates/apps/web/lib/mcp-oauth.ts +64 -0
  47. package/templates/apps/web/lib/mcp-served-tools.ts +231 -0
  48. package/templates/apps/web/lib/offerings-pricing.ts +30 -6
  49. package/templates/apps/web/lib/pricing-page.ts +142 -35
  50. package/templates/apps/web/lib/site-brand.tsx +1 -7
  51. package/templates/apps/web/lib/site-visibility.ts +45 -0
  52. package/templates/apps/web/messages/en.json +8 -0
  53. package/templates/apps/web/middleware.ts +16 -1
  54. package/templates/apps/web/src/lib/routes.ts +3 -3
  55. package/versions.json +51 -51
  56. package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
  57. package/templates/apps/web/lib/release-scope.ts +0 -47
package/README.md CHANGED
@@ -797,9 +797,12 @@ AILK_AGENT_KEY=<agent key> create-ailk seed-workspace ./my-site --api-url <api o
797
797
  and the origin's source, before any request.
798
798
  - The agent key is read from `AILK_AGENT_KEY` only — never a flag or a file —
799
799
  and never printed. An owner issues it in the Admin with the `content-edit`
800
- and `content-publish` grants. After the first refused publish, the rest of
801
- the pages are saved as drafts and fail `not published`; a re-run with a
802
- granted key publishes them.
800
+ and `content-publish` grants, and the agent's person sets its level to
801
+ Autonomous on the agent's page: below Autonomous an agent does not publish,
802
+ and every new agent starts at Training. After the first refused publish, the
803
+ rest of the pages are saved as drafts and fail `not published`, and the
804
+ report says when the agent's level held it back; a re-run publishes them only
805
+ once the agent is at Autonomous with both grants.
803
806
  - Each page prints `created`, `updated`, `unchanged`, `skipped` or `failed`,
804
807
  then a count line. A re-run creates nothing and reports every page
805
808
  `unchanged`. An agent writes ten times a minute, so a first seed of about
@@ -25,7 +25,7 @@
25
25
  "importPath": "@working-theory/ui/chrome",
26
26
  "rootBarrel": "@working-theory/ui",
27
27
  "sourceRoot": "packages/ui/src/chrome",
28
- "count": 19
28
+ "count": 20
29
29
  },
30
30
  {
31
31
  "name": "primitives",
@@ -2157,6 +2157,17 @@
2157
2157
  "descriptionGrade": "strong",
2158
2158
  "sectionType": null
2159
2159
  },
2160
+ {
2161
+ "name": "PricingRail",
2162
+ "tier": "chrome",
2163
+ "sourcePath": "packages/ui/src/chrome/PricingRail.tsx",
2164
+ "importPath": "@working-theory/ui/chrome",
2165
+ "exported": true,
2166
+ "description": "Wraps a pricing page's rendered content and owns its layout region. The current page carries `aria-current=\"page\"` in both. Every string is the caller's (`labels`, the items, the `cta`): no English defaults.",
2167
+ "descriptionSource": "doc-comment",
2168
+ "descriptionGrade": "strong",
2169
+ "sectionType": null
2170
+ },
2160
2171
  {
2161
2172
  "name": "SectionNav",
2162
2173
  "tier": "chrome",
@@ -7327,6 +7338,15 @@
7327
7338
  ]
7328
7339
  }
7329
7340
  },
7341
+ "offeringPlans": {
7342
+ "minItems": 1,
7343
+ "maxItems": 12,
7344
+ "type": "array",
7345
+ "items": {
7346
+ "type": "string",
7347
+ "pattern": "^[a-z0-9][a-z0-9-]{0,39}$"
7348
+ }
7349
+ },
7330
7350
  "billingToggle": {
7331
7351
  "type": "boolean"
7332
7352
  },
@@ -7599,6 +7619,9 @@
7599
7619
  "qualifier": {
7600
7620
  "type": "string"
7601
7621
  },
7622
+ "note": {
7623
+ "type": "string"
7624
+ },
7602
7625
  "features": {
7603
7626
  "type": "array",
7604
7627
  "items": {
@@ -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: **331 component files** across 16 tiers — 60 sections, 110 blocks, 19 chrome, 82 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, 13 commerce-blocks, 1 commerce-panels. 328 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: **332 component files** across 16 tiers — 60 sections, 110 blocks, 20 chrome, 82 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, 13 commerce-blocks, 1 commerce-panels. 329 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: **327/331** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 247 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: **328/332** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 248 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, **294** are *strong* — a capability sentence you could match a requirement against — and **33** 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 89%**.
22
+ Of those, **295** are *strong* — a capability sentence you could match a requirement against — and **33** 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 89%**.
23
23
 
24
- Per tier, strong out of total: **Sections** 59/60 · **Blocks** 102/110 · **Chrome** 10/19 · **Primitives** 67/82 (4 undescribed) · **Panels** 6/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** 13/13 · **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** 102/110 · **Chrome** 11/20 · **Primitives** 67/82 (4 undescribed) · **Panels** 6/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** 13/13 · **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
 
@@ -245,7 +245,7 @@ Import: `import { X } from "@working-theory/ui/blocks";` (or from the `@working-
245
245
 
246
246
  ---
247
247
 
248
- ## Chrome (19)
248
+ ## Chrome (20)
249
249
 
250
250
  Persistent framing UI that wraps page content — navigation, footers, sidebars, banners. Not MDX-driven.
251
251
 
@@ -267,6 +267,7 @@ Import: `import { X } from "@working-theory/ui/chrome";` (or from the `@working-
267
267
  | `NavMobileMenu` | Client subcomponent for mobile hamburger state. Isolates "use client" to this narrow component so Nav (Server Component) stays clean. Renders a hamburger button + collapsible link list. Closes the menu automatically when the pathname changes (route navigation). *(weak)* | internal — compose from `packages/ui/src/chrome/NavMobileMenu.tsx` |
268
268
  | `NavOverflowMenu` | The Nav row's per-breakpoint link-overflow disclosure. The desktop link row never wraps: a fixed per-breakpoint inline-link budget (4 at md, 6 at lg+) is enforced by the caller (Nav), which splits `navItems` into an inline slice and an overflow slice. This component renders ONLY the overflow slice, behind a disclosure trigger, in source order — it never computes the budget itself. | internal — compose from `packages/ui/src/chrome/NavOverflowMenu.tsx` |
269
269
  | `NotificationsMenu` | Bell trigger + notifications popover chrome (ploy-capture app-frame). Presentational, props-driven. The unread count and row list arrive entirely via props — this component carries NO fetch/polling logic of its own. Rows are pre-formatted at the call site (relative time, heading, empty copy) per the AILK i18n/formatting convention (design-system-rules Rule 10). | `import { NotificationsMenu } from "@working-theory/ui/chrome"` |
270
+ | `PricingRail` | Wraps a pricing page's rendered content and owns its layout region. The current page carries `aria-current="page"` in both. Every string is the caller's (`labels`, the items, the `cta`): no English defaults. | `import { PricingRail } from "@working-theory/ui/chrome"` |
270
271
  | `SectionNav` | Chrome-tier route-aware section navigation. A horizontal, tab-styled section nav promoting Working Theory's bespoke `UnifiedTabs`/`TheoriesTabs` to a tokenized, tier-correct AILK component. | `import { SectionNav } from "@working-theory/ui/chrome"` |
271
272
  | `SidebarNav` | Application sidebar rail (nav + teams + user) for dashboard shells. Server Component (RSC). Renders the vertical sidebar rail for application-shell layouts. Used as the `sidebar` prop of AdminShell. Wrap in a FixedPanel (panels tier) to get the expanded ↔ rail ↔ hidden state machinery. Independently reusable in future shells (settings, analytics, etc.). *(weak)* | `import { SidebarNav } from "@working-theory/ui/chrome"` |
272
273
  | `SidebarNavRailItems` | Client boundary for the collapsed rail tooltip affordance. Isolated "use client" boundary so SidebarNav itself stays a Server Component. Renders icon-only nav links with Tooltip labels when the rail is collapsed. *(weak)* | internal — compose from `packages/ui/src/chrome/SidebarNavRailItems.tsx` |
@@ -1,5 +1,6 @@
1
1
  import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
2
2
  import { type InstallReportRow } from "./lib/extract-module-bundle.js";
3
+ import type { Level } from "./lib/module-tier.js";
3
4
  import { type ModulePatch } from "./module-architecture.js";
4
5
  import { type ModuleName } from "./parse-args.js";
5
6
  import type { MarkerMap, WorkspaceVersionMap } from "./substitute.js";
@@ -43,6 +44,12 @@ export interface ApplyModuleOptions {
43
44
  templatesDir: string;
44
45
  /** The package's `site-templates/` dir — the shipped manifests the roster rows are read from. */
45
46
  siteTemplatesDir: string;
47
+ /**
48
+ * #11952 D2 — the site's licence level. When it is not Free, every MCP pack
49
+ * the level ships joins `apps/mcp/package.json`, as a fresh keyed scaffold's
50
+ * does. Absent: the packs the bundle's own patches add, and no others.
51
+ */
52
+ mcpLevel?: Level;
46
53
  }
47
54
  export interface AddModuleResult {
48
55
  /** Resolved absolute path to the site. */
@@ -36,7 +36,7 @@ import { appendEnvRows } from "./lib/declared-env.js";
36
36
  import { diffTwoStrings, extractModuleBundle, } from "./lib/extract-module-bundle.js";
37
37
  import { publicTreeRemoved } from "./lib/site-modules.js";
38
38
  import { normalizeModules } from "./module-architecture.js";
39
- import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, writePaidSections, } from "./paid-sections.js";
39
+ import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, withLevelMcpPackages, writePaidSections, } from "./paid-sections.js";
40
40
  import { ParseError, parseModules } from "./parse-args.js";
41
41
  import { RoutesRefusedError, writeRoutes } from "./routes.js";
42
42
  import { writeSpokeFlowsReadme } from "./seed-flows.js";
@@ -244,8 +244,23 @@ export async function applyModuleToScaffold(opts) {
244
244
  const abs = join(targetAbs, path);
245
245
  return { path, abs, before: existsSync(abs) ? readFileSync(abs, "utf8") : undefined };
246
246
  });
247
+ // #11952 D2 — every pack the level ships, after the bundle's own patches and
248
+ // before the registry is written from the file, the order a scaffold uses.
249
+ const levelRows = [];
250
+ const mcpPkgPath = join(targetAbs, "apps", "mcp", "package.json");
251
+ if (opts.mcpLevel !== undefined && opts.mcpLevel !== "free" && existsSync(mcpPkgPath)) {
252
+ const next = withLevelMcpPackages(readFileSync(mcpPkgPath, "utf8"), opts.mcpLevel, opts.versions);
253
+ if (next.added.length > 0) {
254
+ writeFileSync(mcpPkgPath, next.text);
255
+ levelRows.push({
256
+ path: "apps/mcp/package.json",
257
+ action: "patched",
258
+ change: `added ${next.added.join(", ")} (${opts.mcpLevel} level)`,
259
+ });
260
+ }
261
+ }
247
262
  writePaidSections(targetAbs);
248
- const rows = [...report, ...checkoutRows];
263
+ const rows = [...report, ...checkoutRows, ...levelRows];
249
264
  for (const { path, abs, before } of generated) {
250
265
  if (existsSync(abs) && readFileSync(abs, "utf8") !== before)
251
266
  rows.push({ path, action: "written" });
@@ -23,7 +23,7 @@ import { CONTACT_PAGE_PATH, DESIGN_SEED_PAGES, HOME_PAGE_PATH, designHomeSeeds,
23
23
  import { applyDesignPresets, readSectionLookCatalog, shippedPageTypes, validateDesignPresets, } from "./design-presets.js";
24
24
  import { resolveDesign, spliceThemeBlock } from "./design-scaffold.js";
25
25
  import { chromeKnobReaders, unreadChromeKnobs } from "./lib/chrome-readers.js";
26
- import { LICENSE_KEY_FILE } from "./lib/license-key-files.js";
26
+ import { readSiteKey } from "./lib/license-key-files.js";
27
27
  import { CONVERSION_HINT_URL, LicenseRequiredError, assertDesignAllowed, deriveLevel, } from "./lib/module-license-gate.js";
28
28
  import { LEVEL_LABEL } from "./lib/module-tier.js";
29
29
  import { ParseError } from "./parse-args.js";
@@ -140,17 +140,6 @@ function listMdxFiles(dir) {
140
140
  }
141
141
  return out.sort();
142
142
  }
143
- /** The site's own key (D6): `<target>/ailk.key`, else `AILK_LICENSE_KEY`, else none. */
144
- function readSiteKey(targetAbs, env) {
145
- const keyPath = join(targetAbs, LICENSE_KEY_FILE);
146
- if (existsSync(keyPath)) {
147
- const key = readFileSync(keyPath, "utf8").trim();
148
- if (key.length > 0)
149
- return key;
150
- }
151
- const fromEnv = env["AILK_LICENSE_KEY"];
152
- return fromEnv !== undefined && fromEnv.length > 0 ? fromEnv : undefined;
153
- }
154
143
  /**
155
144
  * Apply a design to an existing site (D2–D7). Refuses before any write
156
145
  * (C1–C6); otherwise writes only the files whose text changes — page files,
@@ -156,7 +156,7 @@ export const ENV_CATALOG = {
156
156
  secret: true,
157
157
  },
158
158
  MCP_ABUSE_BLOCKED_USER_AGENTS: {
159
- description: "Comma-separated User-Agent substrings the MCP server blocks, beyond its built-in list.",
159
+ description: "Comma-separated User-Agent substrings the MCP server refuses on write-tool calls; empty refuses none.",
160
160
  secret: false,
161
161
  },
162
162
  MCP_CORS_WRITE_ALLOWED_ORIGINS: {
@@ -256,7 +256,7 @@ export const ENV_CATALOG = {
256
256
  secret: false,
257
257
  },
258
258
  STEALTH: {
259
- description: 'Set to "true" to keep the site out of search indexes (noindex headers) until launch.',
259
+ description: 'Set to "true" to keep the site hidden until launch: on the website, crawlers are blocked and every page is noindexed; on the MCP server, the anonymous path refuses every caller.',
260
260
  secret: false,
261
261
  },
262
262
  };
@@ -58,7 +58,9 @@
58
58
  *
59
59
  * The key travels only as `authorization: Bearer <key>`, never across a
60
60
  * redirect (`redirect: "error"`), and is never printed. Of an API answer only
61
- * a status and a `[a-z0-9_]` error code reach output (SEC-7876-S1).
61
+ * a status and a `[a-z0-9_]` error code reach output (SEC-7876-S1). A 401 or
62
+ * 403 stops the run, except a 403 `plugin_required`, which fails its page
63
+ * alone (#12013 D9).
62
64
  *
63
65
  * Spec: docs/specs/10203-import-mdx-one-mdx-artifact-spec.md; the editorial
64
66
  * walk docs/specs/10701-import-mdx-walks-the-editorial-spec.md; its site
@@ -590,11 +592,17 @@ function failed(at, reason, halt) {
590
592
  ...(halt !== undefined && { halt }),
591
593
  };
592
594
  }
593
- /** A non-success answer: 401/403 stops the run, anything else fails the page. */
595
+ /**
596
+ * A non-success answer: 401/403 stops the run, anything else fails the page.
597
+ * A 403 `plugin_required` refuses one address, not the key, so it fails the
598
+ * page alone (#12013 D9).
599
+ */
594
600
  function refusedAnswer(at, answer) {
595
601
  if ("network" in answer)
596
602
  return failed(at, answer.network);
597
603
  const reason = `${answer.status} ${answer.code}`;
604
+ if (answer.status === 403 && answer.code === "plugin_required")
605
+ return failed(at, reason);
598
606
  return answer.status === 401 || answer.status === 403
599
607
  ? failed(at, reason, `not sent: the API refused the key (${reason})`)
600
608
  : failed(at, reason);
@@ -1,6 +1,8 @@
1
1
  export declare const LICENSE_KEY_FILE = "ailk.key";
2
2
  export declare const LICENSE_ENV_FILE: string;
3
3
  export declare const LICENSE_ENV_VAR = "AILK_LICENSE_KEY";
4
+ /** The site's own key (D6): `<target>/ailk.key`, else `AILK_LICENSE_KEY`, else none. */
5
+ export declare function readSiteKey(targetAbs: string, env: NodeJS.ProcessEnv): string | undefined;
4
6
  /**
5
7
  * Throws unless `key` is 1–4096 characters of `[A-Za-z0-9._-]`. The message
6
8
  * describes the rule, never the value.
@@ -21,6 +21,17 @@ import { dirname, join } from "node:path";
21
21
  export const LICENSE_KEY_FILE = "ailk.key";
22
22
  export const LICENSE_ENV_FILE = join("apps", "api", ".env");
23
23
  export const LICENSE_ENV_VAR = "AILK_LICENSE_KEY";
24
+ /** The site's own key (D6): `<target>/ailk.key`, else `AILK_LICENSE_KEY`, else none. */
25
+ export function readSiteKey(targetAbs, env) {
26
+ const keyPath = join(targetAbs, LICENSE_KEY_FILE);
27
+ if (existsSync(keyPath)) {
28
+ const key = readFileSync(keyPath, "utf8").trim();
29
+ if (key.length > 0)
30
+ return key;
31
+ }
32
+ const fromEnv = env["AILK_LICENSE_KEY"];
33
+ return fromEnv !== undefined && fromEnv.length > 0 ? fromEnv : undefined;
34
+ }
24
35
  const KEY_SHAPE = /^[A-Za-z0-9._-]{1,4096}$/;
25
36
  /** `.gitignore` lines that already ignore a root `ailk.key`. */
26
37
  const KEY_IGNORE_LINES = new Set([
@@ -1,3 +1,5 @@
1
+ import { type Level } from "./lib/module-tier.js";
2
+ import type { WorkspaceVersionMap } from "./substitute.js";
1
3
  /** Scaffold-relative path of the generated registry. */
2
4
  export declare const PAID_SECTIONS_PATH = "apps/web/lib/paid-sections.generated.ts";
3
5
  /** Scaffold-relative path of the generated module-presence flags (#8843 D10). */
@@ -58,6 +60,23 @@ export declare function writeModuleFlags(targetDir: string): "added" | "updated"
58
60
  * appearance, so a package two modules deliver is one row.
59
61
  */
60
62
  export declare function paidMcpToolRows(): string[];
63
+ /**
64
+ * #11952 D1 — the paid MCP tool packs a licence level ships: every pack a
65
+ * module of `LEVEL_MODULES[level]` lists, in `paidMcpToolRows()` order.
66
+ * Free ships none; Pro and Pro Plus ship the same three today.
67
+ */
68
+ export declare function levelMcpPackages(level: Level): string[];
69
+ /**
70
+ * #11952 D2 — `text` (an apps/mcp/package.json) with every
71
+ * `levelMcpPackages(level)` pack its `dependencies` lacks added at
72
+ * `^<versions[pack]>`, dependency keys sorted. `added` is sorted; when it is
73
+ * empty, `text` comes back byte-identical. Throws, naming the pack, when
74
+ * `versions` has none for a pack it must add.
75
+ */
76
+ export declare function withLevelMcpPackages(text: string, level: Level, versions: WorkspaceVersionMap): {
77
+ text: string;
78
+ added: string[];
79
+ };
61
80
  /**
62
81
  * Render the MCP registry: one `() => import("<package>")` per carried
63
82
  * package, `[]` when none is carried. Line 1 is `// oss: false` exactly when
@@ -30,6 +30,7 @@
30
30
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
31
31
  import { dirname, join } from "node:path";
32
32
  import { readArchitectureHeader } from "./add-module-core.js";
33
+ import { LEVEL_MODULES } from "./lib/module-tier.js";
33
34
  import { readSiteManifestModules } from "./lib/site-modules.js";
34
35
  import { MODULE_SLICES } from "./module-architecture.js";
35
36
  import { RECOGNIZED_MODULES } from "./parse-args.js";
@@ -222,6 +223,46 @@ export function paidMcpToolRows() {
222
223
  }
223
224
  return rows;
224
225
  }
226
+ /**
227
+ * #11952 D1 — the paid MCP tool packs a licence level ships: every pack a
228
+ * module of `LEVEL_MODULES[level]` lists, in `paidMcpToolRows()` order.
229
+ * Free ships none; Pro and Pro Plus ship the same three today.
230
+ */
231
+ export function levelMcpPackages(level) {
232
+ const shipped = LEVEL_MODULES[level];
233
+ return paidMcpToolRows().filter((pkg) => shipped.some((m) => (MODULE_SLICES[m].paidMcpToolPackages ?? []).includes(pkg)));
234
+ }
235
+ /**
236
+ * #11952 D2 — `text` (an apps/mcp/package.json) with every
237
+ * `levelMcpPackages(level)` pack its `dependencies` lacks added at
238
+ * `^<versions[pack]>`, dependency keys sorted. `added` is sorted; when it is
239
+ * empty, `text` comes back byte-identical. Throws, naming the pack, when
240
+ * `versions` has none for a pack it must add.
241
+ */
242
+ export function withLevelMcpPackages(text, level, versions) {
243
+ let pkg;
244
+ try {
245
+ pkg = JSON.parse(text);
246
+ }
247
+ catch (err) {
248
+ throw new Error(`apps/mcp/package.json is not valid JSON: ${err.message}`, { cause: err });
249
+ }
250
+ const deps = { ...(pkg.dependencies ?? {}) };
251
+ const added = levelMcpPackages(level)
252
+ .filter((name) => !Object.hasOwn(deps, name))
253
+ .sort();
254
+ if (added.length === 0)
255
+ return { text, added };
256
+ for (const name of added) {
257
+ const version = versions[name];
258
+ if (version === undefined) {
259
+ throw new Error(`apps/mcp/package.json needs a version for ${name}, and this create-ailk's versions.json has none`);
260
+ }
261
+ deps[name] = `^${version}`;
262
+ }
263
+ pkg.dependencies = Object.fromEntries(Object.keys(deps).sort().map((key) => [key, deps[key]]));
264
+ return { text: `${JSON.stringify(pkg, null, 2)}\n`, added };
265
+ }
225
266
  const PAID_MCP_TOOLS_HEADER = `// paid-tools.generated.ts — the paid MCP tool packages this site carries.
226
267
  //
227
268
  // GENERATED by create-ailk from MODULE_SLICES (\`paidMcpToolPackages\`) and
@@ -37,7 +37,7 @@ import { assertLicenseKeyShape, writeLicenseKeyFiles, } from "./lib/license-key-
37
37
  import { assertDesignAllowed, assertReleased, deriveDesignLevel, deriveLevel, resolveModuleSet, resolvePaidModules, } from "./lib/module-license-gate.js";
38
38
  import { classifyModules, isAddition } from "./lib/module-tier.js";
39
39
  import { normalizeModules } from "./module-architecture.js";
40
- import { writePaidSections } from "./paid-sections.js";
40
+ import { withLevelMcpPackages, writePaidSections } from "./paid-sections.js";
41
41
  import { RECOGNIZED_SHAPES, RESERVED_SHAPES, } from "./parse-args.js";
42
42
  import { RemoveModuleRefusedError, removeModuleFromScaffold, } from "./remove-module.js";
43
43
  import { scaffoldSeamRows } from "./seam-refresh.js";
@@ -481,6 +481,37 @@ export async function scaffold(opts) {
481
481
  // (#6813 D7) — and `chosen.free` decides Free-ness by identity (D2), never
482
482
  // by `FREE_DESIGNS.includes(name)` alone (a path is never in that list).
483
483
  assertDesignAllowed(chosenDesign?.display, level ?? "free", chosenDesign?.free);
484
+ // #11952 D3 — the MCP build installs its level's packs (D1), so a run that
485
+ // composed no level (a `--modules` keep run, a `--template` alias run)
486
+ // derives one here, from the key alone. Kept apart from `level`: the
487
+ // manifest records what it did before (#6944), and the design gate above is
488
+ // already decided. Fail closed: a probe that cannot answer installs today's
489
+ // packs and never refuses the run. A `--without-mcp` spoke has nothing to
490
+ // install, so it never probes.
491
+ let mcpLevel = level ?? "free";
492
+ if (level === undefined && !(spoke !== undefined && opts.mcp === false)) {
493
+ try {
494
+ mcpLevel = await deriveDesignLevel({
495
+ licenseKey,
496
+ ...(opts.moduleRegistryUrl !== undefined
497
+ ? { registryUrl: opts.moduleRegistryUrl }
498
+ : {}),
499
+ ...(opts.fetchImpl !== undefined ? { fetchImpl: opts.fetchImpl } : {}),
500
+ });
501
+ }
502
+ catch {
503
+ mcpLevel = "free";
504
+ }
505
+ }
506
+ // Threaded to extractModuleBundle for `package.json` patch targets'
507
+ // `workspace:*` substitution (spec 5418 § 3 D2) — the same version map
508
+ // `scaffoldSync` already reads for `copyTemplate`, re-read here since
509
+ // `scaffold()` doesn't share `scaffoldSync`'s call frame. Read before the
510
+ // target exists, so a level pack it lacks refuses first (#11952 NFR4).
511
+ const versions = readVersionMap();
512
+ // Throws, naming the pack, when `versions` lacks one the level ships — the
513
+ // same check the write below makes, run here against an empty dependency set.
514
+ withLevelMcpPackages(`{"dependencies":{}}`, mcpLevel, versions);
484
515
  // The template's OWN bundle, fetched here — before `scaffoldSync` — so the
485
516
  // fourth refusal (the template's bundle unpublished, parent record D17 /
486
517
  // spec 5481 § 3 DD5 row 4) throws with the target still non-existent, like
@@ -543,11 +574,6 @@ export async function scaffold(opts) {
543
574
  // `resolveSiteChrome` reads a layout object now, not a `StarterDesign`.
544
575
  ...(resolvedDesign !== undefined ? { designLayout: resolvedDesign.pkg.layout } : {}),
545
576
  }, copied);
546
- // Threaded to extractModuleBundle for `package.json` patch targets'
547
- // `workspace:*` substitution (spec 5418 § 3 D2) — the same version map
548
- // `scaffoldSync` already reads for `copyTemplate`, re-read here since
549
- // `scaffold()` doesn't share `scaffoldSync`'s call frame.
550
- const versions = readVersionMap();
551
577
  // #6460 — the SAME marker map `scaffoldSync` just substituted the base
552
578
  // `templates/` copy with, rebuilt here from the same inputs (`scaffold()`
553
579
  // does not share `scaffoldSync`'s call frame, exactly as `versions` above
@@ -875,6 +901,13 @@ export async function scaffold(opts) {
875
901
  }));
876
902
  }
877
903
  }
904
+ // #11952 D2 — every pack the level ships, after the bundles' own patches.
905
+ const mcpPkgPath = join(result.targetDir, "apps", "mcp", "package.json");
906
+ if (existsSync(mcpPkgPath)) {
907
+ const next = withLevelMcpPackages(readFileSync(mcpPkgPath, "utf8"), mcpLevel, versions);
908
+ if (next.added.length > 0)
909
+ writeFileSync(mcpPkgPath, next.text);
910
+ }
878
911
  // #7536 D3 — the registry follows `apps/web/package.json`, which a module
879
912
  // bundle's `patches` (and the template layer) just finished editing.
880
913
  writePaidSections(result.targetDir);
@@ -1259,6 +1292,22 @@ export async function addModule(opts) {
1259
1292
  if (bundleBytes === undefined) {
1260
1293
  throw new Error(`module "${opts.moduleName}": no bundle was resolved`);
1261
1294
  }
1295
+ // #11952 D3 — the MCP build installs its level's packs, so add-module reads
1296
+ // the level from the same key, as `scaffold()` and `update` do. A read that
1297
+ // fails adds no packs and never refuses the run.
1298
+ let mcpLevel;
1299
+ try {
1300
+ ({ level: mcpLevel } = await deriveLevel({
1301
+ licenseKey: opts.licenseKey,
1302
+ ...(opts.moduleRegistryUrl !== undefined
1303
+ ? { registryUrl: opts.moduleRegistryUrl }
1304
+ : {}),
1305
+ ...(opts.fetchImpl !== undefined ? { fetchImpl: opts.fetchImpl } : {}),
1306
+ }));
1307
+ }
1308
+ catch {
1309
+ mcpLevel = undefined;
1310
+ }
1262
1311
  return applyModuleToScaffold({
1263
1312
  targetDir: targetAbs,
1264
1313
  moduleName: opts.moduleName,
@@ -1267,6 +1316,7 @@ export async function addModule(opts) {
1267
1316
  markers: buildScaffoldMarkers(basename(targetAbs)),
1268
1317
  templatesDir: TEMPLATES_DIR,
1269
1318
  siteTemplatesDir: SITE_TEMPLATES_DIR,
1319
+ ...(mcpLevel !== undefined ? { mcpLevel } : {}),
1270
1320
  });
1271
1321
  }
1272
1322
  /**
@@ -69,5 +69,5 @@ export interface SeedWorkspaceArgs {
69
69
  workspaceId: string | undefined;
70
70
  help: boolean;
71
71
  }
72
- export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants. Each page prints created, updated, unchanged,\nskipped or failed, so a re-run is safe. When every page is Live, the site\nswitches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value\neither already sets. The site's dependencies must be installed. Exit 0 when\nevery page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).\n";
72
+ export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants, at Autonomous. Each page prints created, updated,\nunchanged, skipped or failed, so a re-run is safe. When every page is Live, the site\nswitches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value\neither already sets. The site's dependencies must be installed. Exit 0 when\nevery page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).\n";
73
73
  export declare function parseSeedWorkspaceArgs(argv: string[]): SeedWorkspaceArgs;
@@ -43,6 +43,8 @@ export const AGENT_KEY_ENV_VAR = "AILK_AGENT_KEY";
43
43
  export const WORKSPACE_ID_ENV_VAR = "AILK_WORKSPACE_ID";
44
44
  /** The environment variable each app chooses its content source by (#10659). */
45
45
  export const CONTENT_ADAPTER_ENV_VAR = "CONTENT_ADAPTER";
46
+ /** A page the importer saved but whose publish the API refused 403 (`import-mdx.ts`'s reason). */
47
+ const PUBLISH_REFUSED = /not published \(403 [a-z0-9_]+\)$/;
46
48
  /** A refusal the CLI exits 2 on, thrown before any request is sent. */
47
49
  export class SeedWorkspaceRefusedError extends Error {
48
50
  exitCode = 2;
@@ -90,7 +92,7 @@ export async function seedWorkspace(opts) {
90
92
  }
91
93
  const apiKey = given(env[AGENT_KEY_ENV_VAR]);
92
94
  if (apiKey === undefined) {
93
- refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants. It is read from the environment only — never a flag or a file.`);
95
+ refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants, at Autonomous. It is read from the environment only — never a flag or a file.`);
94
96
  }
95
97
  const workspaceId = given(opts.workspaceId) ?? given(env[WORKSPACE_ID_ENV_VAR]);
96
98
  if (workspaceId === undefined) {
@@ -145,6 +147,11 @@ export async function seedWorkspace(opts) {
145
147
  if (failed > 0) {
146
148
  onLine(`${failed} page(s) were not seeded. Fix them and re-run: create-ailk seed-workspace ${opts.targetDir}`);
147
149
  }
150
+ // #12008 D12 — the key is an agent's, and below Autonomous an agent's
151
+ // publish is refused 403.
152
+ if (result.pages.some((page) => page.result === "failed" && PUBLISH_REFUSED.test(page.reason))) {
153
+ onLine("This agent's level holds back publishing. Its person sets it to Autonomous on the agent's page, then run this again.");
154
+ }
148
155
  onLine("Content source: content/ (unchanged) until every page is seeded and Live.");
149
156
  }
150
157
  return { result, exitCode: failed > 0 ? 1 : 0 };
@@ -235,8 +242,8 @@ Options:
235
242
  Each content/en/<Type>/<slug>.mdx page is written to the workspace, and set
236
243
  Live when it has no Live version, through the API's content routes, with the
237
244
  agent key, which is read from AILK_AGENT_KEY only and needs the content-edit
238
- and content-publish grants. Each page prints created, updated, unchanged,
239
- skipped or failed, so a re-run is safe. When every page is Live, the site
245
+ and content-publish grants, at Autonomous. Each page prints created, updated,
246
+ unchanged, skipped or failed, so a re-run is safe. When every page is Live, the site
240
247
  switches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value
241
248
  either already sets. The site's dependencies must be installed. Exit 0 when
242
249
  every page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).
package/dist/surfaces.js CHANGED
@@ -452,7 +452,7 @@ export const GATEABLE_SURFACES = [
452
452
  // schedule/ directory by #5563), and the private index `/private`
453
453
  // (#8843 D10), a second directory gated with it. API-backed like
454
454
  // `flows`: every meeting fact comes from apps/api's
455
- // `GET /v1/schedule/meetings`, so there is no MDX of its own. Since
455
+ // `GET /v1/schedule/meeting-pages`, so there is no MDX of its own. Since
456
456
  // #11252 the pages ship in `@working-theory/ui-scheduling` and the
457
457
  // snapshot carries neither directory; the surface still gates the nav
458
458
  // label and the Free placeholders.
package/dist/update.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { type Level } from "./lib/module-tier.js";
1
2
  import { type MdxParse } from "./mdx-braces.js";
2
3
  import { type ModuleName } from "./parse-args.js";
3
- import type { WorkspaceVersionMap } from "./substitute.js";
4
+ import { type WorkspaceVersionMap } from "./substitute.js";
4
5
  /** A refusal the CLI exits 2 on, thrown before anything is written. */
5
6
  export declare class UpdateRefusedError extends Error {
6
7
  readonly exitCode = 2;
@@ -33,6 +34,10 @@ export interface UpdateSiteOptions {
33
34
  * `null` acts as "not installed". Absent: `loadSiteMdxParse(targetDir)`.
34
35
  */
35
36
  mdxParse?: MdxParse | null;
37
+ /** #11952 D4 — read for AILK_LICENSE_KEY only. Default process.env. */
38
+ env?: NodeJS.ProcessEnv;
39
+ /** #11952 D4 — forwarded to deriveLevel as registryUrl. Default: AILK_MODULE_REGISTRY_URL / fetchModule's default. */
40
+ moduleRegistryUrl?: string;
36
41
  }
37
42
  export interface UpdateResult {
38
43
  targetDir: string;
@@ -101,6 +106,20 @@ export interface UpdateResult {
101
106
  path: string;
102
107
  version: string;
103
108
  }>;
109
+ /** The `apps/web/package.json` scripts set to the running template's, with the published template version each was (#11940). */
110
+ scriptsCarried?: Array<{
111
+ script: string;
112
+ version: string;
113
+ }>;
114
+ /** The dependencies added to `apps/web/package.json` this run (#9889 D9, #11392), sorted. */
115
+ webDependenciesAdded?: string[];
116
+ /** #11952 D4 — the packs added to apps/mcp/package.json for the site's level. */
117
+ mcpPackagesAdded?: {
118
+ level: Level;
119
+ packages: string[];
120
+ };
121
+ /** #11952 D4 — why the level's packs were not checked, when they were not. */
122
+ mcpLevelUnchecked?: string;
104
123
  /** The `project.yaml` `env_contract` rows added for env vars the written files read (#10172). */
105
124
  envRowsAdded?: string[];
106
125
  /** Record rows dropped because the path is no longer recordable (#10173). */
@@ -183,6 +202,6 @@ export interface UpdateArgs {
183
202
  target: string | undefined;
184
203
  help: boolean;
185
204
  }
186
- export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has \u2014 also when its recorded\nversion's copy cannot be read \u2014 and is reviewed only when a key is an object\non one side and a value on the other; a written apps/web file that uses\nthrough t(...) a key the catalog then lacks is held with it, listed under\n\"Held back with <catalog>\". Each @working-theory/* package a written apps/web\nfile imports that apps/web/package.json does not declare is added to its\ndependencies at this release's version. An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. A file at a\ntemplate path that is not in the record (one an earlier sync-routes --apply\nor add-route copied without recording it) whose bytes are a published\ncreate-ailk version's copy \u2014 from the version the site was scaffolded at to\nthis one \u2014 is adopted: recorded and moved forward as an untouched file is,\nlisted under \"Adopted\" with the version it matched. One whose bytes are the\nrunning copy with this site's modules' patches applied (a module's\njest.config.cjs or next.config.mjs edit) is left as it is and not listed.\nOne whose bytes match no published copy is a site edit: skipped, never overwritten, and counted under\n\"Held as site edits, not in the record\". No file under a route the site\nlists in customizations.yaml declined_routes is written: each is listed under\n\"Skipped\" naming the declined route. Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\" (by a relative or @/ import, transitively) is held\nat the site's version with it, its record entry is not advanced, and it is\nlisted under \"Held back with <file>\" \u2014 reconcile the file, then run update\nagain to bring it forward. A skipped file never holds another. A file whose\nown bytes are the record's is not held by what it imports: it moves, unless\nit names an export the held copy lacks, and the held file is listed as\n\"Held back: <file> \u2014 imported by N moved files; the site edit is <hunk\nsummary>\". A written file whose import names a file the site lacks gets it\nadded when this template supplies it; otherwise it is held the same way,\nunder \"Held back with <file> (not in this site)\", unless its own copy\nalready named the file \u2014 then it moves and the path is listed under \"Not in\nthis site or the template: <file>\". A file the template removed is kept\nwhile any file still in the site imports it. A file a customizations.yaml\nentry records is never removed, nor anything it imports: it keeps its record\nrow and is listed under \"Skipped\" as kept. Every other file in the run\nstill updates. When project.yaml has an env_contract block, each\nenv var the written files read that has no row gains one; no row is edited.\nA record row at a path create-ailk no longer records is dropped and listed.\nA surface the site's .ailk-site-manifest.json names a page on but\narchitecture.yaml does not declare (one no module owns, such as projects)\ngets its route files added and is declared, listed under \"Surfaces declared\nfrom the roster\". A code-route row of that roster no page file serves is\ndropped, listed under \"Roster rows dropped, no route serves them\".\nA site with no record gets one on its first run, from the version its\n.ailk-site-manifest.json already records. A site scaffolded before\n@working-theory/mcp-server has its copied apps/mcp moved to the boot set:\nthe server and each module's paid MCP pack join apps/mcp/package.json, the\ncopied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is\nrewritten on every run. A site scaffolded before @working-theory/api has its\ncopied apps/api moved to the boot file: the app becomes @working-theory/app-api,\nthe package and the six @working-theory/api-<module> packages join\napps/api/package.json, its bins and build:vercel delegate to the package, and\nthe copied server files go. Run `pnpm install` after either move, since the\napp's package.json gained dependencies. Each mdx-body page in content/ with no\n'# ' heading gets its title and description written into its body as its\nheading and intro, listed under \"Page heading added\"; a page with one heading\nis left as it is, and one with several, or one whose frontmatter it cannot\nread, is listed under \"Needs review\". Each bare { on an mdx-body page is\nescaped as \\{ when the site's own MDX parser then reads the page clean, listed\nunder \"Placeholder brace escaped\"; a page it cannot escape safely, or any page\nwith one while the site's dependencies are not installed, is listed under\n\"Needs review\". Each topology seam (*.generated.* \u2014 the web seam, the\n(authed) gate, the API origin and the MCP seam) is rendered again for the\ntopology and sign-in mode .ailk-site-manifest.json records and listed under\n\"Regenerated\", when its bytes are still the render .ailk-template-files.json\nrecords; one edited by hand, or with no recorded render, is listed under\n\"Needs review\" and left as it is. Last, the generated route files of every installed page\npackage (one whose package.json declares \"ailk\": { \"routes\" }) are rewritten\nfrom its manifest, listed under \"Route files regenerated\"; run\n`create-ailk routes --write` after the install when the packages were not\ninstalled yet. Each hand-written page `routes --check` then fails on \u2014 no\ndecided customizations.yaml entry, under a package's prefix, or at a\npackage's own route \u2014 is listed under \"Needs review\". Commit before running,\nand review the diff after.\n";
205
+ export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has \u2014 also when its recorded\nversion's copy cannot be read \u2014 and is reviewed only when a key is an object\non one side and a value on the other; a written apps/web file that uses\nthrough t(...) a key the catalog then lacks is held with it, listed under\n\"Held back with <catalog>\". Each @working-theory/* package a written apps/web\nfile imports that apps/web/package.json does not declare is added to its\ndependencies at this release's version. A site missing a paid MCP package\nits licence level ships gets it in apps/mcp/package.json; the level is read\nfrom the site's key (ailk.key, else AILK_LICENSE_KEY) through the module\nregistry, and a run with no key adds none. apps/web/package.json's\nscripts.build is set to this template's when it is a published create-ailk\ntemplate's, listed under \"Build scripts carried\"; a build script matching no\ntemplate's is left as it is and listed under \"Needs review\". An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. A file at a\ntemplate path that is not in the record (one an earlier sync-routes --apply\nor add-route copied without recording it) whose bytes are a published\ncreate-ailk version's copy \u2014 from the version the site was scaffolded at to\nthis one \u2014 is adopted: recorded and moved forward as an untouched file is,\nlisted under \"Adopted\" with the version it matched. One whose bytes are the\nrunning copy with this site's modules' patches applied (a module's\njest.config.cjs or next.config.mjs edit) is left as it is and not listed.\nOne whose bytes match no published copy is a site edit: skipped, never overwritten, and counted under\n\"Held as site edits, not in the record\". No file under a route the site\nlists in customizations.yaml declined_routes is written: each is listed under\n\"Skipped\" naming the declined route. Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\" (by a relative or @/ import, transitively) is held\nat the site's version with it, its record entry is not advanced, and it is\nlisted under \"Held back with <file>\" \u2014 reconcile the file, then run update\nagain to bring it forward. A skipped file never holds another. A file whose\nown bytes are the record's is not held by what it imports: it moves, unless\nit names an export the held copy lacks, and the held file is listed as\n\"Held back: <file> \u2014 imported by N moved files; the site edit is <hunk\nsummary>\". A written file whose import names a file the site lacks gets it\nadded when this template supplies it; otherwise it is held the same way,\nunder \"Held back with <file> (not in this site)\", unless its own copy\nalready named the file \u2014 then it moves and the path is listed under \"Not in\nthis site or the template: <file>\". A file the template removed is kept\nwhile any file still in the site imports it. A file a customizations.yaml\nentry records is never removed, nor anything it imports: it keeps its record\nrow and is listed under \"Skipped\" as kept. Every other file in the run\nstill updates. When project.yaml has an env_contract block, each\nenv var the written files read that has no row gains one; no row is edited.\nA record row at a path create-ailk no longer records is dropped and listed.\nA surface the site's .ailk-site-manifest.json names a page on but\narchitecture.yaml does not declare (one no module owns, such as projects)\ngets its route files added and is declared, listed under \"Surfaces declared\nfrom the roster\". A code-route row of that roster no page file serves is\ndropped, listed under \"Roster rows dropped, no route serves them\".\nA site with no record gets one on its first run, from the version its\n.ailk-site-manifest.json already records. A site scaffolded before\n@working-theory/mcp-server has its copied apps/mcp moved to the boot set:\nthe server and each module's paid MCP pack join apps/mcp/package.json, the\ncopied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is\nrewritten on every run. A site scaffolded before @working-theory/api has its\ncopied apps/api moved to the boot file: the app becomes @working-theory/app-api,\nthe package and the six @working-theory/api-<module> packages join\napps/api/package.json, its bins and build:vercel delegate to the package, and\nthe copied server files go. Run `pnpm install` after either move, since the\napp's package.json gained dependencies. Each mdx-body page in content/ with no\n'# ' heading gets its title and description written into its body as its\nheading and intro, listed under \"Page heading added\"; a page with one heading\nis left as it is, and one with several, or one whose frontmatter it cannot\nread, is listed under \"Needs review\". Each bare { on an mdx-body page is\nescaped as \\{ when the site's own MDX parser then reads the page clean, listed\nunder \"Placeholder brace escaped\"; a page it cannot escape safely, or any page\nwith one while the site's dependencies are not installed, is listed under\n\"Needs review\". Each topology seam (*.generated.* \u2014 the web seam, the\n(authed) gate, the API origin and the MCP seam) is rendered again for the\ntopology and sign-in mode .ailk-site-manifest.json records and listed under\n\"Regenerated\", when its bytes are still the render .ailk-template-files.json\nrecords; one edited by hand, or with no recorded render, is listed under\n\"Needs review\" and left as it is. Last, the generated route files of every installed page\npackage (one whose package.json declares \"ailk\": { \"routes\" }) are rewritten\nfrom its manifest, listed under \"Route files regenerated\"; run\n`create-ailk routes --write` after the install when the packages were not\ninstalled yet. Each hand-written page `routes --check` then fails on \u2014 no\ndecided customizations.yaml entry, under a package's prefix, or at a\npackage's own route \u2014 is listed under \"Needs review\". Commit before running,\nand review the diff after.\n";
187
206
  /** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
188
207
  export declare function parseUpdateArgs(argv: string[]): UpdateArgs;