@calibrate-ds/core 0.1.75 → 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context/get-component-context.d.ts.map +1 -1
- package/dist/context/get-component-context.js +86 -18
- package/dist/context/get-component-context.js.map +1 -1
- package/dist/docs/generate-component-stories.d.ts.map +1 -1
- package/dist/docs/generate-component-stories.js +9 -19
- package/dist/docs/generate-component-stories.js.map +1 -1
- package/dist/mappings/naming-strategy.d.ts +11 -0
- package/dist/mappings/naming-strategy.d.ts.map +1 -1
- package/dist/mappings/naming-strategy.js +14 -0
- package/dist/mappings/naming-strategy.js.map +1 -1
- package/dist/normalizer/instance-resolver.d.ts.map +1 -1
- package/dist/normalizer/instance-resolver.js +29 -7
- package/dist/normalizer/instance-resolver.js.map +1 -1
- package/dist/normalizer/layout-tree.d.ts.map +1 -1
- package/dist/normalizer/layout-tree.js +11 -6
- package/dist/normalizer/layout-tree.js.map +1 -1
- package/dist/normalizer/variant-diff.d.ts.map +1 -1
- package/dist/normalizer/variant-diff.js +5 -1
- package/dist/normalizer/variant-diff.js.map +1 -1
- package/dist/prompt/generate-component-prompt.d.ts.map +1 -1
- package/dist/prompt/generate-component-prompt.js +15 -5
- package/dist/prompt/generate-component-prompt.js.map +1 -1
- package/dist/verify/pixel-diff.d.ts.map +1 -1
- package/dist/verify/pixel-diff.js +18 -8
- package/dist/verify/pixel-diff.js.map +1 -1
- package/dist/verify/structure-check.d.ts.map +1 -1
- package/dist/verify/structure-check.js +4 -1
- package/dist/verify/structure-check.js.map +1 -1
- package/dist/verify/verdict.d.ts +23 -3
- package/dist/verify/verdict.d.ts.map +1 -1
- package/dist/verify/verdict.js +44 -19
- package/dist/verify/verdict.js.map +1 -1
- package/package.json +3 -3
package/dist/verify/verdict.js
CHANGED
|
@@ -8,33 +8,58 @@
|
|
|
8
8
|
export const VERIFY_PASS_THRESHOLD = 0.90;
|
|
9
9
|
export const VERIFY_WARN_THRESHOLD = 0.70;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* If a pixel score falls below this floor while a token/structure primary exists,
|
|
12
|
+
* the pixel evidence hard-vetos the result — no token score can rescue past it.
|
|
13
|
+
* Catches the scaffold false-positive: a default prop value (aria-label="Button")
|
|
14
|
+
* inflates tokenScore to 1.0 on a blank shell, while pixel exposes the emptiness.
|
|
15
|
+
*/
|
|
16
|
+
export const PIXEL_FLOOR_VETO = 0.10;
|
|
17
|
+
/**
|
|
18
|
+
* Computes a single verdict from a VerifyReport.
|
|
19
|
+
*
|
|
20
|
+
* Primary signal: design-content token match (immune to font/AA differences),
|
|
21
|
+
* falling back to structural slot presence when no text tokens exist.
|
|
22
|
+
*
|
|
23
|
+
* NEW-3 (Session 5 audit): the primary used to be a strict override — tokenScore,
|
|
24
|
+
* when defined, was used *exclusively*. But the token scanner has known blind
|
|
25
|
+
* spots (attribute text, short badge text), so a pixel-perfect render could stamp
|
|
26
|
+
* verified:false / 0% because its visible text lived in a placeholder attribute.
|
|
27
|
+
* The PIXEL score may now rescue a low primary — the two corroborate each other:
|
|
28
|
+
* - low pixel + high token → font/AA rendering noise; token is right
|
|
29
|
+
* - high pixel + low token → scanner blind spot; pixel is right
|
|
30
|
+
* structureScore deliberately can NOT rescue a low tokenScore: it only counts
|
|
31
|
+
* slots, so "right number of text nodes, wrong content" would max it out — a
|
|
32
|
+
* false-pass vector with no corroborating evidence behind it. Pixel rescue never
|
|
33
|
+
* downgrades a result the old chain passed (if token was highest, it still wins).
|
|
14
34
|
*/
|
|
15
35
|
export function computeVerifyVerdict(report) {
|
|
16
|
-
let
|
|
17
|
-
let metric = "none";
|
|
36
|
+
let primary = null;
|
|
18
37
|
if (report.tokenScore !== undefined) {
|
|
19
|
-
|
|
20
|
-
metric = "token";
|
|
38
|
+
primary = { score: report.tokenScore, metric: "token" };
|
|
21
39
|
}
|
|
22
40
|
else if (report.structureScore !== undefined) {
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
primary = { score: report.structureScore, metric: "structure" };
|
|
42
|
+
}
|
|
43
|
+
let pixel = null;
|
|
44
|
+
if (report.pixelMatch) {
|
|
45
|
+
pixel = report.pixelMatch.contentScore !== undefined
|
|
46
|
+
? { score: report.pixelMatch.contentScore, metric: "pixel-content" }
|
|
47
|
+
: { score: report.pixelMatch.score, metric: "pixel" };
|
|
25
48
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
score = report.pixelMatch.score;
|
|
33
|
-
metric = "pixel";
|
|
34
|
-
}
|
|
49
|
+
// Pixel floor veto: catastrophically low pixel evidence (< 10%) with an existing
|
|
50
|
+
// primary means the scaffold's default prop values inflated the token/structure
|
|
51
|
+
// score while the render was visually empty. Pixel wins — the component failed.
|
|
52
|
+
if (primary && pixel && pixel.score < PIXEL_FLOOR_VETO) {
|
|
53
|
+
const verdict = "fail";
|
|
54
|
+
return { verdict, score: pixel.score, metric: pixel.metric };
|
|
35
55
|
}
|
|
36
|
-
|
|
56
|
+
// Prefer the primary; let pixel evidence rescue when it is strictly better.
|
|
57
|
+
const best = primary && pixel
|
|
58
|
+
? (pixel.score > primary.score ? pixel : primary)
|
|
59
|
+
: (primary ?? pixel);
|
|
60
|
+
if (!best)
|
|
37
61
|
return { verdict: "no-comparison", score: null, metric: "none" };
|
|
62
|
+
const { score, metric } = best;
|
|
38
63
|
const verdict = score >= VERIFY_PASS_THRESHOLD ? "pass"
|
|
39
64
|
: score >= VERIFY_WARN_THRESHOLD ? "warn"
|
|
40
65
|
: "fail";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verdict.js","sourceRoot":"","sources":["../../src/verify/verdict.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAA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,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC;IAED,4EAA4E;IAC5E,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK;QACzB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;QACjD,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;IAEzB,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE/B,MAAM,OAAO,GAAkB,KAAK,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM;QAClE,CAAC,CAAC,KAAK,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM;YACzC,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calibrate-ds/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"pixelmatch": "^6.0.0",
|
|
40
40
|
"pngjs": "^7.0.0",
|
|
41
41
|
"zod": "^4.3.6",
|
|
42
|
-
"@calibrate-ds/shared-types": "^0.1.
|
|
43
|
-
"@calibrate-ds/figma-client": "^0.1.
|
|
42
|
+
"@calibrate-ds/shared-types": "^0.1.77",
|
|
43
|
+
"@calibrate-ds/figma-client": "^0.1.77"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc -p tsconfig.json",
|