Give the judge what the project records and ten times more of the chunk's transcript

This commit is contained in:
2026-10-03 00:25:24 +02:00
parent 1568b3888d
commit 6d5d19bd69
10 changed files with 76 additions and 28 deletions
+23
View File
@@ -0,0 +1,23 @@
import pathlib
from loop_claude.stop import Stop
def read_records(root: str) -> str | Stop:
"""AGENTS.md and the decision log, each headed by its path; a file the project lacks is left out."""
project = pathlib.Path(root)
paths = [project / "AGENTS.md", project / "docs" / "decisions.md", *sorted(project.glob("docs/decisions/*.md"))]
records = []
for path in paths:
name = path.relative_to(project)
try:
text = path.read_text(encoding="utf-8")
except FileNotFoundError:
continue
except OSError as failure:
return Stop(1, f"{name} in {root}: {failure.strerror} - the judge cannot read the project's records.")
except UnicodeDecodeError as failure:
line = failure.object.count(b"\n", 0, failure.start) + 1
return Stop(1, f"{name} is not UTF-8 on line {line} - the judge cannot read the project's records.")
records.append(f"From {name}:\n{text.strip()}")
return "\n\n".join(records)