@ggui-ai/ui-gen 0.19.0 → 0.20.0
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/adapters/generation-dispatch.js +51 -2
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.js +35 -10
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/types.d.ts +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/advanced/index.js +86 -12
- package/dist/advanced/index.js.map +1 -1
- package/dist/blueprint-validator.js +5 -2
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/evaluation/axis-checks/index.js +46 -0
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.js +46 -0
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.js +46 -0
- package/dist/evaluation/index.js.map +1 -1
- package/dist/harness/check/runtime-render/index.js +5 -2
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/check/runtime-render/render-check-worker.js +5 -2
- package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/types-public.js.map +1 -1
- package/dist/index.js +86 -12
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/adapters/openai/raw.ts +11 -5
- package/src/adapters/openai/sdk.ts +8 -5
- package/src/adapters/openai/tokens.ts +49 -0
- package/src/adapters/types.ts +1 -1
- package/src/evaluation/axis-checks/checks/universal.ts +92 -0
- package/src/harness/check/runtime-render/render-check.ts +15 -0
|
@@ -529,6 +529,46 @@ function runRootWidthCap(input) {
|
|
|
529
529
|
)
|
|
530
530
|
];
|
|
531
531
|
}
|
|
532
|
+
var LABEL_SPECIAL_CHAR = /[^a-z0-9\s]/i;
|
|
533
|
+
var normText = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
|
|
534
|
+
var alnumText = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
535
|
+
function visibleText(sourceCode) {
|
|
536
|
+
const jsx = (sourceCode.match(/>([^<>]*)</g) ?? []).map((m2) => m2.slice(1, -1).replace(/\{[^}]*\}/g, " ")).join(" ");
|
|
537
|
+
let attrs = "";
|
|
538
|
+
const attrRx = /\b(?:aria-label|placeholder|title|alt)\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
539
|
+
let m;
|
|
540
|
+
while ((m = attrRx.exec(sourceCode)) !== null) attrs += " " + (m[1] ?? m[2] ?? "");
|
|
541
|
+
return jsx + " " + attrs;
|
|
542
|
+
}
|
|
543
|
+
function findDroppedActionLabels(sourceCode, contract) {
|
|
544
|
+
const actionSpec = contract?.actionSpec;
|
|
545
|
+
if (actionSpec === void 0) return [];
|
|
546
|
+
if (/\.label\b/.test(sourceCode)) return [];
|
|
547
|
+
const vis = visibleText(sourceCode);
|
|
548
|
+
const normVis = normText(vis);
|
|
549
|
+
const alnumVis = alnumText(vis);
|
|
550
|
+
const out = [];
|
|
551
|
+
for (const [name, entry] of Object.entries(actionSpec)) {
|
|
552
|
+
const label = entry.label;
|
|
553
|
+
if (typeof label !== "string" || label.length === 0 || label === name) continue;
|
|
554
|
+
if (!LABEL_SPECIAL_CHAR.test(label)) continue;
|
|
555
|
+
if (alnumText(label).length < 3) continue;
|
|
556
|
+
if (normVis.includes(normText(label))) continue;
|
|
557
|
+
if (alnumVis.includes(alnumText(label))) out.push({ name, label });
|
|
558
|
+
}
|
|
559
|
+
return out;
|
|
560
|
+
}
|
|
561
|
+
function runActionLabelDropped(input) {
|
|
562
|
+
if (input.compiledCode === null) return [];
|
|
563
|
+
return findDroppedActionLabels(input.sourceCode, input.contract).map(
|
|
564
|
+
({ name, label }) => mkIssue(
|
|
565
|
+
"universal.action_label_dropped",
|
|
566
|
+
`The action "${name}" declares label "${label}", but the rendered control appears to drop its "${label.replace(/[a-z0-9\s]/gi, "").trim()}": the label's words are in the generated source, the full label is not \u2014 a transcription drop (ggui#1190).`,
|
|
567
|
+
`Render the label EXACTLY as the contract states it \u2014 button text should be the verbatim \`actionSpec.${name}.label\`, or render it from data (\`{x.label}\`), never a re-typed copy that drops "&", "/", "+", etc.`,
|
|
568
|
+
"warn"
|
|
569
|
+
)
|
|
570
|
+
);
|
|
571
|
+
}
|
|
532
572
|
var UNIVERSAL_CHECKS = [
|
|
533
573
|
{
|
|
534
574
|
id: "universal.icon_name_known",
|
|
@@ -554,6 +594,12 @@ var UNIVERSAL_CHECKS = [
|
|
|
554
594
|
values: ALL_RENDER_VALUES,
|
|
555
595
|
run: runRootWidthCap
|
|
556
596
|
},
|
|
597
|
+
{
|
|
598
|
+
id: "universal.action_label_dropped",
|
|
599
|
+
axis: "render",
|
|
600
|
+
values: ALL_RENDER_VALUES,
|
|
601
|
+
run: runActionLabelDropped
|
|
602
|
+
},
|
|
557
603
|
{
|
|
558
604
|
id: "universal.terminal_action_unguarded",
|
|
559
605
|
axis: "render",
|