// tools/migrate-tech/core-handlers.ts — Handlers: analyze | map | plan | strategy | validate
import { t } from '../../i18n/index.js';
import { buildStackAnalysis, buildEquivalenceMap, generateMigrationPlan, recommendMigrationStrategy, generateParityValidation, } from '../../engine/migration/index.js';
export function handleAnalyze(args) {
    const data = buildStackAnalysis({
        language: args.sourceStack ?? 'unknown',
        framework: args.sourceStack ?? 'unknown',
        components: [],
        entryPoints: [],
        externalIntegrations: [],
        migratableComponents: [],
        hasTests: false,
    });
    const warnings = [
        ...data.riskFlags,
        'No project-derived migration inventory was provided; analysis does not fabricate components or entry points.',
    ];
    return {
        action: 'analyze',
        data,
        message: t('tools.migrate_tech.analyzeSuccess'),
        warnings,
        savedTo: args.projectId ? `data/projects/${args.projectId}/migration-analysis.json` : undefined,
    };
}
export function handleMap(args) {
    const source = args.sourceStack ?? 'unknown';
    const target = args.targetStack ?? 'unknown';
    const data = buildEquivalenceMap(source, target);
    const warnings = data.unsupportedPairs.length > 0
        ? [`${data.unsupportedPairs.length} equivalence(s) require manual mapping`]
        : [];
    return {
        action: 'map',
        data,
        message: t('tools.migrate_tech.mapSuccess'),
        warnings,
        savedTo: args.projectId ? `data/projects/${args.projectId}/migration-map.json` : undefined,
    };
}
export function handlePlan(args) {
    const data = generateMigrationPlan({
        sourceStack: args.sourceStack ?? 'unknown',
        targetStack: args.targetStack ?? 'unknown',
        components: [],
        hasTests: false,
    });
    const warnings = [
        'No project-derived migration components were provided; plan does not fabricate modules.',
    ];
    if (data.circularDependencies.length > 0) {
        warnings.push(`${data.circularDependencies.length} circular dependency cycles detected — resolve before migrating`);
    }
    return {
        action: 'plan',
        data,
        message: t('tools.migrate_tech.planSuccess'),
        warnings,
    };
}
export function handleStrategy(_args) {
    const data = recommendMigrationStrategy({
        componentCount: 0,
        hasActiveUsers: false,
        hasHighSla: false,
        hasCriticalData: false,
        migratableComponents: [],
        entryPoints: [],
    });
    return {
        action: 'strategy',
        data,
        message: t('tools.migrate_tech.strategySuccess'),
        warnings: [
            'No project-derived strategy inputs were provided; recommendation uses neutral empty evidence.',
        ],
    };
}
export function handleValidate(args) {
    const component = args.component?.trim() ?? '';
    const data = generateParityValidation({
        component,
        endpoints: [],
        observedDifferences: [],
    });
    return {
        action: 'validate',
        data,
        message: t('tools.migrate_tech.validateSuccess'),
        warnings: args.component === undefined
            ? [
                'No component was provided; validation checklist is unscoped and no contract tests were generated.',
            ]
            : ['No endpoints were provided; contract tests were not generated.'],
    };
}
//# sourceMappingURL=core-handlers.js.map