chip-memory 1.1.0__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 (100) hide show
  1. chip_memory-1.1.0/LICENSE +21 -0
  2. chip_memory-1.1.0/PKG-INFO +289 -0
  3. chip_memory-1.1.0/README.md +228 -0
  4. chip_memory-1.1.0/pyproject.toml +95 -0
  5. chip_memory-1.1.0/setup.cfg +4 -0
  6. chip_memory-1.1.0/src/chip_memory/__init__.py +31 -0
  7. chip_memory-1.1.0/src/chip_memory/__main__.py +83 -0
  8. chip_memory-1.1.0/src/chip_memory/_stopwords.py +52 -0
  9. chip_memory-1.1.0/src/chip_memory/_utils.py +38 -0
  10. chip_memory-1.1.0/src/chip_memory/api.py +628 -0
  11. chip_memory-1.1.0/src/chip_memory/auto_write.py +451 -0
  12. chip_memory-1.1.0/src/chip_memory/automagic_token.py +35 -0
  13. chip_memory-1.1.0/src/chip_memory/bm25.py +231 -0
  14. chip_memory-1.1.0/src/chip_memory/collect/__init__.py +22 -0
  15. chip_memory-1.1.0/src/chip_memory/collect/absorb.py +631 -0
  16. chip_memory-1.1.0/src/chip_memory/collect/adapters/__init__.py +0 -0
  17. chip_memory-1.1.0/src/chip_memory/collect/adapters/claude_code.py +352 -0
  18. chip_memory-1.1.0/src/chip_memory/collect/adapters/git.py +353 -0
  19. chip_memory-1.1.0/src/chip_memory/collect/adapters/shell.py +524 -0
  20. chip_memory-1.1.0/src/chip_memory/collect/correlator.py +462 -0
  21. chip_memory-1.1.0/src/chip_memory/collect/dedup.py +212 -0
  22. chip_memory-1.1.0/src/chip_memory/collect/events.py +204 -0
  23. chip_memory-1.1.0/src/chip_memory/collect/redact.py +132 -0
  24. chip_memory-1.1.0/src/chip_memory/collect/review_cli.py +10 -0
  25. chip_memory-1.1.0/src/chip_memory/collect/signal_detector.py +594 -0
  26. chip_memory-1.1.0/src/chip_memory/connect_cmd.py +195 -0
  27. chip_memory-1.1.0/src/chip_memory/consolidation.py +353 -0
  28. chip_memory-1.1.0/src/chip_memory/contradiction.py +366 -0
  29. chip_memory-1.1.0/src/chip_memory/daemon.py +399 -0
  30. chip_memory-1.1.0/src/chip_memory/dashboard/static/data.json +327 -0
  31. chip_memory-1.1.0/src/chip_memory/dashboard/static/index.html +1141 -0
  32. chip_memory-1.1.0/src/chip_memory/dashboard/static/vendor/OrbitControls.js +1417 -0
  33. chip_memory-1.1.0/src/chip_memory/dashboard/static/vendor/three.module.js +53044 -0
  34. chip_memory-1.1.0/src/chip_memory/dashboard.py +480 -0
  35. chip_memory-1.1.0/src/chip_memory/dashboard_cmd.py +80 -0
  36. chip_memory-1.1.0/src/chip_memory/doctor.py +268 -0
  37. chip_memory-1.1.0/src/chip_memory/eval.py +330 -0
  38. chip_memory-1.1.0/src/chip_memory/export.py +228 -0
  39. chip_memory-1.1.0/src/chip_memory/export_wiki.py +467 -0
  40. chip_memory-1.1.0/src/chip_memory/graph/__init__.py +5 -0
  41. chip_memory-1.1.0/src/chip_memory/graph/aliases.py +251 -0
  42. chip_memory-1.1.0/src/chip_memory/graph/predicate_vocab.py +177 -0
  43. chip_memory-1.1.0/src/chip_memory/graph/typed_edges.py +860 -0
  44. chip_memory-1.1.0/src/chip_memory/health.py +191 -0
  45. chip_memory-1.1.0/src/chip_memory/hermes.py +363 -0
  46. chip_memory-1.1.0/src/chip_memory/linker.py +503 -0
  47. chip_memory-1.1.0/src/chip_memory/map_cmd.py +140 -0
  48. chip_memory-1.1.0/src/chip_memory/mcp_server.py +491 -0
  49. chip_memory-1.1.0/src/chip_memory/node.py +598 -0
  50. chip_memory-1.1.0/src/chip_memory/paths.py +109 -0
  51. chip_memory-1.1.0/src/chip_memory/pending.py +78 -0
  52. chip_memory-1.1.0/src/chip_memory/py.typed +0 -0
  53. chip_memory-1.1.0/src/chip_memory/query/__init__.py +2 -0
  54. chip_memory-1.1.0/src/chip_memory/query/triple_query.py +347 -0
  55. chip_memory-1.1.0/src/chip_memory/rebalance.py +67 -0
  56. chip_memory-1.1.0/src/chip_memory/recall.py +149 -0
  57. chip_memory-1.1.0/src/chip_memory/search.py +477 -0
  58. chip_memory-1.1.0/src/chip_memory/seed.py +86 -0
  59. chip_memory-1.1.0/src/chip_memory/server.py +355 -0
  60. chip_memory-1.1.0/src/chip_memory/synthesis/__init__.py +6 -0
  61. chip_memory-1.1.0/src/chip_memory/synthesis/think.py +965 -0
  62. chip_memory-1.1.0/src/chip_memory/telegram_watch.py +590 -0
  63. chip_memory-1.1.0/src/chip_memory/timeline.py +489 -0
  64. chip_memory-1.1.0/src/chip_memory/timeline_cmd.py +93 -0
  65. chip_memory-1.1.0/src/chip_memory/tui.py +678 -0
  66. chip_memory-1.1.0/src/chip_memory/uninstall.py +179 -0
  67. chip_memory-1.1.0/src/chip_memory/watch_context.py +360 -0
  68. chip_memory-1.1.0/src/chip_memory/why.py +32 -0
  69. chip_memory-1.1.0/src/chip_memory.egg-info/PKG-INFO +289 -0
  70. chip_memory-1.1.0/src/chip_memory.egg-info/SOURCES.txt +98 -0
  71. chip_memory-1.1.0/src/chip_memory.egg-info/dependency_links.txt +1 -0
  72. chip_memory-1.1.0/src/chip_memory.egg-info/entry_points.txt +2 -0
  73. chip_memory-1.1.0/src/chip_memory.egg-info/requires.txt +24 -0
  74. chip_memory-1.1.0/src/chip_memory.egg-info/top_level.txt +1 -0
  75. chip_memory-1.1.0/tests/test_aliases.py +174 -0
  76. chip_memory-1.1.0/tests/test_api.py +245 -0
  77. chip_memory-1.1.0/tests/test_collect.py +302 -0
  78. chip_memory-1.1.0/tests/test_core.py +222 -0
  79. chip_memory-1.1.0/tests/test_daemon.py +423 -0
  80. chip_memory-1.1.0/tests/test_dashboard.py +428 -0
  81. chip_memory-1.1.0/tests/test_eval.py +87 -0
  82. chip_memory-1.1.0/tests/test_export_wiki.py +296 -0
  83. chip_memory-1.1.0/tests/test_hermes.py +258 -0
  84. chip_memory-1.1.0/tests/test_map.py +246 -0
  85. chip_memory-1.1.0/tests/test_mcp_server.py +153 -0
  86. chip_memory-1.1.0/tests/test_pending.py +63 -0
  87. chip_memory-1.1.0/tests/test_phase2.py +433 -0
  88. chip_memory-1.1.0/tests/test_phase3.py +353 -0
  89. chip_memory-1.1.0/tests/test_predicate_vocab.py +217 -0
  90. chip_memory-1.1.0/tests/test_redact.py +141 -0
  91. chip_memory-1.1.0/tests/test_rerank.py +163 -0
  92. chip_memory-1.1.0/tests/test_safety.py +527 -0
  93. chip_memory-1.1.0/tests/test_search.py +388 -0
  94. chip_memory-1.1.0/tests/test_server.py +91 -0
  95. chip_memory-1.1.0/tests/test_telegram_watch.py +220 -0
  96. chip_memory-1.1.0/tests/test_timeline.py +275 -0
  97. chip_memory-1.1.0/tests/test_triple_query.py +381 -0
  98. chip_memory-1.1.0/tests/test_tui.py +71 -0
  99. chip_memory-1.1.0/tests/test_typed_edges.py +765 -0
  100. chip_memory-1.1.0/tests/test_uninstall.py +389 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ivan Chakurov
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,289 @@
1
+ Metadata-Version: 2.4
2
+ Name: chip-memory
3
+ Version: 1.1.0
4
+ Summary: Local-first, self-organizing memory layer for AI agents. Auto-absorbs knowledge from shell history, git, and Claude Code sessions. MCP-native.
5
+ Author-email: Ivan Chakurov <ivan@chakurov.dev>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Ivan Chakurov
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/chakurov1907-cyber/chip-memory
29
+ Project-URL: Issues, https://github.com/chakurov1907-cyber/chip-memory/issues
30
+ Keywords: ai,agents,memory,rag,semantic-search,local-first,self-hosted,mcp,knowledge-graph
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
39
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
40
+ Requires-Python: >=3.10
41
+ Description-Content-Type: text/markdown
42
+ License-File: LICENSE
43
+ Requires-Dist: pyyaml>=6.0
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest<9.0,>=7.0; extra == "dev"
46
+ Requires-Dist: pytest-cov<7.0,>=4.0; extra == "dev"
47
+ Provides-Extra: embeddings
48
+ Requires-Dist: numpy<3.0,>=1.24; extra == "embeddings"
49
+ Requires-Dist: sentence-transformers<4.0,>=2.2.0; extra == "embeddings"
50
+ Requires-Dist: torch<3.0,>=2.0; extra == "embeddings"
51
+ Provides-Extra: llm
52
+ Provides-Extra: rerank
53
+ Requires-Dist: flashrank<1.0,>=0.2.10; extra == "rerank"
54
+ Provides-Extra: tui
55
+ Requires-Dist: textual<2.0,>=0.40; extra == "tui"
56
+ Provides-Extra: telegram
57
+ Requires-Dist: telethon<2.0,>=1.28; extra == "telegram"
58
+ Provides-Extra: mcp
59
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
60
+ Dynamic: license-file
61
+
62
+ # chip-memory
63
+
64
+ **The local-first agent brain. A temporal knowledge graph, human-in-the-loop review, and full provenance, running entirely on your machine with zero cloud and no required LLM.**
65
+
66
+ [![CI](https://github.com/chakurov1907-cyber/chip-memory/actions/workflows/test.yml/badge.svg)](https://github.com/chakurov1907-cyber/chip-memory/actions/workflows/test.yml)
67
+ [![PyPI version](https://img.shields.io/pypi/v/chip-memory.svg)](https://pypi.org/project/chip-memory/)
68
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
69
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
70
+
71
+ ![demo](assets/demo.gif)
72
+
73
+ > *AI agents forget everything when the session ends. chip-memory fixes that — local, free, learns from use.*
74
+
75
+ ## Quick start — 60 seconds
76
+
77
+ ```bash
78
+ pip install chip-memory
79
+ chip-memory seed # 15 demo nodes across 4 domains
80
+ chip-memory search "Hall of Light" # hybrid search, sub-millisecond
81
+ chip-memory think "who works at Acme Corp" # cited evidence + knowledge gaps
82
+ ```
83
+
84
+ That's it. The brain is plain JSON on disk. Back it up with `cp`.
85
+
86
+ **MCP for Claude Desktop / Claude Code:**
87
+
88
+ Add this to your Claude Desktop config and restart:
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "chip-memory": {
94
+ "command": "chip-memory",
95
+ "args": ["mcp"]
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ Your agent now has `memory_search`, `memory_remember`, `memory_context_for`, `memory_think`, and `memory_bump` as native tools — persistent memory across every session.
102
+
103
+ ## Features
104
+
105
+ - 🏠 **Local-first** — all data is plain JSON files on disk. No cloud, no account, no API key needed. Back it up with `cp`.
106
+ - 🚫 **Zero LLM required** — core search and linking runs on pure stdlib. No embeddings, no torch, no model download for daily use.
107
+ - 🔗 **Temporal knowledge graph** — typed edges with bi-temporal validity (`valid_from` / `valid_to`). Query "where did Alice work in 2023?" or "who *currently* runs Acme?" with `as_of` semantics.
108
+ - ⏳ **Bi-temporal edges** — single-valued predicates auto-supersede (old facts get `valid_to` + `superseded_by`, never deleted). Multi-valued predicates just append.
109
+ - 🧠 **Think mode** — `chip-memory think "who works at Acme"` returns cited evidence from the brain, explicit knowledge gaps, and (via MCP sampling) fluent prose synthesized by your host LLM — no extra key required.
110
+ - 🔗 **Connect queries** — `chip-memory connect "Alice" "Bob"` finds the multi-hop path (up to 3 hops) between any two entities through the typed edge graph.
111
+ - 📜 **Provenance + `why`** — every node tracks its source (`git`, `user-correct`, `signal`, `manual`), trust confidence, and access history. `chip-memory why <id>` prints the full audit trail.
112
+ - 🔍 **Hybrid search** — `0.7 × vector + 0.3 × BM25`, then `× heat × importance × trust`. `--bm25-only` skips embeddings entirely and stays sub-millisecond.
113
+ - 🌱 **Living knowledge graph** — links get +0.15 on co-access, decay 1% per cycle, and are severed below 0.10. The graph mirrors how you actually use it.
114
+ - 🚦 **Signal detector** — real-time message scoring classifies corrections (even natural language: "no, the interval is 5 minutes not 10"), high-signal knowledge, and low-signal chit-chat — all with zero LLM.
115
+ - 🔗 **MCP-native** — native Model Context Protocol server. Any MCP client (Claude Desktop, Claude Code, Cursor) gets persistent memory tools with no plugins or glue code.
116
+ - 👁 **Human review workflow** — `chip-memory review` shows a review queue before anything enters the brain. Guided mode, strict mode, or auto mode.
117
+ - 📦 **Zero deps** — `pip install chip-memory` installs zero network dependencies. Optional extras add embeddings, reranking, TUI, or LLM extraction behind lazy imports.
118
+
119
+ ## Comparison
120
+
121
+ | Feature | chip-memory | Mem0 | Zep / Graphiti | Letta | Cognee |
122
+ |---|---|---|---|---|---|
123
+ | **Local-first** | ✅ Local JSON | ❌ Cloud | ❌ Cloud | ❌ Cloud | ❌ Cloud |
124
+ | **No LLM required** | ✅ Zero LLM for core | ❌ LLM-dependent | ❌ LLM-dependent | ❌ LLM-dependent | ❌ LLM-dependent |
125
+ | **Temporal / bi-temporal graph** | ✅ Bi-temporal edges, local | ❌ No | ⚠️ Temporal via cloud Neo4j | ❌ No | ❌ No |
126
+ | **Human review workflow** | ✅ Review queue (guided/strict/auto) | ❌ No | ❌ No | ❌ No | ❌ No |
127
+ | **Provenance / `why` command** | ✅ Per-node provenance + trust | ⚠️ Partial | ⚠️ Partial | ❌ No | ❌ No |
128
+ | **Cost** | **$0 (free, MIT)** | 💰 SaaS | 💰 SaaS | 💰 SaaS | 💰 SaaS |
129
+ | **MCP-native** | ✅ Native MCP server | ✅ MCP | ⚠️ API wrapper | ✅ MCP | ❌ No |
130
+ | **Secret redaction** | ✅ 17 patterns, pre-write | ❌ No | ❌ No | ❌ No | ❌ No |
131
+
132
+ ### Where they're ahead
133
+
134
+ - **Managed scale** — Mem0 and Zep handle 100k+ nodes with hosted infrastructure. chip-memory is optimized for the sweet spot (~5k nodes) on a single machine.
135
+ - **Ecosystem** — Mem0, Letta, and Cognee have larger communities and more integrations. chip-memory is newer and growing.
136
+ - **Team size** — hosted solutions have dedicated support, SLAs, and enterprise features. chip-memory is MIT — community-supported.
137
+
138
+ ## MCP integration — Claude Desktop
139
+
140
+ The native MCP server gives Claude persistent memory across sessions.
141
+
142
+ **Claude Desktop config (`claude_desktop_config.json`):**
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "chip-memory": {
148
+ "command": "chip-memory",
149
+ "args": ["mcp"]
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ **Claude Code** auto-discovers the MCP server when installed. No additional config needed.
156
+
157
+ Available MCP tools:
158
+
159
+ | Tool | Description |
160
+ |---|---|
161
+ | `memory_search` | Semantic search over the brain |
162
+ | `memory_remember` | Store a fact |
163
+ | `memory_context_for` | Get relevant context for a prompt |
164
+ | `memory_think` | Answer with cited evidence + gaps (uses host LLM via MCP sampling) |
165
+ | `memory_bump` | Boost a node's heat on access |
166
+
167
+ ## Reproducible eval
168
+
169
+ ```bash
170
+ chip-memory eval
171
+ ```
172
+
173
+ ```
174
+ ✅ PASS P@3=1.000 P@5=1.000 13/13 passed
175
+ ```
176
+
177
+ Benchmark: **NamedThingBench** (13 queries) — a curated set of entity-resolution queries over a seeded fixture brain. Run it yourself in under 2 seconds.
178
+
179
+ ## Who this is for
180
+
181
+ - **Agent developers** using Claude Code, Aider, Hermes, OpenClaw, or your own scripts — drop a session transcript into `pending/` and the brain extracts memory nodes automatically.
182
+ - **People running local models** who want memory that doesn't need a cloud, an account, or an API key for the brain itself.
183
+ - **Hobbyists tired of paying for embeddings.** The brain runs on stdlib — install `chip-memory[embeddings]` (~800MB) only when you want semantic search.
184
+
185
+ ## The problem it solves
186
+
187
+ Without chip-memory, every agent session starts blank:
188
+
189
+ > You: "what was that uv trick for installing tools?"
190
+ > Agent: "I don't have memory of previous conversations."
191
+
192
+ With chip-memory:
193
+
194
+ > You: "what was that uv trick for installing tools?"
195
+ > Agent: _[reads brain]_
196
+ > "Found it:
197
+ > - uv is the fastest way to install Python tools in 2026. `uvx ruff` runs ruff without polluting your system Python.
198
+ > - linked to: 'When debugging a Python script that crashes deep in a third-party library, set PYTHONFAULTHANDLER=1 first...'"
199
+
200
+ The brain remembered. You didn't have to.
201
+
202
+ ## Quick reference
203
+
204
+ ```bash
205
+ chip-memory search "debug python" # hybrid search
206
+ chip-memory think "what's the deployment setup" # cited evidence + gaps
207
+ chip-memory connect "Alice" "Bob" # multi-hop path
208
+ chip-memory why <node_id> # provenance + audit trail
209
+ chip-memory recall yesterday # episodic timeline recall
210
+ chip-memory absorb --dry-run # preview machine knowledge
211
+ chip-memory review # review queue
212
+ chip-memory map hubs # top connected nodes
213
+ chip-memory timeline # brain activity log
214
+ chip-memory dashboard # web dashboard (127.0.0.1:8732)
215
+ chip-memory export "topic" -o topic.md # markdown export
216
+ chip-memory health # brain health score
217
+ ```
218
+
219
+ ## Install
220
+
221
+ ```bash
222
+ pip install chip-memory
223
+ ```
224
+
225
+ From source:
226
+
227
+ ```bash
228
+ git clone https://github.com/chakurov1907-cyber/chip-memory
229
+ cd chip-memory
230
+ pip install -e . # stdlib only
231
+ pip install -e ".[embeddings]" # + vector search (torch + sentence-transformers)
232
+ ```
233
+
234
+ ## Develop
235
+
236
+ ```bash
237
+ git clone https://github.com/chakurov1907-cyber/chip-memory
238
+ cd chip-memory
239
+ python3 -m venv .venv
240
+ source .venv/bin/activate
241
+ pip install -e ".[dev]"
242
+ pytest # 476 tests, ~11s
243
+ chip-memory --help
244
+ ```
245
+
246
+ ## How scoring works
247
+
248
+ ```
249
+ hybrid = 0.7 × cosine_sim + 0.3 × normalized_bm25
250
+ score = hybrid × heat × importance × (0.6 + 0.4 × trust_confidence)
251
+ ```
252
+
253
+ - **cosine_sim** — from `all-MiniLM-L6-v2` (optional, behind `[embeddings]`)
254
+ - **BM25** — pure stdlib, no sklearn
255
+ - **heat** — decays 5% per cycle, boosted by access × importance
256
+ - **trust_confidence** — source-based (git-fix: 0.9, user-correct: 0.85, manual: 0.8, signal: 0.6)
257
+
258
+ ## Honest limits
259
+
260
+ - **Scale:** works fine to ~5k nodes. Past that, search latency climbs because the embedder loads one node at a time. For 10k+ nodes, swap in a real vector DB and use chip-memory as the connection layer.
261
+ - **Multi-tenant:** one brain per directory. Use `CHIP_BRAIN_DIR` env var to switch.
262
+ - **Concurrency:** atomic writes (`tmp` + `os.replace()`) prevent corruption, but two simultaneous writers to the same node will lose one's edits.
263
+
264
+ ## Uninstall
265
+
266
+ ```bash
267
+ chip-memory uninstall # interactive — asks for confirmation
268
+ chip-memory uninstall --force # skip confirmation
269
+ chip-memory uninstall --keep-brain # remove daemon/hooks/config but keep brain data
270
+ ```
271
+
272
+ Removes the daemon process (if running), git post-commit hooks, background watchers, and brain data. To also remove the package itself:
273
+
274
+ ```bash
275
+ pip uninstall chip-memory
276
+ ```
277
+
278
+ ## Architecture
279
+
280
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for the full system design: heat/decay mechanics, living graph dynamics, bi-temporal edge semantics, signal detector pipeline, MCP integration, and temporal reasoning.
281
+
282
+ - [PRIVACY.md](PRIVACY.md) — local-only, no telemetry, redaction
283
+ - [SECURITY.md](SECURITY.md) — disclosure, auth, path traversal
284
+ - [CONTRIBUTING.md](CONTRIBUTING.md) — how to build and contribute
285
+ - [CHANGELOG.md](CHANGELOG.md) — release history
286
+
287
+ ## License
288
+
289
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,228 @@
1
+ # chip-memory
2
+
3
+ **The local-first agent brain. A temporal knowledge graph, human-in-the-loop review, and full provenance, running entirely on your machine with zero cloud and no required LLM.**
4
+
5
+ [![CI](https://github.com/chakurov1907-cyber/chip-memory/actions/workflows/test.yml/badge.svg)](https://github.com/chakurov1907-cyber/chip-memory/actions/workflows/test.yml)
6
+ [![PyPI version](https://img.shields.io/pypi/v/chip-memory.svg)](https://pypi.org/project/chip-memory/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
9
+
10
+ ![demo](assets/demo.gif)
11
+
12
+ > *AI agents forget everything when the session ends. chip-memory fixes that — local, free, learns from use.*
13
+
14
+ ## Quick start — 60 seconds
15
+
16
+ ```bash
17
+ pip install chip-memory
18
+ chip-memory seed # 15 demo nodes across 4 domains
19
+ chip-memory search "Hall of Light" # hybrid search, sub-millisecond
20
+ chip-memory think "who works at Acme Corp" # cited evidence + knowledge gaps
21
+ ```
22
+
23
+ That's it. The brain is plain JSON on disk. Back it up with `cp`.
24
+
25
+ **MCP for Claude Desktop / Claude Code:**
26
+
27
+ Add this to your Claude Desktop config and restart:
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "chip-memory": {
33
+ "command": "chip-memory",
34
+ "args": ["mcp"]
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ Your agent now has `memory_search`, `memory_remember`, `memory_context_for`, `memory_think`, and `memory_bump` as native tools — persistent memory across every session.
41
+
42
+ ## Features
43
+
44
+ - 🏠 **Local-first** — all data is plain JSON files on disk. No cloud, no account, no API key needed. Back it up with `cp`.
45
+ - 🚫 **Zero LLM required** — core search and linking runs on pure stdlib. No embeddings, no torch, no model download for daily use.
46
+ - 🔗 **Temporal knowledge graph** — typed edges with bi-temporal validity (`valid_from` / `valid_to`). Query "where did Alice work in 2023?" or "who *currently* runs Acme?" with `as_of` semantics.
47
+ - ⏳ **Bi-temporal edges** — single-valued predicates auto-supersede (old facts get `valid_to` + `superseded_by`, never deleted). Multi-valued predicates just append.
48
+ - 🧠 **Think mode** — `chip-memory think "who works at Acme"` returns cited evidence from the brain, explicit knowledge gaps, and (via MCP sampling) fluent prose synthesized by your host LLM — no extra key required.
49
+ - 🔗 **Connect queries** — `chip-memory connect "Alice" "Bob"` finds the multi-hop path (up to 3 hops) between any two entities through the typed edge graph.
50
+ - 📜 **Provenance + `why`** — every node tracks its source (`git`, `user-correct`, `signal`, `manual`), trust confidence, and access history. `chip-memory why <id>` prints the full audit trail.
51
+ - 🔍 **Hybrid search** — `0.7 × vector + 0.3 × BM25`, then `× heat × importance × trust`. `--bm25-only` skips embeddings entirely and stays sub-millisecond.
52
+ - 🌱 **Living knowledge graph** — links get +0.15 on co-access, decay 1% per cycle, and are severed below 0.10. The graph mirrors how you actually use it.
53
+ - 🚦 **Signal detector** — real-time message scoring classifies corrections (even natural language: "no, the interval is 5 minutes not 10"), high-signal knowledge, and low-signal chit-chat — all with zero LLM.
54
+ - 🔗 **MCP-native** — native Model Context Protocol server. Any MCP client (Claude Desktop, Claude Code, Cursor) gets persistent memory tools with no plugins or glue code.
55
+ - 👁 **Human review workflow** — `chip-memory review` shows a review queue before anything enters the brain. Guided mode, strict mode, or auto mode.
56
+ - 📦 **Zero deps** — `pip install chip-memory` installs zero network dependencies. Optional extras add embeddings, reranking, TUI, or LLM extraction behind lazy imports.
57
+
58
+ ## Comparison
59
+
60
+ | Feature | chip-memory | Mem0 | Zep / Graphiti | Letta | Cognee |
61
+ |---|---|---|---|---|---|
62
+ | **Local-first** | ✅ Local JSON | ❌ Cloud | ❌ Cloud | ❌ Cloud | ❌ Cloud |
63
+ | **No LLM required** | ✅ Zero LLM for core | ❌ LLM-dependent | ❌ LLM-dependent | ❌ LLM-dependent | ❌ LLM-dependent |
64
+ | **Temporal / bi-temporal graph** | ✅ Bi-temporal edges, local | ❌ No | ⚠️ Temporal via cloud Neo4j | ❌ No | ❌ No |
65
+ | **Human review workflow** | ✅ Review queue (guided/strict/auto) | ❌ No | ❌ No | ❌ No | ❌ No |
66
+ | **Provenance / `why` command** | ✅ Per-node provenance + trust | ⚠️ Partial | ⚠️ Partial | ❌ No | ❌ No |
67
+ | **Cost** | **$0 (free, MIT)** | 💰 SaaS | 💰 SaaS | 💰 SaaS | 💰 SaaS |
68
+ | **MCP-native** | ✅ Native MCP server | ✅ MCP | ⚠️ API wrapper | ✅ MCP | ❌ No |
69
+ | **Secret redaction** | ✅ 17 patterns, pre-write | ❌ No | ❌ No | ❌ No | ❌ No |
70
+
71
+ ### Where they're ahead
72
+
73
+ - **Managed scale** — Mem0 and Zep handle 100k+ nodes with hosted infrastructure. chip-memory is optimized for the sweet spot (~5k nodes) on a single machine.
74
+ - **Ecosystem** — Mem0, Letta, and Cognee have larger communities and more integrations. chip-memory is newer and growing.
75
+ - **Team size** — hosted solutions have dedicated support, SLAs, and enterprise features. chip-memory is MIT — community-supported.
76
+
77
+ ## MCP integration — Claude Desktop
78
+
79
+ The native MCP server gives Claude persistent memory across sessions.
80
+
81
+ **Claude Desktop config (`claude_desktop_config.json`):**
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "chip-memory": {
87
+ "command": "chip-memory",
88
+ "args": ["mcp"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ **Claude Code** auto-discovers the MCP server when installed. No additional config needed.
95
+
96
+ Available MCP tools:
97
+
98
+ | Tool | Description |
99
+ |---|---|
100
+ | `memory_search` | Semantic search over the brain |
101
+ | `memory_remember` | Store a fact |
102
+ | `memory_context_for` | Get relevant context for a prompt |
103
+ | `memory_think` | Answer with cited evidence + gaps (uses host LLM via MCP sampling) |
104
+ | `memory_bump` | Boost a node's heat on access |
105
+
106
+ ## Reproducible eval
107
+
108
+ ```bash
109
+ chip-memory eval
110
+ ```
111
+
112
+ ```
113
+ ✅ PASS P@3=1.000 P@5=1.000 13/13 passed
114
+ ```
115
+
116
+ Benchmark: **NamedThingBench** (13 queries) — a curated set of entity-resolution queries over a seeded fixture brain. Run it yourself in under 2 seconds.
117
+
118
+ ## Who this is for
119
+
120
+ - **Agent developers** using Claude Code, Aider, Hermes, OpenClaw, or your own scripts — drop a session transcript into `pending/` and the brain extracts memory nodes automatically.
121
+ - **People running local models** who want memory that doesn't need a cloud, an account, or an API key for the brain itself.
122
+ - **Hobbyists tired of paying for embeddings.** The brain runs on stdlib — install `chip-memory[embeddings]` (~800MB) only when you want semantic search.
123
+
124
+ ## The problem it solves
125
+
126
+ Without chip-memory, every agent session starts blank:
127
+
128
+ > You: "what was that uv trick for installing tools?"
129
+ > Agent: "I don't have memory of previous conversations."
130
+
131
+ With chip-memory:
132
+
133
+ > You: "what was that uv trick for installing tools?"
134
+ > Agent: _[reads brain]_
135
+ > "Found it:
136
+ > - uv is the fastest way to install Python tools in 2026. `uvx ruff` runs ruff without polluting your system Python.
137
+ > - linked to: 'When debugging a Python script that crashes deep in a third-party library, set PYTHONFAULTHANDLER=1 first...'"
138
+
139
+ The brain remembered. You didn't have to.
140
+
141
+ ## Quick reference
142
+
143
+ ```bash
144
+ chip-memory search "debug python" # hybrid search
145
+ chip-memory think "what's the deployment setup" # cited evidence + gaps
146
+ chip-memory connect "Alice" "Bob" # multi-hop path
147
+ chip-memory why <node_id> # provenance + audit trail
148
+ chip-memory recall yesterday # episodic timeline recall
149
+ chip-memory absorb --dry-run # preview machine knowledge
150
+ chip-memory review # review queue
151
+ chip-memory map hubs # top connected nodes
152
+ chip-memory timeline # brain activity log
153
+ chip-memory dashboard # web dashboard (127.0.0.1:8732)
154
+ chip-memory export "topic" -o topic.md # markdown export
155
+ chip-memory health # brain health score
156
+ ```
157
+
158
+ ## Install
159
+
160
+ ```bash
161
+ pip install chip-memory
162
+ ```
163
+
164
+ From source:
165
+
166
+ ```bash
167
+ git clone https://github.com/chakurov1907-cyber/chip-memory
168
+ cd chip-memory
169
+ pip install -e . # stdlib only
170
+ pip install -e ".[embeddings]" # + vector search (torch + sentence-transformers)
171
+ ```
172
+
173
+ ## Develop
174
+
175
+ ```bash
176
+ git clone https://github.com/chakurov1907-cyber/chip-memory
177
+ cd chip-memory
178
+ python3 -m venv .venv
179
+ source .venv/bin/activate
180
+ pip install -e ".[dev]"
181
+ pytest # 476 tests, ~11s
182
+ chip-memory --help
183
+ ```
184
+
185
+ ## How scoring works
186
+
187
+ ```
188
+ hybrid = 0.7 × cosine_sim + 0.3 × normalized_bm25
189
+ score = hybrid × heat × importance × (0.6 + 0.4 × trust_confidence)
190
+ ```
191
+
192
+ - **cosine_sim** — from `all-MiniLM-L6-v2` (optional, behind `[embeddings]`)
193
+ - **BM25** — pure stdlib, no sklearn
194
+ - **heat** — decays 5% per cycle, boosted by access × importance
195
+ - **trust_confidence** — source-based (git-fix: 0.9, user-correct: 0.85, manual: 0.8, signal: 0.6)
196
+
197
+ ## Honest limits
198
+
199
+ - **Scale:** works fine to ~5k nodes. Past that, search latency climbs because the embedder loads one node at a time. For 10k+ nodes, swap in a real vector DB and use chip-memory as the connection layer.
200
+ - **Multi-tenant:** one brain per directory. Use `CHIP_BRAIN_DIR` env var to switch.
201
+ - **Concurrency:** atomic writes (`tmp` + `os.replace()`) prevent corruption, but two simultaneous writers to the same node will lose one's edits.
202
+
203
+ ## Uninstall
204
+
205
+ ```bash
206
+ chip-memory uninstall # interactive — asks for confirmation
207
+ chip-memory uninstall --force # skip confirmation
208
+ chip-memory uninstall --keep-brain # remove daemon/hooks/config but keep brain data
209
+ ```
210
+
211
+ Removes the daemon process (if running), git post-commit hooks, background watchers, and brain data. To also remove the package itself:
212
+
213
+ ```bash
214
+ pip uninstall chip-memory
215
+ ```
216
+
217
+ ## Architecture
218
+
219
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for the full system design: heat/decay mechanics, living graph dynamics, bi-temporal edge semantics, signal detector pipeline, MCP integration, and temporal reasoning.
220
+
221
+ - [PRIVACY.md](PRIVACY.md) — local-only, no telemetry, redaction
222
+ - [SECURITY.md](SECURITY.md) — disclosure, auth, path traversal
223
+ - [CONTRIBUTING.md](CONTRIBUTING.md) — how to build and contribute
224
+ - [CHANGELOG.md](CHANGELOG.md) — release history
225
+
226
+ ## License
227
+
228
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,95 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "chip-memory"
7
+ version = "1.1.0"
8
+ description = "Local-first, self-organizing memory layer for AI agents. Auto-absorbs knowledge from shell history, git, and Claude Code sessions. MCP-native."
9
+ readme = "README.md"
10
+ license = {file = "LICENSE"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Ivan Chakurov", email = "ivan@chakurov.dev"},
14
+ ]
15
+ keywords = ["ai", "agents", "memory", "rag", "semantic-search", "local-first", "self-hosted", "mcp", "knowledge-graph"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ ]
27
+
28
+ dependencies = [
29
+ # All heavy deps (numpy, sentence-transformers, torch) are lazy-imported
30
+ # inside _get_model() and _get_or_compute_embeddings() so a fresh install
31
+ # is just stdlib. To enable semantic search, install the `embeddings` extra:
32
+ # pip install chip-memory[embeddings]
33
+ # pyyaml: required by eval.py for loading the NamedThingBench YAML fixture
34
+ "pyyaml>=6.0",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=7.0,<9.0",
40
+ "pytest-cov>=4.0,<7.0",
41
+ ]
42
+ embeddings = [
43
+ "numpy>=1.24,<3.0",
44
+ "sentence-transformers>=2.2.0,<4.0",
45
+ "torch>=2.0,<3.0",
46
+ ]
47
+ llm = [
48
+ # For --provider groq or openai (the heuristic extractor needs no API key)
49
+ ]
50
+ rerank = [
51
+ "flashrank>=0.2.10,<1.0",
52
+ ]
53
+ tui = [
54
+ "textual>=0.40,<2.0",
55
+ ]
56
+ telegram = [
57
+ "telethon>=1.28,<2.0",
58
+ ]
59
+ mcp = [
60
+ "mcp>=1.0.0",
61
+ ]
62
+
63
+ [project.scripts]
64
+ chip-memory = "chip_memory.__main__:main"
65
+
66
+ [project.urls]
67
+ Homepage = "https://github.com/chakurov1907-cyber/chip-memory"
68
+ Issues = "https://github.com/chakurov1907-cyber/chip-memory/issues"
69
+
70
+ [tool.setuptools.packages.find]
71
+ where = ["src"]
72
+
73
+ [tool.setuptools.package-data]
74
+ chip_memory = ["py.typed", "dashboard/static/*.html", "dashboard/static/*.json", "dashboard/static/vendor/*.js"]
75
+
76
+ [tool.pytest.ini_options]
77
+ testpaths = ["tests"]
78
+ python_files = ["test_*.py"]
79
+ addopts = "-v --tb=short"
80
+
81
+ [tool.ruff]
82
+ # F401 (unused imports): allowed for lazy/optional-import guards — see auto_write.py
83
+ # and tui.py where imports are wrapped in try/except ImportError.
84
+ # F841 (unused local): allowed for argparse sub-parser bindings (the name must
85
+ # be in scope for argparse to dispatch on it).
86
+ line-length = 100
87
+ extend-exclude = []
88
+
89
+ [tool.ruff.lint]
90
+ select = ["E", "F", "W"]
91
+ ignore = [
92
+ "E501", # line-too-long (we judge this by hand, not by tool)
93
+ "F401", # unused-import (lazy guards + argparse patterns)
94
+ "F841", # unused-local (argparse subparser vars + tui placeholders)
95
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ """
2
+ chip_memory — local-first, self-organizing memory layer for AI agents.
3
+
4
+ Inspired by how microchips work: isolated nodes (transistors) organized in
5
+ layers, with a daemon (electricity) always running, become a CPU (a brain).
6
+
7
+ Public API:
8
+ - chip_memory.search — semantic search over the brain
9
+ - chip_memory.health — brain health score + per-domain stats
10
+ - chip_memory.auto_write — extract nodes from a transcript
11
+ - chip_memory.pending — process pending/ → write nodes
12
+ - chip_memory.seed — seed demo nodes for trying the system
13
+ - chip_memory.rebalance — adjust importance/heat of existing nodes
14
+ - chip_memory.daemon — the always-on loop
15
+ - chip_memory.server — tiny HTTP API (run separately)
16
+ """
17
+ __version__ = "1.1.0"
18
+ __all__ = [
19
+ "api",
20
+ "auto_write",
21
+ "daemon",
22
+ "dashboard",
23
+ "health",
24
+ "node",
25
+ "paths",
26
+ "pending",
27
+ "rebalance",
28
+ "search",
29
+ "seed",
30
+ "server",
31
+ ]