sx-loops: each language runs in its own git worktree
Previous version ran all 7 claude sessions in the main working tree on branch 'architecture'. That would race on git operations and cross- contaminate commits between languages even though their file scopes don't overlap. Now each session runs in /root/rose-ash-loops/<lang> on branch loops/<lang>, created from the current architecture HEAD. sx-loops-down.sh gains --clean to remove the worktrees; loops/<lang> branches stay unless explicitly deleted. Also: second Enter keystroke after the /loop command, since Claude's input box sometimes interprets the first newline as a soft break.
This commit is contained in:
@@ -1,23 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stop the sx-loops tmux session. Prompts the claude sessions to exit cleanly
|
||||
# first (/exit in each window), then kills the tmux session after a grace
|
||||
# period. Loops stop immediately; in-progress iterations commit what they have.
|
||||
# Stop the sx-loops tmux session. Optionally (--clean) also remove the
|
||||
# per-language git worktrees. Loops stop immediately; in-progress iterations
|
||||
# commit whatever they have; nothing is pushed that wasn't already.
|
||||
set -euo pipefail
|
||||
|
||||
SESSION="sx-loops"
|
||||
WORKTREE_BASE="/root/rose-ash-loops"
|
||||
CLEAN=0
|
||||
|
||||
if ! tmux has-session -t "$SESSION" 2>/dev/null; then
|
||||
echo "No sx-loops session running."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
WINDOWS=$(tmux list-windows -t "$SESSION" -F '#W')
|
||||
for w in $WINDOWS; do
|
||||
tmux send-keys -t "$SESSION:$w" "/exit" C-m 2>/dev/null || true
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--clean) CLEAN=1 ;;
|
||||
*) echo "Unknown arg: $arg"; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Sent /exit to all windows. Waiting 5s for clean shutdown..."
|
||||
sleep 5
|
||||
if tmux has-session -t "$SESSION" 2>/dev/null; then
|
||||
WINDOWS=$(tmux list-windows -t "$SESSION" -F '#W')
|
||||
for w in $WINDOWS; do
|
||||
tmux send-keys -t "$SESSION:$w" "/exit" C-m 2>/dev/null || true
|
||||
done
|
||||
echo "Sent /exit to all windows. Waiting 5s for clean shutdown..."
|
||||
sleep 5
|
||||
tmux kill-session -t "$SESSION"
|
||||
echo "Killed tmux session '$SESSION'."
|
||||
else
|
||||
echo "No sx-loops tmux session running."
|
||||
fi
|
||||
|
||||
tmux kill-session -t "$SESSION"
|
||||
echo "Killed sx-loops session."
|
||||
if [ "$CLEAN" = "1" ]; then
|
||||
cd "$(dirname "$0")/.."
|
||||
for lang in lua prolog forth erlang haskell js hs; do
|
||||
wt="$WORKTREE_BASE/$lang"
|
||||
if [ -d "$wt" ]; then
|
||||
git worktree remove --force "$wt" 2>/dev/null || rm -rf "$wt"
|
||||
echo "Removed worktree: $wt"
|
||||
fi
|
||||
done
|
||||
git worktree prune
|
||||
echo "Worktree branches (loops/<lang>) are preserved. Delete manually if desired:"
|
||||
echo " git branch -D loops/lua loops/prolog loops/forth loops/erlang loops/haskell loops/js loops/hs"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user