返回 Skill 列表
extension
分类: 开发与工程无需 API Key

本地代码审查·独立验证器

离线双遍代码审查:生成 findings 后独立复核证据,只报 VERIFIED 结论,代码不出机

person作者: dthzlxhubModelScope

Local Code Reviewer(本地代码审查 × 独立验证器)Skill Guide

pre-commit 场景的离线代码审查。核心差异化:两遍协议 — pass 1 生成 findings,pass 2 用独立上下文逐条复核(文件存在/行号有效/证据原文一致/规则可复现),幻觉 finding 直接拦截,只输出 VERIFIED 结论。涉密仓库代码全程不出机。

Usage

Windows:       scripts\run.ps1 <command> [argument]
macOS / Linux: scripts/run.sh  <command> [argument]

两个启动器接同一套命令与退出码,下表以 Windows 写法示例(POSIX 把 scripts\run.ps1 换成 scripts/run.sh、把 Windows 路径换成 POSIX 路径即可)。

Examples:

| Intent | Command | | --- | --- | | 审查一个文件 | scripts\run.ps1 review D:\repo\payment.py | | 审查整个目录 | scripts\run.ps1 review D:\repo\src | | 查看引擎与规则集状态 | scripts\run.ps1 status | | 停止常驻服务 | scripts\run.ps1 shutdown | | 模型下载超时后续跑 | scripts\run.ps1 --continue |

Important:

  • scripts\run.ps1 (Windows) / scripts/run.sh (macOS, Linux) is the only supported interface — do not call other scripts directly.
  • First call downloads the local review model (Qwen2.5-Coder-1.5B-Instruct INT4); if it times out, run the same launcher with --continue to resume.
  • On non-supported hardware the skill prints an error and exits with code 1.
  • Never falls back to a cloud service — code content stays on this machine.

Interpreting the reply

  • 报告为 Markdown:结论: N 条 VERIFIED / M 条被验证器拦截;每条 VERIFIED finding 带 [severity] rule — 文件:行号、证据原文(反引号内为该行实际内容)与说明。
  • 被拦截 段列出证据不可复现的 finding 及拦截原因(透明度,便于评估验证器行为)。
  • 末行统计:生成 X 条 / 验证通过 Y 条 / 拦截 Z 条

Failure handling

  • exit 0 成功;exit 1 参数/路径/初始化错误;exit 2 本地服务通信失败(重跑会自动重启服务);exit 3 模型下载中(用 --continue)。
  • 服务端异常置 state=error 并写完整 traceback 到日志目录(~/.openvino/log/)。

Environment

  • 引擎默认 openvino(真实本地模型)。CODE_REVIEWER_ENGINE=mock 切到零下载的静态引擎,供 CI 与冒烟测试使用。
  • CODE_REVIEWER_LLM_DIR 指定模型目录,覆盖 info.json 默认选型;CODE_REVIEWER_DEVICECPU/GPU/NPU
  • <skill root>/.env(KEY=VALUE,每行一条,不随作品包发布)可为单台机器覆盖上面这些变量;OPENVINO_SKILL_PYTHON 指向已装好 OpenVINO 的解释器时跳过托管 venv,避免重复安装依赖。

What this skill does NOT do

  • 不改代码、不自动修复(只报告,修复决定权在人)。
  • 不联网查 CVE 库、不上传任何代码片段。
  • 不替代测试与 CI(发现的是静态可验证问题,非全部缺陷)。