engram-chateau 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 (62) hide show
  1. engram_chateau-1.1.0/LICENSE +21 -0
  2. engram_chateau-1.1.0/PKG-INFO +547 -0
  3. engram_chateau-1.1.0/README.md +500 -0
  4. engram_chateau-1.1.0/engram/__init__.py +8 -0
  5. engram_chateau-1.1.0/engram/agents.py +207 -0
  6. engram_chateau-1.1.0/engram/audit.py +219 -0
  7. engram_chateau-1.1.0/engram/backends/__init__.py +48 -0
  8. engram_chateau-1.1.0/engram/backends/base.py +52 -0
  9. engram_chateau-1.1.0/engram/backends/chromadb_backend.py +118 -0
  10. engram_chateau-1.1.0/engram/backends/faiss_backend.py +146 -0
  11. engram_chateau-1.1.0/engram/backends/sqlitevec_backend.py +185 -0
  12. engram_chateau-1.1.0/engram/chateau.py +462 -0
  13. engram_chateau-1.1.0/engram/chateau_graph.py +89 -0
  14. engram_chateau-1.1.0/engram/classifier.py +104 -0
  15. engram_chateau-1.1.0/engram/cli.py +837 -0
  16. engram_chateau-1.1.0/engram/config.py +89 -0
  17. engram_chateau-1.1.0/engram/conflict.py +271 -0
  18. engram_chateau-1.1.0/engram/convo_miner.py +318 -0
  19. engram_chateau-1.1.0/engram/hooks/engram_precompact_hook.sh +59 -0
  20. engram_chateau-1.1.0/engram/hooks/engram_save_hook.sh +61 -0
  21. engram_chateau-1.1.0/engram/indexing.py +84 -0
  22. engram_chateau-1.1.0/engram/knowledge_graph.py +285 -0
  23. engram_chateau-1.1.0/engram/layers.py +157 -0
  24. engram_chateau-1.1.0/engram/mcp_server.py +533 -0
  25. engram_chateau-1.1.0/engram/miner.py +223 -0
  26. engram_chateau-1.1.0/engram/onboarding.py +168 -0
  27. engram_chateau-1.1.0/engram/plugins/__init__.py +22 -0
  28. engram_chateau-1.1.0/engram/plugins/base.py +37 -0
  29. engram_chateau-1.1.0/engram/plugins/linear.py +115 -0
  30. engram_chateau-1.1.0/engram/plugins/notion.py +95 -0
  31. engram_chateau-1.1.0/engram/plugins/obsidian.py +134 -0
  32. engram_chateau-1.1.0/engram/provenance.py +100 -0
  33. engram_chateau-1.1.0/engram/qa.py +125 -0
  34. engram_chateau-1.1.0/engram/replay.py +135 -0
  35. engram_chateau-1.1.0/engram/searcher.py +164 -0
  36. engram_chateau-1.1.0/engram/shorthand.py +424 -0
  37. engram_chateau-1.1.0/engram/typed_memory.py +198 -0
  38. engram_chateau-1.1.0/engram/ui.html +1229 -0
  39. engram_chateau-1.1.0/engram/watcher.py +134 -0
  40. engram_chateau-1.1.0/engram_chateau.egg-info/PKG-INFO +547 -0
  41. engram_chateau-1.1.0/engram_chateau.egg-info/SOURCES.txt +60 -0
  42. engram_chateau-1.1.0/engram_chateau.egg-info/dependency_links.txt +1 -0
  43. engram_chateau-1.1.0/engram_chateau.egg-info/entry_points.txt +2 -0
  44. engram_chateau-1.1.0/engram_chateau.egg-info/requires.txt +30 -0
  45. engram_chateau-1.1.0/engram_chateau.egg-info/top_level.txt +1 -0
  46. engram_chateau-1.1.0/pyproject.toml +85 -0
  47. engram_chateau-1.1.0/setup.cfg +4 -0
  48. engram_chateau-1.1.0/tests/test_backends.py +54 -0
  49. engram_chateau-1.1.0/tests/test_chateau.py +219 -0
  50. engram_chateau-1.1.0/tests/test_classifier.py +99 -0
  51. engram_chateau-1.1.0/tests/test_conflict.py +149 -0
  52. engram_chateau-1.1.0/tests/test_hooks.py +211 -0
  53. engram_chateau-1.1.0/tests/test_indexing.py +135 -0
  54. engram_chateau-1.1.0/tests/test_knowledge_graph.py +159 -0
  55. engram_chateau-1.1.0/tests/test_mcp_server.py +188 -0
  56. engram_chateau-1.1.0/tests/test_name_validation.py +63 -0
  57. engram_chateau-1.1.0/tests/test_scripts.py +62 -0
  58. engram_chateau-1.1.0/tests/test_searcher.py +147 -0
  59. engram_chateau-1.1.0/tests/test_shorthand.py +237 -0
  60. engram_chateau-1.1.0/tests/test_sqlitevec_backend.py +98 -0
  61. engram_chateau-1.1.0/tests/test_storage_originals.py +90 -0
  62. engram_chateau-1.1.0/tests/test_watcher.py +91 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tushae Thomas
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,547 @@
1
+ Metadata-Version: 2.4
2
+ Name: engram-chateau
3
+ Version: 1.1.0
4
+ Summary: The AI memory layer that never forgets.
5
+ Author: Tushae Thomas
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/TushaeBXN/engram
8
+ Project-URL: Issues, https://github.com/TushaeBXN/engram/issues
9
+ Keywords: ai,memory,mcp,llm,chromadb,claude
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: chromadb>=0.4.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: watchdog>=3.0.0
24
+ Requires-Dist: questionary>=2.0.0
25
+ Requires-Dist: typer>=0.9.0
26
+ Requires-Dist: rich>=13.0.0
27
+ Requires-Dist: requests>=2.31.0
28
+ Provides-Extra: faiss
29
+ Requires-Dist: faiss-cpu>=1.7.0; extra == "faiss"
30
+ Provides-Extra: sqlitevec
31
+ Requires-Dist: sqlite-vec>=0.1.0; extra == "sqlitevec"
32
+ Provides-Extra: viz
33
+ Requires-Dist: matplotlib>=3.5.0; extra == "viz"
34
+ Requires-Dist: networkx>=2.8.0; extra == "viz"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=7.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
38
+ Requires-Dist: black>=23.0; extra == "dev"
39
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
40
+ Requires-Dist: pre-commit>=3.0; extra == "dev"
41
+ Provides-Extra: all
42
+ Requires-Dist: faiss-cpu>=1.7.0; extra == "all"
43
+ Requires-Dist: sqlite-vec>=0.1.0; extra == "all"
44
+ Requires-Dist: matplotlib>=3.5.0; extra == "all"
45
+ Requires-Dist: networkx>=2.8.0; extra == "all"
46
+ Dynamic: license-file
47
+
48
+ # Engram
49
+ <img width="1408" height="768" alt="Gemini_Generated_Image_9nr9z59nr9z59nr9" src="https://github.com/user-attachments/assets/e04422f2-1974-48c2-8568-238bc2641bdf" />
50
+
51
+
52
+ > **Small, private, verbatim memory for your AI — set up in a minute, readable in an afternoon.**
53
+
54
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
55
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
56
+ [![CI](https://github.com/TushaeBXN/engram/actions/workflows/ci.yml/badge.svg)](https://github.com/TushaeBXN/engram/actions/workflows/ci.yml)
57
+
58
+ Engram gives Claude (and any MCP client) a long-term memory that lives on your machine. It keeps every note, file and conversation **word for word**, organises them into wings and rooms, and finds them again with semantic search. No cloud, no API key, no account.
59
+
60
+ ## Why Engram
61
+
62
+ - **Small enough to read.** About 6,300 lines of Python in 33 files. You can audit everything that touches your data in an afternoon.
63
+ - **Two commands to set up.** Install, run `engram install-hooks`, and Claude Code saves your work and conversations automatically.
64
+ - **Verbatim, not summarised.** Drawers store your original text. Compression is only used for the small context Engram loads into a model.
65
+ - **Private by default.** Everything stays under `~/.engram/`. Nothing is sent anywhere.
66
+ - **Honest numbers.** Benchmarks are reproducible from this repo, and unmeasured goals are labelled as goals ([details](#benchmark-targets)).
67
+
68
+ ## Set up in 60 seconds
69
+
70
+ ```bash
71
+ pip install git+https://github.com/TushaeBXN/engram # Python 3.9+
72
+ engram init ~/myproject # create your memory château
73
+ engram install-hooks # auto-save from Claude Code (prints a settings.json snippet)
74
+ claude mcp add engram -- python -m engram.mcp_server # give Claude the 22 engram_* tools
75
+ ```
76
+
77
+ Then ask Claude to search or remember things, or use the CLI: `engram mine ~/myproject --wing myapp`, `engram search "auth decisions"`.
78
+
79
+ ## Engram and MemPalace
80
+
81
+ Engram's design (wings, rooms, halls, drawers, a temporal knowledge graph) is inspired by [MemPalace](https://github.com/MemPalace/mempalace), a much larger and more mature project. If you need a shared memory hub across machines, Docker images, GPU embedding models, LLM reranking or its published benchmark results, use MemPalace. Engram aims to be the small one: the same core ideas in a codebase one person can read, with a two-line setup.
82
+
83
+ ---
84
+
85
+ ## Why local memory?
86
+
87
+ | | Engram | Cloud memory tools |
88
+ |---|---|---|
89
+ | Cold-start context | Designed for **~170 tokens** (L0 + L1, not yet measured) | Varies |
90
+ | Install | One `pip install` (from GitHub) | Often Docker + cloud signup |
91
+ | API key required | **No** | Usually |
92
+ | Data leaves your machine | **Never** | Yes |
93
+ | Compression | **ES shorthand** for context (~1.6× on prose) | — |
94
+ | Open source | **MIT** | Often proprietary |
95
+
96
+ ---
97
+
98
+ ## Benchmark Targets
99
+
100
+ These are goals, not results. ES compression is measured today; the LongMemEval runner is ready but its full 500-question score has not been published yet, and the LoCoMo runner is still a stub. See [benchmarks/BENCHMARKS.md](benchmarks/BENCHMARKS.md) to reproduce.
101
+
102
+ | Benchmark | Metric | Target | Status |
103
+ |----------------------|---------------------|-----------|-------------------------|
104
+ | LongMemEval | Session recall R@5 | ≥ 0.95 | Runner ready, not yet run |
105
+ | LongMemEval | Session recall R@10 | ≥ 0.97 | Runner ready, not yet run |
106
+ | LoCoMo | Entity recall | ≥ 0.72 | Not yet implemented |
107
+ | LoCoMo | Event recall | ≥ 0.69 | Not yet implemented |
108
+ | ES compression | Factual paragraphs | ≥ 1.5× | 1.6× measured |
109
+ | ES compression | Code-heavy content | ≥ 1.1× | 1.1× measured |
110
+ | ES compression | Mixed | ≥ 1.4× | 1.5× measured |
111
+ | Cold-start context | L0 + L1 tokens | ≤ 170 | Not yet measured |
112
+ | Search latency p99 | ChromaDB 100k | < 200ms | Not yet measured |
113
+ | Search latency p99 | FAISS 100k | < 50ms | Not yet measured |
114
+
115
+ ---
116
+
117
+ ## Quick Start
118
+
119
+ > **Note:** the `engram` package on PyPI is an unrelated project. Install Engram from GitHub as shown below, not with `pip install engram`. Engram's own PyPI package will be **`engram-chateau`**; the command stays `engram`.
120
+
121
+ ```bash
122
+ # Install (from GitHub; Engram is not on PyPI yet)
123
+ pip install git+https://github.com/TushaeBXN/engram
124
+
125
+ # Or with optional backends
126
+ pip install "engram-chateau[faiss] @ git+https://github.com/TushaeBXN/engram" # FAISS speed backend
127
+ pip install "engram-chateau[sqlitevec] @ git+https://github.com/TushaeBXN/engram" # zero-dependency fallback
128
+ pip install "engram-chateau[viz] @ git+https://github.com/TushaeBXN/engram" # graph visualisation (matplotlib + networkx)
129
+ pip install "engram-chateau[all] @ git+https://github.com/TushaeBXN/engram" # everything
130
+
131
+ # Initialise your memory château
132
+ engram init ~/myproject
133
+
134
+ # Mine a project directory
135
+ engram mine ~/myproject --wing myapp
136
+
137
+ # Mine a conversation export
138
+ engram mine ~/Downloads/claude-export --mode convos --wing myapp
139
+
140
+ # Search
141
+ engram search "auth migration decisions" --wing myapp
142
+
143
+ # Answer a question grounded in memory (uses Ollama if available)
144
+ engram answer "What did we decide about the auth strategy?" --wing myapp
145
+
146
+ # Store a typed, validated memory
147
+ engram remember-type "Always prefer float32 on CPU because bfloat16 is unsupported" \
148
+ instruction --wing myapp --confidence 0.95
149
+
150
+ # Load cold-start context (~170 tokens)
151
+ engram wake-up
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Memory Château Architecture
157
+
158
+ ```
159
+ Wing (person or project)
160
+ └── Room (named topic: "auth-migration", "ci-pipeline")
161
+ ├── Hall (memory type: facts | events | discoveries | preferences | advice)
162
+ │ ├── Closet (ES-compressed summary — fast AI read)
163
+ │ └── Drawer (verbatim original — never summarised)
164
+ └── Tunnel (cross-wing link when same room spans multiple wings)
165
+ ```
166
+
167
+ Mined notes and conversation messages are sorted into halls by their **content** (e.g. "I prefer…" → preferences, "turns out the root cause…" → discoveries) using a local, rule-based classifier (`engram/classifier.py`). Code and config files keep their extension-based hall; when nothing matches clearly, the old extension/role default is used.
168
+
169
+ ### Memory Layers
170
+
171
+ | Layer | Content | Size | When Loaded |
172
+ |-------|--------------------------------|------------|--------------------------|
173
+ | L0 | Identity — who is this AI? | ~50 tokens | Always |
174
+ | L1 | Critical facts in ES | ~120 tokens| Always |
175
+ | L2 | Room recall — current project | On demand | When topic arises |
176
+ | L3 | Deep semantic search | On demand | When explicitly queried |
177
+
178
+ Total cold-start context: **~170 tokens** (L0 + L1 only).
179
+
180
+ ---
181
+
182
+ ## Using with Claude via MCP
183
+
184
+ **Claude Code:**
185
+
186
+ ```bash
187
+ claude mcp add engram -- python -m engram.mcp_server
188
+ ```
189
+
190
+ **Claude Desktop:** add this to `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`):
191
+
192
+ ```json
193
+ {
194
+ "mcpServers": {
195
+ "engram": {
196
+ "command": "python",
197
+ "args": ["-m", "engram.mcp_server"]
198
+ }
199
+ }
200
+ }
201
+ ```
202
+
203
+ Use the full path to the Python that has Engram installed if `python` on your PATH is a different one.
204
+
205
+ Claude will then have access to all 22 `engram_*` tools including `engram_wake_up`,
206
+ `engram_search`, `engram_add_memory`, `engram_kg_add`, `engram_replay`, and more.
207
+
208
+ See [`examples/mcp_setup.md`](examples/mcp_setup.md) for the full tool list.
209
+
210
+ ---
211
+
212
+ ## Using with Local Models
213
+
214
+ Engram works entirely offline. The vector backends use local embeddings:
215
+
216
+ ```python
217
+ from engram.backends import get_backend
218
+ from engram.palace import Palace
219
+ from engram.searcher import Searcher
220
+
221
+ palace = Palace()
222
+ backend = get_backend("chromadb") # or "faiss" / "sqlitevec"
223
+ searcher = Searcher(backend, palace)
224
+
225
+ results = searcher.search("auth migration")
226
+ for r in results:
227
+ print(r["text"], r["final_score"])
228
+ ```
229
+
230
+ No model API required. ChromaDB embeds locally using its bundled models.
231
+
232
+ ---
233
+
234
+ ## Full CLI Reference
235
+
236
+ ### Setup
237
+
238
+ ```bash
239
+ engram init <dir> # guided onboarding + ES bootstrap
240
+ ```
241
+
242
+ ### Mining
243
+
244
+ ```bash
245
+ engram mine <dir> # mine project files
246
+ engram mine <dir> --mode convos # mine conversation exports
247
+ engram mine <dir> --mode convos --wing myapp # tag with a wing
248
+ engram mine <dir> --since 2026-01-01 # skip files older than date
249
+ engram mine <dir> --plugin obsidian # use Obsidian vault plugin
250
+ engram mine <dir> --plugin notion # Notion export
251
+ engram mine <dir> --plugin linear # Linear issues export
252
+ ```
253
+
254
+ ### Watch Mode
255
+
256
+ ```bash
257
+ engram watch <dir> # auto-mine on file changes
258
+ engram watch <dir> --wing myapp --mode convos # tag + conversation mode
259
+ ```
260
+
261
+ ### Search
262
+
263
+ ```bash
264
+ engram search "query"
265
+ engram search "query" --wing myapp
266
+ engram search "query" --room auth-migration
267
+ engram search "query" --no-decay # disable recency weighting
268
+ engram search "query" --results 20 # max results
269
+ ```
270
+
271
+ ### Memory Stack
272
+
273
+ ```bash
274
+ engram wake-up # L0 + L1 context dump (~170 tokens)
275
+ engram wake-up --wing myapp # wing-scoped L1
276
+ engram wake-up --rebuild # rebuild L1 from drawers
277
+ ```
278
+
279
+ ### Compression
280
+
281
+ ```bash
282
+ engram compress # ES compress all closets
283
+ engram compress --wing myapp # wing-scoped
284
+ engram compress --wing myapp --room auth # room-scoped
285
+ ```
286
+
287
+ ### Knowledge Graph
288
+
289
+ ```bash
290
+ engram kg query "Kai"
291
+ engram kg query "Kai" --all # include expired triples
292
+ engram kg add "Kai" works_on "Orion" --from 2025-06-01
293
+ engram kg invalidate "Kai" works_on "Orion" --ended 2026-03-01
294
+ engram kg timeline "auth-migration"
295
+ ```
296
+
297
+ ### Answer (LLM-grounded QA)
298
+
299
+ ```bash
300
+ engram answer "What auth approach did we choose?"
301
+ engram answer "What did we decide about the DB?" --wing myapp
302
+ engram answer "Why did we drop Redis?" --model llama3.2 --chunks 8
303
+ ```
304
+
305
+ ### Typed Memory
306
+
307
+ ```bash
308
+ # Store a categorised, validated memory
309
+ engram remember-type "Prefer SQLite for local dev" preference --wing myapp
310
+ engram remember-type "Use float32 on CPU because bfloat16 unsupported" \
311
+ instruction --wing anthos --confidence 0.95
312
+
313
+ # List all 13 valid types
314
+ engram remember-type --list
315
+ ```
316
+
317
+ ### Provenance
318
+
319
+ ```bash
320
+ engram provenance <drawer-id> # provenance record for one memory
321
+ engram provenance <drawer-id> --history # full version chain
322
+ engram provenance --summary # source counts across château
323
+ ```
324
+
325
+ ### Graph Visualisation
326
+
327
+ ```bash
328
+ pip install "engram-chateau[viz] @ git+https://github.com/TushaeBXN/engram"
329
+ engram graph # all wings → memory_graph.png
330
+ engram graph --wing myapp --output myapp.png # scoped to one wing
331
+ ```
332
+
333
+ ### Maintenance
334
+
335
+ ```bash
336
+ engram conflicts # interactive TUI conflict resolver
337
+ engram audit # health check
338
+ engram audit --fix # auto-resolve safe issues
339
+ engram replay --room auth-migration # chronological room story
340
+ engram replay --room auth-migration --wing myapp
341
+ engram replay --room auth-migration --type decision # filter by type
342
+ engram replay --room auth-migration --since 2026-06-01 # filter by date
343
+ engram replay --room auth-migration --min-confidence 0.8 # filter by confidence
344
+ engram status # château overview
345
+ engram split <dir> # split concatenated transcripts
346
+ engram split <dir> --dry-run
347
+ ```
348
+
349
+ ---
350
+
351
+ ## Configuration
352
+
353
+ **`~/.engram/config.json`**
354
+
355
+ ```json
356
+ {
357
+ "palace_path": "~/.engram/palace",
358
+ "vector_backend": "chromadb",
359
+ "decay_factor": 0.005,
360
+ "decay_max_days": 90,
361
+ "collection_name": "engram_drawers",
362
+ "people_map": {}
363
+ }
364
+ ```
365
+
366
+ | Key | Default | Description |
367
+ |------------------|----------------------|-------------------------------------------------------|
368
+ | `palace_path` | `~/.engram/palace` | Root of the château filesystem |
369
+ | `vector_backend` | `chromadb` | `chromadb` \| `faiss` \| `sqlitevec` |
370
+ | `decay_factor` | `0.005` | Recency boost per day: `score * (1 + factor * days)` |
371
+ | `decay_max_days` | `90` | Days after which decay levels off |
372
+ | `collection_name`| `engram_drawers` | ChromaDB collection name |
373
+
374
+ `ENGRAM_VECTOR_BACKEND` overrides `vector_backend` for a single run without editing the file, e.g. `ENGRAM_VECTOR_BACKEND=sqlitevec engram search "auth"`.
375
+
376
+ ### Troubleshooting: ChromaDB fails to load
377
+
378
+ ChromaDB 1.x ships compiled Rust bindings (`chromadb_rust_bindings`). If they don't match your Python or platform, Engram prints a `ChromaDB failed to load` message instead of starting. Fix it by reinstalling (`pip install --force-reinstall --no-cache-dir chromadb`) or by switching to the `sqlitevec` backend, which needs no compiled dependencies. Each backend keeps its own index, so re-run `engram mine` after switching.
379
+
380
+ **`~/.engram/identity.txt`** — plain text, becomes your L0 context.
381
+
382
+ **`~/.engram/wing_config.json`** — generated by `engram init`.
383
+
384
+ ---
385
+
386
+ ## Module Reference
387
+
388
+ | File | Description |
389
+ |-------------------------------|-----------------------------------------------------|
390
+ | `engram/chateau.py` | Wing/Room/Hall/Closet/Drawer data model |
391
+ | `engram/config.py` | Config loading, `~/.engram/` management |
392
+ | `engram/shorthand.py` | Engram Shorthand (ES) compression dialect |
393
+ | `engram/knowledge_graph.py` | Temporal KG, SQLite backend |
394
+ | `engram/miner.py` | Project file ingest pipeline |
395
+ | `engram/convo_miner.py` | Conversation export ingest (Claude, ChatGPT, Slack) |
396
+ | `engram/searcher.py` | Semantic search + recency weighting |
397
+ | `engram/layers.py` | L0–L3 memory stack |
398
+ | `engram/watcher.py` | FSEvents/inotify watch mode |
399
+ | `engram/conflict.py` | Contradiction detection + TUI resolver |
400
+ | `engram/audit.py` | Memory health audit |
401
+ | `engram/replay.py` | Session/room replay |
402
+ | `engram/qa.py` | LLM-grounded QA over memory (Ollama + fallback) |
403
+ | `engram/typed_memory.py` | 13-type typed memory with validation + ES storage |
404
+ | `engram/provenance.py` | Memory provenance and version-chain tracking |
405
+ | `engram/agents.py` | Specialist agent diary system |
406
+ | `engram/chateau_graph.py` | Room navigation graph |
407
+ | `engram/onboarding.py` | Guided init + ES bootstrap |
408
+ | `engram/cli.py` | Typer CLI entry point |
409
+ | `engram/mcp_server.py` | MCP server — 22 tools |
410
+ | `engram/backends/base.py` | Abstract VectorBackend interface |
411
+ | `engram/backends/chromadb_backend.py` | ChromaDB backend (default) |
412
+ | `engram/backends/faiss_backend.py` | FAISS backend (speed-optimised) |
413
+ | `engram/backends/sqlitevec_backend.py`| sqlite-vec backend (zero-dependency) |
414
+ | `engram/plugins/obsidian.py` | Obsidian vault plugin miner |
415
+ | `engram/plugins/notion.py` | Notion export plugin miner |
416
+ | `engram/plugins/linear.py` | Linear issues plugin miner |
417
+ | `engram/hooks/engram_save_hook.sh` | Claude Code auto-save hook |
418
+ | `engram/hooks/engram_precompact_hook.sh` | Claude Code pre-compact hook |
419
+
420
+ ---
421
+
422
+ ## Engram Shorthand (ES)
423
+
424
+ ES is a compact shorthand that any LLM can read without a decoder. It is used for the context Engram loads into a model (L1 facts, closets); drawers always keep your original text. ES is lossy: filler words such as "the" and "that" are dropped, and `decompress()` only expands unambiguous symbols such as `∴` and `→`. Expect about 1.6× on prose and 1.1× on code.
425
+
426
+ ```python
427
+ from engram.shorthand import compress, decompress
428
+
429
+ text = (
430
+ "The authentication module is a critical component that has a dependency "
431
+ "on the database and is responsible for verifying user credentials."
432
+ )
433
+
434
+ es = compress(text, confidence=4)
435
+ # → "auth module=★★ component +dep on db&owns: verifying user credentials. [★★★★]"
436
+
437
+ decompress(es)
438
+ # → expands unambiguous symbols (∴, →, ¬ …) back to words
439
+
440
+ # Code-aware compression
441
+ code = "def authenticate(user: str, token: str) -> bool:"
442
+ compress(code, is_code=True)
443
+ # → "fn:authenticate(user: str,token: str)->bool"
444
+
445
+ # Diff notation
446
+ compress("+add_middleware()\n-manual_verify()", is_diff=True, diff_filename="auth.py")
447
+ # → "CHANGE:auth.py add:add_middleware() rm:manual_verify()"
448
+ ```
449
+
450
+ ---
451
+
452
+ ## Recency Weighting
453
+
454
+ ```
455
+ final_score = semantic_score × (1 + recency_boost)
456
+ recency_boost = decay_factor × max(0, decay_max_days − age_days)
457
+ ```
458
+
459
+ Pinned drawers (`engram_pin`) bypass decay entirely.
460
+
461
+ ---
462
+
463
+ ## Claude Code Hooks
464
+
465
+ Two hooks keep Engram up to date while you work in Claude Code:
466
+
467
+ - **Save hook** (PostToolUse): every file Claude writes or edits is mined into the château. Re-saving a file replaces its drawer instead of adding a duplicate.
468
+ - **Pre-compact hook** (PreCompact): before Claude Code compacts a conversation, the session transcript is mined so nothing is lost. Only user and assistant text is stored, not tool calls, tool output or thinking, and running it again on the same session adds no duplicates.
469
+
470
+ ```bash
471
+ engram install-hooks # copies the scripts to ~/.engram/hooks/ and prints the settings snippet
472
+ ```
473
+
474
+ Merge the printed snippet into `~/.claude/settings.json`. It looks like:
475
+
476
+ ```json
477
+ {
478
+ "hooks": {
479
+ "PostToolUse": [{
480
+ "matcher": "Write|Edit|MultiEdit",
481
+ "hooks": [{"type": "command", "command": "~/.engram/hooks/engram_save_hook.sh"}]
482
+ }],
483
+ "PreCompact": [{
484
+ "hooks": [{"type": "command", "command": "~/.engram/hooks/engram_precompact_hook.sh"}]
485
+ }]
486
+ }
487
+ }
488
+ ```
489
+
490
+ Optional environment variables: `ENGRAM_WING` (default `default`), `ENGRAM_ROOM` for transcripts (default `conversation`), `ENGRAM_AGENT` for diary entries (default `claude-code`).
491
+
492
+ ---
493
+
494
+ ## Web UI (notes)
495
+
496
+ ```bash
497
+ engram ui # opens http://127.0.0.1:7741 in your browser
498
+ ```
499
+ <img width="1126" height="932" alt="Engram notes UI with knowledge graph" src="https://github.com/user-attachments/assets/870d76e7-bdc3-42a5-9056-6a54a1dd7ef1" />
500
+
501
+ A local notes app with a force-directed graph of your notes and their `[[wikilinks]]`: wing tabs, `#tag` filters, pinned notes, a daily journal, a Markdown editor, and JSON export/import.
502
+
503
+ > **Note:** the UI keeps its notes in your browser's local storage. It does not yet show the memories Engram stores in `~/.engram/` (mined files, conversations, MCP memories). Use `engram search`, `engram replay` or the MCP tools for those.
504
+
505
+ ---
506
+
507
+ ## Requirements
508
+
509
+ - Python 3.9+
510
+ - chromadb ≥ 0.4.0
511
+ - typer ≥ 0.9.0
512
+ - rich ≥ 13.0.0
513
+ - watchdog ≥ 3.0.0
514
+ - questionary ≥ 2.0.0
515
+ - pyyaml ≥ 6.0
516
+
517
+ Optional:
518
+ - `faiss-cpu` — FAISS backend
519
+ - `sqlite-vec` — sqlite-vec backend
520
+ - `matplotlib` + `networkx` — graph visualisation (`pip install "engram-chateau[viz] @ git+https://github.com/TushaeBXN/engram"`)
521
+ - `requests` — Ollama API calls for `engram answer`
522
+
523
+ No API key. No internet after install.
524
+
525
+ ---
526
+
527
+ ## Contributing
528
+
529
+ 1. Fork the repo
530
+ 2. `pip install -e ".[dev]"`
531
+ 3. `pre-commit install`
532
+ 4. Run tests: `pytest tests/ -v`
533
+ 5. Submit a PR
534
+
535
+ ### Releasing
536
+
537
+ Engram is published to PyPI as **`engram-chateau`** (the command and `import engram` are unchanged). Publishing runs from `.github/workflows/publish.yml` using PyPI trusted publishing, so no API token is stored anywhere.
538
+
539
+ One-time setup (maintainer, on pypi.org): *Account settings → Publishing → Add a new pending publisher* with PyPI project name `engram-chateau`, owner `TushaeBXN`, repository `engram`, workflow `publish.yml`, environment `pypi`.
540
+
541
+ To release: bump `version` in `pyproject.toml` and `__version__` in `engram/__init__.py`, merge, then publish a GitHub release tagged `v<version>` (for example `v1.1.0`). The workflow checks the tag matches both, runs the tests, builds, and uploads.
542
+
543
+ ---
544
+
545
+ ## License
546
+
547
+ MIT © 2026 Tushae Thomas