yourmemory 1.4.0__tar.gz → 1.4.2__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 (46) hide show
  1. yourmemory-1.4.2/PKG-INFO +411 -0
  2. yourmemory-1.4.2/README.md +372 -0
  3. {yourmemory-1.4.0 → yourmemory-1.4.2}/memory_mcp.py +78 -2
  4. {yourmemory-1.4.0 → yourmemory-1.4.2}/pyproject.toml +1 -1
  5. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/app.py +2 -1
  6. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/jobs/decay_job.py +3 -2
  7. yourmemory-1.4.2/src/routes/memories.py +293 -0
  8. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/routes/retrieve.py +2 -2
  9. yourmemory-1.4.2/src/routes/ui.py +206 -0
  10. yourmemory-1.4.2/yourmemory.egg-info/PKG-INFO +411 -0
  11. {yourmemory-1.4.0 → yourmemory-1.4.2}/yourmemory.egg-info/SOURCES.txt +1 -0
  12. yourmemory-1.4.0/PKG-INFO +0 -504
  13. yourmemory-1.4.0/README.md +0 -465
  14. yourmemory-1.4.0/src/routes/memories.py +0 -279
  15. yourmemory-1.4.0/yourmemory.egg-info/PKG-INFO +0 -504
  16. {yourmemory-1.4.0 → yourmemory-1.4.2}/LICENSE +0 -0
  17. {yourmemory-1.4.0 → yourmemory-1.4.2}/setup.cfg +0 -0
  18. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/__init__.py +0 -0
  19. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/db/connection.py +0 -0
  20. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/db/duckdb_schema.sql +0 -0
  21. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/db/migrate.py +0 -0
  22. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/db/schema.sql +0 -0
  23. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/db/sqlite_schema.sql +0 -0
  24. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/__init__.py +0 -0
  25. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/backend.py +0 -0
  26. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/graph_store.py +0 -0
  27. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/neo4j_backend.py +0 -0
  28. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/networkx_backend.py +0 -0
  29. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/graph/svo_extract.py +0 -0
  30. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/routes/__init__.py +0 -0
  31. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/routes/agents.py +0 -0
  32. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/__init__.py +0 -0
  33. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/agent_registry.py +0 -0
  34. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/api_keys.py +0 -0
  35. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/decay.py +0 -0
  36. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/embed.py +0 -0
  37. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/extract.py +0 -0
  38. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/extract_fallback.py +0 -0
  39. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/resolve.py +0 -0
  40. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/resolve_fallback.py +0 -0
  41. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/retrieve.py +0 -0
  42. {yourmemory-1.4.0 → yourmemory-1.4.2}/src/services/utils.py +0 -0
  43. {yourmemory-1.4.0 → yourmemory-1.4.2}/yourmemory.egg-info/dependency_links.txt +0 -0
  44. {yourmemory-1.4.0 → yourmemory-1.4.2}/yourmemory.egg-info/entry_points.txt +0 -0
  45. {yourmemory-1.4.0 → yourmemory-1.4.2}/yourmemory.egg-info/requires.txt +0 -0
  46. {yourmemory-1.4.0 → yourmemory-1.4.2}/yourmemory.egg-info/top_level.txt +0 -0
@@ -0,0 +1,411 @@
1
+ Metadata-Version: 2.4
2
+ Name: yourmemory
3
+ Version: 1.4.2
4
+ Summary: Persistent memory for Claude — Ebbinghaus forgetting curve, semantic deduplication, MCP-native
5
+ Author-email: Sachit Misra <mishrasachit1@gmail.com>
6
+ License-Expression: CC-BY-NC-4.0
7
+ Project-URL: Homepage, https://github.com/sachitrafa/YourMemory
8
+ Project-URL: Repository, https://github.com/sachitrafa/YourMemory
9
+ Keywords: mcp,claude,memory,ebbinghaus,ai,sqlite,postgresql
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: python-dotenv
19
+ Requires-Dist: mcp
20
+ Requires-Dist: sentence-transformers
21
+ Requires-Dist: numpy
22
+ Requires-Dist: python-dateutil
23
+ Requires-Dist: duckdb>=0.10.0
24
+ Requires-Dist: apscheduler
25
+ Requires-Dist: spacy<4.0,>=3.8.13
26
+ Requires-Dist: networkx>=3.0
27
+ Provides-Extra: postgres
28
+ Requires-Dist: psycopg2-binary; extra == "postgres"
29
+ Requires-Dist: pgvector; extra == "postgres"
30
+ Provides-Extra: sse
31
+ Requires-Dist: fastapi; extra == "sse"
32
+ Requires-Dist: uvicorn[standard]; extra == "sse"
33
+ Requires-Dist: httpx; extra == "sse"
34
+ Provides-Extra: neo4j
35
+ Requires-Dist: neo4j>=5.0; extra == "neo4j"
36
+ Provides-Extra: all
37
+ Requires-Dist: yourmemory[neo4j,postgres,sse]; extra == "all"
38
+ Dynamic: license-file
39
+
40
+ <div align="center">
41
+
42
+ # YourMemory
43
+
44
+ **Persistent memory for AI agents — built on the science of how humans remember.**
45
+
46
+ [![Docker Publish](https://img.shields.io/github/actions/workflow/status/sachitrafa/YourMemory/docker-publish.yml?branch=main&label=docker%20build&logo=docker)](https://github.com/sachitrafa/YourMemory/actions/workflows/docker-publish.yml)
47
+ [![Version](https://img.shields.io/badge/version-1.4.1-blue)](https://github.com/sachitrafa/YourMemory/releases)
48
+ [![License: CC BY-NC 4.0](https://img.shields.io/badge/license-CC%20BY--NC%204.0-lightgrey)](https://creativecommons.org/licenses/by-nc/4.0/)
49
+ [![Recall@5](https://img.shields.io/badge/Recall%405-59%25-brightgreen)](BENCHMARKS.md)
50
+
51
+ </div>
52
+
53
+ ---
54
+
55
+ ## The Problem
56
+
57
+ Every session, your AI assistant starts from zero. It asks the same questions, forgets your preferences, re-learns your stack. There is no memory between conversations.
58
+
59
+ **YourMemory fixes that.** It gives AI agents a persistent memory layer that works the way human memory does — important things stick, forgotten things fade, outdated facts get replaced automatically. Two commands to install, zero infrastructure required.
60
+
61
+ ---
62
+
63
+ ## How Well Does It Work?
64
+
65
+ Tested on [LoCoMo-10](https://github.com/snap-research/locomo) — 1,534 QA pairs across 10 multi-session conversations.
66
+
67
+ | System | Recall@5 | 95% CI |
68
+ |--------|:--------:|:------:|
69
+ | **YourMemory** (BM25 + vector + graph + decay) | **59%** | 56–61% |
70
+ | Zep Cloud | 28% | 26–30% |
71
+
72
+ > **2× better recall than Zep Cloud on the same benchmark.**
73
+
74
+ Full methodology and per-sample breakdown in [BENCHMARKS.md](BENCHMARKS.md). Writeup: [I built memory decay for AI agents using the Ebbinghaus forgetting curve](https://dev.to/sachit_mishra_686a94d1bb5/i-built-memory-decay-for-ai-agents-using-the-ebbinghaus-forgetting-curve-1b0e).
75
+
76
+ ---
77
+
78
+ ## Demo
79
+
80
+ ![YourMemory Demo](demo.gif)
81
+
82
+ ---
83
+
84
+ ## Quick Start
85
+
86
+ **Supports Python 3.11, 3.12, 3.13, and 3.14. No Docker, no database setup, no external services.**
87
+
88
+ ### Step 1 — Install
89
+
90
+ ```bash
91
+ pip install yourmemory
92
+ ```
93
+
94
+ ### Step 2 — Run setup (once)
95
+
96
+ ```bash
97
+ yourmemory-setup
98
+ ```
99
+
100
+ Downloads the spaCy language model and initialises the local database at `~/.yourmemory/memories.duckdb`.
101
+
102
+ ### Step 3 — Get your config path
103
+
104
+ ```bash
105
+ yourmemory-path
106
+ ```
107
+
108
+ Prints your full executable path and a ready-to-paste config block. Copy it.
109
+
110
+ ### Step 4 — Wire into your AI client
111
+
112
+ <details>
113
+ <summary><strong>Claude Code</strong></summary>
114
+
115
+ Add to `~/.claude/settings.json`:
116
+
117
+ ```json
118
+ {
119
+ "mcpServers": {
120
+ "yourmemory": {
121
+ "command": "yourmemory"
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ Reload (`Cmd+Shift+P` → `Developer: Reload Window`).
128
+
129
+ </details>
130
+
131
+ <details>
132
+ <summary><strong>Claude Desktop</strong></summary>
133
+
134
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
135
+
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "yourmemory": {
140
+ "command": "yourmemory"
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ Restart Claude Desktop.
147
+
148
+ </details>
149
+
150
+ <details>
151
+ <summary><strong>Cline (VS Code)</strong></summary>
152
+
153
+ VS Code doesn't inherit your shell PATH. Run `yourmemory-path` first to get the full executable path.
154
+
155
+ In Cline → **MCP Servers** → **Edit MCP Settings**:
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "yourmemory": {
161
+ "command": "/full/path/to/yourmemory",
162
+ "args": [],
163
+ "env": { "YOURMEMORY_USER": "your_name" }
164
+ }
165
+ }
166
+ }
167
+ ```
168
+
169
+ Restart Cline after saving.
170
+
171
+ </details>
172
+
173
+ <details>
174
+ <summary><strong>Cursor</strong></summary>
175
+
176
+ Add to `~/.cursor/mcp.json`:
177
+
178
+ ```json
179
+ {
180
+ "mcpServers": {
181
+ "yourmemory": {
182
+ "command": "/full/path/to/yourmemory",
183
+ "args": [],
184
+ "env": { "YOURMEMORY_USER": "your_name" }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ </details>
191
+
192
+ <details>
193
+ <summary><strong>OpenCode</strong></summary>
194
+
195
+ Add to `~/.config/opencode/config.json`:
196
+
197
+ ```json
198
+ {
199
+ "mcp": {
200
+ "yourmemory": {
201
+ "type": "local",
202
+ "command": ["yourmemory"],
203
+ "environment": { "YOURMEMORY_USER": "your_name" }
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ Then copy the memory workflow instructions:
210
+
211
+ ```bash
212
+ cp sample_CLAUDE.md ~/.config/opencode/instructions.md
213
+ ```
214
+
215
+ Restart OpenCode.
216
+
217
+ </details>
218
+
219
+ > **Any MCP-compatible client:** YourMemory is a standard stdio MCP server. Works with Windsurf, Continue, Zed, and any client that supports MCP. Use the full path from `yourmemory-path` if the client doesn't inherit shell PATH.
220
+
221
+ ### Step 5 — Add memory instructions to your project
222
+
223
+ ```bash
224
+ cp sample_CLAUDE.md CLAUDE.md
225
+ ```
226
+
227
+ Edit `CLAUDE.md` — replace `YOUR_NAME` and `YOUR_USER_ID`. Claude now follows the recall → store → update workflow automatically on every task.
228
+
229
+ ---
230
+
231
+ ## MCP Tools
232
+
233
+ Three tools. Called by Claude automatically once `CLAUDE.md` is in place.
234
+
235
+ | Tool | When | What it does |
236
+ |------|------|--------------|
237
+ | `recall_memory(query)` | Start of every task | Surfaces relevant memories ranked by similarity × strength |
238
+ | `store_memory(content, importance)` | After learning something new | Embeds and stores with biological decay |
239
+ | `update_memory(id, new_content)` | When a memory is outdated | Re-embeds and replaces |
240
+
241
+ ```python
242
+ # Example session
243
+ store_memory("Sachit prefers tabs over spaces in Python", importance=0.9, category="fact")
244
+
245
+ # Next session — without being told again:
246
+ recall_memory("Python formatting")
247
+ # → {"content": "Sachit prefers tabs over spaces in Python", "strength": 0.87}
248
+ ```
249
+
250
+ ### Categories control how fast memories fade
251
+
252
+ | Category | Survives without recall | Use case |
253
+ |----------|------------------------|----------|
254
+ | `strategy` | ~38 days | Successful patterns |
255
+ | `fact` | ~24 days | Preferences, identity |
256
+ | `assumption` | ~19 days | Inferred context |
257
+ | `failure` | ~11 days | Errors, environment-specific issues |
258
+
259
+ ---
260
+
261
+ ## How It Works
262
+
263
+ ### Ebbinghaus Forgetting Curve
264
+
265
+ Memory strength decays exponentially — but importance and recall frequency slow that decay:
266
+
267
+ ```
268
+ effective_λ = base_λ × (1 - importance × 0.8)
269
+ strength = importance × e^(−effective_λ × days) × (1 + recall_count × 0.2)
270
+ score = cosine_similarity × strength
271
+ ```
272
+
273
+ Memories recalled frequently resist decay. Memories below strength `0.05` are pruned automatically every 24 hours.
274
+
275
+ ### Hybrid Retrieval: Vector + Graph
276
+
277
+ Retrieval runs in two rounds to surface related context that vocabulary-based search misses:
278
+
279
+ **Round 1 — Vector search:** cosine similarity against all memories, returns top-k above threshold.
280
+
281
+ **Round 2 — Graph expansion:** BFS traversal from Round 1 seeds surfaces memories that share context but not vocabulary — connected via semantic edges (cosine similarity ≥ 0.4).
282
+
283
+ ```
284
+ recall("Python backend")
285
+ Round 1 → [1] Python/MongoDB (sim=0.61)
286
+ [2] DuckDB/spaCy (sim=0.19)
287
+ Round 2 → [5] Docker/Kubernetes (sim=0.29 — below cut-off, surfaced via graph)
288
+ ```
289
+
290
+ **Chain-aware pruning:** A decayed memory is kept alive if any graph neighbour is above the prune threshold. Related memories age together.
291
+
292
+ ---
293
+
294
+ ## Multi-Agent Memory
295
+
296
+ Multiple agents can share the same YourMemory instance — each with isolated private memories and controlled access to shared context.
297
+
298
+ ```python
299
+ from src.services.api_keys import register_agent
300
+
301
+ result = register_agent(
302
+ agent_id="coding-agent",
303
+ user_id="sachit",
304
+ can_read=["shared", "private"],
305
+ can_write=["shared", "private"],
306
+ )
307
+ # → result["api_key"] — ym_xxxx, shown once only
308
+ ```
309
+
310
+ Pass `api_key` to any MCP call to authenticate as an agent:
311
+
312
+ ```python
313
+ store_memory(content="Staging uses self-signed cert — skip SSL verify",
314
+ importance=0.7, category="failure",
315
+ api_key="ym_xxxx", visibility="private")
316
+
317
+ recall_memory(query="staging SSL", api_key="ym_xxxx")
318
+ # → returns shared memories + this agent's private memories
319
+ # → other agents see shared only
320
+ ```
321
+
322
+ ---
323
+
324
+ ## Stack
325
+
326
+ | Component | Role |
327
+ |-----------|------|
328
+ | **DuckDB** | Default vector DB — zero setup, native cosine similarity |
329
+ | **NetworkX** | Default graph backend — persists at `~/.yourmemory/graph.pkl` |
330
+ | **sentence-transformers** | Local embeddings (`all-mpnet-base-v2`, 768 dims) |
331
+ | **spaCy** | Local NLP for deduplication and SVO triple extraction |
332
+ | **APScheduler** | Automatic 24h decay job |
333
+ | **PostgreSQL + pgvector** | Optional — for teams or large datasets |
334
+ | **Neo4j** | Optional graph backend — `pip install 'yourmemory[neo4j]'` |
335
+
336
+ <details>
337
+ <summary><strong>PostgreSQL setup (optional)</strong></summary>
338
+
339
+ ```bash
340
+ pip install yourmemory[postgres]
341
+ ```
342
+
343
+ Create a `.env` file:
344
+
345
+ ```bash
346
+ DATABASE_URL=postgresql://YOUR_USER@localhost:5432/yourmemory
347
+ ```
348
+
349
+ **macOS**
350
+ ```bash
351
+ brew install postgresql@16 pgvector && brew services start postgresql@16
352
+ createdb yourmemory
353
+ ```
354
+
355
+ **Ubuntu / Debian**
356
+ ```bash
357
+ sudo apt install postgresql postgresql-contrib postgresql-16-pgvector
358
+ createdb yourmemory
359
+ ```
360
+
361
+ </details>
362
+
363
+ ---
364
+
365
+ ## Architecture
366
+
367
+ ```
368
+ Claude / Cline / Cursor / Any MCP client
369
+
370
+ ├── recall_memory(query, api_key?)
371
+ │ └── embed → vector similarity (Round 1)
372
+ │ → graph BFS expansion (Round 2)
373
+ │ → score = sim × strength → top-k
374
+ │ → recall propagation → boost neighbours
375
+
376
+ ├── store_memory(content, importance, category?, visibility?, api_key?)
377
+ │ └── question? → reject
378
+ │ contradiction check → update if conflict
379
+ │ embed() → INSERT → index_memory() → graph node + edges
380
+
381
+ └── update_memory(id, new_content, importance)
382
+ └── embed(new_content) → UPDATE → refresh graph node
383
+
384
+ Vector DB (Round 1) Graph DB (Round 2)
385
+ DuckDB (default) NetworkX (default)
386
+ memories.duckdb graph.pkl
387
+ ├── embedding FLOAT[768] ├── nodes: memory_id, strength
388
+ ├── importance FLOAT └── edges: sim × verb_weight ≥ 0.4
389
+ ├── recall_count INTEGER
390
+ ├── visibility VARCHAR Neo4j (opt-in)
391
+ └── agent_id VARCHAR └── bolt://localhost:7687
392
+ ```
393
+
394
+ ---
395
+
396
+ ## Dataset Reference
397
+
398
+ Benchmarks use the [LoCoMo](https://github.com/snap-research/locomo) dataset by Snap Research.
399
+
400
+ > Maharana et al. (2024). *LoCoMo: Long Context Multimodal Benchmark for Dialogue.* Snap Research.
401
+
402
+ ---
403
+
404
+ ## License
405
+
406
+ Copyright 2026 **Sachit Misra** — Licensed under [CC-BY-NC-4.0](LICENSE).
407
+
408
+ **Free for:** personal use, education, academic research, open-source projects.
409
+ **Not permitted:** commercial use without a separate written agreement.
410
+
411
+ Commercial licensing: mishrasachit1@gmail.com