lastword-cc 0.1.1__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.
- lastword_cc-0.1.1/LICENSE +21 -0
- lastword_cc-0.1.1/MANIFEST.in +14 -0
- lastword_cc-0.1.1/PKG-INFO +265 -0
- lastword_cc-0.1.1/README.md +243 -0
- lastword_cc-0.1.1/lastword/__init__.py +10 -0
- lastword_cc-0.1.1/lastword/__main__.py +5 -0
- lastword_cc-0.1.1/lastword/cli.py +638 -0
- lastword_cc-0.1.1/lastword/demo.py +335 -0
- lastword_cc-0.1.1/lastword/extract.py +169 -0
- lastword_cc-0.1.1/lastword/home.py +155 -0
- lastword_cc-0.1.1/lastword/hook.py +271 -0
- lastword_cc-0.1.1/lastword/indexer.py +533 -0
- lastword_cc-0.1.1/lastword/manifest.py +146 -0
- lastword_cc-0.1.1/lastword/markdown_lite.py +244 -0
- lastword_cc-0.1.1/lastword/models.py +131 -0
- lastword_cc-0.1.1/lastword/parser.py +255 -0
- lastword_cc-0.1.1/lastword/projects.py +314 -0
- lastword_cc-0.1.1/lastword/render_html.py +423 -0
- lastword_cc-0.1.1/lastword/render_markdown.py +128 -0
- lastword_cc-0.1.1/lastword/reports.py +149 -0
- lastword_cc-0.1.1/lastword/scanner.py +38 -0
- lastword_cc-0.1.1/lastword/store.py +152 -0
- lastword_cc-0.1.1/lastword/theme.py +270 -0
- lastword_cc-0.1.1/lastword/timeline.py +90 -0
- lastword_cc-0.1.1/lastword/util.py +141 -0
- lastword_cc-0.1.1/lastword_cc.egg-info/PKG-INFO +265 -0
- lastword_cc-0.1.1/lastword_cc.egg-info/SOURCES.txt +34 -0
- lastword_cc-0.1.1/lastword_cc.egg-info/dependency_links.txt +1 -0
- lastword_cc-0.1.1/lastword_cc.egg-info/entry_points.txt +2 -0
- lastword_cc-0.1.1/lastword_cc.egg-info/top_level.txt +1 -0
- lastword_cc-0.1.1/pyproject.toml +38 -0
- lastword_cc-0.1.1/setup.cfg +4 -0
- lastword_cc-0.1.1/tests/__init__.py +0 -0
- lastword_cc-0.1.1/tests/test_archive.py +378 -0
- lastword_cc-0.1.1/tests/test_hook.py +171 -0
- lastword_cc-0.1.1/tools/make_demo.py +37 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kxzongoing
|
|
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,14 @@
|
|
|
1
|
+
# The checkout may hold a real archive of private transcripts. Keep every
|
|
2
|
+
# path the exporter writes out of the source distribution, explicitly.
|
|
3
|
+
prune sessions
|
|
4
|
+
prune index
|
|
5
|
+
prune extracts
|
|
6
|
+
prune timeline
|
|
7
|
+
prune docs/demo
|
|
8
|
+
exclude index.html manifest.json manifest.json.tmp manifest.v*.bak.json
|
|
9
|
+
exclude project_aliases.json project_aliases.json.tmp .lastword.lock
|
|
10
|
+
exclude replicate_prompt.md
|
|
11
|
+
|
|
12
|
+
include LICENSE README.md
|
|
13
|
+
recursive-include tests *.py
|
|
14
|
+
recursive-include tools *.py
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lastword-cc
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A permanent, browsable archive of your Claude Code session transcripts, before they're deleted.
|
|
5
|
+
Author: kxzongoing
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/kxzongoing/lastword
|
|
8
|
+
Project-URL: Issues, https://github.com/kxzongoing/lastword/issues
|
|
9
|
+
Keywords: claude,claude-code,transcripts,archive,backup,cli
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Topic :: System :: Archiving :: Backup
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/banner.svg" alt="lastword" width="100%">
|
|
26
|
+
|
|
27
|
+
<br>
|
|
28
|
+
|
|
29
|
+
**Claude Code deletes your session transcripts after 30 days.**<br>
|
|
30
|
+
**This archives them permanently — and makes them beautiful to read.**
|
|
31
|
+
|
|
32
|
+
<br>
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+

|
|
37
|
+

|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 😱 The problem
|
|
45
|
+
|
|
46
|
+
Claude Code writes every conversation to `~/.claude/projects/*.jsonl`, then **silently deletes anything older than `cleanupPeriodDays` — which defaults to 30.**
|
|
47
|
+
|
|
48
|
+
That research session where you finally cracked the architecture? The debugging marathon with the fix you'd never reconstruct? Gone, with no warning and no undo.
|
|
49
|
+
|
|
50
|
+
## ✨ The fix
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv tool install lastword-cc # or: pipx install lastword-cc
|
|
54
|
+
lastword # archive everything Claude Code still has
|
|
55
|
+
lastword open # browse it
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
That's the whole setup — Python 3.9+, zero dependencies, zero network calls. The package is `lastword-cc` (cc for Claude Code); the command it installs is `lastword`. Want to try it without installing? `uvx --from lastword-cc lastword`. Upgrade later with `uv tool upgrade lastword-cc`.
|
|
59
|
+
|
|
60
|
+
Every later run picks up what's new and leaves the rest alone. **Once a conversation is archived, it stays — even after Claude Code deletes the original.**
|
|
61
|
+
|
|
62
|
+
## 👀 See it before you run it
|
|
63
|
+
|
|
64
|
+
Don't want to point it at your own chats yet? Build a demo archive from invented transcripts:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
lastword demo --open
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
That builds eight fictional sessions in a temp folder, rendered by the **same code** that renders a real archive. Nothing in it touches `~/.claude`. It's also the right way to grab screenshots or check a UI change without exposing your own work.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🖥️ What you get
|
|
75
|
+
|
|
76
|
+
<div align="center">
|
|
77
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/screenshot-browser.png" alt="Session browser" width="100%">
|
|
78
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/screenshot-search.png" alt="Full-text search" width="100%">
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
### 📚 A browser for everything
|
|
82
|
+
|
|
83
|
+
Run `lastword open` for a two-pane reader: sessions grouped by **Today / Yesterday / Earlier this week**, live filtering, and full keyboard navigation — <kbd>/</kbd> to search, <kbd>↑</kbd><kbd>↓</kbd> or <kbd>j</kbd><kbd>k</kbd> to move, <kbd>Esc</kbd> to clear. Light and dark themes, remembered between visits.
|
|
84
|
+
|
|
85
|
+
### 💬 Conversations that read like conversations
|
|
86
|
+
|
|
87
|
+
Messages render as **actual prose** — headings, lists, tables, and syntax-styled code — not walls of preformatted text. Three lanes stay visually distinct so you always know who said what:
|
|
88
|
+
|
|
89
|
+
| Lane | Appearance |
|
|
90
|
+
| ------------- | ------------------------------------------------------------------------ |
|
|
91
|
+
| 🧑 **You** | Filled card with an accent border — the thing you scan for |
|
|
92
|
+
| 🤖 **Claude** | Clean prose, unadorned |
|
|
93
|
+
| ⚙️ **Tools** | Muted monospace folds, collapsed by default, each showing its own output |
|
|
94
|
+
|
|
95
|
+
Tool results are nested **inside the call that produced them** — so a 500-turn session scans in seconds, and nothing machine-generated is ever mislabelled as something you typed.
|
|
96
|
+
|
|
97
|
+
### 🔍 Search that actually finds things
|
|
98
|
+
|
|
99
|
+
`index/search.html` does instant client-side search across every turn, bash command and file edit — filter by type, jump straight to the moment in the conversation. No server, no index to build.
|
|
100
|
+
|
|
101
|
+
### 📦 Plain files underneath
|
|
102
|
+
|
|
103
|
+
Everything is JSON and Markdown you can grep, diff, or feed to other tools. Paths are relative to the archive home (`lastword where`):
|
|
104
|
+
|
|
105
|
+
| Path | Contents |
|
|
106
|
+
| -------------------------------------------- | ----------------------------------------------------- |
|
|
107
|
+
| `sessions/<project>/<id>/` | `source.jsonl`, `conversation.md`, `conversation.html` |
|
|
108
|
+
| `index/session_index.{json,md}` | One row per session — title, project, duration, links |
|
|
109
|
+
| `extracts/tool_invocations.{json,md}` | Every tool call, matched with its result |
|
|
110
|
+
| `extracts/file_modifications.{json,md}` | Every Edit / Write / MultiEdit / NotebookEdit |
|
|
111
|
+
| `extracts/bash_commands.{json,md}` | Every Bash call with stdout and stderr |
|
|
112
|
+
| `extracts/architectural_decisions.{json,md}` | Heuristically surfaced decision points |
|
|
113
|
+
| `timeline/timeline.{json,md}` | All of the above, merged and sorted by date |
|
|
114
|
+
|
|
115
|
+
`source.jsonl` is a **byte-for-byte copy** of Claude Code's transcript, the archive of record; everything else is rebuilt from it. Session UUIDs and original timestamps survive everywhere — filenames, table rows, HTML anchors.
|
|
116
|
+
|
|
117
|
+
> **Note** — `architectural_decisions` is a heuristic (plan proposals, `AskUserQuestion` points, decision language). Read it for signal, not as a curated list.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🛡️ Stop losing chats in the first place
|
|
122
|
+
|
|
123
|
+
Before anything else, widen Claude Code's retention window in `~/.claude/settings.json`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"cleanupPeriodDays": 365
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This tool can only archive what still exists when it runs. A year of retention buys you margin; archiving automatically closes the gap completely.
|
|
132
|
+
|
|
133
|
+
**Archive every session as it ends:**
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
lastword hook install # adds a SessionEnd hook to ~/.claude/settings.json
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
When a session ends — you exit, `/clear`, or `/resume` another — Claude Code runs `lastword hook run`, which starts an archive run in the background and returns at once, so ending a session never waits on it. Your other settings are left exactly as they were (a backup is saved as `settings.json.lastword-backup`). `lastword hook status` shows the hook and its log (`hook.log` in the archive home); `lastword hook uninstall` removes it. Install lastword as a command first (`uv tool install` / `pipx install`): the hook runs it from whatever project you were in.
|
|
140
|
+
|
|
141
|
+
**And as a backstop, a daily run.** The hook doesn't fire if a terminal is killed or Claude Code crashes, so schedule one too:
|
|
142
|
+
|
|
143
|
+
**macOS / Linux** — `crontab -e` (cron has a minimal `PATH`, so give the full path from `which lastword`):
|
|
144
|
+
|
|
145
|
+
```cron
|
|
146
|
+
0 20 * * * $HOME/.local/bin/lastword --quiet
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Windows** — Task Scheduler → daily → `lastword --quiet`.
|
|
150
|
+
|
|
151
|
+
`lastword` exits non-zero if any session failed to archive, so a scheduler that alerts on failure will tell you. Two runs that overlap don't collide: the second waits for the first.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## ♻️ Already lost chats? Maybe not.
|
|
156
|
+
|
|
157
|
+
If you archived sessions before and they've vanished from your index, **they are probably still on disk.** Earlier versions rebuilt the index only from live sources, so pruned sessions dropped out even though `sessions/` still held every byte.
|
|
158
|
+
|
|
159
|
+
Just run it again:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
lastword
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The backfill pass replays every session in `manifest.json` from its archived copy:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
Sessions found: 23 | archived: 2 | unchanged: 21 | restored from archive: 28 | pages rendered: 2 | failed: 0
|
|
169
|
+
Total sessions in index: 51
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
As long as `manifest.json` and `sessions/` survive, nothing is lost.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 🚚 Renamed or moved a project?
|
|
177
|
+
|
|
178
|
+
Claude Code files sessions under the project's folder path, so renaming the folder splits its history in two: old sessions stay under the old name, new ones start under the new one. Join them back up:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
lastword move-project ~/code/old-name ~/code/new-name --dry-run # preview
|
|
182
|
+
lastword move-project ~/code/old-name ~/code/new-name
|
|
183
|
+
lastword
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This moves the old sessions to the new name both in `~/.claude/projects` (so `claude --resume` finds them from the new folder) and in your archive, and from then on shows the old path as the new one in the index, search and timeline. Your transcripts are never rewritten; `source.jsonl` keeps the paths exactly as they were recorded.
|
|
187
|
+
|
|
188
|
+
Close any Claude Code session still running in the old folder first. `move-project` refuses to run while one is running, and stops without changing anything if a file at the new name would be overwritten. If a session was open during the move anyway, Claude Code writes a few closing records back to the old folder when it exits; run `move-project` again and it recognises that stub and clears it away, since everything in it is already in the moved copy. Pass `--archive-only` to leave `~/.claude/projects` alone.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 🏠 Where your archive lives
|
|
193
|
+
|
|
194
|
+
By default in **`~/.lastword`**, private to your user (`700`). `lastword where` prints it; to put it elsewhere, pass `--home DIR` or set `LASTWORD_HOME`. Avoid folders that sync to the cloud (Documents or Desktop with iCloud or OneDrive): the archive holds everything you pasted into a session.
|
|
195
|
+
|
|
196
|
+
**Archived into a git checkout before 0.1?** Nothing breaks: run from inside a folder that already holds an archive, lastword keeps using it. To move it to the standard place:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
lastword migrate --from /path/to/lastword # copies to ~/.lastword and checks every byte
|
|
200
|
+
lastword && lastword verify
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The old copy is left untouched until you delete it. The first run on an archive from before 0.1 upgrades it in place, keeping the original manifest as `manifest.v0.bak.json`.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## ⚙️ Commands
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
lastword [archive] Archive new and changed sessions (the default)
|
|
211
|
+
--root DIR Claude Code projects dir (default: ~/.claude/projects)
|
|
212
|
+
--project SUBSTR Only process project dirs matching a substring
|
|
213
|
+
--force Re-render every session's pages
|
|
214
|
+
--quiet / --json Print nothing but problems / print counts as JSON
|
|
215
|
+
--wait SECONDS How long to wait for another run to finish (default: 60)
|
|
216
|
+
lastword open Open the session browser
|
|
217
|
+
lastword where Print the archive's location
|
|
218
|
+
lastword verify Check every archived transcript against its checksum
|
|
219
|
+
lastword migrate --from DIR Copy an existing archive to the archive home
|
|
220
|
+
lastword move-project OLD NEW Join a renamed project's sessions (see above)
|
|
221
|
+
lastword hook install Archive each session when it ends (also: uninstall, status)
|
|
222
|
+
lastword demo [--open] Build a demo archive from invented sessions
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Every command takes `--home DIR`. Exit codes: `0` success, `1` something failed (details on stderr), `2` bad usage.
|
|
226
|
+
|
|
227
|
+
**Stability:** until 1.0, the commands above and the archive layout (`sessions/`, `manifest.json`) are stable — a newer lastword always upgrades an older archive, and an older lastword refuses a newer archive rather than damage it. The JSON layouts under `extracts/`, `index/` and `timeline/` may still change.
|
|
228
|
+
|
|
229
|
+
## 🔒 How it stays safe
|
|
230
|
+
|
|
231
|
+
**Byte-exact** — each transcript is copied verbatim to `source.jsonl`, with its sha256 in `manifest.json`. `lastword verify` re-checks every one.
|
|
232
|
+
|
|
233
|
+
**Never overwritten** — Claude Code only appends to a transcript, so a new snapshot replaces the old one only if it starts with every byte of it. If a transcript is ever rewritten instead, the earlier copy is kept alongside.
|
|
234
|
+
|
|
235
|
+
**Append-only** — aggregates rebuild from the union of live sources **and** every session in the manifest, replayed from its archived copy. Claude Code's prune can't remove anything from your index.
|
|
236
|
+
|
|
237
|
+
**Crash-safe** — every file is written to a temp file and renamed into place, and overlapping runs take turns, so an interrupted run never leaves a half-written archive.
|
|
238
|
+
|
|
239
|
+
**Local** — reads `~/.claude/projects`, writes to disk. No network, no telemetry, no dependencies. Transcript text is escaped before rendering, and `javascript:` URLs are stripped.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 🚨 Privacy — read this before pushing anywhere
|
|
244
|
+
|
|
245
|
+
**Your exported conversations are private. Never commit them.**
|
|
246
|
+
|
|
247
|
+
The archive holds whatever you discussed with Claude: proprietary source, file paths, customer data, credentials pasted into prompts. Keep it out of any repository. If you still archive into a git checkout, its bundled `.gitignore` excludes every path the exporter writes, so a fork stays code-only. Before your first push:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
git status --porcelain # should list source files only
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
To back up the archive itself, use a **private** repo or ordinary file backup — never a public one.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 🤝 Contributing
|
|
258
|
+
|
|
259
|
+
Issues and PRs welcome. Run the tests with `python3 -m unittest` — they build invented transcripts and never touch your own. For screenshots or UI checks, `python3 tools/make_demo.py` rebuilds `docs/demo/`. Please never paste real transcript content into a bug report — a redacted snippet or the structure alone is plenty.
|
|
260
|
+
|
|
261
|
+
## 📄 License
|
|
262
|
+
|
|
263
|
+
MIT — see [LICENSE](LICENSE).
|
|
264
|
+
|
|
265
|
+
<div align="center"><br><sub>Your conversations are work. Keep them.</sub></div>
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/banner.svg" alt="lastword" width="100%">
|
|
4
|
+
|
|
5
|
+
<br>
|
|
6
|
+
|
|
7
|
+
**Claude Code deletes your session transcripts after 30 days.**<br>
|
|
8
|
+
**This archives them permanently — and makes them beautiful to read.**
|
|
9
|
+
|
|
10
|
+
<br>
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 😱 The problem
|
|
23
|
+
|
|
24
|
+
Claude Code writes every conversation to `~/.claude/projects/*.jsonl`, then **silently deletes anything older than `cleanupPeriodDays` — which defaults to 30.**
|
|
25
|
+
|
|
26
|
+
That research session where you finally cracked the architecture? The debugging marathon with the fix you'd never reconstruct? Gone, with no warning and no undo.
|
|
27
|
+
|
|
28
|
+
## ✨ The fix
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv tool install lastword-cc # or: pipx install lastword-cc
|
|
32
|
+
lastword # archive everything Claude Code still has
|
|
33
|
+
lastword open # browse it
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's the whole setup — Python 3.9+, zero dependencies, zero network calls. The package is `lastword-cc` (cc for Claude Code); the command it installs is `lastword`. Want to try it without installing? `uvx --from lastword-cc lastword`. Upgrade later with `uv tool upgrade lastword-cc`.
|
|
37
|
+
|
|
38
|
+
Every later run picks up what's new and leaves the rest alone. **Once a conversation is archived, it stays — even after Claude Code deletes the original.**
|
|
39
|
+
|
|
40
|
+
## 👀 See it before you run it
|
|
41
|
+
|
|
42
|
+
Don't want to point it at your own chats yet? Build a demo archive from invented transcripts:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
lastword demo --open
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
That builds eight fictional sessions in a temp folder, rendered by the **same code** that renders a real archive. Nothing in it touches `~/.claude`. It's also the right way to grab screenshots or check a UI change without exposing your own work.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 🖥️ What you get
|
|
53
|
+
|
|
54
|
+
<div align="center">
|
|
55
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/screenshot-browser.png" alt="Session browser" width="100%">
|
|
56
|
+
<img src="https://raw.githubusercontent.com/kxzongoing/lastword/main/docs/screenshot-search.png" alt="Full-text search" width="100%">
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
### 📚 A browser for everything
|
|
60
|
+
|
|
61
|
+
Run `lastword open` for a two-pane reader: sessions grouped by **Today / Yesterday / Earlier this week**, live filtering, and full keyboard navigation — <kbd>/</kbd> to search, <kbd>↑</kbd><kbd>↓</kbd> or <kbd>j</kbd><kbd>k</kbd> to move, <kbd>Esc</kbd> to clear. Light and dark themes, remembered between visits.
|
|
62
|
+
|
|
63
|
+
### 💬 Conversations that read like conversations
|
|
64
|
+
|
|
65
|
+
Messages render as **actual prose** — headings, lists, tables, and syntax-styled code — not walls of preformatted text. Three lanes stay visually distinct so you always know who said what:
|
|
66
|
+
|
|
67
|
+
| Lane | Appearance |
|
|
68
|
+
| ------------- | ------------------------------------------------------------------------ |
|
|
69
|
+
| 🧑 **You** | Filled card with an accent border — the thing you scan for |
|
|
70
|
+
| 🤖 **Claude** | Clean prose, unadorned |
|
|
71
|
+
| ⚙️ **Tools** | Muted monospace folds, collapsed by default, each showing its own output |
|
|
72
|
+
|
|
73
|
+
Tool results are nested **inside the call that produced them** — so a 500-turn session scans in seconds, and nothing machine-generated is ever mislabelled as something you typed.
|
|
74
|
+
|
|
75
|
+
### 🔍 Search that actually finds things
|
|
76
|
+
|
|
77
|
+
`index/search.html` does instant client-side search across every turn, bash command and file edit — filter by type, jump straight to the moment in the conversation. No server, no index to build.
|
|
78
|
+
|
|
79
|
+
### 📦 Plain files underneath
|
|
80
|
+
|
|
81
|
+
Everything is JSON and Markdown you can grep, diff, or feed to other tools. Paths are relative to the archive home (`lastword where`):
|
|
82
|
+
|
|
83
|
+
| Path | Contents |
|
|
84
|
+
| -------------------------------------------- | ----------------------------------------------------- |
|
|
85
|
+
| `sessions/<project>/<id>/` | `source.jsonl`, `conversation.md`, `conversation.html` |
|
|
86
|
+
| `index/session_index.{json,md}` | One row per session — title, project, duration, links |
|
|
87
|
+
| `extracts/tool_invocations.{json,md}` | Every tool call, matched with its result |
|
|
88
|
+
| `extracts/file_modifications.{json,md}` | Every Edit / Write / MultiEdit / NotebookEdit |
|
|
89
|
+
| `extracts/bash_commands.{json,md}` | Every Bash call with stdout and stderr |
|
|
90
|
+
| `extracts/architectural_decisions.{json,md}` | Heuristically surfaced decision points |
|
|
91
|
+
| `timeline/timeline.{json,md}` | All of the above, merged and sorted by date |
|
|
92
|
+
|
|
93
|
+
`source.jsonl` is a **byte-for-byte copy** of Claude Code's transcript, the archive of record; everything else is rebuilt from it. Session UUIDs and original timestamps survive everywhere — filenames, table rows, HTML anchors.
|
|
94
|
+
|
|
95
|
+
> **Note** — `architectural_decisions` is a heuristic (plan proposals, `AskUserQuestion` points, decision language). Read it for signal, not as a curated list.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 🛡️ Stop losing chats in the first place
|
|
100
|
+
|
|
101
|
+
Before anything else, widen Claude Code's retention window in `~/.claude/settings.json`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"cleanupPeriodDays": 365
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This tool can only archive what still exists when it runs. A year of retention buys you margin; archiving automatically closes the gap completely.
|
|
110
|
+
|
|
111
|
+
**Archive every session as it ends:**
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
lastword hook install # adds a SessionEnd hook to ~/.claude/settings.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
When a session ends — you exit, `/clear`, or `/resume` another — Claude Code runs `lastword hook run`, which starts an archive run in the background and returns at once, so ending a session never waits on it. Your other settings are left exactly as they were (a backup is saved as `settings.json.lastword-backup`). `lastword hook status` shows the hook and its log (`hook.log` in the archive home); `lastword hook uninstall` removes it. Install lastword as a command first (`uv tool install` / `pipx install`): the hook runs it from whatever project you were in.
|
|
118
|
+
|
|
119
|
+
**And as a backstop, a daily run.** The hook doesn't fire if a terminal is killed or Claude Code crashes, so schedule one too:
|
|
120
|
+
|
|
121
|
+
**macOS / Linux** — `crontab -e` (cron has a minimal `PATH`, so give the full path from `which lastword`):
|
|
122
|
+
|
|
123
|
+
```cron
|
|
124
|
+
0 20 * * * $HOME/.local/bin/lastword --quiet
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Windows** — Task Scheduler → daily → `lastword --quiet`.
|
|
128
|
+
|
|
129
|
+
`lastword` exits non-zero if any session failed to archive, so a scheduler that alerts on failure will tell you. Two runs that overlap don't collide: the second waits for the first.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## ♻️ Already lost chats? Maybe not.
|
|
134
|
+
|
|
135
|
+
If you archived sessions before and they've vanished from your index, **they are probably still on disk.** Earlier versions rebuilt the index only from live sources, so pruned sessions dropped out even though `sessions/` still held every byte.
|
|
136
|
+
|
|
137
|
+
Just run it again:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
lastword
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The backfill pass replays every session in `manifest.json` from its archived copy:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
Sessions found: 23 | archived: 2 | unchanged: 21 | restored from archive: 28 | pages rendered: 2 | failed: 0
|
|
147
|
+
Total sessions in index: 51
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
As long as `manifest.json` and `sessions/` survive, nothing is lost.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 🚚 Renamed or moved a project?
|
|
155
|
+
|
|
156
|
+
Claude Code files sessions under the project's folder path, so renaming the folder splits its history in two: old sessions stay under the old name, new ones start under the new one. Join them back up:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
lastword move-project ~/code/old-name ~/code/new-name --dry-run # preview
|
|
160
|
+
lastword move-project ~/code/old-name ~/code/new-name
|
|
161
|
+
lastword
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This moves the old sessions to the new name both in `~/.claude/projects` (so `claude --resume` finds them from the new folder) and in your archive, and from then on shows the old path as the new one in the index, search and timeline. Your transcripts are never rewritten; `source.jsonl` keeps the paths exactly as they were recorded.
|
|
165
|
+
|
|
166
|
+
Close any Claude Code session still running in the old folder first. `move-project` refuses to run while one is running, and stops without changing anything if a file at the new name would be overwritten. If a session was open during the move anyway, Claude Code writes a few closing records back to the old folder when it exits; run `move-project` again and it recognises that stub and clears it away, since everything in it is already in the moved copy. Pass `--archive-only` to leave `~/.claude/projects` alone.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 🏠 Where your archive lives
|
|
171
|
+
|
|
172
|
+
By default in **`~/.lastword`**, private to your user (`700`). `lastword where` prints it; to put it elsewhere, pass `--home DIR` or set `LASTWORD_HOME`. Avoid folders that sync to the cloud (Documents or Desktop with iCloud or OneDrive): the archive holds everything you pasted into a session.
|
|
173
|
+
|
|
174
|
+
**Archived into a git checkout before 0.1?** Nothing breaks: run from inside a folder that already holds an archive, lastword keeps using it. To move it to the standard place:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
lastword migrate --from /path/to/lastword # copies to ~/.lastword and checks every byte
|
|
178
|
+
lastword && lastword verify
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The old copy is left untouched until you delete it. The first run on an archive from before 0.1 upgrades it in place, keeping the original manifest as `manifest.v0.bak.json`.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## ⚙️ Commands
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
lastword [archive] Archive new and changed sessions (the default)
|
|
189
|
+
--root DIR Claude Code projects dir (default: ~/.claude/projects)
|
|
190
|
+
--project SUBSTR Only process project dirs matching a substring
|
|
191
|
+
--force Re-render every session's pages
|
|
192
|
+
--quiet / --json Print nothing but problems / print counts as JSON
|
|
193
|
+
--wait SECONDS How long to wait for another run to finish (default: 60)
|
|
194
|
+
lastword open Open the session browser
|
|
195
|
+
lastword where Print the archive's location
|
|
196
|
+
lastword verify Check every archived transcript against its checksum
|
|
197
|
+
lastword migrate --from DIR Copy an existing archive to the archive home
|
|
198
|
+
lastword move-project OLD NEW Join a renamed project's sessions (see above)
|
|
199
|
+
lastword hook install Archive each session when it ends (also: uninstall, status)
|
|
200
|
+
lastword demo [--open] Build a demo archive from invented sessions
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Every command takes `--home DIR`. Exit codes: `0` success, `1` something failed (details on stderr), `2` bad usage.
|
|
204
|
+
|
|
205
|
+
**Stability:** until 1.0, the commands above and the archive layout (`sessions/`, `manifest.json`) are stable — a newer lastword always upgrades an older archive, and an older lastword refuses a newer archive rather than damage it. The JSON layouts under `extracts/`, `index/` and `timeline/` may still change.
|
|
206
|
+
|
|
207
|
+
## 🔒 How it stays safe
|
|
208
|
+
|
|
209
|
+
**Byte-exact** — each transcript is copied verbatim to `source.jsonl`, with its sha256 in `manifest.json`. `lastword verify` re-checks every one.
|
|
210
|
+
|
|
211
|
+
**Never overwritten** — Claude Code only appends to a transcript, so a new snapshot replaces the old one only if it starts with every byte of it. If a transcript is ever rewritten instead, the earlier copy is kept alongside.
|
|
212
|
+
|
|
213
|
+
**Append-only** — aggregates rebuild from the union of live sources **and** every session in the manifest, replayed from its archived copy. Claude Code's prune can't remove anything from your index.
|
|
214
|
+
|
|
215
|
+
**Crash-safe** — every file is written to a temp file and renamed into place, and overlapping runs take turns, so an interrupted run never leaves a half-written archive.
|
|
216
|
+
|
|
217
|
+
**Local** — reads `~/.claude/projects`, writes to disk. No network, no telemetry, no dependencies. Transcript text is escaped before rendering, and `javascript:` URLs are stripped.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 🚨 Privacy — read this before pushing anywhere
|
|
222
|
+
|
|
223
|
+
**Your exported conversations are private. Never commit them.**
|
|
224
|
+
|
|
225
|
+
The archive holds whatever you discussed with Claude: proprietary source, file paths, customer data, credentials pasted into prompts. Keep it out of any repository. If you still archive into a git checkout, its bundled `.gitignore` excludes every path the exporter writes, so a fork stays code-only. Before your first push:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
git status --porcelain # should list source files only
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
To back up the archive itself, use a **private** repo or ordinary file backup — never a public one.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 🤝 Contributing
|
|
236
|
+
|
|
237
|
+
Issues and PRs welcome. Run the tests with `python3 -m unittest` — they build invented transcripts and never touch your own. For screenshots or UI checks, `python3 tools/make_demo.py` rebuilds `docs/demo/`. Please never paste real transcript content into a bug report — a redacted snippet or the structure alone is plenty.
|
|
238
|
+
|
|
239
|
+
## 📄 License
|
|
240
|
+
|
|
241
|
+
MIT — see [LICENSE](LICENSE).
|
|
242
|
+
|
|
243
|
+
<div align="center"><br><sub>Your conversations are work. Keep them.</sub></div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""lastword — a permanent archive for Claude Code session transcripts.
|
|
2
|
+
|
|
3
|
+
Recursively scans a Claude Code `projects` directory (JSONL session
|
|
4
|
+
transcripts), keeps a byte-exact copy of every transcript it sees,
|
|
5
|
+
reconstructs each conversation in chronological order, and exports
|
|
6
|
+
Markdown, HTML, session/search indexes, tool/file/bash extracts, an
|
|
7
|
+
architectural-decisions digest, and a project timeline.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.1"
|