# Node.js 18+
node --version
# npm
npm --versionnpm install# Windows
npm install -g opencode-ai
# Linux/macOS
curl -fsSL https://opencode.ai/install | bashnpm start这将自动启动 OpenCode 后端 (如果需要) 并启动代理服务。
cp config.json.example config.json| 命令 | 说明 |
|---|---|
npm test -- --runInBand |
运行所有测试 |
npm run test:unit |
运行单元测试 |
npm run test:integration |
运行集成测试 |
# 构建并运行
docker compose up -d --build
# 查看日志
docker compose logs -f项目使用 ESLint (如有配置):
npm run lint使用 Conventional Commits:
feat: add new feature
fix: fix bug
docs: update documentation
refactor: refactor code
test: add tests
chore: update build/ci
OpenCode2API/
├── src/
│ └── proxy.js # 核心代理逻辑
├── tests/
│ ├── app.test.js # 单元测试
│ ├── test-integration.sh # 集成测试
│ └── test-streaming-real.sh # 流式测试
├── docs/ # 文档
├── index.js # 入口文件
├── package.json # 项目配置
├── Dockerfile # Docker 镜像
└── docker-compose.yml # Docker Compose
- ⭐ Fork 项目
- 🌿 创建功能分支:
git checkout -b feature/your-feature - 💾 提交更改:
git commit -m 'feat: add new feature' - 📤 推送分支:
git push origin feature/your-feature - 🔀 创建 Pull Request
MIT License - 详见 LICENSE