claude-session-backup 0.2.2__tar.gz → 0.3.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/PKG-INFO +62 -12
  2. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/README.md +61 -11
  3. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/_version.py +3 -3
  4. claude_session_backup-0.3.10/claude_session_backup/cli.py +539 -0
  5. claude_session_backup-0.3.10/claude_session_backup/commands.py +1533 -0
  6. claude_session_backup-0.3.10/claude_session_backup/config.py +267 -0
  7. claude_session_backup-0.3.10/claude_session_backup/fts5_db.py +305 -0
  8. claude_session_backup-0.3.10/claude_session_backup/fts5_importer.py +119 -0
  9. claude_session_backup-0.3.10/claude_session_backup/fts5_index.py +261 -0
  10. claude_session_backup-0.3.10/claude_session_backup/fts5_migrations.py +159 -0
  11. claude_session_backup-0.3.10/claude_session_backup/fts_paths.py +122 -0
  12. claude_session_backup-0.3.10/claude_session_backup/ids.py +305 -0
  13. claude_session_backup-0.3.10/claude_session_backup/index.py +718 -0
  14. claude_session_backup-0.3.10/claude_session_backup/lockfile.py +380 -0
  15. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/metadata.py +10 -12
  16. claude_session_backup-0.3.10/claude_session_backup/migrations.py +114 -0
  17. claude_session_backup-0.3.10/claude_session_backup/pathkit.py +307 -0
  18. claude_session_backup-0.3.10/claude_session_backup/search.py +1108 -0
  19. claude_session_backup-0.3.10/claude_session_backup/search_render.py +545 -0
  20. claude_session_backup-0.3.10/claude_session_backup/sesslog_parser.py +270 -0
  21. claude_session_backup-0.3.10/claude_session_backup/sesslog_scanner.py +142 -0
  22. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/timeline.py +127 -38
  23. claude_session_backup-0.3.10/claude_session_backup/transcript_walker.py +377 -0
  24. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup.egg-info/PKG-INFO +62 -12
  25. claude_session_backup-0.3.10/claude_session_backup.egg-info/SOURCES.txt +58 -0
  26. claude_session_backup-0.3.10/tests/test_backup_hook.py +228 -0
  27. claude_session_backup-0.3.10/tests/test_cli.py +636 -0
  28. claude_session_backup-0.3.10/tests/test_commands.py +643 -0
  29. claude_session_backup-0.3.10/tests/test_config.py +305 -0
  30. claude_session_backup-0.3.10/tests/test_fts5_db.py +404 -0
  31. claude_session_backup-0.3.10/tests/test_fts5_importer.py +399 -0
  32. claude_session_backup-0.3.10/tests/test_fts5_index.py +242 -0
  33. claude_session_backup-0.3.10/tests/test_fts5_migrations.py +288 -0
  34. claude_session_backup-0.3.10/tests/test_fts_paths.py +181 -0
  35. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/tests/test_hook.py +21 -14
  36. claude_session_backup-0.3.10/tests/test_ids.py +321 -0
  37. claude_session_backup-0.3.10/tests/test_index.py +721 -0
  38. claude_session_backup-0.3.10/tests/test_lockfile.py +310 -0
  39. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/tests/test_metadata.py +23 -1
  40. claude_session_backup-0.3.10/tests/test_migrations.py +279 -0
  41. claude_session_backup-0.3.10/tests/test_pathkit.py +504 -0
  42. claude_session_backup-0.3.10/tests/test_search.py +1937 -0
  43. claude_session_backup-0.3.10/tests/test_search_render.py +522 -0
  44. claude_session_backup-0.3.10/tests/test_session_sources.py +228 -0
  45. claude_session_backup-0.3.10/tests/test_sesslog_parser.py +321 -0
  46. claude_session_backup-0.3.10/tests/test_sesslog_scanner.py +217 -0
  47. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/tests/test_timeline.py +64 -0
  48. claude_session_backup-0.2.2/claude_session_backup/cli.py +0 -252
  49. claude_session_backup-0.2.2/claude_session_backup/commands.py +0 -526
  50. claude_session_backup-0.2.2/claude_session_backup/config.py +0 -108
  51. claude_session_backup-0.2.2/claude_session_backup/index.py +0 -364
  52. claude_session_backup-0.2.2/claude_session_backup/lockfile.py +0 -74
  53. claude_session_backup-0.2.2/claude_session_backup.egg-info/SOURCES.txt +0 -29
  54. claude_session_backup-0.2.2/tests/test_cli.py +0 -113
  55. claude_session_backup-0.2.2/tests/test_index.py +0 -214
  56. claude_session_backup-0.2.2/tests/test_lockfile.py +0 -62
  57. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/LICENSE +0 -0
  58. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/__init__.py +0 -0
  59. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/__main__.py +0 -0
  60. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/git_ops.py +0 -0
  61. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup/scanner.py +0 -0
  62. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup.egg-info/dependency_links.txt +0 -0
  63. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup.egg-info/entry_points.txt +0 -0
  64. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup.egg-info/requires.txt +0 -0
  65. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/claude_session_backup.egg-info/top_level.txt +0 -0
  66. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/pyproject.toml +0 -0
  67. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/setup.cfg +0 -0
  68. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/tests/test_scanner.py +0 -0
  69. {claude_session_backup-0.2.2 → claude_session_backup-0.3.10}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-session-backup
3
- Version: 0.2.2
3
+ Version: 0.3.10
4
4
  Summary: Git-backed Claude Code session backup with timeline view, folder analysis, deletion detection, and session restore.
5
5
  Author-email: djdarcy <6962246+djdarcy@users.noreply.github.com>
6
6
  License: GPL-3.0-or-later
@@ -47,13 +47,13 @@ Claude Code stores session data in `~/.claude/projects/` as JSONL files. These c
47
47
  **csb** preserves every session in your existing `~/.claude` git repository, builds a searchable metadata index, detects deletions, and can restore lost sessions from git history.
48
48
 
49
49
  > [!WARNING]
50
- > **Prealpha software.** `csb` is functional and all tests pass, but it is not yet feature-complete and has not been broadly tested outside of active dogfooding. Expect bugs, rough edges, and breaking changes until the first alpha/beta releases. Three items gate the next milestone: distilled conversation backup (#12), end-to-end restore verification (#13), and a CLI launcher for claude-code-history-viewer (#14). By all means use it -- and please file issues -- but don't rely on `csb` as your only backup just yet.
50
+ > **Prealpha software.** `csb` is functional and all tests pass, but it is not yet feature-complete and has not been broadly tested outside of active dogfooding. Expect bugs, rough edges, and breaking changes until the first alpha/beta releases. Three items gate the next milestone: distilled conversation backup ([#12](https://github.com/DazzleML/Claude-Session-Backup/issues/12)), end-to-end restore verification ([#13](https://github.com/DazzleML/Claude-Session-Backup/issues/13)), and a CLI launcher for claude-code-history-viewer ([#14](https://github.com/DazzleML/Claude-Session-Backup/issues/14)). By all means use it -- and please [file issues](https://github.com/DazzleML/Claude-Session-Backup/issues) -- but don't rely on `csb` as your only backup just yet.
51
51
 
52
52
  ## Quick Start
53
53
 
54
54
  ```bash
55
- # 1. Install the CLI (PyPI release coming shortly)
56
- pip install git+https://github.com/DazzleML/Claude-Session-Backup.git
55
+ # 1. Install the CLI
56
+ pip install claude-session-backup
57
57
 
58
58
  # 2. (recommended) Install the Claude Code plugin so pre-compact backups fire
59
59
  # automatically. Full commands in the "Claude Code Plugin" section below.
@@ -89,17 +89,54 @@ csb list [keyword] # Filter by keyword in name/project/folder
89
89
  csb list --sort expiration # Sort by soonest-to-purge first
90
90
  csb list --sort {last-used|expiration|started|oldest|messages|size}
91
91
  csb list --deleted # Show deleted sessions
92
- csb scan [path] # Find sessions touching this directory
93
- csb scan [path] -NU # Prefix-only match (skip folder-usage search)
92
+ csb scan # Find sessions touching cwd (path-prefix)
93
+ csb scan <term> # Filter by term: name, project, folder paths
94
+ csb scan ./<dirname> # Shortcut: same as -d <dirname> (no flag to remember)
95
+ csb scan -d <pattern> # Path-strict: folder + descendants
96
+ csb scan -D <pattern> # Path-strict: this folder only, no descendants
97
+ csb scan -s <pattern> # start_folder only ("what sessions originated here?")
98
+ csb scan -d <pattern> <term> # Scope-then-filter combined
99
+ csb scan -d <pattern>* / -D <pattern>* / -s <pattern>* # Trailing-* wildcard
100
+ csb scan ... -NU # Skip folder-usage search (start_folder only)
94
101
  csb status # Summary stats
95
102
  csb show <session-id> # Detailed session info with folder analysis
96
- csb search "query" # Search by session name, project, or folder
103
+ csb search "query" # Search transcript content (USER/AI/AGENT messages)
104
+ csb search -E "regex.*pattern" # Regex mode (Python re)
105
+ csb search "X" -C 3 # Show 3 events of context before AND after each hit
106
+ csb search "X" -A 5 -B 2 # Asymmetric context (5 after, 2 before)
107
+ csb search "X" --source convo # Force a source channel; auto = convo > sesslog > jsonl
108
+ csb search "X" --session <uuid> # Constrain to one session by UUID prefix
109
+ csb search "X" --json # NDJSON output for piping into jq
97
110
  csb restore <session-id> # Restore deleted session from git history
98
111
  csb resume <session-id> # Launch claude --resume with full UUID
99
112
  csb rebuild-index # Reconstruct SQLite from scratch
100
- csb config [key] [value] # View/edit configuration
113
+ csb config [key] [value] # View/edit csb's own configuration
114
+ csb config settings:cleanupPeriodDays # View Claude Code's session purge TTL
115
+ csb config settings:cleanupPeriodDays 365 # Set the TTL (writes ~/.claude/settings.json)
101
116
  ```
102
117
 
118
+ ### Searching conversations
119
+
120
+ Use `csb search` to find old sessions by **what was discussed**, not just by folder or name. The query is a case-insensitive literal substring by default; `-E` switches to Python regex.
121
+
122
+ ```bash
123
+ # Find every session where you talked about OAuth callbacks
124
+ csb search "oauth callback"
125
+
126
+ # Regex with context (3 events above and below each hit)
127
+ csb search -E "refresh.*token" -C 3
128
+
129
+ # Constrain to one session and one source channel
130
+ csb search "auth flow" --session 916441e6 --source convo
131
+
132
+ # Pipe results into another tool
133
+ csb search "rate limit" --json | jq -r '.session_id' | sort -u
134
+ ```
135
+
136
+ Per-session source preference is `.convo*` (preferred, USER/AI/AGENT-only) -> `.sesslog*` (filtered to USER/AI/AGENT) -> `<uuid>.jsonl` (authoritative fallback). New sessions logged by [claude-session-logger](https://github.com/DazzleML/claude-session-logger) get the cleanest `.convo*` source; older sessions fall through to JSONL automatically. Hits are sorted by session last-used time, so the most recent matches surface first.
137
+
138
+ For metadata search (folder paths, project, session name), use `csb list <filter>` or `csb scan <term>` -- those are the right tools for "find sessions in this folder" rather than "find sessions about this topic."
139
+
103
140
  ### Finding sessions at risk of purge
104
141
 
105
142
  Claude Code auto-deletes sessions after `cleanupPeriodDays` (default 30). To see which of your sessions are closest to being purged:
@@ -110,6 +147,19 @@ csb list --sort expiration -n 20
110
147
 
111
148
  Sessions are sorted by the JSONL file's modification time, so active sessions (which refresh their mtime on every interaction) stay safe while dormant sessions surface to the top of the expiration list.
112
149
 
150
+ To **view or change the TTL itself** without hand-editing `settings.json`:
151
+
152
+ ```bash
153
+ csb config settings:cleanupPeriodDays # show current value + source + guidance
154
+ csb config settings:cleanupPeriodDays 365 # keep transcripts for a year
155
+ csb config settings:cleanupPeriodDays 36500 # effectively never purge (~100 years)
156
+ ```
157
+
158
+ The `settings:` prefix is a fully-qualified namespace: a bare key (e.g. `csb config display_top_folders`) addresses csb's own config, while a `settings:` key addresses Claude Code's `~/.claude/settings.json` -- the two never collide. The write is a read-merge-write that preserves your other settings and refuses to touch a malformed file.
159
+
160
+ > [!CAUTION]
161
+ > `cleanupPeriodDays` of **`0` does not mean "keep forever"** -- Claude Code treats it as *disable session persistence* and deletes all transcripts at its next startup. csb refuses to write `0` without `--force`. For "never purge", set a large number instead.
162
+
113
163
  ## How It Works
114
164
 
115
165
  ```mermaid
@@ -197,16 +247,16 @@ schtasks /create /tn "Claude Session Backup" /tr "csb backup --quiet" /sc minute
197
247
  ## Installation
198
248
 
199
249
  ```bash
200
- # From GitHub (recommended until PyPI publish lands)
250
+ # From PyPI (recommended)
251
+ pip install claude-session-backup
252
+
253
+ # Latest unreleased build from GitHub
201
254
  pip install git+https://github.com/DazzleML/Claude-Session-Backup.git
202
255
 
203
256
  # From source (development / contributing)
204
257
  git clone https://github.com/DazzleML/Claude-Session-Backup.git
205
258
  cd Claude-Session-Backup
206
259
  pip install -e ".[dev]"
207
-
208
- # From PyPI (once published)
209
- pip install claude-session-backup
210
260
  ```
211
261
 
212
262
  ## Contributing
@@ -16,13 +16,13 @@ Claude Code stores session data in `~/.claude/projects/` as JSONL files. These c
16
16
  **csb** preserves every session in your existing `~/.claude` git repository, builds a searchable metadata index, detects deletions, and can restore lost sessions from git history.
17
17
 
18
18
  > [!WARNING]
19
- > **Prealpha software.** `csb` is functional and all tests pass, but it is not yet feature-complete and has not been broadly tested outside of active dogfooding. Expect bugs, rough edges, and breaking changes until the first alpha/beta releases. Three items gate the next milestone: distilled conversation backup (#12), end-to-end restore verification (#13), and a CLI launcher for claude-code-history-viewer (#14). By all means use it -- and please file issues -- but don't rely on `csb` as your only backup just yet.
19
+ > **Prealpha software.** `csb` is functional and all tests pass, but it is not yet feature-complete and has not been broadly tested outside of active dogfooding. Expect bugs, rough edges, and breaking changes until the first alpha/beta releases. Three items gate the next milestone: distilled conversation backup ([#12](https://github.com/DazzleML/Claude-Session-Backup/issues/12)), end-to-end restore verification ([#13](https://github.com/DazzleML/Claude-Session-Backup/issues/13)), and a CLI launcher for claude-code-history-viewer ([#14](https://github.com/DazzleML/Claude-Session-Backup/issues/14)). By all means use it -- and please [file issues](https://github.com/DazzleML/Claude-Session-Backup/issues) -- but don't rely on `csb` as your only backup just yet.
20
20
 
21
21
  ## Quick Start
22
22
 
23
23
  ```bash
24
- # 1. Install the CLI (PyPI release coming shortly)
25
- pip install git+https://github.com/DazzleML/Claude-Session-Backup.git
24
+ # 1. Install the CLI
25
+ pip install claude-session-backup
26
26
 
27
27
  # 2. (recommended) Install the Claude Code plugin so pre-compact backups fire
28
28
  # automatically. Full commands in the "Claude Code Plugin" section below.
@@ -58,17 +58,54 @@ csb list [keyword] # Filter by keyword in name/project/folder
58
58
  csb list --sort expiration # Sort by soonest-to-purge first
59
59
  csb list --sort {last-used|expiration|started|oldest|messages|size}
60
60
  csb list --deleted # Show deleted sessions
61
- csb scan [path] # Find sessions touching this directory
62
- csb scan [path] -NU # Prefix-only match (skip folder-usage search)
61
+ csb scan # Find sessions touching cwd (path-prefix)
62
+ csb scan <term> # Filter by term: name, project, folder paths
63
+ csb scan ./<dirname> # Shortcut: same as -d <dirname> (no flag to remember)
64
+ csb scan -d <pattern> # Path-strict: folder + descendants
65
+ csb scan -D <pattern> # Path-strict: this folder only, no descendants
66
+ csb scan -s <pattern> # start_folder only ("what sessions originated here?")
67
+ csb scan -d <pattern> <term> # Scope-then-filter combined
68
+ csb scan -d <pattern>* / -D <pattern>* / -s <pattern>* # Trailing-* wildcard
69
+ csb scan ... -NU # Skip folder-usage search (start_folder only)
63
70
  csb status # Summary stats
64
71
  csb show <session-id> # Detailed session info with folder analysis
65
- csb search "query" # Search by session name, project, or folder
72
+ csb search "query" # Search transcript content (USER/AI/AGENT messages)
73
+ csb search -E "regex.*pattern" # Regex mode (Python re)
74
+ csb search "X" -C 3 # Show 3 events of context before AND after each hit
75
+ csb search "X" -A 5 -B 2 # Asymmetric context (5 after, 2 before)
76
+ csb search "X" --source convo # Force a source channel; auto = convo > sesslog > jsonl
77
+ csb search "X" --session <uuid> # Constrain to one session by UUID prefix
78
+ csb search "X" --json # NDJSON output for piping into jq
66
79
  csb restore <session-id> # Restore deleted session from git history
67
80
  csb resume <session-id> # Launch claude --resume with full UUID
68
81
  csb rebuild-index # Reconstruct SQLite from scratch
69
- csb config [key] [value] # View/edit configuration
82
+ csb config [key] [value] # View/edit csb's own configuration
83
+ csb config settings:cleanupPeriodDays # View Claude Code's session purge TTL
84
+ csb config settings:cleanupPeriodDays 365 # Set the TTL (writes ~/.claude/settings.json)
70
85
  ```
71
86
 
87
+ ### Searching conversations
88
+
89
+ Use `csb search` to find old sessions by **what was discussed**, not just by folder or name. The query is a case-insensitive literal substring by default; `-E` switches to Python regex.
90
+
91
+ ```bash
92
+ # Find every session where you talked about OAuth callbacks
93
+ csb search "oauth callback"
94
+
95
+ # Regex with context (3 events above and below each hit)
96
+ csb search -E "refresh.*token" -C 3
97
+
98
+ # Constrain to one session and one source channel
99
+ csb search "auth flow" --session 916441e6 --source convo
100
+
101
+ # Pipe results into another tool
102
+ csb search "rate limit" --json | jq -r '.session_id' | sort -u
103
+ ```
104
+
105
+ Per-session source preference is `.convo*` (preferred, USER/AI/AGENT-only) -> `.sesslog*` (filtered to USER/AI/AGENT) -> `<uuid>.jsonl` (authoritative fallback). New sessions logged by [claude-session-logger](https://github.com/DazzleML/claude-session-logger) get the cleanest `.convo*` source; older sessions fall through to JSONL automatically. Hits are sorted by session last-used time, so the most recent matches surface first.
106
+
107
+ For metadata search (folder paths, project, session name), use `csb list <filter>` or `csb scan <term>` -- those are the right tools for "find sessions in this folder" rather than "find sessions about this topic."
108
+
72
109
  ### Finding sessions at risk of purge
73
110
 
74
111
  Claude Code auto-deletes sessions after `cleanupPeriodDays` (default 30). To see which of your sessions are closest to being purged:
@@ -79,6 +116,19 @@ csb list --sort expiration -n 20
79
116
 
80
117
  Sessions are sorted by the JSONL file's modification time, so active sessions (which refresh their mtime on every interaction) stay safe while dormant sessions surface to the top of the expiration list.
81
118
 
119
+ To **view or change the TTL itself** without hand-editing `settings.json`:
120
+
121
+ ```bash
122
+ csb config settings:cleanupPeriodDays # show current value + source + guidance
123
+ csb config settings:cleanupPeriodDays 365 # keep transcripts for a year
124
+ csb config settings:cleanupPeriodDays 36500 # effectively never purge (~100 years)
125
+ ```
126
+
127
+ The `settings:` prefix is a fully-qualified namespace: a bare key (e.g. `csb config display_top_folders`) addresses csb's own config, while a `settings:` key addresses Claude Code's `~/.claude/settings.json` -- the two never collide. The write is a read-merge-write that preserves your other settings and refuses to touch a malformed file.
128
+
129
+ > [!CAUTION]
130
+ > `cleanupPeriodDays` of **`0` does not mean "keep forever"** -- Claude Code treats it as *disable session persistence* and deletes all transcripts at its next startup. csb refuses to write `0` without `--force`. For "never purge", set a large number instead.
131
+
82
132
  ## How It Works
83
133
 
84
134
  ```mermaid
@@ -166,16 +216,16 @@ schtasks /create /tn "Claude Session Backup" /tr "csb backup --quiet" /sc minute
166
216
  ## Installation
167
217
 
168
218
  ```bash
169
- # From GitHub (recommended until PyPI publish lands)
219
+ # From PyPI (recommended)
220
+ pip install claude-session-backup
221
+
222
+ # Latest unreleased build from GitHub
170
223
  pip install git+https://github.com/DazzleML/Claude-Session-Backup.git
171
224
 
172
225
  # From source (development / contributing)
173
226
  git clone https://github.com/DazzleML/Claude-Session-Backup.git
174
227
  cd Claude-Session-Backup
175
228
  pip install -e ".[dev]"
176
-
177
- # From PyPI (once published)
178
- pip install claude-session-backup
179
229
  ```
180
230
 
181
231
  ## Contributing
@@ -14,14 +14,14 @@ To bump version: python scripts/sync-versions.py --bump patch
14
14
 
15
15
  # Version components - edit these for version bumps
16
16
  MAJOR = 0
17
- MINOR = 2
18
- PATCH = 2
17
+ MINOR = 3
18
+ PATCH = 10
19
19
  PHASE = "" # Per-MINOR feature set: None, "alpha", "beta", "rc1", etc.
20
20
  PRE_RELEASE_NUM = 1 # PEP 440 pre-release number (e.g., a1, b2)
21
21
  PROJECT_PHASE = "prealpha" # Project-wide: "prealpha", "alpha", "beta", "stable"
22
22
 
23
23
  # Auto-updated by git hooks - do not edit manually
24
- __version__ = "0.2.2"
24
+ __version__ = "0.3.10_main_29-20260530-e03e14cd"
25
25
  __app_name__ = "claude-session-backup"
26
26
 
27
27