Skip to content

Conversation

@tobimori
Copy link
Owner

@tobimori tobimori commented Oct 26, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added AI-powered content generation for meta titles, descriptions, and Open Graph fields with streaming support
    • Integrated multiple AI provider support (OpenAI, Anthropic, OpenRouter)
    • Added edit and customize workflows for AI-generated content
    • Introduced AI permissions and enhanced editor interface with generation controls
  • Documentation

    • Updated README with contributing guidelines and improved product description

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR adds AI-assisted content generation to the Kirby SEO plugin. It introduces a streaming AI infrastructure with multiple provider support (OpenAI, Anthropic), backend prompt scaffolding for SEO tasks, Vue component streaming integration, and updated field blueprints with AI-enabled seo-writer field types. Configuration, translations, and documentation are expanded accordingly.

Changes

Cohort / File(s) Summary
AI Backend Infrastructure
classes/Ai.php, classes/Ai/Driver.php, classes/Ai/Chunk.php, classes/Ai/SseStream.php
New AI facade with provider management; abstract Driver base class; Chunk value object for streaming events; SseStream for HTTP/2 server-sent events streaming with curl multi-handle management, frame parsing, and error handling.
AI Provider Drivers
classes/Ai/Drivers/Anthropic.php, classes/Ai/Drivers/OpenAi.php
Concrete driver implementations for Anthropic and OpenAI APIs; build request headers/payloads; handle SSE event mapping to Chunk types; yield streaming responses.
Field Blueprints Updates
blueprints/fields/meta-group.yml, blueprints/fields/og-group.yml, blueprints/fields/title-template.yml, blueprints/site.yml
Replace inline/marks/nodes options with ai identifiers (title, description, og-description, site-description, site-og-description); streamline content generation configuration.
AI Field Configuration
config/fields.php, config/options/ai.php
New seo-writer field extending writer with AI button, permission checks, and POST /ai/stream endpoint for SSE streaming; AI options define enabled flag, default provider, and provider configs.
Vue Component AI Integration
src/fields/seo-writer.vue, src/fields/seo-writer-input.vue, index.js
Add ai prop, aiStreaming state, buttons computed property for AI actions, streaming lifecycle methods, SSE event handling, editor delta application, dialog handlers for instructions/edits.
AI Prompt Templates
snippets/prompts/introduction.php, snippets/prompts/content.php, snippets/prompts/meta.php, snippets/prompts/site-meta.php, snippets/prompts/tasks/title.php, snippets/prompts/tasks/description.php, snippets/prompts/tasks/og-description.php, snippets/prompts/tasks/og-site-description.php, snippets/prompts/tasks/site-description.php
Prompt scaffolding: introduction with role/rules; content extraction and sanitization; meta field collection; task-specific instructions for title, meta descriptions, OG descriptions at page and site levels.
Plugin Registration & Config
index.php, config/areas.php, config/options.php, config/fields.php
Update plugin registration to extends-based format; add fields, permissions, snippets, templates, blueprints config sections; convert areas callback to arrow function; wire AI configuration.
Documentation & Metadata
README.md, composer.json
Add Contributing section with SEO license eligibility; update description to emphasize technical SEO and ease of use; update license link to ./LICENSE.md.
Build & Package Config
package.json, src/index.js
Add package name "kirby-seo"; bump devDependencies and kirbyuse; expand browserslist; add seo-ai icon SVG.
Internationalization
translations/en.json, translations/cs.json, translations/de.json, translations/fr.json, translations/nl.json, translations/pt_PT.json, translations/sv_SE.json, translations/tr.json
Add AI action labels (generate, regenerate, edit, customize, stop), error messages (request, disabled, permission), dialog labels/placeholders/submissions across 8 languages.
Utility Updates
classes/Meta.php
Replace HTML sanitization with Str::unhtml for template variable content.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Panel as Kirby Panel<br/>(Vue Component)
    participant Backend as PHP Backend<br/>(Streaming Endpoint)
    participant Provider as AI Provider<br/>(OpenAI/Anthropic)

    User->>Panel: Click "Generate" (AI Enabled)
    Panel->>Panel: Open instruction/edit dialog
    User->>Panel: Confirm instruction
    Panel->>Backend: POST /ai/stream<br/>(SSE, with instructions & field data)
    activate Backend
    Backend->>Backend: Validate permissions & ai.enabled()
    Backend->>Backend: Load & render prompt snippets<br/>(introduction, meta, content, task)
    Backend->>Backend: Send SSE headers<br/>Set up streaming
    Backend->>Provider: Stream POST request<br/>(prompt, model, stream=true)
    activate Provider
    Provider-->>Backend: SSE event stream
    deactivate Provider
    activate Panel
    loop Process SSE Events
        Backend->>Backend: Parse SSE frames<br/>Map to Chunk types
        Backend-->>Panel: SSE data event<br/>(chunk: type, text, payload)
        Panel->>Panel: consumeStream()<br/>processStreamBuffer()
        Panel->>Panel: handleAiEvent()<br/>(text-delta, error, etc.)
        Panel->>Panel: applyAiDelta() to editor
        Panel->>User: Render streamed text
    end
    deactivate Panel
    deactivate Backend
    User->>Panel: View generated content
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • classes/Ai/SseStream.php — Core streaming infrastructure with curl multi-handle management, buffer draining, frame parsing, and error extraction; verify correctness of SSE protocol parsing and resource cleanup.
  • classes/Ai/Drivers/*.php — Verify correct event mapping for each provider API (Anthropic vs. OpenAI event schemas differ); check for robust error handling and timeout behavior.
  • src/fields/seo-writer.vue — Complex streaming lifecycle with AbortController, multiple event handlers, and editor state mutation; ensure proper cleanup and error propagation.
  • config/fields.php ai/stream endpoint — Permission checks, language context setup, SSE header handling, and data transformation should be carefully reviewed for security and correctness.
  • Prompt templates — Verify prompt construction logic across task types (title template handling in snippets/prompts/tasks/title.php includes conditional length calculations).

Poem

🐰 Whiskers twitch with glee as AI takes the quill,
Streams of brilliance flow—a prompt-crafted thrill!
From Anthropic dreams to OpenAI's might,
SEO content sparkles, SVG and bytes unite!
With chunks and drivers, the panel comes alive—
Watch those delta deltas help your content thrive!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ai

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 511b09d and a966e11.

⛔ Files ignored due to path filters (2)
  • i18n.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • README.md (3 hunks)
  • blueprints/fields/meta-group.yml (2 hunks)
  • blueprints/fields/og-group.yml (1 hunks)
  • blueprints/fields/title-template.yml (0 hunks)
  • blueprints/site.yml (2 hunks)
  • classes/Ai.php (1 hunks)
  • classes/Ai/Chunk.php (1 hunks)
  • classes/Ai/Driver.php (1 hunks)
  • classes/Ai/Drivers/Anthropic.php (1 hunks)
  • classes/Ai/Drivers/OpenAi.php (1 hunks)
  • classes/Ai/SseStream.php (1 hunks)
  • classes/Meta.php (1 hunks)
  • composer.json (1 hunks)
  • config/areas.php (1 hunks)
  • config/fields.php (1 hunks)
  • config/options.php (1 hunks)
  • config/options/ai.php (1 hunks)
  • index.js (1 hunks)
  • index.php (1 hunks)
  • package.json (2 hunks)
  • snippets/prompts/content.php (1 hunks)
  • snippets/prompts/introduction.php (1 hunks)
  • snippets/prompts/meta.php (1 hunks)
  • snippets/prompts/site-meta.php (1 hunks)
  • snippets/prompts/tasks/description.php (1 hunks)
  • snippets/prompts/tasks/og-description.php (1 hunks)
  • snippets/prompts/tasks/og-site-description.php (1 hunks)
  • snippets/prompts/tasks/site-description.php (1 hunks)
  • snippets/prompts/tasks/title.php (1 hunks)
  • src/fields/seo-writer-input.vue (1 hunks)
  • src/fields/seo-writer.vue (2 hunks)
  • src/index.js (1 hunks)
  • translations/cs.json (2 hunks)
  • translations/de.json (2 hunks)
  • translations/en.json (1 hunks)
  • translations/fr.json (1 hunks)
  • translations/nl.json (2 hunks)
  • translations/pt_PT.json (2 hunks)
  • translations/sv_SE.json (1 hunks)
  • translations/tr.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tobimori tobimori merged commit e80f215 into main Oct 26, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants