Group loop_claude's modules into claude_code, claude_runs and project, and move the findings document beside larv-review

This commit is contained in:
2026-09-28 21:28:41 +02:00
parent 6a1a1d9027
commit 998cc3ac85
26 changed files with 39 additions and 35 deletions
+31
View File
@@ -0,0 +1,31 @@
import subprocess
import sys
from loop_claude import human
from loop_claude.project.checkout import checkouts
from loop_claude.outcome import Failure, Stop
from loop_claude.claude_code.transcript import human_turns, read
from loop_claude.claude_code.trust import trust
TO = "answer the question above"
def interrupt(root, session_id, model, path, question, paths):
print(f"\n{question}", file=sys.stderr)
if stop := human.off_terminal(TO):
return stop
trust(paths.claude_json, checkouts(root))
entries = read(path)
if isinstance(entries, Failure):
return Stop(1, entries.reason)
before = human_turns(entries)
try:
subprocess.run(["claude", "--model", model, "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
except OSError as failure:
return Stop(1, f"could not start claude for the interrupt: {failure.strerror}")
entries = read(path)
if isinstance(entries, Failure):
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
if human_turns(entries) <= before:
return human.needed(TO, "the interrupt ended with nothing typed")
return None