// tools/migrate-tech/detect-pending-handler.ts — SPEC-054 S4
// Exposes detectPendingMajorMigrations as a migrate_tech action.
import { detectPendingMajorMigrations, generateMigrationPlan, } from '../../engine/dynamic-migration-detector.js';
import { loadBuiltinCatalog } from '../../engine/dynamic-migration-detector/catalog-loader.js';
export async function handleDetectPending(args) {
    const projectPath = args.projectPath ?? process.cwd();
    const result = await detectPendingMajorMigrations(projectPath);
    const catalog = loadBuiltinCatalog();
    const criticalPlans = result.pending
        .filter((p) => p.risk === 'critical' || p.risk === 'high')
        .slice(0, 5)
        .map((p) => generateMigrationPlan(p, catalog));
    const warnings = [];
    if (result.criticalCount > 0) {
        warnings.push(`${String(result.criticalCount)} critical migration(s) require immediate attention.`);
    }
    if (result.totalPending > 10) {
        warnings.push(`Large migration backlog (${String(result.totalPending)} items). Consider batching by ecosystem.`);
    }
    return {
        action: 'detect-pending',
        message: result.summary,
        warnings,
        savedTo: undefined,
        data: {
            ...result,
            topPriorityPlans: criticalPlans,
        },
    };
}
//# sourceMappingURL=detect-pending-handler.js.map