// Build recommended skills section for generated rules files
// Uses managed markers so updates don't destroy user content
const MANAGED_START = '<!-- planu:skills:start -->';
const MANAGED_END = '<!-- planu:skills:end -->';
export function buildRecommendedSkillsSection(skills) {
    if (skills.length === 0) {
        return null;
    }
    const rules = skills.map((s) => ({
        rule: `\`${s.name}\` — ${s.description}. Install: \`${s.installCommand}\`. ${s.justification}`,
        enforcement: 'recommended',
    }));
    return {
        title: 'Recommended Skills (auto-managed by Planu)',
        rules,
    };
}
export function injectManagedSkillsBlock(existingContent, skills) {
    const block = buildSkillsMarkdownBlock(skills);
    const startIdx = existingContent.indexOf(MANAGED_START);
    const endIdx = existingContent.indexOf(MANAGED_END);
    if (startIdx !== -1 && endIdx !== -1) {
        // Replace existing managed block
        return (existingContent.substring(0, startIdx) +
            block +
            existingContent.substring(endIdx + MANAGED_END.length));
    }
    // Append managed block at the end
    const trimmed = existingContent.trimEnd();
    return `${trimmed}\n\n${block}\n`;
}
function buildSkillsMarkdownBlock(skills) {
    if (skills.length === 0) {
        return '';
    }
    const lines = [
        MANAGED_START,
        '## Recommended Skills (auto-managed by Planu)',
        '',
        '| Skill | Description | Install |',
        '|-------|-------------|---------|',
    ];
    for (const s of skills) {
        lines.push(`| ${s.name} | ${s.description} | \`${s.installCommand}\` |`);
    }
    lines.push('');
    lines.push(`*Auto-detected from project stack. Updated: ${new Date().toISOString().split('T')[0]}*`);
    lines.push(MANAGED_END);
    return lines.join('\n');
}
//# sourceMappingURL=sections-skills.js.map