diff --git a/dist/pgboxdb.com/README.md b/dist/pgboxdb.com/README.md index 15c06104d4..a52829883f 100644 --- a/dist/pgboxdb.com/README.md +++ b/dist/pgboxdb.com/README.md @@ -1,10 +1,24 @@ -# pgboxdb.com `/install` endpoint (prepared, not deployed) +# pgboxdb.com `/install` and `/llms.txt` endpoints -`https://pgboxdb.com/install` must serve the reviewed [`dist/install.sh`](../install.sh) -so that `curl -fsSL https://pgboxdb.com/install | sh` works. Today `pgboxdb.com` is a -Cloudflare-hosted placeholder page and `/install` returns **HTTP 404**. +The Cloudflare Worker `pgboxdb-install` (this directory) owns two routes on +`pgboxdb.com`: -## Current hosting (identified) +* `/install` serves the reviewed [`dist/install.sh`](../install.sh) from the + pinned release tag `INSTALL_REF`, so `curl -fsSL https://pgboxdb.com/install | sh` + installs that release. +* `/llms.txt` serves [`llms.txt`](llms.txt), the agent-facing summary of the + product. Update it with every release (a test checks it names the npm + package version) and redeploy. + +Both routes are more specific than whatever serves the rest of `pgboxdb.com`, +so they win over it. The rest of the site is not in this repository. + +| Version | Deployed (UTC) | Change | +|---|---|---| +| `9d1e7dd0-88a9-413d-9260-f45f270b8c39` | 2026-11-23 18:43 | `/install`, `INSTALL_REF` v0.2.0 | +| `5f39dbe1-88f4-453c-94df-fab05df23a6b` | 2026-11-23 | + `/llms.txt` (v0.2.0) | + +## Hosting before this Worker (historical) - `pgboxdb.com` resolves through **Cloudflare** (`server: cloudflare`, `cf-ray`, `cf-cache-status`). - The root serves a **parked/placeholder page** (an `` document + `support.js`), not a managed site. There is **no** `/install` route. - The serving configuration lives in the **Cloudflare account**, not in this repository. @@ -30,10 +44,12 @@ own the zone — so a successful deploy is itself proof of control. ## Deploy (maintainer, after approval — needs Cloudflare access) ```sh cd dist/pgboxdb.com +node --test install-worker.test.js npx wrangler deploy --var INSTALL_REF:v0.2.0 # pin to the released tag (a PGBoxDB release, >= v0.2.0) curl -fsSL https://pgboxdb.com/install | head # verify it serves the script +curl -fsSL https://pgboxdb.com/llms.txt | head ``` -This adds a single route; it does **not** change DNS or other pgboxdb.com content. +This owns only `/install` and `/llms.txt`; it does **not** change DNS or other pgboxdb.com content. ## Prerequisites before the public `curl | sh` works 1. Publish the GitHub release (tag `v0.2.0`, the first PGBoxDB release) with the platform tarballs + `.sha256` (via `.github/workflows/release.yml`, draft → manual publish). diff --git a/dist/pgboxdb.com/index.js b/dist/pgboxdb.com/index.js new file mode 100644 index 0000000000..3fdf9ef709 --- /dev/null +++ b/dist/pgboxdb.com/index.js @@ -0,0 +1,6 @@ +// Worker entry for pgboxdb.com/install and pgboxdb.com/llms.txt. +// Wrangler bundles llms.txt as a text module (its default rule for *.txt). +import llmsTxt from "./llms.txt"; +import { createWorker } from "./install-worker.js"; + +export default createWorker(llmsTxt); diff --git a/dist/pgboxdb.com/install-worker.js b/dist/pgboxdb.com/install-worker.js index 105ef82b00..5cc8b49168 100644 --- a/dist/pgboxdb.com/install-worker.js +++ b/dist/pgboxdb.com/install-worker.js @@ -16,41 +16,63 @@ const REPO = "pgrundev/pgboxdb"; // hex commit sha (7–40). A branch name like "main" is intentionally rejected. const REF_RE = /^(v\d+\.\d+\.\d+[0-9A-Za-z.-]*|[0-9a-f]{7,40})$/; -export default { - async fetch(request, env) { - const url = new URL(request.url); - if (url.pathname !== "/install") { - return new Response("not found\n", { status: 404 }); - } - if (request.method !== "GET" && request.method !== "HEAD") { - return new Response("method not allowed\n", { status: 405 }); - } - const ref = env && env.INSTALL_REF; - if (!ref || !REF_RE.test(ref)) { - // Misconfiguration must fail loudly, never silently serve a mutable ref. - return new Response( - "pgboxdb installer misconfigured: INSTALL_REF must be a pinned release tag (e.g. v0.1.0-beta.1) or commit sha\n", - { status: 500, headers: { "content-type": "text/plain; charset=utf-8" } } - ); - } - const raw = `https://raw.githubusercontent.com/${REPO}/${ref}/dist/install.sh`; - const upstream = await fetch(raw, { cf: { cacheTtl: 300, cacheEverything: true } }); - if (!upstream.ok) { - // Fail loudly: never serve an empty/200 body that would make `| sh` a no-op - // (e.g. an invalid ref whose raw URL 404s). - return new Response(`pgboxdb installer unavailable (upstream ${upstream.status} for ref ${ref})\n`, { - status: 502, - headers: { "content-type": "text/plain; charset=utf-8" }, - }); - } - const body = await upstream.text(); - return new Response(body, { - status: 200, - headers: { - "content-type": "text/x-shellscript; charset=utf-8", - "cache-control": "public, max-age=300", - "x-pgboxdb-install-ref": ref, - }, +// /llms.txt is the agent-facing summary of the product (llms.txt, the file +// in this directory). index.js passes its text in; the Worker serves it on the +// pgboxdb.com/llms.txt route, which is more specific than whatever serves the +// rest of the site, so the summary always matches the current release. +export function createWorker(llmsTxt) { + return { + async fetch(request, env) { + const url = new URL(request.url); + if (request.method !== "GET" && request.method !== "HEAD") { + return new Response("method not allowed\n", { status: 405 }); + } + if (url.pathname === "/llms.txt" && llmsTxt) { + return new Response(request.method === "HEAD" ? null : llmsTxt, { + status: 200, + headers: { + "content-type": "text/plain; charset=utf-8", + "cache-control": "public, max-age=300", + }, + }); + } + if (url.pathname !== "/install") { + return new Response("not found\n", { status: 404 }); + } + return install(env); + }, + }; +} + +// Without llms.txt text (the unit tests of /install): /install only. +export default createWorker(null); + +async function install(env) { + const ref = env && env.INSTALL_REF; + if (!ref || !REF_RE.test(ref)) { + // Misconfiguration must fail loudly, never silently serve a mutable ref. + return new Response( + "pgboxdb installer misconfigured: INSTALL_REF must be a pinned release tag (e.g. v0.1.0-beta.1) or commit sha\n", + { status: 500, headers: { "content-type": "text/plain; charset=utf-8" } } + ); + } + const raw = `https://raw.githubusercontent.com/${REPO}/${ref}/dist/install.sh`; + const upstream = await fetch(raw, { cf: { cacheTtl: 300, cacheEverything: true } }); + if (!upstream.ok) { + // Fail loudly: never serve an empty/200 body that would make `| sh` a no-op + // (e.g. an invalid ref whose raw URL 404s). + return new Response(`pgboxdb installer unavailable (upstream ${upstream.status} for ref ${ref})\n`, { + status: 502, + headers: { "content-type": "text/plain; charset=utf-8" }, }); - }, -}; + } + const body = await upstream.text(); + return new Response(body, { + status: 200, + headers: { + "content-type": "text/x-shellscript; charset=utf-8", + "cache-control": "public, max-age=300", + "x-pgboxdb-install-ref": ref, + }, + }); +} diff --git a/dist/pgboxdb.com/install-worker.test.js b/dist/pgboxdb.com/install-worker.test.js index 811ccf2f96..1e80c59e88 100644 --- a/dist/pgboxdb.com/install-worker.test.js +++ b/dist/pgboxdb.com/install-worker.test.js @@ -70,3 +70,41 @@ test("non-GET methods are rejected", async () => { const res = await worker.fetch(new Request("https://pgboxdb.com/install", { method: "POST" }), { INSTALL_REF: "v0.1.0-beta.1" }); assert.equal(res.status, 405); }); + +// ---- /llms.txt (served by the same Worker; text from llms.txt) ---- +import { readFileSync } from "node:fs"; +import { createWorker } from "./install-worker.js"; + +const LLMS = readFileSync(new URL("./llms.txt", import.meta.url), "utf8"); +const site = createWorker(LLMS); + +test("/llms.txt serves the llms.txt file as plain text, without upstream fetches", async () => { + const calls = stubFetch(notFound); + const res = await site.fetch(new Request("https://pgboxdb.com/llms.txt"), { INSTALL_REF: "v0.2.0" }); + assert.equal(res.status, 200); + assert.match(res.headers.get("content-type"), /^text\/plain/); + assert.equal(await res.text(), LLMS); + assert.equal(calls.length, 0); +}); + +test("/install still works on the Worker that also serves /llms.txt", async () => { + stubFetch(okResp); + const res = await site.fetch(new Request("https://pgboxdb.com/install"), { INSTALL_REF: "v0.2.0" }); + assert.equal(res.status, 200); + assert.equal(await res.text(), SCRIPT); +}); + +test("llms.txt uses the PGBoxDB brand, commands and install URL only", () => { + assert.match(LLMS, /^# PGBoxDB /); + assert.ok(LLMS.includes("curl -fsSL https://pgboxdb.com/install | sh")); + assert.ok(LLMS.includes("/plugin install pgboxdb@pgboxdb-plugin")); + assert.ok(LLMS.includes("--skill pgboxdb")); + // No other spelling of the brand, no unowned domain, no command without "db". + assert.doesNotMatch(LLMS, /PGBOX(?!DB)|PGBox(?!DB)|pgbox\.dev|PGBOX_|\bpgbox(?!db)\b/); + assert.doesNotMatch(LLMS, /(^|[^a-z0-9])(pgx|PGX|pgxdb)([^a-z0-9]|$)|pgx\.dev/); +}); + +test("llms.txt names the version being released", () => { + const pkg = JSON.parse(readFileSync(new URL("../npm/package.json", import.meta.url), "utf8")); + assert.ok(LLMS.includes(`Latest release: v${pkg.version} `), `llms.txt must name v${pkg.version}`); +}); diff --git a/dist/pgboxdb.com/llms.txt b/dist/pgboxdb.com/llms.txt new file mode 100644 index 0000000000..5fbad39143 --- /dev/null +++ b/dist/pgboxdb.com/llms.txt @@ -0,0 +1,185 @@ +# PGBoxDB - Lightweight Postgres for AI Agents + +> PGBoxDB is a lightweight PostgreSQL-compatible database runtime written in Rust. Run thousands of isolated, disposable databases in one process. Designed for AI agents, CI, testing, and local development. + +Website: https://pgboxdb.com +GitHub: https://github.com/pgrundev/pgboxdb +npm: https://www.npmjs.com/package/pgboxdb +Latest release: v0.2.0 (https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0) +License: AGPL-3.0 + +## Quick Start (Recommended) + +The simplest way to install and run PGBoxDB: + +```bash +npx pgboxdb@latest +``` + +This installs PGBoxDB, starts the runtime, creates an `app` database, and prints its PostgreSQL connection URL. + +No Docker, Rust, or system PostgreSQL installation required. + +## What's New in v0.2.0 + +- First release under the PGBoxDB name. The command and the npm package are `pgboxdb`, environment variables are `PGBOXDB_*`, the data home is `~/.pgboxdb`, the project file is `.pgboxdb.toml`. +- `pgboxdb top`: a read-only live terminal monitor of every database, grouped by project, Git branch and agent session. `pgboxdb --json top --snapshot` gives one snapshot as JSON. +- Existing installations of the previous product are never lost: `pgboxdb migrate` moves them (a dry run by default, `--apply` to do it, `--rollback` to undo). + +## Installation Methods + +### 1. NPX - Zero Setup + +```bash +npx pgboxdb@latest +``` + +Recommended for trying PGBoxDB immediately. + +### 2. NPM - Global Installation + +```bash +npm install -g pgboxdb +pgboxdb run +``` + +Recommended for frequent local development. + +### 3. Shell - macOS and Linux + +```bash +curl -fsSL https://pgboxdb.com/install | sh +pgboxdb run +``` + +Recommended when Node.js is unavailable. The installer verifies the SHA-256 of the release tarball. + +### 4. Claude Code - Native Plugin + +Inside Claude Code: + +```text +/plugin marketplace add pgrundev/pgboxdb-plugin +/plugin install pgboxdb@pgboxdb-plugin +``` + +Then ask Claude: + +"Set up isolated PGBoxDB databases for this project." + +The plugin provides agent instructions. The database runtime is installed when needed, subject to user permissions. + +### 5. Cursor, Codex and Other AI Agents + +Install the PGBoxDB agent skill: + +```bash +npx skills add pgrundev/pgboxdb --skill pgboxdb +``` + +Then ask your agent: + +"Use PGBoxDB for isolated development databases. Set up this project." + +The skill helps the agent configure PGBoxDB and database isolation. + +### 6. Docker - Build Locally + +```bash +git clone https://github.com/pgrundev/pgboxdb.git +cd pgboxdb +docker build -t pgboxdb:dev . +docker run --rm -p 5432:5432 \ + -e PGBOXDB_PASSWORD=secret \ + -v pgboxdbdata:/var/lib/pgboxdb \ + pgboxdb:dev +``` + +Recommended for container-based environments. + +### 7. Build from Source + +```bash +git clone https://github.com/pgrundev/pgboxdb.git +cd pgboxdb +cargo build --release --locked --bin postgres +``` + +Requires the pinned Rust toolchain, RE2, and PostgreSQL 18 build/client dependencies. See docs/pgboxdb/local-dev/build-from-source.md. + +## Basic Usage + +```bash +# Start PGBoxDB and get a ready `app` database +pgboxdb run + +# Create a database +pgboxdb create myapp + +# Get a connection URL +pgboxdb url myapp + +# Create an isolated agent branch (expires after 2h by default) +pgboxdb branch myapp agent-001 + +# Create a temporary clone +pgboxdb clone myapp test-001 --ttl 30m + +# Run any command with its own branch in DATABASE_URL +pgboxdb agent exec -- bin/rails test + +# One database per Git branch, automatically +pgboxdb git init + +# Watch every database live +pgboxdb top + +# List databases +pgboxdb ls + +# Stop runtime +pgboxdb stop +``` + +Commands can also run through `npx pgboxdb`. + +## Guidance for AI Agents + +- Prefer `npx pgboxdb@latest` for the simplest setup. +- Prefer the native plugin for Claude Code. +- Prefer the PGBoxDB skill for Cursor, Codex, and other supported agents. +- Use a separate database branch for each independent agent. +- Use TTLs for temporary databases. +- Use `pgboxdb --json ls` for machine-readable database listings. +- Use PostgreSQL-compatible clients and connection URLs. +- Never use PGBoxDB as the production source of truth. +- Do not copy sensitive production data without appropriate sanitization. +- Request permission before installing software or changing project configuration. + +## Platform Support + +- macOS: Apple Silicon +- Linux: x86-64 and ARM64 +- Intel macOS: not currently supported + +## Limitations + +PGBoxDB is an early release for disposable workloads, not a production PostgreSQL replacement. + +- Not crash-safe under the ephemeral runtime profile +- Databases share one runtime failure domain +- PostgreSQL C extensions are not supported +- Copy-on-write cloning depends on filesystem capabilities + +## Documentation + +- [GitHub README](https://github.com/pgrundev/pgboxdb) +- [Release notes v0.2.0](https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0) +- [Install](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/install.md) +- [CLI reference](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/cli.md) +- [Agent setup](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/agents.md) +- [Claude Code plugin](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/claude-plugin.md) +- [Git branches](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/git.md) +- [Live monitor (top)](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/top.md) +- [Import PostgreSQL](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/copy.md) +- [Upgrading from the previous name](https://github.com/pgrundev/pgboxdb/blob/main/docs/pgboxdb/local-dev/upgrading.md) diff --git a/dist/pgboxdb.com/wrangler.toml b/dist/pgboxdb.com/wrangler.toml index cd98678753..153b16f4fe 100644 --- a/dist/pgboxdb.com/wrangler.toml +++ b/dist/pgboxdb.com/wrangler.toml @@ -1,16 +1,17 @@ -# Cloudflare Worker that serves https://pgboxdb.com/install (see install-worker.js). -# PREPARED, NOT DEPLOYED — deploying requires Cloudflare account access and -# maintainer approval. It does not touch DNS or any other pgboxdb.com route. +# Cloudflare Worker that serves https://pgboxdb.com/install (see install-worker.js) +# and https://pgboxdb.com/llms.txt (the file llms.txt). Deployed by a maintainer +# (README.md). It does not touch DNS or any other pgboxdb.com route. name = "pgboxdb-install" -main = "install-worker.js" +main = "index.js" compatibility_date = "2026-10-01" -# The route this Worker owns. Deploying this route REQUIRES that the configured +# The routes this Worker owns. Deploying them REQUIRES that the configured # Cloudflare account controls the pgboxdb.com zone — `wrangler deploy` fails if the # account does not own `zone_name`, which is the enforcement point for # "verify the account controls the zone" (see README). routes = [ { pattern = "pgboxdb.com/install", zone_name = "pgboxdb.com" }, + { pattern = "pgboxdb.com/llms.txt", zone_name = "pgboxdb.com" }, ] # Pinned release ref the installer is served from. There is no fallback in the diff --git a/dist/test/dist_consistency_test.sh b/dist/test/dist_consistency_test.sh index 5c8871f9c2..a7e22ce927 100755 --- a/dist/test/dist_consistency_test.sh +++ b/dist/test/dist_consistency_test.sh @@ -87,7 +87,7 @@ check "Worker route is pgboxdb.com/install" has dist/pgboxdb.com/wrangler.toml ' ALLOW="share/pgx/dist\\.json|share/pgx|'share', 'pgx'|/var/run/pgx|pgx_version|from before the rename|before the rename" hits="$(grep -rnE '(^|[^a-z0-9])(pgx|PGX|pgxdb)([^a-z0-9]|$)|pgx\.dev|pgrundev/pgx([^-]|$)' \ dist/install.sh dist/assemble.sh dist/layout.md dist/npm/lib dist/npm/bin dist/npm/package.json dist/npm/README.md \ - dist/docker Dockerfile dist/pgboxdb.com/install-worker.js dist/pgboxdb.com/wrangler.toml dist/release \ + dist/docker Dockerfile dist/pgboxdb.com/install-worker.js dist/pgboxdb.com/index.js dist/pgboxdb.com/llms.txt dist/pgboxdb.com/wrangler.toml dist/release \ .github/workflows 2>/dev/null | grep -vE "$ALLOW" || true)" [ -z "$hits" ] && ok "no previous-name identifier outside the legacy detection lines" || { bad "previous-name identifiers:"; echo "$hits" | sed 's/^/ /'; }