preview-stacks

module
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT

README

preview-stacks

A monorepo. The product is packages/pstack — a control plane for ephemeral per-PR preview stacks, released as one static Go binary on GitHub Releases. Its README is the design document; start there.

packages/pstack        the CLI, HTTP API, and the basic embedded UI   (Go; GitHub Releases)
packages/conformance   the black-box specification: goldens + tests that grade the binary
packages/client        the TypeScript API client                       (npm: @samyx/preview-stacks-client)
apps/ui                the optional advanced web UI                   (npm: @samyx/preview-stacks-ui; its own container)
docs/                  guides that span all of it — bootstrap, usage, control-plane architecture
skills/pstack/         a skill teaching an agent to use pstack

Working in it

Turborepo drives every task, so a command at the root fans out across packages and caches results — go build/go test -race/go vet for pstack, bun for the rest.

bun install
bun run build        # turbo run build   (packages/pstack/bin/pstack, the UI and client bundles)
bun run test         # turbo run test
bun run typecheck
bun run check        # build + test + typecheck, per package

Run a single package's task directly when iterating:

go test -race ./packages/pstack/internal/spec/     # one Go package
cd packages/conformance && bun test                 # the black-box suite against bin/pstack

Releasing

A v* tag releases everything at that lockstep version: .github/workflows/release.yml asserts the tag equals the three package.json versions, runs GoReleaser (.goreleaser.yaml — the binaries, checksums.txt, install.sh), smoke-tests the published installer, then publishes the two npm packages with publish-kit (publish.config.ts selects them by name).

bunx publish-kit bump minor     # the two npm packages; set packages/pstack/package.json (the version of
                                # record, what the binary reports) to the same number in the same edit
git tag v0.29.0 && git push --tags

The release workflow refuses a tag whose number differs from any of the three package.jsons, so a missed bump fails before anything is published.

Docs

docs/README.md is the index — what each document answers, and which to read first. The short version:

  • Usage — task-oriented guide
  • Bootstrap — build a host from nothing (Hetzner + cloud-init)
  • Control plane — architecture, registry contract, trust boundary
  • Webhook events — every event a notifier receives: payloads, signature verification, delivery semantics
  • API client — @samyx/preview-stacks-client: typed calls, waitForJob / waitForReady, and webhook verification for your receiver
  • UI rules — the conventions the advanced UI is held to: casing, alignment, spacing, roundness, width
  • Secret exposure — resolved in 0.10.0 (every route authenticated); kept as the design record
  • AGENTS.md — start here if you are an AI agent or new to the code: invariants, repo map, testing expectations, scope discipline

Directories

Path Synopsis
packages
pstack
Package pstack carries the eight files the binary embeds.
Package pstack carries the eight files the binary embeds.
pstack/cmd/pstack command
The pstack binary.
The pstack binary.
pstack/internal/api
Package api is the HTTP control plane.
Package api is the HTTP control plane.
pstack/internal/apicli
Package apicli is the `pstack api …` command tree, GENERATED from `packages/pstack/api/openapi.yaml`.
Package apicli is the `pstack api …` command tree, GENERATED from `packages/pstack/api/openapi.yaml`.
pstack/internal/auth
Package auth is accounts, sessions and personal API tokens, on top of the Store.
Package auth is accounts, sessions and personal API tokens, on top of the Store.
pstack/internal/autolabel
Package autolabel generates the Traefik labels and network wiring a preview service needs, from one short label — and, on a host that runs Loki, the logging block that ships its output there.
Package autolabel generates the Traefik labels and network wiring a preview service needs, from one short label — and, on a host that runs Loki, the logging block that ships its output there.
pstack/internal/cli
`pstack api …` — every HTTP route as a command, generated from `packages/pstack/api/openapi.yaml`.
`pstack api …` — every HTTP route as a command, generated from `packages/pstack/api/openapi.yaml`.
pstack/internal/cloudinit
Package cloudinit is `pstack cloud-init` — fill the cloud-config template and print a ready-to-boot user-data file.
Package cloudinit is `pstack cloud-init` — fill the cloud-config template and print a ready-to-boot user-data file.
pstack/internal/compose
Package compose is the Docker Compose invocation.
Package compose is the Docker Compose invocation.
pstack/internal/config
Package config is the portable host configuration document: everything that makes a pstack host *this* host, in a form that can be carried to a new one.
Package config is the portable host configuration document: everything that makes a pstack host *this* host, in a form that can be carried to a new one.
pstack/internal/events
Package events is the domain event bus.
Package events is the domain event bus.
pstack/internal/exec
Package exec runs things.
Package exec runs things.
pstack/internal/hostvars
Package hostvars is host-level variables and secrets — the GitHub-Actions model, scoped to one host.
Package hostvars is host-level variables and secrets — the GitHub-Actions model, scoped to one host.
pstack/internal/image
Package image is `pstack build-image` — build the control image from the running binary itself.
Package image is `pstack build-image` — build the control image from the running binary itself.
pstack/internal/initctl
Package initctl is `pstack init` — stand up the CONTROL stack on a host.
Package initctl is `pstack init` — stand up the CONTROL stack on a host.
pstack/internal/inspect
The CONTROL STACK's own runtime — traefik, pstack, the optional advanced UI — as an operator's page shows it.
The CONTROL STACK's own runtime — traefik, pstack, the optional advanced UI — as an operator's page shows it.
pstack/internal/jobs
Package jobs is the in-memory job registry.
Package jobs is the in-memory job registry.
pstack/internal/js
Package js reproduces the JavaScript primitives the contract leans on.
Package js reproduces the JavaScript primitives the contract leans on.
pstack/internal/jsonx
Package jsonx is JSON.stringify.
Package jsonx is JSON.stringify.
pstack/internal/log
Package log is the logging seam: the CLI wants progress on stdout, the API wants the same events captured per job and streamed to a browser, so the orchestrator writes to a Sink and each consumer passes its own.
Package log is the logging seam: the CLI wants progress on stdout, the API wants the same events captured per job and streamed to a browser, so the orchestrator writes to a Sink and each consumer passes its own.
pstack/internal/loki
Package loki is Loki's settings: what an operator may change, the ranges pstack holds them to, and the bytes they become in control/loki/config.yaml and control/loki/s3-credentials.
Package loki is Loki's settings: what an operator may change, the ranges pstack holds them to, and the bytes they become in control/loki/config.yaml and control/loki/s3-credentials.
pstack/internal/notify
Package notify delivers domain events to the outside world.
Package notify delivers domain events to the outside world.
pstack/internal/omap
Package omap is the ordered map the whole compose pipeline runs on.
Package omap is the ordered map the whole compose pipeline runs on.
pstack/internal/readiness
Package readiness answers "did the stack actually come up?".
Package readiness answers "did the stack actually come up?".
pstack/internal/redact
Package redact is redaction for anything a human is shown.
Package redact is redaction for anything a human is shown.
pstack/internal/registries
Package registries is private registry credentials for the control plane.
Package registries is private registry credentials for the control plane.
pstack/internal/registry
Package registry is the deployment registry — what turns pstack from a CLI into a control plane.
Package registry is the deployment registry — what turns pstack from a CLI into a control plane.
pstack/internal/routing
ADDITIONAL DOMAINS: the hostnames this host answers on besides the one `init` rendered.
ADDITIONAL DOMAINS: the hostnames this host answers on besides the one `init` rendered.
pstack/internal/scheduler
Package scheduler is sleep and wake-on-call: the SleepIndex (hostname → the deployment the catch-all router's request belongs to), the TrafficMeter (Traefik's per-router counters → "last request"), the tick that applies a spec's `sleep:` policy, and the "spinning up" page.
Package scheduler is sleep and wake-on-call: the SleepIndex (hostname → the deployment the catch-all router's request belongs to), the TrafficMeter (Traefik's per-router counters → "last request"), the tick that applies a spec's `sleep:` policy, and the "spinning up" page.
pstack/internal/settings
Package settings is the handful of host knobs an operator may change at RUNTIME, without restarting the control container.
Package settings is the handful of host knobs an operator may change at RUNTIME, without restarting the control container.
pstack/internal/share
Package share is share links: a signed, expiring, READ-ONLY grant to one deployment.
Package share is share links: a signed, expiring, READ-ONLY grant to one deployment.
pstack/internal/signals
Package signals answers the two questions something outside pstack asks before it turns a worker machine on or off:
Package signals answers the two questions something outside pstack asks before it turns a worker machine on or off:
pstack/internal/spec
Package spec parses and validates a `preview.yml` into a resolved Stack.
Package spec parses and validates a `preview.yml` into a resolved Stack.
pstack/internal/specs
Package specs is the named-spec store — store a spec once, reference it from many deployments.
Package specs is the named-spec store — store a spec once, reference it from many deployments.
pstack/internal/sso
Package sso is sign-in with the operator's own identity provider.
Package sso is sign-in with the operator's own identity provider.
pstack/internal/stack
Package stack is lifecycle orchestration.
Package stack is lifecycle orchestration.
pstack/internal/store
Package store is the persistent state that is not the registry: users, sessions, API tokens, webhook registrations and delivery logs, the terminal audit, host variables, SSO.
Package store is the persistent state that is not the registry: users, sessions, API tokens, webhook registrations and delivery logs, the terminal audit, host variables, SSO.
pstack/internal/swarm
Package swarm is Docker Swarm: the compose→swarm conversion, the `docker stack` command lines, the node/join helpers behind the swarm panel, and the line that puts the Loki log plugin on a node.
Package swarm is Docker Swarm: the compose→swarm conversion, the `docker stack` command lines, the node/join helpers behind the swarm panel, and the line that puts the Loki log plugin on a node.
pstack/internal/terminal
Package terminal is a shell inside a preview container, over a WebSocket.
Package terminal is a shell inside a preview container, over a WebSocket.
pstack/internal/testfacts
Package testfacts locates packages/conformance/golden/facts — the measured Bun semantics the foundation packages are tested against.
Package testfacts locates packages/conformance/golden/facts — the measured Bun semantics the foundation packages are tested against.
pstack/internal/upgrade
Package upgrade is `pstack upgrade` — move a host to a new version of pstack.
Package upgrade is `pstack upgrade` — move a host to a new version of pstack.
pstack/internal/version
Package version answers "which pstack is this" from two sources, in order: the -X flag a release build stamps, else the `version` field of the embedded package.json.
Package version answers "which pstack is this" from two sources, in order: the -X flag a release build stamps, else the `version` field of the embedded package.json.
pstack/internal/webhooks
Package webhooks is notifier registrations and their delivery log.
Package webhooks is notifier registrations and their delivery log.
pstack/internal/yamlx
Package yamlx is Bun.YAML.parse.
Package yamlx is Bun.YAML.parse.
pstack/tools/yamlcat command
yamlcat parses YAML files with pstack's own parser and prints each one as JSON, one line per file: {"path":…,"json":…} or {"path":…,"error":…}.
yamlcat parses YAML files with pstack's own parser and prints each one as JSON, one line per file: {"path":…,"json":…} or {"path":…,"error":…}.

Jump to

Keyboard shortcuts

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