/**
 * Score the 4-layer scan result and produce a gap assessment.
 */
export function scoreGap(result) {
    const fileScore = Math.min(25, result.files.length * 12);
    const symbolScore = Math.min(35, result.symbols.length * 10);
    const testScore = Math.min(25, result.tests.length * 12);
    const regScore = Math.min(15, result.registrations.length * 8);
    const total = fileScore + symbolScore + testScore + regScore;
    const status = resolveStatus(total);
    const warning = buildWarning(status, result);
    return {
        score: total,
        status,
        layerScores: {
            files: fileScore,
            symbols: symbolScore,
            tests: testScore,
            registrations: regScore,
        },
        warning,
    };
}
function resolveStatus(score) {
    if (score >= 75) {
        return 'complete';
    }
    if (score >= 40) {
        return 'partial';
    }
    if (score >= 10) {
        return 'minimal';
    }
    return 'not_found';
}
function buildWarning(status, result) {
    if (status === 'not_found') {
        return null;
    }
    const lines = [];
    if (status === 'complete') {
        lines.push('⚠️  **Implementación detectada en el código** — verifica si esta spec ya está done antes de reimplementar.');
    }
    else if (status === 'partial') {
        lines.push('⚠️  **Implementación parcial detectada** — puede haber gaps. Revisa antes de continuar.');
    }
    else {
        lines.push('ℹ️  **Evidencia mínima en código** — posiblemente en etapas tempranas.');
    }
    if (result.files.length > 0) {
        lines.push(`\n**Archivos encontrados**: ${result.files.slice(0, 5).join(', ')}`);
    }
    if (result.symbols.length > 0) {
        lines.push(`**Símbolos exportados**: ${result.symbols.slice(0, 5).join(', ')}`);
    }
    if (result.tests.length > 0) {
        lines.push(`**Tests encontrados**: ${result.tests.slice(0, 3).join(', ')}`);
    }
    if (result.registrations.length > 0) {
        lines.push(`**Registros**: ${result.registrations.slice(0, 3).join(', ')}`);
    }
    const gaps = [];
    if (result.files.length === 0) {
        gaps.push('archivos');
    }
    if (result.symbols.length === 0) {
        gaps.push('lógica exportada');
    }
    if (result.tests.length === 0) {
        gaps.push('tests');
    }
    if (result.registrations.length === 0) {
        gaps.push('registro/wiring');
    }
    if (gaps.length > 0 && status !== 'complete') {
        lines.push(`\n**Gaps detectados**: ${gaps.join(', ')}`);
    }
    return lines.join('\n');
}
//# sourceMappingURL=gap-scorer.js.map