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
/previewcommands 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
- install tailscale on the host and authenticate it (
tailscale up). - ensure magicdns is enabled so
DEVICE.TAILNET.ts.netresolves. - 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"
# per-project overrides (Takopi project tables are strict, so use plugins.preview.projects)
[plugins.preview.projects.myapp]
port = 5173
dev_command = "npm run dev -- --host 127.0.0.1 --port {port}"
notes:
dev_commandmay include{port}; it will be substituted at runtime.dev_commandis required whenauto_start = true. setauto_start = falseto manage the dev server yourself.- Inline
--dev/--overrides enable auto-start for that run; use--no-startto force manual mode. - To require an explicit command each run, omit
dev_commandand setauto_start = false, then pass--devor--. ttl_minutes = 0disables expiration.- empty
allowed_user_idsmeans no allowlist enforcement.
commands
/preview start [port]: start a preview for the current context/preview start [port] --dev "<command>": override the dev command for this run/preview start [port] -- <command>: shorthand for an inline dev command/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
- choose a context:
/myapp @feat/loginor reply in an existing thread. - run
/preview start(or/preview start 5173). - open the returned url, for example:
https://DEVICE.TAILNET.ts.net/preview/5173
- stop when done:
/preview stopor/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. - serve disabled: enable serve for your tailnet (Tailscale admin UI) if you see the "Serve is not enabled" error.
- port already in use: run
/preview listor 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file takopi_preview-0.1.2.tar.gz.
File metadata
- Download URL: takopi_preview-0.1.2.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
931464e8e638c0ea47f8a4c1e810fd92838b2e47b648e530f0c1c07dec053c23
|
|
| MD5 |
cc83404115247cfb6449584b4c766f48
|
|
| BLAKE2b-256 |
e290b785f7b43f426997f420275ffb3e5114330872dbb8ea3f8b1c3ef82bb796
|
Provenance
The following attestation bundles were made for takopi_preview-0.1.2.tar.gz:
Publisher:
workflow.yml on richardliang/takopi-preview
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takopi_preview-0.1.2.tar.gz -
Subject digest:
931464e8e638c0ea47f8a4c1e810fd92838b2e47b648e530f0c1c07dec053c23 - Sigstore transparency entry: 838678574
- Sigstore integration time:
-
Permalink:
richardliang/takopi-preview@2d85ba6ea929f036a8e68a0a6f6e9388891e8020 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/richardliang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@2d85ba6ea929f036a8e68a0a6f6e9388891e8020 -
Trigger Event:
push
-
Statement type:
File details
Details for the file takopi_preview-0.1.2-py3-none-any.whl.
File metadata
- Download URL: takopi_preview-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa52428dd6e4f154f6fa7aed490c80b18dcb46052178f9389e35ee4c6ae92fad
|
|
| MD5 |
2517b60f6918a4f78191c5bb5afb285e
|
|
| BLAKE2b-256 |
503dc58917db1a74c178d52617b884a924154b86c29d82255b5f5589b295ac37
|
Provenance
The following attestation bundles were made for takopi_preview-0.1.2-py3-none-any.whl:
Publisher:
workflow.yml on richardliang/takopi-preview
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takopi_preview-0.1.2-py3-none-any.whl -
Subject digest:
fa52428dd6e4f154f6fa7aed490c80b18dcb46052178f9389e35ee4c6ae92fad - Sigstore transparency entry: 838678575
- Sigstore integration time:
-
Permalink:
richardliang/takopi-preview@2d85ba6ea929f036a8e68a0a6f6e9388891e8020 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/richardliang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@2d85ba6ea929f036a8e68a0a6f6e9388891e8020 -
Trigger Event:
push
-
Statement type: