WP Manifestindependent plugin directory
manifest / ai / gutenberg-ai-assistant

AI Editor Assistant

A secure, server-side AI assistant for the WordPress block editor. Rewrite, summarize, expand, and tone-shift content from a Gutenberg sidebar - with proper API key handling, per-user rate limiting, and a usage log. No client-side keys, no SaaS lock-in.

by Dan Lapteacru · github.com/danlapteacru/gutenberg-ai-assistant · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/danlapteacru/gutenberg-ai-assistant/archive/refs/heads/main.zip

Readme

AI Editor Assistant

A WordPress plugin that adds an AI-powered writing assistant to the Gutenberg editor. It runs all API calls server-side so your Anthropic key is never sent to the browser, handles per-user rate limiting to keep costs predictable, and logs every request for auditing. The sidebar lets authors rewrite, summarize, expand, or shift the tone of selected blocks without leaving the editor.

Features

  • AI writing actions — rewrite, summarize, expand, and tone-shift selected block content directly from the editor sidebar.
  • Server-side API calls — all requests to the Anthropic API are made from PHP; the API key never reaches the client.
  • Key resolution chain — the plugin checks AI_EDITOR_ASSISTANT_ANTHROPIC_KEY constant, then the AI_EDITOR_ASSISTANT_ANTHROPIC_KEY environment variable, then the value saved on the Settings page.
  • Per-user rate limiting — configurable request cap per user to prevent runaway costs.
  • Usage logging — every API call is recorded with user, token count, and timestamp. No prompt content is stored.
  • Gutenberg sidebar — a dedicated sidebar panel registered via @wordpress/plugins so it feels native to the editor.
  • Capability checks — only users with the edit_posts capability can access the assistant.

Installation

Composer (recommended)

composer require danlapteacru/ai-editor-assistant

Manual

  1. Download the latest release from GitHub.
  2. Upload the ai-editor-assistant folder to wp-content/plugins/.
  3. Run composer install --no-dev inside the plugin directory.
  4. Run npm install && npm run build to compile the JavaScript assets.
  5. Activate the plugin in Plugins > Installed Plugins.

Configuration

The plugin resolves the Anthropic API key in this order:

  1. PHP constant (highest priority)
  2. Environment variable
  3. Settings page value (lowest priority)

To use a constant, add this to wp-config.php:

define('AI_EDITOR_ASSISTANT_ANTHROPIC_KEY', 'sk-ant-...');

Alternatively, set the AI_EDITOR_ASSISTANT_ANTHROPIC_KEY environment variable on your server, or enter the key on the Settings > AI Editor Assistant page in the WordPress admin.

Security Notes

  • The API key is resolved and used on the server only. It is never exposed to the browser or included in any REST response.
  • All REST endpoints require the edit_posts capability, so subscribers and unauthenticated visitors cannot trigger API calls.
  • Per-user rate limiting prevents any single account from generating excessive requests.
  • Prompt and completion content is never written to the database. The usage log records only metadata: user ID, token counts, model, and timestamp.

Cost Control

  • View per-user and aggregate usage under Tools > AI Usage Log in the WordPress admin.
  • Rate limits and maximum token counts are configurable to cap spending.
  • The default model is claude-sonnet-4-6. Override it with the ai_editor_assistant_model filter.

Extending

Filters

Filter Description Default
ai_editor_assistant_model Override the Anthropic model used for requests claude-sonnet-4-6

Actions

  • The activation hook creates the usage-log database table automatically on plugin activation.

Development Setup

Requires PHP 8.1+, Node 20+, and Composer.

# Install PHP dependencies
composer install

# Install JS dependencies and build assets
npm install
npm run build

# Start the dev watcher (hot reload)
npm run start

# Run PHPCS
vendor/bin/phpcs

# Run PHPUnit
vendor/bin/phpunit

Requirements

  • WordPress 6.4+
  • PHP 8.1+
  • Node 20+ (for building JS assets)

License

GPL-2.0-or-later. See LICENSE for details.

Read the full README on GitHub →