关于 open-code-review
Open Code Review 是一个面向 AI 生成代码的开源质量门禁工具,可检测虚构的导入、过时 API、过度设计和安全反模式。它提供 ocr 命令行、CI/CD 集成和 MCP 服务,适合希望在本地或 CI 中审查 AI 代码的团队。
主要功能
- 01检测虚构导入并核对 npm、PyPI、Maven、Go 包库
- 02识别过时 API 与过度设计模式
- 03支持 TypeScript、Python、Java、Go、Kotlin 等 6 种语言
- 04可通过 Ollama 本地运行深度 LLM 分析
- 05提供 ocr heal 自动修复建议
- 06支持 JSON、SARIF、HTML 等输出格式
适用场景
- 01在 CI/CD 流水线中为 AI 生成的 PR 设置质量门禁
- 02开源维护者审查合并前的 AI 生成代码
- 03在 Cursor 或 Claude Desktop 中通过 MCP 服务调用扫描
MCP 相关
该项目提供 MCP 服务,向 MCP 客户端暴露 ocr_scan、ocr_heal 和 ocr_explain 三个工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
4收录的工具列表 · 更新于 3 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| path | string | 是 | 要扫描的目录路径 |
| level | enum | 否 | SLA 级别:L1(快速结构检查)、L2(标准检查 + 本地 AI)、L3(深度检查 + 远程 AI)L1 | L2 | L3 |
| languages | string | 否 | 以逗号分隔的语言(例如 'typescript,python')。如果省略,则自动检测。 |
详细介绍
Open Code Review
首个专为 AI 生成代码打造的开源 CI/CD 质量门禁。 检测幻觉导入、过时 API、过度设计和安全反模式——由本地 LLM 和任何兼容 OpenAI 的提供商提供支持。 免费。可自托管。支持 6 种语言。

兼容工具
任何能生成代码的 AI 工具都适用——只要它写代码,OCR 就会审查。
AI 代码检查工具会漏掉什么
AI 编码助手(Copilot、Cursor、Claude)生成的代码包含传统工具完全检测不到的缺陷:
| 缺陷 | 示例 | ESLint / SonarQube |
|---|---|---|
| 幻觉导入 | import { x } from 'non-existent-pkg' | ❌ 漏检 |
| 过时 API | 使用训练数据中的已弃用 API | ❌ 漏检 |
| 上下文窗口产物 | 跨文件的逻辑矛盾 | ❌ 漏检 |
| 过度设计的模式 | 不必要的抽象、死代码 | ❌ 漏检 |
| 安全反模式 | 硬编码的示例密钥、eval() | ❌ 部分漏检 |
Open Code Review 可检测所有这些问题——支持6 种语言,且免费。
演示

快速预览
$ ocr scan src/ --sla L3
╔══════════════════════════════════════════════════════════════╗
║ Open Code Review — Deep Scan Report ║
╚══════════════════════════════════════════════════════════════╝
Project: packages/core/src
SLA: L3 Deep — Structural + Embedding + LLM Analysis
112 issues found in 110 files
Overall Score: 67/100 D
Threshold: 70 | Status: FAILED
Files Scanned: 110 | Languages: typescript | Duration: 12.3s
深度扫描(L3)——工作原理
L3 结合三个分析层,实现最大范围的覆盖:
Layer 1: Structural Detection Layer 2: Semantic Analysis Layer 3: LLM Deep Scan
├── Hallucinated imports (npm/PyPI) ├── Embedding similarity recall ├── Cross-file coherence check
├── Stale API detection ├── Risk scoring ├── Logic bug detection
├── Security patterns ├── Context window artifacts ├── Confidence scoring
├── Over-engineering metrics └── Enhanced severity ranking └── AI-powered fix suggestions
└── A+ → F quality scoring
由本地 LLM 或任何兼容 OpenAI 的 API 提供支持。 运行 Ollama 即可进行 100% 本地分析,也可以连接到任何远程 LLM 提供商——使用的接口相同。
# Local analysis (Ollama)
ocr scan src/ --sla L3 --provider ollama --model qwen3-coder
# Any OpenAI-compatible provider
ocr scan src/ --sla L3 --provider openai-compatible \
--api-base https://your-llm-endpoint/v1 --model your-model --api-key YOUR_KEY
AI 自动修复——ocr heal
让 AI 自动修复发现的问题。应用前可先审查更改。
# Preview fixes without changing files
ocr heal src/ --dry-run
# Apply fixes + generate IDE rules
ocr heal src/ --provider ollama --model qwen3-coder --setup-ide
# Only generate IDE rules (Cursor, Copilot, Augment)
ocr setup src/
多语言检测
针对 6 种语言的专用检测器,以及虚构软件包数据库(npm、PyPI、Maven、Go modules):
| 语言 | 专用检测器 |
|---|---|
| TypeScript / JavaScript | 虚构导入(npm)、过时 API、过度设计 |
| Python | 裸 except、eval()、可变默认参数、虚构导入(PyPI) |
| Java | 泄漏的 System.out.println、已弃用的 Date/Calendar、虚构导入(Maven) |
| Go | 未处理的错误、已弃用的 ioutil、库代码中的 panic |
| Kotlin | 滥用 !!、泄漏的 println、空安全反模式 |
对比
| Open Code Review | Claude Code Review | CodeRabbit | GitHub Copilot | |
|---|---|---|---|---|
| 价格 | 免费 | $15–25/PR | $24/月/席位 | $10–39/月 |
| 开源 | ✅ | ❌ | ❌ | ❌ |
| 可自托管 | ✅ | ❌ | 企业版 | ❌ |
| AI 幻觉检测 | ✅ | ❌ | ❌ | ❌ |
| 过时 API 检测 | ✅ | ❌ | ❌ | ❌ |
| 深度大模型分析 | ✅ | ❌ | ❌ | ❌ |
| AI 自动修复 | ✅ | ❌ | ❌ | ❌ |
| 多语言 | ✅ 6 种语言 | ❌ | JS/TS | JS/TS |
| 注册表验证 | ✅ npm/PyPI/Maven | ❌ | ❌ | ❌ |
| Unicode 安全检测 | ✅ | ❌ | ❌ | ❌ |
| SARIF 输出 | ✅ | ❌ | ❌ | ❌ |
| GitHub + GitLab | ✅ 两者均支持 | 仅 GitHub | 两者均支持 | 仅 GitHub |
| 数据隐私 | ✅ 100% 本地 | ❌ 云端 | ❌ 云端 | ❌ 云端 |
快速开始
# Install
npm install -g @opencodereview/cli
# Fast scan — no AI needed
ocr scan src/
# Deep scan — with local LLM (Ollama)
ocr scan src/ --sla L3 --provider ollama --model qwen3-coder
# Deep scan — with any OpenAI-compatible provider
ocr scan src/ --sla L3 --provider openai-compatible \
--api-base https://your-provider/v1 --model your-model --api-key YOUR_KEY
CI/CD 集成
GitHub Actions(30 秒)
name: Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: raye-deng/open-code-review@v1
with:
sla: L1
threshold: 60
github-token: ${{ secrets.GITHUB_TOKEN }}
GitLab CI
code-review:
script:
- npx @opencodereview/cli scan src/ --sla L1 --threshold 60 --format json --output ocr-report.json
artifacts:
reports:
codequality: ocr-report.json
输出格式
ocr scan src/ --format terminal # Pretty terminal output
ocr scan src/ --format json # JSON for CI pipelines
ocr scan src/ --format sarif # SARIF for GitHub Code Scanning
ocr scan src/ --format html # Interactive HTML report
配置
# .ocrrc.yml
sla: L3
ai:
embedding:
provider: ollama
model: nomic-embed-text
baseUrl: http://localhost:11434
llm:
provider: ollama
model: qwen3-coder
endpoint: http://localhost:11434
# Or use any OpenAI-compatible provider:
# provider: openai-compatible
# apiBase: https://your-llm-endpoint/v1
# model: your-model
MCP 服务 — 在 Claude Desktop、Cursor、Windsurf 中使用
通过 Model Context Protocol 将 Open Code Review 直接集成到你的 AI IDE 中:
npx @opencodereview/mcp-server
Claude Desktop(claude_desktop_config.json):
{
"mcpServers": {
"open-code-review": {
"command": "npx",
"args": ["-y", "@opencodereview/mcp-server"]
}
}
}
Cursor / Windsurf / VS Code Copilot:在 MCP 设置中添加相同的配置。
可用的 MCP 工具:ocr_scan(质量门扫描)、ocr_heal(AI 自动修复)、ocr_explain(问题说明)。
💡 兼容 Chrome DevTools MCP:OCR MCP Server 遵循标准的 Model Context Protocol。将它与 Google 的 Chrome DevTools MCP Server 配合使用,即可构建完整的 AI 原生开发工作流——一个检查正在运行的应用,另一个检查源代码。
项目结构
packages/
core/ # Detection engine + scoring (@opencodereview/core)
cli/ # CLI tool — ocr command (@opencodereview/cli)
mcp-server/ # MCP Server for AI IDEs (@opencodereview/mcp-server)
github-action/ # GitHub Action wrapper
适用对象
- 使用 AI 编码助手的团队——Copilot、Cursor、Claude Code、Codex,或任何能生成生产代码的大模型工具
- 开源项目维护者——合并前检查 AI 生成的 PR,排查虚构导入、过时 API 和安全反模式
- DevOps / 平台工程师——在 CI/CD 流水线中添加质量门,无需将代码发送到云服务
- 注重安全的团队——在本地运行所有操作(Ollama),让代码留在自己的设备上
- 独立开发者——免费、快速、无需配置(
npx @opencodereview/cli scan src/)
精选推荐
许可证
BSL-1.1 — 可免费用于个人及非商业用途。将于 2030-03-11 转为 Apache 2.0 许可证。 商业用途需购买 Team 或 Enterprise 许可证。
如果觉得这个仓库有用,请点个星——这比你想象的更有帮助!
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。