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

goodiffer

v1.3.0

Published

AI-powered git diff analyzer for code review - 智能代码审查工具

Downloads

216

Readme

Goodiffer

AI-powered git diff analyzer for code review - 基于 AI 的 Git Diff 智能分析工具

npm version License: MIT

Features

  • 🤖 支持 Claude (Anthropic) 和 GPT (OpenAI) 模型
  • 🔍 自动分析 git diff,识别潜在问题
  • 📊 生成结构化的代码审查报告
  • 🔗 检测代码关联性风险
  • 📋 生成可复制的修复提示词,方便在 Claude Code / Codex 中使用
  • 🌐 支持第三方 API 代理
  • 🔮 支持代码上下文获取 (Tool Use),AI 可按需读取相关源码
  • NEW LSP 集成 - 提供类型信息、引用查找、符号导航等智能功能
  • 🧠 NEW Codex 深度审查 - 基于 GPT-5.2 的 8 维度深度代码审查

Installation

npm install -g goodiffer

Quick Start

# 1. 初始化配置
goodiffer init

# 2. 分析最近一次 commit
goodiffer

# 3. 查看帮助
goodiffer --help

Usage

初始化配置

goodiffer init

交互式配置:

  • 选择 API Host (Anthropic/OpenAI/PackyAPI/自定义)
  • 输入 API Key
  • 选择模型 (claude-sonnet-4-5/gpt-4o/自定义)

分析命令

# 分析最近一次 commit (默认)
goodiffer

# 分析暂存区
goodiffer -s
goodiffer --staged

# 分析指定 commit
goodiffer -c <commit-sha>
goodiffer --commit <commit-sha>

# 分析 commit 范围
goodiffer --from <start-sha> --to <end-sha>

# 分析最近 n 条 commit (n <= 10)
goodiffer -n 3          # 分析最近 3 条 commit
goodiffer -n 5          # 分析最近 5 条 commit

# 分析第 n 条到第 m 条 commit (m-n <= 10)
goodiffer -n 2 -m 5     # 分析第 2 到第 5 条 commit
goodiffer -n 3 -m 8     # 分析第 3 到第 8 条 commit

# 启用代码上下文获取 (AI 可按需读取相关源码)
goodiffer --context     # 分析时 AI 可以读取项目中的其他文件
goodiffer -c abc123 --context  # 分析指定 commit,启用上下文

代码上下文模式 (--context)

启用 --context 选项后,AI 在分析代码时可以使用以下工具:

基础工具

  1. read_file - 读取项目中的源文件,了解函数/类的具体实现
  2. find_definition - 查找函数、类、变量的定义位置
  3. search_code - 在项目中搜索代码模式
  4. list_files - 列出目录结构

LSP 增强工具 (TypeScript/JavaScript)

  1. get_type_info - 获取变量、函数的类型信息和文档
  2. find_references - 查找符号在整个项目中的所有引用位置
  3. get_document_symbols - 获取文件中的所有符号列表(函数、类、变量等)
  4. go_to_definition - 使用 LSP 精确定位符号的定义位置

LSP 工具优势:

  • ✅ 精确的类型分析(支持 TypeScript/JavaScript)
  • ✅ 跨文件引用查找
  • ✅ 快速了解文件结构
  • ✅ 自动回退到正则搜索

这使得 AI 能够:

  • 验证被调用函数的实现是否正确
  • 检查类型定义和接口
  • 发现潜在的关联影响
  • 了解代码的调用关系和依赖

注意: 此功能需要 Claude 模型(使用 Tool Use API)。LSP 功能自动启用,无需额外配置。

Codex 深度代码审查 (NEW)

使用 OpenAI Codex (GPT-5.2) 进行深度代码审查,提供 8 维度质量评估和高推理分析。

# 使用 Codex 深度审查最近一次 commit
goodiffer codex

# 审查暂存区
goodiffer codex -s

# 审查指定 commit
goodiffer codex -c abc123

# 指定推理强度 (low/medium/high)
goodiffer codex --reasoning high

Codex Review 特性

8 维度质量评估:

  1. Code Style & Formatting - 代码风格与格式
  2. Security & Compliance - 安全性与合规性
  3. Error Handling & Logging - 错误处理与日志
  4. Readability & Maintainability - 可读性与可维护性
  5. Performance & Scalability - 性能与可扩展性
  6. Testing & Quality Assurance - 测试与质量保证
  7. Documentation & Version Control - 文档与版本控制
  8. Accessibility & Internationalization - 可访问性与国际化

评分系统:

  • Extraordinary (90-100) - 卓越质量
  • Acceptable (70-89) - 符合标准
  • ⚠️ Poor (0-69) - 需要改进

高推理模式:

  • 使用 reasoning: { effort: "high" } 进行深度分析
  • 提供置信度评分(0.0-1.0)
  • 生成正确性判断(patch is correct / incorrect)

结构化输出:

  • 使用 JSON Schema 定义输出格式(降低 35% 失败率)
  • 精确的文件/行号引用
  • 优先级分级(P0-P3)

输出示例:

╭──────────────────────────────────────────────────────────╮
│  Codex Deep Code Review Report                          │
╰──────────────────────────────────────────────────────────╯

📝 Commit: abc1234
📋 Message: feat: add user authentication

📊 Summary: 添加了用户认证功能...

═══════════════════════════════════════════════════════════

🎯 8-Dimensional Quality Assessment

1. Security & Compliance
   🌟 Rating: EXTRAORDINARY | Score: 95/100
   密码加密使用了 bcrypt,符合安全标准

2. Error Handling & Logging
   ⚠️ Rating: POOR | Score: 60/100
   缺少异常处理和日志记录
   ▸ API 调用未处理错误情况
   ▸ 缺少关键操作的日志

═══════════════════════════════════════════════════════════

⚖️  Overall Assessment

✅ Correctness: PATCH IS CORRECT
📈 Confidence: 85% (High)
💡 Explanation: 代码功能正确,但需改进错误处理

═══════════════════════════════════════════════════════════

🔍 Findings (2)

🟠 P1 - URGENT (1)

[A] [P1] API 调用缺少错误处理

   Location: src/auth/api.js:45-52
   Confidence: 90% (Very High)
   Dimension: Error Handling & Logging

   在 loginUser 函数中直接调用 API 而未处理可能的网络错误...

   💡 Suggestion: 添加 try-catch 块处理异常

   📋 修复提示词 (复制到 Claude Code/Codex):
   ┌──────────────────────────────────────────────────┐
   │ 在 src/auth/api.js:45 添加 try-catch 处理异常   │
   └──────────────────────────────────────────────────┘

推荐使用场景: 关键代码审查、生产环境发布前、安全敏感功能

配置管理

# 查看当前配置
goodiffer config list

# 设置配置项
goodiffer config set apiHost https://api.anthropic.com
goodiffer config set model claude-sonnet-4-5-20250929

# 清除配置
goodiffer config clear

Output Example

╭──────────────────────────────────────────────────────────╮
│  Goodiffer Analysis Report                               │
╰──────────────────────────────────────────────────────────╯

📝 Commit: feat: add user authentication

📊 Summary: 添加用户认证功能,包含登录表单和 API 调用

🎯 Commit 匹配: ✓ 代码修改符合 commit 描述

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔴 ERRORS (1)

[E001] src/auth/login.js:45-52
问题: 未处理 API 调用失败的情况

📋 修复提示词 (复制到 cc/codex):
┌────────────────────────────────────────────────────────┐
│ 在 src/auth/login.js 第45行添加 try-catch 处理异常    │
└────────────────────────────────────────────────────────┘

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📈 统计: 1 errors 0 warnings 0 info 0 risks

Supported API Providers

| Provider | API Host | Models | |----------|----------|--------| | Anthropic | https://api.anthropic.com | claude-sonnet-4-5, claude-3-opus | | OpenAI | https://api.openai.com | gpt-4o, gpt-4-turbo | | PackyAPI | https://www.packyapi.com | claude-, gpt- | | Custom | 自定义 URL | 任意模型 |

Configuration

配置文件存储在 ~/.config/goodiffer-nodejs/config.json

可配置项:

  • apiHost - API 服务地址
  • apiKey - API 密钥
  • model - 模型名称
  • provider - 提供商 (claude/openai/custom)

Requirements

  • Node.js >= 18.0.0
  • Git

License

MIT