mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
- Bump skills plugin version 2.1.1 -> 3.0.0 (plugin.json, marketplace.json, harness SKILL.md files). CLI and Chrome extension unchanged. - Remove prefixed universal zip bundle and all related code: factory.js prefix/outputSuffix options, zip.js variant pass, utils.js prefixSkillReferences, the "universal-prefixed" entry in download-providers.js, and the matching test suite in utils.test.js. - Redesign Get Started step 1 "Install the skill and CLI": two terminal rows (npx skills + npm i -g impeccable) with paired notes, drop the Recommended badge. - Collapse "Other install methods" back into a <details> element so the primary install path is the first thing users see. - Simplify step 3 to "Add the Chrome extension": remove the CLI tool block (now in step 1), use standard .btn .btn-primary for the CTA so it matches other primary buttons (square corners, accent slide-up hover), and lay out the preview screenshot next to the button instead of stacked so the screenshot no longer dominates vertical space. - CLAUDE.md: rewrite with v3.0 architecture, the "no em dash also means no --" rule, the harness-dirs-are-tracked gotcha, the named-export test-spy warning, and the evals inline-skill.ts sync note. - AGENTS.md, DEVELOP.md: drop prefixed variant references. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
130 lines
4.3 KiB
JavaScript
130 lines
4.3 KiB
JavaScript
import path from 'path';
|
|
import { cleanDir, ensureDir, writeFile, generateYamlFrontmatter, replacePlaceholders } from '../utils.js';
|
|
|
|
/**
|
|
* Map from frontmatter field name to extraction spec.
|
|
*
|
|
* - sourceKey: property name on the skill object
|
|
* - yamlKey: key name in YAML frontmatter
|
|
* - condition: if provided, field is only emitted when this returns true
|
|
* - value: if provided, use this instead of skill[sourceKey]
|
|
*/
|
|
const FIELD_SPECS = {
|
|
'user-invocable': {
|
|
sourceKey: 'userInvocable',
|
|
yamlKey: 'user-invocable',
|
|
condition: (skill) => skill.userInvocable,
|
|
value: () => true,
|
|
},
|
|
'argument-hint': {
|
|
sourceKey: 'argumentHint',
|
|
yamlKey: 'argument-hint',
|
|
condition: (skill) => skill.userInvocable && skill.argumentHint,
|
|
},
|
|
license: {
|
|
sourceKey: 'license',
|
|
yamlKey: 'license',
|
|
},
|
|
compatibility: {
|
|
sourceKey: 'compatibility',
|
|
yamlKey: 'compatibility',
|
|
},
|
|
metadata: {
|
|
sourceKey: 'metadata',
|
|
yamlKey: 'metadata',
|
|
},
|
|
'allowed-tools': {
|
|
sourceKey: 'allowedTools',
|
|
yamlKey: 'allowed-tools',
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Create a transformer function for a given provider config.
|
|
*
|
|
* @param {Object} config - Provider configuration from providers.js
|
|
* @returns {Function} transform(skills, distDir, options?)
|
|
*/
|
|
export function createTransformer(config) {
|
|
const { provider, configDir, displayName, frontmatterFields = [], bodyTransform, placeholderProvider } = config;
|
|
const placeholderKey = placeholderProvider || provider;
|
|
|
|
const activeFields = frontmatterFields
|
|
.map((name) => FIELD_SPECS[name])
|
|
.filter(Boolean);
|
|
|
|
return function transform(skills, distDir, options = {}) {
|
|
const { skillsVersion = '' } = options;
|
|
const providerDir = path.join(distDir, provider);
|
|
const skillsDir = path.join(providerDir, `${configDir}/skills`);
|
|
|
|
cleanDir(providerDir);
|
|
ensureDir(skillsDir);
|
|
|
|
const allSkillNames = skills.map((s) => s.name);
|
|
const commandNames = skills
|
|
.filter((s) => s.userInvocable)
|
|
.map((s) => s.name);
|
|
|
|
let refCount = 0;
|
|
let scriptCount = 0;
|
|
|
|
for (const skill of skills) {
|
|
const skillName = skill.name;
|
|
const skillDir = path.join(skillsDir, skillName);
|
|
|
|
// Build frontmatter
|
|
const frontmatterObj = {
|
|
name: skillName,
|
|
description: skill.description,
|
|
};
|
|
if (skillsVersion) frontmatterObj.version = skillsVersion;
|
|
|
|
for (const spec of activeFields) {
|
|
if (spec.condition && !spec.condition(skill)) continue;
|
|
const val = spec.value ? spec.value(skill) : skill[spec.sourceKey];
|
|
if (val) frontmatterObj[spec.yamlKey] = val;
|
|
}
|
|
|
|
const frontmatter = generateYamlFrontmatter(frontmatterObj);
|
|
|
|
// Build body
|
|
let skillBody = replacePlaceholders(skill.body, placeholderKey, commandNames, allSkillNames);
|
|
|
|
// Replace {{scripts_path}} with provider-aware path to skill's scripts directory
|
|
const scriptsPath = `${configDir}/skills/${skillName}/scripts`;
|
|
skillBody = skillBody.replace(/\{\{scripts_path\}\}/g, scriptsPath);
|
|
if (bodyTransform) skillBody = bodyTransform(skillBody, skill);
|
|
|
|
const content = `${frontmatter}\n\n${skillBody}`;
|
|
writeFile(path.join(skillDir, 'SKILL.md'), content);
|
|
|
|
// Copy reference files
|
|
if (skill.references && skill.references.length > 0) {
|
|
const refDir = path.join(skillDir, 'reference');
|
|
ensureDir(refDir);
|
|
for (const ref of skill.references) {
|
|
const refContent = replacePlaceholders(ref.content, placeholderKey, [], allSkillNames);
|
|
writeFile(path.join(refDir, `${ref.name}.md`), refContent);
|
|
refCount++;
|
|
}
|
|
}
|
|
|
|
// Copy script files
|
|
if (skill.scripts && skill.scripts.length > 0) {
|
|
const scriptsOutDir = path.join(skillDir, 'scripts');
|
|
ensureDir(scriptsOutDir);
|
|
for (const script of skill.scripts) {
|
|
writeFile(path.join(scriptsOutDir, script.name), script.content);
|
|
scriptCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
const skillWord = skills.length === 1 ? 'skill' : 'skills';
|
|
const refInfo = refCount > 0 ? ` (${refCount} reference files)` : '';
|
|
const scriptInfo = scriptCount > 0 ? ` (${scriptCount} script files)` : '';
|
|
console.log(`✓ ${displayName}: ${skills.length} ${skillWord}${refInfo}${scriptInfo}`);
|
|
};
|
|
}
|