kyisaiah47/multiagent-code-review

GitHub: kyisaiah47/multiagent-code-review

基于 Qwen Cloud 的多 Agent 代码审查工具,通过五位专家 Agent 并发审查与辩论共识机制,为开发者提供全面的自动化代码质量报告。

Stars: 0 | Forks: 0

banner # 🤝 Multi-Agent 代码审查 **五位专家 AI agent 并发审查你的代码,对发现的问题进行辩论,并生成共识报告。** ![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white) ![Qwen](https://img.shields.io/badge/Qwen%20Cloud-AI%20Powered-6B46C1?style=for-the-badge) ![FastAPI](https://img.shields.io/badge/FastAPI-009688?style=for-the-badge&logo=fastapi&logoColor=white) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge)

Multi-Agent Code Review 协调五位专家 AI agent —— Static Analysis、Security、Performance、Documentation 和 Test Coverage —— 它们并发检查你的代码,并就有分歧的发现进行辩论。一个 Moderator agent 会运行最多三轮共识构建过程,并将任何未解决的问题升级以供人工审查。专为 [Global AI Hackathon with Qwen Cloud](https://qwenhackathon.devpost.com/)(赛道 3:Agent Society)而构建。 ## ✨ 功能 - **并发专家 agent** — 五个 agent 并行审查你的代码,每个 agent 专注于一个独立的关注点(风格、安全、性能、文档和测试覆盖率) - **辩论驱动共识** — Moderator agent 运行最多 3 轮结构化辩论,在展示冲突发现之前解决它们 - **人工升级** — 未解决的冲突会被明确标记以供人工审查,确保不会遗漏任何问题 - **CLI + REST API** — 直接从终端审查文件,或通过本地 FastAPI 服务器进行集成 - **Git diff 支持** — 将 `git diff` 输出与文件一起传入,以将审查重点集中在更改的内容上 - **丰富的终端输出** — 审查结果呈现为按严重程度排序的表格,并附带每个发现的面板,显示描述、建议、证据和共识状态 ## 🛠️ 技术栈 | 层级 | 技术 | |---|---| | 编排与协调 | `qwen-max` | | 专家 Agent | `qwen-plus` (×5) | | API Server | FastAPI | | 终端 UI | Rich | | 语言 | Python 3 | ### 架构 有关完整的系统图,请参见 [`architecture_diagram.md`](architecture_diagram.md)。 ``` Input: source file + optional git diff │ ▼ Orchestrator (qwen-max) │ dispatches concurrently ├── StaticAnalysisAgent (qwen-plus) ├── SecurityAgent (qwen-plus) ├── PerformanceAgent (qwen-plus) ├── DocumentationAgent (qwen-plus) └── TestCoverageAgent (qwen-plus) │ ▼ ModeratorAgent (qwen-max) │ up to 3 debate rounds on conflicting findings ▼ ConsensusResult ├── consensus_findings (agreed findings with severity + confidence) ├── unresolved_conflicts (escalated for human review) └── metrics (conflicts detected/resolved, human review flag) ``` ## 🚀 快速开始 ### 1. 安装 ``` python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt ``` ### 2. 配置 ``` cp .env.example .env # 在 .env 中设置 QWEN_API_KEY=your_key_here ``` ### 3. 审查文件 ``` # 审查文件 python main.py review path/to/file.py # 使用 git diff 进行审查 python main.py review path/to/file.py --diff "$(git diff HEAD~1 path/to/file.py)" ``` ### 4. 作为 API Server 运行 ``` python main.py serve # POST http://localhost:8000/review ``` ## ☁️ 部署 (Alibaba Cloud) 该项目附带了一个独立的部署脚本,用于 [Alibaba Cloud Function Compute v3](https://www.alibabacloud.com/product/function-compute):[`deploy/alibaba_cloud.py`](deploy/alibaba_cloud.py)。 该脚本使用 Alibaba Cloud 的 **FC** (Function Compute)、**ECS** 和 **credentials** SDK 来打包应用程序,创建或更新 Function Compute 服务,并配置 HTTP 触发器 —— 无需手动进行控制台操作。 **运行方式:** ``` python deploy/alibaba_cloud.py ``` 凭据从标准的 Alibaba Cloud 环境变量(`ALIBABA_CLOUD_ACCESS_KEY_ID`、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`)或从 `~/.alibabacloud/credentials` 中读取。 ## 📊 基准测试 一个可复现的基准测试套件位于 [`benchmarks/evaluate.py`](benchmarks/evaluate.py) 中。它针对三个示例文件(位于 `benchmarks/samples/` 中)运行完整的多 agent pipeline,这些文件包含一组已知的真实标准问题,然后报告每个专家 agent 和共识输出的**精确率**和**召回率**。 **运行基准测试:** ``` python benchmarks/evaluate.py ``` 结果以表格形式打印到 stdout。未使用任何 API 模拟 —— 基准测试会请求真实的 Qwen endpoint,因此在运行之前请确保已在你的 `.env` 中设置了 `QWEN_API_KEY`。 **致黑客松评委:** 这三个示例文件分别涵盖了安全漏洞、性能反模式和缺少文档的情况。预期的发现在 `evaluate.py` 中内联定义,以便您可以一目了然地验证评分逻辑。 ## 📄 许可证 MIT
标签:AI编程助手, AV绕过, FastAPI, Python, 代码审查, 多智能体, 无后门, 逆向工具, 通义千问