niceeval 0.5.4 → 0.6.1
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 +55 -0
- package/dist/agents/types.d.ts +321 -0
- package/dist/context/types.d.ts +335 -0
- package/dist/i18n/core.d.ts +11 -0
- package/dist/i18n/en.d.ts +181 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/zh-CN.d.ts +183 -0
- package/dist/o11y/otlp/parse.d.ts +3 -0
- package/dist/o11y/otlp/receiver.d.ts +21 -0
- package/dist/o11y/otlp/turn-otel.d.ts +43 -0
- package/dist/o11y/types.d.ts +190 -0
- package/dist/report/aggregate.d.ts +57 -0
- package/dist/report/aggregate.js +212 -0
- package/dist/report/built-ins/experiment-comparison.d.ts +1 -0
- package/dist/report/built-ins/experiment-comparison.js +13 -0
- package/dist/report/built-ins/index.d.ts +1 -0
- package/dist/report/built-ins/index.js +2 -0
- package/dist/report/components.d.ts +180 -0
- package/dist/report/components.js +132 -0
- package/dist/report/compute.d.ts +106 -0
- package/dist/report/compute.js +600 -0
- package/dist/report/flag.d.ts +6 -0
- package/dist/report/flag.js +8 -0
- package/dist/report/format.d.ts +26 -0
- package/dist/report/format.js +109 -0
- package/dist/report/index.d.ts +19 -0
- package/dist/report/index.js +30 -0
- package/dist/report/load.d.ts +12 -0
- package/dist/report/load.js +56 -0
- package/dist/report/locale.d.ts +94 -0
- package/dist/report/locale.js +183 -0
- package/dist/report/metrics.d.ts +21 -0
- package/dist/report/metrics.js +115 -0
- package/dist/report/primitives.d.ts +64 -0
- package/dist/report/primitives.js +113 -0
- package/dist/report/react/AttemptList.d.ts +23 -0
- package/dist/report/react/AttemptList.js +19 -0
- package/dist/report/react/DeltaTable.d.ts +8 -0
- package/dist/report/react/DeltaTable.js +24 -0
- package/dist/report/react/EvalList.d.ts +10 -0
- package/dist/report/react/EvalList.js +0 -0
- package/dist/report/react/ExperimentList.d.ts +11 -0
- package/dist/report/react/ExperimentList.js +67 -0
- package/dist/report/react/GroupSummary.d.ts +8 -0
- package/dist/report/react/GroupSummary.js +8 -0
- package/dist/report/react/MetricBars.d.ts +10 -0
- package/dist/report/react/MetricBars.js +48 -0
- package/dist/report/react/MetricLine.d.ts +9 -0
- package/dist/report/react/MetricLine.js +68 -0
- package/dist/report/react/MetricMatrix.d.ts +10 -0
- package/dist/report/react/MetricMatrix.js +23 -0
- package/dist/report/react/MetricScatter.d.ts +9 -0
- package/dist/report/react/MetricScatter.js +96 -0
- package/dist/report/react/MetricTable.d.ts +11 -0
- package/dist/report/react/MetricTable.js +26 -0
- package/dist/report/react/RunOverview.d.ts +8 -0
- package/dist/report/react/RunOverview.js +12 -0
- package/dist/report/react/Scoreboard.d.ts +8 -0
- package/dist/report/react/Scoreboard.js +26 -0
- package/dist/report/react/cell.d.ts +9 -0
- package/dist/report/react/cell.js +9 -0
- package/dist/report/react/chart-math.d.ts +14 -0
- package/dist/report/react/chart-math.js +68 -0
- package/dist/report/react/colors.d.ts +14 -0
- package/dist/report/react/colors.js +45 -0
- package/dist/report/react/fixtures.d.ts +19 -0
- package/dist/report/react/fixtures.js +398 -0
- package/dist/report/react/format.d.ts +3 -0
- package/dist/report/react/format.js +7 -0
- package/dist/report/react/index.d.ts +6 -0
- package/dist/report/react/index.js +14 -0
- package/dist/report/report.d.ts +24 -0
- package/dist/report/report.js +49 -0
- package/dist/report/text/faces.d.ts +29 -0
- package/dist/report/text/faces.js +541 -0
- package/dist/report/text/layout.d.ts +75 -0
- package/dist/report/text/layout.js +173 -0
- package/dist/report/text/plot.d.ts +37 -0
- package/dist/report/text/plot.js +81 -0
- package/dist/report/text/table.d.ts +8 -0
- package/dist/report/text/table.js +86 -0
- package/dist/report/tree.d.ts +99 -0
- package/dist/report/tree.js +228 -0
- package/dist/report/types.d.ts +408 -0
- package/dist/report/types.js +4 -0
- package/dist/report/web.d.ts +15 -0
- package/dist/report/web.js +37 -0
- package/dist/results/locator.d.ts +75 -0
- package/dist/results/locator.js +0 -0
- package/dist/results/select.d.ts +45 -0
- package/dist/results/select.js +230 -0
- package/dist/results/source-hash.d.ts +9 -0
- package/dist/results/types.d.ts +204 -0
- package/dist/runner/eval-source.d.ts +22 -0
- package/dist/runner/fingerprint.d.ts +23 -0
- package/dist/runner/types.d.ts +332 -0
- package/dist/sandbox/docker-stream.d.ts +24 -0
- package/dist/sandbox/docker.d.ts +84 -0
- package/dist/sandbox/e2b.d.ts +31 -0
- package/dist/sandbox/errors.d.ts +4 -0
- package/dist/sandbox/local-files.d.ts +6 -0
- package/dist/sandbox/paths.d.ts +4 -0
- package/dist/sandbox/registry.d.ts +13 -0
- package/dist/sandbox/resolve.d.ts +40 -0
- package/dist/sandbox/retry.d.ts +10 -0
- package/dist/sandbox/shell.d.ts +11 -0
- package/dist/sandbox/source-files.d.ts +13 -0
- package/dist/sandbox/types.d.ts +203 -0
- package/dist/sandbox/vercel.d.ts +37 -0
- package/dist/scoring/types.d.ts +70 -0
- package/dist/shared/aggregate.d.ts +29 -0
- package/dist/shared/aggregate.js +55 -0
- package/dist/shared/types.d.ts +27 -0
- package/dist/shared/verdict.d.ts +27 -0
- package/dist/shared/verdict.js +34 -0
- package/dist/tty-line.d.ts +6 -0
- package/dist/types.d.ts +7 -0
- package/dist/util.d.ts +22 -0
- package/docs-site/zh/concepts/adapter.mdx +7 -7
- package/docs-site/zh/concepts/assert.mdx +19 -18
- package/docs-site/zh/concepts/evals.mdx +12 -11
- package/docs-site/zh/concepts/experiment.mdx +2 -2
- package/docs-site/zh/concepts/judge.mdx +9 -9
- package/docs-site/zh/concepts/overview.mdx +3 -3
- package/docs-site/zh/concepts/tier.mdx +6 -6
- package/docs-site/zh/example/claude-code-codex-plugin.mdx +9 -5
- package/docs-site/zh/example/claude-code-codex-skill.mdx +12 -7
- package/docs-site/zh/guides/agent-feedback-loop.mdx +237 -78
- package/docs-site/zh/guides/connect-otel.mdx +3 -3
- package/docs-site/zh/guides/connect-your-agent.mdx +2 -2
- package/docs-site/zh/guides/custom-reports.mdx +196 -36
- package/docs-site/zh/guides/experiments.mdx +7 -1
- package/docs-site/zh/guides/fixtures.mdx +4 -2
- package/docs-site/zh/guides/official-adapters.mdx +31 -9
- package/docs-site/zh/guides/publish-report.mdx +4 -4
- package/docs-site/zh/guides/report-components.mdx +194 -55
- package/docs-site/zh/guides/reporters.mdx +2 -2
- package/docs-site/zh/guides/results-data.mdx +61 -34
- package/docs-site/zh/guides/runner.mdx +2 -2
- package/docs-site/zh/guides/sandbox-agent.mdx +3 -2
- package/docs-site/zh/guides/{sandbox-backends.mdx → sandbox-providers.mdx} +12 -12
- package/docs-site/zh/guides/viewing-results.mdx +200 -79
- package/docs-site/zh/guides/write-experiment.mdx +9 -1
- package/docs-site/zh/guides/write-send.mdx +4 -3
- package/docs-site/zh/index.mdx +4 -3
- package/docs-site/zh/introduction.mdx +2 -1
- package/docs-site/zh/quickstart.mdx +5 -3
- package/docs-site/zh/reference/builtin-agents.mdx +38 -13
- package/docs-site/zh/reference/capabilities.mdx +1 -1
- package/docs-site/zh/reference/cli.mdx +36 -13
- package/docs-site/zh/reference/define-agent.mdx +15 -13
- package/docs-site/zh/reference/define-config.mdx +1 -1
- package/docs-site/zh/reference/define-eval.mdx +3 -3
- package/docs-site/zh/reference/events.mdx +9 -3
- package/docs-site/zh/reference/expect.mdx +13 -8
- package/package.json +10 -6
- package/src/agents/bub.ts +129 -42
- package/src/agents/claude-code.test.ts +152 -0
- package/src/agents/claude-code.ts +127 -13
- package/src/agents/codex.test.ts +192 -0
- package/src/agents/codex.ts +151 -12
- package/src/agents/index.ts +9 -3
- package/src/agents/manifest.ts +41 -0
- package/src/agents/plugin-config.test.ts +94 -0
- package/src/agents/shared.ts +33 -2
- package/src/agents/skills.test.ts +214 -0
- package/src/agents/skills.ts +304 -0
- package/src/agents/streaming.ts +5 -5
- package/src/agents/types.ts +59 -3
- package/src/cli.ts +74 -47
- package/src/context/context.test.ts +20 -2
- package/src/context/control-flow.ts +1 -1
- package/src/context/session.test.ts +92 -1
- package/src/context/session.ts +23 -1
- package/src/context/types.ts +4 -4
- package/src/define.test.ts +8 -8
- package/src/define.ts +11 -11
- package/src/expect/index.ts +5 -5
- package/src/i18n/en.ts +33 -15
- package/src/i18n/zh-CN.ts +37 -21
- package/src/index.ts +1 -1
- package/src/o11y/execution-tree.test.ts +452 -0
- package/src/o11y/execution-tree.ts +367 -0
- package/src/o11y/otlp/receiver.ts +1 -1
- package/src/o11y/otlp/select.ts +7 -3
- package/src/o11y/parsers/claude-code.test.ts +175 -0
- package/src/o11y/parsers/claude-code.ts +32 -0
- package/src/o11y/types.ts +6 -1
- package/src/report/aggregate.ts +26 -20
- package/src/report/built-in-user-parity.test.tsx +640 -0
- package/src/report/built-ins/experiment-comparison.tsx +19 -0
- package/src/report/built-ins/index.ts +2 -0
- package/src/report/components.tsx +225 -50
- package/src/report/compute.ts +335 -54
- package/src/report/dual-render.test.tsx +1129 -0
- package/src/report/flag.ts +1 -1
- package/src/report/format.ts +35 -2
- package/src/report/index.ts +47 -14
- package/src/report/load.ts +1 -1
- package/src/report/locale.ts +229 -0
- package/src/report/metrics.ts +39 -15
- package/src/report/primitives.tsx +100 -2
- package/src/report/react/AttemptList.tsx +113 -0
- package/src/report/react/DeltaTable.tsx +9 -6
- package/src/report/react/EvalList.tsx +0 -0
- package/src/report/react/ExperimentList.tsx +220 -0
- package/src/report/react/GroupSummary.tsx +66 -0
- package/src/report/react/MetricBars.tsx +24 -13
- package/src/report/react/MetricLine.tsx +21 -21
- package/src/report/react/MetricMatrix.tsx +8 -4
- package/src/report/react/MetricScatter.tsx +126 -96
- package/src/report/react/MetricTable.tsx +115 -15
- package/src/report/react/RunOverview.tsx +48 -26
- package/src/report/react/Scoreboard.tsx +15 -7
- package/src/report/react/cell.tsx +18 -9
- package/src/{view/app/lib/chart.ts → report/react/chart-math.ts} +2 -6
- package/src/report/react/colors.ts +24 -15
- package/src/report/react/enhance.js +168 -0
- package/src/report/react/fixtures.ts +169 -34
- package/src/report/react/format.ts +1 -1
- package/src/report/react/index.tsx +21 -6
- package/src/report/react/render.test.tsx +180 -31
- package/src/report/react/styles.css +432 -213
- package/src/report/report.test.ts +398 -94
- package/src/report/report.ts +29 -11
- package/src/report/text/faces.ts +344 -96
- package/src/report/text/layout.ts +76 -11
- package/src/report/text/table.ts +98 -0
- package/src/report/tree.ts +103 -20
- package/src/report/types.ts +184 -25
- package/src/report/web.ts +46 -19
- package/src/results/annotated-source.test.ts +146 -0
- package/src/results/annotated-source.ts +128 -0
- package/src/results/attempt-evidence.test.ts +158 -0
- package/src/results/attempt-evidence.ts +158 -0
- package/src/results/attempt-source.ts +48 -0
- package/src/results/copy.ts +154 -139
- package/src/results/format.ts +54 -47
- package/src/results/host-equivalence.test.ts +527 -0
- package/src/results/index.ts +56 -14
- package/src/results/locator.test.ts +198 -0
- package/src/results/locator.ts +0 -0
- package/src/results/open.ts +392 -175
- package/src/results/results.test.ts +943 -494
- package/src/results/select.ts +129 -23
- package/src/results/skipped-notice.ts +0 -0
- package/src/results/source-hash.ts +28 -0
- package/src/results/types.ts +98 -62
- package/src/results/writer.ts +304 -176
- package/src/runner/attempt.test.ts +170 -0
- package/src/runner/attempt.ts +48 -13
- package/src/runner/discover.test.ts +65 -0
- package/src/runner/discover.ts +6 -2
- package/src/runner/eval-source.test.ts +121 -0
- package/src/runner/eval-source.ts +45 -0
- package/src/runner/fingerprint.ts +54 -1
- package/src/runner/remote-sandbox.ts +1 -1
- package/src/runner/report.test.ts +6 -8
- package/src/runner/report.ts +5 -4
- package/src/runner/reporters/artifacts.ts +27 -41
- package/src/runner/reporters/braintrust.test.ts +3 -3
- package/src/runner/reporters/braintrust.ts +1 -1
- package/src/runner/reporters/console.ts +6 -6
- package/src/runner/reporters/json.ts +4 -4
- package/src/runner/reporters/live.test.ts +56 -0
- package/src/runner/reporters/live.ts +36 -10
- package/src/runner/reporters/quiet.test.ts +66 -0
- package/src/runner/reporters/quiet.ts +49 -0
- package/src/runner/reporters/shared.ts +5 -5
- package/src/runner/reporters/table.ts +17 -17
- package/src/runner/run.ts +61 -102
- package/src/runner/types.ts +43 -32
- package/src/sandbox/checkpoint.ts +1 -1
- package/src/sandbox/docker.ts +15 -2
- package/src/sandbox/e2b.ts +11 -5
- package/src/sandbox/errors.ts +13 -0
- package/src/sandbox/index.ts +3 -3
- package/src/sandbox/local-files.ts +1 -1
- package/src/sandbox/registry.ts +6 -5
- package/src/sandbox/resolve.ts +38 -23
- package/src/sandbox/retry.test.ts +68 -0
- package/src/sandbox/retry.ts +44 -0
- package/src/sandbox/types.ts +24 -24
- package/src/sandbox/vercel.ts +17 -3
- package/src/scoring/collector.ts +3 -3
- package/src/scoring/judge.ts +2 -2
- package/src/scoring/scoped.ts +13 -1
- package/src/scoring/types.ts +7 -7
- package/src/scoring/verdict.ts +4 -4
- package/src/shared/aggregate.ts +23 -3
- package/src/shared/types.ts +2 -2
- package/src/shared/{outcome.ts → verdict.ts} +15 -15
- package/src/show/compose.ts +12 -132
- package/src/show/index.ts +119 -95
- package/src/show/render.ts +462 -159
- package/src/show/show.test.ts +471 -253
- package/src/source-loc.ts +1 -1
- package/src/tty-line.ts +32 -0
- package/src/types.ts +2 -2
- package/src/util.test.ts +21 -1
- package/src/util.ts +5 -1
- package/src/view/app/App.tsx +33 -198
- package/src/view/app/components/AttemptModal.tsx +6 -6
- package/src/view/app/components/CodeView.tsx +2 -2
- package/src/view/app/components/CopyControls.tsx +32 -36
- package/src/view/app/components/SkippedRunsBanner.tsx +140 -0
- package/src/view/app/components/ui/badge.tsx +1 -1
- package/src/view/app/components/ui/dialog.tsx +2 -2
- package/src/view/app/i18n.ts +40 -31
- package/src/view/app/lib/artifact-url.ts +1 -1
- package/src/view/app/lib/attempt-route.test.ts +37 -47
- package/src/view/app/lib/attempt-route.ts +26 -26
- package/src/view/app/lib/rows.ts +9 -112
- package/src/view/app/lib/verdict.ts +25 -0
- package/src/view/app/main.tsx +9 -12
- package/src/view/app/pages/RunsPage.tsx +4 -4
- package/src/view/app/pages/TracesPage.tsx +3 -3
- package/src/view/app/shared.ts +0 -1
- package/src/view/app/types.ts +6 -51
- package/src/view/artifact-serving.test.ts +136 -0
- package/src/view/client-dist/app.css +1 -1
- package/src/view/client-dist/app.js +21 -21
- package/src/view/data.test.ts +214 -143
- package/src/view/data.ts +166 -120
- package/src/view/index.ts +23 -11
- package/src/view/server.ts +52 -17
- package/src/view/shared/types.ts +22 -31
- package/src/view/styles.css +117 -327
- package/src/view/view-report.test.ts +146 -98
- package/src/report/default-report.tsx +0 -222
- package/src/report/dual-face.test.tsx +0 -527
- package/src/report/react/CaseList.tsx +0 -70
- package/src/view/app/components/CostScoreChart.tsx +0 -147
- package/src/view/app/components/ExperimentTable.tsx +0 -284
- package/src/view/app/components/GroupSelector.tsx +0 -61
- package/src/view/app/components/primitives.tsx +0 -43
- package/src/view/app/lib/outcome.ts +0 -82
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AttemptLocator } from "../results/locator.ts";
|
|
2
|
+
import { type ReportNode } from "./tree.ts";
|
|
3
|
+
import { type ReportLocale } from "./locale.ts";
|
|
4
|
+
import { type ColumnAlign } from "./text/layout.ts";
|
|
5
|
+
export interface LayoutProps {
|
|
6
|
+
children?: ReportNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行)。 */
|
|
10
|
+
export declare const Col: import("./tree.ts").ReportComponent<LayoutProps>;
|
|
11
|
+
/** 并排:网页横向排布,终端字符分栏;终端宽度不够时自动降级为纵向。 */
|
|
12
|
+
export declare const Row: import("./tree.ts").ReportComponent<LayoutProps>;
|
|
13
|
+
export interface SectionProps extends LayoutProps {
|
|
14
|
+
title: string;
|
|
15
|
+
}
|
|
16
|
+
/** 带标题的块:网页是标题层级,终端是标题行加缩进。 */
|
|
17
|
+
export declare const Section: import("./tree.ts").ReportComponent<SectionProps>;
|
|
18
|
+
/** 说明文字:网页是段落,终端是折行文本。 */
|
|
19
|
+
export declare const Text: import("./tree.ts").ReportComponent<LayoutProps>;
|
|
20
|
+
export interface StyleProps {
|
|
21
|
+
children?: string;
|
|
22
|
+
}
|
|
23
|
+
/** 自定义组件的样式随树带走:web 面吐 <style> 标签,text 面渲染为空。 */
|
|
24
|
+
export declare const Style: import("./tree.ts").ReportComponent<StyleProps>;
|
|
25
|
+
/** 一列的定义:取哪个 cells 键、表头写什么、往哪边对齐。 */
|
|
26
|
+
export interface TableColumn {
|
|
27
|
+
/** 取 `row.cells[key]` 的键。 */
|
|
28
|
+
key: string;
|
|
29
|
+
/** 表头文案,两个面都原样渲染。 */
|
|
30
|
+
header: string;
|
|
31
|
+
/** 对齐方向,默认 `"left"`;`"right"` 按显示宽度右对齐,数字列用。 */
|
|
32
|
+
align?: ColumnAlign;
|
|
33
|
+
}
|
|
34
|
+
/** 一行的数据:身份键、已格式化的格子、可选的 attempt locator。 */
|
|
35
|
+
export interface TableRow {
|
|
36
|
+
/** 行身份。 */
|
|
37
|
+
key: string;
|
|
38
|
+
/** 已格式化的显示值;`null`(或缺这个键)渲染成 `—`,不补 0。 */
|
|
39
|
+
cells: Record<string, string | null>;
|
|
40
|
+
/** 带上就多一列 attempt:web 面链到证据室,text 面列出 locator。 */
|
|
41
|
+
locator?: AttemptLocator;
|
|
42
|
+
}
|
|
43
|
+
export interface TableProps {
|
|
44
|
+
/** 列定义;数组顺序即渲染顺序。 */
|
|
45
|
+
columns: TableColumn[];
|
|
46
|
+
/** 行数据;数组顺序即渲染顺序,组件不重排也不过滤。 */
|
|
47
|
+
rows: TableRow[];
|
|
48
|
+
/** 组件自带文案(attempt 表头、丢列提示)的语言;省略时随宿主。 */
|
|
49
|
+
locale?: ReportLocale;
|
|
50
|
+
/** web 面挂到 `<table>` 上。 */
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 自定义表的标准件:列由报告作者定,格子是算好的显示值,两个面各自排整齐。
|
|
55
|
+
*
|
|
56
|
+
* text 面列宽按**显示宽度**算(CJK / 全角记 2 列),所以中文列不会撕歪;总宽超过
|
|
57
|
+
* `ctx.width` 时先折最宽的左对齐列(右对齐列是数字,折行读不了),压到下限仍放不下
|
|
58
|
+
* 就从右侧丢列并在表下如实报丢了几列。web 面是 `<table>` + `<thead>` / `<tbody>`,
|
|
59
|
+
* 右对齐落成 `nre-align-right` 类,不用内联样式。
|
|
60
|
+
*
|
|
61
|
+
* 官方的 `MetricTable` / `MetricMatrix` / `Scoreboard` / `DeltaTable` 的 text 面就建在
|
|
62
|
+
* 这个组件上:自定义表和官方表用同一把尺子。
|
|
63
|
+
*/
|
|
64
|
+
export declare const Table: import("./tree.ts").ReportComponent<TableProps>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { defineComponent } from "./tree.js";
|
|
3
|
+
import { localeText } from "./locale.js";
|
|
4
|
+
import { indentBlock, joinColumns, wrapDisplay } from "./text/layout.js";
|
|
5
|
+
import { renderTableText } from "./text/table.js";
|
|
6
|
+
function childArray(children) {
|
|
7
|
+
if (children === null || children === undefined || typeof children === "boolean")
|
|
8
|
+
return [];
|
|
9
|
+
return Array.isArray(children) ? children : [children];
|
|
10
|
+
}
|
|
11
|
+
function cx(...parts) {
|
|
12
|
+
return parts.filter(Boolean).join(" ");
|
|
13
|
+
}
|
|
14
|
+
/** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行)。 */
|
|
15
|
+
export const Col = defineComponent({
|
|
16
|
+
web({ children, className }) {
|
|
17
|
+
return _jsx("div", { className: cx("nre", "nre-col", className), children: children });
|
|
18
|
+
},
|
|
19
|
+
text({ children }, ctx) {
|
|
20
|
+
return childArray(children)
|
|
21
|
+
.map((child) => ctx.render(child))
|
|
22
|
+
.filter((block) => block.length > 0)
|
|
23
|
+
.join("\n\n");
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Col.displayName = "Col";
|
|
27
|
+
// Row 的每栏至少留这个宽度,不硬挤;不够就降级纵向
|
|
28
|
+
const MIN_COLUMN_WIDTH = 24;
|
|
29
|
+
const COLUMN_SEPARATOR = " │ ";
|
|
30
|
+
/** 并排:网页横向排布,终端字符分栏;终端宽度不够时自动降级为纵向。 */
|
|
31
|
+
export const Row = defineComponent({
|
|
32
|
+
web({ children, className }) {
|
|
33
|
+
return _jsx("div", { className: cx("nre", "nre-row", className), children: children });
|
|
34
|
+
},
|
|
35
|
+
text({ children }, ctx) {
|
|
36
|
+
const blocks = childArray(children).filter((child) => child !== null && child !== undefined && typeof child !== "boolean");
|
|
37
|
+
if (blocks.length === 0)
|
|
38
|
+
return "";
|
|
39
|
+
if (blocks.length === 1)
|
|
40
|
+
return ctx.render(blocks[0]);
|
|
41
|
+
const columnWidth = Math.floor((ctx.width - COLUMN_SEPARATOR.length * (blocks.length - 1)) / blocks.length);
|
|
42
|
+
if (columnWidth < MIN_COLUMN_WIDTH) {
|
|
43
|
+
// 宽度不足:降级纵向,与 Col 同一形态
|
|
44
|
+
return blocks
|
|
45
|
+
.map((child) => ctx.render(child))
|
|
46
|
+
.filter((block) => block.length > 0)
|
|
47
|
+
.join("\n\n");
|
|
48
|
+
}
|
|
49
|
+
const rendered = blocks.map((child) => ctx.render(child, columnWidth));
|
|
50
|
+
return joinColumns(rendered, rendered.map(() => columnWidth), COLUMN_SEPARATOR);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
Row.displayName = "Row";
|
|
54
|
+
/** 带标题的块:网页是标题层级,终端是标题行加缩进。 */
|
|
55
|
+
export const Section = defineComponent({
|
|
56
|
+
web({ title, children, className }) {
|
|
57
|
+
return (_jsxs("section", { className: cx("nre", "nre-section", className), children: [_jsx("h2", { className: "nre-section-title", children: title }), children] }));
|
|
58
|
+
},
|
|
59
|
+
text({ title, children }, ctx) {
|
|
60
|
+
const body = childArray(children)
|
|
61
|
+
.map((child) => ctx.render(child, ctx.width - 2))
|
|
62
|
+
.filter((block) => block.length > 0)
|
|
63
|
+
.join("\n\n");
|
|
64
|
+
return body.length > 0 ? `${title}\n${indentBlock(body, " ")}` : title;
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
Section.displayName = "Section";
|
|
68
|
+
/** 说明文字:网页是段落,终端是折行文本。 */
|
|
69
|
+
export const Text = defineComponent({
|
|
70
|
+
web({ children, className }) {
|
|
71
|
+
return _jsx("p", { className: cx("nre", "nre-text", className), children: children });
|
|
72
|
+
},
|
|
73
|
+
text({ children }, ctx) {
|
|
74
|
+
return wrapDisplay(ctx.render(children), ctx.width).join("\n");
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
Text.displayName = "Text";
|
|
78
|
+
/** 自定义组件的样式随树带走:web 面吐 <style> 标签,text 面渲染为空。 */
|
|
79
|
+
export const Style = defineComponent({
|
|
80
|
+
web({ children }) {
|
|
81
|
+
return _jsx("style", { children: children });
|
|
82
|
+
},
|
|
83
|
+
text() {
|
|
84
|
+
return "";
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
Style.displayName = "Style";
|
|
88
|
+
const MISSING_MARK = "—";
|
|
89
|
+
/**
|
|
90
|
+
* 自定义表的标准件:列由报告作者定,格子是算好的显示值,两个面各自排整齐。
|
|
91
|
+
*
|
|
92
|
+
* text 面列宽按**显示宽度**算(CJK / 全角记 2 列),所以中文列不会撕歪;总宽超过
|
|
93
|
+
* `ctx.width` 时先折最宽的左对齐列(右对齐列是数字,折行读不了),压到下限仍放不下
|
|
94
|
+
* 就从右侧丢列并在表下如实报丢了几列。web 面是 `<table>` + `<thead>` / `<tbody>`,
|
|
95
|
+
* 右对齐落成 `nre-align-right` 类,不用内联样式。
|
|
96
|
+
*
|
|
97
|
+
* 官方的 `MetricTable` / `MetricMatrix` / `Scoreboard` / `DeltaTable` 的 text 面就建在
|
|
98
|
+
* 这个组件上:自定义表和官方表用同一把尺子。
|
|
99
|
+
*/
|
|
100
|
+
export const Table = defineComponent({
|
|
101
|
+
web({ columns, rows, locale, className }, ctx) {
|
|
102
|
+
const chrome = locale ?? ctx.locale;
|
|
103
|
+
const hasLocator = rows.some((row) => row.locator !== undefined);
|
|
104
|
+
const alignClass = (align) => (align === "right" ? "nre-align-right" : undefined);
|
|
105
|
+
return (_jsxs("table", { className: cx("nre", "nre-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [columns.map((column) => (_jsx("th", { scope: "col", className: alignClass(column.align), children: column.header }, column.key))), hasLocator ? _jsx("th", { scope: "col", children: localeText(chrome, "table.attempt") }) : null] }) }), _jsx("tbody", { children: rows.map((row) => (_jsxs("tr", { children: [columns.map((column) => {
|
|
106
|
+
const value = row.cells[column.key];
|
|
107
|
+
const missing = value === null || value === undefined;
|
|
108
|
+
return (_jsx("td", { className: alignClass(column.align), children: missing ? _jsx("span", { className: "nre-missing", children: MISSING_MARK }) : value }, column.key));
|
|
109
|
+
}), hasLocator ? (_jsx("td", { children: row.locator ? (_jsx("a", { className: "nre-locator", href: ctx.attemptHref(row.locator), children: row.locator })) : (_jsx("span", { className: "nre-missing", children: MISSING_MARK })) })) : null] }, row.key))) })] }));
|
|
110
|
+
},
|
|
111
|
+
text: renderTableText,
|
|
112
|
+
});
|
|
113
|
+
Table.displayName = "Table";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { AttemptListItem } from "../types.ts";
|
|
3
|
+
import type { AttemptLocator } from "../../results/locator.ts";
|
|
4
|
+
import { type ReportLocale } from "../locale.ts";
|
|
5
|
+
/** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
|
|
6
|
+
export declare function AttemptLocatorBadge({ item, attemptHref, }: {
|
|
7
|
+
item: Pick<AttemptListItem, "locator" | "verdict">;
|
|
8
|
+
attemptHref: (locator: AttemptLocator) => string;
|
|
9
|
+
}): ReactElement;
|
|
10
|
+
/** 一条 Attempt 的完整卡片:AttemptList 自己的一项,也是 EvalList 展开区里的一行。 */
|
|
11
|
+
export declare function AttemptRow({ item, attemptHref, locale, }: {
|
|
12
|
+
item: AttemptListItem;
|
|
13
|
+
attemptHref: (locator: AttemptLocator) => string;
|
|
14
|
+
locale?: ReportLocale;
|
|
15
|
+
}): ReactElement;
|
|
16
|
+
export declare function AttemptList({ items, total, attemptHref, className, locale, }: {
|
|
17
|
+
items: AttemptListItem[];
|
|
18
|
+
/** items 被 slice 时的原始数量;如实显示还剩多少条没展示。 */
|
|
19
|
+
total?: number;
|
|
20
|
+
attemptHref: (locator: AttemptLocator) => string;
|
|
21
|
+
className?: string;
|
|
22
|
+
locale?: ReportLocale;
|
|
23
|
+
}): ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
|
|
3
|
+
import { colorClassForKey } from "./colors.js";
|
|
4
|
+
import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
|
|
5
|
+
/** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
|
|
6
|
+
export function AttemptLocatorBadge({ item, attemptHref, }) {
|
|
7
|
+
return (_jsxs("a", { className: cx("nre-locator", `nre-verdict-${item.verdict}`), href: attemptHref(item.locator), children: [item.locator, _jsx("span", { className: "nre-locator-mark", children: verdictMark(item.verdict) })] }));
|
|
8
|
+
}
|
|
9
|
+
function AssertionRow({ assertion, locale }) {
|
|
10
|
+
return (_jsxs("li", { className: cx("nre-assertion", `nre-assertion-${assertion.severity}`, !assertion.passed && "nre-assertion-failed"), children: [_jsx("span", { className: "nre-assertion-severity", children: assertion.severity }), _jsx("span", { className: "nre-assertion-name", children: assertion.name }), _jsx("span", { className: "nre-assertion-score", children: localeText(locale, "attemptList.score", { score: assertion.score }) }), (assertion.detail || assertion.evidence) && (_jsxs("details", { className: "nre-assertion-more", children: [_jsx("summary", { children: localeText(locale, "attemptList.details") }), assertion.detail && _jsx("p", { className: "nre-assertion-detail", children: assertion.detail }), assertion.evidence && _jsx("blockquote", { className: "nre-assertion-evidence", children: assertion.evidence })] }))] }));
|
|
11
|
+
}
|
|
12
|
+
/** 一条 Attempt 的完整卡片:AttemptList 自己的一项,也是 EvalList 展开区里的一行。 */
|
|
13
|
+
export function AttemptRow({ item, attemptHref, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
14
|
+
return (_jsxs("li", { className: cx("nre-attempt", `nre-attempt-${item.verdict}`), children: [_jsxs("div", { className: "nre-attempt-head", children: [_jsx(AttemptLocatorBadge, { item: item, attemptHref: attemptHref }), _jsx("span", { className: "nre-attempt-eval", children: item.evalId }), _jsx("span", { className: "nre-attempt-experiment", children: item.experimentId }), _jsx("span", { className: cx("nre-attempt-agent", "nre-key", colorClassForKey(item.agent)), children: item.agent }), _jsx("span", { className: "nre-attempt-duration", children: formatDurationMs(item.durationMs) }), item.costUSD !== undefined && _jsx("span", { className: "nre-attempt-cost", children: formatUSD(item.costUSD) })] }), item.error && _jsx("p", { className: "nre-attempt-error", children: item.error }), item.assertions.length > 0 && (_jsx("ul", { className: "nre-assertions", children: item.assertions.map((a, i) => (_jsx(AssertionRow, { assertion: a, locale: locale }, i))) }))] }));
|
|
15
|
+
}
|
|
16
|
+
export function AttemptList({ items, total, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
17
|
+
const remaining = (total ?? items.length) - items.length;
|
|
18
|
+
return (_jsxs("section", { className: cx("nre", "nre-attempt-list", className), children: [items.length === 0 && _jsx("p", { className: "nre-attempt-list-empty", children: localeText(locale, "attemptList.empty") }), _jsx("ul", { className: "nre-attempts", children: items.map((item) => (_jsx(AttemptRow, { item: item, attemptHref: attemptHref, locale: locale }, item.locator))) }), remaining > 0 && (_jsx("p", { className: "nre-truncated", children: localeText(locale, "attemptList.truncated", { n: remaining }) }))] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { DeltaData } from "../types.ts";
|
|
3
|
+
import { type ReportLocale } from "../locale.ts";
|
|
4
|
+
export declare function DeltaTable({ data, className, locale, }: {
|
|
5
|
+
data: DeltaData;
|
|
6
|
+
className?: string;
|
|
7
|
+
locale?: ReportLocale;
|
|
8
|
+
}): ReactElement;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, localeText, resolveMetricLabel } from "../locale.js";
|
|
3
|
+
import { MetricCellView } from "./cell.js";
|
|
4
|
+
import { colorClassForKey } from "./colors.js";
|
|
5
|
+
import { cx } from "./format.js";
|
|
6
|
+
/** Δ 的语义配色 class:好/坏由 better 方向判定,不看正负号本身。 */
|
|
7
|
+
function deltaToneClass(delta, better) {
|
|
8
|
+
if (delta === null)
|
|
9
|
+
return "nre-delta-missing";
|
|
10
|
+
if (delta === 0)
|
|
11
|
+
return "nre-delta-flat";
|
|
12
|
+
if (!better)
|
|
13
|
+
return "nre-delta-neutral"; // 指标没表态方向,只显示不评判
|
|
14
|
+
const improved = better === "higher" ? delta > 0 : delta < 0;
|
|
15
|
+
return improved ? "nre-delta-good" : "nre-delta-bad";
|
|
16
|
+
}
|
|
17
|
+
export function DeltaTable({ data, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
18
|
+
return (_jsxs("table", { className: cx("nre", "nre-delta-table", className), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: localeText(locale, "delta.pairHeader") }), data.columns.map((col) => (_jsxs("th", { scope: "col", className: "nre-metric-col", children: [resolveMetricLabel(col.label, locale, col.key), col.unit && _jsxs("span", { className: "nre-unit", children: ["(", col.unit, ")"] })] }, col.key)))] }) }), _jsx("tbody", { children: data.rows.map((row) => (_jsxs("tr", { children: [_jsxs("th", { scope: "row", className: "nre-pair", children: [_jsx("span", { className: cx("nre-row-key", "nre-key", colorClassForKey(row.key)), children: row.key }), _jsxs("span", { className: "nre-pair-ids", children: [row.a.experimentId, " \u2192 ", row.b.experimentId] })] }), data.columns.map((col) => {
|
|
19
|
+
const cell = row.cells[col.key];
|
|
20
|
+
if (!cell)
|
|
21
|
+
return _jsx("td", { className: "nre-td-empty" }, col.key);
|
|
22
|
+
return (_jsxs("td", { className: "nre-delta-cell", children: [_jsxs("span", { className: "nre-delta-side nre-delta-a", children: [_jsx("span", { className: "nre-delta-tag", children: "A" }), _jsx(MetricCellView, { cell: cell.a, locale: locale })] }), _jsxs("span", { className: "nre-delta-side nre-delta-b", children: [_jsx("span", { className: "nre-delta-tag", children: "B" }), _jsx(MetricCellView, { cell: cell.b, locale: locale })] }), _jsxs("span", { className: cx("nre-delta-side", "nre-delta-d", deltaToneClass(cell.delta, col.better)), children: [_jsx("span", { className: "nre-delta-tag", children: "\u0394" }), cell.delta === null ? _jsx("span", { className: "nre-missing", children: localeText(locale, "cell.missing") }) : cell.display] })] }, col.key));
|
|
23
|
+
})] }, row.key))) })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { EvalListItem } from "../types.ts";
|
|
3
|
+
import type { AttemptLocator } from "../../results/locator.ts";
|
|
4
|
+
import { type ReportLocale } from "../locale.ts";
|
|
5
|
+
export declare function EvalList({ items, attemptHref, className, locale, }: {
|
|
6
|
+
items: EvalListItem[];
|
|
7
|
+
attemptHref: (locator: AttemptLocator) => string;
|
|
8
|
+
className?: string;
|
|
9
|
+
locale?: ReportLocale;
|
|
10
|
+
}): ReactElement;
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { AttemptLocator } from "../../results/locator.ts";
|
|
3
|
+
import type { ExperimentListItem } from "../types.ts";
|
|
4
|
+
import { type ReportLocale } from "../locale.ts";
|
|
5
|
+
export declare function ExperimentList({ items, attemptHref, filter, className, locale, }: {
|
|
6
|
+
items: ExperimentListItem[];
|
|
7
|
+
attemptHref: (locator: AttemptLocator) => string;
|
|
8
|
+
filter?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
locale?: ReportLocale;
|
|
11
|
+
}): ReactElement;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { attemptItemReason } from "../format.js";
|
|
3
|
+
import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
|
|
4
|
+
import { AttemptLocatorBadge } from "./AttemptList.js";
|
|
5
|
+
import { MetricCellView } from "./cell.js";
|
|
6
|
+
import { colorClassForKey } from "./colors.js";
|
|
7
|
+
import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
|
|
8
|
+
const verdictOrder = ["passed", "failed", "errored", "skipped"];
|
|
9
|
+
function passRateTone(value) {
|
|
10
|
+
if (value === null)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (value >= 0.8)
|
|
13
|
+
return "nre-good";
|
|
14
|
+
if (value >= 0.5)
|
|
15
|
+
return "nre-warn";
|
|
16
|
+
return "nre-bad";
|
|
17
|
+
}
|
|
18
|
+
function formatDate(value, locale) {
|
|
19
|
+
const date = new Date(value);
|
|
20
|
+
if (Number.isNaN(date.valueOf()))
|
|
21
|
+
return value;
|
|
22
|
+
return new Intl.DateTimeFormat(locale === "zh-CN" ? "zh-CN" : "en", {
|
|
23
|
+
month: "short",
|
|
24
|
+
day: "numeric",
|
|
25
|
+
hour: "2-digit",
|
|
26
|
+
minute: "2-digit",
|
|
27
|
+
}).format(date);
|
|
28
|
+
}
|
|
29
|
+
function VerdictSummary({ item, locale }) {
|
|
30
|
+
const parts = verdictOrder
|
|
31
|
+
.filter((verdict) => item.verdicts[verdict] > 0)
|
|
32
|
+
.map((verdict) => `${item.verdicts[verdict]} ${localeText(locale, `verdict.${verdict}`)}`);
|
|
33
|
+
return _jsx("span", { className: "nre-experiment-pill", children: parts.join(" / ") || "—" });
|
|
34
|
+
}
|
|
35
|
+
function ExperimentAttemptRow({ attempt, last, attemptHref, }) {
|
|
36
|
+
const reason = attemptItemReason(attempt);
|
|
37
|
+
return (_jsxs("li", { className: cx("nre-experiment-attempt-row", `nre-eval-${attempt.verdict}`), children: [_jsx("span", { className: "nre-attempt-branch", "aria-hidden": "true", children: last ? "└─" : "├─" }), _jsx("span", { className: "nre-eval-attempt-badges", children: _jsx(AttemptLocatorBadge, { item: attempt, attemptHref: attemptHref }) }), _jsxs("span", { className: "nre-eval-attempt-metrics", children: [formatDurationMs(attempt.durationMs), attempt.costUSD !== undefined && _jsxs(_Fragment, { children: [" \u00B7 ", formatUSD(attempt.costUSD)] })] }), _jsx("span", { className: "nre-eval-reason", children: reason ?? "—" })] }));
|
|
38
|
+
}
|
|
39
|
+
function EvalAttempts({ row, attemptHref, locale, }) {
|
|
40
|
+
return (_jsxs("li", { className: "nre-experiment-eval", children: [_jsxs("div", { className: cx("nre-experiment-eval-header", `nre-eval-${row.verdict}`), children: [_jsx("span", { className: cx("nre-eval-verdict", `nre-verdict-${row.verdict}`), children: verdictMark(row.verdict) }), _jsx("span", { className: "nre-eval-id", children: row.evalId }), _jsx("span", { className: "nre-eval-attempt-count", children: localeText(locale, "overview.attemptsCount", { n: row.attempts.length }) }), _jsx("span", { className: "nre-eval-summary", children: row.verdict === "passed"
|
|
41
|
+
? [formatDurationMs(row.duration.value ?? 0), row.cost.value === null ? undefined : formatUSD(row.cost.value)]
|
|
42
|
+
.filter((value) => value !== undefined)
|
|
43
|
+
.join(" · ")
|
|
44
|
+
: row.reason })] }), _jsx("ul", { className: "nre-experiment-attempts", children: row.attempts.map((attempt, index) => (_jsx(ExperimentAttemptRow, { attempt: attempt, last: index === row.attempts.length - 1, attemptHref: attemptHref }, attempt.locator))) })] }));
|
|
45
|
+
}
|
|
46
|
+
function Flags({ flags, locale }) {
|
|
47
|
+
if (!flags || Object.keys(flags).length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
return (_jsxs("div", { className: "nre-experiment-flags", children: [_jsx("span", { children: localeText(locale, "experimentList.flags") }), Object.entries(flags).map(([key, value]) => (_jsxs("b", { children: [key, "=", String(value)] }, key)))] }));
|
|
50
|
+
}
|
|
51
|
+
function ExperimentRow({ item, attemptHref, locale, }) {
|
|
52
|
+
return (_jsxs("details", { className: "nre-experiment-entry", children: [_jsxs("summary", { className: "nre-experiment-summary", children: [_jsxs("span", { className: "nre-experiment-name", "data-sort-value": item.experimentId, children: [_jsx("b", { className: cx("nre-experiment-id", "nre-key", colorClassForKey(item.experimentId)), children: item.experimentId }), _jsxs("small", { children: [localeText(locale, "overview.evalsCount", { n: item.evals }), item.attempts > item.evals ? ` · ${localeText(locale, "overview.attemptsCount", { n: item.attempts })}` : "", ` · ${formatDate(item.lastRunAt, locale)}`] })] }), _jsx("span", { "data-sort-value": item.model ?? "", children: item.model ?? localeText(locale, "experimentList.defaultModel") }), _jsx("span", { "data-sort-value": item.agent, children: item.agent }), _jsx("span", { className: "nre-num", "data-sort-value": item.duration.value ?? "", children: _jsx(MetricCellView, { cell: item.duration, locale: locale }) }), _jsx("span", { className: cx("nre-num", passRateTone(item.passRate.value)), "data-sort-value": item.passRate.value ?? "", children: _jsx(MetricCellView, { cell: item.passRate, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.tokens.value ?? "", children: _jsx(MetricCellView, { cell: item.tokens, locale: locale }) }), _jsx("span", { className: "nre-num", "data-sort-value": item.cost.value ?? "", children: _jsx(MetricCellView, { cell: item.cost, locale: locale }) }), _jsx("span", { "data-sort-value": item.verdicts.passed, children: _jsx(VerdictSummary, { item: item, locale: locale }) })] }), _jsxs("div", { className: "nre-experiment-detail", children: [_jsx(Flags, { flags: item.flags, locale: locale }), _jsx("ul", { className: "nre-experiment-evals", children: item.evalRows.map((row) => (_jsx(EvalAttempts, { row: row, attemptHref: attemptHref, locale: locale }, row.evalId))) })] })] }));
|
|
53
|
+
}
|
|
54
|
+
export function ExperimentList({ items, attemptHref, filter = false, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
55
|
+
const labels = [
|
|
56
|
+
localeText(locale, "experimentList.experiment"),
|
|
57
|
+
localeText(locale, "table.model"),
|
|
58
|
+
localeText(locale, "table.agent"),
|
|
59
|
+
localeText(locale, "experimentList.avgDuration"),
|
|
60
|
+
localeText(locale, "experimentList.passRate"),
|
|
61
|
+
localeText(locale, "experimentList.tokens"),
|
|
62
|
+
localeText(locale, "experimentList.estimatedCost"),
|
|
63
|
+
localeText(locale, "experimentList.result"),
|
|
64
|
+
];
|
|
65
|
+
const board = (_jsxs("div", { className: "nre-experiment-table", children: [_jsx("div", { className: "nre-experiment-head", children: labels.map((label, index) => (_jsx("button", { type: "button", "data-nre-experiment-sort": index, className: index === 4 ? "nre-sort-desc" : undefined, children: label }, label))) }), items.length === 0 && _jsx("p", { className: "nre-experiment-list-empty", children: localeText(locale, "attemptList.empty") }), items.map((item) => (_jsx(ExperimentRow, { item: item, attemptHref: attemptHref, locale: locale }, item.experimentId)))] }));
|
|
66
|
+
return (_jsxs("div", { className: cx("nre", "nre-experiment-list", filter && "nre-experiment-table-wrap", className), children: [filter && (_jsx("input", { className: "nre-filter", "data-nre-experiment-filter": "", type: "search", placeholder: localeText(locale, "experimentList.filterPlaceholder") })), board] }));
|
|
67
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { GroupSummaryData } from "../types.ts";
|
|
3
|
+
import { type ReportLocale } from "../locale.ts";
|
|
4
|
+
export declare function GroupSummary({ data, className, locale, }: {
|
|
5
|
+
data: GroupSummaryData;
|
|
6
|
+
className?: string;
|
|
7
|
+
locale?: ReportLocale;
|
|
8
|
+
}): ReactElement;
|
|
@@ -0,0 +1,8 @@
|
|
|
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, formatUSD } from "./format.js";
|
|
5
|
+
export function GroupSummary({ data, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
6
|
+
const missing = _jsx("span", { className: "nre-missing", children: localeText(locale, "cell.missing") });
|
|
7
|
+
return (_jsxs("div", { className: cx("nre", "nre-group-summary", className), children: [_jsxs("dl", { className: "nre-group-kpis", children: [_jsxs("div", { className: "nre-group-kpi nre-group-kpi-rate", children: [_jsx("dt", { children: localeText(locale, "overview.passRate") }), _jsx("dd", { children: _jsx(MetricCellView, { cell: data.passRate, locale: locale }) })] }), _jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "groupSummary.experiments") }), _jsx("dd", { children: data.experiments })] }), _jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "overview.evals") }), _jsx("dd", { children: data.evals })] }), _jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "overview.attempts") }), _jsx("dd", { children: data.attempts })] }), _jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "verdict.failed") }), _jsx("dd", { className: "nre-verdict-failed", children: data.verdicts.failed })] }), data.verdicts.errored > 0 && (_jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "verdict.errored") }), _jsx("dd", { className: "nre-verdict-errored", children: data.verdicts.errored })] })), _jsxs("div", { className: "nre-group-kpi", children: [_jsx("dt", { children: localeText(locale, "overview.totalCost") }), _jsx("dd", { children: data.totalCostUSD === null ? missing : formatUSD(data.totalCostUSD) })] })] }), data.lastRunAt && (_jsx("p", { className: "nre-group-summary-time", children: localeText(locale, "latestRun", { run: data.lastRunAt }) }))] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { MatrixData } from "../types.ts";
|
|
3
|
+
import type { AttemptLocator } from "../../results/locator.ts";
|
|
4
|
+
import { type ReportLocale } from "../locale.ts";
|
|
5
|
+
export declare function MetricBars({ data, attemptHref, className, locale, }: {
|
|
6
|
+
data: MatrixData;
|
|
7
|
+
attemptHref?: (locator: AttemptLocator) => string;
|
|
8
|
+
className?: string;
|
|
9
|
+
locale?: ReportLocale;
|
|
10
|
+
}): ReactElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, resolveMetricLabel } from "../locale.js";
|
|
3
|
+
import { colorClassForKey, seriesClassForKey } from "./colors.js";
|
|
4
|
+
import { cx } from "./format.js";
|
|
5
|
+
const WIDTH = 640;
|
|
6
|
+
const HEIGHT = 320;
|
|
7
|
+
const PLOT = { left: 16, right: WIDTH - 16, top: 28, bottom: HEIGHT - 40 };
|
|
8
|
+
export function MetricBars({ data, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
9
|
+
// 稀疏 cells → 首次出现顺序的组/系列键 + 查找表
|
|
10
|
+
const groupKeys = [];
|
|
11
|
+
const seriesKeys = [];
|
|
12
|
+
const byPosition = new Map();
|
|
13
|
+
for (const entry of data.cells) {
|
|
14
|
+
if (!groupKeys.includes(entry.row))
|
|
15
|
+
groupKeys.push(entry.row);
|
|
16
|
+
if (!seriesKeys.includes(entry.column))
|
|
17
|
+
seriesKeys.push(entry.column);
|
|
18
|
+
byPosition.set(JSON.stringify([entry.row, entry.column]), entry.cell);
|
|
19
|
+
}
|
|
20
|
+
const metricLabel = resolveMetricLabel(data.metric.label, locale, data.metric.key);
|
|
21
|
+
const better = data.metric.better ?? "higher";
|
|
22
|
+
const values = data.cells.map((c) => c.cell.value).filter((v) => v !== null);
|
|
23
|
+
const maxValue = values.length > 0 ? Math.max(...values) : 0;
|
|
24
|
+
// 条高刻度:% 的天然域是 [0,1],其余以全图最大值为满条
|
|
25
|
+
const ratioOf = (value) => (data.metric.unit === "%" ? Math.min(1, Math.max(0, value)) : maxValue === 0 ? 0 : value / maxValue);
|
|
26
|
+
const groupWidth = (PLOT.right - PLOT.left) / Math.max(1, groupKeys.length);
|
|
27
|
+
const barWidth = Math.min(36, (groupWidth - 16) / Math.max(1, seriesKeys.length));
|
|
28
|
+
const plotHeight = PLOT.bottom - PLOT.top;
|
|
29
|
+
return (_jsxs("figure", { className: cx("nre", "nre-metric-bars", className), children: [_jsxs("svg", { className: "nre-bars-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${metricLabel} by ${data.rows} × ${data.columns}`, children: [groupKeys.map((group, gi) => {
|
|
30
|
+
const x0 = PLOT.left + gi * groupWidth;
|
|
31
|
+
// 组内按值排序,方向随 better(缺数据的系列不画柱)
|
|
32
|
+
const entries = seriesKeys
|
|
33
|
+
.map((series) => ({ series, cell: byPosition.get(JSON.stringify([group, series])) }))
|
|
34
|
+
.filter((e) => e.cell !== undefined && e.cell.value !== null)
|
|
35
|
+
.sort((a, b) => better === "lower" ? a.cell.value - b.cell.value : b.cell.value - a.cell.value);
|
|
36
|
+
const innerWidth = entries.length * barWidth;
|
|
37
|
+
const startX = x0 + (groupWidth - innerWidth) / 2;
|
|
38
|
+
return (_jsxs("g", { className: "nre-bars-group", "data-group": group, children: [entries.map(({ series, cell }, si) => {
|
|
39
|
+
const h = Math.max(1, ratioOf(cell.value) * plotHeight);
|
|
40
|
+
const x = startX + si * barWidth;
|
|
41
|
+
const y = PLOT.bottom - h;
|
|
42
|
+
const title = `${group} · ${series}: ${cell.display}(${cell.samples}/${cell.total})`;
|
|
43
|
+
const rect = (_jsx("rect", { className: cx("nre-bar", seriesClassForKey(series)), x: x + 2, y: y, width: barWidth - 4, height: h, children: _jsx("title", { children: title }) }));
|
|
44
|
+
const locator = cell.refs[0];
|
|
45
|
+
return (_jsxs("g", { children: [attemptHref && locator ? _jsx("a", { href: attemptHref(locator), children: rect }) : rect, _jsx("text", { className: "nre-bar-value", x: x + barWidth / 2, y: y - 4, textAnchor: "middle", children: cell.samples < cell.total ? `${cell.display} ${cell.samples}/${cell.total}` : cell.display })] }, series));
|
|
46
|
+
}), _jsx("text", { className: "nre-bars-group-label", x: x0 + groupWidth / 2, y: HEIGHT - 20, textAnchor: "middle", children: group })] }, group));
|
|
47
|
+
}), _jsx("line", { className: "nre-bars-baseline", x1: PLOT.left, y1: PLOT.bottom, x2: PLOT.right, y2: PLOT.bottom })] }), _jsxs("figcaption", { className: "nre-bars-legend", children: [_jsxs("span", { className: "nre-bars-metric", children: [metricLabel, data.metric.unit && _jsxs("span", { className: "nre-unit", children: ["(", data.metric.unit, ")"] })] }), seriesKeys.map((series) => (_jsx("span", { className: cx("nre-legend-key", "nre-key", colorClassForKey(series)), children: series }, series)))] })] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { LineData } from "../types.ts";
|
|
3
|
+
import { type ReportLocale } from "../locale.ts";
|
|
4
|
+
export declare function MetricLine({ data, pointHref, className, locale, }: {
|
|
5
|
+
data: LineData;
|
|
6
|
+
pointHref?: (row: LineData["rows"][number]) => string;
|
|
7
|
+
className?: string;
|
|
8
|
+
locale?: ReportLocale;
|
|
9
|
+
}): ReactElement;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveMetricLabel } from "../locale.js";
|
|
3
|
+
import { seriesClassForKey } from "./colors.js";
|
|
4
|
+
import { cx } from "./format.js";
|
|
5
|
+
const WIDTH = 640;
|
|
6
|
+
const HEIGHT = 360;
|
|
7
|
+
const PLOT = { left: 64, right: WIDTH - 140, top: 24, bottom: HEIGHT - 56 };
|
|
8
|
+
function linearScale(values, pixelLo, pixelHi, invert) {
|
|
9
|
+
const lo = Math.min(...values);
|
|
10
|
+
const hi = Math.max(...values);
|
|
11
|
+
const span = hi - lo || 2;
|
|
12
|
+
const padded = { lo: lo - (hi - lo ? span * 0.08 : 1), hi: hi + (hi - lo ? span * 0.08 : 1) };
|
|
13
|
+
const scale = (v) => {
|
|
14
|
+
let t = (v - padded.lo) / (padded.hi - padded.lo);
|
|
15
|
+
if (invert)
|
|
16
|
+
t = 1 - t;
|
|
17
|
+
return pixelLo + t * (pixelHi - pixelLo);
|
|
18
|
+
};
|
|
19
|
+
return { lo, hi, scale };
|
|
20
|
+
}
|
|
21
|
+
export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
22
|
+
const missing = data.rows.filter((r) => r.x === null || r.y.value === null);
|
|
23
|
+
const drawableRows = data.rows.filter((r) => r.x !== null && r.y.value !== null);
|
|
24
|
+
const yLabel = resolveMetricLabel(data.y.label, locale, data.y.key);
|
|
25
|
+
const missingNote = missing.length > 0 ? (_jsx("p", { className: "nre-line-missing", title: missing.map((r) => r.key).join(", "), children: countText(locale, "pointsMissing", missing.length) })) : null;
|
|
26
|
+
if (drawableRows.length === 0) {
|
|
27
|
+
return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsx("p", { className: "nre-missing", children: localeText(locale, "cell.missing") }), missingNote] }));
|
|
28
|
+
}
|
|
29
|
+
const xScale = linearScale(drawableRows.map((r) => r.x), PLOT.left, PLOT.right, false);
|
|
30
|
+
// y 像素轴向下增长:higher 高值在上;lower 反向后「好」的一端同样在上
|
|
31
|
+
const yScale = linearScale(drawableRows.map((r) => r.y.value), PLOT.bottom, PLOT.top, data.y.better === "lower");
|
|
32
|
+
const points = drawableRows.map((r) => ({
|
|
33
|
+
key: r.key,
|
|
34
|
+
series: r.series,
|
|
35
|
+
xValue: r.x,
|
|
36
|
+
yValue: r.y.value,
|
|
37
|
+
title: `${r.key}\n${data.x.label}: ${r.xDisplay}\n${yLabel}: ${r.y.display}(${r.y.samples}/${r.y.total})`,
|
|
38
|
+
px: xScale.scale(r.x),
|
|
39
|
+
py: yScale.scale(r.y.value),
|
|
40
|
+
}));
|
|
41
|
+
// 同系列的点按 x 排序连线;系列名标在最右点旁
|
|
42
|
+
const seriesOrder = [];
|
|
43
|
+
const bySeries = new Map();
|
|
44
|
+
for (const p of points) {
|
|
45
|
+
const key = p.series ?? "";
|
|
46
|
+
if (!bySeries.has(key)) {
|
|
47
|
+
bySeries.set(key, []);
|
|
48
|
+
seriesOrder.push(key);
|
|
49
|
+
}
|
|
50
|
+
bySeries.get(key).push(p);
|
|
51
|
+
}
|
|
52
|
+
for (const list of bySeries.values())
|
|
53
|
+
list.sort((a, b) => a.xValue - b.xValue);
|
|
54
|
+
const xTicks = xScale.lo === xScale.hi ? [xScale.lo] : [xScale.lo, xScale.hi];
|
|
55
|
+
const yTicks = yScale.lo === yScale.hi ? [yScale.lo] : [yScale.lo, yScale.hi];
|
|
56
|
+
const xDisplayFor = (value) => drawableRows.find((r) => r.x === value)?.xDisplay ?? String(value);
|
|
57
|
+
const yDisplayFor = (value) => drawableRows.find((r) => r.y.value === value)?.y.display ?? String(value);
|
|
58
|
+
return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsxs("svg", { className: "nre-line-svg", viewBox: `0 0 ${WIDTH} ${HEIGHT}`, role: "img", "aria-label": `${yLabel} by ${data.x.label}`, children: [_jsx("rect", { className: "nre-line-plot", x: PLOT.left, y: PLOT.top, width: PLOT.right - PLOT.left, height: PLOT.bottom - PLOT.top, fill: "none" }), _jsxs("text", { className: "nre-line-xlabel", x: (PLOT.left + PLOT.right) / 2, y: HEIGHT - 8, textAnchor: "middle", children: [data.x.label, data.x.unit ? `(${data.x.unit})` : ""] }), _jsxs("text", { className: "nre-line-ylabel", x: 16, y: (PLOT.top + PLOT.bottom) / 2, textAnchor: "middle", transform: `rotate(-90 16 ${(PLOT.top + PLOT.bottom) / 2})`, children: [yLabel, data.y.unit ? `(${data.y.unit})` : ""] }), xTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: xScale.scale(v), y: PLOT.bottom + 16, textAnchor: "middle", children: xDisplayFor(v) }, `x${v}`))), yTicks.map((v) => (_jsx("text", { className: "nre-line-tick", x: PLOT.left - 6, y: yScale.scale(v) + 4, textAnchor: "end", children: yDisplayFor(v) }, `y${v}`))), seriesOrder.map((series) => {
|
|
59
|
+
const list = bySeries.get(series);
|
|
60
|
+
const seriesClass = series === "" ? "nre-series-none" : seriesClassForKey(series);
|
|
61
|
+
const labelAt = list.reduce((a, b) => (b.px > a.px ? b : a));
|
|
62
|
+
return (_jsxs("g", { className: cx("nre-line-series", seriesClass), "data-series": series || undefined, children: [list.length > 1 && (_jsx("polyline", { className: "nre-line-path", points: list.map((p) => `${p.px},${p.py}`).join(" "), fill: "none" })), series !== "" && (_jsx("text", { className: "nre-line-series-label", x: labelAt.px + 8, y: labelAt.py + 4, children: series }))] }, series || "(single)"));
|
|
63
|
+
}), points.map((p, i) => {
|
|
64
|
+
const circle = (_jsx("circle", { className: cx("nre-line-point", p.series !== undefined ? seriesClassForKey(p.series) : "nre-series-none"), "data-key": p.key, cx: p.px, cy: p.py, r: 4, children: _jsx("title", { children: p.title }) }));
|
|
65
|
+
const row = drawableRows[i];
|
|
66
|
+
return pointHref ? (_jsx("a", { className: "nre-line-point-link", href: pointHref(row), children: circle }, `${p.key}:${i}`)) : (_jsx("g", { children: circle }, `${p.key}:${i}`));
|
|
67
|
+
})] }), missingNote] }));
|
|
68
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { MatrixData } from "../types.ts";
|
|
3
|
+
import type { AttemptLocator } from "../../results/locator.ts";
|
|
4
|
+
import { type ReportLocale } from "../locale.ts";
|
|
5
|
+
export declare function MetricMatrix({ data, attemptHref, className, locale, }: {
|
|
6
|
+
data: MatrixData;
|
|
7
|
+
attemptHref?: (locator: AttemptLocator) => string;
|
|
8
|
+
className?: string;
|
|
9
|
+
locale?: ReportLocale;
|
|
10
|
+
}): ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_REPORT_LOCALE, resolveMetricLabel } from "../locale.js";
|
|
3
|
+
import { MetricCellView } from "./cell.js";
|
|
4
|
+
import { colorClassForKey } from "./colors.js";
|
|
5
|
+
import { cx } from "./format.js";
|
|
6
|
+
export function MetricMatrix({ data, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
|
|
7
|
+
// 稀疏 cells → 首次出现顺序的行/列键 + 查找表;组件只整理形状,不碰数值
|
|
8
|
+
const rowKeys = [];
|
|
9
|
+
const columnKeys = [];
|
|
10
|
+
// 键用 \u0000 拼接:行/列键都是用户可见 id,普通分隔符可能撞键
|
|
11
|
+
const byPosition = new Map();
|
|
12
|
+
for (const entry of data.cells) {
|
|
13
|
+
if (!rowKeys.includes(entry.row))
|
|
14
|
+
rowKeys.push(entry.row);
|
|
15
|
+
if (!columnKeys.includes(entry.column))
|
|
16
|
+
columnKeys.push(entry.column);
|
|
17
|
+
byPosition.set(`${entry.row}\u0000${entry.column}`, entry.cell);
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("table", { className: cx("nre", "nre-metric-matrix", className), children: [_jsxs("caption", { className: "nre-matrix-caption", children: [resolveMetricLabel(data.metric.label, locale, data.metric.key), data.metric.unit && _jsxs("span", { className: "nre-unit", children: ["(", data.metric.unit, ")"] }), _jsxs("span", { className: "nre-matrix-axes", children: [data.rows, " \u00D7 ", data.columns] })] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.rows }), columnKeys.map((column) => (_jsx("th", { scope: "col", className: cx("nre-col-key", "nre-key", colorClassForKey(column)), children: column }, column)))] }) }), _jsx("tbody", { children: rowKeys.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: "nre-row-key", children: row }), columnKeys.map((column) => {
|
|
20
|
+
const cell = byPosition.get(`${row}\u0000${column}`);
|
|
21
|
+
return (_jsx("td", { className: cx("nre-td", !cell && "nre-td-empty"), children: cell ? _jsx(MetricCellView, { cell: cell, attemptHref: attemptHref, locale: locale }) : null }, column));
|
|
22
|
+
})] }, row))) })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ScatterData } from "../types.ts";
|
|
3
|
+
import { type ReportLocale } from "../locale.ts";
|
|
4
|
+
export declare function MetricScatter({ data, pointHref, className, locale, }: {
|
|
5
|
+
data: ScatterData;
|
|
6
|
+
pointHref?: (row: ScatterData["rows"][number]) => string;
|
|
7
|
+
className?: string;
|
|
8
|
+
locale?: ReportLocale;
|
|
9
|
+
}): ReactElement;
|