Documentation Index
Fetch the complete documentation index at: https://docs.megallm.io/llms.txt
Use this file to discover all available pages before exploring further.
RooCode 是一个功能强大的独立 AI 编程助手应用程序,具有交互式聊天界面、代码审查功能和多文件编辑能力。配置它以使用 MegaLLM 来访问多个 AI 模型。
快速配置
分步设置
打开 RooCode 设置
- 启动 RooCode 应用程序
- 点击齿轮图标 ⚙️(左下角)
- 导航至:
设置 → API 配置
选择提供商类型
- 提供商类型:选择
OpenAI Compatible
- 这将启用自定义基础 URL 配置
- 允许 MegaLLM 集成
配置 API 端点
- 基础 URL:
https://ai.megallm.io/v1
- API 密钥:
sk-mega-your-api-key-here
- 组织:留空(非必需)
- 点击 保存
选择默认模型
- 默认模型:
gpt-5
- 备用模型:
gpt-4o(可选)
- 温度:
0.7(平衡创造力)
- 最大令牌数:
4096
启用功能
- 代码补全
- 聊天界面
- 代码审查
- 重构助手
- 多文件编辑
直接编辑文件
配置文件位置:%APPDATA%\RooCode\config.json
# 完整路径: C:\Users\YourName\AppData\Roaming\RooCode\config.json
配置内容:{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "sk-mega-your-api-key-here",
"organization": "",
"model": "gpt-5",
"temperature": 0.7,
"maxTokens": 4096
},
"features": {
"codeCompletion": true,
"chatInterface": true,
"codeReview": true,
"refactoring": true,
"multiFileEdit": true
},
"ui": {
"theme": "dark",
"showInlineHints": true,
"autoSaveChats": true,
"fontSize": 14
}
}
编辑配置文件后,请重启 RooCode 以使更改生效。
导入预制配置
步骤 1:创建 roocode-megallm-config.json{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "REPLACE_WITH_YOUR_KEY",
"model": "gpt-5"
},
"features": {
"codeCompletion": true,
"chatInterface": true,
"codeReview": true,
"refactoring": true
}
}
步骤 2:在 RooCode 中导入
- 打开 RooCode
- 转到:
文件 → 导入配置
- 选择您的
roocode-megallm-config.json
- 将
REPLACE_WITH_YOUR_KEY 替换为实际的 API 密钥
- 点击 应用
- 重启 RooCode
配置导入成功!
场景示例
场景 1:首次安装
从下载到首次使用的完整设置:
下载并安装 RooCode
- 访问 RooCode.io(示例 URL)
- 为您的操作系统下载(Windows/macOS/Linux)
- 安装应用程序
- 启动 RooCode
获取 MegaLLM API 密钥
- 访问 MegaLLM 控制台
- 注册或登录
- 导航至 API 密钥 部分
- 点击 创建新密钥
- 复制密钥(以
sk-mega- 开头)
配置 API 提供商
在 RooCode 中:
- 点击 ⚙️ 设置图标
- 转到 API 配置
- 选择 提供商:
OpenAI Compatible
- 输入 基础 URL:
https://ai.megallm.io/v1
- 粘贴 API 密钥:
sk-mega-your-key
- 点击 测试连接(应显示 ✓ 成功)
- 点击 保存
选择您的第一个模型
- 在设置 → 模型选择
- 选择:
gpt-5(推荐用于一般用途)
- 或浏览可用模型
- 设置 温度:
0.7(平衡)
- 保存设置
测试配置
- 在 RooCode 中打开新聊天
- 输入:
你好!你在使用什么模型?
- 应该会响应模型信息
- 尝试:
编写一个 Python 的 hello world 函数
预期响应:def hello_world():
print("Hello, World!")
if __name__ == "__main__":
hello_world()
场景 2:团队共享配置设置
为整个开发团队设置 RooCode:
**场景:**10 人开发团队需要一致的 RooCode 配置
步骤 1:团队负责人创建基础配置
team-roocode-config.json:
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "TEAM_MEMBER_REPLACES_THIS",
"model": "gpt-5",
"temperature": 0.7,
"maxTokens": 4096
},
"features": {
"codeCompletion": true,
"chatInterface": true,
"codeReview": true,
"refactoring": true,
"multiFileEdit": true
},
"projectSettings": {
"language": "typescript",
"framework": "react",
"codingStyle": "airbnb",
"testFramework": "jest"
},
"customPrompts": {
"review": "Review this code following our team's Airbnb style guide and best practices",
"test": "Generate Jest unit tests with at least 80% coverage",
"doc": "Generate JSDoc comments for this function",
"refactor": "Refactor this code for better maintainability and TypeScript strict mode"
},
"ui": {
"theme": "dark",
"showInlineHints": true,
"autoSaveChats": true,
"fontSize": 14
}
}
步骤 2:创建设置说明
ROOCODE_SETUP.md:
# RooCode 团队设置指南
## 前提条件
- 已安装 RooCode 应用程序([下载](https://roocode.io))
- MegaLLM API 密钥([获取您的密钥](https://megallm.io/dashboard))
## 设置步骤
### 1. 获取您的个人 API 密钥
1. 访问 https://megallm.io/dashboard
2. 导航至 **API 密钥**
3. 点击 **创建新密钥**
4. 复制您的密钥(以 `sk-mega-` 开头)
### 2. 导入团队配置
1. 从此仓库下载 `team-roocode-config.json`
2. 打开 RooCode
3. 转到:`文件 → 导入配置`
4. 选择 `team-roocode-config.json`
### 3. 添加您的个人 API 密钥
1. 导入后,转到:`设置 → API 配置`
2. 将 `TEAM_MEMBER_REPLACES_THIS` 替换为您的实际密钥
3. 点击 **测试连接**(应显示 ✓ 成功)
4. 点击 **保存**
### 4. 重启 RooCode
关闭并重新打开 RooCode 以应用所有设置。
## 验证
1. 打开新聊天
2. 输入:`生成一个登录表单的 React 组件`
3. 应生成遵循 Airbnb 风格的 TypeScript 代码
## 故障排除
- **连接失败**:检查 API 密钥是否正确
- **代码风格错误**:验证配置是否正确导入
- **模型错误**:确保使用 `gpt-5` 或其他支持的模型
## 支持
联系团队负责人或查看 [MegaLLM 文档](https://docs.megallm.io)
步骤 3:分发给团队
# 团队负责人提交到仓库
git add team-roocode-config.json ROOCODE_SETUP.md
git commit -m "添加 RooCode 团队配置"
git push
# 团队成员克隆并设置
git pull
# 遵循 ROOCODE_SETUP.md 中的说明
**结果:**整个团队使用一致的:
- 相同的 AI 模型(gpt-5)
- 相同的温度和设置
- 相同的自定义提示
- 相同的编码标准
- 个人 API 密钥(不共享)
场景 3:项目特定配置
为不同项目类型使用不同的 RooCode 配置:
Python 数据科学项目:
roocode-datascience.json:
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "${env:MEGALLM_API_KEY}",
"model": "claude-opus-4-1-20250805",
"temperature": 0.5
},
"projectSettings": {
"language": "python",
"libraries": ["numpy", "pandas", "scikit-learn", "matplotlib"],
"codingStyle": "pep8"
},
"customPrompts": {
"analyze": "Analyze this data processing code for efficiency and correctness",
"optimize": "Optimize this pandas operation for large datasets",
"visualize": "Suggest matplotlib visualization for this data",
"doc": "Generate numpy-style docstring"
}
}
React Web 应用程序:
roocode-webapp.json:
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "${env:MEGALLM_API_KEY}",
"model": "gpt-5",
"temperature": 0.7
},
"projectSettings": {
"language": "typescript",
"framework": "react",
"stateManagement": "zustand",
"styling": "tailwind"
},
"customPrompts": {
"component": "Generate a React functional component with TypeScript and Tailwind",
"test": "Write React Testing Library tests for this component",
"hook": "Create a custom React hook for this functionality",
"api": "Generate API integration with tanstack-query"
}
}
系统编程(Rust):
roocode-systems.json:
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "${env:MEGALLM_API_KEY}",
"model": "gemini-2.5-pro",
"temperature": 0.3
},
"projectSettings": {
"language": "rust",
"codingStyle": "rust-fmt"
},
"customPrompts": {
"review": "Review this Rust code for memory safety and performance",
"optimize": "Suggest optimizations for this performance-critical code",
"test": "Generate comprehensive Rust tests",
"unsafe": "Analyze this unsafe block for correctness"
}
}
项目间切换:
# 在 ~/.bashrc 或 ~/.zshrc 中创建别名
alias roocode-ds='cp ~/configs/roocode-datascience.json ~/.config/RooCode/config.json && roocode'
alias roocode-web='cp ~/configs/roocode-webapp.json ~/.config/RooCode/config.json && roocode'
alias roocode-sys='cp ~/configs/roocode-systems.json ~/.config/RooCode/config.json && roocode'
场景 4:从 Cursor/其他 AI 工具迁移
从另一个 AI 编码工具切换到 RooCode 与 MegaLLM:
当前设置:使用 Cursor 与 OpenAI
为什么切换到 RooCode + MegaLLM:
- 使用一个密钥访问多个模型(GPT、Claude、Gemini)
- 独立应用程序(不依赖特定编辑器)
- 更好的定价且无席位限制
- 更多自定义选项
迁移步骤:
导出当前偏好设置
从 Cursor(如果可能):
- 记录您偏好的模型
- 保存任何自定义提示
- 记录您使用的键盘快捷键
安装 RooCode
为您的操作系统下载并安装 RooCode
配置 MegaLLM
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "sk-mega-your-megallm-key",
"model": "gpt-5"
}
}
重建自定义提示
添加您常用的提示:{
"customPrompts": {
"explain": "详细解释此代码",
"fix": "查找并修复此代码中的错误",
"improve": "为此代码提出改进建议"
}
}
测试功能
并排比较:
- 在两个工具中打开相同的代码
- 提出相同的问题
- 比较代码生成质量
- 评估响应速度
对比表:
| 功能 | Cursor | RooCode + MegaLLM |
|---|
| 编辑器集成 | VS Code 分支 | 独立 + 任何编辑器 |
| 可用模型 | GPT-4、GPT-3.5 | GPT、Claude、Gemini 等 |
| API 密钥 | 仅 OpenAI | 一个密钥适用所有模型 |
| 定价 | 按席位订阅 | 按使用付费 |
| 自定义 | 有限 | 广泛 |
| 离线模式 | 否 | 否 |
场景 5:多模型工作流
为不同类型的任务使用不同的模型:
带模型配置文件的配置:
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "sk-mega-your-api-key-here",
"model": "gpt-5"
},
"modelProfiles": {
"fast": {
"model": "gpt-4o-mini",
"temperature": 0.5,
"maxTokens": 1000,
"description": "简单任务的快速补全"
},
"balanced": {
"model": "gpt-5",
"temperature": 0.7,
"maxTokens": 4096,
"description": "平衡的质量和速度"
},
"quality": {
"model": "claude-opus-4-1-20250805",
"temperature": 0.3,
"maxTokens": 8192,
"description": "复杂任务的最高质量"
},
"creative": {
"model": "gpt-5",
"temperature": 0.9,
"maxTokens": 4096,
"description": "创意文档和命名"
},
"analysis": {
"model": "claude-sonnet-4",
"temperature": 0.4,
"maxTokens": 6000,
"description": "代码审查和分析"
}
}
}
工作流示例:
上午:快速原型开发
→ 切换到 "fast" 配置文件(gpt-4o-mini)
→ 快速代码生成
→ 快速迭代
下午:生产代码
→ 切换到 "quality" 配置文件(claude-opus-4)
→ 生成生产就绪代码
→ 全面的错误处理
代码审查时间
→ 切换到 "analysis" 配置文件(claude-sonnet-4)
→ 详细的代码审查
→ 安全分析
文档编写
→ 切换到 "creative" 配置文件(gpt-5,高温度)
→ 生成吸引人的文档
→ 创意命名建议
在 RooCode 中切换配置文件:
- 点击模型下拉菜单(顶部栏)
- 选择配置文件:Fast / Balanced / Quality / Creative / Analysis
- 配置文件应用于当前会话
场景 6:CI/CD 集成
在 CI/CD 中使用 RooCode API 进行自动化代码审查:
GitHub Actions 示例:
.github/workflows/roocode-review.yml:
name: AI Code Review with RooCode
on:
pull_request:
types: [opened, synchronize]
jobs:
ai-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup RooCode CLI
run: |
curl -O https://roocode.io/cli/install.sh
bash install.sh
- name: Configure MegaLLM
env:
MEGALLM_API_KEY: ${{ secrets.MEGALLM_API_KEY }}
run: |
mkdir -p ~/.config/RooCode
cat > ~/.config/RooCode/config.json << EOF
{
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "$MEGALLM_API_KEY",
"model": "claude-sonnet-4"
}
}
EOF
- name: Run AI Code Review
run: |
roocode review \
--files "$(git diff --name-only origin/main...HEAD)" \
--output review.md
- name: Post Review Comment
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## AI Code Review\n\n${review}`
});
配置选项
完整参考
{
// API Configuration
"provider": "openai-compatible",
"api": {
"baseURL": "https://ai.megallm.io/v1",
"apiKey": "sk-mega-your-api-key-here",
"organization": "",
"model": "gpt-5",
"temperature": 0.7,
"maxTokens": 4096,
"topP": 0.9,
"frequencyPenalty": 0.0,
"presencePenalty": 0.0,
"timeout": 30000
},
// Feature Toggles
"features": {
"codeCompletion": true,
"chatInterface": true,
"codeReview": true,
"refactoring": true,
"multiFileEdit": true,
"contextAwareness": true,
"autoSave": true
},
// Project Settings
"projectSettings": {
"language": "typescript",
"framework": "react",
"codingStyle": "airbnb",
"testFramework": "jest",
"linter": "eslint"
},
// Custom Prompts
"customPrompts": {
"review": "Review code for bugs and best practices",
"test": "Generate comprehensive unit tests",
"doc": "Generate detailed documentation",
"refactor": "Refactor for better maintainability",
"optimize": "Optimize for performance",
"secure": "Analyze for security vulnerabilities"
},
// UI Preferences
"ui": {
"theme": "dark",
"fontSize": 14,
"fontFamily": "Fira Code",
"showInlineHints": true,
"showLineNumbers": true,
"autoSaveChats": true,
"chatPosition": "right",
"enableAnimations": true
},
// Keyboard Shortcuts
"shortcuts": {
"newChat": "Cmd+N",
"sendMessage": "Cmd+Enter",
"clearChat": "Cmd+K",
"switchModel": "Cmd+M",
"openSettings": "Cmd+,"
},
// Advanced
"advanced": {
"logLevel": "info",
"cacheResponses": true,
"maxChatHistory": 100,
"contextWindowSize": 8000,
"streamResponses": true
}
}
模型选择指南
| 任务 | 推荐模型 | 原因 |
|---|
| 快速补全 | gpt-4o-mini | 最快、经济实惠 |
| 代码审查 | claude-sonnet-4 | 出色的分析能力 |
| 复杂逻辑 | claude-opus-4-1-20250805 | 卓越的推理能力 |
| Web 开发 | gpt-5 | 最适合 JS/TS/React |
| 文档编写 | gpt-5 | 清晰、引人入胜的写作 |
| 数据科学 | claude-sonnet-4 | 擅长 pandas/numpy |
| 系统代码 | gemini-2.5-pro | 精确、数学化 |
测试 1:聊天功能
- 打开 RooCode
- 点击 新建聊天
- 输入:
编写一个函数,按属性对对象数组进行排序
- 应该收到可工作的代码
预期响应:
function sortByProperty(array, property) {
return array.sort((a, b) => {
if (a[property] < b[property]) return -1;
if (a[property] > b[property]) return 1;
return 0;
});
}
测试 2:代码审查
- 粘贴此代码:
def divide(a, b):
return a / b
- 点击 审查代码 按钮
- 应识别出:缺少零除检查
测试 3:多文件编辑
- 打开多文件视图
- 请求:“为所有 API 调用添加错误处理”
- 应显示多个文件的更改
- 审查并应用更改
测试 4:连接状态
检查状态指示器(右上角):
- 🟢 绿色 = 已连接到 MegaLLM
- 🟡 黄色 = 连接中…
- 🔴 红色 = 连接失败
点击状态查看:
- 模型:
gpt-5
- 端点:
https://ai.megallm.io/v1
- 令牌使用情况:当前会话统计
故障排除
症状:
- “无法连接到 API”
- 请求在 30 秒后超时
- 聊天消息无法发送
解决方案:
-
验证基础 URL 是否正确:
https://ai.megallm.io/v1 <Icon icon="check" /> 正确
https://ai.megallm.io <Icon icon="xmark" /> 缺少 /v1
https://api.openai.com/v1 <Icon icon="xmark" /> 错误的端点
-
测试连接:
# 测试连接
curl -I https://ai.megallm.io/v1/models
# 应返回: HTTP/2 200
-
检查防火墙:
- 允许 RooCode 通过防火墙
- 检查企业代理设置
- 验证没有 VPN 阻止
-
增加超时时间:
{
"api": {
"timeout": 60000 // 增加到 60 秒
}
}
-
手动测试 API 密钥:
curl -X POST https://ai.megallm.io/v1/chat/completions \
-H "Authorization: Bearer $MEGALLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"test"}]}'
症状:
- “无效的 API 密钥” 错误
- 401 未授权
- 身份验证失败
解决方案:
-
验证密钥格式:
- 必须以
sk-mega- 开头
- 应为 60+ 个字符
- 没有额外的空格或换行符
- 配置文件中实际密钥周围没有引号
-
检查密钥是否激活:
- 登录到 控制台
- 转到 API 密钥
- 验证密钥显示为”活动”
- 检查它未被撤销或过期
-
重新输入密钥:
- 从控制台复制密钥
- 从 RooCode 设置中删除旧密钥
- 粘贴新密钥
- 保存并重启 RooCode
-
直接测试密钥:
curl -H "Authorization: Bearer sk-mega-your-actual-key" \
https://ai.megallm.io/v1/models
# 应返回模型的 JSON 列表
症状:解决方案:
-
提供更好的上下文:
- 在设置中设置项目语言
- 添加框架信息
- 使用自定义提示
-
调整温度:
{
"api": {
"temperature": 0.3 // 降低 = 更专注(代码用 0.2-0.4)
}
}
-
尝试不同的模型:
{
"api": {
"model": "claude-sonnet-4" // 更好的分析
}
}
-
增加最大令牌数:
{
"api": {
"maxTokens": 8192 // 更长、更完整的响应
}
}
-
使用具体的提示:
{
"customPrompts": {
"generate": "生成遵循最佳实践的生产就绪 TypeScript 代码"
}
}
症状:
- RooCode 启动时崩溃
- 长响应期间冻结
- UI 无响应
解决方案:
-
检查系统资源:
- 关闭其他应用程序
- 确保有 4GB+ RAM 可用
- 检查 CPU 使用率
-
减少最大令牌数:
{
"api": {
"maxTokens": 2048 // 从 8192 减少
}
}
-
禁用流式传输:
{
"advanced": {
"streamResponses": false
}
}
-
清除缓存:
# Windows
rmdir /s "%APPDATA%\RooCode\cache"
# macOS/Linux
rm -rf ~/Library/Application\ Support/RooCode/cache
rm -rf ~/.config/RooCode/cache
-
重新安装 RooCode:
- 备份 config.json
- 卸载 RooCode
- 下载最新版本
- 安装并恢复配置
最佳实践
模型配置文件
为不同任务设置配置文件:fast、quality、creative
高级技巧
环境变量
RooCode 支持环境变量替换:
{
"api": {
"apiKey": "${env:MEGALLM_API_KEY}",
"baseURL": "${env:MEGALLM_BASE_URL}"
}
}
设置变量:
export MEGALLM_API_KEY="sk-mega-your-key"
export MEGALLM_BASE_URL="https://ai.megallm.io/v1"
上下文管理
通过更好的上下文改进响应:
{
"advanced": {
"contextWindowSize": 16000,
"includeProjectStructure": true,
"includeOpenFiles": true,
"maxRelevantFiles": 10
}
}
响应缓存
通过智能缓存节省 API 成本:
{
"advanced": {
"cacheResponses": true,
"cacheExpiry": 3600, // seconds
"maxCacheSize": 100 // MB
}
}
下一步
Kilocode 设置
配置 Kilocode VSCode 扩展
Cline 设置
配置 Cline VSCode 扩展