memoir-cli 2.5.2 → 2.6.0

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.
package/VISION.md ADDED
@@ -0,0 +1,722 @@
1
+ # memoir v3: The AI Development Context Portability Layer
2
+
3
+ ## Vision Document — March 2026
4
+
5
+ **One command to freeze your entire development state. One command to thaw it anywhere.**
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [The Problem](#the-problem)
12
+ 2. [What Exists Today](#what-exists-today)
13
+ 3. [The memoir v3 Vision](#the-memoir-v3-vision)
14
+ 4. [Technical Architecture](#technical-architecture)
15
+ 5. [The AI Context Layer (Killer Differentiator)](#the-ai-context-layer)
16
+ 6. [Cloud Architecture](#cloud-architecture)
17
+ 7. [Implementation Roadmap](#implementation-roadmap)
18
+ 8. [What Makes This Viral/Fundable](#what-makes-this-viralfundable)
19
+ 9. [Competitive Moat](#competitive-moat)
20
+
21
+ ---
22
+
23
+ ## The Problem
24
+
25
+ Developers in 2026 don't just switch machines — they switch between AI assistants mid-thought. You're deep in a Claude Code session on your Mac, you close the laptop, open your Windows desktop, fire up Gemini or Cursor, and... the AI has no idea what you were doing. Your files might sync via git, but your **context** — what you were building, why, what decisions you made, what's blocked, what's next — is gone.
26
+
27
+ This is the "AI context gap." Every tool today solves a piece of it. None solve all of it.
28
+
29
+ ### What gets lost today:
30
+ - **AI memory files** (CLAUDE.md, .cursorrules, GEMINI.md) — tool-specific, scattered
31
+ - **Session state** — what the AI learned about your codebase during a conversation
32
+ - **Decision history** — why you chose React over Svelte, why you avoided that npm package
33
+ - **Work-in-progress context** — uncommitted changes, half-written features, debugging state
34
+ - **Cross-tool intelligence** — Claude knows your codebase deeply, but Cursor doesn't
35
+
36
+ ---
37
+
38
+ ## What Exists Today
39
+
40
+ ### Cloud Dev Environments (Codespaces, Gitpod, Replit)
41
+
42
+ **How they work:** Entire VM/container in the cloud. Your "machine" is a URL. Codespaces uses Azure VMs with devcontainer.json; Gitpod runs Docker containers on Kubernetes with gitpod.yml.
43
+
44
+ **What they solve:** Environment consistency. You get the same Node version, same extensions, same everything.
45
+
46
+ **What they don't solve:**
47
+ - AI context doesn't transfer between environments
48
+ - Vendor lock-in (Codespaces is GitHub-only, Gitpod requires its config format)
49
+ - Latency — you're coding over a network connection
50
+ - Cost — always running, always billing
51
+ - No cross-tool portability (can't go from Codespaces to local Cursor)
52
+
53
+ **Lesson for memoir:** Don't compete with cloud IDEs. Complement them. memoir works whether you're local, in Codespaces, or SSH'd into a server.
54
+
55
+ ### File Sync Tools (Syncthing, rsync, Unison, Rclone)
56
+
57
+ **How they work:** Continuous or on-demand file mirroring between machines.
58
+
59
+ **What they solve:** Getting files from A to B.
60
+
61
+ **What they don't solve:**
62
+ - No understanding of *what* the files are — they sync node_modules as happily as CLAUDE.md
63
+ - No deduplication intelligence (rsync does binary diffs, but not content-addressable storage)
64
+ - No concept of "context" or "sessions"
65
+ - Conflict resolution is file-level, not semantic
66
+
67
+ **Technical lessons:**
68
+ - **rsync** — mature, battle-tested binary diff algorithm. Good for incremental sync.
69
+ - **Restic/Borg** — content-addressable, deduplicated, encrypted backup. Restic splits files into content-defined chunks, hashes each, only uploads new chunks. Borg does the same with variable-length chunking.
70
+ - **Rclone** — "rsync for cloud" — supports 70+ storage backends.
71
+
72
+ ### AI Memory/Context Tools (Direct Competitors)
73
+
74
+ **OneContext** (newest, most relevant):
75
+ - Self-managed persistent context layer for coding agents
76
+ - Stores project knowledge across sessions, devices, collaborators
77
+ - Supports importing old Codex/Claude sessions
78
+ - Can share context via hyperlink
79
+ - Context visualization/timeline
80
+ - Local-first architecture
81
+ - **Gap:** Focused on context only, doesn't sync AI configs/rules. No migration between AI tools.
82
+
83
+ **Memorix:**
84
+ - Persistent memory for AI coding agents via MCP
85
+ - Supports Cursor, Windsurf, Claude Code, Codex, Copilot, Gemini CLI
86
+ - npm package
87
+ - **Gap:** MCP-based (requires MCP support). No session handoff, no cross-device sync.
88
+
89
+ **Mem0:**
90
+ - "Universal memory layer for AI agents"
91
+ - Focused on agent memory management, not developer workflow
92
+ - More of an API/SDK than a CLI tool
93
+ - **Gap:** Enterprise/API-oriented, not developer-facing CLI.
94
+
95
+ **MemOS:**
96
+ - Memory OS for LLMs — persistent skill memory for cross-task reuse
97
+ - Academic/research-oriented
98
+ - **Gap:** Not a practical developer tool.
99
+
100
+ ### Apple Handoff (Conceptual Inspiration)
101
+
102
+ **How it works:**
103
+ 1. Devices signed into the same iCloud account establish BLE 4.2 pairing via APNs
104
+ 2. AES-256-GCM encrypted BLE advertisements broadcast current activity state
105
+ 3. Nearby device detects the ad, shows a Handoff icon
106
+ 4. User taps it — small payloads transfer via BLE, large ones via peer-to-peer Wi-Fi (TLS encrypted, trust derived from iCloud Keychain)
107
+
108
+ **Key design principles to steal:**
109
+ - **Discovery is passive** — you don't "send" to a device, it just appears
110
+ - **Minimal payload first** — just enough to show the icon (activity type + app)
111
+ - **Full payload on demand** — only transfer everything when user opts in
112
+ - **Identity-based trust** — same account = trusted, no manual pairing
113
+ - **Encrypted end-to-end** — even Apple can't read the transfer
114
+
115
+ **This is exactly what `memoir push` / `memoir restore` should feel like.** One identity, encrypted, instant.
116
+
117
+ ---
118
+
119
+ ## The memoir v3 Vision
120
+
121
+ ### The Pitch
122
+
123
+ **memoir is the portability layer between you, your code, and your AI.**
124
+
125
+ Today it syncs AI config files. Tomorrow it captures your *entire development state* — project files, AI memory, session context, decisions, blockers, next steps — and recreates it on another machine with one command. Not just the files. The understanding.
126
+
127
+ ### Core Commands (v3)
128
+
129
+ ```bash
130
+ # Capture EVERYTHING — AI configs + project state + session context
131
+ memoir push
132
+
133
+ # Recreate everything on another machine
134
+ memoir restore
135
+
136
+ # Snapshot current coding session (already exists, enhanced)
137
+ memoir snapshot --smart
138
+
139
+ # Resume on new machine — AI already knows what you were doing
140
+ memoir resume --inject --to claude
141
+
142
+ # Time travel — restore from any point
143
+ memoir restore --version 12
144
+ memoir restore --date "2 days ago"
145
+
146
+ # Share context with a teammate
147
+ memoir share --to teammate@email.com
148
+ memoir share --link # generates a shareable URL
149
+
150
+ # See your development timeline
151
+ memoir timeline
152
+
153
+ # Cross-tool migration (already exists, enhanced)
154
+ memoir migrate --from claude --to gemini --include-context
155
+ ```
156
+
157
+ ### What `memoir push` Captures (v3)
158
+
159
+ | Layer | What | How |
160
+ |-------|------|-----|
161
+ | **AI Configs** | CLAUDE.md, .cursorrules, GEMINI.md, etc. | File copy (existing) |
162
+ | **AI Memory** | ~/.claude/projects/*/memory/, session JSONL | File copy + parse |
163
+ | **Project State** | git status, branch, uncommitted changes, stash | `git diff`, `git stash` |
164
+ | **Session Context** | What you were working on, files touched, decisions | JSONL parsing + AI summary |
165
+ | **Environment** | Node version, Python version, key deps | Runtime detection |
166
+ | **Intent** | What's next, blockers, TODO items | AI-extracted from session |
167
+
168
+ ### What `memoir restore` Recreates (v3)
169
+
170
+ 1. AI config files placed in correct locations for each tool
171
+ 2. Session handoff injected into target AI tool's context
172
+ 3. Git state optionally restored (branch checkout, stash pop)
173
+ 4. AI summary available: "Here's what was happening and what's next"
174
+
175
+ ---
176
+
177
+ ## Technical Architecture
178
+
179
+ ### Content-Addressable Storage (CAS)
180
+
181
+ Instead of storing full file snapshots every time, use content-addressable storage like git objects or Restic:
182
+
183
+ ```
184
+ memoir-store/
185
+ ├── objects/ # Content-addressed blobs (SHA-256 hash of content)
186
+ │ ├── ab/cd1234... # Deduplicated file chunks
187
+ │ └── ef/gh5678...
188
+ ├── snapshots/ # Snapshot manifests (list of object refs)
189
+ │ ├── 2026-03-11T14-30-00.json
190
+ │ └── 2026-03-10T09-15-00.json
191
+ └── index.json # Local index of all known objects
192
+ ```
193
+
194
+ **How it works:**
195
+ 1. On `memoir push`, walk all tracked files
196
+ 2. Split each file into chunks (content-defined chunking, like Restic/Borg)
197
+ 3. Hash each chunk (SHA-256)
198
+ 4. Check if hash exists in remote store — skip if yes (dedup)
199
+ 5. Upload only new chunks
200
+ 6. Create a snapshot manifest (JSON listing all file paths + their chunk hashes)
201
+
202
+ **Benefits:**
203
+ - First push: full upload. Subsequent pushes: only diffs. Massive bandwidth savings.
204
+ - Multiple snapshots share chunks — 50 versions might only use 1.2x storage of a single version
205
+ - Integrity verification built in (hash = content identity)
206
+
207
+ **Implementation (Node.js):**
208
+ ```javascript
209
+ import { createHash } from 'crypto';
210
+
211
+ function hashChunk(buffer) {
212
+ return createHash('sha256').update(buffer).digest('hex');
213
+ }
214
+
215
+ // Content-defined chunking using rolling hash (Rabin fingerprint)
216
+ function chunkFile(buffer, avgSize = 64 * 1024) {
217
+ const chunks = [];
218
+ // Use Rabin fingerprint for content-defined boundaries
219
+ // This ensures similar files produce similar chunks even if bytes shift
220
+ let start = 0;
221
+ // ... rolling hash implementation
222
+ return chunks.map(chunk => ({
223
+ hash: hashChunk(chunk),
224
+ data: chunk,
225
+ size: chunk.length
226
+ }));
227
+ }
228
+ ```
229
+
230
+ For a solo dev MVP: skip the rolling hash complexity. Use fixed-size chunks (64KB) initially. Content-defined chunking is an optimization for later.
231
+
232
+ ### Incremental Sync Protocol
233
+
234
+ ```
235
+ Client Server (R2/Supabase)
236
+ │ │
237
+ │ 1. GET /snapshots/latest │
238
+ │ ─────────────────────────────> │
239
+ │ { manifest: [...hashes] } │
240
+ │ <───────────────────────────── │
241
+ │ │
242
+ │ 2. Diff local vs remote │
243
+ │ (compute new/changed chunks) │
244
+ │ │
245
+ │ 3. PUT /objects/{hash} │
246
+ │ (upload only new chunks) │
247
+ │ ─────────────────────────────> │
248
+ │ │
249
+ │ 4. POST /snapshots │
250
+ │ (create new snapshot manifest)│
251
+ │ ─────────────────────────────> │
252
+ │ │
253
+ │ Done. Only new data sent. │
254
+ ```
255
+
256
+ ### End-to-End Encryption
257
+
258
+ Project files may contain secrets, proprietary code, API keys. The server should never see plaintext.
259
+
260
+ **Approach: libsodium (tweetnacl-js for Node)**
261
+
262
+ ```
263
+ Key Generation (on first `memoir login`):
264
+ 1. Generate X25519 keypair
265
+ 2. Derive symmetric key from user password via Argon2id
266
+ 3. Encrypt private key with derived key, store encrypted private key on server
267
+ 4. Public key stored in plaintext on server
268
+
269
+ Encryption (on `memoir push`):
270
+ 1. Generate ephemeral symmetric key (XChaCha20-Poly1305)
271
+ 2. Encrypt each chunk with this key
272
+ 3. Encrypt the symmetric key with user's public key (sealed box)
273
+ 4. Upload: encrypted chunks + sealed key
274
+
275
+ Decryption (on `memoir restore`):
276
+ 1. Download encrypted chunks + sealed key
277
+ 2. Unseal symmetric key with user's private key
278
+ 3. Decrypt chunks
279
+ ```
280
+
281
+ **Libraries:** `tweetnacl` (1.4KB, zero deps) or `libsodium-wrappers` (more complete). For a CLI tool, `tweetnacl` + `tweetnacl-sealed-box` is sufficient and keeps the install fast.
282
+
283
+ ### Conflict Resolution
284
+
285
+ When the same file is modified on two machines between syncs:
286
+
287
+ **Strategy: Last-write-wins with conflict preservation**
288
+
289
+ ```
290
+ 1. On restore, if local file differs from snapshot AND snapshot differs from what was last restored:
291
+ → CONFLICT DETECTED
292
+ 2. Save both versions:
293
+ - .cursorrules (remote version applied)
294
+ - .cursorrules.memoir-conflict-2026-03-11 (local version preserved)
295
+ 3. Show user: "Conflict in .cursorrules — remote version applied, local saved as .memoir-conflict"
296
+ 4. For AI memory files: MERGE, not overwrite (append new memories, dedup)
297
+ ```
298
+
299
+ For AI config files specifically, merging is smarter than overwriting — a CLAUDE.md modified on two machines likely has additive changes, not conflicting ones.
300
+
301
+ ### Compression
302
+
303
+ **Use zstd (level 3) instead of gzip:**
304
+ - 3-5x faster compression than gzip at similar ratios
305
+ - Better compression ratio than gzip at same speed
306
+ - Streaming support (crypto_secretstream compatible)
307
+ - Node.js: `@aspect-build/zstd` or compile via `node-zstd`
308
+
309
+ Current codebase uses `zlib.createGzip({ level: 9 })` — switching to zstd level 3 would be faster with comparable compression.
310
+
311
+ ---
312
+
313
+ ## The AI Context Layer
314
+
315
+ **This is the killer differentiator. No tool does this today.**
316
+
317
+ ### The Problem Restated
318
+
319
+ You have a 2-hour Claude Code session. Claude reads 40 files, writes 12, runs 30 commands, makes architectural decisions, hits 3 bugs and fixes 2. You close the laptop.
320
+
321
+ On another machine, you open Claude Code. It knows *nothing*. You start from scratch.
322
+
323
+ `memoir snapshot` already captures the raw session data. The leap is making that data **actionable across any AI tool**.
324
+
325
+ ### Architecture: The Context Bundle
326
+
327
+ ```json
328
+ {
329
+ "memoir_version": "3.0",
330
+ "context_format": "ucf-1", // Universal Context Format
331
+ "captured_at": "2026-03-11T14:30:00Z",
332
+ "source": {
333
+ "tool": "claude-code",
334
+ "machine": "macbook-pro",
335
+ "platform": "darwin",
336
+ "session_id": "abc123"
337
+ },
338
+ "project": {
339
+ "path": "/Users/cam/myproject",
340
+ "git_branch": "feature/auth",
341
+ "git_status": "3 files modified, 1 untracked",
342
+ "git_diff_summary": "Adding JWT auth middleware...",
343
+ "language": "typescript",
344
+ "framework": "next.js",
345
+ "key_dependencies": ["next@14", "prisma@5", "jose@5"]
346
+ },
347
+ "session": {
348
+ "duration_minutes": 127,
349
+ "files_modified": ["src/middleware.ts", "src/lib/auth.ts", "prisma/schema.prisma"],
350
+ "files_read": ["src/app/api/route.ts", "package.json", "..."],
351
+ "decisions": [
352
+ "Chose jose over jsonwebtoken for Edge Runtime compatibility",
353
+ "Using middleware.ts for auth instead of per-route checks",
354
+ "Prisma schema uses @@map for snake_case DB columns"
355
+ ],
356
+ "blockers": [
357
+ "Prisma client not generating types for new User model — need to run prisma generate"
358
+ ],
359
+ "errors_encountered": [
360
+ "Edge Runtime doesn't support Node.js crypto — switched to jose"
361
+ ]
362
+ },
363
+ "intent": {
364
+ "summary": "Building JWT authentication for Next.js API routes",
365
+ "completed": [
366
+ "Auth middleware skeleton",
367
+ "Prisma User model with email/password",
368
+ "Login API route"
369
+ ],
370
+ "in_progress": [
371
+ "Token refresh endpoint"
372
+ ],
373
+ "next_steps": [
374
+ "Finish /api/auth/refresh route",
375
+ "Add protected route wrapper component",
376
+ "Write tests for auth flow"
377
+ ]
378
+ },
379
+ "ai_memory": {
380
+ "tool_configs": {
381
+ "claude": { "path": "~/.claude/projects/-Users-cam-myproject/memory/", "files": ["MEMORY.md"] },
382
+ "cursor": { "path": ".cursorrules", "content": "..." }
383
+ },
384
+ "learned_preferences": [
385
+ "User prefers function components over class components",
386
+ "User wants explicit error handling, not try/catch swallowing",
387
+ "User uses pnpm, not npm or yarn"
388
+ ]
389
+ }
390
+ }
391
+ ```
392
+
393
+ ### Cross-Tool Translation
394
+
395
+ The existing `memoir migrate` already translates configs between tools. v3 extends this to translate **context**:
396
+
397
+ ```bash
398
+ # Push from Claude Code session
399
+ memoir push # captures Claude-format context
400
+
401
+ # Restore into Cursor on another machine
402
+ memoir restore --to cursor
403
+ ```
404
+
405
+ What happens on restore to Cursor:
406
+ 1. AI configs restored (.cursorrules placed)
407
+ 2. Context bundle translated to Cursor-compatible format
408
+ 3. A `.cursor/context/memoir-handoff.md` file is generated:
409
+
410
+ ```markdown
411
+ # Project Context (from memoir)
412
+ You are continuing work on JWT authentication for a Next.js app.
413
+
414
+ ## Key Decisions Already Made
415
+ - Using `jose` (not jsonwebtoken) for Edge Runtime compatibility
416
+ - Auth via middleware.ts, not per-route
417
+ - Prisma with snake_case DB mapping
418
+
419
+ ## Current State
420
+ - Auth middleware: DONE
421
+ - Login route: DONE
422
+ - Token refresh: IN PROGRESS (started, not finished)
423
+
424
+ ## Next Steps
425
+ 1. Finish /api/auth/refresh route
426
+ 2. Add protected route wrapper component
427
+ 3. Write tests for auth flow
428
+
429
+ ## Known Issues
430
+ - Run `prisma generate` before starting — types are stale
431
+
432
+ ## Files to Focus On
433
+ - src/middleware.ts (auth logic)
434
+ - src/lib/auth.ts (token utils)
435
+ - src/app/api/auth/refresh/route.ts (in progress)
436
+ ```
437
+
438
+ The AI on the new machine reads this and **already knows what you were doing**. No re-explaining. No context rebuilding.
439
+
440
+ ### Smart Summaries (Enhanced)
441
+
442
+ The existing `--smart` flag uses Gemini to summarize. v3 makes this the default and extracts structured data:
443
+
444
+ ```javascript
445
+ // Extract decisions, blockers, next steps from raw session
446
+ async function extractContext(sessionData) {
447
+ const prompt = `Analyze this coding session and extract:
448
+ 1. KEY DECISIONS: Technical choices made and why
449
+ 2. CURRENT STATE: What's done, what's in progress
450
+ 3. BLOCKERS: Issues hit, unresolved problems
451
+ 4. NEXT STEPS: What should be done next
452
+ 5. PREFERENCES: Coding style/tool preferences observed
453
+
454
+ Return as JSON matching this schema: { decisions: [], state: {}, blockers: [], next_steps: [], preferences: [] }
455
+
456
+ Session data:
457
+ ${JSON.stringify(sessionData)}`;
458
+
459
+ // Use whatever LLM is available — Gemini (free), or user's own key
460
+ return callLLM(prompt);
461
+ }
462
+ ```
463
+
464
+ ### Session Continuity: The "Handoff Protocol"
465
+
466
+ ```
467
+ Machine A (Mac) memoir cloud Machine B (Windows)
468
+ │ │ │
469
+ │ memoir push │ │
470
+ │ ─ scan AI configs │ │
471
+ │ ─ parse Claude session │ │
472
+ │ ─ extract context (AI) │ │
473
+ │ ─ bundle + encrypt │ │
474
+ │ ─ upload (incremental) │ │
475
+ │ ───────────────────────────────>│ │
476
+ │ │ │
477
+ │ │ memoir restore │
478
+ │ │ ─ download + decrypt │
479
+ │ │ ─ detect local AI tools │
480
+ │ │ ─ restore configs │
481
+ │ │ ─ translate context │
482
+ │ │ ─ inject handoff │
483
+ │ │<───────────────────────────────│
484
+ │ │ │
485
+ │ │ Open Cursor/Claude/Gemini │
486
+ │ │ → AI reads handoff │
487
+ │ │ → "I see you were building │
488
+ │ │ JWT auth. The refresh │
489
+ │ │ endpoint is next." │
490
+ ```
491
+
492
+ ---
493
+
494
+ ## Cloud Architecture
495
+
496
+ ### Storage: Cloudflare R2 (Primary) + Supabase (Metadata/Auth)
497
+
498
+ The current codebase uses Supabase for everything (auth + storage + metadata). For v3, split concerns:
499
+
500
+ | Concern | Service | Why |
501
+ |---------|---------|-----|
502
+ | **Auth** | Supabase Auth | Already built, works well, free tier generous |
503
+ | **Metadata** | Supabase Postgres | Backup history, user profiles, sharing permissions |
504
+ | **File Storage** | Cloudflare R2 | Zero egress fees, S3-compatible, $0.015/GB/mo |
505
+ | **Edge Logic** | Supabase Edge Functions or Cloudflare Workers | Sharing links, webhook handlers |
506
+
507
+ **Why R2 over Supabase Storage for v3:**
508
+ - Zero egress = restores are free no matter how large
509
+ - S3-compatible API = can switch backends later
510
+ - Better for large bundles (AI session files can be 10-50MB)
511
+ - Current Supabase Storage works fine for v2 scale; R2 is the v3 scaling play
512
+
513
+ **Migration path:** Keep Supabase Storage for now. Add R2 as an option behind a storage abstraction. Switch default when R2 proves stable.
514
+
515
+ ### Storage Layout (R2)
516
+
517
+ ```
518
+ memoir-backups/
519
+ ├── {user_id}/
520
+ │ ├── objects/ # Content-addressed chunks
521
+ │ │ ├── ab/cd1234... # Encrypted chunk
522
+ │ │ └── ef/gh5678...
523
+ │ ├── snapshots/ # Snapshot manifests
524
+ │ │ ├── v001.json.enc # Encrypted manifest
525
+ │ │ ├── v002.json.enc
526
+ │ │ └── latest.json.enc
527
+ │ └── shared/ # Shared context bundles
528
+ │ └── {share_id}.json.enc
529
+ ```
530
+
531
+ ### Cost Projections
532
+
533
+ For a typical developer (5 AI tools, ~2MB of config/memory, daily pushes):
534
+
535
+ | Scale | Storage | R2 Cost/mo | Supabase Cost/mo | Total |
536
+ |-------|---------|-----------|------------------|-------|
537
+ | 100 users | ~500MB | $0.01 | $0 (free tier) | ~$0 |
538
+ | 1,000 users | ~5GB | $0.08 | $0 (free tier) | ~$0 |
539
+ | 10,000 users | ~50GB | $0.75 | $25 (Pro) | ~$26 |
540
+ | 100,000 users | ~500GB | $7.50 | $25 (Pro) | ~$33 |
541
+
542
+ At $5/mo Pro pricing, 100 paid users = $500 MRR with ~$33 infra cost. The margins are absurd.
543
+
544
+ ### Alternative: Git Bundles as Transport
545
+
546
+ The current codebase already supports git as a storage backend. Git bundles could be an interesting transport layer:
547
+
548
+ ```bash
549
+ # Create a bundle (like a portable git repo)
550
+ git bundle create memoir-backup.bundle --all
551
+
552
+ # Incremental bundle (only new commits since last push)
553
+ git bundle create memoir-incremental.bundle main..HEAD
554
+ ```
555
+
556
+ **Pros:** Built-in dedup, compression, incremental sync. Git is everywhere.
557
+ **Cons:** Overhead of maintaining a git repo per user. Not great for binary files (AI session JSONL can be large). Requires git installed.
558
+
559
+ **Verdict:** Use CAS for file storage, but keep the existing git provider as an option for users who want self-hosted/private backup.
560
+
561
+ ---
562
+
563
+ ## Implementation Roadmap
564
+
565
+ ### Phase 1: Enhanced Context Capture (v2.6 — 2 weeks)
566
+
567
+ Enhance what already exists with zero new infrastructure:
568
+
569
+ - [ ] Make `memoir push` capture git state (branch, status, recent commits) alongside AI configs
570
+ - [ ] Make `memoir snapshot --smart` the default (with fallback if no API key)
571
+ - [ ] Add structured context extraction (decisions, blockers, next steps) to snapshot
572
+ - [ ] Add `memoir push --project` to include git diff/status in the bundle
573
+ - [ ] Enhance `memoir resume --inject` to generate richer handoff documents
574
+
575
+ **Why first:** Immediate value, no backend changes, can ship to existing users today.
576
+
577
+ ### Phase 2: Incremental Sync + Encryption (v2.8 — 3 weeks)
578
+
579
+ Replace the current "upload full gzip every time" with smart sync:
580
+
581
+ - [ ] Implement content-addressable chunk storage (fixed-size chunks first)
582
+ - [ ] Add hash-based dedup (skip uploading chunks that already exist)
583
+ - [ ] Add E2E encryption with tweetnacl (generate keypair on login, encrypt chunks)
584
+ - [ ] Add zstd compression (replace gzip)
585
+ - [ ] Add conflict detection + resolution for AI config files
586
+
587
+ **Why second:** Makes push/restore 10x faster for repeat users. Encryption unlocks enterprise.
588
+
589
+ ### Phase 3: Universal Context Format + Cross-Tool Intelligence (v3.0 — 4 weeks)
590
+
591
+ The big leap — make context portable across AI tools:
592
+
593
+ - [ ] Define UCF (Universal Context Format) JSON schema
594
+ - [ ] Build context extractors for each supported tool (Claude JSONL, Cursor, Gemini, etc.)
595
+ - [ ] Build context injectors for each tool (generate tool-specific handoff files)
596
+ - [ ] Add `memoir restore --to <tool>` with context translation
597
+ - [ ] Add `memoir migrate --include-context` for full context + config migration
598
+ - [ ] Add time travel: `memoir restore --version N` or `memoir restore --date "yesterday"`
599
+
600
+ ### Phase 4: Sharing + Teams (v3.2 — 3 weeks)
601
+
602
+ The viral/fundable features:
603
+
604
+ - [ ] `memoir share --link` — generate a shareable context URL
605
+ - [ ] `memoir share --to email` — invite a collaborator to your context
606
+ - [ ] Team workspaces — shared AI configs + context across a team
607
+ - [ ] `memoir onboard` — new team member gets full project context in one command
608
+ - [ ] Context permissions (read-only share vs. full sync)
609
+
610
+ ### Phase 5: Real-Time + Watch Mode (v3.5 — 4 weeks)
611
+
612
+ Approach Apple Handoff-level seamlessness:
613
+
614
+ - [ ] `memoir watch` — background daemon that auto-pushes on file changes
615
+ - [ ] WebSocket-based real-time sync (instant push to connected devices)
616
+ - [ ] Notification on restore: "Your Mac just pushed new context — restore?"
617
+ - [ ] Optional: BLE/mDNS discovery for LAN-based sync (zero cloud, like AirDrop)
618
+
619
+ ---
620
+
621
+ ## What Makes This Viral/Fundable
622
+
623
+ ### Positioning: "GitHub for AI Context"
624
+
625
+ GitHub stores your code. memoir stores everything your AI knows about your code. Every developer using AI tools (that's everyone in 2026) has this problem. GitHub solved "where is my code?" — memoir solves "where is my AI's understanding of my code?"
626
+
627
+ ### Viral Mechanics
628
+
629
+ 1. **`memoir share --link`** — Every shared context link is a memoir advertisement. Recipient needs memoir to restore. Free viral loop.
630
+
631
+ 2. **Team onboarding** — "We use memoir for context sharing" becomes a team standard. One person adopts, whole team follows.
632
+
633
+ 3. **`memoir snapshot` output is shareable** — The handoff markdown is useful even without memoir. People share it on Twitter/Discord. "Look how clean this session summary is."
634
+
635
+ 4. **Cross-tool migration** — Already a unique feature. "I switched from Cursor to Claude and memoir kept all my context" is a tweet that writes itself.
636
+
637
+ 5. **Time travel** — "I can restore my AI's understanding from 2 weeks ago" is mind-blowing demo material.
638
+
639
+ ### Revenue Model
640
+
641
+ | Tier | Price | Features |
642
+ |------|-------|----------|
643
+ | **Free** | $0 | 3 snapshots, 2 devices, local sync, git sync |
644
+ | **Pro** | $8/mo | 50 snapshots, unlimited devices, cloud sync, E2E encryption, time travel |
645
+ | **Team** | $12/user/mo | Everything in Pro + shared contexts, team onboarding, admin controls |
646
+
647
+ ### Fundable Signals
648
+
649
+ - **Large TAM:** Every developer using AI coding tools (tens of millions by 2026)
650
+ - **Natural network effects:** Sharing and team features create pull
651
+ - **Low infrastructure cost:** <$50/mo to serve 10K users
652
+ - **Strong retention:** Once your AI context is in memoir, switching is painful (positive lock-in)
653
+ - **Clear expansion path:** Enterprise (SOC2, SSO, audit logs), marketplace (share context templates), API (other tools integrate with memoir)
654
+
655
+ ### Competitive Moat
656
+
657
+ | Feature | memoir | OneContext | Memorix | Codespaces |
658
+ |---------|--------|-----------|---------|------------|
659
+ | Multi-tool config sync | 11 tools | No | 7 tools (MCP) | No |
660
+ | Cross-tool migration | Yes | No | No | No |
661
+ | Session handoff | Yes | Yes | No | No |
662
+ | Context extraction | AI-powered | Manual | No | No |
663
+ | Cross-device sync | Yes | Manual | No | Cloud-only |
664
+ | E2E encryption | Planned | No | No | Microsoft-managed |
665
+ | Time travel | Planned | Yes | No | No |
666
+ | Sharing/Teams | Planned | Link sharing | No | GitHub-native |
667
+ | Works offline | Yes | Yes | Yes | No |
668
+ | Zero vendor lock-in | Yes (self-host option) | Yes | MCP-dependent | GitHub-locked |
669
+
670
+ **memoir's unique position:** It's the only tool that combines config sync + context extraction + cross-tool translation + cloud backup. OneContext is the closest competitor but focuses only on context, not configs. Memorix requires MCP. Codespaces is a different category entirely.
671
+
672
+ ### The Magic Moment
673
+
674
+ A developer works on their Mac all day with Claude Code. At 6 PM:
675
+
676
+ ```bash
677
+ $ memoir push
678
+ Backed up!
679
+ ├─ Claude CLI (12 files, 1.2MB)
680
+ ├─ Cursor (3 files, 4.1KB)
681
+ ├─ Projects (5) (8 files, 12KB)
682
+ └─ Session Context (JWT auth feature, 127 min session)
683
+
684
+ → memoir cloud (v14, 23KB uploaded, 1.1MB deduped)
685
+ ```
686
+
687
+ They go home, open their Windows desktop:
688
+
689
+ ```bash
690
+ $ memoir restore
691
+ Restored from cloud (v14, from macbook-pro)
692
+ ├─ Claude CLI configs restored
693
+ ├─ Cursor rules restored
694
+ ├─ Context injected → Claude knows you were building JWT auth
695
+
696
+ Ready to continue. Your AI remembers everything.
697
+ ```
698
+
699
+ They open Claude Code. It reads the handoff. First message:
700
+
701
+ > "I see you were building JWT authentication. The middleware and login route are done. The token refresh endpoint at `/api/auth/refresh` is in progress — you need to finish the refresh token rotation logic in `src/lib/auth.ts`. Should I pick up where you left off?"
702
+
703
+ **That's the magic.**
704
+
705
+ ---
706
+
707
+ ## Technical Decisions Summary
708
+
709
+ | Decision | Choice | Rationale |
710
+ |----------|--------|-----------|
711
+ | Language | Node.js (existing) | Already built, npm distribution, cross-platform |
712
+ | Storage | R2 (files) + Supabase (auth/meta) | Zero egress + existing auth |
713
+ | Encryption | tweetnacl (X25519 + XChaCha20) | Tiny, zero deps, audited |
714
+ | Compression | zstd level 3 | 3-5x faster than gzip, better ratio |
715
+ | Dedup | SHA-256 content-addressed chunks | Proven approach (Restic/Borg) |
716
+ | Sync model | Snapshot-based (not real-time) | Simpler, fewer conflicts, explicit |
717
+ | Context format | JSON (UCF schema) | Universal, parseable, translatable |
718
+ | Conflict resolution | Last-write-wins + conflict files | Simple, transparent, recoverable |
719
+
720
+ ---
721
+
722
+ *This document is a living plan. The roadmap is sequenced so each phase delivers standalone value — no phase depends on a future phase to be useful. Phase 1 can ship this week.*