Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/extract_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,21 @@ def edited_files(content):

def projects_dir_for(cwd):
"""Claude stores transcripts under ~/.claude/projects/<encoded-cwd>/,
where the cwd has every '/' and '.' replaced by '-'."""
where the cwd has every non-alphanumeric char replaced by '-'. This covers
POSIX ('/', '.', '_') and Windows ('\\', ':', drive letters) alike."""
home = os.path.expanduser("~")
encoded = re.sub(r"[/.]", "-", os.path.abspath(cwd))
return os.path.join(home, ".claude", "projects", encoded)
projects = os.path.join(home, ".claude", "projects")
encoded = re.sub(r"[^a-zA-Z0-9]", "-", os.path.abspath(cwd))
candidate = os.path.join(projects, encoded)
if os.path.isdir(candidate):
return candidate
# Fallback: case-insensitive match (e.g. Windows drive-letter casing,
# where abspath may yield 'C:' but the stored dir starts 'c-').
if os.path.isdir(projects):
for name in os.listdir(projects):
if name.lower() == encoded.lower():
return os.path.join(projects, name)
return candidate


def parse_session(path, tail):
Expand Down