Group a cycle's modules under cycle/, apart from claude_code/
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
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.outcome import Failure, Stop
|
||||
from loop_claude.project.checkout import checkouts
|
||||
|
||||
TO = "answer the question above"
|
||||
|
||||
|
||||
def interrupt(root, session_id, model, path, question, paths):
|
||||
print(f"\n{question}", file=sys.stderr)
|
||||
if stop := human_needed.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.stop(TO, "the interrupt ended with nothing typed")
|
||||
return None
|
||||
Reference in New Issue
Block a user