阿波罗特工
█████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
██╔══██╗██╔══██╗██╔═══██╗██║ ██║ ██╔═══██╗
███████║██████╔╝██║ ██║██║ ██║ ██║ ██║
██╔══██║██╔═══╝ ██║ ██║██║ ██║ ██║ ██║
██║ ██║██║ ╚██████╔╝███████╗███████╗╚██████╔╝
╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝具有语义代码理解和结构化推理的AI驱动编码代理
Apollo Agent将尖端的MCP(模型上下文协议)服务器与OpenRouter LLM集成在一起,为软件开发任务提供智能、上下文感知的帮助。它结合了语义代码分析(Serena)、结构化问题解决(Sequential Thinking)和强大的语言模型,在深层次上理解和操纵代码库。
🎯 特性
- 🔍 语义代码分析 -通过Serena MCP了解代码结构、符号和关系
- 🧠 结构化推理 -系统地计划和执行多步骤任务
- 📚 知识库 -在整个会话中保持上下文和学习
- 🔧 终端集成 -使用智能sudo处理执行命令
- 📊 符号索引 -快速代码导航和搜索
- 🎨 丰富的CLI界面 -美观、信息丰富的终端输出
🚀 快速开始
先决条件
必修的:
可选:
- OpenRouter API密钥(买一个)
安装
# Clone the repository
git clone https://github.com/AlexandrosLiaskos/apollo-agent.git
cd apollo-agent
# Install dependencies
npm install
# Configure environment
cp .env.example .env
nano .env # Add your OPENROUTER_API_KEY
# Start Apollo
npm start首次运行
在首次创业时,阿波罗将:
- 初始化Serena MCP服务器(通过
uvx) - 初始化顺序思维MCP服务器
- 连接到OpenRouter
- 创建终端会话
- 加载可用工具(来自MCP服务器的30+)
█████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
██╔══██╗██╔══██╗██╔═══██╗██║ ██║ ██╔═══██╗
███████║██████╔╝██║ ██║██║ ██║ ██║ ██║
██╔══██║██╔═══╝ ██║ ██║██║ ██║ ██║ ██║
██║ ██║██║ ╚██████╔╝███████╗███████╗╚██████╔╝
╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝
AI Agent with MCP Integration
✔ OpenRouter initialized (model: anthropic/claude-sonnet-4)
✔ Connected to all MCP servers
✔ Loaded 30 tools from MCP servers
? 🚀 Task (or "exit" to quit):📖 用法
交互模式
Apollo提供了一个交互式CLI,您可以在其中:
分配任务:
? 🚀 Task: Refactor the UserService class to use async/await使用命令:
status - Show agent status
tasks - View current task list
knowledge - List knowledge entries
symbols - Show symbol index stats
search - Search for symbols
help - Show all commands
exit - Quit Apollo示例任务
代码分析:
? Task: Find all uses of the calculateTotal function
? Task: Show me the structure of the UserController class
? Task: List all API endpoints in this project代码修改:
? Task: Add error handling to the login method
? Task: Convert all var declarations to const/let
? Task: Add TypeScript types to user.js系统操作:
? Task: Install and configure the axios package
? Task: Update all dependencies to latest versions
? Task: Set up ESLint with standard config🛠️ 配置
环境变量
编辑 .env:
# OpenRouter Configuration (REQUIRED)
OPENROUTER_API_KEY=your_api_key_here
# Model Selection (optional)
OPENROUTER_MODEL=anthropic/claude-sonnet-4
# Sudo Configuration (see below)
SUDO_MODE=auto # auto | nopasswd | interactive | passwordSudo命令
Apollo可以执行sudo命令。通过配置 SUDO_MODE:
选项1:自动(默认)
SUDO_MODE=auto首先尝试无密码的sudo,如果需要,可以回退到交互式。
选项2:无密码Sudo(推荐)
# Configure system for passwordless package management
sudo visudo
# Add (replace 'user' with your username):
user ALL=(ALL) NOPASSWD: /usr/bin/pacman
user ALL=(ALL) NOPASSWD: /usr/bin/apt-get
user ALL=(ALL) NOPASSWD: /usr/bin/dnf
# Then in .env:
SUDO_MODE=nopasswd选项3:互动
SUDO_MODE=interactive需要时,Apollo会暂停并提示输入密码。
选项4:Env中的密码(⚠️ 不太安全)
SUDO_MODE=password
SUDO_PASSWORD=your_password仅用于磁盘加密的个人发展。
📚 建筑
核心组件
核心代理 (src/agent/apollo-agent.js)
- 主代理编排
- 任务规划和执行
- 工具协调
MCP集成 (src/mcp/serena-client.js)
- 连接到Serena(语义代码分析)
- 连接到顺序思维(结构化推理)
- 工具注册和执行
LLM提供者 (src/providers/openrouter.js)
- OpenRouter API集成
- 流媒体支持
- 多型号支持
终端工具 (src/tools/terminal-tool.js)
- 命令执行
- Sudo处理
- 会话管理
知识库 (src/agent/knowledge-base.js)
- 持久内存存储
- 上下文积累
- 跨课程学习
符号索引 (src/agent/symbol-index.js)
- 快速代码符号搜索
- 文件索引
- 符号关系
MCP服务器
Serena MCP (奥拉奥斯/塞雷娜)
- 语义代码操作
- 符号导航
- 智能代码编辑
- 内存管理
顺序思维MCP (@模型上下文协议/服务器顺序思维)
- 逐步推理
- 计划验证
- 结构化问题解决
🔧 发展
项目结构
apollo-agent/
├── src/
│ ├── index.js # Entry point
│ ├── agent/
│ │ ├── apollo-agent.js # Main agent
│ │ ├── task-manager.js # Task tracking
│ │ ├── knowledge-base.js # Memory system
│ │ └── symbol-index.js # Code indexing
│ ├── mcp/
│ │ └── serena-client.js # MCP client manager
│ ├── providers/
│ │ └── openrouter.js # LLM provider
│ ├── session/
│ │ └── session-manager.js # Session persistence
│ ├── tools/
│ │ ├── api-tools.js # Tool registry
│ │ └── terminal-tool.js # Command execution
│ └── ui/
│ └── rich-output.js # CLI interface
├── package.json
├── .env.example
└── README.md在发展中奔跑
# Watch mode (auto-restart on changes)
npm run dev
# Standard mode
npm start添加自定义工具
- 实施工具
src/tools/ - 注册
ToolRegistry(src/tools/api-tools.js) - 添加到代理工具列表
扩展LLM提供商
- 在中创建提供程序类
src/providers/ - 实施
chat()和chatStream()方法 - 更新代理初始化
🐛 故障排除
“Serena MCP连接失败”
原因: uv 未安装或未在PATH中
修复:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Verify
uv --version“OpenRouter API错误”
原因: API密钥无效或丢失
修复:
# Get API key from https://openrouter.ai/keys
# Add to .env:
echo "OPENROUTER_API_KEY=sk-or-..." >> .env“找不到命令:apollo”
原因: 未全局安装
修复:
# Option 1: Use npm start
npm start
# Option 2: Install globally
npm install -g .
apollo“sudo:需要密码”
原因: 未配置无密码sudo
修复:
# Configure in .env:
SUDO_MODE=interactive
# Or setup passwordless sudo (see Configuration section)📊 系统要求
| 组件 | 最小值 | 推荐 |
|---|---|---|
| 操作系统 | Linux,macOS | Arch Linux,Ubuntu 22.04+ |
| Node.js | 18.0.0 | 20.0.0+ |
| 随机存取存储器 | 2GB | 4GB+ |
| 存储 | 500MB | 1GB+ |
| 网络 | 必需 | 高速 |
🤝 贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add amazing feature') - 推送到分支(
git push origin feature/amazing-feature) - 打开拉取请求
📄 许可证
MIT许可证-请参阅 许可证 详细信息文件
🙏 致谢
- Serena MCP -语义代码操作
- 模型上下文协议 -MCP规范
- OpenRouter -LLM API聚合
- 安thropic克劳德 -默认语言模型
📞 支持
- 问题:
- 讨论:
______________________________________________________________________
内置于❤️ 亚历山德罗斯·利亚斯科斯
