create-ailk 0.40.3 → 0.42.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 +31 -1
- package/component-catalog.json +6 -0
- package/dist/add-route.d.ts +2 -6
- package/dist/add-route.js +2 -43
- package/dist/export-content.js +11 -3
- package/dist/language-import.js +5 -2
- package/dist/lib/env-catalog.js +5 -1
- package/dist/lib/import-mdx.js +10 -7
- package/dist/magnet-page.d.ts +36 -0
- package/dist/magnet-page.js +70 -0
- package/dist/module-architecture.js +14 -48
- package/dist/routes.d.ts +44 -2
- package/dist/routes.js +766 -33
- package/dist/surfaces.d.ts +18 -2
- package/dist/surfaces.js +85 -21
- package/dist/topology.js +0 -1
- package/dist/update.d.ts +16 -1
- package/dist/update.js +273 -7
- package/package.json +3 -3
- package/templates/.claude/hooks/template-guard.sh +145 -36
- package/templates/CLAUDE.md +1 -1
- package/templates/apps/api/.env.example +2 -1
- package/templates/apps/api/CLAUDE.md +1 -0
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/.env.example +5 -6
- package/templates/apps/web/CLAUDE.md +41 -7
- package/templates/apps/web/app/[locale]/layout.tsx +6 -3
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +37 -1
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +28 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +17 -0
- package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +1 -0
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +42 -0
- package/templates/apps/web/lib/__tests__/route-paths.test.ts +57 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +22 -7
- package/templates/apps/web/lib/deck-page.ts +20 -1
- package/templates/apps/web/lib/mcp-oauth.ts +14 -10
- package/templates/apps/web/lib/page-chrome.ts +11 -5
- package/templates/apps/web/lib/route-paths.ts +22 -0
- package/templates/apps/web/lib/services-path.ts +27 -18
- package/templates/apps/web/messages/en.json +0 -9
- package/templates/apps/web/middleware.ts +2 -1
- package/templates/apps/web/next.config.mjs +123 -2
- package/templates/apps/web/src/lib/routes.ts +4 -2
- package/versions.json +50 -50
- package/templates/apps/web/lib/deliverable-grant.ts +0 -18
|
@@ -4,8 +4,13 @@ import { parse as parseYaml } from "yaml";
|
|
|
4
4
|
import bundleAnalyzer from "@next/bundle-analyzer";
|
|
5
5
|
import { withSentryConfig } from "@sentry/nextjs";
|
|
6
6
|
import createNextIntlPlugin from "next-intl/plugin";
|
|
7
|
-
import { DocsPathSchema, ServicesPathSchema } from "@working-theory/site-config/schema";
|
|
8
|
-
import {
|
|
7
|
+
import { DocsPathSchema, ServicesPathSchema, SiteConfigSchema } from "@working-theory/site-config/schema";
|
|
8
|
+
import {
|
|
9
|
+
legacyRedirects,
|
|
10
|
+
routeRenameRefusals,
|
|
11
|
+
ROUTES,
|
|
12
|
+
SERVICES_ROUTE,
|
|
13
|
+
} from "@working-theory/templates/routes";
|
|
9
14
|
import { assetRemotePattern } from "@working-theory/validation";
|
|
10
15
|
import { parseStealth } from "@working-theory/web-i18n/stealth";
|
|
11
16
|
import { withBotId } from "botid/next/config";
|
|
@@ -280,6 +285,118 @@ function readServiceParents() {
|
|
|
280
285
|
const servicesPathAtBuild = readServicesPathFromSiteMdx();
|
|
281
286
|
readServiceParents();
|
|
282
287
|
|
|
288
|
+
// #11385 D4 — a renamed route family. A site sets `portfolio: { path:
|
|
289
|
+
// /writing-samples }` in content/_site.mdx on one of the renamable families
|
|
290
|
+
// (the `_site.mdx` keys other than `services` whose schema takes a `path`);
|
|
291
|
+
// it is read here, refused by name when it cannot be served or when its route
|
|
292
|
+
// files were not regenerated, and baked into NEXT_PUBLIC_AILK_ROUTE_PATHS,
|
|
293
|
+
// keyed by convention segment, for @working-theory/templates/route-paths.
|
|
294
|
+
// `redirects()` reads the same value through `legacyRedirects()`.
|
|
295
|
+
const ROUTE_PATH_SCHEMAS = Object.fromEntries(
|
|
296
|
+
Object.entries(SiteConfigSchema.shape)
|
|
297
|
+
.filter(([key, schema]) => key !== "services" && schema.unwrap?.()?.shape?.path !== undefined)
|
|
298
|
+
.map(([key, schema]) => [key, schema.unwrap().shape.path.unwrap()]),
|
|
299
|
+
);
|
|
300
|
+
/** Family → convention segment: the key's kebab form (`caseStudies` → `case-studies`). */
|
|
301
|
+
const ROUTE_CONVENTIONS = Object.fromEntries(
|
|
302
|
+
Object.keys(ROUTE_PATH_SCHEMAS).map((family) => [
|
|
303
|
+
family,
|
|
304
|
+
family.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`),
|
|
305
|
+
]),
|
|
306
|
+
);
|
|
307
|
+
// middleware.ts's NON_LOCALE_ROUTE_PREFIXES, without their slash.
|
|
308
|
+
const NON_LOCALE_SEGMENTS = ["api", "apple-icon", "og", "v1"];
|
|
309
|
+
const ROUTE_ROOT = join(process.cwd(), "app/[locale]");
|
|
310
|
+
const GENERATED_ROUTE_HEADER = /^(?:\/\/ oss: false\r?\n)?\/\/ Generated by create-ailk routes from /;
|
|
311
|
+
|
|
312
|
+
function refuseRouteRename(family, value, reason) {
|
|
313
|
+
throw new Error(`content/_site.mdx ${family}.path ${value}: ${reason}`);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** A route file's text when create-ailk generated it; `undefined` otherwise. */
|
|
317
|
+
function readGeneratedRoute(path) {
|
|
318
|
+
let text;
|
|
319
|
+
try {
|
|
320
|
+
text = readFileSync(path, "utf8");
|
|
321
|
+
} catch {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
return GENERATED_ROUTE_HEADER.test(text) ? text : undefined;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function readRouteRenamesFromSiteMdx() {
|
|
328
|
+
const renames = {};
|
|
329
|
+
for (const [family, schema] of Object.entries(ROUTE_PATH_SCHEMAS)) {
|
|
330
|
+
const value = siteFrontmatterAtBuild?.[family]?.path;
|
|
331
|
+
if (value === undefined || value === null) continue;
|
|
332
|
+
const parsed = schema.safeParse(value);
|
|
333
|
+
if (!parsed.success) refuseRouteRename(family, value, parsed.error.issues[0].message);
|
|
334
|
+
renames[family] = parsed.data.slice(1);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const [refusal] = routeRenameRefusals(renames, ROUTE_CONVENTIONS, NON_LOCALE_SEGMENTS, [
|
|
338
|
+
...enabledLocalesAtBuild.split(",").map((l) => l.toLowerCase()),
|
|
339
|
+
docsPathAtBuild.split("/")[1],
|
|
340
|
+
servicesPathAtBuild.split("/")[1],
|
|
341
|
+
...NON_LOCALE_SEGMENTS,
|
|
342
|
+
]);
|
|
343
|
+
if (refusal !== undefined) {
|
|
344
|
+
const family = refusal.split(" → ")[0];
|
|
345
|
+
const value = `/${renames[family]}`;
|
|
346
|
+
refuseRouteRename(family, value, refusal.slice(`${family} → ${value}: `.length));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// A renamed family's route files must be generated under its new segment,
|
|
350
|
+
// and that page must be the family's own (`…/pages/<convention>/…`).
|
|
351
|
+
for (const [family, segment] of Object.entries(renames)) {
|
|
352
|
+
const text = readGeneratedRoute(join(ROUTE_ROOT, segment, "page.tsx"));
|
|
353
|
+
const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
|
|
354
|
+
if (!module?.includes(`/pages/${ROUTE_CONVENTIONS[family]}/`)) {
|
|
355
|
+
refuseRouteRename(
|
|
356
|
+
family,
|
|
357
|
+
`/${segment}`,
|
|
358
|
+
`app/[locale]/${segment}/page.tsx is not the ${family} family's generated route file; run create-ailk routes --write`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// And no generated route file may serve a family away from its segment:
|
|
364
|
+
// the package page it re-exports (`…/pages/<segment>/…`) names its family.
|
|
365
|
+
const familyOfSegment = Object.fromEntries(
|
|
366
|
+
Object.entries(ROUTE_CONVENTIONS).map(([family, segment]) => [segment, family]),
|
|
367
|
+
);
|
|
368
|
+
let dirs = [];
|
|
369
|
+
try {
|
|
370
|
+
dirs = readdirSync(ROUTE_ROOT, { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
371
|
+
} catch {
|
|
372
|
+
// No app/[locale]/ — nothing generated to check.
|
|
373
|
+
}
|
|
374
|
+
for (const { name: dir } of dirs) {
|
|
375
|
+
const text = readGeneratedRoute(join(ROUTE_ROOT, dir, "page.tsx"));
|
|
376
|
+
const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
|
|
377
|
+
const family = module && familyOfSegment[/\/pages\/([^/]+)\//.exec(module)?.[1]];
|
|
378
|
+
if (!family) continue;
|
|
379
|
+
const served = renames[family] ?? ROUTE_CONVENTIONS[family];
|
|
380
|
+
if (dir !== served) {
|
|
381
|
+
throw new Error(
|
|
382
|
+
`app/[locale]/${dir}/page.tsx re-exports ${module}, the ${family} family's page, which this site serves at /${served}; run create-ailk routes --write`,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return renames;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const routePathsAtBuild = JSON.stringify(
|
|
390
|
+
Object.fromEntries(
|
|
391
|
+
Object.entries(readRouteRenamesFromSiteMdx()).map(([family, segment]) => [
|
|
392
|
+
ROUTE_CONVENTIONS[family],
|
|
393
|
+
segment,
|
|
394
|
+
]),
|
|
395
|
+
),
|
|
396
|
+
);
|
|
397
|
+
// Before the config is built, so `legacyRedirects()` in `redirects()` reads it.
|
|
398
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = routePathsAtBuild;
|
|
399
|
+
|
|
283
400
|
// #10647 D6 — a database spoke's pages name library images as `asset:<key>`,
|
|
284
401
|
// which the hub resolves to its own `/v1/assets/:id` URLs. `next/image` admits
|
|
285
402
|
// that path on the hub's origin, and nothing else, when `AILK_API_URL` (the
|
|
@@ -426,6 +543,10 @@ const nextConfig = {
|
|
|
426
543
|
// services.path, or `/services`. Read by middleware.ts,
|
|
427
544
|
// lib/services-path.ts and @working-theory/page-renderer.
|
|
428
545
|
NEXT_PUBLIC_AILK_SERVICES_PATH: servicesPathAtBuild,
|
|
546
|
+
// The route-family renames (#11385), from content/_site.mdx's
|
|
547
|
+
// `<family>.path` keys, as `{ <convention segment>: <served segment> }`,
|
|
548
|
+
// or `{}`. Read by @working-theory/templates/route-paths.
|
|
549
|
+
NEXT_PUBLIC_AILK_ROUTE_PATHS: routePathsAtBuild,
|
|
429
550
|
},
|
|
430
551
|
async headers() {
|
|
431
552
|
if (!STEALTH) return [];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* handlers to avoid copy-paste duplication.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { pagePath, routeFor } from "@working-theory/templates/routes";
|
|
8
|
+
import { pagePath, renamedPath, routeFor } from "@working-theory/templates/routes";
|
|
9
9
|
|
|
10
10
|
import { SERVICES_PATH } from "../../lib/services-path";
|
|
11
11
|
import { SITE_BASE_URL } from "../../lib/site-brand";
|
|
@@ -44,8 +44,10 @@ export function resolveBaseUrl(): string {
|
|
|
44
44
|
* optional. `sitemap.xml`, `llms.txt` and, since #10775, the docs-blog
|
|
45
45
|
* module's `docs-blog/llms-route.ts` call `pagePathFor` instead; the export
|
|
46
46
|
* stays for a docs-blog site that installed the older copy of that route.
|
|
47
|
+
* It answers the public path, so a renamed route family's segment applies
|
|
48
|
+
* (#11385 D3); `routeFor` stays the hub's path key.
|
|
47
49
|
*/
|
|
48
|
-
export const slugToPath
|
|
50
|
+
export const slugToPath = (type: string, slug: string): string => renamedPath(routeFor(type, slug));
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* One listed page's public path (#10043 D9): `slugToPath`, except that the
|
package/versions.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@working-theory/account": "0.
|
|
3
|
-
"@working-theory/admin-ui": "0.
|
|
4
|
-
"@working-theory/aeo": "0.
|
|
5
|
-
"@working-theory/agent-context": "0.
|
|
2
|
+
"@working-theory/account": "0.69.0",
|
|
3
|
+
"@working-theory/admin-ui": "0.69.0",
|
|
4
|
+
"@working-theory/aeo": "0.69.0",
|
|
5
|
+
"@working-theory/agent-context": "0.69.0",
|
|
6
6
|
"@working-theory/agent-contract": "0.1.0",
|
|
7
7
|
"@working-theory/agent-memory": "0.0.0",
|
|
8
8
|
"@working-theory/ai": "0.1.0",
|
|
9
|
-
"@working-theory/analytics": "0.
|
|
10
|
-
"@working-theory/api": "0.
|
|
11
|
-
"@working-theory/api-client": "0.
|
|
12
|
-
"@working-theory/auth": "0.
|
|
9
|
+
"@working-theory/analytics": "0.69.0",
|
|
10
|
+
"@working-theory/api": "0.69.0",
|
|
11
|
+
"@working-theory/api-client": "0.69.0",
|
|
12
|
+
"@working-theory/auth": "0.69.0",
|
|
13
13
|
"@working-theory/cda-filesystem": "0.0.0",
|
|
14
|
-
"@working-theory/cli": "0.
|
|
15
|
-
"@working-theory/common": "0.
|
|
14
|
+
"@working-theory/cli": "0.69.0",
|
|
15
|
+
"@working-theory/common": "0.69.0",
|
|
16
16
|
"@working-theory/consent": "0.1.0",
|
|
17
|
-
"@working-theory/content-adapters": "0.
|
|
18
|
-
"@working-theory/content-projection": "0.
|
|
19
|
-
"@working-theory/email": "0.
|
|
17
|
+
"@working-theory/content-adapters": "0.69.0",
|
|
18
|
+
"@working-theory/content-projection": "0.69.0",
|
|
19
|
+
"@working-theory/email": "0.69.0",
|
|
20
20
|
"@working-theory/env": "0.0.0",
|
|
21
|
-
"@working-theory/eslint-config": "0.
|
|
22
|
-
"@working-theory/fumadocs-schema": "0.
|
|
21
|
+
"@working-theory/eslint-config": "0.69.0",
|
|
22
|
+
"@working-theory/fumadocs-schema": "0.69.0",
|
|
23
23
|
"@working-theory/ids": "0.21.0",
|
|
24
|
-
"@working-theory/jsonld": "0.
|
|
25
|
-
"@working-theory/license": "0.
|
|
26
|
-
"@working-theory/mcp-server": "0.
|
|
27
|
-
"@working-theory/metadata": "0.
|
|
28
|
-
"@working-theory/observability": "0.
|
|
29
|
-
"@working-theory/page-renderer": "0.
|
|
24
|
+
"@working-theory/jsonld": "0.69.0",
|
|
25
|
+
"@working-theory/license": "0.69.0",
|
|
26
|
+
"@working-theory/mcp-server": "0.69.0",
|
|
27
|
+
"@working-theory/metadata": "0.69.0",
|
|
28
|
+
"@working-theory/observability": "0.69.0",
|
|
29
|
+
"@working-theory/page-renderer": "0.69.0",
|
|
30
30
|
"@working-theory/plugin-mcp": "0.1.3",
|
|
31
|
-
"@working-theory/schema": "0.
|
|
32
|
-
"@working-theory/schema-pack-registry": "0.
|
|
33
|
-
"@working-theory/schema-validator": "0.
|
|
34
|
-
"@working-theory/sections-registry": "0.
|
|
35
|
-
"@working-theory/site-config": "0.
|
|
36
|
-
"@working-theory/site-pages": "0.
|
|
37
|
-
"@working-theory/spoke-checkout": "0.7.
|
|
38
|
-
"@working-theory/stripe-client": "0.
|
|
39
|
-
"@working-theory/templates": "0.
|
|
40
|
-
"@working-theory/theme": "0.
|
|
41
|
-
"@working-theory/ui": "0.
|
|
42
|
-
"@working-theory/validation": "0.
|
|
43
|
-
"@working-theory/web-i18n": "0.
|
|
44
|
-
"@working-theory/admin": "0.
|
|
45
|
-
"@working-theory/api-commerce": "0.2.
|
|
46
|
-
"@working-theory/api-content-write": "0.
|
|
47
|
-
"@working-theory/api-hub": "0.7.
|
|
48
|
-
"@working-theory/api-multi-tenant": "0.4.
|
|
49
|
-
"@working-theory/api-scheduling": "0.6.
|
|
50
|
-
"@working-theory/api-signal-collectors": "0.6.
|
|
51
|
-
"@working-theory/api-workspace": "0.
|
|
31
|
+
"@working-theory/schema": "0.69.0",
|
|
32
|
+
"@working-theory/schema-pack-registry": "0.69.0",
|
|
33
|
+
"@working-theory/schema-validator": "0.69.0",
|
|
34
|
+
"@working-theory/sections-registry": "0.69.0",
|
|
35
|
+
"@working-theory/site-config": "0.69.0",
|
|
36
|
+
"@working-theory/site-pages": "0.69.0",
|
|
37
|
+
"@working-theory/spoke-checkout": "0.7.25",
|
|
38
|
+
"@working-theory/stripe-client": "0.69.0",
|
|
39
|
+
"@working-theory/templates": "0.69.0",
|
|
40
|
+
"@working-theory/theme": "0.69.0",
|
|
41
|
+
"@working-theory/ui": "0.69.0",
|
|
42
|
+
"@working-theory/validation": "0.69.0",
|
|
43
|
+
"@working-theory/web-i18n": "0.69.0",
|
|
44
|
+
"@working-theory/admin": "0.20.0",
|
|
45
|
+
"@working-theory/api-commerce": "0.2.3",
|
|
46
|
+
"@working-theory/api-content-write": "0.13.0",
|
|
47
|
+
"@working-theory/api-hub": "0.7.3",
|
|
48
|
+
"@working-theory/api-multi-tenant": "0.4.3",
|
|
49
|
+
"@working-theory/api-scheduling": "0.6.8",
|
|
50
|
+
"@working-theory/api-signal-collectors": "0.6.9",
|
|
51
|
+
"@working-theory/api-workspace": "0.13.0",
|
|
52
52
|
"@working-theory/billing-client": "0.0.0",
|
|
53
53
|
"@working-theory/branding": "0.0.0",
|
|
54
54
|
"@working-theory/license-client": "0.0.0",
|
|
55
55
|
"@working-theory/license-manifest": "0.0.0",
|
|
56
|
-
"@working-theory/mcp-scheduling": "0.4.
|
|
57
|
-
"@working-theory/mcp-signal-collectors": "0.2.
|
|
58
|
-
"@working-theory/mcp-workspace": "0.
|
|
56
|
+
"@working-theory/mcp-scheduling": "0.4.10",
|
|
57
|
+
"@working-theory/mcp-signal-collectors": "0.2.23",
|
|
58
|
+
"@working-theory/mcp-workspace": "0.12.0",
|
|
59
59
|
"@working-theory/partner-session": "0.0.0",
|
|
60
60
|
"@working-theory/preview-protocol": "0.0.0",
|
|
61
|
-
"@working-theory/ui-commerce": "0.
|
|
62
|
-
"@working-theory/ui-docs-blog": "0.
|
|
63
|
-
"@working-theory/ui-scheduling": "0.
|
|
64
|
-
"@working-theory/ui-signal-collectors": "0.
|
|
61
|
+
"@working-theory/ui-commerce": "0.69.0",
|
|
62
|
+
"@working-theory/ui-docs-blog": "0.69.0",
|
|
63
|
+
"@working-theory/ui-scheduling": "0.69.0",
|
|
64
|
+
"@working-theory/ui-signal-collectors": "0.69.0",
|
|
65
65
|
"@working-theory/web": "0.0.0",
|
|
66
66
|
"@working-theory/app-api": "1.0.0",
|
|
67
67
|
"@working-theory/mcp": "0.0.0",
|
|
68
|
-
"@working-theory/database": "0.
|
|
68
|
+
"@working-theory/database": "0.69.0"
|
|
69
69
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shape a deliverable grant id must match before anything spends a hub
|
|
3
|
-
* call on it (#9125). One definition, read by the report page
|
|
4
|
-
* (`app/[locale]/reports/[slug]/page.tsx`, `resolveGrantId`) and its file
|
|
5
|
-
* route (`app/[locale]/reports/[slug]/file/route.ts`), so the page and the
|
|
6
|
-
* bytes can never disagree on which ids are worth probing.
|
|
7
|
-
*
|
|
8
|
-
* A grant id is minted as `dgrant_<uuidv7>` (database/inbox/schema.prisma).
|
|
9
|
-
* This is deliberately a charset-and-length check, not a `dgrant_` prefix
|
|
10
|
-
* match: the API stays the authority on which ids are real, and a future id
|
|
11
|
-
* scheme should not need an edit here. 128 is a generous ceiling over today's
|
|
12
|
-
* `dgrant_<uuid>`.
|
|
13
|
-
*
|
|
14
|
-
* Deliberately base-tree, not slice-owned: a keyed scaffold's
|
|
15
|
-
* signal-collectors bundle installs the page and route that import it, so it
|
|
16
|
-
* must already be in every scaffold.
|
|
17
|
-
*/
|
|
18
|
-
export const GRANT_ID_SHAPE = /^[A-Za-z0-9_-]{1,128}$/;
|