@ggui-ai/ui-gen 0.17.0 → 0.19.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.
Files changed (69) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +1 -1
  2. package/dist/adapters/generation-dispatch.js +449 -194
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/adapters/index.js +4 -6
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/advanced/index.d.ts +2 -2
  7. package/dist/advanced/index.js +391 -134
  8. package/dist/advanced/index.js.map +1 -1
  9. package/dist/boilerplate.js +29 -5
  10. package/dist/boilerplate.js.map +1 -1
  11. package/dist/check/index.d.ts +1 -1
  12. package/dist/check/index.js +70 -0
  13. package/dist/check/index.js.map +1 -1
  14. package/dist/{create-ui-generator-C8Ki9Wz1.d.ts → create-ui-generator-CxPvudbs.d.ts} +1 -1
  15. package/dist/{dispatch-D2htzi9h.d.ts → dispatch-N8wdNOX-.d.ts} +4 -2
  16. package/dist/evaluation/axis-checks/index.d.ts +3 -3
  17. package/dist/evaluation/axis-checks/index.js +147 -3
  18. package/dist/evaluation/axis-checks/index.js.map +1 -1
  19. package/dist/evaluation/axis-checks/registry.d.ts +1 -1
  20. package/dist/evaluation/axis-checks/registry.js +142 -1
  21. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  22. package/dist/evaluation/index.d.ts +3 -3
  23. package/dist/evaluation/index.js +217 -84
  24. package/dist/evaluation/index.js.map +1 -1
  25. package/dist/harness/check/runtime-render/index.d.ts +1 -1
  26. package/dist/harness/index.d.ts +1 -1
  27. package/dist/harness/index.js +91 -64
  28. package/dist/harness/index.js.map +1 -1
  29. package/dist/harness/prompts.js +4 -0
  30. package/dist/harness/prompts.js.map +1 -1
  31. package/dist/harness/result-types.d.ts +1 -1
  32. package/dist/harness/runtime.d.ts +1 -1
  33. package/dist/harness/runtime.js +31 -7
  34. package/dist/harness/runtime.js.map +1 -1
  35. package/dist/harness/types-public.d.ts +8 -1
  36. package/dist/harness/types-public.js +91 -64
  37. package/dist/harness/types-public.js.map +1 -1
  38. package/dist/harness/validator-trace-sink.d.ts +1 -1
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.js +391 -134
  41. package/dist/index.js.map +1 -1
  42. package/dist/patch.d.ts +1 -1
  43. package/dist/{types-public-DVSssdc-.d.ts → types-public-DKR_h70H.d.ts} +9 -0
  44. package/dist/validation/index.d.ts +1 -1
  45. package/dist/validation/index.js +1 -1
  46. package/dist/validation/index.js.map +1 -1
  47. package/dist/workflows.d.ts +1 -1
  48. package/package.json +12 -12
  49. package/src/adapters/google/sdk.ts +11 -7
  50. package/src/boilerplate/free-design-prompt.ts +2 -0
  51. package/src/boilerplate/generate.ts +8 -1
  52. package/src/boilerplate/hard-sections.ts +32 -3
  53. package/src/boilerplate/system-prompt.ts +3 -1
  54. package/src/boilerplate/templates/layouts/fullscreen-desktop.tsx.tmpl +5 -3
  55. package/src/boilerplate/templates/layouts/fullscreen-mobile.tsx.tmpl +3 -3
  56. package/src/boilerplate/templates/layouts/fullscreen-universal.tsx.tmpl +5 -3
  57. package/src/check/run-tier0.ts +152 -0
  58. package/src/coding-agent/tools.ts +58 -6
  59. package/src/contract-context.ts +13 -0
  60. package/src/create-harness.ts +1 -0
  61. package/src/evaluation/axis-checks/checks/universal.ts +179 -1
  62. package/src/evaluation/axis-checks/dispatch.ts +8 -1
  63. package/src/evaluation/types-public.ts +9 -0
  64. package/src/harness/coding/generate-task-runner.ts +1 -0
  65. package/src/harness/coding/run-coding-turn.ts +14 -0
  66. package/src/harness/types-public.ts +7 -0
  67. package/src/run-check.ts +2 -0
  68. package/src/tools/get-wire.ts +1 -1
  69. package/src/validation/primitives.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { A as AxisCheck } from '../../types-public-DVSssdc-.js';
1
+ import { A as AxisCheck } from '../../types-public-DKR_h70H.js';
2
2
  import '../../design-mode-DLufhrNp.js';
3
3
  import '@ggui-ai/protocol';
4
4
  import '../../axes-CzLEMDeB.js';
@@ -1,7 +1,16 @@
1
- import { LUCIDE_ICON_NAMES } from '@ggui-ai/design';
1
+ import { LUCIDE_ICON_NAMES, maxWidth } from '@ggui-ai/design';
2
2
  import { listContractGadgets, HOOK_NAME_RE, STDLIB_GADGETS_PACKAGE } from '@ggui-ai/protocol';
3
3
 
4
4
  // src/evaluation/axis-checks/checks/universal.ts
5
+
6
+ // src/design-mode.ts
7
+ var CANVAS_VIEWPORTS = {
8
+ "xs-chat-card": { width: 400, height: 640 },
9
+ "mobile-fullscreen-small": { width: 390, height: 844 },
10
+ md: { width: 768, height: 1024 },
11
+ lg: { width: 1024, height: 768 },
12
+ xl: { width: 1440, height: 900 }
13
+ };
5
14
  var ID_FIELD_CANDIDATES = ["id", "uuid", "symbol", "key", "slug", "code"];
6
15
  function getItemsProperties(p) {
7
16
  return p.items?.properties ?? p.schema?.items?.properties;
@@ -399,6 +408,126 @@ function runViewportSized(input) {
399
408
  )
400
409
  ];
401
410
  }
411
+ var TERMINAL_WORDS = /* @__PURE__ */ new Set([
412
+ "submit",
413
+ "confirm",
414
+ "approve",
415
+ "schedule",
416
+ "reserve",
417
+ "book",
418
+ "pay",
419
+ "checkout",
420
+ "purchase",
421
+ "order"
422
+ ]);
423
+ var TERMINAL_LABEL_RX = /\b(submit|confirm|approve|schedule|reserve|book|pay|checkout|purchase|place\s+order)\b/i;
424
+ var GUARD_RX = /\b(disabled|aria-disabled)\s*=/;
425
+ function nameWords(name) {
426
+ return name.split(/(?=[A-Z])|[_\-\s]+/).map((w) => w.toLowerCase()).filter((w) => w.length > 0);
427
+ }
428
+ function findUnguardedTerminalControls(sourceCode) {
429
+ if (GUARD_RX.test(sourceCode)) return [];
430
+ const names = /* @__PURE__ */ new Set();
431
+ for (const m of sourceCode.matchAll(/useAction(?:<[^>]*>)?\(\s*['"`]([^'"`]+)['"`]/g)) {
432
+ const name = m[1] ?? "";
433
+ if (nameWords(name).some((w) => TERMINAL_WORDS.has(w))) names.add(name);
434
+ }
435
+ for (const m of sourceCode.matchAll(/>([^<>{}]{1,60})<\/Button>/g)) {
436
+ const label = (m[1] ?? "").replace(/\s+/g, " ").trim();
437
+ if (label.length > 0 && TERMINAL_LABEL_RX.test(label)) names.add(label.slice(0, 40));
438
+ }
439
+ return [...names];
440
+ }
441
+ function runTerminalActionUnguarded(input) {
442
+ if (input.compiledCode === null) return [];
443
+ const found = findUnguardedTerminalControls(input.sourceCode);
444
+ if (found.length === 0) return [];
445
+ const list = found.map((t) => `"${t}"`).join(", ");
446
+ return [
447
+ mkIssue(
448
+ "universal.terminal_action_unguarded",
449
+ `${list} reads as an action the user means once, and nothing in this component disables the control after it fires \u2014 a double-click sends it twice.`,
450
+ 'Hold the fired state (`const [submitted, setSubmitted] = useState(false)`), set it in the handler, and pass `disabled={submitted}` to that control with a word that says so ("Submitted"). If the action IS meant to repeat \u2014 sending a message, adding an item \u2014 leave it armed and ignore this.',
451
+ "warn"
452
+ )
453
+ ];
454
+ }
455
+ function rootOpeningTag(sourceCode) {
456
+ const start = sourceCode.indexOf("export default function");
457
+ const body = start >= 0 ? sourceCode.slice(start) : sourceCode;
458
+ const ret = /\breturn\s*\(?\s*</.exec(body);
459
+ if (ret === null) return null;
460
+ const at = ret.index + ret[0].length - 1;
461
+ const nameMatch = /^<([A-Za-z][\w.]*)/.exec(body.slice(at));
462
+ if (nameMatch === null) return null;
463
+ let j = at + nameMatch[0].length;
464
+ let depth = 0;
465
+ let quote = null;
466
+ for (; j < body.length; j++) {
467
+ const ch = body[j];
468
+ if (quote !== null) {
469
+ if (ch === quote) quote = null;
470
+ continue;
471
+ }
472
+ if (ch === '"' || ch === "'" || ch === "`") quote = ch;
473
+ else if (ch === "{") depth++;
474
+ else if (ch === "}") depth--;
475
+ else if (ch === ">" && depth === 0) break;
476
+ }
477
+ return { name: nameMatch[1], attrs: body.slice(at + nameMatch[0].length, j) };
478
+ }
479
+ var CONTAINER_PRESETS = maxWidth;
480
+ var NOT_A_CAP = /* @__PURE__ */ new Set(["full", "none", "100%", "unset", "initial", "inherit"]);
481
+ function capPx(value) {
482
+ const v = value.trim();
483
+ if (NOT_A_CAP.has(v)) return void 0;
484
+ const resolved = CONTAINER_PRESETS[v] ?? v;
485
+ if (NOT_A_CAP.has(resolved)) return void 0;
486
+ const px = /^(\d+(?:\.\d+)?)px$/.exec(resolved);
487
+ return px === null ? null : Number(px[1]);
488
+ }
489
+ function findRootWidthCap(sourceCode) {
490
+ const root = rootOpeningTag(sourceCode);
491
+ if (root === null) return null;
492
+ const { name, attrs } = root;
493
+ const prop = /\bmaxWidth\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*(?:"([^"]*)"|'([^']*)'|(\d+(?:\.\d+)?))\s*\})/.exec(attrs);
494
+ if (prop !== null) {
495
+ const raw = prop[1] ?? prop[2] ?? prop[3] ?? prop[4] ?? `${prop[5]}px`;
496
+ const px = capPx(raw);
497
+ return px === void 0 ? null : { element: name, cap: `maxWidth="${raw}"`, px };
498
+ }
499
+ const style = /\bmaxWidth\s*:\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|(\d+(?:\.\d+)?))/.exec(attrs);
500
+ if (style !== null) {
501
+ const raw = style[1] ?? style[2] ?? style[3] ?? `${style[4]}px`;
502
+ const px = capPx(raw);
503
+ return px === void 0 ? null : { element: name, cap: `maxWidth: '${raw}'`, px };
504
+ }
505
+ const cls = /(?<![\w-])max-w-([\w[\]%.-]+)/.exec(attrs);
506
+ if (cls !== null) {
507
+ if (cls[1] === "full" || cls[1] === "none") return null;
508
+ return { element: name, cap: `max-w-${cls[1]}`, px: null };
509
+ }
510
+ if (name === "Container") return { element: name, cap: "lg (Container default)", px: capPx("lg") ?? null };
511
+ return null;
512
+ }
513
+ var WIDE_CANVASES = /* @__PURE__ */ new Set(["md", "lg", "xl"]);
514
+ function runRootWidthCap(input) {
515
+ if (input.compiledCode === null) return [];
516
+ if (input.canvas === void 0 || !WIDE_CANVASES.has(input.canvas)) return [];
517
+ const cap2 = findRootWidthCap(input.sourceCode);
518
+ if (cap2 === null) return [];
519
+ const width = CANVAS_VIEWPORTS[input.canvas].width;
520
+ if (cap2.px !== null && cap2.px >= width) return [];
521
+ const sized = cap2.px !== null ? `${cap2.px}px on a ${width}px canvas` : `on a ${width}px canvas`;
522
+ return [
523
+ mkIssue(
524
+ "universal.root_width_cap",
525
+ `The outermost element <${cap2.element}> carries a width cap (${cap2.cap}, ${sized}): on this canvas the card becomes a narrow strip with the frame's ground on either side. The frame owns the width; a cap belongs INSIDE the root, on the column that holds text.`,
526
+ 'Let the root fill the frame \u2014 drop the cap on the element you return at the top (or `maxWidth="full"`) \u2014 and put the reading measure on an inner column: `<Box padding="lg"><Container maxWidth="sm">\u2026</Container></Box>`.',
527
+ "warn"
528
+ )
529
+ ];
530
+ }
402
531
  var UNIVERSAL_CHECKS = [
403
532
  {
404
533
  id: "universal.icon_name_known",
@@ -418,6 +547,18 @@ var UNIVERSAL_CHECKS = [
418
547
  values: ALL_RENDER_VALUES,
419
548
  run: runViewportSized
420
549
  },
550
+ {
551
+ id: "universal.root_width_cap",
552
+ axis: "render",
553
+ values: ALL_RENDER_VALUES,
554
+ run: runRootWidthCap
555
+ },
556
+ {
557
+ id: "universal.terminal_action_unguarded",
558
+ axis: "render",
559
+ values: ALL_RENDER_VALUES,
560
+ run: runTerminalActionUnguarded
561
+ },
421
562
  {
422
563
  id: "universal.accent_text_ink",
423
564
  axis: "render",