21 lines
926 B
Python
21 lines
926 B
Python
import hashlib
|
|
import pathlib
|
|
import typing
|
|
|
|
from claude_code.transcript import first_timestamped_line
|
|
from project_key import project_key
|
|
|
|
|
|
def archive_root(home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path:
|
|
"""Where loop-claude archives every project's chunks."""
|
|
return pathlib.Path(env["LOOP_CLAUDE_TRANSCRIPTS"]).expanduser() if env.get("LOOP_CLAUDE_TRANSCRIPTS") else home / ".claude" / "loop-claude-transcripts"
|
|
|
|
|
|
def project_archive(checkout_root: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path:
|
|
return archive_root(home, env) / 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()
|