kalyan-1845/ai-code-reviewer

GitHub: kalyan-1845/ai-code-reviewer

一款基于大语言模型的 AI 代码审查工具,能够自动分析 GitHub 仓库与 Pull Request 中的 bug、安全漏洞和性能问题,并提供文档生成、复杂度分析与仓库对话等功能。

Stars: 9 | Forks: 19

# 🚀 RepoSage — AI 驱动的开发者 Copilot ### _自动化代码审查 · 安全扫描 · 文档生成 · 仓库智能分析_ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](LICENSE) [![GSSoC '26](https://img.shields.io/badge/GSSoC%20'26-Contributor%20Program-orange?style=for-the-badge&logo=opensourceinitiative&logoColor=white)](https://gssoc.girlscript.tech/) [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/) [![React](https://img.shields.io/badge/React-19-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev/) [![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org/) [![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen?style=for-the-badge)](CONTRIBUTING.md)
开发者花费 **60% 的时间** 来阅读和审查代码。**RepoSage** 利用 AI 实现了这一过程的自动化 —— 在几秒钟内分析整个 GitHub 仓库,找出 bug、安全漏洞和性能瓶颈,并生成详尽的文档。
[📖 文档](./API.md) · [🐛 报告 Bug](https://github.com/kalyan-1845/ai-code-reviewer/issues) · [💡 请求功能](https://github.com/kalyan-1845/ai-code-reviewer/issues) · [🤝 参与贡献](CONTRIBUTING.md)
## 📋 目录 - [✨ 功能](#-features) - [🏗️ 架构](#️-architecture) - [🛠️ 技术栈](#️-tech-stack) - [⚡ 快速开始](#-quick-start) - [🤖 GitHub Action 集成](#-github-action-integration) - [📊 API 参考](#-api-reference) - [🗺️ 路线图](#️-roadmap) - [🤝 贡献指南](#-contributing) - [👥 贡献者](#-contributors) - [📜 许可证](#-license) ## ✨ 功能
### 🔍 AI 代码审查 由 LLM (Llama 3、DeepSeek、Google Gemma) 提供支持,自动检测 bug、反模式、性能瓶颈和代码风格违规。 ### 🛡️ 安全扫描器 基于正则表达式的凭据检测,可找出 API key、私钥、Twilio token、AWS secret 以及常见的 `.env` 文件泄漏。
### 📝 README 生成器 一键自动为任何仓库生成全面且结构清晰的文档。 ### 📊 复杂度指标 静态分析计算每个文件的代码行数、注释密度、函数数量以及复杂度评级 (A–F)。
### 🌐 13+ 种语言 全面支持 Python、JavaScript、TypeScript、Java、Go、Rust、C++、C#、PHP、Ruby、SQL、HTML 和 CSS。 ### 🎨 现代化仪表板 精美的 React 仪表板,具备明亮/深色主题、文件树搜索、交互式指标以及一键导出 HTML 报告功能。
### 🤖 GitHub Action Bot 开箱即用的 GitHub Action,可直接在你的 Pull Request 上逐行发布内联的 AI 审查评论。 ### 💬 AI 仓库对话 使用自然语言询问任何关于代码库的问题 —— _"解释一下身份验证流程"_、_"API 路由在哪里?"_
## 🏗️ 架构 ``` graph TB subgraph Frontend["🎨 Frontend (React + Vite)"] UI[Dashboard UI] Theme[Theme Toggle] FileNav[File Navigator] Metrics[Metrics Panel] end subgraph Backend["⚙️ Backend (Node.js + Express)"] API[REST API] Clone[Repo Cloner] Scanner[Security Scanner] Analyzer[Complexity Analyzer] Reporter[Report Exporter] end subgraph AIEngine["🧠 AI Engine (Python + FastAPI)"] LLM[LLM Integration] Prompt[Prompt Manager] Models[Llama · DeepSeek · Gemma] end subgraph GitHubAction["🤖 GitHub Action"] Webhook[PR Webhook] Reviewer[Inline Reviewer] end UI --> API API --> Clone Clone --> Scanner Clone --> Analyzer API --> LLM LLM --> Prompt Prompt --> Models API --> Reporter Webhook --> Reviewer Reviewer --> API ``` 该项目分为 **四个独立模块**: | 模块 | 技术 | 描述 | |--------|------|-------------| | **Frontend** | React 19 + Vite + Vanilla CSS | 交互式仪表板,支持主题切换、文件搜索和指标可视化 | | **Backend** | Node.js 18 + Express | 提供 REST API,用于仓库克隆、安全扫描、复杂度分析和报告导出 | | **AI Engine** | Python 3.10 + FastAPI | 基于 LLM 的代码审查、bug 检测和 README 生成 | | **GitHub Action** | Bundled JS Runner | 自动化的 PR 审查 Bot,在 GitHub 上发布内联评论 | ## 🛠️ 技术栈
| 层级 | 技术 | |:------|:-------------| | **Frontend** | ![React](https://img.shields.io/badge/React-61DAFB?style=flat-square&logo=react&logoColor=black) ![Vite](https://img.shields.io/badge/Vite-646CFF?style=flat-square&logo=vite&logoColor=white) ![CSS3](https://img.shields.io/badge/CSS3-1572B6?style=flat-square&logo=css3&logoColor=white) ![Lucide](https://img.shields.io/badge/Lucide_Icons-F56565?style=flat-square) | | **Backend** | ![Node.js](https://img.shields.io/badge/Node.js-339933?style=flat-square&logo=nodedotjs&logoColor=white) ![Express](https://img.shields.io/badge/Express-000000?style=flat-square&logo=express&logoColor=white) ![REST API](https://img.shields.io/badge/REST_API-005571?style=flat-square) | | **AI Engine** | ![Python](https://img.shields.io/badge/Python-3776AB?style=flat-square&logo=python&logoColor=white) ![FastAPI](https://img.shields.io/badge/FastAPI-009688?style=flat-square&logo=fastapi&logoColor=white) ![Groq](https://img.shields.io/badge/Groq_API-FF6B35?style=flat-square) | | **AI Models** | ![Llama](https://img.shields.io/badge/Llama_3-0467DF?style=flat-square&logo=meta&logoColor=white) ![DeepSeek](https://img.shields.io/badge/DeepSeek-4A90D9?style=flat-square) ![Gemma](https://img.shields.io/badge/Google_Gemma-4285F4?style=flat-square&logo=google&logoColor=white) | | **DevOps** | ![GitHub Actions](https://img.shields.io/badge/GitHub_Actions-2088FF?style=flat-square&logo=githubactions&logoColor=white) ![Git](https://img.shields.io/badge/Git-F05032?style=flat-square&logo=git&logoColor=white) |
## ⚡ 快速开始 ### 前置条件 - **Node.js** ≥ 18 & **npm** ≥ 9 - **Python** ≥ 3.10 & **pip** - **Git** - 一个免费的 **[Groq API Key](https://console.groq.com/keys)** ### 1. 克隆仓库 ``` git clone https://github.com/kalyan-1845/ai-code-reviewer.git cd ai-code-reviewer ``` ### 2. Backend 配置 ``` cd backend npm install cp .env.example .env # Add your GROQ_API_KEY npm run dev # Starts on http://localhost:5000 ``` ### 3. AI Engine 配置 ``` cd ai-engine pip install -r requirements.txt uvicorn app:app --reload # Starts on http://localhost:8000 ``` ### 4. Frontend 配置 ``` cd frontend npm install npm run dev # Starts on http://localhost:3000 ``` ## 🤖 GitHub Action 集成 只需 2 分钟,即可将自动化的 AI 代码审查添加到 **任何仓库**: ``` # .github/workflows/reposage-review.yml name: RepoSage AI Reviewer on: pull_request: types: [opened, synchronize] jobs: review: runs-on: ubuntu-latest permissions: pull-requests: write steps: - name: Checkout Code uses: actions/checkout@v4 - name: Run RepoSage AI PR Audit uses: kalyan-1845/ai-code-reviewer/github-action@main with: github-token: ${{ secrets.GITHUB_TOKEN }} groq-api-key: ${{ secrets.GROQ_API_KEY }} ``` 该 Bot 会自动在每一个新的 PR 上发布逐行的内联审查评论! ## 📊 API 参考 有关包含请求/响应示例的完整 endpoint 文档,请参阅 **[API.md](./API.md)**。 | Endpoint | Method | 描述 | |----------|--------|-------------| | `/api/analyze` | `POST` | 分析 GitHub 仓库 | | `/api/reports/html` | `POST` | 将审查报告导出为 HTML | | `/api/chat` | `POST` | 使用 AI 与仓库进行对话 | | `/analyze` | `POST` | AI Engine 直接分析 (FastAPI) | ## 🗺️ 路线图 请参阅我们完整的 **[ROADMAP.md](./ROADMAP.md)** 以获取详细的项目路线图。 | 阶段 | 状态 | 亮点 | |-------|--------|------------| | **阶段 1**:MVP | ✅ 已完成 | 仓库导入、AI 审查、README 生成、仪表板 UI | | **阶段 2**:核心增强 | ✅ 已完成 | 13+ 种语言、报告导出、安全扫描器、模型选择 | | **阶段 3**:高级功能 | ✅ 已完成 | AI 仓库对话、架构图、PR Bot、复杂度指标 | | **阶段 4**:社区与扩展 | 🚧 进行中 | 审查历史、PDF 导出、设置弹窗、组合图表 | | **阶段 5**:企业版 | 📋 计划中 | 团队工作区、RBAC、VS Code 扩展、SARIF 导出 | ## 📜 许可证 该项目基于 **MIT License** 授权 —— 详情请参阅 [LICENSE](LICENSE) 文件。
**由 [Bhoompally Kalyan Reddy](https://github.com/kalyan-1845) 和开源社区 ❤️ 构建。** _RepoSage —— 让每次审查变得更智能,逐个仓库地改变代码审查。_
标签:AI代码审查, GNU通用公共许可证, MITM代理, Node.js, React, SOC Prime, Syscalls, Sysdig, 开发工具, 自动化攻击, 逆向工具, 错误基检测, 静态代码分析