Skip to content

Commit c160cd7

Browse files
committed
Search: rename plan docs (remove date prefix), slim down api-design, add roadmap
1 parent f99ca99 commit c160cd7

6 files changed

Lines changed: 125 additions & 194 deletions

projects/packages/search/docs/plans/2026-04-21-search-ai-answers-api-design.md

Lines changed: 0 additions & 179 deletions
This file was deleted.

projects/packages/search/docs/plans/2026-04-21-local-testing-setup.md renamed to projects/packages/search/docs/plans/local-testing-setup.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ A checklist to verify your local environment can run tests and test the AI Answe
66

77
## 1. Prerequisites
88

9-
- [ ] Docker Desktop is installed and running (`docker info` returns no error)
10-
- [ ] `jetpack` CLI is installed and on PATH:
9+
- [x ] Docker Desktop is installed and running (`docker info` returns no error)
10+
- [x ] `jetpack` CLI is installed and on PATH:
1111
```bash
1212
jetpack --version
1313
# If missing: npm install -g @automattic/jetpack-cli (or pnpm add -g)
1414
```
15-
- [ ] Node and pnpm are available:
15+
- [x ] Node and pnpm are available:
1616
```bash
1717
node --version # 20+
1818
pnpm --version # 9+
1919
```
20-
- [ ] PHP and Composer are available:
20+
- [x ] PHP and Composer are available:
2121
```bash
2222
php --version # 8.0+
2323
composer --version
2424
```
25-
- [ ] You're on the right branch:
25+
- [x ] You're on the right branch:
2626
```bash
2727
git branch # should be jps3-answers-plan
2828
```
@@ -31,7 +31,7 @@ A checklist to verify your local environment can run tests and test the AI Answe
3131

3232
## 2. Install Monorepo Dependencies
3333

34-
- [ ] Install all JS and PHP dependencies from the monorepo root:
34+
- [x ] Install all JS and PHP dependencies from the monorepo root:
3535
```bash
3636
pnpm install
3737
composer install
@@ -44,19 +44,19 @@ A checklist to verify your local environment can run tests and test the AI Answe
4444

4545
The PHP unit tests for the Search and Sync packages use WorDBless (no WordPress needed) and run locally without Docker.
4646

47-
- [ ] Run Search package PHP tests:
47+
- [x ] Run Search package PHP tests:
4848
```bash
4949
jetpack test php packages/search -v
5050
```
5151
Expected: all tests pass (including `AI_Answers_Test` once Task 1 is implemented).
5252

53-
- [ ] Run Sync package PHP tests:
53+
- [x ] Run Sync package PHP tests:
5454
```bash
5555
jetpack test php packages/sync -v
5656
```
5757
Expected: all tests pass (including the CPT sync tests once Task 2 is implemented).
5858

59-
- [ ] Run Search package JS tests:
59+
- [x ] Run Search package JS tests:
6060
```bash
6161
cd projects/packages/search
6262
pnpm test-scripts
@@ -69,7 +69,7 @@ The PHP unit tests for the Search and Sync packages use WorDBless (no WordPress
6969

7070
Build is required before the Docker site can serve the updated JS bundle.
7171

72-
- [ ] Build all Search JS bundles:
72+
- [x ] Build all Search JS bundles:
7373
```bash
7474
cd projects/packages/search
7575
pnpm build
@@ -86,26 +86,26 @@ Build is required before the Docker site can serve the updated JS bundle.
8686

8787
## 5. Start Docker WordPress Environment
8888

89-
- [ ] Start containers (first time or after `jetpack docker clean`):
89+
- [x ] Start containers (first time or after `jetpack docker clean`):
9090
```bash
9191
jetpack docker up -d
9292
jetpack docker install
9393
```
9494
WordPress is now at [http://localhost](http://localhost).
9595
Default credentials: `jp_docker_acct` / `jp_docker_pass`
9696

97-
- [ ] If containers were already installed previously, just start them:
97+
- [x ] If containers were already installed previously, just start them:
9898
```bash
9999
jetpack docker up -d
100100
```
101101

102-
- [ ] Verify WordPress is reachable:
102+
- [x ] Verify WordPress is reachable:
103103
```bash
104104
open http://localhost/wp-admin
105105
```
106106
You should see the WP login page.
107107

108-
- [ ] Verify Jetpack plugin is active (it's auto-linked from the monorepo):
108+
- [x ] Verify Jetpack plugin is active (it's auto-linked from the monorepo):
109109
```bash
110110
jetpack docker wp plugin list | grep jetpack
111111
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Jetpack Search AI Answers — wpcom API
2+
3+
## Endpoint
4+
5+
```
6+
POST /wpcom/v2/ai/agent/jetpack-search-answers
7+
Authorization: Bearer {jwt-or-hmac-token}
8+
Accept: text/event-stream
9+
Content-Type: application/json
10+
```
11+
12+
## Authentication
13+
14+
Two auth paths:
15+
16+
**Anonymous site visitors**: A site-level hourly HMAC token generated server-side in PHP and embedded in `JetpackInstantSearchOptions.aiAnswersToken`:
17+
18+
```
19+
hash_hmac('sha256', 'search-answers:' . $site_id . ':' . floor(time()/3600), $blog_token_secret)
20+
```
21+
22+
Rotates hourly; wpcom accepts both the current and previous hour's token to handle clock skew.
23+
24+
**Logged-in users**: Standard Jetpack AI JWT from `/jetpack/v4/jetpack-ai-jwt`.
25+
26+
## Request Format
27+
28+
JSON-RPC 2.0 with `message/stream` method. The search query goes in the `text` part; site context (site ID, active filters, locale) goes in the `data` part:
29+
30+
```json
31+
{
32+
"jsonrpc": "2.0",
33+
"id": "req-1",
34+
"method": "message/stream",
35+
"params": {
36+
"message": {
37+
"role": "user",
38+
"parts": [
39+
{ "type": "text", "text": "how do I reset my password" },
40+
{
41+
"type": "data",
42+
"data": {
43+
"clientContext": {
44+
"selectedSiteId": 12345,
45+
"filters": { "post_type": ["post", "page"], "category": [] },
46+
"locale": "en"
47+
}
48+
},
49+
"metadata": {}
50+
}
51+
],
52+
"kind": "message",
53+
"messageId": "msg-1"
54+
}
55+
},
56+
"tokenStreaming": true
57+
}
58+
```
59+
60+
## SSE Response Events
61+
62+
| Event | Payload | Description |
63+
|---------|---------|-------------|
64+
| `chunk` | `{"type":"chunk","text":"…"}` | Answer tokens, appended as they arrive |
65+
| `done` | `{"type":"done","citations":[{"title":"…","url":"…","excerpt":"…"}]}` | Stream complete; citations as structured list |
66+
| `error` | `{"type":"error","code":"quota_exceeded","message":"…"}` | Terminal error; overlay hides AI panel |
67+
68+
## Quota
69+
70+
500 requests per calendar month per site (all plans). Returns `error` with `code: quota_exceeded` when exceeded; overlay falls back to standard search results.

projects/packages/search/docs/plans/2026-04-21-search-ai-answers-plugin-design.md renamed to projects/packages/search/docs/plans/search-ai-answers-plugin-design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
The WordPress plugin side of Jetpack Search AI Answers adds two custom post types for site-owner customization, syncs them to wpcom, embeds the auth token for anonymous visitors in the search overlay options, connects the overlay to the wpcom streaming endpoint, and provides an admin UI for managing search behavior and topics.
99

10-
The companion spec for the wpcom API side is `2026-04-21-search-ai-answers-api-design.md`.
10+
The companion spec for the wpcom API side is `search-ai-answers-api-design.md`.
1111

1212
## Custom Post Types
1313

projects/packages/search/docs/plans/2026-04-21-search-ai-answers-plugin-plan.md renamed to projects/packages/search/docs/plans/search-ai-answers-plugin-plan.md

File renamed without changes.

0 commit comments

Comments
 (0)