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

@chris_zp/ai-code-review-cli

v1.0.19

Published

AI代码审查脚手架工具,基于AI技术对代码进行质量分析和审查

Downloads

136

Readme

AI 代码审查脚手架工具

基于 AI 技术的代码审查工具,能够自动化分析代码质量、发现潜在问题并提供改进建议。

功能特性

  • 🤖 使用 AI 技术进行代码审查
  • 📁 Git 暂存文件审查:专为 Git 提交钩子设计,自动审查暂存区文件
  • 🎯 多种严重程度评估(high/medium/low)
  • 💡 提供详细的修复建议
  • 📊 支持多种输出格式(控制台/Markdown)
  • ⚙️ 灵活的配置选项
  • 🔍 智能依赖分析:自动识别代码变更涉及的关联文件
  • 🏗️ 技术栈检测:自动分析项目技术栈,提供上下文信息
  • 📚 增强上下文:整合关联文件和技术栈信息,提升审查准确性

技术栈

  • Node.js
  • Commander.js (命令行框架)
  • Axios (HTTP 请求)
  • Dotenv (环境变量管理)
  • JS-YAML (配置管理)
  • tiktoken (Token 计数)
  • Babel Parser (JavaScript 代码解析)
  • @babel/traverse (AST 遍历)

项目文档

安装

全局安装

npm install -g @chris_zp/ai-code-review-cli

本地安装

npm install @chris_zp/ai-code-review-cli --save-dev

使用流程

1. 初始化全局配置

在首次使用前,需要初始化全局配置(只需设置一次):

ai-code-review init

这将创建配置文件 ~/.ai-code-review/config.yml,您可以通过编辑配置文件或使用 config 命令设置 API 密钥和其他全局配置选项。

2. 在项目中安装 pre-commit 钩子

在您的项目根目录下运行:

ai-code-review install

这将:

  • 安装必要的依赖(如 husky)
  • 初始化 Git 钩子配置
  • 创建 pre-commit 钩子脚本
  • 配置自动触发审查流程

3. 自动触发审查

从现在开始,每当您执行 git commit 命令时,工具将自动:

  • 检查 Git 暂存文件
  • 分析项目技术栈
  • 自动审查代码变更
  • 生成审查报告
  • 如果发现问题,阻止提交

无需手动执行 review 命令!

配置管理

所有配置都是全局的,适用于所有项目。

查看全局配置:

ai-code-review config --list

设置全局配置项:

ai-code-review config --set api_key=your_api_key
ai-code-review config --set model_name=deepseek-chat
ai-code-review config --set file_types=ts,tsx,js,jsx

获取全局配置项:

ai-code-review config --get api_key

配置选项

配置文件存储在 ~/.ai-code-review/config.yml,支持以下选项:

  • api_key: AI 服务的 API 密钥
  • model_name: 使用的 AI 模型 (默认: deepseek-chat)
  • agent_url: AI 服务的基础 URL (默认: https://api.deepseek.com/v1/chat/completions)
  • review_threshold: 审查阈值 (默认: 0.7)
  • file_types: 需要审查的文件类型 (默认: [ts, tsx, js, jsx, vue, py])

示例

审查 Git 暂存文件

# 将文件添加到暂存区
git add src/index.js src/utils/helper.js

# 运行代码审查
ai-code-review review

输出示例:

开始审查 2 个文件...
🔍 正在分析项目技术栈...
✅ 技术栈分析完成

[1/2] 审查文件: src/index.js
  � 正在分析文件依赖...
  � 发现 1 个关联文件
  ✅ 未发现问题

[2/2] 审查文件: src/utils/helper.js
  🔍 正在分析文件依赖...
  🔗 发现 0 个关联文件
  ✅ 未发现问题

✅ 代码审查完成,未发现问题

✅ 审查报告已保存到: e:\workspace\project\ai-code-review-report.md

审查报告示例

生成的 Markdown 报告 (ai-code-review-report.md) 示例:

# AI 代码审查报告

## 审查概览

-   审查时间: 2024-01-01 12:00:00
-   审查文件数: 2
-   发现问题数: 1

## 问题详情

### 1. 未处理的错误

-   **文件**: src/index.js
-   **行号**: 15
-   **类型**: 错误处理
-   **严重程度**: high
-   **描述**: fetch 调用未处理可能的错误,这可能导致应用在网络问题时崩溃
-   **建议**: 添加 try-catch 块处理错误,或使用.catch()方法捕获 Promise 拒绝

许可证

ISC

贡献

欢迎提交 Issue 和 Pull Request!

支持

如果您有任何问题或建议,请创建 Issue。