trailback 0.1.0__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 (39) hide show
  1. trailback-0.1.0/.claude/settings.local.json +9 -0
  2. trailback-0.1.0/.gitignore +216 -0
  3. trailback-0.1.0/LICENSE +21 -0
  4. trailback-0.1.0/PKG-INFO +130 -0
  5. trailback-0.1.0/README.md +108 -0
  6. trailback-0.1.0/docs/ARCHITECTURE.md +27 -0
  7. trailback-0.1.0/docs/CLAUDE_FORMAT.md +108 -0
  8. trailback-0.1.0/docs/CLI.md +299 -0
  9. trailback-0.1.0/docs/CODEX_FORMAT.md +65 -0
  10. trailback-0.1.0/docs/DECISIONS.md +23 -0
  11. trailback-0.1.0/docs/GEMINI_FORMAT.md +83 -0
  12. trailback-0.1.0/docs/LMSTUDIO_FORMAT.md +132 -0
  13. trailback-0.1.0/docs/LOG_SYNC.md +62 -0
  14. trailback-0.1.0/docs/NAMING.md +64 -0
  15. trailback-0.1.0/docs/README.md +21 -0
  16. trailback-0.1.0/docs/SOURCES.md +77 -0
  17. trailback-0.1.0/docs/TODO.md +25 -0
  18. trailback-0.1.0/docs/TUI.md +62 -0
  19. trailback-0.1.0/docs/dev-plans/2025-10-codex-parser-and-usage.md +74 -0
  20. trailback-0.1.0/docs/dev-plans/2026-01-claude-session-format-investigation.md +210 -0
  21. trailback-0.1.0/docs/dev-plans/2026-01-gemini-adapter.md +24 -0
  22. trailback-0.1.0/docs/dev-plans/2026-01-session-layout-audit.md +25 -0
  23. trailback-0.1.0/docs/machines/rpi5-pipecat.md +56 -0
  24. trailback-0.1.0/pyproject.toml +36 -0
  25. trailback-0.1.0/scripts/com.trail.logs-sync.plist +40 -0
  26. trailback-0.1.0/scripts/sync-logs.sh +89 -0
  27. trailback-0.1.0/src/trailback/__init__.py +2 -0
  28. trailback-0.1.0/src/trailback/claude.py +280 -0
  29. trailback-0.1.0/src/trailback/cli.py +908 -0
  30. trailback-0.1.0/src/trailback/codex.py +506 -0
  31. trailback-0.1.0/src/trailback/config.py +98 -0
  32. trailback-0.1.0/src/trailback/gemini.py +360 -0
  33. trailback-0.1.0/src/trailback/lmstudio.py +321 -0
  34. trailback-0.1.0/src/trailback/model.py +61 -0
  35. trailback-0.1.0/src/trailback/todos.py +93 -0
  36. trailback-0.1.0/src/trailback/tokens.py +31 -0
  37. trailback-0.1.0/src/trailback/tui.py +1262 -0
  38. trailback-0.1.0/trail-claude.toml +4 -0
  39. trailback-0.1.0/uv.lock +395 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebFetch(domain:pypi.org)",
5
+ "Bash(curl:*)",
6
+ "Bash(git checkout:*)"
7
+ ]
8
+ }
9
+ }
@@ -0,0 +1,216 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Ruff stuff:
205
+ .ruff_cache/
206
+
207
+ # PyPI configuration file
208
+ .pypirc
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
214
+
215
+ # Streamlit
216
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Varun Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: trailback
3
+ Version: 0.1.0
4
+ Summary: Vendor-neutral CLI/TUI for browsing local agent logs
5
+ Project-URL: Homepage, https://trailback.dev
6
+ Project-URL: Repository, https://github.com/vr000m/trailback
7
+ Project-URL: Issues, https://github.com/vr000m/trailback/issues
8
+ Author: Varun Singh
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,claude,cli,codex,gemini,logs,tui
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: textual>=0.57.1
20
+ Requires-Dist: tiktoken>=0.7.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # trailback
24
+
25
+ Vendor-neutral CLI/TUI for browsing local agent logs.
26
+
27
+ > **Note:** The package is called `trailback` (`uv pip install trailback`), but the
28
+ > CLI command is `trail` — short to type, easy to remember. See
29
+ > [docs/NAMING.md](docs/NAMING.md) for background.
30
+
31
+ Current MVP supports Codex, Claude, and Gemini sessions for listing, viewing transcripts, and usage stats.
32
+
33
+ ## Install
34
+ Install the CLI as a `uv` tool so the `trail` executable is available from anywhere:
35
+
36
+ ```
37
+ uv tool install -e .
38
+ ```
39
+
40
+ Ensure the `uv` tool bin directory is on your `PATH` (usually `~/.local/bin`):
41
+
42
+ ```
43
+ export PATH="$HOME/.local/bin:$PATH"
44
+ ```
45
+
46
+ Verify:
47
+
48
+ ```
49
+ command -v trail
50
+ trail tui
51
+ ```
52
+
53
+ ## CLI
54
+ - `trail sources`
55
+ - `trail ls [--source codex] [--no-cwd]`
56
+ - `trail ls [--group] [--header] [--show-ids]`
57
+ - `trail open <session_id> [--source codex]`
58
+ - `trail open <group_id>`
59
+ - `trail stats [--source codex] [--format text|csv|json] [--period all|daily|monthly|yearly] [--no-header]`
60
+ - `trail tui`
61
+ - `trail init [--path PATH] [--force]`
62
+
63
+ ## Config
64
+ Use `~/.config/trail/config.toml` to add sources. Default Codex example:
65
+
66
+ ```
67
+ [sources.codex]
68
+ kind = "codex"
69
+ path = "~/.codex"
70
+ include = ["sessions/**/*.jsonl", "sessions/**/*.json"]
71
+ ```
72
+
73
+ Claude example:
74
+
75
+ ```
76
+ [sources.claude]
77
+ kind = "claude"
78
+ path = "~/.claude"
79
+ include = ["projects/**/*.jsonl"]
80
+ ```
81
+
82
+ Gemini example:
83
+
84
+ ```
85
+ [sources.gemini]
86
+ kind = "gemini"
87
+ path = "~/.gemini"
88
+ include = ["tmp/*/chats/session-*.json", "tmp/*/logs.json"]
89
+ ```
90
+
91
+ ## Log sync (multi-machine)
92
+
93
+ Use `scripts/sync-logs.sh` to sync logs from a secondary machine to a primary.
94
+ It is designed for one-way sync (secondary -> primary) and uses a quiet window
95
+ to avoid in-progress files.
96
+
97
+ Manual run:
98
+
99
+ ```
100
+ PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
101
+ ```
102
+
103
+ Dry run:
104
+
105
+ ```
106
+ DRY_RUN=1 PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
107
+ ```
108
+
109
+ Optional SSH options:
110
+
111
+ ```
112
+ SSH_OPTS="-i ~/.ssh/id_ed25519_trailsync -o StrictHostKeyChecking=accept-new" \
113
+ PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
114
+ ```
115
+
116
+ LaunchAgent example (runs every 6 hours):
117
+
118
+ ```
119
+ ~/Library/LaunchAgents/com.trail.logs-sync.plist
120
+ ```
121
+
122
+ Reload after edits:
123
+
124
+ ```
125
+ launchctl unload -w ~/Library/LaunchAgents/com.trail.logs-sync.plist 2>/dev/null || true
126
+ launchctl load -w ~/Library/LaunchAgents/com.trail.logs-sync.plist
127
+ launchctl kickstart -k gui/$(id -u)/com.trail.logs-sync
128
+ ```
129
+
130
+ For design details, see `docs/LOG_SYNC.md`.
@@ -0,0 +1,108 @@
1
+ # trailback
2
+
3
+ Vendor-neutral CLI/TUI for browsing local agent logs.
4
+
5
+ > **Note:** The package is called `trailback` (`uv pip install trailback`), but the
6
+ > CLI command is `trail` — short to type, easy to remember. See
7
+ > [docs/NAMING.md](docs/NAMING.md) for background.
8
+
9
+ Current MVP supports Codex, Claude, and Gemini sessions for listing, viewing transcripts, and usage stats.
10
+
11
+ ## Install
12
+ Install the CLI as a `uv` tool so the `trail` executable is available from anywhere:
13
+
14
+ ```
15
+ uv tool install -e .
16
+ ```
17
+
18
+ Ensure the `uv` tool bin directory is on your `PATH` (usually `~/.local/bin`):
19
+
20
+ ```
21
+ export PATH="$HOME/.local/bin:$PATH"
22
+ ```
23
+
24
+ Verify:
25
+
26
+ ```
27
+ command -v trail
28
+ trail tui
29
+ ```
30
+
31
+ ## CLI
32
+ - `trail sources`
33
+ - `trail ls [--source codex] [--no-cwd]`
34
+ - `trail ls [--group] [--header] [--show-ids]`
35
+ - `trail open <session_id> [--source codex]`
36
+ - `trail open <group_id>`
37
+ - `trail stats [--source codex] [--format text|csv|json] [--period all|daily|monthly|yearly] [--no-header]`
38
+ - `trail tui`
39
+ - `trail init [--path PATH] [--force]`
40
+
41
+ ## Config
42
+ Use `~/.config/trail/config.toml` to add sources. Default Codex example:
43
+
44
+ ```
45
+ [sources.codex]
46
+ kind = "codex"
47
+ path = "~/.codex"
48
+ include = ["sessions/**/*.jsonl", "sessions/**/*.json"]
49
+ ```
50
+
51
+ Claude example:
52
+
53
+ ```
54
+ [sources.claude]
55
+ kind = "claude"
56
+ path = "~/.claude"
57
+ include = ["projects/**/*.jsonl"]
58
+ ```
59
+
60
+ Gemini example:
61
+
62
+ ```
63
+ [sources.gemini]
64
+ kind = "gemini"
65
+ path = "~/.gemini"
66
+ include = ["tmp/*/chats/session-*.json", "tmp/*/logs.json"]
67
+ ```
68
+
69
+ ## Log sync (multi-machine)
70
+
71
+ Use `scripts/sync-logs.sh` to sync logs from a secondary machine to a primary.
72
+ It is designed for one-way sync (secondary -> primary) and uses a quiet window
73
+ to avoid in-progress files.
74
+
75
+ Manual run:
76
+
77
+ ```
78
+ PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
79
+ ```
80
+
81
+ Dry run:
82
+
83
+ ```
84
+ DRY_RUN=1 PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
85
+ ```
86
+
87
+ Optional SSH options:
88
+
89
+ ```
90
+ SSH_OPTS="-i ~/.ssh/id_ed25519_trailsync -o StrictHostKeyChecking=accept-new" \
91
+ PRIMARY_USER=vr000m PRIMARY_HOST=trail-primary ./scripts/sync-logs.sh
92
+ ```
93
+
94
+ LaunchAgent example (runs every 6 hours):
95
+
96
+ ```
97
+ ~/Library/LaunchAgents/com.trail.logs-sync.plist
98
+ ```
99
+
100
+ Reload after edits:
101
+
102
+ ```
103
+ launchctl unload -w ~/Library/LaunchAgents/com.trail.logs-sync.plist 2>/dev/null || true
104
+ launchctl load -w ~/Library/LaunchAgents/com.trail.logs-sync.plist
105
+ launchctl kickstart -k gui/$(id -u)/com.trail.logs-sync
106
+ ```
107
+
108
+ For design details, see `docs/LOG_SYNC.md`.
@@ -0,0 +1,27 @@
1
+ # Architecture
2
+
3
+ ## Overview
4
+ Trail is a vendor-neutral CLI/TUI for browsing local agent logs. Providers are added via source adapters that normalize raw log entries into a shared event model.
5
+
6
+ ## Current scope (MVP)
7
+ - Provider: Codex, Claude
8
+ - CLI: list sessions, open a session, usage stats
9
+ - Usage: aggregate usage from logs when present + estimate tokens via tokenizer
10
+
11
+ ## Proposed layering
12
+ - cli.py: argument parsing and command handlers
13
+ - config.py: config loading with default sources
14
+ - codex.py: adapter for Codex JSONL sessions
15
+ - model.py: shared data structures
16
+ - tokens.py: tokenizer utilities
17
+
18
+ ## Adapter responsibilities
19
+ - Read provider log files and normalize into Event objects
20
+ - Extract metadata: timestamps, role, content, model, usage
21
+ - Provide a stable Session view (title, started_at, usage totals)
22
+
23
+ ## Future extensions
24
+ - Additional adapters: Claude, Gemini
25
+ - Indexing: SQLite/DuckDB for fast search
26
+ - Exporters: Markdown/HTML/JSON
27
+ - TUI: Textual, 2-3 pane explorer
@@ -0,0 +1,108 @@
1
+ # Claude Formats
2
+
3
+ This document captures on-disk layout and JSONL schema details observed in Claude Code v2.0.x.
4
+
5
+ ## Directory structure
6
+
7
+ ```
8
+ ~/.claude/
9
+ ├── projects/ # Session transcripts (current format)
10
+ │ └── -Users-username-path.../ # Escaped project path as directory name
11
+ │ ├── <uuid>.jsonl # Main session files
12
+ │ └── agent-<hash>.jsonl # Agent/subagent session files
13
+ ├── todos/ # Todo snapshots (JSON, not JSONL)
14
+ │ └── <uuid>-agent-<uuid>.json # JSON arrays with todo items
15
+ ├── history.jsonl # Command/prompt history
16
+ ├── debug/ # Debug logs (.txt files)
17
+ ├── plans/ # Plan data (currently empty)
18
+ ├── session-env/ # Session environment snapshots
19
+ ├── shell-snapshots/ # Shell environment snapshots
20
+ ├── settings.json # User settings
21
+ ├── statsig/ # Feature flag cache
22
+ ├── local/ # Local installation (npm package)
23
+ ├── plugins/ # Plugin data and marketplaces
24
+ └── ide/ # IDE integration data
25
+ ```
26
+
27
+ Root-level files:
28
+ - `~/.claude.json` - Project metadata (allowed tools, MCP servers, onboarding state)
29
+
30
+ ## Session JSONL format
31
+
32
+ Each line is a JSON object:
33
+
34
+ ```json
35
+ {
36
+ "type": "user" | "assistant",
37
+ "parentUuid": "<uuid>",
38
+ "isSidechain": false,
39
+ "userType": "external",
40
+ "cwd": "/path/to/project",
41
+ "sessionId": "<uuid>",
42
+ "version": "2.0.76",
43
+ "gitBranch": "main",
44
+ "message": {
45
+ "role": "user" | "assistant",
46
+ "content": "string" | [{"type": "text", "text": "..."}, ...],
47
+ "model": "claude-sonnet-4-5-20250929",
48
+ "usage": {
49
+ "input_tokens": 1234,
50
+ "output_tokens": 5678,
51
+ "cache_creation_input_tokens": 0,
52
+ "cache_read_input_tokens": 0
53
+ }
54
+ },
55
+ "uuid": "<uuid>",
56
+ "timestamp": "2026-01-01T18:26:23.403Z"
57
+ }
58
+ ```
59
+
60
+ Agent sessions include additional fields:
61
+ - `agentId`: Short hash identifying the agent
62
+ - `isSidechain`: true for agent sessions
63
+
64
+ Special event types:
65
+ - `type: "summary"` - Session summary with `leafUuid`
66
+ - `type: "file-history-snapshot"` - File tracking data (filtered out by Trail)
67
+
68
+ ## Todos format (JSON, not JSONL)
69
+
70
+ Files in `~/.claude/todos/` are JSON arrays:
71
+
72
+ ```json
73
+ [
74
+ {"content": "Task description", "status": "completed", "priority": "high", "id": "1"},
75
+ {"content": "Another task", "status": "pending", "priority": "medium", "id": "2"}
76
+ ]
77
+ ```
78
+
79
+ File naming: `<sessionId>-agent-<sessionId>.json` or `<sessionId>.json`
80
+
81
+ ## History format
82
+
83
+ `~/.claude/history.jsonl` stores command history:
84
+
85
+ ```json
86
+ {"display": "user prompt text", "pastedContents": {}, "timestamp": 1767298415108, "project": "/path", "sessionId": "<uuid>"}
87
+ ```
88
+
89
+ ## Known issues / format changes
90
+
91
+ Missing old sessions (pre-Dec 2025):
92
+ - Observed: `todos/` files exist from May-Oct 2025, but corresponding session JSONL files are missing
93
+ - The `projects/` directory only contains recent sessions
94
+ - Hypothesis: Claude Code changed session storage format at some point
95
+ - Old sessions may have been stored differently (in memory, different location, or ephemeral)
96
+ - The todos were persisted separately and survived, but session transcripts did not
97
+
98
+ ## Trail support
99
+
100
+ - Reads: `projects/**/*.jsonl`, `todos/*.json`
101
+ - Does NOT read: `history.jsonl`
102
+
103
+ ## Notes
104
+
105
+ - JSONL messages store per-message usage; we sum usage across the session
106
+ - Multiple files may belong to the same session (grouped by `sessionId`)
107
+ - Agent sessions (`agent-*.jsonl`) are treated as subsessions of the main session
108
+ - Cache tokens (creation + read) are added to input_tokens for accurate totals