Перейти к основному содержимому
M

dsh-pixel-lint

maxisoft-git/dsh-pixel-lint

Compares a design screenshot with the built page, capturing the page in headless Chrome when no screenshot is given, and reports the pixel difference, the failing checks and a pass or fail verdict, using a separately installed pixel-validator. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Установка

dsh plugin --profile web add github:maxisoft-git/dsh-pixel-lint

README

Pixel lint

English · Русский · 简体中文

License: MIT DSH >= 0.2.2-rc.1

A numeric gate between a design screenshot and the built page. It adds the pixel_validate tool, the /pixels command and a tab titled «Пиксели» in the right sidebar. The tool compares a reference image with an implementation — an existing screenshot or a capture of a URL taken with headless Chrome — and returns a verdict against a strictness profile: per-pixel difference, per-section difference, colour ΔE at sample points, and the text and spacing drift you measured yourself. It does not edit the page or the design, does not judge how the page looks, and does not ship the comparison scripts: they are a separate local install.

What it adds

RowEffect
Tool pixel_validateCompares reference with implementation or with a capture of url + viewport; optional target to compare one element or rectangle, fit for differing image sizes, JSON files for section, colour, text and spacing checks. Returns a compact PASS/FAIL summary, the failing rows and the report path.
Command /pixelsRepeats the last run of this workspace without a model turn, or runs /pixels <ref> <impl> [profile]. The command-menu entry opens the tab.
Right-sidebar tab «Пиксели»One tab type (pixel-lint): verdict badge, profile and image size, the global diff, per-group pass counts and worst drift, the failing checks, the fit warning, the reference and implementation paths and the report path, with an «Обновить» button.
Host route GET /api/pixel-lint/lastThe JSON the tab renders — the same report the tool returned. Accepts ?sid=<sessionId>, or ?dir=<path> that must stay inside the session workspace; the route answers only a loopback peer with a loopback Host and a same-origin Origin on writes.

Install

DSH 0.2.2-rc.1 or newer.

In DSH. Plugins → Add plugin with the installation spec github:maxisoft-git/dsh-pixel-lint. The plugin manager installs it for the whole profile; a new session picks it up.

From a checkout. git clone https://github.com/maxisoft-git/dsh-pixel-lint.git, then install that absolute directory with Plugins → Add plugin.

Use

  1. Put the design export in the workspace, at the size it will be compared at, for example design/home.png at 390×844.
  2. Ask the agent to compare, or call the tool yourself:
pixel_validate { "reference": "design/home.png", "capture": { "url": "http://localhost:5173", "width": 390, "height": 844 }, "profile": "strict" }
pixel_validate { "reference": "design/home.png", "implementation": "build/home.png" }
pixel_validate { "reference": "design/home.png", "capture": { "url": "http://localhost:5173", "width": 390, "height": 844 }, "target": { "selector": ".card" }, "fit": true }
  1. Or, without a model turn:
/pixels design/home.png build/home.png strict
/pixels

Bare /pixels reads the arguments of the last run from .dsh/pixel-lint/last-args.json and repeats it.

  1. Read the result in the chat or in the right sidebar: open the tab from the sidebar's add control, or pick /pixels in the command menu. The tab and the tool read the same JSON, so they cannot disagree.

The tool compares the whole image unless a target names a region. target.selector and target.text are measured in the live page over the Chrome DevTools Protocol and require capture.url; target.rect works with two ready images; target.pad grows the box without leaving the image. The chosen rectangle is cut out of both images, so the numbers describe that region alone.

The four profiles and their thresholds, which come from the validator install and are recorded in every report:

ProfileGlobalSectionTextSpacingColour
lenient3.5 %2.5 %3 px2 pxΔE 4
portable1.5 %1.0 %2 px1 pxΔE 2.5
strict (default)0.8 %0.5 %1 px1 pxΔE 1.5
ultra0.4 %0.25 %0.5 px0.5 pxΔE 1.0

Facts about a run: reference and implementation must be .png, .jpg, .jpeg or .webp files up to 64 MB, and the check JSON files must live inside the workspace; the implementation is captured at device pixel ratio 1, so 390 CSS px stay 390 px; image sizes must match, and a mismatch is an error unless fit is set — then the smaller image is padded with white, the larger is cropped from the top-left, and the result says which happened; sections, colors, text and spacing are JSON files of extra checks; for text and spacing the plugin only compares the drift between the two numbers you measured.

Configuration

The plugin has no keys in its plugin row. The environment variables are read from the DSH process:

KeyDefaultMeaningWhere it is stored
PIXEL_VALIDATOR_HOME~/.local/share/pixel-validatorDirectory holding validate-visual.sh and summarize-validation.shEnvironment of the DSH process
DSH_PIXEL_LINT_CHROME— (unset; the first existing candidate path is used)Chrome or Chromium binary for capture; when set it is tried before the candidatesEnvironment of the DSH process
DSH_PIXEL_LINT_VALIDATOR_SHA256— (unset)Optional pin: comma-separated sha256 of validate-visual.sh and summarize-validation.sh; a mismatch refuses the runEnvironment of the DSH process
profilestrictStrictness profile of one runThe tool call or the /pixels argument
capture.dpr1Device pixel ratio of a captureThe tool call

The candidate paths, in order: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome, /Applications/Chromium.app/Contents/MacOS/Chromium, /usr/bin/google-chrome, /usr/bin/chromium, /usr/bin/chromium-browser. capture has no chrome field — the model cannot choose the binary; a non-standard installation is selected with DSH_PIXEL_LINT_CHROME.

Data and network

The plugin sends no image and no report anywhere; the only network traffic is the page load of the capture.url you gave. It is opened by the local Chrome: an http(s):// URL without embedded credentials, or a local .html/.htm file inside the workspace. Any other form — a file:// URL outside the workspace, data:, chrome: — is rejected before the browser starts. A page that loads remote resources makes the browser request them.

The comparison runs on this machine: ImageMagick (magick) and the scripts at PIXEL_VALIDATOR_HOME. Chrome is started only for a capture, with a throwaway profile directory in the system temp folder that is removed afterwards, so it never sees your cookies, extensions or history; measuring a target by selector or text starts the same kind of throwaway browser.

Files written on disk, all under <workspace>/.dsh/pixel-lint/:

FileWhen
report.jsonevery run — the full validator report
last.jsonevery run — what the tab renders
last-args.jsonevery run — what bare /pixels repeats
implementation.pnga run with capture
implementation-full.pnga run with capture and a target measured in the page
target-reference.png, target-implementation.pnga run with a target
report.json.aligned.pnga run with fit on images of different sizes
.gitignorewritten with the first run; it contains *, so nothing in the folder is committed

Turning it off: disable the plugin, which removes the tool, the command, the tab and the route. The artifacts stay until you delete .dsh/pixel-lint/.

Security

SECURITY.md — how to report a vulnerability and which versions are supported. SECURITY-AUDIT.md — the per-plugin audit: data flow, permissions, findings and their fixes.

The route answers loopback sockets only, rejects a foreign Origin, takes no request body, and reads a report only from the workspace whose directory it resolved. The plugin never sends the images anywhere and never returns the full report JSON to the model — only the compact summary and paths.

Requirements

  • DeepSeek Harness 0.2.2-rc.1 or newer.
  • Node.js 22.19.0 or newer, as declared in engines.
  • ImageMagick with the magick command: brew install imagemagick on macOS, the distribution package elsewhere.
  • The pixel-validator scripts in ~/.local/share/pixel-validator, or wherever PIXEL_VALIDATOR_HOME points. They are not vendored here: they come from jasny/perfect-agent, which carries no license, so the package only runs them.
  • Chrome or Chromium for capture; not needed when implementation is an existing image. The candidate paths above are macOS and Linux paths.
  • macOS or Linux.

Development

  • npm test runs node scripts/smoke.mjs: a real Chrome capture, the capture-boundary refusals, a deterministic identical run, a drifted run that must fail strict, the size-mismatch refusal, fit and the workspace store. On a machine without Chrome or without the validator scripts it still runs the capture-boundary refusals and skips the rest, which is what CI does.
  • node scripts/smoke-host.mjs and node scripts/smoke-target.mjs cover the mounted plugin — tool, refusals, /pixels, the route — and the target geometry; they are run directly, not by npm test.
  • npm run verify checks the manifest, the patch file, the three locale files and the required README, LICENSE, CHANGELOG, SECURITY and SECURITY-AUDIT files.
  • Local link install: Plugins → Add plugin with the absolute path of the checkout. No build step.
  • Layout: index.js (Host: route, tool, /pixels), client.js (Browser: the tab), lib/validator.mjs (validator and Chrome capture), lib/cdp.mjs (DevTools Protocol driver for measuring an element), lib/target.mjs (target validation and cropping), lib/report.mjs (report shaping and the workspace store), cordis.patch.yml, locale/, scripts/.

License

MIT © 2026 maxisoft-git

Похожие плагины