17 lines
768 B
Python
17 lines
768 B
Python
import hashlib
|
|
import pathlib
|
|
import typing
|
|
|
|
from claude_code.transcript import first_timestamped_line
|
|
from project_key import project_key
|
|
|
|
|
|
def project_archive(checkout_root: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path:
|
|
archive = pathlib.Path(env["LOOP_CLAUDE_TRANSCRIPTS"]).expanduser() if env.get("LOOP_CLAUDE_TRANSCRIPTS") else home / ".claude" / "loop-claude-transcripts"
|
|
return archive / project_key(checkout_root, home)
|
|
|
|
|
|
def chunk_folder(project_archive: pathlib.Path, transcript: bytes) -> pathlib.Path:
|
|
# Each chunk's first timestamped line is its own: a finished chunk's session is deleted, so the next chunk's transcript starts afresh.
|
|
return project_archive / hashlib.sha256(first_timestamped_line(transcript)).hexdigest()
|