claude-flow 2.7.0-alpha.1 → 2.7.0-alpha.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.
- package/bin/claude-flow +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/simple-commands/init/index.js +45 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +31 -4
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/memory/swarm-memory.js +416 -348
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/reasoningbank/reasoningbank-adapter.js +59 -0
- package/dist/src/reasoningbank/reasoningbank-adapter.js.map +1 -1
- package/dist/src/utils/key-redactor.js.map +1 -1
- package/dist/src/utils/metrics-reader.js +29 -41
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/simple-commands/init/index.js +70 -0
- package/src/cli/simple-commands/memory.js +42 -4
- package/src/reasoningbank/reasoningbank-adapter.js +82 -0
|
@@ -423,17 +423,55 @@ async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
|
423
423
|
const initialized = await isReasoningBankInitialized();
|
|
424
424
|
|
|
425
425
|
// Lazy load the adapter (ES modules)
|
|
426
|
-
const { initializeReasoningBank, storeMemory, queryMemories, listMemories, getStatus } = await import('../../reasoningbank/reasoningbank-adapter.js');
|
|
426
|
+
const { initializeReasoningBank, storeMemory, queryMemories, listMemories, getStatus, checkReasoningBankTables, migrateReasoningBank } = await import('../../reasoningbank/reasoningbank-adapter.js');
|
|
427
427
|
|
|
428
428
|
// Special handling for 'init' command
|
|
429
429
|
if (command === 'init') {
|
|
430
|
+
const dbPath = '.swarm/memory.db';
|
|
431
|
+
|
|
430
432
|
if (initialized) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
433
|
+
// Database exists - check if migration is needed
|
|
434
|
+
printInfo('🔍 Checking existing database for ReasoningBank schema...\n');
|
|
435
|
+
|
|
436
|
+
try {
|
|
437
|
+
// Set the database path for ReasoningBank
|
|
438
|
+
process.env.CLAUDE_FLOW_DB_PATH = dbPath;
|
|
439
|
+
|
|
440
|
+
const tableCheck = await checkReasoningBankTables();
|
|
441
|
+
|
|
442
|
+
if (tableCheck.exists) {
|
|
443
|
+
printSuccess('✅ ReasoningBank already complete');
|
|
444
|
+
console.log('Database: .swarm/memory.db');
|
|
445
|
+
console.log('All ReasoningBank tables present\n');
|
|
446
|
+
console.log('Use --reasoningbank flag with memory commands to enable AI features');
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Missing tables found - run migration
|
|
451
|
+
console.log(`🔄 Migrating database: ${tableCheck.missingTables.length} tables missing`);
|
|
452
|
+
console.log(` Missing: ${tableCheck.missingTables.join(', ')}\n`);
|
|
453
|
+
|
|
454
|
+
const migrationResult = await migrateReasoningBank();
|
|
455
|
+
|
|
456
|
+
if (migrationResult.success) {
|
|
457
|
+
printSuccess(`✓ Migration complete: added ${migrationResult.addedTables?.length || 0} tables`);
|
|
458
|
+
console.log('\nNext steps:');
|
|
459
|
+
console.log(' 1. Store memories: memory store key "value" --reasoningbank');
|
|
460
|
+
console.log(' 2. Query memories: memory query "search" --reasoningbank');
|
|
461
|
+
console.log(' 3. Check status: memory status --reasoningbank');
|
|
462
|
+
} else {
|
|
463
|
+
printError(`❌ Migration failed: ${migrationResult.message}`);
|
|
464
|
+
console.log('Try running: init --force to reinitialize');
|
|
465
|
+
}
|
|
466
|
+
} catch (error) {
|
|
467
|
+
printError('❌ Migration check failed');
|
|
468
|
+
console.error(error.message);
|
|
469
|
+
console.log('\nTry running: init --force to reinitialize');
|
|
470
|
+
}
|
|
434
471
|
return;
|
|
435
472
|
}
|
|
436
473
|
|
|
474
|
+
// Fresh initialization
|
|
437
475
|
printInfo('🧠 Initializing ReasoningBank...');
|
|
438
476
|
console.log('This will create: .swarm/memory.db\n');
|
|
439
477
|
|
|
@@ -189,3 +189,85 @@ export async function getStatus() {
|
|
|
189
189
|
total_trajectories: trajectoryCount.count || 0,
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Check which ReasoningBank tables are present in the database
|
|
195
|
+
* Returns object with table names and their existence status
|
|
196
|
+
*/
|
|
197
|
+
export async function checkReasoningBankTables() {
|
|
198
|
+
try {
|
|
199
|
+
const dbInstance = db.getDb();
|
|
200
|
+
|
|
201
|
+
// Required ReasoningBank tables
|
|
202
|
+
const requiredTables = [
|
|
203
|
+
'patterns',
|
|
204
|
+
'pattern_embeddings',
|
|
205
|
+
'pattern_links',
|
|
206
|
+
'task_trajectories',
|
|
207
|
+
'matts_runs',
|
|
208
|
+
'consolidation_runs',
|
|
209
|
+
'metrics_log'
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
// Query existing tables
|
|
213
|
+
const existingTables = dbInstance.prepare(`
|
|
214
|
+
SELECT name FROM sqlite_master
|
|
215
|
+
WHERE type='table'
|
|
216
|
+
`).all().map(row => row.name);
|
|
217
|
+
|
|
218
|
+
// Check which required tables are missing
|
|
219
|
+
const missingTables = requiredTables.filter(table => !existingTables.includes(table));
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
exists: missingTables.length === 0,
|
|
223
|
+
existingTables,
|
|
224
|
+
missingTables,
|
|
225
|
+
requiredTables
|
|
226
|
+
};
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return {
|
|
229
|
+
exists: false,
|
|
230
|
+
existingTables: [],
|
|
231
|
+
missingTables: [],
|
|
232
|
+
requiredTables: [],
|
|
233
|
+
error: error.message
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Migrate existing database to add missing ReasoningBank tables
|
|
240
|
+
*/
|
|
241
|
+
export async function migrateReasoningBank() {
|
|
242
|
+
try {
|
|
243
|
+
// Check current state
|
|
244
|
+
const tableCheck = await checkReasoningBankTables();
|
|
245
|
+
|
|
246
|
+
if (tableCheck.exists) {
|
|
247
|
+
return {
|
|
248
|
+
success: true,
|
|
249
|
+
message: 'All ReasoningBank tables already exist',
|
|
250
|
+
migrated: false
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Run full initialization which will create missing tables
|
|
255
|
+
await initializeReasoningBank();
|
|
256
|
+
|
|
257
|
+
// Verify migration
|
|
258
|
+
const afterCheck = await checkReasoningBankTables();
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
success: afterCheck.exists,
|
|
262
|
+
message: `Migration completed: ${tableCheck.missingTables.length} tables added`,
|
|
263
|
+
migrated: true,
|
|
264
|
+
addedTables: tableCheck.missingTables
|
|
265
|
+
};
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return {
|
|
268
|
+
success: false,
|
|
269
|
+
message: `Migration failed: ${error.message}`,
|
|
270
|
+
error: error.message
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|