sessionmem 1.0.5 → 1.0.6
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/LICENSE +21 -21
- package/README.md +372 -365
- package/dist/adapters/capabilities/fallbackTools.js +33 -18
- package/dist/adapters/claudeMdInjector.js +120 -0
- package/dist/adapters/generic.js +83 -12
- package/dist/adapters/tools/ping.js +4 -1
- package/dist/cli/commands/install.js +18 -1
- package/dist/cli/commands/reEmbed.js +47 -0
- package/dist/cli/commands/run.js +28 -2
- package/dist/cli/commands/savings.js +75 -0
- package/dist/cli/commands/uninstall.js +10 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/output.js +11 -3
- package/dist/core/api/contracts.js +34 -10
- package/dist/core/api/memoryCoreService.js +188 -86
- package/dist/core/api/sessionLifecycleService.js +12 -2
- package/dist/core/config/policyConfig.js +20 -0
- package/dist/core/injection/formatStartupInjection.js +2 -1
- package/dist/core/injection/tokenBudget.js +8 -0
- package/dist/core/retrieve/importance.js +4 -3
- package/dist/core/retrieve/recencyBands.js +3 -10
- package/dist/core/retrieve/retrieveMemories.js +17 -4
- package/dist/core/retrieve/score.js +11 -1
- package/dist/core/schema/migrations/005_team_provenance.sql +9 -9
- package/dist/core/schema/migrations/006_access_pattern_boosting.sql +5 -0
- package/dist/core/schema/migrations/007_feedback_manual_delete.sql +23 -0
- package/dist/core/schema/migrations/008_fts5_search.sql +33 -0
- package/dist/core/storage/db.js +6 -0
- package/dist/core/storage/memoryFeedbackRepo.js +14 -4
- package/dist/core/storage/memoryRepo.js +134 -120
- package/dist/core/storage/memorySearchRepo.js +87 -13
- package/dist/core/storage/sessionEventsRepo.js +19 -9
- package/dist/core/storage/summarizationFailuresRepo.js +36 -26
- package/dist/core/storage/tokenSavingsRepo.js +20 -0
- package/dist/core/summarize/cloudSummarizer.js +21 -5
- package/dist/core/summarize/localSummarizer.js +1 -10
- package/package.json +50 -48
package/README.md
CHANGED
|
@@ -1,365 +1,372 @@
|
|
|
1
|
-
# sessionmem
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/sessionmem) [](https://github.com/catfish-1234/sessionmem/blob/main/LICENSE)
|
|
4
|
-
|
|
5
|
-
**Give your AI coding assistant a memory that lasts beyond one conversation — stored entirely on your own computer.**
|
|
6
|
-
|
|
7
|
-
`sessionmem` is a local-first memory layer for AI coding assistants (Claude Code, Cursor, Codex, Cline, Windsurf, Antigravity, QCoder, and any other tool that speaks [MCP](https://modelcontextprotocol.io)). It watches your coding sessions, writes down the important stuff (decisions, warnings, facts about your project), and quietly reminds the assistant about it the next time you start working — without you having to repeat yourself.
|
|
8
|
-
|
|
9
|
-
Everything happens on your machine. There is no account to create, no cloud service to trust, and no data that leaves your computer unless you explicitly turn that on.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Quickstart
|
|
14
|
-
|
|
15
|
-
No programming experience needed for these steps — just a terminal (Command Prompt, Terminal, or PowerShell) and [Node.js](https://nodejs.org) installed.
|
|
16
|
-
|
|
17
|
-
### 1. Install sessionmem
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install -g sessionmem
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### 2. Register it with your AI tool
|
|
24
|
-
|
|
25
|
-
Run this inside the project folder you're working on, with your AI tool (Claude Code, Cursor, etc.) configured:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
sessionmem install
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This does
|
|
32
|
-
- Tells your AI tool's MCP host about `sessionmem` so it can be launched automatically.
|
|
33
|
-
- Creates a config file at `~/.sessionmem/config.json` with safe, privacy-respecting defaults — **only if one doesn't already exist.**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
- At the
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
61
|
-
- [
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
64
|
-
- [
|
|
65
|
-
- [
|
|
66
|
-
- [
|
|
67
|
-
- [
|
|
68
|
-
- [
|
|
69
|
-
- [
|
|
70
|
-
- [
|
|
71
|
-
- [
|
|
72
|
-
- [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
| **
|
|
102
|
-
| **
|
|
103
|
-
| **
|
|
104
|
-
| **
|
|
105
|
-
| **
|
|
106
|
-
| **
|
|
107
|
-
| **
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
npm run
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
│
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
│
|
|
160
|
-
│
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
│
|
|
167
|
-
│
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
│
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
- **
|
|
179
|
-
- **The
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
| `sessionmem
|
|
191
|
-
| `sessionmem
|
|
192
|
-
| `sessionmem
|
|
193
|
-
| `sessionmem
|
|
194
|
-
| `sessionmem
|
|
195
|
-
| `sessionmem
|
|
196
|
-
| `sessionmem
|
|
197
|
-
| `sessionmem
|
|
198
|
-
| `sessionmem
|
|
199
|
-
| `sessionmem
|
|
200
|
-
| `sessionmem
|
|
201
|
-
| `sessionmem
|
|
202
|
-
| `sessionmem
|
|
203
|
-
| `sessionmem
|
|
204
|
-
| `sessionmem
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
-
|
|
219
|
-
-
|
|
220
|
-
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
-
|
|
295
|
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
- [
|
|
311
|
-
- [
|
|
312
|
-
- [
|
|
313
|
-
- [
|
|
314
|
-
- [
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
1
|
+
# sessionmem
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/sessionmem) [](https://github.com/catfish-1234/sessionmem/blob/main/LICENSE)
|
|
4
|
+
|
|
5
|
+
**Give your AI coding assistant a memory that lasts beyond one conversation — stored entirely on your own computer.**
|
|
6
|
+
|
|
7
|
+
`sessionmem` is a local-first memory layer for AI coding assistants (Claude Code, Cursor, Codex, Cline, Windsurf, Antigravity, QCoder, and any other tool that speaks [MCP](https://modelcontextprotocol.io)). It watches your coding sessions, writes down the important stuff (decisions, warnings, facts about your project), and quietly reminds the assistant about it the next time you start working — without you having to repeat yourself.
|
|
8
|
+
|
|
9
|
+
Everything happens on your machine. There is no account to create, no cloud service to trust, and no data that leaves your computer unless you explicitly turn that on.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
No programming experience needed for these steps — just a terminal (Command Prompt, Terminal, or PowerShell) and [Node.js](https://nodejs.org) installed.
|
|
16
|
+
|
|
17
|
+
### 1. Install sessionmem
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g sessionmem
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. Register it with your AI tool
|
|
24
|
+
|
|
25
|
+
Run this inside the project folder you're working on, with your AI tool (Claude Code, Cursor, etc.) configured:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
sessionmem install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This does three things:
|
|
32
|
+
- Tells your AI tool's MCP host about `sessionmem` so it can be launched automatically.
|
|
33
|
+
- Creates a config file at `~/.sessionmem/config.json` with safe, privacy-respecting defaults — **only if one doesn't already exist.**
|
|
34
|
+
- Injects instructions into `~/.claude/CLAUDE.md` so Claude Code knows about sessionmem's tools and uses them proactively (idempotent — safe to re-run).
|
|
35
|
+
|
|
36
|
+
### 3. Start using your AI tool as normal
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
sessionmem run
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
(Most of the time you won't run this yourself — your AI tool's host starts it for you automatically once it's registered.)
|
|
43
|
+
|
|
44
|
+
That's it. From here:
|
|
45
|
+
- `sessionmem` watches your sessions in the background.
|
|
46
|
+
- At the end of each session, it writes down a short summary of what mattered.
|
|
47
|
+
- At the start of your next session, it quietly reminds your assistant of the relevant bits.
|
|
48
|
+
|
|
49
|
+
You can verify everything is working with:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
sessionmem ping
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Table of Contents
|
|
58
|
+
|
|
59
|
+
- [What problem does this solve?](#what-problem-does-this-solve)
|
|
60
|
+
- [How is sessionmem different?](#how-is-sessionmem-different)
|
|
61
|
+
- [Benchmark results](#benchmark-results)
|
|
62
|
+
- [How it works (in plain English)](#how-it-works-in-plain-english)
|
|
63
|
+
- [CLI command reference](#cli-command-reference)
|
|
64
|
+
- [Privacy, secrets, and your data](#privacy-secrets-and-your-data)
|
|
65
|
+
- [Memory rot: keeping memory accurate over time](#memory-rot-keeping-memory-accurate-over-time)
|
|
66
|
+
- [Team mode (optional)](#team-mode-optional)
|
|
67
|
+
- [Cloud summarization (optional, off by default)](#cloud-summarization-optional-off-by-default)
|
|
68
|
+
- [Supported tools](#supported-tools)
|
|
69
|
+
- [Further documentation](#further-documentation)
|
|
70
|
+
- [Troubleshooting](#troubleshooting)
|
|
71
|
+
- [FAQ](#faq)
|
|
72
|
+
- [Contributing](#contributing)
|
|
73
|
+
- [License](#license)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## What problem does this solve?
|
|
78
|
+
|
|
79
|
+
If you've used an AI coding assistant for more than a day, you've probably hit this:
|
|
80
|
+
|
|
81
|
+
> You spend twenty minutes explaining your project's setup, the libraries you use, a tricky bug you already fixed, and a decision you made about how authentication should work. The assistant nods along, helps you out... and then in your **next session**, it has forgotten all of it. You explain everything again.
|
|
82
|
+
|
|
83
|
+
This happens because most AI assistants only "know" what's inside the current conversation. Once that conversation ends, the context is gone.
|
|
84
|
+
|
|
85
|
+
`sessionmem` fixes this by sitting quietly between your assistant and your project:
|
|
86
|
+
|
|
87
|
+
1. While you work, it **captures** what happens in the session.
|
|
88
|
+
2. When the session ends, it **summarizes** the important parts — decisions made, warnings, useful facts — into short, durable notes.
|
|
89
|
+
3. The next time you start a session, it **reminds** the assistant of the most relevant notes, automatically, in a small amount of text.
|
|
90
|
+
|
|
91
|
+
You don't run any of these steps yourself. Once installed, it just works in the background.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## How is sessionmem different?
|
|
96
|
+
|
|
97
|
+
There are other "memory for Claude" projects out there (for example, tools like *claude-mem* and similar community projects). Here's what sets `sessionmem` apart:
|
|
98
|
+
|
|
99
|
+
| | **sessionmem** | Typical cloud/Claude-only memory tools |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| **Where is data stored?** | A single SQLite file on your computer (`~/.sessionmem/memories.db`) | Often a hosted service, a cloud vector database, or a separate server process you have to run |
|
|
102
|
+
| **Account / sign-up required?** | No — never | Sometimes |
|
|
103
|
+
| **Which AI tools does it work with?** | Claude Code, Cursor, Codex, Cline, Windsurf, Antigravity, QCoder, and any other MCP-compatible host | Usually just one specific tool (commonly Claude Code only) |
|
|
104
|
+
| **Secret redaction** | Built in and on by default — API keys, tokens, passwords, private keys, etc. are scrubbed before anything is saved | Often not handled, or left to the user |
|
|
105
|
+
| **Token budget control** | Injected memories are trimmed to a small, fixed token budget so they don't bloat every conversation (see benchmarks below) | Varies, often unbounded |
|
|
106
|
+
| **Old/stale memory cleanup** | Built-in retention policy automatically prunes old memories (configurable, on by default) | Often grows forever ("memory rot") |
|
|
107
|
+
| **Team sharing** | Optional, via a shared folder you already control (network drive, synced directory) — no server to host | Usually requires a shared hosted backend |
|
|
108
|
+
| **Offline-capable** | Yes, fully — works with no network connection by default | Usually requires network access to the memory service |
|
|
109
|
+
|
|
110
|
+
In short: `sessionmem` aims to be the **boring, local, "just a SQLite file" option** — easy to inspect, easy to back up, easy to delete, and not tied to any one vendor's AI tool.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Benchmark results
|
|
115
|
+
|
|
116
|
+
These numbers come from `npm run benchmark` (`scripts/benchmark.mjs`), which runs the **real** production retrieval and injection code over a fixed, synthetic set of test data — no network calls, fully reproducible. See [`docs/benchmark.md`](docs/benchmark.md) for the full report and how to regenerate it.
|
|
117
|
+
|
|
118
|
+
### Token savings
|
|
119
|
+
|
|
120
|
+
> **~85.6% reduction** in tokens compared to carrying full session history.
|
|
121
|
+
|
|
122
|
+
| | Tokens |
|
|
123
|
+
|---|---|
|
|
124
|
+
| Full session history (baseline) | 1,587 |
|
|
125
|
+
| What sessionmem injects at the start of your next session | 228 |
|
|
126
|
+
|
|
127
|
+
In practice: instead of re-reading (or re-explaining) ~1,600 tokens of past context every session, the assistant gets a ~230-token summary of just the things that matter — decisions, warnings, and key facts.
|
|
128
|
+
|
|
129
|
+
### Retrieval accuracy
|
|
130
|
+
|
|
131
|
+
> **100% hit-rate** — every one of the 10 test queries successfully retrieved the memory it was supposed to.
|
|
132
|
+
|
|
133
|
+
| Metric | Result |
|
|
134
|
+
|---|---|
|
|
135
|
+
| Hit-rate (10 curated queries) | 100.0% |
|
|
136
|
+
| Recall | 100.0% |
|
|
137
|
+
| Precision | 33.3% |
|
|
138
|
+
|
|
139
|
+
Precision of 33.3% is expected here: each query retrieves the top 3 candidate memories, and only one of those three is the "expected" match for a given test query — the other two are still relevant context for the agent, just not the one being scored. The important number is recall/hit-rate: **the right memory is never missed.**
|
|
140
|
+
|
|
141
|
+
These benchmarks are deterministic and reproducible — run them yourself:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run build # benchmark imports the compiled code from dist/
|
|
145
|
+
npm run benchmark # regenerates docs/benchmark.md
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## How it works (in plain English)
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
┌──────────────────────────────────────────────┐
|
|
154
|
+
│ Your AI tool │
|
|
155
|
+
│ (Claude Code, Cursor, Codex, Cline, ...) │
|
|
156
|
+
└───────────────────────┬──────────────────────┘
|
|
157
|
+
│
|
|
158
|
+
┌───────────▼───────────┐ ┌──────────────┐
|
|
159
|
+
│ sessionmem adapter │ │ sessionmem │
|
|
160
|
+
│ (translates for your │ │ CLI │
|
|
161
|
+
│ specific AI tool) │ │ (you type │
|
|
162
|
+
└───────────┬───────────┘ │ commands) │
|
|
163
|
+
│ └──────┬───────┘
|
|
164
|
+
▼ │
|
|
165
|
+
┌──────────────────────────────────────────────┐
|
|
166
|
+
│ sessionmem core engine │
|
|
167
|
+
│ watches sessions · writes summaries · │
|
|
168
|
+
│ finds relevant memories · trims to fit │
|
|
169
|
+
└───────────────────────┬──────────────────────┘
|
|
170
|
+
│
|
|
171
|
+
▼
|
|
172
|
+
┌──────────────────────────────────────────────┐
|
|
173
|
+
│ One SQLite file on your computer │
|
|
174
|
+
│ ~/.sessionmem/memories.db │
|
|
175
|
+
└──────────────────────────────────────────────┘
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- **Adapters** are small pieces that know how to talk to each specific AI tool. This is why sessionmem can support many tools — adding a new one doesn't change how memory itself works.
|
|
179
|
+
- **The core engine** is the same no matter which tool you use. It decides what's worth remembering, how relevant it is later, and how much of it fits in a small "reminder" at the start of your next session.
|
|
180
|
+
- **The database** is just a file. You can back it up, move it, inspect it, or delete it like any other file on your computer.
|
|
181
|
+
|
|
182
|
+
For a deeper technical dive, see [`docs/architecture.md`](docs/architecture.md).
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## CLI command reference
|
|
187
|
+
|
|
188
|
+
| Command | What it does |
|
|
189
|
+
|---------|--------------|
|
|
190
|
+
| `sessionmem install` | Register sessionmem with the current MCP host and write default config. |
|
|
191
|
+
| `sessionmem uninstall [--purge]` | Remove sessionmem from the host. `--purge` also deletes the local database. |
|
|
192
|
+
| `sessionmem run` | Start the MCP server. |
|
|
193
|
+
| `sessionmem ping` | Check server connectivity. |
|
|
194
|
+
| `sessionmem search <query> [--limit <n>]` | Search memories by semantic query. |
|
|
195
|
+
| `sessionmem list` | List all memories for the current project. |
|
|
196
|
+
| `sessionmem show <id>` | Show full details of a memory. |
|
|
197
|
+
| `sessionmem forget <id> [--force]` | Delete a memory by ID. |
|
|
198
|
+
| `sessionmem export [path]` | Export memories to a JSON file. |
|
|
199
|
+
| `sessionmem import <path> [--merge]` | Import memories from a JSON file. |
|
|
200
|
+
| `sessionmem stats` | Show memory statistics for the current project. |
|
|
201
|
+
| `sessionmem savings [--json]` | Show token savings from compression and injection, with percentage. |
|
|
202
|
+
| `sessionmem redact-scan [--apply]` | Scan stored memories for secrets; `--apply` redacts in place. |
|
|
203
|
+
| `sessionmem retention prune [--force] [--days <n>]` | Prune old memories (dry-run by default). |
|
|
204
|
+
| `sessionmem config get <key>` / `config set <key> <value>` | Read and write policy config. |
|
|
205
|
+
| `sessionmem team enable <path>` / `team disable` / `team status` | Manage shared-path team memory mode. |
|
|
206
|
+
| `sessionmem sync` | Push local memories and pull teammate memories via the shared path. |
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Privacy, secrets, and your data
|
|
211
|
+
|
|
212
|
+
**Everything stays on your machine by default.** No account, no telemetry, no hosted memory service. Storage, retrieval, and summarization all run locally, governed by `~/.sessionmem/config.json`.
|
|
213
|
+
|
|
214
|
+
### Secrets are scrubbed automatically
|
|
215
|
+
|
|
216
|
+
Before anything is saved, `sessionmem` automatically removes common secret patterns and replaces them with `REDACTED`:
|
|
217
|
+
|
|
218
|
+
- Email addresses
|
|
219
|
+
- API keys (`sk-...`, AWS `AKIA...`, GitHub `ghp_...`/`gho_...`, etc.)
|
|
220
|
+
- Bearer tokens and JWTs
|
|
221
|
+
- Private key blocks (`-----BEGIN ... PRIVATE KEY-----`)
|
|
222
|
+
- Connection-string style secrets (`password=...`, `secret=...`)
|
|
223
|
+
|
|
224
|
+
This is **on by default**. You can scan and clean up older memories at any time:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
sessionmem redact-scan # see what would be redacted
|
|
228
|
+
sessionmem redact-scan --apply # actually redact in place
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Full details: [`docs/privacy-and-retention.md`](docs/privacy-and-retention.md).
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Memory rot: keeping memory accurate over time
|
|
236
|
+
|
|
237
|
+
"Memory rot" is what happens when a memory system keeps accumulating notes forever — eventually it's full of outdated decisions, duplicate facts, and noise, and the assistant starts surfacing **wrong or stale** information instead of helpful information.
|
|
238
|
+
|
|
239
|
+
`sessionmem` is designed to avoid this in a few ways:
|
|
240
|
+
|
|
241
|
+
1. **Retention pruning** — memories older than a configurable window (default **90 days**) are automatically eligible for cleanup. This runs as a light check at the end of every session, and can also be run manually:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
sessionmem retention prune # dry run — shows what *would* be deleted
|
|
245
|
+
sessionmem retention prune --force # actually deletes
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
2. **Importance-weighted ranking** — when memories are retrieved, they're ranked by a blend of *semantic relevance*, *recency*, and *importance*. Old, low-importance notes naturally sink to the bottom and stop being surfaced even before they're pruned.
|
|
249
|
+
|
|
250
|
+
3. **Token-budgeted injection** — only the top-ranked, most relevant memories are injected (trimmed to a small token budget, see [benchmarks](#benchmark-results)), so even a large memory store doesn't translate into bloated, noisy context.
|
|
251
|
+
|
|
252
|
+
4. **Conflict resolution in team mode** — when memories are merged from teammates, the system uses last-write-wins by id (so stale duplicates don't pile up) while preserving the higher importance score (so a critical warning doesn't get silently downgraded).
|
|
253
|
+
|
|
254
|
+
The retrieval benchmark above (100% hit-rate / 100% recall) demonstrates that even with the ranking and trimming in place, the *right* memory still surfaces — accuracy isn't traded away for compactness.
|
|
255
|
+
|
|
256
|
+
You're always in control: export everything first if you want a permanent record before pruning:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
sessionmem export
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Team mode (optional)
|
|
265
|
+
|
|
266
|
+
Want your whole team's AI assistants to share decisions and warnings? Point `sessionmem` at a shared folder (a network drive, a synced directory — anything everyone can read and write):
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
sessionmem team enable <shared-path>
|
|
270
|
+
sessionmem sync
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
- **Off by default** — nothing is shared until you turn it on.
|
|
274
|
+
- No server to host — it's just files in a folder you already control.
|
|
275
|
+
- Teammates' memories show up with an `author:` prefix so you know where they came from.
|
|
276
|
+
- Secrets are re-redacted on every pulled memory, so a teammate's snapshot can't reintroduce something your redaction policy would have stripped.
|
|
277
|
+
|
|
278
|
+
Full details, including the trust model: [`docs/team-mode.md`](docs/team-mode.md).
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Cloud summarization (optional, off by default)
|
|
283
|
+
|
|
284
|
+
By default, summarization (turning a session into a short memory) happens **entirely locally** — no API calls.
|
|
285
|
+
|
|
286
|
+
If you explicitly opt in (`allowCloudSummarization=true`) **and** provide an `ANTHROPIC_API_KEY`, summarization can use Claude's API for higher-quality summaries. If that ever fails, it automatically falls back to local summarization — your sessions are never left unsummarized.
|
|
287
|
+
|
|
288
|
+
Details: [`docs/cloud-summarization.md`](docs/cloud-summarization.md).
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Supported tools
|
|
293
|
+
|
|
294
|
+
`sessionmem` works with any MCP-compatible host, including:
|
|
295
|
+
|
|
296
|
+
- Claude Code
|
|
297
|
+
- Cursor
|
|
298
|
+
- Codex
|
|
299
|
+
- Cline
|
|
300
|
+
- Windsurf
|
|
301
|
+
- Antigravity
|
|
302
|
+
- QCoder
|
|
303
|
+
|
|
304
|
+
...and any other tool that implements the [Model Context Protocol](https://modelcontextprotocol.io).
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Further documentation
|
|
309
|
+
|
|
310
|
+
- [Architecture](docs/architecture.md) — how the core engine, adapters, CLI, and SQLite storage fit together.
|
|
311
|
+
- [Benchmark](docs/benchmark.md) — full token-reduction and retrieval-accuracy report, and how to reproduce it.
|
|
312
|
+
- [Privacy and retention](docs/privacy-and-retention.md) — secret redaction, retention pruning, and config.
|
|
313
|
+
- [Team mode](docs/team-mode.md) — shared-path team memory.
|
|
314
|
+
- [Cloud summarization](docs/cloud-summarization.md) — the opt-in cloud summarization path.
|
|
315
|
+
- [Migration](docs/migration.md) — the SQLite migration system and version-upgrade policy.
|
|
316
|
+
- [Troubleshooting](docs/troubleshooting.md) — install failures, adapter issues, and `better-sqlite3` native-build problems.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Troubleshooting
|
|
321
|
+
|
|
322
|
+
Run into trouble installing or running `sessionmem`? Start with [`docs/troubleshooting.md`](docs/troubleshooting.md) — it covers install failures, adapter-specific issues, and native module (`better-sqlite3`) build problems on different platforms.
|
|
323
|
+
|
|
324
|
+
Quick checks:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
sessionmem ping # is the server reachable?
|
|
328
|
+
sessionmem stats # is data being stored?
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## FAQ
|
|
334
|
+
|
|
335
|
+
**How do I give Cursor, Cline, or Windsurf memory between sessions?**
|
|
336
|
+
Install sessionmem (`npm i -g sessionmem`), then run `sessionmem install` in your project. It registers as an MCP server with any supported host automatically.
|
|
337
|
+
|
|
338
|
+
**How do I give Claude Code persistent memory?**
|
|
339
|
+
Same install. sessionmem also ships as a Claude Code plugin (the `.claude-plugin` file in the repo), so it works with Claude Code's native plugin system too.
|
|
340
|
+
|
|
341
|
+
**Is there a local MCP memory server that works offline with no API key?**
|
|
342
|
+
Yes — sessionmem stores everything in a single SQLite file at `~/.sessionmem/memories.db` and works fully offline by default. Nothing leaves your machine unless you explicitly enable the optional cloud summarization path.
|
|
343
|
+
|
|
344
|
+
**How is sessionmem different from claude-mem?**
|
|
345
|
+
sessionmem is not Claude-only. It works with Cursor, Cline, Codex, Windsurf, Antigravity, QCoder, and any other MCP host — not just Claude Code. It also redacts secrets (API keys, tokens, JWTs) by default, prunes stale memory automatically, and ships reproducible benchmarks you can run yourself.
|
|
346
|
+
|
|
347
|
+
**Does sessionmem send my code to the cloud?**
|
|
348
|
+
No. Nothing leaves your machine by default. The optional cloud summarization path is opt-in and off by default.
|
|
349
|
+
|
|
350
|
+
**How do I see how many tokens sessionmem saved me?**
|
|
351
|
+
Run `sessionmem savings` to see a breakdown of storage compression (raw session tokens vs memory tokens) and injection efficiency. Add `--json` for machine-readable output.
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Contributing
|
|
356
|
+
|
|
357
|
+
Issues and pull requests are welcome. The codebase is TypeScript, tested with [Vitest](https://vitest.dev), and linted with ESLint:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
npm install
|
|
361
|
+
npm run build
|
|
362
|
+
npm test
|
|
363
|
+
npm run lint
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**MCP config for local development:** Copy `.mcp.json.example` to `.mcp.json` for local dev, or use `sessionmem install` to auto-configure. The `.mcp.json` file is gitignored because it contains machine-specific paths.
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## License
|
|
371
|
+
|
|
372
|
+
[MIT](LICENSE)
|