@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
@@ -4,7 +4,7 @@ import { JsonObject, DataContract } from '@ggui-ai/protocol';
4
4
  import { RuntimeRenderCheck } from '../../types-public.js';
5
5
  import '../../../styling-profile-CxfvV48g.js';
6
6
  import '../../../axes-CzLEMDeB.js';
7
- import '../../../types-public-DVSssdc-.js';
7
+ import '../../../types-public-DKR_h70H.js';
8
8
  import '../../../design-mode-DLufhrNp.js';
9
9
  import '../../../types-BOvHNG7K.js';
10
10
  import '../../../llm.js';
@@ -10,7 +10,7 @@ export { computeHarnessId, computeHarnessName, hashClassification } from '../has
10
10
  import '@ggui-ai/protocol';
11
11
  import '../styling-profile-CxfvV48g.js';
12
12
  import '../axes-CzLEMDeB.js';
13
- import '../types-public-DVSssdc-.js';
13
+ import '../types-public-DKR_h70H.js';
14
14
  import '../design-mode-DLufhrNp.js';
15
15
  import '../types-BOvHNG7K.js';
16
16
  import '../llm.js';
@@ -203,6 +203,61 @@ function truncateSourceForTrace(source) {
203
203
  function newValidatorTraceId() {
204
204
  return Date.now().toString(36) + Math.random().toString(36).slice(2, 10);
205
205
  }
206
+
207
+ // src/design-mode.ts
208
+ var DEFAULT_DESIGN_MODE = "constrained";
209
+ function canvasDisplayModeForShell(shell) {
210
+ return shell === "chat" || shell === "inline" ? "inline" : "fullscreen";
211
+ }
212
+ function canvasForRendering(shellType, screen) {
213
+ const shell = shellType ?? "fullscreen";
214
+ if (canvasDisplayModeForShell(shell) === "inline") return "xs-chat-card";
215
+ if (shell === "spatial") return "md";
216
+ switch (screen ?? "universal") {
217
+ case "mobile":
218
+ return "mobile-fullscreen-small";
219
+ case "tablet":
220
+ return "md";
221
+ default:
222
+ return "lg";
223
+ }
224
+ }
225
+ var CANVAS_DESCRIPTORS = {
226
+ "xs-chat-card": {
227
+ label: "extra-small chat card",
228
+ minWidthPx: 320,
229
+ maxWidthPx: 480,
230
+ host: "an inline card inside a chat message bubble \u2014 the host draws the card border, shadow and rounded corners; the component fills the bubble width and takes its natural height"
231
+ },
232
+ "mobile-fullscreen-small": {
233
+ label: "small mobile fullscreen",
234
+ minWidthPx: 320,
235
+ maxWidthPx: 599,
236
+ host: "a phone-sized viewport the component owns edge to edge \u2014 single column, touch targets at least 44px, the component manages its own scroll"
237
+ },
238
+ md: {
239
+ label: "medium panel",
240
+ minWidthPx: 600,
241
+ maxWidthPx: 1023,
242
+ host: "a tablet viewport or a floating panel (spatial / picture-in-picture) \u2014 one or two columns, medium density"
243
+ },
244
+ lg: {
245
+ label: "large fullscreen",
246
+ minWidthPx: 1024,
247
+ maxWidthPx: 1439,
248
+ host: "a desktop viewport the component owns edge to edge \u2014 multi-column layouts, hover states and pointer interactions are available"
249
+ },
250
+ xl: {
251
+ label: "extra-large fullscreen",
252
+ minWidthPx: 1440,
253
+ maxWidthPx: 1920,
254
+ host: "a wide desktop viewport the component owns edge to edge \u2014 cap content width or use the extra room deliberately; never stretch a single column across the whole width"
255
+ }
256
+ };
257
+ function describeCanvas(canvas) {
258
+ const d = CANVAS_DESCRIPTORS[canvas];
259
+ return `This component renders on the \`${canvas}\` canvas (${d.label}): ${d.minWidthPx}\u2013${d.maxWidthPx}px wide, ${d.host}. Design for the whole range \u2014 the host may size the iframe anywhere inside it, and the host owns the height: size to your content, never to the viewport.`;
260
+ }
206
261
  function axisCheckTraceEnabled() {
207
262
  return process.env["GGUI_AXIS_CHECK_TRACE"] === "1";
208
263
  }
@@ -468,7 +523,9 @@ function traceFacts(input) {
468
523
  designMode: input.designMode ?? "constrained",
469
524
  classification: input.classification.vector,
470
525
  propsSpecKeys: Object.keys(propsSpec ?? {}),
471
- propsSpecPropertyKeys: Object.keys(propsSpec?.properties ?? {})
526
+ propsSpecPropertyKeys: Object.keys(propsSpec?.properties ?? {}),
527
+ // No default here, unlike designMode: an absent canvas is a fact about the caller, not a guess to paper over.
528
+ ...input.canvas !== void 0 ? { canvas: input.canvas } : {}
472
529
  };
473
530
  }
474
531
 
@@ -523,7 +580,9 @@ async function runCheck(input) {
523
580
  contract,
524
581
  originalPrompt: prompt,
525
582
  classification: harness.classification,
526
- designMode: harness.designMode
583
+ designMode: harness.designMode,
584
+ // ggui#1117: the canvas the harness was built for, when it has one — never a default.
585
+ ...harness.canvas !== void 0 ? { canvas: harness.canvas } : {}
527
586
  };
528
587
  const axisRun = runGatedAxisChecks(check.axisChecks, axisInput);
529
588
  issues.push(...axisRun.issues);
@@ -1153,63 +1212,6 @@ function compose(classification) {
1153
1212
  fragments: matched
1154
1213
  };
1155
1214
  }
1156
-
1157
- // src/design-mode.ts
1158
- var DEFAULT_DESIGN_MODE = "constrained";
1159
- function canvasDisplayModeForShell(shell) {
1160
- return shell === "chat" || shell === "inline" ? "inline" : "fullscreen";
1161
- }
1162
- function canvasForRendering(shellType, screen) {
1163
- const shell = shellType ?? "fullscreen";
1164
- if (canvasDisplayModeForShell(shell) === "inline") return "xs-chat-card";
1165
- if (shell === "spatial") return "md";
1166
- switch (screen ?? "universal") {
1167
- case "mobile":
1168
- return "mobile-fullscreen-small";
1169
- case "tablet":
1170
- return "md";
1171
- default:
1172
- return "lg";
1173
- }
1174
- }
1175
- var CANVAS_DESCRIPTORS = {
1176
- "xs-chat-card": {
1177
- label: "extra-small chat card",
1178
- minWidthPx: 320,
1179
- maxWidthPx: 480,
1180
- host: "an inline card inside a chat message bubble \u2014 the host draws the card border, shadow and rounded corners; the component fills the bubble width and takes its natural height"
1181
- },
1182
- "mobile-fullscreen-small": {
1183
- label: "small mobile fullscreen",
1184
- minWidthPx: 320,
1185
- maxWidthPx: 599,
1186
- host: "a phone-sized viewport the component owns edge to edge \u2014 single column, touch targets at least 44px, the component manages its own scroll"
1187
- },
1188
- md: {
1189
- label: "medium panel",
1190
- minWidthPx: 600,
1191
- maxWidthPx: 1023,
1192
- host: "a tablet viewport or a floating panel (spatial / picture-in-picture) \u2014 one or two columns, medium density"
1193
- },
1194
- lg: {
1195
- label: "large fullscreen",
1196
- minWidthPx: 1024,
1197
- maxWidthPx: 1439,
1198
- host: "a desktop viewport the component owns edge to edge \u2014 multi-column layouts, hover states and pointer interactions are available"
1199
- },
1200
- xl: {
1201
- label: "extra-large fullscreen",
1202
- minWidthPx: 1440,
1203
- maxWidthPx: 1920,
1204
- host: "a wide desktop viewport the component owns edge to edge \u2014 cap content width or use the extra room deliberately; never stretch a single column across the whole width"
1205
- }
1206
- };
1207
- function describeCanvas(canvas) {
1208
- const d = CANVAS_DESCRIPTORS[canvas];
1209
- return `This component renders on the \`${canvas}\` canvas (${d.label}): ${d.minWidthPx}\u2013${d.maxWidthPx}px wide, ${d.host}. Design for the whole range \u2014 the host may size the iframe anywhere inside it, and the host owns the height: size to your content, never to the viewport.`;
1210
- }
1211
-
1212
- // src/boilerplate/render.ts
1213
1215
  var __dirname$1 = dirname(fileURLToPath(import.meta.url));
1214
1216
  var TEMPLATE_DIRS = [
1215
1217
  resolve(__dirname$1, "templates"),
@@ -1481,7 +1483,8 @@ type ${typeName} = ${tsType};`
1481
1483
  );
1482
1484
  const callSig = tsType === "void" ? "() => void \u2014 fire and forget" : `(data: ${tsType}) => void`;
1483
1485
  const toolHint = tool ? ` \u2192 nextStep: ${tool}` : "";
1484
- actionHookCalls.push(` const ${key} = useAction<${typeName}>('${key}'); // ${callSig}${toolHint}`);
1486
+ const onceHint = " \u2014 if this is meant ONCE, disable its control after it fires";
1487
+ actionHookCalls.push(` const ${key} = useAction<${typeName}>('${key}'); // ${callSig}${toolHint}${onceHint}`);
1485
1488
  }
1486
1489
  const streamChannels = contract?.streamSpec ?? {};
1487
1490
  const streamChannelEntries = Object.entries(streamChannels);
@@ -1814,14 +1817,35 @@ Rules:
1814
1817
  1. All request-specific data \u2192 props with defaults. City names, tickers, user names, dates, counts.
1815
1818
  2. Layout and styling are universal. Colors, spacing, structure \u2014 these are the reusable part.
1816
1819
  3. Default values come from the current request \u2014 so the component renders correctly standalone.
1817
- 4. Copy comes from the props. NEVER invent display text the contract does not carry \u2014 no eyebrow / kicker / overline (a \`<Text caps>\` label), no helper line, no status text, no tagline. A caps label exists only when a prop supplies its text (\`<Text caps>{props.section}</Text>\`); a heading's fallback is the request's own words, never a slogan of your own. Text the agent cannot change is chatter on every render.
1820
+ 4. Copy comes from the props. NEVER invent display text the contract does not carry \u2014 no eyebrow / kicker / overline (a \`<Text caps>\` label), no helper line, no status text, no tagline. **Do NOT add a caps label above the heading** \u2014 not \`<Text caps>LET'S BEGIN</Text>\`, not \`WELCOME\`, not a section kicker like \`GETTING STARTED\` or \`OVERVIEW\` \u2014 UNLESS a prop supplies that exact text (\`<Text caps>{props.section}</Text>\`). When the request asks for a heading and a line, render the heading and the line and NOTHING above the heading. A heading's fallback is the request's own words, never a slogan of your own. Text the agent cannot change is chatter on every render, and a caps eyebrow you wrote is the most common form of it.
1818
1821
  5. Props interface must be typed and exported.`;
1819
- var FRAME_SIZING = `## Sizing \u2014 the frame owns the height
1822
+ var TERMINAL_ACTIONS = `## Actions the user means once
1823
+
1824
+ A second press is a mistake only when it would make a SECOND THING HAPPEN IN THE WORLD \u2014 a second booking, a second charge, a second order, a second application sent. If pressing again would only write the SAME STATE AGAIN \u2014 saving, updating, renaming, setting a preference, toggling \u2014 nothing is duplicated and the control stays armed.
1825
+
1826
+ Guard a control only where you have evidence, not a feeling about the verb: the request itself names a one-time commitment \u2014 "submit the application", "place the order", "confirm the booking".
1827
+
1828
+ **When in doubt, leave it armed.** A control the user cannot press a second time has lost them something that worked \u2014 save, edit, save again is ordinary. A control left armed is only what every interface does by default.
1829
+
1830
+ When you do guard one:
1831
+ - Hold a small piece of state for it and set it in the handler: \`const [submitted, setSubmitted] = useState(false)\`.
1832
+ - \`disabled={submitted}\` on the control that fires it, and say so in the label or beside it ("Submitted", "Request sent") \u2014 a control that is disabled without explanation reads as broken.
1833
+ - A card re-rendered with new props starts fresh; the state above lives with the component, not with the request.
1834
+
1835
+ Nothing in the wire DECLARES one-shot-ness yet, which is why the test is what a second press would DO \u2014 not how final the word sounds.`;
1836
+ var FRAME_SIZING = `## Sizing \u2014 the frame owns the height and the width
1820
1837
 
1821
1838
  The host sizes the iframe; the component never sizes itself to the viewport. NEVER write \`100vh\` / \`100dvh\` / \`100svh\` (or an \`h-screen\` / \`min-h-screen\` class) as a height on any element:
1822
1839
  - An inline card takes its natural height. A content-sized frame is measured FROM the content, so a \`100vh\` root can never shrink and grows the frame on every re-measure.
1823
1840
  - Under fullscreen the frame already stretches your root to its full height. Centre inside it with flex (\`display: flex; flex-direction: column; justify-content: center\`), never with a viewport height.
1824
- - To fill a parent that has a height use \`height: 100%\` or \`flex: 1\`; a viewport unit is only ever a \`max-height\` cap on a scroll region.`;
1841
+ - To fill a parent that has a height use \`height: 100%\` or \`flex: 1\`; a viewport unit is only ever a \`max-height\` cap on a scroll region.
1842
+
1843
+ The width works the same way, and the mistake is the mirror image: **your outermost element FILLS the frame; a width cap belongs INSIDE it, on the column that holds text.**
1844
+
1845
+ - Never put \`maxWidth\` (or a \`max-w-*\` class) on the element you return at the top. On a wide canvas that turns your card into a narrow strip with the frame's ground on either side of it, and on a narrow one it does nothing \u2014 the same composition reading differently at two sizes.
1846
+ - DO cap the reading measure inside: a column of prose is easiest to read at 60\u201370 characters, so wrap the TEXT in a \`<Container maxWidth="sm">\` (or your own \`max-width\`) and leave the root filling. A hero band, a toolbar, a table or an image then still uses the whole width, which is what makes a wide card look composed rather than padded.
1847
+ - Centre that inner column with the container's own centring, not by shrinking the root.
1848
+ - **They are two different elements.** Even when the whole card is one column of text, the root still fills and the column sits INSIDE it \u2014 \`<Box padding="lg"><Container maxWidth="sm">\u2026</Container></Box>\`, never a root that is itself the container. A centred card is centring inside a filled frame, not a shrunken frame.`;
1825
1849
  var COMPONENT_STRUCTURE = `## Component Structure
1826
1850
 
1827
1851
  Keep JSX nesting depth to 3\u20135 levels. When deeper, extract repeated/complex sections into helper components \u2014 named functions defined above the main Component in the same file. Helpers take data + callbacks via props; they don't own state.
@@ -2033,6 +2057,7 @@ ${axisSection}
2033
2057
  CONTRACT_SURFACE,
2034
2058
  DEFENSIVE_CODING,
2035
2059
  GESTURE_ROUTING,
2060
+ TERMINAL_ACTIONS,
2036
2061
  FREE_GESTURE_SURFACE,
2037
2062
  ANTI_PATTERNS,
2038
2063
  CROSS_REFERENCE_RULES,
@@ -2431,6 +2456,7 @@ ${axisSection}
2431
2456
  CONTRACT_SURFACE,
2432
2457
  DEFENSIVE_CODING,
2433
2458
  GESTURE_ROUTING,
2459
+ TERMINAL_ACTIONS,
2434
2460
  INTERACTIVE_TRAITS,
2435
2461
  ANTI_PATTERNS,
2436
2462
  CROSS_REFERENCE_RULES,
@@ -2638,7 +2664,7 @@ Don't render text-only metrics. A weather widget without a sun/cloud, a stock ca
2638
2664
  </Row>
2639
2665
  \`\`\`
2640
2666
 
2641
- Use \`<Icon name="..." />\` for line icons \u2014 ONLY the curated Lucide subset renders (call \`get_available_icons\` for the exact kebab-case names; a name outside it renders an empty box and fails the check); emoji directly for status/weather/mood. Both are valid. For per-stat tiny accents, use a small icon next to the label.
2667
+ Use \`<Icon name="..." />\` for line icons \u2014 ONLY the design system's curated set renders (~200 kebab-case Lucide names); a name OUTSIDE it renders an empty box and fails the check. On a single-pass render you cannot look the set up, so use ONLY a name you are sure is in it. Safe common names: \`check\` \`x\` \`plus\` \`minus\` \`search\` \`settings\` \`user\` \`users\` \`calendar\` \`clock\` \`arrow-right\` \`arrow-left\` \`chevron-right\` \`chevron-down\` \`trash-2\` \`edit\` \`info\` \`alert-circle\` \`bell\` \`home\` \`file\` \`file-text\` \`star\` \`heart\` \`mail\` \`send\` \`download\` \`upload\` \`external-link\` \`filter\` \`check-circle\`. The numbered variants (\`edit-2\`, \`edit-3\`) and synonyms (\`pencil\`, \`pen\`, \`trash\`, \`x-circle\`) are NOT in the set \u2014 use \`edit\` and \`trash-2\`. If the icon you want is not clearly one of these, OMIT it: a card with no icon beats one with an empty box. Emoji render directly for status/weather/mood. For per-stat tiny accents, use a small icon next to the label.
2642
2668
 
2643
2669
  ### Spacing \u2014 generosity beats compactness
2644
2670
 
@@ -3145,6 +3171,7 @@ function createHarness(input) {
3145
3171
  name,
3146
3172
  classification,
3147
3173
  designMode,
3174
+ ...input.canvas !== void 0 ? { canvas: input.canvas } : {},
3148
3175
  ...input.profile !== void 0 ? { profile: input.profile } : {},
3149
3176
  how,
3150
3177
  what,