create-ailk 0.43.0 → 0.45.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.
package/README.md CHANGED
@@ -898,23 +898,24 @@ AILK_AGENT_KEY=<agent key> create-ailk migrate-content ./my-site --apply --api-u
898
898
  - Pages land as drafts and nothing is published, so the live site keeps
899
899
  serving its MDX files and does not change.
900
900
  - The plan cannot see a write the API would refuse at `--apply` (a conflict
901
- with an edit made in between, or a server error): such a page is planned
902
- `create` or `update`. A page whose content fails its page type is planned
903
- and then saved with the errors the editor shows, not `failed`.
901
+ with an edit made in between, a server error, or a page whose content fails
902
+ its page type): such a page is planned `create` or `update`. At `--apply`
903
+ the save refuses a page that fails its page type with `422 invalid` and
904
+ stores nothing (#11843); fix its file and re-run.
904
905
  - The site's dependencies must be installed (`pnpm install`): the pages are
905
906
  read through the site's own `@working-theory/content-adapters`.
906
- - Every page is written with a live-source mark (#10898): its words already
907
- ship on the live site, so a heading its page type's template asks for and
908
- the page lacks is listed as advisory, and publish takes the page. Editing
909
- the page's words in the hub drops the mark, and the page is then gated as
910
- any other. A dry run prints a line after each page —
907
+ - Each page is saved in one write (#11843): `save_page` for a page — its
908
+ sections as its words when its frontmatter carries them, else its body —
909
+ and `save_document` for a document. No page carries a live-source mark, so
910
+ a heading its page type's template asks for and the page lacks stops its
911
+ publish, as on any page. A dry run prints a line after each page —
911
912
  `<path>: publish — publishable`, `publishable · advisory: missing "<heading>", …`
912
913
  or `not publishable · <status> · <code>:<where> "<what>"` — and then
913
914
  `publish: publishable <N> (<K> with advisory headings) · not publishable <M>`.
914
915
  The verdict is the site's installed `@working-theory/validation`'s, not the
915
916
  hub's: it sees no library-file finding, and no layout the hub repairs
916
- differently. A site whose validation package predates the live-source
917
- report prints one `publish: not checked` line instead.
917
+ differently. A site whose validation package has no content check prints
918
+ one `publish: not checked` line instead.
918
919
  - Exit 0 when no page failed, 1 when any did (in a dry run, when any would), 2
919
920
  on a refusal (a missing key, workspace id or origin, no `content/`, the
920
921
  adapter not installed), which sends nothing.
@@ -4766,6 +4766,29 @@
4766
4766
  "kind",
4767
4767
  "flow"
4768
4768
  ]
4769
+ },
4770
+ {
4771
+ "type": "object",
4772
+ "properties": {
4773
+ "kind": {
4774
+ "type": "string",
4775
+ "const": "magnet"
4776
+ },
4777
+ "slug": {
4778
+ "type": "string",
4779
+ "minLength": 1,
4780
+ "maxLength": 59,
4781
+ "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
4782
+ },
4783
+ "href": {
4784
+ "type": "string",
4785
+ "minLength": 1
4786
+ }
4787
+ },
4788
+ "required": [
4789
+ "kind",
4790
+ "slug"
4791
+ ]
4769
4792
  }
4770
4793
  ]
4771
4794
  },
@@ -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: {
@@ -39,10 +39,10 @@ export interface MdxAdapterModule {
39
39
  */
40
40
  siteFields?: SiteFieldRules;
41
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.
42
+ * The verdict the hub's publish gate will give a page (#10898 D6, #11843
43
+ * D7), from the site's own contract; `undefined` for a type with no
44
+ * registry entry. Absent when the site's validation package has no content
45
+ * check.
46
46
  */
47
47
  publishCheck?: (type: string, content: Record<string, unknown>, layout: Layout | undefined) => PublishVerdict | undefined;
48
48
  /**
@@ -64,7 +64,7 @@ export interface ContentIssueLike {
64
64
  };
65
65
  fixer: string;
66
66
  }
67
- /** Whether publish will take a live-source page, and what its report lists (#10898 D6). */
67
+ /** Whether publish will take a page, and what its report lists (#10898 D6). */
68
68
  export type PublishVerdict = {
69
69
  publishable: true;
70
70
  advisory: ContentIssueLike[];
@@ -101,8 +101,6 @@ export interface ImportMdxOptions {
101
101
  onLine?: (line: string) => void;
102
102
  /** Set Live each written page that has no Live version (#10659 D2); off by default. */
103
103
  publish?: boolean;
104
- /** Send the live-source mark on each page (#10898 D5): migrate-content's import only. */
105
- liveSource?: boolean;
106
104
  }
107
105
  /** The tree a page came from: `content/` or the site's `apps/web/content`. */
108
106
  export type ImportMdxRoot = "content" | "editorial";
@@ -112,7 +110,7 @@ export type ImportMdxOutcome = {
112
110
  result: "created" | "updated" | "unchanged";
113
111
  type: string;
114
112
  slug: string;
115
- /** With `liveSource` and `publishCheck`: what the hub's publish gate will answer (#10898 D6). */
113
+ /** With `publishCheck`: what the hub's publish gate will answer (#10898 D6, #11843 D7). */
116
114
  publishVerdict?: PublishVerdict;
117
115
  /** `updated` with the words already matching the hub: only the layout changed (#11749 D5). */
118
116
  layoutOnly?: true;
@@ -191,7 +189,6 @@ export interface PublishCheckMembers {
191
189
  slug: string;
192
190
  body: string;
193
191
  }, structure: unknown) => ContentReportLike;
194
- liveSourceReport: (report: ContentReportLike) => ContentReportLike;
195
192
  templates: Readonly<Record<string, {
196
193
  kind: string;
197
194
  }>>;
@@ -201,12 +198,12 @@ export interface PublishCheckMembers {
201
198
  }[];
202
199
  }
203
200
  /**
204
- * The hub's publish gate over a live-source page, as the site's contract
205
- * reads it: the page's words checked against its type's template and the
206
- * structure publish's repair would build — the layout when the page converts,
207
- * an editorial template's frontmatter quartet, else none — with the
208
- * required-heading findings advisory. Publish repairs every `script` finding,
209
- * so only the rest block.
201
+ * The hub's publish gate over a page, as the site's contract reads it: the
202
+ * page's words checked against its type's template and the structure
203
+ * publish's repair would build — the layout when the page converts, an
204
+ * editorial template's frontmatter quartet, else none. No live-source split
205
+ * is applied: no save keeps the mark (#11843 D7). Publish repairs every
206
+ * `script` finding, so only the rest block.
210
207
  */
211
208
  export declare function publishCheckOf(members: PublishCheckMembers): NonNullable<MdxAdapterModule["publishCheck"]>;
212
209
  /**