mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Fix bug in Kiro transformer where commandNames was incorrectly passed to replacePlaceholders for reference files. Add dedicated test suites for Agents and Kiro transformers, and add unit tests for replacePlaceholders and prefixSkillReferences utilities. (107 → 164 tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
2.7 KiB
JavaScript
66 lines
2.7 KiB
JavaScript
import path from 'path';
|
|
import { cleanDir, ensureDir, writeFile, generateYamlFrontmatter, replacePlaceholders, prefixSkillReferences } from '../utils.js';
|
|
|
|
/**
|
|
* Kiro Transformer (Skills Only)
|
|
*
|
|
* All skills output to .kiro/skills/{name}/SKILL.md
|
|
* Frontmatter: name, description, license, compatibility, metadata
|
|
*
|
|
* @param {Array} skills - All skills (including user-invokable ones)
|
|
* @param {string} distDir - Distribution output directory
|
|
* @param {Object} patterns - Design patterns data (unused)
|
|
* @param {Object} options - Optional settings
|
|
* @param {string} options.prefix - Prefix to add to skill names (e.g., 'i-')
|
|
* @param {string} options.outputSuffix - Suffix for output directory (e.g., '-prefixed')
|
|
*/
|
|
export function transformKiro(skills, distDir, patterns = null, options = {}) {
|
|
const { prefix = '', outputSuffix = '' } = options;
|
|
const kiroDir = path.join(distDir, `kiro${outputSuffix}`);
|
|
const skillsDir = path.join(kiroDir, '.kiro/skills');
|
|
|
|
cleanDir(kiroDir);
|
|
ensureDir(skillsDir);
|
|
|
|
const allSkillNames = skills.map(s => s.name);
|
|
const commandNames = skills.filter(s => s.userInvokable).map(s => `${prefix}${s.name}`);
|
|
let refCount = 0;
|
|
for (const skill of skills) {
|
|
const skillName = `${prefix}${skill.name}`;
|
|
const skillDir = path.join(skillsDir, skillName);
|
|
|
|
const frontmatterObj = {
|
|
name: skillName,
|
|
description: skill.description,
|
|
};
|
|
|
|
if (skill.license) frontmatterObj.license = skill.license;
|
|
if (skill.compatibility) frontmatterObj.compatibility = skill.compatibility;
|
|
if (skill.metadata) frontmatterObj.metadata = skill.metadata;
|
|
|
|
const frontmatter = generateYamlFrontmatter(frontmatterObj);
|
|
let skillBody = replacePlaceholders(skill.body, 'kiro', commandNames);
|
|
if (prefix) skillBody = prefixSkillReferences(skillBody, prefix, allSkillNames);
|
|
const content = `${frontmatter}\n\n${skillBody}`;
|
|
const outputPath = path.join(skillDir, 'SKILL.md');
|
|
writeFile(outputPath, content);
|
|
|
|
// Copy reference files if they exist
|
|
if (skill.references && skill.references.length > 0) {
|
|
const refDir = path.join(skillDir, 'reference');
|
|
ensureDir(refDir);
|
|
for (const ref of skill.references) {
|
|
const refOutputPath = path.join(refDir, `${ref.name}.md`);
|
|
const refContent = replacePlaceholders(ref.content, 'kiro');
|
|
writeFile(refOutputPath, refContent);
|
|
refCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
const userInvokableCount = skills.filter(s => s.userInvokable).length;
|
|
const refInfo = refCount > 0 ? ` (${refCount} reference files)` : '';
|
|
const prefixInfo = prefix ? ` [${prefix}prefixed]` : '';
|
|
console.log(`✓ Kiro${prefixInfo}: ${skills.length} skills (${userInvokableCount} user-invokable)${refInfo}`);
|
|
}
|