Repository navigation
Releases
v2.0.0 — organise, find, compare and move pergams
2.0 turns the 1.x server, which published and listed documents, into one for living with them: organise, find, read and compare versions, and move pergams between servers. It also frames every published document in a sandbox. Running 1.x? Read Upgrade notes first.
Organise
- Types come from a configurable list (
PERGAM_TYPES); tags are free-form and belong to the pergam, not to a version. - Pin a pergam to show it as a card above the index (12 at most by default,
PERGAM_MAX_PINNED); the most recently pinned comes first. - Archive a pergam to take it out of the index. Archived pergams stay reachable by URL, and archiving also unpins.
PATCH /{id}/metaedits tags,archivedandpinnedwithout creating a version.POST /pergamaccepts optionaltags(merged into the pergam's tags) andnote.
Find and read
- Search (
?q=) matches titles and the visible text of every pergam, with highlighted snippets. The search field is in every page's top bar, and/focuses it. - A filter dialog filters by several types, authors and tags and by status, with live counts. Filters combine, and the index sorts by date or title, 100 pergams per page with "Load more".
- Index rows carry a one-line summary; a switch shows it under each title.
/{id}/textand/{id}/v{n}/textreturn what a reader sees as Markdown.GET /feed.atomfollows new publications, filtered by tag, author or status.GET /api/pergams,GET /api/pergams/{id}andGET /facetsreturn the index, one pergam and the filter counts as JSON.- Mermaid 11.17.2 is served by the server at
/static/mermaid/11.17.2/mermaid.min.js, so diagrams render with no external request. POST /lintreports what the sandbox would break (external resources, broken TOC anchors, malformed Mermaid blocks) with line and column, and stores nothing.
Versions
- Every version can carry a one-line note (
note, up to 280 characters). - The view page opens each pergam at full width under one bar: version selector, Pin, History and a menu. The History panel lists every version with its note, author and date; older versions say when they were published and link to the current one.
/{id}/diff/v2..v5compares two versions section by section, with pickers for the pair and a Sections list.
Across servers
GET /{id}/exportreturns a pergam whole (every version, its HTML and metadata) as one JSON document, andPOST /importrecreates it on another server with the same id, version numbers and dates. Importing the same document twice changes nothing, and a pergam remembers the server it came from (origin).- The Claude Code skill keeps named servers in
~/.config/pergam/servers.json, publishes to the one you name, and promotes a pergam from one server to another in one command (pergam_promote.py).
Trust
- Published HTML runs sandboxed: framed in an opaque origin, under a content policy that blocks every request to the server's API. A script inside a pergam cannot read the index, publish, patch or submit a form. See Upgrade notes for what that changes for documents.
- With
TRUST_PROXY_USER=1the author of every write comes fromX-Forwarded-User, set by an authenticating reverse proxy. Each pergam then has an owner (the author of v1) and a list of collaborators, and only they can add versions or edit it. Off by default. - Every page the server renders refuses to be framed by another origin.
- Request bodies are capped (
PERGAM_MAX_BODY_MB), andPOST /lintis limited to 2 MB and two at a time. - Errors are shown as a page to browsers; other clients get the same responses as before.
Interface
- One visual system across the index, view, diff, filter and error pages, with light and dark themes: system by default, or chosen from the top bar and remembered. System fonts only; nothing is loaded from elsewhere.
- Every control works with the keyboard and has a visible focus ring; the pages are usable on a phone, and the filter dialog becomes a full-screen sheet there.
- The pages work without script: the filter button opens a page, menus are
<details>dropdowns and "Load more" is a link. Script adds the dialog and live counts, the history panel and the pin, archive and tag controls.
Changed
- Each release is published as a multi-arch image (
linux/amd64,linux/arm64) atghcr.io/diesilveira/pergam, tagged<version>,<major>.<minor>,<major>andlatest. The bundled compose file runs it whenPERGAM_IMAGEis set, and still builds from source when it is not. See Published image. GET /{id}/viewandGET /{id}/v{n}/viewreturn the view page, with the document in a frame, and no longer the document itself./{id}/rawand/{id}/v{n}/rawstill return the posted bytes astext/plain.- The bundled compose service is now
pergam-local(containerpergam-local), and the database schema is created by migrations, not loaded fromdb/schema.sql. - The image is based on
python:3.14-slim;psycopgis 3.3.
Upgrade notes
For anyone running 1.x. The POST /pergam request and response shapes are unchanged: {title, html, type, author, id?} still returns {id, version, view_url, title, type, author}. tags and note are optional additions, and the response carries them only when the request sent them. Clients and the skill that worked against 1.x keep working. What a client can now be refused with: 413 above PERGAM_MAX_BODY_MB, 400 for a control character in author or an invalid tags or note, 400 for a type outside PERGAM_TYPES, and, with TRUST_PROXY_USER on, 401 and 403.
Migrations. Migrations 001 to 008 apply by themselves, in order, when the server starts, and the server listens only after they succeed. They are additive: none drops or rewrites an existing row, and the 1.x tables, indexes and view stay as they are. 001 records the 1.x schema without running DDL; 002 to 008 add pergam_meta, pergam_text, pergam_note and columns on them. The applied ones are listed in schema_migrations. A failed migration rolls back, logs migrations failed and exits non-zero. Back up the database before the first start all the same.
Search index. After the migrations the server fills the text of versions published before 2.0 in the background, 50 at a time. The server answers meanwhile, and until a version is indexed, search still finds it by title.
Database privileges. The role in DATABASE_URL needs:
- With the bundled compose database, nothing: the role owns its database.
- With an external database that 1.x initialised, a role that is not the owner needs
SELECT, INSERTonpergams,SELECTonpergams_latest, andCREATEon the schema (it createsschema_migrations,pergam_meta,pergam_textandpergam_note), plus ownership of the tables it later alters (pergam_meta,pergam_text), which it has when it created them. WithoutCREATE, the owner runs the files indb/migrations/once and grantsSELECT, INSERT, UPDATEonpergam_metaandpergam_textandSELECT, INSERTonpergam_noteandschema_migrations. DOCS.md lists them migration by migration.
Bundled compose. The service app (container pergam) is now pergam-local. Start 2.0 with docker compose up -d --build --remove-orphans, so the old container is replaced and does not keep holding the port. The db_data volume and the data in it carry over; a mount of db/schema.sql is gone. If you reference the service or container by name in scripts, update them.
Published HTML is sandboxed. Every document is framed with sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox allow-modals allow-top-navigation-by-user-activation" (no allow-same-origin), and /{id}/v{n}/content repeats that sandbox in a Content-Security-Policy with these sources: scripts inline, from the server and from https://cdn.jsdelivr.net; styles inline and from jsDelivr; images data: only; fonts data: and jsDelivr; connect-src jsDelivr only; no forms, no <base>, no nested frames. Documents already published are not rewritten, but some will look or behave differently:
- Images and fonts from any other host no longer load. Inline them as
data:URIs. - Scripts and stylesheets from hosts other than the server and jsDelivr no longer load.
fetchand XHR to anything but jsDelivr are blocked, and so are forms, nested frames and cookies.localStorageandsessionStoragedo not persist. A small stand-in keeps documents that use them without a guard working, but its contents are gone on every load.- A document cannot navigate the whole window without a click, and relative URLs resolve against
/{id}/v{n}/, not the view URL. - Mermaid from
https://cdn.jsdelivr.netkeeps rendering, and so do inline scripts and styles. New documents should load the server's copy from/static/mermaid/.
POST /lint tells you which of these a document hits before you publish it. Posted bytes are untouched: /raw and /export return exactly what was posted. In 1.x a document was served as the page itself, on the server's own origin; in 2.0 it never runs there. /{id}/v{n}/content, the route the view page frames, is cached for five minutes (public, max-age=300).
Archived pergams. Archiving is new in 2.0: an archived pergam is left out of the index and the feed but stays reachable by URL. The index shows active pergams by default, and ?state=active|archived|all chooses the status: state=archived lists only archived pergams and state=all both. /?archived=1 is also accepted and answered with a 301 to the same URL with state=all; on /api/pergams...
v1.0.0 — first stable release
pergam turns every HTML report, dashboard, or design doc your AI generates into a permanent, versioned URL your team can open. Self-hostable in one docker compose up, or use the hosted ephemeral service at pergam.dev.
✨ What's in v1.0
- 🐍 Self-hostable server — Python + Postgres, MIT, no telemetry. One container, one schema, immutable history.
- ☁️ Hosted service at pergam.dev — drop an
.html, get a 72-hour public link. Cloudflare Worker + KV, strict CSP. - 🤖
post-pergamClaude Code skill — your AI publishes pergams directly. Auto-picks the backend (hosted vs self-hosted) from$PERGAM_URL. Supports versioning (v2,v3, …) on self-host. - 🔒 Immutable + versioned — pergams can't be edited or deleted, only superseded by a new version under the same
id. - 🪞 Built-in viewer — sandboxed iframe with strict CSP. Mermaid + jsDelivr inline CSS allowed; everything else blocked.
🚀 Two ways to start
1. Hosted (zero setup)
Drop an .html on pergam.dev, get a 72h link. No account, no key. Or, from Claude Code:
# install the skill once
git clone https://github.com/diesilveira/pergam
cp -r pergam/skills/post-pergam ~/.claude/skills/
# ask Claude inside any project:
# "armá un pergam de X y publicalo"2. Self-host (durable + versioned)
git clone https://github.com/diesilveira/pergam
cd pergam
docker compose up -d --build
curl http://localhost:1111/healthz # → {"ok":true}Point the skill at it: export PERGAM_URL="http://localhost:1111"
📚 Docs
- README — overview + 5-min quickstart
- DOCS.md — full API reference, versioning model, deployment guide
- Skill contract — how the
post-pergamskill decides between backends
🔗 Links
- Live: https://pergam.dev
- API: https://api.pergam.dev
- License: MIT
If pergam is the shape of what you wanted, starring the repo helps a ton — it's how I find out it's solving a real problem.