claude-memory-hub 0.5.1 → 0.6.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,98 @@ Format follows [Keep a Changelog](https://keepachangelog.com/).
5
5
 
6
6
  ---
7
7
 
8
+ ## [0.6.0] - 2026-04-01
9
+
10
+ Major release: semantic search, resource intelligence, observation capture, CLAUDE.md tracking, LLM summarization.
11
+
12
+ ### Phase 1 — ResourceRegistry + Entity Coverage
13
+
14
+ - **ResourceRegistry** — unified scanner for ALL `.claude` locations: skills (58), agents (36), commands (65), workflows (10), CLAUDE.md. Parses agent frontmatter `name:` for correct resolution (e.g., `ios-developer` → `~/.claude/agent_mobile/ios/AGENT.md`). 3-level token estimation: listing (~50-200), full (200-8000), total (all files on disk)
15
+ - **OverheadReport** — `memory_context_budget` MCP tool now shows: fixed token overhead breakdown, unused skill/agent detection, potential savings recommendations
16
+ - **InjectionValidator** — sanitizes context before `UserPromptSubmit` injection. Strips HTML comments, caps at 4500 chars, filters dead resource recommendations via `filterAliveRecommendations()`
17
+ - **Agent/Skill entities** — `Agent` and `Skill` tool calls now produce `entity_type="decision"` entities (importance 3/2), visible in summarization and compact scoring
18
+ - **Expanded resource types** — `resource_usage` table tracks 8 types: skill, agent, command, workflow, claude_md, memory, mcp_tool, hook (was 5)
19
+ - **Real token costs** — `SmartResourceLoader` uses ResourceRegistry for actual file-size-based estimates instead of hardcoded 500 fallback
20
+
21
+ ### Phase 2 — Schema v3 + Observations + CLAUDE.md Tracking
22
+
23
+ - **Schema migration v3** — entities table rebuilt with `observation` type in CHECK constraint + new `claude_md_registry` table
24
+ - **Observation extractor** — heuristic-based free-form capture from tool output and user prompts. Keywords: IMPORTANT/CRITICAL (importance 4), decision:/NOTE: (3), TODO:/FIXME: (2). Max 1 observation per tool call, capped at 300 chars
25
+ - **CLAUDE.md tracker** — walks from `cwd` to root, finds all CLAUDE.md files, extracts `## sections` + 200-char previews, content-hash change detection (only re-parses on change), injects rule summary into context
26
+ - **Session summarizer** includes top 5 observations in L3 summaries
27
+ - **Vector search** reindexes observation entities alongside decisions and errors
28
+
29
+ ### Phase 3 — LLM Summarization Pipeline
30
+
31
+ - **3-tier fallback** — Tier 1: PostCompact summary (free, already existed). Tier 2: `claude -p ... --print` subprocess with 30s timeout. Tier 3: Rule-based (always available)
32
+ - **Hook recursion guard** — `CLAUDE_MEMORY_HUB_SKIP_HOOKS=1` env var set on CLI subprocess, checked by all 5 hook entry scripts. Prevents infinite loop when CLI summarizer triggers hooks
33
+ - **Configurable** — `CLAUDE_MEMORY_HUB_LLM=auto|cli-only|rule-based` env var. `CLAUDE_MEMORY_HUB_LLM_TIMEOUT_MS` for custom timeout
34
+
35
+ ### Phase 4 — Semantic Search
36
+
37
+ - **Embedding model** — `@huggingface/transformers` with `all-MiniLM-L6-v2` (384-dim, 90MB cached, 9ms warm inference). Lazy-loaded: only imports when first embedding requested. Graceful degradation if package not installed
38
+ - **Pure JS cosine similarity** — no native sqlite-vec binary needed. Fast enough for <1000 docs. Embeddings stored as BLOBs in new `embeddings` table (schema v4)
39
+ - **Hybrid search** — `searchIndex()` now merges FTS5 BM25 + TF-IDF + semantic cosine similarity. Deduplicates by id+type, keeps highest score
40
+ - **Auto-indexing** — session-end hook generates embedding for new summaries automatically
41
+ - **Opt-in** — `CLAUDE_MEMORY_HUB_EMBEDDINGS=auto|disabled` env var. `@huggingface/transformers` is `optionalDependencies` — install failure doesn't break anything
42
+
43
+ ### New Environment Variables
44
+
45
+ | Variable | Default | Description |
46
+ |----------|---------|-------------|
47
+ | `CLAUDE_MEMORY_HUB_LLM` | `auto` | Summarization mode: auto, cli-only, rule-based |
48
+ | `CLAUDE_MEMORY_HUB_LLM_TIMEOUT_MS` | `30000` | CLI summarizer timeout in ms |
49
+ | `CLAUDE_MEMORY_HUB_EMBEDDINGS` | `auto` | Embedding mode: auto, disabled |
50
+ | `CLAUDE_MEMORY_HUB_SKIP_HOOKS` | — | Set to `1` to suppress hooks (internal use) |
51
+
52
+ ### New/Modified Files
53
+
54
+ ```
55
+ NEW:
56
+ src/context/resource-registry.ts — unified resource scanner
57
+ src/context/injection-validator.ts — context sanitization
58
+ src/capture/observation-extractor.ts — free-form observation capture
59
+ src/context/claude-md-tracker.ts — CLAUDE.md scanning + tracking
60
+ src/summarizer/cli-summarizer.ts — Tier 2 CLI summarization
61
+ src/search/embedding-model.ts — lazy @huggingface/transformers
62
+ src/search/semantic-search.ts — cosine similarity search
63
+
64
+ MODIFIED:
65
+ src/db/schema.ts — migrations v3 + v4
66
+ src/types/index.ts — EntityType += observation
67
+ src/capture/entity-extractor.ts — Agent/Skill + observation extraction
68
+ src/capture/hook-handler.ts — registry + validator + CLAUDE.md + observations
69
+ src/context/smart-resource-loader.ts — uses ResourceRegistry
70
+ src/context/resource-tracker.ts — 8 resource types
71
+ src/mcp/tool-handlers.ts — overhead report in context_budget
72
+ src/summarizer/session-summarizer.ts — 3-tier pipeline
73
+ src/search/search-workflow.ts — hybrid FTS5+TF-IDF+semantic
74
+ src/search/vector-search.ts — reindex includes observations+embeddings
75
+ src/db/session-store.ts — getSessionObservations()
76
+ src/hooks-entry/*.ts — SKIP_HOOKS recursion guard
77
+ ```
78
+
79
+ ### Dependencies
80
+
81
+ ```
82
+ KEPT: @modelcontextprotocol/sdk
83
+ ADDED: @huggingface/transformers (optional — semantic search)
84
+ ```
85
+
86
+ ---
87
+
88
+ ## [0.5.2] - 2026-04-01
89
+
90
+ ### Fixed
91
+ - **Viewer JS broken after bundle** — inline `onclick` handlers lost reference when Bun bundled template literal into `cli.js`. Rewrote all JS to IIFE + `addEventListener` pattern
92
+ - **Escaped quotes in template literal** — `this.classList.toggle('expanded')` caused `SyntaxError: Unexpected identifier` after bundle. Switched to double quotes and event delegation
93
+ - **push-private.sh deletes source** — `git checkout main` removed untracked `src/` directory. Added backup/restore of source dirs around branch switch
94
+
95
+ ### Changed
96
+ - **push-public.sh** — fixed version extraction in commit message (`node -p` with proper quoting)
97
+
98
+ ---
99
+
8
100
  ## [0.5.1] - 2026-04-01
9
101
 
10
102
  ### Fixed
package/README.md CHANGED
@@ -45,8 +45,13 @@ Search: Keyword-only, no semantic ranking
45
45
  | Influence what compact preserves | -- | -- | **Yes** |
46
46
  | Save compact output | -- | -- | **Yes** |
47
47
  | Token budget optimization | -- | -- | **Yes** |
48
- | Hybrid search (FTS5 + TF-IDF) | -- | Partial | **Yes** |
48
+ | Semantic search (embeddings) | -- | Chroma (external) | **Yes (offline)** |
49
+ | Hybrid search (FTS5 + TF-IDF + semantic) | -- | Partial | **Yes** |
49
50
  | 3-layer progressive search | -- | Yes | **Yes** |
51
+ | Resource overhead analysis | -- | -- | **Yes** |
52
+ | CLAUDE.md rule tracking | -- | -- | **Yes** |
53
+ | Free-form observation capture | -- | Yes | **Yes** |
54
+ | LLM summarization (3-tier) | -- | Yes (API) | **Yes (free)** |
50
55
  | Browser UI | -- | Yes | **Yes** |
51
56
  | Health monitoring | -- | -- | **Yes** |
52
57
  | Migrate from claude-mem | N/A | N/A | **Yes** |
@@ -127,7 +132,7 @@ Session N+1 → UserPromptSubmit hook fires
127
132
 
128
133
  memory-hub tracks which skills/agents/tools you **actually use**, then recommends only those for future sessions. Rare resources load on demand via SkillTool.
129
134
 
130
- ### Layer 5 — 3-Layer Progressive Search (new in v0.5)
135
+ ### Layer 5 — 3-Layer Progressive Search + Semantic (new in v0.5/v0.6)
131
136
 
132
137
  ```
133
138
  Traditional search: query → ALL full records → 5000+ tokens wasted
@@ -140,7 +145,35 @@ memory-hub search: query → Layer 1 (index) → ~50 tokens/result
140
145
  Token savings: ~80-90% vs. full context
141
146
  ```
142
147
 
143
- Hybrid ranking: FTS5 BM25 for keyword matches + TF-IDF cosine similarity for semantic ranking. Zero external dependencies pure TypeScript implementation.
148
+ Hybrid ranking: FTS5 BM25 (keyword) + TF-IDF (term frequency) + **semantic cosine similarity** (384-dim embeddings, v0.6). "debugging tips" now matches "error fixing" even without shared keywords.
149
+
150
+ ### Layer 6 — Resource Intelligence (new in v0.6)
151
+
152
+ ```
153
+ ResourceRegistry scans ALL .claude locations:
154
+ ~/.claude/skills/ 58 skills → listing + full + total tokens
155
+ ~/.claude/agents/ 36 agents → frontmatter name: resolution
156
+ ~/.claude/agent_mobile/ ios-developer → agent_mobile/ios/AGENT.md
157
+ ~/.claude/commands/ 65 commands → relative path naming
158
+ ~/.claude/workflows/ 10 workflows
159
+ ~/.claude/CLAUDE.md + project CLAUDE.md chain
160
+
161
+ OverheadReport:
162
+ "56/64 skills unused in last 10 sessions → ~1033 listing tokens wasted"
163
+ "CLAUDE.md chain is 3222 tokens"
164
+ ```
165
+
166
+ ### Layer 7 — Observation Capture (new in v0.6)
167
+
168
+ ```
169
+ Tool output contains "IMPORTANT: always pool DB connections"
170
+ → observation entity (importance=4) saved to L2
171
+ → included in session summary
172
+ → searchable across sessions
173
+
174
+ User prompt contains "remember that we use TypeScript strict"
175
+ → observation entity (importance=3) saved to L2
176
+ ```
144
177
 
145
178
  ---
146
179
 
@@ -195,6 +228,9 @@ Hybrid ranking: FTS5 BM25 for keyword matches + TF-IDF cosine similarity for sem
195
228
  │ resource_usage │
196
229
  │ fts_memories │
197
230
  │ tfidf_index │
231
+ │ embeddings │
232
+ │ claude_md_ │
233
+ │ registry │
198
234
  │ health_checks │
199
235
  └────────────────────┘
200
236
  ```
@@ -235,6 +271,21 @@ One command. Registers MCP server + 5 hooks globally. Works on CLI, VS Code, Jet
235
271
 
236
272
  **Coming from claude-mem?** The installer auto-detects `~/.claude-mem/claude-mem.db` and migrates your data automatically. No manual steps needed.
237
273
 
274
+ ### Update
275
+
276
+ ```bash
277
+ bunx claude-memory-hub@latest install
278
+ ```
279
+
280
+ Or if installed globally:
281
+
282
+ ```bash
283
+ bun install -g claude-memory-hub@latest
284
+ claude-memory-hub install
285
+ ```
286
+
287
+ Your data at `~/.claude-memory-hub/` is preserved across updates. Schema migrations run automatically.
288
+
238
289
  ### From source
239
290
 
240
291
  ```bash
@@ -346,6 +397,7 @@ Migration is idempotent — safe to run multiple times with zero duplicates.
346
397
  | **v0.3.0** | Removed API key requirement, 1-command install |
347
398
  | **v0.4.0** | Smart resource loading, token budget optimization |
348
399
  | **v0.5.0** | Production hardening, hybrid search, 3-layer progressive search, browser UI, health monitoring, claude-mem migration |
400
+ | **v0.6.0** | ResourceRegistry (170 resources), semantic search (384-dim embeddings), observation capture, CLAUDE.md tracking, 3-tier LLM summarization, overhead analysis |
349
401
 
350
402
  See [CHANGELOG.md](CHANGELOG.md) for full details.
351
403
 
@@ -354,13 +406,21 @@ See [CHANGELOG.md](CHANGELOG.md) for full details.
354
406
  ## Dependencies
355
407
 
356
408
  ```
357
- @modelcontextprotocol/sdk MCP stdio server
358
- bun:sqlite Built-in, zero install
409
+ @modelcontextprotocol/sdk MCP stdio server (required)
410
+ bun:sqlite Built-in, zero install
411
+ @huggingface/transformers Semantic search embeddings (optional)
359
412
  ```
360
413
 
361
- That's it. **One npm package.** The other is built into Bun.
414
+ **Two npm packages + one optional.** No Python. No Chroma. No HTTP server. No API key. No Docker.
415
+
416
+ ### Environment Variables
362
417
 
363
- No Python. No Chroma. No HTTP server. No API key. No Docker.
418
+ | Variable | Default | Description |
419
+ |----------|---------|-------------|
420
+ | `CLAUDE_MEMORY_HUB_LLM` | `auto` | Summarization: auto, cli-only, rule-based |
421
+ | `CLAUDE_MEMORY_HUB_LLM_TIMEOUT_MS` | `30000` | CLI summarizer timeout |
422
+ | `CLAUDE_MEMORY_HUB_EMBEDDINGS` | `auto` | Embeddings: auto, disabled |
423
+ | `CMH_LOG_LEVEL` | `info` | Log level: debug, info, warn, error |
364
424
 
365
425
  ---
366
426