claude-memory-hub 0.4.0 → 0.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/CHANGELOG.md CHANGED
@@ -5,6 +5,75 @@ Format follows [Keep a Changelog](https://keepachangelog.com/).
5
5
 
6
6
  ---
7
7
 
8
+ ## [0.5.0] - 2026-04-01
9
+
10
+ Major release: production hardening, hybrid search, browser UI, claude-mem migration.
11
+
12
+ ### P0 — Production Hardening
13
+
14
+ - **Structured logging** — JSON-line logger with levels (debug/info/warn/error), file rotation at 5MB, per-module context. All modules now log structured events to `~/.claude-memory-hub/logs/`
15
+ - **Schema repair** — `initDatabase()` now runs `PRAGMA integrity_check` on startup, detects orphaned FTS tables, attempts WAL checkpoint recovery on corruption
16
+ - **Health monitoring** — new `health_checks` SQLite table + `memory_health` MCP tool. Checks: database connectivity, FTS5 availability, disk usage, FK integrity. Historical health persisted. CLI: `bunx claude-memory-hub health`
17
+ - **Schema v2 migration** — incremental migration system. v2 adds `discovery_tokens` column to entities and summaries for ROI tracking
18
+
19
+ ### P1 — Hybrid Search & Browser UI
20
+
21
+ - **TF-IDF vector search** — pure TypeScript, zero external deps. Tokenizer with stop-word removal, term frequency normalization, IDF weighting. Stored in `tfidf_index` SQLite table. CLI: `bunx claude-memory-hub reindex`
22
+ - **3-layer search workflow** — token-efficient progressive disclosure:
23
+ - Layer 1 (`memory_search`): index results ~50 tokens each. FTS5 + TF-IDF hybrid ranking
24
+ - Layer 2 (`memory_timeline`): chronological context around a result ~200 tokens
25
+ - Layer 3 (`memory_fetch`): full records by ID ~500 tokens each
26
+ - Saves ~80-90% tokens vs. returning full context on every search
27
+ - **Browser UI** — `bunx claude-memory-hub viewer` opens http://localhost:37888. Dark-themed dashboard with stats, search, pagination, session/entity/summary browsing. Zero build step — single embedded HTML
28
+ - **Pagination** — all list APIs (sessions, entities, summaries) support `limit` + `offset`
29
+
30
+ ### P2 — Hook Improvements
31
+
32
+ - **Exit code strategy** — hooks use structured exit codes: 0=success, 1=non-blocking error (Claude Code continues), 2=blocking error. `safeHookRun()` wrapper ensures hooks never crash Claude Code
33
+ - **Hook stdin reader** — `readHookStdin()` with configurable timeout, safe JSON parsing
34
+
35
+ ### claude-mem Data Migration
36
+
37
+ - **Auto-detect on install** — `bunx claude-memory-hub install` checks for `~/.claude-mem/claude-mem.db`. If found, migrates automatically
38
+ - **Standalone CLI** — `bunx claude-memory-hub migrate` for manual migration
39
+ - **Idempotent** — safe to run multiple times. Content-hash dedup for entities, UPSERT for sessions/summaries
40
+
41
+ ### Data Mapping (claude-mem → memory-hub)
42
+ | claude-mem | → | claude-memory-hub |
43
+ |------------|---|-------------------|
44
+ | `sdk_sessions` | → | `sessions` (1:1 field map) |
45
+ | `observations.files_read` | → | `entities` (type=file_read) |
46
+ | `observations.files_modified` | → | `entities` (type=file_modified) |
47
+ | `observations` (title/narrative) | → | `entities` (type=decision) + `session_notes` |
48
+ | `session_summaries` | → | `long_term_summaries` (FTS5 indexed) |
49
+
50
+ ### New MCP Tools
51
+ | Tool | Layer | Tokens/result |
52
+ |------|-------|---------------|
53
+ | `memory_search` | 1 (index) | ~50 |
54
+ | `memory_timeline` | 2 (context) | ~200 |
55
+ | `memory_fetch` | 3 (full) | ~500 |
56
+ | `memory_health` | — | ~100 |
57
+
58
+ ### New CLI Commands
59
+ ```
60
+ bunx claude-memory-hub viewer # Browser UI at :37888
61
+ bunx claude-memory-hub health # Health check
62
+ bunx claude-memory-hub reindex # Rebuild TF-IDF index
63
+ bunx claude-memory-hub migrate # Import from claude-mem
64
+ ```
65
+
66
+ ### Files Added
67
+ - `src/logger/index.ts` — structured logging
68
+ - `src/health/monitor.ts` — health checks
69
+ - `src/search/vector-search.ts` — TF-IDF engine
70
+ - `src/search/search-workflow.ts` — 3-layer search
71
+ - `src/hooks/exit-codes.ts` — hook error handling
72
+ - `src/ui/viewer.ts` — browser dashboard
73
+ - `src/migration/claude-mem-migrator.ts` — data migration
74
+
75
+ ---
76
+
8
77
  ## [0.4.0] - 2026-04-01
9
78
 
10
79
  ### Problem
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="assets/logo.png" alt="claude-memory-hub" width="200" />
2
+ <img src="assets/logo.png" alt="claude-memory-hub" width="400" />
3
3
  </p>
4
4
 
5
5
  <h1 align="center">claude-memory-hub</h1>
@@ -19,7 +19,7 @@ Zero API key. Zero Python. Zero config. One install command.
19
19
 
20
20
  ## The Problem
21
21
 
22
- Claude Code forgets everything between sessions. Within long sessions, auto-compact destroys 90% of context. Every session wastes tokens loading resources that aren't needed.
22
+ Claude Code forgets everything between sessions. Within long sessions, auto-compact destroys 90% of context. Every session wastes tokens loading resources that aren't needed. Search is keyword-only with no ranking.
23
23
 
24
24
  ```
25
25
  Session 1: You spend 2 hours building auth system
@@ -32,9 +32,12 @@ Long session: Claude auto-compacts at 200K tokens
32
32
  Every session: ALL skills + agents + rules loaded
33
33
  → 23-51K tokens consumed before you type anything
34
34
  → Most of them never used
35
+
36
+ Search: Keyword-only, no semantic ranking
37
+ → Irrelevant results, wasted tokens on full records
35
38
  ```
36
39
 
37
- **Three problems. No existing tool solves all of them.**
40
+ **Four problems. No existing tool solves all of them.**
38
41
 
39
42
  | Problem | Claude Code built-in | claude-mem | memory-hub |
40
43
  |---------|:-------------------:|:----------:|:----------:|
@@ -42,6 +45,11 @@ Every session: ALL skills + agents + rules loaded
42
45
  | Influence what compact preserves | -- | -- | **Yes** |
43
46
  | Save compact output | -- | -- | **Yes** |
44
47
  | Token budget optimization | -- | -- | **Yes** |
48
+ | Hybrid search (FTS5 + TF-IDF) | -- | Partial | **Yes** |
49
+ | 3-layer progressive search | -- | Yes | **Yes** |
50
+ | Browser UI | -- | Yes | **Yes** |
51
+ | Health monitoring | -- | -- | **Yes** |
52
+ | Migrate from claude-mem | N/A | N/A | **Yes** |
45
53
  | No API key needed | N/A | Yes | **Yes** |
46
54
  | No Python/Chroma needed | N/A | -- | **Yes** |
47
55
  | No XML format required | N/A | -- | **Yes** |
@@ -94,7 +102,7 @@ Session N ends → rule-based summary from entities → SQLite L3
94
102
  OR PostCompact summary (richer) → SQLite L3
95
103
 
96
104
  Session N+1 → UserPromptSubmit hook fires
97
- → FTS5 search: match user prompt against past summaries
105
+ → FTS5 + TF-IDF hybrid search: match user prompt
98
106
  → inject relevant context automatically
99
107
  → Claude starts with history, not from zero
100
108
  ```
@@ -119,51 +127,76 @@ Session N+1 → UserPromptSubmit hook fires
119
127
 
120
128
  memory-hub tracks which skills/agents/tools you **actually use**, then recommends only those for future sessions. Rare resources load on demand via SkillTool.
121
129
 
130
+ ### Layer 5 — 3-Layer Progressive Search (new in v0.5)
131
+
132
+ ```
133
+ Traditional search: query → ALL full records → 5000+ tokens wasted
134
+
135
+ memory-hub search: query → Layer 1 (index) → ~50 tokens/result
136
+ → Layer 2 (timeline) → ~200 tokens context
137
+ → Layer 3 (full) → ~500 tokens/result
138
+ only for filtered IDs
139
+
140
+ Token savings: ~80-90% vs. full context
141
+ ```
142
+
143
+ Hybrid ranking: FTS5 BM25 for keyword matches + TF-IDF cosine similarity for semantic ranking. Zero external dependencies — pure TypeScript implementation.
144
+
122
145
  ---
123
146
 
124
147
  ## Architecture
125
148
 
126
149
  ```
127
- ┌──────────────────────────────────────────────────────────┐
128
- Claude Code
129
-
130
- │ 5 Lifecycle Hooks
131
- ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
132
- │ │ PostToolUse │ │ PreCompact │ │ PostCompact │
133
- │ │ entity capture│ │ inject │ │ save summary │
134
- └──────┬───────┘ │ priorities │ └──────┬───────┘
135
- │ │ └──────┬───────┘ │
136
- │ ┌──────┴───────┐ │ ┌──────┴───────┐
137
- │ │UserPrompt │ │ │ Stop │
138
- │ │Submit: inject│ │ │ session end │
139
- │ │past context │ │ │ summarize │
140
- │ └──────────────┘ │ └──────────────┘
141
-
142
- │ MCP Server (stdio)
143
- │ ┌─────────────────────┐
144
- │ │ memory_recall │
145
- │ │ memory_entities │ ┌────────────────────────┐
146
- │ │ memory_session_notes│ Smart Resource Loader │ │
147
- │ │ memory_store │ track usage → predict │ │
148
- │ │ memory_context_budget│ budget → recommend
149
- └─────────────────────┘ └────────────────────────┘
150
-
151
- └───────────────────────────┼──────────────────────────────┘
152
-
153
- ┌────────┴────────┐
154
- SQLite + FTS5
155
- ~/.claude-
156
- memory-hub/
157
- memory.db
158
-
159
- │ sessions │
160
- entities │
161
- │ session_notes │
162
- long_term_
163
- summaries
164
- resource_usage
165
- fts_memories
166
- └─────────────────┘
150
+ ┌──────────────────────────────────────────────────────────────┐
151
+ Claude Code
152
+
153
+ │ 5 Lifecycle Hooks
154
+ ┌───────────────┐ ┌──────────────┐ ┌──────────────┐
155
+ │ │ PostToolUse │ │ PreCompact │ │ PostCompact │
156
+ │ │ entity capture│ │ inject │ │ save summary │
157
+ └──────┬────────┘ │ priorities │ └──────┬───────┘
158
+ │ │ └──────┬───────┘ │
159
+ │ ┌──────┴───────┐ │ ┌──────┴───────┐
160
+ │ │UserPrompt │ │ │ Stop │
161
+ │ │Submit: inject│ │ │ session end │
162
+ │ │past context │ │ │ summarize │
163
+ │ └──────────────┘ │ └──────────────┘
164
+
165
+ │ MCP Server (stdio) Health Monitor
166
+ │ ┌─────────────────────┐ ┌────────────────────────┐
167
+ │ │ memory_recall │ sqlite, fts5, disk, │ │
168
+ │ │ memory_entities │ integrity checks │ │
169
+ │ │ memory_session_notes│ └────────────────────────┘
170
+ │ │ memory_store │
171
+ │ │ memory_context_budget│ │ Smart Resource Loader
172
+ │ │ memory_search ←L1 │ ┌────────────────────────┐ │
173
+ memory_timeline ←L2 │ │ track usage → predict │ │
174
+ │ │ memory_fetch ←L3 │ │ │ → budget → recommend │ │
175
+ │ memory_health │ │ └────────────────────────┘ │
176
+ │ └─────────────────────┘ │ │
177
+ │ Browser UI (:37888)
178
+ ┌────────────────────────┐ │
179
+ │ │ search, browse, stats
180
+ └────────────────────────┘ │
181
+
182
+ └────────────────────────────┼────────────────────────────────┘
183
+
184
+ ┌─────────┴──────────┐
185
+ SQLite + FTS5
186
+ ~/.claude-
187
+ memory-hub/
188
+ memory.db
189
+ │ │
190
+ │ sessions │
191
+ │ entities │
192
+ │ session_notes │
193
+ │ long_term_ │
194
+ │ summaries │
195
+ │ resource_usage │
196
+ │ fts_memories │
197
+ │ tfidf_index │
198
+ │ health_checks │
199
+ └────────────────────┘
167
200
  ```
168
201
 
169
202
  ---
@@ -181,10 +214,10 @@ memory-hub tracks which skills/agents/tools you **actually use**, then recommend
181
214
  │ files_read, file_modified Per-session scope │
182
215
  │ errors, decisions Importance scored │
183
216
  ├─────────────────────────────────────────────────────┤
184
- │ L3: LongTermStore SQLite + FTS5
217
+ │ L3: LongTermStore SQLite + FTS5 + TF-IDF
185
218
  │ Cross-session summaries <100ms access │
186
- BM25 ranked search Persistent forever │
187
- │ Auto-injected on start LIKE fallback
219
+ Hybrid ranked search Persistent forever │
220
+ │ Auto-injected on start 3-layer progressive
188
221
  └─────────────────────────────────────────────────────┘
189
222
  ```
190
223
 
@@ -200,6 +233,8 @@ bunx claude-memory-hub install
200
233
 
201
234
  One command. Registers MCP server + 5 hooks globally. Works on CLI, VS Code, JetBrains.
202
235
 
236
+ **Coming from claude-mem?** The installer auto-detects `~/.claude-mem/claude-mem.db` and migrates your data automatically. No manual steps needed.
237
+
203
238
  ### From source
204
239
 
205
240
  ```bash
@@ -209,11 +244,16 @@ bun install && bun run build:all
209
244
  bunx . install
210
245
  ```
211
246
 
212
- ### Other commands
247
+ ### All CLI commands
213
248
 
214
249
  ```bash
215
- bunx claude-memory-hub status # Check installation
250
+ bunx claude-memory-hub install # Register MCP + hooks (auto-migrates claude-mem)
216
251
  bunx claude-memory-hub uninstall # Clean removal
252
+ bunx claude-memory-hub status # Check installation
253
+ bunx claude-memory-hub migrate # Import data from claude-mem
254
+ bunx claude-memory-hub viewer # Open browser UI at localhost:37888
255
+ bunx claude-memory-hub health # Run health diagnostics
256
+ bunx claude-memory-hub reindex # Rebuild TF-IDF search index
217
257
  ```
218
258
 
219
259
  ### Requirements
@@ -228,6 +268,8 @@ bunx claude-memory-hub uninstall # Clean removal
228
268
 
229
269
  Claude can call these tools directly during conversation:
230
270
 
271
+ ### Core Tools
272
+
231
273
  | Tool | What it does | When to use |
232
274
  |------|-------------|-------------|
233
275
  | `memory_recall` | FTS5 search past session summaries | Starting a task, looking for prior work |
@@ -236,6 +278,63 @@ Claude can call these tools directly during conversation:
236
278
  | `memory_store` | Manually save a note or decision | Preserving important context |
237
279
  | `memory_context_budget` | Analyze token costs + recommendations | Optimizing which resources to load |
238
280
 
281
+ ### 3-Layer Search (new in v0.5)
282
+
283
+ | Tool | Layer | Tokens/result | When to use |
284
+ |------|-------|---------------|-------------|
285
+ | `memory_search` | 1 (index) | ~50 | First: find relevant memories by query |
286
+ | `memory_timeline` | 2 (context) | ~200 | Then: see what happened before/after a result |
287
+ | `memory_fetch` | 3 (full) | ~500 | Finally: get complete records for specific IDs |
288
+
289
+ ### Diagnostics
290
+
291
+ | Tool | What it does |
292
+ |------|-------------|
293
+ | `memory_health` | Check database, FTS5, disk, integrity status |
294
+
295
+ ---
296
+
297
+ ## Browser UI
298
+
299
+ ```bash
300
+ bunx claude-memory-hub viewer
301
+ ```
302
+
303
+ Opens a dark-themed dashboard at `http://localhost:37888` with:
304
+
305
+ - **Stats** — session count, entity count, summary count
306
+ - **Search** — hybrid FTS5 + TF-IDF search with ranking scores
307
+ - **Browse** — paginated views of sessions, entities, summaries
308
+ - **Health** — real-time component health indicators
309
+
310
+ ---
311
+
312
+ ## Migrating from claude-mem
313
+
314
+ If you're already using [claude-mem](https://github.com/nicobailey-llc/claude-mem), migration is seamless:
315
+
316
+ ```bash
317
+ # Automatic (during install)
318
+ bunx claude-memory-hub install
319
+ # → Detects ~/.claude-mem/claude-mem.db automatically
320
+ # → Migrates sessions, observations, summaries
321
+
322
+ # Manual
323
+ bunx claude-memory-hub migrate
324
+ ```
325
+
326
+ ### What gets migrated
327
+
328
+ | claude-mem | → | memory-hub |
329
+ |------------|---|------------|
330
+ | `sdk_sessions` | → | `sessions` |
331
+ | `observations` (files_read) | → | `entities` (type=file_read) |
332
+ | `observations` (files_modified) | → | `entities` (type=file_modified) |
333
+ | `observations` (title/narrative) | → | `entities` (type=decision) + `session_notes` |
334
+ | `session_summaries` | → | `long_term_summaries` (FTS5 indexed) |
335
+
336
+ Migration is idempotent — safe to run multiple times with zero duplicates.
337
+
239
338
  ---
240
339
 
241
340
  ## Version History
@@ -246,6 +345,7 @@ Claude can call these tools directly during conversation:
246
345
  | **v0.2.0** | Compact interceptor (PreCompact/PostCompact hooks), context enrichment, importance scoring |
247
346
  | **v0.3.0** | Removed API key requirement, 1-command install |
248
347
  | **v0.4.0** | Smart resource loading, token budget optimization |
348
+ | **v0.5.0** | Production hardening, hybrid search, 3-layer progressive search, browser UI, health monitoring, claude-mem migration |
249
349
 
250
350
  See [CHANGELOG.md](CHANGELOG.md) for full details.
251
351
 
@@ -266,7 +366,14 @@ No Python. No Chroma. No HTTP server. No API key. No Docker.
266
366
 
267
367
  ## Data & Privacy
268
368
 
269
- All data stored locally at `~/.claude-memory-hub/memory.db`.
369
+ All data stored locally at `~/.claude-memory-hub/`.
370
+
371
+ ```
372
+ ~/.claude-memory-hub/
373
+ ├── memory.db # SQLite database (sessions, entities, summaries)
374
+ └── logs/
375
+ └── memory-hub.log # Structured JSON logs (auto-rotated at 5MB)
376
+ ```
270
377
 
271
378
  No cloud. No telemetry. No network calls. Your memory stays on your machine.
272
379
 
@@ -275,7 +382,7 @@ No cloud. No telemetry. No network calls. Your memory stays on your machine.
275
382
  ## Uninstall
276
383
 
277
384
  ```bash
278
- claude mcp remove claude-memory-hub -s user
279
- # Remove hook entries containing "claude-memory-hub" from ~/.claude/settings.json
385
+ bunx claude-memory-hub uninstall
386
+ # Data at ~/.claude-memory-hub/ preserved. Delete manually if desired:
280
387
  rm -rf ~/.claude-memory-hub
281
388
  ```