mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-18 00:56:30 +03:00
Add Trae IDE support
- Add trae.js transformer with full metadata support (same as Claude Code) - Update build.js to include Trae in provider transformations - Update README.md with Trae installation instructions - Update DEVELOP.md with Trae transformer documentation Trae uses ~/.trae-cn/builtin_skills/ for skills installation.
This commit is contained in:
+7
-2
@@ -26,7 +26,8 @@ import {
|
||||
transformAgents,
|
||||
transformKiro,
|
||||
transformOpenCode,
|
||||
transformPi
|
||||
transformPi,
|
||||
transformTrae
|
||||
} from './lib/transformers/index.js';
|
||||
import { createAllZips } from './lib/zip.js';
|
||||
import { execSync } from 'child_process';
|
||||
@@ -149,7 +150,8 @@ function assembleUniversal(distDir, suffix = '') {
|
||||
{ provider: 'agents', configDir: '.agents' },
|
||||
{ provider: 'kiro', configDir: '.kiro' },
|
||||
{ provider: 'opencode', configDir: '.opencode' },
|
||||
{ provider: 'pi', configDir: '.pi' }
|
||||
{ provider: 'pi', configDir: '.pi' },
|
||||
{ provider: 'trae', configDir: '.trae-cn' }
|
||||
];
|
||||
|
||||
for (const { provider, configDir } of providerMappings) {
|
||||
@@ -177,6 +179,7 @@ This folder contains skills for all supported tools:
|
||||
.kiro/ → Kiro
|
||||
.opencode/ → OpenCode
|
||||
.pi/ → Pi
|
||||
.trae-cn/ → Trae
|
||||
|
||||
To install, copy the relevant folder(s) into your project root.
|
||||
These are hidden folders (dotfiles) — press Cmd+Shift+. in Finder to see them.
|
||||
@@ -349,6 +352,7 @@ async function build() {
|
||||
transformKiro(skills, DIST_DIR, patterns);
|
||||
transformOpenCode(skills, DIST_DIR, patterns);
|
||||
transformPi(skills, DIST_DIR, patterns);
|
||||
transformTrae(skills, DIST_DIR, patterns);
|
||||
|
||||
// Transform for each provider (prefixed with i-)
|
||||
const prefixOptions = { prefix: 'i-', outputSuffix: '-prefixed' };
|
||||
@@ -360,6 +364,7 @@ async function build() {
|
||||
transformKiro(skills, DIST_DIR, patterns, prefixOptions);
|
||||
transformOpenCode(skills, DIST_DIR, patterns, prefixOptions);
|
||||
transformPi(skills, DIST_DIR, patterns, prefixOptions);
|
||||
transformTrae(skills, DIST_DIR, patterns, prefixOptions);
|
||||
|
||||
// Assemble universal directory (unprefixed and prefixed)
|
||||
assembleUniversal(DIST_DIR);
|
||||
|
||||
@@ -6,3 +6,4 @@ export { transformAgents } from './agents.js';
|
||||
export { transformKiro } from './kiro.js';
|
||||
export { transformOpenCode } from "./opencode.js";
|
||||
export { transformPi } from './pi.js';
|
||||
export { transformTrae } from './trae.js';
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import path from 'path';
|
||||
import { cleanDir, ensureDir, writeFile, generateYamlFrontmatter, replacePlaceholders, prefixSkillReferences } from '../utils.js';
|
||||
|
||||
/**
|
||||
* Trae Transformer (Skills Only)
|
||||
*
|
||||
* All skills output to .trae-cn/builtin_skills/{name}/SKILL.md
|
||||
* Trae uses a similar format to Claude Code with full metadata support.
|
||||
*
|
||||
* @param {Array} skills - All skills (including user-invokable ones)
|
||||
* @param {string} distDir - Distribution output directory
|
||||
* @param {Object} patterns - Design patterns data (unused, kept for interface consistency)
|
||||
* @param {Object} options - Optional settings
|
||||
* @param {string} options.prefix - Prefix to add to user-invokable skill names (e.g., 'i-')
|
||||
* @param {string} options.outputSuffix - Suffix for output directory (e.g., '-prefixed')
|
||||
*/
|
||||
export function transformTrae(skills, distDir, patterns = null, options = {}) {
|
||||
const { prefix = '', outputSuffix = '' } = options;
|
||||
const traeDir = path.join(distDir, `trae${outputSuffix}`);
|
||||
const skillsDir = path.join(traeDir, '.trae-cn/builtin_skills');
|
||||
|
||||
cleanDir(traeDir);
|
||||
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.userInvokable) frontmatterObj['user-invokable'] = true;
|
||||
if (skill.args && skill.args.length > 0) frontmatterObj.args = skill.args;
|
||||
if (skill.license) frontmatterObj.license = skill.license;
|
||||
if (skill.compatibility) frontmatterObj.compatibility = skill.compatibility;
|
||||
if (skill.metadata) frontmatterObj.metadata = skill.metadata;
|
||||
if (skill.allowedTools) frontmatterObj['allowed-tools'] = skill.allowedTools;
|
||||
|
||||
const frontmatter = generateYamlFrontmatter(frontmatterObj);
|
||||
let skillBody = replacePlaceholders(skill.body, 'trae', commandNames);
|
||||
if (prefix) skillBody = prefixSkillReferences(skillBody, prefix, allSkillNames);
|
||||
const content = `${frontmatter}\n\n${skillBody}`;
|
||||
const outputPath = path.join(skillDir, 'SKILL.md');
|
||||
writeFile(outputPath, content);
|
||||
|
||||
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, 'trae');
|
||||
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(`✓ Trae${prefixInfo}: ${skills.length} skills (${userInvokableCount} user-invokable)${refInfo}`);
|
||||
}
|
||||
Reference in New Issue
Block a user