/**
 * JetBrains Adapter
 */
import * as path from 'path';
import * as fs from '../../utils/fs-native.js';
import { AdapterBase } from '../adapter-base.js';
export class JetBrainsAdapter extends AdapterBase {
    constructor() {
        super(...arguments);
        this.name = 'jetbrains';
        this.description = 'JetBrains adapter — skills installed in .junie/skills/';
        this.automationLevel = 'semi';
    }
    async detect() {
        return await this.fileExists('.junie') || await this.fileExists('.aiassistant') || await this.commandExists('idea');
    }
    getFiles() {
        return [];
    }
    async install(options) {
        console.log('\n📦 Installing JetBrains Adapter\n');
        await fs.ensureDir(path.join(options.projectPath, '.junie/skills'));
        console.log('\n✨ JetBrains adapter installed!');
        console.log('   Run `specweave refresh-plugins` to install skills.');
    }
    supportsPlugins() {
        return true;
    }
    getSkillsDirectory() {
        return '.junie/skills';
    }
    async compilePlugin(plugin) {
        const skillsDir = '.junie/skills';
        console.log(`\n📦 Installing plugin skills for JetBrains: ${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 JetBrains!`);
    }
    async unloadPlugin(pluginName) {
        console.log(`\n🗑️  Unloading plugin from JetBrains: ${pluginName}`);
        await this.removeSkillFiles(pluginName, '.junie/skills');
        console.log(`   ✓ Removed from .junie/skills/`);
        console.log(`\n✅ Plugin ${pluginName} unloaded!`);
    }
    async getInstalledPlugins() {
        return await this.listInstalledPluginsInDir('.junie/skills');
    }
    async postInstall(options) {
        console.log(this.getInstructions());
    }
    getInstructions() {
        return `
JetBrains Adapter

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