Exit when loop-claude is started outside a checkout

This commit is contained in:
2026-09-25 08:44:48 +02:00
parent 76d1b218bf
commit 4d46d369d3
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -10,7 +10,7 @@ interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the sa
cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words:
~/.claude/CLAUDE.md → "Vocabulary". ~/.claude/CLAUDE.md → "Vocabulary".
Exit 1: no task, no premises, claude leaves no transcript, or the worker or the judge fails three Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or the judge fails three
times running, a verdict missing a field or quoting nothing in the transcript being a judge failure. times running, a verdict missing a field or quoting nothing in the transcript being a judge failure.
Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without
them typing anything. Rerunning resumes the session after either exit. Before an interrupt every them typing anything. Rerunning resumes the session after either exit. Before an interrupt every
@@ -115,7 +115,9 @@ def read_premises():
def checkout_root(): def checkout_root():
found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True) found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
return found.stdout.strip() if found.returncode == 0 else os.getcwd() if found.returncode != 0:
sys.exit(found.stderr.strip())
return found.stdout.strip()
def project(): def project():
+4 -2
View File
@@ -86,10 +86,12 @@ class HumanTurns(unittest.TestCase):
class CheckoutRoot(unittest.TestCase): class CheckoutRoot(unittest.TestCase):
def test_is_the_checkout_from_any_directory_inside_it_and_the_directory_itself_outside_one(self): def test_is_the_checkout_from_any_directory_inside_it_and_exits_outside_one(self):
with tempfile.TemporaryDirectory() as tmp, contextlib.chdir(tmp): with tempfile.TemporaryDirectory() as tmp, contextlib.chdir(tmp):
root = os.getcwd() root = os.getcwd()
self.assertEqual(loop.checkout_root(), root) with self.assertRaises(SystemExit) as stopped:
loop.checkout_root()
self.assertIn("not a git repository", stopped.exception.code)
subprocess.run(["git", "init", "-q"], check=True) subprocess.run(["git", "init", "-q"], check=True)
os.makedirs("a/b") os.makedirs("a/b")
with contextlib.chdir("a/b"): with contextlib.chdir("a/b"):