Repository navigation
Feature : Site Agent Experiment - #1214
Vrishabhsk wants to merge 3 commits into
Conversation
Adds a conversational assistant under Tools that reads site information and proposes site changes. Actions are ordinary WordPress Abilities, so each keeps its own schema, permission callback, validation, and execution hook. The agent adds a reviewed allowlist, a propose-then-approve boundary for writes, and an audit trail. Write proposals are user-scoped, conversation-bound, single-use, and expire after 30 minutes. The experiment and its write gate are disabled by default. See WordPress#189.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Vrishabhsk. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1214 +/- ##
=============================================
- Coverage 85.49% 83.13% -2.36%
- Complexity 4807 5331 +524
=============================================
Files 188 205 +17
Lines 17734 19703 +1969
=============================================
+ Hits 15161 16380 +1219
- Misses 2573 3323 +750
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:
|
Add persistent named conversation history with rename/archive/delete, render Markdown and proposal content, show current and proposed values with inline editing before approval, require a next step in replies, refresh the sample prompts, and make the screen fill the admin frame. Also add controller and conversation-store coverage.
…-develop # Conflicts: # includes/Experiments/Experiments.php # readme.txt
|
hi @jeffpaul, i've made some modifications based on your feedback. Could you take a look? |
|
@Vrishabhsk probably better to get your help reviewing the AI Workspace PRs as we're planning to ship that and the Site Agent is more or less a duplicate of that (note we're still crediting you there for your work here). So peeking into any open PRs in https://github.com/WordPress/ai/pulls?q=is%3Apr+state%3Aopen+workspace and providing feedback there would be most helpful, thanks! |
…pplied on approval (#1314) ## What? Related: #1287 The AI Workspace can now change things that already exist, not only create drafts and templates. The assistant can propose a new title, excerpt or content for a post, or a new site title or tagline. Nothing changes until you approve, and the card shows each current value next to the proposed one. You can edit a value before approving it. This is the first of the stacked PRs that build #1287's single agent on top of `feat/ai-workspace` (#1004). It ports #1214's write actions. The next PRs add site info and screen finding, then the Command Palette entry, then audit and privacy hooks, then the docs pass for the name. ## Why? #1287's first version needs the agent to finish tasks like "change my tagline to fit what I write about" instead of telling the person how. Before this, the workspace's approval flow could only create new posts. Its single-approval guarantee rested on a per-post token, which doesn't exist when you're editing something that's already there. ## How? **Writes are proposal types, not abilities.** `ai/propose-post-changes` and `ai/propose-site-identity` only store a proposal. The write happens when the person approves it in the card. #1214 registered `ai/site-agent-update-post` and `ai/site-agent-update-setting` as abilities instead. In this plugin every `ai/*` ability is offered over MCP by default, so those would have been callable by any MCP client with no approval step. #1214's validation rules are ported into the two new writers. **The approval flow is now safe for editing existing content:** - **One approval:** approving takes a lock with a single `INSERT IGNORE` into the options table, the pattern core's `WP_Upgrader::create_lock()` uses. `add_option()` won't do here: it writes with `ON DUPLICATE KEY UPDATE`, which lets a second claim with a different value succeed. - **Partial results kept:** each item's result is saved as soon as it's written. An approval still running after five minutes reads as failed and keeps its partial results. - **Expired and deleted:** an expired proposal is reported as expired, not "not found". A proposal whose chat was deleted can't be approved. - **Checked at approval:** a field that changed since it was proposed is left alone and reported as changed. One already at the new value is reported as unchanged. A post someone else is editing is reported as locked. - **Edits re-checked:** an edited value runs through the same server-side rules as the assistant's value, and it can change only the value, never which post, field or option is targeted. **Content stays intact:** - **Plain titles:** a title with any markup is refused. Core skips title kses for admins with `unfiltered_html`, so this check is the only one. - **No silent stripping:** a content change is refused when kses would strip something from the post's current content, such as an iframe or an embed saved by an admin. Ordinary block markup like images and separators is fine. - **One field at a time:** writing one field leaves the post's other text columns exactly as stored. - **Block markup kept:** `ai/read-content-bodies` gains `raw: true`. It returns the stored markup, only for posts the user can edit, so a content change can keep the post's blocks. **The card hides nothing that would publish.** Content is parsed in an inert `DOMParser` document and drawn through the transcript's existing renderer. Self-closing blocks (`core/rss`, `core/latest-posts`), media, embeds and form controls show in place as plain text, so a person sees everything they're approving. Nothing is fetched or run, and links are live only on the site's own host. **Workspace-only abilities are off MCP.** `ai/propose-*` and `ai/ask-user` now declare `meta.mcp.public` as false. Before, MCP clients were offered tools that always refused outside a workspace turn. An override on the MCP Access screen still wins. **Filters:** - `wpai_workspace_write_proposals_enabled` (default true) turns these two proposal types off. That's #1287's "allow writes" question: on by default, with no settings toggle. - `wpai_workspace_proposal_kinds` is the list of proposal types. The tool list, the turn-ending rules and the system instruction are now all built from it. Code from #1214 is credited to @Vrishabhsk with Co-authored-by on the two writer commits. ### Use of AI Tools AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: planning, implementing the changes and tests, and code review. I've reviewed the changes, understand them and can explain them under review. They have all been tested locally. ## Testing Instructions 1. Enable AI Workspace under Settings → AI and connect a provider. 2. In Tools → AI Workspace, ask "Make my tagline fit what I write about". - The card shows the current tagline beside the proposed one. - Edit the proposed tagline, then apply. Settings → General shows your edited tagline. 3. Ask for a new title for one of your published posts. The card says the change is live as soon as you approve it. 4. Open the same chat in a second tab and approve in the first. The second tab shows the outcome, not an Apply button. **Tests run** (all passing): - **PHPUnit, full suite:** 3306 tests on WordPress latest, on both single site and multisite, at 4f6931b. Before the first round of review fixes, the full suite also passed on trunk (7.2-beta4), at 3286 tests. - **PHPUnit, new tests:** - `Proposal_StoreTest`: lock, failed window, expiry grace, edits, kind registry, write gate, and client/server ability parity. Includes `test_a_lock_row_written_outside_the_cache_blocks_the_claim`, which failed against the old `add_option()` lock. - `Post_Field_ProposalTest`, including `test_a_title_changed_since_the_proposal_is_stale`, `test_two_fields_of_one_post_both_write`, `test_a_post_locked_by_another_user_is_locked`, `test_content_with_an_iframe_is_refused_but_other_fields_work`, `test_content_with_an_image_block_accepts_a_change`, `test_content_with_a_separator_block_accepts_a_change`, `test_content_kses_would_strip_from_is_refused`, `test_an_edit_cannot_retarget_the_item`, `test_a_duplicate_field_of_one_post_is_refused`, `test_a_model_supplied_snapshot_is_ignored` and `test_a_title_with_a_backslash_survives_the_write`. - `Site_Identity_ProposalTest`: 16 tests. - `Proposal_ControllerTest`: `test_approval_while_another_request_holds_the_lock_writes_nothing`, `test_an_interrupted_write_keeps_partial_results_and_reads_as_failed`, `test_approving_after_the_chat_was_deleted_is_refused` and `test_get_returns_the_stored_results_once_approved`. - `MCP_AdapterTest`: `test_plugin_ability_declared_hidden_stays_hidden`, `test_workspace_only_abilities_are_hidden_from_mcp`, `test_override_exposes_a_plugin_ability_declared_hidden` and `test_workspace_only_ability_refuses_outside_a_turn`. - `Read_Content_BodiesTest`: `test_raw_returns_stored_markup_to_an_editor_of_the_post`, `test_raw_is_withheld_from_a_user_who_can_only_read_the_post` and `test_raw_is_off_by_default`. - **e2e (Chromium):** all `tests/e2e/specs/experiments/ai-workspace*` specs, 135 passed at 4f6931b. They were run with this branch merged into #1315, because this PR's own test site holds the live-check data. - New `ai-workspace-update-proposals.spec.ts` (8 tests): current next to new, plus editing; the server's message on an invalid edit; a second page after approving; approving in a second page while the first is still writing; a stale field; deselecting one of three changes; a reopened discarded proposal; the tagline. - New `ai-workspace-html.spec.ts` for the content renderer. It covers every element shown as plain text instead of rendered, and the notice naming blocks whose settings a content change alters. - From the second review round: "an approval whose answer is lost after it wrote shows what was applied" and "discarding a change another page already applied shows what was applied". - **Test-first:** tests written before their change failed before it. - **Other checks:** PHPStan finds no errors. phpcs is clean on the changed plugin PHP. tsc, lint-js and the build are clean. - **Live check with a real provider** (on a separate test site, not the demo one), one 19-turn chat: 7 proposals and 9 changes approved, all reported as updated, none stale, locked or failed. - The site title and tagline were both changed. - A published post's title and the excerpts of the three latest posts were updated. - The same post's content was rewritten four times: separators, headings and lists added, sections filled in, the intro changed, and Ctrl to Ctrl/Cmd. After each rewrite the post was still valid block markup, with every block parsed and 6 revisions kept. Rewrites after the first one added separators were still accepted. - When asked to fill in sections it had no facts for, the assistant asked which ones to use rather than inventing them. - **Second live check** (2026-11-07, Anthropic `claude-sonnet-5`, at 4f6931b, through the workspace REST routes as an administrator): one turn and one approval per write kind, with the posts and options read straight from the database before and after. - A post title, an excerpt approved with the person's edited value in place of the model's, block content with a paragraph added, and the site title and tagline together. Each was reported as updated. - After each turn the database was unchanged. Approving changed only the field proposed (plus `post_modified`), and the edited excerpt was written as edited. - The block content kept its existing blocks byte for byte, and the new paragraph was a `wp:paragraph` block. - A second approval of the same proposal returned the stored results and wrote nothing. - **Found in that run and fixed in 36820b2:** an applied card no longer showed what the field now held. It now shows "Now: …". The tool-steps summary also said "1 steps". - **PHPUnit added in the second review round**, each failing before its fix: `test_a_stale_lock_replaced_before_the_delete_is_not_deleted`, `test_a_writer_that_throws_part_way_leaves_the_proposal_failed`, `test_discarding_while_an_approval_holds_the_lock_is_refused`, `test_an_executed_proposal_read_after_expiry_shows_its_outcome`, `test_approving_with_nothing_selected_is_refused_for_any_kind`, `test_a_post_another_hook_updates_during_the_write_keeps_its_own_columns` and `test_content_proposed_after_the_post_changed_since_it_was_read_is_refused`. **Code review, two rounds:** - **Round one** (run `20261106-154448-0faae422`): 8 reviewers and an independent validator. A bug in how the reviewer prompts were built cut off the PR's intent and the location of its diff, so each reviewer worked out the scope on its own. Its findings were checked against the code and are fixed in 25748bd: - content changes were refused for posts with image or separator blocks; - the card dropped markup that would publish; - content could only be read as stripped text; - a proposal could name the same field twice; - missing tests and a docs line. - **Round two** (run `20261106-212611-pra2rerun`): the same 8 reviewers on the full diff at 36820b2, with the intent and diff in every prompt. Each finding was reproduced or traced in the code before being fixed, rather than going through the separate validator. Fixed in 476784a to 4f6931b: - after a lost or 5xx approval response, the card said nothing was changed without checking (three reviewers found this). It now reads the proposal back and shows what was applied; - a writer that threw left the proposal executing and the lock held. It now settles as failed, keeps the partial results and tells the model; - a discard didn't take the approval lock, and could land during an approval; - two requests reclaiming a dead lock could both get it; - an applied proposal opened after its expiry showed as expired instead of showing what was applied; - discarding in a second window after the first applied said nothing was changed; - the "select at least one item to create" message was shown on update cards; - the column pin leaked into other posts written by hooks during the save; - a change to a wrapping block's settings, such as a Query Loop's arguments, was invisible in the card. The card now names those blocks; - an edit made to a post between the assistant reading it and proposing a change could be overwritten. A content change based on an older read is now refused; - one interrupted-approval path re-ticked items the person had unticked. The cross-model pass didn't run, because no model CLI from another provider is installed. ## Unapplied review findings - [ ] P2: `includes/Experiments/AI_Workspace/Propose_Post_Changes.php`: the four propose abilities repeat the same setup code (turn check, meta block, proposal envelope). A shared base would remove it. Deferred: it follows the existing pattern, and it's a refactor outside this PR's scope. - [ ] P2: `Propose_Post_Changes` and `Propose_Site_Identity` each check for a duplicate target themselves. The kind could own a target key, and the store could refuse duplicates once. Deferred: same refactor scope as above. - [ ] P2: `src/experiments/ai-workspace/utils/proposal-card.ts`: the client works out which proposal types are updates (`UPDATE_KINDS`, `SITE_FIELDS`) on its own. The server could send `is_update` and the target instead. Deferred: it changes the contract between client and server. - [x] Residual risk (fixed in 22d5d2c): `decline_proposal()` doesn't take the approval lock, so a discard can interleave with an approval that has claimed the lock but not yet saved. - [x] Residual risk (fixed in 3c4cd75): `keep_other_columns()` pins the `*_save_pre` filters for the whole `wp_update_post()` call. A `save_post` hook that writes a different post would receive this post's columns. - [ ] Residual risk: approving while the same user has the post open in the block editor passes their own post lock. A later autosave from that tab could revert the change. ## Screenshots or screencast **Post changes: each current value beside the proposed one**  **Editing a proposed value before approving**  **A tagline proposal**  **After approval: the post is updated**  **After approval: the new tagline is live**  **A field changed since the proposal is left alone and reported**  ## Changelog Entry > Added - AI Workspace can propose changes to a post's title, excerpt or content, and to the site title and tagline, applied only after approval, with current and new values shown side by side. **Post-deploy monitoring:** no additional operational monitoring is required. This is an experiment behind the AI Workspace toggle, off by default, and every write needs explicit approval. --- [](https://github.com/EveryInc/compound-engineering-plugin) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- wp-playground-preview:start --> <a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1314-de66f8c8c5056c5bac61514daa130d6d890c275d.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer"> <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" /> </a> <!-- wp-playground-preview:end --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Vrishabhsk <vrishabhsk@gmail.com>
#1315) ## What? Related: #1287 The AI Workspace assistant can now answer questions about the site itself, and point people to the right admin screen: - **"What PHP version am I running?"** It reads the site's name, tagline, language, timezone, theme and, for admins, the WordPress and PHP versions. - **"Where do I hide my site from Google?"** It answers with a link to Settings → Reading. This is the second stacked PR for #1287, on top of #1314. In a live run of #1314, the assistant proposed a new tagline and site title without being able to read the current ones ("I can't see your current site title"). This PR fixes that. ## Why? #1287's first version needs the agent to answer site questions and navigation questions directly. Before this, the workspace could read posts but nothing about the site. It also had no way to know which admin screen handles which job. ## How? **`ai/get-site-info`** returns these fields, and no others: - the site name, tagline and home URL; - the language and timezone; - the date and time formats; - the active theme, and whether it's a block theme. The WordPress and PHP versions are included only for users who can see Site Health (`view_site_health_checks`), which on multisite means super admins, as in core. It never returns the admin email, database details or the plugin list. Core's own `core/get-site-info` returns the admin email, so it joins the workspace's `NEVER_ADMITTED` list next to the environment and settings readers. **`ai/find-admin-screens`** matches a request against a curated map of 33 core admin screens on the server, using titles and keywords. There's no model call inside it. It returns up to five screens, best match first, and only screens the current user can open, as `admin_url()` links on the site's own host. - Sites and plugins can add or remove entries with the new `wpai_admin_screens` filter. A filtered entry whose path has a scheme, a leading slash or `..` is dropped. - The Site Editor is offered only on block themes, and the Customizer only on classic ones. **Both are plain read abilities.** Any logged-in user can call them, they're annotated read-only and not open-world, and they're listed over MCP like the content reads. Both join the workspace's curated tool list, because policy admission is off by default. #1250's palette ability, which makes a nested model call over the palette's own commands, stays separate. It comes with the Command Palette PR. Site-info field choices are ported from #1214's `Read_Site`, credited to @Vrishabhsk with Co-authored-by. ### Use of AI Tools AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: planning, implementing the changes and tests, and code review. I've reviewed the changes, understand them and can explain them under review. They have all been tested locally. ## Testing Instructions 1. Enable AI Workspace and connect a provider. 2. Ask "What PHP version am I running?". The assistant answers with your PHP version. 3. Ask "Where do I hide my site from Google?". The reply links Settings → Reading, and following the link opens it. 4. As an editor, call `ai/get-site-info` through the Abilities Explorer or REST. The response has no version fields. **Tests run** (all passing): - **PHPUnit, full suite:** 3325 tests on WordPress latest. - **`Get_Site_InfoTest`:** `test_administrator_gets_every_field_including_versions`, `test_editor_gets_the_fields_without_versions`, `test_manage_options_without_site_health_access_gets_no_versions`, `test_no_response_carries_admin_email_siteurl_database_or_plugins`, `test_executes_without_any_input`, `test_name_and_tagline_are_decoded`, `test_timezone_falls_back_to_the_utc_offset`, `test_logged_out_visitor_is_refused`, `test_output_schema_marks_the_versions_optional`, `test_registration_has_a_category_and_read_only_annotations`, `test_declared_to_the_model_for_administrator_and_editor_with_admission_off` and `test_listed_for_mcp`. - **`Find_Admin_ScreensTest`:** - Queries: `test_hiding_the_site_from_google_finds_reading_settings_first`, `test_stopping_spam_comments_finds_discussion_settings_first`, `test_changing_the_timezone_finds_general_settings_first`, `test_singular_and_plural_settings_match_alike`, `test_returns_at_most_five_screens` and `test_stopword_only_query_returns_an_empty_list`. - Access: `test_editor_asking_for_plugins_gets_no_plugins_or_settings_screen`, `test_filter_added_screen_appears_only_for_users_with_its_capability`, `test_filter_can_remove_a_core_screen` and `test_every_url_is_on_the_admin_host`. - Themes and matching: `test_block_theme_offers_the_site_editor_not_the_customizer`, `test_classic_theme_offers_the_customizer_not_the_site_editor` and `test_stem_is_idempotent_for_every_word_in_the_map`. - Registration: `test_logged_out_visitor_is_refused`, `test_registration_has_a_category_and_read_only_annotations`, `test_declared_to_the_model_for_administrator_and_editor_with_admission_off` and `test_listed_for_mcp`. - **`Tool_PolicyTest`:** `test_core_get_site_info_is_withheld_with_perfect_annotations`. It failed before `core/get-site-info` was added to `NEVER_ADMITTED`. - **e2e (Chromium):** all `tests/e2e/specs/experiments/ai-workspace*` specs, 126 passed. That includes the new `ai-workspace-navigate.spec.ts`: asking where to change the timezone links Settings → General, and the link opens it. - **Test-first:** tests written before their change failed before it. - **Other checks:** PHPStan finds no errors, phpcs is clean on the changed plugin PHP, and the build passes. - **Not run yet:** a live check against a real provider. **Code review:** six reviewers ran: correctness, security, adversarial, testing, maintainability and agent-native. The orchestrator then reproduced each finding on a test site, instead of running the skill's separate validator. Four reviewers found nothing. The confirmed findings are fixed in 21cf902: - a call with no input failed; - the name and tagline came back HTML-escaped; - the versions were visible to sub-site admins on multisite; - the screen matcher missed singular words; - the theme branch had no test. ## Known limits - An entry a plugin adds through `wpai_admin_screens` is trusted to name the capability its screen needs. A weaker capability gives users a link they can't open. It never gives a link off the site's host. - Keywords are English only. A query in another language matches only the translated screen titles. - The navigation e2e test's link comes from the mocked model reply, so it proves the tool round trip and the link working, while the ranking itself is covered by `Find_Admin_ScreensTest`. ## Screenshots **Asking where to change the timezone links Settings → General**  ## Changelog Entry > Added - AI Workspace can answer questions about the site (name, tagline, theme, and WordPress and PHP versions for admins) and link to the admin screen for a request. **Post-deploy monitoring:** no additional operational monitoring is required. This is an experiment behind the AI Workspace toggle, off by default, and it adds read-only abilities. --- [](https://github.com/EveryInc/compound-engineering-plugin) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- wp-playground-preview:start --> <a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1315-2113f328ff63bca3163299767db00d0699313222.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer"> <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" /> </a> <!-- wp-playground-preview:end --> --------- Co-authored-by: Vrishabhsk <vrishabhsk@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ase, Wapuu busy states (#1317) ## What? Related: #1287 The AI Workspace gains an audit trail, personal-data export and erase, and Wapuu busy states: - **One audit trail.** Every agent event is one `agent` row in the AI Request Log and one call of a new `wpai_agent_event` action. Events are tool calls (including withheld ones), each item an approval writes, and each step in a proposal's life: created, edited, declined, expired, failed, or refused because its chat was deleted. The action fires even when AI Request Logging is off. - **Chats are personal data.** Tools → Export Personal Data includes the person's saved chats, and Tools → Erase Personal Data deletes them. This works with the experiment off. - **Wapuu.** While a turn runs, the transcript shows a working Wapuu instead of a spinner, then a celebrating one for a moment when the turn finishes, or an oops one next to an error. This is the fourth stacked PR for #1287, on top of #1316, #1315 and #1314. ## Why? #1287 asks that a site owner can see everything the agent did, was asked and was refused, in one place, and that audit plugins can hook it. Before this, workspace rows were mixed in with every other `ability` row, proposal events weren't logged at all, and nothing fired with logging off. Saved chats are personal data that core's export and erase tools didn't know about. And Jeff posted a Wapuu set on #1287 so a long turn looks busy rather than stuck. ## How? **`Agent_Audit`** is the one place agent events are recorded. - It fires `wpai_agent_event( $operation, $status, $context, $error )`, then writes the row through `log_ai_request()` with the new `agent` type. - The two existing log calls, for tool calls in `Turn_Runner` and for written items in `Proposal_Writes`, now go through it. Proposal events are recorded in `Proposal_Store` and `Proposal_Controller`: - created, when a proposal is stored; - edited, when an approval carries edits, naming the edited items; - declined; - expired, once, when an expired proposal is next read, since it's deleted then; - failed, when a write throws or is interrupted for longer than the approval lock; - refused, when an approval comes after its chat was deleted. - Context names the conversation, the proposal and its item keys, the post and field, or the option. It never carries post content or option values. - The hook covers agent turns and approvals only. A direct MCP call to an ability doesn't fire it. Docs say so. - The log screen gains the `denied` status, ported from #1214, and agent rows are labelled "Agent". Rows logged before this keep the `ability` type. - #1214's `wp_after_execute_ability` listener isn't ported: `Turn_Runner` already logs each call, so it would log them twice. **`Conversation_Privacy`** registers an "AI chats" exporter and eraser. - They're hooked from `Main`, next to the chat ownership filter, so they work while the experiment is off. - The export has one item per chat: name, created and updated dates, whether it's archived, and each turn's message and reply. Tool results are left out. It pages at 20 chats. - The eraser deletes all the person's chats. - Chat IDs are read straight from the posts table, as the user-deletion cleanup already does, so archived chats are found even while their status isn't registered. That reader is now shared, as `Conversation_Store::chat_ids()`. - A proposal from an erased chat can't be approved, because an approval is refused once its chat is gone. **Wapuu** sprites replace the transcript's spinner. - **Sprites:** `working` while a turn runs, `celebrating` for 1.8 seconds after one finishes, and `oops` next to an error. They come from the set @jeffpaul posted on #1287. - **Accessibility:** each sprite is an `<img alt="">`. The existing "Responding…" text and error text stay as the status. - **Reduced motion:** an SVG inside an `<img>` doesn't reliably follow the page's setting. So with reduced motion on, the component switches each sprite's animations off in its markup, which gives the same still pose. - **Scope:** only busy, done and error states ship. Per-tool sprites need streaming to know which tool is running. - **Credit:** the sprites are derived from Kazuko Kaneuchi's original Wapuu, GPL-2.0-or-later, and credited in `CREDITS.md`. ### Use of AI Tools AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: implementing the changes and tests, and code review. I've reviewed the changes, understand them and can explain them under review. They have all been tested locally. ## Testing Instructions 1. Enable AI Workspace and AI Request Logging, and connect a provider. 2. Send a message. A Wapuu shows beside "Responding…", then a celebrating Wapuu for a moment when the reply arrives. 3. Ask for a new tagline. Edit the proposed value and approve it. Ask for a draft and discard it. 4. Open Tools → AI Request Logs and filter by type `agent`. The tool calls, `proposal_created`, `proposal_edited` and `proposal_declined` rows are there, none of them with the tagline's text. 5. Tools → Export Personal Data for your own email: the download has an "AI chats" section with your chats. Erase personal data for a test user who has chats: their chats are gone. 6. With reduced motion turned on in your OS, the Wapuu is still. **Tests run** (all passing): - **PHPUnit, full suite:** 3398 tests, single site and multisite, on WordPress latest. - **`Agent_AuditTest`:** `test_agent_is_a_log_type`, `test_an_event_writes_one_row_and_fires_the_hook`, `test_the_hook_fires_with_logging_off`, `test_a_proposal_event_names_the_proposal_and_its_items_only` and `test_a_proposal_without_a_kind_is_recorded_as_drafts`. - **`Proposal_ControllerTest`:** `test_each_proposal_event_is_recorded_once_in_order`, `test_events_fire_the_hook_with_logging_off`, `test_an_expired_proposal_is_recorded_once`, `test_an_expired_proposal_read_through_the_store_is_recorded_once`, `test_an_interrupted_write_is_recorded_failed_once`, `test_a_writer_that_throws_is_recorded_failed` and `test_an_approval_for_a_deleted_chat_is_recorded_denied`. - **`Turn_ControllerTest`:** `test_a_turn_records_a_withheld_call_and_a_proposal_in_order`, and `test_every_tool_call_writes_exactly_one_log_row` updated for the `agent` type. - **`Post_Field_ProposalTest`:** `test_a_content_update_records_the_field_not_the_content`. - **`AI_Request_Log_ControllerTest`:** `test_get_logs_filters_agent_rows_by_type_and_denied_status`. - **`Conversation_PrivacyTest`:** `test_the_exporter_and_eraser_are_registered_without_the_experiment`, `test_export_returns_every_chat_with_its_prompts_and_replies`, `test_export_with_the_experiment_off_includes_archived_chats`, `test_export_pages_at_twenty_chats`, `test_erase_removes_the_persons_chats_only`, `test_a_proposal_in_an_erased_chat_cannot_be_approved` and `test_an_unknown_email_exports_and_erases_nothing`. - **e2e (Chromium):** all `ai-workspace*` specs, the palette spec and the request-log spec, 168 passed in one run on a fresh site. That includes the new "AI Workspace Wapuu" tests in `ai-workspace.spec.js`: a running turn shows the busy Wapuu beside "Responding…"; with reduced motion the busy Wapuu is a still frame; a failed turn shows the error Wapuu with the error; a finished turn shows the done Wapuu briefly. Each Wapuu test also ran three more times, 12 of 12 passing. - **Test-first:** the audit tests failed before `Agent_Audit` existed. The privacy tests were written before `Conversation_Privacy` but first run after it, so they have no recorded red run. - **Other checks:** PHPStan finds no errors, phpcs is clean on the changed plugin PHP, and tsc, lint-js and the build are clean. Style lint reports errors in `ai-request-logs/index.scss` and `ai-workspace/index.scss` that are already on the base branch. - **Live check:** core's exporter and eraser lists include "AI chats" on a running site, and the screenshots below come from one. - **Not run yet:** a live check against a real provider, and the PHPUnit suite on WordPress trunk. **Code review:** seven reviewers ran on this PR's own diff (correctness, security, adversarial, testing, maintainability, frontend races and API contract), plus an independent validator. The verdict was "Ready to merge" with no actionable findings. The one candidate, that the status filter rejects `skipped`, was rejected because it's already on the base branch. Applied afterwards in eef886a: agent rows were labelled "Text" on the log screen, a docblock still said these rows use the `ability` type, and the store's expiry path had no test. **One test from #1316 hardened** (1060833): its short palette search for "q" matched "AI Request Logs" whenever AI Request Logging was on, which the request-log spec leaves on when both run in one session. It now searches for "~". ## Screenshots **A running turn**  **A finished turn**  **A failed turn**  **Agent events in the AI Request Log**  **AI chats in a personal-data export**  ## Known limits - After an erase, a pending proposal from an erased chat can still be read by its owner, though not approved, until it expires (about 90 minutes). - "Recorded once" for an expired or interrupted proposal holds for requests that run one after another. Two requests reading the same proposal at the same instant can each record it. - A `wpai_agent_event` listener that throws during an approval write marks the proposal failed, as any WordPress hook would. The hook isn't wrapped. - The log screen's status filter doesn't accept `skipped`, which item rows have used since before this PR. - Workspace rows written after this are `agent`, not `ability`, so a view filtered to `ability` no longer shows them. ## Changelog Entry > Added - AI Workspace records every agent tool call and proposal event in the AI Request Log under an `agent` type, with a `wpai_agent_event` hook that fires even when logging is off; saved chats are included in personal-data export and erase; and a Wapuu shows while a turn runs, finishes or fails. **Post-deploy monitoring:** no additional operational monitoring is required. This is an experiment behind the AI Workspace toggle, off by default. The exporter and eraser run only when an administrator processes a personal-data request. --- [](https://github.com/EveryInc/compound-engineering-plugin) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- wp-playground-preview:start --> <a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1317-77686452fbd3e34a0cb582c18648d7667c78a603.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer"> <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" /> </a> <!-- wp-playground-preview:end --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
## What? Related: #1287 The docs pass for the #1287 stack. AI Workspace keeps its name and is documented as the plugin's one agent. The experiment doc, `readme.txt`, `README.md`, the changelog and the settings card now describe what #1314 to #1317 added. No code paths change. This is the fifth and last stacked PR for #1287, on top of #1317, #1316, #1315 and #1314. ## Why? #1287 folds two planned experiments into AI Workspace: Site Agent (#1214) and Command Palette AI Search (#1250). A reader of the docs, readme or changelog should learn that from them. Before this, the settings card and readme still described a workspace that only creates drafts and templates. The changelog had nothing for the write, palette, audit, privacy or Wapuu changes, `README.md` had no AI Workspace entry at all, and "Site Agent" was still listed under Coming Soon. ## How? - **`docs/experiments/ai-workspace.md`** - The summary and key features cover changes to existing content, site answers and screen links, the chats panel, the Wapuu, the audit log and personal-data export. - A new "One agent" section says what Site Agent and Command Palette AI Search proposed and where each now lives. It also says that the name, menu, URL and every identifier, including the experiment ID `ai-workspace`, are unchanged. - The entry-points list names every ability the experiment registers, and `Conversation_Privacy`. - A stale limitation is removed. It said chats have no history screen, but the chats panel ships. - **`readme.txt` and `CHANGELOG.md`** - Added: changes to existing content, the palette's AI search and Ask AI, the `agent` log rows, chats in export and erase, and the Wapuu. - Developer: `wpai_agent_event`, the two new proposal filters, the MCP visibility change, `raw: true`, and the `ability` to `agent` log type change. - `CHANGELOG.md` also gains the two ability lines #1315 added only to `readme.txt`. - **`README.md`:** adds the missing AI Workspace entry. - **Both readme files:** "Site Agent" leaves Coming Soon. - **Settings card:** the AI Workspace description says it answers site questions, proposes changes to posts and the site title and tagline, and adds AI to the command palette. The name stays "AI Workspace". Nothing on #1287 has settled on another name. ### Use of AI Tools AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: writing the documentation and changelog entries, checking them against the code, and code review. I've reviewed the changes, understand them and can explain them under review. They have all been tested locally. ## Testing Instructions 1. Open Settings → AI. The AI Workspace card reads as in the screenshot below. 2. Read `docs/experiments/ai-workspace.md` → "One agent", and the Unreleased changelog in `readme.txt` and `CHANGELOG.md`. **Tests run** (all passing): - **PHPUnit, full suite:** 3398 tests, single site and multisite, on WordPress latest. Only the settings-card string is code, and no test asserts it. - **Other checks:** phpcs and `php -l` are clean on `AI_Workspace.php`. - **Name check:** a grep for "Site Agent" and "Wordspace" across `includes/`, `src/` and the built assets finds nothing user-visible. - **Claims checked against the code:** - the abilities `AI_Workspace::register()` registers; - `meta.mcp.public` false on the propose and ask-user abilities; - the `wpai_workspace_write_proposals_enabled` and `wpai_workspace_proposal_kinds` filters; - `raw` on `ai/read-content-bodies`; - the chats panel's rename, archive and delete actions; - the three in-page anchors the doc links to. - **Not run:** e2e. No script, style or behavior changes. **Code review:** `ce-code-review` sized this diff to a single-context review: 51 changed lines, two of them code. It found nothing and gave "Ready to merge". Its one residual is applied in 0b06540: the doc's feature bullet now says rows are written while AI Request Logging is on. ## Screenshots **The settings card**  ## Known limits - The changelog lines for #1314, #1316 and #1317 are added here rather than in those PRs, so they land only when this one merges after them. ## Changelog Entry > Changed - AI Workspace is documented as the plugin's one agent: it now includes what the Site Agent and Command Palette AI Search proposals planned, under its existing name. **Post-deploy monitoring:** no additional operational monitoring is required. Documentation and one settings-card string. --- [](https://github.com/EveryInc/compound-engineering-plugin) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- wp-playground-preview:start --> <a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1318-aa0faf515572fcec68b35f0b8a0634d387875fd1.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer"> <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" /> </a> <!-- wp-playground-preview:end --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing in favor of #1004, thanks for the work here @Vrishabhsk and note you'll be credited as 1004 merges/releases. |










What?
Closes #189
Adds an opt-in Site Agent experiment under Tools → Site Agent that maps natural-language requests to reviewed WordPress Abilities, with approval-gated writes and an audit trail.
Why?
Issue #189 asks for a conversational admin agent that can perform WordPress actions with strong security, permissions, and auditability from the start, and that is opt-in and disabled by default.
This PR takes an abilities-first approach. Instead of describing every action twice (once as a REST resource table, once as a custom action class), the agent uses ordinary WordPress Abilities as the action layer. Each action keeps its own input schema, permission callback, validation, and execution hook. The agent adds only three things:
This keeps the implementation substantially smaller than the earlier draft while preserving the security properties in the issue.
How?
Experiment and gates
Site_Agentregisters the screen, REST routes, abilities, and audit listener only when the experiment is enabled.false.manage_optionsby default; sites can narrow or lower this withwpai_site_agent_capability.Abilities as actions
ai/site-agent-read-siteai/site-agent-create-draftedit_posts/edit_pagesai/site-agent-update-postedit_postai/site-agent-update-settingmanage_optionsRead sections use their own capability (
manage_options,edit_posts,edit_pages,activate_plugins) and filter object reads throughread_post. The settings section never exposes URLs, email addresses, roles, or arbitrary options.Proposal and approval flow
readonly => trueruns immediately.check_permissions()with the stored arguments.$ability->execute( $stored_args )as the current user. WordPress validates the input, sanitizes it, checks permissions again, and fires its hooks.Proposals are single-use and expire after 30 minutes. Conversations expire after two hours.
Audit
wp_after_execute_ability.site_agentlog type, with the ability name as the operation and the phase in context.wpai_site_agent_action.UI
What is intentionally not included
Use of AI Tools
AI assistance: Yes
Tool(s): Ollama
Model(s): Deepseek-v4.1-flash:cloud
Used for: Initial implementation, the refactor to the abilities-first design, tests, documentation, and manual verification. The final code, tests, and security behaviour were reviewed and edited by the author.
Testing Instructions
Automated
Run the Site Agent e2e spec with the AI plugin active in the wp-env test site:
Validated locally:
1937 tests, 5537 assertions, 42 skipped.35 testsacross the abilities, agent loop, and experiment/gates.phpcsandphpstanclean for the new backend code.Manual
ai/site-agent-read-site.blogdescriptionand the exact new value. Approve and verify under Settings → General.site_agent, and confirm proposal/execute/approval/decline rows exist without content or secret values.I also tested the above end-to-end on a real WordPress 7.1.3 site with a Google connector, including the read, proposal, approve, decline, settings update, and audit paths.
Screenshots or screencast
Changelog Entry