Conversation
wp ai is-supported command
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds a new wp ai is-supported WP-CLI subcommand intended to expose WordPress 7.0’s wp_supports_ai() check, and updates existing AI commands/tests to handle “AI disabled” flows more cleanly.
Changes:
- Introduces
wp ai is-supportedsubcommand inAI_Command. - Adds/adjusts disabled-AI handling in
generate,check, andstatuspaths (including handlingWP_Errorreturns). - Adds Behat coverage for the new command and for generate behavior when AI is disabled; updates command registration list.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/AI_Command.php |
Adds the new is-supported subcommand; adds AI-support gating and WP_Error handling; tweaks image --stdout handling. |
features/is-supported.feature |
New Behat feature for wp ai is-supported (default, filter-disabled, pre-7.0). |
features/generate.feature |
Adds scenario for disabled-AI generate; expands mock provider to support image generation and updates expected outputs. |
composer.json |
Registers ai is-supported in the package command list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @require-wp-7.0 | ||
| Scenario: AI is supported by default | ||
| When I run `wp ai is-supported` | ||
| Then the return code should be 0 |
There was a problem hiding this comment.
The “AI is supported by default” scenario only asserts the exit code. Since this PR is introducing a user-facing command, it would be good to also assert the expected success output (to prevent regressions where the command stays silent).
| Then the return code should be 0 | |
| Then the return code should be 0 | |
| And STDOUT should contain: | |
| """ | |
| AI is supported | |
| """ |
| """ | ||
|
|
||
| When I try `wp ai is-supported` | ||
| Then the return code should be 1 |
There was a problem hiding this comment.
The “AI is not supported when disabled via filter” scenario only checks the exit code. To validate the new behavior end-to-end, add an assertion for the expected error message on STDERR (per the PR description/example).
| Then the return code should be 1 | |
| Then the return code should be 1 | |
| And STDERR should contain: | |
| """ | |
| Error: AI is not supported when disabled via filter. | |
| """ |
| @require-wp-7.0 | ||
| Scenario: Generates text using mock provider | ||
| When I run `wp ai status` | ||
| Then STDOUT should be a table containing rows: | ||
| | capability | supported | | ||
| | Text Generation | Yes | | ||
| | Image Generation | Yes | | ||
|
|
||
| @require-wp-7.0 | ||
| Scenario: Generates text using mock provider | ||
| When I run `wp ai generate text "Test prompt"` | ||
| Then STDOUT should be: |
There was a problem hiding this comment.
There are two scenarios named “Generates text using mock provider”, but they test different behavior (wp ai status vs wp ai generate text). Renaming one of them would make failures easier to interpret and keep the feature file clearer.
| WP_CLI::halt( 0 ); | ||
| } else { | ||
| WP_CLI::halt( 1 ); |
There was a problem hiding this comment.
is_supported() currently only halts with an exit code and produces no user-facing output. This conflicts with the command’s docblock example and the PR description (which show Success:/Error: messaging). Consider printing a success message when supported and using WP_CLI::error() (or equivalent) with a clear message when unsupported, while preserving the intended exit codes.
| WP_CLI::halt( 0 ); | |
| } else { | |
| WP_CLI::halt( 1 ); | |
| WP_CLI::success( 'AI features are supported.' ); | |
| } else { | |
| WP_CLI::error( 'AI features are not supported in this environment.' ); |
| Given a WP install | ||
|
|
||
| @less-than-wp-7.0 | ||
| Scenario: Command not available on WP < 7.0 |
There was a problem hiding this comment.
The WP < 7.0 scenario name is misleading: the command is registered, but execution fails due to the package-level WordPress version guard ("Requires WordPress 7.0 or greater."). Consider renaming this scenario to reflect the actual behavior (e.g., "Errors on WP < 7.0").
| Scenario: Command not available on WP < 7.0 | |
| Scenario: Errors on WP < 7.0 |
WordPress 7.0 introduces
wp_supports_ai()— allowing hosts/plugins to disable AI features via theWP_AI_SUPPORTconstant orwp_supports_aifilter. This adds a CLI command to expose that check and test coverage for the disabled-AI code paths.Changes
wp ai is-supportedcommand — callswp_supports_ai(), exits 0 if supported, 1 if notWP_Errorhandling ingenerate,check,status—wp_ai_client_prompt()returns aWP_Error(codeprompt_prevented) when AI is disabled; these methods now surface that error cleanlyfeatures/is-supported.feature— scenarios for default (supported), filter-disabled, and pre-7.0 casesfeatures/generate.feature— scenario verifyingwp ai generatefails gracefully when AI is disabled via filtercomposer.json— registersai is-supportedin the commands list📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.