代码审查工具

DiffPilot是一个本地AI代码审查工具,帮助开发者在提交代码前进行自我审查,支持自动分支检测、秘密扫描等功能。

  • by bkalafat
  • C#
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 bkalafat/DiffPilot

使用说明

🔍 DiffPilot 的

推送前对本地AI代码进行审查


💡 为什么选择DiffPilot?

在创建PR之前,请在本地检查您的代码。 DiffPilot是一个MCP服务器,可以让您:

  1. PR前的自我审查 -在上次提交后,在推送之前,对本地更改进行AI代码审查
  2. 审阅者工作流程 -作为代码审查员,在本地签出源代码分支并获得人工智能辅助审查
  3. 自动分支检测 -无需指定 main -DiffPilot会自动查找您的基础分支

🔒 100%本地 -没有云,没有外部API。适用于Azure DevOps、TFS、气隙环境。


🚀 快速开始

安装

# VS Code Marketplace
ext install BurakKalafat.diffpilot

# Or NuGet (.NET tool)
dotnet tool install -g DiffPilot

与GitHub Copilot一起使用

# Review my changes (auto-detects base branch)
@workspace #review_pr_changes

# Review with focus areas
@workspace #review_pr_changes focus on security and error handling

# Generate commit message
@workspace #generate_commit_message

# Scan for secrets before committing
@workspace #scan_secrets

🛠️ 9 MCP工具

公关审查工具

工具 示例提示
#get_pr_diff “显示我的分支和主分支之间的差异”
#review_pr_changes “检查我的PR是否存在安全问题”
#generate_pr_title “生成常规PR标题”
#generate_pr_description “使用检查表创建PR描述”

开发者工具

工具 示例提示
#generate_commit_message “为阶段性更改生成提交消息”
#scan_secrets “在我的更改中检查API密钥”
#diff_stats “显示更改统计信息”
#suggest_tests “我应该写什么测试?”
#generate_changelog “根据提交生成更改日志”

✨ 主要特点

特性 描述
🔄 自动分支检测 自动查找 main, master,或 develop
🔐 秘密扫描 检测API密钥、密码、令牌、JWT
📊 差异统计 添加/删除行,按类型细分文件
🧪 测试建议 基于模式的测试用例建议
📝 约定式提交 生成 feat:, fix:, refactor: 信息
🛡️ 企业安全 银行级输入验证、利率限制、输出净化

🛡️ 安全

DiffPilot实现了企业级安全功能:

安全功能 描述
输入验证 根据严格模式验证所有参数
预防注射 命令注入、路径遍历保护
输出消毒 自动编辑工具输出中的机密
速率限制 防止DoS攻击(120请求/分钟)
安全错误 没有向客户披露内部细节
审计日志 记录到stderr的安全事件

自动修正模式: API密钥、AWS凭据、GitHub/Slack令牌、JWT、密码、私钥、连接字符串。

看 安全.md 获取完整文档。


📋 用例

公关前的自我评估

# After finishing your work, before creating PR:
@workspace #review_pr_changes

# AI reviews your changes and provides feedback
# Fix issues locally, then push with confidence

2.代码审阅者工作流程

# Checkout the feature branch locally
git checkout feature/user-auth

# Use DiffPilot to review
@workspace #review_pr_changes focus on security

# Get structured review with AI assistance

3.预提交秘密检查

@workspace #scan_secrets

# Catches API keys, passwords, tokens before they're committed

⚙️ 配置

{
  "diffpilot.defaultBaseBranch": "main",
  "diffpilot.prTitleStyle": "conventional",
  "diffpilot.commitMessageStyle": "conventional"
}

📦 安装选项

方法 命令
VS代码 ext install BurakKalafat.diffpilot
NuGet dotnet tool install -g DiffPilot
手册 git clone + dotnet build

要求: .NET 9 SDK,VS代码1.101+,Git


📜 版本历史

1.2.0 (2025-12-09)

  • 安全强化 -银行级安全功能
    • 输入验证(CWE-20)
    • 命令注入预防(CWE-78)
    • 路径遍历保护(CWE-22)
    • 输出净化-自动编辑机密(CWE-200)
    • 速率限制(CWE-400)
    • 安全错误处理
  • 添加了SECURITY.md文档
  • 80个新的安全单元测试

1.1.5 (2025-12-08)

  • 更新了README中的用例和 #tool 提示
  • 突出显示的自动分支检测

1.1.4 (2025-12-07)

  • 图标优化

1.1.3 (2025-12-07)

  • 新的扩展图标(带加号/减号的镜头)

1.1.2 (2025-12-07)

  • 优化包装尺寸

1.1.1 (2025-12-07)

  • 更新了扩展图标

1.1.0 (2025-12-07)

  • 改进了工具文档

1.0.9 (2025-12-07)

  • 已修复:服务器使用工作区文件夹进行git操作

1.0.8 (2025-12-07)

  • 简化工具描述,打造更简洁的用户界面

1.0.7 (2025-12-07)

  • 已修复:捆绑服务器包含TargetFramework

1.0.6 (2025-12-07)

  • 修复:MCP自动注册VS代码1.101+

1.0.5 (2025-12-07)

  • 发布到NuGet和MCP注册表

1.0.0 (2025-12-06)

  • 初始版本包含9个MCP工具

📄 许可证

MIT许可证- 布拉克 卡拉法特


GitHub • VS代码市场 • 纽吉特

⭐ 星如果有用!