# 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: irm https://vcn-49-the-swarm.vercel.app/wire.ps1 | iex # From inside the repo you are bringing: # cd your-repo; irm https://vcn-49-the-swarm.vercel.app/wire.ps1 | iex # # To also do a real worktree add/list/remove round-trip in a temp dir and clean up: # $env:SWARM_PROBE=1; irm https://vcn-49-the-swarm.vercel.app/wire.ps1 | iex # # There are NO credentials in this file and it prints none. ASCII only. # Nothing to uninstall: the default run writes nothing. $ErrorActionPreference = 'Continue' $script:Failed = 0 function Ok ($m) { Write-Host (" OK " + $m) } function Warn ($m) { Write-Host (" WARN " + $m) } function Bad ($m) { Write-Host (" FAIL " + $m); $script:Failed = 1 } function Have ($c) { $null -ne (Get-Command $c -ErrorAction SilentlyContinue) } Write-Host "" Write-Host "VCN #49 The Swarm - machine doctor" Write-Host "-----------------------------------" # 1. git present, and new enough for worktrees (shipped in 2.5, Jul 2015). if (Have git) { $gv = (git --version) -replace '[^0-9\.]', '' -split '\.' $maj = [int]($gv[0]); $min = [int]($gv[1]) if ($maj -gt 2 -or ($maj -eq 2 -and $min -ge 5)) { Ok ("git " + $maj + "." + $min + " (worktrees need 2.5+)") } else { Bad ("git " + $maj + "." + $min + " is older than 2.5 - no worktree support") } } else { Bad "git not found on PATH" } # 2. Claude Code, the thing that drives each worker. if (Have claude) { Ok "claude on PATH" } else { Warn "claude not on PATH - you need it to drive the agents" } # 3. Are we inside a repo? $inRepo = $false if (Have git) { git rev-parse --git-dir *> $null if ($LASTEXITCODE -eq 0) { $inRepo = $true; Ok "inside a git repo" } else { Warn "not inside a git repo - re-run from the repo you are bringing tonight" } } if ($inRepo) { # 4. Clean tree. Worktree add works dirty, but tonight you merge three branches # back, and an unrelated dirty file turns a clean merge into a confusing one. # 2>$null: some git configs emit "warning: untracked cache is disabled" on # every status, which is noise in a doctor whose whole job is a clean report. $st = git status --porcelain 2>$null if ([string]::IsNullOrWhiteSpace(($st | Out-String))) { Ok "working tree is clean" } else { Warn "working tree is dirty - commit or stash before the lab" } # 5. Existing worktrees. One is the normal starting state. $n = @(git worktree list).Count if ($n -le 1) { Ok ("worktrees: " + $n + " (a clean starting point)") } else { Warn ("worktrees: " + $n + " already exist - 'git worktree list' to see them") } # 6. THE ONE THAT BITES ON WINDOWS. A junction inside a worktree is FOLLOWED by # `git worktree remove`, which deletes the TARGET, outside the worktree, and # exits 0 printing nothing. See slide 9. rmdir the link first, never rm -rf. $rp = Get-ChildItem -Force -Depth 1 -ErrorAction SilentlyContinue | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint -or $_.Name -in '.venv','node_modules' } | Select-Object -First 5 if ($rp) { Warn "found junctions/links or heavy dirs near the root:" $rp | ForEach-Object { Write-Host (" " + $_.Name) } Warn "if you link any of these INTO a worktree, rmdir the link BEFORE removing the tree" } else { Ok "no obvious reparse points near the repo root" } } # 7. Optional: prove the mechanism for real, in a temp dir, then clean up. if ($env:SWARM_PROBE -eq '1' -and (Have git)) { Write-Host "" Write-Host " probe: real worktree round-trip in a temp dir" $t = Join-Path ([IO.Path]::GetTempPath()) ("swarm-probe-" + [Guid]::NewGuid().ToString('N').Substring(0,8)) try { New-Item -ItemType Directory -Path (Join-Path $t 'r') -Force | Out-Null Push-Location (Join-Path $t 'r') git init -q . *> $null git -c user.name=probe -c user.email=probe@local commit -q --allow-empty -m init *> $null git worktree add ../w -b probe/tmp *> $null $added = ($LASTEXITCODE -eq 0) git worktree remove ../w *> $null $removed = ($LASTEXITCODE -eq 0) Pop-Location if ($added -and $removed) { Ok "worktree add / list / remove all work here" } else { Bad "worktree round-trip failed on this machine" } } catch { Bad "worktree round-trip failed on this machine" } finally { # os-level rmdir semantics: this temp tree contains no links we created. Remove-Item -Recurse -Force $t -ErrorAction SilentlyContinue } } Write-Host "" if ($script:Failed -eq 0) { Write-Host " READY. Bring a repo with THREE independent things to do." Write-Host " Independence is the real prerequisite: if two of them edit the" Write-Host " same file, they are one task, and the lab will show you why." } else { Write-Host " NOT READY. Fix the FAIL lines above, then re-run." } Write-Host "" Write-Host " Deck: https://vcn-49-the-swarm.vercel.app" Write-Host " Prep: https://vcn-49-the-swarm.vercel.app/setup.txt" Write-Host " Agents: https://vcn-49-the-swarm.vercel.app/llms.txt" Write-Host ""