niceeval 0.6.2 → 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.
Files changed (216) hide show
  1. package/INDEX.md +23 -23
  2. package/README.zh.md +6 -6
  3. package/dist/agents/types.d.ts +2 -2
  4. package/dist/i18n/zh-CN.d.ts +3 -3
  5. package/dist/report/aggregate.d.ts +32 -26
  6. package/dist/report/aggregate.js +157 -76
  7. package/dist/report/built-in/index.d.ts +2 -0
  8. package/dist/report/built-in/index.js +8 -0
  9. package/dist/report/components.d.ts +91 -164
  10. package/dist/report/components.js +377 -114
  11. package/dist/report/compute.d.ts +86 -73
  12. package/dist/report/compute.js +592 -432
  13. package/dist/report/flag.d.ts +28 -17
  14. package/dist/report/flag.js +86 -16
  15. package/dist/report/format.d.ts +11 -11
  16. package/dist/report/format.js +17 -15
  17. package/dist/report/index.d.ts +16 -17
  18. package/dist/report/index.js +20 -22
  19. package/dist/report/load.js +3 -2
  20. package/dist/report/locale.d.ts +49 -34
  21. package/dist/report/locale.js +106 -58
  22. package/dist/report/metrics.d.ts +10 -3
  23. package/dist/report/metrics.js +46 -12
  24. package/dist/report/primitives.d.ts +42 -15
  25. package/dist/report/primitives.js +135 -26
  26. package/dist/report/react/AttemptList.d.ts +10 -8
  27. package/dist/report/react/AttemptList.js +18 -10
  28. package/dist/report/react/DeltaTable.js +19 -18
  29. package/dist/report/react/EvalList.d.ts +3 -3
  30. package/dist/report/react/EvalList.js +0 -0
  31. package/dist/report/react/ExperimentComparison.d.ts +4 -2
  32. package/dist/report/react/ExperimentComparison.js +5 -4
  33. package/dist/report/react/ExperimentList.d.ts +3 -3
  34. package/dist/report/react/ExperimentList.js +16 -15
  35. package/dist/report/react/MetricBars.js +5 -4
  36. package/dist/report/react/MetricLine.js +12 -5
  37. package/dist/report/react/MetricMatrix.js +1 -1
  38. package/dist/report/react/MetricScatter.js +54 -17
  39. package/dist/report/react/MetricTable.js +2 -12
  40. package/dist/report/react/ScopeSummary.d.ts +10 -0
  41. package/dist/report/react/ScopeSummary.js +17 -0
  42. package/dist/report/react/Scoreboard.js +6 -6
  43. package/dist/report/react/cell.js +2 -2
  44. package/dist/report/react/fixtures.d.ts +5 -9
  45. package/dist/report/react/fixtures.js +105 -149
  46. package/dist/report/react/index.d.ts +15 -5
  47. package/dist/report/react/index.js +18 -7
  48. package/dist/report/report.d.ts +137 -20
  49. package/dist/report/report.js +261 -34
  50. package/dist/report/text/faces.d.ts +17 -19
  51. package/dist/report/text/faces.js +225 -157
  52. package/dist/report/text/plot.js +1 -1
  53. package/dist/report/text/table.js +2 -2
  54. package/dist/report/tree.d.ts +90 -40
  55. package/dist/report/tree.js +252 -94
  56. package/dist/report/types.d.ts +245 -300
  57. package/dist/report/types.js +4 -3
  58. package/dist/report/web.d.ts +21 -5
  59. package/dist/report/web.js +42 -16
  60. package/dist/results/select.d.ts +38 -16
  61. package/dist/results/select.js +73 -25
  62. package/dist/results/types.d.ts +38 -14
  63. package/dist/shared/aggregate.d.ts +3 -2
  64. package/dist/shared/aggregate.js +5 -4
  65. package/docs-site/zh/README.md +44 -0
  66. package/docs-site/zh/examples/ai-agent-application.mdx +63 -0
  67. package/docs-site/zh/examples/coding-agent-extensions.mdx +57 -0
  68. package/docs-site/zh/examples/index.mdx +50 -0
  69. package/docs-site/zh/{concepts → explanation}/adapter.mdx +11 -11
  70. package/docs-site/zh/{concepts → explanation}/assert.mdx +7 -7
  71. package/docs-site/zh/{concepts → explanation}/drive.mdx +8 -8
  72. package/docs-site/zh/{concepts → explanation}/evals.mdx +4 -4
  73. package/docs-site/zh/{concepts → explanation}/experiment.mdx +8 -8
  74. package/docs-site/zh/{concepts → explanation}/hitl.mdx +8 -8
  75. package/docs-site/zh/{concepts → explanation}/judge.mdx +5 -5
  76. package/docs-site/zh/{concepts → explanation}/overview.mdx +5 -5
  77. package/docs-site/zh/{guides → explanation}/runner.mdx +1 -1
  78. package/docs-site/zh/{concepts → explanation}/tier.mdx +6 -6
  79. package/docs-site/zh/{guides → how-to}/agent-feedback-loop.mdx +7 -7
  80. package/docs-site/zh/{guides → how-to}/authoring.mdx +2 -2
  81. package/docs-site/zh/{guides → how-to}/connect-otel.mdx +6 -6
  82. package/docs-site/zh/{guides → how-to}/connect-your-agent.mdx +18 -18
  83. package/docs-site/zh/{guides → how-to}/custom-reports.mdx +6 -6
  84. package/docs-site/zh/{guides → how-to}/experiments.mdx +3 -3
  85. package/docs-site/zh/{guides → how-to}/publish-report.mdx +2 -2
  86. package/docs-site/zh/{guides → how-to}/sandbox-agent.mdx +2 -2
  87. package/docs-site/zh/{guides → how-to}/sandbox-providers.mdx +1 -1
  88. package/docs-site/zh/{guides → how-to}/viewing-results.mdx +6 -6
  89. package/docs-site/zh/{guides → how-to}/write-experiment.mdx +3 -3
  90. package/docs-site/zh/{guides → how-to}/write-send.mdx +13 -13
  91. package/docs-site/zh/index.mdx +23 -25
  92. package/docs-site/zh/introduction.mdx +8 -8
  93. package/docs-site/zh/reference/builtin-agents.mdx +5 -5
  94. package/docs-site/zh/reference/capabilities.mdx +6 -6
  95. package/docs-site/zh/reference/cli.mdx +9 -7
  96. package/docs-site/zh/reference/define-agent.mdx +1 -1
  97. package/docs-site/zh/reference/events.mdx +3 -3
  98. package/docs-site/zh/{guides → reference}/official-adapters.mdx +7 -7
  99. package/docs-site/zh/{guides → reference}/report-components.mdx +5 -5
  100. package/docs-site/zh/{guides → reference}/results-data.mdx +5 -5
  101. package/docs-site/zh/{guides → troubleshooting}/debug-sandbox.mdx +2 -2
  102. package/docs-site/zh/{guides → troubleshooting}/debugging.mdx +4 -2
  103. package/docs-site/zh/{quickstart.mdx → tutorials/quickstart.mdx} +5 -17
  104. package/package.json +6 -2
  105. package/src/agents/index.ts +2 -2
  106. package/src/agents/openai-compat.ts +1 -1
  107. package/src/agents/streaming.ts +2 -2
  108. package/src/agents/types.ts +3 -3
  109. package/src/cli.ts +42 -23
  110. package/src/context/context.ts +1 -1
  111. package/src/context/session.test.ts +1 -1
  112. package/src/context/session.ts +1 -1
  113. package/src/i18n/en.ts +18 -16
  114. package/src/i18n/zh-CN.ts +16 -15
  115. package/src/report/aggregate.ts +175 -87
  116. package/src/report/built-in/index.tsx +9 -0
  117. package/src/report/components.tsx +625 -285
  118. package/src/report/compute.ts +717 -515
  119. package/src/report/dual-render.test.tsx +738 -1148
  120. package/src/report/flag.ts +97 -33
  121. package/src/report/format.ts +18 -22
  122. package/src/report/index.ts +113 -58
  123. package/src/report/load.ts +3 -2
  124. package/src/report/locale.ts +120 -69
  125. package/src/report/metrics.ts +42 -12
  126. package/src/report/primitives.tsx +190 -45
  127. package/src/report/react/AttemptList.tsx +32 -20
  128. package/src/report/react/DeltaTable.tsx +63 -45
  129. package/src/report/react/EvalList.tsx +0 -0
  130. package/src/report/react/ExperimentComparison.tsx +12 -7
  131. package/src/report/react/ExperimentList.tsx +38 -26
  132. package/src/report/react/MetricBars.tsx +5 -4
  133. package/src/report/react/MetricLine.tsx +13 -8
  134. package/src/report/react/MetricMatrix.tsx +2 -2
  135. package/src/report/react/MetricScatter.tsx +74 -20
  136. package/src/report/react/MetricTable.tsx +4 -76
  137. package/src/report/react/ScopeSummary.tsx +86 -0
  138. package/src/report/react/Scoreboard.tsx +28 -10
  139. package/src/report/react/cell.tsx +2 -2
  140. package/src/report/react/enhance.js +57 -5
  141. package/src/report/react/fixtures.ts +109 -156
  142. package/src/report/react/index.tsx +24 -39
  143. package/src/report/react/render.test.tsx +139 -104
  144. package/src/report/react/styles.css +181 -91
  145. package/src/report/report.test.ts +761 -1031
  146. package/src/report/report.ts +425 -47
  147. package/src/report/text/faces.ts +257 -164
  148. package/src/report/text/plot.ts +1 -1
  149. package/src/report/text/table.ts +2 -2
  150. package/src/report/tree.ts +362 -104
  151. package/src/report/types.ts +257 -287
  152. package/src/report/web.ts +63 -20
  153. package/src/results/attempt-evidence.test.ts +4 -4
  154. package/src/results/attempt-evidence.ts +5 -5
  155. package/src/results/copy.ts +6 -6
  156. package/src/results/host-equivalence.test.ts +26 -14
  157. package/src/results/index.ts +10 -4
  158. package/src/results/open.ts +8 -4
  159. package/src/results/results.test.ts +4 -3
  160. package/src/results/select.ts +104 -34
  161. package/src/results/types.ts +36 -14
  162. package/src/runner/feedback/human.test.ts +1 -1
  163. package/src/runner/run.ts +1 -1
  164. package/src/sandbox/cli-commands.ts +2 -2
  165. package/src/scoring/judge.test.ts +1 -1
  166. package/src/shared/aggregate.ts +5 -4
  167. package/src/show/compose.ts +50 -67
  168. package/src/show/index.ts +107 -56
  169. package/src/show/render.ts +43 -27
  170. package/src/show/report-host.test.ts +188 -0
  171. package/src/show/report-host.ts +375 -0
  172. package/src/show/show.test.ts +86 -36
  173. package/src/view/app/App.test.tsx +69 -0
  174. package/src/view/app/App.tsx +144 -48
  175. package/src/view/app/components/AttemptModal.tsx +324 -63
  176. package/src/view/app/components/CodeView.tsx +10 -4
  177. package/src/view/app/i18n.ts +31 -17
  178. package/src/view/app/main.tsx +13 -8
  179. package/src/view/app/pages/{RunsPage.tsx → AttemptsPage.tsx} +6 -6
  180. package/src/view/app/types.ts +4 -1
  181. package/src/view/client-dist/app.css +1 -1
  182. package/src/view/client-dist/app.js +14 -14
  183. package/src/view/data.test.ts +9 -3
  184. package/src/view/data.ts +145 -49
  185. package/src/view/index.ts +48 -44
  186. package/src/view/server.ts +35 -15
  187. package/src/view/shared/types.ts +34 -5
  188. package/src/view/styles.css +224 -0
  189. package/src/view/view-report.test.ts +161 -57
  190. package/dist/report/built-ins/experiment-comparison.d.ts +0 -39
  191. package/dist/report/built-ins/experiment-comparison.js +0 -119
  192. package/dist/report/built-ins/index.d.ts +0 -2
  193. package/dist/report/built-ins/index.js +0 -2
  194. package/dist/report/react/GroupSummary.d.ts +0 -8
  195. package/dist/report/react/GroupSummary.js +0 -8
  196. package/dist/report/react/RunOverview.d.ts +0 -8
  197. package/dist/report/react/RunOverview.js +0 -12
  198. package/docs-site/zh/example/ai-agent-application.mdx +0 -152
  199. package/docs-site/zh/example/claude-code-codex-plugin.mdx +0 -167
  200. package/docs-site/zh/example/claude-code-codex-skill.mdx +0 -152
  201. package/docs-site/zh/example/showcase.mdx +0 -39
  202. package/src/report/built-in-user-parity.test.tsx +0 -597
  203. package/src/report/built-ins/experiment-comparison.tsx +0 -179
  204. package/src/report/built-ins/index.ts +0 -7
  205. package/src/report/react/GroupSummary.tsx +0 -66
  206. package/src/report/react/RunOverview.tsx +0 -109
  207. /package/docs-site/zh/{example/tier1-ai-sdk-v7.mdx → examples/integrations/ai-sdk-v7.mdx} +0 -0
  208. /package/docs-site/zh/{example/tier1-claude-sdk.mdx → examples/integrations/claude-sdk.mdx} +0 -0
  209. /package/docs-site/zh/{example/tier1-codex-sdk.mdx → examples/integrations/codex-sdk.mdx} +0 -0
  210. /package/docs-site/zh/{example/tier1-langgraph.mdx → examples/integrations/langgraph.mdx} +0 -0
  211. /package/docs-site/zh/{example/tier1-pi-sdk.mdx → examples/integrations/pi-sdk.mdx} +0 -0
  212. /package/docs-site/zh/{guides → how-to}/ci-integration.mdx +0 -0
  213. /package/docs-site/zh/{guides → how-to}/dataset-fanout.mdx +0 -0
  214. /package/docs-site/zh/{guides → how-to}/fixtures.mdx +0 -0
  215. /package/docs-site/zh/{guides → how-to}/reporters.mdx +0 -0
  216. /package/docs-site/zh/{guides → how-to}/scoring-guide.mdx +0 -0
@@ -1,17 +1,17 @@
1
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";
2
+ import { COMPONENT_RAW_CHILDREN, COMPONENT_ROLE, defineComponent } from "./tree.js";
3
+ import { localeText, resolveLocalizedText } from "./locale.js";
4
+ import { indentBlock, joinColumns, stringWidth, wrapDisplay } from "./text/layout.js";
5
5
  import { renderTableText } from "./text/table.js";
6
6
  function childArray(children) {
7
7
  if (children === null || children === undefined || typeof children === "boolean")
8
8
  return [];
9
- return Array.isArray(children) ? children : [children];
9
+ return Array.isArray(children) ? [...children] : [children];
10
10
  }
11
11
  function cx(...parts) {
12
12
  return parts.filter(Boolean).join(" ");
13
13
  }
14
- /** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行) */
14
+ /** 纵向依次排列:网页是块级堆叠,终端是逐块输出(块间空一行)。两面都按声明序。 */
15
15
  export const Col = defineComponent({
16
16
  web({ children, className }) {
17
17
  return _jsx("div", { className: cx("nre", "nre-col", className), children: children });
@@ -24,10 +24,15 @@ export const Col = defineComponent({
24
24
  },
25
25
  });
26
26
  Col.displayName = "Col";
27
- // Row 的每栏至少留这个宽度,不硬挤;不够就降级纵向
28
- const MIN_COLUMN_WIDTH = 24;
29
27
  const COLUMN_SEPARATOR = " │ ";
30
- /** 并排:网页横向排布,终端字符分栏;终端宽度不够时自动降级为纵向。 */
28
+ /** 一段已渲染文本的自然显示宽度(最长一行)。 */
29
+ function blockWidth(block) {
30
+ return Math.max(...block.split("\n").map((line) => stringWidth(line)), 0);
31
+ }
32
+ /**
33
+ * 并排:web 面横排;text 面在可用宽度装得下全部子块时按显示宽度并排(与 `columns` 工具
34
+ * 同一把尺),装不下时整块退化为纵向堆叠——不截断、不隐藏任何子块。
35
+ */
31
36
  export const Row = defineComponent({
32
37
  web({ children, className }) {
33
38
  return _jsx("div", { className: cx("nre", "nre-row", className), children: children });
@@ -38,44 +43,49 @@ export const Row = defineComponent({
38
43
  return "";
39
44
  if (blocks.length === 1)
40
45
  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");
46
+ const rendered = blocks.map((child) => ctx.render(child)).filter((block) => block.length > 0);
47
+ if (rendered.length === 0)
48
+ return "";
49
+ const widths = rendered.map(blockWidth);
50
+ const total = widths.reduce((sum, w) => sum + w, 0) + COLUMN_SEPARATOR.length * (rendered.length - 1);
51
+ if (total > ctx.width) {
52
+ // 装不下:整块退化为纵向堆叠,与 Col 同一形态
53
+ return rendered.join("\n\n");
48
54
  }
49
- const rendered = blocks.map((child) => ctx.render(child, columnWidth));
50
- return joinColumns(rendered, rendered.map(() => columnWidth), COLUMN_SEPARATOR);
55
+ return joinColumns(rendered, widths, COLUMN_SEPARATOR);
51
56
  },
52
57
  });
53
58
  Row.displayName = "Row";
54
59
  /** 带标题的块:网页是标题层级,终端是标题行加缩进。 */
55
60
  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] }));
61
+ web({ title, children, className }, ctx) {
62
+ return (_jsxs("section", { className: cx("nre", "nre-section", className), children: [_jsx("h2", { className: "nre-section-title", children: resolveLocalizedText(title, ctx.locale) }), children] }));
58
63
  },
59
64
  text({ title, children }, ctx) {
65
+ const heading = resolveLocalizedText(title, ctx.locale);
60
66
  const body = childArray(children)
61
67
  .map((child) => ctx.render(child, ctx.width - 2))
62
68
  .filter((block) => block.length > 0)
63
69
  .join("\n\n");
64
- return body.length > 0 ? `${title}\n${indentBlock(body, " ")}` : title;
70
+ return body.length > 0 ? `${heading}\n${indentBlock(body, " ")}` : heading;
65
71
  },
66
72
  });
67
73
  Section.displayName = "Section";
68
- /** 说明文字:网页是段落,终端是折行文本。 */
74
+ /** 自由文本的显式载体:web 面负责转义,text 面按显示宽度折行。 */
69
75
  export const Text = defineComponent({
70
76
  web({ children, className }) {
71
77
  return _jsx("p", { className: cx("nre", "nre-text", className), children: children });
72
78
  },
73
79
  text({ children }, ctx) {
74
- return wrapDisplay(ctx.render(children), ctx.width).join("\n");
80
+ return wrapDisplay(String(children), ctx.width).join("\n");
75
81
  },
76
82
  });
77
83
  Text.displayName = "Text";
78
- /** 自定义组件的样式随树带走:web 面吐 <style> 标签,text 面渲染为空。 */
84
+ Text[COMPONENT_RAW_CHILDREN] = true;
85
+ /**
86
+ * 注入页级全局 CSS:树位置只决定声明顺序,不限定作用域;text 面零输出。
87
+ * 配置对象形态的报告要全站样式优先用外壳 styles,两条通道注入同一增强层。
88
+ */
79
89
  export const Style = defineComponent({
80
90
  web({ children }) {
81
91
  return _jsx("style", { children: children });
@@ -85,7 +95,101 @@ export const Style = defineComponent({
85
95
  },
86
96
  });
87
97
  Style.displayName = "Style";
98
+ Style[COMPONENT_RAW_CHILDREN] = true;
99
+ /** Tabs 的直接 Tab 子项(数组 / Fragment 已展平;结构合法性由树校验保证)。 */
100
+ function tabEntries(children) {
101
+ const out = [];
102
+ const visit = (node) => {
103
+ if (node === null || node === undefined || typeof node === "boolean")
104
+ return;
105
+ if (Array.isArray(node)) {
106
+ for (const child of node)
107
+ visit(child);
108
+ return;
109
+ }
110
+ if (typeof node === "object" && node !== null && "props" in node) {
111
+ const element = node;
112
+ if (element.type === Symbol.for("react.fragment")) {
113
+ visit(element.props.children);
114
+ return;
115
+ }
116
+ out.push({
117
+ title: element.props.title ?? "",
118
+ children: element.props.children,
119
+ className: element.props.className,
120
+ });
121
+ }
122
+ };
123
+ visit(children);
124
+ return out;
125
+ }
126
+ /**
127
+ * 页内并列视图的可切换块。tab 是页内浏览状态,不是数据边界,也不是宿主寻址单位——
128
+ * 两个渲染面都输出全部 tab 的完整内容:web 静态 HTML 每 tab 一个 <details>(首个默认展开,
129
+ * 渐进增强升级成单选 tab 条,切换不改变数据);text 面按声明序输出带标题分节,不折成索引
130
+ * 也不省略(tab 没有选择器,索引只能是死路)。
131
+ */
132
+ export const Tabs = defineComponent({
133
+ web({ children, className }, ctx) {
134
+ const tabs = tabEntries(children);
135
+ return (_jsx("div", { className: cx("nre", "nre-tabs", className), "data-nre-tabs": true, children: tabs.map((tab, i) => (_jsxs("details", { className: cx("nre-tab", tab.className), open: i === 0, children: [_jsx("summary", { className: "nre-tab-title", children: resolveLocalizedText(tab.title, ctx.locale) }), _jsx("div", { className: "nre-tab-body", children: tab.children })] }, i))) }));
136
+ },
137
+ text({ children }, ctx) {
138
+ const tabs = tabEntries(children);
139
+ return tabs
140
+ .map((tab) => {
141
+ const heading = resolveLocalizedText(tab.title, ctx.locale);
142
+ const body = childArray(tab.children)
143
+ .map((child) => ctx.render(child, ctx.width - 2))
144
+ .filter((block) => block.length > 0)
145
+ .join("\n\n");
146
+ return body.length > 0 ? `${heading}\n${indentBlock(body, " ")}` : heading;
147
+ })
148
+ .join("\n\n");
149
+ },
150
+ });
151
+ Tabs.displayName = "Tabs";
152
+ Tabs[COMPONENT_ROLE] = "tabs";
153
+ /** 只能直接放在 <Tabs> 下;除通用 children / className 外只有 title。不参与路由,没有 id。 */
154
+ export const Tab = defineComponent({
155
+ web({ children, className }) {
156
+ return _jsx("div", { className: cx("nre", "nre-tab-body", className), children: children });
157
+ },
158
+ text({ children }, ctx) {
159
+ return childArray(children)
160
+ .map((child) => ctx.render(child))
161
+ .filter((block) => block.length > 0)
162
+ .join("\n\n");
163
+ },
164
+ });
165
+ Tab.displayName = "Tab";
166
+ Tab[COMPONENT_ROLE] = "tab";
88
167
  const MISSING_MARK = "—";
168
+ /** 列 key 唯一、行 cells 不携带未声明 key、空列拒绝——无类型 JS 输入在渲染前同样校验。 */
169
+ function validateTableProps(props) {
170
+ if (!Array.isArray(props.columns) || props.columns.length === 0) {
171
+ throw new Error("Table needs at least one column: pass columns: [{ key, header }] — an empty column list renders nothing readable.");
172
+ }
173
+ const keys = new Set();
174
+ for (const column of props.columns) {
175
+ if (keys.has(column.key)) {
176
+ throw new Error(`Table column key "${column.key}" is declared twice — column keys address row.cells and must be unique. Rename one column.`);
177
+ }
178
+ keys.add(column.key);
179
+ }
180
+ const rowKeys = new Set();
181
+ for (const row of props.rows) {
182
+ if (rowKeys.has(row.key)) {
183
+ throw new Error(`Table row key "${row.key}" is declared twice — row keys are the row identity and must be unique.`);
184
+ }
185
+ rowKeys.add(row.key);
186
+ for (const cellKey of Object.keys(row.cells)) {
187
+ if (!keys.has(cellKey)) {
188
+ throw new Error(`Table row "${row.key}" has a cell "${cellKey}" that no column declares. Declare the column in columns, or drop the stray cell.`);
189
+ }
190
+ }
191
+ }
192
+ }
89
193
  /**
90
194
  * 自定义表的标准件:列由报告作者定,格子是算好的显示值,两个面各自排整齐。
91
195
  *
@@ -98,16 +202,21 @@ const MISSING_MARK = "—";
98
202
  * 这个组件上:自定义表和官方表用同一把尺子。
99
203
  */
100
204
  export const Table = defineComponent({
101
- web({ columns, rows, locale, className }, ctx) {
205
+ web(props, ctx) {
206
+ validateTableProps(props);
207
+ const { columns, rows, locale, className } = props;
102
208
  const chrome = locale ?? ctx.locale;
103
209
  const hasLocator = rows.some((row) => row.locator !== undefined);
104
210
  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) => {
211
+ 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: resolveLocalizedText(column.header, chrome) }, 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
212
  const value = row.cells[column.key];
107
213
  const missing = value === null || value === undefined;
108
214
  return (_jsx("td", { className: alignClass(column.align), children: missing ? _jsx("span", { className: "nre-missing", children: MISSING_MARK }) : value }, column.key));
109
215
  }), 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
216
  },
111
- text: renderTableText,
217
+ text(props, ctx) {
218
+ validateTableProps(props);
219
+ return renderTableText(props, ctx);
220
+ },
112
221
  });
113
222
  Table.displayName = "Table";
@@ -5,19 +5,21 @@ import { type ReportLocale } from "../locale.ts";
5
5
  /** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
6
6
  export declare function AttemptLocatorBadge({ item, attemptHref, }: {
7
7
  item: Pick<AttemptListItem, "locator" | "verdict">;
8
- attemptHref: (locator: AttemptLocator) => string;
8
+ attemptHref?: (locator: AttemptLocator) => string;
9
9
  }): ReactElement;
10
- /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
11
- export declare function AttemptRow({ item, attemptHref, }: {
10
+ /** failureSummary + moreFailures 的展示形态:摘要原样,+N 计数由 moreFailures 驱动。 */
11
+ export declare function failureSummaryText(item: Pick<AttemptListItem, "failureSummary" | "moreFailures">, locale: ReportLocale): string | null;
12
+ /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
13
+ export declare function AttemptRow({ item, attemptHref, locale, }: {
12
14
  item: AttemptListItem;
13
- attemptHref: (locator: AttemptLocator) => string;
15
+ attemptHref?: (locator: AttemptLocator) => string;
14
16
  locale?: ReportLocale;
15
17
  }): ReactElement;
16
- export declare function AttemptList({ items, total, attemptHref, className, locale, }: {
17
- items: AttemptListItem[];
18
- /** items 被 slice 时的原始数量;如实显示还剩多少条没展示。 */
18
+ export declare function AttemptList({ data, total, attemptHref, className, locale, }: {
19
+ data: readonly AttemptListItem[];
20
+ /** data 被 slice 时的原始数量;如实显示还剩多少条没展示。 */
19
21
  total?: number;
20
- attemptHref: (locator: AttemptLocator) => string;
22
+ attemptHref?: (locator: AttemptLocator) => string;
21
23
  className?: string;
22
24
  locale?: ReportLocale;
23
25
  }): ReactElement;
@@ -1,18 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
3
- import { attemptItemReason } from "../format.js";
2
+ import { DEFAULT_REPORT_LOCALE, countText, localeText } from "../locale.js";
4
3
  import { colorClassForKey } from "./colors.js";
5
4
  import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
5
+ const DEFAULT_ATTEMPT_HREF = (locator) => `#/attempt/${locator}`;
6
6
  /** locator + 判定符的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
7
- export function AttemptLocatorBadge({ item, attemptHref, }) {
7
+ export function AttemptLocatorBadge({ item, attemptHref = DEFAULT_ATTEMPT_HREF, }) {
8
8
  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) })] }));
9
9
  }
10
- /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
11
- export function AttemptRow({ item, attemptHref, }) {
12
- const reason = attemptItemReason(item);
13
- 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) })] }), reason && _jsx("p", { className: "nre-attempt-result", children: reason })] }));
10
+ /** failureSummary + moreFailures 的展示形态:摘要原样,+N 计数由 moreFailures 驱动。 */
11
+ export function failureSummaryText(item, locale) {
12
+ if (item.failureSummary === null)
13
+ return null;
14
+ return item.moreFailures > 0
15
+ ? `${item.failureSummary} · ${countText(locale, "entityList.moreFailures", item.moreFailures)}`
16
+ : item.failureSummary;
14
17
  }
15
- export function AttemptList({ items, total, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
16
- const remaining = (total ?? items.length) - items.length;
17
- 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 }) }))] }));
18
+ /** 一条 Attempt 的比较卡片;完整 assertions 通过 locator 下钻,不在列表内展开。 */
19
+ export function AttemptRow({ item, attemptHref = DEFAULT_ATTEMPT_HREF, locale = DEFAULT_REPORT_LOCALE, }) {
20
+ const reason = failureSummaryText(item, locale);
21
+ 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 !== null && _jsx("span", { className: "nre-attempt-cost", children: formatUSD(item.costUSD) })] }), reason && _jsx("p", { className: "nre-attempt-result", children: reason })] }));
22
+ }
23
+ export function AttemptList({ data, total, attemptHref = DEFAULT_ATTEMPT_HREF, className, locale = DEFAULT_REPORT_LOCALE, }) {
24
+ const remaining = (total ?? data.length) - data.length;
25
+ return (_jsxs("section", { className: cx("nre", "nre-attempt-list", className), children: [data.length === 0 && _jsx("p", { className: "nre-attempt-list-empty", children: localeText(locale, "attemptList.empty") }), _jsx("ul", { className: "nre-attempts", children: data.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 }) }))] }));
18
26
  }
@@ -1,24 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, localeText, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, localeText, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { MetricCellView } from "./cell.js";
4
4
  import { colorClassForKey } from "./colors.js";
5
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
- }
6
+ const OUTCOME_CLASS = {
7
+ improved: "nre-delta-good",
8
+ regressed: "nre-delta-bad",
9
+ unchanged: "nre-delta-flat",
10
+ unavailable: "nre-delta-missing",
11
+ };
17
12
  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))) })] }));
13
+ if (data.rows.length === 0) {
14
+ return (_jsx("div", { className: cx("nre", "nre-delta-table-empty", className), children: _jsx("p", { className: "nre-missing", children: localeText(locale, "delta.empty", { experiments: data.experiments ?? 0 }) }) }));
15
+ }
16
+ 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) => {
17
+ const label = resolveLocalizedText(row.label, locale);
18
+ return (_jsxs("tr", { children: [_jsxs("th", { scope: "row", className: "nre-pair", children: [_jsx("span", { className: cx("nre-row-key", "nre-key", colorClassForKey(label)), children: label }), _jsxs("span", { className: "nre-pair-ids", children: [row.a.key, " \u2192 ", row.b.key] })] }), 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", OUTCOME_CLASS[cell.outcome]), "data-outcome": cell.outcome, children: [_jsx("span", { className: "nre-delta-tag", children: "\u0394" }), cell.delta === null ? (_jsx("span", { className: "nre-missing", children: localeText(locale, "cell.missing") })) : (resolveLocalizedText(cell.display, locale))] })] }, col.key));
23
+ })] }, row.key));
24
+ }) })] }));
24
25
  }
@@ -2,9 +2,9 @@ import type { ReactElement } from "react";
2
2
  import type { AttemptLocator } from "../../results/locator.ts";
3
3
  import type { EvalListItem } from "../types.ts";
4
4
  import { type ReportLocale } from "../locale.ts";
5
- export declare function EvalList({ items, attemptHref, className, locale, }: {
6
- items: EvalListItem[];
7
- attemptHref: (locator: AttemptLocator) => string;
5
+ export declare function EvalList({ data, attemptHref, className, locale, }: {
6
+ data: readonly EvalListItem[];
7
+ attemptHref?: (locator: AttemptLocator) => string;
8
8
  className?: string;
9
9
  locale?: ReportLocale;
10
10
  }): ReactElement;
Binary file
@@ -1,8 +1,10 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ExperimentComparisonData } from "../built-ins/experiment-comparison.tsx";
2
+ import type { ExperimentComparisonData } from "../types.ts";
3
3
  import { type ReportLocale } from "../locale.ts";
4
- export declare function ExperimentComparisonView({ data, className, locale, }: {
4
+ import type { AttemptLocator } from "../../results/locator.ts";
5
+ export declare function ExperimentComparisonView({ data, className, locale, attemptHref, }: {
5
6
  data: ExperimentComparisonData;
6
7
  className?: string;
7
8
  locale?: ReportLocale;
9
+ attemptHref?: (locator: AttemptLocator) => string;
8
10
  }): ReactElement;
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
3
- import { ExperimentList, MetricScatter } from "../components.js";
4
- import { GroupSummary } from "./GroupSummary.js";
3
+ import { ScopeSummary } from "./ScopeSummary.js";
4
+ import { MetricScatter } from "./MetricScatter.js";
5
+ import { ExperimentList } from "./ExperimentList.js";
5
6
  import { cx } from "./format.js";
6
- export function ExperimentComparisonView({ data, className, locale = DEFAULT_REPORT_LOCALE, }) {
7
+ export function ExperimentComparisonView({ data, className, locale = DEFAULT_REPORT_LOCALE, attemptHref, }) {
7
8
  if (data.groups.length === 0) {
8
9
  return (_jsx("div", { className: cx("nre", "nre-experiment-comparison", className), children: _jsx("p", { className: "nre-experiment-groups-empty", children: localeText(locale, "experimentComparison.empty") }) }));
9
10
  }
10
- return (_jsxs("div", { className: cx("nre", "nre-experiment-comparison", className), "data-nre-experiment-groups": true, children: [_jsx("div", { className: "nre-experiment-group-tabs", role: "tablist", "aria-label": localeText(locale, "experimentComparison.groups"), children: data.groups.map((group, index) => (_jsxs("div", { className: "nre-experiment-group-tab", role: "tab", tabIndex: index === 0 ? 0 : -1, "aria-selected": index === 0 ? "true" : "false", "aria-label": localeText(locale, "experimentComparison.selectGroup", { group: group.key }), "data-nre-experiment-group-select": index, children: [_jsx("strong", { className: "nre-experiment-group-name", children: group.key }), _jsx(GroupSummary, { data: group.summary, locale: locale })] }, group.key))) }), _jsx("div", { className: "nre-experiment-group-panels", children: data.groups.map((group, index) => (_jsxs("details", { className: "nre-experiment-group-panel", "data-nre-experiment-group-panel": index, role: "tabpanel", open: index === 0, children: [_jsx("summary", { children: group.key }), _jsx(MetricScatter, { data: group.scatter, locale: locale }), _jsx(ExperimentList, { items: group.experiments, filter: true, locale: locale, relativeTo: group.key })] }, group.key))) })] }));
11
+ return (_jsxs("div", { className: cx("nre", "nre-experiment-comparison", className), "data-nre-experiment-groups": true, children: [_jsx("div", { className: "nre-experiment-group-tabs", role: "tablist", "aria-label": localeText(locale, "experimentComparison.groups"), children: data.groups.map((group, index) => (_jsxs("div", { className: "nre-experiment-group-tab", role: "tab", tabIndex: index === 0 ? 0 : -1, "aria-selected": index === 0 ? "true" : "false", "aria-label": localeText(locale, "experimentComparison.selectGroup", { group: group.key }), "data-nre-experiment-group-select": index, children: [_jsx("strong", { className: "nre-experiment-group-name", children: group.key }), _jsx(ScopeSummary, { data: group.summary, locale: locale })] }, group.key))) }), _jsx("div", { className: "nre-experiment-group-panels", children: data.groups.map((group, index) => (_jsxs("details", { className: "nre-experiment-group-panel", "data-nre-experiment-group-panel": index, role: "tabpanel", open: index === 0, children: [_jsx("summary", { children: group.key }), _jsx(MetricScatter, { data: group.scatter, locale: locale }), _jsx(ExperimentList, { data: group.experiments, filter: true, locale: locale, relativeTo: group.key, attemptHref: attemptHref })] }, group.key))) })] }));
11
12
  }
@@ -2,9 +2,9 @@ import type { ReactElement } from "react";
2
2
  import type { AttemptLocator } from "../../results/locator.ts";
3
3
  import type { ExperimentListItem } from "../types.ts";
4
4
  import { type ReportLocale } from "../locale.ts";
5
- export declare function ExperimentList({ items, attemptHref, filter, className, locale, relativeTo, }: {
6
- items: ExperimentListItem[];
7
- attemptHref: (locator: AttemptLocator) => string;
5
+ export declare function ExperimentList({ data, attemptHref, filter, className, locale, relativeTo, }: {
6
+ data: readonly ExperimentListItem[];
7
+ attemptHref?: (locator: AttemptLocator) => string;
8
8
  filter?: boolean;
9
9
  className?: string;
10
10
  locale?: ReportLocale;
@@ -1,10 +1,11 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { attemptItemReason, experimentDisplayName } from "../format.js";
2
+ import { experimentDisplayName } from "../format.js";
3
3
  import { DEFAULT_REPORT_LOCALE, localeText } from "../locale.js";
4
- import { AttemptLocatorBadge } from "./AttemptList.js";
4
+ import { AttemptLocatorBadge, failureSummaryText } from "./AttemptList.js";
5
5
  import { MetricCellView } from "./cell.js";
6
6
  import { colorClassForKey } from "./colors.js";
7
7
  import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
8
+ const DEFAULT_ATTEMPT_HREF = (locator) => `#/attempt/${locator}`;
8
9
  const verdictOrder = ["passed", "failed", "errored", "skipped"];
9
10
  function passRateTone(value) {
10
11
  if (value === null)
@@ -28,28 +29,28 @@ function formatDate(value, locale) {
28
29
  }
29
30
  function VerdictSummary({ item, locale }) {
30
31
  const parts = verdictOrder
31
- .filter((verdict) => item.verdicts[verdict] > 0)
32
- .map((verdict) => `${item.verdicts[verdict]} ${localeText(locale, `verdict.${verdict}`)}`);
32
+ .filter((verdict) => item.evalVerdicts[verdict] > 0)
33
+ .map((verdict) => `${item.evalVerdicts[verdict]} ${localeText(locale, `verdict.${verdict}`)}`);
33
34
  return _jsx("span", { className: "nre-experiment-pill", children: parts.join(" / ") || "—" });
34
35
  }
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 ?? "—" })] }));
36
+ function ExperimentAttemptRow({ attempt, last, attemptHref, locale, }) {
37
+ const reason = failureSummaryText(attempt, locale);
38
+ 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 !== null && _jsxs(_Fragment, { children: [" \u00B7 ", formatUSD(attempt.costUSD)] })] }), _jsx("span", { className: "nre-eval-reason", children: reason ?? "—" })] }));
38
39
  }
39
40
  function EvalAttempts({ row, attemptHref, locale, }) {
40
- const duration = row.duration.value === null ? localeText(locale, "cell.missing") : formatDurationMs(row.duration.value);
41
- const cost = row.cost.value === null ? localeText(locale, "cell.missing") : formatUSD(row.cost.value);
42
- 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 }) }), _jsxs("span", { className: "nre-eval-rollup", children: [localeText(locale, "entityList.average", { value: duration }), " · ", localeText(locale, "entityList.average", { value: cost })] })] }), _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))) })] }));
41
+ const duration = row.durationMs.value === null ? localeText(locale, "cell.missing") : formatDurationMs(row.durationMs.value);
42
+ const cost = row.costUSD.value === null ? localeText(locale, "cell.missing") : formatUSD(row.costUSD.value);
43
+ 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 }) }), _jsxs("span", { className: "nre-eval-rollup", children: [localeText(locale, "entityList.average", { value: duration }), " · ", localeText(locale, "entityList.average", { value: cost })] })] }), _jsx("ul", { className: "nre-experiment-attempts", children: row.attempts.map((attempt, index) => (_jsx(ExperimentAttemptRow, { attempt: attempt, last: index === row.attempts.length - 1, attemptHref: attemptHref, locale: locale }, attempt.locator))) })] }));
43
44
  }
44
45
  function Flags({ flags, locale }) {
45
46
  if (!flags || Object.keys(flags).length === 0)
46
47
  return null;
47
- 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)))] }));
48
+ 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, "=", typeof value === "string" ? value : JSON.stringify(value)] }, key)))] }));
48
49
  }
49
50
  function ExperimentRow({ item, attemptHref, locale, relativeTo, }) {
50
- 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: experimentDisplayName(item.experimentId, relativeTo) }), _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))) })] })] }));
51
+ 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: experimentDisplayName(item.experimentId, relativeTo) }), _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.durationMs.value ?? "", children: _jsx(MetricCellView, { cell: item.durationMs, locale: locale }) }), _jsx("span", { className: cx("nre-num", passRateTone(item.endToEndPassRate.value)), "data-sort-value": item.endToEndPassRate.value ?? "", children: _jsx(MetricCellView, { cell: item.endToEndPassRate, 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.costUSD.value ?? "", children: _jsx(MetricCellView, { cell: item.costUSD, locale: locale }) }), _jsx("span", { "data-sort-value": item.evalVerdicts.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))) })] })] }));
51
52
  }
52
- export function ExperimentList({ items, attemptHref, filter = false, className, locale = DEFAULT_REPORT_LOCALE, relativeTo, }) {
53
+ export function ExperimentList({ data, attemptHref = DEFAULT_ATTEMPT_HREF, filter = false, className, locale = DEFAULT_REPORT_LOCALE, relativeTo, }) {
53
54
  const labels = [
54
55
  localeText(locale, "experimentList.experiment"),
55
56
  localeText(locale, "table.model"),
@@ -57,9 +58,9 @@ export function ExperimentList({ items, attemptHref, filter = false, className,
57
58
  localeText(locale, "experimentList.avgDuration"),
58
59
  localeText(locale, "experimentList.passRate"),
59
60
  localeText(locale, "experimentList.tokens"),
60
- localeText(locale, "experimentList.estimatedCost"),
61
+ localeText(locale, "experimentList.cost"),
61
62
  localeText(locale, "experimentList.result"),
62
63
  ];
63
- 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, relativeTo: relativeTo }, item.experimentId)))] }));
64
+ 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))) }), data.length === 0 && _jsx("p", { className: "nre-experiment-list-empty", children: localeText(locale, "attemptList.empty") }), data.map((item) => (_jsx(ExperimentRow, { item: item, attemptHref: attemptHref, locale: locale, relativeTo: relativeTo }, item.experimentId)))] }));
64
65
  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] }));
65
66
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { colorClassForKey, seriesClassForKey } from "./colors.js";
4
4
  import { cx } from "./format.js";
5
5
  const WIDTH = 640;
@@ -26,7 +26,7 @@ export function MetricBars({ data, attemptHref, className, locale = DEFAULT_REPO
26
26
  const groupWidth = (PLOT.right - PLOT.left) / Math.max(1, groupKeys.length);
27
27
  const barWidth = Math.min(36, (groupWidth - 16) / Math.max(1, seriesKeys.length));
28
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) => {
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.rowDimension} × ${data.columnDimension}`, children: [groupKeys.map((group, gi) => {
30
30
  const x0 = PLOT.left + gi * groupWidth;
31
31
  // 组内按值排序,方向随 better(缺数据的系列不画柱)
32
32
  const entries = seriesKeys
@@ -39,10 +39,11 @@ export function MetricBars({ data, attemptHref, className, locale = DEFAULT_REPO
39
39
  const h = Math.max(1, ratioOf(cell.value) * plotHeight);
40
40
  const x = startX + si * barWidth;
41
41
  const y = PLOT.bottom - h;
42
- const title = `${group} · ${series}: ${cell.display}(${cell.samples}/${cell.total})`;
42
+ const display = resolveLocalizedText(cell.display, locale);
43
+ const title = `${group} · ${series}: ${display}(${cell.samples}/${cell.total})`;
43
44
  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
45
  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
+ 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 ? `${display} ${cell.samples}/${cell.total}` : display })] }, series));
46
47
  }), _jsx("text", { className: "nre-bars-group-label", x: x0 + groupWidth / 2, y: HEIGHT - 20, textAnchor: "middle", children: group })] }, group));
47
48
  }), _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
49
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveMetricLabel } from "../locale.js";
2
+ import { DEFAULT_REPORT_LOCALE, countText, localeText, resolveLocalizedText, resolveMetricLabel } from "../locale.js";
3
3
  import { seriesClassForKey } from "./colors.js";
4
4
  import { cx } from "./format.js";
5
5
  const WIDTH = 640;
@@ -22,6 +22,7 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
22
22
  const missing = data.rows.filter((r) => r.x === null || r.y.value === null);
23
23
  const drawableRows = data.rows.filter((r) => r.x !== null && r.y.value !== null);
24
24
  const yLabel = resolveMetricLabel(data.y.label, locale, data.y.key);
25
+ const xLabel = resolveMetricLabel(data.x.label, locale, data.x.key);
25
26
  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
27
  if (drawableRows.length === 0) {
27
28
  return (_jsxs("figure", { className: cx("nre", "nre-metric-line", className), children: [_jsx("p", { className: "nre-missing", children: localeText(locale, "cell.missing") }), missingNote] }));
@@ -34,7 +35,7 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
34
35
  series: r.series,
35
36
  xValue: r.x,
36
37
  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
+ title: `${r.key}\n${xLabel}: ${resolveLocalizedText(r.xDisplay, locale)}\n${yLabel}: ${resolveLocalizedText(r.y.display, locale)}(${r.y.samples}/${r.y.total})`,
38
39
  px: xScale.scale(r.x),
39
40
  py: yScale.scale(r.y.value),
40
41
  }));
@@ -53,9 +54,15 @@ export function MetricLine({ data, pointHref, className, locale = DEFAULT_REPORT
53
54
  list.sort((a, b) => a.xValue - b.xValue);
54
55
  const xTicks = xScale.lo === xScale.hi ? [xScale.lo] : [xScale.lo, xScale.hi];
55
56
  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) => {
57
+ const xDisplayFor = (value) => {
58
+ const row = drawableRows.find((r) => r.x === value);
59
+ return row === undefined ? String(value) : resolveLocalizedText(row.xDisplay, locale);
60
+ };
61
+ const yDisplayFor = (value) => {
62
+ const row = drawableRows.find((r) => r.y.value === value);
63
+ return row === undefined ? String(value) : resolveLocalizedText(row.y.display, locale);
64
+ };
65
+ 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 ${xLabel}`, 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: [xLabel, 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
66
  const list = bySeries.get(series);
60
67
  const seriesClass = series === "" ? "nre-series-none" : seriesClassForKey(series);
61
68
  const labelAt = list.reduce((a, b) => (b.px > a.px ? b : a));
@@ -16,7 +16,7 @@ export function MetricMatrix({ data, attemptHref, className, locale = DEFAULT_RE
16
16
  columnKeys.push(entry.column);
17
17
  byPosition.set(`${entry.row}\u0000${entry.column}`, entry.cell);
18
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) => {
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.rowDimension, " \u00D7 ", data.columnDimension] })] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "nre-dimension", children: data.rowDimension }), 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
20
  const cell = byPosition.get(`${row}\u0000${column}`);
21
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
22
  })] }, row))) })] }));