Skip to content

Add wp-ai-client, wp-ai-connectors, wp-ai-plugin (WP 7.0+ AI surfaces)#49

Open
henryperkins wants to merge 6 commits into
WordPress:trunkfrom
henryperkins:feat/wp-ai-skills
Open

Add wp-ai-client, wp-ai-connectors, wp-ai-plugin (WP 7.0+ AI surfaces)#49
henryperkins wants to merge 6 commits into
WordPress:trunkfrom
henryperkins:feat/wp-ai-skills

Conversation

@henryperkins

@henryperkins henryperkins commented May 4, 2026

Copy link
Copy Markdown

Adds three skills covering WordPress 7.0+ AI surfaces — wp-ai-client, wp-ai-connectors, wp-ai-plugin — plus additive extensions to wp-abilities-api for the WP 7.0+ JS API and the MCP Adapter. The eval harness gets an 8-line change so it accepts either the existing WP 6.9 + PHP 7.2.24 baseline or a new WP 7.0 + PHP 7.4 one; existing skills are unaffected.

Background: this is one of the three approaches I sketched in #48 (the dual-baseline one). I'm opening it as a concrete reference for that discussion rather than asserting the policy is decided — if maintainers prefer the class_exists-guards approach or want to keep the repo single-baseline, happy to close and reshape.

Summary

  • Three new skills covering WordPress 7.0+ AI surfaces: wp-ai-client, wp-ai-connectors, wp-ai-plugin.
  • Additive extensions to wp-abilities-api for the WP 7.0+ client-side JS API and the MCP Adapter (existing 6.9 content untouched).
  • Decision-tree entries in wordpress-router so AI tasks route to the right skill.
  • Eight-line patch to eval/harness/run.mjs accepting either the existing WordPress 6.9 + PHP 7.2.24 baseline or a new WordPress 7.0 + PHP 7.4 baseline. Existing skills are unaffected.
  • Compatibility policy + skill-set-v1 + README updated to reflect the dual-baseline + the three new skills.

Diff: +2,570 / −10 across 26 files. No existing skill's frontmatter, body, or scenarios are modified.

Why dual-baseline

The new AI surfaces (wp_ai_client_prompt(), WP_Connector_Registry, the canonical AI plugin's Abstract_Feature) literally do not exist on 6.9. A skill targeting them with a 6.9 floor would either lie in its compatibility line or load-bear class_exists() guards in every example — both options trade honesty for the harness check. The dual-baseline approach keeps each skill's declared floor truthful and the harness still gates against drift (now expressed against either of two named baselines).

The harness change is small enough to read here:

const matchesLegacyBaseline =
  compatibility.includes("WordPress 6.9") && compatibility.includes("PHP 7.2.24");
const matchesAiEraBaseline =
  compatibility.includes("WordPress 7.0") && compatibility.includes("PHP 7.4");
assert(
  matchesLegacyBaseline || matchesAiEraBaseline,
  ...
);

What's added

wp-ai-client — building features with the in-core AI Client

SKILL.md plus three references (prompt-builder.md, rest-patterns.md, error-handling.md) and a detect_ai_client.mjs script.

Anchored to canonical surfaces: wp_ai_client_prompt(), WP_AI_Client_Prompt_Builder, the is_supported_for_*() family, using_abilities() as the bridge to the Abilities API, the wp_ai_client_prevent_prompt filter (clarifies that the filter receives a clone of the builder), GenerativeAiResult. Reference patterns include per-feature REST endpoints (vs. the high-privilege client-side prompt API), structured output via as_json_response(), and image generation that lands in the Media Library with bounded data-URI parsing and post-upload MIME re-validation.

Sources cited: the AI Client dev note, WordPress/php-ai-client, WordPress/wp-ai-client, Trac #64591.

wp-ai-connectors — provider plugins

SKILL.md plus three references (provider-registration.md, capabilities-declaration.md, community-providers.md).

Encodes the canonical bootstrap from WordPress/ai-provider-for-anthropic v1.0.2 verbatim: AiClient::defaultRegistry()->registerProvider(Class::class) (class-name string, not instance; registerProvider, not register), class_exists + hasProvider guards, init priority 5 to run before _wp_connectors_init at 10, auto-discovery means you do not call WP_Connector_Registry::register() for new providers, the API key naming convention (connectors_ai_{id}_api_key, env/constant {ID}_API_KEY), and the env > constant > database priority order. Community-providers reference covers the OpenRouter (aggregator), Ollama (none auth, local), and Mistral (direct-API) patterns.

Sources cited: the Connectors API dev note, the AI Client dev note, the three flagship provider plugins, the Call for Testing post.

wp-ai-plugin — extending the canonical AI plugin

SKILL.md plus four references (experiments-framework.md, dashboard-widgets.md, guidelines-integration.md, hooks-and-filters.md).

Anchored to WordPress/ai v0.8.0 source. Covers Abstract_Feature (correct namespace WordPress\AI\Abstracts\Abstract_Feature, not WP\AI\Features\Abstract_Feature — a common error), the two extension points (wpai_default_feature_classes filter, wpai_register_features action), the canonical Example_Experiment as the copy-this starting point, paired-Ability registration via wp_abilities_api_init, guideline_categories() opting an Ability into Guidelines automatically, wp_supports_ai() gating, and the actual WPAI_* constant names (WPAI_PLUGIN_FILE, WPAI_PLUGIN_DIR, WPAI_PLUGIN_URL — not WPAI_FILE/WPAI_PATH/WPAI_URL). The dashboard-widgets reference explicitly states there is no AI-plugin-specific widget framework in v0.8.0 — extensions use standard wp_add_dashboard_widget().

Source cited: WordPress/ai (the source is the canonical reference) plus the AI Team blog.

wp-abilities-api — additive extensions

Two new references:

  • references/client-side.md — WP 7.0+ JavaScript API: @wordpress/abilities and @wordpress/core-abilities, registerAbility / executeAbility, the core/abilities store, how annotations (readonly / destructive / idempotent) drive the HTTP method (GET / DELETE / POST) when executeAbility calls a server-registered ability through REST.
  • references/mcp-exposure.md — installing the MCP Adapter via Composer, how abilities map to MCP tools, the default server vs. a custom server (create_server() has 13 parameters in v0.5.0+; the 7th is the required transports array), the two mcp_adapter_default_server_* filters, the Plain-permalinks gotcha, and Application Passwords for local Claude Desktop / Cursor integration.

The SKILL.md update adds step 6 (consume from JS) wording for the WP 7.0+ surface and a new step 7 (expose via MCP). The 6.9 content is unchanged and wp-abilities-api keeps its 6.9 + PHP 7.2.24 baseline; the new references are additive context for sites running 7.0.

wordpress-router/references/decision-tree.md

Adds entries for AI Client / Connectors API / canonical AI plugin / MCP Adapter so AI-related tasks route correctly. Existing entries unchanged.

Eval scenarios

Four new scenarios under eval/scenarios/:

  • ai-client-add-feature-endpoint.json — "add a 'rewrite paragraph' button to the editor"
  • ai-connectors-register-provider.json — "build a Mistral provider plugin"
  • ai-plugin-register-experiment.json — "add an internal-link suggestion Experiment to WordPress/ai"
  • abilities-mcp-expose.json — "expose existing abilities to Claude Desktop via MCP"

Each lists explicit success criteria pinned to method names / namespaces / hook timing — they catch the named errors a model is most likely to produce on these surfaces (e.g., register() vs registerProvider(), the wrong namespace for Abstract_Feature, missing class_exists guards).

Docs

  • docs/compatibility-policy.md — names both baselines, documents that 7.0+ is only for skills covering features unavailable on 6.9.
  • docs/skill-set-v1.md — lists the three new skills.
  • README.md — adds the three new skills to the Available Skills table (matches PR New Skill: wp-plugin-directory-guidelines #22's precedent).

Verification

Locally on feat/wp-ai-skills:

  • node eval/harness/run.mjsOK: skills frontmatter and triage report sanity checks passed.
  • node shared/scripts/skillpack-build.mjs --clean --out=/tmp/x --targets=codex,vscode → both packs build.
  • node skills/wp-ai-client/scripts/detect_ai_client.mjs → returns the documented JSON shape on a non-WP repo.

CI (.github/workflows/ci.yml) is unchanged. The skills-ref validate step in CI explicitly enumerates a subset of skills today (it does not currently validate wp-rest-api, wp-phpstan, wpds, blueprint, wp-plugin-directory-guidelines either) — I left it unchanged here so this PR is purely additive. Adding the new skills to that list is a separate cleanup if maintainers want it.

Test plan

  • node eval/harness/run.mjs passes on CI.
  • Skillpack build + smoke install in CI passes (it already runs against the codex and vscode targets).
  • Frontmatter on each of the three new skills matches the new baseline string WordPress 7.0 + PHP 7.4.
  • Frontmatter on every existing skill still matches WordPress 6.9 + PHP 7.2.24.
  • wordpress-router decision-tree changes route AI/MCP queries correctly without breaking existing routes.
  • Spot-check one example from each new skill against the canonical source (Anthropic provider plugin, Example_Experiment.php, dev notes) to confirm method/namespace accuracy.

Notes for maintainers

  • Issue Discussion: how should this repo handle skills targeting WP 7.0+ surfaces? #48 frames the policy question. This PR is one option. I'm happy to close it and re-open under a different shape if a different approach wins the discussion there.
  • AI authorship: the three new skills were drafted by Claude (Opus 4.7) against the canonical sources cited above and reviewed by me. docs/ai-authorship.md is intentionally not modified in this PR — the existing table is per-skill discretion (PR New Skill: wp-plugin-directory-guidelines #22 did not extend it either) and I'd rather follow the maintainer's preference than guess.
  • No version bump on the standalone skillpack manifest (none exists separately from skills/); the build script auto-discovers skills/*/SKILL.md.

🤖 Generated with Claude Code

henryperkins and others added 6 commits May 3, 2026 19:34
Adds three skills covering the WP 7.0+ AI surface:

- wp-ai-client — building AI features via wp_ai_client_prompt() and the
  in-core fluent prompt builder, including REST patterns, error handling,
  feature detection, and the using_abilities() bridge to the Abilities API.
- wp-ai-connectors — writing AI provider plugins that register with
  AiClient::defaultRegistry() and surface in Settings -> Connectors via
  the Connectors API auto-discovery flow.
- wp-ai-plugin — extending the canonical WordPress/ai plugin with
  Experiments (Abstract_Feature), paired Abilities, Guidelines, and the
  documented wpai_* extension hooks.

Extends wp-abilities-api with WP 7.0+ client-side coverage
(@wordpress/core-abilities, executeAbility, core/abilities store) and a
new MCP exposure reference for routing abilities to Claude Desktop,
Cursor, and ChatGPT via the MCP Adapter.

Updates wordpress-router decision tree with routing entries for the new
skills and the MCP sub-route. Adds four eval scenarios covering the new
skills' procedures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The compatibility contract assertion required every skill to declare
WordPress 6.9 + PHP 7.2.24 in its frontmatter. The new wp-ai-client,
wp-ai-connectors, and wp-ai-plugin skills target WP 7.0+ exclusively
(the AI Client and Connectors API don't exist in 6.9), so they cannot
honestly claim 6.9 compatibility.

Accept either baseline — legacy (WP 6.9 + PHP 7.2.24) or AI-era
(WP 7.0 + PHP 7.4) — and update the assertion message accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Brings docs/compatibility-policy.md in line with the harness change in
ca6fd44. Skills targeting WP 7.0+ AI surfaces (AI Client, Connectors
API, client-side Abilities API) declare WordPress 7.0+ / PHP 7.4+;
all other skills continue to declare the 6.9 / 7.2.24 default floor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add WP 7.0 AI skill set + abilities-api extensions
prompt-builder.md: the conditional autoloader used
wp_get_wp_version(), which isn't a canonical WordPress function.
Replace with feature detection on wp_ai_client_prompt() — the
standard "feature, not version" pattern.

rest-patterns.md: the image upload example had a placeholder
comment ("/* extract from data URI */") inside base64_decode(),
making the snippet syntactically incomplete. Replace with a real
data-URI parser: bounded size, allowed-subtype regex (png/jpeg/
webp), strict base64, post-upload MIME re-validation, cleanup on
failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Match the precedent set by PR WordPress#22 (wp-plugin-directory-guidelines) and
list the three new WP 7.0+ AI skills in the discoverability table.
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: henryperkins <htperkins@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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.

1 participant