/*
 * Copyright (c) 2025, Salesforce, Inc.
 * SPDX-License-Identifier: Apache-2
 * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
 */
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
const home = os.homedir();
/**
 * IDE configurations with paths and detection logic.
 */
export const IDE_CONFIGS = {
    'claude-code': {
        id: 'claude-code',
        displayName: 'Claude Code',
        paths: {
            projectDir: '.claude/skills',
            globalDir: path.join(home, '.claude/skills'),
        },
        detectInstalled: async () => {
            return fs.existsSync(path.join(home, '.claude'));
        },
        docsUrl: 'https://docs.anthropic.com/en/docs/claude-code',
    },
    cursor: {
        id: 'cursor',
        displayName: 'Cursor',
        paths: {
            projectDir: '.cursor/skills',
            globalDir: path.join(home, '.cursor/skills'),
        },
        detectInstalled: async () => {
            return fs.existsSync(path.join(home, '.cursor'));
        },
        docsUrl: 'https://cursor.com/docs/context/skills',
    },
    windsurf: {
        id: 'windsurf',
        displayName: 'Windsurf',
        paths: {
            projectDir: '.windsurf/skills',
            globalDir: path.join(home, '.codeium/windsurf/skills'),
        },
        detectInstalled: async () => {
            return fs.existsSync(path.join(home, '.codeium/windsurf'));
        },
        docsUrl: 'https://docs.windsurf.com/',
    },
    vscode: {
        id: 'vscode',
        displayName: 'VS Code / GitHub Copilot',
        paths: {
            projectDir: '.github/skills',
            globalDir: path.join(home, '.copilot/skills'),
        },
        detectInstalled: async () => {
            // Check for either .github directory (project-based) or ~/.copilot
            return fs.existsSync(path.join(home, '.copilot'));
        },
        docsUrl: 'https://code.visualstudio.com/docs/copilot/customization/agent-skills',
    },
    codex: {
        id: 'codex',
        displayName: 'OpenAI Codex CLI',
        paths: {
            projectDir: '.codex/skills',
            globalDir: path.join(home, '.codex/skills'),
        },
        detectInstalled: async () => {
            return fs.existsSync(path.join(home, '.codex'));
        },
        docsUrl: 'https://github.com/openai/codex',
    },
    opencode: {
        id: 'opencode',
        displayName: 'OpenCode',
        paths: {
            projectDir: '.opencode/skills',
            globalDir: path.join(home, '.config/opencode/skills'),
        },
        detectInstalled: async () => {
            return fs.existsSync(path.join(home, '.config/opencode'));
        },
        docsUrl: 'https://opencode.ai/',
    },
    manual: {
        id: 'manual',
        displayName: 'Manual Installation',
        paths: {
            // Manual mode uses same paths as Claude Code
            projectDir: '.claude/skills',
            globalDir: path.join(home, '.claude/skills'),
        },
        detectInstalled: async () => {
            // Manual is always "available" as a fallback
            return true;
        },
    },
};
/**
 * All supported IDE types in display order.
 */
export const ALL_IDE_TYPES = ['claude-code', 'cursor', 'windsurf', 'vscode', 'codex', 'opencode', 'manual'];
/**
 * Detect which IDEs are installed on the system.
 *
 * @returns Array of IDE types that appear to be installed
 */
export async function detectInstalledIdes() {
    const installed = [];
    for (const ideType of ALL_IDE_TYPES) {
        // Skip 'manual' from auto-detection since it's always available
        if (ideType === 'manual') {
            continue;
        }
        const config = IDE_CONFIGS[ideType];
        const isInstalled = await config.detectInstalled();
        if (isInstalled) {
            installed.push(ideType);
        }
    }
    return installed;
}
/**
 * Get the installation path for a skill.
 *
 * @param ide - Target IDE
 * @param skillName - Name of the skill
 * @param options - Installation options
 * @returns Absolute path where the skill would be installed
 */
export function getSkillInstallPath(ide, skillName, options) {
    const config = IDE_CONFIGS[ide];
    if (options.global) {
        return path.join(config.paths.globalDir, skillName);
    }
    const projectRoot = options.projectRoot || process.cwd();
    return path.join(projectRoot, config.paths.projectDir, skillName);
}
/**
 * Get the display name for an IDE.
 *
 * @param ide - IDE type
 * @returns Human-readable display name
 */
export function getIdeDisplayName(ide) {
    return IDE_CONFIGS[ide].displayName;
}
/**
 * Get the documentation URL for an IDE.
 *
 * @param ide - IDE type
 * @returns Documentation URL or undefined if not available
 */
export function getIdeDocsUrl(ide) {
    return IDE_CONFIGS[ide].docsUrl;
}
//# sourceMappingURL=agents.js.map