niceeval 0.5.3 → 0.6.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 (344) hide show
  1. package/INDEX.md +55 -0
  2. package/dist/agents/types.d.ts +317 -0
  3. package/dist/context/types.d.ts +335 -0
  4. package/dist/i18n/core.d.ts +11 -0
  5. package/dist/i18n/en.d.ts +181 -0
  6. package/dist/i18n/index.d.ts +5 -0
  7. package/dist/i18n/zh-CN.d.ts +183 -0
  8. package/dist/o11y/execution-tree.d.ts +103 -0
  9. package/dist/o11y/otlp/parse.d.ts +3 -0
  10. package/dist/o11y/otlp/receiver.d.ts +21 -0
  11. package/dist/o11y/otlp/select.d.ts +22 -0
  12. package/dist/o11y/otlp/turn-otel.d.ts +43 -0
  13. package/dist/o11y/types.d.ts +190 -0
  14. package/dist/report/aggregate.d.ts +57 -0
  15. package/dist/report/aggregate.js +212 -0
  16. package/dist/report/built-ins/cost-pass-rate-comparison.d.ts +1 -0
  17. package/dist/report/built-ins/cost-pass-rate-comparison.js +17 -0
  18. package/dist/report/built-ins/index.d.ts +1 -0
  19. package/dist/report/built-ins/index.js +2 -0
  20. package/dist/report/components.d.ts +178 -0
  21. package/dist/report/components.js +132 -0
  22. package/dist/report/compute.d.ts +106 -0
  23. package/dist/report/compute.js +618 -0
  24. package/dist/report/flag.d.ts +6 -0
  25. package/dist/report/flag.js +8 -0
  26. package/dist/report/format.d.ts +32 -0
  27. package/dist/report/format.js +126 -0
  28. package/dist/report/index.d.ts +19 -0
  29. package/dist/report/index.js +30 -0
  30. package/dist/report/load.d.ts +12 -0
  31. package/dist/report/load.js +56 -0
  32. package/dist/report/locale.d.ts +83 -0
  33. package/dist/report/locale.js +160 -0
  34. package/dist/report/metrics.d.ts +21 -0
  35. package/dist/report/metrics.js +115 -0
  36. package/dist/report/primitives.d.ts +64 -0
  37. package/dist/report/primitives.js +113 -0
  38. package/dist/report/react/AttemptList.d.ts +23 -0
  39. package/dist/report/react/AttemptList.js +20 -0
  40. package/dist/report/react/DeltaTable.d.ts +8 -0
  41. package/dist/report/react/DeltaTable.js +24 -0
  42. package/dist/report/react/EvalList.d.ts +10 -0
  43. package/dist/report/react/EvalList.js +0 -0
  44. package/dist/report/react/ExperimentList.d.ts +10 -0
  45. package/dist/report/react/ExperimentList.js +15 -0
  46. package/dist/report/react/GroupSummary.d.ts +8 -0
  47. package/dist/report/react/GroupSummary.js +8 -0
  48. package/dist/report/react/MetricBars.d.ts +10 -0
  49. package/dist/report/react/MetricBars.js +48 -0
  50. package/dist/report/react/MetricLine.d.ts +9 -0
  51. package/dist/report/react/MetricLine.js +68 -0
  52. package/dist/report/react/MetricMatrix.d.ts +10 -0
  53. package/dist/report/react/MetricMatrix.js +23 -0
  54. package/dist/report/react/MetricScatter.d.ts +9 -0
  55. package/dist/report/react/MetricScatter.js +100 -0
  56. package/dist/report/react/MetricTable.d.ts +11 -0
  57. package/dist/report/react/MetricTable.js +26 -0
  58. package/dist/report/react/RunOverview.d.ts +8 -0
  59. package/dist/report/react/RunOverview.js +12 -0
  60. package/dist/report/react/Scoreboard.d.ts +8 -0
  61. package/dist/report/react/Scoreboard.js +26 -0
  62. package/dist/report/react/cell.d.ts +9 -0
  63. package/dist/report/react/cell.js +9 -0
  64. package/dist/report/react/chart-math.d.ts +14 -0
  65. package/dist/report/react/chart-math.js +68 -0
  66. package/dist/report/react/colors.d.ts +14 -0
  67. package/dist/report/react/colors.js +45 -0
  68. package/dist/report/react/fixtures.d.ts +19 -0
  69. package/dist/report/react/fixtures.js +393 -0
  70. package/dist/report/react/format.d.ts +3 -0
  71. package/dist/report/react/format.js +7 -0
  72. package/dist/report/react/index.d.ts +6 -0
  73. package/dist/report/react/index.js +14 -0
  74. package/dist/report/report.d.ts +24 -0
  75. package/dist/report/report.js +49 -0
  76. package/dist/report/text/faces.d.ts +29 -0
  77. package/dist/report/text/faces.js +503 -0
  78. package/dist/report/text/layout.d.ts +75 -0
  79. package/dist/report/text/layout.js +173 -0
  80. package/dist/report/text/plot.d.ts +37 -0
  81. package/dist/report/text/plot.js +81 -0
  82. package/dist/report/text/table.d.ts +8 -0
  83. package/dist/report/text/table.js +86 -0
  84. package/dist/report/tree.d.ts +99 -0
  85. package/dist/report/tree.js +228 -0
  86. package/dist/report/types.d.ts +420 -0
  87. package/dist/report/types.js +4 -0
  88. package/dist/report/web.d.ts +15 -0
  89. package/dist/report/web.js +37 -0
  90. package/dist/results/annotated-source.d.ts +61 -0
  91. package/dist/results/attempt-evidence.d.ts +69 -0
  92. package/dist/results/attempt-source.d.ts +15 -0
  93. package/dist/results/locator.d.ts +75 -0
  94. package/dist/results/locator.js +0 -0
  95. package/dist/results/select.d.ts +45 -0
  96. package/dist/results/select.js +230 -0
  97. package/dist/results/source-hash.d.ts +9 -0
  98. package/dist/results/types.d.ts +204 -0
  99. package/dist/runner/eval-source.d.ts +22 -0
  100. package/dist/runner/fingerprint.d.ts +23 -0
  101. package/dist/runner/types.d.ts +332 -0
  102. package/dist/sandbox/docker-stream.d.ts +24 -0
  103. package/dist/sandbox/docker.d.ts +84 -0
  104. package/dist/sandbox/e2b.d.ts +31 -0
  105. package/dist/sandbox/errors.d.ts +4 -0
  106. package/dist/sandbox/local-files.d.ts +6 -0
  107. package/dist/sandbox/paths.d.ts +4 -0
  108. package/dist/sandbox/registry.d.ts +13 -0
  109. package/dist/sandbox/resolve.d.ts +40 -0
  110. package/dist/sandbox/retry.d.ts +10 -0
  111. package/dist/sandbox/shell.d.ts +11 -0
  112. package/dist/sandbox/source-files.d.ts +13 -0
  113. package/dist/sandbox/types.d.ts +203 -0
  114. package/dist/sandbox/vercel.d.ts +37 -0
  115. package/dist/scoring/types.d.ts +70 -0
  116. package/dist/shared/aggregate.d.ts +29 -0
  117. package/dist/shared/aggregate.js +55 -0
  118. package/dist/shared/types.d.ts +27 -0
  119. package/dist/shared/verdict.d.ts +27 -0
  120. package/dist/shared/verdict.js +34 -0
  121. package/dist/tty-line.d.ts +6 -0
  122. package/dist/types.d.ts +7 -0
  123. package/dist/util.d.ts +22 -0
  124. package/docs-site/zh/concepts/adapter.mdx +9 -4
  125. package/docs-site/zh/concepts/assert.mdx +8 -8
  126. package/docs-site/zh/concepts/evals.mdx +5 -5
  127. package/docs-site/zh/concepts/experiment.mdx +3 -1
  128. package/docs-site/zh/concepts/judge.mdx +9 -9
  129. package/docs-site/zh/concepts/overview.mdx +2 -2
  130. package/docs-site/zh/concepts/tier.mdx +6 -6
  131. package/docs-site/zh/example/claude-code-codex-plugin.mdx +9 -5
  132. package/docs-site/zh/example/claude-code-codex-skill.mdx +12 -7
  133. package/docs-site/zh/guides/agent-feedback-loop.mdx +235 -78
  134. package/docs-site/zh/guides/connect-otel.mdx +3 -3
  135. package/docs-site/zh/guides/connect-your-agent.mdx +2 -2
  136. package/docs-site/zh/guides/custom-reports.mdx +196 -36
  137. package/docs-site/zh/guides/experiments.mdx +7 -0
  138. package/docs-site/zh/guides/fixtures.mdx +1 -1
  139. package/docs-site/zh/guides/official-adapters.mdx +31 -9
  140. package/docs-site/zh/guides/publish-report.mdx +4 -4
  141. package/docs-site/zh/guides/report-components.mdx +194 -55
  142. package/docs-site/zh/guides/reporters.mdx +2 -2
  143. package/docs-site/zh/guides/results-data.mdx +35 -34
  144. package/docs-site/zh/guides/runner.mdx +2 -2
  145. package/docs-site/zh/guides/sandbox-agent.mdx +10 -5
  146. package/docs-site/zh/guides/sandbox-providers.mdx +102 -0
  147. package/docs-site/zh/guides/viewing-results.mdx +199 -79
  148. package/docs-site/zh/guides/write-experiment.mdx +23 -1
  149. package/docs-site/zh/guides/write-send.mdx +2 -2
  150. package/docs-site/zh/index.mdx +4 -3
  151. package/docs-site/zh/introduction.mdx +2 -1
  152. package/docs-site/zh/quickstart.mdx +5 -3
  153. package/docs-site/zh/reference/builtin-agents.mdx +38 -13
  154. package/docs-site/zh/reference/capabilities.mdx +1 -1
  155. package/docs-site/zh/reference/cli.mdx +36 -13
  156. package/docs-site/zh/reference/define-agent.mdx +24 -12
  157. package/docs-site/zh/reference/define-config.mdx +1 -1
  158. package/docs-site/zh/reference/define-eval.mdx +3 -3
  159. package/docs-site/zh/reference/events.mdx +7 -1
  160. package/docs-site/zh/reference/expect.mdx +3 -3
  161. package/package.json +10 -6
  162. package/src/agents/bub.ts +134 -43
  163. package/src/agents/claude-code.test.ts +152 -0
  164. package/src/agents/claude-code.ts +127 -13
  165. package/src/agents/codex.test.ts +192 -0
  166. package/src/agents/codex.ts +151 -12
  167. package/src/agents/index.ts +11 -3
  168. package/src/agents/manifest.ts +41 -0
  169. package/src/agents/plugin-config.test.ts +94 -0
  170. package/src/agents/shared.ts +33 -2
  171. package/src/agents/skills.test.ts +214 -0
  172. package/src/agents/skills.ts +304 -0
  173. package/src/agents/streaming.ts +5 -5
  174. package/src/agents/types.ts +62 -2
  175. package/src/cli.ts +74 -47
  176. package/src/context/context.test.ts +20 -2
  177. package/src/context/context.ts +3 -0
  178. package/src/context/control-flow.ts +1 -1
  179. package/src/context/session.test.ts +92 -1
  180. package/src/context/session.ts +26 -1
  181. package/src/context/types.ts +4 -4
  182. package/src/define.test.ts +82 -0
  183. package/src/define.ts +72 -11
  184. package/src/expect/index.ts +5 -5
  185. package/src/i18n/en.ts +36 -15
  186. package/src/i18n/zh-CN.ts +39 -21
  187. package/src/index.ts +1 -1
  188. package/src/o11y/execution-tree.test.ts +452 -0
  189. package/src/o11y/execution-tree.ts +367 -0
  190. package/src/o11y/otlp/receiver.ts +1 -1
  191. package/src/o11y/otlp/select.ts +7 -3
  192. package/src/o11y/parsers/claude-code.test.ts +175 -0
  193. package/src/o11y/parsers/claude-code.ts +32 -0
  194. package/src/o11y/types.ts +6 -1
  195. package/src/report/aggregate.ts +26 -20
  196. package/src/report/built-in-user-parity.test.tsx +643 -0
  197. package/src/report/built-ins/cost-pass-rate-comparison.tsx +23 -0
  198. package/src/report/built-ins/index.ts +2 -0
  199. package/src/report/components.tsx +223 -50
  200. package/src/report/compute.ts +358 -53
  201. package/src/report/dual-render.test.tsx +1125 -0
  202. package/src/report/flag.ts +1 -1
  203. package/src/report/format.ts +50 -2
  204. package/src/report/index.ts +48 -14
  205. package/src/report/load.ts +1 -1
  206. package/src/report/locale.ts +206 -0
  207. package/src/report/metrics.ts +39 -15
  208. package/src/report/primitives.tsx +100 -2
  209. package/src/report/react/AttemptList.tsx +115 -0
  210. package/src/report/react/DeltaTable.tsx +9 -6
  211. package/src/report/react/EvalList.tsx +0 -0
  212. package/src/report/react/ExperimentList.tsx +108 -0
  213. package/src/report/react/GroupSummary.tsx +66 -0
  214. package/src/report/react/MetricBars.tsx +24 -13
  215. package/src/report/react/MetricLine.tsx +21 -21
  216. package/src/report/react/MetricMatrix.tsx +8 -4
  217. package/src/report/react/MetricScatter.tsx +136 -96
  218. package/src/report/react/MetricTable.tsx +115 -15
  219. package/src/report/react/RunOverview.tsx +48 -26
  220. package/src/report/react/Scoreboard.tsx +15 -7
  221. package/src/report/react/cell.tsx +18 -9
  222. package/src/{view/app/lib/chart.ts → report/react/chart-math.ts} +2 -6
  223. package/src/report/react/colors.ts +24 -15
  224. package/src/report/react/enhance.js +129 -0
  225. package/src/report/react/fixtures.ts +163 -34
  226. package/src/report/react/format.ts +1 -1
  227. package/src/report/react/index.tsx +22 -6
  228. package/src/report/react/render.test.tsx +164 -31
  229. package/src/report/react/styles.css +405 -213
  230. package/src/report/report.test.ts +403 -94
  231. package/src/report/report.ts +29 -11
  232. package/src/report/text/faces.ts +303 -95
  233. package/src/report/text/layout.ts +76 -11
  234. package/src/report/text/table.ts +98 -0
  235. package/src/report/tree.ts +103 -20
  236. package/src/report/types.ts +196 -25
  237. package/src/report/web.ts +46 -19
  238. package/src/results/annotated-source.test.ts +146 -0
  239. package/src/results/annotated-source.ts +128 -0
  240. package/src/results/attempt-evidence.test.ts +158 -0
  241. package/src/results/attempt-evidence.ts +158 -0
  242. package/src/results/attempt-source.ts +48 -0
  243. package/src/results/copy.ts +154 -139
  244. package/src/results/format.ts +54 -47
  245. package/src/results/host-equivalence.test.ts +527 -0
  246. package/src/results/index.ts +56 -14
  247. package/src/results/locator.test.ts +198 -0
  248. package/src/results/locator.ts +0 -0
  249. package/src/results/open.ts +392 -175
  250. package/src/results/results.test.ts +943 -494
  251. package/src/results/select.ts +129 -23
  252. package/src/results/skipped-notice.ts +0 -0
  253. package/src/results/source-hash.ts +28 -0
  254. package/src/results/types.ts +98 -62
  255. package/src/results/writer.ts +304 -176
  256. package/src/runner/attempt.test.ts +170 -0
  257. package/src/runner/attempt.ts +97 -15
  258. package/src/runner/discover.test.ts +65 -0
  259. package/src/runner/discover.ts +6 -2
  260. package/src/runner/eval-source.test.ts +121 -0
  261. package/src/runner/eval-source.ts +45 -0
  262. package/src/runner/fingerprint.ts +54 -1
  263. package/src/runner/remote-sandbox.ts +1 -1
  264. package/src/runner/report.test.ts +6 -8
  265. package/src/runner/report.ts +5 -4
  266. package/src/runner/reporters/artifacts.ts +27 -41
  267. package/src/runner/reporters/braintrust.test.ts +3 -3
  268. package/src/runner/reporters/braintrust.ts +1 -1
  269. package/src/runner/reporters/console.ts +6 -6
  270. package/src/runner/reporters/json.ts +4 -4
  271. package/src/runner/reporters/live.test.ts +56 -0
  272. package/src/runner/reporters/live.ts +36 -10
  273. package/src/runner/reporters/quiet.test.ts +66 -0
  274. package/src/runner/reporters/quiet.ts +49 -0
  275. package/src/runner/reporters/shared.ts +5 -5
  276. package/src/runner/reporters/table.ts +17 -17
  277. package/src/runner/run.ts +61 -102
  278. package/src/runner/types.ts +43 -32
  279. package/src/sandbox/checkpoint.ts +1 -1
  280. package/src/sandbox/docker.ts +15 -2
  281. package/src/sandbox/e2b.ts +11 -5
  282. package/src/sandbox/errors.ts +13 -0
  283. package/src/sandbox/index.ts +3 -3
  284. package/src/sandbox/local-files.ts +1 -1
  285. package/src/sandbox/registry.ts +6 -5
  286. package/src/sandbox/resolve.ts +38 -23
  287. package/src/sandbox/retry.test.ts +68 -0
  288. package/src/sandbox/retry.ts +44 -0
  289. package/src/sandbox/types.ts +69 -28
  290. package/src/sandbox/vercel.ts +17 -3
  291. package/src/scoring/collector.ts +3 -3
  292. package/src/scoring/judge.ts +2 -2
  293. package/src/scoring/scoped.ts +13 -1
  294. package/src/scoring/types.ts +7 -7
  295. package/src/scoring/verdict.ts +4 -4
  296. package/src/shared/aggregate.ts +23 -3
  297. package/src/shared/types.ts +2 -2
  298. package/src/shared/{outcome.ts → verdict.ts} +15 -15
  299. package/src/show/compose.ts +12 -132
  300. package/src/show/index.ts +125 -94
  301. package/src/show/render.ts +660 -160
  302. package/src/show/show.test.ts +472 -253
  303. package/src/source-loc.ts +1 -1
  304. package/src/tty-line.ts +32 -0
  305. package/src/types.ts +2 -2
  306. package/src/util.test.ts +21 -1
  307. package/src/util.ts +5 -1
  308. package/src/view/app/App.tsx +33 -198
  309. package/src/view/app/components/AttemptModal.tsx +6 -6
  310. package/src/view/app/components/CodeView.tsx +2 -2
  311. package/src/view/app/components/CopyControls.tsx +32 -36
  312. package/src/view/app/components/SkippedRunsBanner.tsx +140 -0
  313. package/src/view/app/components/ui/badge.tsx +1 -1
  314. package/src/view/app/components/ui/dialog.tsx +2 -2
  315. package/src/view/app/i18n.ts +40 -31
  316. package/src/view/app/lib/artifact-url.ts +1 -1
  317. package/src/view/app/lib/attempt-route.test.ts +37 -47
  318. package/src/view/app/lib/attempt-route.ts +26 -26
  319. package/src/view/app/lib/rows.ts +9 -112
  320. package/src/view/app/lib/verdict.ts +25 -0
  321. package/src/view/app/main.tsx +9 -12
  322. package/src/view/app/pages/RunsPage.tsx +4 -4
  323. package/src/view/app/pages/TracesPage.tsx +3 -3
  324. package/src/view/app/shared.ts +0 -1
  325. package/src/view/app/types.ts +6 -51
  326. package/src/view/artifact-serving.test.ts +136 -0
  327. package/src/view/client-dist/app.css +1 -1
  328. package/src/view/client-dist/app.js +21 -21
  329. package/src/view/data.test.ts +214 -143
  330. package/src/view/data.ts +166 -120
  331. package/src/view/index.ts +23 -11
  332. package/src/view/server.ts +52 -17
  333. package/src/view/shared/types.ts +22 -31
  334. package/src/view/styles.css +117 -327
  335. package/src/view/view-report.test.ts +146 -98
  336. package/docs-site/zh/guides/sandbox-backends.mdx +0 -75
  337. package/src/report/default-report.tsx +0 -222
  338. package/src/report/dual-face.test.tsx +0 -527
  339. package/src/report/react/CaseList.tsx +0 -70
  340. package/src/view/app/components/CostScoreChart.tsx +0 -147
  341. package/src/view/app/components/ExperimentTable.tsx +0 -284
  342. package/src/view/app/components/GroupSelector.tsx +0 -61
  343. package/src/view/app/components/primitives.tsx +0 -43
  344. 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" | "capabilities">;
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,20 @@
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 { capabilityBadge, cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
5
+ /** locator + 判定符 + 证据能力标记的普通 <a>,AttemptList/EvalList/ExperimentList 共用。 */
6
+ export function AttemptLocatorBadge({ item, attemptHref, }) {
7
+ const caps = capabilityBadge(item.capabilities);
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) }), caps && _jsx("span", { className: "nre-locator-caps", children: caps })] }));
9
+ }
10
+ function AssertionRow({ assertion, locale }) {
11
+ 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 })] }))] }));
12
+ }
13
+ /** 一条 Attempt 的完整卡片:AttemptList 自己的一项,也是 EvalList 展开区里的一行。 */
14
+ export function AttemptRow({ item, attemptHref, locale = DEFAULT_REPORT_LOCALE, }) {
15
+ 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))) }))] }));
16
+ }
17
+ export function AttemptList({ items, total, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
18
+ const remaining = (total ?? items.length) - items.length;
19
+ 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 }) }))] }));
20
+ }
@@ -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,10 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ExperimentListItem } from "../types.ts";
3
+ import type { AttemptLocator } from "../../results/locator.ts";
4
+ import { type ReportLocale } from "../locale.ts";
5
+ export declare function ExperimentList({ items, attemptHref, className, locale, }: {
6
+ items: ExperimentListItem[];
7
+ attemptHref: (locator: AttemptLocator) => string;
8
+ className?: string;
9
+ locale?: ReportLocale;
10
+ }): ReactElement;
@@ -0,0 +1,15 @@
1
+ import { Fragment as _Fragment, 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 { AttemptLocatorBadge } from "./AttemptList.js";
5
+ import { colorClassForKey } from "./colors.js";
6
+ import { cx, formatDurationMs, formatUSD, verdictMark } from "./format.js";
7
+ function EvalRow({ row, attemptHref, }) {
8
+ return (_jsxs("li", { className: cx("nre-experiment-eval-row", `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-badges", children: row.attempts.map((attempt) => (_jsx(AttemptLocatorBadge, { item: attempt, attemptHref: attemptHref }, attempt.locator))) }), row.verdict === "passed" ? (_jsxs("span", { className: "nre-eval-avg", children: [formatDurationMs(row.duration.value ?? 0), row.cost.value !== null && _jsxs(_Fragment, { children: [" \u00B7 ", formatUSD(row.cost.value)] })] })) : (_jsx("span", { className: "nre-eval-reason", children: row.reason }))] }));
9
+ }
10
+ function ExperimentCard({ item, attemptHref, locale, }) {
11
+ return (_jsx("li", { className: "nre-experiment-entry", children: _jsxs("details", { className: "nre-experiment-details", children: [_jsxs("summary", { className: "nre-experiment-summary", children: [_jsx("span", { className: cx("nre-experiment-id", "nre-key", colorClassForKey(item.experimentId)), children: item.experimentId }), _jsx("span", { className: "nre-experiment-agent", children: item.agent }), item.model && _jsx("span", { className: "nre-experiment-model", children: item.model }), _jsx("span", { className: "nre-experiment-cell", children: _jsx(MetricCellView, { cell: item.passRate, attemptHref: attemptHref, locale: locale }) }), _jsx("span", { className: "nre-experiment-cell", children: _jsx(MetricCellView, { cell: item.cost, attemptHref: attemptHref, locale: locale }) }), _jsx("span", { className: "nre-experiment-cell", children: _jsx(MetricCellView, { cell: item.duration, attemptHref: attemptHref, locale: locale }) }), _jsxs("span", { className: "nre-experiment-meta-sub", children: [localeText(locale, "overview.evalsCount", { n: item.evals }), item.attempts > item.evals ? ` · ${localeText(locale, "overview.attemptsCount", { n: item.attempts })}` : "", ` · ${localeText(locale, "latestRun", { run: item.lastRunAt })}`] })] }), _jsx("ul", { className: "nre-experiment-evals", children: item.evalRows.map((row) => (_jsx(EvalRow, { row: row, attemptHref: attemptHref }, row.evalId))) })] }) }));
12
+ }
13
+ export function ExperimentList({ items, attemptHref, className, locale = DEFAULT_REPORT_LOCALE, }) {
14
+ return (_jsxs("div", { className: cx("nre", "nre-experiment-list", className), children: [items.length === 0 && _jsx("p", { className: "nre-experiment-list-empty", children: localeText(locale, "attemptList.empty") }), _jsx("ul", { className: "nre-experiments", children: items.map((item) => (_jsx(ExperimentCard, { item: item, attemptHref: attemptHref, locale: locale }, item.experimentId))) })] }));
15
+ }
@@ -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;