mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
All commands are now skills with user-invokable: true. Source lives in
source/skills/{name}/SKILL.md. Added VS Code Copilot (.agents/skills/)
and Google Antigravity (.agent/skills/) transformers. All 6 providers
output to skills directories only — no more commands/prompts dirs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
199 lines
6.4 KiB
JavaScript
199 lines
6.4 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Build System for Cross-Provider Design Skills
|
|
*
|
|
* Transforms source skills into provider-specific formats:
|
|
* - Cursor: .cursor/skills/
|
|
* - Claude Code: .claude/skills/
|
|
* - Gemini: .gemini/skills/
|
|
* - Codex: .codex/skills/
|
|
* - Copilot: .agents/skills/
|
|
* - Antigravity: .agent/skills/
|
|
*
|
|
* Also builds Tailwind CSS for production deployment.
|
|
*/
|
|
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
import { fileURLToPath } from 'url';
|
|
import { readSourceFiles, readPatterns } from './lib/utils.js';
|
|
import {
|
|
transformCursor,
|
|
transformClaudeCode,
|
|
transformGemini,
|
|
transformCodex,
|
|
transformCopilot,
|
|
transformAntigravity
|
|
} from './lib/transformers/index.js';
|
|
import { createAllZips } from './lib/zip.js';
|
|
import { execSync } from 'child_process';
|
|
|
|
/**
|
|
* Copy directory recursively
|
|
*/
|
|
function copyDirSync(src, dest) {
|
|
fs.mkdirSync(dest, { recursive: true });
|
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
for (const entry of entries) {
|
|
const srcPath = path.join(src, entry.name);
|
|
const destPath = path.join(dest, entry.name);
|
|
if (entry.isDirectory()) {
|
|
copyDirSync(srcPath, destPath);
|
|
} else {
|
|
fs.copyFileSync(srcPath, destPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const ROOT_DIR = path.resolve(__dirname, '..');
|
|
const DIST_DIR = path.join(ROOT_DIR, 'dist');
|
|
|
|
/**
|
|
* Build Tailwind CSS using the CLI
|
|
* Tailwind v4 uses @theme directive which Bun's CSS bundler doesn't understand
|
|
*/
|
|
function buildTailwindCSS() {
|
|
const inputFile = path.join(ROOT_DIR, 'public', 'css', 'main.css');
|
|
const outputFile = path.join(ROOT_DIR, 'public', 'css', 'styles.css');
|
|
|
|
console.log('🎨 Building Tailwind CSS...');
|
|
try {
|
|
execSync(`bunx @tailwindcss/cli -i "${inputFile}" -o "${outputFile}" --minify`, {
|
|
cwd: ROOT_DIR,
|
|
stdio: 'inherit'
|
|
});
|
|
console.log('✓ Tailwind CSS compiled\n');
|
|
} catch (error) {
|
|
console.error('Failed to build Tailwind CSS:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build static site using Bun's HTML bundler
|
|
* CSS is pre-compiled by Tailwind CLI, then bundled with HTML/JS
|
|
*/
|
|
async function buildStaticSite() {
|
|
const entrypoints = [
|
|
path.join(ROOT_DIR, 'public', 'index.html'),
|
|
path.join(ROOT_DIR, 'public', 'cheatsheet.html'),
|
|
];
|
|
const outdir = path.join(ROOT_DIR, 'build');
|
|
|
|
console.log('📦 Building static site with Bun...');
|
|
|
|
try {
|
|
const result = await Bun.build({
|
|
entrypoints: entrypoints,
|
|
outdir: outdir,
|
|
minify: true,
|
|
sourcemap: 'linked',
|
|
});
|
|
|
|
if (!result.success) {
|
|
console.error('Build failed:');
|
|
for (const log of result.logs) {
|
|
console.error(log.message || log);
|
|
if (log.position) {
|
|
console.error(` at ${log.position.file}:${log.position.line}:${log.position.column}`);
|
|
}
|
|
}
|
|
process.exit(1);
|
|
}
|
|
|
|
// Calculate total size
|
|
const totalSize = result.outputs.reduce((sum, o) => sum + o.size, 0);
|
|
const jsFiles = result.outputs.filter(o => o.path.endsWith('.js'));
|
|
const cssFiles = result.outputs.filter(o => o.path.endsWith('.css'));
|
|
|
|
console.log(`✓ Static site built to ./build/`);
|
|
console.log(` HTML: 1 file`);
|
|
console.log(` JS: ${jsFiles.length} file(s) (${(jsFiles.reduce((s, f) => s + f.size, 0) / 1024).toFixed(1)} KB)`);
|
|
console.log(` CSS: ${cssFiles.length} file(s) (${(cssFiles.reduce((s, f) => s + f.size, 0) / 1024).toFixed(1)} KB)`);
|
|
console.log(` Total: ${(totalSize / 1024).toFixed(1)} KB\n`);
|
|
|
|
return result;
|
|
} catch (error) {
|
|
console.error('Failed to build static site:', error.message);
|
|
console.error(error.stack);
|
|
if (error.logs) {
|
|
for (const log of error.logs) {
|
|
console.error(log.message || log);
|
|
}
|
|
}
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Main build process
|
|
*/
|
|
async function build() {
|
|
console.log('🔨 Building cross-provider design skills...\n');
|
|
|
|
// Build CSS with Tailwind CLI (handles @theme directive)
|
|
buildTailwindCSS();
|
|
|
|
// Bundle HTML, JS, and compiled CSS with Bun
|
|
await buildStaticSite();
|
|
|
|
// Copy root-level static assets that need stable (unhashed) URLs
|
|
const staticAssets = ['og-image.jpg', 'robots.txt', 'sitemap.xml', 'favicon.svg', 'apple-touch-icon.png'];
|
|
const buildDir = path.join(ROOT_DIR, 'build');
|
|
for (const asset of staticAssets) {
|
|
const src = path.join(ROOT_DIR, 'public', asset);
|
|
if (fs.existsSync(src)) {
|
|
fs.copyFileSync(src, path.join(buildDir, asset));
|
|
}
|
|
}
|
|
|
|
// Read source files (unified skills architecture)
|
|
const { skills } = readSourceFiles(ROOT_DIR);
|
|
const patterns = readPatterns(ROOT_DIR);
|
|
const userInvokableCount = skills.filter(s => s.userInvokable).length;
|
|
console.log(`📖 Read ${skills.length} skills (${userInvokableCount} user-invokable) and ${patterns.patterns.length + patterns.antipatterns.length} pattern categories\n`);
|
|
|
|
// Transform for each provider (unprefixed)
|
|
transformCursor(skills, DIST_DIR, patterns);
|
|
transformClaudeCode(skills, DIST_DIR, patterns);
|
|
transformGemini(skills, DIST_DIR, patterns);
|
|
transformCodex(skills, DIST_DIR, patterns);
|
|
transformCopilot(skills, DIST_DIR, patterns);
|
|
transformAntigravity(skills, DIST_DIR, patterns);
|
|
|
|
// Transform for each provider (prefixed with i-)
|
|
const prefixOptions = { prefix: 'i-', outputSuffix: '-prefixed' };
|
|
transformCursor(skills, DIST_DIR, patterns, prefixOptions);
|
|
transformClaudeCode(skills, DIST_DIR, patterns, prefixOptions);
|
|
transformGemini(skills, DIST_DIR, patterns, prefixOptions);
|
|
transformCodex(skills, DIST_DIR, patterns, prefixOptions);
|
|
transformCopilot(skills, DIST_DIR, patterns, prefixOptions);
|
|
transformAntigravity(skills, DIST_DIR, patterns, prefixOptions);
|
|
|
|
// Create ZIP bundles (both unprefixed and prefixed)
|
|
await createAllZips(DIST_DIR);
|
|
|
|
// Copy Claude Code output to project's .claude directory for local development
|
|
const claudeCodeSrc = path.join(DIST_DIR, 'claude-code', '.claude');
|
|
const claudeCodeDest = path.join(ROOT_DIR, '.claude');
|
|
|
|
// Copy skills directory (preserves other files like settings.local.json)
|
|
const skillsSrc = path.join(claudeCodeSrc, 'skills');
|
|
const skillsDest = path.join(claudeCodeDest, 'skills');
|
|
|
|
// Remove existing and copy fresh
|
|
if (fs.existsSync(skillsDest)) fs.rmSync(skillsDest, { recursive: true });
|
|
|
|
copyDirSync(skillsSrc, skillsDest);
|
|
|
|
console.log(`📋 Synced to .claude/: skills`);
|
|
|
|
console.log('\n✨ Build complete!');
|
|
}
|
|
|
|
// Run the build
|
|
build();
|