prism-mcp-server 5.1.0 โ†’ 5.2.1

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Prism MCP โ€” The Mind Palace for AI Agents ๐Ÿง 
1
+ # ๐Ÿง  Prism MCP โ€” The Mind Palace for AI Agents
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/prism-mcp-server?color=cb0000&label=npm)](https://www.npmjs.com/package/prism-mcp-server)
4
4
  [![MCP Registry](https://img.shields.io/badge/MCP_Registry-listed-00ADD8?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTUtMTAtNXpNMiAxN2wxMCA1IDEwLTV2LTJMMTI0djJMMiA5djh6Ii8+PC9zdmc+)](https://registry.modelcontextprotocol.io)
@@ -8,379 +8,102 @@
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
9
9
  [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
10
10
 
11
- > **Your AI agent's memory that survives between sessions.** Prism MCP is a Model Context Protocol server that gives Claude Desktop, Cursor, Windsurf, and any MCP client **persistent memory**, **time travel**, **visual context**, **multi-agent sync**, **GDPR-compliant deletion**, **memory tracing**, **quantized vector compression**, and **LangChain integration** โ€” all running locally with zero cloud dependencies.
12
- >
13
- > Built with **SQLite + F32_BLOB vector search**, **TurboQuant 10ร— embedding compression**, **optimistic concurrency control**, **MCP Prompts & Resources**, **auto-compaction**, **Gemini-powered Morning Briefings**, **MemoryTrace explainability**, and optional **Supabase cloud sync**.
14
-
15
- ## Table of Contents
16
-
17
- - [What's New (v5.1.0)](#whats-new-in-v510--deep-storage--knowledge-graph-)
18
- - [What's New (v5.0.0)](#whats-new-in-v500--quantized-agentic-memory-)
19
- - [What's New (v4.6.0)](#whats-new-in-v460--opentelemetry-observability-)
20
- - [Multi-Instance Support](#multi-instance-support)
21
- - [How Prism Compares](#how-prism-compares)
22
- - [Quick Start](#quick-start-zero-config--local-mode)
23
- - [Mind Palace Dashboard](#-the-mind-palace-dashboard)
24
- - [Integration Examples](#integration-examples)
25
- - [Claude Code Integration (Hooks)](#claude-code-integration-hooks)
26
- - [Gemini / Antigravity Integration](#gemini--antigravity-integration)
27
- - [Use Cases](#use-cases)
28
- - [Architecture](#architecture) | [Full Architecture Guide](docs/ARCHITECTURE.md) | [Self-Improving Agent Guide](docs/self-improving-agent.md)
29
- - [Tool Reference](#tool-reference)
30
- - [Agent Hivemind โ€” Role Usage](#agent-hivemind--role-usage)
31
- - [LangChain / LangGraph Integration](#langchain--langgraph-integration)
32
- - [Environment Variables](#environment-variables)
33
- - [Boot Settings (Restart Required)](#-boot-settings-restart-required)
34
- - [Progressive Context Loading](#progressive-context-loading)
35
- - [Time Travel](#time-travel-version-history)
36
- - [Agent Telepathy](#agent-telepathy-multi-client-sync)
37
- - [Knowledge Accumulation](#knowledge-accumulation)
38
- - [GDPR Compliance](#gdpr-compliance)
39
- - [Observability & Tracing](#observability--tracing)
40
- - [Supabase Setup](#supabase-setup-cloud-mode)
41
- - [Project Structure](#project-structure)
42
- - [Hybrid Search Pipeline](#hybrid-search-pipeline-brave--vertex-ai)
43
- - [๐Ÿš€ Roadmap](#-roadmap)
11
+ **Your AI agent forgets everything between sessions. Prism fixes that.**
44
12
 
45
- ---
46
-
47
- ## What's New in v5.1.0 โ€” Deep Storage & Knowledge Graph ๐Ÿ—‚๏ธ
48
-
49
- > **๐Ÿ—‚๏ธ Reclaim 90% of your vector storage and visually edit your agent's knowledge graph.**
50
- > [CHANGELOG](CHANGELOG.md)
51
-
52
- | Feature | Description |
53
- |---|---|
54
- | ๐Ÿ—‘๏ธ **Deep Storage Mode** | New `deep_storage_purge` tool NULLs out redundant float32 embeddings for entries with TurboQuant compressed blobs, reclaiming ~90% of vector storage. Safety guards: 7-day minimum age, dry-run preview, multi-tenant isolation. |
55
- | ๐Ÿ•ธ๏ธ **Knowledge Graph Editor** | The Mind Palace Neural Graph is now fully interactive โ€” click nodes to rename or delete keywords, filter by project/date/importance, and surgically groom your agent's semantic memory. |
56
- | ๐Ÿ”ง **Auto-Load Reliability** | Hardened hook-based integration patterns for Claude Code and Gemini/Antigravity to guarantee context loading on the absolute first turn without reasoning hallucinations. |
57
- | ๐Ÿงช **303 Tests** | 8 new deep-storage test cases covering dry run, execute, safety guards, and idempotency โ€” zero regressions across 13 suites. |
58
-
59
- ---
60
-
61
- ## What's New in v5.0.0 โ€” Quantized Agentic Memory ๐Ÿงฌ
62
-
63
- > **๐Ÿงฌ 10ร— embedding compression is here.** Powered by Google's TurboQuant (ICLR 2026), Prism now compresses 768-dim embeddings from **3,072 bytes โ†’ ~400 bytes** โ€” enabling decades of session history on a standard laptop.
64
- > [RFC-001: Quantized Agentic Memory](docs/rfcs/001-turboquant-integration.md) | [CHANGELOG](CHANGELOG.md)
65
-
66
- ### Performance Benchmarks
67
-
68
- | Metric | Before v5.0 | After v5.0 |
69
- |--------|------------|------------|
70
- | **Storage per embedding** | 3,072 bytes (float32) | ~400 bytes (turbo4) |
71
- | **Compression ratio** | 1:1 | **~7.7:1** (4-bit) / **~10.1:1** (3-bit) |
72
- | **Similarity correlation** | Baseline | >0.85 (4-bit) |
73
- | **Top-1 retrieval accuracy** | Baseline | >90% (N=100) |
74
- | **Entries per GB** | ~330K | **~2.5M** |
75
- | **Search without vector DB** | โŒ Empty | โœ… Tier-2 JS fallback |
76
-
77
- ### Three-Tier Memory Architecture
78
-
79
- ```
80
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
81
- โ”‚ PRISM v5.0 MEMORY โ”‚
82
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
83
- โ”‚ TIER โ”‚ STORAGE โ”‚ SEARCH METHOD โ”‚
84
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
85
- โ”‚ Tier 0 โ”‚ FTS5 keywords โ”‚ Full-text search (knowledge_search) โ”‚
86
- โ”‚ Tier 1 โ”‚ float32 3072B โ”‚ sqlite-vec cosine (native) โ”‚
87
- โ”‚ Tier 2 โ”‚ turbo4 400B โ”‚ JS asymmetricCosineSimilarity โ”‚
88
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
89
-
90
- searchMemory() flow:
91
- โ†’ Tier 1 (sqlite-vec) โ”€โ”€ success โ†’ return results
92
- โ”€โ”€ fail โ†’ Tier 2 (TurboQuant JS)
93
- โ”€โ”€ success โ†’ return results
94
- โ”€โ”€ fail โ†’ return []
95
- ```
96
-
97
- ### Live Usage: How TurboQuant Works in Practice
98
-
99
- **Every `session_save_ledger` call now generates both tiers automatically:**
100
-
101
- ```typescript
102
- // What happens behind the scenes when you save a session:
103
- await saveLedger({ project: "my-app", summary: "Built auth flow" });
104
-
105
- // 1. Gemini generates float32 embedding (3,072 bytes)
106
- // 2. TurboQuant compresses to turbo4 blob (~400 bytes)
107
- // 3. Single atomic patchLedger writes BOTH to the database
108
- // โ†’ embedding: "[0.0234, -0.0156, ...]" (float32)
109
- // โ†’ embedding_compressed: "base64..." (turbo4)
110
- // โ†’ embedding_format: "turbo4"
111
- // โ†’ embedding_turbo_radius: 12.847
112
-
113
- // Searching works seamlessly across both tiers:
114
- await searchMemory({ query: "auth flow" });
115
- // โ†’ Tier 1 tries native vector search
116
- // โ†’ If unavailable, Tier 2 deserializes compressed blobs
117
- // and ranks using asymmetric cosine similarity in JS
118
- ```
13
+ One command. Persistent memory. Zero cloud dependencies.
119
14
 
120
- **Backfill existing entries with one command:**
121
- ```
122
- > Use tool: session_backfill_embeddings
123
- > Now repairs AND compresses in a single atomic update
15
+ ```bash
16
+ npx -y prism-mcp-server
124
17
  ```
125
18
 
126
- > **๐Ÿ’ก Ollama TurboQuant Tip:** If using Ollama for self-hosted inference, set `OLLAMA_KV_CACHE_TYPE=turbo3` for 10ร— smaller KV caches during generation โ€” the same algorithm powering Prism's memory compression.
19
+ Works with **Claude Desktop ยท Claude Code ยท Cursor ยท Windsurf ยท Cline ยท Gemini ยท Antigravity** โ€” any MCP client.
127
20
 
128
21
  ---
129
22
 
130
- <details>
131
- <summary><strong>What's in v4.6.0 โ€” OpenTelemetry Observability ๐Ÿ”ญ</strong></summary>
132
-
133
- > **๐Ÿ”ญ Full distributed tracing for every MCP tool call, LLM provider hop, and background AI worker.**
134
- > Configure in the new **๐Ÿ”ญ Observability** tab in Mind Palace โ€” no code changes required.
135
- > Activates a 4-tier span waterfall: `mcp.call_tool` โ†’ `worker.vlm_caption` โ†’ `llm.generate_image_description` / `llm.generate_embedding`.
136
-
137
- </details>
138
-
139
- <a name="whats-new-in-v451--gdpr-export-"></a>
140
- <details>
141
- <summary><strong>What's in v4.5.1 โ€” GDPR Export & Test Hardening ๐Ÿ”’</strong></summary>
142
-
143
- | Feature | Description |
144
- |---|---|
145
- | ๐Ÿ“ฆ **`session_export_memory`** | Full ZIP export of project memory (JSON + Markdown). Satisfies GDPR Art. 20 Right to Portability. API keys redacted, embeddings stripped. |
146
- | ๐Ÿงช **270 Tests** | Concurrent export safety, redaction edge cases, MCP contract validation under load. |
147
-
148
- </details>
149
-
150
- <a name="whats-new-in-v450--vlm-multimodal-memory-"></a>
151
- <details>
152
- <summary><strong>What's in v4.5.0 โ€” VLM Multimodal Memory ๐Ÿ‘๏ธ</strong></summary>
153
-
154
- | Feature | Description |
155
- |---|---|
156
- | ๐Ÿ‘๏ธ **Visual Memory** | `session_save_image` โ†’ VLM auto-caption โ†’ ledger entry โ†’ vector embedding. Images become semantically searchable with zero schema changes. |
157
- | ๐Ÿ›ก๏ธ **Provider Size Guards** | Anthropic 5MB hard cap, Gemini/OpenAI 20MB. Pre-flight check before API call. |
158
-
159
- </details>
160
-
161
- <a name="whats-new-in-v440--pluggable-llm-adapters-"></a>
162
- <details>
163
- <summary><strong>What's in v4.4.0 โ€” Pluggable LLM Adapters (BYOM) ๐Ÿ”Œ</strong></summary>
164
-
165
- | Feature | Description |
166
- |---|---|
167
- | ๐Ÿ”Œ **BYOM** | OpenAI, Anthropic, Gemini, Ollama adapters. Text + embedding providers independently configurable. |
168
- | ๐Ÿ›ก๏ธ **Air-Gapped** | Full local mode via `http://127.0.0.1:11434` โ€” zero cloud API keys required. |
169
-
170
- </details>
171
-
172
- <a name="whats-new-in-v430--the-bridge-"></a>
173
- <details>
174
- <summary><strong>What's in v4.3.0 โ€” The Bridge: Knowledge Sync Rules ๐ŸŒ‰</strong></summary>
175
-
176
- > **๐Ÿง  Active Behavioral Memory & IDE Sync**
177
- > Prism doesn't just log what happenedโ€”it learns. When an agent is corrected, the memory gains "Importance". Once an insight graduates (Importance >= 7), Prism automatically syncs it to `.cursorrules` / `.clauderules` โ€” permanent, zero-token IDE enforcement.
178
-
179
- </details>
180
-
181
-
182
- <a name="whats-new-in-v420--project-repo-registry-"></a>
183
- <details>
184
- <summary><strong>What's in v4.2.0 โ€” Project Repo Registry ๐Ÿ—‚๏ธ</strong></summary>
185
-
186
- | Feature | Description |
187
- |---|---|
188
- | ๐Ÿ—‚๏ธ **Project Repo Paths** | Map each project to its repo directory in the dashboard. `session_save_ledger` validates `files_changed` paths and warns on mismatch โ€” prevents cross-project contamination. |
189
- | ๐Ÿ”„ **Universal Auto-Load** | Auto-load projects via dynamic tool descriptions โ€” works across all MCP clients (Claude, Cursor, Gemini, Antigravity) without lifecycle hooks. Dashboard is the sole source of truth. |
190
- | ๐Ÿ  **Dashboard-First Config** | Removed `PRISM_AUTOLOAD_PROJECTS` env var override. The Mind Palace dashboard is now the single source of truth for auto-load project configuration. |
191
-
192
- </details>
193
-
194
- <a name="whats-in-v410--auto-migration--multi-instance-"></a>
195
- <details>
196
- <summary><strong>What's in v4.1.0 โ€” Auto-Migration & Multi-Instance ๐Ÿ”€</strong></summary>
197
-
198
- | Feature | Description |
199
- |---|---|
200
- | ๐Ÿ”„ **Auto-Migrations (Supabase)** | Zero-config schema upgrades โ€” pending DDL migrations run automatically on server startup via `prism_apply_ddl` RPC. |
201
- | ๐Ÿ”€ **Multi-Instance Support** | `PRISM_INSTANCE` env var enables instance-aware PID locks โ€” run multiple Prism servers side-by-side without conflicts. |
202
- | ๐Ÿ›ก๏ธ **Server Lifecycle Management** | Singleton PID lock with graceful shutdown and stale PID recovery. |
203
-
204
- </details>
205
-
206
- <a name="whats-in-v400--behavioral-memory-"></a>
207
- <details>
208
- <summary><strong>What's in v4.0.0 โ€” Behavioral Memory ๐Ÿง </strong></summary>
209
-
210
- | Feature | Description |
211
- |---|---|
212
- | ๐Ÿง  **Behavioral Memory** | `session_save_experience` โ€” log actions, outcomes, corrections with confidence scores. Auto-injects warnings into context so agents learn from mistakes. |
213
- | ๐ŸŽฏ **Dynamic Roles** | Role auto-resolves from dashboard settings. Set once in Mind Palace, applies everywhere. |
214
- | ๐Ÿ“ **Token Budget** | `max_tokens` on `session_load_context` โ€” intelligently truncates to fit your budget. |
215
- | ๐Ÿ“‰ **Importance Decay** | Stale corrections auto-fade over time to keep context fresh. |
216
- | ๐Ÿ”ง **Claude Code Hooks** | Simplified SessionStart/Stop hooks that reliably trigger MCP tool calls. |
23
+ ## Why Prism?
217
24
 
218
- </details>
219
-
220
- <a name="whats-in-v310--memory-lifecycle-"></a>
221
- <details>
222
- <summary><strong>What's in v3.1.0 โ€” Memory Lifecycle ๐Ÿ”„</strong></summary>
223
-
224
- | Feature | Description |
225
- |---|---|
226
- | ๐Ÿ“Š **Memory Analytics** | Dashboard sparkline chart, session counts, rollup savings, context richness metrics. |
227
- | โณ **Data Retention (TTL)** | Per-project TTL via `knowledge_set_retention` or dashboard. Auto-expires old entries every 12h. |
228
- | ๐Ÿ—œ๏ธ **Auto-Compaction** | Background health check after saves โ€” auto-compacts when brain is degraded. |
229
- | ๐Ÿ“ฆ **PKM Export** | Export project memory as ZIP of Markdown files for Obsidian/Logseq. |
230
- | ๐Ÿงช **95 Tests** | Analytics, TTL, rollup, compaction, type guards, and export coverage. |
25
+ Every time you start a new conversation with an AI coding assistant, it starts from scratch. You re-explain your architecture, re-describe your decisions, re-list your TODOs. Hours of context โ€” gone.
231
26
 
232
- </details>
233
-
234
- <details>
235
- <summary><strong>What's in v3.0.1 โ€” Agent Identity & Brain Clean-up ๐Ÿงน</strong></summary>
27
+ **Prism gives your agent a brain that persists.** Save what matters at the end of each session. Load it back instantly on the next one. Your agent remembers what it did, what it learned, and what's left to do.
236
28
 
237
- | Feature | Description |
238
- |---|---|
239
- | ๐Ÿงน **Brain Health Clean-up** | One-click **Fix Issues** button โ€” detects and cleans orphaned handoffs, missing embeddings, stale rollups. |
240
- | ๐Ÿ‘ค **Agent Identity** | Set Default Role and Agent Name in dashboard โ€” auto-applies as fallback in all tools. |
241
- | ๐Ÿ“œ **Role-Scoped Skills** | Per-role persistent rules documents, auto-injected at `session_load_context`. |
242
- | ๐Ÿ”ค **Resource Formatting** | `memory://` resources render as formatted text instead of raw JSON. |
29
+ ---
243
30
 
244
- </details>
31
+ ## โœจ What Makes Prism Different
245
32
 
246
- <a name="whats-in-v300--agent-hivemind-"></a>
247
- <details>
248
- <summary><strong>What's in v3.0.0 โ€” Agent Hivemind ๐Ÿ</strong></summary>
249
-
250
- | Feature | Description |
251
- |---|---|
252
- | ๐Ÿ **Role-Scoped Memory** | Optional `role` param โ€” each role gets isolated memory within a project. |
253
- | ๐Ÿ‘ฅ **Agent Registry** | `agent_register`, `agent_heartbeat`, `agent_list_team` โ€” multi-agent discovery. |
254
- | ๐ŸŽฏ **Team Roster** | Auto-injected teammate awareness during context loading. |
255
- | โš™๏ธ **Dashboard Settings** | Runtime toggles backed by persistent key-value store. |
256
- | ๐Ÿ“ก **Hivemind Radar** | Dashboard widget showing active agents, roles, and heartbeats. |
257
- | ๐Ÿ”’ **Conditional Tools** | `PRISM_ENABLE_HIVEMIND` gates multi-agent tools. |
258
- | โœ… **58 Tests** | Storage, tools, dashboard, concurrent writes, role isolation. |
33
+ ### ๐Ÿง  Your Agent Learns From Mistakes
34
+ When you correct your agent, Prism tracks it. Corrections accumulate **importance** over time. High-importance lessons auto-surface as warnings in future sessions โ€” and can even sync to your `.cursorrules` file for permanent enforcement. Your agent literally gets smarter the more you use it.
259
35
 
260
- </details>
36
+ ### ๐Ÿ•ฐ๏ธ Time Travel
37
+ Every save creates a versioned snapshot. Made a mistake? `memory_checkout` reverts your agent's memory to any previous state โ€” like `git revert` for your agent's brain. Full version history with optimistic concurrency control.
261
38
 
39
+ ### ๐Ÿ”ฎ Mind Palace Dashboard
40
+ A gorgeous glassmorphism UI at `localhost:3000` that lets you see exactly what your agent is thinking:
262
41
 
263
- <details>
264
- <summary><strong>What's in v2.5.1 โ€” Version Sync & Embedding Safety</strong></summary>
42
+ - **Current State & TODOs** โ€” the exact context injected into the LLM's prompt
43
+ - **Interactive Knowledge Graph** โ€” force-directed neural graph with click-to-filter, node renaming, and surgical keyword deletion *(v5.1)*
44
+ - **Deep Storage Manager** โ€” preview and execute vector purge operations with dry-run safety *(v5.1)*
45
+ - **Session Ledger** โ€” full audit trail of every decision your agent has made
46
+ - **Time Travel Timeline** โ€” browse and revert any historical handoff version
47
+ - **Visual Memory Vault** โ€” browse VLM-captioned screenshots and auto-captured HTML states
48
+ - **Hivemind Radar** โ€” real-time active agent roster with role, task, and heartbeat
49
+ - **Morning Briefing** โ€” AI-synthesized action plan after 4+ hours away
50
+ - **Brain Health** โ€” memory integrity scan with one-click auto-repair
265
51
 
266
- | Feature | Description |
267
- |---|---|
268
- | ๐Ÿ”„ **Dynamic Versioning** | Version derived from `package.json` โ€” MCP handshake, dashboard, and npm stay in sync. |
269
- | ๐Ÿ›ก๏ธ **Embedding Validation** | Validates 768-dimension vectors at runtime to catch model regressions. |
52
+ ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
270
53
 
271
- </details>
54
+ ### ๐Ÿงฌ 10ร— Memory Compression
55
+ Powered by a pure TypeScript port of Google's TurboQuant (ICLR 2026), Prism compresses 768-dim embeddings from **3,072 bytes โ†’ ~400 bytes** โ€” enabling decades of session history on a standard laptop. No native modules. No vector database required.
272
56
 
273
- <details>
274
- <summary><strong>What's in v2.5.0 โ€” Enterprise Memory ๐Ÿ—๏ธ</strong></summary>
57
+ ### ๐Ÿ Multi-Agent Hivemind
58
+ Multiple agents (dev, QA, PM) can work on the same project with **role-isolated memory**. Agents discover each other automatically, share context in real-time via Telepathy sync, and see a team roster during context loading.
275
59
 
276
- | Feature | Description |
277
- |---|---|
278
- | ๐Ÿ” **Memory Tracing** | `MemoryTrace` with latency breakdown and scoring metadata for LangSmith. |
279
- | ๐Ÿ›ก๏ธ **GDPR Deletion** | `session_forget_memory` with soft/hard delete and Article 17 justification. |
280
- | ๐Ÿ”— **LangChain Integration** | `PrismMemoryRetriever` / `PrismKnowledgeRetriever` BaseRetriever adapters. |
281
- | ๐Ÿงฉ **LangGraph Agent** | 5-node research agent example with MCP bridge and hybrid search. |
60
+ ### ๐Ÿ–ผ๏ธ Visual Memory
61
+ Save UI screenshots, architecture diagrams, and bug states to a searchable vault. Images are auto-captioned by a VLM (Claude Vision / GPT-4V / Gemini) and become semantically searchable across sessions.
282
62
 
283
- </details>
63
+ ### ๐Ÿ”ญ Full Observability
64
+ OpenTelemetry spans for every MCP tool call, LLM hop, and background worker. Route to Jaeger, Grafana, or any OTLP collector. Configure in the dashboard โ€” zero code changes.
284
65
 
285
- <details>
286
- <summary><strong>What's in v2.3.12 โ€” Stability & Fixes</strong></summary>
66
+ ### ๐Ÿ”’ GDPR Compliant
67
+ Soft/hard delete (Art. 17), full ZIP export (Art. 20), API key redaction, per-project TTL retention, and audit trail. Enterprise-ready out of the box.
287
68
 
288
- | Feature | Description |
289
- |---|---|
290
- | ๐Ÿชฒ **Windows Black Screen Fix** | Fixed Python `subprocess.Popen` spawning visible Node.js terminal windows on Windows. |
291
- | ๐Ÿ“ **Debug Logging** | Gated verbose startup logs behind `PRISM_DEBUG_LOGGING` for a cleaner default experience. |
292
- | โšก **Excess Loading Fixes** | Performance improvements to resolve excess loading loops. |
69
+ ---
293
70
 
294
- </details>
71
+ ## ๐ŸŽฏ Use Cases
295
72
 
296
- <details>
297
- <summary><strong>What's in v2.3.8 โ€” LangGraph Research Agent</strong></summary>
73
+ **Long-running feature work** โ€” Save state at end of day, restore full context next morning. No re-explaining.
298
74
 
299
- | Feature | Description |
300
- |---|---|
301
- | ๐Ÿค– **LangGraph Agent** | 5-node research agent with autonomous looping, MCP integration, persistent memory. |
302
- | ๐Ÿง  **Agentic Memory** | `save_session` node persists findings to ledger โ€” agents don't just answer and forget. |
303
- | ๐Ÿ”Œ **MCP Client Bridge** | JSON-RPC 2.0 client wraps Prism tools as LangChain `StructuredTool` objects. |
304
- | ๐Ÿ”ง **Storage Fix** | Resource/Prompt handlers route through `getStorage()` โ€” eliminates EOF crashes. |
305
- | ๐Ÿ›ก๏ธ **Error Boundaries** | Graceful error handling with proper MCP error responses. |
75
+ **Multi-agent collaboration** โ€” Dev, QA, and PM agents share real-time context without stepping on each other's memory.
306
76
 
307
- </details>
77
+ **Consulting / multi-project** โ€” Switch between client projects with progressive loading: `quick` (~50 tokens), `standard` (~200), or `deep` (~1000+).
308
78
 
309
- <details>
310
- <summary><strong>What's in v2.2.0</strong></summary>
79
+ **Visual debugging** โ€” Save UI screenshots to searchable memory. Find that CSS bug from last week by description.
311
80
 
312
- | Feature | Description |
313
- |---|---|
314
- | ๐Ÿฉบ **Brain Health Check** | `session_health_check` โ€” like Unix `fsck` for your agent's memory. Detects missing embeddings, duplicate entries, orphaned handoffs, and stale rollups. Use `auto_fix: true` to repair automatically. |
315
- | ๐Ÿ“Š **Mind Palace Health** | Brain health indicator on the Mind Palace Dashboard โ€” see your memory integrity at a glance. **๐Ÿงน Fix Issues** button auto-deletes orphaned handoffs in one click. |
81
+ **Team onboarding** โ€” New team member's agent loads the full project history instantly.
316
82
 
317
- </details>
83
+ **Behavior enforcement** โ€” Agent corrections auto-graduate into permanent `.cursorrules` / `.clauderules` rules.
318
84
 
319
- <details>
320
- <summary><strong>What's in v2.0 "Mind Palace"</strong></summary>
321
-
322
- | Feature | Description |
323
- |---|---|
324
- | ๐Ÿ  **Local-First SQLite** | Run Prism entirely locally with zero cloud dependencies. Full vector search (libSQL F32_BLOB) and FTS5 included. |
325
- | ๐Ÿ”ฎ **Mind Palace UI** | A beautiful glassmorphism dashboard at `localhost:3000` (configurable via `PRISM_DASHBOARD_PORT`) to inspect your agent's memory, visual vault, and Git drift. |
326
- | ๐Ÿ•ฐ๏ธ **Time Travel** | `memory_history` and `memory_checkout` act like `git revert` for your agent's brain โ€” full version history with OCC. |
327
- | ๐Ÿ–ผ๏ธ **Visual Memory** | Agents can save screenshots to a local media vault. Auto-capture mode snapshots your local dev server on every handoff save. |
328
- | ๐Ÿ“ก **Agent Telepathy** | Multi-client sync: if your agent in Cursor saves state, Claude Desktop gets a live notification instantly. |
329
- | ๐ŸŒ… **Morning Briefing** | Gemini auto-synthesizes a 3-bullet action plan if it's been >4 hours since your last session. |
330
- | ๐Ÿ“ **Code Mode Templates** | 8 pre-built QuickJS extraction templates for GitHub, Jira, OpenAPI, Slack, CSV, and DOM parsing โ€” zero reasoning tokens. |
331
- | ๐Ÿ” **Reality Drift Detection** | Prism captures Git state on save and warns if files changed outside the agent's view. |
85
+ **Offline / air-gapped** โ€” Full SQLite local mode + Ollama LLM adapter. Zero internet dependency.
332
86
 
333
- </details>
87
+ **Morning Briefings** โ€” After 4+ hours away, Prism auto-synthesizes a 3-bullet action plan from your last sessions.
334
88
 
335
89
  ---
336
90
 
337
- > ๐Ÿ’ก **TL;DR:** Prism MCP gives your AI agent persistent memory using a local SQLite database. No cloud accounts, no API keys, and no Postgres/Qdrant containers required. Just `npx -y prism-mcp-server` and you're running.
91
+ ## ๐Ÿ†• What's New in v5.2
338
92
 
339
- ## How Prism Compares
93
+ - ๐Ÿง  **Cognitive Memory** โ€” Ebbinghaus importance decay computes `effective_importance = base ร— 0.95^days` at retrieval time. Frequently accessed memories stay prominent; neglected ones naturally fade. Tracks `last_accessed_at` per entry.
94
+ - ๐ŸŽฏ **Context-Weighted Retrieval** โ€” New `context_boost` parameter on `session_search_memory` prepends your active project's context to the query before embedding, biasing results toward what matters right now.
95
+ - ๐Ÿ”„ **[Universal History Migration](#migrating-existing-history-claude-gemini-openai)** โ€” Import years of Claude Code, Gemini, and ChatGPT sessions on day one. Strategy Pattern adapters with OOM-safe streaming, content-hash dedup, and `--dry-run` support. Also available via the [Dashboard Import UI](#-mind-palace-dashboard).
96
+ - ๐Ÿงน **Smart Consolidation** โ€” Enhanced compaction extracts recurring principles alongside summaries for richer rollups.
97
+ - ๐Ÿ›ก๏ธ **SQL Injection Prevention** โ€” 17-column allowlist on `patchLedger()` hardens all dynamic SQL paths.
98
+ - ๐Ÿงช **352 Tests** โ€” Zero regressions across 15 suites.
340
99
 
341
- | Feature | **Prism MCP** | [MCP Memory](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) | [Mem0](https://github.com/mem0ai/mem0) | [Mnemory](https://github.com/fpytloun/mnemory) | [Basic Memory](https://github.com/basicmachines-co/basic-memory) |
342
- |---|---|---|---|---|---|
343
- | **Pricing** | โœ… Free / MIT | โœ… Free / MIT | Freemium | โœ… Free / OSS | Freemium |
344
- | **Storage** | SQLite + Supabase | JSON file | Postgres + Qdrant | Qdrant + S3 | Markdown files |
345
- | **Zero Config** | โœ… npx one-liner | โœ… | โŒ Qdrant/Postgres | โœ… uvx | โœ… pip |
346
- | **Behavioral Memory** | โœ… Importance tracking | โŒ | โŒ | โŒ | โŒ |
347
- | **Dynamic Roles** | โœ… Dashboard auto-resolve | โŒ | โŒ | โŒ | โŒ |
348
- | **Token Budget** | โœ… max_tokens param | โŒ | โŒ | โŒ | โŒ |
349
- | **Importance Decay** | โœ… Auto-fade stale data | โŒ | โŒ | โŒ | โŒ |
350
- | **Semantic Search** | โœ… Vectors + FTS5 | โŒ | โœ… pgvector | โœ… Qdrant | โŒ Text only |
351
- | **Knowledge Graph** | โœ… Neural Graph | โœ… Entity model | โŒ | โœ… Graph | โœ… MD links |
352
- | **Time Travel** | โœ… History + checkout | โŒ | โŒ | โŒ | โŒ |
353
- | **Fact Merging** | โœ… Gemini async | โŒ | โœ… Built-in | โœ… Contradiction | โŒ |
354
- | **Security Scan** | โœ… Injection detection | โŒ | โŒ | โœ… Anti-injection | โŒ |
355
- | **Health Check** | โœ… fsck tool | โŒ | โŒ | โœ… 3-phase fsck | โŒ |
356
- | **Visual Dashboard** | โœ… Mind Palace | โŒ | โœ… Cloud UI | โœ… Mgmt UI | โŒ |
357
- | **Multi-Agent Sync** | โœ… Real-time | โŒ | โŒ | โŒ Per-user | โŒ |
358
- | **Visual Memory** | โœ… Screenshot vault | โŒ | โŒ | โœ… Artifacts | โŒ |
359
- | **Auto-Compaction** | โœ… Gemini rollups | โŒ | โŒ | โŒ | โŒ |
360
- | **Morning Briefing** | โœ… Gemini synthesis | โŒ | โŒ | โŒ | โŒ |
361
- | **OCC (Concurrency)** | โœ… Version-based | โŒ | โŒ | โŒ | โŒ |
362
- | **GDPR Compliance** | โœ… Soft/hard delete + ZIP export | โŒ | โŒ | โŒ | โŒ |
363
- | **Memory Tracing** | โœ… Latency breakdown | โŒ | โŒ | โŒ | โŒ |
364
- | **OpenTelemetry** | โœ… OTLP spans (v4.6) | โŒ | โŒ | โŒ | โŒ |
365
- | **VLM Image Captions** | โœ… Auto-caption vault (v4.5) | โŒ | โŒ | โŒ | โŒ |
366
- | **Pluggable LLM Adapters** | โœ… OpenAI/Anthropic/Gemini/Ollama | โŒ | โœ… Multi-provider | โŒ | โŒ |
367
- | **LangChain** | โœ… BaseRetriever | โŒ | โŒ | โŒ | โŒ |
368
- | **Vector Compression** | โœ… TurboQuant 10ร— (v5.0) | โŒ | โŒ | โŒ | โŒ |
369
- | **Three-Tier Search** | โœ… FTS + Vec + Quantized | โŒ | โŒ | โŒ | โŒ |
370
- | **MCP Native** | โœ… stdio | โœ… stdio | โŒ Python SDK | โœ… HTTP + MCP | โœ… stdio |
371
- | **Language** | TypeScript | TypeScript | Python | Python | Python |
372
-
373
- > **When to choose Prism MCP:** You want MCP-native memory with zero infrastructure overhead, progressive context loading, and enterprise features (OCC, compaction, time travel, security scanning) that work directly in Claude Desktop โ€” without running Qdrant, Postgres, or cloud services.
100
+ > [Full CHANGELOG โ†’](CHANGELOG.md) ยท [Architecture Deep Dive โ†’](docs/ARCHITECTURE.md)
374
101
 
375
102
  ---
376
103
 
377
- ## Quick Start (Zero Config โ€” Local Mode)
378
-
379
- Get the MCP server running with Claude Desktop or Cursor in **under 60 seconds**. No API keys required for basic local memory!
380
-
381
- ### Option A: npx (Fastest)
104
+ ## ๐Ÿš€ Quick Start
382
105
 
383
- Add this to your `claude_desktop_config.json` or `.cursor/mcp.json`:
106
+ Add to your MCP client config (`claude_desktop_config.json`, `.cursor/mcp.json`, etc.):
384
107
 
385
108
  ```json
386
109
  {
@@ -393,100 +116,25 @@ Add this to your `claude_desktop_config.json` or `.cursor/mcp.json`:
393
116
  }
394
117
  ```
395
118
 
396
- That's it โ€” **zero env vars needed** for local memory, Mind Palace dashboard, Time Travel, and Telepathy.
397
-
398
- > **Optional API keys:** Add `BRAVE_API_KEY` for web search, `GOOGLE_API_KEY` for semantic search + Morning Briefings + paper analysis. See [Environment Variables](#environment-variables) for the full list.
399
-
400
- ### Option B: Cloud Sync Mode (Supabase)
401
-
402
- To share memory across multiple machines or teams, switch to Supabase:
403
-
404
- ```json
405
- {
406
- "mcpServers": {
407
- "prism-mcp": {
408
- "command": "npx",
409
- "args": ["-y", "prism-mcp-server"],
410
- "env": {
411
- "PRISM_STORAGE": "supabase",
412
- "SUPABASE_URL": "https://your-project.supabase.co",
413
- "SUPABASE_KEY": "your-supabase-anon-key"
414
- }
415
- }
416
- }
417
- }
418
- ```
419
-
420
- ### Option C: Clone & Build (Full Control)
421
-
422
- ```bash
423
- git clone https://github.com/dcostenco/prism-mcp.git
424
- cd prism-mcp
425
- npm install
426
- npm run build
427
- ```
428
-
429
- Then add to your MCP config:
430
-
431
- ```json
432
- {
433
- "mcpServers": {
434
- "prism-mcp": {
435
- "command": "node",
436
- "args": ["/absolute/path/to/prism-mcp/dist/server.js"],
437
- "env": {
438
- "BRAVE_API_KEY": "your-brave-api-key",
439
- "GOOGLE_API_KEY": "your-google-gemini-key"
440
- }
441
- }
442
- }
443
- }
444
- ```
445
-
446
- **Restart your MCP client. That's it โ€” all tools are now available.**
447
-
448
- ---
449
-
450
- ## ๐Ÿ”ฎ The Mind Palace Dashboard
451
-
452
- Prism MCP spins up a lightweight, zero-dependency HTTP server alongside the MCP stdio process. No frameworks, no build step โ€” just pure glassmorphism CSS served as a template literal.
453
-
454
- Open **`http://localhost:3000`** in your browser to see exactly what your AI agent is thinking:
119
+ **That's it.** Restart your client. All 30+ tools are available. Dashboard at `http://localhost:3000`.
455
120
 
456
- ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
457
-
458
- - **Current State & TODOs** โ€” See the exact context injected into the LLM's prompt
459
- - **Agent Identity Chip** โ€” Header shows your active role + name (e.g. `๐Ÿ› ๏ธ dev ยท Antigravity`); click to open Settings
460
- - **Project Repo Paths** โ€” Map each project to its repo directory for save validation
461
- - **Brain Health ๐Ÿฉบ** โ€” Memory integrity status at a glance; **๐Ÿงน Fix Issues** button auto-cleans orphaned handoffs in one click
462
- - **Git Drift Detection** โ€” Alerts you if you've modified code outside the agent's view
463
- - **Morning Briefing** โ€” AI-synthesized action plan from your last sessions
464
- - **Time Travel Timeline** โ€” Browse historical handoff states and revert any version
465
- - **Visual Memory Vault** โ€” Browse UI screenshots and auto-captured HTML states
466
- - **Session Ledger** โ€” Full audit trail of every decision your agent has made
467
- - **Neural Graph** โ€” Force-directed visualization of project โ†” keyword associations
468
- - **Hivemind Radar** โ€” Real-time active agent roster with role, task, and heartbeat
469
-
470
- The dashboard auto-discovers all your projects and updates in real time.
121
+ > **Optional API keys:** `GOOGLE_API_KEY` for semantic search + Morning Briefings, `BRAVE_API_KEY` for web search. See [Environment Variables](#environment-variables).
471
122
 
472
123
  ---
473
124
 
474
- ## Integration Examples
475
-
476
- Copy-paste configs for popular MCP clients. All configs use the `npx` method.
125
+ ## ๐Ÿ“– Setup Guides
477
126
 
478
127
  <details>
479
128
  <summary><strong>Claude Desktop</strong></summary>
480
129
 
481
- Add to your `claude_desktop_config.json`:
130
+ Add to `claude_desktop_config.json`:
482
131
 
483
132
  ```json
484
133
  {
485
134
  "mcpServers": {
486
135
  "prism-mcp": {
487
136
  "command": "npx",
488
- "args": ["-y", "prism-mcp-server"],
489
- "env": {}
137
+ "args": ["-y", "prism-mcp-server"]
490
138
  }
491
139
  }
492
140
  }
@@ -497,15 +145,14 @@ Add to your `claude_desktop_config.json`:
497
145
  <details>
498
146
  <summary><strong>Cursor</strong></summary>
499
147
 
500
- Add to `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
148
+ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
501
149
 
502
150
  ```json
503
151
  {
504
152
  "mcpServers": {
505
153
  "prism-mcp": {
506
154
  "command": "npx",
507
- "args": ["-y", "prism-mcp-server"],
508
- "env": {}
155
+ "args": ["-y", "prism-mcp-server"]
509
156
  }
510
157
  }
511
158
  }
@@ -523,8 +170,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
523
170
  "mcpServers": {
524
171
  "prism-mcp": {
525
172
  "command": "npx",
526
- "args": ["-y", "prism-mcp-server"],
527
- "env": {}
173
+ "args": ["-y", "prism-mcp-server"]
528
174
  }
529
175
  }
530
176
  }
@@ -554,23 +200,48 @@ Add to your Continue `config.json` or Cline MCP settings:
554
200
 
555
201
  </details>
556
202
 
557
- ---
203
+ <details>
204
+ <summary><strong>Migrating Existing History (Claude, Gemini, OpenAI)</strong></summary>
205
+
206
+ Prism can ingest months of historical sessions from other tools to give your Mind Palace a massive head start.
207
+
208
+ ### Supported Formats
209
+ * **Claude Code** (`.jsonl` logs) โ€” Automatically handles streaming chunk deduplication and `requestId` normalization.
210
+ * **Gemini** (JSON history arrays) โ€” Supports large-file streaming for 100MB+ exports.
211
+ * **OpenAI** (JSON chat completion history) โ€” Normalizes disparate tool-call structures into the unified Ledger schema.
212
+
213
+ ### How to Run
214
+ Use the `universal-import` command:
215
+
216
+ ```bash
217
+ # Ingest Claude Code history
218
+ npx -y prism-mcp-server universal-import --format claude --path ~/path/to/claude_log.jsonl --project my-project
219
+
220
+ # Dry run (verify mapping without saving)
221
+ npx -y prism-mcp-server universal-import --format gemini --path ./gemini_history.json --dry-run
222
+ ```
223
+
224
+ ### Key Features
225
+ * **OOM-Safe Streaming:** Processes massive log files line-by-line using `stream-json`.
226
+ * **Chronological Integrity:** Uses timestamp fallbacks and `requestId` sorting to ensure your memory timeline is accurate.
227
+ * **Smart Context Mapping:** Extracts `cwd`, `gitBranch`, and tool usage patterns into searchable metadata.
558
228
 
559
- ## Claude Code Integration (Hooks)
229
+ </details>
230
+
231
+ <details>
232
+ <summary><strong>Claude Code โ€” Lifecycle Hooks (Auto-Load & Auto-Save)</strong></summary>
560
233
 
561
- Claude Code supports custom hooks (`SessionStart`, `Stop`) that can force the agent to load and save Prism context automatically. Because Claude Code requires explicit permission for MCP tools, you must also whitelist the Prism commands.
234
+ Claude Code supports `SessionStart` and `Stop` hooks that force the agent to load/save Prism context automatically.
562
235
 
563
- ### 1. The Auto-Load Hook Script
236
+ ### 1. Create the Hook Script
564
237
 
565
- Create a Python script (e.g., `~/.claude/mcp_autoload_hook.py`). This script outputs JSON that Claude Code reads during the `SessionStart` event.
238
+ Save as `~/.claude/mcp_autoload_hook.py`:
566
239
 
567
240
  ```python
568
241
  #!/usr/bin/env python3
569
- import json
570
- import sys
242
+ import json, sys
571
243
 
572
244
  def main():
573
- # Inject a system message forcing the agent to load memory BEFORE speaking
574
245
  print(json.dumps({
575
246
  "continue": True,
576
247
  "suppressOutput": True,
@@ -587,8 +258,6 @@ if __name__ == "__main__":
587
258
 
588
259
  ### 2. Configure `settings.json`
589
260
 
590
- Map the hooks in your `~/.claude/settings.json`:
591
-
592
261
  ```json
593
262
  {
594
263
  "hooks": {
@@ -610,8 +279,7 @@ Map the hooks in your `~/.claude/settings.json`:
610
279
  "hooks": [
611
280
  {
612
281
  "type": "command",
613
- "command": "python3 -c \"import json; print(json.dumps({'continue': True, 'suppressOutput': True, 'systemMessage': 'MANDATORY END WORKFLOW: 1) Call mcp__prism-mcp__session_save_ledger with project and summary. 2) Call mcp__prism-mcp__session_save_handoff with expected_version set to the loaded version.'}))\"",
614
- "timeout": 10
282
+ "command": "python3 -c \"import json; print(json.dumps({'continue': True, 'suppressOutput': True, 'systemMessage': 'MANDATORY END WORKFLOW: 1) Call mcp__prism-mcp__session_save_ledger with project and summary. 2) Call mcp__prism-mcp__session_save_handoff with expected_version set to the loaded version.'}))\""
615
283
  }
616
284
  ]
617
285
  }
@@ -629,1099 +297,437 @@ Map the hooks in your `~/.claude/settings.json`:
629
297
  }
630
298
  ```
631
299
 
632
- ### How the Hooks Work
633
-
634
- The hook `command` runs a Python script that returns a JSON object to Claude Code:
635
-
636
- | Field | Purpose |
637
- |---|---|
638
- | `continue: true` | Tell Claude Code to proceed (don't abort the session) |
639
- | `suppressOutput: true` | Silently inject the system message (recommended for Stop hooks) |
640
- | `systemMessage` | Instruction injected as a system message โ€” the agent follows it |
641
-
642
- The agent receives the `systemMessage` as an instruction and executes the tool calls. The server resolves the agent's **role** and **name** automatically from the dashboard โ€” no need to specify them in the hook.
643
-
644
- ### Role Resolution โ€” No Hardcoding Needed
645
-
646
- Prism resolves the agent role dynamically using a priority chain:
647
-
648
- ```
649
- explicit tool argument โ†’ dashboard setting โ†’ "global" (default)
650
- ```
651
-
652
- 1. **Explicit arg wins** โ€” if `role` is passed in the tool call, it's used directly.
653
- 2. **Dashboard fallback** โ€” if `role` is omitted, the server calls `getSetting("default_role")` and uses whatever role you configured in the **Mind Palace Dashboard โš™๏ธ Settings โ†’ Agent Identity**.
654
- 3. **Final default** โ€” if no dashboard setting exists, falls back to `"global"`.
300
+ ### Troubleshooting
655
301
 
656
- Change your role once in the dashboard, and it automatically applies to every session โ€” CLI, extension, and all MCP clients.
302
+ - **Hook not firing?** Check `timeout` โ€” if your script takes too long, Claude ignores it.
303
+ - **"Tool not available"?** This is a hallucination. Ensure `permissions.allow` exactly matches the double-underscore format.
657
304
 
658
- ### Troubleshooting Claude Code
305
+ </details>
659
306
 
660
- - **Hook not firing?** Check the hook `timeout` in Claude Code settings. If your Python script takes too long, Claude ignores it silently.
661
- - **"Tool not available" hallucination?** If Claude claims it doesn't have the tool, it's usually an adversarial Chain-of-Thought loop. Ensure the `permissions.allow` array exactly matches the double-underscore format (`mcp__prism-mcp__...`).
662
- - **Missing `PRISM_CONTEXT_LOADED`?** The hook didn't fire or the MCP server isn't connected. Verify `prism-mcp` is listed in your `mcpServers` config.
307
+ <details>
308
+ <summary><strong>Gemini / Antigravity โ€” Auto-Load Rules (Battle-Tested)</strong></summary>
663
309
 
664
- ---
310
+ Gemini-based agents (including Google's Antigravity IDE) require a fundamentally different approach to auto-load. This guide was refined over **14 iterations** of real-world prompt engineering.
665
311
 
666
- ## Gemini / Antigravity Integration
312
+ ### The Core Problem
667
313
 
668
- Antigravity and Gemini-based agents require a radically simplified approach to auto-loading. If you give modern instruction-tuned models a long list of "Banned Behaviors" (e.g., "Do NOT say hello first"), their internal reasoning often over-indexes on the constraints and causes them to hallucinate that the tool doesn't exist.
314
+ When given verbose instructions with many constraints, Gemini models hallucinate that MCP tools "don't exist" or "aren't available" โ€” even when they are. This is adversarial reasoning triggered by long rule lists, not a configuration issue.
669
315
 
670
- ### The 2-Line "First Action" Rule
316
+ ### The 2-Line Rule (Proven Fix)
671
317
 
672
- Create a `GEMINI.md` file in your project root (or globally at `~/.gemini/GEMINI.md`) or paste this into your Antigravity **User Rules**:
318
+ Create `~/.gemini/GEMINI.md`:
673
319
 
674
320
  ```markdown
675
321
  ## First Action
676
322
  Call `mcp_prism-mcp_session_load_context(project="my-project", level="deep")` before responding.
677
323
  ```
678
324
 
679
- > **Note:** Antigravity uses single underscores (`mcp_prism-mcp_...`) compared to Claude Code's double underscores (`mcp__prism-mcp__...`).
680
-
681
- That's it โ€” **two lines**. This approach proved reliable after 13 iterations of increasingly complex prompt engineering. The key insight: shorter instructions avoid triggering the model's adversarial reasoning about tool availability.
682
-
683
- ### Session End Protocol
325
+ **Why this works:**
326
+ - Gemini uses **single underscores** for MCP tools (`mcp_prism-mcp_...`) vs Claude's **double underscores** (`mcp__prism-mcp__...`)
327
+ - Keeping the instruction to 2 lines avoids triggering the model's adversarial "tool not found" reasoning
328
+ - Framing as a positive "First Action" directive outperforms negative constraint lists
684
329
 
685
- At the end of your conversation, explicitly tell the agent:
686
- > *"Wrap up the session."*
330
+ ### Antigravity UI Caveat
687
331
 
688
- The agent will rely on its system prompt to execute:
689
- 1. `session_save_ledger` โ€” immutable work log with summary, TODOs, and decisions
690
- 2. `session_save_handoff` โ€” passing the `expected_version` it received during the load step to ensure Optimistic Concurrency Control
691
-
692
- ### Antigravity UI Caveats
693
-
694
- Antigravity's UI currently does **not** visually render the raw output of MCP tool calls. To ensure the agent actually ingested the context, add this to your User Rules:
332
+ Antigravity **does not visually render MCP tool output blocks** in the chat UI. The tool executes successfully, but the user sees nothing. Fix this by adding an echo rule:
695
333
 
696
334
  ```markdown
697
- ## STEP 2: Echo Context in Your Text Response
698
- After the tool returns, include the following in your greeting text:
699
- - Agent identity: `๐Ÿค– Agent: <role> โ€” <name>`
335
+ ## Echo Context
336
+ After loading context, include in your text reply:
337
+ - Agent identity (role + name)
700
338
  - Last session summary
701
339
  - Open TODOs
702
340
  - Session version number
703
341
  ```
704
342
 
705
- This forces the agent to prove it loaded context by echoing it in visible text.
343
+ This ensures the user sees their project context even though the raw MCP output is invisible.
706
344
 
707
- ---
345
+ ### Session End Workflow
708
346
 
709
- ## Use Cases
710
-
711
- | Scenario | How Prism MCP Helps | Live Sample |
712
- |----------|---------------------|-------------|
713
- | **Long-running feature work** | Save session state at end of day, restore full context next morning โ€” no re-explaining | `session_save_handoff(project, last_summary, open_todos)` |
714
- | **Multi-agent collaboration** | Hivemind Telepathy lets multiple agents share real-time context across clients | `session_load_context(project, role="qa")` |
715
- | **Consulting / multi-project** | Switch between client projects with progressive context loading | `session_load_context(project, level="quick")` |
716
- | **Research & analysis** | Multi-engine search with 94% context reduction via sandboxed code transforms | `brave_web_search` + `code_mode_transform(template="api_endpoints")` |
717
- | **Team onboarding** | New team member's agent loads full project history instantly | `session_load_context(project, level="deep")` |
718
- | **Visual debugging** | Save UI screenshots to visual memory โ€” searchable by description | `session_save_image(project, path, description)` โ†’ `session_view_image(id)` |
719
- | **Offline / air-gapped** | Full SQLite local mode, Ollama LLM adapter โ€” zero internet dependency | `PRISM_LLM_PROVIDER=ollama` in MCP config env |
720
- | **Behavior enforcement** | Agent corrections auto-graduate into permanent `.cursorrules` | `session_save_experience(event_type="correction")` โ†’ `knowledge_sync_rules(project)` |
721
- | **Infrastructure observability** | OTel spans to Jaeger/Grafana for every MCP tool call fanout | Enable in Dashboard โ†’ Settings โ†’ ๐Ÿ”ญ Observability |
722
- | **GDPR / audit export** | ZIP export of all memory as JSON + Markdown, sensitive fields redacted | `session_export_memory(project, format="zip")` |
347
+ Tell the agent: *"Wrap up the session."* It should execute:
723
348
 
724
- ---
349
+ 1. `session_save_ledger` โ€” append immutable work log (summary, decisions, files changed)
350
+ 2. `session_save_handoff` โ€” upsert project state with `expected_version` for OCC
725
351
 
726
- ## New in v4.6.0 โ€” Feature Setup Guide
352
+ > **Tip:** Include the session-end instructions in your `GEMINI.md` or ask the agent to save when you're done.
727
353
 
728
- ### ๐Ÿ”ญ OpenTelemetry Distributed Tracing
354
+ ### Key Findings from 14 Iterations
729
355
 
730
- **Why:** Every `session_save_ledger` call can silently fan out into a synchronous DB write, an async VLM caption, and a vector embedding backfill. Without tracing, these are invisible. OTel makes the full call tree visible in Jaeger, Grafana Tempo, or any OTLP-compatible collector.
356
+ | Iteration | What We Tried | Result |
357
+ |-----------|---------------|--------|
358
+ | 1โ€“6 | Verbose "Banned Behaviors" blocks, negative constraints | โŒ Model hallucinated tools were unavailable |
359
+ | 7โ€“9 | `always_on` trigger rules, multi-file configs | โŒ Redundant configs caused race conditions |
360
+ | 10โ€“11 | Emergency-style `๐Ÿšจ MANDATORY` headers | โš ๏ธ Inconsistent โ€” worked sometimes |
361
+ | 12โ€“13 | Positive-only framing, progressively shorter | โš ๏ธ Better but still intermittent |
362
+ | 14 | **2-line "First Action" directive** | โœ… Reliable across sessions |
731
363
 
732
- **Setup:**
733
- 1. Open Mind Palace Dashboard โ†’ โš™๏ธ Settings โ†’ ๐Ÿ”ญ Observability
734
- 2. Toggle **Enable OpenTelemetry** โ†’ set your OTLP endpoint (default: `http://localhost:4318`)
735
- 3. Restart the MCP server
736
- 4. Run Jaeger locally:
737
- ```bash
738
- docker run -d --name jaeger \
739
- -p 16686:16686 -p 4318:4318 \
740
- jaegertracing/all-in-one:latest
741
- ```
742
- 5. Open http://localhost:16686 โ€” select service `prism-mcp` to see span waterfalls.
364
+ ### Platform Gotchas
743
365
 
744
- **Span hierarchy:**
745
- ```
746
- mcp.call_tool [session_save_ledger]
747
- โ”œโ”€โ”€ storage.write_ledger ~2ms
748
- โ”œโ”€โ”€ llm.generate_embedding ~180ms
749
- โ””โ”€โ”€ worker.vlm_caption (async) ~1.2s
750
- ```
366
+ - **`replace_file_content` silently fails** on `~/.gemini/GEMINI.md` in some environments โ€” use `write_to_file` with overwrite instead
367
+ - **Multiple GEMINI.md locations** can conflict: global (`~/.gemini/`), workspace, and User Rules in the Antigravity UI. Keep them synchronized
368
+ - **Camoufox/browser tools** called at startup spawn visible black windows โ€” never call browser tools during greeting handlers
751
369
 
752
- > GDPR note: Span attributes contain only metadata โ€” no prompt content, embeddings, or image data.
370
+ </details>
753
371
 
754
- ---
372
+ <details>
373
+ <summary><strong>Supabase Cloud Sync</strong></summary>
374
+
375
+ To sync memory across machines or teams:
376
+
377
+ ```json
378
+ {
379
+ "mcpServers": {
380
+ "prism-mcp": {
381
+ "command": "npx",
382
+ "args": ["-y", "prism-mcp-server"],
383
+ "env": {
384
+ "PRISM_STORAGE": "supabase",
385
+ "SUPABASE_URL": "https://your-project.supabase.co",
386
+ "SUPABASE_KEY": "your-supabase-anon-key"
387
+ }
388
+ }
389
+ }
390
+ }
391
+ ```
755
392
 
756
- ### ๐Ÿ–ผ๏ธ VLM Multimodal Memory
393
+ See the **Supabase Setup** section below for schema migration instructions.
757
394
 
758
- **Why:** Agents lose visual context between sessions. UI screenshots, architecture diagrams, and bug states all become searchable memory.
395
+ </details>
759
396
 
760
- **Setup:** Requires `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` (vision-capable model).
397
+ <details>
398
+ <summary><strong>Clone & Build (Full Control)</strong></summary>
761
399
 
762
- **Usage:**
763
- ```
764
- session_save_image(project="my-app", file_path="/path/to/screenshot.png", description="Login page broken layout after CSS refactor")
765
- ```
766
- The image is auto-captioned by a VLM and stored in the media vault. Retrieve later:
400
+ ```bash
401
+ git clone https://github.com/dcostenco/prism-mcp.git
402
+ cd prism-mcp && npm install && npm run build
767
403
  ```
768
- session_view_image(project="my-app", image_id="8f2a1b3c")
404
+
405
+ Then add to your MCP config:
406
+
407
+ ```json
408
+ {
409
+ "mcpServers": {
410
+ "prism-mcp": {
411
+ "command": "node",
412
+ "args": ["/path/to/prism-mcp/dist/server.js"],
413
+ "env": {
414
+ "BRAVE_API_KEY": "your-key",
415
+ "GOOGLE_API_KEY": "your-gemini-key"
416
+ }
417
+ }
418
+ }
419
+ }
769
420
  ```
770
421
 
422
+ </details>
423
+
771
424
  ---
772
425
 
773
- ## Architecture
426
+ ## How Prism Compares
774
427
 
775
- > **๐Ÿ“– Deep dive**: [Full Architecture Guide](docs/ARCHITECTURE.md) โ€” TurboQuant math, Three-Tier search, storage optimization flow
776
- > **๐Ÿค– Tutorial**: [How to Build a Self-Improving Agent](docs/self-improving-agent.md) โ€” corrections โ†’ behavioral memory โ†’ IDE rules
777
-
778
- ```mermaid
779
- graph TB
780
- Client["AI Client<br/>(Claude Desktop / Cursor / Windsurf)"]
781
- LangChain["LangChain / LangGraph<br/>(Python/TS Retrievers)"]
782
- MCP["Prism MCP Server<br/>(TypeScript)"]
783
-
784
- Client -- "MCP Protocol (stdio)" --> MCP
785
- LangChain -- "JSON-RPC via MCP Bridge" --> MCP
786
-
787
- MCP --> Tracing["OTel Tracing<br/>v4.6 Observability"]
788
- MCP --> Dashboard["Mind Palace Dashboard<br/>localhost:3000<br/>(PRISM_DASHBOARD_PORT)"]
789
- MCP --> Brave["Brave Search API<br/>Web + Local + AI Answers"]
790
- MCP --> LLM["LLM Factory<br/>Gemini / OpenAI / Ollama"]
791
- MCP --> Sandbox["QuickJS Sandbox<br/>Code-Mode Templates"]
792
- MCP --> SyncBus["SyncBus<br/>Agent Telepathy"]
793
- MCP --> GDPR["GDPR Engine<br/>Soft/Hard Delete + Audit"]
794
-
795
- MCP --> Storage{"Storage Backend"}
796
- Storage --> SQLite["SQLite (Local)<br/>libSQL + sqlite-vec"]
797
- Storage --> Supabase["Supabase (Cloud)<br/>PostgreSQL + pgvector"]
798
-
799
- SQLite --> Ledger["session_ledger"]
800
- Ledger --> T1["Tier 1: float32<br/>3,072B native search"]
801
- T1 -- "v5.0 TurboQuant" --> T2["Tier 2: turbo4<br/>400B JS search"]
802
- T1 -. "v5.1 Purge" .-> Null["NULL after 30d"]
803
-
804
- SQLite --> Handoffs["session_handoffs<br/>(OCC versioning)"]
805
- SQLite --> History["history_snapshots<br/>(Time Travel)"]
806
- SQLite --> Media["media vault<br/>(Visual Memory)"]
807
-
808
- style Client fill:#4A90D9,color:#fff
809
- style LangChain fill:#1C3D5A,color:#fff
810
- style MCP fill:#2D3748,color:#fff
811
- style Tracing fill:#D69E2E,color:#fff
812
- style Dashboard fill:#9F7AEA,color:#fff
813
- style Brave fill:#FB542B,color:#fff
814
- style LLM fill:#4285F4,color:#fff
815
- style Sandbox fill:#805AD5,color:#fff
816
- style SyncBus fill:#ED64A6,color:#fff
817
- style GDPR fill:#E53E3E,color:#fff
818
- style Storage fill:#2D3748,color:#fff
819
- style SQLite fill:#38B2AC,color:#fff
820
- style Supabase fill:#3ECF8E,color:#fff
821
- style T1 fill:#48BB78,color:#fff
822
- style T2 fill:#E8B004,color:#000
823
- style Null fill:#E53E3E,color:#fff
824
- ```
428
+ **Prism MCP** vs [MCP Memory](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) ยท [Mem0](https://github.com/mem0ai/mem0) ยท [Mnemory](https://github.com/fpytloun/mnemory) ยท [Basic Memory](https://github.com/basicmachines-co/basic-memory)
825
429
 
826
- ---
430
+ **Only Prism has all of these:**
431
+ - โœ… Zero config โ€” one `npx` command, no Qdrant/Postgres containers
432
+ - โœ… Time Travel โ€” versioned snapshots with `memory_checkout`
433
+ - โœ… Behavioral memory โ€” importance tracking, auto-decay, mistake learning
434
+ - โœ… Visual dashboard โ€” Mind Palace at localhost:3000
435
+ - โœ… Multi-agent sync โ€” role-isolated Hivemind with real-time Telepathy
436
+ - โœ… Visual memory โ€” VLM-captioned screenshot vault
437
+ - โœ… Token budgeting โ€” `max_tokens` param on context loading
438
+ - โœ… 10ร— vector compression โ€” TurboQuant, no external vector DB
439
+ - โœ… GDPR compliance โ€” soft/hard delete, ZIP export, TTL retention
440
+ - โœ… OpenTelemetry โ€” full span tracing to Jaeger/Grafana
441
+ - โœ… LangChain adapters โ€” `BaseRetriever` integration + LangGraph examples
442
+ - โœ… Morning Briefings โ€” AI-synthesized action plans after breaks
443
+ - โœ… Auto-compaction โ€” Gemini-powered rollups to prevent unbounded growth
444
+ - โœ… IDE rules sync โ€” graduated insights โ†’ `.cursorrules` / `.clauderules`
445
+ - โœ… Air-gapped mode โ€” SQLite + Ollama, zero internet needed
827
446
 
828
- ## Tool Reference
447
+ > **TL;DR:** Prism is the only MCP memory server with time travel, behavioral learning, visual memory, multi-agent sync, and 10ร— compression โ€” all from a single `npx` command.
829
448
 
830
- ### Search & Analysis Tools
449
+ ---
831
450
 
832
- | Tool | Purpose |
833
- |------|---------|
834
- | `brave_web_search` | Real-time internet search |
835
- | `brave_local_search` | Location-based POI discovery |
836
- | `brave_web_search_code_mode` | JS extraction over web search results |
837
- | `brave_local_search_code_mode` | JS extraction over local search results |
838
- | `code_mode_transform` | Universal post-processing with **8 built-in templates** |
839
- | `gemini_research_paper_analysis` | Academic paper analysis via Gemini |
840
- | `brave_answers` | AI-grounded answers from Brave |
451
+ ## ๐Ÿ”ง Tool Reference
841
452
 
842
- ### Session Memory & Knowledge Tools
453
+ <details>
454
+ <summary><strong>Session Memory & Knowledge (12 tools)</strong></summary>
843
455
 
844
456
  | Tool | Purpose |
845
457
  |------|---------|
846
458
  | `session_save_ledger` | Append immutable session log (summary, TODOs, decisions) |
847
459
  | `session_save_handoff` | Upsert latest project state with OCC version tracking |
848
460
  | `session_load_context` | Progressive context loading (quick / standard / deep) |
849
- | `knowledge_search` | Semantic search across accumulated knowledge |
461
+ | `knowledge_search` | Full-text keyword search across accumulated knowledge |
850
462
  | `knowledge_forget` | Prune outdated or incorrect memories (4 modes + dry_run) |
463
+ | `knowledge_set_retention` | Set per-project TTL retention policy |
851
464
  | `session_search_memory` | Vector similarity search across all sessions |
852
- | `session_compact_ledger` | Auto-compact old ledger entries via Gemini-powered summarization |
465
+ | `session_compact_ledger` | Auto-compact old entries via Gemini summarization |
466
+ | `session_forget_memory` | GDPR-compliant deletion (soft/hard + Art. 17 reason) |
467
+ | `session_export_memory` | Full ZIP export (JSON + Markdown) for portability |
468
+ | `session_health_check` | Brain integrity scan + auto-repair (`fsck`) |
469
+ | `deep_storage_purge` | Reclaim ~90% vector storage (v5.1) |
470
+
471
+ </details>
853
472
 
854
- ### v3.1 Lifecycle Tools
473
+ <details>
474
+ <summary><strong>Behavioral Memory & Knowledge Graph (5 tools)</strong></summary>
855
475
 
856
476
  | Tool | Purpose |
857
477
  |------|---------|
858
- | `knowledge_set_retention` | Set a per-project TTL retention policy (0 = disabled, min 7 days). Immediately expires overdue entries. |
478
+ | `session_save_experience` | Record corrections, successes, failures, learnings |
479
+ | `knowledge_upvote` | Increase entry importance (+1) |
480
+ | `knowledge_downvote` | Decrease entry importance (-1) |
481
+ | `knowledge_sync_rules` | Sync graduated insights to `.cursorrules` / `.clauderules` |
482
+ | `session_save_image` / `session_view_image` | Visual memory vault |
483
+
484
+ </details>
859
485
 
860
- ### v2.0 Advanced Memory Tools
486
+ <details>
487
+ <summary><strong>Time Travel & History (2 tools)</strong></summary>
861
488
 
862
489
  | Tool | Purpose |
863
490
  |------|---------|
864
491
  | `memory_history` | Browse all historical versions of a project's handoff state |
865
- | `memory_checkout` | Revert to any previous version (non-destructive, like `git revert`) |
866
- | `session_save_image` | Save a screenshot/image to the visual memory vault |
867
- | `session_view_image` | Retrieve and display a saved image from the vault |
492
+ | `memory_checkout` | Revert to any previous version (non-destructive) |
868
493
 
869
- ### v2.2 Brain Health Tools
494
+ </details>
870
495
 
871
- | Tool | Purpose | Key Args | Returns |
872
- |------|---------|----------|---------|
873
- | `session_health_check` | Scan brain for integrity issues (`fsck`) | `project`, `auto_fix` (boolean) | Health report & auto-repairs |
496
+ <details>
497
+ <summary><strong>Search & Analysis (7 tools)</strong></summary>
874
498
 
875
- The **Mind Palace Dashboard** also shows a live **Brain Health ๐Ÿฉบ** card for every project:
499
+ | Tool | Purpose |
500
+ |------|---------|
501
+ | `brave_web_search` | Real-time internet search |
502
+ | `brave_local_search` | Location-based POI discovery |
503
+ | `brave_web_search_code_mode` | JS extraction over web search results |
504
+ | `brave_local_search_code_mode` | JS extraction over local search results |
505
+ | `code_mode_transform` | Universal post-processing with 8 built-in templates |
506
+ | `gemini_research_paper_analysis` | Academic paper analysis via Gemini |
507
+ | `brave_answers` | AI-grounded answers from Brave |
876
508
 
877
- - **Status indicator** โ€” `โœ… Healthy` or `โš ๏ธ Issues detected` with entry/handoff/rollup counts
878
- - **๐Ÿงน Fix Issues button** โ€” appears automatically when issues are detected; click to clean up orphaned handoffs and stale rollups in one click, no MCP tool call required
879
- - **No issues found** โ€” shown in green when memory integrity is confirmed
509
+ </details>
880
510
 
881
- The tool and dashboard button both call the same repair logic โ€” the dashboard button is simply a zero-friction shortcut for common maintenance.
882
-
883
- ### v2.5 Enterprise Memory Tools
884
-
885
- | Tool | Purpose | Key Args | Returns |
886
- |------|---------|----------|---------|
887
- | `session_forget_memory` | GDPR-compliant deletion (soft/hard) | `memory_id`, `hard_delete`, `reason` | Deletion confirmation + audit |
888
- | `session_search_memory` | Semantic search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
889
- | `knowledge_search` | Knowledge search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
890
-
891
- ### v4.0 Behavioral Memory Tools
892
-
893
- | Tool | Purpose | Key Args |
894
- |------|---------|----------|
895
- | `session_save_experience` | Record behavioral events with importance tracking | `project`, `event_type`, `context`, `action`, `outcome` |
896
-
897
- **Dynamic Roles (v4.0):** `role` is now *optional* on all tools. Set your **Default Role** once in the dashboard (โš™๏ธ Settings โ†’ Agent Identity) and it auto-applies everywhere โ€” no need to pass it per call.
898
-
899
- **Token Budget (v4.0):** Set a default in the dashboard (โš™๏ธ Settings โ†’ Token Budget) or pass `max_tokens` per call to override:
900
-
901
- ```json
902
- { "name": "session_load_context", "arguments": {
903
- "project": "my-app", "level": "standard", "max_tokens": 2000
904
- }}
905
- ```
906
-
907
- > ๐Ÿ’ก Set Token Budget to `0` in the dashboard for unlimited (default). Per-call `max_tokens` always takes priority.
908
-
909
- **Recording experiences:**
910
-
911
- ```json
912
- { "name": "session_save_experience", "arguments": {
913
- "project": "my-app",
914
- "event_type": "correction",
915
- "context": "User asked to add a database migration",
916
- "action": "Ran ALTER TABLE directly in production",
917
- "outcome": "Data was corrupted",
918
- "correction": "Always create a migration file and test in staging first",
919
- "confidence_score": 95
920
- }}
921
- ```
922
-
923
- **Event types:** `correction` (user corrected the agent), `success` (task went well), `failure` (task failed), `learning` (new knowledge acquired).
924
-
925
- **How behavioral memory works:**
926
- 1. Agent records experiences via `session_save_experience`
927
- 2. Prism assigns an **importance score** based on event type + confidence
928
- 3. Stale entries **auto-decay** in importance over time
929
- 4. On `session_load_context`, high-importance corrections auto-surface as `[โš ๏ธ BEHAVIORAL WARNINGS]`
930
- 5. Agent sees warnings and avoids repeating past mistakes
931
-
932
- ### v4.3.0 Knowledge Sync Rules โ€” "The Bridge"
933
-
934
- Bridges **v4.0 Behavioral Memory** (graduated insights) with **v4.2.0 Project Registry** (repo paths) to physically write agent learnings into your project's IDE rules file.
935
-
936
- | Feature | Without Sync Rules | With `knowledge_sync_rules` |
937
- |---------|-------------------|----------------------------|
938
- | **Insight Visibility** | Only in Prism context injection | Persisted as static IDE context (`.cursorrules` / `.clauderules`) |
939
- | **Cross-Session** | Loaded per-session via tool call | Always-on โ€” IDE reads rules file on every prompt |
940
- | **Agent Learning Loop** | Behavioral warnings during context load | Rules enforced even without Prism connected |
941
- | **Idempotency** | N/A | Sentinel markers ensure safe re-runs |
942
- | **User Control** | View in dashboard | User-maintained rules preserved; only sentinel block updated |
943
-
944
- **Syncing graduated insights:**
945
-
946
- ```json
947
- { "name": "knowledge_sync_rules", "arguments": {
948
- "project": "my-app",
949
- "target_file": ".cursorrules",
950
- "dry_run": true
951
- }}
952
- ```
953
-
954
- **How it works:**
955
- 1. Fetches graduated insights (`importance >= 7`) from the ledger
956
- 2. Formats them as markdown rules inside `<!-- PRISM:AUTO-RULES:START/END -->` sentinel markers
957
- 3. Idempotently writes them into the target file at the project's configured `repo_path`
958
-
959
- | Tool | Purpose | Key Args |
960
- |------|---------|----------|
961
- | `knowledge_sync_rules` | Sync graduated insights to IDE rules file | `project`, `target_file`, `dry_run` |
962
- | `knowledge_upvote` | Increase entry importance (+1) | `id` |
963
- | `knowledge_downvote` | Decrease entry importance (-1) | `id` |
964
-
965
- > ๐Ÿ’ก **Prerequisite:** Set a `repo_path` for your project in the Mind Palace dashboard (โš™๏ธ Settings โ†’ Project Repo Paths) before syncing.
966
-
967
- ### Code Mode Templates (v2.1)
968
-
969
- Instead of writing custom JavaScript, pass a `template` name for instant extraction:
970
-
971
- | Template | Source Data | What It Extracts |
972
- |----------|-----------|-----------------|
973
- | `github_issues` | GitHub REST API | `#number [state] title (@author) {labels}` |
974
- | `github_prs` | GitHub REST API | `#number [state] title (base โ† head)` |
975
- | `jira_tickets` | Jira REST API | `[KEY] summary - Status - Priority - Assignee` |
976
- | `dom_links` | Raw HTML | All `<a>` links as markdown |
977
- | `dom_headings` | Raw HTML | H1-H6 hierarchy with indentation |
978
- | `api_endpoints` | OpenAPI/Swagger JSON | `[METHOD] /path - summary` |
979
- | `slack_messages` | Slack Web API | `[timestamp] @user: message` |
980
- | `csv_summary` | CSV text | Column names, row count, sample rows |
981
-
982
- **Tool Arguments:** `{ "data": "<raw JSON>", "template": "github_issues" }` โ€” no custom code needed.
983
-
984
- ---
985
-
986
- ## Agent Hivemind โ€” Role Usage
987
-
988
- Role-scoped memory lets multiple agents work on the same project without stepping on each other's memory. Each role gets its own isolated memory lane. Defaults to `global` for full backward compatibility.
511
+ <details>
512
+ <summary><strong>Multi-Agent Hivemind (3 tools)</strong></summary>
989
513
 
990
- ### Available Roles
514
+ Requires `PRISM_ENABLE_HIVEMIND=true`.
991
515
 
992
- | Role | Use for |
516
+ | Tool | Purpose |
993
517
  |------|---------|
994
- | `dev` | Development agent |
995
- | `qa` | Testing / QA agent |
996
- | `pm` | Product management |
997
- | `lead` | Tech lead / orchestrator |
998
- | `security` | Security review |
999
- | `ux` | Design / UX |
1000
- | `global` | Default โ€” shared, no isolation |
1001
-
1002
- Custom role strings are also supported (e.g. `"docs"`, `"ml"`).
1003
-
1004
- ### Using Roles with Memory Tools
1005
-
1006
- Just add `"role"` to any of the core memory tools:
1007
-
1008
- ```json
1009
- // Save a ledger entry as the "dev" agent
1010
- { "name": "session_save_ledger", "arguments": {
1011
- "project": "my-app",
1012
- "role": "dev",
1013
- "conversation_id": "abc123",
1014
- "summary": "Fixed the auth race condition"
1015
- }}
1016
-
1017
- // Load context scoped to your role
1018
- // Also injects a Team Roster showing active teammates
1019
- { "name": "session_load_context", "arguments": {
1020
- "project": "my-app",
1021
- "role": "dev",
1022
- "level": "standard"
1023
- }}
1024
-
1025
- // Save handoff as the "qa" agent
1026
- { "name": "session_save_handoff", "arguments": {
1027
- "project": "my-app",
1028
- "role": "qa",
1029
- "last_summary": "Ran regression suite โ€” 2 failures in auth module"
1030
- }}
1031
- ```
1032
-
1033
- ### Hivemind Coordination Tools
1034
-
1035
- > **Requires:** `PRISM_ENABLE_HIVEMIND=true` (Boot Setting โ€” restart required)
1036
-
1037
- ```json
1038
- // Announce yourself to the team at session start
1039
- { "name": "agent_register", "arguments": {
1040
- "project": "my-app",
1041
- "role": "dev",
1042
- "agent_name": "Dev Agent #1",
1043
- "current_task": "Refactoring auth module"
1044
- }}
1045
-
1046
- // Pulse every ~5 min to stay visible (agents pruned after 30 min)
1047
- { "name": "agent_heartbeat", "arguments": {
1048
- "project": "my-app",
1049
- "role": "dev",
1050
- "current_task": "Now writing tests"
1051
- }}
1052
-
1053
- // See everyone on the team
1054
- { "name": "agent_list_team", "arguments": {
1055
- "project": "my-app"
1056
- }}
1057
- ```
1058
-
1059
- ### How Role Isolation Works
1060
-
1061
- - `session_load_context` with `role: "dev"` only sees entries saved with `role: "dev"`
1062
- - The `global` role is a shared pool โ€” anything saved without a role goes here
1063
- - When loading *with* a role, Prism auto-injects a **Team Roster** block listing active teammates, roles, and tasks โ€” no extra tool call needed
1064
- - The Hivemind Radar widget in the Mind Palace dashboard shows agent activity in real time
1065
-
1066
- ### Setting Your Agent Identity
1067
-
1068
- The easiest way to configure your role and name is via the **Mind Palace Dashboard โš™๏ธ Settings โ†’ Agent Identity**:
1069
-
1070
- - **Default Role** โ€” dropdown to select `dev`, `qa`, `pm`, `lead`, `security`, `ux`, or `global`
1071
- - **Agent Name** โ€” free text for your display name (e.g. `Dmitri`, `Dev Alex`, `QA Bot`)
1072
-
1073
- Once set, **all memory and Hivemind tools automatically use these values** as fallbacks โ€” no need to pass `role` or `agent_name` in every tool call.
1074
-
1075
- > **Priority order:** explicit tool arg โ†’ dashboard setting โ†’ `"global"` (default)
1076
-
1077
- **Alternative โ€” hardcode in your startup rules** (if you prefer prompt-level config):
1078
-
1079
- ```markdown
1080
- ## Prism MCP Memory Auto-Load (CRITICAL)
1081
- At the start of every new session, call session_load_context with:
1082
- - project: "my-app", role: "dev"
1083
- - project: "my-other-project", role: "dev"
1084
- ```
1085
-
1086
- > **Tip:** For true multi-agent setups, each AI instance has its own Mind Palace dashboard โ€” set a different identity per agent there rather than managing it in prompts.
1087
-
1088
- ---
1089
-
1090
- ## LangChain / LangGraph Integration
1091
-
1092
- Prism MCP includes first-class Python adapters for the LangChain ecosystem, located in `examples/langgraph-agent/`:
1093
-
1094
- | Component | File | Purpose |
1095
- |-----------|------|---------|
1096
- | **MCP Bridge** | `mcp_client.py` | JSON-RPC 2.0 client with `call_tool()` and `call_tool_raw()` (preserves `MemoryTrace`) |
1097
- | **Semantic Retriever** | `prism_retriever.py` | `PrismMemoryRetriever(BaseRetriever)` โ€” async-first vector search |
1098
- | **Keyword Retriever** | `prism_retriever.py` | `PrismKnowledgeRetriever(BaseRetriever)` โ€” FTS5 keyword search |
1099
- | **Forget Tool** | `tools.py` | `forget_memory()` โ€” GDPR deletion bridge |
1100
- | **Research Agent** | `agent.py` | 5-node LangGraph agent (planโ†’searchโ†’analyzeโ†’decideโ†’answerโ†’save) |
1101
-
1102
- ### Hybrid Search with EnsembleRetriever
1103
-
1104
- Combine both retrievers for hybrid (semantic + keyword) search with a single line:
1105
-
1106
- ```python
1107
- from langchain.retrievers import EnsembleRetriever
1108
- from prism_retriever import PrismMemoryRetriever, PrismKnowledgeRetriever
1109
-
1110
- retriever = EnsembleRetriever(
1111
- retrievers=[PrismMemoryRetriever(...), PrismKnowledgeRetriever(...)],
1112
- weights=[0.7, 0.3], # 70% semantic, 30% keyword
1113
- )
1114
- ```
1115
-
1116
- ### MemoryTrace in LangSmith
1117
-
1118
- When `enable_trace=True`, each `Document.metadata["trace"]` contains:
518
+ | `agent_register` | Announce yourself to the team |
519
+ | `agent_heartbeat` | Pulse every ~5 min to stay visible |
520
+ | `agent_list_team` | See all active teammates |
1119
521
 
1120
- ```json
1121
- {
1122
- "strategy": "vector_cosine_similarity",
1123
- "latency": { "embedding_ms": 45, "storage_ms": 12, "total_ms": 57 },
1124
- "result_count": 5,
1125
- "threshold": 0.7
1126
- }
1127
- ```
1128
-
1129
- This metadata flows automatically into LangSmith traces for observability.
1130
-
1131
- ### Async Architecture
1132
-
1133
- The retrievers use `_aget_relevant_documents` as the primary path with `asyncio.to_thread()` to wrap the synchronous MCP bridge. This prevents the `RuntimeError: This event loop is already running` crash that plagues most LangGraph deployments.
522
+ </details>
1134
523
 
1135
524
  ---
1136
525
 
1137
526
  ## Environment Variables
1138
527
 
528
+ <details>
529
+ <summary><strong>Full variable reference</strong></summary>
530
+
1139
531
  | Variable | Required | Description |
1140
532
  |----------|----------|-------------|
1141
- | `BRAVE_API_KEY` | No | Brave Search Pro API key (enables web/local search tools) |
1142
- | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` โ€” **requires restart** |
1143
- | `PRISM_ENABLE_HIVEMIND` | No | Set `"true"` to enable multi-agent Hivemind tools โ€” **requires restart** |
1144
- | `PRISM_INSTANCE` | No | Instance name for PID lock isolation (e.g. `"athena"`, `"prism-dev"`). Enables [multi-instance support](#multi-instance-support). Default: `"default"` |
1145
- | `GOOGLE_API_KEY` | No | Google AI / Gemini โ€” enables paper analysis, Morning Briefings, compaction |
1146
- | `BRAVE_ANSWERS_API_KEY` | No | Separate Brave Answers key for AI-grounded answers |
1147
- | `SUPABASE_URL` | If cloud mode | Supabase project URL |
1148
- | `SUPABASE_KEY` | If cloud mode | Supabase anon/service key |
533
+ | `BRAVE_API_KEY` | No | Brave Search Pro API key |
534
+ | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` โ€” restart required |
535
+ | `PRISM_ENABLE_HIVEMIND` | No | `"true"` to enable multi-agent tools โ€” restart required |
536
+ | `PRISM_INSTANCE` | No | Instance name for multi-server PID isolation |
537
+ | `GOOGLE_API_KEY` | No | Gemini โ€” enables semantic search, Briefings, compaction |
538
+ | `BRAVE_ANSWERS_API_KEY` | No | Separate Brave Answers key |
539
+ | `SUPABASE_URL` | If cloud | Supabase project URL |
540
+ | `SUPABASE_KEY` | If cloud | Supabase anon/service key |
1149
541
  | `PRISM_USER_ID` | No | Multi-tenant user isolation (default: `"default"`) |
1150
- | `PRISM_AUTO_CAPTURE` | No | Set `"true"` to auto-capture HTML snapshots of dev servers |
1151
- | `PRISM_CAPTURE_PORTS` | No | Comma-separated ports to scan (default: `3000,3001,5173,8080`) |
1152
- | `PRISM_DEBUG_LOGGING` | No | Set `"true"` to enable verbose debug logs (default: quiet) |
1153
- | `PRISM_DASHBOARD_PORT` | No | Configure the dashboard port (default: `3000`) |
1154
-
1155
- ---
1156
-
1157
- ## โšก Boot Settings (Restart Required)
1158
-
1159
- Some settings affect how Prism **initializes at startup** and cannot be changed at runtime. Prism stores these in a lightweight, dedicated SQLite database (`~/.prism-mcp/prism-config.db`) that is read **before** the main storage backend is selected โ€” solving the chicken-and-egg problem of needing config before the config store is ready.
1160
-
1161
- > **โš ๏ธ You must restart the Prism MCP server after changing any Boot Setting.** The Mind Palace dashboard labels these with a **"Restart Required"** badge.
1162
-
1163
- | Setting | Dashboard Control | Environment Override | Description |
1164
- |---------|------------------|---------------------|-------------|
1165
- | `PRISM_STORAGE` | โš™๏ธ Storage Backend dropdown | `PRISM_STORAGE=supabase` | Switch between `local` (SQLite) and `supabase` (cloud) |
1166
- | `PRISM_ENABLE_HIVEMIND` | โš™๏ธ Hivemind Mode toggle | `PRISM_ENABLE_HIVEMIND=true` | Enable/disable multi-agent coordination tools |
1167
-
1168
- ### How Boot Settings Work
1169
-
1170
- 1. **Dashboard saves the setting** โ†’ written to `~/.prism-mcp/prism-config.db` immediately
1171
- 2. **You restart the MCP server** โ†’ server reads the config DB at startup, selects backend/features
1172
- 3. **Environment variables always win** โ†’ if `PRISM_STORAGE` is set in your MCP config JSON, it overrides the dashboard value
1173
-
1174
- ```
1175
- Priority: env var in MCP config JSON > Dashboard (prism-config.db) > default (local)
1176
- ```
1177
-
1178
- ### Runtime Settings (no restart needed)
1179
-
1180
- These settings take effect immediately without a restart:
1181
-
1182
- | Setting | Description |
1183
- |---------|-------------|
1184
- | Dashboard Theme | Visual theme for the Mind Palace (`dark`, `midnight`, `purple`) |
1185
- | Context Depth | Default level for `session_load_context` (`quick`, `standard`, `deep`) |
1186
- | Auto-Capture HTML | Snapshot local dev server HTML on every handoff save |
1187
-
1188
- ---
1189
-
1190
- ## Progressive Context Loading
1191
-
1192
- Load only what you need โ€” saves tokens and speeds up boot:
1193
-
1194
- | Level | What You Get | Size | When to Use |
1195
- |-------|-------------|------|-------------|
1196
- | **quick** | Open TODOs + keywords | ~50 tokens | Fast check-in: "what was I working on?" |
1197
- | **standard** | Above + summary + recent decisions + knowledge cache + Git drift | ~200 tokens | **Recommended default** |
1198
- | **deep** | Above + full logs (last 5 sessions) + cross-project knowledge | ~1000+ tokens | After a long break or when you need complete history |
1199
-
1200
- ### Morning Briefing (Automatic)
1201
-
1202
- If it's been more than 4 hours since your last session, Prism automatically:
1203
- 1. Fetches the 10 most recent uncompacted ledger entries
1204
- 2. Sends a notification: *"๐ŸŒ… Brewing your Morning Briefing..."*
1205
- 3. Uses Gemini to synthesize a 3-bullet action plan
1206
- 4. Injects the briefing into the `session_load_context` response
1207
-
1208
- The agent boots up knowing exactly what to do โ€” zero prompting needed.
1209
-
1210
- ### Auto-Load on Session Start (Recommended)
1211
-
1212
- For the best experience, ensure your agent boots with full project memory on every new session. There are three approaches โ€” use whichever fits your workflow:
1213
-
1214
- #### Option A: Dashboard Setting (Easiest)
1215
-
1216
- Open the **Mind Palace Dashboard** (โš™๏ธ Settings) and type your project names into the **Auto-Load Projects** field under Boot Settings:
1217
-
1218
- ```
1219
- prism-mcp, my-app
1220
- ```
1221
-
1222
- That's it. Restart your AI client and Prism auto-pushes context for each listed project on next boot.
1223
-
1224
- #### Option B: Client-Side Hooks / Rules
1225
-
1226
- For clients that support lifecycle hooks or startup rules, instruct the AI to **call `session_load_context` as a tool** at session start:
1227
-
1228
- - **[Claude Code Integration (Hooks)](#claude-code-integration-hooks)** โ€” `SessionStart` and `Stop` hook JSON samples for `~/.claude/settings.json`
1229
- - **[Gemini / Antigravity Integration](#gemini--antigravity-integration)** โ€” global rules for `~/.gemini/GEMINI.md` or user rules
1230
-
1231
- > **You can use both approaches together.** The dashboard auto-load (A) injects project names into the `session_load_context` tool description โ€” works universally across all MCP clients. Client-side hooks (B) give the AI full structured access to the context response (including version numbers for OCC).
1232
-
1233
- > **Key principle:** Never hardcode a `role` in your hooks or rules. Set your role once in the **Mind Palace Dashboard โš™๏ธ Settings โ†’ Agent Identity**, and Prism automatically resolves it for every tool call across all clients. See [Role Resolution](#role-resolution--no-hardcoding-needed).
1234
-
1235
- > **Tip:** Replace `my-project` with your actual project identifiers. You can list as many projects as you need โ€” each one gets its own independent memory timeline.
1236
-
1237
- ---
1238
-
1239
- ## Time Travel (Version History)
1240
-
1241
- Every successful handoff save creates a snapshot. You can browse and revert any version:
1242
-
1243
- ```
1244
- v1 โ†’ v2 โ†’ v3 โ†’ v4 (current)
1245
- โ†‘
1246
- memory_checkout(v2) โ†’ creates v5 with v2's content
1247
- ```
1248
-
1249
- This is a **non-destructive revert** โ€” like `git revert`, not `git reset`. No history is ever lost.
1250
-
1251
- ### Usage
1252
-
1253
- ```json
1254
- // Browse all versions
1255
- { "name": "memory_history", "arguments": { "project": "my-app" } }
542
+ | `PRISM_AUTO_CAPTURE` | No | `"true"` to auto-snapshot dev servers |
543
+ | `PRISM_CAPTURE_PORTS` | No | Comma-separated ports (default: `3000,3001,5173,8080`) |
544
+ | `PRISM_DEBUG_LOGGING` | No | `"true"` for verbose logs |
545
+ | `PRISM_DASHBOARD_PORT` | No | Dashboard port (default: `3000`) |
1256
546
 
1257
- // Revert to version 2
1258
- { "name": "memory_checkout", "arguments": { "project": "my-app", "version": 2 } }
1259
- ```
1260
-
1261
- ---
1262
-
1263
- ## Agent Telepathy (Multi-Client Sync)
1264
-
1265
- When Agent A (Cursor) saves a handoff, Agent B (Claude Desktop) gets notified instantly:
1266
-
1267
- - **Local Mode:** File-based IPC via SQLite polling
1268
- - **Cloud Mode:** Supabase Realtime (Postgres CDC)
1269
-
1270
- No configuration needed โ€” it just works.
547
+ </details>
1271
548
 
1272
549
  ---
1273
550
 
1274
- ## Reality Drift Detection
551
+ ## Architecture
1275
552
 
1276
- Prism captures Git state (branch + commit SHA) on every handoff save. When the agent loads context, it compares the saved state against the current working directory:
553
+ <details>
554
+ <summary><strong>Three-Tier Memory Architecture</strong></summary>
1277
555
 
1278
556
  ```
1279
- โš ๏ธ REALITY DRIFT DETECTED for "my-app":
1280
- Branch changed: feature/auth โ†’ main
1281
- Commit changed: abc1234 โ†’ def5678
1282
-
1283
- The codebase has been modified since your last session.
1284
- Re-examine before making assumptions.
1285
- ```
1286
-
1287
- This prevents the agent from writing code based on stale context.
1288
-
1289
- ---
1290
-
1291
- ## Visual Memory & Auto-Capture
557
+ searchMemory() flow:
1292
558
 
1293
- ### Manual: Save Screenshots
559
+ Tier 0: FTS5 keywords โ†’ Full-text search (knowledge_search)
560
+ Tier 1: float32 (3072B) โ†’ sqlite-vec cosine similarity (native)
561
+ Tier 2: turbo4 (400B) โ†’ JS asymmetricCosineSimilarity (fallback)
1294
562
 
1295
- ```json
1296
- { "name": "session_save_image", "arguments": {
1297
- "project": "my-app",
1298
- "image_path": "/path/to/screenshot.png",
1299
- "description": "Login page after CSS fix"
1300
- }}
563
+ โ†’ Tier 1 success โ†’ return results
564
+ โ†’ Tier 1 fail โ†’ Tier 2 success โ†’ return results
565
+ โ†’ Tier 2 fail โ†’ return []
1301
566
  ```
1302
567
 
1303
- ### Automatic: HTML Snapshots
568
+ Every `session_save_ledger` call generates both tiers automatically:
569
+ 1. Gemini generates float32 embedding (3,072 bytes)
570
+ 2. TurboQuant compresses to turbo4 blob (~400 bytes)
571
+ 3. Single atomic write stores both to the database
1304
572
 
1305
- Set `PRISM_AUTO_CAPTURE=true` and Prism silently captures your local dev server's HTML on every handoff save. Supported formats: PNG, JPG, WebP, GIF, SVG, HTML.
1306
-
1307
- ---
1308
-
1309
- ## Knowledge Accumulation
1310
-
1311
- Every `session_save_ledger` and `session_save_handoff` automatically extracts keywords using lightweight, in-process NLP (~0.020ms/call). No LLM calls, no external dependencies.
1312
-
1313
- **Example:** Saving *"Fixed Stripe webhook race condition using database-backed idempotency keys"* auto-extracts:
1314
- - **Keywords:** `stripe`, `webhook`, `race`, `condition`, `database`, `idempotency`
1315
- - **Categories:** `cat:debugging`, `cat:api-integration`
1316
-
1317
- ### Search Knowledge
573
+ | Metric | Before v5.0 | After v5.0 |
574
+ |--------|------------|------------|
575
+ | Storage per embedding | 3,072 bytes | ~400 bytes |
576
+ | Compression ratio | 1:1 | ~7.7:1 (4-bit) |
577
+ | Entries per GB | ~330K | ~2.5M |
1318
578
 
1319
- ```json
1320
- { "name": "knowledge_search", "arguments": {
1321
- "project": "ecommerce-api",
1322
- "category": "debugging",
1323
- "query": "Stripe webhook"
1324
- }}
1325
- ```
579
+ </details>
1326
580
 
1327
- ### Forget Bad Memories
581
+ <details>
582
+ <summary><strong>Progressive Context Loading</strong></summary>
1328
583
 
1329
- | Mode | Example | Effect |
1330
- |------|---------|--------|
1331
- | **By project** | `project: "old-app"` | Clear all knowledge |
1332
- | **By category** | `category: "debugging"` | Forget debugging entries only |
1333
- | **By age** | `older_than_days: 30` | Forget entries older than 30 days |
1334
- | **Dry run** | `dry_run: true` | Preview what would be deleted |
584
+ | Level | What You Get | Size | When to Use |
585
+ |-------|-------------|------|-------------|
586
+ | **quick** | Open TODOs + keywords | ~50 tokens | Fast check-in |
587
+ | **standard** | + summary + recent decisions + Git drift | ~200 tokens | **Recommended** |
588
+ | **deep** | + full logs (last 5 sessions) + cross-project knowledge | ~1000+ tokens | After a long break |
1335
589
 
1336
- ## GDPR Compliance
590
+ </details>
1337
591
 
1338
- ### GDPR-Compliant Deletion
592
+ <details>
593
+ <summary><strong>Role Resolution</strong></summary>
1339
594
 
1340
- Prism supports surgical, per-entry deletion for GDPR Article 17 compliance:
595
+ Prism resolves agent roles using a priority chain:
1341
596
 
1342
- ```json
1343
- // Soft delete (tombstone โ€” reversible, keeps audit trail)
1344
- { "name": "session_forget_memory", "arguments": {
1345
- "memory_id": "abc123",
1346
- "reason": "User requested data deletion"
1347
- }}
1348
-
1349
- // Hard delete (permanent โ€” irreversible)
1350
- { "name": "session_forget_memory", "arguments": {
1351
- "memory_id": "abc123",
1352
- "hard_delete": true
1353
- }}
1354
597
  ```
1355
-
1356
- **How it works:**
1357
- - **Soft delete** sets `deleted_at = NOW()` + `deleted_reason`. The entry stays in the DB for audit but is excluded from ALL search results (vector, FTS5, and context loading).
1358
- - **Hard delete** physically removes the row. FTS5 triggers auto-clean the full-text index.
1359
- - **Top-K Hole Prevention**: `deleted_at IS NULL` filtering happens INSIDE the SQL query, BEFORE the `LIMIT` clause โ€” so `LIMIT 5` always returns 5 live results, never fewer. *(A "Top-K Hole" occurs when deleted entries are filtered out after the vector search, causing fewer than K results to be returned. Prism avoids this by filtering inside SQL before the LIMIT.)*
1360
-
1361
- ### Article 17 โ€” Right to Erasure ("Right to be Forgotten")
1362
-
1363
- | Requirement | How Prism Satisfies It |
1364
- |-------------|----------------------|
1365
- | **Individual deletion** | `session_forget_memory` operates on a single `memory_id` โ€” the data subject can request deletion of *specific* memories, not just bulk wipes. |
1366
- | **Soft delete (audit trail)** | `deleted_at` + `deleted_reason` columns prove *when* and *why* data was deleted โ€” required for SOC2 audit logs. |
1367
- | **Hard delete (full erasure)** | `hard_delete: true` physically removes the row from the database. No tombstone, no trace. True erasure as required by Article 17(1). |
1368
- | **Justification logging** | The `reason` parameter captures the GDPR justification (e.g., `"User requested data deletion"`, `"Data retention policy expired"`). |
1369
-
1370
- ### Article 25 โ€” Data Protection by Design and by Default
1371
-
1372
- | Requirement | How Prism Satisfies It |
1373
- |-------------|----------------------|
1374
- | **Ownership guards** | `softDeleteLedger()` and `hardDeleteLedger()` verify `user_id` before executing. User A cannot delete User B's data. |
1375
- | **Database-level filtering** | `deleted_at IS NULL` is inside the SQL `WHERE` clause, *before* `LIMIT`. Soft-deleted data never leaks into search results โ€” not even accidentally. |
1376
- | **Default = safe** | The system defaults to soft delete (reversible). Hard delete requires an explicit `hard_delete: true` flag โ€” preventing accidental permanent data loss. |
1377
- | **Multi-tenant isolation** | `PRISM_USER_ID` environment variable ensures all operations are scoped to a single tenant. |
1378
-
1379
- ### Coverage Summary
1380
-
1381
- | GDPR Right | Status | Implementation |
1382
- |-----------|--------|----------------|
1383
- | Right to Erasure (Art. 17) | โœ… Implemented | `session_forget_memory` (soft + hard delete) |
1384
- | Data Protection by Design (Art. 25) | โœ… Implemented | Ownership guards, DB-level filtering, safe defaults |
1385
- | Audit Trail | โœ… Implemented | `deleted_at` + `deleted_reason` columns |
1386
- | User Isolation | โœ… Implemented | `user_id` verification on all delete operations |
1387
- | Right to Portability (Art. 20) | โœ… Implemented | `session_export_memory` โ€” ZIP export of JSON + Markdown, API keys redacted |
1388
- | Consent Management | โž– Out of scope | Application-layer responsibility |
1389
-
1390
- > **Note:** No software is "GDPR certified" on its own โ€” GDPR is an organizational compliance framework. Prism provides the technical controls that a DPO (Data Protection Officer) needs to satisfy the data deletion and privacy-by-design requirements.
1391
-
1392
- ---
1393
-
1394
- ## Observability & Tracing
1395
-
1396
- Prism MCP ships **two complementary tracing systems** serving different audiences:
1397
-
1398
- | | MemoryTrace | OpenTelemetry (OTel) |
1399
- |---|---|---|
1400
- | **Question answered** | Why was this memory returned? | What was the end-to-end latency? |
1401
- | **Output** | `content[1]` in MCP response | OTLP โ†’ Jaeger / Tempo / Zipkin |
1402
- | **Trigger** | `enable_trace: true` parameter | Every tool call, automatically |
1403
- | **Audience** | LLM / LangSmith orchestration | Developers debugging infrastructure |
1404
-
1405
- ### MemoryTrace (Phase 1 โ€” LLM Explainability)
1406
-
1407
- A zero-dependency tracing system built for MCP. Returns per-query latency breakdowns and result scoring metadata as a second `content` block โ€” keeping structured telemetry out of the LLM's context window.
1408
-
1409
- ```json
1410
- { "trace": { "strategy": "semantic", "latency": { "embedding_ms": 45, "storage_ms": 12, "total_ms": 57 }, "result_count": 3 } }
598
+ explicit tool argument โ†’ dashboard setting โ†’ "global" (default)
1411
599
  ```
1412
600
 
1413
- ### OpenTelemetry (Phase 2 โ€” Infrastructure Observability)
601
+ Set your role once in the Mind Palace Dashboard (โš™๏ธ Settings โ†’ Agent Identity) and it auto-applies to every session.
1414
602
 
1415
- Every MCP tool call emits a **4-tier span waterfall** to any OTLP-compatible collector:
603
+ Available roles: `dev`, `qa`, `pm`, `lead`, `security`, `ux`, `global`, or any custom string.
1416
604
 
1417
- ```
1418
- mcp.call_tool [e.g. session_save_image, ~50 ms]
1419
- โ””โ”€ worker.vlm_caption [~2โ€“5 s, outlives parent โœ“]
1420
- โ””โ”€ llm.generate_image_description [~1โ€“4 s]
1421
- โ””โ”€ llm.generate_embedding [~200 ms]
1422
- ```
1423
-
1424
- **Quick-start with Jaeger:**
605
+ </details>
1425
606
 
1426
- ```bash
1427
- docker run -d -p 4318:4318 -p 16686:16686 jaegertracing/all-in-one
607
+ <details>
608
+ <summary><strong>Project Structure</strong></summary>
609
+
610
+ ```
611
+ src/
612
+ โ”œโ”€โ”€ server.ts # MCP server core + tool routing
613
+ โ”œโ”€โ”€ config.ts # Environment management
614
+ โ”œโ”€โ”€ storage/
615
+ โ”‚ โ”œโ”€โ”€ interface.ts # StorageBackend abstraction
616
+ โ”‚ โ”œโ”€โ”€ sqlite.ts # SQLite local (libSQL + F32_BLOB)
617
+ โ”‚ โ”œโ”€โ”€ supabase.ts # Supabase cloud storage
618
+ โ”‚ โ””โ”€โ”€ configStorage.ts # Boot config micro-DB
619
+ โ”œโ”€โ”€ dashboard/
620
+ โ”‚ โ”œโ”€โ”€ server.ts # Dashboard HTTP server
621
+ โ”‚ โ””โ”€โ”€ ui.ts # Mind Palace glassmorphism UI
622
+ โ”œโ”€โ”€ tools/
623
+ โ”‚ โ”œโ”€โ”€ definitions.ts # Search & analysis schemas
624
+ โ”‚ โ”œโ”€โ”€ handlers.ts # Search & analysis handlers
625
+ โ”‚ โ”œโ”€โ”€ sessionMemoryDefinitions.ts
626
+ โ”‚ โ””โ”€โ”€ sessionMemoryHandlers.ts
627
+ โ””โ”€โ”€ utils/
628
+ โ”œโ”€โ”€ telemetry.ts # OTel singleton
629
+ โ”œโ”€โ”€ turboquant.ts # TurboQuant math core
630
+ โ”œโ”€โ”€ universalImporter.ts # Universal migration orchestrator
631
+ โ”œโ”€โ”€ migration/ # Format-specific adapters (Claude/Gemini/OpenAI)
632
+ โ”œโ”€โ”€ imageCaptioner.ts # VLM auto-caption pipeline
633
+ โ””โ”€โ”€ llm/adapters/ # Gemini, OpenAI, Anthropic, Ollama
1428
634
  ```
1429
635
 
1430
- Then open **Mind Palace Dashboard โ†’ โš™๏ธ Settings โ†’ ๐Ÿ”ญ Observability**, toggle OTel on, and restart. Open [localhost:16686](http://localhost:16686) to see traces.
1431
-
1432
- **GDPR-safe by design:** Span attributes capture only character counts and byte sizes โ€” never prompt content, vector embeddings, or base64 image data.
1433
-
1434
- | Setting | Default | Description |
1435
- |---------|---------|-------------|
1436
- | `otel_enabled` | `false` | Toggle OTel pipeline on/off (restart required) |
1437
- | `otel_endpoint` | `http://localhost:4318/v1/traces` | OTLP HTTP collector URL |
1438
- | `otel_service_name` | `prism-mcp-server` | Service label in trace UI |
1439
-
1440
-
1441
- ---
1442
-
1443
- ## Supabase Setup (Cloud Mode)
636
+ </details>
1444
637
 
1445
638
  <details>
1446
- <summary><strong>Step-by-step Supabase configuration</strong></summary>
1447
-
1448
- ### 1. Create a Supabase Project
1449
-
1450
- 1. Go to [supabase.com](https://supabase.com) and sign in (free tier works)
1451
- 2. Click **New Project** โ†’ choose a name and password โ†’ select a region
1452
- 3. Wait for provisioning (~30 seconds)
1453
-
1454
- ### 2. Apply Migrations
639
+ <summary><strong>Supabase Setup</strong></summary>
1455
640
 
1456
- In the SQL Editor, run the **bootstrap migration** first:
1457
- 1. [`supabase/migrations/015_session_memory.sql`](supabase/migrations/015_session_memory.sql)
1458
- 2. [`supabase/migrations/016_knowledge_accumulation.sql`](supabase/migrations/016_knowledge_accumulation.sql)
1459
- 3. [`supabase/migrations/027_auto_migration_infra.sql`](supabase/migrations/027_auto_migration_infra.sql) โ€” **enables auto-migrations** (see below)
641
+ 1. Create a Supabase project at [supabase.com](https://supabase.com)
642
+ 2. Run the migration SQL files from `supabase/migrations/` in order
643
+ 3. Set `PRISM_STORAGE=supabase`, `SUPABASE_URL`, and `SUPABASE_KEY` in your MCP config
644
+ 4. Prism auto-applies pending DDL migrations on startup via `prism_apply_ddl` RPC
1460
645
 
1461
- > **After applying migration 027**, all future schema changes are applied automatically on server startup โ€” no manual SQL required.
1462
-
1463
- ### 3. Get Credentials
646
+ </details>
1464
647
 
1465
- Go to **Settings โ†’ API** and copy:
1466
- - **Project URL** (e.g. `https://abcdefg.supabase.co`)
1467
- - **anon public** key (starts with `eyJ...`)
648
+ <details>
649
+ <summary><strong>LangChain / LangGraph Integration</strong></summary>
1468
650
 
1469
- ### 4. Configure
651
+ Prism includes Python adapters in `examples/langgraph-agent/`:
1470
652
 
1471
- Add these to your MCP client's configuration file (e.g., `claude_desktop_config.json` under `"env"`), or export them if running the server manually:
653
+ ```python
654
+ from langchain.retrievers import EnsembleRetriever
655
+ from prism_retriever import PrismMemoryRetriever, PrismKnowledgeRetriever
1472
656
 
1473
- ```bash
1474
- export SUPABASE_URL="https://your-project.supabase.co"
1475
- export SUPABASE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
1476
- export PRISM_STORAGE="supabase"
657
+ # Hybrid search: 70% semantic, 30% keyword
658
+ retriever = EnsembleRetriever(
659
+ retrievers=[PrismMemoryRetriever(...), PrismKnowledgeRetriever(...)],
660
+ weights=[0.7, 0.3],
661
+ )
1477
662
  ```
1478
663
 
1479
- > **Note:** Claude Desktop, Cursor, and other MCP clients spawn isolated processes โ€” terminal `export` commands won't be inherited. Always set env vars in the client's config JSON.
1480
-
1481
- ### Security
1482
-
1483
- 1. **Use the anon key** for MCP server config
1484
- 2. **Enable RLS** on both tables
1485
- 3. **Never commit** your `SUPABASE_KEY` to version control
664
+ Includes a full 5-node LangGraph research agent with MCP bridge and persistent memory.
1486
665
 
1487
666
  </details>
1488
667
 
1489
- ### Auto-Migrations (Supabase Cloud)
1490
-
1491
- Prism includes a zero-config auto-migration system for Supabase. Once the bootstrap migration (`027_auto_migration_infra.sql`) is applied, all future schema changes are applied automatically on server startup.
1492
-
1493
- **How it works:**
1494
-
1495
- 1. On startup, the migration runner checks each entry in `MIGRATIONS[]` (defined in `supabaseMigrations.ts`)
1496
- 2. For each migration, it calls `prism_apply_ddl(version, name, sql)` โ€” a `SECURITY DEFINER` RPC function
1497
- 3. The function checks `prism_schema_versions` โ€” if the version is already recorded, it's silently skipped (idempotent)
1498
- 4. If not applied, it executes the DDL and records the version number
1499
-
1500
- **Graceful degradation:** If `prism_apply_ddl()` doesn't exist (you haven't applied migration 027 yet), the runner logs a warning and continues โ€” the server still starts, but newer schema features may not be available.
1501
-
1502
- **Adding new migrations** โ€” just append to the `MIGRATIONS[]` array in `src/storage/supabaseMigrations.ts`:
1503
-
1504
- ```typescript
1505
- {
1506
- version: 28,
1507
- name: "my_new_feature",
1508
- sql: `ALTER TABLE session_ledger ADD COLUMN IF NOT EXISTS my_col TEXT;`,
1509
- }
1510
- ```
1511
-
1512
- All SQL must be idempotent (`IF NOT EXISTS` / `IF EXISTS` guards).
1513
-
1514
668
  ---
1515
669
 
1516
- ## Multi-Instance Support
670
+ ## Research Roadmap
1517
671
 
1518
- Run multiple Prism MCP servers side-by-side on the same machine without PID lock conflicts. This is useful when you have different MCP configurations (e.g., one for web search + memory, another for memory-only) running in different clients simultaneously.
672
+ Prism is evolving from smart session logging toward a **cognitive memory architecture** โ€” grounded in real research, not marketing.
1519
673
 
1520
- ### Configuration
674
+ | Phase | Feature | Inspired By | Status |
675
+ |-------|---------|-------------|--------|
676
+ | **v5.2** | Smart Consolidation โ€” extract principles, not just summaries | Neuroscience sleep consolidation | โœ… Shipped |
677
+ | **v5.2** | Ebbinghaus Importance Decay โ€” memories fade unless reinforced | Ebbinghaus forgetting curve | โœ… Shipped |
678
+ | **v5.2** | Context-Weighted Retrieval โ€” current work biases what surfaces | Contextual memory in cognitive science | โœ… Shipped |
679
+ | **v6.x** | Superposed Memory (SDM) โ€” O(1) retrieval via correlation | Kanerva's Sparse Distributed Memory (1988) | ๐Ÿ”ฌ Research |
680
+ | **v6.x** | Affect-Tagged Memory โ€” sentiment shapes what gets recalled | Affect-modulated retrieval (neuroscience) | ๐Ÿ”ฌ Research |
681
+ | **v7+** | Zero-Search Retrieval โ€” no index, no ANN, just ask the vector | Holographic Reduced Representations | ๐Ÿ”ญ Horizon |
1521
682
 
1522
- Set `PRISM_INSTANCE` to a unique name per server instance:
1523
-
1524
- ```json
1525
- {
1526
- "mcpServers": {
1527
- "prism-search": {
1528
- "command": "node",
1529
- "args": ["/path/to/prism/dist/server.js"],
1530
- "env": {
1531
- "PRISM_INSTANCE": "prism-search",
1532
- "BRAVE_API_KEY": "your-key"
1533
- }
1534
- },
1535
- "prism-memory": {
1536
- "command": "node",
1537
- "args": ["/path/to/prism/dist/server.js"],
1538
- "env": {
1539
- "PRISM_INSTANCE": "prism-memory"
1540
- }
1541
- }
1542
- }
1543
- }
1544
- ```
1545
-
1546
- ### How it works
1547
-
1548
- - Each instance gets its own PID file: `/tmp/prism-{PRISM_INSTANCE}.pid`
1549
- - Default instance name is `"default"` (backward compatible)
1550
- - Instances share the same SQLite database and Supabase backend โ€” only the process lock is isolated
1551
- - Graceful shutdown cleans up the instance's PID file
683
+ > Informed by LeCun's "Why AI Systems Don't Learn" (Dupoux, LeCun, Malik โ€” March 2026) and Kanerva's SDM.
1552
684
 
1553
685
  ---
1554
686
 
1555
- ## Hybrid Search Pipeline (Brave + Vertex AI)
687
+ ## Version History
1556
688
 
1557
689
  <details>
1558
- <summary><strong>Enterprise search with Vertex AI Discovery Engine</strong></summary>
1559
-
1560
- Prism can combine **real-time web search** (Brave) with **enterprise-curated search** (Vertex AI Discovery Engine) for a hybrid pipeline achieving **94% context reduction** and **~17K tokens saved per query**.
1561
-
1562
- | Metric | Brave (Web) | Discovery Engine | Hybrid |
1563
- |--------|------------|-----------------|--------|
1564
- | Avg latency | 220ms | 1,193ms | ~1.4s |
1565
- | Raw payload | 42.4 KB | 28.9 KB | 71.3 KB |
1566
- | Reduced payload | 3.0 KB | 1.2 KB | **4.2 KB** (94% reduction) |
1567
- | Token savings | ~10,103 | ~7,097 | **~17,200 / query** |
1568
-
1569
- See [`vertex-ai/`](vertex-ai/) for setup and benchmarks.
690
+ <summary><strong>Previous releases (v3.0 โ€” v5.0)</strong></summary>
691
+
692
+ - **v5.1** โ€” Knowledge Graph Editor, Deep Storage purge
693
+ - **v5.0** โ€” TurboQuant 10ร— embedding compression, three-tier search architecture
694
+ - **v4.6** โ€” OpenTelemetry distributed tracing (Jaeger, Grafana)
695
+ - **v4.5** โ€” VLM multimodal memory + GDPR Art. 20 ZIP export
696
+ - **v4.4** โ€” Pluggable LLM adapters (OpenAI, Anthropic, Gemini, Ollama)
697
+ - **v4.3** โ€” Knowledge Sync Rules (behavioral insights โ†’ IDE rules)
698
+ - **v4.2** โ€” Project repo registry + universal auto-load
699
+ - **v4.1** โ€” Auto-migration + multi-instance support
700
+ - **v4.0** โ€” Behavioral memory (corrections, importance, auto-decay)
701
+ - **v3.1** โ€” Memory lifecycle (TTL, auto-compaction, PKM export)
702
+ - **v3.0** โ€” Agent Hivemind (role-scoped memory, Telepathy sync)
703
+
704
+ See [CHANGELOG.md](CHANGELOG.md) for full details.
1570
705
 
1571
706
  </details>
1572
707
 
1573
708
  ---
1574
709
 
1575
- ## Project Structure
1576
-
1577
- ```
1578
- โ”œโ”€โ”€ src/
1579
- โ”‚ โ”œโ”€โ”€ server.ts # MCP server core + tool routing + lifecycle
1580
- โ”‚ โ”œโ”€โ”€ config.ts # Environment management
1581
- โ”‚ โ”œโ”€โ”€ storage/
1582
- โ”‚ โ”‚ โ”œโ”€โ”€ interface.ts # StorageBackend abstraction (+ GDPR delete methods)
1583
- โ”‚ โ”‚ โ”œโ”€โ”€ sqlite.ts # SQLite local storage (libSQL + F32_BLOB + deleted_at migration)
1584
- โ”‚ โ”‚ โ”œโ”€โ”€ supabase.ts # Supabase cloud storage (+ soft/hard delete)
1585
- โ”‚ โ”‚ โ”œโ”€โ”€ supabaseMigrations.ts # Auto-migration runner for Supabase DDL
1586
- โ”‚ โ”‚ โ”œโ”€โ”€ configStorage.ts # Boot config micro-DB (~/.prism-mcp/prism-config.db)
1587
- โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Backend factory (auto-selects based on PRISM_STORAGE)
1588
- โ”‚ โ”œโ”€โ”€ sync/
1589
- โ”‚ โ”‚ โ”œโ”€โ”€ interface.ts # SyncBus abstraction (Telepathy)
1590
- โ”‚ โ”‚ โ”œโ”€โ”€ localSync.ts # File-based IPC for local mode
1591
- โ”‚ โ”‚ โ”œโ”€โ”€ supabaseSync.ts # Supabase Realtime CDC for cloud mode
1592
- โ”‚ โ”‚ โ””โ”€โ”€ factory.ts # Auto-selects sync backend
1593
- โ”‚ โ”œโ”€โ”€ dashboard/
1594
- โ”‚ โ”‚ โ”œโ”€โ”€ server.ts # Dashboard HTTP server with port recovery
1595
- โ”‚ โ”‚ โ””โ”€โ”€ ui.ts # Mind Palace glassmorphism HTML template
1596
- โ”‚ โ”œโ”€โ”€ templates/
1597
- โ”‚ โ”‚ โ””โ”€โ”€ codeMode.ts # 8 pre-built QuickJS extraction templates
1598
- โ”‚ โ”œโ”€โ”€ tools/
1599
- โ”‚ โ”‚ โ”œโ”€โ”€ definitions.ts # Search & analysis tool schemas
1600
- โ”‚ โ”‚ โ”œโ”€โ”€ handlers.ts # Search & analysis handlers
1601
- โ”‚ โ”‚ โ”œโ”€โ”€ sessionMemoryDefinitions.ts # Memory tools + GDPR + tracing schemas
1602
- โ”‚ โ”‚ โ”œโ”€โ”€ sessionMemoryHandlers.ts # Memory handlers (OCC, GDPR, Tracing, Time Travel)
1603
- โ”‚ โ”‚ โ”œโ”€โ”€ compactionHandler.ts # Gemini-powered ledger compaction
1604
- โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Tool registration & re-exports
1605
- โ”‚ โ””โ”€โ”€ utils/
1606
- โ”‚ โ”œโ”€โ”€ telemetry.ts # OTel singleton โ€” NodeTracerProvider, BatchSpanProcessor, no-op mode
1607
- โ”‚ โ”œโ”€โ”€ tracing.ts # MemoryTrace types + factory (Phase 1 โ€” LLM explainability)
1608
- โ”‚ โ”œโ”€โ”€ imageCaptioner.ts # VLM auto-caption pipeline (v4.5) + worker.vlm_caption OTel span
1609
- โ”‚ โ”œโ”€โ”€ logger.ts # Debug logging (gated by PRISM_DEBUG_LOGGING)
1610
- โ”‚ โ”œโ”€โ”€ braveApi.ts # Brave Search REST client
1611
- โ”‚ โ”œโ”€โ”€ googleAi.ts # Gemini SDK wrapper
1612
- โ”‚ โ”œโ”€โ”€ executor.ts # QuickJS sandbox executor
1613
- โ”‚ โ”œโ”€โ”€ autoCapture.ts # Dev server HTML snapshot utility
1614
- โ”‚ โ”œโ”€โ”€ healthCheck.ts # Brain integrity engine + security scanner
1615
- โ”‚ โ”œโ”€โ”€ factMerger.ts # Async LLM contradiction resolution
1616
- โ”‚ โ”œโ”€โ”€ git.ts # Git state capture + drift detection
1617
- โ”‚ โ”œโ”€โ”€ embeddingApi.ts # Embedding generation
1618
- โ”‚ โ”œโ”€โ”€ keywordExtractor.ts # Zero-dependency NLP keyword extraction
1619
- โ”‚ โ””โ”€โ”€ llm/
1620
- โ”‚ โ”œโ”€โ”€ provider.ts # LLMProvider interface
1621
- โ”‚ โ”œโ”€โ”€ factory.ts # Provider factory โ€” composes + wraps in TracingLLMProvider
1622
- โ”‚ โ””โ”€โ”€ adapters/
1623
- โ”‚ โ”œโ”€โ”€ gemini.ts # Google Gemini adapter
1624
- โ”‚ โ”œโ”€โ”€ openai.ts # OpenAI adapter
1625
- โ”‚ โ”œโ”€โ”€ anthropic.ts # Anthropic Claude adapter
1626
- โ”‚ โ”œโ”€โ”€ ollama.ts # Ollama (local) adapter
1627
- โ”‚ โ””โ”€โ”€ traced.ts # TracingLLMProvider decorator (v4.6 OTel)
1628
- โ”œโ”€โ”€ examples/langgraph-agent/ # LangChain/LangGraph integration
1629
- โ”‚ โ”œโ”€โ”€ agent.py # 5-node LangGraph research agent
1630
- โ”‚ โ”œโ”€โ”€ mcp_client.py # MCP Bridge (call_tool + call_tool_raw)
1631
- โ”‚ โ”œโ”€โ”€ prism_retriever.py # PrismMemoryRetriever + PrismKnowledgeRetriever
1632
- โ”‚ โ”œโ”€โ”€ tools.py # Agent tools + GDPR forget_memory
1633
- โ”‚ โ””โ”€โ”€ demo_retriever.py # Standalone retriever demo
1634
- โ”œโ”€โ”€ supabase/migrations/ # Cloud mode SQL schemas + auto-migration bootstrap
1635
- โ”‚ โ””โ”€โ”€ 027_auto_migration_infra.sql # prism_apply_ddl() RPC + schema version tracking
1636
- โ”œโ”€โ”€ vertex-ai/ # Vertex AI hybrid search pipeline
1637
- โ”œโ”€โ”€ index.ts # Server entry point
1638
- โ””โ”€โ”€ package.json
1639
- ```
1640
-
1641
- ---
1642
-
1643
710
  ## ๐Ÿš€ Roadmap
1644
711
 
1645
- > **[View the full project board โ†’](https://github.com/users/dcostenco/projects/1/views/1)** | **[Full ROADMAP.md โ†’](ROADMAP.md)**
1646
-
1647
- ### โœ… v5.0 โ€” Quantized Agentic Memory (Shipped!)
1648
-
1649
- | Feature | Description |
1650
- |---|---|
1651
- | ๐Ÿงฎ **TurboQuant Math Core** | Pure TypeScript port of Google's TurboQuant (ICLR 2026) โ€” Lloyd-Max codebook, QR rotation, QJL error correction. Zero dependencies. [RFC-001](docs/rfcs/001-turboquant-integration.md) |
1652
- | ๐Ÿ“ฆ **~7ร— Embedding Compression** | 768-dim embeddings shrink from 3,072 bytes to ~400 bytes (4-bit) via variable bit-packing. |
1653
- | ๐Ÿ” **Asymmetric Similarity** | Unbiased inner product estimator: query as float32 vs compressed blobs. No decompression needed. |
1654
- | ๐Ÿ—„๏ธ **Two-Tier Search** | FTS5 candidate filter โ†’ JS-side asymmetric scoring. Bypasses sqlite-vec float32 limitation. |
1655
-
1656
- ### โœ… v5.1 โ€” Deep Storage Mode (Shipped!)
1657
-
1658
- | Feature | Description |
1659
- |---|---|
1660
- | ๐Ÿงฌ **Deep Storage Purge** | Automated `deep_storage_purge` tool NULLs out redundant float32 embeddings for entries with TurboQuant compressed blobs, reclaiming ~90% of vector storage. |
1661
- | ๐Ÿ›ก๏ธ **Safety Guards** | Minimum 7-day age threshold, dry-run preview mode, multi-tenant isolation, and compressed-blob-existence validation ensure zero data loss. |
1662
- | ๐Ÿ—ƒ๏ธ **Supabase RPC** | `prism_purge_embeddings` Postgres function (migration 030) provides full backend parity with SQLite. Auto-applied via the v4.1 migration runner. |
1663
- | ๐Ÿงช **303 Tests** | 8 new deep-storage test cases covering dry run, execute, safety guards, and idempotency โ€” zero regressions across the full suite. |
1664
-
1665
- ### โœ… v4.6 โ€” OpenTelemetry Observability (Shipped!)
1666
-
1667
- | Feature | Description |
1668
- |---|---|
1669
- | ๐Ÿ”ญ **OTel Root Span** | Every MCP tool call wrapped in `mcp.call_tool` span โ€” propagated to all child async operations via AsyncLocalStorage. |
1670
- | ๐ŸŽจ **TracingLLMProvider** | Decorator pattern wraps the composed LLM factory. Zero changes to vendor adapters. Instruments `generate_text`, `generate_embedding`, `generate_image_description`. |
1671
- | โš™๏ธ **Worker Spans** | `worker.vlm_caption` span in `imageCaptioner` correctly parents fire-and-forget async tasks to the root span. |
1672
- | ๐Ÿ”’ **Shutdown Flush** | `shutdownTelemetry()` wired as step-0 in `lifecycle.ts` โ€” flushes `BatchSpanProcessor` before DB closes on SIGTERM. |
1673
- | ๐Ÿ–ฅ๏ธ **Dashboard UI** | New ๐Ÿ”ญ Observability tab with enable toggle, OTLP endpoint, service name, inline Jaeger docker command, and ASCII waterfall diagram. |
1674
-
1675
- ### โœ… v4.5 โ€” VLM Multimodal Memory & GDPR Export (Shipped!)
1676
-
1677
- | Feature | Description |
1678
- |---|---|
1679
- | ๐Ÿ‘๏ธ **Auto-Captioning** | `session_save_image` โ†’ VLM โ†’ ledger entry โ†’ vector embedding. Images become semantically searchable with zero schema changes. |
1680
- | ๐Ÿ“ฆ **GDPR Art. 20** | `session_export_memory` โ€” full ZIP export (JSON + Markdown), API keys redacted, embeddings stripped. |
1681
- | ๐Ÿงช **270 tests** | Full regression coverage including concurrent safety, redaction edge cases, and MCP contract validation. |
1682
-
1683
- ### โœ… v4.4 โ€” Pluggable LLM Adapters (Shipped!)
1684
-
1685
- | Feature | Description |
1686
- |---|---|
1687
- | ๐Ÿ”Œ **BYOM** | OpenAI, Anthropic, Gemini, Ollama adapters. Text + embedding providers independently configurable. |
1688
- | ๐Ÿ›ก๏ธ **Air-Gapped** | Full local mode via Ollama โ€” zero cloud API keys required. |
1689
-
1690
- ### โœ… v4.3 โ€” The Bridge: Knowledge Sync Rules (Shipped!)
1691
-
1692
- See [What's in v4.3.0](#whats-new-in-v430--the-bridge-) above โ€” syncing dynamic behavioral insights to static IDE rules files.
1693
-
1694
- ### โœ… v4.2 โ€” Project Repo Registry (Shipped!)
1695
-
1696
- | Feature | Description |
1697
- |---|---|
1698
- | ๐Ÿ—‚๏ธ **Project Repo Paths** | Dashboard UI to map projects to repo directories + `session_save_ledger` path validation. |
1699
- | ๐Ÿ”„ **Universal Auto-Load** | Dynamic tool descriptions replace env var โ€” dashboard is sole source of truth. |
1700
-
1701
- ### โœ… v4.1 โ€” Auto-Migration & Multi-Instance (Shipped!)
1702
-
1703
- See [What's in v4.1.0](#whats-in-v410--auto-migration--multi-instance-) above.
1704
-
1705
- ### โœ… v4.0 โ€” Behavioral Memory (Shipped!)
1706
-
1707
- See [What's in v4.0.0](#whats-in-v400--behavioral-memory-) above.
1708
-
1709
- ### โœ… v3.x โ€” Memory Lifecycle & Agent Hivemind (Shipped!)
712
+ > **[Full ROADMAP.md โ†’](ROADMAP.md)**
1710
713
 
1711
- See [v3.1.0](#whats-in-v310--memory-lifecycle-) and [v3.0.0](#whats-in-v300--agent-hivemind-) above.
714
+ **Next (v5.3):**
715
+ - ๐Ÿ”„ CRDT Handoff Merging โ€” conflict-free concurrent multi-agent edits
716
+ - โฐ Background Purge Scheduler โ€” automated storage reclamation
717
+ - ๐Ÿ“ฑ Mind Palace Mobile PWA โ€” offline-first responsive dashboard
718
+ - ๐ŸŒ Autonomous Web Scholar โ€” agent-driven research pipeline
1712
719
 
1713
720
  ---
1714
721
 
1715
- ### ๐Ÿ—บ๏ธ Next on the Horizon
722
+ ## โš ๏ธ Limitations
1716
723
 
1717
- | Priority | Feature | Description |
1718
- |----------|---------|-------------|
1719
- | โœ… | **Documentation & Architecture Guide** | [Architecture Guide](docs/ARCHITECTURE.md), [Self-Improving Agent Guide](docs/self-improving-agent.md), updated README diagram with v5.x vector tiers. |
1720
- | โœ… | **Knowledge Graph Editor** | Interactive vis.js graph with click-to-filter, node stats, project/keyword/category visualization. |
1721
- | ๐Ÿฅ‰ | **Autonomous Web Scholar** | Agent-driven learning pipeline using Brave Search + VLM to autonomously build project context while the developer sleeps. |
1722
- | โœ… | **Dashboard Auth** | HTTP Basic Auth with session cookies, timing-safe comparison, styled login page. Set `PRISM_DASHBOARD_USER`/`PRISM_DASHBOARD_PASS`. |
1723
- | โœ… | **TypeScript LangGraph Examples** | [Reference agent](examples/langgraph-ts/) with MCP client, memory retriever nodes, and session persistence. |
1724
- | โ€” | **CRDT Conflict Resolution** | Conflict-free types for concurrent multi-agent edits on the same handoff. |
724
+ - **LLM-dependent features require an API key.** Semantic search, Morning Briefings, auto-compaction, and VLM captioning need a `GOOGLE_API_KEY` (Gemini) or equivalent provider key. Without one, Prism falls back to keyword-only search (FTS5).
725
+ - **Auto-load is model-dependent.** Session auto-loading relies on the LLM following system prompt instructions. Some models (especially Gemini) intermittently hallucinate that MCP tools are "unavailable." See the [Gemini/Antigravity setup guide](#gemini--antigravity--auto-load-rules-battle-tested) for workarounds.
726
+ - **No real-time sync without Supabase.** Local SQLite mode is single-machine only. Multi-device or team sync requires a Supabase backend.
727
+ - **Embedding quality varies by provider.** Gemini `text-embedding-004` and OpenAI `text-embedding-3-small` produce high-quality 768-dim vectors. Ollama embeddings (e.g., `nomic-embed-text`) are usable but may reduce retrieval accuracy.
728
+ - **Dashboard is HTTP-only.** The Mind Palace dashboard at `localhost:3000` does not support HTTPS. For remote access, use a reverse proxy (nginx/Caddy) or SSH tunnel. Basic auth is available via `PRISM_DASHBOARD_USER` / `PRISM_DASHBOARD_PASS`.
729
+ - **Migration is one-way.** Universal History Migration imports sessions *into* Prism but does not export back to Claude/Gemini/OpenAI formats. Use `session_export_memory` for portable JSON/Markdown export.
730
+ - **No Windows CI testing.** Prism is developed and tested on macOS/Linux. It should work on Windows via Node.js, but edge cases (file paths, PID locks) may surface.
1725
731
 
1726
732
  ---
1727
733
 
@@ -1731,4 +737,4 @@ MIT
1731
737
 
1732
738
  ---
1733
739
 
1734
- <sub>**Keywords:** MCP server, Model Context Protocol, Claude Desktop memory, persistent session memory, AI agent memory, local-first, SQLite MCP, Mind Palace, time travel, visual memory, VLM image captioning, OpenTelemetry OTel tracing, Jaeger distributed traces, GDPR export portability, agent telepathy, multi-agent sync, behavioral memory, IDE rules sync, cursorrules, pluggable LLM, Ollama MCP, Anthropic Claude MCP, OpenAI MCP, reality drift detection, morning briefing, code mode templates, cursor MCP server, windsurf MCP server, cline MCP server, pgvector semantic search, progressive context loading, MCP Prompts, MCP Resources, knowledge management AI, Brave Search MCP, Gemini analysis, optimistic concurrency control, zero config, memory tracing, LangChain retriever, LangGraph agent, soft delete, memory lineage, explainability, enterprise AI memory</sub>
740
+ <sub>**Keywords:** MCP server, Model Context Protocol, Claude Desktop memory, persistent session memory, AI agent memory, local-first, SQLite MCP, Mind Palace, time travel, visual memory, VLM image captioning, OpenTelemetry, GDPR, agent telepathy, multi-agent sync, behavioral memory, cursorrules, Ollama MCP, Brave Search MCP, TurboQuant, progressive context loading, knowledge management, LangChain retriever, LangGraph agent</sub>