import { existsSync } from 'node:fs';
import { join } from 'node:path';
const AI_TOOLS = [
    {
        id: 'claude',
        name: 'Claude Code',
        markers: ['.claude/', 'CLAUDE.md'],
        configPath: '.claude/',
        rulesPath: '.claude/rules/',
        rulesFormat: 'markdown',
        supportsSkills: true,
    },
    {
        id: 'cursor',
        name: 'Cursor',
        markers: ['.cursorrules', '.cursor/'],
        configPath: '.cursorrules',
        rulesPath: '.cursor/rules/',
        rulesFormat: 'markdown',
        supportsSkills: false,
    },
    {
        id: 'copilot',
        name: 'GitHub Copilot',
        markers: ['.github/copilot-instructions.md'],
        configPath: '.github/copilot-instructions.md',
        rulesPath: '.github/',
        rulesFormat: 'markdown',
        supportsSkills: false,
    },
    {
        id: 'windsurf',
        name: 'Windsurf',
        markers: ['.windsurfrules'],
        configPath: '.windsurfrules',
        rulesPath: '.',
        rulesFormat: 'markdown',
        supportsSkills: false,
    },
    {
        id: 'aider',
        name: 'Aider',
        markers: ['.aider.conf.yml', 'CONVENTIONS.md'],
        configPath: '.aider.conf.yml',
        rulesPath: '.',
        rulesFormat: 'markdown',
        supportsSkills: false,
    },
];
function hasAnyMarker(projectPath, markers) {
    for (const marker of markers) {
        const fullPath = join(projectPath, marker);
        if (existsSync(fullPath)) {
            return marker;
        }
    }
    return null;
}
/** Detect which AI tools are configured in a project by checking file/directory markers. */
export function detectAiTools(projectPath) {
    const detected = [];
    for (const tool of AI_TOOLS) {
        const foundMarker = hasAnyMarker(projectPath, tool.markers);
        if (foundMarker !== null) {
            detected.push({
                toolId: tool.id,
                name: tool.name,
                configPath: foundMarker,
                rulesFormat: tool.rulesFormat,
                rulesPath: tool.rulesPath,
                supportsSkills: tool.supportsSkills,
            });
        }
    }
    return detected;
}
/** Returns the primary tool (first detected, or claude as default). */
export function getPrimaryAiTool(projectPath) {
    const detected = detectAiTools(projectPath);
    const first = detected[0];
    if (first) {
        return first;
    }
    // Default to Claude Code when nothing is detected
    const claudeConfig = AI_TOOLS.find((t) => t.id === 'claude');
    return {
        toolId: claudeConfig?.id ?? 'claude',
        name: claudeConfig?.name ?? 'Claude Code',
        configPath: claudeConfig?.configPath ?? '.claude/',
        rulesFormat: claudeConfig?.rulesFormat ?? 'markdown',
        rulesPath: claudeConfig?.rulesPath ?? '.claude/rules/',
        supportsSkills: claudeConfig?.supportsSkills ?? true,
    };
}
//# sourceMappingURL=index.js.map