21 lines
732 B
Python
21 lines
732 B
Python
import pathlib
|
|
import typing
|
|
|
|
from failure import Failure
|
|
from loop_claude.transcript_archive import FinishedChunk
|
|
from loop_claude.paths import paths_from
|
|
from loop_claude.project.checkout import project_key
|
|
|
|
|
|
def project_archive(checkout_root: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path:
|
|
paths = paths_from(home, env)
|
|
return paths.transcript_archive / project_key(checkout_root, paths.code)
|
|
|
|
|
|
def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure:
|
|
"""The worker's transcript, then each subagent's."""
|
|
try:
|
|
return [path.read_bytes() for path in (chunk.transcript, *chunk.subagents)]
|
|
except OSError as failure:
|
|
return Failure(f"could not read {failure.filename}: {failure.strerror}")
|