-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·195 lines (171 loc) · 5.22 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·195 lines (171 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Ralph-Lisa Loop - Start Script
#
# Launches Claude (Ralph) and Codex (Lisa) in two terminals.
# Codex reads .codex/config.toml for instructions and skills.
#
# Usage: ./start.sh [--full-auto] [task-description]
#
# Options:
# --full-auto Skip all permission prompts (claude --dangerously-skip-permissions + codex --dangerously-bypass-approvals-and-sandbox)
#
# Supports: macOS Terminal, iTerm2, tmux
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Parse --full-auto flag
FULL_AUTO=false
ARGS=()
for arg in "$@"; do
case "$arg" in
--full-auto) FULL_AUTO=true ;;
*) ARGS+=("$arg") ;;
esac
done
set -- "${ARGS[@]+"${ARGS[@]}"}"
PROJECT_DIR="${1:+$(cd "${1}" && pwd)}"
PROJECT_DIR="${PROJECT_DIR:-$(pwd)}"
TASK="${2:-${1:-}}"
# If first arg is a directory, use it as PROJECT_DIR
# Otherwise treat it as the task description
if [[ -n "${1:-}" ]] && [[ ! -d "${1:-}" ]]; then
PROJECT_DIR="$(pwd)"
TASK="${1:-}"
fi
# Build agent commands based on --full-auto
if [[ "$FULL_AUTO" == true ]]; then
CLAUDE_CMD="claude --dangerously-skip-permissions"
CODEX_CMD="codex --dangerously-bypass-approvals-and-sandbox"
else
CLAUDE_CMD="claude"
CODEX_CMD="codex"
fi
echo "========================================"
echo "Ralph-Lisa Loop - Start"
echo "========================================"
echo "Project: $PROJECT_DIR"
if [[ "$FULL_AUTO" == true ]]; then
echo "Mode: FULL AUTO (no permission prompts)"
fi
echo ""
# Check prerequisites
if ! command -v claude &> /dev/null; then
echo "Error: 'claude' command not found. Install Claude Code first."
exit 1
fi
if ! command -v codex &> /dev/null; then
echo "Error: 'codex' command not found. Install Codex CLI first."
exit 1
fi
# Check if initialized
if [[ ! -f "$PROJECT_DIR/CLAUDE.md" ]] || ! grep -q "RALPH-LISA-LOOP" "$PROJECT_DIR/CLAUDE.md" 2>/dev/null; then
echo "Error: Not initialized. Run init.sh first."
exit 1
fi
# Initialize task if provided
if [[ -n "$TASK" ]]; then
if [[ -d "$PROJECT_DIR/.dual-agent" ]] && [[ -f "$PROJECT_DIR/.dual-agent/task.md" ]]; then
EXISTING_TASK=$(sed -n '3p' "$PROJECT_DIR/.dual-agent/task.md" 2>/dev/null || echo "unknown")
echo "Warning: Existing session will be overwritten."
echo "Current task: $EXISTING_TASK"
echo ""
read -p "Continue and overwrite? [y/N] " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
fi
echo "Task: $TASK"
"$PROJECT_DIR/io.sh" init "$TASK"
echo ""
fi
#===========================================
# Launch commands
#===========================================
# Ralph (Claude Code)
# - CLAUDE.md auto-read as project instructions
# - .claude/commands/ auto-loaded as slash commands
RALPH_CMD="cd '$PROJECT_DIR' && echo '=== Ralph (Claude Code) ===' && echo 'Commands: /check-turn, /submit-work, /view-status' && echo 'First: /check-turn' && echo '' && $CLAUDE_CMD"
# Lisa (Codex)
# - .codex/config.toml provides: instructions (CODEX.md) and skills path
LISA_CMD="cd '$PROJECT_DIR' && echo '=== Lisa (Codex) ===' && echo 'First: ralph-lisa whose-turn' && echo '' && $CODEX_CMD"
launch_macos_terminal() {
echo "Launching with macOS Terminal..."
osascript << EOF
tell application "Terminal"
activate
do script "$RALPH_CMD"
set custom title of front window to "Ralph (Claude)"
end tell
EOF
sleep 1
osascript << EOF
tell application "Terminal"
activate
do script "$LISA_CMD"
set custom title of front window to "Lisa (Codex)"
end tell
EOF
}
launch_iterm2() {
echo "Launching with iTerm2..."
osascript << EOF
tell application "iTerm"
activate
set ralphWindow to (create window with default profile)
tell current session of ralphWindow
write text "$RALPH_CMD"
set name to "Ralph (Claude)"
end tell
tell current window
set lisaTab to (create tab with default profile)
tell current session of lisaTab
write text "$LISA_CMD"
set name to "Lisa (Codex)"
end tell
end tell
end tell
EOF
}
launch_tmux() {
echo "Launching with tmux..."
SESSION_NAME="ralph-lisa"
tmux kill-session -t "$SESSION_NAME" 2>/dev/null || true
tmux new-session -d -s "$SESSION_NAME" -n "Ralph" "bash -c '$RALPH_CMD; exec bash'"
tmux split-window -h -t "$SESSION_NAME" "bash -c '$LISA_CMD; exec bash'"
tmux attach-session -t "$SESSION_NAME"
}
launch_generic() {
echo "Please manually open two terminals:"
echo ""
echo "Terminal 1 (Ralph):"
echo " cd $PROJECT_DIR && claude"
echo ""
echo "Terminal 2 (Lisa):"
echo " cd $PROJECT_DIR && codex"
}
# Detect and launch
if [[ "$OSTYPE" == "darwin"* ]]; then
if pgrep -x "iTerm2" > /dev/null || [[ -d "/Applications/iTerm.app" ]]; then
launch_iterm2
else
launch_macos_terminal
fi
elif command -v tmux &> /dev/null; then
launch_tmux
else
launch_generic
fi
echo ""
echo "========================================"
echo "Both agents launched!"
echo "========================================"
echo ""
echo "Turn-based workflow:"
echo " 1. Check turn: ./io.sh whose-turn"
echo " 2. Submit: ./io.sh submit-ralph/lisa \"[TAG]...\""
echo " 3. Turn auto-passes to partner"
echo " 4. STOP and wait"
echo ""
echo "Current turn: $(cat "$PROJECT_DIR/.dual-agent/turn.txt" 2>/dev/null || echo 'ralph')"
echo "========================================"