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,217 @@
|
|
|
1
|
+
# Episodic Memory Analysis
|
|
2
|
+
|
|
3
|
+
*Analysis Date: 2026-03-02*
|
|
4
|
+
*Repository: https://github.com/obra/episodic-memory*
|
|
5
|
+
*Version: 1.0.15 (commit 6feaa5b)*
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Executive Summary
|
|
10
|
+
|
|
11
|
+
### Project Purpose
|
|
12
|
+
|
|
13
|
+
Episodic Memory provides semantic search for Claude Code conversations. It indexes past sessions and makes them searchable via natural language, enabling Claude to remember decisions, patterns, and context across sessions.
|
|
14
|
+
|
|
15
|
+
### Key Innovation
|
|
16
|
+
|
|
17
|
+
**Conversation-level semantic search with local embeddings.** Rather than extracting structured facts, episodic-memory preserves raw conversation exchanges (user/assistant pairs) and makes them searchable via Transformers.js embeddings — all local, no API calls for search. Uses Claude Agent SDK for optional summarization.
|
|
18
|
+
|
|
19
|
+
### Technology Stack
|
|
20
|
+
|
|
21
|
+
| Component | Technology |
|
|
22
|
+
|-----------|-----------|
|
|
23
|
+
| **Language** | TypeScript (ESM) |
|
|
24
|
+
| **Database** | better-sqlite3 + sqlite-vec v0.1.7-alpha.2 |
|
|
25
|
+
| **Embeddings** | @xenova/transformers (all-MiniLM-L6-v2, local ONNX) |
|
|
26
|
+
| **Summarization** | @anthropic-ai/claude-agent-sdk (Haiku default) |
|
|
27
|
+
| **MCP** | @modelcontextprotocol/sdk v1.20.0 |
|
|
28
|
+
| **Validation** | Zod v3 |
|
|
29
|
+
| **Build** | tsc + esbuild |
|
|
30
|
+
| **Testing** | vitest |
|
|
31
|
+
| **Plugin** | Claude Code marketplace format |
|
|
32
|
+
|
|
33
|
+
### Production Readiness
|
|
34
|
+
|
|
35
|
+
- **Maturity**: Stable (v1.0.15), actively maintained
|
|
36
|
+
- **Test Coverage**: vitest suite (api-config, parser, db, sync, search, etc.)
|
|
37
|
+
- **Plugin Distribution**: Claude Code marketplace
|
|
38
|
+
- **Author**: Jesse Vincent (obra) — well-known Ruby/Perl community figure
|
|
39
|
+
- **Offline**: Full local operation (embeddings + search), summarization optional
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Architecture Overview
|
|
44
|
+
|
|
45
|
+
### Data Model
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
~/.claude/projects/ (raw conversation JSONL files)
|
|
49
|
+
↓ sync/copy
|
|
50
|
+
~/.episodic-memory/archive/ (archived copies)
|
|
51
|
+
↓ parse
|
|
52
|
+
exchanges table (id, project, timestamp, user_message, assistant_message, archive_path, line_start, line_end)
|
|
53
|
+
↓ embed
|
|
54
|
+
vec_exchanges (sqlite-vec virtual table, vector similarity)
|
|
55
|
+
↓ summarize (optional)
|
|
56
|
+
summaries (Claude-generated conversation summaries)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Key schema features (`src/db.ts:57-79`):
|
|
60
|
+
- Session metadata: `session_id`, `cwd`, `git_branch`, `claude_version`
|
|
61
|
+
- Thinking metadata: `thinking_level`, `thinking_disabled`, `thinking_triggers`
|
|
62
|
+
- Parent tracking: `parent_uuid`, `is_sidechain` for conversation branching
|
|
63
|
+
|
|
64
|
+
### Design Patterns
|
|
65
|
+
|
|
66
|
+
1. **Exchange-Level Granularity** (`src/indexer.ts:40-100`): Each user/assistant pair is a searchable unit. Embeddings combine both messages for context.
|
|
67
|
+
|
|
68
|
+
2. **Local-First Embeddings** (`src/embeddings.ts:1-46`): Xenova/transformers.js with all-MiniLM-L6-v2 — no API calls, no API keys, works offline. 384-dim vectors, 512-token max.
|
|
69
|
+
|
|
70
|
+
3. **Delta Sync** (`src/indexer.ts:64-89`): Only copies new/modified files from `~/.claude/projects` to archive. Idempotent and safe for concurrent execution.
|
|
71
|
+
|
|
72
|
+
4. **Multi-Concept AND Search** (`src/search.ts:27-100`): Supports both single-query and multi-concept array queries. Vector and text modes combinable.
|
|
73
|
+
|
|
74
|
+
5. **Exclusion Markers**: `<INSTRUCTIONS-TO-EPISODIC-MEMORY>DO NOT INDEX THIS CHAT</INSTRUCTIONS-TO-EPISODIC-MEMORY>` for sensitive conversations.
|
|
75
|
+
|
|
76
|
+
### Comparison with ClaudeMemory
|
|
77
|
+
|
|
78
|
+
| Aspect | Episodic Memory | ClaudeMemory | Notes |
|
|
79
|
+
|--------|----------------|--------------|-------|
|
|
80
|
+
| **Data Model** | Raw conversation exchanges | Distilled facts with provenance | Different philosophy |
|
|
81
|
+
| **Storage** | better-sqlite3 + sqlite-vec | Sequel + Extralite | Both use SQLite |
|
|
82
|
+
| **Embeddings** | @xenova/transformers (local) | fastembed-rb (local) | Both local ONNX |
|
|
83
|
+
| **Vector Search** | sqlite-vec (native) | JSON embeddings (O(n)) | They're faster |
|
|
84
|
+
| **Summarization** | Claude Agent SDK (optional) | Distiller pipeline | We extract structured facts |
|
|
85
|
+
| **Scope** | Per-conversation exchanges | Per-fact with project/global scope | We're more granular |
|
|
86
|
+
| **MCP Tools** | search, show | 18 tools | We're more comprehensive |
|
|
87
|
+
| **Plugin** | marketplace.json | Ruby gem | They're easier to install |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Key Components Deep-Dive
|
|
92
|
+
|
|
93
|
+
### Component 1: Local Embedding Pipeline
|
|
94
|
+
|
|
95
|
+
**Purpose**: Generate vector embeddings without external APIs.
|
|
96
|
+
|
|
97
|
+
**Location**: `src/embeddings.ts:1-46`
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// From src/embeddings.ts:8-13
|
|
101
|
+
embeddingPipeline = await pipeline(
|
|
102
|
+
'feature-extraction',
|
|
103
|
+
'Xenova/all-MiniLM-L6-v2'
|
|
104
|
+
);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Design Decisions**:
|
|
108
|
+
- all-MiniLM-L6-v2: 384 dimensions, fast, good quality for conversation search
|
|
109
|
+
- Combined user+assistant+tools for richer embeddings (`embeddings.ts:32-45`)
|
|
110
|
+
- 2000 character truncation (512 token model limit)
|
|
111
|
+
|
|
112
|
+
### Component 2: Conversation Sync
|
|
113
|
+
|
|
114
|
+
**Purpose**: Copy and archive conversations from Claude Code's project directory.
|
|
115
|
+
|
|
116
|
+
**Location**: `src/indexer.ts:40-100`
|
|
117
|
+
|
|
118
|
+
**Design Decisions**:
|
|
119
|
+
- Copies to `~/.episodic-memory/archive/` for persistence
|
|
120
|
+
- Batch processing with configurable concurrency
|
|
121
|
+
- Exclude projects via config
|
|
122
|
+
- Optional no-summaries mode for faster indexing
|
|
123
|
+
|
|
124
|
+
### Component 3: Multi-Concept Search
|
|
125
|
+
|
|
126
|
+
**Purpose**: Find conversations matching ALL of multiple concepts.
|
|
127
|
+
|
|
128
|
+
**Location**: `src/search.ts:27-100`, `src/mcp-server.ts:31-68`
|
|
129
|
+
|
|
130
|
+
**Design Decisions**:
|
|
131
|
+
- Array query triggers multi-concept AND search
|
|
132
|
+
- Single string triggers standard search
|
|
133
|
+
- Modes: vector, text, both
|
|
134
|
+
- Date range filtering (after/before)
|
|
135
|
+
- Line-range addressing for conversation excerpts
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Comparative Analysis
|
|
140
|
+
|
|
141
|
+
### What They Do Well
|
|
142
|
+
|
|
143
|
+
1. **Local Embeddings**: Xenova/transformers.js works offline with zero configuration
|
|
144
|
+
2. **sqlite-vec Integration**: Native vector search in SQLite
|
|
145
|
+
3. **Plugin Distribution**: Single `/plugin install` command
|
|
146
|
+
4. **Conversation Preservation**: Keeps raw context, not just extracted facts
|
|
147
|
+
5. **Multi-Concept AND Search**: Powerful for finding intersections
|
|
148
|
+
|
|
149
|
+
### What We Do Well
|
|
150
|
+
|
|
151
|
+
1. **Knowledge Distillation**: Facts with provenance > raw transcripts
|
|
152
|
+
2. **Truth Maintenance**: Supersession and conflict resolution
|
|
153
|
+
3. **Dual-Database System**: Project/global scope separation
|
|
154
|
+
4. **Comprehensive MCP Tools**: 18 tools vs 2
|
|
155
|
+
5. **Rich Metadata**: Temporal validity, predicate policies, fact links
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Adoption Opportunities
|
|
160
|
+
|
|
161
|
+
### High Priority ⭐
|
|
162
|
+
|
|
163
|
+
#### 1. sqlite-vec for Vector Search (Reinforces QMD Finding)
|
|
164
|
+
- **Value**: Native vector search, eliminates O(n) Ruby similarity
|
|
165
|
+
- **Evidence**: `src/db.ts:5,51` — single `sqliteVec.load(db)` call with better-sqlite3
|
|
166
|
+
- **Implementation**: Same as QMD recommendation — add sqlite-vec extension
|
|
167
|
+
- **Effort**: 3-5 days
|
|
168
|
+
- **Trade-off**: Native dependency
|
|
169
|
+
- **Recommendation**: **ADOPT** — Both QMD and episodic-memory validate sqlite-vec
|
|
170
|
+
|
|
171
|
+
#### 2. Multi-Concept AND Search
|
|
172
|
+
- **Value**: Find facts matching ALL of multiple concepts (intersection queries)
|
|
173
|
+
- **Evidence**: `src/mcp-server.ts:31-40` — array query for multi-concept search
|
|
174
|
+
- **Implementation**: Already partially implemented as `memory.search_concepts`
|
|
175
|
+
- **Effort**: 1 day (verify existing implementation covers this)
|
|
176
|
+
- **Trade-off**: None
|
|
177
|
+
- **Recommendation**: **ADOPT** — Validate our existing implementation matches their pattern
|
|
178
|
+
|
|
179
|
+
#### 3. Conversation Exclusion Markers
|
|
180
|
+
- **Value**: Let users exclude sensitive sessions from indexing
|
|
181
|
+
- **Evidence**: README:236-251 — `<INSTRUCTIONS-TO-EPISODIC-MEMORY>DO NOT INDEX</INSTRUCTIONS-TO-EPISODIC-MEMORY>`
|
|
182
|
+
- **Implementation**: Honor `<no-memory>` or similar tags during ingest
|
|
183
|
+
- **Effort**: 0.5 days
|
|
184
|
+
- **Trade-off**: None
|
|
185
|
+
- **Recommendation**: **ADOPT** — We already strip `<no-memory>` tags, but should skip entire sessions containing them
|
|
186
|
+
|
|
187
|
+
### Medium Priority
|
|
188
|
+
|
|
189
|
+
#### 4. Exchange-Level Embedding
|
|
190
|
+
- **Value**: Combined user+assistant+tool embeddings capture richer context
|
|
191
|
+
- **Evidence**: `src/embeddings.ts:32-45` — combines user, assistant, and tool names
|
|
192
|
+
- **Implementation**: Include tool context in fact embeddings during distillation
|
|
193
|
+
- **Effort**: 1 day
|
|
194
|
+
- **Trade-off**: Slightly larger embeddings
|
|
195
|
+
- **Recommendation**: **CONSIDER**
|
|
196
|
+
|
|
197
|
+
### Features to Avoid
|
|
198
|
+
|
|
199
|
+
- **Raw Conversation Storage**: We distill into structured facts — keeping raw exchanges would bloat storage
|
|
200
|
+
- **Claude Agent SDK for Summarization**: We use direct API calls via anthropic-rb gem
|
|
201
|
+
- **all-MiniLM-L6-v2 Model**: Our bge-small-en-v1.5 is better for fact-style content (384-dim vs 384-dim, but better benchmarks)
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Key Takeaways
|
|
206
|
+
|
|
207
|
+
### Main Learnings
|
|
208
|
+
1. sqlite-vec is becoming standard — used by QMD, episodic-memory, and others
|
|
209
|
+
2. Multi-concept AND search is valuable for intersecting knowledge domains
|
|
210
|
+
3. Local-first embeddings (no API) is the right approach — we already do this
|
|
211
|
+
4. Conversation exclusion markers provide important privacy control
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
*Analysis completed: 2026-03-02*
|
|
216
|
+
*Analyst: Claude Code*
|
|
217
|
+
*Review Status: Draft*
|