claude-memory-hub 0.6.0 → 0.8.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 +131 -4
- package/README.md +24 -17
- package/dist/cli.js +381 -21
- package/dist/hooks/post-compact.js +47 -20
- package/dist/hooks/post-tool-use.js +171 -16
- package/dist/hooks/pre-compact.js +47 -20
- package/dist/hooks/session-end.js +63 -25
- package/dist/hooks/user-prompt-submit.js +24 -15
- package/dist/index.js +103 -37
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,132 @@ Format follows [Keep a Changelog](https://keepachangelog.com/).
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [0.8.0] - 2026-04-02
|
|
9
|
+
|
|
10
|
+
Major release: test infrastructure, architectural fixes, hook performance, data portability.
|
|
11
|
+
|
|
12
|
+
### Phase 1 — Unit Tests (0% → 91 tests)
|
|
13
|
+
|
|
14
|
+
- **bun:test infrastructure** — 10 test files, 91 tests, 161 assertions, 225ms runtime
|
|
15
|
+
- **In-memory SQLite** — all tests use `:memory:` databases for isolation, zero filesystem side effects
|
|
16
|
+
- **Test coverage modules:** schema, session-store, long-term-store, entity-extractor, observation-extractor, vector-search, working-memory, injection-validator, compact-interceptor, health-monitor
|
|
17
|
+
- **Test helpers** — `createTestDb()`, `seedSession()`, `seedEntity()`, `seedSummary()`, `mockPostToolUseHook()` in `tests/setup.ts`
|
|
18
|
+
|
|
19
|
+
### Phase 4 — L1 WorkingMemory Redesign
|
|
20
|
+
|
|
21
|
+
- **Read-through cache** — `WorkingMemory` rewritten from dead in-process Map to read-through cache over `SessionStore`. First call loads entities from SQLite, subsequent calls serve from cache (<1ms)
|
|
22
|
+
- **Previous behavior:** `workingMemory.summarize()` always returned `""` because hook scripts (short-lived) wrote to L2 directly, MCP server never populated L1
|
|
23
|
+
- **New behavior:** MCP server's `memory_session_notes` tool returns real data via L1 cache
|
|
24
|
+
- **API changes:** removed `add()` method (no callers), added `refresh()` and `invalidate()`. Constructor accepts `SessionStore` for DI
|
|
25
|
+
- **Cache TTL:** 5 minutes, invalidated on session end
|
|
26
|
+
|
|
27
|
+
### Phase 5 — Hook Performance (Batch Queue)
|
|
28
|
+
|
|
29
|
+
- **Batch queue** — `src/capture/batch-queue.ts` implements write-through batching for PostToolUse. Events appended to `~/.claude-memory-hub/batch/queue.jsonl` (~3ms) instead of direct DB write (~75ms)
|
|
30
|
+
- **Opportunistic flush** — each hook invocation tries to flush batch to DB if lock available
|
|
31
|
+
- **File-based lock** — PID-based with 30s staleness check, prevents dead lock accumulation
|
|
32
|
+
- **Fallback** — if batch dir unavailable or enqueue fails, falls back to direct write
|
|
33
|
+
- **Env var:** `CLAUDE_MEMORY_HUB_BATCH=auto|enabled|disabled`
|
|
34
|
+
|
|
35
|
+
### Phase 6 — Export/Import CLI
|
|
36
|
+
|
|
37
|
+
- **`bunx claude-memory-hub export`** — JSONL streaming export to stdout. Options: `--since TIMESTAMP`, `--table TABLE`
|
|
38
|
+
- **`bunx claude-memory-hub import`** — JSONL import from stdin with UPSERT semantics. Option: `--dry-run`
|
|
39
|
+
- **`bunx claude-memory-hub cleanup`** — remove old data beyond retention period. Option: `--days N` (default 90)
|
|
40
|
+
- **BLOB handling** — embedding vectors encoded as `{"$base64": true, "encoded": "..."}` for JSON portability
|
|
41
|
+
- **Schema version header** — first JSONL line declares `__schema_version` for compatibility validation
|
|
42
|
+
- **Idempotent import** — sessions (ON CONFLICT id), summaries (ON CONFLICT session_id), embeddings (ON CONFLICT doc_type+doc_id)
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
- **Observation regex trailing `\b`** — patterns ending with `:` (decision:, TODO:, performance:) had trailing `\b` that failed to match because `:` followed by space = no word boundary. Removed trailing `\b` from colon-ending patterns
|
|
47
|
+
|
|
48
|
+
### New/Modified Files
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
NEW:
|
|
52
|
+
tests/setup.ts — test infrastructure
|
|
53
|
+
tests/unit/*.test.ts — 10 test files (91 tests)
|
|
54
|
+
src/capture/batch-queue.ts — write-through batch queue
|
|
55
|
+
src/export/exporter.ts — JSONL streaming export
|
|
56
|
+
src/export/importer.ts — JSONL streaming import
|
|
57
|
+
|
|
58
|
+
MODIFIED:
|
|
59
|
+
src/memory/working-memory.ts — read-through cache over SessionStore
|
|
60
|
+
src/hooks-entry/post-tool-use.ts — batch queue fast path
|
|
61
|
+
src/capture/observation-extractor.ts — regex trailing \b fix
|
|
62
|
+
src/cli/main.ts — export, import, cleanup commands
|
|
63
|
+
package.json — test scripts, version 0.8.0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### New CLI Commands
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bunx claude-memory-hub export [--since T] [--table T] # JSONL export to stdout
|
|
70
|
+
bunx claude-memory-hub import [--dry-run] # JSONL import from stdin
|
|
71
|
+
bunx claude-memory-hub cleanup [--days N] # Remove old data
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### New Environment Variables
|
|
75
|
+
|
|
76
|
+
| Variable | Default | Description |
|
|
77
|
+
|----------|---------|-------------|
|
|
78
|
+
| `CLAUDE_MEMORY_HUB_BATCH` | `auto` | Batch mode: auto, enabled, disabled |
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## [0.7.0] - 2026-04-01
|
|
83
|
+
|
|
84
|
+
Hardening release: honest resource analysis, search scaling, improved observation capture, DB auto-cleanup, summarizer reliability.
|
|
85
|
+
|
|
86
|
+
### Correctness & Honesty
|
|
87
|
+
|
|
88
|
+
- **Smart Resource Loader rewritten** — v0.4-v0.6 claimed "~24K tokens saved per session" but Claude Code has NO external API to filter resource loading (confirmed by reading Claude Code source). `formatContextAdvice()` now provides **honest, actionable advice**: shows frequently-used resources and overhead awareness instead of misleading "deferred for token efficiency" language
|
|
89
|
+
- **Project CLAUDE.md name validation** — `scanClaudeMd()` now validates relative paths against `SAFE_COMMAND_NAME_RE` before registering, preventing invalid resource names in registry
|
|
90
|
+
|
|
91
|
+
### Semantic Search Scaling
|
|
92
|
+
|
|
93
|
+
- **Pre-filter by doc_type** — `semanticSearch()` accepts `docType` option to filter at SQL level, reducing memory usage for targeted queries
|
|
94
|
+
- **Max candidates cap** — new `maxCandidates` option (default 2000) with `ORDER BY created_at DESC` prevents OOM on large datasets (>5000 embeddings)
|
|
95
|
+
- **Configurable threshold** — similarity threshold now configurable via `SemanticSearchOptions` (default 0.2), was hard-coded
|
|
96
|
+
- **Batch embedding reindex** — `reindexAllEmbeddings()` uses `embedBatch()` with chunk size 16 instead of processing 1-by-1. Tries batch API first, falls back to sequential
|
|
97
|
+
|
|
98
|
+
### Embedding Model
|
|
99
|
+
|
|
100
|
+
- **True batch processing** — `embedBatch()` processes in configurable chunks (default 8), attempts native `@huggingface/transformers` batch call first, falls back to individual if unsupported
|
|
101
|
+
|
|
102
|
+
### Observation Extraction
|
|
103
|
+
|
|
104
|
+
- **8 new patterns** — expanded from 6 to 14 heuristics:
|
|
105
|
+
- Tool output: DEPRECATED, SECURITY, VULNERABILITY (importance 4), "discovered", "root cause", "switched to" (3), HACK, WORKAROUND, "bottleneck", "OOM" (2)
|
|
106
|
+
- User prompts: "MUST" (4), "don't", "never", "avoid" (3), "prefer", "always use", "convention is" (2)
|
|
107
|
+
- **Increased value capture** — max observation length 300 → 500 characters for richer context
|
|
108
|
+
|
|
109
|
+
### Health Monitoring & Auto-Cleanup
|
|
110
|
+
|
|
111
|
+
- **Embeddings size check** — new `checkEmbeddingsSize()` health check, warns when >5000 embeddings
|
|
112
|
+
- **Disk check includes WAL** — total disk size now sums `memory.db` + `-wal` + `-shm` files. Tiered thresholds: 200MB warn, 500MB error
|
|
113
|
+
- **`cleanupOldData()`** — transaction-safe cleanup with configurable retention (default 90 days). Deletes: sessions, entities, notes, summaries, embeddings, resource_usage, old health checks. Runs WAL checkpoint after large deletions
|
|
114
|
+
|
|
115
|
+
### LLM Summarizer Reliability
|
|
116
|
+
|
|
117
|
+
- **Retry logic** — `tryCliSummary()` now retries once (2 attempts total) with 1s pause between attempts before falling back to rule-based
|
|
118
|
+
- **CLI availability TTL** — `isClaudeCliAvailable()` cache expires after 5 minutes when `false`, allowing recovery if `claude` CLI becomes available mid-session (was cached forever)
|
|
119
|
+
|
|
120
|
+
### Modified Files
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
src/context/smart-resource-loader.ts — honest advice, no misleading claims
|
|
124
|
+
src/context/resource-registry.ts — CLAUDE.md name validation
|
|
125
|
+
src/search/semantic-search.ts — pre-filter, maxCandidates, batch reindex
|
|
126
|
+
src/search/embedding-model.ts — true batch processing with chunking
|
|
127
|
+
src/capture/observation-extractor.ts — 8 new patterns, 500-char cap
|
|
128
|
+
src/health/monitor.ts — embeddings check, WAL disk, auto-cleanup
|
|
129
|
+
src/summarizer/cli-summarizer.ts — retry logic, CLI TTL recovery
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
8
134
|
## [0.6.0] - 2026-04-01
|
|
9
135
|
|
|
10
136
|
Major release: semantic search, resource intelligence, observation capture, CLAUDE.md tracking, LLM summarization.
|
|
@@ -191,10 +317,11 @@ Every Claude Code session loads ALL skills, agents, rules, and memory files into
|
|
|
191
317
|
|
|
192
318
|
### Impact
|
|
193
319
|
```
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
320
|
+
Tracks resource usage across sessions
|
|
321
|
+
Identifies unused skills/agents with token cost estimates
|
|
322
|
+
Provides recommendations for manual cleanup
|
|
323
|
+
NOTE: Claude Code loads ALL resources regardless — this is
|
|
324
|
+
an analysis tool, not a filter. See v0.7.0 for details.
|
|
198
325
|
```
|
|
199
326
|
|
|
200
327
|
### Files
|
package/README.md
CHANGED
|
@@ -31,20 +31,21 @@ Long session: Claude auto-compacts at 200K tokens
|
|
|
31
31
|
|
|
32
32
|
Every session: ALL skills + agents + rules loaded
|
|
33
33
|
→ 23-51K tokens consumed before you type anything
|
|
34
|
-
→
|
|
34
|
+
→ No external tool can prevent this (Claude Code limitation)
|
|
35
|
+
→ But you CAN identify and remove unused resources
|
|
35
36
|
|
|
36
37
|
Search: Keyword-only, no semantic ranking
|
|
37
38
|
→ Irrelevant results, wasted tokens on full records
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
**Four problems.
|
|
41
|
+
**Four problems. memory-hub solves three directly and provides analysis for the fourth.**
|
|
41
42
|
|
|
42
43
|
| Problem | Claude Code built-in | claude-mem | memory-hub |
|
|
43
44
|
|---------|:-------------------:|:----------:|:----------:|
|
|
44
45
|
| Cross-session memory | -- | Yes | **Yes** |
|
|
45
46
|
| Influence what compact preserves | -- | -- | **Yes** |
|
|
46
47
|
| Save compact output | -- | -- | **Yes** |
|
|
47
|
-
| Token
|
|
48
|
+
| Token overhead analysis | -- | -- | **Yes** |
|
|
48
49
|
| Semantic search (embeddings) | -- | Chroma (external) | **Yes (offline)** |
|
|
49
50
|
| Hybrid search (FTS5 + TF-IDF + semantic) | -- | Partial | **Yes** |
|
|
50
51
|
| 3-layer progressive search | -- | Yes | **Yes** |
|
|
@@ -112,25 +113,25 @@ Session N+1 → UserPromptSubmit hook fires
|
|
|
112
113
|
→ Claude starts with history, not from zero
|
|
113
114
|
```
|
|
114
115
|
|
|
115
|
-
### Layer 4 —
|
|
116
|
+
### Layer 4 — Resource Intelligence & Overhead Analysis
|
|
116
117
|
|
|
117
118
|
```
|
|
118
|
-
|
|
119
|
+
ResourceRegistry scans your setup:
|
|
120
|
+
58 skills, 36 agents, 65 commands, 10 workflows, CLAUDE.md chain
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
└──────────────────┘ └──────────────────┘
|
|
122
|
+
ResourceTracker records actual usage per session:
|
|
123
|
+
"skill:mobile-development used 4/5 recent sessions"
|
|
124
|
+
"agent:veo3-prompt-expert used 0/5 recent sessions"
|
|
125
|
+
|
|
126
|
+
OverheadReport identifies waste:
|
|
127
|
+
"42/58 skills never used → ~1500 listing tokens overhead"
|
|
128
|
+
"CLAUDE.md chain is 8200 tokens → consider consolidating"
|
|
129
|
+
|
|
130
|
+
UserPromptSubmit injects priority hints:
|
|
131
|
+
"Frequently-used: skill:debugging, agent:planner, agent:tester"
|
|
131
132
|
```
|
|
132
133
|
|
|
133
|
-
memory-hub
|
|
134
|
+
> **Transparency note:** Claude Code loads ALL resources into its system prompt — no external tool can prevent this. memory-hub provides **analysis and prioritization**, not filtering. To actually reduce token overhead, remove or relocate unused skills/agents based on the overhead report.
|
|
134
135
|
|
|
135
136
|
### Layer 5 — 3-Layer Progressive Search + Semantic (new in v0.5/v0.6)
|
|
136
137
|
|
|
@@ -305,6 +306,9 @@ bunx claude-memory-hub migrate # Import data from claude-mem
|
|
|
305
306
|
bunx claude-memory-hub viewer # Open browser UI at localhost:37888
|
|
306
307
|
bunx claude-memory-hub health # Run health diagnostics
|
|
307
308
|
bunx claude-memory-hub reindex # Rebuild TF-IDF search index
|
|
309
|
+
bunx claude-memory-hub export # Export data as JSONL to stdout
|
|
310
|
+
bunx claude-memory-hub import # Import JSONL from stdin
|
|
311
|
+
bunx claude-memory-hub cleanup # Remove old data (default: 90 days)
|
|
308
312
|
```
|
|
309
313
|
|
|
310
314
|
### Requirements
|
|
@@ -398,6 +402,8 @@ Migration is idempotent — safe to run multiple times with zero duplicates.
|
|
|
398
402
|
| **v0.4.0** | Smart resource loading, token budget optimization |
|
|
399
403
|
| **v0.5.0** | Production hardening, hybrid search, 3-layer progressive search, browser UI, health monitoring, claude-mem migration |
|
|
400
404
|
| **v0.6.0** | ResourceRegistry (170 resources), semantic search (384-dim embeddings), observation capture, CLAUDE.md tracking, 3-tier LLM summarization, overhead analysis |
|
|
405
|
+
| **v0.7.0** | Honest resource analysis, semantic search scaling, batch embeddings, 14 observation patterns, DB auto-cleanup, summarizer retry |
|
|
406
|
+
| **v0.8.0** | 91 unit tests (was 0%), L1 WorkingMemory read-through cache, PostToolUse batch queue (75ms→3ms), JSONL export/import CLI, data cleanup command |
|
|
401
407
|
|
|
402
408
|
See [CHANGELOG.md](CHANGELOG.md) for full details.
|
|
403
409
|
|
|
@@ -420,6 +426,7 @@ bun:sqlite Built-in, zero install
|
|
|
420
426
|
| `CLAUDE_MEMORY_HUB_LLM` | `auto` | Summarization: auto, cli-only, rule-based |
|
|
421
427
|
| `CLAUDE_MEMORY_HUB_LLM_TIMEOUT_MS` | `30000` | CLI summarizer timeout |
|
|
422
428
|
| `CLAUDE_MEMORY_HUB_EMBEDDINGS` | `auto` | Embeddings: auto, disabled |
|
|
429
|
+
| `CLAUDE_MEMORY_HUB_BATCH` | `auto` | PostToolUse batching: auto, enabled, disabled |
|
|
423
430
|
| `CMH_LOG_LEVEL` | `info` | Log level: debug, info, warn, error |
|
|
424
431
|
|
|
425
432
|
---
|