import { getDetectedTools } from './detector.js';
import { writeCursorRules } from './cursor/cursorrules-generator.js';
import { writeWindsurfRules } from './windsurf/windsurfrules-generator.js';
import { writeAiderConfig } from './aider/aider-config-generator.js';
function generateForCursor(options) {
    writeCursorRules(options.projectPath, {
        projectName: options.projectName,
        stack: options.stack,
        activeSpecId: options.activeSpecId,
        approvedSpecs: options.approvedSpecs,
        architectureStyle: options.architectureStyle,
    });
    return {
        tool: 'cursor',
        filesGenerated: ['.cursorrules'],
        skipped: false,
    };
}
function generateForWindsurf(options) {
    writeWindsurfRules(options.projectPath, {
        projectName: options.projectName,
        stack: options.stack,
        activeSpecId: options.activeSpecId,
        approvedSpecs: options.approvedSpecs,
        architectureStyle: options.architectureStyle,
    });
    return {
        tool: 'windsurf',
        filesGenerated: ['.windsurfrules'],
        skipped: false,
    };
}
function generateForAider(options) {
    writeAiderConfig(options.projectPath, {});
    return {
        tool: 'aider',
        filesGenerated: ['.aider.conf.yml'],
        skipped: false,
    };
}
function skipTool(tool, reason) {
    return { tool, filesGenerated: [], skipped: true, reason };
}
const GENERATORS = {
    cursor: generateForCursor,
    windsurf: generateForWindsurf,
    aider: generateForAider,
};
const SKIPPED_TOOLS = {
    'claude-code': 'Already managed by SPEC-263/265',
    'codex-cli': 'Managed by SPEC-266 (codex worktree)',
    'gemini-cli': 'Managed by SPEC-267 (gemini worktree)',
    'github-copilot': 'No Planu config integration yet',
    'continue-dev': 'No Planu config integration yet',
};
export function generateConfigsForDetectedTools(options) {
    const tools = options.detectedTools ?? getDetectedTools(options.projectPath);
    const results = [];
    for (const tool of tools) {
        const skipReason = SKIPPED_TOOLS[tool];
        if (skipReason !== undefined) {
            results.push(skipTool(tool, skipReason));
            continue;
        }
        const generator = GENERATORS[tool];
        if (generator === undefined) {
            /* v8 ignore start */
            results.push(skipTool(tool, 'No generator available'));
            continue;
            /* v8 ignore stop */
        }
        try {
            results.push(generator(options));
        }
        catch (err) {
            const message = err instanceof Error ? err.message : String(err);
            results.push({
                tool,
                filesGenerated: [],
                skipped: false,
                reason: `Error: ${message}`,
            });
        }
    }
    return results;
}
//# sourceMappingURL=universal-config-generator.js.map