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
package/evals/src/baseline.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { buildKnowledgeBase, createDefaultAdapters } from "@uigw/adapters";
|
|
|
4
4
|
import { compileDesignMd, describeDesign } from "@uigw/design-md";
|
|
5
5
|
import { createGateway } from "@uigw/gateway";
|
|
6
6
|
import { buildHandoff } from "@uigw/orchestrator";
|
|
7
|
-
import { GatewayResultSchema, type GatewayResult, type Intent } from "@uigw/protocol";
|
|
7
|
+
import { GatewayResultSchema, type ConfidenceSignals, type GatewayResult, type Intent } from "@uigw/protocol";
|
|
8
8
|
import { detectProject } from "@uigw/profile";
|
|
9
9
|
import {
|
|
10
10
|
parseSelectionResponse,
|
|
@@ -18,9 +18,12 @@ import {
|
|
|
18
18
|
checkThresholds,
|
|
19
19
|
computeCalibration,
|
|
20
20
|
computeMetrics,
|
|
21
|
+
computeTaskOutcomes,
|
|
21
22
|
type CalibrationReport,
|
|
22
23
|
type EvalRecord,
|
|
23
24
|
type MetricsReport,
|
|
25
|
+
type TaskOutcomeRecord,
|
|
26
|
+
type TaskOutcomeReport,
|
|
24
27
|
type Thresholds,
|
|
25
28
|
} from "./metrics";
|
|
26
29
|
import { createLocalLlmSelectionModel, createLocalLlmCall, createOpenAiCompatibleSelectionModel, createOpenAiCompatibleCall, createSimulatedModel, createSimulatedModelCall, type LocalLlmOptions, type OpenAiCompatibleOptions, type SimulatedBehaviorName, simulatedBehaviors, renderPlainPrompt, parsePlainPrompt } from "./local-llm";
|
|
@@ -29,7 +32,13 @@ export interface ArmReport {
|
|
|
29
32
|
name: string;
|
|
30
33
|
description: string;
|
|
31
34
|
metrics: MetricsReport;
|
|
32
|
-
predictions: Array<{
|
|
35
|
+
predictions: Array<{
|
|
36
|
+
item_id: string;
|
|
37
|
+
predicted: string[];
|
|
38
|
+
acceptable: string[];
|
|
39
|
+
confidence: number;
|
|
40
|
+
signals?: ConfidenceSignals;
|
|
41
|
+
}>;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
export interface BaselineModelInfo {
|
|
@@ -57,6 +66,7 @@ export interface BaselineReport {
|
|
|
57
66
|
threshold_checks: ReturnType<typeof checkThresholds>;
|
|
58
67
|
thresholds_passed: boolean;
|
|
59
68
|
calibration: CalibrationReport;
|
|
69
|
+
task_outcomes: TaskOutcomeReport;
|
|
60
70
|
model_info: BaselineModelInfo | null;
|
|
61
71
|
n_sample_agreement: NSampleAgreementReport | null;
|
|
62
72
|
notes: string[];
|
|
@@ -157,6 +167,7 @@ export async function runComparison(options: BaselineOptions = {}): Promise<Base
|
|
|
157
167
|
const normalizedIntents = new Map<string, Intent>();
|
|
158
168
|
|
|
159
169
|
const fullRecords: EvalRecord[] = [];
|
|
170
|
+
const fullTaskRecords: TaskOutcomeRecord[] = [];
|
|
160
171
|
const fullPredictions: ArmReport["predictions"] = [];
|
|
161
172
|
|
|
162
173
|
for (const item of items) {
|
|
@@ -168,8 +179,10 @@ export async function runComparison(options: BaselineOptions = {}): Promise<Base
|
|
|
168
179
|
acceptance_criteria: [{ type: "all_intents_mapped" }],
|
|
169
180
|
});
|
|
170
181
|
normalizedIntents.set(item.item_id, handoff.intents[0]!);
|
|
182
|
+
const started = Date.now();
|
|
171
183
|
const response = await runtime.gateway.submit(handoff);
|
|
172
|
-
const
|
|
184
|
+
const wallMs = Date.now() - started;
|
|
185
|
+
const result = response.result ?? undefined;
|
|
173
186
|
const predicted = predictedIds(result);
|
|
174
187
|
const intent = result?.intents[0];
|
|
175
188
|
fullPredictions.push({
|
|
@@ -177,6 +190,33 @@ export async function runComparison(options: BaselineOptions = {}): Promise<Base
|
|
|
177
190
|
predicted,
|
|
178
191
|
acceptable: item.acceptable,
|
|
179
192
|
confidence: intent?.confidence ?? 0,
|
|
193
|
+
...(intent?.confidence_signals ? { signals: intent.confidence_signals } : {}),
|
|
194
|
+
});
|
|
195
|
+
const checks = intent?.verification?.checks ?? [];
|
|
196
|
+
const checkPassed = (name: string): boolean =>
|
|
197
|
+
checks.find((check) => check.name === name)?.passed ?? true;
|
|
198
|
+
fullTaskRecords.push({
|
|
199
|
+
item_id: item.item_id,
|
|
200
|
+
compiles: intent?.verification?.compiled ?? null,
|
|
201
|
+
lint_clean: Boolean(
|
|
202
|
+
result?.intents.every((entry) =>
|
|
203
|
+
entry.verification ? entry.verification.checks.every((check) => check.passed) : true,
|
|
204
|
+
),
|
|
205
|
+
),
|
|
206
|
+
a11y_clean: checkPassed("a11y"),
|
|
207
|
+
constraints_ok: Boolean(
|
|
208
|
+
result !== undefined &&
|
|
209
|
+
result.intents.every(
|
|
210
|
+
(entry) => !entry.error && (entry.verification?.checks.every((check) => check.passed) ?? true),
|
|
211
|
+
),
|
|
212
|
+
),
|
|
213
|
+
libraries_allowed: (intent?.mappings[0]?.source ?? "local") !== "new" || handoff.strict === false,
|
|
214
|
+
tokens_matched: null,
|
|
215
|
+
tool_calls: 1,
|
|
216
|
+
tokens: null,
|
|
217
|
+
wall_ms: wallMs,
|
|
218
|
+
predicted,
|
|
219
|
+
acceptable: item.acceptable,
|
|
180
220
|
});
|
|
181
221
|
fullRecords.push({
|
|
182
222
|
item_id: item.item_id,
|
|
@@ -184,17 +224,17 @@ export async function runComparison(options: BaselineOptions = {}): Promise<Base
|
|
|
184
224
|
acceptable: item.acceptable,
|
|
185
225
|
schema_valid: Boolean(result && GatewayResultSchema.safeParse(result).success),
|
|
186
226
|
constraints_ok: Boolean(
|
|
187
|
-
|
|
188
|
-
result
|
|
227
|
+
result !== undefined &&
|
|
228
|
+
result.intents.every(
|
|
189
229
|
(entry) => !entry.error && (entry.verification?.checks.every((check) => check.passed) ?? true),
|
|
190
230
|
),
|
|
191
231
|
),
|
|
192
232
|
confidence: intent?.confidence ?? 0,
|
|
193
|
-
outcome: response.
|
|
233
|
+
outcome: response.outcome,
|
|
194
234
|
invalid_imports: [],
|
|
195
235
|
invalid_props: [],
|
|
196
236
|
turns_to_green: 0,
|
|
197
|
-
refused:
|
|
237
|
+
refused: result === undefined || result.intents.length === 0,
|
|
198
238
|
refusal_correct: item.acceptable.length === 0,
|
|
199
239
|
unsafe_accept: predicted.length > 0 && !item.acceptable.includes(predicted[0]!),
|
|
200
240
|
});
|
|
@@ -277,6 +317,7 @@ export async function runComparison(options: BaselineOptions = {}): Promise<Base
|
|
|
277
317
|
threshold_checks: thresholdChecks,
|
|
278
318
|
thresholds_passed: thresholdChecks.every((check) => check.passed),
|
|
279
319
|
calibration,
|
|
320
|
+
task_outcomes: computeTaskOutcomes(fullTaskRecords),
|
|
280
321
|
model_info: modelInfo,
|
|
281
322
|
n_sample_agreement: nSampleAgreement,
|
|
282
323
|
notes: [
|
|
@@ -18,6 +18,7 @@ Options:
|
|
|
18
18
|
--output-dir <dir> Output directory for labels (default: out/blind-labels/<annotator>)
|
|
19
19
|
--limit <n> Limit items to label in this session
|
|
20
20
|
--blind-only Only label items with blind: true flag
|
|
21
|
+
--relabel <fraction> Re-label this fraction (e.g. 0.15) to measure self-agreement
|
|
21
22
|
--help, -h Show this help
|
|
22
23
|
|
|
23
24
|
Example:
|
|
@@ -48,6 +49,9 @@ Format: library/component (e.g., shadcn/button, mui/text-field)
|
|
|
48
49
|
const limit = limitIdx !== -1 && limitIdx + 1 < args.length ? parseInt(args[limitIdx + 1], 10) : undefined;
|
|
49
50
|
|
|
50
51
|
const blindOnly = args.includes("--blind-only");
|
|
52
|
+
const relabelIdx = args.indexOf("--relabel");
|
|
53
|
+
const relabelFraction =
|
|
54
|
+
relabelIdx !== -1 && relabelIdx + 1 < args.length ? Number(args[relabelIdx + 1]) : undefined;
|
|
51
55
|
|
|
52
56
|
try {
|
|
53
57
|
await blindLabelCommand(fixturesDir(), {
|
|
@@ -56,6 +60,7 @@ Format: library/component (e.g., shadcn/button, mui/text-field)
|
|
|
56
60
|
outputDir,
|
|
57
61
|
limit,
|
|
58
62
|
blindOnly,
|
|
63
|
+
...(relabelFraction && Number.isFinite(relabelFraction) ? { relabelFraction } : {}),
|
|
59
64
|
});
|
|
60
65
|
return 0;
|
|
61
66
|
} catch (error) {
|
|
@@ -59,6 +59,8 @@ export async function blindLabelCommand(
|
|
|
59
59
|
limit?: number;
|
|
60
60
|
/** Only label items with blind: true. */
|
|
61
61
|
blindOnly?: boolean;
|
|
62
|
+
/** Re-label this fraction (e.g. 0.15) on a second pass to measure self-agreement. */
|
|
63
|
+
relabelFraction?: number;
|
|
62
64
|
},
|
|
63
65
|
): Promise<void> {
|
|
64
66
|
const inputPath = options.inputFile ?? join(fixturesDir, "blind-labeling.json");
|
|
@@ -201,6 +203,50 @@ export async function blindLabelCommand(
|
|
|
201
203
|
|
|
202
204
|
process.stdout.write(` recorded: ${answer}\n`);
|
|
203
205
|
}
|
|
206
|
+
|
|
207
|
+
const fraction = options.relabelFraction ?? 0;
|
|
208
|
+
if (fraction > 0) {
|
|
209
|
+
const firstPass = readFileSync(labelsPath, "utf8")
|
|
210
|
+
.split("\n")
|
|
211
|
+
.filter(Boolean)
|
|
212
|
+
.map((line) => JSON.parse(line) as BlindLabelRecord);
|
|
213
|
+
if (firstPass.length > 0) {
|
|
214
|
+
const wanted = Math.max(1, Math.round(firstPass.length * Math.min(1, fraction)));
|
|
215
|
+
const step = Math.max(1, Math.floor(firstPass.length / wanted));
|
|
216
|
+
const sampled = firstPass.filter((_, index) => index % step === 0).slice(0, wanted);
|
|
217
|
+
process.stdout.write(`\n=== RELABEL PASS (${sampled.length} of ${firstPass.length}, self-agreement) ===\n`);
|
|
218
|
+
process.stdout.write(`Re-answer the same items without looking at your first answer.\n`);
|
|
219
|
+
const relabels: Array<{ item_id: string; first: string; second: string; match: boolean }> = [];
|
|
220
|
+
for (const record of sampled) {
|
|
221
|
+
const item = items.find((candidate) => candidate.item_id === record.item_id);
|
|
222
|
+
if (!item) continue;
|
|
223
|
+
process.stdout.write(`\n${item.item_id} — ${item.intent_type}\n Description: ${item.description}\n`);
|
|
224
|
+
const answer = await ask(` Relabel component ID (or skip) > `);
|
|
225
|
+
if (!answer || answer === "skip" || answer === "quit") continue;
|
|
226
|
+
if (!/^[a-z0-9-]+\/[a-z0-9-]+$/.test(answer)) {
|
|
227
|
+
process.stdout.write(` Invalid format; skipped\n`);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
relabels.push({ item_id: record.item_id, first: record.label ?? "", second: answer, match: record.label === answer });
|
|
231
|
+
}
|
|
232
|
+
const matches = relabels.filter((entry) => entry.match).length;
|
|
233
|
+
writeFileSync(
|
|
234
|
+
join(outputDir, "self-agreement.json"),
|
|
235
|
+
JSON.stringify(
|
|
236
|
+
{
|
|
237
|
+
annotator_id: options.annotatorId,
|
|
238
|
+
sampled: relabels.length,
|
|
239
|
+
matches,
|
|
240
|
+
rate: relabels.length > 0 ? matches / relabels.length : null,
|
|
241
|
+
relabels,
|
|
242
|
+
},
|
|
243
|
+
null,
|
|
244
|
+
2,
|
|
245
|
+
),
|
|
246
|
+
);
|
|
247
|
+
process.stdout.write(`\nSelf-agreement: ${matches}/${relabels.length} (${((relabels.length ? matches / relabels.length : 0) * 100).toFixed(1)}%)\n`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
204
250
|
} finally {
|
|
205
251
|
rl.close();
|
|
206
252
|
session.completed_at = new Date().toISOString();
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { deriveDesignMd } from "@uigw/design-md";
|
|
5
|
+
import { detectProject, profileNeedsInput } from "@uigw/profile";
|
|
6
|
+
|
|
7
|
+
export interface ExternalRepo {
|
|
8
|
+
name: string;
|
|
9
|
+
repo: string;
|
|
10
|
+
ref: string;
|
|
11
|
+
subdir?: string;
|
|
12
|
+
library: string;
|
|
13
|
+
framework: string;
|
|
14
|
+
resolved_commit?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ExternalRepoResult {
|
|
18
|
+
name: string;
|
|
19
|
+
repo: string;
|
|
20
|
+
ref: string;
|
|
21
|
+
resolved_commit: string | null;
|
|
22
|
+
cloned: boolean;
|
|
23
|
+
detected: boolean;
|
|
24
|
+
framework: string | null;
|
|
25
|
+
styling: string[];
|
|
26
|
+
libraries: string[];
|
|
27
|
+
local_components: number;
|
|
28
|
+
needs_input: string[];
|
|
29
|
+
design_md_ok: boolean;
|
|
30
|
+
design_sources: string[];
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const DEFAULT_CACHE = ".tmp/external-repos";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Resolve pins without cloning. Useful in CI and on machines where cloning the
|
|
38
|
+
* full shallow history is expensive: `git ls-remote` still returns the exact
|
|
39
|
+
* commit for a branch or tag, which is all reproducibility needs.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveExternalPins(options: {
|
|
42
|
+
fixturePath?: string;
|
|
43
|
+
only?: string[];
|
|
44
|
+
} = {}): { results: Array<{ name: string; repo: string; ref: string; resolved_commit: string | null; error?: string }>; fixturePath: string } {
|
|
45
|
+
const fixturePath = resolve(options.fixturePath ?? join("evals", "fixtures", "external-repos.json"));
|
|
46
|
+
const fixture = JSON.parse(readFileSync(fixturePath, "utf8")) as { repos: ExternalRepo[] };
|
|
47
|
+
const results: Array<{ name: string; repo: string; ref: string; resolved_commit: string | null; error?: string }> = [];
|
|
48
|
+
for (const repo of fixture.repos) {
|
|
49
|
+
if (options.only && options.only.length > 0 && !options.only.includes(repo.name)) continue;
|
|
50
|
+
try {
|
|
51
|
+
const output = execFileSync("git", ["ls-remote", repo.repo, repo.ref], { encoding: "utf8" });
|
|
52
|
+
const lines = output
|
|
53
|
+
.split("\n")
|
|
54
|
+
.map((line) => line.trim().split(/\s+/))
|
|
55
|
+
.filter((parts) => parts.length === 2);
|
|
56
|
+
const exactRef = (suffix: string) =>
|
|
57
|
+
lines.find((parts) => parts[1] === `refs/tags/${repo.ref}${suffix}`)?.[0] ??
|
|
58
|
+
lines.find((parts) => parts[1] === `refs/heads/${repo.ref}`)?.[0] ??
|
|
59
|
+
lines.find((parts) => parts[1] === `refs/tags/${repo.ref}`)?.[0];
|
|
60
|
+
const commit = exactRef("^{}") ?? exactRef("") ?? lines[0]?.[0] ?? null;
|
|
61
|
+
if (!commit) throw new Error(`could not resolve ${repo.ref}`);
|
|
62
|
+
repo.resolved_commit = commit;
|
|
63
|
+
results.push({ name: repo.name, repo: repo.repo, ref: repo.ref, resolved_commit: commit });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
results.push({
|
|
66
|
+
name: repo.name,
|
|
67
|
+
repo: repo.repo,
|
|
68
|
+
ref: repo.ref,
|
|
69
|
+
resolved_commit: repo.resolved_commit ?? null,
|
|
70
|
+
error: (error as Error).message,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(fixturePath, `${JSON.stringify(fixture, null, 2)}\n`, "utf8");
|
|
75
|
+
return { results, fixturePath };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Clone pinned open-source repos and run real detection + Design MD derivation
|
|
80
|
+
* on them. Clones are shallow and cached; `updatePins` writes the resolved
|
|
81
|
+
* commit back to the fixture so a later run checks out the same code.
|
|
82
|
+
*/
|
|
83
|
+
export function runExternalRepos(options: {
|
|
84
|
+
fixturePath?: string;
|
|
85
|
+
cacheDir?: string;
|
|
86
|
+
updatePins?: boolean;
|
|
87
|
+
only?: string[];
|
|
88
|
+
} = {}): { results: ExternalRepoResult[]; fixturePath: string } {
|
|
89
|
+
const fixturePath = resolve(options.fixturePath ?? join("evals", "fixtures", "external-repos.json"));
|
|
90
|
+
const cacheDir = resolve(options.cacheDir ?? DEFAULT_CACHE);
|
|
91
|
+
const fixture = JSON.parse(readFileSync(fixturePath, "utf8")) as { repos: ExternalRepo[] };
|
|
92
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
93
|
+
const results: ExternalRepoResult[] = [];
|
|
94
|
+
|
|
95
|
+
for (const repo of fixture.repos) {
|
|
96
|
+
if (options.only && options.only.length > 0 && !options.only.includes(repo.name)) continue;
|
|
97
|
+
const checkout = join(cacheDir, repo.name);
|
|
98
|
+
let cloned = false;
|
|
99
|
+
try {
|
|
100
|
+
if (!existsSync(join(checkout, ".git"))) {
|
|
101
|
+
execFileSync("git", ["clone", "--depth", "1", "--branch", repo.ref, repo.repo, checkout], {
|
|
102
|
+
stdio: "pipe",
|
|
103
|
+
});
|
|
104
|
+
cloned = true;
|
|
105
|
+
} else {
|
|
106
|
+
execFileSync("git", ["fetch", "--depth", "1", "origin", repo.ref], { cwd: checkout, stdio: "pipe" });
|
|
107
|
+
execFileSync("git", ["checkout", "--force", "FETCH_HEAD"], { cwd: checkout, stdio: "pipe" });
|
|
108
|
+
}
|
|
109
|
+
if (repo.resolved_commit) {
|
|
110
|
+
try {
|
|
111
|
+
execFileSync("git", ["checkout", "--force", repo.resolved_commit], { cwd: checkout, stdio: "pipe" });
|
|
112
|
+
} catch {
|
|
113
|
+
// The pin may be unreachable in a shallow clone; the resolved commit
|
|
114
|
+
// below records what was actually checked out.
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const commit = execFileSync("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" }).trim();
|
|
118
|
+
const dir = repo.subdir ? join(checkout, ...repo.subdir.split("/")) : checkout;
|
|
119
|
+
if (!existsSync(dir)) throw new Error(`subdirectory not found: ${repo.subdir}`);
|
|
120
|
+
const profile = detectProject(dir);
|
|
121
|
+
const derived = deriveDesignMd(dir, {
|
|
122
|
+
libraries: profile.libraries.value.map((library) => library.id),
|
|
123
|
+
supportedLibraries: [
|
|
124
|
+
"shadcn",
|
|
125
|
+
"mui",
|
|
126
|
+
"chakra",
|
|
127
|
+
"mantine",
|
|
128
|
+
"nuxt-ui",
|
|
129
|
+
"radix",
|
|
130
|
+
"antd",
|
|
131
|
+
"bootstrap",
|
|
132
|
+
"vue",
|
|
133
|
+
"svelte",
|
|
134
|
+
"angular",
|
|
135
|
+
"solid",
|
|
136
|
+
],
|
|
137
|
+
mode: profile.mode,
|
|
138
|
+
});
|
|
139
|
+
results.push({
|
|
140
|
+
name: repo.name,
|
|
141
|
+
repo: repo.repo,
|
|
142
|
+
ref: repo.ref,
|
|
143
|
+
resolved_commit: commit,
|
|
144
|
+
cloned,
|
|
145
|
+
detected: true,
|
|
146
|
+
framework: profile.framework.value,
|
|
147
|
+
styling: profile.styling.value,
|
|
148
|
+
libraries: profile.libraries.value.map((library) => library.id),
|
|
149
|
+
local_components: profile.local_components.value.length,
|
|
150
|
+
needs_input: profileNeedsInput(profile),
|
|
151
|
+
design_md_ok: derived.ok,
|
|
152
|
+
design_sources: derived.sources,
|
|
153
|
+
});
|
|
154
|
+
if (options.updatePins) repo.resolved_commit = commit;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
results.push({
|
|
157
|
+
name: repo.name,
|
|
158
|
+
repo: repo.repo,
|
|
159
|
+
ref: repo.ref,
|
|
160
|
+
resolved_commit: repo.resolved_commit ?? null,
|
|
161
|
+
cloned,
|
|
162
|
+
detected: false,
|
|
163
|
+
framework: null,
|
|
164
|
+
styling: [],
|
|
165
|
+
libraries: [],
|
|
166
|
+
local_components: 0,
|
|
167
|
+
needs_input: [],
|
|
168
|
+
design_md_ok: false,
|
|
169
|
+
design_sources: [],
|
|
170
|
+
error: (error as Error).message,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (options.updatePins) {
|
|
176
|
+
writeFileSync(fixturePath, `${JSON.stringify(fixture, null, 2)}\n`, "utf8");
|
|
177
|
+
}
|
|
178
|
+
return { results, fixturePath };
|
|
179
|
+
}
|
package/evals/src/metrics.ts
CHANGED
|
@@ -54,6 +54,42 @@ export interface MetricsReport {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export interface TaskOutcomeRecord {
|
|
58
|
+
item_id: string;
|
|
59
|
+
/** The project's real tsc accepted the generated code. */
|
|
60
|
+
compiles: boolean | null;
|
|
61
|
+
/** The page checks reported no error-severity findings. */
|
|
62
|
+
lint_clean: boolean;
|
|
63
|
+
/** Basic a11y checks passed (alt text, accessible names, main landmark). */
|
|
64
|
+
a11y_clean: boolean;
|
|
65
|
+
/** No forbidden library/pattern from the Design MD. */
|
|
66
|
+
constraints_ok: boolean;
|
|
67
|
+
/** Only installed or Design-MD-allowed libraries were imported. */
|
|
68
|
+
libraries_allowed: boolean;
|
|
69
|
+
/** Design MD token names appear where the generated code uses literal values. */
|
|
70
|
+
tokens_matched: boolean | null;
|
|
71
|
+
tool_calls: number;
|
|
72
|
+
tokens: number | null;
|
|
73
|
+
wall_ms: number;
|
|
74
|
+
predicted: string[];
|
|
75
|
+
acceptable: string[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface TaskOutcomeReport {
|
|
79
|
+
n: number;
|
|
80
|
+
compile_rate: number;
|
|
81
|
+
compile_interval: WilsonInterval;
|
|
82
|
+
lint_clean_rate: number;
|
|
83
|
+
a11y_clean_rate: number;
|
|
84
|
+
constraint_free_rate: number;
|
|
85
|
+
library_compliance_rate: number;
|
|
86
|
+
token_match_rate: number | null;
|
|
87
|
+
acceptable_set_hit_rate: number;
|
|
88
|
+
mean_tool_calls: number;
|
|
89
|
+
mean_tokens: number | null;
|
|
90
|
+
mean_wall_ms: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
57
93
|
export interface WilsonInterval {
|
|
58
94
|
low: number;
|
|
59
95
|
high: number;
|
|
@@ -158,6 +194,40 @@ export function computeCalibration(records: EvalRecord[], binCount = 10): Calibr
|
|
|
158
194
|
};
|
|
159
195
|
}
|
|
160
196
|
|
|
197
|
+
export function computeTaskOutcomes(records: TaskOutcomeRecord[]): TaskOutcomeReport {
|
|
198
|
+
const n = records.length;
|
|
199
|
+
const compiled = records.filter((record) => record.compiles === true).length;
|
|
200
|
+
const withTokens = records.filter((record) => record.tokens_matched !== null);
|
|
201
|
+
return {
|
|
202
|
+
n,
|
|
203
|
+
compile_rate: rate(compiled, records.filter((record) => record.compiles !== null).length),
|
|
204
|
+
compile_interval: wilsonInterval(compiled, Math.max(1, records.filter((record) => record.compiles !== null).length)),
|
|
205
|
+
lint_clean_rate: rate(records.filter((record) => record.lint_clean).length, n),
|
|
206
|
+
a11y_clean_rate: rate(records.filter((record) => record.a11y_clean).length, n),
|
|
207
|
+
constraint_free_rate: rate(records.filter((record) => record.constraints_ok).length, n),
|
|
208
|
+
library_compliance_rate: rate(records.filter((record) => record.libraries_allowed).length, n),
|
|
209
|
+
token_match_rate:
|
|
210
|
+
withTokens.length > 0
|
|
211
|
+
? rate(withTokens.filter((record) => record.tokens_matched).length, withTokens.length)
|
|
212
|
+
: null,
|
|
213
|
+
acceptable_set_hit_rate: rate(
|
|
214
|
+
records.filter(
|
|
215
|
+
(record) => record.predicted.length > 0 && record.acceptable.includes(record.predicted[0]!),
|
|
216
|
+
).length,
|
|
217
|
+
n,
|
|
218
|
+
),
|
|
219
|
+
mean_tool_calls: n > 0 ? round(records.reduce((sum, record) => sum + record.tool_calls, 0) / n) : 0,
|
|
220
|
+
mean_tokens:
|
|
221
|
+
records.some((record) => record.tokens !== null)
|
|
222
|
+
? round(
|
|
223
|
+
records.reduce((sum, record) => sum + (record.tokens ?? 0), 0) /
|
|
224
|
+
Math.max(1, records.filter((record) => record.tokens !== null).length),
|
|
225
|
+
)
|
|
226
|
+
: null,
|
|
227
|
+
mean_wall_ms: n > 0 ? round(records.reduce((sum, record) => sum + record.wall_ms, 0) / n) : 0,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
161
231
|
function isCorrect(record: EvalRecord): boolean {
|
|
162
232
|
return record.predicted.length > 0 && record.acceptable.includes(record.predicted[0]!);
|
|
163
233
|
}
|
package/evals/src/mutations.ts
CHANGED
|
@@ -216,12 +216,12 @@ export async function runMutationHarness(gateway: Gateway, baseHandoff: Handoff)
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
function describeResponse(response: Awaited<ReturnType<Gateway["submit"]>>): MutationResult["actual"] {
|
|
219
|
-
if (!response.
|
|
220
|
-
return { ok: false, code: response.error
|
|
219
|
+
if (!response.result) {
|
|
220
|
+
return { ok: false, code: response.error?.code, outcome: response.outcome };
|
|
221
221
|
}
|
|
222
222
|
const intentError = response.result.intents.find((intent) => intent.error)?.error;
|
|
223
223
|
return {
|
|
224
|
-
ok:
|
|
224
|
+
ok: response.ok,
|
|
225
225
|
code: response.result.errors[0]?.code ?? intentError?.code,
|
|
226
226
|
outcome: response.result.outcome,
|
|
227
227
|
};
|
|
@@ -232,13 +232,13 @@ function matches(
|
|
|
232
232
|
response: Awaited<ReturnType<Gateway["submit"]>>,
|
|
233
233
|
): boolean {
|
|
234
234
|
if ("error_code" in expected) {
|
|
235
|
-
if (!response.
|
|
235
|
+
if (!response.result) return response.error?.code === expected.error_code;
|
|
236
236
|
return response.result.errors.some((error) => error.code === expected.error_code);
|
|
237
237
|
}
|
|
238
238
|
if ("intent_error_code" in expected) {
|
|
239
|
-
if (!response.
|
|
239
|
+
if (!response.result) return false;
|
|
240
240
|
return response.result.intents.some((intent) => intent.error?.code === expected.intent_error_code);
|
|
241
241
|
}
|
|
242
|
-
if (!response.
|
|
242
|
+
if (!response.result) return false;
|
|
243
243
|
return response.result.outcome === expected.outcome;
|
|
244
244
|
}
|