prism-mcp-server 4.0.0 β†’ 4.3.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
@@ -14,7 +14,8 @@
14
14
 
15
15
  ## Table of Contents
16
16
 
17
- - [What's New (v4.0.0)](#whats-new-in-v400--behavioral-memory-)
17
+ - [What's New (v4.2.0)](#whats-new-in-v420--project-repo-registry-)
18
+ - [Multi-Instance Support](#multi-instance-support)
18
19
  - [How Prism Compares](#how-prism-compares)
19
20
  - [Quick Start](#quick-start-zero-config--local-mode)
20
21
  - [Mind Palace Dashboard](#-the-mind-palace-dashboard)
@@ -41,26 +42,56 @@
41
42
 
42
43
  ---
43
44
 
44
- ## What's New in v4.0.0 β€” Behavioral Memory 🧠
45
+ ## What's New in v4.3.0 β€” The Bridge πŸŒ‰
46
+
47
+ > **🧠 Active Behavioral Memory & IDE Sync**
48
+ > 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 can automatically sync it directly to your `.cursorrules` or `.clauderules` file, turning dynamic behavioral learnings into permanent, zero-token IDE enforcement.
49
+
50
+ <details>
51
+ <summary><strong>What's in v4.2.0 β€” Project Repo Registry πŸ—‚οΈ</strong></summary>
52
+
53
+ | Feature | Description |
54
+ |---|---|
55
+ | πŸ—‚οΈ **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. |
56
+ | πŸ”„ **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. |
57
+ | 🏠 **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. |
58
+
59
+ </details>
60
+
61
+ <details>
62
+ <summary><strong>What's in v4.1.0 β€” Auto-Migration & Multi-Instance πŸ”€</strong></summary>
63
+
64
+ | Feature | Description |
65
+ |---|---|
66
+ | πŸ”„ **Auto-Migrations (Supabase)** | Zero-config schema upgrades β€” pending DDL migrations run automatically on server startup via `prism_apply_ddl` RPC. |
67
+ | πŸ”€ **Multi-Instance Support** | `PRISM_INSTANCE` env var enables instance-aware PID locks β€” run multiple Prism servers side-by-side without conflicts. |
68
+ | πŸ›‘οΈ **Server Lifecycle Management** | Singleton PID lock with graceful shutdown and stale PID recovery. |
69
+
70
+ </details>
71
+
72
+ <details>
73
+ <summary><strong>What's in v4.0.0 β€” Behavioral Memory 🧠</strong></summary>
45
74
 
46
75
  | Feature | Description |
47
76
  |---|---|
48
- | 🧠 **Active Behavioral Memory** | New `session_save_experience` tool β€” agents log actions, outcomes, corrections, and confidence scores. Prism tracks importance, applies decay over time, and injects behavioral warnings into context loading so agents learn from past mistakes. |
49
- | 🎯 **Dynamic Role Resolution** | Role parameter is now fully optional across all tools. The server auto-resolves from dashboard settings via `getSetting("default_role")` β€” set your role once in the Mind Palace Dashboard, and it applies everywhere. No more hardcoding `role: "global"`. |
50
- | πŸ“ **Token Budget** | New `max_tokens` parameter on `session_load_context` β€” set a token budget and the response is intelligently truncated to fit. Uses a 1 token β‰ˆ 4 chars heuristic. |
51
- | πŸ“‰ **Importance Decay** | Stale behavioral experiences automatically decay over time β€” older corrections fade in importance to keep context fresh and relevant. |
52
- | πŸ”§ **Claude Code Hooks** | Refined SessionStart/Stop hook samples that reliably trigger MCP tool calls. Simplified from multi-step workflows to single imperative instructions. |
77
+ | 🧠 **Behavioral Memory** | `session_save_experience` β€” log actions, outcomes, corrections with confidence scores. Auto-injects warnings into context so agents learn from mistakes. |
78
+ | 🎯 **Dynamic Roles** | Role auto-resolves from dashboard settings. Set once in Mind Palace, applies everywhere. |
79
+ | πŸ“ **Token Budget** | `max_tokens` on `session_load_context` β€” intelligently truncates to fit your budget. |
80
+ | πŸ“‰ **Importance Decay** | Stale corrections auto-fade over time to keep context fresh. |
81
+ | πŸ”§ **Claude Code Hooks** | Simplified SessionStart/Stop hooks that reliably trigger MCP tool calls. |
82
+
83
+ </details>
53
84
 
54
85
  <details>
55
86
  <summary><strong>What's in v3.1.0 β€” Memory Lifecycle πŸ”„</strong></summary>
56
87
 
57
88
  | Feature | Description |
58
89
  |---|---|
59
- | πŸ“Š **Memory Analytics** | New **Memory Analytics** card in the dashboard β€” 14-day sparkline chart, active sessions count, rollup savings, and average context richness. Powered by `getAnalytics()` on both SQLite and Supabase backends. |
60
- | ⏳ **Automated Data Retention (TTL)** | Set a per-project data retention policy via `knowledge_set_retention` MCP tool or the dashboard **Lifecycle Controls** card. Entries older than the TTL are soft-deleted (GDPR-compliant `archived_at` tombstone) every 12 hours automatically. Rollups are never expired. Minimum 7 days to prevent accidental mass-delete. |
61
- | πŸ—œοΈ **Smart Auto-Compaction** | After every `session_save_ledger`, Prism runs a background health check and triggers compaction automatically if the brain is degraded or unhealthy β€” gated by `compaction_auto` setting and debounced per-project to prevent concurrent Gemini calls. **Compact Now** button also available in the dashboard. |
62
- | πŸ“¦ **PKM Export (Obsidian / Logseq)** | Export any project's full memory as a ZIP archive of Markdown files β€” one file per session with YAML-like frontmatter, TODOs, decisions, files-changed, and `#hashtag` keywords. Includes an `_index.md` with `[[wikilink]]` references. Click **Export ZIP** in the dashboard Lifecycle Controls card. |
63
- | πŸ§ͺ **Expanded Test Suite** | 37 new Vitest tests (95 total) β€” covers analytics queries, TTL soft-delete idempotency, rollup preservation, `activeCompactions` Set memory-leak prevention, type guards, export Markdown structure, and TTL sweep scheduler contracts. |
90
+ | πŸ“Š **Memory Analytics** | Dashboard sparkline chart, session counts, rollup savings, context richness metrics. |
91
+ | ⏳ **Data Retention (TTL)** | Per-project TTL via `knowledge_set_retention` or dashboard. Auto-expires old entries every 12h. |
92
+ | πŸ—œοΈ **Auto-Compaction** | Background health check after saves β€” auto-compacts when brain is degraded. |
93
+ | πŸ“¦ **PKM Export** | Export project memory as ZIP of Markdown files for Obsidian/Logseq. |
94
+ | πŸ§ͺ **95 Tests** | Analytics, TTL, rollup, compaction, type guards, and export coverage. |
64
95
 
65
96
  </details>
66
97
 
@@ -69,10 +100,10 @@
69
100
 
70
101
  | Feature | Description |
71
102
  |---|---|
72
- | 🧹 **Brain Health Clean-up** | New **Fix Issues** button in the Mind Palace Dashboard's Brain Health card β€” detects orphaned handoffs, missing embeddings, and stale rollups, then cleans them up in one click without needing the MCP tool. |
73
- | πŸ‘€ **Agent Identity Settings** | Dashboard Settings β†’ Agent Identity panel lets you set a **Default Role** (`dev`, `qa`, `pm`…) and **Agent Name** (e.g. `Dmitri`). Both values auto-apply as fallbacks in all memory and Hivemind tools β€” no need to pass them per call. |
74
- | πŸ“œ **Role-Scoped Skills** | Each agent role can have its own persistent skill/rules document stored in the dashboard (βš™οΈ Settings β†’ Skills). It is automatically injected into every `session_load_context` response so the agent boots with its rules pre-loaded. |
75
- | πŸ”€ **Resource Formatting Fix** | `memory://{project}/handoff` resources now render as formatted plain text (Last Summary, TODOs, Keywords) instead of a raw JSON blob β€” readable in Claude Desktop's paperclip attach panel. |
103
+ | 🧹 **Brain Health Clean-up** | One-click **Fix Issues** button β€” detects and cleans orphaned handoffs, missing embeddings, stale rollups. |
104
+ | πŸ‘€ **Agent Identity** | Set Default Role and Agent Name in dashboard β€” auto-applies as fallback in all tools. |
105
+ | πŸ“œ **Role-Scoped Skills** | Per-role persistent rules documents, auto-injected at `session_load_context`. |
106
+ | πŸ”€ **Resource Formatting** | `memory://` resources render as formatted text instead of raw JSON. |
76
107
 
77
108
  </details>
78
109
 
@@ -81,13 +112,13 @@
81
112
 
82
113
  | Feature | Description |
83
114
  |---|---|
84
- | 🐝 **Role-Scoped Memory** | Optional `role` parameter on ledger, handoff, and context loading β€” each agent role (dev, qa, pm, lead, security, ux) gets its own isolated memory lane within a project. Defaults to `'global'` for full backward compatibility. |
85
- | πŸ‘₯ **Agent Registry** | New `agent_register`, `agent_heartbeat`, `agent_list_team` tools β€” agents announce their presence, pulse their status, and discover who else is working on the team. Stale agents are auto-pruned after 30 minutes. |
86
- | 🎯 **Team Roster Injection** | When loading context with a role, Prism automatically injects a "Team Roster" showing active teammates, their roles, current tasks, and last heartbeat β€” true multi-agent awareness without extra tool calls. |
87
- | βš™οΈ **Dashboard Settings** | New Settings modal with runtime toggles (auto-capture, theme, context depth) backed by a persistent `system_settings` key-value store. Environment variables override DB settings for safety. |
88
- | πŸ“‘ **Hivemind Radar** | New dashboard widget showing active agents, their roles (with icons), current tasks, and heartbeat timestamps β€” a real-time team coordination dashboard. |
89
- | πŸ”’ **Conditional Tool Registration** | `PRISM_ENABLE_HIVEMIND` env var gates Hivemind tools β€” users who don't need multi-agent features keep the same lean tool count as v2.x. |
90
- | βœ… **Test Suite** | 58 tests across 4 suites (storage, tools, dashboard, load) with Vitest β€” includes concurrent write stress tests, role isolation verification, and 0.2ms/write performance benchmarks. |
115
+ | 🐝 **Role-Scoped Memory** | Optional `role` param β€” each role gets isolated memory within a project. |
116
+ | πŸ‘₯ **Agent Registry** | `agent_register`, `agent_heartbeat`, `agent_list_team` β€” multi-agent discovery. |
117
+ | 🎯 **Team Roster** | Auto-injected teammate awareness during context loading. |
118
+ | βš™οΈ **Dashboard Settings** | Runtime toggles backed by persistent key-value store. |
119
+ | πŸ“‘ **Hivemind Radar** | Dashboard widget showing active agents, roles, and heartbeats. |
120
+ | πŸ”’ **Conditional Tools** | `PRISM_ENABLE_HIVEMIND` gates multi-agent tools. |
121
+ | βœ… **58 Tests** | Storage, tools, dashboard, concurrent writes, role isolation. |
91
122
 
92
123
  </details>
93
124
 
@@ -97,10 +128,10 @@
97
128
 
98
129
  | Feature | Description |
99
130
  |---|---|
100
- | πŸ” **Memory Tracing (Phase 1)** | Every search now returns a structured `MemoryTrace` with latency breakdown (`embedding_ms`, `storage_ms`, `total_ms`), search strategy, and scoring metadata β€” surfaced as a separate `content[1]` block for LangSmith integration. |
101
- | πŸ›‘οΈ **GDPR Memory Deletion (Phase 2)** | New `session_forget_memory` tool with soft-delete (tombstoning via `deleted_at`) and hard-delete. Ownership guards prevent cross-user deletion. `deleted_reason` column captures GDPR Article 17 justification. Top-K Hole solved by filtering inside SQL, not post-query (ensures we always return exactly K results, rather than returning fewer because deleted items were filtered out after the vector search). |
102
- | πŸ”— **LangChain Integration (Phase 3)** | `PrismMemoryRetriever` and `PrismKnowledgeRetriever` β€” async-first `BaseRetriever` subclasses that wrap Prism MCP's traced search endpoints. Trace metadata flows automatically into `Document.metadata["trace"]` for LangSmith visibility. |
103
- | 🧩 **LangGraph Research Agent** | Full example in `examples/langgraph-agent/` β€” a 5-node agentic research loop with MCP bridge, persistent memory, and `EnsembleRetriever` hybrid search. |
131
+ | πŸ” **Memory Tracing** | `MemoryTrace` with latency breakdown and scoring metadata for LangSmith. |
132
+ | πŸ›‘οΈ **GDPR Deletion** | `session_forget_memory` with soft/hard delete and Article 17 justification. |
133
+ | πŸ”— **LangChain Integration** | `PrismMemoryRetriever` / `PrismKnowledgeRetriever` BaseRetriever adapters. |
134
+ | 🧩 **LangGraph Agent** | 5-node research agent example with MCP bridge and hybrid search. |
104
135
 
105
136
  </details>
106
137
 
@@ -109,8 +140,8 @@
109
140
 
110
141
  | Feature | Description |
111
142
  |---|---|
112
- | πŸ”„ **Dynamic Versioning** | Server version is now derived from `package.json` at startup β€” MCP handshake, dashboard badge, and npm metadata always stay in sync. Falls back to `0.0.0` if unreadable. |
113
- | πŸ›‘οΈ **Embedding Dimension Validation** | `generateEmbedding()` now validates the returned vector is exactly 768 dimensions at runtime, catching model regressions before storing bad vectors. Removed `as any` cast in favor of proper `EmbedContentRequest` typing. |
143
+ | πŸ”„ **Dynamic Versioning** | Version derived from `package.json` β€” MCP handshake, dashboard, and npm stay in sync. |
144
+ | πŸ›‘οΈ **Embedding Validation** | Validates 768-dimension vectors at runtime to catch model regressions. |
114
145
 
115
146
  </details>
116
147
 
@@ -130,11 +161,11 @@
130
161
 
131
162
  | Feature | Description |
132
163
  |---|---|
133
- | πŸ€– **LangGraph Research Agent** | New `examples/langgraph-agent/` β€” a 5-node agentic research agent (planβ†’searchβ†’analyzeβ†’decideβ†’answerβ†’save) with autonomous looping, MCP integration, and persistent memory. |
134
- | 🧠 **Agentic Memory** | `save_session` node persists research findings to a ledger β€” the agent doesn't just answer and forget. Routes to Prism's `session_save_ledger` in MCP-connected mode. |
135
- | πŸ”Œ **MCP Client Bridge** | Raw JSON-RPC 2.0 client (`mcp_client.py`) for Python 3.9+ β€” dynamically discovers and wraps Prism MCP tools as LangChain `StructuredTool` objects. |
136
- | πŸ”§ **Storage Abstraction Fix** | Resource/Prompt handlers now route through `getStorage()` instead of calling Supabase directly β€” eliminates EOF crashes when reading `memory://` resources. |
137
- | πŸ›‘οΈ **Error Boundaries** | Resource handlers catch errors gracefully and return proper MCP error responses (`isError: true`) instead of crashing the server process. |
164
+ | πŸ€– **LangGraph Agent** | 5-node research agent with autonomous looping, MCP integration, persistent memory. |
165
+ | 🧠 **Agentic Memory** | `save_session` node persists findings to ledger β€” agents don't just answer and forget. |
166
+ | πŸ”Œ **MCP Client Bridge** | JSON-RPC 2.0 client wraps Prism tools as LangChain `StructuredTool` objects. |
167
+ | πŸ”§ **Storage Fix** | Resource/Prompt handlers route through `getStorage()` β€” eliminates EOF crashes. |
168
+ | πŸ›‘οΈ **Error Boundaries** | Graceful error handling with proper MCP error responses. |
138
169
 
139
170
  </details>
140
171
 
@@ -172,25 +203,29 @@
172
203
 
173
204
  | 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) |
174
205
  |---|---|---|---|---|---|
175
- | **Pricing** | βœ… Free & open source (MIT) | βœ… Free & open source (MIT) | Freemium (free 10K memories; paid Pro) | βœ… Free & open source | Freemium (OSS core free; paid Pro) |
176
- | **Storage** | SQLite (local) + Supabase (cloud) | JSON file | Postgres + Qdrant (hosted or self-hosted) | Qdrant + S3/MinIO | Markdown files |
177
- | **Zero Config** | βœ… `npx -y prism-mcp-server` | βœ… | ❌ Requires Qdrant/Postgres | βœ… `uvx mnemory` | βœ… `pip install basic-memory` |
178
- | **Semantic Search** | βœ… F32_BLOB vectors + FTS5 | ❌ | βœ… pgvector | βœ… Qdrant vectors | ❌ Text search only |
179
- | **Knowledge Graph** | βœ… Neural Graph (Vis.js dashboard) | βœ… Entity/Relation model | ❌ | βœ… Relationship graph | βœ… Markdown links |
180
- | **Time Travel** | βœ… `memory_history` / `memory_checkout` | ❌ | ❌ | ❌ | ❌ |
181
- | **Fact Merging** | βœ… Async Gemini (fire-and-forget) | ❌ | βœ… Built-in | βœ… Contradiction resolution | ❌ |
182
- | **Security Scan** | βœ… Prompt injection detection | ❌ | ❌ | βœ… Anti-injection in fsck | ❌ |
183
- | **Health Check** | βœ… `session_health_check` (fsck) | ❌ | ❌ | βœ… 3-phase fsck | ❌ |
184
- | **Visual Dashboard** | βœ… Mind Palace (localhost:3000) | ❌ | βœ… Cloud dashboard | βœ… Management UI | ❌ |
185
- | **Multi-Agent Sync** | βœ… Real-time cross-client | ❌ | ❌ | ❌ Per-user isolation | ❌ |
186
- | **Visual Memory** | βœ… Screenshot vault + auto-capture | ❌ | ❌ | βœ… Artifact store | ❌ |
206
+ | **Pricing** | βœ… Free / MIT | βœ… Free / MIT | Freemium | βœ… Free / OSS | Freemium |
207
+ | **Storage** | SQLite + Supabase | JSON file | Postgres + Qdrant | Qdrant + S3 | Markdown files |
208
+ | **Zero Config** | βœ… npx one-liner | βœ… | ❌ Qdrant/Postgres | βœ… uvx | βœ… pip |
209
+ | **Behavioral Memory** | βœ… Importance tracking | ❌ | ❌ | ❌ | ❌ |
210
+ | **Dynamic Roles** | βœ… Dashboard auto-resolve | ❌ | ❌ | ❌ | ❌ |
211
+ | **Token Budget** | βœ… max_tokens param | ❌ | ❌ | ❌ | ❌ |
212
+ | **Importance Decay** | βœ… Auto-fade stale data | ❌ | ❌ | ❌ | ❌ |
213
+ | **Semantic Search** | βœ… Vectors + FTS5 | ❌ | βœ… pgvector | βœ… Qdrant | ❌ Text only |
214
+ | **Knowledge Graph** | βœ… Neural Graph | βœ… Entity model | ❌ | βœ… Graph | βœ… MD links |
215
+ | **Time Travel** | βœ… History + checkout | ❌ | ❌ | ❌ | ❌ |
216
+ | **Fact Merging** | βœ… Gemini async | ❌ | βœ… Built-in | βœ… Contradiction | ❌ |
217
+ | **Security Scan** | βœ… Injection detection | ❌ | ❌ | βœ… Anti-injection | ❌ |
218
+ | **Health Check** | βœ… fsck tool | ❌ | ❌ | βœ… 3-phase fsck | ❌ |
219
+ | **Visual Dashboard** | βœ… Mind Palace | ❌ | βœ… Cloud UI | βœ… Mgmt UI | ❌ |
220
+ | **Multi-Agent Sync** | βœ… Real-time | ❌ | ❌ | ❌ Per-user | ❌ |
221
+ | **Visual Memory** | βœ… Screenshot vault | ❌ | ❌ | βœ… Artifacts | ❌ |
187
222
  | **Auto-Compaction** | βœ… Gemini rollups | ❌ | ❌ | ❌ | ❌ |
188
223
  | **Morning Briefing** | βœ… Gemini synthesis | ❌ | ❌ | ❌ | ❌ |
189
224
  | **OCC (Concurrency)** | βœ… Version-based | ❌ | ❌ | ❌ | ❌ |
190
- | **GDPR Compliance** | βœ… Soft/hard delete + audit trail | ❌ | ❌ | ❌ | ❌ |
191
- | **Memory Tracing** | βœ… MemoryTrace with latency breakdown | ❌ | ❌ | ❌ | ❌ |
192
- | **LangChain Native** | βœ… BaseRetriever adapters | ❌ | ❌ | ❌ | ❌ |
193
- | **MCP Native** | βœ… stdio (Claude Desktop, Cursor) | βœ… stdio | ❌ Python SDK / REST | βœ… HTTP + MCP | βœ… stdio |
225
+ | **GDPR Compliance** | βœ… Soft/hard delete | ❌ | ❌ | ❌ | ❌ |
226
+ | **Memory Tracing** | βœ… Latency breakdown | ❌ | ❌ | ❌ | ❌ |
227
+ | **LangChain** | βœ… BaseRetriever | ❌ | ❌ | ❌ | ❌ |
228
+ | **MCP Native** | βœ… stdio | βœ… stdio | ❌ Python SDK | βœ… HTTP + MCP | βœ… stdio |
194
229
  | **Language** | TypeScript | TypeScript | Python | Python | Python |
195
230
 
196
231
  > **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.
@@ -280,6 +315,7 @@ Open **`http://localhost:3000`** in your browser to see exactly what your AI age
280
315
 
281
316
  - **Current State & TODOs** β€” See the exact context injected into the LLM's prompt
282
317
  - **Agent Identity Chip** β€” Header shows your active role + name (e.g. `πŸ› οΈ dev Β· Antigravity`); click to open Settings
318
+ - **Project Repo Paths** β€” Map each project to its repo directory for save validation
283
319
  - **Brain Health 🩺** β€” Memory integrity status at a glance; **🧹 Fix Issues** button auto-cleans orphaned handoffs in one click
284
320
  - **Git Drift Detection** β€” Alerts you if you've modified code outside the agent's view
285
321
  - **Morning Briefing** β€” AI-synthesized action plan from your last sessions
@@ -621,6 +657,82 @@ The tool and dashboard button both call the same repair logic β€” the dashboard
621
657
  | `session_search_memory` | Semantic search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
622
658
  | `knowledge_search` | Knowledge search with `enable_trace` | `query`, `enable_trace` | Results + `MemoryTrace` in `content[1]` |
623
659
 
660
+ ### v4.0 Behavioral Memory Tools
661
+
662
+ | Tool | Purpose | Key Args |
663
+ |------|---------|----------|
664
+ | `session_save_experience` | Record behavioral events with importance tracking | `project`, `event_type`, `context`, `action`, `outcome` |
665
+
666
+ **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.
667
+
668
+ **Token Budget (v4.0):** Set a default in the dashboard (βš™οΈ Settings β†’ Token Budget) or pass `max_tokens` per call to override:
669
+
670
+ ```json
671
+ { "name": "session_load_context", "arguments": {
672
+ "project": "my-app", "level": "standard", "max_tokens": 2000
673
+ }}
674
+ ```
675
+
676
+ > πŸ’‘ Set Token Budget to `0` in the dashboard for unlimited (default). Per-call `max_tokens` always takes priority.
677
+
678
+ **Recording experiences:**
679
+
680
+ ```json
681
+ { "name": "session_save_experience", "arguments": {
682
+ "project": "my-app",
683
+ "event_type": "correction",
684
+ "context": "User asked to add a database migration",
685
+ "action": "Ran ALTER TABLE directly in production",
686
+ "outcome": "Data was corrupted",
687
+ "correction": "Always create a migration file and test in staging first",
688
+ "confidence_score": 95
689
+ }}
690
+ ```
691
+
692
+ **Event types:** `correction` (user corrected the agent), `success` (task went well), `failure` (task failed), `learning` (new knowledge acquired).
693
+
694
+ **How behavioral memory works:**
695
+ 1. Agent records experiences via `session_save_experience`
696
+ 2. Prism assigns an **importance score** based on event type + confidence
697
+ 3. Stale entries **auto-decay** in importance over time
698
+ 4. On `session_load_context`, high-importance corrections auto-surface as `[⚠️ BEHAVIORAL WARNINGS]`
699
+ 5. Agent sees warnings and avoids repeating past mistakes
700
+
701
+ ### v4.2 Knowledge Sync Rules β€” "The Bridge"
702
+
703
+ Bridges **v4.0 Behavioral Memory** (graduated insights) with **v4.2 Project Registry** (repo paths) to physically write agent learnings into your project's IDE rules file.
704
+
705
+ | Feature | Without Sync Rules | With `knowledge_sync_rules` |
706
+ |---------|-------------------|----------------------------|
707
+ | **Insight Visibility** | Only in Prism context injection | Persisted as static IDE context (`.cursorrules` / `.clauderules`) |
708
+ | **Cross-Session** | Loaded per-session via tool call | Always-on β€” IDE reads rules file on every prompt |
709
+ | **Agent Learning Loop** | Behavioral warnings during context load | Rules enforced even without Prism connected |
710
+ | **Idempotency** | N/A | Sentinel markers ensure safe re-runs |
711
+ | **User Control** | View in dashboard | User-maintained rules preserved; only sentinel block updated |
712
+
713
+ **Syncing graduated insights:**
714
+
715
+ ```json
716
+ { "name": "knowledge_sync_rules", "arguments": {
717
+ "project": "my-app",
718
+ "target_file": ".cursorrules",
719
+ "dry_run": true
720
+ }}
721
+ ```
722
+
723
+ **How it works:**
724
+ 1. Fetches graduated insights (`importance >= 7`) from the ledger
725
+ 2. Formats them as markdown rules inside `<!-- PRISM:AUTO-RULES:START/END -->` sentinel markers
726
+ 3. Idempotently writes them into the target file at the project's configured `repo_path`
727
+
728
+ | Tool | Purpose | Key Args |
729
+ |------|---------|----------|
730
+ | `knowledge_sync_rules` | Sync graduated insights to IDE rules file | `project`, `target_file`, `dry_run` |
731
+ | `knowledge_upvote` | Increase entry importance (+1) | `id` |
732
+ | `knowledge_downvote` | Decrease entry importance (-1) | `id` |
733
+
734
+ > πŸ’‘ **Prerequisite:** Set a `repo_path` for your project in the Mind Palace dashboard (βš™οΈ Settings β†’ Project Repo Paths) before syncing.
735
+
624
736
  ### Code Mode Templates (v2.1)
625
737
 
626
738
  Instead of writing custom JavaScript, pass a `template` name for instant extraction:
@@ -798,6 +910,7 @@ The retrievers use `_aget_relevant_documents` as the primary path with `asyncio.
798
910
  | `BRAVE_API_KEY` | No | Brave Search Pro API key (enables web/local search tools) |
799
911
  | `PRISM_STORAGE` | No | `"local"` (default) or `"supabase"` β€” **requires restart** |
800
912
  | `PRISM_ENABLE_HIVEMIND` | No | Set `"true"` to enable multi-agent Hivemind tools β€” **requires restart** |
913
+ | `PRISM_INSTANCE` | No | Instance name for PID lock isolation (e.g. `"athena"`, `"prism-dev"`). Enables [multi-instance support](#multi-instance-support). Default: `"default"` |
801
914
  | `GOOGLE_API_KEY` | No | Google AI / Gemini β€” enables paper analysis, Morning Briefings, compaction |
802
915
  | `BRAVE_ANSWERS_API_KEY` | No | Separate Brave Answers key for AI-grounded answers |
803
916
  | `SUPABASE_URL` | If cloud mode | Supabase project URL |
@@ -864,12 +977,27 @@ The agent boots up knowing exactly what to do β€” zero prompting needed.
864
977
 
865
978
  ### Auto-Load on Session Start (Recommended)
866
979
 
867
- For the best experience, configure your AI coding assistant to **automatically call `session_load_context`** at the start of every new session. This ensures your agent always boots with full project memory β€” no manual prompting needed.
980
+ 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:
981
+
982
+ #### Option A: Dashboard Setting (Easiest)
983
+
984
+ Open the **Mind Palace Dashboard** (βš™οΈ Settings) and type your project names into the **Auto-Load Projects** field under Boot Settings:
985
+
986
+ ```
987
+ prism-mcp, my-app
988
+ ```
989
+
990
+ That's it. Restart your AI client and Prism auto-pushes context for each listed project on next boot.
991
+
992
+ #### Option B: Client-Side Hooks / Rules
993
+
994
+ For clients that support lifecycle hooks or startup rules, instruct the AI to **call `session_load_context` as a tool** at session start:
868
995
 
869
- See the full setup guides for each client:
870
996
  - **[Claude Code Integration (Hooks)](#claude-code-integration-hooks)** β€” `SessionStart` and `Stop` hook JSON samples for `~/.claude/settings.json`
871
997
  - **[Gemini / Antigravity Integration](#gemini--antigravity-integration)** β€” global rules for `~/.gemini/GEMINI.md` or user rules
872
998
 
999
+ > **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).
1000
+
873
1001
  > **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).
874
1002
 
875
1003
  > **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.
@@ -1083,9 +1211,12 @@ Traces are returned as `content[1]` in MCP responses β€” a separate content bloc
1083
1211
 
1084
1212
  ### 2. Apply Migrations
1085
1213
 
1086
- In the SQL Editor, run:
1214
+ In the SQL Editor, run the **bootstrap migration** first:
1087
1215
  1. [`supabase/migrations/015_session_memory.sql`](supabase/migrations/015_session_memory.sql)
1088
1216
  2. [`supabase/migrations/016_knowledge_accumulation.sql`](supabase/migrations/016_knowledge_accumulation.sql)
1217
+ 3. [`supabase/migrations/027_auto_migration_infra.sql`](supabase/migrations/027_auto_migration_infra.sql) β€” **enables auto-migrations** (see below)
1218
+
1219
+ > **After applying migration 027**, all future schema changes are applied automatically on server startup β€” no manual SQL required.
1089
1220
 
1090
1221
  ### 3. Get Credentials
1091
1222
 
@@ -1113,6 +1244,70 @@ export PRISM_STORAGE="supabase"
1113
1244
 
1114
1245
  </details>
1115
1246
 
1247
+ ### Auto-Migrations (Supabase Cloud)
1248
+
1249
+ 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.
1250
+
1251
+ **How it works:**
1252
+
1253
+ 1. On startup, the migration runner checks each entry in `MIGRATIONS[]` (defined in `supabaseMigrations.ts`)
1254
+ 2. For each migration, it calls `prism_apply_ddl(version, name, sql)` β€” a `SECURITY DEFINER` RPC function
1255
+ 3. The function checks `prism_schema_versions` β€” if the version is already recorded, it's silently skipped (idempotent)
1256
+ 4. If not applied, it executes the DDL and records the version number
1257
+
1258
+ **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.
1259
+
1260
+ **Adding new migrations** β€” just append to the `MIGRATIONS[]` array in `src/storage/supabaseMigrations.ts`:
1261
+
1262
+ ```typescript
1263
+ {
1264
+ version: 28,
1265
+ name: "my_new_feature",
1266
+ sql: `ALTER TABLE session_ledger ADD COLUMN IF NOT EXISTS my_col TEXT;`,
1267
+ }
1268
+ ```
1269
+
1270
+ All SQL must be idempotent (`IF NOT EXISTS` / `IF EXISTS` guards).
1271
+
1272
+ ---
1273
+
1274
+ ## Multi-Instance Support
1275
+
1276
+ 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.
1277
+
1278
+ ### Configuration
1279
+
1280
+ Set `PRISM_INSTANCE` to a unique name per server instance:
1281
+
1282
+ ```json
1283
+ {
1284
+ "mcpServers": {
1285
+ "prism-search": {
1286
+ "command": "node",
1287
+ "args": ["/path/to/prism/dist/server.js"],
1288
+ "env": {
1289
+ "PRISM_INSTANCE": "prism-search",
1290
+ "BRAVE_API_KEY": "your-key"
1291
+ }
1292
+ },
1293
+ "prism-memory": {
1294
+ "command": "node",
1295
+ "args": ["/path/to/prism/dist/server.js"],
1296
+ "env": {
1297
+ "PRISM_INSTANCE": "prism-memory"
1298
+ }
1299
+ }
1300
+ }
1301
+ }
1302
+ ```
1303
+
1304
+ ### How it works
1305
+
1306
+ - Each instance gets its own PID file: `/tmp/prism-{PRISM_INSTANCE}.pid`
1307
+ - Default instance name is `"default"` (backward compatible)
1308
+ - Instances share the same SQLite database and Supabase backend β€” only the process lock is isolated
1309
+ - Graceful shutdown cleans up the instance's PID file
1310
+
1116
1311
  ---
1117
1312
 
1118
1313
  ## Hybrid Search Pipeline (Brave + Vertex AI)
@@ -1139,12 +1334,13 @@ See [`vertex-ai/`](vertex-ai/) for setup and benchmarks.
1139
1334
 
1140
1335
  ```
1141
1336
  β”œβ”€β”€ src/
1142
- β”‚ β”œβ”€β”€ server.ts # MCP server core + tool routing
1337
+ β”‚ β”œβ”€β”€ server.ts # MCP server core + tool routing + lifecycle
1143
1338
  β”‚ β”œβ”€β”€ config.ts # Environment management
1144
1339
  β”‚ β”œβ”€β”€ storage/
1145
1340
  β”‚ β”‚ β”œβ”€β”€ interface.ts # StorageBackend abstraction (+ GDPR delete methods)
1146
1341
  β”‚ β”‚ β”œβ”€β”€ sqlite.ts # SQLite local storage (libSQL + F32_BLOB + deleted_at migration)
1147
1342
  β”‚ β”‚ β”œβ”€β”€ supabase.ts # Supabase cloud storage (+ soft/hard delete)
1343
+ β”‚ β”‚ β”œβ”€β”€ supabaseMigrations.ts # Auto-migration runner for Supabase DDL
1148
1344
  β”‚ β”‚ β”œβ”€β”€ configStorage.ts # Boot config micro-DB (~/.prism-mcp/prism-config.db)
1149
1345
  β”‚ β”‚ └── index.ts # Backend factory (auto-selects based on PRISM_STORAGE)
1150
1346
  β”‚ β”œβ”€β”€ sync/
@@ -1182,7 +1378,8 @@ See [`vertex-ai/`](vertex-ai/) for setup and benchmarks.
1182
1378
  β”‚ β”œβ”€β”€ prism_retriever.py # PrismMemoryRetriever + PrismKnowledgeRetriever
1183
1379
  β”‚ β”œβ”€β”€ tools.py # Agent tools + GDPR forget_memory
1184
1380
  β”‚ └── demo_retriever.py # Standalone retriever demo
1185
- β”œβ”€β”€ supabase/migrations/ # Cloud mode SQL schemas
1381
+ β”œβ”€β”€ supabase/migrations/ # Cloud mode SQL schemas + auto-migration bootstrap
1382
+ β”‚ └── 027_auto_migration_infra.sql # prism_apply_ddl() RPC + schema version tracking
1186
1383
  β”œβ”€β”€ vertex-ai/ # Vertex AI hybrid search pipeline
1187
1384
  β”œβ”€β”€ index.ts # Server entry point
1188
1385
  └── package.json
@@ -1194,40 +1391,41 @@ See [`vertex-ai/`](vertex-ai/) for setup and benchmarks.
1194
1391
 
1195
1392
  > **[View the full project board β†’](https://github.com/users/dcostenco/projects/1/views/1)**
1196
1393
 
1197
- ### βœ… v3.0.1 β€” Agent Identity & Brain Clean-up (Shipped!)
1394
+ ### βœ… v4.2 β€” Project Repo Registry + Knowledge Sync Rules (Shipped!)
1198
1395
 
1199
- See [What's New in v3.0.1](#whats-new-in-v301---agent-identity--brain-clean-up-) above.
1396
+ | Feature | Description |
1397
+ |---|---|
1398
+ | πŸ—‚οΈ **Project Repo Paths** | Dashboard UI to map projects to repo directories + `session_save_ledger` path validation. |
1399
+ | πŸ”„ **Universal Auto-Load** | Dynamic tool descriptions replace env var β€” dashboard is sole source of truth. |
1400
+ | 🏠 **Dashboard-First Config** | Removed `PRISM_AUTOLOAD_PROJECTS` env var override. |
1401
+ | πŸŒ‰ **Knowledge Sync Rules** | `knowledge_sync_rules` β€” auto-sync graduated insights to `.cursorrules` / `.clauderules` with idempotent sentinel markers. |
1200
1402
 
1201
- ### βœ… v3.0 β€” Agent Hivemind (Shipped!)
1403
+ ### βœ… v4.1 β€” Auto-Migration & Multi-Instance (Shipped!)
1202
1404
 
1203
- See [What's New in v3.0.0 β€” Agent Hivemind](#whats-new-in-v300---agent-hivemind-) above.
1405
+ See [What's in v4.1.0](#whats-in-v410--auto-migration--multi-instance-) above.
1204
1406
 
1205
- ### πŸ”œ v4.0 β€” Active Behavioral Memory (In Development)
1407
+ ### βœ… v4.0 β€” Behavioral Memory (Shipped!)
1206
1408
 
1207
- Evolves Prism from passive session logging to an **experience learning engine** that shapes agent behavior over time.
1409
+ See [What's in v4.0.0](#whats-in-v400--behavioral-memory-) above.
1208
1410
 
1209
- | Feature | Description |
1210
- |---------|-------------|
1211
- | **Structured Event Types** | Typed experience events (`correction`, `success`, `failure`, `learning`) with `confidence_score` (1-100) β€” agents don't just log, they learn |
1212
- | **Token-Budgeted Context Loading** | `max_tokens` param on `session_load_context` β€” guarantees constant cost regardless of DB size (1 token β‰ˆ 4 chars heuristic) |
1213
- | **`session_save_experience` Tool** | Dedicated tool for behavioral data: context β†’ action β†’ outcome β†’ correction. Auto-extracts keywords, seeds importance |
1214
- | **Insight Graduation System** | `knowledge_upvote` / `knowledge_downvote` tools. Importance β‰₯ 7 β†’ graduated rule. 30-day decay prevents bloat |
1215
- | **Behavioral Warnings** | High-importance corrections auto-surface as `[⚠️ BEHAVIORAL WARNINGS]` in `session_load_context` β€” agents proactively avoid past mistakes |
1411
+ ### βœ… v3.1 β€” Memory Lifecycle (Shipped!)
1412
+
1413
+ See [What's in v3.1.0](#whats-in-v310--memory-lifecycle-) above.
1414
+
1415
+ ### βœ… v3.0 β€” Agent Hivemind (Shipped!)
1416
+
1417
+ See [What's in v3.0.0](#whats-in-v300--agent-hivemind-) above.
1216
1418
 
1217
1419
  ### πŸš€ Future Ideas
1218
1420
 
1219
1421
  | Feature | Issue | Description |
1220
1422
  |---------|-------|-------------|
1221
- | **Role-Scoped Skills & Rules** | β€” | Each agent role (`dev`, `qa`, `pm`, etc.) gets its own persistent skill/rules document. Preloaded automatically at session start via `session_load_context`. Skills editable and uploadable from the Mind Palace Dashboard (βš™οΈ β†’ Skills tab per role). Stored in `configStorage` per-role key β€” backend already exists. |
1222
- | OpenTelemetry SDK Integration | [#6](https://github.com/dcostenco/prism-mcp/issues/6) | W3C-compliant tracing with Jaeger/Zipkin export |
1223
- | GDPR Right to Portability | [#7](https://github.com/dcostenco/prism-mcp/issues/7) | `session_export_memory` tool for Art. 20 compliance |
1224
- | Multi-agent CRDT Conflict Resolution | [#9](https://github.com/dcostenco/prism-mcp/issues/9) | Conflict-free replicated data types for concurrent agent edits |
1225
- | Memory Analytics Dashboard | [#10](https://github.com/dcostenco/prism-mcp/issues/10) | Usage trends, token costs, and memory health metrics |
1226
- | Pluggable LLM Providers | [#13](https://github.com/dcostenco/prism-mcp/issues/13) | Anthropic, OpenAI, Ollama provider adapters |
1227
- | VLM / OCR for Visual Memory | [#14](https://github.com/dcostenco/prism-mcp/issues/14) | Auto-extract text and insights from stored images |
1228
- | Automated Data Retention (TTL) | [#16](https://github.com/dcostenco/prism-mcp/issues/16) | Time-based memory expiration policies |
1229
- | Obsidian / Logseq Export Bridge | [#17](https://github.com/dcostenco/prism-mcp/issues/17) | Export memory to Markdown knowledge bases |
1230
- | Interactive Knowledge Graph Editor | [#19](https://github.com/dcostenco/prism-mcp/issues/19) | Visual graph editor inside the Mind Palace dashboard |
1423
+ | OpenTelemetry | [#6](https://github.com/dcostenco/prism-mcp/issues/6) | W3C tracing with Jaeger/Zipkin export |
1424
+ | GDPR Portability | [#7](https://github.com/dcostenco/prism-mcp/issues/7) | `session_export_memory` for Art. 20 |
1425
+ | CRDT Conflict Resolution | [#9](https://github.com/dcostenco/prism-mcp/issues/9) | Conflict-free types for concurrent edits |
1426
+ | Pluggable LLM Providers | [#13](https://github.com/dcostenco/prism-mcp/issues/13) | Anthropic, OpenAI, Ollama adapters |
1427
+ | VLM / OCR for Images | [#14](https://github.com/dcostenco/prism-mcp/issues/14) | Auto-extract text from stored images |
1428
+ | Knowledge Graph Editor | [#19](https://github.com/dcostenco/prism-mcp/issues/19) | Visual graph editor in Mind Palace |
1231
1429
 
1232
1430
  ### 🧰 Infrastructure & Stack
1233
1431
 
package/dist/config.js CHANGED
@@ -114,6 +114,14 @@ export const PRISM_DEBUG_LOGGING = process.env.PRISM_DEBUG_LOGGING === "true";
114
114
  // doesn't increase tool count.
115
115
  // Set PRISM_ENABLE_HIVEMIND=true to unlock the Agent Registry tools.
116
116
  export const PRISM_ENABLE_HIVEMIND = process.env.PRISM_ENABLE_HIVEMIND === "true";
117
+ // ─── v4.1: Auto-Load Projects ────────────────────────────────
118
+ // Auto-load is configured exclusively via the Mind Palace dashboard
119
+ // ("Auto-Load Projects" checkboxes in Settings). The setting is stored
120
+ // in prism-config.db and read at startup via getSettingSync().
121
+ //
122
+ // The PRISM_AUTOLOAD_PROJECTS env var has been removed β€” the dashboard
123
+ // is the single source of truth. This prevents mismatches between
124
+ // env var and dashboard values causing duplicate project loads.
117
125
  if (PRISM_AUTO_CAPTURE) {
118
126
  // Use console.error instead of debugLog here to prevent circular dependency
119
127
  if (PRISM_DEBUG_LOGGING) {