Name the stream that is not a terminal, and the rerun after exit 2

This commit is contained in:
2026-09-24 23:33:24 +02:00
parent 14b7e72ae3
commit 27dc866e7d
4 changed files with 9 additions and 9 deletions
+5 -6
View File
@@ -10,10 +10,10 @@ unfinished chunk resumes the same session next cycle; a finished one starts a fr
continue until that interrupt or Ctrl-C.
Exit 1: no task, 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;
rerunning resumes the session. Exit 2: the human is needed and no terminal is attached, or the
interrupt ended without them typing anything. Before an interrupt every worktree is marked trusted in
~/.claude.json.
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
them typing anything. Rerunning resumes the session after either. Before an interrupt every worktree
is marked trusted in ~/.claude.json.
Each project has one session, "A ~/code/<path> auto-mode" (the absolute path outside ~/code),
deleted when the chunk finishes. Its transcript is archived under $AUTO_MODE_TRANSCRIPTS (default
@@ -134,7 +134,6 @@ def end_session(path):
def session_open(session_id):
"""The transcript outlives its cycle until end_session removes it: present means the chunk is unfinished."""
return bool(session_file(session_id))
@@ -311,7 +310,7 @@ def judge(task, premises, transcript):
def interrupt(session_id, path, question):
print(f"\n{question}", file=sys.stderr)
if not (sys.stdin.isatty() and sys.stdout.isatty()):
return "the human is needed and no terminal is attached"
return "stdin or stdout is not a terminal"
trust(checkouts())
before = human_turns(entries(path))
subprocess.run(["claude", "--permission-mode", "bypassPermissions", "--resume", str(session_id)])
+2 -2
View File
@@ -145,7 +145,7 @@ class Interrupt(unittest.TestCase):
transcript = os.path.join(root, "session.jsonl")
open(transcript, "w").write("{}\n")
with unittest.mock.patch("sys.stdin.isatty", return_value=False):
self.assertEqual(loop.interrupt(SESSION_ID, transcript, "q?"), "the human is needed and no terminal is attached")
self.assertEqual(loop.interrupt(SESSION_ID, transcript, "q?"), "stdin or stdout is not a terminal")
with (
unittest.mock.patch("sys.stdin.isatty", return_value=True),
unittest.mock.patch("sys.stdout.isatty", return_value=True),
@@ -218,7 +218,7 @@ class RunCycle(unittest.TestCase):
self.assertEqual(stopped.exception.code, 2)
said = "".join(str(call.args[0]) for call in stderr.write.call_args_list)
self.assertIn("transcript:", said)
self.assertIn("no terminal is attached", said)
self.assertIn("not a terminal", said)
for plan in ("fail fail fail", "unquoted unquoted unquoted"):
open(verdicts, "w").write(plan)
with self.assertRaises(SystemExit) as stopped: