Refactor cockpit to use DockerTmuxController pattern

Based on claude-code-tools TmuxCLIController, this refactor:

- Added DockerTmuxController class for robust tmux session management
- Implements send_keys() with configurable delay_enter
- Implements capture_pane() for output retrieval
- Implements wait_for_prompt() for pattern-based completion detection
- Implements wait_for_idle() for content-hash-based idle detection
- Implements wait_for_shell_prompt() for shell prompt detection

Also includes workflow improvements:
- Pre-task git snapshot before agent execution
- Post-task commit protocol in agent guidelines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
admin
2026-01-14 10:42:16 -03:00
commit ec33ac1936
265 changed files with 92011 additions and 0 deletions

41
docker/Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
# Luzia Sandbox - Lightweight agent execution environment
# Agents execute inside this container as project users
FROM alpine:3.19
# Install common tools agents need
RUN apk add --no-cache \
bash \
git \
curl \
wget \
jq \
grep \
sed \
gawk \
findutils \
coreutils \
diffutils \
patch \
openssh-client \
nodejs \
npm \
python3 \
py3-pip \
make \
gcc \
g++ \
musl-dev
# Install common Node.js tools
RUN npm install -g \
typescript \
ts-node \
prettier \
eslint
# Set workspace
WORKDIR /workspace
# Keep container alive for docker exec commands
CMD ["tail", "-f", "/dev/null"]

72
docker/cockpit/Dockerfile Normal file
View File

@@ -0,0 +1,72 @@
# Luzia Cockpit - Interactive Claude Agent Container
# Provides tmux-based session management for human-in-the-loop workflows
FROM debian:bookworm-slim
# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install base tools
RUN apt-get update && apt-get install -y --no-install-recommends \
tmux \
curl \
git \
jq \
ca-certificates \
gnupg \
procps \
less \
vim-tiny \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20 LTS
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Install Claude CLI globally
RUN npm install -g @anthropic-ai/claude-code
# Create workspace directory
RUN mkdir -p /workspace /root/.claude
# Tmux configuration for better session handling
RUN cat > /root/.tmux.conf << 'EOF'
# Increase scrollback buffer
set-option -g history-limit 50000
# Don't rename windows automatically
set-option -g allow-rename off
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Enable mouse (for human attach)
set -g mouse on
# Status bar showing session info
set -g status-left '[#S] '
set -g status-right '%H:%M '
# Keep tmux server running even if no clients
set -g exit-empty off
EOF
# Entry script that starts tmux and keeps container alive
RUN cat > /entrypoint.sh << 'EOF'
#!/bin/bash
set -e
# Start tmux server with agent session
tmux new-session -d -s agent -n main
# Keep container alive by waiting on tmux
exec tmux wait-for exit-signal
EOF
RUN chmod +x /entrypoint.sh
WORKDIR /workspace
# Default command starts tmux server
CMD ["/entrypoint.sh"]