export function detectarContextoProjeto(opcoes) {
    const { arquivo, conteudo, relPath, packageJson } = opcoes;
    const caminho = arquivo.replace(/\\/g, '/').toLowerCase();
    const rel = (relPath || arquivo).replace(/\\/g, '/').toLowerCase();
    const contexto = {
        isBot: false,
        isCLI: false,
        isWebApp: false,
        isLibrary: false,
        isTest: false,
        isConfiguracao: false,
        isInfrastructure: false,
        frameworks: [],
        linguagens: []
    };
    if (/\.(ts|tsx)$/.test(caminho))
        contexto.linguagens.push('typescript');
    if (/\.(js|jsx)$/.test(caminho))
        contexto.linguagens.push('javascript');
    if (/\.(py)$/.test(caminho))
        contexto.linguagens.push('python');
    if (/\.(php)$/.test(caminho))
        contexto.linguagens.push('php');
    if (/\.(html|htm)$/.test(caminho))
        contexto.linguagens.push('html');
    if (/\.(css)$/.test(caminho))
        contexto.linguagens.push('css');
    const isTestPath = /(^|\/)tests?(\/|\.)/i.test(rel) || /\.(test|spec)\.(ts|js|tsx|jsx)$/i.test(caminho) || /__tests__/.test(rel);
    const belongsToTestExt = /\.(ts|js|tsx|jsx)$/i.test(caminho);
    const hasTestContent = belongsToTestExt && (/^(describe|it|test|expect)\s*\(/m.test(conteudo) || /\.(it|test|describe|expect)\s*\(/m.test(conteudo));
    contexto.isTest = isTestPath || hasTestContent;
    if (contexto.isTest) {
        return {
            ...contexto,
            isBot: false,
            isCLI: false,
            isWebApp: false,
            isLibrary: false
        };
    }
    contexto.isConfiguracao = /config|\.config\.|\.rc\.|\.json$|\.yaml$|\.yml$|\.env/.test(caminho) || /(^|\/)(\.|config|configs?)(\/|\.)/i.test(rel) || /package\.json|tsconfig|eslint|prettier|vitest|jest|babel/.test(caminho) || /stub|mock|fixture|example/i.test(caminho);
    contexto.isInfrastructure = /index\.|main\.|app\.|server\.|setup\.|bootstrap/.test(caminho) || /(client\.login|client\.connect|createApp|express\(\)|listen\(|server\.start)/.test(conteudo) || /export\s+default|module\.exports\s*=/.test(conteudo) || /(guardian|sentinela|verificador|hash|diff|baseline)/i.test(caminho) ||
        /(monitor|watch|observer|scanner)/i.test(caminho);
    const importMatches = conteudo.match(/import.*from.*['"`]([^'"`]+)['"`]|require\(['"`]([^'"`]+)['"`]\)/g) || [];
    const allImports = importMatches.join(' ').toLowerCase();
    if (/discord\.js|@discordjs|eris/.test(allImports)) {
        contexto.frameworks.push('discord.js');
        contexto.isBot = true;
    }
    if (/telegraf|grammy|node-telegram-bot/.test(allImports)) {
        contexto.frameworks.push('telegraf');
        contexto.isBot = true;
    }
    if (/commander|yargs|inquirer|chalk|ora/.test(allImports)) {
        contexto.frameworks.push('cli');
        contexto.isCLI = true;
    }
    if (/oclif/.test(allImports)) {
        contexto.frameworks.push('oclif');
        contexto.isCLI = true;
    }
    if (/express|fastify|koa|hapi/.test(allImports)) {
        contexto.frameworks.push('backend');
        contexto.isWebApp = true;
    }
    if (/react|vue|angular|svelte/.test(allImports)) {
        contexto.frameworks.push('frontend');
        contexto.isWebApp = true;
    }
    if (/next|nuxt|gatsby|remix/.test(allImports)) {
        contexto.frameworks.push('fullstack');
        contexto.isWebApp = true;
    }
    if (!contexto.isBot && /slash.*command|interaction\.|commandName|client\.on.*message/i.test(conteudo)) {
        contexto.isBot = true;
    }
    if (!contexto.isCLI && /process\.argv|command.*line|\.option\(|\.command\(/i.test(conteudo)) {
        contexto.isCLI = true;
    }
    if (/export\s+(interface|type|class.*\{)/i.test(conteudo) || /import.*types?.*from|export.*types?/i.test(conteudo) || /function\s+format|function\s+display|function\s+render/i.test(conteudo) || /console\.log|logger\.|\.write\(|\.render\(/i.test(conteudo)) {
        contexto.isInfrastructure = true;
    }
    if (/export\s+(class|function|const|interface|type)|module\.exports/.test(conteudo) && !contexto.isWebApp && !contexto.isBot && !contexto.isCLI) {
        contexto.isLibrary = true;
    }
    if (/(^|\/)bot(\/|\.|-)|discord|telegram/.test(rel)) {
        contexto.isBot = true;
    }
    if (/(^|\/)(cli|commands?|comandos?)(\/|\.|-)|bin\//.test(rel)) {
        if (!/\/(processing|display|options|utils|helpers|types|interfaces)\//.test(rel) && !/\/(options|display|processing|filter|helper|util|type)\./.test(rel) && !/(options|processing|display|filter|helper|util|types?)[-.]/.test(caminho)) {
            contexto.isCLI = true;
        }
    }
    if (/(^|\/)src\/(pages|app|routes|components|views)/.test(rel)) {
        contexto.isWebApp = true;
    }
    if (packageJson) {
        detectarFrameworksPackageJson(packageJson, contexto);
    }
    contexto.frameworks = [...new Set(contexto.frameworks)];
    contexto.linguagens = [...new Set(contexto.linguagens)];
    return contexto;
}
function detectarFrameworksPackageJson(packageJson, contexto) {
    const deps = {
        ...(packageJson?.dependencies ?? {}),
        ...(packageJson?.devDependencies ?? {})
    };
    for (const dep of Object.keys(deps)) {
        if (/discord\.js|eris|@discordjs/.test(dep)) {
            contexto.isBot = true;
            contexto.frameworks.push('discord.js');
        }
        if (/telegraf|grammy/.test(dep)) {
            contexto.isBot = true;
            contexto.frameworks.push('telegraf');
        }
        if (/commander|yargs|oclif/.test(dep)) {
            contexto.isCLI = true;
            contexto.frameworks.push('cli');
        }
        if (/express|fastify|react|vue|next/.test(dep)) {
            contexto.isWebApp = true;
        }
    }
}
export function isRelevanteParaAnalise(contexto, tipoAnalise) {
    if (contexto.isTest || contexto.isConfiguracao || contexto.isInfrastructure)
        return false;
    switch (tipoAnalise) {
        case 'comando':
        case 'bot':
            return (contexto.isBot || contexto.isCLI) && !contexto.isInfrastructure;
        case 'cli':
            return contexto.isCLI && !contexto.isInfrastructure;
        case 'web':
            return contexto.isWebApp;
        case 'biblioteca':
            return contexto.isLibrary;
        default:
            return true;
    }
}
export function sugerirFrameworks(contexto) {
    const sugestoes = [];
    if (contexto.isBot && !contexto.frameworks.some((arquivo) => arquivo.includes('discord') || arquivo.includes('telegraf'))) {
        sugestoes.push('Considere usar discord.js ou telegraf para bots');
    }
    if (contexto.isCLI && !contexto.frameworks.some((arquivo) => arquivo.includes('cli') || arquivo.includes('commander'))) {
        sugestoes.push('Considere usar commander.js ou yargs para CLI');
    }
    return sugestoes;
}
export function isContextoDocumentacao(relPath) {
    const arquivosDoc = ['readme', 'doc/', 'docs/', '.md', '.example', '.sample', '.template', 'third-party-notices', 'license', 'changelog'];
    const pathLower = relPath.toLowerCase();
    return arquivosDoc.some(pattern => pathLower.includes(pattern));
}
//# sourceMappingURL=context-project.js.map