开发指南
贡献指南
如何为 OpenCowork 贡献代码。
贡献指南 / Contributing
欢迎为 OpenCowork 贡献代码!以下是参与贡献的指南。
开始之前 / Before You Start
- Fork AIDotNet/OpenCowork
- 克隆你的 Fork:
git clone https://github.com/YOUR_USERNAME/OpenCowork.git - 搭建开发环境:参见 开发环境搭建
开发流程 / Development Workflow
# 创建功能分支
git checkout -b feature/your-feature-name
# 开发并测试
npm run dev
# 类型检查
npm run typecheck
# 代码规范检查
npm run lint
# 提交
git commit -m "feat: add your feature"
# 推送并创建 PR
git push origin feature/your-feature-nameCommit 规范 / Commit Convention
使用 Conventional Commits 规范:
| 类型 | 说明 |
|---|---|
feat | 新功能 |
fix | Bug 修复 |
docs | 文档更新 |
refactor | 代码重构 |
chore | 构建/工具链变更 |
添加新工具 / Adding a New Tool
- 在
src/renderer/src/lib/tools/创建工具文件 - 实现
ToolHandler接口 - 在
src/renderer/src/App.tsx的工具注册处添加
// 工具实现示例
export const myTool: ToolHandler = {
definition: {
name: 'MyTool',
description: '工具描述',
input_schema: {
type: 'object',
properties: {
param: { type: 'string', description: '参数说明' }
},
required: ['param']
}
},
async execute(input, ctx) {
const { param } = input as { param: string }
// 实现逻辑
return { type: 'text', text: `结果: ${param}` }
}
}添加新插件 / Adding a New Plugin
- 在
src/main/channels/providers/创建平台目录 - 实现
MessagingChannelService接口 - 在
ChannelManager中注册工厂
问题反馈 / Reporting Issues
在 GitHub Issues 提交问题,请包含:
- 操作系统和版本
- OpenCowork 版本
- 复现步骤
- 错误日志(
~/.open-cowork/crash.log)