sessionmem 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/sessionmem-logo.svg +57 -0
- package/CHANGELOG.md +128 -0
- package/CONTRIBUTING.md +130 -0
- package/README.md +292 -108
- package/SECURITY.md +33 -0
- package/dist/adapters/diagnostics.js +109 -0
- package/dist/adapters/generic.js +6 -2
- package/dist/adapters/global/antigravity.js +4 -1
- package/dist/adapters/global/claudeCode.js +19 -4
- package/dist/adapters/global/codex.js +7 -6
- package/dist/adapters/global/qcoder.js +4 -1
- package/dist/adapters/ide/cline.js +3 -0
- package/dist/adapters/ide/cursor.js +3 -0
- package/dist/adapters/ide/installer.js +17 -5
- package/dist/adapters/ide/windsurf.js +3 -0
- package/dist/adapters/installedHosts.js +51 -0
- package/dist/cli/commands/dedupe.js +1 -1
- package/dist/cli/commands/doctor.js +146 -0
- package/dist/cli/commands/entities.js +27 -0
- package/dist/cli/commands/history.js +23 -0
- package/dist/cli/commands/import.js +15 -44
- package/dist/cli/commands/ingestHook.js +4 -78
- package/dist/cli/commands/install.js +37 -59
- package/dist/cli/commands/list.js +3 -0
- package/dist/cli/commands/run.js +10 -12
- package/dist/cli/commands/scan.js +16 -0
- package/dist/cli/commands/search.js +9 -4
- package/dist/cli/commands/team.js +7 -3
- package/dist/cli/commands/ui.js +67 -0
- package/dist/cli/commands/uninstall.js +2 -1
- package/dist/cli/commands/watch.js +48 -0
- package/dist/cli/context.js +8 -6
- package/dist/cli/index.js +48 -7
- package/dist/cli/projectId.js +1 -2
- package/dist/cli/transcriptSweep.js +182 -0
- package/dist/core/api/contracts.js +1 -0
- package/dist/core/api/memoryCoreService.js +8 -0
- package/dist/core/api/sessionLifecycleService.js +13 -1
- package/dist/core/capture/toolEvent.js +82 -0
- package/dist/core/config/policyConfig.js +5 -1
- package/dist/core/extract/factClaims.js +97 -0
- package/dist/core/extract/knowledge.js +127 -0
- package/dist/core/injection/tokenBudget.js +10 -2
- package/dist/core/retrieve/retrieveMemories.js +20 -4
- package/dist/core/schema/migrations/012_transcript_checkpoints.sql +4 -0
- package/dist/core/schema/migrations/013_fts_porter.sql +32 -0
- package/dist/core/schema/migrations/014_memory_entities.sql +19 -0
- package/dist/core/schema/migrations/015_memory_supersessions.sql +41 -0
- package/dist/core/schema/runMigrations.js +55 -5
- package/dist/core/storage/db.js +31 -9
- package/dist/core/storage/knowledgeRepo.js +67 -0
- package/dist/core/storage/memoryRepo.js +45 -12
- package/dist/core/storage/memorySearchRepo.js +30 -20
- package/dist/core/storage/supersessionRepo.js +101 -0
- package/dist/core/summarize/cloudSummarizer.js +3 -8
- package/dist/core/summarize/summaryShape.js +1 -1
- package/dist/ui/assets.js +181 -0
- package/dist/ui/server.js +147 -0
- package/docs/REGISTRY_LISTING.md +88 -0
- package/docs/architecture.md +77 -0
- package/docs/benchmark.md +122 -0
- package/docs/cloud-summarization.md +57 -0
- package/docs/migration.md +44 -0
- package/docs/privacy-and-retention.md +139 -0
- package/docs/team-mode.md +117 -0
- package/docs/troubleshooting.md +126 -0
- package/docs/typescript-upgrade.md +48 -0
- package/package.json +25 -13
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<a href="https://github.com/catfish-1234/sessionmem/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
**
|
|
12
|
+
**Project memory between sessions, stored on your machine.**
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
New session. Claude starts fresh.
|
|
@@ -27,15 +27,15 @@ WITH sessionmem:
|
|
|
27
27
|
Claude: "Looks like you're mid-Stripe migration. Where do you want to pick up?"
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
`sessionmem` is an MCP server that
|
|
30
|
+
`sessionmem` is an MCP server that stores decisions, warnings, and project context across sessions. Claude Code hooks capture supported tool events and load relevant memories automatically. Other hosts use its MCP tools and installed instructions; session automation depends on the host. It works with Claude Code, Cursor, Cline, Codex, Windsurf, and other [MCP](https://modelcontextprotocol.io) hosts.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
By default, everything stays on your machine. You don't need an account or a cloud service. Data only leaves your computer if you enable sharing or cloud summarization.
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
36
|
## Quickstart
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
You need a terminal (Command Prompt, Terminal, or PowerShell) and [Node.js](https://nodejs.org), version 20.19+ on the Node 20 line, or 22.13+. Node 22 LTS is recommended. No programming experience is required.
|
|
39
39
|
|
|
40
40
|
### 1. Install sessionmem
|
|
41
41
|
|
|
@@ -45,34 +45,49 @@ npm install -g sessionmem
|
|
|
45
45
|
|
|
46
46
|
### 2. Register it with your AI tool
|
|
47
47
|
|
|
48
|
-
Run this
|
|
48
|
+
Run this in your project folder after configuring your AI tool (Claude Code, Cursor, etc.):
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
sessionmem install
|
|
52
|
+
# Optional: select one host explicitly, including in automation:
|
|
53
|
+
sessionmem install --adapter claude-code
|
|
54
|
+
# Other names: cursor, cline, codex, windsurf, antigravity, qcoder, generic
|
|
52
55
|
```
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
`install` detects installed hosts from local executables, including from a plain
|
|
58
|
+
terminal, and configures every host found. Automatic discovery currently supports
|
|
59
|
+
Claude Code on `PATH` or in its standard native install locations. Use
|
|
60
|
+
`--adapter <name>` for the other adapters or to override discovery. The existing
|
|
61
|
+
`SESSIONMEM_ADAPTER` environment override also works; the flag takes precedence.
|
|
62
|
+
If no supported host is found, the command says so and exits nonzero before
|
|
63
|
+
creating files. Discovery and configuration work fully offline.
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
This initializes the database and, for each selected adapter:
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
sessionmem
|
|
63
|
-
|
|
67
|
+
- Registers `sessionmem` with your AI tool's MCP host so the host can start it automatically.
|
|
68
|
+
- Creates `~/.sessionmem/config.json` with secret redaction enabled and a 90-day retention window, if the file doesn't already exist.
|
|
69
|
+
- Adds instructions to the selected host's guidance file, such as `~/.claude/CLAUDE.md` for Claude Code or `~/.codex/AGENTS.md` for Codex. You can re-run the command without duplicating those instructions.
|
|
70
|
+
- Installs Claude Code's SessionStart, SessionEnd, and PostToolUse hooks and prints what was configured per host. If a host fails, the remaining hosts are still attempted and the command exits nonzero.
|
|
71
|
+
|
|
72
|
+
### 3. Restart your AI tool
|
|
73
|
+
|
|
74
|
+
Restart your editor or agent so it loads the MCP registration. Your host starts
|
|
75
|
+
`sessionmem run` automatically; running it directly starts a stdio server that
|
|
76
|
+
waits for MCP messages, so it can appear to hang in a terminal. For an unknown
|
|
77
|
+
host (`generic`), install writes a project-local `.mcp.json`; if your host uses
|
|
78
|
+
another format or location, copy its server entry into that host’s MCP config.
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
After restarting:
|
|
66
81
|
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
- At the end of each session, it writes down a short summary of what mattered.
|
|
70
|
-
- At the start of your next session, it quietly reminds your assistant of the relevant bits.
|
|
82
|
+
- In Claude Code, the installed PostToolUse, SessionEnd, and SessionStart hooks capture supported tool events, summarize them, and load prior memories automatically.
|
|
83
|
+
- Other MCP hosts use sessionmem's tools and installed instructions. Automatic capture and session lifecycle calls depend on the host or agent. MCP registration alone does not install Claude Code hooks there.
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
Check the installation offline:
|
|
73
86
|
|
|
74
87
|
```bash
|
|
75
|
-
sessionmem
|
|
88
|
+
sessionmem doctor
|
|
89
|
+
# For an explicitly selected host:
|
|
90
|
+
sessionmem doctor --adapter claude-code
|
|
76
91
|
```
|
|
77
92
|
|
|
78
93
|
---
|
|
@@ -92,6 +107,7 @@ sessionmem ping
|
|
|
92
107
|
- [Further documentation](#further-documentation)
|
|
93
108
|
- [Troubleshooting](#troubleshooting)
|
|
94
109
|
- [FAQ](#faq)
|
|
110
|
+
- [Security](#security)
|
|
95
111
|
- [Contributing](#contributing)
|
|
96
112
|
- [License](#license)
|
|
97
113
|
|
|
@@ -99,73 +115,56 @@ sessionmem ping
|
|
|
99
115
|
|
|
100
116
|
## What problem does this solve?
|
|
101
117
|
|
|
102
|
-
|
|
118
|
+
Most AI coding assistants rely on the current conversation for context. Start a new session and you may need to explain the project's setup, libraries, fixed bugs, and design decisions again.
|
|
103
119
|
|
|
104
|
-
|
|
120
|
+
`sessionmem` keeps short notes between sessions:
|
|
105
121
|
|
|
106
|
-
|
|
122
|
+
1. While you work, it captures session events.
|
|
123
|
+
2. At session end, it summarizes decisions, warnings, and useful facts into stored memories.
|
|
124
|
+
3. At the next session start, it loads the most relevant memories within a small token budget.
|
|
107
125
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
2. When the session ends, it **summarizes** the important parts (decisions made, warnings, useful facts) into short, durable notes.
|
|
112
|
-
3. The next time you start a session, it **reminds** the assistant of the most relevant notes, automatically, in a small amount of text.
|
|
113
|
-
|
|
114
|
-
You don't run any of these steps yourself. Once installed, it just works in the background.
|
|
126
|
+
Claude Code runs these steps through the installed hooks. Other hosts need their
|
|
127
|
+
agent to call the MCP memory and lifecycle tools; the installed guidance explains
|
|
128
|
+
how to do that.
|
|
115
129
|
|
|
116
130
|
---
|
|
117
131
|
|
|
118
132
|
## How is sessionmem different?
|
|
119
133
|
|
|
120
|
-
|
|
134
|
+
Compared with projects such as *claude-mem* and other cloud or Claude-only memory tools, `sessionmem` focuses on local storage and support for multiple MCP hosts:
|
|
121
135
|
|
|
122
136
|
| | **sessionmem** | Typical cloud/Claude-only memory tools |
|
|
123
137
|
|---|---|---|
|
|
124
138
|
| **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 |
|
|
125
|
-
| **Account / sign-up required?** | No
|
|
139
|
+
| **Account / sign-up required?** | No | Sometimes |
|
|
126
140
|
| **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) |
|
|
127
141
|
| **Secret redaction** | Built in, on by default. API keys, tokens, passwords, and private keys are scrubbed before anything is saved. | Often not handled, or left to the user |
|
|
128
|
-
| **Token budget control** | Injected memories are trimmed to a small, fixed token budget
|
|
129
|
-
| **Old/stale memory cleanup** | Built-in retention policy automatically prunes old memories (configurable, on by default) | Often
|
|
142
|
+
| **Token budget control** | Injected memories are trimmed to a small, fixed token budget (see benchmarks below) | Varies, often unbounded |
|
|
143
|
+
| **Old/stale memory cleanup** | Built-in retention policy automatically prunes old memories (configurable, on by default) | Often no automatic cleanup ("memory rot") |
|
|
130
144
|
| **Team sharing** | Optional, via a shared folder you already control (network drive, synced directory). No server needed. | Usually requires a shared hosted backend |
|
|
131
|
-
| **Offline-capable** | Yes
|
|
145
|
+
| **Offline-capable** | Yes. Works with no network connection by default. | Usually requires network access to the memory service |
|
|
132
146
|
|
|
133
|
-
|
|
147
|
+
The SQLite file is easy to inspect, back up, or delete, and you can use it across AI tools from different vendors.
|
|
134
148
|
|
|
135
149
|
---
|
|
136
150
|
|
|
137
151
|
## Benchmark results
|
|
138
152
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
> **~85.6% reduction** in tokens compared to carrying full session history.
|
|
144
|
-
|
|
145
|
-
| | Tokens |
|
|
146
|
-
|---|---|
|
|
147
|
-
| Full session history (baseline) | 1,587 |
|
|
148
|
-
| What sessionmem injects at the start of your next session | 228 |
|
|
149
|
-
|
|
150
|
-
In practice: instead of re-reading (or re-explaining) about 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.
|
|
151
|
-
|
|
152
|
-
### Retrieval accuracy
|
|
153
|
-
|
|
154
|
-
> **100% hit-rate**: every one of the 10 test queries successfully retrieved the memory it was supposed to.
|
|
155
|
-
|
|
156
|
-
| Metric | Result |
|
|
157
|
-
|---|---|
|
|
158
|
-
| Hit-rate (10 curated queries) | 100.0% |
|
|
159
|
-
| Recall | 100.0% |
|
|
160
|
-
| Precision | 33.3% |
|
|
153
|
+
`npm run benchmark` evaluates conversational retrieval on the committed LoCoMo
|
|
154
|
+
corpus: 10 conversations, 272 sessions, 5,882 turns, and 1,527 scored questions.
|
|
155
|
+
It captures dialogue through the public `storeMemory` API and asks the original
|
|
156
|
+
questions through `retrieveMemories`, fully offline with no API keys.
|
|
161
157
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
The evaluation reports hit rate, precision, recall, complete-evidence retrieval,
|
|
159
|
+
and latency. Production retrieval uses offline BM25 ranking with English stemming;
|
|
160
|
+
conversational questions test recall beyond exact copies of memory text.
|
|
161
|
+
See [benchmark results](docs/benchmark.md) and the
|
|
162
|
+
[methodology, dataset license, and metric definitions](benchmarks/README.md).
|
|
165
163
|
|
|
166
164
|
```bash
|
|
167
|
-
npm run build
|
|
168
|
-
npm run benchmark
|
|
165
|
+
npm run build
|
|
166
|
+
npm run benchmark
|
|
167
|
+
npm run benchmark -- --output benchmarks/results/locomo.json
|
|
169
168
|
```
|
|
170
169
|
|
|
171
170
|
---
|
|
@@ -198,11 +197,11 @@ npm run benchmark # regenerates docs/benchmark.md
|
|
|
198
197
|
└──────────────────────────────────────────────┘
|
|
199
198
|
```
|
|
200
199
|
|
|
201
|
-
- **Adapters**
|
|
202
|
-
- **The core engine**
|
|
203
|
-
- **The database** is
|
|
200
|
+
- **Adapters** connect each AI tool to sessionmem. Supporting another tool doesn't require changing the memory engine.
|
|
201
|
+
- **The core engine** stores memories, ranks their relevance, and selects what fits in the next session's context budget. Every adapter uses the same engine.
|
|
202
|
+
- **The database** is a local file. You can back it up, move it, inspect it, or delete it.
|
|
204
203
|
|
|
205
|
-
|
|
204
|
+
See [`docs/architecture.md`](docs/architecture.md) for the technical overview.
|
|
206
205
|
|
|
207
206
|
---
|
|
208
207
|
|
|
@@ -210,33 +209,194 @@ For a deeper technical dive, see [`docs/architecture.md`](docs/architecture.md).
|
|
|
210
209
|
|
|
211
210
|
| Command | What it does |
|
|
212
211
|
|---------|--------------|
|
|
213
|
-
| `sessionmem install` |
|
|
214
|
-
| `sessionmem
|
|
212
|
+
| `sessionmem install [--adapter <name>]` | Detect installed hosts, register sessionmem with each, and write default config; the flag selects one host. |
|
|
213
|
+
| `sessionmem doctor [--adapter <name>]` | Check the store, schema, hooks, MCP wiring, and canary recall offline; print PASS/FAIL and repair hints. |
|
|
214
|
+
| `sessionmem uninstall [--adapter <name>] [--purge]` | Remove sessionmem from the host. `--purge` also deletes the local database. |
|
|
215
215
|
| `sessionmem run` | Start the MCP server. |
|
|
216
|
-
| `sessionmem
|
|
217
|
-
| `sessionmem
|
|
218
|
-
| `sessionmem
|
|
219
|
-
| `sessionmem
|
|
216
|
+
| `sessionmem ui [--port N]` | Open the local read-only web viewer (default port 3777). |
|
|
217
|
+
| `sessionmem ping` | Check the local version and database reachability. |
|
|
218
|
+
| `sessionmem search <query> [--limit <n>] [--include-history]` | Search current memories by text query (limit 1–100, default 10). Include superseded facts with `--include-history`. |
|
|
219
|
+
| `sessionmem list` | List up to 200 recent memories for the current project; warns when truncated. |
|
|
220
|
+
| `sessionmem entities [--project <id>] [--json]` | List extracted entities, typed relations, and their source memory IDs. Defaults to the current project. |
|
|
221
|
+
| `sessionmem history [--project <id>] [--json]` | List supersession chains with old/new values, source memory IDs, reasons, and timestamps. |
|
|
222
|
+
| `sessionmem show <id>` | Show memory details (content capped at 2000 characters; use export for full content). |
|
|
220
223
|
| `sessionmem forget <id> [--force]` | Delete a memory by ID. |
|
|
221
|
-
| `sessionmem export [path]` | Export memories to
|
|
222
|
-
| `sessionmem import <path> [--merge]` | Import
|
|
224
|
+
| `sessionmem export [path]` | Export all current-project memories to JSON (default `~/.sessionmem/export-YYYY-MM-DD.json`). |
|
|
225
|
+
| `sessionmem import <path> [--merge]` | Import up to 1000 valid records from UTF-8 JSON into the current project. Existing IDs are preserved, including with `--merge`; invalid records are skipped with warnings. |
|
|
226
|
+
| `sessionmem scan [--transcripts-dir <path>]` | Import existing Claude Code JSONL transcripts into local session memories. Reports files found, sessions imported, memories created, skipped files, and errors. |
|
|
227
|
+
| `sessionmem watch [--once] [--interval <seconds>] [--transcripts-dir <path>]` | Capture new or updated Claude Code transcripts. Polls every 5 seconds by default; `--once` runs a single sweep. |
|
|
223
228
|
| `sessionmem stats` | Show memory statistics for the current project. |
|
|
224
229
|
| `sessionmem savings [--json]` | Show token savings from compression and injection, with percentage. |
|
|
225
230
|
| `sessionmem redact-scan [--apply]` | Scan stored memories for secrets; `--apply` redacts in place. |
|
|
226
231
|
| `sessionmem retention prune [--force] [--days <n>]` | Prune old memories (dry-run by default). |
|
|
227
232
|
| `sessionmem config get <key>` / `config set <key> <value>` | Read and write policy config. |
|
|
228
|
-
| `sessionmem team enable <path>` / `team disable` / `team status` | Manage shared-path team memory mode. |
|
|
233
|
+
| `sessionmem team enable <path>` / `team disable [--remove-team-memories]` / `team status` | Manage shared-path team memory mode. |
|
|
229
234
|
| `sessionmem sync` | Push local memories and pull teammate memories via the shared path. |
|
|
235
|
+
| `sessionmem browse [--project <id>]` | List projects or preview up to 50 recent memories from one project. |
|
|
236
|
+
| `sessionmem dedupe [--apply] [--threshold <n>]` | Preview duplicate memories; `--apply` deletes them (threshold >0–1, default 0.85). |
|
|
237
|
+
| `sessionmem re-embed` | Refresh memories with stale embedding versions. |
|
|
238
|
+
| `sessionmem session-start` | Print prior context as Claude Code SessionStart hook JSON. |
|
|
239
|
+
| `sessionmem ingest-hook` | Read a Claude Code PostToolUse JSON payload from stdin and capture supported tool events. |
|
|
240
|
+
| `sessionmem session-end` | Summarize ingested events and apply retention pruning; reads the hook session ID from stdin. |
|
|
241
|
+
|
|
242
|
+
Use `sessionmem --help` or `sessionmem <command> --help` for options, and
|
|
243
|
+
`sessionmem --version` for the installed version. Destructive commands require
|
|
244
|
+
`--force`, `--apply`, or `--purge` as shown above. `team disable` preserves
|
|
245
|
+
teammate memories unless `--remove-team-memories` is passed.
|
|
246
|
+
|
|
247
|
+
The default database is `~/.sessionmem/memories.db`. Set `SESSIONMEM_DB_PATH`
|
|
248
|
+
to use another file; its parent directories are created automatically and the
|
|
249
|
+
default directory is not created by database commands. Server logs are written
|
|
250
|
+
to `logs/mcp.log` beside the selected database (disabled for `:memory:`). Config remains at
|
|
251
|
+
`~/.sessionmem/config.json`. `uninstall --purge` deletes the selected database.
|
|
252
|
+
Quote paths containing spaces (for example `"C:\Users\Ada Lovelace\memory.db"`
|
|
253
|
+
on Windows). In JSON config files, use forward slashes or escaped backslashes
|
|
254
|
+
for Windows paths. Imports accept CRLF and a UTF-8 BOM; convert other encodings to UTF-8.
|
|
255
|
+
|
|
256
|
+
`SESSIONMEM_PROJECT_ID` pins the project bucket (useful when moving a repository);
|
|
257
|
+
otherwise it is derived from the repository root or working directory.
|
|
258
|
+
`SESSIONMEM_ADAPTER` selects the install/doctor/uninstall host unless `--adapter` is set.
|
|
259
|
+
`SESSIONMEM_DEBUG=1` enables ingest-hook diagnostics on stderr.
|
|
260
|
+
|
|
261
|
+
### Inspect memories in your browser
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
sessionmem ui
|
|
265
|
+
sessionmem ui --port 8080
|
|
266
|
+
sessionmem ui --port 0 # Pick an available port
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
The command prints its URL and opens your default browser. It binds only to
|
|
270
|
+
`127.0.0.1`, needs no authentication, and serves all assets locally using Node's
|
|
271
|
+
built-in HTTP server. No external services, CDNs, or additional runtime dependencies
|
|
272
|
+
are used. If browser launch is unavailable, open the printed URL manually. Press
|
|
273
|
+
Ctrl-C to stop the server and close its database connection.
|
|
274
|
+
|
|
275
|
+
The viewer starts on the current project, with a selector for other projects in
|
|
276
|
+
the same store. Browse saved memories, search through the existing recall path,
|
|
277
|
+
inspect extracted entities and relations with their source memories, and follow
|
|
278
|
+
supersession chains with old/new values, source IDs, assertion times, detection
|
|
279
|
+
times, and partial/full status. Search returns up to 50 results and defaults to
|
|
280
|
+
current facts; select **Include superseded facts in search** to recall history.
|
|
281
|
+
Browsing lists all saved records, including superseded and expired ones, in pages
|
|
282
|
+
of 50. Source IDs open full memory details. Entity visibility and history links
|
|
283
|
+
use the same rules as `sessionmem entities` and `sessionmem history`.
|
|
284
|
+
|
|
285
|
+
The database is opened read-only. Browsing and on-demand search do not increment
|
|
286
|
+
access counts, migrate the schema, or change memories. Only HTTP GET and HEAD are
|
|
287
|
+
accepted; no write, delete, or edit routes are exposed. Responses are not cached,
|
|
288
|
+
and cross-origin browser requests and unexpected Host headers are rejected. Run
|
|
289
|
+
`sessionmem ping` first to initialize a missing store or upgrade an older schema.
|
|
290
|
+
The usual `SESSIONMEM_DB_PATH` and `SESSIONMEM_PROJECT_ID` overrides
|
|
291
|
+
apply. Anyone with access to this computer can read the local viewer while it is
|
|
292
|
+
running; stop it when finished inspecting private memories.
|
|
293
|
+
|
|
294
|
+
### Import existing sessions and watch for new ones
|
|
295
|
+
|
|
296
|
+
When a fact changes, sessionmem can link its replacement locally. For example, “I use VS Code” followed by “I switched to Neovim” supersedes the earlier editor choice. Recall excludes fully superseded memories by default. `retrieveMemories` accepts the optional `includeHistory: true`; `sessionmem search --include-history` searches earlier facts too. `sessionmem history` shows what replaced what. The old memory stays available through show, list, and export.
|
|
297
|
+
|
|
298
|
+
Detection uses deterministic entity/relation rules, shared purpose words, a small tool-category vocabulary, and explicit negation or replacement phrases. It needs no API or model. Unfamiliar wording can be missed, and ambiguous changes can be misclassified. A memory with independent claims remains searchable while any claim is current; history labels these partial supersessions. See [supersession details](docs/architecture.md#contradiction-and-supersession).
|
|
299
|
+
|
|
300
|
+
Run a scan to capture Claude Code sessions from before sessionmem was installed:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
sessionmem scan
|
|
304
|
+
sessionmem watch --once
|
|
305
|
+
sessionmem watch --interval 10
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Both commands recursively read `~/.claude/projects/**/*.jsonl`. Use
|
|
309
|
+
`--transcripts-dir "/path/to/projects"` to select another transcript tree. They
|
|
310
|
+
work fully offline without API keys and always use the local summarizer, even
|
|
311
|
+
if cloud summarization is enabled elsewhere.
|
|
312
|
+
|
|
313
|
+
Transcript user/assistant text and supported tool uses (Bash, Edit, Write,
|
|
314
|
+
MultiEdit) pass through the existing event-ingestion, redaction, and session-summary
|
|
315
|
+
pipeline. Each session gets one summary memory, including short sessions with
|
|
316
|
+
only one event. Updated sessions refresh that summary. Project buckets come from
|
|
317
|
+
each transcript's `cwd`, using its repository root when available; the directory
|
|
318
|
+
where you run scan/watch does not select the project. `SESSIONMEM_PROJECT_ID`
|
|
319
|
+
can explicitly pin all imports to one bucket. Transcripts without a working
|
|
320
|
+
directory or capturable events are skipped; nested subagent files get separate
|
|
321
|
+
session summaries.
|
|
322
|
+
|
|
323
|
+
Re-running either command does not duplicate memories or transcript events.
|
|
324
|
+
File checkpoints live in the selected memory database, and unchanged files are
|
|
325
|
+
skipped across restarts. Stable event IDs also make interrupted imports safe to
|
|
326
|
+
retry. Partial or malformed JSONL lines are reported and retried on later sweeps;
|
|
327
|
+
valid events in the same file can still be captured. A single sweep exits with
|
|
328
|
+
status 1 if it encounters errors. The daemon keeps running and retries errors.
|
|
329
|
+
|
|
330
|
+
`watch` prints its first sweep and subsequent imports or errors. It runs in the
|
|
331
|
+
foreground until SIGINT or SIGTERM. For a background process:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
nohup sessionmem watch > sessionmem-watch.log 2>&1 &
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
For macOS launchd, save this as
|
|
338
|
+
`~/Library/LaunchAgents/io.sessionmem.watch.plist`. Replace the executable path
|
|
339
|
+
with the output of `command -v sessionmem`, and adjust PATH for your Node install:
|
|
340
|
+
|
|
341
|
+
```xml
|
|
342
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
343
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
344
|
+
<plist version="1.0">
|
|
345
|
+
<dict>
|
|
346
|
+
<key>Label</key><string>io.sessionmem.watch</string>
|
|
347
|
+
<key>ProgramArguments</key>
|
|
348
|
+
<array><string>/opt/homebrew/bin/sessionmem</string><string>watch</string></array>
|
|
349
|
+
<key>EnvironmentVariables</key>
|
|
350
|
+
<dict><key>PATH</key><string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string></dict>
|
|
351
|
+
<key>RunAtLoad</key><true/>
|
|
352
|
+
<key>KeepAlive</key><true/>
|
|
353
|
+
</dict>
|
|
354
|
+
</plist>
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
launchctl bootstrap "gui/$(id -u)" ~/Library/LaunchAgents/io.sessionmem.watch.plist
|
|
359
|
+
# Stop and unload:
|
|
360
|
+
launchctl bootout "gui/$(id -u)/io.sessionmem.watch"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
For a Linux systemd user service, save this as
|
|
364
|
+
`~/.config/systemd/user/sessionmem-watch.service`. Replace the executable path
|
|
365
|
+
and adjust PATH for your Node install:
|
|
366
|
+
|
|
367
|
+
```ini
|
|
368
|
+
[Unit]
|
|
369
|
+
Description=Capture Claude Code transcripts with sessionmem
|
|
370
|
+
|
|
371
|
+
[Service]
|
|
372
|
+
ExecStart=/usr/local/bin/sessionmem watch
|
|
373
|
+
Environment=PATH=/usr/local/bin:/usr/bin:/bin
|
|
374
|
+
Restart=on-failure
|
|
375
|
+
RestartSec=5
|
|
376
|
+
|
|
377
|
+
[Install]
|
|
378
|
+
WantedBy=default.target
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
systemctl --user daemon-reload
|
|
383
|
+
systemctl --user enable --now sessionmem-watch.service
|
|
384
|
+
journalctl --user -u sessionmem-watch.service -f
|
|
385
|
+
# Stop and disable:
|
|
386
|
+
systemctl --user disable --now sessionmem-watch.service
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
These are optional examples; `sessionmem install` does not register a daemon.
|
|
230
390
|
|
|
231
391
|
---
|
|
232
392
|
|
|
233
393
|
## Privacy, secrets, and your data
|
|
234
394
|
|
|
235
|
-
|
|
395
|
+
Storage, retrieval, and summarization run locally by default. There is no account, telemetry, or hosted memory service. Settings live in `~/.sessionmem/config.json`.
|
|
236
396
|
|
|
237
397
|
### Secrets are scrubbed automatically
|
|
238
398
|
|
|
239
|
-
Before
|
|
399
|
+
Before saving memory content, `sessionmem` replaces common secret patterns with `REDACTED`:
|
|
240
400
|
|
|
241
401
|
- Email addresses
|
|
242
402
|
- API keys (`sk-...`, AWS `AKIA...`, GitHub `ghp_...`/`gho_...`, etc.)
|
|
@@ -244,7 +404,7 @@ Before anything is saved, `sessionmem` automatically removes common secret patte
|
|
|
244
404
|
- Private key blocks (`-----BEGIN ... PRIVATE KEY-----`)
|
|
245
405
|
- Connection-string style secrets (`password=...`, `secret=...`)
|
|
246
406
|
|
|
247
|
-
|
|
407
|
+
Redaction is on by default. To scan and clean up older memories:
|
|
248
408
|
|
|
249
409
|
```bash
|
|
250
410
|
sessionmem redact-scan # see what would be redacted
|
|
@@ -257,26 +417,26 @@ Full details: [`docs/privacy-and-retention.md`](docs/privacy-and-retention.md).
|
|
|
257
417
|
|
|
258
418
|
## Memory rot: keeping memory accurate over time
|
|
259
419
|
|
|
260
|
-
|
|
420
|
+
Old decisions and duplicate facts can accumulate in a memory store, causing the assistant to use outdated information. This is sometimes called "memory rot."
|
|
261
421
|
|
|
262
|
-
`sessionmem`
|
|
422
|
+
`sessionmem` handles it through retention, ranking, and sync rules:
|
|
263
423
|
|
|
264
|
-
1. **Retention pruning**: memories older than a configurable window (
|
|
424
|
+
1. **Retention pruning**: memories older than a configurable window (90 days by default) are eligible for deletion. A lightweight check runs at session end. You can also run it manually:
|
|
265
425
|
|
|
266
426
|
```bash
|
|
267
427
|
sessionmem retention prune # dry run - shows what *would* be deleted
|
|
268
428
|
sessionmem retention prune --force # actually deletes
|
|
269
429
|
```
|
|
270
430
|
|
|
271
|
-
2. **Importance-weighted ranking**:
|
|
431
|
+
2. **Importance-weighted ranking**: retrieval ranks memories by offline BM25 lexical relevance, entity overlap, recency, and importance. Older, less important notes rank lower even before they are pruned.
|
|
272
432
|
|
|
273
|
-
3. **Token-budgeted injection**: only the
|
|
433
|
+
3. **Token-budgeted injection**: only the highest-ranked memories are loaded, trimmed to a small token budget (see [benchmarks](#benchmark-results)). The context stays within that budget as the store grows.
|
|
274
434
|
|
|
275
|
-
4. **Conflict resolution in team mode**:
|
|
435
|
+
4. **Conflict resolution in team mode**: merging teammate memories uses last-write-wins by id to avoid stale duplicates and keeps the higher importance score so a warning isn't downgraded.
|
|
276
436
|
|
|
277
|
-
The
|
|
437
|
+
The [conversational benchmark](benchmarks/README.md) measures retrieval quality separately from retention and startup token budgets.
|
|
278
438
|
|
|
279
|
-
|
|
439
|
+
Export your memories before pruning if you want to keep a copy:
|
|
280
440
|
|
|
281
441
|
```bash
|
|
282
442
|
sessionmem export
|
|
@@ -286,17 +446,17 @@ sessionmem export
|
|
|
286
446
|
|
|
287
447
|
## Team mode (optional)
|
|
288
448
|
|
|
289
|
-
|
|
449
|
+
To share decisions and warnings across your team's AI assistants, point `sessionmem` at a folder everyone can read and write, such as a network drive or synced directory:
|
|
290
450
|
|
|
291
451
|
```bash
|
|
292
452
|
sessionmem team enable <shared-path>
|
|
293
453
|
sessionmem sync
|
|
294
454
|
```
|
|
295
455
|
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
456
|
+
- Team mode is off by default. Nothing is shared until you enable it.
|
|
457
|
+
- Memories are shared as files in that folder; no server is needed.
|
|
458
|
+
- Teammate memories appear with an `author:` prefix identifying their source.
|
|
459
|
+
- Redaction runs on every pulled memory using your redaction policy.
|
|
300
460
|
|
|
301
461
|
Full details, including the trust model: [`docs/team-mode.md`](docs/team-mode.md).
|
|
302
462
|
|
|
@@ -304,9 +464,9 @@ Full details, including the trust model: [`docs/team-mode.md`](docs/team-mode.md
|
|
|
304
464
|
|
|
305
465
|
## Cloud summarization (optional, off by default)
|
|
306
466
|
|
|
307
|
-
By default,
|
|
467
|
+
By default, session summaries are created locally, with no API calls.
|
|
308
468
|
|
|
309
|
-
|
|
469
|
+
To use Claude's API for higher-quality summaries, set `allowCloudSummarization=true` and provide an `ANTHROPIC_API_KEY`. If cloud summarization fails after retries, sessionmem uses local summarization. Failures are recorded for diagnosis; see the configuration guide below.
|
|
310
470
|
|
|
311
471
|
Details: [`docs/cloud-summarization.md`](docs/cloud-summarization.md).
|
|
312
472
|
|
|
@@ -324,14 +484,14 @@ Details: [`docs/cloud-summarization.md`](docs/cloud-summarization.md).
|
|
|
324
484
|
- Antigravity
|
|
325
485
|
- QCoder
|
|
326
486
|
|
|
327
|
-
|
|
487
|
+
Other tools that implement the [Model Context Protocol](https://modelcontextprotocol.io) can connect too.
|
|
328
488
|
|
|
329
489
|
---
|
|
330
490
|
|
|
331
491
|
## Further documentation
|
|
332
492
|
|
|
333
493
|
- [Architecture](docs/architecture.md): how the core engine, adapters, CLI, and SQLite storage fit together.
|
|
334
|
-
- [Benchmark](docs/benchmark.md):
|
|
494
|
+
- [Benchmark](docs/benchmark.md): conversational retrieval results and reproduction steps.
|
|
335
495
|
- [Privacy and retention](docs/privacy-and-retention.md): secret redaction, retention pruning, and config.
|
|
336
496
|
- [Team mode](docs/team-mode.md): shared-path team memory.
|
|
337
497
|
- [Cloud summarization](docs/cloud-summarization.md): the opt-in cloud summarization path.
|
|
@@ -342,21 +502,34 @@ Details: [`docs/cloud-summarization.md`](docs/cloud-summarization.md).
|
|
|
342
502
|
|
|
343
503
|
## Troubleshooting
|
|
344
504
|
|
|
345
|
-
|
|
505
|
+
For install failures, adapter issues, missing session data, or `better-sqlite3` native-build problems, see [`docs/troubleshooting.md`](docs/troubleshooting.md).
|
|
346
506
|
|
|
347
|
-
|
|
507
|
+
Start with offline diagnostics:
|
|
348
508
|
|
|
349
509
|
```bash
|
|
350
|
-
sessionmem
|
|
351
|
-
sessionmem
|
|
510
|
+
sessionmem doctor
|
|
511
|
+
sessionmem doctor --adapter claude-code # explicit host override
|
|
352
512
|
```
|
|
353
513
|
|
|
514
|
+
`doctor` reports a separate PASS or FAIL for the memory store, schema, hook
|
|
515
|
+
definitions shipped with the current version, configured MCP command, and a
|
|
516
|
+
canary write/recall. It exits nonzero if any check fails and prints fix hints,
|
|
517
|
+
including exact commands for safe repairs. It does not create a missing store or
|
|
518
|
+
apply migrations. Its temporary canary is isolated from your projects and rolled
|
|
519
|
+
back even on failure. The MCP check starts the installed local command and verifies
|
|
520
|
+
its version, tools, and a stats response; it does not require a running agent.
|
|
521
|
+
|
|
522
|
+
Use `sessionmem ping` to initialize a missing store or apply pending schema
|
|
523
|
+
migrations, or `sessionmem install --adapter claude-code` to refresh Claude Code's
|
|
524
|
+
MCP registration and hooks. Run repairs with the same `SESSIONMEM_DB_PATH` as
|
|
525
|
+
doctor when using a custom store.
|
|
526
|
+
|
|
354
527
|
If `stats` shows `sessions: 0` after real work, see [“0 sessions” / no session data recorded](docs/troubleshooting.md#0-sessions--no-session-data-recorded). Memories are keyed to the **repository root**, so every directory inside one repo shares a bucket; outside a repo the working directory itself is the key.
|
|
355
528
|
|
|
356
|
-
|
|
529
|
+
To check database access and memory counts:
|
|
357
530
|
|
|
358
531
|
```bash
|
|
359
|
-
sessionmem ping #
|
|
532
|
+
sessionmem ping # can the local database be opened?
|
|
360
533
|
sessionmem stats # is data being stored?
|
|
361
534
|
```
|
|
362
535
|
|
|
@@ -365,16 +538,16 @@ sessionmem stats # is data being stored?
|
|
|
365
538
|
## FAQ
|
|
366
539
|
|
|
367
540
|
**How do I give Cursor, Cline, or Windsurf memory between sessions?**
|
|
368
|
-
Install sessionmem (`npm i -g sessionmem`), then run `sessionmem install` in your project.
|
|
541
|
+
Install sessionmem (`npm i -g sessionmem`), then run `sessionmem install` in your project. Use `--adapter cursor`, `--adapter cline`, or `--adapter windsurf` when auto-detection cannot identify your host.
|
|
369
542
|
|
|
370
543
|
**How do I give Claude Code persistent memory?**
|
|
371
|
-
|
|
544
|
+
Use the same install steps above. sessionmem also ships as a Claude Code plugin (the `.claude-plugin` directory in the repo) for Claude Code's native plugin system.
|
|
372
545
|
|
|
373
546
|
**Is there a local MCP memory server that works offline with no API key?**
|
|
374
|
-
Yes. sessionmem stores
|
|
547
|
+
Yes. sessionmem stores memories in a single SQLite file at `~/.sessionmem/memories.db` and works offline by default. Sharing and cloud summarization are optional and off by default.
|
|
375
548
|
|
|
376
549
|
**How is sessionmem different from claude-mem?**
|
|
377
|
-
sessionmem
|
|
550
|
+
sessionmem works with Claude Code, Cursor, Cline, Codex, Windsurf, Antigravity, QCoder, and other MCP hosts. It redacts secrets (API keys, tokens, JWTs) by default, prunes old memories automatically, and includes reproducible benchmarks.
|
|
378
551
|
|
|
379
552
|
**Does sessionmem send my code to the cloud?**
|
|
380
553
|
No. Nothing leaves your machine by default. The optional cloud summarization path is opt-in and off by default.
|
|
@@ -384,18 +557,29 @@ Run `sessionmem savings` to see a breakdown of storage compression (raw session
|
|
|
384
557
|
|
|
385
558
|
---
|
|
386
559
|
|
|
560
|
+
## Security
|
|
561
|
+
|
|
562
|
+
See the [security policy](SECURITY.md) for supported versions, private vulnerability
|
|
563
|
+
reporting through GitHub security advisories, and response expectations.
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
387
567
|
## Contributing
|
|
388
568
|
|
|
389
569
|
Issues and pull requests are welcome. The codebase is TypeScript, tested with [Vitest](https://vitest.dev), and linted with ESLint:
|
|
390
570
|
|
|
391
571
|
```bash
|
|
392
|
-
npm
|
|
572
|
+
npm ci
|
|
393
573
|
npm run build
|
|
574
|
+
npm run typecheck
|
|
394
575
|
npm test
|
|
395
576
|
npm run lint
|
|
396
577
|
```
|
|
397
578
|
|
|
398
|
-
**MCP config for local development:**
|
|
579
|
+
**MCP config for local development:** Clone the repository, build it, copy
|
|
580
|
+
`.mcp.json.example` to `.mcp.json`, and replace the example path with the absolute
|
|
581
|
+
path to your checkout’s `dist/cli/index.js`. This runs your local build.
|
|
582
|
+
`sessionmem install` registers the `sessionmem` executable on PATH instead. The `.mcp.json` file is gitignored because it contains machine-specific paths.
|
|
399
583
|
|
|
400
584
|
---
|
|
401
585
|
|