claude_memory 0.5.0 → 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.
- checksums.yaml +4 -4
- data/.claude/CLAUDE.md +1 -1
- data/.claude/rules/claude_memory.generated.md +1 -1
- data/.claude/settings.json +11 -6
- data/.claude/settings.local.json +9 -1
- data/.claude-plugin/marketplace.json +5 -2
- data/.claude-plugin/plugin.json +16 -3
- data/.mcp.json +9 -0
- data/CHANGELOG.md +69 -0
- data/CLAUDE.md +27 -13
- data/README.md +6 -2
- data/Rakefile +22 -0
- data/db/migrations/011_add_tool_call_summaries.rb +18 -0
- data/db/migrations/012_add_vec_indexing_support.rb +19 -0
- data/docs/improvements.md +86 -66
- data/docs/influence/claude-mem.md +253 -0
- data/docs/influence/claude-supermemory.md +158 -430
- data/docs/influence/episodic-memory.md +217 -0
- data/docs/influence/grepai.md +163 -839
- data/docs/influence/kbs.md +437 -0
- data/docs/influence/qmd.md +139 -481
- data/hooks/hooks.json +19 -15
- data/lefthook.yml +4 -0
- data/lib/claude_memory/commands/checks/vec_check.rb +73 -0
- data/lib/claude_memory/commands/compact_command.rb +94 -0
- data/lib/claude_memory/commands/doctor_command.rb +1 -0
- data/lib/claude_memory/commands/export_command.rb +108 -0
- data/lib/claude_memory/commands/help_command.rb +2 -0
- data/lib/claude_memory/commands/hook_command.rb +110 -9
- data/lib/claude_memory/commands/index_command.rb +63 -8
- data/lib/claude_memory/commands/initializers/global_initializer.rb +26 -7
- data/lib/claude_memory/commands/initializers/project_initializer.rb +35 -12
- data/lib/claude_memory/commands/registry.rb +3 -1
- data/lib/claude_memory/hook/context_injector.rb +75 -0
- data/lib/claude_memory/hook/error_classifier.rb +67 -0
- data/lib/claude_memory/hook/handler.rb +21 -1
- data/lib/claude_memory/index/vector_index.rb +171 -0
- data/lib/claude_memory/infrastructure/schema_validator.rb +5 -1
- data/lib/claude_memory/ingest/ingester.rb +26 -1
- data/lib/claude_memory/ingest/observation_compressor.rb +177 -0
- data/lib/claude_memory/mcp/instructions_builder.rb +76 -0
- data/lib/claude_memory/mcp/server.rb +3 -1
- data/lib/claude_memory/mcp/tool_definitions.rb +15 -7
- data/lib/claude_memory/mcp/tools.rb +125 -2
- data/lib/claude_memory/publish.rb +28 -27
- data/lib/claude_memory/recall/dual_query_template.rb +1 -12
- data/lib/claude_memory/recall.rb +71 -17
- data/lib/claude_memory/store/sqlite_store.rb +95 -29
- data/lib/claude_memory/sweep/sweeper.rb +30 -0
- data/lib/claude_memory/version.rb +1 -1
- data/lib/claude_memory.rb +8 -0
- data/scripts/hook-runner.sh +14 -0
- data/scripts/serve-mcp.sh +14 -0
- data/skills/setup-memory/SKILL.md +6 -0
- metadata +32 -2
data/docs/improvements.md
CHANGED
|
@@ -1,104 +1,102 @@
|
|
|
1
1
|
# Improvements to Consider
|
|
2
2
|
|
|
3
|
-
*Updated: 2026-02-
|
|
3
|
+
*Updated: 2026-03-02 - Re-studied all 5 influencer repos + new KBS study. Added new items from episodic-memory, claude-mem, updated QMD/grepai/supermemory findings.*
|
|
4
4
|
*Sources:*
|
|
5
|
-
- *[thedotmack/claude-mem](https://github.com/thedotmack/claude-mem) - Memory compression system*
|
|
6
|
-
- *[obra/episodic-memory](https://github.com/obra/episodic-memory) - Semantic conversation search*
|
|
7
|
-
- *[yoanbernabeu/grepai](https://github.com/yoanbernabeu/grepai) - Semantic code search
|
|
8
|
-
- *[supermemoryai/claude-supermemory](https://github.com/supermemoryai/claude-supermemory) - Cloud-backed persistent memory
|
|
9
|
-
- *[tobi/qmd](https://github.com/tobi/qmd) - On-device hybrid search engine (
|
|
5
|
+
- *[thedotmack/claude-mem](https://github.com/thedotmack/claude-mem) - Memory compression system (v10.5.2, studied 2026-03-02)*
|
|
6
|
+
- *[obra/episodic-memory](https://github.com/obra/episodic-memory) - Semantic conversation search (v1.0.15, studied 2026-03-02)*
|
|
7
|
+
- *[yoanbernabeu/grepai](https://github.com/yoanbernabeu/grepai) - Semantic code search (v0.34.0, studied 2026-03-02)*
|
|
8
|
+
- *[supermemoryai/claude-supermemory](https://github.com/supermemoryai/claude-supermemory) - Cloud-backed persistent memory (v2.0.0, studied 2026-03-02)*
|
|
9
|
+
- *[tobi/qmd](https://github.com/tobi/qmd) - On-device hybrid search engine (v1.1.0, studied 2026-03-02)*
|
|
10
|
+
- *[MadBomber/kbs](https://github.com/MadBomber/kbs) - Knowledge-Based System with RETE inference (v0.2.1, studied 2026-03-02)*
|
|
10
11
|
|
|
11
12
|
This document contains only unimplemented improvements. Completed items are removed.
|
|
12
13
|
|
|
13
14
|
---
|
|
14
15
|
|
|
15
|
-
## High Priority
|
|
16
|
+
## High Priority
|
|
16
17
|
|
|
17
|
-
### 1. Native Vector Storage (sqlite-vec)
|
|
18
|
+
### ~~1. Native Vector Storage (sqlite-vec)~~ ✅ Implemented 2026-03-04
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
- **QMD Proof**: Handles 10,000+ documents with sub-second vector queries
|
|
21
|
-
- **Current Issue**: JSON embedding storage requires loading all facts, O(n) Ruby similarity calculation
|
|
22
|
-
- **Solution**: sqlite-vec extension with native C KNN queries
|
|
23
|
-
- **Implementation**:
|
|
24
|
-
- Schema migration v11: Create `facts_vec` virtual table using `vec0`
|
|
25
|
-
- Two-step query pattern (avoid JOINs - they hang with vec tables!)
|
|
26
|
-
- Update `Embeddings::Similarity` class
|
|
27
|
-
- Backfill existing embeddings
|
|
28
|
-
- **Trade-off**: Adds native dependency (acceptable, well-maintained, cross-platform)
|
|
20
|
+
Schema migration v12 with `facts_vec` virtual table (vec0, cosine distance). Two-step query pattern (KNN → batch hydration). VectorIndex class with native C KNN search, fallback to O(n) Ruby. Backfill via `claude-memory index --vec` and sweeper. Doctor check with coverage stats. Cross-platform: arm64-darwin, x86_64-darwin, x86_64-linux.
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## High Priority (Study-Inspired)
|
|
22
|
+
### ~~2. Claude Code Plugin Distribution Format~~ ✅ Implemented 2026-03-04
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
Plugin packaging with `plugin.json` referencing MCP server, hooks, skills, commands, and output styles. Wrapper scripts (`scripts/serve-mcp.sh`, `scripts/hook-runner.sh`) handle gem detection gracefully. Initializers detect plugin mode via `CLAUDE_PLUGIN_ROOT` and skip hooks/MCP/output-style config. Version sync Rake task keeps plugin metadata in sync with gem version.
|
|
35
25
|
|
|
36
|
-
|
|
26
|
+
---
|
|
37
27
|
|
|
38
|
-
|
|
39
|
-
- **Implementation**: Inject recalled facts into Claude's context at session start using `hookSpecificOutput.additionalContext`
|
|
40
|
-
- **Evidence**: `context-hook.js:72-74` — uses hook response to inject `<supermemory-context>` XML
|
|
41
|
-
- **Effort**: 1-2 days (hook handler, context formatter, settings)
|
|
28
|
+
## Medium Priority
|
|
42
29
|
|
|
43
|
-
### 3.
|
|
30
|
+
### 3. Incremental Indexing with File Watching
|
|
44
31
|
|
|
45
|
-
Source:
|
|
32
|
+
Source: grepai study (reinforced 2026-03-02)
|
|
46
33
|
|
|
47
|
-
- **Value**:
|
|
48
|
-
- **Implementation**:
|
|
49
|
-
- **Evidence**: `
|
|
50
|
-
- **Effort**:
|
|
34
|
+
- **Value**: Eliminates manual `claude-memory ingest` calls
|
|
35
|
+
- **Implementation**: Add `Listen` gem, watch `.claude/projects/*/transcripts/*.jsonl`, debounce 500ms, trigger IngestCommand automatically
|
|
36
|
+
- **Evidence**: `watcher/watcher.go:30-59` — fsnotify with debouncing (300ms default), gitignore respect, event deduplication
|
|
37
|
+
- **Effort**: 2-3 days
|
|
38
|
+
- **Trade-off**: Background process ~10MB memory overhead
|
|
51
39
|
|
|
52
|
-
### 4.
|
|
40
|
+
### 4. Document Chunking for Long Transcripts
|
|
53
41
|
|
|
54
|
-
Source: QMD study
|
|
42
|
+
Source: QMD study (updated 2026-03-02)
|
|
55
43
|
|
|
56
|
-
- **Value**:
|
|
57
|
-
- **Implementation**:
|
|
58
|
-
- **Evidence**:
|
|
44
|
+
- **Value**: Better embeddings for long content (>3000 chars)
|
|
45
|
+
- **Implementation**: 900 tokens/chunk, 15% overlap, markdown-aware break points
|
|
46
|
+
- **Evidence**: QMD v1.1.0 `store.ts:53-219` — scored break point patterns (h1=100 → newline=1), code fence detection, squared distance decay
|
|
47
|
+
- **Consideration**: Only if users report issues with long transcripts
|
|
59
48
|
- **Effort**: 2-3 days
|
|
60
49
|
|
|
50
|
+
### ~~5. Background Processing for Hooks~~ ✅ Implemented 2026-03-02
|
|
51
|
+
|
|
52
|
+
`--async` flag on hook ingest/sweep/publish subcommands. Fork+detach for non-blocking execution, fallback to sync when fork unavailable.
|
|
53
|
+
|
|
61
54
|
---
|
|
62
55
|
|
|
63
|
-
##
|
|
56
|
+
## Low Priority / Defer
|
|
64
57
|
|
|
65
|
-
### 5.
|
|
58
|
+
### 5. Signal-Based Ingestion Filtering
|
|
66
59
|
|
|
67
|
-
Source:
|
|
60
|
+
Source: claude-supermemory study (2026-03-02)
|
|
68
61
|
|
|
69
|
-
- **Value**:
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
72
|
-
- **Effort**: 2
|
|
73
|
-
- **Trade-off**:
|
|
62
|
+
- **Value**: Reduce noise by prioritizing transcript sections with signal keywords
|
|
63
|
+
- **Evidence**: supermemory `settings.json:signalKeywords` — keyword-triggered capture with context window
|
|
64
|
+
- **Implementation**: During ingest, weight transcript sections containing signal keywords ("decided", "convention", "always", "never", "prefer") higher
|
|
65
|
+
- **Effort**: 1-2 days
|
|
66
|
+
- **Trade-off**: May miss important but subtly-expressed facts. Our distiller already extracts structured facts, which inherently filters noise.
|
|
67
|
+
- **Recommendation**: DEFER — Distiller handles this naturally
|
|
74
68
|
|
|
75
|
-
### 6.
|
|
69
|
+
### 6. HTTP MCP Transport
|
|
76
70
|
|
|
77
|
-
Source:
|
|
71
|
+
Source: QMD study (2026-03-02)
|
|
78
72
|
|
|
79
|
-
- **Value**:
|
|
80
|
-
- **
|
|
81
|
-
- **
|
|
73
|
+
- **Value**: Shared server, models stay loaded, faster subsequent queries
|
|
74
|
+
- **Evidence**: QMD `mcp.ts:119-137` — WebStandardStreamableHTTPServerTransport with daemon mode
|
|
75
|
+
- **Implementation**: Add HTTP transport option alongside stdio
|
|
76
|
+
- **Effort**: 2-3 days
|
|
77
|
+
- **Trade-off**: Process management complexity
|
|
78
|
+
- **Recommendation**: DEFER — Only if MCP startup latency becomes an issue
|
|
82
79
|
|
|
83
|
-
### 7.
|
|
80
|
+
### ~~7. MCP Discovery Tools~~ ✅ Implemented 2026-03-02
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
Added `memory.list_projects` MCP tool. Shows global DB, current project, and discovers other projects from promoted facts/global fact paths with stats.
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
- **Implementation**: 800 tokens, 15% overlap, semantic boundary detection
|
|
89
|
-
- **Consideration**: Only if users report issues with long transcripts
|
|
84
|
+
### ~~8. Database Compact Command~~ ✅ Implemented 2026-03-02
|
|
90
85
|
|
|
91
|
-
|
|
86
|
+
Added `claude-memory compact` command. Runs SQLite VACUUM with optional integrity check (`--check`). Supports `--scope` for global/project/all. Reports size before/after with savings.
|
|
87
|
+
|
|
88
|
+
### ~~9. Fact Export Command~~ ✅ Implemented 2026-03-02
|
|
89
|
+
|
|
90
|
+
Added `claude-memory export` command. Dumps facts with entities and provenance to JSON. Supports `--scope`, `--status` (active/all), `--output` (file), `--pretty`. Includes version metadata for import compatibility.
|
|
92
91
|
|
|
93
92
|
---
|
|
94
93
|
|
|
95
94
|
## Features to Avoid
|
|
96
95
|
|
|
97
|
-
- **Chroma Vector Database** — We use fastembed-rb with local ONNX model
|
|
96
|
+
- **Chroma Vector Database** — We use fastembed-rb with local ONNX model. sqlite-vec is the better upgrade path (claude-mem uses Chroma, but QMD/episodic-memory prove sqlite-vec is simpler and sufficient)
|
|
98
97
|
- **Claude Agent SDK for Distillation** — Direct API calls via `anthropic-rb` gem
|
|
99
|
-
- **Worker Service Background Process** — Keep stdio-based MCP server
|
|
98
|
+
- **Worker Service Background Process** — Keep stdio-based MCP server. claude-mem's worker architecture adds significant complexity and failure modes.
|
|
100
99
|
- **Web Viewer UI** — CLI output is sufficient. Add if users request it
|
|
101
|
-
- **Configuration-Driven Context** — Default config is sufficient. Add if users request it
|
|
102
100
|
- **Neural Embeddings (EmbeddingGemma)** — Superseded by FastEmbed (BAAI/bge-small-en-v1.5)
|
|
103
101
|
- **Cross-Encoder Reranking (Qwen3-Reranker-0.6B)** — Over-engineering for fact retrieval
|
|
104
102
|
- **Query Expansion (LLM, Qwen3-1.7B)** — No LLM in recall path, too heavy
|
|
@@ -106,6 +104,19 @@ Source: QMD study
|
|
|
106
104
|
- **YAML Collection System** — Our dual-database approach is cleaner
|
|
107
105
|
- **Content-Addressable Storage** — Facts deduplicated by signature, not content hash
|
|
108
106
|
- **Virtual Path System** — Dual-database provides clear namespace
|
|
107
|
+
- **Cloud Storage Dependency** — Local-first is superior (supermemory's weakness)
|
|
108
|
+
- **Tree-Sitter AST Code Navigation** — Out of scope for memory/fact retrieval (claude-mem's Smart Explore)
|
|
109
|
+
- **RPG Semantic Code Graph** — Wrong domain; code structure graph vs fact knowledge graph (grepai)
|
|
110
|
+
- **AGPL Licensing** — Too restrictive for developer tools (claude-mem)
|
|
111
|
+
- **Multiple AI Providers (Gemini/OpenRouter)** — Over-engineering; anthropic-rb is sufficient
|
|
112
|
+
- **Bubble Tea TUI** — CLI output is sufficient (grepai)
|
|
113
|
+
- **Query Document Format (lex/vec/hyde)** — Over-engineering for fact retrieval (QMD)
|
|
114
|
+
- **Team Memory via Cloud Sync** — Our dual-database handles scope well; cloud sync adds complexity (supermemory)
|
|
115
|
+
- **Raw Conversation Storage** — We distill into structured facts (episodic-memory stores raw exchanges)
|
|
116
|
+
- **KBS as Dependency (RETE inference engine)** — KBS (MadBomber/kbs) provides RETE inference, but solves a fundamentally different problem (forward-chaining rules vs knowledge recall). Architectural mismatch, schema incompatibility (JSON blobs vs normalized triples), performance regression (raw sqlite3 vs Sequel+Extralite), low adoption (2 stars, sole maintainer). See `docs/influence/kbs.md`.
|
|
117
|
+
- **KBS Redis Backend** — Redis store adds operational complexity; SQLite + Extralite is fast enough for our use case
|
|
118
|
+
- **KBS Message Queue** — Hook ordering already handles coordination; message queue adds unnecessary complexity
|
|
119
|
+
- **KBS Declarative Rule DSL** — Expressive but wrong paradigm for knowledge recall; our query/search approach is more appropriate
|
|
109
120
|
|
|
110
121
|
---
|
|
111
122
|
|
|
@@ -127,12 +138,21 @@ Source: QMD study
|
|
|
127
138
|
|
|
128
139
|
## References
|
|
129
140
|
|
|
130
|
-
- [episodic-memory GitHub](https://github.com/obra/episodic-memory) - Semantic conversation search
|
|
131
|
-
- [claude-mem GitHub](https://github.com/thedotmack/claude-mem) - Memory compression system
|
|
132
|
-
- [grepai GitHub](https://github.com/yoanbernabeu/grepai) - Semantic code search
|
|
133
|
-
- [claude-supermemory GitHub](https://github.com/supermemoryai/claude-supermemory) - Cloud-backed memory
|
|
134
|
-
- [QMD GitHub](https://github.com/tobi/qmd) - On-device hybrid search engine
|
|
141
|
+
- [episodic-memory GitHub](https://github.com/obra/episodic-memory) - Semantic conversation search (v1.0.15)
|
|
142
|
+
- [claude-mem GitHub](https://github.com/thedotmack/claude-mem) - Memory compression system (v10.5.2)
|
|
143
|
+
- [grepai GitHub](https://github.com/yoanbernabeu/grepai) - Semantic code search (v0.34.0)
|
|
144
|
+
- [claude-supermemory GitHub](https://github.com/supermemoryai/claude-supermemory) - Cloud-backed memory (v2.0.0)
|
|
145
|
+
- [QMD GitHub](https://github.com/tobi/qmd) - On-device hybrid search engine (v1.1.0)
|
|
146
|
+
- [KBS GitHub](https://github.com/MadBomber/kbs) - Knowledge-Based System with RETE inference (v0.2.1)
|
|
147
|
+
|
|
148
|
+
Influence documents:
|
|
149
|
+
- [docs/influence/qmd.md](influence/qmd.md) - Updated 2026-03-02
|
|
150
|
+
- [docs/influence/episodic-memory.md](influence/episodic-memory.md) - New 2026-03-02
|
|
151
|
+
- [docs/influence/claude-mem.md](influence/claude-mem.md) - New 2026-03-02
|
|
152
|
+
- [docs/influence/grepai.md](influence/grepai.md) - Updated 2026-03-02
|
|
153
|
+
- [docs/influence/claude-supermemory.md](influence/claude-supermemory.md) - Updated 2026-03-02
|
|
154
|
+
- [docs/influence/kbs.md](influence/kbs.md) - New 2026-03-02
|
|
135
155
|
|
|
136
156
|
---
|
|
137
157
|
|
|
138
|
-
*Last updated: 2026-
|
|
158
|
+
*Last updated: 2026-03-04 - Marked Claude Code Plugin Distribution Format as implemented. Previous: sqlite-vec (Native Vector Storage), Database Compact Command, Fact Export Command, Background Processing for Hooks (--async), MCP Discovery Tools (memory.list_projects), Hook Error Classification, Dynamic MCP Server Instructions, Progressive Disclosure Documentation, Conversation Exclusion Markers.*
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Claude-Mem Analysis
|
|
2
|
+
|
|
3
|
+
*Analysis Date: 2026-03-02*
|
|
4
|
+
*Repository: https://github.com/thedotmack/claude-mem*
|
|
5
|
+
*Version: 10.5.2 (commit ecb09df)*
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Executive Summary
|
|
10
|
+
|
|
11
|
+
### Project Purpose
|
|
12
|
+
|
|
13
|
+
Claude-Mem is a persistent memory compression system for Claude Code. It captures tool usage observations during sessions, generates semantic summaries, and injects relevant context into future sessions. The largest and most actively developed memory plugin in the ecosystem.
|
|
14
|
+
|
|
15
|
+
### Key Innovation
|
|
16
|
+
|
|
17
|
+
1. **Progressive Disclosure Pattern**: 3-layer token-efficient workflow — search (compact index, ~50-100 tokens/result) → timeline (chronological context) → get_observations (full details, ~500-1000 tokens/result). Claims ~10x token savings by filtering before fetching.
|
|
18
|
+
|
|
19
|
+
2. **Worker Service Architecture**: Background HTTP server (port 37777) with web viewer UI, managed by Bun. Decouples hook processing from worker logic.
|
|
20
|
+
|
|
21
|
+
3. **Smart Explore** (v10.5.0): Tree-sitter AST-powered code navigation with 3 MCP tools (`smart_search`, `smart_outline`, `smart_unfold`). Claims 6-12x token savings vs full file reads.
|
|
22
|
+
|
|
23
|
+
4. **Multi-Platform Support**: Claude Code + Cursor + OpenClaw gateway adapters.
|
|
24
|
+
|
|
25
|
+
### Technology Stack
|
|
26
|
+
|
|
27
|
+
| Component | Technology |
|
|
28
|
+
|-----------|-----------|
|
|
29
|
+
| **Language** | TypeScript (ESM) |
|
|
30
|
+
| **Runtime** | Bun (worker), Node.js (hooks) |
|
|
31
|
+
| **Database** | SQLite (sessions, observations, summaries) |
|
|
32
|
+
| **Vector Search** | Chroma vector database (hybrid semantic + keyword) |
|
|
33
|
+
| **Summarization** | Claude Agent SDK + Gemini + OpenRouter agents |
|
|
34
|
+
| **MCP** | @modelcontextprotocol/sdk v1.25.1 |
|
|
35
|
+
| **Web UI** | React 18 + Express (port 37777) |
|
|
36
|
+
| **AST Parsing** | tree-sitter (10 languages) |
|
|
37
|
+
| **Build** | esbuild |
|
|
38
|
+
| **Testing** | Bun test runner |
|
|
39
|
+
| **Plugin** | Claude Code marketplace format |
|
|
40
|
+
| **License** | AGPL-3.0 |
|
|
41
|
+
|
|
42
|
+
### Production Readiness
|
|
43
|
+
|
|
44
|
+
- **Maturity**: Production (v10.5.2, very active development)
|
|
45
|
+
- **Test Coverage**: Extensive test suite (70+ test files across sqlite, worker, agents, search, context, infrastructure)
|
|
46
|
+
- **Documentation**: Professional docs site (docs.claude-mem.ai)
|
|
47
|
+
- **Community**: Large user base, active issue tracker
|
|
48
|
+
- **Complexity**: High — worker service, Chroma, multiple AI providers, web UI
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Architecture Overview
|
|
53
|
+
|
|
54
|
+
### Data Model
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Lifecycle Hooks (SessionStart, UserPromptSubmit, PostToolUse, Stop, SessionEnd)
|
|
58
|
+
↓
|
|
59
|
+
Hook Scripts → JSON stdin → Platform Adapter → Event Handler
|
|
60
|
+
↓
|
|
61
|
+
Worker Service (HTTP API on port 37777)
|
|
62
|
+
↓
|
|
63
|
+
┌─────────────────┐ ┌──────────────────┐
|
|
64
|
+
│ SQLite DB │ │ Chroma Vector DB│
|
|
65
|
+
│ - sessions │ │ - embeddings │
|
|
66
|
+
│ - observations │ │ - hybrid search │
|
|
67
|
+
│ - summaries │ │ - keyword index │
|
|
68
|
+
│ - prompts │ │ │
|
|
69
|
+
└─────────────────┘ └──────────────────┘
|
|
70
|
+
↓
|
|
71
|
+
MCP Tools (search, timeline, get_observations, smart_*)
|
|
72
|
+
↓
|
|
73
|
+
Web Viewer UI (React, port 37777)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Key Design Patterns
|
|
77
|
+
|
|
78
|
+
1. **Platform Adapter Pattern** (`src/cli/adapters/`): Claude Code and Cursor have different hook formats. Adapters normalize input for shared event handlers.
|
|
79
|
+
|
|
80
|
+
2. **Progressive Disclosure** (`README:199-232`): 3-layer workflow for token-efficient memory retrieval:
|
|
81
|
+
- Layer 1: `search` — compact index with IDs (~50-100 tokens/result)
|
|
82
|
+
- Layer 2: `timeline` — chronological context around results
|
|
83
|
+
- Layer 3: `get_observations` — full details for filtered IDs
|
|
84
|
+
|
|
85
|
+
3. **Worker Service** (`src/services/worker/`): Background HTTP server manages state, search, SSE broadcasting, and AI agent calls. Hooks are thin clients that POST to the worker.
|
|
86
|
+
|
|
87
|
+
4. **Graceful Degradation** (`src/cli/hook-command.ts:26-66`): Sophisticated error classification — transport failures (worker down) return exit 0 (graceful), client bugs (4xx) return exit 2 (blocking).
|
|
88
|
+
|
|
89
|
+
5. **Smart Explore** (v10.5.0): Tree-sitter AST parsing for structural code navigation. `smart_search` → `smart_outline` → `smart_unfold` progressive disclosure.
|
|
90
|
+
|
|
91
|
+
### Comparison with ClaudeMemory
|
|
92
|
+
|
|
93
|
+
| Aspect | Claude-Mem | ClaudeMemory | Notes |
|
|
94
|
+
|--------|-----------|--------------|-------|
|
|
95
|
+
| **Data Model** | Observations + summaries | Subject-predicate-object facts | They store raw observations; we extract knowledge |
|
|
96
|
+
| **Storage** | SQLite + Chroma | Dual SQLite (project + global) | They need separate Chroma process |
|
|
97
|
+
| **Vector Search** | Chroma (external) | fastembed-rb (embedded) | We're simpler, they're more capable |
|
|
98
|
+
| **Architecture** | Worker service + hooks | MCP server + hooks | They have background process overhead |
|
|
99
|
+
| **MCP Tools** | search, timeline, get_observations, smart_* | 18 recall/management tools | Different focus |
|
|
100
|
+
| **Plugin Format** | marketplace.json | Ruby gem | They're easier to install |
|
|
101
|
+
| **Web UI** | React viewer at :37777 | None | Feature we don't need |
|
|
102
|
+
| **AI Providers** | Claude SDK + Gemini + OpenRouter | anthropic-rb | They're more flexible |
|
|
103
|
+
| **License** | AGPL-3.0 | MIT | Our license is more permissive |
|
|
104
|
+
| **Complexity** | Very high (~10K+ LOC) | Moderate (~5K LOC) | We're simpler by design |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Key Components Deep-Dive
|
|
109
|
+
|
|
110
|
+
### Component 1: Progressive Disclosure Search
|
|
111
|
+
|
|
112
|
+
**Purpose**: Minimize token usage during memory retrieval.
|
|
113
|
+
|
|
114
|
+
**Location**: `README:199-232`, MCP tools
|
|
115
|
+
|
|
116
|
+
**Implementation**:
|
|
117
|
+
```
|
|
118
|
+
Step 1: search(query="auth bug", type="bugfix", limit=10)
|
|
119
|
+
→ Returns compact index with IDs (~50-100 tokens/result)
|
|
120
|
+
Step 2: Review index, identify relevant IDs (e.g., #123, #456)
|
|
121
|
+
Step 3: get_observations(ids=[123, 456])
|
|
122
|
+
→ Returns full details (~500-1000 tokens/result)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Design Decisions**:
|
|
126
|
+
- ~10x token savings by filtering before fetching details
|
|
127
|
+
- Timeline layer provides chronological context
|
|
128
|
+
- Batch ID fetching for efficiency
|
|
129
|
+
|
|
130
|
+
### Component 2: Hook Error Classification
|
|
131
|
+
|
|
132
|
+
**Purpose**: Distinguish worker unavailability from actual bugs.
|
|
133
|
+
|
|
134
|
+
**Location**: `src/cli/hook-command.ts:26-66`
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Transport failures → exit 0 (graceful degradation)
|
|
138
|
+
const transportPatterns = [
|
|
139
|
+
'econnrefused', 'econnreset', 'epipe', 'etimedout',
|
|
140
|
+
'fetch failed', 'socket hang up',
|
|
141
|
+
];
|
|
142
|
+
// HTTP 4xx → exit 2 (blocking error, developer needs to see)
|
|
143
|
+
// HTTP 5xx → exit 0 (server issues, degrade gracefully)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Design Decisions**:
|
|
147
|
+
- Conservative: unknown errors are blocking (surface bugs)
|
|
148
|
+
- Transport failures never block Claude Code sessions
|
|
149
|
+
- Hook stderr suppressed (Claude Code shows stderr as error UI)
|
|
150
|
+
|
|
151
|
+
### Component 3: Smart Explore (Tree-Sitter AST)
|
|
152
|
+
|
|
153
|
+
**Purpose**: Token-optimized structural code search.
|
|
154
|
+
|
|
155
|
+
**Location**: v10.5.0 changelog, plugin skills
|
|
156
|
+
|
|
157
|
+
**Design Decisions**:
|
|
158
|
+
- 10 languages via tree-sitter grammars
|
|
159
|
+
- 3-tool progressive disclosure: search → outline → unfold
|
|
160
|
+
- Claims 6-12x token savings vs full file reads
|
|
161
|
+
- Complements rather than replaces Read tool
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Comparative Analysis
|
|
166
|
+
|
|
167
|
+
### What They Do Well
|
|
168
|
+
|
|
169
|
+
1. **Progressive Disclosure**: Elegant token-saving pattern for search results
|
|
170
|
+
2. **Graceful Degradation**: Sophisticated error classification prevents blocking Claude sessions
|
|
171
|
+
3. **Platform Adapters**: Clean abstraction for Claude Code vs Cursor
|
|
172
|
+
4. **Smart Explore**: AST-powered code navigation is genuinely useful
|
|
173
|
+
5. **Web Viewer**: Real-time memory stream with SSE
|
|
174
|
+
|
|
175
|
+
### What We Do Well
|
|
176
|
+
|
|
177
|
+
1. **Knowledge Distillation**: Structured facts > raw observations
|
|
178
|
+
2. **Truth Maintenance**: Supersession and conflict resolution
|
|
179
|
+
3. **Simplicity**: No background process, no external database
|
|
180
|
+
4. **Dual-Database System**: Clean project/global separation
|
|
181
|
+
5. **License**: MIT vs AGPL-3.0
|
|
182
|
+
6. **Test Architecture**: Focused, fast, no I/O in tests
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Adoption Opportunities
|
|
187
|
+
|
|
188
|
+
### High Priority ⭐
|
|
189
|
+
|
|
190
|
+
#### 1. Progressive Disclosure Pattern for Recall
|
|
191
|
+
- **Value**: ~10x token savings on large result sets
|
|
192
|
+
- **Evidence**: `README:199-232` — 3-layer search → timeline → details workflow
|
|
193
|
+
- **Implementation**: Our `memory.recall_index` + `memory.recall_details` already implements this! Validate it matches their token savings pattern.
|
|
194
|
+
- **Effort**: 0.5 days (validation and documentation)
|
|
195
|
+
- **Trade-off**: None — we already have the infrastructure
|
|
196
|
+
- **Recommendation**: **ADOPT** (document our existing progressive disclosure)
|
|
197
|
+
|
|
198
|
+
#### 2. Hook Error Classification
|
|
199
|
+
- **Value**: Prevent memory system errors from blocking Claude Code sessions
|
|
200
|
+
- **Evidence**: `src/cli/hook-command.ts:26-66` — transport vs client error classification
|
|
201
|
+
- **Implementation**: Add similar classification to our hook commands. Exit 0 for transport failures, exit 1 for bugs.
|
|
202
|
+
- **Effort**: 1 day
|
|
203
|
+
- **Trade-off**: Minimal
|
|
204
|
+
- **Recommendation**: **ADOPT**
|
|
205
|
+
|
|
206
|
+
### Medium Priority
|
|
207
|
+
|
|
208
|
+
#### 3. Platform Adapter Pattern
|
|
209
|
+
- **Value**: Clean abstraction for supporting multiple AI code editors
|
|
210
|
+
- **Evidence**: `src/cli/adapters/` — Claude Code, Cursor adapters
|
|
211
|
+
- **Implementation**: Extract hook input normalization into adapter interface
|
|
212
|
+
- **Effort**: 2-3 days
|
|
213
|
+
- **Trade-off**: Premature if we only support Claude Code
|
|
214
|
+
- **Recommendation**: **DEFER** — Only if Cursor/Windsurf support is requested
|
|
215
|
+
|
|
216
|
+
#### 4. Compact Result Mode Documentation
|
|
217
|
+
- **Value**: Our `compact: true` mode already provides token savings — document it better
|
|
218
|
+
- **Evidence**: Their progressive disclosure docs show clear token economics
|
|
219
|
+
- **Implementation**: Add token estimates to our MCP tool descriptions
|
|
220
|
+
- **Effort**: 0.5 days
|
|
221
|
+
- **Recommendation**: **ADOPT**
|
|
222
|
+
|
|
223
|
+
### Features to Avoid
|
|
224
|
+
|
|
225
|
+
- **Worker Service Architecture**: Background process adds complexity and failure modes. Our stdio MCP server is simpler and sufficient.
|
|
226
|
+
- **Chroma Vector Database**: External dependency. sqlite-vec (from QMD/episodic-memory) is better fit.
|
|
227
|
+
- **Web Viewer UI**: CLI output is sufficient. CLAUDE.md already says to avoid this.
|
|
228
|
+
- **AGPL License**: Restrictive for a developer tool.
|
|
229
|
+
- **Multiple AI Providers**: Over-engineering. We use anthropic-rb directly.
|
|
230
|
+
- **Smart Explore**: Interesting but out of scope — code search is not our domain.
|
|
231
|
+
- **Tree-Sitter AST Parsing**: Not relevant to memory/fact retrieval.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Key Takeaways
|
|
236
|
+
|
|
237
|
+
### Main Learnings
|
|
238
|
+
1. Progressive disclosure is the right pattern for token-efficient retrieval — we already have it
|
|
239
|
+
2. Hook error classification is important for not blocking user sessions
|
|
240
|
+
3. Worker service architecture adds significant complexity
|
|
241
|
+
4. Chroma is being used but sqlite-vec (from QMD/episodic-memory) is simpler
|
|
242
|
+
5. AGPL licensing is unusual for developer tools
|
|
243
|
+
|
|
244
|
+
### Recommended Adoption Order
|
|
245
|
+
1. **Document progressive disclosure**: We already have recall_index + recall_details
|
|
246
|
+
2. **Add hook error classification**: Prevent hook failures from blocking sessions
|
|
247
|
+
3. **Add token estimates to tool descriptions**: Help Claude use tools efficiently
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
*Analysis completed: 2026-03-02*
|
|
252
|
+
*Analyst: Claude Code*
|
|
253
|
+
*Review Status: Draft*
|