Skip to content

Conversation

@dpatou
Copy link
Owner

@dpatou dpatou commented Dec 28, 2025

Summary

This PR adds two new options to the all command to support managing transcript archives across multiple machines:

  • --merge / -m: Preserves existing sessions in the output directory when regenerating. Sessions from the source are regenerated, while sessions only present in the existing archive are kept in the index.

  • --prefix: Adds a prefix label to sessions (displayed as [prefix] in the index). Useful for identifying which machine generated each session.

Use case

When using Claude Code on multiple machines, each machine has its own ~/.claude/projects/ folder. Without --merge, regenerating the archive from one machine would overwrite sessions from other machines.

With these options, you can:

# On machine A
claude-code-transcripts all --merge --prefix=laptop -o /shared/archive/

# On machine B  
claude-code-transcripts all --merge --prefix=desktop -o /shared/archive/

Each run preserves sessions from other machines while regenerating local sessions with a machine identifier.

Changes

  • Added find_existing_sessions() function to parse existing archive's project_index.html
  • Added merge_sessions() function to combine source and existing sessions
  • Modified generate_batch_html() to support merge and prefix parameters
  • Updated project_index.html template to display prefix labels
  • Added comprehensive tests for all new functionality
  • Updated README.md with documentation

Test plan

  • Unit tests pass (uv run pytest)
  • Manual testing with real session files
  • Verified prefix display in generated HTML
  • Verified merge preserves orphaned sessions

…chives

When running 'all' from multiple machines, the --merge option allows
preserving existing sessions in the archive that are no longer in the
source directory.

New features:
- find_existing_sessions(): Scan existing archive to discover sessions
- merge_sessions(): Merge source sessions with existing archive
- --merge (-m): Enable merge mode for 'all' command
- --prefix: Add a label to sessions in the index (e.g., machine name)

This enables maintaining a unified archive from multiple machines by:
1. Regenerating all sessions found in source
2. Preserving "orphan" sessions that only exist in the archive
3. Optional prefix to identify session origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants