Decode the worker's stream leniently, name UserEntryKind's members only, and restore the section-headers decision's citation
This commit is contained in:
@@ -67,7 +67,7 @@ def run_cycle(root, task, premises, chosen, paths, env):
|
|||||||
return stop
|
return stop
|
||||||
if verdict["finished"]:
|
if verdict["finished"]:
|
||||||
archive(root, path, f"Task: {task}\n\nVerdict: finished", paths)
|
archive(root, path, f"Task: {task}\n\nVerdict: finished", paths)
|
||||||
delete_session(path)
|
delete_session(session)
|
||||||
return Continue()
|
return Continue()
|
||||||
|
|
||||||
|
|
||||||
@@ -254,14 +254,15 @@ def interrupt(root, session_id, chosen, path, question, paths, env):
|
|||||||
if not (sys.stdin.isatty() and sys.stdout.isatty()):
|
if not (sys.stdin.isatty() and sys.stdout.isatty()):
|
||||||
return Stop(2, "stdin or stdout is not a terminal")
|
return Stop(2, "stdin or stdout is not a terminal")
|
||||||
trust(paths.claude_json, checkouts(root))
|
trust(paths.claude_json, checkouts(root))
|
||||||
before = read(path)
|
entries = read(path)
|
||||||
if isinstance(before, Failure):
|
if isinstance(entries, Failure):
|
||||||
return Stop(1, before.reason)
|
return Stop(1, entries.reason)
|
||||||
|
before = human_turns(entries)
|
||||||
subprocess.run(["claude", "--model", model_for(env, "LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
subprocess.run(["claude", "--model", model_for(env, "LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
||||||
after = read(path)
|
entries = read(path)
|
||||||
if isinstance(after, Failure):
|
if isinstance(entries, Failure):
|
||||||
return Stop(1, f"could not tell whether you typed anything: {after.reason}")
|
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
|
||||||
if human_turns(after) <= human_turns(before):
|
if human_turns(entries) <= before:
|
||||||
return Stop(2, "the interrupt ended without the human typing anything")
|
return Stop(2, "the interrupt ended without the human typing anything")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ def transcript_file(session):
|
|||||||
return hit[0] if hit else ""
|
return hit[0] if hit else ""
|
||||||
|
|
||||||
|
|
||||||
def delete_session(path):
|
def delete_session(session):
|
||||||
|
path = transcript_file(session)
|
||||||
|
if not path:
|
||||||
|
return
|
||||||
for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"):
|
for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"):
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling)
|
shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling)
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ from loop_claude.outcome import Failure
|
|||||||
|
|
||||||
|
|
||||||
class UserEntryKind(enum.Enum):
|
class UserEntryKind(enum.Enum):
|
||||||
"""Who wrote a "user" entry: the human wrote HUMAN, Claude Code every other kind; the value is the tell."""
|
"""Who wrote a "user" entry: the human wrote HUMAN, Claude Code every other kind."""
|
||||||
|
|
||||||
COMMAND = "string content starting with <"
|
COMMAND = enum.auto()
|
||||||
CTRL_C = "a text part starting with [Request interrupted"
|
CTRL_C = enum.auto()
|
||||||
EMPTY = "no content"
|
EMPTY = enum.auto()
|
||||||
HUMAN = "typed by the human"
|
HUMAN = enum.auto()
|
||||||
META = "isMeta"
|
META = enum.auto()
|
||||||
NON_TEXT = "a part that is not text, such as a tool result"
|
NON_TEXT = enum.auto()
|
||||||
SDK_PROMPT = "promptSource sdk: the claude -p prompt"
|
SDK_PROMPT = enum.auto()
|
||||||
|
|
||||||
|
|
||||||
def read(path):
|
def read(path):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from loop_claude.transcript import parse, parts, said
|
|||||||
|
|
||||||
def run_worker(root, args):
|
def run_worker(root, args):
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(["claude", *args], cwd=root, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, text=True)
|
proc = subprocess.Popen(["claude", *args], cwd=root, encoding="utf-8", errors="replace", stdin=subprocess.DEVNULL, stdout=subprocess.PIPE)
|
||||||
except OSError as failure:
|
except OSError as failure:
|
||||||
return Failure(f"could not start claude: {failure.strerror}")
|
return Failure(f"could not start claude: {failure.strerror}")
|
||||||
with proc:
|
with proc:
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class DeleteTranscriptFiles(unittest.TestCase):
|
|||||||
pathlib.Path(root, f"{SESSION_ID}.orphaned-1-ab.jsonl").write_text("{}\n")
|
pathlib.Path(root, f"{SESSION_ID}.orphaned-1-ab.jsonl").write_text("{}\n")
|
||||||
located = session.Session(uuid.UUID(SESSION_ID), "A name", projects)
|
located = session.Session(uuid.UUID(SESSION_ID), "A name", projects)
|
||||||
self.assertEqual(session.transcript_file(located), transcript)
|
self.assertEqual(session.transcript_file(located), transcript)
|
||||||
session.delete_session(transcript)
|
session.delete_session(located)
|
||||||
self.assertEqual(os.listdir(root), [])
|
self.assertEqual(os.listdir(root), [])
|
||||||
self.assertEqual(session.transcript_file(located), "")
|
self.assertEqual(session.transcript_file(located), "")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
## loop-claude: the section headers stay
|
## loop-claude: the section headers stay
|
||||||
|
|
||||||
2026-09-26, larv-review, declining a prose-pass deletion under `CLAUDE.md` → "Comments and documentation". Serves goal 4. Two seats of the 2026-09-26 panel credit Navigation 8 to `# ~/.claude.json` and its siblings, now in `bin/loop_claude/cycle.py`, indexing it by the file or format each group touches. Valid until the modules the rebuild splits out of `cycle.py` take over that index.
|
2026-09-26, larv-review, declining a prose-pass deletion under `CLAUDE.md` → "Comments and documentation". Serves goal 4. Two seats of the 2026-09-26 panel credit Navigation 8 to `# The transcript file` and its siblings, indexing what is now `bin/loop_claude/cycle.py` by the file or format each group touches. Valid until the modules the rebuild splits out of `cycle.py` take over that index; a header stays in it until its group moves.
|
||||||
|
|
||||||
## vocabulary: the concept words are defined under `CLAUDE.md` → "Vocabulary" and cited by a bare link
|
## vocabulary: the concept words are defined under `CLAUDE.md` → "Vocabulary" and cited by a bare link
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user