FROM debian:bookworm-slim AS scsh-base
LABEL scsh.generated=true
ARG AGENT_UID=1000
ARG AGENT_GID=1000
ARG TZ=UTC
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates curl wget gnupg \
git git-lfs openssh-client \
bash less tree file procps psmisc \
tar gzip xz-utils zip unzip patch diffutils \
locales tzdata \
build-essential pkg-config libssl-dev cmake \
python3 python3-venv \
perl gawk \
jq sqlite3 postgresql-client \
ripgrep shellcheck \
asciinema tmux \
protobuf-compiler \
iputils-ping traceroute bind9-dnsutils netcat-openbsd iproute2 whois socat; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
ln -snf "/usr/share/zoneinfo/${TZ:-UTC}" /etc/localtime; \
echo "${TZ:-UTC}" > /etc/timezone
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) uvarch=x86_64 ;; \
arm64) uvarch=aarch64 ;; \
*) echo "scsh: unsupported architecture '$arch'" >&2; exit 1 ;; \
esac; \
tmp="$(mktemp -d)"; \
curl -fsSL "https://github.com/astral-sh/uv/releases/latest/download/uv-${uvarch}-unknown-linux-gnu.tar.gz" \
| tar xz -C "$tmp" --strip-components=1; \
install -m 0755 "$tmp/uv" "$tmp/uvx" /usr/local/bin/; rm -rf "$tmp"; \
curl -fsSL "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${arch}" -o /usr/local/bin/yq; \
chmod +x /usr/local/bin/yq; \
curl -fsSL "https://dl.k8s.io/release/$(curl -fsSL https://dl.k8s.io/release/stable.txt)/bin/linux/${arch}/kubectl" \
-o /usr/local/bin/kubectl; \
chmod +x /usr/local/bin/kubectl; \
install -d -m 0755 /etc/apt/keyrings; \
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
-o /etc/apt/keyrings/githubcli-archive-keyring.gpg; \
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg; \
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list; \
apt-get update; apt-get install -y --no-install-recommends gh; rm -rf /var/lib/apt/lists/*; \
uv --version; yq --version; kubectl version --client; gh --version
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
GO_VER="$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -1)"; \
curl -fsSL "https://go.dev/dl/${GO_VER}.linux-${arch}.tar.gz" | tar xz -C /usr/local; \
/usr/local/go/bin/go version
RUN set -eux; \
export CARGO_HOME=/usr/local/cargo RUSTUP_HOME=/usr/local/rustup; \
curl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal; \
chmod -R a+rwX /usr/local/cargo; \
/usr/local/cargo/bin/rustc --version; /usr/local/cargo/bin/cargo --version
RUN set -eux; \
case "$(dpkg --print-architecture)" in \
amd64) awsarch=x86_64 ;; \
arm64) awsarch=aarch64 ;; \
*) echo "scsh: unsupported architecture" >&2; exit 1 ;; \
esac; \
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${awsarch}.zip" -o /tmp/awscliv2.zip; \
unzip -q /tmp/awscliv2.zip -d /tmp; /tmp/aws/install; rm -rf /tmp/aws /tmp/awscliv2.zip; \
aws --version
RUN set -eux; \
case "$(dpkg --print-architecture)" in \
amd64) gclarch=x86_64 ;; \
arm64) gclarch=arm ;; \
*) echo "scsh: unsupported architecture" >&2; exit 1 ;; \
esac; \
curl -fsSL "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-${gclarch}.tar.gz" \
| tar xz -C /usr/local; \
/usr/local/google-cloud-sdk/install.sh --quiet --usage-reporting=false --path-update=false --command-completion=false; \
ln -snf /usr/local/google-cloud-sdk/bin/gcloud /usr/local/bin/gcloud; \
ln -snf /usr/local/google-cloud-sdk/bin/gsutil /usr/local/bin/gsutil; \
gcloud --version
RUN set -eu; \
uid="${AGENT_UID:-1000}"; gid="${AGENT_GID:-1000}"; \
groupadd -g "$gid" agent 2>/dev/null || groupadd agent 2>/dev/null || true; \
useradd -u "$uid" -g "$gid" -m -d /home/agent -s /bin/sh agent 2>/dev/null \
|| useradd -g "$gid" -m -d /home/agent -s /bin/sh agent 2>/dev/null || true; \
mkdir -p /home/agent/repo; chown -R "$uid:$gid" /home/agent
WORKDIR /home/agent/repo
ENV SCSH=1
ENV HOME=/home/agent
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV TZ=${TZ}
ENV CARGO_HOME=/usr/local/cargo
ENV RUSTUP_HOME=/usr/local/rustup
ENV PATH=/usr/local/go/bin:/usr/local/cargo/bin:/usr/local/bin:$PATH
ENV SCSH_RUN_LOG=/home/agent/repo/tmp/scsh-run.log
ENV TERM=xterm-256color
RUN cat > /usr/local/bin/scsh-tui-record <<'SCSH_TUI_RECORD'
#!/bin/sh
# Usage: scsh-tui-record COLS ROWS QUIT RESULT CMD
# QUIT: slash-exit (Claude) | double-ctrl-c (codex, cursor)
set -u
cols=$1; rows=$2; quit=$3; result=$4; cmd=$5
tmux -f /dev/null new-session -d -x "$cols" -y "$rows" -s scsh "$cmd"
tmux set -t scsh status off >/dev/null 2>&1 || true
# Watcher: end the TUI once the skill has produced its result file.
{
while tmux has-session -t scsh 2>/dev/null; do
if [ -f "$result" ]; then
sleep 4
case "$quit" in
slash-exit) tmux send-keys -t scsh -l /exit; sleep 1; tmux send-keys -t scsh Enter ;;
double-ctrl-c) tmux send-keys -t scsh C-c; sleep 1; tmux send-keys -t scsh C-c ;;
esac
sleep 3
tmux kill-session -t scsh 2>/dev/null || true
break
fi
sleep 2
done
} >/dev/null 2>&1 &
asciinema rec -q --cols "$cols" --rows "$rows" -c 'tmux attach -r -t scsh' "$SCSH_RUN_LOG.cast"
wait
SCSH_TUI_RECORD
RUN chmod 0755 /usr/local/bin/scsh-tui-record
FROM scsh-base AS scsh-opencode
RUN set -eux; \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
rm -rf /var/lib/apt/lists/*; \
npm install -g opencode-ai; \
chmod -R a+rX "$(npm root -g)"; \
opencode --version
ENV OPENCODE_YOLO=true
ENV OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true
ENV XDG_DATA_HOME=/home/agent/repo/tmp/.xdg-data
USER agent
FROM scsh-base AS scsh-claude
RUN set -eux; \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
rm -rf /var/lib/apt/lists/*; \
npm install -g @anthropic-ai/claude-code; \
chmod -R a+rX "$(npm root -g)"; \
claude --version
ENV CLAUDE_CONFIG_DIR=/home/agent/repo/tmp/.claude-auth/.claude
USER agent
FROM scsh-base AS scsh-codex
RUN set -eux; \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
rm -rf /var/lib/apt/lists/*; \
npm install -g @openai/codex; \
chmod -R a+rX "$(npm root -g)"; \
codex --version
ENV CODEX_HOME=/home/agent/repo/tmp/.codex
USER agent
FROM scsh-base AS scsh-grok
RUN set -eux; \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
rm -rf /var/lib/apt/lists/*; \
npm install -g @xai-official/grok; \
chmod -R a+rX "$(npm root -g)"; \
grok --version
ENV GROK_HOME=/home/agent/repo/tmp/.grok
USER agent
FROM scsh-base AS scsh-cursor
ARG CURSOR_AGENT_VERSION=2026.07.01-41b2de7
ENV CURSOR_AGENT_HOME=/usr/local/share/cursor-agent
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) cursorarch=x64 ;; \
arm64) cursorarch=arm64 ;; \
*) echo "scsh: unsupported architecture" >&2; exit 1 ;; \
esac; \
tmp="$(mktemp -d)"; \
curl -fsSL "https://downloads.cursor.com/lab/${CURSOR_AGENT_VERSION}/linux/${cursorarch}/agent-cli-package.tar.gz" \
| tar -xzf - -C "$tmp"; \
rm -rf "$CURSOR_AGENT_HOME"; \
mv "$tmp/dist-package" "$CURSOR_AGENT_HOME"; \
rm -rf "$tmp"; \
ln -sf "$CURSOR_AGENT_HOME/cursor-agent" /usr/local/bin/cursor-agent; \
ln -sf "$CURSOR_AGENT_HOME/cursor-agent" /usr/local/bin/agent; \
cursor-agent --version
ENV CURSOR_CONFIG_DIR=/home/agent/repo/tmp/.cursor
ENV XDG_CONFIG_HOME=/home/agent/repo/tmp/.config
USER agent