Cloudflare Worker that acts as the trusted intermediary between the FragCap plugin and the FragCap registry.
User (plugin) → POST /register { gist_id } → Worker → reads public Gist from GitHub → rate-limits by gist owner → writes shard to registry repo
The Worker holds the GitHub App installation token and is the only component with write access to the registry repository. The plugin never touches the registry directly. No user credentials are accepted or stored — gist ownership is established by reading the public gist metadata from GitHub's own API.
Each registered Gist must contain a SKILL.md file — a structured markdown file with YAML frontmatter. The Worker parses the frontmatter to extract id, tags, description, status, and author for the registry index, and reads the ## Problem and ## Fix sections from the markdown body.
Registrations are limited to 20 per gist owner per UTC day, enforced via Cloudflare KV. The owner identity is read directly from the public gist's owner.login field returned by GitHub — no user token is required.
Registers a public Gist as a FragCap capsule in the registry.
Headers:
Content-Type: application/json
Body:
{ "gist_id": "abc123..." }Validation:
- Gist must be public
- Gist description must contain
[fragcap] - Gist must contain a
SKILL.mdfile - SKILL.md must have valid frontmatter with
id,tags, anddescriptionfields - SKILL.md must not exceed 100 KB
Responses:
200 { "ok": true }— registered successfully400— missing/invalidgist_idor gist fails validation404— gist not found429— rate limit exceeded (20 registrations per owner per day)500— internal error
Returns worker status.
Response: 200 { "ok": true, "service": "fragcap-worker" }
- Go to GitHub → Settings → Developer settings → GitHub Apps → New GitHub App.
- Set the app name (e.g.
fragcap-registry-bot). - Under Repository permissions, set Contents to Read & Write.
- Install the app on the
fragcap/registryrepository. - Note the App ID and Installation ID.
- Generate and download a private key (
.pemfile).
GitHub provides PKCS1 keys; Cloudflare Workers requires PKCS8:
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in key.pem -out key-pkcs8.pemwrangler kv namespace create RATE_LIMITCopy the id from the output and add it to wrangler.toml (already pre-filled for the production deployment):
[[kv_namespaces]]
binding = "RATE_LIMIT"
id = "<your-namespace-id>"wrangler secret put APP_ID
wrangler secret put PRIVATE_KEY # paste the contents of key-pkcs8.pem
wrangler secret put INSTALLATION_IDnpm install
npx wrangler deployCreate .dev.vars (see .dev.vars.example):
APP_ID=your_app_id
PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----
INSTALLATION_ID=your_installation_id
Then run:
npx wrangler dev