// engine/skill-generation/multi-agent-adapter.ts — SPEC-607
// Adapts Agent Skills spec SKILL.md content for each AI agent's format.
/** Strip the YAML frontmatter from skill content, returning only the body. */
function stripFrontmatter(content) {
    if (!content.startsWith('---\n')) {
        return content;
    }
    const end = content.indexOf('\n---\n', 4);
    if (end === -1) {
        return content;
    }
    return content.slice(end + 5);
}
/** Build a Cursor-compatible MDC frontmatter block. */
function buildCursorFrontmatter(metadata) {
    const lines = ['---'];
    lines.push(`description: ${metadata.description}`);
    if (metadata.triggers && metadata.triggers.length > 0) {
        lines.push(`globs: [${metadata.triggers.map((t) => `"${t}"`).join(', ')}]`);
    }
    lines.push('alwaysApply: false');
    lines.push('---');
    return lines.join('\n');
}
/** Build a section header for copilot/gemini append format. */
function buildSectionHeader(name) {
    return `\n## ${name}\n`;
}
/**
 * Adapt skill content for a specific AI agent's format.
 *
 * - claude: returned as-is (SKILL.md format)
 * - cursor: converted to .mdc with Cursor frontmatter
 * - copilot: frontmatter stripped, body only (for append to copilot-instructions.md)
 * - gemini: frontmatter stripped, body only (for append to GEMINI.md)
 */
export function adaptSkillForAgent(skillContent, metadata, target) {
    switch (target) {
        case 'claude':
            return skillContent;
        case 'cursor': {
            const body = stripFrontmatter(skillContent);
            return buildCursorFrontmatter(metadata) + '\n' + body;
        }
        case 'copilot': {
            const body = stripFrontmatter(skillContent);
            return buildSectionHeader(metadata.name) + body;
        }
        case 'gemini': {
            const body = stripFrontmatter(skillContent);
            return buildSectionHeader(metadata.name) + body;
        }
        default: {
            // Exhaustiveness guard — TypeScript will catch missing cases at compile time
            const _exhaustive = target;
            return _exhaustive;
        }
    }
}
//# sourceMappingURL=multi-agent-adapter.js.map