// Planu — Linting & Formatting tooling recommendations (SPEC-025)
// Barrel: merges core languages + extended languages, builds recommendation lines
import { LINTING_CORE } from './linting-catalog-core.js';
import { LINTING_EXTENDED } from './linting-catalog-extended.js';
const LINTING_BY_LANGUAGE = {
    ...LINTING_CORE,
    ...LINTING_EXTENDED,
};
/** Map raw language strings to registry keys */
function resolveLangKey(lang) {
    if (lang.includes('typescript') || lang.includes(' ts')) {
        return 'typescript';
    }
    if (lang.includes('python') || lang.includes('py')) {
        return 'python';
    }
    if (lang.includes('golang') || lang === 'go') {
        return 'go';
    }
    if (lang.includes('rust') || lang === 'rs') {
        return 'rust';
    }
    if (lang.includes('java') && !lang.includes('javascript')) {
        return 'java';
    }
    if (lang.includes('swift')) {
        return 'swift';
    }
    if (lang.includes('kotlin')) {
        return 'kotlin';
    }
    if (lang.includes('php')) {
        return 'php';
    }
    if (lang.includes('ruby') || lang === 'rb') {
        return 'ruby';
    }
    if (lang.includes('csharp') || lang.includes('c#') || lang.includes('.net')) {
        return 'csharp';
    }
    if (lang.includes('dart') || lang.includes('flutter')) {
        return 'dart';
    }
    if (lang.includes('elixir')) {
        return 'elixir';
    }
    if (lang.includes('scala')) {
        return 'scala';
    }
    if (lang.includes('c++') || lang.includes('cpp') || lang === 'c') {
        return 'c';
    }
    if (lang.includes('javascript') || lang === 'js') {
        return 'javascript';
    }
    return null;
}
export function buildLintingToolingLines(knowledge) {
    const lang = knowledge.language.toLowerCase();
    const langKey = resolveLangKey(lang);
    if (!langKey) {
        return [];
    }
    const block = LINTING_BY_LANGUAGE[langKey];
    if (!block) {
        return [];
    }
    const detectedToolNames = knowledge.linting.detectedLinters.map((l) => l.tool.toLowerCase());
    const detectedTools = new Set(detectedToolNames);
    const missingRecommended = block.recommended.filter((r) => !detectedTools.has(r.name.toLowerCase()));
    const missingTransversal = block.transversal.filter((r) => !detectedTools.has(r.name.toLowerCase()));
    if (missingRecommended.length === 0 && missingTransversal.length === 0) {
        return [];
    }
    const lines = [`## Linting & Formatting (${block.language})`, ''];
    if (missingRecommended.length > 0) {
        lines.push('### Recommended Linters');
        lines.push('');
        for (const tool of missingRecommended) {
            lines.push(`#### ${tool.name}`);
            lines.push(`**Purpose:** ${tool.purpose}`);
            lines.push(`**Install:** \`${tool.installCmd}\``);
            lines.push(`**Docs:** ${tool.docsUrl}`);
            lines.push('');
        }
    }
    if (missingTransversal.length > 0) {
        lines.push('### Transversal Linters (language-agnostic)');
        lines.push('');
        for (const tool of missingTransversal) {
            lines.push(`- **${tool.name}**: ${tool.purpose} — \`${tool.installCmd}\``);
        }
        lines.push('');
    }
    return lines;
}
//# sourceMappingURL=linting-catalog.js.map