Give the judge what the project records and ten times more of the chunk's transcript
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user