本指南将帮助您在5分钟内完成 CodeRocket 的安装和配置,立即开始享受AI驱动的代码审查体验。
在开始之前,请确保您的系统满足以下要求:
- 操作系统: macOS, Linux, 或 Windows (WSL)
- Node.js: 版本 >= 14.0.0
- Git: 版本 >= 2.0.0
- 网络连接: 能够访问互联网和AI服务API
# 一键安装脚本
curl -fsSL https://raw.githubusercontent.com/im47cn/coderocket-cli/main/install.sh | bash安装过程中会提示选择安装模式,建议选择"全局安装":
- ✅ 新项目自动启用
- ✅ 提供全局命令
- ✅ 一次安装,终身受益
# 克隆项目
git clone https://github.com/im47cn/coderocket-cli.git
cd coderocket-cli
# 运行安装脚本
./install.sh
# 选择"项目安装"模式选择并配置一个AI服务:
# 安装Gemini CLI
npm install -g @google/gemini-cli
# 配置API密钥
gemini config
# 按提示输入您的Google AI Studio API密钥# OpenCode
npm install -g @opencode/cli
opencode config
# ClaudeCode
npm install -g @anthropic-ai/claude-code
claudecode config如果需要自动创建MR功能:
# 设置GitLab访问令牌
export GITLAB_PERSONAL_ACCESS_TOKEN="your-gitlab-token"
# 或者创建项目配置文件
echo "GITLAB_PERSONAL_ACCESS_TOKEN=your-gitlab-token" > .env获取GitLab Token:
- 登录GitLab → Settings → Access Tokens
- 创建新令牌,权限选择:
api,read_repository,write_repository
# 全局安装验证
coderocket --version
# 项目安装验证
ls -la .git/hooks/
./lib/ai-service-manager.sh status# 测试Gemini
gemini --version
echo "测试提示" | gemini
# 测试其他服务
opencode --version
claudecode --version- 修改代码:
# 在您的项目中修改任意文件
echo "console.log('Hello CodeRocket!');" >> test.js- 提交代码:
git add test.js
git commit -m "feat: 添加测试代码"- 查看审查结果:
# 审查报告会自动生成在 review_logs/ 目录
ls review_logs/
cat review_logs/最新的审查报告.md- 创建功能分支:
git checkout -b feature/my-first-feature- 提交更改:
git add .
git commit -m "feat: 我的第一个功能"- 推送并创建MR:
git push origin feature/my-first-feature
# 系统会自动提示是否创建MR# 交互式选择
./lib/ai-config.sh select
# 直接设置
echo "AI_SERVICE=gemini" > .ai-config# 创建项目级提示词文件
mkdir -p prompts
cp ~/.coderocket/prompts/git-commit-review-prompt.md prompts/
# 编辑自定义规则
vim prompts/git-commit-review-prompt.md创建 .env 文件:
# AI服务配置
AI_SERVICE=gemini
# GitLab配置
GITLAB_PERSONAL_ACCESS_TOKEN=your-token
GITLAB_API_URL=https://gitlab.com/api/v4
# 调试模式
DEBUG=false# 1. 全局安装
curl -fsSL https://raw.githubusercontent.com/im47cn/coderocket-cli/main/install.sh | bash
# 2. 配置Gemini
gemini config
# 3. 开始编码
git add .
git commit -m "feat: 新功能"
# 自动触发代码审查# 1. 项目级安装
git clone https://github.com/im47cn/coderocket-cli.git
./install.sh
# 2. 团队配置
cp .env.example .env
# 编辑 .env 设置团队共享的配置
# 3. 协作开发
git checkout -b feature/team-feature
git commit -m "feat: 团队功能"
git push origin feature/team-feature
# 自动创建MR# GitHub Actions 示例
- name: Setup CodeRocket
run: |
curl -fsSL https://raw.githubusercontent.com/im47cn/coderocket-cli/main/install.sh | bash
echo "AI_SERVICE=gemini" > .ai-config
- name: Run Code Review
run: ./githooks/post-commit# 查看当前服务
./lib/ai-service-manager.sh status
# 切换服务
./lib/ai-config.sh set AI_SERVICE opencode
# 测试新服务
./lib/ai-service-manager.sh test# 审查最近5个提交
for i in {1..5}; do
git checkout HEAD~$i
./githooks/post-commit
done# 检查服务状态
./lib/ai-service-manager.sh status
# 重新配置
gemini config --reset# 检查权限
chmod +x .git/hooks/post-commit
chmod +x .git/hooks/pre-push
# 重新安装
./install-hooks.sh# 检查配置
echo $GITLAB_PERSONAL_ACCESS_TOKEN
# 重启终端或IDE现在您已经成功安装并配置了 CodeRocket,建议继续学习:
- 定期更新:
# 检查更新
coderocket update- 备份配置:
# 备份重要配置
cp -r ~/.coderocket ~/.coderocket.backup- 团队标准化:
# 使用项目级配置确保团队一致性
cp .env.example .env
git add .env.example您已经成功完成了 CodeRocket 的快速入门!现在您可以:
- ✅ 享受AI驱动的自动代码审查
- ✅ 获得详细的代码质量报告
- ✅ 自动创建智能的GitLab MR
- ✅ 提升代码质量和开发效率
开始您的智能代码审查之旅吧! 🚀✨