Name the loop's states with one transition function, and inject its side effects

This commit is contained in:
2026-10-01 23:12:37 +02:00
parent d0ce3b2690
commit f385b563f0
16 changed files with 469 additions and 126 deletions
+5 -6
View File
@@ -1,11 +1,10 @@
import subprocess
from loop_claude.effects import Effects
from loop_claude.outcome import Stop
def checkout_root(cwd) -> str | Stop:
def checkout_root(cwd, effects: Effects) -> str | Stop:
try:
found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, cwd=cwd, text=True)
found = effects.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, cwd=cwd, text=True)
except OSError as failure:
return Stop(1, f"could not start git: {failure.strerror}")
if found.returncode != 0:
@@ -13,10 +12,10 @@ def checkout_root(cwd) -> str | Stop:
return found.stdout.strip()
def checkouts(root) -> list[str]:
def checkouts(root, effects: Effects) -> list[str]:
found = [root]
try:
listing = subprocess.run(["git", "worktree", "list", "--porcelain"], capture_output=True, cwd=root, text=True)
listing = effects.run(["git", "worktree", "list", "--porcelain"], capture_output=True, cwd=root, text=True)
except OSError:
return found
if listing.returncode == 0: