/**
 * install/transforms/kilo.mjs — Kilo transform.
 *
 * Same body/frontmatter transform as OpenCode (color → hex, strip the same
 * agent fields) but writes under .kilo/agent/ + .kilo/command/. We import
 * the OpenCode transform body and only diverge on output paths.
 */

import { basename, dirname } from 'node:path'
import { applyOpencodeTransform } from './opencode.mjs'

/**
 * @param {import('../pipeline.mjs').TransformInput} input
 * @returns {import('../pipeline.mjs').TransformOutput[]}
 */
export function transform({ canonicalContent, canonicalRelPath, version, fileType }) {
	const payload = applyOpencodeTransform(canonicalContent, version)
	if (fileType === 'skill') {
		const folder = basename(dirname(canonicalRelPath))
		return [
			{ outputPath: `agent/${folder}.md`, content: payload },
			{ outputPath: `command/${folder}.md`, content: payload },
		]
	}
	if (fileType === 'agent') {
		const file = basename(canonicalRelPath, '.md')
		return [{ outputPath: `agent/${file}.md`, content: payload }]
	}
	return []
}
