// engine/provider-adapters/registry.ts — SPEC-670: Lazy registry of provider adapters.
//
// Adding a provider = (1) create `adapters/<kind>.ts` exporting a class implementing
// `SpecRenderer` with `kind: '<kind>'`, (2) add a single line to PROVIDER_FACTORIES
// below.
/**
 * Registered provider factories. Lazy-loaded so unused adapters never enter the
 * import graph.
 */
const PROVIDER_FACTORIES = new Map([
    [
        'claude',
        async () => {
            const { ClaudeRenderer } = await import('./adapters/claude.js');
            return new ClaudeRenderer();
        },
    ],
    [
        'gpt4',
        async () => {
            const { GPT4Renderer } = await import('./adapters/gpt4.js');
            return new GPT4Renderer();
        },
    ],
    [
        'gemini',
        async () => {
            const { GeminiRenderer } = await import('./adapters/gemini.js');
            return new GeminiRenderer();
        },
    ],
    [
        'markdown',
        async () => {
            const { GenericMarkdownRenderer } = await import('./adapters/markdown.js');
            return new GenericMarkdownRenderer();
        },
    ],
]);
/** List of all provider kinds known to the registry, in insertion order. */
export function getRegisteredProviders() {
    return [...PROVIDER_FACTORIES.keys()];
}
/**
 * Resolve a renderer for a given provider kind. Throws an actionable error when the
 * kind is not registered (the message includes how to add a new adapter — see
 * Scenario 9 / 5).
 */
export async function getRenderer(kind) {
    const factory = PROVIDER_FACTORIES.get(kind);
    if (!factory) {
        const known = getRegisteredProviders().join(', ');
        throw new Error(`Unknown provider "${kind}". Registered: ${known}. ` +
            `Add an adapter at src/engine/provider-adapters/adapters/${kind}.ts to support it.`);
    }
    return factory();
}
/**
 * Map an LLMClientKind (canonical SPEC-645 detection result) to the matching provider.
 *
 *   claude-code → claude
 *   copilot     → gpt4
 *   codex       → gpt4
 *   gemini      → gemini
 *   cursor      → markdown   (Cursor reads context.md today)
 *   windsurf    → markdown
 *   unknown     → markdown
 */
export function llmClientToProvider(client) {
    switch (client) {
        case 'claude-code':
            return 'claude';
        case 'copilot':
        case 'codex':
            return 'gpt4';
        case 'gemini':
            return 'gemini';
        case 'cursor':
        case 'windsurf':
        case 'unknown':
        default:
            return 'markdown';
    }
}
//# sourceMappingURL=registry.js.map