claude-flow 2.7.1 → 2.7.2

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 (76) hide show
  1. package/README.md +83 -22
  2. package/bin/claude-flow +1 -1
  3. package/dist/src/cli/commands/memory.js +64 -1
  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-commands/config.js +257 -115
  8. package/dist/src/cli/simple-commands/config.js.map +1 -1
  9. package/dist/src/core/version.js +1 -1
  10. package/dist/src/core/version.js.map +1 -1
  11. package/dist/src/memory/agentdb-adapter.js +214 -0
  12. package/dist/src/memory/agentdb-adapter.js.map +1 -0
  13. package/dist/src/memory/backends/agentdb.js +234 -0
  14. package/dist/src/memory/backends/agentdb.js.map +1 -0
  15. package/dist/src/memory/index.js +11 -2
  16. package/dist/src/memory/index.js.map +1 -1
  17. package/dist/src/memory/migration/legacy-bridge.js +222 -0
  18. package/dist/src/memory/migration/legacy-bridge.js.map +1 -0
  19. package/dist/src/memory/swarm-memory.js +421 -340
  20. package/dist/src/memory/swarm-memory.js.map +1 -1
  21. package/dist/src/utils/key-redactor.js.map +1 -1
  22. package/dist/src/utils/metrics-reader.js.map +1 -1
  23. package/docs/.claude-flow/metrics/performance.json +80 -2
  24. package/docs/.claude-flow/metrics/task-metrics.json +3 -3
  25. package/docs/INDEX.md +37 -12
  26. package/docs/README.md +92 -4
  27. package/docs/agentdb/AGENT3_FINAL_REPORT.md +643 -0
  28. package/docs/agentdb/AGENT3_SUMMARY.md +354 -0
  29. package/docs/agentdb/AGENTDB_INTEGRATION_PLAN.md +1258 -0
  30. package/docs/agentdb/BACKWARD_COMPATIBILITY_GUARANTEE.md +421 -0
  31. package/docs/agentdb/OPTIMIZATION_REPORT.md +360 -0
  32. package/docs/agentdb/PRODUCTION_READINESS.md +499 -0
  33. package/docs/agentdb/PUBLISHING_CHECKLIST.md +364 -0
  34. package/docs/agentdb/README.md +58 -0
  35. package/docs/agentdb/SWARM_COORDINATION.md +393 -0
  36. package/docs/agentdb/SWARM_IMPLEMENTATION_COMPLETE.md +538 -0
  37. package/docs/agentdb/agentdb-integration-summary.md +331 -0
  38. package/docs/agentdb/benchmarks/baseline-report.json +75 -0
  39. package/docs/development/AGENT1_COMPLETION_REPORT.md +466 -0
  40. package/docs/development/README.md +22 -0
  41. package/docs/fixes/PATTERN_FIX_CONFIRMATION.md +513 -0
  42. package/docs/fixes/README.md +33 -0
  43. package/docs/guides/README.md +29 -0
  44. package/docs/integrations/agentic-flow/INTEGRATION-TEST-v1.7.1.md +419 -0
  45. package/docs/integrations/agentic-flow/MIGRATION_v1.7.0.md +381 -0
  46. package/docs/integrations/agentic-flow/README.md +229 -0
  47. package/docs/integrations/agentic-flow/RELEASE-v1.7.0.md +348 -0
  48. package/docs/integrations/agentic-flow/RELEASE-v1.7.1.md +547 -0
  49. package/docs/integrations/agentic-flow/VERIFICATION-v1.7.4.md +556 -0
  50. package/docs/performance/README.md +31 -0
  51. package/docs/releases/ALPHA_TAG_UPDATE.md +150 -0
  52. package/docs/releases/README.md +25 -0
  53. 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
  54. package/docs/releases/v2.7.1/RELEASE_SUMMARY_v2.7.1.md +340 -0
  55. package/docs/validation/DOCKER_VERIFICATION_REPORT.md +371 -0
  56. package/docs/validation/README.md +25 -0
  57. package/docs/validation/REGRESSION_ANALYSIS_v2.7.1.md +357 -0
  58. package/package.json +4 -3
  59. package/scripts/fix-agentdb-imports.sh +18 -0
  60. package/scripts/run-docker-regression.sh +101 -0
  61. package/scripts/verify-agentdb-integration.sh +220 -0
  62. package/src/cli/commands/memory.ts +95 -1
  63. package/src/memory/README-AGENTDB.md +366 -0
  64. package/src/memory/agentdb-adapter.js +373 -0
  65. package/src/memory/backends/agentdb.js +360 -0
  66. package/src/memory/index.js +32 -3
  67. package/src/memory/migration/legacy-bridge.js +330 -0
  68. /package/docs/{COMMANDS_TO_SKILLS_MIGRATION.md → development/COMMANDS_TO_SKILLS_MIGRATION.md} +0 -0
  69. /package/docs/{FINAL_INIT_STRUCTURE.md → development/FINAL_INIT_STRUCTURE.md} +0 -0
  70. /package/docs/{CLI-MEMORY-COMMANDS-WORKING.md → fixes/CLI-MEMORY-COMMANDS-WORKING.md} +0 -0
  71. /package/docs/{PATTERN_PERSISTENCE_FIX.md → fixes/PATTERN_PERSISTENCE_FIX.md} +0 -0
  72. /package/docs/{skills-tutorial.md → guides/skills-tutorial.md} +0 -0
  73. /package/docs/{PERFORMANCE-JSON-IMPROVEMENTS.md → performance/PERFORMANCE-JSON-IMPROVEMENTS.md} +0 -0
  74. /package/docs/{PERFORMANCE-METRICS-GUIDE.md → performance/PERFORMANCE-METRICS-GUIDE.md} +0 -0
  75. /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
  76. /package/docs/{RELEASE_v2.7.1.md → releases/v2.7.1/RELEASE_v2.7.1.md} +0 -0
@@ -0,0 +1,330 @@
1
+ /**
2
+ * Legacy Data Bridge - Migration utilities for AgentDB integration
3
+ * Provides safe migration from legacy memory stores to AgentDB
4
+ */
5
+
6
+ import { writeFileSync, readFileSync, existsSync } from 'fs';
7
+ import { join } from 'path';
8
+
9
+ export class LegacyDataBridge {
10
+ constructor(options = {}) {
11
+ this.backupDir = options.backupDir || '.agentdb/backups';
12
+ this.verbose = options.verbose || false;
13
+ }
14
+
15
+ /**
16
+ * Migrate all data from legacy store to AgentDB
17
+ * @param {Object} sourceStore - Legacy memory store (EnhancedMemory)
18
+ * @param {Object} targetAdapter - AgentDB adapter
19
+ * @param {Object} options - Migration options
20
+ * @returns {Promise<Object>} Migration results
21
+ */
22
+ async migrateToAgentDB(sourceStore, targetAdapter, options = {}) {
23
+ const startTime = Date.now();
24
+ const results = {
25
+ success: false,
26
+ migrated: 0,
27
+ errors: 0,
28
+ skipped: 0,
29
+ backupPath: null,
30
+ duration: 0,
31
+ };
32
+
33
+ try {
34
+ // Step 1: Create backup
35
+ this._log('Creating backup of legacy data...');
36
+ const backupPath = await this.createBackup(sourceStore);
37
+ results.backupPath = backupPath;
38
+ this._log(`Backup created at: ${backupPath}`);
39
+
40
+ // Step 2: Export all legacy data
41
+ this._log('Exporting legacy data...');
42
+ const legacyData = await sourceStore.exportData();
43
+
44
+ // Step 3: Migrate each namespace
45
+ for (const [namespace, items] of Object.entries(legacyData)) {
46
+ this._log(`Migrating namespace: ${namespace} (${items.length} items)`);
47
+
48
+ for (const item of items) {
49
+ try {
50
+ // Check if item should be migrated with embedding
51
+ const shouldEmbed = this._shouldEmbed(item, namespace, options);
52
+
53
+ if (shouldEmbed && options.generateEmbedding) {
54
+ // Generate embedding and store with vector
55
+ const embedding = await options.generateEmbedding(item.value);
56
+
57
+ await targetAdapter.storeWithEmbedding(item.key, item.value, {
58
+ embedding,
59
+ metadata: item.metadata,
60
+ namespace,
61
+ ttl: item.ttl,
62
+ });
63
+ } else {
64
+ // Store without embedding (legacy compatibility)
65
+ await targetAdapter.store(item.key, item.value, {
66
+ metadata: item.metadata,
67
+ namespace,
68
+ ttl: item.ttl,
69
+ });
70
+ }
71
+
72
+ results.migrated++;
73
+ } catch (error) {
74
+ results.errors++;
75
+ this._log(`Error migrating ${item.key}: ${error.message}`, 'error');
76
+
77
+ if (options.stopOnError) {
78
+ throw error;
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ // Step 4: Validate migration
85
+ this._log('Validating migration...');
86
+ const validation = await this.validateMigration(sourceStore, targetAdapter);
87
+
88
+ if (!validation.isValid && options.strictValidation) {
89
+ throw new Error(`Migration validation failed: ${validation.errors.join(', ')}`);
90
+ }
91
+
92
+ results.success = true;
93
+ results.duration = Date.now() - startTime;
94
+
95
+ this._log(`Migration completed in ${results.duration}ms`);
96
+ this._log(`Migrated: ${results.migrated}, Errors: ${results.errors}, Skipped: ${results.skipped}`);
97
+
98
+ return results;
99
+ } catch (error) {
100
+ results.success = false;
101
+ results.duration = Date.now() - startTime;
102
+ results.error = error.message;
103
+
104
+ this._log(`Migration failed: ${error.message}`, 'error');
105
+ return results;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Validate migration integrity
111
+ * @param {Object} sourceStore - Source legacy store
112
+ * @param {Object} targetAdapter - Target AgentDB adapter
113
+ * @returns {Promise<Object>} Validation results
114
+ */
115
+ async validateMigration(sourceStore, targetAdapter) {
116
+ const validation = {
117
+ isValid: true,
118
+ errors: [],
119
+ warnings: [],
120
+ stats: {
121
+ sourceCount: 0,
122
+ targetCount: 0,
123
+ matched: 0,
124
+ mismatched: 0,
125
+ },
126
+ };
127
+
128
+ try {
129
+ // Export both stores
130
+ const sourceData = await sourceStore.exportData();
131
+ const targetData = await targetAdapter.exportData();
132
+
133
+ // Count total items
134
+ for (const items of Object.values(sourceData)) {
135
+ validation.stats.sourceCount += items.length;
136
+ }
137
+
138
+ for (const items of Object.values(targetData)) {
139
+ validation.stats.targetCount += items.length;
140
+ }
141
+
142
+ // Validate each namespace
143
+ for (const [namespace, sourceItems] of Object.entries(sourceData)) {
144
+ const targetItems = targetData[namespace] || [];
145
+ const targetKeys = new Set(targetItems.map(item => item.key));
146
+
147
+ for (const sourceItem of sourceItems) {
148
+ if (targetKeys.has(sourceItem.key)) {
149
+ // Find matching item
150
+ const targetItem = targetItems.find(item => item.key === sourceItem.key);
151
+
152
+ // Deep compare values
153
+ if (JSON.stringify(sourceItem.value) === JSON.stringify(targetItem.value)) {
154
+ validation.stats.matched++;
155
+ } else {
156
+ validation.stats.mismatched++;
157
+ validation.warnings.push(
158
+ `Value mismatch for key: ${sourceItem.key} in namespace: ${namespace}`,
159
+ );
160
+ }
161
+ } else {
162
+ validation.errors.push(`Missing key in target: ${sourceItem.key} in namespace: ${namespace}`);
163
+ validation.isValid = false;
164
+ }
165
+ }
166
+ }
167
+
168
+ // Check for count discrepancies
169
+ if (validation.stats.sourceCount !== validation.stats.targetCount) {
170
+ validation.warnings.push(
171
+ `Count mismatch: source=${validation.stats.sourceCount}, target=${validation.stats.targetCount}`,
172
+ );
173
+ }
174
+
175
+ return validation;
176
+ } catch (error) {
177
+ validation.isValid = false;
178
+ validation.errors.push(`Validation error: ${error.message}`);
179
+ return validation;
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Rollback migration from backup
185
+ * @param {string} backupPath - Path to backup file
186
+ * @param {Object} targetStore - Store to restore to
187
+ * @returns {Promise<Object>} Rollback results
188
+ */
189
+ async rollback(backupPath, targetStore) {
190
+ const startTime = Date.now();
191
+ const results = {
192
+ success: false,
193
+ restored: 0,
194
+ errors: 0,
195
+ duration: 0,
196
+ };
197
+
198
+ try {
199
+ // Check if backup exists
200
+ if (!existsSync(backupPath)) {
201
+ throw new Error(`Backup file not found: ${backupPath}`);
202
+ }
203
+
204
+ // Read backup
205
+ this._log(`Reading backup from: ${backupPath}`);
206
+ const backupData = JSON.parse(readFileSync(backupPath, 'utf-8'));
207
+
208
+ // Restore data
209
+ this._log('Restoring data from backup...');
210
+ await targetStore.importData(backupData);
211
+
212
+ results.success = true;
213
+ results.duration = Date.now() - startTime;
214
+
215
+ this._log(`Rollback completed in ${results.duration}ms`);
216
+ return results;
217
+ } catch (error) {
218
+ results.success = false;
219
+ results.duration = Date.now() - startTime;
220
+ results.error = error.message;
221
+
222
+ this._log(`Rollback failed: ${error.message}`, 'error');
223
+ return results;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Create backup of current data
229
+ * @param {Object} sourceStore - Store to backup
230
+ * @returns {Promise<string>} Backup file path
231
+ */
232
+ async createBackup(sourceStore) {
233
+ try {
234
+ // Ensure backup directory exists
235
+ const fs = await import('fs');
236
+ if (!fs.existsSync(this.backupDir)) {
237
+ fs.mkdirSync(this.backupDir, { recursive: true });
238
+ }
239
+
240
+ // Export data
241
+ const data = await sourceStore.exportData();
242
+
243
+ // Create backup file with timestamp
244
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
245
+ const backupPath = join(this.backupDir, `backup-${timestamp}.json`);
246
+
247
+ // Write backup
248
+ writeFileSync(backupPath, JSON.stringify(data, null, 2), 'utf-8');
249
+
250
+ return backupPath;
251
+ } catch (error) {
252
+ throw new Error(`Backup creation failed: ${error.message}`);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Determine if item should have embedding
258
+ * @private
259
+ */
260
+ _shouldEmbed(item, namespace, options) {
261
+ // Skip embedding for certain namespaces
262
+ const skipNamespaces = options.skipEmbedding || ['metrics', 'performance', 'coordination'];
263
+
264
+ if (skipNamespaces.includes(namespace)) {
265
+ return false;
266
+ }
267
+
268
+ // Skip if value is not suitable for embedding
269
+ if (typeof item.value !== 'object' && typeof item.value !== 'string') {
270
+ return false;
271
+ }
272
+
273
+ // Embed knowledge, learning, and sessions by default
274
+ const embedNamespaces = options.embedNamespaces || ['knowledge', 'learning', 'sessions', 'workflows'];
275
+
276
+ return embedNamespaces.includes(namespace);
277
+ }
278
+
279
+ /**
280
+ * Log message
281
+ * @private
282
+ */
283
+ _log(message, level = 'info') {
284
+ if (!this.verbose && level !== 'error') {
285
+ return;
286
+ }
287
+
288
+ const timestamp = new Date().toISOString();
289
+ const prefix = level === 'error' ? 'ERROR' : 'INFO';
290
+
291
+ console.error(`[${timestamp}] ${prefix} [legacy-bridge] ${message}`);
292
+ }
293
+
294
+ /**
295
+ * Generate migration report
296
+ * @param {Object} results - Migration results
297
+ * @returns {string} Formatted report
298
+ */
299
+ generateReport(results) {
300
+ const lines = [];
301
+
302
+ lines.push('='.repeat(60));
303
+ lines.push('AgentDB Migration Report');
304
+ lines.push('='.repeat(60));
305
+ lines.push('');
306
+ lines.push(`Status: ${results.success ? 'SUCCESS' : 'FAILED'}`);
307
+ lines.push(`Duration: ${results.duration}ms`);
308
+ lines.push('');
309
+ lines.push('Statistics:');
310
+ lines.push(` Migrated: ${results.migrated}`);
311
+ lines.push(` Errors: ${results.errors}`);
312
+ lines.push(` Skipped: ${results.skipped}`);
313
+
314
+ if (results.backupPath) {
315
+ lines.push('');
316
+ lines.push(`Backup Location: ${results.backupPath}`);
317
+ }
318
+
319
+ if (results.error) {
320
+ lines.push('');
321
+ lines.push(`Error: ${results.error}`);
322
+ }
323
+
324
+ lines.push('='.repeat(60));
325
+
326
+ return lines.join('\n');
327
+ }
328
+ }
329
+
330
+ export default LegacyDataBridge;