感谢有兴趣为 WindsurfAPI 贡献代码。本文档说明环境准备、代码规范与 PR 流程。
- Node.js ≥ 20
- Windsurf Language Server 二进制文件 (
language_server_linux_x64),默认放在/opt/windsurf/ - 不需要
npm install—— 项目零 npm 依赖,只用node:*内置模块
git clone https://github.com/<your-fork>/WindsurfAPI.git
cd WindsurfAPI
# 快速启动(前台)
node src/index.js
# 开发模式(文件变更自动重启)
node --watch src/index.js服务默认监听 http://0.0.0.0:3003,Dashboard 在 /dashboard。
- 不要添加任何
npm install <xxx>。需要 HTTP/protobuf/crypto 功能?用node:https/ 手写 varint /node:crypto - 这是项目的设计取舍:安全面小、启动快、部署简单
package.json里的dependencies字段必须保持为空(CI 会校验)
- ES modules (
import/export),不用 CommonJS - 注释使用英文,Dashboard UI 用简体中文
- 变量命名用 camelCase,类用 PascalCase
- 错误日志一律走
log.info/warn/error/debug(来自src/config.js)
参考 ARCHITECTURE.md 的模块划分。新增功能建议:
- HTTP 路由入口 →
src/server.js - 请求处理逻辑 →
src/handlers/*.js - Dashboard 后端 API →
src/dashboard/api.js - Dashboard 前端 →
src/dashboard/index.html - 持久化状态 → 写单独的
*.json文件(加入.gitignore)
采用 Conventional Commits 格式:
feat: 新功能
fix: 修 bug
docs: 文档
refactor: 重构(不影响功能)
perf: 性能优化
test: 测试
chore: 构建/脚手架
示例:
feat(dashboard): add token usage export/import endpoints
fix(cascade): handle panel-state-not-found on Send retry
提交 PR 前请确认:
-
find src -name '*.js' -exec node --check {} \;全部通过 - 没有引入 npm 依赖
- 没有硬编码路径、IP、凭证
- 新增功能在 README 和/或 ARCHITECTURE.md 中有说明
- 敏感文件(
accounts.json/stats.json/.env/logs//data/)没有被提交
目前项目没有正式的单元测试套件,但关键路径的验证办法:
# 启动服务
node src/index.js &
# 基本可用性
curl -fsS http://localhost:3003/health
curl -fsS http://localhost:3003/v1/models | head -20
# Dashboard 登录
curl -H "X-Dashboard-Password: $DASHBOARD_PASSWORD" \
http://localhost:3003/dashboard/api/statscurl -sS http://localhost:3003/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"say hi"}],"stream":false}'- Bug:GitHub Issues,请附上
logs/error-*.jsonl的最近几行 - 功能建议:Issues 里贴上使用场景
- 安全漏洞:请私下邮件联系维护者,不要公开在 Issues
贡献代码等同同意以 MIT 许可证发布。