You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(goose): add support for tmux as an alternative to screen
- Introduced new variables `experiment_use_tmux` and `session_name` for configuring tmux or screen sessions.
- Updated script logic to handle both tmux and screen, ensuring only one can be enabled at a time.
- Enhanced error handling for missing dependencies and session management for both tmux and screen.
if [ "${var.experiment_use_screen}" = "true" ]; then
202
+
# Handle terminal multiplexer selection (tmux or screen)
203
+
if [ "${var.experiment_use_tmux}" = "true" ] && [ "${var.experiment_use_screen}" = "true" ]; then
204
+
echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously."
205
+
echo "Please set only one of them to true."
206
+
exit 1
207
+
fi
208
+
209
+
# Determine goose command
210
+
if command_exists goose; then
211
+
GOOSE_CMD=goose
212
+
elif [ -f "$HOME/.local/bin/goose" ]; then
213
+
GOOSE_CMD="$HOME/.local/bin/goose"
214
+
else
215
+
echo "Error: Goose is not installed. Please enable install_goose or install it manually."
216
+
exit 1
217
+
fi
218
+
219
+
# Run with tmux if enabled
220
+
if [ "${var.experiment_use_tmux}" = "true" ]; then
221
+
echo "Running Goose in the background with tmux..."
222
+
223
+
# Check if tmux is installed
224
+
if ! command_exists tmux; then
225
+
echo "Error: tmux is not installed. Please install tmux manually."
226
+
exit 1
227
+
fi
228
+
229
+
touch "$HOME/.goose.log"
230
+
231
+
export LANG=en_US.UTF-8
232
+
export LC_ALL=en_US.UTF-8
233
+
234
+
# Configure tmux for shared sessions
235
+
if [ ! -f "$HOME/.tmux.conf" ]; then
236
+
echo "Creating ~/.tmux.conf with shared session settings..."
237
+
echo "set -g mouse on" > "$HOME/.tmux.conf"
238
+
fi
239
+
240
+
if ! grep -q "^set -g mouse on$" "$HOME/.tmux.conf"; then
241
+
echo "Adding 'set -g mouse on' to ~/.tmux.conf..."
242
+
echo "set -g mouse on" >> "$HOME/.tmux.conf"
243
+
fi
244
+
245
+
# Create a new tmux session in detached mode
246
+
tmux new-session -d -s ${var.session_name} -c ${var.folder} "\"$GOOSE_CMD\" run --text \"Review your goosehints. Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GOOSE_TASK_PROMPT\" --interactive | tee -a \"$HOME/.goose.log\"; exec bash"
247
+
elif [ "${var.experiment_use_screen}" = "true" ]; then
192
248
echo "Running Goose in the background..."
193
249
194
250
# Check if screen is installed
@@ -217,31 +273,11 @@ EOL
217
273
export LANG=en_US.UTF-8
218
274
export LC_ALL=en_US.UTF-8
219
275
220
-
# Determine goose command
221
-
if command_exists goose; then
222
-
GOOSE_CMD=goose
223
-
elif [ -f "$HOME/.local/bin/goose" ]; then
224
-
GOOSE_CMD="$HOME/.local/bin/goose"
225
-
else
226
-
echo "Error: Goose is not installed. Please enable install_goose or install it manually."
227
-
exit 1
228
-
fi
229
-
230
-
screen -U -dmS goose bash -c "
276
+
screen -U -dmS ${var.session_name} bash -c "
231
277
cd ${var.folder}
232
278
\"$GOOSE_CMD\" run --text \"Review your goosehints. Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GOOSE_TASK_PROMPT\" --interactive | tee -a \"$HOME/.goose.log\"
233
279
/bin/bash
234
280
"
235
-
else
236
-
# Check if goose is installed before running
237
-
if command_exists goose; then
238
-
GOOSE_CMD=goose
239
-
elif [ -f "$HOME/.local/bin/goose" ]; then
240
-
GOOSE_CMD="$HOME/.local/bin/goose"
241
-
else
242
-
echo "Error: Goose is not installed. Please enable install_goose or install it manually."
if [ "${var.experiment_use_screen}" = "true" ]; then
309
+
export LANG=en_US.UTF-8
310
+
export LC_ALL=en_US.UTF-8
311
+
312
+
if [ "${var.experiment_use_tmux}" = "true" ]; then
313
+
if tmux has-session -t ${var.session_name} 2>/dev/null; then
314
+
echo "Attaching to existing Goose tmux session." | tee -a "$HOME/.goose.log"
315
+
tmux attach-session -t ${var.session_name}
316
+
else
317
+
echo "Starting a new Goose tmux session." | tee -a "$HOME/.goose.log"
318
+
tmux new-session -s ${var.session_name} -c ${var.folder} "\"$GOOSE_CMD\" run --text \"Review your goosehints. Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GOOSE_TASK_PROMPT\" --interactive | tee -a \"$HOME/.goose.log\"; exec bash"
319
+
fi
320
+
elif [ "${var.experiment_use_screen}" = "true" ]; then
274
321
# Check if session exists first
275
-
if ! screen -list | grep -q "goose"; then
322
+
if ! screen -list | grep -q "${var.session_name}"; then
276
323
echo "Error: No existing Goose session found. Please wait for the script to start it."
277
324
exit 1
278
325
fi
279
326
# Only attach to existing session
280
-
screen -xRR goose
327
+
screen -xRR ${var.session_name}
281
328
else
282
329
cd ${var.folder}
283
-
export LANG=en_US.UTF-8
284
-
export LC_ALL=en_US.UTF-8
285
330
"$GOOSE_CMD" run --text "Review goosehints. Your task: $GOOSE_TASK_PROMPT" --interactive
0 commit comments