Files
pbakaus_impeccable/scripts/lib/transformers/gemini.js
T
Paul BakausandClaude Opus 4.6 df1c26ce63 Fix user-invokable -> user-invocable spelling across entire codebase
PR #50 fixed the output SKILL.md files but the source files, build
scripts, tests, docs, and server code still used the wrong spelling.
Claude Code expects `user-invocable` (with c) for slash command
autocomplete to work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 23:33:22 -07:00

67 lines
2.7 KiB
JavaScript

import path from 'path';
import { cleanDir, ensureDir, writeFile, generateYamlFrontmatter, replacePlaceholders, prefixSkillReferences } from '../utils.js';
/**
* Gemini Transformer (Skills Only)
*
* All skills output to .gemini/skills/{name}/SKILL.md
* Frontmatter: name, description
* For user-invocable skills: {{arg}} placeholders become {{args}} in body
*
* @param {Array} skills - All skills (including user-invocable 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 user-invocable skill names (e.g., 'i-')
* @param {string} options.outputSuffix - Suffix for output directory (e.g., '-prefixed')
*/
export function transformGemini(skills, distDir, patterns = null, options = {}) {
const { prefix = '', outputSuffix = '' } = options;
const geminiDir = path.join(distDir, `gemini${outputSuffix}`);
const skillsDir = path.join(geminiDir, '.gemini/skills');
cleanDir(geminiDir);
ensureDir(skillsDir);
const allSkillNames = skills.map(s => s.name);
const commandNames = skills.filter(s => s.userInvocable).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 frontmatter = generateYamlFrontmatter({
name: skillName,
description: skill.description,
});
let skillBody = replacePlaceholders(skill.body, 'gemini', commandNames);
if (prefix) skillBody = prefixSkillReferences(skillBody, prefix, allSkillNames);
// For user-invocable skills, replace remaining {{arg}} placeholders with {{args}}
if (skill.userInvocable) {
skillBody = skillBody.replace(/\{\{[^}]+\}\}/g, '{{args}}');
}
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, 'gemini');
writeFile(refOutputPath, refContent);
refCount++;
}
}
}
const userInvocableCount = skills.filter(s => s.userInvocable).length;
const refInfo = refCount > 0 ? ` (${refCount} reference files)` : '';
const prefixInfo = prefix ? ` [${prefix}prefixed]` : '';
console.log(`✓ Gemini${prefixInfo}: ${skills.length} skills (${userInvocableCount} user-invocable)${refInfo}`);
}