Token导航 LogoToken导航TokenDH.com
LLM Reviewer logo
开发工具stdio官方级别未说明来源级核验

LLM Reviewer

MCP Server

一个利用大型语言模型(LLM)进行代码审查的CLI工具,支持GitHub Copilot、本地Ollama模型和任何OpenAI兼容的端点。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
代码审查开发工具TypeScriptClaudeGitHub CopilotClaudeCursorClineVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

asheshv

提供方

asheshv

最后核验

2026/5/17 20:21

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx --yes github:asheshv/llm-reviewer --help

详细介绍

llm审阅者

使用LLMs(CLI+MCP服务器)检查任何AI代理的代码更改。支持GitHub Copilot、本地Ollama模型和任何与OpenAI兼容的端点。

安装

# Install globally from GitHub
npm install -g github:asheshv/llm-reviewer

# Or use without installing:
npx --yes github:asheshv/llm-reviewer --help

快速开始

# Review uncommitted local changes (uses Copilot by default)
llm-reviewer

# Review changes in a feature branch vs main
llm-reviewer branch main

# Review a pull request
llm-reviewer pr 123

# Review with a local Ollama model
llm-reviewer local --provider ollama --model qwen2.5-coder:14b

# Review with any OpenAI-compatible endpoint
LLM_REVIEWER_API_KEY="sk-..." llm-reviewer local \
  --provider custom --base-url https://openrouter.ai/api/v1 \
  --model google/gemini-2.5-flash

命令行用法

llm-reviewer [mode] [options]

Modes (default: local):
  unstaged              Working tree vs index
  staged                Index vs HEAD
  local                 Working tree vs HEAD (default)
  branch [base]         Current branch vs base (default: main)
  pr            Pull request diff
  commits            Last N commits
  range ..  Arbitrary ref range

Options:
  --model           Model to use (default: auto)
  --format         text | markdown | json (default: markdown)
  --stream              Force streaming output
  --no-stream           Force buffered output
  --prompt        Override review prompt
  --config 
       Override config file path
  --provider      Review provider: copilot, ollama, custom, custom:
  --chunking      auto | always | never (default: auto)
  --timeout    Request timeout (default: 30 for copilot/custom, 120 for ollama)
  --ollama-url     Ollama base URL (default: http://localhost:11434)
  --base-url       Base URL for custom provider (OpenAI-compatible endpoint)
  --verbose             Enable debug logging to stderr
  --help                Show help
  --version             Show version

Subcommands:
  llm-reviewer models          List available models
  llm-reviewer chat ""    Free-form LLM chat
  llm-reviewer status          Show provider connectivity and configuration

例子

# Review staged changes before committing
llm-reviewer staged

# Review the last 3 commits
llm-reviewer commits 3

# Review a ref range
llm-reviewer range v1.0.0..HEAD

# Use a specific model with JSON output
llm-reviewer branch main --model gpt-4.1 --format json

# Custom review instructions
llm-reviewer --prompt "Focus on security and error handling"

# Review with Ollama (local LLM)
llm-reviewer local --provider ollama --model qwen2.5-coder:14b

# List Ollama models
llm-reviewer models --provider ollama

# Check provider status
llm-reviewer status --provider ollama

# Force chunking for large diffs
llm-reviewer branch main --chunking always

# Longer timeout for large models
llm-reviewer commits 1 --provider ollama --model qwen2.5-coder:32b --timeout 300

提供商

副驾驶(默认)

使用GitHub Copilot的聊天API。需要GitHub令牌(请参阅 认证).

llm-reviewer local                          # auto-selects model
llm-reviewer local --model gpt-4.1          # specific model
llm-reviewer models                         # list available models

Ollama(当地)

使用本地运行 奥拉玛 例子无需身份验证。

# Start Ollama (if not running)
ollama serve

# List available models
llm-reviewer models --provider ollama

# Review with a specific model (model is required for Ollama)
llm-reviewer local --provider ollama --model qwen2.5-coder:14b

# Custom Ollama URL
llm-reviewer local --provider ollama --ollama-url http://remote:11434 --model codellama

# Non-streaming for cleaner output
llm-reviewer commits 1 --provider ollama --model qwen2.5-coder:14b --no-stream

自定义提供者(兼容OpenAI)

连接到实现OpenAI聊天完成API的任何端点-OpenRouter、Groq、Together AI、Fireworks、LM Studio、vLLM等。

基本URL必须包括完整的API路径(例如。, https://api.groq.com/openai/v1,不 https://api.groq.com).如果您遇到404错误,请检查您的URL是否包含 /v1 或提供者的等效路径前缀。
# Quick start: API key via env var, endpoint via --base-url
LLM_REVIEWER_API_KEY="sk-or-..." llm-reviewer local \
  --provider custom --base-url https://openrouter.ai/api/v1 \
  --model google/gemini-2.5-flash

# Named provider from config file (see config example below)
llm-reviewer local --provider custom:groq --model llama-3.3-70b-versatile

# List models from a custom endpoint
llm-reviewer models --provider custom --base-url https://api.groq.com/openai/v1

# Dynamic auth with a shell command
# Config: { "providerOptions": { "gcp": { "baseUrl": "https://...", "apiKeyCommand": "gcloud auth print-access-token" } } }
llm-reviewer local --provider custom:gcp --model gemini-2.5-flash

# Bare "custom" picks from providerOptions if --base-url is not set (see Named Configurations)
llm-reviewer local --provider custom --model google/gemini-2.5-flash

# Local endpoint (no auth required)
llm-reviewer local --provider custom --base-url http://localhost:1234/v1 --model local-model

模型始终是必需的 对于自定义提供程序,没有自动选择。集 --model 或添加 "model" 到您的配置文件。

命名配置

使用以下命令在配置文件中定义多个端点 providerOptions:

{
  "providerOptions": {
    "groq": {
      "baseUrl": "https://api.groq.com/openai/v1",
      "apiKeyCommand": "op read 'op://Dev/Groq/api-key'"
    },
    "openrouter": {
      "baseUrl": "https://openrouter.ai/api/v1",
      "apiKeyCommand": "cat ~/.config/openrouter/key"
    }
  }
}

然后使用它们 --provider custom::

llm-reviewer local --provider custom:groq --model llama-3.3-70b-versatile
llm-reviewer local --provider custom:openrouter --model anthropic/claude-sonnet-4

使用裸机时 --provider custom,解析顺序为:

  1. --base-url CLI标志或 LLM_REVIEWER_BASE_URL env 是
  2. providerOptions.custom 进入
  3. 第一个非内置 providerOptions 进入

认证

自定义提供程序支持三种身份验证模式:

模式配置字段描述
静态密钥apiKey每次请求都会发送承载令牌
动态命令apiKeyCommand执行Shell命令以获取密钥;缓存,直到身份验证失败
无身份验证_(省略两者)_没有 Authorization 标头(用于本地端点)

当两者都 apiKeyapiKeyCommand 存在, apiKeyCommand 获胜(动态胜过静态)。

在401(或没有速率限制标头的403)上,通过重新运行命令刷新密钥,并重试一次请求。

流行的OpenAI兼容端点

提供者基本URL身份验证模型示例
OpenRouterhttps://openrouter.ai/api/v1承载密钥google/gemini-2.5-flash, anthropic/claude-sonnet-4
Groqhttps://api.groq.com/openai/v1承载密钥llama-3.3-70b-versatile, mixtral-8x7b-32768
一起AIhttps://api.together.xyz/v1承载密钥meta-llama/Llama-3.3-70B-Instruct-Turbo
烟花https://api.fireworks.ai/inference/v1承载密钥accounts/fireworks/models/llama-v3p3-70b-instruct
LM工作室http://localhost:1234/v1无论加载何种模型
vLLMhttp://localhost:8000/v1取决于部署

安全说明

  • apiKeyCommand 以完全用户权限执行shell命令。像对待它一样对待它 package.json scripts——在不受信任的存储库中运行之前,请检查项目配置文件。
  • 不要 存储静态 apiKey 项目配置文件中可能提交到版本控制的值。使用 apiKeyCommandLLM_REVIEWER_API_KEY 取而代之的是env-var。
  • API密钥从不出现在错误消息中。从所有错误输出中编辑命令字符串。

超时

自定义提供程序使用默认的30秒超时(与Copilot相同)。云API很快。对于自定义端点后面的本地模型,设置 --timeout 120"timeout": 120 在配置中。

状态命令

检查提供程序连接、已解析的配置和可用型号:

llm-reviewer status                         # default provider (copilot)
llm-reviewer status --provider ollama       # check Ollama
llm-reviewer status --provider custom:groq  # check custom endpoint
llm-reviewer status --json                  # machine-readable output

分块评论

对于超出模型上下文窗口的较大差异, llm-reviewer 自动将差异拆分为块,独立审查每个块,然后通过reduce pass聚合结果。

  • auto (默认)--当diff超过模型上下文的80%时,执行块
  • always --总是大块,即使是很小的差异
  • never --如果差异太大,则失败(对CI硬限制有用)
llm-reviewer branch main --chunking always   # force chunking
llm-reviewer branch main --chunking never    # disable chunking

# Kill switch via environment variable
LLM_REVIEWER_CHUNKING=never llm-reviewer local

分块评论显示stderr的进展:

Reviewing chunk 1/3 (src/auth.ts, src/config.ts)... done (3,200 tokens)
Reviewing chunk 2/3 (src/review.ts, src/prompt.ts)... done (2,800 tokens)
Reviewing chunk 3/3 (src/cli.ts)... done (1,950 tokens)
Aggregating findings... done (4,500 tokens)

MCP服务器设置

MCP服务器将LLM审查功能作为AI代理(Claude Code、Cursor、Zed、Cline等)的工具公开。

克劳德代码

添加 .mcp.json 在您的项目根目录中或 ~/.config/claude/mcp.json:

{
  "mcpServers": {
    "llm-reviewer": {
      "command": "llm-reviewer",
      "args": ["--mcp"]
    }
  }
}

适用于通用MCP客户端

{
  "llm-reviewer": {
    "type": "stdio",
    "command": "llm-reviewer",
    "args": ["--mcp"]
  }
}

或者,如果在本地使用(不是全局安装):

{
  "llm-reviewer": {
    "type": "stdio",
    "command": "node",
    "args": ["/absolute/path/to/llm-reviewer/dist/cli.js", "--mcp"]
  }
}

可用的MCP工具

  • llm_review --查看代码更改(支持所有7种模式)
  • llm_chat --与LLM免费聊天(可选代码上下文)
  • llm_models --列出可用型号

克劳德代码技能

您还可以添加 llm-reviewer 作为 Claude代码技能 因此,当您请求代码审查时,Claude可以自动调用它。

设置

# Copy the skill into your Claude skills directory
mkdir -p ~/.claude/skills/llm-reviewer
cp skills/SKILL.md ~/.claude/skills/llm-reviewer/SKILL.md

用法

安装后,Claude Code将自动使用 llm-reviewer 当你:

  • 要求查看代码更改、差异或PR
  • 完成一个功能并寻求第二意见
  • 请求积极的多轮审查

您还可以显式调用它:

/llm-reviewer

该技能支持所有提供者(Copilot、Ollama、Custom)、分块、跨模型审查和完整的CLI功能集。看 skills/SKILL.md 以供完整参考。

配置

配置从多个层加载(从最低优先级到最高优先级):

  1. 内置默认值 --随工具发货
  2. 环境变量LLM_REVIEWER_* (见下文)
  3. 全局配置~/.llm-reviewer/config.jsonconfig.md
  4. 项目配置/.llm-reviewer/config.jsonconfig.md
  5. 命令行标志--model, --format, --provider等等。(最高优先级)

环境变量

变量描述示例
LLM_REVIEWER_PROVIDER覆盖提供者ollama, custom
LLM_REVIEWER_OLLAMA_URL 基础 URLhttp://remote:11434
LLM_REVIEWER_BASE_URL自定义提供程序基本URLhttps://api.groq.com/openai/v1
LLM_REVIEWER_API_KEY自定义提供程序API密钥(静态)sk-...
LLM_REVIEWER_API_KEY_COMMAND获取API密钥的Shell命令op read 'op://Dev/key'
LLM_REVIEWER_CHUNKING分块模式(关闭开关)never

当两者都 LLM_REVIEWER_API_KEYLLM_REVIEWER_API_KEY_COMMAND 被设置, API_KEY 优先(env-var使用静态排序而不是动态排序,因为用户显式地设置了这两种排序)。在配置文件内, apiKeyCommand 赢得青睐 apiKey (动态多于静态)。这些环境变量只影响裸机 --provider custom,未指定提供者,如 custom:groq.

config.json架构

{
  "model": "auto",
  "format": "markdown",
  "stream": true,
  "mode": "extend",
  "prompt": "path/to/custom-prompt.md",
  "defaultBase": "main",
  "ignorePaths": ["*.lock", "dist/**"],
  "provider": "copilot",
  "providerOptions": {
    "ollama": {
      "baseUrl": "http://localhost:11434"
    },
    "groq": {
      "baseUrl": "https://api.groq.com/openai/v1",
      "apiKeyCommand": "op read 'op://Dev/Groq/api-key'"
    },
    "openrouter": {
      "baseUrl": "https://openrouter.ai/api/v1",
      "apiKeyCommand": "cat ~/.config/openrouter/key"
    }
  },
  "chunking": "auto",
  "timeout": 30
}
字段类型默认值描述
model字符串"auto"型号ID或 "auto" 用于自动选择
format字符串"markdown"输出格式: text, markdown,或 json
stream布尔值true启用流式输出
mode字符串"extend"快速合并策略: extendreplace
promptstring--内联文本或路径 .md 文件(相对于配置目录)
defaultBase字符串"main"默认基础分支 branch 模式
ignorePathsstring\[\][]要从差异中排除的全局模式(跨层合并)
provider字符串"copilot"提供商: copilot, ollama, custom, custom:
providerOptions对象{}特定于提供商的配置(Ollama URL、自定义端点)
chunking字符串"auto"分块模式: auto, always,或 never
timeout编号30请求超时(秒)(Ollama自动:120)

快速定制

您可以通过两种方式自定义审核说明:

  1. 在config.json中内联:
   {
     "mode": "extend",
     "prompt": "Focus on TypeScript type safety and error handling."
   }
  1. 单独的config.md文件:
   # Project-Specific Review Guidelines

   - Check React hooks dependencies
   - Verify error boundaries are present
   - Flag any `any` types

提示合并模式

  • "extend" (默认)--将您的指令附加到默认提示
  • "replace" --将默认提示完全替换为您的提示

多层合并示例(全部使用 "extend"):

[Default prompt from prompts/default-review.md]

## Additional Instructions (Global)
[Global ~/.llm-reviewer/config.md]

## Project Instructions
[Project .llm-reviewer/config.md]

如果项目配置使用 "mode": "replace",仅使用项目提示。

命令行界面 --prompt 标志总是取代一切:

llm-reviewer --prompt "Only check for SQL injection"

默认审核提示

内置提示符按优先级顺序检查代码更改:

  1. 安全 --SQL注入、XSS、命令注入、身份验证旁路、OWASP Top 10
  2. 正确性 --边缘情况、竞争条件、错误路径、无效假设
  3. 演出 --N+1个查询、缺失索引、算法复杂性
  4. 可读性 --命名不明确、评论误导、不必要的复杂性
  5. 简洁 --过度工程化、过早抽象、违反YAGNI

结果分为高、中或低严重程度。安全问题总是很严重。

要自定义,请添加 config.md 归档 ~/.llm-reviewer/ (全球)或 /.llm-reviewer/ (项目)。

输出格式

Markdown(默认)

### HIGH SQL Injection in query builder
**File:** `src/db.ts` **Line:** 42
**Category:** Security

User input is concatenated directly into SQL query.

**Suggestion:**
Use parameterized queries instead...

文本

无标记格式的纯文本输出。适用于不支持markdown的终端或工具。

JSON

在单个JSON对象中完成结构化输出:

{
  "review": {
    "content": "### HIGH SQL Injection...",
    "model": "gpt-4.1",
    "usage": { "totalTokens": 1234 }
  },
  "diff": {
    "filesChanged": 5,
    "insertions": 120,
    "deletions": 45,
    "files": [
      { "path": "src/db.ts", "status": "modified" }
    ]
  },
  "warnings": [],
  "exitCode": 1
}

对于分块评论,使用情况包括细分:

"usage": {
  "totalTokens": 12450,
  "chunkedBreakdown": { "mapTokens": 7950, "reduceTokens": 4500, "chunks": 3 }
}

NDJSON(流式JSON)

使用 --stream --format json 对于换行符分隔的JSON流:

llm-reviewer --stream --format json | while read line; do
  echo "$line" | jq -r '.text // empty'
done

每一行都是一个有效的JSON对象。启用流输出的实时机器消费。

退出代码

代码含义用例
0成功--无严重性问题正常完成
1审查已完成,结果为高CI门控: `llm-reviewer branch main \\exit 1`
2身份验证失败未找到GitHub令牌
3Diff错误Diff为空,不是git仓库等。
4API/型号错误速率限制,服务器错误,型号不可用
5配置错误配置文件格式不正确

CI集成示例

# Fail the build if high-severity issues are found
llm-reviewer branch main || exit 1

# Or capture the exit code
llm-reviewer branch main
if [ $? -eq 1 ]; then
  echo "High-severity issues found. Please review."
  exit 1
fi

认证

GitHub令牌按优先级顺序解析。第一场比赛获胜。

  1. $GITHUB_TOKEN 环境变量
   export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
   llm-reviewer
  1. 副驾驶配置文件 (由编辑器扩展创建)

- ~/.config/github-copilot/hosts.json - ~/.config/github-copilot/apps.json

  1. GitHub命令行界面(gh)
   gh auth login
   llm-reviewer

该工具会自动将您的OAuth令牌交换为会话令牌,并为后续请求缓存它。

注: 仅Copilot提供者需要GitHub令牌身份验证。Ollama不需要授权。自定义提供程序使用自己的身份验证(请参阅 自定义提供商).

设置身份验证

选项1:GitHub CLI(推荐)

gh auth login

选项2:环境变量

# Get a token from https://github.com/settings/tokens
# Scopes required: read:user, copilot
export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"

选项3:使用副驾驶扩展

在VS Code、Neovim或JetBrains中登录GitHub Copilot。该工具将使用缓存的令牌。

发展

# Clone the repository
git clone https://github.com/asheshv/llm-reviewer.git
cd llm-reviewer

# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

# Run the CLI locally
node dist/cli.js --help

# Or link globally for testing
npm link
llm-reviewer --help

项目结构

llm-reviewer/
├── src/
│   ├── cli.ts                     # CLI entry point
│   ├── mcp-server.ts              # MCP server entry point
│   └── lib/
│       ├── providers/             # Provider abstraction layer
│       │   ├── types.ts           # ReviewProvider interface
│       │   ├── openai-chat-provider.ts  # Shared OpenAI-compatible base
│       │   ├── copilot-provider.ts      # GitHub Copilot provider
│       │   ├── ollama-provider.ts       # Ollama local provider
│       │   ├── custom-provider.ts       # OpenAI-compatible custom provider
│       │   └── index.ts           # Provider factory
│       ├── auth.ts                # Token resolution + session exchange
│       ├── chunking.ts            # Diff splitting + bin-packing
│       ├── config.ts              # Multi-layer config loading
│       ├── diff.ts                # Git diff collection (7 modes)
│       ├── formatter.ts           # Output formatting (text/markdown/json)
│       ├── prompt.ts              # Prompt assembly + file manifests
│       ├── review.ts              # Review orchestration + map-reduce chunking
│       ├── streaming.ts           # SSE parser
│       ├── truncation.ts          # Severity-aware truncation for reduce pass
│       ├── types.ts               # Shared type definitions
│       └── index.ts               # Public API exports
├── test/                          # Tests (vitest + msw)
├── prompts/
│   └── default-review.md          # Built-in review prompt
├── skills/
│   └── SKILL.md                   # Claude Code skill definition
├── docs/
│   ├── spec/                      # Design specifications
│   ├── adr/                       # Architecture decision records
│   ├── plans/                     # Implementation plans
│   └── reference/                 # API documentation
└── .llm-reviewer/                 # Project-level config (dogfooding)
    ├── config.json
    └── config.md

许可证

MIT许可证。看 许可证 了解详情。

______________________________________________________________________

问题或议题? 打开一个问题 .

目录标签

目录标签

代码审查开发工具TypeScriptClaudeGitHub Copilot本地部署LLM工具GitHubCopilotOllama

支持客户端

ClaudeCursorClineVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

oauth

运行时(runtime,运行环境)

Node.js

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiooauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP