Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions dist/pgboxdb.com/README.md
Original file line number Diff line number Diff line change
@@ -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 `<x-dc>` document + `support.js`), not a managed site. There is **no** `/install` route.
- The serving configuration lives in the **Cloudflare account**, not in this repository.
Expand All @@ -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).
Expand Down
6 changes: 6 additions & 0 deletions dist/pgboxdb.com/index.js
Original file line number Diff line number Diff line change
@@ -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);
96 changes: 59 additions & 37 deletions dist/pgboxdb.com/install-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}
38 changes: 38 additions & 0 deletions dist/pgboxdb.com/install-worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
185 changes: 185 additions & 0 deletions dist/pgboxdb.com/llms.txt
Original file line number Diff line number Diff line change
@@ -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)
Loading
Loading