@ggui-ai/ui-gen 0.24.0 → 0.25.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/{adapter-Du7P_5Fx.d.ts → adapter-Cg_rkpGq.d.ts} +1 -1
- package/dist/adapters/generation-dispatch.d.ts +27 -5
- package/dist/adapters/generation-dispatch.js +909 -53
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.js +3 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/advanced/index.d.ts +12 -10
- package/dist/advanced/index.js +917 -98
- package/dist/advanced/index.js.map +1 -1
- package/dist/{axes-CzLEMDeB.d.ts → axes-CKVCzR_x.d.ts} +1 -1
- package/dist/bank-CT4eEkta.d.ts +118 -0
- package/dist/boilerplate.js +24 -12
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +11 -4
- package/dist/check/index.js +47 -1
- package/dist/check/index.js.map +1 -1
- package/dist/classifier/index.d.ts +2 -2
- package/dist/compose.d.ts +2 -2
- package/dist/{create-ui-generator-GIhzx08x.d.ts → create-ui-generator-DFnnArrv.d.ts} +11 -3
- package/dist/{dispatch-BnAH56p4.d.ts → dispatch-CStl9eAw.d.ts} +5 -3
- package/dist/evaluation/axis-checks/index.d.ts +5 -5
- package/dist/evaluation/axis-checks/index.js +90 -2
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +3 -3
- package/dist/evaluation/axis-checks/registry.js +88 -1
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +300 -23
- package/dist/evaluation/index.js +746 -30
- package/dist/evaluation/index.js.map +1 -1
- package/dist/evaluation/types.d.ts +9 -1
- package/dist/evaluation/types.js.map +1 -1
- package/dist/fragments/index.d.ts +3 -3
- package/dist/harness/check/runtime-render/index.d.ts +5 -5
- package/dist/harness/index.d.ts +4 -4
- package/dist/harness/index.js +33 -15
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/result-types.d.ts +3 -3
- package/dist/harness/runtime.d.ts +10 -4
- package/dist/harness/runtime.js +26 -14
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +3 -3
- package/dist/harness/types-public.js +33 -15
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +3 -3
- package/dist/hash.d.ts +1 -1
- package/dist/index.d.ts +25 -9
- package/dist/index.js +926 -101
- package/dist/index.js.map +1 -1
- package/dist/{llm-router-DwwUK1bz.d.ts → llm-router-nfO7wPec.d.ts} +3 -1
- package/dist/patch.d.ts +3 -3
- package/dist/policy.d.ts +1 -1
- package/dist/tools/get-primitives-ts.d.ts +1 -1
- package/dist/tools/get-primitives-ts.js +1 -1
- package/dist/tools/get-primitives-ts.js.map +1 -1
- package/dist/{types-BOvHNG7K.d.ts → types-Dh1s4K9j.d.ts} +1 -1
- package/dist/{types-public-Bk6d1WLN.d.ts → types-public-BJTLpzWn.d.ts} +134 -7
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/index.js.map +1 -1
- package/dist/workflows.d.ts +3 -3
- package/package.json +12 -12
- package/src/adapters/generation-dispatch.ts +36 -2
- package/src/adapters/tools.ts +2 -1
- package/src/boilerplate/free-design-prompt.ts +1 -1
- package/src/boilerplate/generate.ts +26 -1
- package/src/boilerplate/hard-sections.ts +13 -13
- package/src/boilerplate/system-prompt.ts +1 -1
- package/src/check/index.ts +1 -0
- package/src/check/sample-props.ts +63 -0
- package/src/coding-agent/tools.ts +4 -1
- package/src/create-harness.ts +3 -3
- package/src/create-ui-generator.ts +20 -1
- package/src/evaluation/__fixtures__/png.ts +100 -0
- package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
- package/src/evaluation/axis-checks/checks/universal.ts +111 -0
- package/src/evaluation/axis-checks/dispatch.ts +4 -1
- package/src/evaluation/criteria/bank.ts +85 -0
- package/src/evaluation/criteria/context.ts +52 -0
- package/src/evaluation/criteria/resolve.ts +159 -0
- package/src/evaluation/criteria/select.ts +79 -0
- package/src/evaluation/index.ts +23 -0
- package/src/evaluation/ink-extent.ts +200 -0
- package/src/evaluation/theme-css.ts +12 -5
- package/src/evaluation/types-public.ts +130 -3
- package/src/evaluation/types.ts +9 -0
- package/src/evaluation/visual-evaluator.ts +636 -30
- package/src/harness/coding/generate-task-runner.ts +3 -0
- package/src/harness/coding/run-coding-turn.ts +7 -3
- package/src/harness/coding/run-eval-round.ts +19 -0
- package/src/harness/runtime.ts +5 -0
- package/src/harness-tool-names.ts +38 -0
- package/src/index.ts +12 -0
- package/src/run-check.ts +2 -0
- package/src/tools/get-primitives-ts.ts +1 -1
- package/src/tools/get-wire.ts +1 -1
- package/src/tools/render-check.ts +0 -60
- package/src/tools.ts +11 -1
- package/src/validation/primitives.ts +1 -1
package/dist/workflows.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as Classification } from './axes-
|
|
1
|
+
import { C as Classification } from './axes-CKVCzR_x.js';
|
|
2
2
|
import { Workflow } from './harness/types-public.js';
|
|
3
3
|
import '@ggui-ai/protocol';
|
|
4
4
|
import './styling-profile-CxfvV48g.js';
|
|
5
|
-
import './types-public-
|
|
5
|
+
import './types-public-BJTLpzWn.js';
|
|
6
6
|
import '@ggui-ai/mcp-server-core';
|
|
7
7
|
import './design-mode-DLufhrNp.js';
|
|
8
|
-
import './types-
|
|
8
|
+
import './types-Dh1s4K9j.js';
|
|
9
9
|
import './llm.js';
|
|
10
10
|
import './policy.js';
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ggui-ai/ui-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "UI generation harness for ggui — the LLM system prompt, multi-turn coding loop, and evaluation engine that turn a DataContract into a React component. Implements the UiGenerator contract from @ggui-ai/mcp-server-core; consumed by @ggui-ai/mcp-server.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -189,9 +189,9 @@
|
|
|
189
189
|
"puppeteer-core": "^24.40.0 || ^25.0.0",
|
|
190
190
|
"react": "^18.0.0 || ^19.0.0",
|
|
191
191
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
192
|
-
"@ggui-ai/project-config": "0.
|
|
193
|
-
"@ggui-ai/
|
|
194
|
-
"@ggui-ai/
|
|
192
|
+
"@ggui-ai/project-config": "0.25.0",
|
|
193
|
+
"@ggui-ai/mcp-server-core": "0.25.0",
|
|
194
|
+
"@ggui-ai/protocol": "0.25.0"
|
|
195
195
|
},
|
|
196
196
|
"peerDependenciesMeta": {
|
|
197
197
|
"@google/adk": {
|
|
@@ -233,11 +233,11 @@
|
|
|
233
233
|
"openai": "^7.9.0",
|
|
234
234
|
"typescript": "^5.0.0",
|
|
235
235
|
"zod": "^4.3.6",
|
|
236
|
-
"@ggui-ai/design": "0.
|
|
237
|
-
"@ggui-ai/
|
|
238
|
-
"@ggui-ai/
|
|
239
|
-
"@ggui-ai/
|
|
240
|
-
"@ggui-ai/wire": "0.
|
|
236
|
+
"@ggui-ai/design": "0.25.0",
|
|
237
|
+
"@ggui-ai/ui-visual-tester": "0.25.0",
|
|
238
|
+
"@ggui-ai/gadgets": "0.25.0",
|
|
239
|
+
"@ggui-ai/sandbox": "0.25.0",
|
|
240
|
+
"@ggui-ai/wire": "0.25.0"
|
|
241
241
|
},
|
|
242
242
|
"devDependencies": {
|
|
243
243
|
"@google/adk": "^2.0.0",
|
|
@@ -252,9 +252,9 @@
|
|
|
252
252
|
"react-dom": "^19.0.0",
|
|
253
253
|
"tsup": "^8.5.0",
|
|
254
254
|
"vitest": "^3.2.6",
|
|
255
|
-
"@ggui-ai/mcp-server-core": "0.
|
|
256
|
-
"@ggui-ai/project-config": "0.
|
|
257
|
-
"@ggui-ai/protocol": "0.
|
|
255
|
+
"@ggui-ai/mcp-server-core": "0.25.0",
|
|
256
|
+
"@ggui-ai/project-config": "0.25.0",
|
|
257
|
+
"@ggui-ai/protocol": "0.25.0"
|
|
258
258
|
},
|
|
259
259
|
"engines": {
|
|
260
260
|
"node": ">=22.0.0"
|
|
@@ -60,8 +60,22 @@ import type { QualityConfig } from "../evaluation/types-public.js";
|
|
|
60
60
|
import type { AgentConfig } from "../harness/llm-router.js";
|
|
61
61
|
import { type GadgetDescriptor, type JsonObject } from "@ggui-ai/protocol";
|
|
62
62
|
import { canvasForRendering, type CanvasClass, type DesignMode } from "../design-mode.js";
|
|
63
|
+
import type { VisionProvider } from "../harness/llm-router.js";
|
|
64
|
+
import type { CriteriaBank } from "../evaluation/criteria/bank.js";
|
|
63
65
|
import type { GenerationProfileInput } from "../boilerplate/styling-profile.js";
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* ggui#1250 — the in-loop VISUAL judge as its own agent: a vision provider (typed so an OpenAI judge cannot
|
|
69
|
+
* be written), a model, and — when the caller resolves provider keys itself — that provider's key, which
|
|
70
|
+
* becomes the agent's own `routeOverride`. Never the coding agent's route: where this exists (an OpenAI
|
|
71
|
+
* coding lane), the coding key is another provider's.
|
|
72
|
+
*/
|
|
73
|
+
export interface VisualEvalAgentSpec {
|
|
74
|
+
readonly provider: VisionProvider;
|
|
75
|
+
readonly model: string;
|
|
76
|
+
readonly apiKey?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
65
79
|
export interface GenerationDispatchParams {
|
|
66
80
|
provider: ProviderName;
|
|
67
81
|
model: string;
|
|
@@ -109,6 +123,9 @@ export interface GenerationDispatchParams {
|
|
|
109
123
|
* the same box. See `VisualEvalConfig.canvasViewports`.
|
|
110
124
|
*/
|
|
111
125
|
canvasViewports?: Partial<Readonly<Record<CanvasClass, { width: number; height: number }>>>;
|
|
126
|
+
/** ggui#1436 — see `SingleComponentParams.visualEvaluation.criteriaBank`. */
|
|
127
|
+
criteriaBank?: CriteriaBank;
|
|
128
|
+
criteriaKind?: string;
|
|
112
129
|
};
|
|
113
130
|
/** Quality config controlling eval tiers and improvement behavior */
|
|
114
131
|
qualityConfig?: QualityConfig;
|
|
@@ -190,6 +207,13 @@ export interface GenerationDispatchParams {
|
|
|
190
207
|
* existing behavior for callers that don't set it.
|
|
191
208
|
*/
|
|
192
209
|
routeOverride?: AgentConfig["routeOverride"];
|
|
210
|
+
/**
|
|
211
|
+
* ggui#1250 — the in-loop visual judge named as its own agent (see {@link VisualEvalAgentSpec}).
|
|
212
|
+
* Absent (default, every existing caller): today's chain, `visualEval ← evaluation ← coding`, which on
|
|
213
|
+
* a lane without a vision path records the score half as skipped (#1248). Off by default; a measurement
|
|
214
|
+
* knob first, a product knob only by ruling.
|
|
215
|
+
*/
|
|
216
|
+
visualEvalAgent?: VisualEvalAgentSpec;
|
|
193
217
|
/**
|
|
194
218
|
* Retry observer (#489) — see `AgentConfig.onRetry`. Threaded onto
|
|
195
219
|
* the coding + evaluation agent specs so a rate-limited retry inside
|
|
@@ -268,8 +292,17 @@ export async function dispatchGeneration(
|
|
|
268
292
|
onRetry: params.onRetry,
|
|
269
293
|
}
|
|
270
294
|
: undefined;
|
|
271
|
-
//
|
|
272
|
-
//
|
|
295
|
+
// ggui#1250 — the in-loop visual judge as its own agent when named: its own provider and its own key
|
|
296
|
+
// route, never the coding agent's. Absent: today's chain, visualEval ← evaluation ← coding, inside
|
|
297
|
+
// resolveSessionAgents (ModelRoles has no visualEval slot — a role is a model, and this needs a provider).
|
|
298
|
+
const visualEvalAgent = params.visualEvalAgent
|
|
299
|
+
? {
|
|
300
|
+
provider: params.visualEvalAgent.provider,
|
|
301
|
+
model: params.visualEvalAgent.model,
|
|
302
|
+
...(params.visualEvalAgent.apiKey !== undefined ? { routeOverride: { apiKey: params.visualEvalAgent.apiKey } } : {}),
|
|
303
|
+
onRetry: params.onRetry,
|
|
304
|
+
}
|
|
305
|
+
: undefined;
|
|
273
306
|
|
|
274
307
|
// ── Contract enrichment ──────────────────────────────────────────────
|
|
275
308
|
// The contract is used as-is: `clientCapabilities.gadgets`
|
|
@@ -426,6 +459,7 @@ export async function dispatchGeneration(
|
|
|
426
459
|
const agents = resolveSessionAgents({
|
|
427
460
|
codingAgent,
|
|
428
461
|
evaluationAgent,
|
|
462
|
+
...(visualEvalAgent !== undefined ? { visualEvalAgent } : {}),
|
|
429
463
|
});
|
|
430
464
|
|
|
431
465
|
// ── Runtime policy resolution ──
|
package/src/adapters/tools.ts
CHANGED
|
@@ -20,7 +20,8 @@ import { validateAllContracts } from '../check/index.js';
|
|
|
20
20
|
import { typecheck } from '../check/index.js';
|
|
21
21
|
import { lintReactHooks } from '../check/index.js';
|
|
22
22
|
import ts from 'typescript';
|
|
23
|
-
import { tryRender
|
|
23
|
+
import { tryRender } from '../tools/render-check.js';
|
|
24
|
+
import { generateSampleProps } from '../check/sample-props.js';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Context for creating generator tools.
|
|
@@ -212,7 +212,7 @@ With raw elements YOU own the semantics — nothing is accessible by constructio
|
|
|
212
212
|
3. **Images have \`alt\`** (\`alt=""\` for decorative). Icon-only buttons need \`aria-label\`; decorative icons and emoji are \`aria-hidden="true"\`.
|
|
213
213
|
4. **Live & streaming data** (a \`useStream\` \`.latest\` value, counters, clocks, flashing prices) sits in an \`aria-live="polite"\` (or \`role="status"\`) region so screen readers announce the change.
|
|
214
214
|
5. **Headings nest**: one \`<h1>\` per screen, \`<h2>\` for sections, \`<h3>\` below — never skipped or inverted.
|
|
215
|
-
6. **Busy state is announced**: \`<button disabled={
|
|
215
|
+
6. **Busy state is announced**: every control that dispatches an action (a button, a select whose change dispatches, an input that sends on Enter) stays pending from \`useActionPending('<action>')\` until the agent's answer repaints the card — \`<button disabled={sendPending} aria-busy={sendPending}>{sendPending ? 'Sending…' : 'Send'}</button>\`. Only a control that dispatches the action carries its busy look; while it is pending, other controls of the same record may be disabled — nothing more (controls of other records, creation controls and the action's own cancel stay enabled); busy state the card owns (\`isLoading\`) the same way.
|
|
216
216
|
7. **Stateful controls announce state**: \`role="checkbox"\` + \`aria-checked\` on a toggleable row, \`aria-pressed\` on a toggle button, \`aria-selected\` on the chosen item, \`aria-expanded\` on an open/close affordance. Styling (strikethrough, color, a check mark) is never the only carrier of state.
|
|
217
217
|
8. **Focus is visible** — style \`:focus-visible\` with a token color; never \`outline: none\` without a replacement.`;
|
|
218
218
|
|
|
@@ -230,6 +230,7 @@ export function generateBoilerplate(
|
|
|
230
230
|
const actionTypeAliases: string[] = [];
|
|
231
231
|
const actionHookCalls: string[] = [];
|
|
232
232
|
const actionReturnFields: string[] = [];
|
|
233
|
+
let hasOneShotAction = false;
|
|
233
234
|
const actionsMap: ActionSpec = contract?.actionSpec ?? {};
|
|
234
235
|
for (const [key, entry] of Object.entries(actionsMap)) {
|
|
235
236
|
const label = entry.label ?? key;
|
|
@@ -274,7 +275,29 @@ export function generateBoilerplate(
|
|
|
274
275
|
// instruction for every action. So it stays, ALONE on the hook line — what
|
|
275
276
|
// sits next to it is part of what it says.
|
|
276
277
|
const onceHint = " — if this is meant ONCE, disable its control after it fires";
|
|
277
|
-
|
|
278
|
+
// ggui#1223 (rnd reliability/013, arm C): an action the contract DECLARES
|
|
279
|
+
// `oneShot` gets its spent state as data, pre-bound beside the dispatcher —
|
|
280
|
+
// WHAT to code, beside HOW — and the generic once-hint leaves ITS line only:
|
|
281
|
+
// left there, the hint steered the model to a local `useState(false)` guard
|
|
282
|
+
// against the prompt's block (arm B: 0 of 6 declared cells used the hook).
|
|
283
|
+
// The generic hint stays verbatim on every undeclared action.
|
|
284
|
+
if (entry.oneShot === true) {
|
|
285
|
+
hasOneShotAction = true;
|
|
286
|
+
actionHookCalls.push(
|
|
287
|
+
` const ${key} = useAction<${typeName}>('${key}'); // ${callSig}${toolHint} — declared oneShot: the runtime drops a second dispatch`,
|
|
288
|
+
);
|
|
289
|
+
actionHookCalls.push(
|
|
290
|
+
` const ${key}Spent = useActionSpent('${key}'); // true once fired, also after a reload — render the control from THIS: disabled={${key}Spent} and a spent label`,
|
|
291
|
+
);
|
|
292
|
+
} else {
|
|
293
|
+
actionHookCalls.push(` const ${key} = useAction<${typeName}>('${key}'); // ${callSig}${toolHint}${onceHint}`);
|
|
294
|
+
}
|
|
295
|
+
// ggui#1398 — the dispatch's in-flight state, bound at the site the model
|
|
296
|
+
// writes the control (reliability/013: a rule alone reached 1/6, the
|
|
297
|
+
// binding 6/6).
|
|
298
|
+
actionHookCalls.push(
|
|
299
|
+
` const ${key}Pending = useActionPending('${key}'); // true from the tap until the agent's answer repaints the card — render EVERY control that dispatches '${key}' (a Button, a Select's onChange, an Input's Enter) from THIS: disabled={${key}Pending} aria-busy={${key}Pending}, and a working label on a button; no other control carries its aria-busy`,
|
|
300
|
+
);
|
|
278
301
|
actionReturnFields.push(key);
|
|
279
302
|
}
|
|
280
303
|
|
|
@@ -507,6 +530,8 @@ export function generateBoilerplate(
|
|
|
507
530
|
|
|
508
531
|
const wireHooks: string[] = [];
|
|
509
532
|
if (hasActions) wireHooks.push("useAction");
|
|
533
|
+
if (hasOneShotAction) wireHooks.push("useActionSpent");
|
|
534
|
+
if (hasActions) wireHooks.push("useActionPending");
|
|
510
535
|
if (hasStream) wireHooks.push("useStream");
|
|
511
536
|
if (hasContext) wireHooks.push("useGguiContext");
|
|
512
537
|
const wireImport = hasAnyWireFromWire
|
|
@@ -214,29 +214,29 @@ Rules:
|
|
|
214
214
|
2. Layout and styling are universal. Colors, spacing, structure — these are the reusable part.
|
|
215
215
|
3. Default values come from the current request — so the component renders correctly standalone.
|
|
216
216
|
4. Copy comes from the props. NEVER invent display text the contract does not carry — 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** — not \`<Text caps>LET'S BEGIN</Text>\`, not \`WELCOME\`, not a section kicker like \`GETTING STARTED\` or \`OVERVIEW\` — 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. An action's control shows the contract's \`label\` VERBATIM — every character, including \`&\`, \`/\`, \`–\` and quotes — never paraphrased, shortened or re-cased (\`"Confirm & Schedule"\` is not \`"Confirm Schedule"\`).
|
|
217
|
-
5. Props interface must be typed and exported
|
|
217
|
+
5. Props interface must be typed and exported.
|
|
218
|
+
6. Keys on a mapped list come from the item's own identity: \`key={item.id}\` when the contract gives an id; when the items carry none (KPI tiles \`{label, value}\`, forecast days \`{day, high}\`), key by the field that names each one — \`key={item.label}\`, \`key={day.day}\` — never by the map index: a reorder or a stream merge re-keys by index and re-mounts the wrong rows, and the self-check refuses an index key.`;
|
|
218
219
|
|
|
219
220
|
/**
|
|
220
221
|
* A control that fires an action the user would not mean to repeat must not
|
|
221
|
-
* stay armed (ggui#1108
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
222
|
+
* stay armed (ggui#1108). One-shot-ness is DECLARED on the action
|
|
223
|
+
* (`actionSpec.<name>.oneShot`), enforced by the runtime, and readable by the
|
|
224
|
+
* component through `useActionSpent` (ggui#1223) — so a declared action's
|
|
225
|
+
* control renders from data that survives a reload, and the local-state guard
|
|
226
|
+
* remains only as the fallback for an action the contract failed to declare.
|
|
227
|
+
* Both arms, one HARD section: the contract says which actions are once; where
|
|
228
|
+
* it does not, the request may, and no static rule of ours can infer it from a
|
|
229
|
+
* verb.
|
|
225
230
|
*/
|
|
226
231
|
export const TERMINAL_ACTIONS = `## Actions the user means once
|
|
227
232
|
|
|
228
233
|
A second press is a mistake only when it would make a SECOND THING HAPPEN IN THE WORLD — a second booking, a second charge, a second order, a second application sent. If pressing again would only write the SAME STATE AGAIN — saving, updating, renaming, setting a preference, toggling — nothing is duplicated and the control stays armed.
|
|
229
234
|
|
|
230
|
-
|
|
235
|
+
**The contract says which actions are once.** An action the contract declares \`oneShot: true\` (in the Contract block above) is guarded by the runtime — a second dispatch is dropped — and its spent state is DATA you read, never state you hold: render its control from \`const spent = useActionSpent('<name>')\`, \`disabled={spent}\`, and say so in the label or beside it ("Submitted", "Request sent") — a control that is disabled without explanation reads as broken. The hook's answer survives a reload and a second tab; \`useState(false)\` does not, so a reloaded card built on local state re-arms a control that already fired.
|
|
231
236
|
|
|
232
|
-
**
|
|
237
|
+
**An action the contract does not declare \`oneShot\` stays armed.** Never guard one from a feeling about the verb — "confirm", "submit", "place" alone are not evidence. Guard it only where the request itself names a one-time commitment the contract failed to declare ("submit the application", "place the order"), and then with local state as the fallback: \`const [submitted, setSubmitted] = useState(false)\` set in the handler, \`disabled={submitted}\` with a label — knowing that this state lives with the component, not with the request, and starts fresh on a re-render with new props.
|
|
233
238
|
|
|
234
|
-
When
|
|
235
|
-
- Hold a small piece of state for it and set it in the handler: \`const [submitted, setSubmitted] = useState(false)\`.
|
|
236
|
-
- \`disabled={submitted}\` on the control that fires it, and say so in the label or beside it ("Submitted", "Request sent") — a control that is disabled without explanation reads as broken.
|
|
237
|
-
- A card re-rendered with new props starts fresh; the state above lives with the component, not with the request.
|
|
238
|
-
|
|
239
|
-
Nothing in the wire DECLARES one-shot-ness yet, which is why the test is what a second press would DO — not how final the word sounds.`;
|
|
239
|
+
**When in doubt, leave it armed.** A control the user cannot press a second time has lost them something that worked — save, edit, save again is ordinary. A control left armed is only what every interface does by default.`;
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* The frame owns the height — the component never sizes itself to the
|
|
@@ -469,7 +469,7 @@ The design-system primitives are accessible by construction — they emit their
|
|
|
469
469
|
3. **Icons are decorative by default** — \`<Icon name="check" />\` is hidden from screen readers, which is correct for an icon sitting next to text. Add \`aria-label\` ONLY for a standalone, meaning-bearing icon with no adjacent text. Icon-only \`Button\`s still need \`aria-label\` on the **Button** itself.
|
|
470
470
|
4. **Live & streaming data** — wrap any region whose content updates on its own (a \`useStream\` \`.latest\` value, a live clock, an "N new" counter, a flashing price) in an element with \`aria-live="polite"\` so screen readers announce the change.
|
|
471
471
|
5. **Headings nest** — one \`<Heading level={1}>\` per screen, \`level={2}\` for sections, \`level={3}\` for subsections. Never skip or invert levels.
|
|
472
|
-
6. **Buttons** — descriptive text content; icon-only buttons need \`aria-label\`. Announce busy state: \`<Button disabled={
|
|
472
|
+
6. **Buttons** — descriptive text content; icon-only buttons need \`aria-label\`. Announce busy state. EVERY control that dispatches an action — a Button, a Select whose change dispatches, an Input that sends on Enter — stays pending from that action's \`useActionPending\` until the agent's answer repaints the card: with \`const sendPending = useActionPending('send');\`, write \`<Button disabled={sendPending} aria-busy={sendPending} onClick={() => send({ text })}>{sendPending ? 'Sending…' : 'Send'}</Button>\`, and give a dispatching Select or Input the same \`disabled={sendPending} aria-busy={sendPending}\`. Only a control that dispatches the action carries its \`aria-busy\` and a working label. While it is pending, other controls of the SAME record may be \`disabled\` — nothing more; controls of other records, creation controls and the action's own cancel stay enabled. Busy state the card owns (a local \`isLoading\`) is announced the same way.
|
|
473
473
|
7. **Stateful controls announce their state.** Toggleable / selectable / expandable things use the primitive that carries the semantics (\`Checkbox\`, \`Toggle\`, \`Tabs\`, \`Accordion\`) — never a styled \`Box\`/\`Icon\` that only *looks* checked. When you hand-roll one with \`as={Clickable}\`, \`Clickable\` adds button + keyboard semantics but NOT state — add it yourself: \`role="checkbox"\` + \`aria-checked={done}\` on a toggleable row, \`aria-pressed\` on a toggle button, \`aria-selected\` on the chosen item, \`aria-expanded\` on an open/close affordance. Styling (strikethrough, color, a check icon) must never be the only carrier of state.
|
|
474
474
|
|
|
475
475
|
## Design System Usage (CRITICAL)
|
package/src/check/index.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Sample props from a PropsSpec — `example` first, then `default`, then a type-driven fill from the JSON
|
|
2
|
+
// Schema. Pure: protocol types only, no sandbox, no node modules, so `@ggui-ai/ui-gen/check` can export it and a
|
|
3
|
+
// caller outside the harness (an experiment's judge input, ggui#1386) synthesizes the SAME props the coding
|
|
4
|
+
// agent's own render check falls back to. Moved verbatim out of `tools/render-check.ts` (2026-09-26).
|
|
5
|
+
import type { JsonObject, JsonSchema, JsonValue, PropsSpec } from '@ggui-ai/protocol';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate sample props from a PropsSpec contract.
|
|
9
|
+
* Uses `example` values from each PropEntry when available,
|
|
10
|
+
* otherwise synthesizes plausible defaults from the JSON Schema.
|
|
11
|
+
*/
|
|
12
|
+
export function generateSampleProps(spec: PropsSpec): JsonObject {
|
|
13
|
+
const props: JsonObject = {};
|
|
14
|
+
|
|
15
|
+
for (const [name, entry] of Object.entries(spec.properties)) {
|
|
16
|
+
// Prefer explicit example value
|
|
17
|
+
if (entry.example !== undefined) {
|
|
18
|
+
props[name] = entry.example;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Prefer explicit default value
|
|
23
|
+
if (entry.default !== undefined) {
|
|
24
|
+
props[name] = entry.default;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Synthesize from JSON Schema
|
|
29
|
+
props[name] = synthesizeFromSchema(entry.schema);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return props;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function synthesizeFromSchema(schema: JsonSchema): JsonValue | undefined {
|
|
36
|
+
// Draft-07 type arrays (`['string','null']`) synthesize from the
|
|
37
|
+
// first non-null member — the canonical nullability form the
|
|
38
|
+
// enforced-props-schema emission produces.
|
|
39
|
+
const declared = Array.isArray(schema.type)
|
|
40
|
+
? schema.type.find((t) => t !== 'null')
|
|
41
|
+
: schema.type;
|
|
42
|
+
switch (declared) {
|
|
43
|
+
case 'string': return 'sample';
|
|
44
|
+
case 'number':
|
|
45
|
+
case 'integer': return 0;
|
|
46
|
+
case 'boolean': return false;
|
|
47
|
+
case 'null': return null;
|
|
48
|
+
case 'array': {
|
|
49
|
+
if (schema.items) return [synthesizeFromSchema(schema.items) ?? null];
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
case 'object': {
|
|
53
|
+
const obj: JsonObject = {};
|
|
54
|
+
if (schema.properties) {
|
|
55
|
+
for (const [k, v] of Object.entries(schema.properties)) {
|
|
56
|
+
obj[k] = synthesizeFromSchema(v);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
default: return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -17,7 +17,7 @@ import type { AxisCheck, AxisCheckInput } from '../evaluation/types-public.js';
|
|
|
17
17
|
import type { Classification } from '../classifier/axes.js';
|
|
18
18
|
import type { CanvasClass } from '../design-mode.js';
|
|
19
19
|
import { PRIMITIVES_DOCUMENTATION } from '../validation/index.js';
|
|
20
|
-
import type { DataContract } from '@ggui-ai/protocol';
|
|
20
|
+
import type { DataContract, JsonObject } from '@ggui-ai/protocol';
|
|
21
21
|
import type {
|
|
22
22
|
ToolResult,
|
|
23
23
|
CommitMetadata,
|
|
@@ -64,6 +64,8 @@ export interface AutoCommitAxisChecks {
|
|
|
64
64
|
readonly originalPrompt: string;
|
|
65
65
|
/** The canvas the harness was built for (ggui#1117); absent = no rendering context, never a default. */
|
|
66
66
|
readonly canvas?: CanvasClass;
|
|
67
|
+
/** The props the probe and judge render with (ggui#1285); absent = the fixture-echo check stands down. */
|
|
68
|
+
readonly fixtureProps?: JsonObject;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
async function autoCommit(
|
|
@@ -161,6 +163,7 @@ async function autoCommit(
|
|
|
161
163
|
classification: axis.classification,
|
|
162
164
|
designMode,
|
|
163
165
|
...(axis.canvas !== undefined ? { canvas: axis.canvas } : {}),
|
|
166
|
+
...(axis.fixtureProps !== undefined ? { fixtureProps: axis.fixtureProps } : {}),
|
|
164
167
|
}
|
|
165
168
|
: undefined;
|
|
166
169
|
if (axisFacts !== undefined && !buildSuccess) traceAxisChecksSkipped(axisFacts, 'build failed — no check ran');
|
package/src/create-harness.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { hasProfile } from "./boilerplate/styling-profile.js";
|
|
|
16
16
|
import type { CacheTier } from "./fragments/index.js";
|
|
17
17
|
import { compose } from "./compose.js";
|
|
18
18
|
import { buildSystemPrompt, generateBoilerplate } from "./boilerplate.js";
|
|
19
|
-
import {
|
|
19
|
+
import { HARNESS_CODING_TOOLS, HARNESS_SCOPED_TOOLS } from "./harness-tool-names.js";
|
|
20
20
|
import { defaultApplyPatch } from "./patch.js";
|
|
21
21
|
import { computeHarnessId, computeHarnessName, hashClassification } from "./hash.js";
|
|
22
22
|
import { pickWorkflow } from "./workflows.js";
|
|
@@ -128,8 +128,8 @@ export function createHarness(input: CreateHarnessInput): Harness {
|
|
|
128
128
|
const baseWhat: WhatLeg = {
|
|
129
129
|
boilerplate,
|
|
130
130
|
fragments: whatFragments,
|
|
131
|
-
codingTools: [
|
|
132
|
-
scopedTools: [
|
|
131
|
+
codingTools: [...HARNESS_CODING_TOOLS],
|
|
132
|
+
scopedTools: [...HARNESS_SCOPED_TOOLS],
|
|
133
133
|
applyPatch: defaultPatchFn,
|
|
134
134
|
// Registered gadget catalog — drives the system prompt's gadget
|
|
135
135
|
// table + the boilerplate's direct-import emission. Omitted when no
|
|
@@ -38,6 +38,7 @@ import type {
|
|
|
38
38
|
JsonObject,
|
|
39
39
|
GeneratorId,
|
|
40
40
|
ModelRef,
|
|
41
|
+
AppGenerationProfileEffort,
|
|
41
42
|
} from "@ggui-ai/protocol";
|
|
42
43
|
import { isGeneratorId, modelRefOfRoute } from "@ggui-ai/protocol";
|
|
43
44
|
import type { GadgetCatalogAdapter } from "@ggui-ai/gadgets";
|
|
@@ -58,7 +59,7 @@ import {
|
|
|
58
59
|
parseGeneratorSlug,
|
|
59
60
|
} from "@ggui-ai/mcp-server-core";
|
|
60
61
|
import { createGeneratorTools } from "./adapters/index.js";
|
|
61
|
-
import { dispatchGeneration } from "./adapters/generation-dispatch.js";
|
|
62
|
+
import { dispatchGeneration, type VisualEvalAgentSpec } from "./adapters/generation-dispatch.js";
|
|
62
63
|
import {
|
|
63
64
|
createRuntimeRenderCheck,
|
|
64
65
|
type RuntimeRenderProbeConfig,
|
|
@@ -139,6 +140,13 @@ export interface CreateUiGeneratorOptions {
|
|
|
139
140
|
* prompt or the identity. Default: none — the round runs as today.
|
|
140
141
|
*/
|
|
141
142
|
readonly visualEvaluation?: SingleComponentParams["visualEvaluation"];
|
|
143
|
+
/**
|
|
144
|
+
* ggui#1250 — the in-loop VISUAL judge as its own agent (a vision provider, a model, and that
|
|
145
|
+
* provider's key when the caller resolves keys itself). Absent (default): the judge is the
|
|
146
|
+
* evaluation agent's provider, which on a lane without a vision path records the score half as
|
|
147
|
+
* skipped (#1248). Forwarded verbatim to the dispatch; never part of the prompt or the identity.
|
|
148
|
+
*/
|
|
149
|
+
readonly visualEvalAgent?: VisualEvalAgentSpec;
|
|
142
150
|
/** Quality config controlling eval tiers + improvement behavior. */
|
|
143
151
|
readonly qualityConfig?: QualityConfig;
|
|
144
152
|
/**
|
|
@@ -259,6 +267,7 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
259
267
|
maxEvalRounds,
|
|
260
268
|
evaluation,
|
|
261
269
|
visualEvaluation,
|
|
270
|
+
visualEvalAgent,
|
|
262
271
|
qualityConfig,
|
|
263
272
|
gadgetCatalog,
|
|
264
273
|
disableEnvMutation = false,
|
|
@@ -354,6 +363,9 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
354
363
|
}
|
|
355
364
|
: undefined;
|
|
356
365
|
|
|
366
|
+
// ggui#1459 — the named level whose dials this generation applied; set
|
|
367
|
+
// where the dials are resolved, read by both metadata arms below.
|
|
368
|
+
let effortRan: AppGenerationProfileEffort | undefined;
|
|
357
369
|
try {
|
|
358
370
|
const tools = createGeneratorTools({
|
|
359
371
|
...(input.contract ? { contract: input.contract } : {}),
|
|
@@ -400,6 +412,7 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
400
412
|
// deployment's options for THIS generation; absent ⇒ untouched.
|
|
401
413
|
// Prompt bytes never move with it (dials only).
|
|
402
414
|
const dials = effortDials(input.profile?.effort);
|
|
415
|
+
if (dials !== undefined) effortRan = input.profile?.effort;
|
|
403
416
|
const effectiveMaxAttempts = dials?.maxAttempts ?? maxAttempts;
|
|
404
417
|
const effectiveMaxEvalRounds = dials?.maxEvalRounds ?? maxEvalRounds;
|
|
405
418
|
const effectiveEvaluation =
|
|
@@ -442,6 +455,8 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
442
455
|
// ggui#1279 — the shell the declared rendering composes for (chat only; see harnessShellForRendering).
|
|
443
456
|
...(shellType !== undefined ? { shellType } : {}),
|
|
444
457
|
...(input.profile !== undefined ? { profile: input.profile } : {}),
|
|
458
|
+
// ggui#1250 — the named in-loop visual judge, when this generator was built with one.
|
|
459
|
+
...(visualEvalAgent !== undefined ? { visualEvalAgent } : {}),
|
|
445
460
|
// Fixture props reach the in-loop probe + visual round only (never the prompt, never identity).
|
|
446
461
|
...(input.fixtureProps !== undefined ? { fixtureProps: input.fixtureProps } : {}),
|
|
447
462
|
});
|
|
@@ -461,6 +476,8 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
461
476
|
attempts: result.turnsUsed,
|
|
462
477
|
// ggui#1280 — the build that made this generation (template keys, never per-request).
|
|
463
478
|
build: generatorBuild(designMode ?? DEFAULT_DESIGN_MODE),
|
|
479
|
+
// ggui#1459 — the level that ran; absent when none was applied.
|
|
480
|
+
...(effortRan !== undefined ? { effort: effortRan } : {}),
|
|
464
481
|
// Prompt-cache counters are provider-specific (Claude reports
|
|
465
482
|
// them; others omit). Pass through truthfully — absent on the
|
|
466
483
|
// adapter result stays absent here, never defaulted to 0.
|
|
@@ -507,6 +524,8 @@ export function createUiGenerator(options: CreateUiGeneratorOptions = {}): UiGen
|
|
|
507
524
|
cacheHit: false,
|
|
508
525
|
// ggui#1280 — a failed generation still names the build that failed.
|
|
509
526
|
build: generatorBuild(designMode ?? DEFAULT_DESIGN_MODE),
|
|
527
|
+
// ggui#1459 — and the level it ran, when one was applied.
|
|
528
|
+
...(effortRan !== undefined ? { effort: effortRan } : {}),
|
|
510
529
|
},
|
|
511
530
|
};
|
|
512
531
|
} finally {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PNG writer for tests (ggui#1120): 8-bit RGB / RGBA, non-interlaced, one scanline filter for the
|
|
3
|
+
* whole image — the shapes the judge's browser writes, so `decodePng` is exercised on every filter it
|
|
4
|
+
* must undo. Test-only: nothing in `src` imports it.
|
|
5
|
+
*/
|
|
6
|
+
import { crc32, deflateSync } from 'node:zlib';
|
|
7
|
+
|
|
8
|
+
export type Rgb = readonly [number, number, number];
|
|
9
|
+
|
|
10
|
+
export interface PngSpec {
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly height: number;
|
|
13
|
+
readonly channels: 3 | 4;
|
|
14
|
+
/** The colour at (x, y). */
|
|
15
|
+
readonly pixel: (x: number, y: number) => Rgb;
|
|
16
|
+
/** The scanline filter applied to every row (0 none, 1 sub, 2 up, 3 average, 4 paeth). */
|
|
17
|
+
readonly filter?: 0 | 1 | 2 | 3 | 4;
|
|
18
|
+
/** Overrides for the malformed cases. */
|
|
19
|
+
readonly bitDepth?: number;
|
|
20
|
+
readonly colorType?: number;
|
|
21
|
+
readonly interlace?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function chunk(type: string, data: Buffer): Buffer {
|
|
25
|
+
const head = Buffer.alloc(8);
|
|
26
|
+
head.writeUInt32BE(data.length, 0);
|
|
27
|
+
head.write(type, 4, 'latin1');
|
|
28
|
+
const crc = Buffer.alloc(4);
|
|
29
|
+
crc.writeUInt32BE(crc32(data, crc32(Buffer.from(type, 'latin1'))) >>> 0, 0);
|
|
30
|
+
return Buffer.concat([head, data, crc]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function encodePng(spec: PngSpec): Buffer {
|
|
34
|
+
const { width, height, channels } = spec;
|
|
35
|
+
const filter = spec.filter ?? 0;
|
|
36
|
+
const stride = width * channels;
|
|
37
|
+
const rows: number[][] = [];
|
|
38
|
+
for (let y = 0; y < height; y++) {
|
|
39
|
+
const row: number[] = [];
|
|
40
|
+
for (let x = 0; x < width; x++) {
|
|
41
|
+
const [r, g, b] = spec.pixel(x, y);
|
|
42
|
+
row.push(r, g, b);
|
|
43
|
+
if (channels === 4) row.push(255);
|
|
44
|
+
}
|
|
45
|
+
rows.push(row);
|
|
46
|
+
}
|
|
47
|
+
const raw = Buffer.alloc((stride + 1) * height);
|
|
48
|
+
for (let y = 0; y < height; y++) {
|
|
49
|
+
raw[y * (stride + 1)] = filter;
|
|
50
|
+
for (let i = 0; i < stride; i++) {
|
|
51
|
+
const x = rows[y]![i]!;
|
|
52
|
+
const a = i >= channels ? rows[y]![i - channels]! : 0;
|
|
53
|
+
const b = y > 0 ? rows[y - 1]![i]! : 0;
|
|
54
|
+
const c = y > 0 && i >= channels ? rows[y - 1]![i - channels]! : 0;
|
|
55
|
+
let out: number;
|
|
56
|
+
switch (filter) {
|
|
57
|
+
case 0:
|
|
58
|
+
out = x;
|
|
59
|
+
break;
|
|
60
|
+
case 1:
|
|
61
|
+
out = x - a;
|
|
62
|
+
break;
|
|
63
|
+
case 2:
|
|
64
|
+
out = x - b;
|
|
65
|
+
break;
|
|
66
|
+
case 3:
|
|
67
|
+
out = x - ((a + b) >> 1);
|
|
68
|
+
break;
|
|
69
|
+
case 4: {
|
|
70
|
+
const p = a + b - c;
|
|
71
|
+
const pa = Math.abs(p - a);
|
|
72
|
+
const pb = Math.abs(p - b);
|
|
73
|
+
const pc = Math.abs(p - c);
|
|
74
|
+
out = x - (pa <= pb && pa <= pc ? a : pb <= pc ? b : c);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
raw[y * (stride + 1) + 1 + i] = out & 0xff;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const ihdr = Buffer.alloc(13);
|
|
82
|
+
ihdr.writeUInt32BE(width, 0);
|
|
83
|
+
ihdr.writeUInt32BE(height, 4);
|
|
84
|
+
ihdr[8] = spec.bitDepth ?? 8;
|
|
85
|
+
ihdr[9] = spec.colorType ?? (channels === 4 ? 6 : 2);
|
|
86
|
+
ihdr[10] = 0;
|
|
87
|
+
ihdr[11] = 0;
|
|
88
|
+
ihdr[12] = spec.interlace ?? 0;
|
|
89
|
+
return Buffer.concat([
|
|
90
|
+
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
|
91
|
+
chunk('IHDR', ihdr),
|
|
92
|
+
chunk('IDAT', deflateSync(raw)),
|
|
93
|
+
chunk('IEND', Buffer.alloc(0)),
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** One flat colour — the blank. */
|
|
98
|
+
export function flatPng(width: number, height: number, colour: Rgb, channels: 3 | 4 = 3, filter: PngSpec['filter'] = 0): Buffer {
|
|
99
|
+
return encodePng({ width, height, channels, pixel: () => colour, filter });
|
|
100
|
+
}
|
|
@@ -108,7 +108,7 @@ function runMapKeyIsId(input: AxisCheckInput): EvalIssue[] {
|
|
|
108
108
|
mkIssue(
|
|
109
109
|
"render.map_key_is_id",
|
|
110
110
|
`Array key uses index variable "${key}" — reorders and stream merges will break React reconciliation.`,
|
|
111
|
-
`Replace key={${key}} with key={item.id}
|
|
111
|
+
`Replace key={${key}} with key={item.id} — or, when the items carry no id, with the field that names each one (item.label / item.symbol / item.name).`,
|
|
112
112
|
),
|
|
113
113
|
);
|
|
114
114
|
}
|