Gather every Claude Code format loop-claude reads into claude_code.py, verified on 2.1.284
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import dataclasses
|
||||
import glob
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
@@ -7,6 +6,7 @@ import sys
|
||||
import uuid
|
||||
|
||||
from loop_claude.checkout import project_name
|
||||
from loop_claude.claude_code import session_files, transcript_path
|
||||
|
||||
NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
||||
|
||||
@@ -27,17 +27,14 @@ def session_for(root, paths):
|
||||
|
||||
|
||||
def transcript_file(session):
|
||||
# Where Claude Code 2.1.282 writes a session's transcript.
|
||||
hit = glob.glob(os.path.join(glob.escape(str(session.projects)), "*", f"{session.id}.jsonl"))
|
||||
return hit[0] if hit else ""
|
||||
return transcript_path(session.projects, session.id)
|
||||
|
||||
|
||||
def delete_session(session):
|
||||
path = transcript_file(session)
|
||||
if not path:
|
||||
return
|
||||
# Claude Code 2.1.282 also keeps a <id>/ folder and <id>.superseded-*/ and <id>.orphaned-*.jsonl siblings.
|
||||
for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"):
|
||||
for sibling in session_files(path):
|
||||
try:
|
||||
shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling)
|
||||
except OSError as failure:
|
||||
|
||||
Reference in New Issue
Block a user