Keep formats.py to Claude Code's shapes, with paths and file reads at their callers
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import dataclasses
|
||||
import glob
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from loop_claude.claude_code.formats import session_files, transcript_path
|
||||
|
||||
NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
||||
|
||||
|
||||
@@ -24,15 +23,18 @@ def session_for(project, paths):
|
||||
return Session(id=uuid.uuid5(NAMESPACE, name), claude_code_transcripts=paths.claude_code_transcripts, name=name)
|
||||
|
||||
|
||||
# <claude_code_transcripts>/-home-me-code-log/<session id>.jsonl
|
||||
def transcript_file(session):
|
||||
return transcript_path(session.claude_code_transcripts, session.id)
|
||||
hit = glob.glob(os.path.join(glob.escape(str(session.claude_code_transcripts)), "*", f"{session.id}.jsonl"))
|
||||
return hit[0] if hit else ""
|
||||
|
||||
|
||||
def delete_session(session):
|
||||
path = transcript_file(session)
|
||||
if not path:
|
||||
return
|
||||
for sibling in session_files(path):
|
||||
# <session id>.jsonl, <session id>/subagents/, and from older versions <session id>.superseded-1789290815002/ and <session id>.orphaned-*.jsonl
|
||||
for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"):
|
||||
try:
|
||||
shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling)
|
||||
except OSError as failure:
|
||||
|
||||
Reference in New Issue
Block a user