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.
- package/README.md +83 -22
- package/bin/claude-flow +1 -1
- package/dist/src/cli/commands/memory.js +272 -33
- package/dist/src/cli/commands/memory.js.map +1 -1
- package/dist/src/cli/help-formatter.js +3 -5
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/simple-cli.js +0 -104
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/config.js +257 -115
- package/dist/src/cli/simple-commands/config.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/memory/agentdb-adapter.js +214 -0
- package/dist/src/memory/agentdb-adapter.js.map +1 -0
- package/dist/src/memory/backends/agentdb.js +234 -0
- package/dist/src/memory/backends/agentdb.js.map +1 -0
- package/dist/src/memory/index.js +11 -2
- package/dist/src/memory/index.js.map +1 -1
- package/dist/src/memory/migration/legacy-bridge.js +222 -0
- package/dist/src/memory/migration/legacy-bridge.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +29 -41
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/.claude-flow/metrics/performance.json +80 -2
- package/docs/.claude-flow/metrics/task-metrics.json +3 -3
- package/docs/INDEX.md +37 -12
- package/docs/README.md +92 -4
- package/docs/agentdb/AGENT3_FINAL_REPORT.md +643 -0
- package/docs/agentdb/AGENT3_SUMMARY.md +354 -0
- package/docs/agentdb/AGENTDB_INTEGRATION_PLAN.md +1258 -0
- package/docs/agentdb/BACKWARD_COMPATIBILITY_GUARANTEE.md +421 -0
- package/docs/agentdb/OPTIMIZATION_REPORT.md +360 -0
- package/docs/agentdb/PRODUCTION_READINESS.md +499 -0
- package/docs/agentdb/PUBLISHING_CHECKLIST.md +364 -0
- package/docs/agentdb/README.md +58 -0
- package/docs/agentdb/SWARM_COORDINATION.md +393 -0
- package/docs/agentdb/SWARM_IMPLEMENTATION_COMPLETE.md +538 -0
- package/docs/agentdb/agentdb-integration-summary.md +331 -0
- package/docs/agentdb/benchmarks/baseline-report.json +75 -0
- package/docs/development/AGENT1_COMPLETION_REPORT.md +466 -0
- package/docs/development/README.md +22 -0
- package/docs/fixes/PATTERN_FIX_CONFIRMATION.md +513 -0
- package/docs/fixes/README.md +33 -0
- package/docs/guides/README.md +29 -0
- package/docs/integrations/agentic-flow/INTEGRATION-TEST-v1.7.1.md +419 -0
- package/docs/integrations/agentic-flow/MIGRATION_v1.7.0.md +381 -0
- package/docs/integrations/agentic-flow/README.md +229 -0
- package/docs/integrations/agentic-flow/RELEASE-v1.7.0.md +348 -0
- package/docs/integrations/agentic-flow/RELEASE-v1.7.1.md +547 -0
- package/docs/integrations/agentic-flow/VERIFICATION-v1.7.4.md +556 -0
- package/docs/performance/README.md +31 -0
- package/docs/releases/ALPHA_TAG_UPDATE.md +150 -0
- package/docs/releases/README.md +25 -0
- 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
- package/docs/releases/v2.7.1/RELEASE_SUMMARY_v2.7.1.md +340 -0
- package/docs/validation/DOCKER_VERIFICATION_REPORT.md +371 -0
- package/docs/validation/README.md +25 -0
- package/docs/validation/REGRESSION_ANALYSIS_v2.7.1.md +357 -0
- package/package.json +4 -3
- package/scripts/fix-agentdb-imports.sh +18 -0
- package/scripts/run-docker-regression.sh +101 -0
- package/scripts/verify-agentdb-integration.sh +220 -0
- package/src/cli/commands/memory.ts +347 -35
- package/src/memory/README-AGENTDB.md +366 -0
- package/src/memory/agentdb-adapter.js +373 -0
- package/src/memory/backends/agentdb.js +360 -0
- package/src/memory/index.js +32 -3
- package/src/memory/migration/legacy-bridge.js +330 -0
- /package/docs/{COMMANDS_TO_SKILLS_MIGRATION.md → development/COMMANDS_TO_SKILLS_MIGRATION.md} +0 -0
- /package/docs/{FINAL_INIT_STRUCTURE.md → development/FINAL_INIT_STRUCTURE.md} +0 -0
- /package/docs/{CLI-MEMORY-COMMANDS-WORKING.md → fixes/CLI-MEMORY-COMMANDS-WORKING.md} +0 -0
- /package/docs/{PATTERN_PERSISTENCE_FIX.md → fixes/PATTERN_PERSISTENCE_FIX.md} +0 -0
- /package/docs/{skills-tutorial.md → guides/skills-tutorial.md} +0 -0
- /package/docs/{PERFORMANCE-JSON-IMPROVEMENTS.md → performance/PERFORMANCE-JSON-IMPROVEMENTS.md} +0 -0
- /package/docs/{PERFORMANCE-METRICS-GUIDE.md → performance/PERFORMANCE-METRICS-GUIDE.md} +0 -0
- /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
- /package/docs/{RELEASE_v2.7.1.md → releases/v2.7.1/RELEASE_v2.7.1.md} +0 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentDB Memory Adapter - v1.3.9 Integration
|
|
3
|
+
* Extends EnhancedMemory with vector search capabilities
|
|
4
|
+
* 100% backward compatible with existing memory operations
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { EnhancedMemory } from './enhanced-memory.js';
|
|
8
|
+
import { AgentDBBackend } from './backends/agentdb.js';
|
|
9
|
+
|
|
10
|
+
export class AgentDBMemoryAdapter extends EnhancedMemory {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super(options);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Operational modes:
|
|
16
|
+
* - 'hybrid': AgentDB for new features, fallback to legacy (default, recommended)
|
|
17
|
+
* - 'agentdb': AgentDB only, fail if unavailable
|
|
18
|
+
* - 'legacy': Legacy only, no AgentDB features
|
|
19
|
+
*/
|
|
20
|
+
this.mode = options.mode || 'hybrid';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* AgentDB instance for vector operations
|
|
24
|
+
* Null if mode is 'legacy' or initialization fails
|
|
25
|
+
*/
|
|
26
|
+
this.agentdb = null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Track initialization state
|
|
30
|
+
*/
|
|
31
|
+
this.agentdbInitialized = false;
|
|
32
|
+
this.agentdbError = null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async initialize() {
|
|
36
|
+
// Always initialize legacy memory first
|
|
37
|
+
await super.initialize();
|
|
38
|
+
|
|
39
|
+
// Initialize AgentDB if mode allows
|
|
40
|
+
if (this.mode !== 'legacy') {
|
|
41
|
+
try {
|
|
42
|
+
this.agentdb = new AgentDBBackend({
|
|
43
|
+
dbPath: this.options.agentdbPath || '.agentdb/claude-flow.db',
|
|
44
|
+
quantization: this.options.quantization || 'scalar',
|
|
45
|
+
enableHNSW: this.options.enableHNSW !== false,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await this.agentdb.initialize();
|
|
49
|
+
this.agentdbInitialized = true;
|
|
50
|
+
|
|
51
|
+
console.error(
|
|
52
|
+
`[${new Date().toISOString()}] INFO [agentdb-adapter] AgentDB initialized in ${this.mode} mode`,
|
|
53
|
+
);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
this.agentdbError = error;
|
|
56
|
+
|
|
57
|
+
if (this.mode === 'agentdb') {
|
|
58
|
+
// Fail hard if AgentDB-only mode
|
|
59
|
+
throw new Error(`AgentDB initialization failed in agentdb-only mode: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Hybrid mode: warn and continue with legacy
|
|
63
|
+
console.error(
|
|
64
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] AgentDB initialization failed, using legacy mode: ${error.message}`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Check if AgentDB is available
|
|
72
|
+
* @returns {boolean} True if AgentDB is initialized and ready
|
|
73
|
+
*/
|
|
74
|
+
isAgentDBAvailable() {
|
|
75
|
+
return this.agentdbInitialized && this.agentdb !== null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Store data with optional vector embedding
|
|
80
|
+
* Backward compatible with legacy store() method
|
|
81
|
+
*
|
|
82
|
+
* @param {string} key - Storage key
|
|
83
|
+
* @param {*} value - Value to store
|
|
84
|
+
* @param {Object} options - Storage options
|
|
85
|
+
* @param {string} options.embedding - Optional embedding vector for semantic search
|
|
86
|
+
* @param {Object} options.metadata - Metadata for the entry
|
|
87
|
+
* @param {string} options.namespace - Namespace for organization
|
|
88
|
+
* @param {number} options.ttl - Time to live in seconds
|
|
89
|
+
* @returns {Promise<*>} Storage result
|
|
90
|
+
*/
|
|
91
|
+
async storeWithEmbedding(key, value, options = {}) {
|
|
92
|
+
// Always store in legacy for backward compatibility
|
|
93
|
+
const legacyResult = await this.store(key, value, options);
|
|
94
|
+
|
|
95
|
+
// If embedding provided and AgentDB available, store vector
|
|
96
|
+
if (options.embedding && this.isAgentDBAvailable()) {
|
|
97
|
+
try {
|
|
98
|
+
await this.agentdb.storeVector(key, options.embedding, {
|
|
99
|
+
value,
|
|
100
|
+
metadata: options.metadata,
|
|
101
|
+
namespace: options.namespace,
|
|
102
|
+
timestamp: Date.now(),
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(
|
|
106
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] Vector storage failed: ${error.message}`,
|
|
107
|
+
);
|
|
108
|
+
// Don't fail if vector storage fails in hybrid mode
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return legacyResult;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Perform semantic vector search
|
|
117
|
+
* Falls back to legacy search if AgentDB unavailable
|
|
118
|
+
*
|
|
119
|
+
* @param {Array<number>|string} query - Query vector or embedding
|
|
120
|
+
* @param {Object} options - Search options
|
|
121
|
+
* @param {number} options.k - Number of results (default: 10)
|
|
122
|
+
* @param {string} options.namespace - Filter by namespace
|
|
123
|
+
* @param {Object} options.filter - Additional filters
|
|
124
|
+
* @returns {Promise<Array>} Search results with similarity scores
|
|
125
|
+
*/
|
|
126
|
+
async vectorSearch(query, options = {}) {
|
|
127
|
+
if (!this.isAgentDBAvailable()) {
|
|
128
|
+
// Fallback to legacy pattern search
|
|
129
|
+
console.error(
|
|
130
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] AgentDB unavailable, falling back to legacy search`,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const pattern = typeof query === 'string' ? query : '*';
|
|
134
|
+
return this.search(pattern, {
|
|
135
|
+
namespace: options.namespace,
|
|
136
|
+
limit: options.k || 10,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
return await this.agentdb.search(query, {
|
|
142
|
+
k: options.k || 10,
|
|
143
|
+
namespace: options.namespace,
|
|
144
|
+
filter: options.filter,
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error(
|
|
148
|
+
`[${new Date().toISOString()}] ERROR [agentdb-adapter] Vector search failed: ${error.message}`,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Fallback to legacy in hybrid mode
|
|
152
|
+
if (this.mode === 'hybrid') {
|
|
153
|
+
const pattern = typeof query === 'string' ? query : '*';
|
|
154
|
+
return this.search(pattern, {
|
|
155
|
+
namespace: options.namespace,
|
|
156
|
+
limit: options.k || 10,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Retrieve semantically similar data
|
|
166
|
+
* Combines vector search with legacy retrieval
|
|
167
|
+
*
|
|
168
|
+
* @param {string} query - Query text or embedding
|
|
169
|
+
* @param {Object} options - Retrieval options
|
|
170
|
+
* @returns {Promise<*>} Retrieved value or null
|
|
171
|
+
*/
|
|
172
|
+
async semanticRetrieve(query, options = {}) {
|
|
173
|
+
if (!this.isAgentDBAvailable()) {
|
|
174
|
+
// Fallback to exact key match
|
|
175
|
+
return this.retrieve(query, options);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
const results = await this.vectorSearch(query, {
|
|
180
|
+
k: 1,
|
|
181
|
+
namespace: options.namespace,
|
|
182
|
+
filter: options.filter,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (results.length === 0) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Return the most similar result
|
|
190
|
+
return results[0].value || results[0].metadata?.value;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error(
|
|
193
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] Semantic retrieve failed: ${error.message}`,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
// Fallback to exact match
|
|
197
|
+
return this.retrieve(query, options);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Store knowledge with semantic embedding
|
|
203
|
+
* Enhanced version of storeKnowledge with vector support
|
|
204
|
+
*/
|
|
205
|
+
async storeKnowledgeWithEmbedding(domain, key, value, metadata = {}, embedding = null) {
|
|
206
|
+
// Store in legacy knowledge base
|
|
207
|
+
const legacyResult = await this.storeKnowledge(domain, key, value, metadata);
|
|
208
|
+
|
|
209
|
+
// If embedding provided, store vector
|
|
210
|
+
if (embedding && this.isAgentDBAvailable()) {
|
|
211
|
+
try {
|
|
212
|
+
await this.agentdb.storeVector(`knowledge:${domain}:${key}`, embedding, {
|
|
213
|
+
domain,
|
|
214
|
+
key,
|
|
215
|
+
value,
|
|
216
|
+
metadata,
|
|
217
|
+
createdAt: Date.now(),
|
|
218
|
+
});
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error(
|
|
221
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] Knowledge vector storage failed: ${error.message}`,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return legacyResult;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Search knowledge semantically
|
|
231
|
+
* Enhanced version of searchKnowledge with vector support
|
|
232
|
+
*/
|
|
233
|
+
async searchKnowledgeSemantic(domain, queryEmbedding, options = {}) {
|
|
234
|
+
if (!this.isAgentDBAvailable()) {
|
|
235
|
+
// Fallback to legacy pattern search
|
|
236
|
+
return this.searchKnowledge(domain, '*');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
return await this.agentdb.search(queryEmbedding, {
|
|
241
|
+
k: options.limit || 50,
|
|
242
|
+
filter: { domain },
|
|
243
|
+
});
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.error(
|
|
246
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] Semantic knowledge search failed: ${error.message}`,
|
|
247
|
+
);
|
|
248
|
+
return this.searchKnowledge(domain, '*');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get AgentDB statistics
|
|
254
|
+
* @returns {Promise<Object>} Database statistics
|
|
255
|
+
*/
|
|
256
|
+
async getAgentDBStats() {
|
|
257
|
+
if (!this.isAgentDBAvailable()) {
|
|
258
|
+
return {
|
|
259
|
+
available: false,
|
|
260
|
+
error: this.agentdbError?.message || 'AgentDB not initialized',
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
try {
|
|
265
|
+
return await this.agentdb.getStats();
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return {
|
|
268
|
+
available: true,
|
|
269
|
+
error: error.message,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Optimize AgentDB indices
|
|
276
|
+
* @returns {Promise<Object>} Optimization results
|
|
277
|
+
*/
|
|
278
|
+
async optimizeAgentDB() {
|
|
279
|
+
if (!this.isAgentDBAvailable()) {
|
|
280
|
+
throw new Error('AgentDB not available for optimization');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return this.agentdb.optimize();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Export data including vectors
|
|
288
|
+
* @param {string} namespace - Optional namespace filter
|
|
289
|
+
* @returns {Promise<Object>} Exported data with vectors
|
|
290
|
+
*/
|
|
291
|
+
async exportDataWithVectors(namespace = null) {
|
|
292
|
+
const legacyData = await this.exportData(namespace);
|
|
293
|
+
|
|
294
|
+
if (!this.isAgentDBAvailable()) {
|
|
295
|
+
return {
|
|
296
|
+
legacy: legacyData,
|
|
297
|
+
vectors: null,
|
|
298
|
+
agentdbAvailable: false,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
const vectorData = await this.agentdb.exportVectors(namespace);
|
|
304
|
+
return {
|
|
305
|
+
legacy: legacyData,
|
|
306
|
+
vectors: vectorData,
|
|
307
|
+
agentdbAvailable: true,
|
|
308
|
+
};
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error(
|
|
311
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] Vector export failed: ${error.message}`,
|
|
312
|
+
);
|
|
313
|
+
return {
|
|
314
|
+
legacy: legacyData,
|
|
315
|
+
vectors: null,
|
|
316
|
+
agentdbAvailable: true,
|
|
317
|
+
error: error.message,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Cleanup both legacy and AgentDB data
|
|
324
|
+
* @returns {Promise<Object>} Cleanup results
|
|
325
|
+
*/
|
|
326
|
+
async cleanupAll() {
|
|
327
|
+
const legacyCleanup = await this.cleanupExpired();
|
|
328
|
+
|
|
329
|
+
if (!this.isAgentDBAvailable()) {
|
|
330
|
+
return {
|
|
331
|
+
legacy: legacyCleanup,
|
|
332
|
+
agentdb: null,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
const agentdbCleanup = await this.agentdb.cleanup();
|
|
338
|
+
return {
|
|
339
|
+
legacy: legacyCleanup,
|
|
340
|
+
agentdb: agentdbCleanup,
|
|
341
|
+
};
|
|
342
|
+
} catch (error) {
|
|
343
|
+
console.error(
|
|
344
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] AgentDB cleanup failed: ${error.message}`,
|
|
345
|
+
);
|
|
346
|
+
return {
|
|
347
|
+
legacy: legacyCleanup,
|
|
348
|
+
agentdb: null,
|
|
349
|
+
error: error.message,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Close both legacy and AgentDB connections
|
|
356
|
+
* @returns {Promise<void>}
|
|
357
|
+
*/
|
|
358
|
+
async close() {
|
|
359
|
+
await super.close?.();
|
|
360
|
+
|
|
361
|
+
if (this.isAgentDBAvailable()) {
|
|
362
|
+
try {
|
|
363
|
+
await this.agentdb.close();
|
|
364
|
+
} catch (error) {
|
|
365
|
+
console.error(
|
|
366
|
+
`[${new Date().toISOString()}] WARN [agentdb-adapter] AgentDB close failed: ${error.message}`,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export default AgentDBMemoryAdapter;
|