agmem 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.
- agmem-0.1.1.dist-info/METADATA +656 -0
- agmem-0.1.1.dist-info/RECORD +67 -0
- agmem-0.1.1.dist-info/WHEEL +5 -0
- agmem-0.1.1.dist-info/entry_points.txt +2 -0
- agmem-0.1.1.dist-info/licenses/LICENSE +21 -0
- agmem-0.1.1.dist-info/top_level.txt +1 -0
- memvcs/__init__.py +9 -0
- memvcs/cli.py +178 -0
- memvcs/commands/__init__.py +23 -0
- memvcs/commands/add.py +258 -0
- memvcs/commands/base.py +23 -0
- memvcs/commands/blame.py +169 -0
- memvcs/commands/branch.py +110 -0
- memvcs/commands/checkout.py +101 -0
- memvcs/commands/clean.py +76 -0
- memvcs/commands/clone.py +91 -0
- memvcs/commands/commit.py +174 -0
- memvcs/commands/daemon.py +267 -0
- memvcs/commands/diff.py +157 -0
- memvcs/commands/fsck.py +203 -0
- memvcs/commands/garden.py +107 -0
- memvcs/commands/graph.py +151 -0
- memvcs/commands/init.py +61 -0
- memvcs/commands/log.py +103 -0
- memvcs/commands/mcp.py +59 -0
- memvcs/commands/merge.py +88 -0
- memvcs/commands/pull.py +65 -0
- memvcs/commands/push.py +143 -0
- memvcs/commands/reflog.py +52 -0
- memvcs/commands/remote.py +51 -0
- memvcs/commands/reset.py +98 -0
- memvcs/commands/search.py +163 -0
- memvcs/commands/serve.py +54 -0
- memvcs/commands/show.py +125 -0
- memvcs/commands/stash.py +97 -0
- memvcs/commands/status.py +112 -0
- memvcs/commands/tag.py +117 -0
- memvcs/commands/test.py +132 -0
- memvcs/commands/tree.py +156 -0
- memvcs/core/__init__.py +21 -0
- memvcs/core/config_loader.py +245 -0
- memvcs/core/constants.py +12 -0
- memvcs/core/diff.py +380 -0
- memvcs/core/gardener.py +466 -0
- memvcs/core/hooks.py +151 -0
- memvcs/core/knowledge_graph.py +381 -0
- memvcs/core/merge.py +474 -0
- memvcs/core/objects.py +323 -0
- memvcs/core/pii_scanner.py +343 -0
- memvcs/core/refs.py +447 -0
- memvcs/core/remote.py +278 -0
- memvcs/core/repository.py +522 -0
- memvcs/core/schema.py +414 -0
- memvcs/core/staging.py +227 -0
- memvcs/core/storage/__init__.py +72 -0
- memvcs/core/storage/base.py +359 -0
- memvcs/core/storage/gcs.py +308 -0
- memvcs/core/storage/local.py +182 -0
- memvcs/core/storage/s3.py +369 -0
- memvcs/core/test_runner.py +371 -0
- memvcs/core/vector_store.py +313 -0
- memvcs/integrations/__init__.py +5 -0
- memvcs/integrations/mcp_server.py +267 -0
- memvcs/integrations/web_ui/__init__.py +1 -0
- memvcs/integrations/web_ui/server.py +352 -0
- memvcs/utils/__init__.py +9 -0
- memvcs/utils/helpers.py +178 -0
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agmem
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Agentic Memory Version Control System - Git for AI agent memories
|
|
5
|
+
Home-page: https://github.com/vivek-tiwari-vt/agmem
|
|
6
|
+
Author: agmem Team
|
|
7
|
+
Author-email: agmem Team <team@agmem.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/vivek-tiwari-vt/agmem
|
|
10
|
+
Project-URL: Documentation, https://github.com/vivek-tiwari-vt/agmem#readme
|
|
11
|
+
Project-URL: Repository, https://github.com/vivek-tiwari-vt/agmem
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/vivek-tiwari-vt/agmem/issues
|
|
13
|
+
Keywords: ai,agent,memory,version-control,git,vcs,llm
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
36
|
+
Provides-Extra: mcp
|
|
37
|
+
Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
38
|
+
Provides-Extra: vector
|
|
39
|
+
Requires-Dist: sqlite-vec>=0.1.0; extra == "vector"
|
|
40
|
+
Requires-Dist: sentence-transformers>=2.0.0; extra == "vector"
|
|
41
|
+
Provides-Extra: web
|
|
42
|
+
Requires-Dist: fastapi>=0.100.0; extra == "web"
|
|
43
|
+
Requires-Dist: uvicorn>=0.22.0; extra == "web"
|
|
44
|
+
Provides-Extra: cloud
|
|
45
|
+
Requires-Dist: boto3>=1.34.0; extra == "cloud"
|
|
46
|
+
Requires-Dist: google-cloud-storage>=2.0.0; extra == "cloud"
|
|
47
|
+
Provides-Extra: gardener
|
|
48
|
+
Requires-Dist: scikit-learn>=1.3.0; extra == "gardener"
|
|
49
|
+
Requires-Dist: openai>=1.0.0; extra == "gardener"
|
|
50
|
+
Provides-Extra: pii
|
|
51
|
+
Requires-Dist: presidio-analyzer>=2.2.0; extra == "pii"
|
|
52
|
+
Provides-Extra: daemon
|
|
53
|
+
Requires-Dist: watchdog>=3.0.0; extra == "daemon"
|
|
54
|
+
Provides-Extra: graph
|
|
55
|
+
Requires-Dist: networkx>=3.0; extra == "graph"
|
|
56
|
+
Provides-Extra: all
|
|
57
|
+
Requires-Dist: mcp>=1.0.0; extra == "all"
|
|
58
|
+
Requires-Dist: sqlite-vec>=0.1.0; extra == "all"
|
|
59
|
+
Requires-Dist: sentence-transformers>=2.0.0; extra == "all"
|
|
60
|
+
Requires-Dist: fastapi>=0.100.0; extra == "all"
|
|
61
|
+
Requires-Dist: uvicorn>=0.22.0; extra == "all"
|
|
62
|
+
Requires-Dist: boto3>=1.34.0; extra == "all"
|
|
63
|
+
Requires-Dist: google-cloud-storage>=2.0.0; extra == "all"
|
|
64
|
+
Requires-Dist: scikit-learn>=1.3.0; extra == "all"
|
|
65
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
66
|
+
Requires-Dist: watchdog>=3.0.0; extra == "all"
|
|
67
|
+
Requires-Dist: networkx>=3.0; extra == "all"
|
|
68
|
+
Dynamic: author
|
|
69
|
+
Dynamic: home-page
|
|
70
|
+
Dynamic: license-file
|
|
71
|
+
Dynamic: requires-python
|
|
72
|
+
|
|
73
|
+
# agmem - Agentic Memory Version Control System
|
|
74
|
+
|
|
75
|
+
[](https://www.python.org/downloads/)
|
|
76
|
+
[](https://opensource.org/licenses/MIT)
|
|
77
|
+
[](https://github.com/psf/black)
|
|
78
|
+
|
|
79
|
+
> **Git for AI Agent Memories**
|
|
80
|
+
|
|
81
|
+
agmem is a version control system specifically designed for AI agent memory artifacts. It brings Git's proven concepts—commits, branches, merging, and distributed collaboration—to the world of agent episodic logs, semantic knowledge, and procedural workflows.
|
|
82
|
+
|
|
83
|
+
## Why agmem?
|
|
84
|
+
|
|
85
|
+
AI agents accumulate vast amounts of memory: conversation histories, learned facts, user preferences, and problem-solving strategies. But unlike code, agent memory lacks:
|
|
86
|
+
|
|
87
|
+
- **Version history** - See what an agent learned and when
|
|
88
|
+
- **Branching** - Experiment safely with different memory strategies
|
|
89
|
+
- **Merging** - Combine knowledge from multiple agents
|
|
90
|
+
- **Collaboration** - Share and fork agent memories
|
|
91
|
+
- **Rollback** - Undo when agents learn the wrong things
|
|
92
|
+
|
|
93
|
+
agmem solves all of these problems with a familiar Git-like interface.
|
|
94
|
+
|
|
95
|
+
## Features
|
|
96
|
+
|
|
97
|
+
- ✅ **Git-like workflow** — `init`, `add`, `commit`, `status`, `log`, `branch`, `checkout`, `merge`, `diff`, `show`, `reset`, `tag`, `stash`, `reflog`, `blame`, `tree`, `clean`
|
|
98
|
+
- ✅ **HEAD~n** — Walk parent chain: `agmem log HEAD~5`, `agmem show HEAD~1`
|
|
99
|
+
- ✅ **Branch/tag names with `/`** — Git-style refs: `feature/test`, `releases/v1` (path-validated)
|
|
100
|
+
- ✅ **Content-addressable storage** — SHA-256 deduplication like Git
|
|
101
|
+
- ✅ **Memory-type-aware merging** — Episodic append, semantic consolidate, procedural prefer-new
|
|
102
|
+
- ✅ **Remote (file://)** — `clone`, `push`, `pull`, `remote`; pull merges into current branch
|
|
103
|
+
- ✅ **Search** — Semantic with `agmem[vector]`, or plain text over `current/` when vector deps missing
|
|
104
|
+
- ✅ **Knowledge graph** — `agmem graph` from wikilinks/tags; `--no-similarity`, `--format d3`, `--serve` (optional `agmem[web]`)
|
|
105
|
+
- ✅ **Integrity** — `agmem fsck`; path/ref/hash validation throughout (no path traversal)
|
|
106
|
+
- ✅ **Optional** — `serve`, `daemon` (watch + auto-commit), `garden` (episode archival), MCP server; install extras as needed
|
|
107
|
+
|
|
108
|
+
## Quick Start
|
|
109
|
+
|
|
110
|
+
### Installation
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install agmem
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Or install from source:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
git clone https://github.com/vivek-tiwari-vt/agmem.git
|
|
120
|
+
cd agmem
|
|
121
|
+
pip install -e .
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Initialize a Repository
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
agmem init
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This creates a `.mem/` directory and a `current/` working directory with subdirectories for different memory types:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
.mem/ # Repository internals
|
|
134
|
+
├── objects/ # Content-addressable storage
|
|
135
|
+
├── refs/ # Branch and tag references
|
|
136
|
+
├── staging/ # Staging area
|
|
137
|
+
├── index.json # Staging index
|
|
138
|
+
└── config.json # Repository configuration
|
|
139
|
+
|
|
140
|
+
current/ # Working directory
|
|
141
|
+
├── episodic/ # Session logs, conversation history
|
|
142
|
+
├── semantic/ # Facts, user preferences, knowledge
|
|
143
|
+
├── procedural/ # Workflows, prompt templates
|
|
144
|
+
├── checkpoints/ # Agent state snapshots
|
|
145
|
+
└── session-summaries/ # AI-generated summaries
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Basic Workflow
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Add memory files
|
|
152
|
+
agmem add episodic/session-2026-01-31.md
|
|
153
|
+
agmem add semantic/user-preferences.md
|
|
154
|
+
|
|
155
|
+
# Or add all changes
|
|
156
|
+
agmem add .
|
|
157
|
+
|
|
158
|
+
# Check status
|
|
159
|
+
agmem status
|
|
160
|
+
|
|
161
|
+
# Commit changes
|
|
162
|
+
agmem commit -m "Learned user prefers dark mode and Python"
|
|
163
|
+
|
|
164
|
+
# View history
|
|
165
|
+
agmem log
|
|
166
|
+
|
|
167
|
+
# Create a branch for experimentation
|
|
168
|
+
agmem branch experiment
|
|
169
|
+
agmem checkout experiment
|
|
170
|
+
|
|
171
|
+
# Make changes and commit
|
|
172
|
+
agmem add .
|
|
173
|
+
agmem commit -m "Experimenting with new workflow"
|
|
174
|
+
|
|
175
|
+
# Switch back and merge
|
|
176
|
+
agmem checkout main
|
|
177
|
+
agmem merge experiment
|
|
178
|
+
|
|
179
|
+
# See who changed each line of a memory file (like git blame)
|
|
180
|
+
agmem blame current/semantic/user-preferences.md
|
|
181
|
+
|
|
182
|
+
# Stash work in progress, then restore
|
|
183
|
+
agmem stash push -m "WIP"
|
|
184
|
+
agmem stash list
|
|
185
|
+
agmem stash pop
|
|
186
|
+
|
|
187
|
+
# View HEAD history (reflog)
|
|
188
|
+
agmem reflog
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Commands
|
|
192
|
+
|
|
193
|
+
All commands are listed below. Highlights: **`agmem blame <file>`** (who changed each line), **`agmem daemon`** (watch + optional auto-commit), **`agmem garden`** (episode archival & consolidation), **`agmem fsck`** (integrity check). See [Inspection & maintenance](#inspection--maintenance) for blame, daemon, and garden details.
|
|
194
|
+
|
|
195
|
+
### Core (Git-like)
|
|
196
|
+
|
|
197
|
+
| Command | Description |
|
|
198
|
+
|---------|-------------|
|
|
199
|
+
| `agmem init` | Initialize a new repository |
|
|
200
|
+
| `agmem add <file>` | Stage files (paths under `current/` validated) |
|
|
201
|
+
| `agmem commit -m "msg"` | Save staged changes |
|
|
202
|
+
| `agmem status` | Show working tree status |
|
|
203
|
+
| `agmem log [ref]` | Commit history; supports `HEAD~n`, `--oneline`, `-n` |
|
|
204
|
+
| `agmem branch` | List branches |
|
|
205
|
+
| `agmem branch <name>` | Create branch (names like `feature/test` allowed) |
|
|
206
|
+
| `agmem checkout <ref>` | Switch branch or detached commit |
|
|
207
|
+
| `agmem merge <branch>` | Merge into current branch |
|
|
208
|
+
| `agmem diff [ref1 [ref2]]` | Show changes |
|
|
209
|
+
| `agmem show <object>` | Show commit/blob/tree (supports `HEAD~n`) |
|
|
210
|
+
| `agmem tag <name>` | Create tag at HEAD |
|
|
211
|
+
| `agmem reset <ref>` | Reset HEAD or file |
|
|
212
|
+
| `agmem tree [ref]` | Directory tree of `current/` |
|
|
213
|
+
| `agmem stash` | push / pop / list |
|
|
214
|
+
| `agmem clean -f` | Remove untracked files |
|
|
215
|
+
| `agmem blame <file>` | **Who changed each line** — commit hash, author, line number, content (like `git blame`) |
|
|
216
|
+
| `agmem reflog` | HEAD change history (branch/checkout/commit) |
|
|
217
|
+
|
|
218
|
+
### Remote & integrity
|
|
219
|
+
|
|
220
|
+
| Command | Description |
|
|
221
|
+
|---------|-------------|
|
|
222
|
+
| `agmem clone <url> [dir]` | Clone repo (file:// URLs); path-validated |
|
|
223
|
+
| `agmem remote add <name> <url>` | Add remote |
|
|
224
|
+
| `agmem remote show` | List remotes |
|
|
225
|
+
| `agmem push <remote> <branch>` | Push branch (refs validated) |
|
|
226
|
+
| `agmem pull [--remote <name>] [--branch <b>]` | Fetch and merge into current branch |
|
|
227
|
+
| `agmem fsck` | Check objects, refs, optional vector store |
|
|
228
|
+
|
|
229
|
+
### Optional (install extras)
|
|
230
|
+
|
|
231
|
+
| Command | Extra | Description |
|
|
232
|
+
|---------|-------|-------------|
|
|
233
|
+
| `agmem search <query>` | `agmem[vector]` | Semantic search; else plain text over `current/` |
|
|
234
|
+
| `agmem graph` | — | Knowledge graph from wikilinks/tags; `--no-similarity` skips vector |
|
|
235
|
+
| `agmem graph --serve` | `agmem[web]` | Serve graph UI (same as `agmem serve`) |
|
|
236
|
+
| `agmem serve` | `agmem[web]` | Web UI for history and diffs |
|
|
237
|
+
| `agmem daemon` | `agmem[daemon]` | **Watch `current/`** — optional auto-commit after debounce; `daemon run` / `status` / `start` / `stop` |
|
|
238
|
+
| `agmem garden` | — | **Episode archival & consolidation** — archive old episodic files, merge semantic facts; `--dry-run` supported |
|
|
239
|
+
| `agmem mcp` | `agmem[mcp]` | MCP server for Cursor/Claude |
|
|
240
|
+
|
|
241
|
+
### Refs and optional extras
|
|
242
|
+
|
|
243
|
+
- **Branch and tag names** can include `/` (e.g. `feature/test`, `releases/v1`); the resolved path must stay under `refs/heads` or `refs/tags` (Git-style).
|
|
244
|
+
- **HEAD~n** is supported for walking the commit parent chain (e.g. `agmem log HEAD~5`, `agmem show HEAD~1`).
|
|
245
|
+
- **Search:** Semantic search when `pip install agmem[vector]`; otherwise `agmem search` falls back to plain text (grep-style) search over `current/`.
|
|
246
|
+
- **Web:** `agmem serve` and `agmem graph --serve` require `pip install agmem[web]`.
|
|
247
|
+
- **Daemon:** `agmem daemon` requires `pip install agmem[daemon]`.
|
|
248
|
+
- **MCP:** `agmem mcp` requires `pip install agmem[mcp]`.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Inspection & maintenance
|
|
253
|
+
|
|
254
|
+
### Blame — who changed each line
|
|
255
|
+
|
|
256
|
+
See which commit and author last modified each line of a memory file (like `git blame`):
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
agmem blame current/semantic/user-preferences.md
|
|
260
|
+
agmem blame episodic/session1.md
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Output: commit hash (short), author, line number, and line content. Use this to trace where a fact or session line came from, or for audits.
|
|
264
|
+
|
|
265
|
+
### Daemon — watch and auto-commit (optional)
|
|
266
|
+
|
|
267
|
+
Run a background process that watches `current/` and can auto-commit when files change. Requires the `daemon` extra (watchdog).
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
pip install agmem[daemon]
|
|
271
|
+
agmem daemon run # Watch current/, optional auto-commit after debounce
|
|
272
|
+
agmem daemon status # Show if daemon is running
|
|
273
|
+
agmem daemon start # Start in background (uses .mem/daemon.pid by default)
|
|
274
|
+
agmem daemon stop # Stop the daemon
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Use when you want memory changes to be committed automatically after a short idle period, or to keep a live view of the repo.
|
|
278
|
+
|
|
279
|
+
### Garden — episode archival & consolidation (optional)
|
|
280
|
+
|
|
281
|
+
Archive old episodic files and consolidate semantic memory. All paths stay under `current/` (path-validated).
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
agmem garden # Run archival and consolidation (see config)
|
|
285
|
+
agmem garden --dry-run # Show what would be archived/consolidated without writing
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Configure in `.mem/config.json` (e.g. `archive_dir`, consolidation thresholds). Use to keep `current/episodic/` manageable and to merge related semantic facts.
|
|
289
|
+
|
|
290
|
+
### Integrity check
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
agmem fsck
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Verifies objects, refs, and (if installed) the vector store. Run after cloning or if something looks wrong.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Memory Types
|
|
301
|
+
|
|
302
|
+
agmem recognizes three types of agent memory:
|
|
303
|
+
|
|
304
|
+
### Episodic Memory
|
|
305
|
+
Time-stamped records of agent interactions:
|
|
306
|
+
```
|
|
307
|
+
current/episodic/
|
|
308
|
+
├── 2026-01-31-session1.md
|
|
309
|
+
├── 2026-01-31-session2.md
|
|
310
|
+
└── 2026-02-01-session1.md
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Merge strategy:** Append chronologically (no conflicts)
|
|
314
|
+
|
|
315
|
+
### Semantic Memory
|
|
316
|
+
Factual knowledge and learned patterns:
|
|
317
|
+
```
|
|
318
|
+
current/semantic/
|
|
319
|
+
├── user-preferences.md
|
|
320
|
+
├── project-context.md
|
|
321
|
+
└── domain-knowledge.md
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Merge strategy:** Smart consolidation with conflict markers
|
|
325
|
+
|
|
326
|
+
### Procedural Memory
|
|
327
|
+
Workflows and prompt templates:
|
|
328
|
+
```
|
|
329
|
+
current/procedural/
|
|
330
|
+
├── coding-workflow.md
|
|
331
|
+
└── debugging-process.md
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Merge strategy:** Prefer newer, flag for manual review
|
|
335
|
+
|
|
336
|
+
## How It Works
|
|
337
|
+
|
|
338
|
+
### Memory Flow
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
current/ staging .mem/
|
|
342
|
+
╭────────────────────┐ ╭─────────────┐ ╭──────────────────────┐
|
|
343
|
+
│ episodic/ │ │ │ │ objects/ │
|
|
344
|
+
│ session logs │ │ index.json │ │ blobs → trees → │
|
|
345
|
+
│ semantic/ │───►│ (staged) │───►│ commits │
|
|
346
|
+
│ facts, prefs │ │ │ │ (content-addressable)│
|
|
347
|
+
│ procedural/ │ │ │ │ │
|
|
348
|
+
│ workflows │ ╰─────────────╯ ╰──────────────────────╯
|
|
349
|
+
╰────────────────────┘
|
|
350
|
+
│ │
|
|
351
|
+
agmem add agmem commit
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Merge Strategies
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
Episodic Branch A ──╮
|
|
358
|
+
(append) Branch B ──╯──► chronological append ──► ✓ no conflicts
|
|
359
|
+
|
|
360
|
+
Semantic Branch A ──╮
|
|
361
|
+
(consolidate) Branch B ──╯──► conflict markers ──► ⚠ manual review
|
|
362
|
+
|
|
363
|
+
Procedural Branch A ──╮
|
|
364
|
+
(prefer new) Branch B ──╯──► newer wins ──► ⚠ flag for review
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### How Others Handle Memory vs agmem
|
|
368
|
+
|
|
369
|
+
| Tool | Approach | Gap |
|
|
370
|
+
|------|----------|-----|
|
|
371
|
+
| **Cursor** | Ephemeral, session-based context; no persistent version control | No history, branching, or merge for agent memory |
|
|
372
|
+
| **Claude Code** | File-based (CLAUDE.md, .claude/rules); loaded at launch | No built-in version control; Git is not memory-type-aware |
|
|
373
|
+
| **Mem0** | Cloud/API; vector-based persistence | No branching, merging, or "git log" for what the agent learned |
|
|
374
|
+
| **agmem** | Git-like version control for memory | Version history, branching, merging, local-first, memory-type-aware |
|
|
375
|
+
|
|
376
|
+
## Example: Multi-Agent Collaboration
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Agent A creates base memory
|
|
380
|
+
agmem init --author-name "Agent-A"
|
|
381
|
+
echo "User prefers Python" > current/semantic/preferences.md
|
|
382
|
+
agmem add .
|
|
383
|
+
agmem commit -m "Initial preferences"
|
|
384
|
+
|
|
385
|
+
# Agent B clones and extends
|
|
386
|
+
# cd agent-b-memory
|
|
387
|
+
# agmem clone file:///path/to/agent-a
|
|
388
|
+
# echo "User also likes TypeScript" >> current/semantic/preferences.md
|
|
389
|
+
# agmem add .
|
|
390
|
+
# agmem commit -m "Added TypeScript preference"
|
|
391
|
+
|
|
392
|
+
# Agent A pulls and merges Agent B's changes
|
|
393
|
+
# agmem pull
|
|
394
|
+
# agmem merge agent-b/main
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Storage (Git-Like)
|
|
398
|
+
|
|
399
|
+
agmem stores agent memory exactly like Git stores code:
|
|
400
|
+
|
|
401
|
+
| Git | agmem |
|
|
402
|
+
|-----|-------|
|
|
403
|
+
| `.git/objects/` | `.mem/objects/` |
|
|
404
|
+
| Blob, Tree, Commit | Same (content-addressable) |
|
|
405
|
+
| SHA-1 | SHA-256 |
|
|
406
|
+
| zlib compression | zlib compression |
|
|
407
|
+
| Deduplication | Deduplication |
|
|
408
|
+
| `refs/heads/` | `refs/heads/` |
|
|
409
|
+
| `refs/tags/` | `refs/tags/` |
|
|
410
|
+
| Reflog | Reflog |
|
|
411
|
+
| Stash | Stash |
|
|
412
|
+
|
|
413
|
+
**Working directory:** `current/` with episodic, semantic, procedural, checkpoints, session-summaries. Same mental model as Git's working tree.
|
|
414
|
+
|
|
415
|
+
**Security:** Paths, refs, and object hashes are validated everywhere (no path traversal). Branch/tag names may include `/` but must resolve under `refs/heads` or `refs/tags`. Remote URLs (file://) and clone targets are validated. `serve` binds to 127.0.0.1 by default.
|
|
416
|
+
|
|
417
|
+
- **Content-addressable objects** — Blobs, trees, commits hashed with SHA-256
|
|
418
|
+
- **Compression** — zlib for efficient storage
|
|
419
|
+
- **Deduplication** — Same content = same hash, stored once
|
|
420
|
+
- **Reflog** — History of HEAD changes (commit, checkout)
|
|
421
|
+
- **Stash** — Temporary storage for work-in-progress
|
|
422
|
+
|
|
423
|
+
## Configuration
|
|
424
|
+
|
|
425
|
+
### Repository config (`.mem/config.json`)
|
|
426
|
+
|
|
427
|
+
Repository configuration is stored in `.mem/config.json`:
|
|
428
|
+
|
|
429
|
+
```json
|
|
430
|
+
{
|
|
431
|
+
"author": {
|
|
432
|
+
"name": "Agent",
|
|
433
|
+
"email": "agent@example.com"
|
|
434
|
+
},
|
|
435
|
+
"core": {
|
|
436
|
+
"default_branch": "main",
|
|
437
|
+
"compression": true,
|
|
438
|
+
"gc_prune_days": 90
|
|
439
|
+
},
|
|
440
|
+
"memory": {
|
|
441
|
+
"auto_summarize": true,
|
|
442
|
+
"summarizer_model": "default",
|
|
443
|
+
"max_episode_size": 1048576,
|
|
444
|
+
"consolidation_threshold": 100
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### agmem config (cloud and PII)
|
|
450
|
+
|
|
451
|
+
Optional user/repo config for S3/GCS and PII hooks:
|
|
452
|
+
|
|
453
|
+
- **User-level**: `~/.config/agmem/config.yaml` (or `$XDG_CONFIG_HOME/agmem/config.yaml`)
|
|
454
|
+
- **Repo-level**: `<repo>/.agmemrc` or `<repo>/.mem/config.yaml` (YAML)
|
|
455
|
+
|
|
456
|
+
Repo overrides user. **Never put secrets in config files.** Credentials are supplied via environment variables (or standard AWS/GCP mechanisms). Config may reference env var *names* only (e.g. `access_key_var: AWS_ACCESS_KEY_ID`). See [docs/CONFIG.md](docs/CONFIG.md) for schema and examples.
|
|
457
|
+
|
|
458
|
+
- **Cloud (S3/GCS)**: region, endpoint, env var names for credentials; GCS can use `credentials_path` (validated under repo/home) or `credentials_json_var` (env var containing JSON key).
|
|
459
|
+
- **PII**: `pii.enabled` (default true) to enable/disable pre-commit PII scanning; `pii.allowlist` (path globs) to skip scanning certain files.
|
|
460
|
+
|
|
461
|
+
## Architecture
|
|
462
|
+
|
|
463
|
+
agmem follows Git's proven architecture:
|
|
464
|
+
|
|
465
|
+
```
|
|
466
|
+
╔═══════════════════════════════════════════════════════════════════════╗
|
|
467
|
+
║ PORCELAIN · What you type ║
|
|
468
|
+
╠═══════════════════════════════════════════════════════════════════════╣
|
|
469
|
+
║ init add commit status log · branch checkout merge ║
|
|
470
|
+
║ diff show tag reset tree · stash clean blame reflog ║
|
|
471
|
+
║ clone push pull remote fsck · graph search serve daemon ║
|
|
472
|
+
╠═══════════════════════════════════════════════════════════════════════╣
|
|
473
|
+
║ PLUMBING · What happens under the hood ║
|
|
474
|
+
╠═══════════════════════════════════════════════════════════════════════╣
|
|
475
|
+
║ objects (blob, tree, commit) · refs (HEAD, branches, tags) ║
|
|
476
|
+
║ staging area ║
|
|
477
|
+
╠═══════════════════════════════════════════════════════════════════════╣
|
|
478
|
+
║ STORAGE · On disk ║
|
|
479
|
+
╠═══════════════════════════════════════════════════════════════════════╣
|
|
480
|
+
║ SHA-256 hashing · zlib compression · deduplication ║
|
|
481
|
+
╚═══════════════════════════════════════════════════════════════════════╝
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
## Development
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
# Clone repository
|
|
488
|
+
git clone https://github.com/vivek-tiwari-vt/agmem.git
|
|
489
|
+
cd agmem
|
|
490
|
+
|
|
491
|
+
# Install development dependencies
|
|
492
|
+
pip install -e ".[dev]"
|
|
493
|
+
|
|
494
|
+
# Run tests
|
|
495
|
+
pytest
|
|
496
|
+
|
|
497
|
+
# Format code
|
|
498
|
+
black memvcs/
|
|
499
|
+
|
|
500
|
+
# Type check
|
|
501
|
+
mypy memvcs/
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
## Roadmap
|
|
505
|
+
|
|
506
|
+
- [x] Core object storage (blob, tree, commit)
|
|
507
|
+
- [x] Basic commands (init, add, commit, status, log, diff, show, reset, tag, stash, reflog, blame, tree, clean)
|
|
508
|
+
- [x] HEAD~n resolution; branch/tag names with `/` (Git-style)
|
|
509
|
+
- [x] Branching and checkout; merging with memory-type-aware strategies
|
|
510
|
+
- [x] Remote operations (clone, push, pull, remote) — file:// URLs; pull merges into current branch
|
|
511
|
+
- [x] Search — semantic with `agmem[vector]`, plain text fallback
|
|
512
|
+
- [x] Knowledge graph (`agmem graph`) — wikilinks, tags, optional similarity; `--no-similarity`, `--serve`
|
|
513
|
+
- [x] Integrity (`agmem fsck`); path/ref/hash validation (security)
|
|
514
|
+
- [x] Web UI (`agmem serve`); MCP server (`agmem mcp`); daemon (`agmem daemon`); garden (`agmem garden`)
|
|
515
|
+
- [ ] Garbage collection
|
|
516
|
+
- [ ] Pack files for efficiency
|
|
517
|
+
|
|
518
|
+
## Integrations
|
|
519
|
+
|
|
520
|
+
```
|
|
521
|
+
Cursor ────────╮
|
|
522
|
+
Claude Code ───┼──► MCP Server ──► current/ ──► .mem/
|
|
523
|
+
Windsurf ──────┤ (agmem mcp) episodic/
|
|
524
|
+
Continue ──────╯ semantic/
|
|
525
|
+
procedural/
|
|
526
|
+
|
|
527
|
+
Python API ────► Repository() ──► (same)
|
|
528
|
+
LangChain
|
|
529
|
+
LangGraph
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Cursor
|
|
533
|
+
|
|
534
|
+
1. Install: `pip install agmem[mcp]`
|
|
535
|
+
2. Add MCP server to Cursor settings (Settings → MCP → Edit Config):
|
|
536
|
+
|
|
537
|
+
```json
|
|
538
|
+
{
|
|
539
|
+
"mcpServers": {
|
|
540
|
+
"agmem": {
|
|
541
|
+
"command": "agmem",
|
|
542
|
+
"args": ["mcp"]
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
3. Use memory tools in chat: `memory_read`, `memory_search`, `memory_add`, `memory_log`, `memory_diff`
|
|
549
|
+
4. Optional: Add Cursor rules pointing to `current/` for automatic context loading
|
|
550
|
+
|
|
551
|
+
### Claude Code
|
|
552
|
+
|
|
553
|
+
Same MCP setup as Cursor. Claude Desktop uses MCP natively. File-based memory (CLAUDE.md, .claude/rules) can coexist with agmem—agmem adds version control on top.
|
|
554
|
+
|
|
555
|
+
### Other IDEs
|
|
556
|
+
|
|
557
|
+
Any MCP-compatible client (Windsurf, Continue, etc.) works with the same config. Use the Python API for custom integrations.
|
|
558
|
+
|
|
559
|
+
### Vector Search
|
|
560
|
+
|
|
561
|
+
```bash
|
|
562
|
+
pip install agmem[vector]
|
|
563
|
+
agmem search "user prefers Python"
|
|
564
|
+
agmem search "workflow" --rebuild # Rebuild index after many changes
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
When `agmem[vector]` is not installed, `agmem search` uses plain text (grep-style) search over `current/**/*.md` and `*.txt`.
|
|
568
|
+
|
|
569
|
+
### Knowledge graph
|
|
570
|
+
|
|
571
|
+
```bash
|
|
572
|
+
agmem graph # Summary: nodes, edges by type, isolated files
|
|
573
|
+
agmem graph --no-similarity # Wikilinks + tags only (no vector store)
|
|
574
|
+
agmem graph --format json # Full graph JSON
|
|
575
|
+
agmem graph --format d3 -o g.json # D3 nodes/links for visualization
|
|
576
|
+
agmem graph --serve # Serve graph UI (requires agmem[web])
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
Edges come from **wikilinks** (`[[target]]`, `[[target|label]]`) and shared **YAML frontmatter tags**. Use `--no-similarity` when vector deps are not installed.
|
|
580
|
+
|
|
581
|
+
### Web UI
|
|
582
|
+
|
|
583
|
+
```bash
|
|
584
|
+
pip install agmem[web]
|
|
585
|
+
agmem serve # Browse history, view diffs in browser
|
|
586
|
+
agmem graph --serve # Serve knowledge graph UI (same extra)
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
## Use Cases
|
|
590
|
+
|
|
591
|
+
### Multi-Agent Collaboration
|
|
592
|
+
|
|
593
|
+
- **Agent A** develops memory on `main`
|
|
594
|
+
- **Agent B** clones, branches, and extends: `agmem clone file:///path/to/agent-a`
|
|
595
|
+
- **Agent A** pulls and merges: `agmem pull` then `agmem merge agent-b/main`
|
|
596
|
+
- Memory-type-aware merge: episodic appends, semantic uses conflict markers, procedural prefers newer
|
|
597
|
+
|
|
598
|
+
### Experiment Tracking
|
|
599
|
+
|
|
600
|
+
- Branch per experiment: `agmem branch exp-v2-prompt`
|
|
601
|
+
- Compare results: `agmem diff main exp-v2-prompt`
|
|
602
|
+
- Tag successful runs: `agmem tag v1.0`
|
|
603
|
+
- Roll back: `agmem reset --hard HEAD~1`
|
|
604
|
+
|
|
605
|
+
### Compliance and Audit
|
|
606
|
+
|
|
607
|
+
- **Full history:** `agmem log`, `agmem reflog`
|
|
608
|
+
- **Line-level attribution:** `agmem blame <file>` — see which commit and author last changed each line (e.g. `agmem blame current/semantic/user-preferences.md`)
|
|
609
|
+
- **Visual audit:** `agmem serve` for browser-based history and diff viewer
|
|
610
|
+
- **Integrity:** `agmem fsck` to verify objects and refs
|
|
611
|
+
|
|
612
|
+
## Ecosystem Plugin Patterns
|
|
613
|
+
|
|
614
|
+
### LangChain / LangGraph
|
|
615
|
+
|
|
616
|
+
Use the agmem Python API or MCP tools as a memory backend:
|
|
617
|
+
|
|
618
|
+
```python
|
|
619
|
+
from pathlib import Path
|
|
620
|
+
from memvcs.core.repository import Repository
|
|
621
|
+
|
|
622
|
+
repo = Repository(Path("."))
|
|
623
|
+
repo.stage_file("semantic/learned.md", content=b"Agent learned X")
|
|
624
|
+
repo.commit("Learned X")
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
Or connect via MCP and call `memory_add` from your agent.
|
|
628
|
+
|
|
629
|
+
### MCP Resource URIs
|
|
630
|
+
|
|
631
|
+
- `mem://current/semantic/user-preferences.md` — Read memory file
|
|
632
|
+
- `mem://current/episodic/session1.md` — Session log
|
|
633
|
+
- `mem://current/procedural/workflow.md` — Procedural memory
|
|
634
|
+
|
|
635
|
+
### Plugin Checklist
|
|
636
|
+
|
|
637
|
+
1. Detect agmem repo: `.mem/` directory exists
|
|
638
|
+
2. Read from `current/` for context
|
|
639
|
+
3. Write via `agmem add` + `agmem commit` or MCP `memory_add`
|
|
640
|
+
4. Optional: Use `agmem search` for semantic retrieval
|
|
641
|
+
|
|
642
|
+
## Contributing
|
|
643
|
+
|
|
644
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
645
|
+
|
|
646
|
+
## License
|
|
647
|
+
|
|
648
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
649
|
+
|
|
650
|
+
## Acknowledgments
|
|
651
|
+
|
|
652
|
+
agmem is inspired by Git's elegant design and the growing need for agent memory management in the AI ecosystem. Thanks to the Git team for proving that distributed version control can be both powerful and usable.
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
**Made with ❤️ for AI agents and their developers**
|