Group a cycle's modules under cycle/, apart from claude_code/
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
from loop_claude.file_writes import make_private, replace_file
|
||||
from loop_claude.outcome import Failure
|
||||
|
||||
|
||||
def archive(project, path, note, paths):
|
||||
folder = paths.archive / project
|
||||
try:
|
||||
with open(path, "rb") as handle:
|
||||
raw = handle.read()
|
||||
make_private(folder)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not archive the transcript: {failure.filename}: {failure.strerror}")
|
||||
copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl"
|
||||
# The copy lands last, so a copy on disk always has its verdict beside it.
|
||||
if not copy.exists():
|
||||
for dest, data in ((copy.with_suffix(".verdict.md"), f"{note}\n".encode()), (copy, raw)):
|
||||
if failure := replace_file(dest, data):
|
||||
return Failure(f"could not archive the transcript: {dest}: {failure.reason}")
|
||||
print(f"transcript: {copy}", file=sys.stderr)
|
||||
return None
|
||||
Reference in New Issue
Block a user