@ggui-ai/ui-gen 0.15.0 → 0.16.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 (101) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +21 -4
  2. package/dist/adapters/generation-dispatch.js +913 -350
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/adapters/index.js +26 -22
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/advanced/index.d.ts +17 -12
  7. package/dist/advanced/index.js +966 -374
  8. package/dist/advanced/index.js.map +1 -1
  9. package/dist/boilerplate.d.ts +16 -1
  10. package/dist/boilerplate.js +579 -245
  11. package/dist/boilerplate.js.map +1 -1
  12. package/dist/check/index.d.ts +17 -3
  13. package/dist/check/index.js +32 -25
  14. package/dist/check/index.js.map +1 -1
  15. package/dist/{create-ui-generator-D6TKuv9V.d.ts → create-ui-generator-CCIeQaEe.d.ts} +77 -10
  16. package/dist/design-mode-BHEE7flj.d.ts +67 -0
  17. package/dist/{dispatch-BuZfTh9r.d.ts → dispatch-BA5dJcg-.d.ts} +4 -1
  18. package/dist/evaluation/axis-checks/index.d.ts +4 -3
  19. package/dist/evaluation/axis-checks/index.js +3 -1
  20. package/dist/evaluation/axis-checks/index.js.map +1 -1
  21. package/dist/evaluation/axis-checks/registry.d.ts +2 -1
  22. package/dist/evaluation/axis-checks/registry.js +1 -0
  23. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  24. package/dist/evaluation/index.d.ts +143 -3
  25. package/dist/evaluation/index.js +3866 -92
  26. package/dist/evaluation/index.js.map +1 -1
  27. package/dist/{generate-BTfvELgl.d.ts → generate-8L_bc2iP.d.ts} +10 -1
  28. package/dist/harness/check/runtime-render/index.d.ts +2 -1
  29. package/dist/harness/index.d.ts +2 -1
  30. package/dist/harness/index.js +589 -248
  31. package/dist/harness/index.js.map +1 -1
  32. package/dist/harness/llm-trace-sink.d.ts +3 -3
  33. package/dist/harness/llm-trace-sink.js.map +1 -1
  34. package/dist/harness/prompts.d.ts +2 -1
  35. package/dist/harness/prompts.js +3 -0
  36. package/dist/harness/prompts.js.map +1 -1
  37. package/dist/harness/result-types.d.ts +17 -5
  38. package/dist/harness/result-types.js.map +1 -1
  39. package/dist/harness/runtime.d.ts +19 -3
  40. package/dist/harness/runtime.js +602 -261
  41. package/dist/harness/runtime.js.map +1 -1
  42. package/dist/harness/types-public.d.ts +28 -1
  43. package/dist/harness/types-public.js +589 -248
  44. package/dist/harness/types-public.js.map +1 -1
  45. package/dist/harness/validator-trace-sink.d.ts +2 -1
  46. package/dist/index.d.ts +8 -4
  47. package/dist/index.js +973 -372
  48. package/dist/index.js.map +1 -1
  49. package/dist/patch.d.ts +2 -1
  50. package/dist/{prompts-BVhtH3M1.d.ts → prompts-k6m6reqe.d.ts} +11 -1
  51. package/dist/providers/index.d.ts +2 -2
  52. package/dist/providers/index.js.map +1 -1
  53. package/dist/tools/get-primitives-ts.d.ts +1 -1
  54. package/dist/tools/get-primitives-ts.js +1 -1
  55. package/dist/tools/get-primitives-ts.js.map +1 -1
  56. package/dist/{types-public-CkNWEov9.d.ts → types-public-D24JLJgl.d.ts} +49 -5
  57. package/dist/validation/index.d.ts +1 -1
  58. package/dist/validation/index.js +4 -4
  59. package/dist/validation/index.js.map +1 -1
  60. package/dist/workflows.d.ts +2 -1
  61. package/package.json +12 -12
  62. package/src/adapters/generation-dispatch.ts +57 -4
  63. package/src/adapters/provider-router.ts +7 -6
  64. package/src/adapters/tools.ts +5 -5
  65. package/src/advanced/generator.ts +11 -10
  66. package/src/advanced/index.ts +5 -4
  67. package/src/boilerplate/free-design-prompt.ts +329 -0
  68. package/src/boilerplate/generate.ts +10 -1
  69. package/src/boilerplate/hard-sections.ts +242 -0
  70. package/src/boilerplate/render.ts +32 -8
  71. package/src/boilerplate/system-prompt.ts +81 -229
  72. package/src/boilerplate/templates/base-free.tsx.tmpl +24 -0
  73. package/src/check/run-tier0.ts +80 -20
  74. package/src/coding-agent/tools.ts +8 -2
  75. package/src/contract-context.ts +28 -0
  76. package/src/create-harness.ts +11 -0
  77. package/src/create-ui-generator.ts +71 -25
  78. package/src/design-mode.ts +182 -0
  79. package/src/design-system-docs.ts +17 -13
  80. package/src/evaluation/axis-checks/dispatch.ts +4 -0
  81. package/src/evaluation/axis-checks/extras.ts +5 -0
  82. package/src/evaluation/cost-tracker.ts +2 -3
  83. package/src/evaluation/index.ts +46 -2
  84. package/src/evaluation/llm-evaluator.ts +77 -21
  85. package/src/evaluation/types-public.ts +103 -8
  86. package/src/evaluation/visual-evaluator.ts +301 -29
  87. package/src/harness/coding/dupe-break.ts +0 -0
  88. package/src/harness/coding/init-session.ts +1 -0
  89. package/src/harness/coding/run-coding-turn.ts +3 -0
  90. package/src/harness/coding/run-eval-round.ts +15 -2
  91. package/src/harness/llm-trace-sink.ts +3 -3
  92. package/src/harness/result-types.ts +15 -3
  93. package/src/harness/runtime.ts +18 -0
  94. package/src/harness/types-public.ts +27 -0
  95. package/src/index.ts +26 -0
  96. package/src/internal/extract-call-signatures.ts +2 -2
  97. package/src/providers/bedrock.ts +4 -4
  98. package/src/run-check.ts +1 -0
  99. package/src/tools/get-primitives-ts.ts +1 -1
  100. package/src/validation/allowed-imports.ts +8 -2
  101. package/src/validation/primitives.ts +1 -1
@@ -1,10 +1,14 @@
1
- export { A as AxisCheck, a as AxisCheckInput, C as CRITERIA, d as CriterionCoverage, e as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, f as EvalCategory, g as EvalCriterion, E as EvalIssue, h as EvalOutcome, b as EvalResult, c as EvalTier, L as LLM_EVAL_STATIC_CRITERIA, P as Priority, Q as QualityConfig, i as QualityMode, j as buildCodingCriteriaSummary, k as getActionableIssues, l as getCriteriaByPriority, n as getCriterionById, o as getLLMCriteria, p as isBlocked, m as matches, q as notApplicableCoverage, r as priorityForIssue } from '../types-public-CkNWEov9.js';
1
+ import { E as EvalIssue, V as VisualEvalSummary } from '../types-public-D24JLJgl.js';
2
+ export { A as AxisCheck, a as AxisCheckInput, C as CRITERIA, d as CanvasVisualSummary, e as CriterionCoverage, f as CriterionRunStatus, D as DEFAULT_QUALITY_CONFIG, g as EvalCategory, h as EvalCriterion, i as EvalOutcome, b as EvalResult, c as EvalTier, L as LLM_EVAL_STATIC_CRITERIA, P as Priority, Q as QualityConfig, j as QualityMode, k as buildCodingCriteriaSummary, l as criteriaFor, n as getActionableIssues, o as getCriteriaByPriority, p as getCriterionById, q as getLLMCriteria, r as isBlocked, m as matches, s as notApplicableCoverage, t as priorityForIssue } from '../types-public-D24JLJgl.js';
2
3
  import * as _anthropic_ai_claude_agent_sdk from '@anthropic-ai/claude-agent-sdk';
3
4
  import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
4
5
  import { EvaluationContext, EvaluationConfig, QualityMetadata, EvaluationResult, EvaluationIssue } from './types.js';
5
6
  export { DEFAULT_EVAL_MAX_ROUNDS, DimensionScores, MAX_EVAL_ROUNDS_HARD_LIMIT } from './types.js';
6
- export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-BuZfTh9r.js';
7
+ export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-BA5dJcg-.js';
8
+ import { C as CanvasClass, g as CanvasViewport } from '../design-mode-BHEE7flj.js';
9
+ export { a as CANVAS_BREAKPOINTS, b as CANVAS_CLASSES, c as CANVAS_DESCRIPTORS, d as CANVAS_VIEWPORTS, e as CanvasDescriptor, f as CanvasDisplayMode, j as canvasDisplayModeForShell, k as canvasForRendering, l as canvasForViewportWidth, m as describeCanvas } from '../design-mode-BHEE7flj.js';
7
10
  import { A as AgentConfig, L as LLMResponse } from '../llm-router-D7fjBhtr.js';
11
+ import { LaunchOptions } from 'puppeteer-core';
8
12
  import '@ggui-ai/protocol';
9
13
  import '../axes-CzLEMDeB.js';
10
14
  import '../types-BOvHNG7K.js';
@@ -194,6 +198,18 @@ interface VisualEvalConfig {
194
198
  width: number;
195
199
  height: number;
196
200
  };
201
+ /**
202
+ * Per-canvas judging — ARM-NEUTRAL (the same judge, prompt and
203
+ * threshold in every design mode). When set, the SAME rendered HTML
204
+ * shell is screenshotted once per class at `CANVAS_VIEWPORTS[class]`
205
+ * and judged once per class; the result carries one entry per class
206
+ * in `canvases`, and the single-shot fields aggregate: `finalScore` =
207
+ * mean of the canvas scores (rounded), `passed` = every canvas passed,
208
+ * `dimensions` = per-dimension means, `issues` = every canvas's issues
209
+ * (description prefixed `[<canvas>]`). Unset (or empty) = today's
210
+ * single screenshot at `viewport`; no `canvases` field on the result.
211
+ */
212
+ canvases?: readonly CanvasClass[];
197
213
  /**
198
214
  * Optional provider-routing override — see
199
215
  * `AgentConfig.routeOverride`. Threaded onto the agent this
@@ -209,6 +225,101 @@ interface VisualEvalConfig {
209
225
  */
210
226
  onRetry?: AgentConfig['onRetry'];
211
227
  }
228
+ /** One canvas's verdict — screenshot + judge score at that class's viewport. */
229
+ interface CanvasVisualResult {
230
+ canvas: CanvasClass;
231
+ viewport: CanvasViewport;
232
+ /** The judge's weighted score for this canvas (0-100). */
233
+ score: number;
234
+ /** `score >= passThreshold`. */
235
+ passed: boolean;
236
+ /** The PNG the judge saw — kept for artefact persistence + the human look. */
237
+ screenshotPng: Buffer;
238
+ }
239
+ /**
240
+ * `runVisualEvaluation`'s result. Identical to `EvaluationResult` when
241
+ * `config.canvases` is unset; with canvases set, `canvases` holds the
242
+ * per-class verdicts and the base fields aggregate them (see
243
+ * `VisualEvalConfig.canvases`).
244
+ */
245
+ interface VisualEvaluationResult extends EvaluationResult {
246
+ canvases?: CanvasVisualResult[];
247
+ }
248
+ /** Injection points for `runVisualEvaluation` — screenshot deps plus the judge call (tests). */
249
+ interface VisualEvalDeps extends ScreenshotDeps {
250
+ /** The multimodal judge call (default: `callMultimodalLLM`). */
251
+ judge?: typeof callMultimodalLLM;
252
+ }
253
+ interface VisualEvalContext {
254
+ /** Compiled JavaScript code (ESM with imports) */
255
+ compiledCode: string;
256
+ /** Original user prompt */
257
+ originalPrompt: string;
258
+ /** Design system CSS tokens */
259
+ cssTokens?: string;
260
+ }
261
+ /** The page surface the capture uses — a structural subset of puppeteer's `Page`. */
262
+ interface ScreenshotPage {
263
+ setContent(html: string, options: {
264
+ waitUntil: 'load';
265
+ timeout: number;
266
+ }): Promise<void>;
267
+ waitForNetworkIdle(options: {
268
+ idleTime: number;
269
+ timeout: number;
270
+ }): Promise<void>;
271
+ waitForSelector(selector: string, options: {
272
+ timeout: number;
273
+ }): Promise<unknown>;
274
+ screenshot(options: {
275
+ type: 'png';
276
+ fullPage: boolean;
277
+ }): Promise<Uint8Array>;
278
+ }
279
+ /** The browser surface the capture uses — a structural subset of puppeteer's `Browser`. */
280
+ interface ScreenshotBrowser {
281
+ newPage(): Promise<ScreenshotPage>;
282
+ close(): Promise<void>;
283
+ }
284
+ type ScreenshotLauncher = (options: LaunchOptions) => Promise<ScreenshotBrowser>;
285
+ /** The two members of `@sparticuz/chromium` the fallback launch path reads. */
286
+ interface ChromiumProvider {
287
+ readonly args: string[];
288
+ executablePath(): Promise<string>;
289
+ }
290
+ /**
291
+ * Injection points for the capture — every default is the production
292
+ * path; tests replace them to pin branch selection without launching a
293
+ * browser.
294
+ */
295
+ interface ScreenshotDeps {
296
+ /** Launches the browser (default: `puppeteer-core`'s `launch`). */
297
+ launch?: ScreenshotLauncher;
298
+ /** Environment the executable-path override is read from (default: `process.env`). */
299
+ env?: NodeJS.ProcessEnv;
300
+ /** Loads `@sparticuz/chromium` (default: dynamic import) — only consulted when no override is set. */
301
+ loadChromium?: () => Promise<ChromiumProvider>;
302
+ /** Post-load settle time before the screenshot, ms (default 1000). */
303
+ settleMs?: number;
304
+ }
305
+ /**
306
+ * Pick the browser binary. `PUPPETEER_EXECUTABLE_PATH` (a system
307
+ * Chromium — the bench runner image, a dev box) wins and skips the
308
+ * `@sparticuz/chromium` load entirely; otherwise the bundled Lambda
309
+ * Chromium supplies both binary and flags, as before.
310
+ */
311
+ declare function resolveLaunchOptions(viewport: {
312
+ width: number;
313
+ height: number;
314
+ }, deps?: Pick<ScreenshotDeps, 'env' | 'loadChromium'>): Promise<LaunchOptions>;
315
+ /**
316
+ * Take a screenshot of the rendered component.
317
+ * Returns the PNG bytes, or null if no browser could be launched.
318
+ */
319
+ declare function captureScreenshot(html: string, viewport?: {
320
+ width: number;
321
+ height: number;
322
+ }, deps?: ScreenshotDeps): Promise<Buffer | null>;
212
323
  /**
213
324
  * Send the screenshot to the configured multimodal provider through
214
325
  * the shared `LLMAgent` machinery. Routing through `createVisionAgent`
@@ -220,5 +331,34 @@ interface VisualEvalConfig {
220
331
  * Bedrock path) instead of `process.env`.
221
332
  */
222
333
  declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prompt: string, screenshot: Buffer, originalPrompt: string): Promise<LLMResponse>;
334
+ /**
335
+ * Run visual evaluation on a compiled component.
336
+ *
337
+ * 1. Builds an HTML page with the component + sample props
338
+ * 2. Takes a screenshot via puppeteer (if available)
339
+ * 3. Sends screenshot to multimodal LLM for visual scoring
340
+ *
341
+ * Returns null if puppeteer is not available (graceful fallback).
342
+ */
343
+ declare function runVisualEvaluation(context: VisualEvalContext, config: VisualEvalConfig, deps?: VisualEvalDeps): Promise<VisualEvaluationResult | null>;
344
+ /** The per-canvas verdicts without the PNGs — what the harness stamps on `EvalResult.visual`. */
345
+ declare function summarizeVisualResult(result: VisualEvaluationResult): VisualEvalSummary | undefined;
346
+
347
+ /** What the harness's eval round consumes from the visual leg. */
348
+ interface VisualEvalOutcome {
349
+ /** Tier-2 issues (empty when no browser is available). */
350
+ issues: EvalIssue[];
351
+ /**
352
+ * Per-canvas summary — present ONLY when `config.canvases` was set and
353
+ * the leg ran; the harness stamps it on `EvalResult.visual`. Absent on
354
+ * the single-shot path (byte-identical to the pre-canvas result).
355
+ */
356
+ summary?: VisualEvalSummary;
357
+ }
358
+ /**
359
+ * Run visual evaluation and return tier 2 EvalIssues (+ the per-canvas
360
+ * summary when canvases were requested).
361
+ */
362
+ declare function runVisualEval(context: VisualEvalContext, config: VisualEvalConfig): Promise<VisualEvalOutcome>;
223
363
 
224
- export { type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, QualityMetadata, type SdkMessage, type VisualEvalConfig, buildFixPrompt, callMultimodalLLM, computeEvaluationScore, createEvaluationToolsServer, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, runEvaluation, runEvaluationLoop };
364
+ export { CanvasClass, CanvasViewport, type CanvasVisualResult, type ChromiumProvider, EvalIssue, type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, QualityMetadata, type ScreenshotBrowser, type ScreenshotDeps, type ScreenshotLauncher, type ScreenshotPage, type SdkMessage, type VisualEvalConfig, type VisualEvalContext, type VisualEvalDeps, type VisualEvalOutcome, VisualEvalSummary, type VisualEvaluationResult, buildFixPrompt, callMultimodalLLM, captureScreenshot, computeEvaluationScore, createEvaluationToolsServer, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, resolveLaunchOptions, runEvaluation, runEvaluationLoop, runVisualEval, runVisualEvaluation, summarizeVisualResult };