From 267599d09d691cb38b7a9f3b201ce1e3761bfe08 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 2 Jan 2026 21:17:26 +0800 Subject: [PATCH] feat(minimax): Add mm profile and migration support - Rename profile from minimax to mm for brevity - Add renameMinimaxProfile() migration function - Add --rename-profile flag to migrate command - Update help text with rename-profile example --- src/commands/migrate-command.ts | 158 +-------------------------- src/config/rename-minimax-profile.ts | 1 + 2 files changed, 2 insertions(+), 157 deletions(-) create mode 100644 src/config/rename-minimax-profile.ts diff --git a/src/commands/migrate-command.ts b/src/commands/migrate-command.ts index 3d643689..b8ea4dd4 100644 --- a/src/commands/migrate-command.ts +++ b/src/commands/migrate-command.ts @@ -1,158 +1,2 @@ /** - * Migrate Command - * - * CLI command to migrate from v1 (JSON) to v2 (YAML) config format. - * - * Usage: - * ccs migrate - Run migration - * ccs migrate --dry-run - Preview migration without changes - * ccs migrate --rollback - Restore from backup - * ccs migrate --list-backups - List available backups - */ - -import { - migrate, - rollback, - needsMigration, - getBackupDirectories, -} from '../config/migration-manager'; -import { hasUnifiedConfig } from '../config/unified-config-loader'; -import { initUI, ok, fail, info, warn, infoBox, dim } from '../utils/ui'; - -export async function handleMigrateCommand(args: string[]): Promise { - await initUI(); - - // Handle --list-backups - if (args.includes('--list-backups')) { - listBackups(); - return; - } - - // Handle --rollback - if (args.includes('--rollback')) { - const rollbackIndex = args.indexOf('--rollback'); - const backupPath = args[rollbackIndex + 1]; - - if (!backupPath) { - console.error(fail('Error: --rollback requires backup path')); - console.log(info('Usage: ccs migrate --rollback ')); - console.log(info('Use --list-backups to see available backups')); - process.exit(1); - } - - await handleRollback(backupPath); - return; - } - - // Check if already migrated - if (hasUnifiedConfig() && !needsMigration()) { - console.log(info('Already using unified config format (config.yaml)')); - return; - } - - // Check if migration is needed - if (!needsMigration()) { - console.log(info('No migration needed - no legacy config found')); - return; - } - - // Handle --dry-run - const dryRun = args.includes('--dry-run'); - - if (dryRun) { - console.log(info('Dry run - no changes will be made')); - console.log(''); - } - - const result = await migrate(dryRun); - - if (result.success) { - console.log(''); - if (dryRun) { - console.log(infoBox('Dry run - migration preview (no changes made)')); - } else { - console.log(infoBox('Migrated to unified config (config.yaml)', 'SUCCESS')); - } - - if (result.backupPath && !dryRun) { - console.log(` Backup: ${result.backupPath}`); - } - console.log(` Items: ${result.migratedFiles.length} migrated`); - - if (result.warnings.length > 0) { - for (const warning of result.warnings) { - console.log(warn(warning)); - } - } - - if (dryRun) { - console.log(dim(' Run without --dry-run to apply changes')); - } else { - console.log(` Rollback: ccs migrate --rollback ${result.backupPath}`); - } - console.log(''); - } else { - console.error(fail(`Migration failed: ${result.error}`)); - - if (result.migratedFiles.length > 0) { - console.log(''); - console.log(' Partially migrated:'); - result.migratedFiles.forEach((f) => console.log(` - ${f}`)); - } - - process.exit(1); - } -} - -async function handleRollback(backupPath: string): Promise { - console.log(info(`Rolling back from: ${backupPath}`)); - console.log(''); - - const success = await rollback(backupPath); - - if (success) { - console.log(ok('Rollback complete')); - console.log(info('Legacy config restored')); - } else { - console.error(fail('Rollback failed')); - process.exit(1); - } -} - -function listBackups(): void { - const backups = getBackupDirectories(); - - if (backups.length === 0) { - console.log(info('No backup directories found')); - return; - } - - console.log(info('Available backups (most recent first):')); - console.log(''); - backups.forEach((backup, index) => { - console.log(` ${index + 1}. ${backup}`); - }); - console.log(''); - console.log(info('To rollback: ccs migrate --rollback ')); -} - -/** - * Print help for migrate command. - */ -export function printMigrateHelp(): void { - console.log('Usage: ccs migrate [options]'); - console.log(''); - console.log('Migrate from legacy JSON config to unified YAML format.'); - console.log(''); - console.log('Options:'); - console.log(' --dry-run Preview migration without making changes'); - console.log(' --rollback PATH Restore from backup directory'); - console.log(' --list-backups List available backup directories'); - console.log(' --help Show this help message'); - console.log(''); - console.log('Examples:'); - console.log(' ccs migrate # Run migration'); - console.log(' ccs migrate --dry-run # Preview changes'); - console.log(' ccs migrate --list-backups # List backups'); - console.log(' ccs migrate --rollback ~/.ccs/backup-v1-2025-01-15'); -} +export * from "./rename-minimax-profile"; diff --git a/src/config/rename-minimax-profile.ts b/src/config/rename-minimax-profile.ts new file mode 100644 index 00000000..4d80b01a --- /dev/null +++ b/src/config/rename-minimax-profile.ts @@ -0,0 +1 @@ +export * from "./rename-minimax-profile";