Skip to content

Add studio ai CLI command with interactive AI agent#2632

Draft
youknowriad wants to merge 10 commits intotrunkfrom
add-studio-ai-command
Draft

Add studio ai CLI command with interactive AI agent#2632
youknowriad wants to merge 10 commits intotrunkfrom
add-studio-ai-command

Conversation

@youknowriad
Copy link
Contributor

Related issues

  • Related to AI assistant exploration for Studio CLI

Proposed Changes

  • Add a new studio ai command that launches an interactive AI-powered WordPress assistant
  • Integrate the Claude Agent SDK with a terminal UI (pi-tui) for rich markdown chat
  • Provide MCP tools for site management: listing sites, getting site info, starting/stopping sites, running WP-CLI commands
  • Bundle WordPress development skills as SDK plugins (creating/editing blocks, themes, and patterns)
  • BYOK (Bring Your Own Key) authentication with API key persistence in appdata
  • Session resume across conversation turns within the same REPL session
  • Escape key to interrupt the agent mid-turn without losing context
  • Human-readable tool status in the spinner (e.g., "Running WP-CLI" instead of mcp__studio__wp_cli)
  • Tool result output displayed inline with dimmed formatting

Testing Instructions

Prerequisites

Setup

  1. npm install
  2. npm run cli:build

Basic flow

  1. Run node dist/cli/main.js ai
  2. On first run, you'll be prompted for your Anthropic API key — it will be saved for future use
  3. The chat interface should appear with a bordered editor at the bottom

Test conversations

Try these prompts to exercise different capabilities:

Site management tools:

  • "List all my WordPress sites" — should call site_list and display results
  • "Start [site-name]" — should start the site and confirm
  • "What plugins are installed on [site-name]?" — should use wp_cli with plugin list

WordPress development skills:

  • "Create a custom WordPress block plugin called 'testimonial-card' that displays a quote, author name, and photo" — should load the creating-blocks skill and write files
  • "Create a minimal block theme called 'minimal-starter'" — should load the creating-themes skill

UI behavior:

  • Verify the spinner shows human-readable labels (e.g., "Listing sites", "Reading file", "Thinking…")
  • Verify tool results appear as dimmed lines below the spinner
  • Verify error results appear with red prefix
  • Verify text from the agent has line breaks between consecutive messages (not concatenated)
  • Press Escape during a long operation — should interrupt the agent gracefully
  • Press Ctrl+C — should exit cleanly
  • When the agent asks questions (AskUserQuestion), verify options are numbered and you can type a number to select

Session continuity:

  • After one prompt completes, send a follow-up that references the first (e.g., "now add a settings panel to that block") — should resume the session context

Edge cases:

  • Try asking about a site that doesn't exist — should get a clear error
  • Try running WP-CLI on a stopped site — should tell you to start it first
  • Run with --max-turns 5 and give a complex task — should hit the limit with a clear message

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Introduces an AI-powered WordPress assistant accessible via `studio ai`.
Uses the Claude Agent SDK with a TUI (pi-tui) for interactive conversations.

Features:
- REPL chat interface with markdown rendering and bordered editor
- MCP tools for site management (list, info, start, stop, WP-CLI)
- WordPress development skills via SDK plugins (blocks, themes, patterns)
- BYOK authentication with saved API key
- Session resume across conversation turns
- Escape to interrupt, Ctrl+C to exit
- Human-readable tool status in spinner
- Tool result output display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad youknowriad force-pushed the add-studio-ai-command branch from b82b416 to cf74c03 Compare February 20, 2026 15:42
youknowriad and others added 2 commits February 20, 2026 16:49
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch to Sonnet model with bypassPermissions mode to prevent tool hanging
- Replace old skills (creating-themes, editing-blocks, editing-themes, generating-patterns)
  with new ones (frontend-design, wordpress-block-theming, wp-interactivity-api)
- Forward Logger progress messages to TUI spinner instead of fighting with ora
- Add directive workflow in system prompt to ensure site creation vs reuse
- Add block markup rules: no HTML blocks, no decorative comments, no emojis
- Fix stale PM2 bus cache causing "SUB connection already being closed" errors
  after site creation by clearing pm2Bus on disconnect

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad
Copy link
Contributor Author

This is not just a Proof of concept in my mind but yeah still early :P

youknowriad and others added 3 commits February 24, 2026 23:33
…m prompt

Remove the SDK plugin/skills system and move block content rules directly
into the system prompt. Switch to Sonnet 4.6, add PM2 keepAlive to prevent
stale bus connections, fix WP-CLI quoted argument parsing, and fix lint issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ributes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wojtekn
Copy link
Contributor

wojtekn commented Feb 25, 2026

This is not just a Proof of concept in my mind but yeah still early :P

I used 'Proof of Concept' to signal that we haven't settled on the exact approach yet, not to say the ideas aren't valuable - they are! We're actually about to start a project to integrate Studio with ACP, and what you've built here will definitely help shape that work. Since we don't know the final architecture yet, I'd rather not merge something we might need to rewrite later - but I'd love to keep this PR as a reference as we figure out the direction. Would that work for you?

Validates WordPress block content against registered save() functions
using @wordpress/blocks + @wordpress/block-library with jsdom as DOM
polyfill. The agent must now validate every file with block content and
loop until 0 invalid blocks remain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad
Copy link
Contributor Author

Let's discuss a bit after but IMO, We should ship something if it's valuable. I agree with not merging the PR before it's ready though if that's what you meant but if you see this PR as just a "vision PR", this is not my intent, my ultimate intent is to ship the PR.

youknowriad and others added 3 commits February 25, 2026 14:14
- Suppress console.error during block validation to eliminate verbose
  block type object dumps from WordPress's validation logging
- Auto-validate post content in wp_cli post create/update commands,
  rejecting invalid blocks before execution
- Add progress messages to validate_blocks showing file and result status
- Track last tool name in UI for context-aware result display
- Increase validation result truncation limit to 2000 chars
- Increase default max turns from 10 to 30
- Make --experimental-wasm-jspi conditional on Node 22+ to fix site
  startup on Node 20
- Add emitProgress helper to logger
- Update system prompt: restructure validation steps, add block content
  checklist, note wp_cli content validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a Playwright-based screenshot tool that captures full-page PNG
screenshots of URLs with desktop (1040x1248) and mobile (390x844)
viewport support. The browser instance is lazily initialized and
reused across calls. Returns images in MCP ImageContent format for
the agent to analyze visually.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…reenshots

Restructure system prompt: add design guidelines section with typography,
color, motion, and layout direction. Refine block content rules with
explicit core/html allowlist. Screenshot tool now waits for all images
to load before capturing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants