perch README

项目的 README,来自 github.com/lakeday-org/perch。合并为一个 markdown 文件:README.md。

perch

npm ci node license perch

perchscan.com  ·  docs  ·  benchmarks  ·  Discord

Semantic code and security scanner.

Known bugs caught on the Greptile benchmark and the cost of a pull request: Greptile 82% at about $1, perch on OpenAI Decisions 76% at $0.007, Cursor Bugbot 58% at about $1.50, GitHub Copilot 54%, CodeRabbit 44% at $1–3, perch on Jev 44% at $0.003, Graphite 6% at about $2

Getting started

npm install -g @lakeday/perch
perch login
perch scan

perch login signs you in to Perch Cloud, where the first $5 is free. Since decisions are cached, running perch again on unchanged code is free. Perch Cloud also scans pull requests in CI, without writing any workflows.

$ perch scan
checkout.py
  ID        Line  Severity  Type    Confidence  Problem                     Method
  bdc67421    14  P1 (0.8)  defect         81%  wrong_order                 place_order
  ddc5c917    24  P1 (0.8)  defect         92%  inverted_condition          can_fulfil

cart.py
  ID        Line  Severity  Type    Confidence  Problem             Method
  287bfb9d     9  P1 (1.0)  defect         90%  off_by_one          subtotal
  80d6ebbb    29  P1 (1.4)  defect         89%  unhandled_null      cheapest

✖ 20 problems in 5 files, all failing

Run perch issues to see them worst first, and perch issues <id> to view one.

perch check <id> asks again after you think you've fixed it. It doesn't record anything.

Agent skills

perch setup claude-code   # .claude/skills/perch/SKILL.md
perch setup codex         # .codex/skills/perch/SKILL.md
perch setup pi            # .pi/skills/perch/SKILL.md
perch setup cursor        # .cursor/rules/perch.mdc

Semantic linting

You can extend perch with your own linting rules by adding them to perch.yaml:

- name: private-logs
  where: "src/**/*.ts"
  each: method
  ensure: >
    Keep passwords and access tokens out of logs.

ReviewBench

Recall on ReviewBench and the cost of a pull request: Laude RevEngine Prime 46.3%, perch on OpenAI Decisions 40.0% at $0.024, then the leaderboard's other reviewers down to Cursor at 9.6%, and perch on Jev 7.9% at $0.011

ReviewBench is GitHub's benchmark for AI code review. Perch is credited when it flags the method holding a labelled bug; the leaderboard credits a review comment that a judge model matches to one. The runs, the answers and how to reproduce them are linked from .benchmarks/reviewbench.

The numbers
Reviewer Recall
Laude RevEngine Prime 46.3%
Perch · OpenAI Decisions, $0.024 a pull request 40.0%
block/review 32.6%
Klaussy 29.8%
Copilot code review 26.0%
DeepSeek Harness Reviewer 25.6%
Devin AI 23.8%
Qodo 22.1%
Codex 18.5%
Cubic 16.3%
Greptile 16.2%
Cursor 9.6%
Perch · Jev, $0.011 a pull request 7.9%

Greptile benchmark

Greptile's benchmark runs code reviewers on 50 pull requests, each with one known bug. The runs and their labels are linked from .benchmarks/greptile.

Perch is credited when it flags the function holding the known bug. The published tools were credited for a line comment identifying it.

Models

By default, Perch Cloud routes your questions to the best model for answering them. To ask a specific decision model, override the endpoint, key, and model:

export PERCH_BASE_URL=https://api.typesafe.ai/v1/systemone
export PERCH_API_KEY='paste-your-TypeSafe-key-here'
export PERCH_MODEL_ID=jev-latest
Model PERCH_BASE_URL PERCH_MODEL_ID
Jev https://api.typesafe.ai/v1/systemone jev-latest
Liquid AI d1 https://api.liquid.ai/decisions/v1/systemone d1:free
OpenAI gpt-6-luna https://api.openai.com/v1/decisions gpt-6-luna
DiffusionGemma Jev on Beam https://app.beam.cloud/v1/models/jev/diffusiongemma/invoke jev/diffusiongemma
SemiF on Beam https://app.beam.cloud/v1/models/jev/semif/invoke jev/semif

Any endpoint that supports the System One format will work, and so does OpenAI's Decisions API: perch recognizes a PERCH_BASE_URL ending in /decisions and reads its key from OPENAI_API_KEY when PERCH_API_KEY is not set. Each model gets as many questions per request as it says it takes. For a model that doesn't say, set PERCH_MAX_QUESTIONS. See the benchmarks for a comparison.

Documentation

Getting started Install, sign in, the first scan.
Reading issues The list, the filters, closing what does not matter.
Semantic linting where, each, sees, context, min, gate, and the longhand grammar.
Checking a change perch check on work in progress.
perch in CI What a build can gate on, and what it cannot.
Command reference Every command, its flags, and what each exit code means.
Scan internals The graph walk, the questions, and how probabilities turn into a ranking.

Perch files

Location Contents
.perch/ Generated scan results and cache files, alongside the committed files below. Use --out <directory> to choose another results location.
.perch/rules/ Custom rules split across .yaml and .yml files. Commit these files.
.perch/closed.jsonl Dismissed findings and their reasons. Commit this file.
perch.yaml Custom rules. Updated by perch rules add, edit, and remove.
.claude/, .codex/, .pi/, .cursor/ Instructions installed for the selected assistant by perch setup <assistant>.

Development

npm install       # dependencies
npm run check     # lint, typecheck, test
npm run build     # bundle src/cli.js into dist/cli.mjs

npm link after a build puts the checkout's perch on your PATH.

perch (lakeday-org/perch)

正在搜索数据库…

这是什么?Perch 是一个命令行语义代码检查器,它使用决策模型(Decision Models)而非单纯的语法规则来扫描代码库中的真实问题,并把发现的问题按严重程度从最差开始排序。
这是 CLI 工具,还是能在编辑器里使用?它主要是 CLI 工具(perch issues、perch check),但也会安装“智能体技能”,让 Claude Code、Codex、Cursor 和 pi 等编程助手可以直接使用它。
怎么让它跑起来?在 console.typesafe.ai 创建 API 密钥,把它设置为 PERCHAPIKEY 环境变量,然后运行 perch issues 查看首次扫描结果。
扫描之前必须有 API 密钥吗?需要,perch 调用托管服务,必须先有从 console.typesafe.ai 生成的 PERCHAPIKEY 才能运行。
问题的排序是固定的规则检查,还是更偏主观判断?扫描的工作方式是遍历一个问题图并把概率转换成排序,因此结果更接近加权判断,而不是确定性的规则匹配。
perch issues 和 perch check 有什么区别?perch issues 按严重程度从最差开始列出所有发现,并允许你打开其中一条;perch check 在修复之后重新扫描进行中的工作,并记录仍然发现的问题。
.perch/closed.jsonl 存储什么?它记录你忽略的发现以及你给出的理由,应当与你的规则一起提交到版本库。
perch 可以与哪些编程智能体集成?perch setup 会把指令安装到 .claude/、.codex/、.pi/ 或 .cursor/ 文件夹,覆盖 Claude Code、Codex、pi 和 Cursor。
大小
42 MB
星标
317
时长
2个月
提交 · 90 天