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
+7 -5
View File
@@ -1,7 +1,9 @@
import json
from loop_claude.claude_code.formats import assistant_parts, human_text, parse, part_text, tool_call
from loop_claude.outcome import Failure
from loop_claude.claude_code.entries import assistant_parts, human_text, parse, part_text, tool_call
from loop_claude.failure import Failure
JUDGED_TOOL_INPUT = 400
def read(path: str) -> list[dict] | Failure:
@@ -19,16 +21,16 @@ def human_turns(entries: list[dict]) -> int:
def render(entries: list[dict]) -> str:
lines = []
for entry in entries:
lines += [line for part in assistant_parts(entry) if (line := part_line(part))]
lines += [line for part in assistant_parts(entry) if (line := part_line(part, JUDGED_TOOL_INPUT))]
if (text := human_text(entry)) is not None:
lines.append("[human] " + text)
return "\n\n".join(lines)
def part_line(part: object, limit: int = 400) -> str:
def part_line(part: object, tool_input_chars: int) -> str:
if (text := part_text(part)) and text.strip():
return text
if call := tool_call(part):
name, arguments = call
return f"[tool {name}] {json.dumps(arguments)[:limit]}"
return f"[tool {name}] {json.dumps(arguments)[:tool_input_chars]}"
return ""