mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-09 14:04:06 +09:00
* fix(memory): add missing 'type' column to schema migration Fixes #977 - Memory store command failed with "table memory_entries has no column named type" on older databases that were missing this column. Changes: - Add 'type' column to ensureSchemaColumns() migration list - Fix .gitignore to use rooted paths (/memory/ instead of memory/) to prevent accidentally ignoring src/memory/ source code The ensureSchemaColumns() function now properly adds the 'type' column when upgrading databases from older schema versions. Co-Authored-By: claude-flow <ruv@ruv.net> * chore: bump version to 3.0.0-alpha.153 Published to npm with fix for issue #977. Co-Authored-By: claude-flow <ruv@ruv.net> * fix(memory): support namespace in delete command Fixes #980 - CLI memory delete now properly supports namespaced entries. Changes: - Add `deleteEntry()` function to memory-initializer.ts - Add `--key` and `--namespace` options to delete command - Support both positional argument and flag for key - Use consistent pattern with retrieve command Usage: memory delete --key "mykey" --namespace "myns" -f memory delete mykey -f (uses default namespace) Co-Authored-By: claude-flow <ruv@ruv.net> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T15:55:06Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): update pnpm-lock.yaml for @claude-flow/browser Updates the lockfile to include dependencies for the browser package that were causing CI failures with frozen-lockfile mode. Co-Authored-By: claude-flow <ruv@ruv.net> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:05:21Z - Changes: 11 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:05:27Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:10:09Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:10:16Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:16:14Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:16:24Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Checkpoint: File edits Automatic checkpoint created by Claude Code - Branch: fix/issue-980-memory-delete-namespace - Timestamp: 2026-01-22T16:16:37Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@claude-flow/memory
High-performance memory module for Claude Flow V3 - AgentDB unification, HNSW indexing, vector search, and hybrid SQLite+AgentDB backend (ADR-009).
Features
- 150x-12,500x Faster Search - HNSW (Hierarchical Navigable Small World) vector index for ultra-fast similarity search
- Hybrid Backend - SQLite for structured data + AgentDB for vectors (ADR-009)
- Vector Quantization - Binary, scalar, and product quantization for 4-32x memory reduction
- Multiple Distance Metrics - Cosine, Euclidean, dot product, and Manhattan distance
- Query Builder - Fluent API for building complex memory queries
- Cache Manager - LRU caching with configurable size and TTL
- Migration Tools - Seamless migration from V2 memory systems
Installation
npm install @claude-flow/memory
Quick Start
import { HNSWIndex, AgentDBAdapter, CacheManager } from '@claude-flow/memory';
// Create HNSW index for vector search
const index = new HNSWIndex({
dimensions: 1536, // OpenAI embedding size
M: 16, // Max connections per node
efConstruction: 200,
metric: 'cosine'
});
// Add vectors
await index.addPoint('memory-1', new Float32Array(embedding));
await index.addPoint('memory-2', new Float32Array(embedding2));
// Search for similar vectors
const results = await index.search(queryVector, 10);
// [{ id: 'memory-1', distance: 0.05 }, { id: 'memory-2', distance: 0.12 }]
API Reference
HNSW Index
import { HNSWIndex } from '@claude-flow/memory';
const index = new HNSWIndex({
dimensions: 1536,
M: 16, // Max connections per layer
efConstruction: 200, // Construction-time search depth
maxElements: 1000000, // Max vectors
metric: 'cosine', // 'cosine' | 'euclidean' | 'dot' | 'manhattan'
quantization: { // Optional quantization
type: 'scalar', // 'binary' | 'scalar' | 'product'
bits: 8
}
});
// Add vectors
await index.addPoint(id: string, vector: Float32Array);
// Search
const results = await index.search(
query: Float32Array,
k: number,
ef?: number // Search-time depth (higher = more accurate)
);
// Search with filters
const filtered = await index.searchWithFilters(
query,
k,
(id) => id.startsWith('session-')
);
// Remove vectors
await index.removePoint(id);
// Get statistics
const stats = index.getStats();
// { vectorCount, memoryUsage, avgSearchTime, compressionRatio }
AgentDB Adapter
import { AgentDBAdapter } from '@claude-flow/memory';
const adapter = new AgentDBAdapter({
dimension: 1536,
indexType: 'hnsw',
metric: 'cosine',
hnswM: 16,
hnswEfConstruction: 200,
enableCache: true,
cacheSizeMb: 256
});
await adapter.initialize();
// Store memory
await adapter.store({
id: 'mem-123',
content: 'User prefers dark mode',
embedding: vector,
metadata: { type: 'preference', agentId: 'agent-1' }
});
// Semantic search
const memories = await adapter.search(queryVector, {
limit: 10,
threshold: 0.7,
filter: { type: 'preference' }
});
// Cross-agent memory sharing
await adapter.enableCrossAgentSharing({
shareTypes: ['patterns', 'preferences'],
excludeTypes: ['secrets']
});
Cache Manager
import { CacheManager } from '@claude-flow/memory';
const cache = new CacheManager({
maxSize: 1000,
ttlMs: 3600000, // 1 hour
strategy: 'lru'
});
// Cache operations
cache.set('key', value);
const value = cache.get('key');
const exists = cache.has('key');
cache.delete('key');
cache.clear();
// Statistics
const stats = cache.getStats();
// { size, hits, misses, hitRate }
Query Builder
import { QueryBuilder } from '@claude-flow/memory';
const results = await new QueryBuilder()
.semantic(queryVector)
.where('agentId', '=', 'agent-1')
.where('type', 'in', ['pattern', 'strategy'])
.where('createdAt', '>', Date.now() - 86400000)
.orderBy('relevance', 'desc')
.limit(20)
.execute();
Migration
import { MemoryMigration } from '@claude-flow/memory';
const migration = new MemoryMigration({
source: './data/v2-memory.db',
destination: './data/v3-memory.db'
});
// Dry run
const preview = await migration.preview();
console.log(`Will migrate ${preview.recordCount} records`);
// Execute migration
await migration.execute({
batchSize: 1000,
onProgress: (progress) => console.log(`${progress.percent}%`)
});
Performance Benchmarks
| Operation | V2 Performance | V3 Performance | Improvement |
|---|---|---|---|
| Vector Search | 150ms | <1ms | 150x |
| Bulk Insert | 500ms | 5ms | 100x |
| Memory Write | 50ms | <5ms | 10x |
| Cache Hit | 5ms | <0.1ms | 50x |
| Index Build | 10s | 800ms | 12.5x |
Quantization Options
// Binary quantization (32x compression)
const binaryIndex = new HNSWIndex({
dimensions: 1536,
quantization: { type: 'binary' }
});
// Scalar quantization (4x compression)
const scalarIndex = new HNSWIndex({
dimensions: 1536,
quantization: { type: 'scalar', bits: 8 }
});
// Product quantization (8x compression)
const productIndex = new HNSWIndex({
dimensions: 1536,
quantization: { type: 'product', subquantizers: 8 }
});
TypeScript Types
import type {
HNSWConfig,
HNSWStats,
SearchResult,
MemoryEntry,
QuantizationConfig,
DistanceMetric
} from '@claude-flow/memory';
Dependencies
agentdb- Vector database enginebetter-sqlite3- SQLite driver (native)sql.js- SQLite driver (WASM fallback)
Related Packages
- @claude-flow/neural - Neural learning integration
- @claude-flow/shared - Shared types and utilities
License
MIT