dia-scoring
GitHub用于对比HTML与SVG渲染差异的评分技能,基于Playwright和Canvas像素级比对,确保测量准确性。
Trigger Scenarios
Install
npx skills add mermaid-js/zenuml-core --skill dia-scoring -g -y
SKILL.md
Frontmatter
{
"name": "dia-scoring",
"description": "Score HTML-vs-SVG diagram parity in compare-case pages, including message labels, fragment labels, sequence numbers, arrows, participant headers, icons, stereotypes, participant colors, participant groups, comments, and residual diff scopes. Use Playwright for page inspection and semantic attribution; use the live `#diff-panel canvas` as the sole pixel-diff source of truth."
}
Dia Scoring
Use this skill when the task is to measure message labels, fragment labels, sequence numbers, message arrows, participant labels, participant boxes, participant icons, stereotypes, participant colors, participant groups, inline comments, and residual diff hotspots between the HTML renderer and the native SVG renderer on compare-case.html. Use Playwright page inspection only to inspect the page and semantically attribute diffs to letters or elements. Use the live #diff-panel canvas as the sole pixel-diff source of truth.
The workflow is browser-native:
- Open
http://localhost:14000/e2e/tools/compare-case.html?case=<name>. - Treat the
native-diff-extextension as required for pixel diff work: it generates the live#diff-panel canvason page load. - Use the analyzer script at ../../scripts/analyze-compare-case.mjs.
- Prefer
--jsonwhen the next step is automated processing. - Prefer
--output-dir <dir>when you need savedhtml.png,svg.png,diff.png, andreport.json. - Treat all pixel-diff comparison and residual scoping as live-panel work sourced from
#diff-panel canvas. - When recalibrating or correcting this skill itself, use the live
#diff-panel canvasto calibrate the skill's measurement rules and reporting language.
Offset Anchor
All reported offsets must use the outermost frame's top-left corner as the anchor.
- HTML anchor: the compare-case HTML frame root
- SVG anchor: the compare-case SVG root / outer frame root
- Do not report alternate offset systems
- Do not anchor offsets to participant boxes, label boxes, stereotype boxes, or local containers
- If a local-container-relative reading differs from the frame-anchor reading, prefer the frame-anchor reading in all reporting
Browser Requirement
Use Playwright browser tools only for browser interaction in this workflow.
- Preferred tools:
browser_navigate,browser_snapshot,browser_evaluate,browser_take_screenshot,browser_click,browser_wait_for - Do not use Chrome DevTools browser tools for scoring, DOM inspection, screenshot capture, or residual validation
- Do not build your own pixel diff from HTML/SVG screenshots. For pixel comparison, use only the extension-rendered
#diff-panel canvas
Rules
- Do not use
html-to-imagefor capture. - Use browser-native screenshots only.
- Use Playwright for browser-native screenshots and page inspection.
- Use the extension-generated live
#diff-panel canvasas the sole source for pixel diff comparison and residual validation. - All offset calculations must be anchored to the outermost frame's top-left corner.
- When re-checking, recalibrating, or correcting
dia-scoringitself, calibrate the skill against the live#diff-panel canvas, not against a separately-built diff or memory of prior results. - If
#diff-panel canvasis absent, do not recalibrate or correctdia-scoringitself. - Never build or trust a local screenshot-to-screenshot pixel diff when
#diff-panel canvasis the question. - Do not use Chrome DevTools browser tools for this workflow.
- Scope:
- normal messages
- self messages
- returns
- fragment conditions such as
[cond],[else] - fragment section labels such as
catch,finally - participant label text and participant box geometry
- participant icons (actor, database, ec2, lambda, azurefunction, sqs, sns, iam, boundary, control, entity)
- participant stereotypes such as
«BFF»,«Interface» - participant background colors (
#FFEBE6,#0747A6, etc.) and computed text contrast - participant groups (dashed outline containers with title bar)
- inline comments (
// text) above messages and fragments, including styled comments (// [red] text) - residual
html-onlyandsvg-onlydiff clusters scoped back to nearby elements
- For each supported message, include:
- label text
- fragment condition / section label text when present
- sequence number text, including fragment sequence numbers when present
- arrow geometry keyed by sequence number
- normal/return arrow endpoint deltas:
left_dx,right_dx,width_dx - self-arrow loop geometry from the painted loop path plus arrowhead, not the outer
svgviewport - self-arrow vertical deltas:
top_dy,bottom_dy,height_dy
- For participant icons, include:
- icon presence (HTML vs SVG)
- participant label text when the participant has an icon
- icon position relative to participant label
- icon visual match confirmation from diff image
- For participant stereotypes, include:
- stereotype text presence (HTML vs SVG), e.g.
«BFF» - stereotype position relative to participant label (above label, smaller font)
- stereotype offset must be measured with per-letter glyph-box comparison relative to the outermost frame anchor
- do not use participant-box-relative or other local-container-relative deltas in final reporting
- do not mark a stereotype as clean from glyph boxes alone; also check the live
#diff-panel canvasin the stereotype row - if glyph-box deltas are
0/0but the panel still shows localized red/blue pixels overlapping the stereotype glyph union, report the stereotype asambiguousorpaint-level residual, not clean - stereotype text color matching participant background contrast
- stereotype text presence (HTML vs SVG), e.g.
- For participant colors, include:
- background fill color (hex value) on participant rect
- text color contrast (dark text on light bg, white text on dark bg)
- color application to both top and bottom participant boxes
- For participant groups, include:
- group name text presence and position (centered title bar)
- dashed outline rect enclosing grouped participants
- group bounds: leftmost to rightmost participant with margin
- group height extending to diagram bottom
- For inline comments, include:
- comment text presence and position (above the associated statement)
- comment Y offset from the message/fragment it belongs to
- fragment-level comments (e.g.
// comment 4beforeif(...)) positioned above fragment header - styled comment color application (e.g.
// [red] text)
- For participant boxes, include:
html_boxandsvg_boxwithx,y,w,h- box deltas
dx,dy,dw,dh - SVG measurement based on the painted outer bounds of the stroked box, not the inset rect geometry
- For residual scopes, include:
- connected
html-onlyandsvg-onlydiff clusters from#diff-panel canvas - cluster
size,bbox, andcentroid - nearest scoped HTML and SVG targets at that position
- summaries that explain which element a remaining positional diff most likely belongs to
- live native diff panel confirmation before claiming a hotspot is real
- the largest confirmed live-panel
html-onlyandsvg-onlyclusters with approximate positions - grouped summaries of where the panel's red and blue pixels are concentrated
- connected
- Do not report a residual hotspot as real if it is absent from the live
#diff-panel canvas. - Do not stop at totals like
HTML-only (44)orSVG-only (55)when residuals matter; report where those pixels are. - Each reported letter must be backed by:
- direct HTML-vs-SVG browser layout positions
- pixel-panel confirmation from
#diff-panel canvas
- Participant stereotypes are first-class targets, not just part of
participant-boxorparticipant-label. - If the evidence is weak or contradictory, keep the letter
ambiguous.
Commands
Run from ../..:
node scripts/analyze-compare-case.mjs --case async-2a
node scripts/analyze-compare-case.mjs --case async-2a --json
node scripts/analyze-compare-case.mjs --case async-2a --output-dir tmp/message-elements/async-2a
References
- Selector and pairing details: references/selectors-and-keys.md
Version History
- 377f600 Current 2026-08-20 15:11


