Skip to content

sshnuke3/mimo-code-reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mimo-Code-Reviewer

🤖 基于小米 MiMo V2.5 大模型的全栈代码审查平台

Python 3.10+ MIT License

🚀 核心功能

功能 描述
🔒 安全审查 SQL注入、XSS、密码硬编码、命令注入等漏洞检测
📊 代码质量 重复代码、函数过长、命名规范、错误处理
性能分析 N+1查询、内存泄漏、复杂循环、异步问题
🏗️ 设计模式 SOLID原则、设计模式检测、架构审查
🧪 测试生成 单元测试、集成测试、测试计划生成
📖 文档生成 API文档、README、CHANGELOG、贡献指南
🌐 Web Dashboard 可视化代码审查平台

🏗️ 系统架构

┌─────────────────────────────────────────────────────────────┐
│                      Mimo-Code-Reviewer                       │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────┐  ┌──────────┐  ┌──────────┐  ┌─────────────┐   │
│  │ Review  │  │ Design   │  │  Test    │  │    Doc      │   │
│  │ Agent   │  │ Agent    │  │  Agent   │  │   Agent     │   │
│  │ 🔍审查  │  │ 🏗️架构   │  │ 🧪测试   │  │  📖文档     │   │
│  └────┬────┘  └────┬─────┘  └────┬─────┘  └──────┬──────┘   │
│       └────────────┴────────────┴──────────────┘           │
│                          │                                   │
│               ┌──────────┴──────────┐                      │
│               │    MiMo V2.5 API     │                      │
│               │   (小米大模型推理)    │                      │
│               └─────────────────────┘                      │
├─────────────────────────────────────────────────────────────┤
│  CLI (命令行)  │  Web Dashboard  │  GitHub PR 集成         │
└─────────────────────────────────────────────────────────────┘

📦 Agent 矩阵

Agent 输入 输出
Reviewer 代码文件 漏洞列表 + 修复建议
DesignReviewer 代码 + 架构上下文 设计模式建议 + 架构评分
TestGenerator 源代码 可运行的测试代码
DocGenerator 代码/API定义 文档字符串/API参考
PRReviewer GitHub PR PR评论 + 审查报告

🛠️ 快速开始

安装

git clone https://github.com/sshnuke3/mimo-code-reviewer.git
cd mimo-code-reviewer
pip install -r requirements.txt

设置 API Key

export MIMO_API_KEY="你的小米MiMo API Key"
export GITHUB_TOKEN="你的GitHub Token(可选,用于PR集成)"

CLI 用法

# 代码审查
python -m cli.unified review ./src/main.py --task security

# 设计模式审查
python -m cli.unified design ./src/manager.py

# 生成测试
python -m cli.unified test ./src/api.py --framework pytest

# 生成文档
python -m cli.unified doc ./src/utils.py

# 启动 Web Dashboard
python -m cli.unified serve --port 5001

Web Dashboard

启动后访问 http://localhost:5001/dashboard

python -m cli.unified serve

功能:

  • 粘贴代码即时审查
  • 多维度切换(安全/质量/性能/设计)
  • 历史记录
  • 报告导出

GitHub PR 集成

from github.pr_client import PRReviewer
from core.mimo_client import MimoClient

client = MimoClient(api_key="your-key")
reviewer = PRReviewer(
    owner="your-org",
    repo="your-repo", 
    pr_number=123,
    github_token="ghp_xxx",
    mimo_client=client
)

reviewer.review_and_comment()

📁 项目结构

mimo-code-reviewer/
├── agents/                 # AI Agent 实现
│   ├── reviewer.py         # 主审查 Agent
│   ├── design_agent.py     # 设计模式审查
│   ├── test_agent.py       # 测试生成
│   └── doc_agent.py         # 文档生成
├── core/                   # 核心模块
│   ├── mimo_client.py       # MiMo API 客户端
│   └── models.py            # 数据模型
├── github/                 # GitHub 集成
│   └── pr_client.py         # PR 审查客户端
├── cli/                    # 命令行工具
│   ├── main.py             # 原始入口
│   └── unified.py           # 统一入口
├── web/                    # Web 服务
│   └── app.py              # Flask Dashboard
├── tests/                  # 测试
├── README.md
├── requirements.txt
└── config.yaml

🎯 审查维度

安全审查 (Security)

  • 🔴 Critical: 远程代码执行、敏感数据泄露
  • 🟠 High: SQL注入、XSS、认证绕过
  • 🟡 Medium: 密码弱加密、不安全依赖
  • 🔵 Low: 信息泄露、配置问题

代码质量 (Quality)

  • 重复代码检测
  • 函数/类长度检查
  • 命名规范检查
  • 注释覆盖率
  • 圈复杂度分析

性能分析 (Performance)

  • N+1 查询问题
  • 内存泄漏识别
  • 不必要的循环
  • 缓存利用率
  • 异步/并发问题

设计模式 (Design)

  • SOLID 原则检查
  • 设计模式建议
  • 耦合度分析
  • 重构计划生成

📊 输出示例

$ python -m cli.unified review ./src/main.py

🔍 Mimo-Code-Reviewer 代码审查
📂 路径: ./src/main.py
🎯 维度: all

✅ 审查完成!
📊 评分: 78.5/100
📁 文件: 3 | 🐛 问题: 7
   🔴 严重: 1
   🟠 高危: 2
   🟡 中危: 3

📋 审查摘要:
发现1个严重安全漏洞(密码硬编码),建议立即修复...

🌐 API 服务

# 启动 API 服务
python web/app.py

# 调用示例
curl -X POST http://localhost:5001/review \
  -H "Content-Type: application/json" \
  -d '{"code": "import os\npassword = \"hardcoded\"", "file_path": "test.py", "task": "security"}'

🔧 配置

config.yaml 中配置:

mimo:
  api_key: "your-key"
  api_base: "https://api.mimimo.com/v1"
  model: "MiMo-V2.5-Pro"

review:
  max_file_size: 10000
  parallel_workers: 3
  timeout: 60

📝 License

MIT


🦞 Powered by Xiaomi MiMo V2.5

About

基于小米MiMo大模型的AI代码审查智能体系统

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages