#!/usr/bin/env sh # VCN #49 The Swarm - check a machine can run parallel coding agents in git worktrees. # DOCTOR ONLY. This script changes NOTHING: it creates no worktree, no branch, no # file, and touches no global config. It reads your git version and repo state and # tells you whether tonight's lab will work here. # # Run: curl -fsSL https://vcn-49-the-swarm.vercel.app/wire.sh | sh # From inside the repo you are bringing: # cd your-repo && curl -fsSL https://vcn-49-the-swarm.vercel.app/wire.sh | sh # # Options (append after -s --): # --probe ALSO do a real worktree add/list/remove round-trip in a temp dir, # then clean it up. Proves the mechanism end to end. Still creates # nothing inside your repo that it does not remove. # # There are NO credentials in this file and it prints none. ASCII only. # Nothing to uninstall: the default run writes nothing. set -u PROBE=0 while [ $# -gt 0 ]; do case "$1" in --probe) PROBE=1 ;; -h|--help) sed -n '2,18p' "$0" 2>/dev/null || echo "see https://vcn-49-the-swarm.vercel.app/wire.sh"; exit 0 ;; *) echo "unknown option: $1 (ignored)" ;; esac shift done ok() { printf ' OK %s\n' "$1"; } warn() { printf ' WARN %s\n' "$1"; } bad() { printf ' FAIL %s\n' "$1"; } have() { command -v "$1" >/dev/null 2>&1; } FAILED=0 echo "" echo "VCN #49 The Swarm - machine doctor" echo "-----------------------------------" # 1. git present, and new enough for worktrees (shipped in 2.5, Jul 2015). if have git; then GV=$(git --version 2>/dev/null | awk '{print $3}') MAJ=$(echo "$GV" | cut -d. -f1) MIN=$(echo "$GV" | cut -d. -f2) if [ "${MAJ:-0}" -gt 2 ] 2>/dev/null || { [ "${MAJ:-0}" -eq 2 ] && [ "${MIN:-0}" -ge 5 ]; } 2>/dev/null; then ok "git $GV (worktrees need 2.5+)" else bad "git $GV is older than 2.5 - no worktree support"; FAILED=1 fi else bad "git not found on PATH"; FAILED=1 fi # 2. Claude Code, the thing that drives each worker. if have claude; then ok "claude on PATH"; else warn "claude not on PATH - you need it to drive the agents. See $0 notes." fi # 3. Are we inside a repo? Everything below only applies if we are. INREPO=0 if have git && git rev-parse --git-dir >/dev/null 2>&1; then INREPO=1 ok "inside a git repo" else warn "not inside a git repo - re-run this from the repo you are bringing tonight" fi if [ "$INREPO" -eq 1 ]; then # 4. Clean tree. `git worktree add` works with a dirty tree, but tonight you # will be merging three branches back and an unrelated dirty file is the # thing that turns a clean merge into a confusing one. if [ -z "$(git status --porcelain 2>/dev/null)" ]; then ok "working tree is clean" else warn "working tree is dirty - commit or stash before the lab" fi # 5. How many worktrees already exist. One is the normal starting state. N=$(git worktree list 2>/dev/null | wc -l | tr -d ' ') if [ "${N:-0}" -le 1 ]; then ok "worktrees: $N (a clean starting point)" else warn "worktrees: $N already exist - 'git worktree list' to see them" fi # 6. THE ONE THAT BITES. A reparse point (symlink/junction) inside a worktree # is followed by `git worktree remove` and by `rm -rf`, which deletes the # TARGET, outside the worktree, and exits 0 saying nothing. See slide 9. LINKS=$(find . -maxdepth 2 \( -type l -o -name .venv -o -name node_modules \) 2>/dev/null | head -5) if [ -n "$LINKS" ]; then warn "found links or heavy dirs near the root:" echo "$LINKS" | sed 's/^/ /' warn "if you link any of these INTO a worktree, unlink before removing it" else ok "no obvious reparse points near the repo root" fi fi # 7. Optional: prove the mechanism for real, in a temp dir, then clean up. if [ "$PROBE" -eq 1 ] && have git; then echo "" echo " probe: real worktree round-trip in a temp dir" T=$(mktemp -d 2>/dev/null || echo "./.swarm-probe-$$") ( mkdir -p "$T/r" && cd "$T/r" \ && git init -q . 2>/dev/null \ && git -c user.name=probe -c user.email=probe@local commit -q --allow-empty -m init 2>/dev/null \ && git worktree add ../w -b probe/tmp >/dev/null 2>&1 \ && git worktree list | tail -1 >/dev/null \ && git worktree remove ../w >/dev/null 2>&1 ) \ && ok "worktree add / list / remove all work here" \ || { bad "worktree round-trip failed on this machine"; FAILED=1; } rm -rf "$T" 2>/dev/null fi echo "" if [ "$FAILED" -eq 0 ]; then echo " READY. Bring a repo with THREE independent things to do." echo " Independence is the real prerequisite: if two of them edit the" echo " same file, they are one task, and the lab will show you why." else echo " NOT READY. Fix the FAIL lines above, then re-run." fi echo "" echo " Deck: https://vcn-49-the-swarm.vercel.app" echo " Prep: https://vcn-49-the-swarm.vercel.app/setup.txt" echo " Agents: https://vcn-49-the-swarm.vercel.app/llms.txt" echo "" exit "$FAILED"