prism-mcp-server 5.2.1 → 5.5.0

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
@@ -18,6 +18,23 @@ npx -y prism-mcp-server
18
18
 
19
19
  Works with **Claude Desktop · Claude Code · Cursor · Windsurf · Cline · Gemini · Antigravity** — any MCP client.
20
20
 
21
+ ## 📖 Table of Contents
22
+
23
+ - [Why Prism?](#why-prism)
24
+ - [Quick Start](#-quick-start)
25
+ - [Setup Guides](#-setup-guides)
26
+ - [What Makes Prism Different](#-what-makes-prism-different)
27
+ - [Use Cases](#-use-cases)
28
+ - [What's New](#-whats-new)
29
+ - [Autonomous Web Scholar](#-autonomous-web-scholar)
30
+ - [How Prism Compares](#how-prism-compares)
31
+ - [Tool Reference](#-tool-reference)
32
+ - [Environment Variables](#environment-variables)
33
+ - [Architecture](#architecture)
34
+ - [Research Roadmap](#research-roadmap)
35
+ - [Roadmap](#-roadmap)
36
+ - [Limitations](#-limitations)
37
+
21
38
  ---
22
39
 
23
40
  ## Why Prism?
@@ -28,81 +45,9 @@ Every time you start a new conversation with an AI coding assistant, it starts f
28
45
 
29
46
  ---
30
47
 
31
- ## ✨ What Makes Prism Different
32
-
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.
35
-
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.
38
-
39
- ### 🔮 Mind Palace Dashboard
40
- A gorgeous glassmorphism UI at `localhost:3000` that lets you see exactly what your agent is thinking:
41
-
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
51
-
52
- ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
53
-
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.
56
-
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.
59
-
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.
62
-
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.
65
-
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.
68
-
69
- ---
70
-
71
- ## 🎯 Use Cases
72
-
73
- **Long-running feature work** — Save state at end of day, restore full context next morning. No re-explaining.
74
-
75
- **Multi-agent collaboration** — Dev, QA, and PM agents share real-time context without stepping on each other's memory.
76
-
77
- **Consulting / multi-project** — Switch between client projects with progressive loading: `quick` (~50 tokens), `standard` (~200), or `deep` (~1000+).
78
-
79
- **Visual debugging** — Save UI screenshots to searchable memory. Find that CSS bug from last week by description.
80
-
81
- **Team onboarding** — New team member's agent loads the full project history instantly.
82
-
83
- **Behavior enforcement** — Agent corrections auto-graduate into permanent `.cursorrules` / `.clauderules` rules.
84
-
85
- **Offline / air-gapped** — Full SQLite local mode + Ollama LLM adapter. Zero internet dependency.
86
-
87
- **Morning Briefings** — After 4+ hours away, Prism auto-synthesizes a 3-bullet action plan from your last sessions.
88
-
89
- ---
90
-
91
- ## 🆕 What's New in v5.2
92
-
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.
99
-
100
- > [Full CHANGELOG →](CHANGELOG.md) · [Architecture Deep Dive →](docs/ARCHITECTURE.md)
101
-
102
- ---
103
-
104
48
  ## 🚀 Quick Start
105
49
 
50
+
106
51
  Add to your MCP client config (`claude_desktop_config.json`, `.cursor/mcp.json`, etc.):
107
52
 
108
53
  ```json
@@ -118,7 +63,7 @@ Add to your MCP client config (`claude_desktop_config.json`, `.cursor/mcp.json`,
118
63
 
119
64
  **That's it.** Restart your client. All 30+ tools are available. Dashboard at `http://localhost:3000`.
120
65
 
121
- > **Optional API keys:** `GOOGLE_API_KEY` for semantic search + Morning Briefings, `BRAVE_API_KEY` for web search. See [Environment Variables](#environment-variables).
66
+ > 🔑 **API Key Requirements:** Need semantic search, Morning Briefings, or auto-compaction? Provide a `GOOGLE_API_KEY` (Gemini) or equivalent. Want Web Scholar to search the live internet? Provide a `BRAVE_API_KEY`. Without keys, Prism still works but falls back to local keyword search (FTS5). See [Environment Variables](#environment-variables).
122
67
 
123
68
  ---
124
69
 
@@ -200,10 +145,12 @@ Add to your Continue `config.json` or Cline MCP settings:
200
145
 
201
146
  </details>
202
147
 
148
+ #### Migration
149
+
203
150
  <details>
204
151
  <summary><strong>Migrating Existing History (Claude, Gemini, OpenAI)</strong></summary>
205
152
 
206
- Prism can ingest months of historical sessions from other tools to give your Mind Palace a massive head start.
153
+ Prism can ingest months of historical sessions from other tools to give your Mind Palace a massive head start. Import via the **CLI** or directly from the [Mind Palace Dashboard](#-mind-palace-dashboard) Import tab (file picker + manual path + dry-run toggle).
207
154
 
208
155
  ### Supported Formats
209
156
  * **Claude Code** (`.jsonl` logs) — Automatically handles streaming chunk deduplication and `requestId` normalization.
@@ -211,7 +158,8 @@ Prism can ingest months of historical sessions from other tools to give your Min
211
158
  * **OpenAI** (JSON chat completion history) — Normalizes disparate tool-call structures into the unified Ledger schema.
212
159
 
213
160
  ### How to Run
214
- Use the `universal-import` command:
161
+
162
+ **Option 1 — CLI:**
215
163
 
216
164
  ```bash
217
165
  # Ingest Claude Code history
@@ -221,8 +169,11 @@ npx -y prism-mcp-server universal-import --format claude --path ~/path/to/claude
221
169
  npx -y prism-mcp-server universal-import --format gemini --path ./gemini_history.json --dry-run
222
170
  ```
223
171
 
172
+ **Option 2 — Dashboard:** Open `localhost:3000`, navigate to the **Import** tab, select the format and file, and click Import. Supports dry-run preview. See the [dashboard screenshot](#-mind-palace-dashboard) above.
173
+
224
174
  ### Key Features
225
175
  * **OOM-Safe Streaming:** Processes massive log files line-by-line using `stream-json`.
176
+ * **Idempotent Dedup:** Content-hash prevents duplicate imports on re-run (`skipCount` reported).
226
177
  * **Chronological Integrity:** Uses timestamp fallbacks and `requestId` sorting to ensure your memory timeline is accurate.
227
178
  * **Smart Context Mapping:** Extracts `cwd`, `gitBranch`, and tool usage patterns into searchable metadata.
228
179
 
@@ -304,43 +255,76 @@ if __name__ == "__main__":
304
255
 
305
256
  </details>
306
257
 
307
- <details>
308
- <summary><strong>Gemini / Antigravity — Auto-Load Rules (Battle-Tested)</strong></summary>
258
+ <details id="antigravity-auto-load">
259
+ <summary><strong>Gemini / Antigravity — Three-Layer Auto-Load (Battle-Tested)</strong></summary>
309
260
 
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.
261
+ Gemini-based agents (including Google's Antigravity IDE) use a **three-layer architecture** for reliable auto-load, proven over **14+ iterations** of prompt engineering (March 2026).
311
262
 
312
- ### The Core Problem
263
+ ### Architecture
313
264
 
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.
265
+ | Layer | File | Purpose |
266
+ |-------|------|---------|
267
+ | **1. User Rules** | `~/.gemini/GEMINI.md` | Slim ~10-line directive injected verbatim into system prompt |
268
+ | **2. Cross-Tool Rules** | `~/.gemini/AGENTS.md` | Reinforcement for multi-client setups (Antigravity + Cursor) |
269
+ | **3. Skill** | `.agent/skills/prism-startup/SKILL.md` | Full startup procedure with greeting detection and context echo |
270
+ | **Server Fallback** | Built into `server.ts` (v5.2.1) | Deferred auto-push via `sendLoggingMessage` if model doesn't comply within 10s |
315
271
 
316
- ### The 2-Line Rule (Proven Fix)
272
+ ### Layer 1: User Rules
317
273
 
318
274
  Create `~/.gemini/GEMINI.md`:
319
275
 
320
276
  ```markdown
321
- ## First Action
322
- Call `mcp_prism-mcp_session_load_context(project="my-project", level="deep")` before responding.
323
- ```
277
+ # Startup — MANDATORY
324
278
 
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
279
+ Your first action in every conversation is a tool call. Zero text before it.
329
280
 
330
- ### Antigravity UI Caveat
281
+ Tool: mcp_prism-mcp_session_load_context
282
+ Args: project="my-project", level="deep"
283
+
284
+ After success: echo agent identity, last summary, open TODOs, session version.
285
+ If the call fails: say "Prism load failed — retrying" and try ONE more time.
286
+ ```
287
+
288
+ ### Layer 2: Cross-Tool Reinforcement
331
289
 
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:
290
+ Create `~/.gemini/AGENTS.md`:
333
291
 
334
292
  ```markdown
335
- ## Echo Context
336
- After loading context, include in your text reply:
337
- - Agent identity (role + name)
338
- - Last session summary
339
- - Open TODOs
340
- - Session version number
293
+ # Session Memory
294
+ Every conversation starts with: mcp_prism-mcp_session_load_context(project="my-project", level="deep")
295
+ Echo result: agent identity, TODOs, session version.
341
296
  ```
342
297
 
343
- This ensures the user sees their project context even though the raw MCP output is invisible.
298
+ ### Layer 3: Prism Startup Skill
299
+
300
+ Create `.agent/skills/prism-startup/SKILL.md` (or `.agents/skills/`) in your project or global config. This is a structured skill file that Antigravity loads with higher priority than plain rules. It includes:
301
+
302
+ - Greeting detection (fires on "hi", "hello", etc.)
303
+ - Full tool call instructions with error handling
304
+ - Context echo template (agent identity, TODOs, version)
305
+ - Startup block display
306
+
307
+ ### Server-Side Fallback (v5.2.1)
308
+
309
+ If the model ignores all three layers, Prism's server pushes context automatically:
310
+
311
+ 1. After storage warmup, a 10-second timer starts
312
+ 2. If `session_load_context` hasn't been called by then, the server pushes context via `sendLoggingMessage`
313
+ 3. If the client already called the tool, the push is silently skipped (zero impact on Claude CLI)
314
+
315
+ This ensures context is always available, even with non-compliant models.
316
+
317
+ ### Why This Architecture Works
318
+
319
+ - **Gemini uses single underscores** for MCP tools (`mcp_prism-mcp_...`) vs Claude's double underscores
320
+ - **Slim rules** (~10 lines) avoid triggering adversarial "tool not found" reasoning
321
+ - **Skills have dedicated 3-level loading** in Antigravity — higher compliance than plain rules
322
+ - **Server fallback** catches the remaining edge cases without affecting well-behaved clients
323
+ - **Positive "First Action" framing** outperforms negative constraint lists
324
+
325
+ ### Antigravity UI Caveat
326
+
327
+ Antigravity **does not visually render MCP tool output blocks** in the chat UI. The tool executes successfully, but the user sees nothing. All three layers instruct the agent to **echo context in its text reply**.
344
328
 
345
329
  ### Session End Workflow
346
330
 
@@ -349,17 +333,7 @@ Tell the agent: *"Wrap up the session."* It should execute:
349
333
  1. `session_save_ledger` — append immutable work log (summary, decisions, files changed)
350
334
  2. `session_save_handoff` — upsert project state with `expected_version` for OCC
351
335
 
352
- > **Tip:** Include the session-end instructions in your `GEMINI.md` or ask the agent to save when you're done.
353
-
354
- ### Key Findings from 14 Iterations
355
-
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 |
336
+ > **Tip:** Include session-end instructions in your `GEMINI.md` or ask the agent to save when you're done.
363
337
 
364
338
  ### Platform Gotchas
365
339
 
@@ -423,6 +397,101 @@ Then add to your MCP config:
423
397
 
424
398
  ---
425
399
 
400
+ ## ✨ What Makes Prism Different
401
+
402
+ ### 🧠 Your Agent Learns From Mistakes
403
+ 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.
404
+
405
+ ### 🕰️ Time Travel
406
+ 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.
407
+
408
+ ### 🔮 Mind Palace Dashboard
409
+ A gorgeous glassmorphism UI at `localhost:3000` that lets you see exactly what your agent is thinking:
410
+
411
+ - **Current State & TODOs** — the exact context injected into the LLM's prompt
412
+ - **Interactive Knowledge Graph** — force-directed neural graph with click-to-filter, node renaming, and surgical keyword deletion *(v5.1)*
413
+ - **Deep Storage Manager** — preview and execute vector purge operations with dry-run safety *(v5.1)*
414
+ - **Session Ledger** — full audit trail of every decision your agent has made
415
+ - **Time Travel Timeline** — browse and revert any historical handoff version
416
+ - **Visual Memory Vault** — browse VLM-captioned screenshots and auto-captured HTML states
417
+ - **Hivemind Radar** — real-time active agent roster with role, task, and heartbeat
418
+ - **Morning Briefing** — AI-synthesized action plan after 4+ hours away
419
+ - **Brain Health** — memory integrity scan with one-click auto-repair
420
+
421
+ ![Mind Palace Dashboard](docs/mind-palace-dashboard.png)
422
+
423
+ ### 🧬 10× Memory Compression
424
+ 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.
425
+
426
+ ### 🐝 Multi-Agent Hivemind
427
+ 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.
428
+
429
+ ### 🖼️ Visual Memory
430
+ 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.
431
+
432
+ ### 🔭 Full Observability
433
+ 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.
434
+
435
+ ## 🌐 Autonomous Web Scholar
436
+ Prism researches while you sleep. A background pipeline searches the web, scrapes articles, synthesizes findings via LLM, and injects results directly into your semantic memory — fully searchable on your next session. [Details below →](#-autonomous-web-scholar)
437
+
438
+ ### 🔒 GDPR Compliant
439
+ 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.
440
+
441
+ ---
442
+
443
+ ## 🎯 Use Cases
444
+
445
+ **Long-running feature work** — Save state at end of day, restore full context next morning. No re-explaining.
446
+
447
+ **Multi-agent collaboration** — Dev, QA, and PM agents share real-time context without stepping on each other's memory.
448
+
449
+ **Consulting / multi-project** — Switch between client projects with progressive loading: `quick` (~50 tokens), `standard` (~200), or `deep` (~1000+).
450
+
451
+ **Visual debugging** — Save UI screenshots to searchable memory. Find that CSS bug from last week by description.
452
+
453
+ **Team onboarding** — New team member's agent loads the full project history instantly.
454
+
455
+ **Behavior enforcement** — Agent corrections auto-graduate into permanent `.cursorrules` / `.clauderules` rules.
456
+
457
+ **Offline / air-gapped** — Full SQLite local mode + Ollama LLM adapter. Zero internet dependency.
458
+
459
+ **Morning Briefings** — After 4+ hours away, Prism auto-synthesizes a 3-bullet action plan from your last sessions.
460
+
461
+ ---
462
+
463
+ ## 🆕 What's New
464
+
465
+ ### v5.5 — Architectural Hardening ✅
466
+ > **Current stable release.** Zero-dependency, production-grade reliability improvements.
467
+
468
+ - 🛡️ **Transactional Migrations** — SQLite DDL rebuilds are wrapped in explicit `BEGIN/COMMIT` blocks. A crash mid-migration can no longer corrupt your schema or lose handoff state.
469
+ - 🛑 **Graceful Shutdown Registry** — `BackgroundTaskRegistry` uses a 5-second `Promise.race()` to await all in-flight flushes (embeddings, SDM writes, OTel spans) before the process exits. No more orphaned I/O.
470
+ - 🕰️ **Thundering Herd Prevention** — Maintenance scheduler migrated from `setInterval` to a state-aware recursive `setTimeout`. Expensive compaction routines can never stack on top of each other.
471
+ - 🚀 **Zero-Thrashing SDM Scans** — `Int32Array` scratchpad allocations hoisted outside the hot decode loop. Eliminates V8 GC pressure on large semantic memory banks.
472
+ - 🧪 **368 Tests** — Zero regressions across 17 test suites.
473
+
474
+ ### v5.4 — Convergent Intelligence
475
+ - 🔄 **CRDT Handoff Merging** — Multi-agent saves no longer reject on version conflict. Custom OR-Map engine auto-merges concurrent edits (Add-Wins for arrays, LWW for scalars).
476
+ - ⏰ **Background Purge Scheduler** — Fully automated storage maintenance: TTL sweep, Ebbinghaus importance decay, auto-compaction, and deep storage purge on a configurable interval.
477
+ - 🌐 **[Autonomous Web Scholar](#-autonomous-web-scholar)** — Agent-driven research pipeline. Brave Search → Firecrawl scrape → LLM synthesis → Prism ledger. Task-aware and Hivemind-integrated.
478
+ - 🐝 **Scholar ↔ Hivemind Integration** — Scholar registers on the Radar, emits heartbeats, and broadcasts Telepathy alerts on completion.
479
+
480
+ <details>
481
+ <summary><strong>Earlier releases (v5.3 and below)</strong></summary>
482
+
483
+ - **v5.3** — Hivemind Health Watchdog (state machine, loop detection, Telepathy alert injection)
484
+ - **v5.2** — Cognitive Memory (Ebbinghaus decay, context-weighted retrieval), Universal History Migration, Smart Consolidation
485
+ - **v5.1** — Knowledge Graph Editor, Deep Storage purge
486
+ - **v5.0** — TurboQuant 10× embedding compression, three-tier search architecture
487
+ - **v4.x** — OpenTelemetry, VLM multimodal memory, LLM adapters, Behavioral memory, Hivemind
488
+
489
+ </details>
490
+
491
+ > [Full CHANGELOG →](CHANGELOG.md) · [Architecture Deep Dive →](docs/ARCHITECTURE.md)
492
+
493
+ ---
494
+
426
495
  ## How Prism Compares
427
496
 
428
497
  **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)
@@ -433,9 +502,12 @@ Then add to your MCP config:
433
502
  - ✅ Behavioral memory — importance tracking, auto-decay, mistake learning
434
503
  - ✅ Visual dashboard — Mind Palace at localhost:3000
435
504
  - ✅ Multi-agent sync — role-isolated Hivemind with real-time Telepathy
505
+ - ✅ CRDT merging — conflict-free concurrent multi-agent edits
506
+ - ✅ Autonomous research — Web Scholar pipeline runs while you sleep
436
507
  - ✅ Visual memory — VLM-captioned screenshot vault
437
508
  - ✅ Token budgeting — `max_tokens` param on context loading
438
509
  - ✅ 10× vector compression — TurboQuant, no external vector DB
510
+ - ✅ Automated maintenance — background scheduler handles TTL, decay, compaction, purge
439
511
  - ✅ GDPR compliance — soft/hard delete, ZIP export, TTL retention
440
512
  - ✅ OpenTelemetry — full span tracing to Jaeger/Grafana
441
513
  - ✅ LangChain adapters — `BaseRetriever` integration + LangGraph examples
@@ -444,7 +516,7 @@ Then add to your MCP config:
444
516
  - ✅ IDE rules sync — graduated insights → `.cursorrules` / `.clauderules`
445
517
  - ✅ Air-gapped mode — SQLite + Ollama, zero internet needed
446
518
 
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.
519
+ > **TL;DR:** Prism is the only MCP memory server with time travel, behavioral learning, autonomous research, CRDT multi-agent sync, and 10× compression — all from a single `npx` command.
448
520
 
449
521
  ---
450
522
 
@@ -531,6 +603,7 @@ Requires `PRISM_ENABLE_HIVEMIND=true`.
531
603
  | Variable | Required | Description |
532
604
  |----------|----------|-------------|
533
605
  | `BRAVE_API_KEY` | No | Brave Search Pro API key |
606
+ | `FIRECRAWL_API_KEY` | No | Firecrawl API key — required for Web Scholar |
534
607
  | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` — restart required |
535
608
  | `PRISM_ENABLE_HIVEMIND` | No | `"true"` to enable multi-agent tools — restart required |
536
609
  | `PRISM_INSTANCE` | No | Instance name for multi-server PID isolation |
@@ -543,6 +616,12 @@ Requires `PRISM_ENABLE_HIVEMIND=true`.
543
616
  | `PRISM_CAPTURE_PORTS` | No | Comma-separated ports (default: `3000,3001,5173,8080`) |
544
617
  | `PRISM_DEBUG_LOGGING` | No | `"true"` for verbose logs |
545
618
  | `PRISM_DASHBOARD_PORT` | No | Dashboard port (default: `3000`) |
619
+ | `PRISM_SCHEDULER_ENABLED` | No | `"false"` to disable background maintenance (default: enabled) |
620
+ | `PRISM_SCHEDULER_INTERVAL_MS` | No | Maintenance interval in ms (default: `43200000` = 12h) |
621
+ | `PRISM_SCHOLAR_ENABLED` | No | `"true"` to enable Web Scholar pipeline |
622
+ | `PRISM_SCHOLAR_INTERVAL_MS` | No | Scholar interval in ms (default: `0` = manual only) |
623
+ | `PRISM_SCHOLAR_TOPICS` | No | Comma-separated research topics (default: `"ai,agents"`) |
624
+ | `PRISM_SCHOLAR_MAX_ARTICLES_PER_RUN` | No | Max articles per Scholar run (default: `3`) |
546
625
 
547
626
  </details>
548
627
 
@@ -550,118 +629,136 @@ Requires `PRISM_ENABLE_HIVEMIND=true`.
550
629
 
551
630
  ## Architecture
552
631
 
553
- <details>
554
- <summary><strong>Three-Tier Memory Architecture</strong></summary>
632
+ | Layer | File | Purpose |
633
+ |-------|------|---------|
634
+ | **1. User Rules** | `~/.gemini/GEMINI.md` | Slim ~10-line directive injected verbatim into system prompt |
635
+ | **2. Cross-Tool Rules** | `~/.gemini/AGENTS.md` | Reinforcement for multi-client setups (Antigravity + Cursor) |
636
+ | **3. Skill** | `.agent/skills/prism-startup/SKILL.md` | Full startup procedure with greeting detection and context echo |
637
+ | **Server Fallback** | Built into `server.ts` (v5.2.1) | Deferred auto-push via `sendLoggingMessage` if model doesn't comply within 10s |
638
+
639
+ ### Layer 1: User Rules
640
+
641
+ Create `~/.gemini/GEMINI.md`:
642
+
643
+ ```markdown
644
+ # Startup — MANDATORY
645
+
646
+ Your first action in every conversation is a tool call. Zero text before it.
647
+
648
+ Tool: mcp_prism-mcp_session_load_context
649
+ Args: project="my-project", level="deep"
555
650
 
651
+ After success: echo agent identity, last summary, open TODOs, session version.
652
+ If the call fails: say "Prism load failed — retrying" and try ONE more time.
556
653
  ```
557
- searchMemory() flow:
558
654
 
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)
655
+ ### Layer 2: Cross-Tool Reinforcement
562
656
 
563
- Tier 1 success → return results
564
- → Tier 1 fail → Tier 2 success → return results
565
- → Tier 2 fail → return []
657
+ Create `~/.gemini/AGENTS.md`:
658
+
659
+ ```markdown
660
+ # Session Memory
661
+ Every conversation starts with: mcp_prism-mcp_session_load_context(project="my-project", level="deep")
662
+ Echo result: agent identity, TODOs, session version.
566
663
  ```
567
664
 
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
665
+ ### Layer 3: Prism Startup Skill
572
666
 
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 |
667
+ Create `.agent/skills/prism-startup/SKILL.md` (or `.agents/skills/`) in your project or global config. This is a structured skill file that Antigravity loads with higher priority than plain rules. It includes:
578
668
 
579
- </details>
669
+ - Greeting detection (fires on "hi", "hello", etc.)
670
+ - Full tool call instructions with error handling
671
+ - Context echo template (agent identity, TODOs, version)
672
+ - Startup block display
580
673
 
581
- <details>
582
- <summary><strong>Progressive Context Loading</strong></summary>
674
+ ### Server-Side Fallback (v5.2.1)
583
675
 
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 |
676
+ If the model ignores all three layers, Prism's server pushes context automatically:
589
677
 
590
- </details>
678
+ 1. After storage warmup, a 10-second timer starts
679
+ 2. If `session_load_context` hasn't been called by then, the server pushes context via `sendLoggingMessage`
680
+ 3. If the client already called the tool, the push is silently skipped (zero impact on Claude CLI)
591
681
 
592
- <details>
593
- <summary><strong>Role Resolution</strong></summary>
682
+ This ensures context is always available, even with non-compliant models.
594
683
 
595
- Prism resolves agent roles using a priority chain:
684
+ ### Why This Architecture Works
596
685
 
597
- ```
598
- explicit tool argument → dashboard setting → "global" (default)
599
- ```
686
+ - **Gemini uses single underscores** for MCP tools (`mcp_prism-mcp_...`) vs Claude's double underscores
687
+ - **Slim rules** (~10 lines) avoid triggering adversarial "tool not found" reasoning
688
+ - **Skills have dedicated 3-level loading** in Antigravity — higher compliance than plain rules
689
+ - **Server fallback** catches the remaining edge cases without affecting well-behaved clients
690
+ - **Positive "First Action" framing** outperforms negative constraint lists
600
691
 
601
- Set your role once in the Mind Palace Dashboard (⚙️ Settings → Agent Identity) and it auto-applies to every session.
692
+ ### Antigravity UI Caveat
602
693
 
603
- Available roles: `dev`, `qa`, `pm`, `lead`, `security`, `ux`, `global`, or any custom string.
694
+ Antigravity **does not visually render MCP tool output blocks** in the chat UI. The tool executes successfully, but the user sees nothing. All three layers instruct the agent to **echo context in its text reply**.
604
695
 
605
- </details>
696
+ ### Session End Workflow
606
697
 
607
- <details>
608
- <summary><strong>Project Structure</strong></summary>
698
+ Tell the agent: *"Wrap up the session."* It should execute:
609
699
 
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
634
- ```
700
+ 1. `session_save_ledger` — append immutable work log (summary, decisions, files changed)
701
+ 2. `session_save_handoff` — upsert project state with `expected_version` for OCC
702
+
703
+ > **Tip:** Include session-end instructions in your `GEMINI.md` or ask the agent to save when you're done.
704
+
705
+ ### Platform Gotchas
706
+
707
+ - **`replace_file_content` silently fails** on `~/.gemini/GEMINI.md` in some environments — use `write_to_file` with overwrite instead
708
+ - **Multiple GEMINI.md locations** can conflict: global (`~/.gemini/`), workspace, and User Rules in the Antigravity UI. Keep them synchronized
709
+ - **Camoufox/browser tools** called at startup spawn visible black windows — never call browser tools during greeting handlers
635
710
 
636
711
  </details>
637
712
 
638
713
  <details>
639
- <summary><strong>Supabase Setup</strong></summary>
714
+ <summary><strong>Supabase Cloud Sync</strong></summary>
640
715
 
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
716
+ To sync memory across machines or teams:
717
+
718
+ ```json
719
+ {
720
+ "mcpServers": {
721
+ "prism-mcp": {
722
+ "command": "npx",
723
+ "args": ["-y", "prism-mcp-server"],
724
+ "env": {
725
+ "PRISM_STORAGE": "supabase",
726
+ "SUPABASE_URL": "https://your-project.supabase.co",
727
+ "SUPABASE_KEY": "your-supabase-anon-key"
728
+ }
729
+ }
730
+ }
731
+ }
732
+ ```
733
+
734
+ See the **Supabase Setup** section below for schema migration instructions.
645
735
 
646
736
  </details>
647
737
 
648
738
  <details>
649
- <summary><strong>LangChain / LangGraph Integration</strong></summary>
650
-
651
- Prism includes Python adapters in `examples/langgraph-agent/`:
739
+ <summary><strong>Clone & Build (Full Control)</strong></summary>
652
740
 
653
- ```python
654
- from langchain.retrievers import EnsembleRetriever
655
- from prism_retriever import PrismMemoryRetriever, PrismKnowledgeRetriever
656
-
657
- # Hybrid search: 70% semantic, 30% keyword
658
- retriever = EnsembleRetriever(
659
- retrievers=[PrismMemoryRetriever(...), PrismKnowledgeRetriever(...)],
660
- weights=[0.7, 0.3],
661
- )
741
+ ```bash
742
+ git clone https://github.com/dcostenco/prism-mcp.git
743
+ cd prism-mcp && npm install && npm run build
662
744
  ```
663
745
 
664
- Includes a full 5-node LangGraph research agent with MCP bridge and persistent memory.
746
+ Then add to your MCP config:
747
+
748
+ ```json
749
+ {
750
+ "mcpServers": {
751
+ "prism-mcp": {
752
+ "command": "node",
753
+ "args": ["/path/to/prism-mcp/dist/server.js"],
754
+ "env": {
755
+ "BRAVE_API_KEY": "your-key",
756
+ "GOOGLE_API_KEY": "your-gemini-key"
757
+ }
758
+ }
759
+ }
760
+ }
761
+ ```
665
762
 
666
763
  </details>
667
764
 
@@ -676,53 +773,34 @@ Prism is evolving from smart session logging toward a **cognitive memory archite
676
773
  | **v5.2** | Smart Consolidation — extract principles, not just summaries | Neuroscience sleep consolidation | ✅ Shipped |
677
774
  | **v5.2** | Ebbinghaus Importance Decay — memories fade unless reinforced | Ebbinghaus forgetting curve | ✅ Shipped |
678
775
  | **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 |
776
+ | **v5.5** | SDM Decoder Foundationpre-allocated typed-array hot loop, zero GC thrash | Kanerva's Sparse Distributed Memory (1988) | Shipped |
777
+ | **v5.6** | Full Superposed Memory (SDM) O(1) key-value retrieval via Hamming correlation | Kanerva's SDM | 🔬 In Progress |
778
+ | **v5.6** | Intuitive Recall — proactive surface of relevant past decisions without explicit search | Predictive memory (cognitive science) | 🔬 In Progress |
779
+ | **v6.x** | Affect-Tagged Memory — sentiment shapes what gets recalled | Affect-modulated retrieval (neuroscience) | 🔭 Horizon |
681
780
  | **v7+** | Zero-Search Retrieval — no index, no ANN, just ask the vector | Holographic Reduced Representations | 🔭 Horizon |
682
781
 
683
782
  > Informed by LeCun's "Why AI Systems Don't Learn" (Dupoux, LeCun, Malik — March 2026) and Kanerva's SDM.
684
783
 
685
784
  ---
686
785
 
687
- ## Version History
688
-
689
- <details>
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.
705
-
706
- </details>
707
-
708
- ---
709
-
710
- ## 🚀 Roadmap
786
+ ## 📅 Roadmap
711
787
 
712
788
  > **[Full ROADMAP.md →](ROADMAP.md)**
713
789
 
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 Scholaragent-driven research pipeline
790
+ **Shipped v5.5:**
791
+ - 🛡️ Transactional migrations, graceful shutdown registry, thundering herd prevention, SDM decoder GC optimization
792
+
793
+ **Nextv5.6:**
794
+ - 🧠 **Full Superposed Memory (SDM)** O(1) semantic retrieval via Hamming correlation, no ANN index needed
795
+ - 🔮 **Intuitive Recall** — proactive surfacing of relevant past context without explicit `session_search_memory` calls
796
+ - 📊 **Radar 2.0** — richer Hivemind dashboard with agent task graphs and dependency visualization
719
797
 
720
798
  ---
721
799
 
722
800
  ## ⚠️ Limitations
723
801
 
724
802
  - **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.
803
+ - **Auto-load is model-dependent.** Session auto-loading relies on the LLM following system prompt instructions. Gemini/Antigravity uses a [three-layer architecture](#antigravity-auto-load) (User Rules + AGENTS.md + Startup Skill) with a v5.2.1 server-side fallback that auto-pushes context if the model doesn't comply within 10 seconds.
726
804
  - **No real-time sync without Supabase.** Local SQLite mode is single-machine only. Multi-device or team sync requires a Supabase backend.
727
805
  - **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
806
  - **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`.