memgit 0.1.1__py3-none-any.whl

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.
@@ -0,0 +1,457 @@
1
+ Metadata-Version: 2.4
2
+ Name: memgit
3
+ Version: 0.1.1
4
+ Summary: Git for AI memory — version-controlled context persistence across Claude, GPT, Gemini, Cursor, Windsurf, and more
5
+ License: MIT
6
+ Project-URL: Homepage, https://memgit.dev
7
+ Project-URL: Repository, https://github.com/code4161/memgit
8
+ Project-URL: Documentation, https://memgit.dev/docs
9
+ Project-URL: Bug Tracker, https://github.com/code4161/memgit/issues
10
+ Keywords: ai,memory,mcp,claude,cursor,windsurf,llm,context,version-control,agent,chatgpt,gemini
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: click>=8.0
23
+ Requires-Dist: rich>=13.0
24
+ Requires-Dist: mcp>=1.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: pytest-anyio>=0.0.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # memgit — git for AI memory
31
+
32
+ **Version-controlled, cross-AI context that persists, diffs, rolls back, and syncs like code.**
33
+
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
+
41
+ [![PyPI](https://img.shields.io/pypi/v/memgit)](https://pypi.org/project/memgit/)
42
+ [![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
+
45
+ ---
46
+
47
+ ## Why not claude.md? Why not mem-search?
48
+
49
+ You've probably already tried both. Here's why they hit a ceiling:
50
+
51
+ | Capability | claude.md | mem-search plugin | **memgit** |
52
+ |---|---|---|---|
53
+ | Loads only relevant context | ❌ loads everything | ⚠️ loads recent observations | ✅ BM25 search — top-k per query |
54
+ | Version history | ❌ | ❌ | ✅ full commit log |
55
+ | Diff between sessions | ❌ | ❌ | ✅ `memgit diff` |
56
+ | Roll back a wrong memory | ❌ manual edit | ❌ | ✅ `memgit checkout` |
57
+ | Works in Cursor, Windsurf, GPT | ❌ Claude only | ❌ Claude only | ✅ all via MCP / HTTP |
58
+ | Team sync | ❌ copy-paste files | ❌ | ✅ `memgit git push` |
59
+ | Scales to 10k+ sessions | ❌ file grows | ❌ search slows | ✅ `memgit squash` |
60
+ | Measurable token savings | ❌ | ❌ | ✅ `memgit stats` |
61
+ | Export / import standard format | ❌ | ❌ | ✅ TOON + git |
62
+
63
+ ---
64
+
65
+ ## Proof — token savings you can measure
66
+
67
+ Run this on your own store to see the actual numbers:
68
+
69
+ ```
70
+ $ memgit stats
71
+
72
+ Total memories: 108 (41 feedback · 23 user · 19 project · 12 reference · 8 convention · 5 lesson)
73
+ Priority: 3 critical · 67 medium · 38 low
74
+
75
+ Token cost comparison:
76
+ ┌─────────────────────────────────────┬──────────────────┬───────────────────┬─────────────────────┐
77
+ │ Approach │ Tokens/session │ vs full load │ $/session (GPT-4o) │
78
+ ├─────────────────────────────────────┼──────────────────┼───────────────────┼─────────────────────┤
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 │
82
+ └─────────────────────────────────────┴──────────────────┴───────────────────┴─────────────────────┘
83
+
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)
87
+ ```
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.
90
+
91
+ ---
92
+
93
+ ## The git analogy is literal
94
+
95
+ memgit's data model maps exactly to git:
96
+
97
+ | memgit | git |
98
+ |---|---|
99
+ | `mnemonic` | file |
100
+ | `MindState` | tree |
101
+ | `checkpoint` | commit |
102
+ | `thread` | branch |
103
+ | `memgit commit` | `git commit` |
104
+ | `memgit diff` | `git diff` |
105
+ | `memgit log` | `git log` |
106
+ | `memgit squash --keep-last 100` | `git rebase -i --autosquash` |
107
+ | `memgit git push` | `git push` |
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.
110
+
111
+ ---
112
+
113
+ ## The store IS a git repo
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:
127
+
128
+ ```bash
129
+ memgit git init --remote git@github.com:yourteam/ai-memory.git
130
+ memgit git push
131
+ ```
132
+
133
+ Teammates pull and get your AI's learned rules, preferences, and lessons instantly:
134
+
135
+ ```bash
136
+ git clone git@github.com:yourteam/ai-memory.git ~/.claude/memgit-store
137
+ memgit setup all
138
+ # Their AI now knows everything your AI knows — from session 1
139
+ ```
140
+
141
+ You can `grep`, `git blame`, and `git diff` your memories just like code:
142
+
143
+ ```bash
144
+ # Search across all memories
145
+ grep -rl "database" ~/.claude/memgit-store/memories/
146
+
147
+ # See who changed what
148
+ git log --follow memories/no-db-mock.toon
149
+
150
+ # What changed this week?
151
+ git diff HEAD~7 memories/
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Install
157
+
158
+ ```bash
159
+ pip install memgit
160
+ ```
161
+
162
+ Homebrew (after tap published):
163
+ ```bash
164
+ brew tap code4161/tap && brew install memgit
165
+ ```
166
+
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"] }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Quickstart (3 minutes)
176
+
177
+ ```bash
178
+ # 1. Install and initialize
179
+ pip install memgit
180
+ memgit init ~/.claude/memgit-store
181
+
182
+ # 2. Import existing memories (if you use Claude Code)
183
+ cd ~/.claude/memgit-store
184
+ memgit import claude-code ~/.claude/projects/
185
+
186
+ # 3. Register with every AI tool on your machine
187
+ memgit setup all
188
+
189
+ # 4. See your token savings
190
+ 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
+ ```
196
+
197
+ Restart your AI tool — it now searches your memory store at the start of every session.
198
+
199
+ ---
200
+
201
+ ## Scale to 10,000+ sessions
202
+
203
+ After months of use, your checkpoint history grows. `memgit squash` handles it — like `git rebase --autosquash` but automatic:
204
+
205
+ ```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
219
+ ```
220
+
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.
222
+
223
+ ---
224
+
225
+ ## What the AI sees
226
+
227
+ Once registered via MCP, every AI tool gets 5 tools:
228
+
229
+ | Tool | When the AI uses it |
230
+ |---|---|
231
+ | `search_memories` | Start of every session — loads relevant context automatically |
232
+ | `get_memory` | When it needs full details of a specific memory |
233
+ | `list_memories` | To browse or audit what's stored |
234
+ | `save_memory` | When it learns something worth keeping for next time |
235
+ | `get_checkpoint_log` | To check when memories were last synced |
236
+
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.
238
+
239
+ ---
240
+
241
+ ## Commands
242
+
243
+ ```bash
244
+ # 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
255
+
256
+ # Scale & proof
257
+ memgit stats # token savings vs alternatives
258
+ memgit lint # validate all memories
259
+ memgit fsck # verify store integrity
260
+
261
+ # Import / export
262
+ memgit sync # sync from Claude Code files + commit
263
+ memgit import claude-code <path>
264
+ memgit import file <path>
265
+ memgit export <slug>
266
+
267
+ # Git sync (team features)
268
+ memgit git init [--remote URL] # initialize git in the store
269
+ memgit git push [remote] [branch]
270
+ memgit git pull [remote] [branch]
271
+ memgit git export # write flat memories/ files
272
+ memgit git status # changes since last git commit
273
+
274
+ # AI tool registration
275
+ memgit setup all
276
+ memgit setup claude-code
277
+ memgit setup cursor
278
+ memgit setup windsurf
279
+ memgit setup cline
280
+ memgit setup continue
281
+ memgit setup print-config <tool>
282
+
283
+ # Server
284
+ memgit serve # MCP stdio (Claude Code, Cursor, Windsurf, Cline)
285
+ memgit serve --http # HTTP REST (ChatGPT Custom Actions, Gemini)
286
+
287
+ # Visualization
288
+ memgit graph # D3.js interactive relationship map
289
+ memgit thread list / switch / create
290
+ ```
291
+
292
+ ---
293
+
294
+ ## AI tool support
295
+
296
+ | Tool | Protocol | Command |
297
+ |---|---|---|
298
+ | **Claude Code** | MCP stdio | `memgit setup claude-code` |
299
+ | **Claude Desktop** | MCP stdio | `memgit setup claude-desktop` |
300
+ | **Cursor** | MCP stdio | `memgit setup cursor` |
301
+ | **Windsurf** | MCP stdio | `memgit setup windsurf` |
302
+ | **Cline / Roo-Code** | MCP stdio | `memgit setup cline` |
303
+ | **Continue.dev** | MCP stdio | `memgit setup continue` |
304
+ | **ChatGPT (Custom Actions)** | HTTP + OpenAPI | `memgit serve --http` → import `http://localhost:7474/openapi.json` |
305
+ | **Gemini API** | HTTP function calling | `memgit serve --http` + `llm-tool-definitions.json` |
306
+ | **Any MCP tool** | MCP stdio | Add `{"command": "memgit", "args": ["serve"]}` to config |
307
+
308
+ ---
309
+
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):
336
+
337
+ ```markdown
338
+ ## Rule: Never mock the database in tests
339
+ **Type:** feedback
340
+ **Priority:** medium
341
+ **Why:** We got burned last quarter — mocked tests passed but the prod migration failed.
342
+ **When to apply:** Any time writing tests that touch persistence layers.
343
+ **Tags:** testing, database
344
+ ```
345
+ *Token count: ~62*
346
+
347
+ The same memory in TOON:
348
+
349
+ ```
350
+ TOON1|fb|no-db-mock|2026-07-01T10:00Z
351
+ #testing #database
352
+ RULE:Never mock the database in tests
353
+ WHY:Mocked tests passed but prod migration failed last quarter
354
+ WHEN:Any persistence test
355
+ ```
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
+
364
+ Source code is version-controlled because it's a company's primary asset. In 2026, **agent memory is equally valuable**:
365
+
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
369
+
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
+ ```
392
+
393
+ ---
394
+
395
+ ## Architecture
396
+
397
+ ```
398
+ ~/.claude/memgit-store/
399
+ .memgit/
400
+ objects/ ← SHA-256 content-addressed blobs (gzip compressed)
401
+ refs/threads/main ← HEAD checkpoint SHA
402
+ TOON_INDEX ← active slug→sha mapping (cache, recoverable via fsck)
403
+ config ← author, default thread
404
+ logs/ ← ref change audit trail
405
+ memories/ ← flat .toon files (git-trackable, human-readable)
406
+ no-db-mock.toon
407
+ trading-rules.toon
408
+ ...
409
+ .git/ ← standard git repo (after `memgit git init`)
410
+ .gitignore ← excludes .memgit/objects/ (binary blobs)
411
+ ```
412
+
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
+ ---
416
+
417
+ ## Contributing
418
+
419
+ ```bash
420
+ git clone https://github.com/code4161/memgit.git
421
+ cd memgit
422
+ python -m venv .venv && source .venv/bin/activate
423
+ pip install -e ".[dev]"
424
+ pytest # 48 tests, all passing, < 1 second
425
+ ```
426
+
427
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
428
+
429
+ ---
430
+
431
+ ## Roadmap
432
+
433
+ - [x] Content-addressed object store (git-identical architecture)
434
+ - [x] TOON format (40–55% token reduction vs markdown)
435
+ - [x] MCP server — Claude Code, Cursor, Windsurf, Cline, Continue.dev
436
+ - [x] HTTP server — ChatGPT Custom Actions, Gemini function calling
437
+ - [x] BM25 relevance search (load only what matters)
438
+ - [x] `memgit stats` — measured token savings proof
439
+ - [x] `memgit squash` — scale to 10k+ sessions
440
+ - [x] `memgit git push/pull` — team sync via standard git
441
+ - [x] Flat `memories/` directory — grep/diff/blame your memories
442
+ - [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)
446
+ - [ ] JetBrains plugin (Phase 3)
447
+ - [ ] Semantic search via embeddings (Phase 4)
448
+ - [ ] memgit.dev website (Phase 4)
449
+ - [ ] Memory compression / auto-summarization (Phase 5)
450
+ - [ ] Team access control + audit trail (Phase 5)
451
+ - [ ] Memory marketplace — share reusable context packs (Phase 6)
452
+
453
+ ---
454
+
455
+ ## License
456
+
457
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,18 @@
1
+ memgit/__init__.py,sha256=YX3sDj3VlMaAOvPAE59zmyIjzcXsawrcg5S2YqFLgb8,59
2
+ memgit/cli.py,sha256=zlJoDOjM_3JNp_GRbmTHGB0l_vOrOCzG-VnOtUAo8-U,48082
3
+ memgit/graph.py,sha256=riWtKgavz1ofLxFD6m0AIKQJ__Dy3WqtdDUf4tGnF8I,18352
4
+ memgit/http_server.py,sha256=dy-DY4LKK2id-CgPEtlR-n973gMOfPTQBiteWlnHDNU,8179
5
+ memgit/importer.py,sha256=ko3o_58YdgVa2KaFMXNZGYDKKciGD3PxAwu18Bna8Hc,3514
6
+ memgit/mcp_server.py,sha256=od2kb3hEled_3WnmkSXQkqg9gijnGSIegeybhNqqb8A,17299
7
+ memgit/models.py,sha256=0TfTezF3o92LLG5UAGVMBVzyD9CVEwluVc63NmFMaWo,2392
8
+ memgit/repo.py,sha256=XPfKWB41EMq2UFXBObczJcwWF6JbgjhZ3u26sjiQjik,29289
9
+ memgit/scorer.py,sha256=ANiNTuFYN36T7Eo66TxhZThdjkLhUk8jnrc4J8iIbww,3181
10
+ memgit/store.py,sha256=aAQrfes_MHAqCNNVqxUGh11R2h5JOPcH50cmyRDnGXU,6675
11
+ memgit/tokens.py,sha256=fP5Dtk2sMXoZ8iOE8FXqhrs8W63wSfx672nheEUSsZM,1646
12
+ memgit/toon.py,sha256=FW1-aevSkRKfY1S9CD20VlYbNZu6nRxMw_IWSVdRk3U,10580
13
+ memgit-0.1.1.dist-info/licenses/LICENSE,sha256=sbcU08PiTvrqxXMSq3P74UuRGLarI4SFpBUX0QrQNZA,1077
14
+ memgit-0.1.1.dist-info/METADATA,sha256=8fG-mvS0WiTLy-6Vb9l3iG_WmTKzvihNrBUsFMonb54,15888
15
+ memgit-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ memgit-0.1.1.dist-info/entry_points.txt,sha256=HKhqsO3yLOq1GqQt2gZt8whriyGE_S-qCF3FiV486w8,42
17
+ memgit-0.1.1.dist-info/top_level.txt,sha256=ij9EYBuat7r1Y--0HnG-QQKFacmBJSu01jViw9a77xI,7
18
+ memgit-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ memgit = memgit.cli:cli
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hari Hara Sankar K A
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 @@
1
+ memgit