ui-gateway 0.1.1 → 0.1.2
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/AGENTS.md +41 -6
- package/BENCHMARK.md +141 -0
- package/CHANGELOG.md +200 -2
- package/CONTRIBUTING.md +48 -6
- package/NON-GOALS.md +9 -6
- package/README.md +136 -41
- package/SECURITY.md +22 -1
- package/SKILL.md +71 -17
- package/action.yml +90 -0
- package/dist/evals/src/baseline.d.ts +4 -1
- package/dist/evals/src/baseline.d.ts.map +1 -1
- package/dist/evals/src/baseline.js +28 -6
- package/dist/evals/src/baseline.js.map +1 -1
- package/dist/evals/src/metrics.d.ts +35 -0
- package/dist/evals/src/metrics.d.ts.map +1 -1
- package/dist/evals/src/metrics.js +24 -0
- package/dist/evals/src/metrics.js.map +1 -1
- package/dist/packages/adapters/src/angular/index.js +2 -2
- package/dist/packages/adapters/src/angular/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/angular/manifest.js +2 -8
- package/dist/packages/adapters/src/angular/manifest.js.map +1 -1
- package/dist/packages/adapters/src/antd/index.js +2 -2
- package/dist/packages/adapters/src/antd/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/antd/manifest.js +2 -8
- package/dist/packages/adapters/src/antd/manifest.js.map +1 -1
- package/dist/packages/adapters/src/bootstrap/index.js +2 -2
- package/dist/packages/adapters/src/bootstrap/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/bootstrap/manifest.js +2 -8
- package/dist/packages/adapters/src/bootstrap/manifest.js.map +1 -1
- package/dist/packages/adapters/src/chakra/index.d.ts.map +1 -1
- package/dist/packages/adapters/src/chakra/index.js +30 -5
- package/dist/packages/adapters/src/chakra/index.js.map +1 -1
- package/dist/packages/adapters/src/chakra/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/chakra/manifest.js +309 -10
- package/dist/packages/adapters/src/chakra/manifest.js.map +1 -1
- package/dist/packages/adapters/src/index.d.ts +4 -0
- package/dist/packages/adapters/src/index.d.ts.map +1 -1
- package/dist/packages/adapters/src/index.js +18 -14
- package/dist/packages/adapters/src/index.js.map +1 -1
- package/dist/packages/adapters/src/local.d.ts.map +1 -1
- package/dist/packages/adapters/src/local.js +4 -2
- package/dist/packages/adapters/src/local.js.map +1 -1
- package/dist/packages/adapters/src/mantine/index.js +3 -3
- package/dist/packages/adapters/src/mantine/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/mantine/manifest.js +8 -21
- package/dist/packages/adapters/src/mantine/manifest.js.map +1 -1
- package/dist/packages/adapters/src/mui/index.js +3 -3
- package/dist/packages/adapters/src/mui/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/mui/manifest.js +2 -11
- package/dist/packages/adapters/src/mui/manifest.js.map +1 -1
- package/dist/packages/adapters/src/nuxt-ui/index.d.ts +5 -0
- package/dist/packages/adapters/src/nuxt-ui/index.d.ts.map +1 -0
- package/dist/packages/adapters/src/nuxt-ui/index.js +79 -0
- package/dist/packages/adapters/src/nuxt-ui/index.js.map +1 -0
- package/dist/packages/adapters/src/nuxt-ui/manifest.d.ts +3 -0
- package/dist/packages/adapters/src/nuxt-ui/manifest.d.ts.map +1 -0
- package/dist/packages/adapters/src/nuxt-ui/manifest.js +295 -0
- package/dist/packages/adapters/src/nuxt-ui/manifest.js.map +1 -0
- package/dist/packages/adapters/src/radix/index.d.ts +5 -0
- package/dist/packages/adapters/src/radix/index.d.ts.map +1 -0
- package/dist/packages/adapters/src/radix/index.js +71 -0
- package/dist/packages/adapters/src/radix/index.js.map +1 -0
- package/dist/packages/adapters/src/radix/manifest.d.ts +3 -0
- package/dist/packages/adapters/src/radix/manifest.d.ts.map +1 -0
- package/dist/packages/adapters/src/radix/manifest.js +331 -0
- package/dist/packages/adapters/src/radix/manifest.js.map +1 -0
- package/dist/packages/adapters/src/registry.d.ts +1 -1
- package/dist/packages/adapters/src/registry.d.ts.map +1 -1
- package/dist/packages/adapters/src/registry.js +16 -12
- package/dist/packages/adapters/src/registry.js.map +1 -1
- package/dist/packages/adapters/src/shadcn/index.js +3 -3
- package/dist/packages/adapters/src/shadcn/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/shadcn/manifest.js +2 -11
- package/dist/packages/adapters/src/shadcn/manifest.js.map +1 -1
- package/dist/packages/adapters/src/solid/index.js +2 -2
- package/dist/packages/adapters/src/solid/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/solid/manifest.js +2 -8
- package/dist/packages/adapters/src/solid/manifest.js.map +1 -1
- package/dist/packages/adapters/src/svelte/index.js +2 -2
- package/dist/packages/adapters/src/svelte/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/svelte/manifest.js +2 -8
- package/dist/packages/adapters/src/svelte/manifest.js.map +1 -1
- package/dist/packages/adapters/src/vue/index.js +2 -2
- package/dist/packages/adapters/src/vue/manifest.d.ts.map +1 -1
- package/dist/packages/adapters/src/vue/manifest.js +2 -8
- package/dist/packages/adapters/src/vue/manifest.js.map +1 -1
- package/dist/packages/design-md/src/compile.js +2 -2
- package/dist/packages/design-md/src/derive.d.ts +41 -0
- package/dist/packages/design-md/src/derive.d.ts.map +1 -0
- package/dist/packages/design-md/src/derive.js +341 -0
- package/dist/packages/design-md/src/derive.js.map +1 -0
- package/dist/packages/design-md/src/index.d.ts +1 -0
- package/dist/packages/design-md/src/index.d.ts.map +1 -1
- package/dist/packages/design-md/src/index.js +6 -5
- package/dist/packages/design-md/src/index.js.map +1 -1
- package/dist/packages/gateway/src/confidence.d.ts +51 -1
- package/dist/packages/gateway/src/confidence.d.ts.map +1 -1
- package/dist/packages/gateway/src/confidence.js +198 -6
- package/dist/packages/gateway/src/confidence.js.map +1 -1
- package/dist/packages/gateway/src/gateway.d.ts +10 -2
- package/dist/packages/gateway/src/gateway.d.ts.map +1 -1
- package/dist/packages/gateway/src/gateway.js +190 -14
- package/dist/packages/gateway/src/gateway.js.map +1 -1
- package/dist/packages/gateway/src/index.d.ts +1 -0
- package/dist/packages/gateway/src/index.d.ts.map +1 -1
- package/dist/packages/gateway/src/index.js +7 -6
- package/dist/packages/gateway/src/index.js.map +1 -1
- package/dist/packages/gateway/src/preview.d.ts +12 -0
- package/dist/packages/gateway/src/preview.d.ts.map +1 -0
- package/dist/packages/gateway/src/preview.js +113 -0
- package/dist/packages/gateway/src/preview.js.map +1 -0
- package/dist/packages/gateway/src/validate.d.ts +5 -2
- package/dist/packages/gateway/src/validate.d.ts.map +1 -1
- package/dist/packages/gateway/src/validate.js +46 -18
- package/dist/packages/gateway/src/validate.js.map +1 -1
- package/dist/packages/kb/src/bundle-size.d.ts +8 -9
- package/dist/packages/kb/src/bundle-size.d.ts.map +1 -1
- package/dist/packages/kb/src/bundle-size.js +14 -12
- package/dist/packages/kb/src/bundle-size.js.map +1 -1
- package/dist/packages/kb/src/entry.d.ts +19 -1
- package/dist/packages/kb/src/entry.d.ts.map +1 -1
- package/dist/packages/kb/src/entry.js +13 -1
- package/dist/packages/kb/src/entry.js.map +1 -1
- package/dist/packages/kb/src/freshness.d.ts +76 -0
- package/dist/packages/kb/src/freshness.d.ts.map +1 -0
- package/dist/packages/kb/src/freshness.js +186 -0
- package/dist/packages/kb/src/freshness.js.map +1 -0
- package/dist/packages/kb/src/index.d.ts +2 -1
- package/dist/packages/kb/src/index.d.ts.map +1 -1
- package/dist/packages/kb/src/index.js +6 -5
- package/dist/packages/kb/src/index.js.map +1 -1
- package/dist/packages/kb/src/ingest.d.ts +3 -0
- package/dist/packages/kb/src/ingest.d.ts.map +1 -1
- package/dist/packages/kb/src/ingest.js +7 -1
- package/dist/packages/kb/src/ingest.js.map +1 -1
- package/dist/packages/kb/src/kb.d.ts +5 -0
- package/dist/packages/kb/src/kb.d.ts.map +1 -1
- package/dist/packages/kb/src/kb.js +5 -2
- package/dist/packages/kb/src/kb.js.map +1 -1
- package/dist/packages/matcher/src/anthropic.js +1 -1
- package/dist/packages/matcher/src/index.d.ts +8 -1
- package/dist/packages/matcher/src/index.d.ts.map +1 -1
- package/dist/packages/matcher/src/index.js +21 -11
- package/dist/packages/matcher/src/index.js.map +1 -1
- package/dist/packages/matcher/src/scaffold.d.ts.map +1 -1
- package/dist/packages/matcher/src/scaffold.js +62 -19
- package/dist/packages/matcher/src/scaffold.js.map +1 -1
- package/dist/packages/matcher/src/score.d.ts +8 -1
- package/dist/packages/matcher/src/score.d.ts.map +1 -1
- package/dist/packages/matcher/src/score.js +90 -25
- package/dist/packages/matcher/src/score.js.map +1 -1
- package/dist/packages/matcher/src/select.d.ts +15 -1
- package/dist/packages/matcher/src/select.d.ts.map +1 -1
- package/dist/packages/matcher/src/select.js +53 -3
- package/dist/packages/matcher/src/select.js.map +1 -1
- package/dist/packages/orchestrator/src/figma.d.ts +12 -0
- package/dist/packages/orchestrator/src/figma.d.ts.map +1 -0
- package/dist/packages/orchestrator/src/figma.js +102 -0
- package/dist/packages/orchestrator/src/figma.js.map +1 -0
- package/dist/packages/orchestrator/src/index.d.ts +1 -0
- package/dist/packages/orchestrator/src/index.d.ts.map +1 -1
- package/dist/packages/orchestrator/src/index.js +3 -2
- package/dist/packages/orchestrator/src/index.js.map +1 -1
- package/dist/packages/orchestrator/src/orchestrator.d.ts.map +1 -1
- package/dist/packages/orchestrator/src/orchestrator.js +14 -3
- package/dist/packages/orchestrator/src/orchestrator.js.map +1 -1
- package/dist/packages/profile/src/detect.d.ts +9 -0
- package/dist/packages/profile/src/detect.d.ts.map +1 -1
- package/dist/packages/profile/src/detect.js +52 -5
- package/dist/packages/profile/src/detect.js.map +1 -1
- package/dist/packages/profile/src/index.js +7 -7
- package/dist/packages/profile/src/local-components.d.ts.map +1 -1
- package/dist/packages/profile/src/local-components.js +70 -1
- package/dist/packages/profile/src/local-components.js.map +1 -1
- package/dist/packages/profile/src/registry.d.ts.map +1 -1
- package/dist/packages/profile/src/registry.js +3 -1
- package/dist/packages/profile/src/registry.js.map +1 -1
- package/dist/packages/profile/src/skills.js +1 -1
- package/dist/packages/protocol/src/errors.js +1 -1
- package/dist/packages/protocol/src/errors.js.map +1 -1
- package/dist/packages/protocol/src/event-log.d.ts.map +1 -1
- package/dist/packages/protocol/src/event-log.js +11 -5
- package/dist/packages/protocol/src/event-log.js.map +1 -1
- package/dist/packages/protocol/src/events.js +5 -5
- package/dist/packages/protocol/src/hashing.d.ts +6 -0
- package/dist/packages/protocol/src/hashing.d.ts.map +1 -1
- package/dist/packages/protocol/src/hashing.js +8 -2
- package/dist/packages/protocol/src/hashing.js.map +1 -1
- package/dist/packages/protocol/src/index.js +12 -12
- package/dist/packages/protocol/src/lease.js +2 -2
- package/dist/packages/protocol/src/schemas.d.ts +2803 -116
- package/dist/packages/protocol/src/schemas.d.ts.map +1 -1
- package/dist/packages/protocol/src/schemas.js +54 -4
- package/dist/packages/protocol/src/schemas.js.map +1 -1
- package/dist/packages/protocol/src/semantic.js +1 -1
- package/dist/packages/protocol/src/state-machine.js +1 -1
- package/dist/packages/transports/src/check.d.ts +30 -0
- package/dist/packages/transports/src/check.d.ts.map +1 -0
- package/dist/packages/transports/src/check.js +190 -0
- package/dist/packages/transports/src/check.js.map +1 -0
- package/dist/packages/transports/src/cli.d.ts +1 -1
- package/dist/packages/transports/src/cli.js +278 -25
- package/dist/packages/transports/src/cli.js.map +1 -1
- package/dist/packages/transports/src/exit-codes.d.ts +8 -0
- package/dist/packages/transports/src/exit-codes.d.ts.map +1 -0
- package/dist/packages/transports/src/exit-codes.js +19 -0
- package/dist/packages/transports/src/exit-codes.js.map +1 -0
- package/dist/packages/transports/src/http.js +2 -2
- package/dist/packages/transports/src/http.js.map +1 -1
- package/dist/packages/transports/src/index.d.ts +5 -0
- package/dist/packages/transports/src/index.d.ts.map +1 -1
- package/dist/packages/transports/src/index.js +11 -6
- package/dist/packages/transports/src/index.js.map +1 -1
- package/dist/packages/transports/src/init.d.ts +32 -0
- package/dist/packages/transports/src/init.d.ts.map +1 -0
- package/dist/packages/transports/src/init.js +110 -0
- package/dist/packages/transports/src/init.js.map +1 -0
- package/dist/packages/transports/src/mcp-config.d.ts +27 -0
- package/dist/packages/transports/src/mcp-config.d.ts.map +1 -0
- package/dist/packages/transports/src/mcp-config.js +99 -0
- package/dist/packages/transports/src/mcp-config.js.map +1 -0
- package/dist/packages/transports/src/mcp.js +3 -3
- package/dist/packages/transports/src/paths.d.ts +9 -0
- package/dist/packages/transports/src/paths.d.ts.map +1 -0
- package/dist/packages/transports/src/paths.js +32 -0
- package/dist/packages/transports/src/paths.js.map +1 -0
- package/dist/packages/transports/src/receipt.d.ts +8 -0
- package/dist/packages/transports/src/receipt.d.ts.map +1 -0
- package/dist/packages/transports/src/receipt.js +87 -0
- package/dist/packages/transports/src/receipt.js.map +1 -0
- package/dist/packages/transports/src/resources.js +3 -3
- package/dist/packages/transports/src/resources.js.map +1 -1
- package/dist/packages/transports/src/tools.d.ts.map +1 -1
- package/dist/packages/transports/src/tools.js +284 -10
- package/dist/packages/transports/src/tools.js.map +1 -1
- package/dist/packages/verifier/src/index.js +7 -7
- package/dist/packages/verifier/src/lint.js +1 -1
- package/dist/packages/verifier/src/page.js +2 -2
- package/dist/packages/verifier/src/render-axe.js +1 -1
- package/dist/packages/verifier/src/verify.js +4 -4
- package/dist/scripts/build-site.d.ts +2 -0
- package/dist/scripts/build-site.d.ts.map +1 -0
- package/dist/scripts/build-site.js +254 -0
- package/dist/scripts/build-site.js.map +1 -0
- package/dist/scripts/calibration.js +33 -2
- package/dist/scripts/calibration.js.map +1 -1
- package/dist/scripts/fix-imports.js +32 -2
- package/dist/scripts/fix-imports.js.map +1 -1
- package/dist/scripts/generate-kb.d.ts +3 -0
- package/dist/scripts/generate-kb.d.ts.map +1 -0
- package/dist/scripts/generate-kb.js +195 -0
- package/dist/scripts/generate-kb.js.map +1 -0
- package/dist/scripts/generate-refusal-catalog.d.ts +3 -0
- package/dist/scripts/generate-refusal-catalog.d.ts.map +1 -0
- package/dist/scripts/generate-refusal-catalog.js +50 -0
- package/dist/scripts/generate-refusal-catalog.js.map +1 -0
- package/dist/scripts/generate-tool-docs.d.ts +3 -0
- package/dist/scripts/generate-tool-docs.d.ts.map +1 -0
- package/dist/scripts/generate-tool-docs.js +24 -0
- package/dist/scripts/generate-tool-docs.js.map +1 -0
- package/dist/scripts/mcp-config.js +28 -60
- package/dist/scripts/mcp-config.js.map +1 -1
- package/docs/archive/UI Gateway Final Project Roadmap.md +285 -0
- package/docs/benchmarks/external-repos.json +26 -0
- package/docs/benchmarks/local-gemma3-1b-stride32.json +455 -0
- package/docs/calibration.svg +44 -0
- package/docs/design-import.md +19 -0
- package/docs/design-md.md +109 -0
- package/docs/distribution.md +41 -0
- package/docs/engineering-principles.md +152 -0
- package/docs/layers-plan.md +372 -0
- package/docs/metrics.md +153 -0
- package/docs/modes.md +22 -0
- package/docs/parking-lot.md +25 -0
- package/docs/quickstart.md +72 -0
- package/docs/refusal-catalog.md +32 -0
- package/docs/spike-source-discovery.md +36 -0
- package/docs/telemetry.md +26 -0
- package/evals/fixtures/external-repos.json +55 -0
- package/evals/fixtures/kb-generated/angular.json +72 -0
- package/evals/fixtures/kb-generated/antd.json +72 -0
- package/evals/fixtures/kb-generated/bootstrap.json +72 -0
- package/evals/fixtures/kb-generated/chakra.json +14939 -0
- package/evals/fixtures/kb-generated/mantine.json +192 -0
- package/evals/fixtures/kb-generated/mui.json +8997 -0
- package/evals/fixtures/kb-generated/shadcn.json +192 -0
- package/evals/fixtures/kb-generated/solid.json +72 -0
- package/evals/fixtures/kb-generated/svelte.json +72 -0
- package/evals/fixtures/kb-generated/vue.json +72 -0
- package/evals/fixtures/projects/existing-chakra-v3/package.json +10 -0
- package/evals/fixtures/projects/existing-nuxt-ui/package.json +9 -0
- package/evals/fixtures/projects/existing-radix/package.json +9 -0
- package/evals/out/agent-report.json +190 -11
- package/evals/out/baseline-report.json +1441 -387
- package/evals/out/calibration.json +387 -42
- package/evals/out/external-repos-report.json +112 -0
- package/evals/out/local-benchmark-report.json +455 -0
- package/evals/src/agent-eval.test.ts +3 -0
- package/evals/src/agent-eval.ts +26 -4
- package/evals/src/baseline.ts +48 -7
- package/evals/src/blind-labeling-cli.ts +5 -0
- package/evals/src/blind-labeling.ts +46 -0
- package/evals/src/external-repos.ts +179 -0
- package/evals/src/metrics.ts +70 -0
- package/evals/src/mutations.ts +6 -6
- package/evals/src/page-a11y-eval.ts +37 -36
- package/evals/src/page-real-eval.ts +8 -7
- package/evals/src/plain-agent.test.ts +14 -0
- package/evals/src/plain-agent.ts +240 -0
- package/evals/src/run-agent-evals.ts +3 -0
- package/evals/src/run-external-repos.ts +43 -0
- package/evals/src/run-local-benchmark.ts +105 -0
- package/evals/src/run-plain-agent.ts +81 -0
- package/examples/README.md +32 -0
- package/examples/build-handoff.ts +106 -0
- package/examples/design-md.md +24 -0
- package/examples/handoff-input.json +59 -0
- package/examples/handoff.json +216 -0
- package/examples/layer-operations.json +18 -0
- package/examples/website-demo-handoff.json +580 -0
- package/package.json +29 -6
- package/references/design-md.md +3 -1
- package/references/errors.md +1 -1
- package/references/handoff.md +16 -1
- package/references/outcomes.md +60 -11
- package/references/patterns.md +3 -3
- package/references/tools.md +86 -27
- package/scripts/action-review.mjs +59 -0
- package/scripts/bench-latency.ts +90 -0
- package/scripts/build-site.ts +324 -0
- package/scripts/calibration.ts +50 -14
- package/scripts/fix-imports.ts +31 -2
- package/scripts/generate-kb.ts +214 -0
- package/scripts/generate-refusal-catalog.ts +58 -0
- package/scripts/generate-tool-docs.ts +31 -0
- package/scripts/mcp-config.ts +26 -83
- package/scripts/package-plugin.mjs +50 -0
- package/scripts/sbom.mjs +46 -0
- package/scripts/visual-diff.mjs +52 -0
- package/site/data.json +187 -0
- package/site/index.html +151 -0
- package/skills/ui-gateway-cli/SKILL.md +41 -0
- package/templates/next-shadcn/.github/workflows/ui-check.yml +14 -0
- package/templates/next-shadcn/.mcp.json +8 -0
- package/templates/next-shadcn/DESIGN.md +35 -0
- package/templates/next-shadcn/README.md +14 -0
- package/templates/next-shadcn/app/page.tsx +8 -0
- package/templates/next-shadcn/package.json +19 -0
- package/templates/vite-mantine/.github/workflows/ui-check.yml +14 -0
- package/templates/vite-mantine/.mcp.json +8 -0
- package/templates/vite-mantine/DESIGN.md +30 -0
- package/templates/vite-mantine/README.md +7 -0
- package/templates/vite-mantine/package.json +21 -0
- package/templates/vite-mantine/src/App.tsx +10 -0
- package/templates/vite-mui/.github/workflows/ui-check.yml +14 -0
- package/templates/vite-mui/.mcp.json +8 -0
- package/templates/vite-mui/DESIGN.md +30 -0
- package/templates/vite-mui/README.md +8 -0
- package/templates/vite-mui/package.json +22 -0
- package/templates/vite-mui/src/App.tsx +12 -0
- package/scripts/fetch-bundle-sizes.ts +0 -106
- package/scripts/test-bundlephobia.ts +0 -11
|
@@ -64,11 +64,12 @@ async function main(): Promise<void> {
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
const gateway = makeGateway();
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
const submitted = await gateway.submit(handoff);
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
if (!submitted.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
throw new Error(`fixture handoff failed: ${submitted.error.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
if (!submitted.result) {
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
throw new Error(`fixture handoff failed: ${submitted.error?.message ?? submitted.outcome}`);
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
const result = submitted.result;
|
|
128
|
+
const firstPage = composePage(handoff, result.intents, { responsiveMode: "tailwind" });
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
136
137
|
if (!firstPage) throw new Error("gateway did not compose a page");
|
|
137
138
|
|
|
138
139
|
|
|
139
140
|
|
|
140
141
|
|
|
141
142
|
|
|
142
143
|
|
|
143
144
|
|
|
144
145
|
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
|
|
151
152
|
|
|
152
153
|
|
|
153
154
|
|
|
154
155
|
writeFileSync(
|
|
155
156
|
|
|
156
157
|
|
|
157
158
|
|
|
158
159
|
|
|
159
160
|
|
|
160
161
|
|
|
161
162
|
|
|
162
163
|
|
|
@@ -168,7 +169,7 @@ async function main(): Promise<void> {
|
|
|
168
169
|
const browser = await chromium.launch({ executablePath: CHROME, headless: true });
|
|
169
170
|
|
|
170
171
|
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
|
|
174
175
|
|
|
175
176
|
|
|
176
177
|
|
|
177
178
|
try {
|
|
178
179
|
|
|
179
180
|
|
|
180
181
|
|
|
181
182
|
|
|
182
183
|
|
|
183
184
|
|
|
184
185
|
|
|
185
186
|
|
|
186
187
|
for (const mode of MODES) {
|
|
187
188
|
|
|
188
189
|
|
|
189
190
|
|
|
190
191
|
|
|
191
192
|
|
|
192
193
|
|
|
193
194
|
|
|
194
195
|
|
|
195
|
-
const page = composePage(handoff,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
const page = composePage(handoff, result.intents, { responsiveMode: mode });
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
204
205
|
if (!page) throw new Error(`no page for mode ${mode}`);
|
|
205
206
|
|
|
206
207
|
|
|
207
208
|
|
|
208
209
|
|
|
209
210
|
|
|
210
211
|
|
|
211
212
|
|
|
212
213
|
|
|
213
214
|
if (page.files.length > 1) {
|
|
214
215
|
|
|
215
216
|
|
|
216
217
|
|
|
217
218
|
|
|
218
219
|
|
|
219
220
|
|
|
220
221
|
|
|
221
222
|
|
|
222
223
|
writeFileSync(join(root, "page-state.tsx"), page.files[1].code);
|
|
223
224
|
|
|
224
225
|
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
|
|
228
229
|
|
|
229
230
|
|
|
230
231
|
|
|
@@ -171,21 +171,22 @@ async function main(): Promise<void> {
|
|
|
171
171
|
},
|
|
172
172
|
});
|
|
173
173
|
const response = await gateway.submit(handoff);
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
const result = response.result;
|
|
175
|
+
if (!result) throw new Error(`${testCase.name}: submit failed: ${response.error?.message ?? response.outcome}`);
|
|
176
|
+
const pageCode = result.page?.code;
|
|
176
177
|
if (!pageCode) throw new Error(`${testCase.name}: no composed page`);
|
|
177
|
-
const unmapped =
|
|
178
|
+
const unmapped = result.intents.filter((intent) => !intent.scaffold);
|
|
178
179
|
if (unmapped.length > 0) {
|
|
179
180
|
throw new Error(`${testCase.name}: unmapped intents ${unmapped.map((intent) => intent.intent_id).join(", ")}`);
|
|
180
181
|
}
|
|
181
|
-
const theme =
|
|
182
|
+
const theme = result.token_projection?.find(
|
|
182
183
|
(projection) => projection.library === testCase.provider,
|
|
183
184
|
);
|
|
184
185
|
if (!theme?.files[0]) throw new Error(`${testCase.name}: no native theme projection`);
|
|
185
186
|
writeFileSync(join(root, "theme.tokens.ts"), theme.files[0].code);
|
|
186
187
|
|
|
187
188
|
const intentScaffoldFiles: Array<{ filename: string; code: string }> = [];
|
|
188
|
-
for (const intent of
|
|
189
|
+
for (const intent of result.intents) {
|
|
189
190
|
if (!intent.scaffold) continue;
|
|
190
191
|
const filename = `${intent.intent_id
|
|
191
192
|
.toLowerCase()
|
|
@@ -195,7 +196,7 @@ async function main(): Promise<void> {
|
|
|
195
196
|
writeFileSync(join(root, filename), intent.scaffold!);
|
|
196
197
|
}
|
|
197
198
|
writeFileSync(join(root, "Page.tsx"), pageCode);
|
|
198
|
-
for (const file of
|
|
199
|
+
for (const file of result.page?.files ?? []) {
|
|
199
200
|
writeFileSync(join(root, file.filename), file.code);
|
|
200
201
|
}
|
|
201
202
|
writeFileSync(join(root, "main.tsx"), mainEntry(testCase.provider));
|
|
@@ -212,7 +213,7 @@ async function main(): Promise<void> {
|
|
|
212
213
|
logLevel: "silent",
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
const verifyFiles = [...intentScaffoldFiles, ...
|
|
216
|
+
const verifyFiles = [...intentScaffoldFiles, ...result.page?.files ?? []];
|
|
216
217
|
const staticCheck = verifyPage({
|
|
217
218
|
code: pageCode,
|
|
218
219
|
files: verifyFiles,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { extractCode } from "./plain-agent";
|
|
3
|
+
|
|
4
|
+
describe("plain-agent code extraction", () => {
|
|
5
|
+
it("strips tsx and typescript fences", () => {
|
|
6
|
+
expect(extractCode("```tsx\nexport const A = 1;\n```")).toBe("export const A = 1;");
|
|
7
|
+
expect(extractCode("```typescript\nimport React from 'react';\n```")).toBe("import React from 'react';");
|
|
8
|
+
expect(extractCode("```javascript\nexport default 1;\n```")).toBe("export default 1;");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("accepts unfenced output", () => {
|
|
12
|
+
expect(extractCode("export const A = 1;")).toBe("export const A = 1;");
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { buildKnowledgeBase, createDefaultAdapters } from "@uigw/adapters";
|
|
4
|
+
import { compileDesignMd, describeDesign } from "@uigw/design-md";
|
|
5
|
+
import { detectProject } from "@uigw/profile";
|
|
6
|
+
import { verifyPage } from "@uigw/verifier";
|
|
7
|
+
import type { ModelCall } from "@uigw/matcher";
|
|
8
|
+
import { fixturesDir, loadGoldenSet, type GoldenItem } from "./golden";
|
|
9
|
+
import { computeTaskOutcomes, type TaskOutcomeRecord, type TaskOutcomeReport } from "./metrics";
|
|
10
|
+
|
|
11
|
+
export interface PlainAgentReport {
|
|
12
|
+
arm: string;
|
|
13
|
+
description: string;
|
|
14
|
+
generated_at: string;
|
|
15
|
+
n: number;
|
|
16
|
+
outcomes: TaskOutcomeReport;
|
|
17
|
+
records: Array<TaskOutcomeRecord & { code: string; issues: string[] }>;
|
|
18
|
+
model_info: { provider: string; id: string } | null;
|
|
19
|
+
notes: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const KNOWN_MODULES: Record<string, string> = {
|
|
23
|
+
mui: "@mui/material",
|
|
24
|
+
chakra: "@chakra-ui/react",
|
|
25
|
+
mantine: "@mantine/core",
|
|
26
|
+
antd: "antd",
|
|
27
|
+
bootstrap: "bootstrap",
|
|
28
|
+
shadcn: "@/components/ui",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The real competitor arm: the same model, the same project and a normal
|
|
33
|
+
* read/write/tsc toolset, but no gateway. It writes one component file per
|
|
34
|
+
* intent; the project's verifier then records task outcomes rather than just a
|
|
35
|
+
* component id, so the benchmark answers "does the code work?".
|
|
36
|
+
*/
|
|
37
|
+
export async function runPlainAgentArm(
|
|
38
|
+
callModel: ModelCall,
|
|
39
|
+
options: {
|
|
40
|
+
fixtures?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
stride?: number;
|
|
43
|
+
modelInfo?: { provider: string; id: string };
|
|
44
|
+
} = {},
|
|
45
|
+
): Promise<PlainAgentReport> {
|
|
46
|
+
const fixtures = options.fixtures ?? fixturesDir();
|
|
47
|
+
const set = loadGoldenSet(fixtures);
|
|
48
|
+
const items = options.limit
|
|
49
|
+
? set.items.slice(0, options.limit)
|
|
50
|
+
: options.stride && options.stride > 1
|
|
51
|
+
? set.items.filter((_, index) => index % options.stride! === 0)
|
|
52
|
+
: set.items;
|
|
53
|
+
|
|
54
|
+
const designs = new Map<string, string>();
|
|
55
|
+
const designFor = (item: GoldenItem): string => {
|
|
56
|
+
const file = item.design_md_file ?? set.design_md_file;
|
|
57
|
+
const cached = designs.get(file);
|
|
58
|
+
if (cached !== undefined) return cached;
|
|
59
|
+
const text = file === set.design_md_file ? set.design_md : readFileSync(join(fixtures, file), "utf8");
|
|
60
|
+
designs.set(file, text);
|
|
61
|
+
return text;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const records: PlainAgentReport["records"] = [];
|
|
65
|
+
for (const item of items) {
|
|
66
|
+
const project = item.project ?? "greenfield-react";
|
|
67
|
+
const dir = join(fixtures, "projects", project);
|
|
68
|
+
const profile = detectProject(dir);
|
|
69
|
+
const kb = buildKnowledgeBase({ adapters: createDefaultAdapters(), profile });
|
|
70
|
+
const designMd = designFor(item);
|
|
71
|
+
const design = compileDesignMd(designMd);
|
|
72
|
+
const allowed = allowedModules(profile.libraries.value.map((library) => library.id), design.preferred_libraries);
|
|
73
|
+
|
|
74
|
+
const prompt = renderPlainAgentPrompt({
|
|
75
|
+
designMd,
|
|
76
|
+
designSummary: describeDesign(design),
|
|
77
|
+
intent: item.intent,
|
|
78
|
+
project,
|
|
79
|
+
libraries: profile.libraries.value.map((library) => library.id),
|
|
80
|
+
allowed,
|
|
81
|
+
});
|
|
82
|
+
const started = Date.now();
|
|
83
|
+
const response = await callModel(prompt);
|
|
84
|
+
const code = extractCode(response);
|
|
85
|
+
const issues = verifyPage({ code, filename: "Component.tsx", compile: true }).issues;
|
|
86
|
+
const wallMs = Date.now() - started;
|
|
87
|
+
|
|
88
|
+
const modules = importModules(code);
|
|
89
|
+
const predicted = predictedIds(kb, modules);
|
|
90
|
+
const constrained = constraintFindings(code, design, modules);
|
|
91
|
+
const librariesAllowed = modules.every(
|
|
92
|
+
(module) => module.startsWith(".") || module.startsWith("@/") || module === "react" || allowed.has(module),
|
|
93
|
+
);
|
|
94
|
+
const a11y = issues.filter((issue) => issue.code === "MISSING_ALT" || issue.code === "UNLABELED_CONTROL" || issue.code === "MISSING_MAIN");
|
|
95
|
+
const errors = issues.filter((issue) => issue.code !== "UNUSED_IMPORT" && issue.code !== "DUPLICATE_DISPLAY_UTILITY");
|
|
96
|
+
const compileIssue = issues.find((issue) => issue.code === "COMPILE_ERROR");
|
|
97
|
+
|
|
98
|
+
records.push({
|
|
99
|
+
item_id: item.item_id,
|
|
100
|
+
compiles: compileIssue ? false : issues.every((issue) => issue.code !== "SYNTAX_ERROR") ? true : false,
|
|
101
|
+
lint_clean: errors.length === 0,
|
|
102
|
+
a11y_clean: a11y.length === 0 && !errors.some((issue) => issue.code === "SYNTAX_ERROR"),
|
|
103
|
+
constraints_ok: constrained.length === 0,
|
|
104
|
+
libraries_allowed: librariesAllowed,
|
|
105
|
+
tokens_matched: tokenMatch(code, designMd),
|
|
106
|
+
tool_calls: 1,
|
|
107
|
+
tokens: null,
|
|
108
|
+
wall_ms: wallMs,
|
|
109
|
+
predicted,
|
|
110
|
+
acceptable: item.acceptable,
|
|
111
|
+
code,
|
|
112
|
+
issues: [...issues.map((issue) => `${issue.code}: ${issue.message}`), ...constrained],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
arm: "plain_agent_no_gateway",
|
|
118
|
+
description:
|
|
119
|
+
"Same model, same project and normal read/write/tsc toolset, no gateway; outcome measured by the project verifier",
|
|
120
|
+
generated_at: new Date().toISOString(),
|
|
121
|
+
n: records.length,
|
|
122
|
+
outcomes: computeTaskOutcomes(records),
|
|
123
|
+
records,
|
|
124
|
+
model_info: options.modelInfo ?? null,
|
|
125
|
+
notes: [
|
|
126
|
+
"This arm is the competitor: it may import any installed library and write any code.",
|
|
127
|
+
"compiles is the project verifier's TypeScript sandbox result; lint/a11y/constraints come from the same verifier.",
|
|
128
|
+
"token_match means at least half of the Design MD token values sampled appear in the generated code.",
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function renderPlainAgentPrompt(input: {
|
|
134
|
+
designMd: string;
|
|
135
|
+
designSummary: string;
|
|
136
|
+
intent: GoldenItem["intent"];
|
|
137
|
+
project: string;
|
|
138
|
+
libraries: string[];
|
|
139
|
+
allowed: Set<string>;
|
|
140
|
+
}): string {
|
|
141
|
+
return [
|
|
142
|
+
"You are a coding agent working directly in a TypeScript UI project. You do NOT have UI Gateway.",
|
|
143
|
+
`Project: ${input.project}`,
|
|
144
|
+
`Installed UI libraries: ${input.libraries.join(", ") || "none"}`,
|
|
145
|
+
`Allowed import modules: ${[...input.allowed].join(", ") || "the project's relative modules"}`,
|
|
146
|
+
"",
|
|
147
|
+
"Implement exactly one intent as a single React component file.",
|
|
148
|
+
"Return only a fenced tsx code block, no commentary.",
|
|
149
|
+
"Use real imports and props for the installed library; do not invent packages.",
|
|
150
|
+
"",
|
|
151
|
+
"DESIGN MD:",
|
|
152
|
+
input.designMd,
|
|
153
|
+
"",
|
|
154
|
+
"DESIGN SUMMARY:",
|
|
155
|
+
input.designSummary,
|
|
156
|
+
"",
|
|
157
|
+
"INTENT:",
|
|
158
|
+
JSON.stringify(input.intent, null, 2),
|
|
159
|
+
].join("\n");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function allowedModules(libraries: string[], preferred: string[]): Set<string> {
|
|
163
|
+
const out = new Set<string>(["react"]);
|
|
164
|
+
for (const library of [...libraries, ...preferred]) {
|
|
165
|
+
const module = KNOWN_MODULES[library];
|
|
166
|
+
if (module) out.add(module);
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function extractCode(response: string): string {
|
|
172
|
+
// Models label fences as typescript/javascript as often as tsx/ts. The label
|
|
173
|
+
// is metadata; compiling the fence markers themselves is not a model error.
|
|
174
|
+
const fenced = /```(?:tsx|ts|jsx|js|typescript|javascript)?\s*\n([\s\S]*?)```/i.exec(response);
|
|
175
|
+
return (fenced?.[1] ?? response).trim();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function importModules(code: string): string[] {
|
|
179
|
+
const modules: string[] = [];
|
|
180
|
+
for (const match of code.matchAll(/(?:from\s+|import\s*\()\s*["']([^"']+)["']/g)) {
|
|
181
|
+
if (match[1]) modules.push(match[1]);
|
|
182
|
+
}
|
|
183
|
+
return [...new Set(modules)];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function predictedIds(
|
|
187
|
+
kb: ReturnType<typeof buildKnowledgeBase>,
|
|
188
|
+
modules: string[],
|
|
189
|
+
): string[] {
|
|
190
|
+
const details: string[] = [];
|
|
191
|
+
for (const match of modules) details.push(match);
|
|
192
|
+
const ids: string[] = [];
|
|
193
|
+
for (const entry of kb.entries) {
|
|
194
|
+
for (const spec of entry.imports) {
|
|
195
|
+
if (details.includes(spec.module)) {
|
|
196
|
+
ids.push(entry.component_id);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return [...new Set(ids)];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function constraintFindings(
|
|
205
|
+
code: string,
|
|
206
|
+
design: ReturnType<typeof compileDesignMd>,
|
|
207
|
+
modules: string[],
|
|
208
|
+
): string[] {
|
|
209
|
+
const findings: string[] = [];
|
|
210
|
+
for (const entry of design.hard) {
|
|
211
|
+
if (entry.constraint.kind === "forbid_library") {
|
|
212
|
+
const library = entry.constraint.library;
|
|
213
|
+
const module = KNOWN_MODULES[library];
|
|
214
|
+
if (module && modules.includes(module)) findings.push(`FORBIDDEN_LIBRARY: ${library}`);
|
|
215
|
+
}
|
|
216
|
+
if (entry.constraint.kind === "forbid_pattern") {
|
|
217
|
+
const patterns: Record<string, RegExp> = {
|
|
218
|
+
gradient: /gradient\(/,
|
|
219
|
+
"inline-style": /style=\{\{/,
|
|
220
|
+
"arbitrary-tailwind": /\[[^\]]+\]/,
|
|
221
|
+
important: /![a-z-]/,
|
|
222
|
+
animation: /animate-(spin|ping|pulse|bounce)/,
|
|
223
|
+
shadow: /shadow-(sm|md|lg|xl)/,
|
|
224
|
+
};
|
|
225
|
+
const rule = patterns[entry.constraint.pattern];
|
|
226
|
+
if (rule?.test(code)) findings.push(`FORBIDDEN_PATTERN: ${entry.constraint.pattern}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return findings;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function tokenMatch(code: string, designMd: string): boolean | null {
|
|
233
|
+
const tokens = [...designMd.matchAll(/^-\s+([a-z]+[.\w-]*):\s+(.+)$/gm)]
|
|
234
|
+
.map((match) => match[2]?.trim())
|
|
235
|
+
.filter((value): value is string => Boolean(value) && !/^(light|dark)$/.test(value!));
|
|
236
|
+
if (tokens.length === 0) return null;
|
|
237
|
+
const sample = tokens.slice(0, 5);
|
|
238
|
+
const used = sample.filter((value) => code.includes(value));
|
|
239
|
+
return used.length >= Math.ceil(sample.length / 2);
|
|
240
|
+
}
|
|
@@ -32,6 +32,9 @@ async function main(): Promise<number> {
|
|
|
32
32
|
submitted: report.submitted,
|
|
33
33
|
mapped: report.mapped,
|
|
34
34
|
mapped_rate: Number(report.mapped_rate.toFixed(3)),
|
|
35
|
+
tool_calls_total: report.tool_calls_total,
|
|
36
|
+
tool_calls_per_item: report.tool_calls_per_item,
|
|
37
|
+
max_tool_calls: report.max_tool_calls,
|
|
35
38
|
failures: report.failures,
|
|
36
39
|
},
|
|
37
40
|
null,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fixturesDir } from "./golden";
|
|
4
|
+
import { resolveExternalPins, runExternalRepos } from "./external-repos";
|
|
5
|
+
|
|
6
|
+
async function main(): Promise<number> {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const updatePins = args.includes("--update-pins");
|
|
9
|
+
const pinsOnly = args.includes("--pins-only");
|
|
10
|
+
const onlyIndex = args.indexOf("--only");
|
|
11
|
+
const only = onlyIndex >= 0 ? (args[onlyIndex + 1] ?? "").split(",").filter(Boolean) : undefined;
|
|
12
|
+
if (pinsOnly) {
|
|
13
|
+
const { results, fixturePath } = resolveExternalPins({
|
|
14
|
+
fixturePath: join(fixturesDir(), "external-repos.json"),
|
|
15
|
+
...(only && only.length > 0 ? { only } : {}),
|
|
16
|
+
});
|
|
17
|
+
process.stdout.write(`${JSON.stringify({ fixture_path: fixturePath, results }, null, 2)}\n`);
|
|
18
|
+
return results.every((result) => result.resolved_commit !== null) ? 0 : 1;
|
|
19
|
+
}
|
|
20
|
+
const { results } = runExternalRepos({
|
|
21
|
+
fixturePath: join(fixturesDir(), "external-repos.json"),
|
|
22
|
+
...(updatePins ? { updatePins: true } : {}),
|
|
23
|
+
...(only && only.length > 0 ? { only } : {}),
|
|
24
|
+
});
|
|
25
|
+
const out = join(fixturesDir(), "..", "out", "external-repos-report.json");
|
|
26
|
+
try {
|
|
27
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
28
|
+
writeFileSync(out, `${JSON.stringify({ generated_at: new Date().toISOString(), results }, null, 2)}\n`, "utf8");
|
|
29
|
+
} catch {
|
|
30
|
+
// stdout is the primary contract.
|
|
31
|
+
}
|
|
32
|
+
process.stdout.write(`${JSON.stringify({ results }, null, 2)}\n`);
|
|
33
|
+
return results.every((result) => result.detected && result.design_md_ok) ? 0 : 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then((code) => {
|
|
38
|
+
process.exitCode = code;
|
|
39
|
+
})
|
|
40
|
+
.catch((error) => {
|
|
41
|
+
process.stderr.write(`${(error as Error).message}\n`);
|
|
42
|
+
process.exitCode = 2;
|
|
43
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { runComparison } from "./baseline";
|
|
4
|
+
import { fixturesDir } from "./golden";
|
|
5
|
+
import { createLocalLlmCall, createLocalLlmSelectionModel } from "./local-llm";
|
|
6
|
+
import { runPlainAgentArm } from "./plain-agent";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Local-model benchmark: gateway vs retrieval-free selection vs plain
|
|
10
|
+
* generation, plus the plain-agent no-gateway arm. This runs against Ollama so
|
|
11
|
+
* it needs no API key, but the numbers are explicitly local-model numbers, not
|
|
12
|
+
* Claude/DeepSeek numbers.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* UIGW_LOCAL_MODEL=qwen2.5:latest UIGW_EVAL_STRIDE=16 npm run eval:local
|
|
16
|
+
*/
|
|
17
|
+
async function main(): Promise<number> {
|
|
18
|
+
const model = process.env.UIGW_LOCAL_MODEL ?? "qwen2.5:latest";
|
|
19
|
+
const baseUrl = process.env.UIGW_OLLAMA_URL ?? "http://localhost:11434";
|
|
20
|
+
const limit = parsePositiveInt(process.env.UIGW_EVAL_LIMIT);
|
|
21
|
+
const stride = parseStride(process.env.UIGW_EVAL_STRIDE) ?? 16;
|
|
22
|
+
const samples = parsePositiveInt(process.env.UIGW_LOCAL_SAMPLES) ?? 2;
|
|
23
|
+
const local = { baseUrl, model, temperature: 0.1, maxTokens: 220 };
|
|
24
|
+
|
|
25
|
+
process.stderr.write(`local benchmark: ${model} at ${baseUrl}, stride ${stride}, ${samples} sample(s)\n`);
|
|
26
|
+
const gateway = await runComparison({
|
|
27
|
+
compile: true,
|
|
28
|
+
model: createLocalLlmSelectionModel(local),
|
|
29
|
+
noRetrievalModel: createLocalLlmSelectionModel({ ...local, maxTokens: 120 }),
|
|
30
|
+
plainCall: createLocalLlmCall({ ...local, maxTokens: 120 }),
|
|
31
|
+
localLlm: local,
|
|
32
|
+
modelInfo: { provider: "ollama", id: model },
|
|
33
|
+
stride,
|
|
34
|
+
...(limit ? { limit } : {}),
|
|
35
|
+
nSamples: samples,
|
|
36
|
+
blindOnly: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
process.stderr.write("local benchmark: running plain-agent no-gateway arm\n");
|
|
40
|
+
const plainAgent = await runPlainAgentArm(
|
|
41
|
+
createLocalLlmCall({ baseUrl, model, temperature: 0.1, maxTokens: 1200 }),
|
|
42
|
+
{
|
|
43
|
+
modelInfo: { provider: "ollama", id: model },
|
|
44
|
+
stride,
|
|
45
|
+
...(limit ? { limit } : {}),
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const report = {
|
|
50
|
+
generated_at: new Date().toISOString(),
|
|
51
|
+
model_info: { provider: "ollama", id: model, base_url: baseUrl },
|
|
52
|
+
sample: {
|
|
53
|
+
stride,
|
|
54
|
+
gateway_items: gateway.arms[0]?.metrics.n ?? 0,
|
|
55
|
+
plain_agent_items: plainAgent.n,
|
|
56
|
+
note:
|
|
57
|
+
"Stratified subset, not the full 172-item set. These are local Ollama numbers; they are not DeepSeek or Claude numbers.",
|
|
58
|
+
},
|
|
59
|
+
gateway: {
|
|
60
|
+
thresholds_passed: gateway.thresholds_passed,
|
|
61
|
+
arms: gateway.arms.map((arm) => ({ name: arm.name, metrics: arm.metrics })),
|
|
62
|
+
task_outcomes: gateway.task_outcomes,
|
|
63
|
+
calibration: gateway.calibration,
|
|
64
|
+
n_sample_agreement: gateway.n_sample_agreement,
|
|
65
|
+
},
|
|
66
|
+
plain_agent: plainAgent,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const out = join(fixturesDir(), "..", "out", "local-benchmark-report.json");
|
|
70
|
+
try {
|
|
71
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
72
|
+
writeFileSync(out, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
73
|
+
} catch {
|
|
74
|
+
// stdout remains the primary contract.
|
|
75
|
+
}
|
|
76
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parsePositiveInt(raw: string | undefined): number | undefined {
|
|
81
|
+
if (!raw) return undefined;
|
|
82
|
+
const value = Number(raw);
|
|
83
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
84
|
+
throw new Error("expected a positive integer");
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function parseStride(raw: string | undefined): number | undefined {
|
|
90
|
+
if (!raw) return undefined;
|
|
91
|
+
const value = Number(raw);
|
|
92
|
+
if (!Number.isInteger(value) || value < 2) {
|
|
93
|
+
throw new Error("UIGW_EVAL_STRIDE must be an integer >= 2");
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
main()
|
|
99
|
+
.then((code) => {
|
|
100
|
+
process.exitCode = code;
|
|
101
|
+
})
|
|
102
|
+
.catch((error) => {
|
|
103
|
+
process.stderr.write(`${(error as Error).message}\n`);
|
|
104
|
+
process.exitCode = 2;
|
|
105
|
+
});
|