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