npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ouyangzhigang/ai-code-review

v1.0.13

Published

By the AI to code review npm cli tool

Readme

AI Code Review (AIR)

🔍 AI驱动的智能代码评审工具 — 让每一次代码提交都经过专业审视

npm version License Node Version


✨ 核心特性

| 特性 | 描述 | |------|------| | 🚀 并发处理 | 最多5个文件并行评审,告别等待 | | 🎯 精准定位 | 每个问题精确到文件路径和行号 | | 📊 分级报告 | 三级分类:🔴必须修复 / 🟡建议优化 / 🟢值得肯定 | | 🌐 多语言支持 | 支持30+主流编程语言 | | 📁 独立报告 | 每个文件生成独立报告,索引链接便于查阅 | | 🔧 灵活配置 | 支持自定义模型、API地址、输出目录 |


📦 安装

npm install -g @ouyangzhigang/ai-code-review

🚀 快速开始

1. 配置环境变量

Windows:

set AIR_API_KEY=sk-your-api-key
set AIR_BASE_URL=https://api.deepseek.com/v1
set AIR_MODEL=deepseek-coder

Linux/Mac:

export AIR_API_KEY=sk-your-api-key
export AIR_BASE_URL=https://api.deepseek.com/v1
export AIR_MODEL=deepseek-coder

| 环境变量 | 必须 | 默认值 | 说明 | |----------|:----:|--------|------| | AIR_API_KEY | ✅ | — | API密钥(未设置将报错提示) | | AIR_BASE_URL | ❌ | https://api.deepseek.com/v1 | API服务地址 | | AIR_MODEL | ❌ | deepseek-coder | 使用的模型名称 |

2. 运行评审

# 当前目录下评审未推送变更
air

# 评审指定目录的未推送变更
air -d ./src

# 与指定分支对比评审
air -d ./src -b main

# 自定义输出目录
air -d ./src -o ./reports

🎮 命令参数

Usage: air [options]

🔍 AI-driven code review tool for Git changes

Options:
  -V, --version          输出版本号
  -d, --dir <path>       目标目录 (默认: ".")
  -b, --base <branch>    对比基准分支 (不指定则检测未推送变更)
  -o, --output <path>    报告输出目录 (默认: "__report__")
  -h, --help             显示帮助信息

📊 报告输出

输出结构

__report__/
├── code-review-report.md        # 📋 总摘要 + 文件索引
├── src-core-ai.ts.md            # 📄 单文件详细报告
├── src-core-diff-tester.ts.md   # 📄 单文件详细报告
└── ...

摘要报告示例

# AI Code Review Report

**Generated:** 2024-01-15T10:30:00Z
**Base Directory:** ./src
**Mode:** Unpushed changes on 'feature/new-api'

---

## Summary

- **Files Reviewed:** 5
- **🔴 Must Fix:** 8
- **🟡 Suggest Optimize:** 12
- **🟢 Highlights:** 3

---

## File Index

| Status | File | 🔴 Must Fix | 🟡 Suggest | 🟢 Highlights |
|:------:|:-----|:-----------:|:----------:|:-------------:|
| 🔴 | [src/api.ts](./src-api.ts.md) | 3 | 2 | 0 |
| 🟡 | [src/utils.ts](./src-utils.ts.md) | 0 | 4 | 1 |
| 🟢 | [src/config.ts](./src-config.ts.md) | 0 | 0 | 2 |

单文件报告示例

# Code Review: src/api.ts

**Generated:** 2024-01-15T10:30:00Z

---

## 🔴 必须修复(严重)

- **[src/api.ts:42]** 未处理Promise rejection → `fetchData().catch()` 缺失 → 添加错误处理链

## 🟡 建议优化(一般)

- **[src/api.ts:58]** 重复的HTTP请求 → 使用缓存或请求合并

## 🟢 值得肯定(亮点)

- **[src/api.ts:75]** 良好的类型定义和注释

🌐 支持的编程语言

AIR 支持 30+ 主流编程语言,覆盖前后端全栈开发:

| 类别 | 支持的扩展名 | |------|-------------| | JavaScript/TypeScript | .js, .jsx, .mjs, .cjs, .ts, .tsx | | Python | .py | | Java | .java | | Go | .go | | Rust | .rs | | C/C++ | .c, .cpp, .cc, .cxx, .h, .hpp | | Ruby | .rb | | PHP | .php | | Swift | .swift | | Kotlin | .kt, .kts | | Scala | .scala | | C# | .cs | | 前端框架 | .vue, .svelte | | 样式文件 | .css, .scss, .sass, .less | | HTML | .html, .htm | | SQL | .sql | | Shell脚本 | .sh, .bash, .zsh |


⚡ 性能优化

并发处理机制

AIR 采用 Worker Pool 模式实现并发评审:

┌─────────────────────────────────────────┐
│           文件队列 (Queue)               │
│  [file1] [file2] [file3] [file4] [file5] │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│         Worker Pool (Max 5)              │
│   ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐         │
│   │W1│ │W2│ │W3│ │W4│ │W5│             │
│   └───┘ └───┘ └───┘ └───┘ └───┘         │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│            输出报告                      │
│   report1.md  report2.md  ...           │
└─────────────────────────────────────────┘
                    ↓
            code-review-report.md

效果:5个文件同时评审,无需等待每个文件依次完成!


🏗️ 技术架构

┌──────────────────────────────────────────────────────┐
│                    CLI Entry (cli.ts)                 │
│                  commander + chalk                    │
└──────────────────────────────────────────────────────┘
                          │
          ┌───────────────┼───────────────┐
          ↓               ↓               ↓
┌─────────────┐  ┌─────────────┐  ┌─────────────┐
│  GitService │  │ AstExtractor│  │AIOrchestrator│
│   git.ts    │  │   ast.ts    │  │    ai.ts    │
├─────────────┤  ├─────────────┤  ├─────────────┤
│ • diff解析  │  │ • AST解析   │  │ • LLM调用   │
│ • 变更检测  │  │ • 函数提取  │  │ • 结构化输出 │
│ • 行号定位  │  │ • Vue处理   │  │ • Zod Schema │
└─────────────┘  └─────────────┘  └─────────────┘
                          │
                          ↓
┌──────────────────────────────────────────────────────┐
│               DiffTester (diff-tester.ts)             │
│              • 并发处理  • 报告生成                    │
└──────────────────────────────────────────────────────┘

🔧 本地开发

# 克隆仓库
git clone https://github.com/zaneouyang/ai-code-review.git

# 安装依赖
npm install

# 开发模式 (热重载)
npm run dev

# 构建
npm run build

# 类型检查
npm run typecheck

🤝 贡献指南

欢迎提交 Issue 和 Pull Request!

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 创建 Pull Request

📝 License

ISC License © 2024 ouyangzhigang


🙏 致谢