migrate-storage.tsโข2.31 kB
#!/usr/bin/env ts-node
/**
* CLI tool to migrate Memory objects to TodoLists
* Part of the storage architecture simplification
*/
import { Storage } from '../src/core/storage.js';
import { migrateMemoriesToTodoLists } from '../src/utils/migrate-memories.js';
async function main() {
const args = process.argv.slice(2);
const dryRun = !args.includes('--execute');
console.log('='.repeat(60));
console.log('๐ฆ COA Goldfish MCP - Storage Migration Tool');
console.log('='.repeat(60));
console.log(`Mode: ${dryRun ? '๐ DRY RUN (preview only)' : 'โก EXECUTE (will make changes)'}`);
console.log();
const storage = new Storage();
console.log(`๐ Base path: ${storage.getBasePath()}`);
console.log();
try {
console.log('๐ Starting migration...');
const result = await migrateMemoriesToTodoLists(storage, dryRun);
// Display results
console.log();
console.log('๐ MIGRATION RESULTS');
console.log('='.repeat(40));
console.log(`Status: ${result.success ? 'โ
SUCCESS' : 'โ FAILED'}`);
console.log(`Migrated: ${result.migratedCount} items`);
console.log(`Skipped: ${result.skippedCount} items`);
console.log(`Errors: ${result.errors.length}`);
console.log();
if (result.details.length > 0) {
console.log('๐ DETAILS');
console.log('-'.repeat(40));
result.details.forEach(detail => console.log(detail));
console.log();
}
if (result.errors.length > 0) {
console.log('โ ERRORS');
console.log('-'.repeat(40));
result.errors.forEach(error => console.error(error));
console.log();
}
if (dryRun && result.migratedCount > 0) {
console.log('๐ก To execute the migration, run:');
console.log(' npm run migrate:storage -- --execute');
console.log();
}
if (!dryRun && result.success) {
console.log('๐ Migration completed successfully!');
console.log('๐ Note: Original Memory files are preserved for safety.');
console.log(' Run Phase 3.2 cleanup when ready to remove them.');
console.log();
}
} catch (error) {
console.error('๐ฅ Migration failed with error:', error);
process.exit(1);
}
}
main().catch(error => {
console.error('๐ฅ Unexpected error:', error);
process.exit(1);
});