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 #1004 +/- ##
=============================================
+ Coverage 85.59% 86.76% +1.17%
- Complexity 5091 6603 +1512
=============================================
Files 193 230 +37
Lines 18425 23475 +5050
=============================================
+ Hits 15770 20369 +4599
- Misses 2655 3106 +451
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:
|
|
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:
|
|
@whyisjake we'll likely want the streaming PR in the PHP AI client into a tagged release there as a precursor to this PR (and perhaps something in the Requests library as well?), so if you could help on those upstream effort(s) and then come back to this PR that'll help keep things unblocked. |
|
Thanks @jeffpaul, agreed on the sequencing. WordPress/php-ai-client#255 is rebased and mergeable and is waiting on @JasonTheAdams's review. The streaming subset vendored here is byte-identical to the current head of that PR, apart from the core-prefixed PSR imports, and the AI Workspace test suites run it under core's prefixed environment. I'll post that as a consumer review there and weigh in on the two open design questions (the opt-in streaming interface, and aborting a stream mid-way). On Requests: WP's HTTP API buffers the whole body, so this branch opens the stream with This stays a draft until WordPress/php-ai-client#255 is in a tagged release, then I'll re-vendor from trunk. |
…reen Adds a full-screen, capability-gated admin screen behind its own experiment toggle. The screen renders an app shell only; conversation behaviour, REST routes, and streaming land in later units. The capability check is layered rather than single-point: the menu entry, the asset enqueue, and the render callback each gate on manage_options, so a direct call to the render callback cannot emit the app shell or its localized data to a user without the capability. Advances R1, R2, R3, R4 (U1). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Registers ai/search-content, a bounded full-text search over the post types exposed to the Abilities API. core/read-content is exact-match only and is kept byte-similar to core's copy, so this lands as a sibling rather than a change to it. Results are filtered at execute time against the requesting user's read permission, mirroring core/read-content's permission walk including the inherited-parent chain, so every ability consumer inherits the same filtering rather than relying on the query alone. The permission callback can only gate coarsely; the row filter is the authoritative check. Two query behaviours worth noting. per_page is capped at 20 in the schema and clamped again in the callback, so the cap holds on transports that skip schema validation. perm => 'readable' is passed only for a single-post-type query: WP_Query resolves a multi-type query to the placeholder capability read_private_multiple_post_types, which no role holds, silently hiding private posts from users who can read them. Registered from the workspace experiment rather than the Custom Abilities gated collection, so the workspace always has its search tool and every other ability consumer can still reach it. Advances R12, R13 (U2). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…overlay Adds an independently-gated `streaming` feature to SDK_Overlay, alongside `embeddings`, so environments whose bundled PHP AI Client predates streaming get the streaming types from a vendored copy. A spike established what the plan had wrong. WordPress core bundles the SDK without its vendor directory, so upstream PR #255's Guzzle-based streaming transport does not apply here; core supplies its own transporter over wp_safe_remote_request. Only the SDK-level types are useful, and a WordPress streaming transporter is required regardless of whether that PR merges. Vendored files are NOT verbatim, unlike the embeddings feature. Core prefixes its PSR and Nyholm dependencies under WordPress\AiClientDependencies, so every such import is rewritten; the unprefixed names do not resolve under a WordPress bootstrap. The README records the rewrite table. PromptBuilder and AiClient are deliberately excluded. PromptBuilder is 45KB of trunk-era code and the largest drift risk against the bundled 0.3.1, and the method it adds only validates, resolves the model, and delegates. Two further candidates were trimmed as unreferenced by the kept set. The sentinel is StreamedGenerativeAiResult rather than the streaming model interface: resolve() probes with class_exists(), which returns false for interfaces, so an interface sentinel would activate the feature even where the environment already ships streaming. A new test enforces that for every feature. Streaming is not yet reachable end to end: the transport and an Anthropic model implementing the streaming interface are still missing (U12). Adds U11 (new; the plan has no unit for this work). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Makes streaming reachable in PHP. A Streaming_Http_Transporter decorates the configured transporter: non-streaming calls delegate unchanged, and a streaming request is opened through fopen() with a stream context so the body is pulled lazily and wrapped as a PSR-7 stream the SDK's SSE parser reads unmodified. Because this path bypasses wp_safe_remote_request(), it also bypasses connector approval and request logging, so both are restored explicitly. Approval mirrors Http_Guard step for step -- same Connector_Key_Index lookup, same Caller_Identifier, same Approvals_Store check, same pending-approval record -- and runs before the opener is touched. A test asserts zero calls to the opener, which is the only egress point, so "before egress" is proven rather than implied. Logging wraps the whole body in a finally, so a refused request is logged as an error too. Two honest limits are documented on the class: a streamed entry records time-to-headers, not time-to-last-byte, and carries no token counts, because those arrive inside a body that has not been read yet. The same bypass loses that function's SSRF protection, so wp_http_validate_url() is applied before connecting and CRLF is stripped from header names and values. Anthropic's stream is mapped in its own class. Its SSE uses named events rather than a single delta shape, which is why upstream PR #255 does not cover it, and tool arguments arrive as input_json_delta fragments that must be concatenated across deltas before parsing -- parsing a fragment early yields plausible but wrong arguments. Interleaved fragments from concurrent tool calls are covered. The transporter is deliberately not installed globally and nothing constructs the streaming model in production code; ordering against Logging_Http_Transporter in the registry belongs to the turn endpoint that will drive it. phpstan.neon.dist excludes the two classes that implement or extend SDK and provider symbols PHPStan cannot resolve. Verified necessary: without it the run reports 15 errors that PHPStan itself marks unignorable. This follows the existing precedent for Logging_Http_Transporter; the mapper, opener and interface stay fully analysed. Adds U12 (new; the plan has no unit for this work). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
The spike in U3 contradicted three assumptions KTD3 rested on, and its outcome added two units the plan did not contain. Brings the artifact back in line with the code so U4 is planned against what exists. - KTD3 records the corrected findings: upstream PR #255 streams via Guzzle, which core does not bundle, so a WordPress-side transport is needed either way; vendoring cannot be verbatim because core prefixes its PSR dependencies; and the guards are restorable by construction through the public transporter seam rather than bypassed. - U3 is marked complete with its outcome; U11 and U12 are added. - U2's file list pointed at the gated-abilities collection, which accepts only gated base classes and runs only when a different experiment is enabled. - U4's approach corrected on three counts found by review and confirmed in the code: the batch resolver call offers no per-call seam for provenance or logging; a null-input permission call cannot filter tools because this repo's content callbacks are input-dependent; and cancellation cannot rely on abort detection on a buffered turn. - Stop conditions and the streaming open question updated: a host that cannot stream now degrades to a buffered request instead of blocking the plan. Also adds the Anthropic provider to the wp-env configs, since Claude is the chosen provider and the environment previously loaded only Google and OpenAI. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…l loop Runs a bounded, permission-filtered, logged tool-calling conversation behind POST ai/v1/workspace/messages, with a companion cancel route. Both gate on capability independently of nonce validation. Tool selection uses a coarse, input-free capability predicate. Filtering with a null-input permission check does not work here: this repository's content permission callbacks are input-dependent and return false without a post id or slug, so that filter would deny every tool to every user including administrators. Object-level authorization stays at execute time, where WP_Ability::execute() runs the ability's own callback. The loop iterates the assistant message's function-call parts and invokes the resolver's single-call execute_ability() per call. The batch form runs every call internally and exposes no hooks, leaving no seam for the provenance envelope or for one log row per invocation. Tool results are wrapped as provenance-tagged data before returning to the model, and every invocation writes exactly one log row -- allowed, denied, and failed alike. Denials are distinguishable from failures on the indexed status column without decoding context, and context.surface discriminates workspace rows from MCP rows sharing the same ability name. Cancellation is out of band: a separate route sets a marker the loop re-reads between rounds. Client-abort detection cannot serve here because PHP observes a disconnect only after writing output, which a buffered turn never does and the strict no-output test setting forbids. The marker is written by a different request, so the read drops its cache entries first -- otherwise the loop would answer from the value cached at request start and never observe a cancel. Conversation state lives in user-scoped transients: session-lifetime, regenerable, and expiring, which matters because it accumulates retrieved private and draft post bodies. Ownership is enforced twice -- the key is derived from the user id, and the stored owner is compared again on load -- so a second user holding the same capability cannot read another's conversation. A miss is a 404 rather than a silently-new conversation. Streaming is driven through U12's transport behind a seam, and every reference to the provider-dependent model is isolated so nothing autoloads where the Anthropic plugin is absent. A transport that cannot stream on this host falls back to a buffered request rather than failing. phpstan.neon.dist excludes one small driver file whose provider parent is unresolvable; the errors are non-ignorable and the surface was deliberately isolated so the rest of the loop stays fully analysed. Advances R6, R7, R8, R9, R10, R13, R18, R20, R21 (U4). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…mission Builds the conversational surface: transcript with tool steps, prompt input with send/stop/clear, the two context scopes, and the streaming client. Server side, Stream_Responder consumes the filter seam the turn endpoint left and emits SSE frames. Model output is rendered by a restricted-subset markdown renderer rather than a parser plus sanitizer. The renderer emits a node tree, never an HTML string, and the components map nodes to elements, so dangerouslySetInnerHTML appears nowhere in the unit. Dangerous constructs are impossible to emit rather than stripped after parsing. Links get the same treatment as images, which the plan understated. Blocking images alone leaves the exfiltration path half open: a model steered by injected post content can emit a link whose destination carries retrieved private content in its query string, behind anchor text that reads as a legitimate next step. A link is live only when it resolves to http or https on this host; everything else renders as text with its destination visible. Images are inert including reference-style syntax, which is not implemented at all. Streaming asks for SSE and branches on the response content type, so a host that cannot stream renders the identical turn arriving at once with a quiet line saying so -- not an error state. Headers are sent lazily on the first delta, so a turn that never streams falls through to the ordinary JSON body. Accessibility replaces the plan's loose wording: one polite visually-hidden live region updated at sentence and paragraph boundaries and on completion, with the transcript itself no longer aria-live. Announcing every chunk was the failure mode that wording invited. Retry resends the original prompt as a new turn rather than replacing the failed one. A turn that failed mid-stream may already have run tools, and replacing it in place would hide that it ran twice -- exactly the fact a person needs once writes exist. Only errors offer retry; round-cap and cancelled turns do not, because the model ended those, not the transport. ContextScope in the TypeScript types was 'site' | 'post-type' | 'selection', which matched neither R6 nor the endpoint's enum. Reconciled to 'site' | 'general'. Known gap, commented at the call site: on the first turn of a new conversation the client does not yet know the server-minted conversation id, so Stop closes the reader locally while that round finishes server-side. Later turns cancel properly. Closing it needs the turn endpoint to publish the id early. Advances R2, R6, R8, R9, R11, R19 (U5). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…the transcript Closes a gap the transcript could not work around: the turn route returned only tool invocation records, never the results, so no post list could reach the client at all. Each tool_calls entry now carries the ability's own return value on success, and null on a denial -- a refusal is not a result. The passthrough is deliberately narrow. Nothing is re-fetched, joined, or enriched, because re-fetching post data client-side would bypass the execute-time permission filtering the whole read path rests on. A test asserts the value the client receives is identical to direct ability execution for the same user and input, so the response cannot leak more than the tool did. The client then treats it as unknown and rebuilds each row from the fields the search ability declares, so a future ability with a wider payload cannot push unexpected fields into the table. The table is chrome-free by construction rather than by configuration: composing DataViews with an explicit Layout child means search, filters, view config and pagination are never mounted, since the component renders its default UI only when given no children. Per-field flags and controlled view state back that up. The plan's instruction to copy the DataViews stylesheet in webpack was unnecessary -- the copy plugin already emits it once to a fixed path outside the entry map -- so the config is untouched and the page enqueues the existing file conditionally, mirroring the request-logs page. R14 is only half-met by this unit: rows link to the post, not to its editor. The search ability returns no edit URL and nothing client-side may invent one, so the edit action is gated on a row-supplied URL and is currently never rendered. Completing it belongs on the ability that already owns the permission walk. Advances R14 (U6). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Completes R14. The transcript table already had an edit action gated on a row-supplied URL, but no ability emitted one, so the action never rendered and rows linked only to the published post. The URL doubles as the permission proof: it is present only when the current user can edit the post, so a consumer does not re-derive the capability and cannot construct an editor URL for a post it may only read. That also avoids guessing wp-admin/post.php, which breaks on non-standard admin paths. The explicit capability check is deliberate redundancy, and the docblock says so: get_edit_post_link() already returns nothing for a user who cannot edit, and a mutation run with the gate removed left the new tests green. The gate stays because the emptiness of this field is a permission guarantee consumers rely on, and that guarantee should not rest on the internals of a core function that is free to change. The tests lock the contract rather than the mechanism. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…ally work Two bugs found by running the workspace against a real provider rather than against tests. Both were invisible because each degraded politely instead of failing. OptionEnum::FUNCTION_DECLARATIONS is not a constant. That call threw an undefined-constant Error, a catch-everything swallowed it, and the screen therefore always reported "no compatible model available" -- even though all eleven Anthropic models advertise function calling. The enum extends AbstractEnum, so the member is reached with isFunctionDeclarations(). The catch is now narrower in effect: an Error is re-thrown rather than swallowed, so a programming mistake in that method surfaces instead of presenting as a permanent, plausible-looking capability gap. An unreachable provider still degrades quietly, which is the case the catch is for. Throwable is still the caught type because the project's coding standard requires it over Exception. The streaming driver called GenerativeAiResultChunk::toText(), which does not exist -- the method is getDeltaText(). The Throwable guard turned that into "this host cannot stream", so every turn silently fell back to a buffered request and the UI truthfully reported a condition that was not true. Verified end to end afterwards: a turn now streams, and the fallback notice is gone. Only the visible delta text is emitted; getReasoningDeltaText() carries the model's thinking, which is not the reply. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…hinking signatures Two defects found by running a two-turn conversation against the real provider. The model was whichever candidate the registry happened to return first, which on a live site resolved to the most capable and most expensive model available -- selected by array position, not intent. Selection now consults an ordered preference, filterable per site, and falls through cleanly when a preferred model is absent. That accidental choice also exposed the second defect. Always-on-thinking models return thinking blocks, and Anthropic rejects a replayed thinking block whose signature is missing, so the second turn of any conversation failed with "messages.1.content.0.thinking.signature: Field required". The signature arrives as its own signature_delta after the block's thinking text, so the mapper now records which block indices opened as thinking and carries the signature onto the part it belongs to, matched by index rather than arrival order. The storage round trip was never at fault: the SDK's MessagePart already carries a thought signature and Message::fromArray()/toArray() preserve it. The loss was ours, in the mapper, on the streaming path only -- which is why no test saw it and why it took a live second turn to surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
The model can propose drafts; only a person's confirmation writes them. The proposal is persisted server-side and the confirmation renders the stored resolved values, never the model's summary of them -- that summary is attacker-influenceable, which is the reason the requirement exists. There is no registered write ability. The plan called for one kept off the MCP surface, but that is an intention without a mechanism: a registered ability is reachable by the MCP surface, the Abilities Explorer, and any third-party caller, none of which have a confirm gate. Instead the writer is a plain class reachable only from the proposal controller, so the confirm gate is a structural property of the write path rather than a validation rule someone can route around. The model's only reach is a propose ability that writes nothing, is hidden from REST and MCP, and refuses outside an active turn context. Ownership is bound, not merely capability-checked. Capability is not identity: without this, a second user holding the same capability could execute another's proposal by id, and the values they approved on screen would not be the ones written. The store derives its key from the owner, compares the stored owner again on read, and compares the conversation at execution -- three checks independent of the capability re-check at write time. Verified by mutation: with the key no longer user-scoped, the stored-owner comparison still refuses a peer, so both layers hold on their own. Set approval is bounded. Proposals cap at twenty items, matching the search tool's row bound, and items start deselected so an item appended by injected content must be chosen deliberately rather than ridden in on a batch approval. A status the user cannot publish to fails the proposal instead of being downgraded silently. Partial failure is reported per item to both the person and the model, with no auto-retry, and re-executing a confirmed proposal creates nothing. Every write attempt is logged in the shape the tool-call rows already use, so writes and reads join on one conversation. Advances R15, R16, R17, R20 (U7). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
An Options-menu action in the post editor opens the workspace with the current post in scope. It carries identity only -- post ID, status, type, title -- and never the body: the workspace reads content through the permission-checked tool path, so there is one enforcement path and nothing trusts a client-supplied body. A test asserts a marker in the post content never reaches the localized data. The seed is re-resolved server-side from the query argument and checked with read_post, so the URL cannot hand someone a post they may not read; a refusal renders an explanation rather than content. A post title is author-controlled text, so it is flattened to single spaces and clamped before it leaves PHP -- a title cannot smuggle a multi-line instruction block -- and it reaches the model only inside a message the person has seen and can edit. The composer is prefilled, never auto-sent. The residual surface is a person who sends a prefilled prompt without reading it; that is bounded to one clamped line with a human in the loop, and removing it entirely would mean not naming the post at all, which the available tools make useless. Mounted as a post-level Options-menu item rather than the block toolbar the plan named. This is a navigation action for the whole post: a block toolbar entry would either repeat on every block or be arbitrarily scoped to one block type the way content resizing is. The repository already has post-level plugin precedent. The webpack entry is part of this change. That build declares every bundle explicitly, and the asset loader bails silently on a missing asset file, so without the entry the action would never appear and nothing would report why. R5 is only half met and should not be read as complete: the handoff carries identity, but no read-full-body tool is in the workspace allowlist, so the assistant can find the post and see its excerpt while the body stays out of reach. Widening the allowlist is a security-relevant scope decision and was deliberately left alone. Advances R5, R18 (U8). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
63 of the workspace's 155 Playwright tests never opened a browser: they assert pure functions in utils/ (the markdown renderer, the proposal card, stored chats, post results, questions) and took no measurable time. Playwright still counted them when splitting the suite across CI's three shards, and it splits by test count, not time. All 63 landed on one shard, which then counted as full and finished in under five minutes, while the shards carrying the real browser tests took 13 and 17. The run waits for the slowest shard. They move to src/experiments/ai-workspace/utils/test/, beside the code they cover, and run with Vitest through wp-scripts test-unit-js, which is what @wordpress/scripts 36 uses for unit tests. CI runs them in the existing JavaScript job. The assertions are unchanged; only the imports, describe(), and relative paths differ. The HTML renderer's spec stays in Playwright. It is the boundary between markup an approver approves and markup they see, and it needs a real browser's parser, not jsdom's approximation of one. Moving them under src/ also puts them under the project's strict tsconfig, which tests/ is excluded from. That found one real gap: the proposal-card fixture built an outcome without its required value field. Adds vitest 5.1.0 and vite 8.3.5, and @types/node 24.19.2, which vitest needs (it accepts 22 or later) and which matches the Node 24 the project requires. vitest.config.ts limits the run to src/**/test/, because Vitest's default glob also matches the Playwright *.spec files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Every workspace browser test enabled the experiment by loading the AI settings
screen and checking its toggle, and disabled it afterwards the same way: two
full settings-page loads per test, 152 across the suite, none of them what the
test was about.
setExperimentEnabled() writes the same wpai_feature_{id}_enabled setting the
toggle saves, over REST, without a page. The workspace specs use it in their
setup and teardown and in the three handoff tests that switch the experiment
mid-test. Each test still turns the experiment on before it runs and off after,
so isolation is unchanged; only the route is cheaper. enableExperiment() stays
for tests where the toggle itself is the subject.
Measured locally on the branch as it stood before these two commits: the
workspace specs went from 155 tests in 3.9 minutes (231s of test time) to 92
in 1.8 minutes (107s), the 63 removed being the ones moved to Vitest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…need hundreds of lines of comments to be understandable
A batch of two or more new items now has a "Select all" checkbox, so choosing every draft no longer takes one click per item. It keeps the batch rule: it starts unchecked like every item, and it selects only draft and pending items. An item that would be published or made private is left out and still takes its own click; a note under the box says so when the batch holds one. Single items, update cards, template cards and settled proposals get no box. The server-side `selected` contract is unchanged. Tests: 4 Vitest cases for bulkSelectable(); the proposal-card e2e test now checks Select all starts unchecked, selects all three drafts and clears them; the Plan a series demo test counts the extra checkbox. Workspace e2e 92/92, Vitest 67/67, tsc and eslint clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
| 'label' => __( 'Propose Post Changes', 'ai' ), | ||
| 'description' => sprintf( | ||
| /* translators: %d: the maximum number of items a proposal may contain. */ | ||
| __( 'Records proposed changes to the title, excerpt or content of existing posts, for the person to review. This writes nothing: each item names one field of one post and its complete new value, the person sees the current value next to yours, may edit yours, and must approve before anything changes. A title is plain text with no HTML. To change content, first read the post with ai/read-content-bodies and "raw": true, then propose its complete block markup built from "content_raw", changing only what was asked and keeping every other block as it is; the plain-text body has lost its blocks and must not be used. Content that holds embeds or iframes cannot be rewritten. Propose at most %d items at a time, and never claim a post changed until you are told the outcome.', 'ai' ), |
There was a problem hiding this comment.
Another thing I'm noticing, most of these Abilities we're introducing are very specific to being used by AI within the Workspace. The Abilities API is not AI specific though, it's a higher level primitive that exposes functionality in lots of contexts, AI tool calls being just one of those. Maybe this is fine but wondering if there's a different structure we should consider here instead of just throwing these in as Abilities? Is there a way to just register these as tool calls directly instead of filtering through the Abilities API?
There was a problem hiding this comment.
I looked at registering them as direct tool declarations. The Workspace leans on what the abilities pipeline gives each call:
- input-schema validation
permission_callbackand the feature access filter- the execute hooks that stale-edit detection listens on
- the Explorer remove/restore controls
Going direct would mean rebuilding all of that for these few tools.
They're already private:
show_in_restis false andmcp.publicis false.- They refuse to run outside a Workspace turn, so another caller can't create a proposal nobody reviews.
So I kept them as abilities and moved them to includes/Abilities/AI_Workspace/ (82a7814). If you'd still rather they bypass the Abilities API, I'm happy to look at it as a follow-up.
Release notes go in the PR description and are pulled out at release time, per review. The readme feature bullet stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
The screen is registered with add_menu_page as "Workspace", so the readme, README, experiment description and docs no longer say it is under Tools. The readme bullet and description take the reviewer's suggested wording, and README names the palette row by its real label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
- Function_Calling_Support returns early without the SDK, and its docblock says the first call can hit each connector's models endpoint when there is no persistent object cache. - Drop guards that can never fire: the wp_ai_client_prompt existence check (WP 7.0.3 minimum), is_user_logged_in() before current_user_can() in the propose abilities, and the unregister-then-register checks on the plugin's own ability names. - The command palette ability builds its request once with the JSON schema instead of probing support and rebuilding without it. Tests: new Function_Calling_SupportTest; the palette test now requires a single support check (8 of 19 failed against the old code); propose abilities refuse logged-out visitors and under-capable users inside a turn. Focused PHPUnit 403 passing, PHPStan and PHPCS clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…ist-terms ai/search-content, ai/read-content-bodies, ai/get-site-info and ai/find-admin-screens now supply registration args and the feature registers them with register_feature_ability(), so they carry the ai-workspace feature tag and Workspace access control applies when they run over the Abilities REST API. Before this, an administrator the Workspace was restricted from could still run them over REST. ai/list-terms is removed, as review asked: it now lives in the Abilities package. The two starter prompts that needed term counts work from search-content instead: "Find a gap" reads recent posts, and "Write a template" builds a 404 template from the latest posts and a search box. Tests: the read abilities carry the feature meta, and a restricted administrator gets 403 wpai_feature_access_denied over REST (both failed before). Focused PHPUnit 280 passing, PHPStan and PHPCS clean, JS lint, types and unit tests clean, Workspace e2e 92/92. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
The four propose abilities and ai/ask-user move from includes/Experiments/AI_Workspace/ to includes/Abilities/AI_Workspace/ (namespace WordPress\AI\Abilities\AI_Workspace), matching where the plugin keeps every other ability. They stay abilities: still hidden from REST and MCP, still refused outside a workspace turn, and still registered by the feature. Names and behavior are unchanged. The admin screen map leaves the abilities directory's loose data file and becomes Utilities\Admin_Screens::get_screens(); the wpai_admin_screens filter applies where it did. Tests: their own tests moved alongside; imports updated everywhere. Focused PHPUnit 298 passing (1 skipped, unrelated), PHPStan clean, PHPCS clean apart from two errors already in MCP_AdapterTest on develop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
ai/command-palette-ai-search becomes ai/command-palette-search, as
review asked: the plugin avoids "AI" in names inside the AI plugin.
The class, directory, asset handle and path, localized global, loader
hook, CSS classes and keyframes, derived prompt-builder filter
(wpai_command_palette_search_prompt_builder), fixtures and specs are
renamed with it. Nothing has shipped, so there is no alias. User-facing
text ("AI suggestions", "Ask in AI Workspace") is unchanged.
Tests: palette PHPUnit 53 passing; palette and handoff e2e 22/22;
build, lint, types and unit tests clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Review found that picking "No thanks" on an assistant question sent a
full multi-turn request. A question card now has its own "Dismiss
question" button. It calls POST workspace/conversations/{id}/dismiss
with the question's turn id, which records a `dismissed` entry and
sends nothing to the model. The route uses the workspace's permission
and feature-access check, loads the chat by owner (404 otherwise), and
returns 409 when the question is no longer open. The closed card keeps
the question visible with its choices disabled, survives reopening the
chat, and is left out of the personal-data export.
On the next message the model is told, in one line, that the person
closed its previous question, so it doesn't read the message as the
answer. The question tool now accepts a single choice, and the system
instruction no longer requires every reply to end with a question or
to offer choices that only end the conversation.
Tests: dismiss route stores, conflicts, 404s and refuses without
access; the note appears only after a dismissal; single choice valid
(PHP 123 passing, 12 failed first). JS unit 75 passing. E2E: dismissing
makes no model call and focuses the composer, a conflict shows the
stored answer, a failure keeps the card live, and a dismissal survives
reload; Workspace e2e 96/96.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…nscript The transcript now scrolls to the latest reply while the person is at or near the bottom, holds its place when they have scrolled up to read, opens a reopened chat at the bottom, and jumps to the bottom when they send a message or pick a choice. Scrolling is instant and never moves focus. The composer box was width 100% plus its padding and border without border-box sizing, so it ran 26px wider than the transcript column; it now shares the column's edges. Once a chat has turns, both reserve the same scrollbar gutter. The message field gets inner padding. Tests: useStickToBottom unit tests; e2e for a tall reply staying in view, scrolling up holding position, and matching left and right edges with non-zero input padding at 1280x800 and 390x844. JS unit 81 passing; Workspace e2e 100 passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Review found the Explorer's assistant controls confusing and partly unreachable: declaration-based admission is off by default, so the policy toggle, the "eligible" state and most reason labels described a feature nobody could use, and only already-used abilities had a control. Each ability now shows one of three things: "Used by AI Workspace" with a "Remove from AI Workspace" button, "Removed from AI Workspace" with "Restore to AI Workspace", or nothing. The policy toggle and reason labels leave the UI and the REST responses, and the surface route accepts only remove and restore. A failed change shows an inline error and leaves the row as it was. Tool_Policy keeps its server-side reasons and off switch for when admission ships (#354). The docs describe what a site owner can actually do. Tests: the surface route refuses policy actions (400) and rows the Workspace does not use carry no state even with admission on (failed first); workspace.ts unit tests; Explorer PHPUnit 123 passing; JS unit 85 passing; Explorer e2e 21/21. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
…e palette rename Opening a chat and refreshing it after a dismiss conflict now use one readChat() helper instead of two copies of the same request. Comments still naming the command palette "AI search" now match the rename. No behavior change. Tests: JS lint, types, unit 85 passing; Workspace and palette e2e 112/112. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
- A message sent while a dismissal request was in flight could be saved over by the dismissal, or have the dismissed entry appended after it so a question the new turn asked showed as dismissed. The composer is now busy for that request; a follow-up that starts meanwhile reloads the stored chat instead of appending out of order. Focus returns to the composer once it is enabled again. - After a dismissal, answering a question a later follow-up asked no longer tells the model its question was closed unanswered. - open() gets its docblock back. Tests: new Turn_Runner cases for an answered follow-up question (failed first), a follow-up that asks nothing, and no repeat on later turns; Turn_RunnerTest 16 passing; JS unit 85 passing; Workspace e2e 99 passing plus the focus test, fixed after, with the tools and history specs re-run (29/29). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
From an independent review by a second model family: - The dismiss route saved the whole chat it had read, so a turn, proposal outcome or owed follow-up saved in between was erased. Conversation_Store::append_entry() rereads the stored entries and writes only them; the route uses it. - A question saved without its turn ID no longer shows a Dismiss button that could never work. - Stop stays disabled while a dismissal is in flight; the composer takes a separate isBusy flag instead of overloading isRunning. Tests: append_entry keeps messages, follow-up state and newer entries another writer saved, and refuses another user's chat (both errored before). Workspace PHPUnit 71 passing, PHPStan and PHPCS clean, JS unit 85 passing, Workspace e2e 100/100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
|
Thanks for testing. All three are fixed:
While doing this I also found that the Workspace's read abilities were registered outside the feature, so an administrator the Workspace was restricted from could still run them over REST. They now go through |
Conflicts were only in package.json and package-lock.json. package.json keeps develop's --wp-env-config flag on the e2e scripts and this branch's test:unit script and dev dependencies; the lockfile was regenerated from develop's with npm install. Checked after the merge: npm run test:unit (85 passing), typecheck, lint:js and build. PHP and e2e suites were not re-run on the merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
Feature access is enforced through the wp_ability_permission_result filter, which core only has from 7.1. Abstract_Ability back-fills it for its own subclasses, but an ability registered through register_feature_ability() from plain args (the Workspace's read abilities since they moved to the feature) skipped it, so on WordPress 7.0.x an administrator left out of the AI Workspace could still run ai/search-content over REST. CI caught it on the WP 7.0.4 jobs. register_feature_ability() now wraps the permission callback of such an ability on WordPress < 7.1 so the same filter runs. Abstract_Ability subclasses are left alone, since they already apply it. Tests: new AI_WorkspaceTest case pins WordPress 7.0.4 and checks the read ability's own permission callback refuses the excluded administrator (failed before). AI_Workspace, Feature_Access and Feature_Ability_Registration tests passing; PHPStan and PHPCS clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L
|
Thanks for all the work on this! Would it make sense to review and merge #1394 before merging this into The PR is up to date with |
|
Thanks for putting #1394 together, and for keeping it up to date with This branch already adds a "Select all" control to the proposal card, in 1861f32. It's a single checkbox that shows a partial state when only some items are checked. Unchecking it clears them again, so it covers "Select none" too. The main difference from #1394 is that ours never bulk-selects an item that would be published or made private. Those items stay out of "Select all", and a note under the checkbox tells people to check them one at a time. Publishing or changing visibility affects the live site, so we didn't want one click to approve it. Both PRs rewrite the same part of |
|
Thanks for the guidance, @whyisjake! I’ve narrowed this PR #1394 to build on the existing checkbox with three improvements:
I have attached an updated screencast showing the changes. Can you please take a look when you have a chance, I’d appreciate your feedback! Screen.Recording.2026-11-24.at.5.10.20.PM.mov |
Implements #282. Closes #1379.
A full-screen conversational admin screen where a site owner talks to an AI about their own site. It reads content under their own capabilities, never above them, and changes nothing until they approve it.
What this adds
A new
ai-workspaceexperiment with its own top-level Workspace admin menu (manage_options, plus per-role access controls). It is built on the Abilities API and core's ability-backed tool loop.A turn endpoint and tool loop. Each function call runs through the resolver's single-call
execute_ability(), so every invocation, including a denial, produces exactly one log row.Four read abilities, registered through the feature so its access controls apply on every surface:
ai/search-content: full-text search; titles and excerpts only.ai/read-content-bodies: full bodies for up to five posts by ID.ai/get-site-info: site details, without the admin email, database or plugin list.ai/find-admin-screens: links to matching admin screens the user can open.Rows are filtered per user at execute time.
Propose-then-approve writes. The model can propose new drafts, a block template, changes to a post's title, excerpt or content, and the site title or tagline. Nothing is written until the person approves the stored values. Batches start unchecked and have a "Select all" that skips anything that would publish or go private.
Questions with a dismiss control. The assistant can ask with one to five choices. The person can answer, type a reply, or dismiss the question without a model call.
Saved chats with history, archive, rename and delete, included in personal data export and erasure.
Command Palette integration. AI suggestions when a search finds nothing, and "Ask in AI Workspace: ".
A block editor handoff that opens the workspace naming the current post. It never sends the post body; the assistant reads that through a permission-checked tool.
Abilities Explorer integration. It shows which abilities the AI Workspace uses, with the description it is given, and lets a site owner remove or restore one.
Notes for review
Permission filtering is execute-time, not declaration-time. The capability on a tool decides whether it is declared to the model. Which rows come back is decided per row, per user, on every call.
Withheld counts are measured, not derived.
total - count(results)would mix pagination with permission filtering.ai/search-contentcounts what the permission walk drops from the page it builds.ai/read-content-bodiesreports no count, so it can't be used to learn whether a named post exists.The Workspace-only tools are private abilities. The propose tools and
ai/ask-usersetshow_in_restandmcp.publicto false, and refuse to run outside a workspace turn. They stay abilities so they keep schema validation, permission checks, the access-control filter and the Explorer controls.The tool surface is a floor plus an off-by-default policy. The floor is the four read abilities plus the proposal and question tools (
Tool_Selector::DEFAULT_CANDIDATES). Declaration-based admission of other abilities exists, but stays off until #354 settles the channel name. Every ability the model can call is also reachable by an instruction embedded in content someone else wrote, which is why the surface is narrow.Streaming is a follow-up (#1083)
Provider streaming depended on WordPress/php-ai-client#255, which is not merged or released, so this PR used to carry a vendored copy of that PR's streaming classes. It no longer does. Streaming now lives in #1083, stacked on this PR, as a single commit that reverts its removal. It can merge once #255 is released and re-vendored from that release.
What that means for this PR:
publicmeta flag from WordPress 7.1.embeddingsfiles already ondevelopunderincludes/Vendor/AiClient/are unchanged; the streaming overlay entry and its classes are gone.Testing
Run locally on this branch:
npm run test:php: 3,422 tests, 12,217 assertions, 58 skipped on 45b1693; multisite also 3,422 tests. Three MCP Adapter install tests failed because the e2e suite had left a plugin on the shared test site. With it removed, those tests pass (36 tests).npm run test:e2e: 391 passed on 45b1693 (16.9 min locally, one worker), against mocked providers. No network access.npm run test:unit(85 Vitest tests).npm run lint:php(PHPCS) andnpm run lint:php:stan(PHPStan): clean.npm run build,npm run typecheck,npm run lint:js: clean.Test suites executed by name, as the WordPress AI Guidelines require:
PHPUnit (
tests/Integration/):AI_WorkspaceTest,Admin_PageTest,Agent_AuditTest,Ask_UserTest,Command_PaletteTest,Command_Palette_SearchTest,Conversation_ControllerTest,Conversation_PrivacyTest,Conversation_StoreTest,Find_Admin_ScreensTest,Function_Calling_SupportTest,Get_Site_InfoTest,Post_Field_ProposalTest,Prompt_Model_ClientTest,Proposal_ControllerTest,Proposal_StoreTest,Propose_DraftsTest,Read_Content_BodiesTest,Search_ContentTest,Search_Content_RestTest,Site_Identity_ProposalTest,Template_ProposalTest,Tool_PolicyTest,Tool_SelectorTest,Turn_ControllerTest,Turn_RunnerTest,Abilities_ControllerTest.Playwright (
tests/e2e/specs/experiments/): everyai-workspace*spec,command-palette-search.spec.js,abilities-explorer.spec.js,abilities-explorer-surface.spec.js.Vitest (
src/**/test/):chat.test.ts,post-results.test.ts,proposal-card.test.ts,question.test.ts,render-markdown.test.ts,useStickToBottom.test.ts,workspace.test.ts.When first submitted, the security-relevant read tests were verified by mutation. Forcing
Read_Content_Bodies::check_read_permission()open and removing its clamp failed five tests. Replacing the withheld count with subtraction failedtest_retrieval_summary_never_counts_paginated_rows_as_withheld.Still open
search-contentandread-content-bodiesexist alongsidecore/content-query.Changelog
Added
ai/search-content(full-text search returning excerpts),ai/read-content-bodies(up to five posts by ID),ai/get-site-info(site details without admin email, database or plugin list) andai/find-admin-screens(links to matching admin screens the user can open, filterable throughwpai_admin_screens).agenttype, with adeniedstatus. No row records post content or option values.Developer
wpai_workspace_tool_candidates,wpai_workspace_max_rounds,wpai_workspace_system_instruction,wpai_workspace_stream_emitter,wpai_has_function_calling_support,wpai_workspace_write_proposals_enabled,wpai_workspace_proposal_kinds,wpai_workspace_withheld_abilitiesandwpai_admin_screens.wpai_agent_eventaction, fired for every Workspace agent event.wpai_workspace_tool_admission_enabledor theWPAI_WORKSPACE_TOOL_ADMISSIONconstant turns it on to try it.ai/propose-*,ai/ask-user) are not exposed over REST or MCP and refuse to run outside a Workspace turn.AI assistance: Yes. Tool(s): Claude Code (Opus 5). Used for: implementation of all units in the linked plan, test authoring including the mutation testing described above, and this description.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BRSJEyQyYp3XTeum8fiq3L