claude_memory 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.
- checksums.yaml +4 -4
- data/.claude/CLAUDE.md +1 -1
- data/.claude/rules/claude_memory.generated.md +1 -1
- data/.claude/settings.json +5 -0
- data/.claude/settings.local.json +9 -1
- data/.claude-plugin/marketplace.json +5 -2
- data/.claude-plugin/plugin.json +16 -3
- data/CHANGELOG.md +55 -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 +17 -1
- 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 +31 -2
|
@@ -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*
|