Skip to main content

Tailscale preview command plugin for Takopi

Project description

takopi-preview

tailscale-backed preview command plugin for takopi. starts a dev server (optional), exposes it inside your tailnet via tailscale serve, and tracks preview sessions by project/worktree context.

published as the takopi-preview package. the command id is preview.

features

  • /preview commands to start, list, stop, and clean up previews
  • tailnet-only urls (no public ingress) with tailscale serve
  • per-project overrides for ports and dev commands
  • optional dev server auto-start with {port} substitution
  • session registry with ttl expiration and state recovery
  • allowlist support for sensitive commands (like killall)

requirements

  • python 3.14+
  • takopi >= 0.20
  • tailscale installed and authenticated on the host (tailscale up)
  • dev server binds to 127.0.0.1 (tailscale proxies locally)
  • security groups should not expose the dev server port publicly

install

install into the same environment as takopi.

uv tool install -U takopi
uv tool install -U takopi --with takopi-transport-slack --with takopi-preview

or, with a virtualenv:

pip install takopi-transport-slack takopi-preview

setup

  1. install tailscale on the host and authenticate it (tailscale up).
  2. ensure magicdns is enabled so DEVICE.TAILNET.ts.net resolves.
  3. run takopi with your transport (slack or telegram) as usual.

configuration

add to ~/.takopi/takopi.toml:

[plugins]
enabled = ["takopi-transport-slack", "takopi-preview"]

[plugins.preview]
provider = "tailscale"
default_port = 3000
dev_command = "pnpm dev -- --host 127.0.0.1 --port {port}"
auto_start = true
ttl_minutes = 120
allowed_user_ids = [123456789]

# optional env injection for the dev server
[plugins.preview.env]
NODE_ENV = "development"

# advanced overrides
tailscale_bin = "tailscale"
local_host = "127.0.0.1"

[projects.myapp.preview]
port = 5173
dev_command = "npm run dev -- --host 127.0.0.1 --port {port}"

notes:

  • dev_command may include {port}; it will be substituted at runtime.
  • set auto_start = false if you start your dev server manually.
  • ttl_minutes = 0 disables expiration.
  • empty allowed_user_ids means no allowlist enforcement.

commands

  • /preview start [port]: start a preview for the current context
  • /preview list: show active previews (url, port, uptime, context)
  • /preview stop [id|port]: stop a preview (defaults to current context)
  • /preview killall: stop all previews (restricted by allowlist)
  • /preview help: usage help

workflow

  1. choose a context: /myapp @feat/login or reply in an existing thread.
  2. run /preview start (or /preview start 5173).
  3. open the returned url, for example:
https://DEVICE.TAILNET.ts.net/preview/5173
  1. stop when done: /preview stop or /preview stop 5173.

state and ttl

sessions are stored in memory and persisted to:

  • ~/.takopi/state/preview.json

dev server logs (when auto-started) are written to:

  • ~/.takopi/state/preview-logs/<session>.log

ttl_minutes controls automatic expiration; expired sessions are cleaned up on the next command invocation.

errors

  • missing tailscale: follow the install docs and run tailscale up.
  • port already in use: run /preview list or pick a new port.
  • dev server failures: the error includes log tail + log path.

spec alignment

this implementation follows the webapp preview workflow spec:

  • command surface: start/list/stop/killall/help
  • config in [plugins.preview] with per-project overrides
  • tailscale serve + dns from tailscale status --json
  • tailnet-only https urls
  • in-memory registry + state file under ~/.takopi/state/preview.json
  • ttl-based expiration (ttl_minutes)
  • allowlist enforcement via allowed_user_ids

license

mit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

takopi_preview-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

takopi_preview-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file takopi_preview-0.1.0.tar.gz.

File metadata

  • Download URL: takopi_preview-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for takopi_preview-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9478d375e3e5e0e9f98f027151d49c5bd156b168be9c0ce3100c44d9675b49ef
MD5 cd74a0329b933be6ba119741d29fca31
BLAKE2b-256 76903d66d94f6907028ffecb72da0bc70cafba89a76f9cc5d7952dc6ee5d271c

See more details on using hashes here.

Provenance

The following attestation bundles were made for takopi_preview-0.1.0.tar.gz:

Publisher: workflow.yml on richardliang/takopi-preview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file takopi_preview-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: takopi_preview-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for takopi_preview-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cec2ca5fb112cc717374b71f07acbf92cf255c1e9172c2b0bb89219f96ce6983
MD5 4c07aec2e241a8264f2eb367ca0f5b07
BLAKE2b-256 3b857c2f60428bf6e5d3dc24d5fda07c8f0b67eb268ea1826679961d1c5b592c

See more details on using hashes here.

Provenance

The following attestation bundles were made for takopi_preview-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on richardliang/takopi-preview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page