cairn

module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT

README

Cairn

AI-native artifact sharing. A pastebin / gist / requestbin for the agent era: pipe anything in, get a shareable, agent-native link back — pbcopy for cairn. Humans post from the CLI and web; agents read, create, comment, and react over MCP. Every artifact is a short URL with provenance, reactions, comments, and a TTL.

cat checkout-web-audit.md | cairn      →  cairn.stump.wtf/9qz1a

Share types

Markdown · Code · Image · File · Bundle (multi-file) · Webhook (live requestbin) · Trace (a whole agent run — an OTel-style span waterfall + activity stream).

Surfaces

  • Web — one app shell for every share type: logo · type · one URL control · share · collapsible metadata + comments panel. Plus the Bin, your artifact listing.
  • CLI (cairn) — pipe or add files, log in, and check who you are. A cairn ls TUI to browse the Bin is planned, not shipped.
  • MCP — agents read/create/comment/react over MCP, authorized via MCP OAuth.

CLI — install, login, push

cairn is one static Go binary. As a client it is a pure REST client of the core /v1 API, with no domain logic of its own (see ADR-0003). Since v0.3.0 it is also the server: cairn serve replaces the old cairnd binary (see ADR-0031).

Install

With Homebrew, on macOS or Linux:

brew install stump-wtf/tap/cairn

Or download an archive for your platform from GitHub Releases, or install from the module:

go install github.com/stump-wtf/cairn/cmd/cairn@latest

That puts cairn in $(go env GOPATH)/bin, so make sure that is on your PATH. To build from a checkout instead:

git clone https://github.com/stump-wtf/cairn && cd cairn
go build -o cairn ./cmd/cairn
Log in

Authenticate with a bearer token. Mint a personal access token from your Cairn server's web Settings page, or use one your deployment operator issued:

cairn login --token <token>       # or: echo "$TOKEN" | cairn login
✓ authorized as sam@stump.rocks · via API
cairn whoami                      # check who you are

A bare cairn login prompts for the token with input hidden. Tokens are stored in the OS keyring when one is reachable (macOS Keychain, Secret Service on Linux), otherwise in a 0600 file under your config directory. They are never logged or printed. cairn logout deletes the stored copy.

Push
cat notes.md | cairn              # pipe content in, get a link back
cairn report.pdf                  # or pass a file path
cairn add a.png b.log dump.sql    # push several files as one bundle

cairn --ttl 24h --title "incident notes" incident.md   # optional flags

By default cairn copies the resulting link to your clipboard (best-effort, --no-copy to disable) and shows the server-assigned expiry and access policy — the CLI displays these, it never decides them. Piped/non-interactive output prints only the bare cairn.stump.wtf/<id> link, so it composes cleanly in scripts:

url=$(cat report.md | cairn)

See the CLI reference for every command, flag and exit code, and SPEC-0008 for the requirements behind them.

Run the server

cairn serve runs the web app, the /v1 API, the SSE streams and the MCP server in one process. It takes no flags; its whole configuration is the CAIRN_* environment. The self-hosting guide lists the variables and walks through a full deployment.

Upgrading from cairnd changes only the command name: cairn serve reads the same variables with the same meanings. The container image still starts through a cairnd shim that runs cairn serve, so container deployments need no change.

Self-hosting

Want your own cairn? The self-hosting guide takes you from nothing to a running instance: Postgres + any S3-compatible store, a pasteable compose file, OIDC sign-in, and a verified end-to-end loop. The image is ghcr.io/stump-wtf/cairn.

Project docs

Built spec-first with the sdd workflow: decisions → specs → tracked issues.

Status

Cairn is running and released. https://cairn.stump.wtf is a live instance, and releases ship as the cairn binary (Homebrew and GitHub Releases) and the container image ghcr.io/stump-wtf/cairn, currently the v0.3.x line. The ADRs and specs in docs/ are the design record the code follows.

Reporting bugs

Report bugs in GitHub Issues. The bug form asks for the version, deployment and surface we need to reproduce it. Report a vulnerability privately instead, as SECURITY.md describes.

Development happens on a private Gitea instance, and this GitHub repository is a read-only mirror of it. Bugs filed here are carried over to the internal tracker.

Directories

Path Synopsis
cmd
cairn command
Command cairn is the human's terminal surface for Cairn (SPEC-0008): a separate static Go binary that speaks only the documented core /v1 REST/JSON contract (ADR-0003 "Triple Surface Parity" — the CLI is a pure network client, not an in-process adapter, and carries no domain logic).
Command cairn is the human's terminal surface for Cairn (SPEC-0008): a separate static Go binary that speaks only the documented core /v1 REST/JSON contract (ADR-0003 "Triple Surface Parity" — the CLI is a pure network client, not an in-process adapter, and carries no domain logic).
cairnd command
Command cairnd is a deprecation shim: it execs `cairn serve "$@"` with the same arguments and environment (ADR-0031).
Command cairnd is a deprecation shim: it execs `cairn serve "$@"` with the same arguments and environment (ADR-0031).
gen-chroma-css command
Command gen-chroma-css regenerates the code viewer's bundled syntax-theme stylesheet (internal/httpapi/web/assets/chroma.css) from chroma's built-in "github-dark" style, using the exact same formatter options internal/code/render.go highlights with (WithClasses, ClassPrefix "chroma-", PreventSurroundingPre) so the class names the viewer emits and the class names this stylesheet defines can never drift apart.
Command gen-chroma-css regenerates the code viewer's bundled syntax-theme stylesheet (internal/httpapi/web/assets/chroma.css) from chroma's built-in "github-dark" style, using the exact same formatter options internal/code/render.go highlights with (WithClasses, ClassPrefix "chroma-", PreventSurroundingPre) so the class names the viewer emits and the class names this stylesheet defines can never drift apart.
internal
annotation
Package annotation owns the polymorphic annotation anchor model shared by reactions and comments: one embedded anchor of {artifact_id, anchor_type, anchor_ref} plus the canonical anchor_key the service derives from it.
Package annotation owns the polymorphic annotation anchor model shared by reactions and comments: one embedded anchor of {artifact_id, anchor_type, anchor_ref} plus the canonical anchor_key the service derives from it.
artifact
Package artifact defines the Cairn Artifact aggregate — the single shared unit and aggregate root — and its creation invariants.
Package artifact defines the Cairn Artifact aggregate — the single shared unit and aggregate root — and its creation invariants.
cliclient
Package cliclient is the cairn CLI's typed HTTP client over the core /v1 REST API.
Package cliclient is the cairn CLI's typed HTTP client over the core /v1 REST API.
clicmd
Package clicmd builds the `cairn` command tree (SPEC-0008 "Command Surface and REST-Client Boundary"): the bare pipe/path ingest command, `add`, `read`, `comment`, `login`, `logout`, and `whoami`.
Package clicmd builds the `cairn` command tree (SPEC-0008 "Command Surface and REST-Client Boundary"): the bare pipe/path ingest command, `add`, `read`, `comment`, `login`, `logout`, and `whoami`.
cliconfig
Package cliconfig resolves the cairn CLI's runtime configuration — the API base URL and bearer token — from flags, environment variables, and an on-disk config file, in that precedence order (SPEC-0008 "Configuration and Server Endpoint Resolution").
Package cliconfig resolves the cairn CLI's runtime configuration — the API base URL and bearer token — from flags, environment variables, and an on-disk config file, in that precedence order (SPEC-0008 "Configuration and Server Endpoint Resolution").
cliexit
Package cliexit implements the cairn CLI's stable exit-code taxonomy (SPEC-0008 "Machine-Readable Error Mapping and Exit Codes").
Package cliexit implements the cairn CLI's stable exit-code taxonomy (SPEC-0008 "Machine-Readable Error Mapping and Exit Codes").
code
Package code renders a code artifact body into the server-side, line numbered, syntax-highlighted HTML fragment the app shell drops into its body slot, together with a navigable symbol outline and the facts the metadata panel shows — the code-viewer analogue of internal/markdown (SPEC-0003 REQ "Code Viewer").
Package code renders a code artifact body into the server-side, line numbered, syntax-highlighted HTML fragment the app shell drops into its body slot, together with a navigable symbol outline and the facts the metadata panel shows — the code-viewer analogue of internal/markdown (SPEC-0003 REQ "Code Viewer").
config
Package config loads Cairn's runtime configuration from the environment.
Package config loads Cairn's runtime configuration from the environment.
db
Package db owns the Postgres connection lifecycle and schema migrations.
Package db owns the Postgres connection lifecycle and schema migrations.
errs
Package errs defines Cairn's domain error taxonomy.
Package errs defines Cairn's domain error taxonomy.
event
Package event defines the transport-agnostic lifecycle facts Cairn announces: what happened (Kind), which artifact it happened to (Subject), and who caused it (Actor).
Package event defines the transport-agnostic lifecycle facts Cairn announces: what happened (Kind), which artifact it happened to (Subject), and who caused it (Actor).
httpapi
Package httpapi is the /v1 REST/JSON adapter over the core store service.
Package httpapi is the /v1 REST/JSON adapter over the core store service.
httpapi/authprovider
Package authprovider abstracts the human login providers behind one interface (SPEC-0012): a provider knows how to start its login (produce the redirect to its authorization endpoint) and how to finish one (turn the callback's code into a verified identity).
Package authprovider abstracts the human login providers behind one interface (SPEC-0012): a provider knows how to start its login (produce the redirect to its authorization endpoint) and how to finish one (turn the callback's code into a verified identity).
id
Package id mints Cairn's short, opaque, public artifact identifiers.
Package id mints Cairn's short, opaque, public artifact identifiers.
imageview
Package imageview renders the image share type's server-side body-slot fragment (SPEC-0003 REQ "Image Viewer", issue #69): the image itself plus the static scaffolding image.js progressively enhances into the bespoke pin overlay and the whole-artifact react-below affordance.
Package imageview renders the image share type's server-side body-slot fragment (SPEC-0003 REQ "Image Viewer", issue #69): the image itself plus the static scaffolding image.js progressively enhances into the bespoke pin overlay and the whole-artifact react-below affordance.
markdown
Package markdown renders a markdown artifact body into the sanitized, server-side HTML fragment the app shell drops into its body slot, together with the derived table of contents, the deterministic per-block ids anchors resolve against, and a small stats summary the metadata panel shows.
Package markdown renders a markdown artifact body into the sanitized, server-side HTML fragment the app shell drops into its body slot, together with the derived table of contents, the deterministic per-block ids anchors resolve against, and a small stats summary the metadata panel shows.
mcpsession
Package mcpsession is the core for tracking MCP agent sessions/connections (issue #76, SPEC-0007, ADR-0004): Joe runs multiple agents over MCP and wants to make sense of which agent is doing what.
Package mcpsession is the core for tracking MCP agent sessions/connections (issue #76, SPEC-0007, ADR-0004): Joe runs multiple agents over MCP and wants to make sense of which agent is doing what.
metrics
Package metrics is Cairn's Prometheus metrics registry (ADR-0021, SPEC-0014).
Package metrics is Cairn's Prometheus metrics registry (ADR-0021, SPEC-0014).
oauth
Package oauth is Cairn's in-process OAuth 2.1 authorization server core (SPEC-0007, ADR-0004).
Package oauth is Cairn's in-process OAuth 2.1 authorization server core (SPEC-0007, ADR-0004).
objectstore
MinIO-backed ObjectStore.
MinIO-backed ObjectStore.
operator
Package operator is Cairn's operator profile (ADR-0029, SPEC-0023 REQ "Operator and User Profiles"): who runs the instance, and the small, audited set of things they may do to it.
Package operator is Cairn's operator profile (ADR-0029, SPEC-0023 REQ "Operator and User Profiles"): who runs the instance, and the small, audited set of things they may do to it.
outboundhook
Package outboundhook delivers post-commit lifecycle events to the owned outbound subscriptions of the workspace that owns the artifact each event is about.
Package outboundhook delivers post-commit lifecycle events to the owned outbound subscriptions of the workspace that owns the artifact each event is about.
pat
Package pat implements Cairn's personal access tokens: human-minted bearer credentials for the /v1 surface, created and revoked from the web Settings UI (issue #74).
Package pat implements Cairn's personal access tokens: human-minted bearer credentials for the /v1 surface, created and revoked from the web Settings UI (issue #74).
redact
Package redact finds credentials in text before Cairn stores it, and either refuses the write or masks each value as [REDACTED].
Package redact finds credentials in text before Cairn stores it, and either refuses the write or masks each value as [REDACTED].
search
Package search is the lexical index layer of SPEC-0022: the queue write paths enqueue into, the indexer that drains it, and the backfill that rebuilds everything.
Package search is the lexical index layer of SPEC-0022: the queue write paths enqueue into, the indexer that drains it, and the backfill that rebuilds everything.
serve
The reindex half of `cairn search reindex` (SPEC-0022 REQ-11): rebuild the lexical index from what is in the database and object storage right now.
The reindex half of `cairn search reindex` (SPEC-0022 REQ-11): rebuild the lexical index from what is in the database and object storage right now.
session
Package session is Cairn's minimal server-side web session store (SPEC-0001, ADR-0004).
Package session is Cairn's minimal server-side web session store (SPEC-0001, ADR-0004).
sharetype
Package sharetype is the compile-time share-type registry: the one place a stored share type is mapped to its viewer/panel/anchor affordances.
Package sharetype is the compile-time share-type registry: the one place a stored share type is mapped to its viewer/panel/anchor affordances.
store
Package store is the Artifact core service: it streams bodies into content-addressed object storage and persists the Artifact aggregate and its blob registry in Postgres, transactionally.
Package store is the Artifact core service: it streams bodies into content-addressed object storage and persists the Artifact aggregate and its blob registry in Postgres, transactionally.
subscription
Package subscription implements owned outbound subscriptions: the only delivery targets for Cairn's outbound events.
Package subscription implements owned outbound subscriptions: the only delivery targets for Cairn's outbound events.
tracectx
Package tracectx parses the W3C trace context a create may carry, so every surface reads the same value the same way.
Package tracectx parses the W3C trace context a create may carry, so every surface reads the same value the same way.
trajectory
Package trajectory is the core service for the trajectory share type: it persists an agent run as an ordered, nested span tree, spills oversized span outputs to content-addressed object storage, links a run to the artifacts it produced, and derives all run statistics from the span rows so they can never disagree with the waterfall.
Package trajectory is the core service for the trajectory share type: it persists an agent run as an ordered, nested span tree, spills oversized span outputs to content-addressed object storage, links a run to the artifacts it produced, and derives all run statistics from the span rows so they can never disagree with the waterfall.
user
Package user owns Cairn's users and the sign-in identities attached to them (ADR-0029, SPEC-0023 REQ "Users and Identities").
Package user owns Cairn's users and the sign-in identities attached to them (ADR-0029, SPEC-0023 REQ "Users and Identities").
webhook
Package webhook is the core service for the webhook (requestbin) share type: it provisions a capture endpoint as an ordinary Cairn artifact, holds its captured requests in a bounded, seq-ordered ring buffer — metadata in PostgreSQL, oversized bodies spilled to content-addressed object storage — and evicts the oldest record whenever a capture would push the buffer past its cap.
Package webhook is the core service for the webhook (requestbin) share type: it provisions a capture endpoint as an ordinary Cairn artifact, holds its captured requests in a bounded, seq-ordered ring buffer — metadata in PostgreSQL, oversized bodies spilled to content-addressed object storage — and evicts the oldest record whenever a capture would push the buffer past its cap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL