@ggui-ai/ui-gen 0.27.0 → 0.28.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 +172 -7
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/advanced/index.js +174 -9
- package/dist/advanced/index.js.map +1 -1
- package/dist/evaluation/axis-checks/index.js +97 -1
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.js +97 -1
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.js +102 -4
- package/dist/evaluation/index.js.map +1 -1
- package/dist/harness/index.js +2 -0
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/result-types.d.ts +12 -1
- package/dist/harness/result-types.js.map +1 -1
- package/dist/harness/types-public.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +174 -9
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/adapters/provider-router.ts +1 -0
- package/src/create-ui-generator.ts +4 -2
- package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
- package/src/evaluation/axis-checks/helpers.ts +125 -0
- package/src/evaluation/evaluator.ts +2 -2
- package/src/evaluation/llm-evaluator.ts +2 -2
- package/src/evaluation/visual-evaluator.ts +1 -1
- package/src/harness/coding/assemble-result.ts +1 -0
- package/src/harness/coding/dupe-break.ts +70 -0
- package/src/harness/coding/generate-task-runner.ts +5 -1
- package/src/harness/coding/run-coding-turn.ts +56 -1
- package/src/harness/result-types.ts +12 -0
- package/src/index.ts +1 -1
|
@@ -145,10 +145,96 @@ function getInitialValuePropNames(contract) {
|
|
|
145
145
|
}
|
|
146
146
|
return names;
|
|
147
147
|
}
|
|
148
|
+
function objectLiteralKeysAt(src, open) {
|
|
149
|
+
if (src[open] !== "{") return void 0;
|
|
150
|
+
const keys = [];
|
|
151
|
+
let depth = 0;
|
|
152
|
+
let expectKey = true;
|
|
153
|
+
for (let i = open; i < src.length; i++) {
|
|
154
|
+
const c = src[i];
|
|
155
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
156
|
+
let j = i + 1;
|
|
157
|
+
while (j < src.length && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
|
|
158
|
+
if (depth === 1 && expectKey && /^\s*:/.test(src.slice(j + 1))) keys.push(src.slice(i + 1, j));
|
|
159
|
+
i = j;
|
|
160
|
+
expectKey = false;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (c === "{" || c === "[" || c === "(") {
|
|
164
|
+
depth++;
|
|
165
|
+
if (depth === 1) expectKey = true;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (c === "}" || c === "]" || c === ")") {
|
|
169
|
+
depth--;
|
|
170
|
+
if (depth === 0) return keys;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (depth !== 1) continue;
|
|
174
|
+
if (c === ",") {
|
|
175
|
+
expectKey = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (expectKey && /[A-Za-z_$]/.test(c ?? "")) {
|
|
179
|
+
const m = /^([A-Za-z_$][\w$]*)\s*(:|,|\})/.exec(src.slice(i));
|
|
180
|
+
if (m !== null && m[1] !== void 0) keys.push(m[1]);
|
|
181
|
+
expectKey = false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return keys;
|
|
185
|
+
}
|
|
186
|
+
function callArgsAt(src, open) {
|
|
187
|
+
const args = [];
|
|
188
|
+
let depth = 0;
|
|
189
|
+
let start = open + 1;
|
|
190
|
+
for (let i = open; i < src.length; i++) {
|
|
191
|
+
const c = src[i];
|
|
192
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
193
|
+
let j = i + 1;
|
|
194
|
+
while (j < src.length && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
|
|
195
|
+
i = j;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (c === "(" || c === "{" || c === "[") depth++;
|
|
199
|
+
else if (c === ")" || c === "}" || c === "]") {
|
|
200
|
+
depth--;
|
|
201
|
+
if (depth === 0) {
|
|
202
|
+
args.push(src.slice(start, i));
|
|
203
|
+
return args;
|
|
204
|
+
}
|
|
205
|
+
} else if (c === "," && depth === 1) {
|
|
206
|
+
args.push(src.slice(start, i));
|
|
207
|
+
start = i + 1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return args;
|
|
211
|
+
}
|
|
212
|
+
function initialStateKeys(src, argStart, argText) {
|
|
213
|
+
const lead = argText.length - argText.trimStart().length;
|
|
214
|
+
let at = argStart + lead;
|
|
215
|
+
let text = argText.trim();
|
|
216
|
+
const lazy = /^\(\s*\)\s*=>\s*\(?\s*/.exec(text);
|
|
217
|
+
if (lazy !== null) {
|
|
218
|
+
at += lazy[0].length;
|
|
219
|
+
text = text.slice(lazy[0].length);
|
|
220
|
+
}
|
|
221
|
+
if (text.startsWith("{")) return objectLiteralKeysAt(src, at) ?? [];
|
|
222
|
+
const ident = /^([A-Za-z_$][\w$]*)\s*\)?\s*$/.exec(text);
|
|
223
|
+
if (ident === null || ident[1] === void 0) return [];
|
|
224
|
+
const decls = [...src.matchAll(new RegExp(`(?:const|let|var)\\s+${ident[1]}\\s*(?::[^=]{1,200})?=\\s*`, "g"))];
|
|
225
|
+
const decl = decls.length === 1 ? decls[0] : void 0;
|
|
226
|
+
if (decl === void 0) return [];
|
|
227
|
+
return objectLiteralKeysAt(src, (decl.index ?? 0) + decl[0].length) ?? [];
|
|
228
|
+
}
|
|
148
229
|
function collectStateKeys(src) {
|
|
149
230
|
const keys = /* @__PURE__ */ new Set();
|
|
150
231
|
const varRe = /const\s*\[\s*(\w+)\s*,\s*(\w+)\s*\]\s*=\s*useState/g;
|
|
151
232
|
for (const m of src.matchAll(varRe)) keys.add(m[1]);
|
|
233
|
+
const contextRe = /const\s*\[\s*(\w+)\s*,\s*\w+\s*\]\s*=\s*useGguiContext\s*(?:<[^>]*>)?\s*\(\s*['"`](\w+)['"`]/g;
|
|
234
|
+
for (const m of src.matchAll(contextRe)) {
|
|
235
|
+
keys.add(m[1]);
|
|
236
|
+
keys.add(m[2]);
|
|
237
|
+
}
|
|
152
238
|
const objRe = /useState(?:<[^>]*>)?\s*\(\s*\{([\s\S]*?)\}\s*\)/g;
|
|
153
239
|
for (const m of src.matchAll(objRe)) {
|
|
154
240
|
const keyRe = /(?:^|,)\s*(\w+)\s*:/g;
|
|
@@ -159,6 +245,16 @@ function collectStateKeys(src) {
|
|
|
159
245
|
const keyRe = /(?:^|,)\s*(\w+)\s*:/g;
|
|
160
246
|
for (const km of m[1].matchAll(keyRe)) keys.add(km[1]);
|
|
161
247
|
}
|
|
248
|
+
for (const m of src.matchAll(/\b(useState|useReducer)\s*(?:<[^>]*>)?\s*\(/g)) {
|
|
249
|
+
const open = (m.index ?? 0) + m[0].length - 1;
|
|
250
|
+
const args = callArgsAt(src, open);
|
|
251
|
+
const which = m[1] === "useReducer" ? 1 : 0;
|
|
252
|
+
const arg = args[which];
|
|
253
|
+
if (arg === void 0) continue;
|
|
254
|
+
let argStart = open + 1;
|
|
255
|
+
for (let k = 0; k < which; k++) argStart += (args[k]?.length ?? 0) + 1;
|
|
256
|
+
for (const key of initialStateKeys(src, argStart, arg)) keys.add(key);
|
|
257
|
+
}
|
|
162
258
|
return keys;
|
|
163
259
|
}
|
|
164
260
|
function mkIssue(subcategory, description, fix, result = "fail") {
|
|
@@ -771,7 +867,7 @@ function runNoHardcodedEntities(input) {
|
|
|
771
867
|
mkIssue(
|
|
772
868
|
"state.merge.no_hardcoded_entities",
|
|
773
869
|
`Hardcoded entity array literal (multiple objects with "${idField}") in the component \u2014 entity data should come from state/props.`,
|
|
774
|
-
`Remove the literal array
|
|
870
|
+
`Remove the literal array: this data comes from ${all.filter((e) => e.idField === idField).map((e) => `props.${e.name}`).join(" / ") || "props"}. Read it there (\`?? []\` for an absent value, never a literal default), seed state from it, and merge updates via stream.`
|
|
775
871
|
)
|
|
776
872
|
);
|
|
777
873
|
}
|