@calibrate-ds/core 0.1.74 → 0.1.76
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/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 +8 -3
- 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 +16 -3
- package/dist/verify/verdict.d.ts.map +1 -1
- package/dist/verify/verdict.js +30 -19
- package/dist/verify/verdict.js.map +1 -1
- package/package.json +3 -3
package/dist/verify/verdict.js
CHANGED
|
@@ -8,33 +8,44 @@
|
|
|
8
8
|
export const VERIFY_PASS_THRESHOLD = 0.90;
|
|
9
9
|
export const VERIFY_WARN_THRESHOLD = 0.70;
|
|
10
10
|
/**
|
|
11
|
-
* Computes a single verdict from a VerifyReport
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Computes a single verdict from a VerifyReport.
|
|
12
|
+
*
|
|
13
|
+
* Primary signal: design-content token match (immune to font/AA differences),
|
|
14
|
+
* falling back to structural slot presence when no text tokens exist.
|
|
15
|
+
*
|
|
16
|
+
* NEW-3 (Session 5 audit): the primary used to be a strict override — tokenScore,
|
|
17
|
+
* when defined, was used *exclusively*. But the token scanner has known blind
|
|
18
|
+
* spots (attribute text, short badge text), so a pixel-perfect render could stamp
|
|
19
|
+
* verified:false / 0% because its visible text lived in a placeholder attribute.
|
|
20
|
+
* The PIXEL score may now rescue a low primary — the two corroborate each other:
|
|
21
|
+
* - low pixel + high token → font/AA rendering noise; token is right
|
|
22
|
+
* - high pixel + low token → scanner blind spot; pixel is right
|
|
23
|
+
* structureScore deliberately can NOT rescue a low tokenScore: it only counts
|
|
24
|
+
* slots, so "right number of text nodes, wrong content" would max it out — a
|
|
25
|
+
* false-pass vector with no corroborating evidence behind it. Pixel rescue never
|
|
26
|
+
* downgrades a result the old chain passed (if token was highest, it still wins).
|
|
14
27
|
*/
|
|
15
28
|
export function computeVerifyVerdict(report) {
|
|
16
|
-
let
|
|
17
|
-
let metric = "none";
|
|
29
|
+
let primary = null;
|
|
18
30
|
if (report.tokenScore !== undefined) {
|
|
19
|
-
|
|
20
|
-
metric = "token";
|
|
31
|
+
primary = { score: report.tokenScore, metric: "token" };
|
|
21
32
|
}
|
|
22
33
|
else if (report.structureScore !== undefined) {
|
|
23
|
-
|
|
24
|
-
metric = "structure";
|
|
34
|
+
primary = { score: report.structureScore, metric: "structure" };
|
|
25
35
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
metric
|
|
30
|
-
|
|
31
|
-
else {
|
|
32
|
-
score = report.pixelMatch.score;
|
|
33
|
-
metric = "pixel";
|
|
34
|
-
}
|
|
36
|
+
let pixel = null;
|
|
37
|
+
if (report.pixelMatch) {
|
|
38
|
+
pixel = report.pixelMatch.contentScore !== undefined
|
|
39
|
+
? { score: report.pixelMatch.contentScore, metric: "pixel-content" }
|
|
40
|
+
: { score: report.pixelMatch.score, metric: "pixel" };
|
|
35
41
|
}
|
|
36
|
-
|
|
42
|
+
// Prefer the primary; let pixel evidence rescue when it is strictly better.
|
|
43
|
+
const best = primary && pixel
|
|
44
|
+
? (pixel.score > primary.score ? pixel : primary)
|
|
45
|
+
: (primary ?? pixel);
|
|
46
|
+
if (!best)
|
|
37
47
|
return { verdict: "no-comparison", score: null, metric: "none" };
|
|
48
|
+
const { score, metric } = best;
|
|
38
49
|
const verdict = score >= VERIFY_PASS_THRESHOLD ? "pass"
|
|
39
50
|
: score >= VERIFY_WARN_THRESHOLD ? "warn"
|
|
40
51
|
: "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,CAAC;AAY1C
|
|
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,CAAC;AAY1C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MACc;IAC/C,IAAI,OAAO,GAAoE,IAAI,CAAC;IAEpF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5D,CAAC;SAAM,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,cAAc,EA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
|
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.76",
|
|
43
|
+
"@calibrate-ds/figma-client": "^0.1.76"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc -p tsconfig.json",
|