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:
56
lib/cockpit-service
Executable file
56
lib/cockpit-service
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# Helper script for cockpits to request services
|
||||
# Mount this into cockpits at /usr/local/bin/cockpit-service
|
||||
#
|
||||
# Usage:
|
||||
# cockpit-service start <service>
|
||||
# cockpit-service stop <service>
|
||||
# cockpit-service status
|
||||
# cockpit-service list
|
||||
|
||||
REQUESTS_DIR="/var/cockpit/service_requests"
|
||||
PROJECT="${PROJECT:-$(basename $(dirname /workspace))}" # Detect from workspace
|
||||
|
||||
# Try to get project from workspace mount
|
||||
if [ -d "/workspace" ]; then
|
||||
# /workspace is typically mounted from /home/<project>
|
||||
# Read from env or use parent dir name
|
||||
PROJECT="${COCKPIT_PROJECT:-unknown}"
|
||||
fi
|
||||
|
||||
# Ensure project dir exists
|
||||
mkdir -p "$REQUESTS_DIR/$PROJECT"
|
||||
|
||||
action="$1"
|
||||
service="$2"
|
||||
|
||||
if [ -z "$action" ]; then
|
||||
echo "Usage: cockpit-service <start|stop|status|list> [service]"
|
||||
echo " cockpit-service start backend"
|
||||
echo " cockpit-service stop backend"
|
||||
echo " cockpit-service status"
|
||||
echo " cockpit-service list"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
request_id="${action}-${service:-all}-$(date +%s)"
|
||||
request_file="$REQUESTS_DIR/$PROJECT/${request_id}.request"
|
||||
response_file="$REQUESTS_DIR/$PROJECT/${request_id}.response"
|
||||
|
||||
# Write request
|
||||
echo "{\"action\":\"$action\",\"service\":\"$service\"}" > "$request_file"
|
||||
echo "Request submitted: $request_id"
|
||||
|
||||
# Wait for response (max 30s)
|
||||
for i in $(seq 1 30); do
|
||||
if [ -f "$response_file" ]; then
|
||||
echo "Response:"
|
||||
cat "$response_file"
|
||||
rm -f "$response_file"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Timeout waiting for response"
|
||||
exit 1
|
||||
Reference in New Issue
Block a user