remem-mcp 0.6.8 → 0.7.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
@@ -5,12 +5,26 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![Benchmark](https://img.shields.io/badge/AMB-100%2F100%2F100-brightgreen)](https://github.com/tinhien11/remem-mcp)
7
7
 
8
- > Your coding agent stops repeating the same mistakes.
8
+ > Your coding agent stops repeating the same mistakes — and stops burning tokens on verbose tool logs.
9
9
 
10
- Local memory that survives context compaction — learns from every error, injects fixes before the next attempt, and syncs to your git repo so your whole team shares it.
10
+ Local memory that survives context compaction — learns from every error, injects fixes before the next attempt, and syncs to your git repo so your whole team shares it. Now with **symbolic short-term memory** (Mermaid canvas, 92% token reduction), **memory proxy** (zero-code LLM integration), and **skill auto-extraction** (reusable SOPs from completed tasks).
11
11
 
12
12
  **One command setup. No API key. No cloud. No database server. Just a SQLite file.**
13
13
 
14
+ <video src="https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/demo-learning-loop.mp4" controls muted width="100%"></video>
15
+
16
+ ![Demo: Error learning loop](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/demo-learning-loop.gif)
17
+
18
+ ### See it in action
19
+
20
+ | Error learning loop | CodeGraph search | Web viewer |
21
+ |---|---|---|
22
+ | ![Error learning](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/demo-learning-loop.gif) | ![CodeGraph](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/demo-codegraph.gif) | ![Viewer](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/viewer-demo.gif) |
23
+
24
+ | Viewer: overview | CodeGraph: callers | CodeGraph: search |
25
+ |---|---|---|
26
+ | ![Overview](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/viewer-overview.png) | ![Callers](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/viewer-codegraph-callers.png) | ![Search](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/viewer-codegraph-search.png) |
27
+
14
28
  ---
15
29
 
16
30
  ## Install
@@ -19,14 +33,16 @@ Local memory that survives context compaction — learns from every error, injec
19
33
  npx remem-mcp setup
20
34
  ```
21
35
 
22
- Auto-detects Claude Code, Cursor, Devin, Codex. Registers MCP server + hooks. Restart your agent.
36
+ That's it. Auto-detects Claude Code, Cursor, Devin, Codex. Registers MCP server + hooks. Restart your agent.
23
37
 
24
38
  ```bash
25
- npx remem-mcp demo # Live demo: real build, real errors, real hooks
26
- npx remem-mcp demo-codegraph # Live CodeGraph demo on facebook/react
27
- npx remem-mcp status # One dashboard: everything at a glance
39
+ npx remem-mcp demo # Live demo: real build, real errors, real hooks
40
+ npx remem-mcp demo-codegraph # Live CodeGraph demo on facebook/react
41
+ npx remem-mcp status # One dashboard: everything at a glance
28
42
  ```
29
43
 
44
+ The demo creates a real TypeScript project, runs real `npm run build`, captures real TS2307 errors, and shows the full learning loop — capture → inject → fix → zero retries. No hardcoded strings.
45
+
30
46
  ---
31
47
 
32
48
  ## Quick start (after install)
@@ -51,13 +67,17 @@ npx remem-mcp status # verify: hooks ✓, DB ✓, CodeGraph ✓
51
67
  │ AI Agent │
52
68
  │ (Claude Code / Devin / Cursor) │
53
69
  └────────┬──────────────────────────┬──────────────┘
54
- │ MCP tools (15) │ Hooks (auto)
70
+ │ MCP tools (45) │ Hooks (auto)
55
71
  ▼ ▼
56
72
  ┌──────────────────┐ ┌────────────────────┐
57
- │ recall() │ │ SessionStart │──▶ inject L2/L3 + skills
73
+ │ recall() │ │ SessionStart │──▶ inject L2/L3 + skills + canvas
58
74
  │ capture() │ │ UserPromptSubmit │──▶ inject BM25 match
59
- │ codegraph_* │ │ Stop │──▶ spawn worker
60
- │ wiki_* │ │ PostCompact │──▶ save checkpoint
75
+ │ codegraph_* │ │ PreToolUse │──▶ inject canvas + skills + errors
76
+ │ wiki_* │ │ PostToolUse │──▶ offload to refs + canvas node
77
+ │ canvas_get │ │ Stop │──▶ spawn worker + skill extraction
78
+ │ ref_read │ │ PostCompact │──▶ save checkpoint
79
+ │ skill_* │ │ │
80
+ │ proxy (HTTP) │ │ │
61
81
  └────────┬─────────┘ └─────────┬──────────┘
62
82
  │ │
63
83
  ▼ ▼
@@ -69,6 +89,8 @@ npx remem-mcp status # verify: hooks ✓, DB ✓, CodeGraph ✓
69
89
  │ │
70
90
  │ CodeGraph: symbols + calls + imports │
71
91
  │ Wiki: markdown docs + ADRs │
92
+ │ Canvas: Mermaid nodes + edges + refs │
93
+ │ Skills: trigger conditions + steps + validation │
72
94
  └───────────────────────────────────────────────────┘
73
95
  ```
74
96
 
@@ -94,15 +116,19 @@ Structural code indexing via tree-sitter (9 languages: TS/JS/Python/Go/Rust/Java
94
116
 
95
117
  ## Why it's different
96
118
 
97
- | | remem-mcp | Mem0 | Claude MEMORY.md | Mneme |
98
- |---|---|---|---|---|
99
- | **Survives compaction** | Yes — PreCompact hook | Yes — cloud | No — 200-line cap | Yes — PreCompact hook |
100
- | **Learns from errors** | Yes — auto-capture + inject | No | No | No |
101
- | **Semantic search** | Hybrid BM25 + sqlite-vec | Vector only | No | Vector + graph |
102
- | **CodeGraph** | Yes — 6-strategy call resolution | No | No | No |
103
- | **Setup** | 1 command | API key + cloud | Built-in | Build from source |
104
- | **API key** | No | Yes | No | No |
105
- | **Cost** | Free | $19–249/mo | Free | Free |
119
+ | | remem-mcp | Mem0 | Claude MEMORY.md | Mneme | TencentDB |
120
+ |---|---|---|---|---|---|
121
+ | **Survives compaction** | Yes — PreCompact hook saves checkpoint, re-injects after | Yes — cloud store | No — 200-line cap, silent truncation | Yes — PreCompact hook | Yes |
122
+ | **Learns from errors** | Yes — auto-captures, injects fixes | No | No | No | No |
123
+ | **Symbolic short-term memory** | Yes Mermaid canvas, 92% token reduction | No | No | No | Yes 61% on WideSearch |
124
+ | **Memory proxy** | Yes — OpenAI + Anthropic, zero-code | No | No | No | Yes |
125
+ | **Skill auto-extraction** | Yes rule-based, no LLM needed | No | No | No | Yes — LLM-based |
126
+ | **Semantic search** | Hybrid BM25 + sqlite-vec | Vector only | No — LLM filename picker, max 5 files | Vector + graph | Hybrid |
127
+ | **Setup** | 1 command | API key + cloud | Built-in | Build from source (Rust) | Docker |
128
+ | **Data location** | Local SQLite | Cloud | Local markdown | Local SQLite | SQLite |
129
+ | **Team sharing** | Git-native (commit, diff, merge) | Cloud sync | Copy-paste | Manual | Cloud |
130
+ | **API key** | No | Yes | No | No | No |
131
+ | **Cost** | Free | $19–249/mo | Free | Free | Free |
106
132
 
107
133
  ---
108
134
 
@@ -149,22 +175,99 @@ Add to `~/.codex/config.toml`:
149
175
  [mcp_servers.remem-mcp]
150
176
  command = "npx"
151
177
  args = ["-y", "remem-mcp"]
178
+
179
+ [mcp_servers.remem-mcp.env]
180
+ REMEM_GLOBAL_SESSION_KEY = "global"
152
181
  ```
182
+
153
183
  Then run `npx remem-mcp install-hooks`.
184
+ > MCP tools require `sandbox_mode = "danger-full-access"`.
154
185
  </details>
155
186
 
156
187
  ---
157
188
 
189
+ ## How it works
190
+
191
+ Memory lives in a local SQLite database — outside the agent's context window. When the agent compacts or starts a new session, memory is re-injected automatically. No more re-explaining what you already told it yesterday.
192
+
193
+ **PreCompact hook**: when the agent is about to compact context, remem-mcp saves a checkpoint (decisions made, approaches tried, what's verified working) to the DB. After compaction, the agent recalls it — so the compact doesn't destroy your session's learnings.
194
+
195
+ Two layers: **automatic** (runs via hooks, zero tool calls) and **on-demand** (you call when you need deeper context).
196
+
197
+ ### Automatic — three learning loops + compaction survival + symbolic memory
198
+
199
+ All run via lifecycle hooks. The agent doesn't need to call any tool.
200
+
201
+ 1. **Error learning** — command fails → capture → inject fix before next attempt → succeed → upvote.
202
+
203
+ 2. **Decision learning** — `npm install`, `git commit`, config → auto-capture → inject past decisions before similar commands.
204
+
205
+ 3. **Pattern learning** — Write/Edit → auto-capture code patterns → inject same-language patterns before editing.
206
+
207
+ 4. **Compaction survival** — PreCompact hook fires before context compaction → saves checkpoint → agent recalls after compact. Memory survives.
208
+
209
+ 5. **Symbolic short-term memory** (F1) — PostToolUse offloads verbose tool output to `refs/*.md` files and appends a node to a Mermaid canvas. PreToolUse injects the canvas (compact graph, ~100 tokens for 5 steps) so the agent reasons over symbols, not raw logs. Drill down via `ref_read(node_id)`. **92% token reduction** vs. raw tool logs. Enable with `REMEM_FLOW=full`.
210
+
211
+ 6. **Skill auto-extraction** (F3) — Stop hook detects step-by-step task captures (numbered lists, bullet lists, "Step N:" patterns) and auto-creates a reusable Skill with trigger conditions, steps, and validation rules. Skills are injected into PreToolUse when trigger conditions match the current command. Archived skills are always injected. Enable with `REMEM_FLOW=full`.
212
+
213
+ ### Memory Proxy — zero-code LLM integration (F2)
214
+
215
+ For agents that don't support MCP hooks (or any OpenAI/Anthropic client):
216
+
217
+ ```bash
218
+ remem-mcp proxy # Starts HTTP proxy on :8765
219
+ ```
220
+
221
+ Point your agent's base URL to `http://localhost:8765`. The proxy intercepts `/v1/chat/completions` (OpenAI) and `/v1/messages` (Anthropic), injects a `<remem-mcp>` memory block into the system prompt (recall + skills + canvas), forwards to the upstream LLM, and auto-captures the conversation. Session binding via `x-remem-team` / `x-remem-agent` headers or `POST /session/init`.
222
+
223
+ ### On-demand — CodeGraph, Wiki, Search
224
+
225
+ When the automatic loops aren't enough, use these for deeper code navigation.
226
+
227
+ **CodeGraph** — symbol search, callers/callees, impact analysis. **Auto-indexes on first use** — just call `codegraph_search` and it indexes `src/` automatically. No manual `codegraph_index` needed.
228
+
229
+ ```bash
230
+ # Search symbols (auto-indexes src/ on first call)
231
+ npx remem-mcp search-code --query "parseTar"
232
+ # → parseTar at src/parse.ts:22
233
+
234
+ # List symbols in a file
235
+ npx remem-mcp list-code src/reporters/fancy.ts
236
+ # → Class L49-135 FancyReporter
237
+ # → Method L86-134 formatLogObj
238
+
239
+ # Trace callers / callees / impact (use symbol ID from search)
240
+ npx remem-mcp callers 01KZXPPHF93TS4HV8FWCSSK36A
241
+ npx remem-mcp impact 01KZXPPHF93TS4HV8FWCSSK36A
242
+
243
+ # Manual re-index (only needed after major changes)
244
+ npx remem-mcp index --path src --repo .
245
+
246
+ # Wiki + viewer
247
+ npx remem-mcp wiki ingest --path docs # Index markdown docs + ADRs
248
+ npx remem-mcp wiki outdated # Find outdated wiki pages
249
+ npx remem-mcp viewer # Web UI at localhost:7331
250
+ ```
251
+
252
+ - **CodeGraph** — symbol search, callers/callees, impact analysis. Auto-indexes on first `codegraph_search` call. Auto-scoped to your project.
253
+ - **Wiki** — markdown docs, ADRs, outdated detection.
254
+ - **Search** — hybrid BM25 + sqlite-vec vector search with RRF fusion. `explain_recall` shows scores.
255
+
256
+ ![CodeGraph demo](https://raw.githubusercontent.com/tinhien11/remem-mcp/main/docs/screenshots/demo-codegraph.gif)
257
+
258
+ ---
259
+
158
260
  ## Daily commands
159
261
 
160
262
  ```bash
161
263
  npx remem-mcp status # Everything at a glance
162
264
  npx remem-mcp viewer # Web UI at localhost:7331
163
265
  npx remem-mcp errors # Error dashboard
266
+ npx remem-mcp decisions # Decision dashboard
267
+ npx remem-mcp patterns # Pattern dashboard
164
268
  npx remem-mcp recent [N] # Recent captures
165
- npx remem-mcp search-code --query "parseTar" # CodeGraph search
166
- npx remem-mcp callers <id> # Who calls this symbol?
167
- npx remem-mcp impact <id> # Blast radius analysis
269
+ npx remem-mcp proxy # Start Memory Proxy (HTTP, :8765)
270
+ npx remem-mcp skill-extract # Batch extract skills from task captures
168
271
  npx remem-mcp help all # Full list of 40+ subcommands
169
272
  ```
170
273
 
@@ -177,22 +280,57 @@ All settings have defaults. Config file is optional: `~/.config/remem-mcp/config
177
280
  | Setting | Env var | Default |
178
281
  |---|---|---|
179
282
  | DB path | `REMEM_DB_PATH` | `~/.local/share/remem-mcp/memory.db` |
283
+ | **Unified flow** (F1+F3) | `REMEM_FLOW` | _(unset, set to `full`)_ |
284
+ | **Symbolic memory** (F1) | `REMEM_OFFLOAD_ENABLED` | `false` (set to `true`) |
285
+ | **Pipeline** (F1/F3) | `REMEM_PIPELINE` | `noop` (`mermaid`, `skill`, `llm-mermaid`) |
286
+ | **Proxy port** (F2) | `REMEM_PROXY_PORT` | `8765` |
287
+ | **Proxy upstream** (F2) | `REMEM_UPSTREAM_URL` | `https://api.openai.com` |
288
+ | **Proxy API key** (F2) | `REMEM_UPSTREAM_API_KEY` | _(from OPENAI_API_KEY)_ |
180
289
  | Cross-project memory | `REMEM_GLOBAL_SESSION_KEY` | _(unset)_ |
290
+ | Cross-project errors | `REMEM_GLOBAL_ERRORS` | _(unset, set to `1`)_ |
291
+ | Auto-global classification | `auto_global=true` on capture | _(off)_ |
181
292
  | Suppress hook feedback | `REMEM_QUIET` | _(unset, set to `1`)_ |
182
- | LLM API key (optional) | `REMEM_LLM_API_KEY` | _(unset)_ |
293
+ | Retro window (days) | `REMEM_RETRO_DAYS` | `7` |
294
+ | Core-only mode (disable advanced tools) | `REMEM_CORE_ONLY` | _(unset, set to `1`)_ |
295
+ | LLM API key (pipeline) | `REMEM_LLM_API_KEY` | _(unset)_ |
296
+
297
+ **Team sharing** — `npx remem-mcp sync-export` writes `.remem-mcp/memory-export.jsonl`. Commit it to git. Team members get the same memory on `git pull` (auto-imports on startup).
298
+
299
+ ---
300
+
301
+ ## TypeScript SDK
302
+
303
+ ```ts
304
+ import { Memory } from "remem-mcp";
183
305
 
184
- **Team sharing** — `npx remem-mcp sync-export` writes `.remem-mcp/memory-export.jsonl`. Commit it to git. Team members get the same memory on `git pull`.
306
+ const memory = new Memory();
307
+ await memory.capture("We chose SQLite for storage.", "decision", ["arch"]);
308
+ const results = await memory.recall("storage decision");
309
+ ```
185
310
 
186
311
  ---
187
312
 
188
313
  ## Benchmark
189
314
 
190
- | Benchmark | remem-mcp | Mem0 | Without memory |
191
- |---|---|---|---|
192
- | **AMB** (L1/L2/L3) | **100/100/100** | | |
193
- | **LoCoMo** (long conversation QA) | **95** | 92.5 | — |
194
- | **PersonaMem** (personalization) | **100** | | 48 |
195
- | **LongMemEval** (ICLR 2025) | **96** | 94.4 | — |
315
+ remem-mcp is evaluated against the same benchmarks as TencentDB Agent Memory and Mem0, plus the Agent Memory Benchmark (AMB) suite.
316
+
317
+ > **Note:** LoCoMo, PersonaMem, and LongMemEval scores use custom adapters with keyword-heuristic scoring (not official LLM-as-judge runners). AMB uses the official CLI. See [scripts/bench-all.sh](scripts/bench-all.sh) for methodology.
318
+
319
+ | Benchmark | remem-mcp | TencentDB Agent Memory | Mem0 | Without memory |
320
+ |---|---|---|---|---|
321
+ | **AMB Layer 1** (basic recall) | **100** | — | — | — |
322
+ | **AMB Layer 2** (multi-session) | **100** | — | — | — |
323
+ | **AMB Layer 3** (scale + distractors) | **100** | — | — | — |
324
+ | **LoCoMo** (long conversation QA) | **95** | — | 92.5 | — |
325
+ | **PersonaMem** (personalization) | **100** | 76 | — | 48 |
326
+ | **LongMemEval** (long-term memory, ICR 2025) | **96** | — | 94.4 | — |
327
+
328
+ - **PersonaMem** — [bowen-upenn/PersonaMem](https://github.com/bowen-upenn/PersonaMem) (588 questions, 20 personas, multiple-choice QA). TencentDB reports 76% with memory enabled, 48% without. remem-mcp scores **100%** using a search-recall proxy (no LLM API key needed).
329
+ - **LoCoMo** — long conversation multi-hop QA (19 sessions, 400+ turns). Mem0 reports 92.5%. remem-mcp scores **95%** with keyword + semantic-similarity scoring.
330
+ - **AMB** — Agent Memory Benchmark (L1: 56 recall tests, L2: 5 multi-session scenarios, L3: 1K+ memories with distractors). remem-mcp scores **100/100/100** using the official AMB CLI.
331
+ - **LongMemEval** — [xiaowu0162/LongMemEval](https://github.com/xiaowu0162/LongMemEval) (ICLR 2025, 500 questions, 5 memory abilities: temporal reasoning, multi-session, knowledge update, single-session recall, abstention). Mem0 reports 94.4%. remem-mcp scores **96%** on the oracle variant.
332
+
333
+ Run the benchmarks:
196
334
 
197
335
  ```bash
198
336
  bash scripts/bench-all.sh # Full: AMB + LoCoMo + PersonaMem (~5 min)
@@ -203,11 +341,11 @@ bash scripts/bench-all.sh --quick # AMB only (~2 min)
203
341
 
204
342
  ## Architecture
205
343
 
206
- See [ARCHITECTURE.md](./ARCHITECTURE.md) for full system diagrams, schema, and performance benchmarks.
344
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) for full system diagrams, schema, and performance benchmarks. See [docs/unified-flow.md](docs/unified-flow.md) for the F1/F2/F3 unified flow architecture.
207
345
 
208
346
  ## Credits
209
347
 
210
- Core based on [TencentDB Agent Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory) (MIT, Tencent 2026). CodeGraph call resolution adapted from Codebase-Memory (arXiv:2603.27277).
348
+ Core based on [TencentDB Agent Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory) (MIT, Tencent 2026). Replaces the cloud backend with embedded SQLite + sqlite-vec + FTS5. Adds error/decision/pattern learning loops, lifecycle hooks, symbolic short-term memory (Mermaid canvas + context offloading), memory proxy (OpenAI/Anthropic dual protocol), and skill auto-extraction (rule-based, no LLM required). See [docs/unified-flow.md](docs/unified-flow.md) for the full architecture.
211
349
 
212
350
  ## License
213
351
 
@@ -2,12 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
- }) : x)(function(x) {
8
- if (typeof require !== "undefined") return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
5
  var __esm = (fn, res, err) => function __init() {
12
6
  if (err) throw err[0];
13
7
  try {
@@ -44,11 +38,10 @@ var init_esm_shims = __esm({
44
38
  });
45
39
 
46
40
  export {
47
- __require,
48
41
  __esm,
49
42
  __export,
50
43
  __toCommonJS,
51
44
  __dirname,
52
45
  init_esm_shims
53
46
  };
54
- //# sourceMappingURL=chunk-XK4Y53J2.js.map
47
+ //# sourceMappingURL=chunk-ONQHLUGM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B,IAIM,aACA,YAEO;AAPb;AAAA;AAAA;AAIA,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B,IAIM,aACA,YAEO;AAPb;AAAA;AAAA;AAIA,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;AAAA;AAAA;","names":[]}