Repository navigation
Conversation
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #949 +/- ##
=============================================
- Coverage 75.37% 75.31% -0.07%
- Complexity 3357 3405 +48
=============================================
Files 138 144 +6
Lines 12976 13395 +419
=============================================
+ Hits 9781 10088 +307
- Misses 3195 3307 +112
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@gziolo This part:
I think is fairly important. Wondering if we should extract that piece out to it's own PR so we can get that merged and fixed sooner. |
62f4fc1 to
2c14695
Compare
Adds the `wp_knowledge` storage layer and a Settings > Guidelines page, ported from the Gutenberg plugin's `lib/experimental/knowledge` and `routes/guidelines`. The Gutenberg plugin ships the same feature behind its `gutenberg-guidelines` flag. Both share one contract, so only one may provide it. The rule is first to declare it wins: every shared `wp_*` function sits behind `function_exists()`, the classes are namespaced so there is no redeclare, and `Knowledge_Post_Type::register()` returns early when `wp_knowledge` already exists. Ownership then gates the scopes route and the admin page, so the two plugins never produce a duplicate page or route. The Guidelines service read the removed `wp_guideline` post type and its post meta, so guideline injection into prompts had stopped working against current Gutenberg. It now reads `wp_knowledge` rows by slug. The public API is unchanged, so the abilities using it need no edits. `isContentBlock` is a private API in `@wordpress/blocks` that a plugin cannot unlock, so the route reimplements it on public APIs.
The lock was regenerated with npm 11 on Node 24, but CI follows .nvmrc and runs npm 10 on Node 22. The newer npm dropped four transitive entries that npm 10 still resolves, so npm ci failed on a lock that was out of sync with package.json. Regenerated with Node 22, which leaves a single added line for the new @wordpress/blob dependency.
2c14695 to
28572f9
Compare
- Use `@since x.x.x` in the new Knowledge files. Version 1.3.0 is already released. - Remove the CHANGELOG.md entries. The changelog is put together at release time. - Port the rest of Gutenberg's Guidelines e2e spec: Settings menu link, saving and clearing scope guidelines, reclaiming a private row, adding a block guideline, export and import, and a filtered scopes registry. - Add a REST toggle to the E2E Testing plugin that filters `wp_guideline_scopes`, so the filtered-registry scenario can run without a separate test plugin.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@gziolo I'm not sure it makes sense / that I agree on pulling Knowledge/Guidelines fully into the AI plugin. I'm fine with an AI experiment relying on Gutenberg being installed (and a Gutenberg experiment being enabled) as this is similar to trying to have folks help test the new media editor (via a forthcoming AI experiment on smart focal cropping). In my mind, this helps drive folks to trying out Gutenberg experiments (and perhaps trying out more than one) and as such don't know that its better to try and duplicate things here in the AI plugin. |
|
@jeffpaul My reading of the merge proposal feedback was that moving testing into the AI plugin was the expected next step, to demonstrate deeper integration with AI features and gather broader feedback. That was the motivation behind this PR. Given your feedback and the limited interest in pursuing this direction, I’m inclined to close this PR and continue iterating on the experiment in Gutenberg. |
Background
In June, the Merge Proposal: Guidelines built on Knowledge asked to bring the
wp_knowledgepost type and the Guidelines page into WordPress 7.1. The feedback was mixed. Several people felt the design was not proven yet and asked for a full release cycle in a plugin first. On July 10 the proposal was declined for 7.1. The stated bar for core is real-world adoption with strong week-to-week growth.This PR is a step toward that bar. Shipping the feature as an experiment in the AI plugin lets it reach sites that do not run the Gutenberg plugin, so it can gather real usage and feedback before another proposal.
What?
Adds a new Knowledge and Guidelines experiment. When it is enabled, the AI plugin stores site guidelines in the
wp_knowledgepost type and adds a Settings → Guidelines page to manage them.Both parts are ported from the Gutenberg plugin:
lib/experimental/knowledgeandroutes/guidelines. The port stays as close to the upstream code as possible, so future Gutenberg changes are easy to bring over.Why?
Site guidelines give AI features useful context about the site's purpose, voice, and style. Since #988, the AI plugin reads them from
wp_knowledge. But it had no way to create or edit them. That only worked when the Gutenberg plugin was installed with itsgutenberg-guidelinesexperiment turned on.With this PR, the AI plugin can provide the storage and the settings page on its own.
How?
One feature, two plugins: the first to declare it wins
Gutenberg ships the same feature. Both plugins share one contract: the
wp_knowledgepost type, the/wp/v2/knowledgeREST routes, and a small set of sharedwp_*helper functions. So only one plugin may provide it at a time.This PR follows the same rules Gutenberg already uses, so neither side needs to know about the other:
function_exists()guards.The scopes REST route and the Settings page are registered only when this plugin owns the feature. So there is never a duplicate page or a duplicate route.
Gutenberg registers on
initat priority 10. This experiment runs at priority 15. As a result, Gutenberg wins whenever its flag is on. The AI plugin takes over when the flag is off or Gutenberg is not installed. The page URL is the same in both cases:options-general.php?page=guidelines-wp-admin.Owning versus extending
Other plugins do not need to own the feature to add to it. To add a scope or a knowledge type, use the
wp_guideline_scopesandwp_knowledge_typesfilters. They work no matter which plugin owns the base implementation, and the Settings page grows a new section automatically.docs/experiments/knowledge.mdhas an example.What changed in the port
The PHP moved into namespaced classes under
includes/Experiments/Knowledge/and plugs into the plugin's experiment framework. The UI is a wp-build route underroutes/guidelines/.Two things had to be adapted rather than copied:
@wordpress/blocksto decide which blocks can carry guidelines. A plugin cannot unlock it, so the route reimplements the same check with public APIs.@wordpress/componentsimports (VStack, HStack, Heading, ConfirmDialog).@wordpress/uidoes not cover all of them yet. To keep the port close to upstream, the lint rule for these imports is turned off forroutes/guidelines/only. Happy to swap them out instead if reviewers prefer.Smaller adjustments: the
aitext domain was added, the stricter TypeScript settings of this repo were satisfied, and SCSS variables were replaced with plain values because@wordpress/base-stylesis not a dependency here.docs/experiments/knowledge.mddescribes the feature, the ownership rule, the capabilities model, and how to extend it.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Reading the Gutenberg source, writing the port and the adaptation work, and drafting the tests and docs. All of it was reviewed and adjusted by me.
Testing Instructions
Without Gutenberg
<guidelines>block.With Gutenberg,
gutenberg-guidelinesonWith Gutenberg,
gutenberg-guidelinesoffAutomated
All pass. New PHP tests cover the experiment, including that it stands down when the post type already exists. The e2e spec is a port of Gutenberg's Guidelines spec. It covers the Settings menu link, saving and clearing guidelines, block guidelines, export and import, focus handling, and a plugin that filters the scopes registry. The E2E Testing helper plugin gained a small REST toggle for that last scenario.
Screenshots or screencast
Changelog Entry
🤖 Generated with Claude Code