Feature/content guidelines#359
Conversation
|
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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #359 +/- ##
=============================================
+ Coverage 66.90% 67.72% +0.81%
- Complexity 907 959 +52
=============================================
Files 59 60 +1
Lines 4699 4836 +137
=============================================
+ Hits 3144 3275 +131
- Misses 1555 1561 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@saarnilauri let us know when this is ready again for review/testing, thanks! |
|
I have updated the post type to match the new slug but keep the legacy slug for < 23.0
The support for the guideline taxonomy is now baked in.
Gutenberg's REST controller saves new guideline posts as 'draft' by default. Our query only matched 'publish', silently returning no guidelines for the common case. Now accept both statuses (matching Gutenberg's own
These new abilities have now guidelines injected to them. So, everything is ready for your review. The not yet implemented PR WordPress/gutenberg#77230 in the Gutenberg, requires a larger refactoring and we need to keep tracking it's progress. It might be better to create a new issue related to it. |
dkotter
left a comment
There was a problem hiding this comment.
Tested and works well for me now. Left one comment about maybe waiting until Gutenberg 23.0 comes out before merging this, so we can just make that the minimum version we support. But otherwise this looks good to go, thanks for all the work here!
jeffpaul
left a comment
There was a problem hiding this comment.
Tested copy and images guidelines and title generation and featured image generation resulted as expected.
Just passing by and saw this. Are we picking up a new dependency in the form of the Gutenberg plugin or is there some availability checking that I'd see if I actually pulled this PR down to review more deeply? |
It is the latter. We are not including Gutenberg as a dependency within the plugin. This is a progressive enhancement that only runs if the right version of Gutenberg is installed and if the Guidelines experiment is turned on. |
|
Ready for the review |
dkotter
left a comment
There was a problem hiding this comment.
Looking good now. Looks like the meta keys they use were also updated in the latest version of Gutenberg so I had to push a fix for those (going from _content_guidelines to just _guidelines. Also had some flaky E2E tests not related to this PR I fixed up.
Thanks for all the work here @saarnilauri!
What?
Closes #322
Adds Content Guidelines integration to the AI plugin, allowing all AI abilities to respect site-wide editorial standards defined via Gutenberg's
wp_content_guidelinecustom post type (introduced in Gutenberg 22.7+).Why?
When sites define content guidelines (tone, style, image standards, etc.), AI-generated content should follow them. Without this integration, AI abilities operate without awareness of the site's editorial standards, producing output that may not align with the site's voice and style.
How?
New
Content_Guidelinesservice (includes/Services/Content_Guidelines.php):wp_content_guidelineCPTsite,copy,images,additional, plus per-block guidelines<content-guidelines>) for prompt injectionwpai_max_guideline_length)wpai_use_content_guidelinesfilterAbstract ability opt-in pattern (
includes/Abstracts/Abstract_Ability.php):guideline_categories()method — subclasses override to declare which categories they useget_content_guidelines_for_prompt()helper fetches and formats guidelines for the declared categoriesget_system_instruction()auto-appends a guidelines-awareness paragraph when categories are declaredPer-ability wiring — each ability declares relevant categories and injects guidelines into its prompt:
site,copysite,copysite,copysite,imagessite,imagessite,imagessite,copy,additionalReview Notes also gains a new
guidelinesreview type that flags content violating the editorial standards.Helper functions in
includes/helpers.php:get_content_guidelines()— retrieve guidelines (optionally filtered by category)format_content_guidelines_for_prompt()— format guidelines for prompt injectionUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code (Opus 4.6 and Sonnet 4.6)
Used for: Initial planning and code implementation; finalization of implementation and tests were reviewed and edited by me.
Testing Instructions
npm run test:e2e:env:startnpm run test:php— runs unit/integration tests includingContent_Guidelines_TestandAbstract_Ability_Guidelines_Testnpm run test:e2e— runs e2e tests includingcontent-guidelines.spec.jswp_content_guidelineCPT doesn't exist).