open-mem 0.11.0 → 0.12.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/CHANGELOG.md +7 -0
- package/README.md +73 -565
- package/dist/adapters/http/loopback.d.ts +3 -0
- package/dist/adapters/http/loopback.d.ts.map +1 -0
- package/dist/adapters/http/server.d.ts.map +1 -1
- package/dist/adapters/mcp/server.d.ts +0 -2
- package/dist/adapters/mcp/server.d.ts.map +1 -1
- package/dist/adapters/opencode/tools.d.ts.map +1 -1
- package/dist/ai/fallback-policy.d.ts +18 -0
- package/dist/ai/fallback-policy.d.ts.map +1 -0
- package/dist/ai/fallback.d.ts +3 -1
- package/dist/ai/fallback.d.ts.map +1 -1
- package/dist/ai/provider.d.ts +2 -1
- package/dist/ai/provider.d.ts.map +1 -1
- package/dist/claude-code.js +87 -87
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/contracts/api.d.ts +2 -120
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/schemas.d.ts +134 -0
- package/dist/contracts/schemas.d.ts.map +1 -0
- package/dist/cursor.js +87 -87
- package/dist/daemon.js +70 -70
- package/dist/db/observations.d.ts.map +1 -1
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -122
- package/dist/maintenance.js +43 -43
- package/dist/mcp.js +73 -73
- package/dist/modes/loader.d.ts.map +1 -1
- package/dist/modes/resolver.d.ts +21 -0
- package/dist/modes/resolver.d.ts.map +1 -0
- package/dist/platform-worker.d.ts.map +1 -1
- package/dist/search/orchestrator.d.ts +4 -13
- package/dist/search/orchestrator.d.ts.map +1 -1
- package/dist/search/registry.d.ts +19 -0
- package/dist/search/registry.d.ts.map +1 -0
- package/dist/search/strategies/filter-only.d.ts +4 -0
- package/dist/search/strategies/filter-only.d.ts.map +1 -0
- package/dist/search/strategies/hybrid.d.ts +3 -0
- package/dist/search/strategies/hybrid.d.ts.map +1 -0
- package/dist/search/strategies/semantic.d.ts +4 -0
- package/dist/search/strategies/semantic.d.ts.map +1 -0
- package/dist/search/strategies/types.d.ts +22 -0
- package/dist/search/strategies/types.d.ts.map +1 -0
- package/dist/services/readiness.d.ts +26 -0
- package/dist/services/readiness.d.ts.map +1 -0
- package/dist/services/setup-diagnostics.d.ts +23 -0
- package/dist/services/setup-diagnostics.d.ts.map +1 -0
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -1,622 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>open-mem</h1>
|
|
3
|
+
<p>Persistent memory for AI coding assistants.<br/>Captures what you do, compresses it, recalls it next session.</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
<a href="docs/getting-started.md">Documentation</a>
|
|
6
|
+
<span> • </span>
|
|
7
|
+
<a href="https://github.com/clopca/open-mem/issues">Issues</a>
|
|
8
|
+
<span> • </span>
|
|
9
|
+
<a href="CHANGELOG.md">Changelog</a>
|
|
10
|
+
</div>
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
<br/>
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/open-mem"><img src="https://img.shields.io/npm/v/open-mem.svg" alt="npm version"></a>
|
|
16
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
17
|
+
<a href="https://bun.sh"><img src="https://img.shields.io/badge/Bun-%3E%3D1.0-pink.svg" alt="Bun"></a>
|
|
18
|
+
</p>
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
- [Bun](https://bun.sh) >= 1.0
|
|
20
|
+
---
|
|
13
21
|
|
|
14
|
-
##
|
|
22
|
+
## What is open-mem?
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
open-mem is a plugin for [OpenCode](https://opencode.ai) that gives your AI assistant memory across sessions. It runs in the background — when you read files, run commands, or edit code, it captures what happened. During idle time, it compresses those captures into structured observations using AI. Next session, it injects a compact summary into the system prompt so the agent picks up where you left off.
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
bun add open-mem
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Configure OpenCode
|
|
23
|
-
|
|
24
|
-
Add `open-mem` to the `plugin` array in your OpenCode config (`~/.config/opencode/opencode.json`):
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"plugin": ["open-mem"]
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
> **Note**: If you already have plugins, just append `"open-mem"` to the existing array.
|
|
33
|
-
|
|
34
|
-
That's it. open-mem starts capturing from your next OpenCode session.
|
|
35
|
-
|
|
36
|
-
### Enable AI Compression (Optional)
|
|
37
|
-
|
|
38
|
-
For intelligent compression of observations, configure an AI provider:
|
|
39
|
-
|
|
40
|
-
**Google Gemini (default — free tier):**
|
|
41
|
-
```bash
|
|
42
|
-
# Get a free key at https://aistudio.google.com/apikey
|
|
43
|
-
export GOOGLE_GENERATIVE_AI_API_KEY=...
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**Anthropic:**
|
|
47
|
-
```bash
|
|
48
|
-
export OPEN_MEM_PROVIDER=anthropic
|
|
49
|
-
export ANTHROPIC_API_KEY=sk-ant-...
|
|
50
|
-
export OPEN_MEM_MODEL=claude-sonnet-4-20250514
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**AWS Bedrock:**
|
|
54
|
-
```bash
|
|
55
|
-
export OPEN_MEM_PROVIDER=bedrock
|
|
56
|
-
export OPEN_MEM_MODEL=us.anthropic.claude-sonnet-4-20250514-v1:0
|
|
57
|
-
# Uses AWS credentials from environment (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or AWS_PROFILE)
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**OpenAI** (requires `bun add @ai-sdk/openai`):
|
|
61
|
-
```bash
|
|
62
|
-
export OPEN_MEM_PROVIDER=openai
|
|
63
|
-
export OPENAI_API_KEY=sk-...
|
|
64
|
-
export OPEN_MEM_MODEL=gpt-4o
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**OpenRouter (100+ models):**
|
|
68
|
-
```bash
|
|
69
|
-
export OPEN_MEM_PROVIDER=openrouter
|
|
70
|
-
export OPENROUTER_API_KEY=sk-or-...
|
|
71
|
-
export OPEN_MEM_MODEL=google/gemini-2.5-flash-lite
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Auto-detection:** open-mem detects your provider from environment variables: `GOOGLE_GENERATIVE_AI_API_KEY` → Google, `ANTHROPIC_API_KEY` → Anthropic, AWS credentials → Bedrock, `OPENROUTER_API_KEY` → OpenRouter.
|
|
75
|
-
|
|
76
|
-
Without any provider configured, open-mem still works — it falls back to a basic metadata extractor that captures tool names, file paths, and output snippets.
|
|
77
|
-
|
|
78
|
-
## Why open-mem?
|
|
79
|
-
|
|
80
|
-
- **Native vector search** — sqlite-vec embedded directly in SQLite, no external vector database required
|
|
81
|
-
- **Knowledge graph** — automatic entity extraction with relationships, graph-augmented search via traversal
|
|
82
|
-
- **5 AI providers + fallback chain** — Google, Anthropic, AWS Bedrock, OpenAI, OpenRouter with automatic failover
|
|
83
|
-
- **Advanced search** — FTS5 full-text + vector similarity + Reciprocal Rank Fusion + graph traversal + reranking
|
|
84
|
-
- **Revision lineage** — immutable history with audit trail; revisions never overwrite, they supersede
|
|
85
|
-
- **User-level memory** — cross-project memories stored in a separate user-scoped database
|
|
86
|
-
- **Web dashboard** — 6-page management UI with real-time SSE streaming and config control plane
|
|
87
|
-
- **Multi-platform** — native adapters for OpenCode, Claude Code, and Cursor
|
|
88
|
-
- **MIT license** — enterprise-friendly, no AGPL restrictions
|
|
89
|
-
- **Well-tested** — 71 test files covering core logic, adapters, and integration scenarios
|
|
90
|
-
|
|
91
|
-
## Key Features
|
|
92
|
-
|
|
93
|
-
- 🧠 **Automatic observation capture** from tool executions and user prompts
|
|
94
|
-
- 🤖 **AI-powered compression** via Vercel AI SDK — supports Anthropic, AWS Bedrock, OpenAI, Google (optional — works without API key)
|
|
95
|
-
- 🔍 **Hybrid search** — FTS5 full-text search + vector embeddings with Reciprocal Rank Fusion
|
|
96
|
-
- 💡 **Progressive disclosure** with token-cost-aware context injection and ROI tracking
|
|
97
|
-
- 🔒 **Privacy controls** with `<private>` tag support
|
|
98
|
-
- 🛠️ **Nine custom tools**: memory.find, memory.create, memory.history, memory.get, memory.transfer.export, memory.transfer.import, memory.revise, memory.remove, memory.help
|
|
99
|
-
- 🌐 **MCP server mode** — expose memory tools to any MCP-compatible AI client
|
|
100
|
-
- 🔗 **Knowledge graph** — entity extraction with relationships, graph-augmented search
|
|
101
|
-
- 🔄 **Multi-platform** — native adapters for OpenCode, Claude Code, and Cursor
|
|
102
|
-
- 🌳 **Git worktree support** — shared memory across all worktrees
|
|
103
|
-
- 📂 **AGENTS.md generation** — auto-generated folder-level context on session end
|
|
104
|
-
- 📊 **Web dashboard** — 6-page management UI with real-time streaming
|
|
105
|
-
- 📦 **Import/export** — portable JSON for backup and transfer between machines
|
|
106
|
-
- ⚡ **Zero-config setup** — works out of the box
|
|
107
|
-
- 📁 **All data stored locally** in your project directory
|
|
108
|
-
|
|
109
|
-
## How It Works
|
|
110
|
-
|
|
111
|
-
open-mem runs in the background as an OpenCode plugin. When you use tools (reading files, running commands, editing code), it captures what happened. During idle time, it compresses those captures into structured observations using AI. At the start of your next session, it injects a compact memory index into the system prompt — so your agent knows what you've been working on.
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
┌──────────────────────────────────────────────────────────────┐
|
|
115
|
-
│ OpenCode │
|
|
116
|
-
│ │
|
|
117
|
-
│ tool.execute.after ───> [Tool Capture Hook] │
|
|
118
|
-
│ chat.message ─────────> [Chat Capture Hook] │
|
|
119
|
-
│ │ │
|
|
120
|
-
│ v │
|
|
121
|
-
│ [Pending Queue] │
|
|
122
|
-
│ │ │
|
|
123
|
-
│ session.idle ─────────> [Queue Processor] │
|
|
124
|
-
│ │ │
|
|
125
|
-
│ ┌─────┴─────┐ │
|
|
126
|
-
│ v v │
|
|
127
|
-
│ [AI Compressor] [Embedding Gen] │
|
|
128
|
-
│ │ │ │
|
|
129
|
-
│ v v │
|
|
130
|
-
│ [SQLite + FTS5 + Vectors] │
|
|
131
|
-
│ │ │
|
|
132
|
-
│ system.transform <─── [Context Injector + ROI Footer] │
|
|
133
|
-
│ │
|
|
134
|
-
│ session.end ──────────> [AGENTS.md Generation] │
|
|
135
|
-
│ │
|
|
136
|
-
│ memory.find ─────────> [Hybrid Search (FTS5 + Vector/RRF)] │
|
|
137
|
-
│ memory.create ───────────> [Direct Save] │
|
|
138
|
-
│ memory.history ───────> [Session Query] │
|
|
139
|
-
│ memory.get ─────────> [Full Observation Fetch] │
|
|
140
|
-
│ memory.transfer.export ─────────> [JSON Export] │
|
|
141
|
-
│ memory.transfer.import ─────────> [JSON Import] │
|
|
142
|
-
│ memory.revise ─────────> [Create Revision] │
|
|
143
|
-
│ memory.remove ─────────> [Tombstone Observation] │
|
|
144
|
-
│ memory.help ──────────> [Workflow Guidance] │
|
|
145
|
-
│ │
|
|
146
|
-
│ ┌──────────────────────────────────────────┐ │
|
|
147
|
-
│ │ MCP Server (stdin/stdout, JSON-RPC 2.0) │ │
|
|
148
|
-
│ │ Exposes tools to any MCP-compatible AI │ │
|
|
149
|
-
│ └──────────────────────────────────────────┘ │
|
|
150
|
-
└──────────────────────────────────────────────────────────────┘
|
|
151
|
-
```
|
|
26
|
+
It also works with **Claude Code**, **Cursor**, and any **MCP-compatible client**.
|
|
152
27
|
|
|
153
|
-
###
|
|
28
|
+
### How it works
|
|
154
29
|
|
|
155
|
-
|
|
30
|
+
You use tools, open-mem captures the outputs, AI compresses them into structured observations, and SQLite stores everything locally. Next session, a compact index gets injected into the system prompt so the agent picks up where you left off.
|
|
156
31
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
On `session.idle`, the queue processor batches pending observations and sends them to the configured AI provider for semantic compression. Each raw tool output is distilled into a structured observation with:
|
|
160
|
-
|
|
161
|
-
- Type classification (decision, bugfix, feature, refactor, discovery, change)
|
|
162
|
-
- Title and narrative summary
|
|
163
|
-
- Key facts extracted
|
|
164
|
-
- Concepts/tags for search
|
|
165
|
-
- Files involved
|
|
166
|
-
|
|
167
|
-
If no API key is set, a fallback compressor extracts basic metadata without AI.
|
|
168
|
-
|
|
169
|
-
### Progressive Disclosure
|
|
170
|
-
|
|
171
|
-
open-mem injects a compact index into the system prompt at session start. Each entry shows a type icon, title, token cost, and related files — giving the agent a map of what's in memory without consuming the full context window.
|
|
172
|
-
|
|
173
|
-
The agent sees *what* exists and decides *what to fetch* using `memory.find` and `memory.get`. This minimizes context window usage while providing full access to all stored observations.
|
|
174
|
-
|
|
175
|
-
Example of an injected index entry:
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
🔧 [refactor] Extract pricing logic (~120 tokens) — src/pricing.ts
|
|
179
|
-
💡 [discovery] FTS5 requires specific tokenizer config (~85 tokens)
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Session Compaction
|
|
183
|
-
|
|
184
|
-
During session compaction (`experimental.session.compacting`), open-mem injects memory context to preserve important information across compaction boundaries.
|
|
185
|
-
|
|
186
|
-
### Hybrid Search
|
|
187
|
-
|
|
188
|
-
When an AI provider with embedding support is configured (Google, OpenAI, or AWS Bedrock), open-mem generates vector embeddings for observations and uses Reciprocal Rank Fusion (RRF) to merge FTS5 text search with vector similarity search. This significantly improves search relevance.
|
|
189
|
-
|
|
190
|
-
Embeddings are generated automatically during observation processing. If no embedding model is available (e.g., Anthropic, which doesn't offer embeddings), search falls back to FTS5-only — no degradation.
|
|
191
|
-
|
|
192
|
-
### User Prompt Capture
|
|
193
|
-
|
|
194
|
-
open-mem captures user messages via the `chat.message` hook, storing them as searchable observations. This preserves the *intent* behind tool executions — so future sessions can understand not just what happened, but why.
|
|
195
|
-
|
|
196
|
-
### Git Worktree Support
|
|
197
|
-
|
|
198
|
-
open-mem automatically detects git worktrees and resolves to the main repository root. All worktrees share the same memory database, so observations from one worktree are available in all others.
|
|
199
|
-
|
|
200
|
-
### Folder-Level Context (AGENTS.md)
|
|
201
|
-
|
|
202
|
-
On session end, open-mem auto-generates `AGENTS.md` files in project folders that were touched during the session. These files contain a managed section (between `<!-- open-mem-context -->` tags) with recent activity, key concepts, and decisions for that folder.
|
|
203
|
-
|
|
204
|
-
User content outside the managed tags is preserved. Disable with `OPEN_MEM_FOLDER_CONTEXT=false`.
|
|
205
|
-
|
|
206
|
-
**Modes:**
|
|
207
|
-
- **Dispersed** (default): Creates `AGENTS.md` in each touched folder with activity for that folder
|
|
208
|
-
- **Single**: Creates one root file with all folder activity grouped by section headers (`### src/tools/`, `### src/hooks/`, etc.)
|
|
209
|
-
|
|
210
|
-
Configure via `OPEN_MEM_FOLDER_CONTEXT_MODE=single` or `OPEN_MEM_FOLDER_CONTEXT_FILENAME=CLAUDE.md`.
|
|
211
|
-
|
|
212
|
-
### Token ROI Tracking
|
|
213
|
-
|
|
214
|
-
The context injector includes a "Memory Economics" footer showing how much context compression saves: read cost vs. original discovery cost, with a savings percentage. This helps you understand the value of AI compression at a glance.
|
|
215
|
-
|
|
216
|
-
## Web Dashboard
|
|
217
|
-
|
|
218
|
-
open-mem includes a built-in web dashboard for memory management and observability. It provides six pages:
|
|
219
|
-
|
|
220
|
-
| Page | Description |
|
|
221
|
-
|------|-------------|
|
|
222
|
-
| **Timeline** | Chronological view of all observations with type filtering |
|
|
223
|
-
| **Sessions** | Browse past coding sessions and their observations |
|
|
224
|
-
| **Search** | Full-text and semantic search across all memories |
|
|
225
|
-
| **Stats** | Database statistics, observation counts, and memory economics |
|
|
226
|
-
| **Operations** | Queue status, maintenance actions, folder context management |
|
|
227
|
-
| **Settings** | Config control plane with live preview, mode presets, and audit log |
|
|
228
|
-
|
|
229
|
-
### Enable the Dashboard
|
|
32
|
+
## Quick start
|
|
230
33
|
|
|
231
34
|
```bash
|
|
232
|
-
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
Access at `http://localhost:3737` (configurable via `OPEN_MEM_DASHBOARD_PORT`). The dashboard streams real-time updates via Server-Sent Events — new observations appear as they are captured.
|
|
236
|
-
|
|
237
|
-
The [Config Control Plane](#config-control-plane) is accessible through the Settings page, allowing you to preview, apply, and roll back configuration changes without restarting.
|
|
238
|
-
|
|
239
|
-
## Custom Tools
|
|
240
|
-
|
|
241
|
-
### memory.find
|
|
242
|
-
|
|
243
|
-
Search through past observations and session summaries. Uses hybrid search (FTS5 + vector embeddings) when an embedding-capable provider is configured, or FTS5-only otherwise.
|
|
244
|
-
|
|
245
|
-
| Argument | Type | Required | Description |
|
|
246
|
-
|----------|------|----------|-------------|
|
|
247
|
-
| `query` | string | yes | Search query (keywords, phrases, file paths) |
|
|
248
|
-
| `type` | enum | no | Filter by type: `decision`, `bugfix`, `feature`, `refactor`, `discovery`, `change` |
|
|
249
|
-
| `limit` | number | no | Max results (1–50, default: 10) |
|
|
250
|
-
|
|
251
|
-
### memory.create
|
|
252
|
-
|
|
253
|
-
Manually save an important observation to memory.
|
|
254
|
-
|
|
255
|
-
| Argument | Type | Required | Description |
|
|
256
|
-
|----------|------|----------|-------------|
|
|
257
|
-
| `title` | string | yes | Brief title (max 80 chars) |
|
|
258
|
-
| `type` | enum | yes | Observation type: `decision`, `bugfix`, `feature`, `refactor`, `discovery`, `change` |
|
|
259
|
-
| `narrative` | string | yes | Detailed description of what to remember |
|
|
260
|
-
| `concepts` | string[] | no | Related concepts/tags |
|
|
261
|
-
| `files` | string[] | no | Related file paths |
|
|
262
|
-
|
|
263
|
-
### memory.history
|
|
264
|
-
|
|
265
|
-
View a timeline of past coding sessions, or center the view around a specific observation for cross-session navigation.
|
|
266
|
-
|
|
267
|
-
| Argument | Type | Required | Description |
|
|
268
|
-
|----------|------|----------|-------------|
|
|
269
|
-
| `limit` | number | no | Number of recent sessions (1–20, default: 5) |
|
|
270
|
-
| `sessionId` | string | no | Show details for a specific session |
|
|
271
|
-
| `anchor` | string | no | Observation ID to center the timeline around (cross-session view) |
|
|
272
|
-
| `depthBefore` | number | no | Observations to show before anchor (0–20, default: 5) |
|
|
273
|
-
| `depthAfter` | number | no | Observations to show after anchor (0–20, default: 5) |
|
|
274
|
-
|
|
275
|
-
### memory.get
|
|
276
|
-
|
|
277
|
-
Fetch full observation details by ID. Use after `memory.find` to get complete narratives, facts, concepts, and file lists for specific observations.
|
|
278
|
-
|
|
279
|
-
| Argument | Type | Required | Description |
|
|
280
|
-
|----------|------|----------|-------------|
|
|
281
|
-
| `ids` | string[] | yes | Observation IDs to fetch |
|
|
282
|
-
| `limit` | number | no | Maximum number of results (1–50, default: 10) |
|
|
283
|
-
|
|
284
|
-
### memory.transfer.export
|
|
285
|
-
|
|
286
|
-
Export project memories (observations and session summaries) as portable JSON for backup or transfer between machines.
|
|
287
|
-
|
|
288
|
-
| Argument | Type | Required | Description |
|
|
289
|
-
|----------|------|----------|-------------|
|
|
290
|
-
| `format` | enum | no | Export format (currently `json` only) |
|
|
291
|
-
| `type` | enum | no | Filter by observation type |
|
|
292
|
-
| `limit` | number | no | Maximum observations to export |
|
|
293
|
-
|
|
294
|
-
### memory.transfer.import
|
|
295
|
-
|
|
296
|
-
Import observations and summaries from a JSON export. Skips duplicates by ID.
|
|
297
|
-
|
|
298
|
-
| Argument | Type | Required | Description |
|
|
299
|
-
|----------|------|----------|-------------|
|
|
300
|
-
| `data` | string | yes | JSON string from a memory.transfer.export output |
|
|
301
|
-
|
|
302
|
-
### memory.revise
|
|
303
|
-
|
|
304
|
-
Update an existing project observation by ID.
|
|
305
|
-
This is immutable: the update creates a new revision and supersedes the previous active revision.
|
|
306
|
-
|
|
307
|
-
| Argument | Type | Required | Description |
|
|
308
|
-
|----------|------|----------|-------------|
|
|
309
|
-
| `id` | string | yes | Observation ID to update |
|
|
310
|
-
| `title` | string | no | Updated title |
|
|
311
|
-
| `narrative` | string | no | Updated narrative |
|
|
312
|
-
| `type` | enum | no | Updated observation type |
|
|
313
|
-
| `concepts` | string[] | no | Updated concepts/tags |
|
|
314
|
-
| `importance` | number | no | Updated importance (1-5) |
|
|
315
|
-
|
|
316
|
-
### memory.remove
|
|
317
|
-
|
|
318
|
-
Tombstone an existing project observation by ID.
|
|
319
|
-
This is a soft delete: the observation is hidden from default recall/search but retained for lineage.
|
|
320
|
-
|
|
321
|
-
| Argument | Type | Required | Description |
|
|
322
|
-
|----------|------|----------|-------------|
|
|
323
|
-
| `id` | string | yes | Observation ID to delete |
|
|
324
|
-
|
|
325
|
-
### memory.help
|
|
326
|
-
|
|
327
|
-
Returns a short workflow guide for using memory tools effectively:
|
|
328
|
-
`memory.find` -> `memory.history` -> `memory.get`, plus write/edit/import/export patterns.
|
|
329
|
-
|
|
330
|
-
## MCP Server Mode
|
|
331
|
-
|
|
332
|
-
open-mem includes a standalone MCP (Model Context Protocol) server that exposes memory tools to any MCP-compatible AI client — not just OpenCode.
|
|
333
|
-
|
|
334
|
-
### Setup
|
|
335
|
-
|
|
336
|
-
Run the MCP server:
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
bunx open-mem-mcp --project /path/to/your/project
|
|
35
|
+
bun add open-mem
|
|
340
36
|
```
|
|
341
37
|
|
|
342
|
-
|
|
38
|
+
Add it to your OpenCode config (`~/.config/opencode/opencode.json`):
|
|
343
39
|
|
|
344
40
|
```json
|
|
345
41
|
{
|
|
346
|
-
"
|
|
347
|
-
"open-mem": {
|
|
348
|
-
"command": "bunx",
|
|
349
|
-
"args": ["open-mem-mcp", "--project", "/path/to/your/project"]
|
|
350
|
-
}
|
|
351
|
-
}
|
|
42
|
+
"plugin": ["open-mem"]
|
|
352
43
|
}
|
|
353
44
|
```
|
|
354
45
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
Lifecycle behavior:
|
|
358
|
-
- `initialize` negotiates protocol version (default `2024-11-05`)
|
|
359
|
-
- `notifications/initialized` is supported
|
|
360
|
-
- strict mode requires initialize before `tools/list`/`tools/call`
|
|
46
|
+
That's it. open-mem starts capturing from your next session.
|
|
361
47
|
|
|
362
|
-
|
|
48
|
+
### AI compression (optional)
|
|
363
49
|
|
|
364
|
-
open-mem
|
|
50
|
+
By default, open-mem uses a basic metadata extractor. For semantic compression, add an AI provider:
|
|
365
51
|
|
|
366
52
|
```bash
|
|
367
|
-
#
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
# Cursor adapter worker
|
|
371
|
-
bunx open-mem-cursor --project /path/to/project
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
Each line on stdin must be one JSON event. The workers normalize events into open-mem's shared platform schema and reuse the same capture/lifecycle pipeline used by OpenCode hooks.
|
|
375
|
-
Each line receives a JSON response on stdout:
|
|
376
|
-
- success: `{"ok":true,"code":"OK","ingested":true}`
|
|
377
|
-
- parse error: `{"ok":false,"code":"INVALID_JSON",...}`
|
|
378
|
-
- schema mismatch: `{"ok":false,"code":"UNSUPPORTED_EVENT",...}`
|
|
379
|
-
|
|
380
|
-
Optional worker commands:
|
|
381
|
-
- `{"command":"flush"}` to force queue processing
|
|
382
|
-
- `{"command":"health"}` to get worker queue status
|
|
383
|
-
- `{"command":"shutdown"}` to request graceful shutdown
|
|
384
|
-
|
|
385
|
-
Optional HTTP bridge mode:
|
|
386
|
-
|
|
387
|
-
```bash
|
|
388
|
-
bunx open-mem-claude-code --project /path/to/project --http-port 37877
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
Endpoints:
|
|
392
|
-
- `POST /v1/events` (same envelope/response semantics as stdio)
|
|
393
|
-
- `GET /v1/health`
|
|
394
|
-
|
|
395
|
-
Enable these adapters via env vars:
|
|
396
|
-
- `OPEN_MEM_PLATFORM_CLAUDE_CODE=true`
|
|
397
|
-
- `OPEN_MEM_PLATFORM_CURSOR=true`
|
|
398
|
-
|
|
399
|
-
## Data Model Notes
|
|
400
|
-
|
|
401
|
-
- Local-first storage remains project-local in `.open-mem/` (plus optional user-level DB).
|
|
402
|
-
- `memory.revise` uses revision lineage, not in-place mutation.
|
|
403
|
-
- `memory.remove` uses tombstones, not hard delete, for safer auditability and conflict handling.
|
|
404
|
-
- Pre-`0.7.0` databases are not auto-migrated to lineage semantics. Use:
|
|
405
|
-
|
|
406
|
-
```bash
|
|
407
|
-
bunx open-mem-maintenance reset-db --project /path/to/your/project
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
## Config Control Plane
|
|
411
|
-
|
|
412
|
-
open-mem now supports a canonical project config file at `.open-mem/config.json`, in addition to environment variables.
|
|
413
|
-
|
|
414
|
-
Precedence:
|
|
415
|
-
1. defaults
|
|
416
|
-
2. `.open-mem/config.json`
|
|
417
|
-
3. environment variables
|
|
418
|
-
4. programmatic overrides
|
|
419
|
-
|
|
420
|
-
Dashboard config APIs:
|
|
421
|
-
- `GET /api/config/schema`
|
|
422
|
-
- `GET /api/config/effective`
|
|
423
|
-
- `POST /api/config/preview`
|
|
424
|
-
- `PATCH /api/config`
|
|
425
|
-
- `GET /api/modes`
|
|
426
|
-
- `POST /api/modes/:id/apply`
|
|
427
|
-
- `GET /api/health`
|
|
428
|
-
- `GET /api/metrics`
|
|
429
|
-
|
|
430
|
-
## Configuration
|
|
431
|
-
|
|
432
|
-
open-mem works out of the box with zero configuration. All settings can be customized via environment variables:
|
|
433
|
-
|
|
434
|
-
| Variable | Default | Description |
|
|
435
|
-
|----------|---------|-------------|
|
|
436
|
-
| `OPEN_MEM_PROVIDER` | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai`, `openrouter` |
|
|
437
|
-
| `GOOGLE_GENERATIVE_AI_API_KEY` | — | API key for Google Gemini provider ([free](https://aistudio.google.com/apikey)) |
|
|
438
|
-
| `ANTHROPIC_API_KEY` | — | API key for Anthropic provider |
|
|
439
|
-
| `OPENAI_API_KEY` | — | API key for OpenAI provider |
|
|
440
|
-
| `OPENROUTER_API_KEY` | — | API key for OpenRouter provider |
|
|
441
|
-
| `OPEN_MEM_FALLBACK_PROVIDERS` | — | Comma-separated fallback providers (e.g., `google,anthropic,openai`) |
|
|
442
|
-
| `OPEN_MEM_DB_PATH` | `.open-mem/memory.db` | Path to SQLite database |
|
|
443
|
-
| `OPEN_MEM_MODEL` | `gemini-2.5-flash-lite` | Model for AI compression |
|
|
444
|
-
| `OPEN_MEM_MAX_CONTEXT_TOKENS` | `4000` | Token budget for injected context |
|
|
445
|
-
| `OPEN_MEM_COMPRESSION` | `true` | Set to `false` to disable AI compression |
|
|
446
|
-
| `OPEN_MEM_CONTEXT_INJECTION` | `true` | Set to `false` to disable context injection |
|
|
447
|
-
| `OPEN_MEM_IGNORED_TOOLS` | — | Comma-separated tool names to ignore (e.g. `Bash,Glob`) |
|
|
448
|
-
| `OPEN_MEM_BATCH_SIZE` | `5` | Observations per processing batch |
|
|
449
|
-
| `OPEN_MEM_RETENTION_DAYS` | `90` | Delete observations older than N days (0 = forever) |
|
|
450
|
-
| `OPEN_MEM_LOG_LEVEL` | `warn` | Log verbosity: `debug`, `info`, `warn`, `error` |
|
|
451
|
-
| `OPEN_MEM_CONTEXT_SHOW_TOKEN_COSTS` | `true` | Show token costs in context index entries |
|
|
452
|
-
| `OPEN_MEM_CONTEXT_TYPES` | all | Observation types to include in context injection |
|
|
453
|
-
| `OPEN_MEM_CONTEXT_FULL_COUNT` | `3` | Number of recent observations shown in full |
|
|
454
|
-
| `OPEN_MEM_MAX_OBSERVATIONS` | `50` | Maximum observations to consider for context |
|
|
455
|
-
| `OPEN_MEM_FOLDER_CONTEXT` | `true` | Set to `false` to disable AGENTS.md generation |
|
|
456
|
-
| `OPEN_MEM_FOLDER_CONTEXT_MAX_DEPTH` | `5` | Max folder depth for AGENTS.md generation |
|
|
457
|
-
| `OPEN_MEM_FOLDER_CONTEXT_MODE` | `dispersed` | Context file mode: `dispersed` (per-folder) or `single` (one root file) |
|
|
458
|
-
| `OPEN_MEM_FOLDER_CONTEXT_FILENAME` | `AGENTS.md` | Filename for context files (e.g. `CLAUDE.md` for Claude Code) |
|
|
459
|
-
| `OPEN_MEM_PLATFORM_OPENCODE` | `true` | Set to `false` to disable OpenCode adapter |
|
|
460
|
-
| `OPEN_MEM_PLATFORM_CLAUDE_CODE` | `false` | Set to `true` to enable Claude Code adapter surface |
|
|
461
|
-
| `OPEN_MEM_PLATFORM_CURSOR` | `false` | Set to `true` to enable Cursor adapter surface |
|
|
462
|
-
| `OPEN_MEM_MCP_COMPAT_MODE` | `strict` | MCP mode: `strict` or `legacy` |
|
|
463
|
-
| `OPEN_MEM_MCP_PROTOCOL_VERSION` | `2024-11-05` | Preferred MCP protocol version |
|
|
464
|
-
| `OPEN_MEM_MCP_SUPPORTED_PROTOCOLS` | `2024-11-05` | Comma-separated supported protocol versions |
|
|
465
|
-
| `OPEN_MEM_DASHBOARD` | `false` | Set to `true` to enable the web dashboard |
|
|
466
|
-
| `OPEN_MEM_DASHBOARD_PORT` | `3737` | Dashboard HTTP port |
|
|
467
|
-
|
|
468
|
-
<details>
|
|
469
|
-
<summary><strong>Programmatic Configuration Reference</strong></summary>
|
|
470
|
-
|
|
471
|
-
If you need to configure open-mem programmatically (e.g. for testing or custom integrations), these are the full config options:
|
|
472
|
-
|
|
473
|
-
| Option | Type | Default | Description |
|
|
474
|
-
|--------|------|---------|-------------|
|
|
475
|
-
| `dbPath` | string | `.open-mem/memory.db` | SQLite database file path |
|
|
476
|
-
| `provider` | string | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai`, `openrouter` |
|
|
477
|
-
| `apiKey` | string | `undefined` | Provider API key |
|
|
478
|
-
| `model` | string | `gemini-2.5-flash-lite` | Model for compression |
|
|
479
|
-
| `maxTokensPerCompression` | number | `1024` | Max tokens per compression response |
|
|
480
|
-
| `compressionEnabled` | boolean | `true` | Enable AI compression |
|
|
481
|
-
| `contextInjectionEnabled` | boolean | `true` | Enable context injection |
|
|
482
|
-
| `maxContextTokens` | number | `4000` | Token budget for system prompt injection |
|
|
483
|
-
| `batchSize` | number | `5` | Observations per batch |
|
|
484
|
-
| `batchIntervalMs` | number | `30000` | Batch processing interval (ms) |
|
|
485
|
-
| `ignoredTools` | string[] | `[]` | Tool names to skip |
|
|
486
|
-
| `minOutputLength` | number | `50` | Minimum output length to capture |
|
|
487
|
-
| `maxIndexEntries` | number | `20` | Max observation index entries in context |
|
|
488
|
-
| `sensitivePatterns` | string[] | `[]` | Additional regex patterns to redact |
|
|
489
|
-
| `retentionDays` | number | `90` | Data retention period (0 = forever) |
|
|
490
|
-
| `maxDatabaseSizeMb` | number | `500` | Maximum database size |
|
|
491
|
-
| `logLevel` | string | `warn` | Log level: `debug`, `info`, `warn`, `error` |
|
|
492
|
-
| `folderContextEnabled` | boolean | `true` | Auto-generate AGENTS.md in active folders |
|
|
493
|
-
| `folderContextMaxDepth` | number | `5` | Max folder depth from project root |
|
|
494
|
-
| `folderContextMode` | string | `dispersed` | Context file mode: `dispersed` (per-folder) or `single` (one root file) |
|
|
495
|
-
| `folderContextFilename` | string | `AGENTS.md` | Filename for context files (e.g. `CLAUDE.md` for Claude Code) |
|
|
496
|
-
| `fallbackProviders` | string[] | `undefined` | Comma-separated provider names for automatic failover (e.g., `["google","anthropic"]`) |
|
|
497
|
-
|
|
498
|
-
</details>
|
|
499
|
-
|
|
500
|
-
## Privacy & Security
|
|
501
|
-
|
|
502
|
-
### Local Data Storage
|
|
503
|
-
|
|
504
|
-
All data is stored locally in your project's `.open-mem/` directory. No data leaves your machine except when AI compression is enabled.
|
|
505
|
-
|
|
506
|
-
### AI Provider
|
|
507
|
-
|
|
508
|
-
When AI compression is enabled, tool outputs are sent to the configured AI provider for compression. Disable with `OPEN_MEM_COMPRESSION=false` to keep everything fully local.
|
|
509
|
-
|
|
510
|
-
### Automatic Redaction
|
|
511
|
-
|
|
512
|
-
open-mem automatically redacts common sensitive patterns before storage:
|
|
513
|
-
|
|
514
|
-
- API keys and tokens (e.g. `sk-ant-...`, `ghp_...`, `Bearer ...`)
|
|
515
|
-
- Passwords and secrets
|
|
516
|
-
- Environment variable values matching sensitive patterns
|
|
517
|
-
- Custom patterns via the `sensitivePatterns` config option
|
|
518
|
-
|
|
519
|
-
### `<private>` Tags
|
|
520
|
-
|
|
521
|
-
Wrap any content in `<private>...</private>` tags to exclude it from memory entirely. Private blocks are stripped before observation capture — they never reach the database or the AI provider.
|
|
522
|
-
|
|
523
|
-
```
|
|
524
|
-
<private>
|
|
525
|
-
This content will not be stored in memory.
|
|
526
|
-
</private>
|
|
53
|
+
# Google Gemini — free tier available
|
|
54
|
+
export GOOGLE_GENERATIVE_AI_API_KEY=...
|
|
527
55
|
```
|
|
528
56
|
|
|
529
|
-
|
|
57
|
+
Also supports Anthropic, AWS Bedrock, OpenAI, and OpenRouter. Auto-detects from environment variables. See [Configuration](docs/configuration.md) for all providers.
|
|
530
58
|
|
|
531
|
-
|
|
59
|
+
## Features
|
|
532
60
|
|
|
533
|
-
|
|
534
|
-
echo '.open-mem/' >> .gitignore
|
|
535
|
-
```
|
|
61
|
+
**Search & retrieval** — hybrid search combining FTS5 full-text, vector embeddings (via sqlite-vec), knowledge graph traversal, and Reciprocal Rank Fusion. No external vector database needed.
|
|
536
62
|
|
|
537
|
-
|
|
63
|
+
**AI compression** — raw tool outputs distilled into typed observations (decision, bugfix, feature, refactor, discovery, change) with titles, narratives, concepts, and importance scores. 5 providers with automatic fallback chain.
|
|
538
64
|
|
|
539
|
-
|
|
65
|
+
**Progressive disclosure** — a token-budgeted index is injected into the system prompt. The agent sees *what* exists and decides *what to fetch*. Typical compression ratio: ~96%.
|
|
540
66
|
|
|
541
|
-
|
|
67
|
+
**Knowledge graph** — automatic entity extraction with relationships. Graph-augmented search finds connections across sessions that keyword search would miss.
|
|
542
68
|
|
|
543
|
-
|
|
544
|
-
# Google Gemini (default — free tier)
|
|
545
|
-
# Get a free key at https://aistudio.google.com/apikey
|
|
546
|
-
export GOOGLE_GENERATIVE_AI_API_KEY=...
|
|
69
|
+
**Revision lineage** — observations are immutable. Updates create new revisions that supersede the previous one. Deletes are tombstones. Full audit trail.
|
|
547
70
|
|
|
548
|
-
|
|
549
|
-
export OPEN_MEM_PROVIDER=anthropic
|
|
550
|
-
export ANTHROPIC_API_KEY=sk-ant-...
|
|
71
|
+
**9 memory tools** — `memory.find`, `memory.create`, `memory.history`, `memory.get`, `memory.revise`, `memory.remove`, `memory.transfer.export`, `memory.transfer.import`, `memory.help`. See [Tools reference](docs/tools.md).
|
|
551
72
|
|
|
552
|
-
|
|
553
|
-
export OPEN_MEM_PROVIDER=bedrock
|
|
554
|
-
export OPEN_MEM_MODEL=us.anthropic.claude-sonnet-4-20250514-v1:0
|
|
555
|
-
```
|
|
73
|
+
**AGENTS.md generation** — auto-generates folder-level context files on session end so the agent has project awareness even without the plugin loaded.
|
|
556
74
|
|
|
557
|
-
|
|
75
|
+
**Web dashboard** — timeline, sessions, search, stats, operations, and settings. Real-time updates via SSE. Config control plane with live preview and rollback.
|
|
558
76
|
|
|
559
|
-
|
|
77
|
+
**Privacy-first** — all data stored locally in `.open-mem/`. Automatic redaction of API keys, tokens, passwords. `<private>` tags to exclude content entirely. See [Privacy & Security](docs/privacy.md).
|
|
560
78
|
|
|
561
|
-
|
|
562
|
-
rm -rf .open-mem/
|
|
563
|
-
```
|
|
79
|
+
## Multi-platform
|
|
564
80
|
|
|
565
|
-
|
|
81
|
+
open-mem isn't limited to OpenCode. Dedicated adapters bring the same capabilities to other tools:
|
|
566
82
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
83
|
+
| Platform | Integration |
|
|
84
|
+
|----------|------------|
|
|
85
|
+
| **OpenCode** | Native plugin (hooks + tools) |
|
|
86
|
+
| **Claude Code** | `bunx open-mem-claude-code --project /path/to/project` |
|
|
87
|
+
| **Cursor** | `bunx open-mem-cursor --project /path/to/project` |
|
|
88
|
+
| **Any MCP client** | `bunx open-mem-mcp --project /path/to/project` |
|
|
571
89
|
|
|
572
|
-
|
|
90
|
+
See [Platform Adapters](docs/platforms.md) for setup details.
|
|
573
91
|
|
|
574
|
-
|
|
92
|
+
## Dashboard
|
|
575
93
|
|
|
576
94
|
```bash
|
|
577
|
-
export
|
|
578
|
-
|
|
95
|
+
export OPEN_MEM_DASHBOARD=true
|
|
96
|
+
# Access at http://localhost:3737
|
|
579
97
|
```
|
|
580
98
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
1. Remove `"open-mem"` from the `plugin` array in your OpenCode config (`~/.config/opencode/opencode.json`).
|
|
584
|
-
|
|
585
|
-
2. Remove the package:
|
|
586
|
-
```bash
|
|
587
|
-
bun remove open-mem
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
3. Optionally, delete stored memory data:
|
|
591
|
-
```bash
|
|
592
|
-
rm -rf .open-mem/
|
|
593
|
-
```
|
|
99
|
+
Six pages: Timeline, Sessions, Search, Stats, Operations, Settings. The Settings page doubles as a config control plane — preview changes, apply them, roll back if needed.
|
|
594
100
|
|
|
595
101
|
## Documentation
|
|
596
102
|
|
|
597
|
-
- [Getting Started](docs/getting-started.md) — installation
|
|
598
|
-
- [Architecture](docs/architecture.md) — internal design
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
103
|
+
- [Getting Started](docs/getting-started.md) — installation and first steps
|
|
104
|
+
- [Architecture](docs/architecture.md) — internal design and data flow
|
|
105
|
+
- [Memory Tools](docs/tools.md) — all 9 tools with arguments and examples
|
|
106
|
+
- [Search](docs/search.md) — how hybrid search works
|
|
107
|
+
- [Configuration](docs/configuration.md) — environment variables and config file
|
|
108
|
+
- [Privacy & Security](docs/privacy.md) — data handling and redaction
|
|
109
|
+
- [Platform Adapters](docs/platforms.md) — Claude Code, Cursor, MCP server
|
|
110
|
+
- [Troubleshooting](docs/troubleshooting.md) — common issues and fixes
|
|
111
|
+
|
|
112
|
+
## Comparison
|
|
113
|
+
|
|
114
|
+
| | open-mem | Typical alternatives |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| Vector search | Embedded (sqlite-vec) | External service |
|
|
117
|
+
| AI providers | 5 + fallback chain | 1–3 |
|
|
606
118
|
| Search | FTS5 + Vector + RRF + Graph | FTS5 only |
|
|
607
|
-
| Knowledge graph |
|
|
119
|
+
| Knowledge graph | Yes | No |
|
|
608
120
|
| Revision history | Immutable lineage | No |
|
|
609
|
-
| Dashboard |
|
|
121
|
+
| Dashboard | Web UI with SSE | No |
|
|
122
|
+
| Data storage | Project-local | Global |
|
|
610
123
|
| License | MIT | AGPL / proprietary |
|
|
611
|
-
| Data locality | Project-local `.open-mem/` | Global |
|
|
612
124
|
|
|
613
125
|
## Contributing
|
|
614
126
|
|
|
615
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup
|
|
616
|
-
|
|
617
|
-
## Changelog
|
|
618
|
-
|
|
619
|
-
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
|
|
127
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
620
128
|
|
|
621
129
|
## License
|
|
622
130
|
|