create-ailk 0.1.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/LICENSE +201 -0
- package/README.md +39 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +80 -0
- package/dist/copy.d.ts +8 -0
- package/dist/copy.js +109 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/lib/pro-callout.d.ts +12 -0
- package/dist/lib/pro-callout.js +20 -0
- package/dist/parse-args.d.ts +13 -0
- package/dist/parse-args.js +81 -0
- package/dist/programmatic.d.ts +49 -0
- package/dist/programmatic.js +89 -0
- package/dist/substitute.d.ts +31 -0
- package/dist/substitute.js +45 -0
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +70 -0
- package/package.json +47 -0
- package/templates/.claude/.gitkeep +0 -0
- package/templates/.claude/agents/web.md +80 -0
- package/templates/.claude/rules/architecture.md +62 -0
- package/templates/.claude/rules/preserve-existing-style.md +51 -0
- package/templates/.claude/skills/README.md +43 -0
- package/templates/.claude/skills/add-schema/SKILL.md +270 -0
- package/templates/.claude/skills/add-schema/references/conflict-handling.md +200 -0
- package/templates/.claude/skills/add-schema/references/file-finding.md +123 -0
- package/templates/.claude/skills/add-schema/references/schema-types.md +131 -0
- package/templates/.claude/skills/audit-site/SKILL.md +213 -0
- package/templates/.claude/skills/audit-site/references/common-errors.md +113 -0
- package/templates/.claude/skills/audit-site/references/findings-glossary.md +138 -0
- package/templates/.claude/skills/audit-site/references/severity-levels.md +114 -0
- package/templates/.claude/skills/provision-config/SKILL.md +243 -0
- package/templates/.claude/skills/provision-config/references/env-vars-template.md +184 -0
- package/templates/.claude/skills/provision-config/references/runbook-template.md +248 -0
- package/templates/.claude/skills/provision-config/references/vercel-json-template.md +98 -0
- package/templates/.claude/skills/scaffold-auth/SKILL.md +261 -0
- package/templates/.claude/skills/scaffold-auth/references/env-vars.md +91 -0
- package/templates/.claude/skills/scaffold-auth/references/oauth-app-setup.md +171 -0
- package/templates/.claude/skills/scaffold-commerce/SKILL.md +310 -0
- package/templates/.claude/skills/scaffold-commerce/references/lookup-keys-template.md +71 -0
- package/templates/.claude/skills/scaffold-commerce/references/marketplace-brand-pages.md +83 -0
- package/templates/.claude/skills/scaffold-commerce/templates/marketplace-cta-route.tsx.tmpl +72 -0
- package/templates/.claude/skills/scaffold-page/SKILL.md +243 -0
- package/templates/.claude/skills/scaffold-page/references/page-types.md +169 -0
- package/templates/.claude/skills/scaffold-page/templates/content.mdx.tmpl +28 -0
- package/templates/.claude/skills/scaffold-page/templates/route.tsx.tmpl +28 -0
- package/templates/.claude/skills/suggest-site-pages/SKILL.md +242 -0
- package/templates/.claude/skills/suggest-site-pages/references/categories.md +287 -0
- package/templates/.env.example +205 -0
- package/templates/.gitkeep +2 -0
- package/templates/CLAUDE.md +142 -0
- package/templates/CONVENTIONS.md +222 -0
- package/templates/README.md +110 -0
- package/templates/apps/api/.env.example +40 -0
- package/templates/apps/api/CLAUDE.md +63 -0
- package/templates/apps/api/api/index.ts +144 -0
- package/templates/apps/api/jest.config.cjs +74 -0
- package/templates/apps/api/package.json +54 -0
- package/templates/apps/api/src/__tests__/factories/content-fixture.ts +138 -0
- package/templates/apps/api/src/__tests__/factories/index.ts +70 -0
- package/templates/apps/api/src/__tests__/factories/lead-fixture.ts +82 -0
- package/templates/apps/api/src/__tests__/index.test.ts +118 -0
- package/templates/apps/api/src/__tests__/server.test.ts +207 -0
- package/templates/apps/api/src/__tests__/services/enrichment-shim.test.ts +126 -0
- package/templates/apps/api/src/__tests__/setup.ts +24 -0
- package/templates/apps/api/src/cli.ts +30 -0
- package/templates/apps/api/src/config/__tests__/index.test.ts +97 -0
- package/templates/apps/api/src/config/index.ts +56 -0
- package/templates/apps/api/src/index.ts +32 -0
- package/templates/apps/api/src/lib/__mocks__/prisma-client.js +15 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +45 -0
- package/templates/apps/api/src/lib/__tests__/content-adapter.test.ts +178 -0
- package/templates/apps/api/src/lib/__tests__/error-serializer.test.ts +100 -0
- package/templates/apps/api/src/lib/__tests__/errors.test.ts +94 -0
- package/templates/apps/api/src/lib/__tests__/file-fallback.test.ts +144 -0
- package/templates/apps/api/src/lib/__tests__/fixtures/HomePage/home.mdx +8 -0
- package/templates/apps/api/src/lib/__tests__/lead-capture-store.test.ts +227 -0
- package/templates/apps/api/src/lib/__tests__/outbound-http.test.ts +125 -0
- package/templates/apps/api/src/lib/__tests__/prisma.test.ts +165 -0
- package/templates/apps/api/src/lib/__tests__/require-paid-tier.test.ts +129 -0
- package/templates/apps/api/src/lib/__tests__/stripe.test.ts +74 -0
- package/templates/apps/api/src/lib/content-adapter.ts +86 -0
- package/templates/apps/api/src/lib/error-serializer.ts +77 -0
- package/templates/apps/api/src/lib/errors.ts +95 -0
- package/templates/apps/api/src/lib/file-fallback.ts +87 -0
- package/templates/apps/api/src/lib/lead-capture-store.ts +110 -0
- package/templates/apps/api/src/lib/locales.ts +201 -0
- package/templates/apps/api/src/lib/outbound-http.ts +122 -0
- package/templates/apps/api/src/lib/prisma.ts +21 -0
- package/templates/apps/api/src/lib/require-paid-tier.ts +53 -0
- package/templates/apps/api/src/lib/stripe.ts +30 -0
- package/templates/apps/api/src/lib/webhook-idempotency.ts +92 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/bearer-token-format.test.ts +111 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/cookie-or-bearer-precedence.test.ts +172 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-bearer-skip.test.ts +119 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-cookie-path.test.ts +138 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/session-fixation.test.ts +149 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/session-timeout.test.ts +139 -0
- package/templates/apps/api/src/middleware/__tests__/auth.bearer-path.test.ts +175 -0
- package/templates/apps/api/src/middleware/__tests__/auth.both-present-precedence.test.ts +76 -0
- package/templates/apps/api/src/middleware/__tests__/auth.cookie-path.test.ts +153 -0
- package/templates/apps/api/src/middleware/__tests__/auth.neither-present.test.ts +72 -0
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +292 -0
- package/templates/apps/api/src/middleware/auth.ts +246 -0
- package/templates/apps/api/src/middleware/rate-limit.ts +132 -0
- package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +129 -0
- package/templates/apps/api/src/openapi/index.ts +12 -0
- package/templates/apps/api/src/openapi/spec.ts +408 -0
- package/templates/apps/api/src/routes/auth/__tests__/auth-tokens.functional.test.ts +193 -0
- package/templates/apps/api/src/routes/auth/__tests__/auth-user.functional.test.ts +201 -0
- package/templates/apps/api/src/routes/auth/__tests__/tokens.test.ts +294 -0
- package/templates/apps/api/src/routes/auth/__tests__/user.test.ts +486 -0
- package/templates/apps/api/src/routes/auth/tokens.ts +199 -0
- package/templates/apps/api/src/routes/auth/user.ts +244 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +588 -0
- package/templates/apps/api/src/routes/checkout/index.ts +13 -0
- package/templates/apps/api/src/routes/checkout/sessions.ts +185 -0
- package/templates/apps/api/src/routes/content/__tests__/create.test.ts +239 -0
- package/templates/apps/api/src/routes/content/__tests__/delete.test.ts +201 -0
- package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +141 -0
- package/templates/apps/api/src/routes/content/__tests__/list-pages.test.ts +122 -0
- package/templates/apps/api/src/routes/content/__tests__/list-types.test.ts +44 -0
- package/templates/apps/api/src/routes/content/__tests__/locale.test.ts +118 -0
- package/templates/apps/api/src/routes/content/__tests__/rate-limit.test.ts +51 -0
- package/templates/apps/api/src/routes/content/__tests__/update.test.ts +252 -0
- package/templates/apps/api/src/routes/content/create.ts +114 -0
- package/templates/apps/api/src/routes/content/delete.ts +81 -0
- package/templates/apps/api/src/routes/content/get-page.ts +98 -0
- package/templates/apps/api/src/routes/content/index.ts +32 -0
- package/templates/apps/api/src/routes/content/list-pages.ts +83 -0
- package/templates/apps/api/src/routes/content/list-types.ts +19 -0
- package/templates/apps/api/src/routes/content/rate-limit.ts +13 -0
- package/templates/apps/api/src/routes/content/slug.ts +9 -0
- package/templates/apps/api/src/routes/content/update.ts +111 -0
- package/templates/apps/api/src/routes/leads/__tests__/index.test.ts +415 -0
- package/templates/apps/api/src/routes/leads/__tests__/track.test.ts +165 -0
- package/templates/apps/api/src/routes/leads/index.ts +130 -0
- package/templates/apps/api/src/routes/test/auth/__tests__/session.test.ts +296 -0
- package/templates/apps/api/src/routes/test/auth/session.ts +141 -0
- package/templates/apps/api/src/routes/webhooks/README.md +57 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-idempotency.test.ts +247 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-rate-limit.test.ts +198 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +633 -0
- package/templates/apps/api/src/routes/webhooks/index.ts +41 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +253 -0
- package/templates/apps/api/src/server.ts +157 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +395 -0
- package/templates/apps/api/src/services/enrichment-shim.ts +53 -0
- package/templates/apps/api/src/services/lead-routing.ts +338 -0
- package/templates/apps/api/tsconfig.json +34 -0
- package/templates/apps/api/vercel.json +17 -0
- package/templates/apps/mcp/.env.example +52 -0
- package/templates/apps/mcp/CLAUDE.md +84 -0
- package/templates/apps/mcp/__tests__/abuse/daily-cap.test.ts +52 -0
- package/templates/apps/mcp/__tests__/abuse/email-validator.test.ts +46 -0
- package/templates/apps/mcp/__tests__/abuse/honeypot.test.ts +36 -0
- package/templates/apps/mcp/__tests__/abuse/user-agent-deny.test.ts +54 -0
- package/templates/apps/mcp/__tests__/aeo-cli-parity.test.ts +110 -0
- package/templates/apps/mcp/__tests__/audit-single-page.test.ts +213 -0
- package/templates/apps/mcp/__tests__/audit.test.ts +217 -0
- package/templates/apps/mcp/__tests__/catalog-drift.test.ts +52 -0
- package/templates/apps/mcp/__tests__/create_page.test.ts +201 -0
- package/templates/apps/mcp/__tests__/delete_page.test.ts +176 -0
- package/templates/apps/mcp/__tests__/get_business_hours.test.ts +82 -0
- package/templates/apps/mcp/__tests__/get_faq.test.ts +80 -0
- package/templates/apps/mcp/__tests__/get_locations.test.ts +65 -0
- package/templates/apps/mcp/__tests__/get_offerings.test.ts +90 -0
- package/templates/apps/mcp/__tests__/get_pricing.test.ts +80 -0
- package/templates/apps/mcp/__tests__/get_site_info.test.ts +81 -0
- package/templates/apps/mcp/__tests__/http-transport.test.ts +323 -0
- package/templates/apps/mcp/__tests__/lib/errors.test.ts +75 -0
- package/templates/apps/mcp/__tests__/lib/require-paid-tier.test.ts +75 -0
- package/templates/apps/mcp/__tests__/list_pages.test.ts +112 -0
- package/templates/apps/mcp/__tests__/locale.test.ts +135 -0
- package/templates/apps/mcp/__tests__/parity.test.ts +205 -0
- package/templates/apps/mcp/__tests__/purchase-disabled.test.ts +34 -0
- package/templates/apps/mcp/__tests__/read_content.test.ts +153 -0
- package/templates/apps/mcp/__tests__/request_callback.test.ts +163 -0
- package/templates/apps/mcp/__tests__/search_content.test.ts +153 -0
- package/templates/apps/mcp/__tests__/server.test.ts +115 -0
- package/templates/apps/mcp/__tests__/submit_lead.test.ts +165 -0
- package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +161 -0
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +227 -0
- package/templates/apps/mcp/__tests__/tools/scaffold.test.ts +237 -0
- package/templates/apps/mcp/__tests__/update_page.test.ts +195 -0
- package/templates/apps/mcp/jest.config.cjs +82 -0
- package/templates/apps/mcp/package.json +37 -0
- package/templates/apps/mcp/src/abuse/daily-cap.ts +47 -0
- package/templates/apps/mcp/src/abuse/email-validator.ts +25 -0
- package/templates/apps/mcp/src/abuse/honeypot.ts +21 -0
- package/templates/apps/mcp/src/abuse/index.ts +111 -0
- package/templates/apps/mcp/src/abuse/user-agent-deny.ts +58 -0
- package/templates/apps/mcp/src/http-transport.ts +303 -0
- package/templates/apps/mcp/src/index.ts +67 -0
- package/templates/apps/mcp/src/lib/audit-single-page.ts +194 -0
- package/templates/apps/mcp/src/lib/errors.ts +61 -0
- package/templates/apps/mcp/src/lib/locales.ts +171 -0
- package/templates/apps/mcp/src/lib/require-paid-tier.ts +44 -0
- package/templates/apps/mcp/src/lib/resolve-locale.ts +30 -0
- package/templates/apps/mcp/src/server.ts +139 -0
- package/templates/apps/mcp/src/tools/audit.ts +103 -0
- package/templates/apps/mcp/src/tools/capture_lead.ts +52 -0
- package/templates/apps/mcp/src/tools/create_page.ts +95 -0
- package/templates/apps/mcp/src/tools/delete_page.ts +73 -0
- package/templates/apps/mcp/src/tools/get_business_hours.ts +66 -0
- package/templates/apps/mcp/src/tools/get_faq.ts +69 -0
- package/templates/apps/mcp/src/tools/get_locations.ts +85 -0
- package/templates/apps/mcp/src/tools/get_offerings.ts +66 -0
- package/templates/apps/mcp/src/tools/get_pricing.ts +74 -0
- package/templates/apps/mcp/src/tools/get_site_info.ts +84 -0
- package/templates/apps/mcp/src/tools/index.ts +125 -0
- package/templates/apps/mcp/src/tools/list_pages.ts +72 -0
- package/templates/apps/mcp/src/tools/purchase.ts +89 -0
- package/templates/apps/mcp/src/tools/read_content.ts +61 -0
- package/templates/apps/mcp/src/tools/request_callback.ts +51 -0
- package/templates/apps/mcp/src/tools/scaffold.ts +119 -0
- package/templates/apps/mcp/src/tools/search_content.ts +59 -0
- package/templates/apps/mcp/src/tools/subscribe_newsletter.ts +47 -0
- package/templates/apps/mcp/src/tools/update_page.ts +91 -0
- package/templates/apps/mcp/tsconfig.json +19 -0
- package/templates/apps/web/.env.example +47 -0
- package/templates/apps/web/CLAUDE.md +81 -0
- package/templates/apps/web/__tests__/auth/adversarial/cookie-attributes.test.ts +94 -0
- package/templates/apps/web/__tests__/auth/adversarial/oauth-state-parameter.test.ts +75 -0
- package/templates/apps/web/__tests__/auth/adversarial/redirect-uri-allowlist.test.ts +82 -0
- package/templates/apps/web/__tests__/auth/env-helpers.test.ts +168 -0
- package/templates/apps/web/__tests__/authority-list-routes.test.tsx +208 -0
- package/templates/apps/web/__tests__/better-stack.test.ts +66 -0
- package/templates/apps/web/__tests__/blog-dir-resolution.test.ts +87 -0
- package/templates/apps/web/__tests__/blog-source-populated.test.ts +130 -0
- package/templates/apps/web/__tests__/data-testid-coverage.test.tsx +60 -0
- package/templates/apps/web/__tests__/google-analytics.test.tsx +104 -0
- package/templates/apps/web/__tests__/i18n/middleware.test.ts +119 -0
- package/templates/apps/web/__tests__/i18n/routing.test.ts +114 -0
- package/templates/apps/web/__tests__/i18n/translations.test.ts +191 -0
- package/templates/apps/web/__tests__/json-ld.test.ts +98 -0
- package/templates/apps/web/__tests__/knowledge-events-routes.test.tsx +580 -0
- package/templates/apps/web/__tests__/layout-stealth.test.ts +39 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/improvement-image-shrink.tsx +103 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/override-fixture.md +114 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/regression-bloat.tsx +94 -0
- package/templates/apps/web/__tests__/page.test.tsx +230 -0
- package/templates/apps/web/__tests__/products-services-phase1.test.tsx +321 -0
- package/templates/apps/web/__tests__/projects-routes.test.tsx +392 -0
- package/templates/apps/web/__tests__/resources-downloads-integrations-phase2.test.tsx +475 -0
- package/templates/apps/web/__tests__/routes/ai-plugin-json.test.ts +53 -0
- package/templates/apps/web/__tests__/routes/blog-route.test.tsx +191 -0
- package/templates/apps/web/__tests__/routes/llms-txt.test.ts +123 -0
- package/templates/apps/web/__tests__/routes/robots-txt.test.ts +52 -0
- package/templates/apps/web/__tests__/routes/sitemap-xml.test.ts +78 -0
- package/templates/apps/web/__tests__/routes/well-known-mcp.test.ts +203 -0
- package/templates/apps/web/__tests__/section-routes.test.tsx +693 -0
- package/templates/apps/web/__tests__/security-headers.test.ts +201 -0
- package/templates/apps/web/__tests__/sentry-config.test.ts +116 -0
- package/templates/apps/web/__tests__/setup.ts +82 -0
- package/templates/apps/web/__tests__/sitemap-locales.test.ts +415 -0
- package/templates/apps/web/__tests__/standalone-informational-routes.test.tsx +844 -0
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +81 -0
- package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +110 -0
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +58 -0
- package/templates/apps/web/app/[locale]/__tests__/layout.test.tsx +120 -0
- package/templates/apps/web/app/[locale]/__tests__/page-renderer-migration.test.tsx +202 -0
- package/templates/apps/web/app/[locale]/about/page.tsx +31 -0
- package/templates/apps/web/app/[locale]/blog/[[...slug]]/page.tsx +173 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +45 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +117 -0
- package/templates/apps/web/app/[locale]/careers/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +44 -0
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +113 -0
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/clients/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/contact/ContactForm.tsx +130 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +152 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +92 -0
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +79 -0
- package/templates/apps/web/app/[locale]/contact/error.tsx +24 -0
- package/templates/apps/web/app/[locale]/contact/page.tsx +38 -0
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +119 -0
- package/templates/apps/web/app/[locale]/courses/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/dev/purchase/__tests__/actions.test.ts +160 -0
- package/templates/apps/web/app/[locale]/dev/purchase/error.tsx +25 -0
- package/templates/apps/web/app/[locale]/dev/purchase/page.tsx +117 -0
- package/templates/apps/web/app/[locale]/dev/purchase/purchase.actions.ts +58 -0
- package/templates/apps/web/app/[locale]/docs/[[...slug]]/page.tsx +118 -0
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +72 -0
- package/templates/apps/web/app/[locale]/downloads/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +130 -0
- package/templates/apps/web/app/[locale]/events/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/faq/page.tsx +36 -0
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +78 -0
- package/templates/apps/web/app/[locale]/how-to/page.tsx +40 -0
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/integrations/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +31 -0
- package/templates/apps/web/app/[locale]/layout.tsx +241 -0
- package/templates/apps/web/app/[locale]/page.tsx +41 -0
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +44 -0
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +113 -0
- package/templates/apps/web/app/[locale]/partners/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/products/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +138 -0
- package/templates/apps/web/app/[locale]/projects/page.tsx +30 -0
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +51 -0
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +117 -0
- package/templates/apps/web/app/[locale]/resources/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/services/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +81 -0
- package/templates/apps/web/app/[locale]/software/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +82 -0
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/use-cases/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/use-cases/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +82 -0
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +39 -0
- package/templates/apps/web/app/__tests__/error-boundaries.test.tsx +152 -0
- package/templates/apps/web/app/api/auth/[...all]/route.ts +16 -0
- package/templates/apps/web/app/error-fallback.tsx +75 -0
- package/templates/apps/web/app/error.tsx +23 -0
- package/templates/apps/web/app/layout.tsx +18 -0
- package/templates/apps/web/app/llms.txt/route.ts +101 -0
- package/templates/apps/web/app/not-found.tsx +48 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +164 -0
- package/templates/apps/web/app/og/route.tsx +135 -0
- package/templates/apps/web/app/robots.txt/route.ts +36 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +146 -0
- package/templates/apps/web/auth.ts +141 -0
- package/templates/apps/web/components/ThemeToggle.tsx +60 -0
- package/templates/apps/web/components/google-analytics.tsx +34 -0
- package/templates/apps/web/content/en/blog/index.mdx +15 -0
- package/templates/apps/web/content/en/blog/launching-ailk.mdx +20 -0
- package/templates/apps/web/content/en/docs/getting-started.mdx +30 -0
- package/templates/apps/web/i18n/request.ts +36 -0
- package/templates/apps/web/jest.config.cjs +100 -0
- package/templates/apps/web/lib/__mocks__/next-mdx-remote-rsc.js +12 -0
- package/templates/apps/web/lib/__mocks__/source-server.js +31 -0
- package/templates/apps/web/lib/__tests__/og.test.ts +65 -0
- package/templates/apps/web/lib/auth-env.ts +66 -0
- package/templates/apps/web/lib/blog-list-data.ts +95 -0
- package/templates/apps/web/lib/blog-post-data.ts +79 -0
- package/templates/apps/web/lib/nav-config.ts +13 -0
- package/templates/apps/web/lib/observability/better-stack.ts +27 -0
- package/templates/apps/web/lib/og.ts +23 -0
- package/templates/apps/web/lib/prisma-for-auth.ts +34 -0
- package/templates/apps/web/lib/source.ts +34 -0
- package/templates/apps/web/messages/en.json +131 -0
- package/templates/apps/web/middleware.ts +80 -0
- package/templates/apps/web/next.config.mjs +167 -0
- package/templates/apps/web/package.json +62 -0
- package/templates/apps/web/public/.well-known/security.txt +17 -0
- package/templates/apps/web/public/android-chrome-192x192.png +0 -0
- package/templates/apps/web/public/android-chrome-512x512.png +0 -0
- package/templates/apps/web/public/apple-touch-icon.png +0 -0
- package/templates/apps/web/public/favicon-16x16.png +0 -0
- package/templates/apps/web/public/favicon-32x32.png +0 -0
- package/templates/apps/web/public/favicon.ico +0 -0
- package/templates/apps/web/public/favicon.svg +4 -0
- package/templates/apps/web/public/logo-dark.svg +21 -0
- package/templates/apps/web/public/logo-light.svg +21 -0
- package/templates/apps/web/public/logomark-dark.svg +4 -0
- package/templates/apps/web/public/logomark-light.svg +4 -0
- package/templates/apps/web/public/og-default.png +0 -0
- package/templates/apps/web/public/site.webmanifest +19 -0
- package/templates/apps/web/scripts/assert-content-bundled.ts +55 -0
- package/templates/apps/web/security-headers.config.ts +132 -0
- package/templates/apps/web/sentry.client.config.ts +27 -0
- package/templates/apps/web/sentry.edge.config.ts +15 -0
- package/templates/apps/web/sentry.server.config.ts +20 -0
- package/templates/apps/web/source.config.ts +78 -0
- package/templates/apps/web/src/components/SiteNav.tsx +21 -0
- package/templates/apps/web/src/lib/routes.ts +37 -0
- package/templates/apps/web/tsconfig.json +35 -0
- package/templates/apps/web/types/messages.d.ts +19 -0
- package/templates/content/.gitkeep +0 -0
- package/templates/content/CLAUDE.md +85 -0
- package/templates/content/_site.mdx +38 -0
- package/templates/content/ar/HomePage/home.mdx +123 -0
- package/templates/content/ar/_site.mdx +35 -0
- package/templates/content/de/_site.mdx +29 -0
- package/templates/content/en/.gitkeep +0 -0
- package/templates/content/en/AboutPage/about.mdx +19 -0
- package/templates/content/en/AboutPage/about.schema.json +82 -0
- package/templates/content/en/BookCall/book-call.mdx +19 -0
- package/templates/content/en/BookCall/book-call.schema.json +121 -0
- package/templates/content/en/BreadcrumbList/site-breadcrumbs.mdx +20 -0
- package/templates/content/en/CareersList/careers.mdx +24 -0
- package/templates/content/en/CaseStudiesList/case-studies.mdx +22 -0
- package/templates/content/en/CaseStudiesList/showcase.mdx +8 -0
- package/templates/content/en/CaseStudy/ailk-aeo-rollout.mdx +32 -0
- package/templates/content/en/CaseStudy/schema-builder-migration.mdx +41 -0
- package/templates/content/en/ClientsList/clients.mdx +38 -0
- package/templates/content/en/ContactPage/contact.mdx +19 -0
- package/templates/content/en/ContactPage/contact.schema.json +100 -0
- package/templates/content/en/ContactPoint/primary.mdx +14 -0
- package/templates/content/en/Course/aeo-fundamentals.mdx +37 -0
- package/templates/content/en/Course/schema-builder-workshop.mdx +62 -0
- package/templates/content/en/CoursesList/courses.mdx +22 -0
- package/templates/content/en/DownloadsList/downloads.mdx +22 -0
- package/templates/content/en/Event/aeo-office-hours-may-2026.mdx +39 -0
- package/templates/content/en/Event/ailk-launch-day-2026.mdx +35 -0
- package/templates/content/en/EventsList/events.mdx +26 -0
- package/templates/content/en/FAQPage/faq.mdx +420 -0
- package/templates/content/en/FAQPage/faq.schema.json +231 -0
- package/templates/content/en/GlossaryList/glossary.mdx +19 -0
- package/templates/content/en/GlossaryList/glossary.schema.json +300 -0
- package/templates/content/en/HomePage/home.mdx +312 -0
- package/templates/content/en/HomePage/home.schema.json +88 -0
- package/templates/content/en/HomePage/launch-service.mdx +475 -0
- package/templates/content/en/HomePage/launch-service.schema.json +138 -0
- package/templates/content/en/HowTo/add-mdx-content.mdx +38 -0
- package/templates/content/en/HowTo/configure-aeo-scoring.mdx +35 -0
- package/templates/content/en/HowTo/set-up-json-ld.mdx +36 -0
- package/templates/content/en/Integration/github-actions.mdx +31 -0
- package/templates/content/en/Integration/openai-api.mdx +26 -0
- package/templates/content/en/Integration/vercel.mdx +32 -0
- package/templates/content/en/IntegrationsList/integrations.mdx +22 -0
- package/templates/content/en/JobPosting/content-strategist.mdx +46 -0
- package/templates/content/en/JobPosting/developer-advocate.mdx +47 -0
- package/templates/content/en/JobPosting/senior-fullstack-engineer.mdx +57 -0
- package/templates/content/en/LandingPage/aeo-audit.mdx +19 -0
- package/templates/content/en/LandingPage/aeo-audit.schema.json +92 -0
- package/templates/content/en/LandingPage/agency-waitlist.mdx +340 -0
- package/templates/content/en/LandingPage/agency-waitlist.schema.json +152 -0
- package/templates/content/en/LandingPage/developers.mdx +19 -0
- package/templates/content/en/LandingPage/developers.schema.json +109 -0
- package/templates/content/en/LandingPage/for-agencies.mdx +390 -0
- package/templates/content/en/LandingPage/for-agencies.schema.json +107 -0
- package/templates/content/en/LandingPage/for-ai-search-agencies.mdx +417 -0
- package/templates/content/en/LandingPage/for-ai-search-agencies.schema.json +105 -0
- package/templates/content/en/LandingPage/for-businesses.mdx +19 -0
- package/templates/content/en/LandingPage/for-businesses.schema.json +96 -0
- package/templates/content/en/LandingPage/platform.mdx +369 -0
- package/templates/content/en/LandingPage/platform.schema.json +166 -0
- package/templates/content/en/LandingPage/vs-ai-website-builders.mdx +19 -0
- package/templates/content/en/LandingPage/vs-ai-website-builders.schema.json +102 -0
- package/templates/content/en/LandingPage/vs-wordpress.mdx +19 -0
- package/templates/content/en/LandingPage/vs-wordpress.schema.json +53 -0
- package/templates/content/en/NewsletterSignup/newsletter.mdx +236 -0
- package/templates/content/en/NewsletterSignup/newsletter.schema.json +91 -0
- package/templates/content/en/Organization/site-owner.mdx +16 -0
- package/templates/content/en/Partner/prisma.mdx +31 -0
- package/templates/content/en/Partner/supabase.mdx +30 -0
- package/templates/content/en/Partner/vercel.mdx +28 -0
- package/templates/content/en/PartnersList/partners.mdx +22 -0
- package/templates/content/en/Person/founder.mdx +18 -0
- package/templates/content/en/Pricing/pricing.mdx +538 -0
- package/templates/content/en/Pricing/pricing.schema.json +209 -0
- package/templates/content/en/PrivacyPage/privacy.mdx +165 -0
- package/templates/content/en/PrivacyPage/privacy.schema.json +64 -0
- package/templates/content/en/Product/ailk.mdx +19 -0
- package/templates/content/en/Product/ailk.schema.json +94 -0
- package/templates/content/en/Product/api-launch-kit.mdx +26 -0
- package/templates/content/en/Product/launch-kit.mdx +28 -0
- package/templates/content/en/ProductsList/products.mdx +26 -0
- package/templates/content/en/Project/ailk-phase-2.mdx +54 -0
- package/templates/content/en/ProjectsList/projects.mdx +25 -0
- package/templates/content/en/ResourceDetail/aeo-scoring-guide.mdx +27 -0
- package/templates/content/en/ResourceDetail/content-model-whitepaper.mdx +28 -0
- package/templates/content/en/ResourceDetail/schema-org-quick-reference.mdx +39 -0
- package/templates/content/en/ResourcesHub/resources.mdx +22 -0
- package/templates/content/en/Service/consulting.mdx +22 -0
- package/templates/content/en/Service/implementation.mdx +30 -0
- package/templates/content/en/Service/launch-service.mdx +232 -0
- package/templates/content/en/Service/launch.mdx +228 -0
- package/templates/content/en/ServicesList/services.mdx +84 -0
- package/templates/content/en/SoftwareProduct/ailk-aeo.mdx +44 -0
- package/templates/content/en/SoftwareProduct/ailk-content-adapters.mdx +47 -0
- package/templates/content/en/SoftwareProduct/ailk-schema.mdx +49 -0
- package/templates/content/en/TeamList/team.mdx +63 -0
- package/templates/content/en/TeamMember/founder.mdx +72 -0
- package/templates/content/en/TermsPage/terms.mdx +19 -0
- package/templates/content/en/TermsPage/terms.schema.json +99 -0
- package/templates/content/en/TestimonialsList/testimonials.mdx +44 -0
- package/templates/content/en/UseCasesList/use-cases.mdx +30 -0
- package/templates/content/en/Whitepaper/ax-first-product-development.mdx +27 -0
- package/templates/content/en/Whitepaper/open-core-commercial-strategy.mdx +27 -0
- package/templates/content/en/Whitepaper/structured-data-for-answer-engines.mdx +31 -0
- package/templates/content/en-XA/AboutPage/about.mdx +8 -0
- package/templates/content/en-XA/FAQPage/faq.mdx +8 -0
- package/templates/content/en-XA/HomePage/home.mdx +8 -0
- package/templates/content/es/_site.mdx +30 -0
- package/templates/content/fr/_site.mdx +30 -0
- package/templates/content/ja/_site.mdx +30 -0
- package/templates/content/pt-BR/AboutPage/about.mdx +8 -0
- package/templates/content/pt-BR/FAQPage/faq.mdx +8 -0
- package/templates/content/pt-BR/HomePage/home.mdx +23 -0
- package/templates/database/CHANGELOG.md +5 -0
- package/templates/database/README.md +234 -0
- package/templates/database/__tests__/user-cascade.test.ts +125 -0
- package/templates/database/auth/.gitkeep +0 -0
- package/templates/database/config/.gitkeep +0 -0
- package/templates/database/content/.gitkeep +0 -0
- package/templates/database/inbox/.gitkeep +0 -0
- package/templates/database/inbox/README.md +3 -0
- package/templates/database/inbox/__tests__/schema.test.ts +40 -0
- package/templates/database/inbox/schema.prisma +52 -0
- package/templates/database/jest.config.cjs +29 -0
- package/templates/database/migrations/20260508000000_add_inbox_namespace/migration.sql +328 -0
- package/templates/database/migrations/20260513000000_better_auth_migration/migration.sql +100 -0
- package/templates/database/migrations/20260515000000_add_user_billing_fields/migration.sql +28 -0
- package/templates/database/migrations/20260516000000_add_user_tier_care_plan_seat/migration.sql +25 -0
- package/templates/database/migrations/20260518000000_add_telemetry_records/migration.sql +42 -0
- package/templates/database/migrations/20260525000000_theme_wiring/migration.sql +67 -0
- package/templates/database/migrations/20260710000000_retire_commercial_tier/migration.sql +21 -0
- package/templates/database/migrations/migration_lock.toml +3 -0
- package/templates/database/ops/.gitkeep +0 -0
- package/templates/database/package.json +45 -0
- package/templates/database/prisma.config.ts +20 -0
- package/templates/database/schema.prisma +487 -0
- package/templates/database/scripts/db-generate-locked.sh +80 -0
- package/templates/database/seed-test.ts +85 -0
- package/templates/database/tsconfig.build.json +16 -0
- package/templates/database/tsconfig.json +9 -0
- package/templates/package.json +125 -0
- package/templates/pnpm-workspace.yaml +6 -0
- package/templates/project.yaml +59 -0
- package/templates/tsconfig.base.json +18 -0
- package/templates/tsconfig.json +45 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the subscribe_newsletter MCP tool handler.
|
|
3
|
+
*
|
|
4
|
+
* Acceptance criteria verified here:
|
|
5
|
+
* 1. Malformed input → { ok: false, error: { kind: 'invalid_input', issues } }, api-client never called
|
|
6
|
+
* 2. Happy path → forwards to apiClient.leads.subscribe, returns { ok: true, id, persisted }
|
|
7
|
+
* 3. API 400 → { ok: false, error: { kind: 'api_error', status: 400 } }
|
|
8
|
+
* 4. API 503 → { ok: false, error: { kind: 'api_error', status: 503 } }
|
|
9
|
+
* 5. API 429 → { ok: false, error: { kind: 'api_error', status: 429 } }
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { ailkSubscribeNewsletter } from "../src/tools/subscribe_newsletter.js";
|
|
13
|
+
|
|
14
|
+
jest.mock("@working-theory/api-client", () => ({
|
|
15
|
+
apiClient: {
|
|
16
|
+
leads: {
|
|
17
|
+
subscribe: jest.fn(),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const { apiClient } = require("@working-theory/api-client") as {
|
|
24
|
+
apiClient: { leads: { subscribe: jest.Mock } };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const VALID_INPUT = {
|
|
28
|
+
email: "jane@example.com",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("ailkSubscribeNewsletter — input validation", () => {
|
|
36
|
+
it("rejects malformed input (invalid email) without calling api-client", async () => {
|
|
37
|
+
const result = await ailkSubscribeNewsletter({ email: "not-an-email" });
|
|
38
|
+
|
|
39
|
+
expect(result.ok).toBe(false);
|
|
40
|
+
if (!result.ok) {
|
|
41
|
+
expect(result.error.kind).toBe("invalid_input");
|
|
42
|
+
if (result.error.kind === "invalid_input") {
|
|
43
|
+
expect(Array.isArray(result.error.issues)).toBe(true);
|
|
44
|
+
expect(result.error.issues.length).toBeGreaterThan(0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
expect(apiClient.leads.subscribe).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("ailkSubscribeNewsletter — happy path", () => {
|
|
52
|
+
it("forwards canonical body to api-client and returns ok:true with id and persisted", async () => {
|
|
53
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
54
|
+
ok: true,
|
|
55
|
+
body: { id: "sub_xyz789", persisted: "db" },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = await ailkSubscribeNewsletter(VALID_INPUT);
|
|
59
|
+
|
|
60
|
+
expect(apiClient.leads.subscribe).toHaveBeenCalledWith({
|
|
61
|
+
siteId: "default",
|
|
62
|
+
email: "jane@example.com",
|
|
63
|
+
source: "mcp",
|
|
64
|
+
});
|
|
65
|
+
expect(result.ok).toBe(true);
|
|
66
|
+
if (result.ok) {
|
|
67
|
+
expect(result.id).toBe("sub_xyz789");
|
|
68
|
+
expect(result.persisted).toBe("db");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("ailkSubscribeNewsletter — API error mapping", () => {
|
|
74
|
+
it("maps API 400 to { ok: false, error: { kind: 'api_error', status: 400 } }", async () => {
|
|
75
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
76
|
+
ok: false,
|
|
77
|
+
status: 400,
|
|
78
|
+
body: { error: "bad_request" },
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const result = await ailkSubscribeNewsletter(VALID_INPUT);
|
|
82
|
+
|
|
83
|
+
expect(result.ok).toBe(false);
|
|
84
|
+
if (!result.ok) {
|
|
85
|
+
expect(result.error.kind).toBe("api_error");
|
|
86
|
+
if (result.error.kind === "api_error") {
|
|
87
|
+
expect(result.error.status).toBe(400);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("maps API 503 to { ok: false, error: { kind: 'api_error', status: 503 } }", async () => {
|
|
93
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
94
|
+
ok: false,
|
|
95
|
+
status: 503,
|
|
96
|
+
body: { error: "service_unavailable" },
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const result = await ailkSubscribeNewsletter(VALID_INPUT);
|
|
100
|
+
|
|
101
|
+
expect(result.ok).toBe(false);
|
|
102
|
+
if (!result.ok) {
|
|
103
|
+
expect(result.error.kind).toBe("api_error");
|
|
104
|
+
if (result.error.kind === "api_error") {
|
|
105
|
+
expect(result.error.status).toBe(503);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("maps API 429 to { ok: false, error: { kind: 'api_error', status: 429 } }", async () => {
|
|
111
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
112
|
+
ok: false,
|
|
113
|
+
status: 429,
|
|
114
|
+
body: { error: "rate_limited" },
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const result = await ailkSubscribeNewsletter(VALID_INPUT);
|
|
118
|
+
|
|
119
|
+
expect(result.ok).toBe(false);
|
|
120
|
+
if (!result.ok) {
|
|
121
|
+
expect(result.error.kind).toBe("api_error");
|
|
122
|
+
if (result.error.kind === "api_error") {
|
|
123
|
+
expect(result.error.status).toBe(429);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe("ailkSubscribeNewsletter — siteId default", () => {
|
|
130
|
+
it("uses siteId 'default' when AILK_SITE_ID is unset", async () => {
|
|
131
|
+
delete process.env.AILK_SITE_ID;
|
|
132
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
133
|
+
ok: true,
|
|
134
|
+
body: { id: "sub_default", persisted: "db" },
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
await ailkSubscribeNewsletter(VALID_INPUT);
|
|
138
|
+
|
|
139
|
+
const call = apiClient.leads.subscribe.mock.calls[0][0] as { siteId: string };
|
|
140
|
+
expect(call.siteId).toBe("default");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("ailkSubscribeNewsletter — siteId override", () => {
|
|
145
|
+
afterEach(() => {
|
|
146
|
+
delete process.env.AILK_SITE_ID;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("uses AILK_SITE_ID env var when set", async () => {
|
|
150
|
+
process.env.AILK_SITE_ID = "site-abc";
|
|
151
|
+
apiClient.leads.subscribe.mockResolvedValueOnce({
|
|
152
|
+
ok: true,
|
|
153
|
+
body: { id: "sub_override", persisted: "db" },
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await ailkSubscribeNewsletter(VALID_INPUT);
|
|
157
|
+
|
|
158
|
+
const call = apiClient.leads.subscribe.mock.calls[0][0] as { siteId: string };
|
|
159
|
+
expect(call.siteId).toBe("site-abc");
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the ailkPurchase MCP tool (Phase 3 U2: live implementation).
|
|
3
|
+
*
|
|
4
|
+
* Acceptance criteria verified here:
|
|
5
|
+
* - purchaseInputSchema validates correct inputs
|
|
6
|
+
* - purchaseInputSchema rejects invalid inputs
|
|
7
|
+
* - purchaseOutputSchema validates { url: string } live shape
|
|
8
|
+
* - ailkPurchase handler calls POST /v1/checkout/sessions
|
|
9
|
+
* - ailkPurchase returns { url: string } on success
|
|
10
|
+
* - ailkPurchase returns Zod errors on invalid input
|
|
11
|
+
* - No Stripe SDK import in apps/mcp (architectural guard)
|
|
12
|
+
* - Parity: response shape matches purchaseAction Server Action shape
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { ailkPurchase } from "../../src/tools/purchase.js";
|
|
16
|
+
import {
|
|
17
|
+
purchaseInputSchema as PurchaseInputSchema,
|
|
18
|
+
purchaseOutputSchema as PurchaseOutputSchema,
|
|
19
|
+
} from "@working-theory/validation";
|
|
20
|
+
|
|
21
|
+
// ── fetch mock ────────────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
const mockFetch = jest.fn();
|
|
24
|
+
global.fetch = mockFetch;
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// ── Input schema ──────────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
describe("PurchaseInputSchema", () => {
|
|
33
|
+
it("accepts valid input with priceId and quantity", () => {
|
|
34
|
+
const result = PurchaseInputSchema.safeParse({
|
|
35
|
+
priceId: "price_test_123",
|
|
36
|
+
quantity: 1,
|
|
37
|
+
});
|
|
38
|
+
expect(result.success).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("accepts valid input with priceId only (quantity defaults)", () => {
|
|
42
|
+
const result = PurchaseInputSchema.safeParse({
|
|
43
|
+
priceId: "price_test_abc",
|
|
44
|
+
});
|
|
45
|
+
expect(result.success).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("accepts valid input with successUrl and cancelUrl", () => {
|
|
49
|
+
const result = PurchaseInputSchema.safeParse({
|
|
50
|
+
priceId: "price_test_123",
|
|
51
|
+
successUrl: "https://example.com/success",
|
|
52
|
+
cancelUrl: "https://example.com/cancel",
|
|
53
|
+
});
|
|
54
|
+
expect(result.success).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("rejects input missing priceId", () => {
|
|
58
|
+
const result = PurchaseInputSchema.safeParse({ quantity: 1 });
|
|
59
|
+
expect(result.success).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("rejects input with empty priceId", () => {
|
|
63
|
+
const result = PurchaseInputSchema.safeParse({ priceId: "" });
|
|
64
|
+
expect(result.success).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("rejects input with non-integer quantity", () => {
|
|
68
|
+
const result = PurchaseInputSchema.safeParse({
|
|
69
|
+
priceId: "price_x",
|
|
70
|
+
quantity: 1.5,
|
|
71
|
+
});
|
|
72
|
+
expect(result.success).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("rejects input with quantity less than 1", () => {
|
|
76
|
+
const result = PurchaseInputSchema.safeParse({
|
|
77
|
+
priceId: "price_x",
|
|
78
|
+
quantity: 0,
|
|
79
|
+
});
|
|
80
|
+
expect(result.success).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// ── Output schema (live shape) ────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
describe("PurchaseOutputSchema", () => {
|
|
87
|
+
it("accepts the live success shape { url: string }", () => {
|
|
88
|
+
const result = PurchaseOutputSchema.safeParse({
|
|
89
|
+
url: "https://checkout.stripe.com/pay/cs_test_abc123",
|
|
90
|
+
});
|
|
91
|
+
expect(result.success).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("rejects output missing url", () => {
|
|
95
|
+
const result = PurchaseOutputSchema.safeParse({});
|
|
96
|
+
expect(result.success).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("rejects output where url is not a string", () => {
|
|
100
|
+
const result = PurchaseOutputSchema.safeParse({ url: 42 });
|
|
101
|
+
expect(result.success).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// ── ailkPurchase handler ──────────────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
describe("ailkPurchase — valid input", () => {
|
|
108
|
+
it("calls POST /v1/checkout/sessions with mapped payload", async () => {
|
|
109
|
+
mockFetch.mockResolvedValueOnce({
|
|
110
|
+
ok: true,
|
|
111
|
+
status: 201,
|
|
112
|
+
json: () =>
|
|
113
|
+
Promise.resolve({
|
|
114
|
+
sessionId: "cs_test_abc123",
|
|
115
|
+
url: "https://checkout.stripe.com/pay/cs_test_abc123",
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await ailkPurchase({
|
|
120
|
+
priceId: "price_test_123",
|
|
121
|
+
quantity: 1,
|
|
122
|
+
successUrl: "https://example.com/success",
|
|
123
|
+
cancelUrl: "https://example.com/cancel",
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
127
|
+
const [url, opts] = mockFetch.mock.calls[0] as [string, RequestInit];
|
|
128
|
+
expect(url).toMatch(/\/v1\/checkout\/sessions$/);
|
|
129
|
+
expect(opts.method).toBe("POST");
|
|
130
|
+
const body = JSON.parse(opts.body as string) as Record<string, unknown>;
|
|
131
|
+
expect(body.productCode).toBe("price_test_123");
|
|
132
|
+
expect(body.quantity).toBe(1);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("returns { url } on success", async () => {
|
|
136
|
+
mockFetch.mockResolvedValueOnce({
|
|
137
|
+
ok: true,
|
|
138
|
+
status: 201,
|
|
139
|
+
json: () =>
|
|
140
|
+
Promise.resolve({
|
|
141
|
+
sessionId: "cs_test_xyz",
|
|
142
|
+
url: "https://checkout.stripe.com/pay/cs_test_xyz",
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const output = await ailkPurchase({
|
|
147
|
+
priceId: "price_test_xyz",
|
|
148
|
+
successUrl: "https://example.com/success",
|
|
149
|
+
cancelUrl: "https://example.com/cancel",
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
expect(output).toEqual({
|
|
153
|
+
url: "https://checkout.stripe.com/pay/cs_test_xyz",
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("output validates against PurchaseOutputSchema", async () => {
|
|
158
|
+
mockFetch.mockResolvedValueOnce({
|
|
159
|
+
ok: true,
|
|
160
|
+
status: 201,
|
|
161
|
+
json: () =>
|
|
162
|
+
Promise.resolve({
|
|
163
|
+
sessionId: "cs_test_valid",
|
|
164
|
+
url: "https://checkout.stripe.com/pay/cs_test_valid",
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const output = await ailkPurchase({ priceId: "price_test_valid" });
|
|
169
|
+
const result = PurchaseOutputSchema.safeParse(output);
|
|
170
|
+
expect(result.success).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe("ailkPurchase — invalid input (Zod errors)", () => {
|
|
175
|
+
it("throws ZodError for missing priceId before any fetch", async () => {
|
|
176
|
+
await expect(
|
|
177
|
+
ailkPurchase({ quantity: 1 } as never),
|
|
178
|
+
).rejects.toThrow();
|
|
179
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("throws ZodError for empty priceId before any fetch", async () => {
|
|
183
|
+
await expect(
|
|
184
|
+
ailkPurchase({ priceId: "" }),
|
|
185
|
+
).rejects.toThrow();
|
|
186
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe("ailkPurchase — parity shape with purchaseAction", () => {
|
|
191
|
+
it("success shape is { url: string } matching Server Action shape", async () => {
|
|
192
|
+
mockFetch.mockResolvedValueOnce({
|
|
193
|
+
ok: true,
|
|
194
|
+
status: 201,
|
|
195
|
+
json: () =>
|
|
196
|
+
Promise.resolve({
|
|
197
|
+
sessionId: "cs_test_parity",
|
|
198
|
+
url: "https://checkout.stripe.com/pay/cs_test_parity",
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const output = await ailkPurchase({
|
|
203
|
+
priceId: "price_parity",
|
|
204
|
+
successUrl: "https://example.com/success",
|
|
205
|
+
cancelUrl: "https://example.com/cancel",
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Shape must match purchaseAction's success shape
|
|
209
|
+
expect(output).toHaveProperty("url");
|
|
210
|
+
expect(typeof (output as { url: string }).url).toBe("string");
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// ── Architectural guard ───────────────────────────────────────────────────────
|
|
215
|
+
|
|
216
|
+
describe("architectural guard — no Stripe import", () => {
|
|
217
|
+
it("apps/mcp/src/tools/purchase.ts does not import stripe", async () => {
|
|
218
|
+
const { readFileSync } = await import("node:fs");
|
|
219
|
+
const { resolve } = await import("node:path");
|
|
220
|
+
const src = readFileSync(
|
|
221
|
+
resolve(__dirname, "../../src/tools/purchase.ts"),
|
|
222
|
+
"utf-8",
|
|
223
|
+
);
|
|
224
|
+
expect(src).not.toMatch(/import.*['"]stripe['"]/);
|
|
225
|
+
expect(src).not.toMatch(/require\s*\(\s*['"]stripe['"]/);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the ailkScaffold MCP tool handler.
|
|
3
|
+
*
|
|
4
|
+
* Acceptance criteria verified here:
|
|
5
|
+
* - scaffoldInputSchema validates correct inputs
|
|
6
|
+
* - scaffoldInputSchema rejects invalid inputs (empty projectName, missing targetDir)
|
|
7
|
+
* - ailkScaffold scaffolds into a tmp dir: package.json + ≥1 file created
|
|
8
|
+
* - ailkScaffold fails cleanly when targetDir is non-empty (rejects with Error)
|
|
9
|
+
* - Output validates against scaffoldOutputSchema
|
|
10
|
+
* - No direct create-ailk import in apps/mcp (architectural guard)
|
|
11
|
+
*
|
|
12
|
+
* Hermetic: uses os.tmpdir() + unique subdir. No network calls.
|
|
13
|
+
* Integration tests pass CLI_PATH explicitly to ailkScaffold (second arg)
|
|
14
|
+
* so they don't depend on process.cwd() being the repo root in Jest.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
existsSync,
|
|
19
|
+
mkdirSync,
|
|
20
|
+
mkdtempSync,
|
|
21
|
+
rmSync,
|
|
22
|
+
writeFileSync,
|
|
23
|
+
} from "node:fs";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { join, resolve } from "node:path";
|
|
26
|
+
|
|
27
|
+
import { scaffoldInputSchema, scaffoldOutputSchema } from "@working-theory/validation";
|
|
28
|
+
|
|
29
|
+
import { ailkScaffold } from "../../src/tools/scaffold.js";
|
|
30
|
+
|
|
31
|
+
// ── Input schema tests ────────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
describe("scaffoldInputSchema", () => {
|
|
34
|
+
it("accepts valid input with targetDir and projectName", () => {
|
|
35
|
+
const result = scaffoldInputSchema.safeParse({
|
|
36
|
+
targetDir: "/tmp/my-site",
|
|
37
|
+
projectName: "my-site",
|
|
38
|
+
});
|
|
39
|
+
expect(result.success).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("accepts valid input with optional preset", () => {
|
|
43
|
+
const result = scaffoldInputSchema.safeParse({
|
|
44
|
+
targetDir: "/tmp/my-site",
|
|
45
|
+
projectName: "my-site",
|
|
46
|
+
preset: "default",
|
|
47
|
+
});
|
|
48
|
+
expect(result.success).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("rejects input missing targetDir", () => {
|
|
52
|
+
const result = scaffoldInputSchema.safeParse({
|
|
53
|
+
projectName: "my-site",
|
|
54
|
+
});
|
|
55
|
+
expect(result.success).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("rejects input with empty projectName", () => {
|
|
59
|
+
const result = scaffoldInputSchema.safeParse({
|
|
60
|
+
targetDir: "/tmp/my-site",
|
|
61
|
+
projectName: "",
|
|
62
|
+
});
|
|
63
|
+
expect(result.success).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("rejects input missing projectName", () => {
|
|
67
|
+
const result = scaffoldInputSchema.safeParse({
|
|
68
|
+
targetDir: "/tmp/my-site",
|
|
69
|
+
});
|
|
70
|
+
expect(result.success).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ── Output schema tests ───────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
describe("scaffoldOutputSchema", () => {
|
|
77
|
+
it("accepts a valid success output", () => {
|
|
78
|
+
const result = scaffoldOutputSchema.safeParse({
|
|
79
|
+
targetDir: "/tmp/my-site",
|
|
80
|
+
filesCreated: 5,
|
|
81
|
+
});
|
|
82
|
+
expect(result.success).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("accepts zero filesCreated (empty template edge case)", () => {
|
|
86
|
+
const result = scaffoldOutputSchema.safeParse({
|
|
87
|
+
targetDir: "/tmp/my-site",
|
|
88
|
+
filesCreated: 0,
|
|
89
|
+
});
|
|
90
|
+
expect(result.success).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("rejects output missing targetDir", () => {
|
|
94
|
+
const result = scaffoldOutputSchema.safeParse({ filesCreated: 5 });
|
|
95
|
+
expect(result.success).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ── Handler integration tests ─────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
// Resolve CLI_PATH relative to the repo root using __dirname traversal.
|
|
102
|
+
// __tests__/tools → __tests__ → apps/mcp → apps → repo root
|
|
103
|
+
const REPO_ROOT = resolve(__dirname, "../../../..");
|
|
104
|
+
const CLI_PATH = join(REPO_ROOT, "packages/create-ailk/dist/cli.js");
|
|
105
|
+
|
|
106
|
+
describe("ailkScaffold handler", () => {
|
|
107
|
+
let scratch: string;
|
|
108
|
+
|
|
109
|
+
beforeAll(() => {
|
|
110
|
+
if (!existsSync(CLI_PATH)) {
|
|
111
|
+
console.warn(
|
|
112
|
+
`[scaffold.test] create-ailk CLI not built: ${CLI_PATH} missing. ` +
|
|
113
|
+
"Run `pnpm --filter create-ailk build` first.",
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
beforeEach(() => {
|
|
119
|
+
scratch = mkdtempSync(join(tmpdir(), "ailk-mcp-scaffold-"));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
afterEach(() => {
|
|
123
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("scaffolds at least one file into a fresh tmp dir and reports targetDir", async () => {
|
|
127
|
+
if (!existsSync(CLI_PATH)) {
|
|
128
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const target = join(scratch, "my-site");
|
|
132
|
+
const output = await ailkScaffold(
|
|
133
|
+
{ targetDir: target, projectName: "my-site" },
|
|
134
|
+
CLI_PATH,
|
|
135
|
+
);
|
|
136
|
+
expect(output.targetDir).toBe(target);
|
|
137
|
+
expect(output.filesCreated).toBeGreaterThan(0);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("scaffolds package.json when full templates are built (build-templates required)", async () => {
|
|
141
|
+
if (!existsSync(CLI_PATH)) {
|
|
142
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const TEMPLATES_DIR = join(REPO_ROOT, "packages/create-ailk/templates");
|
|
146
|
+
const PKG_JSON_IN_TEMPLATES = join(TEMPLATES_DIR, "package.json");
|
|
147
|
+
if (!existsSync(PKG_JSON_IN_TEMPLATES)) {
|
|
148
|
+
console.warn(
|
|
149
|
+
"[scaffold.test] skipping package.json assertion — run `pnpm --filter create-ailk run build-templates` first",
|
|
150
|
+
);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const target = join(scratch, "my-site");
|
|
154
|
+
await ailkScaffold({ targetDir: target, projectName: "my-site" }, CLI_PATH);
|
|
155
|
+
expect(existsSync(join(target, "package.json"))).toBe(true);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("scaffolds app dir when full templates are built (build-templates required)", async () => {
|
|
159
|
+
if (!existsSync(CLI_PATH)) {
|
|
160
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const TEMPLATES_DIR = join(REPO_ROOT, "packages/create-ailk/templates");
|
|
164
|
+
const PKG_JSON_IN_TEMPLATES = join(TEMPLATES_DIR, "package.json");
|
|
165
|
+
if (!existsSync(PKG_JSON_IN_TEMPLATES)) {
|
|
166
|
+
console.warn(
|
|
167
|
+
"[scaffold.test] skipping app dir assertion — run `pnpm --filter create-ailk run build-templates` first",
|
|
168
|
+
);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const target = join(scratch, "my-site");
|
|
172
|
+
await ailkScaffold({ targetDir: target, projectName: "my-site" }, CLI_PATH);
|
|
173
|
+
// The template produces apps/web/app/ from the monorepo template snapshot.
|
|
174
|
+
const hasApp =
|
|
175
|
+
existsSync(join(target, "app")) ||
|
|
176
|
+
existsSync(join(target, "apps", "web", "app"));
|
|
177
|
+
expect(hasApp).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("returns at least one file (schema-typed page seed or README.md)", async () => {
|
|
181
|
+
if (!existsSync(CLI_PATH)) {
|
|
182
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const target = join(scratch, "my-site");
|
|
186
|
+
await ailkScaffold({ targetDir: target, projectName: "my-site" }, CLI_PATH);
|
|
187
|
+
// At minimum README.md is always emitted by the template.
|
|
188
|
+
expect(existsSync(join(target, "README.md"))).toBe(true);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("returns output conforming to scaffoldOutputSchema", async () => {
|
|
192
|
+
if (!existsSync(CLI_PATH)) {
|
|
193
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const target = join(scratch, "my-site");
|
|
197
|
+
const output = await ailkScaffold(
|
|
198
|
+
{ targetDir: target, projectName: "my-site" },
|
|
199
|
+
CLI_PATH,
|
|
200
|
+
);
|
|
201
|
+
const result = scaffoldOutputSchema.safeParse(output);
|
|
202
|
+
expect(result.success).toBe(true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("rejects with a clear error when targetDir is non-empty", async () => {
|
|
206
|
+
if (!existsSync(CLI_PATH)) {
|
|
207
|
+
console.warn("[scaffold.test] skipping integration test — CLI not built");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const target = join(scratch, "populated");
|
|
211
|
+
mkdirSync(target);
|
|
212
|
+
writeFileSync(join(target, "existing.txt"), "data");
|
|
213
|
+
|
|
214
|
+
// The create-ailk CLI exits non-zero with a ValidationError message when
|
|
215
|
+
// the target exists and is non-empty. The MCP handler rejects with a
|
|
216
|
+
// descriptive Error whose message matches the CLI stderr output.
|
|
217
|
+
await expect(
|
|
218
|
+
ailkScaffold({ targetDir: target, projectName: "populated" }, CLI_PATH),
|
|
219
|
+
).rejects.toThrow(/non-empty|exists/i);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// ── Architectural guard ───────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
describe("architectural guard — no create-ailk direct import", () => {
|
|
226
|
+
it("apps/mcp/src/tools/scaffold.ts does not import create-ailk directly", async () => {
|
|
227
|
+
const { readFileSync } = await import("node:fs");
|
|
228
|
+
const { resolve: res } = await import("node:path");
|
|
229
|
+
const src = readFileSync(
|
|
230
|
+
res(__dirname, "../../src/tools/scaffold.ts"),
|
|
231
|
+
"utf-8",
|
|
232
|
+
);
|
|
233
|
+
// Must not have a static import of create-ailk or its dist
|
|
234
|
+
expect(src).not.toMatch(/from ['"]create-ailk['"]/);
|
|
235
|
+
expect(src).not.toMatch(/require\s*\(\s*['"]create-ailk['"]/);
|
|
236
|
+
});
|
|
237
|
+
});
|