@reneturcios/visualdiff

中文文档
0.1.0发布于 2026/11/02MITES Module

SnapDiff visual testing from the terminal and MCP: verify UI changes against a baseline, compare pages, capture screenshots, and render HTML/CSS to images. One bin serves a small CLI and a stdio MCP server.

原始使用文档
文档目录6 节
  1. Install
  2. CLI
  3. MCP server
  4. Tools
  5. Development
  6. License

visualdiff

visualdiff wraps the SnapDiff visual-testing API: verify that a UI change matches what you meant to do, diff two pages (or a page against a stored baseline), capture a screenshot of any URL, and render raw HTML/CSS straight to an image. One binary serves a command-line interface and a stdio MCP server.

An API key is required. Set SNAPDIFF_API_KEY to a key from the SnapDiff dashboard; calls fail before any request is made when it is missing. The API base URL can be overridden with SNAPDIFF_API_URL; when it is not set, calls go to https://api.snapdiff.ai/v1.

Install

npx @reneturcios/visualdiff screenshot https://example.com

Or run the container image:

docker run -i -e SNAPDIFF_API_KEY=sk_live_... ghcr.io/cloudcorprecords/visualdiff

The container defaults to the MCP server (see below). Pass CLI arguments to use it as a CLI instead.

CLI

export SNAPDIFF_API_KEY=sk_live_...

visualdiff verify myproj pricing https://staging.example.com/pricing "added a yearly billing toggle"
visualdiff compare https://staging.example.com --before https://www.example.com
visualdiff compare http://localhost:3000 --project myproj --page-name homepage
visualdiff screenshot https://example.com --width 800 --full-page
visualdiff html-to-image "<h1>Hello</h1>" --css "h1 { color: navy; }" --width 1200 --height 630

visualdiff --version

Commands print the upstream JSON payload. Exit codes: 0 on success, 1 when a call fails (including a missing API key or an upstream API error), 2 for usage errors.

MCP server

One bin serves both faces. The mcp subcommand starts a stdio MCP server:

npx -y @reneturcios/visualdiff mcp

MCP client configuration:

{
  "mcpServers": {
    "visualdiff": {
      "command": "npx",
      "args": ["-y", "@reneturcios/visualdiff", "mcp"],
      "env": { "SNAPDIFF_API_KEY": "sk_live_..." }
    }
  }
}

Tools

ToolInputWhat it returns
snapdiff_verify_ui_changeproject, page_name, after, intent (all required); optional intent_regions, branch, threshold, match_tolerance_percent, ignore_selectors, full_pageA verdict (pass, expected_change_detected, unexpected_regression, no_change_detected, or needs_human_review), a next_action, and a review_url. Requires a project with a stored page baseline.
snapdiff_compare_pagesafter (required); plus before, or project + page_name for baseline mode; optional branch, threshold, ignore_selectors, full_pageA diff percentage plus a highlighted diff image.
snapdiff_capture_screenshoturl (required); optional full_page, dark_mode, selector, widthA screenshot of the page.
snapdiff_html_to_imagehtml (required); optional css, width, heightThe rendered image (OG cards, social images, email headers).

Each tool is sent as a POST to a per-tool endpoint under the base URL with the API key as a Bearer token. Optional arguments that are not supplied are omitted from the request body entirely.

Development

npm install
npm run build   # tsc -> dist/
npm test        # node test runner over test/*.test.ts, no network (fake fetch fixtures)
npm run dev     # run the CLI from source via tsx

License

MIT — see LICENSE.

版本与发布记录

@reneturcios/visualdiff 共发布 2 个版本,首次发布于 2026/11/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 @reneturcios/visualdiff 的常见问题

@reneturcios/visualdiff 是什么?

来自终端和MCP的SnapDiff视觉测试:根据基线验证UI更改,比较页面,捕获屏幕截图,并将HTML/CSS呈现为图像。一个bin提供一个小型CLI和一个studio MCP服务器。

如何安装 @reneturcios/visualdiff?

在项目目录运行 npm install @reneturcios/visualdiff,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 visualdiff,可以用 npx visualdiff 直接运行。

@reneturcios/visualdiff 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/reneturcios__visualdiff 是否存在。

@reneturcios/visualdiff 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@reneturcios/visualdiff 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@reneturcios/visualdiff 可以商用吗?

@reneturcios/visualdiff 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@reneturcios/visualdiff 还在维护吗?

最新版本 0.1.0 发布于 2026/11/02(1 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。