// Formatting functions for platform-specific rules output
export function formatRulesForPlatform(platform, config, sections) {
    switch (config.format) {
        case 'markdown':
            return formatAsMarkdown(platform, sections);
        case 'json':
            return formatAsJson(sections);
        case 'yaml':
            return formatAsYaml(sections);
        case 'toml':
            return formatAsMarkdown(platform, sections);
        /* v8 ignore next 2 */
        default:
            return formatAsMarkdown(platform, sections);
    }
}
export function formatAsMarkdown(platform, sections) {
    const lines = [];
    lines.push(`# ${getPlatformTitle(platform)} Rules`);
    lines.push('');
    lines.push('> Auto-generated by Planu SDD MCP Server');
    lines.push('');
    for (const section of sections) {
        lines.push(`## ${section.title}`);
        lines.push('');
        for (const { rule, enforcement } of section.rules) {
            const prefix = enforcement === 'strict' ? '- **[STRICT]**' : '-';
            lines.push(`${prefix} ${rule}`);
        }
        lines.push('');
    }
    return lines.join('\n');
}
export function formatAsJson(sections) {
    const obj = {};
    for (const section of sections) {
        obj[section.title.toLowerCase().replace(/\s+/g, '_')] = section.rules.map((r) => ({
            rule: r.rule,
            enforcement: r.enforcement,
        }));
    }
    return JSON.stringify(obj, null, 2);
}
export function formatAsYaml(sections) {
    const lines = [];
    lines.push('# Auto-generated by Planu SDD MCP Server');
    lines.push('');
    for (const section of sections) {
        const key = section.title.toLowerCase().replace(/\s+/g, '_');
        lines.push(`${key}:`);
        for (const { rule, enforcement } of section.rules) {
            lines.push(`  - rule: "${escapeYamlString(rule)}"`);
            lines.push(`    enforcement: ${enforcement}`);
        }
        lines.push('');
    }
    return lines.join('\n');
}
export function escapeYamlString(str) {
    return str.replace(/"/g, '\\"');
}
export function getPlatformTitle(platform) {
    const titles = {
        'claude-code': 'Claude Code',
        cursor: 'Cursor',
        windsurf: 'Windsurf',
        copilot: 'GitHub Copilot',
        cline: 'Cline',
        continue: 'Continue.dev',
        aider: 'Aider',
    };
    return titles[platform] ?? platform;
}
//# sourceMappingURL=format.js.map