hostinger-api-mcp 4.3.0 → 4.5.0
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/SKILL.md +55 -13
- package/skills/headless/VERSION +3 -3
- package/skills/headless/run-log.mjs +3 -5
- package/skills/headless/steps/01-check-state/SKILL.md +16 -5
- package/skills/headless/steps/02-refine/SKILL.md +56 -29
- package/skills/headless/steps/03-provision/SKILL.md +24 -27
- package/skills/headless/steps/03-provision/pocketbase/SKILL.md +190 -0
- package/skills/headless/steps/04-content-model/SKILL.md +50 -13
- package/skills/headless/steps/04-content-model/pocketbase/SKILL.md +90 -0
- package/skills/headless/steps/04-content-model/pocketbase/auth.md +52 -0
- package/skills/headless/steps/04-content-model/pocketbase/frontend.md +130 -0
- package/skills/headless/steps/04-content-model/pocketbase/patterns.md +286 -0
- package/skills/headless/steps/04-content-model/pocketbase/rules.md +66 -0
- package/skills/headless/steps/04-content-model/pocketbase/schema.example.json +65 -0
- package/skills/headless/steps/04-content-model/pocketbase/schema.md +78 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-apply-schema.mjs +245 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-lib.mjs +120 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-verify.mjs +127 -0
- package/skills/headless/steps/04-content-model/pocketbase/troubleshooting.md +55 -0
- package/skills/headless/steps/05-design/SKILL.md +7 -5
- package/skills/headless/steps/06-frontend/SKILL.md +32 -33
- package/skills/headless/steps/07-validate/SKILL.md +8 -2
- package/skills/headless/steps/08-deploy/SKILL.md +32 -17
- package/skills/headless/steps/09-done/SKILL.md +20 -3
- package/skills/headless/wait.mjs +19 -9
- package/src/core/skills.js +117 -40
- package/src/core/skills.ts +117 -40
- 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/skills/headless/steps/03-provision/webapp/SKILL.md +0 -164
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: headless-step-provision-pocketbase
|
|
3
|
+
description: "Provision the PocketBase backend for the Hostinger Headless flow: create a headless website (type headless_pocketbase) or adopt the one onboarding made, then create its PocketBase backend with hosting_pocketbase_create-backend (database, visitor sign-in, file storage and realtime at /api, the owner's dashboard at /_/), save the one-time superuser password outside the deployable source, verify it answers, and record it in site.json. For any app, SPA or site whose visitors create its data."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# headless-step-provision-pocketbase
|
|
7
|
+
|
|
8
|
+
Provision a **headless website with a PocketBase backend** for `<domain>` and prove it is ready. This
|
|
9
|
+
is the backend for **any app, SPA or site whose visitors create the data it keeps** — accounts,
|
|
10
|
+
bookings, comments, votes, scores, order requests, uploads, live messages. There is no CMS and no store
|
|
11
|
+
engine here. PocketBase runs on the site's own domain: the REST and realtime API at
|
|
12
|
+
`https://<domain>/api`, the owner's dashboard at `https://<domain>/_/`. Every other path is the
|
|
13
|
+
frontend that the frontend step builds and the deploy step ships as a Node.js application.
|
|
14
|
+
**Out:** `site.json` and `~/.hostinger/<domain>/.pocketbase/credentials.json`.
|
|
15
|
+
|
|
16
|
+
> **Not WordPress, not Ecommerce.** Never provision `headless_wordpress` / `headless_ecommerce` for a
|
|
17
|
+
> PocketBase build, and never install WordPress at `/cms`: Hostinger refuses a PocketBase backend on a
|
|
18
|
+
> headless WordPress site. The app owns every route except `/api` and `/_`.
|
|
19
|
+
|
|
20
|
+
All website operations below go through the Hostinger connector (`execute`). Read each operation's
|
|
21
|
+
`inputSchema` (from `search`) before its first call.
|
|
22
|
+
|
|
23
|
+
> **Fire vs join (background provision).** For a **fresh site**, the fire half is Step 2's
|
|
24
|
+
> `hosting_websites_create`; the join half is `wait.mjs setup`, then Step 3 (the backend), Step 4 and
|
|
25
|
+
> Step 5. For an **adopted shell** (onboarding's `headless_empty` or `headless_pocketbase` site), the
|
|
26
|
+
> fire half is Step 3's `hosting_pocketbase_create-backend` call plus saving its response — one call
|
|
27
|
+
> that returns at once — and the join half is `wait.mjs pocketbase`, Step 4 and Step 5. Record
|
|
28
|
+
> `provision.in_progress` after the fire and return to the prepare work (see the router `../SKILL.md`);
|
|
29
|
+
> join when an instance-barrier step needs the backend, or immediately if the agent can't interleave.
|
|
30
|
+
> A site whose backend Step 1 already finds means provision is done: record `provision.completed` and
|
|
31
|
+
> adopt it.
|
|
32
|
+
|
|
33
|
+
## Step 0 — Preflight
|
|
34
|
+
|
|
35
|
+
`search` with the query `pocketbase`. You need `hosting_pocketbase_create-backend`,
|
|
36
|
+
`hosting_pocketbase_backend` and `hosting_pocketbase_set-superuser`; read each one's `inputSchema`
|
|
37
|
+
before its first call. If any is missing, the connector is outdated: update it (connect's Phase 1
|
|
38
|
+
install), log an `issue` event and stop. **Never improvise a database in its place.**
|
|
39
|
+
|
|
40
|
+
## Step 1 — Detect before you create (never provision twice)
|
|
41
|
+
|
|
42
|
+
Run these in order: the kind checks (points 1–3) decide whether this site may be used at all, before
|
|
43
|
+
its setup status (point 4) says where to pick it up.
|
|
44
|
+
|
|
45
|
+
1. `hosting_websites_list { "domain": "<domain>" }` — substring filter, so **exact-match** the row's
|
|
46
|
+
`domain`. If a row exists, note `username`, `order_id`, `website_type`. No exact row → nothing
|
|
47
|
+
exists on this domain → **create fresh** (Step 2).
|
|
48
|
+
2. **A row of another kind** (`website_type` not `headless`: a WordPress or store site) → stop and
|
|
49
|
+
tell the user — this domain already hosts something else. **Never create a second site.**
|
|
50
|
+
3. **A `headless` row.** `wordpress_installations_list { username, domain, ownership: "all" }` with a
|
|
51
|
+
`directory: "cms"` row → stop and tell the user: this is a headless WordPress site, and Hostinger
|
|
52
|
+
refuses PocketBase there. Otherwise `hosting_pocketbase_backend { username, domain }`:
|
|
53
|
+
- a backend (any `state` but `missing`) → **adopt it**; Step 3 point 1 settles the credentials
|
|
54
|
+
(rotate the superuser when this build made the backend and the file is gone, otherwise ask).
|
|
55
|
+
- 404, or `state: "missing"` → the shell is empty (onboarding's `headless_empty`, or a
|
|
56
|
+
`headless_pocketbase` site whose backend wasn't created yet): **adopt the site, don't call
|
|
57
|
+
`hosting_websites_create`**, and create the backend on it in Step 3 with this row's `username`.
|
|
58
|
+
**Only provision PocketBase for a `pocketbase` brief.** A `wordpress` or `ecommerce` brief belongs
|
|
59
|
+
in those subfolders — never give it a PocketBase backend.
|
|
60
|
+
4. **Where to pick it up.** `hosting_websites_list-setups { "domain": "<domain>" }` — exact-match the row:
|
|
61
|
+
- `completed`, or no row (it drops off after 24 h) → the website is ready → Step 3.
|
|
62
|
+
- `running` → the setup is still going: at the join, `cd "$HOME" && node <skill>/wait.mjs setup <domain>`
|
|
63
|
+
before Step 3.
|
|
64
|
+
- `failed` → tell the user and point them at hPanel; do **not** call `hosting_websites_create` again on your own.
|
|
65
|
+
|
|
66
|
+
## Step 2 — Create (only when nothing exists)
|
|
67
|
+
|
|
68
|
+
1. Pick the plan: `hosting_orders_list { "statuses": ["active"] }`. One active order → use it; several
|
|
69
|
+
→ ask the user which.
|
|
70
|
+
2. Start the setup as a **headless website marked for PocketBase** (it installs nothing yet; Step 3
|
|
71
|
+
creates the backend):
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{ "operation": "hosting_websites_create",
|
|
75
|
+
"params": { "order_id": <order_id>, "type": "headless_pocketbase", "domain": "<domain>" } }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`domain` must be a **customer-owned** domain. For a temporary `*.hostingersite.com` subdomain,
|
|
79
|
+
**omit `domain`** — the setup generates one itself and returns it in the response. Don't call a
|
|
80
|
+
separate subdomain op to make one first: there's no need in this flow. The response then carries the
|
|
81
|
+
generated domain: if it differs from the workspace directory name, move `~/.hostinger/<old>/` to
|
|
82
|
+
`~/.hostinger/<new>/`
|
|
83
|
+
(if `<new>/` already exists, stop and ask instead of moving into it),
|
|
84
|
+
update the domain in `brief.md`, and tell the user the new domain.
|
|
85
|
+
3. Don't wait here. At the join, `cd "$HOME" && node <skill>/wait.mjs setup <domain>` (see *Waiting on Hostinger* in
|
|
86
|
+
the top-level `SKILL.md`) returns once the setup is `completed`, usually at once by then. A `failed`
|
|
87
|
+
setup → stop, point at hPanel. Then Step 3.
|
|
88
|
+
|
|
89
|
+
## Step 3 — Create the backend
|
|
90
|
+
|
|
91
|
+
Needs the website (setup `completed`). On an adopted shell this is the **fire** half; on a fresh site
|
|
92
|
+
it runs at the join.
|
|
93
|
+
|
|
94
|
+
1. **Already there?** `hosting_pocketbase_backend { username, domain }`. A backend plus
|
|
95
|
+
`~/.hostinger/<domain>/.pocketbase/credentials.json` with a matching `domain` → adopt it and go to
|
|
96
|
+
point 4. A backend without that file → the password is gone (Hostinger returns it once and never
|
|
97
|
+
stores it): when this build made it (a resumed run, `site.json → backend: "pocketbase"`), rotate it
|
|
98
|
+
with `hosting_pocketbase_set-superuser { username, domain }` (no password, so a strong one is
|
|
99
|
+
generated) and save the response as in point 2; when it may belong to something else, **ask** first.
|
|
100
|
+
2. **Create it.** `hosting_pocketbase_create-backend { username, domain }` **without**
|
|
101
|
+
`superuser_password`. As soon as the call returns, before any other step or message, write the
|
|
102
|
+
**full response** to `~/.hostinger/<domain>/.pocketbase/credentials.json` with your file-writing
|
|
103
|
+
tool and `chmod 600` it (on Windows the profile folder is already private). It holds `domain`,
|
|
104
|
+
`api_url`, `admin_url`, `superuser_email`, `superuser_password`, `instance_id`, `state` and
|
|
105
|
+
`version`; **the password is returned only this once**. The file sits in the workspace, outside
|
|
106
|
+
`src/`, so no deploy archive can include it. Never print the password or put it in `site.json`,
|
|
107
|
+
`brief.md`, the run log or a chat reply.
|
|
108
|
+
3. **A 422 is not always "already exists"**: read its message and show it to the user when you stop.
|
|
109
|
+
- *This website already has a PocketBase instance* → go back to point 1 (once; if it still finds no
|
|
110
|
+
backend, stop and show the user the message).
|
|
111
|
+
- *not supported on headless WordPress websites* or *cannot be added to a parked domain* → stop
|
|
112
|
+
and tell the user: this domain can't take PocketBase.
|
|
113
|
+
- *not available* / *no access yet* (PocketBase is rolling out gradually and this account isn't
|
|
114
|
+
enabled yet) → stop and tell the user PocketBase isn't enabled on their account yet, quoting the
|
|
115
|
+
message; log an `issue` event. **Never improvise a database in its place.**
|
|
116
|
+
- Any other message → stop and show it to the user. Never retry a 422 blindly.
|
|
117
|
+
4. **Wait for it.** `state` may be `null` right after creation; that's normal.
|
|
118
|
+
`cd "$HOME" && node <skill>/wait.mjs pocketbase <domain>` returns once `https://<domain>/api/health`
|
|
119
|
+
answers 200 (over `http://` with `https_pending: true` while a new domain's certificate is still
|
|
120
|
+
installing — fine, go on). If it times out, re-read `hosting_pocketbase_backend`: `failed` means
|
|
121
|
+
the last start didn't succeed and Hostinger retries it on its own after `retry_after_seconds`
|
|
122
|
+
(the data is intact — wait that long and read again, never delete the backend); `unregistered`
|
|
123
|
+
means it's broken → stop and show the user; `missing` means its files are gone → point 2 creates
|
|
124
|
+
a new, empty one. The backend sleeps after about 5 idle minutes, so one 503 on a first request is
|
|
125
|
+
a wake-up.
|
|
126
|
+
|
|
127
|
+
PocketBase owns `/api` and `/_` on this domain; the app's own server routes use another prefix (e.g.
|
|
128
|
+
`/server`). The owner sets outgoing mail (SMTP), backups and social sign-in in the dashboard: they
|
|
129
|
+
aren't in the API. `hosting_pocketbase_delete-backend` destroys every record and upload — never call
|
|
130
|
+
it in this flow.
|
|
131
|
+
|
|
132
|
+
## Step 4 — Verify
|
|
133
|
+
|
|
134
|
+
| Check | How | Expect |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| Website exists | `hosting_websites_list` exact row | the row is present, `username` known |
|
|
137
|
+
| Setup finished *(fresh site only)* | `hosting_websites_list-setups` exact row | `status: completed` |
|
|
138
|
+
| Backend healthy | `hosting_pocketbase_backend { username, domain }` | `state` is `asleep`, `starting` or `running` |
|
|
139
|
+
| PocketBase answers | `GET https://<domain>/api/health` and `GET https://<domain>/_/` | 200 and 200 |
|
|
140
|
+
| Credentials saved | `~/.hostinger/<domain>/.pocketbase/credentials.json` | present, mode `600`, `domain` matches |
|
|
141
|
+
|
|
142
|
+
`GET https://<domain>/` returns the Hostinger default page (or 403) until the frontend is deployed —
|
|
143
|
+
expected, not a failure. There is **no `/cms`** on this domain; the app itself serves every route but
|
|
144
|
+
`/api` and `/_` once it is deployed (Step 8).
|
|
145
|
+
|
|
146
|
+
If a check fails: retry once after ~30 s; if it still fails, stop and point the user at hPanel.
|
|
147
|
+
|
|
148
|
+
## Step 5 — Record `site.json`
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"backend": "pocketbase",
|
|
153
|
+
"website_type": "headless",
|
|
154
|
+
"order_id": 1007223428,
|
|
155
|
+
"username": "u…",
|
|
156
|
+
"runtime": "nodejs",
|
|
157
|
+
"pocketbase": {
|
|
158
|
+
"instance_id": "…",
|
|
159
|
+
"version": "…",
|
|
160
|
+
"superuser_email": "…",
|
|
161
|
+
"credentials_file": ".pocketbase/credentials.json"
|
|
162
|
+
},
|
|
163
|
+
"urls": {
|
|
164
|
+
"site": "https://<domain>",
|
|
165
|
+
"api": "https://<domain>/api",
|
|
166
|
+
"admin": "https://<domain>/_/"
|
|
167
|
+
},
|
|
168
|
+
"provisioned_at": "…",
|
|
169
|
+
"verified_at": "…"
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`credentials_file` is relative to the workspace `~/.hostinger/<domain>/`. No passwords or tokens in
|
|
174
|
+
`site.json` — the superuser password lives only in the credentials file. Together, `superuser_email`
|
|
175
|
+
and that file are the owner's **login access** to the dashboard at `urls.admin`; the done step hands
|
|
176
|
+
them over by name (the email, the file's full path, never the password itself).
|
|
177
|
+
|
|
178
|
+
## Content model & deploy (what happens next)
|
|
179
|
+
|
|
180
|
+
- **Content model** runs `../../04-content-model/pocketbase/SKILL.md`: it designs the collections,
|
|
181
|
+
access rules and seed records in `pocketbase/schema.json` during the provision wait, then applies
|
|
182
|
+
and verifies them against this backend at the instance barrier. The shared prepare phase still
|
|
183
|
+
writes the site's fixed copy (title, navigation, pages) to `content-model.md`.
|
|
184
|
+
- **Deploy** is a standard Node.js application deploy, handled by `../../08-deploy/SKILL.md`: it archives
|
|
185
|
+
the **source** (not the build output; exclude `node_modules/`, `.next/`, `dist/`, build output and
|
|
186
|
+
`.git/`), then deploys with `hosting_deploy` (`type: "nodejs"`, upload + server-side `npm install` +
|
|
187
|
+
build, one shot) passing the framework's `appType` + `outputDirectory` inline, and polls
|
|
188
|
+
`hosting_get-deployment` until the build completes. Any supported `appType` works (Next.js, Nuxt,
|
|
189
|
+
Express, NestJS, Fastify, Vite/React/Vue SPA, …). `/api` and `/_` keep belonging to PocketBase; deploy
|
|
190
|
+
checks they survived.
|
|
@@ -10,7 +10,7 @@ Two phases around the **instance barrier** (see the top-level `SKILL.md`):
|
|
|
10
10
|
- **Prepare — no instance.** Build the content helper from `brief.md` and generate the content it
|
|
11
11
|
calls for. Runs *during* the provision wait; needs only the brief.
|
|
12
12
|
- **Push — needs the instance.** Create that content in the backend. Gated on
|
|
13
|
-
`provision.status == "completed"`; routes to `wordpress/` or `
|
|
13
|
+
`provision.status == "completed"`; routes to `wordpress/`, `ecommerce/` or `pocketbase/`.
|
|
14
14
|
|
|
15
15
|
**In:** `brief.md`. **Out:** `content-model.md` (+ any generated media under
|
|
16
16
|
`~/.hostinger/<domain>/media/`).
|
|
@@ -19,6 +19,42 @@ Two phases around the **instance barrier** (see the top-level `SKILL.md`):
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## Prepare in a subagent
|
|
23
|
+
|
|
24
|
+
**Content subagent: skip this section and start at *Prepare phase*.** Main agent with a subagent
|
|
25
|
+
tool: don't do the prepare phase yourself (*Content and design at the same time* in the top-level
|
|
26
|
+
`SKILL.md`). Ask the image-source question (*Images* below), then launch one background subagent
|
|
27
|
+
with the prompt below and go on to design. One subagent keeps the whole site in one voice and leaves
|
|
28
|
+
no files to merge.
|
|
29
|
+
|
|
30
|
+
Send the prompt as it is, filling only the `<…>` slots. Add nothing to it: word counts, item counts,
|
|
31
|
+
extra photos or extra sections make the subagent slower, and the push waits for it.
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
You are the content subagent of a Hostinger headless build for <domain>. Do content prepare
|
|
35
|
+
yourself, start to finish, and skip the section "Prepare in a subagent".
|
|
36
|
+
|
|
37
|
+
Workspace: ~/.hostinger/<domain>/ (brief.md is there). Skill folder: <skill folder>.
|
|
38
|
+
Backend: <backend from brief.md>. Image source the user chose: <their answer>.
|
|
39
|
+
|
|
40
|
+
Follow <skill folder>/steps/04-content-model/SKILL.md → "Prepare phase". For the file format: on
|
|
41
|
+
wordpress, with or without WooCommerce, also <skill folder>/steps/04-content-model/wordpress/SKILL.md
|
|
42
|
+
→ "Step 1 — Write content.json" (the catalog goes under "store"); on pocketbase, also
|
|
43
|
+
<skill folder>/steps/04-content-model/pocketbase/SKILL.md → "Prepare phase"; on ecommerce,
|
|
44
|
+
content-model.md holds the products.
|
|
45
|
+
Take sizes and counts from brief.md and those files only.
|
|
46
|
+
|
|
47
|
+
Write only content-model.md, content.json or pocketbase/schema.json, and media/. Leave state.json,
|
|
48
|
+
the run log, design.md and brand/ alone, and call neither the Hostinger connector nor the live site.
|
|
49
|
+
You can't ask the user anything: the image question is already answered above, and wherever a file
|
|
50
|
+
says to offer or ask the user, or brief.md is silent, pick what fits the site and list it as a gap.
|
|
51
|
+
For Hostinger AI images, write their briefs only; the main agent generates them later.
|
|
52
|
+
|
|
53
|
+
Report back: the files you wrote, the page, article and product counts, and any gaps.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
22
58
|
## Prepare phase — write the content helper (no instance)
|
|
23
59
|
|
|
24
60
|
`content-model.md` is a lightweight helper, not a schema. Fill the **fixed values** from the brief and
|
|
@@ -82,6 +118,10 @@ Guidance:
|
|
|
82
118
|
copy, terms, menu and image details into `~/.hostinger/<domain>/content.json` (format: `wordpress/SKILL.md`
|
|
83
119
|
Step 1), not into `content-model.md`, so nothing is written twice. `content-model.md` keeps the fixed
|
|
84
120
|
values, the prompts and the image briefs.
|
|
121
|
+
- **PocketBase: the fixed copy still comes from here.** Title, Description, Navigation and Pages are
|
|
122
|
+
built into the frontend as on any backend; drop Articles and Products unless the brief has them. What
|
|
123
|
+
visitors create (accounts, bookings, comments, votes, order requests) is designed in
|
|
124
|
+
`pocketbase/schema.json` by `pocketbase/SKILL.md`'s prepare phase, run alongside this one.
|
|
85
125
|
- **Optional sections.** Drop **Articles** if the brief has no article-like content. Drop **Products**
|
|
86
126
|
for a non-commerce brief; for a commerce brief, generate the product catalog here (names, prices,
|
|
87
127
|
descriptions, collections, images) — that's prepare work, and the `ecommerce` push phase then creates
|
|
@@ -100,7 +140,7 @@ not an answer, see *When you ask the user* in the top-level `SKILL.md`):
|
|
|
100
140
|
| Option | Tool | Backends | Needs the live instance? |
|
|
101
141
|
|---|---|---|---|
|
|
102
142
|
| **A — Hostinger AI image generation** *(default for WordPress / WooCommerce)* | `wordpress_ai-content_generate-images` | WordPress, WordPress + WooCommerce | **yes** — runs at the instance barrier |
|
|
103
|
-
| **B — Unsplash stock photos** *(default for Ecommerce /
|
|
143
|
+
| **B — Unsplash stock photos** *(default for Ecommerce / PocketBase; the fallback everywhere)* | Unsplash API, or web fetch of Unsplash search pages | any | no — pure prepare work |
|
|
104
144
|
|
|
105
145
|
> **Do not silently fall back to stock on a WordPress site.** On WordPress / WooCommerce the default is
|
|
106
146
|
> **Hostinger AI (Option A)** — on-brand, generated from `design.md`. Using Unsplash on a WordPress build
|
|
@@ -164,7 +204,8 @@ runs **at the instance barrier** (after `provision.status == "completed"`), usin
|
|
|
164
204
|
Follow [`images-unsplash.md`](images-unsplash.md). It is prepare work and needs no live backend.
|
|
165
205
|
|
|
166
206
|
Then update `state.json`: set `stage` to the next prepare stage still to do, fresh `updated_at`. Do
|
|
167
|
-
**not** advance past the barrier here.
|
|
207
|
+
**not** advance past the barrier here. A content subagent skips this: the main agent owns
|
|
208
|
+
`state.json`.
|
|
168
209
|
|
|
169
210
|
---
|
|
170
211
|
|
|
@@ -181,18 +222,14 @@ token) to create the menu, pages, posts, categories and media:
|
|
|
181
222
|
| WordPress | `wordpress/SKILL.md` |
|
|
182
223
|
| WordPress + WooCommerce | `wordpress/SKILL.md` — pushes WP content **and** seeds the WooCommerce catalog (its WooCommerce section + `wordpress/woocommerce.md`) |
|
|
183
224
|
| Ecommerce | `ecommerce/SKILL.md` |
|
|
184
|
-
|
|
|
225
|
+
| PocketBase | `pocketbase/SKILL.md` — applies `pocketbase/schema.json` (collections, access rules, seed records) to the backend and verifies it |
|
|
185
226
|
|
|
186
|
-
> **Supported backends: `wordpress` (optionally with a WooCommerce store), `ecommerce
|
|
187
|
-
>
|
|
188
|
-
>
|
|
189
|
-
>
|
|
227
|
+
> **Supported backends: `wordpress` (optionally with a WooCommerce store), `ecommerce` and `pocketbase`.**
|
|
228
|
+
> A **WordPress + WooCommerce** brief routes to `wordpress/SKILL.md`, which pushes the WP content
|
|
229
|
+
> **and** seeds the WooCommerce catalog in the same push. A **PocketBase** brief pushes its collections,
|
|
230
|
+
> rules and seed records through `pocketbase/SKILL.md`; its fixed copy stays in `content-model.md` and
|
|
231
|
+
> is built into the frontend, since PocketBase holds what visitors create, not the site's pages.
|
|
190
232
|
> Push to whichever single backend provision set up (see the provision router) — don't try to push to two
|
|
191
233
|
> backends here.
|
|
192
|
-
>
|
|
193
|
-
> **Webapp has no content backend.** There is no CMS or store to seed, so a `webapp` brief **skips this
|
|
194
|
-
> whole stage** — both prepare and push. The app owns its own data (its own API or database). Leave
|
|
195
|
-
> `content-model.md` unwritten, mark content-model `skipped` in the run log, and go straight to the
|
|
196
|
-
> frontend step.
|
|
197
234
|
|
|
198
235
|
After the push completes, update `state.json` and continue to the frontend **data** phase.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: headless-step-content-model-pocketbase
|
|
3
|
+
description: "Step 4 (content model) for the PocketBase backend of the Hostinger Headless flow. Prepare phase: turns the brief's visitor features into pocketbase/schema.json (collections, access rules, unique indexes, rate limits, seed records) from tested recipes and validates it offline. Push phase: applies it to the live backend with pb-apply-schema.mjs and checks it with pb-verify.mjs. Idempotent, instance-gated."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# headless-step-content-model-pocketbase
|
|
7
|
+
|
|
8
|
+
Runs for the **PocketBase** backend (`site.json → backend: "pocketbase"`). Such an app keeps what
|
|
9
|
+
its **visitors** enter: accounts, bookings, comments, votes, scores, order requests, uploads, live
|
|
10
|
+
messages. This step designs that data and its access rules, and seeds the records the owner starts
|
|
11
|
+
with (classes, menu items, rooms, events). The site's fixed copy (Title, Description, Navigation,
|
|
12
|
+
Pages) still comes from `content-model.md` and is built into the frontend. An app that stores nothing
|
|
13
|
+
yet still gets a schema (`{ "collections": [] }`): apply is a no-op, and verify still proves the backend.
|
|
14
|
+
|
|
15
|
+
The one rule that matters: **access is decided by the collection rules, never by frontend code**, so
|
|
16
|
+
every rule is written on purpose and checked against the live backend.
|
|
17
|
+
|
|
18
|
+
**In:** `brief.md`, `content-model.md` (when the shared prepare phase wrote one), `site.json` (push only). **Out:**
|
|
19
|
+
`~/.hostinger/<domain>/pocketbase/schema.json`, applied to the backend.
|
|
20
|
+
|
|
21
|
+
`<here>` below is this folder (`steps/04-content-model/pocketbase/` in the installed skill). The
|
|
22
|
+
scripts need Node.js 18 or later and nothing else.
|
|
23
|
+
|
|
24
|
+
## Prepare phase — write and check the schema (no instance)
|
|
25
|
+
|
|
26
|
+
Runs during the provision wait, alongside the shared prepare phase in `../SKILL.md`.
|
|
27
|
+
|
|
28
|
+
1. **List the visitor features** from the brief's **Purpose**, **Pages** and **Must-haves**: what
|
|
29
|
+
visitors create, who may read it, who may change it, and whether visitors need accounts.
|
|
30
|
+
2. **Start each one from the closest recipe** in `<here>/patterns.md` (contact form, comments, likes
|
|
31
|
+
and votes, leaderboard, private notes, live chat, order requests, bookings with limited places,
|
|
32
|
+
admin area). Rename collections and fields to fit the site, and combine the recipes in one
|
|
33
|
+
`collections` array. `<here>/schema.md` has the file format, `<here>/rules.md` the rule syntax,
|
|
34
|
+
`<here>/schema.example.json` a complete example.
|
|
35
|
+
3. **Seed what the owner starts with** (the classes and their places, the menu, the rooms) with
|
|
36
|
+
`seed` records drawn from `content-model.md`. Seed records are inserted only into an empty
|
|
37
|
+
collection, so a re-run never duplicates them.
|
|
38
|
+
4. **Accounts only when the site needs them.** No per-person data (contact form, guestbook, anonymous
|
|
39
|
+
polls, bookings, order requests) → no login; the rules protect it. Owners of their own records,
|
|
40
|
+
private data or moderators → email and password, as `<here>/auth.md` says. Only the site owner
|
|
41
|
+
signs in → a separate auth collection with `create` set to `null`.
|
|
42
|
+
5. Write it to `~/.hostinger/<domain>/pocketbase/schema.json`, then validate it offline:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
node <here>/scripts/pb-apply-schema.mjs --check ~/.hostinger/<domain>/pocketbase/schema.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Fix every reported problem until it passes. Then list each collection and what it holds under a
|
|
49
|
+
`## Data` section of `content-model.md`, creating the file with just that section when the shared
|
|
50
|
+
prepare phase didn't write one, so the frontend step finds the whole data model in one place.
|
|
51
|
+
|
|
52
|
+
Rules that prevent the common failures:
|
|
53
|
+
|
|
54
|
+
- A rule is a filter: `null` = superusers only, `""` = everyone. Start from a recipe, never from `""`
|
|
55
|
+
everywhere.
|
|
56
|
+
- What a visitor must not change goes in the rule, not in frontend code: ownership
|
|
57
|
+
(`@request.body.owner = @request.auth.id`), locked fields (`@request.body.status:isset = false`),
|
|
58
|
+
state (`@request.body.room.open = true`).
|
|
59
|
+
- One per person, and any fixed number of places, is a unique index, not a frontend check.
|
|
60
|
+
- Text length is the field's `max`, not a rule.
|
|
61
|
+
- Anything anyone can create gets a honeypot field and a rate limit (`patterns.md`, contact form).
|
|
62
|
+
- To take a record off other people's screens, delete it: subscribers get no realtime event for a
|
|
63
|
+
record they can no longer see, so a "hidden" flag leaves it on their screen.
|
|
64
|
+
|
|
65
|
+
## Push phase — apply and verify (needs the instance)
|
|
66
|
+
|
|
67
|
+
Only once `provision.status == "completed"`.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
node <here>/scripts/pb-apply-schema.mjs ~/.hostinger/<domain>/pocketbase/schema.json ~/.hostinger/<domain>/.pocketbase/credentials.json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Fix every reported problem and run it again until it prints `DONE`. It is idempotent: it never
|
|
74
|
+
deletes fields or data, adds `created` and `updated` timestamps, inserts `seed` records into empty
|
|
75
|
+
collections and merges `rateLimits`. Re-run it after every schema change; a schema change needs no
|
|
76
|
+
redeploy.
|
|
77
|
+
|
|
78
|
+
Then check the backend against the schema:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
node <here>/scripts/pb-verify.mjs ~/.hostinger/<domain>/.pocketbase/credentials.json ~/.hostinger/<domain>/pocketbase/schema.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Every `FAIL` must be fixed here except the last one, *the website itself returned …; deploy the
|
|
85
|
+
frontend*: the frontend isn't deployed yet, so deploy runs the same command again and expects
|
|
86
|
+
`READY`. A realtime `WARN` over HTTP/1.1 is fine for browsers; `<here>/troubleshooting.md` covers it
|
|
87
|
+
and the other traps.
|
|
88
|
+
|
|
89
|
+
Delete any test records you created by hand before handing over. Then update `state.json` and continue
|
|
90
|
+
to the frontend **data** phase.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Login
|
|
2
|
+
|
|
3
|
+
Email and password only. The built-in `users` auth collection has `email`, `password`, `name` and `avatar`; it needs no setup. Set its rules in `schema.json` (the example keeps each user's record private to that user, and `patterns.md` adds an admin flag).
|
|
4
|
+
|
|
5
|
+
## One form: sign in or create the account
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { ClientResponseError } from "pocketbase"
|
|
9
|
+
|
|
10
|
+
export async function signInOrUp(email: string, password: string) {
|
|
11
|
+
if (password.length < 8) throw new Error("Use at least 8 characters.")
|
|
12
|
+
try {
|
|
13
|
+
return await pb.collection("users").authWithPassword(email, password)
|
|
14
|
+
} catch (signInError) {
|
|
15
|
+
if (!(signInError instanceof ClientResponseError) || signInError.status !== 400) throw signInError
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
await pb.collection("users").create({ email, password, passwordConfirm: password })
|
|
19
|
+
} catch (createError) {
|
|
20
|
+
const emailTaken = createError instanceof ClientResponseError && createError.response?.data?.email?.code === "validation_not_unique"
|
|
21
|
+
if (emailTaken) throw new Error("That email already has an account with a different password.")
|
|
22
|
+
throw createError
|
|
23
|
+
}
|
|
24
|
+
return pb.collection("users").authWithPassword(email, password)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With the plain HTML SDK, use `PocketBase.ClientResponseError`.
|
|
29
|
+
|
|
30
|
+
- A wrong password and an unknown email both return 400 "Failed to authenticate."; the create step tells them apart.
|
|
31
|
+
- The platform limits sign-in attempts to 20 per 5 minutes per IP for signed-out visitors (`*:auth`), which slows password guessing. A 429 means wait.
|
|
32
|
+
- Show the error message next to the form; keep the typed email.
|
|
33
|
+
|
|
34
|
+
## Session
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
pb.authStore.isValid
|
|
38
|
+
pb.authStore.record
|
|
39
|
+
pb.authStore.onChange((token, record) => setUser(record), true)
|
|
40
|
+
pb.authStore.clear()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The SDK keeps the session in `localStorage` (`pocketbase_auth`). Call `pb.collection("users").authRefresh()` on app start when `isValid` is true, to pick up changes made in the dashboard (such as an admin flag), and clear the store if it fails.
|
|
44
|
+
|
|
45
|
+
## Mail-dependent features
|
|
46
|
+
|
|
47
|
+
Email verification, password reset and email change send mail, and outgoing mail is off on a new backend. Until the owner sets an SMTP server in the dashboard (Settings > Mail settings):
|
|
48
|
+
|
|
49
|
+
- Do not require `verified = true` in rules.
|
|
50
|
+
- Do not show a "Forgot password?" link. The owner can set a new password for a user in the dashboard.
|
|
51
|
+
|
|
52
|
+
Once mail works: `pb.collection("users").requestPasswordReset(email)` sends the reset link, and `requestVerification(email)` sends a verification link. The links open PocketBase's own confirmation pages under `https://<domain>/_/`, so the app needs no page of its own for them.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Connecting the app
|
|
2
|
+
|
|
3
|
+
The backend is on the same domain as the site, so the browser needs no API URL, no CORS setup and no keys.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- Bundled apps, plain HTML, local development
|
|
8
|
+
- Everyday calls, pagination, errors
|
|
9
|
+
- Files
|
|
10
|
+
- Realtime
|
|
11
|
+
- Node.js apps on the same website
|
|
12
|
+
- Routing for single-page apps
|
|
13
|
+
|
|
14
|
+
## Bundled apps (Vite, React, Vue, Svelte, Next.js static export)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install pocketbase@0.28.1
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import PocketBase from "pocketbase"
|
|
22
|
+
|
|
23
|
+
export const pb = new PocketBase(import.meta.env.DEV ? "https://<domain>" : window.location.origin)
|
|
24
|
+
pb.autoCancellation(false)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`autoCancellation(false)` matters: by default the SDK aborts an earlier request to the same collection when a new one starts, so parallel loads fail with "The request was aborted". For Next.js use `process.env.NODE_ENV === "development"` in place of `import.meta.env.DEV`.
|
|
28
|
+
|
|
29
|
+
## Plain HTML
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/pocketbase@0.28.1/dist/pocketbase.umd.js"></script>
|
|
33
|
+
<script>
|
|
34
|
+
const pb = new PocketBase(window.location.origin)
|
|
35
|
+
pb.autoCancellation(false)
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Local development
|
|
40
|
+
|
|
41
|
+
There is one backend, the live one. In development the app talks to it directly (above), not through a dev-server proxy: a proxy works for REST but realtime through it depends on HTTP/1.1 (`troubleshooting.md`). Records created while testing are real data; delete them in the dashboard before handing over, or use a test account. Opening the app from `file://` does not work for same-origin calls; use the dev server.
|
|
42
|
+
|
|
43
|
+
## Everyday calls
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const page = await pb.collection("posts").getList(1, 20, {
|
|
47
|
+
filter: pb.filter("published = {:p} && author = {:a}", { p: true, a: userId }),
|
|
48
|
+
sort: "-created",
|
|
49
|
+
expand: "author",
|
|
50
|
+
})
|
|
51
|
+
const all = await pb.collection("products").getFullList({ sort: "name" })
|
|
52
|
+
const one = await pb.collection("posts").getOne(id)
|
|
53
|
+
const first = await pb.collection("rooms").getFirstListItem(pb.filter("slug = {:s}", { s: slug }))
|
|
54
|
+
const post = await pb.collection("posts").create({ title, author: pb.authStore.record.id })
|
|
55
|
+
await pb.collection("posts").update(post.id, { published: true })
|
|
56
|
+
await pb.collection("posts").delete(post.id)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- Build every filter with `pb.filter(expr, params)`; never put user input into a filter string yourself.
|
|
60
|
+
- `getList` returns `{ items, page, perPage, totalItems, totalPages }`; `perPage` goes up to 1000. Show "Load more" with the next `page`, or pass `skipTotal: true` when the count is not needed (faster).
|
|
61
|
+
- `getFullList` fetches every page; use it only for small collections such as a catalog.
|
|
62
|
+
- `expand: "author"` puts the related record in `record.expand.author`, but only if the caller may view it under that collection's rules.
|
|
63
|
+
|
|
64
|
+
## Errors
|
|
65
|
+
|
|
66
|
+
Errors are `ClientResponseError` with `status` and `response`:
|
|
67
|
+
|
|
68
|
+
- 400 with `response.data.<field>.message`: show that message next to the field.
|
|
69
|
+
- 400 "Failed to create record." with empty `data`: the create rule rejected it (honeypot filled, wrong owner, room closed). Show a general "Could not send" and check the rule.
|
|
70
|
+
- 404 on view, update or delete: not found or not allowed by the rule.
|
|
71
|
+
- 403: the rule is `null` (superusers only).
|
|
72
|
+
- 429: rate limit. Ask the visitor to wait a minute.
|
|
73
|
+
- `status` 0: network error or aborted request.
|
|
74
|
+
|
|
75
|
+
## Files
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const form = new FormData()
|
|
79
|
+
form.append("title", title)
|
|
80
|
+
form.append("cover", fileInput.files[0])
|
|
81
|
+
const post = await pb.collection("posts").create(form)
|
|
82
|
+
const url = pb.files.getURL(post, post.cover, { thumb: "400x300" })
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- Files over the field's `maxSize` (default 5 MB) are rejected with a field error; check `file.size` before uploading.
|
|
86
|
+
- Thumbnails work only for sizes listed in the field's `thumbs`.
|
|
87
|
+
- For `protected` file fields, fetch a token first: `const token = await pb.files.getToken()` and pass `{ token }` to `getURL`. It expires after a few minutes.
|
|
88
|
+
|
|
89
|
+
## Realtime
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const unsubscribe = await pb.collection("messages").subscribe(
|
|
93
|
+
"*",
|
|
94
|
+
(event) => {
|
|
95
|
+
if (event.action === "create") add(event.record)
|
|
96
|
+
if (event.action === "update") replace(event.record)
|
|
97
|
+
if (event.action === "delete") remove(event.record.id)
|
|
98
|
+
},
|
|
99
|
+
{ filter: pb.filter("room = {:room}", { room: roomId }), expand: "author" },
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- Load the initial list first, then subscribe, and merge by `id` so nothing shows twice.
|
|
104
|
+
- Call `unsubscribe()` when the view unmounts.
|
|
105
|
+
- `pb.realtime.isConnected` tells whether the stream is up; show a small "Live" or "Connecting" indicator.
|
|
106
|
+
- Events follow the collection's view rule: a visitor only receives records they may view.
|
|
107
|
+
- An idle backend sleeps after about 5 minutes and wakes on the next request; an open realtime stream keeps it awake. The first request after sleep can take a few seconds or return 503 once, so retry once and keep timeouts at 10 s or more.
|
|
108
|
+
|
|
109
|
+
## Node.js apps on the same website
|
|
110
|
+
|
|
111
|
+
A Node.js app on the site can call its own backend at `https://<domain>` for trusted server-side work (webhooks, scheduled jobs, writes visitors must not make):
|
|
112
|
+
|
|
113
|
+
1. Store `PB_URL`, `PB_SUPERUSER_EMAIL` and `PB_SUPERUSER_PASSWORD` as Node.js environment variables. `hosting_nodejs_replace-environment-variables` replaces the full set, so read the current ones first and send them all.
|
|
114
|
+
2. Authenticate once at startup with `pb.collection("_superusers").authWithPassword(email, password)` and again on a 401.
|
|
115
|
+
3. The app's own routes must not start with `/api` or `/_`; those paths go to PocketBase.
|
|
116
|
+
4. For realtime subscriptions from Node.js, check the HTTP/1.1 note in `troubleshooting.md`.
|
|
117
|
+
|
|
118
|
+
## Routing for single-page apps
|
|
119
|
+
|
|
120
|
+
PocketBase owns `/api/*` and `/_/*`. If the app uses history routing (`/rooms/42`) on a static deploy, add `public/.htaccess` so unknown paths load `index.html` without catching the backend:
|
|
121
|
+
|
|
122
|
+
```apache
|
|
123
|
+
RewriteEngine On
|
|
124
|
+
RewriteCond %{REQUEST_URI} !^/(api|_)(/|$)
|
|
125
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
126
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
127
|
+
RewriteRule ^ /index.html [L]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Hash routing (`/#/rooms/42`) needs nothing.
|