commit 373fef6f1bfd498c7a013e31b041a4c7d58a49ad Author: Azat Date: Mon Feb 2 22:14:46 2026 +0100 Initial ttyd skill diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..d81a135 --- /dev/null +++ b/SKILL.md @@ -0,0 +1,70 @@ +--- +name: ttyd +description: Share terminal over the web via WebSocket +metadata: + version: "1.0.0" + vibestack: + main: false +--- + +# TTYD Skill + +Installs [ttyd](https://github.com/tsl0922/ttyd) - a simple command-line tool for sharing terminal over the web. + +## Features + +- Share any command-line program over the web +- WebSocket-based, low latency +- SSL/TLS support +- Basic authentication +- Customizable terminal options + +## Configuration + +### Environment Variables + +| Variable | Description | Default | +|----------|-------------|---------| +| `TTYD_PORT` | Port to listen on | `7681` | +| `TTYD_COMMAND` | Command to run | `/bin/bash` | +| `TTYD_CREDENTIAL` | Basic auth (user:pass) | (none) | +| `TTYD_OPTIONS` | Additional ttyd options | (none) | + +## Usage + +### As a dependency + +```yaml +metadata: + vibestack: + requires: + - ttyd +``` + +### Standalone + +```bash +# Start with default shell +./scripts/run.sh + +# With authentication +TTYD_CREDENTIAL="admin:secret" ./scripts/run.sh + +# Custom command +TTYD_COMMAND="htop" ./scripts/run.sh +``` + +### With Caddy (HTTPS) + +```caddyfile +terminal.example.com { + reverse_proxy localhost:7681 +} +``` + +## Security + +For production use: +1. Always use `TTYD_CREDENTIAL` for authentication +2. Put behind Caddy/nginx for HTTPS +3. Consider network isolation diff --git a/scripts/autorun.sh b/scripts/autorun.sh new file mode 100644 index 0000000..0da8b0f --- /dev/null +++ b/scripts/autorun.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +TTYD_VERSION="${TTYD_VERSION:-1.7.7}" + +# Idempotent ttyd installation +install_ttyd() { + if command -v ttyd &>/dev/null; then + echo "ttyd already installed: $(ttyd --version)" + return 0 + fi + + echo "Installing ttyd v${TTYD_VERSION}..." + + # Detect architecture + local arch + case "$(uname -m)" in + x86_64) arch="x86_64" ;; + aarch64) arch="aarch64" ;; + armv7l) arch="armhf" ;; + *) + echo "Unsupported architecture: $(uname -m)" + exit 1 + ;; + esac + + # Download prebuilt binary + local url="https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.${arch}" + curl -sSL "$url" -o /usr/local/bin/ttyd + chmod +x /usr/local/bin/ttyd + + echo "ttyd installed: $(ttyd --version)" +} + +install_ttyd diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100644 index 0000000..68ed7ad --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +TTYD_PORT="${TTYD_PORT:-7681}" +TTYD_COMMAND="${TTYD_COMMAND:-/bin/bash}" +TTYD_CREDENTIAL="${TTYD_CREDENTIAL:-}" +TTYD_OPTIONS="${TTYD_OPTIONS:-}" + +# Build command arguments +args=() +args+=("--port" "$TTYD_PORT") + +# Add authentication if set +if [ -n "$TTYD_CREDENTIAL" ]; then + args+=("--credential" "$TTYD_CREDENTIAL") +fi + +# Add any extra options +if [ -n "$TTYD_OPTIONS" ]; then + # shellcheck disable=SC2206 + args+=($TTYD_OPTIONS) +fi + +echo "Starting ttyd on port $TTYD_PORT..." +echo "Command: $TTYD_COMMAND" +[ -n "$TTYD_CREDENTIAL" ] && echo "Authentication: enabled" + +exec ttyd "${args[@]}" $TTYD_COMMAND