claude-flow 2.7.1 → 2.7.3

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.
Files changed (75) hide show
  1. package/README.md +83 -22
  2. package/bin/claude-flow +1 -1
  3. package/dist/src/cli/commands/memory.js +272 -33
  4. package/dist/src/cli/commands/memory.js.map +1 -1
  5. package/dist/src/cli/help-formatter.js +3 -5
  6. package/dist/src/cli/help-formatter.js.map +1 -1
  7. package/dist/src/cli/simple-cli.js +0 -104
  8. package/dist/src/cli/simple-cli.js.map +1 -1
  9. package/dist/src/cli/simple-commands/config.js +257 -115
  10. package/dist/src/cli/simple-commands/config.js.map +1 -1
  11. package/dist/src/cli/validation-helper.js.map +1 -1
  12. package/dist/src/memory/agentdb-adapter.js +214 -0
  13. package/dist/src/memory/agentdb-adapter.js.map +1 -0
  14. package/dist/src/memory/backends/agentdb.js +234 -0
  15. package/dist/src/memory/backends/agentdb.js.map +1 -0
  16. package/dist/src/memory/index.js +11 -2
  17. package/dist/src/memory/index.js.map +1 -1
  18. package/dist/src/memory/migration/legacy-bridge.js +222 -0
  19. package/dist/src/memory/migration/legacy-bridge.js.map +1 -0
  20. package/dist/src/utils/metrics-reader.js +29 -41
  21. package/dist/src/utils/metrics-reader.js.map +1 -1
  22. package/docs/.claude-flow/metrics/performance.json +80 -2
  23. package/docs/.claude-flow/metrics/task-metrics.json +3 -3
  24. package/docs/INDEX.md +37 -12
  25. package/docs/README.md +92 -4
  26. package/docs/agentdb/AGENT3_FINAL_REPORT.md +643 -0
  27. package/docs/agentdb/AGENT3_SUMMARY.md +354 -0
  28. package/docs/agentdb/AGENTDB_INTEGRATION_PLAN.md +1258 -0
  29. package/docs/agentdb/BACKWARD_COMPATIBILITY_GUARANTEE.md +421 -0
  30. package/docs/agentdb/OPTIMIZATION_REPORT.md +360 -0
  31. package/docs/agentdb/PRODUCTION_READINESS.md +499 -0
  32. package/docs/agentdb/PUBLISHING_CHECKLIST.md +364 -0
  33. package/docs/agentdb/README.md +58 -0
  34. package/docs/agentdb/SWARM_COORDINATION.md +393 -0
  35. package/docs/agentdb/SWARM_IMPLEMENTATION_COMPLETE.md +538 -0
  36. package/docs/agentdb/agentdb-integration-summary.md +331 -0
  37. package/docs/agentdb/benchmarks/baseline-report.json +75 -0
  38. package/docs/development/AGENT1_COMPLETION_REPORT.md +466 -0
  39. package/docs/development/README.md +22 -0
  40. package/docs/fixes/PATTERN_FIX_CONFIRMATION.md +513 -0
  41. package/docs/fixes/README.md +33 -0
  42. package/docs/guides/README.md +29 -0
  43. package/docs/integrations/agentic-flow/INTEGRATION-TEST-v1.7.1.md +419 -0
  44. package/docs/integrations/agentic-flow/MIGRATION_v1.7.0.md +381 -0
  45. package/docs/integrations/agentic-flow/README.md +229 -0
  46. package/docs/integrations/agentic-flow/RELEASE-v1.7.0.md +348 -0
  47. package/docs/integrations/agentic-flow/RELEASE-v1.7.1.md +547 -0
  48. package/docs/integrations/agentic-flow/VERIFICATION-v1.7.4.md +556 -0
  49. package/docs/performance/README.md +31 -0
  50. package/docs/releases/ALPHA_TAG_UPDATE.md +150 -0
  51. package/docs/releases/README.md +25 -0
  52. package/docs/{RELEASE-NOTES-v2.7.0-alpha.10.md → releases/v2.7.0-alpha.10/RELEASE-NOTES-v2.7.0-alpha.10.md} +1 -1
  53. package/docs/releases/v2.7.1/RELEASE_SUMMARY_v2.7.1.md +340 -0
  54. package/docs/validation/DOCKER_VERIFICATION_REPORT.md +371 -0
  55. package/docs/validation/README.md +25 -0
  56. package/docs/validation/REGRESSION_ANALYSIS_v2.7.1.md +357 -0
  57. package/package.json +4 -3
  58. package/scripts/fix-agentdb-imports.sh +18 -0
  59. package/scripts/run-docker-regression.sh +101 -0
  60. package/scripts/verify-agentdb-integration.sh +220 -0
  61. package/src/cli/commands/memory.ts +347 -35
  62. package/src/memory/README-AGENTDB.md +366 -0
  63. package/src/memory/agentdb-adapter.js +373 -0
  64. package/src/memory/backends/agentdb.js +360 -0
  65. package/src/memory/index.js +32 -3
  66. package/src/memory/migration/legacy-bridge.js +330 -0
  67. /package/docs/{COMMANDS_TO_SKILLS_MIGRATION.md → development/COMMANDS_TO_SKILLS_MIGRATION.md} +0 -0
  68. /package/docs/{FINAL_INIT_STRUCTURE.md → development/FINAL_INIT_STRUCTURE.md} +0 -0
  69. /package/docs/{CLI-MEMORY-COMMANDS-WORKING.md → fixes/CLI-MEMORY-COMMANDS-WORKING.md} +0 -0
  70. /package/docs/{PATTERN_PERSISTENCE_FIX.md → fixes/PATTERN_PERSISTENCE_FIX.md} +0 -0
  71. /package/docs/{skills-tutorial.md → guides/skills-tutorial.md} +0 -0
  72. /package/docs/{PERFORMANCE-JSON-IMPROVEMENTS.md → performance/PERFORMANCE-JSON-IMPROVEMENTS.md} +0 -0
  73. /package/docs/{PERFORMANCE-METRICS-GUIDE.md → performance/PERFORMANCE-METRICS-GUIDE.md} +0 -0
  74. /package/docs/{RELEASE-NOTES-v2.7.0-alpha.9.md → releases/v2.7.0-alpha.9/RELEASE-NOTES-v2.7.0-alpha.9.md} +0 -0
  75. /package/docs/{RELEASE_v2.7.1.md → releases/v2.7.1/RELEASE_v2.7.1.md} +0 -0
@@ -0,0 +1,360 @@
1
+ /**
2
+ * AgentDB Backend - Direct integration with AgentDB v1.3.9
3
+ * Provides vector storage, HNSW search, and quantization
4
+ */
5
+
6
+ export class AgentDBBackend {
7
+ constructor(options = {}) {
8
+ this.dbPath = options.dbPath || '.agentdb/claude-flow.db';
9
+ this.quantization = options.quantization || 'scalar'; // scalar, binary, product
10
+ this.enableHNSW = options.enableHNSW !== false;
11
+ this.db = null;
12
+ this.initialized = false;
13
+ }
14
+
15
+ async initialize() {
16
+ try {
17
+ // Dynamic import of AgentDB
18
+ const { default: AgentDB } = await import('agentdb');
19
+
20
+ // Initialize AgentDB instance
21
+ this.db = new AgentDB({
22
+ path: this.dbPath,
23
+ quantization: this.quantization,
24
+ indexType: this.enableHNSW ? 'hnsw' : 'flat',
25
+ });
26
+
27
+ await this.db.init();
28
+ this.initialized = true;
29
+
30
+ console.error(
31
+ `[${new Date().toISOString()}] INFO [agentdb-backend] AgentDB initialized at ${this.dbPath}`,
32
+ );
33
+ console.error(
34
+ `[${new Date().toISOString()}] INFO [agentdb-backend] Quantization: ${this.quantization}, HNSW: ${this.enableHNSW}`,
35
+ );
36
+ } catch (error) {
37
+ console.error(
38
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Failed to initialize AgentDB: ${error.message}`,
39
+ );
40
+ throw new Error(`AgentDB initialization failed: ${error.message}`);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Store a vector with metadata
46
+ * @param {string} key - Unique identifier
47
+ * @param {Array<number>} embedding - Vector embedding
48
+ * @param {Object} metadata - Associated metadata
49
+ * @returns {Promise<void>}
50
+ */
51
+ async storeVector(key, embedding, metadata = {}) {
52
+ if (!this.initialized) {
53
+ throw new Error('AgentDB not initialized');
54
+ }
55
+
56
+ try {
57
+ await this.db.add({
58
+ id: key,
59
+ vector: embedding,
60
+ metadata: {
61
+ ...metadata,
62
+ storedAt: Date.now(),
63
+ },
64
+ });
65
+ } catch (error) {
66
+ console.error(
67
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Failed to store vector: ${error.message}`,
68
+ );
69
+ throw error;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Search for similar vectors
75
+ * @param {Array<number>|string} query - Query vector or text
76
+ * @param {Object} options - Search options
77
+ * @param {number} options.k - Number of results
78
+ * @param {string} options.namespace - Filter by namespace
79
+ * @param {Object} options.filter - Metadata filters
80
+ * @returns {Promise<Array>} Results with similarity scores
81
+ */
82
+ async search(query, options = {}) {
83
+ if (!this.initialized) {
84
+ throw new Error('AgentDB not initialized');
85
+ }
86
+
87
+ try {
88
+ const results = await this.db.search({
89
+ vector: query,
90
+ k: options.k || 10,
91
+ filter: this._buildFilter(options),
92
+ });
93
+
94
+ return results.map(result => ({
95
+ id: result.id,
96
+ similarity: result.score,
97
+ metadata: result.metadata,
98
+ value: result.metadata?.value,
99
+ }));
100
+ } catch (error) {
101
+ console.error(
102
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Search failed: ${error.message}`,
103
+ );
104
+ throw error;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Get a specific vector by key
110
+ * @param {string} key - Vector identifier
111
+ * @returns {Promise<Object|null>} Vector data or null
112
+ */
113
+ async getVector(key) {
114
+ if (!this.initialized) {
115
+ throw new Error('AgentDB not initialized');
116
+ }
117
+
118
+ try {
119
+ return await this.db.get(key);
120
+ } catch (error) {
121
+ console.error(
122
+ `[${new Date().toISOString()}] WARN [agentdb-backend] Get vector failed: ${error.message}`,
123
+ );
124
+ return null;
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Delete a vector by key
130
+ * @param {string} key - Vector identifier
131
+ * @returns {Promise<boolean>} Success status
132
+ */
133
+ async deleteVector(key) {
134
+ if (!this.initialized) {
135
+ throw new Error('AgentDB not initialized');
136
+ }
137
+
138
+ try {
139
+ await this.db.delete(key);
140
+ return true;
141
+ } catch (error) {
142
+ console.error(
143
+ `[${new Date().toISOString()}] WARN [agentdb-backend] Delete vector failed: ${error.message}`,
144
+ );
145
+ return false;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Build filter object from options
151
+ * @private
152
+ */
153
+ _buildFilter(options) {
154
+ const filter = {};
155
+
156
+ if (options.namespace) {
157
+ filter['metadata.namespace'] = options.namespace;
158
+ }
159
+
160
+ if (options.filter) {
161
+ Object.entries(options.filter).forEach(([key, value]) => {
162
+ filter[`metadata.${key}`] = value;
163
+ });
164
+ }
165
+
166
+ return Object.keys(filter).length > 0 ? filter : undefined;
167
+ }
168
+
169
+ /**
170
+ * Get database statistics
171
+ * @returns {Promise<Object>} Statistics
172
+ */
173
+ async getStats() {
174
+ if (!this.initialized) {
175
+ return {
176
+ initialized: false,
177
+ vectorCount: 0,
178
+ };
179
+ }
180
+
181
+ try {
182
+ const stats = await this.db.stats();
183
+ return {
184
+ initialized: true,
185
+ vectorCount: stats.count || 0,
186
+ indexType: this.enableHNSW ? 'hnsw' : 'flat',
187
+ quantization: this.quantization,
188
+ dbPath: this.dbPath,
189
+ ...stats,
190
+ };
191
+ } catch (error) {
192
+ console.error(
193
+ `[${new Date().toISOString()}] WARN [agentdb-backend] Stats failed: ${error.message}`,
194
+ );
195
+ return {
196
+ initialized: true,
197
+ error: error.message,
198
+ };
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Optimize database indices
204
+ * @returns {Promise<Object>} Optimization results
205
+ */
206
+ async optimize() {
207
+ if (!this.initialized) {
208
+ throw new Error('AgentDB not initialized');
209
+ }
210
+
211
+ try {
212
+ const startTime = Date.now();
213
+
214
+ if (this.enableHNSW && this.db.optimize) {
215
+ await this.db.optimize();
216
+ }
217
+
218
+ return {
219
+ success: true,
220
+ duration: Date.now() - startTime,
221
+ timestamp: Date.now(),
222
+ };
223
+ } catch (error) {
224
+ console.error(
225
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Optimization failed: ${error.message}`,
226
+ );
227
+ return {
228
+ success: false,
229
+ error: error.message,
230
+ };
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Export all vectors
236
+ * @param {string} namespace - Optional namespace filter
237
+ * @returns {Promise<Array>} All vectors
238
+ */
239
+ async exportVectors(namespace = null) {
240
+ if (!this.initialized) {
241
+ throw new Error('AgentDB not initialized');
242
+ }
243
+
244
+ try {
245
+ const filter = namespace ? { 'metadata.namespace': namespace } : undefined;
246
+ const results = await this.db.list({ filter });
247
+
248
+ return results.map(result => ({
249
+ id: result.id,
250
+ vector: result.vector,
251
+ metadata: result.metadata,
252
+ }));
253
+ } catch (error) {
254
+ console.error(
255
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Export failed: ${error.message}`,
256
+ );
257
+ throw error;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Import vectors in batch
263
+ * @param {Array} vectors - Array of {id, vector, metadata}
264
+ * @returns {Promise<Object>} Import results
265
+ */
266
+ async importVectors(vectors) {
267
+ if (!this.initialized) {
268
+ throw new Error('AgentDB not initialized');
269
+ }
270
+
271
+ try {
272
+ const startTime = Date.now();
273
+ let successCount = 0;
274
+ let errorCount = 0;
275
+
276
+ for (const vector of vectors) {
277
+ try {
278
+ await this.storeVector(vector.id, vector.vector, vector.metadata);
279
+ successCount++;
280
+ } catch (error) {
281
+ errorCount++;
282
+ console.error(
283
+ `[${new Date().toISOString()}] WARN [agentdb-backend] Import vector failed: ${error.message}`,
284
+ );
285
+ }
286
+ }
287
+
288
+ return {
289
+ success: true,
290
+ imported: successCount,
291
+ errors: errorCount,
292
+ total: vectors.length,
293
+ duration: Date.now() - startTime,
294
+ };
295
+ } catch (error) {
296
+ console.error(
297
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Import failed: ${error.message}`,
298
+ );
299
+ throw error;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Cleanup expired or invalid vectors
305
+ * @returns {Promise<Object>} Cleanup results
306
+ */
307
+ async cleanup() {
308
+ if (!this.initialized) {
309
+ throw new Error('AgentDB not initialized');
310
+ }
311
+
312
+ try {
313
+ // AgentDB handles its own cleanup internally
314
+ // This is a placeholder for custom cleanup logic if needed
315
+ const stats = await this.getStats();
316
+
317
+ return {
318
+ success: true,
319
+ vectorCount: stats.vectorCount,
320
+ timestamp: Date.now(),
321
+ };
322
+ } catch (error) {
323
+ console.error(
324
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Cleanup failed: ${error.message}`,
325
+ );
326
+ return {
327
+ success: false,
328
+ error: error.message,
329
+ };
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Close database connection
335
+ * @returns {Promise<void>}
336
+ */
337
+ async close() {
338
+ if (!this.initialized) {
339
+ return;
340
+ }
341
+
342
+ try {
343
+ if (this.db && this.db.close) {
344
+ await this.db.close();
345
+ }
346
+ this.initialized = false;
347
+
348
+ console.error(
349
+ `[${new Date().toISOString()}] INFO [agentdb-backend] AgentDB closed`,
350
+ );
351
+ } catch (error) {
352
+ console.error(
353
+ `[${new Date().toISOString()}] ERROR [agentdb-backend] Close failed: ${error.message}`,
354
+ );
355
+ throw error;
356
+ }
357
+ }
358
+ }
359
+
360
+ export default AgentDBBackend;
@@ -2,14 +2,25 @@
2
2
  * Memory Module - Unified memory persistence for ruv-swarm
3
3
  *
4
4
  * Provides both generic SharedMemory and MCP-specific SwarmMemory implementations
5
+ * Now with AgentDB v1.3.9 vector database integration
5
6
  *
6
7
  * @module memory
7
8
  */
8
9
 
9
10
  import SharedMemory from './shared-memory.js';
10
11
  import { SwarmMemory, createSwarmMemory } from './swarm-memory.js';
12
+ import { AgentDBMemoryAdapter } from './agentdb-adapter.js';
13
+ import { AgentDBBackend } from './backends/agentdb.js';
14
+ import { LegacyDataBridge } from './migration/legacy-bridge.js';
11
15
 
12
- export { SharedMemory, SwarmMemory, createSwarmMemory };
16
+ export {
17
+ SharedMemory,
18
+ SwarmMemory,
19
+ createSwarmMemory,
20
+ AgentDBMemoryAdapter,
21
+ AgentDBBackend,
22
+ LegacyDataBridge,
23
+ };
13
24
 
14
25
  // Re-export swarm namespaces for convenience
15
26
  export const SWARM_NAMESPACES = {
@@ -25,14 +36,32 @@ export const SWARM_NAMESPACES = {
25
36
  /**
26
37
  * Create memory instance based on context
27
38
  * @param {Object} options - Configuration options
28
- * @returns {SharedMemory|SwarmMemory} Memory instance
39
+ * @param {string} options.type - Memory type: 'swarm', 'agentdb', or default
40
+ * @param {string} options.mode - AgentDB mode: 'hybrid', 'agentdb', or 'legacy'
41
+ * @returns {SharedMemory|SwarmMemory|AgentDBMemoryAdapter} Memory instance
29
42
  */
30
43
  export function createMemory(options = {}) {
44
+ // Create AgentDB-enhanced memory if requested
45
+ if (options.type === 'agentdb' || options.mode) {
46
+ return new AgentDBMemoryAdapter(options);
47
+ }
48
+
49
+ // Create swarm-specific memory
31
50
  if (options.type === 'swarm' || options.swarmId) {
32
51
  return new SwarmMemory(options);
33
52
  }
53
+
54
+ // Default to SharedMemory
34
55
  return new SharedMemory(options);
35
56
  }
36
57
 
37
58
  // Default export for backwards compatibility
38
- export default { SharedMemory, SwarmMemory, createMemory, SWARM_NAMESPACES };
59
+ export default {
60
+ SharedMemory,
61
+ SwarmMemory,
62
+ createMemory,
63
+ SWARM_NAMESPACES,
64
+ AgentDBMemoryAdapter,
65
+ AgentDBBackend,
66
+ LegacyDataBridge,
67
+ };