/**
 * install/transforms/windsurf.mjs — Windsurf transform.
 *
 * Windsurf quirks:
 *   - frontmatter strips color+skills.
 *   - skills land in .windsurf/rules/<name>.md (Windsurf rule files).
 *   - agents/invocable land in .windsurf/workflows/<name>.md.
 */
import { basename, dirname } from 'node:path';
import { parseFrontmatter, serializeFrontmatter, stripFields, substituteVersion, } from './_shared.mjs';
const STRIP = ['color', 'skills'];
/**
 * @param {import('../pipeline.mjs').TransformInput} input
 * @returns {import('../pipeline.mjs').TransformOutput[]}
 */
export function transform({ canonicalContent, canonicalRelPath, version, fileType }) {
    const subbed = substituteVersion(canonicalContent, version);
    const parsed = parseFrontmatter(subbed);
    let payload = subbed;
    if (parsed.hasFrontmatter && parsed.fm) {
        stripFields(parsed.fm, STRIP);
        payload = serializeFrontmatter(parsed);
    }
    if (fileType === 'skill') {
        const folder = basename(dirname(canonicalRelPath));
        return [{ outputPath: `rules/${folder}.md`, content: payload }];
    }
    if (fileType === 'agent') {
        const file = basename(canonicalRelPath, '.md');
        return [{ outputPath: `workflows/${file}.md`, content: payload }];
    }
    return [];
}
//# sourceMappingURL=windsurf.mjs.map