feat(cli): WordPress site generator for Studio Code (theme + companion plugin)#3666
Draft
draganescu wants to merge 2 commits into
Draft
feat(cli): WordPress site generator for Studio Code (theme + companion plugin)#3666draganescu wants to merge 2 commits into
draganescu wants to merge 2 commits into
Conversation
…tion for studio ai Adds an end-to-end WordPress site generator to the `studio ai`/`studio code` agent: generation tools plus knowledge/runbook skills that produce a pure-presentation block theme and a companion plugin (CPTs, REST routes, build-less plain-JS blocks), seed content into the live DB, and fill AI imagery. Tools (registered in tools/index.ts): generate_design_previews, generate_theme (parallel per-file generation), generate_companion_plugin, seed_content, generate_image. Orchestrated by the `site-generator` skill (/site-generator slash command) alongside theme-architecture, companion-plugin, layout-patterns, wp-best-practices, and data-persistence knowledge skills + bundled generator prompt fragments adapted from Telex. Generation core (apps/cli/ai/generation/): non-streaming parallel Anthropic client reusing the wpcom provider env, transient-error retry/backoff, robust JSON extraction, manifest schema, AI_IMAGE handling, path/WP-CLI helpers. Key correctness fixes from live testing: - seed_content writes large post content to a host file the WP filesystem reads (wp post create/update <file>) instead of a giant --post_content arg that the daemon IPC bus truncates (25KB -> 16 bytes). - CPT entries generated with their meta fields from the companion plugin's post types, so collections actually populate. - AI images use the authorized OpenAI images route (gpt-image-1 under the studio-assistant feature slug); Telex's Imagen slug is 403 for Studio accounts. Placeholders are stripped when not logged into WordPress.com. Adds unit tests (apps/cli/ai/tests/wsg-generation.test.ts, 22 passing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
This for now is a one size exploration which tries to settle the best shape of porting some of the Telex learnings on site generation into agent friendly skills and tools. Images don't generate because of the auth system on WPCOM for certain ai proxies which is not tied to user auth. The agent using the orchestrator command is still significantly slower than the Telex PHP orchestrator. Finally, an area this exploration shed light on is that we need to have a wp build system bundled somehow so we don't npm install for every theme fresh. Right now the draft instructs generation as vanilla JS for blocks to avoid building. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an end-to-end WordPress site generator to the
studio ai/studio codeagent. From a description, it produces a complete site: a pure-presentation block theme plus a companion plugin (custom post types, REST routes, build-less plain-JS blocks), seeds content into the live database, and fills AI imagery — all driven by the user's existing WordPress.com authentication.Adapted from the Telex generation pipeline, repackaged natively for this harness (Pi Agent Core tools +
SKILL.mdskills + the WPCom AI proxy that's already wired inproviders.ts).What it adds
Tools (registered in
apps/cli/ai/tools/index.ts):generate_design_previews— N distinct first-fold HTML directions for the user to pick fromgenerate_theme— parallel per-file generation of a pure-presentation theme (theme.json, style.css, templates, parts), activates it, returns a manifestgenerate_companion_plugin— CPTs / taxonomies / post meta / REST routes / build-less plain-JS blocks (no@wordpress/scripts)seed_content— generates page + CPT content and publishes it into the live DBgenerate_image— fillsAI_IMAGE:placeholders via the WPCom AI proxySkills (
apps/cli/ai/skills/): the orchestratorsite-generator(/site-generatorslash command) plus knowledge skillstheme-architecture,companion-plugin,layout-patterns,wp-best-practices,data-persistence, and bundled generator prompt fragments.Generation core (
apps/cli/ai/generation/): a non-streaming parallel Anthropic client that reuses the wpcom provider env, transient-error retry/backoff, robust JSON extraction, the manifest schema, AI_IMAGE handling, and WP-CLI helpers.Design
Two packages, not one bloated theme: the theme is presentation only; behaviour lives in a companion plugin that survives a theme switch. Content is seeded into the live DB, not baked into the theme. Custom blocks are build-less plain JS (matching the harness's existing no-build approach).
Notable correctness fixes (found during live testing)
wp post create/update --post_content=<large>is truncated crossing the daemon IPC bus (25KB → 16 bytes).seed_contentnow writes content to a host file the WP filesystem reads (wp post create/update <file>), since<site>/wp-contentis the live WP FS.gpt-image-1under thestudio-assistantfeature slug). Telex's Imagen slug returns 403 for Studio accounts. Placeholders are stripped (not left broken) when not logged into WordPress.com.Tests
apps/cli/ai/tests/wsg-generation.test.ts— 22 unit tests for the pure helpers (manifest parsing, fence/JSON extraction, transient-error classification, path containment, aspect mapping, AI_IMAGE parsing/stripping). ESLint clean.Build / verify
🤖 Generated with Claude Code