@ggui-ai/ui-gen 0.27.0 → 0.29.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-h4_V69LI.d.ts → adapter-DLQ-5COm.d.ts} +1 -1
- package/dist/adapters/base.js +2 -27
- package/dist/adapters/base.js.map +1 -1
- package/dist/adapters/generation-dispatch.d.ts +14 -6
- package/dist/adapters/generation-dispatch.js +40 -19095
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +25 -3561
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/types.js +2 -9
- package/dist/adapters/types.js.map +1 -1
- package/dist/advanced/index.d.ts +13 -12
- package/dist/advanced/index.js +63 -21789
- package/dist/advanced/index.js.map +1 -1
- package/dist/{bank-Ctdp3FUA.d.ts → bank-LWaiAtaA.d.ts} +1 -1
- package/dist/blueprint-validator.js +6 -2301
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/boilerplate.d.ts +3 -2
- package/dist/boilerplate.js +6 -1867
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +3 -2
- package/dist/check/index.js +6 -1923
- package/dist/check/index.js.map +1 -1
- package/dist/chunk-33B3BAWS.js +24 -0
- package/dist/chunk-33B3BAWS.js.map +1 -0
- package/dist/chunk-3HSGA6NI.js +591 -0
- package/dist/chunk-3HSGA6NI.js.map +1 -0
- package/dist/chunk-3NNNGNTO.js +1707 -0
- package/dist/chunk-3NNNGNTO.js.map +1 -0
- package/dist/chunk-3T2HMTON.js +79 -0
- package/dist/chunk-3T2HMTON.js.map +1 -0
- package/dist/chunk-3ZSSDV3L.js +123 -0
- package/dist/chunk-3ZSSDV3L.js.map +1 -0
- package/dist/chunk-4MBR5GA3.js +99 -0
- package/dist/chunk-4MBR5GA3.js.map +1 -0
- package/dist/chunk-56NJFD55.js +337 -0
- package/dist/chunk-56NJFD55.js.map +1 -0
- package/dist/chunk-5AGTY555.js +26 -0
- package/dist/chunk-5AGTY555.js.map +1 -0
- package/dist/chunk-5EJM7EGY.js +115 -0
- package/dist/chunk-5EJM7EGY.js.map +1 -0
- package/dist/chunk-5KXCQLLR.js +529 -0
- package/dist/chunk-5KXCQLLR.js.map +1 -0
- package/dist/chunk-5VBXHVEH.js +171 -0
- package/dist/chunk-5VBXHVEH.js.map +1 -0
- package/dist/chunk-6KDDEING.js +515 -0
- package/dist/chunk-6KDDEING.js.map +1 -0
- package/dist/chunk-6VDRWAP6.js +123 -0
- package/dist/chunk-6VDRWAP6.js.map +1 -0
- package/dist/chunk-732IBFEJ.js +2400 -0
- package/dist/chunk-732IBFEJ.js.map +1 -0
- package/dist/chunk-73AURS3I.js +46 -0
- package/dist/chunk-73AURS3I.js.map +1 -0
- package/dist/chunk-77H5SKLX.js +8 -0
- package/dist/chunk-77H5SKLX.js.map +1 -0
- package/dist/chunk-7QE3AHLE.js +35 -0
- package/dist/chunk-7QE3AHLE.js.map +1 -0
- package/dist/chunk-A375NNWN.js +11 -0
- package/dist/chunk-A375NNWN.js.map +1 -0
- package/dist/chunk-AOU33EFS.js +140 -0
- package/dist/chunk-AOU33EFS.js.map +1 -0
- package/dist/chunk-BA4QYA6E.js +461 -0
- package/dist/chunk-BA4QYA6E.js.map +1 -0
- package/dist/chunk-DBP764GL.js +3 -0
- package/dist/chunk-DBP764GL.js.map +1 -0
- package/dist/chunk-DUU3ZJDQ.js +41 -0
- package/dist/chunk-DUU3ZJDQ.js.map +1 -0
- package/dist/chunk-DXKRBXNU.js +30 -0
- package/dist/chunk-DXKRBXNU.js.map +1 -0
- package/dist/chunk-FB7OEEAH.js +1467 -0
- package/dist/chunk-FB7OEEAH.js.map +1 -0
- package/dist/chunk-FLRNMZV2.js +18 -0
- package/dist/chunk-FLRNMZV2.js.map +1 -0
- package/dist/chunk-FWJIMKFZ.js +2032 -0
- package/dist/chunk-FWJIMKFZ.js.map +1 -0
- package/dist/chunk-FXRHWYIQ.js +163 -0
- package/dist/chunk-FXRHWYIQ.js.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-GAJI7Y3P.js +13 -0
- package/dist/chunk-GAJI7Y3P.js.map +1 -0
- package/dist/chunk-GYINWMPR.js +2052 -0
- package/dist/chunk-GYINWMPR.js.map +1 -0
- package/dist/chunk-HD6ABIK7.js +484 -0
- package/dist/chunk-HD6ABIK7.js.map +1 -0
- package/dist/chunk-HDQVHYO6.js +100 -0
- package/dist/chunk-HDQVHYO6.js.map +1 -0
- package/dist/chunk-IHUT3SIW.js +7 -0
- package/dist/chunk-IHUT3SIW.js.map +1 -0
- package/dist/chunk-JDH5EGNZ.js +126 -0
- package/dist/chunk-JDH5EGNZ.js.map +1 -0
- package/dist/chunk-JMD4RGSV.js +37 -0
- package/dist/chunk-JMD4RGSV.js.map +1 -0
- package/dist/chunk-KJWGZL5B.js +33 -0
- package/dist/chunk-KJWGZL5B.js.map +1 -0
- package/dist/chunk-MKMDQFZ7.js +86 -0
- package/dist/chunk-MKMDQFZ7.js.map +1 -0
- package/dist/chunk-NF6JUZWF.js +85 -0
- package/dist/chunk-NF6JUZWF.js.map +1 -0
- package/dist/chunk-O2YC6XDC.js +1933 -0
- package/dist/chunk-O2YC6XDC.js.map +1 -0
- package/dist/chunk-OVLH5ICV.js +29 -0
- package/dist/chunk-OVLH5ICV.js.map +1 -0
- package/dist/chunk-PBOYHGSD.js +106 -0
- package/dist/chunk-PBOYHGSD.js.map +1 -0
- package/dist/chunk-PJFH7QWA.js +81 -0
- package/dist/chunk-PJFH7QWA.js.map +1 -0
- package/dist/chunk-PUH4CXGZ.js +284 -0
- package/dist/chunk-PUH4CXGZ.js.map +1 -0
- package/dist/chunk-QLXXPGTV.js +18 -0
- package/dist/chunk-QLXXPGTV.js.map +1 -0
- package/dist/chunk-R5GIGPW2.js +2845 -0
- package/dist/chunk-R5GIGPW2.js.map +1 -0
- package/dist/chunk-RH4IUSTO.js +83 -0
- package/dist/chunk-RH4IUSTO.js.map +1 -0
- package/dist/chunk-S2GVXKKY.js +153 -0
- package/dist/chunk-S2GVXKKY.js.map +1 -0
- package/dist/chunk-TVHGKFJS.js +58 -0
- package/dist/chunk-TVHGKFJS.js.map +1 -0
- package/dist/chunk-U7GALWLG.js +66 -0
- package/dist/chunk-U7GALWLG.js.map +1 -0
- package/dist/chunk-VTC263LT.js +256 -0
- package/dist/chunk-VTC263LT.js.map +1 -0
- package/dist/chunk-WEOXFEVE.js +739 -0
- package/dist/chunk-WEOXFEVE.js.map +1 -0
- package/dist/chunk-WYHP46LT.js +28 -0
- package/dist/chunk-WYHP46LT.js.map +1 -0
- package/dist/chunk-XGLO5LGG.js +274 -0
- package/dist/chunk-XGLO5LGG.js.map +1 -0
- package/dist/chunk-XRBCRKA2.js +29 -0
- package/dist/chunk-XRBCRKA2.js.map +1 -0
- package/dist/chunk-XW7ADFFV.js +340 -0
- package/dist/chunk-XW7ADFFV.js.map +1 -0
- package/dist/chunk-YIQ42IUX.js +34 -0
- package/dist/chunk-YIQ42IUX.js.map +1 -0
- package/dist/chunk-YJZTUY7B.js +101 -0
- package/dist/chunk-YJZTUY7B.js.map +1 -0
- package/dist/chunk-Z3CXME3K.js +107 -0
- package/dist/chunk-Z3CXME3K.js.map +1 -0
- package/dist/classifier/index.js +2 -527
- package/dist/classifier/index.js.map +1 -1
- package/dist/client-JBPCXU7W.js +4 -0
- package/dist/client-JBPCXU7W.js.map +1 -0
- package/dist/compose.js +3 -367
- package/dist/compose.js.map +1 -1
- package/dist/cost-tracker-HHGQ4FTW.js +67 -0
- package/dist/cost-tracker-HHGQ4FTW.js.map +1 -0
- package/dist/{create-ui-generator-BrZHF0cf.d.ts → create-ui-generator-BY-WeaPi.d.ts} +3 -3
- package/dist/{design-mode-DGWN_Gkm.d.ts → design-mode-XyOQmzE0.d.ts} +4 -3
- package/dist/{dispatch-B07TI30d.d.ts → dispatch-8LzTddKw.d.ts} +3 -2
- package/dist/dist-UALN6ZVB.js +543 -0
- package/dist/dist-UALN6ZVB.js.map +1 -0
- package/dist/dupe-break-X6K7QFIS.js +4 -0
- package/dist/dupe-break-X6K7QFIS.js.map +1 -0
- package/dist/evaluation/axis-checks/index.d.ts +5 -4
- package/dist/evaluation/axis-checks/index.js +6 -1818
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +3 -2
- package/dist/evaluation/axis-checks/registry.js +3 -1748
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +49 -132
- package/dist/evaluation/index.js +302 -6368
- package/dist/evaluation/index.js.map +1 -1
- package/dist/evaluation/types.d.ts +3 -2
- package/dist/evaluation/types.js +2 -5
- package/dist/evaluation/types.js.map +1 -1
- package/dist/fragments/index.js +2 -338
- package/dist/fragments/index.js.map +1 -1
- package/dist/{generate-tSO_shQ0.d.ts → generate-DQ4ci90s.d.ts} +1 -1
- package/dist/harness/check/runtime-render/index.d.ts +35 -15
- package/dist/harness/check/runtime-render/index.js +6 -2390
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/check/runtime-render/render-check-worker.js +4 -1739
- package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
- package/dist/harness/index.d.ts +3 -2
- package/dist/harness/index.js +23 -5124
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/llm-trace-sink.js +2 -24
- package/dist/harness/llm-trace-sink.js.map +1 -1
- package/dist/harness/prompts.d.ts +2 -2
- package/dist/harness/prompts.js +8 -324
- package/dist/harness/prompts.js.map +1 -1
- package/dist/harness/result-types.d.ts +18 -6
- package/dist/harness/result-types.js +2 -0
- package/dist/harness/result-types.js.map +1 -1
- package/dist/harness/runtime.d.ts +22 -5
- package/dist/harness/runtime.js +10 -2313
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +3 -2
- package/dist/harness/types-public.js +16 -2954
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +3 -2
- package/dist/harness/validator-trace-sink.js +2 -26
- package/dist/harness/validator-trace-sink.js.map +1 -1
- package/dist/hash.js +2 -39
- package/dist/hash.js.map +1 -1
- package/dist/hashline-5OKREIRM.js +4 -0
- package/dist/hashline-5OKREIRM.js.map +1 -0
- package/dist/index.d.ts +51 -12
- package/dist/index.js +57 -21850
- package/dist/index.js.map +1 -1
- package/dist/llm-evaluator-PN3WFCS4.js +653 -0
- package/dist/llm-evaluator-PN3WFCS4.js.map +1 -0
- package/dist/magic-string.es-2NZTC4GZ.js +1307 -0
- package/dist/magic-string.es-2NZTC4GZ.js.map +1 -0
- package/dist/patch.d.ts +3 -2
- package/dist/patch.js +2 -56
- package/dist/patch.js.map +1 -1
- package/dist/policy-VCYKGSAC.js +5 -0
- package/dist/policy-VCYKGSAC.js.map +1 -0
- package/dist/policy.js +2 -35
- package/dist/policy.js.map +1 -1
- package/dist/primitive-index-2OF6F4TZ.js +131 -0
- package/dist/primitive-index-2OF6F4TZ.js.map +1 -0
- package/dist/primitive-slice-WTMBLYFJ.js +235 -0
- package/dist/primitive-slice-WTMBLYFJ.js.map +1 -0
- package/dist/{prompts-BhNUuRoZ.d.ts → prompts-CLZGywMP.d.ts} +1 -1
- package/dist/provider-adapter-contract.js +10407 -14204
- package/dist/provider-adapter-contract.js.map +1 -1
- package/dist/provider-adapter.js +2 -44
- package/dist/provider-adapter.js.map +1 -1
- package/dist/providers/index.d.ts +89 -1
- package/dist/providers/index.js +115 -44
- package/dist/providers/index.js.map +1 -1
- package/dist/raw-C6KBH5I3.js +141 -0
- package/dist/raw-C6KBH5I3.js.map +1 -0
- package/dist/raw-FXSBXQTZ.js +7 -0
- package/dist/raw-FXSBXQTZ.js.map +1 -0
- package/dist/raw-MURDUPGK.js +8 -0
- package/dist/raw-MURDUPGK.js.map +1 -0
- package/dist/raw-T3GW3UVX.js +8 -0
- package/dist/raw-T3GW3UVX.js.map +1 -0
- package/dist/render-check-host-ZNIS6BJ5.js +5 -0
- package/dist/render-check-host-ZNIS6BJ5.js.map +1 -0
- package/dist/sdk-4JNSDNSR.js +6 -0
- package/dist/sdk-4JNSDNSR.js.map +1 -0
- package/dist/sdk-DIVJMHCX.js +7 -0
- package/dist/sdk-DIVJMHCX.js.map +1 -0
- package/dist/sdk-QRJOCRTS.js +7 -0
- package/dist/sdk-QRJOCRTS.js.map +1 -0
- package/dist/tag-balance-CTHCTRJ7.js +123 -0
- package/dist/tag-balance-CTHCTRJ7.js.map +1 -0
- package/dist/tools/get-primitives-ts.d.ts +1 -1
- package/dist/tools/get-primitives-ts.js +3 -1
- package/dist/tools/get-primitives-ts.js.map +1 -1
- package/dist/tools/render-check-worker.js +3 -40
- package/dist/tools/render-check-worker.js.map +1 -1
- package/dist/{types-public-h8IMnYuh.d.ts → types-public-hYlrerZh.d.ts} +35 -2
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +3 -498
- package/dist/validation/index.js.map +1 -1
- package/dist/{visual-evaluator-C2strxqD.d.ts → visual-evaluator-KskajxD5.d.ts} +14 -4
- package/dist/visual-evaluator-TGEXYQTP.js +12 -0
- package/dist/visual-evaluator-TGEXYQTP.js.map +1 -0
- package/dist/workflows.d.ts +3 -2
- package/dist/workflows.js +2 -151
- package/dist/workflows.js.map +1 -1
- package/package.json +21 -17
- package/src/adapters/claude/sdk.ts +4 -2
- package/src/adapters/claude/tool-bridge.ts +2 -1
- package/src/adapters/generation-dispatch.ts +9 -0
- package/src/adapters/openai/raw.ts +4 -0
- package/src/adapters/openai/sdk.ts +6 -1
- package/src/adapters/openai/tokens.ts +21 -7
- package/src/adapters/provider-router.ts +1 -0
- package/src/adapters/tool-bridge.ts +1 -1
- package/src/adapters/tools.ts +1 -1
- package/src/advanced/feedback.ts +1 -2
- package/src/advanced/generator.ts +4 -3
- package/src/boilerplate/free-design-prompt.ts +7 -0
- package/src/boilerplate/generate.ts +18 -5
- package/src/boilerplate/hard-sections.ts +8 -3
- package/src/boilerplate/react-hooks.ts +56 -0
- package/src/boilerplate/system-prompt.ts +12 -3
- package/src/check/run-tier0.ts +233 -8
- package/src/check/type-checker.ts +128 -16
- package/src/coding-agent/tools.ts +26 -3
- package/src/create-ui-generator.ts +4 -2
- package/src/design-mode.ts +4 -9
- package/src/evaluation/axis-checks/checks/state-merge.ts +3 -5
- package/src/evaluation/axis-checks/checks/state-payload.ts +1 -28
- package/src/evaluation/axis-checks/checks/tint.ts +197 -0
- package/src/evaluation/axis-checks/helpers.ts +246 -0
- package/src/evaluation/axis-checks/registry.ts +2 -0
- package/src/evaluation/criteria/__fixtures__/edge-v2-draw2.json +4629 -0
- package/src/evaluation/criteria/bank.ts +1 -1
- package/src/evaluation/criteria/edge-instruments.ts +14 -0
- package/src/evaluation/criteria/edge-probe-v2.ts +352 -0
- package/src/evaluation/criteria/edge-v2.ts +242 -0
- package/src/evaluation/criteria/resolve.ts +24 -5
- package/src/evaluation/evaluator.ts +2 -2
- package/src/evaluation/index.ts +3 -5
- package/src/evaluation/llm-evaluator.ts +2 -2
- package/src/evaluation/mcp-server.ts +0 -50
- package/src/evaluation/types-public.ts +6 -1
- package/src/evaluation/visual-evaluator.ts +162 -31
- package/src/harness/check/runtime-render/index.ts +28 -4
- package/src/harness/check/runtime-render/render-check.ts +20 -21
- package/src/harness/claude-agent-sdk-loader.ts +93 -0
- package/src/harness/claude-code-login-query.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 +6 -1
- package/src/harness/coding/run-coding-turn.ts +59 -1
- package/src/harness/coding/run-eval-round.ts +9 -0
- package/src/harness/llm-router.ts +50 -2
- package/src/harness/result-types.ts +12 -0
- package/src/harness/runtime.ts +17 -0
- package/src/index.ts +10 -1
- package/src/providers/anthropic-tool-call.ts +263 -0
- package/src/providers/index.ts +13 -0
- package/src/tools/get-primitives-ts.ts +1 -1
- package/src/tools/render-check.ts +4 -4
- package/src/validation/primitives.ts +2 -1
- package/src/evaluation/loop.ts +0 -218
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
import { emitValidatorTraceEvent, truncateSourceForTrace, newValidatorTraceId } from './chunk-WYHP46LT.js';
|
|
2
|
+
import { pickWorkflow } from './chunk-S2GVXKKY.js';
|
|
3
|
+
import { traceAxisChecksSkipped, runGatedAxisChecks } from './chunk-U7GALWLG.js';
|
|
4
|
+
import { buildSystemPrompt, generateBoilerplate } from './chunk-FB7OEEAH.js';
|
|
5
|
+
import { hasProfile } from './chunk-NF6JUZWF.js';
|
|
6
|
+
import { DEFAULT_DESIGN_MODE } from './chunk-3T2HMTON.js';
|
|
7
|
+
import { compose } from './chunk-YIQ42IUX.js';
|
|
8
|
+
import { hashClassification, computeHarnessId, computeHarnessName } from './chunk-DUU3ZJDQ.js';
|
|
9
|
+
import { defaultApplyPatch } from './chunk-TVHGKFJS.js';
|
|
10
|
+
import { DEFAULT_HARNESS_POLICY, isDefaultHarnessPolicy } from './chunk-JMD4RGSV.js';
|
|
11
|
+
import { createHash } from 'crypto';
|
|
12
|
+
|
|
13
|
+
// src/run-workflow.ts
|
|
14
|
+
var noopDefaultRunner = async (task) => task.id;
|
|
15
|
+
async function runWorkflow(input) {
|
|
16
|
+
const { harness, prompt, contract, taskRunners, defaultRunner, initialResults } = input;
|
|
17
|
+
const workflow = harness.process.workflow;
|
|
18
|
+
const startTotal = Date.now();
|
|
19
|
+
const priorResults = { ...initialResults ?? {} };
|
|
20
|
+
const phaseResults = [];
|
|
21
|
+
const runners = taskRunners ?? {};
|
|
22
|
+
const fallback = defaultRunner ?? noopDefaultRunner;
|
|
23
|
+
for (const phase of workflow.phases) {
|
|
24
|
+
const phaseStart = Date.now();
|
|
25
|
+
const ctx = {
|
|
26
|
+
harness,
|
|
27
|
+
priorResults: { ...priorResults },
|
|
28
|
+
classification: harness.classification,
|
|
29
|
+
prompt,
|
|
30
|
+
contract
|
|
31
|
+
};
|
|
32
|
+
const taskPromises = phase.tasks.map(async (task) => {
|
|
33
|
+
const taskStart = Date.now();
|
|
34
|
+
const runner = runners[task.id] ?? fallback;
|
|
35
|
+
const output = await runner(task, ctx);
|
|
36
|
+
return {
|
|
37
|
+
taskId: task.id,
|
|
38
|
+
outputName: task.outputName,
|
|
39
|
+
output,
|
|
40
|
+
durationMs: Date.now() - taskStart
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const taskResults = await Promise.all(taskPromises);
|
|
44
|
+
for (const tr of taskResults) {
|
|
45
|
+
priorResults[tr.outputName] = tr.output;
|
|
46
|
+
}
|
|
47
|
+
phaseResults.push({
|
|
48
|
+
phaseId: phase.id,
|
|
49
|
+
taskResults,
|
|
50
|
+
durationMs: Date.now() - phaseStart
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
workflowId: workflow.id,
|
|
55
|
+
phases: phaseResults,
|
|
56
|
+
results: { ...priorResults },
|
|
57
|
+
durationMs: Date.now() - startTotal
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/run-check.ts
|
|
62
|
+
async function runCheck(input) {
|
|
63
|
+
const { harness, sourceCode, compiledCode, contract, prompt } = input;
|
|
64
|
+
const check = harness.check;
|
|
65
|
+
const startedAt = Date.now();
|
|
66
|
+
if (compiledCode === null) {
|
|
67
|
+
traceAxisChecksSkipped(
|
|
68
|
+
{ sourceCode, contract, originalPrompt: prompt, classification: harness.classification, designMode: harness.designMode },
|
|
69
|
+
"compiledCode null \u2014 no check ran"
|
|
70
|
+
);
|
|
71
|
+
const result2 = {
|
|
72
|
+
issues: [],
|
|
73
|
+
axisIssueCount: 0,
|
|
74
|
+
tierIssueCount: 0,
|
|
75
|
+
llmIssueCount: 0,
|
|
76
|
+
runtimeRenderIssueCount: 0,
|
|
77
|
+
firedCheckIds: []
|
|
78
|
+
};
|
|
79
|
+
const endedAt2 = Date.now();
|
|
80
|
+
emitValidatorTraceEvent({
|
|
81
|
+
id: newValidatorTraceId(),
|
|
82
|
+
at: startedAt,
|
|
83
|
+
endedAt: endedAt2,
|
|
84
|
+
durationMs: endedAt2 - startedAt,
|
|
85
|
+
harnessId: harness.id,
|
|
86
|
+
classification: harness.classification,
|
|
87
|
+
workflowId: harness.process.workflow.id,
|
|
88
|
+
hadCompiledCode: false,
|
|
89
|
+
skippedRuntimeRender: input.skipRuntimeRender ?? false,
|
|
90
|
+
summary: {
|
|
91
|
+
totalIssues: 0,
|
|
92
|
+
axisIssues: 0,
|
|
93
|
+
tierIssues: 0,
|
|
94
|
+
llmIssues: 0,
|
|
95
|
+
runtimeRenderIssues: 0,
|
|
96
|
+
firedCheckIds: []
|
|
97
|
+
},
|
|
98
|
+
issues: [],
|
|
99
|
+
sourceCode: truncateSourceForTrace(sourceCode),
|
|
100
|
+
prompt
|
|
101
|
+
});
|
|
102
|
+
return result2;
|
|
103
|
+
}
|
|
104
|
+
const issues = [];
|
|
105
|
+
const firedIds = [];
|
|
106
|
+
const axisInput = {
|
|
107
|
+
sourceCode,
|
|
108
|
+
compiledCode,
|
|
109
|
+
contract,
|
|
110
|
+
originalPrompt: prompt,
|
|
111
|
+
classification: harness.classification,
|
|
112
|
+
designMode: harness.designMode,
|
|
113
|
+
// ggui#1117: the canvas the harness was built for, when it has one — never a default.
|
|
114
|
+
...harness.canvas !== void 0 ? { canvas: harness.canvas } : {},
|
|
115
|
+
// ggui#1285: the props the probe and judge rendered with — the fixture-echo check reads them.
|
|
116
|
+
...input.fixtureProps !== void 0 ? { fixtureProps: input.fixtureProps } : {}
|
|
117
|
+
};
|
|
118
|
+
const axisRun = runGatedAxisChecks(check.axisChecks, axisInput);
|
|
119
|
+
issues.push(...axisRun.issues);
|
|
120
|
+
firedIds.push(...axisRun.firedIds);
|
|
121
|
+
const axisIssueCount = axisRun.issues.length;
|
|
122
|
+
let tierIssueCount = 0;
|
|
123
|
+
for (const tierCheck of check.tierChecks) {
|
|
124
|
+
firedIds.push(tierCheck.id);
|
|
125
|
+
const tierIssues = await tierCheck.run({ sourceCode, compiledCode });
|
|
126
|
+
issues.push(...tierIssues);
|
|
127
|
+
tierIssueCount += tierIssues.length;
|
|
128
|
+
}
|
|
129
|
+
let runtimeRenderIssueCount = 0;
|
|
130
|
+
if (check.runtimeRender && !input.skipRuntimeRender) {
|
|
131
|
+
const cheapTier0Failures = issues.filter(
|
|
132
|
+
(i) => i.result === "fail" && (i.tier === 0 || i.tier === void 0)
|
|
133
|
+
).length;
|
|
134
|
+
if (cheapTier0Failures === 0) {
|
|
135
|
+
const outcome = await check.runtimeRender.run({
|
|
136
|
+
sourceCode,
|
|
137
|
+
compiledCode,
|
|
138
|
+
contract,
|
|
139
|
+
fixtureProps: input.fixtureProps
|
|
140
|
+
});
|
|
141
|
+
if (outcome.status === "ran") {
|
|
142
|
+
firedIds.push(check.runtimeRender.id);
|
|
143
|
+
issues.push(...outcome.issues);
|
|
144
|
+
runtimeRenderIssueCount = outcome.issues.length;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let llmIssueCount = 0;
|
|
149
|
+
if (check.llmEvaluator && contract) {
|
|
150
|
+
firedIds.push(check.llmEvaluator.id);
|
|
151
|
+
const llmIssues = await check.llmEvaluator.run({
|
|
152
|
+
sourceCode,
|
|
153
|
+
compiledCode,
|
|
154
|
+
contract,
|
|
155
|
+
prompt
|
|
156
|
+
});
|
|
157
|
+
issues.push(...llmIssues);
|
|
158
|
+
llmIssueCount = llmIssues.length;
|
|
159
|
+
}
|
|
160
|
+
const result = {
|
|
161
|
+
issues,
|
|
162
|
+
axisIssueCount,
|
|
163
|
+
tierIssueCount,
|
|
164
|
+
llmIssueCount,
|
|
165
|
+
runtimeRenderIssueCount,
|
|
166
|
+
firedCheckIds: firedIds
|
|
167
|
+
};
|
|
168
|
+
const endedAt = Date.now();
|
|
169
|
+
emitValidatorTraceEvent({
|
|
170
|
+
id: newValidatorTraceId(),
|
|
171
|
+
at: startedAt,
|
|
172
|
+
endedAt,
|
|
173
|
+
durationMs: endedAt - startedAt,
|
|
174
|
+
harnessId: harness.id,
|
|
175
|
+
classification: harness.classification,
|
|
176
|
+
workflowId: harness.process.workflow.id,
|
|
177
|
+
hadCompiledCode: true,
|
|
178
|
+
skippedRuntimeRender: input.skipRuntimeRender ?? false,
|
|
179
|
+
summary: {
|
|
180
|
+
totalIssues: issues.length,
|
|
181
|
+
axisIssues: axisIssueCount,
|
|
182
|
+
tierIssues: tierIssueCount,
|
|
183
|
+
llmIssues: llmIssueCount,
|
|
184
|
+
runtimeRenderIssues: runtimeRenderIssueCount,
|
|
185
|
+
firedCheckIds: firedIds
|
|
186
|
+
},
|
|
187
|
+
issues,
|
|
188
|
+
sourceCode: truncateSourceForTrace(sourceCode),
|
|
189
|
+
prompt
|
|
190
|
+
});
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/run-harness.ts
|
|
195
|
+
var defaultPasses = (r) => r.issues.every((i) => i.result !== "fail");
|
|
196
|
+
async function runHarness(input) {
|
|
197
|
+
const {
|
|
198
|
+
harness: initialHarness,
|
|
199
|
+
prompt,
|
|
200
|
+
contract,
|
|
201
|
+
taskRunners,
|
|
202
|
+
compile,
|
|
203
|
+
passes = defaultPasses,
|
|
204
|
+
maxIterations: explicitMax,
|
|
205
|
+
skipCheck = false
|
|
206
|
+
} = input;
|
|
207
|
+
const maxIterations = explicitMax ?? initialHarness.process.retry.maxIterations;
|
|
208
|
+
const start = Date.now();
|
|
209
|
+
const iterations = [];
|
|
210
|
+
let harness = initialHarness;
|
|
211
|
+
let lastSource = null;
|
|
212
|
+
let lastCompiled = null;
|
|
213
|
+
let lastCheck = null;
|
|
214
|
+
for (let i = 1; i <= maxIterations; i++) {
|
|
215
|
+
const workflowResult = await runWorkflow({
|
|
216
|
+
harness,
|
|
217
|
+
prompt,
|
|
218
|
+
contract,
|
|
219
|
+
taskRunners
|
|
220
|
+
});
|
|
221
|
+
const source = workflowResult.results.source ?? null;
|
|
222
|
+
let compiled = null;
|
|
223
|
+
if (source && compile) {
|
|
224
|
+
compiled = await compile(source);
|
|
225
|
+
} else if (source && !compile) {
|
|
226
|
+
compiled = source;
|
|
227
|
+
}
|
|
228
|
+
const compileFailed = source !== null && compile !== void 0 && compiled === null;
|
|
229
|
+
const checkStart = Date.now();
|
|
230
|
+
const checkResult = source && !compileFailed && !skipCheck ? await runCheck({ harness, sourceCode: source, compiledCode: compiled, contract, prompt }) : { issues: [], axisIssueCount: 0, tierIssueCount: 0, llmIssueCount: 0, runtimeRenderIssueCount: 0, firedCheckIds: [] };
|
|
231
|
+
const checkDurationMs = Date.now() - checkStart;
|
|
232
|
+
iterations.push({
|
|
233
|
+
iteration: i,
|
|
234
|
+
harnessId: harness.id,
|
|
235
|
+
workflowId: harness.process.workflow.id,
|
|
236
|
+
source,
|
|
237
|
+
compiled,
|
|
238
|
+
workflowDurationMs: workflowResult.durationMs,
|
|
239
|
+
checkDurationMs,
|
|
240
|
+
issueCount: checkResult.issues.length,
|
|
241
|
+
firedCheckIds: checkResult.firedCheckIds
|
|
242
|
+
});
|
|
243
|
+
lastSource = source;
|
|
244
|
+
lastCompiled = compiled;
|
|
245
|
+
lastCheck = checkResult;
|
|
246
|
+
if (!source) {
|
|
247
|
+
return buildResult({
|
|
248
|
+
ok: false,
|
|
249
|
+
reason: "no-source",
|
|
250
|
+
finalHarness: harness,
|
|
251
|
+
finalSource: null,
|
|
252
|
+
finalCompiled: null,
|
|
253
|
+
finalCheck: checkResult,
|
|
254
|
+
iterations,
|
|
255
|
+
start
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
if (compileFailed) {
|
|
259
|
+
return buildResult({
|
|
260
|
+
ok: false,
|
|
261
|
+
reason: "compile-failed",
|
|
262
|
+
finalHarness: harness,
|
|
263
|
+
finalSource: source,
|
|
264
|
+
finalCompiled: null,
|
|
265
|
+
finalCheck: checkResult,
|
|
266
|
+
iterations,
|
|
267
|
+
start
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (passes(checkResult)) {
|
|
271
|
+
return buildResult({
|
|
272
|
+
ok: true,
|
|
273
|
+
reason: "passed",
|
|
274
|
+
finalHarness: harness,
|
|
275
|
+
finalSource: source,
|
|
276
|
+
finalCompiled: compiled,
|
|
277
|
+
finalCheck: checkResult,
|
|
278
|
+
iterations,
|
|
279
|
+
start
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (i < maxIterations) {
|
|
283
|
+
harness = harness.derive({});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return buildResult({
|
|
287
|
+
ok: false,
|
|
288
|
+
reason: "max-iterations",
|
|
289
|
+
finalHarness: harness,
|
|
290
|
+
finalSource: lastSource,
|
|
291
|
+
finalCompiled: lastCompiled,
|
|
292
|
+
finalCheck: lastCheck,
|
|
293
|
+
iterations,
|
|
294
|
+
start
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function buildResult(args) {
|
|
298
|
+
return {
|
|
299
|
+
ok: args.ok,
|
|
300
|
+
reason: args.reason,
|
|
301
|
+
finalHarness: args.finalHarness,
|
|
302
|
+
finalSource: args.finalSource,
|
|
303
|
+
finalCompiled: args.finalCompiled,
|
|
304
|
+
finalCheck: args.finalCheck,
|
|
305
|
+
iterations: args.iterations,
|
|
306
|
+
durationMs: Date.now() - args.start
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/tools.ts
|
|
311
|
+
var APPLY_CHANGES_TOOL = {
|
|
312
|
+
name: "apply_changes",
|
|
313
|
+
description: "Surgical edit: replace line ranges in ui.tsx with new code. Use line numbers from the Current File (shown as N\u2502). Preferred for targeted changes \u2014 fixing one hook, renaming a prop, swapping a component, closing a missing tag. The patch is ALWAYS applied to the workspace even if the resulting file has syntax errors \u2014 the error location is returned as guidance so you can iterate. If the file is in a tangled state and patches aren't converging cleanly, use `write` to rewrite from scratch.",
|
|
314
|
+
parameters: {
|
|
315
|
+
type: "object",
|
|
316
|
+
properties: {
|
|
317
|
+
changes: {
|
|
318
|
+
type: "array",
|
|
319
|
+
description: "Array of changes. Each replaces lines startLine through endLine (inclusive) with the new code lines. Applied bottom-to-top to preserve line numbers.",
|
|
320
|
+
items: {
|
|
321
|
+
type: "object",
|
|
322
|
+
properties: {
|
|
323
|
+
startLine: {
|
|
324
|
+
type: "number",
|
|
325
|
+
description: "First line to replace (from the N\u2502 numbers in Current File)"
|
|
326
|
+
},
|
|
327
|
+
endLine: { type: "number", description: "Last line to replace (inclusive)" },
|
|
328
|
+
code: {
|
|
329
|
+
type: "array",
|
|
330
|
+
items: { type: "string" },
|
|
331
|
+
description: "New code lines. One source line per array element. Avoid embedding newlines inside an element. For long JSX blocks, split at statement boundaries across multiple changes."
|
|
332
|
+
},
|
|
333
|
+
description: { type: "string", description: "What this change does (< 10 words)" }
|
|
334
|
+
},
|
|
335
|
+
required: ["startLine", "endLine", "code", "description"]
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
commit_message: { type: "string", description: "Short summary of all changes" },
|
|
339
|
+
allowBroken: {
|
|
340
|
+
type: "boolean",
|
|
341
|
+
description: "Opt-in: commit the patch even if the resulting file fails syntax preflight. Use when you want to iterate across multiple turns and accept a broken intermediate state (e.g., split a big JSX refactor into 2 patches). Default false (strict preflight)."
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
required: ["changes", "commit_message"]
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var APPLY_CHANGES_TOOL_SCOPED = {
|
|
348
|
+
name: "apply_changes",
|
|
349
|
+
description: "Replace ONE small line range in ui.tsx. Narrow schema for transport-error recovery: emit a single change covering at most 20 lines.",
|
|
350
|
+
parameters: {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
changes: {
|
|
354
|
+
type: "array",
|
|
355
|
+
minItems: 1,
|
|
356
|
+
maxItems: 1,
|
|
357
|
+
description: "Single change. endLine - startLine \u2264 20.",
|
|
358
|
+
items: {
|
|
359
|
+
type: "object",
|
|
360
|
+
properties: {
|
|
361
|
+
startLine: { type: "number", description: "First line to replace" },
|
|
362
|
+
endLine: {
|
|
363
|
+
type: "number",
|
|
364
|
+
description: "Last line (inclusive). Keep endLine - startLine \u2264 20."
|
|
365
|
+
},
|
|
366
|
+
code: {
|
|
367
|
+
type: "array",
|
|
368
|
+
items: { type: "string" },
|
|
369
|
+
description: "New code lines (one source line per element, no embedded newlines). \u2264 20 elements."
|
|
370
|
+
},
|
|
371
|
+
description: { type: "string", description: "What this change does (< 10 words)" }
|
|
372
|
+
},
|
|
373
|
+
required: ["startLine", "endLine", "code", "description"]
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
commit_message: { type: "string", description: "Short summary" }
|
|
377
|
+
},
|
|
378
|
+
required: ["changes", "commit_message"]
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var APPLY_CHANGES_HASHLINE_TOOL = {
|
|
382
|
+
name: "apply_changes",
|
|
383
|
+
description: "Surgical edit with line-hash verification. Replace line ranges in ui.tsx. Line refs use the format `N:hh` from the Current File block (e.g., `47:a3`) \u2014 the 2-char hash anchors your view so the edit is rejected if the file drifted under you. Always use the exact hashes shown in the latest Current File view. The patch is applied even if the resulting file has syntax errors (the error location is returned as guidance); but edits with mismatched hashes are rejected BEFORE apply.",
|
|
384
|
+
parameters: {
|
|
385
|
+
type: "object",
|
|
386
|
+
properties: {
|
|
387
|
+
changes: {
|
|
388
|
+
type: "array",
|
|
389
|
+
description: "Array of changes. Each replaces `startLine` through `endLine` (inclusive) with the new code lines. Line refs use the `N:hh` format.",
|
|
390
|
+
items: {
|
|
391
|
+
type: "object",
|
|
392
|
+
properties: {
|
|
393
|
+
startLine: {
|
|
394
|
+
type: "string",
|
|
395
|
+
pattern: "^\\d+:[0-9a-f]{2}$",
|
|
396
|
+
description: "First line to replace, as `N:hh` (e.g., `47:a3`). The hash MUST match the line's hash in the latest Current File view. Format is line-number, colon, 2 lowercase hex chars \u2014 enforced by JSON schema pattern."
|
|
397
|
+
},
|
|
398
|
+
endLine: {
|
|
399
|
+
type: "string",
|
|
400
|
+
pattern: "^\\d+:[0-9a-f]{2}$",
|
|
401
|
+
description: "Last line to replace, as `N:hh` (e.g., `83:b1`). Hash MUST match. Format: line-number, colon, 2 lowercase hex chars."
|
|
402
|
+
},
|
|
403
|
+
code: {
|
|
404
|
+
type: "array",
|
|
405
|
+
items: { type: "string" },
|
|
406
|
+
description: "New code lines. One source line per array element. No embedded newlines."
|
|
407
|
+
},
|
|
408
|
+
description: { type: "string", description: "What this change does (< 10 words)" }
|
|
409
|
+
},
|
|
410
|
+
required: ["startLine", "endLine", "code", "description"]
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
commit_message: { type: "string", description: "Short summary of all changes" }
|
|
414
|
+
},
|
|
415
|
+
required: ["changes", "commit_message"]
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var APPLY_CHANGES_TOOL_FLAT = {
|
|
419
|
+
name: "apply_changes",
|
|
420
|
+
description: "Surgical edit: replace line ranges in ui.tsx with new code. Use line numbers from the Current File (shown as N\u2502). Preferred for targeted changes. The `code` field is a single string with newlines (`\\n`) between lines. The patch is ALWAYS applied even if the resulting file has syntax errors \u2014 the error is returned as guidance. For a full rewrite, use `rewrite`.",
|
|
421
|
+
parameters: {
|
|
422
|
+
type: "object",
|
|
423
|
+
properties: {
|
|
424
|
+
changes: {
|
|
425
|
+
type: "array",
|
|
426
|
+
description: "Array of changes. Each replaces lines startLine through endLine (inclusive). Applied bottom-to-top.",
|
|
427
|
+
items: {
|
|
428
|
+
type: "object",
|
|
429
|
+
properties: {
|
|
430
|
+
startLine: {
|
|
431
|
+
type: "number",
|
|
432
|
+
description: "First line to replace (from the N\u2502 numbers in Current File)"
|
|
433
|
+
},
|
|
434
|
+
endLine: { type: "number", description: "Last line to replace (inclusive)" },
|
|
435
|
+
code: {
|
|
436
|
+
type: "string",
|
|
437
|
+
description: "New code as a single string. Separate lines with `\\n`. Preserve leading indentation inside the string."
|
|
438
|
+
},
|
|
439
|
+
description: { type: "string", description: "What this change does (< 10 words)" }
|
|
440
|
+
},
|
|
441
|
+
required: ["startLine", "endLine", "code", "description"]
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
commit_message: { type: "string", description: "Short summary of all changes" },
|
|
445
|
+
allowBroken: {
|
|
446
|
+
type: "boolean",
|
|
447
|
+
description: "Opt-in: commit the patch even if the resulting file fails syntax preflight."
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
required: ["changes", "commit_message"]
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
var APPLY_CHANGES_HASHLINE_TOOL_FLAT = {
|
|
454
|
+
name: "apply_changes",
|
|
455
|
+
description: "Surgical edit with line-hash verification. Replace line ranges in ui.tsx using `N:hh` references from the Current File (e.g. `47:a3`). The `code` field is a single string with newlines between lines. Edits with mismatched hashes are rejected before apply.",
|
|
456
|
+
parameters: {
|
|
457
|
+
type: "object",
|
|
458
|
+
properties: {
|
|
459
|
+
changes: {
|
|
460
|
+
type: "array",
|
|
461
|
+
description: "Array of changes. Line refs use `N:hh` format.",
|
|
462
|
+
items: {
|
|
463
|
+
type: "object",
|
|
464
|
+
properties: {
|
|
465
|
+
startLine: {
|
|
466
|
+
type: "string",
|
|
467
|
+
pattern: "^\\d+:[0-9a-f]{2}$",
|
|
468
|
+
description: "First line to replace, as `N:hh` (e.g., `47:a3`). Hash MUST match the latest Current File view. Format: line-number, colon, 2 lowercase hex chars."
|
|
469
|
+
},
|
|
470
|
+
endLine: {
|
|
471
|
+
type: "string",
|
|
472
|
+
pattern: "^\\d+:[0-9a-f]{2}$",
|
|
473
|
+
description: "Last line to replace, as `N:hh` (e.g., `83:b1`). Hash MUST match."
|
|
474
|
+
},
|
|
475
|
+
code: {
|
|
476
|
+
type: "string",
|
|
477
|
+
description: "New code as a single string. Separate lines with `\\n`. Preserve leading indentation."
|
|
478
|
+
},
|
|
479
|
+
description: { type: "string", description: "What this change does (< 10 words)" }
|
|
480
|
+
},
|
|
481
|
+
required: ["startLine", "endLine", "code", "description"]
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
commit_message: { type: "string", description: "Short summary of all changes" }
|
|
485
|
+
},
|
|
486
|
+
required: ["changes", "commit_message"]
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
var ICON_LIST_NO_MATCH_GUIDANCE = "This list is complete and constant \u2014 calling again returns exactly it. If the name you wanted is not here, pick the nearest listed name (or a neutral one such as `circle`) and continue with apply_changes; never call this tool twice.";
|
|
490
|
+
var GET_ICONS_TOOL = {
|
|
491
|
+
name: "get_available_icons",
|
|
492
|
+
description: 'List every Lucide icon name the <Icon name="..."> component renders (kebab-case). A name outside this list renders nothing \u2014 check before choosing. ' + ICON_LIST_NO_MATCH_GUIDANCE,
|
|
493
|
+
parameters: { type: "object", properties: {} }
|
|
494
|
+
};
|
|
495
|
+
var GET_COMPONENTS_INFO_TOOL = {
|
|
496
|
+
name: "get_components_info",
|
|
497
|
+
description: "Fetch full prop API + example + variant mappings for one or more design-system components. Use when the compact index doesn't give you enough detail to write correct JSX (e.g., you need to know the exact prop values for `variant` or the shape of an options array). Batch names in one call \u2014 cheaper than multiple fetches.",
|
|
498
|
+
parameters: {
|
|
499
|
+
type: "object",
|
|
500
|
+
properties: {
|
|
501
|
+
names: {
|
|
502
|
+
type: "array",
|
|
503
|
+
items: { type: "string" },
|
|
504
|
+
description: "Component names to fetch (e.g., ['Card', 'Stack', 'Input']). Names must match the index entries exactly."
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
required: ["names"]
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var WRITE_PLAN_TOOL = {
|
|
511
|
+
name: "write_plan",
|
|
512
|
+
description: "Commit to a concrete plan before writing code. Produce a short structured outline: which components you'll use, rough JSX structure, and wiring (state/actions/streams). After this call, on the next turn you'll be able to write code with `apply_changes`. Keep it brief \u2014 this is a commitment, not a design doc.",
|
|
513
|
+
parameters: {
|
|
514
|
+
type: "object",
|
|
515
|
+
properties: {
|
|
516
|
+
components: {
|
|
517
|
+
type: "array",
|
|
518
|
+
items: { type: "string" },
|
|
519
|
+
description: "Primitive/component names you'll use in the final JSX (e.g., ['Card', 'Stack', 'Input', 'Button'])."
|
|
520
|
+
},
|
|
521
|
+
structure: {
|
|
522
|
+
type: "string",
|
|
523
|
+
description: "Brief JSX structure outline \u2014 a few lines of pseudocode showing nesting. Example: 'Card > Stack > [Heading, Input x3, Button].'"
|
|
524
|
+
},
|
|
525
|
+
wiring: {
|
|
526
|
+
type: "string",
|
|
527
|
+
description: "Brief note on state/actions/streams you'll wire. Example: 'useState for form payload; invokeAction(submit) on Button click.'"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
required: ["components", "structure", "wiring"]
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
var REWRITE_TOOL = {
|
|
534
|
+
name: "rewrite",
|
|
535
|
+
description: "Escape hatch: rewrite the entire ui.tsx file in one call. Use only when surgical `apply_changes` patches have accumulated into a tangled broken state and you need to reset the file to a clean implementation. Single-string payload; auto-compiles + validates. Prefer `apply_changes` for normal edits.",
|
|
536
|
+
parameters: {
|
|
537
|
+
type: "object",
|
|
538
|
+
properties: {
|
|
539
|
+
code: {
|
|
540
|
+
type: "string",
|
|
541
|
+
description: "Complete TSX component source \u2014 the whole file."
|
|
542
|
+
},
|
|
543
|
+
commit_message: {
|
|
544
|
+
type: "string",
|
|
545
|
+
description: "Short description (< 10 words)"
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
required: ["code", "commit_message"]
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// src/harness-tool-names.ts
|
|
553
|
+
var HARNESS_CODING_TOOLS = [APPLY_CHANGES_TOOL];
|
|
554
|
+
var HARNESS_SCOPED_TOOLS = [APPLY_CHANGES_TOOL_SCOPED];
|
|
555
|
+
function harnessToolEntry(def) {
|
|
556
|
+
return `${def.name}@${createHash("sha256").update(JSON.stringify(def), "utf8").digest("hex").slice(0, 8)}`;
|
|
557
|
+
}
|
|
558
|
+
function harnessToolNames(designMode) {
|
|
559
|
+
return [...new Set([...HARNESS_CODING_TOOLS, ...HARNESS_SCOPED_TOOLS].map(harnessToolEntry))].sort();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/create-harness.ts
|
|
563
|
+
var HARNESS_VERSION = "harness@1";
|
|
564
|
+
var HOW_VERSION = "how@1";
|
|
565
|
+
var WHAT_VERSION = "what@1";
|
|
566
|
+
var CHECK_VERSION = "check@1";
|
|
567
|
+
var PROCESS_VERSION = "process@1";
|
|
568
|
+
var defaultPatchFn = defaultApplyPatch;
|
|
569
|
+
function applyLegOverride(base, ovr, ctx) {
|
|
570
|
+
if (!ovr) return base;
|
|
571
|
+
if (typeof ovr === "function") return ovr(base, ctx);
|
|
572
|
+
return { ...base, ...ovr };
|
|
573
|
+
}
|
|
574
|
+
function countCacheTiers(fragments) {
|
|
575
|
+
const counts = { stable: 0, axisDelta: 0, volatile: 0 };
|
|
576
|
+
for (const f of fragments) counts[f.cacheTier]++;
|
|
577
|
+
return counts;
|
|
578
|
+
}
|
|
579
|
+
function createHarness(input) {
|
|
580
|
+
const { classification, contract, prompt, shellType, screen, overrides } = input;
|
|
581
|
+
const ctx = { classification, contract, prompt };
|
|
582
|
+
const designMode = input.designMode ?? DEFAULT_DESIGN_MODE;
|
|
583
|
+
const composed = compose(classification);
|
|
584
|
+
const systemPromptBuilder = input.systemPromptBuilder ?? buildSystemPrompt;
|
|
585
|
+
const systemPrompt = systemPromptBuilder({
|
|
586
|
+
userRequest: prompt,
|
|
587
|
+
shellType,
|
|
588
|
+
screen,
|
|
589
|
+
axisDelta: composed.promptText,
|
|
590
|
+
designMode,
|
|
591
|
+
...input.canvas !== void 0 ? { canvas: input.canvas } : {},
|
|
592
|
+
...input.profile !== void 0 ? { profile: input.profile } : {}
|
|
593
|
+
});
|
|
594
|
+
const howFragments = composed.fragments.filter(
|
|
595
|
+
(f) => f.promptText && f.promptText.trim().length > 0
|
|
596
|
+
);
|
|
597
|
+
const baseHow = {
|
|
598
|
+
systemPrompt,
|
|
599
|
+
implPrompt: "",
|
|
600
|
+
fragments: howFragments,
|
|
601
|
+
version: HOW_VERSION
|
|
602
|
+
};
|
|
603
|
+
const how = applyLegOverride(baseHow, overrides?.how, ctx);
|
|
604
|
+
const boilerplate = generateBoilerplate(
|
|
605
|
+
prompt,
|
|
606
|
+
contract,
|
|
607
|
+
shellType,
|
|
608
|
+
screen,
|
|
609
|
+
composed.boilerplateSections,
|
|
610
|
+
input.appGadgets,
|
|
611
|
+
designMode
|
|
612
|
+
);
|
|
613
|
+
const whatFragments = composed.fragments.filter(
|
|
614
|
+
(f) => f.boilerplateMarker && f.boilerplateMarker.trim().length > 0
|
|
615
|
+
);
|
|
616
|
+
const baseWhat = {
|
|
617
|
+
boilerplate,
|
|
618
|
+
fragments: whatFragments,
|
|
619
|
+
codingTools: [...HARNESS_CODING_TOOLS],
|
|
620
|
+
scopedTools: [...HARNESS_SCOPED_TOOLS],
|
|
621
|
+
applyPatch: defaultPatchFn,
|
|
622
|
+
// Registered gadget catalog — drives the system prompt's gadget
|
|
623
|
+
// table + the boilerplate's direct-import emission. Omitted when no
|
|
624
|
+
// gadgets registered.
|
|
625
|
+
...input.appGadgets !== void 0 ? { appGadgets: input.appGadgets } : {},
|
|
626
|
+
// Third-party wrapper `.d.ts` map — autoCommit's typecheck overlays
|
|
627
|
+
// the real wrapper declarations so a generated direct gadget import
|
|
628
|
+
// gets strict hook types.
|
|
629
|
+
...input.gadgetTypes !== void 0 ? { gadgetTypes: input.gadgetTypes } : {},
|
|
630
|
+
version: WHAT_VERSION
|
|
631
|
+
};
|
|
632
|
+
const what = applyLegOverride(baseWhat, overrides?.what, ctx);
|
|
633
|
+
const axisChecks = input.axisChecks ?? [];
|
|
634
|
+
const baseCheck = {
|
|
635
|
+
axisChecks,
|
|
636
|
+
tierChecks: [],
|
|
637
|
+
runtimeRender: input.runtimeRender,
|
|
638
|
+
llmEvaluator: void 0,
|
|
639
|
+
version: CHECK_VERSION
|
|
640
|
+
};
|
|
641
|
+
const check = applyLegOverride(baseCheck, overrides?.check, ctx);
|
|
642
|
+
const policy = input.policy ?? DEFAULT_HARNESS_POLICY;
|
|
643
|
+
const workflow = pickWorkflow(classification);
|
|
644
|
+
const baseProcess = {
|
|
645
|
+
mode: policy.processMode ?? "single_pass",
|
|
646
|
+
workflow,
|
|
647
|
+
planner: void 0,
|
|
648
|
+
retry: { maxIterations: 30 },
|
|
649
|
+
version: PROCESS_VERSION
|
|
650
|
+
};
|
|
651
|
+
const processLeg = applyLegOverride(baseProcess, overrides?.process, ctx);
|
|
652
|
+
const classificationHash = hashClassification(classification);
|
|
653
|
+
const fragmentIds = composed.fragments.map((f) => `${f.axis}=${f.value}`);
|
|
654
|
+
const cacheTierBreakdown = countCacheTiers(composed.fragments);
|
|
655
|
+
const overrideLabels = [];
|
|
656
|
+
if (overrides?.how) overrideLabels.push("how");
|
|
657
|
+
if (overrides?.what) overrideLabels.push("what");
|
|
658
|
+
if (overrides?.check) overrideLabels.push("check");
|
|
659
|
+
if (overrides?.process) overrideLabels.push("process");
|
|
660
|
+
if (overrides?.label) overrideLabels.push(`label:${overrides.label}`);
|
|
661
|
+
if (!isDefaultHarnessPolicy(policy)) overrideLabels.push("policy");
|
|
662
|
+
if (designMode !== DEFAULT_DESIGN_MODE) overrideLabels.push(`designMode:${designMode}`);
|
|
663
|
+
if (hasProfile(input.profile)) overrideLabels.push("profile");
|
|
664
|
+
const id = computeHarnessId({
|
|
665
|
+
classificationHash,
|
|
666
|
+
howVersion: how.version,
|
|
667
|
+
whatVersion: what.version,
|
|
668
|
+
checkVersion: check.version,
|
|
669
|
+
processVersion: processLeg.version,
|
|
670
|
+
workflowId: workflow.id,
|
|
671
|
+
fragmentIds,
|
|
672
|
+
overrides: overrideLabels
|
|
673
|
+
});
|
|
674
|
+
const name = computeHarnessName({
|
|
675
|
+
classification,
|
|
676
|
+
workflowName: workflow.name,
|
|
677
|
+
version: HARNESS_VERSION
|
|
678
|
+
});
|
|
679
|
+
const meta = {
|
|
680
|
+
classificationHash,
|
|
681
|
+
fragmentIds,
|
|
682
|
+
cacheTierBreakdown,
|
|
683
|
+
overrides: overrideLabels,
|
|
684
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
685
|
+
harnessVersion: HARNESS_VERSION
|
|
686
|
+
};
|
|
687
|
+
const harness = {
|
|
688
|
+
id,
|
|
689
|
+
name,
|
|
690
|
+
classification,
|
|
691
|
+
designMode,
|
|
692
|
+
...input.canvas !== void 0 ? { canvas: input.canvas } : {},
|
|
693
|
+
...input.profile !== void 0 ? { profile: input.profile } : {},
|
|
694
|
+
how,
|
|
695
|
+
what,
|
|
696
|
+
check,
|
|
697
|
+
process: processLeg,
|
|
698
|
+
policy,
|
|
699
|
+
meta,
|
|
700
|
+
derive(revision) {
|
|
701
|
+
return deriveHarness(this, revision, input);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
return harness;
|
|
705
|
+
}
|
|
706
|
+
function deriveHarness(base, revision, originalInput) {
|
|
707
|
+
let mergedOverrides = {
|
|
708
|
+
...originalInput.overrides,
|
|
709
|
+
...revision.overrides ?? {}
|
|
710
|
+
};
|
|
711
|
+
if (revision.workflow) {
|
|
712
|
+
const currentProcessOverride = mergedOverrides.process;
|
|
713
|
+
const processBuilder = (baseProcess, ctx) => {
|
|
714
|
+
const withOverride = typeof currentProcessOverride === "function" ? currentProcessOverride(baseProcess, ctx) : { ...baseProcess, ...currentProcessOverride ?? {} };
|
|
715
|
+
return { ...withOverride, workflow: revision.workflow };
|
|
716
|
+
};
|
|
717
|
+
mergedOverrides = { ...mergedOverrides, process: processBuilder };
|
|
718
|
+
}
|
|
719
|
+
if (revision.useFallbackTools) {
|
|
720
|
+
const currentWhatOverride = mergedOverrides.what;
|
|
721
|
+
const whatBuilder = (baseWhat, ctx) => {
|
|
722
|
+
const withOverride = typeof currentWhatOverride === "function" ? currentWhatOverride(baseWhat, ctx) : { ...baseWhat, ...currentWhatOverride ?? {} };
|
|
723
|
+
if (withOverride.scopedTools && withOverride.scopedTools.length > 0) {
|
|
724
|
+
return { ...withOverride, codingTools: withOverride.scopedTools };
|
|
725
|
+
}
|
|
726
|
+
return withOverride;
|
|
727
|
+
};
|
|
728
|
+
mergedOverrides = { ...mergedOverrides, what: whatBuilder };
|
|
729
|
+
}
|
|
730
|
+
return createHarness({
|
|
731
|
+
...originalInput,
|
|
732
|
+
classification: revision.classification ?? base.classification,
|
|
733
|
+
overrides: mergedOverrides
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export { APPLY_CHANGES_HASHLINE_TOOL, APPLY_CHANGES_HASHLINE_TOOL_FLAT, APPLY_CHANGES_TOOL, APPLY_CHANGES_TOOL_FLAT, APPLY_CHANGES_TOOL_SCOPED, GET_COMPONENTS_INFO_TOOL, GET_ICONS_TOOL, HARNESS_CODING_TOOLS, HARNESS_SCOPED_TOOLS, ICON_LIST_NO_MATCH_GUIDANCE, REWRITE_TOOL, WRITE_PLAN_TOOL, createHarness, harnessToolEntry, harnessToolNames, runCheck, runHarness, runWorkflow };
|
|
738
|
+
//# sourceMappingURL=chunk-WEOXFEVE.js.map
|
|
739
|
+
//# sourceMappingURL=chunk-WEOXFEVE.js.map
|