Skip to content

Commit c5b0810

Browse files
committed
Add code reference for AiCommand class; list available tools.
1 parent 96432cf commit c5b0810

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

docs/reference.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
# Reference
22

3-
## Command
3+
## `AiCommand` class
44

5-
## Client
5+
### Description
66

7-
## Server
7+
The `AiCommand` class extends `WP_CLI_Command` to integrate AI-powered automation into WordPress through WP-CLI. It enables users to interact with an AI model by:
8+
9+
- Executing AI-driven prompts.
10+
- Registering [tools](tools.md) that can be invoked by AI (e.g., calculations, greetings, image generation).
11+
- Registering resources accessible by AI (e.g., user lists, product catalogs).
12+
- Fetching [WordPress community events](https://developer.wordpress.org/reference/classes/wp_community_events/) dynamically.
13+
14+
This class follows an MCP client-server architecture, where:
15+
16+
- Hosts (LLM applications like ChatGPT or IDEs) initiate connections.
17+
- [Clients](#client-class) manage direct communication with the server inside a host.
18+
- [Servers](#server-class) provide tools, resources, and context to the AI model.
19+
20+
### Methods
21+
22+
| Name | Description |
23+
| --- | --- |
24+
| `AiCommand:__invoke( $args, $assoc_args )` | <ul><li>Creates an AI server and client instance.</li><li>Registers tools & resources for AI processing.</li><li>Sends user input ($args[0]) to AI.</li><li>Outputs AI-generated results.</li></ul> |
25+
| `AiCommand:register_tools( $server, $client )` | Registers functionality AI can invoke. See [available tools](tools.md). |
26+
| `AiCommand:register_resources( $server )` | Registers structured datasets AI can access. See [available resources](). |
27+
28+
29+
## `Client` class
30+
31+
## `Server` class

docs/tools.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
## Predefined Tools
44

5+
- `calculate_total` - Computes total price (price * quantity).
6+
- `greet` - Greets a user.
7+
- `generate_image` - Uses AI to generate an image.
8+
- `fetch_wp_community_events` - Fetches WordPress community events based on location.
9+
510
## REST Controllers

0 commit comments

Comments
 (0)