Rendercheck

io.github.ParthibanRajasekaran由 GitHub 账号 ParthibanRajasekaran 发布v0.6.0更新于 Nov 1, 2026

Check from a screenshot that text is really visible to users. Local, offline OCR.

已验证STDIO仅桌面浏览器自动化开发者工具

概览

AI 生成的概览

本地离线 OCR 服务器,让助手检查截图中的文字是否真的可见、清晰且渲染正确。

可以做什么
  • 校验截图文字:确认预期文字确实可见、清晰可读,可设置 OCR 置信度与 WCAG 对比度阈值
  • 读取截图文字:返回用户实际看到的文字,即原始 OCR 结果
  • 可作用于整张图片或指定区域,指定页面元素时还会与 DOM 文本比对
  • 完全在进程内通过 Tesseract.js WebAssembly 运行,不发起网络请求
适用场景
适合助手处理界面代码或测试时,确认屏幕上真正渲染出来的内容而非 DOM 中的内容,例如发现错误的货币符号、被遮挡的文字或对比度过低的文字。也适合在终端或编码助手中从截图中读取文字。
运行要求
作为本地 stdio 进程运行,通过 npx 从 @rendercheck/sdk 这个 npm 包启动,需要 Node.js 18 或更高版本。未声明需要 API 密钥、账号或环境变量。包内只附带英文 OCR 数据,其他语言需自行下载 traineddata 文件并设置 langPath。
安装前请注意
OCR 并不完美:可能误读相似字符或漏读文字,极淡的文字可能完全读不出来,因此结果只是估计而非证明。对比度基于像素测量,渐变、文字背后的图片和抗锯齿会影响准确性。它只校验可见文字,不检查布局、间距或对比度以外的颜色。使用次数会写入本地日志,除非设置 RENDERCHECK_NO_USAGE_LOG;失败记录仅在设置 RENDERCHECK_REPORT_DIR 时才会写入。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Rendercheck,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

RenderCheck

Assert what users actually see, not just what is in the DOM. RenderCheck takes a screenshot, reads it with OCR on your machine, and fails your Playwright or Cypress test with a clear message when the rendered text is wrong, too faint to read, or not there at all.

Renamed. Up to 0.4.1 this package was published as @freetextfromimage/rendercheck. From 0.5.0 it is @rendercheck/sdk; the API is unchanged. See the CHANGELOG for migration steps.

  • Local only. OCR runs in-process (Tesseract.js, WebAssembly). No API key, no upload, no network calls. The English language data ships in the package.
  • Catches what DOM tests cannot: a € where a $ should be, text covered by another element, low-contrast text, text the DOM has but the screen does not show.
  • Plays well with CI. No native modules (pure-JS PNG/JPEG decoding), no browser-side code.
Expected to find text "[Total: $14.00]" but OCR read "[Total: €14.00]" (Confidence: 96%)  Diff: Total: [$]14.00  →  Total: [€]14.00

Install

bash
npm install --save-dev @rendercheck/sdk

Requires Node 18+, and @playwright/test (≥ 1.40) or cypress (≥ 12).

Playwright

ts
import { test } from '@playwright/test';import { expect } from '@rendercheck/sdk/playwright'; // Playwright's expect + toShowText
test('checkout shows the right total', async ({ page }) => {  await page.goto('/checkout');
  await expect(page).toShowText('Total: $14.00', {    minConfidence: 85,      // OCR confidence of the matched words (default 80)    minContrastRatio: 4.5,  // WCAG contrast of the matched words (off unless set)  });
  // One element: also compared with its DOM text (innerText).  await expect(page.locator('#total')).toShowText('Total: $14.00');
  // Only part of the screenshot (CSS pixels from its top-left corner).  await expect(page).toShowText('Pay now', { region: { x: 120, y: 340, width: 200, height: 40 } });
  await expect(page).not.toShowText('Total: €14.00');});

Like Playwright's own assertions, toShowText retries until it passes or timeout (default 5000 ms) runs out. Already using expect.extend? Import toShowText from the same path and add it yourself.

Prices and dates in the right locale

ts
await expect(page).toShowCurrency(1234.5, { currency: 'EUR', locale: 'de-DE' }); // expects "1.234,50 €"await expect(page).toShowDate('2026-03-04', { locale: 'en-GB' });               // expects "04/03/2026"await expect(page).toShowDate('2026-03-04', { locale: 'en-GB', format: { day: 'numeric', month: 'long', year: 'numeric' } });

The expected text comes from Intl, so each locale's separators, symbol position and date order are applied for you. When the screen shows something else, the failure says what it is: The screen shows USD ($14.00), not GBP (£14.00). or The date is formatted for en-US (03/04/2026), but en-GB should show 04/03/2026. Dates use UTC unless you pass dateTimeZone, so they are the same on every CI machine.

Cypress has the same checks: cy.matchCurrency(1234.5, { currency: 'EUR', locale: 'de-DE' }) and cy.matchDate('2026-03-04', { locale: 'en-GB' }). In other tools, expectedCurrency and expectedDate (from the package root) give you the text to pass to toShowText.

Right-to-left and other scripts. Direction marks and non-breaking spaces are ignored in every comparison, so Intl output and DOM text match what OCR reads. Only English OCR data ships with the package. For Arabic, Hebrew, Japanese and the like, download the .traineddata file and set langPath; the language is then picked from the locale (ar-EG uses ara), or set lang yourself. Arabic locales use Arabic-Indic digits, so a page that shows 14.00 where ١٤٫٠٠ belongs fails, which is usually what you want.

Cypress

ts
// cypress.config.tsimport { defineConfig } from 'cypress';import { registerRenderCheck } from '@rendercheck/sdk/cypress/plugin';
export default defineConfig({  e2e: { setupNodeEvents(on) { registerRenderCheck(on); } },});
// cypress/support/e2e.tsimport '@rendercheck/sdk/cypress';
// in a testcy.visit('/checkout');cy.matchText('Total: $14.00', { minConfidence: 85, minContrastRatio: 4.5 });cy.get('#total').matchText('Total: $14.00');

Tested in a real Cypress (13.17, Electron, Linux): examples/cypress runs 5 specs against the mock checkout page, including the failing cases. Other Cypress versions and browsers are untested. Run it with npm run build && npx cypress@13 run --project examples/cypress (add --browser electron).

Command line and AI agents

Check a screenshot from a terminal, a script or an AI coding agent. Same local, offline OCR.

bash
npx @rendercheck/sdk verify screenshot.png --expect "Total: $14.00" --min-contrast 4.5npx @rendercheck/sdk read screenshot.png --json

Exit code 0 means pass, 1 the assertion failed, 2 an error. --json prints { pass, failure, read, confidence, box, message }.

MCP server

rendercheck mcp is a Model Context Protocol server over stdio with two tools: verify_text (is this text really visible, legible and readable?) and read_text (what does a user see?).

json
{  "mcpServers": {    "rendercheck": { "command": "npx", "args": ["-y", "@rendercheck/sdk", "mcp"] }  }}

Claude Code: claude mcp add rendercheck -- npx -y @rendercheck/sdk mcp.

Set up every agent in a repo in one step:

bash
npx @rendercheck/sdk init            # Claude Code, Codex/AGENTS.md, Cursor, Copilotnpx @rendercheck/sdk init --agents claude,cursor --dry-run

It adds a short instruction ("after changing UI, verify the pixels with verify_text") and the MCP server entry. Re-running is safe: only the marked RenderCheck block is updated.

Runs are counted in ~/.rendercheck/usage.jsonl on your machine only, so rendercheck stats can show them to you. Screenshot text is never recorded and nothing is sent anywhere. Set RENDERCHECK_NO_USAGE_LOG=1 to turn it off.

Core

ts
import { verifyText } from '@rendercheck/sdk/core';
const report = await verifyText({  image: fs.readFileSync('screenshot.png'), // PNG or JPEG  expected: 'Total: $14.00',  options: { minContrastRatio: 4.5 },});if (!report.pass) console.error(report.message);

recognize(image, { region }) gives the raw OCR result (words, lines, boxes in image pixels), and analyzeWordContrast the WCAG contrast math, if you want to build your own assertions.

Options

OptionDefault
regionwhole screenshot{ x, y, width, height } in screenshot pixels
minConfidence80minimum OCR confidence (0-100) of the matched words
minContrastRatiooffminimum WCAG contrast ratio, e.g. 4.5 (normal text) or 3 (large text)
exactfalsethe region's text must equal the expected text, not just contain it
ignoreCasefalsePAY NOW is not Pay now unless you say so
domtruewith a Locator, compare with the element's DOM text too
timeout / interval5000 / 250Playwright: retry window and pause between attempts (ms)
fullPagefalsePlaywright: capture the whole scrollable page
lang / langPatheng / bundledother Tesseract languages: point langPath at the folder with <lang>.traineddata.gz

Pull request annotations (GitHub Actions)

When an assertion fails, RenderCheck can leave a record for CI: a JSON file and a copy of the screenshot with the failing text outlined in red. The GitHub Action in action/ turns those into pull request annotations on the failing test line ("Expected Total: $14.00, OCR read Total: €14.00, failing region x=140, y=244, 219×24 px"), a job summary table, and a downloadable report with the outlined screenshots.

yaml
env:  RENDERCHECK_REPORT_DIR: rendercheck-report      # on GitHub Actions this is already the defaultsteps:  - run: npx playwright test                       # or cypress run  - uses: ParthibanRajasekaran/text-from-image/packages/rendercheck/action@<ref>    if: always()

Records are off outside GitHub Actions unless you set RENDERCHECK_REPORT_DIR (set it to an empty string to switch them off there). A failure is recorded once, after the last retry, and a retry that passes removes it. GitHub annotations attach to source lines, not screen coordinates, so the region is written in the message and drawn on the screenshot. Everything stays in your workflow: no service, no token, no network call.

What it can and cannot do

  • OCR is not perfect. It can misread l/I/1 and O/0, and it can skip text. Light text on a coloured background is often missed on a busy page: scope the assertion to the element (page.locator('#pay')) or a region. Very faint text, which is exactly what a contrast check looks for, may not be read at all. Then the assertion still fails, reported as "in the DOM but not visible in the rendered pixels".
  • Contrast is measured on pixels (text colour vs the colour around it, by k-means), not from CSS. Gradients, images behind text and anti-aliasing make it an estimate.
  • It verifies visible text. It does not check layout, spacing or colour beyond contrast; use it with visual-regression tooling, not instead of it.
  • English only out of the box.

Network

No code in this package makes a network request. Tesseract's own cache is switched off, so nothing is written to your project either. (Failure records are the one exception, and only when you turn them on: see above.) To check it yourself on Linux: npm run test:offline runs the tests in a network-less namespace (unshare -rn).

Example

examples/playwright/ is a Playwright suite against a mock checkout page (a local HTML file), including the failing cases: wrong currency, low contrast, text covered by another element.

bash
npx playwright install chromium   # oncenpm run test:example

examples/github-actions.yml shows it in CI.

License

MIT

Links

来源:packages/rendercheck/README.md,提交 0ff6815

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.6.0最新Oct 11, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。