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

mdpi-ai-code-reviewer

v0.1.4

Published

AI Code Reviewer 是一个基于人工智能的代码审查工具,自动分析 GitLab 合并请求中的代码变更,并提供智能反馈和建议。

Readme

AI Code Reviewer

AI Code Reviewer 是一个基于人工智能的代码审查工具,自动分析 GitLab 合并请求中的代码变更,并提供智能反馈和建议。

功能特性

  • 🤖 基于 AI 的代码审查
  • 🔍 自动检测代码中的潜在问题和优化点
  • 🧠 使用Openrouter平台, 支持多种 AI 模型(默认使用 qwen/qwen3-coder:free)
  • 🛠 与 GitLab 深度集成
  • 📝 自动在合并请求中添加评论
  • ⚙️ 可自定义审查提示和模型
  • 📦 支持多语言
  • 🚀 支持增量review
  • 🔥 可自定义审查忽略文件

安装

npm install -g mdpi-ai-code-reviewer

或者直接使用 npx:

npx mdpi-ai-code-reviewer

使用方法

基本用法

ai-code-review \
  --gitlab-token <your-gitlab-token> \
  --openrouter-token <your-openrouter-token> \
  --project-id <project-id> \
  --merge-request-id <merge-request-id>

完整参数选项

ai-code-review [options]
  • -g, --gitlab-api-url <string> GitLab API 地址 (默认: https://gitlab.com/api/v4)
  • -t, --gitlab-token <string> GitLab 访问令牌
  • -u, --openrouter-api-url <string> OpenRouter API 地址 (默认: https://openrouter.ai/api/v1/chat/completions)
  • -o, --openrouter-token <string> OpenRouter 访问令牌
  • -p, --project-id <number> GitLab 项目 ID
  • -q, --merge-request-id <string> GitLab 合并请求 ID
  • -m, --model <string> 自定义 AI 模型
  • -r, --prompt <string> 自定义审查规则
  • -e, --exclude <string> 自定义不需要审查的文件路径 (默认: "package-lock.json, .git, .env, .gitlab-ci.yml, env.**")

在CI中使用

配置gitlab-ci.yml文件, 如下:

stages:
  - ai_code_review

review:
  stage: ai_code_review
  image: node:latest
  rules:
    - if: >
        $CI_PIPELINE_SOURCE == "merge_request_event" &&
        $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "staging"
      when: on_success
  variables: 
    # AI API相关配置
    AI_API_TOKEN: $AI_API_TOKEN  # 存储AI服务的API密钥
    GITLAB_ACCESS_TOKEN: $GITLAB_ACCESS_TOKEN  # 用于向MR添加评论的GitLab令牌
    # 可选:指定AI模型(如qwen/qwen3-coder:free 等,根据Openrouter上的model调整, 或者是自定义url和model)
    AI_MODEL: ""
    # 可选:prompt(可自定义)
    AI_PROMPT: ""
    EXCLUDE: "" # 指定需要忽略的文件或路径,eg: *.ts,**.md
  script:
    - npm i mdpi-ai-code-reviewer -g
    - ai-code-review -g $CI_API_V4_URL -t $GITLAB_ACCESS_TOKEN -o $AI_API_TOKEN -p $CI_PROJECT_ID -q $CI_MERGE_REQUEST_IID -m $AI_MODEL -r $AI_PROMPT -e $EXCLUDE
   

环境要求

  • Node.js >= 14

工作原理

  1. 通过 GitLab API 获取指定合并请求的代码变更
  2. 使用 AI 模型分析代码差异
  3. 在合并请求中自动添加审查评论
  4. 记录审查状态以避免重复审查

目录结构

.gitignore
LICENSE
package.json
README.md
tsconfig.json
bin/
  index.js
src/
  gitlab.ts
  index.ts
  ai/
    content.ts
    openrouter.ts
  utils/
    index.ts

主要文件说明

开发

安装依赖

yarn install

构建项目

yarn run build

本地运行

yarn run start

许可证

MIT License