start method

WizardConfig start()

Presents the interactive prompts and returns the resolved WizardConfig.

Implementation

WizardConfig start() {
  _printBanner();

  final targetPath = _prompt(
    'πŸ“‚ Enter the target path to migrate',
    defaultValue: 'lib',
  );

  final detectedLibs = _detectLibraries(targetPath);
  if (detectedLibs.isNotEmpty) {
    print('\n\x1B[33mπŸ” Detected state management libraries:\x1B[0m');
    for (final lib in detectedLibs) {
      print('   β€’ $lib');
    }
    final proceed = _promptYesNo(
      '\nProceed with migrating these to Riverpod?',
      defaultYes: true,
    );
    if (!proceed) {
      print('\x1B[31mMigration cancelled.\x1B[0m');
      exit(0);
    }
  } else {
    print(
      '\n\x1B[90m  (No known state management libraries detected in pubspec.yaml)\x1B[0m',
    );
  }

  print('\n\x1B[1mWhich migration mode would you like to use?\x1B[0m');
  print(
    '  \x1B[36m1.\x1B[0m safe       – Analyze only, inject TODO comments',
  );
  print(
    '  \x1B[36m2.\x1B[0m assisted   – Generate Riverpod files alongside old code',
  );
  print(
    '  \x1B[36m3.\x1B[0m aggressive – Fully rewrite and replace legacy code',
  );
  final modeChoice = _prompt('Select mode (1–3)', defaultValue: '3');
  final mode = _mapMode(modeChoice);

  print('');
  final dryRun = _promptYesNo(
    'πŸ‘οΈ  Preview changes without writing files (dry run)?',
  );
  final cleanImports = _promptYesNo(
    '🧹 Auto-clean unused Provider imports after migration?',
    defaultYes: true,
  );
  final generateReport = _promptYesNo(
    'πŸ“Š Generate a migration_report.json audit file?',
    defaultYes: true,
  );
  final visualize = _promptYesNo(
    'πŸ—ΊοΈ  Generate a provider dependency graph (Mermaid format)?',
  );
  final useAi = _promptYesNo(
    'πŸ€– Enable AI-assisted logic refactoring (requires local LLM)?',
  );

  final config = WizardConfig(
    targetPath: targetPath,
    mode: mode,
    useAi: useAi,
    dryRun: dryRun,
    cleanImports: cleanImports,
    generateReport: generateReport,
    visualize: visualize,
  );

  _saveConfig(config);
  return config;
}