import { join } from 'node:path';
import { copyDirWithVersionCheck } from '../../../init/tools/shared/copy-helpers.js';
import { UTILITY_SKILLS } from '../../../init/tools/shared/skill-manifest.js';
export { UTILITY_SKILLS };
export async function installUtility(options) {
    const force = options.force ?? false;
    const result = {
        copiedSkills: [],
        updatedSkills: [],
        skippedSkills: [],
        outdatedSkills: [],
    };
    for (const skill of options.skills) {
        const source = join(options.assetsRoot, 'skills', skill);
        const destination = join(options.targetRoot, '.agents', 'skills', skill);
        const resultWithVersion = await copyDirWithVersionCheck(source, destination, force);
        if (resultWithVersion.status === 'copied') {
            result.copiedSkills.push(skill);
        }
        else if (resultWithVersion.status === 'updated') {
            result.updatedSkills.push(skill);
        }
        else if (resultWithVersion.status === 'outdated') {
            result.outdatedSkills.push({
                name: skill,
                installed: resultWithVersion.installedVersion ?? null,
                bundled: resultWithVersion.bundledVersion ?? null,
            });
        }
        else {
            result.skippedSkills.push(skill);
        }
    }
    return result;
}
