import { Request, Response } from 'express';

const agents = {
    team: {
        name: 'team',
        description: '管理复杂开发任务的项目经理和团队协调者',
        mode: 'primary',
        prompt: './.opencode/agents/team.md',
        temperature: 0.3,
        tools: { write: false, edit: false, bash: true },
    },
    planning: {
        name: 'planning',
        description: '专注于深度分析、需求拆解和实施路线图的技术架构师',
        mode: 'subagent',
        prompt: './.opencode/agents/planning.md',
        temperature: 0.2,
        tools: { write: false, edit: false, bash: false },
    },
    frontend: {
        name: 'frontend',
        description: '资深前端与 UmiJS 专家，负责从服务层到 UI/UX 的全栈实施',
        mode: 'subagent',
        prompt: './.opencode/agents/frontend.md',
        temperature: 0.3,
        tools: { write: true, edit: true, bash: true },
    },
    'code-spec': {
        name: 'code-spec',
        description: '强制执行 Ant Design 和 ProComponents 最佳实践的代码规范专家',
        mode: 'subagent',
        prompt: './.opencode/agents/code-spec.md',
        temperature: 0.1,
        tools: { write: true, edit: true, bash: false },
    },
    'qa-tester': {
        name: 'qa-tester',
        description: '进行功能测试和 i18n 验证的资深 QA 工程师',
        mode: 'subagent',
        prompt: './.opencode/agents/qa-tester.md',
        temperature: 0.2,
        tools: { write: false, edit: false, bash: true },
    },
};

export default {
    'GET /api/agents': (req: Request, res: Response) => {
        const list = Object.keys(agents).map((key) => ({
            key,
            ...agents[key],
            promptPath: agents[key].prompt,
        }));
        res.send({ data: list, success: true });
    },
    'GET /api/agents/:key/prompt': (req: Request, res: Response) => {
        res.send({
            data: `这是一个模拟的 ${req.params.key} Prompt 内容...\n# ${req.params.key.toUpperCase()} Agent\n...`,
            success: true,
        });
    },
    'POST /api/agents/update': (req: Request, res: Response) => {
        res.send({ success: true, message: '配置已更新' });
    },
    'GET /api/skills': (req: Request, res: Response) => {
        res.send({
            data: [
                { id: '1', name: 'Ant Design Skill', description: '提供标准组件模式和样式指南', isEnabled: true },
                { id: '2', name: 'Security Audit', description: '代码安全与 XSS 检查脚本', isEnabled: false },
            ],
            success: true,
        });
    },
};
