Name loop_claude's modules and words by what each holds, explain the reload, and tie each exit-1 clause of --help to its Stop

This commit is contained in:
2026-10-02 08:42:29 +02:00
parent dc844030fa
commit 211524196b
27 changed files with 212 additions and 165 deletions
+5 -5
View File
@@ -1,20 +1,20 @@
import sys
import uuid
from loop_claude import human_needed
from loop_claude.claude_code.transcript import human_turns, read
from loop_claude.claude_code.trust import trust
from loop_claude.effects import Effects
from loop_claude.outcome import Failure, Stop
from loop_claude.failure import Failure
from loop_claude.paths import Paths
from loop_claude.project.checkout import checkouts
from loop_claude.stop import Stop, needs_human, needs_terminal
TO = "answer the question above"
ANSWER_QUESTION = "answer the question above"
def interrupt(root: str, session_id: uuid.UUID, model: str, path: str, question: str, paths: Paths, effects: Effects) -> Stop | None:
print(f"\n{question}", file=sys.stderr)
if stop := human_needed.off_terminal(TO, effects.on_terminal()):
if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()):
return stop
trust(paths.claude_json, checkouts(root, effects))
entries = read(path)
@@ -28,4 +28,4 @@ def interrupt(root: str, session_id: uuid.UUID, model: str, path: str, question:
entries = read(path)
if isinstance(entries, Failure):
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
return None if human_turns(entries) > before else human_needed.stop(TO, "the interrupt ended with nothing typed")
return None if human_turns(entries) > before else needs_human(ANSWER_QUESTION, "the interrupt ended with nothing typed")