Local sx-loops tmux launcher: 7 claude sessions, one per language
sx-loops-up.sh spawns a tmux session 'sx-loops' with 7 windows (lua, prolog, forth, erlang, haskell, js, hs). Each window runs 'claude' and then /loop against its briefing at plans/agent-briefings/<x>-loop.md. Optional arg is the interval (e.g. 15m); omit for model-self-paced. Each loop does ONE iteration per fire: pick the first unchecked [ ] item, implement, test, commit, tick, log — then stop. Commits push to origin/loops/<lang> (safe; not main). sx-loops-down.sh sends /exit to each window and kills the session. Attach with: tmux a -t sx-loops
This commit is contained in:
23
scripts/sx-loops-down.sh
Executable file
23
scripts/sx-loops-down.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/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.
|
||||
set -euo pipefail
|
||||
|
||||
SESSION="sx-loops"
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
echo "Sent /exit to all windows. Waiting 5s for clean shutdown..."
|
||||
sleep 5
|
||||
|
||||
tmux kill-session -t "$SESSION"
|
||||
echo "Killed sx-loops session."
|
||||
72
scripts/sx-loops-up.sh
Executable file
72
scripts/sx-loops-up.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
# Spawn 7 claude sessions in tmux, one per language loop.
|
||||
# Each runs /loop against its briefing, doing ONE iteration per fire.
|
||||
#
|
||||
# Usage: ./scripts/sx-loops-up.sh [interval]
|
||||
# interval defaults to self-paced (omit to let model decide)
|
||||
#
|
||||
# After the script prints done:
|
||||
# tmux a -t sx-loops
|
||||
# Ctrl-B + <window-number> to switch
|
||||
# Ctrl-B + d to detach (loops keep running)
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
SESSION="sx-loops"
|
||||
INTERVAL="${1:-}" # e.g. "15m", or empty for self-paced
|
||||
BOOT_WAIT=20 # seconds to wait for each claude to boot before sending /loop
|
||||
|
||||
if tmux has-session -t "$SESSION" 2>/dev/null; then
|
||||
echo "Session '$SESSION' already exists."
|
||||
echo " Attach: tmux a -t $SESSION"
|
||||
echo " Kill: tmux kill-session -t $SESSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -A BRIEFING=(
|
||||
[lua]=lua-loop.md
|
||||
[prolog]=prolog-loop.md
|
||||
[forth]=forth-loop.md
|
||||
[erlang]=erlang-loop.md
|
||||
[haskell]=haskell-loop.md
|
||||
[js]=loop.md
|
||||
[hs]=hs-loop.md
|
||||
)
|
||||
ORDER=(lua prolog forth erlang haskell js hs)
|
||||
|
||||
# Create tmux session with 7 windows, one per language
|
||||
tmux new-session -d -s "$SESSION" -n "${ORDER[0]}" -c "$PWD"
|
||||
for lang in "${ORDER[@]:1}"; do
|
||||
tmux new-window -t "$SESSION" -n "$lang" -c "$PWD"
|
||||
done
|
||||
|
||||
# Start claude in each window
|
||||
echo "Starting 7 claude sessions..."
|
||||
for lang in "${ORDER[@]}"; do
|
||||
tmux send-keys -t "$SESSION:$lang" "claude" C-m
|
||||
done
|
||||
|
||||
echo "Waiting ${BOOT_WAIT}s for claude to boot in each window..."
|
||||
sleep "$BOOT_WAIT"
|
||||
|
||||
# Send the /loop command in each window
|
||||
for lang in "${ORDER[@]}"; do
|
||||
briefing="${BRIEFING[$lang]}"
|
||||
if [ -n "$INTERVAL" ]; then
|
||||
cmd="/loop $INTERVAL Read plans/agent-briefings/$briefing and do ONE iteration per fire: pick the first unchecked [ ] from the plan, implement, test, commit with a short factual message, tick the box, append one dated line to the Progress log (newest first), then stop. Push to origin/loops/$lang (branch per language; never main). Stay strictly in the briefing's scope. Never push to main."
|
||||
else
|
||||
cmd="/loop Read plans/agent-briefings/$briefing and do ONE iteration per fire: pick the first unchecked [ ] from the plan, implement, test, commit with a short factual message, tick the box, append one dated line to the Progress log (newest first), then stop. Push to origin/loops/$lang (branch per language; never main). Stay strictly in the briefing's scope. Never push to main."
|
||||
fi
|
||||
tmux send-keys -t "$SESSION:$lang" "$cmd" C-m
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Done. 7 loops started in tmux session '$SESSION'."
|
||||
echo ""
|
||||
echo " Attach: tmux a -t $SESSION"
|
||||
echo " Switch: Ctrl-B then window number 0-6 (lua=0, prolog=1, forth=2, erlang=3, haskell=4, js=5, hs=6)"
|
||||
echo " Or index: Ctrl-B w (lists windows)"
|
||||
echo " Detach: Ctrl-B d"
|
||||
echo " Kill all: tmux kill-session -t $SESSION"
|
||||
echo ""
|
||||
echo "If a window did NOT enter /loop mode (boot was slow), attach and paste the /loop command manually."
|
||||
Reference in New Issue
Block a user