create-ailk 0.45.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +6 -3
  2. package/component-catalog.json +217 -4
  3. package/component-catalog.md +10 -7
  4. package/dist/lib/env-catalog.js +1 -1
  5. package/dist/lib/import-mdx.js +10 -2
  6. package/dist/seed-workspace.d.ts +1 -1
  7. package/dist/seed-workspace.js +10 -3
  8. package/dist/surfaces.js +1 -1
  9. package/package.json +3 -3
  10. package/templates/apps/api/.env.example +23 -0
  11. package/templates/apps/api/CLAUDE.md +13 -6
  12. package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
  13. package/templates/apps/mcp/.env.example +8 -0
  14. package/templates/apps/mcp/CLAUDE.md +22 -6
  15. package/templates/apps/web/.env.example +1 -1
  16. package/templates/apps/web/CLAUDE.md +80 -16
  17. package/templates/apps/web/app/.well-known/mcp.json/route.ts +6 -7
  18. package/templates/apps/web/app/[locale]/layout.tsx +10 -7
  19. package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
  20. package/templates/apps/web/app/api/site-status/route.ts +62 -0
  21. package/templates/apps/web/app/llms.txt/route.ts +3 -3
  22. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
  23. package/templates/apps/web/app/openapi.json/route.ts +10 -9
  24. package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
  25. package/templates/apps/web/auth.ts +25 -1
  26. package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +10 -3
  27. package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +61 -0
  28. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +384 -1
  29. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +675 -0
  30. package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
  31. package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
  32. package/templates/apps/web/lib/mcp-oauth.ts +64 -0
  33. package/templates/apps/web/lib/mcp-served-tools.ts +51 -9
  34. package/templates/apps/web/lib/offerings-pricing.ts +173 -20
  35. package/templates/apps/web/lib/pricing-page.ts +382 -43
  36. package/templates/apps/web/lib/site-brand.tsx +1 -7
  37. package/templates/apps/web/lib/site-visibility.ts +45 -0
  38. package/templates/apps/web/messages/en.json +9 -0
  39. package/templates/apps/web/middleware.ts +16 -1
  40. package/templates/apps/web/src/lib/routes.ts +3 -3
  41. package/versions.json +51 -51
  42. package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
@@ -43,6 +43,12 @@
43
43
  // base, so old links keep working. A site with no `services.path` takes none
44
44
  // of these branches.
45
45
  //
46
+ // Site visibility (#11978 D2). While the site is Hidden — STEALTH on the
47
+ // hosting project, or the owner's switch off — every response this middleware
48
+ // returns, on every branch, carries `X-Robots-Tag: noindex, nofollow,
49
+ // noarchive`, the value STEALTH's next.config.mjs rule sends. `siteHidden()` is
50
+ // awaited once per request; its hub read is shared per instance for 15 s.
51
+ //
46
52
  // S16 spec: docs/internal/specs/ailk-pre-oss-security-phase-3-s16-security-headers-spec.md
47
53
  // S2 spec: docs/internal/specs/i18n-phase1-s2-next-intl-foundation-spec.md
48
54
  // P2 S1 spec: docs/internal/specs/i18n-phase2-s1-hreflang-metadata-spec.md §3
@@ -69,6 +75,7 @@ import {
69
75
  toInternalServicesPath,
70
76
  toPublicServicesHref,
71
77
  } from "./lib/services-path";
78
+ import { HIDDEN_ROBOTS_HEADER, siteHidden } from "./lib/site-visibility";
72
79
  import {
73
80
  DEFAULT_SECURITY_HEADERS,
74
81
  ONE_TAP_SECURITY_HEADERS,
@@ -185,7 +192,7 @@ const FILE_ROUTE_SECURITY_HEADERS: Readonly<Record<string, string>> =
185
192
  ),
186
193
  );
187
194
 
188
- export function middleware(request: NextRequest): NextResponse {
195
+ function route(request: NextRequest): NextResponse {
189
196
  // Step 1: Forward x-pathname to server components so generateMetadata can
190
197
  // build path-aware hreflang alternates (P2 S1). Clone the request headers
191
198
  // and inject the pathname before running next-intl so the rewritten URL
@@ -291,6 +298,14 @@ export function middleware(request: NextRequest): NextResponse {
291
298
  return intlResponse;
292
299
  }
293
300
 
301
+ export async function middleware(request: NextRequest): Promise<NextResponse> {
302
+ const hidden = await siteHidden();
303
+ const response = route(request);
304
+ // #11978 D2 — Hidden replaces a `!PUBLIC_PAGES` noindex, never removes it.
305
+ if (hidden) response.headers.set("X-Robots-Tag", HIDDEN_ROBOTS_HEADER);
306
+ return response;
307
+ }
308
+
294
309
  // Skip Next.js internal assets and public/ files — security headers attach to
295
310
  // user-facing routes and API handlers, not framework or static asset endpoints.
296
311
  // Also exclude next-intl-specific internal paths (_next/server).
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Shared route utilities for agent-surface discovery routes.
3
3
  *
4
- * Extracted from llms.txt, sitemap.xml, robots.txt, and ai-plugin.json
5
- * handlers to avoid copy-paste duplication.
4
+ * Extracted from the llms.txt, sitemap.xml and robots.txt handlers to avoid
5
+ * copy-paste duplication.
6
6
  */
7
7
 
8
8
  import { pagePath, renamedPath, routeFor } from "@working-theory/templates/routes";
@@ -21,7 +21,7 @@ import { SITE_BASE_URL } from "../../lib/site-brand";
21
21
  * expect a per-call env read, the same contract this function had before
22
22
  * #4157; a frozen snapshot would silently stop honoring an env var set
23
23
  * after this module first loaded. Every caller runs in the Node.js runtime
24
- * (none of robots.txt/sitemap.xml/llms.txt/ai-plugin.json/mcp.json/layout
24
+ * (none of robots.txt/sitemap.xml/llms.txt/mcp.json/layout
25
25
  * declares `runtime = "edge"`), so the frontmatter-derived fallback
26
26
  * (`SITE_BASE_URL`, when no env override is set) is safe here.
27
27
  */
package/versions.json CHANGED
@@ -1,69 +1,69 @@
1
1
  {
2
- "@working-theory/account": "0.73.0",
3
- "@working-theory/admin-ui": "0.73.0",
4
- "@working-theory/aeo": "0.73.0",
5
- "@working-theory/agent-context": "0.73.0",
2
+ "@working-theory/account": "0.75.0",
3
+ "@working-theory/admin-ui": "0.75.0",
4
+ "@working-theory/aeo": "0.75.0",
5
+ "@working-theory/agent-context": "0.75.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.73.0",
10
- "@working-theory/api": "0.73.0",
11
- "@working-theory/api-client": "0.73.0",
12
- "@working-theory/auth": "0.73.0",
9
+ "@working-theory/analytics": "0.75.0",
10
+ "@working-theory/api": "0.75.0",
11
+ "@working-theory/api-client": "0.75.0",
12
+ "@working-theory/auth": "0.75.0",
13
13
  "@working-theory/cda-filesystem": "0.0.0",
14
- "@working-theory/cli": "0.73.0",
15
- "@working-theory/common": "0.73.0",
14
+ "@working-theory/cli": "0.75.0",
15
+ "@working-theory/common": "0.75.0",
16
16
  "@working-theory/consent": "0.1.0",
17
- "@working-theory/content-adapters": "0.73.0",
18
- "@working-theory/content-projection": "0.73.0",
19
- "@working-theory/email": "0.73.0",
17
+ "@working-theory/content-adapters": "0.75.0",
18
+ "@working-theory/content-projection": "0.75.0",
19
+ "@working-theory/email": "0.75.0",
20
20
  "@working-theory/env": "0.0.0",
21
- "@working-theory/eslint-config": "0.73.0",
22
- "@working-theory/fumadocs-schema": "0.73.0",
23
- "@working-theory/ids": "0.22.0",
24
- "@working-theory/jsonld": "0.73.0",
25
- "@working-theory/license": "0.73.0",
26
- "@working-theory/mcp-server": "0.73.0",
27
- "@working-theory/metadata": "0.73.0",
28
- "@working-theory/observability": "0.73.0",
29
- "@working-theory/page-renderer": "0.73.0",
21
+ "@working-theory/eslint-config": "0.75.0",
22
+ "@working-theory/fumadocs-schema": "0.75.0",
23
+ "@working-theory/ids": "0.23.0",
24
+ "@working-theory/jsonld": "0.75.0",
25
+ "@working-theory/license": "0.75.0",
26
+ "@working-theory/mcp-server": "0.75.0",
27
+ "@working-theory/metadata": "0.75.0",
28
+ "@working-theory/observability": "0.75.0",
29
+ "@working-theory/page-renderer": "0.75.0",
30
30
  "@working-theory/plugin-mcp": "0.1.3",
31
- "@working-theory/schema": "0.73.0",
32
- "@working-theory/schema-pack-registry": "0.73.0",
33
- "@working-theory/schema-validator": "0.73.0",
34
- "@working-theory/sections-registry": "0.73.0",
35
- "@working-theory/site-config": "0.73.0",
36
- "@working-theory/site-pages": "0.73.0",
37
- "@working-theory/spoke-checkout": "0.7.29",
38
- "@working-theory/stripe-client": "0.73.0",
39
- "@working-theory/templates": "0.73.0",
40
- "@working-theory/theme": "0.73.0",
41
- "@working-theory/ui": "0.73.0",
42
- "@working-theory/validation": "0.73.0",
43
- "@working-theory/web-i18n": "0.73.0",
44
- "@working-theory/admin": "0.24.0",
45
- "@working-theory/api-commerce": "0.2.7",
46
- "@working-theory/api-content-write": "0.15.1",
47
- "@working-theory/api-hub": "0.7.7",
48
- "@working-theory/api-multi-tenant": "0.4.7",
49
- "@working-theory/api-scheduling": "0.6.12",
50
- "@working-theory/api-signal-collectors": "0.7.2",
51
- "@working-theory/api-workspace": "0.17.0",
31
+ "@working-theory/schema": "0.75.0",
32
+ "@working-theory/schema-pack-registry": "0.75.0",
33
+ "@working-theory/schema-validator": "0.75.0",
34
+ "@working-theory/sections-registry": "0.75.0",
35
+ "@working-theory/site-config": "0.75.0",
36
+ "@working-theory/site-pages": "0.75.0",
37
+ "@working-theory/spoke-checkout": "0.7.31",
38
+ "@working-theory/stripe-client": "0.75.0",
39
+ "@working-theory/templates": "0.75.0",
40
+ "@working-theory/theme": "0.75.0",
41
+ "@working-theory/ui": "0.75.0",
42
+ "@working-theory/validation": "0.75.0",
43
+ "@working-theory/web-i18n": "0.75.0",
44
+ "@working-theory/admin": "0.25.1",
45
+ "@working-theory/api-commerce": "0.2.9",
46
+ "@working-theory/api-content-write": "0.16.1",
47
+ "@working-theory/api-hub": "0.8.1",
48
+ "@working-theory/api-multi-tenant": "0.5.1",
49
+ "@working-theory/api-scheduling": "0.6.14",
50
+ "@working-theory/api-signal-collectors": "0.7.4",
51
+ "@working-theory/api-workspace": "0.18.1",
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.14",
57
- "@working-theory/mcp-signal-collectors": "0.2.27",
58
- "@working-theory/mcp-workspace": "0.15.1",
56
+ "@working-theory/mcp-scheduling": "0.4.16",
57
+ "@working-theory/mcp-signal-collectors": "0.2.29",
58
+ "@working-theory/mcp-workspace": "0.16.1",
59
59
  "@working-theory/partner-session": "0.0.0",
60
60
  "@working-theory/preview-protocol": "0.0.0",
61
- "@working-theory/ui-commerce": "0.73.0",
62
- "@working-theory/ui-docs-blog": "0.73.0",
63
- "@working-theory/ui-scheduling": "0.73.0",
64
- "@working-theory/ui-signal-collectors": "0.73.0",
61
+ "@working-theory/ui-commerce": "0.75.0",
62
+ "@working-theory/ui-docs-blog": "0.75.0",
63
+ "@working-theory/ui-scheduling": "0.75.0",
64
+ "@working-theory/ui-signal-collectors": "0.75.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.73.0"
68
+ "@working-theory/database": "0.75.0"
69
69
  }
@@ -1,93 +0,0 @@
1
- /**
2
- * GET /.well-known/ai-plugin.json
3
- *
4
- * Returns the agent plugin manifest for AILK. The shape conforms to the
5
- * AgentPluginManifestSchema defined in @working-theory/agent-contract.
6
- *
7
- * Fields with no source today default to 'none' / placeholder values and
8
- * are documented here for Phase 2 enrichment:
9
- * - logo_url: no asset yet; omitted
10
- * - contact_email: no org email configured; omitted
11
- * - legal_info_url: no legal page yet; omitted
12
- * - api.url: /openapi.json on this same origin, served by `app/openapi.json`,
13
- * which proxies apps/api's `/v1/openapi.json` (#7396)
14
- *
15
- * ─── Consumer re-validation expectation ─────────────────────────────────────
16
- * This manifest is published over a public, cacheable HTTP route. Consumers
17
- * (LLM agents, gateways, validators) MUST re-verify the manifest contents at
18
- * fetch time — DO NOT trust a cached or out-of-band copy. In particular:
19
- *
20
- * - `description_for_model`: an agent host should bound its length and
21
- * scan for prompt-injection patterns before passing it into a model
22
- * context window.
23
- * - `auth`: confirm the declared scheme matches the API's actual auth
24
- * enforcement at the OpenAPI endpoint.
25
- * - `api.url`: re-fetch the OpenAPI spec and validate the schema before
26
- * synthesizing tool definitions.
27
- *
28
- * See `docs/security/agent-manifest.md` for the full consumer guidance.
29
- */
30
-
31
- import { siteDiscoverable } from "@working-theory/api-client";
32
-
33
- import { SITE_DESCRIPTION, SITE_NAME } from "../../../lib/site-brand";
34
- import { resolveBaseUrl } from "../../../src/lib/routes";
35
-
36
- // #10510 D4 — read per request: the owner's discovery switch is a runtime
37
- // setting a prerendered file could never follow.
38
- export const dynamic = "force-dynamic";
39
-
40
- /** Soft cap to detect runaway `description_for_model` growth. */
41
- export const DESCRIPTION_FOR_MODEL_SOFT_CAP_CHARS = 8_000;
42
-
43
- // #4157 — SITE_NAME-based, and no longer describes AILK's own commercial
44
- // model ("purchase a license"): that claim was never true of a customer's
45
- // scaffolded site, which doesn't sell AILK licenses.
46
- const MANIFEST_DESCRIPTION_FOR_MODEL = `${SITE_NAME} is an AI-native site built with API + MCP as canonical agent surfaces. Use it to explore the site's content and available tools.`;
47
-
48
- /**
49
- * Validates that a manifest's `description_for_model` is within reasonable
50
- * bounds. Logs a warning when oversized; returns a boolean for callers that
51
- * want to short-circuit (we choose to still serve the manifest, since
52
- * truncating silently would be worse than warning).
53
- */
54
- export function validateDescriptionForModel(description: string): boolean {
55
- if (description.length > DESCRIPTION_FOR_MODEL_SOFT_CAP_CHARS) {
56
- console.warn(
57
- `[ai-plugin.json] description_for_model exceeds soft cap (${description.length} > ${DESCRIPTION_FOR_MODEL_SOFT_CAP_CHARS} chars). Consumers may rate-limit or reject oversized manifests.`,
58
- );
59
- return false;
60
- }
61
- return true;
62
- }
63
-
64
- // Startup-time validation: fire once on module load so over-sized manifests
65
- // are flagged before the first request lands.
66
- validateDescriptionForModel(MANIFEST_DESCRIPTION_FOR_MODEL);
67
-
68
- export async function GET(): Promise<Response> {
69
- // #10510 D4 — hidden by the owner: 404, never cached.
70
- if (!(await siteDiscoverable())) return new Response(null, { status: 404, headers: { "cache-control": "no-store" } });
71
- const baseUrl = resolveBaseUrl();
72
-
73
- const manifest = {
74
- schema_version: "v1",
75
- name_for_human: SITE_NAME,
76
- name_for_model: "ai_launch_kit",
77
- // #8085 — the site's own description, as /.well-known/mcp.json (#8057).
78
- description_for_human: SITE_DESCRIPTION,
79
- description_for_model: MANIFEST_DESCRIPTION_FOR_MODEL,
80
- auth: { type: "none" },
81
- api: {
82
- type: "openapi",
83
- url: `${baseUrl}/openapi.json`,
84
- },
85
- };
86
-
87
- return Response.json(manifest, {
88
- status: 200,
89
- headers: {
90
- "cache-control": "public, max-age=86400",
91
- },
92
- });
93
- }