moflo 4.8.21 → 4.8.23
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/.claude/agents/browser/browser-agent.yaml +182 -182
- package/.claude/agents/core/coder.md +265 -265
- package/.claude/agents/core/planner.md +167 -167
- package/.claude/agents/core/researcher.md +189 -189
- package/.claude/agents/core/reviewer.md +325 -325
- package/.claude/agents/core/tester.md +318 -318
- package/.claude/agents/database-specialist.yaml +21 -21
- package/.claude/agents/dual-mode/codex-coordinator.md +224 -224
- package/.claude/agents/dual-mode/codex-worker.md +211 -211
- package/.claude/agents/dual-mode/dual-orchestrator.md +291 -291
- package/.claude/agents/github/code-review-swarm.md +537 -537
- package/.claude/agents/github/github-modes.md +172 -172
- package/.claude/agents/github/issue-tracker.md +318 -318
- package/.claude/agents/github/multi-repo-swarm.md +552 -552
- package/.claude/agents/github/pr-manager.md +190 -190
- package/.claude/agents/github/project-board-sync.md +508 -508
- package/.claude/agents/github/release-manager.md +366 -366
- package/.claude/agents/github/release-swarm.md +582 -582
- package/.claude/agents/github/repo-architect.md +397 -397
- package/.claude/agents/github/swarm-issue.md +572 -572
- package/.claude/agents/github/swarm-pr.md +427 -427
- package/.claude/agents/github/sync-coordinator.md +451 -451
- package/.claude/agents/github/workflow-automation.md +634 -634
- package/.claude/agents/goal/code-goal-planner.md +445 -445
- package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +129 -129
- package/.claude/agents/hive-mind/queen-coordinator.md +202 -202
- package/.claude/agents/hive-mind/scout-explorer.md +241 -241
- package/.claude/agents/hive-mind/swarm-memory-manager.md +192 -192
- package/.claude/agents/hive-mind/worker-specialist.md +216 -216
- package/.claude/agents/index.yaml +17 -17
- package/.claude/agents/neural/safla-neural.md +73 -73
- package/.claude/agents/project-coordinator.yaml +15 -15
- package/.claude/agents/python-specialist.yaml +21 -21
- package/.claude/agents/reasoning/goal-planner.md +72 -72
- package/.claude/agents/security-auditor.yaml +20 -20
- package/.claude/agents/swarm/adaptive-coordinator.md +395 -395
- package/.claude/agents/swarm/hierarchical-coordinator.md +326 -326
- package/.claude/agents/swarm/mesh-coordinator.md +391 -391
- package/.claude/agents/templates/migration-plan.md +745 -745
- package/.claude/agents/typescript-specialist.yaml +21 -21
- package/.claude/checkpoints/1767754460.json +8 -8
- package/.claude/commands/agents/agent-spawning.md +28 -28
- package/.claude/commands/github/github-modes.md +146 -146
- package/.claude/commands/github/github-swarm.md +121 -121
- package/.claude/commands/github/issue-tracker.md +291 -291
- package/.claude/commands/github/pr-manager.md +169 -169
- package/.claude/commands/github/release-manager.md +337 -337
- package/.claude/commands/github/repo-architect.md +366 -366
- package/.claude/commands/github/sync-coordinator.md +300 -300
- package/.claude/commands/memory/neural.md +47 -47
- package/.claude/commands/sparc/analyzer.md +51 -51
- package/.claude/commands/sparc/architect.md +53 -53
- package/.claude/commands/sparc/ask.md +97 -97
- package/.claude/commands/sparc/batch-executor.md +54 -54
- package/.claude/commands/sparc/code.md +89 -89
- package/.claude/commands/sparc/coder.md +54 -54
- package/.claude/commands/sparc/debug.md +83 -83
- package/.claude/commands/sparc/debugger.md +54 -54
- package/.claude/commands/sparc/designer.md +53 -53
- package/.claude/commands/sparc/devops.md +109 -109
- package/.claude/commands/sparc/docs-writer.md +80 -80
- package/.claude/commands/sparc/documenter.md +54 -54
- package/.claude/commands/sparc/innovator.md +54 -54
- package/.claude/commands/sparc/integration.md +83 -83
- package/.claude/commands/sparc/mcp.md +117 -117
- package/.claude/commands/sparc/memory-manager.md +54 -54
- package/.claude/commands/sparc/optimizer.md +54 -54
- package/.claude/commands/sparc/orchestrator.md +131 -131
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
- package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
- package/.claude/commands/sparc/researcher.md +54 -54
- package/.claude/commands/sparc/reviewer.md +54 -54
- package/.claude/commands/sparc/security-review.md +80 -80
- package/.claude/commands/sparc/sparc-modes.md +174 -174
- package/.claude/commands/sparc/sparc.md +111 -111
- package/.claude/commands/sparc/spec-pseudocode.md +80 -80
- package/.claude/commands/sparc/supabase-admin.md +348 -348
- package/.claude/commands/sparc/swarm-coordinator.md +54 -54
- package/.claude/commands/sparc/tdd.md +54 -54
- package/.claude/commands/sparc/tester.md +54 -54
- package/.claude/commands/sparc/tutorial.md +79 -79
- package/.claude/commands/sparc/workflow-manager.md +54 -54
- package/.claude/commands/sparc.md +166 -166
- package/.claude/commands/swarm/analysis.md +95 -95
- package/.claude/commands/swarm/development.md +96 -96
- package/.claude/commands/swarm/examples.md +168 -168
- package/.claude/commands/swarm/maintenance.md +102 -102
- package/.claude/commands/swarm/optimization.md +117 -117
- package/.claude/commands/swarm/research.md +136 -136
- package/.claude/commands/swarm/testing.md +131 -131
- package/.claude/commands/workflows/development.md +77 -77
- package/.claude/commands/workflows/research.md +62 -62
- package/.claude/guidance/moflo-bootstrap.md +126 -126
- package/.claude/guidance/shipped/agent-bootstrap.md +126 -126
- package/.claude/guidance/shipped/guidance-memory-strategy.md +262 -262
- package/.claude/guidance/shipped/memory-strategy.md +204 -204
- package/.claude/guidance/shipped/moflo.md +668 -653
- package/.claude/guidance/shipped/task-swarm-integration.md +441 -441
- package/.claude/helpers/intelligence.cjs +207 -207
- package/.claude/helpers/statusline.cjs +851 -851
- package/.claude/settings.local.json +18 -0
- package/.claude/skills/fl/SKILL.md +583 -583
- package/.claude/skills/flo/SKILL.md +583 -583
- package/.claude/skills/github-code-review/SKILL.md +1140 -1140
- package/.claude/skills/github-multi-repo/SKILL.md +874 -874
- package/.claude/skills/github-project-management/SKILL.md +1277 -1277
- package/.claude/skills/github-release-management/SKILL.md +1081 -1081
- package/.claude/skills/github-workflow-automation/SKILL.md +1065 -1065
- package/.claude/skills/hive-mind-advanced/SKILL.md +712 -712
- package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
- package/.claude/skills/performance-analysis/SKILL.md +563 -563
- package/.claude/skills/sparc-methodology/SKILL.md +1115 -1115
- package/.claude/skills/swarm-advanced/SKILL.md +973 -973
- package/.claude/workflow-state.json +4 -4
- package/LICENSE +21 -21
- package/README.md +698 -685
- package/bin/cli.js +0 -0
- package/bin/gate-hook.mjs +50 -50
- package/bin/gate.cjs +138 -138
- package/bin/generate-code-map.mjs +775 -775
- package/bin/hook-handler.cjs +83 -83
- package/bin/hooks.mjs +656 -656
- package/bin/index-guidance.mjs +892 -892
- package/bin/index-tests.mjs +709 -709
- package/bin/lib/process-manager.mjs +243 -243
- package/bin/lib/registry-cleanup.cjs +41 -41
- package/bin/prompt-hook.mjs +72 -72
- package/bin/semantic-search.mjs +472 -472
- package/bin/session-start-launcher.mjs +238 -238
- package/bin/setup-project.mjs +250 -250
- package/package.json +123 -123
- package/src/@claude-flow/cli/README.md +452 -452
- package/src/@claude-flow/cli/bin/cli.js +180 -180
- package/src/@claude-flow/cli/bin/preinstall.cjs +2 -2
- package/src/@claude-flow/cli/dist/src/commands/completions.js +409 -409
- package/src/@claude-flow/cli/dist/src/commands/doctor.js +18 -2
- package/src/@claude-flow/cli/dist/src/commands/embeddings.js +25 -25
- package/src/@claude-flow/cli/dist/src/commands/github.js +61 -61
- package/src/@claude-flow/cli/dist/src/commands/hive-mind.js +90 -90
- package/src/@claude-flow/cli/dist/src/commands/hooks.js +9 -9
- package/src/@claude-flow/cli/dist/src/commands/init.js +3 -8
- package/src/@claude-flow/cli/dist/src/commands/ruvector/import.js +14 -14
- package/src/@claude-flow/cli/dist/src/commands/ruvector/setup.js +624 -624
- package/src/@claude-flow/cli/dist/src/config/moflo-config.d.ts +3 -0
- package/src/@claude-flow/cli/dist/src/config/moflo-config.js +101 -91
- package/src/@claude-flow/cli/dist/src/index.d.ts +5 -0
- package/src/@claude-flow/cli/dist/src/index.js +44 -0
- package/src/@claude-flow/cli/dist/src/init/claudemd-generator.d.ts +29 -29
- package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +43 -43
- package/src/@claude-flow/cli/dist/src/init/executor.js +453 -453
- package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +482 -482
- package/src/@claude-flow/cli/dist/src/init/moflo-init.d.ts +30 -30
- package/src/@claude-flow/cli/dist/src/init/moflo-init.js +140 -140
- package/src/@claude-flow/cli/dist/src/init/statusline-generator.js +876 -876
- package/src/@claude-flow/cli/dist/src/memory/memory-initializer.js +371 -371
- package/src/@claude-flow/cli/dist/src/runtime/headless.js +28 -28
- package/src/@claude-flow/cli/dist/src/services/container-worker-pool.d.ts +197 -0
- package/src/@claude-flow/cli/dist/src/services/container-worker-pool.js +584 -0
- package/src/@claude-flow/cli/dist/src/services/daemon-lock.d.ts +14 -0
- package/src/@claude-flow/cli/dist/src/services/daemon-lock.js +1 -1
- package/src/@claude-flow/cli/dist/src/services/headless-worker-executor.js +84 -84
- package/src/@claude-flow/cli/package.json +1 -1
- package/src/@claude-flow/guidance/README.md +1195 -1195
- package/src/@claude-flow/guidance/package.json +198 -198
- package/src/@claude-flow/memory/README.md +587 -587
- package/src/@claude-flow/memory/dist/agentdb-backend.js +26 -26
- package/src/@claude-flow/memory/dist/auto-memory-bridge.test.js +27 -27
- package/src/@claude-flow/memory/dist/hybrid-backend.d.ts +245 -0
- package/src/@claude-flow/memory/dist/hybrid-backend.js +569 -0
- package/src/@claude-flow/memory/dist/hybrid-backend.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/hybrid-backend.test.js +320 -0
- package/src/@claude-flow/memory/dist/sqlite-backend.d.ts +121 -0
- package/src/@claude-flow/memory/dist/sqlite-backend.js +572 -0
- package/src/@claude-flow/memory/dist/sqljs-backend.js +26 -26
- package/src/@claude-flow/memory/package.json +44 -44
- package/src/@claude-flow/shared/README.md +323 -323
- package/src/@claude-flow/shared/dist/events/event-store.js +31 -31
- package/src/README.md +493 -493
|
@@ -1,587 +1,587 @@
|
|
|
1
|
-
# @claude-flow/memory
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@claude-flow/memory)
|
|
4
|
-
[](https://www.npmjs.com/package/@claude-flow/memory)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
7
|
-
[](https://github.com/eric-cielo/moflo)
|
|
8
|
-
|
|
9
|
-
> High-performance memory module for Claude Flow V3 - AgentDB unification, HNSW indexing, vector search, self-learning knowledge graph, and hybrid SQLite+AgentDB backend (ADR-009).
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **150x-12,500x Faster Search** - HNSW (Hierarchical Navigable Small World) vector index for ultra-fast similarity search
|
|
14
|
-
- **Hybrid Backend** - SQLite for structured data + AgentDB for vectors (ADR-009)
|
|
15
|
-
- **Auto Memory Bridge** - Bidirectional sync between Claude Code auto memory and AgentDB (ADR-048)
|
|
16
|
-
- **Self-Learning** - LearningBridge connects insights to SONA/ReasoningBank neural pipeline (ADR-049)
|
|
17
|
-
- **Knowledge Graph** - PageRank + label propagation community detection over memory entries (ADR-049)
|
|
18
|
-
- **Agent-Scoped Memory** - 3-scope agent memory (project/local/user) with cross-agent knowledge transfer (ADR-049)
|
|
19
|
-
- **Vector Quantization** - Binary, scalar, and product quantization for 4-32x memory reduction
|
|
20
|
-
- **Multiple Distance Metrics** - Cosine, Euclidean, dot product, and Manhattan distance
|
|
21
|
-
- **Query Builder** - Fluent API for building complex memory queries
|
|
22
|
-
- **Cache Manager** - LRU caching with configurable size and TTL
|
|
23
|
-
- **Migration Tools** - Seamless migration from V2 memory systems
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install @claude-flow/memory
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Quick Start
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { HNSWIndex, AgentDBAdapter, CacheManager } from '@claude-flow/memory';
|
|
35
|
-
|
|
36
|
-
// Create HNSW index for vector search
|
|
37
|
-
const index = new HNSWIndex({
|
|
38
|
-
dimensions: 1536, // OpenAI embedding size
|
|
39
|
-
M: 16, // Max connections per node
|
|
40
|
-
efConstruction: 200,
|
|
41
|
-
metric: 'cosine'
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Add vectors
|
|
45
|
-
await index.addPoint('memory-1', new Float32Array(embedding));
|
|
46
|
-
await index.addPoint('memory-2', new Float32Array(embedding2));
|
|
47
|
-
|
|
48
|
-
// Search for similar vectors
|
|
49
|
-
const results = await index.search(queryVector, 10);
|
|
50
|
-
// [{ id: 'memory-1', distance: 0.05 }, { id: 'memory-2', distance: 0.12 }]
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## API Reference
|
|
54
|
-
|
|
55
|
-
### HNSW Index
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { HNSWIndex } from '@claude-flow/memory';
|
|
59
|
-
|
|
60
|
-
const index = new HNSWIndex({
|
|
61
|
-
dimensions: 1536,
|
|
62
|
-
M: 16, // Max connections per layer
|
|
63
|
-
efConstruction: 200, // Construction-time search depth
|
|
64
|
-
maxElements: 1000000, // Max vectors
|
|
65
|
-
metric: 'cosine', // 'cosine' | 'euclidean' | 'dot' | 'manhattan'
|
|
66
|
-
quantization: { // Optional quantization
|
|
67
|
-
type: 'scalar', // 'binary' | 'scalar' | 'product'
|
|
68
|
-
bits: 8
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Add vectors
|
|
73
|
-
await index.addPoint(id: string, vector: Float32Array);
|
|
74
|
-
|
|
75
|
-
// Search
|
|
76
|
-
const results = await index.search(
|
|
77
|
-
query: Float32Array,
|
|
78
|
-
k: number,
|
|
79
|
-
ef?: number // Search-time depth (higher = more accurate)
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
// Search with filters
|
|
83
|
-
const filtered = await index.searchWithFilters(
|
|
84
|
-
query,
|
|
85
|
-
k,
|
|
86
|
-
(id) => id.startsWith('session-')
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
// Remove vectors
|
|
90
|
-
await index.removePoint(id);
|
|
91
|
-
|
|
92
|
-
// Get statistics
|
|
93
|
-
const stats = index.getStats();
|
|
94
|
-
// { vectorCount, memoryUsage, avgSearchTime, compressionRatio }
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### AgentDB Adapter
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { AgentDBAdapter } from '@claude-flow/memory';
|
|
101
|
-
|
|
102
|
-
const adapter = new AgentDBAdapter({
|
|
103
|
-
dimension: 1536,
|
|
104
|
-
indexType: 'hnsw',
|
|
105
|
-
metric: 'cosine',
|
|
106
|
-
hnswM: 16,
|
|
107
|
-
hnswEfConstruction: 200,
|
|
108
|
-
enableCache: true,
|
|
109
|
-
cacheSizeMb: 256
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
await adapter.initialize();
|
|
113
|
-
|
|
114
|
-
// Store memory
|
|
115
|
-
await adapter.store({
|
|
116
|
-
id: 'mem-123',
|
|
117
|
-
content: 'User prefers dark mode',
|
|
118
|
-
embedding: vector,
|
|
119
|
-
metadata: { type: 'preference', agentId: 'agent-1' }
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Semantic search
|
|
123
|
-
const memories = await adapter.search(queryVector, {
|
|
124
|
-
limit: 10,
|
|
125
|
-
threshold: 0.7,
|
|
126
|
-
filter: { type: 'preference' }
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Cross-agent memory sharing
|
|
130
|
-
await adapter.enableCrossAgentSharing({
|
|
131
|
-
shareTypes: ['patterns', 'preferences'],
|
|
132
|
-
excludeTypes: ['secrets']
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Cache Manager
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
import { CacheManager } from '@claude-flow/memory';
|
|
140
|
-
|
|
141
|
-
const cache = new CacheManager({
|
|
142
|
-
maxSize: 1000,
|
|
143
|
-
ttlMs: 3600000, // 1 hour
|
|
144
|
-
strategy: 'lru'
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// Cache operations
|
|
148
|
-
cache.set('key', value);
|
|
149
|
-
const value = cache.get('key');
|
|
150
|
-
const exists = cache.has('key');
|
|
151
|
-
cache.delete('key');
|
|
152
|
-
cache.clear();
|
|
153
|
-
|
|
154
|
-
// Statistics
|
|
155
|
-
const stats = cache.getStats();
|
|
156
|
-
// { size, hits, misses, hitRate }
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Query Builder
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
import { QueryBuilder } from '@claude-flow/memory';
|
|
163
|
-
|
|
164
|
-
const results = await new QueryBuilder()
|
|
165
|
-
.semantic(queryVector)
|
|
166
|
-
.where('agentId', '=', 'agent-1')
|
|
167
|
-
.where('type', 'in', ['pattern', 'strategy'])
|
|
168
|
-
.where('createdAt', '>', Date.now() - 86400000)
|
|
169
|
-
.orderBy('relevance', 'desc')
|
|
170
|
-
.limit(20)
|
|
171
|
-
.execute();
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Migration
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
import { MemoryMigration } from '@claude-flow/memory';
|
|
178
|
-
|
|
179
|
-
const migration = new MemoryMigration({
|
|
180
|
-
source: './data/v2-memory.db',
|
|
181
|
-
destination: './data/v3-memory.db'
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// Dry run
|
|
185
|
-
const preview = await migration.preview();
|
|
186
|
-
console.log(`Will migrate ${preview.recordCount} records`);
|
|
187
|
-
|
|
188
|
-
// Execute migration
|
|
189
|
-
await migration.execute({
|
|
190
|
-
batchSize: 1000,
|
|
191
|
-
onProgress: (progress) => console.log(`${progress.percent}%`)
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Quantization Options
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
// Binary quantization (32x compression)
|
|
199
|
-
const binaryIndex = new HNSWIndex({
|
|
200
|
-
dimensions: 1536,
|
|
201
|
-
quantization: { type: 'binary' }
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Scalar quantization (4x compression)
|
|
205
|
-
const scalarIndex = new HNSWIndex({
|
|
206
|
-
dimensions: 1536,
|
|
207
|
-
quantization: { type: 'scalar', bits: 8 }
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Product quantization (8x compression)
|
|
211
|
-
const productIndex = new HNSWIndex({
|
|
212
|
-
dimensions: 1536,
|
|
213
|
-
quantization: { type: 'product', subquantizers: 8 }
|
|
214
|
-
});
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Auto Memory Bridge (ADR-048)
|
|
218
|
-
|
|
219
|
-
Bidirectional sync between Claude Code's [auto memory](https://code.claude.com/docs/en/memory) files and AgentDB. Auto memory is a persistent directory (`~/.claude/projects/<project>/memory/`) where Claude writes learnings as markdown. `MEMORY.md` (first 200 lines) is loaded into the system prompt; topic files are read on demand.
|
|
220
|
-
|
|
221
|
-
### Quick Start
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
import { AutoMemoryBridge } from '@claude-flow/memory';
|
|
225
|
-
|
|
226
|
-
const bridge = new AutoMemoryBridge(memoryBackend, {
|
|
227
|
-
workingDir: '/workspaces/my-project',
|
|
228
|
-
syncMode: 'on-session-end', // 'on-write' | 'on-session-end' | 'periodic'
|
|
229
|
-
pruneStrategy: 'confidence-weighted', // 'confidence-weighted' | 'fifo' | 'lru'
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Record an insight (stores in AgentDB + optionally writes to files)
|
|
233
|
-
await bridge.recordInsight({
|
|
234
|
-
category: 'debugging',
|
|
235
|
-
summary: 'HNSW index requires initialization before search',
|
|
236
|
-
source: 'agent:tester',
|
|
237
|
-
confidence: 0.95,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// Sync buffered insights to auto memory files
|
|
241
|
-
const syncResult = await bridge.syncToAutoMemory();
|
|
242
|
-
|
|
243
|
-
// Import existing auto memory files into AgentDB (on session start)
|
|
244
|
-
const importResult = await bridge.importFromAutoMemory();
|
|
245
|
-
|
|
246
|
-
// Curate MEMORY.md index (stays under 200-line limit)
|
|
247
|
-
await bridge.curateIndex();
|
|
248
|
-
|
|
249
|
-
// Check status
|
|
250
|
-
const status = bridge.getStatus();
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Sync Modes
|
|
254
|
-
|
|
255
|
-
| Mode | Behavior |
|
|
256
|
-
|------|----------|
|
|
257
|
-
| `on-write` | Writes to files immediately on `recordInsight()` |
|
|
258
|
-
| `on-session-end` | Buffers insights, flushes on `syncToAutoMemory()` |
|
|
259
|
-
| `periodic` | Auto-syncs on a configurable interval |
|
|
260
|
-
|
|
261
|
-
### Insight Categories
|
|
262
|
-
|
|
263
|
-
| Category | Topic File | Description |
|
|
264
|
-
|----------|-----------|-------------|
|
|
265
|
-
| `project-patterns` | `patterns.md` | Code patterns and conventions |
|
|
266
|
-
| `debugging` | `debugging.md` | Bug fixes and debugging insights |
|
|
267
|
-
| `architecture` | `architecture.md` | Design decisions and module relationships |
|
|
268
|
-
| `performance` | `performance.md` | Benchmarks and optimization results |
|
|
269
|
-
| `security` | `security.md` | Security findings and CVE notes |
|
|
270
|
-
| `preferences` | `preferences.md` | User and project preferences |
|
|
271
|
-
| `swarm-results` | `swarm-results.md` | Multi-agent swarm outcomes |
|
|
272
|
-
|
|
273
|
-
### Key Optimizations
|
|
274
|
-
|
|
275
|
-
- **Batch import** - `bulkInsert()` instead of individual `store()` calls
|
|
276
|
-
- **Pre-fetched hashes** - Single query for content-hash dedup during import
|
|
277
|
-
- **Async I/O** - `node:fs/promises` for non-blocking writes
|
|
278
|
-
- **Exact dedup** - `hasSummaryLine()` uses bullet-prefix matching, not substring
|
|
279
|
-
- **O(1) sync tracking** - `syncedInsightKeys` Set prevents double-write race
|
|
280
|
-
- **Prune-before-build** - Avoids O(n^2) index rebuild loop
|
|
281
|
-
|
|
282
|
-
### Utility Functions
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
import {
|
|
286
|
-
resolveAutoMemoryDir, // Derive auto memory path from working dir
|
|
287
|
-
findGitRoot, // Walk up to find .git root
|
|
288
|
-
parseMarkdownEntries, // Parse ## headings into structured entries
|
|
289
|
-
extractSummaries, // Extract bullet summaries, strip metadata
|
|
290
|
-
formatInsightLine, // Format insight as markdown bullet
|
|
291
|
-
hashContent, // SHA-256 truncated to 16 hex chars
|
|
292
|
-
pruneTopicFile, // Keep topic files under line limit
|
|
293
|
-
hasSummaryLine, // Exact bullet-prefix dedup check
|
|
294
|
-
} from '@claude-flow/memory';
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Types
|
|
298
|
-
|
|
299
|
-
```typescript
|
|
300
|
-
import type {
|
|
301
|
-
AutoMemoryBridgeConfig,
|
|
302
|
-
MemoryInsight,
|
|
303
|
-
InsightCategory,
|
|
304
|
-
SyncDirection,
|
|
305
|
-
SyncMode,
|
|
306
|
-
PruneStrategy,
|
|
307
|
-
SyncResult,
|
|
308
|
-
ImportResult,
|
|
309
|
-
} from '@claude-flow/memory';
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
## Self-Learning Bridge (ADR-049)
|
|
313
|
-
|
|
314
|
-
Connects insights to the `@claude-flow/neural` learning pipeline. When neural is unavailable, all operations degrade to no-ops.
|
|
315
|
-
|
|
316
|
-
### Quick Start
|
|
317
|
-
|
|
318
|
-
```typescript
|
|
319
|
-
import { AutoMemoryBridge, LearningBridge } from '@claude-flow/memory';
|
|
320
|
-
|
|
321
|
-
const bridge = new AutoMemoryBridge(backend, {
|
|
322
|
-
workingDir: '/workspaces/my-project',
|
|
323
|
-
learning: {
|
|
324
|
-
sonaMode: 'balanced',
|
|
325
|
-
confidenceDecayRate: 0.005, // Per-hour decay
|
|
326
|
-
accessBoostAmount: 0.03, // Boost per access
|
|
327
|
-
consolidationThreshold: 10, // Min insights before consolidation
|
|
328
|
-
},
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// Insights now trigger learning trajectories automatically
|
|
332
|
-
await bridge.recordInsight({
|
|
333
|
-
category: 'debugging',
|
|
334
|
-
summary: 'Connection pool exhaustion on high load',
|
|
335
|
-
source: 'agent:tester',
|
|
336
|
-
confidence: 0.9,
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Consolidation runs JUDGE/DISTILL/CONSOLIDATE pipeline
|
|
340
|
-
await bridge.syncToAutoMemory(); // Calls consolidate() first
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
### Standalone Usage
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
import { LearningBridge } from '@claude-flow/memory';
|
|
347
|
-
|
|
348
|
-
const lb = new LearningBridge(backend, {
|
|
349
|
-
// Optional: inject neural loader for custom setups
|
|
350
|
-
neuralLoader: async () => {
|
|
351
|
-
const { NeuralLearningSystem } = await import('@claude-flow/neural');
|
|
352
|
-
return new NeuralLearningSystem();
|
|
353
|
-
},
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
// Boost confidence when insight is accessed
|
|
357
|
-
await lb.onInsightAccessed('entry-123'); // +0.03 confidence
|
|
358
|
-
|
|
359
|
-
// Apply time-based decay
|
|
360
|
-
const decayed = await lb.decayConfidences('default'); // -0.005/hour
|
|
361
|
-
|
|
362
|
-
// Find similar patterns via ReasoningBank
|
|
363
|
-
const patterns = await lb.findSimilarPatterns('connection pooling');
|
|
364
|
-
|
|
365
|
-
// Get learning statistics
|
|
366
|
-
const stats = lb.getStats();
|
|
367
|
-
// { totalTrajectories, activeTrajectories, completedTrajectories,
|
|
368
|
-
// totalConsolidations, accessBoosts, ... }
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### Confidence Lifecycle
|
|
372
|
-
|
|
373
|
-
| Event | Effect | Range |
|
|
374
|
-
|-------|--------|-------|
|
|
375
|
-
| Insight recorded | Initial confidence from source | 0.1 - 1.0 |
|
|
376
|
-
| Insight accessed | +0.03 per access | Capped at 1.0 |
|
|
377
|
-
| Time decay | -0.005 per hour since last access | Floored at 0.1 |
|
|
378
|
-
| Consolidation | Neural pipeline may adjust | 0.1 - 1.0 |
|
|
379
|
-
|
|
380
|
-
## Knowledge Graph (ADR-049)
|
|
381
|
-
|
|
382
|
-
Pure TypeScript knowledge graph with PageRank and community detection. No external graph libraries required.
|
|
383
|
-
|
|
384
|
-
### Quick Start
|
|
385
|
-
|
|
386
|
-
```typescript
|
|
387
|
-
import { AutoMemoryBridge, MemoryGraph } from '@claude-flow/memory';
|
|
388
|
-
|
|
389
|
-
const bridge = new AutoMemoryBridge(backend, {
|
|
390
|
-
workingDir: '/workspaces/my-project',
|
|
391
|
-
graph: {
|
|
392
|
-
similarityThreshold: 0.8,
|
|
393
|
-
pageRankDamping: 0.85,
|
|
394
|
-
maxNodes: 5000,
|
|
395
|
-
},
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// Graph builds automatically on import
|
|
399
|
-
await bridge.importFromAutoMemory();
|
|
400
|
-
|
|
401
|
-
// Curation uses PageRank to prioritize influential insights
|
|
402
|
-
await bridge.curateIndex();
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
### Standalone Usage
|
|
406
|
-
|
|
407
|
-
```typescript
|
|
408
|
-
import { MemoryGraph } from '@claude-flow/memory';
|
|
409
|
-
|
|
410
|
-
const graph = new MemoryGraph({
|
|
411
|
-
pageRankDamping: 0.85,
|
|
412
|
-
pageRankIterations: 50,
|
|
413
|
-
pageRankConvergence: 1e-6,
|
|
414
|
-
maxNodes: 5000,
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// Build from backend entries
|
|
418
|
-
await graph.buildFromBackend(backend, 'my-namespace');
|
|
419
|
-
|
|
420
|
-
// Or build manually
|
|
421
|
-
graph.addNode(entry);
|
|
422
|
-
graph.addEdge('entry-1', 'entry-2', 'reference', 1.0);
|
|
423
|
-
graph.addEdge('entry-1', 'entry-3', 'similar', 0.9);
|
|
424
|
-
|
|
425
|
-
// Compute PageRank (power iteration)
|
|
426
|
-
const ranks = graph.computePageRank();
|
|
427
|
-
|
|
428
|
-
// Detect communities (label propagation)
|
|
429
|
-
const communities = graph.detectCommunities();
|
|
430
|
-
|
|
431
|
-
// Graph-aware ranking: blend vector score + PageRank
|
|
432
|
-
const ranked = graph.rankWithGraph(searchResults, 0.7);
|
|
433
|
-
// alpha=0.7 means 70% vector score + 30% PageRank
|
|
434
|
-
|
|
435
|
-
// Get most influential insights for MEMORY.md
|
|
436
|
-
const topNodes = graph.getTopNodes(20);
|
|
437
|
-
|
|
438
|
-
// BFS traversal for related insights
|
|
439
|
-
const neighbors = graph.getNeighbors('entry-1', 2); // depth=2
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
### Edge Types
|
|
443
|
-
|
|
444
|
-
| Type | Source | Description |
|
|
445
|
-
|------|--------|-------------|
|
|
446
|
-
| `reference` | `MemoryEntry.references` | Explicit cross-references between entries |
|
|
447
|
-
| `similar` | HNSW search | Auto-created when similarity > threshold |
|
|
448
|
-
| `temporal` | Timestamps | Entries created in same time window |
|
|
449
|
-
| `co-accessed` | Access patterns | Entries frequently accessed together |
|
|
450
|
-
| `causal` | Learning pipeline | Cause-effect relationships |
|
|
451
|
-
|
|
452
|
-
### Performance
|
|
453
|
-
|
|
454
|
-
| Operation | Result | Target |
|
|
455
|
-
|-----------|--------|--------|
|
|
456
|
-
| Graph build (1k nodes) | 2.78 ms | <200 ms |
|
|
457
|
-
| PageRank (1k nodes) | 12.21 ms | <100 ms |
|
|
458
|
-
| Community detection (1k) | 19.62 ms | — |
|
|
459
|
-
| `rankWithGraph(10)` | 0.006 ms | — |
|
|
460
|
-
| `getTopNodes(20)` | 0.308 ms | — |
|
|
461
|
-
| `getNeighbors(d=2)` | 0.005 ms | — |
|
|
462
|
-
|
|
463
|
-
## Agent-Scoped Memory (ADR-049)
|
|
464
|
-
|
|
465
|
-
Maps Claude Code's 3-scope agent memory directories for per-agent knowledge isolation and cross-agent transfer.
|
|
466
|
-
|
|
467
|
-
### Quick Start
|
|
468
|
-
|
|
469
|
-
```typescript
|
|
470
|
-
import { createAgentBridge, transferKnowledge } from '@claude-flow/memory';
|
|
471
|
-
|
|
472
|
-
// Create a bridge for a specific agent scope
|
|
473
|
-
const agentBridge = createAgentBridge(backend, {
|
|
474
|
-
agentName: 'my-coder',
|
|
475
|
-
scope: 'project', // 'project' | 'local' | 'user'
|
|
476
|
-
workingDir: '/workspaces/my-project',
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
// Record insights scoped to this agent
|
|
480
|
-
await agentBridge.recordInsight({
|
|
481
|
-
category: 'debugging',
|
|
482
|
-
summary: 'Use connection pooling for DB calls',
|
|
483
|
-
source: 'agent:my-coder',
|
|
484
|
-
confidence: 0.95,
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
// Transfer high-confidence insights between agents
|
|
488
|
-
const result = await transferKnowledge(sourceBackend, targetBridge, {
|
|
489
|
-
sourceNamespace: 'learnings',
|
|
490
|
-
minConfidence: 0.8, // Only transfer confident insights
|
|
491
|
-
maxEntries: 20,
|
|
492
|
-
categories: ['debugging', 'architecture'],
|
|
493
|
-
});
|
|
494
|
-
// { transferred: 15, skipped: 5 }
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
### Scope Paths
|
|
498
|
-
|
|
499
|
-
| Scope | Directory | Use Case |
|
|
500
|
-
|-------|-----------|----------|
|
|
501
|
-
| `project` | `<gitRoot>/.claude/agent-memory/<agent>/` | Project-specific learnings |
|
|
502
|
-
| `local` | `<gitRoot>/.claude/agent-memory-local/<agent>/` | Machine-local data |
|
|
503
|
-
| `user` | `~/.claude/agent-memory/<agent>/` | Cross-project user knowledge |
|
|
504
|
-
|
|
505
|
-
### Utilities
|
|
506
|
-
|
|
507
|
-
```typescript
|
|
508
|
-
import {
|
|
509
|
-
resolveAgentMemoryDir, // Get scope directory path
|
|
510
|
-
createAgentBridge, // Create scoped AutoMemoryBridge
|
|
511
|
-
transferKnowledge, // Cross-agent knowledge sharing
|
|
512
|
-
listAgentScopes, // Discover existing agent scopes
|
|
513
|
-
} from '@claude-flow/memory';
|
|
514
|
-
|
|
515
|
-
// Resolve path for an agent scope
|
|
516
|
-
const dir = resolveAgentMemoryDir('my-agent', 'project');
|
|
517
|
-
// → /workspaces/my-project/.claude/agent-memory/my-agent/
|
|
518
|
-
|
|
519
|
-
// List all agent scopes in a directory
|
|
520
|
-
const scopes = await listAgentScopes('/workspaces/my-project');
|
|
521
|
-
// [{ agentName: 'coder', scope: 'project', path: '...' }, ...]
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
## Performance Benchmarks
|
|
525
|
-
|
|
526
|
-
| Operation | V2 Performance | V3 Performance | Improvement |
|
|
527
|
-
|-----------|---------------|----------------|-------------|
|
|
528
|
-
| Vector Search | 150ms | <1ms | **150x** |
|
|
529
|
-
| Bulk Insert | 500ms | 5ms | **100x** |
|
|
530
|
-
| Memory Write | 50ms | <5ms | **10x** |
|
|
531
|
-
| Cache Hit | 5ms | <0.1ms | **50x** |
|
|
532
|
-
| Index Build | 10s | 800ms | **12.5x** |
|
|
533
|
-
|
|
534
|
-
### ADR-049 Benchmarks
|
|
535
|
-
|
|
536
|
-
| Operation | Actual | Target | Headroom |
|
|
537
|
-
|-----------|--------|--------|----------|
|
|
538
|
-
| Graph build (1k nodes) | 2.78 ms | <200 ms | **71.9x** |
|
|
539
|
-
| PageRank (1k nodes) | 12.21 ms | <100 ms | **8.2x** |
|
|
540
|
-
| Insight recording | 0.12 ms/each | <5 ms/each | **41.0x** |
|
|
541
|
-
| Consolidation | 0.26 ms | <500 ms | **1,955x** |
|
|
542
|
-
| Confidence decay (1k) | 0.23 ms | <50 ms | **215x** |
|
|
543
|
-
| Knowledge transfer | 1.25 ms | <100 ms | **80.0x** |
|
|
544
|
-
|
|
545
|
-
## TypeScript Types
|
|
546
|
-
|
|
547
|
-
```typescript
|
|
548
|
-
import type {
|
|
549
|
-
// Core
|
|
550
|
-
HNSWConfig, HNSWStats, SearchResult, MemoryEntry,
|
|
551
|
-
QuantizationConfig, DistanceMetric,
|
|
552
|
-
|
|
553
|
-
// Auto Memory Bridge (ADR-048)
|
|
554
|
-
AutoMemoryBridgeConfig, MemoryInsight, InsightCategory,
|
|
555
|
-
SyncDirection, SyncMode, PruneStrategy,
|
|
556
|
-
SyncResult, ImportResult,
|
|
557
|
-
|
|
558
|
-
// Learning Bridge (ADR-049)
|
|
559
|
-
LearningBridgeConfig, LearningStats,
|
|
560
|
-
ConsolidateResult, PatternMatch,
|
|
561
|
-
|
|
562
|
-
// Knowledge Graph (ADR-049)
|
|
563
|
-
MemoryGraphConfig, GraphNode, GraphEdge,
|
|
564
|
-
GraphStats, RankedResult, EdgeType,
|
|
565
|
-
|
|
566
|
-
// Agent Scope (ADR-049)
|
|
567
|
-
AgentMemoryScope, AgentScopedConfig,
|
|
568
|
-
TransferOptions, TransferResult,
|
|
569
|
-
} from '@claude-flow/memory';
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
## Dependencies
|
|
573
|
-
|
|
574
|
-
- `agentdb` - Vector database engine
|
|
575
|
-
- `better-sqlite3` - SQLite driver (native)
|
|
576
|
-
- `sql.js` - SQLite driver (WASM fallback)
|
|
577
|
-
- `@claude-flow/neural` - **Optional peer dependency** for self-learning (graceful fallback when unavailable)
|
|
578
|
-
|
|
579
|
-
## Related Packages
|
|
580
|
-
|
|
581
|
-
- [@claude-flow/neural](../neural) - Neural learning integration (SONA, ReasoningBank, EWC++)
|
|
582
|
-
- [@claude-flow/shared](../shared) - Shared types and utilities
|
|
583
|
-
- [@claude-flow/hooks](../hooks) - Session lifecycle hooks for auto memory sync
|
|
584
|
-
|
|
585
|
-
## License
|
|
586
|
-
|
|
587
|
-
MIT
|
|
1
|
+
# @claude-flow/memory
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@claude-flow/memory)
|
|
4
|
+
[](https://www.npmjs.com/package/@claude-flow/memory)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://github.com/eric-cielo/moflo)
|
|
8
|
+
|
|
9
|
+
> High-performance memory module for Claude Flow V3 - AgentDB unification, HNSW indexing, vector search, self-learning knowledge graph, and hybrid SQLite+AgentDB backend (ADR-009).
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **150x-12,500x Faster Search** - HNSW (Hierarchical Navigable Small World) vector index for ultra-fast similarity search
|
|
14
|
+
- **Hybrid Backend** - SQLite for structured data + AgentDB for vectors (ADR-009)
|
|
15
|
+
- **Auto Memory Bridge** - Bidirectional sync between Claude Code auto memory and AgentDB (ADR-048)
|
|
16
|
+
- **Self-Learning** - LearningBridge connects insights to SONA/ReasoningBank neural pipeline (ADR-049)
|
|
17
|
+
- **Knowledge Graph** - PageRank + label propagation community detection over memory entries (ADR-049)
|
|
18
|
+
- **Agent-Scoped Memory** - 3-scope agent memory (project/local/user) with cross-agent knowledge transfer (ADR-049)
|
|
19
|
+
- **Vector Quantization** - Binary, scalar, and product quantization for 4-32x memory reduction
|
|
20
|
+
- **Multiple Distance Metrics** - Cosine, Euclidean, dot product, and Manhattan distance
|
|
21
|
+
- **Query Builder** - Fluent API for building complex memory queries
|
|
22
|
+
- **Cache Manager** - LRU caching with configurable size and TTL
|
|
23
|
+
- **Migration Tools** - Seamless migration from V2 memory systems
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @claude-flow/memory
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { HNSWIndex, AgentDBAdapter, CacheManager } from '@claude-flow/memory';
|
|
35
|
+
|
|
36
|
+
// Create HNSW index for vector search
|
|
37
|
+
const index = new HNSWIndex({
|
|
38
|
+
dimensions: 1536, // OpenAI embedding size
|
|
39
|
+
M: 16, // Max connections per node
|
|
40
|
+
efConstruction: 200,
|
|
41
|
+
metric: 'cosine'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Add vectors
|
|
45
|
+
await index.addPoint('memory-1', new Float32Array(embedding));
|
|
46
|
+
await index.addPoint('memory-2', new Float32Array(embedding2));
|
|
47
|
+
|
|
48
|
+
// Search for similar vectors
|
|
49
|
+
const results = await index.search(queryVector, 10);
|
|
50
|
+
// [{ id: 'memory-1', distance: 0.05 }, { id: 'memory-2', distance: 0.12 }]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API Reference
|
|
54
|
+
|
|
55
|
+
### HNSW Index
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { HNSWIndex } from '@claude-flow/memory';
|
|
59
|
+
|
|
60
|
+
const index = new HNSWIndex({
|
|
61
|
+
dimensions: 1536,
|
|
62
|
+
M: 16, // Max connections per layer
|
|
63
|
+
efConstruction: 200, // Construction-time search depth
|
|
64
|
+
maxElements: 1000000, // Max vectors
|
|
65
|
+
metric: 'cosine', // 'cosine' | 'euclidean' | 'dot' | 'manhattan'
|
|
66
|
+
quantization: { // Optional quantization
|
|
67
|
+
type: 'scalar', // 'binary' | 'scalar' | 'product'
|
|
68
|
+
bits: 8
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Add vectors
|
|
73
|
+
await index.addPoint(id: string, vector: Float32Array);
|
|
74
|
+
|
|
75
|
+
// Search
|
|
76
|
+
const results = await index.search(
|
|
77
|
+
query: Float32Array,
|
|
78
|
+
k: number,
|
|
79
|
+
ef?: number // Search-time depth (higher = more accurate)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Search with filters
|
|
83
|
+
const filtered = await index.searchWithFilters(
|
|
84
|
+
query,
|
|
85
|
+
k,
|
|
86
|
+
(id) => id.startsWith('session-')
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Remove vectors
|
|
90
|
+
await index.removePoint(id);
|
|
91
|
+
|
|
92
|
+
// Get statistics
|
|
93
|
+
const stats = index.getStats();
|
|
94
|
+
// { vectorCount, memoryUsage, avgSearchTime, compressionRatio }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### AgentDB Adapter
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { AgentDBAdapter } from '@claude-flow/memory';
|
|
101
|
+
|
|
102
|
+
const adapter = new AgentDBAdapter({
|
|
103
|
+
dimension: 1536,
|
|
104
|
+
indexType: 'hnsw',
|
|
105
|
+
metric: 'cosine',
|
|
106
|
+
hnswM: 16,
|
|
107
|
+
hnswEfConstruction: 200,
|
|
108
|
+
enableCache: true,
|
|
109
|
+
cacheSizeMb: 256
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await adapter.initialize();
|
|
113
|
+
|
|
114
|
+
// Store memory
|
|
115
|
+
await adapter.store({
|
|
116
|
+
id: 'mem-123',
|
|
117
|
+
content: 'User prefers dark mode',
|
|
118
|
+
embedding: vector,
|
|
119
|
+
metadata: { type: 'preference', agentId: 'agent-1' }
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Semantic search
|
|
123
|
+
const memories = await adapter.search(queryVector, {
|
|
124
|
+
limit: 10,
|
|
125
|
+
threshold: 0.7,
|
|
126
|
+
filter: { type: 'preference' }
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Cross-agent memory sharing
|
|
130
|
+
await adapter.enableCrossAgentSharing({
|
|
131
|
+
shareTypes: ['patterns', 'preferences'],
|
|
132
|
+
excludeTypes: ['secrets']
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Cache Manager
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { CacheManager } from '@claude-flow/memory';
|
|
140
|
+
|
|
141
|
+
const cache = new CacheManager({
|
|
142
|
+
maxSize: 1000,
|
|
143
|
+
ttlMs: 3600000, // 1 hour
|
|
144
|
+
strategy: 'lru'
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Cache operations
|
|
148
|
+
cache.set('key', value);
|
|
149
|
+
const value = cache.get('key');
|
|
150
|
+
const exists = cache.has('key');
|
|
151
|
+
cache.delete('key');
|
|
152
|
+
cache.clear();
|
|
153
|
+
|
|
154
|
+
// Statistics
|
|
155
|
+
const stats = cache.getStats();
|
|
156
|
+
// { size, hits, misses, hitRate }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Query Builder
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { QueryBuilder } from '@claude-flow/memory';
|
|
163
|
+
|
|
164
|
+
const results = await new QueryBuilder()
|
|
165
|
+
.semantic(queryVector)
|
|
166
|
+
.where('agentId', '=', 'agent-1')
|
|
167
|
+
.where('type', 'in', ['pattern', 'strategy'])
|
|
168
|
+
.where('createdAt', '>', Date.now() - 86400000)
|
|
169
|
+
.orderBy('relevance', 'desc')
|
|
170
|
+
.limit(20)
|
|
171
|
+
.execute();
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Migration
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { MemoryMigration } from '@claude-flow/memory';
|
|
178
|
+
|
|
179
|
+
const migration = new MemoryMigration({
|
|
180
|
+
source: './data/v2-memory.db',
|
|
181
|
+
destination: './data/v3-memory.db'
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Dry run
|
|
185
|
+
const preview = await migration.preview();
|
|
186
|
+
console.log(`Will migrate ${preview.recordCount} records`);
|
|
187
|
+
|
|
188
|
+
// Execute migration
|
|
189
|
+
await migration.execute({
|
|
190
|
+
batchSize: 1000,
|
|
191
|
+
onProgress: (progress) => console.log(`${progress.percent}%`)
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Quantization Options
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// Binary quantization (32x compression)
|
|
199
|
+
const binaryIndex = new HNSWIndex({
|
|
200
|
+
dimensions: 1536,
|
|
201
|
+
quantization: { type: 'binary' }
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Scalar quantization (4x compression)
|
|
205
|
+
const scalarIndex = new HNSWIndex({
|
|
206
|
+
dimensions: 1536,
|
|
207
|
+
quantization: { type: 'scalar', bits: 8 }
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Product quantization (8x compression)
|
|
211
|
+
const productIndex = new HNSWIndex({
|
|
212
|
+
dimensions: 1536,
|
|
213
|
+
quantization: { type: 'product', subquantizers: 8 }
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Auto Memory Bridge (ADR-048)
|
|
218
|
+
|
|
219
|
+
Bidirectional sync between Claude Code's [auto memory](https://code.claude.com/docs/en/memory) files and AgentDB. Auto memory is a persistent directory (`~/.claude/projects/<project>/memory/`) where Claude writes learnings as markdown. `MEMORY.md` (first 200 lines) is loaded into the system prompt; topic files are read on demand.
|
|
220
|
+
|
|
221
|
+
### Quick Start
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { AutoMemoryBridge } from '@claude-flow/memory';
|
|
225
|
+
|
|
226
|
+
const bridge = new AutoMemoryBridge(memoryBackend, {
|
|
227
|
+
workingDir: '/workspaces/my-project',
|
|
228
|
+
syncMode: 'on-session-end', // 'on-write' | 'on-session-end' | 'periodic'
|
|
229
|
+
pruneStrategy: 'confidence-weighted', // 'confidence-weighted' | 'fifo' | 'lru'
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Record an insight (stores in AgentDB + optionally writes to files)
|
|
233
|
+
await bridge.recordInsight({
|
|
234
|
+
category: 'debugging',
|
|
235
|
+
summary: 'HNSW index requires initialization before search',
|
|
236
|
+
source: 'agent:tester',
|
|
237
|
+
confidence: 0.95,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Sync buffered insights to auto memory files
|
|
241
|
+
const syncResult = await bridge.syncToAutoMemory();
|
|
242
|
+
|
|
243
|
+
// Import existing auto memory files into AgentDB (on session start)
|
|
244
|
+
const importResult = await bridge.importFromAutoMemory();
|
|
245
|
+
|
|
246
|
+
// Curate MEMORY.md index (stays under 200-line limit)
|
|
247
|
+
await bridge.curateIndex();
|
|
248
|
+
|
|
249
|
+
// Check status
|
|
250
|
+
const status = bridge.getStatus();
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Sync Modes
|
|
254
|
+
|
|
255
|
+
| Mode | Behavior |
|
|
256
|
+
|------|----------|
|
|
257
|
+
| `on-write` | Writes to files immediately on `recordInsight()` |
|
|
258
|
+
| `on-session-end` | Buffers insights, flushes on `syncToAutoMemory()` |
|
|
259
|
+
| `periodic` | Auto-syncs on a configurable interval |
|
|
260
|
+
|
|
261
|
+
### Insight Categories
|
|
262
|
+
|
|
263
|
+
| Category | Topic File | Description |
|
|
264
|
+
|----------|-----------|-------------|
|
|
265
|
+
| `project-patterns` | `patterns.md` | Code patterns and conventions |
|
|
266
|
+
| `debugging` | `debugging.md` | Bug fixes and debugging insights |
|
|
267
|
+
| `architecture` | `architecture.md` | Design decisions and module relationships |
|
|
268
|
+
| `performance` | `performance.md` | Benchmarks and optimization results |
|
|
269
|
+
| `security` | `security.md` | Security findings and CVE notes |
|
|
270
|
+
| `preferences` | `preferences.md` | User and project preferences |
|
|
271
|
+
| `swarm-results` | `swarm-results.md` | Multi-agent swarm outcomes |
|
|
272
|
+
|
|
273
|
+
### Key Optimizations
|
|
274
|
+
|
|
275
|
+
- **Batch import** - `bulkInsert()` instead of individual `store()` calls
|
|
276
|
+
- **Pre-fetched hashes** - Single query for content-hash dedup during import
|
|
277
|
+
- **Async I/O** - `node:fs/promises` for non-blocking writes
|
|
278
|
+
- **Exact dedup** - `hasSummaryLine()` uses bullet-prefix matching, not substring
|
|
279
|
+
- **O(1) sync tracking** - `syncedInsightKeys` Set prevents double-write race
|
|
280
|
+
- **Prune-before-build** - Avoids O(n^2) index rebuild loop
|
|
281
|
+
|
|
282
|
+
### Utility Functions
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import {
|
|
286
|
+
resolveAutoMemoryDir, // Derive auto memory path from working dir
|
|
287
|
+
findGitRoot, // Walk up to find .git root
|
|
288
|
+
parseMarkdownEntries, // Parse ## headings into structured entries
|
|
289
|
+
extractSummaries, // Extract bullet summaries, strip metadata
|
|
290
|
+
formatInsightLine, // Format insight as markdown bullet
|
|
291
|
+
hashContent, // SHA-256 truncated to 16 hex chars
|
|
292
|
+
pruneTopicFile, // Keep topic files under line limit
|
|
293
|
+
hasSummaryLine, // Exact bullet-prefix dedup check
|
|
294
|
+
} from '@claude-flow/memory';
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Types
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import type {
|
|
301
|
+
AutoMemoryBridgeConfig,
|
|
302
|
+
MemoryInsight,
|
|
303
|
+
InsightCategory,
|
|
304
|
+
SyncDirection,
|
|
305
|
+
SyncMode,
|
|
306
|
+
PruneStrategy,
|
|
307
|
+
SyncResult,
|
|
308
|
+
ImportResult,
|
|
309
|
+
} from '@claude-flow/memory';
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Self-Learning Bridge (ADR-049)
|
|
313
|
+
|
|
314
|
+
Connects insights to the `@claude-flow/neural` learning pipeline. When neural is unavailable, all operations degrade to no-ops.
|
|
315
|
+
|
|
316
|
+
### Quick Start
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import { AutoMemoryBridge, LearningBridge } from '@claude-flow/memory';
|
|
320
|
+
|
|
321
|
+
const bridge = new AutoMemoryBridge(backend, {
|
|
322
|
+
workingDir: '/workspaces/my-project',
|
|
323
|
+
learning: {
|
|
324
|
+
sonaMode: 'balanced',
|
|
325
|
+
confidenceDecayRate: 0.005, // Per-hour decay
|
|
326
|
+
accessBoostAmount: 0.03, // Boost per access
|
|
327
|
+
consolidationThreshold: 10, // Min insights before consolidation
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// Insights now trigger learning trajectories automatically
|
|
332
|
+
await bridge.recordInsight({
|
|
333
|
+
category: 'debugging',
|
|
334
|
+
summary: 'Connection pool exhaustion on high load',
|
|
335
|
+
source: 'agent:tester',
|
|
336
|
+
confidence: 0.9,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// Consolidation runs JUDGE/DISTILL/CONSOLIDATE pipeline
|
|
340
|
+
await bridge.syncToAutoMemory(); // Calls consolidate() first
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Standalone Usage
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
import { LearningBridge } from '@claude-flow/memory';
|
|
347
|
+
|
|
348
|
+
const lb = new LearningBridge(backend, {
|
|
349
|
+
// Optional: inject neural loader for custom setups
|
|
350
|
+
neuralLoader: async () => {
|
|
351
|
+
const { NeuralLearningSystem } = await import('@claude-flow/neural');
|
|
352
|
+
return new NeuralLearningSystem();
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// Boost confidence when insight is accessed
|
|
357
|
+
await lb.onInsightAccessed('entry-123'); // +0.03 confidence
|
|
358
|
+
|
|
359
|
+
// Apply time-based decay
|
|
360
|
+
const decayed = await lb.decayConfidences('default'); // -0.005/hour
|
|
361
|
+
|
|
362
|
+
// Find similar patterns via ReasoningBank
|
|
363
|
+
const patterns = await lb.findSimilarPatterns('connection pooling');
|
|
364
|
+
|
|
365
|
+
// Get learning statistics
|
|
366
|
+
const stats = lb.getStats();
|
|
367
|
+
// { totalTrajectories, activeTrajectories, completedTrajectories,
|
|
368
|
+
// totalConsolidations, accessBoosts, ... }
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Confidence Lifecycle
|
|
372
|
+
|
|
373
|
+
| Event | Effect | Range |
|
|
374
|
+
|-------|--------|-------|
|
|
375
|
+
| Insight recorded | Initial confidence from source | 0.1 - 1.0 |
|
|
376
|
+
| Insight accessed | +0.03 per access | Capped at 1.0 |
|
|
377
|
+
| Time decay | -0.005 per hour since last access | Floored at 0.1 |
|
|
378
|
+
| Consolidation | Neural pipeline may adjust | 0.1 - 1.0 |
|
|
379
|
+
|
|
380
|
+
## Knowledge Graph (ADR-049)
|
|
381
|
+
|
|
382
|
+
Pure TypeScript knowledge graph with PageRank and community detection. No external graph libraries required.
|
|
383
|
+
|
|
384
|
+
### Quick Start
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import { AutoMemoryBridge, MemoryGraph } from '@claude-flow/memory';
|
|
388
|
+
|
|
389
|
+
const bridge = new AutoMemoryBridge(backend, {
|
|
390
|
+
workingDir: '/workspaces/my-project',
|
|
391
|
+
graph: {
|
|
392
|
+
similarityThreshold: 0.8,
|
|
393
|
+
pageRankDamping: 0.85,
|
|
394
|
+
maxNodes: 5000,
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// Graph builds automatically on import
|
|
399
|
+
await bridge.importFromAutoMemory();
|
|
400
|
+
|
|
401
|
+
// Curation uses PageRank to prioritize influential insights
|
|
402
|
+
await bridge.curateIndex();
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Standalone Usage
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { MemoryGraph } from '@claude-flow/memory';
|
|
409
|
+
|
|
410
|
+
const graph = new MemoryGraph({
|
|
411
|
+
pageRankDamping: 0.85,
|
|
412
|
+
pageRankIterations: 50,
|
|
413
|
+
pageRankConvergence: 1e-6,
|
|
414
|
+
maxNodes: 5000,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// Build from backend entries
|
|
418
|
+
await graph.buildFromBackend(backend, 'my-namespace');
|
|
419
|
+
|
|
420
|
+
// Or build manually
|
|
421
|
+
graph.addNode(entry);
|
|
422
|
+
graph.addEdge('entry-1', 'entry-2', 'reference', 1.0);
|
|
423
|
+
graph.addEdge('entry-1', 'entry-3', 'similar', 0.9);
|
|
424
|
+
|
|
425
|
+
// Compute PageRank (power iteration)
|
|
426
|
+
const ranks = graph.computePageRank();
|
|
427
|
+
|
|
428
|
+
// Detect communities (label propagation)
|
|
429
|
+
const communities = graph.detectCommunities();
|
|
430
|
+
|
|
431
|
+
// Graph-aware ranking: blend vector score + PageRank
|
|
432
|
+
const ranked = graph.rankWithGraph(searchResults, 0.7);
|
|
433
|
+
// alpha=0.7 means 70% vector score + 30% PageRank
|
|
434
|
+
|
|
435
|
+
// Get most influential insights for MEMORY.md
|
|
436
|
+
const topNodes = graph.getTopNodes(20);
|
|
437
|
+
|
|
438
|
+
// BFS traversal for related insights
|
|
439
|
+
const neighbors = graph.getNeighbors('entry-1', 2); // depth=2
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Edge Types
|
|
443
|
+
|
|
444
|
+
| Type | Source | Description |
|
|
445
|
+
|------|--------|-------------|
|
|
446
|
+
| `reference` | `MemoryEntry.references` | Explicit cross-references between entries |
|
|
447
|
+
| `similar` | HNSW search | Auto-created when similarity > threshold |
|
|
448
|
+
| `temporal` | Timestamps | Entries created in same time window |
|
|
449
|
+
| `co-accessed` | Access patterns | Entries frequently accessed together |
|
|
450
|
+
| `causal` | Learning pipeline | Cause-effect relationships |
|
|
451
|
+
|
|
452
|
+
### Performance
|
|
453
|
+
|
|
454
|
+
| Operation | Result | Target |
|
|
455
|
+
|-----------|--------|--------|
|
|
456
|
+
| Graph build (1k nodes) | 2.78 ms | <200 ms |
|
|
457
|
+
| PageRank (1k nodes) | 12.21 ms | <100 ms |
|
|
458
|
+
| Community detection (1k) | 19.62 ms | — |
|
|
459
|
+
| `rankWithGraph(10)` | 0.006 ms | — |
|
|
460
|
+
| `getTopNodes(20)` | 0.308 ms | — |
|
|
461
|
+
| `getNeighbors(d=2)` | 0.005 ms | — |
|
|
462
|
+
|
|
463
|
+
## Agent-Scoped Memory (ADR-049)
|
|
464
|
+
|
|
465
|
+
Maps Claude Code's 3-scope agent memory directories for per-agent knowledge isolation and cross-agent transfer.
|
|
466
|
+
|
|
467
|
+
### Quick Start
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
import { createAgentBridge, transferKnowledge } from '@claude-flow/memory';
|
|
471
|
+
|
|
472
|
+
// Create a bridge for a specific agent scope
|
|
473
|
+
const agentBridge = createAgentBridge(backend, {
|
|
474
|
+
agentName: 'my-coder',
|
|
475
|
+
scope: 'project', // 'project' | 'local' | 'user'
|
|
476
|
+
workingDir: '/workspaces/my-project',
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// Record insights scoped to this agent
|
|
480
|
+
await agentBridge.recordInsight({
|
|
481
|
+
category: 'debugging',
|
|
482
|
+
summary: 'Use connection pooling for DB calls',
|
|
483
|
+
source: 'agent:my-coder',
|
|
484
|
+
confidence: 0.95,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// Transfer high-confidence insights between agents
|
|
488
|
+
const result = await transferKnowledge(sourceBackend, targetBridge, {
|
|
489
|
+
sourceNamespace: 'learnings',
|
|
490
|
+
minConfidence: 0.8, // Only transfer confident insights
|
|
491
|
+
maxEntries: 20,
|
|
492
|
+
categories: ['debugging', 'architecture'],
|
|
493
|
+
});
|
|
494
|
+
// { transferred: 15, skipped: 5 }
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### Scope Paths
|
|
498
|
+
|
|
499
|
+
| Scope | Directory | Use Case |
|
|
500
|
+
|-------|-----------|----------|
|
|
501
|
+
| `project` | `<gitRoot>/.claude/agent-memory/<agent>/` | Project-specific learnings |
|
|
502
|
+
| `local` | `<gitRoot>/.claude/agent-memory-local/<agent>/` | Machine-local data |
|
|
503
|
+
| `user` | `~/.claude/agent-memory/<agent>/` | Cross-project user knowledge |
|
|
504
|
+
|
|
505
|
+
### Utilities
|
|
506
|
+
|
|
507
|
+
```typescript
|
|
508
|
+
import {
|
|
509
|
+
resolveAgentMemoryDir, // Get scope directory path
|
|
510
|
+
createAgentBridge, // Create scoped AutoMemoryBridge
|
|
511
|
+
transferKnowledge, // Cross-agent knowledge sharing
|
|
512
|
+
listAgentScopes, // Discover existing agent scopes
|
|
513
|
+
} from '@claude-flow/memory';
|
|
514
|
+
|
|
515
|
+
// Resolve path for an agent scope
|
|
516
|
+
const dir = resolveAgentMemoryDir('my-agent', 'project');
|
|
517
|
+
// → /workspaces/my-project/.claude/agent-memory/my-agent/
|
|
518
|
+
|
|
519
|
+
// List all agent scopes in a directory
|
|
520
|
+
const scopes = await listAgentScopes('/workspaces/my-project');
|
|
521
|
+
// [{ agentName: 'coder', scope: 'project', path: '...' }, ...]
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
## Performance Benchmarks
|
|
525
|
+
|
|
526
|
+
| Operation | V2 Performance | V3 Performance | Improvement |
|
|
527
|
+
|-----------|---------------|----------------|-------------|
|
|
528
|
+
| Vector Search | 150ms | <1ms | **150x** |
|
|
529
|
+
| Bulk Insert | 500ms | 5ms | **100x** |
|
|
530
|
+
| Memory Write | 50ms | <5ms | **10x** |
|
|
531
|
+
| Cache Hit | 5ms | <0.1ms | **50x** |
|
|
532
|
+
| Index Build | 10s | 800ms | **12.5x** |
|
|
533
|
+
|
|
534
|
+
### ADR-049 Benchmarks
|
|
535
|
+
|
|
536
|
+
| Operation | Actual | Target | Headroom |
|
|
537
|
+
|-----------|--------|--------|----------|
|
|
538
|
+
| Graph build (1k nodes) | 2.78 ms | <200 ms | **71.9x** |
|
|
539
|
+
| PageRank (1k nodes) | 12.21 ms | <100 ms | **8.2x** |
|
|
540
|
+
| Insight recording | 0.12 ms/each | <5 ms/each | **41.0x** |
|
|
541
|
+
| Consolidation | 0.26 ms | <500 ms | **1,955x** |
|
|
542
|
+
| Confidence decay (1k) | 0.23 ms | <50 ms | **215x** |
|
|
543
|
+
| Knowledge transfer | 1.25 ms | <100 ms | **80.0x** |
|
|
544
|
+
|
|
545
|
+
## TypeScript Types
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
import type {
|
|
549
|
+
// Core
|
|
550
|
+
HNSWConfig, HNSWStats, SearchResult, MemoryEntry,
|
|
551
|
+
QuantizationConfig, DistanceMetric,
|
|
552
|
+
|
|
553
|
+
// Auto Memory Bridge (ADR-048)
|
|
554
|
+
AutoMemoryBridgeConfig, MemoryInsight, InsightCategory,
|
|
555
|
+
SyncDirection, SyncMode, PruneStrategy,
|
|
556
|
+
SyncResult, ImportResult,
|
|
557
|
+
|
|
558
|
+
// Learning Bridge (ADR-049)
|
|
559
|
+
LearningBridgeConfig, LearningStats,
|
|
560
|
+
ConsolidateResult, PatternMatch,
|
|
561
|
+
|
|
562
|
+
// Knowledge Graph (ADR-049)
|
|
563
|
+
MemoryGraphConfig, GraphNode, GraphEdge,
|
|
564
|
+
GraphStats, RankedResult, EdgeType,
|
|
565
|
+
|
|
566
|
+
// Agent Scope (ADR-049)
|
|
567
|
+
AgentMemoryScope, AgentScopedConfig,
|
|
568
|
+
TransferOptions, TransferResult,
|
|
569
|
+
} from '@claude-flow/memory';
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
## Dependencies
|
|
573
|
+
|
|
574
|
+
- `agentdb` - Vector database engine
|
|
575
|
+
- `better-sqlite3` - SQLite driver (native)
|
|
576
|
+
- `sql.js` - SQLite driver (WASM fallback)
|
|
577
|
+
- `@claude-flow/neural` - **Optional peer dependency** for self-learning (graceful fallback when unavailable)
|
|
578
|
+
|
|
579
|
+
## Related Packages
|
|
580
|
+
|
|
581
|
+
- [@claude-flow/neural](../neural) - Neural learning integration (SONA, ReasoningBank, EWC++)
|
|
582
|
+
- [@claude-flow/shared](../shared) - Shared types and utilities
|
|
583
|
+
- [@claude-flow/hooks](../hooks) - Session lifecycle hooks for auto memory sync
|
|
584
|
+
|
|
585
|
+
## License
|
|
586
|
+
|
|
587
|
+
MIT
|