// llm-detector/eu-ai-detector.ts — EU AI Act risk level detection
import { join } from 'node:path';
import { EU_AI_DOMAIN_KEYWORDS, EU_AI_UNACCEPTABLE_KEYWORDS } from './provider-maps.js';
import { readFileOrNull } from './file-readers.js';
/** Detect EU AI Act risk level from project context */
export async function detectEuAiActRisk(projectPath) {
    const readmeContent = await (async () => {
        const readme = await readFileOrNull(join(projectPath, 'README.md'));
        const pkg = await readFileOrNull(join(projectPath, 'package.json'));
        return `${readme ?? ''} ${pkg ?? ''}`.toLowerCase();
    })();
    const detectedDomains = [];
    // Check unacceptable risk first
    if (EU_AI_UNACCEPTABLE_KEYWORDS.some((kw) => readmeContent.includes(kw))) {
        return { risk: 'unacceptable', domains: ['unacceptable-use'] };
    }
    // Check high-risk domains
    for (const [domain, keywords] of Object.entries(EU_AI_DOMAIN_KEYWORDS)) {
        if (keywords.some((kw) => readmeContent.includes(kw))) {
            detectedDomains.push(domain);
        }
    }
    if (detectedDomains.length > 0) {
        return { risk: 'high-risk', domains: detectedDomains };
    }
    // Check if it's a chatbot/assistant
    if (readmeContent.includes('chatbot') ||
        readmeContent.includes('assistant') ||
        readmeContent.includes('chat interface')) {
        return { risk: 'limited-risk', domains: [] };
    }
    return { risk: 'minimal-risk', domains: [] };
}
//# sourceMappingURL=eu-ai-detector.js.map