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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ai-bots/code

v1.0.1

Published

一个基于GitHub Webhook的AI代码审查系统,当Pull Request被创建或重新打开时,自动触发AI代码审查并将结果作为评论发布到PR中。

Downloads

8

Readme

AI代码审查Webhook服务

一个基于GitHub Webhook的AI代码审查系统,当Pull Request被创建或重新打开时,自动触发AI代码审查并将结果作为评论发布到PR中。

功能特性

  • 🤖 自动AI代码审查
  • 📝 支持多种AI服务提供商(Magic AI、DeepSeek)
  • 🔗 GitHub Webhook集成
  • 📊 详细的代码变更分析
  • 🎯 智能问题分级(严重/次严重/轻微)

项目结构

ai-review/
├── index.js              # 主入口文件
├── types.js              # JSDoc类型定义文件
├── config/
│   └── index.js          # 配置文件
├── server/
│   ├── getGithubContent.js    # GitHub内容获取服务
│   ├── postGithub.js          # GitHub API发布服务
│   └── generateResponse.js    # AI响应生成服务
└── data/                 # 示例数据文件
    ├── issue.js          # GitHub Issue数据示例
    ├── pullmerge.js      # Pull Request数据示例
    └── prRes.js          # PR响应数据示例

JSDoc类型系统

本项目使用JSDoc进行类型注释和文档生成。所有类型定义都集中在 types.js 文件中,包括:

主要类型定义

  • GitHubUser - GitHub用户信息
  • GitHubRepository - GitHub仓库信息
  • GitHubPullRequest - Pull Request详细信息
  • GitHubWebhookPayload - Webhook载荷数据
  • GitHubPullRequestFile - PR文件变更信息
  • ApiResponse - API响应格式

使用方式

在代码中引用类型:

/**
 * @param {GitHubWebhookPayload} payload - GitHub webhook数据
 * @returns {Promise<ApiResponse>} API响应
 */
async function handleWebhook(payload) {
    // 函数实现
}

生成文档

使用JSDoc生成API文档:

# 安装JSDoc
npm install -g jsdoc

# 生成文档
jsdoc -c jsdoc.conf.json

安装和使用

  1. 克隆仓库
git clone https://github.com/electroluxcode/web-hook-review.git
cd ai-review
  1. 安装依赖
npm install
  1. 配置环境变量 编辑 config/index.js 文件,设置:
  • GitHub访问令牌
  • AI服务API密钥
  • 仓库信息
  1. 启动服务
npm start
  1. 配置GitHub Webhook 在GitHub仓库设置中添加Webhook:
  • URL: http://your-server:3844/ai-review
  • Content type: application/json
  • Events: Pull requests

API接口

POST /ai-review

接收GitHub Webhook事件,触发AI代码审查。

请求体: GitHubWebhookPayload

响应: ApiResponse

GET /

健康检查接口,返回欢迎消息。

配置说明

config/index.js

export const config = {
    port: 3844,                    // 服务端口
    token: 'your-github-token',    // GitHub访问令牌
    owner: 'your-username',        // 仓库所有者
    repo: 'your-repo',            // 仓库名称
    issue_number: 5,              // 默认Issue编号
    prompt: '...'                 // AI审查提示词
}

开发指南

代码规范

  • 使用JSDoc注释所有函数和类型
  • 遵循ES6+模块化规范
  • 错误处理使用try-catch
  • 日志输出使用console.log

类型安全

项目使用JSDoc提供类型检查:

/** @type {GitHubWebhookPayload} */
const data = req.body;

添加新功能

  1. types.js 中定义相关类型
  2. 实现功能模块
  3. 添加JSDoc注释
  4. 更新README文档

许可证

ISC License


Code by electrolux

仓库配置-webhook-接受端

setting -> webhooks -> add webhook -> 填写 payload url,然后关掉https校验 -> 打开pr ,issue权限即可 仓库的webhook打开配置就好了

webhook-发送端

https://docs.github.com/zh/rest/pulls/comments?apiVersion=2022-11-28#about-pull-request-review-comments 发送评论用 curl 或者是 axios 似乎有问题, 只能用 Octokit 来做