a2a-memory 0.10.0 → 0.10.1
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/README.md +134 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
# @a2a/memory - Persistent AI Memory for Claude Code
|
|
2
2
|
|
|
3
|
-
> v0.
|
|
3
|
+
> v0.10.0 — Local-first memory system with realtime context injection, semantic search, and team collaboration
|
|
4
4
|
|
|
5
|
-
Persistent AI memory for Claude Code. Automatically captures, stores, and retrieves knowledge across coding sessions.
|
|
5
|
+
Persistent AI memory for Claude Code. Automatically captures, stores, and retrieves knowledge across coding sessions with realtime prompt-level memory injection.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
### Core Capabilities
|
|
10
|
+
- **Realtime Context Injection** - Inject relevant memories on every prompt via UserPromptSubmit hook
|
|
10
11
|
- **Session Extraction** - Extract memories from Claude Code sessions (JSONL parsing)
|
|
11
12
|
- **Local-First DB** - SQLite with FTS5 full-text search + vector similarity
|
|
12
|
-
- **Auto-Capture Hooks** - Claude Code hooks for automatic memory
|
|
13
|
-
- **Context Injection** - Inject relevant memories at session start (hybrid search)
|
|
13
|
+
- **Auto-Capture Hooks** - 5 Claude Code hooks for automatic memory lifecycle
|
|
14
14
|
- **Hybrid Search** - FTS + Vector + Recency ranking (Reciprocal Rank Fusion)
|
|
15
|
+
- **Adaptive RAG Router** - Query complexity classification (simple/semantic/complex)
|
|
16
|
+
- **Cross-Encoder Reranker** - Precision re-ranking with ms-marco-MiniLM
|
|
15
17
|
- **Lifecycle Management** - Quality scoring, TTL-based cleanup, memory tiering (Hot/Warm/Cold)
|
|
16
18
|
|
|
17
19
|
### AI & Embeddings
|
|
20
|
+
- **E5 Embedding (384D)** - Local semantic embedding via e5-small-v2 (ONNX, ~16ms/query)
|
|
21
|
+
- **Local TF-IDF (64D)** - Lightweight hash-based embedding (fallback)
|
|
22
|
+
- **OpenAI Embedding (1536D)** - Cloud embedding via OpenAI API
|
|
18
23
|
- **LLM Integration** - AI-powered extraction and classification (OpenAI, Anthropic)
|
|
19
|
-
- **Embeddings** - Local TF-IDF (64D) or OpenAI (1536D) embeddings
|
|
20
24
|
- **Vector Quantization** - Float32 and Int8 scalar quantization for compression
|
|
21
25
|
|
|
26
|
+
### Intelligence
|
|
27
|
+
- **4-Way Dedup (Mem0 Pattern)** - ADD/UPDATE/DELETE/NOOP for memory deduplication
|
|
28
|
+
- **Skill Crystallization** - Repeated patterns auto-crystallize into reusable skills
|
|
29
|
+
- **Proficiency Tracking** - ACT-R cognitive model for skill level tracking
|
|
30
|
+
- **PreCompact Checkpoint** - Preserve critical context before context window compression
|
|
31
|
+
|
|
22
32
|
### Team & Sync
|
|
23
33
|
- **Server Sync** - Synchronize with A2A server via REST API
|
|
24
34
|
- **Team Collaboration** - Share memories across team members (CRDT vector clocks)
|
|
@@ -28,10 +38,10 @@ Persistent AI memory for Claude Code. Automatically captures, stores, and retrie
|
|
|
28
38
|
|
|
29
39
|
### Developer Experience
|
|
30
40
|
- **CLAUDE.md Sync** - Sync CLAUDE.md sections to memory DB
|
|
31
|
-
- **CLI (
|
|
41
|
+
- **CLI (19 commands)** - Full command-line interface for all operations
|
|
32
42
|
- **Logging** - JSON Lines hook logs with rotation and level filtering
|
|
33
43
|
- **i18n** - Internationalization support (Korean, English)
|
|
34
|
-
- **Sensitive Info Filter** - Auto-redaction of API keys, passwords, tokens (21 patterns)
|
|
44
|
+
- **Sensitive Info Filter** - Auto-redaction of API keys, passwords, tokens (21+ patterns)
|
|
35
45
|
|
|
36
46
|
## Quick Start
|
|
37
47
|
|
|
@@ -74,18 +84,24 @@ a2a-memory health
|
|
|
74
84
|
| `a2a-memory cleanup` | Remove low-quality/expired memories | `--dry-run` |
|
|
75
85
|
| `a2a-memory health` | System health check (DB, config, logs) | `--verbose` |
|
|
76
86
|
| `a2a-memory claude-sync` | Sync CLAUDE.md to memory DB | `--dry-run`, `--force` |
|
|
87
|
+
| `a2a-memory skill` | Manage crystallized skills | `list`, `inspect <id>` |
|
|
88
|
+
| `a2a-memory proficiency list` | Show proficiency levels for all skills | - |
|
|
89
|
+
| `a2a-memory proficiency inspect <id>` | Detailed proficiency analysis | - |
|
|
90
|
+
| `a2a-memory proficiency simulate` | Simulate proficiency scenarios | - |
|
|
77
91
|
|
|
78
92
|
## Architecture
|
|
79
93
|
|
|
80
94
|
### 1. Claude Code Hooks
|
|
81
95
|
|
|
82
|
-
After `a2a-memory setup`,
|
|
96
|
+
After `a2a-memory setup`, five hooks are registered:
|
|
83
97
|
|
|
84
|
-
| Hook | Trigger | Action |
|
|
85
|
-
|
|
86
|
-
| **SessionStart** | Session begins | Injects relevant memories via hybrid search |
|
|
87
|
-
| **PostToolUse** | After Write/Edit/Bash | Auto-captures significant actions
|
|
88
|
-
| **
|
|
98
|
+
| Hook | Trigger | Action | Performance |
|
|
99
|
+
|------|---------|--------|-------------|
|
|
100
|
+
| **SessionStart** | Session begins | Injects relevant memories via hybrid search | ~200ms |
|
|
101
|
+
| **PostToolUse** | After Write/Edit/Bash/Read/Grep/Glob | Auto-captures significant actions + dedup check | ~50ms |
|
|
102
|
+
| **UserPromptSubmit** | Every user prompt | Realtime FTS search + context injection | p50 < 30ms |
|
|
103
|
+
| **PreCompact** | Before context compression | Extracts key decisions/progress/TODOs as checkpoints | ~100ms |
|
|
104
|
+
| **SessionEnd** | Session ends | Extracts memories + team sync + skill evaluation | ~500ms |
|
|
89
105
|
|
|
90
106
|
### 2. Memory Extraction
|
|
91
107
|
|
|
@@ -98,8 +114,10 @@ Parses `~/.claude/projects/<project>/<session>.jsonl` files and extracts:
|
|
|
98
114
|
| `decision` | Architectural decisions with reasoning |
|
|
99
115
|
| `project_knowledge` | Project context and rules |
|
|
100
116
|
| `convention` | Development conventions and preferences |
|
|
117
|
+
| `learning` | Learned techniques and insights |
|
|
118
|
+
| `skill` | Crystallized reusable skills |
|
|
101
119
|
|
|
102
|
-
### 3. Hybrid Search
|
|
120
|
+
### 3. Hybrid Search with Adaptive RAG
|
|
103
121
|
|
|
104
122
|
Three-signal Reciprocal Rank Fusion (RRF):
|
|
105
123
|
|
|
@@ -108,10 +126,31 @@ Score = w1 * FTS_rank + w2 * Vector_similarity + w3 * Recency_score
|
|
|
108
126
|
```
|
|
109
127
|
|
|
110
128
|
- **FTS**: SQLite FTS5 full-text search
|
|
111
|
-
- **Vector**: TF-IDF (
|
|
129
|
+
- **Vector**: E5 (384D), TF-IDF (64D), or OpenAI (1536D) embeddings
|
|
112
130
|
- **Recency**: Time decay scoring
|
|
131
|
+
- **Skill Boost**: 1.5x weight for crystallized skill memories
|
|
132
|
+
|
|
133
|
+
**Adaptive Router** classifies query complexity:
|
|
134
|
+
- `simple` (1-2 keywords) → FTS only (< 5ms)
|
|
135
|
+
- `semantic` (questions, descriptions) → FTS + Vector (< 30ms)
|
|
136
|
+
- `complex` (code patterns, errors) → FTS + Vector + Reranker (< 100ms)
|
|
137
|
+
|
|
138
|
+
**Cross-Encoder Reranker** (optional):
|
|
139
|
+
- ms-marco-MiniLM-L-6-v2 for precision re-ranking
|
|
140
|
+
- top-20 → top-5 refinement
|
|
141
|
+
|
|
142
|
+
### 4. Memory Deduplication (Mem0 Pattern)
|
|
143
|
+
|
|
144
|
+
4-Way decision for every new memory:
|
|
113
145
|
|
|
114
|
-
|
|
146
|
+
| Action | Condition | Result |
|
|
147
|
+
|--------|-----------|--------|
|
|
148
|
+
| `ADD` | No similar memory exists | Create new |
|
|
149
|
+
| `UPDATE` | Similarity > 0.8 | Merge with existing |
|
|
150
|
+
| `DELETE` | New info invalidates old | Replace |
|
|
151
|
+
| `NOOP` | Similarity > 0.95 | Skip (exact duplicate) |
|
|
152
|
+
|
|
153
|
+
### 5. Storage & Indexing
|
|
115
154
|
|
|
116
155
|
- **SQLite database** at `~/.a2a/memory.db`
|
|
117
156
|
- FTS5 full-text search index
|
|
@@ -131,35 +170,56 @@ Config file: `~/.a2a/config.json`
|
|
|
131
170
|
"mode": "local",
|
|
132
171
|
"autoCapture": {
|
|
133
172
|
"enabled": false,
|
|
134
|
-
"triggers": ["Write", "Edit", "Bash"],
|
|
173
|
+
"triggers": ["Write", "Edit", "Bash", "Read", "Grep", "Glob"],
|
|
135
174
|
"significanceThreshold": 0.6
|
|
136
175
|
},
|
|
137
176
|
"autoInject": {
|
|
138
177
|
"enabled": true,
|
|
139
|
-
"maxMemories":
|
|
178
|
+
"maxMemories": 10,
|
|
140
179
|
"maxTokens": 2000
|
|
141
180
|
},
|
|
181
|
+
"realtimeInject": {
|
|
182
|
+
"enabled": true,
|
|
183
|
+
"maxMemories": 3,
|
|
184
|
+
"maxTokens": 1000,
|
|
185
|
+
"cacheSize": 20,
|
|
186
|
+
"cacheTTLSeconds": 60,
|
|
187
|
+
"timeoutMs": 100
|
|
188
|
+
},
|
|
189
|
+
"embedding": {
|
|
190
|
+
"enabled": false,
|
|
191
|
+
"provider": "local",
|
|
192
|
+
"dimensions": 64
|
|
193
|
+
},
|
|
194
|
+
"lifecycle": {
|
|
195
|
+
"ttlDays": 90,
|
|
196
|
+
"maxMemories": 1000,
|
|
197
|
+
"cleanupOnSessionEnd": false,
|
|
198
|
+
"qualityThreshold": 0.3
|
|
199
|
+
},
|
|
200
|
+
"skillConversion": {
|
|
201
|
+
"enabled": false,
|
|
202
|
+
"evaluationInterval": 5,
|
|
203
|
+
"minRepetitions": 3,
|
|
204
|
+
"similarityThreshold": 0.85,
|
|
205
|
+
"minConfidence": 0.7
|
|
206
|
+
},
|
|
207
|
+
"proficiency": {
|
|
208
|
+
"enabled": true,
|
|
209
|
+
"levelFormula": "activation",
|
|
210
|
+
"maxLevel": 10
|
|
211
|
+
},
|
|
142
212
|
"autoSync": {
|
|
143
213
|
"enabled": false,
|
|
144
214
|
"pushOnSessionEnd": true,
|
|
145
215
|
"pullOnSessionStart": true,
|
|
146
|
-
"timeoutMs":
|
|
216
|
+
"timeoutMs": 30000,
|
|
147
217
|
"intervalMs": 1800000
|
|
148
218
|
},
|
|
149
219
|
"db": {
|
|
150
220
|
"path": "~/.a2a/memory.db",
|
|
151
221
|
"maxSizeMB": 100
|
|
152
222
|
},
|
|
153
|
-
"embedding": {
|
|
154
|
-
"provider": "local",
|
|
155
|
-
"dimensions": 64
|
|
156
|
-
},
|
|
157
|
-
"lifecycle": {
|
|
158
|
-
"enabled": true,
|
|
159
|
-
"maxMemories": 10000,
|
|
160
|
-
"ttlDays": { "working": 7, "episodic": 90 },
|
|
161
|
-
"minQualityScore": 0.3
|
|
162
|
-
},
|
|
163
223
|
"logging": {
|
|
164
224
|
"enabled": false,
|
|
165
225
|
"level": "info",
|
|
@@ -170,6 +230,24 @@ Config file: `~/.a2a/config.json`
|
|
|
170
230
|
}
|
|
171
231
|
```
|
|
172
232
|
|
|
233
|
+
### Embedding Providers
|
|
234
|
+
|
|
235
|
+
| Provider | Dimensions | Latency | Install |
|
|
236
|
+
|----------|-----------|---------|---------|
|
|
237
|
+
| `local` (TF-IDF) | 64 | < 1ms | Built-in |
|
|
238
|
+
| `e5` (e5-small-v2) | 384 | ~16ms | `npm install @huggingface/transformers` |
|
|
239
|
+
| `openai` | 1536 | ~100ms | Requires API key |
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Enable E5 embeddings
|
|
243
|
+
a2a-memory config set embedding.enabled true
|
|
244
|
+
a2a-memory config set embedding.provider e5
|
|
245
|
+
a2a-memory config set embedding.dimensions 384
|
|
246
|
+
|
|
247
|
+
# Generate embeddings for existing memories
|
|
248
|
+
a2a-memory embed generate
|
|
249
|
+
```
|
|
250
|
+
|
|
173
251
|
### Server Sync
|
|
174
252
|
|
|
175
253
|
```bash
|
|
@@ -223,7 +301,13 @@ import {
|
|
|
223
301
|
|
|
224
302
|
// Search
|
|
225
303
|
HybridRanker,
|
|
304
|
+
AdaptiveRouter,
|
|
305
|
+
CrossEncoderReranker,
|
|
226
306
|
createEmbeddingProvider,
|
|
307
|
+
E5EmbeddingProvider,
|
|
308
|
+
|
|
309
|
+
// Extraction
|
|
310
|
+
DedupManager,
|
|
227
311
|
|
|
228
312
|
// Sync
|
|
229
313
|
A2AClient,
|
|
@@ -239,6 +323,10 @@ import {
|
|
|
239
323
|
encryptContent,
|
|
240
324
|
decryptContent,
|
|
241
325
|
|
|
326
|
+
// Proficiency
|
|
327
|
+
ACTREngine,
|
|
328
|
+
ProficiencyTracker,
|
|
329
|
+
|
|
242
330
|
// Claude.md
|
|
243
331
|
syncClaudeMd,
|
|
244
332
|
} from 'a2a-memory';
|
|
@@ -254,11 +342,21 @@ db.createMemory({
|
|
|
254
342
|
tags: ['auth', 'jwt'],
|
|
255
343
|
});
|
|
256
344
|
|
|
257
|
-
// Hybrid search with embeddings
|
|
258
|
-
const provider = createEmbeddingProvider({ provider: '
|
|
345
|
+
// Hybrid search with E5 embeddings
|
|
346
|
+
const provider = createEmbeddingProvider({ provider: 'e5', dimensions: 384, enabled: true });
|
|
259
347
|
const ranker = new HybridRanker(db, provider);
|
|
260
348
|
const ranked = await ranker.search('auth error', { limit: 5 });
|
|
261
349
|
|
|
350
|
+
// Adaptive RAG routing
|
|
351
|
+
const router = new AdaptiveRouter();
|
|
352
|
+
const route = router.classify('how to fix JWT token expiration?');
|
|
353
|
+
// → { complexity: 'semantic', strategy: 'fts+vector' }
|
|
354
|
+
|
|
355
|
+
// Memory deduplication
|
|
356
|
+
const dedup = new DedupManager(db);
|
|
357
|
+
const decision = await dedup.decide(newContent, existingMemories);
|
|
358
|
+
// → { action: 'UPDATE', targetId: 'mem_123', reason: '...' }
|
|
359
|
+
|
|
262
360
|
// Server sync
|
|
263
361
|
const client = new A2AClient({
|
|
264
362
|
serverUrl: 'https://a2a-api-production-8d17.up.railway.app',
|
|
@@ -268,41 +366,24 @@ const sync = new MemorySynchronizer(db, client);
|
|
|
268
366
|
await sync.push();
|
|
269
367
|
await sync.pull();
|
|
270
368
|
|
|
271
|
-
//
|
|
272
|
-
const scheduler = new SyncScheduler(sync, { intervalMs: 1800000 });
|
|
273
|
-
scheduler.start();
|
|
274
|
-
|
|
275
|
-
// Team collaboration
|
|
276
|
-
const teamSync = new TeamSynchronizer(db, client, 'team-id');
|
|
277
|
-
await teamSync.pushTeamMemories();
|
|
278
|
-
await teamSync.pullTeamMemories();
|
|
279
|
-
|
|
280
|
-
// Lifecycle management
|
|
281
|
-
await cleanupMemories(db, { ttlDays: 90, minQualityScore: 0.3 });
|
|
282
|
-
await rebalanceTiers(db);
|
|
283
|
-
|
|
284
|
-
// Anthropic Memory API adapter (for future integration)
|
|
369
|
+
// Anthropic Memory API adapter
|
|
285
370
|
import { toAnthropicFormat, fromAnthropicFormat } from 'a2a-memory';
|
|
286
371
|
|
|
287
372
|
const memory = db.getMemory('mem_123');
|
|
288
373
|
const anthropicFormat = toAnthropicFormat(memory);
|
|
289
|
-
// → { id, content, type: 'user_preference' | 'learned_info' | 'conversation_context', ... }
|
|
290
|
-
|
|
291
|
-
const anthropicMemory = { id: '...', content: '...', type: 'learned_info', ... };
|
|
292
|
-
const a2aInput = fromAnthropicFormat(anthropicMemory);
|
|
293
|
-
db.createMemory(a2aInput);
|
|
294
374
|
```
|
|
295
375
|
|
|
296
376
|
## Security
|
|
297
377
|
|
|
298
378
|
### Sensitive Information Protection
|
|
299
379
|
|
|
300
|
-
Automatically filters 21 patterns including:
|
|
380
|
+
Automatically filters 21+ patterns including:
|
|
301
381
|
- Cloud provider keys (AWS, Google, Azure)
|
|
302
382
|
- API keys and secrets (OpenAI, Stripe, GitHub)
|
|
303
383
|
- Database connection strings
|
|
304
|
-
- Private keys and certificates (RSA, EC, DSA)
|
|
384
|
+
- Private keys and certificates (RSA, EC, DSA, OPENSSH)
|
|
305
385
|
- JWT tokens and session cookies
|
|
386
|
+
- Service tokens (Slack, Discord, npm, PyPI)
|
|
306
387
|
- Personal identifiable information (Korean SSN, Business registration)
|
|
307
388
|
|
|
308
389
|
### Encryption
|
|
@@ -330,6 +411,7 @@ Fallback: Encrypted file storage at `~/.a2a/credentials.enc`
|
|
|
330
411
|
|
|
331
412
|
- Node.js >= 18.0.0
|
|
332
413
|
- Claude Code (for hooks integration)
|
|
414
|
+
- `@huggingface/transformers` (optional, for E5 embeddings)
|
|
333
415
|
|
|
334
416
|
## License
|
|
335
417
|
|