memgit 0.1.1__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {memgit-0.1.1 → memgit-0.1.4}/PKG-INFO +75 -160
  2. {memgit-0.1.1 → memgit-0.1.4}/README.md +72 -159
  3. {memgit-0.1.1 → memgit-0.1.4}/memgit/cli.py +181 -16
  4. {memgit-0.1.1 → memgit-0.1.4}/memgit/http_server.py +11 -0
  5. {memgit-0.1.1 → memgit-0.1.4}/memgit/mcp_server.py +4 -0
  6. {memgit-0.1.1 → memgit-0.1.4}/memgit/repo.py +94 -14
  7. {memgit-0.1.1 → memgit-0.1.4}/memgit/tokens.py +15 -8
  8. {memgit-0.1.1 → memgit-0.1.4}/memgit/toon.py +4 -2
  9. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/PKG-INFO +75 -160
  10. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/requires.txt +3 -0
  11. {memgit-0.1.1 → memgit-0.1.4}/pyproject.toml +2 -1
  12. {memgit-0.1.1 → memgit-0.1.4}/tests/test_store_repo.py +38 -0
  13. {memgit-0.1.1 → memgit-0.1.4}/tests/test_toon.py +15 -0
  14. {memgit-0.1.1 → memgit-0.1.4}/LICENSE +0 -0
  15. {memgit-0.1.1 → memgit-0.1.4}/memgit/__init__.py +0 -0
  16. {memgit-0.1.1 → memgit-0.1.4}/memgit/graph.py +0 -0
  17. {memgit-0.1.1 → memgit-0.1.4}/memgit/importer.py +0 -0
  18. {memgit-0.1.1 → memgit-0.1.4}/memgit/models.py +0 -0
  19. {memgit-0.1.1 → memgit-0.1.4}/memgit/scorer.py +0 -0
  20. {memgit-0.1.1 → memgit-0.1.4}/memgit/store.py +0 -0
  21. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/SOURCES.txt +0 -0
  22. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/dependency_links.txt +0 -0
  23. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/entry_points.txt +0 -0
  24. {memgit-0.1.1 → memgit-0.1.4}/memgit.egg-info/top_level.txt +0 -0
  25. {memgit-0.1.1 → memgit-0.1.4}/setup.cfg +0 -0
  26. {memgit-0.1.1 → memgit-0.1.4}/tests/test_advanced.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memgit
3
- Version: 0.1.1
3
+ Version: 0.1.4
4
4
  Summary: Git for AI memory — version-controlled context persistence across Claude, GPT, Gemini, Cursor, Windsurf, and more
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://memgit.dev
@@ -25,22 +25,23 @@ Requires-Dist: mcp>=1.0.0
25
25
  Provides-Extra: dev
26
26
  Requires-Dist: pytest>=8.0; extra == "dev"
27
27
  Requires-Dist: pytest-anyio>=0.0.0; extra == "dev"
28
+ Provides-Extra: tokens
29
+ Requires-Dist: tiktoken>=0.7; extra == "tokens"
28
30
  Dynamic: license-file
29
31
 
32
+ <p align="center">
33
+ <img src="assets/logo.png" alt="memgit logo" width="120" />
34
+ </p>
35
+
30
36
  # memgit — git for AI memory
31
37
 
32
- **Version-controlled, cross-AI context that persists, diffs, rolls back, and syncs like code.**
38
+ **Your AI assistants forget everything when the session ends. memgit fixes that.**
33
39
 
34
- ```bash
35
- pip install memgit
36
- memgit init ~/.claude/memgit-store
37
- memgit setup all # registers with every AI tool detected on your machine
38
- memgit stats # see your token savings vs claude.md / other plugins
39
- ```
40
+ Version-controlled, cross-AI context that persists, diffs, rolls back, and syncs like code. Switch from Claude to Cursor to ChatGPT mid-project — your context is already there.
40
41
 
41
42
  [![PyPI](https://img.shields.io/pypi/v/memgit)](https://pypi.org/project/memgit/)
42
43
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
43
- [![Tests](https://img.shields.io/badge/tests-48%20passing-brightgreen)](tests/)
44
+ [![Tests](https://img.shields.io/badge/tests-54%20passing-brightgreen)](tests/)
44
45
 
45
46
  ---
46
47
 
@@ -53,7 +54,7 @@ You've probably already tried both. Here's why they hit a ceiling:
53
54
  | Loads only relevant context | ❌ loads everything | ⚠️ loads recent observations | ✅ BM25 search — top-k per query |
54
55
  | Version history | ❌ | ❌ | ✅ full commit log |
55
56
  | Diff between sessions | ❌ | ❌ | ✅ `memgit diff` |
56
- | Roll back a wrong memory | ❌ manual edit | ❌ | ✅ `memgit checkout` |
57
+ | Roll back a wrong memory | ❌ manual edit | ❌ | ✅ `memgit rollback` |
57
58
  | Works in Cursor, Windsurf, GPT | ❌ Claude only | ❌ Claude only | ✅ all via MCP / HTTP |
58
59
  | Team sync | ❌ copy-paste files | ❌ | ✅ `memgit git push` |
59
60
  | Scales to 10k+ sessions | ❌ file grows | ❌ search slows | ✅ `memgit squash` |
@@ -76,17 +77,16 @@ $ memgit stats
76
77
  ┌─────────────────────────────────────┬──────────────────┬───────────────────┬─────────────────────┐
77
78
  │ Approach │ Tokens/session │ vs full load │ $/session (GPT-4o) │
78
79
  ├─────────────────────────────────────┼──────────────────┼───────────────────┼─────────────────────┤
79
- │ claude.md / dump all memories │ 12,840 │ 100% baseline │ $0.0642
80
- mem-search plugin (top-20 obs) 6,100 (est.) ~47% │ $0.0305
81
- │ memgit search (BM25 top-8) │ 640 │ 5% (95% savings) │ $0.0032 │
80
+ │ claude.md / dump all memories │ 12,840 │ 100% baseline │ $0.0321
81
+ memgit search (BM25 top-8) 640 │ 5% (95% savings) │ $0.0016
82
82
  └─────────────────────────────────────┴──────────────────┴───────────────────┴─────────────────────┘
83
83
 
84
84
  Weekly savings (10 sessions/week):
85
- Tokens saved: 121,600/week
86
- Cost saved: $0.61/week → $31.70/year (at GPT-4o input pricing)
85
+ Tokens saved: 122,000/week
86
+ Cost saved: $0.31/week → $15.86/year (at GPT-4o input pricing, $2.50/M)
87
87
  ```
88
88
 
89
- **Why such a big difference?** claude.md loads *all* context every session. mem-search loads recent observations. memgit uses BM25 relevance scoring — it loads *only the 8 memories most relevant to the current session*, not everything you've ever recorded.
89
+ **Why such a big difference?** claude.md loads *all* context every session. memgit uses BM25 relevance scoring — it loads *only the 8 memories most relevant to the current session*, not everything you've ever recorded.
90
90
 
91
91
  ---
92
92
 
@@ -106,48 +106,31 @@ memgit's data model maps exactly to git:
106
106
  | `memgit squash --keep-last 100` | `git rebase -i --autosquash` |
107
107
  | `memgit git push` | `git push` |
108
108
 
109
- And this is not metaphorical — memgit uses a **content-addressed object store** (SHA-256 blobs) identical to git's architecture. Every memory has a stable SHA. Identical content has identical SHAs. The object store is tamper-evident.
109
+ This is not metaphorical — memgit uses a **content-addressed object store** (SHA-256 blobs) identical to git's architecture. Every memory has a stable SHA. Identical content has identical SHAs. Old state is always recoverable.
110
110
 
111
111
  ---
112
112
 
113
113
  ## The store IS a git repo
114
114
 
115
- Every memory is a readable `.toon` file under `memories/`. You can push your entire memory set to GitHub with standard git:
116
-
117
- ```bash
118
- cd ~/.claude/memgit-store
119
- git init
120
- git remote add origin git@github.com:yourteam/ai-memory.git
121
- git add memories/ .memgit/refs/
122
- git commit -m "session memories"
123
- git push
124
- ```
125
-
126
- Or use the built-in command:
115
+ Every memory is a readable `.toon` file under `memories/`. Push your entire memory set to GitHub with standard git:
127
116
 
128
117
  ```bash
129
118
  memgit git init --remote git@github.com:yourteam/ai-memory.git
130
119
  memgit git push
131
120
  ```
132
121
 
133
- Teammates pull and get your AI's learned rules, preferences, and lessons instantly:
122
+ Teammates pull and start with your AI's learned rules from session 1:
134
123
 
135
124
  ```bash
136
125
  git clone git@github.com:yourteam/ai-memory.git ~/.claude/memgit-store
137
126
  memgit setup all
138
- # Their AI now knows everything your AI knows — from session 1
139
127
  ```
140
128
 
141
129
  You can `grep`, `git blame`, and `git diff` your memories just like code:
142
130
 
143
131
  ```bash
144
- # Search across all memories
145
132
  grep -rl "database" ~/.claude/memgit-store/memories/
146
-
147
- # See who changed what
148
133
  git log --follow memories/no-db-mock.toon
149
-
150
- # What changed this week?
151
134
  git diff HEAD~7 memories/
152
135
  ```
153
136
 
@@ -155,19 +138,25 @@ git diff HEAD~7 memories/
155
138
 
156
139
  ## Install
157
140
 
141
+ **Mac / Linux:**
158
142
  ```bash
159
143
  pip install memgit
160
144
  ```
161
145
 
162
- Homebrew (after tap published):
146
+ **Mac (Homebrew):**
163
147
  ```bash
164
148
  brew tap code4161/tap && brew install memgit
165
149
  ```
166
150
 
167
- npm (for Node-based tools — no Python needed):
168
- ```bash
169
- # In any AI tool's MCP config:
170
- { "command": "npx", "args": ["-y", "memgit-mcp"] }
151
+ **Windows:**
152
+ ```powershell
153
+ pip install memgit
154
+ ```
155
+ (`choco install memgit` is not live yet — the Chocolatey package is not on community.chocolatey.org. Use pip until it lands.)
156
+
157
+ **Any AI tool config (no Python needed — npx auto-installs on first run):**
158
+ ```json
159
+ { "mcpServers": { "memgit": { "command": "npx", "args": ["-y", "memgit-mcp"] } } }
171
160
  ```
172
161
 
173
162
  ---
@@ -177,21 +166,16 @@ npm (for Node-based tools — no Python needed):
177
166
  ```bash
178
167
  # 1. Install and initialize
179
168
  pip install memgit
180
- memgit init ~/.claude/memgit-store
169
+ memgit init # auto-detects best location (~/.claude/memgit-store etc.)
181
170
 
182
171
  # 2. Import existing memories (if you use Claude Code)
183
- cd ~/.claude/memgit-store
184
172
  memgit import claude-code ~/.claude/projects/
185
173
 
186
- # 3. Register with every AI tool on your machine
187
- memgit setup all
174
+ # 3. Register with your AI tools (interactive picker)
175
+ memgit setup
188
176
 
189
177
  # 4. See your token savings
190
178
  memgit stats
191
-
192
- # 5. Push to share with teammates
193
- memgit git init --remote git@github.com:yourteam/ai-memory.git
194
- memgit git push
195
179
  ```
196
180
 
197
181
  Restart your AI tool — it now searches your memory store at the start of every session.
@@ -200,25 +184,15 @@ Restart your AI tool — it now searches your memory store at the start of every
200
184
 
201
185
  ## Scale to 10,000+ sessions
202
186
 
203
- After months of use, your checkpoint history grows. `memgit squash` handles it — like `git rebase --autosquash` but automatic:
187
+ After months of use, your checkpoint history grows. `memgit squash` handles it:
204
188
 
205
189
  ```bash
206
- # Keep last 100 checkpoints; squash everything older into one baseline
207
- memgit squash --keep-last 100
208
-
209
- # Squash everything older than 30 days
210
- memgit squash --older-than 30
211
-
212
- # Preview first
213
- memgit squash --keep-last 100 --dry-run
214
- # → would squash 847 checkpoints (baseline: 2026-04-01) → keep 100 recent ones
215
-
216
- # After squash: history is compact, current memories are fully preserved
217
- memgit log --oneline # clean, readable history
218
- memgit list # all memories still there
190
+ memgit squash --keep-last 100 # keep last 100 checkpoints, squash everything older
191
+ memgit squash --older-than 30 # squash everything older than 30 days
192
+ memgit squash --dry-run # preview first
219
193
  ```
220
194
 
221
- The current memory **state is always preserved** — squash only compresses the historical chain. At 10 sessions/day, squash once a month to keep history manageable.
195
+ The current memory **state is always preserved** — squash only compresses the historical chain.
222
196
 
223
197
  ---
224
198
 
@@ -234,7 +208,7 @@ Once registered via MCP, every AI tool gets 5 tools:
234
208
  | `save_memory` | When it learns something worth keeping for next time |
235
209
  | `get_checkpoint_log` | To check when memories were last synced |
236
210
 
237
- The tool descriptions tell the AI **when** to call each one — including "call `search_memories` at the start of every session." This is what makes it default behavior, not opt-in.
211
+ The tool descriptions tell the AI **when** to call each one — making it default behavior, not opt-in.
238
212
 
239
213
  ---
240
214
 
@@ -242,50 +216,51 @@ The tool descriptions tell the AI **when** to call each one — including "call
242
216
 
243
217
  ```bash
244
218
  # Core (git-like)
245
- memgit init <dir> # initialize store
246
- memgit add <slug> <rule> # stage a memory
247
- memgit commit -m "message" # checkpoint current state
248
- memgit log # history
249
- memgit diff [sha1] [sha2] # what changed
250
- memgit show <slug> # display a memory
251
- memgit remove <slug> # remove from active index (history preserved)
252
- memgit status # staged changes
253
- memgit search <query> # BM25 relevance search
254
- memgit squash # compress old history
219
+ memgit init # initialize store (auto-detects best path)
220
+ memgit add <slug> <rule> # stage a memory
221
+ memgit commit -m "message" # checkpoint current state
222
+ memgit log # history
223
+ memgit diff [sha1] [sha2] # what changed
224
+ memgit show <slug> # display a memory
225
+ memgit remove <slug> # remove from active index (history preserved)
226
+ memgit status # staged changes
227
+ memgit search <query> # BM25 relevance search
228
+ memgit rollback <ref> # restore state to a checkpoint (HEAD~N or SHA)
229
+ memgit squash # compress old history
255
230
 
256
231
  # Scale & proof
257
- memgit stats # token savings vs alternatives
258
- memgit lint # validate all memories
259
- memgit fsck # verify store integrity
232
+ memgit stats # token savings vs alternatives
233
+ memgit lint # validate all memories
234
+ memgit fsck # verify store integrity
260
235
 
261
236
  # Import / export
262
- memgit sync # sync from Claude Code files + commit
237
+ memgit sync # sync from Claude Code files + commit
263
238
  memgit import claude-code <path>
264
239
  memgit import file <path>
265
240
  memgit export <slug>
266
241
 
267
242
  # Git sync (team features)
268
- memgit git init [--remote URL] # initialize git in the store
243
+ memgit git init [--remote URL]
269
244
  memgit git push [remote] [branch]
270
245
  memgit git pull [remote] [branch]
271
- memgit git export # write flat memories/ files
272
- memgit git status # changes since last git commit
246
+ memgit git export
247
+ memgit git status
273
248
 
274
249
  # AI tool registration
275
- memgit setup all
250
+ memgit setup # interactive step-by-step picker
251
+ memgit setup all # auto-register every detected tool
276
252
  memgit setup claude-code
277
253
  memgit setup cursor
278
254
  memgit setup windsurf
279
255
  memgit setup cline
280
256
  memgit setup continue
281
- memgit setup print-config <tool>
282
257
 
283
258
  # Server
284
- memgit serve # MCP stdio (Claude Code, Cursor, Windsurf, Cline)
285
- memgit serve --http # HTTP REST (ChatGPT Custom Actions, Gemini)
259
+ memgit serve # MCP stdio (Claude Code, Cursor, Windsurf, Cline)
260
+ memgit serve --http # HTTP REST (ChatGPT Custom Actions, Gemini)
286
261
 
287
262
  # Visualization
288
- memgit graph # D3.js interactive relationship map
263
+ memgit graph # D3.js interactive relationship map
289
264
  memgit thread list / switch / create
290
265
  ```
291
266
 
@@ -307,33 +282,9 @@ memgit thread list / switch / create
307
282
 
308
283
  ---
309
284
 
310
- ## Default in every session no manual steps
311
-
312
- `memgit setup claude-code` installs a Stop hook that auto-syncs memories when you end a session:
313
-
314
- ```json
315
- // ~/.claude/settings.json (added automatically)
316
- {
317
- "hooks": {
318
- "Stop": [{
319
- "hooks": [{
320
- "type": "command",
321
- "command": "cd ~/.claude/memgit-store && memgit sync 2>/dev/null || true",
322
- "async": true
323
- }]
324
- }]
325
- }
326
- }
327
- ```
328
-
329
- And the MCP server's `search_memories` description tells every AI: *"call this at the start of every session."* This is enforced in the tool schema — the AI sees it as a required step, not an option.
330
-
331
- ---
332
-
333
- ## TOON format — why it's 40–55% more token-efficient
334
-
335
- Standard markdown memory file (what claude.md uses):
285
+ ## TOON formatcompact, readable, diffable
336
286
 
287
+ Standard markdown memory file:
337
288
  ```markdown
338
289
  ## Rule: Never mock the database in tests
339
290
  **Type:** feedback
@@ -342,10 +293,8 @@ Standard markdown memory file (what claude.md uses):
342
293
  **When to apply:** Any time writing tests that touch persistence layers.
343
294
  **Tags:** testing, database
344
295
  ```
345
- *Token count: ~62*
346
296
 
347
297
  The same memory in TOON:
348
-
349
298
  ```
350
299
  TOON1|fb|no-db-mock|2026-07-01T10:00Z
351
300
  #testing #database
@@ -353,42 +302,12 @@ RULE:Never mock the database in tests
353
302
  WHY:Mocked tests passed but prod migration failed last quarter
354
303
  WHEN:Any persistence test
355
304
  ```
356
- *Token count: ~35* **→ 44% fewer tokens for identical content**
357
-
358
- At 108 memories: **12,840 tokens (markdown) → 7,100 tokens (TOON) → 640 tokens (memgit search top-8)**
359
-
360
- ---
361
-
362
- ## The business case — agent memory is the next asset class
363
305
 
364
- Source code is version-controlled because it's a company's primary asset. In 2026, **agent memory is equally valuable**:
306
+ Measured with a real tokenizer, TOON is ~5–10% leaner than equivalent markdown a nice bonus, not the headline. **The headline saving is retrieval**: memgit loads the top-8 relevant memories per query instead of everything.
365
307
 
366
- - Every AI session produces learned rules, discovered preferences, fixed mistakes
367
- - Today: these vanish when the session ends, or accumulate in unversioned markdown files
368
- - Tomorrow: teams will track, audit, merge, and ship their AI context as carefully as they ship code
308
+ At 108 memories: **12,840 tokens (dump everything) 640 tokens (memgit BM25 top-8)**
369
309
 
370
- memgit is the git layer for that transition. Built for the moment when "what did the AI know when it made that decision?" becomes as important as "who wrote that line of code?"
371
-
372
- ---
373
-
374
- ## Team workflow
375
-
376
- ```
377
- # Day 1: Set up shared memory
378
- memgit git init --remote git@github.com:acme/ai-memory.git
379
- memgit git push
380
-
381
- # Every session: memories auto-sync via Stop hook
382
- [session ends] → memgit sync → new checkpoint created
383
-
384
- # Weekly: push to share with team
385
- memgit git push
386
-
387
- # New teammate joins:
388
- git clone git@github.com:acme/ai-memory.git ~/.claude/memgit-store
389
- memgit setup all
390
- # Their AI starts with 6 months of team-learned context — Day 1
391
- ```
310
+ For exact token counts in `memgit stats`, install the optional tokenizer: `pip install "memgit[tokens]"`.
392
311
 
393
312
  ---
394
313
 
@@ -399,19 +318,13 @@ memgit setup all
399
318
  .memgit/
400
319
  objects/ ← SHA-256 content-addressed blobs (gzip compressed)
401
320
  refs/threads/main ← HEAD checkpoint SHA
402
- TOON_INDEX ← active slug→sha mapping (cache, recoverable via fsck)
321
+ TOON_INDEX ← active slug→sha mapping
403
322
  config ← author, default thread
404
323
  logs/ ← ref change audit trail
405
324
  memories/ ← flat .toon files (git-trackable, human-readable)
406
- no-db-mock.toon
407
- trading-rules.toon
408
- ...
409
325
  .git/ ← standard git repo (after `memgit git init`)
410
- .gitignore ← excludes .memgit/objects/ (binary blobs)
411
326
  ```
412
327
 
413
- The object store is **content-addressed**: same memory content = same SHA = stored once. Modifying a memory creates a new object and a new checkpoint pointing to it. Old state is always recoverable.
414
-
415
328
  ---
416
329
 
417
330
  ## Contributing
@@ -431,7 +344,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
431
344
  ## Roadmap
432
345
 
433
346
  - [x] Content-addressed object store (git-identical architecture)
434
- - [x] TOON format (40–55% token reduction vs markdown)
347
+ - [x] TOON format (compact line-oriented memory format)
435
348
  - [x] MCP server — Claude Code, Cursor, Windsurf, Cline, Continue.dev
436
349
  - [x] HTTP server — ChatGPT Custom Actions, Gemini function calling
437
350
  - [x] BM25 relevance search (load only what matters)
@@ -440,12 +353,14 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
440
353
  - [x] `memgit git push/pull` — team sync via standard git
441
354
  - [x] Flat `memories/` directory — grep/diff/blame your memories
442
355
  - [x] D3.js graph visualization of memory relationships
443
- - [x] Multi-platform distribution (PyPI, Homebrew, npm, Chocolatey, winget)
444
- - [ ] PyPI publish (v0.1.0)
445
- - [ ] VS Code extension (Phase 3)
356
+ - [x] PyPI + Homebrew (tap) + npm published (v0.1.4)
357
+ - [ ] Chocolatey (not yet live on community.chocolatey.org)
358
+ - [x] Interactive setup wizard (`memgit setup`)
359
+ - [x] Smart `memgit init` (auto-detects tool, no path needed)
360
+ - [x] VS Code extension (v0.1.4, Marketplace: code416-memgit.memgit)
446
361
  - [ ] JetBrains plugin (Phase 3)
447
362
  - [ ] Semantic search via embeddings (Phase 4)
448
- - [ ] memgit.dev website (Phase 4)
363
+ - [x] memgit.dev website (live)
449
364
  - [ ] Memory compression / auto-summarization (Phase 5)
450
365
  - [ ] Team access control + audit trail (Phase 5)
451
366
  - [ ] Memory marketplace — share reusable context packs (Phase 6)