本文档介绍如何参与 Copilot Shell 的开发。
- Node.js ≥ 20
- npm ≥ 9
- Git
git clone https://github.com/alibaba/anolisa.git
cd src/copilot-shellmake deps此命令会执行 npm install 并初始化 Husky Git hooks。
make build构建使用 esbuild,产物输出到各包的 dist/ 目录。
# 直接运行构建产物
node packages/cli/dist/index.js
# 或使用 npm script
cd packages/cli && npm startmake lint包含 ESLint 和类型检查。
项目使用 Prettier 进行代码格式化。编辑器保存时自动格式化, 或手动运行:
npx prettier --write .make test测试框架为 vitest,测试文件与源码同目录,命名为 *.test.ts。
| 包 | 路径 | 职责 |
|---|---|---|
@copilot-shell/cli |
packages/cli/ |
命令行入口和 TUI |
@copilot-shell/core |
packages/core/ |
核心引擎 |
@copilot-shell/test-utils |
packages/test-utils/ |
测试工具 |
- 使用 ESM(
"type": "module") - 导出统一通过各包的
src/index.ts - 类型声明与实现分离(
types.ts)
遵循项目根目录的提交规范,scope 为 cosh:
feat(cosh): add --json flag to config command
fix(cosh): handle empty model response gracefully
每次提交前确保通过:
make lint
make testHusky pre-commit hook 会自动执行 lint 检查。
- 在
packages/cli/src/commands/下创建命令文件 - 实现
Command接口 - 在命令注册处导入并注册
- 添加对应的单元测试
- 在
packages/core/src/tools/下创建工具定义 - 实现工具的
execute方法 - 在工具注册表中注册
- 添加审批分类(哪些审批模式下需要确认)
- 编写集成测试
- 在
packages/core/src/hooks/中定义事件类型 - 实现事件的输入/输出 schema
- 在 agent loop 的对应位置触发事件
- 编写单元测试
- 更新 Hook 开发文档
集成测试位于 integration-tests/ 目录:
# 运行所有集成测试
cd integration-tests && npm test
# 运行特定测试
npx vitest run integration-tests/hooks/发布通过 /cosh-dev release 技能自动完成:
- 更新版本号
- 生成 CHANGELOG
- 构建并验证
- 创建 Git tag
- 推送到远程