hostinger-api-mcp 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/headless/VERSION +2 -2
- package/skills/headless/steps/03-provision/SKILL.md +1 -1
- package/skills/headless/steps/03-provision/wordpress/SKILL.md +40 -28
- package/skills/headless/steps/04-content-model/wordpress/contact-form.md +8 -18
- package/skills/headless/steps/04-content-model/wordpress/woocommerce.md +17 -26
- package/src/core/runtime.js +9 -2
- package/src/core/runtime.ts +9 -2
- package/src/core/skills.js +12 -12
- package/src/core/skills.ts +12 -12
- package/src/servers/agency-hosting.js +1 -1
- package/src/servers/agency-hosting.ts +1 -1
- package/src/servers/agent-readiness.js +1 -1
- package/src/servers/agent-readiness.ts +1 -1
- package/src/servers/all.js +1 -1
- package/src/servers/all.ts +1 -1
- package/src/servers/billing.js +1 -1
- package/src/servers/billing.ts +1 -1
- package/src/servers/dns.js +1 -1
- package/src/servers/dns.ts +1 -1
- package/src/servers/domains.js +1 -1
- package/src/servers/domains.ts +1 -1
- package/src/servers/ecommerce.js +1 -1
- package/src/servers/ecommerce.ts +1 -1
- package/src/servers/gpu.js +1 -1
- package/src/servers/gpu.ts +1 -1
- package/src/servers/horizons.js +1 -1
- package/src/servers/horizons.ts +1 -1
- package/src/servers/hosting.js +1 -1
- package/src/servers/hosting.ts +1 -1
- package/src/servers/mail.js +1 -1
- package/src/servers/mail.ts +1 -1
- package/src/servers/reach.js +1 -1
- package/src/servers/reach.ts +1 -1
- package/src/servers/vps.js +1 -1
- package/src/servers/vps.ts +1 -1
- package/src/servers/wordpress.js +1 -1
- package/src/servers/wordpress.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ Generated at release time from the diff between the previous and current
|
|
|
4
4
|
build. Tool changes are listed individually; everything else is summarised
|
|
5
5
|
by area.
|
|
6
6
|
|
|
7
|
+
## v4.2.1 — 2026-11-16
|
|
8
|
+
|
|
9
|
+
### Also in this release
|
|
10
|
+
|
|
11
|
+
- Bundled agent skills: 5 files
|
|
12
|
+
- Other files: `src/core/skills.js`, `src/core/skills.ts`
|
|
13
|
+
|
|
14
|
+
## v4.2.0 — 2026-11-16
|
|
15
|
+
|
|
16
|
+
### Also in this release
|
|
17
|
+
|
|
18
|
+
- Dependencies: `package-lock.json`
|
|
19
|
+
- Bundled agent skills: `skills/headless/VERSION`
|
|
20
|
+
- Request handling and authentication: `src/core/runtime.js`, `src/core/runtime.ts`
|
|
21
|
+
|
|
7
22
|
## v4.1.0 — 2026-11-16
|
|
8
23
|
|
|
9
24
|
### Also in this release
|
package/gemini-extension.json
CHANGED
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"url": "https://github.com/hostinger/api-mcp-server",
|
|
18
18
|
"source": "github"
|
|
19
19
|
},
|
|
20
|
-
"version": "4.1
|
|
20
|
+
"version": "4.2.1",
|
|
21
21
|
"packages": [
|
|
22
22
|
{
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"identifier": "@hostinger/mcp",
|
|
25
|
-
"version": "4.1
|
|
25
|
+
"version": "4.2.1",
|
|
26
26
|
"transport": {
|
|
27
27
|
"type": "stdio"
|
|
28
28
|
},
|
package/skills/headless/VERSION
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
version=4.1
|
|
2
|
-
commit=
|
|
1
|
+
version=4.2.1
|
|
2
|
+
commit=b9928dac0c54
|
|
3
3
|
built=2026-11-16
|
|
@@ -17,7 +17,7 @@ Read the brief's **Suggested backend** section:
|
|
|
17
17
|
| Suggested backend | Follow |
|
|
18
18
|
|---|---|
|
|
19
19
|
| WordPress | `wordpress/SKILL.md` |
|
|
20
|
-
| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its
|
|
20
|
+
| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its Steps 4–5; `site.json → backend` stays `"wordpress"`) |
|
|
21
21
|
| Ecommerce | `ecommerce/SKILL.md` |
|
|
22
22
|
| Webapp | `webapp/SKILL.md` |
|
|
23
23
|
|
|
@@ -106,40 +106,52 @@ Notes:
|
|
|
106
106
|
briefly before failing. Its `domain` filter is a substring match, so exact-match the row.
|
|
107
107
|
- The install record's `url` may say `http://`; always use `https://` URLs.
|
|
108
108
|
- `GET https://<domain>/` returns 403 until the frontend is deployed — expected, not a failure.
|
|
109
|
+
- A `jwt-token` HTTP 500 can still have succeeded (a known quirk of the `hostinger-wordpress` MCP):
|
|
110
|
+
call it again before failing.
|
|
109
111
|
- **Never print, log or store the JWT.** It is minted on demand (24 h lifetime) by whichever stage
|
|
110
112
|
needs the per-site WP MCP; only `mcp_url` is recorded.
|
|
111
113
|
|
|
112
114
|
If a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.
|
|
113
115
|
|
|
114
|
-
## Step 4 —
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
116
|
+
## Step 4 — Plugins *(one install call for every plugin the site needs)*
|
|
117
|
+
|
|
118
|
+
Install every wordpress.org plugin the site needs in **one** call, then poll once for all of them. This
|
|
119
|
+
is **join-half** work (needs the live `/cms` install), so run it once `provision.status == "completed"`.
|
|
120
|
+
Build the slug list from the brief:
|
|
121
|
+
|
|
122
|
+
| Slug | Install when | If it doesn't come up |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| `wordpress-seo` (Yoast SEO) | Every site, unless the owner declines it when told (then record `seo.enabled: false`) | Record `seo.enabled: false`, tell the user in one line, and let the frontend generate tags from content |
|
|
125
|
+
| `woocommerce` | The brief's **Suggested backend** is `**WordPress + WooCommerce**` | Stop and point the user at hPanel: a store can't work without it |
|
|
126
|
+
| `contact-form-7` | The brief's **Must-haves** include a contact form | Record `contact_form.enabled: false`, tell the user in one line, and let the frontend render the contact page without a form |
|
|
127
|
+
|
|
128
|
+
Yoast is on by default so per-page title/description/Open Graph/JSON-LD come from a maintained
|
|
129
|
+
plugin's `yoast_head_json` rather than being hand-generated by the frontend. Tell the user in one line
|
|
130
|
+
which plugins you're installing; drop `wordpress-seo` if they say they don't want SEO.
|
|
131
|
+
|
|
132
|
+
1. **Install all of them in one call** (management MCP, async):
|
|
133
|
+
`wordpress_plugins_install { username, software: <install_id>, plugins: [<every slug from the table>] }`.
|
|
134
|
+
An HTTP 500 doesn't mean it failed (a known quirk of the `hostinger-wordpress` MCP): go straight to
|
|
135
|
+
the poll, and never send a second install blindly.
|
|
136
|
+
2. **Poll** `wordpress_plugins_list-installed { username, software }` until every slug shows `active`
|
|
137
|
+
(install and activate usually complete together). Activate a slug that is installed but inactive with
|
|
138
|
+
`wordpress_plugins_activate { username, software, plugin: "<slug>" }`.
|
|
139
|
+
3. **A slug that doesn't come up.** The poll names it, so handle only that slug: if it is still not
|
|
140
|
+
`active` after about two minutes of polling, send one more install with only the slugs that aren't
|
|
141
|
+
`active`, poll again, and apply each remaining slug's fallback from the table. Never fail provision
|
|
142
|
+
over Yoast or Contact Form 7.
|
|
143
|
+
|
|
144
|
+
## Step 5 — Per-plugin checks *(each slug Step 4 left `active`)*
|
|
145
|
+
|
|
146
|
+
A check that fails means that slug didn't come up: apply its fallback from Step 4.
|
|
147
|
+
|
|
148
|
+
- **SEO** (`wordpress-seo`): `GET https://<domain>/cms/wp-json/` → `namespaces` once more, and a sample
|
|
149
|
+
post/page response carries `yoast_head_json`. The per-item Yoast meta (focus title/description per
|
|
150
|
+
post) is set later in the **content-model push**; provision only installs and activates the plugin.
|
|
151
|
+
- **A store** (`woocommerce`): verify it and record it in `site.json` per
|
|
140
152
|
[`../../04-content-model/wordpress/woocommerce.md`](../../04-content-model/wordpress/woocommerce.md) §0.
|
|
141
|
-
- **A contact form** (
|
|
142
|
-
[`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0
|
|
153
|
+
- **A contact form** (`contact-form-7`): verify it and record it in `site.json` per
|
|
154
|
+
[`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0.
|
|
143
155
|
|
|
144
156
|
## Step 6 — Record `site.json`
|
|
145
157
|
|
|
@@ -6,29 +6,19 @@ submitted from the **decoupled frontend**, sends the enquiry to the site owner b
|
|
|
6
6
|
WordPress's built-in `wp_mail()` — no third-party form service, no API keys, no secret on the client.
|
|
7
7
|
|
|
8
8
|
**Contact Form 7 is not a separate backend.** It is the `contact-form-7` plugin on the same headless
|
|
9
|
-
WordPress install at `/cms` (installed at provision, §0). This cookbook is the authoritative home for
|
|
9
|
+
WordPress install at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for
|
|
10
10
|
the contact-form data layer: how to **resolve the form** (content-model push), **deploy a spam guard**,
|
|
11
11
|
what the **frontend submits** (Step 6), and how **validate** proves mail actually leaves.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
## 0 — Provision:
|
|
15
|
+
## 0 — Provision: verify, record `site.json`
|
|
16
16
|
|
|
17
|
-
Read from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.
|
|
18
|
-
`provision.status == "completed"`.
|
|
17
|
+
Read from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(install + activate can complete together), or activate it with
|
|
24
|
-
`wordpress_plugins_activate { username, software, plugin: "contact-form-7" }`.
|
|
25
|
-
- **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job
|
|
26
|
-
succeeded**. Treat a 500 as "verify, don't assume": poll `list-installed` before retrying, and
|
|
27
|
-
never fire a second install blindly.
|
|
28
|
-
2. **Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then
|
|
29
|
-
record `contact_form.enabled: true` in `site.json` (provision Step 6). If the install can't be confirmed after
|
|
30
|
-
one retry, record `contact_form.enabled: false`, tell the user in one line, and let the frontend
|
|
31
|
-
render the contact page without a form (graceful — not a build failure). Don't fail provision over it.
|
|
19
|
+
**Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then record
|
|
20
|
+
`contact_form.enabled: true` in `site.json` (provision Step 6). If it's missing, CF7 didn't come up:
|
|
21
|
+
apply its fallback in provision Step 4.
|
|
32
22
|
|
|
33
23
|
Then add the `contact_form` block to `site.json` (provision Step 6). Provision records only `enabled` +
|
|
34
24
|
`plugin` here; §2 fills `form_id`, `feedback_url`, `fields` and `honeypot_field` once it resolves the form
|
|
@@ -59,8 +49,8 @@ You **could** deploy a custom plugin into the headless `/cms` and write a bespok
|
|
|
59
49
|
[`custom-plugins.md`](custom-plugins.md)), but a contact form is exactly the kind of maintained,
|
|
60
50
|
spam-hardened functionality you should **reuse rather than reinvent**. CF7 is the right choice because:
|
|
61
51
|
|
|
62
|
-
- It is a **wordpress.org-slug plugin** → installs
|
|
63
|
-
|
|
52
|
+
- It is a **wordpress.org-slug plugin** → provision Step 4 installs it like Yoast. No custom
|
|
53
|
+
code to deploy.
|
|
64
54
|
- It ships a **public, unauthenticated submit endpoint**:
|
|
65
55
|
`POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<form_id>/feedback`. Submissions don't need
|
|
66
56
|
the JWT or any key.
|
|
@@ -5,37 +5,28 @@ a **WooCommerce store** (`site.json → woocommerce.enabled: true`) — a brief
|
|
|
5
5
|
`**WordPress + WooCommerce**` (one site: content **and** commerce).
|
|
6
6
|
|
|
7
7
|
**WooCommerce is not a separate backend.** It is the `woocommerce` plugin on a normal headless WordPress
|
|
8
|
-
install at `/cms` (installed at provision, §0). This cookbook is the authoritative home for the store
|
|
8
|
+
install at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for the store
|
|
9
9
|
data layer: how to **seed and CRUD** products, categories and coupons, and how the **storefront** reads
|
|
10
10
|
the cart, coupons and checkout.
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
## 0 — Provision:
|
|
15
|
-
|
|
16
|
-
Read from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
| Check | How | Expect |
|
|
32
|
-
|---|---|---|
|
|
33
|
-
| WooCommerce active | `wordpress_plugins_check-if-woo-commerce-is-installed { domain }` | installed + active |
|
|
34
|
-
| Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |
|
|
35
|
-
| Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |
|
|
36
|
-
|
|
37
|
-
Pretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a
|
|
38
|
-
store route ever 404s, the permalink structure is the thing to check.
|
|
14
|
+
## 0 — Provision: verify, record `site.json`
|
|
15
|
+
|
|
16
|
+
Read from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.
|
|
17
|
+
|
|
18
|
+
**Verify the store endpoints (public, no auth).** Allow a moment for WooCommerce's installer to create
|
|
19
|
+
its tables and the Shop/Cart/Checkout pages. Provision Step 4's `list-installed` poll is the install
|
|
20
|
+
check: `wordpress_plugins_check-if-woo-commerce-is-installed` answers `is_installed: false` on a headless
|
|
21
|
+
`/cms` install even with WooCommerce active, so don't use it.
|
|
22
|
+
|
|
23
|
+
| Check | How | Expect |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |
|
|
26
|
+
| Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |
|
|
27
|
+
|
|
28
|
+
Pretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a
|
|
29
|
+
store route ever 404s, the permalink structure is the thing to check.
|
|
39
30
|
|
|
40
31
|
Then add the `woocommerce` block and the store URLs to `site.json` (provision Step 6; `backend` stays
|
|
41
32
|
`"wordpress"`). Checkout stays off until the owner sets it up (§4), so `payment_enabled` starts `false`:
|
package/src/core/runtime.js
CHANGED
|
@@ -149,14 +149,21 @@ class MCPServer {
|
|
|
149
149
|
*/
|
|
150
150
|
setupHandlers() {
|
|
151
151
|
// Capture the connecting MCP client's identity once the initialize handshake completes.
|
|
152
|
-
// The name
|
|
152
|
+
// The name and version are client-controlled input, so strip CR/LF to prevent header injection.
|
|
153
153
|
this.server.oninitialized = () => {
|
|
154
|
-
const
|
|
154
|
+
const clientInfo = this.server.getClientVersion();
|
|
155
|
+
const clientName = String(clientInfo?.name ?? "")
|
|
155
156
|
.replace(/\r|\n/g, "")
|
|
156
157
|
.trim();
|
|
157
158
|
if (clientName) {
|
|
158
159
|
this.headers["X-MCP-Client"] = clientName;
|
|
159
160
|
}
|
|
161
|
+
const clientVersion = String(clientInfo?.version ?? "")
|
|
162
|
+
.replace(/\r|\n/g, "")
|
|
163
|
+
.trim();
|
|
164
|
+
if (clientVersion) {
|
|
165
|
+
this.headers["X-MCP-Client-Version"] = clientVersion;
|
|
166
|
+
}
|
|
160
167
|
};
|
|
161
168
|
|
|
162
169
|
// Handle tool listing requests
|
package/src/core/runtime.ts
CHANGED
|
@@ -194,14 +194,21 @@ class MCPServer {
|
|
|
194
194
|
*/
|
|
195
195
|
private setupHandlers(): void {
|
|
196
196
|
// Capture the connecting MCP client's identity once the initialize handshake completes.
|
|
197
|
-
// The name
|
|
197
|
+
// The name and version are client-controlled input, so strip CR/LF to prevent header injection.
|
|
198
198
|
this.server.oninitialized = () => {
|
|
199
|
-
const
|
|
199
|
+
const clientInfo = this.server.getClientVersion();
|
|
200
|
+
const clientName = String(clientInfo?.name ?? "")
|
|
200
201
|
.replace(/\r|\n/g, "")
|
|
201
202
|
.trim();
|
|
202
203
|
if (clientName) {
|
|
203
204
|
this.headers["X-MCP-Client"] = clientName;
|
|
204
205
|
}
|
|
206
|
+
const clientVersion = String(clientInfo?.version ?? "")
|
|
207
|
+
.replace(/\r|\n/g, "")
|
|
208
|
+
.trim();
|
|
209
|
+
if (clientVersion) {
|
|
210
|
+
this.headers["X-MCP-Client-Version"] = clientVersion;
|
|
211
|
+
}
|
|
205
212
|
};
|
|
206
213
|
|
|
207
214
|
// Handle tool listing requests
|
package/src/core/skills.js
CHANGED
|
@@ -176,10 +176,10 @@ export default [
|
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
"uri": "skill://hostinger-headless/steps/03-provision/SKILL.md",
|
|
179
|
-
"digest": "sha256:
|
|
180
|
-
"size":
|
|
179
|
+
"digest": "sha256:bf7307c10a493e01561057c29350b77e079e5d338971405dccb0d0c763b7ead1",
|
|
180
|
+
"size": 5608,
|
|
181
181
|
"mimeType": "text/markdown",
|
|
182
|
-
"text": "---\nname: headless-step-provision\ndescription: \"Step 3 (provision) of the Hostinger Headless flow. Chooses the backend from brief.md (wordpress | ecommerce | webapp), then routes to the matching subfolder to provision it; writes site.json. WordPress + WooCommerce routes to the wordpress subfolder with the WooCommerce store turned on — it is not a separate backend.\"\n---\n\n# headless-step-provision\n\nRouter. The backend is decided in **refine** and recorded in `brief.md`; this step only routes to the\nmatching subfolder, which provisions it.\n\n**In:** `brief.md`. **Out:** `site.json` (written by the subfolder).\n\n## Step 1 — Route on the suggested backend\n\nRead the brief's **Suggested backend** section:\n\n| Suggested backend | Follow |\n|---|---|\n| WordPress | `wordpress/SKILL.md` |\n| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its
|
|
182
|
+
"text": "---\nname: headless-step-provision\ndescription: \"Step 3 (provision) of the Hostinger Headless flow. Chooses the backend from brief.md (wordpress | ecommerce | webapp), then routes to the matching subfolder to provision it; writes site.json. WordPress + WooCommerce routes to the wordpress subfolder with the WooCommerce store turned on — it is not a separate backend.\"\n---\n\n# headless-step-provision\n\nRouter. The backend is decided in **refine** and recorded in `brief.md`; this step only routes to the\nmatching subfolder, which provisions it.\n\n**In:** `brief.md`. **Out:** `site.json` (written by the subfolder).\n\n## Step 1 — Route on the suggested backend\n\nRead the brief's **Suggested backend** section:\n\n| Suggested backend | Follow |\n|---|---|\n| WordPress | `wordpress/SKILL.md` |\n| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its Steps 4–5; `site.json → backend` stays `\"wordpress\"`) |\n| Ecommerce | `ecommerce/SKILL.md` |\n| Webapp | `webapp/SKILL.md` |\n\nIf the section is missing or names something else, go back to **refine** — don't pick one here.\nTell the user the backend and its one-line reason before provisioning.\n\n> **Supported backends: `wordpress` (optionally with a WooCommerce store), `ecommerce` and `webapp`.**\n> `webapp` is a plain Node.js app host (an empty website — no CMS, no store, no `/cms`) for any app/SPA\n> that brings its own code and data; it never installs WordPress. PocketBase is not available in this\n> version — refine never proposes it, and there is no `pocketbase/` subfolder; if a brief somehow names\n> it, stop and tell the user rather than improvising it. A **WordPress + Ecommerce** brief (two separate\n> backends — a WordPress site **and** a Hostinger Ecommerce store) has no single combined `hosting_websites_create`\n> type yet: stop, tell the user it isn't supported as one site, and offer either to continue with just\n> WordPress or just Ecommerce (route to that one subfolder), **or**, if they want content and a store on\n> **one** site, to switch the brief to **WordPress + WooCommerce** — the one-site path, which routes to\n> `wordpress/SKILL.md` with the store on.\n\n## Onboarding handoff — swap an existing empty headless shell (do this before creating anything)\n\nOnboarding can create the website **before** you ever run, as an **empty headless shell**\n(`hosting_websites_create { type: \"headless_empty\" }`: `website_type` is `headless`, but **nothing\nis installed**). The single-instance gate in Step 2 is the checklist.\n\n> **Webapp is not part of this handoff at all.** `webapp` is **not** reached on the usual onboarding\n> flow — it is only triggered by experimental actions — so it **ignores headless instances entirely**:\n> it never detects, adopts or swaps an empty headless shell, and provisions its own **Node.js app host**\n> exactly as `webapp/SKILL.md` defines today. The swap below is **WordPress and Ecommerce only**.\n>\n> **But webapp must still never create a second instance for this build.** Only route here when the\n> brief's backend is `webapp` — a `wordpress` or `ecommerce` brief is never provisioned as a webapp. And\n> if this build's domain already has a headless shell/site (an onboarding `headless_empty`, or any row\n> from the single-instance gate below), **do not** spin up a separate Node.js host on another domain:\n> stop and tell the user the domain already has a headless instance, rather than leaving the build split\n> across two sites.\n\n## Step 2 — Fire (don't block)\n\n> **Single-instance gate — pass all four before you create anything:**\n> 1. **Exact-match the domain** in `hosting_websites_list` (substring filter — match the exact `domain`).\n> 2. **A `headless` row already exists → adopt + swap it, never create.** Install the backend into that\n> same site (WordPress → `wordpress_installations_install { type: \"headless\" }` into `/cms`; Ecommerce\n> → adopt as the storefront host). **Do not call `hosting_websites_create` again** — that makes a second site.\n> 3. **No row at all → create one fresh** with the backend's own `hosting_websites_create` type. Create it for **this\n> build's domain only** — never provision the backend on a different domain than the frontend (the CMS\n> is the `/cms` path of the same site, never a separate `cms.<domain>`).\n> 4. **A row of a different kind** (`website_type` not `headless`) → **stop and tell the user**; never\n> overwrite it.\n>\n> `wordpress/SKILL.md` Step 1 and `ecommerce/SKILL.md` Step 1 say how to tell an empty shell from an\n> already-provisioned backend.\n\nFollow the chosen subfolder's `SKILL.md` through **detect + create** (its `hosting_websites_create` call). The\nmoment the create is accepted and queued, record it in `state.json` and **return** — do not wait for\nit yet:\n\n```json\n{ \"stage\": \"content_model\",\n \"provision\": { \"status\": \"in_progress\", \"domain\": \"<domain>\", \"started_at\": \"<now>\" } }\n```\n\nNow go run the prepare work that doesn't need the backend (content-model prepare, frontend\nshell). The subfolder's readiness poll, verification and `site.json` are the **join** half below.\n\n## Step 3 — Join (at the instance barrier)\n\nWhen an instance-barrier step is about to run (content-model push, frontend data wiring, deploy) — or\nright away, if the agent can't interleave — finish the subfolder's `SKILL.md`: run its `wait.mjs` (it\nreturns at once if the job is already done), run its verification, and write `site.json` (which\nrecords the chosen `backend`). Then set `provision.status` to `\"completed\"` in `state.json` with a\nfresh `updated_at`.\n\n"
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
185
|
"uri": "skill://hostinger-headless/steps/03-provision/ecommerce/SKILL.md",
|
|
@@ -197,10 +197,10 @@ export default [
|
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
"uri": "skill://hostinger-headless/steps/03-provision/wordpress/SKILL.md",
|
|
200
|
-
"digest": "sha256:
|
|
201
|
-
"size":
|
|
200
|
+
"digest": "sha256:075bfc73772420e58236f57e1447ed010f67ddc2c45a8a4f5ffeb95c18ab9285",
|
|
201
|
+
"size": 11427,
|
|
202
202
|
"mimeType": "text/markdown",
|
|
203
|
-
"text": "---\nname: headless-step-provision-wordpress\ndescription: \"Provision a headless WordPress backend for the Hostinger Headless flow: create the headless website with WordPress at /cms, verify and self-heal, then record it in site.json.\"\n---\n\n# headless-step-provision-wordpress\n\nCreate the headless WordPress backend for `<domain>` and prove it is ready. One platform call lays\nevery headless site out identically: WordPress in `public_html/cms`, Hostinger AI Assistant + MCP\nadapter, site marked `headless`. **Out:** `site.json`.\n\nAll operations below go through the Hostinger connector (`execute`).\n\n> **Fire vs join (background provision).** Step 1, plus the queuing call — `hosting_websites_create`\n> for a fresh site (Step 2) **or** `wordpress_installations_install` to swap an empty headless shell\n> (Step 2b) — are the **fire** half: once the job is queued, record `provision.in_progress` and return\n> to do prepare work (see the router `../SKILL.md`). The readiness **poll** at the end of Step 2 / 2b,\n> plus Steps 3–6, are the **join** half — run them when an instance-barrier step needs the backend (or\n> immediately, if the agent can't interleave). An already-`completed` site with WordPress at `/cms`\n> detected in Step 1 means provision is already done: record `provision.completed` and adopt it.\n\n## Step 1 — Detect before you create (never provision twice)\n\n1. `hosting_websites_list { \"domain\": \"<domain>\" }` — substring filter, so **exact-match** the row's\n `domain`. If a row exists, note `username`, `order_id`, `website_type`.\n2. **No exact row** → nothing exists on this domain → **create fresh** (Step 2).\n3. **A row exists.** If `website_type` is **not** `headless`, stop and tell the user — this domain\n already hosts a different kind of site (plain WordPress, Node.js, builder, …); never overwrite it.\n If it **is** `headless`, work out whether WordPress is already installed or the shell is still empty:\n check `hosting_websites_list-setups { \"domain\": \"<domain>\" }`\n (exact row) and `wordpress_installations_list { username, domain, ownership: \"all\" }` (exact row):\n - Setup `running` → provisioning is underway → skip to Step 2's poll.\n - Setup `failed` → tell the user and point them at hPanel; do **not** call `hosting_websites_create` again yourself.\n - A WordPress install with `directory: \"cms\"` already present (or setup `type: headless_wordpress`)\n → **already provisioned** → skip to Step 3 (adopt it).\n - A `headless` site with **no** `/cms` install (an **empty headless shell** — setup\n `type: headless_empty`, typically from onboarding) → **swap it to WordPress** (Step 2b). Do **not**\n call `hosting_websites_create` again — the website already exists; you only install WordPress into it.\n\n## Step 2 — Create a fresh headless WordPress site (only when no site exists)\n\n1. Pick the plan: `hosting_orders_list { \"statuses\": [\"active\"] }`. One active order → use it; several\n → ask the user which.\n2. Start the setup:\n\n ```json\n { \"operation\": \"hosting_websites_create\",\n \"params\": { \"order_id\": <order_id>, \"type\": \"headless_wordpress\", \"domain\": \"<domain>\" } }\n ```\n\n `domain` must be a **customer-owned** domain. For a temporary `*.hostingersite.com` subdomain,\n **omit `domain`** — the setup generates one itself and returns it in the response. Don't call a\n separate subdomain op to make one first: there's no need in this flow. The response then carries the\n generated domain: if it differs from the workspace directory name, move `~/.hostinger/<old>/` to\n `~/.hostinger/<new>/`\n (if `<new>/` already exists, stop and ask instead of moving into it),\n update the domain in `brief.md`, and tell the user the new domain.\n Admin credentials are generated by the platform; never ask the user for a password.\n3. Don't wait here. At the join, `cd \"$HOME\" && node <skill>/wait.mjs setup <domain>` (see *Waiting on Hostinger* in\n the top-level `SKILL.md`) returns once the setup is `completed`, usually at once by then. A `failed`\n setup → stop, point at hPanel.\n\n## Step 2b — Swap an empty headless shell to WordPress (only when onboarding already made the shell)\n\nThe website already exists as an empty `headless` shell, so there is **no `hosting_websites_create`** here — you\ninstall WordPress straight into its `/cms` directory. This is the onboarding handoff path.\n\n1. Use the shell's `username` and `order_id` from Step 1's row — no new order pick, no new website.\n2. Install WordPress into `/cms`, flagged headless:\n\n ```json\n { \"operation\": \"wordpress_installations_install\",\n \"params\": { \"username\": \"<username>\", \"domain\": \"<domain>\", \"type\": \"headless\",\n \"site_title\": \"<the brief's Site name>\",\n \"credentials\": { \"login\": \"<admin login>\", \"email\": \"<account email>\",\n \"password\": \"<strong generated password>\" } } }\n ```\n\n - `type: \"headless\"` installs into `/cms` with the Hostinger headless MU plugin and marks the site\n headless-WordPress; **`directory` is not allowed with it** (it is always `cms`). The target must\n already be `headless` — the headless install rewrites the root `.htaccess`, so the API rejects it\n with `422` on any non-headless site (which is why Step 1 confirms `website_type: headless` first).\n - **You generate the admin password** (strong, 8–50 chars, mixed case + a digit) — never ask the user\n for one and never print it. The user signs in later through a one-click login link (Step 6), so the\n password only has to exist, not be remembered.\n - A new database is created for the install unless you pass `database.name` of an existing one; the\n generated database counts against the plan's limit.\n3. The call is **asynchronous** — a success response only means the install job was **queued**. This is\n the *fire*: record `provision.in_progress` and return to prepare work. At the join,\n `cd \"$HOME\" && node <skill>/wait.mjs cms <domain> <username>` returns the `/cms` install row (`directory: \"cms\"`,\n valid) once it exists, usually within 1–2 minutes of the install.\n\n## Step 3 — Verify (all must pass)\n\n| Check | How | Expect |\n|---|---|---|\n| Site is headless | `hosting_websites_list` exact row | `website_type: \"headless\"` |\n| WordPress at `/cms` | `wordpress_installations_list { \"username\": \"<username>\", \"ownership\": \"all\" }`, exact-match `domain` | row with `directory: \"cms\"`, `is_valid: true`; note its `id` |\n| REST API answers | `GET https://<domain>/cms/wp-json/wp/v2/posts?per_page=1` | 200, JSON array |\n| AI Assistant + MCP loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `hostinger-ai-assistant/v1` and `mcp` |\n| JWT mintable | `wordpress_installations_jwt-token { username, software: <id> }` | returns `token`, `mcp_url` |\n\nNotes:\n\n- `wordpress_installations_list` can lag a few seconds behind `completed` and return `[]` — retry\n briefly before failing. Its `domain` filter is a substring match, so exact-match the row.\n- The install record's `url` may say `http://`; always use `https://` URLs.\n- `GET https://<domain>/` returns 403 until the frontend is deployed — expected, not a failure.\n- **Never print, log or store the JWT.** It is minted on demand (24 h lifetime) by whichever stage\n needs the per-site WP MCP; only `mcp_url` is recorded.\n\nIf a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.\n\n## Step 4 — SEO plugin (Yoast) *(every WordPress site — on by default)*\n\nEvery headless WordPress site gets **Yoast SEO** (`wordpress-seo`) installed and activated by default,\nso per-page title/description/Open Graph/JSON-LD come from a maintained plugin's `yoast_head_json`\nrather than being hand-generated from each item's content by the frontend. This is **join-half** work\n(needs the live `/cms` install), so run it once `provision.status == \"completed\"`, the same way as\nStep 5. Tell the user in one line that SEO (Yoast) is being set up; if they explicitly don't\nwant it, skip this step and record `seo.enabled: false` — but the default is to install it.\n\n1. **Install + activate Yoast** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"wordpress-seo\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `wordpress-seo` shows\n `active` (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"wordpress-seo\" }`.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded**. Treat a 500 as \"verify, don't assume\": poll `list-installed` before retrying, and\n never fire a second install blindly.\n2. **Verify** `GET https://<domain>/cms/wp-json/` → `namespaces` once more, and that a sample post/page\n response carries `yoast_head_json`. The per-item Yoast meta (focus title/description per post) is set\n later in the **content-model push** — provision only installs + activates the plugin here. Don't fail\n provision over SEO: if the install can't be confirmed after one retry, record `seo.enabled: false`,\n tell the user, and let the frontend fall back to generating tags from content.\n\n## Step 5 — Store and contact form *(only when the brief has them — skip otherwise)*\n\n- **A store** (the brief's **Suggested backend** is `**WordPress + WooCommerce**`): follow\n [`../../04-content-model/wordpress/woocommerce.md`](../../04-content-model/wordpress/woocommerce.md) §0.\n- **A contact form** (the brief's **Must-haves** include a contact form): follow\n [`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0 to install Contact Form 7 (`contact-form-7`).\n\n## Step 6 — Record `site.json`\n\n```json\n{\n \"backend\": \"wordpress\",\n \"website_type\": \"headless\",\n \"order_id\": 1007223428,\n \"username\": \"u…\",\n \"wordpress\": {\n \"install_id\": \"30…\",\n \"directory\": \"cms\",\n \"admin_login\": \"…\"\n },\n \"seo\": {\n \"plugin\": \"wordpress-seo\",\n \"enabled\": true\n },\n \"urls\": {\n \"site\": \"https://<domain>\",\n \"cms\": \"https://<domain>/cms\",\n \"wp_admin\": \"https://<domain>/cms/wp-admin\",\n \"rest_api\": \"https://<domain>/cms/wp-json/wp/v2\",\n \"wp_mcp\": \"<mcp_url from the JWT call>\"\n },\n \"provisioned_at\": \"…\",\n \"verified_at\": \"…\"\n}\n```\n\nNo passwords or tokens in `site.json`. When the user needs wp-admin, mint a one-click link with\n`wordpress_login_create-links { username, software: <install_id> }` — never hand over a password.\n"
|
|
203
|
+
"text": "---\nname: headless-step-provision-wordpress\ndescription: \"Provision a headless WordPress backend for the Hostinger Headless flow: create the headless website with WordPress at /cms, verify and self-heal, then record it in site.json.\"\n---\n\n# headless-step-provision-wordpress\n\nCreate the headless WordPress backend for `<domain>` and prove it is ready. One platform call lays\nevery headless site out identically: WordPress in `public_html/cms`, Hostinger AI Assistant + MCP\nadapter, site marked `headless`. **Out:** `site.json`.\n\nAll operations below go through the Hostinger connector (`execute`).\n\n> **Fire vs join (background provision).** Step 1, plus the queuing call — `hosting_websites_create`\n> for a fresh site (Step 2) **or** `wordpress_installations_install` to swap an empty headless shell\n> (Step 2b) — are the **fire** half: once the job is queued, record `provision.in_progress` and return\n> to do prepare work (see the router `../SKILL.md`). The readiness **poll** at the end of Step 2 / 2b,\n> plus Steps 3–6, are the **join** half — run them when an instance-barrier step needs the backend (or\n> immediately, if the agent can't interleave). An already-`completed` site with WordPress at `/cms`\n> detected in Step 1 means provision is already done: record `provision.completed` and adopt it.\n\n## Step 1 — Detect before you create (never provision twice)\n\n1. `hosting_websites_list { \"domain\": \"<domain>\" }` — substring filter, so **exact-match** the row's\n `domain`. If a row exists, note `username`, `order_id`, `website_type`.\n2. **No exact row** → nothing exists on this domain → **create fresh** (Step 2).\n3. **A row exists.** If `website_type` is **not** `headless`, stop and tell the user — this domain\n already hosts a different kind of site (plain WordPress, Node.js, builder, …); never overwrite it.\n If it **is** `headless`, work out whether WordPress is already installed or the shell is still empty:\n check `hosting_websites_list-setups { \"domain\": \"<domain>\" }`\n (exact row) and `wordpress_installations_list { username, domain, ownership: \"all\" }` (exact row):\n - Setup `running` → provisioning is underway → skip to Step 2's poll.\n - Setup `failed` → tell the user and point them at hPanel; do **not** call `hosting_websites_create` again yourself.\n - A WordPress install with `directory: \"cms\"` already present (or setup `type: headless_wordpress`)\n → **already provisioned** → skip to Step 3 (adopt it).\n - A `headless` site with **no** `/cms` install (an **empty headless shell** — setup\n `type: headless_empty`, typically from onboarding) → **swap it to WordPress** (Step 2b). Do **not**\n call `hosting_websites_create` again — the website already exists; you only install WordPress into it.\n\n## Step 2 — Create a fresh headless WordPress site (only when no site exists)\n\n1. Pick the plan: `hosting_orders_list { \"statuses\": [\"active\"] }`. One active order → use it; several\n → ask the user which.\n2. Start the setup:\n\n ```json\n { \"operation\": \"hosting_websites_create\",\n \"params\": { \"order_id\": <order_id>, \"type\": \"headless_wordpress\", \"domain\": \"<domain>\" } }\n ```\n\n `domain` must be a **customer-owned** domain. For a temporary `*.hostingersite.com` subdomain,\n **omit `domain`** — the setup generates one itself and returns it in the response. Don't call a\n separate subdomain op to make one first: there's no need in this flow. The response then carries the\n generated domain: if it differs from the workspace directory name, move `~/.hostinger/<old>/` to\n `~/.hostinger/<new>/`\n (if `<new>/` already exists, stop and ask instead of moving into it),\n update the domain in `brief.md`, and tell the user the new domain.\n Admin credentials are generated by the platform; never ask the user for a password.\n3. Don't wait here. At the join, `cd \"$HOME\" && node <skill>/wait.mjs setup <domain>` (see *Waiting on Hostinger* in\n the top-level `SKILL.md`) returns once the setup is `completed`, usually at once by then. A `failed`\n setup → stop, point at hPanel.\n\n## Step 2b — Swap an empty headless shell to WordPress (only when onboarding already made the shell)\n\nThe website already exists as an empty `headless` shell, so there is **no `hosting_websites_create`** here — you\ninstall WordPress straight into its `/cms` directory. This is the onboarding handoff path.\n\n1. Use the shell's `username` and `order_id` from Step 1's row — no new order pick, no new website.\n2. Install WordPress into `/cms`, flagged headless:\n\n ```json\n { \"operation\": \"wordpress_installations_install\",\n \"params\": { \"username\": \"<username>\", \"domain\": \"<domain>\", \"type\": \"headless\",\n \"site_title\": \"<the brief's Site name>\",\n \"credentials\": { \"login\": \"<admin login>\", \"email\": \"<account email>\",\n \"password\": \"<strong generated password>\" } } }\n ```\n\n - `type: \"headless\"` installs into `/cms` with the Hostinger headless MU plugin and marks the site\n headless-WordPress; **`directory` is not allowed with it** (it is always `cms`). The target must\n already be `headless` — the headless install rewrites the root `.htaccess`, so the API rejects it\n with `422` on any non-headless site (which is why Step 1 confirms `website_type: headless` first).\n - **You generate the admin password** (strong, 8–50 chars, mixed case + a digit) — never ask the user\n for one and never print it. The user signs in later through a one-click login link (Step 6), so the\n password only has to exist, not be remembered.\n - A new database is created for the install unless you pass `database.name` of an existing one; the\n generated database counts against the plan's limit.\n3. The call is **asynchronous** — a success response only means the install job was **queued**. This is\n the *fire*: record `provision.in_progress` and return to prepare work. At the join,\n `cd \"$HOME\" && node <skill>/wait.mjs cms <domain> <username>` returns the `/cms` install row (`directory: \"cms\"`,\n valid) once it exists, usually within 1–2 minutes of the install.\n\n## Step 3 — Verify (all must pass)\n\n| Check | How | Expect |\n|---|---|---|\n| Site is headless | `hosting_websites_list` exact row | `website_type: \"headless\"` |\n| WordPress at `/cms` | `wordpress_installations_list { \"username\": \"<username>\", \"ownership\": \"all\" }`, exact-match `domain` | row with `directory: \"cms\"`, `is_valid: true`; note its `id` |\n| REST API answers | `GET https://<domain>/cms/wp-json/wp/v2/posts?per_page=1` | 200, JSON array |\n| AI Assistant + MCP loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `hostinger-ai-assistant/v1` and `mcp` |\n| JWT mintable | `wordpress_installations_jwt-token { username, software: <id> }` | returns `token`, `mcp_url` |\n\nNotes:\n\n- `wordpress_installations_list` can lag a few seconds behind `completed` and return `[]` — retry\n briefly before failing. Its `domain` filter is a substring match, so exact-match the row.\n- The install record's `url` may say `http://`; always use `https://` URLs.\n- `GET https://<domain>/` returns 403 until the frontend is deployed — expected, not a failure.\n- A `jwt-token` HTTP 500 can still have succeeded (a known quirk of the `hostinger-wordpress` MCP):\n call it again before failing.\n- **Never print, log or store the JWT.** It is minted on demand (24 h lifetime) by whichever stage\n needs the per-site WP MCP; only `mcp_url` is recorded.\n\nIf a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.\n\n## Step 4 — Plugins *(one install call for every plugin the site needs)*\n\nInstall every wordpress.org plugin the site needs in **one** call, then poll once for all of them. This\nis **join-half** work (needs the live `/cms` install), so run it once `provision.status == \"completed\"`.\nBuild the slug list from the brief:\n\n| Slug | Install when | If it doesn't come up |\n|---|---|---|\n| `wordpress-seo` (Yoast SEO) | Every site, unless the owner declines it when told (then record `seo.enabled: false`) | Record `seo.enabled: false`, tell the user in one line, and let the frontend generate tags from content |\n| `woocommerce` | The brief's **Suggested backend** is `**WordPress + WooCommerce**` | Stop and point the user at hPanel: a store can't work without it |\n| `contact-form-7` | The brief's **Must-haves** include a contact form | Record `contact_form.enabled: false`, tell the user in one line, and let the frontend render the contact page without a form |\n\nYoast is on by default so per-page title/description/Open Graph/JSON-LD come from a maintained\nplugin's `yoast_head_json` rather than being hand-generated by the frontend. Tell the user in one line\nwhich plugins you're installing; drop `wordpress-seo` if they say they don't want SEO.\n\n1. **Install all of them in one call** (management MCP, async):\n `wordpress_plugins_install { username, software: <install_id>, plugins: [<every slug from the table>] }`.\n An HTTP 500 doesn't mean it failed (a known quirk of the `hostinger-wordpress` MCP): go straight to\n the poll, and never send a second install blindly.\n2. **Poll** `wordpress_plugins_list-installed { username, software }` until every slug shows `active`\n (install and activate usually complete together). Activate a slug that is installed but inactive with\n `wordpress_plugins_activate { username, software, plugin: \"<slug>\" }`.\n3. **A slug that doesn't come up.** The poll names it, so handle only that slug: if it is still not\n `active` after about two minutes of polling, send one more install with only the slugs that aren't\n `active`, poll again, and apply each remaining slug's fallback from the table. Never fail provision\n over Yoast or Contact Form 7.\n\n## Step 5 — Per-plugin checks *(each slug Step 4 left `active`)*\n\nA check that fails means that slug didn't come up: apply its fallback from Step 4.\n\n- **SEO** (`wordpress-seo`): `GET https://<domain>/cms/wp-json/` → `namespaces` once more, and a sample\n post/page response carries `yoast_head_json`. The per-item Yoast meta (focus title/description per\n post) is set later in the **content-model push**; provision only installs and activates the plugin.\n- **A store** (`woocommerce`): verify it and record it in `site.json` per\n [`../../04-content-model/wordpress/woocommerce.md`](../../04-content-model/wordpress/woocommerce.md) §0.\n- **A contact form** (`contact-form-7`): verify it and record it in `site.json` per\n [`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0.\n\n## Step 6 — Record `site.json`\n\n```json\n{\n \"backend\": \"wordpress\",\n \"website_type\": \"headless\",\n \"order_id\": 1007223428,\n \"username\": \"u…\",\n \"wordpress\": {\n \"install_id\": \"30…\",\n \"directory\": \"cms\",\n \"admin_login\": \"…\"\n },\n \"seo\": {\n \"plugin\": \"wordpress-seo\",\n \"enabled\": true\n },\n \"urls\": {\n \"site\": \"https://<domain>\",\n \"cms\": \"https://<domain>/cms\",\n \"wp_admin\": \"https://<domain>/cms/wp-admin\",\n \"rest_api\": \"https://<domain>/cms/wp-json/wp/v2\",\n \"wp_mcp\": \"<mcp_url from the JWT call>\"\n },\n \"provisioned_at\": \"…\",\n \"verified_at\": \"…\"\n}\n```\n\nNo passwords or tokens in `site.json`. When the user needs wp-admin, mint a one-click link with\n`wordpress_login_create-links { username, software: <install_id> }` — never hand over a password.\n"
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
206
|
"uri": "skill://hostinger-headless/steps/04-content-model/SKILL.md",
|
|
@@ -239,10 +239,10 @@ export default [
|
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
241
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/contact-form.md",
|
|
242
|
-
"digest": "sha256:
|
|
243
|
-
"size":
|
|
242
|
+
"digest": "sha256:d5c7813a1f8e6599bf91cf006fb27902bef7402ec9cd2810611cdb50486f9ae5",
|
|
243
|
+
"size": 15315,
|
|
244
244
|
"mimeType": "text/markdown",
|
|
245
|
-
"text": "# headless — Contact Form 7 cookbook (contact form on headless WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the brief's **Must-haves**\ninclude a contact form (`site.json → contact_form.enabled: true`). The goal: a contact page whose form,\nsubmitted from the **decoupled frontend**, sends the enquiry to the site owner by email using\nWordPress's built-in `wp_mail()` — no third-party form service, no API keys, no secret on the client.\n\n**Contact Form 7 is not a separate backend.** It is the `contact-form-7` plugin on the same headless\nWordPress install at `/cms` (installed at provision, §0). This cookbook is the authoritative home for\nthe contact-form data layer: how to **resolve the form** (content-model push), **deploy a spam guard**,\nwhat the **frontend submits** (Step 6), and how **validate** proves mail actually leaves.\n\n---\n\n## 0 — Provision: install, verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5. Like Yoast this is **join-half** work: run it once\n`provision.status == \"completed\"`.\n\n1. **Install + activate CF7** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"contact-form-7\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `contact-form-7` shows `active`\n (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"contact-form-7\" }`.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded**. Treat a 500 as \"verify, don't assume\": poll `list-installed` before retrying, and\n never fire a second install blindly.\n2. **Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then\n record `contact_form.enabled: true` in `site.json` (provision Step 6). If the install can't be confirmed after\n one retry, record `contact_form.enabled: false`, tell the user in one line, and let the frontend\n render the contact page without a form (graceful — not a build failure). Don't fail provision over it.\n\nThen add the `contact_form` block to `site.json` (provision Step 6). Provision records only `enabled` +\n`plugin` here; §2 fills `form_id`, `feedback_url`, `fields` and `honeypot_field` once it resolves the form\nand deploys the spam guard:\n\n```json\n{\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": null,\n \"feedback_url\": null,\n \"fields\": [],\n \"honeypot_field\": null,\n \"recipient\": \"site-admin-email\"\n }\n}\n```\n\n`recipient` is informational — CF7's `To` is `[_site_admin_email]`; no address, token or secret is\nstored in `site.json`.\n\n---\n\n## 1 — Why CF7, and why it works headlessly\n\nYou **could** deploy a custom plugin into the headless `/cms` and write a bespoke mailer (see\n[`custom-plugins.md`](custom-plugins.md)), but a contact form is exactly the kind of maintained,\nspam-hardened functionality you should **reuse rather than reinvent**. CF7 is the right choice because:\n\n- It is a **wordpress.org-slug plugin** → installs through the same management MCP (`wordpress_plugins_install`)\n as Yoast and WooCommerce. No custom code to deploy.\n- It ships a **public, unauthenticated submit endpoint**:\n `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<form_id>/feedback`. Submissions don't need\n the JWT or any key.\n- The frontend (apex domain) and `/cms` are **same-origin**, so the browser posts straight to that\n endpoint — **no proxy route, no CORS, no credentials client-side.**\n- On submit CF7 runs its mail template through `wp_mail()`, which on Hostinger routes through the\n server's mailer. The default form's `To` is `[_site_admin_email]` — the admin address set at install —\n so **basic email delivery works out of the box.**\n\n**Spam protection comes from a tiny deployed plugin, not the Honeypot add-on.** CF7's own\n`contact-form-7-honeypot` add-on only acts when a `[honeypot]` form-tag is present in the form — a wp-admin\nedit the headless agent can't make — so on the default form it does **nothing**. Instead, deploy a\n~15-line `wpcf7_spam` guard into `/cms` (the capability from [`custom-plugins.md`](custom-plugins.md)): it\nrejects a submission whose decoy field is filled, with no owner step and no keys. See *§2b — Spam\nprotection* below. (reCAPTCHA is the alternative but needs owner-provided Google keys set in wp-admin —\nout of reach for the headless agent.)\n\n---\n\n## 2 — Content-model push: resolve the form and record it\n\nA fresh CF7 install ships one form, **\"Contact form 1\"**, with the default fields `your-name`,\n`your-email`, `your-subject`, `your-message` and a submit, and mails `[_site_admin_email]`. You need\nits **numeric form id** (and, if you tailored the form, its field names) to build `feedback_url`.\n\n> **Reality check — how to read the id.** The per-site WP MCP (Hostinger AI Assistant, discovery mode)\n> exposes **no generic REST/`RestEndpointTool` ability**, and `wpcf7_contact_form` is **not a public CPT**\n> (it is absent from `cpt-list-types` and from `wp/v2/types`), so the MCP cannot read the form, and CF7's\n> own `GET /contact-form-7/v1/contact-forms` is capability-gated (no public read). The reliable,\n> tool-free way is to **probe the public feedback endpoint**, which needs no auth.\n\n1. **Find the form id by probing the feedback endpoint (idempotent).** For `id` in a small range\n (`1`‒`30` covers a fresh install — the default form lands a few ids after the sample content), send a\n **`multipart/form-data`** `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<id>/feedback` with\n a single field `_wpcf7_unit_tag=wpcf7-f<id>-o1`. **The content type matters:** CF7 checks it *before*\n it looks up the id and answers **415** to any non-multipart body, so a bare POST returns non-404 for\n *every* id and would wrongly pick id 1.\n - **Hit** → `200` whose JSON body carries `\"contact_form_id\": <id>` (matching the id you probed) and a\n CF7 `\"status\"` (e.g. `validation_failed`). **This id is the form.** On a fresh single-form install\n that is the only hit; reuse it on a re-run.\n - **Miss** → `404` with `\"code\": \"wpcf7_not_found\"`. Keep going.\n - **Inconclusive** → anything else (`415` from a wrong content type, `403`, `429`, `5xx`) is **not** a\n hit — never select such an id. Fix the request or retry, widen the range, and fall back to the owner\n handoff (step 2) if nothing resolves.\n\n The default field names are `your-name`, `your-email`, `your-subject`, `your-message`. (A full test\n submission that confirms both the id and the field names — and that mail actually sends — belongs to\n **validate**, so you send just one real email; see §5.)\n\n2. **(Optional) tailor the form — owner-side.** The headless tooling can't edit the CF7 form (no REST\n ability reaches it). If the design needs different fields, keep the default form for the build and note\n it; the owner edits fields/recipient in wp-admin (Contact → Contact Forms) via the one-click login.\n The default form is enough for a name/email/subject/message enquiry, and its recipient\n (`[_site_admin_email]`) is already correct.\n\n3. **Record into `site.json`** — fill the `contact_form` block provision started:\n\n ```json\n {\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": 4,\n \"feedback_url\": \"https://<domain>/cms/wp-json/contact-form-7/v1/contact-forms/4/feedback\",\n \"fields\": [\"your-name\", \"your-email\", \"your-subject\", \"your-message\"],\n \"cf7_version\": \"6.2.2\",\n \"honeypot_field\": \"your_website\",\n \"recipient\": \"site-admin-email\"\n }\n }\n ```\n\n `cf7_version` is the installed CF7 version (from `wordpress_plugins_list-installed`) — the frontend\n sends it as `_wpcf7_version`. `honeypot_field` is the decoy the spam guard checks (§2b) — the frontend\n renders it empty and the server rejects a filled one. Also note the form id in `content-model.md`. No\n address, token or secret goes into `site.json`.\n\n> **Fallback if the probe finds nothing** (an unusual install, or the default form was removed): mint a\n> one-click wp-admin link (`wordpress_login_create-links { username, software }`) and ask the owner to\n> read the form id from **Contact → Contact Forms** (the shortcode shows `id=\"…\"`). Record it into\n> `site.json` and continue — the same owner-handoff used for the WooCommerce checkout gate, not a build\n> failure.\n\n> **Aside — Hostinger's own shortcode.** The per-site MCP's `pages-create` ability suggests\n> `[hostinger_contact_form]` for a contact form *inside a WordPress page*. That is server-rendered\n> shortcode output, not useful to a decoupled React frontend that reads REST JSON — this flow uses CF7's\n> JSON feedback endpoint instead. Mentioned only so the shortcode hint isn't mistaken for the headless path.\n\n---\n\n## 2b — Spam protection: deploy the honeypot guard\n\nCF7's default form has **no spam protection**, and the `contact-form-7-honeypot` add-on can't help\nheadlessly (it needs a `[honeypot]` form-tag only an owner can add — see §1). Instead, deploy a tiny\nplugin that enforces a honeypot **server-side**, on the same REST feedback path the frontend uses. This\nreuses the custom-plugin deploy from [`custom-plugins.md`](custom-plugins.md) — the only moving part is one\n~15-line file.\n\n**Why it works.** CF7's `wpcf7_spam` filter runs inside `submit()`, which the REST feedback endpoint\ncalls, so returning `true` sets the submission `status` to `spam` and **suppresses the mail**. The hook can\nread any posted field via `WPCF7_Submission::get_posted_data()` — including a decoy field that isn't a CF7\nform-tag, **as long as its name doesn't start with `_`** (CF7 strips `_`-prefixed keys). So the frontend\nsends a decoy field (empty for humans), and the guard flags the submission as spam when a bot fills it.\n\n1. **Write the guard** to `~/.hostinger/<domain>/plugins/cf7-headless-spamguard/cf7-headless-spamguard.php`:\n\n ```php\n <?php\n /**\n * Plugin Name: CF7 Headless Spam Guard\n * Description: Server-side honeypot for Contact Form 7 submissions from a headless frontend.\n * Version: 1.0.0\n * Requires PHP: 7.4\n * License: GPL-2.0-or-later\n */\n if ( ! defined( 'ABSPATH' ) ) { exit; }\n\n // Reject a submission whose decoy field is filled. The name is a fixed convention the frontend\n // renders empty (site.json → contact_form.honeypot_field); it must NOT start with \"_\".\n add_filter( 'wpcf7_spam', function ( $spam, $submission ) {\n \tif ( $spam ) { return $spam; } // keep any earlier spam verdict\n \t$decoy = $submission->get_posted_data( 'your_website' );\n \tif ( is_string( $decoy ) && trim( $decoy ) !== '' ) {\n \t\t$spam = true; // bot filled it → status 'spam', no mail\n \t}\n \treturn $spam;\n }, 10, 2 );\n ```\n\n2. **Deploy it** into the headless `/cms` (activates on install; idempotent — re-deploy to update):\n\n ```json\n { \"operation\": \"hosting_deploy\",\n \"params\": {\n \"domain\": \"<domain>\",\n \"type\": \"wordpress-plugin\",\n \"path\": \"~/.hostinger/<domain>/plugins/cf7-headless-spamguard\",\n \"slug\": \"cf7-headless-spamguard\",\n \"headless\": true } }\n ```\n\n3. **Record** `contact_form.honeypot_field: \"your_website\"` in `site.json` (done in §2 step 3) so the\n frontend knows which decoy to render. Keep the plugin **generic** (no site-specific values) — it's one\n reusable artifact, not per-site code.\n\n> **Nonce note.** CF7's built-in spam check also flags nonce failure, but nonce verification is **inactive\n> for logged-out visitors by default** — which is why a plain headless submission returns `mail_sent`, not\n> `spam`. The guard adds the honeypot on top. Confirm end-to-end in validate (§5).\n\n---\n\n## 3 — What the frontend submits (Step 6 reference)\n\nThe feedback endpoint expects `multipart/form-data` with the form's own fields **plus** CF7's hidden\ncontrol fields. The frontend builds this in a `submitContactForm(data)` helper in the one data module:\n\n| Field | Value |\n|---|---|\n| each name in `contact_form.fields` | the user's input (`your-name`, `your-email`, …) |\n| `_wpcf7` | `contact_form.form_id` (number) |\n| `_wpcf7_version` | CF7 version string, e.g. `\"5.9.8\"` (not strictly validated) |\n| `_wpcf7_locale` | e.g. `\"en_US\"` |\n| `_wpcf7_unit_tag` | any stable string, e.g. `\"wpcf7-f<form_id>-o1\"` |\n| `_wpcf7_container_post` | `\"0\"` |\n| `contact_form.honeypot_field` (the decoy, e.g. `your_website`) | **empty** — rendered hidden/off-screen, `autocomplete=\"off\"`, `tabindex=\"-1\"`; the §2b guard rejects it as spam if filled |\n\n`POST` to `contact_form.feedback_url` and **do not set `Content-Type`** — let the browser add the\nmultipart boundary. Same-origin, so no CORS and no secret.\n\n**Response** is JSON:\n\n```json\n{ \"contact_form_id\": 42, \"status\": \"mail_sent\", \"message\": \"Thank you for your message. It has been sent.\",\n \"invalid_fields\": [], \"posted_data_hash\": \"…\" }\n```\n\nBranch on `status`:\n\n- `mail_sent` → success state (clear the form, show the thank-you message).\n- `validation_failed` → map each `invalid_fields[].field` to its input and show the message inline.\n- `spam` / `aborted` / `mail_failed` / `acceptance_missing` → a generic \"couldn't send, try again\" error.\n\nA user validation error is a **normal UI state, not a build error**. When `contact_form.enabled` is\n`false` or absent, the frontend renders the contact page with plain contact details and **no form**.\n\n---\n\n## 4 — Email delivery & the `wp_mail` caveat (what to tell the owner)\n\nCF7's default form mails `[_site_admin_email]` via `wp_mail()`, so **Hostinger does \"set up\" basic email\nby default** — nothing else to configure for the form to send. One caveat worth surfacing:\n\n- **Deliverability.** `wp_mail` from a shared host can land in spam for external recipients without\n SPF/DKIM. The most reliable recipient is a **Hostinger mailbox on the same domain**. Keep CF7's admin\n recipient; if the owner wants a different inbox, point them to a same-domain mailbox.\n\nDon't install an SMTP plugin or ask for mail credentials as part of this flow — the default `wp_mail`\npath is the intended behaviour; SMTP is an owner decision in wp-admin if deliverability needs hardening.\n\n---\n\n## 5 — Validate (Step 7): the two test sends\n\nRead from [`../../07-validate/SKILL.md`](../../07-validate/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nPOST one throwaway test submission (dummy\nname/email/subject/message + CF7's hidden `_wpcf7*` fields — see §3\nabove) to `contact_form.feedback_url` and assert the JSON\n`status` is **`mail_sent`**. This is the one place a real send happens, so one test email reaches the\nowner — not several. `mail_failed` is a real finding: surface it to the user (CF7 is wired, but\n`wp_mail` delivery/SPF needs attention — a Hostinger mailbox on the domain is the most reliable\nrecipient) and log it as an issue. A `validation_failed` means the test payload didn't match the form's\nfields — fix the field names in `site.json`, not the plugin.\n**Then check the honeypot:** POST a **second** throwaway submission with the same valid fields **plus**\n`contact_form.honeypot_field` **filled**, and assert the `status` is **`spam`** (no mail sent). Keep the\nreal fields valid — CF7 validates **before** running the spam filter, so an invalid payload would return\n`validation_failed` and never reach the honeypot check. A `mail_sent` here means the\n`cf7-headless-spamguard` plugin isn't active — surface it and re-check its deploy.\n\n---\n\n## 6 — Handover (Step 9)\n\nRead from [`../../09-done/SKILL.md`](../../09-done/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nIn the handover, tell the owner the contact page is live and enquiries email\nthe **WordPress admin address** (via `wp_mail`) — and that for the most reliable delivery that address\nshould be a Hostinger mailbox on the domain. If validate reported `mail_failed`, say so plainly instead\nof claiming the form sends.\n"
|
|
245
|
+
"text": "# headless — Contact Form 7 cookbook (contact form on headless WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the brief's **Must-haves**\ninclude a contact form (`site.json → contact_form.enabled: true`). The goal: a contact page whose form,\nsubmitted from the **decoupled frontend**, sends the enquiry to the site owner by email using\nWordPress's built-in `wp_mail()` — no third-party form service, no API keys, no secret on the client.\n\n**Contact Form 7 is not a separate backend.** It is the `contact-form-7` plugin on the same headless\nWordPress install at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for\nthe contact-form data layer: how to **resolve the form** (content-model push), **deploy a spam guard**,\nwhat the **frontend submits** (Step 6), and how **validate** proves mail actually leaves.\n\n---\n\n## 0 — Provision: verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.\n\n**Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then record\n`contact_form.enabled: true` in `site.json` (provision Step 6). If it's missing, CF7 didn't come up:\napply its fallback in provision Step 4.\n\nThen add the `contact_form` block to `site.json` (provision Step 6). Provision records only `enabled` +\n`plugin` here; §2 fills `form_id`, `feedback_url`, `fields` and `honeypot_field` once it resolves the form\nand deploys the spam guard:\n\n```json\n{\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": null,\n \"feedback_url\": null,\n \"fields\": [],\n \"honeypot_field\": null,\n \"recipient\": \"site-admin-email\"\n }\n}\n```\n\n`recipient` is informational — CF7's `To` is `[_site_admin_email]`; no address, token or secret is\nstored in `site.json`.\n\n---\n\n## 1 — Why CF7, and why it works headlessly\n\nYou **could** deploy a custom plugin into the headless `/cms` and write a bespoke mailer (see\n[`custom-plugins.md`](custom-plugins.md)), but a contact form is exactly the kind of maintained,\nspam-hardened functionality you should **reuse rather than reinvent**. CF7 is the right choice because:\n\n- It is a **wordpress.org-slug plugin** → provision Step 4 installs it like Yoast. No custom\n code to deploy.\n- It ships a **public, unauthenticated submit endpoint**:\n `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<form_id>/feedback`. Submissions don't need\n the JWT or any key.\n- The frontend (apex domain) and `/cms` are **same-origin**, so the browser posts straight to that\n endpoint — **no proxy route, no CORS, no credentials client-side.**\n- On submit CF7 runs its mail template through `wp_mail()`, which on Hostinger routes through the\n server's mailer. The default form's `To` is `[_site_admin_email]` — the admin address set at install —\n so **basic email delivery works out of the box.**\n\n**Spam protection comes from a tiny deployed plugin, not the Honeypot add-on.** CF7's own\n`contact-form-7-honeypot` add-on only acts when a `[honeypot]` form-tag is present in the form — a wp-admin\nedit the headless agent can't make — so on the default form it does **nothing**. Instead, deploy a\n~15-line `wpcf7_spam` guard into `/cms` (the capability from [`custom-plugins.md`](custom-plugins.md)): it\nrejects a submission whose decoy field is filled, with no owner step and no keys. See *§2b — Spam\nprotection* below. (reCAPTCHA is the alternative but needs owner-provided Google keys set in wp-admin —\nout of reach for the headless agent.)\n\n---\n\n## 2 — Content-model push: resolve the form and record it\n\nA fresh CF7 install ships one form, **\"Contact form 1\"**, with the default fields `your-name`,\n`your-email`, `your-subject`, `your-message` and a submit, and mails `[_site_admin_email]`. You need\nits **numeric form id** (and, if you tailored the form, its field names) to build `feedback_url`.\n\n> **Reality check — how to read the id.** The per-site WP MCP (Hostinger AI Assistant, discovery mode)\n> exposes **no generic REST/`RestEndpointTool` ability**, and `wpcf7_contact_form` is **not a public CPT**\n> (it is absent from `cpt-list-types` and from `wp/v2/types`), so the MCP cannot read the form, and CF7's\n> own `GET /contact-form-7/v1/contact-forms` is capability-gated (no public read). The reliable,\n> tool-free way is to **probe the public feedback endpoint**, which needs no auth.\n\n1. **Find the form id by probing the feedback endpoint (idempotent).** For `id` in a small range\n (`1`‒`30` covers a fresh install — the default form lands a few ids after the sample content), send a\n **`multipart/form-data`** `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<id>/feedback` with\n a single field `_wpcf7_unit_tag=wpcf7-f<id>-o1`. **The content type matters:** CF7 checks it *before*\n it looks up the id and answers **415** to any non-multipart body, so a bare POST returns non-404 for\n *every* id and would wrongly pick id 1.\n - **Hit** → `200` whose JSON body carries `\"contact_form_id\": <id>` (matching the id you probed) and a\n CF7 `\"status\"` (e.g. `validation_failed`). **This id is the form.** On a fresh single-form install\n that is the only hit; reuse it on a re-run.\n - **Miss** → `404` with `\"code\": \"wpcf7_not_found\"`. Keep going.\n - **Inconclusive** → anything else (`415` from a wrong content type, `403`, `429`, `5xx`) is **not** a\n hit — never select such an id. Fix the request or retry, widen the range, and fall back to the owner\n handoff (step 2) if nothing resolves.\n\n The default field names are `your-name`, `your-email`, `your-subject`, `your-message`. (A full test\n submission that confirms both the id and the field names — and that mail actually sends — belongs to\n **validate**, so you send just one real email; see §5.)\n\n2. **(Optional) tailor the form — owner-side.** The headless tooling can't edit the CF7 form (no REST\n ability reaches it). If the design needs different fields, keep the default form for the build and note\n it; the owner edits fields/recipient in wp-admin (Contact → Contact Forms) via the one-click login.\n The default form is enough for a name/email/subject/message enquiry, and its recipient\n (`[_site_admin_email]`) is already correct.\n\n3. **Record into `site.json`** — fill the `contact_form` block provision started:\n\n ```json\n {\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": 4,\n \"feedback_url\": \"https://<domain>/cms/wp-json/contact-form-7/v1/contact-forms/4/feedback\",\n \"fields\": [\"your-name\", \"your-email\", \"your-subject\", \"your-message\"],\n \"cf7_version\": \"6.2.2\",\n \"honeypot_field\": \"your_website\",\n \"recipient\": \"site-admin-email\"\n }\n }\n ```\n\n `cf7_version` is the installed CF7 version (from `wordpress_plugins_list-installed`) — the frontend\n sends it as `_wpcf7_version`. `honeypot_field` is the decoy the spam guard checks (§2b) — the frontend\n renders it empty and the server rejects a filled one. Also note the form id in `content-model.md`. No\n address, token or secret goes into `site.json`.\n\n> **Fallback if the probe finds nothing** (an unusual install, or the default form was removed): mint a\n> one-click wp-admin link (`wordpress_login_create-links { username, software }`) and ask the owner to\n> read the form id from **Contact → Contact Forms** (the shortcode shows `id=\"…\"`). Record it into\n> `site.json` and continue — the same owner-handoff used for the WooCommerce checkout gate, not a build\n> failure.\n\n> **Aside — Hostinger's own shortcode.** The per-site MCP's `pages-create` ability suggests\n> `[hostinger_contact_form]` for a contact form *inside a WordPress page*. That is server-rendered\n> shortcode output, not useful to a decoupled React frontend that reads REST JSON — this flow uses CF7's\n> JSON feedback endpoint instead. Mentioned only so the shortcode hint isn't mistaken for the headless path.\n\n---\n\n## 2b — Spam protection: deploy the honeypot guard\n\nCF7's default form has **no spam protection**, and the `contact-form-7-honeypot` add-on can't help\nheadlessly (it needs a `[honeypot]` form-tag only an owner can add — see §1). Instead, deploy a tiny\nplugin that enforces a honeypot **server-side**, on the same REST feedback path the frontend uses. This\nreuses the custom-plugin deploy from [`custom-plugins.md`](custom-plugins.md) — the only moving part is one\n~15-line file.\n\n**Why it works.** CF7's `wpcf7_spam` filter runs inside `submit()`, which the REST feedback endpoint\ncalls, so returning `true` sets the submission `status` to `spam` and **suppresses the mail**. The hook can\nread any posted field via `WPCF7_Submission::get_posted_data()` — including a decoy field that isn't a CF7\nform-tag, **as long as its name doesn't start with `_`** (CF7 strips `_`-prefixed keys). So the frontend\nsends a decoy field (empty for humans), and the guard flags the submission as spam when a bot fills it.\n\n1. **Write the guard** to `~/.hostinger/<domain>/plugins/cf7-headless-spamguard/cf7-headless-spamguard.php`:\n\n ```php\n <?php\n /**\n * Plugin Name: CF7 Headless Spam Guard\n * Description: Server-side honeypot for Contact Form 7 submissions from a headless frontend.\n * Version: 1.0.0\n * Requires PHP: 7.4\n * License: GPL-2.0-or-later\n */\n if ( ! defined( 'ABSPATH' ) ) { exit; }\n\n // Reject a submission whose decoy field is filled. The name is a fixed convention the frontend\n // renders empty (site.json → contact_form.honeypot_field); it must NOT start with \"_\".\n add_filter( 'wpcf7_spam', function ( $spam, $submission ) {\n \tif ( $spam ) { return $spam; } // keep any earlier spam verdict\n \t$decoy = $submission->get_posted_data( 'your_website' );\n \tif ( is_string( $decoy ) && trim( $decoy ) !== '' ) {\n \t\t$spam = true; // bot filled it → status 'spam', no mail\n \t}\n \treturn $spam;\n }, 10, 2 );\n ```\n\n2. **Deploy it** into the headless `/cms` (activates on install; idempotent — re-deploy to update):\n\n ```json\n { \"operation\": \"hosting_deploy\",\n \"params\": {\n \"domain\": \"<domain>\",\n \"type\": \"wordpress-plugin\",\n \"path\": \"~/.hostinger/<domain>/plugins/cf7-headless-spamguard\",\n \"slug\": \"cf7-headless-spamguard\",\n \"headless\": true } }\n ```\n\n3. **Record** `contact_form.honeypot_field: \"your_website\"` in `site.json` (done in §2 step 3) so the\n frontend knows which decoy to render. Keep the plugin **generic** (no site-specific values) — it's one\n reusable artifact, not per-site code.\n\n> **Nonce note.** CF7's built-in spam check also flags nonce failure, but nonce verification is **inactive\n> for logged-out visitors by default** — which is why a plain headless submission returns `mail_sent`, not\n> `spam`. The guard adds the honeypot on top. Confirm end-to-end in validate (§5).\n\n---\n\n## 3 — What the frontend submits (Step 6 reference)\n\nThe feedback endpoint expects `multipart/form-data` with the form's own fields **plus** CF7's hidden\ncontrol fields. The frontend builds this in a `submitContactForm(data)` helper in the one data module:\n\n| Field | Value |\n|---|---|\n| each name in `contact_form.fields` | the user's input (`your-name`, `your-email`, …) |\n| `_wpcf7` | `contact_form.form_id` (number) |\n| `_wpcf7_version` | CF7 version string, e.g. `\"5.9.8\"` (not strictly validated) |\n| `_wpcf7_locale` | e.g. `\"en_US\"` |\n| `_wpcf7_unit_tag` | any stable string, e.g. `\"wpcf7-f<form_id>-o1\"` |\n| `_wpcf7_container_post` | `\"0\"` |\n| `contact_form.honeypot_field` (the decoy, e.g. `your_website`) | **empty** — rendered hidden/off-screen, `autocomplete=\"off\"`, `tabindex=\"-1\"`; the §2b guard rejects it as spam if filled |\n\n`POST` to `contact_form.feedback_url` and **do not set `Content-Type`** — let the browser add the\nmultipart boundary. Same-origin, so no CORS and no secret.\n\n**Response** is JSON:\n\n```json\n{ \"contact_form_id\": 42, \"status\": \"mail_sent\", \"message\": \"Thank you for your message. It has been sent.\",\n \"invalid_fields\": [], \"posted_data_hash\": \"…\" }\n```\n\nBranch on `status`:\n\n- `mail_sent` → success state (clear the form, show the thank-you message).\n- `validation_failed` → map each `invalid_fields[].field` to its input and show the message inline.\n- `spam` / `aborted` / `mail_failed` / `acceptance_missing` → a generic \"couldn't send, try again\" error.\n\nA user validation error is a **normal UI state, not a build error**. When `contact_form.enabled` is\n`false` or absent, the frontend renders the contact page with plain contact details and **no form**.\n\n---\n\n## 4 — Email delivery & the `wp_mail` caveat (what to tell the owner)\n\nCF7's default form mails `[_site_admin_email]` via `wp_mail()`, so **Hostinger does \"set up\" basic email\nby default** — nothing else to configure for the form to send. One caveat worth surfacing:\n\n- **Deliverability.** `wp_mail` from a shared host can land in spam for external recipients without\n SPF/DKIM. The most reliable recipient is a **Hostinger mailbox on the same domain**. Keep CF7's admin\n recipient; if the owner wants a different inbox, point them to a same-domain mailbox.\n\nDon't install an SMTP plugin or ask for mail credentials as part of this flow — the default `wp_mail`\npath is the intended behaviour; SMTP is an owner decision in wp-admin if deliverability needs hardening.\n\n---\n\n## 5 — Validate (Step 7): the two test sends\n\nRead from [`../../07-validate/SKILL.md`](../../07-validate/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nPOST one throwaway test submission (dummy\nname/email/subject/message + CF7's hidden `_wpcf7*` fields — see §3\nabove) to `contact_form.feedback_url` and assert the JSON\n`status` is **`mail_sent`**. This is the one place a real send happens, so one test email reaches the\nowner — not several. `mail_failed` is a real finding: surface it to the user (CF7 is wired, but\n`wp_mail` delivery/SPF needs attention — a Hostinger mailbox on the domain is the most reliable\nrecipient) and log it as an issue. A `validation_failed` means the test payload didn't match the form's\nfields — fix the field names in `site.json`, not the plugin.\n**Then check the honeypot:** POST a **second** throwaway submission with the same valid fields **plus**\n`contact_form.honeypot_field` **filled**, and assert the `status` is **`spam`** (no mail sent). Keep the\nreal fields valid — CF7 validates **before** running the spam filter, so an invalid payload would return\n`validation_failed` and never reach the honeypot check. A `mail_sent` here means the\n`cf7-headless-spamguard` plugin isn't active — surface it and re-check its deploy.\n\n---\n\n## 6 — Handover (Step 9)\n\nRead from [`../../09-done/SKILL.md`](../../09-done/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nIn the handover, tell the owner the contact page is live and enquiries email\nthe **WordPress admin address** (via `wp_mail`) — and that for the most reliable delivery that address\nshould be a Hostinger mailbox on the domain. If validate reported `mail_failed`, say so plainly instead\nof claiming the form sends.\n"
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/custom-plugins.md",
|
|
@@ -253,10 +253,10 @@ export default [
|
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/woocommerce.md",
|
|
256
|
-
"digest": "sha256:
|
|
257
|
-
"size":
|
|
256
|
+
"digest": "sha256:9590fe55049b43390faef7b72d69a95be944d2b97d18232c9af43408f7ad8abf",
|
|
257
|
+
"size": 9344,
|
|
258
258
|
"mimeType": "text/markdown",
|
|
259
|
-
"text": "# headless — WooCommerce cookbook (headless store on WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the WordPress backend carries\na **WooCommerce store** (`site.json → woocommerce.enabled: true`) — a brief whose **Suggested backend** is\n`**WordPress + WooCommerce**` (one site: content **and** commerce).\n\n**WooCommerce is not a separate backend.** It is the `woocommerce` plugin on a normal headless WordPress\ninstall at `/cms` (installed at provision, §0). This cookbook is the authoritative home for the store\ndata layer: how to **seed and CRUD** products, categories and coupons, and how the **storefront** reads\nthe cart, coupons and checkout.\n\n---\n\n## 0 — Provision: install, verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5. This is **join-half** work (needs the live instance): run it once\n`provision.status == \"completed\"`.\n\n1. **Install + activate WooCommerce** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"woocommerce\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `woocommerce` shows `active`\n (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"woocommerce\" }`.\n - Confirm with `wordpress_plugins_check-if-woo-commerce-is-installed { domain: \"<domain>\" }`. Allow a\n moment for WooCommerce's installer to create its tables and the Shop/Cart/Checkout pages.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded** (seen on both `plugins_install` and `jwt-token`). Treat a 500 as \"verify, don't assume\":\n poll `list-installed` / re-check before retrying, and never fire a second install blindly.\n2. **Verify the store endpoints (public, no auth):**\n\n | Check | How | Expect |\n |---|---|---|\n | WooCommerce active | `wordpress_plugins_check-if-woo-commerce-is-installed { domain }` | installed + active |\n | Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |\n | Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |\n\n Pretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a\n store route ever 404s, the permalink structure is the thing to check.\n\nThen add the `woocommerce` block and the store URLs to `site.json` (provision Step 6; `backend` stays\n`\"wordpress\"`). Checkout stays off until the owner sets it up (§4), so `payment_enabled` starts `false`:\n\n```json\n{\n \"woocommerce\": {\n \"enabled\": true,\n \"seeded_via\": \"per-site-wp-mcp\",\n \"currency\": \"<currency_code from GET {store_api}/products or the install default>\",\n \"payment_enabled\": false,\n \"checkout_setup\": \"owner enables a payment method + shipping in wp-admin\"\n },\n \"urls\": {\n \"store_api\": \"https://<domain>/cms/wp-json/wc/store/v1\",\n \"wc_rest_api\": \"https://<domain>/cms/wp-json/wc/v3\"\n }\n}\n```\n\n---\n\n## 1 — The one rule: drive the store through the per-site WP MCP\n\nThere is **no seed plugin, no WP-CLI, and no REST consumer key in this flow**: catalog data goes through\nthe WP MCP. Instead, the **per-site WP MCP** (the Hostinger AI Assistant — the same JWT session the WordPress\ncontent push uses, see `SKILL.md`) exposes **native WooCommerce abilities**. The push seeds the\ncatalog through them (§3); call them yourself only by hand or for work after the push.\n\nRelevant abilities (names from `hostinger-ai-discover-abilities`; call `get-ability-info` for each schema\nbefore use — they mirror the WooCommerce REST v3 shapes):\n\n| Area | Abilities |\n|---|---|\n| Products | `wc-products-search` · `wc-products-get` · `wc-products-create` · `wc-products-update` · `wc-products-delete` |\n| Categories / tags / brands | `wc-product-categories-{list,create,update,delete}` · `wc-product-tags-*` · `wc-product-brands-*` |\n| Coupons | `wc-coupons-{search,get,create,update,delete,batch}` |\n| Orders | `wc-orders-{search,get,create,update,delete}` |\n| Reports | `wc-reports-{sales,orders-totals,products-totals,coupons-totals,…}` |\n| Media | `media-upload-from-url` (product images — WordPress keeps its own copy) |\n\nAll run as the install's admin **inside the MCP session** — no consumer keys, no Basic Auth. This is\nproven: a `wc-products-create` call makes a product that immediately appears on the public Store API.\n\n---\n\n## 2 — The storefront reads the public Store API\n\nThe **frontend** never touches the per-site MCP or any key. It reads the **public WooCommerce Store API**\nat `site.json → urls.store_api` (`/cms/wp-json/wc/store/v1`) — public, open CORS, no auth for reads.\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately.\n\n| Store API call | Use |\n|---|---|\n| `GET /products?per_page=100` · `GET /products/<id>` · `?slug=<slug>` | catalog + product pages |\n| `GET /products/categories` | category nav |\n| `GET /cart` | current cart (seeds the `Cart-Token`) |\n| `POST /cart/add-item` `{ id, quantity }` · `/cart/update-item` `{ key, quantity }` · `/cart/remove-item` `{ key }` | cart mutations |\n| `POST /cart/apply-coupon` `{ code }` · `/cart/remove-coupon` `{ code }` | coupons on the cart |\n| `POST /checkout` `{ billing_address, shipping_address, payment_method }` | place an order |\n\n**Store API auth for writes** (cart/checkout): send the **`Nonce`** header (read it from the `Nonce` /\n`X-WC-Store-API-Nonce` response header of a prior Store API GET and echo it back) **and** the\n**`Cart-Token`** header (a JWT the Store API returns on the first cart response — resend it on every\ncart call so a headless client keeps one cart; persist it in `localStorage`). Reads need neither.\n\n**Pricing / minor units.** The Store API returns **integer-string** prices in minor units plus the\ndivisor: `prices.price` (e.g. `\"1999\"`) with `prices.currency_minor_unit` (e.g. `2`) and\n`prices.currency_code`. Display value = `Number(price) / 10 ** currency_minor_unit`. **Pagination:**\n`?page=&per_page=` (max 100), with `X-WP-Total` / `X-WP-TotalPages` headers.\n\n---\n\n## 3 — Seeding the catalog (content-model push)\n\nThe push seeds the catalog with the rest of the content: put product categories, products and coupons\nunder `store` in `content.json` and run `push-content.mjs` (`SKILL.md` Steps 1–2). It looks categories up\nby slug, products by **SKU** and coupons by **code** before creating, so a re-run never duplicates; uploads\neach product image once; checks every SKU and category over the Store API; and records the ids under\n`## Created in WooCommerce` in `content-model.md`.\n\n- `price` is a decimal string in **major units** (`\"39.99\"`); the Store API re-exposes it in minor units.\n- Any other WooCommerce product field passes through as given (`sale_price`, `stock_quantity`,\n `attributes`, …). For a **variable product**, the push creates the parent; add its variations by hand\n through the product update / variations ability that discovery lists.\n- Coupons: `discount_type` is `percent`, `fixed_cart` or `fixed_product`. WooCommerce stores codes in\n lower case.\n\n---\n\n## 4 — Checkout is owner-completed (the one gate)\n\nA fresh WooCommerce install has **no payment gateway and no shipping zone enabled**, and **neither is\nreachable from the headless tooling** — there is no payment/shipping MCP ability, and `wp-settings-update`\nonly writes standard WordPress settings (it ignores `woocommerce_*` options). So:\n\n- **The catalog, product pages, client-side cart and coupon application all work headlessly.**\n- **Checkout (`POST /checkout`) does not work until the owner enables a payment method + a shipping zone\n in wp-admin** (WooCommerce → Settings → Payments / Shipping; reach it via the one-click login in `steps/09-done/SKILL.md`).\n Cash on Delivery is the zero-config choice once enabled.\n- Treat this exactly like the Hostinger Ecommerce `payment_enabled: false` gate: record\n `woocommerce.payment_enabled: false`, tell the user in one line that checkout needs that one setup step,\n and **never block the build on it**. The frontend renders a graceful disabled-checkout state and does not\n call `/checkout` while `payment_enabled` is `false`. Flip it to `true` only after the owner confirms a\n gateway is live. **Never ask the user for payment credentials.**\n\nStore **currency** and **address** (`woocommerce_*` options) likewise aren't settable headlessly — they\nfollow the install default; the owner changes them in wp-admin if needed.\n\n---\n\n## 5 — REST API v3 (optional, owner-only — not used by this flow)\n\nWooCommerce also exposes the authenticated **REST API v3** at `site.json → urls.wc_rest_api`\n(`/cms/wp-json/wc/v3`) for external/server-side integrations. **This build never uses it** — seeding goes\nthrough the per-site MCP and the storefront uses the public Store API. Document it for the owner only:\n\n- **Auth:** `Authorization: Basic base64(\"<consumer_key>:<consumer_secret>\")`, **HTTPS only**, server-side\n only — **never ship a key to the browser.**\n- **Keys:** the owner generates a key pair in **wp-admin → WooCommerce → Settings → Advanced → REST API**\n (the agent cannot mint one headlessly). Store it in the owner's own environment, not in `site.json` or\n the repo.\n- **Endpoints** (same shapes as the abilities above): `GET/POST/PUT/DELETE /products`, `/products/<id>/variations`,\n `/products/categories`, `/coupons`, `/orders`. Idempotency via `?sku=` / `?code=`. Pagination via\n `?page=&per_page=` + `X-WP-Total`.\n\n---\n\n## 6 — Idempotency & verification checklist\n\n- **Idempotency keys:** products → SKU, coupons → code, categories → slug, images → skip when the product\n already has `images`. `push-content.mjs` applies them; follow them too when seeding by hand.\n- **Checkout** is verified only when `payment_enabled` is `true`; while `false`, the catalog and cart over\n the Store API are the whole job.\n"
|
|
259
|
+
"text": "# headless — WooCommerce cookbook (headless store on WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the WordPress backend carries\na **WooCommerce store** (`site.json → woocommerce.enabled: true`) — a brief whose **Suggested backend** is\n`**WordPress + WooCommerce**` (one site: content **and** commerce).\n\n**WooCommerce is not a separate backend.** It is the `woocommerce` plugin on a normal headless WordPress\ninstall at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for the store\ndata layer: how to **seed and CRUD** products, categories and coupons, and how the **storefront** reads\nthe cart, coupons and checkout.\n\n---\n\n## 0 — Provision: verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.\n\n**Verify the store endpoints (public, no auth).** Allow a moment for WooCommerce's installer to create\nits tables and the Shop/Cart/Checkout pages. Provision Step 4's `list-installed` poll is the install\ncheck: `wordpress_plugins_check-if-woo-commerce-is-installed` answers `is_installed: false` on a headless\n`/cms` install even with WooCommerce active, so don't use it.\n\n| Check | How | Expect |\n|---|---|---|\n| Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |\n| Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |\n\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a\nstore route ever 404s, the permalink structure is the thing to check.\n\nThen add the `woocommerce` block and the store URLs to `site.json` (provision Step 6; `backend` stays\n`\"wordpress\"`). Checkout stays off until the owner sets it up (§4), so `payment_enabled` starts `false`:\n\n```json\n{\n \"woocommerce\": {\n \"enabled\": true,\n \"seeded_via\": \"per-site-wp-mcp\",\n \"currency\": \"<currency_code from GET {store_api}/products or the install default>\",\n \"payment_enabled\": false,\n \"checkout_setup\": \"owner enables a payment method + shipping in wp-admin\"\n },\n \"urls\": {\n \"store_api\": \"https://<domain>/cms/wp-json/wc/store/v1\",\n \"wc_rest_api\": \"https://<domain>/cms/wp-json/wc/v3\"\n }\n}\n```\n\n---\n\n## 1 — The one rule: drive the store through the per-site WP MCP\n\nThere is **no seed plugin, no WP-CLI, and no REST consumer key in this flow**: catalog data goes through\nthe WP MCP. Instead, the **per-site WP MCP** (the Hostinger AI Assistant — the same JWT session the WordPress\ncontent push uses, see `SKILL.md`) exposes **native WooCommerce abilities**. The push seeds the\ncatalog through them (§3); call them yourself only by hand or for work after the push.\n\nRelevant abilities (names from `hostinger-ai-discover-abilities`; call `get-ability-info` for each schema\nbefore use — they mirror the WooCommerce REST v3 shapes):\n\n| Area | Abilities |\n|---|---|\n| Products | `wc-products-search` · `wc-products-get` · `wc-products-create` · `wc-products-update` · `wc-products-delete` |\n| Categories / tags / brands | `wc-product-categories-{list,create,update,delete}` · `wc-product-tags-*` · `wc-product-brands-*` |\n| Coupons | `wc-coupons-{search,get,create,update,delete,batch}` |\n| Orders | `wc-orders-{search,get,create,update,delete}` |\n| Reports | `wc-reports-{sales,orders-totals,products-totals,coupons-totals,…}` |\n| Media | `media-upload-from-url` (product images — WordPress keeps its own copy) |\n\nAll run as the install's admin **inside the MCP session** — no consumer keys, no Basic Auth. This is\nproven: a `wc-products-create` call makes a product that immediately appears on the public Store API.\n\n---\n\n## 2 — The storefront reads the public Store API\n\nThe **frontend** never touches the per-site MCP or any key. It reads the **public WooCommerce Store API**\nat `site.json → urls.store_api` (`/cms/wp-json/wc/store/v1`) — public, open CORS, no auth for reads.\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately.\n\n| Store API call | Use |\n|---|---|\n| `GET /products?per_page=100` · `GET /products/<id>` · `?slug=<slug>` | catalog + product pages |\n| `GET /products/categories` | category nav |\n| `GET /cart` | current cart (seeds the `Cart-Token`) |\n| `POST /cart/add-item` `{ id, quantity }` · `/cart/update-item` `{ key, quantity }` · `/cart/remove-item` `{ key }` | cart mutations |\n| `POST /cart/apply-coupon` `{ code }` · `/cart/remove-coupon` `{ code }` | coupons on the cart |\n| `POST /checkout` `{ billing_address, shipping_address, payment_method }` | place an order |\n\n**Store API auth for writes** (cart/checkout): send the **`Nonce`** header (read it from the `Nonce` /\n`X-WC-Store-API-Nonce` response header of a prior Store API GET and echo it back) **and** the\n**`Cart-Token`** header (a JWT the Store API returns on the first cart response — resend it on every\ncart call so a headless client keeps one cart; persist it in `localStorage`). Reads need neither.\n\n**Pricing / minor units.** The Store API returns **integer-string** prices in minor units plus the\ndivisor: `prices.price` (e.g. `\"1999\"`) with `prices.currency_minor_unit` (e.g. `2`) and\n`prices.currency_code`. Display value = `Number(price) / 10 ** currency_minor_unit`. **Pagination:**\n`?page=&per_page=` (max 100), with `X-WP-Total` / `X-WP-TotalPages` headers.\n\n---\n\n## 3 — Seeding the catalog (content-model push)\n\nThe push seeds the catalog with the rest of the content: put product categories, products and coupons\nunder `store` in `content.json` and run `push-content.mjs` (`SKILL.md` Steps 1–2). It looks categories up\nby slug, products by **SKU** and coupons by **code** before creating, so a re-run never duplicates; uploads\neach product image once; checks every SKU and category over the Store API; and records the ids under\n`## Created in WooCommerce` in `content-model.md`.\n\n- `price` is a decimal string in **major units** (`\"39.99\"`); the Store API re-exposes it in minor units.\n- Any other WooCommerce product field passes through as given (`sale_price`, `stock_quantity`,\n `attributes`, …). For a **variable product**, the push creates the parent; add its variations by hand\n through the product update / variations ability that discovery lists.\n- Coupons: `discount_type` is `percent`, `fixed_cart` or `fixed_product`. WooCommerce stores codes in\n lower case.\n\n---\n\n## 4 — Checkout is owner-completed (the one gate)\n\nA fresh WooCommerce install has **no payment gateway and no shipping zone enabled**, and **neither is\nreachable from the headless tooling** — there is no payment/shipping MCP ability, and `wp-settings-update`\nonly writes standard WordPress settings (it ignores `woocommerce_*` options). So:\n\n- **The catalog, product pages, client-side cart and coupon application all work headlessly.**\n- **Checkout (`POST /checkout`) does not work until the owner enables a payment method + a shipping zone\n in wp-admin** (WooCommerce → Settings → Payments / Shipping; reach it via the one-click login in `steps/09-done/SKILL.md`).\n Cash on Delivery is the zero-config choice once enabled.\n- Treat this exactly like the Hostinger Ecommerce `payment_enabled: false` gate: record\n `woocommerce.payment_enabled: false`, tell the user in one line that checkout needs that one setup step,\n and **never block the build on it**. The frontend renders a graceful disabled-checkout state and does not\n call `/checkout` while `payment_enabled` is `false`. Flip it to `true` only after the owner confirms a\n gateway is live. **Never ask the user for payment credentials.**\n\nStore **currency** and **address** (`woocommerce_*` options) likewise aren't settable headlessly — they\nfollow the install default; the owner changes them in wp-admin if needed.\n\n---\n\n## 5 — REST API v3 (optional, owner-only — not used by this flow)\n\nWooCommerce also exposes the authenticated **REST API v3** at `site.json → urls.wc_rest_api`\n(`/cms/wp-json/wc/v3`) for external/server-side integrations. **This build never uses it** — seeding goes\nthrough the per-site MCP and the storefront uses the public Store API. Document it for the owner only:\n\n- **Auth:** `Authorization: Basic base64(\"<consumer_key>:<consumer_secret>\")`, **HTTPS only**, server-side\n only — **never ship a key to the browser.**\n- **Keys:** the owner generates a key pair in **wp-admin → WooCommerce → Settings → Advanced → REST API**\n (the agent cannot mint one headlessly). Store it in the owner's own environment, not in `site.json` or\n the repo.\n- **Endpoints** (same shapes as the abilities above): `GET/POST/PUT/DELETE /products`, `/products/<id>/variations`,\n `/products/categories`, `/coupons`, `/orders`. Idempotency via `?sku=` / `?code=`. Pagination via\n `?page=&per_page=` + `X-WP-Total`.\n\n---\n\n## 6 — Idempotency & verification checklist\n\n- **Idempotency keys:** products → SKU, coupons → code, categories → slug, images → skip when the product\n already has `images`. `push-content.mjs` applies them; follow them too when seeding by hand.\n- **Checkout** is verified only when `payment_enabled` is `true`; while `false`, the catalog and cart over\n the Store API are the whole job.\n"
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
262
|
"uri": "skill://hostinger-headless/steps/05-design/SKILL.md",
|
package/src/core/skills.ts
CHANGED
|
@@ -190,10 +190,10 @@ const skills: Skill[] = [
|
|
|
190
190
|
},
|
|
191
191
|
{
|
|
192
192
|
"uri": "skill://hostinger-headless/steps/03-provision/SKILL.md",
|
|
193
|
-
"digest": "sha256:
|
|
194
|
-
"size":
|
|
193
|
+
"digest": "sha256:bf7307c10a493e01561057c29350b77e079e5d338971405dccb0d0c763b7ead1",
|
|
194
|
+
"size": 5608,
|
|
195
195
|
"mimeType": "text/markdown",
|
|
196
|
-
"text": "---\nname: headless-step-provision\ndescription: \"Step 3 (provision) of the Hostinger Headless flow. Chooses the backend from brief.md (wordpress | ecommerce | webapp), then routes to the matching subfolder to provision it; writes site.json. WordPress + WooCommerce routes to the wordpress subfolder with the WooCommerce store turned on — it is not a separate backend.\"\n---\n\n# headless-step-provision\n\nRouter. The backend is decided in **refine** and recorded in `brief.md`; this step only routes to the\nmatching subfolder, which provisions it.\n\n**In:** `brief.md`. **Out:** `site.json` (written by the subfolder).\n\n## Step 1 — Route on the suggested backend\n\nRead the brief's **Suggested backend** section:\n\n| Suggested backend | Follow |\n|---|---|\n| WordPress | `wordpress/SKILL.md` |\n| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its
|
|
196
|
+
"text": "---\nname: headless-step-provision\ndescription: \"Step 3 (provision) of the Hostinger Headless flow. Chooses the backend from brief.md (wordpress | ecommerce | webapp), then routes to the matching subfolder to provision it; writes site.json. WordPress + WooCommerce routes to the wordpress subfolder with the WooCommerce store turned on — it is not a separate backend.\"\n---\n\n# headless-step-provision\n\nRouter. The backend is decided in **refine** and recorded in `brief.md`; this step only routes to the\nmatching subfolder, which provisions it.\n\n**In:** `brief.md`. **Out:** `site.json` (written by the subfolder).\n\n## Step 1 — Route on the suggested backend\n\nRead the brief's **Suggested backend** section:\n\n| Suggested backend | Follow |\n|---|---|\n| WordPress | `wordpress/SKILL.md` |\n| WordPress + WooCommerce | `wordpress/SKILL.md` **with the WooCommerce store on** (its Steps 4–5; `site.json → backend` stays `\"wordpress\"`) |\n| Ecommerce | `ecommerce/SKILL.md` |\n| Webapp | `webapp/SKILL.md` |\n\nIf the section is missing or names something else, go back to **refine** — don't pick one here.\nTell the user the backend and its one-line reason before provisioning.\n\n> **Supported backends: `wordpress` (optionally with a WooCommerce store), `ecommerce` and `webapp`.**\n> `webapp` is a plain Node.js app host (an empty website — no CMS, no store, no `/cms`) for any app/SPA\n> that brings its own code and data; it never installs WordPress. PocketBase is not available in this\n> version — refine never proposes it, and there is no `pocketbase/` subfolder; if a brief somehow names\n> it, stop and tell the user rather than improvising it. A **WordPress + Ecommerce** brief (two separate\n> backends — a WordPress site **and** a Hostinger Ecommerce store) has no single combined `hosting_websites_create`\n> type yet: stop, tell the user it isn't supported as one site, and offer either to continue with just\n> WordPress or just Ecommerce (route to that one subfolder), **or**, if they want content and a store on\n> **one** site, to switch the brief to **WordPress + WooCommerce** — the one-site path, which routes to\n> `wordpress/SKILL.md` with the store on.\n\n## Onboarding handoff — swap an existing empty headless shell (do this before creating anything)\n\nOnboarding can create the website **before** you ever run, as an **empty headless shell**\n(`hosting_websites_create { type: \"headless_empty\" }`: `website_type` is `headless`, but **nothing\nis installed**). The single-instance gate in Step 2 is the checklist.\n\n> **Webapp is not part of this handoff at all.** `webapp` is **not** reached on the usual onboarding\n> flow — it is only triggered by experimental actions — so it **ignores headless instances entirely**:\n> it never detects, adopts or swaps an empty headless shell, and provisions its own **Node.js app host**\n> exactly as `webapp/SKILL.md` defines today. The swap below is **WordPress and Ecommerce only**.\n>\n> **But webapp must still never create a second instance for this build.** Only route here when the\n> brief's backend is `webapp` — a `wordpress` or `ecommerce` brief is never provisioned as a webapp. And\n> if this build's domain already has a headless shell/site (an onboarding `headless_empty`, or any row\n> from the single-instance gate below), **do not** spin up a separate Node.js host on another domain:\n> stop and tell the user the domain already has a headless instance, rather than leaving the build split\n> across two sites.\n\n## Step 2 — Fire (don't block)\n\n> **Single-instance gate — pass all four before you create anything:**\n> 1. **Exact-match the domain** in `hosting_websites_list` (substring filter — match the exact `domain`).\n> 2. **A `headless` row already exists → adopt + swap it, never create.** Install the backend into that\n> same site (WordPress → `wordpress_installations_install { type: \"headless\" }` into `/cms`; Ecommerce\n> → adopt as the storefront host). **Do not call `hosting_websites_create` again** — that makes a second site.\n> 3. **No row at all → create one fresh** with the backend's own `hosting_websites_create` type. Create it for **this\n> build's domain only** — never provision the backend on a different domain than the frontend (the CMS\n> is the `/cms` path of the same site, never a separate `cms.<domain>`).\n> 4. **A row of a different kind** (`website_type` not `headless`) → **stop and tell the user**; never\n> overwrite it.\n>\n> `wordpress/SKILL.md` Step 1 and `ecommerce/SKILL.md` Step 1 say how to tell an empty shell from an\n> already-provisioned backend.\n\nFollow the chosen subfolder's `SKILL.md` through **detect + create** (its `hosting_websites_create` call). The\nmoment the create is accepted and queued, record it in `state.json` and **return** — do not wait for\nit yet:\n\n```json\n{ \"stage\": \"content_model\",\n \"provision\": { \"status\": \"in_progress\", \"domain\": \"<domain>\", \"started_at\": \"<now>\" } }\n```\n\nNow go run the prepare work that doesn't need the backend (content-model prepare, frontend\nshell). The subfolder's readiness poll, verification and `site.json` are the **join** half below.\n\n## Step 3 — Join (at the instance barrier)\n\nWhen an instance-barrier step is about to run (content-model push, frontend data wiring, deploy) — or\nright away, if the agent can't interleave — finish the subfolder's `SKILL.md`: run its `wait.mjs` (it\nreturns at once if the job is already done), run its verification, and write `site.json` (which\nrecords the chosen `backend`). Then set `provision.status` to `\"completed\"` in `state.json` with a\nfresh `updated_at`.\n\n"
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
"uri": "skill://hostinger-headless/steps/03-provision/ecommerce/SKILL.md",
|
|
@@ -211,10 +211,10 @@ const skills: Skill[] = [
|
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
213
|
"uri": "skill://hostinger-headless/steps/03-provision/wordpress/SKILL.md",
|
|
214
|
-
"digest": "sha256:
|
|
215
|
-
"size":
|
|
214
|
+
"digest": "sha256:075bfc73772420e58236f57e1447ed010f67ddc2c45a8a4f5ffeb95c18ab9285",
|
|
215
|
+
"size": 11427,
|
|
216
216
|
"mimeType": "text/markdown",
|
|
217
|
-
"text": "---\nname: headless-step-provision-wordpress\ndescription: \"Provision a headless WordPress backend for the Hostinger Headless flow: create the headless website with WordPress at /cms, verify and self-heal, then record it in site.json.\"\n---\n\n# headless-step-provision-wordpress\n\nCreate the headless WordPress backend for `<domain>` and prove it is ready. One platform call lays\nevery headless site out identically: WordPress in `public_html/cms`, Hostinger AI Assistant + MCP\nadapter, site marked `headless`. **Out:** `site.json`.\n\nAll operations below go through the Hostinger connector (`execute`).\n\n> **Fire vs join (background provision).** Step 1, plus the queuing call — `hosting_websites_create`\n> for a fresh site (Step 2) **or** `wordpress_installations_install` to swap an empty headless shell\n> (Step 2b) — are the **fire** half: once the job is queued, record `provision.in_progress` and return\n> to do prepare work (see the router `../SKILL.md`). The readiness **poll** at the end of Step 2 / 2b,\n> plus Steps 3–6, are the **join** half — run them when an instance-barrier step needs the backend (or\n> immediately, if the agent can't interleave). An already-`completed` site with WordPress at `/cms`\n> detected in Step 1 means provision is already done: record `provision.completed` and adopt it.\n\n## Step 1 — Detect before you create (never provision twice)\n\n1. `hosting_websites_list { \"domain\": \"<domain>\" }` — substring filter, so **exact-match** the row's\n `domain`. If a row exists, note `username`, `order_id`, `website_type`.\n2. **No exact row** → nothing exists on this domain → **create fresh** (Step 2).\n3. **A row exists.** If `website_type` is **not** `headless`, stop and tell the user — this domain\n already hosts a different kind of site (plain WordPress, Node.js, builder, …); never overwrite it.\n If it **is** `headless`, work out whether WordPress is already installed or the shell is still empty:\n check `hosting_websites_list-setups { \"domain\": \"<domain>\" }`\n (exact row) and `wordpress_installations_list { username, domain, ownership: \"all\" }` (exact row):\n - Setup `running` → provisioning is underway → skip to Step 2's poll.\n - Setup `failed` → tell the user and point them at hPanel; do **not** call `hosting_websites_create` again yourself.\n - A WordPress install with `directory: \"cms\"` already present (or setup `type: headless_wordpress`)\n → **already provisioned** → skip to Step 3 (adopt it).\n - A `headless` site with **no** `/cms` install (an **empty headless shell** — setup\n `type: headless_empty`, typically from onboarding) → **swap it to WordPress** (Step 2b). Do **not**\n call `hosting_websites_create` again — the website already exists; you only install WordPress into it.\n\n## Step 2 — Create a fresh headless WordPress site (only when no site exists)\n\n1. Pick the plan: `hosting_orders_list { \"statuses\": [\"active\"] }`. One active order → use it; several\n → ask the user which.\n2. Start the setup:\n\n ```json\n { \"operation\": \"hosting_websites_create\",\n \"params\": { \"order_id\": <order_id>, \"type\": \"headless_wordpress\", \"domain\": \"<domain>\" } }\n ```\n\n `domain` must be a **customer-owned** domain. For a temporary `*.hostingersite.com` subdomain,\n **omit `domain`** — the setup generates one itself and returns it in the response. Don't call a\n separate subdomain op to make one first: there's no need in this flow. The response then carries the\n generated domain: if it differs from the workspace directory name, move `~/.hostinger/<old>/` to\n `~/.hostinger/<new>/`\n (if `<new>/` already exists, stop and ask instead of moving into it),\n update the domain in `brief.md`, and tell the user the new domain.\n Admin credentials are generated by the platform; never ask the user for a password.\n3. Don't wait here. At the join, `cd \"$HOME\" && node <skill>/wait.mjs setup <domain>` (see *Waiting on Hostinger* in\n the top-level `SKILL.md`) returns once the setup is `completed`, usually at once by then. A `failed`\n setup → stop, point at hPanel.\n\n## Step 2b — Swap an empty headless shell to WordPress (only when onboarding already made the shell)\n\nThe website already exists as an empty `headless` shell, so there is **no `hosting_websites_create`** here — you\ninstall WordPress straight into its `/cms` directory. This is the onboarding handoff path.\n\n1. Use the shell's `username` and `order_id` from Step 1's row — no new order pick, no new website.\n2. Install WordPress into `/cms`, flagged headless:\n\n ```json\n { \"operation\": \"wordpress_installations_install\",\n \"params\": { \"username\": \"<username>\", \"domain\": \"<domain>\", \"type\": \"headless\",\n \"site_title\": \"<the brief's Site name>\",\n \"credentials\": { \"login\": \"<admin login>\", \"email\": \"<account email>\",\n \"password\": \"<strong generated password>\" } } }\n ```\n\n - `type: \"headless\"` installs into `/cms` with the Hostinger headless MU plugin and marks the site\n headless-WordPress; **`directory` is not allowed with it** (it is always `cms`). The target must\n already be `headless` — the headless install rewrites the root `.htaccess`, so the API rejects it\n with `422` on any non-headless site (which is why Step 1 confirms `website_type: headless` first).\n - **You generate the admin password** (strong, 8–50 chars, mixed case + a digit) — never ask the user\n for one and never print it. The user signs in later through a one-click login link (Step 6), so the\n password only has to exist, not be remembered.\n - A new database is created for the install unless you pass `database.name` of an existing one; the\n generated database counts against the plan's limit.\n3. The call is **asynchronous** — a success response only means the install job was **queued**. This is\n the *fire*: record `provision.in_progress` and return to prepare work. At the join,\n `cd \"$HOME\" && node <skill>/wait.mjs cms <domain> <username>` returns the `/cms` install row (`directory: \"cms\"`,\n valid) once it exists, usually within 1–2 minutes of the install.\n\n## Step 3 — Verify (all must pass)\n\n| Check | How | Expect |\n|---|---|---|\n| Site is headless | `hosting_websites_list` exact row | `website_type: \"headless\"` |\n| WordPress at `/cms` | `wordpress_installations_list { \"username\": \"<username>\", \"ownership\": \"all\" }`, exact-match `domain` | row with `directory: \"cms\"`, `is_valid: true`; note its `id` |\n| REST API answers | `GET https://<domain>/cms/wp-json/wp/v2/posts?per_page=1` | 200, JSON array |\n| AI Assistant + MCP loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `hostinger-ai-assistant/v1` and `mcp` |\n| JWT mintable | `wordpress_installations_jwt-token { username, software: <id> }` | returns `token`, `mcp_url` |\n\nNotes:\n\n- `wordpress_installations_list` can lag a few seconds behind `completed` and return `[]` — retry\n briefly before failing. Its `domain` filter is a substring match, so exact-match the row.\n- The install record's `url` may say `http://`; always use `https://` URLs.\n- `GET https://<domain>/` returns 403 until the frontend is deployed — expected, not a failure.\n- **Never print, log or store the JWT.** It is minted on demand (24 h lifetime) by whichever stage\n needs the per-site WP MCP; only `mcp_url` is recorded.\n\nIf a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.\n\n## Step 4 — SEO plugin (Yoast) *(every WordPress site — on by default)*\n\nEvery headless WordPress site gets **Yoast SEO** (`wordpress-seo`) installed and activated by default,\nso per-page title/description/Open Graph/JSON-LD come from a maintained plugin's `yoast_head_json`\nrather than being hand-generated from each item's content by the frontend. This is **join-half** work\n(needs the live `/cms` install), so run it once `provision.status == \"completed\"`, the same way as\nStep 5. Tell the user in one line that SEO (Yoast) is being set up; if they explicitly don't\nwant it, skip this step and record `seo.enabled: false` — but the default is to install it.\n\n1. **Install + activate Yoast** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"wordpress-seo\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `wordpress-seo` shows\n `active` (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"wordpress-seo\" }`.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded**. Treat a 500 as \"verify, don't assume\": poll `list-installed` before retrying, and\n never fire a second install blindly.\n2. **Verify** `GET https://<domain>/cms/wp-json/` → `namespaces` once more, and that a sample post/page\n response carries `yoast_head_json`. The per-item Yoast meta (focus title/description per post) is set\n later in the **content-model push** — provision only installs + activates the plugin here. Don't fail\n provision over SEO: if the install can't be confirmed after one retry, record `seo.enabled: false`,\n tell the user, and let the frontend fall back to generating tags from content.\n\n## Step 5 — Store and contact form *(only when the brief has them — skip otherwise)*\n\n- **A store** (the brief's **Suggested backend** is `**WordPress + WooCommerce**`): follow\n [`../../04-content-model/wordpress/woocommerce.md`](../../04-content-model/wordpress/woocommerce.md) §0.\n- **A contact form** (the brief's **Must-haves** include a contact form): follow\n [`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0 to install Contact Form 7 (`contact-form-7`).\n\n## Step 6 — Record `site.json`\n\n```json\n{\n \"backend\": \"wordpress\",\n \"website_type\": \"headless\",\n \"order_id\": 1007223428,\n \"username\": \"u…\",\n \"wordpress\": {\n \"install_id\": \"30…\",\n \"directory\": \"cms\",\n \"admin_login\": \"…\"\n },\n \"seo\": {\n \"plugin\": \"wordpress-seo\",\n \"enabled\": true\n },\n \"urls\": {\n \"site\": \"https://<domain>\",\n \"cms\": \"https://<domain>/cms\",\n \"wp_admin\": \"https://<domain>/cms/wp-admin\",\n \"rest_api\": \"https://<domain>/cms/wp-json/wp/v2\",\n \"wp_mcp\": \"<mcp_url from the JWT call>\"\n },\n \"provisioned_at\": \"…\",\n \"verified_at\": \"…\"\n}\n```\n\nNo passwords or tokens in `site.json`. When the user needs wp-admin, mint a one-click link with\n`wordpress_login_create-links { username, software: <install_id> }` — never hand over a password.\n"
|
|
217
|
+
"text": "---\nname: headless-step-provision-wordpress\ndescription: \"Provision a headless WordPress backend for the Hostinger Headless flow: create the headless website with WordPress at /cms, verify and self-heal, then record it in site.json.\"\n---\n\n# headless-step-provision-wordpress\n\nCreate the headless WordPress backend for `<domain>` and prove it is ready. One platform call lays\nevery headless site out identically: WordPress in `public_html/cms`, Hostinger AI Assistant + MCP\nadapter, site marked `headless`. **Out:** `site.json`.\n\nAll operations below go through the Hostinger connector (`execute`).\n\n> **Fire vs join (background provision).** Step 1, plus the queuing call — `hosting_websites_create`\n> for a fresh site (Step 2) **or** `wordpress_installations_install` to swap an empty headless shell\n> (Step 2b) — are the **fire** half: once the job is queued, record `provision.in_progress` and return\n> to do prepare work (see the router `../SKILL.md`). The readiness **poll** at the end of Step 2 / 2b,\n> plus Steps 3–6, are the **join** half — run them when an instance-barrier step needs the backend (or\n> immediately, if the agent can't interleave). An already-`completed` site with WordPress at `/cms`\n> detected in Step 1 means provision is already done: record `provision.completed` and adopt it.\n\n## Step 1 — Detect before you create (never provision twice)\n\n1. `hosting_websites_list { \"domain\": \"<domain>\" }` — substring filter, so **exact-match** the row's\n `domain`. If a row exists, note `username`, `order_id`, `website_type`.\n2. **No exact row** → nothing exists on this domain → **create fresh** (Step 2).\n3. **A row exists.** If `website_type` is **not** `headless`, stop and tell the user — this domain\n already hosts a different kind of site (plain WordPress, Node.js, builder, …); never overwrite it.\n If it **is** `headless`, work out whether WordPress is already installed or the shell is still empty:\n check `hosting_websites_list-setups { \"domain\": \"<domain>\" }`\n (exact row) and `wordpress_installations_list { username, domain, ownership: \"all\" }` (exact row):\n - Setup `running` → provisioning is underway → skip to Step 2's poll.\n - Setup `failed` → tell the user and point them at hPanel; do **not** call `hosting_websites_create` again yourself.\n - A WordPress install with `directory: \"cms\"` already present (or setup `type: headless_wordpress`)\n → **already provisioned** → skip to Step 3 (adopt it).\n - A `headless` site with **no** `/cms` install (an **empty headless shell** — setup\n `type: headless_empty`, typically from onboarding) → **swap it to WordPress** (Step 2b). Do **not**\n call `hosting_websites_create` again — the website already exists; you only install WordPress into it.\n\n## Step 2 — Create a fresh headless WordPress site (only when no site exists)\n\n1. Pick the plan: `hosting_orders_list { \"statuses\": [\"active\"] }`. One active order → use it; several\n → ask the user which.\n2. Start the setup:\n\n ```json\n { \"operation\": \"hosting_websites_create\",\n \"params\": { \"order_id\": <order_id>, \"type\": \"headless_wordpress\", \"domain\": \"<domain>\" } }\n ```\n\n `domain` must be a **customer-owned** domain. For a temporary `*.hostingersite.com` subdomain,\n **omit `domain`** — the setup generates one itself and returns it in the response. Don't call a\n separate subdomain op to make one first: there's no need in this flow. The response then carries the\n generated domain: if it differs from the workspace directory name, move `~/.hostinger/<old>/` to\n `~/.hostinger/<new>/`\n (if `<new>/` already exists, stop and ask instead of moving into it),\n update the domain in `brief.md`, and tell the user the new domain.\n Admin credentials are generated by the platform; never ask the user for a password.\n3. Don't wait here. At the join, `cd \"$HOME\" && node <skill>/wait.mjs setup <domain>` (see *Waiting on Hostinger* in\n the top-level `SKILL.md`) returns once the setup is `completed`, usually at once by then. A `failed`\n setup → stop, point at hPanel.\n\n## Step 2b — Swap an empty headless shell to WordPress (only when onboarding already made the shell)\n\nThe website already exists as an empty `headless` shell, so there is **no `hosting_websites_create`** here — you\ninstall WordPress straight into its `/cms` directory. This is the onboarding handoff path.\n\n1. Use the shell's `username` and `order_id` from Step 1's row — no new order pick, no new website.\n2. Install WordPress into `/cms`, flagged headless:\n\n ```json\n { \"operation\": \"wordpress_installations_install\",\n \"params\": { \"username\": \"<username>\", \"domain\": \"<domain>\", \"type\": \"headless\",\n \"site_title\": \"<the brief's Site name>\",\n \"credentials\": { \"login\": \"<admin login>\", \"email\": \"<account email>\",\n \"password\": \"<strong generated password>\" } } }\n ```\n\n - `type: \"headless\"` installs into `/cms` with the Hostinger headless MU plugin and marks the site\n headless-WordPress; **`directory` is not allowed with it** (it is always `cms`). The target must\n already be `headless` — the headless install rewrites the root `.htaccess`, so the API rejects it\n with `422` on any non-headless site (which is why Step 1 confirms `website_type: headless` first).\n - **You generate the admin password** (strong, 8–50 chars, mixed case + a digit) — never ask the user\n for one and never print it. The user signs in later through a one-click login link (Step 6), so the\n password only has to exist, not be remembered.\n - A new database is created for the install unless you pass `database.name` of an existing one; the\n generated database counts against the plan's limit.\n3. The call is **asynchronous** — a success response only means the install job was **queued**. This is\n the *fire*: record `provision.in_progress` and return to prepare work. At the join,\n `cd \"$HOME\" && node <skill>/wait.mjs cms <domain> <username>` returns the `/cms` install row (`directory: \"cms\"`,\n valid) once it exists, usually within 1–2 minutes of the install.\n\n## Step 3 — Verify (all must pass)\n\n| Check | How | Expect |\n|---|---|---|\n| Site is headless | `hosting_websites_list` exact row | `website_type: \"headless\"` |\n| WordPress at `/cms` | `wordpress_installations_list { \"username\": \"<username>\", \"ownership\": \"all\" }`, exact-match `domain` | row with `directory: \"cms\"`, `is_valid: true`; note its `id` |\n| REST API answers | `GET https://<domain>/cms/wp-json/wp/v2/posts?per_page=1` | 200, JSON array |\n| AI Assistant + MCP loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `hostinger-ai-assistant/v1` and `mcp` |\n| JWT mintable | `wordpress_installations_jwt-token { username, software: <id> }` | returns `token`, `mcp_url` |\n\nNotes:\n\n- `wordpress_installations_list` can lag a few seconds behind `completed` and return `[]` — retry\n briefly before failing. Its `domain` filter is a substring match, so exact-match the row.\n- The install record's `url` may say `http://`; always use `https://` URLs.\n- `GET https://<domain>/` returns 403 until the frontend is deployed — expected, not a failure.\n- A `jwt-token` HTTP 500 can still have succeeded (a known quirk of the `hostinger-wordpress` MCP):\n call it again before failing.\n- **Never print, log or store the JWT.** It is minted on demand (24 h lifetime) by whichever stage\n needs the per-site WP MCP; only `mcp_url` is recorded.\n\nIf a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.\n\n## Step 4 — Plugins *(one install call for every plugin the site needs)*\n\nInstall every wordpress.org plugin the site needs in **one** call, then poll once for all of them. This\nis **join-half** work (needs the live `/cms` install), so run it once `provision.status == \"completed\"`.\nBuild the slug list from the brief:\n\n| Slug | Install when | If it doesn't come up |\n|---|---|---|\n| `wordpress-seo` (Yoast SEO) | Every site, unless the owner declines it when told (then record `seo.enabled: false`) | Record `seo.enabled: false`, tell the user in one line, and let the frontend generate tags from content |\n| `woocommerce` | The brief's **Suggested backend** is `**WordPress + WooCommerce**` | Stop and point the user at hPanel: a store can't work without it |\n| `contact-form-7` | The brief's **Must-haves** include a contact form | Record `contact_form.enabled: false`, tell the user in one line, and let the frontend render the contact page without a form |\n\nYoast is on by default so per-page title/description/Open Graph/JSON-LD come from a maintained\nplugin's `yoast_head_json` rather than being hand-generated by the frontend. Tell the user in one line\nwhich plugins you're installing; drop `wordpress-seo` if they say they don't want SEO.\n\n1. **Install all of them in one call** (management MCP, async):\n `wordpress_plugins_install { username, software: <install_id>, plugins: [<every slug from the table>] }`.\n An HTTP 500 doesn't mean it failed (a known quirk of the `hostinger-wordpress` MCP): go straight to\n the poll, and never send a second install blindly.\n2. **Poll** `wordpress_plugins_list-installed { username, software }` until every slug shows `active`\n (install and activate usually complete together). Activate a slug that is installed but inactive with\n `wordpress_plugins_activate { username, software, plugin: \"<slug>\" }`.\n3. **A slug that doesn't come up.** The poll names it, so handle only that slug: if it is still not\n `active` after about two minutes of polling, send one more install with only the slugs that aren't\n `active`, poll again, and apply each remaining slug's fallback from the table. Never fail provision\n over Yoast or Contact Form 7.\n\n## Step 5 — Per-plugin checks *(each slug Step 4 left `active`)*\n\nA check that fails means that slug didn't come up: apply its fallback from Step 4.\n\n- **SEO** (`wordpress-seo`): `GET https://<domain>/cms/wp-json/` → `namespaces` once more, and a sample\n post/page response carries `yoast_head_json`. The per-item Yoast meta (focus title/description per\n post) is set later in the **content-model push**; provision only installs and activates the plugin.\n- **A store** (`woocommerce`): verify it and record it in `site.json` per\n [`../../04-content-model/wordpress/woocommerce.md`](../../04-content-model/wordpress/woocommerce.md) §0.\n- **A contact form** (`contact-form-7`): verify it and record it in `site.json` per\n [`../../04-content-model/wordpress/contact-form.md`](../../04-content-model/wordpress/contact-form.md) §0.\n\n## Step 6 — Record `site.json`\n\n```json\n{\n \"backend\": \"wordpress\",\n \"website_type\": \"headless\",\n \"order_id\": 1007223428,\n \"username\": \"u…\",\n \"wordpress\": {\n \"install_id\": \"30…\",\n \"directory\": \"cms\",\n \"admin_login\": \"…\"\n },\n \"seo\": {\n \"plugin\": \"wordpress-seo\",\n \"enabled\": true\n },\n \"urls\": {\n \"site\": \"https://<domain>\",\n \"cms\": \"https://<domain>/cms\",\n \"wp_admin\": \"https://<domain>/cms/wp-admin\",\n \"rest_api\": \"https://<domain>/cms/wp-json/wp/v2\",\n \"wp_mcp\": \"<mcp_url from the JWT call>\"\n },\n \"provisioned_at\": \"…\",\n \"verified_at\": \"…\"\n}\n```\n\nNo passwords or tokens in `site.json`. When the user needs wp-admin, mint a one-click link with\n`wordpress_login_create-links { username, software: <install_id> }` — never hand over a password.\n"
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
220
|
"uri": "skill://hostinger-headless/steps/04-content-model/SKILL.md",
|
|
@@ -253,10 +253,10 @@ const skills: Skill[] = [
|
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/contact-form.md",
|
|
256
|
-
"digest": "sha256:
|
|
257
|
-
"size":
|
|
256
|
+
"digest": "sha256:d5c7813a1f8e6599bf91cf006fb27902bef7402ec9cd2810611cdb50486f9ae5",
|
|
257
|
+
"size": 15315,
|
|
258
258
|
"mimeType": "text/markdown",
|
|
259
|
-
"text": "# headless — Contact Form 7 cookbook (contact form on headless WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the brief's **Must-haves**\ninclude a contact form (`site.json → contact_form.enabled: true`). The goal: a contact page whose form,\nsubmitted from the **decoupled frontend**, sends the enquiry to the site owner by email using\nWordPress's built-in `wp_mail()` — no third-party form service, no API keys, no secret on the client.\n\n**Contact Form 7 is not a separate backend.** It is the `contact-form-7` plugin on the same headless\nWordPress install at `/cms` (installed at provision, §0). This cookbook is the authoritative home for\nthe contact-form data layer: how to **resolve the form** (content-model push), **deploy a spam guard**,\nwhat the **frontend submits** (Step 6), and how **validate** proves mail actually leaves.\n\n---\n\n## 0 — Provision: install, verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5. Like Yoast this is **join-half** work: run it once\n`provision.status == \"completed\"`.\n\n1. **Install + activate CF7** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"contact-form-7\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `contact-form-7` shows `active`\n (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"contact-form-7\" }`.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded**. Treat a 500 as \"verify, don't assume\": poll `list-installed` before retrying, and\n never fire a second install blindly.\n2. **Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then\n record `contact_form.enabled: true` in `site.json` (provision Step 6). If the install can't be confirmed after\n one retry, record `contact_form.enabled: false`, tell the user in one line, and let the frontend\n render the contact page without a form (graceful — not a build failure). Don't fail provision over it.\n\nThen add the `contact_form` block to `site.json` (provision Step 6). Provision records only `enabled` +\n`plugin` here; §2 fills `form_id`, `feedback_url`, `fields` and `honeypot_field` once it resolves the form\nand deploys the spam guard:\n\n```json\n{\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": null,\n \"feedback_url\": null,\n \"fields\": [],\n \"honeypot_field\": null,\n \"recipient\": \"site-admin-email\"\n }\n}\n```\n\n`recipient` is informational — CF7's `To` is `[_site_admin_email]`; no address, token or secret is\nstored in `site.json`.\n\n---\n\n## 1 — Why CF7, and why it works headlessly\n\nYou **could** deploy a custom plugin into the headless `/cms` and write a bespoke mailer (see\n[`custom-plugins.md`](custom-plugins.md)), but a contact form is exactly the kind of maintained,\nspam-hardened functionality you should **reuse rather than reinvent**. CF7 is the right choice because:\n\n- It is a **wordpress.org-slug plugin** → installs through the same management MCP (`wordpress_plugins_install`)\n as Yoast and WooCommerce. No custom code to deploy.\n- It ships a **public, unauthenticated submit endpoint**:\n `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<form_id>/feedback`. Submissions don't need\n the JWT or any key.\n- The frontend (apex domain) and `/cms` are **same-origin**, so the browser posts straight to that\n endpoint — **no proxy route, no CORS, no credentials client-side.**\n- On submit CF7 runs its mail template through `wp_mail()`, which on Hostinger routes through the\n server's mailer. The default form's `To` is `[_site_admin_email]` — the admin address set at install —\n so **basic email delivery works out of the box.**\n\n**Spam protection comes from a tiny deployed plugin, not the Honeypot add-on.** CF7's own\n`contact-form-7-honeypot` add-on only acts when a `[honeypot]` form-tag is present in the form — a wp-admin\nedit the headless agent can't make — so on the default form it does **nothing**. Instead, deploy a\n~15-line `wpcf7_spam` guard into `/cms` (the capability from [`custom-plugins.md`](custom-plugins.md)): it\nrejects a submission whose decoy field is filled, with no owner step and no keys. See *§2b — Spam\nprotection* below. (reCAPTCHA is the alternative but needs owner-provided Google keys set in wp-admin —\nout of reach for the headless agent.)\n\n---\n\n## 2 — Content-model push: resolve the form and record it\n\nA fresh CF7 install ships one form, **\"Contact form 1\"**, with the default fields `your-name`,\n`your-email`, `your-subject`, `your-message` and a submit, and mails `[_site_admin_email]`. You need\nits **numeric form id** (and, if you tailored the form, its field names) to build `feedback_url`.\n\n> **Reality check — how to read the id.** The per-site WP MCP (Hostinger AI Assistant, discovery mode)\n> exposes **no generic REST/`RestEndpointTool` ability**, and `wpcf7_contact_form` is **not a public CPT**\n> (it is absent from `cpt-list-types` and from `wp/v2/types`), so the MCP cannot read the form, and CF7's\n> own `GET /contact-form-7/v1/contact-forms` is capability-gated (no public read). The reliable,\n> tool-free way is to **probe the public feedback endpoint**, which needs no auth.\n\n1. **Find the form id by probing the feedback endpoint (idempotent).** For `id` in a small range\n (`1`‒`30` covers a fresh install — the default form lands a few ids after the sample content), send a\n **`multipart/form-data`** `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<id>/feedback` with\n a single field `_wpcf7_unit_tag=wpcf7-f<id>-o1`. **The content type matters:** CF7 checks it *before*\n it looks up the id and answers **415** to any non-multipart body, so a bare POST returns non-404 for\n *every* id and would wrongly pick id 1.\n - **Hit** → `200` whose JSON body carries `\"contact_form_id\": <id>` (matching the id you probed) and a\n CF7 `\"status\"` (e.g. `validation_failed`). **This id is the form.** On a fresh single-form install\n that is the only hit; reuse it on a re-run.\n - **Miss** → `404` with `\"code\": \"wpcf7_not_found\"`. Keep going.\n - **Inconclusive** → anything else (`415` from a wrong content type, `403`, `429`, `5xx`) is **not** a\n hit — never select such an id. Fix the request or retry, widen the range, and fall back to the owner\n handoff (step 2) if nothing resolves.\n\n The default field names are `your-name`, `your-email`, `your-subject`, `your-message`. (A full test\n submission that confirms both the id and the field names — and that mail actually sends — belongs to\n **validate**, so you send just one real email; see §5.)\n\n2. **(Optional) tailor the form — owner-side.** The headless tooling can't edit the CF7 form (no REST\n ability reaches it). If the design needs different fields, keep the default form for the build and note\n it; the owner edits fields/recipient in wp-admin (Contact → Contact Forms) via the one-click login.\n The default form is enough for a name/email/subject/message enquiry, and its recipient\n (`[_site_admin_email]`) is already correct.\n\n3. **Record into `site.json`** — fill the `contact_form` block provision started:\n\n ```json\n {\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": 4,\n \"feedback_url\": \"https://<domain>/cms/wp-json/contact-form-7/v1/contact-forms/4/feedback\",\n \"fields\": [\"your-name\", \"your-email\", \"your-subject\", \"your-message\"],\n \"cf7_version\": \"6.2.2\",\n \"honeypot_field\": \"your_website\",\n \"recipient\": \"site-admin-email\"\n }\n }\n ```\n\n `cf7_version` is the installed CF7 version (from `wordpress_plugins_list-installed`) — the frontend\n sends it as `_wpcf7_version`. `honeypot_field` is the decoy the spam guard checks (§2b) — the frontend\n renders it empty and the server rejects a filled one. Also note the form id in `content-model.md`. No\n address, token or secret goes into `site.json`.\n\n> **Fallback if the probe finds nothing** (an unusual install, or the default form was removed): mint a\n> one-click wp-admin link (`wordpress_login_create-links { username, software }`) and ask the owner to\n> read the form id from **Contact → Contact Forms** (the shortcode shows `id=\"…\"`). Record it into\n> `site.json` and continue — the same owner-handoff used for the WooCommerce checkout gate, not a build\n> failure.\n\n> **Aside — Hostinger's own shortcode.** The per-site MCP's `pages-create` ability suggests\n> `[hostinger_contact_form]` for a contact form *inside a WordPress page*. That is server-rendered\n> shortcode output, not useful to a decoupled React frontend that reads REST JSON — this flow uses CF7's\n> JSON feedback endpoint instead. Mentioned only so the shortcode hint isn't mistaken for the headless path.\n\n---\n\n## 2b — Spam protection: deploy the honeypot guard\n\nCF7's default form has **no spam protection**, and the `contact-form-7-honeypot` add-on can't help\nheadlessly (it needs a `[honeypot]` form-tag only an owner can add — see §1). Instead, deploy a tiny\nplugin that enforces a honeypot **server-side**, on the same REST feedback path the frontend uses. This\nreuses the custom-plugin deploy from [`custom-plugins.md`](custom-plugins.md) — the only moving part is one\n~15-line file.\n\n**Why it works.** CF7's `wpcf7_spam` filter runs inside `submit()`, which the REST feedback endpoint\ncalls, so returning `true` sets the submission `status` to `spam` and **suppresses the mail**. The hook can\nread any posted field via `WPCF7_Submission::get_posted_data()` — including a decoy field that isn't a CF7\nform-tag, **as long as its name doesn't start with `_`** (CF7 strips `_`-prefixed keys). So the frontend\nsends a decoy field (empty for humans), and the guard flags the submission as spam when a bot fills it.\n\n1. **Write the guard** to `~/.hostinger/<domain>/plugins/cf7-headless-spamguard/cf7-headless-spamguard.php`:\n\n ```php\n <?php\n /**\n * Plugin Name: CF7 Headless Spam Guard\n * Description: Server-side honeypot for Contact Form 7 submissions from a headless frontend.\n * Version: 1.0.0\n * Requires PHP: 7.4\n * License: GPL-2.0-or-later\n */\n if ( ! defined( 'ABSPATH' ) ) { exit; }\n\n // Reject a submission whose decoy field is filled. The name is a fixed convention the frontend\n // renders empty (site.json → contact_form.honeypot_field); it must NOT start with \"_\".\n add_filter( 'wpcf7_spam', function ( $spam, $submission ) {\n \tif ( $spam ) { return $spam; } // keep any earlier spam verdict\n \t$decoy = $submission->get_posted_data( 'your_website' );\n \tif ( is_string( $decoy ) && trim( $decoy ) !== '' ) {\n \t\t$spam = true; // bot filled it → status 'spam', no mail\n \t}\n \treturn $spam;\n }, 10, 2 );\n ```\n\n2. **Deploy it** into the headless `/cms` (activates on install; idempotent — re-deploy to update):\n\n ```json\n { \"operation\": \"hosting_deploy\",\n \"params\": {\n \"domain\": \"<domain>\",\n \"type\": \"wordpress-plugin\",\n \"path\": \"~/.hostinger/<domain>/plugins/cf7-headless-spamguard\",\n \"slug\": \"cf7-headless-spamguard\",\n \"headless\": true } }\n ```\n\n3. **Record** `contact_form.honeypot_field: \"your_website\"` in `site.json` (done in §2 step 3) so the\n frontend knows which decoy to render. Keep the plugin **generic** (no site-specific values) — it's one\n reusable artifact, not per-site code.\n\n> **Nonce note.** CF7's built-in spam check also flags nonce failure, but nonce verification is **inactive\n> for logged-out visitors by default** — which is why a plain headless submission returns `mail_sent`, not\n> `spam`. The guard adds the honeypot on top. Confirm end-to-end in validate (§5).\n\n---\n\n## 3 — What the frontend submits (Step 6 reference)\n\nThe feedback endpoint expects `multipart/form-data` with the form's own fields **plus** CF7's hidden\ncontrol fields. The frontend builds this in a `submitContactForm(data)` helper in the one data module:\n\n| Field | Value |\n|---|---|\n| each name in `contact_form.fields` | the user's input (`your-name`, `your-email`, …) |\n| `_wpcf7` | `contact_form.form_id` (number) |\n| `_wpcf7_version` | CF7 version string, e.g. `\"5.9.8\"` (not strictly validated) |\n| `_wpcf7_locale` | e.g. `\"en_US\"` |\n| `_wpcf7_unit_tag` | any stable string, e.g. `\"wpcf7-f<form_id>-o1\"` |\n| `_wpcf7_container_post` | `\"0\"` |\n| `contact_form.honeypot_field` (the decoy, e.g. `your_website`) | **empty** — rendered hidden/off-screen, `autocomplete=\"off\"`, `tabindex=\"-1\"`; the §2b guard rejects it as spam if filled |\n\n`POST` to `contact_form.feedback_url` and **do not set `Content-Type`** — let the browser add the\nmultipart boundary. Same-origin, so no CORS and no secret.\n\n**Response** is JSON:\n\n```json\n{ \"contact_form_id\": 42, \"status\": \"mail_sent\", \"message\": \"Thank you for your message. It has been sent.\",\n \"invalid_fields\": [], \"posted_data_hash\": \"…\" }\n```\n\nBranch on `status`:\n\n- `mail_sent` → success state (clear the form, show the thank-you message).\n- `validation_failed` → map each `invalid_fields[].field` to its input and show the message inline.\n- `spam` / `aborted` / `mail_failed` / `acceptance_missing` → a generic \"couldn't send, try again\" error.\n\nA user validation error is a **normal UI state, not a build error**. When `contact_form.enabled` is\n`false` or absent, the frontend renders the contact page with plain contact details and **no form**.\n\n---\n\n## 4 — Email delivery & the `wp_mail` caveat (what to tell the owner)\n\nCF7's default form mails `[_site_admin_email]` via `wp_mail()`, so **Hostinger does \"set up\" basic email\nby default** — nothing else to configure for the form to send. One caveat worth surfacing:\n\n- **Deliverability.** `wp_mail` from a shared host can land in spam for external recipients without\n SPF/DKIM. The most reliable recipient is a **Hostinger mailbox on the same domain**. Keep CF7's admin\n recipient; if the owner wants a different inbox, point them to a same-domain mailbox.\n\nDon't install an SMTP plugin or ask for mail credentials as part of this flow — the default `wp_mail`\npath is the intended behaviour; SMTP is an owner decision in wp-admin if deliverability needs hardening.\n\n---\n\n## 5 — Validate (Step 7): the two test sends\n\nRead from [`../../07-validate/SKILL.md`](../../07-validate/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nPOST one throwaway test submission (dummy\nname/email/subject/message + CF7's hidden `_wpcf7*` fields — see §3\nabove) to `contact_form.feedback_url` and assert the JSON\n`status` is **`mail_sent`**. This is the one place a real send happens, so one test email reaches the\nowner — not several. `mail_failed` is a real finding: surface it to the user (CF7 is wired, but\n`wp_mail` delivery/SPF needs attention — a Hostinger mailbox on the domain is the most reliable\nrecipient) and log it as an issue. A `validation_failed` means the test payload didn't match the form's\nfields — fix the field names in `site.json`, not the plugin.\n**Then check the honeypot:** POST a **second** throwaway submission with the same valid fields **plus**\n`contact_form.honeypot_field` **filled**, and assert the `status` is **`spam`** (no mail sent). Keep the\nreal fields valid — CF7 validates **before** running the spam filter, so an invalid payload would return\n`validation_failed` and never reach the honeypot check. A `mail_sent` here means the\n`cf7-headless-spamguard` plugin isn't active — surface it and re-check its deploy.\n\n---\n\n## 6 — Handover (Step 9)\n\nRead from [`../../09-done/SKILL.md`](../../09-done/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nIn the handover, tell the owner the contact page is live and enquiries email\nthe **WordPress admin address** (via `wp_mail`) — and that for the most reliable delivery that address\nshould be a Hostinger mailbox on the domain. If validate reported `mail_failed`, say so plainly instead\nof claiming the form sends.\n"
|
|
259
|
+
"text": "# headless — Contact Form 7 cookbook (contact form on headless WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the brief's **Must-haves**\ninclude a contact form (`site.json → contact_form.enabled: true`). The goal: a contact page whose form,\nsubmitted from the **decoupled frontend**, sends the enquiry to the site owner by email using\nWordPress's built-in `wp_mail()` — no third-party form service, no API keys, no secret on the client.\n\n**Contact Form 7 is not a separate backend.** It is the `contact-form-7` plugin on the same headless\nWordPress install at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for\nthe contact-form data layer: how to **resolve the form** (content-model push), **deploy a spam guard**,\nwhat the **frontend submits** (Step 6), and how **validate** proves mail actually leaves.\n\n---\n\n## 0 — Provision: verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.\n\n**Verify** `GET https://<domain>/cms/wp-json/` lists the **`contact-form-7/v1`** namespace, then record\n`contact_form.enabled: true` in `site.json` (provision Step 6). If it's missing, CF7 didn't come up:\napply its fallback in provision Step 4.\n\nThen add the `contact_form` block to `site.json` (provision Step 6). Provision records only `enabled` +\n`plugin` here; §2 fills `form_id`, `feedback_url`, `fields` and `honeypot_field` once it resolves the form\nand deploys the spam guard:\n\n```json\n{\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": null,\n \"feedback_url\": null,\n \"fields\": [],\n \"honeypot_field\": null,\n \"recipient\": \"site-admin-email\"\n }\n}\n```\n\n`recipient` is informational — CF7's `To` is `[_site_admin_email]`; no address, token or secret is\nstored in `site.json`.\n\n---\n\n## 1 — Why CF7, and why it works headlessly\n\nYou **could** deploy a custom plugin into the headless `/cms` and write a bespoke mailer (see\n[`custom-plugins.md`](custom-plugins.md)), but a contact form is exactly the kind of maintained,\nspam-hardened functionality you should **reuse rather than reinvent**. CF7 is the right choice because:\n\n- It is a **wordpress.org-slug plugin** → provision Step 4 installs it like Yoast. No custom\n code to deploy.\n- It ships a **public, unauthenticated submit endpoint**:\n `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<form_id>/feedback`. Submissions don't need\n the JWT or any key.\n- The frontend (apex domain) and `/cms` are **same-origin**, so the browser posts straight to that\n endpoint — **no proxy route, no CORS, no credentials client-side.**\n- On submit CF7 runs its mail template through `wp_mail()`, which on Hostinger routes through the\n server's mailer. The default form's `To` is `[_site_admin_email]` — the admin address set at install —\n so **basic email delivery works out of the box.**\n\n**Spam protection comes from a tiny deployed plugin, not the Honeypot add-on.** CF7's own\n`contact-form-7-honeypot` add-on only acts when a `[honeypot]` form-tag is present in the form — a wp-admin\nedit the headless agent can't make — so on the default form it does **nothing**. Instead, deploy a\n~15-line `wpcf7_spam` guard into `/cms` (the capability from [`custom-plugins.md`](custom-plugins.md)): it\nrejects a submission whose decoy field is filled, with no owner step and no keys. See *§2b — Spam\nprotection* below. (reCAPTCHA is the alternative but needs owner-provided Google keys set in wp-admin —\nout of reach for the headless agent.)\n\n---\n\n## 2 — Content-model push: resolve the form and record it\n\nA fresh CF7 install ships one form, **\"Contact form 1\"**, with the default fields `your-name`,\n`your-email`, `your-subject`, `your-message` and a submit, and mails `[_site_admin_email]`. You need\nits **numeric form id** (and, if you tailored the form, its field names) to build `feedback_url`.\n\n> **Reality check — how to read the id.** The per-site WP MCP (Hostinger AI Assistant, discovery mode)\n> exposes **no generic REST/`RestEndpointTool` ability**, and `wpcf7_contact_form` is **not a public CPT**\n> (it is absent from `cpt-list-types` and from `wp/v2/types`), so the MCP cannot read the form, and CF7's\n> own `GET /contact-form-7/v1/contact-forms` is capability-gated (no public read). The reliable,\n> tool-free way is to **probe the public feedback endpoint**, which needs no auth.\n\n1. **Find the form id by probing the feedback endpoint (idempotent).** For `id` in a small range\n (`1`‒`30` covers a fresh install — the default form lands a few ids after the sample content), send a\n **`multipart/form-data`** `POST {urls.cms}/wp-json/contact-form-7/v1/contact-forms/<id>/feedback` with\n a single field `_wpcf7_unit_tag=wpcf7-f<id>-o1`. **The content type matters:** CF7 checks it *before*\n it looks up the id and answers **415** to any non-multipart body, so a bare POST returns non-404 for\n *every* id and would wrongly pick id 1.\n - **Hit** → `200` whose JSON body carries `\"contact_form_id\": <id>` (matching the id you probed) and a\n CF7 `\"status\"` (e.g. `validation_failed`). **This id is the form.** On a fresh single-form install\n that is the only hit; reuse it on a re-run.\n - **Miss** → `404` with `\"code\": \"wpcf7_not_found\"`. Keep going.\n - **Inconclusive** → anything else (`415` from a wrong content type, `403`, `429`, `5xx`) is **not** a\n hit — never select such an id. Fix the request or retry, widen the range, and fall back to the owner\n handoff (step 2) if nothing resolves.\n\n The default field names are `your-name`, `your-email`, `your-subject`, `your-message`. (A full test\n submission that confirms both the id and the field names — and that mail actually sends — belongs to\n **validate**, so you send just one real email; see §5.)\n\n2. **(Optional) tailor the form — owner-side.** The headless tooling can't edit the CF7 form (no REST\n ability reaches it). If the design needs different fields, keep the default form for the build and note\n it; the owner edits fields/recipient in wp-admin (Contact → Contact Forms) via the one-click login.\n The default form is enough for a name/email/subject/message enquiry, and its recipient\n (`[_site_admin_email]`) is already correct.\n\n3. **Record into `site.json`** — fill the `contact_form` block provision started:\n\n ```json\n {\n \"contact_form\": {\n \"enabled\": true,\n \"plugin\": \"contact-form-7\",\n \"form_id\": 4,\n \"feedback_url\": \"https://<domain>/cms/wp-json/contact-form-7/v1/contact-forms/4/feedback\",\n \"fields\": [\"your-name\", \"your-email\", \"your-subject\", \"your-message\"],\n \"cf7_version\": \"6.2.2\",\n \"honeypot_field\": \"your_website\",\n \"recipient\": \"site-admin-email\"\n }\n }\n ```\n\n `cf7_version` is the installed CF7 version (from `wordpress_plugins_list-installed`) — the frontend\n sends it as `_wpcf7_version`. `honeypot_field` is the decoy the spam guard checks (§2b) — the frontend\n renders it empty and the server rejects a filled one. Also note the form id in `content-model.md`. No\n address, token or secret goes into `site.json`.\n\n> **Fallback if the probe finds nothing** (an unusual install, or the default form was removed): mint a\n> one-click wp-admin link (`wordpress_login_create-links { username, software }`) and ask the owner to\n> read the form id from **Contact → Contact Forms** (the shortcode shows `id=\"…\"`). Record it into\n> `site.json` and continue — the same owner-handoff used for the WooCommerce checkout gate, not a build\n> failure.\n\n> **Aside — Hostinger's own shortcode.** The per-site MCP's `pages-create` ability suggests\n> `[hostinger_contact_form]` for a contact form *inside a WordPress page*. That is server-rendered\n> shortcode output, not useful to a decoupled React frontend that reads REST JSON — this flow uses CF7's\n> JSON feedback endpoint instead. Mentioned only so the shortcode hint isn't mistaken for the headless path.\n\n---\n\n## 2b — Spam protection: deploy the honeypot guard\n\nCF7's default form has **no spam protection**, and the `contact-form-7-honeypot` add-on can't help\nheadlessly (it needs a `[honeypot]` form-tag only an owner can add — see §1). Instead, deploy a tiny\nplugin that enforces a honeypot **server-side**, on the same REST feedback path the frontend uses. This\nreuses the custom-plugin deploy from [`custom-plugins.md`](custom-plugins.md) — the only moving part is one\n~15-line file.\n\n**Why it works.** CF7's `wpcf7_spam` filter runs inside `submit()`, which the REST feedback endpoint\ncalls, so returning `true` sets the submission `status` to `spam` and **suppresses the mail**. The hook can\nread any posted field via `WPCF7_Submission::get_posted_data()` — including a decoy field that isn't a CF7\nform-tag, **as long as its name doesn't start with `_`** (CF7 strips `_`-prefixed keys). So the frontend\nsends a decoy field (empty for humans), and the guard flags the submission as spam when a bot fills it.\n\n1. **Write the guard** to `~/.hostinger/<domain>/plugins/cf7-headless-spamguard/cf7-headless-spamguard.php`:\n\n ```php\n <?php\n /**\n * Plugin Name: CF7 Headless Spam Guard\n * Description: Server-side honeypot for Contact Form 7 submissions from a headless frontend.\n * Version: 1.0.0\n * Requires PHP: 7.4\n * License: GPL-2.0-or-later\n */\n if ( ! defined( 'ABSPATH' ) ) { exit; }\n\n // Reject a submission whose decoy field is filled. The name is a fixed convention the frontend\n // renders empty (site.json → contact_form.honeypot_field); it must NOT start with \"_\".\n add_filter( 'wpcf7_spam', function ( $spam, $submission ) {\n \tif ( $spam ) { return $spam; } // keep any earlier spam verdict\n \t$decoy = $submission->get_posted_data( 'your_website' );\n \tif ( is_string( $decoy ) && trim( $decoy ) !== '' ) {\n \t\t$spam = true; // bot filled it → status 'spam', no mail\n \t}\n \treturn $spam;\n }, 10, 2 );\n ```\n\n2. **Deploy it** into the headless `/cms` (activates on install; idempotent — re-deploy to update):\n\n ```json\n { \"operation\": \"hosting_deploy\",\n \"params\": {\n \"domain\": \"<domain>\",\n \"type\": \"wordpress-plugin\",\n \"path\": \"~/.hostinger/<domain>/plugins/cf7-headless-spamguard\",\n \"slug\": \"cf7-headless-spamguard\",\n \"headless\": true } }\n ```\n\n3. **Record** `contact_form.honeypot_field: \"your_website\"` in `site.json` (done in §2 step 3) so the\n frontend knows which decoy to render. Keep the plugin **generic** (no site-specific values) — it's one\n reusable artifact, not per-site code.\n\n> **Nonce note.** CF7's built-in spam check also flags nonce failure, but nonce verification is **inactive\n> for logged-out visitors by default** — which is why a plain headless submission returns `mail_sent`, not\n> `spam`. The guard adds the honeypot on top. Confirm end-to-end in validate (§5).\n\n---\n\n## 3 — What the frontend submits (Step 6 reference)\n\nThe feedback endpoint expects `multipart/form-data` with the form's own fields **plus** CF7's hidden\ncontrol fields. The frontend builds this in a `submitContactForm(data)` helper in the one data module:\n\n| Field | Value |\n|---|---|\n| each name in `contact_form.fields` | the user's input (`your-name`, `your-email`, …) |\n| `_wpcf7` | `contact_form.form_id` (number) |\n| `_wpcf7_version` | CF7 version string, e.g. `\"5.9.8\"` (not strictly validated) |\n| `_wpcf7_locale` | e.g. `\"en_US\"` |\n| `_wpcf7_unit_tag` | any stable string, e.g. `\"wpcf7-f<form_id>-o1\"` |\n| `_wpcf7_container_post` | `\"0\"` |\n| `contact_form.honeypot_field` (the decoy, e.g. `your_website`) | **empty** — rendered hidden/off-screen, `autocomplete=\"off\"`, `tabindex=\"-1\"`; the §2b guard rejects it as spam if filled |\n\n`POST` to `contact_form.feedback_url` and **do not set `Content-Type`** — let the browser add the\nmultipart boundary. Same-origin, so no CORS and no secret.\n\n**Response** is JSON:\n\n```json\n{ \"contact_form_id\": 42, \"status\": \"mail_sent\", \"message\": \"Thank you for your message. It has been sent.\",\n \"invalid_fields\": [], \"posted_data_hash\": \"…\" }\n```\n\nBranch on `status`:\n\n- `mail_sent` → success state (clear the form, show the thank-you message).\n- `validation_failed` → map each `invalid_fields[].field` to its input and show the message inline.\n- `spam` / `aborted` / `mail_failed` / `acceptance_missing` → a generic \"couldn't send, try again\" error.\n\nA user validation error is a **normal UI state, not a build error**. When `contact_form.enabled` is\n`false` or absent, the frontend renders the contact page with plain contact details and **no form**.\n\n---\n\n## 4 — Email delivery & the `wp_mail` caveat (what to tell the owner)\n\nCF7's default form mails `[_site_admin_email]` via `wp_mail()`, so **Hostinger does \"set up\" basic email\nby default** — nothing else to configure for the form to send. One caveat worth surfacing:\n\n- **Deliverability.** `wp_mail` from a shared host can land in spam for external recipients without\n SPF/DKIM. The most reliable recipient is a **Hostinger mailbox on the same domain**. Keep CF7's admin\n recipient; if the owner wants a different inbox, point them to a same-domain mailbox.\n\nDon't install an SMTP plugin or ask for mail credentials as part of this flow — the default `wp_mail`\npath is the intended behaviour; SMTP is an owner decision in wp-admin if deliverability needs hardening.\n\n---\n\n## 5 — Validate (Step 7): the two test sends\n\nRead from [`../../07-validate/SKILL.md`](../../07-validate/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nPOST one throwaway test submission (dummy\nname/email/subject/message + CF7's hidden `_wpcf7*` fields — see §3\nabove) to `contact_form.feedback_url` and assert the JSON\n`status` is **`mail_sent`**. This is the one place a real send happens, so one test email reaches the\nowner — not several. `mail_failed` is a real finding: surface it to the user (CF7 is wired, but\n`wp_mail` delivery/SPF needs attention — a Hostinger mailbox on the domain is the most reliable\nrecipient) and log it as an issue. A `validation_failed` means the test payload didn't match the form's\nfields — fix the field names in `site.json`, not the plugin.\n**Then check the honeypot:** POST a **second** throwaway submission with the same valid fields **plus**\n`contact_form.honeypot_field` **filled**, and assert the `status` is **`spam`** (no mail sent). Keep the\nreal fields valid — CF7 validates **before** running the spam filter, so an invalid payload would return\n`validation_failed` and never reach the honeypot check. A `mail_sent` here means the\n`cf7-headless-spamguard` plugin isn't active — surface it and re-check its deploy.\n\n---\n\n## 6 — Handover (Step 9)\n\nRead from [`../../09-done/SKILL.md`](../../09-done/SKILL.md) when `site.json → contact_form.enabled` is true.\n\nIn the handover, tell the owner the contact page is live and enquiries email\nthe **WordPress admin address** (via `wp_mail`) — and that for the most reliable delivery that address\nshould be a Hostinger mailbox on the domain. If validate reported `mail_failed`, say so plainly instead\nof claiming the form sends.\n"
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
262
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/custom-plugins.md",
|
|
@@ -267,10 +267,10 @@ const skills: Skill[] = [
|
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
269
|
"uri": "skill://hostinger-headless/steps/04-content-model/wordpress/woocommerce.md",
|
|
270
|
-
"digest": "sha256:
|
|
271
|
-
"size":
|
|
270
|
+
"digest": "sha256:9590fe55049b43390faef7b72d69a95be944d2b97d18232c9af43408f7ad8abf",
|
|
271
|
+
"size": 9344,
|
|
272
272
|
"mimeType": "text/markdown",
|
|
273
|
-
"text": "# headless — WooCommerce cookbook (headless store on WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the WordPress backend carries\na **WooCommerce store** (`site.json → woocommerce.enabled: true`) — a brief whose **Suggested backend** is\n`**WordPress + WooCommerce**` (one site: content **and** commerce).\n\n**WooCommerce is not a separate backend.** It is the `woocommerce` plugin on a normal headless WordPress\ninstall at `/cms` (installed at provision, §0). This cookbook is the authoritative home for the store\ndata layer: how to **seed and CRUD** products, categories and coupons, and how the **storefront** reads\nthe cart, coupons and checkout.\n\n---\n\n## 0 — Provision: install, verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5. This is **join-half** work (needs the live instance): run it once\n`provision.status == \"completed\"`.\n\n1. **Install + activate WooCommerce** (management MCP, async — poll, never blind-retry):\n - `wordpress_plugins_install { username, software: <install_id>, plugins: [\"woocommerce\"] }`\n - Poll `wordpress_plugins_list-installed { username, software }` until `woocommerce` shows `active`\n (install + activate can complete together), or activate it with\n `wordpress_plugins_activate { username, software, plugin: \"woocommerce\" }`.\n - Confirm with `wordpress_plugins_check-if-woo-commerce-is-installed { domain: \"<domain>\" }`. Allow a\n moment for WooCommerce's installer to create its tables and the Shop/Cart/Checkout pages.\n - **Known quirk:** the `hostinger-wordpress` MCP sometimes returns **HTTP 500 even though the job\n succeeded** (seen on both `plugins_install` and `jwt-token`). Treat a 500 as \"verify, don't assume\":\n poll `list-installed` / re-check before retrying, and never fire a second install blindly.\n2. **Verify the store endpoints (public, no auth):**\n\n | Check | How | Expect |\n |---|---|---|\n | WooCommerce active | `wordpress_plugins_check-if-woo-commerce-is-installed { domain }` | installed + active |\n | Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |\n | Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |\n\n Pretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a\n store route ever 404s, the permalink structure is the thing to check.\n\nThen add the `woocommerce` block and the store URLs to `site.json` (provision Step 6; `backend` stays\n`\"wordpress\"`). Checkout stays off until the owner sets it up (§4), so `payment_enabled` starts `false`:\n\n```json\n{\n \"woocommerce\": {\n \"enabled\": true,\n \"seeded_via\": \"per-site-wp-mcp\",\n \"currency\": \"<currency_code from GET {store_api}/products or the install default>\",\n \"payment_enabled\": false,\n \"checkout_setup\": \"owner enables a payment method + shipping in wp-admin\"\n },\n \"urls\": {\n \"store_api\": \"https://<domain>/cms/wp-json/wc/store/v1\",\n \"wc_rest_api\": \"https://<domain>/cms/wp-json/wc/v3\"\n }\n}\n```\n\n---\n\n## 1 — The one rule: drive the store through the per-site WP MCP\n\nThere is **no seed plugin, no WP-CLI, and no REST consumer key in this flow**: catalog data goes through\nthe WP MCP. Instead, the **per-site WP MCP** (the Hostinger AI Assistant — the same JWT session the WordPress\ncontent push uses, see `SKILL.md`) exposes **native WooCommerce abilities**. The push seeds the\ncatalog through them (§3); call them yourself only by hand or for work after the push.\n\nRelevant abilities (names from `hostinger-ai-discover-abilities`; call `get-ability-info` for each schema\nbefore use — they mirror the WooCommerce REST v3 shapes):\n\n| Area | Abilities |\n|---|---|\n| Products | `wc-products-search` · `wc-products-get` · `wc-products-create` · `wc-products-update` · `wc-products-delete` |\n| Categories / tags / brands | `wc-product-categories-{list,create,update,delete}` · `wc-product-tags-*` · `wc-product-brands-*` |\n| Coupons | `wc-coupons-{search,get,create,update,delete,batch}` |\n| Orders | `wc-orders-{search,get,create,update,delete}` |\n| Reports | `wc-reports-{sales,orders-totals,products-totals,coupons-totals,…}` |\n| Media | `media-upload-from-url` (product images — WordPress keeps its own copy) |\n\nAll run as the install's admin **inside the MCP session** — no consumer keys, no Basic Auth. This is\nproven: a `wc-products-create` call makes a product that immediately appears on the public Store API.\n\n---\n\n## 2 — The storefront reads the public Store API\n\nThe **frontend** never touches the per-site MCP or any key. It reads the **public WooCommerce Store API**\nat `site.json → urls.store_api` (`/cms/wp-json/wc/store/v1`) — public, open CORS, no auth for reads.\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately.\n\n| Store API call | Use |\n|---|---|\n| `GET /products?per_page=100` · `GET /products/<id>` · `?slug=<slug>` | catalog + product pages |\n| `GET /products/categories` | category nav |\n| `GET /cart` | current cart (seeds the `Cart-Token`) |\n| `POST /cart/add-item` `{ id, quantity }` · `/cart/update-item` `{ key, quantity }` · `/cart/remove-item` `{ key }` | cart mutations |\n| `POST /cart/apply-coupon` `{ code }` · `/cart/remove-coupon` `{ code }` | coupons on the cart |\n| `POST /checkout` `{ billing_address, shipping_address, payment_method }` | place an order |\n\n**Store API auth for writes** (cart/checkout): send the **`Nonce`** header (read it from the `Nonce` /\n`X-WC-Store-API-Nonce` response header of a prior Store API GET and echo it back) **and** the\n**`Cart-Token`** header (a JWT the Store API returns on the first cart response — resend it on every\ncart call so a headless client keeps one cart; persist it in `localStorage`). Reads need neither.\n\n**Pricing / minor units.** The Store API returns **integer-string** prices in minor units plus the\ndivisor: `prices.price` (e.g. `\"1999\"`) with `prices.currency_minor_unit` (e.g. `2`) and\n`prices.currency_code`. Display value = `Number(price) / 10 ** currency_minor_unit`. **Pagination:**\n`?page=&per_page=` (max 100), with `X-WP-Total` / `X-WP-TotalPages` headers.\n\n---\n\n## 3 — Seeding the catalog (content-model push)\n\nThe push seeds the catalog with the rest of the content: put product categories, products and coupons\nunder `store` in `content.json` and run `push-content.mjs` (`SKILL.md` Steps 1–2). It looks categories up\nby slug, products by **SKU** and coupons by **code** before creating, so a re-run never duplicates; uploads\neach product image once; checks every SKU and category over the Store API; and records the ids under\n`## Created in WooCommerce` in `content-model.md`.\n\n- `price` is a decimal string in **major units** (`\"39.99\"`); the Store API re-exposes it in minor units.\n- Any other WooCommerce product field passes through as given (`sale_price`, `stock_quantity`,\n `attributes`, …). For a **variable product**, the push creates the parent; add its variations by hand\n through the product update / variations ability that discovery lists.\n- Coupons: `discount_type` is `percent`, `fixed_cart` or `fixed_product`. WooCommerce stores codes in\n lower case.\n\n---\n\n## 4 — Checkout is owner-completed (the one gate)\n\nA fresh WooCommerce install has **no payment gateway and no shipping zone enabled**, and **neither is\nreachable from the headless tooling** — there is no payment/shipping MCP ability, and `wp-settings-update`\nonly writes standard WordPress settings (it ignores `woocommerce_*` options). So:\n\n- **The catalog, product pages, client-side cart and coupon application all work headlessly.**\n- **Checkout (`POST /checkout`) does not work until the owner enables a payment method + a shipping zone\n in wp-admin** (WooCommerce → Settings → Payments / Shipping; reach it via the one-click login in `steps/09-done/SKILL.md`).\n Cash on Delivery is the zero-config choice once enabled.\n- Treat this exactly like the Hostinger Ecommerce `payment_enabled: false` gate: record\n `woocommerce.payment_enabled: false`, tell the user in one line that checkout needs that one setup step,\n and **never block the build on it**. The frontend renders a graceful disabled-checkout state and does not\n call `/checkout` while `payment_enabled` is `false`. Flip it to `true` only after the owner confirms a\n gateway is live. **Never ask the user for payment credentials.**\n\nStore **currency** and **address** (`woocommerce_*` options) likewise aren't settable headlessly — they\nfollow the install default; the owner changes them in wp-admin if needed.\n\n---\n\n## 5 — REST API v3 (optional, owner-only — not used by this flow)\n\nWooCommerce also exposes the authenticated **REST API v3** at `site.json → urls.wc_rest_api`\n(`/cms/wp-json/wc/v3`) for external/server-side integrations. **This build never uses it** — seeding goes\nthrough the per-site MCP and the storefront uses the public Store API. Document it for the owner only:\n\n- **Auth:** `Authorization: Basic base64(\"<consumer_key>:<consumer_secret>\")`, **HTTPS only**, server-side\n only — **never ship a key to the browser.**\n- **Keys:** the owner generates a key pair in **wp-admin → WooCommerce → Settings → Advanced → REST API**\n (the agent cannot mint one headlessly). Store it in the owner's own environment, not in `site.json` or\n the repo.\n- **Endpoints** (same shapes as the abilities above): `GET/POST/PUT/DELETE /products`, `/products/<id>/variations`,\n `/products/categories`, `/coupons`, `/orders`. Idempotency via `?sku=` / `?code=`. Pagination via\n `?page=&per_page=` + `X-WP-Total`.\n\n---\n\n## 6 — Idempotency & verification checklist\n\n- **Idempotency keys:** products → SKU, coupons → code, categories → slug, images → skip when the product\n already has `images`. `push-content.mjs` applies them; follow them too when seeding by hand.\n- **Checkout** is verified only when `payment_enabled` is `true`; while `false`, the catalog and cart over\n the Store API are the whole job.\n"
|
|
273
|
+
"text": "# headless — WooCommerce cookbook (headless store on WordPress)\n\nA companion recipe to `SKILL.md` (WordPress content model). Use it whenever the WordPress backend carries\na **WooCommerce store** (`site.json → woocommerce.enabled: true`) — a brief whose **Suggested backend** is\n`**WordPress + WooCommerce**` (one site: content **and** commerce).\n\n**WooCommerce is not a separate backend.** It is the `woocommerce` plugin on a normal headless WordPress\ninstall at `/cms` (installed at provision Step 4, checked in §0). This cookbook is the authoritative home for the store\ndata layer: how to **seed and CRUD** products, categories and coupons, and how the **storefront** reads\nthe cart, coupons and checkout.\n\n---\n\n## 0 — Provision: verify, record `site.json`\n\nRead from [`../../03-provision/wordpress/SKILL.md`](../../03-provision/wordpress/SKILL.md) Step 5.\n\n**Verify the store endpoints (public, no auth).** Allow a moment for WooCommerce's installer to create\nits tables and the Shop/Cart/Checkout pages. Provision Step 4's `list-installed` poll is the install\ncheck: `wordpress_plugins_check-if-woo-commerce-is-installed` answers `is_installed: false` on a headless\n`/cms` install even with WooCommerce active, so don't use it.\n\n| Check | How | Expect |\n|---|---|---|\n| Store API answers | `GET https://<domain>/cms/wp-json/wc/store/v1/products?per_page=1` | 200 (empty until content-model seeds — fine) |\n| Both namespaces loaded | `GET https://<domain>/cms/wp-json/` → `namespaces` | contains `wc/store/v1` **and** `wc/v3` |\n\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately; if a\nstore route ever 404s, the permalink structure is the thing to check.\n\nThen add the `woocommerce` block and the store URLs to `site.json` (provision Step 6; `backend` stays\n`\"wordpress\"`). Checkout stays off until the owner sets it up (§4), so `payment_enabled` starts `false`:\n\n```json\n{\n \"woocommerce\": {\n \"enabled\": true,\n \"seeded_via\": \"per-site-wp-mcp\",\n \"currency\": \"<currency_code from GET {store_api}/products or the install default>\",\n \"payment_enabled\": false,\n \"checkout_setup\": \"owner enables a payment method + shipping in wp-admin\"\n },\n \"urls\": {\n \"store_api\": \"https://<domain>/cms/wp-json/wc/store/v1\",\n \"wc_rest_api\": \"https://<domain>/cms/wp-json/wc/v3\"\n }\n}\n```\n\n---\n\n## 1 — The one rule: drive the store through the per-site WP MCP\n\nThere is **no seed plugin, no WP-CLI, and no REST consumer key in this flow**: catalog data goes through\nthe WP MCP. Instead, the **per-site WP MCP** (the Hostinger AI Assistant — the same JWT session the WordPress\ncontent push uses, see `SKILL.md`) exposes **native WooCommerce abilities**. The push seeds the\ncatalog through them (§3); call them yourself only by hand or for work after the push.\n\nRelevant abilities (names from `hostinger-ai-discover-abilities`; call `get-ability-info` for each schema\nbefore use — they mirror the WooCommerce REST v3 shapes):\n\n| Area | Abilities |\n|---|---|\n| Products | `wc-products-search` · `wc-products-get` · `wc-products-create` · `wc-products-update` · `wc-products-delete` |\n| Categories / tags / brands | `wc-product-categories-{list,create,update,delete}` · `wc-product-tags-*` · `wc-product-brands-*` |\n| Coupons | `wc-coupons-{search,get,create,update,delete,batch}` |\n| Orders | `wc-orders-{search,get,create,update,delete}` |\n| Reports | `wc-reports-{sales,orders-totals,products-totals,coupons-totals,…}` |\n| Media | `media-upload-from-url` (product images — WordPress keeps its own copy) |\n\nAll run as the install's admin **inside the MCP session** — no consumer keys, no Basic Auth. This is\nproven: a `wc-products-create` call makes a product that immediately appears on the public Store API.\n\n---\n\n## 2 — The storefront reads the public Store API\n\nThe **frontend** never touches the per-site MCP or any key. It reads the **public WooCommerce Store API**\nat `site.json → urls.store_api` (`/cms/wp-json/wc/store/v1`) — public, open CORS, no auth for reads.\nPretty permalinks are on by default on a headless install, so the Store API resolves immediately.\n\n| Store API call | Use |\n|---|---|\n| `GET /products?per_page=100` · `GET /products/<id>` · `?slug=<slug>` | catalog + product pages |\n| `GET /products/categories` | category nav |\n| `GET /cart` | current cart (seeds the `Cart-Token`) |\n| `POST /cart/add-item` `{ id, quantity }` · `/cart/update-item` `{ key, quantity }` · `/cart/remove-item` `{ key }` | cart mutations |\n| `POST /cart/apply-coupon` `{ code }` · `/cart/remove-coupon` `{ code }` | coupons on the cart |\n| `POST /checkout` `{ billing_address, shipping_address, payment_method }` | place an order |\n\n**Store API auth for writes** (cart/checkout): send the **`Nonce`** header (read it from the `Nonce` /\n`X-WC-Store-API-Nonce` response header of a prior Store API GET and echo it back) **and** the\n**`Cart-Token`** header (a JWT the Store API returns on the first cart response — resend it on every\ncart call so a headless client keeps one cart; persist it in `localStorage`). Reads need neither.\n\n**Pricing / minor units.** The Store API returns **integer-string** prices in minor units plus the\ndivisor: `prices.price` (e.g. `\"1999\"`) with `prices.currency_minor_unit` (e.g. `2`) and\n`prices.currency_code`. Display value = `Number(price) / 10 ** currency_minor_unit`. **Pagination:**\n`?page=&per_page=` (max 100), with `X-WP-Total` / `X-WP-TotalPages` headers.\n\n---\n\n## 3 — Seeding the catalog (content-model push)\n\nThe push seeds the catalog with the rest of the content: put product categories, products and coupons\nunder `store` in `content.json` and run `push-content.mjs` (`SKILL.md` Steps 1–2). It looks categories up\nby slug, products by **SKU** and coupons by **code** before creating, so a re-run never duplicates; uploads\neach product image once; checks every SKU and category over the Store API; and records the ids under\n`## Created in WooCommerce` in `content-model.md`.\n\n- `price` is a decimal string in **major units** (`\"39.99\"`); the Store API re-exposes it in minor units.\n- Any other WooCommerce product field passes through as given (`sale_price`, `stock_quantity`,\n `attributes`, …). For a **variable product**, the push creates the parent; add its variations by hand\n through the product update / variations ability that discovery lists.\n- Coupons: `discount_type` is `percent`, `fixed_cart` or `fixed_product`. WooCommerce stores codes in\n lower case.\n\n---\n\n## 4 — Checkout is owner-completed (the one gate)\n\nA fresh WooCommerce install has **no payment gateway and no shipping zone enabled**, and **neither is\nreachable from the headless tooling** — there is no payment/shipping MCP ability, and `wp-settings-update`\nonly writes standard WordPress settings (it ignores `woocommerce_*` options). So:\n\n- **The catalog, product pages, client-side cart and coupon application all work headlessly.**\n- **Checkout (`POST /checkout`) does not work until the owner enables a payment method + a shipping zone\n in wp-admin** (WooCommerce → Settings → Payments / Shipping; reach it via the one-click login in `steps/09-done/SKILL.md`).\n Cash on Delivery is the zero-config choice once enabled.\n- Treat this exactly like the Hostinger Ecommerce `payment_enabled: false` gate: record\n `woocommerce.payment_enabled: false`, tell the user in one line that checkout needs that one setup step,\n and **never block the build on it**. The frontend renders a graceful disabled-checkout state and does not\n call `/checkout` while `payment_enabled` is `false`. Flip it to `true` only after the owner confirms a\n gateway is live. **Never ask the user for payment credentials.**\n\nStore **currency** and **address** (`woocommerce_*` options) likewise aren't settable headlessly — they\nfollow the install default; the owner changes them in wp-admin if needed.\n\n---\n\n## 5 — REST API v3 (optional, owner-only — not used by this flow)\n\nWooCommerce also exposes the authenticated **REST API v3** at `site.json → urls.wc_rest_api`\n(`/cms/wp-json/wc/v3`) for external/server-side integrations. **This build never uses it** — seeding goes\nthrough the per-site MCP and the storefront uses the public Store API. Document it for the owner only:\n\n- **Auth:** `Authorization: Basic base64(\"<consumer_key>:<consumer_secret>\")`, **HTTPS only**, server-side\n only — **never ship a key to the browser.**\n- **Keys:** the owner generates a key pair in **wp-admin → WooCommerce → Settings → Advanced → REST API**\n (the agent cannot mint one headlessly). Store it in the owner's own environment, not in `site.json` or\n the repo.\n- **Endpoints** (same shapes as the abilities above): `GET/POST/PUT/DELETE /products`, `/products/<id>/variations`,\n `/products/categories`, `/coupons`, `/orders`. Idempotency via `?sku=` / `?code=`. Pagination via\n `?page=&per_page=` + `X-WP-Total`.\n\n---\n\n## 6 — Idempotency & verification checklist\n\n- **Idempotency keys:** products → SKU, coupons → code, categories → slug, images → skip when the product\n already has `images`. `push-content.mjs` applies them; follow them too when seeding by hand.\n- **Checkout** is verified only when `payment_enabled` is `true`; while `false`, the catalog and cart over\n the Store API are the whole job.\n"
|
|
274
274
|
},
|
|
275
275
|
{
|
|
276
276
|
"uri": "skill://hostinger-headless/steps/05-design/SKILL.md",
|
|
@@ -4,4 +4,4 @@ import { startServer } from '../core/runtime.js';
|
|
|
4
4
|
import tools from '../core/tools/agency-hosting.js';
|
|
5
5
|
import instructions from '../core/instructions.agency-hosting.js';
|
|
6
6
|
|
|
7
|
-
startServer({ name: 'hostinger-agency-hosting-mcp', version: '4.1
|
|
7
|
+
startServer({ name: 'hostinger-agency-hosting-mcp', version: '4.2.1', tools, instructions });
|
|
@@ -4,4 +4,4 @@ import { startServer } from '../core/runtime.js';
|
|
|
4
4
|
import tools from '../core/tools/agency-hosting.js';
|
|
5
5
|
import instructions from '../core/instructions.agency-hosting.js';
|
|
6
6
|
|
|
7
|
-
startServer({ name: 'hostinger-agency-hosting-mcp', version: '4.1
|
|
7
|
+
startServer({ name: 'hostinger-agency-hosting-mcp', version: '4.2.1', tools, instructions });
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
import { startServer } from '../core/runtime.js';
|
|
4
4
|
import tools from '../core/tools/agent-readiness.js';
|
|
5
5
|
|
|
6
|
-
startServer({ name: 'hostinger-agent-readiness-mcp', version: '4.1
|
|
6
|
+
startServer({ name: 'hostinger-agent-readiness-mcp', version: '4.2.1', tools });
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
import { startServer } from '../core/runtime.js';
|
|
4
4
|
import tools from '../core/tools/agent-readiness.js';
|
|
5
5
|
|
|
6
|
-
startServer({ name: 'hostinger-agent-readiness-mcp', version: '4.1
|
|
6
|
+
startServer({ name: 'hostinger-agent-readiness-mcp', version: '4.2.1', tools });
|
package/src/servers/all.js
CHANGED
|
@@ -5,4 +5,4 @@ import tools from '../core/tools/all.js';
|
|
|
5
5
|
import instructions from '../core/instructions.js';
|
|
6
6
|
import skills from '../core/skills.js';
|
|
7
7
|
|
|
8
|
-
startServer({ name: 'hostinger-api-mcp', version: '4.1
|
|
8
|
+
startServer({ name: 'hostinger-api-mcp', version: '4.2.1', tools, instructions, skills });
|
package/src/servers/all.ts
CHANGED
|
@@ -5,4 +5,4 @@ import tools from '../core/tools/all.js';
|
|
|
5
5
|
import instructions from '../core/instructions.js';
|
|
6
6
|
import skills from '../core/skills.js';
|
|
7
7
|
|
|
8
|
-
startServer({ name: 'hostinger-api-mcp', version: '4.1
|
|
8
|
+
startServer({ name: 'hostinger-api-mcp', version: '4.2.1', tools, instructions, skills });
|
package/src/servers/billing.js
CHANGED
package/src/servers/billing.ts
CHANGED
package/src/servers/dns.js
CHANGED
package/src/servers/dns.ts
CHANGED
package/src/servers/domains.js
CHANGED
package/src/servers/domains.ts
CHANGED
package/src/servers/ecommerce.js
CHANGED
package/src/servers/ecommerce.ts
CHANGED
package/src/servers/gpu.js
CHANGED
package/src/servers/gpu.ts
CHANGED
package/src/servers/horizons.js
CHANGED
package/src/servers/horizons.ts
CHANGED
package/src/servers/hosting.js
CHANGED
|
@@ -4,4 +4,4 @@ import { startServer } from '../core/runtime.js';
|
|
|
4
4
|
import tools from '../core/tools/hosting.js';
|
|
5
5
|
import instructions from '../core/instructions.js';
|
|
6
6
|
|
|
7
|
-
startServer({ name: 'hostinger-hosting-mcp', version: '4.1
|
|
7
|
+
startServer({ name: 'hostinger-hosting-mcp', version: '4.2.1', tools, instructions });
|
package/src/servers/hosting.ts
CHANGED
|
@@ -4,4 +4,4 @@ import { startServer } from '../core/runtime.js';
|
|
|
4
4
|
import tools from '../core/tools/hosting.js';
|
|
5
5
|
import instructions from '../core/instructions.js';
|
|
6
6
|
|
|
7
|
-
startServer({ name: 'hostinger-hosting-mcp', version: '4.1
|
|
7
|
+
startServer({ name: 'hostinger-hosting-mcp', version: '4.2.1', tools, instructions });
|
package/src/servers/mail.js
CHANGED
package/src/servers/mail.ts
CHANGED
package/src/servers/reach.js
CHANGED
package/src/servers/reach.ts
CHANGED
package/src/servers/vps.js
CHANGED
package/src/servers/vps.ts
CHANGED
package/src/servers/wordpress.js
CHANGED
package/src/servers/wordpress.ts
CHANGED