niceeval 0.6.1 → 0.7.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/INDEX.md +23 -23
- package/README.zh.md +6 -6
- package/dist/agents/types.d.ts +69 -7
- package/dist/context/types.d.ts +32 -12
- package/dist/i18n/en.d.ts +54 -0
- package/dist/i18n/zh-CN.d.ts +57 -3
- package/dist/o11y/types.d.ts +16 -2
- package/dist/report/aggregate.d.ts +32 -24
- package/dist/report/aggregate.js +158 -50
- package/dist/report/built-in/index.d.ts +2 -0
- package/dist/report/built-in/index.js +8 -0
- package/dist/report/components.d.ts +93 -160
- package/dist/report/components.js +377 -114
- package/dist/report/compute.d.ts +87 -81
- package/dist/report/compute.js +597 -417
- package/dist/report/flag.d.ts +32 -6
- package/dist/report/flag.js +92 -4
- package/dist/report/format.d.ts +19 -11
- package/dist/report/format.js +30 -13
- package/dist/report/index.d.ts +16 -16
- package/dist/report/index.js +20 -21
- package/dist/report/load.js +3 -2
- package/dist/report/locale.d.ts +57 -33
- package/dist/report/locale.js +122 -56
- package/dist/report/metrics.d.ts +23 -4
- package/dist/report/metrics.js +110 -25
- package/dist/report/primitives.d.ts +48 -15
- package/dist/report/primitives.js +135 -26
- package/dist/report/react/AttemptList.d.ts +9 -7
- package/dist/report/react/AttemptList.js +17 -10
- package/dist/report/react/DeltaTable.js +19 -18
- package/dist/report/react/EvalList.d.ts +4 -4
- package/dist/report/react/EvalList.js +0 -0
- package/dist/report/react/ExperimentComparison.d.ts +10 -0
- package/dist/report/react/ExperimentComparison.js +12 -0
- package/dist/report/react/ExperimentList.d.ts +4 -3
- package/dist/report/react/ExperimentList.js +17 -18
- package/dist/report/react/MetricBars.js +5 -4
- package/dist/report/react/MetricLine.js +12 -5
- package/dist/report/react/MetricMatrix.js +1 -1
- package/dist/report/react/MetricScatter.js +59 -28
- package/dist/report/react/MetricTable.js +2 -12
- package/dist/report/react/ScopeSummary.d.ts +10 -0
- package/dist/report/react/ScopeSummary.js +17 -0
- package/dist/report/react/Scoreboard.js +6 -6
- package/dist/report/react/cell.js +2 -2
- package/dist/report/react/chart-math.d.ts +23 -6
- package/dist/report/react/chart-math.js +71 -19
- package/dist/report/react/fixtures.d.ts +5 -9
- package/dist/report/react/fixtures.js +110 -147
- package/dist/report/react/index.d.ts +15 -5
- package/dist/report/react/index.js +18 -7
- package/dist/report/report.d.ts +137 -16
- package/dist/report/report.js +259 -28
- package/dist/report/text/faces.d.ts +17 -19
- package/dist/report/text/faces.js +253 -184
- package/dist/report/text/plot.js +1 -1
- package/dist/report/text/table.js +38 -7
- package/dist/report/tree.d.ts +90 -40
- package/dist/report/tree.js +252 -94
- package/dist/report/types.d.ts +247 -284
- package/dist/report/types.js +4 -3
- package/dist/report/web.d.ts +21 -5
- package/dist/report/web.js +42 -16
- package/dist/results/select.d.ts +38 -16
- package/dist/results/select.js +73 -25
- package/dist/results/types.d.ts +49 -14
- package/dist/runner/feedback/sink.d.ts +110 -0
- package/dist/runner/types.d.ts +513 -22
- package/dist/sandbox/docker.d.ts +23 -2
- package/dist/sandbox/e2b.d.ts +15 -1
- package/dist/sandbox/errors.d.ts +30 -3
- package/dist/sandbox/io-retry.d.ts +17 -0
- package/dist/sandbox/registry.d.ts +2 -0
- package/dist/sandbox/resolve.d.ts +18 -5
- package/dist/sandbox/retry.d.ts +11 -1
- package/dist/sandbox/types.d.ts +39 -5
- package/dist/sandbox/vercel.d.ts +7 -1
- package/dist/scoring/coverage.d.ts +30 -0
- package/dist/scoring/display.d.ts +21 -0
- package/dist/scoring/display.js +120 -0
- package/dist/scoring/types.d.ts +103 -20
- package/dist/shared/aggregate.d.ts +4 -2
- package/dist/shared/aggregate.js +8 -7
- package/dist/shared/types.d.ts +28 -0
- package/dist/tty-line.d.ts +0 -4
- package/dist/util.d.ts +23 -0
- package/docs-site/zh/README.md +44 -0
- package/docs-site/zh/examples/ai-agent-application.mdx +63 -0
- package/docs-site/zh/examples/coding-agent-extensions.mdx +57 -0
- package/docs-site/zh/examples/index.mdx +50 -0
- package/docs-site/zh/{concepts → explanation}/adapter.mdx +31 -13
- package/docs-site/zh/{concepts → explanation}/assert.mdx +7 -7
- package/docs-site/zh/{concepts → explanation}/drive.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/evals.mdx +4 -4
- package/docs-site/zh/{concepts → explanation}/experiment.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/hitl.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/judge.mdx +5 -5
- package/docs-site/zh/{concepts → explanation}/overview.mdx +11 -11
- package/docs-site/zh/{guides → explanation}/runner.mdx +18 -8
- package/docs-site/zh/{concepts → explanation}/tier.mdx +6 -6
- package/docs-site/zh/{guides → how-to}/agent-feedback-loop.mdx +35 -33
- package/docs-site/zh/{guides → how-to}/authoring.mdx +35 -2
- package/docs-site/zh/{guides → how-to}/ci-integration.mdx +23 -12
- package/docs-site/zh/{guides → how-to}/connect-otel.mdx +6 -6
- package/docs-site/zh/{guides → how-to}/connect-your-agent.mdx +47 -21
- package/docs-site/zh/{guides → how-to}/custom-reports.mdx +34 -39
- package/docs-site/zh/{guides → how-to}/dataset-fanout.mdx +25 -3
- package/docs-site/zh/{guides → how-to}/experiments.mdx +12 -5
- package/docs-site/zh/how-to/publish-report.mdx +105 -0
- package/docs-site/zh/{guides → how-to}/reporters.mdx +2 -2
- package/docs-site/zh/{guides → how-to}/sandbox-agent.mdx +56 -7
- package/docs-site/zh/how-to/sandbox-providers.mdx +350 -0
- package/docs-site/zh/{guides → how-to}/scoring-guide.mdx +4 -4
- package/docs-site/zh/{guides → how-to}/viewing-results.mdx +82 -39
- package/docs-site/zh/{guides → how-to}/write-experiment.mdx +6 -4
- package/docs-site/zh/{guides → how-to}/write-send.mdx +30 -14
- package/docs-site/zh/index.mdx +24 -26
- package/docs-site/zh/introduction.mdx +8 -8
- package/docs-site/zh/reference/builtin-agents.mdx +32 -5
- package/docs-site/zh/reference/capabilities.mdx +8 -8
- package/docs-site/zh/reference/cli.mdx +40 -12
- package/docs-site/zh/reference/define-agent.mdx +58 -5
- package/docs-site/zh/reference/define-config.mdx +1 -1
- package/docs-site/zh/reference/define-eval.mdx +42 -9
- package/docs-site/zh/reference/events.mdx +3 -3
- package/docs-site/zh/reference/expect.mdx +26 -1
- package/docs-site/zh/{guides → reference}/official-adapters.mdx +32 -8
- package/docs-site/zh/{guides → reference}/report-components.mdx +45 -33
- package/docs-site/zh/{guides → reference}/results-data.mdx +21 -13
- package/docs-site/zh/troubleshooting/debug-sandbox.mdx +57 -0
- package/docs-site/zh/troubleshooting/debugging.mdx +212 -0
- package/docs-site/zh/{quickstart.mdx → tutorials/quickstart.mdx} +5 -17
- package/package.json +10 -2
- package/src/agents/ai-sdk-otel.test.ts +1 -0
- package/src/agents/ai-sdk.test.ts +3 -0
- package/src/agents/ai-sdk.ts +3 -0
- package/src/agents/bub-install-spec.test.ts +34 -0
- package/src/agents/bub-install-spec.ts +32 -0
- package/src/agents/bub.ts +31 -32
- package/src/agents/claude-code.test.ts +130 -9
- package/src/agents/claude-code.ts +76 -4
- package/src/agents/codex.test.ts +189 -40
- package/src/agents/codex.ts +155 -14
- package/src/agents/coding-cli-versions.test.ts +15 -0
- package/src/agents/coding-cli-versions.ts +3 -0
- package/src/agents/index.ts +13 -2
- package/src/agents/langgraph.test.ts +204 -0
- package/src/agents/langgraph.ts +495 -0
- package/src/agents/marketplace.ts +85 -0
- package/src/agents/native-config.test.ts +179 -0
- package/src/agents/native-config.ts +267 -0
- package/src/agents/openai-compat.test.ts +1 -0
- package/src/agents/openai-compat.ts +1 -1
- package/src/agents/openclaw.test.ts +31 -0
- package/src/agents/openclaw.ts +171 -0
- package/src/agents/plugin-config.test.ts +1 -0
- package/src/agents/sdk-streams.test.ts +79 -0
- package/src/agents/sdk-streams.ts +55 -10
- package/src/agents/skills.test.ts +1 -0
- package/src/agents/streaming.test.ts +3 -9
- package/src/agents/streaming.ts +2 -2
- package/src/agents/types.ts +71 -8
- package/src/agents/ui-message-stream.test.ts +3 -0
- package/src/cli.ts +446 -124
- package/src/context/context.test.ts +51 -12
- package/src/context/context.ts +162 -30
- package/src/context/session.test.ts +2 -1
- package/src/context/session.ts +115 -7
- package/src/context/types.ts +30 -12
- package/src/define.test.ts +13 -8
- package/src/define.ts +25 -4
- package/src/expect/index.ts +53 -23
- package/src/i18n/en.ts +81 -17
- package/src/i18n/zh-CN.ts +80 -17
- package/src/o11y/cost.test.ts +1 -0
- package/src/o11y/execution-tree.test.ts +1 -20
- package/src/o11y/otlp/mappers/claude-code.test.ts +1 -0
- package/src/o11y/otlp/parse.test.ts +1 -0
- package/src/o11y/otlp/turn-otel.test.ts +1 -0
- package/src/o11y/parsers/bub.test.ts +1 -0
- package/src/o11y/parsers/claude-code.test.ts +1 -34
- package/src/o11y/parsers/openclaw.test.ts +154 -0
- package/src/o11y/parsers/openclaw.ts +310 -0
- package/src/o11y/prices.json +746 -311
- package/src/o11y/tool-names.test.ts +1 -0
- package/src/o11y/types.ts +16 -2
- package/src/report/aggregate.ts +178 -61
- package/src/report/built-in/index.tsx +9 -0
- package/src/report/components.tsx +625 -279
- package/src/report/compute.ts +723 -491
- package/src/report/dual-render.test.tsx +741 -1024
- package/src/report/flag.ts +104 -12
- package/src/report/format.ts +32 -12
- package/src/report/index.ts +119 -46
- package/src/report/load.ts +3 -2
- package/src/report/locale.ts +136 -65
- package/src/report/metrics.ts +108 -25
- package/src/report/primitives.tsx +196 -45
- package/src/report/react/AttemptList.tsx +30 -43
- package/src/report/react/DeltaTable.tsx +63 -45
- package/src/report/react/EvalList.tsx +0 -0
- package/src/report/react/ExperimentComparison.tsx +73 -0
- package/src/report/react/ExperimentList.tsx +50 -32
- package/src/report/react/MetricBars.tsx +5 -4
- package/src/report/react/MetricLine.tsx +13 -8
- package/src/report/react/MetricMatrix.tsx +2 -2
- package/src/report/react/MetricScatter.tsx +86 -34
- package/src/report/react/MetricTable.tsx +4 -76
- package/src/report/react/ScopeSummary.tsx +86 -0
- package/src/report/react/Scoreboard.tsx +28 -10
- package/src/report/react/cell.tsx +2 -2
- package/src/report/react/chart-math.test.ts +85 -0
- package/src/report/react/chart-math.ts +101 -22
- package/src/report/react/enhance.js +89 -5
- package/src/report/react/fixtures.ts +114 -154
- package/src/report/react/index.tsx +24 -39
- package/src/report/react/render.test.tsx +138 -158
- package/src/report/react/styles.css +243 -82
- package/src/report/report.test.ts +779 -841
- package/src/report/report.ts +423 -41
- package/src/report/text/faces.ts +290 -193
- package/src/report/text/plot.ts +1 -1
- package/src/report/text/table.ts +44 -7
- package/src/report/tree.ts +362 -104
- package/src/report/types.ts +261 -271
- package/src/report/web.ts +63 -20
- package/src/results/annotated-source.test.ts +62 -9
- package/src/results/annotated-source.ts +64 -6
- package/src/results/attempt-evidence.test.ts +13 -11
- package/src/results/attempt-evidence.ts +20 -13
- package/src/results/attempt-source.ts +6 -3
- package/src/results/copy.ts +150 -60
- package/src/results/host-equivalence.test.ts +34 -20
- package/src/results/index.ts +12 -4
- package/src/results/locator.test.ts +1 -22
- package/src/results/open.ts +15 -5
- package/src/results/publish.ts +149 -0
- package/src/results/results.test.ts +89 -54
- package/src/results/select.ts +104 -34
- package/src/results/truncate.ts +90 -0
- package/src/results/types.ts +43 -14
- package/src/results/writer.ts +31 -13
- package/src/runner/attempt.test.ts +138 -7
- package/src/runner/attempt.ts +603 -104
- package/src/runner/discover.test.ts +47 -0
- package/src/runner/discover.ts +36 -2
- package/src/runner/eval-source.test.ts +1 -27
- package/src/runner/feedback/agent.test.ts +504 -0
- package/src/runner/feedback/agent.ts +409 -0
- package/src/runner/feedback/ci.test.ts +562 -0
- package/src/runner/feedback/ci.ts +401 -0
- package/src/runner/feedback/coordinator.test.ts +317 -0
- package/src/runner/feedback/coordinator.ts +397 -0
- package/src/runner/feedback/failure.ts +40 -0
- package/src/runner/feedback/human.test.ts +616 -0
- package/src/runner/feedback/human.ts +535 -0
- package/src/runner/feedback/index.ts +66 -0
- package/src/runner/feedback/io.ts +78 -0
- package/src/runner/feedback/profile.test.ts +50 -0
- package/src/runner/feedback/profile.ts +58 -0
- package/src/runner/feedback/reducer.test.ts +395 -0
- package/src/runner/feedback/reducer.ts +260 -0
- package/src/runner/feedback/renderer.ts +82 -0
- package/src/runner/feedback/sink.ts +203 -0
- package/src/runner/feedback/testing.ts +106 -0
- package/src/runner/ledger.test.ts +230 -0
- package/src/runner/ledger.ts +329 -0
- package/src/runner/report.test.ts +128 -3
- package/src/runner/report.ts +33 -9
- package/src/runner/reporters/artifacts.ts +8 -2
- package/src/runner/reporters/braintrust.test.ts +8 -7
- package/src/runner/reporters/braintrust.ts +9 -2
- package/src/runner/reporters/index.ts +2 -2
- package/src/runner/reporters/json.test.ts +162 -0
- package/src/runner/reporters/json.ts +35 -8
- package/src/runner/reporters/shared.ts +1 -5
- package/src/runner/run.test.ts +760 -3
- package/src/runner/run.ts +243 -37
- package/src/runner/sandbox-prep.ts +3 -42
- package/src/runner/timing.ts +158 -0
- package/src/runner/types.ts +518 -22
- package/src/sandbox/checkpoint.test.ts +55 -0
- package/src/sandbox/checkpoint.ts +29 -8
- package/src/sandbox/cli-commands.ts +407 -0
- package/src/sandbox/docker.ts +115 -16
- package/src/sandbox/e2b-agent-template.test.ts +56 -0
- package/src/sandbox/e2b-agent-template.ts +94 -0
- package/src/sandbox/e2b.ts +74 -9
- package/src/sandbox/errors.ts +111 -4
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/io-retry.test.ts +58 -0
- package/src/sandbox/io-retry.ts +45 -0
- package/src/sandbox/keep-registry.test.ts +86 -0
- package/src/sandbox/keep-registry.ts +142 -0
- package/src/sandbox/keep.ts +178 -0
- package/src/sandbox/paths.test.ts +1 -0
- package/src/sandbox/paths.ts +19 -8
- package/src/sandbox/registry.ts +20 -3
- package/src/sandbox/resolve.ts +76 -11
- package/src/sandbox/retry.test.ts +70 -0
- package/src/sandbox/retry.ts +46 -4
- package/src/sandbox/types.ts +44 -6
- package/src/sandbox/vercel.ts +43 -20
- package/src/scoring/collector.ts +60 -17
- package/src/scoring/coverage.ts +95 -0
- package/src/scoring/diff.ts +81 -0
- package/src/scoring/display.test.ts +121 -0
- package/src/scoring/display.ts +133 -0
- package/src/scoring/evidence.test.ts +189 -0
- package/src/scoring/judge.test.ts +142 -0
- package/src/scoring/judge.ts +15 -18
- package/src/scoring/scoped.ts +217 -50
- package/src/scoring/types.ts +117 -20
- package/src/scoring/verdict.ts +16 -4
- package/src/shared/aggregate.ts +8 -6
- package/src/shared/types.ts +31 -0
- package/src/show/compose.ts +50 -67
- package/src/show/index.ts +127 -56
- package/src/show/render.ts +662 -131
- package/src/show/report-host.test.ts +188 -0
- package/src/show/report-host.ts +375 -0
- package/src/show/show.test.ts +320 -54
- package/src/tty-line.ts +8 -26
- package/src/util.test.ts +1 -0
- package/src/util.ts +41 -0
- package/src/view/app/App.test.tsx +69 -0
- package/src/view/app/App.tsx +144 -48
- package/src/view/app/components/AttemptModal.tsx +423 -11
- package/src/view/app/components/CodeView.tsx +41 -14
- package/src/view/app/components/CopyControls.tsx +2 -2
- package/src/view/app/i18n.ts +37 -17
- package/src/view/app/lib/attempt-route.test.ts +1 -0
- package/src/view/app/lib/verdict.ts +7 -9
- package/src/view/app/main.tsx +13 -8
- package/src/view/app/pages/{RunsPage.tsx → AttemptsPage.tsx} +6 -6
- package/src/view/app/types.ts +4 -1
- package/src/view/artifact-serving.test.ts +2 -1
- package/src/view/client-dist/app.css +1 -1
- package/src/view/client-dist/app.js +17 -17
- package/src/view/data.test.ts +10 -3
- package/src/view/data.ts +155 -49
- package/src/view/index.ts +56 -41
- package/src/view/server.ts +37 -15
- package/src/view/shared/types.ts +34 -5
- package/src/view/styles.css +227 -0
- package/src/view/view-report.test.ts +167 -62
- package/dist/report/built-ins/experiment-comparison.d.ts +0 -1
- package/dist/report/built-ins/experiment-comparison.js +0 -13
- package/dist/report/built-ins/index.d.ts +0 -1
- package/dist/report/built-ins/index.js +0 -2
- package/dist/report/react/GroupSummary.d.ts +0 -8
- package/dist/report/react/GroupSummary.js +0 -8
- package/dist/report/react/RunOverview.d.ts +0 -8
- package/dist/report/react/RunOverview.js +0 -12
- package/docs-site/zh/example/ai-agent-application.mdx +0 -152
- package/docs-site/zh/example/claude-code-codex-plugin.mdx +0 -167
- package/docs-site/zh/example/claude-code-codex-skill.mdx +0 -152
- package/docs-site/zh/example/showcase.mdx +0 -39
- package/docs-site/zh/guides/publish-report.mdx +0 -91
- package/docs-site/zh/guides/sandbox-providers.mdx +0 -102
- package/src/report/built-in-user-parity.test.tsx +0 -640
- package/src/report/built-ins/experiment-comparison.tsx +0 -19
- package/src/report/built-ins/index.ts +0 -2
- package/src/report/react/GroupSummary.tsx +0 -66
- package/src/report/react/RunOverview.tsx +0 -109
- package/src/runner/reporters/console.ts +0 -70
- package/src/runner/reporters/live.test.ts +0 -56
- package/src/runner/reporters/live.ts +0 -247
- package/src/runner/reporters/quiet.test.ts +0 -66
- package/src/runner/reporters/quiet.ts +0 -49
- package/src/runner/reporters/table.ts +0 -277
- /package/docs-site/zh/{example/tier1-ai-sdk-v7.mdx → examples/integrations/ai-sdk-v7.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-claude-sdk.mdx → examples/integrations/claude-sdk.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-codex-sdk.mdx → examples/integrations/codex-sdk.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-langgraph.mdx → examples/integrations/langgraph.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-pi-sdk.mdx → examples/integrations/pi-sdk.mdx} +0 -0
- /package/docs-site/zh/{guides → how-to}/fixtures.mdx +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { formatMetricValue } from "../format.js";
|
|
3
|
-
import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveMetricLabel } from "../locale.js";
|
|
4
|
-
import {
|
|
3
|
+
import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
|
|
4
|
+
import { niceTicks, placePointLabels } from "./chart-math.js";
|
|
5
5
|
import { colorClassForKey, seriesClassForKey } from "./colors.js";
|
|
6
6
|
import { cx } from "./format.js";
|
|
7
7
|
const WIDTH = 640;
|
|
@@ -9,22 +9,55 @@ const HEIGHT = 360;
|
|
|
9
9
|
const MARGIN = { top: 26, right: 24, bottom: 46, left: 62 };
|
|
10
10
|
const PLOT_W = WIDTH - MARGIN.left - MARGIN.right;
|
|
11
11
|
const PLOT_H = HEIGHT - MARGIN.top - MARGIN.bottom;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* 点的直接标签:末段在当前 data 中唯一才缩成末段;重名时逐步加长为能区分它们的最短
|
|
14
|
+
* 路径后缀(完整 id 与两轴值仍进 <title>)。
|
|
15
|
+
*/
|
|
16
|
+
function pointLabels(keys) {
|
|
17
|
+
const segsOf = (key) => key.split("/").filter(Boolean);
|
|
18
|
+
const depth = new Map(keys.map((key) => [key, 1]));
|
|
19
|
+
for (;;) {
|
|
20
|
+
const byLabel = new Map();
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
const segs = segsOf(key);
|
|
23
|
+
const label = segs.slice(-Math.min(depth.get(key), segs.length)).join("/") || key;
|
|
24
|
+
byLabel.set(label, [...(byLabel.get(label) ?? []), key]);
|
|
25
|
+
}
|
|
26
|
+
let grew = false;
|
|
27
|
+
for (const group of byLabel.values()) {
|
|
28
|
+
if (group.length < 2)
|
|
29
|
+
continue;
|
|
30
|
+
for (const key of group) {
|
|
31
|
+
const segs = segsOf(key);
|
|
32
|
+
if (depth.get(key) < segs.length) {
|
|
33
|
+
depth.set(key, depth.get(key) + 1);
|
|
34
|
+
grew = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!grew) {
|
|
39
|
+
const out = new Map();
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
const segs = segsOf(key);
|
|
42
|
+
out.set(key, segs.slice(-Math.min(depth.get(key), segs.length)).join("/") || key);
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
15
47
|
}
|
|
16
48
|
/**
|
|
17
|
-
* 一根轴:niceTicks 撑出整齐的值域,值 →
|
|
18
|
-
* better: "lower"
|
|
49
|
+
* 一根轴:niceTicks 撑出整齐的值域,值 → 像素做线性映射。轴方向跟随指标的 `better`:
|
|
50
|
+
* `better: "lower"` 的轴反向渲染(值大的一端在左 / 下),「更好」因此恒指向右与上;
|
|
51
|
+
* 刻度标签始终显示真实值,反向只改方向不改数字(docs/feature/reports/library/metric-views.md)。
|
|
19
52
|
*/
|
|
20
|
-
function axisScale(values,
|
|
53
|
+
function axisScale(values, pixelLo, pixelHi, invert) {
|
|
21
54
|
const ticks = niceTicks(Math.min(...values), Math.max(...values), 5);
|
|
22
55
|
const lo = ticks[0];
|
|
23
56
|
const hi = ticks[ticks.length - 1];
|
|
24
57
|
const scale = (v) => {
|
|
25
58
|
let t = (v - lo) / (hi - lo || 1);
|
|
26
|
-
if (
|
|
27
|
-
t = 1 - t;
|
|
59
|
+
if (invert)
|
|
60
|
+
t = 1 - t;
|
|
28
61
|
return pixelLo + t * (pixelHi - pixelLo);
|
|
29
62
|
};
|
|
30
63
|
return { ticks, scale };
|
|
@@ -41,21 +74,25 @@ export function MetricScatter({ data, pointHref, className, locale = DEFAULT_REP
|
|
|
41
74
|
return (_jsxs("figure", { className: cx("nre", "nre-metric-scatter", className), children: [_jsx("p", { className: "nre-scatter-empty nre-missing", children: localeText(locale, "scatter.noData", { x: xLabel, y: yLabel }) }), missingNote] }));
|
|
42
75
|
}
|
|
43
76
|
const axisLabel = (label, col) => `${label}${col.unit ? `(${col.unit})` : ""}`;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
// 轴方向跟随 better:lower 反向(值大在左 / 下),higher 与未声明正向。
|
|
78
|
+
const xScale = axisScale(drawableRows.map((r) => r.x.value), MARGIN.left, MARGIN.left + PLOT_W, data.x.better === "lower");
|
|
79
|
+
// y 像素轴向下增长:正向 = 高值在上 → 映射到 [bottom, top];lower 反向 = 高值在下。
|
|
80
|
+
const yScale = axisScale(drawableRows.map((r) => r.y.value), MARGIN.top + PLOT_H, MARGIN.top, data.y.better === "lower");
|
|
81
|
+
const labelByKey = pointLabels(drawableRows.map((r) => r.key));
|
|
82
|
+
// 方向提示恒为「越靠右上越好」,仅当两轴都声明 better 时显示——任一轴未声明,
|
|
83
|
+
// 组件不猜「更好」朝哪边,整图无提示。
|
|
84
|
+
const showBetterHint = data.x.better !== undefined && data.y.better !== undefined;
|
|
47
85
|
const points = drawableRows.map((r) => {
|
|
48
86
|
const xValue = r.x.value;
|
|
49
87
|
const yValue = r.y.value;
|
|
50
88
|
return {
|
|
51
89
|
key: r.key,
|
|
52
90
|
series: r.series,
|
|
53
|
-
label:
|
|
91
|
+
label: labelByKey.get(r.key) ?? r.key,
|
|
54
92
|
xValue,
|
|
55
93
|
yValue,
|
|
56
|
-
// hover 内容:experiment(点键)+ 系列(
|
|
57
|
-
|
|
58
|
-
title: `${r.key}${r.series !== undefined ? `\n${r.series}` : ""}\n${xLabel}: ${r.x.display}(${r.x.samples}/${r.x.total})\n${yLabel}: ${r.y.display}(${r.y.samples}/${r.y.total})`,
|
|
94
|
+
// hover 内容:experiment(点键)+ 系列(有则加一行)+ 两轴 display 与 samples/total
|
|
95
|
+
title: `${r.key}${r.series !== undefined ? `\n${r.series}` : ""}\n${xLabel}: ${resolveLocalizedText(r.x.display, locale)}(${r.x.samples}/${r.x.total})\n${yLabel}: ${resolveLocalizedText(r.y.display, locale)}(${r.y.samples}/${r.y.total})`,
|
|
59
96
|
px: xScale.scale(xValue),
|
|
60
97
|
py: yScale.scale(yValue),
|
|
61
98
|
};
|
|
@@ -74,22 +111,16 @@ export function MetricScatter({ data, pointHref, className, locale = DEFAULT_REP
|
|
|
74
111
|
}
|
|
75
112
|
for (const list of bySeries.values())
|
|
76
113
|
list.sort((a, b) => a.xValue - b.xValue);
|
|
77
|
-
//
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
return { cx: p.px, cy: p.py, anchorLeft, width: p.label.length * 6.4 + 10 };
|
|
81
|
-
});
|
|
82
|
-
const labelOffsets = layoutLabelOffsets(positions);
|
|
83
|
-
return (_jsxs("figure", { className: cx("nre", "nre-metric-scatter", className), children: [_jsxs("svg", { className: "nre-scatter-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${axisLabel(xLabel, data.x)} × ${axisLabel(yLabel, data.y)}`, children: [_jsxs("g", { className: "nre-scatter-grid", children: [yScale.ticks.map((tick) => (_jsx("line", { x1: MARGIN.left, x2: MARGIN.left + PLOT_W, y1: yScale.scale(tick), y2: yScale.scale(tick) }, `gy${tick}`))), xScale.ticks.map((tick) => (_jsx("line", { y1: MARGIN.top, y2: MARGIN.top + PLOT_H, x1: xScale.scale(tick), x2: xScale.scale(tick) }, `gx${tick}`)))] }), _jsx("text", { className: "nre-scatter-better-hint", x: MARGIN.left + PLOT_W - 6, y: MARGIN.top + 14, textAnchor: "end", children: localeText(locale, "scatter.betterHint") }), _jsx("g", { className: "nre-scatter-axis nre-scatter-axis-y", children: yScale.ticks.map((tick) => (_jsx("text", { className: "nre-scatter-tick", x: MARGIN.left - 8, y: yScale.scale(tick) + 3, textAnchor: "end", children: formatMetricValue(tick, data.y.unit) }, `ay${tick}`))) }), _jsx("g", { className: "nre-scatter-axis nre-scatter-axis-x", children: xScale.ticks.map((tick) => (_jsx("text", { className: "nre-scatter-tick", x: xScale.scale(tick), y: MARGIN.top + PLOT_H + 16, textAnchor: "middle", children: formatMetricValue(tick, data.x.unit) }, `ax${tick}`))) }), _jsx("text", { className: "nre-scatter-xlabel", x: MARGIN.left + PLOT_W / 2, y: HEIGHT - 8, textAnchor: "middle", children: axisLabel(xLabel, data.x) }), _jsx("text", { className: "nre-scatter-ylabel", x: 14, y: MARGIN.top + PLOT_H / 2, textAnchor: "middle", transform: `rotate(-90 14 ${MARGIN.top + PLOT_H / 2})`, children: axisLabel(yLabel, data.y) }), seriesOrder.map((series) => {
|
|
114
|
+
// 直接标签的候选位择优布局:锚向、避让方向都由布局按空间决定,画布边界含边距
|
|
115
|
+
const labels = placePointLabels(points.map((p) => ({ cx: p.px, cy: p.py, width: p.label.length * 6.4 + 10 })), { x0: 2, y0: 2, x1: WIDTH - 2, y1: HEIGHT - 2 });
|
|
116
|
+
return (_jsxs("figure", { className: cx("nre", "nre-metric-scatter", className), children: [_jsxs("svg", { className: "nre-scatter-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${axisLabel(xLabel, data.x)} × ${axisLabel(yLabel, data.y)}`, children: [_jsxs("g", { className: "nre-scatter-grid", children: [yScale.ticks.map((tick) => (_jsx("line", { x1: MARGIN.left, x2: MARGIN.left + PLOT_W, y1: yScale.scale(tick), y2: yScale.scale(tick) }, `gy${tick}`))), xScale.ticks.map((tick) => (_jsx("line", { y1: MARGIN.top, y2: MARGIN.top + PLOT_H, x1: xScale.scale(tick), x2: xScale.scale(tick) }, `gx${tick}`)))] }), showBetterHint && (_jsx("text", { className: "nre-scatter-better-hint", x: MARGIN.left + PLOT_W - 6, y: MARGIN.top + 14, textAnchor: "end", children: localeText(locale, "scatter.betterUpperRight") })), _jsx("g", { className: "nre-scatter-axis nre-scatter-axis-y", children: yScale.ticks.map((tick) => (_jsx("text", { className: "nre-scatter-tick", x: MARGIN.left - 8, y: yScale.scale(tick) + 3, textAnchor: "end", children: formatMetricValue(tick, data.y.unit) }, `ay${tick}`))) }), _jsx("g", { className: "nre-scatter-axis nre-scatter-axis-x", children: xScale.ticks.map((tick) => (_jsx("text", { className: "nre-scatter-tick", x: xScale.scale(tick), y: MARGIN.top + PLOT_H + 16, textAnchor: "middle", children: formatMetricValue(tick, data.x.unit) }, `ax${tick}`))) }), _jsx("text", { className: "nre-scatter-xlabel", x: MARGIN.left + PLOT_W / 2, y: HEIGHT - 8, textAnchor: "middle", children: axisLabel(xLabel, data.x) }), _jsx("text", { className: "nre-scatter-ylabel", x: 14, y: MARGIN.top + PLOT_H / 2, textAnchor: "middle", transform: `rotate(-90 14 ${MARGIN.top + PLOT_H / 2})`, children: axisLabel(yLabel, data.y) }), seriesOrder.map((series) => {
|
|
84
117
|
const list = bySeries.get(series);
|
|
85
118
|
if (list.length < 2)
|
|
86
119
|
return null;
|
|
87
120
|
return (_jsx("polyline", { className: cx("nre-scatter-line", seriesClassForKey(series)), "data-series": series, points: list.map((p) => `${p.px},${p.py}`).join(" "), fill: "none" }, series));
|
|
88
121
|
}), points.map((p, i) => {
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const labelY = p.py + 4 + labelOffsets[i];
|
|
92
|
-
const group = (_jsxs("g", { className: cx("nre-scatter-point", p.series !== undefined ? seriesClassForKey(p.series) : "nre-series-none"), "data-key": p.key, children: [_jsx("title", { children: p.title }), labelOffsets[i] !== 0 && _jsx("line", { className: "nre-leader", x1: p.px, y1: p.py, x2: labelX, y2: labelY - 4 }), _jsx("circle", { className: "nre-scatter-hit", cx: p.px, cy: p.py, r: 12 }), _jsx("circle", { className: "nre-scatter-dot", cx: p.px, cy: p.py, r: 4.5 }), _jsx("text", { className: "nre-scatter-point-label", x: labelX, y: labelY, textAnchor: anchorLeft ? "end" : "start", children: p.label })] }));
|
|
122
|
+
const label = labels[i];
|
|
123
|
+
const group = (_jsxs("g", { className: cx("nre-scatter-point", p.series !== undefined ? seriesClassForKey(p.series) : "nre-series-none"), "data-key": p.key, children: [_jsx("title", { children: p.title }), label.leader && _jsx("line", { className: "nre-leader", x1: p.px, y1: p.py, x2: label.x, y2: label.y - 4 }), _jsx("circle", { className: "nre-scatter-hit", cx: p.px, cy: p.py, r: 12 }), _jsx("circle", { className: "nre-scatter-dot", cx: p.px, cy: p.py, r: 4.5 }), _jsx("text", { className: "nre-scatter-point-label", x: label.x, y: label.y, textAnchor: label.anchor, children: p.label })] }));
|
|
93
124
|
const row = drawableRows[i];
|
|
94
125
|
return pointHref ? (_jsx("a", { className: "nre-scatter-point-link", href: pointHref(row), children: group }, p.key)) : (_jsx("g", { children: group }, p.key));
|
|
95
126
|
})] }), seriesOrder.length > 0 && (_jsx("figcaption", { className: "nre-scatter-legend", children: seriesOrder.map((series) => (_jsx("span", { className: cx("nre-legend-key", "nre-key", colorClassForKey(series)), children: series }, series))) })), missingNote] }));
|
|
@@ -3,21 +3,11 @@ import { DEFAULT_REPORT_LOCALE, localeText, resolveMetricLabel } from "../locale
|
|
|
3
3
|
import { MetricCellView } from "./cell.js";
|
|
4
4
|
import { colorClassForKey } from "./colors.js";
|
|
5
5
|
import { cx } from "./format.js";
|
|
6
|
-
/** verdict 计票 pill(「3 passed / 1 failed」):非零判定各一枚,全零如实空。 */
|
|
7
|
-
function VerdictTally({ verdicts, locale, }) {
|
|
8
|
-
const kinds = ["passed", "failed", "errored", "skipped"].filter((k) => verdicts[k] > 0);
|
|
9
|
-
return (_jsxs("span", { className: "nre-verdict-tally", children: [kinds.map((kind) => (_jsxs("span", { className: cx("nre-verdict-pill", `nre-verdict-${kind}`), children: [verdicts[kind], " ", localeText(locale, `verdict.${kind}`)] }, kind))), kinds.length === 0 && _jsx("span", { className: "nre-missing", children: "\u2014" })] }));
|
|
10
|
-
}
|
|
11
6
|
export function MetricTable({ data, attemptHref, filter, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
12
|
-
const
|
|
13
|
-
const hasModel = data.rows.some((row) => row.meta?.model !== undefined);
|
|
14
|
-
const hasVerdicts = data.rows.some((row) => row.meta?.verdicts !== undefined);
|
|
15
|
-
const table = (_jsxs("table", { className: cx("nre", "nre-metric-table", !filter && className), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", "data-nre-sort": "", children: data.dimension }), hasMeta && hasModel && (_jsx("th", { scope: "col", className: "nre-meta-col", "data-nre-sort": "", children: localeText(locale, "table.model") })), hasMeta && (_jsx("th", { scope: "col", className: "nre-meta-col", "data-nre-sort": "", children: localeText(locale, "table.agent") })), data.columns.map((col) => (_jsxs("th", { scope: "col", className: "nre-metric-col", "data-nre-sort": "", children: [resolveMetricLabel(col.label, locale, col.key), col.unit && _jsxs("span", { className: "nre-unit", children: ["(", col.unit, ")"] }), col.better && (_jsx("span", { className: "nre-better", title: localeText(locale, col.better === "higher" ? "table.higherBetter" : "table.lowerBetter"), children: col.better === "higher" ? "↑" : "↓" }))] }, col.key))), hasVerdicts && (_jsx("th", { scope: "col", className: "nre-verdicts-col", "data-nre-sort": "", children: localeText(locale, "table.verdicts") }))] }) }), _jsx("tbody", { children: data.rows.map((row) => (_jsxs("tr", { children: [_jsxs("th", { scope: "row", className: cx("nre-row-key", "nre-key", colorClassForKey(row.key)), "data-sort-value": row.key, children: [row.key, row.meta?.evals !== undefined && (_jsxs("div", { className: "nre-row-meta-sub", children: [localeText(locale, "overview.evalsCount", { n: row.meta.evals }), row.meta.attempts !== undefined && row.meta.attempts > row.meta.evals
|
|
16
|
-
? ` · ${localeText(locale, "overview.attemptsCount", { n: row.meta.attempts })}`
|
|
17
|
-
: "", row.meta.lastRunAt ? ` · ${localeText(locale, "latestRun", { run: row.meta.lastRunAt })}` : ""] }))] }), hasMeta && hasModel && (_jsx("td", { className: "nre-td nre-meta-cell", "data-sort-value": row.meta?.model ?? "", children: row.meta?.model ?? _jsx("span", { className: "nre-missing", children: "\u2014" }) })), hasMeta && (_jsx("td", { className: "nre-td nre-meta-cell", "data-sort-value": row.meta?.agent ?? "", children: row.meta?.agent ?? _jsx("span", { className: "nre-missing", children: "\u2014" }) })), data.columns.map((col) => {
|
|
7
|
+
const table = (_jsxs("table", { className: cx("nre", "nre-metric-table", !filter && className), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", "data-nre-sort": "", children: data.rowDimension }), data.columns.map((col) => (_jsxs("th", { scope: "col", className: "nre-metric-col", "data-nre-sort": "", children: [resolveMetricLabel(col.label, locale, col.key), col.unit && _jsxs("span", { className: "nre-unit", children: ["(", col.unit, ")"] }), col.better && (_jsx("span", { className: "nre-better", title: localeText(locale, col.better === "higher" ? "table.higherBetter" : "table.lowerBetter"), children: col.better === "higher" ? "↑" : "↓" }))] }, col.key)))] }) }), _jsx("tbody", { children: data.rows.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: cx("nre-row-key", "nre-key", colorClassForKey(row.key)), "data-sort-value": row.key, children: row.key }), data.columns.map((col) => {
|
|
18
8
|
const cell = row.cells[col.key];
|
|
19
9
|
return (_jsx("td", { className: "nre-td", "data-sort-value": cell?.value ?? "", children: cell ? (_jsx(MetricCellView, { cell: cell, attemptHref: attemptHref, locale: locale })) : (_jsx("span", { className: "nre-empty" })) }, col.key));
|
|
20
|
-
})
|
|
10
|
+
})] }, row.key))) })] }));
|
|
21
11
|
if (!filter)
|
|
22
12
|
return table;
|
|
23
13
|
// 过滤输入框渲染在表格前(同一个 wrap 里),enhance.js 经 data-nre-filter 接管;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ScopeSummaryData } from "../types.ts";
|
|
3
|
+
import { type ReportLocale } from "../locale.ts";
|
|
4
|
+
export declare function ScopeSummary({ data, votes, className, locale, }: {
|
|
5
|
+
data: ScopeSummaryData;
|
|
6
|
+
/** 显示哪一级计票;默认 "eval"。data 恒携带两级,votes 只选择呈现。 */
|
|
7
|
+
votes?: "eval" | "attempt";
|
|
8
|
+
className?: string;
|
|
9
|
+
locale?: ReportLocale;
|
|
10
|
+
}): ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
|
|
3
|
+
import { MetricCellView } from "./cell.js";
|
|
4
|
+
import { cx } from "./format.js";
|
|
5
|
+
function VerdictTallyView({ tally, locale }) {
|
|
6
|
+
const kinds = ["passed", "failed", "errored", "skipped"].filter((k) => tally[k] > 0);
|
|
7
|
+
return (_jsxs("span", { className: "nre-verdict-tally", children: [kinds.map((kind) => (_jsxs("span", { className: cx("nre-verdict-pill", `nre-verdict-${kind}`), children: [tally[kind], " ", localeText(locale, `verdict.${kind}`)] }, kind))), kinds.length === 0 && _jsx("span", { className: "nre-missing", children: "\u2014" })] }));
|
|
8
|
+
}
|
|
9
|
+
export function ScopeSummary({ data, votes = "eval", className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
10
|
+
const tally = votes === "attempt" ? data.attemptVerdicts : data.evalVerdicts;
|
|
11
|
+
return (_jsxs("div", { className: cx("nre", "nre-scope-summary", className), "data-votes": votes, children: [_jsxs("dl", { className: "nre-scope-kpis", children: [_jsxs("div", { className: "nre-scope-kpi nre-scope-kpi-rate", children: [_jsx("dt", { children: localeText(locale, "scopeSummary.passRate") }), _jsx("dd", { children: _jsx(MetricCellView, { cell: data.endToEndPassRate, locale: locale }) })] }), _jsxs("div", { className: "nre-scope-kpi", children: [_jsx("dt", { children: localeText(locale, "scopeSummary.experiments") }), _jsx("dd", { children: data.experiments })] }), _jsxs("div", { className: "nre-scope-kpi", children: [_jsx("dt", { children: localeText(locale, "scopeSummary.evals") }), _jsx("dd", { children: data.evals })] }), _jsxs("div", { className: "nre-scope-kpi", children: [_jsx("dt", { children: localeText(locale, "scopeSummary.attempts") }), _jsx("dd", { children: data.attempts })] }), _jsxs("div", { className: "nre-scope-kpi nre-scope-kpi-verdicts", children: [_jsx("dt", { children: localeText(locale, votes === "attempt" ? "scopeSummary.votesAttempt" : "scopeSummary.votesEval") }), _jsx("dd", { children: _jsx(VerdictTallyView, { tally: tally, locale: locale }) })] }), _jsxs("div", { className: "nre-scope-kpi", children: [_jsx("dt", { children: localeText(locale, "scopeSummary.totalCost") }), _jsx("dd", { children: _jsx(MetricCellView, { cell: data.totalCostUSD, locale: locale }) })] })] }), data.range.latestStartedAt !== null && (_jsx("p", { className: "nre-scope-summary-range", children: data.range.earliestStartedAt !== null && data.range.earliestStartedAt !== data.range.latestStartedAt
|
|
12
|
+
? localeText(locale, "scopeSummary.range", {
|
|
13
|
+
from: data.range.earliestStartedAt,
|
|
14
|
+
to: data.range.latestStartedAt,
|
|
15
|
+
})
|
|
16
|
+
: data.range.latestStartedAt }))] }));
|
|
17
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DEFAULT_REPORT_LOCALE, countText, localeText } from "../locale.js";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveLocalizedText } from "../locale.js";
|
|
3
3
|
import { colorClassForKey } from "./colors.js";
|
|
4
4
|
import { cx } from "./format.js";
|
|
5
5
|
export function Scoreboard({ data, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
@@ -11,16 +11,16 @@ export function Scoreboard({ data, className, locale = DEFAULT_REPORT_LOCALE, })
|
|
|
11
11
|
subjectKeys.push(subject.key);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
return (_jsxs("section", { className: cx("nre", "nre-scoreboard", className), children: [_jsxs("table", { className: "nre-scoreboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.
|
|
14
|
+
return (_jsxs("section", { className: cx("nre", "nre-scoreboard", className), children: [_jsxs("table", { className: "nre-scoreboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.rowDimension }), _jsxs("th", { scope: "col", className: "nre-total-col", children: [localeText(locale, "scoreboard.total"), _jsxs("span", { className: "nre-full-marks", children: ["/ ", data.fullMarks] })] }), subjectKeys.map((key) => (_jsx("th", { scope: "col", className: "nre-subject-col", children: key }, key)))] }) }), _jsx("tbody", { children: data.rows.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: cx("nre-row-key", "nre-key", colorClassForKey(row.key)), children: row.key }), _jsxs("td", { className: "nre-total", children: [resolveLocalizedText(row.total.display, locale), row.total.notRun > 0 && (_jsx("span", { className: "nre-total-not-run", children: countText(locale, "scoreboard.notRun", row.total.notRun) })), row.total.unscorable > 0 && (_jsx("span", { className: "nre-total-unscorable", children: countText(locale, "scoreboard.unscorable", row.total.unscorable) }))] }), subjectKeys.map((key) => {
|
|
15
15
|
const subject = row.subjects.find((s) => s.key === key);
|
|
16
16
|
if (!subject)
|
|
17
17
|
return _jsx("td", { className: "nre-td-empty" }, key);
|
|
18
|
-
return (_jsxs("td", { className: "nre-subject", children: [
|
|
19
|
-
|
|
18
|
+
return (_jsxs("td", { className: "nre-subject", children: [_jsx("span", { className: "nre-subject-score", title: localeText(locale, "scoreboard.subjectTitle", {
|
|
19
|
+
questions: subject.questions,
|
|
20
20
|
earned: subject.earned,
|
|
21
21
|
possible: subject.possible,
|
|
22
|
-
}), children:
|
|
22
|
+
}), children: resolveLocalizedText(subject.display, locale) }), subject.notRun > 0 && (_jsx("span", { className: "nre-subject-not-run", children: localeText(locale, "scoreboard.notRunText", { n: subject.notRun }) })), subject.unscorable > 0 && (_jsx("span", { className: "nre-subject-unscorable", children: localeText(locale, "scoreboard.unscorableText", { n: subject.unscorable }) }))] }, key));
|
|
23
23
|
})] }, row.key))) })] }), _jsxs("p", { className: "nre-weights", children: [localeText(locale, "scoreboard.weights"), " ", data.weights.length === 0
|
|
24
24
|
? localeText(locale, "scoreboard.allWeights")
|
|
25
|
-
: data.weights.map((w) => (_jsxs("span", { className: "nre-weight", children: [w.prefix, " \u00D7", w.weight] }, w.prefix))), data.weights.length > 0 && _jsx("span", { className: "nre-weight-rest", children: localeText(locale, "scoreboard.othersWeight") })] })] }));
|
|
25
|
+
: data.weights.map((w) => (_jsxs("span", { className: "nre-weight", children: [w.prefix, " \u00D7", w.weight] }, w.prefix))), data.weights.length > 0 && _jsx("span", { className: "nre-weight-rest", children: localeText(locale, "scoreboard.othersWeight") })] }), data.ignoredEvals > 0 && (_jsx("p", { className: "nre-scoreboard-ignored", children: countText(locale, "scoreboard.ignored", data.ignoredEvals) }))] }));
|
|
26
26
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, localeText, resolveLocalizedText } from "../locale.js";
|
|
3
3
|
export function MetricCellView({ cell, attemptHref, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
4
4
|
// 全 null(没有任何有效样本)→ 缺数据文案,绝不画 0;total 仍如实入 title
|
|
5
5
|
if (cell.value === null) {
|
|
6
6
|
return (_jsx("span", { className: "nre-cell nre-cell-missing", children: _jsx("span", { className: "nre-missing", title: localeText(locale, "cell.noneMeasurableTitle", { total: cell.total }), children: localeText(locale, "cell.missing") }) }));
|
|
7
7
|
}
|
|
8
|
-
return (_jsxs("span", { className: "nre-cell", children: [_jsx("span", { className: "nre-value", title: localeText(locale, "cell.measuredTitle", { samples: cell.samples, total: cell.total }), children: cell.display }), cell.samples < cell.total && (_jsxs("sup", { className: "nre-coverage", title: localeText(locale, "cell.coverageTitle", { samples: cell.samples, total: cell.total }), children: [cell.samples, "/", cell.total] })), attemptHref && cell.refs && cell.refs.length > 0 && (_jsx("span", { className: "nre-refs", children: cell.refs.map((locator, i) => (_jsxs("a", { className: "nre-ref", href: attemptHref(locator), children: ["#", i + 1] }, locator))) }))] }));
|
|
8
|
+
return (_jsxs("span", { className: "nre-cell", children: [_jsx("span", { className: "nre-value", title: localeText(locale, "cell.measuredTitle", { samples: cell.samples, total: cell.total }), children: resolveLocalizedText(cell.display, locale) }), cell.samples < cell.total && (_jsxs("sup", { className: "nre-coverage", title: localeText(locale, "cell.coverageTitle", { samples: cell.samples, total: cell.total }), children: [cell.samples, "/", cell.total] })), attemptHref && cell.refs && cell.refs.length > 0 && (_jsx("span", { className: "nre-refs", children: cell.refs.map((locator, i) => (_jsxs("a", { className: "nre-ref", href: attemptHref(locator), children: ["#", i + 1] }, locator))) }))] }));
|
|
9
9
|
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
/** [min, max] 区间上生成 count 个左右的“整齐”刻度(Heckbert nice-numbers)。 */
|
|
2
2
|
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
3
|
-
export interface
|
|
3
|
+
export interface PointLabelInput {
|
|
4
4
|
cx: number;
|
|
5
5
|
cy: number;
|
|
6
|
+
/** 标签文本的估算宽度(px)。 */
|
|
6
7
|
width: number;
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
}
|
|
9
|
+
/** 标签允许占用的画布范围(含坐标轴边距,标签可以借用空白边距)。 */
|
|
10
|
+
export interface LabelBounds {
|
|
11
|
+
x0: number;
|
|
12
|
+
y0: number;
|
|
13
|
+
x1: number;
|
|
14
|
+
y1: number;
|
|
15
|
+
}
|
|
16
|
+
export interface PlacedPointLabel {
|
|
17
|
+
/** <text> 的锚点坐标(y 为文字基线)。 */
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
anchor: "start" | "end" | "middle";
|
|
21
|
+
/** 标签不在点左右紧邻位:渲染层补 leader line 连回原点。 */
|
|
22
|
+
leader: boolean;
|
|
9
23
|
}
|
|
10
24
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
25
|
+
* 散点直接标签的候选位择优布局(docs/feature/reports/library.md「MetricScatter」):
|
|
26
|
+
* 每个标签在点四周由近及远的候选环上打分——与已放置标签的重叠、与任何数据点的重叠、
|
|
27
|
+
* 越出画布的面积、离点距离逐项累加,取代价最小的候选。存在无冲突候选时标签必不遮点、
|
|
28
|
+
* 不叠标签、不越界;全候选冲突时取重叠最小者,绝不丢标签。重合点簇因此向不同方向散开,
|
|
29
|
+
* 而不是单向堆叠压到下方的数据点上。
|
|
13
30
|
*/
|
|
14
|
-
export declare function
|
|
31
|
+
export declare function placePointLabels(points: PointLabelInput[], bounds: LabelBounds): PlacedPointLabel[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// 通用图表数值工具:round-number
|
|
2
|
-
// 从 src/view/app/lib/chart.ts 迁来(view 侧从这里 re-export),报告组件与 view 共用同一份。
|
|
1
|
+
// 通用图表数值工具:round-number 刻度生成与点标签布局,零依赖纯函数。
|
|
3
2
|
function niceNumber(range, round) {
|
|
4
3
|
if (range <= 0)
|
|
5
4
|
return 1;
|
|
@@ -43,26 +42,79 @@ export function niceTicks(min, max, count = 5) {
|
|
|
43
42
|
ticks.push(Number(v.toFixed(10)));
|
|
44
43
|
return ticks;
|
|
45
44
|
}
|
|
45
|
+
/** 标签框高度(基线上方 10px、下方 2px,对应 11px 字号)。 */
|
|
46
|
+
const LABEL_ASCENT = 10;
|
|
47
|
+
const LABEL_DESCENT = 2;
|
|
48
|
+
/** 数据点视为边长 2×DOT_R 的方形障碍(点半径 4.5 + 命中余量)。 */
|
|
49
|
+
const DOT_R = 6;
|
|
50
|
+
/** 紧邻位与点的水平间距;候选环按它逐环外扩。 */
|
|
51
|
+
const NEAR = 10;
|
|
52
|
+
const RINGS = [NEAR, NEAR + 12, NEAR + 26];
|
|
53
|
+
function labelBoxAt(x, y, anchor, width) {
|
|
54
|
+
const x0 = anchor === "start" ? x : anchor === "end" ? x - width : x - width / 2;
|
|
55
|
+
return { x0, y0: y - LABEL_ASCENT, x1: x0 + width, y1: y + LABEL_DESCENT };
|
|
56
|
+
}
|
|
57
|
+
function overlapArea(a, b) {
|
|
58
|
+
const w = Math.min(a.x1, b.x1) - Math.max(a.x0, b.x0);
|
|
59
|
+
const h = Math.min(a.y1, b.y1) - Math.max(a.y0, b.y0);
|
|
60
|
+
return w > 0 && h > 0 ? w * h : 0;
|
|
61
|
+
}
|
|
62
|
+
function outOfBoundsArea(box, bounds) {
|
|
63
|
+
const total = (box.x1 - box.x0) * (box.y1 - box.y0);
|
|
64
|
+
const w = Math.min(box.x1, bounds.x1) - Math.max(box.x0, bounds.x0);
|
|
65
|
+
const h = Math.min(box.y1, bounds.y1) - Math.max(box.y0, bounds.y0);
|
|
66
|
+
const inside = w > 0 && h > 0 ? w * h : 0;
|
|
67
|
+
return total - inside;
|
|
68
|
+
}
|
|
69
|
+
/** 一个点在距离 d 的候选环:左右紧邻、四个斜角、正上正下。顺序即同代价时的偏好序。 */
|
|
70
|
+
function ringCandidates(p, d) {
|
|
71
|
+
const diag = d * 0.75;
|
|
72
|
+
return [
|
|
73
|
+
{ x: p.cx + d, y: p.cy + 4, anchor: "start" },
|
|
74
|
+
{ x: p.cx - d, y: p.cy + 4, anchor: "end" },
|
|
75
|
+
{ x: p.cx + diag, y: p.cy - diag - 2, anchor: "start" },
|
|
76
|
+
{ x: p.cx - diag, y: p.cy - diag - 2, anchor: "end" },
|
|
77
|
+
{ x: p.cx, y: p.cy - d - LABEL_DESCENT - 2, anchor: "middle" },
|
|
78
|
+
{ x: p.cx + diag, y: p.cy + diag + LABEL_ASCENT, anchor: "start" },
|
|
79
|
+
{ x: p.cx - diag, y: p.cy + diag + LABEL_ASCENT, anchor: "end" },
|
|
80
|
+
{ x: p.cx, y: p.cy + d + LABEL_ASCENT + 2, anchor: "middle" },
|
|
81
|
+
];
|
|
82
|
+
}
|
|
46
83
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
84
|
+
* 散点直接标签的候选位择优布局(docs/feature/reports/library.md「MetricScatter」):
|
|
85
|
+
* 每个标签在点四周由近及远的候选环上打分——与已放置标签的重叠、与任何数据点的重叠、
|
|
86
|
+
* 越出画布的面积、离点距离逐项累加,取代价最小的候选。存在无冲突候选时标签必不遮点、
|
|
87
|
+
* 不叠标签、不越界;全候选冲突时取重叠最小者,绝不丢标签。重合点簇因此向不同方向散开,
|
|
88
|
+
* 而不是单向堆叠压到下方的数据点上。
|
|
49
89
|
*/
|
|
50
|
-
export function
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
90
|
+
export function placePointLabels(points, bounds) {
|
|
91
|
+
const dots = points.map((p) => ({ x0: p.cx - DOT_R, y0: p.cy - DOT_R, x1: p.cx + DOT_R, y1: p.cy + DOT_R }));
|
|
92
|
+
const placedBoxes = [];
|
|
93
|
+
const result = new Array(points.length);
|
|
94
|
+
// 由上到下、由左到右逐个放置,布局确定可复现
|
|
95
|
+
const order = [...points.keys()].sort((a, b) => points[a].cy - points[b].cy || points[a].cx - points[b].cx);
|
|
54
96
|
for (const i of order) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
97
|
+
const p = points[i];
|
|
98
|
+
let best = null;
|
|
99
|
+
for (let ring = 0; ring < RINGS.length; ring++) {
|
|
100
|
+
const candidates = ringCandidates(p, RINGS[ring]);
|
|
101
|
+
for (let c = 0; c < candidates.length; c++) {
|
|
102
|
+
const candidate = candidates[c];
|
|
103
|
+
const box = labelBoxAt(candidate.x, candidate.y, candidate.anchor, p.width);
|
|
104
|
+
let cost = 0;
|
|
105
|
+
for (const placed of placedBoxes)
|
|
106
|
+
cost += overlapArea(box, placed) * 4;
|
|
107
|
+
for (const dot of dots)
|
|
108
|
+
cost += overlapArea(box, dot) * 3;
|
|
109
|
+
cost += outOfBoundsArea(box, bounds) * 6;
|
|
110
|
+
cost += ring * 8 + c * 0.5; // 近环、偏好序靠前者优先,只作同冲突程度下的排序
|
|
111
|
+
if (best === null || cost < best.cost) {
|
|
112
|
+
best = { candidate, box, cost, leader: !(ring === 0 && c <= 1) };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
63
115
|
}
|
|
64
|
-
|
|
65
|
-
|
|
116
|
+
placedBoxes.push(best.box);
|
|
117
|
+
result[i] = { ...best.candidate, leader: best.leader };
|
|
66
118
|
}
|
|
67
|
-
return
|
|
119
|
+
return result;
|
|
68
120
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import type { AttemptListItem, DeltaData, EvalListItem, ExperimentListItem,
|
|
1
|
+
import type { AttemptListItem, DeltaData, EvalListItem, ExperimentListItem, LineData, MatrixData, MetricColumn, ScatterData, ScopeSummaryData, ScoreboardData, TableData } from "../types.ts";
|
|
2
2
|
export declare const passRateColumn: MetricColumn;
|
|
3
3
|
export declare const codeLinesColumn: MetricColumn;
|
|
4
4
|
export declare const costColumn: MetricColumn;
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
export declare const groupSummaryData: GroupSummaryData;
|
|
9
|
-
export declare const tableData: TableData<"pass-rate" | "code-lines">;
|
|
10
|
-
/** rows: "experiment" 的榜单形态:行携带 agent/model 元信息与 eval 级折叠计票。 */
|
|
11
|
-
export declare const tableDataWithMeta: TableData<"pass-rate">;
|
|
5
|
+
/** scopeSummaryData 的产物形态:两级计票恒随行,成功率与总成本是官方 MetricCell。 */
|
|
6
|
+
export declare const scopeSummaryData: ScopeSummaryData;
|
|
7
|
+
export declare const tableData: TableData;
|
|
12
8
|
export declare const matrixData: MatrixData;
|
|
13
9
|
export declare const scoreboardData: ScoreboardData;
|
|
14
10
|
export declare const scatterData: ScatterData;
|
|
15
11
|
export declare const lineData: LineData;
|
|
16
|
-
export declare const deltaData: DeltaData
|
|
12
|
+
export declare const deltaData: DeltaData;
|
|
17
13
|
export declare const attemptListItems: AttemptListItem[];
|
|
18
14
|
export declare const evalListItems: EvalListItem[];
|
|
19
15
|
export declare const experimentListItems: ExperimentListItem[];
|