batonpass-cli 0.5.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.
- batonpass_cli-0.5.0/LICENSE +21 -0
- batonpass_cli-0.5.0/PKG-INFO +324 -0
- batonpass_cli-0.5.0/README.md +292 -0
- batonpass_cli-0.5.0/pyproject.toml +50 -0
- batonpass_cli-0.5.0/setup.cfg +4 -0
- batonpass_cli-0.5.0/src/batonpass/__init__.py +7 -0
- batonpass_cli-0.5.0/src/batonpass/__main__.py +3 -0
- batonpass_cli-0.5.0/src/batonpass/archive/__init__.py +4 -0
- batonpass_cli-0.5.0/src/batonpass/archive/adapters.py +616 -0
- batonpass_cli-0.5.0/src/batonpass/archive/export.py +71 -0
- batonpass_cli-0.5.0/src/batonpass/archive/runner.py +128 -0
- batonpass_cli-0.5.0/src/batonpass/cli.py +579 -0
- batonpass_cli-0.5.0/src/batonpass/discover/__init__.py +36 -0
- batonpass_cli-0.5.0/src/batonpass/discover/probe.py +1052 -0
- batonpass_cli-0.5.0/src/batonpass/doctor.py +314 -0
- batonpass_cli-0.5.0/src/batonpass/identity/__init__.py +9 -0
- batonpass_cli-0.5.0/src/batonpass/identity/artifacts.py +293 -0
- batonpass_cli-0.5.0/src/batonpass/identity/project.py +245 -0
- batonpass_cli-0.5.0/src/batonpass/identity/tasks.py +423 -0
- batonpass_cli-0.5.0/src/batonpass/mcp.py +273 -0
- batonpass_cli-0.5.0/src/batonpass/paths.py +26 -0
- batonpass_cli-0.5.0/src/batonpass/recall/__init__.py +45 -0
- batonpass_cli-0.5.0/src/batonpass/recall/index.py +147 -0
- batonpass_cli-0.5.0/src/batonpass/recall/query.py +215 -0
- batonpass_cli-0.5.0/src/batonpass/store/__init__.py +5 -0
- batonpass_cli-0.5.0/src/batonpass/store/codecs.py +31 -0
- batonpass_cli-0.5.0/src/batonpass/store/content.py +186 -0
- batonpass_cli-0.5.0/src/batonpass/store/db.py +95 -0
- batonpass_cli-0.5.0/src/batonpass/store/schema.py +152 -0
- batonpass_cli-0.5.0/src/batonpass/store/text.py +55 -0
- batonpass_cli-0.5.0/src/batonpass/store/write.py +92 -0
- batonpass_cli-0.5.0/src/batonpass/sync/__init__.py +15 -0
- batonpass_cli-0.5.0/src/batonpass/sync/channel.py +213 -0
- batonpass_cli-0.5.0/src/batonpass/sync/crypt.py +216 -0
- batonpass_cli-0.5.0/src/batonpass/sync/pull.py +186 -0
- batonpass_cli-0.5.0/src/batonpass/sync/push.py +276 -0
- batonpass_cli-0.5.0/src/batonpass/sync/status.py +56 -0
- batonpass_cli-0.5.0/src/batonpass/sync/wire.py +205 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/PKG-INFO +324 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/SOURCES.txt +49 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/dependency_links.txt +1 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/entry_points.txt +2 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/requires.txt +6 -0
- batonpass_cli-0.5.0/src/batonpass_cli.egg-info/top_level.txt +1 -0
- batonpass_cli-0.5.0/tests/test_archive.py +94 -0
- batonpass_cli-0.5.0/tests/test_crypt.py +120 -0
- batonpass_cli-0.5.0/tests/test_doctor.py +91 -0
- batonpass_cli-0.5.0/tests/test_identity.py +251 -0
- batonpass_cli-0.5.0/tests/test_mcp.py +126 -0
- batonpass_cli-0.5.0/tests/test_recall.py +59 -0
- batonpass_cli-0.5.0/tests/test_sync.py +210 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 batonpass contributors
|
|
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,324 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: batonpass-cli
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Never drop the baton. Read-only archive of the AI history on your machine, portable to the next one.
|
|
5
|
+
Author: lcpkof
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lcpkof/batonpass
|
|
8
|
+
Project-URL: Issues, https://github.com/lcpkof/batonpass/issues
|
|
9
|
+
Keywords: ai,agent,memory,archive,handoff,sqlite,read-only,continuity
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Database
|
|
23
|
+
Classifier: Topic :: System :: Archiving
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Provides-Extra: zstd
|
|
28
|
+
Requires-Dist: zstandard>=0.21; extra == "zstd"
|
|
29
|
+
Provides-Extra: crypto
|
|
30
|
+
Requires-Dist: cryptography>=3.4; extra == "crypto"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# batonpass
|
|
34
|
+
|
|
35
|
+
> **Never drop the baton.**
|
|
36
|
+
> Switch machines mid-task — your work picks up exactly where you left it.
|
|
37
|
+
|
|
38
|
+
You are 3 hours into a task on the Mac mini. You open the laptop. Nothing is there.
|
|
39
|
+
|
|
40
|
+
Not the transcript, not the tool output that told you which endpoint 404'd, not the reason
|
|
41
|
+
you rejected the third approach. You remember the *concept* — "the岗位表 thing, I fixed the
|
|
42
|
+
join" — and you spend 20 minutes re-deriving what you already knew.
|
|
43
|
+
|
|
44
|
+
`batonpass` is the thing that hands the baton over: **from one machine to the next, from
|
|
45
|
+
last-week-you to today-you**, without the work touching the ground.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
batonpass discover # what AI history is on this machine? (read-only, 2 s)
|
|
49
|
+
batonpass archive # pull it into a portable library (~1 min per GB)
|
|
50
|
+
batonpass export <session> --text # read one conversation back out
|
|
51
|
+
batonpass sync push ~/Dropbox/baton # one file per machine, summaries only (~2 MB)
|
|
52
|
+
batonpass sync pull ~/Dropbox/baton # on the other machine: 713 sessions, zero messages
|
|
53
|
+
batonpass index # local search index, ~17 s per 700 sessions
|
|
54
|
+
batonpass find "岗位表" --at 7d # search it, with time windows
|
|
55
|
+
batonpass tasks # every project, one line each
|
|
56
|
+
batonpass resume # handover card for the directory you are in
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## The rule that makes this safe to point at your machine
|
|
62
|
+
|
|
63
|
+
**batonpass never writes to your AI tools' data. Ever.**
|
|
64
|
+
|
|
65
|
+
Your Claude / Codex / Cursor / zcode / dsh / billion databases are opened `mode=ro`.
|
|
66
|
+
No schema migrations, no `ALTER TABLE`, no "helpful" cleanup. If a tool ships a new
|
|
67
|
+
schema tomorrow, batonpass reads what it can, names what it couldn't, and never touches
|
|
68
|
+
the file to find out.
|
|
69
|
+
|
|
70
|
+
This is not a preference, it's the first law, and `discover` is built to prove it: it
|
|
71
|
+
refuses to import a networking module, and it records any source it had to open
|
|
72
|
+
immutably instead of silently proceeding.
|
|
73
|
+
|
|
74
|
+
**Read-only in · you own the copy out.**
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Start here: `batonpass discover`
|
|
79
|
+
|
|
80
|
+
Before you trust a tool with your history, look at what's actually there.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uvx batonpass-cli discover --report ~/Desktop/batonpass-report.html
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
One file, standard library only, ~2 seconds, no network, no writes. It produces a
|
|
87
|
+
single self-contained HTML page telling you:
|
|
88
|
+
|
|
89
|
+
- **what it found** — 261,354 messages across 713 conversations in 9 sources, 2.2 GB on my machine
|
|
90
|
+
- **how much it can actually read** — every source gets a coverage verdict, not a vibe
|
|
91
|
+
- **what it is silently failing to read, and why** — a skip ledger: `browser-cache: 14`,
|
|
92
|
+
`backup-copy: 4`, `nested-artifact: 1`. A skip you can see is not a silent skip.
|
|
93
|
+
- **what it refused to guess** — databases it recognised *without* a known adapter, with
|
|
94
|
+
the reason and a repro command, so you can open an issue instead of debugging alone
|
|
95
|
+
|
|
96
|
+
A real run on this machine:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
261,354 messages · 713 conversations · 9 sources recognised · 2.2 GB
|
|
100
|
+
26 files skipped (browser caches, backups) · 7 dirs still in the queue
|
|
101
|
+
billion 212,433 msg 385 sess 1,489.9 MB degraded: media-by-reference
|
|
102
|
+
zcode 48,078 msg 304 sess 847.8 MB ok
|
|
103
|
+
alma 75 msg 2 sess 11.4 MB ok
|
|
104
|
+
zcode-tasks 203 tasks 10 projects 5 hosts ok (role: index)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Note the third line: 1.4 GB of that source is media stored by reference — the text is
|
|
108
|
+
fine, the images aren't in the DB. `batonpass` says so up front instead of handing you a
|
|
109
|
+
176 MB archive that turns out to be empty in the middle.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Then: three tiers, pick your cost
|
|
114
|
+
|
|
115
|
+
| Tier | What you get | Time | Cost |
|
|
116
|
+
|---|---|---|---|
|
|
117
|
+
| **A · Look** | The report above. No library, no config, no writes. | 30 s | 0 |
|
|
118
|
+
| **B · Archive one machine** | Full local library, `find` / `resume` over it. | ~5 min setup, 6–13 min first archive | ~250–450 MB from 3.8 GB |
|
|
119
|
+
| **C · Sync machines** | Every machine's history in one place, details on demand. | +2 min | 2 MB of catalog replicated first |
|
|
120
|
+
|
|
121
|
+
Tier C is the interesting one, and it's built on a deliberate split:
|
|
122
|
+
|
|
123
|
+
**2 MB of catalog first, the details only when you ask.**
|
|
124
|
+
|
|
125
|
+
A new machine doesn't download your history. It downloads an index — who, when, which
|
|
126
|
+
task, which file — in about two seconds, and then pulls transcripts *for the task you're
|
|
127
|
+
actually continuing*. Measured on real data: `message.data` gzips 5.43 MB → 0.80 MB and
|
|
128
|
+
zstd-19s to **0.28 MB (19.7×)**. You don't need the other 250 MB to keep working.
|
|
129
|
+
|
|
130
|
+
## Why a baton, and not a sync
|
|
131
|
+
|
|
132
|
+
When you're mid-task on two machines, the second machine doesn't need a *merge*, it needs
|
|
133
|
+
to know **what you already decided**. So the store is append-only and the conflict rule is
|
|
134
|
+
one line: **fork, never merge**. Two machines can't corrupt each other because neither one
|
|
135
|
+
writes the other's file. Transcripts are immutable facts; the only mutable thing is
|
|
136
|
+
`task.status`, which is itself a stream of appended events.
|
|
137
|
+
|
|
138
|
+
The result: you can work on the Mac mini and the laptop **at the same time**, and
|
|
139
|
+
`batonpass resume` will show you both branches and tell you they diverged — instead of
|
|
140
|
+
picking one silently and losing the other.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Status
|
|
145
|
+
|
|
146
|
+
| verb | state |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `discover` | **shipped** — read-only inventory, ~2 s, one HTML page |
|
|
149
|
+
| `archive` | **shipped** — five adapters, replay-safe (re-run adds 0 rows) |
|
|
150
|
+
| `sync` | **shipped** — append-only channel, tiered push/pull, replay-safe both ways |
|
|
151
|
+
| `identity` | **shipped** — machine-independent project key, artifact refs, handover cards |
|
|
152
|
+
| `index` · `find` | **shipped** — FTS5 trigram over everything you typed, with time windows |
|
|
153
|
+
| `tasks` · `card` · `resume` | **shipped** — the handover packet, from a project name or a directory |
|
|
154
|
+
| `sync compact` | **shipped** — a re-pushed stream collapses back to one line per fact |
|
|
155
|
+
| `doctor` | **shipped** — every "why doesn't it work" turned into one line you can act on |
|
|
156
|
+
| `mcp` | **shipped** — `memory_search` · `memory_add` · `resume` over stdio, for AI tools |
|
|
157
|
+
|
|
158
|
+
`archive`, measured end-to-end on this machine — all five sources, one pass:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
712 sessions · 261,310 messages · 484,573 parts · 52 s
|
|
162
|
+
2.2 GB of source databases → 466 MB portable library
|
|
163
|
+
448 MB of plaintext → 179.5 MB stored (2.50×, trained dict + zstd-19)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The number that matters more than the ratio: **running it again adds zero rows.**
|
|
167
|
+
Counts reconcile against the sources exactly — 304/304 sessions, 48,168/48,168
|
|
168
|
+
messages — and parts match once you account for the 72,184 `step-start` /
|
|
169
|
+
`step-finish` rows it skips *by name*. A message with no prose (a tool call, a
|
|
170
|
+
reasoning block) becomes a structured part instead of being thrown away. Nothing is
|
|
171
|
+
dropped silently; anything unaudited is reported as a number you can argue with.
|
|
172
|
+
|
|
173
|
+
`identity` + `find`, measured on that same 713-session library:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
713 sessions → 12 real projects · 558 honestly ungrouped
|
|
177
|
+
57 sessions folded into `xueji`, 50 into `gp`
|
|
178
|
+
6,479 deliverables → found in 575 sessions (xlsx, csv, pdf, png, md…)
|
|
179
|
+
58,508 messages indexed → 16.6 s one-off · 164 MB · 59212 docs
|
|
180
|
+
batonpass find 岗位表 → one hit, with the sentence it appeared in
|
|
181
|
+
batonpass find 妖族 → nothing (it never appears — 妖股 does)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
And the round trip, on a machine that has never seen the data — it pulls 356 KB
|
|
185
|
+
of catalog (t0) and can already say what is in flight:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
pull t0 → 713 sessions, 713 new, 0.04 s
|
|
189
|
+
batonpass tasks → 12 projects, sizes, devices, stale marks
|
|
190
|
+
batonpass card xueji → the same card, forks and all
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The ungrouped 558 are the point. Every one of them had a session title that looked
|
|
194
|
+
like a project name ("这道题我做错了,帮我讲讲"), and promoting those produced 400
|
|
195
|
+
clusters of one — structure that was pure invention. They stay searchable; they are just
|
|
196
|
+
not lied about.
|
|
197
|
+
|
|
198
|
+
`sync`, measured the same way — a real 713-session library, a channel folder, and a
|
|
199
|
+
second library that has never seen any of those apps:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
library 528 MB → channel 2.8 MB push 713 sessions in 2.0 s
|
|
203
|
+
t0 catalog 356 KB
|
|
204
|
+
t1 summaries 2.70 MB (incl. the files each session produced)
|
|
205
|
+
fresh machine reads t0 0.04 s → 713 sessions, 0 messages
|
|
206
|
+
then t1 0.05 s → every session has a first ask, its last rounds,
|
|
207
|
+
and the files it produced
|
|
208
|
+
deep-pull one task 0.14 s → 64 messages, 256 parts, 317 blobs
|
|
209
|
+
verify: 64/64 message hashes identical, 0 bodies differ
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
A channel is just a folder — a shared volume, a synced directory, a git remote, a USB
|
|
213
|
+
stick. Each machine appends only to *its own* file, so there is no lock, no leader and
|
|
214
|
+
no merge step, and pulling never writes into the channel. Everything is addressed by the
|
|
215
|
+
sha256 of its plaintext, which is why the same line arriving twice is indistinguishable
|
|
216
|
+
from it arriving once. The one cost of append-only: a re-pushed summary leaves the old
|
|
217
|
+
line behind, and a reader takes the last one. So a stream gets rewritten once it has
|
|
218
|
+
grown past a floor — `sync compact` (and every push, when it is worth it):
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
3 pushes of the same 713 sessions → 1005 KB · 2139 lines
|
|
222
|
+
sync compact → 335 KB · 713 lines (one line per session)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Each rewrite bumps a generation counter in `heads/<device>.<tier>.json`. A reader keys
|
|
226
|
+
its byte offset on the generation, so a rewritten file simply looks new and is read from
|
|
227
|
+
zero — safe precisely because every import is an idempotent `INSERT OR IGNORE`.
|
|
228
|
+
|
|
229
|
+
### When the channel is a cloud drive
|
|
230
|
+
|
|
231
|
+
A folder on someone else's disk is a folder on someone else's disk. Say so at `init`:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
export BATONPASS_KEY='the passphrase you will type on every machine'
|
|
235
|
+
batonpass sync init ~/Nutstore/batonpass --encrypt
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Every payload is sealed with AES-256-GCM before it lands on the drive, keyed by scrypt
|
|
239
|
+
from that passphrase; blobs already in the channel are re-sealed in place. The key is
|
|
240
|
+
never written into the channel — it comes from `BATONPASS_KEY` or `~/.batonpass/key`.
|
|
241
|
+
Addressing stays on the plaintext sha256, so a re-sent message still lands on exactly the
|
|
242
|
+
same path, and a wrong passphrase produces one sentence (*"this channel is encrypted and
|
|
243
|
+
the key does not match"*) instead of a corrupt-archive mystery.
|
|
244
|
+
|
|
245
|
+
What is **not** sealed: the catalog lines themselves, because dedupe keys live there. So
|
|
246
|
+
the drive's operator can see that you had 713 sessions with these titles on these dates —
|
|
247
|
+
not a word of what was said. That leak is real and small, and stating it is the point.
|
|
248
|
+
|
|
249
|
+
If it ever doesn't work, it says why instead of throwing:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
$ batonpass doctor --channel ~/Dropbox/batonpass
|
|
253
|
+
OK python 3.9.6
|
|
254
|
+
OK sqlite 3.54.0, fts5 + trigram
|
|
255
|
+
WARN zstd not installed — archives stay readable, 2.50x becomes 2.04x
|
|
256
|
+
→ pip install "batonpass-cli[zstd]"
|
|
257
|
+
OK library 680.6 MB, 713 sessions, 263,256 messages
|
|
258
|
+
OK identity 12 named project key(s), 558 honestly ungrouped
|
|
259
|
+
OK channel id c62264a7f0b4, 1 device(s), 0 B
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Letting the AI tools call it
|
|
263
|
+
|
|
264
|
+
`batonpass mcp` is an MCP server on stdio — no daemon, no port, nothing left running
|
|
265
|
+
when the client exits. Three tools, because that is the whole vocabulary an agent needs:
|
|
266
|
+
`memory_search` (look something up by a vague phrase), `memory_add` (write down what it
|
|
267
|
+
just learned, before it is forgotten), `resume` (hand the baton over).
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{"mcpServers": {"batonpass": {"command": "uvx", "args": ["batonpass", "mcp"]}}}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
The silence contract applies here too: a search that finds nothing returns
|
|
274
|
+
*"not found — do not invent one"*, because a model that hallucinates a file path costs
|
|
275
|
+
you twenty minutes of looking for a file that never existed.
|
|
276
|
+
|
|
277
|
+
If you run it and it *doesn't* recognise a source you use, that is the most useful bug
|
|
278
|
+
report there is — please use the
|
|
279
|
+
[unrecognized source template](.github/ISSUE_TEMPLATE/unrecognized-source.md). It asks
|
|
280
|
+
for a schema fingerprint, not your data.
|
|
281
|
+
|
|
282
|
+
## Non-goals
|
|
283
|
+
|
|
284
|
+
- **Not a memory layer.** `memory-bridge` and friends remember *conclusions*. This keeps
|
|
285
|
+
the *transcript* — the 40 tool calls that produced the conclusion. Different artifact.
|
|
286
|
+
- **Not bidirectional.** There is no write-back into Claude or Cursor. That's the whole
|
|
287
|
+
reason it's safe.
|
|
288
|
+
- **Not a cloud service.** The data plane is yours: a folder, a git remote, or a machine
|
|
289
|
+
you own. The control plane is disposable by design.
|
|
290
|
+
|
|
291
|
+
## Install
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
uvx batonpass-cli discover # no install, runs from a temp env
|
|
295
|
+
pipx run batonpass-cli discover
|
|
296
|
+
pip install "batonpass-cli[zstd]" # or install it, with the compressor
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
The package is `batonpass-cli` on PyPI, because the plain name `batonpass` is
|
|
300
|
+
already spoken for — an unrelated project called `baton-pass` normalizes to the
|
|
301
|
+
same string, and PyPI compares names with the separators removed. The command
|
|
302
|
+
it installs is still `batonpass`.
|
|
303
|
+
|
|
304
|
+
Python 3.9+. Zero required dependencies — `zstandard` is the only extra, and it
|
|
305
|
+
buys the 2.5× storage ratio. Without it, libraries written with zstd still
|
|
306
|
+
refuse gracefully and tell you the one command to run.
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
MIT. See [`Acknowledgments`](#acknowledgments).
|
|
311
|
+
|
|
312
|
+
### Acknowledgments
|
|
313
|
+
|
|
314
|
+
The design learned from two prior projects — **no source code was copied from either**:
|
|
315
|
+
|
|
316
|
+
- [`jiabaobei/memory-bridge`](https://github.com/jiabaobei/memory-bridge) — per-device own-file
|
|
317
|
+
heartbeat, write-once wiring, content-freeze, handover cards with staleness windows, and
|
|
318
|
+
the one-line session index that made "which file was it" searchable again.
|
|
319
|
+
- [`Nwflower/dsh-chat-import`](https://github.com/Nwflower/dsh-chat-import) — the Interchange
|
|
320
|
+
IR, named degradation policies (`lossless | text-fallback | skip-placeholder`), multi-frame
|
|
321
|
+
zstd decoding, and the `PRAGMA table_info` adaptivity that lets a reader survive schema drift.
|
|
322
|
+
|
|
323
|
+
Both solve a real slice of this problem. Neither ships a machine-to-machine handoff.
|
|
324
|
+
That gap is what batonpass is for.
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# batonpass
|
|
2
|
+
|
|
3
|
+
> **Never drop the baton.**
|
|
4
|
+
> Switch machines mid-task — your work picks up exactly where you left it.
|
|
5
|
+
|
|
6
|
+
You are 3 hours into a task on the Mac mini. You open the laptop. Nothing is there.
|
|
7
|
+
|
|
8
|
+
Not the transcript, not the tool output that told you which endpoint 404'd, not the reason
|
|
9
|
+
you rejected the third approach. You remember the *concept* — "the岗位表 thing, I fixed the
|
|
10
|
+
join" — and you spend 20 minutes re-deriving what you already knew.
|
|
11
|
+
|
|
12
|
+
`batonpass` is the thing that hands the baton over: **from one machine to the next, from
|
|
13
|
+
last-week-you to today-you**, without the work touching the ground.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
batonpass discover # what AI history is on this machine? (read-only, 2 s)
|
|
17
|
+
batonpass archive # pull it into a portable library (~1 min per GB)
|
|
18
|
+
batonpass export <session> --text # read one conversation back out
|
|
19
|
+
batonpass sync push ~/Dropbox/baton # one file per machine, summaries only (~2 MB)
|
|
20
|
+
batonpass sync pull ~/Dropbox/baton # on the other machine: 713 sessions, zero messages
|
|
21
|
+
batonpass index # local search index, ~17 s per 700 sessions
|
|
22
|
+
batonpass find "岗位表" --at 7d # search it, with time windows
|
|
23
|
+
batonpass tasks # every project, one line each
|
|
24
|
+
batonpass resume # handover card for the directory you are in
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## The rule that makes this safe to point at your machine
|
|
30
|
+
|
|
31
|
+
**batonpass never writes to your AI tools' data. Ever.**
|
|
32
|
+
|
|
33
|
+
Your Claude / Codex / Cursor / zcode / dsh / billion databases are opened `mode=ro`.
|
|
34
|
+
No schema migrations, no `ALTER TABLE`, no "helpful" cleanup. If a tool ships a new
|
|
35
|
+
schema tomorrow, batonpass reads what it can, names what it couldn't, and never touches
|
|
36
|
+
the file to find out.
|
|
37
|
+
|
|
38
|
+
This is not a preference, it's the first law, and `discover` is built to prove it: it
|
|
39
|
+
refuses to import a networking module, and it records any source it had to open
|
|
40
|
+
immutably instead of silently proceeding.
|
|
41
|
+
|
|
42
|
+
**Read-only in · you own the copy out.**
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Start here: `batonpass discover`
|
|
47
|
+
|
|
48
|
+
Before you trust a tool with your history, look at what's actually there.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uvx batonpass-cli discover --report ~/Desktop/batonpass-report.html
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
One file, standard library only, ~2 seconds, no network, no writes. It produces a
|
|
55
|
+
single self-contained HTML page telling you:
|
|
56
|
+
|
|
57
|
+
- **what it found** — 261,354 messages across 713 conversations in 9 sources, 2.2 GB on my machine
|
|
58
|
+
- **how much it can actually read** — every source gets a coverage verdict, not a vibe
|
|
59
|
+
- **what it is silently failing to read, and why** — a skip ledger: `browser-cache: 14`,
|
|
60
|
+
`backup-copy: 4`, `nested-artifact: 1`. A skip you can see is not a silent skip.
|
|
61
|
+
- **what it refused to guess** — databases it recognised *without* a known adapter, with
|
|
62
|
+
the reason and a repro command, so you can open an issue instead of debugging alone
|
|
63
|
+
|
|
64
|
+
A real run on this machine:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
261,354 messages · 713 conversations · 9 sources recognised · 2.2 GB
|
|
68
|
+
26 files skipped (browser caches, backups) · 7 dirs still in the queue
|
|
69
|
+
billion 212,433 msg 385 sess 1,489.9 MB degraded: media-by-reference
|
|
70
|
+
zcode 48,078 msg 304 sess 847.8 MB ok
|
|
71
|
+
alma 75 msg 2 sess 11.4 MB ok
|
|
72
|
+
zcode-tasks 203 tasks 10 projects 5 hosts ok (role: index)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Note the third line: 1.4 GB of that source is media stored by reference — the text is
|
|
76
|
+
fine, the images aren't in the DB. `batonpass` says so up front instead of handing you a
|
|
77
|
+
176 MB archive that turns out to be empty in the middle.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Then: three tiers, pick your cost
|
|
82
|
+
|
|
83
|
+
| Tier | What you get | Time | Cost |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| **A · Look** | The report above. No library, no config, no writes. | 30 s | 0 |
|
|
86
|
+
| **B · Archive one machine** | Full local library, `find` / `resume` over it. | ~5 min setup, 6–13 min first archive | ~250–450 MB from 3.8 GB |
|
|
87
|
+
| **C · Sync machines** | Every machine's history in one place, details on demand. | +2 min | 2 MB of catalog replicated first |
|
|
88
|
+
|
|
89
|
+
Tier C is the interesting one, and it's built on a deliberate split:
|
|
90
|
+
|
|
91
|
+
**2 MB of catalog first, the details only when you ask.**
|
|
92
|
+
|
|
93
|
+
A new machine doesn't download your history. It downloads an index — who, when, which
|
|
94
|
+
task, which file — in about two seconds, and then pulls transcripts *for the task you're
|
|
95
|
+
actually continuing*. Measured on real data: `message.data` gzips 5.43 MB → 0.80 MB and
|
|
96
|
+
zstd-19s to **0.28 MB (19.7×)**. You don't need the other 250 MB to keep working.
|
|
97
|
+
|
|
98
|
+
## Why a baton, and not a sync
|
|
99
|
+
|
|
100
|
+
When you're mid-task on two machines, the second machine doesn't need a *merge*, it needs
|
|
101
|
+
to know **what you already decided**. So the store is append-only and the conflict rule is
|
|
102
|
+
one line: **fork, never merge**. Two machines can't corrupt each other because neither one
|
|
103
|
+
writes the other's file. Transcripts are immutable facts; the only mutable thing is
|
|
104
|
+
`task.status`, which is itself a stream of appended events.
|
|
105
|
+
|
|
106
|
+
The result: you can work on the Mac mini and the laptop **at the same time**, and
|
|
107
|
+
`batonpass resume` will show you both branches and tell you they diverged — instead of
|
|
108
|
+
picking one silently and losing the other.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Status
|
|
113
|
+
|
|
114
|
+
| verb | state |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `discover` | **shipped** — read-only inventory, ~2 s, one HTML page |
|
|
117
|
+
| `archive` | **shipped** — five adapters, replay-safe (re-run adds 0 rows) |
|
|
118
|
+
| `sync` | **shipped** — append-only channel, tiered push/pull, replay-safe both ways |
|
|
119
|
+
| `identity` | **shipped** — machine-independent project key, artifact refs, handover cards |
|
|
120
|
+
| `index` · `find` | **shipped** — FTS5 trigram over everything you typed, with time windows |
|
|
121
|
+
| `tasks` · `card` · `resume` | **shipped** — the handover packet, from a project name or a directory |
|
|
122
|
+
| `sync compact` | **shipped** — a re-pushed stream collapses back to one line per fact |
|
|
123
|
+
| `doctor` | **shipped** — every "why doesn't it work" turned into one line you can act on |
|
|
124
|
+
| `mcp` | **shipped** — `memory_search` · `memory_add` · `resume` over stdio, for AI tools |
|
|
125
|
+
|
|
126
|
+
`archive`, measured end-to-end on this machine — all five sources, one pass:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
712 sessions · 261,310 messages · 484,573 parts · 52 s
|
|
130
|
+
2.2 GB of source databases → 466 MB portable library
|
|
131
|
+
448 MB of plaintext → 179.5 MB stored (2.50×, trained dict + zstd-19)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The number that matters more than the ratio: **running it again adds zero rows.**
|
|
135
|
+
Counts reconcile against the sources exactly — 304/304 sessions, 48,168/48,168
|
|
136
|
+
messages — and parts match once you account for the 72,184 `step-start` /
|
|
137
|
+
`step-finish` rows it skips *by name*. A message with no prose (a tool call, a
|
|
138
|
+
reasoning block) becomes a structured part instead of being thrown away. Nothing is
|
|
139
|
+
dropped silently; anything unaudited is reported as a number you can argue with.
|
|
140
|
+
|
|
141
|
+
`identity` + `find`, measured on that same 713-session library:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
713 sessions → 12 real projects · 558 honestly ungrouped
|
|
145
|
+
57 sessions folded into `xueji`, 50 into `gp`
|
|
146
|
+
6,479 deliverables → found in 575 sessions (xlsx, csv, pdf, png, md…)
|
|
147
|
+
58,508 messages indexed → 16.6 s one-off · 164 MB · 59212 docs
|
|
148
|
+
batonpass find 岗位表 → one hit, with the sentence it appeared in
|
|
149
|
+
batonpass find 妖族 → nothing (it never appears — 妖股 does)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
And the round trip, on a machine that has never seen the data — it pulls 356 KB
|
|
153
|
+
of catalog (t0) and can already say what is in flight:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
pull t0 → 713 sessions, 713 new, 0.04 s
|
|
157
|
+
batonpass tasks → 12 projects, sizes, devices, stale marks
|
|
158
|
+
batonpass card xueji → the same card, forks and all
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The ungrouped 558 are the point. Every one of them had a session title that looked
|
|
162
|
+
like a project name ("这道题我做错了,帮我讲讲"), and promoting those produced 400
|
|
163
|
+
clusters of one — structure that was pure invention. They stay searchable; they are just
|
|
164
|
+
not lied about.
|
|
165
|
+
|
|
166
|
+
`sync`, measured the same way — a real 713-session library, a channel folder, and a
|
|
167
|
+
second library that has never seen any of those apps:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
library 528 MB → channel 2.8 MB push 713 sessions in 2.0 s
|
|
171
|
+
t0 catalog 356 KB
|
|
172
|
+
t1 summaries 2.70 MB (incl. the files each session produced)
|
|
173
|
+
fresh machine reads t0 0.04 s → 713 sessions, 0 messages
|
|
174
|
+
then t1 0.05 s → every session has a first ask, its last rounds,
|
|
175
|
+
and the files it produced
|
|
176
|
+
deep-pull one task 0.14 s → 64 messages, 256 parts, 317 blobs
|
|
177
|
+
verify: 64/64 message hashes identical, 0 bodies differ
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
A channel is just a folder — a shared volume, a synced directory, a git remote, a USB
|
|
181
|
+
stick. Each machine appends only to *its own* file, so there is no lock, no leader and
|
|
182
|
+
no merge step, and pulling never writes into the channel. Everything is addressed by the
|
|
183
|
+
sha256 of its plaintext, which is why the same line arriving twice is indistinguishable
|
|
184
|
+
from it arriving once. The one cost of append-only: a re-pushed summary leaves the old
|
|
185
|
+
line behind, and a reader takes the last one. So a stream gets rewritten once it has
|
|
186
|
+
grown past a floor — `sync compact` (and every push, when it is worth it):
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
3 pushes of the same 713 sessions → 1005 KB · 2139 lines
|
|
190
|
+
sync compact → 335 KB · 713 lines (one line per session)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Each rewrite bumps a generation counter in `heads/<device>.<tier>.json`. A reader keys
|
|
194
|
+
its byte offset on the generation, so a rewritten file simply looks new and is read from
|
|
195
|
+
zero — safe precisely because every import is an idempotent `INSERT OR IGNORE`.
|
|
196
|
+
|
|
197
|
+
### When the channel is a cloud drive
|
|
198
|
+
|
|
199
|
+
A folder on someone else's disk is a folder on someone else's disk. Say so at `init`:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
export BATONPASS_KEY='the passphrase you will type on every machine'
|
|
203
|
+
batonpass sync init ~/Nutstore/batonpass --encrypt
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Every payload is sealed with AES-256-GCM before it lands on the drive, keyed by scrypt
|
|
207
|
+
from that passphrase; blobs already in the channel are re-sealed in place. The key is
|
|
208
|
+
never written into the channel — it comes from `BATONPASS_KEY` or `~/.batonpass/key`.
|
|
209
|
+
Addressing stays on the plaintext sha256, so a re-sent message still lands on exactly the
|
|
210
|
+
same path, and a wrong passphrase produces one sentence (*"this channel is encrypted and
|
|
211
|
+
the key does not match"*) instead of a corrupt-archive mystery.
|
|
212
|
+
|
|
213
|
+
What is **not** sealed: the catalog lines themselves, because dedupe keys live there. So
|
|
214
|
+
the drive's operator can see that you had 713 sessions with these titles on these dates —
|
|
215
|
+
not a word of what was said. That leak is real and small, and stating it is the point.
|
|
216
|
+
|
|
217
|
+
If it ever doesn't work, it says why instead of throwing:
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
$ batonpass doctor --channel ~/Dropbox/batonpass
|
|
221
|
+
OK python 3.9.6
|
|
222
|
+
OK sqlite 3.54.0, fts5 + trigram
|
|
223
|
+
WARN zstd not installed — archives stay readable, 2.50x becomes 2.04x
|
|
224
|
+
→ pip install "batonpass-cli[zstd]"
|
|
225
|
+
OK library 680.6 MB, 713 sessions, 263,256 messages
|
|
226
|
+
OK identity 12 named project key(s), 558 honestly ungrouped
|
|
227
|
+
OK channel id c62264a7f0b4, 1 device(s), 0 B
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Letting the AI tools call it
|
|
231
|
+
|
|
232
|
+
`batonpass mcp` is an MCP server on stdio — no daemon, no port, nothing left running
|
|
233
|
+
when the client exits. Three tools, because that is the whole vocabulary an agent needs:
|
|
234
|
+
`memory_search` (look something up by a vague phrase), `memory_add` (write down what it
|
|
235
|
+
just learned, before it is forgotten), `resume` (hand the baton over).
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{"mcpServers": {"batonpass": {"command": "uvx", "args": ["batonpass", "mcp"]}}}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The silence contract applies here too: a search that finds nothing returns
|
|
242
|
+
*"not found — do not invent one"*, because a model that hallucinates a file path costs
|
|
243
|
+
you twenty minutes of looking for a file that never existed.
|
|
244
|
+
|
|
245
|
+
If you run it and it *doesn't* recognise a source you use, that is the most useful bug
|
|
246
|
+
report there is — please use the
|
|
247
|
+
[unrecognized source template](.github/ISSUE_TEMPLATE/unrecognized-source.md). It asks
|
|
248
|
+
for a schema fingerprint, not your data.
|
|
249
|
+
|
|
250
|
+
## Non-goals
|
|
251
|
+
|
|
252
|
+
- **Not a memory layer.** `memory-bridge` and friends remember *conclusions*. This keeps
|
|
253
|
+
the *transcript* — the 40 tool calls that produced the conclusion. Different artifact.
|
|
254
|
+
- **Not bidirectional.** There is no write-back into Claude or Cursor. That's the whole
|
|
255
|
+
reason it's safe.
|
|
256
|
+
- **Not a cloud service.** The data plane is yours: a folder, a git remote, or a machine
|
|
257
|
+
you own. The control plane is disposable by design.
|
|
258
|
+
|
|
259
|
+
## Install
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
uvx batonpass-cli discover # no install, runs from a temp env
|
|
263
|
+
pipx run batonpass-cli discover
|
|
264
|
+
pip install "batonpass-cli[zstd]" # or install it, with the compressor
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
The package is `batonpass-cli` on PyPI, because the plain name `batonpass` is
|
|
268
|
+
already spoken for — an unrelated project called `baton-pass` normalizes to the
|
|
269
|
+
same string, and PyPI compares names with the separators removed. The command
|
|
270
|
+
it installs is still `batonpass`.
|
|
271
|
+
|
|
272
|
+
Python 3.9+. Zero required dependencies — `zstandard` is the only extra, and it
|
|
273
|
+
buys the 2.5× storage ratio. Without it, libraries written with zstd still
|
|
274
|
+
refuse gracefully and tell you the one command to run.
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
MIT. See [`Acknowledgments`](#acknowledgments).
|
|
279
|
+
|
|
280
|
+
### Acknowledgments
|
|
281
|
+
|
|
282
|
+
The design learned from two prior projects — **no source code was copied from either**:
|
|
283
|
+
|
|
284
|
+
- [`jiabaobei/memory-bridge`](https://github.com/jiabaobei/memory-bridge) — per-device own-file
|
|
285
|
+
heartbeat, write-once wiring, content-freeze, handover cards with staleness windows, and
|
|
286
|
+
the one-line session index that made "which file was it" searchable again.
|
|
287
|
+
- [`Nwflower/dsh-chat-import`](https://github.com/Nwflower/dsh-chat-import) — the Interchange
|
|
288
|
+
IR, named degradation policies (`lossless | text-fallback | skip-placeholder`), multi-frame
|
|
289
|
+
zstd decoding, and the `PRAGMA table_info` adaptivity that lets a reader survive schema drift.
|
|
290
|
+
|
|
291
|
+
Both solve a real slice of this problem. Neither ships a machine-to-machine handoff.
|
|
292
|
+
That gap is what batonpass is for.
|