Skip to content

feat: add @focus-reactive/payload-plugin-ai-page-builder#17

Open
dogfrogfog wants to merge 3 commits into
mainfrom
issue-16-ai-page-builder
Open

feat: add @focus-reactive/payload-plugin-ai-page-builder#17
dogfrogfog wants to merge 3 commits into
mainfrom
issue-16-ai-page-builder

Conversation

@dogfrogfog
Copy link
Copy Markdown
Member

Summary

Implements a new published plugin that generates complete Payload CMS pages from a natural-language prompt, using the Vercel AI SDK and Zod schemas.

  • Schema-first design — callers supply Zod schemas for each block type; the same schemas drive both Payload field validation and the generateObject structured-output constraint passed to the AI model, so generated content always matches block field shapes.
  • POST /api/ai-page-builder/generate endpoint — accepts { prompt, collectionSlug }, builds a Zod discriminated-union schema from the configured block definitions, calls generateObject, creates a draft document, and returns its id.
  • Admin UI panel — a ✨ Generate with AI button is injected via beforeListTable into every configured collection; expanding it shows a textarea, submits to the endpoint, then navigates the editor to the newly created draft.
  • Dev sandbox wiringapps/dev is configured with Hero + Copy block definitions so the plugin can be tested locally with an OPENAI_API_KEY.
  • Infrastructure fixesturbo.json check-types now depends on ^build so workspace package dist/ is present before apps run tsgo; pre-existing TS2589 depth error in payload-plugin-translator's zodResolver calls is resolved with a targeted cast.

Closes #16

Test plan

  • Set OPENAI_API_KEY in apps/dev/.env
  • bun run dev — navigate to /admin/collections/pages
  • Click ✨ Generate with AI, enter a prompt (e.g. "A landing page for a project management SaaS"), click Generate
  • Verify the editor opens on a new draft page with a title, slug, and generated Hero/Copy sections
  • Verify error toast appears when the API key is missing or the prompt is empty
  • bunx turbo run build --filter='@focus-reactive/payload-plugin-ai-page-builder' — build succeeds
  • bun run lint on the plugin directory — 0 errors

Generated by Claude Code

claude added 3 commits June 1, 2026 17:42
Implements a new Payload CMS plugin that lets editors generate complete
pages from a natural-language prompt.

- POST /api/ai-page-builder/generate endpoint — uses Vercel AI SDK
  generateObject with a Zod discriminated-union schema built from the
  caller's block definitions; creates a draft document and returns its id
- "✨ Generate with AI" panel injected into beforeListTable for every
  configured collection; expands into a textarea, calls the endpoint,
  then navigates to the new draft in the editor
- Schema-first design: the same Zod schemas drive both Payload type
  safety and the structured-output constraint passed to the AI model,
  ensuring generated content always matches the block field shapes
- Wired into apps/dev with Hero + Copy block definitions for local testing

Closes #16
- Guard req.json possibly-undefined call with null check
- Cast schema and model through any to avoid deep type-instantiation
  error in generateObject invocation
- Cast blockSchemas through unknown to satisfy ZodDiscriminatedUnion
  option constraint that expects blockType in the shape
- turbo.json: add '^build' to check-types dependsOn so workspace package
  dist/ is present before apps run tsgo — fixes cms:check-types failing
  with 'Cannot find module' when packages haven't been built yet
- payload-plugin-translator: cast zodResolver call through any to silence
  TS2589 deep-instantiation error from tsgo with computed-key zod schemas
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
turbo-cms-kit-payload Ready Ready Preview, Comment Jun 1, 2026 5:49pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NEW PLUGIN: AI Page Builder, build pages with natural language based on user's prompt

2 participants