diff --git a/frontend/src/components/ai/aiSlashCommands.test.ts b/frontend/src/components/ai/aiSlashCommands.test.ts index 7ce3e5b..822abab 100644 --- a/frontend/src/components/ai/aiSlashCommands.test.ts +++ b/frontend/src/components/ai/aiSlashCommands.test.ts @@ -12,7 +12,10 @@ describe('aiSlashCommands', () => { expect(commands.length).toBeGreaterThan(8); expect(commands.some((command) => command.cmd === '/health')).toBe(true); + expect(commands.some((command) => command.cmd === '/tools')).toBe(true); + expect(commands.some((command) => command.cmd === '/budget')).toBe(true); expect(commands.some((command) => command.cmd === '/mcp')).toBe(true); + expect(commands.some((command) => command.cmd === '/mcpfail')).toBe(true); expect(commands.some((command) => command.cmd === '/mcpadd')).toBe(true); expect(commands.some((command) => command.cmd === '/mcpdraft')).toBe(true); expect(commands.some((command) => command.cmd === '/mcptool')).toBe(true); @@ -30,6 +33,18 @@ describe('aiSlashCommands', () => { expect(commands.map((command) => command.cmd)).not.toContain('/mcpadd'); }); + it('supports filtering builtin tool catalog diagnostics by keyword and command prefix', () => { + expect(filterAISlashCommands('工具目录').map((command) => command.cmd)).toContain('/tools'); + expect(filterAISlashCommands('参数提示').map((command) => command.cmd)).toContain('/tools'); + expect(filterAISlashCommands('/too').map((command) => command.cmd)).toContain('/tools'); + }); + + it('supports filtering context budget diagnostics by keyword and command prefix', () => { + expect(filterAISlashCommands('上下文').map((command) => command.cmd)).toContain('/budget'); + expect(filterAISlashCommands('变慢').map((command) => command.cmd)).toContain('/budget'); + expect(filterAISlashCommands('/bud').map((command) => command.cmd)).toContain('/budget'); + }); + it('supports filtering shortcut diagnostics by chinese keyword and command prefix', () => { expect(filterAISlashCommands('快捷键').map((command) => command.cmd)).toContain('/shortcuts'); expect(filterAISlashCommands('/sho').map((command) => command.cmd)).toContain('/shortcuts'); @@ -62,6 +77,13 @@ describe('aiSlashCommands', () => { expect(filterAISlashCommands('/mcpt').map((command) => command.cmd)).toContain('/mcptool'); }); + it('supports filtering mcp runtime failure diagnostics by keyword and command prefix', () => { + expect(filterAISlashCommands('运行期失败').map((command) => command.cmd)).toContain('/mcpfail'); + expect(filterAISlashCommands('工具发现0个').map((command) => command.cmd)).toContain('/mcpfail'); + expect(filterAISlashCommands('stdio').map((command) => command.cmd)).toContain('/mcpfail'); + expect(filterAISlashCommands('/mcpf').map((command) => command.cmd)).toContain('/mcpfail'); + }); + it('supports filtering mcp draft validation diagnostics by keyword and command prefix', () => { expect(filterAISlashCommands('MCP草稿').map((command) => command.cmd)).toContain('/mcpdraft'); expect(filterAISlashCommands('启动命令').map((command) => command.cmd)).toContain('/mcpdraft'); @@ -85,6 +107,9 @@ describe('aiSlashCommands', () => { expect(featured).toContain('/mcpadd'); expect(featured).toContain('/connfail'); expect(featured).toContain('/tx'); + expect(featured).not.toContain('/tools'); + expect(featured).not.toContain('/budget'); + expect(featured).not.toContain('/mcpfail'); expect(featured).not.toContain('/shortcuts'); }); }); diff --git a/frontend/src/components/ai/aiSlashCommands.ts b/frontend/src/components/ai/aiSlashCommands.ts index b3307d8..5017fe9 100644 --- a/frontend/src/components/ai/aiSlashCommands.ts +++ b/frontend/src/components/ai/aiSlashCommands.ts @@ -48,7 +48,10 @@ export const DEFAULT_AI_SLASH_COMMANDS: AISlashCommandDefinition[] = [ { cmd: '/schema', label: '🏗️ 表设计评审', desc: '评审表结构设计质量', prompt: '请全面评审当前关联表的设计,包括字段类型、范式、索引策略等方面的改进建议:', category: 'review', keywords: ['schema', '表结构', '设计'] }, { cmd: '/index', label: '📊 索引建议', desc: '推荐最优索引方案', prompt: '请基于当前表结构和常见查询场景,推荐最优的索引方案并给出建表语句:', category: 'review', keywords: ['index', '索引', '慢查询'] }, { cmd: '/health', label: '🩺 AI 配置体检', desc: '调用体检探针总览当前 AI 配置', prompt: '请先调用 inspect_ai_setup_health,对当前 GoNavi AI 配置做一次完整体检,然后总结 blockers、warnings 和 nextActions。', category: 'diagnose', featured: true, keywords: ['health', '体检', 'ai配置', '探针'] }, + { cmd: '/tools', label: '🧰 工具目录', desc: '按关键词选择该用哪个内置探针', prompt: '请先调用 inspect_ai_tool_catalog,按我的问题关键词筛选推荐流程、内置工具参数提示和当前 MCP 工具摘要,再告诉我下一步应该调用哪个工具。关键词:', category: 'diagnose', keywords: ['工具目录', '内置工具', 'toolcatalog', '参数提示', 'arguments', '探针路线'] }, + { cmd: '/budget', label: '🧠 上下文体量', desc: '诊断消息、DDL、MCP schema 和 Skills 体量', prompt: '请先调用 inspect_ai_context_budget,检查当前会话消息、工具结果、DDL、MCP schema、提示词和 Skills 的体量风险,并给出应该收窄哪些上下文。', category: 'diagnose', keywords: ['上下文', 'context', '体量', '预算', '变慢', '乱答', 'schema太大', '工具结果'] }, { cmd: '/mcp', label: '🪛 排查 MCP 接入', desc: '检查 MCP 服务和外部客户端状态', prompt: '请先调用 inspect_mcp_setup,帮我盘点当前 MCP 服务、工具发现结果,以及 Claude Code / Codex 本机客户端和 OpenClaw / Hermans 远程 Agent 的接入状态。', category: 'diagnose', featured: true, keywords: ['mcp', 'codex', 'claude', 'openclaw', 'hermans', '外部客户端'] }, + { cmd: '/mcpfail', label: '🧯 MCP 运行失败', desc: '读取 MCP 启动、发现和调用失败日志', prompt: '请先调用 inspect_mcp_runtime_failures,读取最近 MCP 启动、工具发现、工具调用、stdio、Docker 或 HTTP MCP 失败日志,结合当前 MCP 服务配置判断原因和 nextActions。关键词或服务名:', category: 'diagnose', keywords: ['mcpfail', 'mcp失败', '运行期失败', '工具发现0个', 'stdio', 'docker mcp', 'http mcp', '启动失败', '调用失败'] }, { cmd: '/mcpadd', label: '🧭 新增 MCP 指引', desc: '查看 command、args、env 和模板怎么填', prompt: '请先调用 inspect_mcp_authoring_guide;如果我贴了完整启动命令或草稿,再调用 inspect_mcp_draft 试算字段和校验问题;最后结合 inspect_mcp_setup,告诉我新增 GoNavi MCP 服务时 command、args、env、timeout 应该怎么填,以及最接近的模板应该选哪个。', category: 'diagnose', featured: true, keywords: ['mcp新增', 'command', 'args', 'env', '模板'] }, { cmd: '/mcpdraft', label: '🧪 MCP 草稿校验', desc: '校验一条 MCP 启动命令怎么拆', prompt: '请先调用 inspect_mcp_draft 校验我提供的 MCP fullCommand 或 command/args/env/timeout 草稿,返回自动拆分结果、启动预览、suggestedServerSeed、错误/告警和 nextActions;如果还缺字段说明,再补充调用 inspect_mcp_authoring_guide。', category: 'diagnose', keywords: ['mcp草稿', 'mcp校验', 'fullcommand', '启动命令', '参数拆分', 'command', 'args', 'env'] }, { cmd: '/mcptool', label: '🧩 MCP 工具参数', desc: '查看 MCP 工具 schema 和 arguments 写法', prompt: '请先调用 inspect_mcp_setup 找到当前已发现的 MCP 工具 alias;如果我已经给了工具名或关键词,再调用 inspect_mcp_tool_schema 读取对应 inputSchema,告诉我必填参数、字段类型、枚举值、嵌套路径,以及 arguments JSON 应该怎么写。', category: 'diagnose', keywords: ['mcp工具', 'mcp工具参数', 'schema', 'arguments', '参数', '工具调用', 'inputschema'] },