/**
 * Trae Adapter (ByteDance)
 */
import * as path from 'path';
import * as fs from '../../utils/fs-native.js';
import { AdapterBase } from '../adapter-base.js';
export class TraeAdapter extends AdapterBase {
    constructor() {
        super(...arguments);
        this.name = 'trae';
        this.description = 'Trae adapter — skills installed in .trae/skills/';
        this.automationLevel = 'semi';
    }
    async detect() {
        try {
            const { execSync } = await import('child_process');
            execSync('which trae', { stdio: 'ignore' });
            return true;
        }
        catch {
            return await this.fileExists('.trae');
        }
    }
    getFiles() {
        return [];
    }
    async install(options) {
        console.log('\n📦 Installing Trae Adapter\n');
        await fs.ensureDir(path.join(options.projectPath, '.trae/skills'));
        console.log('\n✨ Trae adapter installed!');
        console.log('   Run `specweave refresh-plugins` to install skills.');
    }
    supportsPlugins() {
        return true;
    }
    getSkillsDirectory() {
        return '.trae/skills';
    }
    async compilePlugin(plugin) {
        const skillsDir = '.trae/skills';
        console.log(`\n📦 Installing plugin skills for Trae: ${plugin.manifest.name}`);
        await this.writeSkillFiles(plugin, skillsDir);
        console.log(`   ✓ ${plugin.skills.length} skill(s) written to ${skillsDir}/`);
        console.log(`\n✅ Plugin ${plugin.manifest.name} installed for Trae!`);
    }
    async unloadPlugin(pluginName) {
        console.log(`\n🗑️  Unloading plugin from Trae: ${pluginName}`);
        await this.removeSkillFiles(pluginName, '.trae/skills');
        console.log(`   ✓ Removed from .trae/skills/`);
        console.log(`\n✅ Plugin ${pluginName} unloaded!`);
    }
    async getInstalledPlugins() {
        return await this.listInstalledPluginsInDir('.trae/skills');
    }
    async postInstall(options) {
        console.log(this.getInstructions());
    }
    getInstructions() {
        return `
Trae Adapter

Skills installed in .trae/skills/.
Run: specweave refresh-plugins
    `;
    }
}
//# sourceMappingURL=adapter.js.map