使用说明
副驾驶技能集评审员
具有多IDE集成的AI驱动的代码审查和合规系统
概述
Copilot Skillset Reviewer是一个全面的人工智能代码审查和合规性检查系统,提供:
- 多接口架构:HTTP API服务器、MCP服务器集成和VS代码扩展
- 智能代码分析:GitHub存储库与自动规则加载的集成
- 合规性检查:自动检测机密、许可证标头、测试存在和安全漏洞
- 多IDE支持:适用于GitHub Copilot、Cursor、WindSurf、Claude Code和VS Code
- 捆绑式指导包:为各种合规框架预先配置的规则集
主要特点
- GitHub应用程序集成:支持webhook的存储库软件技能集API
- MCP服务器:基于stdio的JSON-RPC用于Claude集成
- VS代码扩展:状态栏包切换器、引导预览和包跳转
- 确定性合规性检查:秘密检测、测试存在验证、许可证标头验证
- 捆绑规则包:
baseline-secure,oss-apache-2,enterprise-strict,pci-dss,pii-redaction,design-doc-reviewer - GitHub操作集成:自动PR评论和带有文件注释的检查运行
快速开始
先决条件
- Node.js:版本20.0.0或更高版本
- npm:版本9.0.0或更高版本
- TypeScript:5.5.0或更高版本
- 码头工人:(可选)用于集装箱化部署
安装
# Clone the repository
git clone https://github.com/armoin-llc/copilot-skillset-reviewer.git
cd copilot-skillset-reviewer
# Install dependencies
npm install
# Build the project
npm run build
开发设置
# Start HTTP API server in development mode
npm run dev # Starts server on http://localhost:8080
# Start MCP server for Claude integration
npm run mcp # JSON-RPC over stdio
# Build and run VS Code extension
npm run ext:install # Install extension dependencies
npm run ext:build # Build the extension
npm run ext:package # Package for installation
测试
# Run all tests
npm test
# Run tests with coverage report
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run specific test suites
npm run test:unit # Unit tests only
npm run test:integration # Integration tests only
API文档
HTTP API终结点
服务器在端口8080上公开一个REST API(可通过 PORT 环境变量):
核心终点
GET /healthz-健康检查端点(在100ms内响应)POST /load-rules-从GitHub存储库或捆绑包加载编码规则POST /summarize-rules-从规则文档中生成可操作的检查表POST /normalize-diff-解析并规范统一的差异格式POST /assert-compliance-对代码更改进行全面的合规性检查
交互式文档
服务器运行时,请访问 http://localhost:8080/docs 用于Swagger UI提供的交互式API文档。
MCP服务器集成
对于Claude Code和其他MCP兼容客户端:
npm run mcp # Starts MCP server on stdio
VS代码扩展
该扩展提供:
- 状态栏包切换器:在导航包之间切换
- 指导预览:预览规则内容和检查表
- 打包棉绒:验证指导包结构
配置
环境变量
# Server Configuration
PORT=8080 # HTTP server port (default: 8080)
NODE_ENV=production # Environment mode
# GitHub Integration
GH_APP_ID=123456 # GitHub App ID
GH_APP_PRIVATE_KEY=... # GitHub App private key (PEM format)
# Optional Configuration
LOG_LEVEL=info # Logging level (debug, info, warn, error)
CORS_ORIGIN=* # CORS allowed origins
GitHub应用程序设置
-
创建GitHub应用程序:
- 转到GitHub→ 设置→ 开发人员设置→ GitHub应用程序→ 新GitHub应用程序
- 选择 从清单创建GitHub应用程序
-
使用应用清单:
# Upload .github/app/app-manifest.json or paste its contents -
完成设置:
# You'll receive a one-time code, then run: node scripts/create-github-app-from-manifest.mjs <one-time-code> -
配置环境:
- 保存私钥文件
- 集
GH_APP_ID和GH_APP_PRIVATE_KEY在你的.env文件
Docker部署
Docker快速入门
# Build and run with docker-compose
docker compose up -d
# Or build manually
make build # Builds armoin2018/copilot-skillset:v0.9.0
make push # Push to registry (requires login)
# Run the container
docker run -p 8080:8080 -e PORT=8080 armoin2018/copilot-skillset:v0.9.0
容器配置
Docker镜像支持:
- 基本图像:
node:20-alpine最小攻击面 - 多阶段构建:优化的生产映像<200MB
- 健康检查:内置容器健康监测
- 安全:非root用户执行
生产部署
# Production build with version tagging
make build # Builds armoin2018/copilot-skillset:v0.9.0
make tag-latest # Tag as :latest
make push-all # Push both versioned and latest tags
开发指南
项目结构
├── src/ # TypeScript source code
│ ├── server.ts # HTTP API server
│ ├── mcp.ts # MCP server implementation
│ ├── lib.ts # Skills interface library
│ ├── rules.ts # Rule processing engine
│ ├── diff.ts # Diff parsing utilities
│ ├── assert.ts # Compliance checking
│ ├── github.ts # GitHub API integration
│ └── bundled.ts # Bundled pack management
├── tests/ # Test suites
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── setup.ts # Test configuration
├── bundled/ # Pre-packaged guidance packs
├── vscode-extension/ # VS Code extension source
├── .claude/ # Claude Code integration
│ ├── agents/
│ │ ├── instructions/ # Language-specific instructions
│ │ └── personas/ # Role-based personas
│ └── claude-instructions.md
└── docs/ # Additional documentation
添加新功能
- 先创建测试:在中添加测试用例
tests/unit/或tests/integration/ - 机具功能:适当增加执行
src/模块 - 更新文档:更新README.md并添加内联代码文档
- 验证覆盖范围:确保满足>80%的测试覆盖率要求
- 更新API文档:为新端点添加OpenAPI规范
代码的风格
- TypeScript严格模式:所有代码都必须通过严格的类型检查
- ESLint合规性:代码必须通过linting检查
- 预处理格式:强制执行一致的代码格式
- 测试覆盖率:要求最低80%的覆盖率
- 文档:所有公共API的JSDoc注释
故障排除
常见问题
服务器无法启动:
- 检查端口8080是否可用
- 验证Node.js版本是否为20.0.0或更高版本
- 确保安装了所有依赖项(
npm install)
GitHub集成失败:
- 验证
GH_APP_ID和GH_APP_PRIVATE_KEY设置正确 - 检查GitHub应用程序是否具有所需的权限
- 确保使用 webhooks 时可访问 webhook URL
MCP服务器连接问题:
- 验证克劳德代码MCP配置
- 检查一下
npm run mcp启动时没有错误 - 验证JSON-RPC消息格式
测试失败:
- 跑
npm run build确保TypeScript编译成功 - 检查中的测试环境设置
tests/setup.ts - 验证是否安装了所有测试依赖项
获取帮助
- 问题:报告错误 GitHub问题
- 文档:参见
CLAUDE.md建筑细节 - api参考:参观
/docs服务器运行时的终结点 - 发展:检查
.claude/agents/针对特定角色的指导
贡献
- 分叉存储库:在GitHub上创建自己的fork
- 创建特征分支:
git checkout -b feature/your-feature-name - 添加测试:确保全面的测试覆盖率
- 运行质量检查:
npm test && npm run build - 提交拉取请求:包括对变更的清晰描述
开发标准
- 遵循现有的代码模式和架构
- 保持API更改的向后兼容性
- 更新所有更改的文档
- 确保所有测试通过,覆盖率保持在80%以上
- 对版本使用语义版本控制
许可证
该项目根据MIT许可证获得许可。看 许可证 文件以获取详细信息。
有关详细的技术文档,请参阅 CLAUDE.md
