// engine/ai-integration/agent-frameworks/autogen-exporter.ts — AutoGen config exporter (SPEC-274)
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
/**
 * Converts a Planu spec into an AutoGen/Microsoft multi-agent config.
 * Produces AssistantAgent, UserProxyAgent, and GroupChatManager.
 */
export function exportSpecToAutogen(spec) {
    return {
        agents: [
            {
                name: 'planu-assistant',
                type: 'assistant',
                systemMessage: [
                    `You are a software implementer using Spec Driven Development.`,
                    `Your current task: implement spec ${spec.id} — ${spec.title}.`,
                    `Description: ${spec.description}`,
                    `Acceptance criteria: ${spec.acceptanceCriteria.join('; ')}.`,
                    `After implementation, call mcp__planu__validate to verify compliance.`,
                    `Stack: ${spec.stack.join(', ') || 'not specified'}.`,
                ].join(' '),
            },
            {
                name: 'user-proxy',
                type: 'user-proxy',
                systemMessage: 'Human proxy agent. Approves or rejects agent outputs.',
            },
            {
                name: 'group-chat-manager',
                type: 'group-chat-manager',
            },
        ],
        groupChat: {
            maxRounds: 12,
            speakerSelection: 'auto',
        },
    };
}
/**
 * Serializes the AutoGen config to JSON and writes `planu-autogen.json` to the project path.
 */
export function writeAutogenConfig(projectPath, spec) {
    const config = exportSpecToAutogen(spec);
    /* v8 ignore start */
    if (!existsSync(projectPath)) {
        mkdirSync(projectPath, { recursive: true });
    }
    /* v8 ignore stop */
    const json = JSON.stringify(config, null, 2);
    writeFileSync(join(projectPath, 'planu-autogen.json'), json, 'utf8');
}
//# sourceMappingURL=autogen-exporter.js.map