This repository was archived by the owner on Mar 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Leverage WP AI Client #73
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
50bf779
Initial plan
Copilot 818b905
Add WP AI Client support with credentials management
Copilot c195bc1
Improve backward compatibility and add tests
Copilot f807a05
Address code review feedback
Copilot ca652fc
Remove AI Services backward compatibility, use only WP AI Client
Copilot 9bd9edc
WIP: Fix composer install and remove MCP code
pwtyler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # WP-CLI AI Command | ||
|
|
||
| A WP-CLI package that enables AI interactions with WordPress via the Model Context Protocol (MCP). | ||
|
|
||
| ## Project Overview | ||
|
|
||
| - **Type**: WP-CLI package | ||
| - **PHP Version**: 8.2+ | ||
| - **Namespace**: `McpWp\AiCommand` | ||
| - **License**: Apache-2.0 | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| src/ | ||
| ├── AI/ # AI client implementations (WpAiClient, AiClient) | ||
| ├── MCP/ # MCP protocol implementation | ||
| │ ├── Servers/ # MCP servers (WP_CLI tools) | ||
| │ └── Client.php # MCP client | ||
| ├── Utils/ # Utilities (logging, config) | ||
| ├── AiCommand.php # Main `wp ai` command | ||
| ├── CredentialsCommand.php # `wp ai credentials` subcommand | ||
| ├── McpCommand.php # `wp mcp` command | ||
| └── McpServerCommand.php # `wp mcp server` subcommand | ||
| ``` | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ```bash | ||
| # Run all tests | ||
| composer test | ||
|
|
||
| # Individual test suites | ||
| composer phpunit # PHPUnit tests | ||
| composer behat # Behat integration tests | ||
| composer phpcs # Code style checks | ||
| composer phpstan # Static analysis | ||
| composer lint # Linter | ||
|
|
||
| # Fix code style | ||
| composer format # or: composer phpcbf | ||
|
|
||
| # Prepare test environment | ||
| composer prepare-tests | ||
| ``` | ||
|
|
||
| ## Code Style | ||
|
|
||
| - Uses WP_CLI_CS ruleset (WordPress coding standards) | ||
| - Global namespace prefix: `McpWp\AiCommand` (classes) or `ai_command` (functions/variables) | ||
| - Run `composer format` to auto-fix style issues | ||
|
|
||
| ## Key Dependencies | ||
|
|
||
| - `logiscape/mcp-sdk-php`: MCP SDK for PHP | ||
| - `mcp-wp/mcp-server`: MCP server implementation | ||
| - `wp-cli/wp-cli`: WP-CLI framework | ||
| - `wordpress/wp-ai-client`: WordPress AI client (dev dependency for testing) | ||
|
|
||
| ## WP-CLI Commands | ||
|
|
||
| - `wp ai` - Main AI interaction command | ||
| - `wp ai credentials list|set|delete` - Manage AI provider API keys | ||
| - `wp mcp prompt` - MCP prompt handling | ||
| - `wp mcp server add|list|remove|update` - Manage MCP servers | ||
|
|
||
| ## Testing Notes | ||
|
|
||
| - PHPUnit tests are in `tests/phpunit/` | ||
| - Behat feature tests are in `features/` | ||
| - PHPStan config: `phpstan.neon.dist` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Feature: AI Credentials command | ||
| Scenario: Credentials management with WP AI Client | ||
| Given a WP installation | ||
|
|
||
| When I run `wp ai credentials list` | ||
| Then STDOUT should contain: | ||
| """ | ||
| No credentials configured. | ||
| """ | ||
|
|
||
| When I run `wp ai credentials set openai sk-test-key` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Credentials for 'openai' saved. | ||
| """ | ||
|
|
||
| When I run `wp ai credentials list` | ||
| Then STDOUT should contain: | ||
| """ | ||
| openai | ||
| """ | ||
|
|
||
| When I run `wp ai credentials delete openai` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Credentials for 'openai' deleted. | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,22 @@ | ||
| Feature: AI command | ||
| Scenario: Missing AI Services plugin | ||
| When I try `wp ai "Hello World"` | ||
| Scenario: AI prompt requires WordPress | ||
| When I try `wp ai prompt "Hello World"` | ||
| Then STDERR should contain: | ||
| """ | ||
| This does not seem to be a WordPress installation. | ||
| """ | ||
|
|
||
| When I try `wp ai "Hello World" --skip-wordpress` | ||
| Scenario: Skip WordPress not implemented | ||
| When I try `wp ai prompt "Hello World" --skip-wordpress` | ||
| Then STDERR should contain: | ||
| """ | ||
| Not implemented yet. | ||
| """ | ||
|
|
||
| Scenario: AI prompt requires configured models | ||
| Given a WP installation | ||
| When I try `wp ai "Hello World"` | ||
| When I try `wp ai prompt "Hello World"` | ||
| Then STDERR should contain: | ||
| """ | ||
| This command currently requires the AI Services plugin. | ||
| """ | ||
|
|
||
| When I run `wp plugin install ai-services --activate` | ||
| When I try `wp ai "Hello World"` | ||
| Then STDERR should contain: | ||
| """ | ||
| No service satisfying the given arguments is registered and available. | ||
| No models found | ||
| """ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation file seems to be outdated and doesn't reflect the significant changes made in this pull request. Several sections are now incorrect:
MCP/directory,McpCommand.php, andMcpServerCommand.php, all of which have been removed.wp mcpcommands that have been removed.Please update this file to accurately describe the current state of the project, focusing on the integration with WP AI Client.